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 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 44 | int ql2xenableclass2; |
| 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" |
| 92 | "\t\t0x7fffffff - For enabling all logs, can be too many logs.\n" |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 93 | "\t\t0x1e400000 - Preferred value for capturing essential " |
| 94 | "debug information (equivalent to old " |
| 95 | "ql2xextended_error_logging=1).\n" |
Saurav Kashyap | 3ce8866 | 2011-07-14 12:00:12 -0700 | [diff] [blame] | 96 | "\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] | 97 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 98 | int ql2xshiftctondsd = 6; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 99 | module_param(ql2xshiftctondsd, int, S_IRUGO); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 100 | MODULE_PARM_DESC(ql2xshiftctondsd, |
| 101 | "Set to control shifting of command type processing " |
| 102 | "based on total number of SG elements."); |
| 103 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 104 | static void qla2x00_free_device(scsi_qla_host_t *); |
| 105 | |
Andrew Vasquez | 7e47e5c | 2008-04-24 15:21:26 -0700 | [diff] [blame] | 106 | int ql2xfdmienable=1; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 107 | module_param(ql2xfdmienable, int, S_IRUGO); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 108 | MODULE_PARM_DESC(ql2xfdmienable, |
Ferenc Wagner | 7794a5a | 2010-03-23 18:14:59 +0100 | [diff] [blame] | 109 | "Enables FDMI registrations. " |
| 110 | "0 - no FDMI. Default is 1 - perform FDMI."); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 111 | |
Andrew Vasquez | df7baa5 | 2006-10-13 09:33:39 -0700 | [diff] [blame] | 112 | #define MAX_Q_DEPTH 32 |
| 113 | static int ql2xmaxqdepth = MAX_Q_DEPTH; |
| 114 | module_param(ql2xmaxqdepth, int, S_IRUGO|S_IWUSR); |
| 115 | MODULE_PARM_DESC(ql2xmaxqdepth, |
Chad Dupuis | e92e4a8 | 2012-08-22 14:21:23 -0400 | [diff] [blame] | 116 | "Maximum queue depth to set for each LUN. " |
| 117 | "Default is 32."); |
Andrew Vasquez | df7baa5 | 2006-10-13 09:33:39 -0700 | [diff] [blame] | 118 | |
Arun Easi | 9e522cd | 2012-08-22 14:21:31 -0400 | [diff] [blame] | 119 | int ql2xenabledif = 2; |
| 120 | module_param(ql2xenabledif, int, S_IRUGO); |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 121 | MODULE_PARM_DESC(ql2xenabledif, |
| 122 | " Enable T10-CRC-DIF " |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 123 | " Default is 0 - No DIF Support. 1 - Enable it" |
| 124 | ", 2 - Enable DIF for all types, except Type 0."); |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 125 | |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 126 | int ql2xenablehba_err_chk = 2; |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 127 | module_param(ql2xenablehba_err_chk, int, S_IRUGO|S_IWUSR); |
| 128 | MODULE_PARM_DESC(ql2xenablehba_err_chk, |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 129 | " Enable T10-CRC-DIF Error isolation by HBA:\n" |
| 130 | " Default is 1.\n" |
| 131 | " 0 -- Error isolation disabled\n" |
| 132 | " 1 -- Error isolation enabled only for DIX Type 0\n" |
| 133 | " 2 -- Error isolation enabled for all Types\n"); |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 134 | |
Andrew Vasquez | e5896bd | 2008-07-10 16:55:52 -0700 | [diff] [blame] | 135 | int ql2xiidmaenable=1; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 136 | module_param(ql2xiidmaenable, int, S_IRUGO); |
Andrew Vasquez | e5896bd | 2008-07-10 16:55:52 -0700 | [diff] [blame] | 137 | MODULE_PARM_DESC(ql2xiidmaenable, |
| 138 | "Enables iIDMA settings " |
| 139 | "Default is 1 - perform iIDMA. 0 - no iIDMA."); |
| 140 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 141 | int ql2xmaxqueues = 1; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 142 | module_param(ql2xmaxqueues, int, S_IRUGO); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 143 | MODULE_PARM_DESC(ql2xmaxqueues, |
| 144 | "Enables MQ settings " |
Joe Perches | ae68230 | 2010-08-10 18:01:21 -0700 | [diff] [blame] | 145 | "Default is 1 for single queue. Set it to number " |
| 146 | "of queues in MQ mode."); |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 147 | |
| 148 | int ql2xmultique_tag; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 149 | module_param(ql2xmultique_tag, int, S_IRUGO); |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 150 | MODULE_PARM_DESC(ql2xmultique_tag, |
| 151 | "Enables CPU affinity settings for the driver " |
| 152 | "Default is 0 for no affinity of request and response IO. " |
| 153 | "Set it to 1 to turn on the cpu affinity."); |
Andrew Vasquez | e337d90 | 2009-04-06 22:33:49 -0700 | [diff] [blame] | 154 | |
| 155 | int ql2xfwloadbin; |
Chad Dupuis | 86e45bf | 2011-08-16 11:31:47 -0700 | [diff] [blame] | 156 | module_param(ql2xfwloadbin, int, S_IRUGO|S_IWUSR); |
Andrew Vasquez | e337d90 | 2009-04-06 22:33:49 -0700 | [diff] [blame] | 157 | MODULE_PARM_DESC(ql2xfwloadbin, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 158 | "Option to specify location from which to load ISP firmware:.\n" |
| 159 | " 2 -- load firmware via the request_firmware() (hotplug).\n" |
Andrew Vasquez | e337d90 | 2009-04-06 22:33:49 -0700 | [diff] [blame] | 160 | " interface.\n" |
| 161 | " 1 -- load firmware from flash.\n" |
| 162 | " 0 -- use default semantics.\n"); |
| 163 | |
Andrew Vasquez | ae97c91 | 2010-02-18 10:07:28 -0800 | [diff] [blame] | 164 | int ql2xetsenable; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 165 | module_param(ql2xetsenable, int, S_IRUGO); |
Andrew Vasquez | ae97c91 | 2010-02-18 10:07:28 -0800 | [diff] [blame] | 166 | MODULE_PARM_DESC(ql2xetsenable, |
| 167 | "Enables firmware ETS burst." |
| 168 | "Default is 0 - skip ETS enablement."); |
| 169 | |
Giridhar Malavali | 6907869 | 2010-05-28 15:08:28 -0700 | [diff] [blame] | 170 | int ql2xdbwr = 1; |
Chad Dupuis | 86e45bf | 2011-08-16 11:31:47 -0700 | [diff] [blame] | 171 | module_param(ql2xdbwr, int, S_IRUGO|S_IWUSR); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 172 | MODULE_PARM_DESC(ql2xdbwr, |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 173 | "Option to specify scheme for request queue posting.\n" |
| 174 | " 0 -- Regular doorbell.\n" |
| 175 | " 1 -- CAMRAM doorbell (faster).\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 176 | |
Giridhar Malavali | f4c496c | 2010-05-04 15:01:33 -0700 | [diff] [blame] | 177 | int ql2xtargetreset = 1; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 178 | module_param(ql2xtargetreset, int, S_IRUGO); |
Giridhar Malavali | f4c496c | 2010-05-04 15:01:33 -0700 | [diff] [blame] | 179 | MODULE_PARM_DESC(ql2xtargetreset, |
| 180 | "Enable target reset." |
| 181 | "Default is 1 - use hw defaults."); |
| 182 | |
Chad Dupuis | 4da26e1 | 2010-10-15 11:27:40 -0700 | [diff] [blame] | 183 | int ql2xgffidenable; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 184 | module_param(ql2xgffidenable, int, S_IRUGO); |
Chad Dupuis | 4da26e1 | 2010-10-15 11:27:40 -0700 | [diff] [blame] | 185 | MODULE_PARM_DESC(ql2xgffidenable, |
| 186 | "Enables GFF_ID checks of port type. " |
| 187 | "Default is 0 - Do not use GFF_ID information."); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 188 | |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 189 | int ql2xasynctmfenable; |
Joe Carnuccio | f2019cb | 2010-12-21 16:00:22 -0800 | [diff] [blame] | 190 | module_param(ql2xasynctmfenable, int, S_IRUGO); |
Madhuranath Iyengar | 3822263 | 2010-05-04 15:01:29 -0700 | [diff] [blame] | 191 | MODULE_PARM_DESC(ql2xasynctmfenable, |
| 192 | "Enables issue of TM IOCBs asynchronously via IOCB mechanism" |
| 193 | "Default is 0 - Issue TM IOCBs via mailbox mechanism."); |
Giridhar Malavali | ed0de87 | 2011-03-30 11:46:29 -0700 | [diff] [blame] | 194 | |
| 195 | int ql2xdontresethba; |
Chad Dupuis | 86e45bf | 2011-08-16 11:31:47 -0700 | [diff] [blame] | 196 | module_param(ql2xdontresethba, int, S_IRUGO|S_IWUSR); |
Giridhar Malavali | ed0de87 | 2011-03-30 11:46:29 -0700 | [diff] [blame] | 197 | MODULE_PARM_DESC(ql2xdontresethba, |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 198 | "Option to specify reset behaviour.\n" |
| 199 | " 0 (Default) -- Reset on failure.\n" |
| 200 | " 1 -- Do not reset on failure.\n"); |
Giridhar Malavali | ed0de87 | 2011-03-30 11:46:29 -0700 | [diff] [blame] | 201 | |
Andrew Vasquez | 8251592 | 2011-05-10 11:30:13 -0700 | [diff] [blame] | 202 | uint ql2xmaxlun = MAX_LUNS; |
| 203 | module_param(ql2xmaxlun, uint, S_IRUGO); |
| 204 | MODULE_PARM_DESC(ql2xmaxlun, |
| 205 | "Defines the maximum LU number to register with the SCSI " |
| 206 | "midlayer. Default is 65535."); |
| 207 | |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 208 | int ql2xmdcapmask = 0x1F; |
| 209 | module_param(ql2xmdcapmask, int, S_IRUGO); |
| 210 | MODULE_PARM_DESC(ql2xmdcapmask, |
| 211 | "Set the Minidump driver capture mask level. " |
Giridhar Malavali | 6e96fa7 | 2011-11-18 09:03:14 -0800 | [diff] [blame] | 212 | "Default is 0x1F - Can be set to 0x3, 0x7, 0xF, 0x1F, 0x7F."); |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 213 | |
Giridhar Malavali | 3aadff3 | 2011-11-18 09:02:14 -0800 | [diff] [blame] | 214 | int ql2xmdenable = 1; |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 215 | module_param(ql2xmdenable, int, S_IRUGO); |
| 216 | MODULE_PARM_DESC(ql2xmdenable, |
| 217 | "Enable/disable MiniDump. " |
Giridhar Malavali | 3aadff3 | 2011-11-18 09:02:14 -0800 | [diff] [blame] | 218 | "0 - MiniDump disabled. " |
| 219 | "1 (Default) - MiniDump enabled."); |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 220 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 221 | /* |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 222 | * SCSI host template entry points |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 223 | */ |
| 224 | static int qla2xxx_slave_configure(struct scsi_device * device); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 225 | static int qla2xxx_slave_alloc(struct scsi_device *); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 226 | static int qla2xxx_scan_finished(struct Scsi_Host *, unsigned long time); |
| 227 | static void qla2xxx_scan_start(struct Scsi_Host *); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 228 | static void qla2xxx_slave_destroy(struct scsi_device *); |
Jeff Garzik | f281233 | 2010-11-16 02:10:29 -0500 | [diff] [blame] | 229 | static int qla2xxx_queuecommand(struct Scsi_Host *h, struct scsi_cmnd *cmd); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 230 | static int qla2xxx_eh_abort(struct scsi_cmnd *); |
| 231 | static int qla2xxx_eh_device_reset(struct scsi_cmnd *); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 232 | static int qla2xxx_eh_target_reset(struct scsi_cmnd *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 233 | static int qla2xxx_eh_bus_reset(struct scsi_cmnd *); |
| 234 | static int qla2xxx_eh_host_reset(struct scsi_cmnd *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 235 | |
Mike Christie | e881a17 | 2009-10-15 17:46:39 -0700 | [diff] [blame] | 236 | static int qla2x00_change_queue_depth(struct scsi_device *, int, int); |
Andrew Vasquez | ce7e4af | 2005-08-26 19:09:30 -0700 | [diff] [blame] | 237 | static int qla2x00_change_queue_type(struct scsi_device *, int); |
| 238 | |
Giridhar Malavali | a5326f8 | 2009-03-24 09:07:56 -0700 | [diff] [blame] | 239 | struct scsi_host_template qla2xxx_driver_template = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 240 | .module = THIS_MODULE, |
Andrew Vasquez | cb63067 | 2006-05-17 15:09:45 -0700 | [diff] [blame] | 241 | .name = QLA2XXX_DRIVER_NAME, |
Giridhar Malavali | a5326f8 | 2009-03-24 09:07:56 -0700 | [diff] [blame] | 242 | .queuecommand = qla2xxx_queuecommand, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 243 | |
| 244 | .eh_abort_handler = qla2xxx_eh_abort, |
| 245 | .eh_device_reset_handler = qla2xxx_eh_device_reset, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 246 | .eh_target_reset_handler = qla2xxx_eh_target_reset, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 247 | .eh_bus_reset_handler = qla2xxx_eh_bus_reset, |
| 248 | .eh_host_reset_handler = qla2xxx_eh_host_reset, |
| 249 | |
| 250 | .slave_configure = qla2xxx_slave_configure, |
| 251 | |
| 252 | .slave_alloc = qla2xxx_slave_alloc, |
| 253 | .slave_destroy = qla2xxx_slave_destroy, |
Andrew Vasquez | ed67708 | 2007-03-12 10:41:27 -0700 | [diff] [blame] | 254 | .scan_finished = qla2xxx_scan_finished, |
| 255 | .scan_start = qla2xxx_scan_start, |
Andrew Vasquez | ce7e4af | 2005-08-26 19:09:30 -0700 | [diff] [blame] | 256 | .change_queue_depth = qla2x00_change_queue_depth, |
| 257 | .change_queue_type = qla2x00_change_queue_type, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 258 | .this_id = -1, |
| 259 | .cmd_per_lun = 3, |
| 260 | .use_clustering = ENABLE_CLUSTERING, |
| 261 | .sg_tablesize = SG_ALL, |
| 262 | |
| 263 | .max_sectors = 0xFFFF, |
Andrew Vasquez | afb046e | 2005-08-26 19:09:40 -0700 | [diff] [blame] | 264 | .shost_attrs = qla2x00_host_attrs, |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 265 | |
| 266 | .supported_mode = MODE_INITIATOR, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 267 | }; |
| 268 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 269 | static struct scsi_transport_template *qla2xxx_transport_template = NULL; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 270 | struct scsi_transport_template *qla2xxx_transport_vport_template = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 271 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 272 | /* TODO Convert to inlines |
| 273 | * |
| 274 | * Timer routines |
| 275 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 276 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 277 | __inline__ void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 278 | 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] | 279 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 280 | init_timer(&vha->timer); |
| 281 | vha->timer.expires = jiffies + interval * HZ; |
| 282 | vha->timer.data = (unsigned long)vha; |
| 283 | vha->timer.function = (void (*)(unsigned long))func; |
| 284 | add_timer(&vha->timer); |
| 285 | vha->timer_active = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 286 | } |
| 287 | |
| 288 | static inline void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 289 | qla2x00_restart_timer(scsi_qla_host_t *vha, unsigned long interval) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 290 | { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 291 | /* Currently used for 82XX only. */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 292 | if (vha->device_flags & DFLG_DEV_FAILED) { |
| 293 | ql_dbg(ql_dbg_timer, vha, 0x600d, |
| 294 | "Device in a failed state, returning.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 295 | return; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 296 | } |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 297 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 298 | mod_timer(&vha->timer, jiffies + interval * HZ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 299 | } |
| 300 | |
Adrian Bunk | a824ebb | 2008-01-17 09:02:15 -0800 | [diff] [blame] | 301 | static __inline__ void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 302 | qla2x00_stop_timer(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 303 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 304 | del_timer_sync(&vha->timer); |
| 305 | vha->timer_active = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 306 | } |
| 307 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 308 | static int qla2x00_do_dpc(void *data); |
| 309 | |
| 310 | static void qla2x00_rst_aen(scsi_qla_host_t *); |
| 311 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 312 | static int qla2x00_mem_alloc(struct qla_hw_data *, uint16_t, uint16_t, |
| 313 | struct req_que **, struct rsp_que **); |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 314 | static void qla2x00_free_fw_dump(struct qla_hw_data *); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 315 | static void qla2x00_mem_free(struct qla_hw_data *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 316 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 317 | /* -------------------------------------------------------------------------- */ |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 318 | static int qla2x00_alloc_queues(struct qla_hw_data *ha, struct req_que *req, |
| 319 | struct rsp_que *rsp) |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 320 | { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 321 | scsi_qla_host_t *vha = pci_get_drvdata(ha->pdev); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 322 | 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] | 323 | GFP_KERNEL); |
| 324 | if (!ha->req_q_map) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 325 | ql_log(ql_log_fatal, vha, 0x003b, |
| 326 | "Unable to allocate memory for request queue ptrs.\n"); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 327 | goto fail_req_map; |
| 328 | } |
| 329 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 330 | 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] | 331 | GFP_KERNEL); |
| 332 | if (!ha->rsp_q_map) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 333 | ql_log(ql_log_fatal, vha, 0x003c, |
| 334 | "Unable to allocate memory for response queue ptrs.\n"); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 335 | goto fail_rsp_map; |
| 336 | } |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 337 | /* |
| 338 | * Make sure we record at least the request and response queue zero in |
| 339 | * case we need to free them if part of the probe fails. |
| 340 | */ |
| 341 | ha->rsp_q_map[0] = rsp; |
| 342 | ha->req_q_map[0] = req; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 343 | set_bit(0, ha->rsp_qid_map); |
| 344 | set_bit(0, ha->req_qid_map); |
| 345 | return 1; |
| 346 | |
| 347 | fail_rsp_map: |
| 348 | kfree(ha->req_q_map); |
| 349 | ha->req_q_map = NULL; |
| 350 | fail_req_map: |
| 351 | return -ENOMEM; |
| 352 | } |
| 353 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 354 | 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] | 355 | { |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 356 | if (req && req->ring) |
| 357 | dma_free_coherent(&ha->pdev->dev, |
| 358 | (req->length + 1) * sizeof(request_t), |
| 359 | req->ring, req->dma); |
| 360 | |
| 361 | kfree(req); |
| 362 | req = NULL; |
| 363 | } |
| 364 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 365 | static void qla2x00_free_rsp_que(struct qla_hw_data *ha, struct rsp_que *rsp) |
| 366 | { |
| 367 | if (rsp && rsp->ring) |
| 368 | dma_free_coherent(&ha->pdev->dev, |
| 369 | (rsp->length + 1) * sizeof(response_t), |
| 370 | rsp->ring, rsp->dma); |
| 371 | |
| 372 | kfree(rsp); |
| 373 | rsp = NULL; |
| 374 | } |
| 375 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 376 | static void qla2x00_free_queues(struct qla_hw_data *ha) |
| 377 | { |
| 378 | struct req_que *req; |
| 379 | struct rsp_que *rsp; |
| 380 | int cnt; |
| 381 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 382 | for (cnt = 0; cnt < ha->max_req_queues; cnt++) { |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 383 | req = ha->req_q_map[cnt]; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 384 | qla2x00_free_req_que(ha, req); |
| 385 | } |
| 386 | kfree(ha->req_q_map); |
| 387 | ha->req_q_map = NULL; |
| 388 | |
| 389 | for (cnt = 0; cnt < ha->max_rsp_queues; cnt++) { |
| 390 | rsp = ha->rsp_q_map[cnt]; |
| 391 | qla2x00_free_rsp_que(ha, rsp); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 392 | } |
| 393 | kfree(ha->rsp_q_map); |
| 394 | ha->rsp_q_map = NULL; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 395 | } |
| 396 | |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 397 | static int qla25xx_setup_mode(struct scsi_qla_host *vha) |
| 398 | { |
| 399 | uint16_t options = 0; |
| 400 | int ques, req, ret; |
| 401 | struct qla_hw_data *ha = vha->hw; |
| 402 | |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 403 | if (!(ha->fw_attributes & BIT_6)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 404 | ql_log(ql_log_warn, vha, 0x00d8, |
| 405 | "Firmware is not multi-queue capable.\n"); |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 406 | goto fail; |
| 407 | } |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 408 | if (ql2xmultique_tag) { |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 409 | /* create a request queue for IO */ |
| 410 | options |= BIT_7; |
| 411 | req = qla25xx_create_req_que(ha, options, 0, 0, -1, |
| 412 | QLA_DEFAULT_QUE_QOS); |
| 413 | if (!req) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 414 | ql_log(ql_log_warn, vha, 0x00e0, |
| 415 | "Failed to create request queue.\n"); |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 416 | goto fail; |
| 417 | } |
Tejun Heo | 278274d | 2011-02-01 11:42:42 +0100 | [diff] [blame] | 418 | ha->wq = alloc_workqueue("qla2xxx_wq", WQ_MEM_RECLAIM, 1); |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 419 | vha->req = ha->req_q_map[req]; |
| 420 | options |= BIT_1; |
| 421 | for (ques = 1; ques < ha->max_rsp_queues; ques++) { |
| 422 | ret = qla25xx_create_rsp_que(ha, options, 0, 0, req); |
| 423 | if (!ret) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 424 | ql_log(ql_log_warn, vha, 0x00e8, |
| 425 | "Failed to create response queue.\n"); |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 426 | goto fail2; |
| 427 | } |
| 428 | } |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 429 | ha->flags.cpu_affinity_enabled = 1; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 430 | ql_dbg(ql_dbg_multiq, vha, 0xc007, |
| 431 | "CPU affinity mode enalbed, " |
| 432 | "no. of response queues:%d no. of request queues:%d.\n", |
| 433 | ha->max_rsp_queues, ha->max_req_queues); |
| 434 | ql_dbg(ql_dbg_init, vha, 0x00e9, |
| 435 | "CPU affinity mode enalbed, " |
| 436 | "no. of response queues:%d no. of request queues:%d.\n", |
| 437 | ha->max_rsp_queues, ha->max_req_queues); |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 438 | } |
| 439 | return 0; |
| 440 | fail2: |
| 441 | qla25xx_delete_queues(vha); |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 442 | destroy_workqueue(ha->wq); |
| 443 | ha->wq = NULL; |
Giridhar Malavali | 0cd33fc | 2011-11-18 09:02:12 -0800 | [diff] [blame] | 444 | vha->req = ha->req_q_map[0]; |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 445 | fail: |
| 446 | ha->mqenable = 0; |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 447 | kfree(ha->req_q_map); |
| 448 | kfree(ha->rsp_q_map); |
| 449 | ha->max_req_queues = ha->max_rsp_queues = 1; |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 450 | return 1; |
| 451 | } |
| 452 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 453 | static char * |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 454 | qla2x00_pci_info_str(struct scsi_qla_host *vha, char *str) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 455 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 456 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 457 | static char *pci_bus_modes[] = { |
| 458 | "33", "66", "100", "133", |
| 459 | }; |
| 460 | uint16_t pci_bus; |
| 461 | |
| 462 | strcpy(str, "PCI"); |
| 463 | pci_bus = (ha->pci_attr & (BIT_9 | BIT_10)) >> 9; |
| 464 | if (pci_bus) { |
| 465 | strcat(str, "-X ("); |
| 466 | strcat(str, pci_bus_modes[pci_bus]); |
| 467 | } else { |
| 468 | pci_bus = (ha->pci_attr & BIT_8) >> 8; |
| 469 | strcat(str, " ("); |
| 470 | strcat(str, pci_bus_modes[pci_bus]); |
| 471 | } |
| 472 | strcat(str, " MHz)"); |
| 473 | |
| 474 | return (str); |
| 475 | } |
| 476 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 477 | static char * |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 478 | qla24xx_pci_info_str(struct scsi_qla_host *vha, char *str) |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 479 | { |
| 480 | static char *pci_bus_modes[] = { "33", "66", "100", "133", }; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 481 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 482 | uint32_t pci_bus; |
| 483 | int pcie_reg; |
| 484 | |
Jon Mason | e67f132 | 2012-07-10 14:57:56 -0700 | [diff] [blame] | 485 | pcie_reg = pci_pcie_cap(ha->pdev); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 486 | if (pcie_reg) { |
| 487 | char lwstr[6]; |
| 488 | uint16_t pcie_lstat, lspeed, lwidth; |
| 489 | |
Jon Mason | e67f132 | 2012-07-10 14:57:56 -0700 | [diff] [blame] | 490 | pcie_reg += PCI_EXP_LNKCAP; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 491 | pci_read_config_word(ha->pdev, pcie_reg, &pcie_lstat); |
| 492 | lspeed = pcie_lstat & (BIT_0 | BIT_1 | BIT_2 | BIT_3); |
| 493 | lwidth = (pcie_lstat & |
| 494 | (BIT_4 | BIT_5 | BIT_6 | BIT_7 | BIT_8 | BIT_9)) >> 4; |
| 495 | |
| 496 | strcpy(str, "PCIe ("); |
| 497 | if (lspeed == 1) |
Andrew Vasquez | c87a0d8 | 2008-04-03 13:13:21 -0700 | [diff] [blame] | 498 | strcat(str, "2.5GT/s "); |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 499 | else if (lspeed == 2) |
Andrew Vasquez | c87a0d8 | 2008-04-03 13:13:21 -0700 | [diff] [blame] | 500 | strcat(str, "5.0GT/s "); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 501 | else |
| 502 | strcat(str, "<unknown> "); |
| 503 | snprintf(lwstr, sizeof(lwstr), "x%d)", lwidth); |
| 504 | strcat(str, lwstr); |
| 505 | |
| 506 | return str; |
| 507 | } |
| 508 | |
| 509 | strcpy(str, "PCI"); |
| 510 | pci_bus = (ha->pci_attr & CSRX_PCIX_BUS_MODE_MASK) >> 8; |
| 511 | if (pci_bus == 0 || pci_bus == 8) { |
| 512 | strcat(str, " ("); |
| 513 | strcat(str, pci_bus_modes[pci_bus >> 3]); |
| 514 | } else { |
| 515 | strcat(str, "-X "); |
| 516 | if (pci_bus & BIT_2) |
| 517 | strcat(str, "Mode 2"); |
| 518 | else |
| 519 | strcat(str, "Mode 1"); |
| 520 | strcat(str, " ("); |
| 521 | strcat(str, pci_bus_modes[pci_bus & ~BIT_2]); |
| 522 | } |
| 523 | strcat(str, " MHz)"); |
| 524 | |
| 525 | return str; |
| 526 | } |
| 527 | |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 528 | static char * |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 529 | qla2x00_fw_version_str(struct scsi_qla_host *vha, char *str) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 530 | { |
| 531 | char un_str[10]; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 532 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 533 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 534 | sprintf(str, "%d.%02d.%02d ", ha->fw_major_version, |
| 535 | ha->fw_minor_version, |
| 536 | ha->fw_subminor_version); |
| 537 | |
| 538 | if (ha->fw_attributes & BIT_9) { |
| 539 | strcat(str, "FLX"); |
| 540 | return (str); |
| 541 | } |
| 542 | |
| 543 | switch (ha->fw_attributes & 0xFF) { |
| 544 | case 0x7: |
| 545 | strcat(str, "EF"); |
| 546 | break; |
| 547 | case 0x17: |
| 548 | strcat(str, "TP"); |
| 549 | break; |
| 550 | case 0x37: |
| 551 | strcat(str, "IP"); |
| 552 | break; |
| 553 | case 0x77: |
| 554 | strcat(str, "VI"); |
| 555 | break; |
| 556 | default: |
| 557 | sprintf(un_str, "(%x)", ha->fw_attributes); |
| 558 | strcat(str, un_str); |
| 559 | break; |
| 560 | } |
| 561 | if (ha->fw_attributes & 0x100) |
| 562 | strcat(str, "X"); |
| 563 | |
| 564 | return (str); |
| 565 | } |
| 566 | |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 567 | static char * |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 568 | qla24xx_fw_version_str(struct scsi_qla_host *vha, char *str) |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 569 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 570 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | f0883ac | 2005-07-08 17:58:43 -0700 | [diff] [blame] | 571 | |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 572 | sprintf(str, "%d.%02d.%02d (%x)", ha->fw_major_version, |
| 573 | ha->fw_minor_version, ha->fw_subminor_version, ha->fw_attributes); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 574 | return str; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 575 | } |
| 576 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 577 | void |
| 578 | qla2x00_sp_free_dma(void *vha, void *ptr) |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 579 | { |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 580 | srb_t *sp = (srb_t *)ptr; |
| 581 | struct scsi_cmnd *cmd = GET_CMD_SP(sp); |
| 582 | struct qla_hw_data *ha = sp->fcport->vha->hw; |
| 583 | void *ctx = GET_CMD_CTX_SP(sp); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 584 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 585 | if (sp->flags & SRB_DMA_VALID) { |
| 586 | scsi_dma_unmap(cmd); |
| 587 | sp->flags &= ~SRB_DMA_VALID; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 588 | } |
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 | if (sp->flags & SRB_CRC_PROT_DMA_VALID) { |
| 591 | dma_unmap_sg(&ha->pdev->dev, scsi_prot_sglist(cmd), |
| 592 | scsi_prot_sg_count(cmd), cmd->sc_data_direction); |
| 593 | sp->flags &= ~SRB_CRC_PROT_DMA_VALID; |
| 594 | } |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 595 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 596 | if (sp->flags & SRB_CRC_CTX_DSD_VALID) { |
| 597 | /* List assured to be having elements */ |
| 598 | qla2x00_clean_dsd_pool(ha, sp); |
| 599 | sp->flags &= ~SRB_CRC_CTX_DSD_VALID; |
| 600 | } |
| 601 | |
| 602 | if (sp->flags & SRB_CRC_CTX_DMA_VALID) { |
| 603 | dma_pool_free(ha->dl_dma_pool, ctx, |
| 604 | ((struct crc_context *)ctx)->crc_ctx_dma); |
| 605 | sp->flags &= ~SRB_CRC_CTX_DMA_VALID; |
| 606 | } |
| 607 | |
| 608 | if (sp->flags & SRB_FCP_CMND_DMA_VALID) { |
| 609 | struct ct6_dsd *ctx1 = (struct ct6_dsd *)ctx; |
| 610 | |
| 611 | dma_pool_free(ha->fcp_cmnd_dma_pool, ctx1->fcp_cmnd, |
| 612 | ctx1->fcp_cmnd_dma); |
| 613 | list_splice(&ctx1->dsd_list, &ha->gbl_dsd_list); |
| 614 | ha->gbl_dsd_inuse -= ctx1->dsd_use_cnt; |
| 615 | ha->gbl_dsd_avail += ctx1->dsd_use_cnt; |
| 616 | mempool_free(ctx1, ha->ctx_mempool); |
| 617 | ctx1 = NULL; |
| 618 | } |
| 619 | |
| 620 | CMD_SP(cmd) = NULL; |
| 621 | mempool_free(sp, ha->srb_mempool); |
| 622 | } |
| 623 | |
| 624 | static void |
| 625 | qla2x00_sp_compl(void *data, void *ptr, int res) |
| 626 | { |
| 627 | struct qla_hw_data *ha = (struct qla_hw_data *)data; |
| 628 | srb_t *sp = (srb_t *)ptr; |
| 629 | struct scsi_cmnd *cmd = GET_CMD_SP(sp); |
| 630 | |
| 631 | cmd->result = res; |
| 632 | |
| 633 | if (atomic_read(&sp->ref_count) == 0) { |
| 634 | ql_dbg(ql_dbg_io, sp->fcport->vha, 0x3015, |
| 635 | "SP reference-count to ZERO -- sp=%p cmd=%p.\n", |
| 636 | sp, GET_CMD_SP(sp)); |
| 637 | if (ql2xextended_error_logging & ql_dbg_io) |
| 638 | BUG(); |
| 639 | return; |
| 640 | } |
| 641 | if (!atomic_dec_and_test(&sp->ref_count)) |
| 642 | return; |
| 643 | |
| 644 | qla2x00_sp_free_dma(ha, sp); |
| 645 | cmd->scsi_done(cmd); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 646 | } |
| 647 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 648 | static int |
Madhuranath Iyengar | f5e3e40 | 2011-02-23 15:27:06 -0800 | [diff] [blame] | 649 | qla2xxx_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 650 | { |
Madhuranath Iyengar | 134ae07 | 2011-05-10 11:30:08 -0700 | [diff] [blame] | 651 | scsi_qla_host_t *vha = shost_priv(host); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 652 | fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 653 | struct fc_rport *rport = starget_to_rport(scsi_target(cmd->device)); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 654 | struct qla_hw_data *ha = vha->hw; |
| 655 | struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 656 | srb_t *sp; |
| 657 | int rval; |
| 658 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 659 | if (ha->flags.eeh_busy) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 660 | if (ha->flags.pci_channel_io_perm_failure) { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 661 | ql_dbg(ql_dbg_aer, vha, 0x9010, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 662 | "PCI Channel IO permanent failure, exiting " |
| 663 | "cmd=%p.\n", cmd); |
Seokmann Ju | b9b12f7 | 2009-03-24 09:08:18 -0700 | [diff] [blame] | 664 | cmd->result = DID_NO_CONNECT << 16; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 665 | } else { |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 666 | ql_dbg(ql_dbg_aer, vha, 0x9011, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 667 | "EEH_Busy, Requeuing the cmd=%p.\n", cmd); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 668 | cmd->result = DID_REQUEUE << 16; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 669 | } |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 670 | goto qc24_fail_command; |
| 671 | } |
| 672 | |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 673 | rval = fc_remote_port_chkready(rport); |
| 674 | if (rval) { |
| 675 | cmd->result = rval; |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 676 | ql_dbg(ql_dbg_io + ql_dbg_verbose, vha, 0x3003, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 677 | "fc_remote_port_chkready failed for cmd=%p, rval=0x%x.\n", |
| 678 | cmd, rval); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 679 | goto qc24_fail_command; |
| 680 | } |
| 681 | |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 682 | if (!vha->flags.difdix_supported && |
| 683 | scsi_get_prot_op(cmd) != SCSI_PROT_NORMAL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 684 | ql_dbg(ql_dbg_io, vha, 0x3004, |
| 685 | "DIF Cap not reg, fail DIF capable cmd's:%p.\n", |
| 686 | cmd); |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 687 | cmd->result = DID_NO_CONNECT << 16; |
| 688 | goto qc24_fail_command; |
| 689 | } |
Chad Dupuis | aa651be | 2012-02-09 11:14:04 -0800 | [diff] [blame] | 690 | |
| 691 | if (!fcport) { |
| 692 | cmd->result = DID_NO_CONNECT << 16; |
| 693 | goto qc24_fail_command; |
| 694 | } |
| 695 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 696 | if (atomic_read(&fcport->state) != FCS_ONLINE) { |
| 697 | if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD || |
Giridhar Malavali | 38170fa | 2010-10-15 11:27:49 -0700 | [diff] [blame] | 698 | atomic_read(&base_vha->loop_state) == LOOP_DEAD) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 699 | ql_dbg(ql_dbg_io, vha, 0x3005, |
| 700 | "Returning DNC, fcport_state=%d loop_state=%d.\n", |
| 701 | atomic_read(&fcport->state), |
| 702 | atomic_read(&base_vha->loop_state)); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 703 | cmd->result = DID_NO_CONNECT << 16; |
| 704 | goto qc24_fail_command; |
| 705 | } |
Mike Christie | 7b59413 | 2008-08-17 15:24:40 -0500 | [diff] [blame] | 706 | goto qc24_target_busy; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 707 | } |
| 708 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 709 | sp = qla2x00_get_sp(base_vha, fcport, GFP_ATOMIC); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 710 | if (!sp) |
Madhuranath Iyengar | f5e3e40 | 2011-02-23 15:27:06 -0800 | [diff] [blame] | 711 | goto qc24_host_busy; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 712 | |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 713 | sp->u.scmd.cmd = cmd; |
| 714 | sp->type = SRB_SCSI_CMD; |
| 715 | atomic_set(&sp->ref_count, 1); |
| 716 | CMD_SP(cmd) = (void *)sp; |
| 717 | sp->free = qla2x00_sp_free_dma; |
| 718 | sp->done = qla2x00_sp_compl; |
| 719 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 720 | rval = ha->isp_ops->start_scsi(sp); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 721 | if (rval != QLA_SUCCESS) { |
| 722 | ql_dbg(ql_dbg_io, vha, 0x3013, |
| 723 | "Start scsi failed rval=%d for cmd=%p.\n", rval, cmd); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 724 | goto qc24_host_busy_free_sp; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 725 | } |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 726 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 727 | return 0; |
| 728 | |
| 729 | qc24_host_busy_free_sp: |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 730 | qla2x00_sp_free_dma(ha, sp); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 731 | |
Madhuranath Iyengar | f5e3e40 | 2011-02-23 15:27:06 -0800 | [diff] [blame] | 732 | qc24_host_busy: |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 733 | return SCSI_MLQUEUE_HOST_BUSY; |
| 734 | |
Mike Christie | 7b59413 | 2008-08-17 15:24:40 -0500 | [diff] [blame] | 735 | qc24_target_busy: |
| 736 | return SCSI_MLQUEUE_TARGET_BUSY; |
| 737 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 738 | qc24_fail_command: |
Madhuranath Iyengar | f5e3e40 | 2011-02-23 15:27:06 -0800 | [diff] [blame] | 739 | cmd->scsi_done(cmd); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 740 | |
| 741 | return 0; |
| 742 | } |
| 743 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 744 | /* |
| 745 | * qla2x00_eh_wait_on_command |
| 746 | * Waits for the command to be returned by the Firmware for some |
| 747 | * max time. |
| 748 | * |
| 749 | * Input: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 750 | * cmd = Scsi Command to wait on. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 751 | * |
| 752 | * Return: |
| 753 | * Not Found : 0 |
| 754 | * Found : 1 |
| 755 | */ |
| 756 | static int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 757 | qla2x00_eh_wait_on_command(struct scsi_cmnd *cmd) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 758 | { |
Andrew Vasquez | fe74c71 | 2005-08-26 19:10:10 -0700 | [diff] [blame] | 759 | #define ABORT_POLLING_PERIOD 1000 |
| 760 | #define ABORT_WAIT_ITER ((10 * 1000) / (ABORT_POLLING_PERIOD)) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 761 | unsigned long wait_iter = ABORT_WAIT_ITER; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 762 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| 763 | struct qla_hw_data *ha = vha->hw; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 764 | int ret = QLA_SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 765 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 766 | if (unlikely(pci_channel_offline(ha->pdev)) || ha->flags.eeh_busy) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 767 | ql_dbg(ql_dbg_taskm, vha, 0x8005, |
| 768 | "Return:eh_wait.\n"); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 769 | return ret; |
| 770 | } |
| 771 | |
Lalit Chandivade | d970432 | 2009-08-25 11:36:18 -0700 | [diff] [blame] | 772 | while (CMD_SP(cmd) && wait_iter--) { |
Andrew Vasquez | fe74c71 | 2005-08-26 19:10:10 -0700 | [diff] [blame] | 773 | msleep(ABORT_POLLING_PERIOD); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 774 | } |
| 775 | if (CMD_SP(cmd)) |
| 776 | ret = QLA_FUNCTION_FAILED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 777 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 778 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 779 | } |
| 780 | |
| 781 | /* |
| 782 | * qla2x00_wait_for_hba_online |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 783 | * Wait till the HBA is online after going through |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 784 | * <= MAX_RETRIES_OF_ISP_ABORT or |
| 785 | * finally HBA is disabled ie marked offline |
| 786 | * |
| 787 | * Input: |
| 788 | * ha - pointer to host adapter structure |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 789 | * |
| 790 | * Note: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 791 | * Does context switching-Release SPIN_LOCK |
| 792 | * (if any) before calling this routine. |
| 793 | * |
| 794 | * Return: |
| 795 | * Success (Adapter is online) : 0 |
| 796 | * Failed (Adapter is offline/disabled) : 1 |
| 797 | */ |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 798 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 799 | qla2x00_wait_for_hba_online(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 800 | { |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 801 | int return_status; |
| 802 | unsigned long wait_online; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 803 | struct qla_hw_data *ha = vha->hw; |
| 804 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 805 | |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 806 | wait_online = jiffies + (MAX_LOOP_TIMEOUT * HZ); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 807 | while (((test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags)) || |
| 808 | test_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags) || |
| 809 | test_bit(ISP_ABORT_RETRY, &base_vha->dpc_flags) || |
| 810 | ha->dpc_active) && time_before(jiffies, wait_online)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 811 | |
| 812 | msleep(1000); |
| 813 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 814 | if (base_vha->flags.online) |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 815 | return_status = QLA_SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 816 | else |
| 817 | return_status = QLA_FUNCTION_FAILED; |
| 818 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 819 | return (return_status); |
| 820 | } |
| 821 | |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 822 | /* |
| 823 | * qla2x00_wait_for_reset_ready |
| 824 | * Wait till the HBA is online after going through |
| 825 | * <= MAX_RETRIES_OF_ISP_ABORT or |
| 826 | * finally HBA is disabled ie marked offline or flash |
| 827 | * operations are in progress. |
| 828 | * |
| 829 | * Input: |
| 830 | * ha - pointer to host adapter structure |
| 831 | * |
| 832 | * Note: |
| 833 | * Does context switching-Release SPIN_LOCK |
| 834 | * (if any) before calling this routine. |
| 835 | * |
| 836 | * Return: |
| 837 | * Success (Adapter is online/no flash ops) : 0 |
| 838 | * Failed (Adapter is offline/disabled/flash ops in progress) : 1 |
| 839 | */ |
Andrew Vasquez | 3dbe756 | 2010-07-23 15:28:37 +0500 | [diff] [blame] | 840 | static int |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 841 | qla2x00_wait_for_reset_ready(scsi_qla_host_t *vha) |
| 842 | { |
| 843 | int return_status; |
| 844 | unsigned long wait_online; |
| 845 | struct qla_hw_data *ha = vha->hw; |
| 846 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 847 | |
| 848 | wait_online = jiffies + (MAX_LOOP_TIMEOUT * HZ); |
| 849 | while (((test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags)) || |
| 850 | test_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags) || |
| 851 | test_bit(ISP_ABORT_RETRY, &base_vha->dpc_flags) || |
| 852 | ha->optrom_state != QLA_SWAITING || |
| 853 | ha->dpc_active) && time_before(jiffies, wait_online)) |
| 854 | msleep(1000); |
| 855 | |
| 856 | if (base_vha->flags.online && ha->optrom_state == QLA_SWAITING) |
| 857 | return_status = QLA_SUCCESS; |
| 858 | else |
| 859 | return_status = QLA_FUNCTION_FAILED; |
| 860 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 861 | ql_dbg(ql_dbg_taskm, vha, 0x8019, |
| 862 | "%s return status=%d.\n", __func__, return_status); |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 863 | |
| 864 | return return_status; |
| 865 | } |
| 866 | |
Lalit Chandivade | 2533cf6 | 2009-03-24 09:08:07 -0700 | [diff] [blame] | 867 | int |
| 868 | qla2x00_wait_for_chip_reset(scsi_qla_host_t *vha) |
| 869 | { |
| 870 | int return_status; |
| 871 | unsigned long wait_reset; |
| 872 | struct qla_hw_data *ha = vha->hw; |
| 873 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 874 | |
| 875 | wait_reset = jiffies + (MAX_LOOP_TIMEOUT * HZ); |
| 876 | while (((test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags)) || |
| 877 | test_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags) || |
| 878 | test_bit(ISP_ABORT_RETRY, &base_vha->dpc_flags) || |
| 879 | ha->dpc_active) && time_before(jiffies, wait_reset)) { |
| 880 | |
| 881 | msleep(1000); |
| 882 | |
| 883 | if (!test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags) && |
| 884 | ha->flags.chip_reset_done) |
| 885 | break; |
| 886 | } |
| 887 | if (ha->flags.chip_reset_done) |
| 888 | return_status = QLA_SUCCESS; |
| 889 | else |
| 890 | return_status = QLA_FUNCTION_FAILED; |
| 891 | |
| 892 | return return_status; |
| 893 | } |
| 894 | |
Giridhar Malavali | 083a469 | 2010-05-28 15:08:18 -0700 | [diff] [blame] | 895 | static void |
| 896 | sp_get(struct srb *sp) |
| 897 | { |
| 898 | atomic_inc(&sp->ref_count); |
| 899 | } |
| 900 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 901 | /************************************************************************** |
| 902 | * qla2xxx_eh_abort |
| 903 | * |
| 904 | * Description: |
| 905 | * The abort function will abort the specified command. |
| 906 | * |
| 907 | * Input: |
| 908 | * cmd = Linux SCSI command packet to be aborted. |
| 909 | * |
| 910 | * Returns: |
| 911 | * Either SUCCESS or FAILED. |
| 912 | * |
| 913 | * Note: |
Michael Reed | 2ea0020 | 2006-04-27 16:25:30 -0700 | [diff] [blame] | 914 | * Only return FAILED if command not returned by firmware. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 915 | **************************************************************************/ |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 916 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 917 | qla2xxx_eh_abort(struct scsi_cmnd *cmd) |
| 918 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 919 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 920 | srb_t *sp; |
Andrew Vasquez | 4e98d3b | 2011-02-23 15:27:17 -0800 | [diff] [blame] | 921 | int ret; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 922 | unsigned int id, lun; |
Andrew Vasquez | 18e144d | 2005-05-27 15:04:47 -0700 | [diff] [blame] | 923 | unsigned long flags; |
Michael Reed | 2ea0020 | 2006-04-27 16:25:30 -0700 | [diff] [blame] | 924 | int wait = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 925 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 926 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 927 | if (!CMD_SP(cmd)) |
Michael Reed | 2ea0020 | 2006-04-27 16:25:30 -0700 | [diff] [blame] | 928 | return SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 929 | |
Andrew Vasquez | 4e98d3b | 2011-02-23 15:27:17 -0800 | [diff] [blame] | 930 | ret = fc_block_scsi_eh(cmd); |
| 931 | if (ret != 0) |
| 932 | return ret; |
| 933 | ret = SUCCESS; |
| 934 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 935 | id = cmd->device->id; |
| 936 | lun = cmd->device->lun; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 937 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 938 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 939 | sp = (srb_t *) CMD_SP(cmd); |
| 940 | if (!sp) { |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 941 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 942 | return SUCCESS; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 943 | } |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 944 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 945 | ql_dbg(ql_dbg_taskm, vha, 0x8002, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 946 | "Aborting from RISC nexus=%ld:%d:%d sp=%p cmd=%p\n", |
| 947 | vha->host_no, id, lun, sp, cmd); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 948 | |
| 949 | /* Get a reference to the sp and drop the lock.*/ |
| 950 | sp_get(sp); |
| 951 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 952 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 953 | if (ha->isp_ops->abort_command(sp)) { |
Arun Easi | a55aac7 | 2012-02-09 11:14:03 -0800 | [diff] [blame] | 954 | ret = FAILED; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 955 | ql_dbg(ql_dbg_taskm, vha, 0x8003, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 956 | "Abort command mbx failed cmd=%p.\n", cmd); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 957 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 958 | ql_dbg(ql_dbg_taskm, vha, 0x8004, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 959 | "Abort command mbx success cmd=%p.\n", cmd); |
Mike Christie | 170babc | 2010-10-15 11:27:47 -0700 | [diff] [blame] | 960 | wait = 1; |
| 961 | } |
Saurav Kashyap | 7594206 | 2011-08-16 11:29:25 -0700 | [diff] [blame] | 962 | |
| 963 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 964 | sp->done(ha, sp, 0); |
Saurav Kashyap | 7594206 | 2011-08-16 11:29:25 -0700 | [diff] [blame] | 965 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 966 | |
Chad Dupuis | bc91ade | 2011-08-16 11:29:26 -0700 | [diff] [blame] | 967 | /* Did the command return during mailbox execution? */ |
| 968 | if (ret == FAILED && !CMD_SP(cmd)) |
| 969 | ret = SUCCESS; |
| 970 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 971 | /* Wait for the command to be returned. */ |
Michael Reed | 2ea0020 | 2006-04-27 16:25:30 -0700 | [diff] [blame] | 972 | if (wait) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 973 | if (qla2x00_eh_wait_on_command(cmd) != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 974 | ql_log(ql_log_warn, vha, 0x8006, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 975 | "Abort handler timed out cmd=%p.\n", cmd); |
Michael Reed | 2ea0020 | 2006-04-27 16:25:30 -0700 | [diff] [blame] | 976 | ret = FAILED; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 977 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 978 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 979 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 980 | ql_log(ql_log_info, vha, 0x801c, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 981 | "Abort command issued nexus=%ld:%d:%d -- %d %x.\n", |
| 982 | vha->host_no, id, lun, wait, ret); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 983 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 984 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 985 | } |
| 986 | |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 987 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 988 | 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] | 989 | unsigned int l, enum nexus_wait_type type) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 990 | { |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 991 | int cnt, match, status; |
Andrew Vasquez | 18e144d | 2005-05-27 15:04:47 -0700 | [diff] [blame] | 992 | unsigned long flags; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 993 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 994 | struct req_que *req; |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 995 | srb_t *sp; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 996 | struct scsi_cmnd *cmd; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 997 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 998 | status = QLA_SUCCESS; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 999 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1000 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 67c2e93 | 2009-04-06 22:33:42 -0700 | [diff] [blame] | 1001 | req = vha->req; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1002 | for (cnt = 1; status == QLA_SUCCESS && |
| 1003 | cnt < MAX_OUTSTANDING_COMMANDS; cnt++) { |
| 1004 | sp = req->outstanding_cmds[cnt]; |
| 1005 | if (!sp) |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1006 | continue; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1007 | if (sp->type != SRB_SCSI_CMD) |
Andrew Vasquez | cf53b06 | 2009-08-20 11:06:04 -0700 | [diff] [blame] | 1008 | continue; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1009 | if (vha->vp_idx != sp->fcport->vha->vp_idx) |
| 1010 | continue; |
| 1011 | match = 0; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1012 | cmd = GET_CMD_SP(sp); |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1013 | switch (type) { |
| 1014 | case WAIT_HOST: |
| 1015 | match = 1; |
| 1016 | break; |
| 1017 | case WAIT_TARGET: |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1018 | match = cmd->device->id == t; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1019 | break; |
| 1020 | case WAIT_LUN: |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1021 | match = (cmd->device->id == t && |
| 1022 | cmd->device->lun == l); |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1023 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1024 | } |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1025 | if (!match) |
| 1026 | continue; |
| 1027 | |
| 1028 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1029 | status = qla2x00_eh_wait_on_command(cmd); |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1030 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1031 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1032 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1033 | |
| 1034 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1035 | } |
| 1036 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1037 | static char *reset_errors[] = { |
| 1038 | "HBA not online", |
| 1039 | "HBA not ready", |
| 1040 | "Task management failed", |
| 1041 | "Waiting for command completions", |
| 1042 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1043 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1044 | static int |
| 1045 | __qla2xxx_eh_generic_reset(char *name, enum nexus_wait_type type, |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1046 | 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] | 1047 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1048 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1049 | fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; |
| 1050 | int err; |
| 1051 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1052 | if (!fcport) { |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1053 | return FAILED; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1054 | } |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1055 | |
Andrew Vasquez | 4e98d3b | 2011-02-23 15:27:17 -0800 | [diff] [blame] | 1056 | err = fc_block_scsi_eh(cmd); |
| 1057 | if (err != 0) |
| 1058 | return err; |
| 1059 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1060 | ql_log(ql_log_info, vha, 0x8009, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1061 | "%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] | 1062 | cmd->device->id, cmd->device->lun, cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1063 | |
| 1064 | err = 0; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1065 | if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) { |
| 1066 | ql_log(ql_log_warn, vha, 0x800a, |
| 1067 | "Wait for hba online failed for cmd=%p.\n", cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1068 | goto eh_reset_failed; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1069 | } |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1070 | err = 2; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1071 | if (do_reset(fcport, cmd->device->lun, cmd->request->cpu + 1) |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1072 | != QLA_SUCCESS) { |
| 1073 | ql_log(ql_log_warn, vha, 0x800c, |
| 1074 | "do_reset failed for cmd=%p.\n", cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1075 | goto eh_reset_failed; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1076 | } |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1077 | err = 3; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1078 | if (qla2x00_eh_wait_for_pending_commands(vha, cmd->device->id, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1079 | cmd->device->lun, type) != QLA_SUCCESS) { |
| 1080 | ql_log(ql_log_warn, vha, 0x800d, |
Masanari Iida | d6a0358 | 2012-08-22 14:20:58 -0400 | [diff] [blame] | 1081 | "wait for pending cmds failed for cmd=%p.\n", cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1082 | goto eh_reset_failed; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1083 | } |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1084 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1085 | ql_log(ql_log_info, vha, 0x800e, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1086 | "%s RESET SUCCEEDED nexus:%ld:%d:%d cmd=%p.\n", name, |
| 1087 | vha->host_no, cmd->device->id, cmd->device->lun, cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1088 | |
| 1089 | return SUCCESS; |
| 1090 | |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1091 | eh_reset_failed: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1092 | ql_log(ql_log_info, vha, 0x800f, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1093 | "%s RESET FAILED: %s nexus=%ld:%d:%d cmd=%p.\n", name, |
| 1094 | reset_errors[err], vha->host_no, cmd->device->id, cmd->device->lun, |
| 1095 | cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1096 | return FAILED; |
| 1097 | } |
| 1098 | |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 1099 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1100 | qla2xxx_eh_device_reset(struct scsi_cmnd *cmd) |
| 1101 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1102 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| 1103 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1104 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1105 | return __qla2xxx_eh_generic_reset("DEVICE", WAIT_LUN, cmd, |
| 1106 | ha->isp_ops->lun_reset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1107 | } |
| 1108 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1109 | static int |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1110 | qla2xxx_eh_target_reset(struct scsi_cmnd *cmd) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 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("TARGET", WAIT_TARGET, cmd, |
| 1116 | ha->isp_ops->target_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 | /************************************************************************** |
| 1120 | * qla2xxx_eh_bus_reset |
| 1121 | * |
| 1122 | * Description: |
| 1123 | * The bus reset function will reset the bus and abort any executing |
| 1124 | * commands. |
| 1125 | * |
| 1126 | * Input: |
| 1127 | * cmd = Linux SCSI command packet of the command that cause the |
| 1128 | * bus reset. |
| 1129 | * |
| 1130 | * Returns: |
| 1131 | * SUCCESS/FAILURE (defined as macro in scsi.h). |
| 1132 | * |
| 1133 | **************************************************************************/ |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 1134 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1135 | qla2xxx_eh_bus_reset(struct scsi_cmnd *cmd) |
| 1136 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1137 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 1138 | fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1139 | int ret = FAILED; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1140 | unsigned int id, lun; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1141 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1142 | id = cmd->device->id; |
| 1143 | lun = cmd->device->lun; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1144 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1145 | if (!fcport) { |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1146 | return ret; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1147 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1148 | |
Andrew Vasquez | 4e98d3b | 2011-02-23 15:27:17 -0800 | [diff] [blame] | 1149 | ret = fc_block_scsi_eh(cmd); |
| 1150 | if (ret != 0) |
| 1151 | return ret; |
| 1152 | ret = FAILED; |
| 1153 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1154 | ql_log(ql_log_info, vha, 0x8012, |
Andrew Vasquez | 46270af | 2012-05-15 14:34:17 -0400 | [diff] [blame] | 1155 | "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] | 1156 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1157 | if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1158 | ql_log(ql_log_fatal, vha, 0x8013, |
| 1159 | "Wait for hba online failed board disabled.\n"); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1160 | goto eh_bus_reset_done; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1161 | } |
| 1162 | |
Saurav Kashyap | ad53768 | 2011-11-18 09:02:09 -0800 | [diff] [blame] | 1163 | if (qla2x00_loop_reset(vha) == QLA_SUCCESS) |
| 1164 | ret = SUCCESS; |
| 1165 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1166 | if (ret == FAILED) |
| 1167 | goto eh_bus_reset_done; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1168 | |
Andrew Vasquez | 9a41a62 | 2005-09-20 13:25:53 -0700 | [diff] [blame] | 1169 | /* Flush outstanding commands. */ |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1170 | if (qla2x00_eh_wait_for_pending_commands(vha, 0, 0, WAIT_HOST) != |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1171 | QLA_SUCCESS) { |
| 1172 | ql_log(ql_log_warn, vha, 0x8014, |
| 1173 | "Wait for pending commands failed.\n"); |
Andrew Vasquez | 9a41a62 | 2005-09-20 13:25:53 -0700 | [diff] [blame] | 1174 | ret = FAILED; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1175 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1176 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1177 | eh_bus_reset_done: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1178 | ql_log(ql_log_warn, vha, 0x802b, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1179 | "BUS RESET %s nexus=%ld:%d:%d.\n", |
Masanari Iida | d6a0358 | 2012-08-22 14:20:58 -0400 | [diff] [blame] | 1180 | (ret == FAILED) ? "FAILED" : "SUCCEEDED", vha->host_no, id, lun); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1181 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1182 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1183 | } |
| 1184 | |
| 1185 | /************************************************************************** |
| 1186 | * qla2xxx_eh_host_reset |
| 1187 | * |
| 1188 | * Description: |
| 1189 | * The reset function will reset the Adapter. |
| 1190 | * |
| 1191 | * Input: |
| 1192 | * cmd = Linux SCSI command packet of the command that cause the |
| 1193 | * adapter reset. |
| 1194 | * |
| 1195 | * Returns: |
| 1196 | * Either SUCCESS or FAILED. |
| 1197 | * |
| 1198 | * Note: |
| 1199 | **************************************************************************/ |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 1200 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1201 | qla2xxx_eh_host_reset(struct scsi_cmnd *cmd) |
| 1202 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1203 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1204 | struct qla_hw_data *ha = vha->hw; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1205 | int ret = FAILED; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1206 | unsigned int id, lun; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1207 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1208 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1209 | id = cmd->device->id; |
| 1210 | lun = cmd->device->lun; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1211 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1212 | ql_log(ql_log_info, vha, 0x8018, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1213 | "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] | 1214 | |
Lalit Chandivade | 86fbee8 | 2010-05-04 15:01:32 -0700 | [diff] [blame] | 1215 | if (qla2x00_wait_for_reset_ready(vha) != QLA_SUCCESS) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1216 | goto eh_host_reset_lock; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1217 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1218 | if (vha != base_vha) { |
| 1219 | if (qla2x00_vp_abort_isp(vha)) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1220 | goto eh_host_reset_lock; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1221 | } else { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1222 | if (IS_QLA82XX(vha->hw)) { |
| 1223 | if (!qla82xx_fcoe_ctx_reset(vha)) { |
| 1224 | /* Ctx reset success */ |
| 1225 | ret = SUCCESS; |
| 1226 | goto eh_host_reset_lock; |
| 1227 | } |
| 1228 | /* fall thru if ctx reset failed */ |
| 1229 | } |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 1230 | if (ha->wq) |
| 1231 | flush_workqueue(ha->wq); |
| 1232 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1233 | set_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1234 | if (ha->isp_ops->abort_isp(base_vha)) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1235 | clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
| 1236 | /* failed. schedule dpc to try */ |
| 1237 | set_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags); |
| 1238 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1239 | if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) { |
| 1240 | ql_log(ql_log_warn, vha, 0x802a, |
| 1241 | "wait for hba online failed.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1242 | goto eh_host_reset_lock; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1243 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1244 | } |
| 1245 | clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1246 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1247 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1248 | /* Waiting for command to be returned to OS.*/ |
Giridhar Malavali | 4d78c97 | 2010-07-23 15:28:35 +0500 | [diff] [blame] | 1249 | if (qla2x00_eh_wait_for_pending_commands(vha, 0, 0, WAIT_HOST) == |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1250 | QLA_SUCCESS) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1251 | ret = SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1252 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1253 | eh_host_reset_lock: |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1254 | ql_log(ql_log_info, vha, 0x8017, |
| 1255 | "ADAPTER RESET %s nexus=%ld:%d:%d.\n", |
| 1256 | (ret == FAILED) ? "FAILED" : "SUCCEEDED", vha->host_no, id, lun); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1257 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1258 | return ret; |
| 1259 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1260 | |
| 1261 | /* |
| 1262 | * qla2x00_loop_reset |
| 1263 | * Issue loop reset. |
| 1264 | * |
| 1265 | * Input: |
| 1266 | * ha = adapter block pointer. |
| 1267 | * |
| 1268 | * Returns: |
| 1269 | * 0 = success |
| 1270 | */ |
Andrew Vasquez | a4722cf | 2008-01-17 09:02:12 -0800 | [diff] [blame] | 1271 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1272 | qla2x00_loop_reset(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1273 | { |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 1274 | int ret; |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 1275 | struct fc_port *fcport; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1276 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1277 | |
Giridhar Malavali | f4c496c | 2010-05-04 15:01:33 -0700 | [diff] [blame] | 1278 | if (ql2xtargetreset == 1 && ha->flags.enable_target_reset) { |
Andrew Vasquez | 55e5ed2 | 2010-02-18 10:07:25 -0800 | [diff] [blame] | 1279 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
| 1280 | if (fcport->port_type != FCT_TARGET) |
| 1281 | continue; |
| 1282 | |
| 1283 | ret = ha->isp_ops->target_reset(fcport, 0, 0); |
| 1284 | if (ret != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1285 | ql_dbg(ql_dbg_taskm, vha, 0x802c, |
| 1286 | "Bus Reset failed: Target Reset=%d " |
| 1287 | "d_id=%x.\n", ret, fcport->d_id.b24); |
Andrew Vasquez | 55e5ed2 | 2010-02-18 10:07:25 -0800 | [diff] [blame] | 1288 | } |
| 1289 | } |
| 1290 | } |
| 1291 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1292 | if (ha->flags.enable_lip_full_login && !IS_CNA_CAPABLE(ha)) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1293 | ret = qla2x00_full_login_lip(vha); |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 1294 | if (ret != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1295 | ql_dbg(ql_dbg_taskm, vha, 0x802d, |
| 1296 | "full_login_lip=%d.\n", ret); |
Anirban Chakraborty | 749af3d | 2008-11-14 13:48:12 -0800 | [diff] [blame] | 1297 | } |
| 1298 | atomic_set(&vha->loop_state, LOOP_DOWN); |
| 1299 | atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME); |
| 1300 | qla2x00_mark_all_devices_lost(vha, 0); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1301 | } |
| 1302 | |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 1303 | if (ha->flags.enable_lip_reset) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1304 | ret = qla2x00_lip_reset(vha); |
Saurav Kashyap | ad53768 | 2011-11-18 09:02:09 -0800 | [diff] [blame] | 1305 | if (ret != QLA_SUCCESS) |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1306 | ql_dbg(ql_dbg_taskm, vha, 0x802e, |
| 1307 | "lip_reset failed (%d).\n", ret); |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 1308 | } |
| 1309 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1310 | /* 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] | 1311 | vha->marker_needed = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1312 | |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 1313 | return QLA_SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1314 | } |
| 1315 | |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1316 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1317 | qla2x00_abort_all_cmds(scsi_qla_host_t *vha, int res) |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1318 | { |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1319 | int que, cnt; |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1320 | unsigned long flags; |
| 1321 | srb_t *sp; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1322 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1323 | struct req_que *req; |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1324 | |
| 1325 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1326 | for (que = 0; que < ha->max_req_queues; que++) { |
Anirban Chakraborty | 29bdccb | 2009-01-08 15:41:08 -0800 | [diff] [blame] | 1327 | req = ha->req_q_map[que]; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1328 | if (!req) |
| 1329 | continue; |
| 1330 | for (cnt = 1; cnt < MAX_OUTSTANDING_COMMANDS; cnt++) { |
| 1331 | sp = req->outstanding_cmds[cnt]; |
Andrew Vasquez | e612d46 | 2009-03-24 09:08:04 -0700 | [diff] [blame] | 1332 | if (sp) { |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1333 | req->outstanding_cmds[cnt] = NULL; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 1334 | sp->done(vha, sp, res); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1335 | } |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1336 | } |
| 1337 | } |
| 1338 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1339 | } |
| 1340 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1341 | static int |
| 1342 | qla2xxx_slave_alloc(struct scsi_device *sdev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1343 | { |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 1344 | struct fc_rport *rport = starget_to_rport(scsi_target(sdev)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1345 | |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 1346 | if (!rport || fc_remote_port_chkready(rport)) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1347 | return -ENXIO; |
| 1348 | |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 1349 | sdev->hostdata = *(fc_port_t **)rport->dd_data; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1350 | |
| 1351 | return 0; |
| 1352 | } |
| 1353 | |
| 1354 | static int |
| 1355 | qla2xxx_slave_configure(struct scsi_device *sdev) |
| 1356 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1357 | scsi_qla_host_t *vha = shost_priv(sdev->host); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1358 | struct req_que *req = vha->req; |
| 8482e118 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 1359 | |
Arun Easi | 9e522cd | 2012-08-22 14:21:31 -0400 | [diff] [blame] | 1360 | if (IS_T10_PI_CAPABLE(vha->hw)) |
| 1361 | blk_queue_update_dma_alignment(sdev->request_queue, 0x7); |
| 1362 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1363 | if (sdev->tagged_supported) |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1364 | scsi_activate_tcq(sdev, req->max_q_depth); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1365 | else |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1366 | scsi_deactivate_tcq(sdev, req->max_q_depth); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1367 | return 0; |
| 1368 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1369 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1370 | static void |
| 1371 | qla2xxx_slave_destroy(struct scsi_device *sdev) |
| 1372 | { |
| 1373 | sdev->hostdata = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1374 | } |
| 1375 | |
Giridhar Malavali | c45dd30 | 2009-12-02 10:36:54 -0800 | [diff] [blame] | 1376 | static void qla2x00_handle_queue_full(struct scsi_device *sdev, int qdepth) |
| 1377 | { |
| 1378 | fc_port_t *fcport = (struct fc_port *) sdev->hostdata; |
| 1379 | |
| 1380 | if (!scsi_track_queue_full(sdev, qdepth)) |
| 1381 | return; |
| 1382 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1383 | ql_dbg(ql_dbg_io, fcport->vha, 0x3029, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1384 | "Queue depth adjusted-down to %d for nexus=%ld:%d:%d.\n", |
| 1385 | sdev->queue_depth, fcport->vha->host_no, sdev->id, sdev->lun); |
Giridhar Malavali | c45dd30 | 2009-12-02 10:36:54 -0800 | [diff] [blame] | 1386 | } |
| 1387 | |
| 1388 | static void qla2x00_adjust_sdev_qdepth_up(struct scsi_device *sdev, int qdepth) |
| 1389 | { |
| 1390 | fc_port_t *fcport = sdev->hostdata; |
| 1391 | struct scsi_qla_host *vha = fcport->vha; |
Giridhar Malavali | c45dd30 | 2009-12-02 10:36:54 -0800 | [diff] [blame] | 1392 | struct req_que *req = NULL; |
| 1393 | |
| 1394 | req = vha->req; |
| 1395 | if (!req) |
| 1396 | return; |
| 1397 | |
| 1398 | if (req->max_q_depth <= sdev->queue_depth || req->max_q_depth < qdepth) |
| 1399 | return; |
| 1400 | |
| 1401 | if (sdev->ordered_tags) |
| 1402 | scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG, qdepth); |
| 1403 | else |
| 1404 | scsi_adjust_queue_depth(sdev, MSG_SIMPLE_TAG, qdepth); |
| 1405 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 1406 | ql_dbg(ql_dbg_io, vha, 0x302a, |
Chad Dupuis | cfb0919 | 2011-11-18 09:03:07 -0800 | [diff] [blame] | 1407 | "Queue depth adjusted-up to %d for nexus=%ld:%d:%d.\n", |
| 1408 | sdev->queue_depth, fcport->vha->host_no, sdev->id, sdev->lun); |
Giridhar Malavali | c45dd30 | 2009-12-02 10:36:54 -0800 | [diff] [blame] | 1409 | } |
| 1410 | |
Andrew Vasquez | ce7e4af | 2005-08-26 19:09:30 -0700 | [diff] [blame] | 1411 | static int |
Mike Christie | e881a17 | 2009-10-15 17:46:39 -0700 | [diff] [blame] | 1412 | qla2x00_change_queue_depth(struct scsi_device *sdev, int qdepth, int reason) |
Andrew Vasquez | ce7e4af | 2005-08-26 19:09:30 -0700 | [diff] [blame] | 1413 | { |
Giridhar Malavali | c45dd30 | 2009-12-02 10:36:54 -0800 | [diff] [blame] | 1414 | switch (reason) { |
| 1415 | case SCSI_QDEPTH_DEFAULT: |
| 1416 | scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), qdepth); |
| 1417 | break; |
| 1418 | case SCSI_QDEPTH_QFULL: |
| 1419 | qla2x00_handle_queue_full(sdev, qdepth); |
| 1420 | break; |
| 1421 | case SCSI_QDEPTH_RAMP_UP: |
| 1422 | qla2x00_adjust_sdev_qdepth_up(sdev, qdepth); |
| 1423 | break; |
| 1424 | default: |
Roel Kluin | 08002af | 2010-01-29 11:25:19 +0100 | [diff] [blame] | 1425 | return -EOPNOTSUPP; |
Giridhar Malavali | c45dd30 | 2009-12-02 10:36:54 -0800 | [diff] [blame] | 1426 | } |
Mike Christie | e881a17 | 2009-10-15 17:46:39 -0700 | [diff] [blame] | 1427 | |
Andrew Vasquez | ce7e4af | 2005-08-26 19:09:30 -0700 | [diff] [blame] | 1428 | return sdev->queue_depth; |
| 1429 | } |
| 1430 | |
| 1431 | static int |
| 1432 | qla2x00_change_queue_type(struct scsi_device *sdev, int tag_type) |
| 1433 | { |
| 1434 | if (sdev->tagged_supported) { |
| 1435 | scsi_set_tag_type(sdev, tag_type); |
| 1436 | if (tag_type) |
| 1437 | scsi_activate_tcq(sdev, sdev->queue_depth); |
| 1438 | else |
| 1439 | scsi_deactivate_tcq(sdev, sdev->queue_depth); |
| 1440 | } else |
| 1441 | tag_type = 0; |
| 1442 | |
| 1443 | return tag_type; |
| 1444 | } |
| 1445 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1446 | /** |
| 1447 | * qla2x00_config_dma_addressing() - Configure OS DMA addressing method. |
| 1448 | * @ha: HA context |
| 1449 | * |
| 1450 | * At exit, the @ha's flags.enable_64bit_addressing set to indicated |
| 1451 | * supported addressing method. |
| 1452 | */ |
| 1453 | static void |
Andrew Vasquez | 53303c4 | 2009-01-22 09:45:37 -0800 | [diff] [blame] | 1454 | qla2x00_config_dma_addressing(struct qla_hw_data *ha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1455 | { |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1456 | /* Assume a 32bit DMA mask. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1457 | ha->flags.enable_64bit_addressing = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1458 | |
Yang Hongyang | 6a35528 | 2009-04-06 19:01:13 -0700 | [diff] [blame] | 1459 | if (!dma_set_mask(&ha->pdev->dev, DMA_BIT_MASK(64))) { |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1460 | /* Any upper-dword bits set? */ |
| 1461 | if (MSD(dma_get_required_mask(&ha->pdev->dev)) && |
Yang Hongyang | 6a35528 | 2009-04-06 19:01:13 -0700 | [diff] [blame] | 1462 | !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) { |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1463 | /* Ok, a 64bit DMA mask is applicable. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1464 | ha->flags.enable_64bit_addressing = 1; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1465 | ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64; |
| 1466 | ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64; |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1467 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1468 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1469 | } |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1470 | |
Yang Hongyang | 284901a | 2009-04-06 19:01:15 -0700 | [diff] [blame] | 1471 | dma_set_mask(&ha->pdev->dev, DMA_BIT_MASK(32)); |
| 1472 | pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(32)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1473 | } |
| 1474 | |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1475 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1476 | qla2x00_enable_intrs(struct qla_hw_data *ha) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1477 | { |
| 1478 | unsigned long flags = 0; |
| 1479 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
| 1480 | |
| 1481 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1482 | ha->interrupts_on = 1; |
| 1483 | /* enable risc and host interrupts */ |
| 1484 | WRT_REG_WORD(®->ictrl, ICR_EN_INT | ICR_EN_RISC); |
| 1485 | RD_REG_WORD(®->ictrl); |
| 1486 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1487 | |
| 1488 | } |
| 1489 | |
| 1490 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1491 | qla2x00_disable_intrs(struct qla_hw_data *ha) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1492 | { |
| 1493 | unsigned long flags = 0; |
| 1494 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
| 1495 | |
| 1496 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1497 | ha->interrupts_on = 0; |
| 1498 | /* disable risc and host interrupts */ |
| 1499 | WRT_REG_WORD(®->ictrl, 0); |
| 1500 | RD_REG_WORD(®->ictrl); |
| 1501 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1502 | } |
| 1503 | |
| 1504 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1505 | qla24xx_enable_intrs(struct qla_hw_data *ha) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1506 | { |
| 1507 | unsigned long flags = 0; |
| 1508 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
| 1509 | |
| 1510 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1511 | ha->interrupts_on = 1; |
| 1512 | WRT_REG_DWORD(®->ictrl, ICRX_EN_RISC_INT); |
| 1513 | RD_REG_DWORD(®->ictrl); |
| 1514 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1515 | } |
| 1516 | |
| 1517 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1518 | qla24xx_disable_intrs(struct qla_hw_data *ha) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1519 | { |
| 1520 | unsigned long flags = 0; |
| 1521 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
| 1522 | |
Andrew Vasquez | 124f85e | 2009-01-05 11:18:06 -0800 | [diff] [blame] | 1523 | if (IS_NOPOLLING_TYPE(ha)) |
| 1524 | return; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1525 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1526 | ha->interrupts_on = 0; |
| 1527 | WRT_REG_DWORD(®->ictrl, 0); |
| 1528 | RD_REG_DWORD(®->ictrl); |
| 1529 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1530 | } |
| 1531 | |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1532 | static int |
| 1533 | qla2x00_iospace_config(struct qla_hw_data *ha) |
| 1534 | { |
| 1535 | resource_size_t pio; |
| 1536 | uint16_t msix; |
| 1537 | int cpus; |
| 1538 | |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1539 | if (pci_request_selected_regions(ha->pdev, ha->bars, |
| 1540 | QLA2XXX_DRIVER_NAME)) { |
| 1541 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0011, |
| 1542 | "Failed to reserve PIO/MMIO regions (%s), aborting.\n", |
| 1543 | pci_name(ha->pdev)); |
| 1544 | goto iospace_error_exit; |
| 1545 | } |
| 1546 | if (!(ha->bars & 1)) |
| 1547 | goto skip_pio; |
| 1548 | |
| 1549 | /* We only need PIO for Flash operations on ISP2312 v2 chips. */ |
| 1550 | pio = pci_resource_start(ha->pdev, 0); |
| 1551 | if (pci_resource_flags(ha->pdev, 0) & IORESOURCE_IO) { |
| 1552 | if (pci_resource_len(ha->pdev, 0) < MIN_IOBASE_LEN) { |
| 1553 | ql_log_pci(ql_log_warn, ha->pdev, 0x0012, |
| 1554 | "Invalid pci I/O region size (%s).\n", |
| 1555 | pci_name(ha->pdev)); |
| 1556 | pio = 0; |
| 1557 | } |
| 1558 | } else { |
| 1559 | ql_log_pci(ql_log_warn, ha->pdev, 0x0013, |
| 1560 | "Region #0 no a PIO resource (%s).\n", |
| 1561 | pci_name(ha->pdev)); |
| 1562 | pio = 0; |
| 1563 | } |
| 1564 | ha->pio_address = pio; |
| 1565 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0014, |
| 1566 | "PIO address=%llu.\n", |
| 1567 | (unsigned long long)ha->pio_address); |
| 1568 | |
| 1569 | skip_pio: |
| 1570 | /* Use MMIO operations for all accesses. */ |
| 1571 | if (!(pci_resource_flags(ha->pdev, 1) & IORESOURCE_MEM)) { |
| 1572 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0015, |
| 1573 | "Region #1 not an MMIO resource (%s), aborting.\n", |
| 1574 | pci_name(ha->pdev)); |
| 1575 | goto iospace_error_exit; |
| 1576 | } |
| 1577 | if (pci_resource_len(ha->pdev, 1) < MIN_IOBASE_LEN) { |
| 1578 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0016, |
| 1579 | "Invalid PCI mem region size (%s), aborting.\n", |
| 1580 | pci_name(ha->pdev)); |
| 1581 | goto iospace_error_exit; |
| 1582 | } |
| 1583 | |
| 1584 | ha->iobase = ioremap(pci_resource_start(ha->pdev, 1), MIN_IOBASE_LEN); |
| 1585 | if (!ha->iobase) { |
| 1586 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0017, |
| 1587 | "Cannot remap MMIO (%s), aborting.\n", |
| 1588 | pci_name(ha->pdev)); |
| 1589 | goto iospace_error_exit; |
| 1590 | } |
| 1591 | |
| 1592 | /* Determine queue resources */ |
| 1593 | ha->max_req_queues = ha->max_rsp_queues = 1; |
| 1594 | if ((ql2xmaxqueues <= 1 && !ql2xmultique_tag) || |
| 1595 | (ql2xmaxqueues > 1 && ql2xmultique_tag) || |
| 1596 | (!IS_QLA25XX(ha) && !IS_QLA81XX(ha))) |
| 1597 | goto mqiobase_exit; |
| 1598 | |
| 1599 | ha->mqiobase = ioremap(pci_resource_start(ha->pdev, 3), |
| 1600 | pci_resource_len(ha->pdev, 3)); |
| 1601 | if (ha->mqiobase) { |
| 1602 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0018, |
| 1603 | "MQIO Base=%p.\n", ha->mqiobase); |
| 1604 | /* Read MSIX vector size of the board */ |
| 1605 | pci_read_config_word(ha->pdev, QLA_PCI_MSIX_CONTROL, &msix); |
| 1606 | ha->msix_count = msix; |
| 1607 | /* Max queues are bounded by available msix vectors */ |
| 1608 | /* queue 0 uses two msix vectors */ |
| 1609 | if (ql2xmultique_tag) { |
| 1610 | cpus = num_online_cpus(); |
| 1611 | ha->max_rsp_queues = (ha->msix_count - 1 > cpus) ? |
| 1612 | (cpus + 1) : (ha->msix_count - 1); |
| 1613 | ha->max_req_queues = 2; |
| 1614 | } else if (ql2xmaxqueues > 1) { |
| 1615 | ha->max_req_queues = ql2xmaxqueues > QLA_MQ_SIZE ? |
| 1616 | QLA_MQ_SIZE : ql2xmaxqueues; |
| 1617 | ql_dbg_pci(ql_dbg_multiq, ha->pdev, 0xc008, |
| 1618 | "QoS mode set, max no of request queues:%d.\n", |
| 1619 | ha->max_req_queues); |
| 1620 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0019, |
| 1621 | "QoS mode set, max no of request queues:%d.\n", |
| 1622 | ha->max_req_queues); |
| 1623 | } |
| 1624 | ql_log_pci(ql_log_info, ha->pdev, 0x001a, |
| 1625 | "MSI-X vector count: %d.\n", msix); |
| 1626 | } else |
| 1627 | ql_log_pci(ql_log_info, ha->pdev, 0x001b, |
| 1628 | "BAR 3 not enabled.\n"); |
| 1629 | |
| 1630 | mqiobase_exit: |
| 1631 | ha->msix_count = ha->max_rsp_queues + 1; |
| 1632 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x001c, |
| 1633 | "MSIX Count:%d.\n", ha->msix_count); |
| 1634 | return (0); |
| 1635 | |
| 1636 | iospace_error_exit: |
| 1637 | return (-ENOMEM); |
| 1638 | } |
| 1639 | |
| 1640 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1641 | static int |
| 1642 | qla83xx_iospace_config(struct qla_hw_data *ha) |
| 1643 | { |
| 1644 | uint16_t msix; |
| 1645 | int cpus; |
| 1646 | |
| 1647 | if (pci_request_selected_regions(ha->pdev, ha->bars, |
| 1648 | QLA2XXX_DRIVER_NAME)) { |
| 1649 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0117, |
| 1650 | "Failed to reserve PIO/MMIO regions (%s), aborting.\n", |
| 1651 | pci_name(ha->pdev)); |
| 1652 | |
| 1653 | goto iospace_error_exit; |
| 1654 | } |
| 1655 | |
| 1656 | /* Use MMIO operations for all accesses. */ |
| 1657 | if (!(pci_resource_flags(ha->pdev, 0) & IORESOURCE_MEM)) { |
| 1658 | ql_log_pci(ql_log_warn, ha->pdev, 0x0118, |
| 1659 | "Invalid pci I/O region size (%s).\n", |
| 1660 | pci_name(ha->pdev)); |
| 1661 | goto iospace_error_exit; |
| 1662 | } |
| 1663 | if (pci_resource_len(ha->pdev, 0) < MIN_IOBASE_LEN) { |
| 1664 | ql_log_pci(ql_log_warn, ha->pdev, 0x0119, |
| 1665 | "Invalid PCI mem region size (%s), aborting\n", |
| 1666 | pci_name(ha->pdev)); |
| 1667 | goto iospace_error_exit; |
| 1668 | } |
| 1669 | |
| 1670 | ha->iobase = ioremap(pci_resource_start(ha->pdev, 0), MIN_IOBASE_LEN); |
| 1671 | if (!ha->iobase) { |
| 1672 | ql_log_pci(ql_log_fatal, ha->pdev, 0x011a, |
| 1673 | "Cannot remap MMIO (%s), aborting.\n", |
| 1674 | pci_name(ha->pdev)); |
| 1675 | goto iospace_error_exit; |
| 1676 | } |
| 1677 | |
| 1678 | /* 64bit PCI BAR - BAR2 will correspoond to region 4 */ |
| 1679 | /* 83XX 26XX always use MQ type access for queues |
| 1680 | * - mbar 2, a.k.a region 4 */ |
| 1681 | ha->max_req_queues = ha->max_rsp_queues = 1; |
| 1682 | ha->mqiobase = ioremap(pci_resource_start(ha->pdev, 4), |
| 1683 | pci_resource_len(ha->pdev, 4)); |
| 1684 | |
| 1685 | if (!ha->mqiobase) { |
| 1686 | ql_log_pci(ql_log_fatal, ha->pdev, 0x011d, |
| 1687 | "BAR2/region4 not enabled\n"); |
| 1688 | goto mqiobase_exit; |
| 1689 | } |
| 1690 | |
| 1691 | ha->msixbase = ioremap(pci_resource_start(ha->pdev, 2), |
| 1692 | pci_resource_len(ha->pdev, 2)); |
| 1693 | if (ha->msixbase) { |
| 1694 | /* Read MSIX vector size of the board */ |
| 1695 | pci_read_config_word(ha->pdev, |
| 1696 | QLA_83XX_PCI_MSIX_CONTROL, &msix); |
| 1697 | ha->msix_count = msix; |
| 1698 | /* Max queues are bounded by available msix vectors */ |
| 1699 | /* queue 0 uses two msix vectors */ |
| 1700 | if (ql2xmultique_tag) { |
| 1701 | cpus = num_online_cpus(); |
| 1702 | ha->max_rsp_queues = (ha->msix_count - 1 > cpus) ? |
| 1703 | (cpus + 1) : (ha->msix_count - 1); |
| 1704 | ha->max_req_queues = 2; |
| 1705 | } else if (ql2xmaxqueues > 1) { |
| 1706 | ha->max_req_queues = ql2xmaxqueues > QLA_MQ_SIZE ? |
| 1707 | QLA_MQ_SIZE : ql2xmaxqueues; |
| 1708 | ql_dbg_pci(ql_dbg_multiq, ha->pdev, 0xc00c, |
| 1709 | "QoS mode set, max no of request queues:%d.\n", |
| 1710 | ha->max_req_queues); |
| 1711 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x011b, |
| 1712 | "QoS mode set, max no of request queues:%d.\n", |
| 1713 | ha->max_req_queues); |
| 1714 | } |
| 1715 | ql_log_pci(ql_log_info, ha->pdev, 0x011c, |
| 1716 | "MSI-X vector count: %d.\n", msix); |
| 1717 | } else |
| 1718 | ql_log_pci(ql_log_info, ha->pdev, 0x011e, |
| 1719 | "BAR 1 not enabled.\n"); |
| 1720 | |
| 1721 | mqiobase_exit: |
| 1722 | ha->msix_count = ha->max_rsp_queues + 1; |
| 1723 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x011f, |
| 1724 | "MSIX Count:%d.\n", ha->msix_count); |
| 1725 | return 0; |
| 1726 | |
| 1727 | iospace_error_exit: |
| 1728 | return -ENOMEM; |
| 1729 | } |
| 1730 | |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1731 | static struct isp_operations qla2100_isp_ops = { |
| 1732 | .pci_config = qla2100_pci_config, |
| 1733 | .reset_chip = qla2x00_reset_chip, |
| 1734 | .chip_diag = qla2x00_chip_diag, |
| 1735 | .config_rings = qla2x00_config_rings, |
| 1736 | .reset_adapter = qla2x00_reset_adapter, |
| 1737 | .nvram_config = qla2x00_nvram_config, |
| 1738 | .update_fw_options = qla2x00_update_fw_options, |
| 1739 | .load_risc = qla2x00_load_risc, |
| 1740 | .pci_info_str = qla2x00_pci_info_str, |
| 1741 | .fw_version_str = qla2x00_fw_version_str, |
| 1742 | .intr_handler = qla2100_intr_handler, |
| 1743 | .enable_intrs = qla2x00_enable_intrs, |
| 1744 | .disable_intrs = qla2x00_disable_intrs, |
| 1745 | .abort_command = qla2x00_abort_command, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1746 | .target_reset = qla2x00_abort_target, |
| 1747 | .lun_reset = qla2x00_lun_reset, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1748 | .fabric_login = qla2x00_login_fabric, |
| 1749 | .fabric_logout = qla2x00_fabric_logout, |
| 1750 | .calc_req_entries = qla2x00_calc_iocbs_32, |
| 1751 | .build_iocbs = qla2x00_build_scsi_iocbs_32, |
| 1752 | .prep_ms_iocb = qla2x00_prep_ms_iocb, |
| 1753 | .prep_ms_fdmi_iocb = qla2x00_prep_ms_fdmi_iocb, |
| 1754 | .read_nvram = qla2x00_read_nvram_data, |
| 1755 | .write_nvram = qla2x00_write_nvram_data, |
| 1756 | .fw_dump = qla2100_fw_dump, |
| 1757 | .beacon_on = NULL, |
| 1758 | .beacon_off = NULL, |
| 1759 | .beacon_blink = NULL, |
| 1760 | .read_optrom = qla2x00_read_optrom_data, |
| 1761 | .write_optrom = qla2x00_write_optrom_data, |
| 1762 | .get_flash_version = qla2x00_get_flash_version, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1763 | .start_scsi = qla2x00_start_scsi, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1764 | .abort_isp = qla2x00_abort_isp, |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1765 | .iospace_config = qla2x00_iospace_config, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1766 | }; |
| 1767 | |
| 1768 | static struct isp_operations qla2300_isp_ops = { |
| 1769 | .pci_config = qla2300_pci_config, |
| 1770 | .reset_chip = qla2x00_reset_chip, |
| 1771 | .chip_diag = qla2x00_chip_diag, |
| 1772 | .config_rings = qla2x00_config_rings, |
| 1773 | .reset_adapter = qla2x00_reset_adapter, |
| 1774 | .nvram_config = qla2x00_nvram_config, |
| 1775 | .update_fw_options = qla2x00_update_fw_options, |
| 1776 | .load_risc = qla2x00_load_risc, |
| 1777 | .pci_info_str = qla2x00_pci_info_str, |
| 1778 | .fw_version_str = qla2x00_fw_version_str, |
| 1779 | .intr_handler = qla2300_intr_handler, |
| 1780 | .enable_intrs = qla2x00_enable_intrs, |
| 1781 | .disable_intrs = qla2x00_disable_intrs, |
| 1782 | .abort_command = qla2x00_abort_command, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1783 | .target_reset = qla2x00_abort_target, |
| 1784 | .lun_reset = qla2x00_lun_reset, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1785 | .fabric_login = qla2x00_login_fabric, |
| 1786 | .fabric_logout = qla2x00_fabric_logout, |
| 1787 | .calc_req_entries = qla2x00_calc_iocbs_32, |
| 1788 | .build_iocbs = qla2x00_build_scsi_iocbs_32, |
| 1789 | .prep_ms_iocb = qla2x00_prep_ms_iocb, |
| 1790 | .prep_ms_fdmi_iocb = qla2x00_prep_ms_fdmi_iocb, |
| 1791 | .read_nvram = qla2x00_read_nvram_data, |
| 1792 | .write_nvram = qla2x00_write_nvram_data, |
| 1793 | .fw_dump = qla2300_fw_dump, |
| 1794 | .beacon_on = qla2x00_beacon_on, |
| 1795 | .beacon_off = qla2x00_beacon_off, |
| 1796 | .beacon_blink = qla2x00_beacon_blink, |
| 1797 | .read_optrom = qla2x00_read_optrom_data, |
| 1798 | .write_optrom = qla2x00_write_optrom_data, |
| 1799 | .get_flash_version = qla2x00_get_flash_version, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1800 | .start_scsi = qla2x00_start_scsi, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1801 | .abort_isp = qla2x00_abort_isp, |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1802 | .iospace_config = qla2x00_iospace_config, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1803 | }; |
| 1804 | |
| 1805 | static struct isp_operations qla24xx_isp_ops = { |
| 1806 | .pci_config = qla24xx_pci_config, |
| 1807 | .reset_chip = qla24xx_reset_chip, |
| 1808 | .chip_diag = qla24xx_chip_diag, |
| 1809 | .config_rings = qla24xx_config_rings, |
| 1810 | .reset_adapter = qla24xx_reset_adapter, |
| 1811 | .nvram_config = qla24xx_nvram_config, |
| 1812 | .update_fw_options = qla24xx_update_fw_options, |
| 1813 | .load_risc = qla24xx_load_risc, |
| 1814 | .pci_info_str = qla24xx_pci_info_str, |
| 1815 | .fw_version_str = qla24xx_fw_version_str, |
| 1816 | .intr_handler = qla24xx_intr_handler, |
| 1817 | .enable_intrs = qla24xx_enable_intrs, |
| 1818 | .disable_intrs = qla24xx_disable_intrs, |
| 1819 | .abort_command = qla24xx_abort_command, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1820 | .target_reset = qla24xx_abort_target, |
| 1821 | .lun_reset = qla24xx_lun_reset, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1822 | .fabric_login = qla24xx_login_fabric, |
| 1823 | .fabric_logout = qla24xx_fabric_logout, |
| 1824 | .calc_req_entries = NULL, |
| 1825 | .build_iocbs = NULL, |
| 1826 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 1827 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 1828 | .read_nvram = qla24xx_read_nvram_data, |
| 1829 | .write_nvram = qla24xx_write_nvram_data, |
| 1830 | .fw_dump = qla24xx_fw_dump, |
| 1831 | .beacon_on = qla24xx_beacon_on, |
| 1832 | .beacon_off = qla24xx_beacon_off, |
| 1833 | .beacon_blink = qla24xx_beacon_blink, |
| 1834 | .read_optrom = qla24xx_read_optrom_data, |
| 1835 | .write_optrom = qla24xx_write_optrom_data, |
| 1836 | .get_flash_version = qla24xx_get_flash_version, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1837 | .start_scsi = qla24xx_start_scsi, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1838 | .abort_isp = qla2x00_abort_isp, |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1839 | .iospace_config = qla2x00_iospace_config, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1840 | }; |
| 1841 | |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1842 | static struct isp_operations qla25xx_isp_ops = { |
| 1843 | .pci_config = qla25xx_pci_config, |
| 1844 | .reset_chip = qla24xx_reset_chip, |
| 1845 | .chip_diag = qla24xx_chip_diag, |
| 1846 | .config_rings = qla24xx_config_rings, |
| 1847 | .reset_adapter = qla24xx_reset_adapter, |
| 1848 | .nvram_config = qla24xx_nvram_config, |
| 1849 | .update_fw_options = qla24xx_update_fw_options, |
| 1850 | .load_risc = qla24xx_load_risc, |
| 1851 | .pci_info_str = qla24xx_pci_info_str, |
| 1852 | .fw_version_str = qla24xx_fw_version_str, |
| 1853 | .intr_handler = qla24xx_intr_handler, |
| 1854 | .enable_intrs = qla24xx_enable_intrs, |
| 1855 | .disable_intrs = qla24xx_disable_intrs, |
| 1856 | .abort_command = qla24xx_abort_command, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1857 | .target_reset = qla24xx_abort_target, |
| 1858 | .lun_reset = qla24xx_lun_reset, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1859 | .fabric_login = qla24xx_login_fabric, |
| 1860 | .fabric_logout = qla24xx_fabric_logout, |
| 1861 | .calc_req_entries = NULL, |
| 1862 | .build_iocbs = NULL, |
| 1863 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 1864 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 1865 | .read_nvram = qla25xx_read_nvram_data, |
| 1866 | .write_nvram = qla25xx_write_nvram_data, |
| 1867 | .fw_dump = qla25xx_fw_dump, |
| 1868 | .beacon_on = qla24xx_beacon_on, |
| 1869 | .beacon_off = qla24xx_beacon_off, |
| 1870 | .beacon_blink = qla24xx_beacon_blink, |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 1871 | .read_optrom = qla25xx_read_optrom_data, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1872 | .write_optrom = qla24xx_write_optrom_data, |
| 1873 | .get_flash_version = qla24xx_get_flash_version, |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 1874 | .start_scsi = qla24xx_dif_start_scsi, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1875 | .abort_isp = qla2x00_abort_isp, |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1876 | .iospace_config = qla2x00_iospace_config, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1877 | }; |
| 1878 | |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 1879 | static struct isp_operations qla81xx_isp_ops = { |
| 1880 | .pci_config = qla25xx_pci_config, |
| 1881 | .reset_chip = qla24xx_reset_chip, |
| 1882 | .chip_diag = qla24xx_chip_diag, |
| 1883 | .config_rings = qla24xx_config_rings, |
| 1884 | .reset_adapter = qla24xx_reset_adapter, |
| 1885 | .nvram_config = qla81xx_nvram_config, |
| 1886 | .update_fw_options = qla81xx_update_fw_options, |
Andrew Vasquez | eaac30b | 2009-01-22 09:45:32 -0800 | [diff] [blame] | 1887 | .load_risc = qla81xx_load_risc, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 1888 | .pci_info_str = qla24xx_pci_info_str, |
| 1889 | .fw_version_str = qla24xx_fw_version_str, |
| 1890 | .intr_handler = qla24xx_intr_handler, |
| 1891 | .enable_intrs = qla24xx_enable_intrs, |
| 1892 | .disable_intrs = qla24xx_disable_intrs, |
| 1893 | .abort_command = qla24xx_abort_command, |
| 1894 | .target_reset = qla24xx_abort_target, |
| 1895 | .lun_reset = qla24xx_lun_reset, |
| 1896 | .fabric_login = qla24xx_login_fabric, |
| 1897 | .fabric_logout = qla24xx_fabric_logout, |
| 1898 | .calc_req_entries = NULL, |
| 1899 | .build_iocbs = NULL, |
| 1900 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 1901 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
Andrew Vasquez | 3d79038f | 2009-03-24 09:08:14 -0700 | [diff] [blame] | 1902 | .read_nvram = NULL, |
| 1903 | .write_nvram = NULL, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 1904 | .fw_dump = qla81xx_fw_dump, |
| 1905 | .beacon_on = qla24xx_beacon_on, |
| 1906 | .beacon_off = qla24xx_beacon_off, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1907 | .beacon_blink = qla83xx_beacon_blink, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 1908 | .read_optrom = qla25xx_read_optrom_data, |
| 1909 | .write_optrom = qla24xx_write_optrom_data, |
| 1910 | .get_flash_version = qla24xx_get_flash_version, |
Arun Easi | ba77ef5 | 2010-05-28 15:08:27 -0700 | [diff] [blame] | 1911 | .start_scsi = qla24xx_dif_start_scsi, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1912 | .abort_isp = qla2x00_abort_isp, |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1913 | .iospace_config = qla2x00_iospace_config, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1914 | }; |
| 1915 | |
| 1916 | static struct isp_operations qla82xx_isp_ops = { |
| 1917 | .pci_config = qla82xx_pci_config, |
| 1918 | .reset_chip = qla82xx_reset_chip, |
| 1919 | .chip_diag = qla24xx_chip_diag, |
| 1920 | .config_rings = qla82xx_config_rings, |
| 1921 | .reset_adapter = qla24xx_reset_adapter, |
| 1922 | .nvram_config = qla81xx_nvram_config, |
| 1923 | .update_fw_options = qla24xx_update_fw_options, |
| 1924 | .load_risc = qla82xx_load_risc, |
Atul Deshmukh | 9d55ca6 | 2012-08-22 14:21:14 -0400 | [diff] [blame] | 1925 | .pci_info_str = qla24xx_pci_info_str, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1926 | .fw_version_str = qla24xx_fw_version_str, |
| 1927 | .intr_handler = qla82xx_intr_handler, |
| 1928 | .enable_intrs = qla82xx_enable_intrs, |
| 1929 | .disable_intrs = qla82xx_disable_intrs, |
| 1930 | .abort_command = qla24xx_abort_command, |
| 1931 | .target_reset = qla24xx_abort_target, |
| 1932 | .lun_reset = qla24xx_lun_reset, |
| 1933 | .fabric_login = qla24xx_login_fabric, |
| 1934 | .fabric_logout = qla24xx_fabric_logout, |
| 1935 | .calc_req_entries = NULL, |
| 1936 | .build_iocbs = NULL, |
| 1937 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 1938 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 1939 | .read_nvram = qla24xx_read_nvram_data, |
| 1940 | .write_nvram = qla24xx_write_nvram_data, |
| 1941 | .fw_dump = qla24xx_fw_dump, |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 1942 | .beacon_on = qla82xx_beacon_on, |
| 1943 | .beacon_off = qla82xx_beacon_off, |
| 1944 | .beacon_blink = NULL, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 1945 | .read_optrom = qla82xx_read_optrom_data, |
| 1946 | .write_optrom = qla82xx_write_optrom_data, |
| 1947 | .get_flash_version = qla24xx_get_flash_version, |
| 1948 | .start_scsi = qla82xx_start_scsi, |
| 1949 | .abort_isp = qla82xx_abort_isp, |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 1950 | .iospace_config = qla82xx_iospace_config, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 1951 | }; |
| 1952 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 1953 | static struct isp_operations qla83xx_isp_ops = { |
| 1954 | .pci_config = qla25xx_pci_config, |
| 1955 | .reset_chip = qla24xx_reset_chip, |
| 1956 | .chip_diag = qla24xx_chip_diag, |
| 1957 | .config_rings = qla24xx_config_rings, |
| 1958 | .reset_adapter = qla24xx_reset_adapter, |
| 1959 | .nvram_config = qla81xx_nvram_config, |
| 1960 | .update_fw_options = qla81xx_update_fw_options, |
| 1961 | .load_risc = qla81xx_load_risc, |
| 1962 | .pci_info_str = qla24xx_pci_info_str, |
| 1963 | .fw_version_str = qla24xx_fw_version_str, |
| 1964 | .intr_handler = qla24xx_intr_handler, |
| 1965 | .enable_intrs = qla24xx_enable_intrs, |
| 1966 | .disable_intrs = qla24xx_disable_intrs, |
| 1967 | .abort_command = qla24xx_abort_command, |
| 1968 | .target_reset = qla24xx_abort_target, |
| 1969 | .lun_reset = qla24xx_lun_reset, |
| 1970 | .fabric_login = qla24xx_login_fabric, |
| 1971 | .fabric_logout = qla24xx_fabric_logout, |
| 1972 | .calc_req_entries = NULL, |
| 1973 | .build_iocbs = NULL, |
| 1974 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 1975 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 1976 | .read_nvram = NULL, |
| 1977 | .write_nvram = NULL, |
| 1978 | .fw_dump = qla83xx_fw_dump, |
| 1979 | .beacon_on = qla24xx_beacon_on, |
| 1980 | .beacon_off = qla24xx_beacon_off, |
| 1981 | .beacon_blink = qla83xx_beacon_blink, |
| 1982 | .read_optrom = qla25xx_read_optrom_data, |
| 1983 | .write_optrom = qla24xx_write_optrom_data, |
| 1984 | .get_flash_version = qla24xx_get_flash_version, |
| 1985 | .start_scsi = qla24xx_dif_start_scsi, |
| 1986 | .abort_isp = qla2x00_abort_isp, |
| 1987 | .iospace_config = qla83xx_iospace_config, |
| 1988 | }; |
| 1989 | |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 1990 | static inline void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1991 | qla2x00_set_isp_flags(struct qla_hw_data *ha) |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 1992 | { |
| 1993 | ha->device_type = DT_EXTENDED_IDS; |
| 1994 | switch (ha->pdev->device) { |
| 1995 | case PCI_DEVICE_ID_QLOGIC_ISP2100: |
| 1996 | ha->device_type |= DT_ISP2100; |
| 1997 | ha->device_type &= ~DT_EXTENDED_IDS; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 1998 | ha->fw_srisc_address = RISC_START_ADDRESS_2100; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 1999 | break; |
| 2000 | case PCI_DEVICE_ID_QLOGIC_ISP2200: |
| 2001 | ha->device_type |= DT_ISP2200; |
| 2002 | ha->device_type &= ~DT_EXTENDED_IDS; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2003 | ha->fw_srisc_address = RISC_START_ADDRESS_2100; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2004 | break; |
| 2005 | case PCI_DEVICE_ID_QLOGIC_ISP2300: |
| 2006 | ha->device_type |= DT_ISP2300; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2007 | ha->device_type |= DT_ZIO_SUPPORTED; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2008 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2009 | break; |
| 2010 | case PCI_DEVICE_ID_QLOGIC_ISP2312: |
| 2011 | ha->device_type |= DT_ISP2312; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2012 | ha->device_type |= DT_ZIO_SUPPORTED; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2013 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2014 | break; |
| 2015 | case PCI_DEVICE_ID_QLOGIC_ISP2322: |
| 2016 | ha->device_type |= DT_ISP2322; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2017 | ha->device_type |= DT_ZIO_SUPPORTED; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2018 | if (ha->pdev->subsystem_vendor == 0x1028 && |
| 2019 | ha->pdev->subsystem_device == 0x0170) |
| 2020 | ha->device_type |= DT_OEM_001; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2021 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2022 | break; |
| 2023 | case PCI_DEVICE_ID_QLOGIC_ISP6312: |
| 2024 | ha->device_type |= DT_ISP6312; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2025 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2026 | break; |
| 2027 | case PCI_DEVICE_ID_QLOGIC_ISP6322: |
| 2028 | ha->device_type |= DT_ISP6322; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2029 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2030 | break; |
| 2031 | case PCI_DEVICE_ID_QLOGIC_ISP2422: |
| 2032 | ha->device_type |= DT_ISP2422; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2033 | ha->device_type |= DT_ZIO_SUPPORTED; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2034 | ha->device_type |= DT_FWI2; |
Andrew Vasquez | c76f2c0 | 2007-07-19 15:05:57 -0700 | [diff] [blame] | 2035 | ha->device_type |= DT_IIDMA; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2036 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2037 | break; |
| 2038 | case PCI_DEVICE_ID_QLOGIC_ISP2432: |
| 2039 | ha->device_type |= DT_ISP2432; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 2040 | ha->device_type |= DT_ZIO_SUPPORTED; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2041 | ha->device_type |= DT_FWI2; |
Andrew Vasquez | c76f2c0 | 2007-07-19 15:05:57 -0700 | [diff] [blame] | 2042 | ha->device_type |= DT_IIDMA; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2043 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2044 | break; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 2045 | case PCI_DEVICE_ID_QLOGIC_ISP8432: |
| 2046 | ha->device_type |= DT_ISP8432; |
| 2047 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2048 | ha->device_type |= DT_FWI2; |
| 2049 | ha->device_type |= DT_IIDMA; |
| 2050 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2051 | break; |
andrew.vasquez@qlogic.com | 044cc6c | 2006-03-09 14:27:13 -0800 | [diff] [blame] | 2052 | case PCI_DEVICE_ID_QLOGIC_ISP5422: |
| 2053 | ha->device_type |= DT_ISP5422; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2054 | ha->device_type |= DT_FWI2; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2055 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2056 | break; |
andrew.vasquez@qlogic.com | 044cc6c | 2006-03-09 14:27:13 -0800 | [diff] [blame] | 2057 | case PCI_DEVICE_ID_QLOGIC_ISP5432: |
| 2058 | ha->device_type |= DT_ISP5432; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 2059 | ha->device_type |= DT_FWI2; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 2060 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2061 | break; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2062 | case PCI_DEVICE_ID_QLOGIC_ISP2532: |
| 2063 | ha->device_type |= DT_ISP2532; |
| 2064 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2065 | ha->device_type |= DT_FWI2; |
| 2066 | ha->device_type |= DT_IIDMA; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2067 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2068 | break; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2069 | case PCI_DEVICE_ID_QLOGIC_ISP8001: |
| 2070 | ha->device_type |= DT_ISP8001; |
| 2071 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2072 | ha->device_type |= DT_FWI2; |
| 2073 | ha->device_type |= DT_IIDMA; |
| 2074 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2075 | break; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2076 | case PCI_DEVICE_ID_QLOGIC_ISP8021: |
| 2077 | ha->device_type |= DT_ISP8021; |
| 2078 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2079 | ha->device_type |= DT_FWI2; |
| 2080 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2081 | /* Initialize 82XX ISP flags */ |
| 2082 | qla82xx_init_flags(ha); |
| 2083 | break; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2084 | case PCI_DEVICE_ID_QLOGIC_ISP2031: |
| 2085 | ha->device_type |= DT_ISP2031; |
| 2086 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2087 | ha->device_type |= DT_FWI2; |
| 2088 | ha->device_type |= DT_IIDMA; |
| 2089 | ha->device_type |= DT_T10_PI; |
| 2090 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2091 | break; |
| 2092 | case PCI_DEVICE_ID_QLOGIC_ISP8031: |
| 2093 | ha->device_type |= DT_ISP8031; |
| 2094 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 2095 | ha->device_type |= DT_FWI2; |
| 2096 | ha->device_type |= DT_IIDMA; |
| 2097 | ha->device_type |= DT_T10_PI; |
| 2098 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 2099 | break; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2100 | } |
Anirban Chakraborty | e5b68a6 | 2009-04-06 22:33:50 -0700 | [diff] [blame] | 2101 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2102 | if (IS_QLA82XX(ha)) |
| 2103 | ha->port_no = !(ha->portnum & 1); |
| 2104 | else |
| 2105 | /* Get adapter physical port no from interrupt pin register. */ |
| 2106 | pci_read_config_byte(ha->pdev, PCI_INTERRUPT_PIN, &ha->port_no); |
| 2107 | |
Anirban Chakraborty | e5b68a6 | 2009-04-06 22:33:50 -0700 | [diff] [blame] | 2108 | if (ha->port_no & 1) |
| 2109 | ha->flags.port0 = 1; |
| 2110 | else |
| 2111 | ha->flags.port0 = 0; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2112 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x000b, |
Joe Perches | d8424f6 | 2011-11-18 09:03:06 -0800 | [diff] [blame] | 2113 | "device_type=0x%x port=%d fw_srisc_address=0x%x.\n", |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2114 | ha->device_type, ha->flags.port0, ha->fw_srisc_address); |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2115 | } |
| 2116 | |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2117 | static void |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2118 | qla2xxx_scan_start(struct Scsi_Host *shost) |
| 2119 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2120 | scsi_qla_host_t *vha = shost_priv(shost); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2121 | |
Andrew Vasquez | cbc8eb6 | 2009-06-03 09:55:17 -0700 | [diff] [blame] | 2122 | if (vha->hw->flags.running_gold_fw) |
| 2123 | return; |
| 2124 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2125 | set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); |
| 2126 | set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); |
| 2127 | set_bit(RSCN_UPDATE, &vha->dpc_flags); |
| 2128 | set_bit(NPIV_CONFIG_NEEDED, &vha->dpc_flags); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2129 | } |
| 2130 | |
| 2131 | static int |
| 2132 | qla2xxx_scan_finished(struct Scsi_Host *shost, unsigned long time) |
| 2133 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2134 | scsi_qla_host_t *vha = shost_priv(shost); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2135 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2136 | if (!vha->host) |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2137 | return 1; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2138 | if (time > vha->hw->loop_reset_delay * HZ) |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2139 | return 1; |
| 2140 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2141 | return atomic_read(&vha->loop_state) == LOOP_READY; |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2142 | } |
| 2143 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2144 | /* |
| 2145 | * PCI driver interface |
| 2146 | */ |
Andrew Vasquez | 7ee6139 | 2006-06-23 16:11:22 -0700 | [diff] [blame] | 2147 | static int __devinit |
| 2148 | 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] | 2149 | { |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2150 | int ret = -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2151 | struct Scsi_Host *host; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2152 | scsi_qla_host_t *base_vha = NULL; |
| 2153 | struct qla_hw_data *ha; |
Andrew Vasquez | 29856e2 | 2007-08-12 18:22:52 -0700 | [diff] [blame] | 2154 | char pci_info[30]; |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 2155 | char fw_str[30], wq_name[30]; |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 2156 | struct scsi_host_template *sht; |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2157 | int bars, mem_only = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2158 | uint16_t req_length = 0, rsp_length = 0; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2159 | struct req_que *req = NULL; |
| 2160 | struct rsp_que *rsp = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2161 | |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2162 | bars = pci_select_bars(pdev, IORESOURCE_MEM | IORESOURCE_IO); |
Giridhar Malavali | a5326f8 | 2009-03-24 09:07:56 -0700 | [diff] [blame] | 2163 | sht = &qla2xxx_driver_template; |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2164 | if (pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2422 || |
| 2165 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2432 || |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 2166 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8432 || |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2167 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP5422 || |
| 2168 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP5432 || |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2169 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2532 || |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2170 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8001 || |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2171 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8021 || |
| 2172 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2031 || |
| 2173 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8031) { |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2174 | bars = pci_select_bars(pdev, IORESOURCE_MEM); |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 2175 | mem_only = 1; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2176 | ql_dbg_pci(ql_dbg_init, pdev, 0x0007, |
| 2177 | "Mem only adapter.\n"); |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2178 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2179 | ql_dbg_pci(ql_dbg_init, pdev, 0x0008, |
| 2180 | "Bars=%d.\n", bars); |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2181 | |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 2182 | if (mem_only) { |
| 2183 | if (pci_enable_device_mem(pdev)) |
| 2184 | goto probe_out; |
| 2185 | } else { |
| 2186 | if (pci_enable_device(pdev)) |
| 2187 | goto probe_out; |
| 2188 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2189 | |
Jesse Barnes | 0927678 | 2008-10-18 17:33:19 -0700 | [diff] [blame] | 2190 | /* This may fail but that's ok */ |
| 2191 | pci_enable_pcie_error_reporting(pdev); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 2192 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2193 | ha = kzalloc(sizeof(struct qla_hw_data), GFP_KERNEL); |
| 2194 | if (!ha) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2195 | ql_log_pci(ql_log_fatal, pdev, 0x0009, |
| 2196 | "Unable to allocate memory for ha.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2197 | goto probe_out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2198 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2199 | ql_dbg_pci(ql_dbg_init, pdev, 0x000a, |
| 2200 | "Memory allocated for ha=%p.\n", ha); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2201 | ha->pdev = pdev; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2202 | ha->tgt.enable_class_2 = ql2xenableclass2; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2203 | |
| 2204 | /* Clear our data area */ |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 2205 | ha->bars = bars; |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 2206 | ha->mem_only = mem_only; |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 2207 | spin_lock_init(&ha->hardware_lock); |
Andrew Vasquez | 339aa70 | 2010-10-15 11:27:45 -0700 | [diff] [blame] | 2208 | spin_lock_init(&ha->vport_slock); |
Saurav Kashyap | a9b6f72 | 2012-08-22 14:21:01 -0400 | [diff] [blame] | 2209 | mutex_init(&ha->selflogin_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2210 | |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 2211 | /* Set ISP-type information. */ |
| 2212 | qla2x00_set_isp_flags(ha); |
Duane Grigsby | ca79cf6 | 2009-12-15 21:29:47 -0800 | [diff] [blame] | 2213 | |
| 2214 | /* Set EEH reset type to fundamental if required by hba */ |
Joe Carnuccio | 9567611 | 2012-08-22 14:21:20 -0400 | [diff] [blame] | 2215 | if (IS_QLA24XX(ha) || IS_QLA25XX(ha) || IS_QLA81XX(ha) || |
| 2216 | IS_QLA83XX(ha)) |
Duane Grigsby | ca79cf6 | 2009-12-15 21:29:47 -0800 | [diff] [blame] | 2217 | pdev->needs_freset = 1; |
Duane Grigsby | ca79cf6 | 2009-12-15 21:29:47 -0800 | [diff] [blame] | 2218 | |
Chad Dupuis | cba1e47 | 2011-11-18 09:03:21 -0800 | [diff] [blame] | 2219 | ha->prev_topology = 0; |
| 2220 | ha->init_cb_size = sizeof(init_cb_t); |
| 2221 | ha->link_data_rate = PORT_SPEED_UNKNOWN; |
| 2222 | ha->optrom_size = OPTROM_SIZE_2300; |
| 2223 | |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2224 | /* Assign ISP specific operations. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2225 | if (IS_QLA2100(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2226 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2100; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2227 | ha->mbx_count = MAILBOX_REGISTER_COUNT_2100; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2228 | req_length = REQUEST_ENTRY_CNT_2100; |
| 2229 | rsp_length = RESPONSE_ENTRY_CNT_2100; |
| 2230 | ha->max_loop_id = SNS_LAST_LOOP_ID_2100; |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2231 | ha->gid_list_info_size = 4; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2232 | ha->flash_conf_off = ~0; |
| 2233 | ha->flash_data_off = ~0; |
| 2234 | ha->nvram_conf_off = ~0; |
| 2235 | ha->nvram_data_off = ~0; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2236 | ha->isp_ops = &qla2100_isp_ops; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2237 | } else if (IS_QLA2200(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2238 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2100; |
Andrew Vasquez | 67ddda3 | 2012-02-09 11:14:08 -0800 | [diff] [blame] | 2239 | ha->mbx_count = MAILBOX_REGISTER_COUNT_2200; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2240 | req_length = REQUEST_ENTRY_CNT_2200; |
| 2241 | rsp_length = RESPONSE_ENTRY_CNT_2100; |
| 2242 | ha->max_loop_id = SNS_LAST_LOOP_ID_2100; |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2243 | ha->gid_list_info_size = 4; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2244 | ha->flash_conf_off = ~0; |
| 2245 | ha->flash_data_off = ~0; |
| 2246 | ha->nvram_conf_off = ~0; |
| 2247 | ha->nvram_data_off = ~0; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2248 | ha->isp_ops = &qla2100_isp_ops; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 2249 | } else if (IS_QLA23XX(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2250 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2100; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2251 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2252 | req_length = REQUEST_ENTRY_CNT_2200; |
| 2253 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
| 2254 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 2255 | ha->gid_list_info_size = 6; |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 2256 | if (IS_QLA2322(ha) || IS_QLA6322(ha)) |
| 2257 | ha->optrom_size = OPTROM_SIZE_2322; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2258 | ha->flash_conf_off = ~0; |
| 2259 | ha->flash_data_off = ~0; |
| 2260 | ha->nvram_conf_off = ~0; |
| 2261 | ha->nvram_data_off = ~0; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2262 | ha->isp_ops = &qla2300_isp_ops; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 2263 | } else if (IS_QLA24XX_TYPE(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2264 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 2265 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2266 | req_length = REQUEST_ENTRY_CNT_24XX; |
| 2267 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2268 | ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2269 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2270 | ha->init_cb_size = sizeof(struct mid_init_cb_24xx); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 2271 | ha->gid_list_info_size = 8; |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 2272 | ha->optrom_size = OPTROM_SIZE_24XX; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2273 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA24XX; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2274 | ha->isp_ops = &qla24xx_isp_ops; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2275 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF; |
| 2276 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA; |
| 2277 | ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF; |
| 2278 | ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2279 | } else if (IS_QLA25XX(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2280 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2281 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2282 | req_length = REQUEST_ENTRY_CNT_24XX; |
| 2283 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2284 | ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2285 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2286 | ha->init_cb_size = sizeof(struct mid_init_cb_24xx); |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2287 | ha->gid_list_info_size = 8; |
| 2288 | ha->optrom_size = OPTROM_SIZE_25XX; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2289 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 2290 | ha->isp_ops = &qla25xx_isp_ops; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2291 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF; |
| 2292 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA; |
| 2293 | ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF; |
| 2294 | ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA; |
| 2295 | } else if (IS_QLA81XX(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2296 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2297 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
| 2298 | req_length = REQUEST_ENTRY_CNT_24XX; |
| 2299 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
| 2300 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 2301 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 2302 | ha->gid_list_info_size = 8; |
| 2303 | ha->optrom_size = OPTROM_SIZE_81XX; |
Anirban Chakraborty | 40859ae | 2009-06-03 09:55:16 -0700 | [diff] [blame] | 2304 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 2305 | ha->isp_ops = &qla81xx_isp_ops; |
| 2306 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF_81XX; |
| 2307 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA_81XX; |
| 2308 | ha->nvram_conf_off = ~0; |
| 2309 | ha->nvram_data_off = ~0; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2310 | } else if (IS_QLA82XX(ha)) { |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2311 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2312 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
| 2313 | req_length = REQUEST_ENTRY_CNT_82XX; |
| 2314 | rsp_length = RESPONSE_ENTRY_CNT_82XX; |
| 2315 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 2316 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 2317 | ha->gid_list_info_size = 8; |
| 2318 | ha->optrom_size = OPTROM_SIZE_82XX; |
Andrew Vasquez | 087c621 | 2010-11-23 16:52:48 -0800 | [diff] [blame] | 2319 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2320 | ha->isp_ops = &qla82xx_isp_ops; |
| 2321 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF; |
| 2322 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA; |
| 2323 | ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF; |
| 2324 | ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2325 | } else if (IS_QLA83XX(ha)) { |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 2326 | ha->portnum = PCI_FUNC(ha->pdev->devfn); |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2327 | ha->max_fibre_devices = MAX_FIBRE_DEVICES_2400; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2328 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
| 2329 | req_length = REQUEST_ENTRY_CNT_24XX; |
| 2330 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
| 2331 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 2332 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 2333 | ha->gid_list_info_size = 8; |
| 2334 | ha->optrom_size = OPTROM_SIZE_83XX; |
| 2335 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
| 2336 | ha->isp_ops = &qla83xx_isp_ops; |
| 2337 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF_81XX; |
| 2338 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA_81XX; |
| 2339 | ha->nvram_conf_off = ~0; |
| 2340 | ha->nvram_data_off = ~0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2341 | } |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2342 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2343 | ql_dbg_pci(ql_dbg_init, pdev, 0x001e, |
| 2344 | "mbx_count=%d, req_length=%d, " |
| 2345 | "rsp_length=%d, max_loop_id=%d, init_cb_size=%d, " |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2346 | "gid_list_info_size=%d, optrom_size=%d, nvram_npiv_size=%d, " |
| 2347 | "max_fibre_devices=%d.\n", |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2348 | ha->mbx_count, req_length, rsp_length, ha->max_loop_id, |
| 2349 | ha->init_cb_size, ha->gid_list_info_size, ha->optrom_size, |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2350 | ha->nvram_npiv_size, ha->max_fibre_devices); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2351 | ql_dbg_pci(ql_dbg_init, pdev, 0x001f, |
| 2352 | "isp_ops=%p, flash_conf_off=%d, " |
| 2353 | "flash_data_off=%d, nvram_conf_off=%d, nvram_data_off=%d.\n", |
| 2354 | ha->isp_ops, ha->flash_conf_off, ha->flash_data_off, |
| 2355 | ha->nvram_conf_off, ha->nvram_data_off); |
Giridhar Malavali | 706f457 | 2011-11-18 09:03:16 -0800 | [diff] [blame] | 2356 | |
| 2357 | /* Configure PCI I/O space */ |
| 2358 | ret = ha->isp_ops->iospace_config(ha); |
| 2359 | if (ret) |
| 2360 | goto probe_hw_failed; |
| 2361 | |
| 2362 | ql_log_pci(ql_log_info, pdev, 0x001d, |
| 2363 | "Found an ISP%04X irq %d iobase 0x%p.\n", |
| 2364 | pdev->device, pdev->irq, ha->iobase); |
matthias@kaehlcke.net | 6c2f527 | 2008-05-12 22:21:11 -0700 | [diff] [blame] | 2365 | mutex_init(&ha->vport_lock); |
Marcus Barrow | 0b05a1f | 2008-01-17 09:02:13 -0800 | [diff] [blame] | 2366 | init_completion(&ha->mbx_cmd_comp); |
| 2367 | complete(&ha->mbx_cmd_comp); |
| 2368 | init_completion(&ha->mbx_intr_comp); |
Sarang Radke | 23f2ebd | 2010-05-28 15:08:21 -0700 | [diff] [blame] | 2369 | init_completion(&ha->dcbx_comp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2370 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2371 | set_bit(0, (unsigned long *) ha->vp_idx_map); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2372 | |
Andrew Vasquez | 53303c4 | 2009-01-22 09:45:37 -0800 | [diff] [blame] | 2373 | qla2x00_config_dma_addressing(ha); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2374 | ql_dbg_pci(ql_dbg_init, pdev, 0x0020, |
| 2375 | "64 Bit addressing is %s.\n", |
| 2376 | ha->flags.enable_64bit_addressing ? "enable" : |
| 2377 | "disable"); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2378 | ret = qla2x00_mem_alloc(ha, req_length, rsp_length, &req, &rsp); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2379 | if (!ret) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2380 | ql_log_pci(ql_log_fatal, pdev, 0x0031, |
| 2381 | "Failed to allocate memory for adapter, aborting.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2382 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2383 | goto probe_hw_failed; |
| 2384 | } |
| 2385 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2386 | req->max_q_depth = MAX_Q_DEPTH; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2387 | if (ql2xmaxqdepth != 0 && ql2xmaxqdepth <= 0xffffU) |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2388 | req->max_q_depth = ql2xmaxqdepth; |
| 2389 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2390 | |
| 2391 | base_vha = qla2x00_create_host(sht, ha); |
| 2392 | if (!base_vha) { |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2393 | ret = -ENOMEM; |
Anirban Chakraborty | 6e9f21f | 2009-01-22 09:45:28 -0800 | [diff] [blame] | 2394 | qla2x00_mem_free(ha); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2395 | qla2x00_free_req_que(ha, req); |
| 2396 | qla2x00_free_rsp_que(ha, rsp); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2397 | goto probe_hw_failed; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2398 | } |
| 2399 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2400 | pci_set_drvdata(pdev, base_vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2401 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2402 | host = base_vha->host; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2403 | base_vha->req = req; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2404 | host->can_queue = req->length + 128; |
| 2405 | if (IS_QLA2XXX_MIDTYPE(ha)) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2406 | base_vha->mgmt_svr_loop_id = 10 + base_vha->vp_idx; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2407 | else |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2408 | base_vha->mgmt_svr_loop_id = MANAGEMENT_SERVER + |
| 2409 | base_vha->vp_idx; |
Giridhar Malavali | 58548cb | 2010-09-03 15:20:56 -0700 | [diff] [blame] | 2410 | |
| 2411 | /* Set the SG table size based on ISP type */ |
| 2412 | if (!IS_FWI2_CAPABLE(ha)) { |
| 2413 | if (IS_QLA2100(ha)) |
| 2414 | host->sg_tablesize = 32; |
| 2415 | } else { |
| 2416 | if (!IS_QLA82XX(ha)) |
| 2417 | host->sg_tablesize = QLA_SG_ALL; |
| 2418 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2419 | ql_dbg(ql_dbg_init, base_vha, 0x0032, |
| 2420 | "can_queue=%d, req=%p, " |
| 2421 | "mgmt_svr_loop_id=%d, sg_tablesize=%d.\n", |
| 2422 | host->can_queue, base_vha->req, |
| 2423 | base_vha->mgmt_svr_loop_id, host->sg_tablesize); |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 2424 | host->max_id = ha->max_fibre_devices; |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2425 | host->cmd_per_lun = 3; |
Seokmann Ju | 711c1d9 | 2008-07-10 16:55:51 -0700 | [diff] [blame] | 2426 | host->unique_id = host->host_no; |
Arun Easi | e02587d | 2011-08-16 11:29:23 -0700 | [diff] [blame] | 2427 | if (IS_T10_PI_CAPABLE(ha) && ql2xenabledif) |
Arun Easi | 0c47087 | 2010-07-23 15:28:38 +0500 | [diff] [blame] | 2428 | host->max_cmd_len = 32; |
| 2429 | else |
| 2430 | host->max_cmd_len = MAX_CMDSZ; |
Andrew Vasquez | 75bc419 | 2006-05-17 15:09:22 -0700 | [diff] [blame] | 2431 | host->max_channel = MAX_BUSES - 1; |
Andrew Vasquez | 8251592 | 2011-05-10 11:30:13 -0700 | [diff] [blame] | 2432 | host->max_lun = ql2xmaxlun; |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2433 | host->transportt = qla2xxx_transport_template; |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 2434 | sht->vendor_id = (SCSI_NL_VID_TYPE_PCI | PCI_VENDOR_ID_QLOGIC); |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2435 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2436 | ql_dbg(ql_dbg_init, base_vha, 0x0033, |
| 2437 | "max_id=%d this_id=%d " |
| 2438 | "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] | 2439 | "max_lun=%d transportt=%p, vendor_id=%llu.\n", host->max_id, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2440 | host->this_id, host->cmd_per_lun, host->unique_id, |
| 2441 | host->max_cmd_len, host->max_channel, host->max_lun, |
| 2442 | host->transportt, sht->vendor_id); |
| 2443 | |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 2444 | que_init: |
| 2445 | /* Alloc arrays of request and response ring ptrs */ |
| 2446 | if (!qla2x00_alloc_queues(ha, req, rsp)) { |
| 2447 | ql_log(ql_log_fatal, base_vha, 0x003d, |
| 2448 | "Failed to allocate memory for queue pointers..." |
| 2449 | "aborting.\n"); |
| 2450 | goto probe_init_failed; |
| 2451 | } |
| 2452 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2453 | qlt_probe_one_stage1(base_vha, ha); |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 2454 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2455 | /* Set up the irqs */ |
| 2456 | ret = qla2x00_request_irqs(ha, rsp); |
| 2457 | if (ret) |
Anirban Chakraborty | 6e9f21f | 2009-01-22 09:45:28 -0800 | [diff] [blame] | 2458 | goto probe_init_failed; |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 2459 | |
| 2460 | pci_save_state(pdev); |
| 2461 | |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 2462 | /* Assign back pointers */ |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2463 | rsp->req = req; |
| 2464 | req->rsp = rsp; |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 2465 | |
Andrew Vasquez | 0802999 | 2009-03-24 09:07:55 -0700 | [diff] [blame] | 2466 | /* FWI2-capable only. */ |
| 2467 | req->req_q_in = &ha->iobase->isp24.req_q_in; |
| 2468 | req->req_q_out = &ha->iobase->isp24.req_q_out; |
| 2469 | rsp->rsp_q_in = &ha->iobase->isp24.rsp_q_in; |
| 2470 | rsp->rsp_q_out = &ha->iobase->isp24.rsp_q_out; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2471 | if (ha->mqenable || IS_QLA83XX(ha)) { |
Andrew Vasquez | 0802999 | 2009-03-24 09:07:55 -0700 | [diff] [blame] | 2472 | req->req_q_in = &ha->mqiobase->isp25mq.req_q_in; |
| 2473 | req->req_q_out = &ha->mqiobase->isp25mq.req_q_out; |
| 2474 | rsp->rsp_q_in = &ha->mqiobase->isp25mq.rsp_q_in; |
| 2475 | rsp->rsp_q_out = &ha->mqiobase->isp25mq.rsp_q_out; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 2476 | } |
| 2477 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2478 | if (IS_QLA82XX(ha)) { |
| 2479 | req->req_q_out = &ha->iobase->isp82.req_q_out[0]; |
| 2480 | rsp->rsp_q_in = &ha->iobase->isp82.rsp_q_in[0]; |
| 2481 | rsp->rsp_q_out = &ha->iobase->isp82.rsp_q_out[0]; |
| 2482 | } |
| 2483 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2484 | ql_dbg(ql_dbg_multiq, base_vha, 0xc009, |
| 2485 | "rsp_q_map=%p req_q_map=%p rsp->req=%p req->rsp=%p.\n", |
| 2486 | ha->rsp_q_map, ha->req_q_map, rsp->req, req->rsp); |
| 2487 | ql_dbg(ql_dbg_multiq, base_vha, 0xc00a, |
| 2488 | "req->req_q_in=%p req->req_q_out=%p " |
| 2489 | "rsp->rsp_q_in=%p rsp->rsp_q_out=%p.\n", |
| 2490 | req->req_q_in, req->req_q_out, |
| 2491 | rsp->rsp_q_in, rsp->rsp_q_out); |
| 2492 | ql_dbg(ql_dbg_init, base_vha, 0x003e, |
| 2493 | "rsp_q_map=%p req_q_map=%p rsp->req=%p req->rsp=%p.\n", |
| 2494 | ha->rsp_q_map, ha->req_q_map, rsp->req, req->rsp); |
| 2495 | ql_dbg(ql_dbg_init, base_vha, 0x003f, |
| 2496 | "req->req_q_in=%p req->req_q_out=%p rsp->rsp_q_in=%p rsp->rsp_q_out=%p.\n", |
| 2497 | 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] | 2498 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2499 | if (qla2x00_initialize_adapter(base_vha)) { |
| 2500 | ql_log(ql_log_fatal, base_vha, 0x00d6, |
| 2501 | "Failed to initialize adapter - Adapter flags %x.\n", |
| 2502 | base_vha->device_flags); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2503 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2504 | if (IS_QLA82XX(ha)) { |
| 2505 | qla82xx_idc_lock(ha); |
| 2506 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 2507 | QLA8XXX_DEV_FAILED); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2508 | qla82xx_idc_unlock(ha); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2509 | ql_log(ql_log_fatal, base_vha, 0x00d7, |
| 2510 | "HW State: FAILED.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2511 | } |
| 2512 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2513 | ret = -ENODEV; |
| 2514 | goto probe_failed; |
| 2515 | } |
| 2516 | |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 2517 | if (ha->mqenable) { |
| 2518 | if (qla25xx_setup_mode(base_vha)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2519 | ql_log(ql_log_warn, base_vha, 0x00ec, |
| 2520 | "Failed to create queues, falling back to single queue mode.\n"); |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 2521 | goto que_init; |
| 2522 | } |
| 2523 | } |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 2524 | |
Andrew Vasquez | cbc8eb6 | 2009-06-03 09:55:17 -0700 | [diff] [blame] | 2525 | if (ha->flags.running_gold_fw) |
| 2526 | goto skip_dpc; |
| 2527 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2528 | /* |
| 2529 | * Startup the kernel thread for this host adapter |
| 2530 | */ |
| 2531 | ha->dpc_thread = kthread_create(qla2x00_do_dpc, ha, |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2532 | "%s_dpc", base_vha->host_str); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2533 | if (IS_ERR(ha->dpc_thread)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2534 | ql_log(ql_log_fatal, base_vha, 0x00ed, |
| 2535 | "Failed to start DPC thread.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2536 | ret = PTR_ERR(ha->dpc_thread); |
| 2537 | goto probe_failed; |
| 2538 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2539 | ql_dbg(ql_dbg_init, base_vha, 0x00ee, |
| 2540 | "DPC thread started successfully.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2541 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2542 | /* |
| 2543 | * If we're not coming up in initiator mode, we might sit for |
| 2544 | * a while without waking up the dpc thread, which leads to a |
| 2545 | * stuck process warning. So just kick the dpc once here and |
| 2546 | * let the kthread start (and go back to sleep in qla2x00_do_dpc). |
| 2547 | */ |
| 2548 | qla2xxx_wake_dpc(base_vha); |
| 2549 | |
Saurav Kashyap | 8117877 | 2012-08-22 14:21:04 -0400 | [diff] [blame] | 2550 | if (IS_QLA8031(ha) || IS_MCTP_CAPABLE(ha)) { |
| 2551 | sprintf(wq_name, "qla2xxx_%lu_dpc_lp_wq", base_vha->host_no); |
| 2552 | ha->dpc_lp_wq = create_singlethread_workqueue(wq_name); |
| 2553 | INIT_WORK(&ha->idc_aen, qla83xx_service_idc_aen); |
| 2554 | |
| 2555 | sprintf(wq_name, "qla2xxx_%lu_dpc_hp_wq", base_vha->host_no); |
| 2556 | ha->dpc_hp_wq = create_singlethread_workqueue(wq_name); |
| 2557 | INIT_WORK(&ha->nic_core_reset, qla83xx_nic_core_reset_work); |
| 2558 | INIT_WORK(&ha->idc_state_handler, |
| 2559 | qla83xx_idc_state_handler_work); |
| 2560 | INIT_WORK(&ha->nic_core_unrecoverable, |
| 2561 | qla83xx_nic_core_unrecoverable_work); |
| 2562 | } |
| 2563 | |
Andrew Vasquez | cbc8eb6 | 2009-06-03 09:55:17 -0700 | [diff] [blame] | 2564 | skip_dpc: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2565 | list_add_tail(&base_vha->list, &ha->vp_list); |
| 2566 | base_vha->host->irq = ha->pdev->irq; |
| 2567 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2568 | /* Initialized the timer */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2569 | qla2x00_start_timer(base_vha, qla2x00_timer, WATCH_INTERVAL); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2570 | ql_dbg(ql_dbg_init, base_vha, 0x00ef, |
| 2571 | "Started qla2x00_timer with " |
| 2572 | "interval=%d.\n", WATCH_INTERVAL); |
| 2573 | ql_dbg(ql_dbg_init, base_vha, 0x00f0, |
| 2574 | "Detected hba at address=%p.\n", |
| 2575 | ha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2576 | |
Arun Easi | e02587d | 2011-08-16 11:29:23 -0700 | [diff] [blame] | 2577 | if (IS_T10_PI_CAPABLE(ha) && ql2xenabledif) { |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 2578 | if (ha->fw_attributes & BIT_4) { |
Arun Easi | 9e522cd | 2012-08-22 14:21:31 -0400 | [diff] [blame] | 2579 | int prot = 0, guard; |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 2580 | base_vha->flags.difdix_supported = 1; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2581 | ql_dbg(ql_dbg_init, base_vha, 0x00f1, |
| 2582 | "Registering for DIF/DIX type 1 and 3 protection.\n"); |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 2583 | if (ql2xenabledif == 1) |
| 2584 | prot = SHOST_DIX_TYPE0_PROTECTION; |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 2585 | scsi_host_set_prot(host, |
Arun Easi | 8cb2049 | 2011-08-16 11:29:22 -0700 | [diff] [blame] | 2586 | prot | SHOST_DIF_TYPE1_PROTECTION |
Arun Easi | 0c47087 | 2010-07-23 15:28:38 +0500 | [diff] [blame] | 2587 | | SHOST_DIF_TYPE2_PROTECTION |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 2588 | | SHOST_DIF_TYPE3_PROTECTION |
| 2589 | | SHOST_DIX_TYPE1_PROTECTION |
Arun Easi | 0c47087 | 2010-07-23 15:28:38 +0500 | [diff] [blame] | 2590 | | SHOST_DIX_TYPE2_PROTECTION |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 2591 | | SHOST_DIX_TYPE3_PROTECTION); |
Arun Easi | 9e522cd | 2012-08-22 14:21:31 -0400 | [diff] [blame] | 2592 | |
| 2593 | guard = SHOST_DIX_GUARD_CRC; |
| 2594 | |
| 2595 | if (IS_PI_IPGUARD_CAPABLE(ha) && |
| 2596 | (ql2xenabledif > 1 || IS_PI_DIFB_DIX0_CAPABLE(ha))) |
| 2597 | guard |= SHOST_DIX_GUARD_IP; |
| 2598 | |
| 2599 | scsi_host_set_guard(host, guard); |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 2600 | } else |
| 2601 | base_vha->flags.difdix_supported = 0; |
| 2602 | } |
| 2603 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2604 | ha->isp_ops->enable_intrs(ha); |
| 2605 | |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2606 | ret = scsi_add_host(host, &pdev->dev); |
| 2607 | if (ret) |
| 2608 | goto probe_failed; |
| 2609 | |
Michael Reed | 1486400 | 2009-12-02 09:11:16 -0600 | [diff] [blame] | 2610 | base_vha->flags.init_done = 1; |
| 2611 | base_vha->flags.online = 1; |
| 2612 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2613 | ql_dbg(ql_dbg_init, base_vha, 0x00f2, |
| 2614 | "Init done and hba is online.\n"); |
| 2615 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2616 | if (qla_ini_mode_enabled(base_vha)) |
| 2617 | scsi_scan_host(host); |
| 2618 | else |
| 2619 | ql_dbg(ql_dbg_init, base_vha, 0x0122, |
| 2620 | "skipping scsi_scan_host() for non-initiator port\n"); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2621 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2622 | qla2x00_alloc_sysfs_attr(base_vha); |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2623 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2624 | qla2x00_init_host_attr(base_vha); |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2625 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2626 | qla2x00_dfs_setup(base_vha); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 2627 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2628 | ql_log(ql_log_info, base_vha, 0x00fb, |
| 2629 | "QLogic %s - %s.\n", |
| 2630 | ha->model_number, ha->model_desc ? ha->model_desc : ""); |
| 2631 | ql_log(ql_log_info, base_vha, 0x00fc, |
| 2632 | "ISP%04X: %s @ %s hdma%c host#=%ld fw=%s.\n", |
| 2633 | pdev->device, ha->isp_ops->pci_info_str(base_vha, pci_info), |
| 2634 | pci_name(pdev), ha->flags.enable_64bit_addressing ? '+' : '-', |
| 2635 | base_vha->host_no, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2636 | ha->isp_ops->fw_version_str(base_vha, fw_str)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2637 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2638 | qlt_add_target(ha, base_vha); |
| 2639 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2640 | return 0; |
| 2641 | |
Anirban Chakraborty | 6e9f21f | 2009-01-22 09:45:28 -0800 | [diff] [blame] | 2642 | probe_init_failed: |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2643 | qla2x00_free_req_que(ha, req); |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 2644 | ha->req_q_map[0] = NULL; |
| 2645 | clear_bit(0, ha->req_qid_map); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2646 | qla2x00_free_rsp_que(ha, rsp); |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 2647 | ha->rsp_q_map[0] = NULL; |
| 2648 | clear_bit(0, ha->rsp_qid_map); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2649 | ha->max_req_queues = ha->max_rsp_queues = 0; |
Anirban Chakraborty | 6e9f21f | 2009-01-22 09:45:28 -0800 | [diff] [blame] | 2650 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2651 | probe_failed: |
Andrew Vasquez | b997876 | 2009-03-24 09:08:05 -0700 | [diff] [blame] | 2652 | if (base_vha->timer_active) |
| 2653 | qla2x00_stop_timer(base_vha); |
| 2654 | base_vha->flags.online = 0; |
| 2655 | if (ha->dpc_thread) { |
| 2656 | struct task_struct *t = ha->dpc_thread; |
| 2657 | |
| 2658 | ha->dpc_thread = NULL; |
| 2659 | kthread_stop(t); |
| 2660 | } |
| 2661 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2662 | qla2x00_free_device(base_vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2663 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2664 | scsi_host_put(base_vha->host); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2665 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2666 | probe_hw_failed: |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2667 | if (IS_QLA82XX(ha)) { |
| 2668 | qla82xx_idc_lock(ha); |
| 2669 | qla82xx_clear_drv_active(ha); |
| 2670 | qla82xx_idc_unlock(ha); |
| 2671 | iounmap((device_reg_t __iomem *)ha->nx_pcibase); |
| 2672 | if (!ql2xdbwr) |
| 2673 | iounmap((device_reg_t __iomem *)ha->nxdb_wr_ptr); |
| 2674 | } else { |
| 2675 | if (ha->iobase) |
| 2676 | iounmap(ha->iobase); |
| 2677 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2678 | pci_release_selected_regions(ha->pdev, ha->bars); |
| 2679 | kfree(ha); |
| 2680 | ha = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2681 | |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2682 | probe_out: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2683 | pci_disable_device(pdev); |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2684 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2685 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2686 | |
Adrian Bunk | 4c993f7 | 2008-01-14 00:55:16 -0800 | [diff] [blame] | 2687 | static void |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2688 | qla2x00_stop_dpc_thread(scsi_qla_host_t *vha) |
| 2689 | { |
| 2690 | struct qla_hw_data *ha = vha->hw; |
| 2691 | struct task_struct *t = ha->dpc_thread; |
| 2692 | |
| 2693 | if (ha->dpc_thread == NULL) |
| 2694 | return; |
| 2695 | /* |
| 2696 | * qla2xxx_wake_dpc checks for ->dpc_thread |
| 2697 | * so we need to zero it out. |
| 2698 | */ |
| 2699 | ha->dpc_thread = NULL; |
| 2700 | kthread_stop(t); |
| 2701 | } |
| 2702 | |
| 2703 | static void |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 2704 | qla2x00_shutdown(struct pci_dev *pdev) |
| 2705 | { |
| 2706 | scsi_qla_host_t *vha; |
| 2707 | struct qla_hw_data *ha; |
| 2708 | |
| 2709 | vha = pci_get_drvdata(pdev); |
| 2710 | ha = vha->hw; |
| 2711 | |
| 2712 | /* Turn-off FCE trace */ |
| 2713 | if (ha->flags.fce_enabled) { |
| 2714 | qla2x00_disable_fce_trace(vha, NULL, NULL); |
| 2715 | ha->flags.fce_enabled = 0; |
| 2716 | } |
| 2717 | |
| 2718 | /* Turn-off EFT trace */ |
| 2719 | if (ha->eft) |
| 2720 | qla2x00_disable_eft_trace(vha); |
| 2721 | |
| 2722 | /* Stop currently executing firmware. */ |
| 2723 | qla2x00_try_to_stop_firmware(vha); |
| 2724 | |
| 2725 | /* Turn adapter off line */ |
| 2726 | vha->flags.online = 0; |
| 2727 | |
| 2728 | /* turn-off interrupts on the card */ |
| 2729 | if (ha->interrupts_on) { |
| 2730 | vha->flags.init_done = 0; |
| 2731 | ha->isp_ops->disable_intrs(ha); |
| 2732 | } |
| 2733 | |
| 2734 | qla2x00_free_irqs(vha); |
| 2735 | |
| 2736 | qla2x00_free_fw_dump(ha); |
| 2737 | } |
| 2738 | |
| 2739 | static void |
Andrew Vasquez | 7ee6139 | 2006-06-23 16:11:22 -0700 | [diff] [blame] | 2740 | qla2x00_remove_one(struct pci_dev *pdev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2741 | { |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 2742 | scsi_qla_host_t *base_vha, *vha; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2743 | struct qla_hw_data *ha; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 2744 | unsigned long flags; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2745 | |
Chad Dupuis | 9a347ff | 2012-05-15 14:34:14 -0400 | [diff] [blame] | 2746 | /* |
| 2747 | * If the PCI device is disabled that means that probe failed and any |
| 2748 | * resources should be have cleaned up on probe exit. |
| 2749 | */ |
| 2750 | if (!atomic_read(&pdev->enable_cnt)) |
| 2751 | return; |
| 2752 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2753 | base_vha = pci_get_drvdata(pdev); |
| 2754 | ha = base_vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2755 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2756 | ha->flags.host_shutting_down = 1; |
| 2757 | |
Giridhar Malavali | 220d36b | 2012-11-21 02:39:55 -0500 | [diff] [blame^] | 2758 | set_bit(UNLOADING, &base_vha->dpc_flags); |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 2759 | mutex_lock(&ha->vport_lock); |
| 2760 | while (ha->cur_vport_count) { |
| 2761 | struct Scsi_Host *scsi_host; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 2762 | |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 2763 | spin_lock_irqsave(&ha->vport_slock, flags); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 2764 | |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 2765 | BUG_ON(base_vha->list.next == &ha->vp_list); |
| 2766 | /* This assumes first entry in ha->vp_list is always base vha */ |
| 2767 | vha = list_first_entry(&base_vha->list, scsi_qla_host_t, list); |
| 2768 | scsi_host = scsi_host_get(vha->host); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 2769 | |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 2770 | spin_unlock_irqrestore(&ha->vport_slock, flags); |
| 2771 | mutex_unlock(&ha->vport_lock); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 2772 | |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 2773 | fc_vport_terminate(vha->fc_vport); |
| 2774 | scsi_host_put(vha->host); |
| 2775 | |
| 2776 | mutex_lock(&ha->vport_lock); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2777 | } |
Arun Easi | 43ebf16 | 2011-05-10 11:18:16 -0700 | [diff] [blame] | 2778 | mutex_unlock(&ha->vport_lock); |
Andrew Vasquez | c795c1e | 2008-08-13 21:37:01 -0700 | [diff] [blame] | 2779 | |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 2780 | if (IS_QLA8031(ha)) { |
| 2781 | ql_dbg(ql_dbg_p3p, base_vha, 0xb07e, |
| 2782 | "Clearing fcoe driver presence.\n"); |
| 2783 | if (qla83xx_clear_drv_presence(base_vha) != QLA_SUCCESS) |
| 2784 | ql_dbg(ql_dbg_p3p, base_vha, 0xb079, |
| 2785 | "Error while clearing DRV-Presence.\n"); |
| 2786 | } |
| 2787 | |
Andrew Vasquez | b997876 | 2009-03-24 09:08:05 -0700 | [diff] [blame] | 2788 | qla2x00_abort_all_cmds(base_vha, DID_NO_CONNECT << 16); |
| 2789 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2790 | qla2x00_dfs_remove(base_vha); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 2791 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2792 | qla84xx_put_chip(base_vha); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 2793 | |
Andrew Vasquez | b997876 | 2009-03-24 09:08:05 -0700 | [diff] [blame] | 2794 | /* Disable timer */ |
| 2795 | if (base_vha->timer_active) |
| 2796 | qla2x00_stop_timer(base_vha); |
| 2797 | |
| 2798 | base_vha->flags.online = 0; |
| 2799 | |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 2800 | /* Flush the work queue and remove it */ |
| 2801 | if (ha->wq) { |
| 2802 | flush_workqueue(ha->wq); |
| 2803 | destroy_workqueue(ha->wq); |
| 2804 | ha->wq = NULL; |
| 2805 | } |
| 2806 | |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 2807 | /* Cancel all work and destroy DPC workqueues */ |
| 2808 | if (ha->dpc_lp_wq) { |
| 2809 | cancel_work_sync(&ha->idc_aen); |
| 2810 | destroy_workqueue(ha->dpc_lp_wq); |
| 2811 | ha->dpc_lp_wq = NULL; |
| 2812 | } |
| 2813 | |
| 2814 | if (ha->dpc_hp_wq) { |
| 2815 | cancel_work_sync(&ha->nic_core_reset); |
| 2816 | cancel_work_sync(&ha->idc_state_handler); |
| 2817 | cancel_work_sync(&ha->nic_core_unrecoverable); |
| 2818 | destroy_workqueue(ha->dpc_hp_wq); |
| 2819 | ha->dpc_hp_wq = NULL; |
| 2820 | } |
| 2821 | |
Andrew Vasquez | b997876 | 2009-03-24 09:08:05 -0700 | [diff] [blame] | 2822 | /* Kill the kernel thread for this host */ |
| 2823 | if (ha->dpc_thread) { |
| 2824 | struct task_struct *t = ha->dpc_thread; |
| 2825 | |
| 2826 | /* |
| 2827 | * qla2xxx_wake_dpc checks for ->dpc_thread |
| 2828 | * so we need to zero it out. |
| 2829 | */ |
| 2830 | ha->dpc_thread = NULL; |
| 2831 | kthread_stop(t); |
| 2832 | } |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2833 | qlt_remove_target(ha, base_vha); |
Andrew Vasquez | b997876 | 2009-03-24 09:08:05 -0700 | [diff] [blame] | 2834 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2835 | qla2x00_free_sysfs_attr(base_vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2836 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2837 | fc_remove_host(base_vha->host); |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 2838 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2839 | scsi_remove_host(base_vha->host); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2840 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2841 | qla2x00_free_device(base_vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2842 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2843 | scsi_host_put(base_vha->host); |
| 2844 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2845 | if (IS_QLA82XX(ha)) { |
Giridhar Malavali | b963752 | 2010-05-28 15:08:15 -0700 | [diff] [blame] | 2846 | qla82xx_idc_lock(ha); |
| 2847 | qla82xx_clear_drv_active(ha); |
| 2848 | qla82xx_idc_unlock(ha); |
| 2849 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2850 | iounmap((device_reg_t __iomem *)ha->nx_pcibase); |
| 2851 | if (!ql2xdbwr) |
| 2852 | iounmap((device_reg_t __iomem *)ha->nxdb_wr_ptr); |
| 2853 | } else { |
| 2854 | if (ha->iobase) |
| 2855 | iounmap(ha->iobase); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2856 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2857 | if (ha->mqiobase) |
| 2858 | iounmap(ha->mqiobase); |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 2859 | |
| 2860 | if (IS_QLA83XX(ha) && ha->msixbase) |
| 2861 | iounmap(ha->msixbase); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2862 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2863 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2864 | pci_release_selected_regions(ha->pdev, ha->bars); |
| 2865 | kfree(ha); |
| 2866 | ha = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2867 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 2868 | pci_disable_pcie_error_reporting(pdev); |
| 2869 | |
Bernhard Walle | 665db93 | 2007-03-28 00:49:49 +0200 | [diff] [blame] | 2870 | pci_disable_device(pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2871 | pci_set_drvdata(pdev, NULL); |
| 2872 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2873 | |
| 2874 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2875 | qla2x00_free_device(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2876 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2877 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2878 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 2879 | qla2x00_abort_all_cmds(vha, DID_NO_CONNECT << 16); |
| 2880 | |
| 2881 | /* Disable timer */ |
| 2882 | if (vha->timer_active) |
| 2883 | qla2x00_stop_timer(vha); |
| 2884 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2885 | qla2x00_stop_dpc_thread(vha); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 2886 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2887 | qla25xx_delete_queues(vha); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 2888 | if (ha->flags.fce_enabled) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2889 | qla2x00_disable_fce_trace(vha, NULL, NULL); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 2890 | |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 2891 | if (ha->eft) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2892 | qla2x00_disable_eft_trace(vha); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 2893 | |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 2894 | /* Stop currently executing firmware. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2895 | qla2x00_try_to_stop_firmware(vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2896 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 2897 | vha->flags.online = 0; |
| 2898 | |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 2899 | /* turn-off interrupts on the card */ |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2900 | if (ha->interrupts_on) { |
| 2901 | vha->flags.init_done = 0; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2902 | ha->isp_ops->disable_intrs(ha); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 2903 | } |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 2904 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2905 | qla2x00_free_irqs(vha); |
| 2906 | |
Chad Dupuis | 8867048 | 2010-07-23 15:28:30 +0500 | [diff] [blame] | 2907 | qla2x00_free_fcports(vha); |
| 2908 | |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 2909 | qla2x00_mem_free(ha); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2910 | |
Giridhar Malavali | 08de284 | 2011-08-16 11:31:44 -0700 | [diff] [blame] | 2911 | qla82xx_md_free(vha); |
| 2912 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2913 | qla2x00_free_queues(ha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2914 | } |
| 2915 | |
Chad Dupuis | 8867048 | 2010-07-23 15:28:30 +0500 | [diff] [blame] | 2916 | void qla2x00_free_fcports(struct scsi_qla_host *vha) |
| 2917 | { |
| 2918 | fc_port_t *fcport, *tfcport; |
| 2919 | |
| 2920 | list_for_each_entry_safe(fcport, tfcport, &vha->vp_fcports, list) { |
| 2921 | list_del(&fcport->list); |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 2922 | qla2x00_clear_loop_id(fcport); |
Chad Dupuis | 8867048 | 2010-07-23 15:28:30 +0500 | [diff] [blame] | 2923 | kfree(fcport); |
| 2924 | fcport = NULL; |
| 2925 | } |
| 2926 | } |
| 2927 | |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 2928 | static inline void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2929 | 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] | 2930 | int defer) |
| 2931 | { |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 2932 | struct fc_rport *rport; |
Andrew Vasquez | 67becc0 | 2009-08-25 11:36:20 -0700 | [diff] [blame] | 2933 | scsi_qla_host_t *base_vha; |
Madhuranath Iyengar | 044d78e | 2011-01-28 15:17:56 -0800 | [diff] [blame] | 2934 | unsigned long flags; |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 2935 | |
| 2936 | if (!fcport->rport) |
| 2937 | return; |
| 2938 | |
| 2939 | rport = fcport->rport; |
| 2940 | if (defer) { |
Andrew Vasquez | 67becc0 | 2009-08-25 11:36:20 -0700 | [diff] [blame] | 2941 | base_vha = pci_get_drvdata(vha->hw->pdev); |
Madhuranath Iyengar | 044d78e | 2011-01-28 15:17:56 -0800 | [diff] [blame] | 2942 | spin_lock_irqsave(vha->host->host_lock, flags); |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 2943 | fcport->drport = rport; |
Madhuranath Iyengar | 044d78e | 2011-01-28 15:17:56 -0800 | [diff] [blame] | 2944 | spin_unlock_irqrestore(vha->host->host_lock, flags); |
Andrew Vasquez | 67becc0 | 2009-08-25 11:36:20 -0700 | [diff] [blame] | 2945 | set_bit(FCPORT_UPDATE_NEEDED, &base_vha->dpc_flags); |
| 2946 | qla2xxx_wake_dpc(base_vha); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2947 | } else { |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 2948 | fc_remote_port_delete(rport); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 2949 | qlt_fc_port_deleted(vha, fcport); |
| 2950 | } |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 2951 | } |
| 2952 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2953 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2954 | * qla2x00_mark_device_lost Updates fcport state when device goes offline. |
| 2955 | * |
| 2956 | * Input: ha = adapter block pointer. fcport = port structure pointer. |
| 2957 | * |
| 2958 | * Return: None. |
| 2959 | * |
| 2960 | * Context: |
| 2961 | */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2962 | 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] | 2963 | int do_login, int defer) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2964 | { |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2965 | if (atomic_read(&fcport->state) == FCS_ONLINE && |
Joe Carnuccio | c6d39e2 | 2012-05-15 14:34:20 -0400 | [diff] [blame] | 2966 | vha->vp_idx == fcport->vha->vp_idx) { |
Chad Dupuis | ec426e1 | 2011-03-30 11:46:32 -0700 | [diff] [blame] | 2967 | qla2x00_set_fcport_state(fcport, FCS_DEVICE_LOST); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2968 | qla2x00_schedule_rport_del(vha, fcport, defer); |
| 2969 | } |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 2970 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2971 | * We may need to retry the login, so don't change the state of the |
| 2972 | * port but do the retries. |
| 2973 | */ |
| 2974 | if (atomic_read(&fcport->state) != FCS_DEVICE_DEAD) |
Chad Dupuis | ec426e1 | 2011-03-30 11:46:32 -0700 | [diff] [blame] | 2975 | qla2x00_set_fcport_state(fcport, FCS_DEVICE_LOST); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2976 | |
| 2977 | if (!do_login) |
| 2978 | return; |
| 2979 | |
| 2980 | if (fcport->login_retry == 0) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2981 | fcport->login_retry = vha->hw->login_retry_count; |
| 2982 | set_bit(RELOGIN_NEEDED, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2983 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2984 | ql_dbg(ql_dbg_disc, vha, 0x2067, |
| 2985 | "Port login retry " |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2986 | "%02x%02x%02x%02x%02x%02x%02x%02x, " |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 2987 | "id = 0x%04x retry cnt=%d.\n", |
| 2988 | fcport->port_name[0], fcport->port_name[1], |
| 2989 | fcport->port_name[2], fcport->port_name[3], |
| 2990 | fcport->port_name[4], fcport->port_name[5], |
| 2991 | fcport->port_name[6], fcport->port_name[7], |
| 2992 | fcport->loop_id, fcport->login_retry); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2993 | } |
| 2994 | } |
| 2995 | |
| 2996 | /* |
| 2997 | * qla2x00_mark_all_devices_lost |
| 2998 | * Updates fcport state when device goes offline. |
| 2999 | * |
| 3000 | * Input: |
| 3001 | * ha = adapter block pointer. |
| 3002 | * fcport = port structure pointer. |
| 3003 | * |
| 3004 | * Return: |
| 3005 | * None. |
| 3006 | * |
| 3007 | * Context: |
| 3008 | */ |
| 3009 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3010 | qla2x00_mark_all_devices_lost(scsi_qla_host_t *vha, int defer) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3011 | { |
| 3012 | fc_port_t *fcport; |
| 3013 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3014 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
Joe Carnuccio | c6d39e2 | 2012-05-15 14:34:20 -0400 | [diff] [blame] | 3015 | if (vha->vp_idx != 0 && vha->vp_idx != fcport->vha->vp_idx) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3016 | continue; |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 3017 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3018 | /* |
| 3019 | * No point in marking the device as lost, if the device is |
| 3020 | * already DEAD. |
| 3021 | */ |
| 3022 | if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD) |
| 3023 | continue; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3024 | if (atomic_read(&fcport->state) == FCS_ONLINE) { |
Chad Dupuis | ec426e1 | 2011-03-30 11:46:32 -0700 | [diff] [blame] | 3025 | qla2x00_set_fcport_state(fcport, FCS_DEVICE_LOST); |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 3026 | if (defer) |
| 3027 | qla2x00_schedule_rport_del(vha, fcport, defer); |
Joe Carnuccio | c6d39e2 | 2012-05-15 14:34:20 -0400 | [diff] [blame] | 3028 | else if (vha->vp_idx == fcport->vha->vp_idx) |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 3029 | qla2x00_schedule_rport_del(vha, fcport, defer); |
| 3030 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3031 | } |
| 3032 | } |
| 3033 | |
| 3034 | /* |
| 3035 | * qla2x00_mem_alloc |
| 3036 | * Allocates adapter memory. |
| 3037 | * |
| 3038 | * Returns: |
| 3039 | * 0 = success. |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3040 | * !0 = failure. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3041 | */ |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3042 | static int |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3043 | qla2x00_mem_alloc(struct qla_hw_data *ha, uint16_t req_len, uint16_t rsp_len, |
| 3044 | struct req_que **req, struct rsp_que **rsp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3045 | { |
| 3046 | char name[16]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3047 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3048 | 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] | 3049 | &ha->init_cb_dma, GFP_KERNEL); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3050 | if (!ha->init_cb) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3051 | goto fail; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3052 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3053 | if (qlt_mem_alloc(ha) < 0) |
| 3054 | goto fail_free_init_cb; |
| 3055 | |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 3056 | ha->gid_list = dma_alloc_coherent(&ha->pdev->dev, |
| 3057 | qla2x00_gid_list_size(ha), &ha->gid_list_dma, GFP_KERNEL); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3058 | if (!ha->gid_list) |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3059 | goto fail_free_tgt_mem; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3060 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3061 | ha->srb_mempool = mempool_create_slab_pool(SRB_MIN_REQ, srb_cachep); |
| 3062 | if (!ha->srb_mempool) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3063 | goto fail_free_gid_list; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3064 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3065 | if (IS_QLA82XX(ha)) { |
| 3066 | /* Allocate cache for CT6 Ctx. */ |
| 3067 | if (!ctx_cachep) { |
| 3068 | ctx_cachep = kmem_cache_create("qla2xxx_ctx", |
| 3069 | sizeof(struct ct6_dsd), 0, |
| 3070 | SLAB_HWCACHE_ALIGN, NULL); |
| 3071 | if (!ctx_cachep) |
| 3072 | goto fail_free_gid_list; |
| 3073 | } |
| 3074 | ha->ctx_mempool = mempool_create_slab_pool(SRB_MIN_REQ, |
| 3075 | ctx_cachep); |
| 3076 | if (!ha->ctx_mempool) |
| 3077 | goto fail_free_srb_mempool; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3078 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0021, |
| 3079 | "ctx_cachep=%p ctx_mempool=%p.\n", |
| 3080 | ctx_cachep, ha->ctx_mempool); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3081 | } |
| 3082 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3083 | /* Get memory for cached NVRAM */ |
| 3084 | ha->nvram = kzalloc(MAX_NVRAM_SIZE, GFP_KERNEL); |
| 3085 | if (!ha->nvram) |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3086 | goto fail_free_ctx_mempool; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3087 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3088 | snprintf(name, sizeof(name), "%s_%d", QLA2XXX_DRIVER_NAME, |
| 3089 | ha->pdev->device); |
| 3090 | ha->s_dma_pool = dma_pool_create(name, &ha->pdev->dev, |
| 3091 | DMA_POOL_SIZE, 8, 0); |
| 3092 | if (!ha->s_dma_pool) |
| 3093 | goto fail_free_nvram; |
| 3094 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3095 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0022, |
| 3096 | "init_cb=%p gid_list=%p, srb_mempool=%p s_dma_pool=%p.\n", |
| 3097 | ha->init_cb, ha->gid_list, ha->srb_mempool, ha->s_dma_pool); |
| 3098 | |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 3099 | if (IS_QLA82XX(ha) || ql2xenabledif) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3100 | ha->dl_dma_pool = dma_pool_create(name, &ha->pdev->dev, |
| 3101 | DSD_LIST_DMA_POOL_SIZE, 8, 0); |
| 3102 | if (!ha->dl_dma_pool) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3103 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0023, |
| 3104 | "Failed to allocate memory for dl_dma_pool.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3105 | goto fail_s_dma_pool; |
| 3106 | } |
| 3107 | |
| 3108 | ha->fcp_cmnd_dma_pool = dma_pool_create(name, &ha->pdev->dev, |
| 3109 | FCP_CMND_DMA_POOL_SIZE, 8, 0); |
| 3110 | if (!ha->fcp_cmnd_dma_pool) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3111 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0024, |
| 3112 | "Failed to allocate memory for fcp_cmnd_dma_pool.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3113 | goto fail_dl_dma_pool; |
| 3114 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3115 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0025, |
| 3116 | "dl_dma_pool=%p fcp_cmnd_dma_pool=%p.\n", |
| 3117 | ha->dl_dma_pool, ha->fcp_cmnd_dma_pool); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3118 | } |
| 3119 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3120 | /* Allocate memory for SNS commands */ |
| 3121 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3122 | /* Get consistent memory allocated for SNS commands */ |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3123 | ha->sns_cmd = dma_alloc_coherent(&ha->pdev->dev, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3124 | sizeof(struct sns_cmd_pkt), &ha->sns_cmd_dma, GFP_KERNEL); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3125 | if (!ha->sns_cmd) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3126 | goto fail_dma_pool; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3127 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0026, |
Joe Perches | d8424f6 | 2011-11-18 09:03:06 -0800 | [diff] [blame] | 3128 | "sns_cmd: %p.\n", ha->sns_cmd); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3129 | } else { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3130 | /* Get consistent memory allocated for MS IOCB */ |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3131 | ha->ms_iocb = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3132 | &ha->ms_iocb_dma); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3133 | if (!ha->ms_iocb) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3134 | goto fail_dma_pool; |
| 3135 | /* Get consistent memory allocated for CT SNS commands */ |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3136 | ha->ct_sns = dma_alloc_coherent(&ha->pdev->dev, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3137 | sizeof(struct ct_sns_pkt), &ha->ct_sns_dma, GFP_KERNEL); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3138 | if (!ha->ct_sns) |
| 3139 | goto fail_free_ms_iocb; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3140 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0027, |
| 3141 | "ms_iocb=%p ct_sns=%p.\n", |
| 3142 | ha->ms_iocb, ha->ct_sns); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3143 | } |
| 3144 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3145 | /* Allocate memory for request ring */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3146 | *req = kzalloc(sizeof(struct req_que), GFP_KERNEL); |
| 3147 | if (!*req) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3148 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0028, |
| 3149 | "Failed to allocate memory for req.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3150 | goto fail_req; |
| 3151 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3152 | (*req)->length = req_len; |
| 3153 | (*req)->ring = dma_alloc_coherent(&ha->pdev->dev, |
| 3154 | ((*req)->length + 1) * sizeof(request_t), |
| 3155 | &(*req)->dma, GFP_KERNEL); |
| 3156 | if (!(*req)->ring) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3157 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0029, |
| 3158 | "Failed to allocate memory for req_ring.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3159 | goto fail_req_ring; |
| 3160 | } |
| 3161 | /* Allocate memory for response ring */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3162 | *rsp = kzalloc(sizeof(struct rsp_que), GFP_KERNEL); |
| 3163 | if (!*rsp) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3164 | ql_log_pci(ql_log_fatal, ha->pdev, 0x002a, |
| 3165 | "Failed to allocate memory for rsp.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3166 | goto fail_rsp; |
| 3167 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3168 | (*rsp)->hw = ha; |
| 3169 | (*rsp)->length = rsp_len; |
| 3170 | (*rsp)->ring = dma_alloc_coherent(&ha->pdev->dev, |
| 3171 | ((*rsp)->length + 1) * sizeof(response_t), |
| 3172 | &(*rsp)->dma, GFP_KERNEL); |
| 3173 | if (!(*rsp)->ring) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3174 | ql_log_pci(ql_log_fatal, ha->pdev, 0x002b, |
| 3175 | "Failed to allocate memory for rsp_ring.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3176 | goto fail_rsp_ring; |
| 3177 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3178 | (*req)->rsp = *rsp; |
| 3179 | (*rsp)->req = *req; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3180 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x002c, |
| 3181 | "req=%p req->length=%d req->ring=%p rsp=%p " |
| 3182 | "rsp->length=%d rsp->ring=%p.\n", |
| 3183 | *req, (*req)->length, (*req)->ring, *rsp, (*rsp)->length, |
| 3184 | (*rsp)->ring); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3185 | /* Allocate memory for NVRAM data for vports */ |
| 3186 | if (ha->nvram_npiv_size) { |
| 3187 | ha->npiv_info = kzalloc(sizeof(struct qla_npiv_entry) * |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3188 | ha->nvram_npiv_size, GFP_KERNEL); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3189 | if (!ha->npiv_info) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3190 | ql_log_pci(ql_log_fatal, ha->pdev, 0x002d, |
| 3191 | "Failed to allocate memory for npiv_info.\n"); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3192 | goto fail_npiv_info; |
| 3193 | } |
| 3194 | } else |
| 3195 | ha->npiv_info = NULL; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3196 | |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 3197 | /* Get consistent memory allocated for EX-INIT-CB. */ |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 3198 | if (IS_CNA_CAPABLE(ha) || IS_QLA2031(ha)) { |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 3199 | ha->ex_init_cb = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, |
| 3200 | &ha->ex_init_cb_dma); |
| 3201 | if (!ha->ex_init_cb) |
| 3202 | goto fail_ex_init_cb; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3203 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x002e, |
| 3204 | "ex_init_cb=%p.\n", ha->ex_init_cb); |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 3205 | } |
| 3206 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3207 | INIT_LIST_HEAD(&ha->gbl_dsd_list); |
| 3208 | |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 3209 | /* Get consistent memory allocated for Async Port-Database. */ |
| 3210 | if (!IS_FWI2_CAPABLE(ha)) { |
| 3211 | ha->async_pd = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, |
| 3212 | &ha->async_pd_dma); |
| 3213 | if (!ha->async_pd) |
| 3214 | goto fail_async_pd; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3215 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x002f, |
| 3216 | "async_pd=%p.\n", ha->async_pd); |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 3217 | } |
| 3218 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3219 | INIT_LIST_HEAD(&ha->vp_list); |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 3220 | |
| 3221 | /* Allocate memory for our loop_id bitmap */ |
| 3222 | ha->loop_id_map = kzalloc(BITS_TO_LONGS(LOOPID_MAP_SIZE) * sizeof(long), |
| 3223 | GFP_KERNEL); |
| 3224 | if (!ha->loop_id_map) |
| 3225 | goto fail_async_pd; |
| 3226 | else { |
| 3227 | qla2x00_set_reserved_loop_ids(ha); |
| 3228 | ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0123, |
| 3229 | "loop_id_map=%p. \n", ha->loop_id_map); |
| 3230 | } |
| 3231 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3232 | return 1; |
| 3233 | |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 3234 | fail_async_pd: |
| 3235 | 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] | 3236 | fail_ex_init_cb: |
| 3237 | kfree(ha->npiv_info); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3238 | fail_npiv_info: |
| 3239 | dma_free_coherent(&ha->pdev->dev, ((*rsp)->length + 1) * |
| 3240 | sizeof(response_t), (*rsp)->ring, (*rsp)->dma); |
| 3241 | (*rsp)->ring = NULL; |
| 3242 | (*rsp)->dma = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3243 | fail_rsp_ring: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3244 | kfree(*rsp); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3245 | fail_rsp: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3246 | dma_free_coherent(&ha->pdev->dev, ((*req)->length + 1) * |
| 3247 | sizeof(request_t), (*req)->ring, (*req)->dma); |
| 3248 | (*req)->ring = NULL; |
| 3249 | (*req)->dma = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3250 | fail_req_ring: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3251 | kfree(*req); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3252 | fail_req: |
| 3253 | dma_free_coherent(&ha->pdev->dev, sizeof(struct ct_sns_pkt), |
| 3254 | ha->ct_sns, ha->ct_sns_dma); |
| 3255 | ha->ct_sns = NULL; |
| 3256 | ha->ct_sns_dma = 0; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3257 | fail_free_ms_iocb: |
| 3258 | dma_pool_free(ha->s_dma_pool, ha->ms_iocb, ha->ms_iocb_dma); |
| 3259 | ha->ms_iocb = NULL; |
| 3260 | ha->ms_iocb_dma = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3261 | fail_dma_pool: |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 3262 | if (IS_QLA82XX(ha) || ql2xenabledif) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3263 | dma_pool_destroy(ha->fcp_cmnd_dma_pool); |
| 3264 | ha->fcp_cmnd_dma_pool = NULL; |
| 3265 | } |
| 3266 | fail_dl_dma_pool: |
Arun Easi | bad7500 | 2010-05-04 15:01:30 -0700 | [diff] [blame] | 3267 | if (IS_QLA82XX(ha) || ql2xenabledif) { |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3268 | dma_pool_destroy(ha->dl_dma_pool); |
| 3269 | ha->dl_dma_pool = NULL; |
| 3270 | } |
| 3271 | fail_s_dma_pool: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3272 | dma_pool_destroy(ha->s_dma_pool); |
| 3273 | ha->s_dma_pool = NULL; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3274 | fail_free_nvram: |
| 3275 | kfree(ha->nvram); |
| 3276 | ha->nvram = NULL; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3277 | fail_free_ctx_mempool: |
| 3278 | mempool_destroy(ha->ctx_mempool); |
| 3279 | ha->ctx_mempool = NULL; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3280 | fail_free_srb_mempool: |
| 3281 | mempool_destroy(ha->srb_mempool); |
| 3282 | ha->srb_mempool = NULL; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3283 | fail_free_gid_list: |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 3284 | dma_free_coherent(&ha->pdev->dev, qla2x00_gid_list_size(ha), |
| 3285 | ha->gid_list, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3286 | ha->gid_list_dma); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3287 | ha->gid_list = NULL; |
| 3288 | ha->gid_list_dma = 0; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3289 | fail_free_tgt_mem: |
| 3290 | qlt_mem_free(ha); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3291 | fail_free_init_cb: |
| 3292 | dma_free_coherent(&ha->pdev->dev, ha->init_cb_size, ha->init_cb, |
| 3293 | ha->init_cb_dma); |
| 3294 | ha->init_cb = NULL; |
| 3295 | ha->init_cb_dma = 0; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3296 | fail: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3297 | ql_log(ql_log_fatal, NULL, 0x0030, |
| 3298 | "Memory allocation failure.\n"); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3299 | return -ENOMEM; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3300 | } |
| 3301 | |
| 3302 | /* |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3303 | * qla2x00_free_fw_dump |
| 3304 | * Frees fw dump stuff. |
| 3305 | * |
| 3306 | * Input: |
| 3307 | * ha = adapter block pointer. |
| 3308 | */ |
| 3309 | static void |
| 3310 | qla2x00_free_fw_dump(struct qla_hw_data *ha) |
| 3311 | { |
| 3312 | if (ha->fce) |
| 3313 | dma_free_coherent(&ha->pdev->dev, FCE_SIZE, ha->fce, |
| 3314 | ha->fce_dma); |
| 3315 | |
| 3316 | if (ha->fw_dump) { |
| 3317 | if (ha->eft) |
| 3318 | dma_free_coherent(&ha->pdev->dev, |
| 3319 | ntohl(ha->fw_dump->eft_size), ha->eft, ha->eft_dma); |
| 3320 | vfree(ha->fw_dump); |
| 3321 | } |
| 3322 | ha->fce = NULL; |
| 3323 | ha->fce_dma = 0; |
| 3324 | ha->eft = NULL; |
| 3325 | ha->eft_dma = 0; |
| 3326 | ha->fw_dump = NULL; |
| 3327 | ha->fw_dumped = 0; |
| 3328 | ha->fw_dump_reading = 0; |
| 3329 | } |
| 3330 | |
| 3331 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3332 | * qla2x00_mem_free |
| 3333 | * Frees all adapter allocated memory. |
| 3334 | * |
| 3335 | * Input: |
| 3336 | * ha = adapter block pointer. |
| 3337 | */ |
Adrian Bunk | a824ebb | 2008-01-17 09:02:15 -0800 | [diff] [blame] | 3338 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3339 | qla2x00_mem_free(struct qla_hw_data *ha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3340 | { |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 3341 | qla2x00_free_fw_dump(ha); |
| 3342 | |
Saurav Kashyap | 8117877 | 2012-08-22 14:21:04 -0400 | [diff] [blame] | 3343 | if (ha->mctp_dump) |
| 3344 | dma_free_coherent(&ha->pdev->dev, MCTP_DUMP_SIZE, ha->mctp_dump, |
| 3345 | ha->mctp_dump_dma); |
| 3346 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3347 | if (ha->srb_mempool) |
| 3348 | mempool_destroy(ha->srb_mempool); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3349 | |
Andrew Vasquez | 11bbc1d | 2009-06-03 09:55:14 -0700 | [diff] [blame] | 3350 | if (ha->dcbx_tlv) |
| 3351 | dma_free_coherent(&ha->pdev->dev, DCBX_TLV_DATA_SIZE, |
| 3352 | ha->dcbx_tlv, ha->dcbx_tlv_dma); |
| 3353 | |
Andrew Vasquez | ce0423f | 2009-06-03 09:55:13 -0700 | [diff] [blame] | 3354 | if (ha->xgmac_data) |
| 3355 | dma_free_coherent(&ha->pdev->dev, XGMAC_DATA_SIZE, |
| 3356 | ha->xgmac_data, ha->xgmac_data_dma); |
| 3357 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3358 | if (ha->sns_cmd) |
| 3359 | dma_free_coherent(&ha->pdev->dev, sizeof(struct sns_cmd_pkt), |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3360 | ha->sns_cmd, ha->sns_cmd_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3361 | |
| 3362 | if (ha->ct_sns) |
| 3363 | dma_free_coherent(&ha->pdev->dev, sizeof(struct ct_sns_pkt), |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3364 | ha->ct_sns, ha->ct_sns_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3365 | |
Andrew Vasquez | 88729e5 | 2006-06-23 16:10:50 -0700 | [diff] [blame] | 3366 | if (ha->sfp_data) |
| 3367 | dma_pool_free(ha->s_dma_pool, ha->sfp_data, ha->sfp_data_dma); |
| 3368 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3369 | if (ha->ms_iocb) |
| 3370 | dma_pool_free(ha->s_dma_pool, ha->ms_iocb, ha->ms_iocb_dma); |
| 3371 | |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 3372 | if (ha->ex_init_cb) |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3373 | dma_pool_free(ha->s_dma_pool, |
| 3374 | ha->ex_init_cb, ha->ex_init_cb_dma); |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 3375 | |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 3376 | if (ha->async_pd) |
| 3377 | dma_pool_free(ha->s_dma_pool, ha->async_pd, ha->async_pd_dma); |
| 3378 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3379 | if (ha->s_dma_pool) |
| 3380 | dma_pool_destroy(ha->s_dma_pool); |
| 3381 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3382 | if (ha->gid_list) |
Chad Dupuis | 642ef98 | 2012-02-09 11:15:57 -0800 | [diff] [blame] | 3383 | dma_free_coherent(&ha->pdev->dev, qla2x00_gid_list_size(ha), |
| 3384 | ha->gid_list, ha->gid_list_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3385 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3386 | if (IS_QLA82XX(ha)) { |
| 3387 | if (!list_empty(&ha->gbl_dsd_list)) { |
| 3388 | struct dsd_dma *dsd_ptr, *tdsd_ptr; |
| 3389 | |
| 3390 | /* clean up allocated prev pool */ |
| 3391 | list_for_each_entry_safe(dsd_ptr, |
| 3392 | tdsd_ptr, &ha->gbl_dsd_list, list) { |
| 3393 | dma_pool_free(ha->dl_dma_pool, |
| 3394 | dsd_ptr->dsd_addr, dsd_ptr->dsd_list_dma); |
| 3395 | list_del(&dsd_ptr->list); |
| 3396 | kfree(dsd_ptr); |
| 3397 | } |
| 3398 | } |
| 3399 | } |
| 3400 | |
| 3401 | if (ha->dl_dma_pool) |
| 3402 | dma_pool_destroy(ha->dl_dma_pool); |
| 3403 | |
| 3404 | if (ha->fcp_cmnd_dma_pool) |
| 3405 | dma_pool_destroy(ha->fcp_cmnd_dma_pool); |
| 3406 | |
| 3407 | if (ha->ctx_mempool) |
| 3408 | mempool_destroy(ha->ctx_mempool); |
| 3409 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3410 | qlt_mem_free(ha); |
| 3411 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3412 | if (ha->init_cb) |
| 3413 | dma_free_coherent(&ha->pdev->dev, ha->init_cb_size, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3414 | ha->init_cb, ha->init_cb_dma); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3415 | vfree(ha->optrom_buffer); |
| 3416 | kfree(ha->nvram); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3417 | kfree(ha->npiv_info); |
Andrew Vasquez | 7a67735 | 2012-02-09 11:15:56 -0800 | [diff] [blame] | 3418 | kfree(ha->swl); |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 3419 | kfree(ha->loop_id_map); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3420 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 3421 | ha->srb_mempool = NULL; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3422 | ha->ctx_mempool = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3423 | ha->sns_cmd = NULL; |
| 3424 | ha->sns_cmd_dma = 0; |
| 3425 | ha->ct_sns = NULL; |
| 3426 | ha->ct_sns_dma = 0; |
| 3427 | ha->ms_iocb = NULL; |
| 3428 | ha->ms_iocb_dma = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3429 | ha->init_cb = NULL; |
| 3430 | ha->init_cb_dma = 0; |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 3431 | ha->ex_init_cb = NULL; |
| 3432 | ha->ex_init_cb_dma = 0; |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 3433 | ha->async_pd = NULL; |
| 3434 | ha->async_pd_dma = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3435 | |
| 3436 | ha->s_dma_pool = NULL; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 3437 | ha->dl_dma_pool = NULL; |
| 3438 | ha->fcp_cmnd_dma_pool = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3439 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3440 | ha->gid_list = NULL; |
| 3441 | ha->gid_list_dma = 0; |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 3442 | |
| 3443 | ha->tgt.atio_ring = NULL; |
| 3444 | ha->tgt.atio_dma = 0; |
| 3445 | ha->tgt.tgt_vp_map = NULL; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3446 | } |
| 3447 | |
| 3448 | struct scsi_qla_host *qla2x00_create_host(struct scsi_host_template *sht, |
| 3449 | struct qla_hw_data *ha) |
| 3450 | { |
| 3451 | struct Scsi_Host *host; |
| 3452 | struct scsi_qla_host *vha = NULL; |
| 3453 | |
| 3454 | host = scsi_host_alloc(sht, sizeof(scsi_qla_host_t)); |
| 3455 | if (host == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3456 | ql_log_pci(ql_log_fatal, ha->pdev, 0x0107, |
| 3457 | "Failed to allocate host from the scsi layer, aborting.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3458 | goto fail; |
| 3459 | } |
| 3460 | |
| 3461 | /* Clear our data area */ |
| 3462 | vha = shost_priv(host); |
| 3463 | memset(vha, 0, sizeof(scsi_qla_host_t)); |
| 3464 | |
| 3465 | vha->host = host; |
| 3466 | vha->host_no = host->host_no; |
| 3467 | vha->hw = ha; |
| 3468 | |
| 3469 | INIT_LIST_HEAD(&vha->vp_fcports); |
| 3470 | INIT_LIST_HEAD(&vha->work_list); |
| 3471 | INIT_LIST_HEAD(&vha->list); |
| 3472 | |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3473 | spin_lock_init(&vha->work_lock); |
| 3474 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3475 | sprintf(vha->host_str, "%s_%ld", QLA2XXX_DRIVER_NAME, vha->host_no); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3476 | ql_dbg(ql_dbg_init, vha, 0x0041, |
| 3477 | "Allocated the host=%p hw=%p vha=%p dev_name=%s", |
| 3478 | vha->host, vha->hw, vha, |
| 3479 | dev_name(&(ha->pdev->dev))); |
| 3480 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3481 | return vha; |
| 3482 | |
| 3483 | fail: |
| 3484 | return vha; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3485 | } |
| 3486 | |
Adrian Bunk | 01ef66b | 2008-04-24 15:21:27 -0700 | [diff] [blame] | 3487 | static struct qla_work_evt * |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3488 | 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] | 3489 | { |
| 3490 | struct qla_work_evt *e; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3491 | uint8_t bail; |
| 3492 | |
| 3493 | QLA_VHA_MARK_BUSY(vha, bail); |
| 3494 | if (bail) |
| 3495 | return NULL; |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3496 | |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3497 | e = kzalloc(sizeof(struct qla_work_evt), GFP_ATOMIC); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3498 | if (!e) { |
| 3499 | QLA_VHA_MARK_NOT_BUSY(vha); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3500 | return NULL; |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3501 | } |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3502 | |
| 3503 | INIT_LIST_HEAD(&e->list); |
| 3504 | e->type = type; |
| 3505 | e->flags = QLA_EVT_FLAG_FREE; |
| 3506 | return e; |
| 3507 | } |
| 3508 | |
Adrian Bunk | 01ef66b | 2008-04-24 15:21:27 -0700 | [diff] [blame] | 3509 | static int |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3510 | 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] | 3511 | { |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3512 | unsigned long flags; |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3513 | |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3514 | spin_lock_irqsave(&vha->work_lock, flags); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3515 | list_add_tail(&e->list, &vha->work_list); |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3516 | spin_unlock_irqrestore(&vha->work_lock, flags); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3517 | qla2xxx_wake_dpc(vha); |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3518 | |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3519 | return QLA_SUCCESS; |
| 3520 | } |
| 3521 | |
| 3522 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3523 | 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] | 3524 | u32 data) |
| 3525 | { |
| 3526 | struct qla_work_evt *e; |
| 3527 | |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3528 | e = qla2x00_alloc_work(vha, QLA_EVT_AEN); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3529 | if (!e) |
| 3530 | return QLA_FUNCTION_FAILED; |
| 3531 | |
| 3532 | e->u.aen.code = code; |
| 3533 | e->u.aen.data = data; |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3534 | return qla2x00_post_work(vha, e); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3535 | } |
| 3536 | |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 3537 | int |
| 3538 | qla2x00_post_idc_ack_work(struct scsi_qla_host *vha, uint16_t *mb) |
| 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_IDC_ACK); |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 3543 | if (!e) |
| 3544 | return QLA_FUNCTION_FAILED; |
| 3545 | |
| 3546 | 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] | 3547 | return qla2x00_post_work(vha, e); |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 3548 | } |
| 3549 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 3550 | #define qla2x00_post_async_work(name, type) \ |
| 3551 | int qla2x00_post_async_##name##_work( \ |
| 3552 | struct scsi_qla_host *vha, \ |
| 3553 | fc_port_t *fcport, uint16_t *data) \ |
| 3554 | { \ |
| 3555 | struct qla_work_evt *e; \ |
| 3556 | \ |
| 3557 | e = qla2x00_alloc_work(vha, type); \ |
| 3558 | if (!e) \ |
| 3559 | return QLA_FUNCTION_FAILED; \ |
| 3560 | \ |
| 3561 | e->u.logio.fcport = fcport; \ |
| 3562 | if (data) { \ |
| 3563 | e->u.logio.data[0] = data[0]; \ |
| 3564 | e->u.logio.data[1] = data[1]; \ |
| 3565 | } \ |
| 3566 | return qla2x00_post_work(vha, e); \ |
| 3567 | } |
| 3568 | |
| 3569 | qla2x00_post_async_work(login, QLA_EVT_ASYNC_LOGIN); |
| 3570 | qla2x00_post_async_work(login_done, QLA_EVT_ASYNC_LOGIN_DONE); |
| 3571 | qla2x00_post_async_work(logout, QLA_EVT_ASYNC_LOGOUT); |
| 3572 | qla2x00_post_async_work(logout_done, QLA_EVT_ASYNC_LOGOUT_DONE); |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 3573 | qla2x00_post_async_work(adisc, QLA_EVT_ASYNC_ADISC); |
| 3574 | qla2x00_post_async_work(adisc_done, QLA_EVT_ASYNC_ADISC_DONE); |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 3575 | |
Andrew Vasquez | 3420d36 | 2009-10-13 15:16:45 -0700 | [diff] [blame] | 3576 | int |
| 3577 | qla2x00_post_uevent_work(struct scsi_qla_host *vha, u32 code) |
| 3578 | { |
| 3579 | struct qla_work_evt *e; |
| 3580 | |
| 3581 | e = qla2x00_alloc_work(vha, QLA_EVT_UEVENT); |
| 3582 | if (!e) |
| 3583 | return QLA_FUNCTION_FAILED; |
| 3584 | |
| 3585 | e->u.uevent.code = code; |
| 3586 | return qla2x00_post_work(vha, e); |
| 3587 | } |
| 3588 | |
| 3589 | static void |
| 3590 | qla2x00_uevent_emit(struct scsi_qla_host *vha, u32 code) |
| 3591 | { |
| 3592 | char event_string[40]; |
| 3593 | char *envp[] = { event_string, NULL }; |
| 3594 | |
| 3595 | switch (code) { |
| 3596 | case QLA_UEVENT_CODE_FW_DUMP: |
| 3597 | snprintf(event_string, sizeof(event_string), "FW_DUMP=%ld", |
| 3598 | vha->host_no); |
| 3599 | break; |
| 3600 | default: |
| 3601 | /* do nothing */ |
| 3602 | break; |
| 3603 | } |
| 3604 | kobject_uevent_env(&vha->hw->pdev->dev.kobj, KOBJ_CHANGE, envp); |
| 3605 | } |
| 3606 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 3607 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3608 | qla2x00_do_work(struct scsi_qla_host *vha) |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3609 | { |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3610 | struct qla_work_evt *e, *tmp; |
| 3611 | unsigned long flags; |
| 3612 | LIST_HEAD(work); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3613 | |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3614 | spin_lock_irqsave(&vha->work_lock, flags); |
| 3615 | list_splice_init(&vha->work_list, &work); |
| 3616 | spin_unlock_irqrestore(&vha->work_lock, flags); |
| 3617 | |
| 3618 | list_for_each_entry_safe(e, tmp, &work, list) { |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3619 | list_del_init(&e->list); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3620 | |
| 3621 | switch (e->type) { |
| 3622 | case QLA_EVT_AEN: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3623 | fc_host_post_event(vha->host, fc_get_event_number(), |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3624 | e->u.aen.code, e->u.aen.data); |
| 3625 | break; |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 3626 | case QLA_EVT_IDC_ACK: |
| 3627 | qla81xx_idc_ack(vha, e->u.idc_ack.mb); |
| 3628 | break; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 3629 | case QLA_EVT_ASYNC_LOGIN: |
| 3630 | qla2x00_async_login(vha, e->u.logio.fcport, |
| 3631 | e->u.logio.data); |
| 3632 | break; |
| 3633 | case QLA_EVT_ASYNC_LOGIN_DONE: |
| 3634 | qla2x00_async_login_done(vha, e->u.logio.fcport, |
| 3635 | e->u.logio.data); |
| 3636 | break; |
| 3637 | case QLA_EVT_ASYNC_LOGOUT: |
| 3638 | qla2x00_async_logout(vha, e->u.logio.fcport); |
| 3639 | break; |
| 3640 | case QLA_EVT_ASYNC_LOGOUT_DONE: |
| 3641 | qla2x00_async_logout_done(vha, e->u.logio.fcport, |
| 3642 | e->u.logio.data); |
| 3643 | break; |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 3644 | case QLA_EVT_ASYNC_ADISC: |
| 3645 | qla2x00_async_adisc(vha, e->u.logio.fcport, |
| 3646 | e->u.logio.data); |
| 3647 | break; |
| 3648 | case QLA_EVT_ASYNC_ADISC_DONE: |
| 3649 | qla2x00_async_adisc_done(vha, e->u.logio.fcport, |
| 3650 | e->u.logio.data); |
| 3651 | break; |
Andrew Vasquez | 3420d36 | 2009-10-13 15:16:45 -0700 | [diff] [blame] | 3652 | case QLA_EVT_UEVENT: |
| 3653 | qla2x00_uevent_emit(vha, e->u.uevent.code); |
| 3654 | break; |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3655 | } |
| 3656 | if (e->flags & QLA_EVT_FLAG_FREE) |
| 3657 | kfree(e); |
Arun Easi | feafb7b | 2010-09-03 14:57:00 -0700 | [diff] [blame] | 3658 | |
| 3659 | /* For each work completed decrement vha ref count */ |
| 3660 | QLA_VHA_MARK_NOT_BUSY(vha); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3661 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3662 | } |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 3663 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3664 | /* Relogins all the fcports of a vport |
| 3665 | * Context: dpc thread |
| 3666 | */ |
| 3667 | void qla2x00_relogin(struct scsi_qla_host *vha) |
| 3668 | { |
| 3669 | fc_port_t *fcport; |
Andrew Vasquez | c6b2fca | 2009-03-05 11:07:03 -0800 | [diff] [blame] | 3670 | int status; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3671 | uint16_t next_loopid = 0; |
| 3672 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 3673 | uint16_t data[2]; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3674 | |
| 3675 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
| 3676 | /* |
| 3677 | * If the port is not ONLINE then try to login |
| 3678 | * to it if we haven't run out of retries. |
| 3679 | */ |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 3680 | if (atomic_read(&fcport->state) != FCS_ONLINE && |
| 3681 | fcport->login_retry && !(fcport->flags & FCF_ASYNC_SENT)) { |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 3682 | fcport->login_retry--; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3683 | if (fcport->flags & FCF_FABRIC_DEVICE) { |
Andrew Vasquez | f08b725 | 2010-01-12 12:59:48 -0800 | [diff] [blame] | 3684 | if (fcport->flags & FCF_FCP2_DEVICE) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3685 | ha->isp_ops->fabric_logout(vha, |
| 3686 | fcport->loop_id, |
| 3687 | fcport->d_id.b.domain, |
| 3688 | fcport->d_id.b.area, |
| 3689 | fcport->d_id.b.al_pa); |
| 3690 | |
Joe Carnuccio | 03bcfb5 | 2011-03-30 11:46:27 -0700 | [diff] [blame] | 3691 | if (fcport->loop_id == FC_NO_LOOP_ID) { |
| 3692 | fcport->loop_id = next_loopid = |
| 3693 | ha->min_external_loopid; |
| 3694 | status = qla2x00_find_new_loop_id( |
| 3695 | vha, fcport); |
| 3696 | if (status != QLA_SUCCESS) { |
| 3697 | /* Ran out of IDs to use */ |
| 3698 | break; |
| 3699 | } |
| 3700 | } |
| 3701 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 3702 | if (IS_ALOGIO_CAPABLE(ha)) { |
Andrew Vasquez | 5ff1d58 | 2010-05-04 15:01:26 -0700 | [diff] [blame] | 3703 | fcport->flags |= FCF_ASYNC_SENT; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 3704 | data[0] = 0; |
| 3705 | data[1] = QLA_LOGIO_LOGIN_RETRIED; |
| 3706 | status = qla2x00_post_async_login_work( |
| 3707 | vha, fcport, data); |
| 3708 | if (status == QLA_SUCCESS) |
| 3709 | continue; |
| 3710 | /* Attempt a retry. */ |
| 3711 | status = 1; |
Saurav Kashyap | aaf4d3e | 2012-04-25 07:26:16 -0700 | [diff] [blame] | 3712 | } else { |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 3713 | status = qla2x00_fabric_login(vha, |
| 3714 | fcport, &next_loopid); |
Saurav Kashyap | aaf4d3e | 2012-04-25 07:26:16 -0700 | [diff] [blame] | 3715 | if (status == QLA_SUCCESS) { |
| 3716 | int status2; |
| 3717 | uint8_t opts; |
| 3718 | |
| 3719 | opts = 0; |
| 3720 | if (fcport->flags & |
| 3721 | FCF_FCP2_DEVICE) |
| 3722 | opts |= BIT_1; |
| 3723 | status2 = |
| 3724 | qla2x00_get_port_database( |
| 3725 | vha, fcport, |
| 3726 | opts); |
| 3727 | if (status2 != QLA_SUCCESS) |
| 3728 | status = 1; |
| 3729 | } |
| 3730 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3731 | } else |
| 3732 | status = qla2x00_local_device_login(vha, |
| 3733 | fcport); |
| 3734 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3735 | if (status == QLA_SUCCESS) { |
| 3736 | fcport->old_loop_id = fcport->loop_id; |
| 3737 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3738 | ql_dbg(ql_dbg_disc, vha, 0x2003, |
| 3739 | "Port login OK: logged in ID 0x%x.\n", |
| 3740 | fcport->loop_id); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3741 | |
| 3742 | qla2x00_update_fcport(vha, fcport); |
| 3743 | |
| 3744 | } else if (status == 1) { |
| 3745 | set_bit(RELOGIN_NEEDED, &vha->dpc_flags); |
| 3746 | /* retry the login again */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 3747 | ql_dbg(ql_dbg_disc, vha, 0x2007, |
| 3748 | "Retrying %d login again loop_id 0x%x.\n", |
| 3749 | fcport->login_retry, fcport->loop_id); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3750 | } else { |
| 3751 | fcport->login_retry = 0; |
| 3752 | } |
| 3753 | |
| 3754 | if (fcport->login_retry == 0 && status != QLA_SUCCESS) |
Chad Dupuis | 5f16b33 | 2012-08-22 14:21:00 -0400 | [diff] [blame] | 3755 | qla2x00_clear_loop_id(fcport); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3756 | } |
| 3757 | if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) |
| 3758 | break; |
| 3759 | } |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 3760 | } |
| 3761 | |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 3762 | /* Schedule work on any of the dpc-workqueues */ |
| 3763 | void |
| 3764 | qla83xx_schedule_work(scsi_qla_host_t *base_vha, int work_code) |
| 3765 | { |
| 3766 | struct qla_hw_data *ha = base_vha->hw; |
| 3767 | |
| 3768 | switch (work_code) { |
| 3769 | case MBA_IDC_AEN: /* 0x8200 */ |
| 3770 | if (ha->dpc_lp_wq) |
| 3771 | queue_work(ha->dpc_lp_wq, &ha->idc_aen); |
| 3772 | break; |
| 3773 | |
| 3774 | case QLA83XX_NIC_CORE_RESET: /* 0x1 */ |
| 3775 | if (!ha->flags.nic_core_reset_hdlr_active) { |
| 3776 | if (ha->dpc_hp_wq) |
| 3777 | queue_work(ha->dpc_hp_wq, &ha->nic_core_reset); |
| 3778 | } else |
| 3779 | ql_dbg(ql_dbg_p3p, base_vha, 0xb05e, |
| 3780 | "NIC Core reset is already active. Skip " |
| 3781 | "scheduling it again.\n"); |
| 3782 | break; |
| 3783 | case QLA83XX_IDC_STATE_HANDLER: /* 0x2 */ |
| 3784 | if (ha->dpc_hp_wq) |
| 3785 | queue_work(ha->dpc_hp_wq, &ha->idc_state_handler); |
| 3786 | break; |
| 3787 | case QLA83XX_NIC_CORE_UNRECOVERABLE: /* 0x3 */ |
| 3788 | if (ha->dpc_hp_wq) |
| 3789 | queue_work(ha->dpc_hp_wq, &ha->nic_core_unrecoverable); |
| 3790 | break; |
| 3791 | default: |
| 3792 | ql_log(ql_log_warn, base_vha, 0xb05f, |
| 3793 | "Unknow work-code=0x%x.\n", work_code); |
| 3794 | } |
| 3795 | |
| 3796 | return; |
| 3797 | } |
| 3798 | |
| 3799 | /* Work: Perform NIC Core Unrecoverable state handling */ |
| 3800 | void |
| 3801 | qla83xx_nic_core_unrecoverable_work(struct work_struct *work) |
| 3802 | { |
| 3803 | struct qla_hw_data *ha = |
Arun Easi | 2ad1b67 | 2012-08-22 14:21:35 -0400 | [diff] [blame] | 3804 | container_of(work, struct qla_hw_data, nic_core_unrecoverable); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 3805 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 3806 | uint32_t dev_state = 0; |
| 3807 | |
| 3808 | qla83xx_idc_lock(base_vha, 0); |
| 3809 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, &dev_state); |
| 3810 | qla83xx_reset_ownership(base_vha); |
| 3811 | if (ha->flags.nic_core_reset_owner) { |
| 3812 | ha->flags.nic_core_reset_owner = 0; |
| 3813 | qla83xx_wr_reg(base_vha, QLA83XX_IDC_DEV_STATE, |
| 3814 | QLA8XXX_DEV_FAILED); |
| 3815 | ql_log(ql_log_info, base_vha, 0xb060, "HW State: FAILED.\n"); |
| 3816 | qla83xx_schedule_work(base_vha, QLA83XX_IDC_STATE_HANDLER); |
| 3817 | } |
| 3818 | qla83xx_idc_unlock(base_vha, 0); |
| 3819 | } |
| 3820 | |
| 3821 | /* Work: Execute IDC state handler */ |
| 3822 | void |
| 3823 | qla83xx_idc_state_handler_work(struct work_struct *work) |
| 3824 | { |
| 3825 | struct qla_hw_data *ha = |
Arun Easi | 2ad1b67 | 2012-08-22 14:21:35 -0400 | [diff] [blame] | 3826 | container_of(work, struct qla_hw_data, idc_state_handler); |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 3827 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 3828 | uint32_t dev_state = 0; |
| 3829 | |
| 3830 | qla83xx_idc_lock(base_vha, 0); |
| 3831 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, &dev_state); |
| 3832 | if (dev_state == QLA8XXX_DEV_FAILED || |
| 3833 | dev_state == QLA8XXX_DEV_NEED_QUIESCENT) |
| 3834 | qla83xx_idc_state_handler(base_vha); |
| 3835 | qla83xx_idc_unlock(base_vha, 0); |
| 3836 | } |
| 3837 | |
| 3838 | int |
| 3839 | qla83xx_check_nic_core_fw_alive(scsi_qla_host_t *base_vha) |
| 3840 | { |
| 3841 | int rval = QLA_SUCCESS; |
| 3842 | unsigned long heart_beat_wait = jiffies + (1 * HZ); |
| 3843 | uint32_t heart_beat_counter1, heart_beat_counter2; |
| 3844 | |
| 3845 | do { |
| 3846 | if (time_after(jiffies, heart_beat_wait)) { |
| 3847 | ql_dbg(ql_dbg_p3p, base_vha, 0xb07c, |
| 3848 | "Nic Core f/w is not alive.\n"); |
| 3849 | rval = QLA_FUNCTION_FAILED; |
| 3850 | break; |
| 3851 | } |
| 3852 | |
| 3853 | qla83xx_idc_lock(base_vha, 0); |
| 3854 | qla83xx_rd_reg(base_vha, QLA83XX_FW_HEARTBEAT, |
| 3855 | &heart_beat_counter1); |
| 3856 | qla83xx_idc_unlock(base_vha, 0); |
| 3857 | msleep(100); |
| 3858 | qla83xx_idc_lock(base_vha, 0); |
| 3859 | qla83xx_rd_reg(base_vha, QLA83XX_FW_HEARTBEAT, |
| 3860 | &heart_beat_counter2); |
| 3861 | qla83xx_idc_unlock(base_vha, 0); |
| 3862 | } while (heart_beat_counter1 == heart_beat_counter2); |
| 3863 | |
| 3864 | return rval; |
| 3865 | } |
| 3866 | |
| 3867 | /* Work: Perform NIC Core Reset handling */ |
| 3868 | void |
| 3869 | qla83xx_nic_core_reset_work(struct work_struct *work) |
| 3870 | { |
| 3871 | struct qla_hw_data *ha = |
| 3872 | container_of(work, struct qla_hw_data, nic_core_reset); |
| 3873 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 3874 | uint32_t dev_state = 0; |
| 3875 | |
Saurav Kashyap | 8117877 | 2012-08-22 14:21:04 -0400 | [diff] [blame] | 3876 | if (IS_QLA2031(ha)) { |
| 3877 | if (qla2xxx_mctp_dump(base_vha) != QLA_SUCCESS) |
| 3878 | ql_log(ql_log_warn, base_vha, 0xb081, |
| 3879 | "Failed to dump mctp\n"); |
| 3880 | return; |
| 3881 | } |
| 3882 | |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 3883 | if (!ha->flags.nic_core_reset_hdlr_active) { |
| 3884 | if (qla83xx_check_nic_core_fw_alive(base_vha) == QLA_SUCCESS) { |
| 3885 | qla83xx_idc_lock(base_vha, 0); |
| 3886 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, |
| 3887 | &dev_state); |
| 3888 | qla83xx_idc_unlock(base_vha, 0); |
| 3889 | if (dev_state != QLA8XXX_DEV_NEED_RESET) { |
| 3890 | ql_dbg(ql_dbg_p3p, base_vha, 0xb07a, |
| 3891 | "Nic Core f/w is alive.\n"); |
| 3892 | return; |
| 3893 | } |
| 3894 | } |
| 3895 | |
| 3896 | ha->flags.nic_core_reset_hdlr_active = 1; |
| 3897 | if (qla83xx_nic_core_reset(base_vha)) { |
| 3898 | /* NIC Core reset failed. */ |
| 3899 | ql_dbg(ql_dbg_p3p, base_vha, 0xb061, |
| 3900 | "NIC Core reset failed.\n"); |
| 3901 | } |
| 3902 | ha->flags.nic_core_reset_hdlr_active = 0; |
| 3903 | } |
| 3904 | } |
| 3905 | |
| 3906 | /* Work: Handle 8200 IDC aens */ |
| 3907 | void |
| 3908 | qla83xx_service_idc_aen(struct work_struct *work) |
| 3909 | { |
| 3910 | struct qla_hw_data *ha = |
| 3911 | container_of(work, struct qla_hw_data, idc_aen); |
| 3912 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 3913 | uint32_t dev_state, idc_control; |
| 3914 | |
| 3915 | qla83xx_idc_lock(base_vha, 0); |
| 3916 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, &dev_state); |
| 3917 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_CONTROL, &idc_control); |
| 3918 | qla83xx_idc_unlock(base_vha, 0); |
| 3919 | if (dev_state == QLA8XXX_DEV_NEED_RESET) { |
| 3920 | if (idc_control & QLA83XX_IDC_GRACEFUL_RESET) { |
| 3921 | ql_dbg(ql_dbg_p3p, base_vha, 0xb062, |
| 3922 | "Application requested NIC Core Reset.\n"); |
| 3923 | qla83xx_schedule_work(base_vha, QLA83XX_NIC_CORE_RESET); |
| 3924 | } else if (qla83xx_check_nic_core_fw_alive(base_vha) == |
| 3925 | QLA_SUCCESS) { |
| 3926 | ql_dbg(ql_dbg_p3p, base_vha, 0xb07b, |
| 3927 | "Other protocol driver requested NIC Core Reset.\n"); |
| 3928 | qla83xx_schedule_work(base_vha, QLA83XX_NIC_CORE_RESET); |
| 3929 | } |
| 3930 | } else if (dev_state == QLA8XXX_DEV_FAILED || |
| 3931 | dev_state == QLA8XXX_DEV_NEED_QUIESCENT) { |
| 3932 | qla83xx_schedule_work(base_vha, QLA83XX_IDC_STATE_HANDLER); |
| 3933 | } |
| 3934 | } |
| 3935 | |
| 3936 | static void |
| 3937 | qla83xx_wait_logic(void) |
| 3938 | { |
| 3939 | int i; |
| 3940 | |
| 3941 | /* Yield CPU */ |
| 3942 | if (!in_interrupt()) { |
| 3943 | /* |
| 3944 | * Wait about 200ms before retrying again. |
| 3945 | * This controls the number of retries for single |
| 3946 | * lock operation. |
| 3947 | */ |
| 3948 | msleep(100); |
| 3949 | schedule(); |
| 3950 | } else { |
| 3951 | for (i = 0; i < 20; i++) |
| 3952 | cpu_relax(); /* This a nop instr on i386 */ |
| 3953 | } |
| 3954 | } |
| 3955 | |
| 3956 | int |
| 3957 | qla83xx_force_lock_recovery(scsi_qla_host_t *base_vha) |
| 3958 | { |
| 3959 | int rval; |
| 3960 | uint32_t data; |
| 3961 | uint32_t idc_lck_rcvry_stage_mask = 0x3; |
| 3962 | uint32_t idc_lck_rcvry_owner_mask = 0x3c; |
| 3963 | struct qla_hw_data *ha = base_vha->hw; |
| 3964 | |
| 3965 | rval = qla83xx_rd_reg(base_vha, QLA83XX_IDC_LOCK_RECOVERY, &data); |
| 3966 | if (rval) |
| 3967 | return rval; |
| 3968 | |
| 3969 | if ((data & idc_lck_rcvry_stage_mask) > 0) { |
| 3970 | return QLA_SUCCESS; |
| 3971 | } else { |
| 3972 | data = (IDC_LOCK_RECOVERY_STAGE1) | (ha->portnum << 2); |
| 3973 | rval = qla83xx_wr_reg(base_vha, QLA83XX_IDC_LOCK_RECOVERY, |
| 3974 | data); |
| 3975 | if (rval) |
| 3976 | return rval; |
| 3977 | |
| 3978 | msleep(200); |
| 3979 | |
| 3980 | rval = qla83xx_rd_reg(base_vha, QLA83XX_IDC_LOCK_RECOVERY, |
| 3981 | &data); |
| 3982 | if (rval) |
| 3983 | return rval; |
| 3984 | |
| 3985 | if (((data & idc_lck_rcvry_owner_mask) >> 2) == ha->portnum) { |
| 3986 | data &= (IDC_LOCK_RECOVERY_STAGE2 | |
| 3987 | ~(idc_lck_rcvry_stage_mask)); |
| 3988 | rval = qla83xx_wr_reg(base_vha, |
| 3989 | QLA83XX_IDC_LOCK_RECOVERY, data); |
| 3990 | if (rval) |
| 3991 | return rval; |
| 3992 | |
| 3993 | /* Forcefully perform IDC UnLock */ |
| 3994 | rval = qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_UNLOCK, |
| 3995 | &data); |
| 3996 | if (rval) |
| 3997 | return rval; |
| 3998 | /* Clear lock-id by setting 0xff */ |
| 3999 | rval = qla83xx_wr_reg(base_vha, QLA83XX_DRIVER_LOCKID, |
| 4000 | 0xff); |
| 4001 | if (rval) |
| 4002 | return rval; |
| 4003 | /* Clear lock-recovery by setting 0x0 */ |
| 4004 | rval = qla83xx_wr_reg(base_vha, |
| 4005 | QLA83XX_IDC_LOCK_RECOVERY, 0x0); |
| 4006 | if (rval) |
| 4007 | return rval; |
| 4008 | } else |
| 4009 | return QLA_SUCCESS; |
| 4010 | } |
| 4011 | |
| 4012 | return rval; |
| 4013 | } |
| 4014 | |
| 4015 | int |
| 4016 | qla83xx_idc_lock_recovery(scsi_qla_host_t *base_vha) |
| 4017 | { |
| 4018 | int rval = QLA_SUCCESS; |
| 4019 | uint32_t o_drv_lockid, n_drv_lockid; |
| 4020 | unsigned long lock_recovery_timeout; |
| 4021 | |
| 4022 | lock_recovery_timeout = jiffies + QLA83XX_MAX_LOCK_RECOVERY_WAIT; |
| 4023 | retry_lockid: |
| 4024 | rval = qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCKID, &o_drv_lockid); |
| 4025 | if (rval) |
| 4026 | goto exit; |
| 4027 | |
| 4028 | /* MAX wait time before forcing IDC Lock recovery = 2 secs */ |
| 4029 | if (time_after_eq(jiffies, lock_recovery_timeout)) { |
| 4030 | if (qla83xx_force_lock_recovery(base_vha) == QLA_SUCCESS) |
| 4031 | return QLA_SUCCESS; |
| 4032 | else |
| 4033 | return QLA_FUNCTION_FAILED; |
| 4034 | } |
| 4035 | |
| 4036 | rval = qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCKID, &n_drv_lockid); |
| 4037 | if (rval) |
| 4038 | goto exit; |
| 4039 | |
| 4040 | if (o_drv_lockid == n_drv_lockid) { |
| 4041 | qla83xx_wait_logic(); |
| 4042 | goto retry_lockid; |
| 4043 | } else |
| 4044 | return QLA_SUCCESS; |
| 4045 | |
| 4046 | exit: |
| 4047 | return rval; |
| 4048 | } |
| 4049 | |
| 4050 | void |
| 4051 | qla83xx_idc_lock(scsi_qla_host_t *base_vha, uint16_t requester_id) |
| 4052 | { |
| 4053 | uint16_t options = (requester_id << 15) | BIT_6; |
| 4054 | uint32_t data; |
| 4055 | struct qla_hw_data *ha = base_vha->hw; |
| 4056 | |
| 4057 | /* IDC-lock implementation using driver-lock/lock-id remote registers */ |
| 4058 | retry_lock: |
| 4059 | if (qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCK, &data) |
| 4060 | == QLA_SUCCESS) { |
| 4061 | if (data) { |
| 4062 | /* Setting lock-id to our function-number */ |
| 4063 | qla83xx_wr_reg(base_vha, QLA83XX_DRIVER_LOCKID, |
| 4064 | ha->portnum); |
| 4065 | } else { |
| 4066 | ql_dbg(ql_dbg_p3p, base_vha, 0xb063, |
| 4067 | "Failed to acquire IDC lock. retrying...\n"); |
| 4068 | |
| 4069 | /* Retry/Perform IDC-Lock recovery */ |
| 4070 | if (qla83xx_idc_lock_recovery(base_vha) |
| 4071 | == QLA_SUCCESS) { |
| 4072 | qla83xx_wait_logic(); |
| 4073 | goto retry_lock; |
| 4074 | } else |
| 4075 | ql_log(ql_log_warn, base_vha, 0xb075, |
| 4076 | "IDC Lock recovery FAILED.\n"); |
| 4077 | } |
| 4078 | |
| 4079 | } |
| 4080 | |
| 4081 | return; |
| 4082 | |
| 4083 | /* XXX: IDC-lock implementation using access-control mbx */ |
| 4084 | retry_lock2: |
| 4085 | if (qla83xx_access_control(base_vha, options, 0, 0, NULL)) { |
| 4086 | ql_dbg(ql_dbg_p3p, base_vha, 0xb072, |
| 4087 | "Failed to acquire IDC lock. retrying...\n"); |
| 4088 | /* Retry/Perform IDC-Lock recovery */ |
| 4089 | if (qla83xx_idc_lock_recovery(base_vha) == QLA_SUCCESS) { |
| 4090 | qla83xx_wait_logic(); |
| 4091 | goto retry_lock2; |
| 4092 | } else |
| 4093 | ql_log(ql_log_warn, base_vha, 0xb076, |
| 4094 | "IDC Lock recovery FAILED.\n"); |
| 4095 | } |
| 4096 | |
| 4097 | return; |
| 4098 | } |
| 4099 | |
| 4100 | void |
| 4101 | qla83xx_idc_unlock(scsi_qla_host_t *base_vha, uint16_t requester_id) |
| 4102 | { |
| 4103 | uint16_t options = (requester_id << 15) | BIT_7, retry; |
| 4104 | uint32_t data; |
| 4105 | struct qla_hw_data *ha = base_vha->hw; |
| 4106 | |
| 4107 | /* IDC-unlock implementation using driver-unlock/lock-id |
| 4108 | * remote registers |
| 4109 | */ |
| 4110 | retry = 0; |
| 4111 | retry_unlock: |
| 4112 | if (qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_LOCKID, &data) |
| 4113 | == QLA_SUCCESS) { |
| 4114 | if (data == ha->portnum) { |
| 4115 | qla83xx_rd_reg(base_vha, QLA83XX_DRIVER_UNLOCK, &data); |
| 4116 | /* Clearing lock-id by setting 0xff */ |
| 4117 | qla83xx_wr_reg(base_vha, QLA83XX_DRIVER_LOCKID, 0xff); |
| 4118 | } else if (retry < 10) { |
| 4119 | /* SV: XXX: IDC unlock retrying needed here? */ |
| 4120 | |
| 4121 | /* Retry for IDC-unlock */ |
| 4122 | qla83xx_wait_logic(); |
| 4123 | retry++; |
| 4124 | ql_dbg(ql_dbg_p3p, base_vha, 0xb064, |
| 4125 | "Failed to release IDC lock, retyring=%d\n", retry); |
| 4126 | goto retry_unlock; |
| 4127 | } |
| 4128 | } else if (retry < 10) { |
| 4129 | /* Retry for IDC-unlock */ |
| 4130 | qla83xx_wait_logic(); |
| 4131 | retry++; |
| 4132 | ql_dbg(ql_dbg_p3p, base_vha, 0xb065, |
| 4133 | "Failed to read drv-lockid, retyring=%d\n", retry); |
| 4134 | goto retry_unlock; |
| 4135 | } |
| 4136 | |
| 4137 | return; |
| 4138 | |
| 4139 | /* XXX: IDC-unlock implementation using access-control mbx */ |
| 4140 | retry = 0; |
| 4141 | retry_unlock2: |
| 4142 | if (qla83xx_access_control(base_vha, options, 0, 0, NULL)) { |
| 4143 | if (retry < 10) { |
| 4144 | /* Retry for IDC-unlock */ |
| 4145 | qla83xx_wait_logic(); |
| 4146 | retry++; |
| 4147 | ql_dbg(ql_dbg_p3p, base_vha, 0xb066, |
| 4148 | "Failed to release IDC lock, retyring=%d\n", retry); |
| 4149 | goto retry_unlock2; |
| 4150 | } |
| 4151 | } |
| 4152 | |
| 4153 | return; |
| 4154 | } |
| 4155 | |
| 4156 | int |
| 4157 | __qla83xx_set_drv_presence(scsi_qla_host_t *vha) |
| 4158 | { |
| 4159 | int rval = QLA_SUCCESS; |
| 4160 | struct qla_hw_data *ha = vha->hw; |
| 4161 | uint32_t drv_presence; |
| 4162 | |
| 4163 | rval = qla83xx_rd_reg(vha, QLA83XX_IDC_DRV_PRESENCE, &drv_presence); |
| 4164 | if (rval == QLA_SUCCESS) { |
| 4165 | drv_presence |= (1 << ha->portnum); |
| 4166 | rval = qla83xx_wr_reg(vha, QLA83XX_IDC_DRV_PRESENCE, |
| 4167 | drv_presence); |
| 4168 | } |
| 4169 | |
| 4170 | return rval; |
| 4171 | } |
| 4172 | |
| 4173 | int |
| 4174 | qla83xx_set_drv_presence(scsi_qla_host_t *vha) |
| 4175 | { |
| 4176 | int rval = QLA_SUCCESS; |
| 4177 | |
| 4178 | qla83xx_idc_lock(vha, 0); |
| 4179 | rval = __qla83xx_set_drv_presence(vha); |
| 4180 | qla83xx_idc_unlock(vha, 0); |
| 4181 | |
| 4182 | return rval; |
| 4183 | } |
| 4184 | |
| 4185 | int |
| 4186 | __qla83xx_clear_drv_presence(scsi_qla_host_t *vha) |
| 4187 | { |
| 4188 | int rval = QLA_SUCCESS; |
| 4189 | struct qla_hw_data *ha = vha->hw; |
| 4190 | uint32_t drv_presence; |
| 4191 | |
| 4192 | rval = qla83xx_rd_reg(vha, QLA83XX_IDC_DRV_PRESENCE, &drv_presence); |
| 4193 | if (rval == QLA_SUCCESS) { |
| 4194 | drv_presence &= ~(1 << ha->portnum); |
| 4195 | rval = qla83xx_wr_reg(vha, QLA83XX_IDC_DRV_PRESENCE, |
| 4196 | drv_presence); |
| 4197 | } |
| 4198 | |
| 4199 | return rval; |
| 4200 | } |
| 4201 | |
| 4202 | int |
| 4203 | qla83xx_clear_drv_presence(scsi_qla_host_t *vha) |
| 4204 | { |
| 4205 | int rval = QLA_SUCCESS; |
| 4206 | |
| 4207 | qla83xx_idc_lock(vha, 0); |
| 4208 | rval = __qla83xx_clear_drv_presence(vha); |
| 4209 | qla83xx_idc_unlock(vha, 0); |
| 4210 | |
| 4211 | return rval; |
| 4212 | } |
| 4213 | |
| 4214 | void |
| 4215 | qla83xx_need_reset_handler(scsi_qla_host_t *vha) |
| 4216 | { |
| 4217 | struct qla_hw_data *ha = vha->hw; |
| 4218 | uint32_t drv_ack, drv_presence; |
| 4219 | unsigned long ack_timeout; |
| 4220 | |
| 4221 | /* Wait for IDC ACK from all functions (DRV-ACK == DRV-PRESENCE) */ |
| 4222 | ack_timeout = jiffies + (ha->fcoe_reset_timeout * HZ); |
| 4223 | while (1) { |
| 4224 | qla83xx_rd_reg(vha, QLA83XX_IDC_DRIVER_ACK, &drv_ack); |
| 4225 | qla83xx_rd_reg(vha, QLA83XX_IDC_DRV_PRESENCE, &drv_presence); |
| 4226 | if (drv_ack == drv_presence) |
| 4227 | break; |
| 4228 | |
| 4229 | if (time_after_eq(jiffies, ack_timeout)) { |
| 4230 | ql_log(ql_log_warn, vha, 0xb067, |
| 4231 | "RESET ACK TIMEOUT! drv_presence=0x%x " |
| 4232 | "drv_ack=0x%x\n", drv_presence, drv_ack); |
| 4233 | /* |
| 4234 | * The function(s) which did not ack in time are forced |
| 4235 | * to withdraw any further participation in the IDC |
| 4236 | * reset. |
| 4237 | */ |
| 4238 | if (drv_ack != drv_presence) |
| 4239 | qla83xx_wr_reg(vha, QLA83XX_IDC_DRV_PRESENCE, |
| 4240 | drv_ack); |
| 4241 | break; |
| 4242 | } |
| 4243 | |
| 4244 | qla83xx_idc_unlock(vha, 0); |
| 4245 | msleep(1000); |
| 4246 | qla83xx_idc_lock(vha, 0); |
| 4247 | } |
| 4248 | |
| 4249 | qla83xx_wr_reg(vha, QLA83XX_IDC_DEV_STATE, QLA8XXX_DEV_COLD); |
| 4250 | ql_log(ql_log_info, vha, 0xb068, "HW State: COLD/RE-INIT.\n"); |
| 4251 | } |
| 4252 | |
| 4253 | int |
| 4254 | qla83xx_device_bootstrap(scsi_qla_host_t *vha) |
| 4255 | { |
| 4256 | int rval = QLA_SUCCESS; |
| 4257 | uint32_t idc_control; |
| 4258 | |
| 4259 | qla83xx_wr_reg(vha, QLA83XX_IDC_DEV_STATE, QLA8XXX_DEV_INITIALIZING); |
| 4260 | ql_log(ql_log_info, vha, 0xb069, "HW State: INITIALIZING.\n"); |
| 4261 | |
| 4262 | /* Clearing IDC-Control Graceful-Reset Bit before resetting f/w */ |
| 4263 | __qla83xx_get_idc_control(vha, &idc_control); |
| 4264 | idc_control &= ~QLA83XX_IDC_GRACEFUL_RESET; |
| 4265 | __qla83xx_set_idc_control(vha, 0); |
| 4266 | |
| 4267 | qla83xx_idc_unlock(vha, 0); |
| 4268 | rval = qla83xx_restart_nic_firmware(vha); |
| 4269 | qla83xx_idc_lock(vha, 0); |
| 4270 | |
| 4271 | if (rval != QLA_SUCCESS) { |
| 4272 | ql_log(ql_log_fatal, vha, 0xb06a, |
| 4273 | "Failed to restart NIC f/w.\n"); |
| 4274 | qla83xx_wr_reg(vha, QLA83XX_IDC_DEV_STATE, QLA8XXX_DEV_FAILED); |
| 4275 | ql_log(ql_log_info, vha, 0xb06b, "HW State: FAILED.\n"); |
| 4276 | } else { |
| 4277 | ql_dbg(ql_dbg_p3p, vha, 0xb06c, |
| 4278 | "Success in restarting nic f/w.\n"); |
| 4279 | qla83xx_wr_reg(vha, QLA83XX_IDC_DEV_STATE, QLA8XXX_DEV_READY); |
| 4280 | ql_log(ql_log_info, vha, 0xb06d, "HW State: READY.\n"); |
| 4281 | } |
| 4282 | |
| 4283 | return rval; |
| 4284 | } |
| 4285 | |
| 4286 | /* Assumes idc_lock always held on entry */ |
| 4287 | int |
| 4288 | qla83xx_idc_state_handler(scsi_qla_host_t *base_vha) |
| 4289 | { |
| 4290 | struct qla_hw_data *ha = base_vha->hw; |
| 4291 | int rval = QLA_SUCCESS; |
| 4292 | unsigned long dev_init_timeout; |
| 4293 | uint32_t dev_state; |
| 4294 | |
| 4295 | /* Wait for MAX-INIT-TIMEOUT for the device to go ready */ |
| 4296 | dev_init_timeout = jiffies + (ha->fcoe_dev_init_timeout * HZ); |
| 4297 | |
| 4298 | while (1) { |
| 4299 | |
| 4300 | if (time_after_eq(jiffies, dev_init_timeout)) { |
| 4301 | ql_log(ql_log_warn, base_vha, 0xb06e, |
| 4302 | "Initialization TIMEOUT!\n"); |
| 4303 | /* Init timeout. Disable further NIC Core |
| 4304 | * communication. |
| 4305 | */ |
| 4306 | qla83xx_wr_reg(base_vha, QLA83XX_IDC_DEV_STATE, |
| 4307 | QLA8XXX_DEV_FAILED); |
| 4308 | ql_log(ql_log_info, base_vha, 0xb06f, |
| 4309 | "HW State: FAILED.\n"); |
| 4310 | } |
| 4311 | |
| 4312 | qla83xx_rd_reg(base_vha, QLA83XX_IDC_DEV_STATE, &dev_state); |
| 4313 | switch (dev_state) { |
| 4314 | case QLA8XXX_DEV_READY: |
| 4315 | if (ha->flags.nic_core_reset_owner) |
| 4316 | qla83xx_idc_audit(base_vha, |
| 4317 | IDC_AUDIT_COMPLETION); |
| 4318 | ha->flags.nic_core_reset_owner = 0; |
| 4319 | ql_dbg(ql_dbg_p3p, base_vha, 0xb070, |
| 4320 | "Reset_owner reset by 0x%x.\n", |
| 4321 | ha->portnum); |
| 4322 | goto exit; |
| 4323 | case QLA8XXX_DEV_COLD: |
| 4324 | if (ha->flags.nic_core_reset_owner) |
| 4325 | rval = qla83xx_device_bootstrap(base_vha); |
| 4326 | else { |
| 4327 | /* Wait for AEN to change device-state */ |
| 4328 | qla83xx_idc_unlock(base_vha, 0); |
| 4329 | msleep(1000); |
| 4330 | qla83xx_idc_lock(base_vha, 0); |
| 4331 | } |
| 4332 | break; |
| 4333 | case QLA8XXX_DEV_INITIALIZING: |
| 4334 | /* Wait for AEN to change device-state */ |
| 4335 | qla83xx_idc_unlock(base_vha, 0); |
| 4336 | msleep(1000); |
| 4337 | qla83xx_idc_lock(base_vha, 0); |
| 4338 | break; |
| 4339 | case QLA8XXX_DEV_NEED_RESET: |
| 4340 | if (!ql2xdontresethba && ha->flags.nic_core_reset_owner) |
| 4341 | qla83xx_need_reset_handler(base_vha); |
| 4342 | else { |
| 4343 | /* Wait for AEN to change device-state */ |
| 4344 | qla83xx_idc_unlock(base_vha, 0); |
| 4345 | msleep(1000); |
| 4346 | qla83xx_idc_lock(base_vha, 0); |
| 4347 | } |
| 4348 | /* reset timeout value after need reset handler */ |
| 4349 | dev_init_timeout = jiffies + |
| 4350 | (ha->fcoe_dev_init_timeout * HZ); |
| 4351 | break; |
| 4352 | case QLA8XXX_DEV_NEED_QUIESCENT: |
| 4353 | /* XXX: DEBUG for now */ |
| 4354 | qla83xx_idc_unlock(base_vha, 0); |
| 4355 | msleep(1000); |
| 4356 | qla83xx_idc_lock(base_vha, 0); |
| 4357 | break; |
| 4358 | case QLA8XXX_DEV_QUIESCENT: |
| 4359 | /* XXX: DEBUG for now */ |
| 4360 | if (ha->flags.quiesce_owner) |
| 4361 | goto exit; |
| 4362 | |
| 4363 | qla83xx_idc_unlock(base_vha, 0); |
| 4364 | msleep(1000); |
| 4365 | qla83xx_idc_lock(base_vha, 0); |
| 4366 | dev_init_timeout = jiffies + |
| 4367 | (ha->fcoe_dev_init_timeout * HZ); |
| 4368 | break; |
| 4369 | case QLA8XXX_DEV_FAILED: |
| 4370 | if (ha->flags.nic_core_reset_owner) |
| 4371 | qla83xx_idc_audit(base_vha, |
| 4372 | IDC_AUDIT_COMPLETION); |
| 4373 | ha->flags.nic_core_reset_owner = 0; |
| 4374 | __qla83xx_clear_drv_presence(base_vha); |
| 4375 | qla83xx_idc_unlock(base_vha, 0); |
| 4376 | qla8xxx_dev_failed_handler(base_vha); |
| 4377 | rval = QLA_FUNCTION_FAILED; |
| 4378 | qla83xx_idc_lock(base_vha, 0); |
| 4379 | goto exit; |
| 4380 | case QLA8XXX_BAD_VALUE: |
| 4381 | qla83xx_idc_unlock(base_vha, 0); |
| 4382 | msleep(1000); |
| 4383 | qla83xx_idc_lock(base_vha, 0); |
| 4384 | break; |
| 4385 | default: |
| 4386 | ql_log(ql_log_warn, base_vha, 0xb071, |
| 4387 | "Unknow Device State: %x.\n", dev_state); |
| 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 | } |
| 4394 | } |
| 4395 | |
| 4396 | exit: |
| 4397 | return rval; |
| 4398 | } |
| 4399 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4400 | /************************************************************************** |
| 4401 | * qla2x00_do_dpc |
| 4402 | * This kernel thread is a task that is schedule by the interrupt handler |
| 4403 | * to perform the background processing for interrupts. |
| 4404 | * |
| 4405 | * Notes: |
| 4406 | * This task always run in the context of a kernel thread. It |
| 4407 | * is kick-off by the driver's detect code and starts up |
| 4408 | * up one per adapter. It immediately goes to sleep and waits for |
| 4409 | * some fibre event. When either the interrupt handler or |
| 4410 | * the timer routine detects a event it will one of the task |
| 4411 | * bits then wake us up. |
| 4412 | **************************************************************************/ |
| 4413 | static int |
| 4414 | qla2x00_do_dpc(void *data) |
| 4415 | { |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4416 | int rval; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4417 | scsi_qla_host_t *base_vha; |
| 4418 | struct qla_hw_data *ha; |
Seokmann Ju | 99363ef | 2008-01-31 12:33:51 -0800 | [diff] [blame] | 4419 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4420 | ha = (struct qla_hw_data *)data; |
| 4421 | base_vha = pci_get_drvdata(ha->pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4422 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4423 | set_user_nice(current, -20); |
| 4424 | |
James Bottomley | 563585e | 2011-01-27 16:12:37 -0500 | [diff] [blame] | 4425 | set_current_state(TASK_INTERRUPTIBLE); |
Christoph Hellwig | 39a1124 | 2006-02-14 18:46:22 +0100 | [diff] [blame] | 4426 | while (!kthread_should_stop()) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4427 | ql_dbg(ql_dbg_dpc, base_vha, 0x4000, |
| 4428 | "DPC handler sleeping.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4429 | |
Christoph Hellwig | 39a1124 | 2006-02-14 18:46:22 +0100 | [diff] [blame] | 4430 | schedule(); |
| 4431 | __set_current_state(TASK_RUNNING); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4432 | |
Andrew Vasquez | c142caf | 2011-11-18 09:03:10 -0800 | [diff] [blame] | 4433 | if (!base_vha->flags.init_done || ha->flags.mbox_busy) |
| 4434 | goto end_loop; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4435 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 4436 | if (ha->flags.eeh_busy) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4437 | ql_dbg(ql_dbg_dpc, base_vha, 0x4003, |
| 4438 | "eeh_busy=%d.\n", ha->flags.eeh_busy); |
Andrew Vasquez | c142caf | 2011-11-18 09:03:10 -0800 | [diff] [blame] | 4439 | goto end_loop; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 4440 | } |
| 4441 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4442 | ha->dpc_active = 1; |
| 4443 | |
Saurav Kashyap | 5f28d2d | 2012-05-15 14:34:15 -0400 | [diff] [blame] | 4444 | ql_dbg(ql_dbg_dpc + ql_dbg_verbose, base_vha, 0x4001, |
| 4445 | "DPC handler waking up, dpc_flags=0x%lx.\n", |
| 4446 | base_vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4447 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4448 | qla2x00_do_work(base_vha); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 4449 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4450 | if (IS_QLA82XX(ha)) { |
| 4451 | if (test_and_clear_bit(ISP_UNRECOVERABLE, |
| 4452 | &base_vha->dpc_flags)) { |
| 4453 | qla82xx_idc_lock(ha); |
| 4454 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 4455 | QLA8XXX_DEV_FAILED); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4456 | qla82xx_idc_unlock(ha); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4457 | ql_log(ql_log_info, base_vha, 0x4004, |
| 4458 | "HW State: FAILED.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4459 | qla82xx_device_state_handler(base_vha); |
| 4460 | continue; |
| 4461 | } |
| 4462 | |
| 4463 | if (test_and_clear_bit(FCOE_CTX_RESET_NEEDED, |
| 4464 | &base_vha->dpc_flags)) { |
| 4465 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4466 | ql_dbg(ql_dbg_dpc, base_vha, 0x4005, |
| 4467 | "FCoE context reset scheduled.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4468 | if (!(test_and_set_bit(ABORT_ISP_ACTIVE, |
| 4469 | &base_vha->dpc_flags))) { |
| 4470 | if (qla82xx_fcoe_ctx_reset(base_vha)) { |
| 4471 | /* FCoE-ctx reset failed. |
| 4472 | * Escalate to chip-reset |
| 4473 | */ |
| 4474 | set_bit(ISP_ABORT_NEEDED, |
| 4475 | &base_vha->dpc_flags); |
| 4476 | } |
| 4477 | clear_bit(ABORT_ISP_ACTIVE, |
| 4478 | &base_vha->dpc_flags); |
| 4479 | } |
| 4480 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4481 | ql_dbg(ql_dbg_dpc, base_vha, 0x4006, |
| 4482 | "FCoE context reset end.\n"); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4483 | } |
| 4484 | } |
| 4485 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4486 | if (test_and_clear_bit(ISP_ABORT_NEEDED, |
| 4487 | &base_vha->dpc_flags)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4488 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4489 | ql_dbg(ql_dbg_dpc, base_vha, 0x4007, |
| 4490 | "ISP abort scheduled.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4491 | if (!(test_and_set_bit(ABORT_ISP_ACTIVE, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4492 | &base_vha->dpc_flags))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4493 | |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4494 | if (ha->isp_ops->abort_isp(base_vha)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4495 | /* failed. retry later */ |
| 4496 | set_bit(ISP_ABORT_NEEDED, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4497 | &base_vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4498 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4499 | clear_bit(ABORT_ISP_ACTIVE, |
| 4500 | &base_vha->dpc_flags); |
Seokmann Ju | 99363ef | 2008-01-31 12:33:51 -0800 | [diff] [blame] | 4501 | } |
| 4502 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4503 | ql_dbg(ql_dbg_dpc, base_vha, 0x4008, |
| 4504 | "ISP abort end.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4505 | } |
| 4506 | |
David Jeffery | a394aac | 2012-11-21 02:39:54 -0500 | [diff] [blame] | 4507 | if (test_and_clear_bit(FCPORT_UPDATE_NEEDED, |
| 4508 | &base_vha->dpc_flags)) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4509 | qla2x00_update_fcports(base_vha); |
Andrew Vasquez | c9c5ced | 2008-07-24 08:31:49 -0700 | [diff] [blame] | 4510 | } |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 4511 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 4512 | if (test_bit(SCR_PENDING, &base_vha->dpc_flags)) { |
| 4513 | int ret; |
| 4514 | ret = qla2x00_send_change_request(base_vha, 0x3, 0); |
| 4515 | if (ret != QLA_SUCCESS) |
| 4516 | ql_log(ql_log_warn, base_vha, 0x121, |
| 4517 | "Failed to enable receiving of RSCN " |
| 4518 | "requests: 0x%x.\n", ret); |
| 4519 | clear_bit(SCR_PENDING, &base_vha->dpc_flags); |
| 4520 | } |
| 4521 | |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 4522 | if (test_bit(ISP_QUIESCE_NEEDED, &base_vha->dpc_flags)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4523 | ql_dbg(ql_dbg_dpc, base_vha, 0x4009, |
| 4524 | "Quiescence mode scheduled.\n"); |
Chad Dupuis | 8fcd6b8 | 2012-08-22 14:21:06 -0400 | [diff] [blame] | 4525 | if (IS_QLA82XX(ha)) { |
| 4526 | qla82xx_device_state_handler(base_vha); |
| 4527 | clear_bit(ISP_QUIESCE_NEEDED, |
| 4528 | &base_vha->dpc_flags); |
| 4529 | if (!ha->flags.quiesce_owner) { |
| 4530 | qla2x00_perform_loop_resync(base_vha); |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 4531 | |
Chad Dupuis | 8fcd6b8 | 2012-08-22 14:21:06 -0400 | [diff] [blame] | 4532 | qla82xx_idc_lock(ha); |
| 4533 | qla82xx_clear_qsnt_ready(base_vha); |
| 4534 | qla82xx_idc_unlock(ha); |
| 4535 | } |
| 4536 | } else { |
| 4537 | clear_bit(ISP_QUIESCE_NEEDED, |
| 4538 | &base_vha->dpc_flags); |
| 4539 | qla2x00_quiesce_io(base_vha); |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 4540 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4541 | ql_dbg(ql_dbg_dpc, base_vha, 0x400a, |
| 4542 | "Quiescence mode end.\n"); |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 4543 | } |
| 4544 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4545 | if (test_and_clear_bit(RESET_MARKER_NEEDED, |
| 4546 | &base_vha->dpc_flags) && |
| 4547 | (!(test_and_set_bit(RESET_ACTIVE, &base_vha->dpc_flags)))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4548 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4549 | ql_dbg(ql_dbg_dpc, base_vha, 0x400b, |
| 4550 | "Reset marker scheduled.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4551 | qla2x00_rst_aen(base_vha); |
| 4552 | clear_bit(RESET_ACTIVE, &base_vha->dpc_flags); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4553 | ql_dbg(ql_dbg_dpc, base_vha, 0x400c, |
| 4554 | "Reset marker end.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4555 | } |
| 4556 | |
| 4557 | /* Retry each device up to login retry count */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4558 | if ((test_and_clear_bit(RELOGIN_NEEDED, |
| 4559 | &base_vha->dpc_flags)) && |
| 4560 | !test_bit(LOOP_RESYNC_NEEDED, &base_vha->dpc_flags) && |
| 4561 | atomic_read(&base_vha->loop_state) != LOOP_DOWN) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4562 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4563 | ql_dbg(ql_dbg_dpc, base_vha, 0x400d, |
| 4564 | "Relogin scheduled.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4565 | qla2x00_relogin(base_vha); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4566 | ql_dbg(ql_dbg_dpc, base_vha, 0x400e, |
| 4567 | "Relogin end.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4568 | } |
| 4569 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4570 | if (test_and_clear_bit(LOOP_RESYNC_NEEDED, |
| 4571 | &base_vha->dpc_flags)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4572 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4573 | ql_dbg(ql_dbg_dpc, base_vha, 0x400f, |
| 4574 | "Loop resync scheduled.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4575 | |
| 4576 | if (!(test_and_set_bit(LOOP_RESYNC_ACTIVE, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4577 | &base_vha->dpc_flags))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4578 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4579 | rval = qla2x00_loop_resync(base_vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4580 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4581 | clear_bit(LOOP_RESYNC_ACTIVE, |
| 4582 | &base_vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4583 | } |
| 4584 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4585 | ql_dbg(ql_dbg_dpc, base_vha, 0x4010, |
| 4586 | "Loop resync end.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4587 | } |
| 4588 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4589 | if (test_bit(NPIV_CONFIG_NEEDED, &base_vha->dpc_flags) && |
| 4590 | atomic_read(&base_vha->loop_state) == LOOP_READY) { |
| 4591 | clear_bit(NPIV_CONFIG_NEEDED, &base_vha->dpc_flags); |
| 4592 | qla2xxx_flash_npiv_conf(base_vha); |
Andrew Vasquez | 272976c | 2008-09-11 21:22:50 -0700 | [diff] [blame] | 4593 | } |
| 4594 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4595 | if (!ha->interrupts_on) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 4596 | ha->isp_ops->enable_intrs(ha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4597 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4598 | if (test_and_clear_bit(BEACON_BLINK_NEEDED, |
| 4599 | &base_vha->dpc_flags)) |
| 4600 | ha->isp_ops->beacon_blink(base_vha); |
andrew.vasquez@qlogic.com | f6df144 | 2006-01-31 16:05:07 -0800 | [diff] [blame] | 4601 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4602 | qla2x00_do_dpc_all_vps(base_vha); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4603 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4604 | ha->dpc_active = 0; |
Andrew Vasquez | c142caf | 2011-11-18 09:03:10 -0800 | [diff] [blame] | 4605 | end_loop: |
James Bottomley | 563585e | 2011-01-27 16:12:37 -0500 | [diff] [blame] | 4606 | set_current_state(TASK_INTERRUPTIBLE); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4607 | } /* End of while(1) */ |
James Bottomley | 563585e | 2011-01-27 16:12:37 -0500 | [diff] [blame] | 4608 | __set_current_state(TASK_RUNNING); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4609 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4610 | ql_dbg(ql_dbg_dpc, base_vha, 0x4011, |
| 4611 | "DPC handler exiting.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4612 | |
| 4613 | /* |
| 4614 | * Make sure that nobody tries to wake us up again. |
| 4615 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4616 | ha->dpc_active = 0; |
| 4617 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 4618 | /* Cleanup any residual CTX SRBs. */ |
| 4619 | qla2x00_abort_all_cmds(base_vha, DID_NO_CONNECT << 16); |
| 4620 | |
Christoph Hellwig | 39a1124 | 2006-02-14 18:46:22 +0100 | [diff] [blame] | 4621 | return 0; |
| 4622 | } |
| 4623 | |
| 4624 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4625 | qla2xxx_wake_dpc(struct scsi_qla_host *vha) |
Christoph Hellwig | 39a1124 | 2006-02-14 18:46:22 +0100 | [diff] [blame] | 4626 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4627 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | c795c1e | 2008-08-13 21:37:01 -0700 | [diff] [blame] | 4628 | struct task_struct *t = ha->dpc_thread; |
| 4629 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4630 | if (!test_bit(UNLOADING, &vha->dpc_flags) && t) |
Andrew Vasquez | c795c1e | 2008-08-13 21:37:01 -0700 | [diff] [blame] | 4631 | wake_up_process(t); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4632 | } |
| 4633 | |
| 4634 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4635 | * qla2x00_rst_aen |
| 4636 | * Processes asynchronous reset. |
| 4637 | * |
| 4638 | * Input: |
| 4639 | * ha = adapter block pointer. |
| 4640 | */ |
| 4641 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4642 | qla2x00_rst_aen(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4643 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4644 | if (vha->flags.online && !vha->flags.reset_active && |
| 4645 | !atomic_read(&vha->loop_down_timer) && |
| 4646 | !(test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4647 | do { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4648 | clear_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4649 | |
| 4650 | /* |
| 4651 | * Issue marker command only when we are going to start |
| 4652 | * the I/O. |
| 4653 | */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4654 | vha->marker_needed = 1; |
| 4655 | } while (!atomic_read(&vha->loop_down_timer) && |
| 4656 | (test_bit(RESET_MARKER_NEEDED, &vha->dpc_flags))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4657 | } |
| 4658 | } |
| 4659 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4660 | /************************************************************************** |
| 4661 | * qla2x00_timer |
| 4662 | * |
| 4663 | * Description: |
| 4664 | * One second timer |
| 4665 | * |
| 4666 | * Context: Interrupt |
| 4667 | ***************************************************************************/ |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4668 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4669 | qla2x00_timer(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4670 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4671 | unsigned long cpu_flags = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4672 | int start_dpc = 0; |
| 4673 | int index; |
| 4674 | srb_t *sp; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 4675 | uint16_t w; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4676 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4677 | struct req_que *req; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 4678 | |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 4679 | if (ha->flags.eeh_busy) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4680 | ql_dbg(ql_dbg_timer, vha, 0x6000, |
| 4681 | "EEH = %d, restarting timer.\n", |
| 4682 | ha->flags.eeh_busy); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 4683 | qla2x00_restart_timer(vha, WATCH_INTERVAL); |
| 4684 | return; |
| 4685 | } |
| 4686 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 4687 | /* Hardware read to raise pending EEH errors during mailbox waits. */ |
| 4688 | if (!pci_channel_offline(ha->pdev)) |
| 4689 | pci_read_config_word(ha->pdev, PCI_VENDOR_ID, &w); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4690 | |
Saurav Kashyap | cefcaba | 2011-05-10 11:18:18 -0700 | [diff] [blame] | 4691 | /* Make sure qla82xx_watchdog is run only for physical port */ |
| 4692 | if (!vha->vp_idx && IS_QLA82XX(ha)) { |
Saurav Kashyap | 579d12b | 2010-12-21 16:00:14 -0800 | [diff] [blame] | 4693 | if (test_bit(ISP_QUIESCE_NEEDED, &vha->dpc_flags)) |
| 4694 | start_dpc++; |
| 4695 | qla82xx_watchdog(vha); |
| 4696 | } |
| 4697 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4698 | /* Loop down handler. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4699 | if (atomic_read(&vha->loop_down_timer) > 0 && |
Giridhar Malavali | 8f7daea | 2011-03-30 11:46:26 -0700 | [diff] [blame] | 4700 | !(test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags)) && |
| 4701 | !(test_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags)) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4702 | && vha->flags.online) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4703 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4704 | if (atomic_read(&vha->loop_down_timer) == |
| 4705 | vha->loop_down_abort_time) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4706 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4707 | ql_log(ql_log_info, vha, 0x6008, |
| 4708 | "Loop down - aborting the queues before time expires.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4709 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4710 | if (!IS_QLA2100(ha) && vha->link_down_timeout) |
| 4711 | atomic_set(&vha->loop_state, LOOP_DEAD); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4712 | |
Andrew Vasquez | f08b725 | 2010-01-12 12:59:48 -0800 | [diff] [blame] | 4713 | /* |
| 4714 | * Schedule an ISP abort to return any FCP2-device |
| 4715 | * commands. |
| 4716 | */ |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4717 | /* NPIV - scan physical port only */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4718 | if (!vha->vp_idx) { |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4719 | spin_lock_irqsave(&ha->hardware_lock, |
| 4720 | cpu_flags); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 4721 | req = ha->req_q_map[0]; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4722 | for (index = 1; |
| 4723 | index < MAX_OUTSTANDING_COMMANDS; |
| 4724 | index++) { |
| 4725 | fc_port_t *sfcp; |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 4726 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4727 | sp = req->outstanding_cmds[index]; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4728 | if (!sp) |
| 4729 | continue; |
Giridhar Malavali | 9ba56b9 | 2012-02-09 11:15:36 -0800 | [diff] [blame] | 4730 | if (sp->type != SRB_SCSI_CMD) |
Andrew Vasquez | cf53b06 | 2009-08-20 11:06:04 -0700 | [diff] [blame] | 4731 | continue; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4732 | sfcp = sp->fcport; |
Andrew Vasquez | f08b725 | 2010-01-12 12:59:48 -0800 | [diff] [blame] | 4733 | if (!(sfcp->flags & FCF_FCP2_DEVICE)) |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4734 | continue; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4735 | |
Giridhar Malavali | 8f7daea | 2011-03-30 11:46:26 -0700 | [diff] [blame] | 4736 | if (IS_QLA82XX(ha)) |
| 4737 | set_bit(FCOE_CTX_RESET_NEEDED, |
| 4738 | &vha->dpc_flags); |
| 4739 | else |
| 4740 | set_bit(ISP_ABORT_NEEDED, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4741 | &vha->dpc_flags); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 4742 | break; |
| 4743 | } |
| 4744 | spin_unlock_irqrestore(&ha->hardware_lock, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4745 | cpu_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4746 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4747 | start_dpc++; |
| 4748 | } |
| 4749 | |
| 4750 | /* if the loop has been down for 4 minutes, reinit adapter */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4751 | if (atomic_dec_and_test(&vha->loop_down_timer) != 0) { |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 4752 | if (!(vha->device_flags & DFLG_NO_CABLE)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4753 | ql_log(ql_log_warn, vha, 0x6009, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4754 | "Loop down - aborting ISP.\n"); |
| 4755 | |
Giridhar Malavali | 8f7daea | 2011-03-30 11:46:26 -0700 | [diff] [blame] | 4756 | if (IS_QLA82XX(ha)) |
| 4757 | set_bit(FCOE_CTX_RESET_NEEDED, |
| 4758 | &vha->dpc_flags); |
| 4759 | else |
| 4760 | set_bit(ISP_ABORT_NEEDED, |
| 4761 | &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4762 | } |
| 4763 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4764 | ql_dbg(ql_dbg_timer, vha, 0x600a, |
| 4765 | "Loop down - seconds remaining %d.\n", |
| 4766 | atomic_read(&vha->loop_down_timer)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4767 | } |
| 4768 | |
Saurav Kashyap | cefcaba | 2011-05-10 11:18:18 -0700 | [diff] [blame] | 4769 | /* Check if beacon LED needs to be blinked for physical host only */ |
| 4770 | if (!vha->vp_idx && (ha->beacon_blink_led == 1)) { |
Saurav Kashyap | 999916d | 2011-08-16 11:31:45 -0700 | [diff] [blame] | 4771 | /* There is no beacon_blink function for ISP82xx */ |
| 4772 | if (!IS_QLA82XX(ha)) { |
| 4773 | set_bit(BEACON_BLINK_NEEDED, &vha->dpc_flags); |
| 4774 | start_dpc++; |
| 4775 | } |
andrew.vasquez@qlogic.com | f6df144 | 2006-01-31 16:05:07 -0800 | [diff] [blame] | 4776 | } |
| 4777 | |
Andrew Vasquez | 550bf57 | 2008-04-24 15:21:23 -0700 | [diff] [blame] | 4778 | /* Process any deferred work. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4779 | if (!list_empty(&vha->work_list)) |
Andrew Vasquez | 550bf57 | 2008-04-24 15:21:23 -0700 | [diff] [blame] | 4780 | start_dpc++; |
| 4781 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4782 | /* Schedule the DPC routine if needed */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4783 | if ((test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) || |
| 4784 | test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags) || |
| 4785 | test_bit(FCPORT_UPDATE_NEEDED, &vha->dpc_flags) || |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4786 | start_dpc || |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4787 | test_bit(RESET_MARKER_NEEDED, &vha->dpc_flags) || |
| 4788 | test_bit(BEACON_BLINK_NEEDED, &vha->dpc_flags) || |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4789 | test_bit(ISP_UNRECOVERABLE, &vha->dpc_flags) || |
| 4790 | test_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags) || |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4791 | test_bit(VP_DPC_NEEDED, &vha->dpc_flags) || |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4792 | test_bit(RELOGIN_NEEDED, &vha->dpc_flags))) { |
| 4793 | ql_dbg(ql_dbg_timer, vha, 0x600b, |
| 4794 | "isp_abort_needed=%d loop_resync_needed=%d " |
| 4795 | "fcport_update_needed=%d start_dpc=%d " |
| 4796 | "reset_marker_needed=%d", |
| 4797 | test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags), |
| 4798 | test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags), |
| 4799 | test_bit(FCPORT_UPDATE_NEEDED, &vha->dpc_flags), |
| 4800 | start_dpc, |
| 4801 | test_bit(RESET_MARKER_NEEDED, &vha->dpc_flags)); |
| 4802 | ql_dbg(ql_dbg_timer, vha, 0x600c, |
| 4803 | "beacon_blink_needed=%d isp_unrecoverable=%d " |
| 4804 | "fcoe_ctx_reset_needed=%d vp_dpc_needed=%d " |
| 4805 | "relogin_needed=%d.\n", |
| 4806 | test_bit(BEACON_BLINK_NEEDED, &vha->dpc_flags), |
| 4807 | test_bit(ISP_UNRECOVERABLE, &vha->dpc_flags), |
| 4808 | test_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags), |
| 4809 | test_bit(VP_DPC_NEEDED, &vha->dpc_flags), |
| 4810 | test_bit(RELOGIN_NEEDED, &vha->dpc_flags)); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4811 | qla2xxx_wake_dpc(vha); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4812 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4813 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4814 | qla2x00_restart_timer(vha, WATCH_INTERVAL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4815 | } |
| 4816 | |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4817 | /* Firmware interface routines. */ |
| 4818 | |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4819 | #define FW_BLOBS 10 |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4820 | #define FW_ISP21XX 0 |
| 4821 | #define FW_ISP22XX 1 |
| 4822 | #define FW_ISP2300 2 |
| 4823 | #define FW_ISP2322 3 |
andrew.vasquez@qlogic.com | 48c02fd | 2006-03-09 14:27:18 -0800 | [diff] [blame] | 4824 | #define FW_ISP24XX 4 |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 4825 | #define FW_ISP25XX 5 |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 4826 | #define FW_ISP81XX 6 |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4827 | #define FW_ISP82XX 7 |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4828 | #define FW_ISP2031 8 |
| 4829 | #define FW_ISP8031 9 |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4830 | |
Andrew Vasquez | bb8ee49 | 2006-10-02 12:00:48 -0700 | [diff] [blame] | 4831 | #define FW_FILE_ISP21XX "ql2100_fw.bin" |
| 4832 | #define FW_FILE_ISP22XX "ql2200_fw.bin" |
| 4833 | #define FW_FILE_ISP2300 "ql2300_fw.bin" |
| 4834 | #define FW_FILE_ISP2322 "ql2322_fw.bin" |
| 4835 | #define FW_FILE_ISP24XX "ql2400_fw.bin" |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 4836 | #define FW_FILE_ISP25XX "ql2500_fw.bin" |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 4837 | #define FW_FILE_ISP81XX "ql8100_fw.bin" |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4838 | #define FW_FILE_ISP82XX "ql8200_fw.bin" |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4839 | #define FW_FILE_ISP2031 "ql2600_fw.bin" |
| 4840 | #define FW_FILE_ISP8031 "ql8300_fw.bin" |
Andrew Vasquez | bb8ee49 | 2006-10-02 12:00:48 -0700 | [diff] [blame] | 4841 | |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 4842 | static DEFINE_MUTEX(qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4843 | |
| 4844 | static struct fw_blob qla_fw_blobs[FW_BLOBS] = { |
Andrew Vasquez | bb8ee49 | 2006-10-02 12:00:48 -0700 | [diff] [blame] | 4845 | { .name = FW_FILE_ISP21XX, .segs = { 0x1000, 0 }, }, |
| 4846 | { .name = FW_FILE_ISP22XX, .segs = { 0x1000, 0 }, }, |
| 4847 | { .name = FW_FILE_ISP2300, .segs = { 0x800, 0 }, }, |
| 4848 | { .name = FW_FILE_ISP2322, .segs = { 0x800, 0x1c000, 0x1e000, 0 }, }, |
| 4849 | { .name = FW_FILE_ISP24XX, }, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 4850 | { .name = FW_FILE_ISP25XX, }, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 4851 | { .name = FW_FILE_ISP81XX, }, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4852 | { .name = FW_FILE_ISP82XX, }, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4853 | { .name = FW_FILE_ISP2031, }, |
| 4854 | { .name = FW_FILE_ISP8031, }, |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4855 | }; |
| 4856 | |
| 4857 | struct fw_blob * |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4858 | qla2x00_request_firmware(scsi_qla_host_t *vha) |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4859 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4860 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4861 | struct fw_blob *blob; |
| 4862 | |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4863 | if (IS_QLA2100(ha)) { |
| 4864 | blob = &qla_fw_blobs[FW_ISP21XX]; |
| 4865 | } else if (IS_QLA2200(ha)) { |
| 4866 | blob = &qla_fw_blobs[FW_ISP22XX]; |
andrew.vasquez@qlogic.com | 48c02fd | 2006-03-09 14:27:18 -0800 | [diff] [blame] | 4867 | } else if (IS_QLA2300(ha) || IS_QLA2312(ha) || IS_QLA6312(ha)) { |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4868 | blob = &qla_fw_blobs[FW_ISP2300]; |
andrew.vasquez@qlogic.com | 48c02fd | 2006-03-09 14:27:18 -0800 | [diff] [blame] | 4869 | } else if (IS_QLA2322(ha) || IS_QLA6322(ha)) { |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4870 | blob = &qla_fw_blobs[FW_ISP2322]; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 4871 | } else if (IS_QLA24XX_TYPE(ha)) { |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4872 | blob = &qla_fw_blobs[FW_ISP24XX]; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 4873 | } else if (IS_QLA25XX(ha)) { |
| 4874 | blob = &qla_fw_blobs[FW_ISP25XX]; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 4875 | } else if (IS_QLA81XX(ha)) { |
| 4876 | blob = &qla_fw_blobs[FW_ISP81XX]; |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 4877 | } else if (IS_QLA82XX(ha)) { |
| 4878 | blob = &qla_fw_blobs[FW_ISP82XX]; |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 4879 | } else if (IS_QLA2031(ha)) { |
| 4880 | blob = &qla_fw_blobs[FW_ISP2031]; |
| 4881 | } else if (IS_QLA8031(ha)) { |
| 4882 | blob = &qla_fw_blobs[FW_ISP8031]; |
Dan Carpenter | 8a65522 | 2012-02-21 10:29:40 +0300 | [diff] [blame] | 4883 | } else { |
| 4884 | return NULL; |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4885 | } |
| 4886 | |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 4887 | mutex_lock(&qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4888 | if (blob->fw) |
| 4889 | goto out; |
| 4890 | |
| 4891 | if (request_firmware(&blob->fw, blob->name, &ha->pdev->dev)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4892 | ql_log(ql_log_warn, vha, 0x0063, |
| 4893 | "Failed to load firmware image (%s).\n", blob->name); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4894 | blob->fw = NULL; |
| 4895 | blob = NULL; |
| 4896 | goto out; |
| 4897 | } |
| 4898 | |
| 4899 | out: |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 4900 | mutex_unlock(&qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4901 | return blob; |
| 4902 | } |
| 4903 | |
| 4904 | static void |
| 4905 | qla2x00_release_firmware(void) |
| 4906 | { |
| 4907 | int idx; |
| 4908 | |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 4909 | mutex_lock(&qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4910 | for (idx = 0; idx < FW_BLOBS; idx++) |
Jesper Juhl | cf92549 | 2012-04-09 22:51:41 +0200 | [diff] [blame] | 4911 | release_firmware(qla_fw_blobs[idx].fw); |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 4912 | mutex_unlock(&qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 4913 | } |
| 4914 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 4915 | static pci_ers_result_t |
| 4916 | qla2xxx_pci_error_detected(struct pci_dev *pdev, pci_channel_state_t state) |
| 4917 | { |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 4918 | scsi_qla_host_t *vha = pci_get_drvdata(pdev); |
| 4919 | struct qla_hw_data *ha = vha->hw; |
| 4920 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4921 | ql_dbg(ql_dbg_aer, vha, 0x9000, |
| 4922 | "PCI error detected, state %x.\n", state); |
Seokmann Ju | b9b12f7 | 2009-03-24 09:08:18 -0700 | [diff] [blame] | 4923 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 4924 | switch (state) { |
| 4925 | case pci_channel_io_normal: |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 4926 | ha->flags.eeh_busy = 0; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 4927 | return PCI_ERS_RESULT_CAN_RECOVER; |
| 4928 | case pci_channel_io_frozen: |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 4929 | ha->flags.eeh_busy = 1; |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 4930 | /* For ISP82XX complete any pending mailbox cmd */ |
| 4931 | if (IS_QLA82XX(ha)) { |
Giridhar Malavali | 7190575 | 2011-02-23 15:27:10 -0800 | [diff] [blame] | 4932 | ha->flags.isp82xx_fw_hung = 1; |
Chad Dupuis | c8f6544 | 2011-11-18 09:02:17 -0800 | [diff] [blame] | 4933 | ql_dbg(ql_dbg_aer, vha, 0x9001, "Pci channel io frozen\n"); |
| 4934 | qla82xx_clear_pending_mbx(vha); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 4935 | } |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 4936 | qla2x00_free_irqs(vha); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 4937 | pci_disable_device(pdev); |
Lalit Chandivade | bddd2d6 | 2010-09-03 15:20:53 -0700 | [diff] [blame] | 4938 | /* Return back all IOs */ |
| 4939 | qla2x00_abort_all_cmds(vha, DID_RESET << 16); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 4940 | return PCI_ERS_RESULT_NEED_RESET; |
| 4941 | case pci_channel_io_perm_failure: |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 4942 | ha->flags.pci_channel_io_perm_failure = 1; |
| 4943 | qla2x00_abort_all_cmds(vha, DID_NO_CONNECT << 16); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 4944 | return PCI_ERS_RESULT_DISCONNECT; |
| 4945 | } |
| 4946 | return PCI_ERS_RESULT_NEED_RESET; |
| 4947 | } |
| 4948 | |
| 4949 | static pci_ers_result_t |
| 4950 | qla2xxx_pci_mmio_enabled(struct pci_dev *pdev) |
| 4951 | { |
| 4952 | int risc_paused = 0; |
| 4953 | uint32_t stat; |
| 4954 | unsigned long flags; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4955 | scsi_qla_host_t *base_vha = pci_get_drvdata(pdev); |
| 4956 | struct qla_hw_data *ha = base_vha->hw; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 4957 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
| 4958 | struct device_reg_24xx __iomem *reg24 = &ha->iobase->isp24; |
| 4959 | |
Saurav Kashyap | bcc5b6d | 2010-09-03 15:20:57 -0700 | [diff] [blame] | 4960 | if (IS_QLA82XX(ha)) |
| 4961 | return PCI_ERS_RESULT_RECOVERED; |
| 4962 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 4963 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 4964 | if (IS_QLA2100(ha) || IS_QLA2200(ha)){ |
| 4965 | stat = RD_REG_DWORD(®->hccr); |
| 4966 | if (stat & HCCR_RISC_PAUSE) |
| 4967 | risc_paused = 1; |
| 4968 | } else if (IS_QLA23XX(ha)) { |
| 4969 | stat = RD_REG_DWORD(®->u.isp2300.host_status); |
| 4970 | if (stat & HSR_RISC_PAUSED) |
| 4971 | risc_paused = 1; |
| 4972 | } else if (IS_FWI2_CAPABLE(ha)) { |
| 4973 | stat = RD_REG_DWORD(®24->host_status); |
| 4974 | if (stat & HSRX_RISC_PAUSED) |
| 4975 | risc_paused = 1; |
| 4976 | } |
| 4977 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 4978 | |
| 4979 | if (risc_paused) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4980 | ql_log(ql_log_info, base_vha, 0x9003, |
| 4981 | "RISC paused -- mmio_enabled, Dumping firmware.\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 4982 | ha->isp_ops->fw_dump(base_vha, 0); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 4983 | |
| 4984 | return PCI_ERS_RESULT_NEED_RESET; |
| 4985 | } else |
| 4986 | return PCI_ERS_RESULT_RECOVERED; |
| 4987 | } |
| 4988 | |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 4989 | uint32_t qla82xx_error_recovery(scsi_qla_host_t *base_vha) |
| 4990 | { |
| 4991 | uint32_t rval = QLA_FUNCTION_FAILED; |
| 4992 | uint32_t drv_active = 0; |
| 4993 | struct qla_hw_data *ha = base_vha->hw; |
| 4994 | int fn; |
| 4995 | struct pci_dev *other_pdev = NULL; |
| 4996 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 4997 | ql_dbg(ql_dbg_aer, base_vha, 0x9006, |
| 4998 | "Entered %s.\n", __func__); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 4999 | |
| 5000 | set_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
| 5001 | |
| 5002 | if (base_vha->flags.online) { |
| 5003 | /* Abort all outstanding commands, |
| 5004 | * so as to be requeued later */ |
| 5005 | qla2x00_abort_isp_cleanup(base_vha); |
| 5006 | } |
| 5007 | |
| 5008 | |
| 5009 | fn = PCI_FUNC(ha->pdev->devfn); |
| 5010 | while (fn > 0) { |
| 5011 | fn--; |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5012 | ql_dbg(ql_dbg_aer, base_vha, 0x9007, |
| 5013 | "Finding pci device at function = 0x%x.\n", fn); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5014 | other_pdev = |
| 5015 | pci_get_domain_bus_and_slot(pci_domain_nr(ha->pdev->bus), |
| 5016 | ha->pdev->bus->number, PCI_DEVFN(PCI_SLOT(ha->pdev->devfn), |
| 5017 | fn)); |
| 5018 | |
| 5019 | if (!other_pdev) |
| 5020 | continue; |
| 5021 | if (atomic_read(&other_pdev->enable_cnt)) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5022 | ql_dbg(ql_dbg_aer, base_vha, 0x9008, |
| 5023 | "Found PCI func available and enable at 0x%x.\n", |
| 5024 | fn); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5025 | pci_dev_put(other_pdev); |
| 5026 | break; |
| 5027 | } |
| 5028 | pci_dev_put(other_pdev); |
| 5029 | } |
| 5030 | |
| 5031 | if (!fn) { |
| 5032 | /* Reset owner */ |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5033 | ql_dbg(ql_dbg_aer, base_vha, 0x9009, |
| 5034 | "This devfn is reset owner = 0x%x.\n", |
| 5035 | ha->pdev->devfn); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5036 | qla82xx_idc_lock(ha); |
| 5037 | |
| 5038 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5039 | QLA8XXX_DEV_INITIALIZING); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5040 | |
| 5041 | qla82xx_wr_32(ha, QLA82XX_CRB_DRV_IDC_VERSION, |
| 5042 | QLA82XX_IDC_VERSION); |
| 5043 | |
| 5044 | drv_active = qla82xx_rd_32(ha, QLA82XX_CRB_DRV_ACTIVE); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5045 | ql_dbg(ql_dbg_aer, base_vha, 0x900a, |
| 5046 | "drv_active = 0x%x.\n", drv_active); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5047 | |
| 5048 | qla82xx_idc_unlock(ha); |
| 5049 | /* Reset if device is not already reset |
| 5050 | * drv_active would be 0 if a reset has already been done |
| 5051 | */ |
| 5052 | if (drv_active) |
| 5053 | rval = qla82xx_start_firmware(base_vha); |
| 5054 | else |
| 5055 | rval = QLA_SUCCESS; |
| 5056 | qla82xx_idc_lock(ha); |
| 5057 | |
| 5058 | if (rval != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5059 | ql_log(ql_log_info, base_vha, 0x900b, |
| 5060 | "HW State: FAILED.\n"); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5061 | qla82xx_clear_drv_active(ha); |
| 5062 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5063 | QLA8XXX_DEV_FAILED); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5064 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5065 | ql_log(ql_log_info, base_vha, 0x900c, |
| 5066 | "HW State: READY.\n"); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5067 | qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE, |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5068 | QLA8XXX_DEV_READY); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5069 | qla82xx_idc_unlock(ha); |
Giridhar Malavali | 7190575 | 2011-02-23 15:27:10 -0800 | [diff] [blame] | 5070 | ha->flags.isp82xx_fw_hung = 0; |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5071 | rval = qla82xx_restart_isp(base_vha); |
| 5072 | qla82xx_idc_lock(ha); |
| 5073 | /* Clear driver state register */ |
| 5074 | qla82xx_wr_32(ha, QLA82XX_CRB_DRV_STATE, 0); |
| 5075 | qla82xx_set_drv_active(base_vha); |
| 5076 | } |
| 5077 | qla82xx_idc_unlock(ha); |
| 5078 | } else { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5079 | ql_dbg(ql_dbg_aer, base_vha, 0x900d, |
| 5080 | "This devfn is not reset owner = 0x%x.\n", |
| 5081 | ha->pdev->devfn); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5082 | if ((qla82xx_rd_32(ha, QLA82XX_CRB_DEV_STATE) == |
Santosh Vernekar | 7d613ac | 2012-08-22 14:21:03 -0400 | [diff] [blame] | 5083 | QLA8XXX_DEV_READY)) { |
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 | qla82xx_set_drv_active(base_vha); |
| 5088 | qla82xx_idc_unlock(ha); |
| 5089 | } |
| 5090 | } |
| 5091 | clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
| 5092 | |
| 5093 | return rval; |
| 5094 | } |
| 5095 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5096 | static pci_ers_result_t |
| 5097 | qla2xxx_pci_slot_reset(struct pci_dev *pdev) |
| 5098 | { |
| 5099 | pci_ers_result_t ret = PCI_ERS_RESULT_DISCONNECT; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5100 | scsi_qla_host_t *base_vha = pci_get_drvdata(pdev); |
| 5101 | struct qla_hw_data *ha = base_vha->hw; |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 5102 | struct rsp_que *rsp; |
| 5103 | int rc, retries = 10; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5104 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5105 | ql_dbg(ql_dbg_aer, base_vha, 0x9004, |
| 5106 | "Slot Reset.\n"); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5107 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 5108 | /* Workaround: qla2xxx driver which access hardware earlier |
| 5109 | * needs error state to be pci_channel_io_online. |
| 5110 | * Otherwise mailbox command timesout. |
| 5111 | */ |
| 5112 | pdev->error_state = pci_channel_io_normal; |
| 5113 | |
| 5114 | pci_restore_state(pdev); |
| 5115 | |
Richard Lary | 8c1496b | 2010-02-18 10:07:29 -0800 | [diff] [blame] | 5116 | /* pci_restore_state() clears the saved_state flag of the device |
| 5117 | * save restored state which resets saved_state flag |
| 5118 | */ |
| 5119 | pci_save_state(pdev); |
| 5120 | |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 5121 | if (ha->mem_only) |
| 5122 | rc = pci_enable_device_mem(pdev); |
| 5123 | else |
| 5124 | rc = pci_enable_device(pdev); |
| 5125 | |
| 5126 | if (rc) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5127 | ql_log(ql_log_warn, base_vha, 0x9005, |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5128 | "Can't re-enable PCI device after reset.\n"); |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5129 | goto exit_slot_reset; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5130 | } |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5131 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 5132 | rsp = ha->rsp_q_map[0]; |
| 5133 | if (qla2x00_request_irqs(ha, rsp)) |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5134 | goto exit_slot_reset; |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 5135 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5136 | if (ha->isp_ops->pci_config(base_vha)) |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5137 | goto exit_slot_reset; |
| 5138 | |
| 5139 | if (IS_QLA82XX(ha)) { |
| 5140 | if (qla82xx_error_recovery(base_vha) == QLA_SUCCESS) { |
| 5141 | ret = PCI_ERS_RESULT_RECOVERED; |
| 5142 | goto exit_slot_reset; |
| 5143 | } else |
| 5144 | goto exit_slot_reset; |
| 5145 | } |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5146 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 5147 | while (ha->flags.mbox_busy && retries--) |
| 5148 | msleep(1000); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5149 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5150 | set_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5151 | if (ha->isp_ops->abort_isp(base_vha) == QLA_SUCCESS) |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5152 | ret = PCI_ERS_RESULT_RECOVERED; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5153 | clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5154 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 5155 | |
Lalit Chandivade | a5b3632 | 2010-09-03 15:20:50 -0700 | [diff] [blame] | 5156 | exit_slot_reset: |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5157 | ql_dbg(ql_dbg_aer, base_vha, 0x900e, |
| 5158 | "slot_reset return %x.\n", ret); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5159 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5160 | return ret; |
| 5161 | } |
| 5162 | |
| 5163 | static void |
| 5164 | qla2xxx_pci_resume(struct pci_dev *pdev) |
| 5165 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5166 | scsi_qla_host_t *base_vha = pci_get_drvdata(pdev); |
| 5167 | struct qla_hw_data *ha = base_vha->hw; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5168 | int ret; |
| 5169 | |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5170 | ql_dbg(ql_dbg_aer, base_vha, 0x900f, |
| 5171 | "pci_resume.\n"); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5172 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 5173 | ret = qla2x00_wait_for_hba_online(base_vha); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5174 | if (ret != QLA_SUCCESS) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5175 | ql_log(ql_log_fatal, base_vha, 0x9002, |
| 5176 | "The device failed to resume I/O from slot/link_reset.\n"); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5177 | } |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5178 | |
Lalit Chandivade | 3e46f03 | 2010-05-04 15:01:23 -0700 | [diff] [blame] | 5179 | pci_cleanup_aer_uncorrect_error_status(pdev); |
| 5180 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 5181 | ha->flags.eeh_busy = 0; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5182 | } |
| 5183 | |
Stephen Hemminger | a55b2d2 | 2012-09-07 09:33:16 -0700 | [diff] [blame] | 5184 | static const struct pci_error_handlers qla2xxx_err_handler = { |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5185 | .error_detected = qla2xxx_pci_error_detected, |
| 5186 | .mmio_enabled = qla2xxx_pci_mmio_enabled, |
| 5187 | .slot_reset = qla2xxx_pci_slot_reset, |
| 5188 | .resume = qla2xxx_pci_resume, |
| 5189 | }; |
| 5190 | |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5191 | static struct pci_device_id qla2xxx_pci_tbl[] = { |
Andrew Vasquez | 47f5e06 | 2006-05-17 15:09:39 -0700 | [diff] [blame] | 5192 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2100) }, |
| 5193 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2200) }, |
| 5194 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2300) }, |
| 5195 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2312) }, |
| 5196 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2322) }, |
| 5197 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP6312) }, |
| 5198 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP6322) }, |
| 5199 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2422) }, |
| 5200 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2432) }, |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 5201 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8432) }, |
Andrew Vasquez | 47f5e06 | 2006-05-17 15:09:39 -0700 | [diff] [blame] | 5202 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP5422) }, |
| 5203 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP5432) }, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 5204 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2532) }, |
Giridhar Malavali | 6246b8a | 2012-02-09 11:15:34 -0800 | [diff] [blame] | 5205 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2031) }, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 5206 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8001) }, |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5207 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8021) }, |
Chad Dupuis | 650f528 | 2012-08-22 14:20:55 -0400 | [diff] [blame] | 5208 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8031) }, |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5209 | { 0 }, |
| 5210 | }; |
| 5211 | MODULE_DEVICE_TABLE(pci, qla2xxx_pci_tbl); |
| 5212 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 5213 | static struct pci_driver qla2xxx_pci_driver = { |
Andrew Vasquez | cb63067 | 2006-05-17 15:09:45 -0700 | [diff] [blame] | 5214 | .name = QLA2XXX_DRIVER_NAME, |
James Bottomley | 0a21ef1 | 2005-12-01 12:51:50 -0600 | [diff] [blame] | 5215 | .driver = { |
| 5216 | .owner = THIS_MODULE, |
| 5217 | }, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 5218 | .id_table = qla2xxx_pci_tbl, |
Andrew Vasquez | 7ee6139 | 2006-06-23 16:11:22 -0700 | [diff] [blame] | 5219 | .probe = qla2x00_probe_one, |
Adrian Bunk | 4c993f7 | 2008-01-14 00:55:16 -0800 | [diff] [blame] | 5220 | .remove = qla2x00_remove_one, |
Madhuranath Iyengar | e30d175 | 2010-10-15 11:27:46 -0700 | [diff] [blame] | 5221 | .shutdown = qla2x00_shutdown, |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 5222 | .err_handler = &qla2xxx_err_handler, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 5223 | }; |
| 5224 | |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 5225 | static struct file_operations apidev_fops = { |
| 5226 | .owner = THIS_MODULE, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 5227 | .llseek = noop_llseek, |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 5228 | }; |
| 5229 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5230 | /** |
| 5231 | * qla2x00_module_init - Module initialization. |
| 5232 | **/ |
| 5233 | static int __init |
| 5234 | qla2x00_module_init(void) |
| 5235 | { |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 5236 | int ret = 0; |
| 5237 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5238 | /* Allocate cache for SRBs. */ |
Andrew Vasquez | 354d6b2 | 2005-04-23 02:47:27 -0400 | [diff] [blame] | 5239 | srb_cachep = kmem_cache_create("qla2xxx_srbs", sizeof(srb_t), 0, |
Paul Mundt | 20c2df8 | 2007-07-20 10:11:58 +0900 | [diff] [blame] | 5240 | SLAB_HWCACHE_ALIGN, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5241 | if (srb_cachep == NULL) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5242 | ql_log(ql_log_fatal, NULL, 0x0001, |
| 5243 | "Unable to allocate SRB cache...Failing load!.\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5244 | return -ENOMEM; |
| 5245 | } |
| 5246 | |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 5247 | /* Initialize target kmem_cache and mem_pools */ |
| 5248 | ret = qlt_init(); |
| 5249 | if (ret < 0) { |
| 5250 | kmem_cache_destroy(srb_cachep); |
| 5251 | return ret; |
| 5252 | } else if (ret > 0) { |
| 5253 | /* |
| 5254 | * If initiator mode is explictly disabled by qlt_init(), |
| 5255 | * prevent scsi_transport_fc.c:fc_scsi_scan_rport() from |
| 5256 | * performing scsi_scan_target() during LOOP UP event. |
| 5257 | */ |
| 5258 | qla2xxx_transport_functions.disable_target_scan = 1; |
| 5259 | qla2xxx_transport_vport_functions.disable_target_scan = 1; |
| 5260 | } |
| 5261 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5262 | /* Derive version string. */ |
| 5263 | strcpy(qla2x00_version_str, QLA2XXX_VERSION); |
Andrew Vasquez | 11010fe | 2006-10-06 09:54:59 -0700 | [diff] [blame] | 5264 | if (ql2xextended_error_logging) |
Andrew Vasquez | 0181944 | 2006-06-23 16:11:10 -0700 | [diff] [blame] | 5265 | strcat(qla2x00_version_str, "-debug"); |
| 5266 | |
Andrew Vasquez | 1c97a12 | 2005-04-21 16:13:36 -0400 | [diff] [blame] | 5267 | qla2xxx_transport_template = |
| 5268 | fc_attach_transport(&qla2xxx_transport_functions); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5269 | if (!qla2xxx_transport_template) { |
| 5270 | kmem_cache_destroy(srb_cachep); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5271 | ql_log(ql_log_fatal, NULL, 0x0002, |
| 5272 | "fc_attach_transport failed...Failing load!.\n"); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 5273 | qlt_exit(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5274 | return -ENODEV; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5275 | } |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 5276 | |
| 5277 | apidev_major = register_chrdev(0, QLA2XXX_APIDEV, &apidev_fops); |
| 5278 | if (apidev_major < 0) { |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5279 | ql_log(ql_log_fatal, NULL, 0x0003, |
| 5280 | "Unable to register char device %s.\n", QLA2XXX_APIDEV); |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 5281 | } |
| 5282 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5283 | qla2xxx_transport_vport_template = |
| 5284 | fc_attach_transport(&qla2xxx_transport_vport_functions); |
| 5285 | if (!qla2xxx_transport_vport_template) { |
| 5286 | kmem_cache_destroy(srb_cachep); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 5287 | qlt_exit(); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5288 | fc_release_transport(qla2xxx_transport_template); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5289 | ql_log(ql_log_fatal, NULL, 0x0004, |
| 5290 | "fc_attach_transport vport failed...Failing load!.\n"); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5291 | return -ENODEV; |
| 5292 | } |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5293 | ql_log(ql_log_info, NULL, 0x0005, |
| 5294 | "QLogic Fibre Channel HBA Driver: %s.\n", |
Andrew Vasquez | fd9a29f0 | 2008-05-12 22:21:08 -0700 | [diff] [blame] | 5295 | qla2x00_version_str); |
Andrew Vasquez | 7ee6139 | 2006-06-23 16:11:22 -0700 | [diff] [blame] | 5296 | ret = pci_register_driver(&qla2xxx_pci_driver); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 5297 | if (ret) { |
| 5298 | kmem_cache_destroy(srb_cachep); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 5299 | qlt_exit(); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 5300 | fc_release_transport(qla2xxx_transport_template); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5301 | fc_release_transport(qla2xxx_transport_vport_template); |
Saurav Kashyap | 7c3df13 | 2011-07-14 12:00:13 -0700 | [diff] [blame] | 5302 | ql_log(ql_log_fatal, NULL, 0x0006, |
| 5303 | "pci_register_driver failed...ret=%d Failing load!.\n", |
| 5304 | ret); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 5305 | } |
| 5306 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5307 | } |
| 5308 | |
| 5309 | /** |
| 5310 | * qla2x00_module_exit - Module cleanup. |
| 5311 | **/ |
| 5312 | static void __exit |
| 5313 | qla2x00_module_exit(void) |
| 5314 | { |
Harish Zunjarrao | 6a03b4c | 2010-05-04 15:01:24 -0700 | [diff] [blame] | 5315 | unregister_chrdev(apidev_major, QLA2XXX_APIDEV); |
Andrew Vasquez | 7ee6139 | 2006-06-23 16:11:22 -0700 | [diff] [blame] | 5316 | pci_unregister_driver(&qla2xxx_pci_driver); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 5317 | qla2x00_release_firmware(); |
Andrew Vasquez | 354d6b2 | 2005-04-23 02:47:27 -0400 | [diff] [blame] | 5318 | kmem_cache_destroy(srb_cachep); |
Nicholas Bellinger | 2d70c10 | 2012-05-15 14:34:28 -0400 | [diff] [blame] | 5319 | qlt_exit(); |
Giridhar Malavali | a908301 | 2010-04-12 17:59:55 -0700 | [diff] [blame] | 5320 | if (ctx_cachep) |
| 5321 | kmem_cache_destroy(ctx_cachep); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5322 | fc_release_transport(qla2xxx_transport_template); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 5323 | fc_release_transport(qla2xxx_transport_vport_template); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5324 | } |
| 5325 | |
| 5326 | module_init(qla2x00_module_init); |
| 5327 | module_exit(qla2x00_module_exit); |
| 5328 | |
| 5329 | MODULE_AUTHOR("QLogic Corporation"); |
| 5330 | MODULE_DESCRIPTION("QLogic Fibre Channel HBA Driver"); |
| 5331 | MODULE_LICENSE("GPL"); |
| 5332 | MODULE_VERSION(QLA2XXX_VERSION); |
Andrew Vasquez | bb8ee49 | 2006-10-02 12:00:48 -0700 | [diff] [blame] | 5333 | MODULE_FIRMWARE(FW_FILE_ISP21XX); |
| 5334 | MODULE_FIRMWARE(FW_FILE_ISP22XX); |
| 5335 | MODULE_FIRMWARE(FW_FILE_ISP2300); |
| 5336 | MODULE_FIRMWARE(FW_FILE_ISP2322); |
| 5337 | MODULE_FIRMWARE(FW_FILE_ISP24XX); |
Andrew Vasquez | 61623fc | 2008-01-31 12:33:45 -0800 | [diff] [blame] | 5338 | MODULE_FIRMWARE(FW_FILE_ISP25XX); |