Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Andrew Vasquez | fa90c54 | 2005-10-27 11:10:08 -0700 | [diff] [blame] | 2 | * QLogic Fibre Channel HBA Driver |
Armen Baloyan | bd21eaf | 2014-04-11 16:54:24 -0400 | [diff] [blame] | 3 | * Copyright (c) 2003-2014 QLogic Corporation |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | * |
Andrew Vasquez | fa90c54 | 2005-10-27 11:10:08 -0700 | [diff] [blame] | 5 | * See LICENSE.qla2xxx for copyright and licensing details. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | */ |
| 7 | #include "qla_def.h" |
| 8 | |
| 9 | #include <linux/moduleparam.h> |
| 10 | #include <linux/vmalloc.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | #include <linux/delay.h> |
Christoph Hellwig | 39a1124 | 2006-02-14 18:46:22 +0100 | [diff] [blame] | 12 | #include <linux/kthread.h> |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 13 | #include <linux/mutex.h> |
Andrew Vasquez | 3420d36 | 2009-10-13 15:16:45 -0700 | [diff] [blame] | 14 | #include <linux/kobject.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 15 | #include <linux/slab.h> |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 16 | #include <linux/blk-mq-pci.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | #include <scsi/scsi_tcq.h> |
| 18 | #include <scsi/scsicam.h> |
| 19 | #include <scsi/scsi_transport.h> |
| 20 | #include <scsi/scsi_transport_fc.h> |
| 21 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 22 | #include "qla_target.h" |
| 23 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 24 | /* |
| 25 | * Driver version |
| 26 | */ |
| 27 | char qla2x00_version_str[40]; |
| 28 | |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 29 | static int apidev_major; |
| 30 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | /* |
| 32 | * SRB allocation cache |
| 33 | */ |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 34 | struct kmem_cache *srb_cachep; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 36 | /* |
| 37 | * CT6 CTX allocation cache |
| 38 | */ |
| 39 | static struct kmem_cache *ctx_cachep; |
Saurav Kashyap | 3ce8866 | 2011-07-14 12:00:12 -0700 | [diff] [blame] | 40 | /* |
| 41 | * error level for logging |
| 42 | */ |
| 43 | int ql_errlev = ql_log_all; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 44 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 45 | static int ql2xenableclass2; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 46 | module_param(ql2xenableclass2, int, S_IRUGO|S_IRUSR); |
| 47 | MODULE_PARM_DESC(ql2xenableclass2, |
| 48 | "Specify if Class 2 operations are supported from the very " |
| 49 | "beginning. Default is 0 - class 2 not supported."); |
| 50 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 51 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | int ql2xlogintimeout = 20; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 53 | module_param(ql2xlogintimeout, int, S_IRUGO); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 54 | MODULE_PARM_DESC(ql2xlogintimeout, |
| 55 | "Login timeout value in seconds."); |
| 56 | |
Andrew Vasquez | a7b6184 | 2007-05-07 07:42:59 -0700 | [diff] [blame] | 57 | int qlport_down_retry; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 58 | module_param(qlport_down_retry, int, S_IRUGO); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | MODULE_PARM_DESC(qlport_down_retry, |
Jesper Juhl | 900d9f9 | 2006-06-30 02:33:07 -0700 | [diff] [blame] | 60 | "Maximum number of command retries to a port that returns " |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | "a PORT-DOWN status."); |
| 62 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 63 | int ql2xplogiabsentdevice; |
| 64 | module_param(ql2xplogiabsentdevice, int, S_IRUGO|S_IWUSR); |
| 65 | MODULE_PARM_DESC(ql2xplogiabsentdevice, |
| 66 | "Option to enable PLOGI to devices that are not present after " |
Jesper Juhl | 900d9f9 | 2006-06-30 02:33:07 -0700 | [diff] [blame] | 67 | "a Fabric scan. This is needed for several broken switches. " |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | "Default is 0 - no PLOGI. 1 - perfom PLOGI."); |
| 69 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | int ql2xloginretrycount = 0; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 71 | module_param(ql2xloginretrycount, int, S_IRUGO); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 72 | MODULE_PARM_DESC(ql2xloginretrycount, |
| 73 | "Specify an alternate value for the NVRAM login retry count."); |
| 74 | |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 75 | int ql2xallocfwdump = 1; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 76 | module_param(ql2xallocfwdump, int, S_IRUGO); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 77 | MODULE_PARM_DESC(ql2xallocfwdump, |
| 78 | "Option to enable allocation of memory for a firmware dump " |
| 79 | "during HBA initialization. Memory allocation requirements " |
| 80 | "vary by ISP type. Default is 1 - allocate memory."); |
| 81 | |
Andrew Vasquez | 11010fe | 2006-10-06 09:54:59 -0700 | [diff] [blame] | 82 | int ql2xextended_error_logging; |
Andrew Vasquez | 27d9403 | 2007-03-12 10:41:30 -0700 | [diff] [blame] | 83 | module_param(ql2xextended_error_logging, int, S_IRUGO|S_IWUSR); |
Joe Carnuccio | a2b3e01 | 2016-07-06 11:14:21 -0400 | [diff] [blame] | 84 | module_param_named(logging, ql2xextended_error_logging, int, S_IRUGO|S_IWUSR); |
Andrew Vasquez | 11010fe | 2006-10-06 09:54:59 -0700 | [diff] [blame] | 85 | MODULE_PARM_DESC(ql2xextended_error_logging, |
Saurav Kashyap | 3ce8866 | 2011-07-14 12:00:12 -0700 | [diff] [blame] | 86 | "Option to enable extended error logging,\n" |
| 87 | "\t\tDefault is 0 - no logging. 0x40000000 - Module Init & Probe.\n" |
| 88 | "\t\t0x20000000 - Mailbox Cmnds. 0x10000000 - Device Discovery.\n" |
| 89 | "\t\t0x08000000 - IO tracing. 0x04000000 - DPC Thread.\n" |
| 90 | "\t\t0x02000000 - Async events. 0x01000000 - Timer routines.\n" |
| 91 | "\t\t0x00800000 - User space. 0x00400000 - Task Management.\n" |
| 92 | "\t\t0x00200000 - AER/EEH. 0x00100000 - Multi Q.\n" |
| 93 | "\t\t0x00080000 - P3P Specific. 0x00040000 - Virtual Port.\n" |
| 94 | "\t\t0x00020000 - Buffer Dump. 0x00010000 - Misc.\n" |
Chad Dupuis | 29f9f90 | 2012-11-21 02:40:41 -0500 | [diff] [blame] | 95 | "\t\t0x00008000 - Verbose. 0x00004000 - Target.\n" |
| 96 | "\t\t0x00002000 - Target Mgmt. 0x00001000 - Target TMF.\n" |
Saurav Kashyap | 3ce8866 | 2011-07-14 12:00:12 -0700 | [diff] [blame] | 97 | "\t\t0x7fffffff - For enabling all logs, can be too many logs.\n" |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 98 | "\t\t0x1e400000 - Preferred value for capturing essential " |
| 99 | "debug information (equivalent to old " |
| 100 | "ql2xextended_error_logging=1).\n" |
Saurav Kashyap | 3ce8866 | 2011-07-14 12:00:12 -0700 | [diff] [blame] | 101 | "\t\tDo LOGICAL OR of the value to enable more than one level"); |
Andrew Vasquez | 0181944 | 2006-06-23 16:11:10 -0700 | [diff] [blame] | 102 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 103 | int ql2xshiftctondsd = 6; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 104 | module_param(ql2xshiftctondsd, int, S_IRUGO); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 105 | MODULE_PARM_DESC(ql2xshiftctondsd, |
| 106 | "Set to control shifting of command type processing " |
| 107 | "based on total number of SG elements."); |
| 108 | |
Andrew Vasquez | 7e47e5c | 2008-04-24 15:21:26 -0700 | [diff] [blame] | 109 | int ql2xfdmienable=1; |
Himanshu Madhani | de187df | 2014-09-25 05:16:50 -0400 | [diff] [blame] | 110 | module_param(ql2xfdmienable, int, S_IRUGO|S_IWUSR); |
Joe Carnuccio | a2b3e01 | 2016-07-06 11:14:21 -0400 | [diff] [blame] | 111 | module_param_named(fdmi, ql2xfdmienable, int, S_IRUGO|S_IWUSR); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 112 | MODULE_PARM_DESC(ql2xfdmienable, |
Ferenc Wagner | 7794a5a | 2010-03-23 18:14:59 +0100 | [diff] [blame] | 113 | "Enables FDMI registrations. " |
| 114 | "0 - no FDMI. Default is 1 - perform FDMI."); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 115 | |
Chad Dupuis | 50280c0 | 2013-10-30 03:38:14 -0400 | [diff] [blame] | 116 | #define MAX_Q_DEPTH 32 |
| 117 | static int ql2xmaxqdepth = MAX_Q_DEPTH; |
Andrew Vasquez | df7baa5 | 2006-10-13 09:33:39 -0700 | [diff] [blame] | 118 | module_param(ql2xmaxqdepth, int, S_IRUGO|S_IWUSR); |
| 119 | MODULE_PARM_DESC(ql2xmaxqdepth, |
Chad Dupuis | e92e4a8 | 2012-08-22 14:21:23 -0400 | [diff] [blame] | 120 | "Maximum queue depth to set for each LUN. " |
| 121 | "Default is 32."); |
Andrew Vasquez | df7baa5 | 2006-10-13 09:33:39 -0700 | [diff] [blame] | 122 | |
Arun Easi | 9e522cd | 2012-08-22 14:21:31 -0400 | [diff] [blame] | 123 | int ql2xenabledif = 2; |
| 124 | module_param(ql2xenabledif, int, S_IRUGO); |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 125 | MODULE_PARM_DESC(ql2xenabledif, |
Steven J. Magnani | b97f5d0 | 2014-02-04 12:50:35 -0600 | [diff] [blame] | 126 | " Enable T10-CRC-DIF:\n" |
| 127 | " Default is 2.\n" |
| 128 | " 0 -- No DIF Support\n" |
| 129 | " 1 -- Enable DIF for all types\n" |
| 130 | " 2 -- Enable DIF for all types, except Type 0.\n"); |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 131 | |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 132 | int ql2xenablehba_err_chk = 2; |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 133 | module_param(ql2xenablehba_err_chk, int, S_IRUGO|S_IWUSR); |
| 134 | MODULE_PARM_DESC(ql2xenablehba_err_chk, |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 135 | " Enable T10-CRC-DIF Error isolation by HBA:\n" |
Steven J. Magnani | b97f5d0 | 2014-02-04 12:50:35 -0600 | [diff] [blame] | 136 | " Default is 2.\n" |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 137 | " 0 -- Error isolation disabled\n" |
| 138 | " 1 -- Error isolation enabled only for DIX Type 0\n" |
| 139 | " 2 -- Error isolation enabled for all Types\n"); |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 140 | |
Andrew Vasquez | e5896bd | 2008-07-10 16:55:52 -0700 | [diff] [blame] | 141 | int ql2xiidmaenable=1; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 142 | module_param(ql2xiidmaenable, int, S_IRUGO); |
Andrew Vasquez | e5896bd | 2008-07-10 16:55:52 -0700 | [diff] [blame] | 143 | MODULE_PARM_DESC(ql2xiidmaenable, |
| 144 | "Enables iIDMA settings " |
| 145 | "Default is 1 - perform iIDMA. 0 - no iIDMA."); |
| 146 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 147 | int ql2xmqsupport = 1; |
| 148 | module_param(ql2xmqsupport, int, S_IRUGO); |
| 149 | MODULE_PARM_DESC(ql2xmqsupport, |
| 150 | "Enable on demand multiple queue pairs support " |
| 151 | "Default is 1 for supported. " |
| 152 | "Set it to 0 to turn off mq qpair support."); |
Andrew Vasquez | e337d90 | 2009-04-06 22:33:49 -0700 | [diff] [blame] | 153 | |
| 154 | int ql2xfwloadbin; |
Chad Dupuis | 86e45bf | 2011-08-16 11:31:47 -0700 | [diff] [blame] | 155 | module_param(ql2xfwloadbin, int, S_IRUGO|S_IWUSR); |
Joe Carnuccio | a2b3e01 | 2016-07-06 11:14:21 -0400 | [diff] [blame] | 156 | module_param_named(fwload, ql2xfwloadbin, int, S_IRUGO|S_IWUSR); |
Andrew Vasquez | e337d90 | 2009-04-06 22:33:49 -0700 | [diff] [blame] | 157 | MODULE_PARM_DESC(ql2xfwloadbin, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 158 | "Option to specify location from which to load ISP firmware:.\n" |
| 159 | " 2 -- load firmware via the request_firmware() (hotplug).\n" |
Andrew Vasquez | e337d90 | 2009-04-06 22:33:49 -0700 | [diff] [blame] | 160 | " interface.\n" |
| 161 | " 1 -- load firmware from flash.\n" |
| 162 | " 0 -- use default semantics.\n"); |
| 163 | |
Andrew Vasquez | ae97c91 | 2010-02-18 10:07:28 -0800 | [diff] [blame] | 164 | int ql2xetsenable; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 165 | module_param(ql2xetsenable, int, S_IRUGO); |
Andrew Vasquez | ae97c91 | 2010-02-18 10:07:28 -0800 | [diff] [blame] | 166 | MODULE_PARM_DESC(ql2xetsenable, |
| 167 | "Enables firmware ETS burst." |
| 168 | "Default is 0 - skip ETS enablement."); |
| 169 | |
Giridhar Malavali | 6907869 | 2010-05-28 15:08:28 -0700 | [diff] [blame] | 170 | int ql2xdbwr = 1; |
Chad Dupuis | 86e45bf | 2011-08-16 11:31:47 -0700 | [diff] [blame] | 171 | module_param(ql2xdbwr, int, S_IRUGO|S_IWUSR); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 172 | MODULE_PARM_DESC(ql2xdbwr, |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 173 | "Option to specify scheme for request queue posting.\n" |
| 174 | " 0 -- Regular doorbell.\n" |
| 175 | " 1 -- CAMRAM doorbell (faster).\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 176 | |
Giridhar Malavali | f4c496c | 2010-05-04 15:01:33 -0700 | [diff] [blame] | 177 | int ql2xtargetreset = 1; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 178 | module_param(ql2xtargetreset, int, S_IRUGO); |
Giridhar Malavali | f4c496c | 2010-05-04 15:01:33 -0700 | [diff] [blame] | 179 | MODULE_PARM_DESC(ql2xtargetreset, |
| 180 | "Enable target reset." |
| 181 | "Default is 1 - use hw defaults."); |
| 182 | |
Chad Dupuis | 4da26e1 | 2010-10-15 11:27:40 -0700 | [diff] [blame] | 183 | int ql2xgffidenable; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 184 | module_param(ql2xgffidenable, int, S_IRUGO); |
Chad Dupuis | 4da26e1 | 2010-10-15 11:27:40 -0700 | [diff] [blame] | 185 | MODULE_PARM_DESC(ql2xgffidenable, |
| 186 | "Enables GFF_ID checks of port type. " |
| 187 | "Default is 0 - Do not use GFF_ID information."); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 188 | |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 189 | int ql2xasynctmfenable; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 190 | module_param(ql2xasynctmfenable, int, S_IRUGO); |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 191 | MODULE_PARM_DESC(ql2xasynctmfenable, |
| 192 | "Enables issue of TM IOCBs asynchronously via IOCB mechanism" |
| 193 | "Default is 0 - Issue TM IOCBs via mailbox mechanism."); |
Giridhar Malavali | ed0de87 | 2011-03-30 11:46:29 -0700 | [diff] [blame] | 194 | |
| 195 | int ql2xdontresethba; |
Chad Dupuis | 86e45bf | 2011-08-16 11:31:47 -0700 | [diff] [blame] | 196 | module_param(ql2xdontresethba, int, S_IRUGO|S_IWUSR); |
Giridhar Malavali | ed0de87 | 2011-03-30 11:46:29 -0700 | [diff] [blame] | 197 | MODULE_PARM_DESC(ql2xdontresethba, |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 198 | "Option to specify reset behaviour.\n" |
| 199 | " 0 (Default) -- Reset on failure.\n" |
| 200 | " 1 -- Do not reset on failure.\n"); |
Giridhar Malavali | ed0de87 | 2011-03-30 11:46:29 -0700 | [diff] [blame] | 201 | |
Hannes Reinecke | 1abf635 | 2014-06-25 15:27:38 +0200 | [diff] [blame] | 202 | uint64_t ql2xmaxlun = MAX_LUNS; |
| 203 | module_param(ql2xmaxlun, ullong, S_IRUGO); |
Andrew Vasquez | 8251592 | 2011-05-10 11:30:13 -0700 | [diff] [blame] | 204 | MODULE_PARM_DESC(ql2xmaxlun, |
| 205 | "Defines the maximum LU number to register with the SCSI " |
| 206 | "midlayer. Default is 65535."); |
| 207 | |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 208 | int ql2xmdcapmask = 0x1F; |
| 209 | module_param(ql2xmdcapmask, int, S_IRUGO); |
| 210 | MODULE_PARM_DESC(ql2xmdcapmask, |
| 211 | "Set the Minidump driver capture mask level. " |
Giridhar Malavali | 6e96fa7 | 2011-11-18 09:03:14 -0800 | [diff] [blame] | 212 | "Default is 0x1F - Can be set to 0x3, 0x7, 0xF, 0x1F, 0x7F."); |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 213 | |
Giridhar Malavali | 3aadff3 | 2011-11-18 09:02:14 -0800 | [diff] [blame] | 214 | int ql2xmdenable = 1; |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 215 | module_param(ql2xmdenable, int, S_IRUGO); |
| 216 | MODULE_PARM_DESC(ql2xmdenable, |
| 217 | "Enable/disable MiniDump. " |
Giridhar Malavali | 3aadff3 | 2011-11-18 09:02:14 -0800 | [diff] [blame] | 218 | "0 - MiniDump disabled. " |
| 219 | "1 (Default) - MiniDump enabled."); |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 220 | |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 221 | int ql2xexlogins = 0; |
| 222 | module_param(ql2xexlogins, uint, S_IRUGO|S_IWUSR); |
| 223 | MODULE_PARM_DESC(ql2xexlogins, |
| 224 | "Number of extended Logins. " |
| 225 | "0 (Default)- Disabled."); |
| 226 | |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 227 | int ql2xexchoffld = 0; |
| 228 | module_param(ql2xexchoffld, uint, S_IRUGO|S_IWUSR); |
| 229 | MODULE_PARM_DESC(ql2xexchoffld, |
| 230 | "Number of exchanges to offload. " |
| 231 | "0 (Default)- Disabled."); |
| 232 | |
Himanshu Madhani | f198caf | 2016-01-27 12:03:30 -0500 | [diff] [blame] | 233 | int ql2xfwholdabts = 0; |
| 234 | module_param(ql2xfwholdabts, int, S_IRUGO); |
| 235 | MODULE_PARM_DESC(ql2xfwholdabts, |
| 236 | "Allow FW to hold status IOCB until ABTS rsp received. " |
| 237 | "0 (Default) Do not set fw option. " |
| 238 | "1 - Set fw option to hold ABTS."); |
| 239 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 240 | /* |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 241 | * SCSI host template entry points |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 242 | */ |
| 243 | static int qla2xxx_slave_configure(struct scsi_device * device); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 244 | static int qla2xxx_slave_alloc(struct scsi_device *); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 245 | static int qla2xxx_scan_finished(struct Scsi_Host *, unsigned long time); |
| 246 | static void qla2xxx_scan_start(struct Scsi_Host *); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 247 | static void qla2xxx_slave_destroy(struct scsi_device *); |
Jeff Garzik | f281233 | 2010-11-16 02:10:29 -0500 | [diff] [blame] | 248 | static int qla2xxx_queuecommand(struct Scsi_Host *h, struct scsi_cmnd *cmd); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 249 | static int qla2xxx_eh_abort(struct scsi_cmnd *); |
| 250 | static int qla2xxx_eh_device_reset(struct scsi_cmnd *); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 251 | static int qla2xxx_eh_target_reset(struct scsi_cmnd *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 252 | static int qla2xxx_eh_bus_reset(struct scsi_cmnd *); |
| 253 | static int qla2xxx_eh_host_reset(struct scsi_cmnd *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 254 | |
Joe Lawrence | 1a2fbf1 | 2014-08-26 17:11:18 -0400 | [diff] [blame] | 255 | static void qla2x00_clear_drv_active(struct qla_hw_data *); |
Saurav Kashyap | 3491255 | 2013-06-25 11:27:18 -0400 | [diff] [blame] | 256 | static void qla2x00_free_device(scsi_qla_host_t *); |
Himanshu Madhani | 2d5a4c3 | 2014-09-25 05:16:55 -0400 | [diff] [blame] | 257 | static void qla83xx_disable_laser(scsi_qla_host_t *vha); |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 258 | static int qla2xxx_map_queues(struct Scsi_Host *shost); |
Andrew Vasquez | ce7e4af | 2005-08-26 19:09:30 -0700 | [diff] [blame] | 259 | |
Giridhar Malavali | a5326f8 | 2009-03-24 09:07:56 -0700 | [diff] [blame] | 260 | struct scsi_host_template qla2xxx_driver_template = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 261 | .module = THIS_MODULE, |
Andrew Vasquez | cb63067 | 2006-05-17 15:09:45 -0700 | [diff] [blame] | 262 | .name = QLA2XXX_DRIVER_NAME, |
Giridhar Malavali | a5326f8 | 2009-03-24 09:07:56 -0700 | [diff] [blame] | 263 | .queuecommand = qla2xxx_queuecommand, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 264 | |
Christoph Hellwig | b6a05c8 | 2017-01-30 13:18:58 +0100 | [diff] [blame] | 265 | .eh_timed_out = fc_eh_timed_out, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 266 | .eh_abort_handler = qla2xxx_eh_abort, |
| 267 | .eh_device_reset_handler = qla2xxx_eh_device_reset, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 268 | .eh_target_reset_handler = qla2xxx_eh_target_reset, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 269 | .eh_bus_reset_handler = qla2xxx_eh_bus_reset, |
| 270 | .eh_host_reset_handler = qla2xxx_eh_host_reset, |
| 271 | |
| 272 | .slave_configure = qla2xxx_slave_configure, |
| 273 | |
| 274 | .slave_alloc = qla2xxx_slave_alloc, |
| 275 | .slave_destroy = qla2xxx_slave_destroy, |
Andrew Vasquez | ed67708 | 2007-03-12 10:41:27 -0700 | [diff] [blame] | 276 | .scan_finished = qla2xxx_scan_finished, |
| 277 | .scan_start = qla2xxx_scan_start, |
Christoph Hellwig | db5ed4d | 2014-11-13 15:08:42 +0100 | [diff] [blame] | 278 | .change_queue_depth = scsi_change_queue_depth, |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 279 | .map_queues = qla2xxx_map_queues, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 280 | .this_id = -1, |
| 281 | .cmd_per_lun = 3, |
| 282 | .use_clustering = ENABLE_CLUSTERING, |
| 283 | .sg_tablesize = SG_ALL, |
| 284 | |
| 285 | .max_sectors = 0xFFFF, |
Andrew Vasquez | afb046e | 2005-08-26 19:09:40 -0700 | [diff] [blame] | 286 | .shost_attrs = qla2x00_host_attrs, |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 287 | |
| 288 | .supported_mode = MODE_INITIATOR, |
Christoph Hellwig | c40ecc1 | 2014-11-13 14:25:11 +0100 | [diff] [blame] | 289 | .track_queue_depth = 1, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 290 | }; |
| 291 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 292 | static struct scsi_transport_template *qla2xxx_transport_template = NULL; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 293 | struct scsi_transport_template *qla2xxx_transport_vport_template = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 294 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 295 | /* TODO Convert to inlines |
| 296 | * |
| 297 | * Timer routines |
| 298 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 299 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 300 | __inline__ void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 301 | 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] | 302 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 303 | init_timer(&vha->timer); |
| 304 | vha->timer.expires = jiffies + interval * HZ; |
| 305 | vha->timer.data = (unsigned long)vha; |
| 306 | vha->timer.function = (void (*)(unsigned long))func; |
| 307 | add_timer(&vha->timer); |
| 308 | vha->timer_active = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 309 | } |
| 310 | |
| 311 | static inline void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 312 | qla2x00_restart_timer(scsi_qla_host_t *vha, unsigned long interval) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 313 | { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 314 | /* Currently used for 82XX only. */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 315 | if (vha->device_flags & DFLG_DEV_FAILED) { |
| 316 | ql_dbg(ql_dbg_timer, vha, 0x600d, |
| 317 | "Device in a failed state, returning.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 318 | return; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 319 | } |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 320 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 321 | mod_timer(&vha->timer, jiffies + interval * HZ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 322 | } |
| 323 | |
Adrian Bunk | a824ebb | 2008-01-17 09:02:15 -0800 | [diff] [blame] | 324 | static __inline__ void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 325 | qla2x00_stop_timer(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 326 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 327 | del_timer_sync(&vha->timer); |
| 328 | vha->timer_active = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 329 | } |
| 330 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 331 | static int qla2x00_do_dpc(void *data); |
| 332 | |
| 333 | static void qla2x00_rst_aen(scsi_qla_host_t *); |
| 334 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 335 | static int qla2x00_mem_alloc(struct qla_hw_data *, uint16_t, uint16_t, |
| 336 | struct req_que **, struct rsp_que **); |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 337 | static void qla2x00_free_fw_dump(struct qla_hw_data *); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 338 | static void qla2x00_mem_free(struct qla_hw_data *); |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 339 | int qla2xxx_mqueuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd, |
| 340 | struct qla_qpair *qpair); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 341 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 342 | /* -------------------------------------------------------------------------- */ |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 343 | static int qla2x00_alloc_queues(struct qla_hw_data *ha, struct req_que *req, |
| 344 | struct rsp_que *rsp) |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 345 | { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 346 | scsi_qla_host_t *vha = pci_get_drvdata(ha->pdev); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 347 | 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] | 348 | GFP_KERNEL); |
| 349 | if (!ha->req_q_map) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 350 | ql_log(ql_log_fatal, vha, 0x003b, |
| 351 | "Unable to allocate memory for request queue ptrs.\n"); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 352 | goto fail_req_map; |
| 353 | } |
| 354 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 355 | 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] | 356 | GFP_KERNEL); |
| 357 | if (!ha->rsp_q_map) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 358 | ql_log(ql_log_fatal, vha, 0x003c, |
| 359 | "Unable to allocate memory for response queue ptrs.\n"); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 360 | goto fail_rsp_map; |
| 361 | } |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 362 | |
| 363 | if (ql2xmqsupport && ha->max_qpairs) { |
| 364 | ha->queue_pair_map = kcalloc(ha->max_qpairs, sizeof(struct qla_qpair *), |
| 365 | GFP_KERNEL); |
| 366 | if (!ha->queue_pair_map) { |
| 367 | ql_log(ql_log_fatal, vha, 0x0180, |
| 368 | "Unable to allocate memory for queue pair ptrs.\n"); |
| 369 | goto fail_qpair_map; |
| 370 | } |
| 371 | ha->base_qpair = kzalloc(sizeof(struct qla_qpair), GFP_KERNEL); |
| 372 | if (ha->base_qpair == NULL) { |
| 373 | ql_log(ql_log_warn, vha, 0x0182, |
| 374 | "Failed to allocate base queue pair memory.\n"); |
| 375 | goto fail_base_qpair; |
| 376 | } |
| 377 | ha->base_qpair->req = req; |
| 378 | ha->base_qpair->rsp = rsp; |
| 379 | } |
| 380 | |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 381 | /* |
| 382 | * Make sure we record at least the request and response queue zero in |
| 383 | * case we need to free them if part of the probe fails. |
| 384 | */ |
| 385 | ha->rsp_q_map[0] = rsp; |
| 386 | ha->req_q_map[0] = req; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 387 | set_bit(0, ha->rsp_qid_map); |
| 388 | set_bit(0, ha->req_qid_map); |
| 389 | return 1; |
| 390 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 391 | fail_base_qpair: |
| 392 | kfree(ha->queue_pair_map); |
| 393 | fail_qpair_map: |
| 394 | kfree(ha->rsp_q_map); |
| 395 | ha->rsp_q_map = NULL; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 396 | fail_rsp_map: |
| 397 | kfree(ha->req_q_map); |
| 398 | ha->req_q_map = NULL; |
| 399 | fail_req_map: |
| 400 | return -ENOMEM; |
| 401 | } |
| 402 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 403 | 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] | 404 | { |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 405 | if (IS_QLAFX00(ha)) { |
| 406 | if (req && req->ring_fx00) |
| 407 | dma_free_coherent(&ha->pdev->dev, |
| 408 | (req->length_fx00 + 1) * sizeof(request_t), |
| 409 | req->ring_fx00, req->dma_fx00); |
| 410 | } else if (req && req->ring) |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 411 | dma_free_coherent(&ha->pdev->dev, |
| 412 | (req->length + 1) * sizeof(request_t), |
| 413 | req->ring, req->dma); |
| 414 | |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 415 | if (req) |
| 416 | kfree(req->outstanding_cmds); |
| 417 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 418 | kfree(req); |
| 419 | req = NULL; |
| 420 | } |
| 421 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 422 | static void qla2x00_free_rsp_que(struct qla_hw_data *ha, struct rsp_que *rsp) |
| 423 | { |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 424 | if (IS_QLAFX00(ha)) { |
| 425 | if (rsp && rsp->ring) |
| 426 | dma_free_coherent(&ha->pdev->dev, |
| 427 | (rsp->length_fx00 + 1) * sizeof(request_t), |
| 428 | rsp->ring_fx00, rsp->dma_fx00); |
| 429 | } else if (rsp && rsp->ring) { |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 430 | dma_free_coherent(&ha->pdev->dev, |
| 431 | (rsp->length + 1) * sizeof(response_t), |
| 432 | rsp->ring, rsp->dma); |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 433 | } |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 434 | kfree(rsp); |
| 435 | rsp = NULL; |
| 436 | } |
| 437 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 438 | static void qla2x00_free_queues(struct qla_hw_data *ha) |
| 439 | { |
| 440 | struct req_que *req; |
| 441 | struct rsp_que *rsp; |
| 442 | int cnt; |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 443 | unsigned long flags; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 444 | |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 445 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 446 | for (cnt = 0; cnt < ha->max_req_queues; cnt++) { |
Quinn Tran | cb43285 | 2016-02-04 11:45:16 -0500 | [diff] [blame] | 447 | if (!test_bit(cnt, ha->req_qid_map)) |
| 448 | continue; |
| 449 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 450 | req = ha->req_q_map[cnt]; |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 451 | clear_bit(cnt, ha->req_qid_map); |
| 452 | ha->req_q_map[cnt] = NULL; |
| 453 | |
| 454 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 455 | qla2x00_free_req_que(ha, req); |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 456 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 457 | } |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 458 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 459 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 460 | kfree(ha->req_q_map); |
| 461 | ha->req_q_map = NULL; |
| 462 | |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 463 | |
| 464 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 465 | for (cnt = 0; cnt < ha->max_rsp_queues; cnt++) { |
Quinn Tran | cb43285 | 2016-02-04 11:45:16 -0500 | [diff] [blame] | 466 | if (!test_bit(cnt, ha->rsp_qid_map)) |
| 467 | continue; |
| 468 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 469 | rsp = ha->rsp_q_map[cnt]; |
Dave Jones | c3c4239 | 2016-12-27 13:13:21 -0500 | [diff] [blame] | 470 | clear_bit(cnt, ha->rsp_qid_map); |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 471 | ha->rsp_q_map[cnt] = NULL; |
| 472 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 473 | qla2x00_free_rsp_que(ha, rsp); |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 474 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 475 | } |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 476 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 477 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 478 | kfree(ha->rsp_q_map); |
| 479 | ha->rsp_q_map = NULL; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 480 | } |
| 481 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 482 | static char * |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 483 | qla2x00_pci_info_str(struct scsi_qla_host *vha, char *str) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 484 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 485 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 486 | static char *pci_bus_modes[] = { |
| 487 | "33", "66", "100", "133", |
| 488 | }; |
| 489 | uint16_t pci_bus; |
| 490 | |
| 491 | strcpy(str, "PCI"); |
| 492 | pci_bus = (ha->pci_attr & (BIT_9 | BIT_10)) >> 9; |
| 493 | if (pci_bus) { |
| 494 | strcat(str, "-X ("); |
| 495 | strcat(str, pci_bus_modes[pci_bus]); |
| 496 | } else { |
| 497 | pci_bus = (ha->pci_attr & BIT_8) >> 8; |
| 498 | strcat(str, " ("); |
| 499 | strcat(str, pci_bus_modes[pci_bus]); |
| 500 | } |
| 501 | strcat(str, " MHz)"); |
| 502 | |
| 503 | return (str); |
| 504 | } |
| 505 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 506 | static char * |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 507 | qla24xx_pci_info_str(struct scsi_qla_host *vha, char *str) |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 508 | { |
| 509 | static char *pci_bus_modes[] = { "33", "66", "100", "133", }; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 510 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 511 | uint32_t pci_bus; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 512 | |
Bjorn Helgaas | 62a276f | 2013-09-06 11:26:24 -0600 | [diff] [blame] | 513 | if (pci_is_pcie(ha->pdev)) { |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 514 | char lwstr[6]; |
Bjorn Helgaas | 62a276f | 2013-09-06 11:26:24 -0600 | [diff] [blame] | 515 | uint32_t lstat, lspeed, lwidth; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 516 | |
Bjorn Helgaas | 62a276f | 2013-09-06 11:26:24 -0600 | [diff] [blame] | 517 | pcie_capability_read_dword(ha->pdev, PCI_EXP_LNKCAP, &lstat); |
| 518 | lspeed = lstat & PCI_EXP_LNKCAP_SLS; |
| 519 | lwidth = (lstat & PCI_EXP_LNKCAP_MLW) >> 4; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 520 | |
| 521 | strcpy(str, "PCIe ("); |
Saurav Kashyap | 49300af | 2012-11-21 02:40:34 -0500 | [diff] [blame] | 522 | switch (lspeed) { |
| 523 | case 1: |
Andrew Vasquez | c87a0d8 | 2008-04-03 13:13:21 -0700 | [diff] [blame] | 524 | strcat(str, "2.5GT/s "); |
Saurav Kashyap | 49300af | 2012-11-21 02:40:34 -0500 | [diff] [blame] | 525 | break; |
| 526 | case 2: |
Andrew Vasquez | c87a0d8 | 2008-04-03 13:13:21 -0700 | [diff] [blame] | 527 | strcat(str, "5.0GT/s "); |
Saurav Kashyap | 49300af | 2012-11-21 02:40:34 -0500 | [diff] [blame] | 528 | break; |
| 529 | case 3: |
| 530 | strcat(str, "8.0GT/s "); |
| 531 | break; |
| 532 | default: |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 533 | strcat(str, "<unknown> "); |
Saurav Kashyap | 49300af | 2012-11-21 02:40:34 -0500 | [diff] [blame] | 534 | break; |
| 535 | } |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 536 | snprintf(lwstr, sizeof(lwstr), "x%d)", lwidth); |
| 537 | strcat(str, lwstr); |
| 538 | |
| 539 | return str; |
| 540 | } |
| 541 | |
| 542 | strcpy(str, "PCI"); |
| 543 | pci_bus = (ha->pci_attr & CSRX_PCIX_BUS_MODE_MASK) >> 8; |
| 544 | if (pci_bus == 0 || pci_bus == 8) { |
| 545 | strcat(str, " ("); |
| 546 | strcat(str, pci_bus_modes[pci_bus >> 3]); |
| 547 | } else { |
| 548 | strcat(str, "-X "); |
| 549 | if (pci_bus & BIT_2) |
| 550 | strcat(str, "Mode 2"); |
| 551 | else |
| 552 | strcat(str, "Mode 1"); |
| 553 | strcat(str, " ("); |
| 554 | strcat(str, pci_bus_modes[pci_bus & ~BIT_2]); |
| 555 | } |
| 556 | strcat(str, " MHz)"); |
| 557 | |
| 558 | return str; |
| 559 | } |
| 560 | |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 561 | static char * |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 562 | 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] | 563 | { |
| 564 | char un_str[10]; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 565 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 566 | |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 567 | snprintf(str, size, "%d.%02d.%02d ", ha->fw_major_version, |
| 568 | ha->fw_minor_version, ha->fw_subminor_version); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 569 | |
| 570 | if (ha->fw_attributes & BIT_9) { |
| 571 | strcat(str, "FLX"); |
| 572 | return (str); |
| 573 | } |
| 574 | |
| 575 | switch (ha->fw_attributes & 0xFF) { |
| 576 | case 0x7: |
| 577 | strcat(str, "EF"); |
| 578 | break; |
| 579 | case 0x17: |
| 580 | strcat(str, "TP"); |
| 581 | break; |
| 582 | case 0x37: |
| 583 | strcat(str, "IP"); |
| 584 | break; |
| 585 | case 0x77: |
| 586 | strcat(str, "VI"); |
| 587 | break; |
| 588 | default: |
| 589 | sprintf(un_str, "(%x)", ha->fw_attributes); |
| 590 | strcat(str, un_str); |
| 591 | break; |
| 592 | } |
| 593 | if (ha->fw_attributes & 0x100) |
| 594 | strcat(str, "X"); |
| 595 | |
| 596 | return (str); |
| 597 | } |
| 598 | |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 599 | static char * |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 600 | 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] | 601 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 602 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | f0883ac | 2005-07-08 17:58:43 -0700 | [diff] [blame] | 603 | |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 604 | snprintf(str, size, "%d.%02d.%02d (%x)", ha->fw_major_version, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 605 | ha->fw_minor_version, ha->fw_subminor_version, ha->fw_attributes); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 606 | return str; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 607 | } |
| 608 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 609 | void |
| 610 | qla2x00_sp_free_dma(void *vha, void *ptr) |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 611 | { |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 612 | srb_t *sp = (srb_t *)ptr; |
| 613 | struct scsi_cmnd *cmd = GET_CMD_SP(sp); |
| 614 | struct qla_hw_data *ha = sp->fcport->vha->hw; |
| 615 | void *ctx = GET_CMD_CTX_SP(sp); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 616 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 617 | if (sp->flags & SRB_DMA_VALID) { |
| 618 | scsi_dma_unmap(cmd); |
| 619 | sp->flags &= ~SRB_DMA_VALID; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 620 | } |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 621 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 622 | if (sp->flags & SRB_CRC_PROT_DMA_VALID) { |
| 623 | dma_unmap_sg(&ha->pdev->dev, scsi_prot_sglist(cmd), |
| 624 | scsi_prot_sg_count(cmd), cmd->sc_data_direction); |
| 625 | sp->flags &= ~SRB_CRC_PROT_DMA_VALID; |
| 626 | } |
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 | if (sp->flags & SRB_CRC_CTX_DSD_VALID) { |
| 629 | /* List assured to be having elements */ |
Quinn Tran | f83adb6 | 2014-04-11 16:54:43 -0400 | [diff] [blame] | 630 | qla2x00_clean_dsd_pool(ha, sp, NULL); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 631 | sp->flags &= ~SRB_CRC_CTX_DSD_VALID; |
| 632 | } |
| 633 | |
| 634 | if (sp->flags & SRB_CRC_CTX_DMA_VALID) { |
| 635 | dma_pool_free(ha->dl_dma_pool, ctx, |
| 636 | ((struct crc_context *)ctx)->crc_ctx_dma); |
| 637 | sp->flags &= ~SRB_CRC_CTX_DMA_VALID; |
| 638 | } |
| 639 | |
| 640 | if (sp->flags & SRB_FCP_CMND_DMA_VALID) { |
| 641 | struct ct6_dsd *ctx1 = (struct ct6_dsd *)ctx; |
| 642 | |
| 643 | dma_pool_free(ha->fcp_cmnd_dma_pool, ctx1->fcp_cmnd, |
| 644 | ctx1->fcp_cmnd_dma); |
| 645 | list_splice(&ctx1->dsd_list, &ha->gbl_dsd_list); |
| 646 | ha->gbl_dsd_inuse -= ctx1->dsd_use_cnt; |
| 647 | ha->gbl_dsd_avail += ctx1->dsd_use_cnt; |
| 648 | mempool_free(ctx1, ha->ctx_mempool); |
| 649 | ctx1 = NULL; |
| 650 | } |
| 651 | |
| 652 | CMD_SP(cmd) = NULL; |
Chad Dupuis | b00ee7d | 2013-02-08 01:57:50 -0500 | [diff] [blame] | 653 | qla2x00_rel_sp(sp->fcport->vha, sp); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 654 | } |
| 655 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 656 | void |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 657 | qla2x00_sp_compl(void *data, void *ptr, int res) |
| 658 | { |
| 659 | struct qla_hw_data *ha = (struct qla_hw_data *)data; |
| 660 | srb_t *sp = (srb_t *)ptr; |
| 661 | struct scsi_cmnd *cmd = GET_CMD_SP(sp); |
| 662 | |
| 663 | cmd->result = res; |
| 664 | |
| 665 | if (atomic_read(&sp->ref_count) == 0) { |
| 666 | ql_dbg(ql_dbg_io, sp->fcport->vha, 0x3015, |
| 667 | "SP reference-count to ZERO -- sp=%p cmd=%p.\n", |
| 668 | sp, GET_CMD_SP(sp)); |
| 669 | if (ql2xextended_error_logging & ql_dbg_io) |
Hiral Patel | 8fbdac8 | 2015-08-04 13:37:56 -0400 | [diff] [blame] | 670 | WARN_ON(atomic_read(&sp->ref_count) == 0); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 671 | return; |
| 672 | } |
| 673 | if (!atomic_dec_and_test(&sp->ref_count)) |
| 674 | return; |
| 675 | |
| 676 | qla2x00_sp_free_dma(ha, sp); |
| 677 | cmd->scsi_done(cmd); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 678 | } |
| 679 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 680 | void |
| 681 | qla2xxx_qpair_sp_free_dma(void *vha, void *ptr) |
| 682 | { |
| 683 | srb_t *sp = (srb_t *)ptr; |
| 684 | struct scsi_cmnd *cmd = GET_CMD_SP(sp); |
| 685 | struct qla_hw_data *ha = sp->fcport->vha->hw; |
| 686 | void *ctx = GET_CMD_CTX_SP(sp); |
| 687 | |
| 688 | if (sp->flags & SRB_DMA_VALID) { |
| 689 | scsi_dma_unmap(cmd); |
| 690 | sp->flags &= ~SRB_DMA_VALID; |
| 691 | } |
| 692 | |
| 693 | if (sp->flags & SRB_CRC_PROT_DMA_VALID) { |
| 694 | dma_unmap_sg(&ha->pdev->dev, scsi_prot_sglist(cmd), |
| 695 | scsi_prot_sg_count(cmd), cmd->sc_data_direction); |
| 696 | sp->flags &= ~SRB_CRC_PROT_DMA_VALID; |
| 697 | } |
| 698 | |
| 699 | if (sp->flags & SRB_CRC_CTX_DSD_VALID) { |
| 700 | /* List assured to be having elements */ |
| 701 | qla2x00_clean_dsd_pool(ha, sp, NULL); |
| 702 | sp->flags &= ~SRB_CRC_CTX_DSD_VALID; |
| 703 | } |
| 704 | |
| 705 | if (sp->flags & SRB_CRC_CTX_DMA_VALID) { |
| 706 | dma_pool_free(ha->dl_dma_pool, ctx, |
| 707 | ((struct crc_context *)ctx)->crc_ctx_dma); |
| 708 | sp->flags &= ~SRB_CRC_CTX_DMA_VALID; |
| 709 | } |
| 710 | |
| 711 | if (sp->flags & SRB_FCP_CMND_DMA_VALID) { |
| 712 | struct ct6_dsd *ctx1 = (struct ct6_dsd *)ctx; |
| 713 | |
| 714 | dma_pool_free(ha->fcp_cmnd_dma_pool, ctx1->fcp_cmnd, |
| 715 | ctx1->fcp_cmnd_dma); |
| 716 | list_splice(&ctx1->dsd_list, &ha->gbl_dsd_list); |
| 717 | ha->gbl_dsd_inuse -= ctx1->dsd_use_cnt; |
| 718 | ha->gbl_dsd_avail += ctx1->dsd_use_cnt; |
| 719 | mempool_free(ctx1, ha->ctx_mempool); |
| 720 | } |
| 721 | |
| 722 | CMD_SP(cmd) = NULL; |
| 723 | qla2xxx_rel_qpair_sp(sp->qpair, sp); |
| 724 | } |
| 725 | |
| 726 | void |
| 727 | qla2xxx_qpair_sp_compl(void *data, void *ptr, int res) |
| 728 | { |
| 729 | srb_t *sp = (srb_t *)ptr; |
| 730 | struct scsi_cmnd *cmd = GET_CMD_SP(sp); |
| 731 | |
| 732 | cmd->result = res; |
| 733 | |
| 734 | if (atomic_read(&sp->ref_count) == 0) { |
| 735 | ql_dbg(ql_dbg_io, sp->fcport->vha, 0x3079, |
| 736 | "SP reference-count to ZERO -- sp=%p cmd=%p.\n", |
| 737 | sp, GET_CMD_SP(sp)); |
| 738 | if (ql2xextended_error_logging & ql_dbg_io) |
| 739 | WARN_ON(atomic_read(&sp->ref_count) == 0); |
| 740 | return; |
| 741 | } |
| 742 | if (!atomic_dec_and_test(&sp->ref_count)) |
| 743 | return; |
| 744 | |
| 745 | qla2xxx_qpair_sp_free_dma(sp->fcport->vha, sp); |
| 746 | cmd->scsi_done(cmd); |
| 747 | } |
| 748 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 749 | /* If we are SP1 here, we need to still take and release the host_lock as SP1 |
| 750 | * does not have the changes necessary to avoid taking host->host_lock. |
| 751 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 752 | static int |
Madhuranath Iyengar | f5e3e40 | 2011-02-23 15:27:06 -0800 | [diff] [blame] | 753 | qla2xxx_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 754 | { |
Madhuranath Iyengar | 134ae07 | 2011-05-10 11:30:08 -0700 | [diff] [blame] | 755 | scsi_qla_host_t *vha = shost_priv(host); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 756 | fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 757 | struct fc_rport *rport = starget_to_rport(scsi_target(cmd->device)); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 758 | struct qla_hw_data *ha = vha->hw; |
| 759 | struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 760 | srb_t *sp; |
| 761 | int rval; |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 762 | struct qla_qpair *qpair = NULL; |
| 763 | uint32_t tag; |
| 764 | uint16_t hwq; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 765 | |
Mauricio Faria de Oliveira | 04dfaa5 | 2016-11-07 17:53:30 -0200 | [diff] [blame] | 766 | if (unlikely(test_bit(UNLOADING, &base_vha->dpc_flags))) { |
| 767 | cmd->result = DID_NO_CONNECT << 16; |
| 768 | goto qc24_fail_command; |
| 769 | } |
| 770 | |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 771 | if (ha->mqenable) { |
| 772 | if (shost_use_blk_mq(vha->host)) { |
| 773 | tag = blk_mq_unique_tag(cmd->request); |
| 774 | hwq = blk_mq_unique_tag_to_hwq(tag); |
| 775 | qpair = ha->queue_pair_map[hwq]; |
| 776 | } else if (vha->vp_idx && vha->qpair) { |
| 777 | qpair = vha->qpair; |
| 778 | } |
| 779 | |
| 780 | if (qpair) |
| 781 | return qla2xxx_mqueuecommand(host, cmd, qpair); |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 782 | } |
| 783 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 784 | if (ha->flags.eeh_busy) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 785 | if (ha->flags.pci_channel_io_perm_failure) { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 786 | ql_dbg(ql_dbg_aer, vha, 0x9010, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 787 | "PCI Channel IO permanent failure, exiting " |
| 788 | "cmd=%p.\n", cmd); |
Seokmann Ju | b9b12f7 | 2009-03-24 09:08:18 -0700 | [diff] [blame] | 789 | cmd->result = DID_NO_CONNECT << 16; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 790 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 791 | ql_dbg(ql_dbg_aer, vha, 0x9011, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 792 | "EEH_Busy, Requeuing the cmd=%p.\n", cmd); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 793 | cmd->result = DID_REQUEUE << 16; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 794 | } |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 795 | goto qc24_fail_command; |
| 796 | } |
| 797 | |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 798 | rval = fc_remote_port_chkready(rport); |
| 799 | if (rval) { |
| 800 | cmd->result = rval; |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 801 | ql_dbg(ql_dbg_io + ql_dbg_verbose, vha, 0x3003, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 802 | "fc_remote_port_chkready failed for cmd=%p, rval=0x%x.\n", |
| 803 | cmd, rval); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 804 | goto qc24_fail_command; |
| 805 | } |
| 806 | |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 807 | if (!vha->flags.difdix_supported && |
| 808 | scsi_get_prot_op(cmd) != SCSI_PROT_NORMAL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 809 | ql_dbg(ql_dbg_io, vha, 0x3004, |
| 810 | "DIF Cap not reg, fail DIF capable cmd's:%p.\n", |
| 811 | cmd); |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 812 | cmd->result = DID_NO_CONNECT << 16; |
| 813 | goto qc24_fail_command; |
| 814 | } |
Chad Dupuis | aa651be | 2012-02-09 11:14:04 -0800 | [diff] [blame] | 815 | |
| 816 | if (!fcport) { |
| 817 | cmd->result = DID_NO_CONNECT << 16; |
| 818 | goto qc24_fail_command; |
| 819 | } |
| 820 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 821 | if (atomic_read(&fcport->state) != FCS_ONLINE) { |
| 822 | if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD || |
Giridhar Malavali | 38170fa | 2010-10-15 11:27:49 -0700 | [diff] [blame] | 823 | atomic_read(&base_vha->loop_state) == LOOP_DEAD) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 824 | ql_dbg(ql_dbg_io, vha, 0x3005, |
| 825 | "Returning DNC, fcport_state=%d loop_state=%d.\n", |
| 826 | atomic_read(&fcport->state), |
| 827 | atomic_read(&base_vha->loop_state)); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 828 | cmd->result = DID_NO_CONNECT << 16; |
| 829 | goto qc24_fail_command; |
| 830 | } |
Mike Christie | 7b59413 | 2008-08-17 15:24:40 -0500 | [diff] [blame] | 831 | goto qc24_target_busy; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 832 | } |
| 833 | |
Chad Dupuis | e05fe29 | 2014-09-25 05:16:59 -0400 | [diff] [blame] | 834 | /* |
| 835 | * Return target busy if we've received a non-zero retry_delay_timer |
| 836 | * in a FCP_RSP. |
| 837 | */ |
Bruno Prémont | 975f7d4 | 2014-12-19 10:29:16 +0100 | [diff] [blame] | 838 | if (fcport->retry_delay_timestamp == 0) { |
| 839 | /* retry delay not set */ |
| 840 | } else if (time_after(jiffies, fcport->retry_delay_timestamp)) |
Chad Dupuis | e05fe29 | 2014-09-25 05:16:59 -0400 | [diff] [blame] | 841 | fcport->retry_delay_timestamp = 0; |
| 842 | else |
| 843 | goto qc24_target_busy; |
| 844 | |
Chad Dupuis | b00ee7d | 2013-02-08 01:57:50 -0500 | [diff] [blame] | 845 | sp = qla2x00_get_sp(vha, fcport, GFP_ATOMIC); |
Chad Dupuis | 50280c0 | 2013-10-30 03:38:14 -0400 | [diff] [blame] | 846 | if (!sp) |
Madhuranath Iyengar | f5e3e40 | 2011-02-23 15:27:06 -0800 | [diff] [blame] | 847 | goto qc24_host_busy; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 848 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 849 | sp->u.scmd.cmd = cmd; |
| 850 | sp->type = SRB_SCSI_CMD; |
| 851 | atomic_set(&sp->ref_count, 1); |
| 852 | CMD_SP(cmd) = (void *)sp; |
| 853 | sp->free = qla2x00_sp_free_dma; |
| 854 | sp->done = qla2x00_sp_compl; |
| 855 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 856 | rval = ha->isp_ops->start_scsi(sp); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 857 | if (rval != QLA_SUCCESS) { |
Chad Dupuis | 53016ed | 2012-11-21 02:40:32 -0500 | [diff] [blame] | 858 | ql_dbg(ql_dbg_io + ql_dbg_verbose, vha, 0x3013, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 859 | "Start scsi failed rval=%d for cmd=%p.\n", rval, cmd); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 860 | goto qc24_host_busy_free_sp; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 861 | } |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 862 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 863 | return 0; |
| 864 | |
| 865 | qc24_host_busy_free_sp: |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 866 | qla2x00_sp_free_dma(ha, sp); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 867 | |
Madhuranath Iyengar | f5e3e40 | 2011-02-23 15:27:06 -0800 | [diff] [blame] | 868 | qc24_host_busy: |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 869 | return SCSI_MLQUEUE_HOST_BUSY; |
| 870 | |
Mike Christie | 7b59413 | 2008-08-17 15:24:40 -0500 | [diff] [blame] | 871 | qc24_target_busy: |
| 872 | return SCSI_MLQUEUE_TARGET_BUSY; |
| 873 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 874 | qc24_fail_command: |
Madhuranath Iyengar | f5e3e40 | 2011-02-23 15:27:06 -0800 | [diff] [blame] | 875 | cmd->scsi_done(cmd); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 876 | |
| 877 | return 0; |
| 878 | } |
| 879 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 880 | /* For MQ supported I/O */ |
| 881 | int |
| 882 | qla2xxx_mqueuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd, |
| 883 | struct qla_qpair *qpair) |
| 884 | { |
| 885 | scsi_qla_host_t *vha = shost_priv(host); |
| 886 | fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; |
| 887 | struct fc_rport *rport = starget_to_rport(scsi_target(cmd->device)); |
| 888 | struct qla_hw_data *ha = vha->hw; |
| 889 | struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); |
| 890 | srb_t *sp; |
| 891 | int rval; |
| 892 | |
| 893 | rval = fc_remote_port_chkready(rport); |
| 894 | if (rval) { |
| 895 | cmd->result = rval; |
| 896 | ql_dbg(ql_dbg_io + ql_dbg_verbose, vha, 0x3076, |
| 897 | "fc_remote_port_chkready failed for cmd=%p, rval=0x%x.\n", |
| 898 | cmd, rval); |
| 899 | goto qc24_fail_command; |
| 900 | } |
| 901 | |
| 902 | if (!fcport) { |
| 903 | cmd->result = DID_NO_CONNECT << 16; |
| 904 | goto qc24_fail_command; |
| 905 | } |
| 906 | |
| 907 | if (atomic_read(&fcport->state) != FCS_ONLINE) { |
| 908 | if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD || |
| 909 | atomic_read(&base_vha->loop_state) == LOOP_DEAD) { |
| 910 | ql_dbg(ql_dbg_io, vha, 0x3077, |
| 911 | "Returning DNC, fcport_state=%d loop_state=%d.\n", |
| 912 | atomic_read(&fcport->state), |
| 913 | atomic_read(&base_vha->loop_state)); |
| 914 | cmd->result = DID_NO_CONNECT << 16; |
| 915 | goto qc24_fail_command; |
| 916 | } |
| 917 | goto qc24_target_busy; |
| 918 | } |
| 919 | |
| 920 | /* |
| 921 | * Return target busy if we've received a non-zero retry_delay_timer |
| 922 | * in a FCP_RSP. |
| 923 | */ |
| 924 | if (fcport->retry_delay_timestamp == 0) { |
| 925 | /* retry delay not set */ |
| 926 | } else if (time_after(jiffies, fcport->retry_delay_timestamp)) |
| 927 | fcport->retry_delay_timestamp = 0; |
| 928 | else |
| 929 | goto qc24_target_busy; |
| 930 | |
| 931 | sp = qla2xxx_get_qpair_sp(qpair, fcport, GFP_ATOMIC); |
| 932 | if (!sp) |
| 933 | goto qc24_host_busy; |
| 934 | |
| 935 | sp->u.scmd.cmd = cmd; |
| 936 | sp->type = SRB_SCSI_CMD; |
| 937 | atomic_set(&sp->ref_count, 1); |
| 938 | CMD_SP(cmd) = (void *)sp; |
| 939 | sp->free = qla2xxx_qpair_sp_free_dma; |
| 940 | sp->done = qla2xxx_qpair_sp_compl; |
| 941 | sp->qpair = qpair; |
| 942 | |
| 943 | rval = ha->isp_ops->start_scsi_mq(sp); |
| 944 | if (rval != QLA_SUCCESS) { |
| 945 | ql_dbg(ql_dbg_io + ql_dbg_verbose, vha, 0x3078, |
| 946 | "Start scsi failed rval=%d for cmd=%p.\n", rval, cmd); |
| 947 | if (rval == QLA_INTERFACE_ERROR) |
| 948 | goto qc24_fail_command; |
| 949 | goto qc24_host_busy_free_sp; |
| 950 | } |
| 951 | |
| 952 | return 0; |
| 953 | |
| 954 | qc24_host_busy_free_sp: |
| 955 | qla2xxx_qpair_sp_free_dma(vha, sp); |
| 956 | |
| 957 | qc24_host_busy: |
| 958 | return SCSI_MLQUEUE_HOST_BUSY; |
| 959 | |
| 960 | qc24_target_busy: |
| 961 | return SCSI_MLQUEUE_TARGET_BUSY; |
| 962 | |
| 963 | qc24_fail_command: |
| 964 | cmd->scsi_done(cmd); |
| 965 | |
| 966 | return 0; |
| 967 | } |
| 968 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 969 | /* |
| 970 | * qla2x00_eh_wait_on_command |
| 971 | * Waits for the command to be returned by the Firmware for some |
| 972 | * max time. |
| 973 | * |
| 974 | * Input: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 975 | * cmd = Scsi Command to wait on. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 976 | * |
| 977 | * Return: |
| 978 | * Not Found : 0 |
| 979 | * Found : 1 |
| 980 | */ |
| 981 | static int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 982 | qla2x00_eh_wait_on_command(struct scsi_cmnd *cmd) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 983 | { |
Andrew Vasquez | fe74c71 | 2005-08-26 19:10:10 -0700 | [diff] [blame] | 984 | #define ABORT_POLLING_PERIOD 1000 |
Chad Dupuis | 478c3b0 | 2014-04-11 16:54:35 -0400 | [diff] [blame] | 985 | #define ABORT_WAIT_ITER ((2 * 1000) / (ABORT_POLLING_PERIOD)) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 986 | unsigned long wait_iter = ABORT_WAIT_ITER; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 987 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| 988 | struct qla_hw_data *ha = vha->hw; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 989 | int ret = QLA_SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 990 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 991 | if (unlikely(pci_channel_offline(ha->pdev)) || ha->flags.eeh_busy) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 992 | ql_dbg(ql_dbg_taskm, vha, 0x8005, |
| 993 | "Return:eh_wait.\n"); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 994 | return ret; |
| 995 | } |
| 996 | |
Lalit Chandivade | d970432 | 2009-08-25 11:36:18 -0700 | [diff] [blame] | 997 | while (CMD_SP(cmd) && wait_iter--) { |
Andrew Vasquez | fe74c71 | 2005-08-26 19:10:10 -0700 | [diff] [blame] | 998 | msleep(ABORT_POLLING_PERIOD); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 999 | } |
| 1000 | if (CMD_SP(cmd)) |
| 1001 | ret = QLA_FUNCTION_FAILED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1002 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1003 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1004 | } |
| 1005 | |
| 1006 | /* |
| 1007 | * qla2x00_wait_for_hba_online |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1008 | * Wait till the HBA is online after going through |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1009 | * <= MAX_RETRIES_OF_ISP_ABORT or |
| 1010 | * finally HBA is disabled ie marked offline |
| 1011 | * |
| 1012 | * Input: |
| 1013 | * ha - pointer to host adapter structure |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1014 | * |
| 1015 | * Note: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1016 | * Does context switching-Release SPIN_LOCK |
| 1017 | * (if any) before calling this routine. |
| 1018 | * |
| 1019 | * Return: |
| 1020 | * Success (Adapter is online) : 0 |
| 1021 | * Failed (Adapter is offline/disabled) : 1 |
| 1022 | */ |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 1023 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1024 | qla2x00_wait_for_hba_online(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1025 | { |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 1026 | int return_status; |
| 1027 | unsigned long wait_online; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1028 | struct qla_hw_data *ha = vha->hw; |
| 1029 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1030 | |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1031 | wait_online = jiffies + (MAX_LOOP_TIMEOUT * HZ); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1032 | while (((test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags)) || |
| 1033 | test_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags) || |
| 1034 | test_bit(ISP_ABORT_RETRY, &base_vha->dpc_flags) || |
| 1035 | ha->dpc_active) && time_before(jiffies, wait_online)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1036 | |
| 1037 | msleep(1000); |
| 1038 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1039 | if (base_vha->flags.online) |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1040 | return_status = QLA_SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1041 | else |
| 1042 | return_status = QLA_FUNCTION_FAILED; |
| 1043 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1044 | return (return_status); |
| 1045 | } |
| 1046 | |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 1047 | /* |
Sawan Chandak | 638a1a0 | 2014-04-11 16:54:38 -0400 | [diff] [blame] | 1048 | * qla2x00_wait_for_hba_ready |
| 1049 | * Wait till the HBA is ready before doing driver unload |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 1050 | * |
| 1051 | * Input: |
| 1052 | * ha - pointer to host adapter structure |
| 1053 | * |
| 1054 | * Note: |
| 1055 | * Does context switching-Release SPIN_LOCK |
| 1056 | * (if any) before calling this routine. |
| 1057 | * |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 1058 | */ |
Sawan Chandak | 638a1a0 | 2014-04-11 16:54:38 -0400 | [diff] [blame] | 1059 | static void |
| 1060 | qla2x00_wait_for_hba_ready(scsi_qla_host_t *vha) |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 1061 | { |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 1062 | struct qla_hw_data *ha = vha->hw; |
Sawan Chandak | 783e0dc | 2016-07-06 11:14:25 -0400 | [diff] [blame] | 1063 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 1064 | |
Dan Carpenter | 1d48390 | 2016-08-03 21:42:32 +0300 | [diff] [blame] | 1065 | while ((qla2x00_reset_active(vha) || ha->dpc_active || |
| 1066 | ha->flags.mbox_busy) || |
| 1067 | test_bit(FX00_RESET_RECOVERY, &vha->dpc_flags) || |
| 1068 | test_bit(FX00_TARGET_SCAN, &vha->dpc_flags)) { |
| 1069 | if (test_bit(UNLOADING, &base_vha->dpc_flags)) |
| 1070 | break; |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 1071 | msleep(1000); |
Sawan Chandak | 783e0dc | 2016-07-06 11:14:25 -0400 | [diff] [blame] | 1072 | } |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 1073 | } |
| 1074 | |
Lalit Chandivade | 2533cf6 | 2009-03-24 09:08:07 -0700 | [diff] [blame] | 1075 | int |
| 1076 | qla2x00_wait_for_chip_reset(scsi_qla_host_t *vha) |
| 1077 | { |
| 1078 | int return_status; |
| 1079 | unsigned long wait_reset; |
| 1080 | struct qla_hw_data *ha = vha->hw; |
| 1081 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 1082 | |
| 1083 | wait_reset = jiffies + (MAX_LOOP_TIMEOUT * HZ); |
| 1084 | while (((test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags)) || |
| 1085 | test_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags) || |
| 1086 | test_bit(ISP_ABORT_RETRY, &base_vha->dpc_flags) || |
| 1087 | ha->dpc_active) && time_before(jiffies, wait_reset)) { |
| 1088 | |
| 1089 | msleep(1000); |
| 1090 | |
| 1091 | if (!test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags) && |
| 1092 | ha->flags.chip_reset_done) |
| 1093 | break; |
| 1094 | } |
| 1095 | if (ha->flags.chip_reset_done) |
| 1096 | return_status = QLA_SUCCESS; |
| 1097 | else |
| 1098 | return_status = QLA_FUNCTION_FAILED; |
| 1099 | |
| 1100 | return return_status; |
| 1101 | } |
| 1102 | |
Giridhar Malavali | 083a469 | 2010-05-28 15:08:18 -0700 | [diff] [blame] | 1103 | static void |
| 1104 | sp_get(struct srb *sp) |
| 1105 | { |
| 1106 | atomic_inc(&sp->ref_count); |
| 1107 | } |
| 1108 | |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 1109 | #define ISP_REG_DISCONNECT 0xffffffffU |
| 1110 | /************************************************************************** |
| 1111 | * qla2x00_isp_reg_stat |
| 1112 | * |
| 1113 | * Description: |
| 1114 | * Read the host status register of ISP before aborting the command. |
| 1115 | * |
| 1116 | * Input: |
| 1117 | * ha = pointer to host adapter structure. |
| 1118 | * |
| 1119 | * |
| 1120 | * Returns: |
| 1121 | * Either true or false. |
| 1122 | * |
| 1123 | * Note: Return true if there is register disconnect. |
| 1124 | **************************************************************************/ |
| 1125 | static inline |
| 1126 | uint32_t qla2x00_isp_reg_stat(struct qla_hw_data *ha) |
| 1127 | { |
| 1128 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
| 1129 | |
| 1130 | return ((RD_REG_DWORD(®->host_status)) == ISP_REG_DISCONNECT); |
| 1131 | } |
| 1132 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1133 | /************************************************************************** |
| 1134 | * qla2xxx_eh_abort |
| 1135 | * |
| 1136 | * Description: |
| 1137 | * The abort function will abort the specified command. |
| 1138 | * |
| 1139 | * Input: |
| 1140 | * cmd = Linux SCSI command packet to be aborted. |
| 1141 | * |
| 1142 | * Returns: |
| 1143 | * Either SUCCESS or FAILED. |
| 1144 | * |
| 1145 | * Note: |
Michael Reed | 2ea0020 | 2006-04-27 16:25:30 -0700 | [diff] [blame] | 1146 | * Only return FAILED if command not returned by firmware. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1147 | **************************************************************************/ |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 1148 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1149 | qla2xxx_eh_abort(struct scsi_cmnd *cmd) |
| 1150 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1151 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1152 | srb_t *sp; |
Andrew Vasquez | 4e98d3b | 2011-02-23 15:27:17 -0800 | [diff] [blame] | 1153 | int ret; |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1154 | unsigned int id; |
| 1155 | uint64_t lun; |
Andrew Vasquez | 18e144d | 2005-05-27 15:04:47 -0700 | [diff] [blame] | 1156 | unsigned long flags; |
Chad Dupuis | f934c9d | 2014-04-11 16:54:31 -0400 | [diff] [blame] | 1157 | int rval, wait = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1158 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1159 | |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 1160 | if (qla2x00_isp_reg_stat(ha)) { |
| 1161 | ql_log(ql_log_info, vha, 0x8042, |
| 1162 | "PCI/Register disconnect, exiting.\n"); |
| 1163 | return FAILED; |
| 1164 | } |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1165 | if (!CMD_SP(cmd)) |
Michael Reed | 2ea0020 | 2006-04-27 16:25:30 -0700 | [diff] [blame] | 1166 | return SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1167 | |
Andrew Vasquez | 4e98d3b | 2011-02-23 15:27:17 -0800 | [diff] [blame] | 1168 | ret = fc_block_scsi_eh(cmd); |
| 1169 | if (ret != 0) |
| 1170 | return ret; |
| 1171 | ret = SUCCESS; |
| 1172 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1173 | id = cmd->device->id; |
| 1174 | lun = cmd->device->lun; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1175 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1176 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 1177 | sp = (srb_t *) CMD_SP(cmd); |
| 1178 | if (!sp) { |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1179 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 1180 | return SUCCESS; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1181 | } |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 1182 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1183 | ql_dbg(ql_dbg_taskm, vha, 0x8002, |
Chad Dupuis | c7bc4ca | 2015-08-04 13:37:57 -0400 | [diff] [blame] | 1184 | "Aborting from RISC nexus=%ld:%d:%llu sp=%p cmd=%p handle=%x\n", |
| 1185 | vha->host_no, id, lun, sp, cmd, sp->handle); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 1186 | |
| 1187 | /* Get a reference to the sp and drop the lock.*/ |
| 1188 | sp_get(sp); |
| 1189 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1190 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Chad Dupuis | f934c9d | 2014-04-11 16:54:31 -0400 | [diff] [blame] | 1191 | rval = ha->isp_ops->abort_command(sp); |
| 1192 | if (rval) { |
Chad Dupuis | 9621942 | 2015-08-04 13:38:00 -0400 | [diff] [blame] | 1193 | if (rval == QLA_FUNCTION_PARAMETER_ERROR) |
Chad Dupuis | f934c9d | 2014-04-11 16:54:31 -0400 | [diff] [blame] | 1194 | ret = SUCCESS; |
Chad Dupuis | 9621942 | 2015-08-04 13:38:00 -0400 | [diff] [blame] | 1195 | else |
Chad Dupuis | f934c9d | 2014-04-11 16:54:31 -0400 | [diff] [blame] | 1196 | ret = FAILED; |
| 1197 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1198 | ql_dbg(ql_dbg_taskm, vha, 0x8003, |
Chad Dupuis | f934c9d | 2014-04-11 16:54:31 -0400 | [diff] [blame] | 1199 | "Abort command mbx failed cmd=%p, rval=%x.\n", cmd, rval); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 1200 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1201 | ql_dbg(ql_dbg_taskm, vha, 0x8004, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1202 | "Abort command mbx success cmd=%p.\n", cmd); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 1203 | wait = 1; |
| 1204 | } |
Saurav Kashyap | 7594206 | 2011-08-16 11:29:25 -0700 | [diff] [blame] | 1205 | |
| 1206 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1207 | sp->done(ha, sp, 0); |
Saurav Kashyap | 7594206 | 2011-08-16 11:29:25 -0700 | [diff] [blame] | 1208 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1209 | |
Chad Dupuis | bc91ade | 2011-08-16 11:29:26 -0700 | [diff] [blame] | 1210 | /* Did the command return during mailbox execution? */ |
| 1211 | if (ret == FAILED && !CMD_SP(cmd)) |
| 1212 | ret = SUCCESS; |
| 1213 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1214 | /* Wait for the command to be returned. */ |
Michael Reed | 2ea0020 | 2006-04-27 16:25:30 -0700 | [diff] [blame] | 1215 | if (wait) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1216 | if (qla2x00_eh_wait_on_command(cmd) != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1217 | ql_log(ql_log_warn, vha, 0x8006, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1218 | "Abort handler timed out cmd=%p.\n", cmd); |
Michael Reed | 2ea0020 | 2006-04-27 16:25:30 -0700 | [diff] [blame] | 1219 | ret = FAILED; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1220 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1221 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1222 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1223 | ql_log(ql_log_info, vha, 0x801c, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1224 | "Abort command issued nexus=%ld:%d:%llu -- %d %x.\n", |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1225 | vha->host_no, id, lun, wait, ret); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1226 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1227 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1228 | } |
| 1229 | |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1230 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1231 | 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] | 1232 | uint64_t l, enum nexus_wait_type type) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1233 | { |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1234 | int cnt, match, status; |
Andrew Vasquez | 18e144d | 2005-05-27 15:04:47 -0700 | [diff] [blame] | 1235 | unsigned long flags; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1236 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1237 | struct req_que *req; |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1238 | srb_t *sp; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1239 | struct scsi_cmnd *cmd; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1240 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1241 | status = QLA_SUCCESS; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1242 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1243 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 67c2e93 | 2009-04-06 22:33:42 -0700 | [diff] [blame] | 1244 | req = vha->req; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1245 | for (cnt = 1; status == QLA_SUCCESS && |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 1246 | cnt < req->num_outstanding_cmds; cnt++) { |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1247 | sp = req->outstanding_cmds[cnt]; |
| 1248 | if (!sp) |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1249 | continue; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1250 | if (sp->type != SRB_SCSI_CMD) |
Andrew Vasquez | cf53b06 | 2009-08-20 11:06:04 -0700 | [diff] [blame] | 1251 | continue; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1252 | if (vha->vp_idx != sp->fcport->vha->vp_idx) |
| 1253 | continue; |
| 1254 | match = 0; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1255 | cmd = GET_CMD_SP(sp); |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1256 | switch (type) { |
| 1257 | case WAIT_HOST: |
| 1258 | match = 1; |
| 1259 | break; |
| 1260 | case WAIT_TARGET: |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1261 | match = cmd->device->id == t; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1262 | break; |
| 1263 | case WAIT_LUN: |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1264 | match = (cmd->device->id == t && |
| 1265 | cmd->device->lun == l); |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1266 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1267 | } |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1268 | if (!match) |
| 1269 | continue; |
| 1270 | |
| 1271 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1272 | status = qla2x00_eh_wait_on_command(cmd); |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1273 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1274 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1275 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1276 | |
| 1277 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1278 | } |
| 1279 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1280 | static char *reset_errors[] = { |
| 1281 | "HBA not online", |
| 1282 | "HBA not ready", |
| 1283 | "Task management failed", |
| 1284 | "Waiting for command completions", |
| 1285 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1286 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1287 | static int |
| 1288 | __qla2xxx_eh_generic_reset(char *name, enum nexus_wait_type type, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1289 | 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] | 1290 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1291 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1292 | fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; |
| 1293 | int err; |
| 1294 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1295 | if (!fcport) { |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1296 | return FAILED; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1297 | } |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1298 | |
Andrew Vasquez | 4e98d3b | 2011-02-23 15:27:17 -0800 | [diff] [blame] | 1299 | err = fc_block_scsi_eh(cmd); |
| 1300 | if (err != 0) |
| 1301 | return err; |
| 1302 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1303 | ql_log(ql_log_info, vha, 0x8009, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1304 | "%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] | 1305 | cmd->device->id, cmd->device->lun, cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1306 | |
| 1307 | err = 0; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1308 | if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) { |
| 1309 | ql_log(ql_log_warn, vha, 0x800a, |
| 1310 | "Wait for hba online failed for cmd=%p.\n", cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1311 | goto eh_reset_failed; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1312 | } |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1313 | err = 2; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1314 | if (do_reset(fcport, cmd->device->lun, cmd->request->cpu + 1) |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1315 | != QLA_SUCCESS) { |
| 1316 | ql_log(ql_log_warn, vha, 0x800c, |
| 1317 | "do_reset failed for cmd=%p.\n", cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1318 | goto eh_reset_failed; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1319 | } |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1320 | err = 3; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1321 | if (qla2x00_eh_wait_for_pending_commands(vha, cmd->device->id, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1322 | cmd->device->lun, type) != QLA_SUCCESS) { |
| 1323 | ql_log(ql_log_warn, vha, 0x800d, |
Masanari Iida | d6a0358 | 2012-08-22 14:20:58 -0400 | [diff] [blame] | 1324 | "wait for pending cmds failed for cmd=%p.\n", cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1325 | goto eh_reset_failed; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1326 | } |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1327 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1328 | ql_log(ql_log_info, vha, 0x800e, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1329 | "%s RESET SUCCEEDED nexus:%ld:%d:%llu cmd=%p.\n", name, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1330 | vha->host_no, cmd->device->id, cmd->device->lun, cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1331 | |
| 1332 | return SUCCESS; |
| 1333 | |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1334 | eh_reset_failed: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1335 | ql_log(ql_log_info, vha, 0x800f, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1336 | "%s RESET FAILED: %s nexus=%ld:%d:%llu cmd=%p.\n", name, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1337 | reset_errors[err], vha->host_no, cmd->device->id, cmd->device->lun, |
| 1338 | cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1339 | return FAILED; |
| 1340 | } |
| 1341 | |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 1342 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1343 | qla2xxx_eh_device_reset(struct scsi_cmnd *cmd) |
| 1344 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1345 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| 1346 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1347 | |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 1348 | if (qla2x00_isp_reg_stat(ha)) { |
| 1349 | ql_log(ql_log_info, vha, 0x803e, |
| 1350 | "PCI/Register disconnect, exiting.\n"); |
| 1351 | return FAILED; |
| 1352 | } |
| 1353 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1354 | return __qla2xxx_eh_generic_reset("DEVICE", WAIT_LUN, cmd, |
| 1355 | ha->isp_ops->lun_reset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1356 | } |
| 1357 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1358 | static int |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1359 | qla2xxx_eh_target_reset(struct scsi_cmnd *cmd) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1360 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1361 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| 1362 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1363 | |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 1364 | if (qla2x00_isp_reg_stat(ha)) { |
| 1365 | ql_log(ql_log_info, vha, 0x803f, |
| 1366 | "PCI/Register disconnect, exiting.\n"); |
| 1367 | return FAILED; |
| 1368 | } |
| 1369 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1370 | return __qla2xxx_eh_generic_reset("TARGET", WAIT_TARGET, cmd, |
| 1371 | ha->isp_ops->target_reset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1372 | } |
| 1373 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1374 | /************************************************************************** |
| 1375 | * qla2xxx_eh_bus_reset |
| 1376 | * |
| 1377 | * Description: |
| 1378 | * The bus reset function will reset the bus and abort any executing |
| 1379 | * commands. |
| 1380 | * |
| 1381 | * Input: |
| 1382 | * cmd = Linux SCSI command packet of the command that cause the |
| 1383 | * bus reset. |
| 1384 | * |
| 1385 | * Returns: |
| 1386 | * SUCCESS/FAILURE (defined as macro in scsi.h). |
| 1387 | * |
| 1388 | **************************************************************************/ |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 1389 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1390 | qla2xxx_eh_bus_reset(struct scsi_cmnd *cmd) |
| 1391 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1392 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 1393 | fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1394 | int ret = FAILED; |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1395 | unsigned int id; |
| 1396 | uint64_t lun; |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 1397 | struct qla_hw_data *ha = vha->hw; |
| 1398 | |
| 1399 | if (qla2x00_isp_reg_stat(ha)) { |
| 1400 | ql_log(ql_log_info, vha, 0x8040, |
| 1401 | "PCI/Register disconnect, exiting.\n"); |
| 1402 | return FAILED; |
| 1403 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1404 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1405 | id = cmd->device->id; |
| 1406 | lun = cmd->device->lun; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1407 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1408 | if (!fcport) { |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1409 | return ret; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1410 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1411 | |
Andrew Vasquez | 4e98d3b | 2011-02-23 15:27:17 -0800 | [diff] [blame] | 1412 | ret = fc_block_scsi_eh(cmd); |
| 1413 | if (ret != 0) |
| 1414 | return ret; |
| 1415 | ret = FAILED; |
| 1416 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1417 | ql_log(ql_log_info, vha, 0x8012, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1418 | "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] | 1419 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1420 | if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1421 | ql_log(ql_log_fatal, vha, 0x8013, |
| 1422 | "Wait for hba online failed board disabled.\n"); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1423 | goto eh_bus_reset_done; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1424 | } |
| 1425 | |
Saurav Kashyap | ad53768 | 2011-11-18 09:02:09 -0800 | [diff] [blame] | 1426 | if (qla2x00_loop_reset(vha) == QLA_SUCCESS) |
| 1427 | ret = SUCCESS; |
| 1428 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1429 | if (ret == FAILED) |
| 1430 | goto eh_bus_reset_done; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1431 | |
Andrew Vasquez | 9a41a62 | 2005-09-20 13:25:53 -0700 | [diff] [blame] | 1432 | /* Flush outstanding commands. */ |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1433 | if (qla2x00_eh_wait_for_pending_commands(vha, 0, 0, WAIT_HOST) != |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1434 | QLA_SUCCESS) { |
| 1435 | ql_log(ql_log_warn, vha, 0x8014, |
| 1436 | "Wait for pending commands failed.\n"); |
Andrew Vasquez | 9a41a62 | 2005-09-20 13:25:53 -0700 | [diff] [blame] | 1437 | ret = FAILED; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1438 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1439 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1440 | eh_bus_reset_done: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1441 | ql_log(ql_log_warn, vha, 0x802b, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1442 | "BUS RESET %s nexus=%ld:%d:%llu.\n", |
Masanari Iida | d6a0358 | 2012-08-22 14:20:58 -0400 | [diff] [blame] | 1443 | (ret == FAILED) ? "FAILED" : "SUCCEEDED", vha->host_no, id, lun); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1444 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1445 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1446 | } |
| 1447 | |
| 1448 | /************************************************************************** |
| 1449 | * qla2xxx_eh_host_reset |
| 1450 | * |
| 1451 | * Description: |
| 1452 | * The reset function will reset the Adapter. |
| 1453 | * |
| 1454 | * Input: |
| 1455 | * cmd = Linux SCSI command packet of the command that cause the |
| 1456 | * adapter reset. |
| 1457 | * |
| 1458 | * Returns: |
| 1459 | * Either SUCCESS or FAILED. |
| 1460 | * |
| 1461 | * Note: |
| 1462 | **************************************************************************/ |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 1463 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1464 | qla2xxx_eh_host_reset(struct scsi_cmnd *cmd) |
| 1465 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1466 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1467 | struct qla_hw_data *ha = vha->hw; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1468 | int ret = FAILED; |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1469 | unsigned int id; |
| 1470 | uint64_t lun; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1471 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1472 | |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 1473 | if (qla2x00_isp_reg_stat(ha)) { |
| 1474 | ql_log(ql_log_info, vha, 0x8041, |
| 1475 | "PCI/Register disconnect, exiting.\n"); |
| 1476 | schedule_work(&ha->board_disable); |
| 1477 | return SUCCESS; |
| 1478 | } |
| 1479 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1480 | id = cmd->device->id; |
| 1481 | lun = cmd->device->lun; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1482 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1483 | ql_log(ql_log_info, vha, 0x8018, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1484 | "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] | 1485 | |
Chad Dupuis | 63ee707 | 2014-04-11 16:54:46 -0400 | [diff] [blame] | 1486 | /* |
| 1487 | * No point in issuing another reset if one is active. Also do not |
| 1488 | * attempt a reset if we are updating flash. |
| 1489 | */ |
| 1490 | if (qla2x00_reset_active(vha) || ha->optrom_state != QLA_SWAITING) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1491 | goto eh_host_reset_lock; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1492 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1493 | if (vha != base_vha) { |
| 1494 | if (qla2x00_vp_abort_isp(vha)) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1495 | goto eh_host_reset_lock; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1496 | } else { |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 1497 | if (IS_P3P_TYPE(vha->hw)) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1498 | if (!qla82xx_fcoe_ctx_reset(vha)) { |
| 1499 | /* Ctx reset success */ |
| 1500 | ret = SUCCESS; |
| 1501 | goto eh_host_reset_lock; |
| 1502 | } |
| 1503 | /* fall thru if ctx reset failed */ |
| 1504 | } |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 1505 | if (ha->wq) |
| 1506 | flush_workqueue(ha->wq); |
| 1507 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1508 | set_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1509 | if (ha->isp_ops->abort_isp(base_vha)) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1510 | clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
| 1511 | /* failed. schedule dpc to try */ |
| 1512 | set_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags); |
| 1513 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1514 | if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) { |
| 1515 | ql_log(ql_log_warn, vha, 0x802a, |
| 1516 | "wait for hba online failed.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1517 | goto eh_host_reset_lock; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1518 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1519 | } |
| 1520 | clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1521 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1522 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1523 | /* Waiting for command to be returned to OS.*/ |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1524 | if (qla2x00_eh_wait_for_pending_commands(vha, 0, 0, WAIT_HOST) == |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1525 | QLA_SUCCESS) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1526 | ret = SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1527 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1528 | eh_host_reset_lock: |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1529 | ql_log(ql_log_info, vha, 0x8017, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1530 | "ADAPTER RESET %s nexus=%ld:%d:%llu.\n", |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1531 | (ret == FAILED) ? "FAILED" : "SUCCEEDED", vha->host_no, id, lun); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1532 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1533 | return ret; |
| 1534 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1535 | |
| 1536 | /* |
| 1537 | * qla2x00_loop_reset |
| 1538 | * Issue loop reset. |
| 1539 | * |
| 1540 | * Input: |
| 1541 | * ha = adapter block pointer. |
| 1542 | * |
| 1543 | * Returns: |
| 1544 | * 0 = success |
| 1545 | */ |
Andrew Vasquez | a4722cf | 2008-01-17 09:02:12 -0800 | [diff] [blame] | 1546 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1547 | qla2x00_loop_reset(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1548 | { |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 1549 | int ret; |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 1550 | struct fc_port *fcport; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1551 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1552 | |
Armen Baloyan | 5854771 | 2013-08-27 01:37:33 -0400 | [diff] [blame] | 1553 | if (IS_QLAFX00(ha)) { |
| 1554 | return qlafx00_loop_reset(vha); |
| 1555 | } |
| 1556 | |
Giridhar Malavali | f4c496c | 2010-05-04 15:01:33 -0700 | [diff] [blame] | 1557 | if (ql2xtargetreset == 1 && ha->flags.enable_target_reset) { |
Andrew Vasquez | 55e5ed2 | 2010-02-18 10:07:25 -0800 | [diff] [blame] | 1558 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
| 1559 | if (fcport->port_type != FCT_TARGET) |
| 1560 | continue; |
| 1561 | |
| 1562 | ret = ha->isp_ops->target_reset(fcport, 0, 0); |
| 1563 | if (ret != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1564 | ql_dbg(ql_dbg_taskm, vha, 0x802c, |
Armen Baloyan | 5854771 | 2013-08-27 01:37:33 -0400 | [diff] [blame] | 1565 | "Bus Reset failed: Reset=%d " |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1566 | "d_id=%x.\n", ret, fcport->d_id.b24); |
Andrew Vasquez | 55e5ed2 | 2010-02-18 10:07:25 -0800 | [diff] [blame] | 1567 | } |
| 1568 | } |
| 1569 | } |
| 1570 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 1571 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1572 | if (ha->flags.enable_lip_full_login && !IS_CNA_CAPABLE(ha)) { |
Andrew Vasquez | 0b7e7c5 | 2013-02-08 01:57:42 -0500 | [diff] [blame] | 1573 | atomic_set(&vha->loop_state, LOOP_DOWN); |
| 1574 | atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME); |
| 1575 | qla2x00_mark_all_devices_lost(vha, 0); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1576 | ret = qla2x00_full_login_lip(vha); |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 1577 | if (ret != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1578 | ql_dbg(ql_dbg_taskm, vha, 0x802d, |
| 1579 | "full_login_lip=%d.\n", ret); |
Anirban Chakraborty | 749af3d | 2008-11-14 13:48:12 -0800 | [diff] [blame] | 1580 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1581 | } |
| 1582 | |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 1583 | if (ha->flags.enable_lip_reset) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1584 | ret = qla2x00_lip_reset(vha); |
Saurav Kashyap | ad53768 | 2011-11-18 09:02:09 -0800 | [diff] [blame] | 1585 | if (ret != QLA_SUCCESS) |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1586 | ql_dbg(ql_dbg_taskm, vha, 0x802e, |
| 1587 | "lip_reset failed (%d).\n", ret); |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 1588 | } |
| 1589 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1590 | /* 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] | 1591 | vha->marker_needed = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1592 | |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 1593 | return QLA_SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1594 | } |
| 1595 | |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1596 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1597 | qla2x00_abort_all_cmds(scsi_qla_host_t *vha, int res) |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1598 | { |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1599 | int que, cnt; |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1600 | unsigned long flags; |
| 1601 | srb_t *sp; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1602 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1603 | struct req_que *req; |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1604 | |
Arun Easi | c0cb449 | 2014-09-25 06:14:51 -0400 | [diff] [blame] | 1605 | qlt_host_reset_handler(ha); |
| 1606 | |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1607 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1608 | for (que = 0; que < ha->max_req_queues; que++) { |
Anirban Chakraborty | 29bdccb | 2009-01-08 15:41:08 -0800 | [diff] [blame] | 1609 | req = ha->req_q_map[que]; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1610 | if (!req) |
| 1611 | continue; |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 1612 | if (!req->outstanding_cmds) |
| 1613 | continue; |
| 1614 | for (cnt = 1; cnt < req->num_outstanding_cmds; cnt++) { |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1615 | sp = req->outstanding_cmds[cnt]; |
Andrew Vasquez | e612d46 | 2009-03-24 09:08:04 -0700 | [diff] [blame] | 1616 | if (sp) { |
Mauricio Faria de Oliveira | c733ab3 | 2016-11-14 19:26:22 -0200 | [diff] [blame] | 1617 | /* Don't abort commands in adapter during EEH |
| 1618 | * recovery as it's not accessible/responding. |
Mauricio Faria de Oliveira | 1535aa7 | 2016-11-07 17:53:31 -0200 | [diff] [blame] | 1619 | */ |
Mauricio Faria de Oliveira | 2780f3c | 2017-01-25 22:07:06 -0200 | [diff] [blame] | 1620 | if (GET_CMD_SP(sp) && !ha->flags.eeh_busy) { |
Mauricio Faria de Oliveira | c733ab3 | 2016-11-14 19:26:22 -0200 | [diff] [blame] | 1621 | /* Get a reference to the sp and drop the lock. |
| 1622 | * The reference ensures this sp->done() call |
| 1623 | * - and not the call in qla2xxx_eh_abort() - |
| 1624 | * ends the SCSI command (with result 'res'). |
| 1625 | */ |
| 1626 | sp_get(sp); |
| 1627 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1628 | qla2xxx_eh_abort(GET_CMD_SP(sp)); |
| 1629 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1630 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1631 | req->outstanding_cmds[cnt] = NULL; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1632 | sp->done(vha, sp, res); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1633 | } |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1634 | } |
| 1635 | } |
| 1636 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1637 | } |
| 1638 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1639 | static int |
| 1640 | qla2xxx_slave_alloc(struct scsi_device *sdev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1641 | { |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 1642 | struct fc_rport *rport = starget_to_rport(scsi_target(sdev)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1643 | |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 1644 | if (!rport || fc_remote_port_chkready(rport)) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1645 | return -ENXIO; |
| 1646 | |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 1647 | sdev->hostdata = *(fc_port_t **)rport->dd_data; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1648 | |
| 1649 | return 0; |
| 1650 | } |
| 1651 | |
| 1652 | static int |
| 1653 | qla2xxx_slave_configure(struct scsi_device *sdev) |
| 1654 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1655 | scsi_qla_host_t *vha = shost_priv(sdev->host); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1656 | struct req_que *req = vha->req; |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 1657 | |
Arun Easi | 9e522cd | 2012-08-22 14:21:31 -0400 | [diff] [blame] | 1658 | if (IS_T10_PI_CAPABLE(vha->hw)) |
| 1659 | blk_queue_update_dma_alignment(sdev->request_queue, 0x7); |
| 1660 | |
Christoph Hellwig | db5ed4d | 2014-11-13 15:08:42 +0100 | [diff] [blame] | 1661 | scsi_change_queue_depth(sdev, req->max_q_depth); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1662 | return 0; |
| 1663 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1664 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1665 | static void |
| 1666 | qla2xxx_slave_destroy(struct scsi_device *sdev) |
| 1667 | { |
| 1668 | sdev->hostdata = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1669 | } |
| 1670 | |
| 1671 | /** |
| 1672 | * qla2x00_config_dma_addressing() - Configure OS DMA addressing method. |
| 1673 | * @ha: HA context |
| 1674 | * |
| 1675 | * At exit, the @ha's flags.enable_64bit_addressing set to indicated |
| 1676 | * supported addressing method. |
| 1677 | */ |
| 1678 | static void |
Andrew Vasquez | 53303c4 | 2009-01-22 09:45:37 -0800 | [diff] [blame] | 1679 | qla2x00_config_dma_addressing(struct qla_hw_data *ha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1680 | { |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1681 | /* Assume a 32bit DMA mask. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1682 | ha->flags.enable_64bit_addressing = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1683 | |
Yang Hongyang | 6a35528 | 2009-04-06 19:01:13 -0700 | [diff] [blame] | 1684 | if (!dma_set_mask(&ha->pdev->dev, DMA_BIT_MASK(64))) { |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1685 | /* Any upper-dword bits set? */ |
| 1686 | if (MSD(dma_get_required_mask(&ha->pdev->dev)) && |
Yang Hongyang | 6a35528 | 2009-04-06 19:01:13 -0700 | [diff] [blame] | 1687 | !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) { |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1688 | /* Ok, a 64bit DMA mask is applicable. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1689 | ha->flags.enable_64bit_addressing = 1; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1690 | ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64; |
| 1691 | ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64; |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1692 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1693 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1694 | } |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1695 | |
Yang Hongyang | 284901a | 2009-04-06 19:01:15 -0700 | [diff] [blame] | 1696 | dma_set_mask(&ha->pdev->dev, DMA_BIT_MASK(32)); |
| 1697 | pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(32)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1698 | } |
| 1699 | |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1700 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1701 | qla2x00_enable_intrs(struct qla_hw_data *ha) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1702 | { |
| 1703 | unsigned long flags = 0; |
| 1704 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
| 1705 | |
| 1706 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1707 | ha->interrupts_on = 1; |
| 1708 | /* enable risc and host interrupts */ |
| 1709 | WRT_REG_WORD(®->ictrl, ICR_EN_INT | ICR_EN_RISC); |
| 1710 | RD_REG_WORD(®->ictrl); |
| 1711 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1712 | |
| 1713 | } |
| 1714 | |
| 1715 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1716 | qla2x00_disable_intrs(struct qla_hw_data *ha) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1717 | { |
| 1718 | unsigned long flags = 0; |
| 1719 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
| 1720 | |
| 1721 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1722 | ha->interrupts_on = 0; |
| 1723 | /* disable risc and host interrupts */ |
| 1724 | WRT_REG_WORD(®->ictrl, 0); |
| 1725 | RD_REG_WORD(®->ictrl); |
| 1726 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1727 | } |
| 1728 | |
| 1729 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1730 | qla24xx_enable_intrs(struct qla_hw_data *ha) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1731 | { |
| 1732 | unsigned long flags = 0; |
| 1733 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
| 1734 | |
| 1735 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1736 | ha->interrupts_on = 1; |
| 1737 | WRT_REG_DWORD(®->ictrl, ICRX_EN_RISC_INT); |
| 1738 | RD_REG_DWORD(®->ictrl); |
| 1739 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1740 | } |
| 1741 | |
| 1742 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1743 | qla24xx_disable_intrs(struct qla_hw_data *ha) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1744 | { |
| 1745 | unsigned long flags = 0; |
| 1746 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
| 1747 | |
Andrew Vasquez | 124f85e | 2009-01-05 11:18:06 -0800 | [diff] [blame] | 1748 | if (IS_NOPOLLING_TYPE(ha)) |
| 1749 | return; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1750 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1751 | ha->interrupts_on = 0; |
| 1752 | WRT_REG_DWORD(®->ictrl, 0); |
| 1753 | RD_REG_DWORD(®->ictrl); |
| 1754 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1755 | } |
| 1756 | |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1757 | static int |
| 1758 | qla2x00_iospace_config(struct qla_hw_data *ha) |
| 1759 | { |
| 1760 | resource_size_t pio; |
| 1761 | uint16_t msix; |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1762 | |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1763 | if (pci_request_selected_regions(ha->pdev, ha->bars, |
| 1764 | QLA2XXX_DRIVER_NAME)) { |
| 1765 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0011, |
| 1766 | "Failed to reserve PIO/MMIO regions (%s), aborting.\n", |
| 1767 | pci_name(ha->pdev)); |
| 1768 | goto iospace_error_exit; |
| 1769 | } |
| 1770 | if (!(ha->bars & 1)) |
| 1771 | goto skip_pio; |
| 1772 | |
| 1773 | /* We only need PIO for Flash operations on ISP2312 v2 chips. */ |
| 1774 | pio = pci_resource_start(ha->pdev, 0); |
| 1775 | if (pci_resource_flags(ha->pdev, 0) & IORESOURCE_IO) { |
| 1776 | if (pci_resource_len(ha->pdev, 0) < MIN_IOBASE_LEN) { |
| 1777 | ql_log_pci(ql_log_warn, ha->pdev, 0x0012, |
| 1778 | "Invalid pci I/O region size (%s).\n", |
| 1779 | pci_name(ha->pdev)); |
| 1780 | pio = 0; |
| 1781 | } |
| 1782 | } else { |
| 1783 | ql_log_pci(ql_log_warn, ha->pdev, 0x0013, |
| 1784 | "Region #0 no a PIO resource (%s).\n", |
| 1785 | pci_name(ha->pdev)); |
| 1786 | pio = 0; |
| 1787 | } |
| 1788 | ha->pio_address = pio; |
| 1789 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0014, |
| 1790 | "PIO address=%llu.\n", |
| 1791 | (unsigned long long)ha->pio_address); |
| 1792 | |
| 1793 | skip_pio: |
| 1794 | /* Use MMIO operations for all accesses. */ |
| 1795 | if (!(pci_resource_flags(ha->pdev, 1) & IORESOURCE_MEM)) { |
| 1796 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0015, |
| 1797 | "Region #1 not an MMIO resource (%s), aborting.\n", |
| 1798 | pci_name(ha->pdev)); |
| 1799 | goto iospace_error_exit; |
| 1800 | } |
| 1801 | if (pci_resource_len(ha->pdev, 1) < MIN_IOBASE_LEN) { |
| 1802 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0016, |
| 1803 | "Invalid PCI mem region size (%s), aborting.\n", |
| 1804 | pci_name(ha->pdev)); |
| 1805 | goto iospace_error_exit; |
| 1806 | } |
| 1807 | |
| 1808 | ha->iobase = ioremap(pci_resource_start(ha->pdev, 1), MIN_IOBASE_LEN); |
| 1809 | if (!ha->iobase) { |
| 1810 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0017, |
| 1811 | "Cannot remap MMIO (%s), aborting.\n", |
| 1812 | pci_name(ha->pdev)); |
| 1813 | goto iospace_error_exit; |
| 1814 | } |
| 1815 | |
| 1816 | /* Determine queue resources */ |
| 1817 | ha->max_req_queues = ha->max_rsp_queues = 1; |
Michael Hernandez | f54f2cb | 2017-02-15 15:37:19 -0800 | [diff] [blame^] | 1818 | ha->msix_count = QLA_BASE_VECTORS; |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 1819 | if (!ql2xmqsupport || (!IS_QLA25XX(ha) && !IS_QLA81XX(ha))) |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1820 | goto mqiobase_exit; |
| 1821 | |
| 1822 | ha->mqiobase = ioremap(pci_resource_start(ha->pdev, 3), |
| 1823 | pci_resource_len(ha->pdev, 3)); |
| 1824 | if (ha->mqiobase) { |
| 1825 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0018, |
| 1826 | "MQIO Base=%p.\n", ha->mqiobase); |
| 1827 | /* Read MSIX vector size of the board */ |
| 1828 | pci_read_config_word(ha->pdev, QLA_PCI_MSIX_CONTROL, &msix); |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 1829 | ha->msix_count = msix + 1; |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1830 | /* Max queues are bounded by available msix vectors */ |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 1831 | /* MB interrupt uses 1 vector */ |
| 1832 | ha->max_req_queues = ha->msix_count - 1; |
| 1833 | ha->max_rsp_queues = ha->max_req_queues; |
| 1834 | /* Queue pairs is the max value minus the base queue pair */ |
| 1835 | ha->max_qpairs = ha->max_rsp_queues - 1; |
| 1836 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0188, |
| 1837 | "Max no of queues pairs: %d.\n", ha->max_qpairs); |
| 1838 | |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1839 | ql_log_pci(ql_log_info, ha->pdev, 0x001a, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 1840 | "MSI-X vector count: %d.\n", ha->msix_count); |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1841 | } else |
| 1842 | ql_log_pci(ql_log_info, ha->pdev, 0x001b, |
| 1843 | "BAR 3 not enabled.\n"); |
| 1844 | |
| 1845 | mqiobase_exit: |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1846 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x001c, |
Michael Hernandez | f54f2cb | 2017-02-15 15:37:19 -0800 | [diff] [blame^] | 1847 | "MSIX Count: %d.\n", ha->msix_count); |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1848 | return (0); |
| 1849 | |
| 1850 | iospace_error_exit: |
| 1851 | return (-ENOMEM); |
| 1852 | } |
| 1853 | |
| 1854 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1855 | static int |
| 1856 | qla83xx_iospace_config(struct qla_hw_data *ha) |
| 1857 | { |
| 1858 | uint16_t msix; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1859 | |
| 1860 | if (pci_request_selected_regions(ha->pdev, ha->bars, |
| 1861 | QLA2XXX_DRIVER_NAME)) { |
| 1862 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0117, |
| 1863 | "Failed to reserve PIO/MMIO regions (%s), aborting.\n", |
| 1864 | pci_name(ha->pdev)); |
| 1865 | |
| 1866 | goto iospace_error_exit; |
| 1867 | } |
| 1868 | |
| 1869 | /* Use MMIO operations for all accesses. */ |
| 1870 | if (!(pci_resource_flags(ha->pdev, 0) & IORESOURCE_MEM)) { |
| 1871 | ql_log_pci(ql_log_warn, ha->pdev, 0x0118, |
| 1872 | "Invalid pci I/O region size (%s).\n", |
| 1873 | pci_name(ha->pdev)); |
| 1874 | goto iospace_error_exit; |
| 1875 | } |
| 1876 | if (pci_resource_len(ha->pdev, 0) < MIN_IOBASE_LEN) { |
| 1877 | ql_log_pci(ql_log_warn, ha->pdev, 0x0119, |
| 1878 | "Invalid PCI mem region size (%s), aborting\n", |
| 1879 | pci_name(ha->pdev)); |
| 1880 | goto iospace_error_exit; |
| 1881 | } |
| 1882 | |
| 1883 | ha->iobase = ioremap(pci_resource_start(ha->pdev, 0), MIN_IOBASE_LEN); |
| 1884 | if (!ha->iobase) { |
| 1885 | ql_log_pci(ql_log_fatal, ha->pdev, 0x011a, |
| 1886 | "Cannot remap MMIO (%s), aborting.\n", |
| 1887 | pci_name(ha->pdev)); |
| 1888 | goto iospace_error_exit; |
| 1889 | } |
| 1890 | |
| 1891 | /* 64bit PCI BAR - BAR2 will correspoond to region 4 */ |
| 1892 | /* 83XX 26XX always use MQ type access for queues |
| 1893 | * - mbar 2, a.k.a region 4 */ |
| 1894 | ha->max_req_queues = ha->max_rsp_queues = 1; |
Michael Hernandez | f54f2cb | 2017-02-15 15:37:19 -0800 | [diff] [blame^] | 1895 | ha->msix_count = QLA_BASE_VECTORS; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1896 | ha->mqiobase = ioremap(pci_resource_start(ha->pdev, 4), |
| 1897 | pci_resource_len(ha->pdev, 4)); |
| 1898 | |
| 1899 | if (!ha->mqiobase) { |
| 1900 | ql_log_pci(ql_log_fatal, ha->pdev, 0x011d, |
| 1901 | "BAR2/region4 not enabled\n"); |
| 1902 | goto mqiobase_exit; |
| 1903 | } |
| 1904 | |
| 1905 | ha->msixbase = ioremap(pci_resource_start(ha->pdev, 2), |
| 1906 | pci_resource_len(ha->pdev, 2)); |
| 1907 | if (ha->msixbase) { |
| 1908 | /* Read MSIX vector size of the board */ |
| 1909 | pci_read_config_word(ha->pdev, |
| 1910 | QLA_83XX_PCI_MSIX_CONTROL, &msix); |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 1911 | ha->msix_count = msix + 1; |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 1912 | /* |
| 1913 | * By default, driver uses at least two msix vectors |
| 1914 | * (default & rspq) |
| 1915 | */ |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 1916 | if (ql2xmqsupport) { |
| 1917 | /* MB interrupt uses 1 vector */ |
| 1918 | ha->max_req_queues = ha->msix_count - 1; |
| 1919 | ha->max_rsp_queues = ha->max_req_queues; |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 1920 | |
| 1921 | /* ATIOQ needs 1 vector. That's 1 less QPair */ |
| 1922 | if (QLA_TGT_MODE_ENABLED()) |
| 1923 | ha->max_req_queues--; |
| 1924 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 1925 | /* Queue pairs is the max value minus |
| 1926 | * the base queue pair */ |
| 1927 | ha->max_qpairs = ha->max_req_queues - 1; |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 1928 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0190, |
| 1929 | "Max no of queues pairs: %d.\n", ha->max_qpairs); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1930 | } |
| 1931 | ql_log_pci(ql_log_info, ha->pdev, 0x011c, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 1932 | "MSI-X vector count: %d.\n", ha->msix_count); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1933 | } else |
| 1934 | ql_log_pci(ql_log_info, ha->pdev, 0x011e, |
| 1935 | "BAR 1 not enabled.\n"); |
| 1936 | |
| 1937 | mqiobase_exit: |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1938 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x011f, |
Michael Hernandez | f54f2cb | 2017-02-15 15:37:19 -0800 | [diff] [blame^] | 1939 | "MSIX Count: %d.\n", ha->msix_count); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1940 | return 0; |
| 1941 | |
| 1942 | iospace_error_exit: |
| 1943 | return -ENOMEM; |
| 1944 | } |
| 1945 | |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1946 | static struct isp_operations qla2100_isp_ops = { |
| 1947 | .pci_config = qla2100_pci_config, |
| 1948 | .reset_chip = qla2x00_reset_chip, |
| 1949 | .chip_diag = qla2x00_chip_diag, |
| 1950 | .config_rings = qla2x00_config_rings, |
| 1951 | .reset_adapter = qla2x00_reset_adapter, |
| 1952 | .nvram_config = qla2x00_nvram_config, |
| 1953 | .update_fw_options = qla2x00_update_fw_options, |
| 1954 | .load_risc = qla2x00_load_risc, |
| 1955 | .pci_info_str = qla2x00_pci_info_str, |
| 1956 | .fw_version_str = qla2x00_fw_version_str, |
| 1957 | .intr_handler = qla2100_intr_handler, |
| 1958 | .enable_intrs = qla2x00_enable_intrs, |
| 1959 | .disable_intrs = qla2x00_disable_intrs, |
| 1960 | .abort_command = qla2x00_abort_command, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1961 | .target_reset = qla2x00_abort_target, |
| 1962 | .lun_reset = qla2x00_lun_reset, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1963 | .fabric_login = qla2x00_login_fabric, |
| 1964 | .fabric_logout = qla2x00_fabric_logout, |
| 1965 | .calc_req_entries = qla2x00_calc_iocbs_32, |
| 1966 | .build_iocbs = qla2x00_build_scsi_iocbs_32, |
| 1967 | .prep_ms_iocb = qla2x00_prep_ms_iocb, |
| 1968 | .prep_ms_fdmi_iocb = qla2x00_prep_ms_fdmi_iocb, |
| 1969 | .read_nvram = qla2x00_read_nvram_data, |
| 1970 | .write_nvram = qla2x00_write_nvram_data, |
| 1971 | .fw_dump = qla2100_fw_dump, |
| 1972 | .beacon_on = NULL, |
| 1973 | .beacon_off = NULL, |
| 1974 | .beacon_blink = NULL, |
| 1975 | .read_optrom = qla2x00_read_optrom_data, |
| 1976 | .write_optrom = qla2x00_write_optrom_data, |
| 1977 | .get_flash_version = qla2x00_get_flash_version, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1978 | .start_scsi = qla2x00_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 1979 | .start_scsi_mq = NULL, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1980 | .abort_isp = qla2x00_abort_isp, |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1981 | .iospace_config = qla2x00_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 1982 | .initialize_adapter = qla2x00_initialize_adapter, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1983 | }; |
| 1984 | |
| 1985 | static struct isp_operations qla2300_isp_ops = { |
| 1986 | .pci_config = qla2300_pci_config, |
| 1987 | .reset_chip = qla2x00_reset_chip, |
| 1988 | .chip_diag = qla2x00_chip_diag, |
| 1989 | .config_rings = qla2x00_config_rings, |
| 1990 | .reset_adapter = qla2x00_reset_adapter, |
| 1991 | .nvram_config = qla2x00_nvram_config, |
| 1992 | .update_fw_options = qla2x00_update_fw_options, |
| 1993 | .load_risc = qla2x00_load_risc, |
| 1994 | .pci_info_str = qla2x00_pci_info_str, |
| 1995 | .fw_version_str = qla2x00_fw_version_str, |
| 1996 | .intr_handler = qla2300_intr_handler, |
| 1997 | .enable_intrs = qla2x00_enable_intrs, |
| 1998 | .disable_intrs = qla2x00_disable_intrs, |
| 1999 | .abort_command = qla2x00_abort_command, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 2000 | .target_reset = qla2x00_abort_target, |
| 2001 | .lun_reset = qla2x00_lun_reset, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2002 | .fabric_login = qla2x00_login_fabric, |
| 2003 | .fabric_logout = qla2x00_fabric_logout, |
| 2004 | .calc_req_entries = qla2x00_calc_iocbs_32, |
| 2005 | .build_iocbs = qla2x00_build_scsi_iocbs_32, |
| 2006 | .prep_ms_iocb = qla2x00_prep_ms_iocb, |
| 2007 | .prep_ms_fdmi_iocb = qla2x00_prep_ms_fdmi_iocb, |
| 2008 | .read_nvram = qla2x00_read_nvram_data, |
| 2009 | .write_nvram = qla2x00_write_nvram_data, |
| 2010 | .fw_dump = qla2300_fw_dump, |
| 2011 | .beacon_on = qla2x00_beacon_on, |
| 2012 | .beacon_off = qla2x00_beacon_off, |
| 2013 | .beacon_blink = qla2x00_beacon_blink, |
| 2014 | .read_optrom = qla2x00_read_optrom_data, |
| 2015 | .write_optrom = qla2x00_write_optrom_data, |
| 2016 | .get_flash_version = qla2x00_get_flash_version, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2017 | .start_scsi = qla2x00_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2018 | .start_scsi_mq = NULL, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2019 | .abort_isp = qla2x00_abort_isp, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2020 | .iospace_config = qla2x00_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2021 | .initialize_adapter = qla2x00_initialize_adapter, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2022 | }; |
| 2023 | |
| 2024 | static struct isp_operations qla24xx_isp_ops = { |
| 2025 | .pci_config = qla24xx_pci_config, |
| 2026 | .reset_chip = qla24xx_reset_chip, |
| 2027 | .chip_diag = qla24xx_chip_diag, |
| 2028 | .config_rings = qla24xx_config_rings, |
| 2029 | .reset_adapter = qla24xx_reset_adapter, |
| 2030 | .nvram_config = qla24xx_nvram_config, |
| 2031 | .update_fw_options = qla24xx_update_fw_options, |
| 2032 | .load_risc = qla24xx_load_risc, |
| 2033 | .pci_info_str = qla24xx_pci_info_str, |
| 2034 | .fw_version_str = qla24xx_fw_version_str, |
| 2035 | .intr_handler = qla24xx_intr_handler, |
| 2036 | .enable_intrs = qla24xx_enable_intrs, |
| 2037 | .disable_intrs = qla24xx_disable_intrs, |
| 2038 | .abort_command = qla24xx_abort_command, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 2039 | .target_reset = qla24xx_abort_target, |
| 2040 | .lun_reset = qla24xx_lun_reset, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2041 | .fabric_login = qla24xx_login_fabric, |
| 2042 | .fabric_logout = qla24xx_fabric_logout, |
| 2043 | .calc_req_entries = NULL, |
| 2044 | .build_iocbs = NULL, |
| 2045 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2046 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 2047 | .read_nvram = qla24xx_read_nvram_data, |
| 2048 | .write_nvram = qla24xx_write_nvram_data, |
| 2049 | .fw_dump = qla24xx_fw_dump, |
| 2050 | .beacon_on = qla24xx_beacon_on, |
| 2051 | .beacon_off = qla24xx_beacon_off, |
| 2052 | .beacon_blink = qla24xx_beacon_blink, |
| 2053 | .read_optrom = qla24xx_read_optrom_data, |
| 2054 | .write_optrom = qla24xx_write_optrom_data, |
| 2055 | .get_flash_version = qla24xx_get_flash_version, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2056 | .start_scsi = qla24xx_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2057 | .start_scsi_mq = NULL, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2058 | .abort_isp = qla2x00_abort_isp, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2059 | .iospace_config = qla2x00_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2060 | .initialize_adapter = qla2x00_initialize_adapter, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2061 | }; |
| 2062 | |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2063 | static struct isp_operations qla25xx_isp_ops = { |
| 2064 | .pci_config = qla25xx_pci_config, |
| 2065 | .reset_chip = qla24xx_reset_chip, |
| 2066 | .chip_diag = qla24xx_chip_diag, |
| 2067 | .config_rings = qla24xx_config_rings, |
| 2068 | .reset_adapter = qla24xx_reset_adapter, |
| 2069 | .nvram_config = qla24xx_nvram_config, |
| 2070 | .update_fw_options = qla24xx_update_fw_options, |
| 2071 | .load_risc = qla24xx_load_risc, |
| 2072 | .pci_info_str = qla24xx_pci_info_str, |
| 2073 | .fw_version_str = qla24xx_fw_version_str, |
| 2074 | .intr_handler = qla24xx_intr_handler, |
| 2075 | .enable_intrs = qla24xx_enable_intrs, |
| 2076 | .disable_intrs = qla24xx_disable_intrs, |
| 2077 | .abort_command = qla24xx_abort_command, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 2078 | .target_reset = qla24xx_abort_target, |
| 2079 | .lun_reset = qla24xx_lun_reset, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2080 | .fabric_login = qla24xx_login_fabric, |
| 2081 | .fabric_logout = qla24xx_fabric_logout, |
| 2082 | .calc_req_entries = NULL, |
| 2083 | .build_iocbs = NULL, |
| 2084 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2085 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 2086 | .read_nvram = qla25xx_read_nvram_data, |
| 2087 | .write_nvram = qla25xx_write_nvram_data, |
| 2088 | .fw_dump = qla25xx_fw_dump, |
| 2089 | .beacon_on = qla24xx_beacon_on, |
| 2090 | .beacon_off = qla24xx_beacon_off, |
| 2091 | .beacon_blink = qla24xx_beacon_blink, |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 2092 | .read_optrom = qla25xx_read_optrom_data, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2093 | .write_optrom = qla24xx_write_optrom_data, |
| 2094 | .get_flash_version = qla24xx_get_flash_version, |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 2095 | .start_scsi = qla24xx_dif_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2096 | .start_scsi_mq = qla2xxx_dif_start_scsi_mq, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2097 | .abort_isp = qla2x00_abort_isp, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2098 | .iospace_config = qla2x00_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2099 | .initialize_adapter = qla2x00_initialize_adapter, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2100 | }; |
| 2101 | |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2102 | static struct isp_operations qla81xx_isp_ops = { |
| 2103 | .pci_config = qla25xx_pci_config, |
| 2104 | .reset_chip = qla24xx_reset_chip, |
| 2105 | .chip_diag = qla24xx_chip_diag, |
| 2106 | .config_rings = qla24xx_config_rings, |
| 2107 | .reset_adapter = qla24xx_reset_adapter, |
| 2108 | .nvram_config = qla81xx_nvram_config, |
| 2109 | .update_fw_options = qla81xx_update_fw_options, |
Andrew Vasquez | eaac30b | 2009-01-22 09:45:32 -0800 | [diff] [blame] | 2110 | .load_risc = qla81xx_load_risc, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2111 | .pci_info_str = qla24xx_pci_info_str, |
| 2112 | .fw_version_str = qla24xx_fw_version_str, |
| 2113 | .intr_handler = qla24xx_intr_handler, |
| 2114 | .enable_intrs = qla24xx_enable_intrs, |
| 2115 | .disable_intrs = qla24xx_disable_intrs, |
| 2116 | .abort_command = qla24xx_abort_command, |
| 2117 | .target_reset = qla24xx_abort_target, |
| 2118 | .lun_reset = qla24xx_lun_reset, |
| 2119 | .fabric_login = qla24xx_login_fabric, |
| 2120 | .fabric_logout = qla24xx_fabric_logout, |
| 2121 | .calc_req_entries = NULL, |
| 2122 | .build_iocbs = NULL, |
| 2123 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2124 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
Andrew Vasquez | 3d79038f | 2009-03-24 09:08:14 -0700 | [diff] [blame] | 2125 | .read_nvram = NULL, |
| 2126 | .write_nvram = NULL, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2127 | .fw_dump = qla81xx_fw_dump, |
| 2128 | .beacon_on = qla24xx_beacon_on, |
| 2129 | .beacon_off = qla24xx_beacon_off, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2130 | .beacon_blink = qla83xx_beacon_blink, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2131 | .read_optrom = qla25xx_read_optrom_data, |
| 2132 | .write_optrom = qla24xx_write_optrom_data, |
| 2133 | .get_flash_version = qla24xx_get_flash_version, |
Arun Easi | ba77ef5 | 2010-05-28 15:08:27 -0700 | [diff] [blame] | 2134 | .start_scsi = qla24xx_dif_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2135 | .start_scsi_mq = qla2xxx_dif_start_scsi_mq, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2136 | .abort_isp = qla2x00_abort_isp, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2137 | .iospace_config = qla2x00_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2138 | .initialize_adapter = qla2x00_initialize_adapter, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2139 | }; |
| 2140 | |
| 2141 | static struct isp_operations qla82xx_isp_ops = { |
| 2142 | .pci_config = qla82xx_pci_config, |
| 2143 | .reset_chip = qla82xx_reset_chip, |
| 2144 | .chip_diag = qla24xx_chip_diag, |
| 2145 | .config_rings = qla82xx_config_rings, |
| 2146 | .reset_adapter = qla24xx_reset_adapter, |
| 2147 | .nvram_config = qla81xx_nvram_config, |
| 2148 | .update_fw_options = qla24xx_update_fw_options, |
| 2149 | .load_risc = qla82xx_load_risc, |
Atul Deshmukh | 9d55ca6 | 2012-08-22 14:21:14 -0400 | [diff] [blame] | 2150 | .pci_info_str = qla24xx_pci_info_str, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2151 | .fw_version_str = qla24xx_fw_version_str, |
| 2152 | .intr_handler = qla82xx_intr_handler, |
| 2153 | .enable_intrs = qla82xx_enable_intrs, |
| 2154 | .disable_intrs = qla82xx_disable_intrs, |
| 2155 | .abort_command = qla24xx_abort_command, |
| 2156 | .target_reset = qla24xx_abort_target, |
| 2157 | .lun_reset = qla24xx_lun_reset, |
| 2158 | .fabric_login = qla24xx_login_fabric, |
| 2159 | .fabric_logout = qla24xx_fabric_logout, |
| 2160 | .calc_req_entries = NULL, |
| 2161 | .build_iocbs = NULL, |
| 2162 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2163 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 2164 | .read_nvram = qla24xx_read_nvram_data, |
| 2165 | .write_nvram = qla24xx_write_nvram_data, |
Chad Dupuis | a1b23c5 | 2014-02-26 04:15:12 -0500 | [diff] [blame] | 2166 | .fw_dump = qla82xx_fw_dump, |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 2167 | .beacon_on = qla82xx_beacon_on, |
| 2168 | .beacon_off = qla82xx_beacon_off, |
| 2169 | .beacon_blink = NULL, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2170 | .read_optrom = qla82xx_read_optrom_data, |
| 2171 | .write_optrom = qla82xx_write_optrom_data, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2172 | .get_flash_version = qla82xx_get_flash_version, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2173 | .start_scsi = qla82xx_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2174 | .start_scsi_mq = NULL, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2175 | .abort_isp = qla82xx_abort_isp, |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 2176 | .iospace_config = qla82xx_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2177 | .initialize_adapter = qla2x00_initialize_adapter, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2178 | }; |
| 2179 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2180 | static struct isp_operations qla8044_isp_ops = { |
| 2181 | .pci_config = qla82xx_pci_config, |
| 2182 | .reset_chip = qla82xx_reset_chip, |
| 2183 | .chip_diag = qla24xx_chip_diag, |
| 2184 | .config_rings = qla82xx_config_rings, |
| 2185 | .reset_adapter = qla24xx_reset_adapter, |
| 2186 | .nvram_config = qla81xx_nvram_config, |
| 2187 | .update_fw_options = qla24xx_update_fw_options, |
| 2188 | .load_risc = qla82xx_load_risc, |
| 2189 | .pci_info_str = qla24xx_pci_info_str, |
| 2190 | .fw_version_str = qla24xx_fw_version_str, |
| 2191 | .intr_handler = qla8044_intr_handler, |
| 2192 | .enable_intrs = qla82xx_enable_intrs, |
| 2193 | .disable_intrs = qla82xx_disable_intrs, |
| 2194 | .abort_command = qla24xx_abort_command, |
| 2195 | .target_reset = qla24xx_abort_target, |
| 2196 | .lun_reset = qla24xx_lun_reset, |
| 2197 | .fabric_login = qla24xx_login_fabric, |
| 2198 | .fabric_logout = qla24xx_fabric_logout, |
| 2199 | .calc_req_entries = NULL, |
| 2200 | .build_iocbs = NULL, |
| 2201 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2202 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 2203 | .read_nvram = NULL, |
| 2204 | .write_nvram = NULL, |
Chad Dupuis | a1b23c5 | 2014-02-26 04:15:12 -0500 | [diff] [blame] | 2205 | .fw_dump = qla8044_fw_dump, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2206 | .beacon_on = qla82xx_beacon_on, |
| 2207 | .beacon_off = qla82xx_beacon_off, |
| 2208 | .beacon_blink = NULL, |
Saurav Kashyap | 888e639 | 2014-02-26 04:15:13 -0500 | [diff] [blame] | 2209 | .read_optrom = qla8044_read_optrom_data, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2210 | .write_optrom = qla8044_write_optrom_data, |
| 2211 | .get_flash_version = qla82xx_get_flash_version, |
| 2212 | .start_scsi = qla82xx_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2213 | .start_scsi_mq = NULL, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2214 | .abort_isp = qla8044_abort_isp, |
| 2215 | .iospace_config = qla82xx_iospace_config, |
| 2216 | .initialize_adapter = qla2x00_initialize_adapter, |
| 2217 | }; |
| 2218 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2219 | static struct isp_operations qla83xx_isp_ops = { |
| 2220 | .pci_config = qla25xx_pci_config, |
| 2221 | .reset_chip = qla24xx_reset_chip, |
| 2222 | .chip_diag = qla24xx_chip_diag, |
| 2223 | .config_rings = qla24xx_config_rings, |
| 2224 | .reset_adapter = qla24xx_reset_adapter, |
| 2225 | .nvram_config = qla81xx_nvram_config, |
| 2226 | .update_fw_options = qla81xx_update_fw_options, |
| 2227 | .load_risc = qla81xx_load_risc, |
| 2228 | .pci_info_str = qla24xx_pci_info_str, |
| 2229 | .fw_version_str = qla24xx_fw_version_str, |
| 2230 | .intr_handler = qla24xx_intr_handler, |
| 2231 | .enable_intrs = qla24xx_enable_intrs, |
| 2232 | .disable_intrs = qla24xx_disable_intrs, |
| 2233 | .abort_command = qla24xx_abort_command, |
| 2234 | .target_reset = qla24xx_abort_target, |
| 2235 | .lun_reset = qla24xx_lun_reset, |
| 2236 | .fabric_login = qla24xx_login_fabric, |
| 2237 | .fabric_logout = qla24xx_fabric_logout, |
| 2238 | .calc_req_entries = NULL, |
| 2239 | .build_iocbs = NULL, |
| 2240 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2241 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 2242 | .read_nvram = NULL, |
| 2243 | .write_nvram = NULL, |
| 2244 | .fw_dump = qla83xx_fw_dump, |
| 2245 | .beacon_on = qla24xx_beacon_on, |
| 2246 | .beacon_off = qla24xx_beacon_off, |
| 2247 | .beacon_blink = qla83xx_beacon_blink, |
| 2248 | .read_optrom = qla25xx_read_optrom_data, |
| 2249 | .write_optrom = qla24xx_write_optrom_data, |
| 2250 | .get_flash_version = qla24xx_get_flash_version, |
| 2251 | .start_scsi = qla24xx_dif_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2252 | .start_scsi_mq = qla2xxx_dif_start_scsi_mq, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2253 | .abort_isp = qla2x00_abort_isp, |
| 2254 | .iospace_config = qla83xx_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2255 | .initialize_adapter = qla2x00_initialize_adapter, |
| 2256 | }; |
| 2257 | |
| 2258 | static struct isp_operations qlafx00_isp_ops = { |
| 2259 | .pci_config = qlafx00_pci_config, |
| 2260 | .reset_chip = qlafx00_soft_reset, |
| 2261 | .chip_diag = qlafx00_chip_diag, |
| 2262 | .config_rings = qlafx00_config_rings, |
| 2263 | .reset_adapter = qlafx00_soft_reset, |
| 2264 | .nvram_config = NULL, |
| 2265 | .update_fw_options = NULL, |
| 2266 | .load_risc = NULL, |
| 2267 | .pci_info_str = qlafx00_pci_info_str, |
| 2268 | .fw_version_str = qlafx00_fw_version_str, |
| 2269 | .intr_handler = qlafx00_intr_handler, |
| 2270 | .enable_intrs = qlafx00_enable_intrs, |
| 2271 | .disable_intrs = qlafx00_disable_intrs, |
Armen Baloyan | 4440e46 | 2014-02-26 04:15:18 -0500 | [diff] [blame] | 2272 | .abort_command = qla24xx_async_abort_command, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2273 | .target_reset = qlafx00_abort_target, |
| 2274 | .lun_reset = qlafx00_lun_reset, |
| 2275 | .fabric_login = NULL, |
| 2276 | .fabric_logout = NULL, |
| 2277 | .calc_req_entries = NULL, |
| 2278 | .build_iocbs = NULL, |
| 2279 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2280 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 2281 | .read_nvram = qla24xx_read_nvram_data, |
| 2282 | .write_nvram = qla24xx_write_nvram_data, |
| 2283 | .fw_dump = NULL, |
| 2284 | .beacon_on = qla24xx_beacon_on, |
| 2285 | .beacon_off = qla24xx_beacon_off, |
| 2286 | .beacon_blink = NULL, |
| 2287 | .read_optrom = qla24xx_read_optrom_data, |
| 2288 | .write_optrom = qla24xx_write_optrom_data, |
| 2289 | .get_flash_version = qla24xx_get_flash_version, |
| 2290 | .start_scsi = qlafx00_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2291 | .start_scsi_mq = NULL, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2292 | .abort_isp = qlafx00_abort_isp, |
| 2293 | .iospace_config = qlafx00_iospace_config, |
| 2294 | .initialize_adapter = qlafx00_initialize_adapter, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2295 | }; |
| 2296 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2297 | static struct isp_operations qla27xx_isp_ops = { |
| 2298 | .pci_config = qla25xx_pci_config, |
| 2299 | .reset_chip = qla24xx_reset_chip, |
| 2300 | .chip_diag = qla24xx_chip_diag, |
| 2301 | .config_rings = qla24xx_config_rings, |
| 2302 | .reset_adapter = qla24xx_reset_adapter, |
| 2303 | .nvram_config = qla81xx_nvram_config, |
| 2304 | .update_fw_options = qla81xx_update_fw_options, |
| 2305 | .load_risc = qla81xx_load_risc, |
| 2306 | .pci_info_str = qla24xx_pci_info_str, |
| 2307 | .fw_version_str = qla24xx_fw_version_str, |
| 2308 | .intr_handler = qla24xx_intr_handler, |
| 2309 | .enable_intrs = qla24xx_enable_intrs, |
| 2310 | .disable_intrs = qla24xx_disable_intrs, |
| 2311 | .abort_command = qla24xx_abort_command, |
| 2312 | .target_reset = qla24xx_abort_target, |
| 2313 | .lun_reset = qla24xx_lun_reset, |
| 2314 | .fabric_login = qla24xx_login_fabric, |
| 2315 | .fabric_logout = qla24xx_fabric_logout, |
| 2316 | .calc_req_entries = NULL, |
| 2317 | .build_iocbs = NULL, |
| 2318 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2319 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 2320 | .read_nvram = NULL, |
| 2321 | .write_nvram = NULL, |
| 2322 | .fw_dump = qla27xx_fwdump, |
| 2323 | .beacon_on = qla24xx_beacon_on, |
| 2324 | .beacon_off = qla24xx_beacon_off, |
| 2325 | .beacon_blink = qla83xx_beacon_blink, |
| 2326 | .read_optrom = qla25xx_read_optrom_data, |
| 2327 | .write_optrom = qla24xx_write_optrom_data, |
| 2328 | .get_flash_version = qla24xx_get_flash_version, |
| 2329 | .start_scsi = qla24xx_dif_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2330 | .start_scsi_mq = qla2xxx_dif_start_scsi_mq, |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2331 | .abort_isp = qla2x00_abort_isp, |
| 2332 | .iospace_config = qla83xx_iospace_config, |
| 2333 | .initialize_adapter = qla2x00_initialize_adapter, |
| 2334 | }; |
| 2335 | |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2336 | static inline void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2337 | qla2x00_set_isp_flags(struct qla_hw_data *ha) |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2338 | { |
| 2339 | ha->device_type = DT_EXTENDED_IDS; |
| 2340 | switch (ha->pdev->device) { |
| 2341 | case PCI_DEVICE_ID_QLOGIC_ISP2100: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2342 | ha->isp_type |= DT_ISP2100; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2343 | ha->device_type &= ~DT_EXTENDED_IDS; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2344 | ha->fw_srisc_address = RISC_START_ADDRESS_2100; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2345 | break; |
| 2346 | case PCI_DEVICE_ID_QLOGIC_ISP2200: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2347 | ha->isp_type |= DT_ISP2200; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2348 | ha->device_type &= ~DT_EXTENDED_IDS; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2349 | ha->fw_srisc_address = RISC_START_ADDRESS_2100; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2350 | break; |
| 2351 | case PCI_DEVICE_ID_QLOGIC_ISP2300: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2352 | ha->isp_type |= DT_ISP2300; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2353 | ha->device_type |= DT_ZIO_SUPPORTED; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2354 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2355 | break; |
| 2356 | case PCI_DEVICE_ID_QLOGIC_ISP2312: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2357 | ha->isp_type |= DT_ISP2312; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2358 | ha->device_type |= DT_ZIO_SUPPORTED; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2359 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2360 | break; |
| 2361 | case PCI_DEVICE_ID_QLOGIC_ISP2322: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2362 | ha->isp_type |= DT_ISP2322; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2363 | ha->device_type |= DT_ZIO_SUPPORTED; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2364 | if (ha->pdev->subsystem_vendor == 0x1028 && |
| 2365 | ha->pdev->subsystem_device == 0x0170) |
| 2366 | ha->device_type |= DT_OEM_001; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2367 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2368 | break; |
| 2369 | case PCI_DEVICE_ID_QLOGIC_ISP6312: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2370 | ha->isp_type |= DT_ISP6312; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2371 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2372 | break; |
| 2373 | case PCI_DEVICE_ID_QLOGIC_ISP6322: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2374 | ha->isp_type |= DT_ISP6322; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2375 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2376 | break; |
| 2377 | case PCI_DEVICE_ID_QLOGIC_ISP2422: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2378 | ha->isp_type |= DT_ISP2422; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2379 | ha->device_type |= DT_ZIO_SUPPORTED; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2380 | ha->device_type |= DT_FWI2; |
Andrew Vasquez | c76f2c0 | 2007-07-19 15:05:57 -0700 | [diff] [blame] | 2381 | ha->device_type |= DT_IIDMA; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2382 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2383 | break; |
| 2384 | case PCI_DEVICE_ID_QLOGIC_ISP2432: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2385 | ha->isp_type |= DT_ISP2432; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2386 | ha->device_type |= DT_ZIO_SUPPORTED; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2387 | ha->device_type |= DT_FWI2; |
Andrew Vasquez | c76f2c0 | 2007-07-19 15:05:57 -0700 | [diff] [blame] | 2388 | ha->device_type |= DT_IIDMA; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2389 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2390 | break; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 2391 | case PCI_DEVICE_ID_QLOGIC_ISP8432: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2392 | ha->isp_type |= DT_ISP8432; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 2393 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2394 | ha->device_type |= DT_FWI2; |
| 2395 | ha->device_type |= DT_IIDMA; |
| 2396 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2397 | break; |
andrew.vasquez@qlogic.com | 044cc6c | 2006-03-09 14:27:13 -0800 | [diff] [blame] | 2398 | case PCI_DEVICE_ID_QLOGIC_ISP5422: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2399 | ha->isp_type |= DT_ISP5422; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2400 | ha->device_type |= DT_FWI2; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2401 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2402 | break; |
andrew.vasquez@qlogic.com | 044cc6c | 2006-03-09 14:27:13 -0800 | [diff] [blame] | 2403 | case PCI_DEVICE_ID_QLOGIC_ISP5432: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2404 | ha->isp_type |= DT_ISP5432; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2405 | ha->device_type |= DT_FWI2; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2406 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2407 | break; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2408 | case PCI_DEVICE_ID_QLOGIC_ISP2532: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2409 | ha->isp_type |= DT_ISP2532; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2410 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2411 | ha->device_type |= DT_FWI2; |
| 2412 | ha->device_type |= DT_IIDMA; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2413 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2414 | break; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2415 | case PCI_DEVICE_ID_QLOGIC_ISP8001: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2416 | ha->isp_type |= DT_ISP8001; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2417 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2418 | ha->device_type |= DT_FWI2; |
| 2419 | ha->device_type |= DT_IIDMA; |
| 2420 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2421 | break; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2422 | case PCI_DEVICE_ID_QLOGIC_ISP8021: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2423 | ha->isp_type |= DT_ISP8021; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2424 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2425 | ha->device_type |= DT_FWI2; |
| 2426 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2427 | /* Initialize 82XX ISP flags */ |
| 2428 | qla82xx_init_flags(ha); |
| 2429 | break; |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2430 | case PCI_DEVICE_ID_QLOGIC_ISP8044: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2431 | ha->isp_type |= DT_ISP8044; |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2432 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2433 | ha->device_type |= DT_FWI2; |
| 2434 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2435 | /* Initialize 82XX ISP flags */ |
| 2436 | qla82xx_init_flags(ha); |
| 2437 | break; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2438 | case PCI_DEVICE_ID_QLOGIC_ISP2031: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2439 | ha->isp_type |= DT_ISP2031; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2440 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2441 | ha->device_type |= DT_FWI2; |
| 2442 | ha->device_type |= DT_IIDMA; |
| 2443 | ha->device_type |= DT_T10_PI; |
| 2444 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2445 | break; |
| 2446 | case PCI_DEVICE_ID_QLOGIC_ISP8031: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2447 | ha->isp_type |= DT_ISP8031; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2448 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2449 | ha->device_type |= DT_FWI2; |
| 2450 | ha->device_type |= DT_IIDMA; |
| 2451 | ha->device_type |= DT_T10_PI; |
| 2452 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2453 | break; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2454 | case PCI_DEVICE_ID_QLOGIC_ISPF001: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2455 | ha->isp_type |= DT_ISPFX00; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2456 | break; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2457 | case PCI_DEVICE_ID_QLOGIC_ISP2071: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2458 | ha->isp_type |= DT_ISP2071; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2459 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2460 | ha->device_type |= DT_FWI2; |
| 2461 | ha->device_type |= DT_IIDMA; |
Himanshu Madhani | 8ce3f57 | 2016-01-27 12:03:36 -0500 | [diff] [blame] | 2462 | ha->device_type |= DT_T10_PI; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2463 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2464 | break; |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 2465 | case PCI_DEVICE_ID_QLOGIC_ISP2271: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2466 | ha->isp_type |= DT_ISP2271; |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 2467 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2468 | ha->device_type |= DT_FWI2; |
| 2469 | ha->device_type |= DT_IIDMA; |
Himanshu Madhani | 8ce3f57 | 2016-01-27 12:03:36 -0500 | [diff] [blame] | 2470 | ha->device_type |= DT_T10_PI; |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 2471 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2472 | break; |
Sawan Chandak | 2b48992 | 2015-08-04 13:38:03 -0400 | [diff] [blame] | 2473 | case PCI_DEVICE_ID_QLOGIC_ISP2261: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2474 | ha->isp_type |= DT_ISP2261; |
Sawan Chandak | 2b48992 | 2015-08-04 13:38:03 -0400 | [diff] [blame] | 2475 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2476 | ha->device_type |= DT_FWI2; |
| 2477 | ha->device_type |= DT_IIDMA; |
Himanshu Madhani | 8ce3f57 | 2016-01-27 12:03:36 -0500 | [diff] [blame] | 2478 | ha->device_type |= DT_T10_PI; |
Sawan Chandak | 2b48992 | 2015-08-04 13:38:03 -0400 | [diff] [blame] | 2479 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2480 | break; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2481 | } |
Anirban Chakraborty | e5b68a6 | 2009-04-06 22:33:50 -0700 | [diff] [blame] | 2482 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2483 | if (IS_QLA82XX(ha)) |
Saurav Kashyap | 43a9c38 | 2014-02-26 04:15:16 -0500 | [diff] [blame] | 2484 | ha->port_no = ha->portnum & 1; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2485 | else { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2486 | /* Get adapter physical port no from interrupt pin register. */ |
| 2487 | pci_read_config_byte(ha->pdev, PCI_INTERRUPT_PIN, &ha->port_no); |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2488 | if (IS_QLA27XX(ha)) |
| 2489 | ha->port_no--; |
| 2490 | else |
| 2491 | ha->port_no = !(ha->port_no & 1); |
| 2492 | } |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2493 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2494 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x000b, |
Joe Perches | d8424f6 | 2011-11-18 09:03:06 -0800 | [diff] [blame] | 2495 | "device_type=0x%x port=%d fw_srisc_address=0x%x.\n", |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2496 | ha->device_type, ha->port_no, ha->fw_srisc_address); |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2497 | } |
| 2498 | |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2499 | static void |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2500 | qla2xxx_scan_start(struct Scsi_Host *shost) |
| 2501 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2502 | scsi_qla_host_t *vha = shost_priv(shost); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2503 | |
Andrew Vasquez | cbc8eb6 | 2009-06-03 09:55:17 -0700 | [diff] [blame] | 2504 | if (vha->hw->flags.running_gold_fw) |
| 2505 | return; |
| 2506 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2507 | set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); |
| 2508 | set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); |
| 2509 | set_bit(RSCN_UPDATE, &vha->dpc_flags); |
| 2510 | set_bit(NPIV_CONFIG_NEEDED, &vha->dpc_flags); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2511 | } |
| 2512 | |
| 2513 | static int |
| 2514 | qla2xxx_scan_finished(struct Scsi_Host *shost, unsigned long time) |
| 2515 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2516 | scsi_qla_host_t *vha = shost_priv(shost); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2517 | |
Bill Kuzeja | a5dd506e | 2016-10-21 16:45:27 -0400 | [diff] [blame] | 2518 | if (test_bit(UNLOADING, &vha->dpc_flags)) |
| 2519 | return 1; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2520 | if (!vha->host) |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2521 | return 1; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2522 | if (time > vha->hw->loop_reset_delay * HZ) |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2523 | return 1; |
| 2524 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2525 | return atomic_read(&vha->loop_state) == LOOP_READY; |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2526 | } |
| 2527 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2528 | /* |
| 2529 | * PCI driver interface |
| 2530 | */ |
Greg Kroah-Hartman | 6f03979 | 2012-12-21 13:08:55 -0800 | [diff] [blame] | 2531 | static int |
Andrew Vasquez | 7ee6139 | 2006-06-23 16:11:22 -0700 | [diff] [blame] | 2532 | 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] | 2533 | { |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2534 | int ret = -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2535 | struct Scsi_Host *host; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2536 | scsi_qla_host_t *base_vha = NULL; |
| 2537 | struct qla_hw_data *ha; |
Andrew Vasquez | 29856e2 | 2007-08-12 18:22:52 -0700 | [diff] [blame] | 2538 | char pci_info[30]; |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 2539 | char fw_str[30], wq_name[30]; |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 2540 | struct scsi_host_template *sht; |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2541 | int bars, mem_only = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2542 | uint16_t req_length = 0, rsp_length = 0; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2543 | struct req_que *req = NULL; |
| 2544 | struct rsp_que *rsp = NULL; |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 2545 | int i; |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2546 | |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2547 | bars = pci_select_bars(pdev, IORESOURCE_MEM | IORESOURCE_IO); |
Giridhar Malavali | a5326f8 | 2009-03-24 09:07:56 -0700 | [diff] [blame] | 2548 | sht = &qla2xxx_driver_template; |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2549 | if (pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2422 || |
| 2550 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2432 || |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 2551 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8432 || |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2552 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP5422 || |
| 2553 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP5432 || |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2554 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2532 || |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2555 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8001 || |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2556 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8021 || |
| 2557 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2031 || |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2558 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8031 || |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2559 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISPF001 || |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2560 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8044 || |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 2561 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2071 || |
Sawan Chandak | 2b48992 | 2015-08-04 13:38:03 -0400 | [diff] [blame] | 2562 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2271 || |
| 2563 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2261) { |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2564 | bars = pci_select_bars(pdev, IORESOURCE_MEM); |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 2565 | mem_only = 1; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2566 | ql_dbg_pci(ql_dbg_init, pdev, 0x0007, |
| 2567 | "Mem only adapter.\n"); |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2568 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2569 | ql_dbg_pci(ql_dbg_init, pdev, 0x0008, |
| 2570 | "Bars=%d.\n", bars); |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2571 | |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 2572 | if (mem_only) { |
| 2573 | if (pci_enable_device_mem(pdev)) |
| 2574 | goto probe_out; |
| 2575 | } else { |
| 2576 | if (pci_enable_device(pdev)) |
| 2577 | goto probe_out; |
| 2578 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2579 | |
Jesse Barnes | 0927678 | 2008-10-18 17:33:19 -0700 | [diff] [blame] | 2580 | /* This may fail but that's ok */ |
| 2581 | pci_enable_pcie_error_reporting(pdev); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 2582 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2583 | ha = kzalloc(sizeof(struct qla_hw_data), GFP_KERNEL); |
| 2584 | if (!ha) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2585 | ql_log_pci(ql_log_fatal, pdev, 0x0009, |
| 2586 | "Unable to allocate memory for ha.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2587 | goto probe_out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2588 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2589 | ql_dbg_pci(ql_dbg_init, pdev, 0x000a, |
| 2590 | "Memory allocated for ha=%p.\n", ha); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2591 | ha->pdev = pdev; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2592 | ha->tgt.enable_class_2 = ql2xenableclass2; |
Quinn Tran | 33e7997 | 2014-09-25 06:14:55 -0400 | [diff] [blame] | 2593 | INIT_LIST_HEAD(&ha->tgt.q_full_list); |
| 2594 | spin_lock_init(&ha->tgt.q_full_lock); |
Quinn Tran | 7560151 | 2015-12-17 14:57:04 -0500 | [diff] [blame] | 2595 | spin_lock_init(&ha->tgt.sess_lock); |
Quinn Tran | 2f424b9 | 2015-12-17 14:57:07 -0500 | [diff] [blame] | 2596 | spin_lock_init(&ha->tgt.atio_lock); |
| 2597 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2598 | |
| 2599 | /* Clear our data area */ |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2600 | ha->bars = bars; |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 2601 | ha->mem_only = mem_only; |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 2602 | spin_lock_init(&ha->hardware_lock); |
Andrew Vasquez | 339aa70 | 2010-10-15 11:27:45 -0700 | [diff] [blame] | 2603 | spin_lock_init(&ha->vport_slock); |
Saurav Kashyap | a9b6f72 | 2012-08-22 14:21:01 -0400 | [diff] [blame] | 2604 | mutex_init(&ha->selflogin_lock); |
Chad Dupuis | 7a8ab9c | 2014-02-26 04:14:56 -0500 | [diff] [blame] | 2605 | mutex_init(&ha->optrom_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2606 | |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2607 | /* Set ISP-type information. */ |
| 2608 | qla2x00_set_isp_flags(ha); |
Duane Grigsby | ca79cf6 | 2009-12-15 21:29:47 -0800 | [diff] [blame] | 2609 | |
| 2610 | /* Set EEH reset type to fundamental if required by hba */ |
Joe Carnuccio | 9567611 | 2012-08-22 14:21:20 -0400 | [diff] [blame] | 2611 | if (IS_QLA24XX(ha) || IS_QLA25XX(ha) || IS_QLA81XX(ha) || |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2612 | IS_QLA83XX(ha) || IS_QLA27XX(ha)) |
Duane Grigsby | ca79cf6 | 2009-12-15 21:29:47 -0800 | [diff] [blame] | 2613 | pdev->needs_freset = 1; |
Duane Grigsby | ca79cf6 | 2009-12-15 21:29:47 -0800 | [diff] [blame] | 2614 | |
Chad Dupuis | cba1e47 | 2011-11-18 09:03:21 -0800 | [diff] [blame] | 2615 | ha->prev_topology = 0; |
| 2616 | ha->init_cb_size = sizeof(init_cb_t); |
| 2617 | ha->link_data_rate = PORT_SPEED_UNKNOWN; |
| 2618 | ha->optrom_size = OPTROM_SIZE_2300; |
| 2619 | |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2620 | /* Assign ISP specific operations. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2621 | if (IS_QLA2100(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2622 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2100; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2623 | ha->mbx_count = MAILBOX_REGISTER_COUNT_2100; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2624 | req_length = REQUEST_ENTRY_CNT_2100; |
| 2625 | rsp_length = RESPONSE_ENTRY_CNT_2100; |
| 2626 | ha->max_loop_id = SNS_LAST_LOOP_ID_2100; |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2627 | ha->gid_list_info_size = 4; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2628 | ha->flash_conf_off = ~0; |
| 2629 | ha->flash_data_off = ~0; |
| 2630 | ha->nvram_conf_off = ~0; |
| 2631 | ha->nvram_data_off = ~0; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2632 | ha->isp_ops = &qla2100_isp_ops; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2633 | } else if (IS_QLA2200(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2634 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2100; |
Andrew Vasquez | 67ddda3 | 2012-02-09 11:14:08 -0800 | [diff] [blame] | 2635 | ha->mbx_count = MAILBOX_REGISTER_COUNT_2200; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2636 | req_length = REQUEST_ENTRY_CNT_2200; |
| 2637 | rsp_length = RESPONSE_ENTRY_CNT_2100; |
| 2638 | ha->max_loop_id = SNS_LAST_LOOP_ID_2100; |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2639 | ha->gid_list_info_size = 4; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2640 | ha->flash_conf_off = ~0; |
| 2641 | ha->flash_data_off = ~0; |
| 2642 | ha->nvram_conf_off = ~0; |
| 2643 | ha->nvram_data_off = ~0; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2644 | ha->isp_ops = &qla2100_isp_ops; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 2645 | } else if (IS_QLA23XX(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2646 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2100; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2647 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2648 | req_length = REQUEST_ENTRY_CNT_2200; |
| 2649 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
| 2650 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2651 | ha->gid_list_info_size = 6; |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 2652 | if (IS_QLA2322(ha) || IS_QLA6322(ha)) |
| 2653 | ha->optrom_size = OPTROM_SIZE_2322; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2654 | ha->flash_conf_off = ~0; |
| 2655 | ha->flash_data_off = ~0; |
| 2656 | ha->nvram_conf_off = ~0; |
| 2657 | ha->nvram_data_off = ~0; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2658 | ha->isp_ops = &qla2300_isp_ops; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 2659 | } else if (IS_QLA24XX_TYPE(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2660 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 2661 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2662 | req_length = REQUEST_ENTRY_CNT_24XX; |
| 2663 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2664 | ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2665 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2666 | ha->init_cb_size = sizeof(struct mid_init_cb_24xx); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 2667 | ha->gid_list_info_size = 8; |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 2668 | ha->optrom_size = OPTROM_SIZE_24XX; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2669 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA24XX; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2670 | ha->isp_ops = &qla24xx_isp_ops; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2671 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF; |
| 2672 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA; |
| 2673 | ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF; |
| 2674 | ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2675 | } else if (IS_QLA25XX(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2676 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2677 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2678 | req_length = REQUEST_ENTRY_CNT_24XX; |
| 2679 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2680 | ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2681 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2682 | ha->init_cb_size = sizeof(struct mid_init_cb_24xx); |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2683 | ha->gid_list_info_size = 8; |
| 2684 | ha->optrom_size = OPTROM_SIZE_25XX; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2685 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2686 | ha->isp_ops = &qla25xx_isp_ops; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2687 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF; |
| 2688 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA; |
| 2689 | ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF; |
| 2690 | ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA; |
| 2691 | } else if (IS_QLA81XX(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2692 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2693 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
| 2694 | req_length = REQUEST_ENTRY_CNT_24XX; |
| 2695 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
Arun Easi | aa230bc | 2013-01-30 03:34:39 -0500 | [diff] [blame] | 2696 | ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2697 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 2698 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 2699 | ha->gid_list_info_size = 8; |
| 2700 | ha->optrom_size = OPTROM_SIZE_81XX; |
Anirban Chakraborty | 40859ae | 2009-06-03 09:55:16 -0700 | [diff] [blame] | 2701 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2702 | ha->isp_ops = &qla81xx_isp_ops; |
| 2703 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF_81XX; |
| 2704 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA_81XX; |
| 2705 | ha->nvram_conf_off = ~0; |
| 2706 | ha->nvram_data_off = ~0; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2707 | } else if (IS_QLA82XX(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2708 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2709 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
| 2710 | req_length = REQUEST_ENTRY_CNT_82XX; |
| 2711 | rsp_length = RESPONSE_ENTRY_CNT_82XX; |
| 2712 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 2713 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 2714 | ha->gid_list_info_size = 8; |
| 2715 | ha->optrom_size = OPTROM_SIZE_82XX; |
Andrew Vasquez | 087c621 | 2010-11-23 16:52:48 -0800 | [diff] [blame] | 2716 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2717 | ha->isp_ops = &qla82xx_isp_ops; |
| 2718 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF; |
| 2719 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA; |
| 2720 | ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF; |
| 2721 | ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA; |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2722 | } else if (IS_QLA8044(ha)) { |
| 2723 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
| 2724 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
| 2725 | req_length = REQUEST_ENTRY_CNT_82XX; |
| 2726 | rsp_length = RESPONSE_ENTRY_CNT_82XX; |
| 2727 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 2728 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 2729 | ha->gid_list_info_size = 8; |
| 2730 | ha->optrom_size = OPTROM_SIZE_83XX; |
| 2731 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
| 2732 | ha->isp_ops = &qla8044_isp_ops; |
| 2733 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF; |
| 2734 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA; |
| 2735 | ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF; |
| 2736 | ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2737 | } else if (IS_QLA83XX(ha)) { |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 2738 | ha->portnum = PCI_FUNC(ha->pdev->devfn); |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2739 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2740 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
Saurav Kashyap | f2ea653 | 2014-09-25 06:14:54 -0400 | [diff] [blame] | 2741 | req_length = REQUEST_ENTRY_CNT_83XX; |
Quinn Tran | e7b42e3 | 2015-12-17 14:57:09 -0500 | [diff] [blame] | 2742 | rsp_length = RESPONSE_ENTRY_CNT_83XX; |
Arun Easi | b8aa4bd | 2013-01-30 03:34:40 -0500 | [diff] [blame] | 2743 | ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2744 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 2745 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 2746 | ha->gid_list_info_size = 8; |
| 2747 | ha->optrom_size = OPTROM_SIZE_83XX; |
| 2748 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
| 2749 | ha->isp_ops = &qla83xx_isp_ops; |
| 2750 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF_81XX; |
| 2751 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA_81XX; |
| 2752 | ha->nvram_conf_off = ~0; |
| 2753 | ha->nvram_data_off = ~0; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2754 | } else if (IS_QLAFX00(ha)) { |
| 2755 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_FX00; |
| 2756 | ha->mbx_count = MAILBOX_REGISTER_COUNT_FX00; |
| 2757 | ha->aen_mbx_count = AEN_MAILBOX_REGISTER_COUNT_FX00; |
| 2758 | req_length = REQUEST_ENTRY_CNT_FX00; |
| 2759 | rsp_length = RESPONSE_ENTRY_CNT_FX00; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2760 | ha->isp_ops = &qlafx00_isp_ops; |
| 2761 | ha->port_down_retry_count = 30; /* default value */ |
| 2762 | ha->mr.fw_hbt_cnt = QLAFX00_HEARTBEAT_INTERVAL; |
| 2763 | ha->mr.fw_reset_timer_tick = QLAFX00_RESET_INTERVAL; |
Armen Baloyan | 71e5600 | 2013-08-27 01:37:38 -0400 | [diff] [blame] | 2764 | ha->mr.fw_critemp_timer_tick = QLAFX00_CRITEMP_INTERVAL; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2765 | ha->mr.fw_hbt_en = 1; |
Armen Baloyan | e8f5e95 | 2013-10-30 03:38:17 -0400 | [diff] [blame] | 2766 | ha->mr.host_info_resend = false; |
| 2767 | ha->mr.hinfo_resend_timer_tick = QLAFX00_HINFO_RESEND_INTERVAL; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2768 | } else if (IS_QLA27XX(ha)) { |
| 2769 | ha->portnum = PCI_FUNC(ha->pdev->devfn); |
| 2770 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
| 2771 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
Quinn Tran | e7b42e3 | 2015-12-17 14:57:09 -0500 | [diff] [blame] | 2772 | req_length = REQUEST_ENTRY_CNT_83XX; |
| 2773 | rsp_length = RESPONSE_ENTRY_CNT_83XX; |
Himanshu Madhani | b20f02e | 2015-06-10 11:05:18 -0400 | [diff] [blame] | 2774 | ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2775 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 2776 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 2777 | ha->gid_list_info_size = 8; |
| 2778 | ha->optrom_size = OPTROM_SIZE_83XX; |
| 2779 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
| 2780 | ha->isp_ops = &qla27xx_isp_ops; |
| 2781 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF_81XX; |
| 2782 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA_81XX; |
| 2783 | ha->nvram_conf_off = ~0; |
| 2784 | ha->nvram_data_off = ~0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2785 | } |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2786 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2787 | ql_dbg_pci(ql_dbg_init, pdev, 0x001e, |
| 2788 | "mbx_count=%d, req_length=%d, " |
| 2789 | "rsp_length=%d, max_loop_id=%d, init_cb_size=%d, " |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2790 | "gid_list_info_size=%d, optrom_size=%d, nvram_npiv_size=%d, " |
| 2791 | "max_fibre_devices=%d.\n", |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2792 | ha->mbx_count, req_length, rsp_length, ha->max_loop_id, |
| 2793 | ha->init_cb_size, ha->gid_list_info_size, ha->optrom_size, |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2794 | ha->nvram_npiv_size, ha->max_fibre_devices); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2795 | ql_dbg_pci(ql_dbg_init, pdev, 0x001f, |
| 2796 | "isp_ops=%p, flash_conf_off=%d, " |
| 2797 | "flash_data_off=%d, nvram_conf_off=%d, nvram_data_off=%d.\n", |
| 2798 | ha->isp_ops, ha->flash_conf_off, ha->flash_data_off, |
| 2799 | ha->nvram_conf_off, ha->nvram_data_off); |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 2800 | |
| 2801 | /* Configure PCI I/O space */ |
| 2802 | ret = ha->isp_ops->iospace_config(ha); |
| 2803 | if (ret) |
Saurav Kashyap | 0a63ad1 | 2012-11-21 02:40:43 -0500 | [diff] [blame] | 2804 | goto iospace_config_failed; |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 2805 | |
| 2806 | ql_log_pci(ql_log_info, pdev, 0x001d, |
| 2807 | "Found an ISP%04X irq %d iobase 0x%p.\n", |
| 2808 | pdev->device, pdev->irq, ha->iobase); |
matthias@kaehlcke.net | 6c2f527 | 2008-05-12 22:21:11 -0700 | [diff] [blame] | 2809 | mutex_init(&ha->vport_lock); |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2810 | mutex_init(&ha->mq_lock); |
Marcus Barrow | 0b05a1f | 2008-01-17 09:02:13 -0800 | [diff] [blame] | 2811 | init_completion(&ha->mbx_cmd_comp); |
| 2812 | complete(&ha->mbx_cmd_comp); |
| 2813 | init_completion(&ha->mbx_intr_comp); |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 2814 | init_completion(&ha->dcbx_comp); |
Chad Dupuis | f356bef | 2013-02-08 01:58:04 -0500 | [diff] [blame] | 2815 | init_completion(&ha->lb_portup_comp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2816 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2817 | set_bit(0, (unsigned long *) ha->vp_idx_map); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2818 | |
Andrew Vasquez | 53303c4 | 2009-01-22 09:45:37 -0800 | [diff] [blame] | 2819 | qla2x00_config_dma_addressing(ha); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2820 | ql_dbg_pci(ql_dbg_init, pdev, 0x0020, |
| 2821 | "64 Bit addressing is %s.\n", |
| 2822 | ha->flags.enable_64bit_addressing ? "enable" : |
| 2823 | "disable"); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2824 | ret = qla2x00_mem_alloc(ha, req_length, rsp_length, &req, &rsp); |
Dan Carpenter | b2a72ec | 2014-01-21 10:00:10 +0300 | [diff] [blame] | 2825 | if (ret) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2826 | ql_log_pci(ql_log_fatal, pdev, 0x0031, |
| 2827 | "Failed to allocate memory for adapter, aborting.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2828 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2829 | goto probe_hw_failed; |
| 2830 | } |
| 2831 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2832 | req->max_q_depth = MAX_Q_DEPTH; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2833 | if (ql2xmaxqdepth != 0 && ql2xmaxqdepth <= 0xffffU) |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2834 | req->max_q_depth = ql2xmaxqdepth; |
| 2835 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2836 | |
| 2837 | base_vha = qla2x00_create_host(sht, ha); |
| 2838 | if (!base_vha) { |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2839 | ret = -ENOMEM; |
Anirban Chakraborty | 6e9f21f | 2009-01-22 09:45:28 -0800 | [diff] [blame] | 2840 | qla2x00_mem_free(ha); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2841 | qla2x00_free_req_que(ha, req); |
| 2842 | qla2x00_free_rsp_que(ha, rsp); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2843 | goto probe_hw_failed; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2844 | } |
| 2845 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2846 | pci_set_drvdata(pdev, base_vha); |
Joe Lawrence | 6b38397 | 2014-08-26 17:12:29 -0400 | [diff] [blame] | 2847 | set_bit(PFLG_DRIVER_PROBING, &base_vha->pci_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2848 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2849 | host = base_vha->host; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2850 | base_vha->req = req; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2851 | if (IS_QLA2XXX_MIDTYPE(ha)) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2852 | base_vha->mgmt_svr_loop_id = 10 + base_vha->vp_idx; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2853 | else |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2854 | base_vha->mgmt_svr_loop_id = MANAGEMENT_SERVER + |
| 2855 | base_vha->vp_idx; |
Giridhar Malavali | 58548cb | 2010-09-03 15:20:56 -0700 | [diff] [blame] | 2856 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2857 | /* Setup fcport template structure. */ |
| 2858 | ha->mr.fcport.vha = base_vha; |
| 2859 | ha->mr.fcport.port_type = FCT_UNKNOWN; |
| 2860 | ha->mr.fcport.loop_id = FC_NO_LOOP_ID; |
| 2861 | qla2x00_set_fcport_state(&ha->mr.fcport, FCS_UNCONFIGURED); |
| 2862 | ha->mr.fcport.supported_classes = FC_COS_UNSPECIFIED; |
| 2863 | ha->mr.fcport.scan_state = 1; |
| 2864 | |
Giridhar Malavali | 58548cb | 2010-09-03 15:20:56 -0700 | [diff] [blame] | 2865 | /* Set the SG table size based on ISP type */ |
| 2866 | if (!IS_FWI2_CAPABLE(ha)) { |
| 2867 | if (IS_QLA2100(ha)) |
| 2868 | host->sg_tablesize = 32; |
| 2869 | } else { |
| 2870 | if (!IS_QLA82XX(ha)) |
| 2871 | host->sg_tablesize = QLA_SG_ALL; |
| 2872 | } |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2873 | host->max_id = ha->max_fibre_devices; |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2874 | host->cmd_per_lun = 3; |
Seokmann Ju | 711c1d9 | 2008-07-10 16:55:51 -0700 | [diff] [blame] | 2875 | host->unique_id = host->host_no; |
Arun Easi | e02587d | 2011-08-16 11:29:23 -0700 | [diff] [blame] | 2876 | if (IS_T10_PI_CAPABLE(ha) && ql2xenabledif) |
Arun Easi | 0c47087 | 2010-07-23 15:28:38 +0500 | [diff] [blame] | 2877 | host->max_cmd_len = 32; |
| 2878 | else |
| 2879 | host->max_cmd_len = MAX_CMDSZ; |
Andrew Vasquez | 75bc419 | 2006-05-17 15:09:22 -0700 | [diff] [blame] | 2880 | host->max_channel = MAX_BUSES - 1; |
Hannes Reinecke | 755f516 | 2014-06-03 10:58:54 +0200 | [diff] [blame] | 2881 | /* Older HBAs support only 16-bit LUNs */ |
| 2882 | if (!IS_QLAFX00(ha) && !IS_FWI2_CAPABLE(ha) && |
| 2883 | ql2xmaxlun > 0xffff) |
| 2884 | host->max_lun = 0xffff; |
| 2885 | else |
| 2886 | host->max_lun = ql2xmaxlun; |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2887 | host->transportt = qla2xxx_transport_template; |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 2888 | sht->vendor_id = (SCSI_NL_VID_TYPE_PCI | PCI_VENDOR_ID_QLOGIC); |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2889 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2890 | ql_dbg(ql_dbg_init, base_vha, 0x0033, |
| 2891 | "max_id=%d this_id=%d " |
| 2892 | "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] | 2893 | "max_lun=%llu transportt=%p, vendor_id=%llu.\n", host->max_id, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2894 | host->this_id, host->cmd_per_lun, host->unique_id, |
| 2895 | host->max_cmd_len, host->max_channel, host->max_lun, |
| 2896 | host->transportt, sht->vendor_id); |
| 2897 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2898 | /* Set up the irqs */ |
| 2899 | ret = qla2x00_request_irqs(ha, rsp); |
| 2900 | if (ret) |
| 2901 | goto probe_init_failed; |
| 2902 | |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 2903 | /* Alloc arrays of request and response ring ptrs */ |
| 2904 | if (!qla2x00_alloc_queues(ha, req, rsp)) { |
| 2905 | ql_log(ql_log_fatal, base_vha, 0x003d, |
| 2906 | "Failed to allocate memory for queue pointers..." |
| 2907 | "aborting.\n"); |
| 2908 | goto probe_init_failed; |
| 2909 | } |
| 2910 | |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 2911 | if (ha->mqenable && shost_use_blk_mq(host)) { |
| 2912 | /* number of hardware queues supported by blk/scsi-mq*/ |
| 2913 | host->nr_hw_queues = ha->max_qpairs; |
| 2914 | |
| 2915 | ql_dbg(ql_dbg_init, base_vha, 0x0192, |
| 2916 | "blk/scsi-mq enabled, HW queues = %d.\n", host->nr_hw_queues); |
| 2917 | } else |
| 2918 | ql_dbg(ql_dbg_init, base_vha, 0x0193, |
| 2919 | "blk/scsi-mq disabled.\n"); |
| 2920 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2921 | qlt_probe_one_stage1(base_vha, ha); |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 2922 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 2923 | pci_save_state(pdev); |
| 2924 | |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 2925 | /* Assign back pointers */ |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2926 | rsp->req = req; |
| 2927 | req->rsp = rsp; |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 2928 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2929 | if (IS_QLAFX00(ha)) { |
| 2930 | ha->rsp_q_map[0] = rsp; |
| 2931 | ha->req_q_map[0] = req; |
| 2932 | set_bit(0, ha->req_qid_map); |
| 2933 | set_bit(0, ha->rsp_qid_map); |
| 2934 | } |
| 2935 | |
Andrew Vasquez | 0802999 | 2009-03-24 09:07:55 -0700 | [diff] [blame] | 2936 | /* FWI2-capable only. */ |
| 2937 | req->req_q_in = &ha->iobase->isp24.req_q_in; |
| 2938 | req->req_q_out = &ha->iobase->isp24.req_q_out; |
| 2939 | rsp->rsp_q_in = &ha->iobase->isp24.rsp_q_in; |
| 2940 | rsp->rsp_q_out = &ha->iobase->isp24.rsp_q_out; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2941 | if (ha->mqenable || IS_QLA83XX(ha) || IS_QLA27XX(ha)) { |
Andrew Vasquez | 0802999 | 2009-03-24 09:07:55 -0700 | [diff] [blame] | 2942 | req->req_q_in = &ha->mqiobase->isp25mq.req_q_in; |
| 2943 | req->req_q_out = &ha->mqiobase->isp25mq.req_q_out; |
| 2944 | rsp->rsp_q_in = &ha->mqiobase->isp25mq.rsp_q_in; |
| 2945 | rsp->rsp_q_out = &ha->mqiobase->isp25mq.rsp_q_out; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 2946 | } |
| 2947 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2948 | if (IS_QLAFX00(ha)) { |
| 2949 | req->req_q_in = &ha->iobase->ispfx00.req_q_in; |
| 2950 | req->req_q_out = &ha->iobase->ispfx00.req_q_out; |
| 2951 | rsp->rsp_q_in = &ha->iobase->ispfx00.rsp_q_in; |
| 2952 | rsp->rsp_q_out = &ha->iobase->ispfx00.rsp_q_out; |
| 2953 | } |
| 2954 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2955 | if (IS_P3P_TYPE(ha)) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2956 | req->req_q_out = &ha->iobase->isp82.req_q_out[0]; |
| 2957 | rsp->rsp_q_in = &ha->iobase->isp82.rsp_q_in[0]; |
| 2958 | rsp->rsp_q_out = &ha->iobase->isp82.rsp_q_out[0]; |
| 2959 | } |
| 2960 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2961 | ql_dbg(ql_dbg_multiq, base_vha, 0xc009, |
| 2962 | "rsp_q_map=%p req_q_map=%p rsp->req=%p req->rsp=%p.\n", |
| 2963 | ha->rsp_q_map, ha->req_q_map, rsp->req, req->rsp); |
| 2964 | ql_dbg(ql_dbg_multiq, base_vha, 0xc00a, |
| 2965 | "req->req_q_in=%p req->req_q_out=%p " |
| 2966 | "rsp->rsp_q_in=%p rsp->rsp_q_out=%p.\n", |
| 2967 | req->req_q_in, req->req_q_out, |
| 2968 | rsp->rsp_q_in, rsp->rsp_q_out); |
| 2969 | ql_dbg(ql_dbg_init, base_vha, 0x003e, |
| 2970 | "rsp_q_map=%p req_q_map=%p rsp->req=%p req->rsp=%p.\n", |
| 2971 | ha->rsp_q_map, ha->req_q_map, rsp->req, req->rsp); |
| 2972 | ql_dbg(ql_dbg_init, base_vha, 0x003f, |
| 2973 | "req->req_q_in=%p req->req_q_out=%p rsp->rsp_q_in=%p rsp->rsp_q_out=%p.\n", |
| 2974 | 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] | 2975 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2976 | if (ha->isp_ops->initialize_adapter(base_vha)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2977 | ql_log(ql_log_fatal, base_vha, 0x00d6, |
| 2978 | "Failed to initialize adapter - Adapter flags %x.\n", |
| 2979 | base_vha->device_flags); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2980 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2981 | if (IS_QLA82XX(ha)) { |
| 2982 | qla82xx_idc_lock(ha); |
| 2983 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 2984 | QLA8XXX_DEV_FAILED); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2985 | qla82xx_idc_unlock(ha); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2986 | ql_log(ql_log_fatal, base_vha, 0x00d7, |
| 2987 | "HW State: FAILED.\n"); |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2988 | } else if (IS_QLA8044(ha)) { |
| 2989 | qla8044_idc_lock(ha); |
| 2990 | qla8044_wr_direct(base_vha, |
| 2991 | QLA8044_CRB_DEV_STATE_INDEX, |
| 2992 | QLA8XXX_DEV_FAILED); |
| 2993 | qla8044_idc_unlock(ha); |
| 2994 | ql_log(ql_log_fatal, base_vha, 0x0150, |
| 2995 | "HW State: FAILED.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2996 | } |
| 2997 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2998 | ret = -ENODEV; |
| 2999 | goto probe_failed; |
| 3000 | } |
| 3001 | |
Chad Dupuis | 3b1bef6 | 2014-02-26 04:15:04 -0500 | [diff] [blame] | 3002 | if (IS_QLAFX00(ha)) |
| 3003 | host->can_queue = QLAFX00_MAX_CANQUEUE; |
| 3004 | else |
| 3005 | host->can_queue = req->num_outstanding_cmds - 10; |
| 3006 | |
| 3007 | ql_dbg(ql_dbg_init, base_vha, 0x0032, |
| 3008 | "can_queue=%d, req=%p, mgmt_svr_loop_id=%d, sg_tablesize=%d.\n", |
| 3009 | host->can_queue, base_vha->req, |
| 3010 | base_vha->mgmt_svr_loop_id, host->sg_tablesize); |
| 3011 | |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 3012 | if (ha->mqenable && qla_ini_mode_enabled(base_vha)) { |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 3013 | ha->wq = alloc_workqueue("qla2xxx_wq", WQ_MEM_RECLAIM, 1); |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 3014 | /* Create start of day qpairs for Block MQ */ |
| 3015 | if (shost_use_blk_mq(host)) { |
| 3016 | for (i = 0; i < ha->max_qpairs; i++) |
| 3017 | qla2xxx_create_qpair(base_vha, 5, 0); |
| 3018 | } |
| 3019 | } |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 3020 | |
Andrew Vasquez | cbc8eb6 | 2009-06-03 09:55:17 -0700 | [diff] [blame] | 3021 | if (ha->flags.running_gold_fw) |
| 3022 | goto skip_dpc; |
| 3023 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3024 | /* |
| 3025 | * Startup the kernel thread for this host adapter |
| 3026 | */ |
| 3027 | ha->dpc_thread = kthread_create(qla2x00_do_dpc, ha, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3028 | "%s_dpc", base_vha->host_str); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3029 | if (IS_ERR(ha->dpc_thread)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3030 | ql_log(ql_log_fatal, base_vha, 0x00ed, |
| 3031 | "Failed to start DPC thread.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3032 | ret = PTR_ERR(ha->dpc_thread); |
| 3033 | goto probe_failed; |
| 3034 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3035 | ql_dbg(ql_dbg_init, base_vha, 0x00ee, |
| 3036 | "DPC thread started successfully.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3037 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3038 | /* |
| 3039 | * If we're not coming up in initiator mode, we might sit for |
| 3040 | * a while without waking up the dpc thread, which leads to a |
| 3041 | * stuck process warning. So just kick the dpc once here and |
| 3042 | * let the kthread start (and go back to sleep in qla2x00_do_dpc). |
| 3043 | */ |
| 3044 | qla2xxx_wake_dpc(base_vha); |
| 3045 | |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 3046 | INIT_WORK(&ha->board_disable, qla2x00_disable_board_on_pci_error); |
| 3047 | |
Saurav Kashyap | 8117877 | 2012-08-22 14:21:04 -0400 | [diff] [blame] | 3048 | if (IS_QLA8031(ha) || IS_MCTP_CAPABLE(ha)) { |
| 3049 | sprintf(wq_name, "qla2xxx_%lu_dpc_lp_wq", base_vha->host_no); |
| 3050 | ha->dpc_lp_wq = create_singlethread_workqueue(wq_name); |
| 3051 | INIT_WORK(&ha->idc_aen, qla83xx_service_idc_aen); |
| 3052 | |
| 3053 | sprintf(wq_name, "qla2xxx_%lu_dpc_hp_wq", base_vha->host_no); |
| 3054 | ha->dpc_hp_wq = create_singlethread_workqueue(wq_name); |
| 3055 | INIT_WORK(&ha->nic_core_reset, qla83xx_nic_core_reset_work); |
| 3056 | INIT_WORK(&ha->idc_state_handler, |
| 3057 | qla83xx_idc_state_handler_work); |
| 3058 | INIT_WORK(&ha->nic_core_unrecoverable, |
| 3059 | qla83xx_nic_core_unrecoverable_work); |
| 3060 | } |
| 3061 | |
Andrew Vasquez | cbc8eb6 | 2009-06-03 09:55:17 -0700 | [diff] [blame] | 3062 | skip_dpc: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3063 | list_add_tail(&base_vha->list, &ha->vp_list); |
| 3064 | base_vha->host->irq = ha->pdev->irq; |
| 3065 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3066 | /* Initialized the timer */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3067 | qla2x00_start_timer(base_vha, qla2x00_timer, WATCH_INTERVAL); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3068 | ql_dbg(ql_dbg_init, base_vha, 0x00ef, |
| 3069 | "Started qla2x00_timer with " |
| 3070 | "interval=%d.\n", WATCH_INTERVAL); |
| 3071 | ql_dbg(ql_dbg_init, base_vha, 0x00f0, |
| 3072 | "Detected hba at address=%p.\n", |
| 3073 | ha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3074 | |
Arun Easi | e02587d | 2011-08-16 11:29:23 -0700 | [diff] [blame] | 3075 | if (IS_T10_PI_CAPABLE(ha) && ql2xenabledif) { |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 3076 | if (ha->fw_attributes & BIT_4) { |
Arun Easi | 9e522cd | 2012-08-22 14:21:31 -0400 | [diff] [blame] | 3077 | int prot = 0, guard; |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 3078 | base_vha->flags.difdix_supported = 1; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3079 | ql_dbg(ql_dbg_init, base_vha, 0x00f1, |
| 3080 | "Registering for DIF/DIX type 1 and 3 protection.\n"); |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 3081 | if (ql2xenabledif == 1) |
| 3082 | prot = SHOST_DIX_TYPE0_PROTECTION; |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 3083 | scsi_host_set_prot(host, |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 3084 | prot | SHOST_DIF_TYPE1_PROTECTION |
Arun Easi | 0c47087 | 2010-07-23 15:28:38 +0500 | [diff] [blame] | 3085 | | SHOST_DIF_TYPE2_PROTECTION |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 3086 | | SHOST_DIF_TYPE3_PROTECTION |
| 3087 | | SHOST_DIX_TYPE1_PROTECTION |
Arun Easi | 0c47087 | 2010-07-23 15:28:38 +0500 | [diff] [blame] | 3088 | | SHOST_DIX_TYPE2_PROTECTION |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 3089 | | SHOST_DIX_TYPE3_PROTECTION); |
Arun Easi | 9e522cd | 2012-08-22 14:21:31 -0400 | [diff] [blame] | 3090 | |
| 3091 | guard = SHOST_DIX_GUARD_CRC; |
| 3092 | |
| 3093 | if (IS_PI_IPGUARD_CAPABLE(ha) && |
| 3094 | (ql2xenabledif > 1 || IS_PI_DIFB_DIX0_CAPABLE(ha))) |
| 3095 | guard |= SHOST_DIX_GUARD_IP; |
| 3096 | |
| 3097 | scsi_host_set_guard(host, guard); |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 3098 | } else |
| 3099 | base_vha->flags.difdix_supported = 0; |
| 3100 | } |
| 3101 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3102 | ha->isp_ops->enable_intrs(ha); |
| 3103 | |
Armen Baloyan | 1fe19ee | 2013-08-27 01:37:41 -0400 | [diff] [blame] | 3104 | if (IS_QLAFX00(ha)) { |
| 3105 | ret = qlafx00_fx_disc(base_vha, |
| 3106 | &base_vha->hw->mr.fcport, FXDISC_GET_CONFIG_INFO); |
| 3107 | host->sg_tablesize = (ha->mr.extended_io_enabled) ? |
| 3108 | QLA_SG_ALL : 128; |
| 3109 | } |
| 3110 | |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 3111 | ret = scsi_add_host(host, &pdev->dev); |
| 3112 | if (ret) |
| 3113 | goto probe_failed; |
| 3114 | |
Michael Reed | 1486400 | 2009-12-02 09:11:16 -0600 | [diff] [blame] | 3115 | base_vha->flags.init_done = 1; |
| 3116 | base_vha->flags.online = 1; |
Saurav Kashyap | edaa5c7 | 2014-04-11 16:54:14 -0400 | [diff] [blame] | 3117 | ha->prev_minidump_failed = 0; |
Michael Reed | 1486400 | 2009-12-02 09:11:16 -0600 | [diff] [blame] | 3118 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3119 | ql_dbg(ql_dbg_init, base_vha, 0x00f2, |
| 3120 | "Init done and hba is online.\n"); |
| 3121 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3122 | if (qla_ini_mode_enabled(base_vha)) |
| 3123 | scsi_scan_host(host); |
| 3124 | else |
| 3125 | ql_dbg(ql_dbg_init, base_vha, 0x0122, |
| 3126 | "skipping scsi_scan_host() for non-initiator port\n"); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 3127 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3128 | qla2x00_alloc_sysfs_attr(base_vha); |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 3129 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3130 | if (IS_QLAFX00(ha)) { |
| 3131 | ret = qlafx00_fx_disc(base_vha, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3132 | &base_vha->hw->mr.fcport, FXDISC_GET_PORT_INFO); |
| 3133 | |
| 3134 | /* Register system information */ |
| 3135 | ret = qlafx00_fx_disc(base_vha, |
| 3136 | &base_vha->hw->mr.fcport, FXDISC_REG_HOST_INFO); |
| 3137 | } |
| 3138 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3139 | qla2x00_init_host_attr(base_vha); |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 3140 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3141 | qla2x00_dfs_setup(base_vha); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3142 | |
Armen Baloyan | 03eb912 | 2013-10-30 03:38:22 -0400 | [diff] [blame] | 3143 | ql_log(ql_log_info, base_vha, 0x00fb, |
| 3144 | "QLogic %s - %s.\n", ha->model_number, ha->model_desc); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3145 | ql_log(ql_log_info, base_vha, 0x00fc, |
| 3146 | "ISP%04X: %s @ %s hdma%c host#=%ld fw=%s.\n", |
| 3147 | pdev->device, ha->isp_ops->pci_info_str(base_vha, pci_info), |
| 3148 | pci_name(pdev), ha->flags.enable_64bit_addressing ? '+' : '-', |
| 3149 | base_vha->host_no, |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 3150 | 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] | 3151 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3152 | qlt_add_target(ha, base_vha); |
| 3153 | |
Joe Lawrence | 6b38397 | 2014-08-26 17:12:29 -0400 | [diff] [blame] | 3154 | clear_bit(PFLG_DRIVER_PROBING, &base_vha->pci_flags); |
Joe Carnuccio | a29b3dd | 2016-07-06 11:14:19 -0400 | [diff] [blame] | 3155 | |
| 3156 | if (test_bit(UNLOADING, &base_vha->dpc_flags)) |
| 3157 | return -ENODEV; |
| 3158 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3159 | return 0; |
| 3160 | |
Anirban Chakraborty | 6e9f21f | 2009-01-22 09:45:28 -0800 | [diff] [blame] | 3161 | probe_init_failed: |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3162 | qla2x00_free_req_que(ha, req); |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 3163 | ha->req_q_map[0] = NULL; |
| 3164 | clear_bit(0, ha->req_qid_map); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3165 | qla2x00_free_rsp_que(ha, rsp); |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 3166 | ha->rsp_q_map[0] = NULL; |
| 3167 | clear_bit(0, ha->rsp_qid_map); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3168 | ha->max_req_queues = ha->max_rsp_queues = 0; |
Anirban Chakraborty | 6e9f21f | 2009-01-22 09:45:28 -0800 | [diff] [blame] | 3169 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3170 | probe_failed: |
Andrew Vasquez | b997876 | 2009-03-24 09:08:05 -0700 | [diff] [blame] | 3171 | if (base_vha->timer_active) |
| 3172 | qla2x00_stop_timer(base_vha); |
| 3173 | base_vha->flags.online = 0; |
| 3174 | if (ha->dpc_thread) { |
| 3175 | struct task_struct *t = ha->dpc_thread; |
| 3176 | |
| 3177 | ha->dpc_thread = NULL; |
| 3178 | kthread_stop(t); |
| 3179 | } |
| 3180 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3181 | qla2x00_free_device(base_vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3182 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3183 | scsi_host_put(base_vha->host); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3184 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3185 | probe_hw_failed: |
Joe Lawrence | 1a2fbf1 | 2014-08-26 17:11:18 -0400 | [diff] [blame] | 3186 | qla2x00_clear_drv_active(ha); |
| 3187 | |
Saurav Kashyap | 0a63ad1 | 2012-11-21 02:40:43 -0500 | [diff] [blame] | 3188 | iospace_config_failed: |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 3189 | if (IS_P3P_TYPE(ha)) { |
Saurav Kashyap | 0a63ad1 | 2012-11-21 02:40:43 -0500 | [diff] [blame] | 3190 | if (!ha->nx_pcibase) |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3191 | iounmap((device_reg_t *)ha->nx_pcibase); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3192 | if (!ql2xdbwr) |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3193 | iounmap((device_reg_t *)ha->nxdb_wr_ptr); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3194 | } else { |
| 3195 | if (ha->iobase) |
| 3196 | iounmap(ha->iobase); |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3197 | if (ha->cregbase) |
| 3198 | iounmap(ha->cregbase); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3199 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3200 | pci_release_selected_regions(ha->pdev, ha->bars); |
| 3201 | kfree(ha); |
| 3202 | ha = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3203 | |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 3204 | probe_out: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3205 | pci_disable_device(pdev); |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 3206 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3207 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3208 | |
Adrian Bunk | 4c993f7 | 2008-01-14 00:55:16 -0800 | [diff] [blame] | 3209 | static void |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3210 | qla2x00_shutdown(struct pci_dev *pdev) |
| 3211 | { |
| 3212 | scsi_qla_host_t *vha; |
| 3213 | struct qla_hw_data *ha; |
| 3214 | |
Masanari Iida | 552f3f9 | 2013-02-08 01:57:44 -0500 | [diff] [blame] | 3215 | if (!atomic_read(&pdev->enable_cnt)) |
| 3216 | return; |
| 3217 | |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3218 | vha = pci_get_drvdata(pdev); |
| 3219 | ha = vha->hw; |
| 3220 | |
Armen Baloyan | 4247934 | 2013-08-27 01:37:37 -0400 | [diff] [blame] | 3221 | /* Notify ISPFX00 firmware */ |
| 3222 | if (IS_QLAFX00(ha)) |
| 3223 | qlafx00_driver_shutdown(vha, 20); |
| 3224 | |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3225 | /* Turn-off FCE trace */ |
| 3226 | if (ha->flags.fce_enabled) { |
| 3227 | qla2x00_disable_fce_trace(vha, NULL, NULL); |
| 3228 | ha->flags.fce_enabled = 0; |
| 3229 | } |
| 3230 | |
| 3231 | /* Turn-off EFT trace */ |
| 3232 | if (ha->eft) |
| 3233 | qla2x00_disable_eft_trace(vha); |
| 3234 | |
| 3235 | /* Stop currently executing firmware. */ |
| 3236 | qla2x00_try_to_stop_firmware(vha); |
| 3237 | |
| 3238 | /* Turn adapter off line */ |
| 3239 | vha->flags.online = 0; |
| 3240 | |
| 3241 | /* turn-off interrupts on the card */ |
| 3242 | if (ha->interrupts_on) { |
| 3243 | vha->flags.init_done = 0; |
| 3244 | ha->isp_ops->disable_intrs(ha); |
| 3245 | } |
| 3246 | |
| 3247 | qla2x00_free_irqs(vha); |
| 3248 | |
| 3249 | qla2x00_free_fw_dump(ha); |
Chad Dupuis | 61d41f6 | 2014-09-25 05:17:02 -0400 | [diff] [blame] | 3250 | |
| 3251 | pci_disable_pcie_error_reporting(pdev); |
| 3252 | pci_disable_device(pdev); |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3253 | } |
| 3254 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3255 | /* Deletes all the virtual ports for a given ha */ |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3256 | static void |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3257 | 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] | 3258 | { |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3259 | scsi_qla_host_t *vha; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3260 | unsigned long flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3261 | |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 3262 | mutex_lock(&ha->vport_lock); |
| 3263 | while (ha->cur_vport_count) { |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 3264 | spin_lock_irqsave(&ha->vport_slock, flags); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3265 | |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 3266 | BUG_ON(base_vha->list.next == &ha->vp_list); |
| 3267 | /* This assumes first entry in ha->vp_list is always base vha */ |
| 3268 | 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] | 3269 | scsi_host_get(vha->host); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3270 | |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 3271 | spin_unlock_irqrestore(&ha->vport_slock, flags); |
| 3272 | mutex_unlock(&ha->vport_lock); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3273 | |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 3274 | fc_vport_terminate(vha->fc_vport); |
| 3275 | scsi_host_put(vha->host); |
| 3276 | |
| 3277 | mutex_lock(&ha->vport_lock); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3278 | } |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 3279 | mutex_unlock(&ha->vport_lock); |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3280 | } |
Andrew Vasquez | c795c1e | 2008-08-13 21:37:01 -0700 | [diff] [blame] | 3281 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3282 | /* Stops all deferred work threads */ |
| 3283 | static void |
| 3284 | qla2x00_destroy_deferred_work(struct qla_hw_data *ha) |
| 3285 | { |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 3286 | /* Cancel all work and destroy DPC workqueues */ |
| 3287 | if (ha->dpc_lp_wq) { |
| 3288 | cancel_work_sync(&ha->idc_aen); |
| 3289 | destroy_workqueue(ha->dpc_lp_wq); |
| 3290 | ha->dpc_lp_wq = NULL; |
| 3291 | } |
| 3292 | |
| 3293 | if (ha->dpc_hp_wq) { |
| 3294 | cancel_work_sync(&ha->nic_core_reset); |
| 3295 | cancel_work_sync(&ha->idc_state_handler); |
| 3296 | cancel_work_sync(&ha->nic_core_unrecoverable); |
| 3297 | destroy_workqueue(ha->dpc_hp_wq); |
| 3298 | ha->dpc_hp_wq = NULL; |
| 3299 | } |
| 3300 | |
Andrew Vasquez | b997876 | 2009-03-24 09:08:05 -0700 | [diff] [blame] | 3301 | /* Kill the kernel thread for this host */ |
| 3302 | if (ha->dpc_thread) { |
| 3303 | struct task_struct *t = ha->dpc_thread; |
| 3304 | |
| 3305 | /* |
| 3306 | * qla2xxx_wake_dpc checks for ->dpc_thread |
| 3307 | * so we need to zero it out. |
| 3308 | */ |
| 3309 | ha->dpc_thread = NULL; |
| 3310 | kthread_stop(t); |
| 3311 | } |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3312 | } |
Andrew Vasquez | b997876 | 2009-03-24 09:08:05 -0700 | [diff] [blame] | 3313 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3314 | static void |
| 3315 | qla2x00_unmap_iobases(struct qla_hw_data *ha) |
| 3316 | { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3317 | if (IS_QLA82XX(ha)) { |
Giridhar Malavali | b963752 | 2010-05-28 15:08:15 -0700 | [diff] [blame] | 3318 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3319 | iounmap((device_reg_t *)ha->nx_pcibase); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3320 | if (!ql2xdbwr) |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3321 | iounmap((device_reg_t *)ha->nxdb_wr_ptr); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3322 | } else { |
| 3323 | if (ha->iobase) |
| 3324 | iounmap(ha->iobase); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3325 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3326 | if (ha->cregbase) |
| 3327 | iounmap(ha->cregbase); |
| 3328 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3329 | if (ha->mqiobase) |
| 3330 | iounmap(ha->mqiobase); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3331 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3332 | if ((IS_QLA83XX(ha) || IS_QLA27XX(ha)) && ha->msixbase) |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3333 | iounmap(ha->msixbase); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3334 | } |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3335 | } |
| 3336 | |
| 3337 | static void |
Joe Lawrence | db7157d | 2014-08-26 17:10:41 -0400 | [diff] [blame] | 3338 | qla2x00_clear_drv_active(struct qla_hw_data *ha) |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3339 | { |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3340 | if (IS_QLA8044(ha)) { |
| 3341 | qla8044_idc_lock(ha); |
Saurav Kashyap | c41afc9 | 2013-11-07 02:54:56 -0500 | [diff] [blame] | 3342 | qla8044_clear_drv_active(ha); |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3343 | qla8044_idc_unlock(ha); |
| 3344 | } else if (IS_QLA82XX(ha)) { |
| 3345 | qla82xx_idc_lock(ha); |
| 3346 | qla82xx_clear_drv_active(ha); |
| 3347 | qla82xx_idc_unlock(ha); |
| 3348 | } |
| 3349 | } |
| 3350 | |
| 3351 | static void |
| 3352 | qla2x00_remove_one(struct pci_dev *pdev) |
| 3353 | { |
| 3354 | scsi_qla_host_t *base_vha; |
| 3355 | struct qla_hw_data *ha; |
| 3356 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3357 | base_vha = pci_get_drvdata(pdev); |
| 3358 | ha = base_vha->hw; |
| 3359 | |
Joe Lawrence | beb9e31 | 2014-08-26 17:12:14 -0400 | [diff] [blame] | 3360 | /* Indicate device removal to prevent future board_disable and wait |
| 3361 | * until any pending board_disable has completed. */ |
| 3362 | set_bit(PFLG_DRIVER_REMOVING, &base_vha->pci_flags); |
| 3363 | cancel_work_sync(&ha->board_disable); |
| 3364 | |
| 3365 | /* |
| 3366 | * If the PCI device is disabled then there was a PCI-disconnect and |
| 3367 | * qla2x00_disable_board_on_pci_error has taken care of most of the |
| 3368 | * resources. |
| 3369 | */ |
| 3370 | if (!atomic_read(&pdev->enable_cnt)) { |
| 3371 | scsi_host_put(base_vha->host); |
| 3372 | kfree(ha); |
| 3373 | pci_set_drvdata(pdev, NULL); |
| 3374 | return; |
| 3375 | } |
| 3376 | |
Sawan Chandak | 638a1a0 | 2014-04-11 16:54:38 -0400 | [diff] [blame] | 3377 | qla2x00_wait_for_hba_ready(base_vha); |
| 3378 | |
Sawan Chandak | 783e0dc | 2016-07-06 11:14:25 -0400 | [diff] [blame] | 3379 | /* if UNLOAD flag is already set, then continue unload, |
| 3380 | * where it was set first. |
| 3381 | */ |
| 3382 | if (test_bit(UNLOADING, &base_vha->dpc_flags)) |
| 3383 | return; |
| 3384 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3385 | set_bit(UNLOADING, &base_vha->dpc_flags); |
| 3386 | |
| 3387 | if (IS_QLAFX00(ha)) |
| 3388 | qlafx00_driver_shutdown(base_vha, 20); |
| 3389 | |
| 3390 | qla2x00_delete_all_vps(ha, base_vha); |
| 3391 | |
| 3392 | if (IS_QLA8031(ha)) { |
| 3393 | ql_dbg(ql_dbg_p3p, base_vha, 0xb07e, |
| 3394 | "Clearing fcoe driver presence.\n"); |
| 3395 | if (qla83xx_clear_drv_presence(base_vha) != QLA_SUCCESS) |
| 3396 | ql_dbg(ql_dbg_p3p, base_vha, 0xb079, |
| 3397 | "Error while clearing DRV-Presence.\n"); |
| 3398 | } |
| 3399 | |
| 3400 | qla2x00_abort_all_cmds(base_vha, DID_NO_CONNECT << 16); |
| 3401 | |
| 3402 | qla2x00_dfs_remove(base_vha); |
| 3403 | |
| 3404 | qla84xx_put_chip(base_vha); |
| 3405 | |
Himanshu Madhani | 2d5a4c3 | 2014-09-25 05:16:55 -0400 | [diff] [blame] | 3406 | /* Laser should be disabled only for ISP2031 */ |
| 3407 | if (IS_QLA2031(ha)) |
| 3408 | qla83xx_disable_laser(base_vha); |
| 3409 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3410 | /* Disable timer */ |
| 3411 | if (base_vha->timer_active) |
| 3412 | qla2x00_stop_timer(base_vha); |
| 3413 | |
| 3414 | base_vha->flags.online = 0; |
| 3415 | |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 3416 | /* free DMA memory */ |
| 3417 | if (ha->exlogin_buf) |
| 3418 | qla2x00_free_exlogin_buffer(ha); |
| 3419 | |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 3420 | /* free DMA memory */ |
| 3421 | if (ha->exchoffld_buf) |
| 3422 | qla2x00_free_exchoffld_buffer(ha); |
| 3423 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3424 | qla2x00_destroy_deferred_work(ha); |
| 3425 | |
| 3426 | qlt_remove_target(ha, base_vha); |
| 3427 | |
| 3428 | qla2x00_free_sysfs_attr(base_vha, true); |
| 3429 | |
| 3430 | fc_remove_host(base_vha->host); |
| 3431 | |
| 3432 | scsi_remove_host(base_vha->host); |
| 3433 | |
| 3434 | qla2x00_free_device(base_vha); |
| 3435 | |
Joe Lawrence | db7157d | 2014-08-26 17:10:41 -0400 | [diff] [blame] | 3436 | qla2x00_clear_drv_active(ha); |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3437 | |
Arun Easi | d2749ff | 2014-09-25 05:16:51 -0400 | [diff] [blame] | 3438 | scsi_host_put(base_vha->host); |
| 3439 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3440 | qla2x00_unmap_iobases(ha); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3441 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3442 | pci_release_selected_regions(ha->pdev, ha->bars); |
| 3443 | kfree(ha); |
| 3444 | ha = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3445 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 3446 | pci_disable_pcie_error_reporting(pdev); |
| 3447 | |
Bernhard Walle | 665db93 | 2007-03-28 00:49:49 +0200 | [diff] [blame] | 3448 | pci_disable_device(pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3449 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3450 | |
| 3451 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3452 | qla2x00_free_device(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3453 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3454 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3455 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 3456 | qla2x00_abort_all_cmds(vha, DID_NO_CONNECT << 16); |
| 3457 | |
| 3458 | /* Disable timer */ |
| 3459 | if (vha->timer_active) |
| 3460 | qla2x00_stop_timer(vha); |
| 3461 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3462 | qla25xx_delete_queues(vha); |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3463 | |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3464 | if (ha->flags.fce_enabled) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3465 | qla2x00_disable_fce_trace(vha, NULL, NULL); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3466 | |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3467 | if (ha->eft) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3468 | qla2x00_disable_eft_trace(vha); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3469 | |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3470 | /* Stop currently executing firmware. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3471 | qla2x00_try_to_stop_firmware(vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3472 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 3473 | vha->flags.online = 0; |
| 3474 | |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3475 | /* turn-off interrupts on the card */ |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3476 | if (ha->interrupts_on) { |
| 3477 | vha->flags.init_done = 0; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 3478 | ha->isp_ops->disable_intrs(ha); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3479 | } |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3480 | |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 3481 | qla2x00_free_fcports(vha); |
| 3482 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3483 | qla2x00_free_irqs(vha); |
| 3484 | |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 3485 | /* Flush the work queue and remove it */ |
| 3486 | if (ha->wq) { |
| 3487 | flush_workqueue(ha->wq); |
| 3488 | destroy_workqueue(ha->wq); |
| 3489 | ha->wq = NULL; |
| 3490 | } |
| 3491 | |
Chad Dupuis | 8867048 | 2010-07-23 15:28:30 +0500 | [diff] [blame] | 3492 | |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3493 | qla2x00_mem_free(ha); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3494 | |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 3495 | qla82xx_md_free(vha); |
| 3496 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3497 | qla2x00_free_queues(ha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3498 | } |
| 3499 | |
Chad Dupuis | 8867048 | 2010-07-23 15:28:30 +0500 | [diff] [blame] | 3500 | void qla2x00_free_fcports(struct scsi_qla_host *vha) |
| 3501 | { |
| 3502 | fc_port_t *fcport, *tfcport; |
| 3503 | |
| 3504 | list_for_each_entry_safe(fcport, tfcport, &vha->vp_fcports, list) { |
| 3505 | list_del(&fcport->list); |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 3506 | qla2x00_clear_loop_id(fcport); |
Chad Dupuis | 8867048 | 2010-07-23 15:28:30 +0500 | [diff] [blame] | 3507 | kfree(fcport); |
| 3508 | fcport = NULL; |
| 3509 | } |
| 3510 | } |
| 3511 | |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3512 | static inline void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3513 | 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] | 3514 | int defer) |
| 3515 | { |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3516 | struct fc_rport *rport; |
Andrew Vasquez | 67becc0 | 2009-08-25 11:36:20 -0700 | [diff] [blame] | 3517 | scsi_qla_host_t *base_vha; |
Madhuranath Iyengar | 044d78e | 2011-01-28 15:17:56 -0800 | [diff] [blame] | 3518 | unsigned long flags; |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3519 | |
| 3520 | if (!fcport->rport) |
| 3521 | return; |
| 3522 | |
| 3523 | rport = fcport->rport; |
| 3524 | if (defer) { |
Andrew Vasquez | 67becc0 | 2009-08-25 11:36:20 -0700 | [diff] [blame] | 3525 | base_vha = pci_get_drvdata(vha->hw->pdev); |
Madhuranath Iyengar | 044d78e | 2011-01-28 15:17:56 -0800 | [diff] [blame] | 3526 | spin_lock_irqsave(vha->host->host_lock, flags); |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3527 | fcport->drport = rport; |
Madhuranath Iyengar | 044d78e | 2011-01-28 15:17:56 -0800 | [diff] [blame] | 3528 | spin_unlock_irqrestore(vha->host->host_lock, flags); |
Alexei Potashnik | df67327 | 2015-07-14 16:00:46 -0400 | [diff] [blame] | 3529 | qlt_do_generation_tick(vha, &base_vha->total_fcport_update_gen); |
Andrew Vasquez | 67becc0 | 2009-08-25 11:36:20 -0700 | [diff] [blame] | 3530 | set_bit(FCPORT_UPDATE_NEEDED, &base_vha->dpc_flags); |
| 3531 | qla2xxx_wake_dpc(base_vha); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3532 | } else { |
Alexei Potashnik | df67327 | 2015-07-14 16:00:46 -0400 | [diff] [blame] | 3533 | int now; |
Alexei Potashnik | d20ed91 | 2015-07-14 16:00:47 -0400 | [diff] [blame] | 3534 | if (rport) |
| 3535 | fc_remote_port_delete(rport); |
Alexei Potashnik | df67327 | 2015-07-14 16:00:46 -0400 | [diff] [blame] | 3536 | qlt_do_generation_tick(vha, &now); |
| 3537 | qlt_fc_port_deleted(vha, fcport, now); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3538 | } |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3539 | } |
| 3540 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3541 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3542 | * qla2x00_mark_device_lost Updates fcport state when device goes offline. |
| 3543 | * |
| 3544 | * Input: ha = adapter block pointer. fcport = port structure pointer. |
| 3545 | * |
| 3546 | * Return: None. |
| 3547 | * |
| 3548 | * Context: |
| 3549 | */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3550 | 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] | 3551 | int do_login, int defer) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3552 | { |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3553 | if (IS_QLAFX00(vha->hw)) { |
| 3554 | qla2x00_set_fcport_state(fcport, FCS_DEVICE_LOST); |
| 3555 | qla2x00_schedule_rport_del(vha, fcport, defer); |
| 3556 | return; |
| 3557 | } |
| 3558 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3559 | if (atomic_read(&fcport->state) == FCS_ONLINE && |
Joe Carnuccio | c6d39e2 | 2012-05-15 14:34:20 -0400 | [diff] [blame] | 3560 | vha->vp_idx == fcport->vha->vp_idx) { |
Chad Dupuis | ec426e1 | 2011-03-30 11:46:32 -0700 | [diff] [blame] | 3561 | qla2x00_set_fcport_state(fcport, FCS_DEVICE_LOST); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3562 | qla2x00_schedule_rport_del(vha, fcport, defer); |
| 3563 | } |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 3564 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3565 | * We may need to retry the login, so don't change the state of the |
| 3566 | * port but do the retries. |
| 3567 | */ |
| 3568 | if (atomic_read(&fcport->state) != FCS_DEVICE_DEAD) |
Chad Dupuis | ec426e1 | 2011-03-30 11:46:32 -0700 | [diff] [blame] | 3569 | qla2x00_set_fcport_state(fcport, FCS_DEVICE_LOST); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3570 | |
| 3571 | if (!do_login) |
| 3572 | return; |
| 3573 | |
Arun Easi | a1d0285 | 2015-08-04 13:38:02 -0400 | [diff] [blame] | 3574 | set_bit(RELOGIN_NEEDED, &vha->dpc_flags); |
| 3575 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3576 | if (fcport->login_retry == 0) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3577 | fcport->login_retry = vha->hw->login_retry_count; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3578 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3579 | ql_dbg(ql_dbg_disc, vha, 0x2067, |
Oleksandr Khoshaba | 7b83355 | 2013-08-27 01:37:27 -0400 | [diff] [blame] | 3580 | "Port login retry %8phN, id = 0x%04x retry cnt=%d.\n", |
| 3581 | fcport->port_name, fcport->loop_id, fcport->login_retry); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3582 | } |
| 3583 | } |
| 3584 | |
| 3585 | /* |
| 3586 | * qla2x00_mark_all_devices_lost |
| 3587 | * Updates fcport state when device goes offline. |
| 3588 | * |
| 3589 | * Input: |
| 3590 | * ha = adapter block pointer. |
| 3591 | * fcport = port structure pointer. |
| 3592 | * |
| 3593 | * Return: |
| 3594 | * None. |
| 3595 | * |
| 3596 | * Context: |
| 3597 | */ |
| 3598 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3599 | qla2x00_mark_all_devices_lost(scsi_qla_host_t *vha, int defer) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3600 | { |
| 3601 | fc_port_t *fcport; |
| 3602 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3603 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
Joe Carnuccio | c6d39e2 | 2012-05-15 14:34:20 -0400 | [diff] [blame] | 3604 | if (vha->vp_idx != 0 && vha->vp_idx != fcport->vha->vp_idx) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3605 | continue; |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 3606 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3607 | /* |
| 3608 | * No point in marking the device as lost, if the device is |
| 3609 | * already DEAD. |
| 3610 | */ |
| 3611 | if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD) |
| 3612 | continue; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3613 | if (atomic_read(&fcport->state) == FCS_ONLINE) { |
Chad Dupuis | ec426e1 | 2011-03-30 11:46:32 -0700 | [diff] [blame] | 3614 | qla2x00_set_fcport_state(fcport, FCS_DEVICE_LOST); |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 3615 | if (defer) |
| 3616 | qla2x00_schedule_rport_del(vha, fcport, defer); |
Joe Carnuccio | c6d39e2 | 2012-05-15 14:34:20 -0400 | [diff] [blame] | 3617 | else if (vha->vp_idx == fcport->vha->vp_idx) |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 3618 | qla2x00_schedule_rport_del(vha, fcport, defer); |
| 3619 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3620 | } |
| 3621 | } |
| 3622 | |
| 3623 | /* |
| 3624 | * qla2x00_mem_alloc |
| 3625 | * Allocates adapter memory. |
| 3626 | * |
| 3627 | * Returns: |
| 3628 | * 0 = success. |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3629 | * !0 = failure. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3630 | */ |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3631 | static int |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3632 | qla2x00_mem_alloc(struct qla_hw_data *ha, uint16_t req_len, uint16_t rsp_len, |
| 3633 | struct req_que **req, struct rsp_que **rsp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3634 | { |
| 3635 | char name[16]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3636 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3637 | 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] | 3638 | &ha->init_cb_dma, GFP_KERNEL); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3639 | if (!ha->init_cb) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3640 | goto fail; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3641 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3642 | if (qlt_mem_alloc(ha) < 0) |
| 3643 | goto fail_free_init_cb; |
| 3644 | |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 3645 | ha->gid_list = dma_alloc_coherent(&ha->pdev->dev, |
| 3646 | qla2x00_gid_list_size(ha), &ha->gid_list_dma, GFP_KERNEL); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3647 | if (!ha->gid_list) |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3648 | goto fail_free_tgt_mem; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3649 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3650 | ha->srb_mempool = mempool_create_slab_pool(SRB_MIN_REQ, srb_cachep); |
| 3651 | if (!ha->srb_mempool) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3652 | goto fail_free_gid_list; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3653 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 3654 | if (IS_P3P_TYPE(ha)) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3655 | /* Allocate cache for CT6 Ctx. */ |
| 3656 | if (!ctx_cachep) { |
| 3657 | ctx_cachep = kmem_cache_create("qla2xxx_ctx", |
| 3658 | sizeof(struct ct6_dsd), 0, |
| 3659 | SLAB_HWCACHE_ALIGN, NULL); |
| 3660 | if (!ctx_cachep) |
Quinn Tran | fc1ffd6 | 2016-12-23 18:06:10 -0800 | [diff] [blame] | 3661 | goto fail_free_srb_mempool; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3662 | } |
| 3663 | ha->ctx_mempool = mempool_create_slab_pool(SRB_MIN_REQ, |
| 3664 | ctx_cachep); |
| 3665 | if (!ha->ctx_mempool) |
| 3666 | goto fail_free_srb_mempool; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3667 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0021, |
| 3668 | "ctx_cachep=%p ctx_mempool=%p.\n", |
| 3669 | ctx_cachep, ha->ctx_mempool); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3670 | } |
| 3671 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3672 | /* Get memory for cached NVRAM */ |
| 3673 | ha->nvram = kzalloc(MAX_NVRAM_SIZE, GFP_KERNEL); |
| 3674 | if (!ha->nvram) |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3675 | goto fail_free_ctx_mempool; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3676 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3677 | snprintf(name, sizeof(name), "%s_%d", QLA2XXX_DRIVER_NAME, |
| 3678 | ha->pdev->device); |
| 3679 | ha->s_dma_pool = dma_pool_create(name, &ha->pdev->dev, |
| 3680 | DMA_POOL_SIZE, 8, 0); |
| 3681 | if (!ha->s_dma_pool) |
| 3682 | goto fail_free_nvram; |
| 3683 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3684 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0022, |
| 3685 | "init_cb=%p gid_list=%p, srb_mempool=%p s_dma_pool=%p.\n", |
| 3686 | ha->init_cb, ha->gid_list, ha->srb_mempool, ha->s_dma_pool); |
| 3687 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 3688 | if (IS_P3P_TYPE(ha) || ql2xenabledif) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3689 | ha->dl_dma_pool = dma_pool_create(name, &ha->pdev->dev, |
| 3690 | DSD_LIST_DMA_POOL_SIZE, 8, 0); |
| 3691 | if (!ha->dl_dma_pool) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3692 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0023, |
| 3693 | "Failed to allocate memory for dl_dma_pool.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3694 | goto fail_s_dma_pool; |
| 3695 | } |
| 3696 | |
| 3697 | ha->fcp_cmnd_dma_pool = dma_pool_create(name, &ha->pdev->dev, |
| 3698 | FCP_CMND_DMA_POOL_SIZE, 8, 0); |
| 3699 | if (!ha->fcp_cmnd_dma_pool) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3700 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0024, |
| 3701 | "Failed to allocate memory for fcp_cmnd_dma_pool.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3702 | goto fail_dl_dma_pool; |
| 3703 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3704 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0025, |
| 3705 | "dl_dma_pool=%p fcp_cmnd_dma_pool=%p.\n", |
| 3706 | ha->dl_dma_pool, ha->fcp_cmnd_dma_pool); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3707 | } |
| 3708 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3709 | /* Allocate memory for SNS commands */ |
| 3710 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3711 | /* Get consistent memory allocated for SNS commands */ |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3712 | ha->sns_cmd = dma_alloc_coherent(&ha->pdev->dev, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3713 | sizeof(struct sns_cmd_pkt), &ha->sns_cmd_dma, GFP_KERNEL); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3714 | if (!ha->sns_cmd) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3715 | goto fail_dma_pool; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3716 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0026, |
Joe Perches | d8424f6 | 2011-11-18 09:03:06 -0800 | [diff] [blame] | 3717 | "sns_cmd: %p.\n", ha->sns_cmd); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3718 | } else { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3719 | /* Get consistent memory allocated for MS IOCB */ |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3720 | ha->ms_iocb = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3721 | &ha->ms_iocb_dma); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3722 | if (!ha->ms_iocb) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3723 | goto fail_dma_pool; |
| 3724 | /* Get consistent memory allocated for CT SNS commands */ |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3725 | ha->ct_sns = dma_alloc_coherent(&ha->pdev->dev, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3726 | sizeof(struct ct_sns_pkt), &ha->ct_sns_dma, GFP_KERNEL); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3727 | if (!ha->ct_sns) |
| 3728 | goto fail_free_ms_iocb; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3729 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0027, |
| 3730 | "ms_iocb=%p ct_sns=%p.\n", |
| 3731 | ha->ms_iocb, ha->ct_sns); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3732 | } |
| 3733 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3734 | /* Allocate memory for request ring */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3735 | *req = kzalloc(sizeof(struct req_que), GFP_KERNEL); |
| 3736 | if (!*req) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3737 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0028, |
| 3738 | "Failed to allocate memory for req.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3739 | goto fail_req; |
| 3740 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3741 | (*req)->length = req_len; |
| 3742 | (*req)->ring = dma_alloc_coherent(&ha->pdev->dev, |
| 3743 | ((*req)->length + 1) * sizeof(request_t), |
| 3744 | &(*req)->dma, GFP_KERNEL); |
| 3745 | if (!(*req)->ring) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3746 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0029, |
| 3747 | "Failed to allocate memory for req_ring.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3748 | goto fail_req_ring; |
| 3749 | } |
| 3750 | /* Allocate memory for response ring */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3751 | *rsp = kzalloc(sizeof(struct rsp_que), GFP_KERNEL); |
| 3752 | if (!*rsp) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3753 | ql_log_pci(ql_log_fatal, ha->pdev, 0x002a, |
| 3754 | "Failed to allocate memory for rsp.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3755 | goto fail_rsp; |
| 3756 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3757 | (*rsp)->hw = ha; |
| 3758 | (*rsp)->length = rsp_len; |
| 3759 | (*rsp)->ring = dma_alloc_coherent(&ha->pdev->dev, |
| 3760 | ((*rsp)->length + 1) * sizeof(response_t), |
| 3761 | &(*rsp)->dma, GFP_KERNEL); |
| 3762 | if (!(*rsp)->ring) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3763 | ql_log_pci(ql_log_fatal, ha->pdev, 0x002b, |
| 3764 | "Failed to allocate memory for rsp_ring.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3765 | goto fail_rsp_ring; |
| 3766 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3767 | (*req)->rsp = *rsp; |
| 3768 | (*rsp)->req = *req; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3769 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x002c, |
| 3770 | "req=%p req->length=%d req->ring=%p rsp=%p " |
| 3771 | "rsp->length=%d rsp->ring=%p.\n", |
| 3772 | *req, (*req)->length, (*req)->ring, *rsp, (*rsp)->length, |
| 3773 | (*rsp)->ring); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3774 | /* Allocate memory for NVRAM data for vports */ |
| 3775 | if (ha->nvram_npiv_size) { |
| 3776 | ha->npiv_info = kzalloc(sizeof(struct qla_npiv_entry) * |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3777 | ha->nvram_npiv_size, GFP_KERNEL); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3778 | if (!ha->npiv_info) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3779 | ql_log_pci(ql_log_fatal, ha->pdev, 0x002d, |
| 3780 | "Failed to allocate memory for npiv_info.\n"); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3781 | goto fail_npiv_info; |
| 3782 | } |
| 3783 | } else |
| 3784 | ha->npiv_info = NULL; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3785 | |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 3786 | /* Get consistent memory allocated for EX-INIT-CB. */ |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3787 | if (IS_CNA_CAPABLE(ha) || IS_QLA2031(ha) || IS_QLA27XX(ha)) { |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 3788 | ha->ex_init_cb = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, |
| 3789 | &ha->ex_init_cb_dma); |
| 3790 | if (!ha->ex_init_cb) |
| 3791 | goto fail_ex_init_cb; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3792 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x002e, |
| 3793 | "ex_init_cb=%p.\n", ha->ex_init_cb); |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 3794 | } |
| 3795 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3796 | INIT_LIST_HEAD(&ha->gbl_dsd_list); |
| 3797 | |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 3798 | /* Get consistent memory allocated for Async Port-Database. */ |
| 3799 | if (!IS_FWI2_CAPABLE(ha)) { |
| 3800 | ha->async_pd = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, |
| 3801 | &ha->async_pd_dma); |
| 3802 | if (!ha->async_pd) |
| 3803 | goto fail_async_pd; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3804 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x002f, |
| 3805 | "async_pd=%p.\n", ha->async_pd); |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 3806 | } |
| 3807 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3808 | INIT_LIST_HEAD(&ha->vp_list); |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 3809 | |
| 3810 | /* Allocate memory for our loop_id bitmap */ |
| 3811 | ha->loop_id_map = kzalloc(BITS_TO_LONGS(LOOPID_MAP_SIZE) * sizeof(long), |
| 3812 | GFP_KERNEL); |
| 3813 | if (!ha->loop_id_map) |
Quinn Tran | fc1ffd6 | 2016-12-23 18:06:10 -0800 | [diff] [blame] | 3814 | goto fail_loop_id_map; |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 3815 | else { |
| 3816 | qla2x00_set_reserved_loop_ids(ha); |
| 3817 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0123, |
Dan Carpenter | b2a72ec | 2014-01-21 10:00:10 +0300 | [diff] [blame] | 3818 | "loop_id_map=%p.\n", ha->loop_id_map); |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 3819 | } |
| 3820 | |
Dan Carpenter | b2a72ec | 2014-01-21 10:00:10 +0300 | [diff] [blame] | 3821 | return 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3822 | |
Quinn Tran | fc1ffd6 | 2016-12-23 18:06:10 -0800 | [diff] [blame] | 3823 | fail_loop_id_map: |
| 3824 | 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] | 3825 | fail_async_pd: |
| 3826 | 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] | 3827 | fail_ex_init_cb: |
| 3828 | kfree(ha->npiv_info); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3829 | fail_npiv_info: |
| 3830 | dma_free_coherent(&ha->pdev->dev, ((*rsp)->length + 1) * |
| 3831 | sizeof(response_t), (*rsp)->ring, (*rsp)->dma); |
| 3832 | (*rsp)->ring = NULL; |
| 3833 | (*rsp)->dma = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3834 | fail_rsp_ring: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3835 | kfree(*rsp); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3836 | fail_rsp: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3837 | dma_free_coherent(&ha->pdev->dev, ((*req)->length + 1) * |
| 3838 | sizeof(request_t), (*req)->ring, (*req)->dma); |
| 3839 | (*req)->ring = NULL; |
| 3840 | (*req)->dma = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3841 | fail_req_ring: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3842 | kfree(*req); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3843 | fail_req: |
| 3844 | dma_free_coherent(&ha->pdev->dev, sizeof(struct ct_sns_pkt), |
| 3845 | ha->ct_sns, ha->ct_sns_dma); |
| 3846 | ha->ct_sns = NULL; |
| 3847 | ha->ct_sns_dma = 0; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3848 | fail_free_ms_iocb: |
| 3849 | dma_pool_free(ha->s_dma_pool, ha->ms_iocb, ha->ms_iocb_dma); |
| 3850 | ha->ms_iocb = NULL; |
| 3851 | ha->ms_iocb_dma = 0; |
Quinn Tran | fc1ffd6 | 2016-12-23 18:06:10 -0800 | [diff] [blame] | 3852 | |
| 3853 | if (ha->sns_cmd) |
| 3854 | dma_free_coherent(&ha->pdev->dev, sizeof(struct sns_cmd_pkt), |
| 3855 | ha->sns_cmd, ha->sns_cmd_dma); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3856 | fail_dma_pool: |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 3857 | if (IS_QLA82XX(ha) || ql2xenabledif) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3858 | dma_pool_destroy(ha->fcp_cmnd_dma_pool); |
| 3859 | ha->fcp_cmnd_dma_pool = NULL; |
| 3860 | } |
| 3861 | fail_dl_dma_pool: |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 3862 | if (IS_QLA82XX(ha) || ql2xenabledif) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3863 | dma_pool_destroy(ha->dl_dma_pool); |
| 3864 | ha->dl_dma_pool = NULL; |
| 3865 | } |
| 3866 | fail_s_dma_pool: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3867 | dma_pool_destroy(ha->s_dma_pool); |
| 3868 | ha->s_dma_pool = NULL; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3869 | fail_free_nvram: |
| 3870 | kfree(ha->nvram); |
| 3871 | ha->nvram = NULL; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3872 | fail_free_ctx_mempool: |
Quinn Tran | fc1ffd6 | 2016-12-23 18:06:10 -0800 | [diff] [blame] | 3873 | if (ha->ctx_mempool) |
| 3874 | mempool_destroy(ha->ctx_mempool); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3875 | ha->ctx_mempool = NULL; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3876 | fail_free_srb_mempool: |
Quinn Tran | fc1ffd6 | 2016-12-23 18:06:10 -0800 | [diff] [blame] | 3877 | if (ha->srb_mempool) |
| 3878 | mempool_destroy(ha->srb_mempool); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3879 | ha->srb_mempool = NULL; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3880 | fail_free_gid_list: |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 3881 | dma_free_coherent(&ha->pdev->dev, qla2x00_gid_list_size(ha), |
| 3882 | ha->gid_list, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3883 | ha->gid_list_dma); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3884 | ha->gid_list = NULL; |
| 3885 | ha->gid_list_dma = 0; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3886 | fail_free_tgt_mem: |
| 3887 | qlt_mem_free(ha); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3888 | fail_free_init_cb: |
| 3889 | dma_free_coherent(&ha->pdev->dev, ha->init_cb_size, ha->init_cb, |
| 3890 | ha->init_cb_dma); |
| 3891 | ha->init_cb = NULL; |
| 3892 | ha->init_cb_dma = 0; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3893 | fail: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3894 | ql_log(ql_log_fatal, NULL, 0x0030, |
| 3895 | "Memory allocation failure.\n"); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3896 | return -ENOMEM; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3897 | } |
| 3898 | |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 3899 | int |
| 3900 | qla2x00_set_exlogins_buffer(scsi_qla_host_t *vha) |
| 3901 | { |
| 3902 | int rval; |
| 3903 | uint16_t size, max_cnt, temp; |
| 3904 | struct qla_hw_data *ha = vha->hw; |
| 3905 | |
| 3906 | /* Return if we don't need to alloacate any extended logins */ |
| 3907 | if (!ql2xexlogins) |
| 3908 | return QLA_SUCCESS; |
| 3909 | |
| 3910 | ql_log(ql_log_info, vha, 0xd021, "EXLOGIN count: %d.\n", ql2xexlogins); |
| 3911 | max_cnt = 0; |
| 3912 | rval = qla_get_exlogin_status(vha, &size, &max_cnt); |
| 3913 | if (rval != QLA_SUCCESS) { |
| 3914 | ql_log_pci(ql_log_fatal, ha->pdev, 0xd029, |
| 3915 | "Failed to get exlogin status.\n"); |
| 3916 | return rval; |
| 3917 | } |
| 3918 | |
| 3919 | temp = (ql2xexlogins > max_cnt) ? max_cnt : ql2xexlogins; |
| 3920 | ha->exlogin_size = (size * temp); |
| 3921 | ql_log(ql_log_info, vha, 0xd024, |
| 3922 | "EXLOGIN: max_logins=%d, portdb=0x%x, total=%d.\n", |
| 3923 | max_cnt, size, temp); |
| 3924 | |
| 3925 | ql_log(ql_log_info, vha, 0xd025, "EXLOGIN: requested size=0x%x\n", |
| 3926 | ha->exlogin_size); |
| 3927 | |
| 3928 | /* Get consistent memory for extended logins */ |
| 3929 | ha->exlogin_buf = dma_alloc_coherent(&ha->pdev->dev, |
| 3930 | ha->exlogin_size, &ha->exlogin_buf_dma, GFP_KERNEL); |
| 3931 | if (!ha->exlogin_buf) { |
| 3932 | ql_log_pci(ql_log_fatal, ha->pdev, 0xd02a, |
| 3933 | "Failed to allocate memory for exlogin_buf_dma.\n"); |
| 3934 | return -ENOMEM; |
| 3935 | } |
| 3936 | |
| 3937 | /* Now configure the dma buffer */ |
| 3938 | rval = qla_set_exlogin_mem_cfg(vha, ha->exlogin_buf_dma); |
| 3939 | if (rval) { |
| 3940 | ql_log(ql_log_fatal, vha, 0x00cf, |
| 3941 | "Setup extended login buffer ****FAILED****.\n"); |
| 3942 | qla2x00_free_exlogin_buffer(ha); |
| 3943 | } |
| 3944 | |
| 3945 | return rval; |
| 3946 | } |
| 3947 | |
| 3948 | /* |
| 3949 | * qla2x00_free_exlogin_buffer |
| 3950 | * |
| 3951 | * Input: |
| 3952 | * ha = adapter block pointer |
| 3953 | */ |
| 3954 | void |
| 3955 | qla2x00_free_exlogin_buffer(struct qla_hw_data *ha) |
| 3956 | { |
| 3957 | if (ha->exlogin_buf) { |
| 3958 | dma_free_coherent(&ha->pdev->dev, ha->exlogin_size, |
| 3959 | ha->exlogin_buf, ha->exlogin_buf_dma); |
| 3960 | ha->exlogin_buf = NULL; |
| 3961 | ha->exlogin_size = 0; |
| 3962 | } |
| 3963 | } |
| 3964 | |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 3965 | int |
| 3966 | qla2x00_set_exchoffld_buffer(scsi_qla_host_t *vha) |
| 3967 | { |
| 3968 | int rval; |
| 3969 | uint16_t size, max_cnt, temp; |
| 3970 | struct qla_hw_data *ha = vha->hw; |
| 3971 | |
| 3972 | /* Return if we don't need to alloacate any extended logins */ |
| 3973 | if (!ql2xexchoffld) |
| 3974 | return QLA_SUCCESS; |
| 3975 | |
| 3976 | ql_log(ql_log_info, vha, 0xd014, |
| 3977 | "Exchange offload count: %d.\n", ql2xexlogins); |
| 3978 | |
| 3979 | max_cnt = 0; |
| 3980 | rval = qla_get_exchoffld_status(vha, &size, &max_cnt); |
| 3981 | if (rval != QLA_SUCCESS) { |
| 3982 | ql_log_pci(ql_log_fatal, ha->pdev, 0xd012, |
| 3983 | "Failed to get exlogin status.\n"); |
| 3984 | return rval; |
| 3985 | } |
| 3986 | |
| 3987 | temp = (ql2xexchoffld > max_cnt) ? max_cnt : ql2xexchoffld; |
| 3988 | ha->exchoffld_size = (size * temp); |
| 3989 | ql_log(ql_log_info, vha, 0xd016, |
| 3990 | "Exchange offload: max_count=%d, buffers=0x%x, total=%d.\n", |
| 3991 | max_cnt, size, temp); |
| 3992 | |
| 3993 | ql_log(ql_log_info, vha, 0xd017, |
| 3994 | "Exchange Buffers requested size = 0x%x\n", ha->exchoffld_size); |
| 3995 | |
| 3996 | /* Get consistent memory for extended logins */ |
| 3997 | ha->exchoffld_buf = dma_alloc_coherent(&ha->pdev->dev, |
| 3998 | ha->exchoffld_size, &ha->exchoffld_buf_dma, GFP_KERNEL); |
| 3999 | if (!ha->exchoffld_buf) { |
| 4000 | ql_log_pci(ql_log_fatal, ha->pdev, 0xd013, |
| 4001 | "Failed to allocate memory for exchoffld_buf_dma.\n"); |
| 4002 | return -ENOMEM; |
| 4003 | } |
| 4004 | |
| 4005 | /* Now configure the dma buffer */ |
| 4006 | rval = qla_set_exchoffld_mem_cfg(vha, ha->exchoffld_buf_dma); |
| 4007 | if (rval) { |
| 4008 | ql_log(ql_log_fatal, vha, 0xd02e, |
| 4009 | "Setup exchange offload buffer ****FAILED****.\n"); |
| 4010 | qla2x00_free_exchoffld_buffer(ha); |
| 4011 | } |
| 4012 | |
| 4013 | return rval; |
| 4014 | } |
| 4015 | |
| 4016 | /* |
| 4017 | * qla2x00_free_exchoffld_buffer |
| 4018 | * |
| 4019 | * Input: |
| 4020 | * ha = adapter block pointer |
| 4021 | */ |
| 4022 | void |
| 4023 | qla2x00_free_exchoffld_buffer(struct qla_hw_data *ha) |
| 4024 | { |
| 4025 | if (ha->exchoffld_buf) { |
| 4026 | dma_free_coherent(&ha->pdev->dev, ha->exchoffld_size, |
| 4027 | ha->exchoffld_buf, ha->exchoffld_buf_dma); |
| 4028 | ha->exchoffld_buf = NULL; |
| 4029 | ha->exchoffld_size = 0; |
| 4030 | } |
| 4031 | } |
| 4032 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4033 | /* |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 4034 | * qla2x00_free_fw_dump |
| 4035 | * Frees fw dump stuff. |
| 4036 | * |
| 4037 | * Input: |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 4038 | * ha = adapter block pointer |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 4039 | */ |
| 4040 | static void |
| 4041 | qla2x00_free_fw_dump(struct qla_hw_data *ha) |
| 4042 | { |
| 4043 | if (ha->fce) |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4044 | dma_free_coherent(&ha->pdev->dev, |
| 4045 | FCE_SIZE, ha->fce, ha->fce_dma); |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 4046 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4047 | if (ha->eft) |
| 4048 | dma_free_coherent(&ha->pdev->dev, |
| 4049 | EFT_SIZE, ha->eft, ha->eft_dma); |
| 4050 | |
| 4051 | if (ha->fw_dump) |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 4052 | vfree(ha->fw_dump); |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4053 | if (ha->fw_dump_template) |
| 4054 | vfree(ha->fw_dump_template); |
| 4055 | |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 4056 | ha->fce = NULL; |
| 4057 | ha->fce_dma = 0; |
| 4058 | ha->eft = NULL; |
| 4059 | ha->eft_dma = 0; |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 4060 | ha->fw_dumped = 0; |
Hiral Patel | 61f098d | 2014-04-11 16:54:21 -0400 | [diff] [blame] | 4061 | ha->fw_dump_cap_flags = 0; |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 4062 | ha->fw_dump_reading = 0; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4063 | ha->fw_dump = NULL; |
| 4064 | ha->fw_dump_len = 0; |
| 4065 | ha->fw_dump_template = NULL; |
| 4066 | ha->fw_dump_template_len = 0; |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 4067 | } |
| 4068 | |
| 4069 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4070 | * qla2x00_mem_free |
| 4071 | * Frees all adapter allocated memory. |
| 4072 | * |
| 4073 | * Input: |
| 4074 | * ha = adapter block pointer. |
| 4075 | */ |
Adrian Bunk | a824ebb | 2008-01-17 09:02:15 -0800 | [diff] [blame] | 4076 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4077 | qla2x00_mem_free(struct qla_hw_data *ha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4078 | { |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 4079 | qla2x00_free_fw_dump(ha); |
| 4080 | |
Saurav Kashyap | 8117877 | 2012-08-22 14:21:04 -0400 | [diff] [blame] | 4081 | if (ha->mctp_dump) |
| 4082 | dma_free_coherent(&ha->pdev->dev, MCTP_DUMP_SIZE, ha->mctp_dump, |
| 4083 | ha->mctp_dump_dma); |
| 4084 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 4085 | if (ha->srb_mempool) |
| 4086 | mempool_destroy(ha->srb_mempool); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4087 | |
Andrew Vasquez | 11bbc1d | 2009-06-03 09:55:14 -0700 | [diff] [blame] | 4088 | if (ha->dcbx_tlv) |
| 4089 | dma_free_coherent(&ha->pdev->dev, DCBX_TLV_DATA_SIZE, |
| 4090 | ha->dcbx_tlv, ha->dcbx_tlv_dma); |
| 4091 | |
Andrew Vasquez | ce0423f | 2009-06-03 09:55:13 -0700 | [diff] [blame] | 4092 | if (ha->xgmac_data) |
| 4093 | dma_free_coherent(&ha->pdev->dev, XGMAC_DATA_SIZE, |
| 4094 | ha->xgmac_data, ha->xgmac_data_dma); |
| 4095 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4096 | if (ha->sns_cmd) |
| 4097 | dma_free_coherent(&ha->pdev->dev, sizeof(struct sns_cmd_pkt), |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4098 | ha->sns_cmd, ha->sns_cmd_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4099 | |
| 4100 | if (ha->ct_sns) |
| 4101 | dma_free_coherent(&ha->pdev->dev, sizeof(struct ct_sns_pkt), |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4102 | ha->ct_sns, ha->ct_sns_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4103 | |
Andrew Vasquez | 88729e5 | 2006-06-23 16:10:50 -0700 | [diff] [blame] | 4104 | if (ha->sfp_data) |
| 4105 | dma_pool_free(ha->s_dma_pool, ha->sfp_data, ha->sfp_data_dma); |
| 4106 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4107 | if (ha->ms_iocb) |
| 4108 | dma_pool_free(ha->s_dma_pool, ha->ms_iocb, ha->ms_iocb_dma); |
| 4109 | |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 4110 | if (ha->ex_init_cb) |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4111 | dma_pool_free(ha->s_dma_pool, |
| 4112 | ha->ex_init_cb, ha->ex_init_cb_dma); |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 4113 | |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 4114 | if (ha->async_pd) |
| 4115 | dma_pool_free(ha->s_dma_pool, ha->async_pd, ha->async_pd_dma); |
| 4116 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4117 | if (ha->s_dma_pool) |
| 4118 | dma_pool_destroy(ha->s_dma_pool); |
| 4119 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4120 | if (ha->gid_list) |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 4121 | dma_free_coherent(&ha->pdev->dev, qla2x00_gid_list_size(ha), |
| 4122 | ha->gid_list, ha->gid_list_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4123 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4124 | if (IS_QLA82XX(ha)) { |
| 4125 | if (!list_empty(&ha->gbl_dsd_list)) { |
| 4126 | struct dsd_dma *dsd_ptr, *tdsd_ptr; |
| 4127 | |
| 4128 | /* clean up allocated prev pool */ |
| 4129 | list_for_each_entry_safe(dsd_ptr, |
| 4130 | tdsd_ptr, &ha->gbl_dsd_list, list) { |
| 4131 | dma_pool_free(ha->dl_dma_pool, |
| 4132 | dsd_ptr->dsd_addr, dsd_ptr->dsd_list_dma); |
| 4133 | list_del(&dsd_ptr->list); |
| 4134 | kfree(dsd_ptr); |
| 4135 | } |
| 4136 | } |
| 4137 | } |
| 4138 | |
| 4139 | if (ha->dl_dma_pool) |
| 4140 | dma_pool_destroy(ha->dl_dma_pool); |
| 4141 | |
| 4142 | if (ha->fcp_cmnd_dma_pool) |
| 4143 | dma_pool_destroy(ha->fcp_cmnd_dma_pool); |
| 4144 | |
| 4145 | if (ha->ctx_mempool) |
| 4146 | mempool_destroy(ha->ctx_mempool); |
| 4147 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 4148 | qlt_mem_free(ha); |
| 4149 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4150 | if (ha->init_cb) |
| 4151 | dma_free_coherent(&ha->pdev->dev, ha->init_cb_size, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4152 | ha->init_cb, ha->init_cb_dma); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4153 | vfree(ha->optrom_buffer); |
| 4154 | kfree(ha->nvram); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4155 | kfree(ha->npiv_info); |
Andrew Vasquez | 7a67735 | 2012-02-09 11:15:56 -0800 | [diff] [blame] | 4156 | kfree(ha->swl); |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 4157 | kfree(ha->loop_id_map); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4158 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 4159 | ha->srb_mempool = NULL; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4160 | ha->ctx_mempool = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4161 | ha->sns_cmd = NULL; |
| 4162 | ha->sns_cmd_dma = 0; |
| 4163 | ha->ct_sns = NULL; |
| 4164 | ha->ct_sns_dma = 0; |
| 4165 | ha->ms_iocb = NULL; |
| 4166 | ha->ms_iocb_dma = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4167 | ha->init_cb = NULL; |
| 4168 | ha->init_cb_dma = 0; |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 4169 | ha->ex_init_cb = NULL; |
| 4170 | ha->ex_init_cb_dma = 0; |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 4171 | ha->async_pd = NULL; |
| 4172 | ha->async_pd_dma = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4173 | |
| 4174 | ha->s_dma_pool = NULL; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4175 | ha->dl_dma_pool = NULL; |
| 4176 | ha->fcp_cmnd_dma_pool = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4177 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4178 | ha->gid_list = NULL; |
| 4179 | ha->gid_list_dma = 0; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 4180 | |
| 4181 | ha->tgt.atio_ring = NULL; |
| 4182 | ha->tgt.atio_dma = 0; |
| 4183 | ha->tgt.tgt_vp_map = NULL; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4184 | } |
| 4185 | |
| 4186 | struct scsi_qla_host *qla2x00_create_host(struct scsi_host_template *sht, |
| 4187 | struct qla_hw_data *ha) |
| 4188 | { |
| 4189 | struct Scsi_Host *host; |
| 4190 | struct scsi_qla_host *vha = NULL; |
| 4191 | |
| 4192 | host = scsi_host_alloc(sht, sizeof(scsi_qla_host_t)); |
| 4193 | if (host == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4194 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0107, |
| 4195 | "Failed to allocate host from the scsi layer, aborting.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4196 | goto fail; |
| 4197 | } |
| 4198 | |
| 4199 | /* Clear our data area */ |
| 4200 | vha = shost_priv(host); |
| 4201 | memset(vha, 0, sizeof(scsi_qla_host_t)); |
| 4202 | |
| 4203 | vha->host = host; |
| 4204 | vha->host_no = host->host_no; |
| 4205 | vha->hw = ha; |
| 4206 | |
| 4207 | INIT_LIST_HEAD(&vha->vp_fcports); |
| 4208 | INIT_LIST_HEAD(&vha->work_list); |
| 4209 | INIT_LIST_HEAD(&vha->list); |
Swapnil Nagle | 8b2f5ff | 2015-07-14 16:00:43 -0400 | [diff] [blame] | 4210 | INIT_LIST_HEAD(&vha->qla_cmd_list); |
| 4211 | INIT_LIST_HEAD(&vha->qla_sess_op_cmd_list); |
Alexei Potashnik | 71cdc07 | 2015-12-17 14:57:01 -0500 | [diff] [blame] | 4212 | INIT_LIST_HEAD(&vha->logo_list); |
Alexei Potashnik | b7bd104 | 2015-12-17 14:57:02 -0500 | [diff] [blame] | 4213 | INIT_LIST_HEAD(&vha->plogi_ack_list); |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 4214 | INIT_LIST_HEAD(&vha->qp_list); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4215 | |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4216 | spin_lock_init(&vha->work_lock); |
Swapnil Nagle | 8b2f5ff | 2015-07-14 16:00:43 -0400 | [diff] [blame] | 4217 | spin_lock_init(&vha->cmd_list_lock); |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4218 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4219 | sprintf(vha->host_str, "%s_%ld", QLA2XXX_DRIVER_NAME, vha->host_no); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4220 | ql_dbg(ql_dbg_init, vha, 0x0041, |
| 4221 | "Allocated the host=%p hw=%p vha=%p dev_name=%s", |
| 4222 | vha->host, vha->hw, vha, |
| 4223 | dev_name(&(ha->pdev->dev))); |
| 4224 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4225 | return vha; |
| 4226 | |
| 4227 | fail: |
| 4228 | return vha; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4229 | } |
| 4230 | |
Adrian Bunk | 01ef66b | 2008-04-24 15:21:27 -0700 | [diff] [blame] | 4231 | static struct qla_work_evt * |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4232 | 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] | 4233 | { |
| 4234 | struct qla_work_evt *e; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 4235 | uint8_t bail; |
| 4236 | |
| 4237 | QLA_VHA_MARK_BUSY(vha, bail); |
| 4238 | if (bail) |
| 4239 | return NULL; |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4240 | |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4241 | e = kzalloc(sizeof(struct qla_work_evt), GFP_ATOMIC); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 4242 | if (!e) { |
| 4243 | QLA_VHA_MARK_NOT_BUSY(vha); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4244 | return NULL; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 4245 | } |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4246 | |
| 4247 | INIT_LIST_HEAD(&e->list); |
| 4248 | e->type = type; |
| 4249 | e->flags = QLA_EVT_FLAG_FREE; |
| 4250 | return e; |
| 4251 | } |
| 4252 | |
Adrian Bunk | 01ef66b | 2008-04-24 15:21:27 -0700 | [diff] [blame] | 4253 | static int |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4254 | 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] | 4255 | { |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4256 | unsigned long flags; |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4257 | |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4258 | spin_lock_irqsave(&vha->work_lock, flags); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4259 | list_add_tail(&e->list, &vha->work_list); |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4260 | spin_unlock_irqrestore(&vha->work_lock, flags); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4261 | qla2xxx_wake_dpc(vha); |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4262 | |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4263 | return QLA_SUCCESS; |
| 4264 | } |
| 4265 | |
| 4266 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4267 | 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] | 4268 | u32 data) |
| 4269 | { |
| 4270 | struct qla_work_evt *e; |
| 4271 | |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4272 | e = qla2x00_alloc_work(vha, QLA_EVT_AEN); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4273 | if (!e) |
| 4274 | return QLA_FUNCTION_FAILED; |
| 4275 | |
| 4276 | e->u.aen.code = code; |
| 4277 | e->u.aen.data = data; |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4278 | return qla2x00_post_work(vha, e); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4279 | } |
| 4280 | |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 4281 | int |
| 4282 | qla2x00_post_idc_ack_work(struct scsi_qla_host *vha, uint16_t *mb) |
| 4283 | { |
| 4284 | struct qla_work_evt *e; |
| 4285 | |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4286 | e = qla2x00_alloc_work(vha, QLA_EVT_IDC_ACK); |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 4287 | if (!e) |
| 4288 | return QLA_FUNCTION_FAILED; |
| 4289 | |
| 4290 | 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] | 4291 | return qla2x00_post_work(vha, e); |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 4292 | } |
| 4293 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4294 | #define qla2x00_post_async_work(name, type) \ |
| 4295 | int qla2x00_post_async_##name##_work( \ |
| 4296 | struct scsi_qla_host *vha, \ |
| 4297 | fc_port_t *fcport, uint16_t *data) \ |
| 4298 | { \ |
| 4299 | struct qla_work_evt *e; \ |
| 4300 | \ |
| 4301 | e = qla2x00_alloc_work(vha, type); \ |
| 4302 | if (!e) \ |
| 4303 | return QLA_FUNCTION_FAILED; \ |
| 4304 | \ |
| 4305 | e->u.logio.fcport = fcport; \ |
| 4306 | if (data) { \ |
| 4307 | e->u.logio.data[0] = data[0]; \ |
| 4308 | e->u.logio.data[1] = data[1]; \ |
| 4309 | } \ |
| 4310 | return qla2x00_post_work(vha, e); \ |
| 4311 | } |
| 4312 | |
| 4313 | qla2x00_post_async_work(login, QLA_EVT_ASYNC_LOGIN); |
| 4314 | qla2x00_post_async_work(login_done, QLA_EVT_ASYNC_LOGIN_DONE); |
| 4315 | qla2x00_post_async_work(logout, QLA_EVT_ASYNC_LOGOUT); |
| 4316 | qla2x00_post_async_work(logout_done, QLA_EVT_ASYNC_LOGOUT_DONE); |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 4317 | qla2x00_post_async_work(adisc, QLA_EVT_ASYNC_ADISC); |
| 4318 | qla2x00_post_async_work(adisc_done, QLA_EVT_ASYNC_ADISC_DONE); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4319 | |
Andrew Vasquez | 3420d36 | 2009-10-13 15:16:45 -0700 | [diff] [blame] | 4320 | int |
| 4321 | qla2x00_post_uevent_work(struct scsi_qla_host *vha, u32 code) |
| 4322 | { |
| 4323 | struct qla_work_evt *e; |
| 4324 | |
| 4325 | e = qla2x00_alloc_work(vha, QLA_EVT_UEVENT); |
| 4326 | if (!e) |
| 4327 | return QLA_FUNCTION_FAILED; |
| 4328 | |
| 4329 | e->u.uevent.code = code; |
| 4330 | return qla2x00_post_work(vha, e); |
| 4331 | } |
| 4332 | |
| 4333 | static void |
| 4334 | qla2x00_uevent_emit(struct scsi_qla_host *vha, u32 code) |
| 4335 | { |
| 4336 | char event_string[40]; |
| 4337 | char *envp[] = { event_string, NULL }; |
| 4338 | |
| 4339 | switch (code) { |
| 4340 | case QLA_UEVENT_CODE_FW_DUMP: |
| 4341 | snprintf(event_string, sizeof(event_string), "FW_DUMP=%ld", |
| 4342 | vha->host_no); |
| 4343 | break; |
| 4344 | default: |
| 4345 | /* do nothing */ |
| 4346 | break; |
| 4347 | } |
| 4348 | kobject_uevent_env(&vha->hw->pdev->dev.kobj, KOBJ_CHANGE, envp); |
| 4349 | } |
| 4350 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 4351 | int |
| 4352 | qlafx00_post_aenfx_work(struct scsi_qla_host *vha, uint32_t evtcode, |
| 4353 | uint32_t *data, int cnt) |
| 4354 | { |
| 4355 | struct qla_work_evt *e; |
| 4356 | |
| 4357 | e = qla2x00_alloc_work(vha, QLA_EVT_AENFX); |
| 4358 | if (!e) |
| 4359 | return QLA_FUNCTION_FAILED; |
| 4360 | |
| 4361 | e->u.aenfx.evtcode = evtcode; |
| 4362 | e->u.aenfx.count = cnt; |
| 4363 | memcpy(e->u.aenfx.mbx, data, sizeof(*data) * cnt); |
| 4364 | return qla2x00_post_work(vha, e); |
| 4365 | } |
| 4366 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4367 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4368 | qla2x00_do_work(struct scsi_qla_host *vha) |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4369 | { |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4370 | struct qla_work_evt *e, *tmp; |
| 4371 | unsigned long flags; |
| 4372 | LIST_HEAD(work); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4373 | |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4374 | spin_lock_irqsave(&vha->work_lock, flags); |
| 4375 | list_splice_init(&vha->work_list, &work); |
| 4376 | spin_unlock_irqrestore(&vha->work_lock, flags); |
| 4377 | |
| 4378 | list_for_each_entry_safe(e, tmp, &work, list) { |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4379 | list_del_init(&e->list); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4380 | |
| 4381 | switch (e->type) { |
| 4382 | case QLA_EVT_AEN: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4383 | fc_host_post_event(vha->host, fc_get_event_number(), |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4384 | e->u.aen.code, e->u.aen.data); |
| 4385 | break; |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 4386 | case QLA_EVT_IDC_ACK: |
| 4387 | qla81xx_idc_ack(vha, e->u.idc_ack.mb); |
| 4388 | break; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4389 | case QLA_EVT_ASYNC_LOGIN: |
| 4390 | qla2x00_async_login(vha, e->u.logio.fcport, |
| 4391 | e->u.logio.data); |
| 4392 | break; |
| 4393 | case QLA_EVT_ASYNC_LOGIN_DONE: |
| 4394 | qla2x00_async_login_done(vha, e->u.logio.fcport, |
| 4395 | e->u.logio.data); |
| 4396 | break; |
| 4397 | case QLA_EVT_ASYNC_LOGOUT: |
| 4398 | qla2x00_async_logout(vha, e->u.logio.fcport); |
| 4399 | break; |
| 4400 | case QLA_EVT_ASYNC_LOGOUT_DONE: |
| 4401 | qla2x00_async_logout_done(vha, e->u.logio.fcport, |
| 4402 | e->u.logio.data); |
| 4403 | break; |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 4404 | case QLA_EVT_ASYNC_ADISC: |
| 4405 | qla2x00_async_adisc(vha, e->u.logio.fcport, |
| 4406 | e->u.logio.data); |
| 4407 | break; |
| 4408 | case QLA_EVT_ASYNC_ADISC_DONE: |
| 4409 | qla2x00_async_adisc_done(vha, e->u.logio.fcport, |
| 4410 | e->u.logio.data); |
| 4411 | break; |
Andrew Vasquez | 3420d36 | 2009-10-13 15:16:45 -0700 | [diff] [blame] | 4412 | case QLA_EVT_UEVENT: |
| 4413 | qla2x00_uevent_emit(vha, e->u.uevent.code); |
| 4414 | break; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 4415 | case QLA_EVT_AENFX: |
| 4416 | qlafx00_process_aen(vha, e); |
| 4417 | break; |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4418 | } |
| 4419 | if (e->flags & QLA_EVT_FLAG_FREE) |
| 4420 | kfree(e); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 4421 | |
| 4422 | /* For each work completed decrement vha ref count */ |
| 4423 | QLA_VHA_MARK_NOT_BUSY(vha); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4424 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4425 | } |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4426 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4427 | /* Relogins all the fcports of a vport |
| 4428 | * Context: dpc thread |
| 4429 | */ |
| 4430 | void qla2x00_relogin(struct scsi_qla_host *vha) |
| 4431 | { |
| 4432 | fc_port_t *fcport; |
Andrew Vasquez | c6b2fca | 2009-03-05 11:07:03 -0800 | [diff] [blame] | 4433 | int status; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4434 | uint16_t next_loopid = 0; |
| 4435 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4436 | uint16_t data[2]; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4437 | |
| 4438 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
| 4439 | /* |
| 4440 | * If the port is not ONLINE then try to login |
| 4441 | * to it if we haven't run out of retries. |
| 4442 | */ |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 4443 | if (atomic_read(&fcport->state) != FCS_ONLINE && |
| 4444 | fcport->login_retry && !(fcport->flags & FCF_ASYNC_SENT)) { |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4445 | fcport->login_retry--; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4446 | if (fcport->flags & FCF_FABRIC_DEVICE) { |
Andrew Vasquez | f08b725 | 2010-01-12 12:59:48 -0800 | [diff] [blame] | 4447 | if (fcport->flags & FCF_FCP2_DEVICE) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4448 | ha->isp_ops->fabric_logout(vha, |
| 4449 | fcport->loop_id, |
| 4450 | fcport->d_id.b.domain, |
| 4451 | fcport->d_id.b.area, |
| 4452 | fcport->d_id.b.al_pa); |
| 4453 | |
Joe Carnuccio | 03bcfb5 | 2011-03-30 11:46:27 -0700 | [diff] [blame] | 4454 | if (fcport->loop_id == FC_NO_LOOP_ID) { |
| 4455 | fcport->loop_id = next_loopid = |
| 4456 | ha->min_external_loopid; |
| 4457 | status = qla2x00_find_new_loop_id( |
| 4458 | vha, fcport); |
| 4459 | if (status != QLA_SUCCESS) { |
| 4460 | /* Ran out of IDs to use */ |
| 4461 | break; |
| 4462 | } |
| 4463 | } |
| 4464 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4465 | if (IS_ALOGIO_CAPABLE(ha)) { |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 4466 | fcport->flags |= FCF_ASYNC_SENT; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4467 | data[0] = 0; |
| 4468 | data[1] = QLA_LOGIO_LOGIN_RETRIED; |
| 4469 | status = qla2x00_post_async_login_work( |
| 4470 | vha, fcport, data); |
| 4471 | if (status == QLA_SUCCESS) |
| 4472 | continue; |
| 4473 | /* Attempt a retry. */ |
| 4474 | status = 1; |
Saurav Kashyap | aaf4d3e | 2012-04-25 07:26:16 -0700 | [diff] [blame] | 4475 | } else { |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4476 | status = qla2x00_fabric_login(vha, |
| 4477 | fcport, &next_loopid); |
Saurav Kashyap | aaf4d3e | 2012-04-25 07:26:16 -0700 | [diff] [blame] | 4478 | if (status == QLA_SUCCESS) { |
| 4479 | int status2; |
| 4480 | uint8_t opts; |
| 4481 | |
| 4482 | opts = 0; |
| 4483 | if (fcport->flags & |
| 4484 | FCF_FCP2_DEVICE) |
| 4485 | opts |= BIT_1; |
Saurav Kashyap | 0300396 | 2012-11-21 02:40:31 -0500 | [diff] [blame] | 4486 | status2 = |
| 4487 | qla2x00_get_port_database( |
| 4488 | vha, fcport, opts); |
Saurav Kashyap | aaf4d3e | 2012-04-25 07:26:16 -0700 | [diff] [blame] | 4489 | if (status2 != QLA_SUCCESS) |
| 4490 | status = 1; |
| 4491 | } |
| 4492 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4493 | } else |
| 4494 | status = qla2x00_local_device_login(vha, |
| 4495 | fcport); |
| 4496 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4497 | if (status == QLA_SUCCESS) { |
| 4498 | fcport->old_loop_id = fcport->loop_id; |
| 4499 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4500 | ql_dbg(ql_dbg_disc, vha, 0x2003, |
| 4501 | "Port login OK: logged in ID 0x%x.\n", |
| 4502 | fcport->loop_id); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4503 | |
| 4504 | qla2x00_update_fcport(vha, fcport); |
| 4505 | |
| 4506 | } else if (status == 1) { |
| 4507 | set_bit(RELOGIN_NEEDED, &vha->dpc_flags); |
| 4508 | /* retry the login again */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4509 | ql_dbg(ql_dbg_disc, vha, 0x2007, |
| 4510 | "Retrying %d login again loop_id 0x%x.\n", |
| 4511 | fcport->login_retry, fcport->loop_id); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4512 | } else { |
| 4513 | fcport->login_retry = 0; |
| 4514 | } |
| 4515 | |
| 4516 | if (fcport->login_retry == 0 && status != QLA_SUCCESS) |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 4517 | qla2x00_clear_loop_id(fcport); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4518 | } |
| 4519 | if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) |
| 4520 | break; |
| 4521 | } |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4522 | } |
| 4523 | |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4524 | /* Schedule work on any of the dpc-workqueues */ |
| 4525 | void |
| 4526 | qla83xx_schedule_work(scsi_qla_host_t *base_vha, int work_code) |
| 4527 | { |
| 4528 | struct qla_hw_data *ha = base_vha->hw; |
| 4529 | |
| 4530 | switch (work_code) { |
| 4531 | case MBA_IDC_AEN: /* 0x8200 */ |
| 4532 | if (ha->dpc_lp_wq) |
| 4533 | queue_work(ha->dpc_lp_wq, &ha->idc_aen); |
| 4534 | break; |
| 4535 | |
| 4536 | case QLA83XX_NIC_CORE_RESET: /* 0x1 */ |
| 4537 | if (!ha->flags.nic_core_reset_hdlr_active) { |
| 4538 | if (ha->dpc_hp_wq) |
| 4539 | queue_work(ha->dpc_hp_wq, &ha->nic_core_reset); |
| 4540 | } else |
| 4541 | ql_dbg(ql_dbg_p3p, base_vha, 0xb05e, |
| 4542 | "NIC Core reset is already active. Skip " |
| 4543 | "scheduling it again.\n"); |
| 4544 | break; |
| 4545 | case QLA83XX_IDC_STATE_HANDLER: /* 0x2 */ |
| 4546 | if (ha->dpc_hp_wq) |
| 4547 | queue_work(ha->dpc_hp_wq, &ha->idc_state_handler); |
| 4548 | break; |
| 4549 | case QLA83XX_NIC_CORE_UNRECOVERABLE: /* 0x3 */ |
| 4550 | if (ha->dpc_hp_wq) |
| 4551 | queue_work(ha->dpc_hp_wq, &ha->nic_core_unrecoverable); |
| 4552 | break; |
| 4553 | default: |
| 4554 | ql_log(ql_log_warn, base_vha, 0xb05f, |
Masanari Iida | d939be3 | 2015-02-27 23:52:31 +0900 | [diff] [blame] | 4555 | "Unknown work-code=0x%x.\n", work_code); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4556 | } |
| 4557 | |
| 4558 | return; |
| 4559 | } |
| 4560 | |
| 4561 | /* Work: Perform NIC Core Unrecoverable state handling */ |
| 4562 | void |
| 4563 | qla83xx_nic_core_unrecoverable_work(struct work_struct *work) |
| 4564 | { |
| 4565 | struct qla_hw_data *ha = |
Arun Easi | 2ad1b67 | 2012-08-22 14:21:35 -0400 | [diff] [blame] | 4566 | container_of(work, struct qla_hw_data, nic_core_unrecoverable); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4567 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 4568 | uint32_t dev_state = 0; |
| 4569 | |
| 4570 | qla83xx_idc_lock(base_vha, 0); |
| 4571 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, &dev_state); |
| 4572 | qla83xx_reset_ownership(base_vha); |
| 4573 | if (ha->flags.nic_core_reset_owner) { |
| 4574 | ha->flags.nic_core_reset_owner = 0; |
| 4575 | qla83xx_wr_reg(base_vha, QLA83XX_IDC_DEV_STATE, |
| 4576 | QLA8XXX_DEV_FAILED); |
| 4577 | ql_log(ql_log_info, base_vha, 0xb060, "HW State: FAILED.\n"); |
| 4578 | qla83xx_schedule_work(base_vha, QLA83XX_IDC_STATE_HANDLER); |
| 4579 | } |
| 4580 | qla83xx_idc_unlock(base_vha, 0); |
| 4581 | } |
| 4582 | |
| 4583 | /* Work: Execute IDC state handler */ |
| 4584 | void |
| 4585 | qla83xx_idc_state_handler_work(struct work_struct *work) |
| 4586 | { |
| 4587 | struct qla_hw_data *ha = |
Arun Easi | 2ad1b67 | 2012-08-22 14:21:35 -0400 | [diff] [blame] | 4588 | container_of(work, struct qla_hw_data, idc_state_handler); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4589 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 4590 | uint32_t dev_state = 0; |
| 4591 | |
| 4592 | qla83xx_idc_lock(base_vha, 0); |
| 4593 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, &dev_state); |
| 4594 | if (dev_state == QLA8XXX_DEV_FAILED || |
| 4595 | dev_state == QLA8XXX_DEV_NEED_QUIESCENT) |
| 4596 | qla83xx_idc_state_handler(base_vha); |
| 4597 | qla83xx_idc_unlock(base_vha, 0); |
| 4598 | } |
| 4599 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 4600 | static int |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4601 | qla83xx_check_nic_core_fw_alive(scsi_qla_host_t *base_vha) |
| 4602 | { |
| 4603 | int rval = QLA_SUCCESS; |
| 4604 | unsigned long heart_beat_wait = jiffies + (1 * HZ); |
| 4605 | uint32_t heart_beat_counter1, heart_beat_counter2; |
| 4606 | |
| 4607 | do { |
| 4608 | if (time_after(jiffies, heart_beat_wait)) { |
| 4609 | ql_dbg(ql_dbg_p3p, base_vha, 0xb07c, |
| 4610 | "Nic Core f/w is not alive.\n"); |
| 4611 | rval = QLA_FUNCTION_FAILED; |
| 4612 | break; |
| 4613 | } |
| 4614 | |
| 4615 | qla83xx_idc_lock(base_vha, 0); |
| 4616 | qla83xx_rd_reg(base_vha, QLA83XX_FW_HEARTBEAT, |
| 4617 | &heart_beat_counter1); |
| 4618 | qla83xx_idc_unlock(base_vha, 0); |
| 4619 | msleep(100); |
| 4620 | qla83xx_idc_lock(base_vha, 0); |
| 4621 | qla83xx_rd_reg(base_vha, QLA83XX_FW_HEARTBEAT, |
| 4622 | &heart_beat_counter2); |
| 4623 | qla83xx_idc_unlock(base_vha, 0); |
| 4624 | } while (heart_beat_counter1 == heart_beat_counter2); |
| 4625 | |
| 4626 | return rval; |
| 4627 | } |
| 4628 | |
| 4629 | /* Work: Perform NIC Core Reset handling */ |
| 4630 | void |
| 4631 | qla83xx_nic_core_reset_work(struct work_struct *work) |
| 4632 | { |
| 4633 | struct qla_hw_data *ha = |
| 4634 | container_of(work, struct qla_hw_data, nic_core_reset); |
| 4635 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 4636 | uint32_t dev_state = 0; |
| 4637 | |
Saurav Kashyap | 8117877 | 2012-08-22 14:21:04 -0400 | [diff] [blame] | 4638 | if (IS_QLA2031(ha)) { |
| 4639 | if (qla2xxx_mctp_dump(base_vha) != QLA_SUCCESS) |
| 4640 | ql_log(ql_log_warn, base_vha, 0xb081, |
| 4641 | "Failed to dump mctp\n"); |
| 4642 | return; |
| 4643 | } |
| 4644 | |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4645 | if (!ha->flags.nic_core_reset_hdlr_active) { |
| 4646 | if (qla83xx_check_nic_core_fw_alive(base_vha) == QLA_SUCCESS) { |
| 4647 | qla83xx_idc_lock(base_vha, 0); |
| 4648 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, |
| 4649 | &dev_state); |
| 4650 | qla83xx_idc_unlock(base_vha, 0); |
| 4651 | if (dev_state != QLA8XXX_DEV_NEED_RESET) { |
| 4652 | ql_dbg(ql_dbg_p3p, base_vha, 0xb07a, |
| 4653 | "Nic Core f/w is alive.\n"); |
| 4654 | return; |
| 4655 | } |
| 4656 | } |
| 4657 | |
| 4658 | ha->flags.nic_core_reset_hdlr_active = 1; |
| 4659 | if (qla83xx_nic_core_reset(base_vha)) { |
| 4660 | /* NIC Core reset failed. */ |
| 4661 | ql_dbg(ql_dbg_p3p, base_vha, 0xb061, |
| 4662 | "NIC Core reset failed.\n"); |
| 4663 | } |
| 4664 | ha->flags.nic_core_reset_hdlr_active = 0; |
| 4665 | } |
| 4666 | } |
| 4667 | |
| 4668 | /* Work: Handle 8200 IDC aens */ |
| 4669 | void |
| 4670 | qla83xx_service_idc_aen(struct work_struct *work) |
| 4671 | { |
| 4672 | struct qla_hw_data *ha = |
| 4673 | container_of(work, struct qla_hw_data, idc_aen); |
| 4674 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 4675 | uint32_t dev_state, idc_control; |
| 4676 | |
| 4677 | qla83xx_idc_lock(base_vha, 0); |
| 4678 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, &dev_state); |
| 4679 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_CONTROL, &idc_control); |
| 4680 | qla83xx_idc_unlock(base_vha, 0); |
| 4681 | if (dev_state == QLA8XXX_DEV_NEED_RESET) { |
| 4682 | if (idc_control & QLA83XX_IDC_GRACEFUL_RESET) { |
| 4683 | ql_dbg(ql_dbg_p3p, base_vha, 0xb062, |
| 4684 | "Application requested NIC Core Reset.\n"); |
| 4685 | qla83xx_schedule_work(base_vha, QLA83XX_NIC_CORE_RESET); |
| 4686 | } else if (qla83xx_check_nic_core_fw_alive(base_vha) == |
| 4687 | QLA_SUCCESS) { |
| 4688 | ql_dbg(ql_dbg_p3p, base_vha, 0xb07b, |
| 4689 | "Other protocol driver requested NIC Core Reset.\n"); |
| 4690 | qla83xx_schedule_work(base_vha, QLA83XX_NIC_CORE_RESET); |
| 4691 | } |
| 4692 | } else if (dev_state == QLA8XXX_DEV_FAILED || |
| 4693 | dev_state == QLA8XXX_DEV_NEED_QUIESCENT) { |
| 4694 | qla83xx_schedule_work(base_vha, QLA83XX_IDC_STATE_HANDLER); |
| 4695 | } |
| 4696 | } |
| 4697 | |
| 4698 | static void |
| 4699 | qla83xx_wait_logic(void) |
| 4700 | { |
| 4701 | int i; |
| 4702 | |
| 4703 | /* Yield CPU */ |
| 4704 | if (!in_interrupt()) { |
| 4705 | /* |
| 4706 | * Wait about 200ms before retrying again. |
| 4707 | * This controls the number of retries for single |
| 4708 | * lock operation. |
| 4709 | */ |
| 4710 | msleep(100); |
| 4711 | schedule(); |
| 4712 | } else { |
| 4713 | for (i = 0; i < 20; i++) |
| 4714 | cpu_relax(); /* This a nop instr on i386 */ |
| 4715 | } |
| 4716 | } |
| 4717 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 4718 | static int |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4719 | qla83xx_force_lock_recovery(scsi_qla_host_t *base_vha) |
| 4720 | { |
| 4721 | int rval; |
| 4722 | uint32_t data; |
| 4723 | uint32_t idc_lck_rcvry_stage_mask = 0x3; |
| 4724 | uint32_t idc_lck_rcvry_owner_mask = 0x3c; |
| 4725 | struct qla_hw_data *ha = base_vha->hw; |
Saurav Kashyap | 6c31555 | 2013-02-08 01:57:53 -0500 | [diff] [blame] | 4726 | ql_dbg(ql_dbg_p3p, base_vha, 0xb086, |
| 4727 | "Trying force recovery of the IDC lock.\n"); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4728 | |
| 4729 | rval = qla83xx_rd_reg(base_vha, QLA83XX_IDC_LOCK_RECOVERY, &data); |
| 4730 | if (rval) |
| 4731 | return rval; |
| 4732 | |
| 4733 | if ((data & idc_lck_rcvry_stage_mask) > 0) { |
| 4734 | return QLA_SUCCESS; |
| 4735 | } else { |
| 4736 | data = (IDC_LOCK_RECOVERY_STAGE1) | (ha->portnum << 2); |
| 4737 | rval = qla83xx_wr_reg(base_vha, QLA83XX_IDC_LOCK_RECOVERY, |
| 4738 | data); |
| 4739 | if (rval) |
| 4740 | return rval; |
| 4741 | |
| 4742 | msleep(200); |
| 4743 | |
| 4744 | rval = qla83xx_rd_reg(base_vha, QLA83XX_IDC_LOCK_RECOVERY, |
| 4745 | &data); |
| 4746 | if (rval) |
| 4747 | return rval; |
| 4748 | |
| 4749 | if (((data & idc_lck_rcvry_owner_mask) >> 2) == ha->portnum) { |
| 4750 | data &= (IDC_LOCK_RECOVERY_STAGE2 | |
| 4751 | ~(idc_lck_rcvry_stage_mask)); |
| 4752 | rval = qla83xx_wr_reg(base_vha, |
| 4753 | QLA83XX_IDC_LOCK_RECOVERY, data); |
| 4754 | if (rval) |
| 4755 | return rval; |
| 4756 | |
| 4757 | /* Forcefully perform IDC UnLock */ |
| 4758 | rval = qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_UNLOCK, |
| 4759 | &data); |
| 4760 | if (rval) |
| 4761 | return rval; |
| 4762 | /* Clear lock-id by setting 0xff */ |
| 4763 | rval = qla83xx_wr_reg(base_vha, QLA83XX_DRIVER_LOCKID, |
| 4764 | 0xff); |
| 4765 | if (rval) |
| 4766 | return rval; |
| 4767 | /* Clear lock-recovery by setting 0x0 */ |
| 4768 | rval = qla83xx_wr_reg(base_vha, |
| 4769 | QLA83XX_IDC_LOCK_RECOVERY, 0x0); |
| 4770 | if (rval) |
| 4771 | return rval; |
| 4772 | } else |
| 4773 | return QLA_SUCCESS; |
| 4774 | } |
| 4775 | |
| 4776 | return rval; |
| 4777 | } |
| 4778 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 4779 | static int |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4780 | qla83xx_idc_lock_recovery(scsi_qla_host_t *base_vha) |
| 4781 | { |
| 4782 | int rval = QLA_SUCCESS; |
| 4783 | uint32_t o_drv_lockid, n_drv_lockid; |
| 4784 | unsigned long lock_recovery_timeout; |
| 4785 | |
| 4786 | lock_recovery_timeout = jiffies + QLA83XX_MAX_LOCK_RECOVERY_WAIT; |
| 4787 | retry_lockid: |
| 4788 | rval = qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCKID, &o_drv_lockid); |
| 4789 | if (rval) |
| 4790 | goto exit; |
| 4791 | |
| 4792 | /* MAX wait time before forcing IDC Lock recovery = 2 secs */ |
| 4793 | if (time_after_eq(jiffies, lock_recovery_timeout)) { |
| 4794 | if (qla83xx_force_lock_recovery(base_vha) == QLA_SUCCESS) |
| 4795 | return QLA_SUCCESS; |
| 4796 | else |
| 4797 | return QLA_FUNCTION_FAILED; |
| 4798 | } |
| 4799 | |
| 4800 | rval = qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCKID, &n_drv_lockid); |
| 4801 | if (rval) |
| 4802 | goto exit; |
| 4803 | |
| 4804 | if (o_drv_lockid == n_drv_lockid) { |
| 4805 | qla83xx_wait_logic(); |
| 4806 | goto retry_lockid; |
| 4807 | } else |
| 4808 | return QLA_SUCCESS; |
| 4809 | |
| 4810 | exit: |
| 4811 | return rval; |
| 4812 | } |
| 4813 | |
| 4814 | void |
| 4815 | qla83xx_idc_lock(scsi_qla_host_t *base_vha, uint16_t requester_id) |
| 4816 | { |
| 4817 | uint16_t options = (requester_id << 15) | BIT_6; |
| 4818 | uint32_t data; |
Saurav Kashyap | 6c31555 | 2013-02-08 01:57:53 -0500 | [diff] [blame] | 4819 | uint32_t lock_owner; |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4820 | struct qla_hw_data *ha = base_vha->hw; |
| 4821 | |
| 4822 | /* IDC-lock implementation using driver-lock/lock-id remote registers */ |
| 4823 | retry_lock: |
| 4824 | if (qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCK, &data) |
| 4825 | == QLA_SUCCESS) { |
| 4826 | if (data) { |
| 4827 | /* Setting lock-id to our function-number */ |
| 4828 | qla83xx_wr_reg(base_vha, QLA83XX_DRIVER_LOCKID, |
| 4829 | ha->portnum); |
| 4830 | } else { |
Saurav Kashyap | 6c31555 | 2013-02-08 01:57:53 -0500 | [diff] [blame] | 4831 | qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCKID, |
| 4832 | &lock_owner); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4833 | ql_dbg(ql_dbg_p3p, base_vha, 0xb063, |
Saurav Kashyap | 6c31555 | 2013-02-08 01:57:53 -0500 | [diff] [blame] | 4834 | "Failed to acquire IDC lock, acquired by %d, " |
| 4835 | "retrying...\n", lock_owner); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4836 | |
| 4837 | /* Retry/Perform IDC-Lock recovery */ |
| 4838 | if (qla83xx_idc_lock_recovery(base_vha) |
| 4839 | == QLA_SUCCESS) { |
| 4840 | qla83xx_wait_logic(); |
| 4841 | goto retry_lock; |
| 4842 | } else |
| 4843 | ql_log(ql_log_warn, base_vha, 0xb075, |
| 4844 | "IDC Lock recovery FAILED.\n"); |
| 4845 | } |
| 4846 | |
| 4847 | } |
| 4848 | |
| 4849 | return; |
| 4850 | |
| 4851 | /* XXX: IDC-lock implementation using access-control mbx */ |
| 4852 | retry_lock2: |
| 4853 | if (qla83xx_access_control(base_vha, options, 0, 0, NULL)) { |
| 4854 | ql_dbg(ql_dbg_p3p, base_vha, 0xb072, |
| 4855 | "Failed to acquire IDC lock. retrying...\n"); |
| 4856 | /* Retry/Perform IDC-Lock recovery */ |
| 4857 | if (qla83xx_idc_lock_recovery(base_vha) == QLA_SUCCESS) { |
| 4858 | qla83xx_wait_logic(); |
| 4859 | goto retry_lock2; |
| 4860 | } else |
| 4861 | ql_log(ql_log_warn, base_vha, 0xb076, |
| 4862 | "IDC Lock recovery FAILED.\n"); |
| 4863 | } |
| 4864 | |
| 4865 | return; |
| 4866 | } |
| 4867 | |
| 4868 | void |
| 4869 | qla83xx_idc_unlock(scsi_qla_host_t *base_vha, uint16_t requester_id) |
| 4870 | { |
Bart Van Assche | 5897cb2 | 2015-06-04 15:57:20 -0700 | [diff] [blame] | 4871 | #if 0 |
| 4872 | uint16_t options = (requester_id << 15) | BIT_7; |
| 4873 | #endif |
| 4874 | uint16_t retry; |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4875 | uint32_t data; |
| 4876 | struct qla_hw_data *ha = base_vha->hw; |
| 4877 | |
| 4878 | /* IDC-unlock implementation using driver-unlock/lock-id |
| 4879 | * remote registers |
| 4880 | */ |
| 4881 | retry = 0; |
| 4882 | retry_unlock: |
| 4883 | if (qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCKID, &data) |
| 4884 | == QLA_SUCCESS) { |
| 4885 | if (data == ha->portnum) { |
| 4886 | qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_UNLOCK, &data); |
| 4887 | /* Clearing lock-id by setting 0xff */ |
| 4888 | qla83xx_wr_reg(base_vha, QLA83XX_DRIVER_LOCKID, 0xff); |
| 4889 | } else if (retry < 10) { |
| 4890 | /* SV: XXX: IDC unlock retrying needed here? */ |
| 4891 | |
| 4892 | /* Retry for IDC-unlock */ |
| 4893 | qla83xx_wait_logic(); |
| 4894 | retry++; |
| 4895 | ql_dbg(ql_dbg_p3p, base_vha, 0xb064, |
Colin Ian King | ee6a877 | 2016-08-28 12:24:48 +0100 | [diff] [blame] | 4896 | "Failed to release IDC lock, retrying=%d\n", retry); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4897 | goto retry_unlock; |
| 4898 | } |
| 4899 | } else if (retry < 10) { |
| 4900 | /* Retry for IDC-unlock */ |
| 4901 | qla83xx_wait_logic(); |
| 4902 | retry++; |
| 4903 | ql_dbg(ql_dbg_p3p, base_vha, 0xb065, |
Colin Ian King | ee6a877 | 2016-08-28 12:24:48 +0100 | [diff] [blame] | 4904 | "Failed to read drv-lockid, retrying=%d\n", retry); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4905 | goto retry_unlock; |
| 4906 | } |
| 4907 | |
| 4908 | return; |
| 4909 | |
Bart Van Assche | 5897cb2 | 2015-06-04 15:57:20 -0700 | [diff] [blame] | 4910 | #if 0 |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4911 | /* XXX: IDC-unlock implementation using access-control mbx */ |
| 4912 | retry = 0; |
| 4913 | retry_unlock2: |
| 4914 | if (qla83xx_access_control(base_vha, options, 0, 0, NULL)) { |
| 4915 | if (retry < 10) { |
| 4916 | /* Retry for IDC-unlock */ |
| 4917 | qla83xx_wait_logic(); |
| 4918 | retry++; |
| 4919 | ql_dbg(ql_dbg_p3p, base_vha, 0xb066, |
Colin Ian King | ee6a877 | 2016-08-28 12:24:48 +0100 | [diff] [blame] | 4920 | "Failed to release IDC lock, retrying=%d\n", retry); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4921 | goto retry_unlock2; |
| 4922 | } |
| 4923 | } |
| 4924 | |
| 4925 | return; |
Bart Van Assche | 5897cb2 | 2015-06-04 15:57:20 -0700 | [diff] [blame] | 4926 | #endif |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4927 | } |
| 4928 | |
| 4929 | int |
| 4930 | __qla83xx_set_drv_presence(scsi_qla_host_t *vha) |
| 4931 | { |
| 4932 | int rval = QLA_SUCCESS; |
| 4933 | struct qla_hw_data *ha = vha->hw; |
| 4934 | uint32_t drv_presence; |
| 4935 | |
| 4936 | rval = qla83xx_rd_reg(vha, QLA83XX_IDC_DRV_PRESENCE, &drv_presence); |
| 4937 | if (rval == QLA_SUCCESS) { |
| 4938 | drv_presence |= (1 << ha->portnum); |
| 4939 | rval = qla83xx_wr_reg(vha, QLA83XX_IDC_DRV_PRESENCE, |
| 4940 | drv_presence); |
| 4941 | } |
| 4942 | |
| 4943 | return rval; |
| 4944 | } |
| 4945 | |
| 4946 | int |
| 4947 | qla83xx_set_drv_presence(scsi_qla_host_t *vha) |
| 4948 | { |
| 4949 | int rval = QLA_SUCCESS; |
| 4950 | |
| 4951 | qla83xx_idc_lock(vha, 0); |
| 4952 | rval = __qla83xx_set_drv_presence(vha); |
| 4953 | qla83xx_idc_unlock(vha, 0); |
| 4954 | |
| 4955 | return rval; |
| 4956 | } |
| 4957 | |
| 4958 | int |
| 4959 | __qla83xx_clear_drv_presence(scsi_qla_host_t *vha) |
| 4960 | { |
| 4961 | int rval = QLA_SUCCESS; |
| 4962 | struct qla_hw_data *ha = vha->hw; |
| 4963 | uint32_t drv_presence; |
| 4964 | |
| 4965 | rval = qla83xx_rd_reg(vha, QLA83XX_IDC_DRV_PRESENCE, &drv_presence); |
| 4966 | if (rval == QLA_SUCCESS) { |
| 4967 | drv_presence &= ~(1 << ha->portnum); |
| 4968 | rval = qla83xx_wr_reg(vha, QLA83XX_IDC_DRV_PRESENCE, |
| 4969 | drv_presence); |
| 4970 | } |
| 4971 | |
| 4972 | return rval; |
| 4973 | } |
| 4974 | |
| 4975 | int |
| 4976 | qla83xx_clear_drv_presence(scsi_qla_host_t *vha) |
| 4977 | { |
| 4978 | int rval = QLA_SUCCESS; |
| 4979 | |
| 4980 | qla83xx_idc_lock(vha, 0); |
| 4981 | rval = __qla83xx_clear_drv_presence(vha); |
| 4982 | qla83xx_idc_unlock(vha, 0); |
| 4983 | |
| 4984 | return rval; |
| 4985 | } |
| 4986 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 4987 | static void |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4988 | qla83xx_need_reset_handler(scsi_qla_host_t *vha) |
| 4989 | { |
| 4990 | struct qla_hw_data *ha = vha->hw; |
| 4991 | uint32_t drv_ack, drv_presence; |
| 4992 | unsigned long ack_timeout; |
| 4993 | |
| 4994 | /* Wait for IDC ACK from all functions (DRV-ACK == DRV-PRESENCE) */ |
| 4995 | ack_timeout = jiffies + (ha->fcoe_reset_timeout * HZ); |
| 4996 | while (1) { |
| 4997 | qla83xx_rd_reg(vha, QLA83XX_IDC_DRIVER_ACK, &drv_ack); |
| 4998 | qla83xx_rd_reg(vha, QLA83XX_IDC_DRV_PRESENCE, &drv_presence); |
Saurav Kashyap | 807fb6d | 2012-11-21 02:40:36 -0500 | [diff] [blame] | 4999 | if ((drv_ack & drv_presence) == drv_presence) |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5000 | break; |
| 5001 | |
| 5002 | if (time_after_eq(jiffies, ack_timeout)) { |
| 5003 | ql_log(ql_log_warn, vha, 0xb067, |
| 5004 | "RESET ACK TIMEOUT! drv_presence=0x%x " |
| 5005 | "drv_ack=0x%x\n", drv_presence, drv_ack); |
| 5006 | /* |
| 5007 | * The function(s) which did not ack in time are forced |
| 5008 | * to withdraw any further participation in the IDC |
| 5009 | * reset. |
| 5010 | */ |
| 5011 | if (drv_ack != drv_presence) |
| 5012 | qla83xx_wr_reg(vha, QLA83XX_IDC_DRV_PRESENCE, |
| 5013 | drv_ack); |
| 5014 | break; |
| 5015 | } |
| 5016 | |
| 5017 | qla83xx_idc_unlock(vha, 0); |
| 5018 | msleep(1000); |
| 5019 | qla83xx_idc_lock(vha, 0); |
| 5020 | } |
| 5021 | |
| 5022 | qla83xx_wr_reg(vha, QLA83XX_IDC_DEV_STATE, QLA8XXX_DEV_COLD); |
| 5023 | ql_log(ql_log_info, vha, 0xb068, "HW State: COLD/RE-INIT.\n"); |
| 5024 | } |
| 5025 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 5026 | static int |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5027 | qla83xx_device_bootstrap(scsi_qla_host_t *vha) |
| 5028 | { |
| 5029 | int rval = QLA_SUCCESS; |
| 5030 | uint32_t idc_control; |
| 5031 | |
| 5032 | qla83xx_wr_reg(vha, QLA83XX_IDC_DEV_STATE, QLA8XXX_DEV_INITIALIZING); |
| 5033 | ql_log(ql_log_info, vha, 0xb069, "HW State: INITIALIZING.\n"); |
| 5034 | |
| 5035 | /* Clearing IDC-Control Graceful-Reset Bit before resetting f/w */ |
| 5036 | __qla83xx_get_idc_control(vha, &idc_control); |
| 5037 | idc_control &= ~QLA83XX_IDC_GRACEFUL_RESET; |
| 5038 | __qla83xx_set_idc_control(vha, 0); |
| 5039 | |
| 5040 | qla83xx_idc_unlock(vha, 0); |
| 5041 | rval = qla83xx_restart_nic_firmware(vha); |
| 5042 | qla83xx_idc_lock(vha, 0); |
| 5043 | |
| 5044 | if (rval != QLA_SUCCESS) { |
| 5045 | ql_log(ql_log_fatal, vha, 0xb06a, |
| 5046 | "Failed to restart NIC f/w.\n"); |
| 5047 | qla83xx_wr_reg(vha, QLA83XX_IDC_DEV_STATE, QLA8XXX_DEV_FAILED); |
| 5048 | ql_log(ql_log_info, vha, 0xb06b, "HW State: FAILED.\n"); |
| 5049 | } else { |
| 5050 | ql_dbg(ql_dbg_p3p, vha, 0xb06c, |
| 5051 | "Success in restarting nic f/w.\n"); |
| 5052 | qla83xx_wr_reg(vha, QLA83XX_IDC_DEV_STATE, QLA8XXX_DEV_READY); |
| 5053 | ql_log(ql_log_info, vha, 0xb06d, "HW State: READY.\n"); |
| 5054 | } |
| 5055 | |
| 5056 | return rval; |
| 5057 | } |
| 5058 | |
| 5059 | /* Assumes idc_lock always held on entry */ |
| 5060 | int |
| 5061 | qla83xx_idc_state_handler(scsi_qla_host_t *base_vha) |
| 5062 | { |
| 5063 | struct qla_hw_data *ha = base_vha->hw; |
| 5064 | int rval = QLA_SUCCESS; |
| 5065 | unsigned long dev_init_timeout; |
| 5066 | uint32_t dev_state; |
| 5067 | |
| 5068 | /* Wait for MAX-INIT-TIMEOUT for the device to go ready */ |
| 5069 | dev_init_timeout = jiffies + (ha->fcoe_dev_init_timeout * HZ); |
| 5070 | |
| 5071 | while (1) { |
| 5072 | |
| 5073 | if (time_after_eq(jiffies, dev_init_timeout)) { |
| 5074 | ql_log(ql_log_warn, base_vha, 0xb06e, |
| 5075 | "Initialization TIMEOUT!\n"); |
| 5076 | /* Init timeout. Disable further NIC Core |
| 5077 | * communication. |
| 5078 | */ |
| 5079 | qla83xx_wr_reg(base_vha, QLA83XX_IDC_DEV_STATE, |
| 5080 | QLA8XXX_DEV_FAILED); |
| 5081 | ql_log(ql_log_info, base_vha, 0xb06f, |
| 5082 | "HW State: FAILED.\n"); |
| 5083 | } |
| 5084 | |
| 5085 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, &dev_state); |
| 5086 | switch (dev_state) { |
| 5087 | case QLA8XXX_DEV_READY: |
| 5088 | if (ha->flags.nic_core_reset_owner) |
| 5089 | qla83xx_idc_audit(base_vha, |
| 5090 | IDC_AUDIT_COMPLETION); |
| 5091 | ha->flags.nic_core_reset_owner = 0; |
| 5092 | ql_dbg(ql_dbg_p3p, base_vha, 0xb070, |
| 5093 | "Reset_owner reset by 0x%x.\n", |
| 5094 | ha->portnum); |
| 5095 | goto exit; |
| 5096 | case QLA8XXX_DEV_COLD: |
| 5097 | if (ha->flags.nic_core_reset_owner) |
| 5098 | rval = qla83xx_device_bootstrap(base_vha); |
| 5099 | else { |
| 5100 | /* Wait for AEN to change device-state */ |
| 5101 | qla83xx_idc_unlock(base_vha, 0); |
| 5102 | msleep(1000); |
| 5103 | qla83xx_idc_lock(base_vha, 0); |
| 5104 | } |
| 5105 | break; |
| 5106 | case QLA8XXX_DEV_INITIALIZING: |
| 5107 | /* Wait for AEN to change device-state */ |
| 5108 | qla83xx_idc_unlock(base_vha, 0); |
| 5109 | msleep(1000); |
| 5110 | qla83xx_idc_lock(base_vha, 0); |
| 5111 | break; |
| 5112 | case QLA8XXX_DEV_NEED_RESET: |
| 5113 | if (!ql2xdontresethba && ha->flags.nic_core_reset_owner) |
| 5114 | qla83xx_need_reset_handler(base_vha); |
| 5115 | else { |
| 5116 | /* Wait for AEN to change device-state */ |
| 5117 | qla83xx_idc_unlock(base_vha, 0); |
| 5118 | msleep(1000); |
| 5119 | qla83xx_idc_lock(base_vha, 0); |
| 5120 | } |
| 5121 | /* reset timeout value after need reset handler */ |
| 5122 | dev_init_timeout = jiffies + |
| 5123 | (ha->fcoe_dev_init_timeout * HZ); |
| 5124 | break; |
| 5125 | case QLA8XXX_DEV_NEED_QUIESCENT: |
| 5126 | /* XXX: DEBUG for now */ |
| 5127 | qla83xx_idc_unlock(base_vha, 0); |
| 5128 | msleep(1000); |
| 5129 | qla83xx_idc_lock(base_vha, 0); |
| 5130 | break; |
| 5131 | case QLA8XXX_DEV_QUIESCENT: |
| 5132 | /* XXX: DEBUG for now */ |
| 5133 | if (ha->flags.quiesce_owner) |
| 5134 | goto exit; |
| 5135 | |
| 5136 | qla83xx_idc_unlock(base_vha, 0); |
| 5137 | msleep(1000); |
| 5138 | qla83xx_idc_lock(base_vha, 0); |
| 5139 | dev_init_timeout = jiffies + |
| 5140 | (ha->fcoe_dev_init_timeout * HZ); |
| 5141 | break; |
| 5142 | case QLA8XXX_DEV_FAILED: |
| 5143 | if (ha->flags.nic_core_reset_owner) |
| 5144 | qla83xx_idc_audit(base_vha, |
| 5145 | IDC_AUDIT_COMPLETION); |
| 5146 | ha->flags.nic_core_reset_owner = 0; |
| 5147 | __qla83xx_clear_drv_presence(base_vha); |
| 5148 | qla83xx_idc_unlock(base_vha, 0); |
| 5149 | qla8xxx_dev_failed_handler(base_vha); |
| 5150 | rval = QLA_FUNCTION_FAILED; |
| 5151 | qla83xx_idc_lock(base_vha, 0); |
| 5152 | goto exit; |
| 5153 | case QLA8XXX_BAD_VALUE: |
| 5154 | qla83xx_idc_unlock(base_vha, 0); |
| 5155 | msleep(1000); |
| 5156 | qla83xx_idc_lock(base_vha, 0); |
| 5157 | break; |
| 5158 | default: |
| 5159 | ql_log(ql_log_warn, base_vha, 0xb071, |
Masanari Iida | d939be3 | 2015-02-27 23:52:31 +0900 | [diff] [blame] | 5160 | "Unknown Device State: %x.\n", dev_state); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5161 | qla83xx_idc_unlock(base_vha, 0); |
| 5162 | qla8xxx_dev_failed_handler(base_vha); |
| 5163 | rval = QLA_FUNCTION_FAILED; |
| 5164 | qla83xx_idc_lock(base_vha, 0); |
| 5165 | goto exit; |
| 5166 | } |
| 5167 | } |
| 5168 | |
| 5169 | exit: |
| 5170 | return rval; |
| 5171 | } |
| 5172 | |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5173 | void |
| 5174 | qla2x00_disable_board_on_pci_error(struct work_struct *work) |
| 5175 | { |
| 5176 | struct qla_hw_data *ha = container_of(work, struct qla_hw_data, |
| 5177 | board_disable); |
| 5178 | struct pci_dev *pdev = ha->pdev; |
| 5179 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 5180 | |
Sawan Chandak | 783e0dc | 2016-07-06 11:14:25 -0400 | [diff] [blame] | 5181 | /* if UNLOAD flag is already set, then continue unload, |
| 5182 | * where it was set first. |
| 5183 | */ |
| 5184 | if (test_bit(UNLOADING, &base_vha->dpc_flags)) |
| 5185 | return; |
| 5186 | |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5187 | ql_log(ql_log_warn, base_vha, 0x015b, |
| 5188 | "Disabling adapter.\n"); |
| 5189 | |
| 5190 | set_bit(UNLOADING, &base_vha->dpc_flags); |
| 5191 | |
| 5192 | qla2x00_delete_all_vps(ha, base_vha); |
| 5193 | |
| 5194 | qla2x00_abort_all_cmds(base_vha, DID_NO_CONNECT << 16); |
| 5195 | |
| 5196 | qla2x00_dfs_remove(base_vha); |
| 5197 | |
| 5198 | qla84xx_put_chip(base_vha); |
| 5199 | |
| 5200 | if (base_vha->timer_active) |
| 5201 | qla2x00_stop_timer(base_vha); |
| 5202 | |
| 5203 | base_vha->flags.online = 0; |
| 5204 | |
| 5205 | qla2x00_destroy_deferred_work(ha); |
| 5206 | |
| 5207 | /* |
| 5208 | * Do not try to stop beacon blink as it will issue a mailbox |
| 5209 | * command. |
| 5210 | */ |
| 5211 | qla2x00_free_sysfs_attr(base_vha, false); |
| 5212 | |
| 5213 | fc_remove_host(base_vha->host); |
| 5214 | |
| 5215 | scsi_remove_host(base_vha->host); |
| 5216 | |
| 5217 | base_vha->flags.init_done = 0; |
| 5218 | qla25xx_delete_queues(base_vha); |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5219 | qla2x00_free_fcports(base_vha); |
Quinn Tran | 093df73 | 2016-12-12 14:40:09 -0800 | [diff] [blame] | 5220 | qla2x00_free_irqs(base_vha); |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5221 | qla2x00_mem_free(ha); |
| 5222 | qla82xx_md_free(base_vha); |
| 5223 | qla2x00_free_queues(ha); |
| 5224 | |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5225 | qla2x00_unmap_iobases(ha); |
| 5226 | |
| 5227 | pci_release_selected_regions(ha->pdev, ha->bars); |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5228 | pci_disable_pcie_error_reporting(pdev); |
| 5229 | pci_disable_device(pdev); |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5230 | |
Joe Lawrence | beb9e31 | 2014-08-26 17:12:14 -0400 | [diff] [blame] | 5231 | /* |
| 5232 | * Let qla2x00_remove_one cleanup qla_hw_data on device removal. |
| 5233 | */ |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5234 | } |
| 5235 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5236 | /************************************************************************** |
| 5237 | * qla2x00_do_dpc |
| 5238 | * This kernel thread is a task that is schedule by the interrupt handler |
| 5239 | * to perform the background processing for interrupts. |
| 5240 | * |
| 5241 | * Notes: |
| 5242 | * This task always run in the context of a kernel thread. It |
| 5243 | * is kick-off by the driver's detect code and starts up |
| 5244 | * up one per adapter. It immediately goes to sleep and waits for |
| 5245 | * some fibre event. When either the interrupt handler or |
| 5246 | * the timer routine detects a event it will one of the task |
| 5247 | * bits then wake us up. |
| 5248 | **************************************************************************/ |
| 5249 | static int |
| 5250 | qla2x00_do_dpc(void *data) |
| 5251 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5252 | scsi_qla_host_t *base_vha; |
| 5253 | struct qla_hw_data *ha; |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 5254 | uint32_t online; |
| 5255 | struct qla_qpair *qpair; |
Seokmann Ju | 99363ef | 2008-01-31 12:33:51 -0800 | [diff] [blame] | 5256 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5257 | ha = (struct qla_hw_data *)data; |
| 5258 | base_vha = pci_get_drvdata(ha->pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5259 | |
Dongsheng Yang | 8698a74 | 2014-03-11 18:09:12 +0800 | [diff] [blame] | 5260 | set_user_nice(current, MIN_NICE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5261 | |
James Bottomley | 563585e | 2011-01-27 16:12:37 -0500 | [diff] [blame] | 5262 | set_current_state(TASK_INTERRUPTIBLE); |
Christoph Hellwig | 39a1124 | 2006-02-14 18:46:22 +0100 | [diff] [blame] | 5263 | while (!kthread_should_stop()) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5264 | ql_dbg(ql_dbg_dpc, base_vha, 0x4000, |
| 5265 | "DPC handler sleeping.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5266 | |
Christoph Hellwig | 39a1124 | 2006-02-14 18:46:22 +0100 | [diff] [blame] | 5267 | schedule(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5268 | |
Andrew Vasquez | c142caf | 2011-11-18 09:03:10 -0800 | [diff] [blame] | 5269 | if (!base_vha->flags.init_done || ha->flags.mbox_busy) |
| 5270 | goto end_loop; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5271 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5272 | if (ha->flags.eeh_busy) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5273 | ql_dbg(ql_dbg_dpc, base_vha, 0x4003, |
| 5274 | "eeh_busy=%d.\n", ha->flags.eeh_busy); |
Andrew Vasquez | c142caf | 2011-11-18 09:03:10 -0800 | [diff] [blame] | 5275 | goto end_loop; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5276 | } |
| 5277 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5278 | ha->dpc_active = 1; |
| 5279 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5280 | ql_dbg(ql_dbg_dpc + ql_dbg_verbose, base_vha, 0x4001, |
| 5281 | "DPC handler waking up, dpc_flags=0x%lx.\n", |
| 5282 | base_vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5283 | |
Joe Carnuccio | a29b3dd | 2016-07-06 11:14:19 -0400 | [diff] [blame] | 5284 | if (test_bit(UNLOADING, &base_vha->dpc_flags)) |
| 5285 | break; |
| 5286 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5287 | qla2x00_do_work(base_vha); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 5288 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5289 | if (IS_P3P_TYPE(ha)) { |
| 5290 | if (IS_QLA8044(ha)) { |
| 5291 | if (test_and_clear_bit(ISP_UNRECOVERABLE, |
| 5292 | &base_vha->dpc_flags)) { |
| 5293 | qla8044_idc_lock(ha); |
| 5294 | qla8044_wr_direct(base_vha, |
| 5295 | QLA8044_CRB_DEV_STATE_INDEX, |
| 5296 | QLA8XXX_DEV_FAILED); |
| 5297 | qla8044_idc_unlock(ha); |
| 5298 | ql_log(ql_log_info, base_vha, 0x4004, |
| 5299 | "HW State: FAILED.\n"); |
| 5300 | qla8044_device_state_handler(base_vha); |
| 5301 | continue; |
| 5302 | } |
| 5303 | |
| 5304 | } else { |
| 5305 | if (test_and_clear_bit(ISP_UNRECOVERABLE, |
| 5306 | &base_vha->dpc_flags)) { |
| 5307 | qla82xx_idc_lock(ha); |
| 5308 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
| 5309 | QLA8XXX_DEV_FAILED); |
| 5310 | qla82xx_idc_unlock(ha); |
| 5311 | ql_log(ql_log_info, base_vha, 0x0151, |
| 5312 | "HW State: FAILED.\n"); |
| 5313 | qla82xx_device_state_handler(base_vha); |
| 5314 | continue; |
| 5315 | } |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5316 | } |
| 5317 | |
| 5318 | if (test_and_clear_bit(FCOE_CTX_RESET_NEEDED, |
| 5319 | &base_vha->dpc_flags)) { |
| 5320 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5321 | ql_dbg(ql_dbg_dpc, base_vha, 0x4005, |
| 5322 | "FCoE context reset scheduled.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5323 | if (!(test_and_set_bit(ABORT_ISP_ACTIVE, |
| 5324 | &base_vha->dpc_flags))) { |
| 5325 | if (qla82xx_fcoe_ctx_reset(base_vha)) { |
| 5326 | /* FCoE-ctx reset failed. |
| 5327 | * Escalate to chip-reset |
| 5328 | */ |
| 5329 | set_bit(ISP_ABORT_NEEDED, |
| 5330 | &base_vha->dpc_flags); |
| 5331 | } |
| 5332 | clear_bit(ABORT_ISP_ACTIVE, |
| 5333 | &base_vha->dpc_flags); |
| 5334 | } |
| 5335 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5336 | ql_dbg(ql_dbg_dpc, base_vha, 0x4006, |
| 5337 | "FCoE context reset end.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5338 | } |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5339 | } else if (IS_QLAFX00(ha)) { |
| 5340 | if (test_and_clear_bit(ISP_UNRECOVERABLE, |
| 5341 | &base_vha->dpc_flags)) { |
| 5342 | ql_dbg(ql_dbg_dpc, base_vha, 0x4020, |
| 5343 | "Firmware Reset Recovery\n"); |
| 5344 | if (qlafx00_reset_initialize(base_vha)) { |
| 5345 | /* Failed. Abort isp later. */ |
| 5346 | if (!test_bit(UNLOADING, |
Dan Carpenter | f92f82d | 2014-05-05 12:47:57 +0300 | [diff] [blame] | 5347 | &base_vha->dpc_flags)) { |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5348 | set_bit(ISP_UNRECOVERABLE, |
| 5349 | &base_vha->dpc_flags); |
| 5350 | ql_dbg(ql_dbg_dpc, base_vha, |
| 5351 | 0x4021, |
| 5352 | "Reset Recovery Failed\n"); |
Dan Carpenter | f92f82d | 2014-05-05 12:47:57 +0300 | [diff] [blame] | 5353 | } |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5354 | } |
| 5355 | } |
| 5356 | |
| 5357 | if (test_and_clear_bit(FX00_TARGET_SCAN, |
| 5358 | &base_vha->dpc_flags)) { |
| 5359 | ql_dbg(ql_dbg_dpc, base_vha, 0x4022, |
| 5360 | "ISPFx00 Target Scan scheduled\n"); |
| 5361 | if (qlafx00_rescan_isp(base_vha)) { |
| 5362 | if (!test_bit(UNLOADING, |
| 5363 | &base_vha->dpc_flags)) |
| 5364 | set_bit(ISP_UNRECOVERABLE, |
| 5365 | &base_vha->dpc_flags); |
| 5366 | ql_dbg(ql_dbg_dpc, base_vha, 0x401e, |
| 5367 | "ISPFx00 Target Scan Failed\n"); |
| 5368 | } |
| 5369 | ql_dbg(ql_dbg_dpc, base_vha, 0x401f, |
| 5370 | "ISPFx00 Target Scan End\n"); |
| 5371 | } |
Armen Baloyan | e8f5e95 | 2013-10-30 03:38:17 -0400 | [diff] [blame] | 5372 | if (test_and_clear_bit(FX00_HOST_INFO_RESEND, |
| 5373 | &base_vha->dpc_flags)) { |
| 5374 | ql_dbg(ql_dbg_dpc, base_vha, 0x4023, |
| 5375 | "ISPFx00 Host Info resend scheduled\n"); |
| 5376 | qlafx00_fx_disc(base_vha, |
| 5377 | &base_vha->hw->mr.fcport, |
| 5378 | FXDISC_REG_HOST_INFO); |
| 5379 | } |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5380 | } |
| 5381 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5382 | if (test_and_clear_bit(ISP_ABORT_NEEDED, |
| 5383 | &base_vha->dpc_flags)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5384 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5385 | ql_dbg(ql_dbg_dpc, base_vha, 0x4007, |
| 5386 | "ISP abort scheduled.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5387 | if (!(test_and_set_bit(ABORT_ISP_ACTIVE, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5388 | &base_vha->dpc_flags))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5389 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5390 | if (ha->isp_ops->abort_isp(base_vha)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5391 | /* failed. retry later */ |
| 5392 | set_bit(ISP_ABORT_NEEDED, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5393 | &base_vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5394 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5395 | clear_bit(ABORT_ISP_ACTIVE, |
| 5396 | &base_vha->dpc_flags); |
Seokmann Ju | 99363ef | 2008-01-31 12:33:51 -0800 | [diff] [blame] | 5397 | } |
| 5398 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5399 | ql_dbg(ql_dbg_dpc, base_vha, 0x4008, |
| 5400 | "ISP abort end.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5401 | } |
| 5402 | |
David Jeffery | a394aac | 2012-11-21 02:39:54 -0500 | [diff] [blame] | 5403 | if (test_and_clear_bit(FCPORT_UPDATE_NEEDED, |
| 5404 | &base_vha->dpc_flags)) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5405 | qla2x00_update_fcports(base_vha); |
Andrew Vasquez | c9c5ced | 2008-07-24 08:31:49 -0700 | [diff] [blame] | 5406 | } |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 5407 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 5408 | if (test_bit(SCR_PENDING, &base_vha->dpc_flags)) { |
| 5409 | int ret; |
| 5410 | ret = qla2x00_send_change_request(base_vha, 0x3, 0); |
| 5411 | if (ret != QLA_SUCCESS) |
| 5412 | ql_log(ql_log_warn, base_vha, 0x121, |
| 5413 | "Failed to enable receiving of RSCN " |
| 5414 | "requests: 0x%x.\n", ret); |
| 5415 | clear_bit(SCR_PENDING, &base_vha->dpc_flags); |
| 5416 | } |
| 5417 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5418 | if (IS_QLAFX00(ha)) |
| 5419 | goto loop_resync_check; |
| 5420 | |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 5421 | if (test_bit(ISP_QUIESCE_NEEDED, &base_vha->dpc_flags)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5422 | ql_dbg(ql_dbg_dpc, base_vha, 0x4009, |
| 5423 | "Quiescence mode scheduled.\n"); |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5424 | if (IS_P3P_TYPE(ha)) { |
| 5425 | if (IS_QLA82XX(ha)) |
| 5426 | qla82xx_device_state_handler(base_vha); |
| 5427 | if (IS_QLA8044(ha)) |
| 5428 | qla8044_device_state_handler(base_vha); |
Chad Dupuis | 8fcd6b8 | 2012-08-22 14:21:06 -0400 | [diff] [blame] | 5429 | clear_bit(ISP_QUIESCE_NEEDED, |
| 5430 | &base_vha->dpc_flags); |
| 5431 | if (!ha->flags.quiesce_owner) { |
| 5432 | qla2x00_perform_loop_resync(base_vha); |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5433 | if (IS_QLA82XX(ha)) { |
| 5434 | qla82xx_idc_lock(ha); |
| 5435 | qla82xx_clear_qsnt_ready( |
| 5436 | base_vha); |
| 5437 | qla82xx_idc_unlock(ha); |
| 5438 | } else if (IS_QLA8044(ha)) { |
| 5439 | qla8044_idc_lock(ha); |
| 5440 | qla8044_clear_qsnt_ready( |
| 5441 | base_vha); |
| 5442 | qla8044_idc_unlock(ha); |
| 5443 | } |
Chad Dupuis | 8fcd6b8 | 2012-08-22 14:21:06 -0400 | [diff] [blame] | 5444 | } |
| 5445 | } else { |
| 5446 | clear_bit(ISP_QUIESCE_NEEDED, |
| 5447 | &base_vha->dpc_flags); |
| 5448 | qla2x00_quiesce_io(base_vha); |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 5449 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5450 | ql_dbg(ql_dbg_dpc, base_vha, 0x400a, |
| 5451 | "Quiescence mode end.\n"); |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 5452 | } |
| 5453 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5454 | if (test_and_clear_bit(RESET_MARKER_NEEDED, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5455 | &base_vha->dpc_flags) && |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5456 | (!(test_and_set_bit(RESET_ACTIVE, &base_vha->dpc_flags)))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5457 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5458 | ql_dbg(ql_dbg_dpc, base_vha, 0x400b, |
| 5459 | "Reset marker scheduled.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5460 | qla2x00_rst_aen(base_vha); |
| 5461 | clear_bit(RESET_ACTIVE, &base_vha->dpc_flags); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5462 | ql_dbg(ql_dbg_dpc, base_vha, 0x400c, |
| 5463 | "Reset marker end.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5464 | } |
| 5465 | |
| 5466 | /* Retry each device up to login retry count */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5467 | if ((test_and_clear_bit(RELOGIN_NEEDED, |
| 5468 | &base_vha->dpc_flags)) && |
| 5469 | !test_bit(LOOP_RESYNC_NEEDED, &base_vha->dpc_flags) && |
| 5470 | atomic_read(&base_vha->loop_state) != LOOP_DOWN) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5471 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5472 | ql_dbg(ql_dbg_dpc, base_vha, 0x400d, |
| 5473 | "Relogin scheduled.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5474 | qla2x00_relogin(base_vha); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5475 | ql_dbg(ql_dbg_dpc, base_vha, 0x400e, |
| 5476 | "Relogin end.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5477 | } |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5478 | loop_resync_check: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5479 | if (test_and_clear_bit(LOOP_RESYNC_NEEDED, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5480 | &base_vha->dpc_flags)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5481 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5482 | ql_dbg(ql_dbg_dpc, base_vha, 0x400f, |
| 5483 | "Loop resync scheduled.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5484 | |
| 5485 | if (!(test_and_set_bit(LOOP_RESYNC_ACTIVE, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5486 | &base_vha->dpc_flags))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5487 | |
Bart Van Assche | 52c8282 | 2015-07-09 07:23:26 -0700 | [diff] [blame] | 5488 | qla2x00_loop_resync(base_vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5489 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5490 | clear_bit(LOOP_RESYNC_ACTIVE, |
| 5491 | &base_vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5492 | } |
| 5493 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5494 | ql_dbg(ql_dbg_dpc, base_vha, 0x4010, |
| 5495 | "Loop resync end.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5496 | } |
| 5497 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5498 | if (IS_QLAFX00(ha)) |
| 5499 | goto intr_on_check; |
| 5500 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5501 | if (test_bit(NPIV_CONFIG_NEEDED, &base_vha->dpc_flags) && |
| 5502 | atomic_read(&base_vha->loop_state) == LOOP_READY) { |
| 5503 | clear_bit(NPIV_CONFIG_NEEDED, &base_vha->dpc_flags); |
| 5504 | qla2xxx_flash_npiv_conf(base_vha); |
Andrew Vasquez | 272976c | 2008-09-11 21:22:50 -0700 | [diff] [blame] | 5505 | } |
| 5506 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5507 | intr_on_check: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5508 | if (!ha->interrupts_on) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 5509 | ha->isp_ops->enable_intrs(ha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5510 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5511 | if (test_and_clear_bit(BEACON_BLINK_NEEDED, |
Himanshu Madani | 90b604f | 2014-04-11 16:54:40 -0400 | [diff] [blame] | 5512 | &base_vha->dpc_flags)) { |
| 5513 | if (ha->beacon_blink_led == 1) |
| 5514 | ha->isp_ops->beacon_blink(base_vha); |
| 5515 | } |
andrew.vasquez@qlogic.com | f6df144 | 2006-01-31 16:05:07 -0800 | [diff] [blame] | 5516 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 5517 | /* qpair online check */ |
| 5518 | if (test_and_clear_bit(QPAIR_ONLINE_CHECK_NEEDED, |
| 5519 | &base_vha->dpc_flags)) { |
| 5520 | if (ha->flags.eeh_busy || |
| 5521 | ha->flags.pci_channel_io_perm_failure) |
| 5522 | online = 0; |
| 5523 | else |
| 5524 | online = 1; |
| 5525 | |
| 5526 | mutex_lock(&ha->mq_lock); |
| 5527 | list_for_each_entry(qpair, &base_vha->qp_list, |
| 5528 | qp_list_elem) |
| 5529 | qpair->online = online; |
| 5530 | mutex_unlock(&ha->mq_lock); |
| 5531 | } |
| 5532 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5533 | if (!IS_QLAFX00(ha)) |
| 5534 | qla2x00_do_dpc_all_vps(base_vha); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5535 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5536 | ha->dpc_active = 0; |
Andrew Vasquez | c142caf | 2011-11-18 09:03:10 -0800 | [diff] [blame] | 5537 | end_loop: |
James Bottomley | 563585e | 2011-01-27 16:12:37 -0500 | [diff] [blame] | 5538 | set_current_state(TASK_INTERRUPTIBLE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5539 | } /* End of while(1) */ |
James Bottomley | 563585e | 2011-01-27 16:12:37 -0500 | [diff] [blame] | 5540 | __set_current_state(TASK_RUNNING); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5541 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5542 | ql_dbg(ql_dbg_dpc, base_vha, 0x4011, |
| 5543 | "DPC handler exiting.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5544 | |
| 5545 | /* |
| 5546 | * Make sure that nobody tries to wake us up again. |
| 5547 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5548 | ha->dpc_active = 0; |
| 5549 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 5550 | /* Cleanup any residual CTX SRBs. */ |
| 5551 | qla2x00_abort_all_cmds(base_vha, DID_NO_CONNECT << 16); |
| 5552 | |
Christoph Hellwig | 39a1124 | 2006-02-14 18:46:22 +0100 | [diff] [blame] | 5553 | return 0; |
| 5554 | } |
| 5555 | |
| 5556 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5557 | qla2xxx_wake_dpc(struct scsi_qla_host *vha) |
Christoph Hellwig | 39a1124 | 2006-02-14 18:46:22 +0100 | [diff] [blame] | 5558 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5559 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | c795c1e | 2008-08-13 21:37:01 -0700 | [diff] [blame] | 5560 | struct task_struct *t = ha->dpc_thread; |
| 5561 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5562 | if (!test_bit(UNLOADING, &vha->dpc_flags) && t) |
Andrew Vasquez | c795c1e | 2008-08-13 21:37:01 -0700 | [diff] [blame] | 5563 | wake_up_process(t); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5564 | } |
| 5565 | |
| 5566 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5567 | * qla2x00_rst_aen |
| 5568 | * Processes asynchronous reset. |
| 5569 | * |
| 5570 | * Input: |
| 5571 | * ha = adapter block pointer. |
| 5572 | */ |
| 5573 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5574 | qla2x00_rst_aen(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5575 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5576 | if (vha->flags.online && !vha->flags.reset_active && |
| 5577 | !atomic_read(&vha->loop_down_timer) && |
| 5578 | !(test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5579 | do { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5580 | clear_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5581 | |
| 5582 | /* |
| 5583 | * Issue marker command only when we are going to start |
| 5584 | * the I/O. |
| 5585 | */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5586 | vha->marker_needed = 1; |
| 5587 | } while (!atomic_read(&vha->loop_down_timer) && |
| 5588 | (test_bit(RESET_MARKER_NEEDED, &vha->dpc_flags))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5589 | } |
| 5590 | } |
| 5591 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5592 | /************************************************************************** |
| 5593 | * qla2x00_timer |
| 5594 | * |
| 5595 | * Description: |
| 5596 | * One second timer |
| 5597 | * |
| 5598 | * Context: Interrupt |
| 5599 | ***************************************************************************/ |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5600 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5601 | qla2x00_timer(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5602 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5603 | unsigned long cpu_flags = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5604 | int start_dpc = 0; |
| 5605 | int index; |
| 5606 | srb_t *sp; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5607 | uint16_t w; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5608 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 5609 | struct req_que *req; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5610 | |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5611 | if (ha->flags.eeh_busy) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5612 | ql_dbg(ql_dbg_timer, vha, 0x6000, |
| 5613 | "EEH = %d, restarting timer.\n", |
| 5614 | ha->flags.eeh_busy); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5615 | qla2x00_restart_timer(vha, WATCH_INTERVAL); |
| 5616 | return; |
| 5617 | } |
| 5618 | |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5619 | /* |
| 5620 | * Hardware read to raise pending EEH errors during mailbox waits. If |
| 5621 | * the read returns -1 then disable the board. |
| 5622 | */ |
| 5623 | if (!pci_channel_offline(ha->pdev)) { |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5624 | pci_read_config_word(ha->pdev, PCI_VENDOR_ID, &w); |
Joe Lawrence | c821e0d | 2014-08-26 17:11:41 -0400 | [diff] [blame] | 5625 | qla2x00_check_reg16_for_disconnect(vha, w); |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5626 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5627 | |
Saurav Kashyap | cefcaba | 2011-05-10 11:18:18 -0700 | [diff] [blame] | 5628 | /* Make sure qla82xx_watchdog is run only for physical port */ |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5629 | if (!vha->vp_idx && IS_P3P_TYPE(ha)) { |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 5630 | if (test_bit(ISP_QUIESCE_NEEDED, &vha->dpc_flags)) |
| 5631 | start_dpc++; |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5632 | if (IS_QLA82XX(ha)) |
| 5633 | qla82xx_watchdog(vha); |
| 5634 | else if (IS_QLA8044(ha)) |
| 5635 | qla8044_watchdog(vha); |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 5636 | } |
| 5637 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5638 | if (!vha->vp_idx && IS_QLAFX00(ha)) |
| 5639 | qlafx00_timer_routine(vha); |
| 5640 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5641 | /* Loop down handler. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5642 | if (atomic_read(&vha->loop_down_timer) > 0 && |
Giridhar Malavali | 8f7daea | 2011-03-30 11:46:26 -0700 | [diff] [blame] | 5643 | !(test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags)) && |
| 5644 | !(test_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags)) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5645 | && vha->flags.online) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5646 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5647 | if (atomic_read(&vha->loop_down_timer) == |
| 5648 | vha->loop_down_abort_time) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5649 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5650 | ql_log(ql_log_info, vha, 0x6008, |
| 5651 | "Loop down - aborting the queues before time expires.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5652 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5653 | if (!IS_QLA2100(ha) && vha->link_down_timeout) |
| 5654 | atomic_set(&vha->loop_state, LOOP_DEAD); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5655 | |
Andrew Vasquez | f08b725 | 2010-01-12 12:59:48 -0800 | [diff] [blame] | 5656 | /* |
| 5657 | * Schedule an ISP abort to return any FCP2-device |
| 5658 | * commands. |
| 5659 | */ |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5660 | /* NPIV - scan physical port only */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5661 | if (!vha->vp_idx) { |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5662 | spin_lock_irqsave(&ha->hardware_lock, |
| 5663 | cpu_flags); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 5664 | req = ha->req_q_map[0]; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5665 | for (index = 1; |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 5666 | index < req->num_outstanding_cmds; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5667 | index++) { |
| 5668 | fc_port_t *sfcp; |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 5669 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5670 | sp = req->outstanding_cmds[index]; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5671 | if (!sp) |
| 5672 | continue; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 5673 | if (sp->type != SRB_SCSI_CMD) |
Andrew Vasquez | cf53b06 | 2009-08-20 11:06:04 -0700 | [diff] [blame] | 5674 | continue; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5675 | sfcp = sp->fcport; |
Andrew Vasquez | f08b725 | 2010-01-12 12:59:48 -0800 | [diff] [blame] | 5676 | if (!(sfcp->flags & FCF_FCP2_DEVICE)) |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5677 | continue; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5678 | |
Giridhar Malavali | 8f7daea | 2011-03-30 11:46:26 -0700 | [diff] [blame] | 5679 | if (IS_QLA82XX(ha)) |
| 5680 | set_bit(FCOE_CTX_RESET_NEEDED, |
| 5681 | &vha->dpc_flags); |
| 5682 | else |
| 5683 | set_bit(ISP_ABORT_NEEDED, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5684 | &vha->dpc_flags); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5685 | break; |
| 5686 | } |
| 5687 | spin_unlock_irqrestore(&ha->hardware_lock, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5688 | cpu_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5689 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5690 | start_dpc++; |
| 5691 | } |
| 5692 | |
| 5693 | /* if the loop has been down for 4 minutes, reinit adapter */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5694 | if (atomic_dec_and_test(&vha->loop_down_timer) != 0) { |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 5695 | if (!(vha->device_flags & DFLG_NO_CABLE)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5696 | ql_log(ql_log_warn, vha, 0x6009, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5697 | "Loop down - aborting ISP.\n"); |
| 5698 | |
Giridhar Malavali | 8f7daea | 2011-03-30 11:46:26 -0700 | [diff] [blame] | 5699 | if (IS_QLA82XX(ha)) |
| 5700 | set_bit(FCOE_CTX_RESET_NEEDED, |
| 5701 | &vha->dpc_flags); |
| 5702 | else |
| 5703 | set_bit(ISP_ABORT_NEEDED, |
| 5704 | &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5705 | } |
| 5706 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5707 | ql_dbg(ql_dbg_timer, vha, 0x600a, |
| 5708 | "Loop down - seconds remaining %d.\n", |
| 5709 | atomic_read(&vha->loop_down_timer)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5710 | } |
Saurav Kashyap | cefcaba | 2011-05-10 11:18:18 -0700 | [diff] [blame] | 5711 | /* Check if beacon LED needs to be blinked for physical host only */ |
| 5712 | if (!vha->vp_idx && (ha->beacon_blink_led == 1)) { |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 5713 | /* There is no beacon_blink function for ISP82xx */ |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5714 | if (!IS_P3P_TYPE(ha)) { |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 5715 | set_bit(BEACON_BLINK_NEEDED, &vha->dpc_flags); |
| 5716 | start_dpc++; |
| 5717 | } |
andrew.vasquez@qlogic.com | f6df144 | 2006-01-31 16:05:07 -0800 | [diff] [blame] | 5718 | } |
| 5719 | |
Andrew Vasquez | 550bf57 | 2008-04-24 15:21:23 -0700 | [diff] [blame] | 5720 | /* Process any deferred work. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5721 | if (!list_empty(&vha->work_list)) |
Andrew Vasquez | 550bf57 | 2008-04-24 15:21:23 -0700 | [diff] [blame] | 5722 | start_dpc++; |
| 5723 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5724 | /* Schedule the DPC routine if needed */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5725 | if ((test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) || |
| 5726 | test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags) || |
| 5727 | test_bit(FCPORT_UPDATE_NEEDED, &vha->dpc_flags) || |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5728 | start_dpc || |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5729 | test_bit(RESET_MARKER_NEEDED, &vha->dpc_flags) || |
| 5730 | test_bit(BEACON_BLINK_NEEDED, &vha->dpc_flags) || |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5731 | test_bit(ISP_UNRECOVERABLE, &vha->dpc_flags) || |
| 5732 | test_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags) || |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5733 | test_bit(VP_DPC_NEEDED, &vha->dpc_flags) || |
Chad Dupuis | 50280c0 | 2013-10-30 03:38:14 -0400 | [diff] [blame] | 5734 | test_bit(RELOGIN_NEEDED, &vha->dpc_flags))) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5735 | ql_dbg(ql_dbg_timer, vha, 0x600b, |
| 5736 | "isp_abort_needed=%d loop_resync_needed=%d " |
| 5737 | "fcport_update_needed=%d start_dpc=%d " |
| 5738 | "reset_marker_needed=%d", |
| 5739 | test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags), |
| 5740 | test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags), |
| 5741 | test_bit(FCPORT_UPDATE_NEEDED, &vha->dpc_flags), |
| 5742 | start_dpc, |
| 5743 | test_bit(RESET_MARKER_NEEDED, &vha->dpc_flags)); |
| 5744 | ql_dbg(ql_dbg_timer, vha, 0x600c, |
| 5745 | "beacon_blink_needed=%d isp_unrecoverable=%d " |
| 5746 | "fcoe_ctx_reset_needed=%d vp_dpc_needed=%d " |
Chad Dupuis | 50280c0 | 2013-10-30 03:38:14 -0400 | [diff] [blame] | 5747 | "relogin_needed=%d.\n", |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5748 | test_bit(BEACON_BLINK_NEEDED, &vha->dpc_flags), |
| 5749 | test_bit(ISP_UNRECOVERABLE, &vha->dpc_flags), |
| 5750 | test_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags), |
| 5751 | test_bit(VP_DPC_NEEDED, &vha->dpc_flags), |
Chad Dupuis | 50280c0 | 2013-10-30 03:38:14 -0400 | [diff] [blame] | 5752 | test_bit(RELOGIN_NEEDED, &vha->dpc_flags)); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5753 | qla2xxx_wake_dpc(vha); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5754 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5755 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5756 | qla2x00_restart_timer(vha, WATCH_INTERVAL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5757 | } |
| 5758 | |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5759 | /* Firmware interface routines. */ |
| 5760 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 5761 | #define FW_BLOBS 11 |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5762 | #define FW_ISP21XX 0 |
| 5763 | #define FW_ISP22XX 1 |
| 5764 | #define FW_ISP2300 2 |
| 5765 | #define FW_ISP2322 3 |
andrew.vasquez@qlogic.com | 48c02fd | 2006-03-09 14:27:18 -0800 | [diff] [blame] | 5766 | #define FW_ISP24XX 4 |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 5767 | #define FW_ISP25XX 5 |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5768 | #define FW_ISP81XX 6 |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5769 | #define FW_ISP82XX 7 |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5770 | #define FW_ISP2031 8 |
| 5771 | #define FW_ISP8031 9 |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 5772 | #define FW_ISP27XX 10 |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5773 | |
Andrew Vasquez | bb8ee49 | 2006-10-02 12:00:48 -0700 | [diff] [blame] | 5774 | #define FW_FILE_ISP21XX "ql2100_fw.bin" |
| 5775 | #define FW_FILE_ISP22XX "ql2200_fw.bin" |
| 5776 | #define FW_FILE_ISP2300 "ql2300_fw.bin" |
| 5777 | #define FW_FILE_ISP2322 "ql2322_fw.bin" |
| 5778 | #define FW_FILE_ISP24XX "ql2400_fw.bin" |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 5779 | #define FW_FILE_ISP25XX "ql2500_fw.bin" |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5780 | #define FW_FILE_ISP81XX "ql8100_fw.bin" |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5781 | #define FW_FILE_ISP82XX "ql8200_fw.bin" |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5782 | #define FW_FILE_ISP2031 "ql2600_fw.bin" |
| 5783 | #define FW_FILE_ISP8031 "ql8300_fw.bin" |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 5784 | #define FW_FILE_ISP27XX "ql2700_fw.bin" |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 5785 | |
Andrew Vasquez | bb8ee49 | 2006-10-02 12:00:48 -0700 | [diff] [blame] | 5786 | |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 5787 | static DEFINE_MUTEX(qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5788 | |
| 5789 | static struct fw_blob qla_fw_blobs[FW_BLOBS] = { |
Andrew Vasquez | bb8ee49 | 2006-10-02 12:00:48 -0700 | [diff] [blame] | 5790 | { .name = FW_FILE_ISP21XX, .segs = { 0x1000, 0 }, }, |
| 5791 | { .name = FW_FILE_ISP22XX, .segs = { 0x1000, 0 }, }, |
| 5792 | { .name = FW_FILE_ISP2300, .segs = { 0x800, 0 }, }, |
| 5793 | { .name = FW_FILE_ISP2322, .segs = { 0x800, 0x1c000, 0x1e000, 0 }, }, |
| 5794 | { .name = FW_FILE_ISP24XX, }, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 5795 | { .name = FW_FILE_ISP25XX, }, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5796 | { .name = FW_FILE_ISP81XX, }, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5797 | { .name = FW_FILE_ISP82XX, }, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5798 | { .name = FW_FILE_ISP2031, }, |
| 5799 | { .name = FW_FILE_ISP8031, }, |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 5800 | { .name = FW_FILE_ISP27XX, }, |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5801 | }; |
| 5802 | |
| 5803 | struct fw_blob * |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5804 | qla2x00_request_firmware(scsi_qla_host_t *vha) |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5805 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5806 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5807 | struct fw_blob *blob; |
| 5808 | |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5809 | if (IS_QLA2100(ha)) { |
| 5810 | blob = &qla_fw_blobs[FW_ISP21XX]; |
| 5811 | } else if (IS_QLA2200(ha)) { |
| 5812 | blob = &qla_fw_blobs[FW_ISP22XX]; |
andrew.vasquez@qlogic.com | 48c02fd | 2006-03-09 14:27:18 -0800 | [diff] [blame] | 5813 | } else if (IS_QLA2300(ha) || IS_QLA2312(ha) || IS_QLA6312(ha)) { |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5814 | blob = &qla_fw_blobs[FW_ISP2300]; |
andrew.vasquez@qlogic.com | 48c02fd | 2006-03-09 14:27:18 -0800 | [diff] [blame] | 5815 | } else if (IS_QLA2322(ha) || IS_QLA6322(ha)) { |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5816 | blob = &qla_fw_blobs[FW_ISP2322]; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 5817 | } else if (IS_QLA24XX_TYPE(ha)) { |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5818 | blob = &qla_fw_blobs[FW_ISP24XX]; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 5819 | } else if (IS_QLA25XX(ha)) { |
| 5820 | blob = &qla_fw_blobs[FW_ISP25XX]; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5821 | } else if (IS_QLA81XX(ha)) { |
| 5822 | blob = &qla_fw_blobs[FW_ISP81XX]; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5823 | } else if (IS_QLA82XX(ha)) { |
| 5824 | blob = &qla_fw_blobs[FW_ISP82XX]; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5825 | } else if (IS_QLA2031(ha)) { |
| 5826 | blob = &qla_fw_blobs[FW_ISP2031]; |
| 5827 | } else if (IS_QLA8031(ha)) { |
| 5828 | blob = &qla_fw_blobs[FW_ISP8031]; |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 5829 | } else if (IS_QLA27XX(ha)) { |
| 5830 | blob = &qla_fw_blobs[FW_ISP27XX]; |
Dan Carpenter | 8a65522 | 2012-02-21 10:29:40 +0300 | [diff] [blame] | 5831 | } else { |
| 5832 | return NULL; |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5833 | } |
| 5834 | |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 5835 | mutex_lock(&qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5836 | if (blob->fw) |
| 5837 | goto out; |
| 5838 | |
| 5839 | if (request_firmware(&blob->fw, blob->name, &ha->pdev->dev)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5840 | ql_log(ql_log_warn, vha, 0x0063, |
| 5841 | "Failed to load firmware image (%s).\n", blob->name); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5842 | blob->fw = NULL; |
| 5843 | blob = NULL; |
| 5844 | goto out; |
| 5845 | } |
| 5846 | |
| 5847 | out: |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 5848 | mutex_unlock(&qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5849 | return blob; |
| 5850 | } |
| 5851 | |
| 5852 | static void |
| 5853 | qla2x00_release_firmware(void) |
| 5854 | { |
| 5855 | int idx; |
| 5856 | |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 5857 | mutex_lock(&qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5858 | for (idx = 0; idx < FW_BLOBS; idx++) |
Jesper Juhl | cf92549 | 2012-04-09 22:51:41 +0200 | [diff] [blame] | 5859 | release_firmware(qla_fw_blobs[idx].fw); |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 5860 | mutex_unlock(&qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5861 | } |
| 5862 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5863 | static pci_ers_result_t |
| 5864 | qla2xxx_pci_error_detected(struct pci_dev *pdev, pci_channel_state_t state) |
| 5865 | { |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5866 | scsi_qla_host_t *vha = pci_get_drvdata(pdev); |
| 5867 | struct qla_hw_data *ha = vha->hw; |
| 5868 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5869 | ql_dbg(ql_dbg_aer, vha, 0x9000, |
| 5870 | "PCI error detected, state %x.\n", state); |
Seokmann Ju | b9b12f7 | 2009-03-24 09:08:18 -0700 | [diff] [blame] | 5871 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5872 | switch (state) { |
| 5873 | case pci_channel_io_normal: |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5874 | ha->flags.eeh_busy = 0; |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 5875 | if (ql2xmqsupport) { |
| 5876 | set_bit(QPAIR_ONLINE_CHECK_NEEDED, &vha->dpc_flags); |
| 5877 | qla2xxx_wake_dpc(vha); |
| 5878 | } |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5879 | return PCI_ERS_RESULT_CAN_RECOVER; |
| 5880 | case pci_channel_io_frozen: |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5881 | ha->flags.eeh_busy = 1; |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5882 | /* For ISP82XX complete any pending mailbox cmd */ |
| 5883 | if (IS_QLA82XX(ha)) { |
Giridhar Malavali | 7190575 | 2011-02-23 15:27:10 -0800 | [diff] [blame] | 5884 | ha->flags.isp82xx_fw_hung = 1; |
Chad Dupuis | c8f6544 | 2011-11-18 09:02:17 -0800 | [diff] [blame] | 5885 | ql_dbg(ql_dbg_aer, vha, 0x9001, "Pci channel io frozen\n"); |
| 5886 | qla82xx_clear_pending_mbx(vha); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5887 | } |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 5888 | qla2x00_free_irqs(vha); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5889 | pci_disable_device(pdev); |
Lalit Chandivade | bddd2d6 | 2010-09-03 15:20:53 -0700 | [diff] [blame] | 5890 | /* Return back all IOs */ |
| 5891 | qla2x00_abort_all_cmds(vha, DID_RESET << 16); |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 5892 | if (ql2xmqsupport) { |
| 5893 | set_bit(QPAIR_ONLINE_CHECK_NEEDED, &vha->dpc_flags); |
| 5894 | qla2xxx_wake_dpc(vha); |
| 5895 | } |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5896 | return PCI_ERS_RESULT_NEED_RESET; |
| 5897 | case pci_channel_io_perm_failure: |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5898 | ha->flags.pci_channel_io_perm_failure = 1; |
| 5899 | qla2x00_abort_all_cmds(vha, DID_NO_CONNECT << 16); |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 5900 | if (ql2xmqsupport) { |
| 5901 | set_bit(QPAIR_ONLINE_CHECK_NEEDED, &vha->dpc_flags); |
| 5902 | qla2xxx_wake_dpc(vha); |
| 5903 | } |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5904 | return PCI_ERS_RESULT_DISCONNECT; |
| 5905 | } |
| 5906 | return PCI_ERS_RESULT_NEED_RESET; |
| 5907 | } |
| 5908 | |
| 5909 | static pci_ers_result_t |
| 5910 | qla2xxx_pci_mmio_enabled(struct pci_dev *pdev) |
| 5911 | { |
| 5912 | int risc_paused = 0; |
| 5913 | uint32_t stat; |
| 5914 | unsigned long flags; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5915 | scsi_qla_host_t *base_vha = pci_get_drvdata(pdev); |
| 5916 | struct qla_hw_data *ha = base_vha->hw; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5917 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
| 5918 | struct device_reg_24xx __iomem *reg24 = &ha->iobase->isp24; |
| 5919 | |
Saurav Kashyap | bcc5b6d | 2010-09-03 15:20:57 -0700 | [diff] [blame] | 5920 | if (IS_QLA82XX(ha)) |
| 5921 | return PCI_ERS_RESULT_RECOVERED; |
| 5922 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5923 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 5924 | if (IS_QLA2100(ha) || IS_QLA2200(ha)){ |
| 5925 | stat = RD_REG_DWORD(®->hccr); |
| 5926 | if (stat & HCCR_RISC_PAUSE) |
| 5927 | risc_paused = 1; |
| 5928 | } else if (IS_QLA23XX(ha)) { |
| 5929 | stat = RD_REG_DWORD(®->u.isp2300.host_status); |
| 5930 | if (stat & HSR_RISC_PAUSED) |
| 5931 | risc_paused = 1; |
| 5932 | } else if (IS_FWI2_CAPABLE(ha)) { |
| 5933 | stat = RD_REG_DWORD(®24->host_status); |
| 5934 | if (stat & HSRX_RISC_PAUSED) |
| 5935 | risc_paused = 1; |
| 5936 | } |
| 5937 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 5938 | |
| 5939 | if (risc_paused) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5940 | ql_log(ql_log_info, base_vha, 0x9003, |
| 5941 | "RISC paused -- mmio_enabled, Dumping firmware.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5942 | ha->isp_ops->fw_dump(base_vha, 0); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5943 | |
| 5944 | return PCI_ERS_RESULT_NEED_RESET; |
| 5945 | } else |
| 5946 | return PCI_ERS_RESULT_RECOVERED; |
| 5947 | } |
| 5948 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 5949 | static uint32_t |
| 5950 | qla82xx_error_recovery(scsi_qla_host_t *base_vha) |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5951 | { |
| 5952 | uint32_t rval = QLA_FUNCTION_FAILED; |
| 5953 | uint32_t drv_active = 0; |
| 5954 | struct qla_hw_data *ha = base_vha->hw; |
| 5955 | int fn; |
| 5956 | struct pci_dev *other_pdev = NULL; |
| 5957 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5958 | ql_dbg(ql_dbg_aer, base_vha, 0x9006, |
| 5959 | "Entered %s.\n", __func__); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5960 | |
| 5961 | set_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
| 5962 | |
| 5963 | if (base_vha->flags.online) { |
| 5964 | /* Abort all outstanding commands, |
| 5965 | * so as to be requeued later */ |
| 5966 | qla2x00_abort_isp_cleanup(base_vha); |
| 5967 | } |
| 5968 | |
| 5969 | |
| 5970 | fn = PCI_FUNC(ha->pdev->devfn); |
| 5971 | while (fn > 0) { |
| 5972 | fn--; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5973 | ql_dbg(ql_dbg_aer, base_vha, 0x9007, |
| 5974 | "Finding pci device at function = 0x%x.\n", fn); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5975 | other_pdev = |
| 5976 | pci_get_domain_bus_and_slot(pci_domain_nr(ha->pdev->bus), |
| 5977 | ha->pdev->bus->number, PCI_DEVFN(PCI_SLOT(ha->pdev->devfn), |
| 5978 | fn)); |
| 5979 | |
| 5980 | if (!other_pdev) |
| 5981 | continue; |
| 5982 | if (atomic_read(&other_pdev->enable_cnt)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5983 | ql_dbg(ql_dbg_aer, base_vha, 0x9008, |
| 5984 | "Found PCI func available and enable at 0x%x.\n", |
| 5985 | fn); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5986 | pci_dev_put(other_pdev); |
| 5987 | break; |
| 5988 | } |
| 5989 | pci_dev_put(other_pdev); |
| 5990 | } |
| 5991 | |
| 5992 | if (!fn) { |
| 5993 | /* Reset owner */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5994 | ql_dbg(ql_dbg_aer, base_vha, 0x9009, |
| 5995 | "This devfn is reset owner = 0x%x.\n", |
| 5996 | ha->pdev->devfn); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5997 | qla82xx_idc_lock(ha); |
| 5998 | |
| 5999 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 6000 | QLA8XXX_DEV_INITIALIZING); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6001 | |
| 6002 | qla82xx_wr_32(ha, QLA82XX_CRB_DRV_IDC_VERSION, |
| 6003 | QLA82XX_IDC_VERSION); |
| 6004 | |
| 6005 | drv_active = qla82xx_rd_32(ha, QLA82XX_CRB_DRV_ACTIVE); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6006 | ql_dbg(ql_dbg_aer, base_vha, 0x900a, |
| 6007 | "drv_active = 0x%x.\n", drv_active); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6008 | |
| 6009 | qla82xx_idc_unlock(ha); |
| 6010 | /* Reset if device is not already reset |
| 6011 | * drv_active would be 0 if a reset has already been done |
| 6012 | */ |
| 6013 | if (drv_active) |
| 6014 | rval = qla82xx_start_firmware(base_vha); |
| 6015 | else |
| 6016 | rval = QLA_SUCCESS; |
| 6017 | qla82xx_idc_lock(ha); |
| 6018 | |
| 6019 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6020 | ql_log(ql_log_info, base_vha, 0x900b, |
| 6021 | "HW State: FAILED.\n"); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6022 | qla82xx_clear_drv_active(ha); |
| 6023 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 6024 | QLA8XXX_DEV_FAILED); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6025 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6026 | ql_log(ql_log_info, base_vha, 0x900c, |
| 6027 | "HW State: READY.\n"); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6028 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 6029 | QLA8XXX_DEV_READY); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6030 | qla82xx_idc_unlock(ha); |
Giridhar Malavali | 7190575 | 2011-02-23 15:27:10 -0800 | [diff] [blame] | 6031 | ha->flags.isp82xx_fw_hung = 0; |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6032 | rval = qla82xx_restart_isp(base_vha); |
| 6033 | qla82xx_idc_lock(ha); |
| 6034 | /* Clear driver state register */ |
| 6035 | qla82xx_wr_32(ha, QLA82XX_CRB_DRV_STATE, 0); |
| 6036 | qla82xx_set_drv_active(base_vha); |
| 6037 | } |
| 6038 | qla82xx_idc_unlock(ha); |
| 6039 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6040 | ql_dbg(ql_dbg_aer, base_vha, 0x900d, |
| 6041 | "This devfn is not reset owner = 0x%x.\n", |
| 6042 | ha->pdev->devfn); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6043 | if ((qla82xx_rd_32(ha, QLA82XX_CRB_DEV_STATE) == |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 6044 | QLA8XXX_DEV_READY)) { |
Giridhar Malavali | 7190575 | 2011-02-23 15:27:10 -0800 | [diff] [blame] | 6045 | ha->flags.isp82xx_fw_hung = 0; |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6046 | rval = qla82xx_restart_isp(base_vha); |
| 6047 | qla82xx_idc_lock(ha); |
| 6048 | qla82xx_set_drv_active(base_vha); |
| 6049 | qla82xx_idc_unlock(ha); |
| 6050 | } |
| 6051 | } |
| 6052 | clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
| 6053 | |
| 6054 | return rval; |
| 6055 | } |
| 6056 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6057 | static pci_ers_result_t |
| 6058 | qla2xxx_pci_slot_reset(struct pci_dev *pdev) |
| 6059 | { |
| 6060 | pci_ers_result_t ret = PCI_ERS_RESULT_DISCONNECT; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6061 | scsi_qla_host_t *base_vha = pci_get_drvdata(pdev); |
| 6062 | struct qla_hw_data *ha = base_vha->hw; |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 6063 | struct rsp_que *rsp; |
| 6064 | int rc, retries = 10; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6065 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6066 | ql_dbg(ql_dbg_aer, base_vha, 0x9004, |
| 6067 | "Slot Reset.\n"); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6068 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 6069 | /* Workaround: qla2xxx driver which access hardware earlier |
| 6070 | * needs error state to be pci_channel_io_online. |
| 6071 | * Otherwise mailbox command timesout. |
| 6072 | */ |
| 6073 | pdev->error_state = pci_channel_io_normal; |
| 6074 | |
| 6075 | pci_restore_state(pdev); |
| 6076 | |
Richard Lary | 8c1496b | 2010-02-18 10:07:29 -0800 | [diff] [blame] | 6077 | /* pci_restore_state() clears the saved_state flag of the device |
| 6078 | * save restored state which resets saved_state flag |
| 6079 | */ |
| 6080 | pci_save_state(pdev); |
| 6081 | |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 6082 | if (ha->mem_only) |
| 6083 | rc = pci_enable_device_mem(pdev); |
| 6084 | else |
| 6085 | rc = pci_enable_device(pdev); |
| 6086 | |
| 6087 | if (rc) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6088 | ql_log(ql_log_warn, base_vha, 0x9005, |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6089 | "Can't re-enable PCI device after reset.\n"); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6090 | goto exit_slot_reset; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6091 | } |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6092 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 6093 | rsp = ha->rsp_q_map[0]; |
| 6094 | if (qla2x00_request_irqs(ha, rsp)) |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6095 | goto exit_slot_reset; |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 6096 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6097 | if (ha->isp_ops->pci_config(base_vha)) |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6098 | goto exit_slot_reset; |
| 6099 | |
| 6100 | if (IS_QLA82XX(ha)) { |
| 6101 | if (qla82xx_error_recovery(base_vha) == QLA_SUCCESS) { |
| 6102 | ret = PCI_ERS_RESULT_RECOVERED; |
| 6103 | goto exit_slot_reset; |
| 6104 | } else |
| 6105 | goto exit_slot_reset; |
| 6106 | } |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6107 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 6108 | while (ha->flags.mbox_busy && retries--) |
| 6109 | msleep(1000); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6110 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6111 | set_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 6112 | if (ha->isp_ops->abort_isp(base_vha) == QLA_SUCCESS) |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6113 | ret = PCI_ERS_RESULT_RECOVERED; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6114 | clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6115 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 6116 | |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6117 | exit_slot_reset: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6118 | ql_dbg(ql_dbg_aer, base_vha, 0x900e, |
| 6119 | "slot_reset return %x.\n", ret); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6120 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6121 | return ret; |
| 6122 | } |
| 6123 | |
| 6124 | static void |
| 6125 | qla2xxx_pci_resume(struct pci_dev *pdev) |
| 6126 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6127 | scsi_qla_host_t *base_vha = pci_get_drvdata(pdev); |
| 6128 | struct qla_hw_data *ha = base_vha->hw; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6129 | int ret; |
| 6130 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6131 | ql_dbg(ql_dbg_aer, base_vha, 0x900f, |
| 6132 | "pci_resume.\n"); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6133 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6134 | ret = qla2x00_wait_for_hba_online(base_vha); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6135 | if (ret != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6136 | ql_log(ql_log_fatal, base_vha, 0x9002, |
| 6137 | "The device failed to resume I/O from slot/link_reset.\n"); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6138 | } |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6139 | |
Lalit Chandivade | 3e46f03 | 2010-05-04 15:01:23 -0700 | [diff] [blame] | 6140 | pci_cleanup_aer_uncorrect_error_status(pdev); |
| 6141 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6142 | ha->flags.eeh_busy = 0; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6143 | } |
| 6144 | |
Himanshu Madhani | 2d5a4c3 | 2014-09-25 05:16:55 -0400 | [diff] [blame] | 6145 | static void |
| 6146 | qla83xx_disable_laser(scsi_qla_host_t *vha) |
| 6147 | { |
| 6148 | uint32_t reg, data, fn; |
| 6149 | struct qla_hw_data *ha = vha->hw; |
| 6150 | struct device_reg_24xx __iomem *isp_reg = &ha->iobase->isp24; |
| 6151 | |
| 6152 | /* pci func #/port # */ |
| 6153 | ql_dbg(ql_dbg_init, vha, 0x004b, |
| 6154 | "Disabling Laser for hba: %p\n", vha); |
| 6155 | |
| 6156 | fn = (RD_REG_DWORD(&isp_reg->ctrl_status) & |
| 6157 | (BIT_15|BIT_14|BIT_13|BIT_12)); |
| 6158 | |
| 6159 | fn = (fn >> 12); |
| 6160 | |
| 6161 | if (fn & 1) |
| 6162 | reg = PORT_1_2031; |
| 6163 | else |
| 6164 | reg = PORT_0_2031; |
| 6165 | |
| 6166 | data = LASER_OFF_2031; |
| 6167 | |
| 6168 | qla83xx_wr_reg(vha, reg, data); |
| 6169 | } |
| 6170 | |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame] | 6171 | static int qla2xxx_map_queues(struct Scsi_Host *shost) |
| 6172 | { |
| 6173 | scsi_qla_host_t *vha = (scsi_qla_host_t *)shost->hostdata; |
| 6174 | |
| 6175 | return blk_mq_pci_map_queues(&shost->tag_set, vha->hw->pdev); |
| 6176 | } |
| 6177 | |
Stephen Hemminger | a55b2d2 | 2012-09-07 09:33:16 -0700 | [diff] [blame] | 6178 | static const struct pci_error_handlers qla2xxx_err_handler = { |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6179 | .error_detected = qla2xxx_pci_error_detected, |
| 6180 | .mmio_enabled = qla2xxx_pci_mmio_enabled, |
| 6181 | .slot_reset = qla2xxx_pci_slot_reset, |
| 6182 | .resume = qla2xxx_pci_resume, |
| 6183 | }; |
| 6184 | |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6185 | static struct pci_device_id qla2xxx_pci_tbl[] = { |
Andrew Vasquez | 47f5e06 | 2006-05-17 15:09:39 -0700 | [diff] [blame] | 6186 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2100) }, |
| 6187 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2200) }, |
| 6188 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2300) }, |
| 6189 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2312) }, |
| 6190 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2322) }, |
| 6191 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP6312) }, |
| 6192 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP6322) }, |
| 6193 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2422) }, |
| 6194 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2432) }, |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 6195 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8432) }, |
Andrew Vasquez | 47f5e06 | 2006-05-17 15:09:39 -0700 | [diff] [blame] | 6196 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP5422) }, |
| 6197 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP5432) }, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 6198 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2532) }, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 6199 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2031) }, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 6200 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8001) }, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 6201 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8021) }, |
Chad Dupuis | 650f528 | 2012-08-22 14:20:55 -0400 | [diff] [blame] | 6202 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8031) }, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 6203 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISPF001) }, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 6204 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8044) }, |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 6205 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2071) }, |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 6206 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2271) }, |
Sawan Chandak | 2b48992 | 2015-08-04 13:38:03 -0400 | [diff] [blame] | 6207 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2261) }, |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6208 | { 0 }, |
| 6209 | }; |
| 6210 | MODULE_DEVICE_TABLE(pci, qla2xxx_pci_tbl); |
| 6211 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 6212 | static struct pci_driver qla2xxx_pci_driver = { |
Andrew Vasquez | cb63067 | 2006-05-17 15:09:45 -0700 | [diff] [blame] | 6213 | .name = QLA2XXX_DRIVER_NAME, |
James Bottomley | 0a21ef1 | 2005-12-01 12:51:50 -0600 | [diff] [blame] | 6214 | .driver = { |
| 6215 | .owner = THIS_MODULE, |
| 6216 | }, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 6217 | .id_table = qla2xxx_pci_tbl, |
Andrew Vasquez | 7ee6139 | 2006-06-23 16:11:22 -0700 | [diff] [blame] | 6218 | .probe = qla2x00_probe_one, |
Adrian Bunk | 4c993f7 | 2008-01-14 00:55:16 -0800 | [diff] [blame] | 6219 | .remove = qla2x00_remove_one, |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 6220 | .shutdown = qla2x00_shutdown, |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6221 | .err_handler = &qla2xxx_err_handler, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 6222 | }; |
| 6223 | |
Al Viro | 75ef9de | 2013-04-04 19:09:41 -0400 | [diff] [blame] | 6224 | static const struct file_operations apidev_fops = { |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 6225 | .owner = THIS_MODULE, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 6226 | .llseek = noop_llseek, |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 6227 | }; |
| 6228 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6229 | /** |
| 6230 | * qla2x00_module_init - Module initialization. |
| 6231 | **/ |
| 6232 | static int __init |
| 6233 | qla2x00_module_init(void) |
| 6234 | { |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 6235 | int ret = 0; |
| 6236 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6237 | /* Allocate cache for SRBs. */ |
Andrew Vasquez | 354d6b2 | 2005-04-23 02:47:27 -0400 | [diff] [blame] | 6238 | srb_cachep = kmem_cache_create("qla2xxx_srbs", sizeof(srb_t), 0, |
Paul Mundt | 20c2df8 | 2007-07-20 10:11:58 +0900 | [diff] [blame] | 6239 | SLAB_HWCACHE_ALIGN, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6240 | if (srb_cachep == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6241 | ql_log(ql_log_fatal, NULL, 0x0001, |
| 6242 | "Unable to allocate SRB cache...Failing load!.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6243 | return -ENOMEM; |
| 6244 | } |
| 6245 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 6246 | /* Initialize target kmem_cache and mem_pools */ |
| 6247 | ret = qlt_init(); |
| 6248 | if (ret < 0) { |
| 6249 | kmem_cache_destroy(srb_cachep); |
| 6250 | return ret; |
| 6251 | } else if (ret > 0) { |
| 6252 | /* |
| 6253 | * If initiator mode is explictly disabled by qlt_init(), |
| 6254 | * prevent scsi_transport_fc.c:fc_scsi_scan_rport() from |
| 6255 | * performing scsi_scan_target() during LOOP UP event. |
| 6256 | */ |
| 6257 | qla2xxx_transport_functions.disable_target_scan = 1; |
| 6258 | qla2xxx_transport_vport_functions.disable_target_scan = 1; |
| 6259 | } |
| 6260 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6261 | /* Derive version string. */ |
| 6262 | strcpy(qla2x00_version_str, QLA2XXX_VERSION); |
Andrew Vasquez | 11010fe | 2006-10-06 09:54:59 -0700 | [diff] [blame] | 6263 | if (ql2xextended_error_logging) |
Andrew Vasquez | 0181944 | 2006-06-23 16:11:10 -0700 | [diff] [blame] | 6264 | strcat(qla2x00_version_str, "-debug"); |
| 6265 | |
Andrew Vasquez | 1c97a12 | 2005-04-21 16:13:36 -0400 | [diff] [blame] | 6266 | qla2xxx_transport_template = |
| 6267 | fc_attach_transport(&qla2xxx_transport_functions); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6268 | if (!qla2xxx_transport_template) { |
| 6269 | kmem_cache_destroy(srb_cachep); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6270 | ql_log(ql_log_fatal, NULL, 0x0002, |
| 6271 | "fc_attach_transport failed...Failing load!.\n"); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 6272 | qlt_exit(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6273 | return -ENODEV; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6274 | } |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 6275 | |
| 6276 | apidev_major = register_chrdev(0, QLA2XXX_APIDEV, &apidev_fops); |
| 6277 | if (apidev_major < 0) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6278 | ql_log(ql_log_fatal, NULL, 0x0003, |
| 6279 | "Unable to register char device %s.\n", QLA2XXX_APIDEV); |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 6280 | } |
| 6281 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6282 | qla2xxx_transport_vport_template = |
| 6283 | fc_attach_transport(&qla2xxx_transport_vport_functions); |
| 6284 | if (!qla2xxx_transport_vport_template) { |
| 6285 | kmem_cache_destroy(srb_cachep); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 6286 | qlt_exit(); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6287 | fc_release_transport(qla2xxx_transport_template); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6288 | ql_log(ql_log_fatal, NULL, 0x0004, |
| 6289 | "fc_attach_transport vport failed...Failing load!.\n"); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6290 | return -ENODEV; |
| 6291 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6292 | ql_log(ql_log_info, NULL, 0x0005, |
| 6293 | "QLogic Fibre Channel HBA Driver: %s.\n", |
Andrew Vasquez | fd9a29f0 | 2008-05-12 22:21:08 -0700 | [diff] [blame] | 6294 | qla2x00_version_str); |
Andrew Vasquez | 7ee6139 | 2006-06-23 16:11:22 -0700 | [diff] [blame] | 6295 | ret = pci_register_driver(&qla2xxx_pci_driver); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 6296 | if (ret) { |
| 6297 | kmem_cache_destroy(srb_cachep); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 6298 | qlt_exit(); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 6299 | fc_release_transport(qla2xxx_transport_template); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6300 | fc_release_transport(qla2xxx_transport_vport_template); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6301 | ql_log(ql_log_fatal, NULL, 0x0006, |
| 6302 | "pci_register_driver failed...ret=%d Failing load!.\n", |
| 6303 | ret); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 6304 | } |
| 6305 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6306 | } |
| 6307 | |
| 6308 | /** |
| 6309 | * qla2x00_module_exit - Module cleanup. |
| 6310 | **/ |
| 6311 | static void __exit |
| 6312 | qla2x00_module_exit(void) |
| 6313 | { |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 6314 | unregister_chrdev(apidev_major, QLA2XXX_APIDEV); |
Andrew Vasquez | 7ee6139 | 2006-06-23 16:11:22 -0700 | [diff] [blame] | 6315 | pci_unregister_driver(&qla2xxx_pci_driver); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6316 | qla2x00_release_firmware(); |
Andrew Vasquez | 354d6b2 | 2005-04-23 02:47:27 -0400 | [diff] [blame] | 6317 | kmem_cache_destroy(srb_cachep); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 6318 | qlt_exit(); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 6319 | if (ctx_cachep) |
| 6320 | kmem_cache_destroy(ctx_cachep); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6321 | fc_release_transport(qla2xxx_transport_template); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6322 | fc_release_transport(qla2xxx_transport_vport_template); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6323 | } |
| 6324 | |
| 6325 | module_init(qla2x00_module_init); |
| 6326 | module_exit(qla2x00_module_exit); |
| 6327 | |
| 6328 | MODULE_AUTHOR("QLogic Corporation"); |
| 6329 | MODULE_DESCRIPTION("QLogic Fibre Channel HBA Driver"); |
| 6330 | MODULE_LICENSE("GPL"); |
| 6331 | MODULE_VERSION(QLA2XXX_VERSION); |
Andrew Vasquez | bb8ee49 | 2006-10-02 12:00:48 -0700 | [diff] [blame] | 6332 | MODULE_FIRMWARE(FW_FILE_ISP21XX); |
| 6333 | MODULE_FIRMWARE(FW_FILE_ISP22XX); |
| 6334 | MODULE_FIRMWARE(FW_FILE_ISP2300); |
| 6335 | MODULE_FIRMWARE(FW_FILE_ISP2322); |
| 6336 | MODULE_FIRMWARE(FW_FILE_ISP24XX); |
Andrew Vasquez | 61623fc | 2008-01-31 12:33:45 -0800 | [diff] [blame] | 6337 | MODULE_FIRMWARE(FW_FILE_ISP25XX); |