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