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