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