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