Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
Andrew Vasquez | fa90c54 | 2005-10-27 11:10:08 -0700 | [diff] [blame] | 2 | * QLogic Fibre Channel HBA Driver |
Armen Baloyan | bd21eaf | 2014-04-11 16:54:24 -0400 | [diff] [blame] | 3 | * Copyright (c) 2003-2014 QLogic Corporation |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | * |
Andrew Vasquez | fa90c54 | 2005-10-27 11:10:08 -0700 | [diff] [blame] | 5 | * See LICENSE.qla2xxx for copyright and licensing details. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 6 | */ |
| 7 | #include "qla_def.h" |
| 8 | |
| 9 | #include <linux/moduleparam.h> |
| 10 | #include <linux/vmalloc.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 11 | #include <linux/delay.h> |
Christoph Hellwig | 39a1124 | 2006-02-14 18:46:22 +0100 | [diff] [blame] | 12 | #include <linux/kthread.h> |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 13 | #include <linux/mutex.h> |
Andrew Vasquez | 3420d36 | 2009-10-13 15:16:45 -0700 | [diff] [blame] | 14 | #include <linux/kobject.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 15 | #include <linux/slab.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | #include <scsi/scsi_tcq.h> |
| 17 | #include <scsi/scsicam.h> |
| 18 | #include <scsi/scsi_transport.h> |
| 19 | #include <scsi/scsi_transport_fc.h> |
| 20 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 21 | #include "qla_target.h" |
| 22 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | /* |
| 24 | * Driver version |
| 25 | */ |
| 26 | char qla2x00_version_str[40]; |
| 27 | |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 28 | static int apidev_major; |
| 29 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 30 | /* |
| 31 | * SRB allocation cache |
| 32 | */ |
Christoph Lameter | e18b890 | 2006-12-06 20:33:20 -0800 | [diff] [blame] | 33 | static struct kmem_cache *srb_cachep; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 34 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 35 | /* |
| 36 | * CT6 CTX allocation cache |
| 37 | */ |
| 38 | static struct kmem_cache *ctx_cachep; |
Saurav Kashyap | 3ce8866 | 2011-07-14 12:00:12 -0700 | [diff] [blame] | 39 | /* |
| 40 | * error level for logging |
| 41 | */ |
| 42 | int ql_errlev = ql_log_all; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 43 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 44 | static int ql2xenableclass2; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 45 | module_param(ql2xenableclass2, int, S_IRUGO|S_IRUSR); |
| 46 | MODULE_PARM_DESC(ql2xenableclass2, |
| 47 | "Specify if Class 2 operations are supported from the very " |
| 48 | "beginning. Default is 0 - class 2 not supported."); |
| 49 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 50 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 51 | int ql2xlogintimeout = 20; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 52 | module_param(ql2xlogintimeout, int, S_IRUGO); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 53 | MODULE_PARM_DESC(ql2xlogintimeout, |
| 54 | "Login timeout value in seconds."); |
| 55 | |
Andrew Vasquez | a7b6184 | 2007-05-07 07:42:59 -0700 | [diff] [blame] | 56 | int qlport_down_retry; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 57 | module_param(qlport_down_retry, int, S_IRUGO); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | MODULE_PARM_DESC(qlport_down_retry, |
Jesper Juhl | 900d9f9 | 2006-06-30 02:33:07 -0700 | [diff] [blame] | 59 | "Maximum number of command retries to a port that returns " |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | "a PORT-DOWN status."); |
| 61 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 62 | int ql2xplogiabsentdevice; |
| 63 | module_param(ql2xplogiabsentdevice, int, S_IRUGO|S_IWUSR); |
| 64 | MODULE_PARM_DESC(ql2xplogiabsentdevice, |
| 65 | "Option to enable PLOGI to devices that are not present after " |
Jesper Juhl | 900d9f9 | 2006-06-30 02:33:07 -0700 | [diff] [blame] | 66 | "a Fabric scan. This is needed for several broken switches. " |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | "Default is 0 - no PLOGI. 1 - perfom PLOGI."); |
| 68 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 69 | int ql2xloginretrycount = 0; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 70 | module_param(ql2xloginretrycount, int, S_IRUGO); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | MODULE_PARM_DESC(ql2xloginretrycount, |
| 72 | "Specify an alternate value for the NVRAM login retry count."); |
| 73 | |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 74 | int ql2xallocfwdump = 1; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 75 | module_param(ql2xallocfwdump, int, S_IRUGO); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 76 | MODULE_PARM_DESC(ql2xallocfwdump, |
| 77 | "Option to enable allocation of memory for a firmware dump " |
| 78 | "during HBA initialization. Memory allocation requirements " |
| 79 | "vary by ISP type. Default is 1 - allocate memory."); |
| 80 | |
Andrew Vasquez | 11010fe | 2006-10-06 09:54:59 -0700 | [diff] [blame] | 81 | int ql2xextended_error_logging; |
Andrew Vasquez | 27d9403 | 2007-03-12 10:41:30 -0700 | [diff] [blame] | 82 | module_param(ql2xextended_error_logging, int, S_IRUGO|S_IWUSR); |
Andrew Vasquez | 11010fe | 2006-10-06 09:54:59 -0700 | [diff] [blame] | 83 | MODULE_PARM_DESC(ql2xextended_error_logging, |
Saurav Kashyap | 3ce8866 | 2011-07-14 12:00:12 -0700 | [diff] [blame] | 84 | "Option to enable extended error logging,\n" |
| 85 | "\t\tDefault is 0 - no logging. 0x40000000 - Module Init & Probe.\n" |
| 86 | "\t\t0x20000000 - Mailbox Cmnds. 0x10000000 - Device Discovery.\n" |
| 87 | "\t\t0x08000000 - IO tracing. 0x04000000 - DPC Thread.\n" |
| 88 | "\t\t0x02000000 - Async events. 0x01000000 - Timer routines.\n" |
| 89 | "\t\t0x00800000 - User space. 0x00400000 - Task Management.\n" |
| 90 | "\t\t0x00200000 - AER/EEH. 0x00100000 - Multi Q.\n" |
| 91 | "\t\t0x00080000 - P3P Specific. 0x00040000 - Virtual Port.\n" |
| 92 | "\t\t0x00020000 - Buffer Dump. 0x00010000 - Misc.\n" |
Chad Dupuis | 29f9f90 | 2012-11-21 02:40:41 -0500 | [diff] [blame] | 93 | "\t\t0x00008000 - Verbose. 0x00004000 - Target.\n" |
| 94 | "\t\t0x00002000 - Target Mgmt. 0x00001000 - Target TMF.\n" |
Saurav Kashyap | 3ce8866 | 2011-07-14 12:00:12 -0700 | [diff] [blame] | 95 | "\t\t0x7fffffff - For enabling all logs, can be too many logs.\n" |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 96 | "\t\t0x1e400000 - Preferred value for capturing essential " |
| 97 | "debug information (equivalent to old " |
| 98 | "ql2xextended_error_logging=1).\n" |
Saurav Kashyap | 3ce8866 | 2011-07-14 12:00:12 -0700 | [diff] [blame] | 99 | "\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] | 100 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 101 | int ql2xshiftctondsd = 6; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 102 | module_param(ql2xshiftctondsd, int, S_IRUGO); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 103 | MODULE_PARM_DESC(ql2xshiftctondsd, |
| 104 | "Set to control shifting of command type processing " |
| 105 | "based on total number of SG elements."); |
| 106 | |
Andrew Vasquez | 7e47e5c | 2008-04-24 15:21:26 -0700 | [diff] [blame] | 107 | int ql2xfdmienable=1; |
Himanshu Madhani | de187df | 2014-09-25 05:16:50 -0400 | [diff] [blame] | 108 | module_param(ql2xfdmienable, int, S_IRUGO|S_IWUSR); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 109 | MODULE_PARM_DESC(ql2xfdmienable, |
Ferenc Wagner | 7794a5a | 2010-03-23 18:14:59 +0100 | [diff] [blame] | 110 | "Enables FDMI registrations. " |
| 111 | "0 - no FDMI. Default is 1 - perform FDMI."); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 112 | |
Chad Dupuis | 50280c0 | 2013-10-30 03:38:14 -0400 | [diff] [blame] | 113 | #define MAX_Q_DEPTH 32 |
| 114 | static int ql2xmaxqdepth = MAX_Q_DEPTH; |
Andrew Vasquez | df7baa5 | 2006-10-13 09:33:39 -0700 | [diff] [blame] | 115 | module_param(ql2xmaxqdepth, int, S_IRUGO|S_IWUSR); |
| 116 | MODULE_PARM_DESC(ql2xmaxqdepth, |
Chad Dupuis | e92e4a8 | 2012-08-22 14:21:23 -0400 | [diff] [blame] | 117 | "Maximum queue depth to set for each LUN. " |
| 118 | "Default is 32."); |
Andrew Vasquez | df7baa5 | 2006-10-13 09:33:39 -0700 | [diff] [blame] | 119 | |
Arun Easi | 9e522cd | 2012-08-22 14:21:31 -0400 | [diff] [blame] | 120 | int ql2xenabledif = 2; |
| 121 | module_param(ql2xenabledif, int, S_IRUGO); |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 122 | MODULE_PARM_DESC(ql2xenabledif, |
Steven J. Magnani | b97f5d0 | 2014-02-04 12:50:35 -0600 | [diff] [blame] | 123 | " Enable T10-CRC-DIF:\n" |
| 124 | " Default is 2.\n" |
| 125 | " 0 -- No DIF Support\n" |
| 126 | " 1 -- Enable DIF for all types\n" |
| 127 | " 2 -- Enable DIF for all types, except Type 0.\n"); |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 128 | |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 129 | int ql2xenablehba_err_chk = 2; |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 130 | module_param(ql2xenablehba_err_chk, int, S_IRUGO|S_IWUSR); |
| 131 | MODULE_PARM_DESC(ql2xenablehba_err_chk, |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 132 | " Enable T10-CRC-DIF Error isolation by HBA:\n" |
Steven J. Magnani | b97f5d0 | 2014-02-04 12:50:35 -0600 | [diff] [blame] | 133 | " Default is 2.\n" |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 134 | " 0 -- Error isolation disabled\n" |
| 135 | " 1 -- Error isolation enabled only for DIX Type 0\n" |
| 136 | " 2 -- Error isolation enabled for all Types\n"); |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 137 | |
Andrew Vasquez | e5896bd | 2008-07-10 16:55:52 -0700 | [diff] [blame] | 138 | int ql2xiidmaenable=1; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 139 | module_param(ql2xiidmaenable, int, S_IRUGO); |
Andrew Vasquez | e5896bd | 2008-07-10 16:55:52 -0700 | [diff] [blame] | 140 | MODULE_PARM_DESC(ql2xiidmaenable, |
| 141 | "Enables iIDMA settings " |
| 142 | "Default is 1 - perform iIDMA. 0 - no iIDMA."); |
| 143 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 144 | int ql2xmaxqueues = 1; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 145 | module_param(ql2xmaxqueues, int, S_IRUGO); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 146 | MODULE_PARM_DESC(ql2xmaxqueues, |
| 147 | "Enables MQ settings " |
Joe Perches | ae68230 | 2010-08-10 18:01:21 -0700 | [diff] [blame] | 148 | "Default is 1 for single queue. Set it to number " |
| 149 | "of queues in MQ mode."); |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 150 | |
| 151 | int ql2xmultique_tag; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 152 | module_param(ql2xmultique_tag, int, S_IRUGO); |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 153 | MODULE_PARM_DESC(ql2xmultique_tag, |
| 154 | "Enables CPU affinity settings for the driver " |
| 155 | "Default is 0 for no affinity of request and response IO. " |
| 156 | "Set it to 1 to turn on the cpu affinity."); |
Andrew Vasquez | e337d90 | 2009-04-06 22:33:49 -0700 | [diff] [blame] | 157 | |
| 158 | int ql2xfwloadbin; |
Chad Dupuis | 86e45bf | 2011-08-16 11:31:47 -0700 | [diff] [blame] | 159 | module_param(ql2xfwloadbin, int, S_IRUGO|S_IWUSR); |
Andrew Vasquez | e337d90 | 2009-04-06 22:33:49 -0700 | [diff] [blame] | 160 | MODULE_PARM_DESC(ql2xfwloadbin, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 161 | "Option to specify location from which to load ISP firmware:.\n" |
| 162 | " 2 -- load firmware via the request_firmware() (hotplug).\n" |
Andrew Vasquez | e337d90 | 2009-04-06 22:33:49 -0700 | [diff] [blame] | 163 | " interface.\n" |
| 164 | " 1 -- load firmware from flash.\n" |
| 165 | " 0 -- use default semantics.\n"); |
| 166 | |
Andrew Vasquez | ae97c91 | 2010-02-18 10:07:28 -0800 | [diff] [blame] | 167 | int ql2xetsenable; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 168 | module_param(ql2xetsenable, int, S_IRUGO); |
Andrew Vasquez | ae97c91 | 2010-02-18 10:07:28 -0800 | [diff] [blame] | 169 | MODULE_PARM_DESC(ql2xetsenable, |
| 170 | "Enables firmware ETS burst." |
| 171 | "Default is 0 - skip ETS enablement."); |
| 172 | |
Giridhar Malavali | 6907869 | 2010-05-28 15:08:28 -0700 | [diff] [blame] | 173 | int ql2xdbwr = 1; |
Chad Dupuis | 86e45bf | 2011-08-16 11:31:47 -0700 | [diff] [blame] | 174 | module_param(ql2xdbwr, int, S_IRUGO|S_IWUSR); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 175 | MODULE_PARM_DESC(ql2xdbwr, |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 176 | "Option to specify scheme for request queue posting.\n" |
| 177 | " 0 -- Regular doorbell.\n" |
| 178 | " 1 -- CAMRAM doorbell (faster).\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 179 | |
Giridhar Malavali | f4c496c | 2010-05-04 15:01:33 -0700 | [diff] [blame] | 180 | int ql2xtargetreset = 1; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 181 | module_param(ql2xtargetreset, int, S_IRUGO); |
Giridhar Malavali | f4c496c | 2010-05-04 15:01:33 -0700 | [diff] [blame] | 182 | MODULE_PARM_DESC(ql2xtargetreset, |
| 183 | "Enable target reset." |
| 184 | "Default is 1 - use hw defaults."); |
| 185 | |
Chad Dupuis | 4da26e1 | 2010-10-15 11:27:40 -0700 | [diff] [blame] | 186 | int ql2xgffidenable; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 187 | module_param(ql2xgffidenable, int, S_IRUGO); |
Chad Dupuis | 4da26e1 | 2010-10-15 11:27:40 -0700 | [diff] [blame] | 188 | MODULE_PARM_DESC(ql2xgffidenable, |
| 189 | "Enables GFF_ID checks of port type. " |
| 190 | "Default is 0 - Do not use GFF_ID information."); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 191 | |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 192 | int ql2xasynctmfenable; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 193 | module_param(ql2xasynctmfenable, int, S_IRUGO); |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 194 | MODULE_PARM_DESC(ql2xasynctmfenable, |
| 195 | "Enables issue of TM IOCBs asynchronously via IOCB mechanism" |
| 196 | "Default is 0 - Issue TM IOCBs via mailbox mechanism."); |
Giridhar Malavali | ed0de87 | 2011-03-30 11:46:29 -0700 | [diff] [blame] | 197 | |
| 198 | int ql2xdontresethba; |
Chad Dupuis | 86e45bf | 2011-08-16 11:31:47 -0700 | [diff] [blame] | 199 | module_param(ql2xdontresethba, int, S_IRUGO|S_IWUSR); |
Giridhar Malavali | ed0de87 | 2011-03-30 11:46:29 -0700 | [diff] [blame] | 200 | MODULE_PARM_DESC(ql2xdontresethba, |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 201 | "Option to specify reset behaviour.\n" |
| 202 | " 0 (Default) -- Reset on failure.\n" |
| 203 | " 1 -- Do not reset on failure.\n"); |
Giridhar Malavali | ed0de87 | 2011-03-30 11:46:29 -0700 | [diff] [blame] | 204 | |
Hannes Reinecke | 1abf635 | 2014-06-25 15:27:38 +0200 | [diff] [blame] | 205 | uint64_t ql2xmaxlun = MAX_LUNS; |
| 206 | module_param(ql2xmaxlun, ullong, S_IRUGO); |
Andrew Vasquez | 8251592 | 2011-05-10 11:30:13 -0700 | [diff] [blame] | 207 | MODULE_PARM_DESC(ql2xmaxlun, |
| 208 | "Defines the maximum LU number to register with the SCSI " |
| 209 | "midlayer. Default is 65535."); |
| 210 | |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 211 | int ql2xmdcapmask = 0x1F; |
| 212 | module_param(ql2xmdcapmask, int, S_IRUGO); |
| 213 | MODULE_PARM_DESC(ql2xmdcapmask, |
| 214 | "Set the Minidump driver capture mask level. " |
Giridhar Malavali | 6e96fa7 | 2011-11-18 09:03:14 -0800 | [diff] [blame] | 215 | "Default is 0x1F - Can be set to 0x3, 0x7, 0xF, 0x1F, 0x7F."); |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 216 | |
Giridhar Malavali | 3aadff3 | 2011-11-18 09:02:14 -0800 | [diff] [blame] | 217 | int ql2xmdenable = 1; |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 218 | module_param(ql2xmdenable, int, S_IRUGO); |
| 219 | MODULE_PARM_DESC(ql2xmdenable, |
| 220 | "Enable/disable MiniDump. " |
Giridhar Malavali | 3aadff3 | 2011-11-18 09:02:14 -0800 | [diff] [blame] | 221 | "0 - MiniDump disabled. " |
| 222 | "1 (Default) - MiniDump enabled."); |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 223 | |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 224 | int ql2xexlogins = 0; |
| 225 | module_param(ql2xexlogins, uint, S_IRUGO|S_IWUSR); |
| 226 | MODULE_PARM_DESC(ql2xexlogins, |
| 227 | "Number of extended Logins. " |
| 228 | "0 (Default)- Disabled."); |
| 229 | |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 230 | int ql2xexchoffld = 0; |
| 231 | module_param(ql2xexchoffld, uint, S_IRUGO|S_IWUSR); |
| 232 | MODULE_PARM_DESC(ql2xexchoffld, |
| 233 | "Number of exchanges to offload. " |
| 234 | "0 (Default)- Disabled."); |
| 235 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 236 | /* |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 237 | * SCSI host template entry points |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 238 | */ |
| 239 | static int qla2xxx_slave_configure(struct scsi_device * device); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 240 | static int qla2xxx_slave_alloc(struct scsi_device *); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 241 | static int qla2xxx_scan_finished(struct Scsi_Host *, unsigned long time); |
| 242 | static void qla2xxx_scan_start(struct Scsi_Host *); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 243 | static void qla2xxx_slave_destroy(struct scsi_device *); |
Jeff Garzik | f281233 | 2010-11-16 02:10:29 -0500 | [diff] [blame] | 244 | static int qla2xxx_queuecommand(struct Scsi_Host *h, struct scsi_cmnd *cmd); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 245 | static int qla2xxx_eh_abort(struct scsi_cmnd *); |
| 246 | static int qla2xxx_eh_device_reset(struct scsi_cmnd *); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 247 | static int qla2xxx_eh_target_reset(struct scsi_cmnd *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 248 | static int qla2xxx_eh_bus_reset(struct scsi_cmnd *); |
| 249 | static int qla2xxx_eh_host_reset(struct scsi_cmnd *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 250 | |
Joe Lawrence | 1a2fbf1 | 2014-08-26 17:11:18 -0400 | [diff] [blame] | 251 | static void qla2x00_clear_drv_active(struct qla_hw_data *); |
Saurav Kashyap | 3491255 | 2013-06-25 11:27:18 -0400 | [diff] [blame] | 252 | static void qla2x00_free_device(scsi_qla_host_t *); |
Himanshu Madhani | 2d5a4c3 | 2014-09-25 05:16:55 -0400 | [diff] [blame] | 253 | static void qla83xx_disable_laser(scsi_qla_host_t *vha); |
Andrew Vasquez | ce7e4af | 2005-08-26 19:09:30 -0700 | [diff] [blame] | 254 | |
Giridhar Malavali | a5326f8 | 2009-03-24 09:07:56 -0700 | [diff] [blame] | 255 | struct scsi_host_template qla2xxx_driver_template = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 256 | .module = THIS_MODULE, |
Andrew Vasquez | cb63067 | 2006-05-17 15:09:45 -0700 | [diff] [blame] | 257 | .name = QLA2XXX_DRIVER_NAME, |
Giridhar Malavali | a5326f8 | 2009-03-24 09:07:56 -0700 | [diff] [blame] | 258 | .queuecommand = qla2xxx_queuecommand, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 259 | |
| 260 | .eh_abort_handler = qla2xxx_eh_abort, |
| 261 | .eh_device_reset_handler = qla2xxx_eh_device_reset, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 262 | .eh_target_reset_handler = qla2xxx_eh_target_reset, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 263 | .eh_bus_reset_handler = qla2xxx_eh_bus_reset, |
| 264 | .eh_host_reset_handler = qla2xxx_eh_host_reset, |
| 265 | |
| 266 | .slave_configure = qla2xxx_slave_configure, |
| 267 | |
| 268 | .slave_alloc = qla2xxx_slave_alloc, |
| 269 | .slave_destroy = qla2xxx_slave_destroy, |
Andrew Vasquez | ed67708 | 2007-03-12 10:41:27 -0700 | [diff] [blame] | 270 | .scan_finished = qla2xxx_scan_finished, |
| 271 | .scan_start = qla2xxx_scan_start, |
Christoph Hellwig | db5ed4d | 2014-11-13 15:08:42 +0100 | [diff] [blame] | 272 | .change_queue_depth = scsi_change_queue_depth, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 273 | .this_id = -1, |
| 274 | .cmd_per_lun = 3, |
| 275 | .use_clustering = ENABLE_CLUSTERING, |
| 276 | .sg_tablesize = SG_ALL, |
| 277 | |
| 278 | .max_sectors = 0xFFFF, |
Andrew Vasquez | afb046e | 2005-08-26 19:09:40 -0700 | [diff] [blame] | 279 | .shost_attrs = qla2x00_host_attrs, |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 280 | |
| 281 | .supported_mode = MODE_INITIATOR, |
Christoph Hellwig | c40ecc1 | 2014-11-13 14:25:11 +0100 | [diff] [blame] | 282 | .track_queue_depth = 1, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 283 | }; |
| 284 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 285 | static struct scsi_transport_template *qla2xxx_transport_template = NULL; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 286 | struct scsi_transport_template *qla2xxx_transport_vport_template = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 287 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 288 | /* TODO Convert to inlines |
| 289 | * |
| 290 | * Timer routines |
| 291 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 292 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 293 | __inline__ void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 294 | 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] | 295 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 296 | init_timer(&vha->timer); |
| 297 | vha->timer.expires = jiffies + interval * HZ; |
| 298 | vha->timer.data = (unsigned long)vha; |
| 299 | vha->timer.function = (void (*)(unsigned long))func; |
| 300 | add_timer(&vha->timer); |
| 301 | vha->timer_active = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 302 | } |
| 303 | |
| 304 | static inline void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 305 | qla2x00_restart_timer(scsi_qla_host_t *vha, unsigned long interval) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 306 | { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 307 | /* Currently used for 82XX only. */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 308 | if (vha->device_flags & DFLG_DEV_FAILED) { |
| 309 | ql_dbg(ql_dbg_timer, vha, 0x600d, |
| 310 | "Device in a failed state, returning.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 311 | return; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 312 | } |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 313 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 314 | mod_timer(&vha->timer, jiffies + interval * HZ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 315 | } |
| 316 | |
Adrian Bunk | a824ebb | 2008-01-17 09:02:15 -0800 | [diff] [blame] | 317 | static __inline__ void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 318 | qla2x00_stop_timer(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 319 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 320 | del_timer_sync(&vha->timer); |
| 321 | vha->timer_active = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 322 | } |
| 323 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 324 | static int qla2x00_do_dpc(void *data); |
| 325 | |
| 326 | static void qla2x00_rst_aen(scsi_qla_host_t *); |
| 327 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 328 | static int qla2x00_mem_alloc(struct qla_hw_data *, uint16_t, uint16_t, |
| 329 | struct req_que **, struct rsp_que **); |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 330 | static void qla2x00_free_fw_dump(struct qla_hw_data *); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 331 | static void qla2x00_mem_free(struct qla_hw_data *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 332 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 333 | /* -------------------------------------------------------------------------- */ |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 334 | static int qla2x00_alloc_queues(struct qla_hw_data *ha, struct req_que *req, |
| 335 | struct rsp_que *rsp) |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 336 | { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 337 | scsi_qla_host_t *vha = pci_get_drvdata(ha->pdev); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 338 | 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] | 339 | GFP_KERNEL); |
| 340 | if (!ha->req_q_map) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 341 | ql_log(ql_log_fatal, vha, 0x003b, |
| 342 | "Unable to allocate memory for request queue ptrs.\n"); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 343 | goto fail_req_map; |
| 344 | } |
| 345 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 346 | 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] | 347 | GFP_KERNEL); |
| 348 | if (!ha->rsp_q_map) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 349 | ql_log(ql_log_fatal, vha, 0x003c, |
| 350 | "Unable to allocate memory for response queue ptrs.\n"); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 351 | goto fail_rsp_map; |
| 352 | } |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 353 | /* |
| 354 | * Make sure we record at least the request and response queue zero in |
| 355 | * case we need to free them if part of the probe fails. |
| 356 | */ |
| 357 | ha->rsp_q_map[0] = rsp; |
| 358 | ha->req_q_map[0] = req; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 359 | set_bit(0, ha->rsp_qid_map); |
| 360 | set_bit(0, ha->req_qid_map); |
| 361 | return 1; |
| 362 | |
| 363 | fail_rsp_map: |
| 364 | kfree(ha->req_q_map); |
| 365 | ha->req_q_map = NULL; |
| 366 | fail_req_map: |
| 367 | return -ENOMEM; |
| 368 | } |
| 369 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 370 | 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] | 371 | { |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 372 | if (IS_QLAFX00(ha)) { |
| 373 | if (req && req->ring_fx00) |
| 374 | dma_free_coherent(&ha->pdev->dev, |
| 375 | (req->length_fx00 + 1) * sizeof(request_t), |
| 376 | req->ring_fx00, req->dma_fx00); |
| 377 | } else if (req && req->ring) |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 378 | dma_free_coherent(&ha->pdev->dev, |
| 379 | (req->length + 1) * sizeof(request_t), |
| 380 | req->ring, req->dma); |
| 381 | |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 382 | if (req) |
| 383 | kfree(req->outstanding_cmds); |
| 384 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 385 | kfree(req); |
| 386 | req = NULL; |
| 387 | } |
| 388 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 389 | static void qla2x00_free_rsp_que(struct qla_hw_data *ha, struct rsp_que *rsp) |
| 390 | { |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 391 | if (IS_QLAFX00(ha)) { |
| 392 | if (rsp && rsp->ring) |
| 393 | dma_free_coherent(&ha->pdev->dev, |
| 394 | (rsp->length_fx00 + 1) * sizeof(request_t), |
| 395 | rsp->ring_fx00, rsp->dma_fx00); |
| 396 | } else if (rsp && rsp->ring) { |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 397 | dma_free_coherent(&ha->pdev->dev, |
| 398 | (rsp->length + 1) * sizeof(response_t), |
| 399 | rsp->ring, rsp->dma); |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 400 | } |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 401 | kfree(rsp); |
| 402 | rsp = NULL; |
| 403 | } |
| 404 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 405 | static void qla2x00_free_queues(struct qla_hw_data *ha) |
| 406 | { |
| 407 | struct req_que *req; |
| 408 | struct rsp_que *rsp; |
| 409 | int cnt; |
| 410 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 411 | for (cnt = 0; cnt < ha->max_req_queues; cnt++) { |
Quinn Tran | cb43285 | 2016-02-04 11:45:16 -0500 | [diff] [blame] | 412 | if (!test_bit(cnt, ha->req_qid_map)) |
| 413 | continue; |
| 414 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 415 | req = ha->req_q_map[cnt]; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 416 | qla2x00_free_req_que(ha, req); |
| 417 | } |
| 418 | kfree(ha->req_q_map); |
| 419 | ha->req_q_map = NULL; |
| 420 | |
| 421 | for (cnt = 0; cnt < ha->max_rsp_queues; cnt++) { |
Quinn Tran | cb43285 | 2016-02-04 11:45:16 -0500 | [diff] [blame] | 422 | if (!test_bit(cnt, ha->rsp_qid_map)) |
| 423 | continue; |
| 424 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 425 | rsp = ha->rsp_q_map[cnt]; |
| 426 | qla2x00_free_rsp_que(ha, rsp); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 427 | } |
| 428 | kfree(ha->rsp_q_map); |
| 429 | ha->rsp_q_map = NULL; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 430 | } |
| 431 | |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 432 | static int qla25xx_setup_mode(struct scsi_qla_host *vha) |
| 433 | { |
| 434 | uint16_t options = 0; |
| 435 | int ques, req, ret; |
| 436 | struct qla_hw_data *ha = vha->hw; |
| 437 | |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 438 | if (!(ha->fw_attributes & BIT_6)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 439 | ql_log(ql_log_warn, vha, 0x00d8, |
| 440 | "Firmware is not multi-queue capable.\n"); |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 441 | goto fail; |
| 442 | } |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 443 | if (ql2xmultique_tag) { |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 444 | /* create a request queue for IO */ |
| 445 | options |= BIT_7; |
| 446 | req = qla25xx_create_req_que(ha, options, 0, 0, -1, |
| 447 | QLA_DEFAULT_QUE_QOS); |
| 448 | if (!req) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 449 | ql_log(ql_log_warn, vha, 0x00e0, |
| 450 | "Failed to create request queue.\n"); |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 451 | goto fail; |
| 452 | } |
Tejun Heo | 278274d | 2011-02-01 11:42:42 +0100 | [diff] [blame] | 453 | ha->wq = alloc_workqueue("qla2xxx_wq", WQ_MEM_RECLAIM, 1); |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 454 | vha->req = ha->req_q_map[req]; |
| 455 | options |= BIT_1; |
| 456 | for (ques = 1; ques < ha->max_rsp_queues; ques++) { |
| 457 | ret = qla25xx_create_rsp_que(ha, options, 0, 0, req); |
| 458 | if (!ret) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 459 | ql_log(ql_log_warn, vha, 0x00e8, |
| 460 | "Failed to create response queue.\n"); |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 461 | goto fail2; |
| 462 | } |
| 463 | } |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 464 | ha->flags.cpu_affinity_enabled = 1; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 465 | ql_dbg(ql_dbg_multiq, vha, 0xc007, |
Yannick Guerrini | 6ef68da | 2015-02-23 23:26:50 +0100 | [diff] [blame] | 466 | "CPU affinity mode enabled, " |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 467 | "no. of response queues:%d no. of request queues:%d.\n", |
| 468 | ha->max_rsp_queues, ha->max_req_queues); |
| 469 | ql_dbg(ql_dbg_init, vha, 0x00e9, |
Yannick Guerrini | 6ef68da | 2015-02-23 23:26:50 +0100 | [diff] [blame] | 470 | "CPU affinity mode enabled, " |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 471 | "no. of response queues:%d no. of request queues:%d.\n", |
| 472 | ha->max_rsp_queues, ha->max_req_queues); |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 473 | } |
| 474 | return 0; |
| 475 | fail2: |
| 476 | qla25xx_delete_queues(vha); |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 477 | destroy_workqueue(ha->wq); |
| 478 | ha->wq = NULL; |
Giridhar Malavali | 0cd33fc | 2011-11-18 09:02:12 -0800 | [diff] [blame] | 479 | vha->req = ha->req_q_map[0]; |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 480 | fail: |
| 481 | ha->mqenable = 0; |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 482 | kfree(ha->req_q_map); |
| 483 | kfree(ha->rsp_q_map); |
| 484 | ha->max_req_queues = ha->max_rsp_queues = 1; |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 485 | return 1; |
| 486 | } |
| 487 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 488 | static char * |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 489 | qla2x00_pci_info_str(struct scsi_qla_host *vha, char *str) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 490 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 491 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 492 | static char *pci_bus_modes[] = { |
| 493 | "33", "66", "100", "133", |
| 494 | }; |
| 495 | uint16_t pci_bus; |
| 496 | |
| 497 | strcpy(str, "PCI"); |
| 498 | pci_bus = (ha->pci_attr & (BIT_9 | BIT_10)) >> 9; |
| 499 | if (pci_bus) { |
| 500 | strcat(str, "-X ("); |
| 501 | strcat(str, pci_bus_modes[pci_bus]); |
| 502 | } else { |
| 503 | pci_bus = (ha->pci_attr & BIT_8) >> 8; |
| 504 | strcat(str, " ("); |
| 505 | strcat(str, pci_bus_modes[pci_bus]); |
| 506 | } |
| 507 | strcat(str, " MHz)"); |
| 508 | |
| 509 | return (str); |
| 510 | } |
| 511 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 512 | static char * |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 513 | qla24xx_pci_info_str(struct scsi_qla_host *vha, char *str) |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 514 | { |
| 515 | static char *pci_bus_modes[] = { "33", "66", "100", "133", }; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 516 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 517 | uint32_t pci_bus; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 518 | |
Bjorn Helgaas | 62a276f | 2013-09-06 11:26:24 -0600 | [diff] [blame] | 519 | if (pci_is_pcie(ha->pdev)) { |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 520 | char lwstr[6]; |
Bjorn Helgaas | 62a276f | 2013-09-06 11:26:24 -0600 | [diff] [blame] | 521 | uint32_t lstat, lspeed, lwidth; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 522 | |
Bjorn Helgaas | 62a276f | 2013-09-06 11:26:24 -0600 | [diff] [blame] | 523 | pcie_capability_read_dword(ha->pdev, PCI_EXP_LNKCAP, &lstat); |
| 524 | lspeed = lstat & PCI_EXP_LNKCAP_SLS; |
| 525 | lwidth = (lstat & PCI_EXP_LNKCAP_MLW) >> 4; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 526 | |
| 527 | strcpy(str, "PCIe ("); |
Saurav Kashyap | 49300af | 2012-11-21 02:40:34 -0500 | [diff] [blame] | 528 | switch (lspeed) { |
| 529 | case 1: |
Andrew Vasquez | c87a0d8 | 2008-04-03 13:13:21 -0700 | [diff] [blame] | 530 | strcat(str, "2.5GT/s "); |
Saurav Kashyap | 49300af | 2012-11-21 02:40:34 -0500 | [diff] [blame] | 531 | break; |
| 532 | case 2: |
Andrew Vasquez | c87a0d8 | 2008-04-03 13:13:21 -0700 | [diff] [blame] | 533 | strcat(str, "5.0GT/s "); |
Saurav Kashyap | 49300af | 2012-11-21 02:40:34 -0500 | [diff] [blame] | 534 | break; |
| 535 | case 3: |
| 536 | strcat(str, "8.0GT/s "); |
| 537 | break; |
| 538 | default: |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 539 | strcat(str, "<unknown> "); |
Saurav Kashyap | 49300af | 2012-11-21 02:40:34 -0500 | [diff] [blame] | 540 | break; |
| 541 | } |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 542 | snprintf(lwstr, sizeof(lwstr), "x%d)", lwidth); |
| 543 | strcat(str, lwstr); |
| 544 | |
| 545 | return str; |
| 546 | } |
| 547 | |
| 548 | strcpy(str, "PCI"); |
| 549 | pci_bus = (ha->pci_attr & CSRX_PCIX_BUS_MODE_MASK) >> 8; |
| 550 | if (pci_bus == 0 || pci_bus == 8) { |
| 551 | strcat(str, " ("); |
| 552 | strcat(str, pci_bus_modes[pci_bus >> 3]); |
| 553 | } else { |
| 554 | strcat(str, "-X "); |
| 555 | if (pci_bus & BIT_2) |
| 556 | strcat(str, "Mode 2"); |
| 557 | else |
| 558 | strcat(str, "Mode 1"); |
| 559 | strcat(str, " ("); |
| 560 | strcat(str, pci_bus_modes[pci_bus & ~BIT_2]); |
| 561 | } |
| 562 | strcat(str, " MHz)"); |
| 563 | |
| 564 | return str; |
| 565 | } |
| 566 | |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 567 | static char * |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 568 | 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] | 569 | { |
| 570 | char un_str[10]; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 571 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 572 | |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 573 | snprintf(str, size, "%d.%02d.%02d ", ha->fw_major_version, |
| 574 | ha->fw_minor_version, ha->fw_subminor_version); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 575 | |
| 576 | if (ha->fw_attributes & BIT_9) { |
| 577 | strcat(str, "FLX"); |
| 578 | return (str); |
| 579 | } |
| 580 | |
| 581 | switch (ha->fw_attributes & 0xFF) { |
| 582 | case 0x7: |
| 583 | strcat(str, "EF"); |
| 584 | break; |
| 585 | case 0x17: |
| 586 | strcat(str, "TP"); |
| 587 | break; |
| 588 | case 0x37: |
| 589 | strcat(str, "IP"); |
| 590 | break; |
| 591 | case 0x77: |
| 592 | strcat(str, "VI"); |
| 593 | break; |
| 594 | default: |
| 595 | sprintf(un_str, "(%x)", ha->fw_attributes); |
| 596 | strcat(str, un_str); |
| 597 | break; |
| 598 | } |
| 599 | if (ha->fw_attributes & 0x100) |
| 600 | strcat(str, "X"); |
| 601 | |
| 602 | return (str); |
| 603 | } |
| 604 | |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 605 | static char * |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 606 | 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] | 607 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 608 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | f0883ac | 2005-07-08 17:58:43 -0700 | [diff] [blame] | 609 | |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 610 | snprintf(str, size, "%d.%02d.%02d (%x)", ha->fw_major_version, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 611 | ha->fw_minor_version, ha->fw_subminor_version, ha->fw_attributes); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 612 | return str; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 613 | } |
| 614 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 615 | void |
| 616 | qla2x00_sp_free_dma(void *vha, void *ptr) |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 617 | { |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 618 | srb_t *sp = (srb_t *)ptr; |
| 619 | struct scsi_cmnd *cmd = GET_CMD_SP(sp); |
| 620 | struct qla_hw_data *ha = sp->fcport->vha->hw; |
| 621 | void *ctx = GET_CMD_CTX_SP(sp); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 622 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 623 | if (sp->flags & SRB_DMA_VALID) { |
| 624 | scsi_dma_unmap(cmd); |
| 625 | sp->flags &= ~SRB_DMA_VALID; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 626 | } |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 627 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 628 | if (sp->flags & SRB_CRC_PROT_DMA_VALID) { |
| 629 | dma_unmap_sg(&ha->pdev->dev, scsi_prot_sglist(cmd), |
| 630 | scsi_prot_sg_count(cmd), cmd->sc_data_direction); |
| 631 | sp->flags &= ~SRB_CRC_PROT_DMA_VALID; |
| 632 | } |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 633 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 634 | if (sp->flags & SRB_CRC_CTX_DSD_VALID) { |
| 635 | /* List assured to be having elements */ |
Quinn Tran | f83adb6 | 2014-04-11 16:54:43 -0400 | [diff] [blame] | 636 | qla2x00_clean_dsd_pool(ha, sp, NULL); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 637 | sp->flags &= ~SRB_CRC_CTX_DSD_VALID; |
| 638 | } |
| 639 | |
| 640 | if (sp->flags & SRB_CRC_CTX_DMA_VALID) { |
| 641 | dma_pool_free(ha->dl_dma_pool, ctx, |
| 642 | ((struct crc_context *)ctx)->crc_ctx_dma); |
| 643 | sp->flags &= ~SRB_CRC_CTX_DMA_VALID; |
| 644 | } |
| 645 | |
| 646 | if (sp->flags & SRB_FCP_CMND_DMA_VALID) { |
| 647 | struct ct6_dsd *ctx1 = (struct ct6_dsd *)ctx; |
| 648 | |
| 649 | dma_pool_free(ha->fcp_cmnd_dma_pool, ctx1->fcp_cmnd, |
| 650 | ctx1->fcp_cmnd_dma); |
| 651 | list_splice(&ctx1->dsd_list, &ha->gbl_dsd_list); |
| 652 | ha->gbl_dsd_inuse -= ctx1->dsd_use_cnt; |
| 653 | ha->gbl_dsd_avail += ctx1->dsd_use_cnt; |
| 654 | mempool_free(ctx1, ha->ctx_mempool); |
| 655 | ctx1 = NULL; |
| 656 | } |
| 657 | |
| 658 | CMD_SP(cmd) = NULL; |
Chad Dupuis | b00ee7d | 2013-02-08 01:57:50 -0500 | [diff] [blame] | 659 | qla2x00_rel_sp(sp->fcport->vha, sp); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 660 | } |
| 661 | |
Fengguang Wu | 14b0680 | 2013-04-25 01:29:19 -0400 | [diff] [blame] | 662 | static void |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 663 | qla2x00_sp_compl(void *data, void *ptr, int res) |
| 664 | { |
| 665 | struct qla_hw_data *ha = (struct qla_hw_data *)data; |
| 666 | srb_t *sp = (srb_t *)ptr; |
| 667 | struct scsi_cmnd *cmd = GET_CMD_SP(sp); |
| 668 | |
| 669 | cmd->result = res; |
| 670 | |
| 671 | if (atomic_read(&sp->ref_count) == 0) { |
| 672 | ql_dbg(ql_dbg_io, sp->fcport->vha, 0x3015, |
| 673 | "SP reference-count to ZERO -- sp=%p cmd=%p.\n", |
| 674 | sp, GET_CMD_SP(sp)); |
| 675 | if (ql2xextended_error_logging & ql_dbg_io) |
Hiral Patel | 8fbdac8 | 2015-08-04 13:37:56 -0400 | [diff] [blame] | 676 | WARN_ON(atomic_read(&sp->ref_count) == 0); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 677 | return; |
| 678 | } |
| 679 | if (!atomic_dec_and_test(&sp->ref_count)) |
| 680 | return; |
| 681 | |
| 682 | qla2x00_sp_free_dma(ha, sp); |
| 683 | cmd->scsi_done(cmd); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 684 | } |
| 685 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 686 | /* If we are SP1 here, we need to still take and release the host_lock as SP1 |
| 687 | * does not have the changes necessary to avoid taking host->host_lock. |
| 688 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 689 | static int |
Madhuranath Iyengar | f5e3e40 | 2011-02-23 15:27:06 -0800 | [diff] [blame] | 690 | qla2xxx_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 691 | { |
Madhuranath Iyengar | 134ae07 | 2011-05-10 11:30:08 -0700 | [diff] [blame] | 692 | scsi_qla_host_t *vha = shost_priv(host); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 693 | fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 694 | struct fc_rport *rport = starget_to_rport(scsi_target(cmd->device)); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 695 | struct qla_hw_data *ha = vha->hw; |
| 696 | struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 697 | srb_t *sp; |
| 698 | int rval; |
| 699 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 700 | if (ha->flags.eeh_busy) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 701 | if (ha->flags.pci_channel_io_perm_failure) { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 702 | ql_dbg(ql_dbg_aer, vha, 0x9010, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 703 | "PCI Channel IO permanent failure, exiting " |
| 704 | "cmd=%p.\n", cmd); |
Seokmann Ju | b9b12f7 | 2009-03-24 09:08:18 -0700 | [diff] [blame] | 705 | cmd->result = DID_NO_CONNECT << 16; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 706 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 707 | ql_dbg(ql_dbg_aer, vha, 0x9011, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 708 | "EEH_Busy, Requeuing the cmd=%p.\n", cmd); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 709 | cmd->result = DID_REQUEUE << 16; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 710 | } |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 711 | goto qc24_fail_command; |
| 712 | } |
| 713 | |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 714 | rval = fc_remote_port_chkready(rport); |
| 715 | if (rval) { |
| 716 | cmd->result = rval; |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 717 | ql_dbg(ql_dbg_io + ql_dbg_verbose, vha, 0x3003, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 718 | "fc_remote_port_chkready failed for cmd=%p, rval=0x%x.\n", |
| 719 | cmd, rval); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 720 | goto qc24_fail_command; |
| 721 | } |
| 722 | |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 723 | if (!vha->flags.difdix_supported && |
| 724 | scsi_get_prot_op(cmd) != SCSI_PROT_NORMAL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 725 | ql_dbg(ql_dbg_io, vha, 0x3004, |
| 726 | "DIF Cap not reg, fail DIF capable cmd's:%p.\n", |
| 727 | cmd); |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 728 | cmd->result = DID_NO_CONNECT << 16; |
| 729 | goto qc24_fail_command; |
| 730 | } |
Chad Dupuis | aa651be | 2012-02-09 11:14:04 -0800 | [diff] [blame] | 731 | |
| 732 | if (!fcport) { |
| 733 | cmd->result = DID_NO_CONNECT << 16; |
| 734 | goto qc24_fail_command; |
| 735 | } |
| 736 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 737 | if (atomic_read(&fcport->state) != FCS_ONLINE) { |
| 738 | if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD || |
Giridhar Malavali | 38170fa | 2010-10-15 11:27:49 -0700 | [diff] [blame] | 739 | atomic_read(&base_vha->loop_state) == LOOP_DEAD) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 740 | ql_dbg(ql_dbg_io, vha, 0x3005, |
| 741 | "Returning DNC, fcport_state=%d loop_state=%d.\n", |
| 742 | atomic_read(&fcport->state), |
| 743 | atomic_read(&base_vha->loop_state)); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 744 | cmd->result = DID_NO_CONNECT << 16; |
| 745 | goto qc24_fail_command; |
| 746 | } |
Mike Christie | 7b59413 | 2008-08-17 15:24:40 -0500 | [diff] [blame] | 747 | goto qc24_target_busy; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 748 | } |
| 749 | |
Chad Dupuis | e05fe29 | 2014-09-25 05:16:59 -0400 | [diff] [blame] | 750 | /* |
| 751 | * Return target busy if we've received a non-zero retry_delay_timer |
| 752 | * in a FCP_RSP. |
| 753 | */ |
Bruno Prémont | 975f7d4 | 2014-12-19 10:29:16 +0100 | [diff] [blame] | 754 | if (fcport->retry_delay_timestamp == 0) { |
| 755 | /* retry delay not set */ |
| 756 | } else if (time_after(jiffies, fcport->retry_delay_timestamp)) |
Chad Dupuis | e05fe29 | 2014-09-25 05:16:59 -0400 | [diff] [blame] | 757 | fcport->retry_delay_timestamp = 0; |
| 758 | else |
| 759 | goto qc24_target_busy; |
| 760 | |
Chad Dupuis | b00ee7d | 2013-02-08 01:57:50 -0500 | [diff] [blame] | 761 | sp = qla2x00_get_sp(vha, fcport, GFP_ATOMIC); |
Chad Dupuis | 50280c0 | 2013-10-30 03:38:14 -0400 | [diff] [blame] | 762 | if (!sp) |
Madhuranath Iyengar | f5e3e40 | 2011-02-23 15:27:06 -0800 | [diff] [blame] | 763 | goto qc24_host_busy; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 764 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 765 | sp->u.scmd.cmd = cmd; |
| 766 | sp->type = SRB_SCSI_CMD; |
| 767 | atomic_set(&sp->ref_count, 1); |
| 768 | CMD_SP(cmd) = (void *)sp; |
| 769 | sp->free = qla2x00_sp_free_dma; |
| 770 | sp->done = qla2x00_sp_compl; |
| 771 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 772 | rval = ha->isp_ops->start_scsi(sp); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 773 | if (rval != QLA_SUCCESS) { |
Chad Dupuis | 53016ed | 2012-11-21 02:40:32 -0500 | [diff] [blame] | 774 | ql_dbg(ql_dbg_io + ql_dbg_verbose, vha, 0x3013, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 775 | "Start scsi failed rval=%d for cmd=%p.\n", rval, cmd); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 776 | goto qc24_host_busy_free_sp; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 777 | } |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 778 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 779 | return 0; |
| 780 | |
| 781 | qc24_host_busy_free_sp: |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 782 | qla2x00_sp_free_dma(ha, sp); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 783 | |
Madhuranath Iyengar | f5e3e40 | 2011-02-23 15:27:06 -0800 | [diff] [blame] | 784 | qc24_host_busy: |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 785 | return SCSI_MLQUEUE_HOST_BUSY; |
| 786 | |
Mike Christie | 7b59413 | 2008-08-17 15:24:40 -0500 | [diff] [blame] | 787 | qc24_target_busy: |
| 788 | return SCSI_MLQUEUE_TARGET_BUSY; |
| 789 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 790 | qc24_fail_command: |
Madhuranath Iyengar | f5e3e40 | 2011-02-23 15:27:06 -0800 | [diff] [blame] | 791 | cmd->scsi_done(cmd); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 792 | |
| 793 | return 0; |
| 794 | } |
| 795 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 796 | /* |
| 797 | * qla2x00_eh_wait_on_command |
| 798 | * Waits for the command to be returned by the Firmware for some |
| 799 | * max time. |
| 800 | * |
| 801 | * Input: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 802 | * cmd = Scsi Command to wait on. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 803 | * |
| 804 | * Return: |
| 805 | * Not Found : 0 |
| 806 | * Found : 1 |
| 807 | */ |
| 808 | static int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 809 | qla2x00_eh_wait_on_command(struct scsi_cmnd *cmd) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 810 | { |
Andrew Vasquez | fe74c71 | 2005-08-26 19:10:10 -0700 | [diff] [blame] | 811 | #define ABORT_POLLING_PERIOD 1000 |
Chad Dupuis | 478c3b0 | 2014-04-11 16:54:35 -0400 | [diff] [blame] | 812 | #define ABORT_WAIT_ITER ((2 * 1000) / (ABORT_POLLING_PERIOD)) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 813 | unsigned long wait_iter = ABORT_WAIT_ITER; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 814 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| 815 | struct qla_hw_data *ha = vha->hw; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 816 | int ret = QLA_SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 817 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 818 | if (unlikely(pci_channel_offline(ha->pdev)) || ha->flags.eeh_busy) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 819 | ql_dbg(ql_dbg_taskm, vha, 0x8005, |
| 820 | "Return:eh_wait.\n"); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 821 | return ret; |
| 822 | } |
| 823 | |
Lalit Chandivade | d970432 | 2009-08-25 11:36:18 -0700 | [diff] [blame] | 824 | while (CMD_SP(cmd) && wait_iter--) { |
Andrew Vasquez | fe74c71 | 2005-08-26 19:10:10 -0700 | [diff] [blame] | 825 | msleep(ABORT_POLLING_PERIOD); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 826 | } |
| 827 | if (CMD_SP(cmd)) |
| 828 | ret = QLA_FUNCTION_FAILED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 829 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 830 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 831 | } |
| 832 | |
| 833 | /* |
| 834 | * qla2x00_wait_for_hba_online |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 835 | * Wait till the HBA is online after going through |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 836 | * <= MAX_RETRIES_OF_ISP_ABORT or |
| 837 | * finally HBA is disabled ie marked offline |
| 838 | * |
| 839 | * Input: |
| 840 | * ha - pointer to host adapter structure |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 841 | * |
| 842 | * Note: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 843 | * Does context switching-Release SPIN_LOCK |
| 844 | * (if any) before calling this routine. |
| 845 | * |
| 846 | * Return: |
| 847 | * Success (Adapter is online) : 0 |
| 848 | * Failed (Adapter is offline/disabled) : 1 |
| 849 | */ |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 850 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 851 | qla2x00_wait_for_hba_online(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 852 | { |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 853 | int return_status; |
| 854 | unsigned long wait_online; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 855 | struct qla_hw_data *ha = vha->hw; |
| 856 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 857 | |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 858 | wait_online = jiffies + (MAX_LOOP_TIMEOUT * HZ); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 859 | while (((test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags)) || |
| 860 | test_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags) || |
| 861 | test_bit(ISP_ABORT_RETRY, &base_vha->dpc_flags) || |
| 862 | ha->dpc_active) && time_before(jiffies, wait_online)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 863 | |
| 864 | msleep(1000); |
| 865 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 866 | if (base_vha->flags.online) |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 867 | return_status = QLA_SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 868 | else |
| 869 | return_status = QLA_FUNCTION_FAILED; |
| 870 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 871 | return (return_status); |
| 872 | } |
| 873 | |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 874 | /* |
Sawan Chandak | 638a1a0 | 2014-04-11 16:54:38 -0400 | [diff] [blame] | 875 | * qla2x00_wait_for_hba_ready |
| 876 | * Wait till the HBA is ready before doing driver unload |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 877 | * |
| 878 | * Input: |
| 879 | * ha - pointer to host adapter structure |
| 880 | * |
| 881 | * Note: |
| 882 | * Does context switching-Release SPIN_LOCK |
| 883 | * (if any) before calling this routine. |
| 884 | * |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 885 | */ |
Sawan Chandak | 638a1a0 | 2014-04-11 16:54:38 -0400 | [diff] [blame] | 886 | static void |
| 887 | qla2x00_wait_for_hba_ready(scsi_qla_host_t *vha) |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 888 | { |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 889 | struct qla_hw_data *ha = vha->hw; |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 890 | |
Sawan Chandak | 9d35894d | 2014-09-25 05:16:52 -0400 | [diff] [blame] | 891 | while (((qla2x00_reset_active(vha)) || ha->dpc_active || |
| 892 | ha->flags.mbox_busy) || |
| 893 | test_bit(FX00_RESET_RECOVERY, &vha->dpc_flags) || |
| 894 | test_bit(FX00_TARGET_SCAN, &vha->dpc_flags)) |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 895 | msleep(1000); |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 896 | } |
| 897 | |
Lalit Chandivade | 2533cf6 | 2009-03-24 09:08:07 -0700 | [diff] [blame] | 898 | int |
| 899 | qla2x00_wait_for_chip_reset(scsi_qla_host_t *vha) |
| 900 | { |
| 901 | int return_status; |
| 902 | unsigned long wait_reset; |
| 903 | struct qla_hw_data *ha = vha->hw; |
| 904 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 905 | |
| 906 | wait_reset = jiffies + (MAX_LOOP_TIMEOUT * HZ); |
| 907 | while (((test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags)) || |
| 908 | test_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags) || |
| 909 | test_bit(ISP_ABORT_RETRY, &base_vha->dpc_flags) || |
| 910 | ha->dpc_active) && time_before(jiffies, wait_reset)) { |
| 911 | |
| 912 | msleep(1000); |
| 913 | |
| 914 | if (!test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags) && |
| 915 | ha->flags.chip_reset_done) |
| 916 | break; |
| 917 | } |
| 918 | if (ha->flags.chip_reset_done) |
| 919 | return_status = QLA_SUCCESS; |
| 920 | else |
| 921 | return_status = QLA_FUNCTION_FAILED; |
| 922 | |
| 923 | return return_status; |
| 924 | } |
| 925 | |
Giridhar Malavali | 083a469 | 2010-05-28 15:08:18 -0700 | [diff] [blame] | 926 | static void |
| 927 | sp_get(struct srb *sp) |
| 928 | { |
| 929 | atomic_inc(&sp->ref_count); |
| 930 | } |
| 931 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 932 | /************************************************************************** |
| 933 | * qla2xxx_eh_abort |
| 934 | * |
| 935 | * Description: |
| 936 | * The abort function will abort the specified command. |
| 937 | * |
| 938 | * Input: |
| 939 | * cmd = Linux SCSI command packet to be aborted. |
| 940 | * |
| 941 | * Returns: |
| 942 | * Either SUCCESS or FAILED. |
| 943 | * |
| 944 | * Note: |
Michael Reed | 2ea0020 | 2006-04-27 16:25:30 -0700 | [diff] [blame] | 945 | * Only return FAILED if command not returned by firmware. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 946 | **************************************************************************/ |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 947 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 948 | qla2xxx_eh_abort(struct scsi_cmnd *cmd) |
| 949 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 950 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 951 | srb_t *sp; |
Andrew Vasquez | 4e98d3b | 2011-02-23 15:27:17 -0800 | [diff] [blame] | 952 | int ret; |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 953 | unsigned int id; |
| 954 | uint64_t lun; |
Andrew Vasquez | 18e144d | 2005-05-27 15:04:47 -0700 | [diff] [blame] | 955 | unsigned long flags; |
Chad Dupuis | f934c9d | 2014-04-11 16:54:31 -0400 | [diff] [blame] | 956 | int rval, wait = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 957 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 958 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 959 | if (!CMD_SP(cmd)) |
Michael Reed | 2ea0020 | 2006-04-27 16:25:30 -0700 | [diff] [blame] | 960 | return SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 961 | |
Andrew Vasquez | 4e98d3b | 2011-02-23 15:27:17 -0800 | [diff] [blame] | 962 | ret = fc_block_scsi_eh(cmd); |
| 963 | if (ret != 0) |
| 964 | return ret; |
| 965 | ret = SUCCESS; |
| 966 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 967 | id = cmd->device->id; |
| 968 | lun = cmd->device->lun; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 969 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 970 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 971 | sp = (srb_t *) CMD_SP(cmd); |
| 972 | if (!sp) { |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 973 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 974 | return SUCCESS; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 975 | } |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 976 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 977 | ql_dbg(ql_dbg_taskm, vha, 0x8002, |
Chad Dupuis | c7bc4ca | 2015-08-04 13:37:57 -0400 | [diff] [blame] | 978 | "Aborting from RISC nexus=%ld:%d:%llu sp=%p cmd=%p handle=%x\n", |
| 979 | vha->host_no, id, lun, sp, cmd, sp->handle); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 980 | |
| 981 | /* Get a reference to the sp and drop the lock.*/ |
| 982 | sp_get(sp); |
| 983 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 984 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Chad Dupuis | f934c9d | 2014-04-11 16:54:31 -0400 | [diff] [blame] | 985 | rval = ha->isp_ops->abort_command(sp); |
| 986 | if (rval) { |
Chad Dupuis | 9621942 | 2015-08-04 13:38:00 -0400 | [diff] [blame] | 987 | if (rval == QLA_FUNCTION_PARAMETER_ERROR) |
Chad Dupuis | f934c9d | 2014-04-11 16:54:31 -0400 | [diff] [blame] | 988 | ret = SUCCESS; |
Chad Dupuis | 9621942 | 2015-08-04 13:38:00 -0400 | [diff] [blame] | 989 | else |
Chad Dupuis | f934c9d | 2014-04-11 16:54:31 -0400 | [diff] [blame] | 990 | ret = FAILED; |
| 991 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 992 | ql_dbg(ql_dbg_taskm, vha, 0x8003, |
Chad Dupuis | f934c9d | 2014-04-11 16:54:31 -0400 | [diff] [blame] | 993 | "Abort command mbx failed cmd=%p, rval=%x.\n", cmd, rval); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 994 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 995 | ql_dbg(ql_dbg_taskm, vha, 0x8004, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 996 | "Abort command mbx success cmd=%p.\n", cmd); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 997 | wait = 1; |
| 998 | } |
Saurav Kashyap | 7594206 | 2011-08-16 11:29:25 -0700 | [diff] [blame] | 999 | |
| 1000 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1001 | sp->done(ha, sp, 0); |
Saurav Kashyap | 7594206 | 2011-08-16 11:29:25 -0700 | [diff] [blame] | 1002 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1003 | |
Chad Dupuis | bc91ade | 2011-08-16 11:29:26 -0700 | [diff] [blame] | 1004 | /* Did the command return during mailbox execution? */ |
| 1005 | if (ret == FAILED && !CMD_SP(cmd)) |
| 1006 | ret = SUCCESS; |
| 1007 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1008 | /* Wait for the command to be returned. */ |
Michael Reed | 2ea0020 | 2006-04-27 16:25:30 -0700 | [diff] [blame] | 1009 | if (wait) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1010 | if (qla2x00_eh_wait_on_command(cmd) != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1011 | ql_log(ql_log_warn, vha, 0x8006, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1012 | "Abort handler timed out cmd=%p.\n", cmd); |
Michael Reed | 2ea0020 | 2006-04-27 16:25:30 -0700 | [diff] [blame] | 1013 | ret = FAILED; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1014 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1015 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1016 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1017 | ql_log(ql_log_info, vha, 0x801c, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1018 | "Abort command issued nexus=%ld:%d:%llu -- %d %x.\n", |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1019 | vha->host_no, id, lun, wait, ret); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1020 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1021 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1022 | } |
| 1023 | |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1024 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1025 | 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] | 1026 | uint64_t l, enum nexus_wait_type type) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1027 | { |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1028 | int cnt, match, status; |
Andrew Vasquez | 18e144d | 2005-05-27 15:04:47 -0700 | [diff] [blame] | 1029 | unsigned long flags; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1030 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1031 | struct req_que *req; |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1032 | srb_t *sp; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1033 | struct scsi_cmnd *cmd; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1034 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1035 | status = QLA_SUCCESS; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1036 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1037 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 67c2e93 | 2009-04-06 22:33:42 -0700 | [diff] [blame] | 1038 | req = vha->req; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1039 | for (cnt = 1; status == QLA_SUCCESS && |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 1040 | cnt < req->num_outstanding_cmds; cnt++) { |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1041 | sp = req->outstanding_cmds[cnt]; |
| 1042 | if (!sp) |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1043 | continue; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1044 | if (sp->type != SRB_SCSI_CMD) |
Andrew Vasquez | cf53b06 | 2009-08-20 11:06:04 -0700 | [diff] [blame] | 1045 | continue; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1046 | if (vha->vp_idx != sp->fcport->vha->vp_idx) |
| 1047 | continue; |
| 1048 | match = 0; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1049 | cmd = GET_CMD_SP(sp); |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1050 | switch (type) { |
| 1051 | case WAIT_HOST: |
| 1052 | match = 1; |
| 1053 | break; |
| 1054 | case WAIT_TARGET: |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1055 | match = cmd->device->id == t; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1056 | break; |
| 1057 | case WAIT_LUN: |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1058 | match = (cmd->device->id == t && |
| 1059 | cmd->device->lun == l); |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1060 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1061 | } |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1062 | if (!match) |
| 1063 | continue; |
| 1064 | |
| 1065 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1066 | status = qla2x00_eh_wait_on_command(cmd); |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1067 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1068 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1069 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1070 | |
| 1071 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1072 | } |
| 1073 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1074 | static char *reset_errors[] = { |
| 1075 | "HBA not online", |
| 1076 | "HBA not ready", |
| 1077 | "Task management failed", |
| 1078 | "Waiting for command completions", |
| 1079 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1080 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1081 | static int |
| 1082 | __qla2xxx_eh_generic_reset(char *name, enum nexus_wait_type type, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1083 | 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] | 1084 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1085 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1086 | fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; |
| 1087 | int err; |
| 1088 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1089 | if (!fcport) { |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1090 | return FAILED; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1091 | } |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1092 | |
Andrew Vasquez | 4e98d3b | 2011-02-23 15:27:17 -0800 | [diff] [blame] | 1093 | err = fc_block_scsi_eh(cmd); |
| 1094 | if (err != 0) |
| 1095 | return err; |
| 1096 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1097 | ql_log(ql_log_info, vha, 0x8009, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1098 | "%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] | 1099 | cmd->device->id, cmd->device->lun, cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1100 | |
| 1101 | err = 0; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1102 | if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) { |
| 1103 | ql_log(ql_log_warn, vha, 0x800a, |
| 1104 | "Wait for hba online failed for cmd=%p.\n", cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1105 | goto eh_reset_failed; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1106 | } |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1107 | err = 2; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1108 | if (do_reset(fcport, cmd->device->lun, cmd->request->cpu + 1) |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1109 | != QLA_SUCCESS) { |
| 1110 | ql_log(ql_log_warn, vha, 0x800c, |
| 1111 | "do_reset failed for cmd=%p.\n", cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1112 | goto eh_reset_failed; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1113 | } |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1114 | err = 3; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1115 | if (qla2x00_eh_wait_for_pending_commands(vha, cmd->device->id, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1116 | cmd->device->lun, type) != QLA_SUCCESS) { |
| 1117 | ql_log(ql_log_warn, vha, 0x800d, |
Masanari Iida | d6a0358 | 2012-08-22 14:20:58 -0400 | [diff] [blame] | 1118 | "wait for pending cmds failed for cmd=%p.\n", cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1119 | goto eh_reset_failed; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1120 | } |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1121 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1122 | ql_log(ql_log_info, vha, 0x800e, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1123 | "%s RESET SUCCEEDED nexus:%ld:%d:%llu cmd=%p.\n", name, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1124 | vha->host_no, cmd->device->id, cmd->device->lun, cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1125 | |
| 1126 | return SUCCESS; |
| 1127 | |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1128 | eh_reset_failed: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1129 | ql_log(ql_log_info, vha, 0x800f, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1130 | "%s RESET FAILED: %s nexus=%ld:%d:%llu cmd=%p.\n", name, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1131 | reset_errors[err], vha->host_no, cmd->device->id, cmd->device->lun, |
| 1132 | cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1133 | return FAILED; |
| 1134 | } |
| 1135 | |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 1136 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1137 | qla2xxx_eh_device_reset(struct scsi_cmnd *cmd) |
| 1138 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1139 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| 1140 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1141 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1142 | return __qla2xxx_eh_generic_reset("DEVICE", WAIT_LUN, cmd, |
| 1143 | ha->isp_ops->lun_reset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1144 | } |
| 1145 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1146 | static int |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1147 | qla2xxx_eh_target_reset(struct scsi_cmnd *cmd) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1148 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1149 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| 1150 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1151 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1152 | return __qla2xxx_eh_generic_reset("TARGET", WAIT_TARGET, cmd, |
| 1153 | ha->isp_ops->target_reset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1154 | } |
| 1155 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1156 | /************************************************************************** |
| 1157 | * qla2xxx_eh_bus_reset |
| 1158 | * |
| 1159 | * Description: |
| 1160 | * The bus reset function will reset the bus and abort any executing |
| 1161 | * commands. |
| 1162 | * |
| 1163 | * Input: |
| 1164 | * cmd = Linux SCSI command packet of the command that cause the |
| 1165 | * bus reset. |
| 1166 | * |
| 1167 | * Returns: |
| 1168 | * SUCCESS/FAILURE (defined as macro in scsi.h). |
| 1169 | * |
| 1170 | **************************************************************************/ |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 1171 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1172 | qla2xxx_eh_bus_reset(struct scsi_cmnd *cmd) |
| 1173 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1174 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 1175 | fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1176 | int ret = FAILED; |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1177 | unsigned int id; |
| 1178 | uint64_t lun; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1179 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1180 | id = cmd->device->id; |
| 1181 | lun = cmd->device->lun; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1182 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1183 | if (!fcport) { |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1184 | return ret; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1185 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1186 | |
Andrew Vasquez | 4e98d3b | 2011-02-23 15:27:17 -0800 | [diff] [blame] | 1187 | ret = fc_block_scsi_eh(cmd); |
| 1188 | if (ret != 0) |
| 1189 | return ret; |
| 1190 | ret = FAILED; |
| 1191 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1192 | ql_log(ql_log_info, vha, 0x8012, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1193 | "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] | 1194 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1195 | if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1196 | ql_log(ql_log_fatal, vha, 0x8013, |
| 1197 | "Wait for hba online failed board disabled.\n"); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1198 | goto eh_bus_reset_done; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1199 | } |
| 1200 | |
Saurav Kashyap | ad53768 | 2011-11-18 09:02:09 -0800 | [diff] [blame] | 1201 | if (qla2x00_loop_reset(vha) == QLA_SUCCESS) |
| 1202 | ret = SUCCESS; |
| 1203 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1204 | if (ret == FAILED) |
| 1205 | goto eh_bus_reset_done; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1206 | |
Andrew Vasquez | 9a41a62 | 2005-09-20 13:25:53 -0700 | [diff] [blame] | 1207 | /* Flush outstanding commands. */ |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1208 | if (qla2x00_eh_wait_for_pending_commands(vha, 0, 0, WAIT_HOST) != |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1209 | QLA_SUCCESS) { |
| 1210 | ql_log(ql_log_warn, vha, 0x8014, |
| 1211 | "Wait for pending commands failed.\n"); |
Andrew Vasquez | 9a41a62 | 2005-09-20 13:25:53 -0700 | [diff] [blame] | 1212 | ret = FAILED; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1213 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1214 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1215 | eh_bus_reset_done: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1216 | ql_log(ql_log_warn, vha, 0x802b, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1217 | "BUS RESET %s nexus=%ld:%d:%llu.\n", |
Masanari Iida | d6a0358 | 2012-08-22 14:20:58 -0400 | [diff] [blame] | 1218 | (ret == FAILED) ? "FAILED" : "SUCCEEDED", vha->host_no, id, lun); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1219 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1220 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1221 | } |
| 1222 | |
| 1223 | /************************************************************************** |
| 1224 | * qla2xxx_eh_host_reset |
| 1225 | * |
| 1226 | * Description: |
| 1227 | * The reset function will reset the Adapter. |
| 1228 | * |
| 1229 | * Input: |
| 1230 | * cmd = Linux SCSI command packet of the command that cause the |
| 1231 | * adapter reset. |
| 1232 | * |
| 1233 | * Returns: |
| 1234 | * Either SUCCESS or FAILED. |
| 1235 | * |
| 1236 | * Note: |
| 1237 | **************************************************************************/ |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 1238 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1239 | qla2xxx_eh_host_reset(struct scsi_cmnd *cmd) |
| 1240 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1241 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1242 | struct qla_hw_data *ha = vha->hw; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1243 | int ret = FAILED; |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1244 | unsigned int id; |
| 1245 | uint64_t lun; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1246 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1247 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1248 | id = cmd->device->id; |
| 1249 | lun = cmd->device->lun; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1250 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1251 | ql_log(ql_log_info, vha, 0x8018, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1252 | "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] | 1253 | |
Chad Dupuis | 63ee707 | 2014-04-11 16:54:46 -0400 | [diff] [blame] | 1254 | /* |
| 1255 | * No point in issuing another reset if one is active. Also do not |
| 1256 | * attempt a reset if we are updating flash. |
| 1257 | */ |
| 1258 | if (qla2x00_reset_active(vha) || ha->optrom_state != QLA_SWAITING) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1259 | goto eh_host_reset_lock; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1260 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1261 | if (vha != base_vha) { |
| 1262 | if (qla2x00_vp_abort_isp(vha)) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1263 | goto eh_host_reset_lock; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1264 | } else { |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 1265 | if (IS_P3P_TYPE(vha->hw)) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1266 | if (!qla82xx_fcoe_ctx_reset(vha)) { |
| 1267 | /* Ctx reset success */ |
| 1268 | ret = SUCCESS; |
| 1269 | goto eh_host_reset_lock; |
| 1270 | } |
| 1271 | /* fall thru if ctx reset failed */ |
| 1272 | } |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 1273 | if (ha->wq) |
| 1274 | flush_workqueue(ha->wq); |
| 1275 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1276 | set_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1277 | if (ha->isp_ops->abort_isp(base_vha)) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1278 | clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
| 1279 | /* failed. schedule dpc to try */ |
| 1280 | set_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags); |
| 1281 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1282 | if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) { |
| 1283 | ql_log(ql_log_warn, vha, 0x802a, |
| 1284 | "wait for hba online failed.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1285 | goto eh_host_reset_lock; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1286 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1287 | } |
| 1288 | clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1289 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1290 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1291 | /* Waiting for command to be returned to OS.*/ |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1292 | if (qla2x00_eh_wait_for_pending_commands(vha, 0, 0, WAIT_HOST) == |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1293 | QLA_SUCCESS) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1294 | ret = SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1295 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1296 | eh_host_reset_lock: |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1297 | ql_log(ql_log_info, vha, 0x8017, |
Hannes Reinecke | 9cb78c1 | 2014-06-25 15:27:36 +0200 | [diff] [blame] | 1298 | "ADAPTER RESET %s nexus=%ld:%d:%llu.\n", |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1299 | (ret == FAILED) ? "FAILED" : "SUCCEEDED", vha->host_no, id, lun); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1300 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1301 | return ret; |
| 1302 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1303 | |
| 1304 | /* |
| 1305 | * qla2x00_loop_reset |
| 1306 | * Issue loop reset. |
| 1307 | * |
| 1308 | * Input: |
| 1309 | * ha = adapter block pointer. |
| 1310 | * |
| 1311 | * Returns: |
| 1312 | * 0 = success |
| 1313 | */ |
Andrew Vasquez | a4722cf | 2008-01-17 09:02:12 -0800 | [diff] [blame] | 1314 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1315 | qla2x00_loop_reset(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1316 | { |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 1317 | int ret; |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 1318 | struct fc_port *fcport; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1319 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1320 | |
Armen Baloyan | 5854771 | 2013-08-27 01:37:33 -0400 | [diff] [blame] | 1321 | if (IS_QLAFX00(ha)) { |
| 1322 | return qlafx00_loop_reset(vha); |
| 1323 | } |
| 1324 | |
Giridhar Malavali | f4c496c | 2010-05-04 15:01:33 -0700 | [diff] [blame] | 1325 | if (ql2xtargetreset == 1 && ha->flags.enable_target_reset) { |
Andrew Vasquez | 55e5ed2 | 2010-02-18 10:07:25 -0800 | [diff] [blame] | 1326 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
| 1327 | if (fcport->port_type != FCT_TARGET) |
| 1328 | continue; |
| 1329 | |
| 1330 | ret = ha->isp_ops->target_reset(fcport, 0, 0); |
| 1331 | if (ret != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1332 | ql_dbg(ql_dbg_taskm, vha, 0x802c, |
Armen Baloyan | 5854771 | 2013-08-27 01:37:33 -0400 | [diff] [blame] | 1333 | "Bus Reset failed: Reset=%d " |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1334 | "d_id=%x.\n", ret, fcport->d_id.b24); |
Andrew Vasquez | 55e5ed2 | 2010-02-18 10:07:25 -0800 | [diff] [blame] | 1335 | } |
| 1336 | } |
| 1337 | } |
| 1338 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 1339 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1340 | if (ha->flags.enable_lip_full_login && !IS_CNA_CAPABLE(ha)) { |
Andrew Vasquez | 0b7e7c5 | 2013-02-08 01:57:42 -0500 | [diff] [blame] | 1341 | atomic_set(&vha->loop_state, LOOP_DOWN); |
| 1342 | atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME); |
| 1343 | qla2x00_mark_all_devices_lost(vha, 0); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1344 | ret = qla2x00_full_login_lip(vha); |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 1345 | if (ret != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1346 | ql_dbg(ql_dbg_taskm, vha, 0x802d, |
| 1347 | "full_login_lip=%d.\n", ret); |
Anirban Chakraborty | 749af3d | 2008-11-14 13:48:12 -0800 | [diff] [blame] | 1348 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1349 | } |
| 1350 | |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 1351 | if (ha->flags.enable_lip_reset) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1352 | ret = qla2x00_lip_reset(vha); |
Saurav Kashyap | ad53768 | 2011-11-18 09:02:09 -0800 | [diff] [blame] | 1353 | if (ret != QLA_SUCCESS) |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1354 | ql_dbg(ql_dbg_taskm, vha, 0x802e, |
| 1355 | "lip_reset failed (%d).\n", ret); |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 1356 | } |
| 1357 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1358 | /* 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] | 1359 | vha->marker_needed = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1360 | |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 1361 | return QLA_SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1362 | } |
| 1363 | |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1364 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1365 | qla2x00_abort_all_cmds(scsi_qla_host_t *vha, int res) |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1366 | { |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1367 | int que, cnt; |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1368 | unsigned long flags; |
| 1369 | srb_t *sp; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1370 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1371 | struct req_que *req; |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1372 | |
Arun Easi | c0cb449 | 2014-09-25 06:14:51 -0400 | [diff] [blame] | 1373 | qlt_host_reset_handler(ha); |
| 1374 | |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1375 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1376 | for (que = 0; que < ha->max_req_queues; que++) { |
Anirban Chakraborty | 29bdccb | 2009-01-08 15:41:08 -0800 | [diff] [blame] | 1377 | req = ha->req_q_map[que]; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1378 | if (!req) |
| 1379 | continue; |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 1380 | if (!req->outstanding_cmds) |
| 1381 | continue; |
| 1382 | for (cnt = 1; cnt < req->num_outstanding_cmds; cnt++) { |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1383 | sp = req->outstanding_cmds[cnt]; |
Andrew Vasquez | e612d46 | 2009-03-24 09:08:04 -0700 | [diff] [blame] | 1384 | if (sp) { |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1385 | req->outstanding_cmds[cnt] = NULL; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1386 | sp->done(vha, sp, res); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1387 | } |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1388 | } |
| 1389 | } |
| 1390 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1391 | } |
| 1392 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1393 | static int |
| 1394 | qla2xxx_slave_alloc(struct scsi_device *sdev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1395 | { |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 1396 | struct fc_rport *rport = starget_to_rport(scsi_target(sdev)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1397 | |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 1398 | if (!rport || fc_remote_port_chkready(rport)) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1399 | return -ENXIO; |
| 1400 | |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 1401 | sdev->hostdata = *(fc_port_t **)rport->dd_data; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1402 | |
| 1403 | return 0; |
| 1404 | } |
| 1405 | |
| 1406 | static int |
| 1407 | qla2xxx_slave_configure(struct scsi_device *sdev) |
| 1408 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1409 | scsi_qla_host_t *vha = shost_priv(sdev->host); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1410 | struct req_que *req = vha->req; |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 1411 | |
Arun Easi | 9e522cd | 2012-08-22 14:21:31 -0400 | [diff] [blame] | 1412 | if (IS_T10_PI_CAPABLE(vha->hw)) |
| 1413 | blk_queue_update_dma_alignment(sdev->request_queue, 0x7); |
| 1414 | |
Christoph Hellwig | db5ed4d | 2014-11-13 15:08:42 +0100 | [diff] [blame] | 1415 | scsi_change_queue_depth(sdev, req->max_q_depth); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1416 | return 0; |
| 1417 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1418 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1419 | static void |
| 1420 | qla2xxx_slave_destroy(struct scsi_device *sdev) |
| 1421 | { |
| 1422 | sdev->hostdata = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1423 | } |
| 1424 | |
| 1425 | /** |
| 1426 | * qla2x00_config_dma_addressing() - Configure OS DMA addressing method. |
| 1427 | * @ha: HA context |
| 1428 | * |
| 1429 | * At exit, the @ha's flags.enable_64bit_addressing set to indicated |
| 1430 | * supported addressing method. |
| 1431 | */ |
| 1432 | static void |
Andrew Vasquez | 53303c4 | 2009-01-22 09:45:37 -0800 | [diff] [blame] | 1433 | qla2x00_config_dma_addressing(struct qla_hw_data *ha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1434 | { |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1435 | /* Assume a 32bit DMA mask. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1436 | ha->flags.enable_64bit_addressing = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1437 | |
Yang Hongyang | 6a35528 | 2009-04-06 19:01:13 -0700 | [diff] [blame] | 1438 | if (!dma_set_mask(&ha->pdev->dev, DMA_BIT_MASK(64))) { |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1439 | /* Any upper-dword bits set? */ |
| 1440 | if (MSD(dma_get_required_mask(&ha->pdev->dev)) && |
Yang Hongyang | 6a35528 | 2009-04-06 19:01:13 -0700 | [diff] [blame] | 1441 | !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) { |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1442 | /* Ok, a 64bit DMA mask is applicable. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1443 | ha->flags.enable_64bit_addressing = 1; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1444 | ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64; |
| 1445 | ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64; |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1446 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1447 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1448 | } |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1449 | |
Yang Hongyang | 284901a | 2009-04-06 19:01:15 -0700 | [diff] [blame] | 1450 | dma_set_mask(&ha->pdev->dev, DMA_BIT_MASK(32)); |
| 1451 | pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(32)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1452 | } |
| 1453 | |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1454 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1455 | qla2x00_enable_intrs(struct qla_hw_data *ha) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1456 | { |
| 1457 | unsigned long flags = 0; |
| 1458 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
| 1459 | |
| 1460 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1461 | ha->interrupts_on = 1; |
| 1462 | /* enable risc and host interrupts */ |
| 1463 | WRT_REG_WORD(®->ictrl, ICR_EN_INT | ICR_EN_RISC); |
| 1464 | RD_REG_WORD(®->ictrl); |
| 1465 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1466 | |
| 1467 | } |
| 1468 | |
| 1469 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1470 | qla2x00_disable_intrs(struct qla_hw_data *ha) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1471 | { |
| 1472 | unsigned long flags = 0; |
| 1473 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
| 1474 | |
| 1475 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1476 | ha->interrupts_on = 0; |
| 1477 | /* disable risc and host interrupts */ |
| 1478 | WRT_REG_WORD(®->ictrl, 0); |
| 1479 | RD_REG_WORD(®->ictrl); |
| 1480 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1481 | } |
| 1482 | |
| 1483 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1484 | qla24xx_enable_intrs(struct qla_hw_data *ha) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1485 | { |
| 1486 | unsigned long flags = 0; |
| 1487 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
| 1488 | |
| 1489 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1490 | ha->interrupts_on = 1; |
| 1491 | WRT_REG_DWORD(®->ictrl, ICRX_EN_RISC_INT); |
| 1492 | RD_REG_DWORD(®->ictrl); |
| 1493 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1494 | } |
| 1495 | |
| 1496 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1497 | qla24xx_disable_intrs(struct qla_hw_data *ha) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1498 | { |
| 1499 | unsigned long flags = 0; |
| 1500 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
| 1501 | |
Andrew Vasquez | 124f85e | 2009-01-05 11:18:06 -0800 | [diff] [blame] | 1502 | if (IS_NOPOLLING_TYPE(ha)) |
| 1503 | return; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1504 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1505 | ha->interrupts_on = 0; |
| 1506 | WRT_REG_DWORD(®->ictrl, 0); |
| 1507 | RD_REG_DWORD(®->ictrl); |
| 1508 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1509 | } |
| 1510 | |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1511 | static int |
| 1512 | qla2x00_iospace_config(struct qla_hw_data *ha) |
| 1513 | { |
| 1514 | resource_size_t pio; |
| 1515 | uint16_t msix; |
| 1516 | int cpus; |
| 1517 | |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1518 | if (pci_request_selected_regions(ha->pdev, ha->bars, |
| 1519 | QLA2XXX_DRIVER_NAME)) { |
| 1520 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0011, |
| 1521 | "Failed to reserve PIO/MMIO regions (%s), aborting.\n", |
| 1522 | pci_name(ha->pdev)); |
| 1523 | goto iospace_error_exit; |
| 1524 | } |
| 1525 | if (!(ha->bars & 1)) |
| 1526 | goto skip_pio; |
| 1527 | |
| 1528 | /* We only need PIO for Flash operations on ISP2312 v2 chips. */ |
| 1529 | pio = pci_resource_start(ha->pdev, 0); |
| 1530 | if (pci_resource_flags(ha->pdev, 0) & IORESOURCE_IO) { |
| 1531 | if (pci_resource_len(ha->pdev, 0) < MIN_IOBASE_LEN) { |
| 1532 | ql_log_pci(ql_log_warn, ha->pdev, 0x0012, |
| 1533 | "Invalid pci I/O region size (%s).\n", |
| 1534 | pci_name(ha->pdev)); |
| 1535 | pio = 0; |
| 1536 | } |
| 1537 | } else { |
| 1538 | ql_log_pci(ql_log_warn, ha->pdev, 0x0013, |
| 1539 | "Region #0 no a PIO resource (%s).\n", |
| 1540 | pci_name(ha->pdev)); |
| 1541 | pio = 0; |
| 1542 | } |
| 1543 | ha->pio_address = pio; |
| 1544 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0014, |
| 1545 | "PIO address=%llu.\n", |
| 1546 | (unsigned long long)ha->pio_address); |
| 1547 | |
| 1548 | skip_pio: |
| 1549 | /* Use MMIO operations for all accesses. */ |
| 1550 | if (!(pci_resource_flags(ha->pdev, 1) & IORESOURCE_MEM)) { |
| 1551 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0015, |
| 1552 | "Region #1 not an MMIO resource (%s), aborting.\n", |
| 1553 | pci_name(ha->pdev)); |
| 1554 | goto iospace_error_exit; |
| 1555 | } |
| 1556 | if (pci_resource_len(ha->pdev, 1) < MIN_IOBASE_LEN) { |
| 1557 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0016, |
| 1558 | "Invalid PCI mem region size (%s), aborting.\n", |
| 1559 | pci_name(ha->pdev)); |
| 1560 | goto iospace_error_exit; |
| 1561 | } |
| 1562 | |
| 1563 | ha->iobase = ioremap(pci_resource_start(ha->pdev, 1), MIN_IOBASE_LEN); |
| 1564 | if (!ha->iobase) { |
| 1565 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0017, |
| 1566 | "Cannot remap MMIO (%s), aborting.\n", |
| 1567 | pci_name(ha->pdev)); |
| 1568 | goto iospace_error_exit; |
| 1569 | } |
| 1570 | |
| 1571 | /* Determine queue resources */ |
| 1572 | ha->max_req_queues = ha->max_rsp_queues = 1; |
| 1573 | if ((ql2xmaxqueues <= 1 && !ql2xmultique_tag) || |
| 1574 | (ql2xmaxqueues > 1 && ql2xmultique_tag) || |
| 1575 | (!IS_QLA25XX(ha) && !IS_QLA81XX(ha))) |
| 1576 | goto mqiobase_exit; |
| 1577 | |
| 1578 | ha->mqiobase = ioremap(pci_resource_start(ha->pdev, 3), |
| 1579 | pci_resource_len(ha->pdev, 3)); |
| 1580 | if (ha->mqiobase) { |
| 1581 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0018, |
| 1582 | "MQIO Base=%p.\n", ha->mqiobase); |
| 1583 | /* Read MSIX vector size of the board */ |
| 1584 | pci_read_config_word(ha->pdev, QLA_PCI_MSIX_CONTROL, &msix); |
| 1585 | ha->msix_count = msix; |
| 1586 | /* Max queues are bounded by available msix vectors */ |
| 1587 | /* queue 0 uses two msix vectors */ |
| 1588 | if (ql2xmultique_tag) { |
| 1589 | cpus = num_online_cpus(); |
| 1590 | ha->max_rsp_queues = (ha->msix_count - 1 > cpus) ? |
| 1591 | (cpus + 1) : (ha->msix_count - 1); |
| 1592 | ha->max_req_queues = 2; |
| 1593 | } else if (ql2xmaxqueues > 1) { |
| 1594 | ha->max_req_queues = ql2xmaxqueues > QLA_MQ_SIZE ? |
| 1595 | QLA_MQ_SIZE : ql2xmaxqueues; |
| 1596 | ql_dbg_pci(ql_dbg_multiq, ha->pdev, 0xc008, |
| 1597 | "QoS mode set, max no of request queues:%d.\n", |
| 1598 | ha->max_req_queues); |
| 1599 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0019, |
| 1600 | "QoS mode set, max no of request queues:%d.\n", |
| 1601 | ha->max_req_queues); |
| 1602 | } |
| 1603 | ql_log_pci(ql_log_info, ha->pdev, 0x001a, |
| 1604 | "MSI-X vector count: %d.\n", msix); |
| 1605 | } else |
| 1606 | ql_log_pci(ql_log_info, ha->pdev, 0x001b, |
| 1607 | "BAR 3 not enabled.\n"); |
| 1608 | |
| 1609 | mqiobase_exit: |
| 1610 | ha->msix_count = ha->max_rsp_queues + 1; |
| 1611 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x001c, |
| 1612 | "MSIX Count:%d.\n", ha->msix_count); |
| 1613 | return (0); |
| 1614 | |
| 1615 | iospace_error_exit: |
| 1616 | return (-ENOMEM); |
| 1617 | } |
| 1618 | |
| 1619 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1620 | static int |
| 1621 | qla83xx_iospace_config(struct qla_hw_data *ha) |
| 1622 | { |
| 1623 | uint16_t msix; |
| 1624 | int cpus; |
| 1625 | |
| 1626 | if (pci_request_selected_regions(ha->pdev, ha->bars, |
| 1627 | QLA2XXX_DRIVER_NAME)) { |
| 1628 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0117, |
| 1629 | "Failed to reserve PIO/MMIO regions (%s), aborting.\n", |
| 1630 | pci_name(ha->pdev)); |
| 1631 | |
| 1632 | goto iospace_error_exit; |
| 1633 | } |
| 1634 | |
| 1635 | /* Use MMIO operations for all accesses. */ |
| 1636 | if (!(pci_resource_flags(ha->pdev, 0) & IORESOURCE_MEM)) { |
| 1637 | ql_log_pci(ql_log_warn, ha->pdev, 0x0118, |
| 1638 | "Invalid pci I/O region size (%s).\n", |
| 1639 | pci_name(ha->pdev)); |
| 1640 | goto iospace_error_exit; |
| 1641 | } |
| 1642 | if (pci_resource_len(ha->pdev, 0) < MIN_IOBASE_LEN) { |
| 1643 | ql_log_pci(ql_log_warn, ha->pdev, 0x0119, |
| 1644 | "Invalid PCI mem region size (%s), aborting\n", |
| 1645 | pci_name(ha->pdev)); |
| 1646 | goto iospace_error_exit; |
| 1647 | } |
| 1648 | |
| 1649 | ha->iobase = ioremap(pci_resource_start(ha->pdev, 0), MIN_IOBASE_LEN); |
| 1650 | if (!ha->iobase) { |
| 1651 | ql_log_pci(ql_log_fatal, ha->pdev, 0x011a, |
| 1652 | "Cannot remap MMIO (%s), aborting.\n", |
| 1653 | pci_name(ha->pdev)); |
| 1654 | goto iospace_error_exit; |
| 1655 | } |
| 1656 | |
| 1657 | /* 64bit PCI BAR - BAR2 will correspoond to region 4 */ |
| 1658 | /* 83XX 26XX always use MQ type access for queues |
| 1659 | * - mbar 2, a.k.a region 4 */ |
| 1660 | ha->max_req_queues = ha->max_rsp_queues = 1; |
| 1661 | ha->mqiobase = ioremap(pci_resource_start(ha->pdev, 4), |
| 1662 | pci_resource_len(ha->pdev, 4)); |
| 1663 | |
| 1664 | if (!ha->mqiobase) { |
| 1665 | ql_log_pci(ql_log_fatal, ha->pdev, 0x011d, |
| 1666 | "BAR2/region4 not enabled\n"); |
| 1667 | goto mqiobase_exit; |
| 1668 | } |
| 1669 | |
| 1670 | ha->msixbase = ioremap(pci_resource_start(ha->pdev, 2), |
| 1671 | pci_resource_len(ha->pdev, 2)); |
| 1672 | if (ha->msixbase) { |
| 1673 | /* Read MSIX vector size of the board */ |
| 1674 | pci_read_config_word(ha->pdev, |
| 1675 | QLA_83XX_PCI_MSIX_CONTROL, &msix); |
| 1676 | ha->msix_count = msix; |
| 1677 | /* Max queues are bounded by available msix vectors */ |
| 1678 | /* queue 0 uses two msix vectors */ |
| 1679 | if (ql2xmultique_tag) { |
| 1680 | cpus = num_online_cpus(); |
| 1681 | ha->max_rsp_queues = (ha->msix_count - 1 > cpus) ? |
| 1682 | (cpus + 1) : (ha->msix_count - 1); |
| 1683 | ha->max_req_queues = 2; |
| 1684 | } else if (ql2xmaxqueues > 1) { |
| 1685 | ha->max_req_queues = ql2xmaxqueues > QLA_MQ_SIZE ? |
| 1686 | QLA_MQ_SIZE : ql2xmaxqueues; |
| 1687 | ql_dbg_pci(ql_dbg_multiq, ha->pdev, 0xc00c, |
| 1688 | "QoS mode set, max no of request queues:%d.\n", |
| 1689 | ha->max_req_queues); |
| 1690 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x011b, |
| 1691 | "QoS mode set, max no of request queues:%d.\n", |
| 1692 | ha->max_req_queues); |
| 1693 | } |
| 1694 | ql_log_pci(ql_log_info, ha->pdev, 0x011c, |
| 1695 | "MSI-X vector count: %d.\n", msix); |
| 1696 | } else |
| 1697 | ql_log_pci(ql_log_info, ha->pdev, 0x011e, |
| 1698 | "BAR 1 not enabled.\n"); |
| 1699 | |
| 1700 | mqiobase_exit: |
| 1701 | ha->msix_count = ha->max_rsp_queues + 1; |
Arun Easi | aa230bc | 2013-01-30 03:34:39 -0500 | [diff] [blame] | 1702 | |
| 1703 | qlt_83xx_iospace_config(ha); |
| 1704 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1705 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x011f, |
| 1706 | "MSIX Count:%d.\n", ha->msix_count); |
| 1707 | return 0; |
| 1708 | |
| 1709 | iospace_error_exit: |
| 1710 | return -ENOMEM; |
| 1711 | } |
| 1712 | |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1713 | static struct isp_operations qla2100_isp_ops = { |
| 1714 | .pci_config = qla2100_pci_config, |
| 1715 | .reset_chip = qla2x00_reset_chip, |
| 1716 | .chip_diag = qla2x00_chip_diag, |
| 1717 | .config_rings = qla2x00_config_rings, |
| 1718 | .reset_adapter = qla2x00_reset_adapter, |
| 1719 | .nvram_config = qla2x00_nvram_config, |
| 1720 | .update_fw_options = qla2x00_update_fw_options, |
| 1721 | .load_risc = qla2x00_load_risc, |
| 1722 | .pci_info_str = qla2x00_pci_info_str, |
| 1723 | .fw_version_str = qla2x00_fw_version_str, |
| 1724 | .intr_handler = qla2100_intr_handler, |
| 1725 | .enable_intrs = qla2x00_enable_intrs, |
| 1726 | .disable_intrs = qla2x00_disable_intrs, |
| 1727 | .abort_command = qla2x00_abort_command, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1728 | .target_reset = qla2x00_abort_target, |
| 1729 | .lun_reset = qla2x00_lun_reset, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1730 | .fabric_login = qla2x00_login_fabric, |
| 1731 | .fabric_logout = qla2x00_fabric_logout, |
| 1732 | .calc_req_entries = qla2x00_calc_iocbs_32, |
| 1733 | .build_iocbs = qla2x00_build_scsi_iocbs_32, |
| 1734 | .prep_ms_iocb = qla2x00_prep_ms_iocb, |
| 1735 | .prep_ms_fdmi_iocb = qla2x00_prep_ms_fdmi_iocb, |
| 1736 | .read_nvram = qla2x00_read_nvram_data, |
| 1737 | .write_nvram = qla2x00_write_nvram_data, |
| 1738 | .fw_dump = qla2100_fw_dump, |
| 1739 | .beacon_on = NULL, |
| 1740 | .beacon_off = NULL, |
| 1741 | .beacon_blink = NULL, |
| 1742 | .read_optrom = qla2x00_read_optrom_data, |
| 1743 | .write_optrom = qla2x00_write_optrom_data, |
| 1744 | .get_flash_version = qla2x00_get_flash_version, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1745 | .start_scsi = qla2x00_start_scsi, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1746 | .abort_isp = qla2x00_abort_isp, |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1747 | .iospace_config = qla2x00_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 1748 | .initialize_adapter = qla2x00_initialize_adapter, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1749 | }; |
| 1750 | |
| 1751 | static struct isp_operations qla2300_isp_ops = { |
| 1752 | .pci_config = qla2300_pci_config, |
| 1753 | .reset_chip = qla2x00_reset_chip, |
| 1754 | .chip_diag = qla2x00_chip_diag, |
| 1755 | .config_rings = qla2x00_config_rings, |
| 1756 | .reset_adapter = qla2x00_reset_adapter, |
| 1757 | .nvram_config = qla2x00_nvram_config, |
| 1758 | .update_fw_options = qla2x00_update_fw_options, |
| 1759 | .load_risc = qla2x00_load_risc, |
| 1760 | .pci_info_str = qla2x00_pci_info_str, |
| 1761 | .fw_version_str = qla2x00_fw_version_str, |
| 1762 | .intr_handler = qla2300_intr_handler, |
| 1763 | .enable_intrs = qla2x00_enable_intrs, |
| 1764 | .disable_intrs = qla2x00_disable_intrs, |
| 1765 | .abort_command = qla2x00_abort_command, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1766 | .target_reset = qla2x00_abort_target, |
| 1767 | .lun_reset = qla2x00_lun_reset, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1768 | .fabric_login = qla2x00_login_fabric, |
| 1769 | .fabric_logout = qla2x00_fabric_logout, |
| 1770 | .calc_req_entries = qla2x00_calc_iocbs_32, |
| 1771 | .build_iocbs = qla2x00_build_scsi_iocbs_32, |
| 1772 | .prep_ms_iocb = qla2x00_prep_ms_iocb, |
| 1773 | .prep_ms_fdmi_iocb = qla2x00_prep_ms_fdmi_iocb, |
| 1774 | .read_nvram = qla2x00_read_nvram_data, |
| 1775 | .write_nvram = qla2x00_write_nvram_data, |
| 1776 | .fw_dump = qla2300_fw_dump, |
| 1777 | .beacon_on = qla2x00_beacon_on, |
| 1778 | .beacon_off = qla2x00_beacon_off, |
| 1779 | .beacon_blink = qla2x00_beacon_blink, |
| 1780 | .read_optrom = qla2x00_read_optrom_data, |
| 1781 | .write_optrom = qla2x00_write_optrom_data, |
| 1782 | .get_flash_version = qla2x00_get_flash_version, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1783 | .start_scsi = qla2x00_start_scsi, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1784 | .abort_isp = qla2x00_abort_isp, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 1785 | .iospace_config = qla2x00_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 1786 | .initialize_adapter = qla2x00_initialize_adapter, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1787 | }; |
| 1788 | |
| 1789 | static struct isp_operations qla24xx_isp_ops = { |
| 1790 | .pci_config = qla24xx_pci_config, |
| 1791 | .reset_chip = qla24xx_reset_chip, |
| 1792 | .chip_diag = qla24xx_chip_diag, |
| 1793 | .config_rings = qla24xx_config_rings, |
| 1794 | .reset_adapter = qla24xx_reset_adapter, |
| 1795 | .nvram_config = qla24xx_nvram_config, |
| 1796 | .update_fw_options = qla24xx_update_fw_options, |
| 1797 | .load_risc = qla24xx_load_risc, |
| 1798 | .pci_info_str = qla24xx_pci_info_str, |
| 1799 | .fw_version_str = qla24xx_fw_version_str, |
| 1800 | .intr_handler = qla24xx_intr_handler, |
| 1801 | .enable_intrs = qla24xx_enable_intrs, |
| 1802 | .disable_intrs = qla24xx_disable_intrs, |
| 1803 | .abort_command = qla24xx_abort_command, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1804 | .target_reset = qla24xx_abort_target, |
| 1805 | .lun_reset = qla24xx_lun_reset, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1806 | .fabric_login = qla24xx_login_fabric, |
| 1807 | .fabric_logout = qla24xx_fabric_logout, |
| 1808 | .calc_req_entries = NULL, |
| 1809 | .build_iocbs = NULL, |
| 1810 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 1811 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 1812 | .read_nvram = qla24xx_read_nvram_data, |
| 1813 | .write_nvram = qla24xx_write_nvram_data, |
| 1814 | .fw_dump = qla24xx_fw_dump, |
| 1815 | .beacon_on = qla24xx_beacon_on, |
| 1816 | .beacon_off = qla24xx_beacon_off, |
| 1817 | .beacon_blink = qla24xx_beacon_blink, |
| 1818 | .read_optrom = qla24xx_read_optrom_data, |
| 1819 | .write_optrom = qla24xx_write_optrom_data, |
| 1820 | .get_flash_version = qla24xx_get_flash_version, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1821 | .start_scsi = qla24xx_start_scsi, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1822 | .abort_isp = qla2x00_abort_isp, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 1823 | .iospace_config = qla2x00_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 1824 | .initialize_adapter = qla2x00_initialize_adapter, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1825 | }; |
| 1826 | |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1827 | static struct isp_operations qla25xx_isp_ops = { |
| 1828 | .pci_config = qla25xx_pci_config, |
| 1829 | .reset_chip = qla24xx_reset_chip, |
| 1830 | .chip_diag = qla24xx_chip_diag, |
| 1831 | .config_rings = qla24xx_config_rings, |
| 1832 | .reset_adapter = qla24xx_reset_adapter, |
| 1833 | .nvram_config = qla24xx_nvram_config, |
| 1834 | .update_fw_options = qla24xx_update_fw_options, |
| 1835 | .load_risc = qla24xx_load_risc, |
| 1836 | .pci_info_str = qla24xx_pci_info_str, |
| 1837 | .fw_version_str = qla24xx_fw_version_str, |
| 1838 | .intr_handler = qla24xx_intr_handler, |
| 1839 | .enable_intrs = qla24xx_enable_intrs, |
| 1840 | .disable_intrs = qla24xx_disable_intrs, |
| 1841 | .abort_command = qla24xx_abort_command, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1842 | .target_reset = qla24xx_abort_target, |
| 1843 | .lun_reset = qla24xx_lun_reset, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1844 | .fabric_login = qla24xx_login_fabric, |
| 1845 | .fabric_logout = qla24xx_fabric_logout, |
| 1846 | .calc_req_entries = NULL, |
| 1847 | .build_iocbs = NULL, |
| 1848 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 1849 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 1850 | .read_nvram = qla25xx_read_nvram_data, |
| 1851 | .write_nvram = qla25xx_write_nvram_data, |
| 1852 | .fw_dump = qla25xx_fw_dump, |
| 1853 | .beacon_on = qla24xx_beacon_on, |
| 1854 | .beacon_off = qla24xx_beacon_off, |
| 1855 | .beacon_blink = qla24xx_beacon_blink, |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 1856 | .read_optrom = qla25xx_read_optrom_data, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1857 | .write_optrom = qla24xx_write_optrom_data, |
| 1858 | .get_flash_version = qla24xx_get_flash_version, |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 1859 | .start_scsi = qla24xx_dif_start_scsi, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1860 | .abort_isp = qla2x00_abort_isp, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 1861 | .iospace_config = qla2x00_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 1862 | .initialize_adapter = qla2x00_initialize_adapter, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1863 | }; |
| 1864 | |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 1865 | static struct isp_operations qla81xx_isp_ops = { |
| 1866 | .pci_config = qla25xx_pci_config, |
| 1867 | .reset_chip = qla24xx_reset_chip, |
| 1868 | .chip_diag = qla24xx_chip_diag, |
| 1869 | .config_rings = qla24xx_config_rings, |
| 1870 | .reset_adapter = qla24xx_reset_adapter, |
| 1871 | .nvram_config = qla81xx_nvram_config, |
| 1872 | .update_fw_options = qla81xx_update_fw_options, |
Andrew Vasquez | eaac30b | 2009-01-22 09:45:32 -0800 | [diff] [blame] | 1873 | .load_risc = qla81xx_load_risc, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 1874 | .pci_info_str = qla24xx_pci_info_str, |
| 1875 | .fw_version_str = qla24xx_fw_version_str, |
| 1876 | .intr_handler = qla24xx_intr_handler, |
| 1877 | .enable_intrs = qla24xx_enable_intrs, |
| 1878 | .disable_intrs = qla24xx_disable_intrs, |
| 1879 | .abort_command = qla24xx_abort_command, |
| 1880 | .target_reset = qla24xx_abort_target, |
| 1881 | .lun_reset = qla24xx_lun_reset, |
| 1882 | .fabric_login = qla24xx_login_fabric, |
| 1883 | .fabric_logout = qla24xx_fabric_logout, |
| 1884 | .calc_req_entries = NULL, |
| 1885 | .build_iocbs = NULL, |
| 1886 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 1887 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
Andrew Vasquez | 3d79038f | 2009-03-24 09:08:14 -0700 | [diff] [blame] | 1888 | .read_nvram = NULL, |
| 1889 | .write_nvram = NULL, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 1890 | .fw_dump = qla81xx_fw_dump, |
| 1891 | .beacon_on = qla24xx_beacon_on, |
| 1892 | .beacon_off = qla24xx_beacon_off, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1893 | .beacon_blink = qla83xx_beacon_blink, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 1894 | .read_optrom = qla25xx_read_optrom_data, |
| 1895 | .write_optrom = qla24xx_write_optrom_data, |
| 1896 | .get_flash_version = qla24xx_get_flash_version, |
Arun Easi | ba77ef5 | 2010-05-28 15:08:27 -0700 | [diff] [blame] | 1897 | .start_scsi = qla24xx_dif_start_scsi, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1898 | .abort_isp = qla2x00_abort_isp, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 1899 | .iospace_config = qla2x00_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 1900 | .initialize_adapter = qla2x00_initialize_adapter, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1901 | }; |
| 1902 | |
| 1903 | static struct isp_operations qla82xx_isp_ops = { |
| 1904 | .pci_config = qla82xx_pci_config, |
| 1905 | .reset_chip = qla82xx_reset_chip, |
| 1906 | .chip_diag = qla24xx_chip_diag, |
| 1907 | .config_rings = qla82xx_config_rings, |
| 1908 | .reset_adapter = qla24xx_reset_adapter, |
| 1909 | .nvram_config = qla81xx_nvram_config, |
| 1910 | .update_fw_options = qla24xx_update_fw_options, |
| 1911 | .load_risc = qla82xx_load_risc, |
Atul Deshmukh | 9d55ca6 | 2012-08-22 14:21:14 -0400 | [diff] [blame] | 1912 | .pci_info_str = qla24xx_pci_info_str, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1913 | .fw_version_str = qla24xx_fw_version_str, |
| 1914 | .intr_handler = qla82xx_intr_handler, |
| 1915 | .enable_intrs = qla82xx_enable_intrs, |
| 1916 | .disable_intrs = qla82xx_disable_intrs, |
| 1917 | .abort_command = qla24xx_abort_command, |
| 1918 | .target_reset = qla24xx_abort_target, |
| 1919 | .lun_reset = qla24xx_lun_reset, |
| 1920 | .fabric_login = qla24xx_login_fabric, |
| 1921 | .fabric_logout = qla24xx_fabric_logout, |
| 1922 | .calc_req_entries = NULL, |
| 1923 | .build_iocbs = NULL, |
| 1924 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 1925 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 1926 | .read_nvram = qla24xx_read_nvram_data, |
| 1927 | .write_nvram = qla24xx_write_nvram_data, |
Chad Dupuis | a1b23c5 | 2014-02-26 04:15:12 -0500 | [diff] [blame] | 1928 | .fw_dump = qla82xx_fw_dump, |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 1929 | .beacon_on = qla82xx_beacon_on, |
| 1930 | .beacon_off = qla82xx_beacon_off, |
| 1931 | .beacon_blink = NULL, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1932 | .read_optrom = qla82xx_read_optrom_data, |
| 1933 | .write_optrom = qla82xx_write_optrom_data, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 1934 | .get_flash_version = qla82xx_get_flash_version, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1935 | .start_scsi = qla82xx_start_scsi, |
| 1936 | .abort_isp = qla82xx_abort_isp, |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1937 | .iospace_config = qla82xx_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 1938 | .initialize_adapter = qla2x00_initialize_adapter, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 1939 | }; |
| 1940 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 1941 | static struct isp_operations qla8044_isp_ops = { |
| 1942 | .pci_config = qla82xx_pci_config, |
| 1943 | .reset_chip = qla82xx_reset_chip, |
| 1944 | .chip_diag = qla24xx_chip_diag, |
| 1945 | .config_rings = qla82xx_config_rings, |
| 1946 | .reset_adapter = qla24xx_reset_adapter, |
| 1947 | .nvram_config = qla81xx_nvram_config, |
| 1948 | .update_fw_options = qla24xx_update_fw_options, |
| 1949 | .load_risc = qla82xx_load_risc, |
| 1950 | .pci_info_str = qla24xx_pci_info_str, |
| 1951 | .fw_version_str = qla24xx_fw_version_str, |
| 1952 | .intr_handler = qla8044_intr_handler, |
| 1953 | .enable_intrs = qla82xx_enable_intrs, |
| 1954 | .disable_intrs = qla82xx_disable_intrs, |
| 1955 | .abort_command = qla24xx_abort_command, |
| 1956 | .target_reset = qla24xx_abort_target, |
| 1957 | .lun_reset = qla24xx_lun_reset, |
| 1958 | .fabric_login = qla24xx_login_fabric, |
| 1959 | .fabric_logout = qla24xx_fabric_logout, |
| 1960 | .calc_req_entries = NULL, |
| 1961 | .build_iocbs = NULL, |
| 1962 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 1963 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 1964 | .read_nvram = NULL, |
| 1965 | .write_nvram = NULL, |
Chad Dupuis | a1b23c5 | 2014-02-26 04:15:12 -0500 | [diff] [blame] | 1966 | .fw_dump = qla8044_fw_dump, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 1967 | .beacon_on = qla82xx_beacon_on, |
| 1968 | .beacon_off = qla82xx_beacon_off, |
| 1969 | .beacon_blink = NULL, |
Saurav Kashyap | 888e639 | 2014-02-26 04:15:13 -0500 | [diff] [blame] | 1970 | .read_optrom = qla8044_read_optrom_data, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 1971 | .write_optrom = qla8044_write_optrom_data, |
| 1972 | .get_flash_version = qla82xx_get_flash_version, |
| 1973 | .start_scsi = qla82xx_start_scsi, |
| 1974 | .abort_isp = qla8044_abort_isp, |
| 1975 | .iospace_config = qla82xx_iospace_config, |
| 1976 | .initialize_adapter = qla2x00_initialize_adapter, |
| 1977 | }; |
| 1978 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1979 | static struct isp_operations qla83xx_isp_ops = { |
| 1980 | .pci_config = qla25xx_pci_config, |
| 1981 | .reset_chip = qla24xx_reset_chip, |
| 1982 | .chip_diag = qla24xx_chip_diag, |
| 1983 | .config_rings = qla24xx_config_rings, |
| 1984 | .reset_adapter = qla24xx_reset_adapter, |
| 1985 | .nvram_config = qla81xx_nvram_config, |
| 1986 | .update_fw_options = qla81xx_update_fw_options, |
| 1987 | .load_risc = qla81xx_load_risc, |
| 1988 | .pci_info_str = qla24xx_pci_info_str, |
| 1989 | .fw_version_str = qla24xx_fw_version_str, |
| 1990 | .intr_handler = qla24xx_intr_handler, |
| 1991 | .enable_intrs = qla24xx_enable_intrs, |
| 1992 | .disable_intrs = qla24xx_disable_intrs, |
| 1993 | .abort_command = qla24xx_abort_command, |
| 1994 | .target_reset = qla24xx_abort_target, |
| 1995 | .lun_reset = qla24xx_lun_reset, |
| 1996 | .fabric_login = qla24xx_login_fabric, |
| 1997 | .fabric_logout = qla24xx_fabric_logout, |
| 1998 | .calc_req_entries = NULL, |
| 1999 | .build_iocbs = NULL, |
| 2000 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2001 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 2002 | .read_nvram = NULL, |
| 2003 | .write_nvram = NULL, |
| 2004 | .fw_dump = qla83xx_fw_dump, |
| 2005 | .beacon_on = qla24xx_beacon_on, |
| 2006 | .beacon_off = qla24xx_beacon_off, |
| 2007 | .beacon_blink = qla83xx_beacon_blink, |
| 2008 | .read_optrom = qla25xx_read_optrom_data, |
| 2009 | .write_optrom = qla24xx_write_optrom_data, |
| 2010 | .get_flash_version = qla24xx_get_flash_version, |
| 2011 | .start_scsi = qla24xx_dif_start_scsi, |
| 2012 | .abort_isp = qla2x00_abort_isp, |
| 2013 | .iospace_config = qla83xx_iospace_config, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2014 | .initialize_adapter = qla2x00_initialize_adapter, |
| 2015 | }; |
| 2016 | |
| 2017 | static struct isp_operations qlafx00_isp_ops = { |
| 2018 | .pci_config = qlafx00_pci_config, |
| 2019 | .reset_chip = qlafx00_soft_reset, |
| 2020 | .chip_diag = qlafx00_chip_diag, |
| 2021 | .config_rings = qlafx00_config_rings, |
| 2022 | .reset_adapter = qlafx00_soft_reset, |
| 2023 | .nvram_config = NULL, |
| 2024 | .update_fw_options = NULL, |
| 2025 | .load_risc = NULL, |
| 2026 | .pci_info_str = qlafx00_pci_info_str, |
| 2027 | .fw_version_str = qlafx00_fw_version_str, |
| 2028 | .intr_handler = qlafx00_intr_handler, |
| 2029 | .enable_intrs = qlafx00_enable_intrs, |
| 2030 | .disable_intrs = qlafx00_disable_intrs, |
Armen Baloyan | 4440e46 | 2014-02-26 04:15:18 -0500 | [diff] [blame] | 2031 | .abort_command = qla24xx_async_abort_command, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2032 | .target_reset = qlafx00_abort_target, |
| 2033 | .lun_reset = qlafx00_lun_reset, |
| 2034 | .fabric_login = NULL, |
| 2035 | .fabric_logout = NULL, |
| 2036 | .calc_req_entries = NULL, |
| 2037 | .build_iocbs = NULL, |
| 2038 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2039 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 2040 | .read_nvram = qla24xx_read_nvram_data, |
| 2041 | .write_nvram = qla24xx_write_nvram_data, |
| 2042 | .fw_dump = NULL, |
| 2043 | .beacon_on = qla24xx_beacon_on, |
| 2044 | .beacon_off = qla24xx_beacon_off, |
| 2045 | .beacon_blink = NULL, |
| 2046 | .read_optrom = qla24xx_read_optrom_data, |
| 2047 | .write_optrom = qla24xx_write_optrom_data, |
| 2048 | .get_flash_version = qla24xx_get_flash_version, |
| 2049 | .start_scsi = qlafx00_start_scsi, |
| 2050 | .abort_isp = qlafx00_abort_isp, |
| 2051 | .iospace_config = qlafx00_iospace_config, |
| 2052 | .initialize_adapter = qlafx00_initialize_adapter, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2053 | }; |
| 2054 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2055 | static struct isp_operations qla27xx_isp_ops = { |
| 2056 | .pci_config = qla25xx_pci_config, |
| 2057 | .reset_chip = qla24xx_reset_chip, |
| 2058 | .chip_diag = qla24xx_chip_diag, |
| 2059 | .config_rings = qla24xx_config_rings, |
| 2060 | .reset_adapter = qla24xx_reset_adapter, |
| 2061 | .nvram_config = qla81xx_nvram_config, |
| 2062 | .update_fw_options = qla81xx_update_fw_options, |
| 2063 | .load_risc = qla81xx_load_risc, |
| 2064 | .pci_info_str = qla24xx_pci_info_str, |
| 2065 | .fw_version_str = qla24xx_fw_version_str, |
| 2066 | .intr_handler = qla24xx_intr_handler, |
| 2067 | .enable_intrs = qla24xx_enable_intrs, |
| 2068 | .disable_intrs = qla24xx_disable_intrs, |
| 2069 | .abort_command = qla24xx_abort_command, |
| 2070 | .target_reset = qla24xx_abort_target, |
| 2071 | .lun_reset = qla24xx_lun_reset, |
| 2072 | .fabric_login = qla24xx_login_fabric, |
| 2073 | .fabric_logout = qla24xx_fabric_logout, |
| 2074 | .calc_req_entries = NULL, |
| 2075 | .build_iocbs = NULL, |
| 2076 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 2077 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 2078 | .read_nvram = NULL, |
| 2079 | .write_nvram = NULL, |
| 2080 | .fw_dump = qla27xx_fwdump, |
| 2081 | .beacon_on = qla24xx_beacon_on, |
| 2082 | .beacon_off = qla24xx_beacon_off, |
| 2083 | .beacon_blink = qla83xx_beacon_blink, |
| 2084 | .read_optrom = qla25xx_read_optrom_data, |
| 2085 | .write_optrom = qla24xx_write_optrom_data, |
| 2086 | .get_flash_version = qla24xx_get_flash_version, |
| 2087 | .start_scsi = qla24xx_dif_start_scsi, |
| 2088 | .abort_isp = qla2x00_abort_isp, |
| 2089 | .iospace_config = qla83xx_iospace_config, |
| 2090 | .initialize_adapter = qla2x00_initialize_adapter, |
| 2091 | }; |
| 2092 | |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2093 | static inline void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2094 | qla2x00_set_isp_flags(struct qla_hw_data *ha) |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2095 | { |
| 2096 | ha->device_type = DT_EXTENDED_IDS; |
| 2097 | switch (ha->pdev->device) { |
| 2098 | case PCI_DEVICE_ID_QLOGIC_ISP2100: |
| 2099 | ha->device_type |= DT_ISP2100; |
| 2100 | ha->device_type &= ~DT_EXTENDED_IDS; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2101 | ha->fw_srisc_address = RISC_START_ADDRESS_2100; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2102 | break; |
| 2103 | case PCI_DEVICE_ID_QLOGIC_ISP2200: |
| 2104 | ha->device_type |= DT_ISP2200; |
| 2105 | ha->device_type &= ~DT_EXTENDED_IDS; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2106 | ha->fw_srisc_address = RISC_START_ADDRESS_2100; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2107 | break; |
| 2108 | case PCI_DEVICE_ID_QLOGIC_ISP2300: |
| 2109 | ha->device_type |= DT_ISP2300; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2110 | ha->device_type |= DT_ZIO_SUPPORTED; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2111 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2112 | break; |
| 2113 | case PCI_DEVICE_ID_QLOGIC_ISP2312: |
| 2114 | ha->device_type |= DT_ISP2312; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2115 | ha->device_type |= DT_ZIO_SUPPORTED; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2116 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2117 | break; |
| 2118 | case PCI_DEVICE_ID_QLOGIC_ISP2322: |
| 2119 | ha->device_type |= DT_ISP2322; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2120 | ha->device_type |= DT_ZIO_SUPPORTED; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2121 | if (ha->pdev->subsystem_vendor == 0x1028 && |
| 2122 | ha->pdev->subsystem_device == 0x0170) |
| 2123 | ha->device_type |= DT_OEM_001; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2124 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2125 | break; |
| 2126 | case PCI_DEVICE_ID_QLOGIC_ISP6312: |
| 2127 | ha->device_type |= DT_ISP6312; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2128 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2129 | break; |
| 2130 | case PCI_DEVICE_ID_QLOGIC_ISP6322: |
| 2131 | ha->device_type |= DT_ISP6322; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2132 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2133 | break; |
| 2134 | case PCI_DEVICE_ID_QLOGIC_ISP2422: |
| 2135 | ha->device_type |= DT_ISP2422; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2136 | ha->device_type |= DT_ZIO_SUPPORTED; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2137 | ha->device_type |= DT_FWI2; |
Andrew Vasquez | c76f2c0 | 2007-07-19 15:05:57 -0700 | [diff] [blame] | 2138 | ha->device_type |= DT_IIDMA; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2139 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2140 | break; |
| 2141 | case PCI_DEVICE_ID_QLOGIC_ISP2432: |
| 2142 | ha->device_type |= DT_ISP2432; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2143 | ha->device_type |= DT_ZIO_SUPPORTED; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2144 | ha->device_type |= DT_FWI2; |
Andrew Vasquez | c76f2c0 | 2007-07-19 15:05:57 -0700 | [diff] [blame] | 2145 | ha->device_type |= DT_IIDMA; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2146 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2147 | break; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 2148 | case PCI_DEVICE_ID_QLOGIC_ISP8432: |
| 2149 | ha->device_type |= DT_ISP8432; |
| 2150 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2151 | ha->device_type |= DT_FWI2; |
| 2152 | ha->device_type |= DT_IIDMA; |
| 2153 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2154 | break; |
andrew.vasquez@qlogic.com | 044cc6c | 2006-03-09 14:27:13 -0800 | [diff] [blame] | 2155 | case PCI_DEVICE_ID_QLOGIC_ISP5422: |
| 2156 | ha->device_type |= DT_ISP5422; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2157 | ha->device_type |= DT_FWI2; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2158 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2159 | break; |
andrew.vasquez@qlogic.com | 044cc6c | 2006-03-09 14:27:13 -0800 | [diff] [blame] | 2160 | case PCI_DEVICE_ID_QLOGIC_ISP5432: |
| 2161 | ha->device_type |= DT_ISP5432; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2162 | ha->device_type |= DT_FWI2; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2163 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2164 | break; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2165 | case PCI_DEVICE_ID_QLOGIC_ISP2532: |
| 2166 | ha->device_type |= DT_ISP2532; |
| 2167 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2168 | ha->device_type |= DT_FWI2; |
| 2169 | ha->device_type |= DT_IIDMA; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2170 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2171 | break; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2172 | case PCI_DEVICE_ID_QLOGIC_ISP8001: |
| 2173 | ha->device_type |= DT_ISP8001; |
| 2174 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2175 | ha->device_type |= DT_FWI2; |
| 2176 | ha->device_type |= DT_IIDMA; |
| 2177 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2178 | break; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2179 | case PCI_DEVICE_ID_QLOGIC_ISP8021: |
| 2180 | ha->device_type |= DT_ISP8021; |
| 2181 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2182 | ha->device_type |= DT_FWI2; |
| 2183 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2184 | /* Initialize 82XX ISP flags */ |
| 2185 | qla82xx_init_flags(ha); |
| 2186 | break; |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2187 | case PCI_DEVICE_ID_QLOGIC_ISP8044: |
| 2188 | ha->device_type |= DT_ISP8044; |
| 2189 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2190 | ha->device_type |= DT_FWI2; |
| 2191 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2192 | /* Initialize 82XX ISP flags */ |
| 2193 | qla82xx_init_flags(ha); |
| 2194 | break; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2195 | case PCI_DEVICE_ID_QLOGIC_ISP2031: |
| 2196 | ha->device_type |= DT_ISP2031; |
| 2197 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2198 | ha->device_type |= DT_FWI2; |
| 2199 | ha->device_type |= DT_IIDMA; |
| 2200 | ha->device_type |= DT_T10_PI; |
| 2201 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2202 | break; |
| 2203 | case PCI_DEVICE_ID_QLOGIC_ISP8031: |
| 2204 | ha->device_type |= DT_ISP8031; |
| 2205 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2206 | ha->device_type |= DT_FWI2; |
| 2207 | ha->device_type |= DT_IIDMA; |
| 2208 | ha->device_type |= DT_T10_PI; |
| 2209 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2210 | break; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2211 | case PCI_DEVICE_ID_QLOGIC_ISPF001: |
| 2212 | ha->device_type |= DT_ISPFX00; |
| 2213 | break; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2214 | case PCI_DEVICE_ID_QLOGIC_ISP2071: |
| 2215 | ha->device_type |= DT_ISP2071; |
| 2216 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2217 | ha->device_type |= DT_FWI2; |
| 2218 | ha->device_type |= DT_IIDMA; |
| 2219 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2220 | break; |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 2221 | case PCI_DEVICE_ID_QLOGIC_ISP2271: |
| 2222 | ha->device_type |= DT_ISP2271; |
| 2223 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2224 | ha->device_type |= DT_FWI2; |
| 2225 | ha->device_type |= DT_IIDMA; |
| 2226 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2227 | break; |
Sawan Chandak | 2b48992 | 2015-08-04 13:38:03 -0400 | [diff] [blame] | 2228 | case PCI_DEVICE_ID_QLOGIC_ISP2261: |
| 2229 | ha->device_type |= DT_ISP2261; |
| 2230 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2231 | ha->device_type |= DT_FWI2; |
| 2232 | ha->device_type |= DT_IIDMA; |
| 2233 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2234 | break; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2235 | } |
Anirban Chakraborty | e5b68a6 | 2009-04-06 22:33:50 -0700 | [diff] [blame] | 2236 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2237 | if (IS_QLA82XX(ha)) |
Saurav Kashyap | 43a9c38 | 2014-02-26 04:15:16 -0500 | [diff] [blame] | 2238 | ha->port_no = ha->portnum & 1; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2239 | else { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2240 | /* Get adapter physical port no from interrupt pin register. */ |
| 2241 | pci_read_config_byte(ha->pdev, PCI_INTERRUPT_PIN, &ha->port_no); |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2242 | if (IS_QLA27XX(ha)) |
| 2243 | ha->port_no--; |
| 2244 | else |
| 2245 | ha->port_no = !(ha->port_no & 1); |
| 2246 | } |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2247 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2248 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x000b, |
Joe Perches | d8424f6 | 2011-11-18 09:03:06 -0800 | [diff] [blame] | 2249 | "device_type=0x%x port=%d fw_srisc_address=0x%x.\n", |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2250 | ha->device_type, ha->port_no, ha->fw_srisc_address); |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2251 | } |
| 2252 | |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2253 | static void |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2254 | qla2xxx_scan_start(struct Scsi_Host *shost) |
| 2255 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2256 | scsi_qla_host_t *vha = shost_priv(shost); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2257 | |
Andrew Vasquez | cbc8eb6 | 2009-06-03 09:55:17 -0700 | [diff] [blame] | 2258 | if (vha->hw->flags.running_gold_fw) |
| 2259 | return; |
| 2260 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2261 | set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); |
| 2262 | set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); |
| 2263 | set_bit(RSCN_UPDATE, &vha->dpc_flags); |
| 2264 | set_bit(NPIV_CONFIG_NEEDED, &vha->dpc_flags); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2265 | } |
| 2266 | |
| 2267 | static int |
| 2268 | qla2xxx_scan_finished(struct Scsi_Host *shost, unsigned long time) |
| 2269 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2270 | scsi_qla_host_t *vha = shost_priv(shost); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2271 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2272 | if (!vha->host) |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2273 | return 1; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2274 | if (time > vha->hw->loop_reset_delay * HZ) |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2275 | return 1; |
| 2276 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2277 | return atomic_read(&vha->loop_state) == LOOP_READY; |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2278 | } |
| 2279 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2280 | /* |
| 2281 | * PCI driver interface |
| 2282 | */ |
Greg Kroah-Hartman | 6f03979 | 2012-12-21 13:08:55 -0800 | [diff] [blame] | 2283 | static int |
Andrew Vasquez | 7ee6139 | 2006-06-23 16:11:22 -0700 | [diff] [blame] | 2284 | 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] | 2285 | { |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2286 | int ret = -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2287 | struct Scsi_Host *host; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2288 | scsi_qla_host_t *base_vha = NULL; |
| 2289 | struct qla_hw_data *ha; |
Andrew Vasquez | 29856e2 | 2007-08-12 18:22:52 -0700 | [diff] [blame] | 2290 | char pci_info[30]; |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 2291 | char fw_str[30], wq_name[30]; |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 2292 | struct scsi_host_template *sht; |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2293 | int bars, mem_only = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2294 | uint16_t req_length = 0, rsp_length = 0; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2295 | struct req_que *req = NULL; |
| 2296 | struct rsp_que *rsp = NULL; |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2297 | bars = pci_select_bars(pdev, IORESOURCE_MEM | IORESOURCE_IO); |
Giridhar Malavali | a5326f8 | 2009-03-24 09:07:56 -0700 | [diff] [blame] | 2298 | sht = &qla2xxx_driver_template; |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2299 | if (pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2422 || |
| 2300 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2432 || |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 2301 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8432 || |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2302 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP5422 || |
| 2303 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP5432 || |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2304 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2532 || |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2305 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8001 || |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2306 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8021 || |
| 2307 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2031 || |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2308 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8031 || |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2309 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISPF001 || |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2310 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8044 || |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 2311 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2071 || |
Sawan Chandak | 2b48992 | 2015-08-04 13:38:03 -0400 | [diff] [blame] | 2312 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2271 || |
| 2313 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2261) { |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2314 | bars = pci_select_bars(pdev, IORESOURCE_MEM); |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 2315 | mem_only = 1; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2316 | ql_dbg_pci(ql_dbg_init, pdev, 0x0007, |
| 2317 | "Mem only adapter.\n"); |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2318 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2319 | ql_dbg_pci(ql_dbg_init, pdev, 0x0008, |
| 2320 | "Bars=%d.\n", bars); |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2321 | |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 2322 | if (mem_only) { |
| 2323 | if (pci_enable_device_mem(pdev)) |
| 2324 | goto probe_out; |
| 2325 | } else { |
| 2326 | if (pci_enable_device(pdev)) |
| 2327 | goto probe_out; |
| 2328 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2329 | |
Jesse Barnes | 0927678 | 2008-10-18 17:33:19 -0700 | [diff] [blame] | 2330 | /* This may fail but that's ok */ |
| 2331 | pci_enable_pcie_error_reporting(pdev); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 2332 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2333 | ha = kzalloc(sizeof(struct qla_hw_data), GFP_KERNEL); |
| 2334 | if (!ha) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2335 | ql_log_pci(ql_log_fatal, pdev, 0x0009, |
| 2336 | "Unable to allocate memory for ha.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2337 | goto probe_out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2338 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2339 | ql_dbg_pci(ql_dbg_init, pdev, 0x000a, |
| 2340 | "Memory allocated for ha=%p.\n", ha); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2341 | ha->pdev = pdev; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2342 | ha->tgt.enable_class_2 = ql2xenableclass2; |
Quinn Tran | 33e7997 | 2014-09-25 06:14:55 -0400 | [diff] [blame] | 2343 | INIT_LIST_HEAD(&ha->tgt.q_full_list); |
| 2344 | spin_lock_init(&ha->tgt.q_full_lock); |
Quinn Tran | 7560151 | 2015-12-17 14:57:04 -0500 | [diff] [blame] | 2345 | spin_lock_init(&ha->tgt.sess_lock); |
Quinn Tran | 2f424b9 | 2015-12-17 14:57:07 -0500 | [diff] [blame] | 2346 | spin_lock_init(&ha->tgt.atio_lock); |
| 2347 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2348 | |
| 2349 | /* Clear our data area */ |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2350 | ha->bars = bars; |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 2351 | ha->mem_only = mem_only; |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 2352 | spin_lock_init(&ha->hardware_lock); |
Andrew Vasquez | 339aa70 | 2010-10-15 11:27:45 -0700 | [diff] [blame] | 2353 | spin_lock_init(&ha->vport_slock); |
Saurav Kashyap | a9b6f722 | 2012-08-22 14:21:01 -0400 | [diff] [blame] | 2354 | mutex_init(&ha->selflogin_lock); |
Chad Dupuis | 7a8ab9c | 2014-02-26 04:14:56 -0500 | [diff] [blame] | 2355 | mutex_init(&ha->optrom_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2356 | |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2357 | /* Set ISP-type information. */ |
| 2358 | qla2x00_set_isp_flags(ha); |
Duane Grigsby | ca79cf6 | 2009-12-15 21:29:47 -0800 | [diff] [blame] | 2359 | |
| 2360 | /* Set EEH reset type to fundamental if required by hba */ |
Joe Carnuccio | 9567611 | 2012-08-22 14:21:20 -0400 | [diff] [blame] | 2361 | if (IS_QLA24XX(ha) || IS_QLA25XX(ha) || IS_QLA81XX(ha) || |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2362 | IS_QLA83XX(ha) || IS_QLA27XX(ha)) |
Duane Grigsby | ca79cf6 | 2009-12-15 21:29:47 -0800 | [diff] [blame] | 2363 | pdev->needs_freset = 1; |
Duane Grigsby | ca79cf6 | 2009-12-15 21:29:47 -0800 | [diff] [blame] | 2364 | |
Chad Dupuis | cba1e47 | 2011-11-18 09:03:21 -0800 | [diff] [blame] | 2365 | ha->prev_topology = 0; |
| 2366 | ha->init_cb_size = sizeof(init_cb_t); |
| 2367 | ha->link_data_rate = PORT_SPEED_UNKNOWN; |
| 2368 | ha->optrom_size = OPTROM_SIZE_2300; |
| 2369 | |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2370 | /* Assign ISP specific operations. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2371 | if (IS_QLA2100(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2372 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2100; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2373 | ha->mbx_count = MAILBOX_REGISTER_COUNT_2100; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2374 | req_length = REQUEST_ENTRY_CNT_2100; |
| 2375 | rsp_length = RESPONSE_ENTRY_CNT_2100; |
| 2376 | ha->max_loop_id = SNS_LAST_LOOP_ID_2100; |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2377 | ha->gid_list_info_size = 4; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2378 | ha->flash_conf_off = ~0; |
| 2379 | ha->flash_data_off = ~0; |
| 2380 | ha->nvram_conf_off = ~0; |
| 2381 | ha->nvram_data_off = ~0; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2382 | ha->isp_ops = &qla2100_isp_ops; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2383 | } else if (IS_QLA2200(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2384 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2100; |
Andrew Vasquez | 67ddda3 | 2012-02-09 11:14:08 -0800 | [diff] [blame] | 2385 | ha->mbx_count = MAILBOX_REGISTER_COUNT_2200; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2386 | req_length = REQUEST_ENTRY_CNT_2200; |
| 2387 | rsp_length = RESPONSE_ENTRY_CNT_2100; |
| 2388 | ha->max_loop_id = SNS_LAST_LOOP_ID_2100; |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2389 | ha->gid_list_info_size = 4; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2390 | ha->flash_conf_off = ~0; |
| 2391 | ha->flash_data_off = ~0; |
| 2392 | ha->nvram_conf_off = ~0; |
| 2393 | ha->nvram_data_off = ~0; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2394 | ha->isp_ops = &qla2100_isp_ops; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 2395 | } else if (IS_QLA23XX(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2396 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2100; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2397 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2398 | req_length = REQUEST_ENTRY_CNT_2200; |
| 2399 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
| 2400 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2401 | ha->gid_list_info_size = 6; |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 2402 | if (IS_QLA2322(ha) || IS_QLA6322(ha)) |
| 2403 | ha->optrom_size = OPTROM_SIZE_2322; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2404 | ha->flash_conf_off = ~0; |
| 2405 | ha->flash_data_off = ~0; |
| 2406 | ha->nvram_conf_off = ~0; |
| 2407 | ha->nvram_data_off = ~0; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2408 | ha->isp_ops = &qla2300_isp_ops; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 2409 | } else if (IS_QLA24XX_TYPE(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2410 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 2411 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2412 | req_length = REQUEST_ENTRY_CNT_24XX; |
| 2413 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2414 | ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2415 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2416 | ha->init_cb_size = sizeof(struct mid_init_cb_24xx); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 2417 | ha->gid_list_info_size = 8; |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 2418 | ha->optrom_size = OPTROM_SIZE_24XX; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2419 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA24XX; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2420 | ha->isp_ops = &qla24xx_isp_ops; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2421 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF; |
| 2422 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA; |
| 2423 | ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF; |
| 2424 | ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2425 | } else if (IS_QLA25XX(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2426 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2427 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2428 | req_length = REQUEST_ENTRY_CNT_24XX; |
| 2429 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2430 | ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2431 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2432 | ha->init_cb_size = sizeof(struct mid_init_cb_24xx); |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2433 | ha->gid_list_info_size = 8; |
| 2434 | ha->optrom_size = OPTROM_SIZE_25XX; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2435 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2436 | ha->isp_ops = &qla25xx_isp_ops; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2437 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF; |
| 2438 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA; |
| 2439 | ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF; |
| 2440 | ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA; |
| 2441 | } else if (IS_QLA81XX(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2442 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2443 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
| 2444 | req_length = REQUEST_ENTRY_CNT_24XX; |
| 2445 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
Arun Easi | aa230bc | 2013-01-30 03:34:39 -0500 | [diff] [blame] | 2446 | ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2447 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 2448 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 2449 | ha->gid_list_info_size = 8; |
| 2450 | ha->optrom_size = OPTROM_SIZE_81XX; |
Anirban Chakraborty | 40859ae | 2009-06-03 09:55:16 -0700 | [diff] [blame] | 2451 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2452 | ha->isp_ops = &qla81xx_isp_ops; |
| 2453 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF_81XX; |
| 2454 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA_81XX; |
| 2455 | ha->nvram_conf_off = ~0; |
| 2456 | ha->nvram_data_off = ~0; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2457 | } else if (IS_QLA82XX(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2458 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2459 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
| 2460 | req_length = REQUEST_ENTRY_CNT_82XX; |
| 2461 | rsp_length = RESPONSE_ENTRY_CNT_82XX; |
| 2462 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 2463 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 2464 | ha->gid_list_info_size = 8; |
| 2465 | ha->optrom_size = OPTROM_SIZE_82XX; |
Andrew Vasquez | 087c621 | 2010-11-23 16:52:48 -0800 | [diff] [blame] | 2466 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2467 | ha->isp_ops = &qla82xx_isp_ops; |
| 2468 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF; |
| 2469 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA; |
| 2470 | ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF; |
| 2471 | ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA; |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2472 | } else if (IS_QLA8044(ha)) { |
| 2473 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
| 2474 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
| 2475 | req_length = REQUEST_ENTRY_CNT_82XX; |
| 2476 | rsp_length = RESPONSE_ENTRY_CNT_82XX; |
| 2477 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 2478 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 2479 | ha->gid_list_info_size = 8; |
| 2480 | ha->optrom_size = OPTROM_SIZE_83XX; |
| 2481 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
| 2482 | ha->isp_ops = &qla8044_isp_ops; |
| 2483 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF; |
| 2484 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA; |
| 2485 | ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF; |
| 2486 | ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2487 | } else if (IS_QLA83XX(ha)) { |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 2488 | ha->portnum = PCI_FUNC(ha->pdev->devfn); |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2489 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2490 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
Saurav Kashyap | f2ea653 | 2014-09-25 06:14:54 -0400 | [diff] [blame] | 2491 | req_length = REQUEST_ENTRY_CNT_83XX; |
Quinn Tran | e7b42e3 | 2015-12-17 14:57:09 -0500 | [diff] [blame] | 2492 | rsp_length = RESPONSE_ENTRY_CNT_83XX; |
Arun Easi | b8aa4bd | 2013-01-30 03:34:40 -0500 | [diff] [blame] | 2493 | ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2494 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 2495 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 2496 | ha->gid_list_info_size = 8; |
| 2497 | ha->optrom_size = OPTROM_SIZE_83XX; |
| 2498 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
| 2499 | ha->isp_ops = &qla83xx_isp_ops; |
| 2500 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF_81XX; |
| 2501 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA_81XX; |
| 2502 | ha->nvram_conf_off = ~0; |
| 2503 | ha->nvram_data_off = ~0; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2504 | } else if (IS_QLAFX00(ha)) { |
| 2505 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_FX00; |
| 2506 | ha->mbx_count = MAILBOX_REGISTER_COUNT_FX00; |
| 2507 | ha->aen_mbx_count = AEN_MAILBOX_REGISTER_COUNT_FX00; |
| 2508 | req_length = REQUEST_ENTRY_CNT_FX00; |
| 2509 | rsp_length = RESPONSE_ENTRY_CNT_FX00; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2510 | ha->isp_ops = &qlafx00_isp_ops; |
| 2511 | ha->port_down_retry_count = 30; /* default value */ |
| 2512 | ha->mr.fw_hbt_cnt = QLAFX00_HEARTBEAT_INTERVAL; |
| 2513 | ha->mr.fw_reset_timer_tick = QLAFX00_RESET_INTERVAL; |
Armen Baloyan | 71e5600 | 2013-08-27 01:37:38 -0400 | [diff] [blame] | 2514 | ha->mr.fw_critemp_timer_tick = QLAFX00_CRITEMP_INTERVAL; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2515 | ha->mr.fw_hbt_en = 1; |
Armen Baloyan | e8f5e95 | 2013-10-30 03:38:17 -0400 | [diff] [blame] | 2516 | ha->mr.host_info_resend = false; |
| 2517 | ha->mr.hinfo_resend_timer_tick = QLAFX00_HINFO_RESEND_INTERVAL; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2518 | } else if (IS_QLA27XX(ha)) { |
| 2519 | ha->portnum = PCI_FUNC(ha->pdev->devfn); |
| 2520 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
| 2521 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
Quinn Tran | e7b42e3 | 2015-12-17 14:57:09 -0500 | [diff] [blame] | 2522 | req_length = REQUEST_ENTRY_CNT_83XX; |
| 2523 | rsp_length = RESPONSE_ENTRY_CNT_83XX; |
Himanshu Madhani | b20f02e | 2015-06-10 11:05:18 -0400 | [diff] [blame] | 2524 | ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2525 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 2526 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 2527 | ha->gid_list_info_size = 8; |
| 2528 | ha->optrom_size = OPTROM_SIZE_83XX; |
| 2529 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
| 2530 | ha->isp_ops = &qla27xx_isp_ops; |
| 2531 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF_81XX; |
| 2532 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA_81XX; |
| 2533 | ha->nvram_conf_off = ~0; |
| 2534 | ha->nvram_data_off = ~0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2535 | } |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2536 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2537 | ql_dbg_pci(ql_dbg_init, pdev, 0x001e, |
| 2538 | "mbx_count=%d, req_length=%d, " |
| 2539 | "rsp_length=%d, max_loop_id=%d, init_cb_size=%d, " |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2540 | "gid_list_info_size=%d, optrom_size=%d, nvram_npiv_size=%d, " |
| 2541 | "max_fibre_devices=%d.\n", |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2542 | ha->mbx_count, req_length, rsp_length, ha->max_loop_id, |
| 2543 | ha->init_cb_size, ha->gid_list_info_size, ha->optrom_size, |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2544 | ha->nvram_npiv_size, ha->max_fibre_devices); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2545 | ql_dbg_pci(ql_dbg_init, pdev, 0x001f, |
| 2546 | "isp_ops=%p, flash_conf_off=%d, " |
| 2547 | "flash_data_off=%d, nvram_conf_off=%d, nvram_data_off=%d.\n", |
| 2548 | ha->isp_ops, ha->flash_conf_off, ha->flash_data_off, |
| 2549 | ha->nvram_conf_off, ha->nvram_data_off); |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 2550 | |
| 2551 | /* Configure PCI I/O space */ |
| 2552 | ret = ha->isp_ops->iospace_config(ha); |
| 2553 | if (ret) |
Saurav Kashyap | 0a63ad1 | 2012-11-21 02:40:43 -0500 | [diff] [blame] | 2554 | goto iospace_config_failed; |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 2555 | |
| 2556 | ql_log_pci(ql_log_info, pdev, 0x001d, |
| 2557 | "Found an ISP%04X irq %d iobase 0x%p.\n", |
| 2558 | pdev->device, pdev->irq, ha->iobase); |
matthias@kaehlcke.net | 6c2f527 | 2008-05-12 22:21:11 -0700 | [diff] [blame] | 2559 | mutex_init(&ha->vport_lock); |
Marcus Barrow | 0b05a1f | 2008-01-17 09:02:13 -0800 | [diff] [blame] | 2560 | init_completion(&ha->mbx_cmd_comp); |
| 2561 | complete(&ha->mbx_cmd_comp); |
| 2562 | init_completion(&ha->mbx_intr_comp); |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 2563 | init_completion(&ha->dcbx_comp); |
Chad Dupuis | f356bef | 2013-02-08 01:58:04 -0500 | [diff] [blame] | 2564 | init_completion(&ha->lb_portup_comp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2565 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2566 | set_bit(0, (unsigned long *) ha->vp_idx_map); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2567 | |
Andrew Vasquez | 53303c4 | 2009-01-22 09:45:37 -0800 | [diff] [blame] | 2568 | qla2x00_config_dma_addressing(ha); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2569 | ql_dbg_pci(ql_dbg_init, pdev, 0x0020, |
| 2570 | "64 Bit addressing is %s.\n", |
| 2571 | ha->flags.enable_64bit_addressing ? "enable" : |
| 2572 | "disable"); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2573 | ret = qla2x00_mem_alloc(ha, req_length, rsp_length, &req, &rsp); |
Dan Carpenter | b2a72ec | 2014-01-21 10:00:10 +0300 | [diff] [blame] | 2574 | if (ret) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2575 | ql_log_pci(ql_log_fatal, pdev, 0x0031, |
| 2576 | "Failed to allocate memory for adapter, aborting.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2577 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2578 | goto probe_hw_failed; |
| 2579 | } |
| 2580 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2581 | req->max_q_depth = MAX_Q_DEPTH; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2582 | if (ql2xmaxqdepth != 0 && ql2xmaxqdepth <= 0xffffU) |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2583 | req->max_q_depth = ql2xmaxqdepth; |
| 2584 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2585 | |
| 2586 | base_vha = qla2x00_create_host(sht, ha); |
| 2587 | if (!base_vha) { |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2588 | ret = -ENOMEM; |
Anirban Chakraborty | 6e9f21f | 2009-01-22 09:45:28 -0800 | [diff] [blame] | 2589 | qla2x00_mem_free(ha); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2590 | qla2x00_free_req_que(ha, req); |
| 2591 | qla2x00_free_rsp_que(ha, rsp); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2592 | goto probe_hw_failed; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2593 | } |
| 2594 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2595 | pci_set_drvdata(pdev, base_vha); |
Joe Lawrence | 6b38397 | 2014-08-26 17:12:29 -0400 | [diff] [blame] | 2596 | set_bit(PFLG_DRIVER_PROBING, &base_vha->pci_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2597 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2598 | host = base_vha->host; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2599 | base_vha->req = req; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2600 | if (IS_QLA2XXX_MIDTYPE(ha)) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2601 | base_vha->mgmt_svr_loop_id = 10 + base_vha->vp_idx; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2602 | else |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2603 | base_vha->mgmt_svr_loop_id = MANAGEMENT_SERVER + |
| 2604 | base_vha->vp_idx; |
Giridhar Malavali | 58548cb | 2010-09-03 15:20:56 -0700 | [diff] [blame] | 2605 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2606 | /* Setup fcport template structure. */ |
| 2607 | ha->mr.fcport.vha = base_vha; |
| 2608 | ha->mr.fcport.port_type = FCT_UNKNOWN; |
| 2609 | ha->mr.fcport.loop_id = FC_NO_LOOP_ID; |
| 2610 | qla2x00_set_fcport_state(&ha->mr.fcport, FCS_UNCONFIGURED); |
| 2611 | ha->mr.fcport.supported_classes = FC_COS_UNSPECIFIED; |
| 2612 | ha->mr.fcport.scan_state = 1; |
| 2613 | |
Giridhar Malavali | 58548cb | 2010-09-03 15:20:56 -0700 | [diff] [blame] | 2614 | /* Set the SG table size based on ISP type */ |
| 2615 | if (!IS_FWI2_CAPABLE(ha)) { |
| 2616 | if (IS_QLA2100(ha)) |
| 2617 | host->sg_tablesize = 32; |
| 2618 | } else { |
| 2619 | if (!IS_QLA82XX(ha)) |
| 2620 | host->sg_tablesize = QLA_SG_ALL; |
| 2621 | } |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2622 | host->max_id = ha->max_fibre_devices; |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2623 | host->cmd_per_lun = 3; |
Seokmann Ju | 711c1d9 | 2008-07-10 16:55:51 -0700 | [diff] [blame] | 2624 | host->unique_id = host->host_no; |
Arun Easi | e02587d | 2011-08-16 11:29:23 -0700 | [diff] [blame] | 2625 | if (IS_T10_PI_CAPABLE(ha) && ql2xenabledif) |
Arun Easi | 0c47087 | 2010-07-23 15:28:38 +0500 | [diff] [blame] | 2626 | host->max_cmd_len = 32; |
| 2627 | else |
| 2628 | host->max_cmd_len = MAX_CMDSZ; |
Andrew Vasquez | 75bc419 | 2006-05-17 15:09:22 -0700 | [diff] [blame] | 2629 | host->max_channel = MAX_BUSES - 1; |
Hannes Reinecke | 755f516 | 2014-06-03 10:58:54 +0200 | [diff] [blame] | 2630 | /* Older HBAs support only 16-bit LUNs */ |
| 2631 | if (!IS_QLAFX00(ha) && !IS_FWI2_CAPABLE(ha) && |
| 2632 | ql2xmaxlun > 0xffff) |
| 2633 | host->max_lun = 0xffff; |
| 2634 | else |
| 2635 | host->max_lun = ql2xmaxlun; |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2636 | host->transportt = qla2xxx_transport_template; |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 2637 | sht->vendor_id = (SCSI_NL_VID_TYPE_PCI | PCI_VENDOR_ID_QLOGIC); |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2638 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2639 | ql_dbg(ql_dbg_init, base_vha, 0x0033, |
| 2640 | "max_id=%d this_id=%d " |
| 2641 | "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] | 2642 | "max_lun=%llu transportt=%p, vendor_id=%llu.\n", host->max_id, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2643 | host->this_id, host->cmd_per_lun, host->unique_id, |
| 2644 | host->max_cmd_len, host->max_channel, host->max_lun, |
| 2645 | host->transportt, sht->vendor_id); |
| 2646 | |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 2647 | que_init: |
| 2648 | /* Alloc arrays of request and response ring ptrs */ |
| 2649 | if (!qla2x00_alloc_queues(ha, req, rsp)) { |
| 2650 | ql_log(ql_log_fatal, base_vha, 0x003d, |
| 2651 | "Failed to allocate memory for queue pointers..." |
| 2652 | "aborting.\n"); |
| 2653 | goto probe_init_failed; |
| 2654 | } |
| 2655 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2656 | qlt_probe_one_stage1(base_vha, ha); |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 2657 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2658 | /* Set up the irqs */ |
| 2659 | ret = qla2x00_request_irqs(ha, rsp); |
| 2660 | if (ret) |
Anirban Chakraborty | 6e9f21f | 2009-01-22 09:45:28 -0800 | [diff] [blame] | 2661 | goto probe_init_failed; |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 2662 | |
| 2663 | pci_save_state(pdev); |
| 2664 | |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 2665 | /* Assign back pointers */ |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2666 | rsp->req = req; |
| 2667 | req->rsp = rsp; |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 2668 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2669 | if (IS_QLAFX00(ha)) { |
| 2670 | ha->rsp_q_map[0] = rsp; |
| 2671 | ha->req_q_map[0] = req; |
| 2672 | set_bit(0, ha->req_qid_map); |
| 2673 | set_bit(0, ha->rsp_qid_map); |
| 2674 | } |
| 2675 | |
Andrew Vasquez | 0802999 | 2009-03-24 09:07:55 -0700 | [diff] [blame] | 2676 | /* FWI2-capable only. */ |
| 2677 | req->req_q_in = &ha->iobase->isp24.req_q_in; |
| 2678 | req->req_q_out = &ha->iobase->isp24.req_q_out; |
| 2679 | rsp->rsp_q_in = &ha->iobase->isp24.rsp_q_in; |
| 2680 | rsp->rsp_q_out = &ha->iobase->isp24.rsp_q_out; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2681 | if (ha->mqenable || IS_QLA83XX(ha) || IS_QLA27XX(ha)) { |
Andrew Vasquez | 0802999 | 2009-03-24 09:07:55 -0700 | [diff] [blame] | 2682 | req->req_q_in = &ha->mqiobase->isp25mq.req_q_in; |
| 2683 | req->req_q_out = &ha->mqiobase->isp25mq.req_q_out; |
| 2684 | rsp->rsp_q_in = &ha->mqiobase->isp25mq.rsp_q_in; |
| 2685 | rsp->rsp_q_out = &ha->mqiobase->isp25mq.rsp_q_out; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 2686 | } |
| 2687 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2688 | if (IS_QLAFX00(ha)) { |
| 2689 | req->req_q_in = &ha->iobase->ispfx00.req_q_in; |
| 2690 | req->req_q_out = &ha->iobase->ispfx00.req_q_out; |
| 2691 | rsp->rsp_q_in = &ha->iobase->ispfx00.rsp_q_in; |
| 2692 | rsp->rsp_q_out = &ha->iobase->ispfx00.rsp_q_out; |
| 2693 | } |
| 2694 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2695 | if (IS_P3P_TYPE(ha)) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2696 | req->req_q_out = &ha->iobase->isp82.req_q_out[0]; |
| 2697 | rsp->rsp_q_in = &ha->iobase->isp82.rsp_q_in[0]; |
| 2698 | rsp->rsp_q_out = &ha->iobase->isp82.rsp_q_out[0]; |
| 2699 | } |
| 2700 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2701 | ql_dbg(ql_dbg_multiq, base_vha, 0xc009, |
| 2702 | "rsp_q_map=%p req_q_map=%p rsp->req=%p req->rsp=%p.\n", |
| 2703 | ha->rsp_q_map, ha->req_q_map, rsp->req, req->rsp); |
| 2704 | ql_dbg(ql_dbg_multiq, base_vha, 0xc00a, |
| 2705 | "req->req_q_in=%p req->req_q_out=%p " |
| 2706 | "rsp->rsp_q_in=%p rsp->rsp_q_out=%p.\n", |
| 2707 | req->req_q_in, req->req_q_out, |
| 2708 | rsp->rsp_q_in, rsp->rsp_q_out); |
| 2709 | ql_dbg(ql_dbg_init, base_vha, 0x003e, |
| 2710 | "rsp_q_map=%p req_q_map=%p rsp->req=%p req->rsp=%p.\n", |
| 2711 | ha->rsp_q_map, ha->req_q_map, rsp->req, req->rsp); |
| 2712 | ql_dbg(ql_dbg_init, base_vha, 0x003f, |
| 2713 | "req->req_q_in=%p req->req_q_out=%p rsp->rsp_q_in=%p rsp->rsp_q_out=%p.\n", |
| 2714 | 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] | 2715 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2716 | if (ha->isp_ops->initialize_adapter(base_vha)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2717 | ql_log(ql_log_fatal, base_vha, 0x00d6, |
| 2718 | "Failed to initialize adapter - Adapter flags %x.\n", |
| 2719 | base_vha->device_flags); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2720 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2721 | if (IS_QLA82XX(ha)) { |
| 2722 | qla82xx_idc_lock(ha); |
| 2723 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 2724 | QLA8XXX_DEV_FAILED); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2725 | qla82xx_idc_unlock(ha); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2726 | ql_log(ql_log_fatal, base_vha, 0x00d7, |
| 2727 | "HW State: FAILED.\n"); |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2728 | } else if (IS_QLA8044(ha)) { |
| 2729 | qla8044_idc_lock(ha); |
| 2730 | qla8044_wr_direct(base_vha, |
| 2731 | QLA8044_CRB_DEV_STATE_INDEX, |
| 2732 | QLA8XXX_DEV_FAILED); |
| 2733 | qla8044_idc_unlock(ha); |
| 2734 | ql_log(ql_log_fatal, base_vha, 0x0150, |
| 2735 | "HW State: FAILED.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2736 | } |
| 2737 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2738 | ret = -ENODEV; |
| 2739 | goto probe_failed; |
| 2740 | } |
| 2741 | |
Chad Dupuis | 3b1bef6 | 2014-02-26 04:15:04 -0500 | [diff] [blame] | 2742 | if (IS_QLAFX00(ha)) |
| 2743 | host->can_queue = QLAFX00_MAX_CANQUEUE; |
| 2744 | else |
| 2745 | host->can_queue = req->num_outstanding_cmds - 10; |
| 2746 | |
| 2747 | ql_dbg(ql_dbg_init, base_vha, 0x0032, |
| 2748 | "can_queue=%d, req=%p, mgmt_svr_loop_id=%d, sg_tablesize=%d.\n", |
| 2749 | host->can_queue, base_vha->req, |
| 2750 | base_vha->mgmt_svr_loop_id, host->sg_tablesize); |
| 2751 | |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 2752 | if (ha->mqenable) { |
| 2753 | if (qla25xx_setup_mode(base_vha)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2754 | ql_log(ql_log_warn, base_vha, 0x00ec, |
| 2755 | "Failed to create queues, falling back to single queue mode.\n"); |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 2756 | goto que_init; |
| 2757 | } |
| 2758 | } |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 2759 | |
Andrew Vasquez | cbc8eb6 | 2009-06-03 09:55:17 -0700 | [diff] [blame] | 2760 | if (ha->flags.running_gold_fw) |
| 2761 | goto skip_dpc; |
| 2762 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2763 | /* |
| 2764 | * Startup the kernel thread for this host adapter |
| 2765 | */ |
| 2766 | ha->dpc_thread = kthread_create(qla2x00_do_dpc, ha, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2767 | "%s_dpc", base_vha->host_str); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2768 | if (IS_ERR(ha->dpc_thread)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2769 | ql_log(ql_log_fatal, base_vha, 0x00ed, |
| 2770 | "Failed to start DPC thread.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2771 | ret = PTR_ERR(ha->dpc_thread); |
| 2772 | goto probe_failed; |
| 2773 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2774 | ql_dbg(ql_dbg_init, base_vha, 0x00ee, |
| 2775 | "DPC thread started successfully.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2776 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2777 | /* |
| 2778 | * If we're not coming up in initiator mode, we might sit for |
| 2779 | * a while without waking up the dpc thread, which leads to a |
| 2780 | * stuck process warning. So just kick the dpc once here and |
| 2781 | * let the kthread start (and go back to sleep in qla2x00_do_dpc). |
| 2782 | */ |
| 2783 | qla2xxx_wake_dpc(base_vha); |
| 2784 | |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 2785 | INIT_WORK(&ha->board_disable, qla2x00_disable_board_on_pci_error); |
| 2786 | |
Saurav Kashyap | 8117877 | 2012-08-22 14:21:04 -0400 | [diff] [blame] | 2787 | if (IS_QLA8031(ha) || IS_MCTP_CAPABLE(ha)) { |
| 2788 | sprintf(wq_name, "qla2xxx_%lu_dpc_lp_wq", base_vha->host_no); |
| 2789 | ha->dpc_lp_wq = create_singlethread_workqueue(wq_name); |
| 2790 | INIT_WORK(&ha->idc_aen, qla83xx_service_idc_aen); |
| 2791 | |
| 2792 | sprintf(wq_name, "qla2xxx_%lu_dpc_hp_wq", base_vha->host_no); |
| 2793 | ha->dpc_hp_wq = create_singlethread_workqueue(wq_name); |
| 2794 | INIT_WORK(&ha->nic_core_reset, qla83xx_nic_core_reset_work); |
| 2795 | INIT_WORK(&ha->idc_state_handler, |
| 2796 | qla83xx_idc_state_handler_work); |
| 2797 | INIT_WORK(&ha->nic_core_unrecoverable, |
| 2798 | qla83xx_nic_core_unrecoverable_work); |
| 2799 | } |
| 2800 | |
Andrew Vasquez | cbc8eb6 | 2009-06-03 09:55:17 -0700 | [diff] [blame] | 2801 | skip_dpc: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2802 | list_add_tail(&base_vha->list, &ha->vp_list); |
| 2803 | base_vha->host->irq = ha->pdev->irq; |
| 2804 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2805 | /* Initialized the timer */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2806 | qla2x00_start_timer(base_vha, qla2x00_timer, WATCH_INTERVAL); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2807 | ql_dbg(ql_dbg_init, base_vha, 0x00ef, |
| 2808 | "Started qla2x00_timer with " |
| 2809 | "interval=%d.\n", WATCH_INTERVAL); |
| 2810 | ql_dbg(ql_dbg_init, base_vha, 0x00f0, |
| 2811 | "Detected hba at address=%p.\n", |
| 2812 | ha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2813 | |
Arun Easi | e02587d | 2011-08-16 11:29:23 -0700 | [diff] [blame] | 2814 | if (IS_T10_PI_CAPABLE(ha) && ql2xenabledif) { |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 2815 | if (ha->fw_attributes & BIT_4) { |
Arun Easi | 9e522cd | 2012-08-22 14:21:31 -0400 | [diff] [blame] | 2816 | int prot = 0, guard; |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 2817 | base_vha->flags.difdix_supported = 1; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2818 | ql_dbg(ql_dbg_init, base_vha, 0x00f1, |
| 2819 | "Registering for DIF/DIX type 1 and 3 protection.\n"); |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 2820 | if (ql2xenabledif == 1) |
| 2821 | prot = SHOST_DIX_TYPE0_PROTECTION; |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 2822 | scsi_host_set_prot(host, |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 2823 | prot | SHOST_DIF_TYPE1_PROTECTION |
Arun Easi | 0c47087 | 2010-07-23 15:28:38 +0500 | [diff] [blame] | 2824 | | SHOST_DIF_TYPE2_PROTECTION |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 2825 | | SHOST_DIF_TYPE3_PROTECTION |
| 2826 | | SHOST_DIX_TYPE1_PROTECTION |
Arun Easi | 0c47087 | 2010-07-23 15:28:38 +0500 | [diff] [blame] | 2827 | | SHOST_DIX_TYPE2_PROTECTION |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 2828 | | SHOST_DIX_TYPE3_PROTECTION); |
Arun Easi | 9e522cd | 2012-08-22 14:21:31 -0400 | [diff] [blame] | 2829 | |
| 2830 | guard = SHOST_DIX_GUARD_CRC; |
| 2831 | |
| 2832 | if (IS_PI_IPGUARD_CAPABLE(ha) && |
| 2833 | (ql2xenabledif > 1 || IS_PI_DIFB_DIX0_CAPABLE(ha))) |
| 2834 | guard |= SHOST_DIX_GUARD_IP; |
| 2835 | |
| 2836 | scsi_host_set_guard(host, guard); |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 2837 | } else |
| 2838 | base_vha->flags.difdix_supported = 0; |
| 2839 | } |
| 2840 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2841 | ha->isp_ops->enable_intrs(ha); |
| 2842 | |
Armen Baloyan | 1fe19ee | 2013-08-27 01:37:41 -0400 | [diff] [blame] | 2843 | if (IS_QLAFX00(ha)) { |
| 2844 | ret = qlafx00_fx_disc(base_vha, |
| 2845 | &base_vha->hw->mr.fcport, FXDISC_GET_CONFIG_INFO); |
| 2846 | host->sg_tablesize = (ha->mr.extended_io_enabled) ? |
| 2847 | QLA_SG_ALL : 128; |
| 2848 | } |
| 2849 | |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2850 | ret = scsi_add_host(host, &pdev->dev); |
| 2851 | if (ret) |
| 2852 | goto probe_failed; |
| 2853 | |
Michael Reed | 1486400 | 2009-12-02 09:11:16 -0600 | [diff] [blame] | 2854 | base_vha->flags.init_done = 1; |
| 2855 | base_vha->flags.online = 1; |
Saurav Kashyap | edaa5c7 | 2014-04-11 16:54:14 -0400 | [diff] [blame] | 2856 | ha->prev_minidump_failed = 0; |
Michael Reed | 1486400 | 2009-12-02 09:11:16 -0600 | [diff] [blame] | 2857 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2858 | ql_dbg(ql_dbg_init, base_vha, 0x00f2, |
| 2859 | "Init done and hba is online.\n"); |
| 2860 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2861 | if (qla_ini_mode_enabled(base_vha)) |
| 2862 | scsi_scan_host(host); |
| 2863 | else |
| 2864 | ql_dbg(ql_dbg_init, base_vha, 0x0122, |
| 2865 | "skipping scsi_scan_host() for non-initiator port\n"); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2866 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2867 | qla2x00_alloc_sysfs_attr(base_vha); |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2868 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2869 | if (IS_QLAFX00(ha)) { |
| 2870 | ret = qlafx00_fx_disc(base_vha, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2871 | &base_vha->hw->mr.fcport, FXDISC_GET_PORT_INFO); |
| 2872 | |
| 2873 | /* Register system information */ |
| 2874 | ret = qlafx00_fx_disc(base_vha, |
| 2875 | &base_vha->hw->mr.fcport, FXDISC_REG_HOST_INFO); |
| 2876 | } |
| 2877 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2878 | qla2x00_init_host_attr(base_vha); |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2879 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2880 | qla2x00_dfs_setup(base_vha); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 2881 | |
Armen Baloyan | 03eb912 | 2013-10-30 03:38:22 -0400 | [diff] [blame] | 2882 | ql_log(ql_log_info, base_vha, 0x00fb, |
| 2883 | "QLogic %s - %s.\n", ha->model_number, ha->model_desc); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2884 | ql_log(ql_log_info, base_vha, 0x00fc, |
| 2885 | "ISP%04X: %s @ %s hdma%c host#=%ld fw=%s.\n", |
| 2886 | pdev->device, ha->isp_ops->pci_info_str(base_vha, pci_info), |
| 2887 | pci_name(pdev), ha->flags.enable_64bit_addressing ? '+' : '-', |
| 2888 | base_vha->host_no, |
Himanshu Madhani | df57cab | 2014-09-25 05:16:46 -0400 | [diff] [blame] | 2889 | 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] | 2890 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2891 | qlt_add_target(ha, base_vha); |
| 2892 | |
Joe Lawrence | 6b38397 | 2014-08-26 17:12:29 -0400 | [diff] [blame] | 2893 | clear_bit(PFLG_DRIVER_PROBING, &base_vha->pci_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2894 | return 0; |
| 2895 | |
Anirban Chakraborty | 6e9f21f | 2009-01-22 09:45:28 -0800 | [diff] [blame] | 2896 | probe_init_failed: |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2897 | qla2x00_free_req_que(ha, req); |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 2898 | ha->req_q_map[0] = NULL; |
| 2899 | clear_bit(0, ha->req_qid_map); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2900 | qla2x00_free_rsp_que(ha, rsp); |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 2901 | ha->rsp_q_map[0] = NULL; |
| 2902 | clear_bit(0, ha->rsp_qid_map); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2903 | ha->max_req_queues = ha->max_rsp_queues = 0; |
Anirban Chakraborty | 6e9f21f | 2009-01-22 09:45:28 -0800 | [diff] [blame] | 2904 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2905 | probe_failed: |
Andrew Vasquez | b997876 | 2009-03-24 09:08:05 -0700 | [diff] [blame] | 2906 | if (base_vha->timer_active) |
| 2907 | qla2x00_stop_timer(base_vha); |
| 2908 | base_vha->flags.online = 0; |
| 2909 | if (ha->dpc_thread) { |
| 2910 | struct task_struct *t = ha->dpc_thread; |
| 2911 | |
| 2912 | ha->dpc_thread = NULL; |
| 2913 | kthread_stop(t); |
| 2914 | } |
| 2915 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2916 | qla2x00_free_device(base_vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2917 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2918 | scsi_host_put(base_vha->host); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2919 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2920 | probe_hw_failed: |
Joe Lawrence | 1a2fbf1 | 2014-08-26 17:11:18 -0400 | [diff] [blame] | 2921 | qla2x00_clear_drv_active(ha); |
| 2922 | |
Saurav Kashyap | 0a63ad1 | 2012-11-21 02:40:43 -0500 | [diff] [blame] | 2923 | iospace_config_failed: |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 2924 | if (IS_P3P_TYPE(ha)) { |
Saurav Kashyap | 0a63ad1 | 2012-11-21 02:40:43 -0500 | [diff] [blame] | 2925 | if (!ha->nx_pcibase) |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2926 | iounmap((device_reg_t *)ha->nx_pcibase); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2927 | if (!ql2xdbwr) |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 2928 | iounmap((device_reg_t *)ha->nxdb_wr_ptr); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2929 | } else { |
| 2930 | if (ha->iobase) |
| 2931 | iounmap(ha->iobase); |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 2932 | if (ha->cregbase) |
| 2933 | iounmap(ha->cregbase); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2934 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2935 | pci_release_selected_regions(ha->pdev, ha->bars); |
| 2936 | kfree(ha); |
| 2937 | ha = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2938 | |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2939 | probe_out: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2940 | pci_disable_device(pdev); |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2941 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2942 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2943 | |
Adrian Bunk | 4c993f7 | 2008-01-14 00:55:16 -0800 | [diff] [blame] | 2944 | static void |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 2945 | qla2x00_shutdown(struct pci_dev *pdev) |
| 2946 | { |
| 2947 | scsi_qla_host_t *vha; |
| 2948 | struct qla_hw_data *ha; |
| 2949 | |
Masanari Iida | 552f3f9 | 2013-02-08 01:57:44 -0500 | [diff] [blame] | 2950 | if (!atomic_read(&pdev->enable_cnt)) |
| 2951 | return; |
| 2952 | |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 2953 | vha = pci_get_drvdata(pdev); |
| 2954 | ha = vha->hw; |
| 2955 | |
Armen Baloyan | 4247934 | 2013-08-27 01:37:37 -0400 | [diff] [blame] | 2956 | /* Notify ISPFX00 firmware */ |
| 2957 | if (IS_QLAFX00(ha)) |
| 2958 | qlafx00_driver_shutdown(vha, 20); |
| 2959 | |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 2960 | /* Turn-off FCE trace */ |
| 2961 | if (ha->flags.fce_enabled) { |
| 2962 | qla2x00_disable_fce_trace(vha, NULL, NULL); |
| 2963 | ha->flags.fce_enabled = 0; |
| 2964 | } |
| 2965 | |
| 2966 | /* Turn-off EFT trace */ |
| 2967 | if (ha->eft) |
| 2968 | qla2x00_disable_eft_trace(vha); |
| 2969 | |
| 2970 | /* Stop currently executing firmware. */ |
| 2971 | qla2x00_try_to_stop_firmware(vha); |
| 2972 | |
| 2973 | /* Turn adapter off line */ |
| 2974 | vha->flags.online = 0; |
| 2975 | |
| 2976 | /* turn-off interrupts on the card */ |
| 2977 | if (ha->interrupts_on) { |
| 2978 | vha->flags.init_done = 0; |
| 2979 | ha->isp_ops->disable_intrs(ha); |
| 2980 | } |
| 2981 | |
| 2982 | qla2x00_free_irqs(vha); |
| 2983 | |
| 2984 | qla2x00_free_fw_dump(ha); |
Chad Dupuis | 61d41f6 | 2014-09-25 05:17:02 -0400 | [diff] [blame] | 2985 | |
| 2986 | pci_disable_pcie_error_reporting(pdev); |
| 2987 | pci_disable_device(pdev); |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 2988 | } |
| 2989 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 2990 | /* Deletes all the virtual ports for a given ha */ |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 2991 | static void |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 2992 | 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] | 2993 | { |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 2994 | scsi_qla_host_t *vha; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 2995 | unsigned long flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2996 | |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 2997 | mutex_lock(&ha->vport_lock); |
| 2998 | while (ha->cur_vport_count) { |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 2999 | spin_lock_irqsave(&ha->vport_slock, flags); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3000 | |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 3001 | BUG_ON(base_vha->list.next == &ha->vp_list); |
| 3002 | /* This assumes first entry in ha->vp_list is always base vha */ |
| 3003 | 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] | 3004 | scsi_host_get(vha->host); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3005 | |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 3006 | spin_unlock_irqrestore(&ha->vport_slock, flags); |
| 3007 | mutex_unlock(&ha->vport_lock); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3008 | |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 3009 | fc_vport_terminate(vha->fc_vport); |
| 3010 | scsi_host_put(vha->host); |
| 3011 | |
| 3012 | mutex_lock(&ha->vport_lock); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3013 | } |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 3014 | mutex_unlock(&ha->vport_lock); |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3015 | } |
Andrew Vasquez | c795c1e | 2008-08-13 21:37:01 -0700 | [diff] [blame] | 3016 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3017 | /* Stops all deferred work threads */ |
| 3018 | static void |
| 3019 | qla2x00_destroy_deferred_work(struct qla_hw_data *ha) |
| 3020 | { |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 3021 | /* Flush the work queue and remove it */ |
| 3022 | if (ha->wq) { |
| 3023 | flush_workqueue(ha->wq); |
| 3024 | destroy_workqueue(ha->wq); |
| 3025 | ha->wq = NULL; |
| 3026 | } |
| 3027 | |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 3028 | /* Cancel all work and destroy DPC workqueues */ |
| 3029 | if (ha->dpc_lp_wq) { |
| 3030 | cancel_work_sync(&ha->idc_aen); |
| 3031 | destroy_workqueue(ha->dpc_lp_wq); |
| 3032 | ha->dpc_lp_wq = NULL; |
| 3033 | } |
| 3034 | |
| 3035 | if (ha->dpc_hp_wq) { |
| 3036 | cancel_work_sync(&ha->nic_core_reset); |
| 3037 | cancel_work_sync(&ha->idc_state_handler); |
| 3038 | cancel_work_sync(&ha->nic_core_unrecoverable); |
| 3039 | destroy_workqueue(ha->dpc_hp_wq); |
| 3040 | ha->dpc_hp_wq = NULL; |
| 3041 | } |
| 3042 | |
Andrew Vasquez | b997876 | 2009-03-24 09:08:05 -0700 | [diff] [blame] | 3043 | /* Kill the kernel thread for this host */ |
| 3044 | if (ha->dpc_thread) { |
| 3045 | struct task_struct *t = ha->dpc_thread; |
| 3046 | |
| 3047 | /* |
| 3048 | * qla2xxx_wake_dpc checks for ->dpc_thread |
| 3049 | * so we need to zero it out. |
| 3050 | */ |
| 3051 | ha->dpc_thread = NULL; |
| 3052 | kthread_stop(t); |
| 3053 | } |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3054 | } |
Andrew Vasquez | b997876 | 2009-03-24 09:08:05 -0700 | [diff] [blame] | 3055 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3056 | static void |
| 3057 | qla2x00_unmap_iobases(struct qla_hw_data *ha) |
| 3058 | { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3059 | if (IS_QLA82XX(ha)) { |
Giridhar Malavali | b963752 | 2010-05-28 15:08:15 -0700 | [diff] [blame] | 3060 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3061 | iounmap((device_reg_t *)ha->nx_pcibase); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3062 | if (!ql2xdbwr) |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3063 | iounmap((device_reg_t *)ha->nxdb_wr_ptr); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3064 | } else { |
| 3065 | if (ha->iobase) |
| 3066 | iounmap(ha->iobase); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3067 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3068 | if (ha->cregbase) |
| 3069 | iounmap(ha->cregbase); |
| 3070 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3071 | if (ha->mqiobase) |
| 3072 | iounmap(ha->mqiobase); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3073 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3074 | if ((IS_QLA83XX(ha) || IS_QLA27XX(ha)) && ha->msixbase) |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3075 | iounmap(ha->msixbase); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3076 | } |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3077 | } |
| 3078 | |
| 3079 | static void |
Joe Lawrence | db7157d | 2014-08-26 17:10:41 -0400 | [diff] [blame] | 3080 | qla2x00_clear_drv_active(struct qla_hw_data *ha) |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3081 | { |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3082 | if (IS_QLA8044(ha)) { |
| 3083 | qla8044_idc_lock(ha); |
Saurav Kashyap | c41afc9 | 2013-11-07 02:54:56 -0500 | [diff] [blame] | 3084 | qla8044_clear_drv_active(ha); |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3085 | qla8044_idc_unlock(ha); |
| 3086 | } else if (IS_QLA82XX(ha)) { |
| 3087 | qla82xx_idc_lock(ha); |
| 3088 | qla82xx_clear_drv_active(ha); |
| 3089 | qla82xx_idc_unlock(ha); |
| 3090 | } |
| 3091 | } |
| 3092 | |
| 3093 | static void |
| 3094 | qla2x00_remove_one(struct pci_dev *pdev) |
| 3095 | { |
| 3096 | scsi_qla_host_t *base_vha; |
| 3097 | struct qla_hw_data *ha; |
| 3098 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3099 | base_vha = pci_get_drvdata(pdev); |
| 3100 | ha = base_vha->hw; |
| 3101 | |
Joe Lawrence | beb9e31 | 2014-08-26 17:12:14 -0400 | [diff] [blame] | 3102 | /* Indicate device removal to prevent future board_disable and wait |
| 3103 | * until any pending board_disable has completed. */ |
| 3104 | set_bit(PFLG_DRIVER_REMOVING, &base_vha->pci_flags); |
| 3105 | cancel_work_sync(&ha->board_disable); |
| 3106 | |
| 3107 | /* |
| 3108 | * If the PCI device is disabled then there was a PCI-disconnect and |
| 3109 | * qla2x00_disable_board_on_pci_error has taken care of most of the |
| 3110 | * resources. |
| 3111 | */ |
| 3112 | if (!atomic_read(&pdev->enable_cnt)) { |
| 3113 | scsi_host_put(base_vha->host); |
| 3114 | kfree(ha); |
| 3115 | pci_set_drvdata(pdev, NULL); |
| 3116 | return; |
| 3117 | } |
| 3118 | |
Sawan Chandak | 638a1a0 | 2014-04-11 16:54:38 -0400 | [diff] [blame] | 3119 | qla2x00_wait_for_hba_ready(base_vha); |
| 3120 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3121 | set_bit(UNLOADING, &base_vha->dpc_flags); |
| 3122 | |
| 3123 | if (IS_QLAFX00(ha)) |
| 3124 | qlafx00_driver_shutdown(base_vha, 20); |
| 3125 | |
| 3126 | qla2x00_delete_all_vps(ha, base_vha); |
| 3127 | |
| 3128 | if (IS_QLA8031(ha)) { |
| 3129 | ql_dbg(ql_dbg_p3p, base_vha, 0xb07e, |
| 3130 | "Clearing fcoe driver presence.\n"); |
| 3131 | if (qla83xx_clear_drv_presence(base_vha) != QLA_SUCCESS) |
| 3132 | ql_dbg(ql_dbg_p3p, base_vha, 0xb079, |
| 3133 | "Error while clearing DRV-Presence.\n"); |
| 3134 | } |
| 3135 | |
| 3136 | qla2x00_abort_all_cmds(base_vha, DID_NO_CONNECT << 16); |
| 3137 | |
| 3138 | qla2x00_dfs_remove(base_vha); |
| 3139 | |
| 3140 | qla84xx_put_chip(base_vha); |
| 3141 | |
Himanshu Madhani | 2d5a4c3 | 2014-09-25 05:16:55 -0400 | [diff] [blame] | 3142 | /* Laser should be disabled only for ISP2031 */ |
| 3143 | if (IS_QLA2031(ha)) |
| 3144 | qla83xx_disable_laser(base_vha); |
| 3145 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3146 | /* Disable timer */ |
| 3147 | if (base_vha->timer_active) |
| 3148 | qla2x00_stop_timer(base_vha); |
| 3149 | |
| 3150 | base_vha->flags.online = 0; |
| 3151 | |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 3152 | /* free DMA memory */ |
| 3153 | if (ha->exlogin_buf) |
| 3154 | qla2x00_free_exlogin_buffer(ha); |
| 3155 | |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 3156 | /* free DMA memory */ |
| 3157 | if (ha->exchoffld_buf) |
| 3158 | qla2x00_free_exchoffld_buffer(ha); |
| 3159 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3160 | qla2x00_destroy_deferred_work(ha); |
| 3161 | |
| 3162 | qlt_remove_target(ha, base_vha); |
| 3163 | |
| 3164 | qla2x00_free_sysfs_attr(base_vha, true); |
| 3165 | |
| 3166 | fc_remove_host(base_vha->host); |
| 3167 | |
| 3168 | scsi_remove_host(base_vha->host); |
| 3169 | |
| 3170 | qla2x00_free_device(base_vha); |
| 3171 | |
Joe Lawrence | db7157d | 2014-08-26 17:10:41 -0400 | [diff] [blame] | 3172 | qla2x00_clear_drv_active(ha); |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3173 | |
Arun Easi | d2749ff | 2014-09-25 05:16:51 -0400 | [diff] [blame] | 3174 | scsi_host_put(base_vha->host); |
| 3175 | |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3176 | qla2x00_unmap_iobases(ha); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3177 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3178 | pci_release_selected_regions(ha->pdev, ha->bars); |
| 3179 | kfree(ha); |
| 3180 | ha = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3181 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 3182 | pci_disable_pcie_error_reporting(pdev); |
| 3183 | |
Bernhard Walle | 665db93 | 2007-03-28 00:49:49 +0200 | [diff] [blame] | 3184 | pci_disable_device(pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3185 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3186 | |
| 3187 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3188 | qla2x00_free_device(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3189 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3190 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3191 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 3192 | qla2x00_abort_all_cmds(vha, DID_NO_CONNECT << 16); |
| 3193 | |
| 3194 | /* Disable timer */ |
| 3195 | if (vha->timer_active) |
| 3196 | qla2x00_stop_timer(vha); |
| 3197 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 3198 | qla25xx_delete_queues(vha); |
Chad Dupuis | fe1b806 | 2013-10-30 03:38:15 -0400 | [diff] [blame] | 3199 | |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3200 | if (ha->flags.fce_enabled) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3201 | qla2x00_disable_fce_trace(vha, NULL, NULL); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 3202 | |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3203 | if (ha->eft) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3204 | qla2x00_disable_eft_trace(vha); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 3205 | |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3206 | /* Stop currently executing firmware. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3207 | qla2x00_try_to_stop_firmware(vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3208 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 3209 | vha->flags.online = 0; |
| 3210 | |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3211 | /* turn-off interrupts on the card */ |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3212 | if (ha->interrupts_on) { |
| 3213 | vha->flags.init_done = 0; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 3214 | ha->isp_ops->disable_intrs(ha); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3215 | } |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3216 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3217 | qla2x00_free_irqs(vha); |
| 3218 | |
Chad Dupuis | 8867048 | 2010-07-23 15:28:30 +0500 | [diff] [blame] | 3219 | qla2x00_free_fcports(vha); |
| 3220 | |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 3221 | qla2x00_mem_free(ha); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3222 | |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 3223 | qla82xx_md_free(vha); |
| 3224 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3225 | qla2x00_free_queues(ha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3226 | } |
| 3227 | |
Chad Dupuis | 8867048 | 2010-07-23 15:28:30 +0500 | [diff] [blame] | 3228 | void qla2x00_free_fcports(struct scsi_qla_host *vha) |
| 3229 | { |
| 3230 | fc_port_t *fcport, *tfcport; |
| 3231 | |
| 3232 | list_for_each_entry_safe(fcport, tfcport, &vha->vp_fcports, list) { |
| 3233 | list_del(&fcport->list); |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 3234 | qla2x00_clear_loop_id(fcport); |
Chad Dupuis | 8867048 | 2010-07-23 15:28:30 +0500 | [diff] [blame] | 3235 | kfree(fcport); |
| 3236 | fcport = NULL; |
| 3237 | } |
| 3238 | } |
| 3239 | |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3240 | static inline void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3241 | 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] | 3242 | int defer) |
| 3243 | { |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3244 | struct fc_rport *rport; |
Andrew Vasquez | 67becc0 | 2009-08-25 11:36:20 -0700 | [diff] [blame] | 3245 | scsi_qla_host_t *base_vha; |
Madhuranath Iyengar | 044d78e | 2011-01-28 15:17:56 -0800 | [diff] [blame] | 3246 | unsigned long flags; |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3247 | |
| 3248 | if (!fcport->rport) |
| 3249 | return; |
| 3250 | |
| 3251 | rport = fcport->rport; |
| 3252 | if (defer) { |
Andrew Vasquez | 67becc0 | 2009-08-25 11:36:20 -0700 | [diff] [blame] | 3253 | base_vha = pci_get_drvdata(vha->hw->pdev); |
Madhuranath Iyengar | 044d78e | 2011-01-28 15:17:56 -0800 | [diff] [blame] | 3254 | spin_lock_irqsave(vha->host->host_lock, flags); |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3255 | fcport->drport = rport; |
Madhuranath Iyengar | 044d78e | 2011-01-28 15:17:56 -0800 | [diff] [blame] | 3256 | spin_unlock_irqrestore(vha->host->host_lock, flags); |
Alexei Potashnik | df67327 | 2015-07-14 16:00:46 -0400 | [diff] [blame] | 3257 | qlt_do_generation_tick(vha, &base_vha->total_fcport_update_gen); |
Andrew Vasquez | 67becc0 | 2009-08-25 11:36:20 -0700 | [diff] [blame] | 3258 | set_bit(FCPORT_UPDATE_NEEDED, &base_vha->dpc_flags); |
| 3259 | qla2xxx_wake_dpc(base_vha); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3260 | } else { |
Alexei Potashnik | df67327 | 2015-07-14 16:00:46 -0400 | [diff] [blame] | 3261 | int now; |
Alexei Potashnik | d20ed91 | 2015-07-14 16:00:47 -0400 | [diff] [blame] | 3262 | if (rport) |
| 3263 | fc_remote_port_delete(rport); |
Alexei Potashnik | df67327 | 2015-07-14 16:00:46 -0400 | [diff] [blame] | 3264 | qlt_do_generation_tick(vha, &now); |
| 3265 | qlt_fc_port_deleted(vha, fcport, now); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3266 | } |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 3267 | } |
| 3268 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3269 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3270 | * qla2x00_mark_device_lost Updates fcport state when device goes offline. |
| 3271 | * |
| 3272 | * Input: ha = adapter block pointer. fcport = port structure pointer. |
| 3273 | * |
| 3274 | * Return: None. |
| 3275 | * |
| 3276 | * Context: |
| 3277 | */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3278 | 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] | 3279 | int do_login, int defer) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3280 | { |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 3281 | if (IS_QLAFX00(vha->hw)) { |
| 3282 | qla2x00_set_fcport_state(fcport, FCS_DEVICE_LOST); |
| 3283 | qla2x00_schedule_rport_del(vha, fcport, defer); |
| 3284 | return; |
| 3285 | } |
| 3286 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3287 | if (atomic_read(&fcport->state) == FCS_ONLINE && |
Joe Carnuccio | c6d39e2 | 2012-05-15 14:34:20 -0400 | [diff] [blame] | 3288 | vha->vp_idx == fcport->vha->vp_idx) { |
Chad Dupuis | ec426e1 | 2011-03-30 11:46:32 -0700 | [diff] [blame] | 3289 | qla2x00_set_fcport_state(fcport, FCS_DEVICE_LOST); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3290 | qla2x00_schedule_rport_del(vha, fcport, defer); |
| 3291 | } |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 3292 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3293 | * We may need to retry the login, so don't change the state of the |
| 3294 | * port but do the retries. |
| 3295 | */ |
| 3296 | if (atomic_read(&fcport->state) != FCS_DEVICE_DEAD) |
Chad Dupuis | ec426e1 | 2011-03-30 11:46:32 -0700 | [diff] [blame] | 3297 | qla2x00_set_fcport_state(fcport, FCS_DEVICE_LOST); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3298 | |
| 3299 | if (!do_login) |
| 3300 | return; |
| 3301 | |
Arun Easi | a1d0285 | 2015-08-04 13:38:02 -0400 | [diff] [blame] | 3302 | set_bit(RELOGIN_NEEDED, &vha->dpc_flags); |
| 3303 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3304 | if (fcport->login_retry == 0) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3305 | fcport->login_retry = vha->hw->login_retry_count; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3306 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3307 | ql_dbg(ql_dbg_disc, vha, 0x2067, |
Oleksandr Khoshaba | 7b83355 | 2013-08-27 01:37:27 -0400 | [diff] [blame] | 3308 | "Port login retry %8phN, id = 0x%04x retry cnt=%d.\n", |
| 3309 | fcport->port_name, fcport->loop_id, fcport->login_retry); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3310 | } |
| 3311 | } |
| 3312 | |
| 3313 | /* |
| 3314 | * qla2x00_mark_all_devices_lost |
| 3315 | * Updates fcport state when device goes offline. |
| 3316 | * |
| 3317 | * Input: |
| 3318 | * ha = adapter block pointer. |
| 3319 | * fcport = port structure pointer. |
| 3320 | * |
| 3321 | * Return: |
| 3322 | * None. |
| 3323 | * |
| 3324 | * Context: |
| 3325 | */ |
| 3326 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3327 | qla2x00_mark_all_devices_lost(scsi_qla_host_t *vha, int defer) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3328 | { |
| 3329 | fc_port_t *fcport; |
| 3330 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3331 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
Joe Carnuccio | c6d39e2 | 2012-05-15 14:34:20 -0400 | [diff] [blame] | 3332 | if (vha->vp_idx != 0 && vha->vp_idx != fcport->vha->vp_idx) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3333 | continue; |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 3334 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3335 | /* |
| 3336 | * No point in marking the device as lost, if the device is |
| 3337 | * already DEAD. |
| 3338 | */ |
| 3339 | if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD) |
| 3340 | continue; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3341 | if (atomic_read(&fcport->state) == FCS_ONLINE) { |
Chad Dupuis | ec426e1 | 2011-03-30 11:46:32 -0700 | [diff] [blame] | 3342 | qla2x00_set_fcport_state(fcport, FCS_DEVICE_LOST); |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 3343 | if (defer) |
| 3344 | qla2x00_schedule_rport_del(vha, fcport, defer); |
Joe Carnuccio | c6d39e2 | 2012-05-15 14:34:20 -0400 | [diff] [blame] | 3345 | else if (vha->vp_idx == fcport->vha->vp_idx) |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 3346 | qla2x00_schedule_rport_del(vha, fcport, defer); |
| 3347 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3348 | } |
| 3349 | } |
| 3350 | |
| 3351 | /* |
| 3352 | * qla2x00_mem_alloc |
| 3353 | * Allocates adapter memory. |
| 3354 | * |
| 3355 | * Returns: |
| 3356 | * 0 = success. |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3357 | * !0 = failure. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3358 | */ |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3359 | static int |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3360 | qla2x00_mem_alloc(struct qla_hw_data *ha, uint16_t req_len, uint16_t rsp_len, |
| 3361 | struct req_que **req, struct rsp_que **rsp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3362 | { |
| 3363 | char name[16]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3364 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3365 | 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] | 3366 | &ha->init_cb_dma, GFP_KERNEL); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3367 | if (!ha->init_cb) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3368 | goto fail; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3369 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3370 | if (qlt_mem_alloc(ha) < 0) |
| 3371 | goto fail_free_init_cb; |
| 3372 | |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 3373 | ha->gid_list = dma_alloc_coherent(&ha->pdev->dev, |
| 3374 | qla2x00_gid_list_size(ha), &ha->gid_list_dma, GFP_KERNEL); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3375 | if (!ha->gid_list) |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3376 | goto fail_free_tgt_mem; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3377 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3378 | ha->srb_mempool = mempool_create_slab_pool(SRB_MIN_REQ, srb_cachep); |
| 3379 | if (!ha->srb_mempool) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3380 | goto fail_free_gid_list; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3381 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 3382 | if (IS_P3P_TYPE(ha)) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3383 | /* Allocate cache for CT6 Ctx. */ |
| 3384 | if (!ctx_cachep) { |
| 3385 | ctx_cachep = kmem_cache_create("qla2xxx_ctx", |
| 3386 | sizeof(struct ct6_dsd), 0, |
| 3387 | SLAB_HWCACHE_ALIGN, NULL); |
| 3388 | if (!ctx_cachep) |
| 3389 | goto fail_free_gid_list; |
| 3390 | } |
| 3391 | ha->ctx_mempool = mempool_create_slab_pool(SRB_MIN_REQ, |
| 3392 | ctx_cachep); |
| 3393 | if (!ha->ctx_mempool) |
| 3394 | goto fail_free_srb_mempool; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3395 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0021, |
| 3396 | "ctx_cachep=%p ctx_mempool=%p.\n", |
| 3397 | ctx_cachep, ha->ctx_mempool); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3398 | } |
| 3399 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3400 | /* Get memory for cached NVRAM */ |
| 3401 | ha->nvram = kzalloc(MAX_NVRAM_SIZE, GFP_KERNEL); |
| 3402 | if (!ha->nvram) |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3403 | goto fail_free_ctx_mempool; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3404 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3405 | snprintf(name, sizeof(name), "%s_%d", QLA2XXX_DRIVER_NAME, |
| 3406 | ha->pdev->device); |
| 3407 | ha->s_dma_pool = dma_pool_create(name, &ha->pdev->dev, |
| 3408 | DMA_POOL_SIZE, 8, 0); |
| 3409 | if (!ha->s_dma_pool) |
| 3410 | goto fail_free_nvram; |
| 3411 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3412 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0022, |
| 3413 | "init_cb=%p gid_list=%p, srb_mempool=%p s_dma_pool=%p.\n", |
| 3414 | ha->init_cb, ha->gid_list, ha->srb_mempool, ha->s_dma_pool); |
| 3415 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 3416 | if (IS_P3P_TYPE(ha) || ql2xenabledif) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3417 | ha->dl_dma_pool = dma_pool_create(name, &ha->pdev->dev, |
| 3418 | DSD_LIST_DMA_POOL_SIZE, 8, 0); |
| 3419 | if (!ha->dl_dma_pool) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3420 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0023, |
| 3421 | "Failed to allocate memory for dl_dma_pool.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3422 | goto fail_s_dma_pool; |
| 3423 | } |
| 3424 | |
| 3425 | ha->fcp_cmnd_dma_pool = dma_pool_create(name, &ha->pdev->dev, |
| 3426 | FCP_CMND_DMA_POOL_SIZE, 8, 0); |
| 3427 | if (!ha->fcp_cmnd_dma_pool) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3428 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0024, |
| 3429 | "Failed to allocate memory for fcp_cmnd_dma_pool.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3430 | goto fail_dl_dma_pool; |
| 3431 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3432 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0025, |
| 3433 | "dl_dma_pool=%p fcp_cmnd_dma_pool=%p.\n", |
| 3434 | ha->dl_dma_pool, ha->fcp_cmnd_dma_pool); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3435 | } |
| 3436 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3437 | /* Allocate memory for SNS commands */ |
| 3438 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3439 | /* Get consistent memory allocated for SNS commands */ |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3440 | ha->sns_cmd = dma_alloc_coherent(&ha->pdev->dev, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3441 | sizeof(struct sns_cmd_pkt), &ha->sns_cmd_dma, GFP_KERNEL); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3442 | if (!ha->sns_cmd) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3443 | goto fail_dma_pool; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3444 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0026, |
Joe Perches | d8424f6 | 2011-11-18 09:03:06 -0800 | [diff] [blame] | 3445 | "sns_cmd: %p.\n", ha->sns_cmd); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3446 | } else { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3447 | /* Get consistent memory allocated for MS IOCB */ |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3448 | ha->ms_iocb = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3449 | &ha->ms_iocb_dma); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3450 | if (!ha->ms_iocb) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3451 | goto fail_dma_pool; |
| 3452 | /* Get consistent memory allocated for CT SNS commands */ |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3453 | ha->ct_sns = dma_alloc_coherent(&ha->pdev->dev, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3454 | sizeof(struct ct_sns_pkt), &ha->ct_sns_dma, GFP_KERNEL); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3455 | if (!ha->ct_sns) |
| 3456 | goto fail_free_ms_iocb; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3457 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0027, |
| 3458 | "ms_iocb=%p ct_sns=%p.\n", |
| 3459 | ha->ms_iocb, ha->ct_sns); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3460 | } |
| 3461 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3462 | /* Allocate memory for request ring */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3463 | *req = kzalloc(sizeof(struct req_que), GFP_KERNEL); |
| 3464 | if (!*req) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3465 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0028, |
| 3466 | "Failed to allocate memory for req.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3467 | goto fail_req; |
| 3468 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3469 | (*req)->length = req_len; |
| 3470 | (*req)->ring = dma_alloc_coherent(&ha->pdev->dev, |
| 3471 | ((*req)->length + 1) * sizeof(request_t), |
| 3472 | &(*req)->dma, GFP_KERNEL); |
| 3473 | if (!(*req)->ring) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3474 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0029, |
| 3475 | "Failed to allocate memory for req_ring.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3476 | goto fail_req_ring; |
| 3477 | } |
| 3478 | /* Allocate memory for response ring */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3479 | *rsp = kzalloc(sizeof(struct rsp_que), GFP_KERNEL); |
| 3480 | if (!*rsp) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3481 | ql_log_pci(ql_log_fatal, ha->pdev, 0x002a, |
| 3482 | "Failed to allocate memory for rsp.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3483 | goto fail_rsp; |
| 3484 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3485 | (*rsp)->hw = ha; |
| 3486 | (*rsp)->length = rsp_len; |
| 3487 | (*rsp)->ring = dma_alloc_coherent(&ha->pdev->dev, |
| 3488 | ((*rsp)->length + 1) * sizeof(response_t), |
| 3489 | &(*rsp)->dma, GFP_KERNEL); |
| 3490 | if (!(*rsp)->ring) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3491 | ql_log_pci(ql_log_fatal, ha->pdev, 0x002b, |
| 3492 | "Failed to allocate memory for rsp_ring.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3493 | goto fail_rsp_ring; |
| 3494 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3495 | (*req)->rsp = *rsp; |
| 3496 | (*rsp)->req = *req; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3497 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x002c, |
| 3498 | "req=%p req->length=%d req->ring=%p rsp=%p " |
| 3499 | "rsp->length=%d rsp->ring=%p.\n", |
| 3500 | *req, (*req)->length, (*req)->ring, *rsp, (*rsp)->length, |
| 3501 | (*rsp)->ring); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3502 | /* Allocate memory for NVRAM data for vports */ |
| 3503 | if (ha->nvram_npiv_size) { |
| 3504 | ha->npiv_info = kzalloc(sizeof(struct qla_npiv_entry) * |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3505 | ha->nvram_npiv_size, GFP_KERNEL); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3506 | if (!ha->npiv_info) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3507 | ql_log_pci(ql_log_fatal, ha->pdev, 0x002d, |
| 3508 | "Failed to allocate memory for npiv_info.\n"); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3509 | goto fail_npiv_info; |
| 3510 | } |
| 3511 | } else |
| 3512 | ha->npiv_info = NULL; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3513 | |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 3514 | /* Get consistent memory allocated for EX-INIT-CB. */ |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3515 | if (IS_CNA_CAPABLE(ha) || IS_QLA2031(ha) || IS_QLA27XX(ha)) { |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 3516 | ha->ex_init_cb = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, |
| 3517 | &ha->ex_init_cb_dma); |
| 3518 | if (!ha->ex_init_cb) |
| 3519 | goto fail_ex_init_cb; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3520 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x002e, |
| 3521 | "ex_init_cb=%p.\n", ha->ex_init_cb); |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 3522 | } |
| 3523 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3524 | INIT_LIST_HEAD(&ha->gbl_dsd_list); |
| 3525 | |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 3526 | /* Get consistent memory allocated for Async Port-Database. */ |
| 3527 | if (!IS_FWI2_CAPABLE(ha)) { |
| 3528 | ha->async_pd = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, |
| 3529 | &ha->async_pd_dma); |
| 3530 | if (!ha->async_pd) |
| 3531 | goto fail_async_pd; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3532 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x002f, |
| 3533 | "async_pd=%p.\n", ha->async_pd); |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 3534 | } |
| 3535 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3536 | INIT_LIST_HEAD(&ha->vp_list); |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 3537 | |
| 3538 | /* Allocate memory for our loop_id bitmap */ |
| 3539 | ha->loop_id_map = kzalloc(BITS_TO_LONGS(LOOPID_MAP_SIZE) * sizeof(long), |
| 3540 | GFP_KERNEL); |
| 3541 | if (!ha->loop_id_map) |
| 3542 | goto fail_async_pd; |
| 3543 | else { |
| 3544 | qla2x00_set_reserved_loop_ids(ha); |
| 3545 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0123, |
Dan Carpenter | b2a72ec | 2014-01-21 10:00:10 +0300 | [diff] [blame] | 3546 | "loop_id_map=%p.\n", ha->loop_id_map); |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 3547 | } |
| 3548 | |
Dan Carpenter | b2a72ec | 2014-01-21 10:00:10 +0300 | [diff] [blame] | 3549 | return 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3550 | |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 3551 | fail_async_pd: |
| 3552 | 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] | 3553 | fail_ex_init_cb: |
| 3554 | kfree(ha->npiv_info); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3555 | fail_npiv_info: |
| 3556 | dma_free_coherent(&ha->pdev->dev, ((*rsp)->length + 1) * |
| 3557 | sizeof(response_t), (*rsp)->ring, (*rsp)->dma); |
| 3558 | (*rsp)->ring = NULL; |
| 3559 | (*rsp)->dma = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3560 | fail_rsp_ring: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3561 | kfree(*rsp); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3562 | fail_rsp: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3563 | dma_free_coherent(&ha->pdev->dev, ((*req)->length + 1) * |
| 3564 | sizeof(request_t), (*req)->ring, (*req)->dma); |
| 3565 | (*req)->ring = NULL; |
| 3566 | (*req)->dma = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3567 | fail_req_ring: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3568 | kfree(*req); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3569 | fail_req: |
| 3570 | dma_free_coherent(&ha->pdev->dev, sizeof(struct ct_sns_pkt), |
| 3571 | ha->ct_sns, ha->ct_sns_dma); |
| 3572 | ha->ct_sns = NULL; |
| 3573 | ha->ct_sns_dma = 0; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3574 | fail_free_ms_iocb: |
| 3575 | dma_pool_free(ha->s_dma_pool, ha->ms_iocb, ha->ms_iocb_dma); |
| 3576 | ha->ms_iocb = NULL; |
| 3577 | ha->ms_iocb_dma = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3578 | fail_dma_pool: |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 3579 | if (IS_QLA82XX(ha) || ql2xenabledif) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3580 | dma_pool_destroy(ha->fcp_cmnd_dma_pool); |
| 3581 | ha->fcp_cmnd_dma_pool = NULL; |
| 3582 | } |
| 3583 | fail_dl_dma_pool: |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 3584 | if (IS_QLA82XX(ha) || ql2xenabledif) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3585 | dma_pool_destroy(ha->dl_dma_pool); |
| 3586 | ha->dl_dma_pool = NULL; |
| 3587 | } |
| 3588 | fail_s_dma_pool: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3589 | dma_pool_destroy(ha->s_dma_pool); |
| 3590 | ha->s_dma_pool = NULL; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3591 | fail_free_nvram: |
| 3592 | kfree(ha->nvram); |
| 3593 | ha->nvram = NULL; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3594 | fail_free_ctx_mempool: |
| 3595 | mempool_destroy(ha->ctx_mempool); |
| 3596 | ha->ctx_mempool = NULL; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3597 | fail_free_srb_mempool: |
| 3598 | mempool_destroy(ha->srb_mempool); |
| 3599 | ha->srb_mempool = NULL; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3600 | fail_free_gid_list: |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 3601 | dma_free_coherent(&ha->pdev->dev, qla2x00_gid_list_size(ha), |
| 3602 | ha->gid_list, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3603 | ha->gid_list_dma); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3604 | ha->gid_list = NULL; |
| 3605 | ha->gid_list_dma = 0; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3606 | fail_free_tgt_mem: |
| 3607 | qlt_mem_free(ha); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3608 | fail_free_init_cb: |
| 3609 | dma_free_coherent(&ha->pdev->dev, ha->init_cb_size, ha->init_cb, |
| 3610 | ha->init_cb_dma); |
| 3611 | ha->init_cb = NULL; |
| 3612 | ha->init_cb_dma = 0; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3613 | fail: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3614 | ql_log(ql_log_fatal, NULL, 0x0030, |
| 3615 | "Memory allocation failure.\n"); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3616 | return -ENOMEM; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3617 | } |
| 3618 | |
Himanshu Madhani | b0d6cab | 2015-12-17 14:56:56 -0500 | [diff] [blame] | 3619 | int |
| 3620 | qla2x00_set_exlogins_buffer(scsi_qla_host_t *vha) |
| 3621 | { |
| 3622 | int rval; |
| 3623 | uint16_t size, max_cnt, temp; |
| 3624 | struct qla_hw_data *ha = vha->hw; |
| 3625 | |
| 3626 | /* Return if we don't need to alloacate any extended logins */ |
| 3627 | if (!ql2xexlogins) |
| 3628 | return QLA_SUCCESS; |
| 3629 | |
| 3630 | ql_log(ql_log_info, vha, 0xd021, "EXLOGIN count: %d.\n", ql2xexlogins); |
| 3631 | max_cnt = 0; |
| 3632 | rval = qla_get_exlogin_status(vha, &size, &max_cnt); |
| 3633 | if (rval != QLA_SUCCESS) { |
| 3634 | ql_log_pci(ql_log_fatal, ha->pdev, 0xd029, |
| 3635 | "Failed to get exlogin status.\n"); |
| 3636 | return rval; |
| 3637 | } |
| 3638 | |
| 3639 | temp = (ql2xexlogins > max_cnt) ? max_cnt : ql2xexlogins; |
| 3640 | ha->exlogin_size = (size * temp); |
| 3641 | ql_log(ql_log_info, vha, 0xd024, |
| 3642 | "EXLOGIN: max_logins=%d, portdb=0x%x, total=%d.\n", |
| 3643 | max_cnt, size, temp); |
| 3644 | |
| 3645 | ql_log(ql_log_info, vha, 0xd025, "EXLOGIN: requested size=0x%x\n", |
| 3646 | ha->exlogin_size); |
| 3647 | |
| 3648 | /* Get consistent memory for extended logins */ |
| 3649 | ha->exlogin_buf = dma_alloc_coherent(&ha->pdev->dev, |
| 3650 | ha->exlogin_size, &ha->exlogin_buf_dma, GFP_KERNEL); |
| 3651 | if (!ha->exlogin_buf) { |
| 3652 | ql_log_pci(ql_log_fatal, ha->pdev, 0xd02a, |
| 3653 | "Failed to allocate memory for exlogin_buf_dma.\n"); |
| 3654 | return -ENOMEM; |
| 3655 | } |
| 3656 | |
| 3657 | /* Now configure the dma buffer */ |
| 3658 | rval = qla_set_exlogin_mem_cfg(vha, ha->exlogin_buf_dma); |
| 3659 | if (rval) { |
| 3660 | ql_log(ql_log_fatal, vha, 0x00cf, |
| 3661 | "Setup extended login buffer ****FAILED****.\n"); |
| 3662 | qla2x00_free_exlogin_buffer(ha); |
| 3663 | } |
| 3664 | |
| 3665 | return rval; |
| 3666 | } |
| 3667 | |
| 3668 | /* |
| 3669 | * qla2x00_free_exlogin_buffer |
| 3670 | * |
| 3671 | * Input: |
| 3672 | * ha = adapter block pointer |
| 3673 | */ |
| 3674 | void |
| 3675 | qla2x00_free_exlogin_buffer(struct qla_hw_data *ha) |
| 3676 | { |
| 3677 | if (ha->exlogin_buf) { |
| 3678 | dma_free_coherent(&ha->pdev->dev, ha->exlogin_size, |
| 3679 | ha->exlogin_buf, ha->exlogin_buf_dma); |
| 3680 | ha->exlogin_buf = NULL; |
| 3681 | ha->exlogin_size = 0; |
| 3682 | } |
| 3683 | } |
| 3684 | |
Himanshu Madhani | 2f56a7f | 2015-12-17 14:56:57 -0500 | [diff] [blame] | 3685 | int |
| 3686 | qla2x00_set_exchoffld_buffer(scsi_qla_host_t *vha) |
| 3687 | { |
| 3688 | int rval; |
| 3689 | uint16_t size, max_cnt, temp; |
| 3690 | struct qla_hw_data *ha = vha->hw; |
| 3691 | |
| 3692 | /* Return if we don't need to alloacate any extended logins */ |
| 3693 | if (!ql2xexchoffld) |
| 3694 | return QLA_SUCCESS; |
| 3695 | |
| 3696 | ql_log(ql_log_info, vha, 0xd014, |
| 3697 | "Exchange offload count: %d.\n", ql2xexlogins); |
| 3698 | |
| 3699 | max_cnt = 0; |
| 3700 | rval = qla_get_exchoffld_status(vha, &size, &max_cnt); |
| 3701 | if (rval != QLA_SUCCESS) { |
| 3702 | ql_log_pci(ql_log_fatal, ha->pdev, 0xd012, |
| 3703 | "Failed to get exlogin status.\n"); |
| 3704 | return rval; |
| 3705 | } |
| 3706 | |
| 3707 | temp = (ql2xexchoffld > max_cnt) ? max_cnt : ql2xexchoffld; |
| 3708 | ha->exchoffld_size = (size * temp); |
| 3709 | ql_log(ql_log_info, vha, 0xd016, |
| 3710 | "Exchange offload: max_count=%d, buffers=0x%x, total=%d.\n", |
| 3711 | max_cnt, size, temp); |
| 3712 | |
| 3713 | ql_log(ql_log_info, vha, 0xd017, |
| 3714 | "Exchange Buffers requested size = 0x%x\n", ha->exchoffld_size); |
| 3715 | |
| 3716 | /* Get consistent memory for extended logins */ |
| 3717 | ha->exchoffld_buf = dma_alloc_coherent(&ha->pdev->dev, |
| 3718 | ha->exchoffld_size, &ha->exchoffld_buf_dma, GFP_KERNEL); |
| 3719 | if (!ha->exchoffld_buf) { |
| 3720 | ql_log_pci(ql_log_fatal, ha->pdev, 0xd013, |
| 3721 | "Failed to allocate memory for exchoffld_buf_dma.\n"); |
| 3722 | return -ENOMEM; |
| 3723 | } |
| 3724 | |
| 3725 | /* Now configure the dma buffer */ |
| 3726 | rval = qla_set_exchoffld_mem_cfg(vha, ha->exchoffld_buf_dma); |
| 3727 | if (rval) { |
| 3728 | ql_log(ql_log_fatal, vha, 0xd02e, |
| 3729 | "Setup exchange offload buffer ****FAILED****.\n"); |
| 3730 | qla2x00_free_exchoffld_buffer(ha); |
| 3731 | } |
| 3732 | |
| 3733 | return rval; |
| 3734 | } |
| 3735 | |
| 3736 | /* |
| 3737 | * qla2x00_free_exchoffld_buffer |
| 3738 | * |
| 3739 | * Input: |
| 3740 | * ha = adapter block pointer |
| 3741 | */ |
| 3742 | void |
| 3743 | qla2x00_free_exchoffld_buffer(struct qla_hw_data *ha) |
| 3744 | { |
| 3745 | if (ha->exchoffld_buf) { |
| 3746 | dma_free_coherent(&ha->pdev->dev, ha->exchoffld_size, |
| 3747 | ha->exchoffld_buf, ha->exchoffld_buf_dma); |
| 3748 | ha->exchoffld_buf = NULL; |
| 3749 | ha->exchoffld_size = 0; |
| 3750 | } |
| 3751 | } |
| 3752 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3753 | /* |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3754 | * qla2x00_free_fw_dump |
| 3755 | * Frees fw dump stuff. |
| 3756 | * |
| 3757 | * Input: |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 3758 | * ha = adapter block pointer |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3759 | */ |
| 3760 | static void |
| 3761 | qla2x00_free_fw_dump(struct qla_hw_data *ha) |
| 3762 | { |
| 3763 | if (ha->fce) |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3764 | dma_free_coherent(&ha->pdev->dev, |
| 3765 | FCE_SIZE, ha->fce, ha->fce_dma); |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3766 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3767 | if (ha->eft) |
| 3768 | dma_free_coherent(&ha->pdev->dev, |
| 3769 | EFT_SIZE, ha->eft, ha->eft_dma); |
| 3770 | |
| 3771 | if (ha->fw_dump) |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3772 | vfree(ha->fw_dump); |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3773 | if (ha->fw_dump_template) |
| 3774 | vfree(ha->fw_dump_template); |
| 3775 | |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3776 | ha->fce = NULL; |
| 3777 | ha->fce_dma = 0; |
| 3778 | ha->eft = NULL; |
| 3779 | ha->eft_dma = 0; |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3780 | ha->fw_dumped = 0; |
Hiral Patel | 61f098d | 2014-04-11 16:54:21 -0400 | [diff] [blame] | 3781 | ha->fw_dump_cap_flags = 0; |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3782 | ha->fw_dump_reading = 0; |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 3783 | ha->fw_dump = NULL; |
| 3784 | ha->fw_dump_len = 0; |
| 3785 | ha->fw_dump_template = NULL; |
| 3786 | ha->fw_dump_template_len = 0; |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3787 | } |
| 3788 | |
| 3789 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3790 | * qla2x00_mem_free |
| 3791 | * Frees all adapter allocated memory. |
| 3792 | * |
| 3793 | * Input: |
| 3794 | * ha = adapter block pointer. |
| 3795 | */ |
Adrian Bunk | a824ebb | 2008-01-17 09:02:15 -0800 | [diff] [blame] | 3796 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3797 | qla2x00_mem_free(struct qla_hw_data *ha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3798 | { |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3799 | qla2x00_free_fw_dump(ha); |
| 3800 | |
Saurav Kashyap | 8117877 | 2012-08-22 14:21:04 -0400 | [diff] [blame] | 3801 | if (ha->mctp_dump) |
| 3802 | dma_free_coherent(&ha->pdev->dev, MCTP_DUMP_SIZE, ha->mctp_dump, |
| 3803 | ha->mctp_dump_dma); |
| 3804 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3805 | if (ha->srb_mempool) |
| 3806 | mempool_destroy(ha->srb_mempool); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3807 | |
Andrew Vasquez | 11bbc1d | 2009-06-03 09:55:14 -0700 | [diff] [blame] | 3808 | if (ha->dcbx_tlv) |
| 3809 | dma_free_coherent(&ha->pdev->dev, DCBX_TLV_DATA_SIZE, |
| 3810 | ha->dcbx_tlv, ha->dcbx_tlv_dma); |
| 3811 | |
Andrew Vasquez | ce0423f | 2009-06-03 09:55:13 -0700 | [diff] [blame] | 3812 | if (ha->xgmac_data) |
| 3813 | dma_free_coherent(&ha->pdev->dev, XGMAC_DATA_SIZE, |
| 3814 | ha->xgmac_data, ha->xgmac_data_dma); |
| 3815 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3816 | if (ha->sns_cmd) |
| 3817 | dma_free_coherent(&ha->pdev->dev, sizeof(struct sns_cmd_pkt), |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3818 | ha->sns_cmd, ha->sns_cmd_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3819 | |
| 3820 | if (ha->ct_sns) |
| 3821 | dma_free_coherent(&ha->pdev->dev, sizeof(struct ct_sns_pkt), |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3822 | ha->ct_sns, ha->ct_sns_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3823 | |
Andrew Vasquez | 88729e5 | 2006-06-23 16:10:50 -0700 | [diff] [blame] | 3824 | if (ha->sfp_data) |
| 3825 | dma_pool_free(ha->s_dma_pool, ha->sfp_data, ha->sfp_data_dma); |
| 3826 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3827 | if (ha->ms_iocb) |
| 3828 | dma_pool_free(ha->s_dma_pool, ha->ms_iocb, ha->ms_iocb_dma); |
| 3829 | |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 3830 | if (ha->ex_init_cb) |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3831 | dma_pool_free(ha->s_dma_pool, |
| 3832 | ha->ex_init_cb, ha->ex_init_cb_dma); |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 3833 | |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 3834 | if (ha->async_pd) |
| 3835 | dma_pool_free(ha->s_dma_pool, ha->async_pd, ha->async_pd_dma); |
| 3836 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3837 | if (ha->s_dma_pool) |
| 3838 | dma_pool_destroy(ha->s_dma_pool); |
| 3839 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3840 | if (ha->gid_list) |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 3841 | dma_free_coherent(&ha->pdev->dev, qla2x00_gid_list_size(ha), |
| 3842 | ha->gid_list, ha->gid_list_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3843 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3844 | if (IS_QLA82XX(ha)) { |
| 3845 | if (!list_empty(&ha->gbl_dsd_list)) { |
| 3846 | struct dsd_dma *dsd_ptr, *tdsd_ptr; |
| 3847 | |
| 3848 | /* clean up allocated prev pool */ |
| 3849 | list_for_each_entry_safe(dsd_ptr, |
| 3850 | tdsd_ptr, &ha->gbl_dsd_list, list) { |
| 3851 | dma_pool_free(ha->dl_dma_pool, |
| 3852 | dsd_ptr->dsd_addr, dsd_ptr->dsd_list_dma); |
| 3853 | list_del(&dsd_ptr->list); |
| 3854 | kfree(dsd_ptr); |
| 3855 | } |
| 3856 | } |
| 3857 | } |
| 3858 | |
| 3859 | if (ha->dl_dma_pool) |
| 3860 | dma_pool_destroy(ha->dl_dma_pool); |
| 3861 | |
| 3862 | if (ha->fcp_cmnd_dma_pool) |
| 3863 | dma_pool_destroy(ha->fcp_cmnd_dma_pool); |
| 3864 | |
| 3865 | if (ha->ctx_mempool) |
| 3866 | mempool_destroy(ha->ctx_mempool); |
| 3867 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3868 | qlt_mem_free(ha); |
| 3869 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3870 | if (ha->init_cb) |
| 3871 | dma_free_coherent(&ha->pdev->dev, ha->init_cb_size, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3872 | ha->init_cb, ha->init_cb_dma); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3873 | vfree(ha->optrom_buffer); |
| 3874 | kfree(ha->nvram); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3875 | kfree(ha->npiv_info); |
Andrew Vasquez | 7a67735 | 2012-02-09 11:15:56 -0800 | [diff] [blame] | 3876 | kfree(ha->swl); |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 3877 | kfree(ha->loop_id_map); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3878 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3879 | ha->srb_mempool = NULL; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3880 | ha->ctx_mempool = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3881 | ha->sns_cmd = NULL; |
| 3882 | ha->sns_cmd_dma = 0; |
| 3883 | ha->ct_sns = NULL; |
| 3884 | ha->ct_sns_dma = 0; |
| 3885 | ha->ms_iocb = NULL; |
| 3886 | ha->ms_iocb_dma = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3887 | ha->init_cb = NULL; |
| 3888 | ha->init_cb_dma = 0; |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 3889 | ha->ex_init_cb = NULL; |
| 3890 | ha->ex_init_cb_dma = 0; |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 3891 | ha->async_pd = NULL; |
| 3892 | ha->async_pd_dma = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3893 | |
| 3894 | ha->s_dma_pool = NULL; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3895 | ha->dl_dma_pool = NULL; |
| 3896 | ha->fcp_cmnd_dma_pool = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3897 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3898 | ha->gid_list = NULL; |
| 3899 | ha->gid_list_dma = 0; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3900 | |
| 3901 | ha->tgt.atio_ring = NULL; |
| 3902 | ha->tgt.atio_dma = 0; |
| 3903 | ha->tgt.tgt_vp_map = NULL; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3904 | } |
| 3905 | |
| 3906 | struct scsi_qla_host *qla2x00_create_host(struct scsi_host_template *sht, |
| 3907 | struct qla_hw_data *ha) |
| 3908 | { |
| 3909 | struct Scsi_Host *host; |
| 3910 | struct scsi_qla_host *vha = NULL; |
| 3911 | |
| 3912 | host = scsi_host_alloc(sht, sizeof(scsi_qla_host_t)); |
| 3913 | if (host == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3914 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0107, |
| 3915 | "Failed to allocate host from the scsi layer, aborting.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3916 | goto fail; |
| 3917 | } |
| 3918 | |
| 3919 | /* Clear our data area */ |
| 3920 | vha = shost_priv(host); |
| 3921 | memset(vha, 0, sizeof(scsi_qla_host_t)); |
| 3922 | |
| 3923 | vha->host = host; |
| 3924 | vha->host_no = host->host_no; |
| 3925 | vha->hw = ha; |
| 3926 | |
| 3927 | INIT_LIST_HEAD(&vha->vp_fcports); |
| 3928 | INIT_LIST_HEAD(&vha->work_list); |
| 3929 | INIT_LIST_HEAD(&vha->list); |
Swapnil Nagle | 8b2f5ff | 2015-07-14 16:00:43 -0400 | [diff] [blame] | 3930 | INIT_LIST_HEAD(&vha->qla_cmd_list); |
| 3931 | INIT_LIST_HEAD(&vha->qla_sess_op_cmd_list); |
Alexei Potashnik | 71cdc07 | 2015-12-17 14:57:01 -0500 | [diff] [blame] | 3932 | INIT_LIST_HEAD(&vha->logo_list); |
Alexei Potashnik | b7bd104 | 2015-12-17 14:57:02 -0500 | [diff] [blame] | 3933 | INIT_LIST_HEAD(&vha->plogi_ack_list); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3934 | |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3935 | spin_lock_init(&vha->work_lock); |
Swapnil Nagle | 8b2f5ff | 2015-07-14 16:00:43 -0400 | [diff] [blame] | 3936 | spin_lock_init(&vha->cmd_list_lock); |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3937 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3938 | sprintf(vha->host_str, "%s_%ld", QLA2XXX_DRIVER_NAME, vha->host_no); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3939 | ql_dbg(ql_dbg_init, vha, 0x0041, |
| 3940 | "Allocated the host=%p hw=%p vha=%p dev_name=%s", |
| 3941 | vha->host, vha->hw, vha, |
| 3942 | dev_name(&(ha->pdev->dev))); |
| 3943 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3944 | return vha; |
| 3945 | |
| 3946 | fail: |
| 3947 | return vha; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3948 | } |
| 3949 | |
Adrian Bunk | 01ef66b | 2008-04-24 15:21:27 -0700 | [diff] [blame] | 3950 | static struct qla_work_evt * |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3951 | 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] | 3952 | { |
| 3953 | struct qla_work_evt *e; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3954 | uint8_t bail; |
| 3955 | |
| 3956 | QLA_VHA_MARK_BUSY(vha, bail); |
| 3957 | if (bail) |
| 3958 | return NULL; |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3959 | |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3960 | e = kzalloc(sizeof(struct qla_work_evt), GFP_ATOMIC); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3961 | if (!e) { |
| 3962 | QLA_VHA_MARK_NOT_BUSY(vha); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3963 | return NULL; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3964 | } |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3965 | |
| 3966 | INIT_LIST_HEAD(&e->list); |
| 3967 | e->type = type; |
| 3968 | e->flags = QLA_EVT_FLAG_FREE; |
| 3969 | return e; |
| 3970 | } |
| 3971 | |
Adrian Bunk | 01ef66b | 2008-04-24 15:21:27 -0700 | [diff] [blame] | 3972 | static int |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3973 | 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] | 3974 | { |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3975 | unsigned long flags; |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3976 | |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3977 | spin_lock_irqsave(&vha->work_lock, flags); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3978 | list_add_tail(&e->list, &vha->work_list); |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3979 | spin_unlock_irqrestore(&vha->work_lock, flags); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3980 | qla2xxx_wake_dpc(vha); |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3981 | |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3982 | return QLA_SUCCESS; |
| 3983 | } |
| 3984 | |
| 3985 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3986 | 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] | 3987 | u32 data) |
| 3988 | { |
| 3989 | struct qla_work_evt *e; |
| 3990 | |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3991 | e = qla2x00_alloc_work(vha, QLA_EVT_AEN); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3992 | if (!e) |
| 3993 | return QLA_FUNCTION_FAILED; |
| 3994 | |
| 3995 | e->u.aen.code = code; |
| 3996 | e->u.aen.data = data; |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3997 | return qla2x00_post_work(vha, e); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3998 | } |
| 3999 | |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 4000 | int |
| 4001 | qla2x00_post_idc_ack_work(struct scsi_qla_host *vha, uint16_t *mb) |
| 4002 | { |
| 4003 | struct qla_work_evt *e; |
| 4004 | |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4005 | e = qla2x00_alloc_work(vha, QLA_EVT_IDC_ACK); |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 4006 | if (!e) |
| 4007 | return QLA_FUNCTION_FAILED; |
| 4008 | |
| 4009 | 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] | 4010 | return qla2x00_post_work(vha, e); |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 4011 | } |
| 4012 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4013 | #define qla2x00_post_async_work(name, type) \ |
| 4014 | int qla2x00_post_async_##name##_work( \ |
| 4015 | struct scsi_qla_host *vha, \ |
| 4016 | fc_port_t *fcport, uint16_t *data) \ |
| 4017 | { \ |
| 4018 | struct qla_work_evt *e; \ |
| 4019 | \ |
| 4020 | e = qla2x00_alloc_work(vha, type); \ |
| 4021 | if (!e) \ |
| 4022 | return QLA_FUNCTION_FAILED; \ |
| 4023 | \ |
| 4024 | e->u.logio.fcport = fcport; \ |
| 4025 | if (data) { \ |
| 4026 | e->u.logio.data[0] = data[0]; \ |
| 4027 | e->u.logio.data[1] = data[1]; \ |
| 4028 | } \ |
| 4029 | return qla2x00_post_work(vha, e); \ |
| 4030 | } |
| 4031 | |
| 4032 | qla2x00_post_async_work(login, QLA_EVT_ASYNC_LOGIN); |
| 4033 | qla2x00_post_async_work(login_done, QLA_EVT_ASYNC_LOGIN_DONE); |
| 4034 | qla2x00_post_async_work(logout, QLA_EVT_ASYNC_LOGOUT); |
| 4035 | qla2x00_post_async_work(logout_done, QLA_EVT_ASYNC_LOGOUT_DONE); |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 4036 | qla2x00_post_async_work(adisc, QLA_EVT_ASYNC_ADISC); |
| 4037 | qla2x00_post_async_work(adisc_done, QLA_EVT_ASYNC_ADISC_DONE); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4038 | |
Andrew Vasquez | 3420d36 | 2009-10-13 15:16:45 -0700 | [diff] [blame] | 4039 | int |
| 4040 | qla2x00_post_uevent_work(struct scsi_qla_host *vha, u32 code) |
| 4041 | { |
| 4042 | struct qla_work_evt *e; |
| 4043 | |
| 4044 | e = qla2x00_alloc_work(vha, QLA_EVT_UEVENT); |
| 4045 | if (!e) |
| 4046 | return QLA_FUNCTION_FAILED; |
| 4047 | |
| 4048 | e->u.uevent.code = code; |
| 4049 | return qla2x00_post_work(vha, e); |
| 4050 | } |
| 4051 | |
| 4052 | static void |
| 4053 | qla2x00_uevent_emit(struct scsi_qla_host *vha, u32 code) |
| 4054 | { |
| 4055 | char event_string[40]; |
| 4056 | char *envp[] = { event_string, NULL }; |
| 4057 | |
| 4058 | switch (code) { |
| 4059 | case QLA_UEVENT_CODE_FW_DUMP: |
| 4060 | snprintf(event_string, sizeof(event_string), "FW_DUMP=%ld", |
| 4061 | vha->host_no); |
| 4062 | break; |
| 4063 | default: |
| 4064 | /* do nothing */ |
| 4065 | break; |
| 4066 | } |
| 4067 | kobject_uevent_env(&vha->hw->pdev->dev.kobj, KOBJ_CHANGE, envp); |
| 4068 | } |
| 4069 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 4070 | int |
| 4071 | qlafx00_post_aenfx_work(struct scsi_qla_host *vha, uint32_t evtcode, |
| 4072 | uint32_t *data, int cnt) |
| 4073 | { |
| 4074 | struct qla_work_evt *e; |
| 4075 | |
| 4076 | e = qla2x00_alloc_work(vha, QLA_EVT_AENFX); |
| 4077 | if (!e) |
| 4078 | return QLA_FUNCTION_FAILED; |
| 4079 | |
| 4080 | e->u.aenfx.evtcode = evtcode; |
| 4081 | e->u.aenfx.count = cnt; |
| 4082 | memcpy(e->u.aenfx.mbx, data, sizeof(*data) * cnt); |
| 4083 | return qla2x00_post_work(vha, e); |
| 4084 | } |
| 4085 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4086 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4087 | qla2x00_do_work(struct scsi_qla_host *vha) |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4088 | { |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4089 | struct qla_work_evt *e, *tmp; |
| 4090 | unsigned long flags; |
| 4091 | LIST_HEAD(work); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4092 | |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4093 | spin_lock_irqsave(&vha->work_lock, flags); |
| 4094 | list_splice_init(&vha->work_list, &work); |
| 4095 | spin_unlock_irqrestore(&vha->work_lock, flags); |
| 4096 | |
| 4097 | list_for_each_entry_safe(e, tmp, &work, list) { |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4098 | list_del_init(&e->list); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4099 | |
| 4100 | switch (e->type) { |
| 4101 | case QLA_EVT_AEN: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4102 | fc_host_post_event(vha->host, fc_get_event_number(), |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4103 | e->u.aen.code, e->u.aen.data); |
| 4104 | break; |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 4105 | case QLA_EVT_IDC_ACK: |
| 4106 | qla81xx_idc_ack(vha, e->u.idc_ack.mb); |
| 4107 | break; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4108 | case QLA_EVT_ASYNC_LOGIN: |
| 4109 | qla2x00_async_login(vha, e->u.logio.fcport, |
| 4110 | e->u.logio.data); |
| 4111 | break; |
| 4112 | case QLA_EVT_ASYNC_LOGIN_DONE: |
| 4113 | qla2x00_async_login_done(vha, e->u.logio.fcport, |
| 4114 | e->u.logio.data); |
| 4115 | break; |
| 4116 | case QLA_EVT_ASYNC_LOGOUT: |
| 4117 | qla2x00_async_logout(vha, e->u.logio.fcport); |
| 4118 | break; |
| 4119 | case QLA_EVT_ASYNC_LOGOUT_DONE: |
| 4120 | qla2x00_async_logout_done(vha, e->u.logio.fcport, |
| 4121 | e->u.logio.data); |
| 4122 | break; |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 4123 | case QLA_EVT_ASYNC_ADISC: |
| 4124 | qla2x00_async_adisc(vha, e->u.logio.fcport, |
| 4125 | e->u.logio.data); |
| 4126 | break; |
| 4127 | case QLA_EVT_ASYNC_ADISC_DONE: |
| 4128 | qla2x00_async_adisc_done(vha, e->u.logio.fcport, |
| 4129 | e->u.logio.data); |
| 4130 | break; |
Andrew Vasquez | 3420d36 | 2009-10-13 15:16:45 -0700 | [diff] [blame] | 4131 | case QLA_EVT_UEVENT: |
| 4132 | qla2x00_uevent_emit(vha, e->u.uevent.code); |
| 4133 | break; |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 4134 | case QLA_EVT_AENFX: |
| 4135 | qlafx00_process_aen(vha, e); |
| 4136 | break; |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4137 | } |
| 4138 | if (e->flags & QLA_EVT_FLAG_FREE) |
| 4139 | kfree(e); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 4140 | |
| 4141 | /* For each work completed decrement vha ref count */ |
| 4142 | QLA_VHA_MARK_NOT_BUSY(vha); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4143 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4144 | } |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 4145 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4146 | /* Relogins all the fcports of a vport |
| 4147 | * Context: dpc thread |
| 4148 | */ |
| 4149 | void qla2x00_relogin(struct scsi_qla_host *vha) |
| 4150 | { |
| 4151 | fc_port_t *fcport; |
Andrew Vasquez | c6b2fca | 2009-03-05 11:07:03 -0800 | [diff] [blame] | 4152 | int status; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4153 | uint16_t next_loopid = 0; |
| 4154 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4155 | uint16_t data[2]; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4156 | |
| 4157 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
| 4158 | /* |
| 4159 | * If the port is not ONLINE then try to login |
| 4160 | * to it if we haven't run out of retries. |
| 4161 | */ |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 4162 | if (atomic_read(&fcport->state) != FCS_ONLINE && |
| 4163 | fcport->login_retry && !(fcport->flags & FCF_ASYNC_SENT)) { |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4164 | fcport->login_retry--; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4165 | if (fcport->flags & FCF_FABRIC_DEVICE) { |
Andrew Vasquez | f08b725 | 2010-01-12 12:59:48 -0800 | [diff] [blame] | 4166 | if (fcport->flags & FCF_FCP2_DEVICE) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4167 | ha->isp_ops->fabric_logout(vha, |
| 4168 | fcport->loop_id, |
| 4169 | fcport->d_id.b.domain, |
| 4170 | fcport->d_id.b.area, |
| 4171 | fcport->d_id.b.al_pa); |
| 4172 | |
Joe Carnuccio | 03bcfb5 | 2011-03-30 11:46:27 -0700 | [diff] [blame] | 4173 | if (fcport->loop_id == FC_NO_LOOP_ID) { |
| 4174 | fcport->loop_id = next_loopid = |
| 4175 | ha->min_external_loopid; |
| 4176 | status = qla2x00_find_new_loop_id( |
| 4177 | vha, fcport); |
| 4178 | if (status != QLA_SUCCESS) { |
| 4179 | /* Ran out of IDs to use */ |
| 4180 | break; |
| 4181 | } |
| 4182 | } |
| 4183 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4184 | if (IS_ALOGIO_CAPABLE(ha)) { |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 4185 | fcport->flags |= FCF_ASYNC_SENT; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4186 | data[0] = 0; |
| 4187 | data[1] = QLA_LOGIO_LOGIN_RETRIED; |
| 4188 | status = qla2x00_post_async_login_work( |
| 4189 | vha, fcport, data); |
| 4190 | if (status == QLA_SUCCESS) |
| 4191 | continue; |
| 4192 | /* Attempt a retry. */ |
| 4193 | status = 1; |
Saurav Kashyap | aaf4d3e | 2012-04-25 07:26:16 -0700 | [diff] [blame] | 4194 | } else { |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4195 | status = qla2x00_fabric_login(vha, |
| 4196 | fcport, &next_loopid); |
Saurav Kashyap | aaf4d3e | 2012-04-25 07:26:16 -0700 | [diff] [blame] | 4197 | if (status == QLA_SUCCESS) { |
| 4198 | int status2; |
| 4199 | uint8_t opts; |
| 4200 | |
| 4201 | opts = 0; |
| 4202 | if (fcport->flags & |
| 4203 | FCF_FCP2_DEVICE) |
| 4204 | opts |= BIT_1; |
Saurav Kashyap | 0300396 | 2012-11-21 02:40:31 -0500 | [diff] [blame] | 4205 | status2 = |
| 4206 | qla2x00_get_port_database( |
| 4207 | vha, fcport, opts); |
Saurav Kashyap | aaf4d3e | 2012-04-25 07:26:16 -0700 | [diff] [blame] | 4208 | if (status2 != QLA_SUCCESS) |
| 4209 | status = 1; |
| 4210 | } |
| 4211 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4212 | } else |
| 4213 | status = qla2x00_local_device_login(vha, |
| 4214 | fcport); |
| 4215 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4216 | if (status == QLA_SUCCESS) { |
| 4217 | fcport->old_loop_id = fcport->loop_id; |
| 4218 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4219 | ql_dbg(ql_dbg_disc, vha, 0x2003, |
| 4220 | "Port login OK: logged in ID 0x%x.\n", |
| 4221 | fcport->loop_id); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4222 | |
| 4223 | qla2x00_update_fcport(vha, fcport); |
| 4224 | |
| 4225 | } else if (status == 1) { |
| 4226 | set_bit(RELOGIN_NEEDED, &vha->dpc_flags); |
| 4227 | /* retry the login again */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4228 | ql_dbg(ql_dbg_disc, vha, 0x2007, |
| 4229 | "Retrying %d login again loop_id 0x%x.\n", |
| 4230 | fcport->login_retry, fcport->loop_id); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4231 | } else { |
| 4232 | fcport->login_retry = 0; |
| 4233 | } |
| 4234 | |
| 4235 | if (fcport->login_retry == 0 && status != QLA_SUCCESS) |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 4236 | qla2x00_clear_loop_id(fcport); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4237 | } |
| 4238 | if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) |
| 4239 | break; |
| 4240 | } |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4241 | } |
| 4242 | |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4243 | /* Schedule work on any of the dpc-workqueues */ |
| 4244 | void |
| 4245 | qla83xx_schedule_work(scsi_qla_host_t *base_vha, int work_code) |
| 4246 | { |
| 4247 | struct qla_hw_data *ha = base_vha->hw; |
| 4248 | |
| 4249 | switch (work_code) { |
| 4250 | case MBA_IDC_AEN: /* 0x8200 */ |
| 4251 | if (ha->dpc_lp_wq) |
| 4252 | queue_work(ha->dpc_lp_wq, &ha->idc_aen); |
| 4253 | break; |
| 4254 | |
| 4255 | case QLA83XX_NIC_CORE_RESET: /* 0x1 */ |
| 4256 | if (!ha->flags.nic_core_reset_hdlr_active) { |
| 4257 | if (ha->dpc_hp_wq) |
| 4258 | queue_work(ha->dpc_hp_wq, &ha->nic_core_reset); |
| 4259 | } else |
| 4260 | ql_dbg(ql_dbg_p3p, base_vha, 0xb05e, |
| 4261 | "NIC Core reset is already active. Skip " |
| 4262 | "scheduling it again.\n"); |
| 4263 | break; |
| 4264 | case QLA83XX_IDC_STATE_HANDLER: /* 0x2 */ |
| 4265 | if (ha->dpc_hp_wq) |
| 4266 | queue_work(ha->dpc_hp_wq, &ha->idc_state_handler); |
| 4267 | break; |
| 4268 | case QLA83XX_NIC_CORE_UNRECOVERABLE: /* 0x3 */ |
| 4269 | if (ha->dpc_hp_wq) |
| 4270 | queue_work(ha->dpc_hp_wq, &ha->nic_core_unrecoverable); |
| 4271 | break; |
| 4272 | default: |
| 4273 | ql_log(ql_log_warn, base_vha, 0xb05f, |
Masanari Iida | d939be3 | 2015-02-27 23:52:31 +0900 | [diff] [blame] | 4274 | "Unknown work-code=0x%x.\n", work_code); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4275 | } |
| 4276 | |
| 4277 | return; |
| 4278 | } |
| 4279 | |
| 4280 | /* Work: Perform NIC Core Unrecoverable state handling */ |
| 4281 | void |
| 4282 | qla83xx_nic_core_unrecoverable_work(struct work_struct *work) |
| 4283 | { |
| 4284 | struct qla_hw_data *ha = |
Arun Easi | 2ad1b67 | 2012-08-22 14:21:35 -0400 | [diff] [blame] | 4285 | container_of(work, struct qla_hw_data, nic_core_unrecoverable); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4286 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 4287 | uint32_t dev_state = 0; |
| 4288 | |
| 4289 | qla83xx_idc_lock(base_vha, 0); |
| 4290 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, &dev_state); |
| 4291 | qla83xx_reset_ownership(base_vha); |
| 4292 | if (ha->flags.nic_core_reset_owner) { |
| 4293 | ha->flags.nic_core_reset_owner = 0; |
| 4294 | qla83xx_wr_reg(base_vha, QLA83XX_IDC_DEV_STATE, |
| 4295 | QLA8XXX_DEV_FAILED); |
| 4296 | ql_log(ql_log_info, base_vha, 0xb060, "HW State: FAILED.\n"); |
| 4297 | qla83xx_schedule_work(base_vha, QLA83XX_IDC_STATE_HANDLER); |
| 4298 | } |
| 4299 | qla83xx_idc_unlock(base_vha, 0); |
| 4300 | } |
| 4301 | |
| 4302 | /* Work: Execute IDC state handler */ |
| 4303 | void |
| 4304 | qla83xx_idc_state_handler_work(struct work_struct *work) |
| 4305 | { |
| 4306 | struct qla_hw_data *ha = |
Arun Easi | 2ad1b67 | 2012-08-22 14:21:35 -0400 | [diff] [blame] | 4307 | container_of(work, struct qla_hw_data, idc_state_handler); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4308 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 4309 | uint32_t dev_state = 0; |
| 4310 | |
| 4311 | qla83xx_idc_lock(base_vha, 0); |
| 4312 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, &dev_state); |
| 4313 | if (dev_state == QLA8XXX_DEV_FAILED || |
| 4314 | dev_state == QLA8XXX_DEV_NEED_QUIESCENT) |
| 4315 | qla83xx_idc_state_handler(base_vha); |
| 4316 | qla83xx_idc_unlock(base_vha, 0); |
| 4317 | } |
| 4318 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 4319 | static int |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4320 | qla83xx_check_nic_core_fw_alive(scsi_qla_host_t *base_vha) |
| 4321 | { |
| 4322 | int rval = QLA_SUCCESS; |
| 4323 | unsigned long heart_beat_wait = jiffies + (1 * HZ); |
| 4324 | uint32_t heart_beat_counter1, heart_beat_counter2; |
| 4325 | |
| 4326 | do { |
| 4327 | if (time_after(jiffies, heart_beat_wait)) { |
| 4328 | ql_dbg(ql_dbg_p3p, base_vha, 0xb07c, |
| 4329 | "Nic Core f/w is not alive.\n"); |
| 4330 | rval = QLA_FUNCTION_FAILED; |
| 4331 | break; |
| 4332 | } |
| 4333 | |
| 4334 | qla83xx_idc_lock(base_vha, 0); |
| 4335 | qla83xx_rd_reg(base_vha, QLA83XX_FW_HEARTBEAT, |
| 4336 | &heart_beat_counter1); |
| 4337 | qla83xx_idc_unlock(base_vha, 0); |
| 4338 | msleep(100); |
| 4339 | qla83xx_idc_lock(base_vha, 0); |
| 4340 | qla83xx_rd_reg(base_vha, QLA83XX_FW_HEARTBEAT, |
| 4341 | &heart_beat_counter2); |
| 4342 | qla83xx_idc_unlock(base_vha, 0); |
| 4343 | } while (heart_beat_counter1 == heart_beat_counter2); |
| 4344 | |
| 4345 | return rval; |
| 4346 | } |
| 4347 | |
| 4348 | /* Work: Perform NIC Core Reset handling */ |
| 4349 | void |
| 4350 | qla83xx_nic_core_reset_work(struct work_struct *work) |
| 4351 | { |
| 4352 | struct qla_hw_data *ha = |
| 4353 | container_of(work, struct qla_hw_data, nic_core_reset); |
| 4354 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 4355 | uint32_t dev_state = 0; |
| 4356 | |
Saurav Kashyap | 8117877 | 2012-08-22 14:21:04 -0400 | [diff] [blame] | 4357 | if (IS_QLA2031(ha)) { |
| 4358 | if (qla2xxx_mctp_dump(base_vha) != QLA_SUCCESS) |
| 4359 | ql_log(ql_log_warn, base_vha, 0xb081, |
| 4360 | "Failed to dump mctp\n"); |
| 4361 | return; |
| 4362 | } |
| 4363 | |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4364 | if (!ha->flags.nic_core_reset_hdlr_active) { |
| 4365 | if (qla83xx_check_nic_core_fw_alive(base_vha) == QLA_SUCCESS) { |
| 4366 | qla83xx_idc_lock(base_vha, 0); |
| 4367 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, |
| 4368 | &dev_state); |
| 4369 | qla83xx_idc_unlock(base_vha, 0); |
| 4370 | if (dev_state != QLA8XXX_DEV_NEED_RESET) { |
| 4371 | ql_dbg(ql_dbg_p3p, base_vha, 0xb07a, |
| 4372 | "Nic Core f/w is alive.\n"); |
| 4373 | return; |
| 4374 | } |
| 4375 | } |
| 4376 | |
| 4377 | ha->flags.nic_core_reset_hdlr_active = 1; |
| 4378 | if (qla83xx_nic_core_reset(base_vha)) { |
| 4379 | /* NIC Core reset failed. */ |
| 4380 | ql_dbg(ql_dbg_p3p, base_vha, 0xb061, |
| 4381 | "NIC Core reset failed.\n"); |
| 4382 | } |
| 4383 | ha->flags.nic_core_reset_hdlr_active = 0; |
| 4384 | } |
| 4385 | } |
| 4386 | |
| 4387 | /* Work: Handle 8200 IDC aens */ |
| 4388 | void |
| 4389 | qla83xx_service_idc_aen(struct work_struct *work) |
| 4390 | { |
| 4391 | struct qla_hw_data *ha = |
| 4392 | container_of(work, struct qla_hw_data, idc_aen); |
| 4393 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 4394 | uint32_t dev_state, idc_control; |
| 4395 | |
| 4396 | qla83xx_idc_lock(base_vha, 0); |
| 4397 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, &dev_state); |
| 4398 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_CONTROL, &idc_control); |
| 4399 | qla83xx_idc_unlock(base_vha, 0); |
| 4400 | if (dev_state == QLA8XXX_DEV_NEED_RESET) { |
| 4401 | if (idc_control & QLA83XX_IDC_GRACEFUL_RESET) { |
| 4402 | ql_dbg(ql_dbg_p3p, base_vha, 0xb062, |
| 4403 | "Application requested NIC Core Reset.\n"); |
| 4404 | qla83xx_schedule_work(base_vha, QLA83XX_NIC_CORE_RESET); |
| 4405 | } else if (qla83xx_check_nic_core_fw_alive(base_vha) == |
| 4406 | QLA_SUCCESS) { |
| 4407 | ql_dbg(ql_dbg_p3p, base_vha, 0xb07b, |
| 4408 | "Other protocol driver requested NIC Core Reset.\n"); |
| 4409 | qla83xx_schedule_work(base_vha, QLA83XX_NIC_CORE_RESET); |
| 4410 | } |
| 4411 | } else if (dev_state == QLA8XXX_DEV_FAILED || |
| 4412 | dev_state == QLA8XXX_DEV_NEED_QUIESCENT) { |
| 4413 | qla83xx_schedule_work(base_vha, QLA83XX_IDC_STATE_HANDLER); |
| 4414 | } |
| 4415 | } |
| 4416 | |
| 4417 | static void |
| 4418 | qla83xx_wait_logic(void) |
| 4419 | { |
| 4420 | int i; |
| 4421 | |
| 4422 | /* Yield CPU */ |
| 4423 | if (!in_interrupt()) { |
| 4424 | /* |
| 4425 | * Wait about 200ms before retrying again. |
| 4426 | * This controls the number of retries for single |
| 4427 | * lock operation. |
| 4428 | */ |
| 4429 | msleep(100); |
| 4430 | schedule(); |
| 4431 | } else { |
| 4432 | for (i = 0; i < 20; i++) |
| 4433 | cpu_relax(); /* This a nop instr on i386 */ |
| 4434 | } |
| 4435 | } |
| 4436 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 4437 | static int |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4438 | qla83xx_force_lock_recovery(scsi_qla_host_t *base_vha) |
| 4439 | { |
| 4440 | int rval; |
| 4441 | uint32_t data; |
| 4442 | uint32_t idc_lck_rcvry_stage_mask = 0x3; |
| 4443 | uint32_t idc_lck_rcvry_owner_mask = 0x3c; |
| 4444 | struct qla_hw_data *ha = base_vha->hw; |
Saurav Kashyap | 6c31555 | 2013-02-08 01:57:53 -0500 | [diff] [blame] | 4445 | ql_dbg(ql_dbg_p3p, base_vha, 0xb086, |
| 4446 | "Trying force recovery of the IDC lock.\n"); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4447 | |
| 4448 | rval = qla83xx_rd_reg(base_vha, QLA83XX_IDC_LOCK_RECOVERY, &data); |
| 4449 | if (rval) |
| 4450 | return rval; |
| 4451 | |
| 4452 | if ((data & idc_lck_rcvry_stage_mask) > 0) { |
| 4453 | return QLA_SUCCESS; |
| 4454 | } else { |
| 4455 | data = (IDC_LOCK_RECOVERY_STAGE1) | (ha->portnum << 2); |
| 4456 | rval = qla83xx_wr_reg(base_vha, QLA83XX_IDC_LOCK_RECOVERY, |
| 4457 | data); |
| 4458 | if (rval) |
| 4459 | return rval; |
| 4460 | |
| 4461 | msleep(200); |
| 4462 | |
| 4463 | rval = qla83xx_rd_reg(base_vha, QLA83XX_IDC_LOCK_RECOVERY, |
| 4464 | &data); |
| 4465 | if (rval) |
| 4466 | return rval; |
| 4467 | |
| 4468 | if (((data & idc_lck_rcvry_owner_mask) >> 2) == ha->portnum) { |
| 4469 | data &= (IDC_LOCK_RECOVERY_STAGE2 | |
| 4470 | ~(idc_lck_rcvry_stage_mask)); |
| 4471 | rval = qla83xx_wr_reg(base_vha, |
| 4472 | QLA83XX_IDC_LOCK_RECOVERY, data); |
| 4473 | if (rval) |
| 4474 | return rval; |
| 4475 | |
| 4476 | /* Forcefully perform IDC UnLock */ |
| 4477 | rval = qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_UNLOCK, |
| 4478 | &data); |
| 4479 | if (rval) |
| 4480 | return rval; |
| 4481 | /* Clear lock-id by setting 0xff */ |
| 4482 | rval = qla83xx_wr_reg(base_vha, QLA83XX_DRIVER_LOCKID, |
| 4483 | 0xff); |
| 4484 | if (rval) |
| 4485 | return rval; |
| 4486 | /* Clear lock-recovery by setting 0x0 */ |
| 4487 | rval = qla83xx_wr_reg(base_vha, |
| 4488 | QLA83XX_IDC_LOCK_RECOVERY, 0x0); |
| 4489 | if (rval) |
| 4490 | return rval; |
| 4491 | } else |
| 4492 | return QLA_SUCCESS; |
| 4493 | } |
| 4494 | |
| 4495 | return rval; |
| 4496 | } |
| 4497 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 4498 | static int |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4499 | qla83xx_idc_lock_recovery(scsi_qla_host_t *base_vha) |
| 4500 | { |
| 4501 | int rval = QLA_SUCCESS; |
| 4502 | uint32_t o_drv_lockid, n_drv_lockid; |
| 4503 | unsigned long lock_recovery_timeout; |
| 4504 | |
| 4505 | lock_recovery_timeout = jiffies + QLA83XX_MAX_LOCK_RECOVERY_WAIT; |
| 4506 | retry_lockid: |
| 4507 | rval = qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCKID, &o_drv_lockid); |
| 4508 | if (rval) |
| 4509 | goto exit; |
| 4510 | |
| 4511 | /* MAX wait time before forcing IDC Lock recovery = 2 secs */ |
| 4512 | if (time_after_eq(jiffies, lock_recovery_timeout)) { |
| 4513 | if (qla83xx_force_lock_recovery(base_vha) == QLA_SUCCESS) |
| 4514 | return QLA_SUCCESS; |
| 4515 | else |
| 4516 | return QLA_FUNCTION_FAILED; |
| 4517 | } |
| 4518 | |
| 4519 | rval = qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCKID, &n_drv_lockid); |
| 4520 | if (rval) |
| 4521 | goto exit; |
| 4522 | |
| 4523 | if (o_drv_lockid == n_drv_lockid) { |
| 4524 | qla83xx_wait_logic(); |
| 4525 | goto retry_lockid; |
| 4526 | } else |
| 4527 | return QLA_SUCCESS; |
| 4528 | |
| 4529 | exit: |
| 4530 | return rval; |
| 4531 | } |
| 4532 | |
| 4533 | void |
| 4534 | qla83xx_idc_lock(scsi_qla_host_t *base_vha, uint16_t requester_id) |
| 4535 | { |
| 4536 | uint16_t options = (requester_id << 15) | BIT_6; |
| 4537 | uint32_t data; |
Saurav Kashyap | 6c31555 | 2013-02-08 01:57:53 -0500 | [diff] [blame] | 4538 | uint32_t lock_owner; |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4539 | struct qla_hw_data *ha = base_vha->hw; |
| 4540 | |
| 4541 | /* IDC-lock implementation using driver-lock/lock-id remote registers */ |
| 4542 | retry_lock: |
| 4543 | if (qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCK, &data) |
| 4544 | == QLA_SUCCESS) { |
| 4545 | if (data) { |
| 4546 | /* Setting lock-id to our function-number */ |
| 4547 | qla83xx_wr_reg(base_vha, QLA83XX_DRIVER_LOCKID, |
| 4548 | ha->portnum); |
| 4549 | } else { |
Saurav Kashyap | 6c31555 | 2013-02-08 01:57:53 -0500 | [diff] [blame] | 4550 | qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCKID, |
| 4551 | &lock_owner); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4552 | ql_dbg(ql_dbg_p3p, base_vha, 0xb063, |
Saurav Kashyap | 6c31555 | 2013-02-08 01:57:53 -0500 | [diff] [blame] | 4553 | "Failed to acquire IDC lock, acquired by %d, " |
| 4554 | "retrying...\n", lock_owner); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4555 | |
| 4556 | /* Retry/Perform IDC-Lock recovery */ |
| 4557 | if (qla83xx_idc_lock_recovery(base_vha) |
| 4558 | == QLA_SUCCESS) { |
| 4559 | qla83xx_wait_logic(); |
| 4560 | goto retry_lock; |
| 4561 | } else |
| 4562 | ql_log(ql_log_warn, base_vha, 0xb075, |
| 4563 | "IDC Lock recovery FAILED.\n"); |
| 4564 | } |
| 4565 | |
| 4566 | } |
| 4567 | |
| 4568 | return; |
| 4569 | |
| 4570 | /* XXX: IDC-lock implementation using access-control mbx */ |
| 4571 | retry_lock2: |
| 4572 | if (qla83xx_access_control(base_vha, options, 0, 0, NULL)) { |
| 4573 | ql_dbg(ql_dbg_p3p, base_vha, 0xb072, |
| 4574 | "Failed to acquire IDC lock. retrying...\n"); |
| 4575 | /* Retry/Perform IDC-Lock recovery */ |
| 4576 | if (qla83xx_idc_lock_recovery(base_vha) == QLA_SUCCESS) { |
| 4577 | qla83xx_wait_logic(); |
| 4578 | goto retry_lock2; |
| 4579 | } else |
| 4580 | ql_log(ql_log_warn, base_vha, 0xb076, |
| 4581 | "IDC Lock recovery FAILED.\n"); |
| 4582 | } |
| 4583 | |
| 4584 | return; |
| 4585 | } |
| 4586 | |
| 4587 | void |
| 4588 | qla83xx_idc_unlock(scsi_qla_host_t *base_vha, uint16_t requester_id) |
| 4589 | { |
Bart Van Assche | 5897cb2 | 2015-06-04 15:57:20 -0700 | [diff] [blame] | 4590 | #if 0 |
| 4591 | uint16_t options = (requester_id << 15) | BIT_7; |
| 4592 | #endif |
| 4593 | uint16_t retry; |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4594 | uint32_t data; |
| 4595 | struct qla_hw_data *ha = base_vha->hw; |
| 4596 | |
| 4597 | /* IDC-unlock implementation using driver-unlock/lock-id |
| 4598 | * remote registers |
| 4599 | */ |
| 4600 | retry = 0; |
| 4601 | retry_unlock: |
| 4602 | if (qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCKID, &data) |
| 4603 | == QLA_SUCCESS) { |
| 4604 | if (data == ha->portnum) { |
| 4605 | qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_UNLOCK, &data); |
| 4606 | /* Clearing lock-id by setting 0xff */ |
| 4607 | qla83xx_wr_reg(base_vha, QLA83XX_DRIVER_LOCKID, 0xff); |
| 4608 | } else if (retry < 10) { |
| 4609 | /* SV: XXX: IDC unlock retrying needed here? */ |
| 4610 | |
| 4611 | /* Retry for IDC-unlock */ |
| 4612 | qla83xx_wait_logic(); |
| 4613 | retry++; |
| 4614 | ql_dbg(ql_dbg_p3p, base_vha, 0xb064, |
| 4615 | "Failed to release IDC lock, retyring=%d\n", retry); |
| 4616 | goto retry_unlock; |
| 4617 | } |
| 4618 | } else if (retry < 10) { |
| 4619 | /* Retry for IDC-unlock */ |
| 4620 | qla83xx_wait_logic(); |
| 4621 | retry++; |
| 4622 | ql_dbg(ql_dbg_p3p, base_vha, 0xb065, |
| 4623 | "Failed to read drv-lockid, retyring=%d\n", retry); |
| 4624 | goto retry_unlock; |
| 4625 | } |
| 4626 | |
| 4627 | return; |
| 4628 | |
Bart Van Assche | 5897cb2 | 2015-06-04 15:57:20 -0700 | [diff] [blame] | 4629 | #if 0 |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4630 | /* XXX: IDC-unlock implementation using access-control mbx */ |
| 4631 | retry = 0; |
| 4632 | retry_unlock2: |
| 4633 | if (qla83xx_access_control(base_vha, options, 0, 0, NULL)) { |
| 4634 | if (retry < 10) { |
| 4635 | /* Retry for IDC-unlock */ |
| 4636 | qla83xx_wait_logic(); |
| 4637 | retry++; |
| 4638 | ql_dbg(ql_dbg_p3p, base_vha, 0xb066, |
| 4639 | "Failed to release IDC lock, retyring=%d\n", retry); |
| 4640 | goto retry_unlock2; |
| 4641 | } |
| 4642 | } |
| 4643 | |
| 4644 | return; |
Bart Van Assche | 5897cb2 | 2015-06-04 15:57:20 -0700 | [diff] [blame] | 4645 | #endif |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4646 | } |
| 4647 | |
| 4648 | int |
| 4649 | __qla83xx_set_drv_presence(scsi_qla_host_t *vha) |
| 4650 | { |
| 4651 | int rval = QLA_SUCCESS; |
| 4652 | struct qla_hw_data *ha = vha->hw; |
| 4653 | uint32_t drv_presence; |
| 4654 | |
| 4655 | rval = qla83xx_rd_reg(vha, QLA83XX_IDC_DRV_PRESENCE, &drv_presence); |
| 4656 | if (rval == QLA_SUCCESS) { |
| 4657 | drv_presence |= (1 << ha->portnum); |
| 4658 | rval = qla83xx_wr_reg(vha, QLA83XX_IDC_DRV_PRESENCE, |
| 4659 | drv_presence); |
| 4660 | } |
| 4661 | |
| 4662 | return rval; |
| 4663 | } |
| 4664 | |
| 4665 | int |
| 4666 | qla83xx_set_drv_presence(scsi_qla_host_t *vha) |
| 4667 | { |
| 4668 | int rval = QLA_SUCCESS; |
| 4669 | |
| 4670 | qla83xx_idc_lock(vha, 0); |
| 4671 | rval = __qla83xx_set_drv_presence(vha); |
| 4672 | qla83xx_idc_unlock(vha, 0); |
| 4673 | |
| 4674 | return rval; |
| 4675 | } |
| 4676 | |
| 4677 | int |
| 4678 | __qla83xx_clear_drv_presence(scsi_qla_host_t *vha) |
| 4679 | { |
| 4680 | int rval = QLA_SUCCESS; |
| 4681 | struct qla_hw_data *ha = vha->hw; |
| 4682 | uint32_t drv_presence; |
| 4683 | |
| 4684 | rval = qla83xx_rd_reg(vha, QLA83XX_IDC_DRV_PRESENCE, &drv_presence); |
| 4685 | if (rval == QLA_SUCCESS) { |
| 4686 | drv_presence &= ~(1 << ha->portnum); |
| 4687 | rval = qla83xx_wr_reg(vha, QLA83XX_IDC_DRV_PRESENCE, |
| 4688 | drv_presence); |
| 4689 | } |
| 4690 | |
| 4691 | return rval; |
| 4692 | } |
| 4693 | |
| 4694 | int |
| 4695 | qla83xx_clear_drv_presence(scsi_qla_host_t *vha) |
| 4696 | { |
| 4697 | int rval = QLA_SUCCESS; |
| 4698 | |
| 4699 | qla83xx_idc_lock(vha, 0); |
| 4700 | rval = __qla83xx_clear_drv_presence(vha); |
| 4701 | qla83xx_idc_unlock(vha, 0); |
| 4702 | |
| 4703 | return rval; |
| 4704 | } |
| 4705 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 4706 | static void |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4707 | qla83xx_need_reset_handler(scsi_qla_host_t *vha) |
| 4708 | { |
| 4709 | struct qla_hw_data *ha = vha->hw; |
| 4710 | uint32_t drv_ack, drv_presence; |
| 4711 | unsigned long ack_timeout; |
| 4712 | |
| 4713 | /* Wait for IDC ACK from all functions (DRV-ACK == DRV-PRESENCE) */ |
| 4714 | ack_timeout = jiffies + (ha->fcoe_reset_timeout * HZ); |
| 4715 | while (1) { |
| 4716 | qla83xx_rd_reg(vha, QLA83XX_IDC_DRIVER_ACK, &drv_ack); |
| 4717 | qla83xx_rd_reg(vha, QLA83XX_IDC_DRV_PRESENCE, &drv_presence); |
Saurav Kashyap | 807fb6d | 2012-11-21 02:40:36 -0500 | [diff] [blame] | 4718 | if ((drv_ack & drv_presence) == drv_presence) |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4719 | break; |
| 4720 | |
| 4721 | if (time_after_eq(jiffies, ack_timeout)) { |
| 4722 | ql_log(ql_log_warn, vha, 0xb067, |
| 4723 | "RESET ACK TIMEOUT! drv_presence=0x%x " |
| 4724 | "drv_ack=0x%x\n", drv_presence, drv_ack); |
| 4725 | /* |
| 4726 | * The function(s) which did not ack in time are forced |
| 4727 | * to withdraw any further participation in the IDC |
| 4728 | * reset. |
| 4729 | */ |
| 4730 | if (drv_ack != drv_presence) |
| 4731 | qla83xx_wr_reg(vha, QLA83XX_IDC_DRV_PRESENCE, |
| 4732 | drv_ack); |
| 4733 | break; |
| 4734 | } |
| 4735 | |
| 4736 | qla83xx_idc_unlock(vha, 0); |
| 4737 | msleep(1000); |
| 4738 | qla83xx_idc_lock(vha, 0); |
| 4739 | } |
| 4740 | |
| 4741 | qla83xx_wr_reg(vha, QLA83XX_IDC_DEV_STATE, QLA8XXX_DEV_COLD); |
| 4742 | ql_log(ql_log_info, vha, 0xb068, "HW State: COLD/RE-INIT.\n"); |
| 4743 | } |
| 4744 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 4745 | static int |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4746 | qla83xx_device_bootstrap(scsi_qla_host_t *vha) |
| 4747 | { |
| 4748 | int rval = QLA_SUCCESS; |
| 4749 | uint32_t idc_control; |
| 4750 | |
| 4751 | qla83xx_wr_reg(vha, QLA83XX_IDC_DEV_STATE, QLA8XXX_DEV_INITIALIZING); |
| 4752 | ql_log(ql_log_info, vha, 0xb069, "HW State: INITIALIZING.\n"); |
| 4753 | |
| 4754 | /* Clearing IDC-Control Graceful-Reset Bit before resetting f/w */ |
| 4755 | __qla83xx_get_idc_control(vha, &idc_control); |
| 4756 | idc_control &= ~QLA83XX_IDC_GRACEFUL_RESET; |
| 4757 | __qla83xx_set_idc_control(vha, 0); |
| 4758 | |
| 4759 | qla83xx_idc_unlock(vha, 0); |
| 4760 | rval = qla83xx_restart_nic_firmware(vha); |
| 4761 | qla83xx_idc_lock(vha, 0); |
| 4762 | |
| 4763 | if (rval != QLA_SUCCESS) { |
| 4764 | ql_log(ql_log_fatal, vha, 0xb06a, |
| 4765 | "Failed to restart NIC f/w.\n"); |
| 4766 | qla83xx_wr_reg(vha, QLA83XX_IDC_DEV_STATE, QLA8XXX_DEV_FAILED); |
| 4767 | ql_log(ql_log_info, vha, 0xb06b, "HW State: FAILED.\n"); |
| 4768 | } else { |
| 4769 | ql_dbg(ql_dbg_p3p, vha, 0xb06c, |
| 4770 | "Success in restarting nic f/w.\n"); |
| 4771 | qla83xx_wr_reg(vha, QLA83XX_IDC_DEV_STATE, QLA8XXX_DEV_READY); |
| 4772 | ql_log(ql_log_info, vha, 0xb06d, "HW State: READY.\n"); |
| 4773 | } |
| 4774 | |
| 4775 | return rval; |
| 4776 | } |
| 4777 | |
| 4778 | /* Assumes idc_lock always held on entry */ |
| 4779 | int |
| 4780 | qla83xx_idc_state_handler(scsi_qla_host_t *base_vha) |
| 4781 | { |
| 4782 | struct qla_hw_data *ha = base_vha->hw; |
| 4783 | int rval = QLA_SUCCESS; |
| 4784 | unsigned long dev_init_timeout; |
| 4785 | uint32_t dev_state; |
| 4786 | |
| 4787 | /* Wait for MAX-INIT-TIMEOUT for the device to go ready */ |
| 4788 | dev_init_timeout = jiffies + (ha->fcoe_dev_init_timeout * HZ); |
| 4789 | |
| 4790 | while (1) { |
| 4791 | |
| 4792 | if (time_after_eq(jiffies, dev_init_timeout)) { |
| 4793 | ql_log(ql_log_warn, base_vha, 0xb06e, |
| 4794 | "Initialization TIMEOUT!\n"); |
| 4795 | /* Init timeout. Disable further NIC Core |
| 4796 | * communication. |
| 4797 | */ |
| 4798 | qla83xx_wr_reg(base_vha, QLA83XX_IDC_DEV_STATE, |
| 4799 | QLA8XXX_DEV_FAILED); |
| 4800 | ql_log(ql_log_info, base_vha, 0xb06f, |
| 4801 | "HW State: FAILED.\n"); |
| 4802 | } |
| 4803 | |
| 4804 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, &dev_state); |
| 4805 | switch (dev_state) { |
| 4806 | case QLA8XXX_DEV_READY: |
| 4807 | if (ha->flags.nic_core_reset_owner) |
| 4808 | qla83xx_idc_audit(base_vha, |
| 4809 | IDC_AUDIT_COMPLETION); |
| 4810 | ha->flags.nic_core_reset_owner = 0; |
| 4811 | ql_dbg(ql_dbg_p3p, base_vha, 0xb070, |
| 4812 | "Reset_owner reset by 0x%x.\n", |
| 4813 | ha->portnum); |
| 4814 | goto exit; |
| 4815 | case QLA8XXX_DEV_COLD: |
| 4816 | if (ha->flags.nic_core_reset_owner) |
| 4817 | rval = qla83xx_device_bootstrap(base_vha); |
| 4818 | else { |
| 4819 | /* Wait for AEN to change device-state */ |
| 4820 | qla83xx_idc_unlock(base_vha, 0); |
| 4821 | msleep(1000); |
| 4822 | qla83xx_idc_lock(base_vha, 0); |
| 4823 | } |
| 4824 | break; |
| 4825 | case QLA8XXX_DEV_INITIALIZING: |
| 4826 | /* Wait for AEN to change device-state */ |
| 4827 | qla83xx_idc_unlock(base_vha, 0); |
| 4828 | msleep(1000); |
| 4829 | qla83xx_idc_lock(base_vha, 0); |
| 4830 | break; |
| 4831 | case QLA8XXX_DEV_NEED_RESET: |
| 4832 | if (!ql2xdontresethba && ha->flags.nic_core_reset_owner) |
| 4833 | qla83xx_need_reset_handler(base_vha); |
| 4834 | else { |
| 4835 | /* Wait for AEN to change device-state */ |
| 4836 | qla83xx_idc_unlock(base_vha, 0); |
| 4837 | msleep(1000); |
| 4838 | qla83xx_idc_lock(base_vha, 0); |
| 4839 | } |
| 4840 | /* reset timeout value after need reset handler */ |
| 4841 | dev_init_timeout = jiffies + |
| 4842 | (ha->fcoe_dev_init_timeout * HZ); |
| 4843 | break; |
| 4844 | case QLA8XXX_DEV_NEED_QUIESCENT: |
| 4845 | /* XXX: DEBUG for now */ |
| 4846 | qla83xx_idc_unlock(base_vha, 0); |
| 4847 | msleep(1000); |
| 4848 | qla83xx_idc_lock(base_vha, 0); |
| 4849 | break; |
| 4850 | case QLA8XXX_DEV_QUIESCENT: |
| 4851 | /* XXX: DEBUG for now */ |
| 4852 | if (ha->flags.quiesce_owner) |
| 4853 | goto exit; |
| 4854 | |
| 4855 | qla83xx_idc_unlock(base_vha, 0); |
| 4856 | msleep(1000); |
| 4857 | qla83xx_idc_lock(base_vha, 0); |
| 4858 | dev_init_timeout = jiffies + |
| 4859 | (ha->fcoe_dev_init_timeout * HZ); |
| 4860 | break; |
| 4861 | case QLA8XXX_DEV_FAILED: |
| 4862 | if (ha->flags.nic_core_reset_owner) |
| 4863 | qla83xx_idc_audit(base_vha, |
| 4864 | IDC_AUDIT_COMPLETION); |
| 4865 | ha->flags.nic_core_reset_owner = 0; |
| 4866 | __qla83xx_clear_drv_presence(base_vha); |
| 4867 | qla83xx_idc_unlock(base_vha, 0); |
| 4868 | qla8xxx_dev_failed_handler(base_vha); |
| 4869 | rval = QLA_FUNCTION_FAILED; |
| 4870 | qla83xx_idc_lock(base_vha, 0); |
| 4871 | goto exit; |
| 4872 | case QLA8XXX_BAD_VALUE: |
| 4873 | qla83xx_idc_unlock(base_vha, 0); |
| 4874 | msleep(1000); |
| 4875 | qla83xx_idc_lock(base_vha, 0); |
| 4876 | break; |
| 4877 | default: |
| 4878 | ql_log(ql_log_warn, base_vha, 0xb071, |
Masanari Iida | d939be3 | 2015-02-27 23:52:31 +0900 | [diff] [blame] | 4879 | "Unknown Device State: %x.\n", dev_state); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4880 | qla83xx_idc_unlock(base_vha, 0); |
| 4881 | qla8xxx_dev_failed_handler(base_vha); |
| 4882 | rval = QLA_FUNCTION_FAILED; |
| 4883 | qla83xx_idc_lock(base_vha, 0); |
| 4884 | goto exit; |
| 4885 | } |
| 4886 | } |
| 4887 | |
| 4888 | exit: |
| 4889 | return rval; |
| 4890 | } |
| 4891 | |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 4892 | void |
| 4893 | qla2x00_disable_board_on_pci_error(struct work_struct *work) |
| 4894 | { |
| 4895 | struct qla_hw_data *ha = container_of(work, struct qla_hw_data, |
| 4896 | board_disable); |
| 4897 | struct pci_dev *pdev = ha->pdev; |
| 4898 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 4899 | |
| 4900 | ql_log(ql_log_warn, base_vha, 0x015b, |
| 4901 | "Disabling adapter.\n"); |
| 4902 | |
| 4903 | set_bit(UNLOADING, &base_vha->dpc_flags); |
| 4904 | |
| 4905 | qla2x00_delete_all_vps(ha, base_vha); |
| 4906 | |
| 4907 | qla2x00_abort_all_cmds(base_vha, DID_NO_CONNECT << 16); |
| 4908 | |
| 4909 | qla2x00_dfs_remove(base_vha); |
| 4910 | |
| 4911 | qla84xx_put_chip(base_vha); |
| 4912 | |
| 4913 | if (base_vha->timer_active) |
| 4914 | qla2x00_stop_timer(base_vha); |
| 4915 | |
| 4916 | base_vha->flags.online = 0; |
| 4917 | |
| 4918 | qla2x00_destroy_deferred_work(ha); |
| 4919 | |
| 4920 | /* |
| 4921 | * Do not try to stop beacon blink as it will issue a mailbox |
| 4922 | * command. |
| 4923 | */ |
| 4924 | qla2x00_free_sysfs_attr(base_vha, false); |
| 4925 | |
| 4926 | fc_remove_host(base_vha->host); |
| 4927 | |
| 4928 | scsi_remove_host(base_vha->host); |
| 4929 | |
| 4930 | base_vha->flags.init_done = 0; |
| 4931 | qla25xx_delete_queues(base_vha); |
| 4932 | qla2x00_free_irqs(base_vha); |
| 4933 | qla2x00_free_fcports(base_vha); |
| 4934 | qla2x00_mem_free(ha); |
| 4935 | qla82xx_md_free(base_vha); |
| 4936 | qla2x00_free_queues(ha); |
| 4937 | |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 4938 | qla2x00_unmap_iobases(ha); |
| 4939 | |
| 4940 | pci_release_selected_regions(ha->pdev, ha->bars); |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 4941 | pci_disable_pcie_error_reporting(pdev); |
| 4942 | pci_disable_device(pdev); |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 4943 | |
Joe Lawrence | beb9e31 | 2014-08-26 17:12:14 -0400 | [diff] [blame] | 4944 | /* |
| 4945 | * Let qla2x00_remove_one cleanup qla_hw_data on device removal. |
| 4946 | */ |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 4947 | } |
| 4948 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4949 | /************************************************************************** |
| 4950 | * qla2x00_do_dpc |
| 4951 | * This kernel thread is a task that is schedule by the interrupt handler |
| 4952 | * to perform the background processing for interrupts. |
| 4953 | * |
| 4954 | * Notes: |
| 4955 | * This task always run in the context of a kernel thread. It |
| 4956 | * is kick-off by the driver's detect code and starts up |
| 4957 | * up one per adapter. It immediately goes to sleep and waits for |
| 4958 | * some fibre event. When either the interrupt handler or |
| 4959 | * the timer routine detects a event it will one of the task |
| 4960 | * bits then wake us up. |
| 4961 | **************************************************************************/ |
| 4962 | static int |
| 4963 | qla2x00_do_dpc(void *data) |
| 4964 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4965 | scsi_qla_host_t *base_vha; |
| 4966 | struct qla_hw_data *ha; |
Seokmann Ju | 99363ef | 2008-01-31 12:33:51 -0800 | [diff] [blame] | 4967 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4968 | ha = (struct qla_hw_data *)data; |
| 4969 | base_vha = pci_get_drvdata(ha->pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4970 | |
Dongsheng Yang | 8698a74 | 2014-03-11 18:09:12 +0800 | [diff] [blame] | 4971 | set_user_nice(current, MIN_NICE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4972 | |
James Bottomley | 563585e | 2011-01-27 16:12:37 -0500 | [diff] [blame] | 4973 | set_current_state(TASK_INTERRUPTIBLE); |
Christoph Hellwig | 39a1124 | 2006-02-14 18:46:22 +0100 | [diff] [blame] | 4974 | while (!kthread_should_stop()) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4975 | ql_dbg(ql_dbg_dpc, base_vha, 0x4000, |
| 4976 | "DPC handler sleeping.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4977 | |
Christoph Hellwig | 39a1124 | 2006-02-14 18:46:22 +0100 | [diff] [blame] | 4978 | schedule(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4979 | |
Andrew Vasquez | c142caf | 2011-11-18 09:03:10 -0800 | [diff] [blame] | 4980 | if (!base_vha->flags.init_done || ha->flags.mbox_busy) |
| 4981 | goto end_loop; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4982 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 4983 | if (ha->flags.eeh_busy) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4984 | ql_dbg(ql_dbg_dpc, base_vha, 0x4003, |
| 4985 | "eeh_busy=%d.\n", ha->flags.eeh_busy); |
Andrew Vasquez | c142caf | 2011-11-18 09:03:10 -0800 | [diff] [blame] | 4986 | goto end_loop; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 4987 | } |
| 4988 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4989 | ha->dpc_active = 1; |
| 4990 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4991 | ql_dbg(ql_dbg_dpc + ql_dbg_verbose, base_vha, 0x4001, |
| 4992 | "DPC handler waking up, dpc_flags=0x%lx.\n", |
| 4993 | base_vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4994 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4995 | qla2x00_do_work(base_vha); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4996 | |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 4997 | if (IS_P3P_TYPE(ha)) { |
| 4998 | if (IS_QLA8044(ha)) { |
| 4999 | if (test_and_clear_bit(ISP_UNRECOVERABLE, |
| 5000 | &base_vha->dpc_flags)) { |
| 5001 | qla8044_idc_lock(ha); |
| 5002 | qla8044_wr_direct(base_vha, |
| 5003 | QLA8044_CRB_DEV_STATE_INDEX, |
| 5004 | QLA8XXX_DEV_FAILED); |
| 5005 | qla8044_idc_unlock(ha); |
| 5006 | ql_log(ql_log_info, base_vha, 0x4004, |
| 5007 | "HW State: FAILED.\n"); |
| 5008 | qla8044_device_state_handler(base_vha); |
| 5009 | continue; |
| 5010 | } |
| 5011 | |
| 5012 | } else { |
| 5013 | if (test_and_clear_bit(ISP_UNRECOVERABLE, |
| 5014 | &base_vha->dpc_flags)) { |
| 5015 | qla82xx_idc_lock(ha); |
| 5016 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
| 5017 | QLA8XXX_DEV_FAILED); |
| 5018 | qla82xx_idc_unlock(ha); |
| 5019 | ql_log(ql_log_info, base_vha, 0x0151, |
| 5020 | "HW State: FAILED.\n"); |
| 5021 | qla82xx_device_state_handler(base_vha); |
| 5022 | continue; |
| 5023 | } |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5024 | } |
| 5025 | |
| 5026 | if (test_and_clear_bit(FCOE_CTX_RESET_NEEDED, |
| 5027 | &base_vha->dpc_flags)) { |
| 5028 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5029 | ql_dbg(ql_dbg_dpc, base_vha, 0x4005, |
| 5030 | "FCoE context reset scheduled.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5031 | if (!(test_and_set_bit(ABORT_ISP_ACTIVE, |
| 5032 | &base_vha->dpc_flags))) { |
| 5033 | if (qla82xx_fcoe_ctx_reset(base_vha)) { |
| 5034 | /* FCoE-ctx reset failed. |
| 5035 | * Escalate to chip-reset |
| 5036 | */ |
| 5037 | set_bit(ISP_ABORT_NEEDED, |
| 5038 | &base_vha->dpc_flags); |
| 5039 | } |
| 5040 | clear_bit(ABORT_ISP_ACTIVE, |
| 5041 | &base_vha->dpc_flags); |
| 5042 | } |
| 5043 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5044 | ql_dbg(ql_dbg_dpc, base_vha, 0x4006, |
| 5045 | "FCoE context reset end.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5046 | } |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5047 | } else if (IS_QLAFX00(ha)) { |
| 5048 | if (test_and_clear_bit(ISP_UNRECOVERABLE, |
| 5049 | &base_vha->dpc_flags)) { |
| 5050 | ql_dbg(ql_dbg_dpc, base_vha, 0x4020, |
| 5051 | "Firmware Reset Recovery\n"); |
| 5052 | if (qlafx00_reset_initialize(base_vha)) { |
| 5053 | /* Failed. Abort isp later. */ |
| 5054 | if (!test_bit(UNLOADING, |
Dan Carpenter | f92f82d | 2014-05-05 12:47:57 +0300 | [diff] [blame] | 5055 | &base_vha->dpc_flags)) { |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5056 | set_bit(ISP_UNRECOVERABLE, |
| 5057 | &base_vha->dpc_flags); |
| 5058 | ql_dbg(ql_dbg_dpc, base_vha, |
| 5059 | 0x4021, |
| 5060 | "Reset Recovery Failed\n"); |
Dan Carpenter | f92f82d | 2014-05-05 12:47:57 +0300 | [diff] [blame] | 5061 | } |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5062 | } |
| 5063 | } |
| 5064 | |
| 5065 | if (test_and_clear_bit(FX00_TARGET_SCAN, |
| 5066 | &base_vha->dpc_flags)) { |
| 5067 | ql_dbg(ql_dbg_dpc, base_vha, 0x4022, |
| 5068 | "ISPFx00 Target Scan scheduled\n"); |
| 5069 | if (qlafx00_rescan_isp(base_vha)) { |
| 5070 | if (!test_bit(UNLOADING, |
| 5071 | &base_vha->dpc_flags)) |
| 5072 | set_bit(ISP_UNRECOVERABLE, |
| 5073 | &base_vha->dpc_flags); |
| 5074 | ql_dbg(ql_dbg_dpc, base_vha, 0x401e, |
| 5075 | "ISPFx00 Target Scan Failed\n"); |
| 5076 | } |
| 5077 | ql_dbg(ql_dbg_dpc, base_vha, 0x401f, |
| 5078 | "ISPFx00 Target Scan End\n"); |
| 5079 | } |
Armen Baloyan | e8f5e95 | 2013-10-30 03:38:17 -0400 | [diff] [blame] | 5080 | if (test_and_clear_bit(FX00_HOST_INFO_RESEND, |
| 5081 | &base_vha->dpc_flags)) { |
| 5082 | ql_dbg(ql_dbg_dpc, base_vha, 0x4023, |
| 5083 | "ISPFx00 Host Info resend scheduled\n"); |
| 5084 | qlafx00_fx_disc(base_vha, |
| 5085 | &base_vha->hw->mr.fcport, |
| 5086 | FXDISC_REG_HOST_INFO); |
| 5087 | } |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5088 | } |
| 5089 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5090 | if (test_and_clear_bit(ISP_ABORT_NEEDED, |
| 5091 | &base_vha->dpc_flags)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5092 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5093 | ql_dbg(ql_dbg_dpc, base_vha, 0x4007, |
| 5094 | "ISP abort scheduled.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5095 | if (!(test_and_set_bit(ABORT_ISP_ACTIVE, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5096 | &base_vha->dpc_flags))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5097 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5098 | if (ha->isp_ops->abort_isp(base_vha)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5099 | /* failed. retry later */ |
| 5100 | set_bit(ISP_ABORT_NEEDED, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5101 | &base_vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5102 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5103 | clear_bit(ABORT_ISP_ACTIVE, |
| 5104 | &base_vha->dpc_flags); |
Seokmann Ju | 99363ef | 2008-01-31 12:33:51 -0800 | [diff] [blame] | 5105 | } |
| 5106 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5107 | ql_dbg(ql_dbg_dpc, base_vha, 0x4008, |
| 5108 | "ISP abort end.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5109 | } |
| 5110 | |
David Jeffery | a394aac | 2012-11-21 02:39:54 -0500 | [diff] [blame] | 5111 | if (test_and_clear_bit(FCPORT_UPDATE_NEEDED, |
| 5112 | &base_vha->dpc_flags)) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5113 | qla2x00_update_fcports(base_vha); |
Andrew Vasquez | c9c5ced | 2008-07-24 08:31:49 -0700 | [diff] [blame] | 5114 | } |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 5115 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 5116 | if (test_bit(SCR_PENDING, &base_vha->dpc_flags)) { |
| 5117 | int ret; |
| 5118 | ret = qla2x00_send_change_request(base_vha, 0x3, 0); |
| 5119 | if (ret != QLA_SUCCESS) |
| 5120 | ql_log(ql_log_warn, base_vha, 0x121, |
| 5121 | "Failed to enable receiving of RSCN " |
| 5122 | "requests: 0x%x.\n", ret); |
| 5123 | clear_bit(SCR_PENDING, &base_vha->dpc_flags); |
| 5124 | } |
| 5125 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5126 | if (IS_QLAFX00(ha)) |
| 5127 | goto loop_resync_check; |
| 5128 | |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 5129 | if (test_bit(ISP_QUIESCE_NEEDED, &base_vha->dpc_flags)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5130 | ql_dbg(ql_dbg_dpc, base_vha, 0x4009, |
| 5131 | "Quiescence mode scheduled.\n"); |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5132 | if (IS_P3P_TYPE(ha)) { |
| 5133 | if (IS_QLA82XX(ha)) |
| 5134 | qla82xx_device_state_handler(base_vha); |
| 5135 | if (IS_QLA8044(ha)) |
| 5136 | qla8044_device_state_handler(base_vha); |
Chad Dupuis | 8fcd6b8 | 2012-08-22 14:21:06 -0400 | [diff] [blame] | 5137 | clear_bit(ISP_QUIESCE_NEEDED, |
| 5138 | &base_vha->dpc_flags); |
| 5139 | if (!ha->flags.quiesce_owner) { |
| 5140 | qla2x00_perform_loop_resync(base_vha); |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5141 | if (IS_QLA82XX(ha)) { |
| 5142 | qla82xx_idc_lock(ha); |
| 5143 | qla82xx_clear_qsnt_ready( |
| 5144 | base_vha); |
| 5145 | qla82xx_idc_unlock(ha); |
| 5146 | } else if (IS_QLA8044(ha)) { |
| 5147 | qla8044_idc_lock(ha); |
| 5148 | qla8044_clear_qsnt_ready( |
| 5149 | base_vha); |
| 5150 | qla8044_idc_unlock(ha); |
| 5151 | } |
Chad Dupuis | 8fcd6b8 | 2012-08-22 14:21:06 -0400 | [diff] [blame] | 5152 | } |
| 5153 | } else { |
| 5154 | clear_bit(ISP_QUIESCE_NEEDED, |
| 5155 | &base_vha->dpc_flags); |
| 5156 | qla2x00_quiesce_io(base_vha); |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 5157 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5158 | ql_dbg(ql_dbg_dpc, base_vha, 0x400a, |
| 5159 | "Quiescence mode end.\n"); |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 5160 | } |
| 5161 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5162 | if (test_and_clear_bit(RESET_MARKER_NEEDED, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5163 | &base_vha->dpc_flags) && |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5164 | (!(test_and_set_bit(RESET_ACTIVE, &base_vha->dpc_flags)))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5165 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5166 | ql_dbg(ql_dbg_dpc, base_vha, 0x400b, |
| 5167 | "Reset marker scheduled.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5168 | qla2x00_rst_aen(base_vha); |
| 5169 | clear_bit(RESET_ACTIVE, &base_vha->dpc_flags); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5170 | ql_dbg(ql_dbg_dpc, base_vha, 0x400c, |
| 5171 | "Reset marker end.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5172 | } |
| 5173 | |
| 5174 | /* Retry each device up to login retry count */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5175 | if ((test_and_clear_bit(RELOGIN_NEEDED, |
| 5176 | &base_vha->dpc_flags)) && |
| 5177 | !test_bit(LOOP_RESYNC_NEEDED, &base_vha->dpc_flags) && |
| 5178 | atomic_read(&base_vha->loop_state) != LOOP_DOWN) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5179 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5180 | ql_dbg(ql_dbg_dpc, base_vha, 0x400d, |
| 5181 | "Relogin scheduled.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5182 | qla2x00_relogin(base_vha); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5183 | ql_dbg(ql_dbg_dpc, base_vha, 0x400e, |
| 5184 | "Relogin end.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5185 | } |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5186 | loop_resync_check: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5187 | if (test_and_clear_bit(LOOP_RESYNC_NEEDED, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5188 | &base_vha->dpc_flags)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5189 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5190 | ql_dbg(ql_dbg_dpc, base_vha, 0x400f, |
| 5191 | "Loop resync scheduled.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5192 | |
| 5193 | if (!(test_and_set_bit(LOOP_RESYNC_ACTIVE, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5194 | &base_vha->dpc_flags))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5195 | |
Bart Van Assche | 52c8282 | 2015-07-09 07:23:26 -0700 | [diff] [blame] | 5196 | qla2x00_loop_resync(base_vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5197 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5198 | clear_bit(LOOP_RESYNC_ACTIVE, |
| 5199 | &base_vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5200 | } |
| 5201 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5202 | ql_dbg(ql_dbg_dpc, base_vha, 0x4010, |
| 5203 | "Loop resync end.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5204 | } |
| 5205 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5206 | if (IS_QLAFX00(ha)) |
| 5207 | goto intr_on_check; |
| 5208 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5209 | if (test_bit(NPIV_CONFIG_NEEDED, &base_vha->dpc_flags) && |
| 5210 | atomic_read(&base_vha->loop_state) == LOOP_READY) { |
| 5211 | clear_bit(NPIV_CONFIG_NEEDED, &base_vha->dpc_flags); |
| 5212 | qla2xxx_flash_npiv_conf(base_vha); |
Andrew Vasquez | 272976c | 2008-09-11 21:22:50 -0700 | [diff] [blame] | 5213 | } |
| 5214 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5215 | intr_on_check: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5216 | if (!ha->interrupts_on) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 5217 | ha->isp_ops->enable_intrs(ha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5218 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5219 | if (test_and_clear_bit(BEACON_BLINK_NEEDED, |
Himanshu Madani | 90b604f | 2014-04-11 16:54:40 -0400 | [diff] [blame] | 5220 | &base_vha->dpc_flags)) { |
| 5221 | if (ha->beacon_blink_led == 1) |
| 5222 | ha->isp_ops->beacon_blink(base_vha); |
| 5223 | } |
andrew.vasquez@qlogic.com | f6df144 | 2006-01-31 16:05:07 -0800 | [diff] [blame] | 5224 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5225 | if (!IS_QLAFX00(ha)) |
| 5226 | qla2x00_do_dpc_all_vps(base_vha); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5227 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5228 | ha->dpc_active = 0; |
Andrew Vasquez | c142caf | 2011-11-18 09:03:10 -0800 | [diff] [blame] | 5229 | end_loop: |
James Bottomley | 563585e | 2011-01-27 16:12:37 -0500 | [diff] [blame] | 5230 | set_current_state(TASK_INTERRUPTIBLE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5231 | } /* End of while(1) */ |
James Bottomley | 563585e | 2011-01-27 16:12:37 -0500 | [diff] [blame] | 5232 | __set_current_state(TASK_RUNNING); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5233 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5234 | ql_dbg(ql_dbg_dpc, base_vha, 0x4011, |
| 5235 | "DPC handler exiting.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5236 | |
| 5237 | /* |
| 5238 | * Make sure that nobody tries to wake us up again. |
| 5239 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5240 | ha->dpc_active = 0; |
| 5241 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 5242 | /* Cleanup any residual CTX SRBs. */ |
| 5243 | qla2x00_abort_all_cmds(base_vha, DID_NO_CONNECT << 16); |
| 5244 | |
Christoph Hellwig | 39a1124 | 2006-02-14 18:46:22 +0100 | [diff] [blame] | 5245 | return 0; |
| 5246 | } |
| 5247 | |
| 5248 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5249 | qla2xxx_wake_dpc(struct scsi_qla_host *vha) |
Christoph Hellwig | 39a1124 | 2006-02-14 18:46:22 +0100 | [diff] [blame] | 5250 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5251 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | c795c1e | 2008-08-13 21:37:01 -0700 | [diff] [blame] | 5252 | struct task_struct *t = ha->dpc_thread; |
| 5253 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5254 | if (!test_bit(UNLOADING, &vha->dpc_flags) && t) |
Andrew Vasquez | c795c1e | 2008-08-13 21:37:01 -0700 | [diff] [blame] | 5255 | wake_up_process(t); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5256 | } |
| 5257 | |
| 5258 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5259 | * qla2x00_rst_aen |
| 5260 | * Processes asynchronous reset. |
| 5261 | * |
| 5262 | * Input: |
| 5263 | * ha = adapter block pointer. |
| 5264 | */ |
| 5265 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5266 | qla2x00_rst_aen(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5267 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5268 | if (vha->flags.online && !vha->flags.reset_active && |
| 5269 | !atomic_read(&vha->loop_down_timer) && |
| 5270 | !(test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5271 | do { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5272 | clear_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5273 | |
| 5274 | /* |
| 5275 | * Issue marker command only when we are going to start |
| 5276 | * the I/O. |
| 5277 | */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5278 | vha->marker_needed = 1; |
| 5279 | } while (!atomic_read(&vha->loop_down_timer) && |
| 5280 | (test_bit(RESET_MARKER_NEEDED, &vha->dpc_flags))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5281 | } |
| 5282 | } |
| 5283 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5284 | /************************************************************************** |
| 5285 | * qla2x00_timer |
| 5286 | * |
| 5287 | * Description: |
| 5288 | * One second timer |
| 5289 | * |
| 5290 | * Context: Interrupt |
| 5291 | ***************************************************************************/ |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5292 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5293 | qla2x00_timer(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5294 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5295 | unsigned long cpu_flags = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5296 | int start_dpc = 0; |
| 5297 | int index; |
| 5298 | srb_t *sp; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5299 | uint16_t w; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5300 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 5301 | struct req_que *req; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5302 | |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5303 | if (ha->flags.eeh_busy) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5304 | ql_dbg(ql_dbg_timer, vha, 0x6000, |
| 5305 | "EEH = %d, restarting timer.\n", |
| 5306 | ha->flags.eeh_busy); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5307 | qla2x00_restart_timer(vha, WATCH_INTERVAL); |
| 5308 | return; |
| 5309 | } |
| 5310 | |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5311 | /* |
| 5312 | * Hardware read to raise pending EEH errors during mailbox waits. If |
| 5313 | * the read returns -1 then disable the board. |
| 5314 | */ |
| 5315 | if (!pci_channel_offline(ha->pdev)) { |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5316 | pci_read_config_word(ha->pdev, PCI_VENDOR_ID, &w); |
Joe Lawrence | c821e0d | 2014-08-26 17:11:41 -0400 | [diff] [blame] | 5317 | qla2x00_check_reg16_for_disconnect(vha, w); |
Chad Dupuis | f3ddac1 | 2013-10-30 03:38:16 -0400 | [diff] [blame] | 5318 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5319 | |
Saurav Kashyap | cefcaba | 2011-05-10 11:18:18 -0700 | [diff] [blame] | 5320 | /* Make sure qla82xx_watchdog is run only for physical port */ |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5321 | if (!vha->vp_idx && IS_P3P_TYPE(ha)) { |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 5322 | if (test_bit(ISP_QUIESCE_NEEDED, &vha->dpc_flags)) |
| 5323 | start_dpc++; |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5324 | if (IS_QLA82XX(ha)) |
| 5325 | qla82xx_watchdog(vha); |
| 5326 | else if (IS_QLA8044(ha)) |
| 5327 | qla8044_watchdog(vha); |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 5328 | } |
| 5329 | |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5330 | if (!vha->vp_idx && IS_QLAFX00(ha)) |
| 5331 | qlafx00_timer_routine(vha); |
| 5332 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5333 | /* Loop down handler. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5334 | if (atomic_read(&vha->loop_down_timer) > 0 && |
Giridhar Malavali | 8f7daea | 2011-03-30 11:46:26 -0700 | [diff] [blame] | 5335 | !(test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags)) && |
| 5336 | !(test_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags)) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5337 | && vha->flags.online) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5338 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5339 | if (atomic_read(&vha->loop_down_timer) == |
| 5340 | vha->loop_down_abort_time) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5341 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5342 | ql_log(ql_log_info, vha, 0x6008, |
| 5343 | "Loop down - aborting the queues before time expires.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5344 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5345 | if (!IS_QLA2100(ha) && vha->link_down_timeout) |
| 5346 | atomic_set(&vha->loop_state, LOOP_DEAD); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5347 | |
Andrew Vasquez | f08b725 | 2010-01-12 12:59:48 -0800 | [diff] [blame] | 5348 | /* |
| 5349 | * Schedule an ISP abort to return any FCP2-device |
| 5350 | * commands. |
| 5351 | */ |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5352 | /* NPIV - scan physical port only */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5353 | if (!vha->vp_idx) { |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5354 | spin_lock_irqsave(&ha->hardware_lock, |
| 5355 | cpu_flags); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 5356 | req = ha->req_q_map[0]; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5357 | for (index = 1; |
Chad Dupuis | 8d93f55 | 2013-01-30 03:34:37 -0500 | [diff] [blame] | 5358 | index < req->num_outstanding_cmds; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5359 | index++) { |
| 5360 | fc_port_t *sfcp; |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 5361 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5362 | sp = req->outstanding_cmds[index]; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5363 | if (!sp) |
| 5364 | continue; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 5365 | if (sp->type != SRB_SCSI_CMD) |
Andrew Vasquez | cf53b06 | 2009-08-20 11:06:04 -0700 | [diff] [blame] | 5366 | continue; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5367 | sfcp = sp->fcport; |
Andrew Vasquez | f08b725 | 2010-01-12 12:59:48 -0800 | [diff] [blame] | 5368 | if (!(sfcp->flags & FCF_FCP2_DEVICE)) |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5369 | continue; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5370 | |
Giridhar Malavali | 8f7daea | 2011-03-30 11:46:26 -0700 | [diff] [blame] | 5371 | if (IS_QLA82XX(ha)) |
| 5372 | set_bit(FCOE_CTX_RESET_NEEDED, |
| 5373 | &vha->dpc_flags); |
| 5374 | else |
| 5375 | set_bit(ISP_ABORT_NEEDED, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5376 | &vha->dpc_flags); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5377 | break; |
| 5378 | } |
| 5379 | spin_unlock_irqrestore(&ha->hardware_lock, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5380 | cpu_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5381 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5382 | start_dpc++; |
| 5383 | } |
| 5384 | |
| 5385 | /* if the loop has been down for 4 minutes, reinit adapter */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5386 | if (atomic_dec_and_test(&vha->loop_down_timer) != 0) { |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 5387 | if (!(vha->device_flags & DFLG_NO_CABLE)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5388 | ql_log(ql_log_warn, vha, 0x6009, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5389 | "Loop down - aborting ISP.\n"); |
| 5390 | |
Giridhar Malavali | 8f7daea | 2011-03-30 11:46:26 -0700 | [diff] [blame] | 5391 | if (IS_QLA82XX(ha)) |
| 5392 | set_bit(FCOE_CTX_RESET_NEEDED, |
| 5393 | &vha->dpc_flags); |
| 5394 | else |
| 5395 | set_bit(ISP_ABORT_NEEDED, |
| 5396 | &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5397 | } |
| 5398 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5399 | ql_dbg(ql_dbg_timer, vha, 0x600a, |
| 5400 | "Loop down - seconds remaining %d.\n", |
| 5401 | atomic_read(&vha->loop_down_timer)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5402 | } |
Saurav Kashyap | cefcaba | 2011-05-10 11:18:18 -0700 | [diff] [blame] | 5403 | /* Check if beacon LED needs to be blinked for physical host only */ |
| 5404 | if (!vha->vp_idx && (ha->beacon_blink_led == 1)) { |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 5405 | /* There is no beacon_blink function for ISP82xx */ |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5406 | if (!IS_P3P_TYPE(ha)) { |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 5407 | set_bit(BEACON_BLINK_NEEDED, &vha->dpc_flags); |
| 5408 | start_dpc++; |
| 5409 | } |
andrew.vasquez@qlogic.com | f6df144 | 2006-01-31 16:05:07 -0800 | [diff] [blame] | 5410 | } |
| 5411 | |
Andrew Vasquez | 550bf57 | 2008-04-24 15:21:23 -0700 | [diff] [blame] | 5412 | /* Process any deferred work. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5413 | if (!list_empty(&vha->work_list)) |
Andrew Vasquez | 550bf57 | 2008-04-24 15:21:23 -0700 | [diff] [blame] | 5414 | start_dpc++; |
| 5415 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5416 | /* Schedule the DPC routine if needed */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5417 | if ((test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) || |
| 5418 | test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags) || |
| 5419 | test_bit(FCPORT_UPDATE_NEEDED, &vha->dpc_flags) || |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5420 | start_dpc || |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5421 | test_bit(RESET_MARKER_NEEDED, &vha->dpc_flags) || |
| 5422 | test_bit(BEACON_BLINK_NEEDED, &vha->dpc_flags) || |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5423 | test_bit(ISP_UNRECOVERABLE, &vha->dpc_flags) || |
| 5424 | test_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags) || |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5425 | test_bit(VP_DPC_NEEDED, &vha->dpc_flags) || |
Chad Dupuis | 50280c0 | 2013-10-30 03:38:14 -0400 | [diff] [blame] | 5426 | test_bit(RELOGIN_NEEDED, &vha->dpc_flags))) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5427 | ql_dbg(ql_dbg_timer, vha, 0x600b, |
| 5428 | "isp_abort_needed=%d loop_resync_needed=%d " |
| 5429 | "fcport_update_needed=%d start_dpc=%d " |
| 5430 | "reset_marker_needed=%d", |
| 5431 | test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags), |
| 5432 | test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags), |
| 5433 | test_bit(FCPORT_UPDATE_NEEDED, &vha->dpc_flags), |
| 5434 | start_dpc, |
| 5435 | test_bit(RESET_MARKER_NEEDED, &vha->dpc_flags)); |
| 5436 | ql_dbg(ql_dbg_timer, vha, 0x600c, |
| 5437 | "beacon_blink_needed=%d isp_unrecoverable=%d " |
| 5438 | "fcoe_ctx_reset_needed=%d vp_dpc_needed=%d " |
Chad Dupuis | 50280c0 | 2013-10-30 03:38:14 -0400 | [diff] [blame] | 5439 | "relogin_needed=%d.\n", |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5440 | test_bit(BEACON_BLINK_NEEDED, &vha->dpc_flags), |
| 5441 | test_bit(ISP_UNRECOVERABLE, &vha->dpc_flags), |
| 5442 | test_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags), |
| 5443 | test_bit(VP_DPC_NEEDED, &vha->dpc_flags), |
Chad Dupuis | 50280c0 | 2013-10-30 03:38:14 -0400 | [diff] [blame] | 5444 | test_bit(RELOGIN_NEEDED, &vha->dpc_flags)); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5445 | qla2xxx_wake_dpc(vha); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5446 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5447 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5448 | qla2x00_restart_timer(vha, WATCH_INTERVAL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5449 | } |
| 5450 | |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5451 | /* Firmware interface routines. */ |
| 5452 | |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 5453 | #define FW_BLOBS 11 |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5454 | #define FW_ISP21XX 0 |
| 5455 | #define FW_ISP22XX 1 |
| 5456 | #define FW_ISP2300 2 |
| 5457 | #define FW_ISP2322 3 |
andrew.vasquez@qlogic.com | 48c02fd | 2006-03-09 14:27:18 -0800 | [diff] [blame] | 5458 | #define FW_ISP24XX 4 |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 5459 | #define FW_ISP25XX 5 |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5460 | #define FW_ISP81XX 6 |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5461 | #define FW_ISP82XX 7 |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5462 | #define FW_ISP2031 8 |
| 5463 | #define FW_ISP8031 9 |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 5464 | #define FW_ISP27XX 10 |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5465 | |
Andrew Vasquez | bb8ee49 | 2006-10-02 12:00:48 -0700 | [diff] [blame] | 5466 | #define FW_FILE_ISP21XX "ql2100_fw.bin" |
| 5467 | #define FW_FILE_ISP22XX "ql2200_fw.bin" |
| 5468 | #define FW_FILE_ISP2300 "ql2300_fw.bin" |
| 5469 | #define FW_FILE_ISP2322 "ql2322_fw.bin" |
| 5470 | #define FW_FILE_ISP24XX "ql2400_fw.bin" |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 5471 | #define FW_FILE_ISP25XX "ql2500_fw.bin" |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5472 | #define FW_FILE_ISP81XX "ql8100_fw.bin" |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5473 | #define FW_FILE_ISP82XX "ql8200_fw.bin" |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5474 | #define FW_FILE_ISP2031 "ql2600_fw.bin" |
| 5475 | #define FW_FILE_ISP8031 "ql8300_fw.bin" |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 5476 | #define FW_FILE_ISP27XX "ql2700_fw.bin" |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 5477 | |
Andrew Vasquez | bb8ee49 | 2006-10-02 12:00:48 -0700 | [diff] [blame] | 5478 | |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 5479 | static DEFINE_MUTEX(qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5480 | |
| 5481 | static struct fw_blob qla_fw_blobs[FW_BLOBS] = { |
Andrew Vasquez | bb8ee49 | 2006-10-02 12:00:48 -0700 | [diff] [blame] | 5482 | { .name = FW_FILE_ISP21XX, .segs = { 0x1000, 0 }, }, |
| 5483 | { .name = FW_FILE_ISP22XX, .segs = { 0x1000, 0 }, }, |
| 5484 | { .name = FW_FILE_ISP2300, .segs = { 0x800, 0 }, }, |
| 5485 | { .name = FW_FILE_ISP2322, .segs = { 0x800, 0x1c000, 0x1e000, 0 }, }, |
| 5486 | { .name = FW_FILE_ISP24XX, }, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 5487 | { .name = FW_FILE_ISP25XX, }, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5488 | { .name = FW_FILE_ISP81XX, }, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5489 | { .name = FW_FILE_ISP82XX, }, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5490 | { .name = FW_FILE_ISP2031, }, |
| 5491 | { .name = FW_FILE_ISP8031, }, |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 5492 | { .name = FW_FILE_ISP27XX, }, |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5493 | }; |
| 5494 | |
| 5495 | struct fw_blob * |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5496 | qla2x00_request_firmware(scsi_qla_host_t *vha) |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5497 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5498 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5499 | struct fw_blob *blob; |
| 5500 | |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5501 | if (IS_QLA2100(ha)) { |
| 5502 | blob = &qla_fw_blobs[FW_ISP21XX]; |
| 5503 | } else if (IS_QLA2200(ha)) { |
| 5504 | blob = &qla_fw_blobs[FW_ISP22XX]; |
andrew.vasquez@qlogic.com | 48c02fd | 2006-03-09 14:27:18 -0800 | [diff] [blame] | 5505 | } else if (IS_QLA2300(ha) || IS_QLA2312(ha) || IS_QLA6312(ha)) { |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5506 | blob = &qla_fw_blobs[FW_ISP2300]; |
andrew.vasquez@qlogic.com | 48c02fd | 2006-03-09 14:27:18 -0800 | [diff] [blame] | 5507 | } else if (IS_QLA2322(ha) || IS_QLA6322(ha)) { |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5508 | blob = &qla_fw_blobs[FW_ISP2322]; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 5509 | } else if (IS_QLA24XX_TYPE(ha)) { |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5510 | blob = &qla_fw_blobs[FW_ISP24XX]; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 5511 | } else if (IS_QLA25XX(ha)) { |
| 5512 | blob = &qla_fw_blobs[FW_ISP25XX]; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5513 | } else if (IS_QLA81XX(ha)) { |
| 5514 | blob = &qla_fw_blobs[FW_ISP81XX]; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5515 | } else if (IS_QLA82XX(ha)) { |
| 5516 | blob = &qla_fw_blobs[FW_ISP82XX]; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5517 | } else if (IS_QLA2031(ha)) { |
| 5518 | blob = &qla_fw_blobs[FW_ISP2031]; |
| 5519 | } else if (IS_QLA8031(ha)) { |
| 5520 | blob = &qla_fw_blobs[FW_ISP8031]; |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 5521 | } else if (IS_QLA27XX(ha)) { |
| 5522 | blob = &qla_fw_blobs[FW_ISP27XX]; |
Dan Carpenter | 8a65522 | 2012-02-21 10:29:40 +0300 | [diff] [blame] | 5523 | } else { |
| 5524 | return NULL; |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5525 | } |
| 5526 | |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 5527 | mutex_lock(&qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5528 | if (blob->fw) |
| 5529 | goto out; |
| 5530 | |
| 5531 | if (request_firmware(&blob->fw, blob->name, &ha->pdev->dev)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5532 | ql_log(ql_log_warn, vha, 0x0063, |
| 5533 | "Failed to load firmware image (%s).\n", blob->name); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5534 | blob->fw = NULL; |
| 5535 | blob = NULL; |
| 5536 | goto out; |
| 5537 | } |
| 5538 | |
| 5539 | out: |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 5540 | mutex_unlock(&qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5541 | return blob; |
| 5542 | } |
| 5543 | |
| 5544 | static void |
| 5545 | qla2x00_release_firmware(void) |
| 5546 | { |
| 5547 | int idx; |
| 5548 | |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 5549 | mutex_lock(&qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5550 | for (idx = 0; idx < FW_BLOBS; idx++) |
Jesper Juhl | cf92549 | 2012-04-09 22:51:41 +0200 | [diff] [blame] | 5551 | release_firmware(qla_fw_blobs[idx].fw); |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 5552 | mutex_unlock(&qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5553 | } |
| 5554 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5555 | static pci_ers_result_t |
| 5556 | qla2xxx_pci_error_detected(struct pci_dev *pdev, pci_channel_state_t state) |
| 5557 | { |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5558 | scsi_qla_host_t *vha = pci_get_drvdata(pdev); |
| 5559 | struct qla_hw_data *ha = vha->hw; |
| 5560 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5561 | ql_dbg(ql_dbg_aer, vha, 0x9000, |
| 5562 | "PCI error detected, state %x.\n", state); |
Seokmann Ju | b9b12f7 | 2009-03-24 09:08:18 -0700 | [diff] [blame] | 5563 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5564 | switch (state) { |
| 5565 | case pci_channel_io_normal: |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5566 | ha->flags.eeh_busy = 0; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5567 | return PCI_ERS_RESULT_CAN_RECOVER; |
| 5568 | case pci_channel_io_frozen: |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5569 | ha->flags.eeh_busy = 1; |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5570 | /* For ISP82XX complete any pending mailbox cmd */ |
| 5571 | if (IS_QLA82XX(ha)) { |
Giridhar Malavali | 7190575 | 2011-02-23 15:27:10 -0800 | [diff] [blame] | 5572 | ha->flags.isp82xx_fw_hung = 1; |
Chad Dupuis | c8f6544 | 2011-11-18 09:02:17 -0800 | [diff] [blame] | 5573 | ql_dbg(ql_dbg_aer, vha, 0x9001, "Pci channel io frozen\n"); |
| 5574 | qla82xx_clear_pending_mbx(vha); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5575 | } |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 5576 | qla2x00_free_irqs(vha); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5577 | pci_disable_device(pdev); |
Lalit Chandivade | bddd2d6 | 2010-09-03 15:20:53 -0700 | [diff] [blame] | 5578 | /* Return back all IOs */ |
| 5579 | qla2x00_abort_all_cmds(vha, DID_RESET << 16); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5580 | return PCI_ERS_RESULT_NEED_RESET; |
| 5581 | case pci_channel_io_perm_failure: |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5582 | ha->flags.pci_channel_io_perm_failure = 1; |
| 5583 | qla2x00_abort_all_cmds(vha, DID_NO_CONNECT << 16); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5584 | return PCI_ERS_RESULT_DISCONNECT; |
| 5585 | } |
| 5586 | return PCI_ERS_RESULT_NEED_RESET; |
| 5587 | } |
| 5588 | |
| 5589 | static pci_ers_result_t |
| 5590 | qla2xxx_pci_mmio_enabled(struct pci_dev *pdev) |
| 5591 | { |
| 5592 | int risc_paused = 0; |
| 5593 | uint32_t stat; |
| 5594 | unsigned long flags; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5595 | scsi_qla_host_t *base_vha = pci_get_drvdata(pdev); |
| 5596 | struct qla_hw_data *ha = base_vha->hw; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5597 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
| 5598 | struct device_reg_24xx __iomem *reg24 = &ha->iobase->isp24; |
| 5599 | |
Saurav Kashyap | bcc5b6d | 2010-09-03 15:20:57 -0700 | [diff] [blame] | 5600 | if (IS_QLA82XX(ha)) |
| 5601 | return PCI_ERS_RESULT_RECOVERED; |
| 5602 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5603 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 5604 | if (IS_QLA2100(ha) || IS_QLA2200(ha)){ |
| 5605 | stat = RD_REG_DWORD(®->hccr); |
| 5606 | if (stat & HCCR_RISC_PAUSE) |
| 5607 | risc_paused = 1; |
| 5608 | } else if (IS_QLA23XX(ha)) { |
| 5609 | stat = RD_REG_DWORD(®->u.isp2300.host_status); |
| 5610 | if (stat & HSR_RISC_PAUSED) |
| 5611 | risc_paused = 1; |
| 5612 | } else if (IS_FWI2_CAPABLE(ha)) { |
| 5613 | stat = RD_REG_DWORD(®24->host_status); |
| 5614 | if (stat & HSRX_RISC_PAUSED) |
| 5615 | risc_paused = 1; |
| 5616 | } |
| 5617 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 5618 | |
| 5619 | if (risc_paused) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5620 | ql_log(ql_log_info, base_vha, 0x9003, |
| 5621 | "RISC paused -- mmio_enabled, Dumping firmware.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5622 | ha->isp_ops->fw_dump(base_vha, 0); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5623 | |
| 5624 | return PCI_ERS_RESULT_NEED_RESET; |
| 5625 | } else |
| 5626 | return PCI_ERS_RESULT_RECOVERED; |
| 5627 | } |
| 5628 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 5629 | static uint32_t |
| 5630 | qla82xx_error_recovery(scsi_qla_host_t *base_vha) |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5631 | { |
| 5632 | uint32_t rval = QLA_FUNCTION_FAILED; |
| 5633 | uint32_t drv_active = 0; |
| 5634 | struct qla_hw_data *ha = base_vha->hw; |
| 5635 | int fn; |
| 5636 | struct pci_dev *other_pdev = NULL; |
| 5637 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5638 | ql_dbg(ql_dbg_aer, base_vha, 0x9006, |
| 5639 | "Entered %s.\n", __func__); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5640 | |
| 5641 | set_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
| 5642 | |
| 5643 | if (base_vha->flags.online) { |
| 5644 | /* Abort all outstanding commands, |
| 5645 | * so as to be requeued later */ |
| 5646 | qla2x00_abort_isp_cleanup(base_vha); |
| 5647 | } |
| 5648 | |
| 5649 | |
| 5650 | fn = PCI_FUNC(ha->pdev->devfn); |
| 5651 | while (fn > 0) { |
| 5652 | fn--; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5653 | ql_dbg(ql_dbg_aer, base_vha, 0x9007, |
| 5654 | "Finding pci device at function = 0x%x.\n", fn); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5655 | other_pdev = |
| 5656 | pci_get_domain_bus_and_slot(pci_domain_nr(ha->pdev->bus), |
| 5657 | ha->pdev->bus->number, PCI_DEVFN(PCI_SLOT(ha->pdev->devfn), |
| 5658 | fn)); |
| 5659 | |
| 5660 | if (!other_pdev) |
| 5661 | continue; |
| 5662 | if (atomic_read(&other_pdev->enable_cnt)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5663 | ql_dbg(ql_dbg_aer, base_vha, 0x9008, |
| 5664 | "Found PCI func available and enable at 0x%x.\n", |
| 5665 | fn); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5666 | pci_dev_put(other_pdev); |
| 5667 | break; |
| 5668 | } |
| 5669 | pci_dev_put(other_pdev); |
| 5670 | } |
| 5671 | |
| 5672 | if (!fn) { |
| 5673 | /* Reset owner */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5674 | ql_dbg(ql_dbg_aer, base_vha, 0x9009, |
| 5675 | "This devfn is reset owner = 0x%x.\n", |
| 5676 | ha->pdev->devfn); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5677 | qla82xx_idc_lock(ha); |
| 5678 | |
| 5679 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5680 | QLA8XXX_DEV_INITIALIZING); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5681 | |
| 5682 | qla82xx_wr_32(ha, QLA82XX_CRB_DRV_IDC_VERSION, |
| 5683 | QLA82XX_IDC_VERSION); |
| 5684 | |
| 5685 | drv_active = qla82xx_rd_32(ha, QLA82XX_CRB_DRV_ACTIVE); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5686 | ql_dbg(ql_dbg_aer, base_vha, 0x900a, |
| 5687 | "drv_active = 0x%x.\n", drv_active); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5688 | |
| 5689 | qla82xx_idc_unlock(ha); |
| 5690 | /* Reset if device is not already reset |
| 5691 | * drv_active would be 0 if a reset has already been done |
| 5692 | */ |
| 5693 | if (drv_active) |
| 5694 | rval = qla82xx_start_firmware(base_vha); |
| 5695 | else |
| 5696 | rval = QLA_SUCCESS; |
| 5697 | qla82xx_idc_lock(ha); |
| 5698 | |
| 5699 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5700 | ql_log(ql_log_info, base_vha, 0x900b, |
| 5701 | "HW State: FAILED.\n"); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5702 | qla82xx_clear_drv_active(ha); |
| 5703 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5704 | QLA8XXX_DEV_FAILED); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5705 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5706 | ql_log(ql_log_info, base_vha, 0x900c, |
| 5707 | "HW State: READY.\n"); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5708 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5709 | QLA8XXX_DEV_READY); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5710 | qla82xx_idc_unlock(ha); |
Giridhar Malavali | 7190575 | 2011-02-23 15:27:10 -0800 | [diff] [blame] | 5711 | ha->flags.isp82xx_fw_hung = 0; |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5712 | rval = qla82xx_restart_isp(base_vha); |
| 5713 | qla82xx_idc_lock(ha); |
| 5714 | /* Clear driver state register */ |
| 5715 | qla82xx_wr_32(ha, QLA82XX_CRB_DRV_STATE, 0); |
| 5716 | qla82xx_set_drv_active(base_vha); |
| 5717 | } |
| 5718 | qla82xx_idc_unlock(ha); |
| 5719 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5720 | ql_dbg(ql_dbg_aer, base_vha, 0x900d, |
| 5721 | "This devfn is not reset owner = 0x%x.\n", |
| 5722 | ha->pdev->devfn); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5723 | if ((qla82xx_rd_32(ha, QLA82XX_CRB_DEV_STATE) == |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5724 | QLA8XXX_DEV_READY)) { |
Giridhar Malavali | 7190575 | 2011-02-23 15:27:10 -0800 | [diff] [blame] | 5725 | ha->flags.isp82xx_fw_hung = 0; |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5726 | rval = qla82xx_restart_isp(base_vha); |
| 5727 | qla82xx_idc_lock(ha); |
| 5728 | qla82xx_set_drv_active(base_vha); |
| 5729 | qla82xx_idc_unlock(ha); |
| 5730 | } |
| 5731 | } |
| 5732 | clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
| 5733 | |
| 5734 | return rval; |
| 5735 | } |
| 5736 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5737 | static pci_ers_result_t |
| 5738 | qla2xxx_pci_slot_reset(struct pci_dev *pdev) |
| 5739 | { |
| 5740 | pci_ers_result_t ret = PCI_ERS_RESULT_DISCONNECT; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5741 | scsi_qla_host_t *base_vha = pci_get_drvdata(pdev); |
| 5742 | struct qla_hw_data *ha = base_vha->hw; |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 5743 | struct rsp_que *rsp; |
| 5744 | int rc, retries = 10; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5745 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5746 | ql_dbg(ql_dbg_aer, base_vha, 0x9004, |
| 5747 | "Slot Reset.\n"); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5748 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 5749 | /* Workaround: qla2xxx driver which access hardware earlier |
| 5750 | * needs error state to be pci_channel_io_online. |
| 5751 | * Otherwise mailbox command timesout. |
| 5752 | */ |
| 5753 | pdev->error_state = pci_channel_io_normal; |
| 5754 | |
| 5755 | pci_restore_state(pdev); |
| 5756 | |
Richard Lary | 8c1496b | 2010-02-18 10:07:29 -0800 | [diff] [blame] | 5757 | /* pci_restore_state() clears the saved_state flag of the device |
| 5758 | * save restored state which resets saved_state flag |
| 5759 | */ |
| 5760 | pci_save_state(pdev); |
| 5761 | |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 5762 | if (ha->mem_only) |
| 5763 | rc = pci_enable_device_mem(pdev); |
| 5764 | else |
| 5765 | rc = pci_enable_device(pdev); |
| 5766 | |
| 5767 | if (rc) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5768 | ql_log(ql_log_warn, base_vha, 0x9005, |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5769 | "Can't re-enable PCI device after reset.\n"); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5770 | goto exit_slot_reset; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5771 | } |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5772 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 5773 | rsp = ha->rsp_q_map[0]; |
| 5774 | if (qla2x00_request_irqs(ha, rsp)) |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5775 | goto exit_slot_reset; |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 5776 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5777 | if (ha->isp_ops->pci_config(base_vha)) |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5778 | goto exit_slot_reset; |
| 5779 | |
| 5780 | if (IS_QLA82XX(ha)) { |
| 5781 | if (qla82xx_error_recovery(base_vha) == QLA_SUCCESS) { |
| 5782 | ret = PCI_ERS_RESULT_RECOVERED; |
| 5783 | goto exit_slot_reset; |
| 5784 | } else |
| 5785 | goto exit_slot_reset; |
| 5786 | } |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5787 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 5788 | while (ha->flags.mbox_busy && retries--) |
| 5789 | msleep(1000); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5790 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5791 | set_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5792 | if (ha->isp_ops->abort_isp(base_vha) == QLA_SUCCESS) |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5793 | ret = PCI_ERS_RESULT_RECOVERED; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5794 | clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5795 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 5796 | |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5797 | exit_slot_reset: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5798 | ql_dbg(ql_dbg_aer, base_vha, 0x900e, |
| 5799 | "slot_reset return %x.\n", ret); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5800 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5801 | return ret; |
| 5802 | } |
| 5803 | |
| 5804 | static void |
| 5805 | qla2xxx_pci_resume(struct pci_dev *pdev) |
| 5806 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5807 | scsi_qla_host_t *base_vha = pci_get_drvdata(pdev); |
| 5808 | struct qla_hw_data *ha = base_vha->hw; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5809 | int ret; |
| 5810 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5811 | ql_dbg(ql_dbg_aer, base_vha, 0x900f, |
| 5812 | "pci_resume.\n"); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5813 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5814 | ret = qla2x00_wait_for_hba_online(base_vha); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5815 | if (ret != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5816 | ql_log(ql_log_fatal, base_vha, 0x9002, |
| 5817 | "The device failed to resume I/O from slot/link_reset.\n"); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5818 | } |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5819 | |
Lalit Chandivade | 3e46f03 | 2010-05-04 15:01:23 -0700 | [diff] [blame] | 5820 | pci_cleanup_aer_uncorrect_error_status(pdev); |
| 5821 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5822 | ha->flags.eeh_busy = 0; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5823 | } |
| 5824 | |
Himanshu Madhani | 2d5a4c3 | 2014-09-25 05:16:55 -0400 | [diff] [blame] | 5825 | static void |
| 5826 | qla83xx_disable_laser(scsi_qla_host_t *vha) |
| 5827 | { |
| 5828 | uint32_t reg, data, fn; |
| 5829 | struct qla_hw_data *ha = vha->hw; |
| 5830 | struct device_reg_24xx __iomem *isp_reg = &ha->iobase->isp24; |
| 5831 | |
| 5832 | /* pci func #/port # */ |
| 5833 | ql_dbg(ql_dbg_init, vha, 0x004b, |
| 5834 | "Disabling Laser for hba: %p\n", vha); |
| 5835 | |
| 5836 | fn = (RD_REG_DWORD(&isp_reg->ctrl_status) & |
| 5837 | (BIT_15|BIT_14|BIT_13|BIT_12)); |
| 5838 | |
| 5839 | fn = (fn >> 12); |
| 5840 | |
| 5841 | if (fn & 1) |
| 5842 | reg = PORT_1_2031; |
| 5843 | else |
| 5844 | reg = PORT_0_2031; |
| 5845 | |
| 5846 | data = LASER_OFF_2031; |
| 5847 | |
| 5848 | qla83xx_wr_reg(vha, reg, data); |
| 5849 | } |
| 5850 | |
Stephen Hemminger | a55b2d2 | 2012-09-07 09:33:16 -0700 | [diff] [blame] | 5851 | static const struct pci_error_handlers qla2xxx_err_handler = { |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5852 | .error_detected = qla2xxx_pci_error_detected, |
| 5853 | .mmio_enabled = qla2xxx_pci_mmio_enabled, |
| 5854 | .slot_reset = qla2xxx_pci_slot_reset, |
| 5855 | .resume = qla2xxx_pci_resume, |
| 5856 | }; |
| 5857 | |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5858 | static struct pci_device_id qla2xxx_pci_tbl[] = { |
Andrew Vasquez | 47f5e06 | 2006-05-17 15:09:39 -0700 | [diff] [blame] | 5859 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2100) }, |
| 5860 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2200) }, |
| 5861 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2300) }, |
| 5862 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2312) }, |
| 5863 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2322) }, |
| 5864 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP6312) }, |
| 5865 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP6322) }, |
| 5866 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2422) }, |
| 5867 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2432) }, |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 5868 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8432) }, |
Andrew Vasquez | 47f5e06 | 2006-05-17 15:09:39 -0700 | [diff] [blame] | 5869 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP5422) }, |
| 5870 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP5432) }, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 5871 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2532) }, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5872 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2031) }, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5873 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8001) }, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5874 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8021) }, |
Chad Dupuis | 650f528 | 2012-08-22 14:20:55 -0400 | [diff] [blame] | 5875 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8031) }, |
Giridhar Malavali | 8ae6d9c | 2013-03-28 08:21:23 -0400 | [diff] [blame] | 5876 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISPF001) }, |
Atul Deshmukh | 7ec0eff | 2013-08-27 01:37:28 -0400 | [diff] [blame] | 5877 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8044) }, |
Chad Dupuis | f73cb69 | 2014-02-26 04:15:06 -0500 | [diff] [blame] | 5878 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2071) }, |
Joe Carnuccio | 2c5bbbb | 2014-04-11 16:54:13 -0400 | [diff] [blame] | 5879 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2271) }, |
Sawan Chandak | 2b48992 | 2015-08-04 13:38:03 -0400 | [diff] [blame] | 5880 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2261) }, |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5881 | { 0 }, |
| 5882 | }; |
| 5883 | MODULE_DEVICE_TABLE(pci, qla2xxx_pci_tbl); |
| 5884 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 5885 | static struct pci_driver qla2xxx_pci_driver = { |
Andrew Vasquez | cb63067 | 2006-05-17 15:09:45 -0700 | [diff] [blame] | 5886 | .name = QLA2XXX_DRIVER_NAME, |
James Bottomley | 0a21ef1 | 2005-12-01 12:51:50 -0600 | [diff] [blame] | 5887 | .driver = { |
| 5888 | .owner = THIS_MODULE, |
| 5889 | }, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 5890 | .id_table = qla2xxx_pci_tbl, |
Andrew Vasquez | 7ee6139 | 2006-06-23 16:11:22 -0700 | [diff] [blame] | 5891 | .probe = qla2x00_probe_one, |
Adrian Bunk | 4c993f7 | 2008-01-14 00:55:16 -0800 | [diff] [blame] | 5892 | .remove = qla2x00_remove_one, |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 5893 | .shutdown = qla2x00_shutdown, |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5894 | .err_handler = &qla2xxx_err_handler, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 5895 | }; |
| 5896 | |
Al Viro | 75ef9de | 2013-04-04 19:09:41 -0400 | [diff] [blame] | 5897 | static const struct file_operations apidev_fops = { |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 5898 | .owner = THIS_MODULE, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 5899 | .llseek = noop_llseek, |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 5900 | }; |
| 5901 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5902 | /** |
| 5903 | * qla2x00_module_init - Module initialization. |
| 5904 | **/ |
| 5905 | static int __init |
| 5906 | qla2x00_module_init(void) |
| 5907 | { |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 5908 | int ret = 0; |
| 5909 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5910 | /* Allocate cache for SRBs. */ |
Andrew Vasquez | 354d6b2 | 2005-04-23 02:47:27 -0400 | [diff] [blame] | 5911 | srb_cachep = kmem_cache_create("qla2xxx_srbs", sizeof(srb_t), 0, |
Paul Mundt | 20c2df8 | 2007-07-20 10:11:58 +0900 | [diff] [blame] | 5912 | SLAB_HWCACHE_ALIGN, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5913 | if (srb_cachep == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5914 | ql_log(ql_log_fatal, NULL, 0x0001, |
| 5915 | "Unable to allocate SRB cache...Failing load!.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5916 | return -ENOMEM; |
| 5917 | } |
| 5918 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 5919 | /* Initialize target kmem_cache and mem_pools */ |
| 5920 | ret = qlt_init(); |
| 5921 | if (ret < 0) { |
| 5922 | kmem_cache_destroy(srb_cachep); |
| 5923 | return ret; |
| 5924 | } else if (ret > 0) { |
| 5925 | /* |
| 5926 | * If initiator mode is explictly disabled by qlt_init(), |
| 5927 | * prevent scsi_transport_fc.c:fc_scsi_scan_rport() from |
| 5928 | * performing scsi_scan_target() during LOOP UP event. |
| 5929 | */ |
| 5930 | qla2xxx_transport_functions.disable_target_scan = 1; |
| 5931 | qla2xxx_transport_vport_functions.disable_target_scan = 1; |
| 5932 | } |
| 5933 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5934 | /* Derive version string. */ |
| 5935 | strcpy(qla2x00_version_str, QLA2XXX_VERSION); |
Andrew Vasquez | 11010fe | 2006-10-06 09:54:59 -0700 | [diff] [blame] | 5936 | if (ql2xextended_error_logging) |
Andrew Vasquez | 0181944 | 2006-06-23 16:11:10 -0700 | [diff] [blame] | 5937 | strcat(qla2x00_version_str, "-debug"); |
| 5938 | |
Andrew Vasquez | 1c97a12 | 2005-04-21 16:13:36 -0400 | [diff] [blame] | 5939 | qla2xxx_transport_template = |
| 5940 | fc_attach_transport(&qla2xxx_transport_functions); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5941 | if (!qla2xxx_transport_template) { |
| 5942 | kmem_cache_destroy(srb_cachep); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5943 | ql_log(ql_log_fatal, NULL, 0x0002, |
| 5944 | "fc_attach_transport failed...Failing load!.\n"); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 5945 | qlt_exit(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5946 | return -ENODEV; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5947 | } |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 5948 | |
| 5949 | apidev_major = register_chrdev(0, QLA2XXX_APIDEV, &apidev_fops); |
| 5950 | if (apidev_major < 0) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5951 | ql_log(ql_log_fatal, NULL, 0x0003, |
| 5952 | "Unable to register char device %s.\n", QLA2XXX_APIDEV); |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 5953 | } |
| 5954 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5955 | qla2xxx_transport_vport_template = |
| 5956 | fc_attach_transport(&qla2xxx_transport_vport_functions); |
| 5957 | if (!qla2xxx_transport_vport_template) { |
| 5958 | kmem_cache_destroy(srb_cachep); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 5959 | qlt_exit(); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5960 | fc_release_transport(qla2xxx_transport_template); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5961 | ql_log(ql_log_fatal, NULL, 0x0004, |
| 5962 | "fc_attach_transport vport failed...Failing load!.\n"); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5963 | return -ENODEV; |
| 5964 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5965 | ql_log(ql_log_info, NULL, 0x0005, |
| 5966 | "QLogic Fibre Channel HBA Driver: %s.\n", |
Andrew Vasquez | fd9a29f0 | 2008-05-12 22:21:08 -0700 | [diff] [blame] | 5967 | qla2x00_version_str); |
Andrew Vasquez | 7ee6139 | 2006-06-23 16:11:22 -0700 | [diff] [blame] | 5968 | ret = pci_register_driver(&qla2xxx_pci_driver); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 5969 | if (ret) { |
| 5970 | kmem_cache_destroy(srb_cachep); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 5971 | qlt_exit(); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 5972 | fc_release_transport(qla2xxx_transport_template); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5973 | fc_release_transport(qla2xxx_transport_vport_template); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5974 | ql_log(ql_log_fatal, NULL, 0x0006, |
| 5975 | "pci_register_driver failed...ret=%d Failing load!.\n", |
| 5976 | ret); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 5977 | } |
| 5978 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5979 | } |
| 5980 | |
| 5981 | /** |
| 5982 | * qla2x00_module_exit - Module cleanup. |
| 5983 | **/ |
| 5984 | static void __exit |
| 5985 | qla2x00_module_exit(void) |
| 5986 | { |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 5987 | unregister_chrdev(apidev_major, QLA2XXX_APIDEV); |
Andrew Vasquez | 7ee6139 | 2006-06-23 16:11:22 -0700 | [diff] [blame] | 5988 | pci_unregister_driver(&qla2xxx_pci_driver); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5989 | qla2x00_release_firmware(); |
Andrew Vasquez | 354d6b2 | 2005-04-23 02:47:27 -0400 | [diff] [blame] | 5990 | kmem_cache_destroy(srb_cachep); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 5991 | qlt_exit(); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5992 | if (ctx_cachep) |
| 5993 | kmem_cache_destroy(ctx_cachep); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5994 | fc_release_transport(qla2xxx_transport_template); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5995 | fc_release_transport(qla2xxx_transport_vport_template); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5996 | } |
| 5997 | |
| 5998 | module_init(qla2x00_module_init); |
| 5999 | module_exit(qla2x00_module_exit); |
| 6000 | |
| 6001 | MODULE_AUTHOR("QLogic Corporation"); |
| 6002 | MODULE_DESCRIPTION("QLogic Fibre Channel HBA Driver"); |
| 6003 | MODULE_LICENSE("GPL"); |
| 6004 | MODULE_VERSION(QLA2XXX_VERSION); |
Andrew Vasquez | bb8ee49 | 2006-10-02 12:00:48 -0700 | [diff] [blame] | 6005 | MODULE_FIRMWARE(FW_FILE_ISP21XX); |
| 6006 | MODULE_FIRMWARE(FW_FILE_ISP22XX); |
| 6007 | MODULE_FIRMWARE(FW_FILE_ISP2300); |
| 6008 | MODULE_FIRMWARE(FW_FILE_ISP2322); |
| 6009 | MODULE_FIRMWARE(FW_FILE_ISP24XX); |
Andrew Vasquez | 61623fc | 2008-01-31 12:33:45 -0800 | [diff] [blame] | 6010 | MODULE_FIRMWARE(FW_FILE_ISP25XX); |