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 | |
| 265 | .eh_abort_handler = qla2xxx_eh_abort, |
| 266 | .eh_device_reset_handler = qla2xxx_eh_device_reset, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 267 | .eh_target_reset_handler = qla2xxx_eh_target_reset, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 268 | .eh_bus_reset_handler = qla2xxx_eh_bus_reset, |
| 269 | .eh_host_reset_handler = qla2xxx_eh_host_reset, |
| 270 | |
| 271 | .slave_configure = qla2xxx_slave_configure, |
| 272 | |
| 273 | .slave_alloc = qla2xxx_slave_alloc, |
| 274 | .slave_destroy = qla2xxx_slave_destroy, |
Andrew Vasquez | ed67708 | 2007-03-12 10:41:27 -0700 | [diff] [blame] | 275 | .scan_finished = qla2xxx_scan_finished, |
| 276 | .scan_start = qla2xxx_scan_start, |
Christoph Hellwig | db5ed4d | 2014-11-13 15:08:42 +0100 | [diff] [blame] | 277 | .change_queue_depth = scsi_change_queue_depth, |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame^] | 278 | .map_queues = qla2xxx_map_queues, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 279 | .this_id = -1, |
| 280 | .cmd_per_lun = 3, |
| 281 | .use_clustering = ENABLE_CLUSTERING, |
| 282 | .sg_tablesize = SG_ALL, |
| 283 | |
| 284 | .max_sectors = 0xFFFF, |
Andrew Vasquez | afb046e | 2005-08-26 19:09:40 -0700 | [diff] [blame] | 285 | .shost_attrs = qla2x00_host_attrs, |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 286 | |
| 287 | .supported_mode = MODE_INITIATOR, |
Christoph Hellwig | c40ecc1 | 2014-11-13 14:25:11 +0100 | [diff] [blame] | 288 | .track_queue_depth = 1, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 289 | }; |
| 290 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 291 | static struct scsi_transport_template *qla2xxx_transport_template = NULL; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 292 | struct scsi_transport_template *qla2xxx_transport_vport_template = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 293 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 294 | /* TODO Convert to inlines |
| 295 | * |
| 296 | * Timer routines |
| 297 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 298 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 299 | __inline__ void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 300 | 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] | 301 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 302 | init_timer(&vha->timer); |
| 303 | vha->timer.expires = jiffies + interval * HZ; |
| 304 | vha->timer.data = (unsigned long)vha; |
| 305 | vha->timer.function = (void (*)(unsigned long))func; |
| 306 | add_timer(&vha->timer); |
| 307 | vha->timer_active = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 308 | } |
| 309 | |
| 310 | static inline void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 311 | qla2x00_restart_timer(scsi_qla_host_t *vha, unsigned long interval) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 312 | { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 313 | /* Currently used for 82XX only. */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 314 | if (vha->device_flags & DFLG_DEV_FAILED) { |
| 315 | ql_dbg(ql_dbg_timer, vha, 0x600d, |
| 316 | "Device in a failed state, returning.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 317 | return; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 318 | } |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 319 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 320 | mod_timer(&vha->timer, jiffies + interval * HZ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 321 | } |
| 322 | |
Adrian Bunk | a824ebb | 2008-01-17 09:02:15 -0800 | [diff] [blame] | 323 | static __inline__ void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 324 | qla2x00_stop_timer(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 325 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 326 | del_timer_sync(&vha->timer); |
| 327 | vha->timer_active = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 328 | } |
| 329 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 330 | static int qla2x00_do_dpc(void *data); |
| 331 | |
| 332 | static void qla2x00_rst_aen(scsi_qla_host_t *); |
| 333 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 334 | static int qla2x00_mem_alloc(struct qla_hw_data *, uint16_t, uint16_t, |
| 335 | struct req_que **, struct rsp_que **); |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 336 | static void qla2x00_free_fw_dump(struct qla_hw_data *); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 337 | static void qla2x00_mem_free(struct qla_hw_data *); |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 338 | int qla2xxx_mqueuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd, |
| 339 | struct qla_qpair *qpair); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 340 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 341 | /* -------------------------------------------------------------------------- */ |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 342 | static int qla2x00_alloc_queues(struct qla_hw_data *ha, struct req_que *req, |
| 343 | struct rsp_que *rsp) |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 344 | { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 345 | scsi_qla_host_t *vha = pci_get_drvdata(ha->pdev); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 346 | 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] | 347 | GFP_KERNEL); |
| 348 | if (!ha->req_q_map) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 349 | ql_log(ql_log_fatal, vha, 0x003b, |
| 350 | "Unable to allocate memory for request queue ptrs.\n"); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 351 | goto fail_req_map; |
| 352 | } |
| 353 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 354 | 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] | 355 | GFP_KERNEL); |
| 356 | if (!ha->rsp_q_map) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 357 | ql_log(ql_log_fatal, vha, 0x003c, |
| 358 | "Unable to allocate memory for response queue ptrs.\n"); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 359 | goto fail_rsp_map; |
| 360 | } |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 361 | |
| 362 | if (ql2xmqsupport && ha->max_qpairs) { |
| 363 | ha->queue_pair_map = kcalloc(ha->max_qpairs, sizeof(struct qla_qpair *), |
| 364 | GFP_KERNEL); |
| 365 | if (!ha->queue_pair_map) { |
| 366 | ql_log(ql_log_fatal, vha, 0x0180, |
| 367 | "Unable to allocate memory for queue pair ptrs.\n"); |
| 368 | goto fail_qpair_map; |
| 369 | } |
| 370 | ha->base_qpair = kzalloc(sizeof(struct qla_qpair), GFP_KERNEL); |
| 371 | if (ha->base_qpair == NULL) { |
| 372 | ql_log(ql_log_warn, vha, 0x0182, |
| 373 | "Failed to allocate base queue pair memory.\n"); |
| 374 | goto fail_base_qpair; |
| 375 | } |
| 376 | ha->base_qpair->req = req; |
| 377 | ha->base_qpair->rsp = rsp; |
| 378 | } |
| 379 | |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 380 | /* |
| 381 | * Make sure we record at least the request and response queue zero in |
| 382 | * case we need to free them if part of the probe fails. |
| 383 | */ |
| 384 | ha->rsp_q_map[0] = rsp; |
| 385 | ha->req_q_map[0] = req; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 386 | set_bit(0, ha->rsp_qid_map); |
| 387 | set_bit(0, ha->req_qid_map); |
| 388 | return 1; |
| 389 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 390 | fail_base_qpair: |
| 391 | kfree(ha->queue_pair_map); |
| 392 | fail_qpair_map: |
| 393 | kfree(ha->rsp_q_map); |
| 394 | ha->rsp_q_map = NULL; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 395 | fail_rsp_map: |
| 396 | kfree(ha->req_q_map); |
| 397 | ha->req_q_map = NULL; |
| 398 | fail_req_map: |
| 399 | return -ENOMEM; |
| 400 | } |
| 401 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 402 | 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] | 403 | { |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 404 | if (IS_QLAFX00(ha)) { |
| 405 | if (req && req->ring_fx00) |
| 406 | dma_free_coherent(&ha->pdev->dev, |
| 407 | (req->length_fx00 + 1) * sizeof(request_t), |
| 408 | req->ring_fx00, req->dma_fx00); |
| 409 | } else if (req && req->ring) |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 410 | dma_free_coherent(&ha->pdev->dev, |
| 411 | (req->length + 1) * sizeof(request_t), |
| 412 | req->ring, req->dma); |
| 413 | |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 414 | if (req) |
| 415 | kfree(req->outstanding_cmds); |
| 416 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 417 | kfree(req); |
| 418 | req = NULL; |
| 419 | } |
| 420 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 421 | static void qla2x00_free_rsp_que(struct qla_hw_data *ha, struct rsp_que *rsp) |
| 422 | { |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 423 | if (IS_QLAFX00(ha)) { |
| 424 | if (rsp && rsp->ring) |
| 425 | dma_free_coherent(&ha->pdev->dev, |
| 426 | (rsp->length_fx00 + 1) * sizeof(request_t), |
| 427 | rsp->ring_fx00, rsp->dma_fx00); |
| 428 | } else if (rsp && rsp->ring) { |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 429 | dma_free_coherent(&ha->pdev->dev, |
| 430 | (rsp->length + 1) * sizeof(response_t), |
| 431 | rsp->ring, rsp->dma); |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 432 | } |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 433 | kfree(rsp); |
| 434 | rsp = NULL; |
| 435 | } |
| 436 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 437 | static void qla2x00_free_queues(struct qla_hw_data *ha) |
| 438 | { |
| 439 | struct req_que *req; |
| 440 | struct rsp_que *rsp; |
| 441 | int cnt; |
| 442 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 443 | for (cnt = 0; cnt < ha->max_req_queues; cnt++) { |
Quinn Tran | cb43285 | 2016-02-04 11:45:16 -0500 | [diff] [blame] | 444 | if (!test_bit(cnt, ha->req_qid_map)) |
| 445 | continue; |
| 446 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 447 | req = ha->req_q_map[cnt]; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 448 | qla2x00_free_req_que(ha, req); |
| 449 | } |
| 450 | kfree(ha->req_q_map); |
| 451 | ha->req_q_map = NULL; |
| 452 | |
| 453 | for (cnt = 0; cnt < ha->max_rsp_queues; cnt++) { |
Quinn Tran | cb43285 | 2016-02-04 11:45:16 -0500 | [diff] [blame] | 454 | if (!test_bit(cnt, ha->rsp_qid_map)) |
| 455 | continue; |
| 456 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 457 | rsp = ha->rsp_q_map[cnt]; |
| 458 | qla2x00_free_rsp_que(ha, rsp); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 459 | } |
| 460 | kfree(ha->rsp_q_map); |
| 461 | ha->rsp_q_map = NULL; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 462 | } |
| 463 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 464 | static char * |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 465 | qla2x00_pci_info_str(struct scsi_qla_host *vha, char *str) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 466 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 467 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 468 | static char *pci_bus_modes[] = { |
| 469 | "33", "66", "100", "133", |
| 470 | }; |
| 471 | uint16_t pci_bus; |
| 472 | |
| 473 | strcpy(str, "PCI"); |
| 474 | pci_bus = (ha->pci_attr & (BIT_9 | BIT_10)) >> 9; |
| 475 | if (pci_bus) { |
| 476 | strcat(str, "-X ("); |
| 477 | strcat(str, pci_bus_modes[pci_bus]); |
| 478 | } else { |
| 479 | pci_bus = (ha->pci_attr & BIT_8) >> 8; |
| 480 | strcat(str, " ("); |
| 481 | strcat(str, pci_bus_modes[pci_bus]); |
| 482 | } |
| 483 | strcat(str, " MHz)"); |
| 484 | |
| 485 | return (str); |
| 486 | } |
| 487 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 488 | static char * |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 489 | qla24xx_pci_info_str(struct scsi_qla_host *vha, char *str) |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 490 | { |
| 491 | static char *pci_bus_modes[] = { "33", "66", "100", "133", }; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 492 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 493 | uint32_t pci_bus; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 494 | |
Bjorn Helgaas | 62a276f | 2013-09-06 11:26:24 -0600 | [diff] [blame] | 495 | if (pci_is_pcie(ha->pdev)) { |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 496 | char lwstr[6]; |
Bjorn Helgaas | 62a276f | 2013-09-06 11:26:24 -0600 | [diff] [blame] | 497 | uint32_t lstat, lspeed, lwidth; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 498 | |
Bjorn Helgaas | 62a276f | 2013-09-06 11:26:24 -0600 | [diff] [blame] | 499 | pcie_capability_read_dword(ha->pdev, PCI_EXP_LNKCAP, &lstat); |
| 500 | lspeed = lstat & PCI_EXP_LNKCAP_SLS; |
| 501 | lwidth = (lstat & PCI_EXP_LNKCAP_MLW) >> 4; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 502 | |
| 503 | strcpy(str, "PCIe ("); |
Saurav Kashyap | 49300af | 2012-11-21 02:40:34 -0500 | [diff] [blame] | 504 | switch (lspeed) { |
| 505 | case 1: |
Andrew Vasquez | c87a0d8 | 2008-04-03 13:13:21 -0700 | [diff] [blame] | 506 | strcat(str, "2.5GT/s "); |
Saurav Kashyap | 49300af | 2012-11-21 02:40:34 -0500 | [diff] [blame] | 507 | break; |
| 508 | case 2: |
Andrew Vasquez | c87a0d8 | 2008-04-03 13:13:21 -0700 | [diff] [blame] | 509 | strcat(str, "5.0GT/s "); |
Saurav Kashyap | 49300af | 2012-11-21 02:40:34 -0500 | [diff] [blame] | 510 | break; |
| 511 | case 3: |
| 512 | strcat(str, "8.0GT/s "); |
| 513 | break; |
| 514 | default: |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 515 | strcat(str, "<unknown> "); |
Saurav Kashyap | 49300af | 2012-11-21 02:40:34 -0500 | [diff] [blame] | 516 | break; |
| 517 | } |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 518 | snprintf(lwstr, sizeof(lwstr), "x%d)", lwidth); |
| 519 | strcat(str, lwstr); |
| 520 | |
| 521 | return str; |
| 522 | } |
| 523 | |
| 524 | strcpy(str, "PCI"); |
| 525 | pci_bus = (ha->pci_attr & CSRX_PCIX_BUS_MODE_MASK) >> 8; |
| 526 | if (pci_bus == 0 || pci_bus == 8) { |
| 527 | strcat(str, " ("); |
| 528 | strcat(str, pci_bus_modes[pci_bus >> 3]); |
| 529 | } else { |
| 530 | strcat(str, "-X "); |
| 531 | if (pci_bus & BIT_2) |
| 532 | strcat(str, "Mode 2"); |
| 533 | else |
| 534 | strcat(str, "Mode 1"); |
| 535 | strcat(str, " ("); |
| 536 | strcat(str, pci_bus_modes[pci_bus & ~BIT_2]); |
| 537 | } |
| 538 | strcat(str, " MHz)"); |
| 539 | |
| 540 | return str; |
| 541 | } |
| 542 | |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 543 | static char * |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 544 | 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] | 545 | { |
| 546 | char un_str[10]; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 547 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 548 | |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 549 | snprintf(str, size, "%d.%02d.%02d ", ha->fw_major_version, |
| 550 | ha->fw_minor_version, ha->fw_subminor_version); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 551 | |
| 552 | if (ha->fw_attributes & BIT_9) { |
| 553 | strcat(str, "FLX"); |
| 554 | return (str); |
| 555 | } |
| 556 | |
| 557 | switch (ha->fw_attributes & 0xFF) { |
| 558 | case 0x7: |
| 559 | strcat(str, "EF"); |
| 560 | break; |
| 561 | case 0x17: |
| 562 | strcat(str, "TP"); |
| 563 | break; |
| 564 | case 0x37: |
| 565 | strcat(str, "IP"); |
| 566 | break; |
| 567 | case 0x77: |
| 568 | strcat(str, "VI"); |
| 569 | break; |
| 570 | default: |
| 571 | sprintf(un_str, "(%x)", ha->fw_attributes); |
| 572 | strcat(str, un_str); |
| 573 | break; |
| 574 | } |
| 575 | if (ha->fw_attributes & 0x100) |
| 576 | strcat(str, "X"); |
| 577 | |
| 578 | return (str); |
| 579 | } |
| 580 | |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 581 | static char * |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 582 | 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] | 583 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 584 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | f0883ac | 2005-07-08 17:58:43 -0700 | [diff] [blame] | 585 | |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 586 | snprintf(str, size, "%d.%02d.%02d (%x)", ha->fw_major_version, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 587 | ha->fw_minor_version, ha->fw_subminor_version, ha->fw_attributes); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 588 | return str; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 589 | } |
| 590 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 591 | void |
| 592 | qla2x00_sp_free_dma(void *vha, void *ptr) |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 593 | { |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 594 | srb_t *sp = (srb_t *)ptr; |
| 595 | struct scsi_cmnd *cmd = GET_CMD_SP(sp); |
| 596 | struct qla_hw_data *ha = sp->fcport->vha->hw; |
| 597 | void *ctx = GET_CMD_CTX_SP(sp); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 598 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 599 | if (sp->flags & SRB_DMA_VALID) { |
| 600 | scsi_dma_unmap(cmd); |
| 601 | sp->flags &= ~SRB_DMA_VALID; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 602 | } |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 603 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 604 | if (sp->flags & SRB_CRC_PROT_DMA_VALID) { |
| 605 | dma_unmap_sg(&ha->pdev->dev, scsi_prot_sglist(cmd), |
| 606 | scsi_prot_sg_count(cmd), cmd->sc_data_direction); |
| 607 | sp->flags &= ~SRB_CRC_PROT_DMA_VALID; |
| 608 | } |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 609 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 610 | if (sp->flags & SRB_CRC_CTX_DSD_VALID) { |
| 611 | /* List assured to be having elements */ |
Quinn Tran | f83adb6 | 2014-04-11 16:54:43 -0400 | [diff] [blame] | 612 | qla2x00_clean_dsd_pool(ha, sp, NULL); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 613 | sp->flags &= ~SRB_CRC_CTX_DSD_VALID; |
| 614 | } |
| 615 | |
| 616 | if (sp->flags & SRB_CRC_CTX_DMA_VALID) { |
| 617 | dma_pool_free(ha->dl_dma_pool, ctx, |
| 618 | ((struct crc_context *)ctx)->crc_ctx_dma); |
| 619 | sp->flags &= ~SRB_CRC_CTX_DMA_VALID; |
| 620 | } |
| 621 | |
| 622 | if (sp->flags & SRB_FCP_CMND_DMA_VALID) { |
| 623 | struct ct6_dsd *ctx1 = (struct ct6_dsd *)ctx; |
| 624 | |
| 625 | dma_pool_free(ha->fcp_cmnd_dma_pool, ctx1->fcp_cmnd, |
| 626 | ctx1->fcp_cmnd_dma); |
| 627 | list_splice(&ctx1->dsd_list, &ha->gbl_dsd_list); |
| 628 | ha->gbl_dsd_inuse -= ctx1->dsd_use_cnt; |
| 629 | ha->gbl_dsd_avail += ctx1->dsd_use_cnt; |
| 630 | mempool_free(ctx1, ha->ctx_mempool); |
| 631 | ctx1 = NULL; |
| 632 | } |
| 633 | |
| 634 | CMD_SP(cmd) = NULL; |
Chad Dupuis | b00ee7d | 2013-02-08 01:57:50 -0500 | [diff] [blame] | 635 | qla2x00_rel_sp(sp->fcport->vha, sp); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 636 | } |
| 637 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 638 | void |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 639 | qla2x00_sp_compl(void *data, void *ptr, int res) |
| 640 | { |
| 641 | struct qla_hw_data *ha = (struct qla_hw_data *)data; |
| 642 | srb_t *sp = (srb_t *)ptr; |
| 643 | struct scsi_cmnd *cmd = GET_CMD_SP(sp); |
| 644 | |
| 645 | cmd->result = res; |
| 646 | |
| 647 | if (atomic_read(&sp->ref_count) == 0) { |
| 648 | ql_dbg(ql_dbg_io, sp->fcport->vha, 0x3015, |
| 649 | "SP reference-count to ZERO -- sp=%p cmd=%p.\n", |
| 650 | sp, GET_CMD_SP(sp)); |
| 651 | if (ql2xextended_error_logging & ql_dbg_io) |
Hiral Patel | 8fbdac8 | 2015-08-04 13:37:56 -0400 | [diff] [blame] | 652 | WARN_ON(atomic_read(&sp->ref_count) == 0); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 653 | return; |
| 654 | } |
| 655 | if (!atomic_dec_and_test(&sp->ref_count)) |
| 656 | return; |
| 657 | |
| 658 | qla2x00_sp_free_dma(ha, sp); |
| 659 | cmd->scsi_done(cmd); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 660 | } |
| 661 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 662 | void |
| 663 | qla2xxx_qpair_sp_free_dma(void *vha, void *ptr) |
| 664 | { |
| 665 | srb_t *sp = (srb_t *)ptr; |
| 666 | struct scsi_cmnd *cmd = GET_CMD_SP(sp); |
| 667 | struct qla_hw_data *ha = sp->fcport->vha->hw; |
| 668 | void *ctx = GET_CMD_CTX_SP(sp); |
| 669 | |
| 670 | if (sp->flags & SRB_DMA_VALID) { |
| 671 | scsi_dma_unmap(cmd); |
| 672 | sp->flags &= ~SRB_DMA_VALID; |
| 673 | } |
| 674 | |
| 675 | if (sp->flags & SRB_CRC_PROT_DMA_VALID) { |
| 676 | dma_unmap_sg(&ha->pdev->dev, scsi_prot_sglist(cmd), |
| 677 | scsi_prot_sg_count(cmd), cmd->sc_data_direction); |
| 678 | sp->flags &= ~SRB_CRC_PROT_DMA_VALID; |
| 679 | } |
| 680 | |
| 681 | if (sp->flags & SRB_CRC_CTX_DSD_VALID) { |
| 682 | /* List assured to be having elements */ |
| 683 | qla2x00_clean_dsd_pool(ha, sp, NULL); |
| 684 | sp->flags &= ~SRB_CRC_CTX_DSD_VALID; |
| 685 | } |
| 686 | |
| 687 | if (sp->flags & SRB_CRC_CTX_DMA_VALID) { |
| 688 | dma_pool_free(ha->dl_dma_pool, ctx, |
| 689 | ((struct crc_context *)ctx)->crc_ctx_dma); |
| 690 | sp->flags &= ~SRB_CRC_CTX_DMA_VALID; |
| 691 | } |
| 692 | |
| 693 | if (sp->flags & SRB_FCP_CMND_DMA_VALID) { |
| 694 | struct ct6_dsd *ctx1 = (struct ct6_dsd *)ctx; |
| 695 | |
| 696 | dma_pool_free(ha->fcp_cmnd_dma_pool, ctx1->fcp_cmnd, |
| 697 | ctx1->fcp_cmnd_dma); |
| 698 | list_splice(&ctx1->dsd_list, &ha->gbl_dsd_list); |
| 699 | ha->gbl_dsd_inuse -= ctx1->dsd_use_cnt; |
| 700 | ha->gbl_dsd_avail += ctx1->dsd_use_cnt; |
| 701 | mempool_free(ctx1, ha->ctx_mempool); |
| 702 | } |
| 703 | |
| 704 | CMD_SP(cmd) = NULL; |
| 705 | qla2xxx_rel_qpair_sp(sp->qpair, sp); |
| 706 | } |
| 707 | |
| 708 | void |
| 709 | qla2xxx_qpair_sp_compl(void *data, void *ptr, int res) |
| 710 | { |
| 711 | srb_t *sp = (srb_t *)ptr; |
| 712 | struct scsi_cmnd *cmd = GET_CMD_SP(sp); |
| 713 | |
| 714 | cmd->result = res; |
| 715 | |
| 716 | if (atomic_read(&sp->ref_count) == 0) { |
| 717 | ql_dbg(ql_dbg_io, sp->fcport->vha, 0x3079, |
| 718 | "SP reference-count to ZERO -- sp=%p cmd=%p.\n", |
| 719 | sp, GET_CMD_SP(sp)); |
| 720 | if (ql2xextended_error_logging & ql_dbg_io) |
| 721 | WARN_ON(atomic_read(&sp->ref_count) == 0); |
| 722 | return; |
| 723 | } |
| 724 | if (!atomic_dec_and_test(&sp->ref_count)) |
| 725 | return; |
| 726 | |
| 727 | qla2xxx_qpair_sp_free_dma(sp->fcport->vha, sp); |
| 728 | cmd->scsi_done(cmd); |
| 729 | } |
| 730 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 731 | /* If we are SP1 here, we need to still take and release the host_lock as SP1 |
| 732 | * does not have the changes necessary to avoid taking host->host_lock. |
| 733 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 734 | static int |
Madhuranath Iyengar | f5e3e40 | 2011-02-23 15:27:06 -0800 | [diff] [blame] | 735 | qla2xxx_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 736 | { |
Madhuranath Iyengar | 134ae07 | 2011-05-10 11:30:08 -0700 | [diff] [blame] | 737 | scsi_qla_host_t *vha = shost_priv(host); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 738 | fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 739 | struct fc_rport *rport = starget_to_rport(scsi_target(cmd->device)); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 740 | struct qla_hw_data *ha = vha->hw; |
| 741 | struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 742 | srb_t *sp; |
| 743 | int rval; |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame^] | 744 | struct qla_qpair *qpair = NULL; |
| 745 | uint32_t tag; |
| 746 | uint16_t hwq; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 747 | |
Mauricio Faria de Oliveira | 04dfaa5 | 2016-11-07 17:53:30 -0200 | [diff] [blame] | 748 | if (unlikely(test_bit(UNLOADING, &base_vha->dpc_flags))) { |
| 749 | cmd->result = DID_NO_CONNECT << 16; |
| 750 | goto qc24_fail_command; |
| 751 | } |
| 752 | |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame^] | 753 | if (ha->mqenable) { |
| 754 | if (shost_use_blk_mq(vha->host)) { |
| 755 | tag = blk_mq_unique_tag(cmd->request); |
| 756 | hwq = blk_mq_unique_tag_to_hwq(tag); |
| 757 | qpair = ha->queue_pair_map[hwq]; |
| 758 | } else if (vha->vp_idx && vha->qpair) { |
| 759 | qpair = vha->qpair; |
| 760 | } |
| 761 | |
| 762 | if (qpair) |
| 763 | return qla2xxx_mqueuecommand(host, cmd, qpair); |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 764 | } |
| 765 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 766 | if (ha->flags.eeh_busy) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 767 | if (ha->flags.pci_channel_io_perm_failure) { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 768 | ql_dbg(ql_dbg_aer, vha, 0x9010, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 769 | "PCI Channel IO permanent failure, exiting " |
| 770 | "cmd=%p.\n", cmd); |
Seokmann Ju | b9b12f7 | 2009-03-24 09:08:18 -0700 | [diff] [blame] | 771 | cmd->result = DID_NO_CONNECT << 16; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 772 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 773 | ql_dbg(ql_dbg_aer, vha, 0x9011, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 774 | "EEH_Busy, Requeuing the cmd=%p.\n", cmd); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 775 | cmd->result = DID_REQUEUE << 16; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 776 | } |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 777 | goto qc24_fail_command; |
| 778 | } |
| 779 | |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 780 | rval = fc_remote_port_chkready(rport); |
| 781 | if (rval) { |
| 782 | cmd->result = rval; |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 783 | ql_dbg(ql_dbg_io + ql_dbg_verbose, vha, 0x3003, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 784 | "fc_remote_port_chkready failed for cmd=%p, rval=0x%x.\n", |
| 785 | cmd, rval); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 786 | goto qc24_fail_command; |
| 787 | } |
| 788 | |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 789 | if (!vha->flags.difdix_supported && |
| 790 | scsi_get_prot_op(cmd) != SCSI_PROT_NORMAL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 791 | ql_dbg(ql_dbg_io, vha, 0x3004, |
| 792 | "DIF Cap not reg, fail DIF capable cmd's:%p.\n", |
| 793 | cmd); |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 794 | cmd->result = DID_NO_CONNECT << 16; |
| 795 | goto qc24_fail_command; |
| 796 | } |
Chad Dupuis | aa651be | 2012-02-09 11:14:04 -0800 | [diff] [blame] | 797 | |
| 798 | if (!fcport) { |
| 799 | cmd->result = DID_NO_CONNECT << 16; |
| 800 | goto qc24_fail_command; |
| 801 | } |
| 802 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 803 | if (atomic_read(&fcport->state) != FCS_ONLINE) { |
| 804 | if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD || |
Giridhar Malavali | 38170fa | 2010-10-15 11:27:49 -0700 | [diff] [blame] | 805 | atomic_read(&base_vha->loop_state) == LOOP_DEAD) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 806 | ql_dbg(ql_dbg_io, vha, 0x3005, |
| 807 | "Returning DNC, fcport_state=%d loop_state=%d.\n", |
| 808 | atomic_read(&fcport->state), |
| 809 | atomic_read(&base_vha->loop_state)); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 810 | cmd->result = DID_NO_CONNECT << 16; |
| 811 | goto qc24_fail_command; |
| 812 | } |
Mike Christie | 7b59413 | 2008-08-17 15:24:40 -0500 | [diff] [blame] | 813 | goto qc24_target_busy; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 814 | } |
| 815 | |
Chad Dupuis | e05fe29 | 2014-09-25 05:16:59 -0400 | [diff] [blame] | 816 | /* |
| 817 | * Return target busy if we've received a non-zero retry_delay_timer |
| 818 | * in a FCP_RSP. |
| 819 | */ |
Bruno Prémont | 975f7d4 | 2014-12-19 10:29:16 +0100 | [diff] [blame] | 820 | if (fcport->retry_delay_timestamp == 0) { |
| 821 | /* retry delay not set */ |
| 822 | } else if (time_after(jiffies, fcport->retry_delay_timestamp)) |
Chad Dupuis | e05fe29 | 2014-09-25 05:16:59 -0400 | [diff] [blame] | 823 | fcport->retry_delay_timestamp = 0; |
| 824 | else |
| 825 | goto qc24_target_busy; |
| 826 | |
Chad Dupuis | b00ee7d | 2013-02-08 01:57:50 -0500 | [diff] [blame] | 827 | sp = qla2x00_get_sp(vha, fcport, GFP_ATOMIC); |
Chad Dupuis | 50280c0 | 2013-10-30 03:38:14 -0400 | [diff] [blame] | 828 | if (!sp) |
Madhuranath Iyengar | f5e3e40 | 2011-02-23 15:27:06 -0800 | [diff] [blame] | 829 | goto qc24_host_busy; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 830 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 831 | sp->u.scmd.cmd = cmd; |
| 832 | sp->type = SRB_SCSI_CMD; |
| 833 | atomic_set(&sp->ref_count, 1); |
| 834 | CMD_SP(cmd) = (void *)sp; |
| 835 | sp->free = qla2x00_sp_free_dma; |
| 836 | sp->done = qla2x00_sp_compl; |
| 837 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 838 | rval = ha->isp_ops->start_scsi(sp); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 839 | if (rval != QLA_SUCCESS) { |
Chad Dupuis | 53016ed | 2012-11-21 02:40:32 -0500 | [diff] [blame] | 840 | ql_dbg(ql_dbg_io + ql_dbg_verbose, vha, 0x3013, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 841 | "Start scsi failed rval=%d for cmd=%p.\n", rval, cmd); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 842 | goto qc24_host_busy_free_sp; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 843 | } |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 844 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 845 | return 0; |
| 846 | |
| 847 | qc24_host_busy_free_sp: |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 848 | qla2x00_sp_free_dma(ha, sp); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 849 | |
Madhuranath Iyengar | f5e3e40 | 2011-02-23 15:27:06 -0800 | [diff] [blame] | 850 | qc24_host_busy: |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 851 | return SCSI_MLQUEUE_HOST_BUSY; |
| 852 | |
Mike Christie | 7b59413 | 2008-08-17 15:24:40 -0500 | [diff] [blame] | 853 | qc24_target_busy: |
| 854 | return SCSI_MLQUEUE_TARGET_BUSY; |
| 855 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 856 | qc24_fail_command: |
Madhuranath Iyengar | f5e3e40 | 2011-02-23 15:27:06 -0800 | [diff] [blame] | 857 | cmd->scsi_done(cmd); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 858 | |
| 859 | return 0; |
| 860 | } |
| 861 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 862 | /* For MQ supported I/O */ |
| 863 | int |
| 864 | qla2xxx_mqueuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd, |
| 865 | struct qla_qpair *qpair) |
| 866 | { |
| 867 | scsi_qla_host_t *vha = shost_priv(host); |
| 868 | fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; |
| 869 | struct fc_rport *rport = starget_to_rport(scsi_target(cmd->device)); |
| 870 | struct qla_hw_data *ha = vha->hw; |
| 871 | struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); |
| 872 | srb_t *sp; |
| 873 | int rval; |
| 874 | |
| 875 | rval = fc_remote_port_chkready(rport); |
| 876 | if (rval) { |
| 877 | cmd->result = rval; |
| 878 | ql_dbg(ql_dbg_io + ql_dbg_verbose, vha, 0x3076, |
| 879 | "fc_remote_port_chkready failed for cmd=%p, rval=0x%x.\n", |
| 880 | cmd, rval); |
| 881 | goto qc24_fail_command; |
| 882 | } |
| 883 | |
| 884 | if (!fcport) { |
| 885 | cmd->result = DID_NO_CONNECT << 16; |
| 886 | goto qc24_fail_command; |
| 887 | } |
| 888 | |
| 889 | if (atomic_read(&fcport->state) != FCS_ONLINE) { |
| 890 | if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD || |
| 891 | atomic_read(&base_vha->loop_state) == LOOP_DEAD) { |
| 892 | ql_dbg(ql_dbg_io, vha, 0x3077, |
| 893 | "Returning DNC, fcport_state=%d loop_state=%d.\n", |
| 894 | atomic_read(&fcport->state), |
| 895 | atomic_read(&base_vha->loop_state)); |
| 896 | cmd->result = DID_NO_CONNECT << 16; |
| 897 | goto qc24_fail_command; |
| 898 | } |
| 899 | goto qc24_target_busy; |
| 900 | } |
| 901 | |
| 902 | /* |
| 903 | * Return target busy if we've received a non-zero retry_delay_timer |
| 904 | * in a FCP_RSP. |
| 905 | */ |
| 906 | if (fcport->retry_delay_timestamp == 0) { |
| 907 | /* retry delay not set */ |
| 908 | } else if (time_after(jiffies, fcport->retry_delay_timestamp)) |
| 909 | fcport->retry_delay_timestamp = 0; |
| 910 | else |
| 911 | goto qc24_target_busy; |
| 912 | |
| 913 | sp = qla2xxx_get_qpair_sp(qpair, fcport, GFP_ATOMIC); |
| 914 | if (!sp) |
| 915 | goto qc24_host_busy; |
| 916 | |
| 917 | sp->u.scmd.cmd = cmd; |
| 918 | sp->type = SRB_SCSI_CMD; |
| 919 | atomic_set(&sp->ref_count, 1); |
| 920 | CMD_SP(cmd) = (void *)sp; |
| 921 | sp->free = qla2xxx_qpair_sp_free_dma; |
| 922 | sp->done = qla2xxx_qpair_sp_compl; |
| 923 | sp->qpair = qpair; |
| 924 | |
| 925 | rval = ha->isp_ops->start_scsi_mq(sp); |
| 926 | if (rval != QLA_SUCCESS) { |
| 927 | ql_dbg(ql_dbg_io + ql_dbg_verbose, vha, 0x3078, |
| 928 | "Start scsi failed rval=%d for cmd=%p.\n", rval, cmd); |
| 929 | if (rval == QLA_INTERFACE_ERROR) |
| 930 | goto qc24_fail_command; |
| 931 | goto qc24_host_busy_free_sp; |
| 932 | } |
| 933 | |
| 934 | return 0; |
| 935 | |
| 936 | qc24_host_busy_free_sp: |
| 937 | qla2xxx_qpair_sp_free_dma(vha, sp); |
| 938 | |
| 939 | qc24_host_busy: |
| 940 | return SCSI_MLQUEUE_HOST_BUSY; |
| 941 | |
| 942 | qc24_target_busy: |
| 943 | return SCSI_MLQUEUE_TARGET_BUSY; |
| 944 | |
| 945 | qc24_fail_command: |
| 946 | cmd->scsi_done(cmd); |
| 947 | |
| 948 | return 0; |
| 949 | } |
| 950 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 951 | /* |
| 952 | * qla2x00_eh_wait_on_command |
| 953 | * Waits for the command to be returned by the Firmware for some |
| 954 | * max time. |
| 955 | * |
| 956 | * Input: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 957 | * cmd = Scsi Command to wait on. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 958 | * |
| 959 | * Return: |
| 960 | * Not Found : 0 |
| 961 | * Found : 1 |
| 962 | */ |
| 963 | static int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 964 | qla2x00_eh_wait_on_command(struct scsi_cmnd *cmd) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 965 | { |
Andrew Vasquez | fe74c71 | 2005-08-26 19:10:10 -0700 | [diff] [blame] | 966 | #define ABORT_POLLING_PERIOD 1000 |
Chad Dupuis | 478c3b0 | 2014-04-11 16:54:35 -0400 | [diff] [blame] | 967 | #define ABORT_WAIT_ITER ((2 * 1000) / (ABORT_POLLING_PERIOD)) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 968 | unsigned long wait_iter = ABORT_WAIT_ITER; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 969 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| 970 | struct qla_hw_data *ha = vha->hw; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 971 | int ret = QLA_SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 972 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 973 | if (unlikely(pci_channel_offline(ha->pdev)) || ha->flags.eeh_busy) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 974 | ql_dbg(ql_dbg_taskm, vha, 0x8005, |
| 975 | "Return:eh_wait.\n"); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 976 | return ret; |
| 977 | } |
| 978 | |
Lalit Chandivade | d970432 | 2009-08-25 11:36:18 -0700 | [diff] [blame] | 979 | while (CMD_SP(cmd) && wait_iter--) { |
Andrew Vasquez | fe74c71 | 2005-08-26 19:10:10 -0700 | [diff] [blame] | 980 | msleep(ABORT_POLLING_PERIOD); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 981 | } |
| 982 | if (CMD_SP(cmd)) |
| 983 | ret = QLA_FUNCTION_FAILED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 984 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 985 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 986 | } |
| 987 | |
| 988 | /* |
| 989 | * qla2x00_wait_for_hba_online |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 990 | * Wait till the HBA is online after going through |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 991 | * <= MAX_RETRIES_OF_ISP_ABORT or |
| 992 | * finally HBA is disabled ie marked offline |
| 993 | * |
| 994 | * Input: |
| 995 | * ha - pointer to host adapter structure |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 996 | * |
| 997 | * Note: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 998 | * Does context switching-Release SPIN_LOCK |
| 999 | * (if any) before calling this routine. |
| 1000 | * |
| 1001 | * Return: |
| 1002 | * Success (Adapter is online) : 0 |
| 1003 | * Failed (Adapter is offline/disabled) : 1 |
| 1004 | */ |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 1005 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1006 | qla2x00_wait_for_hba_online(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1007 | { |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 1008 | int return_status; |
| 1009 | unsigned long wait_online; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1010 | struct qla_hw_data *ha = vha->hw; |
| 1011 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1012 | |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1013 | wait_online = jiffies + (MAX_LOOP_TIMEOUT * HZ); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1014 | while (((test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags)) || |
| 1015 | test_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags) || |
| 1016 | test_bit(ISP_ABORT_RETRY, &base_vha->dpc_flags) || |
| 1017 | ha->dpc_active) && time_before(jiffies, wait_online)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1018 | |
| 1019 | msleep(1000); |
| 1020 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1021 | if (base_vha->flags.online) |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1022 | return_status = QLA_SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1023 | else |
| 1024 | return_status = QLA_FUNCTION_FAILED; |
| 1025 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1026 | return (return_status); |
| 1027 | } |
| 1028 | |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 1029 | /* |
Sawan Chandak | 638a1a0 | 2014-04-11 16:54:38 -0400 | [diff] [blame] | 1030 | * qla2x00_wait_for_hba_ready |
| 1031 | * Wait till the HBA is ready before doing driver unload |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 1032 | * |
| 1033 | * Input: |
| 1034 | * ha - pointer to host adapter structure |
| 1035 | * |
| 1036 | * Note: |
| 1037 | * Does context switching-Release SPIN_LOCK |
| 1038 | * (if any) before calling this routine. |
| 1039 | * |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 1040 | */ |
Sawan Chandak | 638a1a0 | 2014-04-11 16:54:38 -0400 | [diff] [blame] | 1041 | static void |
| 1042 | qla2x00_wait_for_hba_ready(scsi_qla_host_t *vha) |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 1043 | { |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 1044 | struct qla_hw_data *ha = vha->hw; |
Sawan Chandak | 783e0dc | 2016-07-06 11:14:25 -0400 | [diff] [blame] | 1045 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 1046 | |
Dan Carpenter | 1d48390 | 2016-08-03 21:42:32 +0300 | [diff] [blame] | 1047 | while ((qla2x00_reset_active(vha) || ha->dpc_active || |
| 1048 | ha->flags.mbox_busy) || |
| 1049 | test_bit(FX00_RESET_RECOVERY, &vha->dpc_flags) || |
| 1050 | test_bit(FX00_TARGET_SCAN, &vha->dpc_flags)) { |
| 1051 | if (test_bit(UNLOADING, &base_vha->dpc_flags)) |
| 1052 | break; |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 1053 | msleep(1000); |
Sawan Chandak | 783e0dc | 2016-07-06 11:14:25 -0400 | [diff] [blame] | 1054 | } |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 1055 | } |
| 1056 | |
Lalit Chandivade | 2533cf6 | 2009-03-24 09:08:07 -0700 | [diff] [blame] | 1057 | int |
| 1058 | qla2x00_wait_for_chip_reset(scsi_qla_host_t *vha) |
| 1059 | { |
| 1060 | int return_status; |
| 1061 | unsigned long wait_reset; |
| 1062 | struct qla_hw_data *ha = vha->hw; |
| 1063 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 1064 | |
| 1065 | wait_reset = jiffies + (MAX_LOOP_TIMEOUT * HZ); |
| 1066 | while (((test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags)) || |
| 1067 | test_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags) || |
| 1068 | test_bit(ISP_ABORT_RETRY, &base_vha->dpc_flags) || |
| 1069 | ha->dpc_active) && time_before(jiffies, wait_reset)) { |
| 1070 | |
| 1071 | msleep(1000); |
| 1072 | |
| 1073 | if (!test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags) && |
| 1074 | ha->flags.chip_reset_done) |
| 1075 | break; |
| 1076 | } |
| 1077 | if (ha->flags.chip_reset_done) |
| 1078 | return_status = QLA_SUCCESS; |
| 1079 | else |
| 1080 | return_status = QLA_FUNCTION_FAILED; |
| 1081 | |
| 1082 | return return_status; |
| 1083 | } |
| 1084 | |
Giridhar Malavali | 083a469 | 2010-05-28 15:08:18 -0700 | [diff] [blame] | 1085 | static void |
| 1086 | sp_get(struct srb *sp) |
| 1087 | { |
| 1088 | atomic_inc(&sp->ref_count); |
| 1089 | } |
| 1090 | |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 1091 | #define ISP_REG_DISCONNECT 0xffffffffU |
| 1092 | /************************************************************************** |
| 1093 | * qla2x00_isp_reg_stat |
| 1094 | * |
| 1095 | * Description: |
| 1096 | * Read the host status register of ISP before aborting the command. |
| 1097 | * |
| 1098 | * Input: |
| 1099 | * ha = pointer to host adapter structure. |
| 1100 | * |
| 1101 | * |
| 1102 | * Returns: |
| 1103 | * Either true or false. |
| 1104 | * |
| 1105 | * Note: Return true if there is register disconnect. |
| 1106 | **************************************************************************/ |
| 1107 | static inline |
| 1108 | uint32_t qla2x00_isp_reg_stat(struct qla_hw_data *ha) |
| 1109 | { |
| 1110 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
| 1111 | |
| 1112 | return ((RD_REG_DWORD(®->host_status)) == ISP_REG_DISCONNECT); |
| 1113 | } |
| 1114 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1115 | /************************************************************************** |
| 1116 | * qla2xxx_eh_abort |
| 1117 | * |
| 1118 | * Description: |
| 1119 | * The abort function will abort the specified command. |
| 1120 | * |
| 1121 | * Input: |
| 1122 | * cmd = Linux SCSI command packet to be aborted. |
| 1123 | * |
| 1124 | * Returns: |
| 1125 | * Either SUCCESS or FAILED. |
| 1126 | * |
| 1127 | * Note: |
Michael Reed | 2ea0020 | 2006-04-27 16:25:30 -0700 | [diff] [blame] | 1128 | * Only return FAILED if command not returned by firmware. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1129 | **************************************************************************/ |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 1130 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1131 | qla2xxx_eh_abort(struct scsi_cmnd *cmd) |
| 1132 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1133 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1134 | srb_t *sp; |
Andrew Vasquez | 4e98d3b | 2011-02-23 15:27:17 -0800 | [diff] [blame] | 1135 | int ret; |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1136 | unsigned int id; |
| 1137 | uint64_t lun; |
Andrew Vasquez | 18e144d | 2005-05-27 15:04:47 -0700 | [diff] [blame] | 1138 | unsigned long flags; |
Chad Dupuis | f934c9d | 2014-04-11 16:54:31 -0400 | [diff] [blame] | 1139 | int rval, wait = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1140 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1141 | |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 1142 | if (qla2x00_isp_reg_stat(ha)) { |
| 1143 | ql_log(ql_log_info, vha, 0x8042, |
| 1144 | "PCI/Register disconnect, exiting.\n"); |
| 1145 | return FAILED; |
| 1146 | } |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1147 | if (!CMD_SP(cmd)) |
Michael Reed | 2ea0020 | 2006-04-27 16:25:30 -0700 | [diff] [blame] | 1148 | return SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1149 | |
Andrew Vasquez | 4e98d3b | 2011-02-23 15:27:17 -0800 | [diff] [blame] | 1150 | ret = fc_block_scsi_eh(cmd); |
| 1151 | if (ret != 0) |
| 1152 | return ret; |
| 1153 | ret = SUCCESS; |
| 1154 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1155 | id = cmd->device->id; |
| 1156 | lun = cmd->device->lun; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1157 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1158 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 1159 | sp = (srb_t *) CMD_SP(cmd); |
| 1160 | if (!sp) { |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1161 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 1162 | return SUCCESS; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1163 | } |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 1164 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1165 | ql_dbg(ql_dbg_taskm, vha, 0x8002, |
Chad Dupuis | c7bc4ca | 2015-08-04 13:37:57 -0400 | [diff] [blame] | 1166 | "Aborting from RISC nexus=%ld:%d:%llu sp=%p cmd=%p handle=%x\n", |
| 1167 | vha->host_no, id, lun, sp, cmd, sp->handle); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 1168 | |
| 1169 | /* Get a reference to the sp and drop the lock.*/ |
| 1170 | sp_get(sp); |
| 1171 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1172 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Chad Dupuis | f934c9d | 2014-04-11 16:54:31 -0400 | [diff] [blame] | 1173 | rval = ha->isp_ops->abort_command(sp); |
| 1174 | if (rval) { |
Chad Dupuis | 9621942 | 2015-08-04 13:38:00 -0400 | [diff] [blame] | 1175 | if (rval == QLA_FUNCTION_PARAMETER_ERROR) |
Chad Dupuis | f934c9d | 2014-04-11 16:54:31 -0400 | [diff] [blame] | 1176 | ret = SUCCESS; |
Chad Dupuis | 9621942 | 2015-08-04 13:38:00 -0400 | [diff] [blame] | 1177 | else |
Chad Dupuis | f934c9d | 2014-04-11 16:54:31 -0400 | [diff] [blame] | 1178 | ret = FAILED; |
| 1179 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1180 | ql_dbg(ql_dbg_taskm, vha, 0x8003, |
Chad Dupuis | f934c9d | 2014-04-11 16:54:31 -0400 | [diff] [blame] | 1181 | "Abort command mbx failed cmd=%p, rval=%x.\n", cmd, rval); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 1182 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1183 | ql_dbg(ql_dbg_taskm, vha, 0x8004, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1184 | "Abort command mbx success cmd=%p.\n", cmd); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 1185 | wait = 1; |
| 1186 | } |
Saurav Kashyap | 7594206 | 2011-08-16 11:29:25 -0700 | [diff] [blame] | 1187 | |
| 1188 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1189 | sp->done(ha, sp, 0); |
Saurav Kashyap | 7594206 | 2011-08-16 11:29:25 -0700 | [diff] [blame] | 1190 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1191 | |
Chad Dupuis | bc91ade | 2011-08-16 11:29:26 -0700 | [diff] [blame] | 1192 | /* Did the command return during mailbox execution? */ |
| 1193 | if (ret == FAILED && !CMD_SP(cmd)) |
| 1194 | ret = SUCCESS; |
| 1195 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1196 | /* Wait for the command to be returned. */ |
Michael Reed | 2ea0020 | 2006-04-27 16:25:30 -0700 | [diff] [blame] | 1197 | if (wait) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1198 | if (qla2x00_eh_wait_on_command(cmd) != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1199 | ql_log(ql_log_warn, vha, 0x8006, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1200 | "Abort handler timed out cmd=%p.\n", cmd); |
Michael Reed | 2ea0020 | 2006-04-27 16:25:30 -0700 | [diff] [blame] | 1201 | ret = FAILED; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1202 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1203 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1204 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1205 | ql_log(ql_log_info, vha, 0x801c, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1206 | "Abort command issued nexus=%ld:%d:%llu -- %d %x.\n", |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1207 | vha->host_no, id, lun, wait, ret); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1208 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1209 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1210 | } |
| 1211 | |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1212 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1213 | 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] | 1214 | uint64_t l, enum nexus_wait_type type) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1215 | { |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1216 | int cnt, match, status; |
Andrew Vasquez | 18e144d | 2005-05-27 15:04:47 -0700 | [diff] [blame] | 1217 | unsigned long flags; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1218 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1219 | struct req_que *req; |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1220 | srb_t *sp; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1221 | struct scsi_cmnd *cmd; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1222 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1223 | status = QLA_SUCCESS; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1224 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1225 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 67c2e93 | 2009-04-06 22:33:42 -0700 | [diff] [blame] | 1226 | req = vha->req; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1227 | for (cnt = 1; status == QLA_SUCCESS && |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 1228 | cnt < req->num_outstanding_cmds; cnt++) { |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1229 | sp = req->outstanding_cmds[cnt]; |
| 1230 | if (!sp) |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1231 | continue; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1232 | if (sp->type != SRB_SCSI_CMD) |
Andrew Vasquez | cf53b06 | 2009-08-20 11:06:04 -0700 | [diff] [blame] | 1233 | continue; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1234 | if (vha->vp_idx != sp->fcport->vha->vp_idx) |
| 1235 | continue; |
| 1236 | match = 0; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1237 | cmd = GET_CMD_SP(sp); |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1238 | switch (type) { |
| 1239 | case WAIT_HOST: |
| 1240 | match = 1; |
| 1241 | break; |
| 1242 | case WAIT_TARGET: |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1243 | match = cmd->device->id == t; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1244 | break; |
| 1245 | case WAIT_LUN: |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1246 | match = (cmd->device->id == t && |
| 1247 | cmd->device->lun == l); |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1248 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1249 | } |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1250 | if (!match) |
| 1251 | continue; |
| 1252 | |
| 1253 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1254 | status = qla2x00_eh_wait_on_command(cmd); |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1255 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1256 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1257 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1258 | |
| 1259 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1260 | } |
| 1261 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1262 | static char *reset_errors[] = { |
| 1263 | "HBA not online", |
| 1264 | "HBA not ready", |
| 1265 | "Task management failed", |
| 1266 | "Waiting for command completions", |
| 1267 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1268 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1269 | static int |
| 1270 | __qla2xxx_eh_generic_reset(char *name, enum nexus_wait_type type, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1271 | 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] | 1272 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1273 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1274 | fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; |
| 1275 | int err; |
| 1276 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1277 | if (!fcport) { |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1278 | return FAILED; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1279 | } |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1280 | |
Andrew Vasquez | 4e98d3b | 2011-02-23 15:27:17 -0800 | [diff] [blame] | 1281 | err = fc_block_scsi_eh(cmd); |
| 1282 | if (err != 0) |
| 1283 | return err; |
| 1284 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1285 | ql_log(ql_log_info, vha, 0x8009, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1286 | "%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] | 1287 | cmd->device->id, cmd->device->lun, cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1288 | |
| 1289 | err = 0; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1290 | if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) { |
| 1291 | ql_log(ql_log_warn, vha, 0x800a, |
| 1292 | "Wait for hba online failed for cmd=%p.\n", cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1293 | goto eh_reset_failed; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1294 | } |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1295 | err = 2; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1296 | if (do_reset(fcport, cmd->device->lun, cmd->request->cpu + 1) |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1297 | != QLA_SUCCESS) { |
| 1298 | ql_log(ql_log_warn, vha, 0x800c, |
| 1299 | "do_reset failed for cmd=%p.\n", cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1300 | goto eh_reset_failed; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1301 | } |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1302 | err = 3; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1303 | if (qla2x00_eh_wait_for_pending_commands(vha, cmd->device->id, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1304 | cmd->device->lun, type) != QLA_SUCCESS) { |
| 1305 | ql_log(ql_log_warn, vha, 0x800d, |
Masanari Iida | d6a0358 | 2012-08-22 14:20:58 -0400 | [diff] [blame] | 1306 | "wait for pending cmds failed for cmd=%p.\n", cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1307 | goto eh_reset_failed; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1308 | } |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1309 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1310 | ql_log(ql_log_info, vha, 0x800e, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1311 | "%s RESET SUCCEEDED nexus:%ld:%d:%llu cmd=%p.\n", name, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1312 | vha->host_no, cmd->device->id, cmd->device->lun, cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1313 | |
| 1314 | return SUCCESS; |
| 1315 | |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1316 | eh_reset_failed: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1317 | ql_log(ql_log_info, vha, 0x800f, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1318 | "%s RESET FAILED: %s nexus=%ld:%d:%llu cmd=%p.\n", name, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1319 | reset_errors[err], vha->host_no, cmd->device->id, cmd->device->lun, |
| 1320 | cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1321 | return FAILED; |
| 1322 | } |
| 1323 | |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 1324 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1325 | qla2xxx_eh_device_reset(struct scsi_cmnd *cmd) |
| 1326 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1327 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| 1328 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1329 | |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 1330 | if (qla2x00_isp_reg_stat(ha)) { |
| 1331 | ql_log(ql_log_info, vha, 0x803e, |
| 1332 | "PCI/Register disconnect, exiting.\n"); |
| 1333 | return FAILED; |
| 1334 | } |
| 1335 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1336 | return __qla2xxx_eh_generic_reset("DEVICE", WAIT_LUN, cmd, |
| 1337 | ha->isp_ops->lun_reset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1338 | } |
| 1339 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1340 | static int |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1341 | qla2xxx_eh_target_reset(struct scsi_cmnd *cmd) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1342 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1343 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| 1344 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1345 | |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 1346 | if (qla2x00_isp_reg_stat(ha)) { |
| 1347 | ql_log(ql_log_info, vha, 0x803f, |
| 1348 | "PCI/Register disconnect, exiting.\n"); |
| 1349 | return FAILED; |
| 1350 | } |
| 1351 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1352 | return __qla2xxx_eh_generic_reset("TARGET", WAIT_TARGET, cmd, |
| 1353 | ha->isp_ops->target_reset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1354 | } |
| 1355 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1356 | /************************************************************************** |
| 1357 | * qla2xxx_eh_bus_reset |
| 1358 | * |
| 1359 | * Description: |
| 1360 | * The bus reset function will reset the bus and abort any executing |
| 1361 | * commands. |
| 1362 | * |
| 1363 | * Input: |
| 1364 | * cmd = Linux SCSI command packet of the command that cause the |
| 1365 | * bus reset. |
| 1366 | * |
| 1367 | * Returns: |
| 1368 | * SUCCESS/FAILURE (defined as macro in scsi.h). |
| 1369 | * |
| 1370 | **************************************************************************/ |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 1371 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1372 | qla2xxx_eh_bus_reset(struct scsi_cmnd *cmd) |
| 1373 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1374 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 1375 | fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1376 | int ret = FAILED; |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1377 | unsigned int id; |
| 1378 | uint64_t lun; |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 1379 | struct qla_hw_data *ha = vha->hw; |
| 1380 | |
| 1381 | if (qla2x00_isp_reg_stat(ha)) { |
| 1382 | ql_log(ql_log_info, vha, 0x8040, |
| 1383 | "PCI/Register disconnect, exiting.\n"); |
| 1384 | return FAILED; |
| 1385 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1386 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1387 | id = cmd->device->id; |
| 1388 | lun = cmd->device->lun; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1389 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1390 | if (!fcport) { |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1391 | return ret; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1392 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1393 | |
Andrew Vasquez | 4e98d3b | 2011-02-23 15:27:17 -0800 | [diff] [blame] | 1394 | ret = fc_block_scsi_eh(cmd); |
| 1395 | if (ret != 0) |
| 1396 | return ret; |
| 1397 | ret = FAILED; |
| 1398 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1399 | ql_log(ql_log_info, vha, 0x8012, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1400 | "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] | 1401 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1402 | if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1403 | ql_log(ql_log_fatal, vha, 0x8013, |
| 1404 | "Wait for hba online failed board disabled.\n"); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1405 | goto eh_bus_reset_done; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1406 | } |
| 1407 | |
Saurav Kashyap | ad53768 | 2011-11-18 09:02:09 -0800 | [diff] [blame] | 1408 | if (qla2x00_loop_reset(vha) == QLA_SUCCESS) |
| 1409 | ret = SUCCESS; |
| 1410 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1411 | if (ret == FAILED) |
| 1412 | goto eh_bus_reset_done; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1413 | |
Andrew Vasquez | 9a41a62 | 2005-09-20 13:25:53 -0700 | [diff] [blame] | 1414 | /* Flush outstanding commands. */ |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1415 | if (qla2x00_eh_wait_for_pending_commands(vha, 0, 0, WAIT_HOST) != |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1416 | QLA_SUCCESS) { |
| 1417 | ql_log(ql_log_warn, vha, 0x8014, |
| 1418 | "Wait for pending commands failed.\n"); |
Andrew Vasquez | 9a41a62 | 2005-09-20 13:25:53 -0700 | [diff] [blame] | 1419 | ret = FAILED; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1420 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1421 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1422 | eh_bus_reset_done: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1423 | ql_log(ql_log_warn, vha, 0x802b, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1424 | "BUS RESET %s nexus=%ld:%d:%llu.\n", |
Masanari Iida | d6a0358 | 2012-08-22 14:20:58 -0400 | [diff] [blame] | 1425 | (ret == FAILED) ? "FAILED" : "SUCCEEDED", vha->host_no, id, lun); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1426 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1427 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1428 | } |
| 1429 | |
| 1430 | /************************************************************************** |
| 1431 | * qla2xxx_eh_host_reset |
| 1432 | * |
| 1433 | * Description: |
| 1434 | * The reset function will reset the Adapter. |
| 1435 | * |
| 1436 | * Input: |
| 1437 | * cmd = Linux SCSI command packet of the command that cause the |
| 1438 | * adapter reset. |
| 1439 | * |
| 1440 | * Returns: |
| 1441 | * Either SUCCESS or FAILED. |
| 1442 | * |
| 1443 | * Note: |
| 1444 | **************************************************************************/ |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 1445 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1446 | qla2xxx_eh_host_reset(struct scsi_cmnd *cmd) |
| 1447 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1448 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1449 | struct qla_hw_data *ha = vha->hw; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1450 | int ret = FAILED; |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1451 | unsigned int id; |
| 1452 | uint64_t lun; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1453 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1454 | |
Sawan Chandak | a465537 | 2016-07-06 11:14:32 -0400 | [diff] [blame] | 1455 | if (qla2x00_isp_reg_stat(ha)) { |
| 1456 | ql_log(ql_log_info, vha, 0x8041, |
| 1457 | "PCI/Register disconnect, exiting.\n"); |
| 1458 | schedule_work(&ha->board_disable); |
| 1459 | return SUCCESS; |
| 1460 | } |
| 1461 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1462 | id = cmd->device->id; |
| 1463 | lun = cmd->device->lun; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1464 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1465 | ql_log(ql_log_info, vha, 0x8018, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1466 | "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] | 1467 | |
Chad Dupuis | 63ee707 | 2014-04-11 16:54:46 -0400 | [diff] [blame] | 1468 | /* |
| 1469 | * No point in issuing another reset if one is active. Also do not |
| 1470 | * attempt a reset if we are updating flash. |
| 1471 | */ |
| 1472 | if (qla2x00_reset_active(vha) || ha->optrom_state != QLA_SWAITING) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1473 | goto eh_host_reset_lock; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1474 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1475 | if (vha != base_vha) { |
| 1476 | if (qla2x00_vp_abort_isp(vha)) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1477 | goto eh_host_reset_lock; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1478 | } else { |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 1479 | if (IS_P3P_TYPE(vha->hw)) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1480 | if (!qla82xx_fcoe_ctx_reset(vha)) { |
| 1481 | /* Ctx reset success */ |
| 1482 | ret = SUCCESS; |
| 1483 | goto eh_host_reset_lock; |
| 1484 | } |
| 1485 | /* fall thru if ctx reset failed */ |
| 1486 | } |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 1487 | if (ha->wq) |
| 1488 | flush_workqueue(ha->wq); |
| 1489 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1490 | set_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1491 | if (ha->isp_ops->abort_isp(base_vha)) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1492 | clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
| 1493 | /* failed. schedule dpc to try */ |
| 1494 | set_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags); |
| 1495 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1496 | if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) { |
| 1497 | ql_log(ql_log_warn, vha, 0x802a, |
| 1498 | "wait for hba online failed.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1499 | goto eh_host_reset_lock; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1500 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1501 | } |
| 1502 | clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1503 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1504 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1505 | /* Waiting for command to be returned to OS.*/ |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1506 | if (qla2x00_eh_wait_for_pending_commands(vha, 0, 0, WAIT_HOST) == |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1507 | QLA_SUCCESS) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1508 | ret = SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1509 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1510 | eh_host_reset_lock: |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1511 | ql_log(ql_log_info, vha, 0x8017, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1512 | "ADAPTER RESET %s nexus=%ld:%d:%llu.\n", |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1513 | (ret == FAILED) ? "FAILED" : "SUCCEEDED", vha->host_no, id, lun); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1514 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1515 | return ret; |
| 1516 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1517 | |
| 1518 | /* |
| 1519 | * qla2x00_loop_reset |
| 1520 | * Issue loop reset. |
| 1521 | * |
| 1522 | * Input: |
| 1523 | * ha = adapter block pointer. |
| 1524 | * |
| 1525 | * Returns: |
| 1526 | * 0 = success |
| 1527 | */ |
Andrew Vasquez | a4722cf | 2008-01-17 09:02:12 -0800 | [diff] [blame] | 1528 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1529 | qla2x00_loop_reset(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1530 | { |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 1531 | int ret; |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 1532 | struct fc_port *fcport; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1533 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1534 | |
Armen Baloyan | 5854771 | 2013-08-27 01:37:33 -0400 | [diff] [blame] | 1535 | if (IS_QLAFX00(ha)) { |
| 1536 | return qlafx00_loop_reset(vha); |
| 1537 | } |
| 1538 | |
Giridhar Malavali | f4c496c | 2010-05-04 15:01:33 -0700 | [diff] [blame] | 1539 | if (ql2xtargetreset == 1 && ha->flags.enable_target_reset) { |
Andrew Vasquez | 55e5ed2 | 2010-02-18 10:07:25 -0800 | [diff] [blame] | 1540 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
| 1541 | if (fcport->port_type != FCT_TARGET) |
| 1542 | continue; |
| 1543 | |
| 1544 | ret = ha->isp_ops->target_reset(fcport, 0, 0); |
| 1545 | if (ret != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1546 | ql_dbg(ql_dbg_taskm, vha, 0x802c, |
Armen Baloyan | 5854771 | 2013-08-27 01:37:33 -0400 | [diff] [blame] | 1547 | "Bus Reset failed: Reset=%d " |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1548 | "d_id=%x.\n", ret, fcport->d_id.b24); |
Andrew Vasquez | 55e5ed2 | 2010-02-18 10:07:25 -0800 | [diff] [blame] | 1549 | } |
| 1550 | } |
| 1551 | } |
| 1552 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 1553 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1554 | if (ha->flags.enable_lip_full_login && !IS_CNA_CAPABLE(ha)) { |
Andrew Vasquez | 0b7e7c5 | 2013-02-08 01:57:42 -0500 | [diff] [blame] | 1555 | atomic_set(&vha->loop_state, LOOP_DOWN); |
| 1556 | atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME); |
| 1557 | qla2x00_mark_all_devices_lost(vha, 0); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1558 | ret = qla2x00_full_login_lip(vha); |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 1559 | if (ret != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1560 | ql_dbg(ql_dbg_taskm, vha, 0x802d, |
| 1561 | "full_login_lip=%d.\n", ret); |
Anirban Chakraborty | 749af3d | 2008-11-14 13:48:12 -0800 | [diff] [blame] | 1562 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1563 | } |
| 1564 | |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 1565 | if (ha->flags.enable_lip_reset) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1566 | ret = qla2x00_lip_reset(vha); |
Saurav Kashyap | ad53768 | 2011-11-18 09:02:09 -0800 | [diff] [blame] | 1567 | if (ret != QLA_SUCCESS) |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1568 | ql_dbg(ql_dbg_taskm, vha, 0x802e, |
| 1569 | "lip_reset failed (%d).\n", ret); |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 1570 | } |
| 1571 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1572 | /* 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] | 1573 | vha->marker_needed = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1574 | |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 1575 | return QLA_SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1576 | } |
| 1577 | |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1578 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1579 | qla2x00_abort_all_cmds(scsi_qla_host_t *vha, int res) |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1580 | { |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1581 | int que, cnt; |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1582 | unsigned long flags; |
| 1583 | srb_t *sp; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1584 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1585 | struct req_que *req; |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1586 | |
Arun Easi | c0cb449 | 2014-09-25 06:14:51 -0400 | [diff] [blame] | 1587 | qlt_host_reset_handler(ha); |
| 1588 | |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1589 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1590 | for (que = 0; que < ha->max_req_queues; que++) { |
Anirban Chakraborty | 29bdccb | 2009-01-08 15:41:08 -0800 | [diff] [blame] | 1591 | req = ha->req_q_map[que]; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1592 | if (!req) |
| 1593 | continue; |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 1594 | if (!req->outstanding_cmds) |
| 1595 | continue; |
| 1596 | for (cnt = 1; cnt < req->num_outstanding_cmds; cnt++) { |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1597 | sp = req->outstanding_cmds[cnt]; |
Andrew Vasquez | e612d46 | 2009-03-24 09:08:04 -0700 | [diff] [blame] | 1598 | if (sp) { |
Mauricio Faria de Oliveira | c733ab3 | 2016-11-14 19:26:22 -0200 | [diff] [blame] | 1599 | /* Don't abort commands in adapter during EEH |
| 1600 | * recovery as it's not accessible/responding. |
Mauricio Faria de Oliveira | 1535aa7 | 2016-11-07 17:53:31 -0200 | [diff] [blame] | 1601 | */ |
Mauricio Faria de Oliveira | c733ab3 | 2016-11-14 19:26:22 -0200 | [diff] [blame] | 1602 | if (!ha->flags.eeh_busy) { |
| 1603 | /* Get a reference to the sp and drop the lock. |
| 1604 | * The reference ensures this sp->done() call |
| 1605 | * - and not the call in qla2xxx_eh_abort() - |
| 1606 | * ends the SCSI command (with result 'res'). |
| 1607 | */ |
| 1608 | sp_get(sp); |
| 1609 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1610 | qla2xxx_eh_abort(GET_CMD_SP(sp)); |
| 1611 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1612 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1613 | req->outstanding_cmds[cnt] = NULL; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1614 | sp->done(vha, sp, res); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1615 | } |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1616 | } |
| 1617 | } |
| 1618 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1619 | } |
| 1620 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1621 | static int |
| 1622 | qla2xxx_slave_alloc(struct scsi_device *sdev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1623 | { |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 1624 | struct fc_rport *rport = starget_to_rport(scsi_target(sdev)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1625 | |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 1626 | if (!rport || fc_remote_port_chkready(rport)) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1627 | return -ENXIO; |
| 1628 | |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 1629 | sdev->hostdata = *(fc_port_t **)rport->dd_data; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1630 | |
| 1631 | return 0; |
| 1632 | } |
| 1633 | |
| 1634 | static int |
| 1635 | qla2xxx_slave_configure(struct scsi_device *sdev) |
| 1636 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1637 | scsi_qla_host_t *vha = shost_priv(sdev->host); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1638 | struct req_que *req = vha->req; |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 1639 | |
Arun Easi | 9e522cd | 2012-08-22 14:21:31 -0400 | [diff] [blame] | 1640 | if (IS_T10_PI_CAPABLE(vha->hw)) |
| 1641 | blk_queue_update_dma_alignment(sdev->request_queue, 0x7); |
| 1642 | |
Christoph Hellwig | db5ed4d | 2014-11-13 15:08:42 +0100 | [diff] [blame] | 1643 | scsi_change_queue_depth(sdev, req->max_q_depth); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1644 | return 0; |
| 1645 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1646 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1647 | static void |
| 1648 | qla2xxx_slave_destroy(struct scsi_device *sdev) |
| 1649 | { |
| 1650 | sdev->hostdata = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1651 | } |
| 1652 | |
| 1653 | /** |
| 1654 | * qla2x00_config_dma_addressing() - Configure OS DMA addressing method. |
| 1655 | * @ha: HA context |
| 1656 | * |
| 1657 | * At exit, the @ha's flags.enable_64bit_addressing set to indicated |
| 1658 | * supported addressing method. |
| 1659 | */ |
| 1660 | static void |
Andrew Vasquez | 53303c4 | 2009-01-22 09:45:37 -0800 | [diff] [blame] | 1661 | qla2x00_config_dma_addressing(struct qla_hw_data *ha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1662 | { |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1663 | /* Assume a 32bit DMA mask. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1664 | ha->flags.enable_64bit_addressing = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1665 | |
Yang Hongyang | 6a35528 | 2009-04-06 19:01:13 -0700 | [diff] [blame] | 1666 | if (!dma_set_mask(&ha->pdev->dev, DMA_BIT_MASK(64))) { |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1667 | /* Any upper-dword bits set? */ |
| 1668 | if (MSD(dma_get_required_mask(&ha->pdev->dev)) && |
Yang Hongyang | 6a35528 | 2009-04-06 19:01:13 -0700 | [diff] [blame] | 1669 | !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) { |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1670 | /* Ok, a 64bit DMA mask is applicable. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1671 | ha->flags.enable_64bit_addressing = 1; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1672 | ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64; |
| 1673 | ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64; |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1674 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1675 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1676 | } |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1677 | |
Yang Hongyang | 284901a | 2009-04-06 19:01:15 -0700 | [diff] [blame] | 1678 | dma_set_mask(&ha->pdev->dev, DMA_BIT_MASK(32)); |
| 1679 | pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(32)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1680 | } |
| 1681 | |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1682 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1683 | qla2x00_enable_intrs(struct qla_hw_data *ha) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1684 | { |
| 1685 | unsigned long flags = 0; |
| 1686 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
| 1687 | |
| 1688 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1689 | ha->interrupts_on = 1; |
| 1690 | /* enable risc and host interrupts */ |
| 1691 | WRT_REG_WORD(®->ictrl, ICR_EN_INT | ICR_EN_RISC); |
| 1692 | RD_REG_WORD(®->ictrl); |
| 1693 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1694 | |
| 1695 | } |
| 1696 | |
| 1697 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1698 | qla2x00_disable_intrs(struct qla_hw_data *ha) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1699 | { |
| 1700 | unsigned long flags = 0; |
| 1701 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
| 1702 | |
| 1703 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1704 | ha->interrupts_on = 0; |
| 1705 | /* disable risc and host interrupts */ |
| 1706 | WRT_REG_WORD(®->ictrl, 0); |
| 1707 | RD_REG_WORD(®->ictrl); |
| 1708 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1709 | } |
| 1710 | |
| 1711 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1712 | qla24xx_enable_intrs(struct qla_hw_data *ha) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1713 | { |
| 1714 | unsigned long flags = 0; |
| 1715 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
| 1716 | |
| 1717 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1718 | ha->interrupts_on = 1; |
| 1719 | WRT_REG_DWORD(®->ictrl, ICRX_EN_RISC_INT); |
| 1720 | RD_REG_DWORD(®->ictrl); |
| 1721 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1722 | } |
| 1723 | |
| 1724 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1725 | qla24xx_disable_intrs(struct qla_hw_data *ha) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1726 | { |
| 1727 | unsigned long flags = 0; |
| 1728 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
| 1729 | |
Andrew Vasquez | 124f85e | 2009-01-05 11:18:06 -0800 | [diff] [blame] | 1730 | if (IS_NOPOLLING_TYPE(ha)) |
| 1731 | return; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1732 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1733 | ha->interrupts_on = 0; |
| 1734 | WRT_REG_DWORD(®->ictrl, 0); |
| 1735 | RD_REG_DWORD(®->ictrl); |
| 1736 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1737 | } |
| 1738 | |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1739 | static int |
| 1740 | qla2x00_iospace_config(struct qla_hw_data *ha) |
| 1741 | { |
| 1742 | resource_size_t pio; |
| 1743 | uint16_t msix; |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1744 | |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1745 | if (pci_request_selected_regions(ha->pdev, ha->bars, |
| 1746 | QLA2XXX_DRIVER_NAME)) { |
| 1747 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0011, |
| 1748 | "Failed to reserve PIO/MMIO regions (%s), aborting.\n", |
| 1749 | pci_name(ha->pdev)); |
| 1750 | goto iospace_error_exit; |
| 1751 | } |
| 1752 | if (!(ha->bars & 1)) |
| 1753 | goto skip_pio; |
| 1754 | |
| 1755 | /* We only need PIO for Flash operations on ISP2312 v2 chips. */ |
| 1756 | pio = pci_resource_start(ha->pdev, 0); |
| 1757 | if (pci_resource_flags(ha->pdev, 0) & IORESOURCE_IO) { |
| 1758 | if (pci_resource_len(ha->pdev, 0) < MIN_IOBASE_LEN) { |
| 1759 | ql_log_pci(ql_log_warn, ha->pdev, 0x0012, |
| 1760 | "Invalid pci I/O region size (%s).\n", |
| 1761 | pci_name(ha->pdev)); |
| 1762 | pio = 0; |
| 1763 | } |
| 1764 | } else { |
| 1765 | ql_log_pci(ql_log_warn, ha->pdev, 0x0013, |
| 1766 | "Region #0 no a PIO resource (%s).\n", |
| 1767 | pci_name(ha->pdev)); |
| 1768 | pio = 0; |
| 1769 | } |
| 1770 | ha->pio_address = pio; |
| 1771 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0014, |
| 1772 | "PIO address=%llu.\n", |
| 1773 | (unsigned long long)ha->pio_address); |
| 1774 | |
| 1775 | skip_pio: |
| 1776 | /* Use MMIO operations for all accesses. */ |
| 1777 | if (!(pci_resource_flags(ha->pdev, 1) & IORESOURCE_MEM)) { |
| 1778 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0015, |
| 1779 | "Region #1 not an MMIO resource (%s), aborting.\n", |
| 1780 | pci_name(ha->pdev)); |
| 1781 | goto iospace_error_exit; |
| 1782 | } |
| 1783 | if (pci_resource_len(ha->pdev, 1) < MIN_IOBASE_LEN) { |
| 1784 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0016, |
| 1785 | "Invalid PCI mem region size (%s), aborting.\n", |
| 1786 | pci_name(ha->pdev)); |
| 1787 | goto iospace_error_exit; |
| 1788 | } |
| 1789 | |
| 1790 | ha->iobase = ioremap(pci_resource_start(ha->pdev, 1), MIN_IOBASE_LEN); |
| 1791 | if (!ha->iobase) { |
| 1792 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0017, |
| 1793 | "Cannot remap MMIO (%s), aborting.\n", |
| 1794 | pci_name(ha->pdev)); |
| 1795 | goto iospace_error_exit; |
| 1796 | } |
| 1797 | |
| 1798 | /* Determine queue resources */ |
| 1799 | ha->max_req_queues = ha->max_rsp_queues = 1; |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 1800 | if (!ql2xmqsupport || (!IS_QLA25XX(ha) && !IS_QLA81XX(ha))) |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1801 | goto mqiobase_exit; |
| 1802 | |
| 1803 | ha->mqiobase = ioremap(pci_resource_start(ha->pdev, 3), |
| 1804 | pci_resource_len(ha->pdev, 3)); |
| 1805 | if (ha->mqiobase) { |
| 1806 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0018, |
| 1807 | "MQIO Base=%p.\n", ha->mqiobase); |
| 1808 | /* Read MSIX vector size of the board */ |
| 1809 | pci_read_config_word(ha->pdev, QLA_PCI_MSIX_CONTROL, &msix); |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 1810 | ha->msix_count = msix + 1; |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1811 | /* Max queues are bounded by available msix vectors */ |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 1812 | /* MB interrupt uses 1 vector */ |
| 1813 | ha->max_req_queues = ha->msix_count - 1; |
| 1814 | ha->max_rsp_queues = ha->max_req_queues; |
| 1815 | /* Queue pairs is the max value minus the base queue pair */ |
| 1816 | ha->max_qpairs = ha->max_rsp_queues - 1; |
| 1817 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0188, |
| 1818 | "Max no of queues pairs: %d.\n", ha->max_qpairs); |
| 1819 | |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1820 | ql_log_pci(ql_log_info, ha->pdev, 0x001a, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 1821 | "MSI-X vector count: %d.\n", ha->msix_count); |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1822 | } else |
| 1823 | ql_log_pci(ql_log_info, ha->pdev, 0x001b, |
| 1824 | "BAR 3 not enabled.\n"); |
| 1825 | |
| 1826 | mqiobase_exit: |
| 1827 | ha->msix_count = ha->max_rsp_queues + 1; |
| 1828 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x001c, |
| 1829 | "MSIX Count:%d.\n", ha->msix_count); |
| 1830 | return (0); |
| 1831 | |
| 1832 | iospace_error_exit: |
| 1833 | return (-ENOMEM); |
| 1834 | } |
| 1835 | |
| 1836 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1837 | static int |
| 1838 | qla83xx_iospace_config(struct qla_hw_data *ha) |
| 1839 | { |
| 1840 | uint16_t msix; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1841 | |
| 1842 | if (pci_request_selected_regions(ha->pdev, ha->bars, |
| 1843 | QLA2XXX_DRIVER_NAME)) { |
| 1844 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0117, |
| 1845 | "Failed to reserve PIO/MMIO regions (%s), aborting.\n", |
| 1846 | pci_name(ha->pdev)); |
| 1847 | |
| 1848 | goto iospace_error_exit; |
| 1849 | } |
| 1850 | |
| 1851 | /* Use MMIO operations for all accesses. */ |
| 1852 | if (!(pci_resource_flags(ha->pdev, 0) & IORESOURCE_MEM)) { |
| 1853 | ql_log_pci(ql_log_warn, ha->pdev, 0x0118, |
| 1854 | "Invalid pci I/O region size (%s).\n", |
| 1855 | pci_name(ha->pdev)); |
| 1856 | goto iospace_error_exit; |
| 1857 | } |
| 1858 | if (pci_resource_len(ha->pdev, 0) < MIN_IOBASE_LEN) { |
| 1859 | ql_log_pci(ql_log_warn, ha->pdev, 0x0119, |
| 1860 | "Invalid PCI mem region size (%s), aborting\n", |
| 1861 | pci_name(ha->pdev)); |
| 1862 | goto iospace_error_exit; |
| 1863 | } |
| 1864 | |
| 1865 | ha->iobase = ioremap(pci_resource_start(ha->pdev, 0), MIN_IOBASE_LEN); |
| 1866 | if (!ha->iobase) { |
| 1867 | ql_log_pci(ql_log_fatal, ha->pdev, 0x011a, |
| 1868 | "Cannot remap MMIO (%s), aborting.\n", |
| 1869 | pci_name(ha->pdev)); |
| 1870 | goto iospace_error_exit; |
| 1871 | } |
| 1872 | |
| 1873 | /* 64bit PCI BAR - BAR2 will correspoond to region 4 */ |
| 1874 | /* 83XX 26XX always use MQ type access for queues |
| 1875 | * - mbar 2, a.k.a region 4 */ |
| 1876 | ha->max_req_queues = ha->max_rsp_queues = 1; |
| 1877 | ha->mqiobase = ioremap(pci_resource_start(ha->pdev, 4), |
| 1878 | pci_resource_len(ha->pdev, 4)); |
| 1879 | |
| 1880 | if (!ha->mqiobase) { |
| 1881 | ql_log_pci(ql_log_fatal, ha->pdev, 0x011d, |
| 1882 | "BAR2/region4 not enabled\n"); |
| 1883 | goto mqiobase_exit; |
| 1884 | } |
| 1885 | |
| 1886 | ha->msixbase = ioremap(pci_resource_start(ha->pdev, 2), |
| 1887 | pci_resource_len(ha->pdev, 2)); |
| 1888 | if (ha->msixbase) { |
| 1889 | /* Read MSIX vector size of the board */ |
| 1890 | pci_read_config_word(ha->pdev, |
| 1891 | QLA_83XX_PCI_MSIX_CONTROL, &msix); |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 1892 | ha->msix_count = msix + 1; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1893 | /* Max queues are bounded by available msix vectors */ |
| 1894 | /* queue 0 uses two msix vectors */ |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 1895 | if (ql2xmqsupport) { |
| 1896 | /* MB interrupt uses 1 vector */ |
| 1897 | ha->max_req_queues = ha->msix_count - 1; |
| 1898 | ha->max_rsp_queues = ha->max_req_queues; |
| 1899 | /* Queue pairs is the max value minus |
| 1900 | * the base queue pair */ |
| 1901 | ha->max_qpairs = ha->max_req_queues - 1; |
| 1902 | ql_dbg_pci(ql_dbg_multiq, ha->pdev, 0xc010, |
| 1903 | "Max no of queues pairs: %d.\n", ha->max_qpairs); |
| 1904 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0190, |
| 1905 | "Max no of queues pairs: %d.\n", ha->max_qpairs); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1906 | } |
| 1907 | ql_log_pci(ql_log_info, ha->pdev, 0x011c, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 1908 | "MSI-X vector count: %d.\n", ha->msix_count); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1909 | } else |
| 1910 | ql_log_pci(ql_log_info, ha->pdev, 0x011e, |
| 1911 | "BAR 1 not enabled.\n"); |
| 1912 | |
| 1913 | mqiobase_exit: |
| 1914 | ha->msix_count = ha->max_rsp_queues + 1; |
Arun Easi | aa230bc | 2013-01-30 03:34:39 -0500 | [diff] [blame] | 1915 | |
| 1916 | qlt_83xx_iospace_config(ha); |
| 1917 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1918 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x011f, |
| 1919 | "MSIX Count:%d.\n", ha->msix_count); |
| 1920 | return 0; |
| 1921 | |
| 1922 | iospace_error_exit: |
| 1923 | return -ENOMEM; |
| 1924 | } |
| 1925 | |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1926 | static struct isp_operations qla2100_isp_ops = { |
| 1927 | .pci_config = qla2100_pci_config, |
| 1928 | .reset_chip = qla2x00_reset_chip, |
| 1929 | .chip_diag = qla2x00_chip_diag, |
| 1930 | .config_rings = qla2x00_config_rings, |
| 1931 | .reset_adapter = qla2x00_reset_adapter, |
| 1932 | .nvram_config = qla2x00_nvram_config, |
| 1933 | .update_fw_options = qla2x00_update_fw_options, |
| 1934 | .load_risc = qla2x00_load_risc, |
| 1935 | .pci_info_str = qla2x00_pci_info_str, |
| 1936 | .fw_version_str = qla2x00_fw_version_str, |
| 1937 | .intr_handler = qla2100_intr_handler, |
| 1938 | .enable_intrs = qla2x00_enable_intrs, |
| 1939 | .disable_intrs = qla2x00_disable_intrs, |
| 1940 | .abort_command = qla2x00_abort_command, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1941 | .target_reset = qla2x00_abort_target, |
| 1942 | .lun_reset = qla2x00_lun_reset, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1943 | .fabric_login = qla2x00_login_fabric, |
| 1944 | .fabric_logout = qla2x00_fabric_logout, |
| 1945 | .calc_req_entries = qla2x00_calc_iocbs_32, |
| 1946 | .build_iocbs = qla2x00_build_scsi_iocbs_32, |
| 1947 | .prep_ms_iocb = qla2x00_prep_ms_iocb, |
| 1948 | .prep_ms_fdmi_iocb = qla2x00_prep_ms_fdmi_iocb, |
| 1949 | .read_nvram = qla2x00_read_nvram_data, |
| 1950 | .write_nvram = qla2x00_write_nvram_data, |
| 1951 | .fw_dump = qla2100_fw_dump, |
| 1952 | .beacon_on = NULL, |
| 1953 | .beacon_off = NULL, |
| 1954 | .beacon_blink = NULL, |
| 1955 | .read_optrom = qla2x00_read_optrom_data, |
| 1956 | .write_optrom = qla2x00_write_optrom_data, |
| 1957 | .get_flash_version = qla2x00_get_flash_version, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1958 | .start_scsi = qla2x00_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 1959 | .start_scsi_mq = NULL, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1960 | .abort_isp = qla2x00_abort_isp, |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1961 | .iospace_config = qla2x00_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 1962 | .initialize_adapter = qla2x00_initialize_adapter, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1963 | }; |
| 1964 | |
| 1965 | static struct isp_operations qla2300_isp_ops = { |
| 1966 | .pci_config = qla2300_pci_config, |
| 1967 | .reset_chip = qla2x00_reset_chip, |
| 1968 | .chip_diag = qla2x00_chip_diag, |
| 1969 | .config_rings = qla2x00_config_rings, |
| 1970 | .reset_adapter = qla2x00_reset_adapter, |
| 1971 | .nvram_config = qla2x00_nvram_config, |
| 1972 | .update_fw_options = qla2x00_update_fw_options, |
| 1973 | .load_risc = qla2x00_load_risc, |
| 1974 | .pci_info_str = qla2x00_pci_info_str, |
| 1975 | .fw_version_str = qla2x00_fw_version_str, |
| 1976 | .intr_handler = qla2300_intr_handler, |
| 1977 | .enable_intrs = qla2x00_enable_intrs, |
| 1978 | .disable_intrs = qla2x00_disable_intrs, |
| 1979 | .abort_command = qla2x00_abort_command, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1980 | .target_reset = qla2x00_abort_target, |
| 1981 | .lun_reset = qla2x00_lun_reset, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1982 | .fabric_login = qla2x00_login_fabric, |
| 1983 | .fabric_logout = qla2x00_fabric_logout, |
| 1984 | .calc_req_entries = qla2x00_calc_iocbs_32, |
| 1985 | .build_iocbs = qla2x00_build_scsi_iocbs_32, |
| 1986 | .prep_ms_iocb = qla2x00_prep_ms_iocb, |
| 1987 | .prep_ms_fdmi_iocb = qla2x00_prep_ms_fdmi_iocb, |
| 1988 | .read_nvram = qla2x00_read_nvram_data, |
| 1989 | .write_nvram = qla2x00_write_nvram_data, |
| 1990 | .fw_dump = qla2300_fw_dump, |
| 1991 | .beacon_on = qla2x00_beacon_on, |
| 1992 | .beacon_off = qla2x00_beacon_off, |
| 1993 | .beacon_blink = qla2x00_beacon_blink, |
| 1994 | .read_optrom = qla2x00_read_optrom_data, |
| 1995 | .write_optrom = qla2x00_write_optrom_data, |
| 1996 | .get_flash_version = qla2x00_get_flash_version, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1997 | .start_scsi = qla2x00_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 1998 | .start_scsi_mq = NULL, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1999 | .abort_isp = qla2x00_abort_isp, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2000 | .iospace_config = qla2x00_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2001 | .initialize_adapter = qla2x00_initialize_adapter, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2002 | }; |
| 2003 | |
| 2004 | static struct isp_operations qla24xx_isp_ops = { |
| 2005 | .pci_config = qla24xx_pci_config, |
| 2006 | .reset_chip = qla24xx_reset_chip, |
| 2007 | .chip_diag = qla24xx_chip_diag, |
| 2008 | .config_rings = qla24xx_config_rings, |
| 2009 | .reset_adapter = qla24xx_reset_adapter, |
| 2010 | .nvram_config = qla24xx_nvram_config, |
| 2011 | .update_fw_options = qla24xx_update_fw_options, |
| 2012 | .load_risc = qla24xx_load_risc, |
| 2013 | .pci_info_str = qla24xx_pci_info_str, |
| 2014 | .fw_version_str = qla24xx_fw_version_str, |
| 2015 | .intr_handler = qla24xx_intr_handler, |
| 2016 | .enable_intrs = qla24xx_enable_intrs, |
| 2017 | .disable_intrs = qla24xx_disable_intrs, |
| 2018 | .abort_command = qla24xx_abort_command, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 2019 | .target_reset = qla24xx_abort_target, |
| 2020 | .lun_reset = qla24xx_lun_reset, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2021 | .fabric_login = qla24xx_login_fabric, |
| 2022 | .fabric_logout = qla24xx_fabric_logout, |
| 2023 | .calc_req_entries = NULL, |
| 2024 | .build_iocbs = NULL, |
| 2025 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2026 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 2027 | .read_nvram = qla24xx_read_nvram_data, |
| 2028 | .write_nvram = qla24xx_write_nvram_data, |
| 2029 | .fw_dump = qla24xx_fw_dump, |
| 2030 | .beacon_on = qla24xx_beacon_on, |
| 2031 | .beacon_off = qla24xx_beacon_off, |
| 2032 | .beacon_blink = qla24xx_beacon_blink, |
| 2033 | .read_optrom = qla24xx_read_optrom_data, |
| 2034 | .write_optrom = qla24xx_write_optrom_data, |
| 2035 | .get_flash_version = qla24xx_get_flash_version, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2036 | .start_scsi = qla24xx_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2037 | .start_scsi_mq = NULL, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2038 | .abort_isp = qla2x00_abort_isp, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2039 | .iospace_config = qla2x00_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2040 | .initialize_adapter = qla2x00_initialize_adapter, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2041 | }; |
| 2042 | |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2043 | static struct isp_operations qla25xx_isp_ops = { |
| 2044 | .pci_config = qla25xx_pci_config, |
| 2045 | .reset_chip = qla24xx_reset_chip, |
| 2046 | .chip_diag = qla24xx_chip_diag, |
| 2047 | .config_rings = qla24xx_config_rings, |
| 2048 | .reset_adapter = qla24xx_reset_adapter, |
| 2049 | .nvram_config = qla24xx_nvram_config, |
| 2050 | .update_fw_options = qla24xx_update_fw_options, |
| 2051 | .load_risc = qla24xx_load_risc, |
| 2052 | .pci_info_str = qla24xx_pci_info_str, |
| 2053 | .fw_version_str = qla24xx_fw_version_str, |
| 2054 | .intr_handler = qla24xx_intr_handler, |
| 2055 | .enable_intrs = qla24xx_enable_intrs, |
| 2056 | .disable_intrs = qla24xx_disable_intrs, |
| 2057 | .abort_command = qla24xx_abort_command, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 2058 | .target_reset = qla24xx_abort_target, |
| 2059 | .lun_reset = qla24xx_lun_reset, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2060 | .fabric_login = qla24xx_login_fabric, |
| 2061 | .fabric_logout = qla24xx_fabric_logout, |
| 2062 | .calc_req_entries = NULL, |
| 2063 | .build_iocbs = NULL, |
| 2064 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2065 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 2066 | .read_nvram = qla25xx_read_nvram_data, |
| 2067 | .write_nvram = qla25xx_write_nvram_data, |
| 2068 | .fw_dump = qla25xx_fw_dump, |
| 2069 | .beacon_on = qla24xx_beacon_on, |
| 2070 | .beacon_off = qla24xx_beacon_off, |
| 2071 | .beacon_blink = qla24xx_beacon_blink, |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 2072 | .read_optrom = qla25xx_read_optrom_data, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2073 | .write_optrom = qla24xx_write_optrom_data, |
| 2074 | .get_flash_version = qla24xx_get_flash_version, |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 2075 | .start_scsi = qla24xx_dif_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2076 | .start_scsi_mq = qla2xxx_dif_start_scsi_mq, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2077 | .abort_isp = qla2x00_abort_isp, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2078 | .iospace_config = qla2x00_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2079 | .initialize_adapter = qla2x00_initialize_adapter, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2080 | }; |
| 2081 | |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2082 | static struct isp_operations qla81xx_isp_ops = { |
| 2083 | .pci_config = qla25xx_pci_config, |
| 2084 | .reset_chip = qla24xx_reset_chip, |
| 2085 | .chip_diag = qla24xx_chip_diag, |
| 2086 | .config_rings = qla24xx_config_rings, |
| 2087 | .reset_adapter = qla24xx_reset_adapter, |
| 2088 | .nvram_config = qla81xx_nvram_config, |
| 2089 | .update_fw_options = qla81xx_update_fw_options, |
Andrew Vasquez | eaac30b | 2009-01-22 09:45:32 -0800 | [diff] [blame] | 2090 | .load_risc = qla81xx_load_risc, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2091 | .pci_info_str = qla24xx_pci_info_str, |
| 2092 | .fw_version_str = qla24xx_fw_version_str, |
| 2093 | .intr_handler = qla24xx_intr_handler, |
| 2094 | .enable_intrs = qla24xx_enable_intrs, |
| 2095 | .disable_intrs = qla24xx_disable_intrs, |
| 2096 | .abort_command = qla24xx_abort_command, |
| 2097 | .target_reset = qla24xx_abort_target, |
| 2098 | .lun_reset = qla24xx_lun_reset, |
| 2099 | .fabric_login = qla24xx_login_fabric, |
| 2100 | .fabric_logout = qla24xx_fabric_logout, |
| 2101 | .calc_req_entries = NULL, |
| 2102 | .build_iocbs = NULL, |
| 2103 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2104 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
Andrew Vasquez | 3d79038f | 2009-03-24 09:08:14 -0700 | [diff] [blame] | 2105 | .read_nvram = NULL, |
| 2106 | .write_nvram = NULL, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2107 | .fw_dump = qla81xx_fw_dump, |
| 2108 | .beacon_on = qla24xx_beacon_on, |
| 2109 | .beacon_off = qla24xx_beacon_off, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2110 | .beacon_blink = qla83xx_beacon_blink, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2111 | .read_optrom = qla25xx_read_optrom_data, |
| 2112 | .write_optrom = qla24xx_write_optrom_data, |
| 2113 | .get_flash_version = qla24xx_get_flash_version, |
Arun Easi | ba77ef5 | 2010-05-28 15:08:27 -0700 | [diff] [blame] | 2114 | .start_scsi = qla24xx_dif_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2115 | .start_scsi_mq = qla2xxx_dif_start_scsi_mq, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2116 | .abort_isp = qla2x00_abort_isp, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2117 | .iospace_config = qla2x00_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2118 | .initialize_adapter = qla2x00_initialize_adapter, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2119 | }; |
| 2120 | |
| 2121 | static struct isp_operations qla82xx_isp_ops = { |
| 2122 | .pci_config = qla82xx_pci_config, |
| 2123 | .reset_chip = qla82xx_reset_chip, |
| 2124 | .chip_diag = qla24xx_chip_diag, |
| 2125 | .config_rings = qla82xx_config_rings, |
| 2126 | .reset_adapter = qla24xx_reset_adapter, |
| 2127 | .nvram_config = qla81xx_nvram_config, |
| 2128 | .update_fw_options = qla24xx_update_fw_options, |
| 2129 | .load_risc = qla82xx_load_risc, |
Atul Deshmukh | 9d55ca6 | 2012-08-22 14:21:14 -0400 | [diff] [blame] | 2130 | .pci_info_str = qla24xx_pci_info_str, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2131 | .fw_version_str = qla24xx_fw_version_str, |
| 2132 | .intr_handler = qla82xx_intr_handler, |
| 2133 | .enable_intrs = qla82xx_enable_intrs, |
| 2134 | .disable_intrs = qla82xx_disable_intrs, |
| 2135 | .abort_command = qla24xx_abort_command, |
| 2136 | .target_reset = qla24xx_abort_target, |
| 2137 | .lun_reset = qla24xx_lun_reset, |
| 2138 | .fabric_login = qla24xx_login_fabric, |
| 2139 | .fabric_logout = qla24xx_fabric_logout, |
| 2140 | .calc_req_entries = NULL, |
| 2141 | .build_iocbs = NULL, |
| 2142 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2143 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 2144 | .read_nvram = qla24xx_read_nvram_data, |
| 2145 | .write_nvram = qla24xx_write_nvram_data, |
Chad Dupuis | a1b23c5 | 2014-02-26 04:15:12 -0500 | [diff] [blame] | 2146 | .fw_dump = qla82xx_fw_dump, |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 2147 | .beacon_on = qla82xx_beacon_on, |
| 2148 | .beacon_off = qla82xx_beacon_off, |
| 2149 | .beacon_blink = NULL, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2150 | .read_optrom = qla82xx_read_optrom_data, |
| 2151 | .write_optrom = qla82xx_write_optrom_data, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2152 | .get_flash_version = qla82xx_get_flash_version, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2153 | .start_scsi = qla82xx_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2154 | .start_scsi_mq = NULL, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2155 | .abort_isp = qla82xx_abort_isp, |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 2156 | .iospace_config = qla82xx_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2157 | .initialize_adapter = qla2x00_initialize_adapter, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2158 | }; |
| 2159 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2160 | static struct isp_operations qla8044_isp_ops = { |
| 2161 | .pci_config = qla82xx_pci_config, |
| 2162 | .reset_chip = qla82xx_reset_chip, |
| 2163 | .chip_diag = qla24xx_chip_diag, |
| 2164 | .config_rings = qla82xx_config_rings, |
| 2165 | .reset_adapter = qla24xx_reset_adapter, |
| 2166 | .nvram_config = qla81xx_nvram_config, |
| 2167 | .update_fw_options = qla24xx_update_fw_options, |
| 2168 | .load_risc = qla82xx_load_risc, |
| 2169 | .pci_info_str = qla24xx_pci_info_str, |
| 2170 | .fw_version_str = qla24xx_fw_version_str, |
| 2171 | .intr_handler = qla8044_intr_handler, |
| 2172 | .enable_intrs = qla82xx_enable_intrs, |
| 2173 | .disable_intrs = qla82xx_disable_intrs, |
| 2174 | .abort_command = qla24xx_abort_command, |
| 2175 | .target_reset = qla24xx_abort_target, |
| 2176 | .lun_reset = qla24xx_lun_reset, |
| 2177 | .fabric_login = qla24xx_login_fabric, |
| 2178 | .fabric_logout = qla24xx_fabric_logout, |
| 2179 | .calc_req_entries = NULL, |
| 2180 | .build_iocbs = NULL, |
| 2181 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2182 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 2183 | .read_nvram = NULL, |
| 2184 | .write_nvram = NULL, |
Chad Dupuis | a1b23c5 | 2014-02-26 04:15:12 -0500 | [diff] [blame] | 2185 | .fw_dump = qla8044_fw_dump, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2186 | .beacon_on = qla82xx_beacon_on, |
| 2187 | .beacon_off = qla82xx_beacon_off, |
| 2188 | .beacon_blink = NULL, |
Saurav Kashyap | 888e639 | 2014-02-26 04:15:13 -0500 | [diff] [blame] | 2189 | .read_optrom = qla8044_read_optrom_data, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2190 | .write_optrom = qla8044_write_optrom_data, |
| 2191 | .get_flash_version = qla82xx_get_flash_version, |
| 2192 | .start_scsi = qla82xx_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2193 | .start_scsi_mq = NULL, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2194 | .abort_isp = qla8044_abort_isp, |
| 2195 | .iospace_config = qla82xx_iospace_config, |
| 2196 | .initialize_adapter = qla2x00_initialize_adapter, |
| 2197 | }; |
| 2198 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2199 | static struct isp_operations qla83xx_isp_ops = { |
| 2200 | .pci_config = qla25xx_pci_config, |
| 2201 | .reset_chip = qla24xx_reset_chip, |
| 2202 | .chip_diag = qla24xx_chip_diag, |
| 2203 | .config_rings = qla24xx_config_rings, |
| 2204 | .reset_adapter = qla24xx_reset_adapter, |
| 2205 | .nvram_config = qla81xx_nvram_config, |
| 2206 | .update_fw_options = qla81xx_update_fw_options, |
| 2207 | .load_risc = qla81xx_load_risc, |
| 2208 | .pci_info_str = qla24xx_pci_info_str, |
| 2209 | .fw_version_str = qla24xx_fw_version_str, |
| 2210 | .intr_handler = qla24xx_intr_handler, |
| 2211 | .enable_intrs = qla24xx_enable_intrs, |
| 2212 | .disable_intrs = qla24xx_disable_intrs, |
| 2213 | .abort_command = qla24xx_abort_command, |
| 2214 | .target_reset = qla24xx_abort_target, |
| 2215 | .lun_reset = qla24xx_lun_reset, |
| 2216 | .fabric_login = qla24xx_login_fabric, |
| 2217 | .fabric_logout = qla24xx_fabric_logout, |
| 2218 | .calc_req_entries = NULL, |
| 2219 | .build_iocbs = NULL, |
| 2220 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2221 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 2222 | .read_nvram = NULL, |
| 2223 | .write_nvram = NULL, |
| 2224 | .fw_dump = qla83xx_fw_dump, |
| 2225 | .beacon_on = qla24xx_beacon_on, |
| 2226 | .beacon_off = qla24xx_beacon_off, |
| 2227 | .beacon_blink = qla83xx_beacon_blink, |
| 2228 | .read_optrom = qla25xx_read_optrom_data, |
| 2229 | .write_optrom = qla24xx_write_optrom_data, |
| 2230 | .get_flash_version = qla24xx_get_flash_version, |
| 2231 | .start_scsi = qla24xx_dif_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2232 | .start_scsi_mq = qla2xxx_dif_start_scsi_mq, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2233 | .abort_isp = qla2x00_abort_isp, |
| 2234 | .iospace_config = qla83xx_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2235 | .initialize_adapter = qla2x00_initialize_adapter, |
| 2236 | }; |
| 2237 | |
| 2238 | static struct isp_operations qlafx00_isp_ops = { |
| 2239 | .pci_config = qlafx00_pci_config, |
| 2240 | .reset_chip = qlafx00_soft_reset, |
| 2241 | .chip_diag = qlafx00_chip_diag, |
| 2242 | .config_rings = qlafx00_config_rings, |
| 2243 | .reset_adapter = qlafx00_soft_reset, |
| 2244 | .nvram_config = NULL, |
| 2245 | .update_fw_options = NULL, |
| 2246 | .load_risc = NULL, |
| 2247 | .pci_info_str = qlafx00_pci_info_str, |
| 2248 | .fw_version_str = qlafx00_fw_version_str, |
| 2249 | .intr_handler = qlafx00_intr_handler, |
| 2250 | .enable_intrs = qlafx00_enable_intrs, |
| 2251 | .disable_intrs = qlafx00_disable_intrs, |
Armen Baloyan | 4440e46 | 2014-02-26 04:15:18 -0500 | [diff] [blame] | 2252 | .abort_command = qla24xx_async_abort_command, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2253 | .target_reset = qlafx00_abort_target, |
| 2254 | .lun_reset = qlafx00_lun_reset, |
| 2255 | .fabric_login = NULL, |
| 2256 | .fabric_logout = NULL, |
| 2257 | .calc_req_entries = NULL, |
| 2258 | .build_iocbs = NULL, |
| 2259 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2260 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 2261 | .read_nvram = qla24xx_read_nvram_data, |
| 2262 | .write_nvram = qla24xx_write_nvram_data, |
| 2263 | .fw_dump = NULL, |
| 2264 | .beacon_on = qla24xx_beacon_on, |
| 2265 | .beacon_off = qla24xx_beacon_off, |
| 2266 | .beacon_blink = NULL, |
| 2267 | .read_optrom = qla24xx_read_optrom_data, |
| 2268 | .write_optrom = qla24xx_write_optrom_data, |
| 2269 | .get_flash_version = qla24xx_get_flash_version, |
| 2270 | .start_scsi = qlafx00_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2271 | .start_scsi_mq = NULL, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2272 | .abort_isp = qlafx00_abort_isp, |
| 2273 | .iospace_config = qlafx00_iospace_config, |
| 2274 | .initialize_adapter = qlafx00_initialize_adapter, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2275 | }; |
| 2276 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2277 | static struct isp_operations qla27xx_isp_ops = { |
| 2278 | .pci_config = qla25xx_pci_config, |
| 2279 | .reset_chip = qla24xx_reset_chip, |
| 2280 | .chip_diag = qla24xx_chip_diag, |
| 2281 | .config_rings = qla24xx_config_rings, |
| 2282 | .reset_adapter = qla24xx_reset_adapter, |
| 2283 | .nvram_config = qla81xx_nvram_config, |
| 2284 | .update_fw_options = qla81xx_update_fw_options, |
| 2285 | .load_risc = qla81xx_load_risc, |
| 2286 | .pci_info_str = qla24xx_pci_info_str, |
| 2287 | .fw_version_str = qla24xx_fw_version_str, |
| 2288 | .intr_handler = qla24xx_intr_handler, |
| 2289 | .enable_intrs = qla24xx_enable_intrs, |
| 2290 | .disable_intrs = qla24xx_disable_intrs, |
| 2291 | .abort_command = qla24xx_abort_command, |
| 2292 | .target_reset = qla24xx_abort_target, |
| 2293 | .lun_reset = qla24xx_lun_reset, |
| 2294 | .fabric_login = qla24xx_login_fabric, |
| 2295 | .fabric_logout = qla24xx_fabric_logout, |
| 2296 | .calc_req_entries = NULL, |
| 2297 | .build_iocbs = NULL, |
| 2298 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2299 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 2300 | .read_nvram = NULL, |
| 2301 | .write_nvram = NULL, |
| 2302 | .fw_dump = qla27xx_fwdump, |
| 2303 | .beacon_on = qla24xx_beacon_on, |
| 2304 | .beacon_off = qla24xx_beacon_off, |
| 2305 | .beacon_blink = qla83xx_beacon_blink, |
| 2306 | .read_optrom = qla25xx_read_optrom_data, |
| 2307 | .write_optrom = qla24xx_write_optrom_data, |
| 2308 | .get_flash_version = qla24xx_get_flash_version, |
| 2309 | .start_scsi = qla24xx_dif_start_scsi, |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2310 | .start_scsi_mq = qla2xxx_dif_start_scsi_mq, |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2311 | .abort_isp = qla2x00_abort_isp, |
| 2312 | .iospace_config = qla83xx_iospace_config, |
| 2313 | .initialize_adapter = qla2x00_initialize_adapter, |
| 2314 | }; |
| 2315 | |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2316 | static inline void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2317 | qla2x00_set_isp_flags(struct qla_hw_data *ha) |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2318 | { |
| 2319 | ha->device_type = DT_EXTENDED_IDS; |
| 2320 | switch (ha->pdev->device) { |
| 2321 | case PCI_DEVICE_ID_QLOGIC_ISP2100: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2322 | ha->isp_type |= DT_ISP2100; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2323 | ha->device_type &= ~DT_EXTENDED_IDS; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2324 | ha->fw_srisc_address = RISC_START_ADDRESS_2100; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2325 | break; |
| 2326 | case PCI_DEVICE_ID_QLOGIC_ISP2200: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2327 | ha->isp_type |= DT_ISP2200; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2328 | ha->device_type &= ~DT_EXTENDED_IDS; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2329 | ha->fw_srisc_address = RISC_START_ADDRESS_2100; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2330 | break; |
| 2331 | case PCI_DEVICE_ID_QLOGIC_ISP2300: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2332 | ha->isp_type |= DT_ISP2300; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2333 | ha->device_type |= DT_ZIO_SUPPORTED; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2334 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2335 | break; |
| 2336 | case PCI_DEVICE_ID_QLOGIC_ISP2312: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2337 | ha->isp_type |= DT_ISP2312; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2338 | ha->device_type |= DT_ZIO_SUPPORTED; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2339 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2340 | break; |
| 2341 | case PCI_DEVICE_ID_QLOGIC_ISP2322: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2342 | ha->isp_type |= DT_ISP2322; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2343 | ha->device_type |= DT_ZIO_SUPPORTED; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2344 | if (ha->pdev->subsystem_vendor == 0x1028 && |
| 2345 | ha->pdev->subsystem_device == 0x0170) |
| 2346 | ha->device_type |= DT_OEM_001; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2347 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2348 | break; |
| 2349 | case PCI_DEVICE_ID_QLOGIC_ISP6312: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2350 | ha->isp_type |= DT_ISP6312; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2351 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2352 | break; |
| 2353 | case PCI_DEVICE_ID_QLOGIC_ISP6322: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2354 | ha->isp_type |= DT_ISP6322; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2355 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2356 | break; |
| 2357 | case PCI_DEVICE_ID_QLOGIC_ISP2422: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2358 | ha->isp_type |= DT_ISP2422; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2359 | ha->device_type |= DT_ZIO_SUPPORTED; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2360 | ha->device_type |= DT_FWI2; |
Andrew Vasquez | c76f2c0 | 2007-07-19 15:05:57 -0700 | [diff] [blame] | 2361 | ha->device_type |= DT_IIDMA; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2362 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2363 | break; |
| 2364 | case PCI_DEVICE_ID_QLOGIC_ISP2432: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2365 | ha->isp_type |= DT_ISP2432; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2366 | ha->device_type |= DT_ZIO_SUPPORTED; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2367 | ha->device_type |= DT_FWI2; |
Andrew Vasquez | c76f2c0 | 2007-07-19 15:05:57 -0700 | [diff] [blame] | 2368 | ha->device_type |= DT_IIDMA; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2369 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2370 | break; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 2371 | case PCI_DEVICE_ID_QLOGIC_ISP8432: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2372 | ha->isp_type |= DT_ISP8432; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 2373 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2374 | ha->device_type |= DT_FWI2; |
| 2375 | ha->device_type |= DT_IIDMA; |
| 2376 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2377 | break; |
andrew.vasquez@qlogic.com | 044cc6c | 2006-03-09 14:27:13 -0800 | [diff] [blame] | 2378 | case PCI_DEVICE_ID_QLOGIC_ISP5422: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2379 | ha->isp_type |= DT_ISP5422; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2380 | ha->device_type |= DT_FWI2; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2381 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2382 | break; |
andrew.vasquez@qlogic.com | 044cc6c | 2006-03-09 14:27:13 -0800 | [diff] [blame] | 2383 | case PCI_DEVICE_ID_QLOGIC_ISP5432: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2384 | ha->isp_type |= DT_ISP5432; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2385 | ha->device_type |= DT_FWI2; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2386 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2387 | break; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2388 | case PCI_DEVICE_ID_QLOGIC_ISP2532: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2389 | ha->isp_type |= DT_ISP2532; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2390 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2391 | ha->device_type |= DT_FWI2; |
| 2392 | ha->device_type |= DT_IIDMA; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2393 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2394 | break; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2395 | case PCI_DEVICE_ID_QLOGIC_ISP8001: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2396 | ha->isp_type |= DT_ISP8001; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2397 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2398 | ha->device_type |= DT_FWI2; |
| 2399 | ha->device_type |= DT_IIDMA; |
| 2400 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2401 | break; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2402 | case PCI_DEVICE_ID_QLOGIC_ISP8021: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2403 | ha->isp_type |= DT_ISP8021; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2404 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2405 | ha->device_type |= DT_FWI2; |
| 2406 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2407 | /* Initialize 82XX ISP flags */ |
| 2408 | qla82xx_init_flags(ha); |
| 2409 | break; |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2410 | case PCI_DEVICE_ID_QLOGIC_ISP8044: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2411 | ha->isp_type |= DT_ISP8044; |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2412 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2413 | ha->device_type |= DT_FWI2; |
| 2414 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2415 | /* Initialize 82XX ISP flags */ |
| 2416 | qla82xx_init_flags(ha); |
| 2417 | break; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2418 | case PCI_DEVICE_ID_QLOGIC_ISP2031: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2419 | ha->isp_type |= DT_ISP2031; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2420 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2421 | ha->device_type |= DT_FWI2; |
| 2422 | ha->device_type |= DT_IIDMA; |
| 2423 | ha->device_type |= DT_T10_PI; |
| 2424 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2425 | break; |
| 2426 | case PCI_DEVICE_ID_QLOGIC_ISP8031: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2427 | ha->isp_type |= DT_ISP8031; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2428 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2429 | ha->device_type |= DT_FWI2; |
| 2430 | ha->device_type |= DT_IIDMA; |
| 2431 | ha->device_type |= DT_T10_PI; |
| 2432 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2433 | break; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2434 | case PCI_DEVICE_ID_QLOGIC_ISPF001: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2435 | ha->isp_type |= DT_ISPFX00; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2436 | break; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2437 | case PCI_DEVICE_ID_QLOGIC_ISP2071: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2438 | ha->isp_type |= DT_ISP2071; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2439 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2440 | ha->device_type |= DT_FWI2; |
| 2441 | ha->device_type |= DT_IIDMA; |
Himanshu Madhani | 8ce3f57 | 2016-01-27 12:03:36 -0500 | [diff] [blame] | 2442 | ha->device_type |= DT_T10_PI; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2443 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2444 | break; |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 2445 | case PCI_DEVICE_ID_QLOGIC_ISP2271: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2446 | ha->isp_type |= DT_ISP2271; |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 2447 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2448 | ha->device_type |= DT_FWI2; |
| 2449 | ha->device_type |= DT_IIDMA; |
Himanshu Madhani | 8ce3f57 | 2016-01-27 12:03:36 -0500 | [diff] [blame] | 2450 | ha->device_type |= DT_T10_PI; |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 2451 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2452 | break; |
Sawan Chandak | 2b48992 | 2015-08-04 13:38:03 -0400 | [diff] [blame] | 2453 | case PCI_DEVICE_ID_QLOGIC_ISP2261: |
Joe Carnuccio | 9e052e2 | 2016-07-06 11:14:31 -0400 | [diff] [blame] | 2454 | ha->isp_type |= DT_ISP2261; |
Sawan Chandak | 2b48992 | 2015-08-04 13:38:03 -0400 | [diff] [blame] | 2455 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2456 | ha->device_type |= DT_FWI2; |
| 2457 | ha->device_type |= DT_IIDMA; |
Himanshu Madhani | 8ce3f57 | 2016-01-27 12:03:36 -0500 | [diff] [blame] | 2458 | ha->device_type |= DT_T10_PI; |
Sawan Chandak | 2b48992 | 2015-08-04 13:38:03 -0400 | [diff] [blame] | 2459 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2460 | break; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2461 | } |
Anirban Chakraborty | e5b68a6 | 2009-04-06 22:33:50 -0700 | [diff] [blame] | 2462 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2463 | if (IS_QLA82XX(ha)) |
Saurav Kashyap | 43a9c38 | 2014-02-26 04:15:16 -0500 | [diff] [blame] | 2464 | ha->port_no = ha->portnum & 1; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2465 | else { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2466 | /* Get adapter physical port no from interrupt pin register. */ |
| 2467 | pci_read_config_byte(ha->pdev, PCI_INTERRUPT_PIN, &ha->port_no); |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2468 | if (IS_QLA27XX(ha)) |
| 2469 | ha->port_no--; |
| 2470 | else |
| 2471 | ha->port_no = !(ha->port_no & 1); |
| 2472 | } |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2473 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2474 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x000b, |
Joe Perches | d8424f6 | 2011-11-18 09:03:06 -0800 | [diff] [blame] | 2475 | "device_type=0x%x port=%d fw_srisc_address=0x%x.\n", |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2476 | ha->device_type, ha->port_no, ha->fw_srisc_address); |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2477 | } |
| 2478 | |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2479 | static void |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2480 | qla2xxx_scan_start(struct Scsi_Host *shost) |
| 2481 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2482 | scsi_qla_host_t *vha = shost_priv(shost); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2483 | |
Andrew Vasquez | cbc8eb6 | 2009-06-03 09:55:17 -0700 | [diff] [blame] | 2484 | if (vha->hw->flags.running_gold_fw) |
| 2485 | return; |
| 2486 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2487 | set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); |
| 2488 | set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); |
| 2489 | set_bit(RSCN_UPDATE, &vha->dpc_flags); |
| 2490 | set_bit(NPIV_CONFIG_NEEDED, &vha->dpc_flags); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2491 | } |
| 2492 | |
| 2493 | static int |
| 2494 | qla2xxx_scan_finished(struct Scsi_Host *shost, unsigned long time) |
| 2495 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2496 | scsi_qla_host_t *vha = shost_priv(shost); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2497 | |
Bill Kuzeja | a5dd506e | 2016-10-21 16:45:27 -0400 | [diff] [blame] | 2498 | if (test_bit(UNLOADING, &vha->dpc_flags)) |
| 2499 | return 1; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2500 | if (!vha->host) |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2501 | return 1; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2502 | if (time > vha->hw->loop_reset_delay * HZ) |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2503 | return 1; |
| 2504 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2505 | return atomic_read(&vha->loop_state) == LOOP_READY; |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2506 | } |
| 2507 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2508 | /* |
| 2509 | * PCI driver interface |
| 2510 | */ |
Greg Kroah-Hartman | 6f03979 | 2012-12-21 13:08:55 -0800 | [diff] [blame] | 2511 | static int |
Andrew Vasquez | 7ee6139 | 2006-06-23 16:11:22 -0700 | [diff] [blame] | 2512 | 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] | 2513 | { |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2514 | int ret = -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2515 | struct Scsi_Host *host; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2516 | scsi_qla_host_t *base_vha = NULL; |
| 2517 | struct qla_hw_data *ha; |
Andrew Vasquez | 29856e2 | 2007-08-12 18:22:52 -0700 | [diff] [blame] | 2518 | char pci_info[30]; |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 2519 | char fw_str[30], wq_name[30]; |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 2520 | struct scsi_host_template *sht; |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2521 | int bars, mem_only = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2522 | uint16_t req_length = 0, rsp_length = 0; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2523 | struct req_que *req = NULL; |
| 2524 | struct rsp_que *rsp = NULL; |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame^] | 2525 | int i; |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2526 | |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2527 | bars = pci_select_bars(pdev, IORESOURCE_MEM | IORESOURCE_IO); |
Giridhar Malavali | a5326f8 | 2009-03-24 09:07:56 -0700 | [diff] [blame] | 2528 | sht = &qla2xxx_driver_template; |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2529 | if (pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2422 || |
| 2530 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2432 || |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 2531 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8432 || |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2532 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP5422 || |
| 2533 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP5432 || |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2534 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2532 || |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2535 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8001 || |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2536 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8021 || |
| 2537 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2031 || |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2538 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8031 || |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2539 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISPF001 || |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2540 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8044 || |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 2541 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2071 || |
Sawan Chandak | 2b48992 | 2015-08-04 13:38:03 -0400 | [diff] [blame] | 2542 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2271 || |
| 2543 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2261) { |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2544 | bars = pci_select_bars(pdev, IORESOURCE_MEM); |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 2545 | mem_only = 1; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2546 | ql_dbg_pci(ql_dbg_init, pdev, 0x0007, |
| 2547 | "Mem only adapter.\n"); |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2548 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2549 | ql_dbg_pci(ql_dbg_init, pdev, 0x0008, |
| 2550 | "Bars=%d.\n", bars); |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2551 | |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 2552 | if (mem_only) { |
| 2553 | if (pci_enable_device_mem(pdev)) |
| 2554 | goto probe_out; |
| 2555 | } else { |
| 2556 | if (pci_enable_device(pdev)) |
| 2557 | goto probe_out; |
| 2558 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2559 | |
Jesse Barnes | 0927678 | 2008-10-18 17:33:19 -0700 | [diff] [blame] | 2560 | /* This may fail but that's ok */ |
| 2561 | pci_enable_pcie_error_reporting(pdev); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 2562 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2563 | ha = kzalloc(sizeof(struct qla_hw_data), GFP_KERNEL); |
| 2564 | if (!ha) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2565 | ql_log_pci(ql_log_fatal, pdev, 0x0009, |
| 2566 | "Unable to allocate memory for ha.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2567 | goto probe_out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2568 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2569 | ql_dbg_pci(ql_dbg_init, pdev, 0x000a, |
| 2570 | "Memory allocated for ha=%p.\n", ha); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2571 | ha->pdev = pdev; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2572 | ha->tgt.enable_class_2 = ql2xenableclass2; |
Quinn Tran | 33e7997 | 2014-09-25 06:14:55 -0400 | [diff] [blame] | 2573 | INIT_LIST_HEAD(&ha->tgt.q_full_list); |
| 2574 | spin_lock_init(&ha->tgt.q_full_lock); |
Quinn Tran | 7560151 | 2015-12-17 14:57:04 -0500 | [diff] [blame] | 2575 | spin_lock_init(&ha->tgt.sess_lock); |
Quinn Tran | 2f424b9 | 2015-12-17 14:57:07 -0500 | [diff] [blame] | 2576 | spin_lock_init(&ha->tgt.atio_lock); |
| 2577 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2578 | |
| 2579 | /* Clear our data area */ |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2580 | ha->bars = bars; |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 2581 | ha->mem_only = mem_only; |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 2582 | spin_lock_init(&ha->hardware_lock); |
Andrew Vasquez | 339aa70 | 2010-10-15 11:27:45 -0700 | [diff] [blame] | 2583 | spin_lock_init(&ha->vport_slock); |
Saurav Kashyap | a9b6f72 | 2012-08-22 14:21:01 -0400 | [diff] [blame] | 2584 | mutex_init(&ha->selflogin_lock); |
Chad Dupuis | 7a8ab9c | 2014-02-26 04:14:56 -0500 | [diff] [blame] | 2585 | mutex_init(&ha->optrom_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2586 | |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2587 | /* Set ISP-type information. */ |
| 2588 | qla2x00_set_isp_flags(ha); |
Duane Grigsby | ca79cf6 | 2009-12-15 21:29:47 -0800 | [diff] [blame] | 2589 | |
| 2590 | /* Set EEH reset type to fundamental if required by hba */ |
Joe Carnuccio | 9567611 | 2012-08-22 14:21:20 -0400 | [diff] [blame] | 2591 | if (IS_QLA24XX(ha) || IS_QLA25XX(ha) || IS_QLA81XX(ha) || |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2592 | IS_QLA83XX(ha) || IS_QLA27XX(ha)) |
Duane Grigsby | ca79cf6 | 2009-12-15 21:29:47 -0800 | [diff] [blame] | 2593 | pdev->needs_freset = 1; |
Duane Grigsby | ca79cf6 | 2009-12-15 21:29:47 -0800 | [diff] [blame] | 2594 | |
Chad Dupuis | cba1e47 | 2011-11-18 09:03:21 -0800 | [diff] [blame] | 2595 | ha->prev_topology = 0; |
| 2596 | ha->init_cb_size = sizeof(init_cb_t); |
| 2597 | ha->link_data_rate = PORT_SPEED_UNKNOWN; |
| 2598 | ha->optrom_size = OPTROM_SIZE_2300; |
| 2599 | |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2600 | /* Assign ISP specific operations. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2601 | if (IS_QLA2100(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2602 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2100; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2603 | ha->mbx_count = MAILBOX_REGISTER_COUNT_2100; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2604 | req_length = REQUEST_ENTRY_CNT_2100; |
| 2605 | rsp_length = RESPONSE_ENTRY_CNT_2100; |
| 2606 | ha->max_loop_id = SNS_LAST_LOOP_ID_2100; |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2607 | ha->gid_list_info_size = 4; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2608 | ha->flash_conf_off = ~0; |
| 2609 | ha->flash_data_off = ~0; |
| 2610 | ha->nvram_conf_off = ~0; |
| 2611 | ha->nvram_data_off = ~0; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2612 | ha->isp_ops = &qla2100_isp_ops; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2613 | } else if (IS_QLA2200(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2614 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2100; |
Andrew Vasquez | 67ddda3 | 2012-02-09 11:14:08 -0800 | [diff] [blame] | 2615 | ha->mbx_count = MAILBOX_REGISTER_COUNT_2200; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2616 | req_length = REQUEST_ENTRY_CNT_2200; |
| 2617 | rsp_length = RESPONSE_ENTRY_CNT_2100; |
| 2618 | ha->max_loop_id = SNS_LAST_LOOP_ID_2100; |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2619 | ha->gid_list_info_size = 4; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2620 | ha->flash_conf_off = ~0; |
| 2621 | ha->flash_data_off = ~0; |
| 2622 | ha->nvram_conf_off = ~0; |
| 2623 | ha->nvram_data_off = ~0; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2624 | ha->isp_ops = &qla2100_isp_ops; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 2625 | } else if (IS_QLA23XX(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2626 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2100; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2627 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2628 | req_length = REQUEST_ENTRY_CNT_2200; |
| 2629 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
| 2630 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2631 | ha->gid_list_info_size = 6; |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 2632 | if (IS_QLA2322(ha) || IS_QLA6322(ha)) |
| 2633 | ha->optrom_size = OPTROM_SIZE_2322; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2634 | ha->flash_conf_off = ~0; |
| 2635 | ha->flash_data_off = ~0; |
| 2636 | ha->nvram_conf_off = ~0; |
| 2637 | ha->nvram_data_off = ~0; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2638 | ha->isp_ops = &qla2300_isp_ops; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 2639 | } else if (IS_QLA24XX_TYPE(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2640 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 2641 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2642 | req_length = REQUEST_ENTRY_CNT_24XX; |
| 2643 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2644 | ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2645 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2646 | ha->init_cb_size = sizeof(struct mid_init_cb_24xx); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 2647 | ha->gid_list_info_size = 8; |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 2648 | ha->optrom_size = OPTROM_SIZE_24XX; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2649 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA24XX; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2650 | ha->isp_ops = &qla24xx_isp_ops; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2651 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF; |
| 2652 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA; |
| 2653 | ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF; |
| 2654 | ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2655 | } else if (IS_QLA25XX(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2656 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2657 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2658 | req_length = REQUEST_ENTRY_CNT_24XX; |
| 2659 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2660 | ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2661 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2662 | ha->init_cb_size = sizeof(struct mid_init_cb_24xx); |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2663 | ha->gid_list_info_size = 8; |
| 2664 | ha->optrom_size = OPTROM_SIZE_25XX; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2665 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2666 | ha->isp_ops = &qla25xx_isp_ops; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2667 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF; |
| 2668 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA; |
| 2669 | ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF; |
| 2670 | ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA; |
| 2671 | } else if (IS_QLA81XX(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2672 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2673 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
| 2674 | req_length = REQUEST_ENTRY_CNT_24XX; |
| 2675 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
Arun Easi | aa230bc | 2013-01-30 03:34:39 -0500 | [diff] [blame] | 2676 | ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2677 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 2678 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 2679 | ha->gid_list_info_size = 8; |
| 2680 | ha->optrom_size = OPTROM_SIZE_81XX; |
Anirban Chakraborty | 40859ae | 2009-06-03 09:55:16 -0700 | [diff] [blame] | 2681 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2682 | ha->isp_ops = &qla81xx_isp_ops; |
| 2683 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF_81XX; |
| 2684 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA_81XX; |
| 2685 | ha->nvram_conf_off = ~0; |
| 2686 | ha->nvram_data_off = ~0; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2687 | } else if (IS_QLA82XX(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2688 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2689 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
| 2690 | req_length = REQUEST_ENTRY_CNT_82XX; |
| 2691 | rsp_length = RESPONSE_ENTRY_CNT_82XX; |
| 2692 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 2693 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 2694 | ha->gid_list_info_size = 8; |
| 2695 | ha->optrom_size = OPTROM_SIZE_82XX; |
Andrew Vasquez | 087c621 | 2010-11-23 16:52:48 -0800 | [diff] [blame] | 2696 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2697 | ha->isp_ops = &qla82xx_isp_ops; |
| 2698 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF; |
| 2699 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA; |
| 2700 | ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF; |
| 2701 | ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA; |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2702 | } else if (IS_QLA8044(ha)) { |
| 2703 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
| 2704 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
| 2705 | req_length = REQUEST_ENTRY_CNT_82XX; |
| 2706 | rsp_length = RESPONSE_ENTRY_CNT_82XX; |
| 2707 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 2708 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 2709 | ha->gid_list_info_size = 8; |
| 2710 | ha->optrom_size = OPTROM_SIZE_83XX; |
| 2711 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
| 2712 | ha->isp_ops = &qla8044_isp_ops; |
| 2713 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF; |
| 2714 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA; |
| 2715 | ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF; |
| 2716 | ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2717 | } else if (IS_QLA83XX(ha)) { |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 2718 | ha->portnum = PCI_FUNC(ha->pdev->devfn); |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2719 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2720 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
Saurav Kashyap | f2ea653 | 2014-09-25 06:14:54 -0400 | [diff] [blame] | 2721 | req_length = REQUEST_ENTRY_CNT_83XX; |
Quinn Tran | e7b42e3 | 2015-12-17 14:57:09 -0500 | [diff] [blame] | 2722 | rsp_length = RESPONSE_ENTRY_CNT_83XX; |
Arun Easi | b8aa4bd | 2013-01-30 03:34:40 -0500 | [diff] [blame] | 2723 | ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2724 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 2725 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 2726 | ha->gid_list_info_size = 8; |
| 2727 | ha->optrom_size = OPTROM_SIZE_83XX; |
| 2728 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
| 2729 | ha->isp_ops = &qla83xx_isp_ops; |
| 2730 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF_81XX; |
| 2731 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA_81XX; |
| 2732 | ha->nvram_conf_off = ~0; |
| 2733 | ha->nvram_data_off = ~0; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2734 | } else if (IS_QLAFX00(ha)) { |
| 2735 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_FX00; |
| 2736 | ha->mbx_count = MAILBOX_REGISTER_COUNT_FX00; |
| 2737 | ha->aen_mbx_count = AEN_MAILBOX_REGISTER_COUNT_FX00; |
| 2738 | req_length = REQUEST_ENTRY_CNT_FX00; |
| 2739 | rsp_length = RESPONSE_ENTRY_CNT_FX00; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2740 | ha->isp_ops = &qlafx00_isp_ops; |
| 2741 | ha->port_down_retry_count = 30; /* default value */ |
| 2742 | ha->mr.fw_hbt_cnt = QLAFX00_HEARTBEAT_INTERVAL; |
| 2743 | ha->mr.fw_reset_timer_tick = QLAFX00_RESET_INTERVAL; |
Armen Baloyan | 71e5600 | 2013-08-27 01:37:38 -0400 | [diff] [blame] | 2744 | ha->mr.fw_critemp_timer_tick = QLAFX00_CRITEMP_INTERVAL; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2745 | ha->mr.fw_hbt_en = 1; |
Armen Baloyan | e8f5e95 | 2013-10-30 03:38:17 -0400 | [diff] [blame] | 2746 | ha->mr.host_info_resend = false; |
| 2747 | ha->mr.hinfo_resend_timer_tick = QLAFX00_HINFO_RESEND_INTERVAL; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2748 | } else if (IS_QLA27XX(ha)) { |
| 2749 | ha->portnum = PCI_FUNC(ha->pdev->devfn); |
| 2750 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
| 2751 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
Quinn Tran | e7b42e3 | 2015-12-17 14:57:09 -0500 | [diff] [blame] | 2752 | req_length = REQUEST_ENTRY_CNT_83XX; |
| 2753 | rsp_length = RESPONSE_ENTRY_CNT_83XX; |
Himanshu Madhani | b20f02e | 2015-06-10 11:05:18 -0400 | [diff] [blame] | 2754 | ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2755 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 2756 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 2757 | ha->gid_list_info_size = 8; |
| 2758 | ha->optrom_size = OPTROM_SIZE_83XX; |
| 2759 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
| 2760 | ha->isp_ops = &qla27xx_isp_ops; |
| 2761 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF_81XX; |
| 2762 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA_81XX; |
| 2763 | ha->nvram_conf_off = ~0; |
| 2764 | ha->nvram_data_off = ~0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2765 | } |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2766 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2767 | ql_dbg_pci(ql_dbg_init, pdev, 0x001e, |
| 2768 | "mbx_count=%d, req_length=%d, " |
| 2769 | "rsp_length=%d, max_loop_id=%d, init_cb_size=%d, " |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2770 | "gid_list_info_size=%d, optrom_size=%d, nvram_npiv_size=%d, " |
| 2771 | "max_fibre_devices=%d.\n", |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2772 | ha->mbx_count, req_length, rsp_length, ha->max_loop_id, |
| 2773 | ha->init_cb_size, ha->gid_list_info_size, ha->optrom_size, |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2774 | ha->nvram_npiv_size, ha->max_fibre_devices); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2775 | ql_dbg_pci(ql_dbg_init, pdev, 0x001f, |
| 2776 | "isp_ops=%p, flash_conf_off=%d, " |
| 2777 | "flash_data_off=%d, nvram_conf_off=%d, nvram_data_off=%d.\n", |
| 2778 | ha->isp_ops, ha->flash_conf_off, ha->flash_data_off, |
| 2779 | ha->nvram_conf_off, ha->nvram_data_off); |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 2780 | |
| 2781 | /* Configure PCI I/O space */ |
| 2782 | ret = ha->isp_ops->iospace_config(ha); |
| 2783 | if (ret) |
Saurav Kashyap | 0a63ad1 | 2012-11-21 02:40:43 -0500 | [diff] [blame] | 2784 | goto iospace_config_failed; |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 2785 | |
| 2786 | ql_log_pci(ql_log_info, pdev, 0x001d, |
| 2787 | "Found an ISP%04X irq %d iobase 0x%p.\n", |
| 2788 | pdev->device, pdev->irq, ha->iobase); |
matthias@kaehlcke.net | 6c2f527 | 2008-05-12 22:21:11 -0700 | [diff] [blame] | 2789 | mutex_init(&ha->vport_lock); |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2790 | mutex_init(&ha->mq_lock); |
Marcus Barrow | 0b05a1f | 2008-01-17 09:02:13 -0800 | [diff] [blame] | 2791 | init_completion(&ha->mbx_cmd_comp); |
| 2792 | complete(&ha->mbx_cmd_comp); |
| 2793 | init_completion(&ha->mbx_intr_comp); |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 2794 | init_completion(&ha->dcbx_comp); |
Chad Dupuis | f356bef | 2013-02-08 01:58:04 -0500 | [diff] [blame] | 2795 | init_completion(&ha->lb_portup_comp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2796 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2797 | set_bit(0, (unsigned long *) ha->vp_idx_map); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2798 | |
Andrew Vasquez | 53303c4 | 2009-01-22 09:45:37 -0800 | [diff] [blame] | 2799 | qla2x00_config_dma_addressing(ha); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2800 | ql_dbg_pci(ql_dbg_init, pdev, 0x0020, |
| 2801 | "64 Bit addressing is %s.\n", |
| 2802 | ha->flags.enable_64bit_addressing ? "enable" : |
| 2803 | "disable"); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2804 | ret = qla2x00_mem_alloc(ha, req_length, rsp_length, &req, &rsp); |
Dan Carpenter | b2a72ec | 2014-01-21 10:00:10 +0300 | [diff] [blame] | 2805 | if (ret) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2806 | ql_log_pci(ql_log_fatal, pdev, 0x0031, |
| 2807 | "Failed to allocate memory for adapter, aborting.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2808 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2809 | goto probe_hw_failed; |
| 2810 | } |
| 2811 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2812 | req->max_q_depth = MAX_Q_DEPTH; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2813 | if (ql2xmaxqdepth != 0 && ql2xmaxqdepth <= 0xffffU) |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2814 | req->max_q_depth = ql2xmaxqdepth; |
| 2815 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2816 | |
| 2817 | base_vha = qla2x00_create_host(sht, ha); |
| 2818 | if (!base_vha) { |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2819 | ret = -ENOMEM; |
Anirban Chakraborty | 6e9f21f | 2009-01-22 09:45:28 -0800 | [diff] [blame] | 2820 | qla2x00_mem_free(ha); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2821 | qla2x00_free_req_que(ha, req); |
| 2822 | qla2x00_free_rsp_que(ha, rsp); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2823 | goto probe_hw_failed; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2824 | } |
| 2825 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2826 | pci_set_drvdata(pdev, base_vha); |
Joe Lawrence | 6b38397 | 2014-08-26 17:12:29 -0400 | [diff] [blame] | 2827 | set_bit(PFLG_DRIVER_PROBING, &base_vha->pci_flags); |
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 | host = base_vha->host; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2830 | base_vha->req = req; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2831 | if (IS_QLA2XXX_MIDTYPE(ha)) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2832 | base_vha->mgmt_svr_loop_id = 10 + base_vha->vp_idx; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2833 | else |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2834 | base_vha->mgmt_svr_loop_id = MANAGEMENT_SERVER + |
| 2835 | base_vha->vp_idx; |
Giridhar Malavali | 58548cb | 2010-09-03 15:20:56 -0700 | [diff] [blame] | 2836 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2837 | /* Setup fcport template structure. */ |
| 2838 | ha->mr.fcport.vha = base_vha; |
| 2839 | ha->mr.fcport.port_type = FCT_UNKNOWN; |
| 2840 | ha->mr.fcport.loop_id = FC_NO_LOOP_ID; |
| 2841 | qla2x00_set_fcport_state(&ha->mr.fcport, FCS_UNCONFIGURED); |
| 2842 | ha->mr.fcport.supported_classes = FC_COS_UNSPECIFIED; |
| 2843 | ha->mr.fcport.scan_state = 1; |
| 2844 | |
Giridhar Malavali | 58548cb | 2010-09-03 15:20:56 -0700 | [diff] [blame] | 2845 | /* Set the SG table size based on ISP type */ |
| 2846 | if (!IS_FWI2_CAPABLE(ha)) { |
| 2847 | if (IS_QLA2100(ha)) |
| 2848 | host->sg_tablesize = 32; |
| 2849 | } else { |
| 2850 | if (!IS_QLA82XX(ha)) |
| 2851 | host->sg_tablesize = QLA_SG_ALL; |
| 2852 | } |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2853 | host->max_id = ha->max_fibre_devices; |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2854 | host->cmd_per_lun = 3; |
Seokmann Ju | 711c1d9 | 2008-07-10 16:55:51 -0700 | [diff] [blame] | 2855 | host->unique_id = host->host_no; |
Arun Easi | e02587d | 2011-08-16 11:29:23 -0700 | [diff] [blame] | 2856 | if (IS_T10_PI_CAPABLE(ha) && ql2xenabledif) |
Arun Easi | 0c47087 | 2010-07-23 15:28:38 +0500 | [diff] [blame] | 2857 | host->max_cmd_len = 32; |
| 2858 | else |
| 2859 | host->max_cmd_len = MAX_CMDSZ; |
Andrew Vasquez | 75bc419 | 2006-05-17 15:09:22 -0700 | [diff] [blame] | 2860 | host->max_channel = MAX_BUSES - 1; |
Hannes Reinecke | 755f516 | 2014-06-03 10:58:54 +0200 | [diff] [blame] | 2861 | /* Older HBAs support only 16-bit LUNs */ |
| 2862 | if (!IS_QLAFX00(ha) && !IS_FWI2_CAPABLE(ha) && |
| 2863 | ql2xmaxlun > 0xffff) |
| 2864 | host->max_lun = 0xffff; |
| 2865 | else |
| 2866 | host->max_lun = ql2xmaxlun; |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2867 | host->transportt = qla2xxx_transport_template; |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 2868 | sht->vendor_id = (SCSI_NL_VID_TYPE_PCI | PCI_VENDOR_ID_QLOGIC); |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2869 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2870 | ql_dbg(ql_dbg_init, base_vha, 0x0033, |
| 2871 | "max_id=%d this_id=%d " |
| 2872 | "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] | 2873 | "max_lun=%llu transportt=%p, vendor_id=%llu.\n", host->max_id, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2874 | host->this_id, host->cmd_per_lun, host->unique_id, |
| 2875 | host->max_cmd_len, host->max_channel, host->max_lun, |
| 2876 | host->transportt, sht->vendor_id); |
| 2877 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2878 | /* Set up the irqs */ |
| 2879 | ret = qla2x00_request_irqs(ha, rsp); |
| 2880 | if (ret) |
| 2881 | goto probe_init_failed; |
| 2882 | |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 2883 | /* Alloc arrays of request and response ring ptrs */ |
| 2884 | if (!qla2x00_alloc_queues(ha, req, rsp)) { |
| 2885 | ql_log(ql_log_fatal, base_vha, 0x003d, |
| 2886 | "Failed to allocate memory for queue pointers..." |
| 2887 | "aborting.\n"); |
| 2888 | goto probe_init_failed; |
| 2889 | } |
| 2890 | |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame^] | 2891 | if (ha->mqenable && shost_use_blk_mq(host)) { |
| 2892 | /* number of hardware queues supported by blk/scsi-mq*/ |
| 2893 | host->nr_hw_queues = ha->max_qpairs; |
| 2894 | |
| 2895 | ql_dbg(ql_dbg_init, base_vha, 0x0192, |
| 2896 | "blk/scsi-mq enabled, HW queues = %d.\n", host->nr_hw_queues); |
| 2897 | } else |
| 2898 | ql_dbg(ql_dbg_init, base_vha, 0x0193, |
| 2899 | "blk/scsi-mq disabled.\n"); |
| 2900 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2901 | qlt_probe_one_stage1(base_vha, ha); |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 2902 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 2903 | pci_save_state(pdev); |
| 2904 | |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 2905 | /* Assign back pointers */ |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2906 | rsp->req = req; |
| 2907 | req->rsp = rsp; |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 2908 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2909 | if (IS_QLAFX00(ha)) { |
| 2910 | ha->rsp_q_map[0] = rsp; |
| 2911 | ha->req_q_map[0] = req; |
| 2912 | set_bit(0, ha->req_qid_map); |
| 2913 | set_bit(0, ha->rsp_qid_map); |
| 2914 | } |
| 2915 | |
Andrew Vasquez | 0802999 | 2009-03-24 09:07:55 -0700 | [diff] [blame] | 2916 | /* FWI2-capable only. */ |
| 2917 | req->req_q_in = &ha->iobase->isp24.req_q_in; |
| 2918 | req->req_q_out = &ha->iobase->isp24.req_q_out; |
| 2919 | rsp->rsp_q_in = &ha->iobase->isp24.rsp_q_in; |
| 2920 | rsp->rsp_q_out = &ha->iobase->isp24.rsp_q_out; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2921 | if (ha->mqenable || IS_QLA83XX(ha) || IS_QLA27XX(ha)) { |
Andrew Vasquez | 0802999 | 2009-03-24 09:07:55 -0700 | [diff] [blame] | 2922 | req->req_q_in = &ha->mqiobase->isp25mq.req_q_in; |
| 2923 | req->req_q_out = &ha->mqiobase->isp25mq.req_q_out; |
| 2924 | rsp->rsp_q_in = &ha->mqiobase->isp25mq.rsp_q_in; |
| 2925 | rsp->rsp_q_out = &ha->mqiobase->isp25mq.rsp_q_out; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 2926 | } |
| 2927 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2928 | if (IS_QLAFX00(ha)) { |
| 2929 | req->req_q_in = &ha->iobase->ispfx00.req_q_in; |
| 2930 | req->req_q_out = &ha->iobase->ispfx00.req_q_out; |
| 2931 | rsp->rsp_q_in = &ha->iobase->ispfx00.rsp_q_in; |
| 2932 | rsp->rsp_q_out = &ha->iobase->ispfx00.rsp_q_out; |
| 2933 | } |
| 2934 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2935 | if (IS_P3P_TYPE(ha)) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2936 | req->req_q_out = &ha->iobase->isp82.req_q_out[0]; |
| 2937 | rsp->rsp_q_in = &ha->iobase->isp82.rsp_q_in[0]; |
| 2938 | rsp->rsp_q_out = &ha->iobase->isp82.rsp_q_out[0]; |
| 2939 | } |
| 2940 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2941 | ql_dbg(ql_dbg_multiq, base_vha, 0xc009, |
| 2942 | "rsp_q_map=%p req_q_map=%p rsp->req=%p req->rsp=%p.\n", |
| 2943 | ha->rsp_q_map, ha->req_q_map, rsp->req, req->rsp); |
| 2944 | ql_dbg(ql_dbg_multiq, base_vha, 0xc00a, |
| 2945 | "req->req_q_in=%p req->req_q_out=%p " |
| 2946 | "rsp->rsp_q_in=%p rsp->rsp_q_out=%p.\n", |
| 2947 | req->req_q_in, req->req_q_out, |
| 2948 | rsp->rsp_q_in, rsp->rsp_q_out); |
| 2949 | ql_dbg(ql_dbg_init, base_vha, 0x003e, |
| 2950 | "rsp_q_map=%p req_q_map=%p rsp->req=%p req->rsp=%p.\n", |
| 2951 | ha->rsp_q_map, ha->req_q_map, rsp->req, req->rsp); |
| 2952 | ql_dbg(ql_dbg_init, base_vha, 0x003f, |
| 2953 | "req->req_q_in=%p req->req_q_out=%p rsp->rsp_q_in=%p rsp->rsp_q_out=%p.\n", |
| 2954 | 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] | 2955 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2956 | if (ha->isp_ops->initialize_adapter(base_vha)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2957 | ql_log(ql_log_fatal, base_vha, 0x00d6, |
| 2958 | "Failed to initialize adapter - Adapter flags %x.\n", |
| 2959 | base_vha->device_flags); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2960 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2961 | if (IS_QLA82XX(ha)) { |
| 2962 | qla82xx_idc_lock(ha); |
| 2963 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 2964 | QLA8XXX_DEV_FAILED); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2965 | qla82xx_idc_unlock(ha); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2966 | ql_log(ql_log_fatal, base_vha, 0x00d7, |
| 2967 | "HW State: FAILED.\n"); |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2968 | } else if (IS_QLA8044(ha)) { |
| 2969 | qla8044_idc_lock(ha); |
| 2970 | qla8044_wr_direct(base_vha, |
| 2971 | QLA8044_CRB_DEV_STATE_INDEX, |
| 2972 | QLA8XXX_DEV_FAILED); |
| 2973 | qla8044_idc_unlock(ha); |
| 2974 | ql_log(ql_log_fatal, base_vha, 0x0150, |
| 2975 | "HW State: FAILED.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2976 | } |
| 2977 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2978 | ret = -ENODEV; |
| 2979 | goto probe_failed; |
| 2980 | } |
| 2981 | |
Chad Dupuis | 3b1bef6 | 2014-02-26 04:15:04 -0500 | [diff] [blame] | 2982 | if (IS_QLAFX00(ha)) |
| 2983 | host->can_queue = QLAFX00_MAX_CANQUEUE; |
| 2984 | else |
| 2985 | host->can_queue = req->num_outstanding_cmds - 10; |
| 2986 | |
| 2987 | ql_dbg(ql_dbg_init, base_vha, 0x0032, |
| 2988 | "can_queue=%d, req=%p, mgmt_svr_loop_id=%d, sg_tablesize=%d.\n", |
| 2989 | host->can_queue, base_vha->req, |
| 2990 | base_vha->mgmt_svr_loop_id, host->sg_tablesize); |
| 2991 | |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame^] | 2992 | if (ha->mqenable) { |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 2993 | ha->wq = alloc_workqueue("qla2xxx_wq", WQ_MEM_RECLAIM, 1); |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame^] | 2994 | /* Create start of day qpairs for Block MQ */ |
| 2995 | if (shost_use_blk_mq(host)) { |
| 2996 | for (i = 0; i < ha->max_qpairs; i++) |
| 2997 | qla2xxx_create_qpair(base_vha, 5, 0); |
| 2998 | } |
| 2999 | } |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 3000 | |
Andrew Vasquez | cbc8eb6 | 2009-06-03 09:55:17 -0700 | [diff] [blame] | 3001 | if (ha->flags.running_gold_fw) |
| 3002 | goto skip_dpc; |
| 3003 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3004 | /* |
| 3005 | * Startup the kernel thread for this host adapter |
| 3006 | */ |
| 3007 | ha->dpc_thread = kthread_create(qla2x00_do_dpc, ha, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3008 | "%s_dpc", base_vha->host_str); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3009 | if (IS_ERR(ha->dpc_thread)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3010 | ql_log(ql_log_fatal, base_vha, 0x00ed, |
| 3011 | "Failed to start DPC thread.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3012 | ret = PTR_ERR(ha->dpc_thread); |
| 3013 | goto probe_failed; |
| 3014 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3015 | ql_dbg(ql_dbg_init, base_vha, 0x00ee, |
| 3016 | "DPC thread started successfully.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3017 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3018 | /* |
| 3019 | * If we're not coming up in initiator mode, we might sit for |
| 3020 | * a while without waking up the dpc thread, which leads to a |
| 3021 | * stuck process warning. So just kick the dpc once here and |
| 3022 | * let the kthread start (and go back to sleep in qla2x00_do_dpc). |
| 3023 | */ |
| 3024 | qla2xxx_wake_dpc(base_vha); |
| 3025 | |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 3026 | INIT_WORK(&ha->board_disable, qla2x00_disable_board_on_pci_error); |
| 3027 | |
Saurav Kashyap | 8117877 | 2012-08-22 14:21:04 -0400 | [diff] [blame] | 3028 | if (IS_QLA8031(ha) || IS_MCTP_CAPABLE(ha)) { |
| 3029 | sprintf(wq_name, "qla2xxx_%lu_dpc_lp_wq", base_vha->host_no); |
| 3030 | ha->dpc_lp_wq = create_singlethread_workqueue(wq_name); |
| 3031 | INIT_WORK(&ha->idc_aen, qla83xx_service_idc_aen); |
| 3032 | |
| 3033 | sprintf(wq_name, "qla2xxx_%lu_dpc_hp_wq", base_vha->host_no); |
| 3034 | ha->dpc_hp_wq = create_singlethread_workqueue(wq_name); |
| 3035 | INIT_WORK(&ha->nic_core_reset, qla83xx_nic_core_reset_work); |
| 3036 | INIT_WORK(&ha->idc_state_handler, |
| 3037 | qla83xx_idc_state_handler_work); |
| 3038 | INIT_WORK(&ha->nic_core_unrecoverable, |
| 3039 | qla83xx_nic_core_unrecoverable_work); |
| 3040 | } |
| 3041 | |
Andrew Vasquez | cbc8eb6 | 2009-06-03 09:55:17 -0700 | [diff] [blame] | 3042 | skip_dpc: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3043 | list_add_tail(&base_vha->list, &ha->vp_list); |
| 3044 | base_vha->host->irq = ha->pdev->irq; |
| 3045 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3046 | /* Initialized the timer */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3047 | qla2x00_start_timer(base_vha, qla2x00_timer, WATCH_INTERVAL); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3048 | ql_dbg(ql_dbg_init, base_vha, 0x00ef, |
| 3049 | "Started qla2x00_timer with " |
| 3050 | "interval=%d.\n", WATCH_INTERVAL); |
| 3051 | ql_dbg(ql_dbg_init, base_vha, 0x00f0, |
| 3052 | "Detected hba at address=%p.\n", |
| 3053 | ha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3054 | |
Arun Easi | e02587d | 2011-08-16 11:29:23 -0700 | [diff] [blame] | 3055 | if (IS_T10_PI_CAPABLE(ha) && ql2xenabledif) { |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 3056 | if (ha->fw_attributes & BIT_4) { |
Arun Easi | 9e522cd | 2012-08-22 14:21:31 -0400 | [diff] [blame] | 3057 | int prot = 0, guard; |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 3058 | base_vha->flags.difdix_supported = 1; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3059 | ql_dbg(ql_dbg_init, base_vha, 0x00f1, |
| 3060 | "Registering for DIF/DIX type 1 and 3 protection.\n"); |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 3061 | if (ql2xenabledif == 1) |
| 3062 | prot = SHOST_DIX_TYPE0_PROTECTION; |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 3063 | scsi_host_set_prot(host, |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 3064 | prot | SHOST_DIF_TYPE1_PROTECTION |
Arun Easi | 0c47087 | 2010-07-23 15:28:38 +0500 | [diff] [blame] | 3065 | | SHOST_DIF_TYPE2_PROTECTION |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 3066 | | SHOST_DIF_TYPE3_PROTECTION |
| 3067 | | SHOST_DIX_TYPE1_PROTECTION |
Arun Easi | 0c47087 | 2010-07-23 15:28:38 +0500 | [diff] [blame] | 3068 | | SHOST_DIX_TYPE2_PROTECTION |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 3069 | | SHOST_DIX_TYPE3_PROTECTION); |
Arun Easi | 9e522cd | 2012-08-22 14:21:31 -0400 | [diff] [blame] | 3070 | |
| 3071 | guard = SHOST_DIX_GUARD_CRC; |
| 3072 | |
| 3073 | if (IS_PI_IPGUARD_CAPABLE(ha) && |
| 3074 | (ql2xenabledif > 1 || IS_PI_DIFB_DIX0_CAPABLE(ha))) |
| 3075 | guard |= SHOST_DIX_GUARD_IP; |
| 3076 | |
| 3077 | scsi_host_set_guard(host, guard); |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 3078 | } else |
| 3079 | base_vha->flags.difdix_supported = 0; |
| 3080 | } |
| 3081 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3082 | ha->isp_ops->enable_intrs(ha); |
| 3083 | |
Armen Baloyan | 1fe19ee | 2013-08-27 01:37:41 -0400 | [diff] [blame] | 3084 | if (IS_QLAFX00(ha)) { |
| 3085 | ret = qlafx00_fx_disc(base_vha, |
| 3086 | &base_vha->hw->mr.fcport, FXDISC_GET_CONFIG_INFO); |
| 3087 | host->sg_tablesize = (ha->mr.extended_io_enabled) ? |
| 3088 | QLA_SG_ALL : 128; |
| 3089 | } |
| 3090 | |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 3091 | ret = scsi_add_host(host, &pdev->dev); |
| 3092 | if (ret) |
| 3093 | goto probe_failed; |
| 3094 | |
Michael Reed | 1486400 | 2009-12-02 09:11:16 -0600 | [diff] [blame] | 3095 | base_vha->flags.init_done = 1; |
| 3096 | base_vha->flags.online = 1; |
Saurav Kashyap | edaa5c7 | 2014-04-11 16:54:14 -0400 | [diff] [blame] | 3097 | ha->prev_minidump_failed = 0; |
Michael Reed | 1486400 | 2009-12-02 09:11:16 -0600 | [diff] [blame] | 3098 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3099 | ql_dbg(ql_dbg_init, base_vha, 0x00f2, |
| 3100 | "Init done and hba is online.\n"); |
| 3101 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3102 | if (qla_ini_mode_enabled(base_vha)) |
| 3103 | scsi_scan_host(host); |
| 3104 | else |
| 3105 | ql_dbg(ql_dbg_init, base_vha, 0x0122, |
| 3106 | "skipping scsi_scan_host() for non-initiator port\n"); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 3107 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3108 | qla2x00_alloc_sysfs_attr(base_vha); |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 3109 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3110 | if (IS_QLAFX00(ha)) { |
| 3111 | ret = qlafx00_fx_disc(base_vha, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3112 | &base_vha->hw->mr.fcport, FXDISC_GET_PORT_INFO); |
| 3113 | |
| 3114 | /* Register system information */ |
| 3115 | ret = qlafx00_fx_disc(base_vha, |
| 3116 | &base_vha->hw->mr.fcport, FXDISC_REG_HOST_INFO); |
| 3117 | } |
| 3118 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3119 | qla2x00_init_host_attr(base_vha); |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 3120 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3121 | qla2x00_dfs_setup(base_vha); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3122 | |
Armen Baloyan | 03eb912 | 2013-10-30 03:38:22 -0400 | [diff] [blame] | 3123 | ql_log(ql_log_info, base_vha, 0x00fb, |
| 3124 | "QLogic %s - %s.\n", ha->model_number, ha->model_desc); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3125 | ql_log(ql_log_info, base_vha, 0x00fc, |
| 3126 | "ISP%04X: %s @ %s hdma%c host#=%ld fw=%s.\n", |
| 3127 | pdev->device, ha->isp_ops->pci_info_str(base_vha, pci_info), |
| 3128 | pci_name(pdev), ha->flags.enable_64bit_addressing ? '+' : '-', |
| 3129 | base_vha->host_no, |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 3130 | 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] | 3131 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3132 | qlt_add_target(ha, base_vha); |
| 3133 | |
Joe Lawrence | 6b38397 | 2014-08-26 17:12:29 -0400 | [diff] [blame] | 3134 | clear_bit(PFLG_DRIVER_PROBING, &base_vha->pci_flags); |
Joe Carnuccio | a29b3dd | 2016-07-06 11:14:19 -0400 | [diff] [blame] | 3135 | |
| 3136 | if (test_bit(UNLOADING, &base_vha->dpc_flags)) |
| 3137 | return -ENODEV; |
| 3138 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3139 | return 0; |
| 3140 | |
Anirban Chakraborty | 6e9f21f | 2009-01-22 09:45:28 -0800 | [diff] [blame] | 3141 | probe_init_failed: |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3142 | qla2x00_free_req_que(ha, req); |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 3143 | ha->req_q_map[0] = NULL; |
| 3144 | clear_bit(0, ha->req_qid_map); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3145 | qla2x00_free_rsp_que(ha, rsp); |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 3146 | ha->rsp_q_map[0] = NULL; |
| 3147 | clear_bit(0, ha->rsp_qid_map); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3148 | ha->max_req_queues = ha->max_rsp_queues = 0; |
Anirban Chakraborty | 6e9f21f | 2009-01-22 09:45:28 -0800 | [diff] [blame] | 3149 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3150 | probe_failed: |
Andrew Vasquez | b997876 | 2009-03-24 09:08:05 -0700 | [diff] [blame] | 3151 | if (base_vha->timer_active) |
| 3152 | qla2x00_stop_timer(base_vha); |
| 3153 | base_vha->flags.online = 0; |
| 3154 | if (ha->dpc_thread) { |
| 3155 | struct task_struct *t = ha->dpc_thread; |
| 3156 | |
| 3157 | ha->dpc_thread = NULL; |
| 3158 | kthread_stop(t); |
| 3159 | } |
| 3160 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3161 | qla2x00_free_device(base_vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3162 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3163 | scsi_host_put(base_vha->host); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3164 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3165 | probe_hw_failed: |
Joe Lawrence | 1a2fbf1 | 2014-08-26 17:11:18 -0400 | [diff] [blame] | 3166 | qla2x00_clear_drv_active(ha); |
| 3167 | |
Saurav Kashyap | 0a63ad1 | 2012-11-21 02:40:43 -0500 | [diff] [blame] | 3168 | iospace_config_failed: |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 3169 | if (IS_P3P_TYPE(ha)) { |
Saurav Kashyap | 0a63ad1 | 2012-11-21 02:40:43 -0500 | [diff] [blame] | 3170 | if (!ha->nx_pcibase) |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3171 | iounmap((device_reg_t *)ha->nx_pcibase); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3172 | if (!ql2xdbwr) |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3173 | iounmap((device_reg_t *)ha->nxdb_wr_ptr); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3174 | } else { |
| 3175 | if (ha->iobase) |
| 3176 | iounmap(ha->iobase); |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3177 | if (ha->cregbase) |
| 3178 | iounmap(ha->cregbase); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3179 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3180 | pci_release_selected_regions(ha->pdev, ha->bars); |
| 3181 | kfree(ha); |
| 3182 | ha = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3183 | |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 3184 | probe_out: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3185 | pci_disable_device(pdev); |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 3186 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3187 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3188 | |
Adrian Bunk | 4c993f7 | 2008-01-14 00:55:16 -0800 | [diff] [blame] | 3189 | static void |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3190 | qla2x00_shutdown(struct pci_dev *pdev) |
| 3191 | { |
| 3192 | scsi_qla_host_t *vha; |
| 3193 | struct qla_hw_data *ha; |
| 3194 | |
Masanari Iida | 552f3f9 | 2013-02-08 01:57:44 -0500 | [diff] [blame] | 3195 | if (!atomic_read(&pdev->enable_cnt)) |
| 3196 | return; |
| 3197 | |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3198 | vha = pci_get_drvdata(pdev); |
| 3199 | ha = vha->hw; |
| 3200 | |
Armen Baloyan | 4247934 | 2013-08-27 01:37:37 -0400 | [diff] [blame] | 3201 | /* Notify ISPFX00 firmware */ |
| 3202 | if (IS_QLAFX00(ha)) |
| 3203 | qlafx00_driver_shutdown(vha, 20); |
| 3204 | |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3205 | /* Turn-off FCE trace */ |
| 3206 | if (ha->flags.fce_enabled) { |
| 3207 | qla2x00_disable_fce_trace(vha, NULL, NULL); |
| 3208 | ha->flags.fce_enabled = 0; |
| 3209 | } |
| 3210 | |
| 3211 | /* Turn-off EFT trace */ |
| 3212 | if (ha->eft) |
| 3213 | qla2x00_disable_eft_trace(vha); |
| 3214 | |
| 3215 | /* Stop currently executing firmware. */ |
| 3216 | qla2x00_try_to_stop_firmware(vha); |
| 3217 | |
| 3218 | /* Turn adapter off line */ |
| 3219 | vha->flags.online = 0; |
| 3220 | |
| 3221 | /* turn-off interrupts on the card */ |
| 3222 | if (ha->interrupts_on) { |
| 3223 | vha->flags.init_done = 0; |
| 3224 | ha->isp_ops->disable_intrs(ha); |
| 3225 | } |
| 3226 | |
| 3227 | qla2x00_free_irqs(vha); |
| 3228 | |
| 3229 | qla2x00_free_fw_dump(ha); |
Chad Dupuis | 61d41f6 | 2014-09-25 05:17:02 -0400 | [diff] [blame] | 3230 | |
| 3231 | pci_disable_pcie_error_reporting(pdev); |
| 3232 | pci_disable_device(pdev); |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3233 | } |
| 3234 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3235 | /* Deletes all the virtual ports for a given ha */ |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3236 | static void |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3237 | 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] | 3238 | { |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3239 | scsi_qla_host_t *vha; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3240 | unsigned long flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3241 | |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 3242 | mutex_lock(&ha->vport_lock); |
| 3243 | while (ha->cur_vport_count) { |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 3244 | spin_lock_irqsave(&ha->vport_slock, flags); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3245 | |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 3246 | BUG_ON(base_vha->list.next == &ha->vp_list); |
| 3247 | /* This assumes first entry in ha->vp_list is always base vha */ |
| 3248 | 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] | 3249 | scsi_host_get(vha->host); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3250 | |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 3251 | spin_unlock_irqrestore(&ha->vport_slock, flags); |
| 3252 | mutex_unlock(&ha->vport_lock); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3253 | |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 3254 | fc_vport_terminate(vha->fc_vport); |
| 3255 | scsi_host_put(vha->host); |
| 3256 | |
| 3257 | mutex_lock(&ha->vport_lock); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3258 | } |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 3259 | mutex_unlock(&ha->vport_lock); |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3260 | } |
Andrew Vasquez | c795c1e | 2008-08-13 21:37:01 -0700 | [diff] [blame] | 3261 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3262 | /* Stops all deferred work threads */ |
| 3263 | static void |
| 3264 | qla2x00_destroy_deferred_work(struct qla_hw_data *ha) |
| 3265 | { |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 3266 | /* Flush the work queue and remove it */ |
| 3267 | if (ha->wq) { |
| 3268 | flush_workqueue(ha->wq); |
| 3269 | destroy_workqueue(ha->wq); |
| 3270 | ha->wq = NULL; |
| 3271 | } |
| 3272 | |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 3273 | /* Cancel all work and destroy DPC workqueues */ |
| 3274 | if (ha->dpc_lp_wq) { |
| 3275 | cancel_work_sync(&ha->idc_aen); |
| 3276 | destroy_workqueue(ha->dpc_lp_wq); |
| 3277 | ha->dpc_lp_wq = NULL; |
| 3278 | } |
| 3279 | |
| 3280 | if (ha->dpc_hp_wq) { |
| 3281 | cancel_work_sync(&ha->nic_core_reset); |
| 3282 | cancel_work_sync(&ha->idc_state_handler); |
| 3283 | cancel_work_sync(&ha->nic_core_unrecoverable); |
| 3284 | destroy_workqueue(ha->dpc_hp_wq); |
| 3285 | ha->dpc_hp_wq = NULL; |
| 3286 | } |
| 3287 | |
Andrew Vasquez | b997876 | 2009-03-24 09:08:05 -0700 | [diff] [blame] | 3288 | /* Kill the kernel thread for this host */ |
| 3289 | if (ha->dpc_thread) { |
| 3290 | struct task_struct *t = ha->dpc_thread; |
| 3291 | |
| 3292 | /* |
| 3293 | * qla2xxx_wake_dpc checks for ->dpc_thread |
| 3294 | * so we need to zero it out. |
| 3295 | */ |
| 3296 | ha->dpc_thread = NULL; |
| 3297 | kthread_stop(t); |
| 3298 | } |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3299 | } |
Andrew Vasquez | b997876 | 2009-03-24 09:08:05 -0700 | [diff] [blame] | 3300 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3301 | static void |
| 3302 | qla2x00_unmap_iobases(struct qla_hw_data *ha) |
| 3303 | { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3304 | if (IS_QLA82XX(ha)) { |
Giridhar Malavali | b963752 | 2010-05-28 15:08:15 -0700 | [diff] [blame] | 3305 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3306 | iounmap((device_reg_t *)ha->nx_pcibase); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3307 | if (!ql2xdbwr) |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3308 | iounmap((device_reg_t *)ha->nxdb_wr_ptr); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3309 | } else { |
| 3310 | if (ha->iobase) |
| 3311 | iounmap(ha->iobase); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3312 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3313 | if (ha->cregbase) |
| 3314 | iounmap(ha->cregbase); |
| 3315 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3316 | if (ha->mqiobase) |
| 3317 | iounmap(ha->mqiobase); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3318 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3319 | if ((IS_QLA83XX(ha) || IS_QLA27XX(ha)) && ha->msixbase) |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3320 | iounmap(ha->msixbase); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3321 | } |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3322 | } |
| 3323 | |
| 3324 | static void |
Joe Lawrence | db7157d | 2014-08-26 17:10:41 -0400 | [diff] [blame] | 3325 | qla2x00_clear_drv_active(struct qla_hw_data *ha) |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3326 | { |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3327 | if (IS_QLA8044(ha)) { |
| 3328 | qla8044_idc_lock(ha); |
Saurav Kashyap | c41afc9 | 2013-11-07 02:54:56 -0500 | [diff] [blame] | 3329 | qla8044_clear_drv_active(ha); |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3330 | qla8044_idc_unlock(ha); |
| 3331 | } else if (IS_QLA82XX(ha)) { |
| 3332 | qla82xx_idc_lock(ha); |
| 3333 | qla82xx_clear_drv_active(ha); |
| 3334 | qla82xx_idc_unlock(ha); |
| 3335 | } |
| 3336 | } |
| 3337 | |
| 3338 | static void |
| 3339 | qla2x00_remove_one(struct pci_dev *pdev) |
| 3340 | { |
| 3341 | scsi_qla_host_t *base_vha; |
| 3342 | struct qla_hw_data *ha; |
| 3343 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3344 | base_vha = pci_get_drvdata(pdev); |
| 3345 | ha = base_vha->hw; |
| 3346 | |
Joe Lawrence | beb9e31 | 2014-08-26 17:12:14 -0400 | [diff] [blame] | 3347 | /* Indicate device removal to prevent future board_disable and wait |
| 3348 | * until any pending board_disable has completed. */ |
| 3349 | set_bit(PFLG_DRIVER_REMOVING, &base_vha->pci_flags); |
| 3350 | cancel_work_sync(&ha->board_disable); |
| 3351 | |
| 3352 | /* |
| 3353 | * If the PCI device is disabled then there was a PCI-disconnect and |
| 3354 | * qla2x00_disable_board_on_pci_error has taken care of most of the |
| 3355 | * resources. |
| 3356 | */ |
| 3357 | if (!atomic_read(&pdev->enable_cnt)) { |
| 3358 | scsi_host_put(base_vha->host); |
| 3359 | kfree(ha); |
| 3360 | pci_set_drvdata(pdev, NULL); |
| 3361 | return; |
| 3362 | } |
| 3363 | |
Sawan Chandak | 638a1a0 | 2014-04-11 16:54:38 -0400 | [diff] [blame] | 3364 | qla2x00_wait_for_hba_ready(base_vha); |
| 3365 | |
Sawan Chandak | 783e0dc | 2016-07-06 11:14:25 -0400 | [diff] [blame] | 3366 | /* if UNLOAD flag is already set, then continue unload, |
| 3367 | * where it was set first. |
| 3368 | */ |
| 3369 | if (test_bit(UNLOADING, &base_vha->dpc_flags)) |
| 3370 | return; |
| 3371 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3372 | set_bit(UNLOADING, &base_vha->dpc_flags); |
| 3373 | |
| 3374 | if (IS_QLAFX00(ha)) |
| 3375 | qlafx00_driver_shutdown(base_vha, 20); |
| 3376 | |
| 3377 | qla2x00_delete_all_vps(ha, base_vha); |
| 3378 | |
| 3379 | if (IS_QLA8031(ha)) { |
| 3380 | ql_dbg(ql_dbg_p3p, base_vha, 0xb07e, |
| 3381 | "Clearing fcoe driver presence.\n"); |
| 3382 | if (qla83xx_clear_drv_presence(base_vha) != QLA_SUCCESS) |
| 3383 | ql_dbg(ql_dbg_p3p, base_vha, 0xb079, |
| 3384 | "Error while clearing DRV-Presence.\n"); |
| 3385 | } |
| 3386 | |
| 3387 | qla2x00_abort_all_cmds(base_vha, DID_NO_CONNECT << 16); |
| 3388 | |
| 3389 | qla2x00_dfs_remove(base_vha); |
| 3390 | |
| 3391 | qla84xx_put_chip(base_vha); |
| 3392 | |
Himanshu Madhani | 2d5a4c3 | 2014-09-25 05:16:55 -0400 | [diff] [blame] | 3393 | /* Laser should be disabled only for ISP2031 */ |
| 3394 | if (IS_QLA2031(ha)) |
| 3395 | qla83xx_disable_laser(base_vha); |
| 3396 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3397 | /* Disable timer */ |
| 3398 | if (base_vha->timer_active) |
| 3399 | qla2x00_stop_timer(base_vha); |
| 3400 | |
| 3401 | base_vha->flags.online = 0; |
| 3402 | |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 3403 | /* free DMA memory */ |
| 3404 | if (ha->exlogin_buf) |
| 3405 | qla2x00_free_exlogin_buffer(ha); |
| 3406 | |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 3407 | /* free DMA memory */ |
| 3408 | if (ha->exchoffld_buf) |
| 3409 | qla2x00_free_exchoffld_buffer(ha); |
| 3410 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3411 | qla2x00_destroy_deferred_work(ha); |
| 3412 | |
| 3413 | qlt_remove_target(ha, base_vha); |
| 3414 | |
| 3415 | qla2x00_free_sysfs_attr(base_vha, true); |
| 3416 | |
| 3417 | fc_remove_host(base_vha->host); |
| 3418 | |
| 3419 | scsi_remove_host(base_vha->host); |
| 3420 | |
| 3421 | qla2x00_free_device(base_vha); |
| 3422 | |
Joe Lawrence | db7157d | 2014-08-26 17:10:41 -0400 | [diff] [blame] | 3423 | qla2x00_clear_drv_active(ha); |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3424 | |
Arun Easi | d2749ff | 2014-09-25 05:16:51 -0400 | [diff] [blame] | 3425 | scsi_host_put(base_vha->host); |
| 3426 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3427 | qla2x00_unmap_iobases(ha); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3428 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3429 | pci_release_selected_regions(ha->pdev, ha->bars); |
| 3430 | kfree(ha); |
| 3431 | ha = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3432 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 3433 | pci_disable_pcie_error_reporting(pdev); |
| 3434 | |
Bernhard Walle | 665db93 | 2007-03-28 00:49:49 +0200 | [diff] [blame] | 3435 | pci_disable_device(pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3436 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3437 | |
| 3438 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3439 | qla2x00_free_device(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3440 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3441 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3442 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 3443 | qla2x00_abort_all_cmds(vha, DID_NO_CONNECT << 16); |
| 3444 | |
| 3445 | /* Disable timer */ |
| 3446 | if (vha->timer_active) |
| 3447 | qla2x00_stop_timer(vha); |
| 3448 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3449 | qla25xx_delete_queues(vha); |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3450 | |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3451 | if (ha->flags.fce_enabled) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3452 | qla2x00_disable_fce_trace(vha, NULL, NULL); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3453 | |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3454 | if (ha->eft) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3455 | qla2x00_disable_eft_trace(vha); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3456 | |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3457 | /* Stop currently executing firmware. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3458 | qla2x00_try_to_stop_firmware(vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3459 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 3460 | vha->flags.online = 0; |
| 3461 | |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3462 | /* turn-off interrupts on the card */ |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3463 | if (ha->interrupts_on) { |
| 3464 | vha->flags.init_done = 0; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 3465 | ha->isp_ops->disable_intrs(ha); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3466 | } |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3467 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3468 | qla2x00_free_irqs(vha); |
| 3469 | |
Chad Dupuis | 8867048 | 2010-07-23 15:28:30 +0500 | [diff] [blame] | 3470 | qla2x00_free_fcports(vha); |
| 3471 | |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3472 | qla2x00_mem_free(ha); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3473 | |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 3474 | qla82xx_md_free(vha); |
| 3475 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3476 | qla2x00_free_queues(ha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3477 | } |
| 3478 | |
Chad Dupuis | 8867048 | 2010-07-23 15:28:30 +0500 | [diff] [blame] | 3479 | void qla2x00_free_fcports(struct scsi_qla_host *vha) |
| 3480 | { |
| 3481 | fc_port_t *fcport, *tfcport; |
| 3482 | |
| 3483 | list_for_each_entry_safe(fcport, tfcport, &vha->vp_fcports, list) { |
| 3484 | list_del(&fcport->list); |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 3485 | qla2x00_clear_loop_id(fcport); |
Chad Dupuis | 8867048 | 2010-07-23 15:28:30 +0500 | [diff] [blame] | 3486 | kfree(fcport); |
| 3487 | fcport = NULL; |
| 3488 | } |
| 3489 | } |
| 3490 | |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3491 | static inline void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3492 | 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] | 3493 | int defer) |
| 3494 | { |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3495 | struct fc_rport *rport; |
Andrew Vasquez | 67becc0 | 2009-08-25 11:36:20 -0700 | [diff] [blame] | 3496 | scsi_qla_host_t *base_vha; |
Madhuranath Iyengar | 044d78e | 2011-01-28 15:17:56 -0800 | [diff] [blame] | 3497 | unsigned long flags; |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3498 | |
| 3499 | if (!fcport->rport) |
| 3500 | return; |
| 3501 | |
| 3502 | rport = fcport->rport; |
| 3503 | if (defer) { |
Andrew Vasquez | 67becc0 | 2009-08-25 11:36:20 -0700 | [diff] [blame] | 3504 | base_vha = pci_get_drvdata(vha->hw->pdev); |
Madhuranath Iyengar | 044d78e | 2011-01-28 15:17:56 -0800 | [diff] [blame] | 3505 | spin_lock_irqsave(vha->host->host_lock, flags); |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3506 | fcport->drport = rport; |
Madhuranath Iyengar | 044d78e | 2011-01-28 15:17:56 -0800 | [diff] [blame] | 3507 | spin_unlock_irqrestore(vha->host->host_lock, flags); |
Alexei Potashnik | df67327 | 2015-07-14 16:00:46 -0400 | [diff] [blame] | 3508 | qlt_do_generation_tick(vha, &base_vha->total_fcport_update_gen); |
Andrew Vasquez | 67becc0 | 2009-08-25 11:36:20 -0700 | [diff] [blame] | 3509 | set_bit(FCPORT_UPDATE_NEEDED, &base_vha->dpc_flags); |
| 3510 | qla2xxx_wake_dpc(base_vha); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3511 | } else { |
Alexei Potashnik | df67327 | 2015-07-14 16:00:46 -0400 | [diff] [blame] | 3512 | int now; |
Alexei Potashnik | d20ed91 | 2015-07-14 16:00:47 -0400 | [diff] [blame] | 3513 | if (rport) |
| 3514 | fc_remote_port_delete(rport); |
Alexei Potashnik | df67327 | 2015-07-14 16:00:46 -0400 | [diff] [blame] | 3515 | qlt_do_generation_tick(vha, &now); |
| 3516 | qlt_fc_port_deleted(vha, fcport, now); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3517 | } |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3518 | } |
| 3519 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3520 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3521 | * qla2x00_mark_device_lost Updates fcport state when device goes offline. |
| 3522 | * |
| 3523 | * Input: ha = adapter block pointer. fcport = port structure pointer. |
| 3524 | * |
| 3525 | * Return: None. |
| 3526 | * |
| 3527 | * Context: |
| 3528 | */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3529 | 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] | 3530 | int do_login, int defer) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3531 | { |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3532 | if (IS_QLAFX00(vha->hw)) { |
| 3533 | qla2x00_set_fcport_state(fcport, FCS_DEVICE_LOST); |
| 3534 | qla2x00_schedule_rport_del(vha, fcport, defer); |
| 3535 | return; |
| 3536 | } |
| 3537 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3538 | if (atomic_read(&fcport->state) == FCS_ONLINE && |
Joe Carnuccio | c6d39e2 | 2012-05-15 14:34:20 -0400 | [diff] [blame] | 3539 | vha->vp_idx == fcport->vha->vp_idx) { |
Chad Dupuis | ec426e1 | 2011-03-30 11:46:32 -0700 | [diff] [blame] | 3540 | qla2x00_set_fcport_state(fcport, FCS_DEVICE_LOST); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3541 | qla2x00_schedule_rport_del(vha, fcport, defer); |
| 3542 | } |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 3543 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3544 | * We may need to retry the login, so don't change the state of the |
| 3545 | * port but do the retries. |
| 3546 | */ |
| 3547 | if (atomic_read(&fcport->state) != FCS_DEVICE_DEAD) |
Chad Dupuis | ec426e1 | 2011-03-30 11:46:32 -0700 | [diff] [blame] | 3548 | qla2x00_set_fcport_state(fcport, FCS_DEVICE_LOST); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3549 | |
| 3550 | if (!do_login) |
| 3551 | return; |
| 3552 | |
Arun Easi | a1d0285 | 2015-08-04 13:38:02 -0400 | [diff] [blame] | 3553 | set_bit(RELOGIN_NEEDED, &vha->dpc_flags); |
| 3554 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3555 | if (fcport->login_retry == 0) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3556 | fcport->login_retry = vha->hw->login_retry_count; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3557 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3558 | ql_dbg(ql_dbg_disc, vha, 0x2067, |
Oleksandr Khoshaba | 7b83355 | 2013-08-27 01:37:27 -0400 | [diff] [blame] | 3559 | "Port login retry %8phN, id = 0x%04x retry cnt=%d.\n", |
| 3560 | fcport->port_name, fcport->loop_id, fcport->login_retry); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3561 | } |
| 3562 | } |
| 3563 | |
| 3564 | /* |
| 3565 | * qla2x00_mark_all_devices_lost |
| 3566 | * Updates fcport state when device goes offline. |
| 3567 | * |
| 3568 | * Input: |
| 3569 | * ha = adapter block pointer. |
| 3570 | * fcport = port structure pointer. |
| 3571 | * |
| 3572 | * Return: |
| 3573 | * None. |
| 3574 | * |
| 3575 | * Context: |
| 3576 | */ |
| 3577 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3578 | qla2x00_mark_all_devices_lost(scsi_qla_host_t *vha, int defer) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3579 | { |
| 3580 | fc_port_t *fcport; |
| 3581 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3582 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
Joe Carnuccio | c6d39e2 | 2012-05-15 14:34:20 -0400 | [diff] [blame] | 3583 | if (vha->vp_idx != 0 && vha->vp_idx != fcport->vha->vp_idx) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3584 | continue; |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 3585 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3586 | /* |
| 3587 | * No point in marking the device as lost, if the device is |
| 3588 | * already DEAD. |
| 3589 | */ |
| 3590 | if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD) |
| 3591 | continue; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3592 | if (atomic_read(&fcport->state) == FCS_ONLINE) { |
Chad Dupuis | ec426e1 | 2011-03-30 11:46:32 -0700 | [diff] [blame] | 3593 | qla2x00_set_fcport_state(fcport, FCS_DEVICE_LOST); |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 3594 | if (defer) |
| 3595 | qla2x00_schedule_rport_del(vha, fcport, defer); |
Joe Carnuccio | c6d39e2 | 2012-05-15 14:34:20 -0400 | [diff] [blame] | 3596 | else if (vha->vp_idx == fcport->vha->vp_idx) |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 3597 | qla2x00_schedule_rport_del(vha, fcport, defer); |
| 3598 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3599 | } |
| 3600 | } |
| 3601 | |
| 3602 | /* |
| 3603 | * qla2x00_mem_alloc |
| 3604 | * Allocates adapter memory. |
| 3605 | * |
| 3606 | * Returns: |
| 3607 | * 0 = success. |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3608 | * !0 = failure. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3609 | */ |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3610 | static int |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3611 | qla2x00_mem_alloc(struct qla_hw_data *ha, uint16_t req_len, uint16_t rsp_len, |
| 3612 | struct req_que **req, struct rsp_que **rsp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3613 | { |
| 3614 | char name[16]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3615 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3616 | 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] | 3617 | &ha->init_cb_dma, GFP_KERNEL); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3618 | if (!ha->init_cb) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3619 | goto fail; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3620 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3621 | if (qlt_mem_alloc(ha) < 0) |
| 3622 | goto fail_free_init_cb; |
| 3623 | |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 3624 | ha->gid_list = dma_alloc_coherent(&ha->pdev->dev, |
| 3625 | qla2x00_gid_list_size(ha), &ha->gid_list_dma, GFP_KERNEL); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3626 | if (!ha->gid_list) |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3627 | goto fail_free_tgt_mem; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3628 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3629 | ha->srb_mempool = mempool_create_slab_pool(SRB_MIN_REQ, srb_cachep); |
| 3630 | if (!ha->srb_mempool) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3631 | goto fail_free_gid_list; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3632 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 3633 | if (IS_P3P_TYPE(ha)) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3634 | /* Allocate cache for CT6 Ctx. */ |
| 3635 | if (!ctx_cachep) { |
| 3636 | ctx_cachep = kmem_cache_create("qla2xxx_ctx", |
| 3637 | sizeof(struct ct6_dsd), 0, |
| 3638 | SLAB_HWCACHE_ALIGN, NULL); |
| 3639 | if (!ctx_cachep) |
| 3640 | goto fail_free_gid_list; |
| 3641 | } |
| 3642 | ha->ctx_mempool = mempool_create_slab_pool(SRB_MIN_REQ, |
| 3643 | ctx_cachep); |
| 3644 | if (!ha->ctx_mempool) |
| 3645 | goto fail_free_srb_mempool; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3646 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0021, |
| 3647 | "ctx_cachep=%p ctx_mempool=%p.\n", |
| 3648 | ctx_cachep, ha->ctx_mempool); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3649 | } |
| 3650 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3651 | /* Get memory for cached NVRAM */ |
| 3652 | ha->nvram = kzalloc(MAX_NVRAM_SIZE, GFP_KERNEL); |
| 3653 | if (!ha->nvram) |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3654 | goto fail_free_ctx_mempool; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3655 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3656 | snprintf(name, sizeof(name), "%s_%d", QLA2XXX_DRIVER_NAME, |
| 3657 | ha->pdev->device); |
| 3658 | ha->s_dma_pool = dma_pool_create(name, &ha->pdev->dev, |
| 3659 | DMA_POOL_SIZE, 8, 0); |
| 3660 | if (!ha->s_dma_pool) |
| 3661 | goto fail_free_nvram; |
| 3662 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3663 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0022, |
| 3664 | "init_cb=%p gid_list=%p, srb_mempool=%p s_dma_pool=%p.\n", |
| 3665 | ha->init_cb, ha->gid_list, ha->srb_mempool, ha->s_dma_pool); |
| 3666 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 3667 | if (IS_P3P_TYPE(ha) || ql2xenabledif) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3668 | ha->dl_dma_pool = dma_pool_create(name, &ha->pdev->dev, |
| 3669 | DSD_LIST_DMA_POOL_SIZE, 8, 0); |
| 3670 | if (!ha->dl_dma_pool) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3671 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0023, |
| 3672 | "Failed to allocate memory for dl_dma_pool.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3673 | goto fail_s_dma_pool; |
| 3674 | } |
| 3675 | |
| 3676 | ha->fcp_cmnd_dma_pool = dma_pool_create(name, &ha->pdev->dev, |
| 3677 | FCP_CMND_DMA_POOL_SIZE, 8, 0); |
| 3678 | if (!ha->fcp_cmnd_dma_pool) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3679 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0024, |
| 3680 | "Failed to allocate memory for fcp_cmnd_dma_pool.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3681 | goto fail_dl_dma_pool; |
| 3682 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3683 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0025, |
| 3684 | "dl_dma_pool=%p fcp_cmnd_dma_pool=%p.\n", |
| 3685 | ha->dl_dma_pool, ha->fcp_cmnd_dma_pool); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3686 | } |
| 3687 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3688 | /* Allocate memory for SNS commands */ |
| 3689 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3690 | /* Get consistent memory allocated for SNS commands */ |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3691 | ha->sns_cmd = dma_alloc_coherent(&ha->pdev->dev, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3692 | sizeof(struct sns_cmd_pkt), &ha->sns_cmd_dma, GFP_KERNEL); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3693 | if (!ha->sns_cmd) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3694 | goto fail_dma_pool; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3695 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0026, |
Joe Perches | d8424f6 | 2011-11-18 09:03:06 -0800 | [diff] [blame] | 3696 | "sns_cmd: %p.\n", ha->sns_cmd); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3697 | } else { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3698 | /* Get consistent memory allocated for MS IOCB */ |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3699 | ha->ms_iocb = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3700 | &ha->ms_iocb_dma); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3701 | if (!ha->ms_iocb) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3702 | goto fail_dma_pool; |
| 3703 | /* Get consistent memory allocated for CT SNS commands */ |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3704 | ha->ct_sns = dma_alloc_coherent(&ha->pdev->dev, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3705 | sizeof(struct ct_sns_pkt), &ha->ct_sns_dma, GFP_KERNEL); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3706 | if (!ha->ct_sns) |
| 3707 | goto fail_free_ms_iocb; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3708 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0027, |
| 3709 | "ms_iocb=%p ct_sns=%p.\n", |
| 3710 | ha->ms_iocb, ha->ct_sns); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3711 | } |
| 3712 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3713 | /* Allocate memory for request ring */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3714 | *req = kzalloc(sizeof(struct req_que), GFP_KERNEL); |
| 3715 | if (!*req) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3716 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0028, |
| 3717 | "Failed to allocate memory for req.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3718 | goto fail_req; |
| 3719 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3720 | (*req)->length = req_len; |
| 3721 | (*req)->ring = dma_alloc_coherent(&ha->pdev->dev, |
| 3722 | ((*req)->length + 1) * sizeof(request_t), |
| 3723 | &(*req)->dma, GFP_KERNEL); |
| 3724 | if (!(*req)->ring) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3725 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0029, |
| 3726 | "Failed to allocate memory for req_ring.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3727 | goto fail_req_ring; |
| 3728 | } |
| 3729 | /* Allocate memory for response ring */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3730 | *rsp = kzalloc(sizeof(struct rsp_que), GFP_KERNEL); |
| 3731 | if (!*rsp) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3732 | ql_log_pci(ql_log_fatal, ha->pdev, 0x002a, |
| 3733 | "Failed to allocate memory for rsp.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3734 | goto fail_rsp; |
| 3735 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3736 | (*rsp)->hw = ha; |
| 3737 | (*rsp)->length = rsp_len; |
| 3738 | (*rsp)->ring = dma_alloc_coherent(&ha->pdev->dev, |
| 3739 | ((*rsp)->length + 1) * sizeof(response_t), |
| 3740 | &(*rsp)->dma, GFP_KERNEL); |
| 3741 | if (!(*rsp)->ring) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3742 | ql_log_pci(ql_log_fatal, ha->pdev, 0x002b, |
| 3743 | "Failed to allocate memory for rsp_ring.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3744 | goto fail_rsp_ring; |
| 3745 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3746 | (*req)->rsp = *rsp; |
| 3747 | (*rsp)->req = *req; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3748 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x002c, |
| 3749 | "req=%p req->length=%d req->ring=%p rsp=%p " |
| 3750 | "rsp->length=%d rsp->ring=%p.\n", |
| 3751 | *req, (*req)->length, (*req)->ring, *rsp, (*rsp)->length, |
| 3752 | (*rsp)->ring); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3753 | /* Allocate memory for NVRAM data for vports */ |
| 3754 | if (ha->nvram_npiv_size) { |
| 3755 | ha->npiv_info = kzalloc(sizeof(struct qla_npiv_entry) * |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3756 | ha->nvram_npiv_size, GFP_KERNEL); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3757 | if (!ha->npiv_info) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3758 | ql_log_pci(ql_log_fatal, ha->pdev, 0x002d, |
| 3759 | "Failed to allocate memory for npiv_info.\n"); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3760 | goto fail_npiv_info; |
| 3761 | } |
| 3762 | } else |
| 3763 | ha->npiv_info = NULL; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3764 | |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 3765 | /* Get consistent memory allocated for EX-INIT-CB. */ |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3766 | if (IS_CNA_CAPABLE(ha) || IS_QLA2031(ha) || IS_QLA27XX(ha)) { |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 3767 | ha->ex_init_cb = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, |
| 3768 | &ha->ex_init_cb_dma); |
| 3769 | if (!ha->ex_init_cb) |
| 3770 | goto fail_ex_init_cb; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3771 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x002e, |
| 3772 | "ex_init_cb=%p.\n", ha->ex_init_cb); |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 3773 | } |
| 3774 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3775 | INIT_LIST_HEAD(&ha->gbl_dsd_list); |
| 3776 | |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 3777 | /* Get consistent memory allocated for Async Port-Database. */ |
| 3778 | if (!IS_FWI2_CAPABLE(ha)) { |
| 3779 | ha->async_pd = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, |
| 3780 | &ha->async_pd_dma); |
| 3781 | if (!ha->async_pd) |
| 3782 | goto fail_async_pd; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3783 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x002f, |
| 3784 | "async_pd=%p.\n", ha->async_pd); |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 3785 | } |
| 3786 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3787 | INIT_LIST_HEAD(&ha->vp_list); |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 3788 | |
| 3789 | /* Allocate memory for our loop_id bitmap */ |
| 3790 | ha->loop_id_map = kzalloc(BITS_TO_LONGS(LOOPID_MAP_SIZE) * sizeof(long), |
| 3791 | GFP_KERNEL); |
| 3792 | if (!ha->loop_id_map) |
| 3793 | goto fail_async_pd; |
| 3794 | else { |
| 3795 | qla2x00_set_reserved_loop_ids(ha); |
| 3796 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0123, |
Dan Carpenter | b2a72ec | 2014-01-21 10:00:10 +0300 | [diff] [blame] | 3797 | "loop_id_map=%p.\n", ha->loop_id_map); |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 3798 | } |
| 3799 | |
Dan Carpenter | b2a72ec | 2014-01-21 10:00:10 +0300 | [diff] [blame] | 3800 | return 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3801 | |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 3802 | fail_async_pd: |
| 3803 | 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] | 3804 | fail_ex_init_cb: |
| 3805 | kfree(ha->npiv_info); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3806 | fail_npiv_info: |
| 3807 | dma_free_coherent(&ha->pdev->dev, ((*rsp)->length + 1) * |
| 3808 | sizeof(response_t), (*rsp)->ring, (*rsp)->dma); |
| 3809 | (*rsp)->ring = NULL; |
| 3810 | (*rsp)->dma = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3811 | fail_rsp_ring: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3812 | kfree(*rsp); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3813 | fail_rsp: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3814 | dma_free_coherent(&ha->pdev->dev, ((*req)->length + 1) * |
| 3815 | sizeof(request_t), (*req)->ring, (*req)->dma); |
| 3816 | (*req)->ring = NULL; |
| 3817 | (*req)->dma = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3818 | fail_req_ring: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3819 | kfree(*req); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3820 | fail_req: |
| 3821 | dma_free_coherent(&ha->pdev->dev, sizeof(struct ct_sns_pkt), |
| 3822 | ha->ct_sns, ha->ct_sns_dma); |
| 3823 | ha->ct_sns = NULL; |
| 3824 | ha->ct_sns_dma = 0; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3825 | fail_free_ms_iocb: |
| 3826 | dma_pool_free(ha->s_dma_pool, ha->ms_iocb, ha->ms_iocb_dma); |
| 3827 | ha->ms_iocb = NULL; |
| 3828 | ha->ms_iocb_dma = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3829 | fail_dma_pool: |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 3830 | if (IS_QLA82XX(ha) || ql2xenabledif) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3831 | dma_pool_destroy(ha->fcp_cmnd_dma_pool); |
| 3832 | ha->fcp_cmnd_dma_pool = NULL; |
| 3833 | } |
| 3834 | fail_dl_dma_pool: |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 3835 | if (IS_QLA82XX(ha) || ql2xenabledif) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3836 | dma_pool_destroy(ha->dl_dma_pool); |
| 3837 | ha->dl_dma_pool = NULL; |
| 3838 | } |
| 3839 | fail_s_dma_pool: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3840 | dma_pool_destroy(ha->s_dma_pool); |
| 3841 | ha->s_dma_pool = NULL; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3842 | fail_free_nvram: |
| 3843 | kfree(ha->nvram); |
| 3844 | ha->nvram = NULL; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3845 | fail_free_ctx_mempool: |
| 3846 | mempool_destroy(ha->ctx_mempool); |
| 3847 | ha->ctx_mempool = NULL; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3848 | fail_free_srb_mempool: |
| 3849 | mempool_destroy(ha->srb_mempool); |
| 3850 | ha->srb_mempool = NULL; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3851 | fail_free_gid_list: |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 3852 | dma_free_coherent(&ha->pdev->dev, qla2x00_gid_list_size(ha), |
| 3853 | ha->gid_list, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3854 | ha->gid_list_dma); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3855 | ha->gid_list = NULL; |
| 3856 | ha->gid_list_dma = 0; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3857 | fail_free_tgt_mem: |
| 3858 | qlt_mem_free(ha); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3859 | fail_free_init_cb: |
| 3860 | dma_free_coherent(&ha->pdev->dev, ha->init_cb_size, ha->init_cb, |
| 3861 | ha->init_cb_dma); |
| 3862 | ha->init_cb = NULL; |
| 3863 | ha->init_cb_dma = 0; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3864 | fail: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3865 | ql_log(ql_log_fatal, NULL, 0x0030, |
| 3866 | "Memory allocation failure.\n"); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3867 | return -ENOMEM; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3868 | } |
| 3869 | |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 3870 | int |
| 3871 | qla2x00_set_exlogins_buffer(scsi_qla_host_t *vha) |
| 3872 | { |
| 3873 | int rval; |
| 3874 | uint16_t size, max_cnt, temp; |
| 3875 | struct qla_hw_data *ha = vha->hw; |
| 3876 | |
| 3877 | /* Return if we don't need to alloacate any extended logins */ |
| 3878 | if (!ql2xexlogins) |
| 3879 | return QLA_SUCCESS; |
| 3880 | |
| 3881 | ql_log(ql_log_info, vha, 0xd021, "EXLOGIN count: %d.\n", ql2xexlogins); |
| 3882 | max_cnt = 0; |
| 3883 | rval = qla_get_exlogin_status(vha, &size, &max_cnt); |
| 3884 | if (rval != QLA_SUCCESS) { |
| 3885 | ql_log_pci(ql_log_fatal, ha->pdev, 0xd029, |
| 3886 | "Failed to get exlogin status.\n"); |
| 3887 | return rval; |
| 3888 | } |
| 3889 | |
| 3890 | temp = (ql2xexlogins > max_cnt) ? max_cnt : ql2xexlogins; |
| 3891 | ha->exlogin_size = (size * temp); |
| 3892 | ql_log(ql_log_info, vha, 0xd024, |
| 3893 | "EXLOGIN: max_logins=%d, portdb=0x%x, total=%d.\n", |
| 3894 | max_cnt, size, temp); |
| 3895 | |
| 3896 | ql_log(ql_log_info, vha, 0xd025, "EXLOGIN: requested size=0x%x\n", |
| 3897 | ha->exlogin_size); |
| 3898 | |
| 3899 | /* Get consistent memory for extended logins */ |
| 3900 | ha->exlogin_buf = dma_alloc_coherent(&ha->pdev->dev, |
| 3901 | ha->exlogin_size, &ha->exlogin_buf_dma, GFP_KERNEL); |
| 3902 | if (!ha->exlogin_buf) { |
| 3903 | ql_log_pci(ql_log_fatal, ha->pdev, 0xd02a, |
| 3904 | "Failed to allocate memory for exlogin_buf_dma.\n"); |
| 3905 | return -ENOMEM; |
| 3906 | } |
| 3907 | |
| 3908 | /* Now configure the dma buffer */ |
| 3909 | rval = qla_set_exlogin_mem_cfg(vha, ha->exlogin_buf_dma); |
| 3910 | if (rval) { |
| 3911 | ql_log(ql_log_fatal, vha, 0x00cf, |
| 3912 | "Setup extended login buffer ****FAILED****.\n"); |
| 3913 | qla2x00_free_exlogin_buffer(ha); |
| 3914 | } |
| 3915 | |
| 3916 | return rval; |
| 3917 | } |
| 3918 | |
| 3919 | /* |
| 3920 | * qla2x00_free_exlogin_buffer |
| 3921 | * |
| 3922 | * Input: |
| 3923 | * ha = adapter block pointer |
| 3924 | */ |
| 3925 | void |
| 3926 | qla2x00_free_exlogin_buffer(struct qla_hw_data *ha) |
| 3927 | { |
| 3928 | if (ha->exlogin_buf) { |
| 3929 | dma_free_coherent(&ha->pdev->dev, ha->exlogin_size, |
| 3930 | ha->exlogin_buf, ha->exlogin_buf_dma); |
| 3931 | ha->exlogin_buf = NULL; |
| 3932 | ha->exlogin_size = 0; |
| 3933 | } |
| 3934 | } |
| 3935 | |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 3936 | int |
| 3937 | qla2x00_set_exchoffld_buffer(scsi_qla_host_t *vha) |
| 3938 | { |
| 3939 | int rval; |
| 3940 | uint16_t size, max_cnt, temp; |
| 3941 | struct qla_hw_data *ha = vha->hw; |
| 3942 | |
| 3943 | /* Return if we don't need to alloacate any extended logins */ |
| 3944 | if (!ql2xexchoffld) |
| 3945 | return QLA_SUCCESS; |
| 3946 | |
| 3947 | ql_log(ql_log_info, vha, 0xd014, |
| 3948 | "Exchange offload count: %d.\n", ql2xexlogins); |
| 3949 | |
| 3950 | max_cnt = 0; |
| 3951 | rval = qla_get_exchoffld_status(vha, &size, &max_cnt); |
| 3952 | if (rval != QLA_SUCCESS) { |
| 3953 | ql_log_pci(ql_log_fatal, ha->pdev, 0xd012, |
| 3954 | "Failed to get exlogin status.\n"); |
| 3955 | return rval; |
| 3956 | } |
| 3957 | |
| 3958 | temp = (ql2xexchoffld > max_cnt) ? max_cnt : ql2xexchoffld; |
| 3959 | ha->exchoffld_size = (size * temp); |
| 3960 | ql_log(ql_log_info, vha, 0xd016, |
| 3961 | "Exchange offload: max_count=%d, buffers=0x%x, total=%d.\n", |
| 3962 | max_cnt, size, temp); |
| 3963 | |
| 3964 | ql_log(ql_log_info, vha, 0xd017, |
| 3965 | "Exchange Buffers requested size = 0x%x\n", ha->exchoffld_size); |
| 3966 | |
| 3967 | /* Get consistent memory for extended logins */ |
| 3968 | ha->exchoffld_buf = dma_alloc_coherent(&ha->pdev->dev, |
| 3969 | ha->exchoffld_size, &ha->exchoffld_buf_dma, GFP_KERNEL); |
| 3970 | if (!ha->exchoffld_buf) { |
| 3971 | ql_log_pci(ql_log_fatal, ha->pdev, 0xd013, |
| 3972 | "Failed to allocate memory for exchoffld_buf_dma.\n"); |
| 3973 | return -ENOMEM; |
| 3974 | } |
| 3975 | |
| 3976 | /* Now configure the dma buffer */ |
| 3977 | rval = qla_set_exchoffld_mem_cfg(vha, ha->exchoffld_buf_dma); |
| 3978 | if (rval) { |
| 3979 | ql_log(ql_log_fatal, vha, 0xd02e, |
| 3980 | "Setup exchange offload buffer ****FAILED****.\n"); |
| 3981 | qla2x00_free_exchoffld_buffer(ha); |
| 3982 | } |
| 3983 | |
| 3984 | return rval; |
| 3985 | } |
| 3986 | |
| 3987 | /* |
| 3988 | * qla2x00_free_exchoffld_buffer |
| 3989 | * |
| 3990 | * Input: |
| 3991 | * ha = adapter block pointer |
| 3992 | */ |
| 3993 | void |
| 3994 | qla2x00_free_exchoffld_buffer(struct qla_hw_data *ha) |
| 3995 | { |
| 3996 | if (ha->exchoffld_buf) { |
| 3997 | dma_free_coherent(&ha->pdev->dev, ha->exchoffld_size, |
| 3998 | ha->exchoffld_buf, ha->exchoffld_buf_dma); |
| 3999 | ha->exchoffld_buf = NULL; |
| 4000 | ha->exchoffld_size = 0; |
| 4001 | } |
| 4002 | } |
| 4003 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4004 | /* |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 4005 | * qla2x00_free_fw_dump |
| 4006 | * Frees fw dump stuff. |
| 4007 | * |
| 4008 | * Input: |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 4009 | * ha = adapter block pointer |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 4010 | */ |
| 4011 | static void |
| 4012 | qla2x00_free_fw_dump(struct qla_hw_data *ha) |
| 4013 | { |
| 4014 | if (ha->fce) |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4015 | dma_free_coherent(&ha->pdev->dev, |
| 4016 | FCE_SIZE, ha->fce, ha->fce_dma); |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 4017 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4018 | if (ha->eft) |
| 4019 | dma_free_coherent(&ha->pdev->dev, |
| 4020 | EFT_SIZE, ha->eft, ha->eft_dma); |
| 4021 | |
| 4022 | if (ha->fw_dump) |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 4023 | vfree(ha->fw_dump); |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4024 | if (ha->fw_dump_template) |
| 4025 | vfree(ha->fw_dump_template); |
| 4026 | |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 4027 | ha->fce = NULL; |
| 4028 | ha->fce_dma = 0; |
| 4029 | ha->eft = NULL; |
| 4030 | ha->eft_dma = 0; |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 4031 | ha->fw_dumped = 0; |
Hiral Patel | 61f098d | 2014-04-11 16:54:21 -0400 | [diff] [blame] | 4032 | ha->fw_dump_cap_flags = 0; |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 4033 | ha->fw_dump_reading = 0; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 4034 | ha->fw_dump = NULL; |
| 4035 | ha->fw_dump_len = 0; |
| 4036 | ha->fw_dump_template = NULL; |
| 4037 | ha->fw_dump_template_len = 0; |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 4038 | } |
| 4039 | |
| 4040 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4041 | * qla2x00_mem_free |
| 4042 | * Frees all adapter allocated memory. |
| 4043 | * |
| 4044 | * Input: |
| 4045 | * ha = adapter block pointer. |
| 4046 | */ |
Adrian Bunk | a824ebb | 2008-01-17 09:02:15 -0800 | [diff] [blame] | 4047 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4048 | qla2x00_mem_free(struct qla_hw_data *ha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4049 | { |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 4050 | qla2x00_free_fw_dump(ha); |
| 4051 | |
Saurav Kashyap | 8117877 | 2012-08-22 14:21:04 -0400 | [diff] [blame] | 4052 | if (ha->mctp_dump) |
| 4053 | dma_free_coherent(&ha->pdev->dev, MCTP_DUMP_SIZE, ha->mctp_dump, |
| 4054 | ha->mctp_dump_dma); |
| 4055 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 4056 | if (ha->srb_mempool) |
| 4057 | mempool_destroy(ha->srb_mempool); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4058 | |
Andrew Vasquez | 11bbc1d | 2009-06-03 09:55:14 -0700 | [diff] [blame] | 4059 | if (ha->dcbx_tlv) |
| 4060 | dma_free_coherent(&ha->pdev->dev, DCBX_TLV_DATA_SIZE, |
| 4061 | ha->dcbx_tlv, ha->dcbx_tlv_dma); |
| 4062 | |
Andrew Vasquez | ce0423f | 2009-06-03 09:55:13 -0700 | [diff] [blame] | 4063 | if (ha->xgmac_data) |
| 4064 | dma_free_coherent(&ha->pdev->dev, XGMAC_DATA_SIZE, |
| 4065 | ha->xgmac_data, ha->xgmac_data_dma); |
| 4066 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4067 | if (ha->sns_cmd) |
| 4068 | dma_free_coherent(&ha->pdev->dev, sizeof(struct sns_cmd_pkt), |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4069 | ha->sns_cmd, ha->sns_cmd_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4070 | |
| 4071 | if (ha->ct_sns) |
| 4072 | dma_free_coherent(&ha->pdev->dev, sizeof(struct ct_sns_pkt), |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4073 | ha->ct_sns, ha->ct_sns_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4074 | |
Andrew Vasquez | 88729e5 | 2006-06-23 16:10:50 -0700 | [diff] [blame] | 4075 | if (ha->sfp_data) |
| 4076 | dma_pool_free(ha->s_dma_pool, ha->sfp_data, ha->sfp_data_dma); |
| 4077 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4078 | if (ha->ms_iocb) |
| 4079 | dma_pool_free(ha->s_dma_pool, ha->ms_iocb, ha->ms_iocb_dma); |
| 4080 | |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 4081 | if (ha->ex_init_cb) |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4082 | dma_pool_free(ha->s_dma_pool, |
| 4083 | ha->ex_init_cb, ha->ex_init_cb_dma); |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 4084 | |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 4085 | if (ha->async_pd) |
| 4086 | dma_pool_free(ha->s_dma_pool, ha->async_pd, ha->async_pd_dma); |
| 4087 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4088 | if (ha->s_dma_pool) |
| 4089 | dma_pool_destroy(ha->s_dma_pool); |
| 4090 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4091 | if (ha->gid_list) |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 4092 | dma_free_coherent(&ha->pdev->dev, qla2x00_gid_list_size(ha), |
| 4093 | ha->gid_list, ha->gid_list_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4094 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4095 | if (IS_QLA82XX(ha)) { |
| 4096 | if (!list_empty(&ha->gbl_dsd_list)) { |
| 4097 | struct dsd_dma *dsd_ptr, *tdsd_ptr; |
| 4098 | |
| 4099 | /* clean up allocated prev pool */ |
| 4100 | list_for_each_entry_safe(dsd_ptr, |
| 4101 | tdsd_ptr, &ha->gbl_dsd_list, list) { |
| 4102 | dma_pool_free(ha->dl_dma_pool, |
| 4103 | dsd_ptr->dsd_addr, dsd_ptr->dsd_list_dma); |
| 4104 | list_del(&dsd_ptr->list); |
| 4105 | kfree(dsd_ptr); |
| 4106 | } |
| 4107 | } |
| 4108 | } |
| 4109 | |
| 4110 | if (ha->dl_dma_pool) |
| 4111 | dma_pool_destroy(ha->dl_dma_pool); |
| 4112 | |
| 4113 | if (ha->fcp_cmnd_dma_pool) |
| 4114 | dma_pool_destroy(ha->fcp_cmnd_dma_pool); |
| 4115 | |
| 4116 | if (ha->ctx_mempool) |
| 4117 | mempool_destroy(ha->ctx_mempool); |
| 4118 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 4119 | qlt_mem_free(ha); |
| 4120 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4121 | if (ha->init_cb) |
| 4122 | dma_free_coherent(&ha->pdev->dev, ha->init_cb_size, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4123 | ha->init_cb, ha->init_cb_dma); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4124 | vfree(ha->optrom_buffer); |
| 4125 | kfree(ha->nvram); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4126 | kfree(ha->npiv_info); |
Andrew Vasquez | 7a67735 | 2012-02-09 11:15:56 -0800 | [diff] [blame] | 4127 | kfree(ha->swl); |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 4128 | kfree(ha->loop_id_map); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4129 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 4130 | ha->srb_mempool = NULL; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4131 | ha->ctx_mempool = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4132 | ha->sns_cmd = NULL; |
| 4133 | ha->sns_cmd_dma = 0; |
| 4134 | ha->ct_sns = NULL; |
| 4135 | ha->ct_sns_dma = 0; |
| 4136 | ha->ms_iocb = NULL; |
| 4137 | ha->ms_iocb_dma = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4138 | ha->init_cb = NULL; |
| 4139 | ha->init_cb_dma = 0; |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 4140 | ha->ex_init_cb = NULL; |
| 4141 | ha->ex_init_cb_dma = 0; |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 4142 | ha->async_pd = NULL; |
| 4143 | ha->async_pd_dma = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4144 | |
| 4145 | ha->s_dma_pool = NULL; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4146 | ha->dl_dma_pool = NULL; |
| 4147 | ha->fcp_cmnd_dma_pool = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4148 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4149 | ha->gid_list = NULL; |
| 4150 | ha->gid_list_dma = 0; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 4151 | |
| 4152 | ha->tgt.atio_ring = NULL; |
| 4153 | ha->tgt.atio_dma = 0; |
| 4154 | ha->tgt.tgt_vp_map = NULL; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4155 | } |
| 4156 | |
| 4157 | struct scsi_qla_host *qla2x00_create_host(struct scsi_host_template *sht, |
| 4158 | struct qla_hw_data *ha) |
| 4159 | { |
| 4160 | struct Scsi_Host *host; |
| 4161 | struct scsi_qla_host *vha = NULL; |
| 4162 | |
| 4163 | host = scsi_host_alloc(sht, sizeof(scsi_qla_host_t)); |
| 4164 | if (host == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4165 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0107, |
| 4166 | "Failed to allocate host from the scsi layer, aborting.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4167 | goto fail; |
| 4168 | } |
| 4169 | |
| 4170 | /* Clear our data area */ |
| 4171 | vha = shost_priv(host); |
| 4172 | memset(vha, 0, sizeof(scsi_qla_host_t)); |
| 4173 | |
| 4174 | vha->host = host; |
| 4175 | vha->host_no = host->host_no; |
| 4176 | vha->hw = ha; |
| 4177 | |
| 4178 | INIT_LIST_HEAD(&vha->vp_fcports); |
| 4179 | INIT_LIST_HEAD(&vha->work_list); |
| 4180 | INIT_LIST_HEAD(&vha->list); |
Swapnil Nagle | 8b2f5ff | 2015-07-14 16:00:43 -0400 | [diff] [blame] | 4181 | INIT_LIST_HEAD(&vha->qla_cmd_list); |
| 4182 | INIT_LIST_HEAD(&vha->qla_sess_op_cmd_list); |
Alexei Potashnik | 71cdc07 | 2015-12-17 14:57:01 -0500 | [diff] [blame] | 4183 | INIT_LIST_HEAD(&vha->logo_list); |
Alexei Potashnik | b7bd104 | 2015-12-17 14:57:02 -0500 | [diff] [blame] | 4184 | INIT_LIST_HEAD(&vha->plogi_ack_list); |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 4185 | INIT_LIST_HEAD(&vha->qp_list); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4186 | |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4187 | spin_lock_init(&vha->work_lock); |
Swapnil Nagle | 8b2f5ff | 2015-07-14 16:00:43 -0400 | [diff] [blame] | 4188 | spin_lock_init(&vha->cmd_list_lock); |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4189 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4190 | sprintf(vha->host_str, "%s_%ld", QLA2XXX_DRIVER_NAME, vha->host_no); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4191 | ql_dbg(ql_dbg_init, vha, 0x0041, |
| 4192 | "Allocated the host=%p hw=%p vha=%p dev_name=%s", |
| 4193 | vha->host, vha->hw, vha, |
| 4194 | dev_name(&(ha->pdev->dev))); |
| 4195 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4196 | return vha; |
| 4197 | |
| 4198 | fail: |
| 4199 | return vha; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4200 | } |
| 4201 | |
Adrian Bunk | 01ef66b | 2008-04-24 15:21:27 -0700 | [diff] [blame] | 4202 | static struct qla_work_evt * |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4203 | 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] | 4204 | { |
| 4205 | struct qla_work_evt *e; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 4206 | uint8_t bail; |
| 4207 | |
| 4208 | QLA_VHA_MARK_BUSY(vha, bail); |
| 4209 | if (bail) |
| 4210 | return NULL; |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4211 | |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4212 | e = kzalloc(sizeof(struct qla_work_evt), GFP_ATOMIC); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 4213 | if (!e) { |
| 4214 | QLA_VHA_MARK_NOT_BUSY(vha); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4215 | return NULL; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 4216 | } |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4217 | |
| 4218 | INIT_LIST_HEAD(&e->list); |
| 4219 | e->type = type; |
| 4220 | e->flags = QLA_EVT_FLAG_FREE; |
| 4221 | return e; |
| 4222 | } |
| 4223 | |
Adrian Bunk | 01ef66b | 2008-04-24 15:21:27 -0700 | [diff] [blame] | 4224 | static int |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4225 | 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] | 4226 | { |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4227 | unsigned long flags; |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4228 | |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4229 | spin_lock_irqsave(&vha->work_lock, flags); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4230 | list_add_tail(&e->list, &vha->work_list); |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4231 | spin_unlock_irqrestore(&vha->work_lock, flags); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4232 | qla2xxx_wake_dpc(vha); |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4233 | |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4234 | return QLA_SUCCESS; |
| 4235 | } |
| 4236 | |
| 4237 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4238 | 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] | 4239 | u32 data) |
| 4240 | { |
| 4241 | struct qla_work_evt *e; |
| 4242 | |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4243 | e = qla2x00_alloc_work(vha, QLA_EVT_AEN); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4244 | if (!e) |
| 4245 | return QLA_FUNCTION_FAILED; |
| 4246 | |
| 4247 | e->u.aen.code = code; |
| 4248 | e->u.aen.data = data; |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4249 | return qla2x00_post_work(vha, e); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4250 | } |
| 4251 | |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 4252 | int |
| 4253 | qla2x00_post_idc_ack_work(struct scsi_qla_host *vha, uint16_t *mb) |
| 4254 | { |
| 4255 | struct qla_work_evt *e; |
| 4256 | |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4257 | e = qla2x00_alloc_work(vha, QLA_EVT_IDC_ACK); |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 4258 | if (!e) |
| 4259 | return QLA_FUNCTION_FAILED; |
| 4260 | |
| 4261 | 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] | 4262 | return qla2x00_post_work(vha, e); |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 4263 | } |
| 4264 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4265 | #define qla2x00_post_async_work(name, type) \ |
| 4266 | int qla2x00_post_async_##name##_work( \ |
| 4267 | struct scsi_qla_host *vha, \ |
| 4268 | fc_port_t *fcport, uint16_t *data) \ |
| 4269 | { \ |
| 4270 | struct qla_work_evt *e; \ |
| 4271 | \ |
| 4272 | e = qla2x00_alloc_work(vha, type); \ |
| 4273 | if (!e) \ |
| 4274 | return QLA_FUNCTION_FAILED; \ |
| 4275 | \ |
| 4276 | e->u.logio.fcport = fcport; \ |
| 4277 | if (data) { \ |
| 4278 | e->u.logio.data[0] = data[0]; \ |
| 4279 | e->u.logio.data[1] = data[1]; \ |
| 4280 | } \ |
| 4281 | return qla2x00_post_work(vha, e); \ |
| 4282 | } |
| 4283 | |
| 4284 | qla2x00_post_async_work(login, QLA_EVT_ASYNC_LOGIN); |
| 4285 | qla2x00_post_async_work(login_done, QLA_EVT_ASYNC_LOGIN_DONE); |
| 4286 | qla2x00_post_async_work(logout, QLA_EVT_ASYNC_LOGOUT); |
| 4287 | qla2x00_post_async_work(logout_done, QLA_EVT_ASYNC_LOGOUT_DONE); |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 4288 | qla2x00_post_async_work(adisc, QLA_EVT_ASYNC_ADISC); |
| 4289 | qla2x00_post_async_work(adisc_done, QLA_EVT_ASYNC_ADISC_DONE); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4290 | |
Andrew Vasquez | 3420d36 | 2009-10-13 15:16:45 -0700 | [diff] [blame] | 4291 | int |
| 4292 | qla2x00_post_uevent_work(struct scsi_qla_host *vha, u32 code) |
| 4293 | { |
| 4294 | struct qla_work_evt *e; |
| 4295 | |
| 4296 | e = qla2x00_alloc_work(vha, QLA_EVT_UEVENT); |
| 4297 | if (!e) |
| 4298 | return QLA_FUNCTION_FAILED; |
| 4299 | |
| 4300 | e->u.uevent.code = code; |
| 4301 | return qla2x00_post_work(vha, e); |
| 4302 | } |
| 4303 | |
| 4304 | static void |
| 4305 | qla2x00_uevent_emit(struct scsi_qla_host *vha, u32 code) |
| 4306 | { |
| 4307 | char event_string[40]; |
| 4308 | char *envp[] = { event_string, NULL }; |
| 4309 | |
| 4310 | switch (code) { |
| 4311 | case QLA_UEVENT_CODE_FW_DUMP: |
| 4312 | snprintf(event_string, sizeof(event_string), "FW_DUMP=%ld", |
| 4313 | vha->host_no); |
| 4314 | break; |
| 4315 | default: |
| 4316 | /* do nothing */ |
| 4317 | break; |
| 4318 | } |
| 4319 | kobject_uevent_env(&vha->hw->pdev->dev.kobj, KOBJ_CHANGE, envp); |
| 4320 | } |
| 4321 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 4322 | int |
| 4323 | qlafx00_post_aenfx_work(struct scsi_qla_host *vha, uint32_t evtcode, |
| 4324 | uint32_t *data, int cnt) |
| 4325 | { |
| 4326 | struct qla_work_evt *e; |
| 4327 | |
| 4328 | e = qla2x00_alloc_work(vha, QLA_EVT_AENFX); |
| 4329 | if (!e) |
| 4330 | return QLA_FUNCTION_FAILED; |
| 4331 | |
| 4332 | e->u.aenfx.evtcode = evtcode; |
| 4333 | e->u.aenfx.count = cnt; |
| 4334 | memcpy(e->u.aenfx.mbx, data, sizeof(*data) * cnt); |
| 4335 | return qla2x00_post_work(vha, e); |
| 4336 | } |
| 4337 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4338 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4339 | qla2x00_do_work(struct scsi_qla_host *vha) |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4340 | { |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4341 | struct qla_work_evt *e, *tmp; |
| 4342 | unsigned long flags; |
| 4343 | LIST_HEAD(work); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4344 | |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4345 | spin_lock_irqsave(&vha->work_lock, flags); |
| 4346 | list_splice_init(&vha->work_list, &work); |
| 4347 | spin_unlock_irqrestore(&vha->work_lock, flags); |
| 4348 | |
| 4349 | list_for_each_entry_safe(e, tmp, &work, list) { |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4350 | list_del_init(&e->list); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4351 | |
| 4352 | switch (e->type) { |
| 4353 | case QLA_EVT_AEN: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4354 | fc_host_post_event(vha->host, fc_get_event_number(), |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4355 | e->u.aen.code, e->u.aen.data); |
| 4356 | break; |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 4357 | case QLA_EVT_IDC_ACK: |
| 4358 | qla81xx_idc_ack(vha, e->u.idc_ack.mb); |
| 4359 | break; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4360 | case QLA_EVT_ASYNC_LOGIN: |
| 4361 | qla2x00_async_login(vha, e->u.logio.fcport, |
| 4362 | e->u.logio.data); |
| 4363 | break; |
| 4364 | case QLA_EVT_ASYNC_LOGIN_DONE: |
| 4365 | qla2x00_async_login_done(vha, e->u.logio.fcport, |
| 4366 | e->u.logio.data); |
| 4367 | break; |
| 4368 | case QLA_EVT_ASYNC_LOGOUT: |
| 4369 | qla2x00_async_logout(vha, e->u.logio.fcport); |
| 4370 | break; |
| 4371 | case QLA_EVT_ASYNC_LOGOUT_DONE: |
| 4372 | qla2x00_async_logout_done(vha, e->u.logio.fcport, |
| 4373 | e->u.logio.data); |
| 4374 | break; |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 4375 | case QLA_EVT_ASYNC_ADISC: |
| 4376 | qla2x00_async_adisc(vha, e->u.logio.fcport, |
| 4377 | e->u.logio.data); |
| 4378 | break; |
| 4379 | case QLA_EVT_ASYNC_ADISC_DONE: |
| 4380 | qla2x00_async_adisc_done(vha, e->u.logio.fcport, |
| 4381 | e->u.logio.data); |
| 4382 | break; |
Andrew Vasquez | 3420d36 | 2009-10-13 15:16:45 -0700 | [diff] [blame] | 4383 | case QLA_EVT_UEVENT: |
| 4384 | qla2x00_uevent_emit(vha, e->u.uevent.code); |
| 4385 | break; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 4386 | case QLA_EVT_AENFX: |
| 4387 | qlafx00_process_aen(vha, e); |
| 4388 | break; |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4389 | } |
| 4390 | if (e->flags & QLA_EVT_FLAG_FREE) |
| 4391 | kfree(e); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 4392 | |
| 4393 | /* For each work completed decrement vha ref count */ |
| 4394 | QLA_VHA_MARK_NOT_BUSY(vha); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4395 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4396 | } |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4397 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4398 | /* Relogins all the fcports of a vport |
| 4399 | * Context: dpc thread |
| 4400 | */ |
| 4401 | void qla2x00_relogin(struct scsi_qla_host *vha) |
| 4402 | { |
| 4403 | fc_port_t *fcport; |
Andrew Vasquez | c6b2fca | 2009-03-05 11:07:03 -0800 | [diff] [blame] | 4404 | int status; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4405 | uint16_t next_loopid = 0; |
| 4406 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4407 | uint16_t data[2]; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4408 | |
| 4409 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
| 4410 | /* |
| 4411 | * If the port is not ONLINE then try to login |
| 4412 | * to it if we haven't run out of retries. |
| 4413 | */ |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 4414 | if (atomic_read(&fcport->state) != FCS_ONLINE && |
| 4415 | fcport->login_retry && !(fcport->flags & FCF_ASYNC_SENT)) { |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4416 | fcport->login_retry--; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4417 | if (fcport->flags & FCF_FABRIC_DEVICE) { |
Andrew Vasquez | f08b725 | 2010-01-12 12:59:48 -0800 | [diff] [blame] | 4418 | if (fcport->flags & FCF_FCP2_DEVICE) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4419 | ha->isp_ops->fabric_logout(vha, |
| 4420 | fcport->loop_id, |
| 4421 | fcport->d_id.b.domain, |
| 4422 | fcport->d_id.b.area, |
| 4423 | fcport->d_id.b.al_pa); |
| 4424 | |
Joe Carnuccio | 03bcfb5 | 2011-03-30 11:46:27 -0700 | [diff] [blame] | 4425 | if (fcport->loop_id == FC_NO_LOOP_ID) { |
| 4426 | fcport->loop_id = next_loopid = |
| 4427 | ha->min_external_loopid; |
| 4428 | status = qla2x00_find_new_loop_id( |
| 4429 | vha, fcport); |
| 4430 | if (status != QLA_SUCCESS) { |
| 4431 | /* Ran out of IDs to use */ |
| 4432 | break; |
| 4433 | } |
| 4434 | } |
| 4435 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4436 | if (IS_ALOGIO_CAPABLE(ha)) { |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 4437 | fcport->flags |= FCF_ASYNC_SENT; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4438 | data[0] = 0; |
| 4439 | data[1] = QLA_LOGIO_LOGIN_RETRIED; |
| 4440 | status = qla2x00_post_async_login_work( |
| 4441 | vha, fcport, data); |
| 4442 | if (status == QLA_SUCCESS) |
| 4443 | continue; |
| 4444 | /* Attempt a retry. */ |
| 4445 | status = 1; |
Saurav Kashyap | aaf4d3e | 2012-04-25 07:26:16 -0700 | [diff] [blame] | 4446 | } else { |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4447 | status = qla2x00_fabric_login(vha, |
| 4448 | fcport, &next_loopid); |
Saurav Kashyap | aaf4d3e | 2012-04-25 07:26:16 -0700 | [diff] [blame] | 4449 | if (status == QLA_SUCCESS) { |
| 4450 | int status2; |
| 4451 | uint8_t opts; |
| 4452 | |
| 4453 | opts = 0; |
| 4454 | if (fcport->flags & |
| 4455 | FCF_FCP2_DEVICE) |
| 4456 | opts |= BIT_1; |
Saurav Kashyap | 0300396 | 2012-11-21 02:40:31 -0500 | [diff] [blame] | 4457 | status2 = |
| 4458 | qla2x00_get_port_database( |
| 4459 | vha, fcport, opts); |
Saurav Kashyap | aaf4d3e | 2012-04-25 07:26:16 -0700 | [diff] [blame] | 4460 | if (status2 != QLA_SUCCESS) |
| 4461 | status = 1; |
| 4462 | } |
| 4463 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4464 | } else |
| 4465 | status = qla2x00_local_device_login(vha, |
| 4466 | fcport); |
| 4467 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4468 | if (status == QLA_SUCCESS) { |
| 4469 | fcport->old_loop_id = fcport->loop_id; |
| 4470 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4471 | ql_dbg(ql_dbg_disc, vha, 0x2003, |
| 4472 | "Port login OK: logged in ID 0x%x.\n", |
| 4473 | fcport->loop_id); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4474 | |
| 4475 | qla2x00_update_fcport(vha, fcport); |
| 4476 | |
| 4477 | } else if (status == 1) { |
| 4478 | set_bit(RELOGIN_NEEDED, &vha->dpc_flags); |
| 4479 | /* retry the login again */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4480 | ql_dbg(ql_dbg_disc, vha, 0x2007, |
| 4481 | "Retrying %d login again loop_id 0x%x.\n", |
| 4482 | fcport->login_retry, fcport->loop_id); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4483 | } else { |
| 4484 | fcport->login_retry = 0; |
| 4485 | } |
| 4486 | |
| 4487 | if (fcport->login_retry == 0 && status != QLA_SUCCESS) |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 4488 | qla2x00_clear_loop_id(fcport); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4489 | } |
| 4490 | if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) |
| 4491 | break; |
| 4492 | } |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4493 | } |
| 4494 | |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4495 | /* Schedule work on any of the dpc-workqueues */ |
| 4496 | void |
| 4497 | qla83xx_schedule_work(scsi_qla_host_t *base_vha, int work_code) |
| 4498 | { |
| 4499 | struct qla_hw_data *ha = base_vha->hw; |
| 4500 | |
| 4501 | switch (work_code) { |
| 4502 | case MBA_IDC_AEN: /* 0x8200 */ |
| 4503 | if (ha->dpc_lp_wq) |
| 4504 | queue_work(ha->dpc_lp_wq, &ha->idc_aen); |
| 4505 | break; |
| 4506 | |
| 4507 | case QLA83XX_NIC_CORE_RESET: /* 0x1 */ |
| 4508 | if (!ha->flags.nic_core_reset_hdlr_active) { |
| 4509 | if (ha->dpc_hp_wq) |
| 4510 | queue_work(ha->dpc_hp_wq, &ha->nic_core_reset); |
| 4511 | } else |
| 4512 | ql_dbg(ql_dbg_p3p, base_vha, 0xb05e, |
| 4513 | "NIC Core reset is already active. Skip " |
| 4514 | "scheduling it again.\n"); |
| 4515 | break; |
| 4516 | case QLA83XX_IDC_STATE_HANDLER: /* 0x2 */ |
| 4517 | if (ha->dpc_hp_wq) |
| 4518 | queue_work(ha->dpc_hp_wq, &ha->idc_state_handler); |
| 4519 | break; |
| 4520 | case QLA83XX_NIC_CORE_UNRECOVERABLE: /* 0x3 */ |
| 4521 | if (ha->dpc_hp_wq) |
| 4522 | queue_work(ha->dpc_hp_wq, &ha->nic_core_unrecoverable); |
| 4523 | break; |
| 4524 | default: |
| 4525 | ql_log(ql_log_warn, base_vha, 0xb05f, |
Masanari Iida | d939be3 | 2015-02-27 23:52:31 +0900 | [diff] [blame] | 4526 | "Unknown work-code=0x%x.\n", work_code); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4527 | } |
| 4528 | |
| 4529 | return; |
| 4530 | } |
| 4531 | |
| 4532 | /* Work: Perform NIC Core Unrecoverable state handling */ |
| 4533 | void |
| 4534 | qla83xx_nic_core_unrecoverable_work(struct work_struct *work) |
| 4535 | { |
| 4536 | struct qla_hw_data *ha = |
Arun Easi | 2ad1b67 | 2012-08-22 14:21:35 -0400 | [diff] [blame] | 4537 | container_of(work, struct qla_hw_data, nic_core_unrecoverable); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4538 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 4539 | uint32_t dev_state = 0; |
| 4540 | |
| 4541 | qla83xx_idc_lock(base_vha, 0); |
| 4542 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, &dev_state); |
| 4543 | qla83xx_reset_ownership(base_vha); |
| 4544 | if (ha->flags.nic_core_reset_owner) { |
| 4545 | ha->flags.nic_core_reset_owner = 0; |
| 4546 | qla83xx_wr_reg(base_vha, QLA83XX_IDC_DEV_STATE, |
| 4547 | QLA8XXX_DEV_FAILED); |
| 4548 | ql_log(ql_log_info, base_vha, 0xb060, "HW State: FAILED.\n"); |
| 4549 | qla83xx_schedule_work(base_vha, QLA83XX_IDC_STATE_HANDLER); |
| 4550 | } |
| 4551 | qla83xx_idc_unlock(base_vha, 0); |
| 4552 | } |
| 4553 | |
| 4554 | /* Work: Execute IDC state handler */ |
| 4555 | void |
| 4556 | qla83xx_idc_state_handler_work(struct work_struct *work) |
| 4557 | { |
| 4558 | struct qla_hw_data *ha = |
Arun Easi | 2ad1b67 | 2012-08-22 14:21:35 -0400 | [diff] [blame] | 4559 | container_of(work, struct qla_hw_data, idc_state_handler); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4560 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 4561 | uint32_t dev_state = 0; |
| 4562 | |
| 4563 | qla83xx_idc_lock(base_vha, 0); |
| 4564 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, &dev_state); |
| 4565 | if (dev_state == QLA8XXX_DEV_FAILED || |
| 4566 | dev_state == QLA8XXX_DEV_NEED_QUIESCENT) |
| 4567 | qla83xx_idc_state_handler(base_vha); |
| 4568 | qla83xx_idc_unlock(base_vha, 0); |
| 4569 | } |
| 4570 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 4571 | static int |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4572 | qla83xx_check_nic_core_fw_alive(scsi_qla_host_t *base_vha) |
| 4573 | { |
| 4574 | int rval = QLA_SUCCESS; |
| 4575 | unsigned long heart_beat_wait = jiffies + (1 * HZ); |
| 4576 | uint32_t heart_beat_counter1, heart_beat_counter2; |
| 4577 | |
| 4578 | do { |
| 4579 | if (time_after(jiffies, heart_beat_wait)) { |
| 4580 | ql_dbg(ql_dbg_p3p, base_vha, 0xb07c, |
| 4581 | "Nic Core f/w is not alive.\n"); |
| 4582 | rval = QLA_FUNCTION_FAILED; |
| 4583 | break; |
| 4584 | } |
| 4585 | |
| 4586 | qla83xx_idc_lock(base_vha, 0); |
| 4587 | qla83xx_rd_reg(base_vha, QLA83XX_FW_HEARTBEAT, |
| 4588 | &heart_beat_counter1); |
| 4589 | qla83xx_idc_unlock(base_vha, 0); |
| 4590 | msleep(100); |
| 4591 | qla83xx_idc_lock(base_vha, 0); |
| 4592 | qla83xx_rd_reg(base_vha, QLA83XX_FW_HEARTBEAT, |
| 4593 | &heart_beat_counter2); |
| 4594 | qla83xx_idc_unlock(base_vha, 0); |
| 4595 | } while (heart_beat_counter1 == heart_beat_counter2); |
| 4596 | |
| 4597 | return rval; |
| 4598 | } |
| 4599 | |
| 4600 | /* Work: Perform NIC Core Reset handling */ |
| 4601 | void |
| 4602 | qla83xx_nic_core_reset_work(struct work_struct *work) |
| 4603 | { |
| 4604 | struct qla_hw_data *ha = |
| 4605 | container_of(work, struct qla_hw_data, nic_core_reset); |
| 4606 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 4607 | uint32_t dev_state = 0; |
| 4608 | |
Saurav Kashyap | 8117877 | 2012-08-22 14:21:04 -0400 | [diff] [blame] | 4609 | if (IS_QLA2031(ha)) { |
| 4610 | if (qla2xxx_mctp_dump(base_vha) != QLA_SUCCESS) |
| 4611 | ql_log(ql_log_warn, base_vha, 0xb081, |
| 4612 | "Failed to dump mctp\n"); |
| 4613 | return; |
| 4614 | } |
| 4615 | |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4616 | if (!ha->flags.nic_core_reset_hdlr_active) { |
| 4617 | if (qla83xx_check_nic_core_fw_alive(base_vha) == QLA_SUCCESS) { |
| 4618 | qla83xx_idc_lock(base_vha, 0); |
| 4619 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, |
| 4620 | &dev_state); |
| 4621 | qla83xx_idc_unlock(base_vha, 0); |
| 4622 | if (dev_state != QLA8XXX_DEV_NEED_RESET) { |
| 4623 | ql_dbg(ql_dbg_p3p, base_vha, 0xb07a, |
| 4624 | "Nic Core f/w is alive.\n"); |
| 4625 | return; |
| 4626 | } |
| 4627 | } |
| 4628 | |
| 4629 | ha->flags.nic_core_reset_hdlr_active = 1; |
| 4630 | if (qla83xx_nic_core_reset(base_vha)) { |
| 4631 | /* NIC Core reset failed. */ |
| 4632 | ql_dbg(ql_dbg_p3p, base_vha, 0xb061, |
| 4633 | "NIC Core reset failed.\n"); |
| 4634 | } |
| 4635 | ha->flags.nic_core_reset_hdlr_active = 0; |
| 4636 | } |
| 4637 | } |
| 4638 | |
| 4639 | /* Work: Handle 8200 IDC aens */ |
| 4640 | void |
| 4641 | qla83xx_service_idc_aen(struct work_struct *work) |
| 4642 | { |
| 4643 | struct qla_hw_data *ha = |
| 4644 | container_of(work, struct qla_hw_data, idc_aen); |
| 4645 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 4646 | uint32_t dev_state, idc_control; |
| 4647 | |
| 4648 | qla83xx_idc_lock(base_vha, 0); |
| 4649 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, &dev_state); |
| 4650 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_CONTROL, &idc_control); |
| 4651 | qla83xx_idc_unlock(base_vha, 0); |
| 4652 | if (dev_state == QLA8XXX_DEV_NEED_RESET) { |
| 4653 | if (idc_control & QLA83XX_IDC_GRACEFUL_RESET) { |
| 4654 | ql_dbg(ql_dbg_p3p, base_vha, 0xb062, |
| 4655 | "Application requested NIC Core Reset.\n"); |
| 4656 | qla83xx_schedule_work(base_vha, QLA83XX_NIC_CORE_RESET); |
| 4657 | } else if (qla83xx_check_nic_core_fw_alive(base_vha) == |
| 4658 | QLA_SUCCESS) { |
| 4659 | ql_dbg(ql_dbg_p3p, base_vha, 0xb07b, |
| 4660 | "Other protocol driver requested NIC Core Reset.\n"); |
| 4661 | qla83xx_schedule_work(base_vha, QLA83XX_NIC_CORE_RESET); |
| 4662 | } |
| 4663 | } else if (dev_state == QLA8XXX_DEV_FAILED || |
| 4664 | dev_state == QLA8XXX_DEV_NEED_QUIESCENT) { |
| 4665 | qla83xx_schedule_work(base_vha, QLA83XX_IDC_STATE_HANDLER); |
| 4666 | } |
| 4667 | } |
| 4668 | |
| 4669 | static void |
| 4670 | qla83xx_wait_logic(void) |
| 4671 | { |
| 4672 | int i; |
| 4673 | |
| 4674 | /* Yield CPU */ |
| 4675 | if (!in_interrupt()) { |
| 4676 | /* |
| 4677 | * Wait about 200ms before retrying again. |
| 4678 | * This controls the number of retries for single |
| 4679 | * lock operation. |
| 4680 | */ |
| 4681 | msleep(100); |
| 4682 | schedule(); |
| 4683 | } else { |
| 4684 | for (i = 0; i < 20; i++) |
| 4685 | cpu_relax(); /* This a nop instr on i386 */ |
| 4686 | } |
| 4687 | } |
| 4688 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 4689 | static int |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4690 | qla83xx_force_lock_recovery(scsi_qla_host_t *base_vha) |
| 4691 | { |
| 4692 | int rval; |
| 4693 | uint32_t data; |
| 4694 | uint32_t idc_lck_rcvry_stage_mask = 0x3; |
| 4695 | uint32_t idc_lck_rcvry_owner_mask = 0x3c; |
| 4696 | struct qla_hw_data *ha = base_vha->hw; |
Saurav Kashyap | 6c31555 | 2013-02-08 01:57:53 -0500 | [diff] [blame] | 4697 | ql_dbg(ql_dbg_p3p, base_vha, 0xb086, |
| 4698 | "Trying force recovery of the IDC lock.\n"); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4699 | |
| 4700 | rval = qla83xx_rd_reg(base_vha, QLA83XX_IDC_LOCK_RECOVERY, &data); |
| 4701 | if (rval) |
| 4702 | return rval; |
| 4703 | |
| 4704 | if ((data & idc_lck_rcvry_stage_mask) > 0) { |
| 4705 | return QLA_SUCCESS; |
| 4706 | } else { |
| 4707 | data = (IDC_LOCK_RECOVERY_STAGE1) | (ha->portnum << 2); |
| 4708 | rval = qla83xx_wr_reg(base_vha, QLA83XX_IDC_LOCK_RECOVERY, |
| 4709 | data); |
| 4710 | if (rval) |
| 4711 | return rval; |
| 4712 | |
| 4713 | msleep(200); |
| 4714 | |
| 4715 | rval = qla83xx_rd_reg(base_vha, QLA83XX_IDC_LOCK_RECOVERY, |
| 4716 | &data); |
| 4717 | if (rval) |
| 4718 | return rval; |
| 4719 | |
| 4720 | if (((data & idc_lck_rcvry_owner_mask) >> 2) == ha->portnum) { |
| 4721 | data &= (IDC_LOCK_RECOVERY_STAGE2 | |
| 4722 | ~(idc_lck_rcvry_stage_mask)); |
| 4723 | rval = qla83xx_wr_reg(base_vha, |
| 4724 | QLA83XX_IDC_LOCK_RECOVERY, data); |
| 4725 | if (rval) |
| 4726 | return rval; |
| 4727 | |
| 4728 | /* Forcefully perform IDC UnLock */ |
| 4729 | rval = qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_UNLOCK, |
| 4730 | &data); |
| 4731 | if (rval) |
| 4732 | return rval; |
| 4733 | /* Clear lock-id by setting 0xff */ |
| 4734 | rval = qla83xx_wr_reg(base_vha, QLA83XX_DRIVER_LOCKID, |
| 4735 | 0xff); |
| 4736 | if (rval) |
| 4737 | return rval; |
| 4738 | /* Clear lock-recovery by setting 0x0 */ |
| 4739 | rval = qla83xx_wr_reg(base_vha, |
| 4740 | QLA83XX_IDC_LOCK_RECOVERY, 0x0); |
| 4741 | if (rval) |
| 4742 | return rval; |
| 4743 | } else |
| 4744 | return QLA_SUCCESS; |
| 4745 | } |
| 4746 | |
| 4747 | return rval; |
| 4748 | } |
| 4749 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 4750 | static int |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4751 | qla83xx_idc_lock_recovery(scsi_qla_host_t *base_vha) |
| 4752 | { |
| 4753 | int rval = QLA_SUCCESS; |
| 4754 | uint32_t o_drv_lockid, n_drv_lockid; |
| 4755 | unsigned long lock_recovery_timeout; |
| 4756 | |
| 4757 | lock_recovery_timeout = jiffies + QLA83XX_MAX_LOCK_RECOVERY_WAIT; |
| 4758 | retry_lockid: |
| 4759 | rval = qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCKID, &o_drv_lockid); |
| 4760 | if (rval) |
| 4761 | goto exit; |
| 4762 | |
| 4763 | /* MAX wait time before forcing IDC Lock recovery = 2 secs */ |
| 4764 | if (time_after_eq(jiffies, lock_recovery_timeout)) { |
| 4765 | if (qla83xx_force_lock_recovery(base_vha) == QLA_SUCCESS) |
| 4766 | return QLA_SUCCESS; |
| 4767 | else |
| 4768 | return QLA_FUNCTION_FAILED; |
| 4769 | } |
| 4770 | |
| 4771 | rval = qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCKID, &n_drv_lockid); |
| 4772 | if (rval) |
| 4773 | goto exit; |
| 4774 | |
| 4775 | if (o_drv_lockid == n_drv_lockid) { |
| 4776 | qla83xx_wait_logic(); |
| 4777 | goto retry_lockid; |
| 4778 | } else |
| 4779 | return QLA_SUCCESS; |
| 4780 | |
| 4781 | exit: |
| 4782 | return rval; |
| 4783 | } |
| 4784 | |
| 4785 | void |
| 4786 | qla83xx_idc_lock(scsi_qla_host_t *base_vha, uint16_t requester_id) |
| 4787 | { |
| 4788 | uint16_t options = (requester_id << 15) | BIT_6; |
| 4789 | uint32_t data; |
Saurav Kashyap | 6c31555 | 2013-02-08 01:57:53 -0500 | [diff] [blame] | 4790 | uint32_t lock_owner; |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4791 | struct qla_hw_data *ha = base_vha->hw; |
| 4792 | |
| 4793 | /* IDC-lock implementation using driver-lock/lock-id remote registers */ |
| 4794 | retry_lock: |
| 4795 | if (qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCK, &data) |
| 4796 | == QLA_SUCCESS) { |
| 4797 | if (data) { |
| 4798 | /* Setting lock-id to our function-number */ |
| 4799 | qla83xx_wr_reg(base_vha, QLA83XX_DRIVER_LOCKID, |
| 4800 | ha->portnum); |
| 4801 | } else { |
Saurav Kashyap | 6c31555 | 2013-02-08 01:57:53 -0500 | [diff] [blame] | 4802 | qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCKID, |
| 4803 | &lock_owner); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4804 | ql_dbg(ql_dbg_p3p, base_vha, 0xb063, |
Saurav Kashyap | 6c31555 | 2013-02-08 01:57:53 -0500 | [diff] [blame] | 4805 | "Failed to acquire IDC lock, acquired by %d, " |
| 4806 | "retrying...\n", lock_owner); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4807 | |
| 4808 | /* Retry/Perform IDC-Lock recovery */ |
| 4809 | if (qla83xx_idc_lock_recovery(base_vha) |
| 4810 | == QLA_SUCCESS) { |
| 4811 | qla83xx_wait_logic(); |
| 4812 | goto retry_lock; |
| 4813 | } else |
| 4814 | ql_log(ql_log_warn, base_vha, 0xb075, |
| 4815 | "IDC Lock recovery FAILED.\n"); |
| 4816 | } |
| 4817 | |
| 4818 | } |
| 4819 | |
| 4820 | return; |
| 4821 | |
| 4822 | /* XXX: IDC-lock implementation using access-control mbx */ |
| 4823 | retry_lock2: |
| 4824 | if (qla83xx_access_control(base_vha, options, 0, 0, NULL)) { |
| 4825 | ql_dbg(ql_dbg_p3p, base_vha, 0xb072, |
| 4826 | "Failed to acquire IDC lock. retrying...\n"); |
| 4827 | /* Retry/Perform IDC-Lock recovery */ |
| 4828 | if (qla83xx_idc_lock_recovery(base_vha) == QLA_SUCCESS) { |
| 4829 | qla83xx_wait_logic(); |
| 4830 | goto retry_lock2; |
| 4831 | } else |
| 4832 | ql_log(ql_log_warn, base_vha, 0xb076, |
| 4833 | "IDC Lock recovery FAILED.\n"); |
| 4834 | } |
| 4835 | |
| 4836 | return; |
| 4837 | } |
| 4838 | |
| 4839 | void |
| 4840 | qla83xx_idc_unlock(scsi_qla_host_t *base_vha, uint16_t requester_id) |
| 4841 | { |
Bart Van Assche | 5897cb2 | 2015-06-04 15:57:20 -0700 | [diff] [blame] | 4842 | #if 0 |
| 4843 | uint16_t options = (requester_id << 15) | BIT_7; |
| 4844 | #endif |
| 4845 | uint16_t retry; |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4846 | uint32_t data; |
| 4847 | struct qla_hw_data *ha = base_vha->hw; |
| 4848 | |
| 4849 | /* IDC-unlock implementation using driver-unlock/lock-id |
| 4850 | * remote registers |
| 4851 | */ |
| 4852 | retry = 0; |
| 4853 | retry_unlock: |
| 4854 | if (qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCKID, &data) |
| 4855 | == QLA_SUCCESS) { |
| 4856 | if (data == ha->portnum) { |
| 4857 | qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_UNLOCK, &data); |
| 4858 | /* Clearing lock-id by setting 0xff */ |
| 4859 | qla83xx_wr_reg(base_vha, QLA83XX_DRIVER_LOCKID, 0xff); |
| 4860 | } else if (retry < 10) { |
| 4861 | /* SV: XXX: IDC unlock retrying needed here? */ |
| 4862 | |
| 4863 | /* Retry for IDC-unlock */ |
| 4864 | qla83xx_wait_logic(); |
| 4865 | retry++; |
| 4866 | ql_dbg(ql_dbg_p3p, base_vha, 0xb064, |
Colin Ian King | ee6a877 | 2016-08-28 12:24:48 +0100 | [diff] [blame] | 4867 | "Failed to release IDC lock, retrying=%d\n", retry); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4868 | goto retry_unlock; |
| 4869 | } |
| 4870 | } else if (retry < 10) { |
| 4871 | /* Retry for IDC-unlock */ |
| 4872 | qla83xx_wait_logic(); |
| 4873 | retry++; |
| 4874 | ql_dbg(ql_dbg_p3p, base_vha, 0xb065, |
Colin Ian King | ee6a877 | 2016-08-28 12:24:48 +0100 | [diff] [blame] | 4875 | "Failed to read drv-lockid, retrying=%d\n", retry); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4876 | goto retry_unlock; |
| 4877 | } |
| 4878 | |
| 4879 | return; |
| 4880 | |
Bart Van Assche | 5897cb2 | 2015-06-04 15:57:20 -0700 | [diff] [blame] | 4881 | #if 0 |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4882 | /* XXX: IDC-unlock implementation using access-control mbx */ |
| 4883 | retry = 0; |
| 4884 | retry_unlock2: |
| 4885 | if (qla83xx_access_control(base_vha, options, 0, 0, NULL)) { |
| 4886 | if (retry < 10) { |
| 4887 | /* Retry for IDC-unlock */ |
| 4888 | qla83xx_wait_logic(); |
| 4889 | retry++; |
| 4890 | ql_dbg(ql_dbg_p3p, base_vha, 0xb066, |
Colin Ian King | ee6a877 | 2016-08-28 12:24:48 +0100 | [diff] [blame] | 4891 | "Failed to release IDC lock, retrying=%d\n", retry); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4892 | goto retry_unlock2; |
| 4893 | } |
| 4894 | } |
| 4895 | |
| 4896 | return; |
Bart Van Assche | 5897cb2 | 2015-06-04 15:57:20 -0700 | [diff] [blame] | 4897 | #endif |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4898 | } |
| 4899 | |
| 4900 | int |
| 4901 | __qla83xx_set_drv_presence(scsi_qla_host_t *vha) |
| 4902 | { |
| 4903 | int rval = QLA_SUCCESS; |
| 4904 | struct qla_hw_data *ha = vha->hw; |
| 4905 | uint32_t drv_presence; |
| 4906 | |
| 4907 | rval = qla83xx_rd_reg(vha, QLA83XX_IDC_DRV_PRESENCE, &drv_presence); |
| 4908 | if (rval == QLA_SUCCESS) { |
| 4909 | drv_presence |= (1 << ha->portnum); |
| 4910 | rval = qla83xx_wr_reg(vha, QLA83XX_IDC_DRV_PRESENCE, |
| 4911 | drv_presence); |
| 4912 | } |
| 4913 | |
| 4914 | return rval; |
| 4915 | } |
| 4916 | |
| 4917 | int |
| 4918 | qla83xx_set_drv_presence(scsi_qla_host_t *vha) |
| 4919 | { |
| 4920 | int rval = QLA_SUCCESS; |
| 4921 | |
| 4922 | qla83xx_idc_lock(vha, 0); |
| 4923 | rval = __qla83xx_set_drv_presence(vha); |
| 4924 | qla83xx_idc_unlock(vha, 0); |
| 4925 | |
| 4926 | return rval; |
| 4927 | } |
| 4928 | |
| 4929 | int |
| 4930 | __qla83xx_clear_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_clear_drv_presence(scsi_qla_host_t *vha) |
| 4948 | { |
| 4949 | int rval = QLA_SUCCESS; |
| 4950 | |
| 4951 | qla83xx_idc_lock(vha, 0); |
| 4952 | rval = __qla83xx_clear_drv_presence(vha); |
| 4953 | qla83xx_idc_unlock(vha, 0); |
| 4954 | |
| 4955 | return rval; |
| 4956 | } |
| 4957 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 4958 | static void |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4959 | qla83xx_need_reset_handler(scsi_qla_host_t *vha) |
| 4960 | { |
| 4961 | struct qla_hw_data *ha = vha->hw; |
| 4962 | uint32_t drv_ack, drv_presence; |
| 4963 | unsigned long ack_timeout; |
| 4964 | |
| 4965 | /* Wait for IDC ACK from all functions (DRV-ACK == DRV-PRESENCE) */ |
| 4966 | ack_timeout = jiffies + (ha->fcoe_reset_timeout * HZ); |
| 4967 | while (1) { |
| 4968 | qla83xx_rd_reg(vha, QLA83XX_IDC_DRIVER_ACK, &drv_ack); |
| 4969 | qla83xx_rd_reg(vha, QLA83XX_IDC_DRV_PRESENCE, &drv_presence); |
Saurav Kashyap | 807fb6d | 2012-11-21 02:40:36 -0500 | [diff] [blame] | 4970 | if ((drv_ack & drv_presence) == drv_presence) |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4971 | break; |
| 4972 | |
| 4973 | if (time_after_eq(jiffies, ack_timeout)) { |
| 4974 | ql_log(ql_log_warn, vha, 0xb067, |
| 4975 | "RESET ACK TIMEOUT! drv_presence=0x%x " |
| 4976 | "drv_ack=0x%x\n", drv_presence, drv_ack); |
| 4977 | /* |
| 4978 | * The function(s) which did not ack in time are forced |
| 4979 | * to withdraw any further participation in the IDC |
| 4980 | * reset. |
| 4981 | */ |
| 4982 | if (drv_ack != drv_presence) |
| 4983 | qla83xx_wr_reg(vha, QLA83XX_IDC_DRV_PRESENCE, |
| 4984 | drv_ack); |
| 4985 | break; |
| 4986 | } |
| 4987 | |
| 4988 | qla83xx_idc_unlock(vha, 0); |
| 4989 | msleep(1000); |
| 4990 | qla83xx_idc_lock(vha, 0); |
| 4991 | } |
| 4992 | |
| 4993 | qla83xx_wr_reg(vha, QLA83XX_IDC_DEV_STATE, QLA8XXX_DEV_COLD); |
| 4994 | ql_log(ql_log_info, vha, 0xb068, "HW State: COLD/RE-INIT.\n"); |
| 4995 | } |
| 4996 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 4997 | static int |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4998 | qla83xx_device_bootstrap(scsi_qla_host_t *vha) |
| 4999 | { |
| 5000 | int rval = QLA_SUCCESS; |
| 5001 | uint32_t idc_control; |
| 5002 | |
| 5003 | qla83xx_wr_reg(vha, QLA83XX_IDC_DEV_STATE, QLA8XXX_DEV_INITIALIZING); |
| 5004 | ql_log(ql_log_info, vha, 0xb069, "HW State: INITIALIZING.\n"); |
| 5005 | |
| 5006 | /* Clearing IDC-Control Graceful-Reset Bit before resetting f/w */ |
| 5007 | __qla83xx_get_idc_control(vha, &idc_control); |
| 5008 | idc_control &= ~QLA83XX_IDC_GRACEFUL_RESET; |
| 5009 | __qla83xx_set_idc_control(vha, 0); |
| 5010 | |
| 5011 | qla83xx_idc_unlock(vha, 0); |
| 5012 | rval = qla83xx_restart_nic_firmware(vha); |
| 5013 | qla83xx_idc_lock(vha, 0); |
| 5014 | |
| 5015 | if (rval != QLA_SUCCESS) { |
| 5016 | ql_log(ql_log_fatal, vha, 0xb06a, |
| 5017 | "Failed to restart NIC f/w.\n"); |
| 5018 | qla83xx_wr_reg(vha, QLA83XX_IDC_DEV_STATE, QLA8XXX_DEV_FAILED); |
| 5019 | ql_log(ql_log_info, vha, 0xb06b, "HW State: FAILED.\n"); |
| 5020 | } else { |
| 5021 | ql_dbg(ql_dbg_p3p, vha, 0xb06c, |
| 5022 | "Success in restarting nic f/w.\n"); |
| 5023 | qla83xx_wr_reg(vha, QLA83XX_IDC_DEV_STATE, QLA8XXX_DEV_READY); |
| 5024 | ql_log(ql_log_info, vha, 0xb06d, "HW State: READY.\n"); |
| 5025 | } |
| 5026 | |
| 5027 | return rval; |
| 5028 | } |
| 5029 | |
| 5030 | /* Assumes idc_lock always held on entry */ |
| 5031 | int |
| 5032 | qla83xx_idc_state_handler(scsi_qla_host_t *base_vha) |
| 5033 | { |
| 5034 | struct qla_hw_data *ha = base_vha->hw; |
| 5035 | int rval = QLA_SUCCESS; |
| 5036 | unsigned long dev_init_timeout; |
| 5037 | uint32_t dev_state; |
| 5038 | |
| 5039 | /* Wait for MAX-INIT-TIMEOUT for the device to go ready */ |
| 5040 | dev_init_timeout = jiffies + (ha->fcoe_dev_init_timeout * HZ); |
| 5041 | |
| 5042 | while (1) { |
| 5043 | |
| 5044 | if (time_after_eq(jiffies, dev_init_timeout)) { |
| 5045 | ql_log(ql_log_warn, base_vha, 0xb06e, |
| 5046 | "Initialization TIMEOUT!\n"); |
| 5047 | /* Init timeout. Disable further NIC Core |
| 5048 | * communication. |
| 5049 | */ |
| 5050 | qla83xx_wr_reg(base_vha, QLA83XX_IDC_DEV_STATE, |
| 5051 | QLA8XXX_DEV_FAILED); |
| 5052 | ql_log(ql_log_info, base_vha, 0xb06f, |
| 5053 | "HW State: FAILED.\n"); |
| 5054 | } |
| 5055 | |
| 5056 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, &dev_state); |
| 5057 | switch (dev_state) { |
| 5058 | case QLA8XXX_DEV_READY: |
| 5059 | if (ha->flags.nic_core_reset_owner) |
| 5060 | qla83xx_idc_audit(base_vha, |
| 5061 | IDC_AUDIT_COMPLETION); |
| 5062 | ha->flags.nic_core_reset_owner = 0; |
| 5063 | ql_dbg(ql_dbg_p3p, base_vha, 0xb070, |
| 5064 | "Reset_owner reset by 0x%x.\n", |
| 5065 | ha->portnum); |
| 5066 | goto exit; |
| 5067 | case QLA8XXX_DEV_COLD: |
| 5068 | if (ha->flags.nic_core_reset_owner) |
| 5069 | rval = qla83xx_device_bootstrap(base_vha); |
| 5070 | else { |
| 5071 | /* Wait for AEN to change device-state */ |
| 5072 | qla83xx_idc_unlock(base_vha, 0); |
| 5073 | msleep(1000); |
| 5074 | qla83xx_idc_lock(base_vha, 0); |
| 5075 | } |
| 5076 | break; |
| 5077 | case QLA8XXX_DEV_INITIALIZING: |
| 5078 | /* Wait for AEN to change device-state */ |
| 5079 | qla83xx_idc_unlock(base_vha, 0); |
| 5080 | msleep(1000); |
| 5081 | qla83xx_idc_lock(base_vha, 0); |
| 5082 | break; |
| 5083 | case QLA8XXX_DEV_NEED_RESET: |
| 5084 | if (!ql2xdontresethba && ha->flags.nic_core_reset_owner) |
| 5085 | qla83xx_need_reset_handler(base_vha); |
| 5086 | else { |
| 5087 | /* Wait for AEN to change device-state */ |
| 5088 | qla83xx_idc_unlock(base_vha, 0); |
| 5089 | msleep(1000); |
| 5090 | qla83xx_idc_lock(base_vha, 0); |
| 5091 | } |
| 5092 | /* reset timeout value after need reset handler */ |
| 5093 | dev_init_timeout = jiffies + |
| 5094 | (ha->fcoe_dev_init_timeout * HZ); |
| 5095 | break; |
| 5096 | case QLA8XXX_DEV_NEED_QUIESCENT: |
| 5097 | /* XXX: DEBUG for now */ |
| 5098 | qla83xx_idc_unlock(base_vha, 0); |
| 5099 | msleep(1000); |
| 5100 | qla83xx_idc_lock(base_vha, 0); |
| 5101 | break; |
| 5102 | case QLA8XXX_DEV_QUIESCENT: |
| 5103 | /* XXX: DEBUG for now */ |
| 5104 | if (ha->flags.quiesce_owner) |
| 5105 | goto exit; |
| 5106 | |
| 5107 | qla83xx_idc_unlock(base_vha, 0); |
| 5108 | msleep(1000); |
| 5109 | qla83xx_idc_lock(base_vha, 0); |
| 5110 | dev_init_timeout = jiffies + |
| 5111 | (ha->fcoe_dev_init_timeout * HZ); |
| 5112 | break; |
| 5113 | case QLA8XXX_DEV_FAILED: |
| 5114 | if (ha->flags.nic_core_reset_owner) |
| 5115 | qla83xx_idc_audit(base_vha, |
| 5116 | IDC_AUDIT_COMPLETION); |
| 5117 | ha->flags.nic_core_reset_owner = 0; |
| 5118 | __qla83xx_clear_drv_presence(base_vha); |
| 5119 | qla83xx_idc_unlock(base_vha, 0); |
| 5120 | qla8xxx_dev_failed_handler(base_vha); |
| 5121 | rval = QLA_FUNCTION_FAILED; |
| 5122 | qla83xx_idc_lock(base_vha, 0); |
| 5123 | goto exit; |
| 5124 | case QLA8XXX_BAD_VALUE: |
| 5125 | qla83xx_idc_unlock(base_vha, 0); |
| 5126 | msleep(1000); |
| 5127 | qla83xx_idc_lock(base_vha, 0); |
| 5128 | break; |
| 5129 | default: |
| 5130 | ql_log(ql_log_warn, base_vha, 0xb071, |
Masanari Iida | d939be3 | 2015-02-27 23:52:31 +0900 | [diff] [blame] | 5131 | "Unknown Device State: %x.\n", dev_state); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5132 | qla83xx_idc_unlock(base_vha, 0); |
| 5133 | qla8xxx_dev_failed_handler(base_vha); |
| 5134 | rval = QLA_FUNCTION_FAILED; |
| 5135 | qla83xx_idc_lock(base_vha, 0); |
| 5136 | goto exit; |
| 5137 | } |
| 5138 | } |
| 5139 | |
| 5140 | exit: |
| 5141 | return rval; |
| 5142 | } |
| 5143 | |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5144 | void |
| 5145 | qla2x00_disable_board_on_pci_error(struct work_struct *work) |
| 5146 | { |
| 5147 | struct qla_hw_data *ha = container_of(work, struct qla_hw_data, |
| 5148 | board_disable); |
| 5149 | struct pci_dev *pdev = ha->pdev; |
| 5150 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 5151 | |
Sawan Chandak | 783e0dc | 2016-07-06 11:14:25 -0400 | [diff] [blame] | 5152 | /* if UNLOAD flag is already set, then continue unload, |
| 5153 | * where it was set first. |
| 5154 | */ |
| 5155 | if (test_bit(UNLOADING, &base_vha->dpc_flags)) |
| 5156 | return; |
| 5157 | |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5158 | ql_log(ql_log_warn, base_vha, 0x015b, |
| 5159 | "Disabling adapter.\n"); |
| 5160 | |
| 5161 | set_bit(UNLOADING, &base_vha->dpc_flags); |
| 5162 | |
| 5163 | qla2x00_delete_all_vps(ha, base_vha); |
| 5164 | |
| 5165 | qla2x00_abort_all_cmds(base_vha, DID_NO_CONNECT << 16); |
| 5166 | |
| 5167 | qla2x00_dfs_remove(base_vha); |
| 5168 | |
| 5169 | qla84xx_put_chip(base_vha); |
| 5170 | |
| 5171 | if (base_vha->timer_active) |
| 5172 | qla2x00_stop_timer(base_vha); |
| 5173 | |
| 5174 | base_vha->flags.online = 0; |
| 5175 | |
| 5176 | qla2x00_destroy_deferred_work(ha); |
| 5177 | |
| 5178 | /* |
| 5179 | * Do not try to stop beacon blink as it will issue a mailbox |
| 5180 | * command. |
| 5181 | */ |
| 5182 | qla2x00_free_sysfs_attr(base_vha, false); |
| 5183 | |
| 5184 | fc_remove_host(base_vha->host); |
| 5185 | |
| 5186 | scsi_remove_host(base_vha->host); |
| 5187 | |
| 5188 | base_vha->flags.init_done = 0; |
| 5189 | qla25xx_delete_queues(base_vha); |
| 5190 | qla2x00_free_irqs(base_vha); |
| 5191 | qla2x00_free_fcports(base_vha); |
| 5192 | qla2x00_mem_free(ha); |
| 5193 | qla82xx_md_free(base_vha); |
| 5194 | qla2x00_free_queues(ha); |
| 5195 | |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5196 | qla2x00_unmap_iobases(ha); |
| 5197 | |
| 5198 | pci_release_selected_regions(ha->pdev, ha->bars); |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5199 | pci_disable_pcie_error_reporting(pdev); |
| 5200 | pci_disable_device(pdev); |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5201 | |
Joe Lawrence | beb9e31 | 2014-08-26 17:12:14 -0400 | [diff] [blame] | 5202 | /* |
| 5203 | * Let qla2x00_remove_one cleanup qla_hw_data on device removal. |
| 5204 | */ |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5205 | } |
| 5206 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5207 | /************************************************************************** |
| 5208 | * qla2x00_do_dpc |
| 5209 | * This kernel thread is a task that is schedule by the interrupt handler |
| 5210 | * to perform the background processing for interrupts. |
| 5211 | * |
| 5212 | * Notes: |
| 5213 | * This task always run in the context of a kernel thread. It |
| 5214 | * is kick-off by the driver's detect code and starts up |
| 5215 | * up one per adapter. It immediately goes to sleep and waits for |
| 5216 | * some fibre event. When either the interrupt handler or |
| 5217 | * the timer routine detects a event it will one of the task |
| 5218 | * bits then wake us up. |
| 5219 | **************************************************************************/ |
| 5220 | static int |
| 5221 | qla2x00_do_dpc(void *data) |
| 5222 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5223 | scsi_qla_host_t *base_vha; |
| 5224 | struct qla_hw_data *ha; |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 5225 | uint32_t online; |
| 5226 | struct qla_qpair *qpair; |
Seokmann Ju | 99363ef | 2008-01-31 12:33:51 -0800 | [diff] [blame] | 5227 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5228 | ha = (struct qla_hw_data *)data; |
| 5229 | base_vha = pci_get_drvdata(ha->pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5230 | |
Dongsheng Yang | 8698a74 | 2014-03-11 18:09:12 +0800 | [diff] [blame] | 5231 | set_user_nice(current, MIN_NICE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5232 | |
James Bottomley | 563585e | 2011-01-27 16:12:37 -0500 | [diff] [blame] | 5233 | set_current_state(TASK_INTERRUPTIBLE); |
Christoph Hellwig | 39a1124 | 2006-02-14 18:46:22 +0100 | [diff] [blame] | 5234 | while (!kthread_should_stop()) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5235 | ql_dbg(ql_dbg_dpc, base_vha, 0x4000, |
| 5236 | "DPC handler sleeping.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5237 | |
Christoph Hellwig | 39a1124 | 2006-02-14 18:46:22 +0100 | [diff] [blame] | 5238 | schedule(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5239 | |
Andrew Vasquez | c142caf | 2011-11-18 09:03:10 -0800 | [diff] [blame] | 5240 | if (!base_vha->flags.init_done || ha->flags.mbox_busy) |
| 5241 | goto end_loop; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5242 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5243 | if (ha->flags.eeh_busy) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5244 | ql_dbg(ql_dbg_dpc, base_vha, 0x4003, |
| 5245 | "eeh_busy=%d.\n", ha->flags.eeh_busy); |
Andrew Vasquez | c142caf | 2011-11-18 09:03:10 -0800 | [diff] [blame] | 5246 | goto end_loop; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5247 | } |
| 5248 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5249 | ha->dpc_active = 1; |
| 5250 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 5251 | ql_dbg(ql_dbg_dpc + ql_dbg_verbose, base_vha, 0x4001, |
| 5252 | "DPC handler waking up, dpc_flags=0x%lx.\n", |
| 5253 | base_vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5254 | |
Joe Carnuccio | a29b3dd | 2016-07-06 11:14:19 -0400 | [diff] [blame] | 5255 | if (test_bit(UNLOADING, &base_vha->dpc_flags)) |
| 5256 | break; |
| 5257 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5258 | qla2x00_do_work(base_vha); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 5259 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5260 | if (IS_P3P_TYPE(ha)) { |
| 5261 | if (IS_QLA8044(ha)) { |
| 5262 | if (test_and_clear_bit(ISP_UNRECOVERABLE, |
| 5263 | &base_vha->dpc_flags)) { |
| 5264 | qla8044_idc_lock(ha); |
| 5265 | qla8044_wr_direct(base_vha, |
| 5266 | QLA8044_CRB_DEV_STATE_INDEX, |
| 5267 | QLA8XXX_DEV_FAILED); |
| 5268 | qla8044_idc_unlock(ha); |
| 5269 | ql_log(ql_log_info, base_vha, 0x4004, |
| 5270 | "HW State: FAILED.\n"); |
| 5271 | qla8044_device_state_handler(base_vha); |
| 5272 | continue; |
| 5273 | } |
| 5274 | |
| 5275 | } else { |
| 5276 | if (test_and_clear_bit(ISP_UNRECOVERABLE, |
| 5277 | &base_vha->dpc_flags)) { |
| 5278 | qla82xx_idc_lock(ha); |
| 5279 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
| 5280 | QLA8XXX_DEV_FAILED); |
| 5281 | qla82xx_idc_unlock(ha); |
| 5282 | ql_log(ql_log_info, base_vha, 0x0151, |
| 5283 | "HW State: FAILED.\n"); |
| 5284 | qla82xx_device_state_handler(base_vha); |
| 5285 | continue; |
| 5286 | } |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5287 | } |
| 5288 | |
| 5289 | if (test_and_clear_bit(FCOE_CTX_RESET_NEEDED, |
| 5290 | &base_vha->dpc_flags)) { |
| 5291 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5292 | ql_dbg(ql_dbg_dpc, base_vha, 0x4005, |
| 5293 | "FCoE context reset scheduled.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5294 | if (!(test_and_set_bit(ABORT_ISP_ACTIVE, |
| 5295 | &base_vha->dpc_flags))) { |
| 5296 | if (qla82xx_fcoe_ctx_reset(base_vha)) { |
| 5297 | /* FCoE-ctx reset failed. |
| 5298 | * Escalate to chip-reset |
| 5299 | */ |
| 5300 | set_bit(ISP_ABORT_NEEDED, |
| 5301 | &base_vha->dpc_flags); |
| 5302 | } |
| 5303 | clear_bit(ABORT_ISP_ACTIVE, |
| 5304 | &base_vha->dpc_flags); |
| 5305 | } |
| 5306 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5307 | ql_dbg(ql_dbg_dpc, base_vha, 0x4006, |
| 5308 | "FCoE context reset end.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5309 | } |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5310 | } else if (IS_QLAFX00(ha)) { |
| 5311 | if (test_and_clear_bit(ISP_UNRECOVERABLE, |
| 5312 | &base_vha->dpc_flags)) { |
| 5313 | ql_dbg(ql_dbg_dpc, base_vha, 0x4020, |
| 5314 | "Firmware Reset Recovery\n"); |
| 5315 | if (qlafx00_reset_initialize(base_vha)) { |
| 5316 | /* Failed. Abort isp later. */ |
| 5317 | if (!test_bit(UNLOADING, |
Dan Carpenter | f92f82d | 2014-05-05 12:47:57 +0300 | [diff] [blame] | 5318 | &base_vha->dpc_flags)) { |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5319 | set_bit(ISP_UNRECOVERABLE, |
| 5320 | &base_vha->dpc_flags); |
| 5321 | ql_dbg(ql_dbg_dpc, base_vha, |
| 5322 | 0x4021, |
| 5323 | "Reset Recovery Failed\n"); |
Dan Carpenter | f92f82d | 2014-05-05 12:47:57 +0300 | [diff] [blame] | 5324 | } |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5325 | } |
| 5326 | } |
| 5327 | |
| 5328 | if (test_and_clear_bit(FX00_TARGET_SCAN, |
| 5329 | &base_vha->dpc_flags)) { |
| 5330 | ql_dbg(ql_dbg_dpc, base_vha, 0x4022, |
| 5331 | "ISPFx00 Target Scan scheduled\n"); |
| 5332 | if (qlafx00_rescan_isp(base_vha)) { |
| 5333 | if (!test_bit(UNLOADING, |
| 5334 | &base_vha->dpc_flags)) |
| 5335 | set_bit(ISP_UNRECOVERABLE, |
| 5336 | &base_vha->dpc_flags); |
| 5337 | ql_dbg(ql_dbg_dpc, base_vha, 0x401e, |
| 5338 | "ISPFx00 Target Scan Failed\n"); |
| 5339 | } |
| 5340 | ql_dbg(ql_dbg_dpc, base_vha, 0x401f, |
| 5341 | "ISPFx00 Target Scan End\n"); |
| 5342 | } |
Armen Baloyan | e8f5e95 | 2013-10-30 03:38:17 -0400 | [diff] [blame] | 5343 | if (test_and_clear_bit(FX00_HOST_INFO_RESEND, |
| 5344 | &base_vha->dpc_flags)) { |
| 5345 | ql_dbg(ql_dbg_dpc, base_vha, 0x4023, |
| 5346 | "ISPFx00 Host Info resend scheduled\n"); |
| 5347 | qlafx00_fx_disc(base_vha, |
| 5348 | &base_vha->hw->mr.fcport, |
| 5349 | FXDISC_REG_HOST_INFO); |
| 5350 | } |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5351 | } |
| 5352 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5353 | if (test_and_clear_bit(ISP_ABORT_NEEDED, |
| 5354 | &base_vha->dpc_flags)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5355 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5356 | ql_dbg(ql_dbg_dpc, base_vha, 0x4007, |
| 5357 | "ISP abort scheduled.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5358 | if (!(test_and_set_bit(ABORT_ISP_ACTIVE, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5359 | &base_vha->dpc_flags))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5360 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5361 | if (ha->isp_ops->abort_isp(base_vha)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5362 | /* failed. retry later */ |
| 5363 | set_bit(ISP_ABORT_NEEDED, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5364 | &base_vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5365 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5366 | clear_bit(ABORT_ISP_ACTIVE, |
| 5367 | &base_vha->dpc_flags); |
Seokmann Ju | 99363ef | 2008-01-31 12:33:51 -0800 | [diff] [blame] | 5368 | } |
| 5369 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5370 | ql_dbg(ql_dbg_dpc, base_vha, 0x4008, |
| 5371 | "ISP abort end.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5372 | } |
| 5373 | |
David Jeffery | a394aac | 2012-11-21 02:39:54 -0500 | [diff] [blame] | 5374 | if (test_and_clear_bit(FCPORT_UPDATE_NEEDED, |
| 5375 | &base_vha->dpc_flags)) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5376 | qla2x00_update_fcports(base_vha); |
Andrew Vasquez | c9c5ced | 2008-07-24 08:31:49 -0700 | [diff] [blame] | 5377 | } |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 5378 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 5379 | if (test_bit(SCR_PENDING, &base_vha->dpc_flags)) { |
| 5380 | int ret; |
| 5381 | ret = qla2x00_send_change_request(base_vha, 0x3, 0); |
| 5382 | if (ret != QLA_SUCCESS) |
| 5383 | ql_log(ql_log_warn, base_vha, 0x121, |
| 5384 | "Failed to enable receiving of RSCN " |
| 5385 | "requests: 0x%x.\n", ret); |
| 5386 | clear_bit(SCR_PENDING, &base_vha->dpc_flags); |
| 5387 | } |
| 5388 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5389 | if (IS_QLAFX00(ha)) |
| 5390 | goto loop_resync_check; |
| 5391 | |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 5392 | if (test_bit(ISP_QUIESCE_NEEDED, &base_vha->dpc_flags)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5393 | ql_dbg(ql_dbg_dpc, base_vha, 0x4009, |
| 5394 | "Quiescence mode scheduled.\n"); |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5395 | if (IS_P3P_TYPE(ha)) { |
| 5396 | if (IS_QLA82XX(ha)) |
| 5397 | qla82xx_device_state_handler(base_vha); |
| 5398 | if (IS_QLA8044(ha)) |
| 5399 | qla8044_device_state_handler(base_vha); |
Chad Dupuis | 8fcd6b8 | 2012-08-22 14:21:06 -0400 | [diff] [blame] | 5400 | clear_bit(ISP_QUIESCE_NEEDED, |
| 5401 | &base_vha->dpc_flags); |
| 5402 | if (!ha->flags.quiesce_owner) { |
| 5403 | qla2x00_perform_loop_resync(base_vha); |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5404 | if (IS_QLA82XX(ha)) { |
| 5405 | qla82xx_idc_lock(ha); |
| 5406 | qla82xx_clear_qsnt_ready( |
| 5407 | base_vha); |
| 5408 | qla82xx_idc_unlock(ha); |
| 5409 | } else if (IS_QLA8044(ha)) { |
| 5410 | qla8044_idc_lock(ha); |
| 5411 | qla8044_clear_qsnt_ready( |
| 5412 | base_vha); |
| 5413 | qla8044_idc_unlock(ha); |
| 5414 | } |
Chad Dupuis | 8fcd6b8 | 2012-08-22 14:21:06 -0400 | [diff] [blame] | 5415 | } |
| 5416 | } else { |
| 5417 | clear_bit(ISP_QUIESCE_NEEDED, |
| 5418 | &base_vha->dpc_flags); |
| 5419 | qla2x00_quiesce_io(base_vha); |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 5420 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5421 | ql_dbg(ql_dbg_dpc, base_vha, 0x400a, |
| 5422 | "Quiescence mode end.\n"); |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 5423 | } |
| 5424 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5425 | if (test_and_clear_bit(RESET_MARKER_NEEDED, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5426 | &base_vha->dpc_flags) && |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5427 | (!(test_and_set_bit(RESET_ACTIVE, &base_vha->dpc_flags)))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5428 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5429 | ql_dbg(ql_dbg_dpc, base_vha, 0x400b, |
| 5430 | "Reset marker scheduled.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5431 | qla2x00_rst_aen(base_vha); |
| 5432 | clear_bit(RESET_ACTIVE, &base_vha->dpc_flags); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5433 | ql_dbg(ql_dbg_dpc, base_vha, 0x400c, |
| 5434 | "Reset marker end.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5435 | } |
| 5436 | |
| 5437 | /* Retry each device up to login retry count */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5438 | if ((test_and_clear_bit(RELOGIN_NEEDED, |
| 5439 | &base_vha->dpc_flags)) && |
| 5440 | !test_bit(LOOP_RESYNC_NEEDED, &base_vha->dpc_flags) && |
| 5441 | atomic_read(&base_vha->loop_state) != LOOP_DOWN) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5442 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5443 | ql_dbg(ql_dbg_dpc, base_vha, 0x400d, |
| 5444 | "Relogin scheduled.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5445 | qla2x00_relogin(base_vha); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5446 | ql_dbg(ql_dbg_dpc, base_vha, 0x400e, |
| 5447 | "Relogin end.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5448 | } |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5449 | loop_resync_check: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5450 | if (test_and_clear_bit(LOOP_RESYNC_NEEDED, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5451 | &base_vha->dpc_flags)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5452 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5453 | ql_dbg(ql_dbg_dpc, base_vha, 0x400f, |
| 5454 | "Loop resync scheduled.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5455 | |
| 5456 | if (!(test_and_set_bit(LOOP_RESYNC_ACTIVE, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5457 | &base_vha->dpc_flags))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5458 | |
Bart Van Assche | 52c8282 | 2015-07-09 07:23:26 -0700 | [diff] [blame] | 5459 | qla2x00_loop_resync(base_vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5460 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5461 | clear_bit(LOOP_RESYNC_ACTIVE, |
| 5462 | &base_vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5463 | } |
| 5464 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5465 | ql_dbg(ql_dbg_dpc, base_vha, 0x4010, |
| 5466 | "Loop resync end.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5467 | } |
| 5468 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5469 | if (IS_QLAFX00(ha)) |
| 5470 | goto intr_on_check; |
| 5471 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5472 | if (test_bit(NPIV_CONFIG_NEEDED, &base_vha->dpc_flags) && |
| 5473 | atomic_read(&base_vha->loop_state) == LOOP_READY) { |
| 5474 | clear_bit(NPIV_CONFIG_NEEDED, &base_vha->dpc_flags); |
| 5475 | qla2xxx_flash_npiv_conf(base_vha); |
Andrew Vasquez | 272976c | 2008-09-11 21:22:50 -0700 | [diff] [blame] | 5476 | } |
| 5477 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5478 | intr_on_check: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5479 | if (!ha->interrupts_on) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 5480 | ha->isp_ops->enable_intrs(ha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5481 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5482 | if (test_and_clear_bit(BEACON_BLINK_NEEDED, |
Himanshu Madani | 90b604f | 2014-04-11 16:54:40 -0400 | [diff] [blame] | 5483 | &base_vha->dpc_flags)) { |
| 5484 | if (ha->beacon_blink_led == 1) |
| 5485 | ha->isp_ops->beacon_blink(base_vha); |
| 5486 | } |
andrew.vasquez@qlogic.com | f6df144 | 2006-01-31 16:05:07 -0800 | [diff] [blame] | 5487 | |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 5488 | /* qpair online check */ |
| 5489 | if (test_and_clear_bit(QPAIR_ONLINE_CHECK_NEEDED, |
| 5490 | &base_vha->dpc_flags)) { |
| 5491 | if (ha->flags.eeh_busy || |
| 5492 | ha->flags.pci_channel_io_perm_failure) |
| 5493 | online = 0; |
| 5494 | else |
| 5495 | online = 1; |
| 5496 | |
| 5497 | mutex_lock(&ha->mq_lock); |
| 5498 | list_for_each_entry(qpair, &base_vha->qp_list, |
| 5499 | qp_list_elem) |
| 5500 | qpair->online = online; |
| 5501 | mutex_unlock(&ha->mq_lock); |
| 5502 | } |
| 5503 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5504 | if (!IS_QLAFX00(ha)) |
| 5505 | qla2x00_do_dpc_all_vps(base_vha); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5506 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5507 | ha->dpc_active = 0; |
Andrew Vasquez | c142caf | 2011-11-18 09:03:10 -0800 | [diff] [blame] | 5508 | end_loop: |
James Bottomley | 563585e | 2011-01-27 16:12:37 -0500 | [diff] [blame] | 5509 | set_current_state(TASK_INTERRUPTIBLE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5510 | } /* End of while(1) */ |
James Bottomley | 563585e | 2011-01-27 16:12:37 -0500 | [diff] [blame] | 5511 | __set_current_state(TASK_RUNNING); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5512 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5513 | ql_dbg(ql_dbg_dpc, base_vha, 0x4011, |
| 5514 | "DPC handler exiting.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5515 | |
| 5516 | /* |
| 5517 | * Make sure that nobody tries to wake us up again. |
| 5518 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5519 | ha->dpc_active = 0; |
| 5520 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 5521 | /* Cleanup any residual CTX SRBs. */ |
| 5522 | qla2x00_abort_all_cmds(base_vha, DID_NO_CONNECT << 16); |
| 5523 | |
Christoph Hellwig | 39a1124 | 2006-02-14 18:46:22 +0100 | [diff] [blame] | 5524 | return 0; |
| 5525 | } |
| 5526 | |
| 5527 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5528 | qla2xxx_wake_dpc(struct scsi_qla_host *vha) |
Christoph Hellwig | 39a1124 | 2006-02-14 18:46:22 +0100 | [diff] [blame] | 5529 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5530 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | c795c1e | 2008-08-13 21:37:01 -0700 | [diff] [blame] | 5531 | struct task_struct *t = ha->dpc_thread; |
| 5532 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5533 | if (!test_bit(UNLOADING, &vha->dpc_flags) && t) |
Andrew Vasquez | c795c1e | 2008-08-13 21:37:01 -0700 | [diff] [blame] | 5534 | wake_up_process(t); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5535 | } |
| 5536 | |
| 5537 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5538 | * qla2x00_rst_aen |
| 5539 | * Processes asynchronous reset. |
| 5540 | * |
| 5541 | * Input: |
| 5542 | * ha = adapter block pointer. |
| 5543 | */ |
| 5544 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5545 | qla2x00_rst_aen(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5546 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5547 | if (vha->flags.online && !vha->flags.reset_active && |
| 5548 | !atomic_read(&vha->loop_down_timer) && |
| 5549 | !(test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5550 | do { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5551 | clear_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5552 | |
| 5553 | /* |
| 5554 | * Issue marker command only when we are going to start |
| 5555 | * the I/O. |
| 5556 | */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5557 | vha->marker_needed = 1; |
| 5558 | } while (!atomic_read(&vha->loop_down_timer) && |
| 5559 | (test_bit(RESET_MARKER_NEEDED, &vha->dpc_flags))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5560 | } |
| 5561 | } |
| 5562 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5563 | /************************************************************************** |
| 5564 | * qla2x00_timer |
| 5565 | * |
| 5566 | * Description: |
| 5567 | * One second timer |
| 5568 | * |
| 5569 | * Context: Interrupt |
| 5570 | ***************************************************************************/ |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5571 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5572 | qla2x00_timer(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5573 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5574 | unsigned long cpu_flags = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5575 | int start_dpc = 0; |
| 5576 | int index; |
| 5577 | srb_t *sp; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5578 | uint16_t w; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5579 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 5580 | struct req_que *req; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5581 | |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5582 | if (ha->flags.eeh_busy) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5583 | ql_dbg(ql_dbg_timer, vha, 0x6000, |
| 5584 | "EEH = %d, restarting timer.\n", |
| 5585 | ha->flags.eeh_busy); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5586 | qla2x00_restart_timer(vha, WATCH_INTERVAL); |
| 5587 | return; |
| 5588 | } |
| 5589 | |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5590 | /* |
| 5591 | * Hardware read to raise pending EEH errors during mailbox waits. If |
| 5592 | * the read returns -1 then disable the board. |
| 5593 | */ |
| 5594 | if (!pci_channel_offline(ha->pdev)) { |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5595 | pci_read_config_word(ha->pdev, PCI_VENDOR_ID, &w); |
Joe Lawrence | c821e0d | 2014-08-26 17:11:41 -0400 | [diff] [blame] | 5596 | qla2x00_check_reg16_for_disconnect(vha, w); |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5597 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5598 | |
Saurav Kashyap | cefcaba | 2011-05-10 11:18:18 -0700 | [diff] [blame] | 5599 | /* Make sure qla82xx_watchdog is run only for physical port */ |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5600 | if (!vha->vp_idx && IS_P3P_TYPE(ha)) { |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 5601 | if (test_bit(ISP_QUIESCE_NEEDED, &vha->dpc_flags)) |
| 5602 | start_dpc++; |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5603 | if (IS_QLA82XX(ha)) |
| 5604 | qla82xx_watchdog(vha); |
| 5605 | else if (IS_QLA8044(ha)) |
| 5606 | qla8044_watchdog(vha); |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 5607 | } |
| 5608 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5609 | if (!vha->vp_idx && IS_QLAFX00(ha)) |
| 5610 | qlafx00_timer_routine(vha); |
| 5611 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5612 | /* Loop down handler. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5613 | if (atomic_read(&vha->loop_down_timer) > 0 && |
Giridhar Malavali | 8f7daea | 2011-03-30 11:46:26 -0700 | [diff] [blame] | 5614 | !(test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags)) && |
| 5615 | !(test_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags)) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5616 | && vha->flags.online) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5617 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5618 | if (atomic_read(&vha->loop_down_timer) == |
| 5619 | vha->loop_down_abort_time) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5620 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5621 | ql_log(ql_log_info, vha, 0x6008, |
| 5622 | "Loop down - aborting the queues before time expires.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5623 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5624 | if (!IS_QLA2100(ha) && vha->link_down_timeout) |
| 5625 | atomic_set(&vha->loop_state, LOOP_DEAD); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5626 | |
Andrew Vasquez | f08b725 | 2010-01-12 12:59:48 -0800 | [diff] [blame] | 5627 | /* |
| 5628 | * Schedule an ISP abort to return any FCP2-device |
| 5629 | * commands. |
| 5630 | */ |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5631 | /* NPIV - scan physical port only */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5632 | if (!vha->vp_idx) { |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5633 | spin_lock_irqsave(&ha->hardware_lock, |
| 5634 | cpu_flags); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 5635 | req = ha->req_q_map[0]; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5636 | for (index = 1; |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 5637 | index < req->num_outstanding_cmds; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5638 | index++) { |
| 5639 | fc_port_t *sfcp; |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 5640 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5641 | sp = req->outstanding_cmds[index]; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5642 | if (!sp) |
| 5643 | continue; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 5644 | if (sp->type != SRB_SCSI_CMD) |
Andrew Vasquez | cf53b06 | 2009-08-20 11:06:04 -0700 | [diff] [blame] | 5645 | continue; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5646 | sfcp = sp->fcport; |
Andrew Vasquez | f08b725 | 2010-01-12 12:59:48 -0800 | [diff] [blame] | 5647 | if (!(sfcp->flags & FCF_FCP2_DEVICE)) |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5648 | continue; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5649 | |
Giridhar Malavali | 8f7daea | 2011-03-30 11:46:26 -0700 | [diff] [blame] | 5650 | if (IS_QLA82XX(ha)) |
| 5651 | set_bit(FCOE_CTX_RESET_NEEDED, |
| 5652 | &vha->dpc_flags); |
| 5653 | else |
| 5654 | set_bit(ISP_ABORT_NEEDED, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5655 | &vha->dpc_flags); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5656 | break; |
| 5657 | } |
| 5658 | spin_unlock_irqrestore(&ha->hardware_lock, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5659 | cpu_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5660 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5661 | start_dpc++; |
| 5662 | } |
| 5663 | |
| 5664 | /* if the loop has been down for 4 minutes, reinit adapter */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5665 | if (atomic_dec_and_test(&vha->loop_down_timer) != 0) { |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 5666 | if (!(vha->device_flags & DFLG_NO_CABLE)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5667 | ql_log(ql_log_warn, vha, 0x6009, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5668 | "Loop down - aborting ISP.\n"); |
| 5669 | |
Giridhar Malavali | 8f7daea | 2011-03-30 11:46:26 -0700 | [diff] [blame] | 5670 | if (IS_QLA82XX(ha)) |
| 5671 | set_bit(FCOE_CTX_RESET_NEEDED, |
| 5672 | &vha->dpc_flags); |
| 5673 | else |
| 5674 | set_bit(ISP_ABORT_NEEDED, |
| 5675 | &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5676 | } |
| 5677 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5678 | ql_dbg(ql_dbg_timer, vha, 0x600a, |
| 5679 | "Loop down - seconds remaining %d.\n", |
| 5680 | atomic_read(&vha->loop_down_timer)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5681 | } |
Saurav Kashyap | cefcaba | 2011-05-10 11:18:18 -0700 | [diff] [blame] | 5682 | /* Check if beacon LED needs to be blinked for physical host only */ |
| 5683 | if (!vha->vp_idx && (ha->beacon_blink_led == 1)) { |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 5684 | /* There is no beacon_blink function for ISP82xx */ |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5685 | if (!IS_P3P_TYPE(ha)) { |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 5686 | set_bit(BEACON_BLINK_NEEDED, &vha->dpc_flags); |
| 5687 | start_dpc++; |
| 5688 | } |
andrew.vasquez@qlogic.com | f6df144 | 2006-01-31 16:05:07 -0800 | [diff] [blame] | 5689 | } |
| 5690 | |
Andrew Vasquez | 550bf57 | 2008-04-24 15:21:23 -0700 | [diff] [blame] | 5691 | /* Process any deferred work. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5692 | if (!list_empty(&vha->work_list)) |
Andrew Vasquez | 550bf57 | 2008-04-24 15:21:23 -0700 | [diff] [blame] | 5693 | start_dpc++; |
| 5694 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5695 | /* Schedule the DPC routine if needed */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5696 | if ((test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) || |
| 5697 | test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags) || |
| 5698 | test_bit(FCPORT_UPDATE_NEEDED, &vha->dpc_flags) || |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5699 | start_dpc || |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5700 | test_bit(RESET_MARKER_NEEDED, &vha->dpc_flags) || |
| 5701 | test_bit(BEACON_BLINK_NEEDED, &vha->dpc_flags) || |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5702 | test_bit(ISP_UNRECOVERABLE, &vha->dpc_flags) || |
| 5703 | test_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags) || |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5704 | test_bit(VP_DPC_NEEDED, &vha->dpc_flags) || |
Chad Dupuis | 50280c0 | 2013-10-30 03:38:14 -0400 | [diff] [blame] | 5705 | test_bit(RELOGIN_NEEDED, &vha->dpc_flags))) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5706 | ql_dbg(ql_dbg_timer, vha, 0x600b, |
| 5707 | "isp_abort_needed=%d loop_resync_needed=%d " |
| 5708 | "fcport_update_needed=%d start_dpc=%d " |
| 5709 | "reset_marker_needed=%d", |
| 5710 | test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags), |
| 5711 | test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags), |
| 5712 | test_bit(FCPORT_UPDATE_NEEDED, &vha->dpc_flags), |
| 5713 | start_dpc, |
| 5714 | test_bit(RESET_MARKER_NEEDED, &vha->dpc_flags)); |
| 5715 | ql_dbg(ql_dbg_timer, vha, 0x600c, |
| 5716 | "beacon_blink_needed=%d isp_unrecoverable=%d " |
| 5717 | "fcoe_ctx_reset_needed=%d vp_dpc_needed=%d " |
Chad Dupuis | 50280c0 | 2013-10-30 03:38:14 -0400 | [diff] [blame] | 5718 | "relogin_needed=%d.\n", |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5719 | test_bit(BEACON_BLINK_NEEDED, &vha->dpc_flags), |
| 5720 | test_bit(ISP_UNRECOVERABLE, &vha->dpc_flags), |
| 5721 | test_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags), |
| 5722 | test_bit(VP_DPC_NEEDED, &vha->dpc_flags), |
Chad Dupuis | 50280c0 | 2013-10-30 03:38:14 -0400 | [diff] [blame] | 5723 | test_bit(RELOGIN_NEEDED, &vha->dpc_flags)); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5724 | qla2xxx_wake_dpc(vha); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5725 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5726 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5727 | qla2x00_restart_timer(vha, WATCH_INTERVAL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5728 | } |
| 5729 | |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5730 | /* Firmware interface routines. */ |
| 5731 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 5732 | #define FW_BLOBS 11 |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5733 | #define FW_ISP21XX 0 |
| 5734 | #define FW_ISP22XX 1 |
| 5735 | #define FW_ISP2300 2 |
| 5736 | #define FW_ISP2322 3 |
andrew.vasquez@qlogic.com | 48c02fd | 2006-03-09 14:27:18 -0800 | [diff] [blame] | 5737 | #define FW_ISP24XX 4 |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 5738 | #define FW_ISP25XX 5 |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5739 | #define FW_ISP81XX 6 |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5740 | #define FW_ISP82XX 7 |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5741 | #define FW_ISP2031 8 |
| 5742 | #define FW_ISP8031 9 |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 5743 | #define FW_ISP27XX 10 |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5744 | |
Andrew Vasquez | bb8ee49 | 2006-10-02 12:00:48 -0700 | [diff] [blame] | 5745 | #define FW_FILE_ISP21XX "ql2100_fw.bin" |
| 5746 | #define FW_FILE_ISP22XX "ql2200_fw.bin" |
| 5747 | #define FW_FILE_ISP2300 "ql2300_fw.bin" |
| 5748 | #define FW_FILE_ISP2322 "ql2322_fw.bin" |
| 5749 | #define FW_FILE_ISP24XX "ql2400_fw.bin" |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 5750 | #define FW_FILE_ISP25XX "ql2500_fw.bin" |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5751 | #define FW_FILE_ISP81XX "ql8100_fw.bin" |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5752 | #define FW_FILE_ISP82XX "ql8200_fw.bin" |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5753 | #define FW_FILE_ISP2031 "ql2600_fw.bin" |
| 5754 | #define FW_FILE_ISP8031 "ql8300_fw.bin" |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 5755 | #define FW_FILE_ISP27XX "ql2700_fw.bin" |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 5756 | |
Andrew Vasquez | bb8ee49 | 2006-10-02 12:00:48 -0700 | [diff] [blame] | 5757 | |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 5758 | static DEFINE_MUTEX(qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5759 | |
| 5760 | static struct fw_blob qla_fw_blobs[FW_BLOBS] = { |
Andrew Vasquez | bb8ee49 | 2006-10-02 12:00:48 -0700 | [diff] [blame] | 5761 | { .name = FW_FILE_ISP21XX, .segs = { 0x1000, 0 }, }, |
| 5762 | { .name = FW_FILE_ISP22XX, .segs = { 0x1000, 0 }, }, |
| 5763 | { .name = FW_FILE_ISP2300, .segs = { 0x800, 0 }, }, |
| 5764 | { .name = FW_FILE_ISP2322, .segs = { 0x800, 0x1c000, 0x1e000, 0 }, }, |
| 5765 | { .name = FW_FILE_ISP24XX, }, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 5766 | { .name = FW_FILE_ISP25XX, }, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5767 | { .name = FW_FILE_ISP81XX, }, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5768 | { .name = FW_FILE_ISP82XX, }, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5769 | { .name = FW_FILE_ISP2031, }, |
| 5770 | { .name = FW_FILE_ISP8031, }, |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 5771 | { .name = FW_FILE_ISP27XX, }, |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5772 | }; |
| 5773 | |
| 5774 | struct fw_blob * |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5775 | qla2x00_request_firmware(scsi_qla_host_t *vha) |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5776 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5777 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5778 | struct fw_blob *blob; |
| 5779 | |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5780 | if (IS_QLA2100(ha)) { |
| 5781 | blob = &qla_fw_blobs[FW_ISP21XX]; |
| 5782 | } else if (IS_QLA2200(ha)) { |
| 5783 | blob = &qla_fw_blobs[FW_ISP22XX]; |
andrew.vasquez@qlogic.com | 48c02fd | 2006-03-09 14:27:18 -0800 | [diff] [blame] | 5784 | } else if (IS_QLA2300(ha) || IS_QLA2312(ha) || IS_QLA6312(ha)) { |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5785 | blob = &qla_fw_blobs[FW_ISP2300]; |
andrew.vasquez@qlogic.com | 48c02fd | 2006-03-09 14:27:18 -0800 | [diff] [blame] | 5786 | } else if (IS_QLA2322(ha) || IS_QLA6322(ha)) { |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5787 | blob = &qla_fw_blobs[FW_ISP2322]; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 5788 | } else if (IS_QLA24XX_TYPE(ha)) { |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5789 | blob = &qla_fw_blobs[FW_ISP24XX]; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 5790 | } else if (IS_QLA25XX(ha)) { |
| 5791 | blob = &qla_fw_blobs[FW_ISP25XX]; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5792 | } else if (IS_QLA81XX(ha)) { |
| 5793 | blob = &qla_fw_blobs[FW_ISP81XX]; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5794 | } else if (IS_QLA82XX(ha)) { |
| 5795 | blob = &qla_fw_blobs[FW_ISP82XX]; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5796 | } else if (IS_QLA2031(ha)) { |
| 5797 | blob = &qla_fw_blobs[FW_ISP2031]; |
| 5798 | } else if (IS_QLA8031(ha)) { |
| 5799 | blob = &qla_fw_blobs[FW_ISP8031]; |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 5800 | } else if (IS_QLA27XX(ha)) { |
| 5801 | blob = &qla_fw_blobs[FW_ISP27XX]; |
Dan Carpenter | 8a65522 | 2012-02-21 10:29:40 +0300 | [diff] [blame] | 5802 | } else { |
| 5803 | return NULL; |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5804 | } |
| 5805 | |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 5806 | mutex_lock(&qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5807 | if (blob->fw) |
| 5808 | goto out; |
| 5809 | |
| 5810 | if (request_firmware(&blob->fw, blob->name, &ha->pdev->dev)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5811 | ql_log(ql_log_warn, vha, 0x0063, |
| 5812 | "Failed to load firmware image (%s).\n", blob->name); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5813 | blob->fw = NULL; |
| 5814 | blob = NULL; |
| 5815 | goto out; |
| 5816 | } |
| 5817 | |
| 5818 | out: |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 5819 | mutex_unlock(&qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5820 | return blob; |
| 5821 | } |
| 5822 | |
| 5823 | static void |
| 5824 | qla2x00_release_firmware(void) |
| 5825 | { |
| 5826 | int idx; |
| 5827 | |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 5828 | mutex_lock(&qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5829 | for (idx = 0; idx < FW_BLOBS; idx++) |
Jesper Juhl | cf92549 | 2012-04-09 22:51:41 +0200 | [diff] [blame] | 5830 | release_firmware(qla_fw_blobs[idx].fw); |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 5831 | mutex_unlock(&qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5832 | } |
| 5833 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5834 | static pci_ers_result_t |
| 5835 | qla2xxx_pci_error_detected(struct pci_dev *pdev, pci_channel_state_t state) |
| 5836 | { |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5837 | scsi_qla_host_t *vha = pci_get_drvdata(pdev); |
| 5838 | struct qla_hw_data *ha = vha->hw; |
| 5839 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5840 | ql_dbg(ql_dbg_aer, vha, 0x9000, |
| 5841 | "PCI error detected, state %x.\n", state); |
Seokmann Ju | b9b12f7 | 2009-03-24 09:08:18 -0700 | [diff] [blame] | 5842 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5843 | switch (state) { |
| 5844 | case pci_channel_io_normal: |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5845 | ha->flags.eeh_busy = 0; |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 5846 | if (ql2xmqsupport) { |
| 5847 | set_bit(QPAIR_ONLINE_CHECK_NEEDED, &vha->dpc_flags); |
| 5848 | qla2xxx_wake_dpc(vha); |
| 5849 | } |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5850 | return PCI_ERS_RESULT_CAN_RECOVER; |
| 5851 | case pci_channel_io_frozen: |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5852 | ha->flags.eeh_busy = 1; |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5853 | /* For ISP82XX complete any pending mailbox cmd */ |
| 5854 | if (IS_QLA82XX(ha)) { |
Giridhar Malavali | 7190575 | 2011-02-23 15:27:10 -0800 | [diff] [blame] | 5855 | ha->flags.isp82xx_fw_hung = 1; |
Chad Dupuis | c8f6544 | 2011-11-18 09:02:17 -0800 | [diff] [blame] | 5856 | ql_dbg(ql_dbg_aer, vha, 0x9001, "Pci channel io frozen\n"); |
| 5857 | qla82xx_clear_pending_mbx(vha); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5858 | } |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 5859 | qla2x00_free_irqs(vha); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5860 | pci_disable_device(pdev); |
Lalit Chandivade | bddd2d6 | 2010-09-03 15:20:53 -0700 | [diff] [blame] | 5861 | /* Return back all IOs */ |
| 5862 | qla2x00_abort_all_cmds(vha, DID_RESET << 16); |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 5863 | if (ql2xmqsupport) { |
| 5864 | set_bit(QPAIR_ONLINE_CHECK_NEEDED, &vha->dpc_flags); |
| 5865 | qla2xxx_wake_dpc(vha); |
| 5866 | } |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5867 | return PCI_ERS_RESULT_NEED_RESET; |
| 5868 | case pci_channel_io_perm_failure: |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5869 | ha->flags.pci_channel_io_perm_failure = 1; |
| 5870 | qla2x00_abort_all_cmds(vha, DID_NO_CONNECT << 16); |
Michael Hernandez | d745952 | 2016-12-12 14:40:07 -0800 | [diff] [blame] | 5871 | if (ql2xmqsupport) { |
| 5872 | set_bit(QPAIR_ONLINE_CHECK_NEEDED, &vha->dpc_flags); |
| 5873 | qla2xxx_wake_dpc(vha); |
| 5874 | } |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5875 | return PCI_ERS_RESULT_DISCONNECT; |
| 5876 | } |
| 5877 | return PCI_ERS_RESULT_NEED_RESET; |
| 5878 | } |
| 5879 | |
| 5880 | static pci_ers_result_t |
| 5881 | qla2xxx_pci_mmio_enabled(struct pci_dev *pdev) |
| 5882 | { |
| 5883 | int risc_paused = 0; |
| 5884 | uint32_t stat; |
| 5885 | unsigned long flags; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5886 | scsi_qla_host_t *base_vha = pci_get_drvdata(pdev); |
| 5887 | struct qla_hw_data *ha = base_vha->hw; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5888 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
| 5889 | struct device_reg_24xx __iomem *reg24 = &ha->iobase->isp24; |
| 5890 | |
Saurav Kashyap | bcc5b6d | 2010-09-03 15:20:57 -0700 | [diff] [blame] | 5891 | if (IS_QLA82XX(ha)) |
| 5892 | return PCI_ERS_RESULT_RECOVERED; |
| 5893 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5894 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 5895 | if (IS_QLA2100(ha) || IS_QLA2200(ha)){ |
| 5896 | stat = RD_REG_DWORD(®->hccr); |
| 5897 | if (stat & HCCR_RISC_PAUSE) |
| 5898 | risc_paused = 1; |
| 5899 | } else if (IS_QLA23XX(ha)) { |
| 5900 | stat = RD_REG_DWORD(®->u.isp2300.host_status); |
| 5901 | if (stat & HSR_RISC_PAUSED) |
| 5902 | risc_paused = 1; |
| 5903 | } else if (IS_FWI2_CAPABLE(ha)) { |
| 5904 | stat = RD_REG_DWORD(®24->host_status); |
| 5905 | if (stat & HSRX_RISC_PAUSED) |
| 5906 | risc_paused = 1; |
| 5907 | } |
| 5908 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 5909 | |
| 5910 | if (risc_paused) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5911 | ql_log(ql_log_info, base_vha, 0x9003, |
| 5912 | "RISC paused -- mmio_enabled, Dumping firmware.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5913 | ha->isp_ops->fw_dump(base_vha, 0); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5914 | |
| 5915 | return PCI_ERS_RESULT_NEED_RESET; |
| 5916 | } else |
| 5917 | return PCI_ERS_RESULT_RECOVERED; |
| 5918 | } |
| 5919 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 5920 | static uint32_t |
| 5921 | qla82xx_error_recovery(scsi_qla_host_t *base_vha) |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5922 | { |
| 5923 | uint32_t rval = QLA_FUNCTION_FAILED; |
| 5924 | uint32_t drv_active = 0; |
| 5925 | struct qla_hw_data *ha = base_vha->hw; |
| 5926 | int fn; |
| 5927 | struct pci_dev *other_pdev = NULL; |
| 5928 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5929 | ql_dbg(ql_dbg_aer, base_vha, 0x9006, |
| 5930 | "Entered %s.\n", __func__); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5931 | |
| 5932 | set_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
| 5933 | |
| 5934 | if (base_vha->flags.online) { |
| 5935 | /* Abort all outstanding commands, |
| 5936 | * so as to be requeued later */ |
| 5937 | qla2x00_abort_isp_cleanup(base_vha); |
| 5938 | } |
| 5939 | |
| 5940 | |
| 5941 | fn = PCI_FUNC(ha->pdev->devfn); |
| 5942 | while (fn > 0) { |
| 5943 | fn--; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5944 | ql_dbg(ql_dbg_aer, base_vha, 0x9007, |
| 5945 | "Finding pci device at function = 0x%x.\n", fn); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5946 | other_pdev = |
| 5947 | pci_get_domain_bus_and_slot(pci_domain_nr(ha->pdev->bus), |
| 5948 | ha->pdev->bus->number, PCI_DEVFN(PCI_SLOT(ha->pdev->devfn), |
| 5949 | fn)); |
| 5950 | |
| 5951 | if (!other_pdev) |
| 5952 | continue; |
| 5953 | if (atomic_read(&other_pdev->enable_cnt)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5954 | ql_dbg(ql_dbg_aer, base_vha, 0x9008, |
| 5955 | "Found PCI func available and enable at 0x%x.\n", |
| 5956 | fn); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5957 | pci_dev_put(other_pdev); |
| 5958 | break; |
| 5959 | } |
| 5960 | pci_dev_put(other_pdev); |
| 5961 | } |
| 5962 | |
| 5963 | if (!fn) { |
| 5964 | /* Reset owner */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5965 | ql_dbg(ql_dbg_aer, base_vha, 0x9009, |
| 5966 | "This devfn is reset owner = 0x%x.\n", |
| 5967 | ha->pdev->devfn); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5968 | qla82xx_idc_lock(ha); |
| 5969 | |
| 5970 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5971 | QLA8XXX_DEV_INITIALIZING); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5972 | |
| 5973 | qla82xx_wr_32(ha, QLA82XX_CRB_DRV_IDC_VERSION, |
| 5974 | QLA82XX_IDC_VERSION); |
| 5975 | |
| 5976 | drv_active = qla82xx_rd_32(ha, QLA82XX_CRB_DRV_ACTIVE); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5977 | ql_dbg(ql_dbg_aer, base_vha, 0x900a, |
| 5978 | "drv_active = 0x%x.\n", drv_active); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5979 | |
| 5980 | qla82xx_idc_unlock(ha); |
| 5981 | /* Reset if device is not already reset |
| 5982 | * drv_active would be 0 if a reset has already been done |
| 5983 | */ |
| 5984 | if (drv_active) |
| 5985 | rval = qla82xx_start_firmware(base_vha); |
| 5986 | else |
| 5987 | rval = QLA_SUCCESS; |
| 5988 | qla82xx_idc_lock(ha); |
| 5989 | |
| 5990 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5991 | ql_log(ql_log_info, base_vha, 0x900b, |
| 5992 | "HW State: FAILED.\n"); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5993 | qla82xx_clear_drv_active(ha); |
| 5994 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5995 | QLA8XXX_DEV_FAILED); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5996 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5997 | ql_log(ql_log_info, base_vha, 0x900c, |
| 5998 | "HW State: READY.\n"); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5999 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 6000 | QLA8XXX_DEV_READY); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6001 | qla82xx_idc_unlock(ha); |
Giridhar Malavali | 7190575 | 2011-02-23 15:27:10 -0800 | [diff] [blame] | 6002 | ha->flags.isp82xx_fw_hung = 0; |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6003 | rval = qla82xx_restart_isp(base_vha); |
| 6004 | qla82xx_idc_lock(ha); |
| 6005 | /* Clear driver state register */ |
| 6006 | qla82xx_wr_32(ha, QLA82XX_CRB_DRV_STATE, 0); |
| 6007 | qla82xx_set_drv_active(base_vha); |
| 6008 | } |
| 6009 | qla82xx_idc_unlock(ha); |
| 6010 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6011 | ql_dbg(ql_dbg_aer, base_vha, 0x900d, |
| 6012 | "This devfn is not reset owner = 0x%x.\n", |
| 6013 | ha->pdev->devfn); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6014 | if ((qla82xx_rd_32(ha, QLA82XX_CRB_DEV_STATE) == |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 6015 | QLA8XXX_DEV_READY)) { |
Giridhar Malavali | 7190575 | 2011-02-23 15:27:10 -0800 | [diff] [blame] | 6016 | ha->flags.isp82xx_fw_hung = 0; |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6017 | rval = qla82xx_restart_isp(base_vha); |
| 6018 | qla82xx_idc_lock(ha); |
| 6019 | qla82xx_set_drv_active(base_vha); |
| 6020 | qla82xx_idc_unlock(ha); |
| 6021 | } |
| 6022 | } |
| 6023 | clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
| 6024 | |
| 6025 | return rval; |
| 6026 | } |
| 6027 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6028 | static pci_ers_result_t |
| 6029 | qla2xxx_pci_slot_reset(struct pci_dev *pdev) |
| 6030 | { |
| 6031 | pci_ers_result_t ret = PCI_ERS_RESULT_DISCONNECT; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6032 | scsi_qla_host_t *base_vha = pci_get_drvdata(pdev); |
| 6033 | struct qla_hw_data *ha = base_vha->hw; |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 6034 | struct rsp_que *rsp; |
| 6035 | int rc, retries = 10; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6036 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6037 | ql_dbg(ql_dbg_aer, base_vha, 0x9004, |
| 6038 | "Slot Reset.\n"); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6039 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 6040 | /* Workaround: qla2xxx driver which access hardware earlier |
| 6041 | * needs error state to be pci_channel_io_online. |
| 6042 | * Otherwise mailbox command timesout. |
| 6043 | */ |
| 6044 | pdev->error_state = pci_channel_io_normal; |
| 6045 | |
| 6046 | pci_restore_state(pdev); |
| 6047 | |
Richard Lary | 8c1496b | 2010-02-18 10:07:29 -0800 | [diff] [blame] | 6048 | /* pci_restore_state() clears the saved_state flag of the device |
| 6049 | * save restored state which resets saved_state flag |
| 6050 | */ |
| 6051 | pci_save_state(pdev); |
| 6052 | |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 6053 | if (ha->mem_only) |
| 6054 | rc = pci_enable_device_mem(pdev); |
| 6055 | else |
| 6056 | rc = pci_enable_device(pdev); |
| 6057 | |
| 6058 | if (rc) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6059 | ql_log(ql_log_warn, base_vha, 0x9005, |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6060 | "Can't re-enable PCI device after reset.\n"); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6061 | goto exit_slot_reset; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6062 | } |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6063 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 6064 | rsp = ha->rsp_q_map[0]; |
| 6065 | if (qla2x00_request_irqs(ha, rsp)) |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6066 | goto exit_slot_reset; |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 6067 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6068 | if (ha->isp_ops->pci_config(base_vha)) |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6069 | goto exit_slot_reset; |
| 6070 | |
| 6071 | if (IS_QLA82XX(ha)) { |
| 6072 | if (qla82xx_error_recovery(base_vha) == QLA_SUCCESS) { |
| 6073 | ret = PCI_ERS_RESULT_RECOVERED; |
| 6074 | goto exit_slot_reset; |
| 6075 | } else |
| 6076 | goto exit_slot_reset; |
| 6077 | } |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6078 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 6079 | while (ha->flags.mbox_busy && retries--) |
| 6080 | msleep(1000); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6081 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6082 | set_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 6083 | if (ha->isp_ops->abort_isp(base_vha) == QLA_SUCCESS) |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6084 | ret = PCI_ERS_RESULT_RECOVERED; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6085 | clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6086 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 6087 | |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 6088 | exit_slot_reset: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6089 | ql_dbg(ql_dbg_aer, base_vha, 0x900e, |
| 6090 | "slot_reset return %x.\n", ret); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6091 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6092 | return ret; |
| 6093 | } |
| 6094 | |
| 6095 | static void |
| 6096 | qla2xxx_pci_resume(struct pci_dev *pdev) |
| 6097 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6098 | scsi_qla_host_t *base_vha = pci_get_drvdata(pdev); |
| 6099 | struct qla_hw_data *ha = base_vha->hw; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6100 | int ret; |
| 6101 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6102 | ql_dbg(ql_dbg_aer, base_vha, 0x900f, |
| 6103 | "pci_resume.\n"); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6104 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 6105 | ret = qla2x00_wait_for_hba_online(base_vha); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6106 | if (ret != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6107 | ql_log(ql_log_fatal, base_vha, 0x9002, |
| 6108 | "The device failed to resume I/O from slot/link_reset.\n"); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6109 | } |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6110 | |
Lalit Chandivade | 3e46f03 | 2010-05-04 15:01:23 -0700 | [diff] [blame] | 6111 | pci_cleanup_aer_uncorrect_error_status(pdev); |
| 6112 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 6113 | ha->flags.eeh_busy = 0; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6114 | } |
| 6115 | |
Himanshu Madhani | 2d5a4c3 | 2014-09-25 05:16:55 -0400 | [diff] [blame] | 6116 | static void |
| 6117 | qla83xx_disable_laser(scsi_qla_host_t *vha) |
| 6118 | { |
| 6119 | uint32_t reg, data, fn; |
| 6120 | struct qla_hw_data *ha = vha->hw; |
| 6121 | struct device_reg_24xx __iomem *isp_reg = &ha->iobase->isp24; |
| 6122 | |
| 6123 | /* pci func #/port # */ |
| 6124 | ql_dbg(ql_dbg_init, vha, 0x004b, |
| 6125 | "Disabling Laser for hba: %p\n", vha); |
| 6126 | |
| 6127 | fn = (RD_REG_DWORD(&isp_reg->ctrl_status) & |
| 6128 | (BIT_15|BIT_14|BIT_13|BIT_12)); |
| 6129 | |
| 6130 | fn = (fn >> 12); |
| 6131 | |
| 6132 | if (fn & 1) |
| 6133 | reg = PORT_1_2031; |
| 6134 | else |
| 6135 | reg = PORT_0_2031; |
| 6136 | |
| 6137 | data = LASER_OFF_2031; |
| 6138 | |
| 6139 | qla83xx_wr_reg(vha, reg, data); |
| 6140 | } |
| 6141 | |
Michael Hernandez | 5601236 | 2016-12-12 14:40:08 -0800 | [diff] [blame^] | 6142 | static int qla2xxx_map_queues(struct Scsi_Host *shost) |
| 6143 | { |
| 6144 | scsi_qla_host_t *vha = (scsi_qla_host_t *)shost->hostdata; |
| 6145 | |
| 6146 | return blk_mq_pci_map_queues(&shost->tag_set, vha->hw->pdev); |
| 6147 | } |
| 6148 | |
Stephen Hemminger | a55b2d2 | 2012-09-07 09:33:16 -0700 | [diff] [blame] | 6149 | static const struct pci_error_handlers qla2xxx_err_handler = { |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6150 | .error_detected = qla2xxx_pci_error_detected, |
| 6151 | .mmio_enabled = qla2xxx_pci_mmio_enabled, |
| 6152 | .slot_reset = qla2xxx_pci_slot_reset, |
| 6153 | .resume = qla2xxx_pci_resume, |
| 6154 | }; |
| 6155 | |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6156 | static struct pci_device_id qla2xxx_pci_tbl[] = { |
Andrew Vasquez | 47f5e06 | 2006-05-17 15:09:39 -0700 | [diff] [blame] | 6157 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2100) }, |
| 6158 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2200) }, |
| 6159 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2300) }, |
| 6160 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2312) }, |
| 6161 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2322) }, |
| 6162 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP6312) }, |
| 6163 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP6322) }, |
| 6164 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2422) }, |
| 6165 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2432) }, |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 6166 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8432) }, |
Andrew Vasquez | 47f5e06 | 2006-05-17 15:09:39 -0700 | [diff] [blame] | 6167 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP5422) }, |
| 6168 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP5432) }, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 6169 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2532) }, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 6170 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2031) }, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 6171 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8001) }, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 6172 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8021) }, |
Chad Dupuis | 650f528 | 2012-08-22 14:20:55 -0400 | [diff] [blame] | 6173 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8031) }, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 6174 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISPF001) }, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 6175 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8044) }, |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 6176 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2071) }, |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 6177 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2271) }, |
Sawan Chandak | 2b48992 | 2015-08-04 13:38:03 -0400 | [diff] [blame] | 6178 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2261) }, |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6179 | { 0 }, |
| 6180 | }; |
| 6181 | MODULE_DEVICE_TABLE(pci, qla2xxx_pci_tbl); |
| 6182 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 6183 | static struct pci_driver qla2xxx_pci_driver = { |
Andrew Vasquez | cb63067 | 2006-05-17 15:09:45 -0700 | [diff] [blame] | 6184 | .name = QLA2XXX_DRIVER_NAME, |
James Bottomley | 0a21ef1 | 2005-12-01 12:51:50 -0600 | [diff] [blame] | 6185 | .driver = { |
| 6186 | .owner = THIS_MODULE, |
| 6187 | }, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 6188 | .id_table = qla2xxx_pci_tbl, |
Andrew Vasquez | 7ee6139 | 2006-06-23 16:11:22 -0700 | [diff] [blame] | 6189 | .probe = qla2x00_probe_one, |
Adrian Bunk | 4c993f7 | 2008-01-14 00:55:16 -0800 | [diff] [blame] | 6190 | .remove = qla2x00_remove_one, |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 6191 | .shutdown = qla2x00_shutdown, |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 6192 | .err_handler = &qla2xxx_err_handler, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 6193 | }; |
| 6194 | |
Al Viro | 75ef9de | 2013-04-04 19:09:41 -0400 | [diff] [blame] | 6195 | static const struct file_operations apidev_fops = { |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 6196 | .owner = THIS_MODULE, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 6197 | .llseek = noop_llseek, |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 6198 | }; |
| 6199 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6200 | /** |
| 6201 | * qla2x00_module_init - Module initialization. |
| 6202 | **/ |
| 6203 | static int __init |
| 6204 | qla2x00_module_init(void) |
| 6205 | { |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 6206 | int ret = 0; |
| 6207 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6208 | /* Allocate cache for SRBs. */ |
Andrew Vasquez | 354d6b2 | 2005-04-23 02:47:27 -0400 | [diff] [blame] | 6209 | srb_cachep = kmem_cache_create("qla2xxx_srbs", sizeof(srb_t), 0, |
Paul Mundt | 20c2df8 | 2007-07-20 10:11:58 +0900 | [diff] [blame] | 6210 | SLAB_HWCACHE_ALIGN, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6211 | if (srb_cachep == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6212 | ql_log(ql_log_fatal, NULL, 0x0001, |
| 6213 | "Unable to allocate SRB cache...Failing load!.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6214 | return -ENOMEM; |
| 6215 | } |
| 6216 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 6217 | /* Initialize target kmem_cache and mem_pools */ |
| 6218 | ret = qlt_init(); |
| 6219 | if (ret < 0) { |
| 6220 | kmem_cache_destroy(srb_cachep); |
| 6221 | return ret; |
| 6222 | } else if (ret > 0) { |
| 6223 | /* |
| 6224 | * If initiator mode is explictly disabled by qlt_init(), |
| 6225 | * prevent scsi_transport_fc.c:fc_scsi_scan_rport() from |
| 6226 | * performing scsi_scan_target() during LOOP UP event. |
| 6227 | */ |
| 6228 | qla2xxx_transport_functions.disable_target_scan = 1; |
| 6229 | qla2xxx_transport_vport_functions.disable_target_scan = 1; |
| 6230 | } |
| 6231 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6232 | /* Derive version string. */ |
| 6233 | strcpy(qla2x00_version_str, QLA2XXX_VERSION); |
Andrew Vasquez | 11010fe | 2006-10-06 09:54:59 -0700 | [diff] [blame] | 6234 | if (ql2xextended_error_logging) |
Andrew Vasquez | 0181944 | 2006-06-23 16:11:10 -0700 | [diff] [blame] | 6235 | strcat(qla2x00_version_str, "-debug"); |
| 6236 | |
Andrew Vasquez | 1c97a12 | 2005-04-21 16:13:36 -0400 | [diff] [blame] | 6237 | qla2xxx_transport_template = |
| 6238 | fc_attach_transport(&qla2xxx_transport_functions); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6239 | if (!qla2xxx_transport_template) { |
| 6240 | kmem_cache_destroy(srb_cachep); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6241 | ql_log(ql_log_fatal, NULL, 0x0002, |
| 6242 | "fc_attach_transport failed...Failing load!.\n"); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 6243 | qlt_exit(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6244 | return -ENODEV; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6245 | } |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 6246 | |
| 6247 | apidev_major = register_chrdev(0, QLA2XXX_APIDEV, &apidev_fops); |
| 6248 | if (apidev_major < 0) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6249 | ql_log(ql_log_fatal, NULL, 0x0003, |
| 6250 | "Unable to register char device %s.\n", QLA2XXX_APIDEV); |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 6251 | } |
| 6252 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6253 | qla2xxx_transport_vport_template = |
| 6254 | fc_attach_transport(&qla2xxx_transport_vport_functions); |
| 6255 | if (!qla2xxx_transport_vport_template) { |
| 6256 | kmem_cache_destroy(srb_cachep); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 6257 | qlt_exit(); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6258 | fc_release_transport(qla2xxx_transport_template); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6259 | ql_log(ql_log_fatal, NULL, 0x0004, |
| 6260 | "fc_attach_transport vport failed...Failing load!.\n"); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6261 | return -ENODEV; |
| 6262 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6263 | ql_log(ql_log_info, NULL, 0x0005, |
| 6264 | "QLogic Fibre Channel HBA Driver: %s.\n", |
Andrew Vasquez | fd9a29f0 | 2008-05-12 22:21:08 -0700 | [diff] [blame] | 6265 | qla2x00_version_str); |
Andrew Vasquez | 7ee6139 | 2006-06-23 16:11:22 -0700 | [diff] [blame] | 6266 | ret = pci_register_driver(&qla2xxx_pci_driver); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 6267 | if (ret) { |
| 6268 | kmem_cache_destroy(srb_cachep); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 6269 | qlt_exit(); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 6270 | fc_release_transport(qla2xxx_transport_template); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6271 | fc_release_transport(qla2xxx_transport_vport_template); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 6272 | ql_log(ql_log_fatal, NULL, 0x0006, |
| 6273 | "pci_register_driver failed...ret=%d Failing load!.\n", |
| 6274 | ret); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 6275 | } |
| 6276 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6277 | } |
| 6278 | |
| 6279 | /** |
| 6280 | * qla2x00_module_exit - Module cleanup. |
| 6281 | **/ |
| 6282 | static void __exit |
| 6283 | qla2x00_module_exit(void) |
| 6284 | { |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 6285 | unregister_chrdev(apidev_major, QLA2XXX_APIDEV); |
Andrew Vasquez | 7ee6139 | 2006-06-23 16:11:22 -0700 | [diff] [blame] | 6286 | pci_unregister_driver(&qla2xxx_pci_driver); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 6287 | qla2x00_release_firmware(); |
Andrew Vasquez | 354d6b2 | 2005-04-23 02:47:27 -0400 | [diff] [blame] | 6288 | kmem_cache_destroy(srb_cachep); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 6289 | qlt_exit(); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 6290 | if (ctx_cachep) |
| 6291 | kmem_cache_destroy(ctx_cachep); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6292 | fc_release_transport(qla2xxx_transport_template); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 6293 | fc_release_transport(qla2xxx_transport_vport_template); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6294 | } |
| 6295 | |
| 6296 | module_init(qla2x00_module_init); |
| 6297 | module_exit(qla2x00_module_exit); |
| 6298 | |
| 6299 | MODULE_AUTHOR("QLogic Corporation"); |
| 6300 | MODULE_DESCRIPTION("QLogic Fibre Channel HBA Driver"); |
| 6301 | MODULE_LICENSE("GPL"); |
| 6302 | MODULE_VERSION(QLA2XXX_VERSION); |
Andrew Vasquez | bb8ee49 | 2006-10-02 12:00:48 -0700 | [diff] [blame] | 6303 | MODULE_FIRMWARE(FW_FILE_ISP21XX); |
| 6304 | MODULE_FIRMWARE(FW_FILE_ISP22XX); |
| 6305 | MODULE_FIRMWARE(FW_FILE_ISP2300); |
| 6306 | MODULE_FIRMWARE(FW_FILE_ISP2322); |
| 6307 | MODULE_FIRMWARE(FW_FILE_ISP24XX); |
Andrew Vasquez | 61623fc | 2008-01-31 12:33:45 -0800 | [diff] [blame] | 6308 | MODULE_FIRMWARE(FW_FILE_ISP25XX); |