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 |
Andrew Vasquez | 01e58d8 | 2008-04-03 13:13:13 -0700 | [diff] [blame] | 3 | * Copyright (c) 2003-2008 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 | |
| 17 | #include <scsi/scsi_tcq.h> |
| 18 | #include <scsi/scsicam.h> |
| 19 | #include <scsi/scsi_transport.h> |
| 20 | #include <scsi/scsi_transport_fc.h> |
| 21 | |
| 22 | /* |
| 23 | * Driver version |
| 24 | */ |
| 25 | char qla2x00_version_str[40]; |
| 26 | |
| 27 | /* |
| 28 | * SRB allocation cache |
| 29 | */ |
Christoph Lameter | e18b890 | 2006-12-06 20:33:20 -0800 | [diff] [blame] | 30 | static struct kmem_cache *srb_cachep; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 31 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | int ql2xlogintimeout = 20; |
| 33 | module_param(ql2xlogintimeout, int, S_IRUGO|S_IRUSR); |
| 34 | MODULE_PARM_DESC(ql2xlogintimeout, |
| 35 | "Login timeout value in seconds."); |
| 36 | |
Andrew Vasquez | a7b6184 | 2007-05-07 07:42:59 -0700 | [diff] [blame] | 37 | int qlport_down_retry; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | module_param(qlport_down_retry, int, S_IRUGO|S_IRUSR); |
| 39 | MODULE_PARM_DESC(qlport_down_retry, |
Jesper Juhl | 900d9f9 | 2006-06-30 02:33:07 -0700 | [diff] [blame] | 40 | "Maximum number of command retries to a port that returns " |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | "a PORT-DOWN status."); |
| 42 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 43 | int ql2xplogiabsentdevice; |
| 44 | module_param(ql2xplogiabsentdevice, int, S_IRUGO|S_IWUSR); |
| 45 | MODULE_PARM_DESC(ql2xplogiabsentdevice, |
| 46 | "Option to enable PLOGI to devices that are not present after " |
Jesper Juhl | 900d9f9 | 2006-06-30 02:33:07 -0700 | [diff] [blame] | 47 | "a Fabric scan. This is needed for several broken switches. " |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | "Default is 0 - no PLOGI. 1 - perfom PLOGI."); |
| 49 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 50 | int ql2xloginretrycount = 0; |
| 51 | module_param(ql2xloginretrycount, int, S_IRUGO|S_IRUSR); |
| 52 | MODULE_PARM_DESC(ql2xloginretrycount, |
| 53 | "Specify an alternate value for the NVRAM login retry count."); |
| 54 | |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 55 | int ql2xallocfwdump = 1; |
| 56 | module_param(ql2xallocfwdump, int, S_IRUGO|S_IRUSR); |
| 57 | MODULE_PARM_DESC(ql2xallocfwdump, |
| 58 | "Option to enable allocation of memory for a firmware dump " |
| 59 | "during HBA initialization. Memory allocation requirements " |
| 60 | "vary by ISP type. Default is 1 - allocate memory."); |
| 61 | |
Andrew Vasquez | 11010fe | 2006-10-06 09:54:59 -0700 | [diff] [blame] | 62 | int ql2xextended_error_logging; |
Andrew Vasquez | 27d9403 | 2007-03-12 10:41:30 -0700 | [diff] [blame] | 63 | module_param(ql2xextended_error_logging, int, S_IRUGO|S_IWUSR); |
Andrew Vasquez | 11010fe | 2006-10-06 09:54:59 -0700 | [diff] [blame] | 64 | MODULE_PARM_DESC(ql2xextended_error_logging, |
Andrew Vasquez | 0181944 | 2006-06-23 16:11:10 -0700 | [diff] [blame] | 65 | "Option to enable extended error logging, " |
| 66 | "Default is 0 - no logging. 1 - log errors."); |
| 67 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | static void qla2x00_free_device(scsi_qla_host_t *); |
| 69 | |
Andrew Vasquez | 7e47e5c | 2008-04-24 15:21:26 -0700 | [diff] [blame] | 70 | int ql2xfdmienable=1; |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 71 | module_param(ql2xfdmienable, int, S_IRUGO|S_IRUSR); |
| 72 | MODULE_PARM_DESC(ql2xfdmienable, |
Ferenc Wagner | 7794a5a | 2010-03-23 18:14:59 +0100 | [diff] [blame^] | 73 | "Enables FDMI registrations. " |
| 74 | "0 - no FDMI. Default is 1 - perform FDMI."); |
Andrew Vasquez | cca5335 | 2005-08-26 19:08:30 -0700 | [diff] [blame] | 75 | |
Andrew Vasquez | df7baa5 | 2006-10-13 09:33:39 -0700 | [diff] [blame] | 76 | #define MAX_Q_DEPTH 32 |
| 77 | static int ql2xmaxqdepth = MAX_Q_DEPTH; |
| 78 | module_param(ql2xmaxqdepth, int, S_IRUGO|S_IWUSR); |
| 79 | MODULE_PARM_DESC(ql2xmaxqdepth, |
| 80 | "Maximum queue depth to report for target devices."); |
| 81 | |
Andrew Vasquez | e5896bd | 2008-07-10 16:55:52 -0700 | [diff] [blame] | 82 | int ql2xiidmaenable=1; |
| 83 | module_param(ql2xiidmaenable, int, S_IRUGO|S_IRUSR); |
| 84 | MODULE_PARM_DESC(ql2xiidmaenable, |
| 85 | "Enables iIDMA settings " |
| 86 | "Default is 1 - perform iIDMA. 0 - no iIDMA."); |
| 87 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 88 | int ql2xmaxqueues = 1; |
| 89 | module_param(ql2xmaxqueues, int, S_IRUGO|S_IRUSR); |
| 90 | MODULE_PARM_DESC(ql2xmaxqueues, |
| 91 | "Enables MQ settings " |
| 92 | "Default is 1 for single queue. Set it to number \ |
| 93 | of queues in MQ mode."); |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 94 | |
| 95 | int ql2xmultique_tag; |
| 96 | module_param(ql2xmultique_tag, int, S_IRUGO|S_IRUSR); |
| 97 | MODULE_PARM_DESC(ql2xmultique_tag, |
| 98 | "Enables CPU affinity settings for the driver " |
| 99 | "Default is 0 for no affinity of request and response IO. " |
| 100 | "Set it to 1 to turn on the cpu affinity."); |
Andrew Vasquez | e337d90 | 2009-04-06 22:33:49 -0700 | [diff] [blame] | 101 | |
| 102 | int ql2xfwloadbin; |
| 103 | module_param(ql2xfwloadbin, int, S_IRUGO|S_IRUSR); |
| 104 | MODULE_PARM_DESC(ql2xfwloadbin, |
| 105 | "Option to specify location from which to load ISP firmware:\n" |
| 106 | " 2 -- load firmware via the request_firmware() (hotplug)\n" |
| 107 | " interface.\n" |
| 108 | " 1 -- load firmware from flash.\n" |
| 109 | " 0 -- use default semantics.\n"); |
| 110 | |
Andrew Vasquez | ae97c91 | 2010-02-18 10:07:28 -0800 | [diff] [blame] | 111 | int ql2xetsenable; |
| 112 | module_param(ql2xetsenable, int, S_IRUGO|S_IRUSR); |
| 113 | MODULE_PARM_DESC(ql2xetsenable, |
| 114 | "Enables firmware ETS burst." |
| 115 | "Default is 0 - skip ETS enablement."); |
| 116 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | /* |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 118 | * SCSI host template entry points |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 119 | */ |
| 120 | static int qla2xxx_slave_configure(struct scsi_device * device); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 121 | static int qla2xxx_slave_alloc(struct scsi_device *); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 122 | static int qla2xxx_scan_finished(struct Scsi_Host *, unsigned long time); |
| 123 | static void qla2xxx_scan_start(struct Scsi_Host *); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 124 | static void qla2xxx_slave_destroy(struct scsi_device *); |
Giridhar Malavali | a5326f8 | 2009-03-24 09:07:56 -0700 | [diff] [blame] | 125 | static int qla2xxx_queuecommand(struct scsi_cmnd *cmd, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 126 | void (*fn)(struct scsi_cmnd *)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 127 | static int qla2xxx_eh_abort(struct scsi_cmnd *); |
| 128 | static int qla2xxx_eh_device_reset(struct scsi_cmnd *); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 129 | static int qla2xxx_eh_target_reset(struct scsi_cmnd *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 130 | static int qla2xxx_eh_bus_reset(struct scsi_cmnd *); |
| 131 | static int qla2xxx_eh_host_reset(struct scsi_cmnd *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | |
Mike Christie | e881a17 | 2009-10-15 17:46:39 -0700 | [diff] [blame] | 133 | static int qla2x00_change_queue_depth(struct scsi_device *, int, int); |
Andrew Vasquez | ce7e4af | 2005-08-26 19:09:30 -0700 | [diff] [blame] | 134 | static int qla2x00_change_queue_type(struct scsi_device *, int); |
| 135 | |
Giridhar Malavali | a5326f8 | 2009-03-24 09:07:56 -0700 | [diff] [blame] | 136 | struct scsi_host_template qla2xxx_driver_template = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | .module = THIS_MODULE, |
Andrew Vasquez | cb63067 | 2006-05-17 15:09:45 -0700 | [diff] [blame] | 138 | .name = QLA2XXX_DRIVER_NAME, |
Giridhar Malavali | a5326f8 | 2009-03-24 09:07:56 -0700 | [diff] [blame] | 139 | .queuecommand = qla2xxx_queuecommand, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 140 | |
| 141 | .eh_abort_handler = qla2xxx_eh_abort, |
| 142 | .eh_device_reset_handler = qla2xxx_eh_device_reset, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 143 | .eh_target_reset_handler = qla2xxx_eh_target_reset, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 144 | .eh_bus_reset_handler = qla2xxx_eh_bus_reset, |
| 145 | .eh_host_reset_handler = qla2xxx_eh_host_reset, |
| 146 | |
| 147 | .slave_configure = qla2xxx_slave_configure, |
| 148 | |
| 149 | .slave_alloc = qla2xxx_slave_alloc, |
| 150 | .slave_destroy = qla2xxx_slave_destroy, |
Andrew Vasquez | ed67708 | 2007-03-12 10:41:27 -0700 | [diff] [blame] | 151 | .scan_finished = qla2xxx_scan_finished, |
| 152 | .scan_start = qla2xxx_scan_start, |
Andrew Vasquez | ce7e4af | 2005-08-26 19:09:30 -0700 | [diff] [blame] | 153 | .change_queue_depth = qla2x00_change_queue_depth, |
| 154 | .change_queue_type = qla2x00_change_queue_type, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 155 | .this_id = -1, |
| 156 | .cmd_per_lun = 3, |
| 157 | .use_clustering = ENABLE_CLUSTERING, |
| 158 | .sg_tablesize = SG_ALL, |
| 159 | |
| 160 | .max_sectors = 0xFFFF, |
Andrew Vasquez | afb046e | 2005-08-26 19:09:40 -0700 | [diff] [blame] | 161 | .shost_attrs = qla2x00_host_attrs, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 162 | }; |
| 163 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 164 | static struct scsi_transport_template *qla2xxx_transport_template = NULL; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 165 | struct scsi_transport_template *qla2xxx_transport_vport_template = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 166 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 167 | /* TODO Convert to inlines |
| 168 | * |
| 169 | * Timer routines |
| 170 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 171 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 172 | __inline__ void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 173 | 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] | 174 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 175 | init_timer(&vha->timer); |
| 176 | vha->timer.expires = jiffies + interval * HZ; |
| 177 | vha->timer.data = (unsigned long)vha; |
| 178 | vha->timer.function = (void (*)(unsigned long))func; |
| 179 | add_timer(&vha->timer); |
| 180 | vha->timer_active = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 181 | } |
| 182 | |
| 183 | static inline void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 184 | qla2x00_restart_timer(scsi_qla_host_t *vha, unsigned long interval) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 185 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 186 | mod_timer(&vha->timer, jiffies + interval * HZ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 187 | } |
| 188 | |
Adrian Bunk | a824ebb | 2008-01-17 09:02:15 -0800 | [diff] [blame] | 189 | static __inline__ void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 190 | qla2x00_stop_timer(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 191 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 192 | del_timer_sync(&vha->timer); |
| 193 | vha->timer_active = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 194 | } |
| 195 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 196 | static int qla2x00_do_dpc(void *data); |
| 197 | |
| 198 | static void qla2x00_rst_aen(scsi_qla_host_t *); |
| 199 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 200 | static int qla2x00_mem_alloc(struct qla_hw_data *, uint16_t, uint16_t, |
| 201 | struct req_que **, struct rsp_que **); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 202 | static void qla2x00_mem_free(struct qla_hw_data *); |
| 203 | static void qla2x00_sp_free_dma(srb_t *); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 204 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 205 | /* -------------------------------------------------------------------------- */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 206 | static int qla2x00_alloc_queues(struct qla_hw_data *ha) |
| 207 | { |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 208 | 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] | 209 | GFP_KERNEL); |
| 210 | if (!ha->req_q_map) { |
| 211 | qla_printk(KERN_WARNING, ha, |
| 212 | "Unable to allocate memory for request queue ptrs\n"); |
| 213 | goto fail_req_map; |
| 214 | } |
| 215 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 216 | 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] | 217 | GFP_KERNEL); |
| 218 | if (!ha->rsp_q_map) { |
| 219 | qla_printk(KERN_WARNING, ha, |
| 220 | "Unable to allocate memory for response queue ptrs\n"); |
| 221 | goto fail_rsp_map; |
| 222 | } |
| 223 | set_bit(0, ha->rsp_qid_map); |
| 224 | set_bit(0, ha->req_qid_map); |
| 225 | return 1; |
| 226 | |
| 227 | fail_rsp_map: |
| 228 | kfree(ha->req_q_map); |
| 229 | ha->req_q_map = NULL; |
| 230 | fail_req_map: |
| 231 | return -ENOMEM; |
| 232 | } |
| 233 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 234 | 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] | 235 | { |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 236 | if (req && req->ring) |
| 237 | dma_free_coherent(&ha->pdev->dev, |
| 238 | (req->length + 1) * sizeof(request_t), |
| 239 | req->ring, req->dma); |
| 240 | |
| 241 | kfree(req); |
| 242 | req = NULL; |
| 243 | } |
| 244 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 245 | static void qla2x00_free_rsp_que(struct qla_hw_data *ha, struct rsp_que *rsp) |
| 246 | { |
| 247 | if (rsp && rsp->ring) |
| 248 | dma_free_coherent(&ha->pdev->dev, |
| 249 | (rsp->length + 1) * sizeof(response_t), |
| 250 | rsp->ring, rsp->dma); |
| 251 | |
| 252 | kfree(rsp); |
| 253 | rsp = NULL; |
| 254 | } |
| 255 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 256 | static void qla2x00_free_queues(struct qla_hw_data *ha) |
| 257 | { |
| 258 | struct req_que *req; |
| 259 | struct rsp_que *rsp; |
| 260 | int cnt; |
| 261 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 262 | for (cnt = 0; cnt < ha->max_req_queues; cnt++) { |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 263 | req = ha->req_q_map[cnt]; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 264 | qla2x00_free_req_que(ha, req); |
| 265 | } |
| 266 | kfree(ha->req_q_map); |
| 267 | ha->req_q_map = NULL; |
| 268 | |
| 269 | for (cnt = 0; cnt < ha->max_rsp_queues; cnt++) { |
| 270 | rsp = ha->rsp_q_map[cnt]; |
| 271 | qla2x00_free_rsp_que(ha, rsp); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 272 | } |
| 273 | kfree(ha->rsp_q_map); |
| 274 | ha->rsp_q_map = NULL; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 275 | } |
| 276 | |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 277 | static int qla25xx_setup_mode(struct scsi_qla_host *vha) |
| 278 | { |
| 279 | uint16_t options = 0; |
| 280 | int ques, req, ret; |
| 281 | struct qla_hw_data *ha = vha->hw; |
| 282 | |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 283 | if (!(ha->fw_attributes & BIT_6)) { |
| 284 | qla_printk(KERN_INFO, ha, |
| 285 | "Firmware is not multi-queue capable\n"); |
| 286 | goto fail; |
| 287 | } |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 288 | if (ql2xmultique_tag) { |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 289 | /* create a request queue for IO */ |
| 290 | options |= BIT_7; |
| 291 | req = qla25xx_create_req_que(ha, options, 0, 0, -1, |
| 292 | QLA_DEFAULT_QUE_QOS); |
| 293 | if (!req) { |
| 294 | qla_printk(KERN_WARNING, ha, |
| 295 | "Can't create request queue\n"); |
| 296 | goto fail; |
| 297 | } |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 298 | ha->wq = create_workqueue("qla2xxx_wq"); |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 299 | vha->req = ha->req_q_map[req]; |
| 300 | options |= BIT_1; |
| 301 | for (ques = 1; ques < ha->max_rsp_queues; ques++) { |
| 302 | ret = qla25xx_create_rsp_que(ha, options, 0, 0, req); |
| 303 | if (!ret) { |
| 304 | qla_printk(KERN_WARNING, ha, |
| 305 | "Response Queue create failed\n"); |
| 306 | goto fail2; |
| 307 | } |
| 308 | } |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 309 | ha->flags.cpu_affinity_enabled = 1; |
| 310 | |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 311 | DEBUG2(qla_printk(KERN_INFO, ha, |
| 312 | "CPU affinity mode enabled, no. of response" |
| 313 | " queues:%d, no. of request queues:%d\n", |
| 314 | ha->max_rsp_queues, ha->max_req_queues)); |
| 315 | } |
| 316 | return 0; |
| 317 | fail2: |
| 318 | qla25xx_delete_queues(vha); |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 319 | destroy_workqueue(ha->wq); |
| 320 | ha->wq = NULL; |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 321 | fail: |
| 322 | ha->mqenable = 0; |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 323 | kfree(ha->req_q_map); |
| 324 | kfree(ha->rsp_q_map); |
| 325 | ha->max_req_queues = ha->max_rsp_queues = 1; |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 326 | return 1; |
| 327 | } |
| 328 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 329 | static char * |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 330 | qla2x00_pci_info_str(struct scsi_qla_host *vha, char *str) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 331 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 332 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 333 | static char *pci_bus_modes[] = { |
| 334 | "33", "66", "100", "133", |
| 335 | }; |
| 336 | uint16_t pci_bus; |
| 337 | |
| 338 | strcpy(str, "PCI"); |
| 339 | pci_bus = (ha->pci_attr & (BIT_9 | BIT_10)) >> 9; |
| 340 | if (pci_bus) { |
| 341 | strcat(str, "-X ("); |
| 342 | strcat(str, pci_bus_modes[pci_bus]); |
| 343 | } else { |
| 344 | pci_bus = (ha->pci_attr & BIT_8) >> 8; |
| 345 | strcat(str, " ("); |
| 346 | strcat(str, pci_bus_modes[pci_bus]); |
| 347 | } |
| 348 | strcat(str, " MHz)"); |
| 349 | |
| 350 | return (str); |
| 351 | } |
| 352 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 353 | static char * |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 354 | qla24xx_pci_info_str(struct scsi_qla_host *vha, char *str) |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 355 | { |
| 356 | static char *pci_bus_modes[] = { "33", "66", "100", "133", }; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 357 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 358 | uint32_t pci_bus; |
| 359 | int pcie_reg; |
| 360 | |
| 361 | pcie_reg = pci_find_capability(ha->pdev, PCI_CAP_ID_EXP); |
| 362 | if (pcie_reg) { |
| 363 | char lwstr[6]; |
| 364 | uint16_t pcie_lstat, lspeed, lwidth; |
| 365 | |
| 366 | pcie_reg += 0x12; |
| 367 | pci_read_config_word(ha->pdev, pcie_reg, &pcie_lstat); |
| 368 | lspeed = pcie_lstat & (BIT_0 | BIT_1 | BIT_2 | BIT_3); |
| 369 | lwidth = (pcie_lstat & |
| 370 | (BIT_4 | BIT_5 | BIT_6 | BIT_7 | BIT_8 | BIT_9)) >> 4; |
| 371 | |
| 372 | strcpy(str, "PCIe ("); |
| 373 | if (lspeed == 1) |
Andrew Vasquez | c87a0d8 | 2008-04-03 13:13:21 -0700 | [diff] [blame] | 374 | strcat(str, "2.5GT/s "); |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 375 | else if (lspeed == 2) |
Andrew Vasquez | c87a0d8 | 2008-04-03 13:13:21 -0700 | [diff] [blame] | 376 | strcat(str, "5.0GT/s "); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 377 | else |
| 378 | strcat(str, "<unknown> "); |
| 379 | snprintf(lwstr, sizeof(lwstr), "x%d)", lwidth); |
| 380 | strcat(str, lwstr); |
| 381 | |
| 382 | return str; |
| 383 | } |
| 384 | |
| 385 | strcpy(str, "PCI"); |
| 386 | pci_bus = (ha->pci_attr & CSRX_PCIX_BUS_MODE_MASK) >> 8; |
| 387 | if (pci_bus == 0 || pci_bus == 8) { |
| 388 | strcat(str, " ("); |
| 389 | strcat(str, pci_bus_modes[pci_bus >> 3]); |
| 390 | } else { |
| 391 | strcat(str, "-X "); |
| 392 | if (pci_bus & BIT_2) |
| 393 | strcat(str, "Mode 2"); |
| 394 | else |
| 395 | strcat(str, "Mode 1"); |
| 396 | strcat(str, " ("); |
| 397 | strcat(str, pci_bus_modes[pci_bus & ~BIT_2]); |
| 398 | } |
| 399 | strcat(str, " MHz)"); |
| 400 | |
| 401 | return str; |
| 402 | } |
| 403 | |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 404 | static char * |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 405 | qla2x00_fw_version_str(struct scsi_qla_host *vha, char *str) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 406 | { |
| 407 | char un_str[10]; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 408 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 409 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 410 | sprintf(str, "%d.%02d.%02d ", ha->fw_major_version, |
| 411 | ha->fw_minor_version, |
| 412 | ha->fw_subminor_version); |
| 413 | |
| 414 | if (ha->fw_attributes & BIT_9) { |
| 415 | strcat(str, "FLX"); |
| 416 | return (str); |
| 417 | } |
| 418 | |
| 419 | switch (ha->fw_attributes & 0xFF) { |
| 420 | case 0x7: |
| 421 | strcat(str, "EF"); |
| 422 | break; |
| 423 | case 0x17: |
| 424 | strcat(str, "TP"); |
| 425 | break; |
| 426 | case 0x37: |
| 427 | strcat(str, "IP"); |
| 428 | break; |
| 429 | case 0x77: |
| 430 | strcat(str, "VI"); |
| 431 | break; |
| 432 | default: |
| 433 | sprintf(un_str, "(%x)", ha->fw_attributes); |
| 434 | strcat(str, un_str); |
| 435 | break; |
| 436 | } |
| 437 | if (ha->fw_attributes & 0x100) |
| 438 | strcat(str, "X"); |
| 439 | |
| 440 | return (str); |
| 441 | } |
| 442 | |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 443 | static char * |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 444 | qla24xx_fw_version_str(struct scsi_qla_host *vha, char *str) |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 445 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 446 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | f0883ac | 2005-07-08 17:58:43 -0700 | [diff] [blame] | 447 | |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 448 | sprintf(str, "%d.%02d.%02d (%x)", ha->fw_major_version, |
| 449 | ha->fw_minor_version, ha->fw_subminor_version, ha->fw_attributes); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 450 | return str; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 451 | } |
| 452 | |
| 453 | static inline srb_t * |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 454 | qla2x00_get_new_sp(scsi_qla_host_t *vha, fc_port_t *fcport, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 455 | struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)) |
| 456 | { |
| 457 | srb_t *sp; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 458 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 459 | |
| 460 | sp = mempool_alloc(ha->srb_mempool, GFP_ATOMIC); |
| 461 | if (!sp) |
| 462 | return sp; |
| 463 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 464 | sp->fcport = fcport; |
| 465 | sp->cmd = cmd; |
| 466 | sp->flags = 0; |
| 467 | CMD_SP(cmd) = (void *)sp; |
| 468 | cmd->scsi_done = done; |
Andrew Vasquez | cf53b06 | 2009-08-20 11:06:04 -0700 | [diff] [blame] | 469 | sp->ctx = NULL; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 470 | |
| 471 | return sp; |
| 472 | } |
| 473 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 474 | static int |
Giridhar Malavali | a5326f8 | 2009-03-24 09:07:56 -0700 | [diff] [blame] | 475 | qla2xxx_queuecommand(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *)) |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 476 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 477 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 478 | fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 479 | struct fc_rport *rport = starget_to_rport(scsi_target(cmd->device)); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 480 | struct qla_hw_data *ha = vha->hw; |
| 481 | struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 482 | srb_t *sp; |
| 483 | int rval; |
| 484 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 485 | if (ha->flags.eeh_busy) { |
| 486 | if (ha->flags.pci_channel_io_perm_failure) |
Seokmann Ju | b9b12f7 | 2009-03-24 09:08:18 -0700 | [diff] [blame] | 487 | cmd->result = DID_NO_CONNECT << 16; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 488 | else |
| 489 | cmd->result = DID_REQUEUE << 16; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 490 | goto qc24_fail_command; |
| 491 | } |
| 492 | |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 493 | rval = fc_remote_port_chkready(rport); |
| 494 | if (rval) { |
| 495 | cmd->result = rval; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 496 | goto qc24_fail_command; |
| 497 | } |
| 498 | |
andrew.vasquez@qlogic.com | 387f96b | 2006-02-07 08:45:45 -0800 | [diff] [blame] | 499 | /* Close window on fcport/rport state-transitioning. */ |
Mike Christie | 7b59413 | 2008-08-17 15:24:40 -0500 | [diff] [blame] | 500 | if (fcport->drport) |
| 501 | goto qc24_target_busy; |
andrew.vasquez@qlogic.com | 387f96b | 2006-02-07 08:45:45 -0800 | [diff] [blame] | 502 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 503 | if (atomic_read(&fcport->state) != FCS_ONLINE) { |
| 504 | if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD || |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 505 | atomic_read(&base_vha->loop_state) == LOOP_DEAD) { |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 506 | cmd->result = DID_NO_CONNECT << 16; |
| 507 | goto qc24_fail_command; |
| 508 | } |
Mike Christie | 7b59413 | 2008-08-17 15:24:40 -0500 | [diff] [blame] | 509 | goto qc24_target_busy; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 510 | } |
| 511 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 512 | spin_unlock_irq(vha->host->host_lock); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 513 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 514 | sp = qla2x00_get_new_sp(base_vha, fcport, cmd, done); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 515 | if (!sp) |
| 516 | goto qc24_host_busy_lock; |
| 517 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 518 | rval = ha->isp_ops->start_scsi(sp); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 519 | if (rval != QLA_SUCCESS) |
| 520 | goto qc24_host_busy_free_sp; |
| 521 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 522 | spin_lock_irq(vha->host->host_lock); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 523 | |
| 524 | return 0; |
| 525 | |
| 526 | qc24_host_busy_free_sp: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 527 | qla2x00_sp_free_dma(sp); |
| 528 | mempool_free(sp, ha->srb_mempool); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 529 | |
| 530 | qc24_host_busy_lock: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 531 | spin_lock_irq(vha->host->host_lock); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 532 | return SCSI_MLQUEUE_HOST_BUSY; |
| 533 | |
Mike Christie | 7b59413 | 2008-08-17 15:24:40 -0500 | [diff] [blame] | 534 | qc24_target_busy: |
| 535 | return SCSI_MLQUEUE_TARGET_BUSY; |
| 536 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 537 | qc24_fail_command: |
| 538 | done(cmd); |
| 539 | |
| 540 | return 0; |
| 541 | } |
| 542 | |
| 543 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 544 | /* |
| 545 | * qla2x00_eh_wait_on_command |
| 546 | * Waits for the command to be returned by the Firmware for some |
| 547 | * max time. |
| 548 | * |
| 549 | * Input: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 550 | * cmd = Scsi Command to wait on. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 551 | * |
| 552 | * Return: |
| 553 | * Not Found : 0 |
| 554 | * Found : 1 |
| 555 | */ |
| 556 | static int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 557 | qla2x00_eh_wait_on_command(struct scsi_cmnd *cmd) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 558 | { |
Andrew Vasquez | fe74c71 | 2005-08-26 19:10:10 -0700 | [diff] [blame] | 559 | #define ABORT_POLLING_PERIOD 1000 |
| 560 | #define ABORT_WAIT_ITER ((10 * 1000) / (ABORT_POLLING_PERIOD)) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 561 | unsigned long wait_iter = ABORT_WAIT_ITER; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 562 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| 563 | struct qla_hw_data *ha = vha->hw; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 564 | int ret = QLA_SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 565 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 566 | if (unlikely(pci_channel_offline(ha->pdev)) || ha->flags.eeh_busy) { |
| 567 | DEBUG17(qla_printk(KERN_WARNING, ha, "return:eh_wait\n")); |
| 568 | return ret; |
| 569 | } |
| 570 | |
Lalit Chandivade | d970432 | 2009-08-25 11:36:18 -0700 | [diff] [blame] | 571 | while (CMD_SP(cmd) && wait_iter--) { |
Andrew Vasquez | fe74c71 | 2005-08-26 19:10:10 -0700 | [diff] [blame] | 572 | msleep(ABORT_POLLING_PERIOD); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 573 | } |
| 574 | if (CMD_SP(cmd)) |
| 575 | ret = QLA_FUNCTION_FAILED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 576 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 577 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 578 | } |
| 579 | |
| 580 | /* |
| 581 | * qla2x00_wait_for_hba_online |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 582 | * Wait till the HBA is online after going through |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 583 | * <= MAX_RETRIES_OF_ISP_ABORT or |
| 584 | * finally HBA is disabled ie marked offline |
| 585 | * |
| 586 | * Input: |
| 587 | * ha - pointer to host adapter structure |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 588 | * |
| 589 | * Note: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 590 | * Does context switching-Release SPIN_LOCK |
| 591 | * (if any) before calling this routine. |
| 592 | * |
| 593 | * Return: |
| 594 | * Success (Adapter is online) : 0 |
| 595 | * Failed (Adapter is offline/disabled) : 1 |
| 596 | */ |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 597 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 598 | qla2x00_wait_for_hba_online(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 599 | { |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 600 | int return_status; |
| 601 | unsigned long wait_online; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 602 | struct qla_hw_data *ha = vha->hw; |
| 603 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 604 | |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 605 | wait_online = jiffies + (MAX_LOOP_TIMEOUT * HZ); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 606 | while (((test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags)) || |
| 607 | test_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags) || |
| 608 | test_bit(ISP_ABORT_RETRY, &base_vha->dpc_flags) || |
| 609 | ha->dpc_active) && time_before(jiffies, wait_online)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 610 | |
| 611 | msleep(1000); |
| 612 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 613 | if (base_vha->flags.online) |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 614 | return_status = QLA_SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 615 | else |
| 616 | return_status = QLA_FUNCTION_FAILED; |
| 617 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 618 | return (return_status); |
| 619 | } |
| 620 | |
Lalit Chandivade | 2533cf6 | 2009-03-24 09:08:07 -0700 | [diff] [blame] | 621 | int |
| 622 | qla2x00_wait_for_chip_reset(scsi_qla_host_t *vha) |
| 623 | { |
| 624 | int return_status; |
| 625 | unsigned long wait_reset; |
| 626 | struct qla_hw_data *ha = vha->hw; |
| 627 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
| 628 | |
| 629 | wait_reset = jiffies + (MAX_LOOP_TIMEOUT * HZ); |
| 630 | while (((test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags)) || |
| 631 | test_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags) || |
| 632 | test_bit(ISP_ABORT_RETRY, &base_vha->dpc_flags) || |
| 633 | ha->dpc_active) && time_before(jiffies, wait_reset)) { |
| 634 | |
| 635 | msleep(1000); |
| 636 | |
| 637 | if (!test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags) && |
| 638 | ha->flags.chip_reset_done) |
| 639 | break; |
| 640 | } |
| 641 | if (ha->flags.chip_reset_done) |
| 642 | return_status = QLA_SUCCESS; |
| 643 | else |
| 644 | return_status = QLA_FUNCTION_FAILED; |
| 645 | |
| 646 | return return_status; |
| 647 | } |
| 648 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 649 | /* |
| 650 | * qla2x00_wait_for_loop_ready |
| 651 | * Wait for MAX_LOOP_TIMEOUT(5 min) value for loop |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 652 | * to be in LOOP_READY state. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 653 | * Input: |
| 654 | * ha - pointer to host adapter structure |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 655 | * |
| 656 | * Note: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 657 | * Does context switching-Release SPIN_LOCK |
| 658 | * (if any) before calling this routine. |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 659 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 660 | * |
| 661 | * Return: |
| 662 | * Success (LOOP_READY) : 0 |
| 663 | * Failed (LOOP_NOT_READY) : 1 |
| 664 | */ |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 665 | static inline int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 666 | qla2x00_wait_for_loop_ready(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 667 | { |
| 668 | int return_status = QLA_SUCCESS; |
| 669 | unsigned long loop_timeout ; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 670 | struct qla_hw_data *ha = vha->hw; |
| 671 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 672 | |
| 673 | /* wait for 5 min at the max for loop to be ready */ |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 674 | loop_timeout = jiffies + (MAX_LOOP_TIMEOUT * HZ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 675 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 676 | while ((!atomic_read(&base_vha->loop_down_timer) && |
| 677 | atomic_read(&base_vha->loop_state) == LOOP_DOWN) || |
| 678 | atomic_read(&base_vha->loop_state) != LOOP_READY) { |
| 679 | if (atomic_read(&base_vha->loop_state) == LOOP_DEAD) { |
Ravi Anand | 5768008 | 2006-05-17 15:08:44 -0700 | [diff] [blame] | 680 | return_status = QLA_FUNCTION_FAILED; |
| 681 | break; |
| 682 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 683 | msleep(1000); |
| 684 | if (time_after_eq(jiffies, loop_timeout)) { |
| 685 | return_status = QLA_FUNCTION_FAILED; |
| 686 | break; |
| 687 | } |
| 688 | } |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 689 | return (return_status); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 690 | } |
| 691 | |
| 692 | /************************************************************************** |
| 693 | * qla2xxx_eh_abort |
| 694 | * |
| 695 | * Description: |
| 696 | * The abort function will abort the specified command. |
| 697 | * |
| 698 | * Input: |
| 699 | * cmd = Linux SCSI command packet to be aborted. |
| 700 | * |
| 701 | * Returns: |
| 702 | * Either SUCCESS or FAILED. |
| 703 | * |
| 704 | * Note: |
Michael Reed | 2ea0020 | 2006-04-27 16:25:30 -0700 | [diff] [blame] | 705 | * Only return FAILED if command not returned by firmware. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 706 | **************************************************************************/ |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 707 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 708 | qla2xxx_eh_abort(struct scsi_cmnd *cmd) |
| 709 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 710 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 711 | srb_t *sp; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 712 | int ret, i; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 713 | unsigned int id, lun; |
| 714 | unsigned long serial; |
Andrew Vasquez | 18e144d | 2005-05-27 15:04:47 -0700 | [diff] [blame] | 715 | unsigned long flags; |
Michael Reed | 2ea0020 | 2006-04-27 16:25:30 -0700 | [diff] [blame] | 716 | int wait = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 717 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 67c2e93 | 2009-04-06 22:33:42 -0700 | [diff] [blame] | 718 | struct req_que *req = vha->req; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 719 | srb_t *spt; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 720 | |
Christof Schmitt | 65d430f | 2009-10-30 17:59:29 +0100 | [diff] [blame] | 721 | fc_block_scsi_eh(cmd); |
Andrew Vasquez | 07db518 | 2006-10-02 12:00:49 -0700 | [diff] [blame] | 722 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 723 | if (!CMD_SP(cmd)) |
Michael Reed | 2ea0020 | 2006-04-27 16:25:30 -0700 | [diff] [blame] | 724 | return SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 725 | |
Michael Reed | 2ea0020 | 2006-04-27 16:25:30 -0700 | [diff] [blame] | 726 | ret = SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 727 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 728 | id = cmd->device->id; |
| 729 | lun = cmd->device->lun; |
| 730 | serial = cmd->serial_number; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 731 | spt = (srb_t *) CMD_SP(cmd); |
| 732 | if (!spt) |
| 733 | return SUCCESS; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 734 | |
| 735 | /* Check active list for command command. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 736 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 737 | for (i = 1; i < MAX_OUTSTANDING_COMMANDS; i++) { |
| 738 | sp = req->outstanding_cmds[i]; |
| 739 | |
| 740 | if (sp == NULL) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 741 | continue; |
Andrew Vasquez | cf53b06 | 2009-08-20 11:06:04 -0700 | [diff] [blame] | 742 | if (sp->ctx) |
| 743 | continue; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 744 | if (sp->cmd != cmd) |
| 745 | continue; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 746 | |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 747 | DEBUG2(printk("%s(%ld): aborting sp %p from RISC." |
| 748 | " pid=%ld.\n", __func__, vha->host_no, sp, serial)); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 749 | |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 750 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 751 | if (ha->isp_ops->abort_command(sp)) { |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 752 | DEBUG2(printk("%s(%ld): abort_command " |
| 753 | "mbx failed.\n", __func__, vha->host_no)); |
Andrew Vasquez | 2ac4b64 | 2009-01-22 09:45:35 -0800 | [diff] [blame] | 754 | ret = FAILED; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 755 | } else { |
| 756 | DEBUG3(printk("%s(%ld): abort_command " |
| 757 | "mbx success.\n", __func__, vha->host_no)); |
| 758 | wait = 1; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 759 | } |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 760 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 761 | break; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 762 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 763 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 764 | |
| 765 | /* Wait for the command to be returned. */ |
Michael Reed | 2ea0020 | 2006-04-27 16:25:30 -0700 | [diff] [blame] | 766 | if (wait) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 767 | if (qla2x00_eh_wait_on_command(cmd) != QLA_SUCCESS) { |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 768 | qla_printk(KERN_ERR, ha, |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 769 | "scsi(%ld:%d:%d): Abort handler timed out -- %lx " |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 770 | "%x.\n", vha->host_no, id, lun, serial, ret); |
Michael Reed | 2ea0020 | 2006-04-27 16:25:30 -0700 | [diff] [blame] | 771 | ret = FAILED; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 772 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 773 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 774 | |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 775 | qla_printk(KERN_INFO, ha, |
Michael Reed | 2ea0020 | 2006-04-27 16:25:30 -0700 | [diff] [blame] | 776 | "scsi(%ld:%d:%d): Abort command issued -- %d %lx %x.\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 777 | vha->host_no, id, lun, wait, serial, ret); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 778 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 779 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 780 | } |
| 781 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 782 | enum nexus_wait_type { |
| 783 | WAIT_HOST = 0, |
| 784 | WAIT_TARGET, |
| 785 | WAIT_LUN, |
| 786 | }; |
| 787 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 788 | static int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 789 | qla2x00_eh_wait_for_pending_commands(scsi_qla_host_t *vha, unsigned int t, |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 790 | unsigned int l, srb_t *sp, enum nexus_wait_type type) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 791 | { |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 792 | int cnt, match, status; |
Andrew Vasquez | 18e144d | 2005-05-27 15:04:47 -0700 | [diff] [blame] | 793 | unsigned long flags; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 794 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 795 | struct req_que *req; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 796 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 797 | status = QLA_SUCCESS; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 798 | if (!sp) |
| 799 | return status; |
| 800 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 801 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 67c2e93 | 2009-04-06 22:33:42 -0700 | [diff] [blame] | 802 | req = vha->req; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 803 | for (cnt = 1; status == QLA_SUCCESS && |
| 804 | cnt < MAX_OUTSTANDING_COMMANDS; cnt++) { |
| 805 | sp = req->outstanding_cmds[cnt]; |
| 806 | if (!sp) |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 807 | continue; |
Andrew Vasquez | cf53b06 | 2009-08-20 11:06:04 -0700 | [diff] [blame] | 808 | if (sp->ctx) |
| 809 | continue; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 810 | if (vha->vp_idx != sp->fcport->vha->vp_idx) |
| 811 | continue; |
| 812 | match = 0; |
| 813 | switch (type) { |
| 814 | case WAIT_HOST: |
| 815 | match = 1; |
| 816 | break; |
| 817 | case WAIT_TARGET: |
| 818 | match = sp->cmd->device->id == t; |
| 819 | break; |
| 820 | case WAIT_LUN: |
| 821 | match = (sp->cmd->device->id == t && |
| 822 | sp->cmd->device->lun == l); |
| 823 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 824 | } |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 825 | if (!match) |
| 826 | continue; |
| 827 | |
| 828 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 829 | status = qla2x00_eh_wait_on_command(sp->cmd); |
| 830 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 831 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 832 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 833 | |
| 834 | return status; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 835 | } |
| 836 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 837 | static char *reset_errors[] = { |
| 838 | "HBA not online", |
| 839 | "HBA not ready", |
| 840 | "Task management failed", |
| 841 | "Waiting for command completions", |
| 842 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 843 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 844 | static int |
| 845 | __qla2xxx_eh_generic_reset(char *name, enum nexus_wait_type type, |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 846 | 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] | 847 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 848 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 849 | fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; |
| 850 | int err; |
| 851 | |
Christof Schmitt | 65d430f | 2009-10-30 17:59:29 +0100 | [diff] [blame] | 852 | fc_block_scsi_eh(cmd); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 853 | |
| 854 | if (!fcport) |
| 855 | return FAILED; |
| 856 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 857 | qla_printk(KERN_INFO, vha->hw, "scsi(%ld:%d:%d): %s RESET ISSUED.\n", |
| 858 | vha->host_no, cmd->device->id, cmd->device->lun, name); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 859 | |
| 860 | err = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 861 | if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 862 | goto eh_reset_failed; |
| 863 | err = 1; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 864 | if (qla2x00_wait_for_loop_ready(vha) != QLA_SUCCESS) |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 865 | goto eh_reset_failed; |
| 866 | err = 2; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 867 | if (do_reset(fcport, cmd->device->lun, cmd->request->cpu + 1) |
| 868 | != QLA_SUCCESS) |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 869 | goto eh_reset_failed; |
| 870 | err = 3; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 871 | if (qla2x00_eh_wait_for_pending_commands(vha, cmd->device->id, |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 872 | cmd->device->lun, (srb_t *) CMD_SP(cmd), type) != QLA_SUCCESS) |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 873 | goto eh_reset_failed; |
| 874 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 875 | qla_printk(KERN_INFO, vha->hw, "scsi(%ld:%d:%d): %s RESET SUCCEEDED.\n", |
| 876 | vha->host_no, cmd->device->id, cmd->device->lun, name); |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 877 | |
| 878 | return SUCCESS; |
| 879 | |
| 880 | eh_reset_failed: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 881 | qla_printk(KERN_INFO, vha->hw, "scsi(%ld:%d:%d): %s RESET FAILED: %s.\n" |
| 882 | , vha->host_no, cmd->device->id, cmd->device->lun, name, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 883 | reset_errors[err]); |
| 884 | return FAILED; |
| 885 | } |
| 886 | |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 887 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 888 | qla2xxx_eh_device_reset(struct scsi_cmnd *cmd) |
| 889 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 890 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| 891 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 892 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 893 | return __qla2xxx_eh_generic_reset("DEVICE", WAIT_LUN, cmd, |
| 894 | ha->isp_ops->lun_reset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 895 | } |
| 896 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 897 | static int |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 898 | qla2xxx_eh_target_reset(struct scsi_cmnd *cmd) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 899 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 900 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| 901 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 902 | |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 903 | return __qla2xxx_eh_generic_reset("TARGET", WAIT_TARGET, cmd, |
| 904 | ha->isp_ops->target_reset); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 905 | } |
| 906 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 907 | /************************************************************************** |
| 908 | * qla2xxx_eh_bus_reset |
| 909 | * |
| 910 | * Description: |
| 911 | * The bus reset function will reset the bus and abort any executing |
| 912 | * commands. |
| 913 | * |
| 914 | * Input: |
| 915 | * cmd = Linux SCSI command packet of the command that cause the |
| 916 | * bus reset. |
| 917 | * |
| 918 | * Returns: |
| 919 | * SUCCESS/FAILURE (defined as macro in scsi.h). |
| 920 | * |
| 921 | **************************************************************************/ |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 922 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 923 | qla2xxx_eh_bus_reset(struct scsi_cmnd *cmd) |
| 924 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 925 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 926 | fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 927 | int ret = FAILED; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 928 | unsigned int id, lun; |
| 929 | unsigned long serial; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 930 | srb_t *sp = (srb_t *) CMD_SP(cmd); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 931 | |
Christof Schmitt | 65d430f | 2009-10-30 17:59:29 +0100 | [diff] [blame] | 932 | fc_block_scsi_eh(cmd); |
Andrew Vasquez | 07db518 | 2006-10-02 12:00:49 -0700 | [diff] [blame] | 933 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 934 | id = cmd->device->id; |
| 935 | lun = cmd->device->lun; |
| 936 | serial = cmd->serial_number; |
| 937 | |
Vladislav Bolkhovitin | b0328be | 2006-08-01 13:48:15 -0700 | [diff] [blame] | 938 | if (!fcport) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 939 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 940 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 941 | qla_printk(KERN_INFO, vha->hw, |
Anirban Chakraborty | 749af3d | 2008-11-14 13:48:12 -0800 | [diff] [blame] | 942 | "scsi(%ld:%d:%d): BUS RESET ISSUED.\n", vha->host_no, id, lun); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 943 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 944 | if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 945 | DEBUG2(printk("%s failed:board disabled\n",__func__)); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 946 | goto eh_bus_reset_done; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 947 | } |
| 948 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 949 | if (qla2x00_wait_for_loop_ready(vha) == QLA_SUCCESS) { |
| 950 | if (qla2x00_loop_reset(vha) == QLA_SUCCESS) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 951 | ret = SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 952 | } |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 953 | if (ret == FAILED) |
| 954 | goto eh_bus_reset_done; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 955 | |
Andrew Vasquez | 9a41a62 | 2005-09-20 13:25:53 -0700 | [diff] [blame] | 956 | /* Flush outstanding commands. */ |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 957 | if (qla2x00_eh_wait_for_pending_commands(vha, 0, 0, sp, WAIT_HOST) != |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 958 | QLA_SUCCESS) |
Andrew Vasquez | 9a41a62 | 2005-09-20 13:25:53 -0700 | [diff] [blame] | 959 | ret = FAILED; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 960 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 961 | eh_bus_reset_done: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 962 | qla_printk(KERN_INFO, vha->hw, "%s: reset %s\n", __func__, |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 963 | (ret == FAILED) ? "failed" : "succeded"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 964 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 965 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 966 | } |
| 967 | |
| 968 | /************************************************************************** |
| 969 | * qla2xxx_eh_host_reset |
| 970 | * |
| 971 | * Description: |
| 972 | * The reset function will reset the Adapter. |
| 973 | * |
| 974 | * Input: |
| 975 | * cmd = Linux SCSI command packet of the command that cause the |
| 976 | * adapter reset. |
| 977 | * |
| 978 | * Returns: |
| 979 | * Either SUCCESS or FAILED. |
| 980 | * |
| 981 | * Note: |
| 982 | **************************************************************************/ |
Adrian Bunk | e5f82ab | 2006-11-08 19:55:50 -0800 | [diff] [blame] | 983 | static int |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 984 | qla2xxx_eh_host_reset(struct scsi_cmnd *cmd) |
| 985 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 986 | scsi_qla_host_t *vha = shost_priv(cmd->device->host); |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 987 | fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 988 | struct qla_hw_data *ha = vha->hw; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 989 | int ret = FAILED; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 990 | unsigned int id, lun; |
| 991 | unsigned long serial; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 992 | srb_t *sp = (srb_t *) CMD_SP(cmd); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 993 | scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 994 | |
Christof Schmitt | 65d430f | 2009-10-30 17:59:29 +0100 | [diff] [blame] | 995 | fc_block_scsi_eh(cmd); |
Andrew Vasquez | 07db518 | 2006-10-02 12:00:49 -0700 | [diff] [blame] | 996 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 997 | id = cmd->device->id; |
| 998 | lun = cmd->device->lun; |
| 999 | serial = cmd->serial_number; |
| 1000 | |
Vladislav Bolkhovitin | b0328be | 2006-08-01 13:48:15 -0700 | [diff] [blame] | 1001 | if (!fcport) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1002 | return ret; |
| 1003 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1004 | qla_printk(KERN_INFO, ha, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1005 | "scsi(%ld:%d:%d): ADAPTER RESET ISSUED.\n", vha->host_no, id, lun); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1006 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1007 | if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1008 | goto eh_host_reset_lock; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1009 | |
| 1010 | /* |
| 1011 | * Fixme-may be dpc thread is active and processing |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1012 | * loop_resync,so wait a while for it to |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1013 | * be completed and then issue big hammer.Otherwise |
| 1014 | * it may cause I/O failure as big hammer marks the |
| 1015 | * devices as lost kicking of the port_down_timer |
| 1016 | * while dpc is stuck for the mailbox to complete. |
| 1017 | */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1018 | qla2x00_wait_for_loop_ready(vha); |
| 1019 | if (vha != base_vha) { |
| 1020 | if (qla2x00_vp_abort_isp(vha)) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1021 | goto eh_host_reset_lock; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1022 | } else { |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 1023 | if (ha->wq) |
| 1024 | flush_workqueue(ha->wq); |
| 1025 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1026 | set_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
| 1027 | if (qla2x00_abort_isp(base_vha)) { |
| 1028 | clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
| 1029 | /* failed. schedule dpc to try */ |
| 1030 | set_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags); |
| 1031 | |
| 1032 | if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) |
| 1033 | goto eh_host_reset_lock; |
| 1034 | } |
| 1035 | clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 1036 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1037 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1038 | /* Waiting for command to be returned to OS.*/ |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1039 | if (qla2x00_eh_wait_for_pending_commands(vha, 0, 0, sp, WAIT_HOST) == |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1040 | QLA_SUCCESS) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1041 | ret = SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1042 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1043 | eh_host_reset_lock: |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1044 | qla_printk(KERN_INFO, ha, "%s: reset %s\n", __func__, |
| 1045 | (ret == FAILED) ? "failed" : "succeded"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1046 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1047 | return ret; |
| 1048 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1049 | |
| 1050 | /* |
| 1051 | * qla2x00_loop_reset |
| 1052 | * Issue loop reset. |
| 1053 | * |
| 1054 | * Input: |
| 1055 | * ha = adapter block pointer. |
| 1056 | * |
| 1057 | * Returns: |
| 1058 | * 0 = success |
| 1059 | */ |
Andrew Vasquez | a4722cf | 2008-01-17 09:02:12 -0800 | [diff] [blame] | 1060 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1061 | qla2x00_loop_reset(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1062 | { |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 1063 | int ret; |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 1064 | struct fc_port *fcport; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1065 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1066 | |
Andrew Vasquez | 55e5ed2 | 2010-02-18 10:07:25 -0800 | [diff] [blame] | 1067 | if (ha->flags.enable_target_reset) { |
| 1068 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
| 1069 | if (fcport->port_type != FCT_TARGET) |
| 1070 | continue; |
| 1071 | |
| 1072 | ret = ha->isp_ops->target_reset(fcport, 0, 0); |
| 1073 | if (ret != QLA_SUCCESS) { |
| 1074 | DEBUG2_3(printk("%s(%ld): bus_reset failed: " |
| 1075 | "target_reset=%d d_id=%x.\n", __func__, |
| 1076 | vha->host_no, ret, fcport->d_id.b24)); |
| 1077 | } |
| 1078 | } |
| 1079 | } |
| 1080 | |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 1081 | if (ha->flags.enable_lip_full_login && !IS_QLA81XX(ha)) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1082 | ret = qla2x00_full_login_lip(vha); |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 1083 | if (ret != QLA_SUCCESS) { |
Anirban Chakraborty | 749af3d | 2008-11-14 13:48:12 -0800 | [diff] [blame] | 1084 | DEBUG2_3(printk("%s(%ld): failed: " |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1085 | "full_login_lip=%d.\n", __func__, vha->host_no, |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 1086 | ret)); |
Anirban Chakraborty | 749af3d | 2008-11-14 13:48:12 -0800 | [diff] [blame] | 1087 | } |
| 1088 | atomic_set(&vha->loop_state, LOOP_DOWN); |
| 1089 | atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME); |
| 1090 | qla2x00_mark_all_devices_lost(vha, 0); |
| 1091 | qla2x00_wait_for_loop_ready(vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1092 | } |
| 1093 | |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 1094 | if (ha->flags.enable_lip_reset) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1095 | ret = qla2x00_lip_reset(vha); |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 1096 | if (ret != QLA_SUCCESS) { |
Anirban Chakraborty | 749af3d | 2008-11-14 13:48:12 -0800 | [diff] [blame] | 1097 | DEBUG2_3(printk("%s(%ld): failed: " |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1098 | "lip_reset=%d.\n", __func__, vha->host_no, ret)); |
| 1099 | } else |
| 1100 | qla2x00_wait_for_loop_ready(vha); |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 1101 | } |
| 1102 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1103 | /* 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] | 1104 | vha->marker_needed = 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1105 | |
Andrew Vasquez | 0c8c39a | 2006-12-13 19:20:30 -0800 | [diff] [blame] | 1106 | return QLA_SUCCESS; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1107 | } |
| 1108 | |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1109 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1110 | qla2x00_abort_all_cmds(scsi_qla_host_t *vha, int res) |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1111 | { |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1112 | int que, cnt; |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1113 | unsigned long flags; |
| 1114 | srb_t *sp; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1115 | struct srb_ctx *ctx; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1116 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1117 | struct req_que *req; |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1118 | |
| 1119 | spin_lock_irqsave(&ha->hardware_lock, flags); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1120 | for (que = 0; que < ha->max_req_queues; que++) { |
Anirban Chakraborty | 29bdccb | 2009-01-08 15:41:08 -0800 | [diff] [blame] | 1121 | req = ha->req_q_map[que]; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1122 | if (!req) |
| 1123 | continue; |
| 1124 | for (cnt = 1; cnt < MAX_OUTSTANDING_COMMANDS; cnt++) { |
| 1125 | sp = req->outstanding_cmds[cnt]; |
Andrew Vasquez | e612d46 | 2009-03-24 09:08:04 -0700 | [diff] [blame] | 1126 | if (sp) { |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1127 | req->outstanding_cmds[cnt] = NULL; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1128 | if (!sp->ctx) { |
| 1129 | sp->cmd->result = res; |
| 1130 | qla2x00_sp_compl(ha, sp); |
| 1131 | } else { |
| 1132 | ctx = sp->ctx; |
Andrew Vasquez | 6c452a4 | 2010-03-19 17:04:02 -0700 | [diff] [blame] | 1133 | if (ctx->type == SRB_LOGIN_CMD || |
| 1134 | ctx->type == SRB_LOGOUT_CMD) { |
Giridhar Malavali | db3ad7f | 2010-02-18 10:07:24 -0800 | [diff] [blame] | 1135 | del_timer_sync(&ctx->timer); |
| 1136 | ctx->free(sp); |
| 1137 | } else { |
Andrew Vasquez | 6c452a4 | 2010-03-19 17:04:02 -0700 | [diff] [blame] | 1138 | struct srb_bsg *sp_bsg = |
| 1139 | (struct srb_bsg *)sp->ctx; |
| 1140 | struct fc_bsg_job *bsg_job = |
| 1141 | sp_bsg->bsg_job; |
| 1142 | |
| 1143 | if (bsg_job->request->msgcode |
| 1144 | == FC_BSG_HST_CT) |
Giridhar Malavali | db3ad7f | 2010-02-18 10:07:24 -0800 | [diff] [blame] | 1145 | kfree(sp->fcport); |
Andrew Vasquez | 6c452a4 | 2010-03-19 17:04:02 -0700 | [diff] [blame] | 1146 | bsg_job->req->errors = 0; |
| 1147 | bsg_job->reply->result = res; |
| 1148 | bsg_job->job_done( |
| 1149 | sp_bsg->bsg_job); |
Giridhar Malavali | db3ad7f | 2010-02-18 10:07:24 -0800 | [diff] [blame] | 1150 | kfree(sp->ctx); |
Andrew Vasquez | 6c452a4 | 2010-03-19 17:04:02 -0700 | [diff] [blame] | 1151 | mempool_free(sp, |
| 1152 | ha->srb_mempool); |
Giridhar Malavali | db3ad7f | 2010-02-18 10:07:24 -0800 | [diff] [blame] | 1153 | } |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 1154 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1155 | } |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1156 | } |
| 1157 | } |
| 1158 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1159 | } |
| 1160 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1161 | static int |
| 1162 | qla2xxx_slave_alloc(struct scsi_device *sdev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1163 | { |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 1164 | struct fc_rport *rport = starget_to_rport(scsi_target(sdev)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1165 | |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 1166 | if (!rport || fc_remote_port_chkready(rport)) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1167 | return -ENXIO; |
| 1168 | |
James.Smart@Emulex.Com | 19a7b4a | 2005-10-18 12:03:35 -0400 | [diff] [blame] | 1169 | sdev->hostdata = *(fc_port_t **)rport->dd_data; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1170 | |
| 1171 | return 0; |
| 1172 | } |
| 1173 | |
| 1174 | static int |
| 1175 | qla2xxx_slave_configure(struct scsi_device *sdev) |
| 1176 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1177 | scsi_qla_host_t *vha = shost_priv(sdev->host); |
| 1178 | struct qla_hw_data *ha = vha->hw; |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 1179 | struct fc_rport *rport = starget_to_rport(sdev->sdev_target); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1180 | struct req_que *req = vha->req; |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 1181 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1182 | if (sdev->tagged_supported) |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1183 | scsi_activate_tcq(sdev, req->max_q_depth); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1184 | else |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1185 | scsi_deactivate_tcq(sdev, req->max_q_depth); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1186 | |
Andrew Vasquez | 85821c9 | 2008-07-10 16:55:48 -0700 | [diff] [blame] | 1187 | rport->dev_loss_tmo = ha->port_down_retry_count; |
| 8482e11 | 2005-04-17 15:04:54 -0500 | [diff] [blame] | 1188 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1189 | return 0; |
| 1190 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1191 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 1192 | static void |
| 1193 | qla2xxx_slave_destroy(struct scsi_device *sdev) |
| 1194 | { |
| 1195 | sdev->hostdata = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1196 | } |
| 1197 | |
Giridhar Malavali | c45dd30 | 2009-12-02 10:36:54 -0800 | [diff] [blame] | 1198 | static void qla2x00_handle_queue_full(struct scsi_device *sdev, int qdepth) |
| 1199 | { |
| 1200 | fc_port_t *fcport = (struct fc_port *) sdev->hostdata; |
| 1201 | |
| 1202 | if (!scsi_track_queue_full(sdev, qdepth)) |
| 1203 | return; |
| 1204 | |
| 1205 | DEBUG2(qla_printk(KERN_INFO, fcport->vha->hw, |
| 1206 | "scsi(%ld:%d:%d:%d): Queue depth adjusted-down to %d.\n", |
| 1207 | fcport->vha->host_no, sdev->channel, sdev->id, sdev->lun, |
| 1208 | sdev->queue_depth)); |
| 1209 | } |
| 1210 | |
| 1211 | static void qla2x00_adjust_sdev_qdepth_up(struct scsi_device *sdev, int qdepth) |
| 1212 | { |
| 1213 | fc_port_t *fcport = sdev->hostdata; |
| 1214 | struct scsi_qla_host *vha = fcport->vha; |
| 1215 | struct qla_hw_data *ha = vha->hw; |
| 1216 | struct req_que *req = NULL; |
| 1217 | |
| 1218 | req = vha->req; |
| 1219 | if (!req) |
| 1220 | return; |
| 1221 | |
| 1222 | if (req->max_q_depth <= sdev->queue_depth || req->max_q_depth < qdepth) |
| 1223 | return; |
| 1224 | |
| 1225 | if (sdev->ordered_tags) |
| 1226 | scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG, qdepth); |
| 1227 | else |
| 1228 | scsi_adjust_queue_depth(sdev, MSG_SIMPLE_TAG, qdepth); |
| 1229 | |
| 1230 | DEBUG2(qla_printk(KERN_INFO, ha, |
| 1231 | "scsi(%ld:%d:%d:%d): Queue depth adjusted-up to %d.\n", |
| 1232 | fcport->vha->host_no, sdev->channel, sdev->id, sdev->lun, |
| 1233 | sdev->queue_depth)); |
| 1234 | } |
| 1235 | |
Andrew Vasquez | ce7e4af | 2005-08-26 19:09:30 -0700 | [diff] [blame] | 1236 | static int |
Mike Christie | e881a17 | 2009-10-15 17:46:39 -0700 | [diff] [blame] | 1237 | qla2x00_change_queue_depth(struct scsi_device *sdev, int qdepth, int reason) |
Andrew Vasquez | ce7e4af | 2005-08-26 19:09:30 -0700 | [diff] [blame] | 1238 | { |
Giridhar Malavali | c45dd30 | 2009-12-02 10:36:54 -0800 | [diff] [blame] | 1239 | switch (reason) { |
| 1240 | case SCSI_QDEPTH_DEFAULT: |
| 1241 | scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), qdepth); |
| 1242 | break; |
| 1243 | case SCSI_QDEPTH_QFULL: |
| 1244 | qla2x00_handle_queue_full(sdev, qdepth); |
| 1245 | break; |
| 1246 | case SCSI_QDEPTH_RAMP_UP: |
| 1247 | qla2x00_adjust_sdev_qdepth_up(sdev, qdepth); |
| 1248 | break; |
| 1249 | default: |
Roel Kluin | 08002af | 2010-01-29 11:25:19 +0100 | [diff] [blame] | 1250 | return -EOPNOTSUPP; |
Giridhar Malavali | c45dd30 | 2009-12-02 10:36:54 -0800 | [diff] [blame] | 1251 | } |
Mike Christie | e881a17 | 2009-10-15 17:46:39 -0700 | [diff] [blame] | 1252 | |
Andrew Vasquez | ce7e4af | 2005-08-26 19:09:30 -0700 | [diff] [blame] | 1253 | return sdev->queue_depth; |
| 1254 | } |
| 1255 | |
| 1256 | static int |
| 1257 | qla2x00_change_queue_type(struct scsi_device *sdev, int tag_type) |
| 1258 | { |
| 1259 | if (sdev->tagged_supported) { |
| 1260 | scsi_set_tag_type(sdev, tag_type); |
| 1261 | if (tag_type) |
| 1262 | scsi_activate_tcq(sdev, sdev->queue_depth); |
| 1263 | else |
| 1264 | scsi_deactivate_tcq(sdev, sdev->queue_depth); |
| 1265 | } else |
| 1266 | tag_type = 0; |
| 1267 | |
| 1268 | return tag_type; |
| 1269 | } |
| 1270 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1271 | /** |
| 1272 | * qla2x00_config_dma_addressing() - Configure OS DMA addressing method. |
| 1273 | * @ha: HA context |
| 1274 | * |
| 1275 | * At exit, the @ha's flags.enable_64bit_addressing set to indicated |
| 1276 | * supported addressing method. |
| 1277 | */ |
| 1278 | static void |
Andrew Vasquez | 53303c4 | 2009-01-22 09:45:37 -0800 | [diff] [blame] | 1279 | qla2x00_config_dma_addressing(struct qla_hw_data *ha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1280 | { |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1281 | /* Assume a 32bit DMA mask. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1282 | ha->flags.enable_64bit_addressing = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1283 | |
Yang Hongyang | 6a35528 | 2009-04-06 19:01:13 -0700 | [diff] [blame] | 1284 | if (!dma_set_mask(&ha->pdev->dev, DMA_BIT_MASK(64))) { |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1285 | /* Any upper-dword bits set? */ |
| 1286 | if (MSD(dma_get_required_mask(&ha->pdev->dev)) && |
Yang Hongyang | 6a35528 | 2009-04-06 19:01:13 -0700 | [diff] [blame] | 1287 | !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) { |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1288 | /* Ok, a 64bit DMA mask is applicable. */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1289 | ha->flags.enable_64bit_addressing = 1; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1290 | ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64; |
| 1291 | ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64; |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1292 | return; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1293 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1294 | } |
Andrew Vasquez | 7524f9b | 2005-08-26 19:08:00 -0700 | [diff] [blame] | 1295 | |
Yang Hongyang | 284901a | 2009-04-06 19:01:15 -0700 | [diff] [blame] | 1296 | dma_set_mask(&ha->pdev->dev, DMA_BIT_MASK(32)); |
| 1297 | pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(32)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1298 | } |
| 1299 | |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1300 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1301 | qla2x00_enable_intrs(struct qla_hw_data *ha) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1302 | { |
| 1303 | unsigned long flags = 0; |
| 1304 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
| 1305 | |
| 1306 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1307 | ha->interrupts_on = 1; |
| 1308 | /* enable risc and host interrupts */ |
| 1309 | WRT_REG_WORD(®->ictrl, ICR_EN_INT | ICR_EN_RISC); |
| 1310 | RD_REG_WORD(®->ictrl); |
| 1311 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1312 | |
| 1313 | } |
| 1314 | |
| 1315 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1316 | qla2x00_disable_intrs(struct qla_hw_data *ha) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1317 | { |
| 1318 | unsigned long flags = 0; |
| 1319 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
| 1320 | |
| 1321 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1322 | ha->interrupts_on = 0; |
| 1323 | /* disable risc and host interrupts */ |
| 1324 | WRT_REG_WORD(®->ictrl, 0); |
| 1325 | RD_REG_WORD(®->ictrl); |
| 1326 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1327 | } |
| 1328 | |
| 1329 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1330 | qla24xx_enable_intrs(struct qla_hw_data *ha) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1331 | { |
| 1332 | unsigned long flags = 0; |
| 1333 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
| 1334 | |
| 1335 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1336 | ha->interrupts_on = 1; |
| 1337 | WRT_REG_DWORD(®->ictrl, ICRX_EN_RISC_INT); |
| 1338 | RD_REG_DWORD(®->ictrl); |
| 1339 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1340 | } |
| 1341 | |
| 1342 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1343 | qla24xx_disable_intrs(struct qla_hw_data *ha) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1344 | { |
| 1345 | unsigned long flags = 0; |
| 1346 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
| 1347 | |
Andrew Vasquez | 124f85e | 2009-01-05 11:18:06 -0800 | [diff] [blame] | 1348 | if (IS_NOPOLLING_TYPE(ha)) |
| 1349 | return; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1350 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 1351 | ha->interrupts_on = 0; |
| 1352 | WRT_REG_DWORD(®->ictrl, 0); |
| 1353 | RD_REG_DWORD(®->ictrl); |
| 1354 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 1355 | } |
| 1356 | |
| 1357 | static struct isp_operations qla2100_isp_ops = { |
| 1358 | .pci_config = qla2100_pci_config, |
| 1359 | .reset_chip = qla2x00_reset_chip, |
| 1360 | .chip_diag = qla2x00_chip_diag, |
| 1361 | .config_rings = qla2x00_config_rings, |
| 1362 | .reset_adapter = qla2x00_reset_adapter, |
| 1363 | .nvram_config = qla2x00_nvram_config, |
| 1364 | .update_fw_options = qla2x00_update_fw_options, |
| 1365 | .load_risc = qla2x00_load_risc, |
| 1366 | .pci_info_str = qla2x00_pci_info_str, |
| 1367 | .fw_version_str = qla2x00_fw_version_str, |
| 1368 | .intr_handler = qla2100_intr_handler, |
| 1369 | .enable_intrs = qla2x00_enable_intrs, |
| 1370 | .disable_intrs = qla2x00_disable_intrs, |
| 1371 | .abort_command = qla2x00_abort_command, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1372 | .target_reset = qla2x00_abort_target, |
| 1373 | .lun_reset = qla2x00_lun_reset, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1374 | .fabric_login = qla2x00_login_fabric, |
| 1375 | .fabric_logout = qla2x00_fabric_logout, |
| 1376 | .calc_req_entries = qla2x00_calc_iocbs_32, |
| 1377 | .build_iocbs = qla2x00_build_scsi_iocbs_32, |
| 1378 | .prep_ms_iocb = qla2x00_prep_ms_iocb, |
| 1379 | .prep_ms_fdmi_iocb = qla2x00_prep_ms_fdmi_iocb, |
| 1380 | .read_nvram = qla2x00_read_nvram_data, |
| 1381 | .write_nvram = qla2x00_write_nvram_data, |
| 1382 | .fw_dump = qla2100_fw_dump, |
| 1383 | .beacon_on = NULL, |
| 1384 | .beacon_off = NULL, |
| 1385 | .beacon_blink = NULL, |
| 1386 | .read_optrom = qla2x00_read_optrom_data, |
| 1387 | .write_optrom = qla2x00_write_optrom_data, |
| 1388 | .get_flash_version = qla2x00_get_flash_version, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1389 | .start_scsi = qla2x00_start_scsi, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1390 | }; |
| 1391 | |
| 1392 | static struct isp_operations qla2300_isp_ops = { |
| 1393 | .pci_config = qla2300_pci_config, |
| 1394 | .reset_chip = qla2x00_reset_chip, |
| 1395 | .chip_diag = qla2x00_chip_diag, |
| 1396 | .config_rings = qla2x00_config_rings, |
| 1397 | .reset_adapter = qla2x00_reset_adapter, |
| 1398 | .nvram_config = qla2x00_nvram_config, |
| 1399 | .update_fw_options = qla2x00_update_fw_options, |
| 1400 | .load_risc = qla2x00_load_risc, |
| 1401 | .pci_info_str = qla2x00_pci_info_str, |
| 1402 | .fw_version_str = qla2x00_fw_version_str, |
| 1403 | .intr_handler = qla2300_intr_handler, |
| 1404 | .enable_intrs = qla2x00_enable_intrs, |
| 1405 | .disable_intrs = qla2x00_disable_intrs, |
| 1406 | .abort_command = qla2x00_abort_command, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1407 | .target_reset = qla2x00_abort_target, |
| 1408 | .lun_reset = qla2x00_lun_reset, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1409 | .fabric_login = qla2x00_login_fabric, |
| 1410 | .fabric_logout = qla2x00_fabric_logout, |
| 1411 | .calc_req_entries = qla2x00_calc_iocbs_32, |
| 1412 | .build_iocbs = qla2x00_build_scsi_iocbs_32, |
| 1413 | .prep_ms_iocb = qla2x00_prep_ms_iocb, |
| 1414 | .prep_ms_fdmi_iocb = qla2x00_prep_ms_fdmi_iocb, |
| 1415 | .read_nvram = qla2x00_read_nvram_data, |
| 1416 | .write_nvram = qla2x00_write_nvram_data, |
| 1417 | .fw_dump = qla2300_fw_dump, |
| 1418 | .beacon_on = qla2x00_beacon_on, |
| 1419 | .beacon_off = qla2x00_beacon_off, |
| 1420 | .beacon_blink = qla2x00_beacon_blink, |
| 1421 | .read_optrom = qla2x00_read_optrom_data, |
| 1422 | .write_optrom = qla2x00_write_optrom_data, |
| 1423 | .get_flash_version = qla2x00_get_flash_version, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1424 | .start_scsi = qla2x00_start_scsi, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1425 | }; |
| 1426 | |
| 1427 | static struct isp_operations qla24xx_isp_ops = { |
| 1428 | .pci_config = qla24xx_pci_config, |
| 1429 | .reset_chip = qla24xx_reset_chip, |
| 1430 | .chip_diag = qla24xx_chip_diag, |
| 1431 | .config_rings = qla24xx_config_rings, |
| 1432 | .reset_adapter = qla24xx_reset_adapter, |
| 1433 | .nvram_config = qla24xx_nvram_config, |
| 1434 | .update_fw_options = qla24xx_update_fw_options, |
| 1435 | .load_risc = qla24xx_load_risc, |
| 1436 | .pci_info_str = qla24xx_pci_info_str, |
| 1437 | .fw_version_str = qla24xx_fw_version_str, |
| 1438 | .intr_handler = qla24xx_intr_handler, |
| 1439 | .enable_intrs = qla24xx_enable_intrs, |
| 1440 | .disable_intrs = qla24xx_disable_intrs, |
| 1441 | .abort_command = qla24xx_abort_command, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1442 | .target_reset = qla24xx_abort_target, |
| 1443 | .lun_reset = qla24xx_lun_reset, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1444 | .fabric_login = qla24xx_login_fabric, |
| 1445 | .fabric_logout = qla24xx_fabric_logout, |
| 1446 | .calc_req_entries = NULL, |
| 1447 | .build_iocbs = NULL, |
| 1448 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 1449 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 1450 | .read_nvram = qla24xx_read_nvram_data, |
| 1451 | .write_nvram = qla24xx_write_nvram_data, |
| 1452 | .fw_dump = qla24xx_fw_dump, |
| 1453 | .beacon_on = qla24xx_beacon_on, |
| 1454 | .beacon_off = qla24xx_beacon_off, |
| 1455 | .beacon_blink = qla24xx_beacon_blink, |
| 1456 | .read_optrom = qla24xx_read_optrom_data, |
| 1457 | .write_optrom = qla24xx_write_optrom_data, |
| 1458 | .get_flash_version = qla24xx_get_flash_version, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1459 | .start_scsi = qla24xx_start_scsi, |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1460 | }; |
| 1461 | |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1462 | static struct isp_operations qla25xx_isp_ops = { |
| 1463 | .pci_config = qla25xx_pci_config, |
| 1464 | .reset_chip = qla24xx_reset_chip, |
| 1465 | .chip_diag = qla24xx_chip_diag, |
| 1466 | .config_rings = qla24xx_config_rings, |
| 1467 | .reset_adapter = qla24xx_reset_adapter, |
| 1468 | .nvram_config = qla24xx_nvram_config, |
| 1469 | .update_fw_options = qla24xx_update_fw_options, |
| 1470 | .load_risc = qla24xx_load_risc, |
| 1471 | .pci_info_str = qla24xx_pci_info_str, |
| 1472 | .fw_version_str = qla24xx_fw_version_str, |
| 1473 | .intr_handler = qla24xx_intr_handler, |
| 1474 | .enable_intrs = qla24xx_enable_intrs, |
| 1475 | .disable_intrs = qla24xx_disable_intrs, |
| 1476 | .abort_command = qla24xx_abort_command, |
Andrew Vasquez | 523ec77 | 2008-04-03 13:13:24 -0700 | [diff] [blame] | 1477 | .target_reset = qla24xx_abort_target, |
| 1478 | .lun_reset = qla24xx_lun_reset, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1479 | .fabric_login = qla24xx_login_fabric, |
| 1480 | .fabric_logout = qla24xx_fabric_logout, |
| 1481 | .calc_req_entries = NULL, |
| 1482 | .build_iocbs = NULL, |
| 1483 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 1484 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
| 1485 | .read_nvram = qla25xx_read_nvram_data, |
| 1486 | .write_nvram = qla25xx_write_nvram_data, |
| 1487 | .fw_dump = qla25xx_fw_dump, |
| 1488 | .beacon_on = qla24xx_beacon_on, |
| 1489 | .beacon_off = qla24xx_beacon_off, |
| 1490 | .beacon_blink = qla24xx_beacon_blink, |
Andrew Vasquez | 338c916 | 2007-09-20 14:07:33 -0700 | [diff] [blame] | 1491 | .read_optrom = qla25xx_read_optrom_data, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1492 | .write_optrom = qla24xx_write_optrom_data, |
| 1493 | .get_flash_version = qla24xx_get_flash_version, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1494 | .start_scsi = qla24xx_start_scsi, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1495 | }; |
| 1496 | |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 1497 | static struct isp_operations qla81xx_isp_ops = { |
| 1498 | .pci_config = qla25xx_pci_config, |
| 1499 | .reset_chip = qla24xx_reset_chip, |
| 1500 | .chip_diag = qla24xx_chip_diag, |
| 1501 | .config_rings = qla24xx_config_rings, |
| 1502 | .reset_adapter = qla24xx_reset_adapter, |
| 1503 | .nvram_config = qla81xx_nvram_config, |
| 1504 | .update_fw_options = qla81xx_update_fw_options, |
Andrew Vasquez | eaac30b | 2009-01-22 09:45:32 -0800 | [diff] [blame] | 1505 | .load_risc = qla81xx_load_risc, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 1506 | .pci_info_str = qla24xx_pci_info_str, |
| 1507 | .fw_version_str = qla24xx_fw_version_str, |
| 1508 | .intr_handler = qla24xx_intr_handler, |
| 1509 | .enable_intrs = qla24xx_enable_intrs, |
| 1510 | .disable_intrs = qla24xx_disable_intrs, |
| 1511 | .abort_command = qla24xx_abort_command, |
| 1512 | .target_reset = qla24xx_abort_target, |
| 1513 | .lun_reset = qla24xx_lun_reset, |
| 1514 | .fabric_login = qla24xx_login_fabric, |
| 1515 | .fabric_logout = qla24xx_fabric_logout, |
| 1516 | .calc_req_entries = NULL, |
| 1517 | .build_iocbs = NULL, |
| 1518 | .prep_ms_iocb = qla24xx_prep_ms_iocb, |
| 1519 | .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb, |
Andrew Vasquez | 3d79038 | 2009-03-24 09:08:14 -0700 | [diff] [blame] | 1520 | .read_nvram = NULL, |
| 1521 | .write_nvram = NULL, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 1522 | .fw_dump = qla81xx_fw_dump, |
| 1523 | .beacon_on = qla24xx_beacon_on, |
| 1524 | .beacon_off = qla24xx_beacon_off, |
| 1525 | .beacon_blink = qla24xx_beacon_blink, |
| 1526 | .read_optrom = qla25xx_read_optrom_data, |
| 1527 | .write_optrom = qla24xx_write_optrom_data, |
| 1528 | .get_flash_version = qla24xx_get_flash_version, |
| 1529 | .start_scsi = qla24xx_start_scsi, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 1530 | }; |
| 1531 | |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 1532 | static inline void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1533 | qla2x00_set_isp_flags(struct qla_hw_data *ha) |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 1534 | { |
| 1535 | ha->device_type = DT_EXTENDED_IDS; |
| 1536 | switch (ha->pdev->device) { |
| 1537 | case PCI_DEVICE_ID_QLOGIC_ISP2100: |
| 1538 | ha->device_type |= DT_ISP2100; |
| 1539 | ha->device_type &= ~DT_EXTENDED_IDS; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 1540 | ha->fw_srisc_address = RISC_START_ADDRESS_2100; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 1541 | break; |
| 1542 | case PCI_DEVICE_ID_QLOGIC_ISP2200: |
| 1543 | ha->device_type |= DT_ISP2200; |
| 1544 | ha->device_type &= ~DT_EXTENDED_IDS; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 1545 | ha->fw_srisc_address = RISC_START_ADDRESS_2100; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 1546 | break; |
| 1547 | case PCI_DEVICE_ID_QLOGIC_ISP2300: |
| 1548 | ha->device_type |= DT_ISP2300; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 1549 | ha->device_type |= DT_ZIO_SUPPORTED; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 1550 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 1551 | break; |
| 1552 | case PCI_DEVICE_ID_QLOGIC_ISP2312: |
| 1553 | ha->device_type |= DT_ISP2312; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 1554 | ha->device_type |= DT_ZIO_SUPPORTED; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 1555 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 1556 | break; |
| 1557 | case PCI_DEVICE_ID_QLOGIC_ISP2322: |
| 1558 | ha->device_type |= DT_ISP2322; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 1559 | ha->device_type |= DT_ZIO_SUPPORTED; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 1560 | if (ha->pdev->subsystem_vendor == 0x1028 && |
| 1561 | ha->pdev->subsystem_device == 0x0170) |
| 1562 | ha->device_type |= DT_OEM_001; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 1563 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 1564 | break; |
| 1565 | case PCI_DEVICE_ID_QLOGIC_ISP6312: |
| 1566 | ha->device_type |= DT_ISP6312; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 1567 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 1568 | break; |
| 1569 | case PCI_DEVICE_ID_QLOGIC_ISP6322: |
| 1570 | ha->device_type |= DT_ISP6322; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 1571 | ha->fw_srisc_address = RISC_START_ADDRESS_2300; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 1572 | break; |
| 1573 | case PCI_DEVICE_ID_QLOGIC_ISP2422: |
| 1574 | ha->device_type |= DT_ISP2422; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 1575 | ha->device_type |= DT_ZIO_SUPPORTED; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 1576 | ha->device_type |= DT_FWI2; |
Andrew Vasquez | c76f2c0 | 2007-07-19 15:05:57 -0700 | [diff] [blame] | 1577 | ha->device_type |= DT_IIDMA; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 1578 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 1579 | break; |
| 1580 | case PCI_DEVICE_ID_QLOGIC_ISP2432: |
| 1581 | ha->device_type |= DT_ISP2432; |
andrew.vasquez@qlogic.com | 4a59f71 | 2006-03-09 14:27:39 -0800 | [diff] [blame] | 1582 | ha->device_type |= DT_ZIO_SUPPORTED; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 1583 | ha->device_type |= DT_FWI2; |
Andrew Vasquez | c76f2c0 | 2007-07-19 15:05:57 -0700 | [diff] [blame] | 1584 | ha->device_type |= DT_IIDMA; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 1585 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 1586 | break; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 1587 | case PCI_DEVICE_ID_QLOGIC_ISP8432: |
| 1588 | ha->device_type |= DT_ISP8432; |
| 1589 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 1590 | ha->device_type |= DT_FWI2; |
| 1591 | ha->device_type |= DT_IIDMA; |
| 1592 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 1593 | break; |
andrew.vasquez@qlogic.com | 044cc6c | 2006-03-09 14:27:13 -0800 | [diff] [blame] | 1594 | case PCI_DEVICE_ID_QLOGIC_ISP5422: |
| 1595 | ha->device_type |= DT_ISP5422; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 1596 | ha->device_type |= DT_FWI2; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 1597 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 1598 | break; |
andrew.vasquez@qlogic.com | 044cc6c | 2006-03-09 14:27:13 -0800 | [diff] [blame] | 1599 | case PCI_DEVICE_ID_QLOGIC_ISP5432: |
| 1600 | ha->device_type |= DT_ISP5432; |
Andrew Vasquez | e428924 | 2007-07-19 15:05:56 -0700 | [diff] [blame] | 1601 | ha->device_type |= DT_FWI2; |
Andrew Vasquez | 441d107 | 2006-05-17 15:09:34 -0700 | [diff] [blame] | 1602 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 1603 | break; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1604 | case PCI_DEVICE_ID_QLOGIC_ISP2532: |
| 1605 | ha->device_type |= DT_ISP2532; |
| 1606 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 1607 | ha->device_type |= DT_FWI2; |
| 1608 | ha->device_type |= DT_IIDMA; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 1609 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 1610 | break; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 1611 | case PCI_DEVICE_ID_QLOGIC_ISP8001: |
| 1612 | ha->device_type |= DT_ISP8001; |
| 1613 | ha->device_type |= DT_ZIO_SUPPORTED; |
| 1614 | ha->device_type |= DT_FWI2; |
| 1615 | ha->device_type |= DT_IIDMA; |
| 1616 | ha->fw_srisc_address = RISC_START_ADDRESS_2400; |
| 1617 | break; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 1618 | } |
Anirban Chakraborty | e5b68a6 | 2009-04-06 22:33:50 -0700 | [diff] [blame] | 1619 | |
| 1620 | /* Get adapter physical port no from interrupt pin register. */ |
| 1621 | pci_read_config_byte(ha->pdev, PCI_INTERRUPT_PIN, &ha->port_no); |
| 1622 | if (ha->port_no & 1) |
| 1623 | ha->flags.port0 = 1; |
| 1624 | else |
| 1625 | ha->flags.port0 = 0; |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 1626 | } |
| 1627 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1628 | static int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1629 | qla2x00_iospace_config(struct qla_hw_data *ha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1630 | { |
Andrew Vasquez | 3776541 | 2008-01-17 09:02:09 -0800 | [diff] [blame] | 1631 | resource_size_t pio; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1632 | uint16_t msix; |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 1633 | int cpus; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1634 | |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 1635 | if (pci_request_selected_regions(ha->pdev, ha->bars, |
| 1636 | QLA2XXX_DRIVER_NAME)) { |
| 1637 | qla_printk(KERN_WARNING, ha, |
| 1638 | "Failed to reserve PIO/MMIO regions (%s)\n", |
| 1639 | pci_name(ha->pdev)); |
| 1640 | |
| 1641 | goto iospace_error_exit; |
| 1642 | } |
| 1643 | if (!(ha->bars & 1)) |
| 1644 | goto skip_pio; |
| 1645 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1646 | /* We only need PIO for Flash operations on ISP2312 v2 chips. */ |
| 1647 | pio = pci_resource_start(ha->pdev, 0); |
Andrew Vasquez | 3776541 | 2008-01-17 09:02:09 -0800 | [diff] [blame] | 1648 | if (pci_resource_flags(ha->pdev, 0) & IORESOURCE_IO) { |
| 1649 | if (pci_resource_len(ha->pdev, 0) < MIN_IOBASE_LEN) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1650 | qla_printk(KERN_WARNING, ha, |
| 1651 | "Invalid PCI I/O region size (%s)...\n", |
| 1652 | pci_name(ha->pdev)); |
| 1653 | pio = 0; |
| 1654 | } |
| 1655 | } else { |
| 1656 | qla_printk(KERN_WARNING, ha, |
| 1657 | "region #0 not a PIO resource (%s)...\n", |
| 1658 | pci_name(ha->pdev)); |
| 1659 | pio = 0; |
| 1660 | } |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 1661 | ha->pio_address = pio; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1662 | |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 1663 | skip_pio: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1664 | /* Use MMIO operations for all accesses. */ |
Andrew Vasquez | 3776541 | 2008-01-17 09:02:09 -0800 | [diff] [blame] | 1665 | if (!(pci_resource_flags(ha->pdev, 1) & IORESOURCE_MEM)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1666 | qla_printk(KERN_ERR, ha, |
Andrew Vasquez | 3776541 | 2008-01-17 09:02:09 -0800 | [diff] [blame] | 1667 | "region #1 not an MMIO resource (%s), aborting\n", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1668 | pci_name(ha->pdev)); |
| 1669 | goto iospace_error_exit; |
| 1670 | } |
Andrew Vasquez | 3776541 | 2008-01-17 09:02:09 -0800 | [diff] [blame] | 1671 | if (pci_resource_len(ha->pdev, 1) < MIN_IOBASE_LEN) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1672 | qla_printk(KERN_ERR, ha, |
| 1673 | "Invalid PCI mem region size (%s), aborting\n", |
| 1674 | pci_name(ha->pdev)); |
| 1675 | goto iospace_error_exit; |
| 1676 | } |
| 1677 | |
Andrew Vasquez | 3776541 | 2008-01-17 09:02:09 -0800 | [diff] [blame] | 1678 | ha->iobase = ioremap(pci_resource_start(ha->pdev, 1), MIN_IOBASE_LEN); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1679 | if (!ha->iobase) { |
| 1680 | qla_printk(KERN_ERR, ha, |
| 1681 | "cannot remap MMIO (%s), aborting\n", pci_name(ha->pdev)); |
| 1682 | |
| 1683 | goto iospace_error_exit; |
| 1684 | } |
| 1685 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1686 | /* Determine queue resources */ |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1687 | ha->max_req_queues = ha->max_rsp_queues = 1; |
Michael Hernandez | d84a47c | 2010-03-19 16:59:18 -0700 | [diff] [blame] | 1688 | if ((ql2xmaxqueues <= 1 && !ql2xmultique_tag) || |
| 1689 | (ql2xmaxqueues > 1 && ql2xmultique_tag) || |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1690 | (!IS_QLA25XX(ha) && !IS_QLA81XX(ha))) |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1691 | goto mqiobase_exit; |
Michael Hernandez | d84a47c | 2010-03-19 16:59:18 -0700 | [diff] [blame] | 1692 | |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1693 | ha->mqiobase = ioremap(pci_resource_start(ha->pdev, 3), |
| 1694 | pci_resource_len(ha->pdev, 3)); |
| 1695 | if (ha->mqiobase) { |
| 1696 | /* Read MSIX vector size of the board */ |
| 1697 | pci_read_config_word(ha->pdev, QLA_PCI_MSIX_CONTROL, &msix); |
| 1698 | ha->msix_count = msix; |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 1699 | /* Max queues are bounded by available msix vectors */ |
| 1700 | /* queue 0 uses two msix vectors */ |
| 1701 | if (ql2xmultique_tag) { |
| 1702 | cpus = num_online_cpus(); |
Anirban Chakraborty | 27dc9c5 | 2009-06-17 10:30:28 -0700 | [diff] [blame] | 1703 | ha->max_rsp_queues = (ha->msix_count - 1 > cpus) ? |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 1704 | (cpus + 1) : (ha->msix_count - 1); |
| 1705 | ha->max_req_queues = 2; |
| 1706 | } else if (ql2xmaxqueues > 1) { |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1707 | ha->max_req_queues = ql2xmaxqueues > QLA_MQ_SIZE ? |
| 1708 | QLA_MQ_SIZE : ql2xmaxqueues; |
| 1709 | DEBUG2(qla_printk(KERN_INFO, ha, "QoS mode set, max no" |
| 1710 | " of request queues:%d\n", ha->max_req_queues)); |
| 1711 | } |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 1712 | qla_printk(KERN_INFO, ha, |
| 1713 | "MSI-X vector count: %d\n", msix); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1714 | } else |
| 1715 | qla_printk(KERN_INFO, ha, "BAR 3 not enabled\n"); |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1716 | |
| 1717 | mqiobase_exit: |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1718 | ha->msix_count = ha->max_rsp_queues + 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1719 | return (0); |
| 1720 | |
| 1721 | iospace_error_exit: |
| 1722 | return (-ENOMEM); |
| 1723 | } |
| 1724 | |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 1725 | static void |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 1726 | qla2xxx_scan_start(struct Scsi_Host *shost) |
| 1727 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1728 | scsi_qla_host_t *vha = shost_priv(shost); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 1729 | |
Andrew Vasquez | cbc8eb6 | 2009-06-03 09:55:17 -0700 | [diff] [blame] | 1730 | if (vha->hw->flags.running_gold_fw) |
| 1731 | return; |
| 1732 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1733 | set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); |
| 1734 | set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); |
| 1735 | set_bit(RSCN_UPDATE, &vha->dpc_flags); |
| 1736 | set_bit(NPIV_CONFIG_NEEDED, &vha->dpc_flags); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 1737 | } |
| 1738 | |
| 1739 | static int |
| 1740 | qla2xxx_scan_finished(struct Scsi_Host *shost, unsigned long time) |
| 1741 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1742 | scsi_qla_host_t *vha = shost_priv(shost); |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 1743 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1744 | if (!vha->host) |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 1745 | return 1; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1746 | if (time > vha->hw->loop_reset_delay * HZ) |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 1747 | return 1; |
| 1748 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1749 | return atomic_read(&vha->loop_state) == LOOP_READY; |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 1750 | } |
| 1751 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1752 | /* |
| 1753 | * PCI driver interface |
| 1754 | */ |
Andrew Vasquez | 7ee6139 | 2006-06-23 16:11:22 -0700 | [diff] [blame] | 1755 | static int __devinit |
| 1756 | 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] | 1757 | { |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 1758 | int ret = -ENODEV; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1759 | struct Scsi_Host *host; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1760 | scsi_qla_host_t *base_vha = NULL; |
| 1761 | struct qla_hw_data *ha; |
Andrew Vasquez | 29856e2 | 2007-08-12 18:22:52 -0700 | [diff] [blame] | 1762 | char pci_info[30]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1763 | char fw_str[30]; |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 1764 | struct scsi_host_template *sht; |
Anirban Chakraborty | c51da4e | 2008-11-10 15:53:20 -0800 | [diff] [blame] | 1765 | int bars, max_id, mem_only = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1766 | uint16_t req_length = 0, rsp_length = 0; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1767 | struct req_que *req = NULL; |
| 1768 | struct rsp_que *rsp = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1769 | |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 1770 | bars = pci_select_bars(pdev, IORESOURCE_MEM | IORESOURCE_IO); |
Giridhar Malavali | a5326f8 | 2009-03-24 09:07:56 -0700 | [diff] [blame] | 1771 | sht = &qla2xxx_driver_template; |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 1772 | if (pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2422 || |
| 1773 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2432 || |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 1774 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8432 || |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 1775 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP5422 || |
| 1776 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP5432 || |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 1777 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2532 || |
| 1778 | pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8001) { |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 1779 | bars = pci_select_bars(pdev, IORESOURCE_MEM); |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 1780 | mem_only = 1; |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 1781 | } |
| 1782 | |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 1783 | if (mem_only) { |
| 1784 | if (pci_enable_device_mem(pdev)) |
| 1785 | goto probe_out; |
| 1786 | } else { |
| 1787 | if (pci_enable_device(pdev)) |
| 1788 | goto probe_out; |
| 1789 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1790 | |
Jesse Barnes | 0927678 | 2008-10-18 17:33:19 -0700 | [diff] [blame] | 1791 | /* This may fail but that's ok */ |
| 1792 | pci_enable_pcie_error_reporting(pdev); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 1793 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1794 | ha = kzalloc(sizeof(struct qla_hw_data), GFP_KERNEL); |
| 1795 | if (!ha) { |
| 1796 | DEBUG(printk("Unable to allocate memory for ha\n")); |
| 1797 | goto probe_out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1798 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1799 | ha->pdev = pdev; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1800 | |
| 1801 | /* Clear our data area */ |
Andrew Vasquez | 285d032 | 2007-10-19 15:59:17 -0700 | [diff] [blame] | 1802 | ha->bars = bars; |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 1803 | ha->mem_only = mem_only; |
Andrew Vasquez | df4bf0b | 2008-01-31 12:33:46 -0800 | [diff] [blame] | 1804 | spin_lock_init(&ha->hardware_lock); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1805 | |
andrew.vasquez@qlogic.com | ea5b638 | 2006-03-09 14:27:08 -0800 | [diff] [blame] | 1806 | /* Set ISP-type information. */ |
| 1807 | qla2x00_set_isp_flags(ha); |
Duane Grigsby | ca79cf6 | 2009-12-15 21:29:47 -0800 | [diff] [blame] | 1808 | |
| 1809 | /* Set EEH reset type to fundamental if required by hba */ |
| 1810 | if ( IS_QLA24XX(ha) || IS_QLA25XX(ha) || IS_QLA81XX(ha)) { |
| 1811 | pdev->needs_freset = 1; |
Duane Grigsby | ca79cf6 | 2009-12-15 21:29:47 -0800 | [diff] [blame] | 1812 | } |
| 1813 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1814 | /* Configure PCI I/O space */ |
| 1815 | ret = qla2x00_iospace_config(ha); |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 1816 | if (ret) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1817 | goto probe_hw_failed; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1818 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1819 | qla_printk(KERN_INFO, ha, |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 1820 | "Found an ISP%04X, irq %d, iobase 0x%p\n", pdev->device, pdev->irq, |
| 1821 | ha->iobase); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1822 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1823 | ha->prev_topology = 0; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 1824 | ha->init_cb_size = sizeof(init_cb_t); |
Andrew Vasquez | d8b4521 | 2006-10-02 12:00:43 -0700 | [diff] [blame] | 1825 | ha->link_data_rate = PORT_SPEED_UNKNOWN; |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 1826 | ha->optrom_size = OPTROM_SIZE_2300; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1827 | |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 1828 | /* Assign ISP specific operations. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1829 | max_id = MAX_TARGETS_2200; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1830 | if (IS_QLA2100(ha)) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1831 | max_id = MAX_TARGETS_2100; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1832 | ha->mbx_count = MAILBOX_REGISTER_COUNT_2100; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1833 | req_length = REQUEST_ENTRY_CNT_2100; |
| 1834 | rsp_length = RESPONSE_ENTRY_CNT_2100; |
| 1835 | ha->max_loop_id = SNS_LAST_LOOP_ID_2100; |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 1836 | ha->gid_list_info_size = 4; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 1837 | ha->flash_conf_off = ~0; |
| 1838 | ha->flash_data_off = ~0; |
| 1839 | ha->nvram_conf_off = ~0; |
| 1840 | ha->nvram_data_off = ~0; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1841 | ha->isp_ops = &qla2100_isp_ops; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1842 | } else if (IS_QLA2200(ha)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1843 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1844 | req_length = REQUEST_ENTRY_CNT_2200; |
| 1845 | rsp_length = RESPONSE_ENTRY_CNT_2100; |
| 1846 | ha->max_loop_id = SNS_LAST_LOOP_ID_2100; |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 1847 | ha->gid_list_info_size = 4; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 1848 | ha->flash_conf_off = ~0; |
| 1849 | ha->flash_data_off = ~0; |
| 1850 | ha->nvram_conf_off = ~0; |
| 1851 | ha->nvram_data_off = ~0; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1852 | ha->isp_ops = &qla2100_isp_ops; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 1853 | } else if (IS_QLA23XX(ha)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1854 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1855 | req_length = REQUEST_ENTRY_CNT_2200; |
| 1856 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
| 1857 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
Andrew Vasquez | abbd887 | 2005-07-06 10:30:05 -0700 | [diff] [blame] | 1858 | ha->gid_list_info_size = 6; |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 1859 | if (IS_QLA2322(ha) || IS_QLA6322(ha)) |
| 1860 | ha->optrom_size = OPTROM_SIZE_2322; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 1861 | ha->flash_conf_off = ~0; |
| 1862 | ha->flash_data_off = ~0; |
| 1863 | ha->nvram_conf_off = ~0; |
| 1864 | ha->nvram_data_off = ~0; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1865 | ha->isp_ops = &qla2300_isp_ops; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 1866 | } else if (IS_QLA24XX_TYPE(ha)) { |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 1867 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1868 | req_length = REQUEST_ENTRY_CNT_24XX; |
| 1869 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
| 1870 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1871 | ha->init_cb_size = sizeof(struct mid_init_cb_24xx); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 1872 | ha->gid_list_info_size = 8; |
andrew.vasquez@qlogic.com | 854165f | 2006-01-31 16:05:17 -0800 | [diff] [blame] | 1873 | ha->optrom_size = OPTROM_SIZE_24XX; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1874 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA24XX; |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 1875 | ha->isp_ops = &qla24xx_isp_ops; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 1876 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF; |
| 1877 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA; |
| 1878 | ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF; |
| 1879 | ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1880 | } else if (IS_QLA25XX(ha)) { |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1881 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1882 | req_length = REQUEST_ENTRY_CNT_24XX; |
| 1883 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
| 1884 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1885 | ha->init_cb_size = sizeof(struct mid_init_cb_24xx); |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1886 | ha->gid_list_info_size = 8; |
| 1887 | ha->optrom_size = OPTROM_SIZE_25XX; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1888 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 1889 | ha->isp_ops = &qla25xx_isp_ops; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 1890 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF; |
| 1891 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA; |
| 1892 | ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF; |
| 1893 | ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA; |
| 1894 | } else if (IS_QLA81XX(ha)) { |
| 1895 | ha->mbx_count = MAILBOX_REGISTER_COUNT; |
| 1896 | req_length = REQUEST_ENTRY_CNT_24XX; |
| 1897 | rsp_length = RESPONSE_ENTRY_CNT_2300; |
| 1898 | ha->max_loop_id = SNS_LAST_LOOP_ID_2300; |
| 1899 | ha->init_cb_size = sizeof(struct mid_init_cb_81xx); |
| 1900 | ha->gid_list_info_size = 8; |
| 1901 | ha->optrom_size = OPTROM_SIZE_81XX; |
Anirban Chakraborty | 40859ae | 2009-06-03 09:55:16 -0700 | [diff] [blame] | 1902 | ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 1903 | ha->isp_ops = &qla81xx_isp_ops; |
| 1904 | ha->flash_conf_off = FARX_ACCESS_FLASH_CONF_81XX; |
| 1905 | ha->flash_data_off = FARX_ACCESS_FLASH_DATA_81XX; |
| 1906 | ha->nvram_conf_off = ~0; |
| 1907 | ha->nvram_data_off = ~0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1908 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1909 | |
matthias@kaehlcke.net | 6c2f527 | 2008-05-12 22:21:11 -0700 | [diff] [blame] | 1910 | mutex_init(&ha->vport_lock); |
Marcus Barrow | 0b05a1f | 2008-01-17 09:02:13 -0800 | [diff] [blame] | 1911 | init_completion(&ha->mbx_cmd_comp); |
| 1912 | complete(&ha->mbx_cmd_comp); |
| 1913 | init_completion(&ha->mbx_intr_comp); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1914 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 1915 | set_bit(0, (unsigned long *) ha->vp_idx_map); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1916 | |
Andrew Vasquez | 53303c4 | 2009-01-22 09:45:37 -0800 | [diff] [blame] | 1917 | qla2x00_config_dma_addressing(ha); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1918 | ret = qla2x00_mem_alloc(ha, req_length, rsp_length, &req, &rsp); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1919 | if (!ret) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1920 | qla_printk(KERN_WARNING, ha, |
| 1921 | "[ERROR] Failed to allocate memory for adapter\n"); |
| 1922 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1923 | goto probe_hw_failed; |
| 1924 | } |
| 1925 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1926 | req->max_q_depth = MAX_Q_DEPTH; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1927 | if (ql2xmaxqdepth != 0 && ql2xmaxqdepth <= 0xffffU) |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1928 | req->max_q_depth = ql2xmaxqdepth; |
| 1929 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1930 | |
| 1931 | base_vha = qla2x00_create_host(sht, ha); |
| 1932 | if (!base_vha) { |
| 1933 | qla_printk(KERN_WARNING, ha, |
| 1934 | "[ERROR] Failed to allocate memory for scsi_host\n"); |
| 1935 | |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 1936 | ret = -ENOMEM; |
Anirban Chakraborty | 6e9f21f | 2009-01-22 09:45:28 -0800 | [diff] [blame] | 1937 | qla2x00_mem_free(ha); |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1938 | qla2x00_free_req_que(ha, req); |
| 1939 | qla2x00_free_rsp_que(ha, rsp); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1940 | goto probe_hw_failed; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1941 | } |
| 1942 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1943 | pci_set_drvdata(pdev, base_vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1944 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1945 | host = base_vha->host; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1946 | base_vha->req = req; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1947 | host->can_queue = req->length + 128; |
| 1948 | if (IS_QLA2XXX_MIDTYPE(ha)) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1949 | base_vha->mgmt_svr_loop_id = 10 + base_vha->vp_idx; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1950 | else |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1951 | base_vha->mgmt_svr_loop_id = MANAGEMENT_SERVER + |
| 1952 | base_vha->vp_idx; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1953 | if (IS_QLA2100(ha)) |
| 1954 | host->sg_tablesize = 32; |
| 1955 | host->max_id = max_id; |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 1956 | host->this_id = 255; |
| 1957 | host->cmd_per_lun = 3; |
Seokmann Ju | 711c1d9 | 2008-07-10 16:55:51 -0700 | [diff] [blame] | 1958 | host->unique_id = host->host_no; |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 1959 | host->max_cmd_len = MAX_CMDSZ; |
Andrew Vasquez | 75bc419 | 2006-05-17 15:09:22 -0700 | [diff] [blame] | 1960 | host->max_channel = MAX_BUSES - 1; |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 1961 | host->max_lun = MAX_LUNS; |
| 1962 | host->transportt = qla2xxx_transport_template; |
Giridhar Malavali | 9a069e1 | 2010-01-12 13:02:47 -0800 | [diff] [blame] | 1963 | sht->vendor_id = (SCSI_NL_VID_TYPE_PCI | PCI_VENDOR_ID_QLOGIC); |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 1964 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1965 | /* Set up the irqs */ |
| 1966 | ret = qla2x00_request_irqs(ha, rsp); |
| 1967 | if (ret) |
Anirban Chakraborty | 6e9f21f | 2009-01-22 09:45:28 -0800 | [diff] [blame] | 1968 | goto probe_init_failed; |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 1969 | |
| 1970 | pci_save_state(pdev); |
| 1971 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1972 | /* Alloc arrays of request and response ring ptrs */ |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 1973 | que_init: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1974 | if (!qla2x00_alloc_queues(ha)) { |
| 1975 | qla_printk(KERN_WARNING, ha, |
| 1976 | "[ERROR] Failed to allocate memory for queue" |
| 1977 | " pointers\n"); |
Anirban Chakraborty | 6e9f21f | 2009-01-22 09:45:28 -0800 | [diff] [blame] | 1978 | goto probe_init_failed; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 1979 | } |
| 1980 | ha->rsp_q_map[0] = rsp; |
| 1981 | ha->req_q_map[0] = req; |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 1982 | rsp->req = req; |
| 1983 | req->rsp = rsp; |
| 1984 | set_bit(0, ha->req_qid_map); |
| 1985 | set_bit(0, ha->rsp_qid_map); |
Andrew Vasquez | 0802999 | 2009-03-24 09:07:55 -0700 | [diff] [blame] | 1986 | /* FWI2-capable only. */ |
| 1987 | req->req_q_in = &ha->iobase->isp24.req_q_in; |
| 1988 | req->req_q_out = &ha->iobase->isp24.req_q_out; |
| 1989 | rsp->rsp_q_in = &ha->iobase->isp24.rsp_q_in; |
| 1990 | rsp->rsp_q_out = &ha->iobase->isp24.rsp_q_out; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1991 | if (ha->mqenable) { |
Andrew Vasquez | 0802999 | 2009-03-24 09:07:55 -0700 | [diff] [blame] | 1992 | req->req_q_in = &ha->mqiobase->isp25mq.req_q_in; |
| 1993 | req->req_q_out = &ha->mqiobase->isp25mq.req_q_out; |
| 1994 | rsp->rsp_q_in = &ha->mqiobase->isp25mq.rsp_q_in; |
| 1995 | rsp->rsp_q_out = &ha->mqiobase->isp25mq.rsp_q_out; |
Anirban Chakraborty | 17d9863 | 2008-12-18 10:06:15 -0800 | [diff] [blame] | 1996 | } |
| 1997 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 1998 | if (qla2x00_initialize_adapter(base_vha)) { |
| 1999 | qla_printk(KERN_WARNING, ha, |
| 2000 | "Failed to initialize adapter\n"); |
| 2001 | |
| 2002 | DEBUG2(printk("scsi(%ld): Failed to initialize adapter - " |
| 2003 | "Adapter flags %x.\n", |
| 2004 | base_vha->host_no, base_vha->device_flags)); |
| 2005 | |
| 2006 | ret = -ENODEV; |
| 2007 | goto probe_failed; |
| 2008 | } |
| 2009 | |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 2010 | if (ha->mqenable) { |
| 2011 | if (qla25xx_setup_mode(base_vha)) { |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 2012 | qla_printk(KERN_WARNING, ha, |
| 2013 | "Can't create queues, falling back to single" |
| 2014 | " queue mode\n"); |
Anirban Chakraborty | 7163ea8 | 2009-08-05 09:18:40 -0700 | [diff] [blame] | 2015 | goto que_init; |
| 2016 | } |
| 2017 | } |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 2018 | |
Andrew Vasquez | cbc8eb6 | 2009-06-03 09:55:17 -0700 | [diff] [blame] | 2019 | if (ha->flags.running_gold_fw) |
| 2020 | goto skip_dpc; |
| 2021 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2022 | /* |
| 2023 | * Startup the kernel thread for this host adapter |
| 2024 | */ |
| 2025 | ha->dpc_thread = kthread_create(qla2x00_do_dpc, ha, |
| 2026 | "%s_dpc", base_vha->host_str); |
| 2027 | if (IS_ERR(ha->dpc_thread)) { |
| 2028 | qla_printk(KERN_WARNING, ha, |
| 2029 | "Unable to start DPC thread!\n"); |
| 2030 | ret = PTR_ERR(ha->dpc_thread); |
| 2031 | goto probe_failed; |
| 2032 | } |
| 2033 | |
Andrew Vasquez | cbc8eb6 | 2009-06-03 09:55:17 -0700 | [diff] [blame] | 2034 | skip_dpc: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2035 | list_add_tail(&base_vha->list, &ha->vp_list); |
| 2036 | base_vha->host->irq = ha->pdev->irq; |
| 2037 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2038 | /* Initialized the timer */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2039 | qla2x00_start_timer(base_vha, qla2x00_timer, WATCH_INTERVAL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2040 | |
| 2041 | DEBUG2(printk("DEBUG: detect hba %ld at address = %p\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2042 | base_vha->host_no, ha)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2043 | |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2044 | ret = scsi_add_host(host, &pdev->dev); |
| 2045 | if (ret) |
| 2046 | goto probe_failed; |
| 2047 | |
Michael Reed | 1486400 | 2009-12-02 09:11:16 -0600 | [diff] [blame] | 2048 | base_vha->flags.init_done = 1; |
| 2049 | base_vha->flags.online = 1; |
| 2050 | |
Andrew Vasquez | 048feec | 2008-09-11 22:19:45 -0700 | [diff] [blame] | 2051 | ha->isp_ops->enable_intrs(ha); |
| 2052 | |
Andrew Vasquez | 1e99e33 | 2006-11-22 08:24:48 -0800 | [diff] [blame] | 2053 | scsi_scan_host(host); |
| 2054 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2055 | qla2x00_alloc_sysfs_attr(base_vha); |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2056 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2057 | qla2x00_init_host_attr(base_vha); |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2058 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2059 | qla2x00_dfs_setup(base_vha); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 2060 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2061 | qla_printk(KERN_INFO, ha, "\n" |
| 2062 | " QLogic Fibre Channel HBA Driver: %s\n" |
| 2063 | " QLogic %s - %s\n" |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 2064 | " ISP%04X: %s @ %s hdma%c, host#=%ld, fw=%s\n", |
| 2065 | qla2x00_version_str, ha->model_number, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2066 | ha->model_desc ? ha->model_desc : "", pdev->device, |
| 2067 | ha->isp_ops->pci_info_str(base_vha, pci_info), pci_name(pdev), |
| 2068 | ha->flags.enable_64bit_addressing ? '+' : '-', base_vha->host_no, |
| 2069 | ha->isp_ops->fw_version_str(base_vha, fw_str)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2070 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2071 | return 0; |
| 2072 | |
Anirban Chakraborty | 6e9f21f | 2009-01-22 09:45:28 -0800 | [diff] [blame] | 2073 | probe_init_failed: |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2074 | qla2x00_free_req_que(ha, req); |
| 2075 | qla2x00_free_rsp_que(ha, rsp); |
| 2076 | ha->max_req_queues = ha->max_rsp_queues = 0; |
Anirban Chakraborty | 6e9f21f | 2009-01-22 09:45:28 -0800 | [diff] [blame] | 2077 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2078 | probe_failed: |
Andrew Vasquez | b997876 | 2009-03-24 09:08:05 -0700 | [diff] [blame] | 2079 | if (base_vha->timer_active) |
| 2080 | qla2x00_stop_timer(base_vha); |
| 2081 | base_vha->flags.online = 0; |
| 2082 | if (ha->dpc_thread) { |
| 2083 | struct task_struct *t = ha->dpc_thread; |
| 2084 | |
| 2085 | ha->dpc_thread = NULL; |
| 2086 | kthread_stop(t); |
| 2087 | } |
| 2088 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2089 | qla2x00_free_device(base_vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2090 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2091 | scsi_host_put(base_vha->host); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2092 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2093 | probe_hw_failed: |
| 2094 | if (ha->iobase) |
| 2095 | iounmap(ha->iobase); |
| 2096 | |
| 2097 | pci_release_selected_regions(ha->pdev, ha->bars); |
| 2098 | kfree(ha); |
| 2099 | ha = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2100 | |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2101 | probe_out: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2102 | pci_disable_device(pdev); |
Andrew Vasquez | a1541d5 | 2005-06-09 17:21:28 -0700 | [diff] [blame] | 2103 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2104 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2105 | |
Adrian Bunk | 4c993f7 | 2008-01-14 00:55:16 -0800 | [diff] [blame] | 2106 | static void |
Andrew Vasquez | 7ee6139 | 2006-06-23 16:11:22 -0700 | [diff] [blame] | 2107 | qla2x00_remove_one(struct pci_dev *pdev) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2108 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2109 | scsi_qla_host_t *base_vha, *vha, *temp; |
| 2110 | struct qla_hw_data *ha; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2111 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2112 | base_vha = pci_get_drvdata(pdev); |
| 2113 | ha = base_vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2114 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2115 | list_for_each_entry_safe(vha, temp, &ha->vp_list, list) { |
| 2116 | if (vha && vha->fc_vport) |
| 2117 | fc_vport_terminate(vha->fc_vport); |
| 2118 | } |
Andrew Vasquez | c795c1e | 2008-08-13 21:37:01 -0700 | [diff] [blame] | 2119 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2120 | set_bit(UNLOADING, &base_vha->dpc_flags); |
Andrew Vasquez | c795c1e | 2008-08-13 21:37:01 -0700 | [diff] [blame] | 2121 | |
Andrew Vasquez | b997876 | 2009-03-24 09:08:05 -0700 | [diff] [blame] | 2122 | qla2x00_abort_all_cmds(base_vha, DID_NO_CONNECT << 16); |
| 2123 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2124 | qla2x00_dfs_remove(base_vha); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 2125 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2126 | qla84xx_put_chip(base_vha); |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 2127 | |
Andrew Vasquez | b997876 | 2009-03-24 09:08:05 -0700 | [diff] [blame] | 2128 | /* Disable timer */ |
| 2129 | if (base_vha->timer_active) |
| 2130 | qla2x00_stop_timer(base_vha); |
| 2131 | |
| 2132 | base_vha->flags.online = 0; |
| 2133 | |
Anirban Chakraborty | 68ca949 | 2009-04-06 22:33:41 -0700 | [diff] [blame] | 2134 | /* Flush the work queue and remove it */ |
| 2135 | if (ha->wq) { |
| 2136 | flush_workqueue(ha->wq); |
| 2137 | destroy_workqueue(ha->wq); |
| 2138 | ha->wq = NULL; |
| 2139 | } |
| 2140 | |
Andrew Vasquez | b997876 | 2009-03-24 09:08:05 -0700 | [diff] [blame] | 2141 | /* Kill the kernel thread for this host */ |
| 2142 | if (ha->dpc_thread) { |
| 2143 | struct task_struct *t = ha->dpc_thread; |
| 2144 | |
| 2145 | /* |
| 2146 | * qla2xxx_wake_dpc checks for ->dpc_thread |
| 2147 | * so we need to zero it out. |
| 2148 | */ |
| 2149 | ha->dpc_thread = NULL; |
| 2150 | kthread_stop(t); |
| 2151 | } |
| 2152 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2153 | qla2x00_free_sysfs_attr(base_vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2154 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2155 | fc_remove_host(base_vha->host); |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 2156 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2157 | scsi_remove_host(base_vha->host); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2158 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2159 | qla2x00_free_device(base_vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2160 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2161 | scsi_host_put(base_vha->host); |
| 2162 | |
| 2163 | if (ha->iobase) |
| 2164 | iounmap(ha->iobase); |
| 2165 | |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2166 | if (ha->mqiobase) |
| 2167 | iounmap(ha->mqiobase); |
| 2168 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2169 | pci_release_selected_regions(ha->pdev, ha->bars); |
| 2170 | kfree(ha); |
| 2171 | ha = NULL; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2172 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 2173 | pci_disable_pcie_error_reporting(pdev); |
| 2174 | |
Bernhard Walle | 665db93 | 2007-03-28 00:49:49 +0200 | [diff] [blame] | 2175 | pci_disable_device(pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2176 | pci_set_drvdata(pdev, NULL); |
| 2177 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2178 | |
| 2179 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2180 | qla2x00_free_device(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2181 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2182 | struct qla_hw_data *ha = vha->hw; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2183 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 2184 | qla2x00_abort_all_cmds(vha, DID_NO_CONNECT << 16); |
| 2185 | |
| 2186 | /* Disable timer */ |
| 2187 | if (vha->timer_active) |
| 2188 | qla2x00_stop_timer(vha); |
| 2189 | |
| 2190 | /* Kill the kernel thread for this host */ |
| 2191 | if (ha->dpc_thread) { |
| 2192 | struct task_struct *t = ha->dpc_thread; |
| 2193 | |
| 2194 | /* |
| 2195 | * qla2xxx_wake_dpc checks for ->dpc_thread |
| 2196 | * so we need to zero it out. |
| 2197 | */ |
| 2198 | ha->dpc_thread = NULL; |
| 2199 | kthread_stop(t); |
| 2200 | } |
| 2201 | |
Anirban Chakraborty | 2afa19a | 2009-04-06 22:33:40 -0700 | [diff] [blame] | 2202 | qla25xx_delete_queues(vha); |
| 2203 | |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 2204 | if (ha->flags.fce_enabled) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2205 | qla2x00_disable_fce_trace(vha, NULL, NULL); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 2206 | |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 2207 | if (ha->eft) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2208 | qla2x00_disable_eft_trace(vha); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 2209 | |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 2210 | /* Stop currently executing firmware. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2211 | qla2x00_try_to_stop_firmware(vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2212 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 2213 | vha->flags.online = 0; |
| 2214 | |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 2215 | /* turn-off interrupts on the card */ |
| 2216 | if (ha->interrupts_on) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2217 | ha->isp_ops->disable_intrs(ha); |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 2218 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2219 | qla2x00_free_irqs(vha); |
| 2220 | |
Andrew Vasquez | f6ef3b1 | 2005-08-26 19:10:20 -0700 | [diff] [blame] | 2221 | qla2x00_mem_free(ha); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2222 | |
| 2223 | qla2x00_free_queues(ha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2224 | } |
| 2225 | |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 2226 | static inline void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2227 | 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] | 2228 | int defer) |
| 2229 | { |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 2230 | struct fc_rport *rport; |
Andrew Vasquez | 67becc0 | 2009-08-25 11:36:20 -0700 | [diff] [blame] | 2231 | scsi_qla_host_t *base_vha; |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 2232 | |
| 2233 | if (!fcport->rport) |
| 2234 | return; |
| 2235 | |
| 2236 | rport = fcport->rport; |
| 2237 | if (defer) { |
Andrew Vasquez | 67becc0 | 2009-08-25 11:36:20 -0700 | [diff] [blame] | 2238 | base_vha = pci_get_drvdata(vha->hw->pdev); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2239 | spin_lock_irq(vha->host->host_lock); |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 2240 | fcport->drport = rport; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2241 | spin_unlock_irq(vha->host->host_lock); |
Andrew Vasquez | 67becc0 | 2009-08-25 11:36:20 -0700 | [diff] [blame] | 2242 | set_bit(FCPORT_UPDATE_NEEDED, &base_vha->dpc_flags); |
| 2243 | qla2xxx_wake_dpc(base_vha); |
Seokmann Ju | 5f3a9a2 | 2008-07-10 16:55:47 -0700 | [diff] [blame] | 2244 | } else |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 2245 | fc_remote_port_delete(rport); |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 2246 | } |
| 2247 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2248 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2249 | * qla2x00_mark_device_lost Updates fcport state when device goes offline. |
| 2250 | * |
| 2251 | * Input: ha = adapter block pointer. fcport = port structure pointer. |
| 2252 | * |
| 2253 | * Return: None. |
| 2254 | * |
| 2255 | * Context: |
| 2256 | */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2257 | 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] | 2258 | int do_login, int defer) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2259 | { |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2260 | if (atomic_read(&fcport->state) == FCS_ONLINE && |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2261 | vha->vp_idx == fcport->vp_idx) { |
| 2262 | atomic_set(&fcport->state, FCS_DEVICE_LOST); |
| 2263 | qla2x00_schedule_rport_del(vha, fcport, defer); |
| 2264 | } |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 2265 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2266 | * We may need to retry the login, so don't change the state of the |
| 2267 | * port but do the retries. |
| 2268 | */ |
| 2269 | if (atomic_read(&fcport->state) != FCS_DEVICE_DEAD) |
| 2270 | atomic_set(&fcport->state, FCS_DEVICE_LOST); |
| 2271 | |
| 2272 | if (!do_login) |
| 2273 | return; |
| 2274 | |
| 2275 | if (fcport->login_retry == 0) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2276 | fcport->login_retry = vha->hw->login_retry_count; |
| 2277 | set_bit(RELOGIN_NEEDED, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2278 | |
| 2279 | DEBUG(printk("scsi(%ld): Port login retry: " |
| 2280 | "%02x%02x%02x%02x%02x%02x%02x%02x, " |
| 2281 | "id = 0x%04x retry cnt=%d\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2282 | vha->host_no, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2283 | fcport->port_name[0], |
| 2284 | fcport->port_name[1], |
| 2285 | fcport->port_name[2], |
| 2286 | fcport->port_name[3], |
| 2287 | fcport->port_name[4], |
| 2288 | fcport->port_name[5], |
| 2289 | fcport->port_name[6], |
| 2290 | fcport->port_name[7], |
| 2291 | fcport->loop_id, |
| 2292 | fcport->login_retry)); |
| 2293 | } |
| 2294 | } |
| 2295 | |
| 2296 | /* |
| 2297 | * qla2x00_mark_all_devices_lost |
| 2298 | * Updates fcport state when device goes offline. |
| 2299 | * |
| 2300 | * Input: |
| 2301 | * ha = adapter block pointer. |
| 2302 | * fcport = port structure pointer. |
| 2303 | * |
| 2304 | * Return: |
| 2305 | * None. |
| 2306 | * |
| 2307 | * Context: |
| 2308 | */ |
| 2309 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2310 | qla2x00_mark_all_devices_lost(scsi_qla_host_t *vha, int defer) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2311 | { |
| 2312 | fc_port_t *fcport; |
| 2313 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2314 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 2315 | if (vha->vp_idx != 0 && vha->vp_idx != fcport->vp_idx) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2316 | continue; |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 2317 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2318 | /* |
| 2319 | * No point in marking the device as lost, if the device is |
| 2320 | * already DEAD. |
| 2321 | */ |
| 2322 | if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD) |
| 2323 | continue; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2324 | if (atomic_read(&fcport->state) == FCS_ONLINE) { |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 2325 | if (defer) |
| 2326 | qla2x00_schedule_rport_del(vha, fcport, defer); |
| 2327 | else if (vha->vp_idx == fcport->vp_idx) |
| 2328 | qla2x00_schedule_rport_del(vha, fcport, defer); |
| 2329 | } |
| 2330 | atomic_set(&fcport->state, FCS_DEVICE_LOST); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2331 | } |
| 2332 | } |
| 2333 | |
| 2334 | /* |
| 2335 | * qla2x00_mem_alloc |
| 2336 | * Allocates adapter memory. |
| 2337 | * |
| 2338 | * Returns: |
| 2339 | * 0 = success. |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 2340 | * !0 = failure. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2341 | */ |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 2342 | static int |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2343 | qla2x00_mem_alloc(struct qla_hw_data *ha, uint16_t req_len, uint16_t rsp_len, |
| 2344 | struct req_que **req, struct rsp_que **rsp) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2345 | { |
| 2346 | char name[16]; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2347 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 2348 | 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] | 2349 | &ha->init_cb_dma, GFP_KERNEL); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 2350 | if (!ha->init_cb) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2351 | goto fail; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2352 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2353 | ha->gid_list = dma_alloc_coherent(&ha->pdev->dev, GID_LIST_SIZE, |
| 2354 | &ha->gid_list_dma, GFP_KERNEL); |
| 2355 | if (!ha->gid_list) |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 2356 | goto fail_free_init_cb; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2357 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 2358 | ha->srb_mempool = mempool_create_slab_pool(SRB_MIN_REQ, srb_cachep); |
| 2359 | if (!ha->srb_mempool) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2360 | goto fail_free_gid_list; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2361 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 2362 | /* Get memory for cached NVRAM */ |
| 2363 | ha->nvram = kzalloc(MAX_NVRAM_SIZE, GFP_KERNEL); |
| 2364 | if (!ha->nvram) |
| 2365 | goto fail_free_srb_mempool; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2366 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2367 | snprintf(name, sizeof(name), "%s_%d", QLA2XXX_DRIVER_NAME, |
| 2368 | ha->pdev->device); |
| 2369 | ha->s_dma_pool = dma_pool_create(name, &ha->pdev->dev, |
| 2370 | DMA_POOL_SIZE, 8, 0); |
| 2371 | if (!ha->s_dma_pool) |
| 2372 | goto fail_free_nvram; |
| 2373 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 2374 | /* Allocate memory for SNS commands */ |
| 2375 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2376 | /* Get consistent memory allocated for SNS commands */ |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 2377 | ha->sns_cmd = dma_alloc_coherent(&ha->pdev->dev, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2378 | sizeof(struct sns_cmd_pkt), &ha->sns_cmd_dma, GFP_KERNEL); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 2379 | if (!ha->sns_cmd) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2380 | goto fail_dma_pool; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 2381 | } else { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2382 | /* Get consistent memory allocated for MS IOCB */ |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 2383 | ha->ms_iocb = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2384 | &ha->ms_iocb_dma); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 2385 | if (!ha->ms_iocb) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2386 | goto fail_dma_pool; |
| 2387 | /* Get consistent memory allocated for CT SNS commands */ |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 2388 | ha->ct_sns = dma_alloc_coherent(&ha->pdev->dev, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2389 | sizeof(struct ct_sns_pkt), &ha->ct_sns_dma, GFP_KERNEL); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 2390 | if (!ha->ct_sns) |
| 2391 | goto fail_free_ms_iocb; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2392 | } |
| 2393 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2394 | /* Allocate memory for request ring */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2395 | *req = kzalloc(sizeof(struct req_que), GFP_KERNEL); |
| 2396 | if (!*req) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2397 | DEBUG(printk("Unable to allocate memory for req\n")); |
| 2398 | goto fail_req; |
| 2399 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2400 | (*req)->length = req_len; |
| 2401 | (*req)->ring = dma_alloc_coherent(&ha->pdev->dev, |
| 2402 | ((*req)->length + 1) * sizeof(request_t), |
| 2403 | &(*req)->dma, GFP_KERNEL); |
| 2404 | if (!(*req)->ring) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2405 | DEBUG(printk("Unable to allocate memory for req_ring\n")); |
| 2406 | goto fail_req_ring; |
| 2407 | } |
| 2408 | /* Allocate memory for response ring */ |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2409 | *rsp = kzalloc(sizeof(struct rsp_que), GFP_KERNEL); |
| 2410 | if (!*rsp) { |
| 2411 | qla_printk(KERN_WARNING, ha, |
| 2412 | "Unable to allocate memory for rsp\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2413 | goto fail_rsp; |
| 2414 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2415 | (*rsp)->hw = ha; |
| 2416 | (*rsp)->length = rsp_len; |
| 2417 | (*rsp)->ring = dma_alloc_coherent(&ha->pdev->dev, |
| 2418 | ((*rsp)->length + 1) * sizeof(response_t), |
| 2419 | &(*rsp)->dma, GFP_KERNEL); |
| 2420 | if (!(*rsp)->ring) { |
| 2421 | qla_printk(KERN_WARNING, ha, |
| 2422 | "Unable to allocate memory for rsp_ring\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2423 | goto fail_rsp_ring; |
| 2424 | } |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2425 | (*req)->rsp = *rsp; |
| 2426 | (*rsp)->req = *req; |
| 2427 | /* Allocate memory for NVRAM data for vports */ |
| 2428 | if (ha->nvram_npiv_size) { |
| 2429 | ha->npiv_info = kzalloc(sizeof(struct qla_npiv_entry) * |
| 2430 | ha->nvram_npiv_size, GFP_KERNEL); |
| 2431 | if (!ha->npiv_info) { |
| 2432 | qla_printk(KERN_WARNING, ha, |
| 2433 | "Unable to allocate memory for npiv info\n"); |
| 2434 | goto fail_npiv_info; |
| 2435 | } |
| 2436 | } else |
| 2437 | ha->npiv_info = NULL; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2438 | |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 2439 | /* Get consistent memory allocated for EX-INIT-CB. */ |
| 2440 | if (IS_QLA81XX(ha)) { |
| 2441 | ha->ex_init_cb = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL, |
| 2442 | &ha->ex_init_cb_dma); |
| 2443 | if (!ha->ex_init_cb) |
| 2444 | goto fail_ex_init_cb; |
| 2445 | } |
| 2446 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2447 | INIT_LIST_HEAD(&ha->vp_list); |
| 2448 | return 1; |
| 2449 | |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 2450 | fail_ex_init_cb: |
| 2451 | kfree(ha->npiv_info); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2452 | fail_npiv_info: |
| 2453 | dma_free_coherent(&ha->pdev->dev, ((*rsp)->length + 1) * |
| 2454 | sizeof(response_t), (*rsp)->ring, (*rsp)->dma); |
| 2455 | (*rsp)->ring = NULL; |
| 2456 | (*rsp)->dma = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2457 | fail_rsp_ring: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2458 | kfree(*rsp); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2459 | fail_rsp: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2460 | dma_free_coherent(&ha->pdev->dev, ((*req)->length + 1) * |
| 2461 | sizeof(request_t), (*req)->ring, (*req)->dma); |
| 2462 | (*req)->ring = NULL; |
| 2463 | (*req)->dma = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2464 | fail_req_ring: |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2465 | kfree(*req); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2466 | fail_req: |
| 2467 | dma_free_coherent(&ha->pdev->dev, sizeof(struct ct_sns_pkt), |
| 2468 | ha->ct_sns, ha->ct_sns_dma); |
| 2469 | ha->ct_sns = NULL; |
| 2470 | ha->ct_sns_dma = 0; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 2471 | fail_free_ms_iocb: |
| 2472 | dma_pool_free(ha->s_dma_pool, ha->ms_iocb, ha->ms_iocb_dma); |
| 2473 | ha->ms_iocb = NULL; |
| 2474 | ha->ms_iocb_dma = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2475 | fail_dma_pool: |
| 2476 | dma_pool_destroy(ha->s_dma_pool); |
| 2477 | ha->s_dma_pool = NULL; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 2478 | fail_free_nvram: |
| 2479 | kfree(ha->nvram); |
| 2480 | ha->nvram = NULL; |
| 2481 | fail_free_srb_mempool: |
| 2482 | mempool_destroy(ha->srb_mempool); |
| 2483 | ha->srb_mempool = NULL; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 2484 | fail_free_gid_list: |
| 2485 | dma_free_coherent(&ha->pdev->dev, GID_LIST_SIZE, ha->gid_list, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2486 | ha->gid_list_dma); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 2487 | ha->gid_list = NULL; |
| 2488 | ha->gid_list_dma = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2489 | fail_free_init_cb: |
| 2490 | dma_free_coherent(&ha->pdev->dev, ha->init_cb_size, ha->init_cb, |
| 2491 | ha->init_cb_dma); |
| 2492 | ha->init_cb = NULL; |
| 2493 | ha->init_cb_dma = 0; |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 2494 | fail: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2495 | DEBUG(printk("%s: Memory allocation failure\n", __func__)); |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 2496 | return -ENOMEM; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2497 | } |
| 2498 | |
| 2499 | /* |
| 2500 | * qla2x00_mem_free |
| 2501 | * Frees all adapter allocated memory. |
| 2502 | * |
| 2503 | * Input: |
| 2504 | * ha = adapter block pointer. |
| 2505 | */ |
Adrian Bunk | a824ebb | 2008-01-17 09:02:15 -0800 | [diff] [blame] | 2506 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2507 | qla2x00_mem_free(struct qla_hw_data *ha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2508 | { |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 2509 | if (ha->srb_mempool) |
| 2510 | mempool_destroy(ha->srb_mempool); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2511 | |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 2512 | if (ha->fce) |
| 2513 | dma_free_coherent(&ha->pdev->dev, FCE_SIZE, ha->fce, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2514 | ha->fce_dma); |
Andrew Vasquez | df613b9 | 2008-01-17 09:02:17 -0800 | [diff] [blame] | 2515 | |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 2516 | if (ha->fw_dump) { |
| 2517 | if (ha->eft) |
| 2518 | dma_free_coherent(&ha->pdev->dev, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2519 | ntohl(ha->fw_dump->eft_size), ha->eft, ha->eft_dma); |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 2520 | vfree(ha->fw_dump); |
| 2521 | } |
| 2522 | |
Andrew Vasquez | 11bbc1d | 2009-06-03 09:55:14 -0700 | [diff] [blame] | 2523 | if (ha->dcbx_tlv) |
| 2524 | dma_free_coherent(&ha->pdev->dev, DCBX_TLV_DATA_SIZE, |
| 2525 | ha->dcbx_tlv, ha->dcbx_tlv_dma); |
| 2526 | |
Andrew Vasquez | ce0423f | 2009-06-03 09:55:13 -0700 | [diff] [blame] | 2527 | if (ha->xgmac_data) |
| 2528 | dma_free_coherent(&ha->pdev->dev, XGMAC_DATA_SIZE, |
| 2529 | ha->xgmac_data, ha->xgmac_data_dma); |
| 2530 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2531 | if (ha->sns_cmd) |
| 2532 | dma_free_coherent(&ha->pdev->dev, sizeof(struct sns_cmd_pkt), |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2533 | ha->sns_cmd, ha->sns_cmd_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2534 | |
| 2535 | if (ha->ct_sns) |
| 2536 | dma_free_coherent(&ha->pdev->dev, sizeof(struct ct_sns_pkt), |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2537 | ha->ct_sns, ha->ct_sns_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2538 | |
Andrew Vasquez | 88729e5 | 2006-06-23 16:10:50 -0700 | [diff] [blame] | 2539 | if (ha->sfp_data) |
| 2540 | dma_pool_free(ha->s_dma_pool, ha->sfp_data, ha->sfp_data_dma); |
| 2541 | |
Joe Carnuccio | ad0ecd6 | 2009-03-24 09:08:12 -0700 | [diff] [blame] | 2542 | if (ha->edc_data) |
| 2543 | dma_pool_free(ha->s_dma_pool, ha->edc_data, ha->edc_data_dma); |
| 2544 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2545 | if (ha->ms_iocb) |
| 2546 | dma_pool_free(ha->s_dma_pool, ha->ms_iocb, ha->ms_iocb_dma); |
| 2547 | |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 2548 | if (ha->ex_init_cb) |
| 2549 | dma_pool_free(ha->s_dma_pool, ha->ex_init_cb, ha->ex_init_cb_dma); |
| 2550 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2551 | if (ha->s_dma_pool) |
| 2552 | dma_pool_destroy(ha->s_dma_pool); |
| 2553 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2554 | if (ha->gid_list) |
| 2555 | dma_free_coherent(&ha->pdev->dev, GID_LIST_SIZE, ha->gid_list, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2556 | ha->gid_list_dma); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2557 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2558 | if (ha->init_cb) |
| 2559 | dma_free_coherent(&ha->pdev->dev, ha->init_cb_size, |
| 2560 | ha->init_cb, ha->init_cb_dma); |
| 2561 | vfree(ha->optrom_buffer); |
| 2562 | kfree(ha->nvram); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 2563 | kfree(ha->npiv_info); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2564 | |
Andrew Vasquez | e871108 | 2008-01-31 12:33:48 -0800 | [diff] [blame] | 2565 | ha->srb_mempool = NULL; |
Andrew Vasquez | a7a167b | 2006-06-23 16:10:29 -0700 | [diff] [blame] | 2566 | ha->eft = NULL; |
| 2567 | ha->eft_dma = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2568 | ha->sns_cmd = NULL; |
| 2569 | ha->sns_cmd_dma = 0; |
| 2570 | ha->ct_sns = NULL; |
| 2571 | ha->ct_sns_dma = 0; |
| 2572 | ha->ms_iocb = NULL; |
| 2573 | ha->ms_iocb_dma = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2574 | ha->init_cb = NULL; |
| 2575 | ha->init_cb_dma = 0; |
Andrew Vasquez | b64b0e8 | 2009-03-24 09:08:01 -0700 | [diff] [blame] | 2576 | ha->ex_init_cb = NULL; |
| 2577 | ha->ex_init_cb_dma = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2578 | |
| 2579 | ha->s_dma_pool = NULL; |
| 2580 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2581 | ha->gid_list = NULL; |
| 2582 | ha->gid_list_dma = 0; |
| 2583 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2584 | ha->fw_dump = NULL; |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 2585 | ha->fw_dumped = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2586 | ha->fw_dump_reading = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2587 | } |
| 2588 | |
| 2589 | struct scsi_qla_host *qla2x00_create_host(struct scsi_host_template *sht, |
| 2590 | struct qla_hw_data *ha) |
| 2591 | { |
| 2592 | struct Scsi_Host *host; |
| 2593 | struct scsi_qla_host *vha = NULL; |
| 2594 | |
| 2595 | host = scsi_host_alloc(sht, sizeof(scsi_qla_host_t)); |
| 2596 | if (host == NULL) { |
| 2597 | printk(KERN_WARNING |
| 2598 | "qla2xxx: Couldn't allocate host from scsi layer!\n"); |
| 2599 | goto fail; |
| 2600 | } |
| 2601 | |
| 2602 | /* Clear our data area */ |
| 2603 | vha = shost_priv(host); |
| 2604 | memset(vha, 0, sizeof(scsi_qla_host_t)); |
| 2605 | |
| 2606 | vha->host = host; |
| 2607 | vha->host_no = host->host_no; |
| 2608 | vha->hw = ha; |
| 2609 | |
| 2610 | INIT_LIST_HEAD(&vha->vp_fcports); |
| 2611 | INIT_LIST_HEAD(&vha->work_list); |
| 2612 | INIT_LIST_HEAD(&vha->list); |
| 2613 | |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 2614 | spin_lock_init(&vha->work_lock); |
| 2615 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2616 | sprintf(vha->host_str, "%s_%ld", QLA2XXX_DRIVER_NAME, vha->host_no); |
| 2617 | return vha; |
| 2618 | |
| 2619 | fail: |
| 2620 | return vha; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2621 | } |
| 2622 | |
Adrian Bunk | 01ef66b | 2008-04-24 15:21:27 -0700 | [diff] [blame] | 2623 | static struct qla_work_evt * |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 2624 | 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] | 2625 | { |
| 2626 | struct qla_work_evt *e; |
| 2627 | |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 2628 | e = kzalloc(sizeof(struct qla_work_evt), GFP_ATOMIC); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 2629 | if (!e) |
| 2630 | return NULL; |
| 2631 | |
| 2632 | INIT_LIST_HEAD(&e->list); |
| 2633 | e->type = type; |
| 2634 | e->flags = QLA_EVT_FLAG_FREE; |
| 2635 | return e; |
| 2636 | } |
| 2637 | |
Adrian Bunk | 01ef66b | 2008-04-24 15:21:27 -0700 | [diff] [blame] | 2638 | static int |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 2639 | 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] | 2640 | { |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 2641 | unsigned long flags; |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 2642 | |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 2643 | spin_lock_irqsave(&vha->work_lock, flags); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2644 | list_add_tail(&e->list, &vha->work_list); |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 2645 | spin_unlock_irqrestore(&vha->work_lock, flags); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2646 | qla2xxx_wake_dpc(vha); |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 2647 | |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 2648 | return QLA_SUCCESS; |
| 2649 | } |
| 2650 | |
| 2651 | int |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2652 | 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] | 2653 | u32 data) |
| 2654 | { |
| 2655 | struct qla_work_evt *e; |
| 2656 | |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 2657 | e = qla2x00_alloc_work(vha, QLA_EVT_AEN); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 2658 | if (!e) |
| 2659 | return QLA_FUNCTION_FAILED; |
| 2660 | |
| 2661 | e->u.aen.code = code; |
| 2662 | e->u.aen.data = data; |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 2663 | return qla2x00_post_work(vha, e); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 2664 | } |
| 2665 | |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 2666 | int |
| 2667 | qla2x00_post_idc_ack_work(struct scsi_qla_host *vha, uint16_t *mb) |
| 2668 | { |
| 2669 | struct qla_work_evt *e; |
| 2670 | |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 2671 | e = qla2x00_alloc_work(vha, QLA_EVT_IDC_ACK); |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 2672 | if (!e) |
| 2673 | return QLA_FUNCTION_FAILED; |
| 2674 | |
| 2675 | 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] | 2676 | return qla2x00_post_work(vha, e); |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 2677 | } |
| 2678 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 2679 | #define qla2x00_post_async_work(name, type) \ |
| 2680 | int qla2x00_post_async_##name##_work( \ |
| 2681 | struct scsi_qla_host *vha, \ |
| 2682 | fc_port_t *fcport, uint16_t *data) \ |
| 2683 | { \ |
| 2684 | struct qla_work_evt *e; \ |
| 2685 | \ |
| 2686 | e = qla2x00_alloc_work(vha, type); \ |
| 2687 | if (!e) \ |
| 2688 | return QLA_FUNCTION_FAILED; \ |
| 2689 | \ |
| 2690 | e->u.logio.fcport = fcport; \ |
| 2691 | if (data) { \ |
| 2692 | e->u.logio.data[0] = data[0]; \ |
| 2693 | e->u.logio.data[1] = data[1]; \ |
| 2694 | } \ |
| 2695 | return qla2x00_post_work(vha, e); \ |
| 2696 | } |
| 2697 | |
| 2698 | qla2x00_post_async_work(login, QLA_EVT_ASYNC_LOGIN); |
| 2699 | qla2x00_post_async_work(login_done, QLA_EVT_ASYNC_LOGIN_DONE); |
| 2700 | qla2x00_post_async_work(logout, QLA_EVT_ASYNC_LOGOUT); |
| 2701 | qla2x00_post_async_work(logout_done, QLA_EVT_ASYNC_LOGOUT_DONE); |
| 2702 | |
Andrew Vasquez | 3420d36 | 2009-10-13 15:16:45 -0700 | [diff] [blame] | 2703 | int |
| 2704 | qla2x00_post_uevent_work(struct scsi_qla_host *vha, u32 code) |
| 2705 | { |
| 2706 | struct qla_work_evt *e; |
| 2707 | |
| 2708 | e = qla2x00_alloc_work(vha, QLA_EVT_UEVENT); |
| 2709 | if (!e) |
| 2710 | return QLA_FUNCTION_FAILED; |
| 2711 | |
| 2712 | e->u.uevent.code = code; |
| 2713 | return qla2x00_post_work(vha, e); |
| 2714 | } |
| 2715 | |
| 2716 | static void |
| 2717 | qla2x00_uevent_emit(struct scsi_qla_host *vha, u32 code) |
| 2718 | { |
| 2719 | char event_string[40]; |
| 2720 | char *envp[] = { event_string, NULL }; |
| 2721 | |
| 2722 | switch (code) { |
| 2723 | case QLA_UEVENT_CODE_FW_DUMP: |
| 2724 | snprintf(event_string, sizeof(event_string), "FW_DUMP=%ld", |
| 2725 | vha->host_no); |
| 2726 | break; |
| 2727 | default: |
| 2728 | /* do nothing */ |
| 2729 | break; |
| 2730 | } |
| 2731 | kobject_uevent_env(&vha->hw->pdev->dev.kobj, KOBJ_CHANGE, envp); |
| 2732 | } |
| 2733 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 2734 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2735 | qla2x00_do_work(struct scsi_qla_host *vha) |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 2736 | { |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 2737 | struct qla_work_evt *e, *tmp; |
| 2738 | unsigned long flags; |
| 2739 | LIST_HEAD(work); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 2740 | |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 2741 | spin_lock_irqsave(&vha->work_lock, flags); |
| 2742 | list_splice_init(&vha->work_list, &work); |
| 2743 | spin_unlock_irqrestore(&vha->work_lock, flags); |
| 2744 | |
| 2745 | list_for_each_entry_safe(e, tmp, &work, list) { |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 2746 | list_del_init(&e->list); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 2747 | |
| 2748 | switch (e->type) { |
| 2749 | case QLA_EVT_AEN: |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2750 | fc_host_post_event(vha->host, fc_get_event_number(), |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 2751 | e->u.aen.code, e->u.aen.data); |
| 2752 | break; |
Andrew Vasquez | 8a65957 | 2009-02-08 20:50:12 -0800 | [diff] [blame] | 2753 | case QLA_EVT_IDC_ACK: |
| 2754 | qla81xx_idc_ack(vha, e->u.idc_ack.mb); |
| 2755 | break; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 2756 | case QLA_EVT_ASYNC_LOGIN: |
| 2757 | qla2x00_async_login(vha, e->u.logio.fcport, |
| 2758 | e->u.logio.data); |
| 2759 | break; |
| 2760 | case QLA_EVT_ASYNC_LOGIN_DONE: |
| 2761 | qla2x00_async_login_done(vha, e->u.logio.fcport, |
| 2762 | e->u.logio.data); |
| 2763 | break; |
| 2764 | case QLA_EVT_ASYNC_LOGOUT: |
| 2765 | qla2x00_async_logout(vha, e->u.logio.fcport); |
| 2766 | break; |
| 2767 | case QLA_EVT_ASYNC_LOGOUT_DONE: |
| 2768 | qla2x00_async_logout_done(vha, e->u.logio.fcport, |
| 2769 | e->u.logio.data); |
| 2770 | break; |
Andrew Vasquez | 3420d36 | 2009-10-13 15:16:45 -0700 | [diff] [blame] | 2771 | case QLA_EVT_UEVENT: |
| 2772 | qla2x00_uevent_emit(vha, e->u.uevent.code); |
| 2773 | break; |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 2774 | } |
| 2775 | if (e->flags & QLA_EVT_FLAG_FREE) |
| 2776 | kfree(e); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 2777 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2778 | } |
Andrew Vasquez | f999f4c | 2009-06-03 09:55:28 -0700 | [diff] [blame] | 2779 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2780 | /* Relogins all the fcports of a vport |
| 2781 | * Context: dpc thread |
| 2782 | */ |
| 2783 | void qla2x00_relogin(struct scsi_qla_host *vha) |
| 2784 | { |
| 2785 | fc_port_t *fcport; |
Andrew Vasquez | c6b2fca | 2009-03-05 11:07:03 -0800 | [diff] [blame] | 2786 | int status; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2787 | uint16_t next_loopid = 0; |
| 2788 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 2789 | uint16_t data[2]; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2790 | |
| 2791 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
| 2792 | /* |
| 2793 | * If the port is not ONLINE then try to login |
| 2794 | * to it if we haven't run out of retries. |
| 2795 | */ |
| 2796 | if (atomic_read(&fcport->state) != |
| 2797 | FCS_ONLINE && fcport->login_retry) { |
| 2798 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 2799 | fcport->login_retry--; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2800 | if (fcport->flags & FCF_FABRIC_DEVICE) { |
Andrew Vasquez | f08b725 | 2010-01-12 12:59:48 -0800 | [diff] [blame] | 2801 | if (fcport->flags & FCF_FCP2_DEVICE) |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2802 | ha->isp_ops->fabric_logout(vha, |
| 2803 | fcport->loop_id, |
| 2804 | fcport->d_id.b.domain, |
| 2805 | fcport->d_id.b.area, |
| 2806 | fcport->d_id.b.al_pa); |
| 2807 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 2808 | if (IS_ALOGIO_CAPABLE(ha)) { |
| 2809 | data[0] = 0; |
| 2810 | data[1] = QLA_LOGIO_LOGIN_RETRIED; |
| 2811 | status = qla2x00_post_async_login_work( |
| 2812 | vha, fcport, data); |
| 2813 | if (status == QLA_SUCCESS) |
| 2814 | continue; |
| 2815 | /* Attempt a retry. */ |
| 2816 | status = 1; |
| 2817 | } else |
| 2818 | status = qla2x00_fabric_login(vha, |
| 2819 | fcport, &next_loopid); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2820 | } else |
| 2821 | status = qla2x00_local_device_login(vha, |
| 2822 | fcport); |
| 2823 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2824 | if (status == QLA_SUCCESS) { |
| 2825 | fcport->old_loop_id = fcport->loop_id; |
| 2826 | |
| 2827 | DEBUG(printk("scsi(%ld): port login OK: logged " |
| 2828 | "in ID 0x%x\n", vha->host_no, fcport->loop_id)); |
| 2829 | |
| 2830 | qla2x00_update_fcport(vha, fcport); |
| 2831 | |
| 2832 | } else if (status == 1) { |
| 2833 | set_bit(RELOGIN_NEEDED, &vha->dpc_flags); |
| 2834 | /* retry the login again */ |
| 2835 | DEBUG(printk("scsi(%ld): Retrying" |
| 2836 | " %d login again loop_id 0x%x\n", |
| 2837 | vha->host_no, fcport->login_retry, |
| 2838 | fcport->loop_id)); |
| 2839 | } else { |
| 2840 | fcport->login_retry = 0; |
| 2841 | } |
| 2842 | |
| 2843 | if (fcport->login_retry == 0 && status != QLA_SUCCESS) |
| 2844 | fcport->loop_id = FC_NO_LOOP_ID; |
| 2845 | } |
| 2846 | if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) |
| 2847 | break; |
| 2848 | } |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 2849 | } |
| 2850 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2851 | /************************************************************************** |
| 2852 | * qla2x00_do_dpc |
| 2853 | * This kernel thread is a task that is schedule by the interrupt handler |
| 2854 | * to perform the background processing for interrupts. |
| 2855 | * |
| 2856 | * Notes: |
| 2857 | * This task always run in the context of a kernel thread. It |
| 2858 | * is kick-off by the driver's detect code and starts up |
| 2859 | * up one per adapter. It immediately goes to sleep and waits for |
| 2860 | * some fibre event. When either the interrupt handler or |
| 2861 | * the timer routine detects a event it will one of the task |
| 2862 | * bits then wake us up. |
| 2863 | **************************************************************************/ |
| 2864 | static int |
| 2865 | qla2x00_do_dpc(void *data) |
| 2866 | { |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2867 | int rval; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2868 | scsi_qla_host_t *base_vha; |
| 2869 | struct qla_hw_data *ha; |
Seokmann Ju | 99363ef | 2008-01-31 12:33:51 -0800 | [diff] [blame] | 2870 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2871 | ha = (struct qla_hw_data *)data; |
| 2872 | base_vha = pci_get_drvdata(ha->pdev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2873 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2874 | set_user_nice(current, -20); |
| 2875 | |
Christoph Hellwig | 39a1124 | 2006-02-14 18:46:22 +0100 | [diff] [blame] | 2876 | while (!kthread_should_stop()) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2877 | DEBUG3(printk("qla2x00: DPC handler sleeping\n")); |
| 2878 | |
Christoph Hellwig | 39a1124 | 2006-02-14 18:46:22 +0100 | [diff] [blame] | 2879 | set_current_state(TASK_INTERRUPTIBLE); |
| 2880 | schedule(); |
| 2881 | __set_current_state(TASK_RUNNING); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2882 | |
| 2883 | DEBUG3(printk("qla2x00: DPC handler waking up\n")); |
| 2884 | |
| 2885 | /* Initialization not yet finished. Don't do anything yet. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2886 | if (!base_vha->flags.init_done) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2887 | continue; |
| 2888 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 2889 | if (ha->flags.eeh_busy) { |
| 2890 | DEBUG17(qla_printk(KERN_WARNING, ha, |
| 2891 | "qla2x00_do_dpc: dpc_flags: %lx\n", |
| 2892 | base_vha->dpc_flags)); |
| 2893 | continue; |
| 2894 | } |
| 2895 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2896 | DEBUG3(printk("scsi(%ld): DPC handler\n", base_vha->host_no)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2897 | |
| 2898 | ha->dpc_active = 1; |
| 2899 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2900 | if (ha->flags.mbox_busy) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2901 | ha->dpc_active = 0; |
| 2902 | continue; |
| 2903 | } |
| 2904 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2905 | qla2x00_do_work(base_vha); |
Andrew Vasquez | 0971de7 | 2008-04-03 13:13:18 -0700 | [diff] [blame] | 2906 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2907 | if (test_and_clear_bit(ISP_ABORT_NEEDED, |
| 2908 | &base_vha->dpc_flags)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2909 | |
| 2910 | DEBUG(printk("scsi(%ld): dpc: sched " |
| 2911 | "qla2x00_abort_isp ha = %p\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2912 | base_vha->host_no, ha)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2913 | if (!(test_and_set_bit(ABORT_ISP_ACTIVE, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2914 | &base_vha->dpc_flags))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2915 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2916 | if (qla2x00_abort_isp(base_vha)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2917 | /* failed. retry later */ |
| 2918 | set_bit(ISP_ABORT_NEEDED, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2919 | &base_vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2920 | } |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2921 | clear_bit(ABORT_ISP_ACTIVE, |
| 2922 | &base_vha->dpc_flags); |
Seokmann Ju | 99363ef | 2008-01-31 12:33:51 -0800 | [diff] [blame] | 2923 | } |
| 2924 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2925 | DEBUG(printk("scsi(%ld): dpc: qla2x00_abort_isp end\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2926 | base_vha->host_no)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2927 | } |
| 2928 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2929 | if (test_bit(FCPORT_UPDATE_NEEDED, &base_vha->dpc_flags)) { |
| 2930 | qla2x00_update_fcports(base_vha); |
| 2931 | clear_bit(FCPORT_UPDATE_NEEDED, &base_vha->dpc_flags); |
Andrew Vasquez | c9c5ced | 2008-07-24 08:31:49 -0700 | [diff] [blame] | 2932 | } |
andrew.vasquez@qlogic.com | d97994d | 2006-01-20 14:53:13 -0800 | [diff] [blame] | 2933 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2934 | if (test_and_clear_bit(RESET_MARKER_NEEDED, |
| 2935 | &base_vha->dpc_flags) && |
| 2936 | (!(test_and_set_bit(RESET_ACTIVE, &base_vha->dpc_flags)))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2937 | |
| 2938 | DEBUG(printk("scsi(%ld): qla2x00_reset_marker()\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2939 | base_vha->host_no)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2940 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2941 | qla2x00_rst_aen(base_vha); |
| 2942 | clear_bit(RESET_ACTIVE, &base_vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2943 | } |
| 2944 | |
| 2945 | /* Retry each device up to login retry count */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2946 | if ((test_and_clear_bit(RELOGIN_NEEDED, |
| 2947 | &base_vha->dpc_flags)) && |
| 2948 | !test_bit(LOOP_RESYNC_NEEDED, &base_vha->dpc_flags) && |
| 2949 | atomic_read(&base_vha->loop_state) != LOOP_DOWN) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2950 | |
| 2951 | DEBUG(printk("scsi(%ld): qla2x00_port_login()\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2952 | base_vha->host_no)); |
| 2953 | qla2x00_relogin(base_vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2954 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2955 | DEBUG(printk("scsi(%ld): qla2x00_port_login - end\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2956 | base_vha->host_no)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2957 | } |
| 2958 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2959 | if (test_and_clear_bit(LOOP_RESYNC_NEEDED, |
| 2960 | &base_vha->dpc_flags)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2961 | |
| 2962 | DEBUG(printk("scsi(%ld): qla2x00_loop_resync()\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2963 | base_vha->host_no)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2964 | |
| 2965 | if (!(test_and_set_bit(LOOP_RESYNC_ACTIVE, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2966 | &base_vha->dpc_flags))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2967 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2968 | rval = qla2x00_loop_resync(base_vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2969 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2970 | clear_bit(LOOP_RESYNC_ACTIVE, |
| 2971 | &base_vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2972 | } |
| 2973 | |
| 2974 | DEBUG(printk("scsi(%ld): qla2x00_loop_resync - end\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2975 | base_vha->host_no)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2976 | } |
| 2977 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2978 | if (test_bit(NPIV_CONFIG_NEEDED, &base_vha->dpc_flags) && |
| 2979 | atomic_read(&base_vha->loop_state) == LOOP_READY) { |
| 2980 | clear_bit(NPIV_CONFIG_NEEDED, &base_vha->dpc_flags); |
| 2981 | qla2xxx_flash_npiv_conf(base_vha); |
Andrew Vasquez | 272976c | 2008-09-11 21:22:50 -0700 | [diff] [blame] | 2982 | } |
| 2983 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2984 | if (!ha->interrupts_on) |
Andrew Vasquez | fd34f55 | 2007-07-19 15:06:00 -0700 | [diff] [blame] | 2985 | ha->isp_ops->enable_intrs(ha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2986 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2987 | if (test_and_clear_bit(BEACON_BLINK_NEEDED, |
| 2988 | &base_vha->dpc_flags)) |
| 2989 | ha->isp_ops->beacon_blink(base_vha); |
andrew.vasquez@qlogic.com | f6df144 | 2006-01-31 16:05:07 -0800 | [diff] [blame] | 2990 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2991 | qla2x00_do_dpc_all_vps(base_vha); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 2992 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2993 | ha->dpc_active = 0; |
| 2994 | } /* End of while(1) */ |
| 2995 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 2996 | DEBUG(printk("scsi(%ld): DPC handler exiting\n", base_vha->host_no)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2997 | |
| 2998 | /* |
| 2999 | * Make sure that nobody tries to wake us up again. |
| 3000 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3001 | ha->dpc_active = 0; |
| 3002 | |
Andrew Vasquez | ac280b6 | 2009-08-20 11:06:05 -0700 | [diff] [blame] | 3003 | /* Cleanup any residual CTX SRBs. */ |
| 3004 | qla2x00_abort_all_cmds(base_vha, DID_NO_CONNECT << 16); |
| 3005 | |
Christoph Hellwig | 39a1124 | 2006-02-14 18:46:22 +0100 | [diff] [blame] | 3006 | return 0; |
| 3007 | } |
| 3008 | |
| 3009 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3010 | qla2xxx_wake_dpc(struct scsi_qla_host *vha) |
Christoph Hellwig | 39a1124 | 2006-02-14 18:46:22 +0100 | [diff] [blame] | 3011 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3012 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | c795c1e | 2008-08-13 21:37:01 -0700 | [diff] [blame] | 3013 | struct task_struct *t = ha->dpc_thread; |
| 3014 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3015 | if (!test_bit(UNLOADING, &vha->dpc_flags) && t) |
Andrew Vasquez | c795c1e | 2008-08-13 21:37:01 -0700 | [diff] [blame] | 3016 | wake_up_process(t); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3017 | } |
| 3018 | |
| 3019 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3020 | * qla2x00_rst_aen |
| 3021 | * Processes asynchronous reset. |
| 3022 | * |
| 3023 | * Input: |
| 3024 | * ha = adapter block pointer. |
| 3025 | */ |
| 3026 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3027 | qla2x00_rst_aen(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3028 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3029 | if (vha->flags.online && !vha->flags.reset_active && |
| 3030 | !atomic_read(&vha->loop_down_timer) && |
| 3031 | !(test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags))) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3032 | do { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3033 | clear_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3034 | |
| 3035 | /* |
| 3036 | * Issue marker command only when we are going to start |
| 3037 | * the I/O. |
| 3038 | */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3039 | vha->marker_needed = 1; |
| 3040 | } while (!atomic_read(&vha->loop_down_timer) && |
| 3041 | (test_bit(RESET_MARKER_NEEDED, &vha->dpc_flags))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3042 | } |
| 3043 | } |
| 3044 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 3045 | static void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3046 | qla2x00_sp_free_dma(srb_t *sp) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 3047 | { |
| 3048 | struct scsi_cmnd *cmd = sp->cmd; |
| 3049 | |
| 3050 | if (sp->flags & SRB_DMA_VALID) { |
FUJITA Tomonori | 385d70b | 2007-05-26 01:55:38 +0900 | [diff] [blame] | 3051 | scsi_dma_unmap(cmd); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 3052 | sp->flags &= ~SRB_DMA_VALID; |
| 3053 | } |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 3054 | CMD_SP(cmd) = NULL; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 3055 | } |
| 3056 | |
| 3057 | void |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3058 | qla2x00_sp_compl(struct qla_hw_data *ha, srb_t *sp) |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 3059 | { |
| 3060 | struct scsi_cmnd *cmd = sp->cmd; |
| 3061 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3062 | qla2x00_sp_free_dma(sp); |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 3063 | |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 3064 | mempool_free(sp, ha->srb_mempool); |
| 3065 | |
| 3066 | cmd->scsi_done(cmd); |
| 3067 | } |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 3068 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3069 | /************************************************************************** |
| 3070 | * qla2x00_timer |
| 3071 | * |
| 3072 | * Description: |
| 3073 | * One second timer |
| 3074 | * |
| 3075 | * Context: Interrupt |
| 3076 | ***************************************************************************/ |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3077 | void |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3078 | qla2x00_timer(scsi_qla_host_t *vha) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3079 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3080 | unsigned long cpu_flags = 0; |
| 3081 | fc_port_t *fcport; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3082 | int start_dpc = 0; |
| 3083 | int index; |
| 3084 | srb_t *sp; |
| f4f051e | 2005-04-17 15:02:26 -0500 | [diff] [blame] | 3085 | int t; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 3086 | uint16_t w; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3087 | struct qla_hw_data *ha = vha->hw; |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3088 | struct req_que *req; |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 3089 | |
| 3090 | /* Hardware read to raise pending EEH errors during mailbox waits. */ |
| 3091 | if (!pci_channel_offline(ha->pdev)) |
| 3092 | pci_read_config_word(ha->pdev, PCI_VENDOR_ID, &w); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3093 | /* |
| 3094 | * Ports - Port down timer. |
| 3095 | * |
| 3096 | * Whenever, a port is in the LOST state we start decrementing its port |
| 3097 | * down timer every second until it reaches zero. Once it reaches zero |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 3098 | * the port it marked DEAD. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3099 | */ |
| 3100 | t = 0; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3101 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3102 | if (fcport->port_type != FCT_TARGET) |
| 3103 | continue; |
| 3104 | |
| 3105 | if (atomic_read(&fcport->state) == FCS_DEVICE_LOST) { |
| 3106 | |
| 3107 | if (atomic_read(&fcport->port_down_timer) == 0) |
| 3108 | continue; |
| 3109 | |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 3110 | if (atomic_dec_and_test(&fcport->port_down_timer) != 0) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3111 | atomic_set(&fcport->state, FCS_DEVICE_DEAD); |
Andrew Vasquez | fa2a1ce | 2005-07-06 10:32:07 -0700 | [diff] [blame] | 3112 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3113 | DEBUG(printk("scsi(%ld): fcport-%d - port retry count: " |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 3114 | "%d remaining\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3115 | vha->host_no, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3116 | t, atomic_read(&fcport->port_down_timer))); |
| 3117 | } |
| 3118 | t++; |
| 3119 | } /* End of for fcport */ |
| 3120 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3121 | |
| 3122 | /* Loop down handler. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3123 | if (atomic_read(&vha->loop_down_timer) > 0 && |
| 3124 | !(test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags)) |
| 3125 | && vha->flags.online) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3126 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3127 | if (atomic_read(&vha->loop_down_timer) == |
| 3128 | vha->loop_down_abort_time) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3129 | |
| 3130 | DEBUG(printk("scsi(%ld): Loop Down - aborting the " |
| 3131 | "queues before time expire\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3132 | vha->host_no)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3133 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3134 | if (!IS_QLA2100(ha) && vha->link_down_timeout) |
| 3135 | atomic_set(&vha->loop_state, LOOP_DEAD); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3136 | |
Andrew Vasquez | f08b725 | 2010-01-12 12:59:48 -0800 | [diff] [blame] | 3137 | /* |
| 3138 | * Schedule an ISP abort to return any FCP2-device |
| 3139 | * commands. |
| 3140 | */ |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3141 | /* NPIV - scan physical port only */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3142 | if (!vha->vp_idx) { |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3143 | spin_lock_irqsave(&ha->hardware_lock, |
| 3144 | cpu_flags); |
Anirban Chakraborty | 73208df | 2008-12-09 16:45:39 -0800 | [diff] [blame] | 3145 | req = ha->req_q_map[0]; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3146 | for (index = 1; |
| 3147 | index < MAX_OUTSTANDING_COMMANDS; |
| 3148 | index++) { |
| 3149 | fc_port_t *sfcp; |
| bdf7962 | 2005-04-17 15:06:53 -0500 | [diff] [blame] | 3150 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3151 | sp = req->outstanding_cmds[index]; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3152 | if (!sp) |
| 3153 | continue; |
Andrew Vasquez | cf53b06 | 2009-08-20 11:06:04 -0700 | [diff] [blame] | 3154 | if (sp->ctx) |
| 3155 | continue; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3156 | sfcp = sp->fcport; |
Andrew Vasquez | f08b725 | 2010-01-12 12:59:48 -0800 | [diff] [blame] | 3157 | if (!(sfcp->flags & FCF_FCP2_DEVICE)) |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3158 | continue; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3159 | |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3160 | set_bit(ISP_ABORT_NEEDED, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3161 | &vha->dpc_flags); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3162 | break; |
| 3163 | } |
| 3164 | spin_unlock_irqrestore(&ha->hardware_lock, |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3165 | cpu_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3166 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3167 | start_dpc++; |
| 3168 | } |
| 3169 | |
| 3170 | /* if the loop has been down for 4 minutes, reinit adapter */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3171 | if (atomic_dec_and_test(&vha->loop_down_timer) != 0) { |
Andrew Vasquez | 0d6e61b | 2009-08-25 11:36:19 -0700 | [diff] [blame] | 3172 | if (!(vha->device_flags & DFLG_NO_CABLE)) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3173 | DEBUG(printk("scsi(%ld): Loop down - " |
| 3174 | "aborting ISP.\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3175 | vha->host_no)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3176 | qla_printk(KERN_WARNING, ha, |
| 3177 | "Loop down - aborting ISP.\n"); |
| 3178 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3179 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3180 | } |
| 3181 | } |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 3182 | DEBUG3(printk("scsi(%ld): Loop Down - seconds remaining %d\n", |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3183 | vha->host_no, |
| 3184 | atomic_read(&vha->loop_down_timer))); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3185 | } |
| 3186 | |
andrew.vasquez@qlogic.com | f6df144 | 2006-01-31 16:05:07 -0800 | [diff] [blame] | 3187 | /* Check if beacon LED needs to be blinked */ |
| 3188 | if (ha->beacon_blink_led == 1) { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3189 | set_bit(BEACON_BLINK_NEEDED, &vha->dpc_flags); |
andrew.vasquez@qlogic.com | f6df144 | 2006-01-31 16:05:07 -0800 | [diff] [blame] | 3190 | start_dpc++; |
| 3191 | } |
| 3192 | |
Andrew Vasquez | 550bf57 | 2008-04-24 15:21:23 -0700 | [diff] [blame] | 3193 | /* Process any deferred work. */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3194 | if (!list_empty(&vha->work_list)) |
Andrew Vasquez | 550bf57 | 2008-04-24 15:21:23 -0700 | [diff] [blame] | 3195 | start_dpc++; |
| 3196 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3197 | /* Schedule the DPC routine if needed */ |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3198 | if ((test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) || |
| 3199 | test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags) || |
| 3200 | test_bit(FCPORT_UPDATE_NEEDED, &vha->dpc_flags) || |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3201 | start_dpc || |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3202 | test_bit(RESET_MARKER_NEEDED, &vha->dpc_flags) || |
| 3203 | test_bit(BEACON_BLINK_NEEDED, &vha->dpc_flags) || |
| 3204 | test_bit(VP_DPC_NEEDED, &vha->dpc_flags) || |
| 3205 | test_bit(RELOGIN_NEEDED, &vha->dpc_flags))) |
| 3206 | qla2xxx_wake_dpc(vha); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3207 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3208 | qla2x00_restart_timer(vha, WATCH_INTERVAL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3209 | } |
| 3210 | |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 3211 | /* Firmware interface routines. */ |
| 3212 | |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 3213 | #define FW_BLOBS 7 |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 3214 | #define FW_ISP21XX 0 |
| 3215 | #define FW_ISP22XX 1 |
| 3216 | #define FW_ISP2300 2 |
| 3217 | #define FW_ISP2322 3 |
andrew.vasquez@qlogic.com | 48c02fd | 2006-03-09 14:27:18 -0800 | [diff] [blame] | 3218 | #define FW_ISP24XX 4 |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 3219 | #define FW_ISP25XX 5 |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 3220 | #define FW_ISP81XX 6 |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 3221 | |
Andrew Vasquez | bb8ee49 | 2006-10-02 12:00:48 -0700 | [diff] [blame] | 3222 | #define FW_FILE_ISP21XX "ql2100_fw.bin" |
| 3223 | #define FW_FILE_ISP22XX "ql2200_fw.bin" |
| 3224 | #define FW_FILE_ISP2300 "ql2300_fw.bin" |
| 3225 | #define FW_FILE_ISP2322 "ql2322_fw.bin" |
| 3226 | #define FW_FILE_ISP24XX "ql2400_fw.bin" |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 3227 | #define FW_FILE_ISP25XX "ql2500_fw.bin" |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 3228 | #define FW_FILE_ISP81XX "ql8100_fw.bin" |
Andrew Vasquez | bb8ee49 | 2006-10-02 12:00:48 -0700 | [diff] [blame] | 3229 | |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 3230 | static DEFINE_MUTEX(qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 3231 | |
| 3232 | static struct fw_blob qla_fw_blobs[FW_BLOBS] = { |
Andrew Vasquez | bb8ee49 | 2006-10-02 12:00:48 -0700 | [diff] [blame] | 3233 | { .name = FW_FILE_ISP21XX, .segs = { 0x1000, 0 }, }, |
| 3234 | { .name = FW_FILE_ISP22XX, .segs = { 0x1000, 0 }, }, |
| 3235 | { .name = FW_FILE_ISP2300, .segs = { 0x800, 0 }, }, |
| 3236 | { .name = FW_FILE_ISP2322, .segs = { 0x800, 0x1c000, 0x1e000, 0 }, }, |
| 3237 | { .name = FW_FILE_ISP24XX, }, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 3238 | { .name = FW_FILE_ISP25XX, }, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 3239 | { .name = FW_FILE_ISP81XX, }, |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 3240 | }; |
| 3241 | |
| 3242 | struct fw_blob * |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3243 | qla2x00_request_firmware(scsi_qla_host_t *vha) |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 3244 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3245 | struct qla_hw_data *ha = vha->hw; |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 3246 | struct fw_blob *blob; |
| 3247 | |
| 3248 | blob = NULL; |
| 3249 | if (IS_QLA2100(ha)) { |
| 3250 | blob = &qla_fw_blobs[FW_ISP21XX]; |
| 3251 | } else if (IS_QLA2200(ha)) { |
| 3252 | blob = &qla_fw_blobs[FW_ISP22XX]; |
andrew.vasquez@qlogic.com | 48c02fd | 2006-03-09 14:27:18 -0800 | [diff] [blame] | 3253 | } else if (IS_QLA2300(ha) || IS_QLA2312(ha) || IS_QLA6312(ha)) { |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 3254 | blob = &qla_fw_blobs[FW_ISP2300]; |
andrew.vasquez@qlogic.com | 48c02fd | 2006-03-09 14:27:18 -0800 | [diff] [blame] | 3255 | } else if (IS_QLA2322(ha) || IS_QLA6322(ha)) { |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 3256 | blob = &qla_fw_blobs[FW_ISP2322]; |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 3257 | } else if (IS_QLA24XX_TYPE(ha)) { |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 3258 | blob = &qla_fw_blobs[FW_ISP24XX]; |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 3259 | } else if (IS_QLA25XX(ha)) { |
| 3260 | blob = &qla_fw_blobs[FW_ISP25XX]; |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 3261 | } else if (IS_QLA81XX(ha)) { |
| 3262 | blob = &qla_fw_blobs[FW_ISP81XX]; |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 3263 | } |
| 3264 | |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 3265 | mutex_lock(&qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 3266 | if (blob->fw) |
| 3267 | goto out; |
| 3268 | |
| 3269 | if (request_firmware(&blob->fw, blob->name, &ha->pdev->dev)) { |
| 3270 | DEBUG2(printk("scsi(%ld): Failed to load firmware image " |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3271 | "(%s).\n", vha->host_no, blob->name)); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 3272 | blob->fw = NULL; |
| 3273 | blob = NULL; |
| 3274 | goto out; |
| 3275 | } |
| 3276 | |
| 3277 | out: |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 3278 | mutex_unlock(&qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 3279 | return blob; |
| 3280 | } |
| 3281 | |
| 3282 | static void |
| 3283 | qla2x00_release_firmware(void) |
| 3284 | { |
| 3285 | int idx; |
| 3286 | |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 3287 | mutex_lock(&qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 3288 | for (idx = 0; idx < FW_BLOBS; idx++) |
| 3289 | if (qla_fw_blobs[idx].fw) |
| 3290 | release_firmware(qla_fw_blobs[idx].fw); |
Daniel Walker | e1e82b6 | 2008-05-12 22:21:10 -0700 | [diff] [blame] | 3291 | mutex_unlock(&qla_fw_lock); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 3292 | } |
| 3293 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 3294 | static pci_ers_result_t |
| 3295 | qla2xxx_pci_error_detected(struct pci_dev *pdev, pci_channel_state_t state) |
| 3296 | { |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 3297 | scsi_qla_host_t *vha = pci_get_drvdata(pdev); |
| 3298 | struct qla_hw_data *ha = vha->hw; |
| 3299 | |
| 3300 | DEBUG2(qla_printk(KERN_WARNING, ha, "error_detected:state %x\n", |
| 3301 | state)); |
Seokmann Ju | b9b12f7 | 2009-03-24 09:08:18 -0700 | [diff] [blame] | 3302 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 3303 | switch (state) { |
| 3304 | case pci_channel_io_normal: |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 3305 | ha->flags.eeh_busy = 0; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 3306 | return PCI_ERS_RESULT_CAN_RECOVER; |
| 3307 | case pci_channel_io_frozen: |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 3308 | ha->flags.eeh_busy = 1; |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 3309 | qla2x00_free_irqs(vha); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 3310 | pci_disable_device(pdev); |
| 3311 | return PCI_ERS_RESULT_NEED_RESET; |
| 3312 | case pci_channel_io_perm_failure: |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 3313 | ha->flags.pci_channel_io_perm_failure = 1; |
| 3314 | qla2x00_abort_all_cmds(vha, DID_NO_CONNECT << 16); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 3315 | return PCI_ERS_RESULT_DISCONNECT; |
| 3316 | } |
| 3317 | return PCI_ERS_RESULT_NEED_RESET; |
| 3318 | } |
| 3319 | |
| 3320 | static pci_ers_result_t |
| 3321 | qla2xxx_pci_mmio_enabled(struct pci_dev *pdev) |
| 3322 | { |
| 3323 | int risc_paused = 0; |
| 3324 | uint32_t stat; |
| 3325 | unsigned long flags; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3326 | scsi_qla_host_t *base_vha = pci_get_drvdata(pdev); |
| 3327 | struct qla_hw_data *ha = base_vha->hw; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 3328 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
| 3329 | struct device_reg_24xx __iomem *reg24 = &ha->iobase->isp24; |
| 3330 | |
| 3331 | spin_lock_irqsave(&ha->hardware_lock, flags); |
| 3332 | if (IS_QLA2100(ha) || IS_QLA2200(ha)){ |
| 3333 | stat = RD_REG_DWORD(®->hccr); |
| 3334 | if (stat & HCCR_RISC_PAUSE) |
| 3335 | risc_paused = 1; |
| 3336 | } else if (IS_QLA23XX(ha)) { |
| 3337 | stat = RD_REG_DWORD(®->u.isp2300.host_status); |
| 3338 | if (stat & HSR_RISC_PAUSED) |
| 3339 | risc_paused = 1; |
| 3340 | } else if (IS_FWI2_CAPABLE(ha)) { |
| 3341 | stat = RD_REG_DWORD(®24->host_status); |
| 3342 | if (stat & HSRX_RISC_PAUSED) |
| 3343 | risc_paused = 1; |
| 3344 | } |
| 3345 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
| 3346 | |
| 3347 | if (risc_paused) { |
| 3348 | qla_printk(KERN_INFO, ha, "RISC paused -- mmio_enabled, " |
| 3349 | "Dumping firmware!\n"); |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3350 | ha->isp_ops->fw_dump(base_vha, 0); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 3351 | |
| 3352 | return PCI_ERS_RESULT_NEED_RESET; |
| 3353 | } else |
| 3354 | return PCI_ERS_RESULT_RECOVERED; |
| 3355 | } |
| 3356 | |
| 3357 | static pci_ers_result_t |
| 3358 | qla2xxx_pci_slot_reset(struct pci_dev *pdev) |
| 3359 | { |
| 3360 | pci_ers_result_t ret = PCI_ERS_RESULT_DISCONNECT; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3361 | scsi_qla_host_t *base_vha = pci_get_drvdata(pdev); |
| 3362 | struct qla_hw_data *ha = base_vha->hw; |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 3363 | struct rsp_que *rsp; |
| 3364 | int rc, retries = 10; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 3365 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 3366 | DEBUG17(qla_printk(KERN_WARNING, ha, "slot_reset\n")); |
| 3367 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 3368 | /* Workaround: qla2xxx driver which access hardware earlier |
| 3369 | * needs error state to be pci_channel_io_online. |
| 3370 | * Otherwise mailbox command timesout. |
| 3371 | */ |
| 3372 | pdev->error_state = pci_channel_io_normal; |
| 3373 | |
| 3374 | pci_restore_state(pdev); |
| 3375 | |
Richard Lary | 8c1496b | 2010-02-18 10:07:29 -0800 | [diff] [blame] | 3376 | /* pci_restore_state() clears the saved_state flag of the device |
| 3377 | * save restored state which resets saved_state flag |
| 3378 | */ |
| 3379 | pci_save_state(pdev); |
| 3380 | |
Benjamin Herrenschmidt | 0948391 | 2007-12-20 15:28:09 +1100 | [diff] [blame] | 3381 | if (ha->mem_only) |
| 3382 | rc = pci_enable_device_mem(pdev); |
| 3383 | else |
| 3384 | rc = pci_enable_device(pdev); |
| 3385 | |
| 3386 | if (rc) { |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 3387 | qla_printk(KERN_WARNING, ha, |
| 3388 | "Can't re-enable PCI device after reset.\n"); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 3389 | return ret; |
| 3390 | } |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 3391 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 3392 | rsp = ha->rsp_q_map[0]; |
| 3393 | if (qla2x00_request_irqs(ha, rsp)) |
| 3394 | return ret; |
| 3395 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3396 | if (ha->isp_ops->pci_config(base_vha)) |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 3397 | return ret; |
| 3398 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 3399 | while (ha->flags.mbox_busy && retries--) |
| 3400 | msleep(1000); |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 3401 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3402 | set_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
| 3403 | if (qla2x00_abort_isp(base_vha) == QLA_SUCCESS) |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 3404 | ret = PCI_ERS_RESULT_RECOVERED; |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3405 | clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 3406 | |
Joe Carnuccio | 90a86fc | 2010-01-12 13:02:46 -0800 | [diff] [blame] | 3407 | pci_cleanup_aer_uncorrect_error_status(pdev); |
| 3408 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 3409 | DEBUG17(qla_printk(KERN_WARNING, ha, |
| 3410 | "slot_reset-return:ret=%x\n", ret)); |
| 3411 | |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 3412 | return ret; |
| 3413 | } |
| 3414 | |
| 3415 | static void |
| 3416 | qla2xxx_pci_resume(struct pci_dev *pdev) |
| 3417 | { |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3418 | scsi_qla_host_t *base_vha = pci_get_drvdata(pdev); |
| 3419 | struct qla_hw_data *ha = base_vha->hw; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 3420 | int ret; |
| 3421 | |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 3422 | DEBUG17(qla_printk(KERN_WARNING, ha, "pci_resume\n")); |
| 3423 | |
Anirban Chakraborty | e315cd2 | 2008-11-06 10:40:51 -0800 | [diff] [blame] | 3424 | ret = qla2x00_wait_for_hba_online(base_vha); |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 3425 | if (ret != QLA_SUCCESS) { |
| 3426 | qla_printk(KERN_ERR, ha, |
| 3427 | "the device failed to resume I/O " |
| 3428 | "from slot/link_reset"); |
| 3429 | } |
Andrew Vasquez | 8588080 | 2009-12-15 21:29:46 -0800 | [diff] [blame] | 3430 | |
| 3431 | ha->flags.eeh_busy = 0; |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 3432 | } |
| 3433 | |
| 3434 | static struct pci_error_handlers qla2xxx_err_handler = { |
| 3435 | .error_detected = qla2xxx_pci_error_detected, |
| 3436 | .mmio_enabled = qla2xxx_pci_mmio_enabled, |
| 3437 | .slot_reset = qla2xxx_pci_slot_reset, |
| 3438 | .resume = qla2xxx_pci_resume, |
| 3439 | }; |
| 3440 | |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 3441 | static struct pci_device_id qla2xxx_pci_tbl[] = { |
Andrew Vasquez | 47f5e06 | 2006-05-17 15:09:39 -0700 | [diff] [blame] | 3442 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2100) }, |
| 3443 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2200) }, |
| 3444 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2300) }, |
| 3445 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2312) }, |
| 3446 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2322) }, |
| 3447 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP6312) }, |
| 3448 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP6322) }, |
| 3449 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2422) }, |
| 3450 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2432) }, |
Harihara Kadayam | 4d4df19 | 2008-04-03 13:13:26 -0700 | [diff] [blame] | 3451 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8432) }, |
Andrew Vasquez | 47f5e06 | 2006-05-17 15:09:39 -0700 | [diff] [blame] | 3452 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP5422) }, |
| 3453 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP5432) }, |
Andrew Vasquez | c3a2f0d | 2007-07-19 20:37:34 -0700 | [diff] [blame] | 3454 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2532) }, |
Andrew Vasquez | 3a03eb7 | 2009-01-05 11:18:11 -0800 | [diff] [blame] | 3455 | { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8001) }, |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 3456 | { 0 }, |
| 3457 | }; |
| 3458 | MODULE_DEVICE_TABLE(pci, qla2xxx_pci_tbl); |
| 3459 | |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 3460 | static struct pci_driver qla2xxx_pci_driver = { |
Andrew Vasquez | cb63067 | 2006-05-17 15:09:45 -0700 | [diff] [blame] | 3461 | .name = QLA2XXX_DRIVER_NAME, |
James Bottomley | 0a21ef1 | 2005-12-01 12:51:50 -0600 | [diff] [blame] | 3462 | .driver = { |
| 3463 | .owner = THIS_MODULE, |
| 3464 | }, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 3465 | .id_table = qla2xxx_pci_tbl, |
Andrew Vasquez | 7ee6139 | 2006-06-23 16:11:22 -0700 | [diff] [blame] | 3466 | .probe = qla2x00_probe_one, |
Adrian Bunk | 4c993f7 | 2008-01-14 00:55:16 -0800 | [diff] [blame] | 3467 | .remove = qla2x00_remove_one, |
Seokmann Ju | 14e660e | 2007-09-20 14:07:36 -0700 | [diff] [blame] | 3468 | .err_handler = &qla2xxx_err_handler, |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 3469 | }; |
| 3470 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3471 | /** |
| 3472 | * qla2x00_module_init - Module initialization. |
| 3473 | **/ |
| 3474 | static int __init |
| 3475 | qla2x00_module_init(void) |
| 3476 | { |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 3477 | int ret = 0; |
| 3478 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3479 | /* Allocate cache for SRBs. */ |
Andrew Vasquez | 354d6b2 | 2005-04-23 02:47:27 -0400 | [diff] [blame] | 3480 | srb_cachep = kmem_cache_create("qla2xxx_srbs", sizeof(srb_t), 0, |
Paul Mundt | 20c2df8 | 2007-07-20 10:11:58 +0900 | [diff] [blame] | 3481 | SLAB_HWCACHE_ALIGN, NULL); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3482 | if (srb_cachep == NULL) { |
| 3483 | printk(KERN_ERR |
| 3484 | "qla2xxx: Unable to allocate SRB cache...Failing load!\n"); |
| 3485 | return -ENOMEM; |
| 3486 | } |
| 3487 | |
| 3488 | /* Derive version string. */ |
| 3489 | strcpy(qla2x00_version_str, QLA2XXX_VERSION); |
Andrew Vasquez | 11010fe | 2006-10-06 09:54:59 -0700 | [diff] [blame] | 3490 | if (ql2xextended_error_logging) |
Andrew Vasquez | 0181944 | 2006-06-23 16:11:10 -0700 | [diff] [blame] | 3491 | strcat(qla2x00_version_str, "-debug"); |
| 3492 | |
Andrew Vasquez | 1c97a12 | 2005-04-21 16:13:36 -0400 | [diff] [blame] | 3493 | qla2xxx_transport_template = |
| 3494 | fc_attach_transport(&qla2xxx_transport_functions); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3495 | if (!qla2xxx_transport_template) { |
| 3496 | kmem_cache_destroy(srb_cachep); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3497 | return -ENODEV; |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3498 | } |
| 3499 | qla2xxx_transport_vport_template = |
| 3500 | fc_attach_transport(&qla2xxx_transport_vport_functions); |
| 3501 | if (!qla2xxx_transport_vport_template) { |
| 3502 | kmem_cache_destroy(srb_cachep); |
| 3503 | fc_release_transport(qla2xxx_transport_template); |
| 3504 | return -ENODEV; |
| 3505 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3506 | |
Andrew Vasquez | fd9a29f | 2008-05-12 22:21:08 -0700 | [diff] [blame] | 3507 | printk(KERN_INFO "QLogic Fibre Channel HBA Driver: %s\n", |
| 3508 | qla2x00_version_str); |
Andrew Vasquez | 7ee6139 | 2006-06-23 16:11:22 -0700 | [diff] [blame] | 3509 | ret = pci_register_driver(&qla2xxx_pci_driver); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 3510 | if (ret) { |
| 3511 | kmem_cache_destroy(srb_cachep); |
| 3512 | fc_release_transport(qla2xxx_transport_template); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3513 | fc_release_transport(qla2xxx_transport_vport_template); |
Andrew Vasquez | fca2970 | 2005-07-06 10:31:47 -0700 | [diff] [blame] | 3514 | } |
| 3515 | return ret; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3516 | } |
| 3517 | |
| 3518 | /** |
| 3519 | * qla2x00_module_exit - Module cleanup. |
| 3520 | **/ |
| 3521 | static void __exit |
| 3522 | qla2x00_module_exit(void) |
| 3523 | { |
Andrew Vasquez | 7ee6139 | 2006-06-23 16:11:22 -0700 | [diff] [blame] | 3524 | pci_unregister_driver(&qla2xxx_pci_driver); |
Andrew Vasquez | 5433383 | 2005-11-09 15:49:04 -0800 | [diff] [blame] | 3525 | qla2x00_release_firmware(); |
Andrew Vasquez | 354d6b2 | 2005-04-23 02:47:27 -0400 | [diff] [blame] | 3526 | kmem_cache_destroy(srb_cachep); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3527 | fc_release_transport(qla2xxx_transport_template); |
Seokmann Ju | 2c3dfe3 | 2007-07-05 13:16:51 -0700 | [diff] [blame] | 3528 | fc_release_transport(qla2xxx_transport_vport_template); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 3529 | } |
| 3530 | |
| 3531 | module_init(qla2x00_module_init); |
| 3532 | module_exit(qla2x00_module_exit); |
| 3533 | |
| 3534 | MODULE_AUTHOR("QLogic Corporation"); |
| 3535 | MODULE_DESCRIPTION("QLogic Fibre Channel HBA Driver"); |
| 3536 | MODULE_LICENSE("GPL"); |
| 3537 | MODULE_VERSION(QLA2XXX_VERSION); |
Andrew Vasquez | bb8ee49 | 2006-10-02 12:00:48 -0700 | [diff] [blame] | 3538 | MODULE_FIRMWARE(FW_FILE_ISP21XX); |
| 3539 | MODULE_FIRMWARE(FW_FILE_ISP22XX); |
| 3540 | MODULE_FIRMWARE(FW_FILE_ISP2300); |
| 3541 | MODULE_FIRMWARE(FW_FILE_ISP2322); |
| 3542 | MODULE_FIRMWARE(FW_FILE_ISP24XX); |
Andrew Vasquez | 61623fc | 2008-01-31 12:33:45 -0800 | [diff] [blame] | 3543 | MODULE_FIRMWARE(FW_FILE_ISP25XX); |