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 |
Chad Dupuis | 46152ce | 2012-08-22 14:21:08 -0400 | [diff] [blame] | 3 | * Copyright (c) 2003-2012 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 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | int ql2xlogintimeout = 20; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 51 | module_param(ql2xlogintimeout, int, S_IRUGO); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 52 | MODULE_PARM_DESC(ql2xlogintimeout, |
| 53 | "Login timeout value in seconds."); |
| 54 | |
Andrew Vasquez | a7b6184 | 2007-05-07 07:42:59 -0700 | [diff] [blame] | 55 | int qlport_down_retry; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 56 | module_param(qlport_down_retry, int, S_IRUGO); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 57 | MODULE_PARM_DESC(qlport_down_retry, |
Jesper Juhl | 900d9f9 | 2006-06-30 02:33:07 -0700 | [diff] [blame] | 58 | "Maximum number of command retries to a port that returns " |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 59 | "a PORT-DOWN status."); |
| 60 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | int ql2xplogiabsentdevice; |
| 62 | module_param(ql2xplogiabsentdevice, int, S_IRUGO|S_IWUSR); |
| 63 | MODULE_PARM_DESC(ql2xplogiabsentdevice, |
| 64 | "Option to enable PLOGI to devices that are not present after " |
Jesper Juhl | 900d9f9 | 2006-06-30 02:33:07 -0700 | [diff] [blame] | 65 | "a Fabric scan. This is needed for several broken switches. " |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | "Default is 0 - no PLOGI. 1 - perfom PLOGI."); |
| 67 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | int ql2xloginretrycount = 0; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 69 | module_param(ql2xloginretrycount, int, S_IRUGO); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 70 | MODULE_PARM_DESC(ql2xloginretrycount, |
| 71 | "Specify an alternate value for the NVRAM login retry count."); |
| 72 | |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 73 | int ql2xallocfwdump = 1; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 74 | module_param(ql2xallocfwdump, int, S_IRUGO); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 75 | MODULE_PARM_DESC(ql2xallocfwdump, |
| 76 | "Option to enable allocation of memory for a firmware dump " |
| 77 | "during HBA initialization. Memory allocation requirements " |
| 78 | "vary by ISP type. Default is 1 - allocate memory."); |
| 79 | |
Andrew Vasquez | 11010fe | 2006-10-06 09:54:59 -0700 | [diff] [blame] | 80 | int ql2xextended_error_logging; |
Andrew Vasquez | 27d9403 | 2007-03-12 10:41:30 -0700 | [diff] [blame] | 81 | module_param(ql2xextended_error_logging, int, S_IRUGO|S_IWUSR); |
Andrew Vasquez | 11010fe | 2006-10-06 09:54:59 -0700 | [diff] [blame] | 82 | MODULE_PARM_DESC(ql2xextended_error_logging, |
Saurav Kashyap | 3ce8866 | 2011-07-14 12:00:12 -0700 | [diff] [blame] | 83 | "Option to enable extended error logging,\n" |
| 84 | "\t\tDefault is 0 - no logging. 0x40000000 - Module Init & Probe.\n" |
| 85 | "\t\t0x20000000 - Mailbox Cmnds. 0x10000000 - Device Discovery.\n" |
| 86 | "\t\t0x08000000 - IO tracing. 0x04000000 - DPC Thread.\n" |
| 87 | "\t\t0x02000000 - Async events. 0x01000000 - Timer routines.\n" |
| 88 | "\t\t0x00800000 - User space. 0x00400000 - Task Management.\n" |
| 89 | "\t\t0x00200000 - AER/EEH. 0x00100000 - Multi Q.\n" |
| 90 | "\t\t0x00080000 - P3P Specific. 0x00040000 - Virtual Port.\n" |
| 91 | "\t\t0x00020000 - Buffer Dump. 0x00010000 - Misc.\n" |
Chad Dupuis | 29f9f90 | 2012-11-21 02:40:41 -0500 | [diff] [blame] | 92 | "\t\t0x00008000 - Verbose. 0x00004000 - Target.\n" |
| 93 | "\t\t0x00002000 - Target Mgmt. 0x00001000 - Target TMF.\n" |
Saurav Kashyap | 3ce8866 | 2011-07-14 12:00:12 -0700 | [diff] [blame] | 94 | "\t\t0x7fffffff - For enabling all logs, can be too many logs.\n" |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 95 | "\t\t0x1e400000 - Preferred value for capturing essential " |
| 96 | "debug information (equivalent to old " |
| 97 | "ql2xextended_error_logging=1).\n" |
Saurav Kashyap | 3ce8866 | 2011-07-14 12:00:12 -0700 | [diff] [blame] | 98 | "\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] | 99 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 100 | int ql2xshiftctondsd = 6; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 101 | module_param(ql2xshiftctondsd, int, S_IRUGO); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 102 | MODULE_PARM_DESC(ql2xshiftctondsd, |
| 103 | "Set to control shifting of command type processing " |
| 104 | "based on total number of SG elements."); |
| 105 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 106 | static void qla2x00_free_device(scsi_qla_host_t *); |
| 107 | |
Andrew Vasquez | 7e47e5c | 2008-04-24 15:21:26 -0700 | [diff] [blame] | 108 | int ql2xfdmienable=1; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 109 | module_param(ql2xfdmienable, int, S_IRUGO); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 110 | MODULE_PARM_DESC(ql2xfdmienable, |
Ferenc Wagner | 7794a5a | 2010-03-23 18:14:59 +0100 | [diff] [blame] | 111 | "Enables FDMI registrations. " |
| 112 | "0 - no FDMI. Default is 1 - perform FDMI."); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 113 | |
Andrew Vasquez | df7baa5 | 2006-10-13 09:33:39 -0700 | [diff] [blame] | 114 | #define MAX_Q_DEPTH 32 |
| 115 | static int ql2xmaxqdepth = MAX_Q_DEPTH; |
| 116 | module_param(ql2xmaxqdepth, int, S_IRUGO|S_IWUSR); |
| 117 | MODULE_PARM_DESC(ql2xmaxqdepth, |
Chad Dupuis | e92e4a8 | 2012-08-22 14:21:23 -0400 | [diff] [blame] | 118 | "Maximum queue depth to set for each LUN. " |
| 119 | "Default is 32."); |
Andrew Vasquez | df7baa5 | 2006-10-13 09:33:39 -0700 | [diff] [blame] | 120 | |
Arun Easi | 9e522cd | 2012-08-22 14:21:31 -0400 | [diff] [blame] | 121 | int ql2xenabledif = 2; |
| 122 | module_param(ql2xenabledif, int, S_IRUGO); |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 123 | MODULE_PARM_DESC(ql2xenabledif, |
| 124 | " Enable T10-CRC-DIF " |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 125 | " Default is 0 - No DIF Support. 1 - Enable it" |
| 126 | ", 2 - Enable DIF for all types, except Type 0."); |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 127 | |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 128 | int ql2xenablehba_err_chk = 2; |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 129 | module_param(ql2xenablehba_err_chk, int, S_IRUGO|S_IWUSR); |
| 130 | MODULE_PARM_DESC(ql2xenablehba_err_chk, |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 131 | " Enable T10-CRC-DIF Error isolation by HBA:\n" |
| 132 | " Default is 1.\n" |
| 133 | " 0 -- Error isolation disabled\n" |
| 134 | " 1 -- Error isolation enabled only for DIX Type 0\n" |
| 135 | " 2 -- Error isolation enabled for all Types\n"); |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 136 | |
Andrew Vasquez | e5896bd | 2008-07-10 16:55:52 -0700 | [diff] [blame] | 137 | int ql2xiidmaenable=1; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 138 | module_param(ql2xiidmaenable, int, S_IRUGO); |
Andrew Vasquez | e5896bd | 2008-07-10 16:55:52 -0700 | [diff] [blame] | 139 | MODULE_PARM_DESC(ql2xiidmaenable, |
| 140 | "Enables iIDMA settings " |
| 141 | "Default is 1 - perform iIDMA. 0 - no iIDMA."); |
| 142 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 143 | int ql2xmaxqueues = 1; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 144 | module_param(ql2xmaxqueues, int, S_IRUGO); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 145 | MODULE_PARM_DESC(ql2xmaxqueues, |
| 146 | "Enables MQ settings " |
Joe Perches | ae68230 | 2010-08-10 18:01:21 -0700 | [diff] [blame] | 147 | "Default is 1 for single queue. Set it to number " |
| 148 | "of queues in MQ mode."); |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 149 | |
| 150 | int ql2xmultique_tag; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 151 | module_param(ql2xmultique_tag, int, S_IRUGO); |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 152 | MODULE_PARM_DESC(ql2xmultique_tag, |
| 153 | "Enables CPU affinity settings for the driver " |
| 154 | "Default is 0 for no affinity of request and response IO. " |
| 155 | "Set it to 1 to turn on the cpu affinity."); |
Andrew Vasquez | e337d90 | 2009-04-06 22:33:49 -0700 | [diff] [blame] | 156 | |
| 157 | int ql2xfwloadbin; |
Chad Dupuis | 86e45bf | 2011-08-16 11:31:47 -0700 | [diff] [blame] | 158 | module_param(ql2xfwloadbin, int, S_IRUGO|S_IWUSR); |
Andrew Vasquez | e337d90 | 2009-04-06 22:33:49 -0700 | [diff] [blame] | 159 | MODULE_PARM_DESC(ql2xfwloadbin, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 160 | "Option to specify location from which to load ISP firmware:.\n" |
| 161 | " 2 -- load firmware via the request_firmware() (hotplug).\n" |
Andrew Vasquez | e337d90 | 2009-04-06 22:33:49 -0700 | [diff] [blame] | 162 | " interface.\n" |
| 163 | " 1 -- load firmware from flash.\n" |
| 164 | " 0 -- use default semantics.\n"); |
| 165 | |
Andrew Vasquez | ae97c91 | 2010-02-18 10:07:28 -0800 | [diff] [blame] | 166 | int ql2xetsenable; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 167 | module_param(ql2xetsenable, int, S_IRUGO); |
Andrew Vasquez | ae97c91 | 2010-02-18 10:07:28 -0800 | [diff] [blame] | 168 | MODULE_PARM_DESC(ql2xetsenable, |
| 169 | "Enables firmware ETS burst." |
| 170 | "Default is 0 - skip ETS enablement."); |
| 171 | |
Giridhar Malavali | 6907869 | 2010-05-28 15:08:28 -0700 | [diff] [blame] | 172 | int ql2xdbwr = 1; |
Chad Dupuis | 86e45bf | 2011-08-16 11:31:47 -0700 | [diff] [blame] | 173 | module_param(ql2xdbwr, int, S_IRUGO|S_IWUSR); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 174 | MODULE_PARM_DESC(ql2xdbwr, |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 175 | "Option to specify scheme for request queue posting.\n" |
| 176 | " 0 -- Regular doorbell.\n" |
| 177 | " 1 -- CAMRAM doorbell (faster).\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 178 | |
Giridhar Malavali | f4c496c | 2010-05-04 15:01:33 -0700 | [diff] [blame] | 179 | int ql2xtargetreset = 1; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 180 | module_param(ql2xtargetreset, int, S_IRUGO); |
Giridhar Malavali | f4c496c | 2010-05-04 15:01:33 -0700 | [diff] [blame] | 181 | MODULE_PARM_DESC(ql2xtargetreset, |
| 182 | "Enable target reset." |
| 183 | "Default is 1 - use hw defaults."); |
| 184 | |
Chad Dupuis | 4da26e1 | 2010-10-15 11:27:40 -0700 | [diff] [blame] | 185 | int ql2xgffidenable; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 186 | module_param(ql2xgffidenable, int, S_IRUGO); |
Chad Dupuis | 4da26e1 | 2010-10-15 11:27:40 -0700 | [diff] [blame] | 187 | MODULE_PARM_DESC(ql2xgffidenable, |
| 188 | "Enables GFF_ID checks of port type. " |
| 189 | "Default is 0 - Do not use GFF_ID information."); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 190 | |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 191 | int ql2xasynctmfenable; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 192 | module_param(ql2xasynctmfenable, int, S_IRUGO); |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 193 | MODULE_PARM_DESC(ql2xasynctmfenable, |
| 194 | "Enables issue of TM IOCBs asynchronously via IOCB mechanism" |
| 195 | "Default is 0 - Issue TM IOCBs via mailbox mechanism."); |
Giridhar Malavali | ed0de87 | 2011-03-30 11:46:29 -0700 | [diff] [blame] | 196 | |
| 197 | int ql2xdontresethba; |
Chad Dupuis | 86e45bf | 2011-08-16 11:31:47 -0700 | [diff] [blame] | 198 | module_param(ql2xdontresethba, int, S_IRUGO|S_IWUSR); |
Giridhar Malavali | ed0de87 | 2011-03-30 11:46:29 -0700 | [diff] [blame] | 199 | MODULE_PARM_DESC(ql2xdontresethba, |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 200 | "Option to specify reset behaviour.\n" |
| 201 | " 0 (Default) -- Reset on failure.\n" |
| 202 | " 1 -- Do not reset on failure.\n"); |
Giridhar Malavali | ed0de87 | 2011-03-30 11:46:29 -0700 | [diff] [blame] | 203 | |
Andrew Vasquez | 8251592 | 2011-05-10 11:30:13 -0700 | [diff] [blame] | 204 | uint ql2xmaxlun = MAX_LUNS; |
| 205 | module_param(ql2xmaxlun, uint, S_IRUGO); |
| 206 | MODULE_PARM_DESC(ql2xmaxlun, |
| 207 | "Defines the maximum LU number to register with the SCSI " |
| 208 | "midlayer. Default is 65535."); |
| 209 | |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 210 | int ql2xmdcapmask = 0x1F; |
| 211 | module_param(ql2xmdcapmask, int, S_IRUGO); |
| 212 | MODULE_PARM_DESC(ql2xmdcapmask, |
| 213 | "Set the Minidump driver capture mask level. " |
Giridhar Malavali | 6e96fa7 | 2011-11-18 09:03:14 -0800 | [diff] [blame] | 214 | "Default is 0x1F - Can be set to 0x3, 0x7, 0xF, 0x1F, 0x7F."); |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 215 | |
Giridhar Malavali | 3aadff3 | 2011-11-18 09:02:14 -0800 | [diff] [blame] | 216 | int ql2xmdenable = 1; |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 217 | module_param(ql2xmdenable, int, S_IRUGO); |
| 218 | MODULE_PARM_DESC(ql2xmdenable, |
| 219 | "Enable/disable MiniDump. " |
Giridhar Malavali | 3aadff3 | 2011-11-18 09:02:14 -0800 | [diff] [blame] | 220 | "0 - MiniDump disabled. " |
| 221 | "1 (Default) - MiniDump enabled."); |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 222 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 223 | /* |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 224 | * SCSI host template entry points |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 225 | */ |
| 226 | static int qla2xxx_slave_configure(struct scsi_device * device); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 227 | static int qla2xxx_slave_alloc(struct scsi_device *); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 228 | static int qla2xxx_scan_finished(struct Scsi_Host *, unsigned long time); |
| 229 | static void qla2xxx_scan_start(struct Scsi_Host *); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 230 | static void qla2xxx_slave_destroy(struct scsi_device *); |
Jeff Garzik | f281233 | 2010-11-16 02:10:29 -0500 | [diff] [blame] | 231 | static int qla2xxx_queuecommand(struct Scsi_Host *h, struct scsi_cmnd *cmd); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 232 | static int qla2xxx_eh_abort(struct scsi_cmnd *); |
| 233 | static int qla2xxx_eh_device_reset(struct scsi_cmnd *); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 234 | static int qla2xxx_eh_target_reset(struct scsi_cmnd *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 235 | static int qla2xxx_eh_bus_reset(struct scsi_cmnd *); |
| 236 | static int qla2xxx_eh_host_reset(struct scsi_cmnd *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 237 | |
Mike Christie | e881a17 | 2009-10-15 17:46:39 -0700 | [diff] [blame] | 238 | static int qla2x00_change_queue_depth(struct scsi_device *, int, int); |
Andrew Vasquez | ce7e4af | 2005-08-26 19:09:30 -0700 | [diff] [blame] | 239 | static int qla2x00_change_queue_type(struct scsi_device *, int); |
| 240 | |
Giridhar Malavali | a5326f8 | 2009-03-24 09:07:56 -0700 | [diff] [blame] | 241 | struct scsi_host_template qla2xxx_driver_template = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 242 | .module = THIS_MODULE, |
Andrew Vasquez | cb63067 | 2006-05-17 15:09:45 -0700 | [diff] [blame] | 243 | .name = QLA2XXX_DRIVER_NAME, |
Giridhar Malavali | a5326f8 | 2009-03-24 09:07:56 -0700 | [diff] [blame] | 244 | .queuecommand = qla2xxx_queuecommand, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 245 | |
| 246 | .eh_abort_handler = qla2xxx_eh_abort, |
| 247 | .eh_device_reset_handler = qla2xxx_eh_device_reset, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 248 | .eh_target_reset_handler = qla2xxx_eh_target_reset, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 249 | .eh_bus_reset_handler = qla2xxx_eh_bus_reset, |
| 250 | .eh_host_reset_handler = qla2xxx_eh_host_reset, |
| 251 | |
| 252 | .slave_configure = qla2xxx_slave_configure, |
| 253 | |
| 254 | .slave_alloc = qla2xxx_slave_alloc, |
| 255 | .slave_destroy = qla2xxx_slave_destroy, |
Andrew Vasquez | ed67708 | 2007-03-12 10:41:27 -0700 | [diff] [blame] | 256 | .scan_finished = qla2xxx_scan_finished, |
| 257 | .scan_start = qla2xxx_scan_start, |
Andrew Vasquez | ce7e4af | 2005-08-26 19:09:30 -0700 | [diff] [blame] | 258 | .change_queue_depth = qla2x00_change_queue_depth, |
| 259 | .change_queue_type = qla2x00_change_queue_type, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 260 | .this_id = -1, |
| 261 | .cmd_per_lun = 3, |
| 262 | .use_clustering = ENABLE_CLUSTERING, |
| 263 | .sg_tablesize = SG_ALL, |
| 264 | |
| 265 | .max_sectors = 0xFFFF, |
Andrew Vasquez | afb046e | 2005-08-26 19:09:40 -0700 | [diff] [blame] | 266 | .shost_attrs = qla2x00_host_attrs, |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 267 | |
| 268 | .supported_mode = MODE_INITIATOR, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 269 | }; |
| 270 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 271 | static struct scsi_transport_template *qla2xxx_transport_template = NULL; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 272 | struct scsi_transport_template *qla2xxx_transport_vport_template = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 273 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 274 | /* TODO Convert to inlines |
| 275 | * |
| 276 | * Timer routines |
| 277 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 278 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 279 | __inline__ void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 280 | 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] | 281 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 282 | init_timer(&vha->timer); |
| 283 | vha->timer.expires = jiffies + interval * HZ; |
| 284 | vha->timer.data = (unsigned long)vha; |
| 285 | vha->timer.function = (void (*)(unsigned long))func; |
| 286 | add_timer(&vha->timer); |
| 287 | vha->timer_active = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 288 | } |
| 289 | |
| 290 | static inline void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 291 | qla2x00_restart_timer(scsi_qla_host_t *vha, unsigned long interval) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 292 | { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 293 | /* Currently used for 82XX only. */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 294 | if (vha->device_flags & DFLG_DEV_FAILED) { |
| 295 | ql_dbg(ql_dbg_timer, vha, 0x600d, |
| 296 | "Device in a failed state, returning.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 297 | return; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 298 | } |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 299 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 300 | mod_timer(&vha->timer, jiffies + interval * HZ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 301 | } |
| 302 | |
Adrian Bunk | a824ebb | 2008-01-17 09:02:15 -0800 | [diff] [blame] | 303 | static __inline__ void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 304 | qla2x00_stop_timer(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 305 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 306 | del_timer_sync(&vha->timer); |
| 307 | vha->timer_active = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 308 | } |
| 309 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 310 | static int qla2x00_do_dpc(void *data); |
| 311 | |
| 312 | static void qla2x00_rst_aen(scsi_qla_host_t *); |
| 313 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 314 | static int qla2x00_mem_alloc(struct qla_hw_data *, uint16_t, uint16_t, |
| 315 | struct req_que **, struct rsp_que **); |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 316 | static void qla2x00_free_fw_dump(struct qla_hw_data *); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 317 | static void qla2x00_mem_free(struct qla_hw_data *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 318 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 319 | /* -------------------------------------------------------------------------- */ |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 320 | static int qla2x00_alloc_queues(struct qla_hw_data *ha, struct req_que *req, |
| 321 | struct rsp_que *rsp) |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 322 | { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 323 | scsi_qla_host_t *vha = pci_get_drvdata(ha->pdev); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 324 | 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] | 325 | GFP_KERNEL); |
| 326 | if (!ha->req_q_map) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 327 | ql_log(ql_log_fatal, vha, 0x003b, |
| 328 | "Unable to allocate memory for request queue ptrs.\n"); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 329 | goto fail_req_map; |
| 330 | } |
| 331 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 332 | 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] | 333 | GFP_KERNEL); |
| 334 | if (!ha->rsp_q_map) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 335 | ql_log(ql_log_fatal, vha, 0x003c, |
| 336 | "Unable to allocate memory for response queue ptrs.\n"); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 337 | goto fail_rsp_map; |
| 338 | } |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 339 | /* |
| 340 | * Make sure we record at least the request and response queue zero in |
| 341 | * case we need to free them if part of the probe fails. |
| 342 | */ |
| 343 | ha->rsp_q_map[0] = rsp; |
| 344 | ha->req_q_map[0] = req; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 345 | set_bit(0, ha->rsp_qid_map); |
| 346 | set_bit(0, ha->req_qid_map); |
| 347 | return 1; |
| 348 | |
| 349 | fail_rsp_map: |
| 350 | kfree(ha->req_q_map); |
| 351 | ha->req_q_map = NULL; |
| 352 | fail_req_map: |
| 353 | return -ENOMEM; |
| 354 | } |
| 355 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 356 | 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] | 357 | { |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 358 | if (req && req->ring) |
| 359 | dma_free_coherent(&ha->pdev->dev, |
| 360 | (req->length + 1) * sizeof(request_t), |
| 361 | req->ring, req->dma); |
| 362 | |
| 363 | kfree(req); |
| 364 | req = NULL; |
| 365 | } |
| 366 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 367 | static void qla2x00_free_rsp_que(struct qla_hw_data *ha, struct rsp_que *rsp) |
| 368 | { |
| 369 | if (rsp && rsp->ring) |
| 370 | dma_free_coherent(&ha->pdev->dev, |
| 371 | (rsp->length + 1) * sizeof(response_t), |
| 372 | rsp->ring, rsp->dma); |
| 373 | |
| 374 | kfree(rsp); |
| 375 | rsp = NULL; |
| 376 | } |
| 377 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 378 | static void qla2x00_free_queues(struct qla_hw_data *ha) |
| 379 | { |
| 380 | struct req_que *req; |
| 381 | struct rsp_que *rsp; |
| 382 | int cnt; |
| 383 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 384 | for (cnt = 0; cnt < ha->max_req_queues; cnt++) { |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 385 | req = ha->req_q_map[cnt]; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 386 | qla2x00_free_req_que(ha, req); |
| 387 | } |
| 388 | kfree(ha->req_q_map); |
| 389 | ha->req_q_map = NULL; |
| 390 | |
| 391 | for (cnt = 0; cnt < ha->max_rsp_queues; cnt++) { |
| 392 | rsp = ha->rsp_q_map[cnt]; |
| 393 | qla2x00_free_rsp_que(ha, rsp); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 394 | } |
| 395 | kfree(ha->rsp_q_map); |
| 396 | ha->rsp_q_map = NULL; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 397 | } |
| 398 | |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 399 | static int qla25xx_setup_mode(struct scsi_qla_host *vha) |
| 400 | { |
| 401 | uint16_t options = 0; |
| 402 | int ques, req, ret; |
| 403 | struct qla_hw_data *ha = vha->hw; |
| 404 | |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 405 | if (!(ha->fw_attributes & BIT_6)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 406 | ql_log(ql_log_warn, vha, 0x00d8, |
| 407 | "Firmware is not multi-queue capable.\n"); |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 408 | goto fail; |
| 409 | } |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 410 | if (ql2xmultique_tag) { |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 411 | /* create a request queue for IO */ |
| 412 | options |= BIT_7; |
| 413 | req = qla25xx_create_req_que(ha, options, 0, 0, -1, |
| 414 | QLA_DEFAULT_QUE_QOS); |
| 415 | if (!req) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 416 | ql_log(ql_log_warn, vha, 0x00e0, |
| 417 | "Failed to create request queue.\n"); |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 418 | goto fail; |
| 419 | } |
Tejun Heo | 278274d | 2011-02-01 11:42:42 +0100 | [diff] [blame] | 420 | ha->wq = alloc_workqueue("qla2xxx_wq", WQ_MEM_RECLAIM, 1); |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 421 | vha->req = ha->req_q_map[req]; |
| 422 | options |= BIT_1; |
| 423 | for (ques = 1; ques < ha->max_rsp_queues; ques++) { |
| 424 | ret = qla25xx_create_rsp_que(ha, options, 0, 0, req); |
| 425 | if (!ret) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 426 | ql_log(ql_log_warn, vha, 0x00e8, |
| 427 | "Failed to create response queue.\n"); |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 428 | goto fail2; |
| 429 | } |
| 430 | } |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 431 | ha->flags.cpu_affinity_enabled = 1; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 432 | ql_dbg(ql_dbg_multiq, vha, 0xc007, |
| 433 | "CPU affinity mode enalbed, " |
| 434 | "no. of response queues:%d no. of request queues:%d.\n", |
| 435 | ha->max_rsp_queues, ha->max_req_queues); |
| 436 | ql_dbg(ql_dbg_init, vha, 0x00e9, |
| 437 | "CPU affinity mode enalbed, " |
| 438 | "no. of response queues:%d no. of request queues:%d.\n", |
| 439 | ha->max_rsp_queues, ha->max_req_queues); |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 440 | } |
| 441 | return 0; |
| 442 | fail2: |
| 443 | qla25xx_delete_queues(vha); |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 444 | destroy_workqueue(ha->wq); |
| 445 | ha->wq = NULL; |
Giridhar Malavali | 0cd33fc | 2011-11-18 09:02:12 -0800 | [diff] [blame] | 446 | vha->req = ha->req_q_map[0]; |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 447 | fail: |
| 448 | ha->mqenable = 0; |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 449 | kfree(ha->req_q_map); |
| 450 | kfree(ha->rsp_q_map); |
| 451 | ha->max_req_queues = ha->max_rsp_queues = 1; |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 452 | return 1; |
| 453 | } |
| 454 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 455 | static char * |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 456 | qla2x00_pci_info_str(struct scsi_qla_host *vha, char *str) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 457 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 458 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 459 | static char *pci_bus_modes[] = { |
| 460 | "33", "66", "100", "133", |
| 461 | }; |
| 462 | uint16_t pci_bus; |
| 463 | |
| 464 | strcpy(str, "PCI"); |
| 465 | pci_bus = (ha->pci_attr & (BIT_9 | BIT_10)) >> 9; |
| 466 | if (pci_bus) { |
| 467 | strcat(str, "-X ("); |
| 468 | strcat(str, pci_bus_modes[pci_bus]); |
| 469 | } else { |
| 470 | pci_bus = (ha->pci_attr & BIT_8) >> 8; |
| 471 | strcat(str, " ("); |
| 472 | strcat(str, pci_bus_modes[pci_bus]); |
| 473 | } |
| 474 | strcat(str, " MHz)"); |
| 475 | |
| 476 | return (str); |
| 477 | } |
| 478 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 479 | static char * |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 480 | qla24xx_pci_info_str(struct scsi_qla_host *vha, char *str) |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 481 | { |
| 482 | static char *pci_bus_modes[] = { "33", "66", "100", "133", }; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 483 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 484 | uint32_t pci_bus; |
| 485 | int pcie_reg; |
| 486 | |
Jon Mason | e67f132 | 2012-07-10 14:57:56 -0700 | [diff] [blame] | 487 | pcie_reg = pci_pcie_cap(ha->pdev); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 488 | if (pcie_reg) { |
| 489 | char lwstr[6]; |
| 490 | uint16_t pcie_lstat, lspeed, lwidth; |
| 491 | |
Jon Mason | e67f132 | 2012-07-10 14:57:56 -0700 | [diff] [blame] | 492 | pcie_reg += PCI_EXP_LNKCAP; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 493 | pci_read_config_word(ha->pdev, pcie_reg, &pcie_lstat); |
| 494 | lspeed = pcie_lstat & (BIT_0 | BIT_1 | BIT_2 | BIT_3); |
| 495 | lwidth = (pcie_lstat & |
| 496 | (BIT_4 | BIT_5 | BIT_6 | BIT_7 | BIT_8 | BIT_9)) >> 4; |
| 497 | |
| 498 | strcpy(str, "PCIe ("); |
Saurav Kashyap | 49300af | 2012-11-21 02:40:34 -0500 | [diff] [blame] | 499 | switch (lspeed) { |
| 500 | case 1: |
Andrew Vasquez | c87a0d8 | 2008-04-03 13:13:21 -0700 | [diff] [blame] | 501 | strcat(str, "2.5GT/s "); |
Saurav Kashyap | 49300af | 2012-11-21 02:40:34 -0500 | [diff] [blame] | 502 | break; |
| 503 | case 2: |
Andrew Vasquez | c87a0d8 | 2008-04-03 13:13:21 -0700 | [diff] [blame] | 504 | strcat(str, "5.0GT/s "); |
Saurav Kashyap | 49300af | 2012-11-21 02:40:34 -0500 | [diff] [blame] | 505 | break; |
| 506 | case 3: |
| 507 | strcat(str, "8.0GT/s "); |
| 508 | break; |
| 509 | default: |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 510 | strcat(str, "<unknown> "); |
Saurav Kashyap | 49300af | 2012-11-21 02:40:34 -0500 | [diff] [blame] | 511 | break; |
| 512 | } |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 513 | snprintf(lwstr, sizeof(lwstr), "x%d)", lwidth); |
| 514 | strcat(str, lwstr); |
| 515 | |
| 516 | return str; |
| 517 | } |
| 518 | |
| 519 | strcpy(str, "PCI"); |
| 520 | pci_bus = (ha->pci_attr & CSRX_PCIX_BUS_MODE_MASK) >> 8; |
| 521 | if (pci_bus == 0 || pci_bus == 8) { |
| 522 | strcat(str, " ("); |
| 523 | strcat(str, pci_bus_modes[pci_bus >> 3]); |
| 524 | } else { |
| 525 | strcat(str, "-X "); |
| 526 | if (pci_bus & BIT_2) |
| 527 | strcat(str, "Mode 2"); |
| 528 | else |
| 529 | strcat(str, "Mode 1"); |
| 530 | strcat(str, " ("); |
| 531 | strcat(str, pci_bus_modes[pci_bus & ~BIT_2]); |
| 532 | } |
| 533 | strcat(str, " MHz)"); |
| 534 | |
| 535 | return str; |
| 536 | } |
| 537 | |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 538 | static char * |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 539 | qla2x00_fw_version_str(struct scsi_qla_host *vha, char *str) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 540 | { |
| 541 | char un_str[10]; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 542 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 543 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 544 | sprintf(str, "%d.%02d.%02d ", ha->fw_major_version, |
| 545 | ha->fw_minor_version, |
| 546 | ha->fw_subminor_version); |
| 547 | |
| 548 | if (ha->fw_attributes & BIT_9) { |
| 549 | strcat(str, "FLX"); |
| 550 | return (str); |
| 551 | } |
| 552 | |
| 553 | switch (ha->fw_attributes & 0xFF) { |
| 554 | case 0x7: |
| 555 | strcat(str, "EF"); |
| 556 | break; |
| 557 | case 0x17: |
| 558 | strcat(str, "TP"); |
| 559 | break; |
| 560 | case 0x37: |
| 561 | strcat(str, "IP"); |
| 562 | break; |
| 563 | case 0x77: |
| 564 | strcat(str, "VI"); |
| 565 | break; |
| 566 | default: |
| 567 | sprintf(un_str, "(%x)", ha->fw_attributes); |
| 568 | strcat(str, un_str); |
| 569 | break; |
| 570 | } |
| 571 | if (ha->fw_attributes & 0x100) |
| 572 | strcat(str, "X"); |
| 573 | |
| 574 | return (str); |
| 575 | } |
| 576 | |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 577 | static char * |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 578 | qla24xx_fw_version_str(struct scsi_qla_host *vha, char *str) |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 579 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 580 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | f0883ac | 2005-07-08 17:58:43 -0700 | [diff] [blame] | 581 | |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 582 | sprintf(str, "%d.%02d.%02d (%x)", ha->fw_major_version, |
| 583 | ha->fw_minor_version, ha->fw_subminor_version, ha->fw_attributes); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 584 | return str; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 585 | } |
| 586 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 587 | void |
| 588 | qla2x00_sp_free_dma(void *vha, void *ptr) |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 589 | { |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 590 | srb_t *sp = (srb_t *)ptr; |
| 591 | struct scsi_cmnd *cmd = GET_CMD_SP(sp); |
| 592 | struct qla_hw_data *ha = sp->fcport->vha->hw; |
| 593 | void *ctx = GET_CMD_CTX_SP(sp); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 594 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 595 | if (sp->flags & SRB_DMA_VALID) { |
| 596 | scsi_dma_unmap(cmd); |
| 597 | sp->flags &= ~SRB_DMA_VALID; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 598 | } |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 599 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 600 | if (sp->flags & SRB_CRC_PROT_DMA_VALID) { |
| 601 | dma_unmap_sg(&ha->pdev->dev, scsi_prot_sglist(cmd), |
| 602 | scsi_prot_sg_count(cmd), cmd->sc_data_direction); |
| 603 | sp->flags &= ~SRB_CRC_PROT_DMA_VALID; |
| 604 | } |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 605 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 606 | if (sp->flags & SRB_CRC_CTX_DSD_VALID) { |
| 607 | /* List assured to be having elements */ |
| 608 | qla2x00_clean_dsd_pool(ha, sp); |
| 609 | sp->flags &= ~SRB_CRC_CTX_DSD_VALID; |
| 610 | } |
| 611 | |
| 612 | if (sp->flags & SRB_CRC_CTX_DMA_VALID) { |
| 613 | dma_pool_free(ha->dl_dma_pool, ctx, |
| 614 | ((struct crc_context *)ctx)->crc_ctx_dma); |
| 615 | sp->flags &= ~SRB_CRC_CTX_DMA_VALID; |
| 616 | } |
| 617 | |
| 618 | if (sp->flags & SRB_FCP_CMND_DMA_VALID) { |
| 619 | struct ct6_dsd *ctx1 = (struct ct6_dsd *)ctx; |
| 620 | |
| 621 | dma_pool_free(ha->fcp_cmnd_dma_pool, ctx1->fcp_cmnd, |
| 622 | ctx1->fcp_cmnd_dma); |
| 623 | list_splice(&ctx1->dsd_list, &ha->gbl_dsd_list); |
| 624 | ha->gbl_dsd_inuse -= ctx1->dsd_use_cnt; |
| 625 | ha->gbl_dsd_avail += ctx1->dsd_use_cnt; |
| 626 | mempool_free(ctx1, ha->ctx_mempool); |
| 627 | ctx1 = NULL; |
| 628 | } |
| 629 | |
| 630 | CMD_SP(cmd) = NULL; |
| 631 | mempool_free(sp, ha->srb_mempool); |
| 632 | } |
| 633 | |
| 634 | static void |
| 635 | qla2x00_sp_compl(void *data, void *ptr, int res) |
| 636 | { |
| 637 | struct qla_hw_data *ha = (struct qla_hw_data *)data; |
| 638 | srb_t *sp = (srb_t *)ptr; |
| 639 | struct scsi_cmnd *cmd = GET_CMD_SP(sp); |
| 640 | |
| 641 | cmd->result = res; |
| 642 | |
| 643 | if (atomic_read(&sp->ref_count) == 0) { |
| 644 | ql_dbg(ql_dbg_io, sp->fcport->vha, 0x3015, |
| 645 | "SP reference-count to ZERO -- sp=%p cmd=%p.\n", |
| 646 | sp, GET_CMD_SP(sp)); |
| 647 | if (ql2xextended_error_logging & ql_dbg_io) |
| 648 | BUG(); |
| 649 | return; |
| 650 | } |
| 651 | if (!atomic_dec_and_test(&sp->ref_count)) |
| 652 | return; |
| 653 | |
| 654 | qla2x00_sp_free_dma(ha, sp); |
| 655 | cmd->scsi_done(cmd); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 656 | } |
| 657 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 658 | static int |
Madhuranath Iyengar | f5e3e40 | 2011-02-23 15:27:06 -0800 | [diff] [blame] | 659 | qla2xxx_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 660 | { |
Madhuranath Iyengar | 134ae07 | 2011-05-10 11:30:08 -0700 | [diff] [blame] | 661 | scsi_qla_host_t *vha = shost_priv(host); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 662 | fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 663 | struct fc_rport *rport = starget_to_rport(scsi_target(cmd->device)); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 664 | struct qla_hw_data *ha = vha->hw; |
| 665 | struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 666 | srb_t *sp; |
| 667 | int rval; |
| 668 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 669 | if (ha->flags.eeh_busy) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 670 | if (ha->flags.pci_channel_io_perm_failure) { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 671 | ql_dbg(ql_dbg_aer, vha, 0x9010, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 672 | "PCI Channel IO permanent failure, exiting " |
| 673 | "cmd=%p.\n", cmd); |
Seokmann Ju | b9b12f7 | 2009-03-24 09:08:18 -0700 | [diff] [blame] | 674 | cmd->result = DID_NO_CONNECT << 16; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 675 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 676 | ql_dbg(ql_dbg_aer, vha, 0x9011, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 677 | "EEH_Busy, Requeuing the cmd=%p.\n", cmd); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 678 | cmd->result = DID_REQUEUE << 16; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 679 | } |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 680 | goto qc24_fail_command; |
| 681 | } |
| 682 | |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 683 | rval = fc_remote_port_chkready(rport); |
| 684 | if (rval) { |
| 685 | cmd->result = rval; |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 686 | ql_dbg(ql_dbg_io + ql_dbg_verbose, vha, 0x3003, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 687 | "fc_remote_port_chkready failed for cmd=%p, rval=0x%x.\n", |
| 688 | cmd, rval); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 689 | goto qc24_fail_command; |
| 690 | } |
| 691 | |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 692 | if (!vha->flags.difdix_supported && |
| 693 | scsi_get_prot_op(cmd) != SCSI_PROT_NORMAL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 694 | ql_dbg(ql_dbg_io, vha, 0x3004, |
| 695 | "DIF Cap not reg, fail DIF capable cmd's:%p.\n", |
| 696 | cmd); |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 697 | cmd->result = DID_NO_CONNECT << 16; |
| 698 | goto qc24_fail_command; |
| 699 | } |
Chad Dupuis | aa651be | 2012-02-09 11:14:04 -0800 | [diff] [blame] | 700 | |
| 701 | if (!fcport) { |
| 702 | cmd->result = DID_NO_CONNECT << 16; |
| 703 | goto qc24_fail_command; |
| 704 | } |
| 705 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 706 | if (atomic_read(&fcport->state) != FCS_ONLINE) { |
| 707 | if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD || |
Giridhar Malavali | 38170fa | 2010-10-15 11:27:49 -0700 | [diff] [blame] | 708 | atomic_read(&base_vha->loop_state) == LOOP_DEAD) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 709 | ql_dbg(ql_dbg_io, vha, 0x3005, |
| 710 | "Returning DNC, fcport_state=%d loop_state=%d.\n", |
| 711 | atomic_read(&fcport->state), |
| 712 | atomic_read(&base_vha->loop_state)); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 713 | cmd->result = DID_NO_CONNECT << 16; |
| 714 | goto qc24_fail_command; |
| 715 | } |
Mike Christie | 7b59413 | 2008-08-17 15:24:40 -0500 | [diff] [blame] | 716 | goto qc24_target_busy; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 717 | } |
| 718 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 719 | sp = qla2x00_get_sp(base_vha, fcport, GFP_ATOMIC); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 720 | if (!sp) |
Madhuranath Iyengar | f5e3e40 | 2011-02-23 15:27:06 -0800 | [diff] [blame] | 721 | goto qc24_host_busy; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 722 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 723 | sp->u.scmd.cmd = cmd; |
| 724 | sp->type = SRB_SCSI_CMD; |
| 725 | atomic_set(&sp->ref_count, 1); |
| 726 | CMD_SP(cmd) = (void *)sp; |
| 727 | sp->free = qla2x00_sp_free_dma; |
| 728 | sp->done = qla2x00_sp_compl; |
| 729 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 730 | rval = ha->isp_ops->start_scsi(sp); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 731 | if (rval != QLA_SUCCESS) { |
Chad Dupuis | 53016ed | 2012-11-21 02:40:32 -0500 | [diff] [blame] | 732 | ql_dbg(ql_dbg_io + ql_dbg_verbose, vha, 0x3013, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 733 | "Start scsi failed rval=%d for cmd=%p.\n", rval, cmd); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 734 | goto qc24_host_busy_free_sp; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 735 | } |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 736 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 737 | return 0; |
| 738 | |
| 739 | qc24_host_busy_free_sp: |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 740 | qla2x00_sp_free_dma(ha, sp); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 741 | |
Madhuranath Iyengar | f5e3e40 | 2011-02-23 15:27:06 -0800 | [diff] [blame] | 742 | qc24_host_busy: |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 743 | return SCSI_MLQUEUE_HOST_BUSY; |
| 744 | |
Mike Christie | 7b59413 | 2008-08-17 15:24:40 -0500 | [diff] [blame] | 745 | qc24_target_busy: |
| 746 | return SCSI_MLQUEUE_TARGET_BUSY; |
| 747 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 748 | qc24_fail_command: |
Madhuranath Iyengar | f5e3e40 | 2011-02-23 15:27:06 -0800 | [diff] [blame] | 749 | cmd->scsi_done(cmd); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 750 | |
| 751 | return 0; |
| 752 | } |
| 753 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 754 | /* |
| 755 | * qla2x00_eh_wait_on_command |
| 756 | * Waits for the command to be returned by the Firmware for some |
| 757 | * max time. |
| 758 | * |
| 759 | * Input: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 760 | * cmd = Scsi Command to wait on. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 761 | * |
| 762 | * Return: |
| 763 | * Not Found : 0 |
| 764 | * Found : 1 |
| 765 | */ |
| 766 | static int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 767 | qla2x00_eh_wait_on_command(struct scsi_cmnd *cmd) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 768 | { |
Andrew Vasquez | fe74c71 | 2005-08-26 19:10:10 -0700 | [diff] [blame] | 769 | #define ABORT_POLLING_PERIOD 1000 |
| 770 | #define ABORT_WAIT_ITER ((10 * 1000) / (ABORT_POLLING_PERIOD)) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 771 | unsigned long wait_iter = ABORT_WAIT_ITER; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 772 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| 773 | struct qla_hw_data *ha = vha->hw; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 774 | int ret = QLA_SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 775 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 776 | if (unlikely(pci_channel_offline(ha->pdev)) || ha->flags.eeh_busy) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 777 | ql_dbg(ql_dbg_taskm, vha, 0x8005, |
| 778 | "Return:eh_wait.\n"); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 779 | return ret; |
| 780 | } |
| 781 | |
Lalit Chandivade | d970432 | 2009-08-25 11:36:18 -0700 | [diff] [blame] | 782 | while (CMD_SP(cmd) && wait_iter--) { |
Andrew Vasquez | fe74c71 | 2005-08-26 19:10:10 -0700 | [diff] [blame] | 783 | msleep(ABORT_POLLING_PERIOD); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 784 | } |
| 785 | if (CMD_SP(cmd)) |
| 786 | ret = QLA_FUNCTION_FAILED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 787 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 788 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 789 | } |
| 790 | |
| 791 | /* |
| 792 | * qla2x00_wait_for_hba_online |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 793 | * Wait till the HBA is online after going through |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 794 | * <= MAX_RETRIES_OF_ISP_ABORT or |
| 795 | * finally HBA is disabled ie marked offline |
| 796 | * |
| 797 | * Input: |
| 798 | * ha - pointer to host adapter structure |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 799 | * |
| 800 | * Note: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 801 | * Does context switching-Release SPIN_LOCK |
| 802 | * (if any) before calling this routine. |
| 803 | * |
| 804 | * Return: |
| 805 | * Success (Adapter is online) : 0 |
| 806 | * Failed (Adapter is offline/disabled) : 1 |
| 807 | */ |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 808 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 809 | qla2x00_wait_for_hba_online(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 810 | { |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 811 | int return_status; |
| 812 | unsigned long wait_online; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 813 | struct qla_hw_data *ha = vha->hw; |
| 814 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 815 | |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 816 | wait_online = jiffies + (MAX_LOOP_TIMEOUT * HZ); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 817 | while (((test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags)) || |
| 818 | test_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags) || |
| 819 | test_bit(ISP_ABORT_RETRY, &base_vha->dpc_flags) || |
| 820 | ha->dpc_active) && time_before(jiffies, wait_online)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 821 | |
| 822 | msleep(1000); |
| 823 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 824 | if (base_vha->flags.online) |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 825 | return_status = QLA_SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 826 | else |
| 827 | return_status = QLA_FUNCTION_FAILED; |
| 828 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 829 | return (return_status); |
| 830 | } |
| 831 | |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 832 | /* |
| 833 | * qla2x00_wait_for_reset_ready |
| 834 | * Wait till the HBA is online after going through |
| 835 | * <= MAX_RETRIES_OF_ISP_ABORT or |
| 836 | * finally HBA is disabled ie marked offline or flash |
| 837 | * operations are in progress. |
| 838 | * |
| 839 | * Input: |
| 840 | * ha - pointer to host adapter structure |
| 841 | * |
| 842 | * Note: |
| 843 | * Does context switching-Release SPIN_LOCK |
| 844 | * (if any) before calling this routine. |
| 845 | * |
| 846 | * Return: |
| 847 | * Success (Adapter is online/no flash ops) : 0 |
| 848 | * Failed (Adapter is offline/disabled/flash ops in progress) : 1 |
| 849 | */ |
Andrew Vasquez | 3dbe756 | 2010-07-23 15:28:37 +0500 | [diff] [blame] | 850 | static int |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 851 | qla2x00_wait_for_reset_ready(scsi_qla_host_t *vha) |
| 852 | { |
| 853 | int return_status; |
| 854 | unsigned long wait_online; |
| 855 | struct qla_hw_data *ha = vha->hw; |
| 856 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 857 | |
| 858 | wait_online = jiffies + (MAX_LOOP_TIMEOUT * HZ); |
| 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->optrom_state != QLA_SWAITING || |
| 863 | ha->dpc_active) && time_before(jiffies, wait_online)) |
| 864 | msleep(1000); |
| 865 | |
| 866 | if (base_vha->flags.online && ha->optrom_state == QLA_SWAITING) |
| 867 | return_status = QLA_SUCCESS; |
| 868 | else |
| 869 | return_status = QLA_FUNCTION_FAILED; |
| 870 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 871 | ql_dbg(ql_dbg_taskm, vha, 0x8019, |
| 872 | "%s return status=%d.\n", __func__, return_status); |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 873 | |
| 874 | return return_status; |
| 875 | } |
| 876 | |
Lalit Chandivade | 2533cf6 | 2009-03-24 09:08:07 -0700 | [diff] [blame] | 877 | int |
| 878 | qla2x00_wait_for_chip_reset(scsi_qla_host_t *vha) |
| 879 | { |
| 880 | int return_status; |
| 881 | unsigned long wait_reset; |
| 882 | struct qla_hw_data *ha = vha->hw; |
| 883 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 884 | |
| 885 | wait_reset = jiffies + (MAX_LOOP_TIMEOUT * HZ); |
| 886 | while (((test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags)) || |
| 887 | test_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags) || |
| 888 | test_bit(ISP_ABORT_RETRY, &base_vha->dpc_flags) || |
| 889 | ha->dpc_active) && time_before(jiffies, wait_reset)) { |
| 890 | |
| 891 | msleep(1000); |
| 892 | |
| 893 | if (!test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags) && |
| 894 | ha->flags.chip_reset_done) |
| 895 | break; |
| 896 | } |
| 897 | if (ha->flags.chip_reset_done) |
| 898 | return_status = QLA_SUCCESS; |
| 899 | else |
| 900 | return_status = QLA_FUNCTION_FAILED; |
| 901 | |
| 902 | return return_status; |
| 903 | } |
| 904 | |
Giridhar Malavali | 083a469 | 2010-05-28 15:08:18 -0700 | [diff] [blame] | 905 | static void |
| 906 | sp_get(struct srb *sp) |
| 907 | { |
| 908 | atomic_inc(&sp->ref_count); |
| 909 | } |
| 910 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 911 | /************************************************************************** |
| 912 | * qla2xxx_eh_abort |
| 913 | * |
| 914 | * Description: |
| 915 | * The abort function will abort the specified command. |
| 916 | * |
| 917 | * Input: |
| 918 | * cmd = Linux SCSI command packet to be aborted. |
| 919 | * |
| 920 | * Returns: |
| 921 | * Either SUCCESS or FAILED. |
| 922 | * |
| 923 | * Note: |
Michael Reed | 2ea0020 | 2006-04-27 16:25:30 -0700 | [diff] [blame] | 924 | * Only return FAILED if command not returned by firmware. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 925 | **************************************************************************/ |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 926 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 927 | qla2xxx_eh_abort(struct scsi_cmnd *cmd) |
| 928 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 929 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 930 | srb_t *sp; |
Andrew Vasquez | 4e98d3b | 2011-02-23 15:27:17 -0800 | [diff] [blame] | 931 | int ret; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 932 | unsigned int id, lun; |
Andrew Vasquez | 18e144d | 2005-05-27 15:04:47 -0700 | [diff] [blame] | 933 | unsigned long flags; |
Michael Reed | 2ea0020 | 2006-04-27 16:25:30 -0700 | [diff] [blame] | 934 | int wait = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 935 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 936 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 937 | if (!CMD_SP(cmd)) |
Michael Reed | 2ea0020 | 2006-04-27 16:25:30 -0700 | [diff] [blame] | 938 | return SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 939 | |
Andrew Vasquez | 4e98d3b | 2011-02-23 15:27:17 -0800 | [diff] [blame] | 940 | ret = fc_block_scsi_eh(cmd); |
| 941 | if (ret != 0) |
| 942 | return ret; |
| 943 | ret = SUCCESS; |
| 944 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 945 | id = cmd->device->id; |
| 946 | lun = cmd->device->lun; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 947 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 948 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 949 | sp = (srb_t *) CMD_SP(cmd); |
| 950 | if (!sp) { |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 951 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 952 | return SUCCESS; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 953 | } |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 954 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 955 | ql_dbg(ql_dbg_taskm, vha, 0x8002, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 956 | "Aborting from RISC nexus=%ld:%d:%d sp=%p cmd=%p\n", |
| 957 | vha->host_no, id, lun, sp, cmd); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 958 | |
| 959 | /* Get a reference to the sp and drop the lock.*/ |
| 960 | sp_get(sp); |
| 961 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 962 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 963 | if (ha->isp_ops->abort_command(sp)) { |
Arun Easi | a55aac7 | 2012-02-09 11:14:03 -0800 | [diff] [blame] | 964 | ret = FAILED; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 965 | ql_dbg(ql_dbg_taskm, vha, 0x8003, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 966 | "Abort command mbx failed cmd=%p.\n", cmd); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 967 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 968 | ql_dbg(ql_dbg_taskm, vha, 0x8004, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 969 | "Abort command mbx success cmd=%p.\n", cmd); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 970 | wait = 1; |
| 971 | } |
Saurav Kashyap | 7594206 | 2011-08-16 11:29:25 -0700 | [diff] [blame] | 972 | |
| 973 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 974 | sp->done(ha, sp, 0); |
Saurav Kashyap | 7594206 | 2011-08-16 11:29:25 -0700 | [diff] [blame] | 975 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 976 | |
Chad Dupuis | bc91ade | 2011-08-16 11:29:26 -0700 | [diff] [blame] | 977 | /* Did the command return during mailbox execution? */ |
| 978 | if (ret == FAILED && !CMD_SP(cmd)) |
| 979 | ret = SUCCESS; |
| 980 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 981 | /* Wait for the command to be returned. */ |
Michael Reed | 2ea0020 | 2006-04-27 16:25:30 -0700 | [diff] [blame] | 982 | if (wait) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 983 | if (qla2x00_eh_wait_on_command(cmd) != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 984 | ql_log(ql_log_warn, vha, 0x8006, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 985 | "Abort handler timed out cmd=%p.\n", cmd); |
Michael Reed | 2ea0020 | 2006-04-27 16:25:30 -0700 | [diff] [blame] | 986 | ret = FAILED; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 987 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 988 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 989 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 990 | ql_log(ql_log_info, vha, 0x801c, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 991 | "Abort command issued nexus=%ld:%d:%d -- %d %x.\n", |
| 992 | vha->host_no, id, lun, wait, ret); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 993 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 994 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 995 | } |
| 996 | |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 997 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 998 | qla2x00_eh_wait_for_pending_commands(scsi_qla_host_t *vha, unsigned int t, |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 999 | unsigned int l, enum nexus_wait_type type) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1000 | { |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1001 | int cnt, match, status; |
Andrew Vasquez | 18e144d | 2005-05-27 15:04:47 -0700 | [diff] [blame] | 1002 | unsigned long flags; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1003 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1004 | struct req_que *req; |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1005 | srb_t *sp; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1006 | struct scsi_cmnd *cmd; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1007 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1008 | status = QLA_SUCCESS; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1009 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1010 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 67c2e93 | 2009-04-06 22:33:42 -0700 | [diff] [blame] | 1011 | req = vha->req; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1012 | for (cnt = 1; status == QLA_SUCCESS && |
| 1013 | cnt < MAX_OUTSTANDING_COMMANDS; cnt++) { |
| 1014 | sp = req->outstanding_cmds[cnt]; |
| 1015 | if (!sp) |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1016 | continue; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1017 | if (sp->type != SRB_SCSI_CMD) |
Andrew Vasquez | cf53b06 | 2009-08-20 11:06:04 -0700 | [diff] [blame] | 1018 | continue; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1019 | if (vha->vp_idx != sp->fcport->vha->vp_idx) |
| 1020 | continue; |
| 1021 | match = 0; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1022 | cmd = GET_CMD_SP(sp); |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1023 | switch (type) { |
| 1024 | case WAIT_HOST: |
| 1025 | match = 1; |
| 1026 | break; |
| 1027 | case WAIT_TARGET: |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1028 | match = cmd->device->id == t; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1029 | break; |
| 1030 | case WAIT_LUN: |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1031 | match = (cmd->device->id == t && |
| 1032 | cmd->device->lun == l); |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1033 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1034 | } |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1035 | if (!match) |
| 1036 | continue; |
| 1037 | |
| 1038 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1039 | status = qla2x00_eh_wait_on_command(cmd); |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1040 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1041 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1042 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1043 | |
| 1044 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1045 | } |
| 1046 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1047 | static char *reset_errors[] = { |
| 1048 | "HBA not online", |
| 1049 | "HBA not ready", |
| 1050 | "Task management failed", |
| 1051 | "Waiting for command completions", |
| 1052 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1053 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1054 | static int |
| 1055 | __qla2xxx_eh_generic_reset(char *name, enum nexus_wait_type type, |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1056 | struct scsi_cmnd *cmd, int (*do_reset)(struct fc_port *, unsigned int, int)) |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1057 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1058 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1059 | fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; |
| 1060 | int err; |
| 1061 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1062 | if (!fcport) { |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1063 | return FAILED; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1064 | } |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1065 | |
Andrew Vasquez | 4e98d3b | 2011-02-23 15:27:17 -0800 | [diff] [blame] | 1066 | err = fc_block_scsi_eh(cmd); |
| 1067 | if (err != 0) |
| 1068 | return err; |
| 1069 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1070 | ql_log(ql_log_info, vha, 0x8009, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1071 | "%s RESET ISSUED nexus=%ld:%d:%d cmd=%p.\n", name, vha->host_no, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1072 | cmd->device->id, cmd->device->lun, cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1073 | |
| 1074 | err = 0; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1075 | if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) { |
| 1076 | ql_log(ql_log_warn, vha, 0x800a, |
| 1077 | "Wait for hba online failed for cmd=%p.\n", cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1078 | goto eh_reset_failed; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1079 | } |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1080 | err = 2; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1081 | if (do_reset(fcport, cmd->device->lun, cmd->request->cpu + 1) |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1082 | != QLA_SUCCESS) { |
| 1083 | ql_log(ql_log_warn, vha, 0x800c, |
| 1084 | "do_reset failed for cmd=%p.\n", cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1085 | goto eh_reset_failed; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1086 | } |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1087 | err = 3; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1088 | if (qla2x00_eh_wait_for_pending_commands(vha, cmd->device->id, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1089 | cmd->device->lun, type) != QLA_SUCCESS) { |
| 1090 | ql_log(ql_log_warn, vha, 0x800d, |
Masanari Iida | d6a0358 | 2012-08-22 14:20:58 -0400 | [diff] [blame] | 1091 | "wait for pending cmds failed for cmd=%p.\n", cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1092 | goto eh_reset_failed; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1093 | } |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1094 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1095 | ql_log(ql_log_info, vha, 0x800e, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1096 | "%s RESET SUCCEEDED nexus:%ld:%d:%d cmd=%p.\n", name, |
| 1097 | vha->host_no, cmd->device->id, cmd->device->lun, cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1098 | |
| 1099 | return SUCCESS; |
| 1100 | |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1101 | eh_reset_failed: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1102 | ql_log(ql_log_info, vha, 0x800f, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1103 | "%s RESET FAILED: %s nexus=%ld:%d:%d cmd=%p.\n", name, |
| 1104 | reset_errors[err], vha->host_no, cmd->device->id, cmd->device->lun, |
| 1105 | cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1106 | return FAILED; |
| 1107 | } |
| 1108 | |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 1109 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1110 | qla2xxx_eh_device_reset(struct scsi_cmnd *cmd) |
| 1111 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1112 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| 1113 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1114 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1115 | return __qla2xxx_eh_generic_reset("DEVICE", WAIT_LUN, cmd, |
| 1116 | ha->isp_ops->lun_reset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1117 | } |
| 1118 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1119 | static int |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1120 | qla2xxx_eh_target_reset(struct scsi_cmnd *cmd) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1121 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1122 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| 1123 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1124 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1125 | return __qla2xxx_eh_generic_reset("TARGET", WAIT_TARGET, cmd, |
| 1126 | ha->isp_ops->target_reset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1127 | } |
| 1128 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1129 | /************************************************************************** |
| 1130 | * qla2xxx_eh_bus_reset |
| 1131 | * |
| 1132 | * Description: |
| 1133 | * The bus reset function will reset the bus and abort any executing |
| 1134 | * commands. |
| 1135 | * |
| 1136 | * Input: |
| 1137 | * cmd = Linux SCSI command packet of the command that cause the |
| 1138 | * bus reset. |
| 1139 | * |
| 1140 | * Returns: |
| 1141 | * SUCCESS/FAILURE (defined as macro in scsi.h). |
| 1142 | * |
| 1143 | **************************************************************************/ |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 1144 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1145 | qla2xxx_eh_bus_reset(struct scsi_cmnd *cmd) |
| 1146 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1147 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 1148 | fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1149 | int ret = FAILED; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1150 | unsigned int id, lun; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1151 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1152 | id = cmd->device->id; |
| 1153 | lun = cmd->device->lun; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1154 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1155 | if (!fcport) { |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1156 | return ret; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1157 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1158 | |
Andrew Vasquez | 4e98d3b | 2011-02-23 15:27:17 -0800 | [diff] [blame] | 1159 | ret = fc_block_scsi_eh(cmd); |
| 1160 | if (ret != 0) |
| 1161 | return ret; |
| 1162 | ret = FAILED; |
| 1163 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1164 | ql_log(ql_log_info, vha, 0x8012, |
Andrew Vasquez | 46270af | 2012-05-15 14:34:17 -0400 | [diff] [blame] | 1165 | "BUS RESET ISSUED nexus=%ld:%d:%d.\n", vha->host_no, id, lun); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1166 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1167 | if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1168 | ql_log(ql_log_fatal, vha, 0x8013, |
| 1169 | "Wait for hba online failed board disabled.\n"); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1170 | goto eh_bus_reset_done; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1171 | } |
| 1172 | |
Saurav Kashyap | ad53768 | 2011-11-18 09:02:09 -0800 | [diff] [blame] | 1173 | if (qla2x00_loop_reset(vha) == QLA_SUCCESS) |
| 1174 | ret = SUCCESS; |
| 1175 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1176 | if (ret == FAILED) |
| 1177 | goto eh_bus_reset_done; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1178 | |
Andrew Vasquez | 9a41a62 | 2005-09-20 13:25:53 -0700 | [diff] [blame] | 1179 | /* Flush outstanding commands. */ |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1180 | if (qla2x00_eh_wait_for_pending_commands(vha, 0, 0, WAIT_HOST) != |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1181 | QLA_SUCCESS) { |
| 1182 | ql_log(ql_log_warn, vha, 0x8014, |
| 1183 | "Wait for pending commands failed.\n"); |
Andrew Vasquez | 9a41a62 | 2005-09-20 13:25:53 -0700 | [diff] [blame] | 1184 | ret = FAILED; |
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 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1187 | eh_bus_reset_done: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1188 | ql_log(ql_log_warn, vha, 0x802b, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1189 | "BUS RESET %s nexus=%ld:%d:%d.\n", |
Masanari Iida | d6a0358 | 2012-08-22 14:20:58 -0400 | [diff] [blame] | 1190 | (ret == FAILED) ? "FAILED" : "SUCCEEDED", vha->host_no, id, lun); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1191 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1192 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1193 | } |
| 1194 | |
| 1195 | /************************************************************************** |
| 1196 | * qla2xxx_eh_host_reset |
| 1197 | * |
| 1198 | * Description: |
| 1199 | * The reset function will reset the Adapter. |
| 1200 | * |
| 1201 | * Input: |
| 1202 | * cmd = Linux SCSI command packet of the command that cause the |
| 1203 | * adapter reset. |
| 1204 | * |
| 1205 | * Returns: |
| 1206 | * Either SUCCESS or FAILED. |
| 1207 | * |
| 1208 | * Note: |
| 1209 | **************************************************************************/ |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 1210 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1211 | qla2xxx_eh_host_reset(struct scsi_cmnd *cmd) |
| 1212 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1213 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1214 | struct qla_hw_data *ha = vha->hw; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1215 | int ret = FAILED; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1216 | unsigned int id, lun; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1217 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1218 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1219 | id = cmd->device->id; |
| 1220 | lun = cmd->device->lun; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1221 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1222 | ql_log(ql_log_info, vha, 0x8018, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1223 | "ADAPTER RESET ISSUED nexus=%ld:%d:%d.\n", vha->host_no, id, lun); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1224 | |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 1225 | if (qla2x00_wait_for_reset_ready(vha) != QLA_SUCCESS) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1226 | goto eh_host_reset_lock; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1227 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1228 | if (vha != base_vha) { |
| 1229 | if (qla2x00_vp_abort_isp(vha)) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1230 | goto eh_host_reset_lock; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1231 | } else { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1232 | if (IS_QLA82XX(vha->hw)) { |
| 1233 | if (!qla82xx_fcoe_ctx_reset(vha)) { |
| 1234 | /* Ctx reset success */ |
| 1235 | ret = SUCCESS; |
| 1236 | goto eh_host_reset_lock; |
| 1237 | } |
| 1238 | /* fall thru if ctx reset failed */ |
| 1239 | } |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 1240 | if (ha->wq) |
| 1241 | flush_workqueue(ha->wq); |
| 1242 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1243 | set_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1244 | if (ha->isp_ops->abort_isp(base_vha)) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1245 | clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
| 1246 | /* failed. schedule dpc to try */ |
| 1247 | set_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags); |
| 1248 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1249 | if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) { |
| 1250 | ql_log(ql_log_warn, vha, 0x802a, |
| 1251 | "wait for hba online failed.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1252 | goto eh_host_reset_lock; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1253 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1254 | } |
| 1255 | clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1256 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1257 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1258 | /* Waiting for command to be returned to OS.*/ |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1259 | if (qla2x00_eh_wait_for_pending_commands(vha, 0, 0, WAIT_HOST) == |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1260 | QLA_SUCCESS) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1261 | ret = SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1262 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1263 | eh_host_reset_lock: |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1264 | ql_log(ql_log_info, vha, 0x8017, |
| 1265 | "ADAPTER RESET %s nexus=%ld:%d:%d.\n", |
| 1266 | (ret == FAILED) ? "FAILED" : "SUCCEEDED", vha->host_no, id, lun); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1267 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1268 | return ret; |
| 1269 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1270 | |
| 1271 | /* |
| 1272 | * qla2x00_loop_reset |
| 1273 | * Issue loop reset. |
| 1274 | * |
| 1275 | * Input: |
| 1276 | * ha = adapter block pointer. |
| 1277 | * |
| 1278 | * Returns: |
| 1279 | * 0 = success |
| 1280 | */ |
Andrew Vasquez | a4722cf | 2008-01-17 09:02:12 -0800 | [diff] [blame] | 1281 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1282 | qla2x00_loop_reset(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1283 | { |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 1284 | int ret; |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 1285 | struct fc_port *fcport; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1286 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1287 | |
Giridhar Malavali | f4c496c | 2010-05-04 15:01:33 -0700 | [diff] [blame] | 1288 | if (ql2xtargetreset == 1 && ha->flags.enable_target_reset) { |
Andrew Vasquez | 55e5ed2 | 2010-02-18 10:07:25 -0800 | [diff] [blame] | 1289 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
| 1290 | if (fcport->port_type != FCT_TARGET) |
| 1291 | continue; |
| 1292 | |
| 1293 | ret = ha->isp_ops->target_reset(fcport, 0, 0); |
| 1294 | if (ret != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1295 | ql_dbg(ql_dbg_taskm, vha, 0x802c, |
| 1296 | "Bus Reset failed: Target Reset=%d " |
| 1297 | "d_id=%x.\n", ret, fcport->d_id.b24); |
Andrew Vasquez | 55e5ed2 | 2010-02-18 10:07:25 -0800 | [diff] [blame] | 1298 | } |
| 1299 | } |
| 1300 | } |
| 1301 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1302 | if (ha->flags.enable_lip_full_login && !IS_CNA_CAPABLE(ha)) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1303 | ret = qla2x00_full_login_lip(vha); |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 1304 | if (ret != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1305 | ql_dbg(ql_dbg_taskm, vha, 0x802d, |
| 1306 | "full_login_lip=%d.\n", ret); |
Anirban Chakraborty | 749af3d | 2008-11-14 13:48:12 -0800 | [diff] [blame] | 1307 | } |
| 1308 | atomic_set(&vha->loop_state, LOOP_DOWN); |
| 1309 | atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME); |
| 1310 | qla2x00_mark_all_devices_lost(vha, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1311 | } |
| 1312 | |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 1313 | if (ha->flags.enable_lip_reset) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1314 | ret = qla2x00_lip_reset(vha); |
Saurav Kashyap | ad53768 | 2011-11-18 09:02:09 -0800 | [diff] [blame] | 1315 | if (ret != QLA_SUCCESS) |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1316 | ql_dbg(ql_dbg_taskm, vha, 0x802e, |
| 1317 | "lip_reset failed (%d).\n", ret); |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 1318 | } |
| 1319 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1320 | /* 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] | 1321 | vha->marker_needed = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1322 | |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 1323 | return QLA_SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1324 | } |
| 1325 | |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1326 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1327 | qla2x00_abort_all_cmds(scsi_qla_host_t *vha, int res) |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1328 | { |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1329 | int que, cnt; |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1330 | unsigned long flags; |
| 1331 | srb_t *sp; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1332 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1333 | struct req_que *req; |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1334 | |
| 1335 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1336 | for (que = 0; que < ha->max_req_queues; que++) { |
Anirban Chakraborty | 29bdccb | 2009-01-08 15:41:08 -0800 | [diff] [blame] | 1337 | req = ha->req_q_map[que]; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1338 | if (!req) |
| 1339 | continue; |
| 1340 | for (cnt = 1; cnt < MAX_OUTSTANDING_COMMANDS; cnt++) { |
| 1341 | sp = req->outstanding_cmds[cnt]; |
Andrew Vasquez | e612d46 | 2009-03-24 09:08:04 -0700 | [diff] [blame] | 1342 | if (sp) { |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1343 | req->outstanding_cmds[cnt] = NULL; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1344 | sp->done(vha, sp, res); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1345 | } |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1346 | } |
| 1347 | } |
| 1348 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1349 | } |
| 1350 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1351 | static int |
| 1352 | qla2xxx_slave_alloc(struct scsi_device *sdev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1353 | { |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 1354 | struct fc_rport *rport = starget_to_rport(scsi_target(sdev)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1355 | |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 1356 | if (!rport || fc_remote_port_chkready(rport)) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1357 | return -ENXIO; |
| 1358 | |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 1359 | sdev->hostdata = *(fc_port_t **)rport->dd_data; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1360 | |
| 1361 | return 0; |
| 1362 | } |
| 1363 | |
| 1364 | static int |
| 1365 | qla2xxx_slave_configure(struct scsi_device *sdev) |
| 1366 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1367 | scsi_qla_host_t *vha = shost_priv(sdev->host); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1368 | struct req_que *req = vha->req; |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 1369 | |
Arun Easi | 9e522cd | 2012-08-22 14:21:31 -0400 | [diff] [blame] | 1370 | if (IS_T10_PI_CAPABLE(vha->hw)) |
| 1371 | blk_queue_update_dma_alignment(sdev->request_queue, 0x7); |
| 1372 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1373 | if (sdev->tagged_supported) |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1374 | scsi_activate_tcq(sdev, req->max_q_depth); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1375 | else |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1376 | scsi_deactivate_tcq(sdev, req->max_q_depth); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1377 | return 0; |
| 1378 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1379 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1380 | static void |
| 1381 | qla2xxx_slave_destroy(struct scsi_device *sdev) |
| 1382 | { |
| 1383 | sdev->hostdata = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1384 | } |
| 1385 | |
Giridhar Malavali | c45dd30 | 2009-12-02 10:36:54 -0800 | [diff] [blame] | 1386 | static void qla2x00_handle_queue_full(struct scsi_device *sdev, int qdepth) |
| 1387 | { |
| 1388 | fc_port_t *fcport = (struct fc_port *) sdev->hostdata; |
| 1389 | |
| 1390 | if (!scsi_track_queue_full(sdev, qdepth)) |
| 1391 | return; |
| 1392 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1393 | ql_dbg(ql_dbg_io, fcport->vha, 0x3029, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1394 | "Queue depth adjusted-down to %d for nexus=%ld:%d:%d.\n", |
| 1395 | sdev->queue_depth, fcport->vha->host_no, sdev->id, sdev->lun); |
Giridhar Malavali | c45dd30 | 2009-12-02 10:36:54 -0800 | [diff] [blame] | 1396 | } |
| 1397 | |
| 1398 | static void qla2x00_adjust_sdev_qdepth_up(struct scsi_device *sdev, int qdepth) |
| 1399 | { |
| 1400 | fc_port_t *fcport = sdev->hostdata; |
| 1401 | struct scsi_qla_host *vha = fcport->vha; |
Giridhar Malavali | c45dd30 | 2009-12-02 10:36:54 -0800 | [diff] [blame] | 1402 | struct req_que *req = NULL; |
| 1403 | |
| 1404 | req = vha->req; |
| 1405 | if (!req) |
| 1406 | return; |
| 1407 | |
| 1408 | if (req->max_q_depth <= sdev->queue_depth || req->max_q_depth < qdepth) |
| 1409 | return; |
| 1410 | |
| 1411 | if (sdev->ordered_tags) |
| 1412 | scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG, qdepth); |
| 1413 | else |
| 1414 | scsi_adjust_queue_depth(sdev, MSG_SIMPLE_TAG, qdepth); |
| 1415 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1416 | ql_dbg(ql_dbg_io, vha, 0x302a, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1417 | "Queue depth adjusted-up to %d for nexus=%ld:%d:%d.\n", |
| 1418 | sdev->queue_depth, fcport->vha->host_no, sdev->id, sdev->lun); |
Giridhar Malavali | c45dd30 | 2009-12-02 10:36:54 -0800 | [diff] [blame] | 1419 | } |
| 1420 | |
Andrew Vasquez | ce7e4af | 2005-08-26 19:09:30 -0700 | [diff] [blame] | 1421 | static int |
Mike Christie | e881a17 | 2009-10-15 17:46:39 -0700 | [diff] [blame] | 1422 | qla2x00_change_queue_depth(struct scsi_device *sdev, int qdepth, int reason) |
Andrew Vasquez | ce7e4af | 2005-08-26 19:09:30 -0700 | [diff] [blame] | 1423 | { |
Giridhar Malavali | c45dd30 | 2009-12-02 10:36:54 -0800 | [diff] [blame] | 1424 | switch (reason) { |
| 1425 | case SCSI_QDEPTH_DEFAULT: |
| 1426 | scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), qdepth); |
| 1427 | break; |
| 1428 | case SCSI_QDEPTH_QFULL: |
| 1429 | qla2x00_handle_queue_full(sdev, qdepth); |
| 1430 | break; |
| 1431 | case SCSI_QDEPTH_RAMP_UP: |
| 1432 | qla2x00_adjust_sdev_qdepth_up(sdev, qdepth); |
| 1433 | break; |
| 1434 | default: |
Roel Kluin | 08002af | 2010-01-29 11:25:19 +0100 | [diff] [blame] | 1435 | return -EOPNOTSUPP; |
Giridhar Malavali | c45dd30 | 2009-12-02 10:36:54 -0800 | [diff] [blame] | 1436 | } |
Mike Christie | e881a17 | 2009-10-15 17:46:39 -0700 | [diff] [blame] | 1437 | |
Andrew Vasquez | ce7e4af | 2005-08-26 19:09:30 -0700 | [diff] [blame] | 1438 | return sdev->queue_depth; |
| 1439 | } |
| 1440 | |
| 1441 | static int |
| 1442 | qla2x00_change_queue_type(struct scsi_device *sdev, int tag_type) |
| 1443 | { |
| 1444 | if (sdev->tagged_supported) { |
| 1445 | scsi_set_tag_type(sdev, tag_type); |
| 1446 | if (tag_type) |
| 1447 | scsi_activate_tcq(sdev, sdev->queue_depth); |
| 1448 | else |
| 1449 | scsi_deactivate_tcq(sdev, sdev->queue_depth); |
| 1450 | } else |
| 1451 | tag_type = 0; |
| 1452 | |
| 1453 | return tag_type; |
| 1454 | } |
| 1455 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1456 | /** |
| 1457 | * qla2x00_config_dma_addressing() - Configure OS DMA addressing method. |
| 1458 | * @ha: HA context |
| 1459 | * |
| 1460 | * At exit, the @ha's flags.enable_64bit_addressing set to indicated |
| 1461 | * supported addressing method. |
| 1462 | */ |
| 1463 | static void |
Andrew Vasquez | 53303c4 | 2009-01-22 09:45:37 -0800 | [diff] [blame] | 1464 | qla2x00_config_dma_addressing(struct qla_hw_data *ha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1465 | { |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1466 | /* Assume a 32bit DMA mask. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1467 | ha->flags.enable_64bit_addressing = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1468 | |
Yang Hongyang | 6a35528 | 2009-04-06 19:01:13 -0700 | [diff] [blame] | 1469 | if (!dma_set_mask(&ha->pdev->dev, DMA_BIT_MASK(64))) { |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1470 | /* Any upper-dword bits set? */ |
| 1471 | if (MSD(dma_get_required_mask(&ha->pdev->dev)) && |
Yang Hongyang | 6a35528 | 2009-04-06 19:01:13 -0700 | [diff] [blame] | 1472 | !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) { |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1473 | /* Ok, a 64bit DMA mask is applicable. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1474 | ha->flags.enable_64bit_addressing = 1; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1475 | ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64; |
| 1476 | ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64; |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1477 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1478 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1479 | } |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1480 | |
Yang Hongyang | 284901a | 2009-04-06 19:01:15 -0700 | [diff] [blame] | 1481 | dma_set_mask(&ha->pdev->dev, DMA_BIT_MASK(32)); |
| 1482 | pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(32)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1483 | } |
| 1484 | |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1485 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1486 | qla2x00_enable_intrs(struct qla_hw_data *ha) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1487 | { |
| 1488 | unsigned long flags = 0; |
| 1489 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
| 1490 | |
| 1491 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1492 | ha->interrupts_on = 1; |
| 1493 | /* enable risc and host interrupts */ |
| 1494 | WRT_REG_WORD(®->ictrl, ICR_EN_INT | ICR_EN_RISC); |
| 1495 | RD_REG_WORD(®->ictrl); |
| 1496 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1497 | |
| 1498 | } |
| 1499 | |
| 1500 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1501 | qla2x00_disable_intrs(struct qla_hw_data *ha) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1502 | { |
| 1503 | unsigned long flags = 0; |
| 1504 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
| 1505 | |
| 1506 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1507 | ha->interrupts_on = 0; |
| 1508 | /* disable risc and host interrupts */ |
| 1509 | WRT_REG_WORD(®->ictrl, 0); |
| 1510 | RD_REG_WORD(®->ictrl); |
| 1511 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1512 | } |
| 1513 | |
| 1514 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1515 | qla24xx_enable_intrs(struct qla_hw_data *ha) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1516 | { |
| 1517 | unsigned long flags = 0; |
| 1518 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
| 1519 | |
| 1520 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1521 | ha->interrupts_on = 1; |
| 1522 | WRT_REG_DWORD(®->ictrl, ICRX_EN_RISC_INT); |
| 1523 | RD_REG_DWORD(®->ictrl); |
| 1524 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1525 | } |
| 1526 | |
| 1527 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1528 | qla24xx_disable_intrs(struct qla_hw_data *ha) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1529 | { |
| 1530 | unsigned long flags = 0; |
| 1531 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
| 1532 | |
Andrew Vasquez | 124f85e | 2009-01-05 11:18:06 -0800 | [diff] [blame] | 1533 | if (IS_NOPOLLING_TYPE(ha)) |
| 1534 | return; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1535 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1536 | ha->interrupts_on = 0; |
| 1537 | WRT_REG_DWORD(®->ictrl, 0); |
| 1538 | RD_REG_DWORD(®->ictrl); |
| 1539 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1540 | } |
| 1541 | |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1542 | static int |
| 1543 | qla2x00_iospace_config(struct qla_hw_data *ha) |
| 1544 | { |
| 1545 | resource_size_t pio; |
| 1546 | uint16_t msix; |
| 1547 | int cpus; |
| 1548 | |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1549 | if (pci_request_selected_regions(ha->pdev, ha->bars, |
| 1550 | QLA2XXX_DRIVER_NAME)) { |
| 1551 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0011, |
| 1552 | "Failed to reserve PIO/MMIO regions (%s), aborting.\n", |
| 1553 | pci_name(ha->pdev)); |
| 1554 | goto iospace_error_exit; |
| 1555 | } |
| 1556 | if (!(ha->bars & 1)) |
| 1557 | goto skip_pio; |
| 1558 | |
| 1559 | /* We only need PIO for Flash operations on ISP2312 v2 chips. */ |
| 1560 | pio = pci_resource_start(ha->pdev, 0); |
| 1561 | if (pci_resource_flags(ha->pdev, 0) & IORESOURCE_IO) { |
| 1562 | if (pci_resource_len(ha->pdev, 0) < MIN_IOBASE_LEN) { |
| 1563 | ql_log_pci(ql_log_warn, ha->pdev, 0x0012, |
| 1564 | "Invalid pci I/O region size (%s).\n", |
| 1565 | pci_name(ha->pdev)); |
| 1566 | pio = 0; |
| 1567 | } |
| 1568 | } else { |
| 1569 | ql_log_pci(ql_log_warn, ha->pdev, 0x0013, |
| 1570 | "Region #0 no a PIO resource (%s).\n", |
| 1571 | pci_name(ha->pdev)); |
| 1572 | pio = 0; |
| 1573 | } |
| 1574 | ha->pio_address = pio; |
| 1575 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0014, |
| 1576 | "PIO address=%llu.\n", |
| 1577 | (unsigned long long)ha->pio_address); |
| 1578 | |
| 1579 | skip_pio: |
| 1580 | /* Use MMIO operations for all accesses. */ |
| 1581 | if (!(pci_resource_flags(ha->pdev, 1) & IORESOURCE_MEM)) { |
| 1582 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0015, |
| 1583 | "Region #1 not an MMIO resource (%s), aborting.\n", |
| 1584 | pci_name(ha->pdev)); |
| 1585 | goto iospace_error_exit; |
| 1586 | } |
| 1587 | if (pci_resource_len(ha->pdev, 1) < MIN_IOBASE_LEN) { |
| 1588 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0016, |
| 1589 | "Invalid PCI mem region size (%s), aborting.\n", |
| 1590 | pci_name(ha->pdev)); |
| 1591 | goto iospace_error_exit; |
| 1592 | } |
| 1593 | |
| 1594 | ha->iobase = ioremap(pci_resource_start(ha->pdev, 1), MIN_IOBASE_LEN); |
| 1595 | if (!ha->iobase) { |
| 1596 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0017, |
| 1597 | "Cannot remap MMIO (%s), aborting.\n", |
| 1598 | pci_name(ha->pdev)); |
| 1599 | goto iospace_error_exit; |
| 1600 | } |
| 1601 | |
| 1602 | /* Determine queue resources */ |
| 1603 | ha->max_req_queues = ha->max_rsp_queues = 1; |
| 1604 | if ((ql2xmaxqueues <= 1 && !ql2xmultique_tag) || |
| 1605 | (ql2xmaxqueues > 1 && ql2xmultique_tag) || |
| 1606 | (!IS_QLA25XX(ha) && !IS_QLA81XX(ha))) |
| 1607 | goto mqiobase_exit; |
| 1608 | |
| 1609 | ha->mqiobase = ioremap(pci_resource_start(ha->pdev, 3), |
| 1610 | pci_resource_len(ha->pdev, 3)); |
| 1611 | if (ha->mqiobase) { |
| 1612 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0018, |
| 1613 | "MQIO Base=%p.\n", ha->mqiobase); |
| 1614 | /* Read MSIX vector size of the board */ |
| 1615 | pci_read_config_word(ha->pdev, QLA_PCI_MSIX_CONTROL, &msix); |
| 1616 | ha->msix_count = msix; |
| 1617 | /* Max queues are bounded by available msix vectors */ |
| 1618 | /* queue 0 uses two msix vectors */ |
| 1619 | if (ql2xmultique_tag) { |
| 1620 | cpus = num_online_cpus(); |
| 1621 | ha->max_rsp_queues = (ha->msix_count - 1 > cpus) ? |
| 1622 | (cpus + 1) : (ha->msix_count - 1); |
| 1623 | ha->max_req_queues = 2; |
| 1624 | } else if (ql2xmaxqueues > 1) { |
| 1625 | ha->max_req_queues = ql2xmaxqueues > QLA_MQ_SIZE ? |
| 1626 | QLA_MQ_SIZE : ql2xmaxqueues; |
| 1627 | ql_dbg_pci(ql_dbg_multiq, ha->pdev, 0xc008, |
| 1628 | "QoS mode set, max no of request queues:%d.\n", |
| 1629 | ha->max_req_queues); |
| 1630 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0019, |
| 1631 | "QoS mode set, max no of request queues:%d.\n", |
| 1632 | ha->max_req_queues); |
| 1633 | } |
| 1634 | ql_log_pci(ql_log_info, ha->pdev, 0x001a, |
| 1635 | "MSI-X vector count: %d.\n", msix); |
| 1636 | } else |
| 1637 | ql_log_pci(ql_log_info, ha->pdev, 0x001b, |
| 1638 | "BAR 3 not enabled.\n"); |
| 1639 | |
| 1640 | mqiobase_exit: |
| 1641 | ha->msix_count = ha->max_rsp_queues + 1; |
| 1642 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x001c, |
| 1643 | "MSIX Count:%d.\n", ha->msix_count); |
| 1644 | return (0); |
| 1645 | |
| 1646 | iospace_error_exit: |
| 1647 | return (-ENOMEM); |
| 1648 | } |
| 1649 | |
| 1650 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1651 | static int |
| 1652 | qla83xx_iospace_config(struct qla_hw_data *ha) |
| 1653 | { |
| 1654 | uint16_t msix; |
| 1655 | int cpus; |
| 1656 | |
| 1657 | if (pci_request_selected_regions(ha->pdev, ha->bars, |
| 1658 | QLA2XXX_DRIVER_NAME)) { |
| 1659 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0117, |
| 1660 | "Failed to reserve PIO/MMIO regions (%s), aborting.\n", |
| 1661 | pci_name(ha->pdev)); |
| 1662 | |
| 1663 | goto iospace_error_exit; |
| 1664 | } |
| 1665 | |
| 1666 | /* Use MMIO operations for all accesses. */ |
| 1667 | if (!(pci_resource_flags(ha->pdev, 0) & IORESOURCE_MEM)) { |
| 1668 | ql_log_pci(ql_log_warn, ha->pdev, 0x0118, |
| 1669 | "Invalid pci I/O region size (%s).\n", |
| 1670 | pci_name(ha->pdev)); |
| 1671 | goto iospace_error_exit; |
| 1672 | } |
| 1673 | if (pci_resource_len(ha->pdev, 0) < MIN_IOBASE_LEN) { |
| 1674 | ql_log_pci(ql_log_warn, ha->pdev, 0x0119, |
| 1675 | "Invalid PCI mem region size (%s), aborting\n", |
| 1676 | pci_name(ha->pdev)); |
| 1677 | goto iospace_error_exit; |
| 1678 | } |
| 1679 | |
| 1680 | ha->iobase = ioremap(pci_resource_start(ha->pdev, 0), MIN_IOBASE_LEN); |
| 1681 | if (!ha->iobase) { |
| 1682 | ql_log_pci(ql_log_fatal, ha->pdev, 0x011a, |
| 1683 | "Cannot remap MMIO (%s), aborting.\n", |
| 1684 | pci_name(ha->pdev)); |
| 1685 | goto iospace_error_exit; |
| 1686 | } |
| 1687 | |
| 1688 | /* 64bit PCI BAR - BAR2 will correspoond to region 4 */ |
| 1689 | /* 83XX 26XX always use MQ type access for queues |
| 1690 | * - mbar 2, a.k.a region 4 */ |
| 1691 | ha->max_req_queues = ha->max_rsp_queues = 1; |
| 1692 | ha->mqiobase = ioremap(pci_resource_start(ha->pdev, 4), |
| 1693 | pci_resource_len(ha->pdev, 4)); |
| 1694 | |
| 1695 | if (!ha->mqiobase) { |
| 1696 | ql_log_pci(ql_log_fatal, ha->pdev, 0x011d, |
| 1697 | "BAR2/region4 not enabled\n"); |
| 1698 | goto mqiobase_exit; |
| 1699 | } |
| 1700 | |
| 1701 | ha->msixbase = ioremap(pci_resource_start(ha->pdev, 2), |
| 1702 | pci_resource_len(ha->pdev, 2)); |
| 1703 | if (ha->msixbase) { |
| 1704 | /* Read MSIX vector size of the board */ |
| 1705 | pci_read_config_word(ha->pdev, |
| 1706 | QLA_83XX_PCI_MSIX_CONTROL, &msix); |
| 1707 | ha->msix_count = msix; |
| 1708 | /* Max queues are bounded by available msix vectors */ |
| 1709 | /* queue 0 uses two msix vectors */ |
| 1710 | if (ql2xmultique_tag) { |
| 1711 | cpus = num_online_cpus(); |
| 1712 | ha->max_rsp_queues = (ha->msix_count - 1 > cpus) ? |
| 1713 | (cpus + 1) : (ha->msix_count - 1); |
| 1714 | ha->max_req_queues = 2; |
| 1715 | } else if (ql2xmaxqueues > 1) { |
| 1716 | ha->max_req_queues = ql2xmaxqueues > QLA_MQ_SIZE ? |
| 1717 | QLA_MQ_SIZE : ql2xmaxqueues; |
| 1718 | ql_dbg_pci(ql_dbg_multiq, ha->pdev, 0xc00c, |
| 1719 | "QoS mode set, max no of request queues:%d.\n", |
| 1720 | ha->max_req_queues); |
| 1721 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x011b, |
| 1722 | "QoS mode set, max no of request queues:%d.\n", |
| 1723 | ha->max_req_queues); |
| 1724 | } |
| 1725 | ql_log_pci(ql_log_info, ha->pdev, 0x011c, |
| 1726 | "MSI-X vector count: %d.\n", msix); |
| 1727 | } else |
| 1728 | ql_log_pci(ql_log_info, ha->pdev, 0x011e, |
| 1729 | "BAR 1 not enabled.\n"); |
| 1730 | |
| 1731 | mqiobase_exit: |
| 1732 | ha->msix_count = ha->max_rsp_queues + 1; |
| 1733 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x011f, |
| 1734 | "MSIX Count:%d.\n", ha->msix_count); |
| 1735 | return 0; |
| 1736 | |
| 1737 | iospace_error_exit: |
| 1738 | return -ENOMEM; |
| 1739 | } |
| 1740 | |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1741 | static struct isp_operations qla2100_isp_ops = { |
| 1742 | .pci_config = qla2100_pci_config, |
| 1743 | .reset_chip = qla2x00_reset_chip, |
| 1744 | .chip_diag = qla2x00_chip_diag, |
| 1745 | .config_rings = qla2x00_config_rings, |
| 1746 | .reset_adapter = qla2x00_reset_adapter, |
| 1747 | .nvram_config = qla2x00_nvram_config, |
| 1748 | .update_fw_options = qla2x00_update_fw_options, |
| 1749 | .load_risc = qla2x00_load_risc, |
| 1750 | .pci_info_str = qla2x00_pci_info_str, |
| 1751 | .fw_version_str = qla2x00_fw_version_str, |
| 1752 | .intr_handler = qla2100_intr_handler, |
| 1753 | .enable_intrs = qla2x00_enable_intrs, |
| 1754 | .disable_intrs = qla2x00_disable_intrs, |
| 1755 | .abort_command = qla2x00_abort_command, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1756 | .target_reset = qla2x00_abort_target, |
| 1757 | .lun_reset = qla2x00_lun_reset, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1758 | .fabric_login = qla2x00_login_fabric, |
| 1759 | .fabric_logout = qla2x00_fabric_logout, |
| 1760 | .calc_req_entries = qla2x00_calc_iocbs_32, |
| 1761 | .build_iocbs = qla2x00_build_scsi_iocbs_32, |
| 1762 | .prep_ms_iocb = qla2x00_prep_ms_iocb, |
| 1763 | .prep_ms_fdmi_iocb = qla2x00_prep_ms_fdmi_iocb, |
| 1764 | .read_nvram = qla2x00_read_nvram_data, |
| 1765 | .write_nvram = qla2x00_write_nvram_data, |
| 1766 | .fw_dump = qla2100_fw_dump, |
| 1767 | .beacon_on = NULL, |
| 1768 | .beacon_off = NULL, |
| 1769 | .beacon_blink = NULL, |
| 1770 | .read_optrom = qla2x00_read_optrom_data, |
| 1771 | .write_optrom = qla2x00_write_optrom_data, |
| 1772 | .get_flash_version = qla2x00_get_flash_version, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1773 | .start_scsi = qla2x00_start_scsi, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1774 | .abort_isp = qla2x00_abort_isp, |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1775 | .iospace_config = qla2x00_iospace_config, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1776 | }; |
| 1777 | |
| 1778 | static struct isp_operations qla2300_isp_ops = { |
| 1779 | .pci_config = qla2300_pci_config, |
| 1780 | .reset_chip = qla2x00_reset_chip, |
| 1781 | .chip_diag = qla2x00_chip_diag, |
| 1782 | .config_rings = qla2x00_config_rings, |
| 1783 | .reset_adapter = qla2x00_reset_adapter, |
| 1784 | .nvram_config = qla2x00_nvram_config, |
| 1785 | .update_fw_options = qla2x00_update_fw_options, |
| 1786 | .load_risc = qla2x00_load_risc, |
| 1787 | .pci_info_str = qla2x00_pci_info_str, |
| 1788 | .fw_version_str = qla2x00_fw_version_str, |
| 1789 | .intr_handler = qla2300_intr_handler, |
| 1790 | .enable_intrs = qla2x00_enable_intrs, |
| 1791 | .disable_intrs = qla2x00_disable_intrs, |
| 1792 | .abort_command = qla2x00_abort_command, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1793 | .target_reset = qla2x00_abort_target, |
| 1794 | .lun_reset = qla2x00_lun_reset, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1795 | .fabric_login = qla2x00_login_fabric, |
| 1796 | .fabric_logout = qla2x00_fabric_logout, |
| 1797 | .calc_req_entries = qla2x00_calc_iocbs_32, |
| 1798 | .build_iocbs = qla2x00_build_scsi_iocbs_32, |
| 1799 | .prep_ms_iocb = qla2x00_prep_ms_iocb, |
| 1800 | .prep_ms_fdmi_iocb = qla2x00_prep_ms_fdmi_iocb, |
| 1801 | .read_nvram = qla2x00_read_nvram_data, |
| 1802 | .write_nvram = qla2x00_write_nvram_data, |
| 1803 | .fw_dump = qla2300_fw_dump, |
| 1804 | .beacon_on = qla2x00_beacon_on, |
| 1805 | .beacon_off = qla2x00_beacon_off, |
| 1806 | .beacon_blink = qla2x00_beacon_blink, |
| 1807 | .read_optrom = qla2x00_read_optrom_data, |
| 1808 | .write_optrom = qla2x00_write_optrom_data, |
| 1809 | .get_flash_version = qla2x00_get_flash_version, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1810 | .start_scsi = qla2x00_start_scsi, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1811 | .abort_isp = qla2x00_abort_isp, |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1812 | .iospace_config = qla2x00_iospace_config, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1813 | }; |
| 1814 | |
| 1815 | static struct isp_operations qla24xx_isp_ops = { |
| 1816 | .pci_config = qla24xx_pci_config, |
| 1817 | .reset_chip = qla24xx_reset_chip, |
| 1818 | .chip_diag = qla24xx_chip_diag, |
| 1819 | .config_rings = qla24xx_config_rings, |
| 1820 | .reset_adapter = qla24xx_reset_adapter, |
| 1821 | .nvram_config = qla24xx_nvram_config, |
| 1822 | .update_fw_options = qla24xx_update_fw_options, |
| 1823 | .load_risc = qla24xx_load_risc, |
| 1824 | .pci_info_str = qla24xx_pci_info_str, |
| 1825 | .fw_version_str = qla24xx_fw_version_str, |
| 1826 | .intr_handler = qla24xx_intr_handler, |
| 1827 | .enable_intrs = qla24xx_enable_intrs, |
| 1828 | .disable_intrs = qla24xx_disable_intrs, |
| 1829 | .abort_command = qla24xx_abort_command, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1830 | .target_reset = qla24xx_abort_target, |
| 1831 | .lun_reset = qla24xx_lun_reset, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1832 | .fabric_login = qla24xx_login_fabric, |
| 1833 | .fabric_logout = qla24xx_fabric_logout, |
| 1834 | .calc_req_entries = NULL, |
| 1835 | .build_iocbs = NULL, |
| 1836 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 1837 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 1838 | .read_nvram = qla24xx_read_nvram_data, |
| 1839 | .write_nvram = qla24xx_write_nvram_data, |
| 1840 | .fw_dump = qla24xx_fw_dump, |
| 1841 | .beacon_on = qla24xx_beacon_on, |
| 1842 | .beacon_off = qla24xx_beacon_off, |
| 1843 | .beacon_blink = qla24xx_beacon_blink, |
| 1844 | .read_optrom = qla24xx_read_optrom_data, |
| 1845 | .write_optrom = qla24xx_write_optrom_data, |
| 1846 | .get_flash_version = qla24xx_get_flash_version, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1847 | .start_scsi = qla24xx_start_scsi, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1848 | .abort_isp = qla2x00_abort_isp, |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1849 | .iospace_config = qla2x00_iospace_config, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1850 | }; |
| 1851 | |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1852 | static struct isp_operations qla25xx_isp_ops = { |
| 1853 | .pci_config = qla25xx_pci_config, |
| 1854 | .reset_chip = qla24xx_reset_chip, |
| 1855 | .chip_diag = qla24xx_chip_diag, |
| 1856 | .config_rings = qla24xx_config_rings, |
| 1857 | .reset_adapter = qla24xx_reset_adapter, |
| 1858 | .nvram_config = qla24xx_nvram_config, |
| 1859 | .update_fw_options = qla24xx_update_fw_options, |
| 1860 | .load_risc = qla24xx_load_risc, |
| 1861 | .pci_info_str = qla24xx_pci_info_str, |
| 1862 | .fw_version_str = qla24xx_fw_version_str, |
| 1863 | .intr_handler = qla24xx_intr_handler, |
| 1864 | .enable_intrs = qla24xx_enable_intrs, |
| 1865 | .disable_intrs = qla24xx_disable_intrs, |
| 1866 | .abort_command = qla24xx_abort_command, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1867 | .target_reset = qla24xx_abort_target, |
| 1868 | .lun_reset = qla24xx_lun_reset, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1869 | .fabric_login = qla24xx_login_fabric, |
| 1870 | .fabric_logout = qla24xx_fabric_logout, |
| 1871 | .calc_req_entries = NULL, |
| 1872 | .build_iocbs = NULL, |
| 1873 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 1874 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 1875 | .read_nvram = qla25xx_read_nvram_data, |
| 1876 | .write_nvram = qla25xx_write_nvram_data, |
| 1877 | .fw_dump = qla25xx_fw_dump, |
| 1878 | .beacon_on = qla24xx_beacon_on, |
| 1879 | .beacon_off = qla24xx_beacon_off, |
| 1880 | .beacon_blink = qla24xx_beacon_blink, |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 1881 | .read_optrom = qla25xx_read_optrom_data, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1882 | .write_optrom = qla24xx_write_optrom_data, |
| 1883 | .get_flash_version = qla24xx_get_flash_version, |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 1884 | .start_scsi = qla24xx_dif_start_scsi, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1885 | .abort_isp = qla2x00_abort_isp, |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1886 | .iospace_config = qla2x00_iospace_config, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1887 | }; |
| 1888 | |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 1889 | static struct isp_operations qla81xx_isp_ops = { |
| 1890 | .pci_config = qla25xx_pci_config, |
| 1891 | .reset_chip = qla24xx_reset_chip, |
| 1892 | .chip_diag = qla24xx_chip_diag, |
| 1893 | .config_rings = qla24xx_config_rings, |
| 1894 | .reset_adapter = qla24xx_reset_adapter, |
| 1895 | .nvram_config = qla81xx_nvram_config, |
| 1896 | .update_fw_options = qla81xx_update_fw_options, |
Andrew Vasquez | eaac30b | 2009-01-22 09:45:32 -0800 | [diff] [blame] | 1897 | .load_risc = qla81xx_load_risc, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 1898 | .pci_info_str = qla24xx_pci_info_str, |
| 1899 | .fw_version_str = qla24xx_fw_version_str, |
| 1900 | .intr_handler = qla24xx_intr_handler, |
| 1901 | .enable_intrs = qla24xx_enable_intrs, |
| 1902 | .disable_intrs = qla24xx_disable_intrs, |
| 1903 | .abort_command = qla24xx_abort_command, |
| 1904 | .target_reset = qla24xx_abort_target, |
| 1905 | .lun_reset = qla24xx_lun_reset, |
| 1906 | .fabric_login = qla24xx_login_fabric, |
| 1907 | .fabric_logout = qla24xx_fabric_logout, |
| 1908 | .calc_req_entries = NULL, |
| 1909 | .build_iocbs = NULL, |
| 1910 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 1911 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
Andrew Vasquez | 3d79038f | 2009-03-24 09:08:14 -0700 | [diff] [blame] | 1912 | .read_nvram = NULL, |
| 1913 | .write_nvram = NULL, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 1914 | .fw_dump = qla81xx_fw_dump, |
| 1915 | .beacon_on = qla24xx_beacon_on, |
| 1916 | .beacon_off = qla24xx_beacon_off, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1917 | .beacon_blink = qla83xx_beacon_blink, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 1918 | .read_optrom = qla25xx_read_optrom_data, |
| 1919 | .write_optrom = qla24xx_write_optrom_data, |
| 1920 | .get_flash_version = qla24xx_get_flash_version, |
Arun Easi | ba77ef5 | 2010-05-28 15:08:27 -0700 | [diff] [blame] | 1921 | .start_scsi = qla24xx_dif_start_scsi, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1922 | .abort_isp = qla2x00_abort_isp, |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1923 | .iospace_config = qla2x00_iospace_config, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1924 | }; |
| 1925 | |
| 1926 | static struct isp_operations qla82xx_isp_ops = { |
| 1927 | .pci_config = qla82xx_pci_config, |
| 1928 | .reset_chip = qla82xx_reset_chip, |
| 1929 | .chip_diag = qla24xx_chip_diag, |
| 1930 | .config_rings = qla82xx_config_rings, |
| 1931 | .reset_adapter = qla24xx_reset_adapter, |
| 1932 | .nvram_config = qla81xx_nvram_config, |
| 1933 | .update_fw_options = qla24xx_update_fw_options, |
| 1934 | .load_risc = qla82xx_load_risc, |
Atul Deshmukh | 9d55ca6 | 2012-08-22 14:21:14 -0400 | [diff] [blame] | 1935 | .pci_info_str = qla24xx_pci_info_str, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1936 | .fw_version_str = qla24xx_fw_version_str, |
| 1937 | .intr_handler = qla82xx_intr_handler, |
| 1938 | .enable_intrs = qla82xx_enable_intrs, |
| 1939 | .disable_intrs = qla82xx_disable_intrs, |
| 1940 | .abort_command = qla24xx_abort_command, |
| 1941 | .target_reset = qla24xx_abort_target, |
| 1942 | .lun_reset = qla24xx_lun_reset, |
| 1943 | .fabric_login = qla24xx_login_fabric, |
| 1944 | .fabric_logout = qla24xx_fabric_logout, |
| 1945 | .calc_req_entries = NULL, |
| 1946 | .build_iocbs = NULL, |
| 1947 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 1948 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 1949 | .read_nvram = qla24xx_read_nvram_data, |
| 1950 | .write_nvram = qla24xx_write_nvram_data, |
| 1951 | .fw_dump = qla24xx_fw_dump, |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 1952 | .beacon_on = qla82xx_beacon_on, |
| 1953 | .beacon_off = qla82xx_beacon_off, |
| 1954 | .beacon_blink = NULL, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1955 | .read_optrom = qla82xx_read_optrom_data, |
| 1956 | .write_optrom = qla82xx_write_optrom_data, |
| 1957 | .get_flash_version = qla24xx_get_flash_version, |
| 1958 | .start_scsi = qla82xx_start_scsi, |
| 1959 | .abort_isp = qla82xx_abort_isp, |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1960 | .iospace_config = qla82xx_iospace_config, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 1961 | }; |
| 1962 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1963 | static struct isp_operations qla83xx_isp_ops = { |
| 1964 | .pci_config = qla25xx_pci_config, |
| 1965 | .reset_chip = qla24xx_reset_chip, |
| 1966 | .chip_diag = qla24xx_chip_diag, |
| 1967 | .config_rings = qla24xx_config_rings, |
| 1968 | .reset_adapter = qla24xx_reset_adapter, |
| 1969 | .nvram_config = qla81xx_nvram_config, |
| 1970 | .update_fw_options = qla81xx_update_fw_options, |
| 1971 | .load_risc = qla81xx_load_risc, |
| 1972 | .pci_info_str = qla24xx_pci_info_str, |
| 1973 | .fw_version_str = qla24xx_fw_version_str, |
| 1974 | .intr_handler = qla24xx_intr_handler, |
| 1975 | .enable_intrs = qla24xx_enable_intrs, |
| 1976 | .disable_intrs = qla24xx_disable_intrs, |
| 1977 | .abort_command = qla24xx_abort_command, |
| 1978 | .target_reset = qla24xx_abort_target, |
| 1979 | .lun_reset = qla24xx_lun_reset, |
| 1980 | .fabric_login = qla24xx_login_fabric, |
| 1981 | .fabric_logout = qla24xx_fabric_logout, |
| 1982 | .calc_req_entries = NULL, |
| 1983 | .build_iocbs = NULL, |
| 1984 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 1985 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 1986 | .read_nvram = NULL, |
| 1987 | .write_nvram = NULL, |
| 1988 | .fw_dump = qla83xx_fw_dump, |
| 1989 | .beacon_on = qla24xx_beacon_on, |
| 1990 | .beacon_off = qla24xx_beacon_off, |
| 1991 | .beacon_blink = qla83xx_beacon_blink, |
| 1992 | .read_optrom = qla25xx_read_optrom_data, |
| 1993 | .write_optrom = qla24xx_write_optrom_data, |
| 1994 | .get_flash_version = qla24xx_get_flash_version, |
| 1995 | .start_scsi = qla24xx_dif_start_scsi, |
| 1996 | .abort_isp = qla2x00_abort_isp, |
| 1997 | .iospace_config = qla83xx_iospace_config, |
| 1998 | }; |
| 1999 | |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2000 | static inline void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2001 | qla2x00_set_isp_flags(struct qla_hw_data *ha) |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2002 | { |
| 2003 | ha->device_type = DT_EXTENDED_IDS; |
| 2004 | switch (ha->pdev->device) { |
| 2005 | case PCI_DEVICE_ID_QLOGIC_ISP2100: |
| 2006 | ha->device_type |= DT_ISP2100; |
| 2007 | ha->device_type &= ~DT_EXTENDED_IDS; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2008 | ha->fw_srisc_address = RISC_START_ADDRESS_2100; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2009 | break; |
| 2010 | case PCI_DEVICE_ID_QLOGIC_ISP2200: |
| 2011 | ha->device_type |= DT_ISP2200; |
| 2012 | ha->device_type &= ~DT_EXTENDED_IDS; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2013 | ha->fw_srisc_address = RISC_START_ADDRESS_2100; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2014 | break; |
| 2015 | case PCI_DEVICE_ID_QLOGIC_ISP2300: |
| 2016 | ha->device_type |= DT_ISP2300; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2017 | ha->device_type |= DT_ZIO_SUPPORTED; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2018 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2019 | break; |
| 2020 | case PCI_DEVICE_ID_QLOGIC_ISP2312: |
| 2021 | ha->device_type |= DT_ISP2312; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2022 | ha->device_type |= DT_ZIO_SUPPORTED; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2023 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2024 | break; |
| 2025 | case PCI_DEVICE_ID_QLOGIC_ISP2322: |
| 2026 | ha->device_type |= DT_ISP2322; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2027 | ha->device_type |= DT_ZIO_SUPPORTED; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2028 | if (ha->pdev->subsystem_vendor == 0x1028 && |
| 2029 | ha->pdev->subsystem_device == 0x0170) |
| 2030 | ha->device_type |= DT_OEM_001; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2031 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2032 | break; |
| 2033 | case PCI_DEVICE_ID_QLOGIC_ISP6312: |
| 2034 | ha->device_type |= DT_ISP6312; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2035 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2036 | break; |
| 2037 | case PCI_DEVICE_ID_QLOGIC_ISP6322: |
| 2038 | ha->device_type |= DT_ISP6322; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2039 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2040 | break; |
| 2041 | case PCI_DEVICE_ID_QLOGIC_ISP2422: |
| 2042 | ha->device_type |= DT_ISP2422; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2043 | ha->device_type |= DT_ZIO_SUPPORTED; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2044 | ha->device_type |= DT_FWI2; |
Andrew Vasquez | c76f2c0 | 2007-07-19 15:05:57 -0700 | [diff] [blame] | 2045 | ha->device_type |= DT_IIDMA; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2046 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2047 | break; |
| 2048 | case PCI_DEVICE_ID_QLOGIC_ISP2432: |
| 2049 | ha->device_type |= DT_ISP2432; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2050 | ha->device_type |= DT_ZIO_SUPPORTED; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2051 | ha->device_type |= DT_FWI2; |
Andrew Vasquez | c76f2c0 | 2007-07-19 15:05:57 -0700 | [diff] [blame] | 2052 | ha->device_type |= DT_IIDMA; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2053 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2054 | break; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 2055 | case PCI_DEVICE_ID_QLOGIC_ISP8432: |
| 2056 | ha->device_type |= DT_ISP8432; |
| 2057 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2058 | ha->device_type |= DT_FWI2; |
| 2059 | ha->device_type |= DT_IIDMA; |
| 2060 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2061 | break; |
andrew.vasquez@qlogic.com | 044cc6c | 2006-03-09 14:27:13 -0800 | [diff] [blame] | 2062 | case PCI_DEVICE_ID_QLOGIC_ISP5422: |
| 2063 | ha->device_type |= DT_ISP5422; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2064 | ha->device_type |= DT_FWI2; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2065 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2066 | break; |
andrew.vasquez@qlogic.com | 044cc6c | 2006-03-09 14:27:13 -0800 | [diff] [blame] | 2067 | case PCI_DEVICE_ID_QLOGIC_ISP5432: |
| 2068 | ha->device_type |= DT_ISP5432; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2069 | ha->device_type |= DT_FWI2; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2070 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2071 | break; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2072 | case PCI_DEVICE_ID_QLOGIC_ISP2532: |
| 2073 | ha->device_type |= DT_ISP2532; |
| 2074 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2075 | ha->device_type |= DT_FWI2; |
| 2076 | ha->device_type |= DT_IIDMA; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2077 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2078 | break; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2079 | case PCI_DEVICE_ID_QLOGIC_ISP8001: |
| 2080 | ha->device_type |= DT_ISP8001; |
| 2081 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2082 | ha->device_type |= DT_FWI2; |
| 2083 | ha->device_type |= DT_IIDMA; |
| 2084 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2085 | break; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2086 | case PCI_DEVICE_ID_QLOGIC_ISP8021: |
| 2087 | ha->device_type |= DT_ISP8021; |
| 2088 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2089 | ha->device_type |= DT_FWI2; |
| 2090 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2091 | /* Initialize 82XX ISP flags */ |
| 2092 | qla82xx_init_flags(ha); |
| 2093 | break; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2094 | case PCI_DEVICE_ID_QLOGIC_ISP2031: |
| 2095 | ha->device_type |= DT_ISP2031; |
| 2096 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2097 | ha->device_type |= DT_FWI2; |
| 2098 | ha->device_type |= DT_IIDMA; |
| 2099 | ha->device_type |= DT_T10_PI; |
| 2100 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2101 | break; |
| 2102 | case PCI_DEVICE_ID_QLOGIC_ISP8031: |
| 2103 | ha->device_type |= DT_ISP8031; |
| 2104 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2105 | ha->device_type |= DT_FWI2; |
| 2106 | ha->device_type |= DT_IIDMA; |
| 2107 | ha->device_type |= DT_T10_PI; |
| 2108 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2109 | break; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2110 | } |
Anirban Chakraborty | e5b68a6 | 2009-04-06 22:33:50 -0700 | [diff] [blame] | 2111 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2112 | if (IS_QLA82XX(ha)) |
| 2113 | ha->port_no = !(ha->portnum & 1); |
| 2114 | else |
| 2115 | /* Get adapter physical port no from interrupt pin register. */ |
| 2116 | pci_read_config_byte(ha->pdev, PCI_INTERRUPT_PIN, &ha->port_no); |
| 2117 | |
Anirban Chakraborty | e5b68a6 | 2009-04-06 22:33:50 -0700 | [diff] [blame] | 2118 | if (ha->port_no & 1) |
| 2119 | ha->flags.port0 = 1; |
| 2120 | else |
| 2121 | ha->flags.port0 = 0; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2122 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x000b, |
Joe Perches | d8424f6 | 2011-11-18 09:03:06 -0800 | [diff] [blame] | 2123 | "device_type=0x%x port=%d fw_srisc_address=0x%x.\n", |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2124 | ha->device_type, ha->flags.port0, ha->fw_srisc_address); |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2125 | } |
| 2126 | |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2127 | static void |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2128 | qla2xxx_scan_start(struct Scsi_Host *shost) |
| 2129 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2130 | scsi_qla_host_t *vha = shost_priv(shost); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2131 | |
Andrew Vasquez | cbc8eb6 | 2009-06-03 09:55:17 -0700 | [diff] [blame] | 2132 | if (vha->hw->flags.running_gold_fw) |
| 2133 | return; |
| 2134 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2135 | set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); |
| 2136 | set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); |
| 2137 | set_bit(RSCN_UPDATE, &vha->dpc_flags); |
| 2138 | set_bit(NPIV_CONFIG_NEEDED, &vha->dpc_flags); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2139 | } |
| 2140 | |
| 2141 | static int |
| 2142 | qla2xxx_scan_finished(struct Scsi_Host *shost, unsigned long time) |
| 2143 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2144 | scsi_qla_host_t *vha = shost_priv(shost); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2145 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2146 | if (!vha->host) |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2147 | return 1; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2148 | if (time > vha->hw->loop_reset_delay * HZ) |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2149 | return 1; |
| 2150 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2151 | return atomic_read(&vha->loop_state) == LOOP_READY; |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2152 | } |
| 2153 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2154 | /* |
| 2155 | * PCI driver interface |
| 2156 | */ |
Andrew Vasquez | 7ee6139 | 2006-06-23 16:11:22 -0700 | [diff] [blame] | 2157 | static int __devinit |
| 2158 | 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] | 2159 | { |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2160 | int ret = -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2161 | struct Scsi_Host *host; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2162 | scsi_qla_host_t *base_vha = NULL; |
| 2163 | struct qla_hw_data *ha; |
Andrew Vasquez | 29856e2 | 2007-08-12 18:22:52 -0700 | [diff] [blame] | 2164 | char pci_info[30]; |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 2165 | char fw_str[30], wq_name[30]; |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 2166 | struct scsi_host_template *sht; |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2167 | int bars, mem_only = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2168 | uint16_t req_length = 0, rsp_length = 0; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2169 | struct req_que *req = NULL; |
| 2170 | struct rsp_que *rsp = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2171 | |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2172 | bars = pci_select_bars(pdev, IORESOURCE_MEM | IORESOURCE_IO); |
Giridhar Malavali | a5326f8 | 2009-03-24 09:07:56 -0700 | [diff] [blame] | 2173 | sht = &qla2xxx_driver_template; |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2174 | if (pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2422 || |
| 2175 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2432 || |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 2176 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8432 || |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2177 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP5422 || |
| 2178 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP5432 || |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2179 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2532 || |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2180 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8001 || |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2181 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8021 || |
| 2182 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2031 || |
| 2183 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8031) { |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2184 | bars = pci_select_bars(pdev, IORESOURCE_MEM); |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 2185 | mem_only = 1; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2186 | ql_dbg_pci(ql_dbg_init, pdev, 0x0007, |
| 2187 | "Mem only adapter.\n"); |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2188 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2189 | ql_dbg_pci(ql_dbg_init, pdev, 0x0008, |
| 2190 | "Bars=%d.\n", bars); |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2191 | |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 2192 | if (mem_only) { |
| 2193 | if (pci_enable_device_mem(pdev)) |
| 2194 | goto probe_out; |
| 2195 | } else { |
| 2196 | if (pci_enable_device(pdev)) |
| 2197 | goto probe_out; |
| 2198 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2199 | |
Jesse Barnes | 0927678 | 2008-10-18 17:33:19 -0700 | [diff] [blame] | 2200 | /* This may fail but that's ok */ |
| 2201 | pci_enable_pcie_error_reporting(pdev); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 2202 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2203 | ha = kzalloc(sizeof(struct qla_hw_data), GFP_KERNEL); |
| 2204 | if (!ha) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2205 | ql_log_pci(ql_log_fatal, pdev, 0x0009, |
| 2206 | "Unable to allocate memory for ha.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2207 | goto probe_out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2208 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2209 | ql_dbg_pci(ql_dbg_init, pdev, 0x000a, |
| 2210 | "Memory allocated for ha=%p.\n", ha); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2211 | ha->pdev = pdev; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2212 | ha->tgt.enable_class_2 = ql2xenableclass2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2213 | |
| 2214 | /* Clear our data area */ |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2215 | ha->bars = bars; |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 2216 | ha->mem_only = mem_only; |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 2217 | spin_lock_init(&ha->hardware_lock); |
Andrew Vasquez | 339aa70 | 2010-10-15 11:27:45 -0700 | [diff] [blame] | 2218 | spin_lock_init(&ha->vport_slock); |
Saurav Kashyap | a9b6f72 | 2012-08-22 14:21:01 -0400 | [diff] [blame] | 2219 | mutex_init(&ha->selflogin_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2220 | |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2221 | /* Set ISP-type information. */ |
| 2222 | qla2x00_set_isp_flags(ha); |
Duane Grigsby | ca79cf6 | 2009-12-15 21:29:47 -0800 | [diff] [blame] | 2223 | |
| 2224 | /* Set EEH reset type to fundamental if required by hba */ |
Joe Carnuccio | 9567611 | 2012-08-22 14:21:20 -0400 | [diff] [blame] | 2225 | if (IS_QLA24XX(ha) || IS_QLA25XX(ha) || IS_QLA81XX(ha) || |
| 2226 | IS_QLA83XX(ha)) |
Duane Grigsby | ca79cf6 | 2009-12-15 21:29:47 -0800 | [diff] [blame] | 2227 | pdev->needs_freset = 1; |
Duane Grigsby | ca79cf6 | 2009-12-15 21:29:47 -0800 | [diff] [blame] | 2228 | |
Chad Dupuis | cba1e47 | 2011-11-18 09:03:21 -0800 | [diff] [blame] | 2229 | ha->prev_topology = 0; |
| 2230 | ha->init_cb_size = sizeof(init_cb_t); |
| 2231 | ha->link_data_rate = PORT_SPEED_UNKNOWN; |
| 2232 | ha->optrom_size = OPTROM_SIZE_2300; |
| 2233 | |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2234 | /* Assign ISP specific operations. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2235 | if (IS_QLA2100(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2236 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2100; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2237 | ha->mbx_count = MAILBOX_REGISTER_COUNT_2100; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2238 | req_length = REQUEST_ENTRY_CNT_2100; |
| 2239 | rsp_length = RESPONSE_ENTRY_CNT_2100; |
| 2240 | ha->max_loop_id = SNS_LAST_LOOP_ID_2100; |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2241 | ha->gid_list_info_size = 4; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2242 | ha->flash_conf_off = ~0; |
| 2243 | ha->flash_data_off = ~0; |
| 2244 | ha->nvram_conf_off = ~0; |
| 2245 | ha->nvram_data_off = ~0; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2246 | ha->isp_ops = &qla2100_isp_ops; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2247 | } else if (IS_QLA2200(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2248 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2100; |
Andrew Vasquez | 67ddda3 | 2012-02-09 11:14:08 -0800 | [diff] [blame] | 2249 | ha->mbx_count = MAILBOX_REGISTER_COUNT_2200; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2250 | req_length = REQUEST_ENTRY_CNT_2200; |
| 2251 | rsp_length = RESPONSE_ENTRY_CNT_2100; |
| 2252 | ha->max_loop_id = SNS_LAST_LOOP_ID_2100; |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2253 | ha->gid_list_info_size = 4; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2254 | ha->flash_conf_off = ~0; |
| 2255 | ha->flash_data_off = ~0; |
| 2256 | ha->nvram_conf_off = ~0; |
| 2257 | ha->nvram_data_off = ~0; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2258 | ha->isp_ops = &qla2100_isp_ops; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 2259 | } else if (IS_QLA23XX(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2260 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2100; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2261 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2262 | req_length = REQUEST_ENTRY_CNT_2200; |
| 2263 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
| 2264 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2265 | ha->gid_list_info_size = 6; |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 2266 | if (IS_QLA2322(ha) || IS_QLA6322(ha)) |
| 2267 | ha->optrom_size = OPTROM_SIZE_2322; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2268 | ha->flash_conf_off = ~0; |
| 2269 | ha->flash_data_off = ~0; |
| 2270 | ha->nvram_conf_off = ~0; |
| 2271 | ha->nvram_data_off = ~0; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2272 | ha->isp_ops = &qla2300_isp_ops; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 2273 | } else if (IS_QLA24XX_TYPE(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2274 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 2275 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2276 | req_length = REQUEST_ENTRY_CNT_24XX; |
| 2277 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2278 | ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2279 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2280 | ha->init_cb_size = sizeof(struct mid_init_cb_24xx); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 2281 | ha->gid_list_info_size = 8; |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 2282 | ha->optrom_size = OPTROM_SIZE_24XX; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2283 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA24XX; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2284 | ha->isp_ops = &qla24xx_isp_ops; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2285 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF; |
| 2286 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA; |
| 2287 | ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF; |
| 2288 | ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2289 | } else if (IS_QLA25XX(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2290 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2291 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2292 | req_length = REQUEST_ENTRY_CNT_24XX; |
| 2293 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2294 | ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2295 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2296 | ha->init_cb_size = sizeof(struct mid_init_cb_24xx); |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2297 | ha->gid_list_info_size = 8; |
| 2298 | ha->optrom_size = OPTROM_SIZE_25XX; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2299 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2300 | ha->isp_ops = &qla25xx_isp_ops; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2301 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF; |
| 2302 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA; |
| 2303 | ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF; |
| 2304 | ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA; |
| 2305 | } else if (IS_QLA81XX(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2306 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2307 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
| 2308 | req_length = REQUEST_ENTRY_CNT_24XX; |
| 2309 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
| 2310 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 2311 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 2312 | ha->gid_list_info_size = 8; |
| 2313 | ha->optrom_size = OPTROM_SIZE_81XX; |
Anirban Chakraborty | 40859ae | 2009-06-03 09:55:16 -0700 | [diff] [blame] | 2314 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2315 | ha->isp_ops = &qla81xx_isp_ops; |
| 2316 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF_81XX; |
| 2317 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA_81XX; |
| 2318 | ha->nvram_conf_off = ~0; |
| 2319 | ha->nvram_data_off = ~0; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2320 | } else if (IS_QLA82XX(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2321 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2322 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
| 2323 | req_length = REQUEST_ENTRY_CNT_82XX; |
| 2324 | rsp_length = RESPONSE_ENTRY_CNT_82XX; |
| 2325 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 2326 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 2327 | ha->gid_list_info_size = 8; |
| 2328 | ha->optrom_size = OPTROM_SIZE_82XX; |
Andrew Vasquez | 087c621 | 2010-11-23 16:52:48 -0800 | [diff] [blame] | 2329 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2330 | ha->isp_ops = &qla82xx_isp_ops; |
| 2331 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF; |
| 2332 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA; |
| 2333 | ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF; |
| 2334 | ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2335 | } else if (IS_QLA83XX(ha)) { |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 2336 | ha->portnum = PCI_FUNC(ha->pdev->devfn); |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2337 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2338 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
| 2339 | req_length = REQUEST_ENTRY_CNT_24XX; |
| 2340 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
| 2341 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 2342 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 2343 | ha->gid_list_info_size = 8; |
| 2344 | ha->optrom_size = OPTROM_SIZE_83XX; |
| 2345 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
| 2346 | ha->isp_ops = &qla83xx_isp_ops; |
| 2347 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF_81XX; |
| 2348 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA_81XX; |
| 2349 | ha->nvram_conf_off = ~0; |
| 2350 | ha->nvram_data_off = ~0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2351 | } |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2352 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2353 | ql_dbg_pci(ql_dbg_init, pdev, 0x001e, |
| 2354 | "mbx_count=%d, req_length=%d, " |
| 2355 | "rsp_length=%d, max_loop_id=%d, init_cb_size=%d, " |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2356 | "gid_list_info_size=%d, optrom_size=%d, nvram_npiv_size=%d, " |
| 2357 | "max_fibre_devices=%d.\n", |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2358 | ha->mbx_count, req_length, rsp_length, ha->max_loop_id, |
| 2359 | ha->init_cb_size, ha->gid_list_info_size, ha->optrom_size, |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2360 | ha->nvram_npiv_size, ha->max_fibre_devices); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2361 | ql_dbg_pci(ql_dbg_init, pdev, 0x001f, |
| 2362 | "isp_ops=%p, flash_conf_off=%d, " |
| 2363 | "flash_data_off=%d, nvram_conf_off=%d, nvram_data_off=%d.\n", |
| 2364 | ha->isp_ops, ha->flash_conf_off, ha->flash_data_off, |
| 2365 | ha->nvram_conf_off, ha->nvram_data_off); |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 2366 | |
| 2367 | /* Configure PCI I/O space */ |
| 2368 | ret = ha->isp_ops->iospace_config(ha); |
| 2369 | if (ret) |
Saurav Kashyap | 0a63ad1 | 2012-11-21 02:40:43 -0500 | [diff] [blame^] | 2370 | goto iospace_config_failed; |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 2371 | |
| 2372 | ql_log_pci(ql_log_info, pdev, 0x001d, |
| 2373 | "Found an ISP%04X irq %d iobase 0x%p.\n", |
| 2374 | pdev->device, pdev->irq, ha->iobase); |
matthias@kaehlcke.net | 6c2f527 | 2008-05-12 22:21:11 -0700 | [diff] [blame] | 2375 | mutex_init(&ha->vport_lock); |
Marcus Barrow | 0b05a1f | 2008-01-17 09:02:13 -0800 | [diff] [blame] | 2376 | init_completion(&ha->mbx_cmd_comp); |
| 2377 | complete(&ha->mbx_cmd_comp); |
| 2378 | init_completion(&ha->mbx_intr_comp); |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 2379 | init_completion(&ha->dcbx_comp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2380 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2381 | set_bit(0, (unsigned long *) ha->vp_idx_map); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2382 | |
Andrew Vasquez | 53303c4 | 2009-01-22 09:45:37 -0800 | [diff] [blame] | 2383 | qla2x00_config_dma_addressing(ha); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2384 | ql_dbg_pci(ql_dbg_init, pdev, 0x0020, |
| 2385 | "64 Bit addressing is %s.\n", |
| 2386 | ha->flags.enable_64bit_addressing ? "enable" : |
| 2387 | "disable"); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2388 | ret = qla2x00_mem_alloc(ha, req_length, rsp_length, &req, &rsp); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2389 | if (!ret) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2390 | ql_log_pci(ql_log_fatal, pdev, 0x0031, |
| 2391 | "Failed to allocate memory for adapter, aborting.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2392 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2393 | goto probe_hw_failed; |
| 2394 | } |
| 2395 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2396 | req->max_q_depth = MAX_Q_DEPTH; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2397 | if (ql2xmaxqdepth != 0 && ql2xmaxqdepth <= 0xffffU) |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2398 | req->max_q_depth = ql2xmaxqdepth; |
| 2399 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2400 | |
| 2401 | base_vha = qla2x00_create_host(sht, ha); |
| 2402 | if (!base_vha) { |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2403 | ret = -ENOMEM; |
Anirban Chakraborty | 6e9f21f | 2009-01-22 09:45:28 -0800 | [diff] [blame] | 2404 | qla2x00_mem_free(ha); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2405 | qla2x00_free_req_que(ha, req); |
| 2406 | qla2x00_free_rsp_que(ha, rsp); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2407 | goto probe_hw_failed; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2408 | } |
| 2409 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2410 | pci_set_drvdata(pdev, base_vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2411 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2412 | host = base_vha->host; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2413 | base_vha->req = req; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2414 | host->can_queue = req->length + 128; |
| 2415 | if (IS_QLA2XXX_MIDTYPE(ha)) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2416 | base_vha->mgmt_svr_loop_id = 10 + base_vha->vp_idx; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2417 | else |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2418 | base_vha->mgmt_svr_loop_id = MANAGEMENT_SERVER + |
| 2419 | base_vha->vp_idx; |
Giridhar Malavali | 58548cb | 2010-09-03 15:20:56 -0700 | [diff] [blame] | 2420 | |
| 2421 | /* Set the SG table size based on ISP type */ |
| 2422 | if (!IS_FWI2_CAPABLE(ha)) { |
| 2423 | if (IS_QLA2100(ha)) |
| 2424 | host->sg_tablesize = 32; |
| 2425 | } else { |
| 2426 | if (!IS_QLA82XX(ha)) |
| 2427 | host->sg_tablesize = QLA_SG_ALL; |
| 2428 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2429 | ql_dbg(ql_dbg_init, base_vha, 0x0032, |
| 2430 | "can_queue=%d, req=%p, " |
| 2431 | "mgmt_svr_loop_id=%d, sg_tablesize=%d.\n", |
| 2432 | host->can_queue, base_vha->req, |
| 2433 | base_vha->mgmt_svr_loop_id, host->sg_tablesize); |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2434 | host->max_id = ha->max_fibre_devices; |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2435 | host->cmd_per_lun = 3; |
Seokmann Ju | 711c1d9 | 2008-07-10 16:55:51 -0700 | [diff] [blame] | 2436 | host->unique_id = host->host_no; |
Arun Easi | e02587d | 2011-08-16 11:29:23 -0700 | [diff] [blame] | 2437 | if (IS_T10_PI_CAPABLE(ha) && ql2xenabledif) |
Arun Easi | 0c47087 | 2010-07-23 15:28:38 +0500 | [diff] [blame] | 2438 | host->max_cmd_len = 32; |
| 2439 | else |
| 2440 | host->max_cmd_len = MAX_CMDSZ; |
Andrew Vasquez | 75bc419 | 2006-05-17 15:09:22 -0700 | [diff] [blame] | 2441 | host->max_channel = MAX_BUSES - 1; |
Andrew Vasquez | 8251592 | 2011-05-10 11:30:13 -0700 | [diff] [blame] | 2442 | host->max_lun = ql2xmaxlun; |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2443 | host->transportt = qla2xxx_transport_template; |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 2444 | sht->vendor_id = (SCSI_NL_VID_TYPE_PCI | PCI_VENDOR_ID_QLOGIC); |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2445 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2446 | ql_dbg(ql_dbg_init, base_vha, 0x0033, |
| 2447 | "max_id=%d this_id=%d " |
| 2448 | "cmd_per_len=%d unique_id=%d max_cmd_len=%d max_channel=%d " |
Joe Perches | d8424f6 | 2011-11-18 09:03:06 -0800 | [diff] [blame] | 2449 | "max_lun=%d transportt=%p, vendor_id=%llu.\n", host->max_id, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2450 | host->this_id, host->cmd_per_lun, host->unique_id, |
| 2451 | host->max_cmd_len, host->max_channel, host->max_lun, |
| 2452 | host->transportt, sht->vendor_id); |
| 2453 | |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 2454 | que_init: |
| 2455 | /* Alloc arrays of request and response ring ptrs */ |
| 2456 | if (!qla2x00_alloc_queues(ha, req, rsp)) { |
| 2457 | ql_log(ql_log_fatal, base_vha, 0x003d, |
| 2458 | "Failed to allocate memory for queue pointers..." |
| 2459 | "aborting.\n"); |
| 2460 | goto probe_init_failed; |
| 2461 | } |
| 2462 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2463 | qlt_probe_one_stage1(base_vha, ha); |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 2464 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2465 | /* Set up the irqs */ |
| 2466 | ret = qla2x00_request_irqs(ha, rsp); |
| 2467 | if (ret) |
Anirban Chakraborty | 6e9f21f | 2009-01-22 09:45:28 -0800 | [diff] [blame] | 2468 | goto probe_init_failed; |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 2469 | |
| 2470 | pci_save_state(pdev); |
| 2471 | |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 2472 | /* Assign back pointers */ |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2473 | rsp->req = req; |
| 2474 | req->rsp = rsp; |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 2475 | |
Andrew Vasquez | 0802999 | 2009-03-24 09:07:55 -0700 | [diff] [blame] | 2476 | /* FWI2-capable only. */ |
| 2477 | req->req_q_in = &ha->iobase->isp24.req_q_in; |
| 2478 | req->req_q_out = &ha->iobase->isp24.req_q_out; |
| 2479 | rsp->rsp_q_in = &ha->iobase->isp24.rsp_q_in; |
| 2480 | rsp->rsp_q_out = &ha->iobase->isp24.rsp_q_out; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2481 | if (ha->mqenable || IS_QLA83XX(ha)) { |
Andrew Vasquez | 0802999 | 2009-03-24 09:07:55 -0700 | [diff] [blame] | 2482 | req->req_q_in = &ha->mqiobase->isp25mq.req_q_in; |
| 2483 | req->req_q_out = &ha->mqiobase->isp25mq.req_q_out; |
| 2484 | rsp->rsp_q_in = &ha->mqiobase->isp25mq.rsp_q_in; |
| 2485 | rsp->rsp_q_out = &ha->mqiobase->isp25mq.rsp_q_out; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 2486 | } |
| 2487 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2488 | if (IS_QLA82XX(ha)) { |
| 2489 | req->req_q_out = &ha->iobase->isp82.req_q_out[0]; |
| 2490 | rsp->rsp_q_in = &ha->iobase->isp82.rsp_q_in[0]; |
| 2491 | rsp->rsp_q_out = &ha->iobase->isp82.rsp_q_out[0]; |
| 2492 | } |
| 2493 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2494 | ql_dbg(ql_dbg_multiq, base_vha, 0xc009, |
| 2495 | "rsp_q_map=%p req_q_map=%p rsp->req=%p req->rsp=%p.\n", |
| 2496 | ha->rsp_q_map, ha->req_q_map, rsp->req, req->rsp); |
| 2497 | ql_dbg(ql_dbg_multiq, base_vha, 0xc00a, |
| 2498 | "req->req_q_in=%p req->req_q_out=%p " |
| 2499 | "rsp->rsp_q_in=%p rsp->rsp_q_out=%p.\n", |
| 2500 | req->req_q_in, req->req_q_out, |
| 2501 | rsp->rsp_q_in, rsp->rsp_q_out); |
| 2502 | ql_dbg(ql_dbg_init, base_vha, 0x003e, |
| 2503 | "rsp_q_map=%p req_q_map=%p rsp->req=%p req->rsp=%p.\n", |
| 2504 | ha->rsp_q_map, ha->req_q_map, rsp->req, req->rsp); |
| 2505 | ql_dbg(ql_dbg_init, base_vha, 0x003f, |
| 2506 | "req->req_q_in=%p req->req_q_out=%p rsp->rsp_q_in=%p rsp->rsp_q_out=%p.\n", |
| 2507 | 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] | 2508 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2509 | if (qla2x00_initialize_adapter(base_vha)) { |
| 2510 | ql_log(ql_log_fatal, base_vha, 0x00d6, |
| 2511 | "Failed to initialize adapter - Adapter flags %x.\n", |
| 2512 | base_vha->device_flags); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2513 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2514 | if (IS_QLA82XX(ha)) { |
| 2515 | qla82xx_idc_lock(ha); |
| 2516 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 2517 | QLA8XXX_DEV_FAILED); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2518 | qla82xx_idc_unlock(ha); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2519 | ql_log(ql_log_fatal, base_vha, 0x00d7, |
| 2520 | "HW State: FAILED.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2521 | } |
| 2522 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2523 | ret = -ENODEV; |
| 2524 | goto probe_failed; |
| 2525 | } |
| 2526 | |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 2527 | if (ha->mqenable) { |
| 2528 | if (qla25xx_setup_mode(base_vha)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2529 | ql_log(ql_log_warn, base_vha, 0x00ec, |
| 2530 | "Failed to create queues, falling back to single queue mode.\n"); |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 2531 | goto que_init; |
| 2532 | } |
| 2533 | } |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 2534 | |
Andrew Vasquez | cbc8eb6 | 2009-06-03 09:55:17 -0700 | [diff] [blame] | 2535 | if (ha->flags.running_gold_fw) |
| 2536 | goto skip_dpc; |
| 2537 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2538 | /* |
| 2539 | * Startup the kernel thread for this host adapter |
| 2540 | */ |
| 2541 | ha->dpc_thread = kthread_create(qla2x00_do_dpc, ha, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2542 | "%s_dpc", base_vha->host_str); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2543 | if (IS_ERR(ha->dpc_thread)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2544 | ql_log(ql_log_fatal, base_vha, 0x00ed, |
| 2545 | "Failed to start DPC thread.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2546 | ret = PTR_ERR(ha->dpc_thread); |
| 2547 | goto probe_failed; |
| 2548 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2549 | ql_dbg(ql_dbg_init, base_vha, 0x00ee, |
| 2550 | "DPC thread started successfully.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2551 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2552 | /* |
| 2553 | * If we're not coming up in initiator mode, we might sit for |
| 2554 | * a while without waking up the dpc thread, which leads to a |
| 2555 | * stuck process warning. So just kick the dpc once here and |
| 2556 | * let the kthread start (and go back to sleep in qla2x00_do_dpc). |
| 2557 | */ |
| 2558 | qla2xxx_wake_dpc(base_vha); |
| 2559 | |
Saurav Kashyap | 8117877 | 2012-08-22 14:21:04 -0400 | [diff] [blame] | 2560 | if (IS_QLA8031(ha) || IS_MCTP_CAPABLE(ha)) { |
| 2561 | sprintf(wq_name, "qla2xxx_%lu_dpc_lp_wq", base_vha->host_no); |
| 2562 | ha->dpc_lp_wq = create_singlethread_workqueue(wq_name); |
| 2563 | INIT_WORK(&ha->idc_aen, qla83xx_service_idc_aen); |
| 2564 | |
| 2565 | sprintf(wq_name, "qla2xxx_%lu_dpc_hp_wq", base_vha->host_no); |
| 2566 | ha->dpc_hp_wq = create_singlethread_workqueue(wq_name); |
| 2567 | INIT_WORK(&ha->nic_core_reset, qla83xx_nic_core_reset_work); |
| 2568 | INIT_WORK(&ha->idc_state_handler, |
| 2569 | qla83xx_idc_state_handler_work); |
| 2570 | INIT_WORK(&ha->nic_core_unrecoverable, |
| 2571 | qla83xx_nic_core_unrecoverable_work); |
| 2572 | } |
| 2573 | |
Andrew Vasquez | cbc8eb6 | 2009-06-03 09:55:17 -0700 | [diff] [blame] | 2574 | skip_dpc: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2575 | list_add_tail(&base_vha->list, &ha->vp_list); |
| 2576 | base_vha->host->irq = ha->pdev->irq; |
| 2577 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2578 | /* Initialized the timer */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2579 | qla2x00_start_timer(base_vha, qla2x00_timer, WATCH_INTERVAL); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2580 | ql_dbg(ql_dbg_init, base_vha, 0x00ef, |
| 2581 | "Started qla2x00_timer with " |
| 2582 | "interval=%d.\n", WATCH_INTERVAL); |
| 2583 | ql_dbg(ql_dbg_init, base_vha, 0x00f0, |
| 2584 | "Detected hba at address=%p.\n", |
| 2585 | ha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2586 | |
Arun Easi | e02587d | 2011-08-16 11:29:23 -0700 | [diff] [blame] | 2587 | if (IS_T10_PI_CAPABLE(ha) && ql2xenabledif) { |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 2588 | if (ha->fw_attributes & BIT_4) { |
Arun Easi | 9e522cd | 2012-08-22 14:21:31 -0400 | [diff] [blame] | 2589 | int prot = 0, guard; |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 2590 | base_vha->flags.difdix_supported = 1; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2591 | ql_dbg(ql_dbg_init, base_vha, 0x00f1, |
| 2592 | "Registering for DIF/DIX type 1 and 3 protection.\n"); |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 2593 | if (ql2xenabledif == 1) |
| 2594 | prot = SHOST_DIX_TYPE0_PROTECTION; |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 2595 | scsi_host_set_prot(host, |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 2596 | prot | SHOST_DIF_TYPE1_PROTECTION |
Arun Easi | 0c47087 | 2010-07-23 15:28:38 +0500 | [diff] [blame] | 2597 | | SHOST_DIF_TYPE2_PROTECTION |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 2598 | | SHOST_DIF_TYPE3_PROTECTION |
| 2599 | | SHOST_DIX_TYPE1_PROTECTION |
Arun Easi | 0c47087 | 2010-07-23 15:28:38 +0500 | [diff] [blame] | 2600 | | SHOST_DIX_TYPE2_PROTECTION |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 2601 | | SHOST_DIX_TYPE3_PROTECTION); |
Arun Easi | 9e522cd | 2012-08-22 14:21:31 -0400 | [diff] [blame] | 2602 | |
| 2603 | guard = SHOST_DIX_GUARD_CRC; |
| 2604 | |
| 2605 | if (IS_PI_IPGUARD_CAPABLE(ha) && |
| 2606 | (ql2xenabledif > 1 || IS_PI_DIFB_DIX0_CAPABLE(ha))) |
| 2607 | guard |= SHOST_DIX_GUARD_IP; |
| 2608 | |
| 2609 | scsi_host_set_guard(host, guard); |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 2610 | } else |
| 2611 | base_vha->flags.difdix_supported = 0; |
| 2612 | } |
| 2613 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2614 | ha->isp_ops->enable_intrs(ha); |
| 2615 | |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2616 | ret = scsi_add_host(host, &pdev->dev); |
| 2617 | if (ret) |
| 2618 | goto probe_failed; |
| 2619 | |
Michael Reed | 1486400 | 2009-12-02 09:11:16 -0600 | [diff] [blame] | 2620 | base_vha->flags.init_done = 1; |
| 2621 | base_vha->flags.online = 1; |
| 2622 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2623 | ql_dbg(ql_dbg_init, base_vha, 0x00f2, |
| 2624 | "Init done and hba is online.\n"); |
| 2625 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2626 | if (qla_ini_mode_enabled(base_vha)) |
| 2627 | scsi_scan_host(host); |
| 2628 | else |
| 2629 | ql_dbg(ql_dbg_init, base_vha, 0x0122, |
| 2630 | "skipping scsi_scan_host() for non-initiator port\n"); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2631 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2632 | qla2x00_alloc_sysfs_attr(base_vha); |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2633 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2634 | qla2x00_init_host_attr(base_vha); |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2635 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2636 | qla2x00_dfs_setup(base_vha); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 2637 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2638 | ql_log(ql_log_info, base_vha, 0x00fb, |
| 2639 | "QLogic %s - %s.\n", |
| 2640 | ha->model_number, ha->model_desc ? ha->model_desc : ""); |
| 2641 | ql_log(ql_log_info, base_vha, 0x00fc, |
| 2642 | "ISP%04X: %s @ %s hdma%c host#=%ld fw=%s.\n", |
| 2643 | pdev->device, ha->isp_ops->pci_info_str(base_vha, pci_info), |
| 2644 | pci_name(pdev), ha->flags.enable_64bit_addressing ? '+' : '-', |
| 2645 | base_vha->host_no, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2646 | ha->isp_ops->fw_version_str(base_vha, fw_str)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2647 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2648 | qlt_add_target(ha, base_vha); |
| 2649 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2650 | return 0; |
| 2651 | |
Anirban Chakraborty | 6e9f21f | 2009-01-22 09:45:28 -0800 | [diff] [blame] | 2652 | probe_init_failed: |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2653 | qla2x00_free_req_que(ha, req); |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 2654 | ha->req_q_map[0] = NULL; |
| 2655 | clear_bit(0, ha->req_qid_map); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2656 | qla2x00_free_rsp_que(ha, rsp); |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 2657 | ha->rsp_q_map[0] = NULL; |
| 2658 | clear_bit(0, ha->rsp_qid_map); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2659 | ha->max_req_queues = ha->max_rsp_queues = 0; |
Anirban Chakraborty | 6e9f21f | 2009-01-22 09:45:28 -0800 | [diff] [blame] | 2660 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2661 | probe_failed: |
Andrew Vasquez | b997876 | 2009-03-24 09:08:05 -0700 | [diff] [blame] | 2662 | if (base_vha->timer_active) |
| 2663 | qla2x00_stop_timer(base_vha); |
| 2664 | base_vha->flags.online = 0; |
| 2665 | if (ha->dpc_thread) { |
| 2666 | struct task_struct *t = ha->dpc_thread; |
| 2667 | |
| 2668 | ha->dpc_thread = NULL; |
| 2669 | kthread_stop(t); |
| 2670 | } |
| 2671 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2672 | qla2x00_free_device(base_vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2673 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2674 | scsi_host_put(base_vha->host); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2675 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2676 | probe_hw_failed: |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2677 | if (IS_QLA82XX(ha)) { |
| 2678 | qla82xx_idc_lock(ha); |
| 2679 | qla82xx_clear_drv_active(ha); |
| 2680 | qla82xx_idc_unlock(ha); |
Saurav Kashyap | 0a63ad1 | 2012-11-21 02:40:43 -0500 | [diff] [blame^] | 2681 | } |
| 2682 | iospace_config_failed: |
| 2683 | if (IS_QLA82XX(ha)) { |
| 2684 | if (!ha->nx_pcibase) |
| 2685 | iounmap((device_reg_t __iomem *)ha->nx_pcibase); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2686 | if (!ql2xdbwr) |
| 2687 | iounmap((device_reg_t __iomem *)ha->nxdb_wr_ptr); |
| 2688 | } else { |
| 2689 | if (ha->iobase) |
| 2690 | iounmap(ha->iobase); |
| 2691 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2692 | pci_release_selected_regions(ha->pdev, ha->bars); |
| 2693 | kfree(ha); |
| 2694 | ha = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2695 | |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2696 | probe_out: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2697 | pci_disable_device(pdev); |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2698 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2699 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2700 | |
Adrian Bunk | 4c993f7 | 2008-01-14 00:55:16 -0800 | [diff] [blame] | 2701 | static void |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2702 | qla2x00_stop_dpc_thread(scsi_qla_host_t *vha) |
| 2703 | { |
| 2704 | struct qla_hw_data *ha = vha->hw; |
| 2705 | struct task_struct *t = ha->dpc_thread; |
| 2706 | |
| 2707 | if (ha->dpc_thread == NULL) |
| 2708 | return; |
| 2709 | /* |
| 2710 | * qla2xxx_wake_dpc checks for ->dpc_thread |
| 2711 | * so we need to zero it out. |
| 2712 | */ |
| 2713 | ha->dpc_thread = NULL; |
| 2714 | kthread_stop(t); |
| 2715 | } |
| 2716 | |
| 2717 | static void |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 2718 | qla2x00_shutdown(struct pci_dev *pdev) |
| 2719 | { |
| 2720 | scsi_qla_host_t *vha; |
| 2721 | struct qla_hw_data *ha; |
| 2722 | |
| 2723 | vha = pci_get_drvdata(pdev); |
| 2724 | ha = vha->hw; |
| 2725 | |
| 2726 | /* Turn-off FCE trace */ |
| 2727 | if (ha->flags.fce_enabled) { |
| 2728 | qla2x00_disable_fce_trace(vha, NULL, NULL); |
| 2729 | ha->flags.fce_enabled = 0; |
| 2730 | } |
| 2731 | |
| 2732 | /* Turn-off EFT trace */ |
| 2733 | if (ha->eft) |
| 2734 | qla2x00_disable_eft_trace(vha); |
| 2735 | |
| 2736 | /* Stop currently executing firmware. */ |
| 2737 | qla2x00_try_to_stop_firmware(vha); |
| 2738 | |
| 2739 | /* Turn adapter off line */ |
| 2740 | vha->flags.online = 0; |
| 2741 | |
| 2742 | /* turn-off interrupts on the card */ |
| 2743 | if (ha->interrupts_on) { |
| 2744 | vha->flags.init_done = 0; |
| 2745 | ha->isp_ops->disable_intrs(ha); |
| 2746 | } |
| 2747 | |
| 2748 | qla2x00_free_irqs(vha); |
| 2749 | |
| 2750 | qla2x00_free_fw_dump(ha); |
| 2751 | } |
| 2752 | |
| 2753 | static void |
Andrew Vasquez | 7ee6139 | 2006-06-23 16:11:22 -0700 | [diff] [blame] | 2754 | qla2x00_remove_one(struct pci_dev *pdev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2755 | { |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 2756 | scsi_qla_host_t *base_vha, *vha; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2757 | struct qla_hw_data *ha; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 2758 | unsigned long flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2759 | |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 2760 | /* |
| 2761 | * If the PCI device is disabled that means that probe failed and any |
| 2762 | * resources should be have cleaned up on probe exit. |
| 2763 | */ |
| 2764 | if (!atomic_read(&pdev->enable_cnt)) |
| 2765 | return; |
| 2766 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2767 | base_vha = pci_get_drvdata(pdev); |
| 2768 | ha = base_vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2769 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2770 | ha->flags.host_shutting_down = 1; |
| 2771 | |
Giridhar Malavali | 220d36b | 2012-11-21 02:39:55 -0500 | [diff] [blame] | 2772 | set_bit(UNLOADING, &base_vha->dpc_flags); |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 2773 | mutex_lock(&ha->vport_lock); |
| 2774 | while (ha->cur_vport_count) { |
| 2775 | struct Scsi_Host *scsi_host; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 2776 | |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 2777 | spin_lock_irqsave(&ha->vport_slock, flags); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 2778 | |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 2779 | BUG_ON(base_vha->list.next == &ha->vp_list); |
| 2780 | /* This assumes first entry in ha->vp_list is always base vha */ |
| 2781 | vha = list_first_entry(&base_vha->list, scsi_qla_host_t, list); |
| 2782 | scsi_host = scsi_host_get(vha->host); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 2783 | |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 2784 | spin_unlock_irqrestore(&ha->vport_slock, flags); |
| 2785 | mutex_unlock(&ha->vport_lock); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 2786 | |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 2787 | fc_vport_terminate(vha->fc_vport); |
| 2788 | scsi_host_put(vha->host); |
| 2789 | |
| 2790 | mutex_lock(&ha->vport_lock); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2791 | } |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 2792 | mutex_unlock(&ha->vport_lock); |
Andrew Vasquez | c795c1e | 2008-08-13 21:37:01 -0700 | [diff] [blame] | 2793 | |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 2794 | if (IS_QLA8031(ha)) { |
| 2795 | ql_dbg(ql_dbg_p3p, base_vha, 0xb07e, |
| 2796 | "Clearing fcoe driver presence.\n"); |
| 2797 | if (qla83xx_clear_drv_presence(base_vha) != QLA_SUCCESS) |
| 2798 | ql_dbg(ql_dbg_p3p, base_vha, 0xb079, |
| 2799 | "Error while clearing DRV-Presence.\n"); |
| 2800 | } |
| 2801 | |
Andrew Vasquez | b997876 | 2009-03-24 09:08:05 -0700 | [diff] [blame] | 2802 | qla2x00_abort_all_cmds(base_vha, DID_NO_CONNECT << 16); |
| 2803 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2804 | qla2x00_dfs_remove(base_vha); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 2805 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2806 | qla84xx_put_chip(base_vha); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 2807 | |
Andrew Vasquez | b997876 | 2009-03-24 09:08:05 -0700 | [diff] [blame] | 2808 | /* Disable timer */ |
| 2809 | if (base_vha->timer_active) |
| 2810 | qla2x00_stop_timer(base_vha); |
| 2811 | |
| 2812 | base_vha->flags.online = 0; |
| 2813 | |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 2814 | /* Flush the work queue and remove it */ |
| 2815 | if (ha->wq) { |
| 2816 | flush_workqueue(ha->wq); |
| 2817 | destroy_workqueue(ha->wq); |
| 2818 | ha->wq = NULL; |
| 2819 | } |
| 2820 | |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 2821 | /* Cancel all work and destroy DPC workqueues */ |
| 2822 | if (ha->dpc_lp_wq) { |
| 2823 | cancel_work_sync(&ha->idc_aen); |
| 2824 | destroy_workqueue(ha->dpc_lp_wq); |
| 2825 | ha->dpc_lp_wq = NULL; |
| 2826 | } |
| 2827 | |
| 2828 | if (ha->dpc_hp_wq) { |
| 2829 | cancel_work_sync(&ha->nic_core_reset); |
| 2830 | cancel_work_sync(&ha->idc_state_handler); |
| 2831 | cancel_work_sync(&ha->nic_core_unrecoverable); |
| 2832 | destroy_workqueue(ha->dpc_hp_wq); |
| 2833 | ha->dpc_hp_wq = NULL; |
| 2834 | } |
| 2835 | |
Andrew Vasquez | b997876 | 2009-03-24 09:08:05 -0700 | [diff] [blame] | 2836 | /* Kill the kernel thread for this host */ |
| 2837 | if (ha->dpc_thread) { |
| 2838 | struct task_struct *t = ha->dpc_thread; |
| 2839 | |
| 2840 | /* |
| 2841 | * qla2xxx_wake_dpc checks for ->dpc_thread |
| 2842 | * so we need to zero it out. |
| 2843 | */ |
| 2844 | ha->dpc_thread = NULL; |
| 2845 | kthread_stop(t); |
| 2846 | } |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2847 | qlt_remove_target(ha, base_vha); |
Andrew Vasquez | b997876 | 2009-03-24 09:08:05 -0700 | [diff] [blame] | 2848 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2849 | qla2x00_free_sysfs_attr(base_vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2850 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2851 | fc_remove_host(base_vha->host); |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 2852 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2853 | scsi_remove_host(base_vha->host); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2854 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2855 | qla2x00_free_device(base_vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2856 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2857 | scsi_host_put(base_vha->host); |
| 2858 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2859 | if (IS_QLA82XX(ha)) { |
Giridhar Malavali | b963752 | 2010-05-28 15:08:15 -0700 | [diff] [blame] | 2860 | qla82xx_idc_lock(ha); |
| 2861 | qla82xx_clear_drv_active(ha); |
| 2862 | qla82xx_idc_unlock(ha); |
| 2863 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2864 | iounmap((device_reg_t __iomem *)ha->nx_pcibase); |
| 2865 | if (!ql2xdbwr) |
| 2866 | iounmap((device_reg_t __iomem *)ha->nxdb_wr_ptr); |
| 2867 | } else { |
| 2868 | if (ha->iobase) |
| 2869 | iounmap(ha->iobase); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2870 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2871 | if (ha->mqiobase) |
| 2872 | iounmap(ha->mqiobase); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2873 | |
| 2874 | if (IS_QLA83XX(ha) && ha->msixbase) |
| 2875 | iounmap(ha->msixbase); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2876 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2877 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2878 | pci_release_selected_regions(ha->pdev, ha->bars); |
| 2879 | kfree(ha); |
| 2880 | ha = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2881 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 2882 | pci_disable_pcie_error_reporting(pdev); |
| 2883 | |
Bernhard Walle | 665db93 | 2007-03-28 00:49:49 +0200 | [diff] [blame] | 2884 | pci_disable_device(pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2885 | pci_set_drvdata(pdev, NULL); |
| 2886 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2887 | |
| 2888 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2889 | qla2x00_free_device(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2890 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2891 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2892 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 2893 | qla2x00_abort_all_cmds(vha, DID_NO_CONNECT << 16); |
| 2894 | |
| 2895 | /* Disable timer */ |
| 2896 | if (vha->timer_active) |
| 2897 | qla2x00_stop_timer(vha); |
| 2898 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2899 | qla2x00_stop_dpc_thread(vha); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 2900 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2901 | qla25xx_delete_queues(vha); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 2902 | if (ha->flags.fce_enabled) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2903 | qla2x00_disable_fce_trace(vha, NULL, NULL); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 2904 | |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 2905 | if (ha->eft) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2906 | qla2x00_disable_eft_trace(vha); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 2907 | |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 2908 | /* Stop currently executing firmware. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2909 | qla2x00_try_to_stop_firmware(vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2910 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 2911 | vha->flags.online = 0; |
| 2912 | |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 2913 | /* turn-off interrupts on the card */ |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2914 | if (ha->interrupts_on) { |
| 2915 | vha->flags.init_done = 0; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2916 | ha->isp_ops->disable_intrs(ha); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2917 | } |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 2918 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2919 | qla2x00_free_irqs(vha); |
| 2920 | |
Chad Dupuis | 8867048 | 2010-07-23 15:28:30 +0500 | [diff] [blame] | 2921 | qla2x00_free_fcports(vha); |
| 2922 | |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 2923 | qla2x00_mem_free(ha); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2924 | |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 2925 | qla82xx_md_free(vha); |
| 2926 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2927 | qla2x00_free_queues(ha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2928 | } |
| 2929 | |
Chad Dupuis | 8867048 | 2010-07-23 15:28:30 +0500 | [diff] [blame] | 2930 | void qla2x00_free_fcports(struct scsi_qla_host *vha) |
| 2931 | { |
| 2932 | fc_port_t *fcport, *tfcport; |
| 2933 | |
| 2934 | list_for_each_entry_safe(fcport, tfcport, &vha->vp_fcports, list) { |
| 2935 | list_del(&fcport->list); |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 2936 | qla2x00_clear_loop_id(fcport); |
Chad Dupuis | 8867048 | 2010-07-23 15:28:30 +0500 | [diff] [blame] | 2937 | kfree(fcport); |
| 2938 | fcport = NULL; |
| 2939 | } |
| 2940 | } |
| 2941 | |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 2942 | static inline void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2943 | 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] | 2944 | int defer) |
| 2945 | { |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 2946 | struct fc_rport *rport; |
Andrew Vasquez | 67becc0 | 2009-08-25 11:36:20 -0700 | [diff] [blame] | 2947 | scsi_qla_host_t *base_vha; |
Madhuranath Iyengar | 044d78e | 2011-01-28 15:17:56 -0800 | [diff] [blame] | 2948 | unsigned long flags; |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 2949 | |
| 2950 | if (!fcport->rport) |
| 2951 | return; |
| 2952 | |
| 2953 | rport = fcport->rport; |
| 2954 | if (defer) { |
Andrew Vasquez | 67becc0 | 2009-08-25 11:36:20 -0700 | [diff] [blame] | 2955 | base_vha = pci_get_drvdata(vha->hw->pdev); |
Madhuranath Iyengar | 044d78e | 2011-01-28 15:17:56 -0800 | [diff] [blame] | 2956 | spin_lock_irqsave(vha->host->host_lock, flags); |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 2957 | fcport->drport = rport; |
Madhuranath Iyengar | 044d78e | 2011-01-28 15:17:56 -0800 | [diff] [blame] | 2958 | spin_unlock_irqrestore(vha->host->host_lock, flags); |
Andrew Vasquez | 67becc0 | 2009-08-25 11:36:20 -0700 | [diff] [blame] | 2959 | set_bit(FCPORT_UPDATE_NEEDED, &base_vha->dpc_flags); |
| 2960 | qla2xxx_wake_dpc(base_vha); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2961 | } else { |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 2962 | fc_remote_port_delete(rport); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2963 | qlt_fc_port_deleted(vha, fcport); |
| 2964 | } |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 2965 | } |
| 2966 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2967 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2968 | * qla2x00_mark_device_lost Updates fcport state when device goes offline. |
| 2969 | * |
| 2970 | * Input: ha = adapter block pointer. fcport = port structure pointer. |
| 2971 | * |
| 2972 | * Return: None. |
| 2973 | * |
| 2974 | * Context: |
| 2975 | */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2976 | 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] | 2977 | int do_login, int defer) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2978 | { |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2979 | if (atomic_read(&fcport->state) == FCS_ONLINE && |
Joe Carnuccio | c6d39e2 | 2012-05-15 14:34:20 -0400 | [diff] [blame] | 2980 | vha->vp_idx == fcport->vha->vp_idx) { |
Chad Dupuis | ec426e1 | 2011-03-30 11:46:32 -0700 | [diff] [blame] | 2981 | qla2x00_set_fcport_state(fcport, FCS_DEVICE_LOST); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2982 | qla2x00_schedule_rport_del(vha, fcport, defer); |
| 2983 | } |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 2984 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2985 | * We may need to retry the login, so don't change the state of the |
| 2986 | * port but do the retries. |
| 2987 | */ |
| 2988 | if (atomic_read(&fcport->state) != FCS_DEVICE_DEAD) |
Chad Dupuis | ec426e1 | 2011-03-30 11:46:32 -0700 | [diff] [blame] | 2989 | qla2x00_set_fcport_state(fcport, FCS_DEVICE_LOST); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2990 | |
| 2991 | if (!do_login) |
| 2992 | return; |
| 2993 | |
| 2994 | if (fcport->login_retry == 0) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2995 | fcport->login_retry = vha->hw->login_retry_count; |
| 2996 | set_bit(RELOGIN_NEEDED, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2997 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2998 | ql_dbg(ql_dbg_disc, vha, 0x2067, |
| 2999 | "Port login retry " |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3000 | "%02x%02x%02x%02x%02x%02x%02x%02x, " |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3001 | "id = 0x%04x retry cnt=%d.\n", |
| 3002 | fcport->port_name[0], fcport->port_name[1], |
| 3003 | fcport->port_name[2], fcport->port_name[3], |
| 3004 | fcport->port_name[4], fcport->port_name[5], |
| 3005 | fcport->port_name[6], fcport->port_name[7], |
| 3006 | fcport->loop_id, fcport->login_retry); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3007 | } |
| 3008 | } |
| 3009 | |
| 3010 | /* |
| 3011 | * qla2x00_mark_all_devices_lost |
| 3012 | * Updates fcport state when device goes offline. |
| 3013 | * |
| 3014 | * Input: |
| 3015 | * ha = adapter block pointer. |
| 3016 | * fcport = port structure pointer. |
| 3017 | * |
| 3018 | * Return: |
| 3019 | * None. |
| 3020 | * |
| 3021 | * Context: |
| 3022 | */ |
| 3023 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3024 | qla2x00_mark_all_devices_lost(scsi_qla_host_t *vha, int defer) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3025 | { |
| 3026 | fc_port_t *fcport; |
| 3027 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3028 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
Joe Carnuccio | c6d39e2 | 2012-05-15 14:34:20 -0400 | [diff] [blame] | 3029 | if (vha->vp_idx != 0 && vha->vp_idx != fcport->vha->vp_idx) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3030 | continue; |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 3031 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3032 | /* |
| 3033 | * No point in marking the device as lost, if the device is |
| 3034 | * already DEAD. |
| 3035 | */ |
| 3036 | if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD) |
| 3037 | continue; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3038 | if (atomic_read(&fcport->state) == FCS_ONLINE) { |
Chad Dupuis | ec426e1 | 2011-03-30 11:46:32 -0700 | [diff] [blame] | 3039 | qla2x00_set_fcport_state(fcport, FCS_DEVICE_LOST); |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 3040 | if (defer) |
| 3041 | qla2x00_schedule_rport_del(vha, fcport, defer); |
Joe Carnuccio | c6d39e2 | 2012-05-15 14:34:20 -0400 | [diff] [blame] | 3042 | else if (vha->vp_idx == fcport->vha->vp_idx) |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 3043 | qla2x00_schedule_rport_del(vha, fcport, defer); |
| 3044 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3045 | } |
| 3046 | } |
| 3047 | |
| 3048 | /* |
| 3049 | * qla2x00_mem_alloc |
| 3050 | * Allocates adapter memory. |
| 3051 | * |
| 3052 | * Returns: |
| 3053 | * 0 = success. |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3054 | * !0 = failure. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3055 | */ |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3056 | static int |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3057 | qla2x00_mem_alloc(struct qla_hw_data *ha, uint16_t req_len, uint16_t rsp_len, |
| 3058 | struct req_que **req, struct rsp_que **rsp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3059 | { |
| 3060 | char name[16]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3061 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3062 | 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] | 3063 | &ha->init_cb_dma, GFP_KERNEL); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3064 | if (!ha->init_cb) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3065 | goto fail; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3066 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3067 | if (qlt_mem_alloc(ha) < 0) |
| 3068 | goto fail_free_init_cb; |
| 3069 | |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 3070 | ha->gid_list = dma_alloc_coherent(&ha->pdev->dev, |
| 3071 | qla2x00_gid_list_size(ha), &ha->gid_list_dma, GFP_KERNEL); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3072 | if (!ha->gid_list) |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3073 | goto fail_free_tgt_mem; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3074 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3075 | ha->srb_mempool = mempool_create_slab_pool(SRB_MIN_REQ, srb_cachep); |
| 3076 | if (!ha->srb_mempool) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3077 | goto fail_free_gid_list; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3078 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3079 | if (IS_QLA82XX(ha)) { |
| 3080 | /* Allocate cache for CT6 Ctx. */ |
| 3081 | if (!ctx_cachep) { |
| 3082 | ctx_cachep = kmem_cache_create("qla2xxx_ctx", |
| 3083 | sizeof(struct ct6_dsd), 0, |
| 3084 | SLAB_HWCACHE_ALIGN, NULL); |
| 3085 | if (!ctx_cachep) |
| 3086 | goto fail_free_gid_list; |
| 3087 | } |
| 3088 | ha->ctx_mempool = mempool_create_slab_pool(SRB_MIN_REQ, |
| 3089 | ctx_cachep); |
| 3090 | if (!ha->ctx_mempool) |
| 3091 | goto fail_free_srb_mempool; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3092 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0021, |
| 3093 | "ctx_cachep=%p ctx_mempool=%p.\n", |
| 3094 | ctx_cachep, ha->ctx_mempool); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3095 | } |
| 3096 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3097 | /* Get memory for cached NVRAM */ |
| 3098 | ha->nvram = kzalloc(MAX_NVRAM_SIZE, GFP_KERNEL); |
| 3099 | if (!ha->nvram) |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3100 | goto fail_free_ctx_mempool; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3101 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3102 | snprintf(name, sizeof(name), "%s_%d", QLA2XXX_DRIVER_NAME, |
| 3103 | ha->pdev->device); |
| 3104 | ha->s_dma_pool = dma_pool_create(name, &ha->pdev->dev, |
| 3105 | DMA_POOL_SIZE, 8, 0); |
| 3106 | if (!ha->s_dma_pool) |
| 3107 | goto fail_free_nvram; |
| 3108 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3109 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0022, |
| 3110 | "init_cb=%p gid_list=%p, srb_mempool=%p s_dma_pool=%p.\n", |
| 3111 | ha->init_cb, ha->gid_list, ha->srb_mempool, ha->s_dma_pool); |
| 3112 | |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 3113 | if (IS_QLA82XX(ha) || ql2xenabledif) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3114 | ha->dl_dma_pool = dma_pool_create(name, &ha->pdev->dev, |
| 3115 | DSD_LIST_DMA_POOL_SIZE, 8, 0); |
| 3116 | if (!ha->dl_dma_pool) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3117 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0023, |
| 3118 | "Failed to allocate memory for dl_dma_pool.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3119 | goto fail_s_dma_pool; |
| 3120 | } |
| 3121 | |
| 3122 | ha->fcp_cmnd_dma_pool = dma_pool_create(name, &ha->pdev->dev, |
| 3123 | FCP_CMND_DMA_POOL_SIZE, 8, 0); |
| 3124 | if (!ha->fcp_cmnd_dma_pool) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3125 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0024, |
| 3126 | "Failed to allocate memory for fcp_cmnd_dma_pool.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3127 | goto fail_dl_dma_pool; |
| 3128 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3129 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0025, |
| 3130 | "dl_dma_pool=%p fcp_cmnd_dma_pool=%p.\n", |
| 3131 | ha->dl_dma_pool, ha->fcp_cmnd_dma_pool); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3132 | } |
| 3133 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3134 | /* Allocate memory for SNS commands */ |
| 3135 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3136 | /* Get consistent memory allocated for SNS commands */ |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3137 | ha->sns_cmd = dma_alloc_coherent(&ha->pdev->dev, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3138 | sizeof(struct sns_cmd_pkt), &ha->sns_cmd_dma, GFP_KERNEL); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3139 | if (!ha->sns_cmd) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3140 | goto fail_dma_pool; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3141 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0026, |
Joe Perches | d8424f6 | 2011-11-18 09:03:06 -0800 | [diff] [blame] | 3142 | "sns_cmd: %p.\n", ha->sns_cmd); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3143 | } else { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3144 | /* Get consistent memory allocated for MS IOCB */ |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3145 | ha->ms_iocb = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3146 | &ha->ms_iocb_dma); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3147 | if (!ha->ms_iocb) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3148 | goto fail_dma_pool; |
| 3149 | /* Get consistent memory allocated for CT SNS commands */ |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3150 | ha->ct_sns = dma_alloc_coherent(&ha->pdev->dev, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3151 | sizeof(struct ct_sns_pkt), &ha->ct_sns_dma, GFP_KERNEL); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3152 | if (!ha->ct_sns) |
| 3153 | goto fail_free_ms_iocb; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3154 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0027, |
| 3155 | "ms_iocb=%p ct_sns=%p.\n", |
| 3156 | ha->ms_iocb, ha->ct_sns); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3157 | } |
| 3158 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3159 | /* Allocate memory for request ring */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3160 | *req = kzalloc(sizeof(struct req_que), GFP_KERNEL); |
| 3161 | if (!*req) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3162 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0028, |
| 3163 | "Failed to allocate memory for req.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3164 | goto fail_req; |
| 3165 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3166 | (*req)->length = req_len; |
| 3167 | (*req)->ring = dma_alloc_coherent(&ha->pdev->dev, |
| 3168 | ((*req)->length + 1) * sizeof(request_t), |
| 3169 | &(*req)->dma, GFP_KERNEL); |
| 3170 | if (!(*req)->ring) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3171 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0029, |
| 3172 | "Failed to allocate memory for req_ring.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3173 | goto fail_req_ring; |
| 3174 | } |
| 3175 | /* Allocate memory for response ring */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3176 | *rsp = kzalloc(sizeof(struct rsp_que), GFP_KERNEL); |
| 3177 | if (!*rsp) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3178 | ql_log_pci(ql_log_fatal, ha->pdev, 0x002a, |
| 3179 | "Failed to allocate memory for rsp.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3180 | goto fail_rsp; |
| 3181 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3182 | (*rsp)->hw = ha; |
| 3183 | (*rsp)->length = rsp_len; |
| 3184 | (*rsp)->ring = dma_alloc_coherent(&ha->pdev->dev, |
| 3185 | ((*rsp)->length + 1) * sizeof(response_t), |
| 3186 | &(*rsp)->dma, GFP_KERNEL); |
| 3187 | if (!(*rsp)->ring) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3188 | ql_log_pci(ql_log_fatal, ha->pdev, 0x002b, |
| 3189 | "Failed to allocate memory for rsp_ring.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3190 | goto fail_rsp_ring; |
| 3191 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3192 | (*req)->rsp = *rsp; |
| 3193 | (*rsp)->req = *req; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3194 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x002c, |
| 3195 | "req=%p req->length=%d req->ring=%p rsp=%p " |
| 3196 | "rsp->length=%d rsp->ring=%p.\n", |
| 3197 | *req, (*req)->length, (*req)->ring, *rsp, (*rsp)->length, |
| 3198 | (*rsp)->ring); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3199 | /* Allocate memory for NVRAM data for vports */ |
| 3200 | if (ha->nvram_npiv_size) { |
| 3201 | ha->npiv_info = kzalloc(sizeof(struct qla_npiv_entry) * |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3202 | ha->nvram_npiv_size, GFP_KERNEL); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3203 | if (!ha->npiv_info) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3204 | ql_log_pci(ql_log_fatal, ha->pdev, 0x002d, |
| 3205 | "Failed to allocate memory for npiv_info.\n"); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3206 | goto fail_npiv_info; |
| 3207 | } |
| 3208 | } else |
| 3209 | ha->npiv_info = NULL; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3210 | |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 3211 | /* Get consistent memory allocated for EX-INIT-CB. */ |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3212 | if (IS_CNA_CAPABLE(ha) || IS_QLA2031(ha)) { |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 3213 | ha->ex_init_cb = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, |
| 3214 | &ha->ex_init_cb_dma); |
| 3215 | if (!ha->ex_init_cb) |
| 3216 | goto fail_ex_init_cb; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3217 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x002e, |
| 3218 | "ex_init_cb=%p.\n", ha->ex_init_cb); |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 3219 | } |
| 3220 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3221 | INIT_LIST_HEAD(&ha->gbl_dsd_list); |
| 3222 | |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 3223 | /* Get consistent memory allocated for Async Port-Database. */ |
| 3224 | if (!IS_FWI2_CAPABLE(ha)) { |
| 3225 | ha->async_pd = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, |
| 3226 | &ha->async_pd_dma); |
| 3227 | if (!ha->async_pd) |
| 3228 | goto fail_async_pd; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3229 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x002f, |
| 3230 | "async_pd=%p.\n", ha->async_pd); |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 3231 | } |
| 3232 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3233 | INIT_LIST_HEAD(&ha->vp_list); |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 3234 | |
| 3235 | /* Allocate memory for our loop_id bitmap */ |
| 3236 | ha->loop_id_map = kzalloc(BITS_TO_LONGS(LOOPID_MAP_SIZE) * sizeof(long), |
| 3237 | GFP_KERNEL); |
| 3238 | if (!ha->loop_id_map) |
| 3239 | goto fail_async_pd; |
| 3240 | else { |
| 3241 | qla2x00_set_reserved_loop_ids(ha); |
| 3242 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0123, |
| 3243 | "loop_id_map=%p. \n", ha->loop_id_map); |
| 3244 | } |
| 3245 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3246 | return 1; |
| 3247 | |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 3248 | fail_async_pd: |
| 3249 | 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] | 3250 | fail_ex_init_cb: |
| 3251 | kfree(ha->npiv_info); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3252 | fail_npiv_info: |
| 3253 | dma_free_coherent(&ha->pdev->dev, ((*rsp)->length + 1) * |
| 3254 | sizeof(response_t), (*rsp)->ring, (*rsp)->dma); |
| 3255 | (*rsp)->ring = NULL; |
| 3256 | (*rsp)->dma = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3257 | fail_rsp_ring: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3258 | kfree(*rsp); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3259 | fail_rsp: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3260 | dma_free_coherent(&ha->pdev->dev, ((*req)->length + 1) * |
| 3261 | sizeof(request_t), (*req)->ring, (*req)->dma); |
| 3262 | (*req)->ring = NULL; |
| 3263 | (*req)->dma = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3264 | fail_req_ring: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3265 | kfree(*req); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3266 | fail_req: |
| 3267 | dma_free_coherent(&ha->pdev->dev, sizeof(struct ct_sns_pkt), |
| 3268 | ha->ct_sns, ha->ct_sns_dma); |
| 3269 | ha->ct_sns = NULL; |
| 3270 | ha->ct_sns_dma = 0; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3271 | fail_free_ms_iocb: |
| 3272 | dma_pool_free(ha->s_dma_pool, ha->ms_iocb, ha->ms_iocb_dma); |
| 3273 | ha->ms_iocb = NULL; |
| 3274 | ha->ms_iocb_dma = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3275 | fail_dma_pool: |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 3276 | if (IS_QLA82XX(ha) || ql2xenabledif) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3277 | dma_pool_destroy(ha->fcp_cmnd_dma_pool); |
| 3278 | ha->fcp_cmnd_dma_pool = NULL; |
| 3279 | } |
| 3280 | fail_dl_dma_pool: |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 3281 | if (IS_QLA82XX(ha) || ql2xenabledif) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3282 | dma_pool_destroy(ha->dl_dma_pool); |
| 3283 | ha->dl_dma_pool = NULL; |
| 3284 | } |
| 3285 | fail_s_dma_pool: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3286 | dma_pool_destroy(ha->s_dma_pool); |
| 3287 | ha->s_dma_pool = NULL; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3288 | fail_free_nvram: |
| 3289 | kfree(ha->nvram); |
| 3290 | ha->nvram = NULL; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3291 | fail_free_ctx_mempool: |
| 3292 | mempool_destroy(ha->ctx_mempool); |
| 3293 | ha->ctx_mempool = NULL; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3294 | fail_free_srb_mempool: |
| 3295 | mempool_destroy(ha->srb_mempool); |
| 3296 | ha->srb_mempool = NULL; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3297 | fail_free_gid_list: |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 3298 | dma_free_coherent(&ha->pdev->dev, qla2x00_gid_list_size(ha), |
| 3299 | ha->gid_list, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3300 | ha->gid_list_dma); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3301 | ha->gid_list = NULL; |
| 3302 | ha->gid_list_dma = 0; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3303 | fail_free_tgt_mem: |
| 3304 | qlt_mem_free(ha); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3305 | fail_free_init_cb: |
| 3306 | dma_free_coherent(&ha->pdev->dev, ha->init_cb_size, ha->init_cb, |
| 3307 | ha->init_cb_dma); |
| 3308 | ha->init_cb = NULL; |
| 3309 | ha->init_cb_dma = 0; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3310 | fail: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3311 | ql_log(ql_log_fatal, NULL, 0x0030, |
| 3312 | "Memory allocation failure.\n"); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3313 | return -ENOMEM; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3314 | } |
| 3315 | |
| 3316 | /* |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3317 | * qla2x00_free_fw_dump |
| 3318 | * Frees fw dump stuff. |
| 3319 | * |
| 3320 | * Input: |
| 3321 | * ha = adapter block pointer. |
| 3322 | */ |
| 3323 | static void |
| 3324 | qla2x00_free_fw_dump(struct qla_hw_data *ha) |
| 3325 | { |
| 3326 | if (ha->fce) |
| 3327 | dma_free_coherent(&ha->pdev->dev, FCE_SIZE, ha->fce, |
| 3328 | ha->fce_dma); |
| 3329 | |
| 3330 | if (ha->fw_dump) { |
| 3331 | if (ha->eft) |
| 3332 | dma_free_coherent(&ha->pdev->dev, |
| 3333 | ntohl(ha->fw_dump->eft_size), ha->eft, ha->eft_dma); |
| 3334 | vfree(ha->fw_dump); |
| 3335 | } |
| 3336 | ha->fce = NULL; |
| 3337 | ha->fce_dma = 0; |
| 3338 | ha->eft = NULL; |
| 3339 | ha->eft_dma = 0; |
| 3340 | ha->fw_dump = NULL; |
| 3341 | ha->fw_dumped = 0; |
| 3342 | ha->fw_dump_reading = 0; |
| 3343 | } |
| 3344 | |
| 3345 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3346 | * qla2x00_mem_free |
| 3347 | * Frees all adapter allocated memory. |
| 3348 | * |
| 3349 | * Input: |
| 3350 | * ha = adapter block pointer. |
| 3351 | */ |
Adrian Bunk | a824ebb | 2008-01-17 09:02:15 -0800 | [diff] [blame] | 3352 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3353 | qla2x00_mem_free(struct qla_hw_data *ha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3354 | { |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3355 | qla2x00_free_fw_dump(ha); |
| 3356 | |
Saurav Kashyap | 8117877 | 2012-08-22 14:21:04 -0400 | [diff] [blame] | 3357 | if (ha->mctp_dump) |
| 3358 | dma_free_coherent(&ha->pdev->dev, MCTP_DUMP_SIZE, ha->mctp_dump, |
| 3359 | ha->mctp_dump_dma); |
| 3360 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3361 | if (ha->srb_mempool) |
| 3362 | mempool_destroy(ha->srb_mempool); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3363 | |
Andrew Vasquez | 11bbc1d | 2009-06-03 09:55:14 -0700 | [diff] [blame] | 3364 | if (ha->dcbx_tlv) |
| 3365 | dma_free_coherent(&ha->pdev->dev, DCBX_TLV_DATA_SIZE, |
| 3366 | ha->dcbx_tlv, ha->dcbx_tlv_dma); |
| 3367 | |
Andrew Vasquez | ce0423f | 2009-06-03 09:55:13 -0700 | [diff] [blame] | 3368 | if (ha->xgmac_data) |
| 3369 | dma_free_coherent(&ha->pdev->dev, XGMAC_DATA_SIZE, |
| 3370 | ha->xgmac_data, ha->xgmac_data_dma); |
| 3371 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3372 | if (ha->sns_cmd) |
| 3373 | dma_free_coherent(&ha->pdev->dev, sizeof(struct sns_cmd_pkt), |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3374 | ha->sns_cmd, ha->sns_cmd_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3375 | |
| 3376 | if (ha->ct_sns) |
| 3377 | dma_free_coherent(&ha->pdev->dev, sizeof(struct ct_sns_pkt), |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3378 | ha->ct_sns, ha->ct_sns_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3379 | |
Andrew Vasquez | 88729e5 | 2006-06-23 16:10:50 -0700 | [diff] [blame] | 3380 | if (ha->sfp_data) |
| 3381 | dma_pool_free(ha->s_dma_pool, ha->sfp_data, ha->sfp_data_dma); |
| 3382 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3383 | if (ha->ms_iocb) |
| 3384 | dma_pool_free(ha->s_dma_pool, ha->ms_iocb, ha->ms_iocb_dma); |
| 3385 | |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 3386 | if (ha->ex_init_cb) |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3387 | dma_pool_free(ha->s_dma_pool, |
| 3388 | ha->ex_init_cb, ha->ex_init_cb_dma); |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 3389 | |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 3390 | if (ha->async_pd) |
| 3391 | dma_pool_free(ha->s_dma_pool, ha->async_pd, ha->async_pd_dma); |
| 3392 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3393 | if (ha->s_dma_pool) |
| 3394 | dma_pool_destroy(ha->s_dma_pool); |
| 3395 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3396 | if (ha->gid_list) |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 3397 | dma_free_coherent(&ha->pdev->dev, qla2x00_gid_list_size(ha), |
| 3398 | ha->gid_list, ha->gid_list_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3399 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3400 | if (IS_QLA82XX(ha)) { |
| 3401 | if (!list_empty(&ha->gbl_dsd_list)) { |
| 3402 | struct dsd_dma *dsd_ptr, *tdsd_ptr; |
| 3403 | |
| 3404 | /* clean up allocated prev pool */ |
| 3405 | list_for_each_entry_safe(dsd_ptr, |
| 3406 | tdsd_ptr, &ha->gbl_dsd_list, list) { |
| 3407 | dma_pool_free(ha->dl_dma_pool, |
| 3408 | dsd_ptr->dsd_addr, dsd_ptr->dsd_list_dma); |
| 3409 | list_del(&dsd_ptr->list); |
| 3410 | kfree(dsd_ptr); |
| 3411 | } |
| 3412 | } |
| 3413 | } |
| 3414 | |
| 3415 | if (ha->dl_dma_pool) |
| 3416 | dma_pool_destroy(ha->dl_dma_pool); |
| 3417 | |
| 3418 | if (ha->fcp_cmnd_dma_pool) |
| 3419 | dma_pool_destroy(ha->fcp_cmnd_dma_pool); |
| 3420 | |
| 3421 | if (ha->ctx_mempool) |
| 3422 | mempool_destroy(ha->ctx_mempool); |
| 3423 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3424 | qlt_mem_free(ha); |
| 3425 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3426 | if (ha->init_cb) |
| 3427 | dma_free_coherent(&ha->pdev->dev, ha->init_cb_size, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3428 | ha->init_cb, ha->init_cb_dma); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3429 | vfree(ha->optrom_buffer); |
| 3430 | kfree(ha->nvram); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3431 | kfree(ha->npiv_info); |
Andrew Vasquez | 7a67735 | 2012-02-09 11:15:56 -0800 | [diff] [blame] | 3432 | kfree(ha->swl); |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 3433 | kfree(ha->loop_id_map); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3434 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3435 | ha->srb_mempool = NULL; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3436 | ha->ctx_mempool = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3437 | ha->sns_cmd = NULL; |
| 3438 | ha->sns_cmd_dma = 0; |
| 3439 | ha->ct_sns = NULL; |
| 3440 | ha->ct_sns_dma = 0; |
| 3441 | ha->ms_iocb = NULL; |
| 3442 | ha->ms_iocb_dma = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3443 | ha->init_cb = NULL; |
| 3444 | ha->init_cb_dma = 0; |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 3445 | ha->ex_init_cb = NULL; |
| 3446 | ha->ex_init_cb_dma = 0; |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 3447 | ha->async_pd = NULL; |
| 3448 | ha->async_pd_dma = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3449 | |
| 3450 | ha->s_dma_pool = NULL; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3451 | ha->dl_dma_pool = NULL; |
| 3452 | ha->fcp_cmnd_dma_pool = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3453 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3454 | ha->gid_list = NULL; |
| 3455 | ha->gid_list_dma = 0; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3456 | |
| 3457 | ha->tgt.atio_ring = NULL; |
| 3458 | ha->tgt.atio_dma = 0; |
| 3459 | ha->tgt.tgt_vp_map = NULL; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3460 | } |
| 3461 | |
| 3462 | struct scsi_qla_host *qla2x00_create_host(struct scsi_host_template *sht, |
| 3463 | struct qla_hw_data *ha) |
| 3464 | { |
| 3465 | struct Scsi_Host *host; |
| 3466 | struct scsi_qla_host *vha = NULL; |
| 3467 | |
| 3468 | host = scsi_host_alloc(sht, sizeof(scsi_qla_host_t)); |
| 3469 | if (host == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3470 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0107, |
| 3471 | "Failed to allocate host from the scsi layer, aborting.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3472 | goto fail; |
| 3473 | } |
| 3474 | |
| 3475 | /* Clear our data area */ |
| 3476 | vha = shost_priv(host); |
| 3477 | memset(vha, 0, sizeof(scsi_qla_host_t)); |
| 3478 | |
| 3479 | vha->host = host; |
| 3480 | vha->host_no = host->host_no; |
| 3481 | vha->hw = ha; |
| 3482 | |
| 3483 | INIT_LIST_HEAD(&vha->vp_fcports); |
| 3484 | INIT_LIST_HEAD(&vha->work_list); |
| 3485 | INIT_LIST_HEAD(&vha->list); |
| 3486 | |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3487 | spin_lock_init(&vha->work_lock); |
| 3488 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3489 | sprintf(vha->host_str, "%s_%ld", QLA2XXX_DRIVER_NAME, vha->host_no); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3490 | ql_dbg(ql_dbg_init, vha, 0x0041, |
| 3491 | "Allocated the host=%p hw=%p vha=%p dev_name=%s", |
| 3492 | vha->host, vha->hw, vha, |
| 3493 | dev_name(&(ha->pdev->dev))); |
| 3494 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3495 | return vha; |
| 3496 | |
| 3497 | fail: |
| 3498 | return vha; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3499 | } |
| 3500 | |
Adrian Bunk | 01ef66b | 2008-04-24 15:21:27 -0700 | [diff] [blame] | 3501 | static struct qla_work_evt * |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3502 | 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] | 3503 | { |
| 3504 | struct qla_work_evt *e; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3505 | uint8_t bail; |
| 3506 | |
| 3507 | QLA_VHA_MARK_BUSY(vha, bail); |
| 3508 | if (bail) |
| 3509 | return NULL; |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3510 | |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3511 | e = kzalloc(sizeof(struct qla_work_evt), GFP_ATOMIC); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3512 | if (!e) { |
| 3513 | QLA_VHA_MARK_NOT_BUSY(vha); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3514 | return NULL; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3515 | } |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3516 | |
| 3517 | INIT_LIST_HEAD(&e->list); |
| 3518 | e->type = type; |
| 3519 | e->flags = QLA_EVT_FLAG_FREE; |
| 3520 | return e; |
| 3521 | } |
| 3522 | |
Adrian Bunk | 01ef66b | 2008-04-24 15:21:27 -0700 | [diff] [blame] | 3523 | static int |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3524 | 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] | 3525 | { |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3526 | unsigned long flags; |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3527 | |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3528 | spin_lock_irqsave(&vha->work_lock, flags); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3529 | list_add_tail(&e->list, &vha->work_list); |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3530 | spin_unlock_irqrestore(&vha->work_lock, flags); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3531 | qla2xxx_wake_dpc(vha); |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3532 | |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3533 | return QLA_SUCCESS; |
| 3534 | } |
| 3535 | |
| 3536 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3537 | 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] | 3538 | u32 data) |
| 3539 | { |
| 3540 | struct qla_work_evt *e; |
| 3541 | |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3542 | e = qla2x00_alloc_work(vha, QLA_EVT_AEN); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3543 | if (!e) |
| 3544 | return QLA_FUNCTION_FAILED; |
| 3545 | |
| 3546 | e->u.aen.code = code; |
| 3547 | e->u.aen.data = data; |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3548 | return qla2x00_post_work(vha, e); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3549 | } |
| 3550 | |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 3551 | int |
| 3552 | qla2x00_post_idc_ack_work(struct scsi_qla_host *vha, uint16_t *mb) |
| 3553 | { |
| 3554 | struct qla_work_evt *e; |
| 3555 | |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3556 | e = qla2x00_alloc_work(vha, QLA_EVT_IDC_ACK); |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 3557 | if (!e) |
| 3558 | return QLA_FUNCTION_FAILED; |
| 3559 | |
| 3560 | 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] | 3561 | return qla2x00_post_work(vha, e); |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 3562 | } |
| 3563 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 3564 | #define qla2x00_post_async_work(name, type) \ |
| 3565 | int qla2x00_post_async_##name##_work( \ |
| 3566 | struct scsi_qla_host *vha, \ |
| 3567 | fc_port_t *fcport, uint16_t *data) \ |
| 3568 | { \ |
| 3569 | struct qla_work_evt *e; \ |
| 3570 | \ |
| 3571 | e = qla2x00_alloc_work(vha, type); \ |
| 3572 | if (!e) \ |
| 3573 | return QLA_FUNCTION_FAILED; \ |
| 3574 | \ |
| 3575 | e->u.logio.fcport = fcport; \ |
| 3576 | if (data) { \ |
| 3577 | e->u.logio.data[0] = data[0]; \ |
| 3578 | e->u.logio.data[1] = data[1]; \ |
| 3579 | } \ |
| 3580 | return qla2x00_post_work(vha, e); \ |
| 3581 | } |
| 3582 | |
| 3583 | qla2x00_post_async_work(login, QLA_EVT_ASYNC_LOGIN); |
| 3584 | qla2x00_post_async_work(login_done, QLA_EVT_ASYNC_LOGIN_DONE); |
| 3585 | qla2x00_post_async_work(logout, QLA_EVT_ASYNC_LOGOUT); |
| 3586 | qla2x00_post_async_work(logout_done, QLA_EVT_ASYNC_LOGOUT_DONE); |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 3587 | qla2x00_post_async_work(adisc, QLA_EVT_ASYNC_ADISC); |
| 3588 | qla2x00_post_async_work(adisc_done, QLA_EVT_ASYNC_ADISC_DONE); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 3589 | |
Andrew Vasquez | 3420d36 | 2009-10-13 15:16:45 -0700 | [diff] [blame] | 3590 | int |
| 3591 | qla2x00_post_uevent_work(struct scsi_qla_host *vha, u32 code) |
| 3592 | { |
| 3593 | struct qla_work_evt *e; |
| 3594 | |
| 3595 | e = qla2x00_alloc_work(vha, QLA_EVT_UEVENT); |
| 3596 | if (!e) |
| 3597 | return QLA_FUNCTION_FAILED; |
| 3598 | |
| 3599 | e->u.uevent.code = code; |
| 3600 | return qla2x00_post_work(vha, e); |
| 3601 | } |
| 3602 | |
| 3603 | static void |
| 3604 | qla2x00_uevent_emit(struct scsi_qla_host *vha, u32 code) |
| 3605 | { |
| 3606 | char event_string[40]; |
| 3607 | char *envp[] = { event_string, NULL }; |
| 3608 | |
| 3609 | switch (code) { |
| 3610 | case QLA_UEVENT_CODE_FW_DUMP: |
| 3611 | snprintf(event_string, sizeof(event_string), "FW_DUMP=%ld", |
| 3612 | vha->host_no); |
| 3613 | break; |
| 3614 | default: |
| 3615 | /* do nothing */ |
| 3616 | break; |
| 3617 | } |
| 3618 | kobject_uevent_env(&vha->hw->pdev->dev.kobj, KOBJ_CHANGE, envp); |
| 3619 | } |
| 3620 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 3621 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3622 | qla2x00_do_work(struct scsi_qla_host *vha) |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3623 | { |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3624 | struct qla_work_evt *e, *tmp; |
| 3625 | unsigned long flags; |
| 3626 | LIST_HEAD(work); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3627 | |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3628 | spin_lock_irqsave(&vha->work_lock, flags); |
| 3629 | list_splice_init(&vha->work_list, &work); |
| 3630 | spin_unlock_irqrestore(&vha->work_lock, flags); |
| 3631 | |
| 3632 | list_for_each_entry_safe(e, tmp, &work, list) { |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3633 | list_del_init(&e->list); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3634 | |
| 3635 | switch (e->type) { |
| 3636 | case QLA_EVT_AEN: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3637 | fc_host_post_event(vha->host, fc_get_event_number(), |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3638 | e->u.aen.code, e->u.aen.data); |
| 3639 | break; |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 3640 | case QLA_EVT_IDC_ACK: |
| 3641 | qla81xx_idc_ack(vha, e->u.idc_ack.mb); |
| 3642 | break; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 3643 | case QLA_EVT_ASYNC_LOGIN: |
| 3644 | qla2x00_async_login(vha, e->u.logio.fcport, |
| 3645 | e->u.logio.data); |
| 3646 | break; |
| 3647 | case QLA_EVT_ASYNC_LOGIN_DONE: |
| 3648 | qla2x00_async_login_done(vha, e->u.logio.fcport, |
| 3649 | e->u.logio.data); |
| 3650 | break; |
| 3651 | case QLA_EVT_ASYNC_LOGOUT: |
| 3652 | qla2x00_async_logout(vha, e->u.logio.fcport); |
| 3653 | break; |
| 3654 | case QLA_EVT_ASYNC_LOGOUT_DONE: |
| 3655 | qla2x00_async_logout_done(vha, e->u.logio.fcport, |
| 3656 | e->u.logio.data); |
| 3657 | break; |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 3658 | case QLA_EVT_ASYNC_ADISC: |
| 3659 | qla2x00_async_adisc(vha, e->u.logio.fcport, |
| 3660 | e->u.logio.data); |
| 3661 | break; |
| 3662 | case QLA_EVT_ASYNC_ADISC_DONE: |
| 3663 | qla2x00_async_adisc_done(vha, e->u.logio.fcport, |
| 3664 | e->u.logio.data); |
| 3665 | break; |
Andrew Vasquez | 3420d36 | 2009-10-13 15:16:45 -0700 | [diff] [blame] | 3666 | case QLA_EVT_UEVENT: |
| 3667 | qla2x00_uevent_emit(vha, e->u.uevent.code); |
| 3668 | break; |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3669 | } |
| 3670 | if (e->flags & QLA_EVT_FLAG_FREE) |
| 3671 | kfree(e); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3672 | |
| 3673 | /* For each work completed decrement vha ref count */ |
| 3674 | QLA_VHA_MARK_NOT_BUSY(vha); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3675 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3676 | } |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3677 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3678 | /* Relogins all the fcports of a vport |
| 3679 | * Context: dpc thread |
| 3680 | */ |
| 3681 | void qla2x00_relogin(struct scsi_qla_host *vha) |
| 3682 | { |
| 3683 | fc_port_t *fcport; |
Andrew Vasquez | c6b2fca | 2009-03-05 11:07:03 -0800 | [diff] [blame] | 3684 | int status; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3685 | uint16_t next_loopid = 0; |
| 3686 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 3687 | uint16_t data[2]; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3688 | |
| 3689 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
| 3690 | /* |
| 3691 | * If the port is not ONLINE then try to login |
| 3692 | * to it if we haven't run out of retries. |
| 3693 | */ |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 3694 | if (atomic_read(&fcport->state) != FCS_ONLINE && |
| 3695 | fcport->login_retry && !(fcport->flags & FCF_ASYNC_SENT)) { |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 3696 | fcport->login_retry--; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3697 | if (fcport->flags & FCF_FABRIC_DEVICE) { |
Andrew Vasquez | f08b725 | 2010-01-12 12:59:48 -0800 | [diff] [blame] | 3698 | if (fcport->flags & FCF_FCP2_DEVICE) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3699 | ha->isp_ops->fabric_logout(vha, |
| 3700 | fcport->loop_id, |
| 3701 | fcport->d_id.b.domain, |
| 3702 | fcport->d_id.b.area, |
| 3703 | fcport->d_id.b.al_pa); |
| 3704 | |
Joe Carnuccio | 03bcfb5 | 2011-03-30 11:46:27 -0700 | [diff] [blame] | 3705 | if (fcport->loop_id == FC_NO_LOOP_ID) { |
| 3706 | fcport->loop_id = next_loopid = |
| 3707 | ha->min_external_loopid; |
| 3708 | status = qla2x00_find_new_loop_id( |
| 3709 | vha, fcport); |
| 3710 | if (status != QLA_SUCCESS) { |
| 3711 | /* Ran out of IDs to use */ |
| 3712 | break; |
| 3713 | } |
| 3714 | } |
| 3715 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 3716 | if (IS_ALOGIO_CAPABLE(ha)) { |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 3717 | fcport->flags |= FCF_ASYNC_SENT; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 3718 | data[0] = 0; |
| 3719 | data[1] = QLA_LOGIO_LOGIN_RETRIED; |
| 3720 | status = qla2x00_post_async_login_work( |
| 3721 | vha, fcport, data); |
| 3722 | if (status == QLA_SUCCESS) |
| 3723 | continue; |
| 3724 | /* Attempt a retry. */ |
| 3725 | status = 1; |
Saurav Kashyap | aaf4d3e | 2012-04-25 07:26:16 -0700 | [diff] [blame] | 3726 | } else { |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 3727 | status = qla2x00_fabric_login(vha, |
| 3728 | fcport, &next_loopid); |
Saurav Kashyap | aaf4d3e | 2012-04-25 07:26:16 -0700 | [diff] [blame] | 3729 | if (status == QLA_SUCCESS) { |
| 3730 | int status2; |
| 3731 | uint8_t opts; |
| 3732 | |
| 3733 | opts = 0; |
| 3734 | if (fcport->flags & |
| 3735 | FCF_FCP2_DEVICE) |
| 3736 | opts |= BIT_1; |
Saurav Kashyap | 0300396 | 2012-11-21 02:40:31 -0500 | [diff] [blame] | 3737 | status2 = |
| 3738 | qla2x00_get_port_database( |
| 3739 | vha, fcport, opts); |
Saurav Kashyap | aaf4d3e | 2012-04-25 07:26:16 -0700 | [diff] [blame] | 3740 | if (status2 != QLA_SUCCESS) |
| 3741 | status = 1; |
| 3742 | } |
| 3743 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3744 | } else |
| 3745 | status = qla2x00_local_device_login(vha, |
| 3746 | fcport); |
| 3747 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3748 | if (status == QLA_SUCCESS) { |
| 3749 | fcport->old_loop_id = fcport->loop_id; |
| 3750 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3751 | ql_dbg(ql_dbg_disc, vha, 0x2003, |
| 3752 | "Port login OK: logged in ID 0x%x.\n", |
| 3753 | fcport->loop_id); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3754 | |
| 3755 | qla2x00_update_fcport(vha, fcport); |
| 3756 | |
| 3757 | } else if (status == 1) { |
| 3758 | set_bit(RELOGIN_NEEDED, &vha->dpc_flags); |
| 3759 | /* retry the login again */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3760 | ql_dbg(ql_dbg_disc, vha, 0x2007, |
| 3761 | "Retrying %d login again loop_id 0x%x.\n", |
| 3762 | fcport->login_retry, fcport->loop_id); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3763 | } else { |
| 3764 | fcport->login_retry = 0; |
| 3765 | } |
| 3766 | |
| 3767 | if (fcport->login_retry == 0 && status != QLA_SUCCESS) |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 3768 | qla2x00_clear_loop_id(fcport); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3769 | } |
| 3770 | if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) |
| 3771 | break; |
| 3772 | } |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3773 | } |
| 3774 | |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 3775 | /* Schedule work on any of the dpc-workqueues */ |
| 3776 | void |
| 3777 | qla83xx_schedule_work(scsi_qla_host_t *base_vha, int work_code) |
| 3778 | { |
| 3779 | struct qla_hw_data *ha = base_vha->hw; |
| 3780 | |
| 3781 | switch (work_code) { |
| 3782 | case MBA_IDC_AEN: /* 0x8200 */ |
| 3783 | if (ha->dpc_lp_wq) |
| 3784 | queue_work(ha->dpc_lp_wq, &ha->idc_aen); |
| 3785 | break; |
| 3786 | |
| 3787 | case QLA83XX_NIC_CORE_RESET: /* 0x1 */ |
| 3788 | if (!ha->flags.nic_core_reset_hdlr_active) { |
| 3789 | if (ha->dpc_hp_wq) |
| 3790 | queue_work(ha->dpc_hp_wq, &ha->nic_core_reset); |
| 3791 | } else |
| 3792 | ql_dbg(ql_dbg_p3p, base_vha, 0xb05e, |
| 3793 | "NIC Core reset is already active. Skip " |
| 3794 | "scheduling it again.\n"); |
| 3795 | break; |
| 3796 | case QLA83XX_IDC_STATE_HANDLER: /* 0x2 */ |
| 3797 | if (ha->dpc_hp_wq) |
| 3798 | queue_work(ha->dpc_hp_wq, &ha->idc_state_handler); |
| 3799 | break; |
| 3800 | case QLA83XX_NIC_CORE_UNRECOVERABLE: /* 0x3 */ |
| 3801 | if (ha->dpc_hp_wq) |
| 3802 | queue_work(ha->dpc_hp_wq, &ha->nic_core_unrecoverable); |
| 3803 | break; |
| 3804 | default: |
| 3805 | ql_log(ql_log_warn, base_vha, 0xb05f, |
| 3806 | "Unknow work-code=0x%x.\n", work_code); |
| 3807 | } |
| 3808 | |
| 3809 | return; |
| 3810 | } |
| 3811 | |
| 3812 | /* Work: Perform NIC Core Unrecoverable state handling */ |
| 3813 | void |
| 3814 | qla83xx_nic_core_unrecoverable_work(struct work_struct *work) |
| 3815 | { |
| 3816 | struct qla_hw_data *ha = |
Arun Easi | 2ad1b67 | 2012-08-22 14:21:35 -0400 | [diff] [blame] | 3817 | container_of(work, struct qla_hw_data, nic_core_unrecoverable); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 3818 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 3819 | uint32_t dev_state = 0; |
| 3820 | |
| 3821 | qla83xx_idc_lock(base_vha, 0); |
| 3822 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, &dev_state); |
| 3823 | qla83xx_reset_ownership(base_vha); |
| 3824 | if (ha->flags.nic_core_reset_owner) { |
| 3825 | ha->flags.nic_core_reset_owner = 0; |
| 3826 | qla83xx_wr_reg(base_vha, QLA83XX_IDC_DEV_STATE, |
| 3827 | QLA8XXX_DEV_FAILED); |
| 3828 | ql_log(ql_log_info, base_vha, 0xb060, "HW State: FAILED.\n"); |
| 3829 | qla83xx_schedule_work(base_vha, QLA83XX_IDC_STATE_HANDLER); |
| 3830 | } |
| 3831 | qla83xx_idc_unlock(base_vha, 0); |
| 3832 | } |
| 3833 | |
| 3834 | /* Work: Execute IDC state handler */ |
| 3835 | void |
| 3836 | qla83xx_idc_state_handler_work(struct work_struct *work) |
| 3837 | { |
| 3838 | struct qla_hw_data *ha = |
Arun Easi | 2ad1b67 | 2012-08-22 14:21:35 -0400 | [diff] [blame] | 3839 | container_of(work, struct qla_hw_data, idc_state_handler); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 3840 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 3841 | uint32_t dev_state = 0; |
| 3842 | |
| 3843 | qla83xx_idc_lock(base_vha, 0); |
| 3844 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, &dev_state); |
| 3845 | if (dev_state == QLA8XXX_DEV_FAILED || |
| 3846 | dev_state == QLA8XXX_DEV_NEED_QUIESCENT) |
| 3847 | qla83xx_idc_state_handler(base_vha); |
| 3848 | qla83xx_idc_unlock(base_vha, 0); |
| 3849 | } |
| 3850 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 3851 | static int |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 3852 | qla83xx_check_nic_core_fw_alive(scsi_qla_host_t *base_vha) |
| 3853 | { |
| 3854 | int rval = QLA_SUCCESS; |
| 3855 | unsigned long heart_beat_wait = jiffies + (1 * HZ); |
| 3856 | uint32_t heart_beat_counter1, heart_beat_counter2; |
| 3857 | |
| 3858 | do { |
| 3859 | if (time_after(jiffies, heart_beat_wait)) { |
| 3860 | ql_dbg(ql_dbg_p3p, base_vha, 0xb07c, |
| 3861 | "Nic Core f/w is not alive.\n"); |
| 3862 | rval = QLA_FUNCTION_FAILED; |
| 3863 | break; |
| 3864 | } |
| 3865 | |
| 3866 | qla83xx_idc_lock(base_vha, 0); |
| 3867 | qla83xx_rd_reg(base_vha, QLA83XX_FW_HEARTBEAT, |
| 3868 | &heart_beat_counter1); |
| 3869 | qla83xx_idc_unlock(base_vha, 0); |
| 3870 | msleep(100); |
| 3871 | qla83xx_idc_lock(base_vha, 0); |
| 3872 | qla83xx_rd_reg(base_vha, QLA83XX_FW_HEARTBEAT, |
| 3873 | &heart_beat_counter2); |
| 3874 | qla83xx_idc_unlock(base_vha, 0); |
| 3875 | } while (heart_beat_counter1 == heart_beat_counter2); |
| 3876 | |
| 3877 | return rval; |
| 3878 | } |
| 3879 | |
| 3880 | /* Work: Perform NIC Core Reset handling */ |
| 3881 | void |
| 3882 | qla83xx_nic_core_reset_work(struct work_struct *work) |
| 3883 | { |
| 3884 | struct qla_hw_data *ha = |
| 3885 | container_of(work, struct qla_hw_data, nic_core_reset); |
| 3886 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 3887 | uint32_t dev_state = 0; |
| 3888 | |
Saurav Kashyap | 8117877 | 2012-08-22 14:21:04 -0400 | [diff] [blame] | 3889 | if (IS_QLA2031(ha)) { |
| 3890 | if (qla2xxx_mctp_dump(base_vha) != QLA_SUCCESS) |
| 3891 | ql_log(ql_log_warn, base_vha, 0xb081, |
| 3892 | "Failed to dump mctp\n"); |
| 3893 | return; |
| 3894 | } |
| 3895 | |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 3896 | if (!ha->flags.nic_core_reset_hdlr_active) { |
| 3897 | if (qla83xx_check_nic_core_fw_alive(base_vha) == QLA_SUCCESS) { |
| 3898 | qla83xx_idc_lock(base_vha, 0); |
| 3899 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, |
| 3900 | &dev_state); |
| 3901 | qla83xx_idc_unlock(base_vha, 0); |
| 3902 | if (dev_state != QLA8XXX_DEV_NEED_RESET) { |
| 3903 | ql_dbg(ql_dbg_p3p, base_vha, 0xb07a, |
| 3904 | "Nic Core f/w is alive.\n"); |
| 3905 | return; |
| 3906 | } |
| 3907 | } |
| 3908 | |
| 3909 | ha->flags.nic_core_reset_hdlr_active = 1; |
| 3910 | if (qla83xx_nic_core_reset(base_vha)) { |
| 3911 | /* NIC Core reset failed. */ |
| 3912 | ql_dbg(ql_dbg_p3p, base_vha, 0xb061, |
| 3913 | "NIC Core reset failed.\n"); |
| 3914 | } |
| 3915 | ha->flags.nic_core_reset_hdlr_active = 0; |
| 3916 | } |
| 3917 | } |
| 3918 | |
| 3919 | /* Work: Handle 8200 IDC aens */ |
| 3920 | void |
| 3921 | qla83xx_service_idc_aen(struct work_struct *work) |
| 3922 | { |
| 3923 | struct qla_hw_data *ha = |
| 3924 | container_of(work, struct qla_hw_data, idc_aen); |
| 3925 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 3926 | uint32_t dev_state, idc_control; |
| 3927 | |
| 3928 | qla83xx_idc_lock(base_vha, 0); |
| 3929 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, &dev_state); |
| 3930 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_CONTROL, &idc_control); |
| 3931 | qla83xx_idc_unlock(base_vha, 0); |
| 3932 | if (dev_state == QLA8XXX_DEV_NEED_RESET) { |
| 3933 | if (idc_control & QLA83XX_IDC_GRACEFUL_RESET) { |
| 3934 | ql_dbg(ql_dbg_p3p, base_vha, 0xb062, |
| 3935 | "Application requested NIC Core Reset.\n"); |
| 3936 | qla83xx_schedule_work(base_vha, QLA83XX_NIC_CORE_RESET); |
| 3937 | } else if (qla83xx_check_nic_core_fw_alive(base_vha) == |
| 3938 | QLA_SUCCESS) { |
| 3939 | ql_dbg(ql_dbg_p3p, base_vha, 0xb07b, |
| 3940 | "Other protocol driver requested NIC Core Reset.\n"); |
| 3941 | qla83xx_schedule_work(base_vha, QLA83XX_NIC_CORE_RESET); |
| 3942 | } |
| 3943 | } else if (dev_state == QLA8XXX_DEV_FAILED || |
| 3944 | dev_state == QLA8XXX_DEV_NEED_QUIESCENT) { |
| 3945 | qla83xx_schedule_work(base_vha, QLA83XX_IDC_STATE_HANDLER); |
| 3946 | } |
| 3947 | } |
| 3948 | |
| 3949 | static void |
| 3950 | qla83xx_wait_logic(void) |
| 3951 | { |
| 3952 | int i; |
| 3953 | |
| 3954 | /* Yield CPU */ |
| 3955 | if (!in_interrupt()) { |
| 3956 | /* |
| 3957 | * Wait about 200ms before retrying again. |
| 3958 | * This controls the number of retries for single |
| 3959 | * lock operation. |
| 3960 | */ |
| 3961 | msleep(100); |
| 3962 | schedule(); |
| 3963 | } else { |
| 3964 | for (i = 0; i < 20; i++) |
| 3965 | cpu_relax(); /* This a nop instr on i386 */ |
| 3966 | } |
| 3967 | } |
| 3968 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 3969 | static int |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 3970 | qla83xx_force_lock_recovery(scsi_qla_host_t *base_vha) |
| 3971 | { |
| 3972 | int rval; |
| 3973 | uint32_t data; |
| 3974 | uint32_t idc_lck_rcvry_stage_mask = 0x3; |
| 3975 | uint32_t idc_lck_rcvry_owner_mask = 0x3c; |
| 3976 | struct qla_hw_data *ha = base_vha->hw; |
| 3977 | |
| 3978 | rval = qla83xx_rd_reg(base_vha, QLA83XX_IDC_LOCK_RECOVERY, &data); |
| 3979 | if (rval) |
| 3980 | return rval; |
| 3981 | |
| 3982 | if ((data & idc_lck_rcvry_stage_mask) > 0) { |
| 3983 | return QLA_SUCCESS; |
| 3984 | } else { |
| 3985 | data = (IDC_LOCK_RECOVERY_STAGE1) | (ha->portnum << 2); |
| 3986 | rval = qla83xx_wr_reg(base_vha, QLA83XX_IDC_LOCK_RECOVERY, |
| 3987 | data); |
| 3988 | if (rval) |
| 3989 | return rval; |
| 3990 | |
| 3991 | msleep(200); |
| 3992 | |
| 3993 | rval = qla83xx_rd_reg(base_vha, QLA83XX_IDC_LOCK_RECOVERY, |
| 3994 | &data); |
| 3995 | if (rval) |
| 3996 | return rval; |
| 3997 | |
| 3998 | if (((data & idc_lck_rcvry_owner_mask) >> 2) == ha->portnum) { |
| 3999 | data &= (IDC_LOCK_RECOVERY_STAGE2 | |
| 4000 | ~(idc_lck_rcvry_stage_mask)); |
| 4001 | rval = qla83xx_wr_reg(base_vha, |
| 4002 | QLA83XX_IDC_LOCK_RECOVERY, data); |
| 4003 | if (rval) |
| 4004 | return rval; |
| 4005 | |
| 4006 | /* Forcefully perform IDC UnLock */ |
| 4007 | rval = qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_UNLOCK, |
| 4008 | &data); |
| 4009 | if (rval) |
| 4010 | return rval; |
| 4011 | /* Clear lock-id by setting 0xff */ |
| 4012 | rval = qla83xx_wr_reg(base_vha, QLA83XX_DRIVER_LOCKID, |
| 4013 | 0xff); |
| 4014 | if (rval) |
| 4015 | return rval; |
| 4016 | /* Clear lock-recovery by setting 0x0 */ |
| 4017 | rval = qla83xx_wr_reg(base_vha, |
| 4018 | QLA83XX_IDC_LOCK_RECOVERY, 0x0); |
| 4019 | if (rval) |
| 4020 | return rval; |
| 4021 | } else |
| 4022 | return QLA_SUCCESS; |
| 4023 | } |
| 4024 | |
| 4025 | return rval; |
| 4026 | } |
| 4027 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 4028 | static int |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4029 | qla83xx_idc_lock_recovery(scsi_qla_host_t *base_vha) |
| 4030 | { |
| 4031 | int rval = QLA_SUCCESS; |
| 4032 | uint32_t o_drv_lockid, n_drv_lockid; |
| 4033 | unsigned long lock_recovery_timeout; |
| 4034 | |
| 4035 | lock_recovery_timeout = jiffies + QLA83XX_MAX_LOCK_RECOVERY_WAIT; |
| 4036 | retry_lockid: |
| 4037 | rval = qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCKID, &o_drv_lockid); |
| 4038 | if (rval) |
| 4039 | goto exit; |
| 4040 | |
| 4041 | /* MAX wait time before forcing IDC Lock recovery = 2 secs */ |
| 4042 | if (time_after_eq(jiffies, lock_recovery_timeout)) { |
| 4043 | if (qla83xx_force_lock_recovery(base_vha) == QLA_SUCCESS) |
| 4044 | return QLA_SUCCESS; |
| 4045 | else |
| 4046 | return QLA_FUNCTION_FAILED; |
| 4047 | } |
| 4048 | |
| 4049 | rval = qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCKID, &n_drv_lockid); |
| 4050 | if (rval) |
| 4051 | goto exit; |
| 4052 | |
| 4053 | if (o_drv_lockid == n_drv_lockid) { |
| 4054 | qla83xx_wait_logic(); |
| 4055 | goto retry_lockid; |
| 4056 | } else |
| 4057 | return QLA_SUCCESS; |
| 4058 | |
| 4059 | exit: |
| 4060 | return rval; |
| 4061 | } |
| 4062 | |
| 4063 | void |
| 4064 | qla83xx_idc_lock(scsi_qla_host_t *base_vha, uint16_t requester_id) |
| 4065 | { |
| 4066 | uint16_t options = (requester_id << 15) | BIT_6; |
| 4067 | uint32_t data; |
| 4068 | struct qla_hw_data *ha = base_vha->hw; |
| 4069 | |
| 4070 | /* IDC-lock implementation using driver-lock/lock-id remote registers */ |
| 4071 | retry_lock: |
| 4072 | if (qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCK, &data) |
| 4073 | == QLA_SUCCESS) { |
| 4074 | if (data) { |
| 4075 | /* Setting lock-id to our function-number */ |
| 4076 | qla83xx_wr_reg(base_vha, QLA83XX_DRIVER_LOCKID, |
| 4077 | ha->portnum); |
| 4078 | } else { |
| 4079 | ql_dbg(ql_dbg_p3p, base_vha, 0xb063, |
| 4080 | "Failed to acquire IDC lock. retrying...\n"); |
| 4081 | |
| 4082 | /* Retry/Perform IDC-Lock recovery */ |
| 4083 | if (qla83xx_idc_lock_recovery(base_vha) |
| 4084 | == QLA_SUCCESS) { |
| 4085 | qla83xx_wait_logic(); |
| 4086 | goto retry_lock; |
| 4087 | } else |
| 4088 | ql_log(ql_log_warn, base_vha, 0xb075, |
| 4089 | "IDC Lock recovery FAILED.\n"); |
| 4090 | } |
| 4091 | |
| 4092 | } |
| 4093 | |
| 4094 | return; |
| 4095 | |
| 4096 | /* XXX: IDC-lock implementation using access-control mbx */ |
| 4097 | retry_lock2: |
| 4098 | if (qla83xx_access_control(base_vha, options, 0, 0, NULL)) { |
| 4099 | ql_dbg(ql_dbg_p3p, base_vha, 0xb072, |
| 4100 | "Failed to acquire IDC lock. retrying...\n"); |
| 4101 | /* Retry/Perform IDC-Lock recovery */ |
| 4102 | if (qla83xx_idc_lock_recovery(base_vha) == QLA_SUCCESS) { |
| 4103 | qla83xx_wait_logic(); |
| 4104 | goto retry_lock2; |
| 4105 | } else |
| 4106 | ql_log(ql_log_warn, base_vha, 0xb076, |
| 4107 | "IDC Lock recovery FAILED.\n"); |
| 4108 | } |
| 4109 | |
| 4110 | return; |
| 4111 | } |
| 4112 | |
| 4113 | void |
| 4114 | qla83xx_idc_unlock(scsi_qla_host_t *base_vha, uint16_t requester_id) |
| 4115 | { |
| 4116 | uint16_t options = (requester_id << 15) | BIT_7, retry; |
| 4117 | uint32_t data; |
| 4118 | struct qla_hw_data *ha = base_vha->hw; |
| 4119 | |
| 4120 | /* IDC-unlock implementation using driver-unlock/lock-id |
| 4121 | * remote registers |
| 4122 | */ |
| 4123 | retry = 0; |
| 4124 | retry_unlock: |
| 4125 | if (qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCKID, &data) |
| 4126 | == QLA_SUCCESS) { |
| 4127 | if (data == ha->portnum) { |
| 4128 | qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_UNLOCK, &data); |
| 4129 | /* Clearing lock-id by setting 0xff */ |
| 4130 | qla83xx_wr_reg(base_vha, QLA83XX_DRIVER_LOCKID, 0xff); |
| 4131 | } else if (retry < 10) { |
| 4132 | /* SV: XXX: IDC unlock retrying needed here? */ |
| 4133 | |
| 4134 | /* Retry for IDC-unlock */ |
| 4135 | qla83xx_wait_logic(); |
| 4136 | retry++; |
| 4137 | ql_dbg(ql_dbg_p3p, base_vha, 0xb064, |
| 4138 | "Failed to release IDC lock, retyring=%d\n", retry); |
| 4139 | goto retry_unlock; |
| 4140 | } |
| 4141 | } else if (retry < 10) { |
| 4142 | /* Retry for IDC-unlock */ |
| 4143 | qla83xx_wait_logic(); |
| 4144 | retry++; |
| 4145 | ql_dbg(ql_dbg_p3p, base_vha, 0xb065, |
| 4146 | "Failed to read drv-lockid, retyring=%d\n", retry); |
| 4147 | goto retry_unlock; |
| 4148 | } |
| 4149 | |
| 4150 | return; |
| 4151 | |
| 4152 | /* XXX: IDC-unlock implementation using access-control mbx */ |
| 4153 | retry = 0; |
| 4154 | retry_unlock2: |
| 4155 | if (qla83xx_access_control(base_vha, options, 0, 0, NULL)) { |
| 4156 | if (retry < 10) { |
| 4157 | /* Retry for IDC-unlock */ |
| 4158 | qla83xx_wait_logic(); |
| 4159 | retry++; |
| 4160 | ql_dbg(ql_dbg_p3p, base_vha, 0xb066, |
| 4161 | "Failed to release IDC lock, retyring=%d\n", retry); |
| 4162 | goto retry_unlock2; |
| 4163 | } |
| 4164 | } |
| 4165 | |
| 4166 | return; |
| 4167 | } |
| 4168 | |
| 4169 | int |
| 4170 | __qla83xx_set_drv_presence(scsi_qla_host_t *vha) |
| 4171 | { |
| 4172 | int rval = QLA_SUCCESS; |
| 4173 | struct qla_hw_data *ha = vha->hw; |
| 4174 | uint32_t drv_presence; |
| 4175 | |
| 4176 | rval = qla83xx_rd_reg(vha, QLA83XX_IDC_DRV_PRESENCE, &drv_presence); |
| 4177 | if (rval == QLA_SUCCESS) { |
| 4178 | drv_presence |= (1 << ha->portnum); |
| 4179 | rval = qla83xx_wr_reg(vha, QLA83XX_IDC_DRV_PRESENCE, |
| 4180 | drv_presence); |
| 4181 | } |
| 4182 | |
| 4183 | return rval; |
| 4184 | } |
| 4185 | |
| 4186 | int |
| 4187 | qla83xx_set_drv_presence(scsi_qla_host_t *vha) |
| 4188 | { |
| 4189 | int rval = QLA_SUCCESS; |
| 4190 | |
| 4191 | qla83xx_idc_lock(vha, 0); |
| 4192 | rval = __qla83xx_set_drv_presence(vha); |
| 4193 | qla83xx_idc_unlock(vha, 0); |
| 4194 | |
| 4195 | return rval; |
| 4196 | } |
| 4197 | |
| 4198 | int |
| 4199 | __qla83xx_clear_drv_presence(scsi_qla_host_t *vha) |
| 4200 | { |
| 4201 | int rval = QLA_SUCCESS; |
| 4202 | struct qla_hw_data *ha = vha->hw; |
| 4203 | uint32_t drv_presence; |
| 4204 | |
| 4205 | rval = qla83xx_rd_reg(vha, QLA83XX_IDC_DRV_PRESENCE, &drv_presence); |
| 4206 | if (rval == QLA_SUCCESS) { |
| 4207 | drv_presence &= ~(1 << ha->portnum); |
| 4208 | rval = qla83xx_wr_reg(vha, QLA83XX_IDC_DRV_PRESENCE, |
| 4209 | drv_presence); |
| 4210 | } |
| 4211 | |
| 4212 | return rval; |
| 4213 | } |
| 4214 | |
| 4215 | int |
| 4216 | qla83xx_clear_drv_presence(scsi_qla_host_t *vha) |
| 4217 | { |
| 4218 | int rval = QLA_SUCCESS; |
| 4219 | |
| 4220 | qla83xx_idc_lock(vha, 0); |
| 4221 | rval = __qla83xx_clear_drv_presence(vha); |
| 4222 | qla83xx_idc_unlock(vha, 0); |
| 4223 | |
| 4224 | return rval; |
| 4225 | } |
| 4226 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 4227 | static void |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4228 | qla83xx_need_reset_handler(scsi_qla_host_t *vha) |
| 4229 | { |
| 4230 | struct qla_hw_data *ha = vha->hw; |
| 4231 | uint32_t drv_ack, drv_presence; |
| 4232 | unsigned long ack_timeout; |
| 4233 | |
| 4234 | /* Wait for IDC ACK from all functions (DRV-ACK == DRV-PRESENCE) */ |
| 4235 | ack_timeout = jiffies + (ha->fcoe_reset_timeout * HZ); |
| 4236 | while (1) { |
| 4237 | qla83xx_rd_reg(vha, QLA83XX_IDC_DRIVER_ACK, &drv_ack); |
| 4238 | qla83xx_rd_reg(vha, QLA83XX_IDC_DRV_PRESENCE, &drv_presence); |
Saurav Kashyap | 807fb6d | 2012-11-21 02:40:36 -0500 | [diff] [blame] | 4239 | if ((drv_ack & drv_presence) == drv_presence) |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4240 | break; |
| 4241 | |
| 4242 | if (time_after_eq(jiffies, ack_timeout)) { |
| 4243 | ql_log(ql_log_warn, vha, 0xb067, |
| 4244 | "RESET ACK TIMEOUT! drv_presence=0x%x " |
| 4245 | "drv_ack=0x%x\n", drv_presence, drv_ack); |
| 4246 | /* |
| 4247 | * The function(s) which did not ack in time are forced |
| 4248 | * to withdraw any further participation in the IDC |
| 4249 | * reset. |
| 4250 | */ |
| 4251 | if (drv_ack != drv_presence) |
| 4252 | qla83xx_wr_reg(vha, QLA83XX_IDC_DRV_PRESENCE, |
| 4253 | drv_ack); |
| 4254 | break; |
| 4255 | } |
| 4256 | |
| 4257 | qla83xx_idc_unlock(vha, 0); |
| 4258 | msleep(1000); |
| 4259 | qla83xx_idc_lock(vha, 0); |
| 4260 | } |
| 4261 | |
| 4262 | qla83xx_wr_reg(vha, QLA83XX_IDC_DEV_STATE, QLA8XXX_DEV_COLD); |
| 4263 | ql_log(ql_log_info, vha, 0xb068, "HW State: COLD/RE-INIT.\n"); |
| 4264 | } |
| 4265 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 4266 | static int |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4267 | qla83xx_device_bootstrap(scsi_qla_host_t *vha) |
| 4268 | { |
| 4269 | int rval = QLA_SUCCESS; |
| 4270 | uint32_t idc_control; |
| 4271 | |
| 4272 | qla83xx_wr_reg(vha, QLA83XX_IDC_DEV_STATE, QLA8XXX_DEV_INITIALIZING); |
| 4273 | ql_log(ql_log_info, vha, 0xb069, "HW State: INITIALIZING.\n"); |
| 4274 | |
| 4275 | /* Clearing IDC-Control Graceful-Reset Bit before resetting f/w */ |
| 4276 | __qla83xx_get_idc_control(vha, &idc_control); |
| 4277 | idc_control &= ~QLA83XX_IDC_GRACEFUL_RESET; |
| 4278 | __qla83xx_set_idc_control(vha, 0); |
| 4279 | |
| 4280 | qla83xx_idc_unlock(vha, 0); |
| 4281 | rval = qla83xx_restart_nic_firmware(vha); |
| 4282 | qla83xx_idc_lock(vha, 0); |
| 4283 | |
| 4284 | if (rval != QLA_SUCCESS) { |
| 4285 | ql_log(ql_log_fatal, vha, 0xb06a, |
| 4286 | "Failed to restart NIC f/w.\n"); |
| 4287 | qla83xx_wr_reg(vha, QLA83XX_IDC_DEV_STATE, QLA8XXX_DEV_FAILED); |
| 4288 | ql_log(ql_log_info, vha, 0xb06b, "HW State: FAILED.\n"); |
| 4289 | } else { |
| 4290 | ql_dbg(ql_dbg_p3p, vha, 0xb06c, |
| 4291 | "Success in restarting nic f/w.\n"); |
| 4292 | qla83xx_wr_reg(vha, QLA83XX_IDC_DEV_STATE, QLA8XXX_DEV_READY); |
| 4293 | ql_log(ql_log_info, vha, 0xb06d, "HW State: READY.\n"); |
| 4294 | } |
| 4295 | |
| 4296 | return rval; |
| 4297 | } |
| 4298 | |
| 4299 | /* Assumes idc_lock always held on entry */ |
| 4300 | int |
| 4301 | qla83xx_idc_state_handler(scsi_qla_host_t *base_vha) |
| 4302 | { |
| 4303 | struct qla_hw_data *ha = base_vha->hw; |
| 4304 | int rval = QLA_SUCCESS; |
| 4305 | unsigned long dev_init_timeout; |
| 4306 | uint32_t dev_state; |
| 4307 | |
| 4308 | /* Wait for MAX-INIT-TIMEOUT for the device to go ready */ |
| 4309 | dev_init_timeout = jiffies + (ha->fcoe_dev_init_timeout * HZ); |
| 4310 | |
| 4311 | while (1) { |
| 4312 | |
| 4313 | if (time_after_eq(jiffies, dev_init_timeout)) { |
| 4314 | ql_log(ql_log_warn, base_vha, 0xb06e, |
| 4315 | "Initialization TIMEOUT!\n"); |
| 4316 | /* Init timeout. Disable further NIC Core |
| 4317 | * communication. |
| 4318 | */ |
| 4319 | qla83xx_wr_reg(base_vha, QLA83XX_IDC_DEV_STATE, |
| 4320 | QLA8XXX_DEV_FAILED); |
| 4321 | ql_log(ql_log_info, base_vha, 0xb06f, |
| 4322 | "HW State: FAILED.\n"); |
| 4323 | } |
| 4324 | |
| 4325 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, &dev_state); |
| 4326 | switch (dev_state) { |
| 4327 | case QLA8XXX_DEV_READY: |
| 4328 | if (ha->flags.nic_core_reset_owner) |
| 4329 | qla83xx_idc_audit(base_vha, |
| 4330 | IDC_AUDIT_COMPLETION); |
| 4331 | ha->flags.nic_core_reset_owner = 0; |
| 4332 | ql_dbg(ql_dbg_p3p, base_vha, 0xb070, |
| 4333 | "Reset_owner reset by 0x%x.\n", |
| 4334 | ha->portnum); |
| 4335 | goto exit; |
| 4336 | case QLA8XXX_DEV_COLD: |
| 4337 | if (ha->flags.nic_core_reset_owner) |
| 4338 | rval = qla83xx_device_bootstrap(base_vha); |
| 4339 | else { |
| 4340 | /* Wait for AEN to change device-state */ |
| 4341 | qla83xx_idc_unlock(base_vha, 0); |
| 4342 | msleep(1000); |
| 4343 | qla83xx_idc_lock(base_vha, 0); |
| 4344 | } |
| 4345 | break; |
| 4346 | case QLA8XXX_DEV_INITIALIZING: |
| 4347 | /* Wait for AEN to change device-state */ |
| 4348 | qla83xx_idc_unlock(base_vha, 0); |
| 4349 | msleep(1000); |
| 4350 | qla83xx_idc_lock(base_vha, 0); |
| 4351 | break; |
| 4352 | case QLA8XXX_DEV_NEED_RESET: |
| 4353 | if (!ql2xdontresethba && ha->flags.nic_core_reset_owner) |
| 4354 | qla83xx_need_reset_handler(base_vha); |
| 4355 | else { |
| 4356 | /* Wait for AEN to change device-state */ |
| 4357 | qla83xx_idc_unlock(base_vha, 0); |
| 4358 | msleep(1000); |
| 4359 | qla83xx_idc_lock(base_vha, 0); |
| 4360 | } |
| 4361 | /* reset timeout value after need reset handler */ |
| 4362 | dev_init_timeout = jiffies + |
| 4363 | (ha->fcoe_dev_init_timeout * HZ); |
| 4364 | break; |
| 4365 | case QLA8XXX_DEV_NEED_QUIESCENT: |
| 4366 | /* XXX: DEBUG for now */ |
| 4367 | qla83xx_idc_unlock(base_vha, 0); |
| 4368 | msleep(1000); |
| 4369 | qla83xx_idc_lock(base_vha, 0); |
| 4370 | break; |
| 4371 | case QLA8XXX_DEV_QUIESCENT: |
| 4372 | /* XXX: DEBUG for now */ |
| 4373 | if (ha->flags.quiesce_owner) |
| 4374 | goto exit; |
| 4375 | |
| 4376 | qla83xx_idc_unlock(base_vha, 0); |
| 4377 | msleep(1000); |
| 4378 | qla83xx_idc_lock(base_vha, 0); |
| 4379 | dev_init_timeout = jiffies + |
| 4380 | (ha->fcoe_dev_init_timeout * HZ); |
| 4381 | break; |
| 4382 | case QLA8XXX_DEV_FAILED: |
| 4383 | if (ha->flags.nic_core_reset_owner) |
| 4384 | qla83xx_idc_audit(base_vha, |
| 4385 | IDC_AUDIT_COMPLETION); |
| 4386 | ha->flags.nic_core_reset_owner = 0; |
| 4387 | __qla83xx_clear_drv_presence(base_vha); |
| 4388 | qla83xx_idc_unlock(base_vha, 0); |
| 4389 | qla8xxx_dev_failed_handler(base_vha); |
| 4390 | rval = QLA_FUNCTION_FAILED; |
| 4391 | qla83xx_idc_lock(base_vha, 0); |
| 4392 | goto exit; |
| 4393 | case QLA8XXX_BAD_VALUE: |
| 4394 | qla83xx_idc_unlock(base_vha, 0); |
| 4395 | msleep(1000); |
| 4396 | qla83xx_idc_lock(base_vha, 0); |
| 4397 | break; |
| 4398 | default: |
| 4399 | ql_log(ql_log_warn, base_vha, 0xb071, |
| 4400 | "Unknow Device State: %x.\n", dev_state); |
| 4401 | qla83xx_idc_unlock(base_vha, 0); |
| 4402 | qla8xxx_dev_failed_handler(base_vha); |
| 4403 | rval = QLA_FUNCTION_FAILED; |
| 4404 | qla83xx_idc_lock(base_vha, 0); |
| 4405 | goto exit; |
| 4406 | } |
| 4407 | } |
| 4408 | |
| 4409 | exit: |
| 4410 | return rval; |
| 4411 | } |
| 4412 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4413 | /************************************************************************** |
| 4414 | * qla2x00_do_dpc |
| 4415 | * This kernel thread is a task that is schedule by the interrupt handler |
| 4416 | * to perform the background processing for interrupts. |
| 4417 | * |
| 4418 | * Notes: |
| 4419 | * This task always run in the context of a kernel thread. It |
| 4420 | * is kick-off by the driver's detect code and starts up |
| 4421 | * up one per adapter. It immediately goes to sleep and waits for |
| 4422 | * some fibre event. When either the interrupt handler or |
| 4423 | * the timer routine detects a event it will one of the task |
| 4424 | * bits then wake us up. |
| 4425 | **************************************************************************/ |
| 4426 | static int |
| 4427 | qla2x00_do_dpc(void *data) |
| 4428 | { |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4429 | int rval; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4430 | scsi_qla_host_t *base_vha; |
| 4431 | struct qla_hw_data *ha; |
Seokmann Ju | 99363ef | 2008-01-31 12:33:51 -0800 | [diff] [blame] | 4432 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4433 | ha = (struct qla_hw_data *)data; |
| 4434 | base_vha = pci_get_drvdata(ha->pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4435 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4436 | set_user_nice(current, -20); |
| 4437 | |
James Bottomley | 563585e | 2011-01-27 16:12:37 -0500 | [diff] [blame] | 4438 | set_current_state(TASK_INTERRUPTIBLE); |
Christoph Hellwig | 39a1124 | 2006-02-14 18:46:22 +0100 | [diff] [blame] | 4439 | while (!kthread_should_stop()) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4440 | ql_dbg(ql_dbg_dpc, base_vha, 0x4000, |
| 4441 | "DPC handler sleeping.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4442 | |
Christoph Hellwig | 39a1124 | 2006-02-14 18:46:22 +0100 | [diff] [blame] | 4443 | schedule(); |
| 4444 | __set_current_state(TASK_RUNNING); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4445 | |
Andrew Vasquez | c142caf | 2011-11-18 09:03:10 -0800 | [diff] [blame] | 4446 | if (!base_vha->flags.init_done || ha->flags.mbox_busy) |
| 4447 | goto end_loop; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4448 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 4449 | if (ha->flags.eeh_busy) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4450 | ql_dbg(ql_dbg_dpc, base_vha, 0x4003, |
| 4451 | "eeh_busy=%d.\n", ha->flags.eeh_busy); |
Andrew Vasquez | c142caf | 2011-11-18 09:03:10 -0800 | [diff] [blame] | 4452 | goto end_loop; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 4453 | } |
| 4454 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4455 | ha->dpc_active = 1; |
| 4456 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4457 | ql_dbg(ql_dbg_dpc + ql_dbg_verbose, base_vha, 0x4001, |
| 4458 | "DPC handler waking up, dpc_flags=0x%lx.\n", |
| 4459 | base_vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4460 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4461 | qla2x00_do_work(base_vha); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4462 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4463 | if (IS_QLA82XX(ha)) { |
| 4464 | if (test_and_clear_bit(ISP_UNRECOVERABLE, |
| 4465 | &base_vha->dpc_flags)) { |
| 4466 | qla82xx_idc_lock(ha); |
| 4467 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4468 | QLA8XXX_DEV_FAILED); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4469 | qla82xx_idc_unlock(ha); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4470 | ql_log(ql_log_info, base_vha, 0x4004, |
| 4471 | "HW State: FAILED.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4472 | qla82xx_device_state_handler(base_vha); |
| 4473 | continue; |
| 4474 | } |
| 4475 | |
| 4476 | if (test_and_clear_bit(FCOE_CTX_RESET_NEEDED, |
| 4477 | &base_vha->dpc_flags)) { |
| 4478 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4479 | ql_dbg(ql_dbg_dpc, base_vha, 0x4005, |
| 4480 | "FCoE context reset scheduled.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4481 | if (!(test_and_set_bit(ABORT_ISP_ACTIVE, |
| 4482 | &base_vha->dpc_flags))) { |
| 4483 | if (qla82xx_fcoe_ctx_reset(base_vha)) { |
| 4484 | /* FCoE-ctx reset failed. |
| 4485 | * Escalate to chip-reset |
| 4486 | */ |
| 4487 | set_bit(ISP_ABORT_NEEDED, |
| 4488 | &base_vha->dpc_flags); |
| 4489 | } |
| 4490 | clear_bit(ABORT_ISP_ACTIVE, |
| 4491 | &base_vha->dpc_flags); |
| 4492 | } |
| 4493 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4494 | ql_dbg(ql_dbg_dpc, base_vha, 0x4006, |
| 4495 | "FCoE context reset end.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4496 | } |
| 4497 | } |
| 4498 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4499 | if (test_and_clear_bit(ISP_ABORT_NEEDED, |
| 4500 | &base_vha->dpc_flags)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4501 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4502 | ql_dbg(ql_dbg_dpc, base_vha, 0x4007, |
| 4503 | "ISP abort scheduled.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4504 | if (!(test_and_set_bit(ABORT_ISP_ACTIVE, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4505 | &base_vha->dpc_flags))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4506 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4507 | if (ha->isp_ops->abort_isp(base_vha)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4508 | /* failed. retry later */ |
| 4509 | set_bit(ISP_ABORT_NEEDED, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4510 | &base_vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4511 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4512 | clear_bit(ABORT_ISP_ACTIVE, |
| 4513 | &base_vha->dpc_flags); |
Seokmann Ju | 99363ef | 2008-01-31 12:33:51 -0800 | [diff] [blame] | 4514 | } |
| 4515 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4516 | ql_dbg(ql_dbg_dpc, base_vha, 0x4008, |
| 4517 | "ISP abort end.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4518 | } |
| 4519 | |
David Jeffery | a394aac | 2012-11-21 02:39:54 -0500 | [diff] [blame] | 4520 | if (test_and_clear_bit(FCPORT_UPDATE_NEEDED, |
| 4521 | &base_vha->dpc_flags)) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4522 | qla2x00_update_fcports(base_vha); |
Andrew Vasquez | c9c5ced | 2008-07-24 08:31:49 -0700 | [diff] [blame] | 4523 | } |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 4524 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 4525 | if (test_bit(SCR_PENDING, &base_vha->dpc_flags)) { |
| 4526 | int ret; |
| 4527 | ret = qla2x00_send_change_request(base_vha, 0x3, 0); |
| 4528 | if (ret != QLA_SUCCESS) |
| 4529 | ql_log(ql_log_warn, base_vha, 0x121, |
| 4530 | "Failed to enable receiving of RSCN " |
| 4531 | "requests: 0x%x.\n", ret); |
| 4532 | clear_bit(SCR_PENDING, &base_vha->dpc_flags); |
| 4533 | } |
| 4534 | |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 4535 | if (test_bit(ISP_QUIESCE_NEEDED, &base_vha->dpc_flags)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4536 | ql_dbg(ql_dbg_dpc, base_vha, 0x4009, |
| 4537 | "Quiescence mode scheduled.\n"); |
Chad Dupuis | 8fcd6b8 | 2012-08-22 14:21:06 -0400 | [diff] [blame] | 4538 | if (IS_QLA82XX(ha)) { |
| 4539 | qla82xx_device_state_handler(base_vha); |
| 4540 | clear_bit(ISP_QUIESCE_NEEDED, |
| 4541 | &base_vha->dpc_flags); |
| 4542 | if (!ha->flags.quiesce_owner) { |
| 4543 | qla2x00_perform_loop_resync(base_vha); |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 4544 | |
Chad Dupuis | 8fcd6b8 | 2012-08-22 14:21:06 -0400 | [diff] [blame] | 4545 | qla82xx_idc_lock(ha); |
| 4546 | qla82xx_clear_qsnt_ready(base_vha); |
| 4547 | qla82xx_idc_unlock(ha); |
| 4548 | } |
| 4549 | } else { |
| 4550 | clear_bit(ISP_QUIESCE_NEEDED, |
| 4551 | &base_vha->dpc_flags); |
| 4552 | qla2x00_quiesce_io(base_vha); |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 4553 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4554 | ql_dbg(ql_dbg_dpc, base_vha, 0x400a, |
| 4555 | "Quiescence mode end.\n"); |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 4556 | } |
| 4557 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4558 | if (test_and_clear_bit(RESET_MARKER_NEEDED, |
| 4559 | &base_vha->dpc_flags) && |
| 4560 | (!(test_and_set_bit(RESET_ACTIVE, &base_vha->dpc_flags)))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4561 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4562 | ql_dbg(ql_dbg_dpc, base_vha, 0x400b, |
| 4563 | "Reset marker scheduled.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4564 | qla2x00_rst_aen(base_vha); |
| 4565 | clear_bit(RESET_ACTIVE, &base_vha->dpc_flags); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4566 | ql_dbg(ql_dbg_dpc, base_vha, 0x400c, |
| 4567 | "Reset marker end.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4568 | } |
| 4569 | |
| 4570 | /* Retry each device up to login retry count */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4571 | if ((test_and_clear_bit(RELOGIN_NEEDED, |
| 4572 | &base_vha->dpc_flags)) && |
| 4573 | !test_bit(LOOP_RESYNC_NEEDED, &base_vha->dpc_flags) && |
| 4574 | atomic_read(&base_vha->loop_state) != LOOP_DOWN) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4575 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4576 | ql_dbg(ql_dbg_dpc, base_vha, 0x400d, |
| 4577 | "Relogin scheduled.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4578 | qla2x00_relogin(base_vha); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4579 | ql_dbg(ql_dbg_dpc, base_vha, 0x400e, |
| 4580 | "Relogin end.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4581 | } |
| 4582 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4583 | if (test_and_clear_bit(LOOP_RESYNC_NEEDED, |
| 4584 | &base_vha->dpc_flags)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4585 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4586 | ql_dbg(ql_dbg_dpc, base_vha, 0x400f, |
| 4587 | "Loop resync scheduled.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4588 | |
| 4589 | if (!(test_and_set_bit(LOOP_RESYNC_ACTIVE, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4590 | &base_vha->dpc_flags))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4591 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4592 | rval = qla2x00_loop_resync(base_vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4593 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4594 | clear_bit(LOOP_RESYNC_ACTIVE, |
| 4595 | &base_vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4596 | } |
| 4597 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4598 | ql_dbg(ql_dbg_dpc, base_vha, 0x4010, |
| 4599 | "Loop resync end.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4600 | } |
| 4601 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4602 | if (test_bit(NPIV_CONFIG_NEEDED, &base_vha->dpc_flags) && |
| 4603 | atomic_read(&base_vha->loop_state) == LOOP_READY) { |
| 4604 | clear_bit(NPIV_CONFIG_NEEDED, &base_vha->dpc_flags); |
| 4605 | qla2xxx_flash_npiv_conf(base_vha); |
Andrew Vasquez | 272976c | 2008-09-11 21:22:50 -0700 | [diff] [blame] | 4606 | } |
| 4607 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4608 | if (!ha->interrupts_on) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 4609 | ha->isp_ops->enable_intrs(ha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4610 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4611 | if (test_and_clear_bit(BEACON_BLINK_NEEDED, |
| 4612 | &base_vha->dpc_flags)) |
| 4613 | ha->isp_ops->beacon_blink(base_vha); |
andrew.vasquez@qlogic.com | f6df144 | 2006-01-31 16:05:07 -0800 | [diff] [blame] | 4614 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4615 | qla2x00_do_dpc_all_vps(base_vha); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4616 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4617 | ha->dpc_active = 0; |
Andrew Vasquez | c142caf | 2011-11-18 09:03:10 -0800 | [diff] [blame] | 4618 | end_loop: |
James Bottomley | 563585e | 2011-01-27 16:12:37 -0500 | [diff] [blame] | 4619 | set_current_state(TASK_INTERRUPTIBLE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4620 | } /* End of while(1) */ |
James Bottomley | 563585e | 2011-01-27 16:12:37 -0500 | [diff] [blame] | 4621 | __set_current_state(TASK_RUNNING); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4622 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4623 | ql_dbg(ql_dbg_dpc, base_vha, 0x4011, |
| 4624 | "DPC handler exiting.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4625 | |
| 4626 | /* |
| 4627 | * Make sure that nobody tries to wake us up again. |
| 4628 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4629 | ha->dpc_active = 0; |
| 4630 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4631 | /* Cleanup any residual CTX SRBs. */ |
| 4632 | qla2x00_abort_all_cmds(base_vha, DID_NO_CONNECT << 16); |
| 4633 | |
Christoph Hellwig | 39a1124 | 2006-02-14 18:46:22 +0100 | [diff] [blame] | 4634 | return 0; |
| 4635 | } |
| 4636 | |
| 4637 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4638 | qla2xxx_wake_dpc(struct scsi_qla_host *vha) |
Christoph Hellwig | 39a1124 | 2006-02-14 18:46:22 +0100 | [diff] [blame] | 4639 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4640 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | c795c1e | 2008-08-13 21:37:01 -0700 | [diff] [blame] | 4641 | struct task_struct *t = ha->dpc_thread; |
| 4642 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4643 | if (!test_bit(UNLOADING, &vha->dpc_flags) && t) |
Andrew Vasquez | c795c1e | 2008-08-13 21:37:01 -0700 | [diff] [blame] | 4644 | wake_up_process(t); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4645 | } |
| 4646 | |
| 4647 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4648 | * qla2x00_rst_aen |
| 4649 | * Processes asynchronous reset. |
| 4650 | * |
| 4651 | * Input: |
| 4652 | * ha = adapter block pointer. |
| 4653 | */ |
| 4654 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4655 | qla2x00_rst_aen(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4656 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4657 | if (vha->flags.online && !vha->flags.reset_active && |
| 4658 | !atomic_read(&vha->loop_down_timer) && |
| 4659 | !(test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4660 | do { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4661 | clear_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4662 | |
| 4663 | /* |
| 4664 | * Issue marker command only when we are going to start |
| 4665 | * the I/O. |
| 4666 | */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4667 | vha->marker_needed = 1; |
| 4668 | } while (!atomic_read(&vha->loop_down_timer) && |
| 4669 | (test_bit(RESET_MARKER_NEEDED, &vha->dpc_flags))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4670 | } |
| 4671 | } |
| 4672 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4673 | /************************************************************************** |
| 4674 | * qla2x00_timer |
| 4675 | * |
| 4676 | * Description: |
| 4677 | * One second timer |
| 4678 | * |
| 4679 | * Context: Interrupt |
| 4680 | ***************************************************************************/ |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4681 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4682 | qla2x00_timer(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4683 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4684 | unsigned long cpu_flags = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4685 | int start_dpc = 0; |
| 4686 | int index; |
| 4687 | srb_t *sp; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 4688 | uint16_t w; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4689 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4690 | struct req_que *req; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 4691 | |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 4692 | if (ha->flags.eeh_busy) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4693 | ql_dbg(ql_dbg_timer, vha, 0x6000, |
| 4694 | "EEH = %d, restarting timer.\n", |
| 4695 | ha->flags.eeh_busy); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 4696 | qla2x00_restart_timer(vha, WATCH_INTERVAL); |
| 4697 | return; |
| 4698 | } |
| 4699 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 4700 | /* Hardware read to raise pending EEH errors during mailbox waits. */ |
| 4701 | if (!pci_channel_offline(ha->pdev)) |
| 4702 | pci_read_config_word(ha->pdev, PCI_VENDOR_ID, &w); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4703 | |
Saurav Kashyap | cefcaba | 2011-05-10 11:18:18 -0700 | [diff] [blame] | 4704 | /* Make sure qla82xx_watchdog is run only for physical port */ |
| 4705 | if (!vha->vp_idx && IS_QLA82XX(ha)) { |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 4706 | if (test_bit(ISP_QUIESCE_NEEDED, &vha->dpc_flags)) |
| 4707 | start_dpc++; |
| 4708 | qla82xx_watchdog(vha); |
| 4709 | } |
| 4710 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4711 | /* Loop down handler. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4712 | if (atomic_read(&vha->loop_down_timer) > 0 && |
Giridhar Malavali | 8f7daea | 2011-03-30 11:46:26 -0700 | [diff] [blame] | 4713 | !(test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags)) && |
| 4714 | !(test_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags)) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4715 | && vha->flags.online) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4716 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4717 | if (atomic_read(&vha->loop_down_timer) == |
| 4718 | vha->loop_down_abort_time) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4719 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4720 | ql_log(ql_log_info, vha, 0x6008, |
| 4721 | "Loop down - aborting the queues before time expires.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4722 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4723 | if (!IS_QLA2100(ha) && vha->link_down_timeout) |
| 4724 | atomic_set(&vha->loop_state, LOOP_DEAD); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4725 | |
Andrew Vasquez | f08b725 | 2010-01-12 12:59:48 -0800 | [diff] [blame] | 4726 | /* |
| 4727 | * Schedule an ISP abort to return any FCP2-device |
| 4728 | * commands. |
| 4729 | */ |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4730 | /* NPIV - scan physical port only */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4731 | if (!vha->vp_idx) { |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4732 | spin_lock_irqsave(&ha->hardware_lock, |
| 4733 | cpu_flags); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4734 | req = ha->req_q_map[0]; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4735 | for (index = 1; |
| 4736 | index < MAX_OUTSTANDING_COMMANDS; |
| 4737 | index++) { |
| 4738 | fc_port_t *sfcp; |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 4739 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4740 | sp = req->outstanding_cmds[index]; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4741 | if (!sp) |
| 4742 | continue; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 4743 | if (sp->type != SRB_SCSI_CMD) |
Andrew Vasquez | cf53b06 | 2009-08-20 11:06:04 -0700 | [diff] [blame] | 4744 | continue; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4745 | sfcp = sp->fcport; |
Andrew Vasquez | f08b725 | 2010-01-12 12:59:48 -0800 | [diff] [blame] | 4746 | if (!(sfcp->flags & FCF_FCP2_DEVICE)) |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4747 | continue; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4748 | |
Giridhar Malavali | 8f7daea | 2011-03-30 11:46:26 -0700 | [diff] [blame] | 4749 | if (IS_QLA82XX(ha)) |
| 4750 | set_bit(FCOE_CTX_RESET_NEEDED, |
| 4751 | &vha->dpc_flags); |
| 4752 | else |
| 4753 | set_bit(ISP_ABORT_NEEDED, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4754 | &vha->dpc_flags); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4755 | break; |
| 4756 | } |
| 4757 | spin_unlock_irqrestore(&ha->hardware_lock, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4758 | cpu_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4759 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4760 | start_dpc++; |
| 4761 | } |
| 4762 | |
| 4763 | /* if the loop has been down for 4 minutes, reinit adapter */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4764 | if (atomic_dec_and_test(&vha->loop_down_timer) != 0) { |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 4765 | if (!(vha->device_flags & DFLG_NO_CABLE)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4766 | ql_log(ql_log_warn, vha, 0x6009, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4767 | "Loop down - aborting ISP.\n"); |
| 4768 | |
Giridhar Malavali | 8f7daea | 2011-03-30 11:46:26 -0700 | [diff] [blame] | 4769 | if (IS_QLA82XX(ha)) |
| 4770 | set_bit(FCOE_CTX_RESET_NEEDED, |
| 4771 | &vha->dpc_flags); |
| 4772 | else |
| 4773 | set_bit(ISP_ABORT_NEEDED, |
| 4774 | &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4775 | } |
| 4776 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4777 | ql_dbg(ql_dbg_timer, vha, 0x600a, |
| 4778 | "Loop down - seconds remaining %d.\n", |
| 4779 | atomic_read(&vha->loop_down_timer)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4780 | } |
| 4781 | |
Saurav Kashyap | cefcaba | 2011-05-10 11:18:18 -0700 | [diff] [blame] | 4782 | /* Check if beacon LED needs to be blinked for physical host only */ |
| 4783 | if (!vha->vp_idx && (ha->beacon_blink_led == 1)) { |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 4784 | /* There is no beacon_blink function for ISP82xx */ |
| 4785 | if (!IS_QLA82XX(ha)) { |
| 4786 | set_bit(BEACON_BLINK_NEEDED, &vha->dpc_flags); |
| 4787 | start_dpc++; |
| 4788 | } |
andrew.vasquez@qlogic.com | f6df144 | 2006-01-31 16:05:07 -0800 | [diff] [blame] | 4789 | } |
| 4790 | |
Andrew Vasquez | 550bf57 | 2008-04-24 15:21:23 -0700 | [diff] [blame] | 4791 | /* Process any deferred work. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4792 | if (!list_empty(&vha->work_list)) |
Andrew Vasquez | 550bf57 | 2008-04-24 15:21:23 -0700 | [diff] [blame] | 4793 | start_dpc++; |
| 4794 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4795 | /* Schedule the DPC routine if needed */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4796 | if ((test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) || |
| 4797 | test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags) || |
| 4798 | test_bit(FCPORT_UPDATE_NEEDED, &vha->dpc_flags) || |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4799 | start_dpc || |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4800 | test_bit(RESET_MARKER_NEEDED, &vha->dpc_flags) || |
| 4801 | test_bit(BEACON_BLINK_NEEDED, &vha->dpc_flags) || |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4802 | test_bit(ISP_UNRECOVERABLE, &vha->dpc_flags) || |
| 4803 | test_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags) || |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4804 | test_bit(VP_DPC_NEEDED, &vha->dpc_flags) || |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4805 | test_bit(RELOGIN_NEEDED, &vha->dpc_flags))) { |
| 4806 | ql_dbg(ql_dbg_timer, vha, 0x600b, |
| 4807 | "isp_abort_needed=%d loop_resync_needed=%d " |
| 4808 | "fcport_update_needed=%d start_dpc=%d " |
| 4809 | "reset_marker_needed=%d", |
| 4810 | test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags), |
| 4811 | test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags), |
| 4812 | test_bit(FCPORT_UPDATE_NEEDED, &vha->dpc_flags), |
| 4813 | start_dpc, |
| 4814 | test_bit(RESET_MARKER_NEEDED, &vha->dpc_flags)); |
| 4815 | ql_dbg(ql_dbg_timer, vha, 0x600c, |
| 4816 | "beacon_blink_needed=%d isp_unrecoverable=%d " |
| 4817 | "fcoe_ctx_reset_needed=%d vp_dpc_needed=%d " |
| 4818 | "relogin_needed=%d.\n", |
| 4819 | test_bit(BEACON_BLINK_NEEDED, &vha->dpc_flags), |
| 4820 | test_bit(ISP_UNRECOVERABLE, &vha->dpc_flags), |
| 4821 | test_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags), |
| 4822 | test_bit(VP_DPC_NEEDED, &vha->dpc_flags), |
| 4823 | test_bit(RELOGIN_NEEDED, &vha->dpc_flags)); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4824 | qla2xxx_wake_dpc(vha); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4825 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4826 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4827 | qla2x00_restart_timer(vha, WATCH_INTERVAL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4828 | } |
| 4829 | |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4830 | /* Firmware interface routines. */ |
| 4831 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4832 | #define FW_BLOBS 10 |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4833 | #define FW_ISP21XX 0 |
| 4834 | #define FW_ISP22XX 1 |
| 4835 | #define FW_ISP2300 2 |
| 4836 | #define FW_ISP2322 3 |
andrew.vasquez@qlogic.com | 48c02fd | 2006-03-09 14:27:18 -0800 | [diff] [blame] | 4837 | #define FW_ISP24XX 4 |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 4838 | #define FW_ISP25XX 5 |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 4839 | #define FW_ISP81XX 6 |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4840 | #define FW_ISP82XX 7 |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4841 | #define FW_ISP2031 8 |
| 4842 | #define FW_ISP8031 9 |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4843 | |
Andrew Vasquez | bb8ee49 | 2006-10-02 12:00:48 -0700 | [diff] [blame] | 4844 | #define FW_FILE_ISP21XX "ql2100_fw.bin" |
| 4845 | #define FW_FILE_ISP22XX "ql2200_fw.bin" |
| 4846 | #define FW_FILE_ISP2300 "ql2300_fw.bin" |
| 4847 | #define FW_FILE_ISP2322 "ql2322_fw.bin" |
| 4848 | #define FW_FILE_ISP24XX "ql2400_fw.bin" |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 4849 | #define FW_FILE_ISP25XX "ql2500_fw.bin" |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 4850 | #define FW_FILE_ISP81XX "ql8100_fw.bin" |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4851 | #define FW_FILE_ISP82XX "ql8200_fw.bin" |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4852 | #define FW_FILE_ISP2031 "ql2600_fw.bin" |
| 4853 | #define FW_FILE_ISP8031 "ql8300_fw.bin" |
Andrew Vasquez | bb8ee49 | 2006-10-02 12:00:48 -0700 | [diff] [blame] | 4854 | |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 4855 | static DEFINE_MUTEX(qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4856 | |
| 4857 | static struct fw_blob qla_fw_blobs[FW_BLOBS] = { |
Andrew Vasquez | bb8ee49 | 2006-10-02 12:00:48 -0700 | [diff] [blame] | 4858 | { .name = FW_FILE_ISP21XX, .segs = { 0x1000, 0 }, }, |
| 4859 | { .name = FW_FILE_ISP22XX, .segs = { 0x1000, 0 }, }, |
| 4860 | { .name = FW_FILE_ISP2300, .segs = { 0x800, 0 }, }, |
| 4861 | { .name = FW_FILE_ISP2322, .segs = { 0x800, 0x1c000, 0x1e000, 0 }, }, |
| 4862 | { .name = FW_FILE_ISP24XX, }, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 4863 | { .name = FW_FILE_ISP25XX, }, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 4864 | { .name = FW_FILE_ISP81XX, }, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4865 | { .name = FW_FILE_ISP82XX, }, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4866 | { .name = FW_FILE_ISP2031, }, |
| 4867 | { .name = FW_FILE_ISP8031, }, |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4868 | }; |
| 4869 | |
| 4870 | struct fw_blob * |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4871 | qla2x00_request_firmware(scsi_qla_host_t *vha) |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4872 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4873 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4874 | struct fw_blob *blob; |
| 4875 | |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4876 | if (IS_QLA2100(ha)) { |
| 4877 | blob = &qla_fw_blobs[FW_ISP21XX]; |
| 4878 | } else if (IS_QLA2200(ha)) { |
| 4879 | blob = &qla_fw_blobs[FW_ISP22XX]; |
andrew.vasquez@qlogic.com | 48c02fd | 2006-03-09 14:27:18 -0800 | [diff] [blame] | 4880 | } else if (IS_QLA2300(ha) || IS_QLA2312(ha) || IS_QLA6312(ha)) { |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4881 | blob = &qla_fw_blobs[FW_ISP2300]; |
andrew.vasquez@qlogic.com | 48c02fd | 2006-03-09 14:27:18 -0800 | [diff] [blame] | 4882 | } else if (IS_QLA2322(ha) || IS_QLA6322(ha)) { |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4883 | blob = &qla_fw_blobs[FW_ISP2322]; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4884 | } else if (IS_QLA24XX_TYPE(ha)) { |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4885 | blob = &qla_fw_blobs[FW_ISP24XX]; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 4886 | } else if (IS_QLA25XX(ha)) { |
| 4887 | blob = &qla_fw_blobs[FW_ISP25XX]; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 4888 | } else if (IS_QLA81XX(ha)) { |
| 4889 | blob = &qla_fw_blobs[FW_ISP81XX]; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4890 | } else if (IS_QLA82XX(ha)) { |
| 4891 | blob = &qla_fw_blobs[FW_ISP82XX]; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4892 | } else if (IS_QLA2031(ha)) { |
| 4893 | blob = &qla_fw_blobs[FW_ISP2031]; |
| 4894 | } else if (IS_QLA8031(ha)) { |
| 4895 | blob = &qla_fw_blobs[FW_ISP8031]; |
Dan Carpenter | 8a65522 | 2012-02-21 10:29:40 +0300 | [diff] [blame] | 4896 | } else { |
| 4897 | return NULL; |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4898 | } |
| 4899 | |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 4900 | mutex_lock(&qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4901 | if (blob->fw) |
| 4902 | goto out; |
| 4903 | |
| 4904 | if (request_firmware(&blob->fw, blob->name, &ha->pdev->dev)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4905 | ql_log(ql_log_warn, vha, 0x0063, |
| 4906 | "Failed to load firmware image (%s).\n", blob->name); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4907 | blob->fw = NULL; |
| 4908 | blob = NULL; |
| 4909 | goto out; |
| 4910 | } |
| 4911 | |
| 4912 | out: |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 4913 | mutex_unlock(&qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4914 | return blob; |
| 4915 | } |
| 4916 | |
| 4917 | static void |
| 4918 | qla2x00_release_firmware(void) |
| 4919 | { |
| 4920 | int idx; |
| 4921 | |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 4922 | mutex_lock(&qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4923 | for (idx = 0; idx < FW_BLOBS; idx++) |
Jesper Juhl | cf92549 | 2012-04-09 22:51:41 +0200 | [diff] [blame] | 4924 | release_firmware(qla_fw_blobs[idx].fw); |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 4925 | mutex_unlock(&qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4926 | } |
| 4927 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 4928 | static pci_ers_result_t |
| 4929 | qla2xxx_pci_error_detected(struct pci_dev *pdev, pci_channel_state_t state) |
| 4930 | { |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 4931 | scsi_qla_host_t *vha = pci_get_drvdata(pdev); |
| 4932 | struct qla_hw_data *ha = vha->hw; |
| 4933 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4934 | ql_dbg(ql_dbg_aer, vha, 0x9000, |
| 4935 | "PCI error detected, state %x.\n", state); |
Seokmann Ju | b9b12f7 | 2009-03-24 09:08:18 -0700 | [diff] [blame] | 4936 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 4937 | switch (state) { |
| 4938 | case pci_channel_io_normal: |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 4939 | ha->flags.eeh_busy = 0; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 4940 | return PCI_ERS_RESULT_CAN_RECOVER; |
| 4941 | case pci_channel_io_frozen: |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 4942 | ha->flags.eeh_busy = 1; |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 4943 | /* For ISP82XX complete any pending mailbox cmd */ |
| 4944 | if (IS_QLA82XX(ha)) { |
Giridhar Malavali | 7190575 | 2011-02-23 15:27:10 -0800 | [diff] [blame] | 4945 | ha->flags.isp82xx_fw_hung = 1; |
Chad Dupuis | c8f6544 | 2011-11-18 09:02:17 -0800 | [diff] [blame] | 4946 | ql_dbg(ql_dbg_aer, vha, 0x9001, "Pci channel io frozen\n"); |
| 4947 | qla82xx_clear_pending_mbx(vha); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 4948 | } |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 4949 | qla2x00_free_irqs(vha); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 4950 | pci_disable_device(pdev); |
Lalit Chandivade | bddd2d6 | 2010-09-03 15:20:53 -0700 | [diff] [blame] | 4951 | /* Return back all IOs */ |
| 4952 | qla2x00_abort_all_cmds(vha, DID_RESET << 16); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 4953 | return PCI_ERS_RESULT_NEED_RESET; |
| 4954 | case pci_channel_io_perm_failure: |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 4955 | ha->flags.pci_channel_io_perm_failure = 1; |
| 4956 | qla2x00_abort_all_cmds(vha, DID_NO_CONNECT << 16); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 4957 | return PCI_ERS_RESULT_DISCONNECT; |
| 4958 | } |
| 4959 | return PCI_ERS_RESULT_NEED_RESET; |
| 4960 | } |
| 4961 | |
| 4962 | static pci_ers_result_t |
| 4963 | qla2xxx_pci_mmio_enabled(struct pci_dev *pdev) |
| 4964 | { |
| 4965 | int risc_paused = 0; |
| 4966 | uint32_t stat; |
| 4967 | unsigned long flags; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4968 | scsi_qla_host_t *base_vha = pci_get_drvdata(pdev); |
| 4969 | struct qla_hw_data *ha = base_vha->hw; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 4970 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
| 4971 | struct device_reg_24xx __iomem *reg24 = &ha->iobase->isp24; |
| 4972 | |
Saurav Kashyap | bcc5b6d | 2010-09-03 15:20:57 -0700 | [diff] [blame] | 4973 | if (IS_QLA82XX(ha)) |
| 4974 | return PCI_ERS_RESULT_RECOVERED; |
| 4975 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 4976 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 4977 | if (IS_QLA2100(ha) || IS_QLA2200(ha)){ |
| 4978 | stat = RD_REG_DWORD(®->hccr); |
| 4979 | if (stat & HCCR_RISC_PAUSE) |
| 4980 | risc_paused = 1; |
| 4981 | } else if (IS_QLA23XX(ha)) { |
| 4982 | stat = RD_REG_DWORD(®->u.isp2300.host_status); |
| 4983 | if (stat & HSR_RISC_PAUSED) |
| 4984 | risc_paused = 1; |
| 4985 | } else if (IS_FWI2_CAPABLE(ha)) { |
| 4986 | stat = RD_REG_DWORD(®24->host_status); |
| 4987 | if (stat & HSRX_RISC_PAUSED) |
| 4988 | risc_paused = 1; |
| 4989 | } |
| 4990 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 4991 | |
| 4992 | if (risc_paused) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4993 | ql_log(ql_log_info, base_vha, 0x9003, |
| 4994 | "RISC paused -- mmio_enabled, Dumping firmware.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4995 | ha->isp_ops->fw_dump(base_vha, 0); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 4996 | |
| 4997 | return PCI_ERS_RESULT_NEED_RESET; |
| 4998 | } else |
| 4999 | return PCI_ERS_RESULT_RECOVERED; |
| 5000 | } |
| 5001 | |
Saurav Kashyap | fa49263 | 2012-11-21 02:40:29 -0500 | [diff] [blame] | 5002 | static uint32_t |
| 5003 | qla82xx_error_recovery(scsi_qla_host_t *base_vha) |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5004 | { |
| 5005 | uint32_t rval = QLA_FUNCTION_FAILED; |
| 5006 | uint32_t drv_active = 0; |
| 5007 | struct qla_hw_data *ha = base_vha->hw; |
| 5008 | int fn; |
| 5009 | struct pci_dev *other_pdev = NULL; |
| 5010 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5011 | ql_dbg(ql_dbg_aer, base_vha, 0x9006, |
| 5012 | "Entered %s.\n", __func__); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5013 | |
| 5014 | set_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
| 5015 | |
| 5016 | if (base_vha->flags.online) { |
| 5017 | /* Abort all outstanding commands, |
| 5018 | * so as to be requeued later */ |
| 5019 | qla2x00_abort_isp_cleanup(base_vha); |
| 5020 | } |
| 5021 | |
| 5022 | |
| 5023 | fn = PCI_FUNC(ha->pdev->devfn); |
| 5024 | while (fn > 0) { |
| 5025 | fn--; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5026 | ql_dbg(ql_dbg_aer, base_vha, 0x9007, |
| 5027 | "Finding pci device at function = 0x%x.\n", fn); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5028 | other_pdev = |
| 5029 | pci_get_domain_bus_and_slot(pci_domain_nr(ha->pdev->bus), |
| 5030 | ha->pdev->bus->number, PCI_DEVFN(PCI_SLOT(ha->pdev->devfn), |
| 5031 | fn)); |
| 5032 | |
| 5033 | if (!other_pdev) |
| 5034 | continue; |
| 5035 | if (atomic_read(&other_pdev->enable_cnt)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5036 | ql_dbg(ql_dbg_aer, base_vha, 0x9008, |
| 5037 | "Found PCI func available and enable at 0x%x.\n", |
| 5038 | fn); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5039 | pci_dev_put(other_pdev); |
| 5040 | break; |
| 5041 | } |
| 5042 | pci_dev_put(other_pdev); |
| 5043 | } |
| 5044 | |
| 5045 | if (!fn) { |
| 5046 | /* Reset owner */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5047 | ql_dbg(ql_dbg_aer, base_vha, 0x9009, |
| 5048 | "This devfn is reset owner = 0x%x.\n", |
| 5049 | ha->pdev->devfn); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5050 | qla82xx_idc_lock(ha); |
| 5051 | |
| 5052 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5053 | QLA8XXX_DEV_INITIALIZING); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5054 | |
| 5055 | qla82xx_wr_32(ha, QLA82XX_CRB_DRV_IDC_VERSION, |
| 5056 | QLA82XX_IDC_VERSION); |
| 5057 | |
| 5058 | drv_active = qla82xx_rd_32(ha, QLA82XX_CRB_DRV_ACTIVE); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5059 | ql_dbg(ql_dbg_aer, base_vha, 0x900a, |
| 5060 | "drv_active = 0x%x.\n", drv_active); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5061 | |
| 5062 | qla82xx_idc_unlock(ha); |
| 5063 | /* Reset if device is not already reset |
| 5064 | * drv_active would be 0 if a reset has already been done |
| 5065 | */ |
| 5066 | if (drv_active) |
| 5067 | rval = qla82xx_start_firmware(base_vha); |
| 5068 | else |
| 5069 | rval = QLA_SUCCESS; |
| 5070 | qla82xx_idc_lock(ha); |
| 5071 | |
| 5072 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5073 | ql_log(ql_log_info, base_vha, 0x900b, |
| 5074 | "HW State: FAILED.\n"); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5075 | qla82xx_clear_drv_active(ha); |
| 5076 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5077 | QLA8XXX_DEV_FAILED); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5078 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5079 | ql_log(ql_log_info, base_vha, 0x900c, |
| 5080 | "HW State: READY.\n"); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5081 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5082 | QLA8XXX_DEV_READY); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5083 | qla82xx_idc_unlock(ha); |
Giridhar Malavali | 7190575 | 2011-02-23 15:27:10 -0800 | [diff] [blame] | 5084 | ha->flags.isp82xx_fw_hung = 0; |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5085 | rval = qla82xx_restart_isp(base_vha); |
| 5086 | qla82xx_idc_lock(ha); |
| 5087 | /* Clear driver state register */ |
| 5088 | qla82xx_wr_32(ha, QLA82XX_CRB_DRV_STATE, 0); |
| 5089 | qla82xx_set_drv_active(base_vha); |
| 5090 | } |
| 5091 | qla82xx_idc_unlock(ha); |
| 5092 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5093 | ql_dbg(ql_dbg_aer, base_vha, 0x900d, |
| 5094 | "This devfn is not reset owner = 0x%x.\n", |
| 5095 | ha->pdev->devfn); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5096 | if ((qla82xx_rd_32(ha, QLA82XX_CRB_DEV_STATE) == |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5097 | QLA8XXX_DEV_READY)) { |
Giridhar Malavali | 7190575 | 2011-02-23 15:27:10 -0800 | [diff] [blame] | 5098 | ha->flags.isp82xx_fw_hung = 0; |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5099 | rval = qla82xx_restart_isp(base_vha); |
| 5100 | qla82xx_idc_lock(ha); |
| 5101 | qla82xx_set_drv_active(base_vha); |
| 5102 | qla82xx_idc_unlock(ha); |
| 5103 | } |
| 5104 | } |
| 5105 | clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
| 5106 | |
| 5107 | return rval; |
| 5108 | } |
| 5109 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5110 | static pci_ers_result_t |
| 5111 | qla2xxx_pci_slot_reset(struct pci_dev *pdev) |
| 5112 | { |
| 5113 | pci_ers_result_t ret = PCI_ERS_RESULT_DISCONNECT; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5114 | scsi_qla_host_t *base_vha = pci_get_drvdata(pdev); |
| 5115 | struct qla_hw_data *ha = base_vha->hw; |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 5116 | struct rsp_que *rsp; |
| 5117 | int rc, retries = 10; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5118 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5119 | ql_dbg(ql_dbg_aer, base_vha, 0x9004, |
| 5120 | "Slot Reset.\n"); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5121 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 5122 | /* Workaround: qla2xxx driver which access hardware earlier |
| 5123 | * needs error state to be pci_channel_io_online. |
| 5124 | * Otherwise mailbox command timesout. |
| 5125 | */ |
| 5126 | pdev->error_state = pci_channel_io_normal; |
| 5127 | |
| 5128 | pci_restore_state(pdev); |
| 5129 | |
Richard Lary | 8c1496b | 2010-02-18 10:07:29 -0800 | [diff] [blame] | 5130 | /* pci_restore_state() clears the saved_state flag of the device |
| 5131 | * save restored state which resets saved_state flag |
| 5132 | */ |
| 5133 | pci_save_state(pdev); |
| 5134 | |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 5135 | if (ha->mem_only) |
| 5136 | rc = pci_enable_device_mem(pdev); |
| 5137 | else |
| 5138 | rc = pci_enable_device(pdev); |
| 5139 | |
| 5140 | if (rc) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5141 | ql_log(ql_log_warn, base_vha, 0x9005, |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5142 | "Can't re-enable PCI device after reset.\n"); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5143 | goto exit_slot_reset; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5144 | } |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5145 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 5146 | rsp = ha->rsp_q_map[0]; |
| 5147 | if (qla2x00_request_irqs(ha, rsp)) |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5148 | goto exit_slot_reset; |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 5149 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5150 | if (ha->isp_ops->pci_config(base_vha)) |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5151 | goto exit_slot_reset; |
| 5152 | |
| 5153 | if (IS_QLA82XX(ha)) { |
| 5154 | if (qla82xx_error_recovery(base_vha) == QLA_SUCCESS) { |
| 5155 | ret = PCI_ERS_RESULT_RECOVERED; |
| 5156 | goto exit_slot_reset; |
| 5157 | } else |
| 5158 | goto exit_slot_reset; |
| 5159 | } |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5160 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 5161 | while (ha->flags.mbox_busy && retries--) |
| 5162 | msleep(1000); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5163 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5164 | set_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5165 | if (ha->isp_ops->abort_isp(base_vha) == QLA_SUCCESS) |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5166 | ret = PCI_ERS_RESULT_RECOVERED; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5167 | clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5168 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 5169 | |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5170 | exit_slot_reset: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5171 | ql_dbg(ql_dbg_aer, base_vha, 0x900e, |
| 5172 | "slot_reset return %x.\n", ret); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5173 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5174 | return ret; |
| 5175 | } |
| 5176 | |
| 5177 | static void |
| 5178 | qla2xxx_pci_resume(struct pci_dev *pdev) |
| 5179 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5180 | scsi_qla_host_t *base_vha = pci_get_drvdata(pdev); |
| 5181 | struct qla_hw_data *ha = base_vha->hw; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5182 | int ret; |
| 5183 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5184 | ql_dbg(ql_dbg_aer, base_vha, 0x900f, |
| 5185 | "pci_resume.\n"); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5186 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5187 | ret = qla2x00_wait_for_hba_online(base_vha); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5188 | if (ret != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5189 | ql_log(ql_log_fatal, base_vha, 0x9002, |
| 5190 | "The device failed to resume I/O from slot/link_reset.\n"); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5191 | } |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5192 | |
Lalit Chandivade | 3e46f03 | 2010-05-04 15:01:23 -0700 | [diff] [blame] | 5193 | pci_cleanup_aer_uncorrect_error_status(pdev); |
| 5194 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5195 | ha->flags.eeh_busy = 0; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5196 | } |
| 5197 | |
Stephen Hemminger | a55b2d2 | 2012-09-07 09:33:16 -0700 | [diff] [blame] | 5198 | static const struct pci_error_handlers qla2xxx_err_handler = { |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5199 | .error_detected = qla2xxx_pci_error_detected, |
| 5200 | .mmio_enabled = qla2xxx_pci_mmio_enabled, |
| 5201 | .slot_reset = qla2xxx_pci_slot_reset, |
| 5202 | .resume = qla2xxx_pci_resume, |
| 5203 | }; |
| 5204 | |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5205 | static struct pci_device_id qla2xxx_pci_tbl[] = { |
Andrew Vasquez | 47f5e06 | 2006-05-17 15:09:39 -0700 | [diff] [blame] | 5206 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2100) }, |
| 5207 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2200) }, |
| 5208 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2300) }, |
| 5209 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2312) }, |
| 5210 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2322) }, |
| 5211 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP6312) }, |
| 5212 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP6322) }, |
| 5213 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2422) }, |
| 5214 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2432) }, |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 5215 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8432) }, |
Andrew Vasquez | 47f5e06 | 2006-05-17 15:09:39 -0700 | [diff] [blame] | 5216 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP5422) }, |
| 5217 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP5432) }, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 5218 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2532) }, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5219 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2031) }, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5220 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8001) }, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5221 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8021) }, |
Chad Dupuis | 650f528 | 2012-08-22 14:20:55 -0400 | [diff] [blame] | 5222 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8031) }, |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5223 | { 0 }, |
| 5224 | }; |
| 5225 | MODULE_DEVICE_TABLE(pci, qla2xxx_pci_tbl); |
| 5226 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 5227 | static struct pci_driver qla2xxx_pci_driver = { |
Andrew Vasquez | cb63067 | 2006-05-17 15:09:45 -0700 | [diff] [blame] | 5228 | .name = QLA2XXX_DRIVER_NAME, |
James Bottomley | 0a21ef1 | 2005-12-01 12:51:50 -0600 | [diff] [blame] | 5229 | .driver = { |
| 5230 | .owner = THIS_MODULE, |
| 5231 | }, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 5232 | .id_table = qla2xxx_pci_tbl, |
Andrew Vasquez | 7ee6139 | 2006-06-23 16:11:22 -0700 | [diff] [blame] | 5233 | .probe = qla2x00_probe_one, |
Adrian Bunk | 4c993f7 | 2008-01-14 00:55:16 -0800 | [diff] [blame] | 5234 | .remove = qla2x00_remove_one, |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 5235 | .shutdown = qla2x00_shutdown, |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5236 | .err_handler = &qla2xxx_err_handler, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 5237 | }; |
| 5238 | |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 5239 | static struct file_operations apidev_fops = { |
| 5240 | .owner = THIS_MODULE, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 5241 | .llseek = noop_llseek, |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 5242 | }; |
| 5243 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5244 | /** |
| 5245 | * qla2x00_module_init - Module initialization. |
| 5246 | **/ |
| 5247 | static int __init |
| 5248 | qla2x00_module_init(void) |
| 5249 | { |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 5250 | int ret = 0; |
| 5251 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5252 | /* Allocate cache for SRBs. */ |
Andrew Vasquez | 354d6b2 | 2005-04-23 02:47:27 -0400 | [diff] [blame] | 5253 | srb_cachep = kmem_cache_create("qla2xxx_srbs", sizeof(srb_t), 0, |
Paul Mundt | 20c2df8 | 2007-07-20 10:11:58 +0900 | [diff] [blame] | 5254 | SLAB_HWCACHE_ALIGN, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5255 | if (srb_cachep == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5256 | ql_log(ql_log_fatal, NULL, 0x0001, |
| 5257 | "Unable to allocate SRB cache...Failing load!.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5258 | return -ENOMEM; |
| 5259 | } |
| 5260 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 5261 | /* Initialize target kmem_cache and mem_pools */ |
| 5262 | ret = qlt_init(); |
| 5263 | if (ret < 0) { |
| 5264 | kmem_cache_destroy(srb_cachep); |
| 5265 | return ret; |
| 5266 | } else if (ret > 0) { |
| 5267 | /* |
| 5268 | * If initiator mode is explictly disabled by qlt_init(), |
| 5269 | * prevent scsi_transport_fc.c:fc_scsi_scan_rport() from |
| 5270 | * performing scsi_scan_target() during LOOP UP event. |
| 5271 | */ |
| 5272 | qla2xxx_transport_functions.disable_target_scan = 1; |
| 5273 | qla2xxx_transport_vport_functions.disable_target_scan = 1; |
| 5274 | } |
| 5275 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5276 | /* Derive version string. */ |
| 5277 | strcpy(qla2x00_version_str, QLA2XXX_VERSION); |
Andrew Vasquez | 11010fe | 2006-10-06 09:54:59 -0700 | [diff] [blame] | 5278 | if (ql2xextended_error_logging) |
Andrew Vasquez | 0181944 | 2006-06-23 16:11:10 -0700 | [diff] [blame] | 5279 | strcat(qla2x00_version_str, "-debug"); |
| 5280 | |
Andrew Vasquez | 1c97a12 | 2005-04-21 16:13:36 -0400 | [diff] [blame] | 5281 | qla2xxx_transport_template = |
| 5282 | fc_attach_transport(&qla2xxx_transport_functions); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5283 | if (!qla2xxx_transport_template) { |
| 5284 | kmem_cache_destroy(srb_cachep); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5285 | ql_log(ql_log_fatal, NULL, 0x0002, |
| 5286 | "fc_attach_transport failed...Failing load!.\n"); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 5287 | qlt_exit(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5288 | return -ENODEV; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5289 | } |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 5290 | |
| 5291 | apidev_major = register_chrdev(0, QLA2XXX_APIDEV, &apidev_fops); |
| 5292 | if (apidev_major < 0) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5293 | ql_log(ql_log_fatal, NULL, 0x0003, |
| 5294 | "Unable to register char device %s.\n", QLA2XXX_APIDEV); |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 5295 | } |
| 5296 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5297 | qla2xxx_transport_vport_template = |
| 5298 | fc_attach_transport(&qla2xxx_transport_vport_functions); |
| 5299 | if (!qla2xxx_transport_vport_template) { |
| 5300 | kmem_cache_destroy(srb_cachep); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 5301 | qlt_exit(); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5302 | fc_release_transport(qla2xxx_transport_template); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5303 | ql_log(ql_log_fatal, NULL, 0x0004, |
| 5304 | "fc_attach_transport vport failed...Failing load!.\n"); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5305 | return -ENODEV; |
| 5306 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5307 | ql_log(ql_log_info, NULL, 0x0005, |
| 5308 | "QLogic Fibre Channel HBA Driver: %s.\n", |
Andrew Vasquez | fd9a29f0 | 2008-05-12 22:21:08 -0700 | [diff] [blame] | 5309 | qla2x00_version_str); |
Andrew Vasquez | 7ee6139 | 2006-06-23 16:11:22 -0700 | [diff] [blame] | 5310 | ret = pci_register_driver(&qla2xxx_pci_driver); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 5311 | if (ret) { |
| 5312 | kmem_cache_destroy(srb_cachep); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 5313 | qlt_exit(); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 5314 | fc_release_transport(qla2xxx_transport_template); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5315 | fc_release_transport(qla2xxx_transport_vport_template); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5316 | ql_log(ql_log_fatal, NULL, 0x0006, |
| 5317 | "pci_register_driver failed...ret=%d Failing load!.\n", |
| 5318 | ret); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 5319 | } |
| 5320 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5321 | } |
| 5322 | |
| 5323 | /** |
| 5324 | * qla2x00_module_exit - Module cleanup. |
| 5325 | **/ |
| 5326 | static void __exit |
| 5327 | qla2x00_module_exit(void) |
| 5328 | { |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 5329 | unregister_chrdev(apidev_major, QLA2XXX_APIDEV); |
Andrew Vasquez | 7ee6139 | 2006-06-23 16:11:22 -0700 | [diff] [blame] | 5330 | pci_unregister_driver(&qla2xxx_pci_driver); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5331 | qla2x00_release_firmware(); |
Andrew Vasquez | 354d6b2 | 2005-04-23 02:47:27 -0400 | [diff] [blame] | 5332 | kmem_cache_destroy(srb_cachep); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 5333 | qlt_exit(); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5334 | if (ctx_cachep) |
| 5335 | kmem_cache_destroy(ctx_cachep); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5336 | fc_release_transport(qla2xxx_transport_template); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5337 | fc_release_transport(qla2xxx_transport_vport_template); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5338 | } |
| 5339 | |
| 5340 | module_init(qla2x00_module_init); |
| 5341 | module_exit(qla2x00_module_exit); |
| 5342 | |
| 5343 | MODULE_AUTHOR("QLogic Corporation"); |
| 5344 | MODULE_DESCRIPTION("QLogic Fibre Channel HBA Driver"); |
| 5345 | MODULE_LICENSE("GPL"); |
| 5346 | MODULE_VERSION(QLA2XXX_VERSION); |
Andrew Vasquez | bb8ee49 | 2006-10-02 12:00:48 -0700 | [diff] [blame] | 5347 | MODULE_FIRMWARE(FW_FILE_ISP21XX); |
| 5348 | MODULE_FIRMWARE(FW_FILE_ISP22XX); |
| 5349 | MODULE_FIRMWARE(FW_FILE_ISP2300); |
| 5350 | MODULE_FIRMWARE(FW_FILE_ISP2322); |
| 5351 | MODULE_FIRMWARE(FW_FILE_ISP24XX); |
Andrew Vasquez | 61623fc | 2008-01-31 12:33:45 -0800 | [diff] [blame] | 5352 | MODULE_FIRMWARE(FW_FILE_ISP25XX); |