blob: a6761ff73e24ac1e9bbd8e78ba63b9a70b6cd4a4 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001/*
Andrew Vasquezfa90c542005-10-27 11:10:08 -07002 * QLogic Fibre Channel HBA Driver
Andrew Vasquez01e58d82008-04-03 13:13:13 -07003 * Copyright (c) 2003-2008 QLogic Corporation
Linus Torvalds1da177e2005-04-16 15:20:36 -07004 *
Andrew Vasquezfa90c542005-10-27 11:10:08 -07005 * See LICENSE.qla2xxx for copyright and licensing details.
Linus Torvalds1da177e2005-04-16 15:20:36 -07006 */
7#include "qla_def.h"
8
9#include <linux/moduleparam.h>
10#include <linux/vmalloc.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070011#include <linux/delay.h>
Christoph Hellwig39a11242006-02-14 18:46:22 +010012#include <linux/kthread.h>
Daniel Walkere1e82b62008-05-12 22:21:10 -070013#include <linux/mutex.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070014
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 */
23char qla2x00_version_str[40];
24
25/*
26 * SRB allocation cache
27 */
Christoph Lametere18b8902006-12-06 20:33:20 -080028static struct kmem_cache *srb_cachep;
Linus Torvalds1da177e2005-04-16 15:20:36 -070029
Linus Torvalds1da177e2005-04-16 15:20:36 -070030int ql2xlogintimeout = 20;
31module_param(ql2xlogintimeout, int, S_IRUGO|S_IRUSR);
32MODULE_PARM_DESC(ql2xlogintimeout,
33 "Login timeout value in seconds.");
34
Andrew Vasqueza7b61842007-05-07 07:42:59 -070035int qlport_down_retry;
Linus Torvalds1da177e2005-04-16 15:20:36 -070036module_param(qlport_down_retry, int, S_IRUGO|S_IRUSR);
37MODULE_PARM_DESC(qlport_down_retry,
Jesper Juhl900d9f92006-06-30 02:33:07 -070038 "Maximum number of command retries to a port that returns "
Linus Torvalds1da177e2005-04-16 15:20:36 -070039 "a PORT-DOWN status.");
40
Linus Torvalds1da177e2005-04-16 15:20:36 -070041int ql2xplogiabsentdevice;
42module_param(ql2xplogiabsentdevice, int, S_IRUGO|S_IWUSR);
43MODULE_PARM_DESC(ql2xplogiabsentdevice,
44 "Option to enable PLOGI to devices that are not present after "
Jesper Juhl900d9f92006-06-30 02:33:07 -070045 "a Fabric scan. This is needed for several broken switches. "
Linus Torvalds1da177e2005-04-16 15:20:36 -070046 "Default is 0 - no PLOGI. 1 - perfom PLOGI.");
47
Linus Torvalds1da177e2005-04-16 15:20:36 -070048int ql2xloginretrycount = 0;
49module_param(ql2xloginretrycount, int, S_IRUGO|S_IRUSR);
50MODULE_PARM_DESC(ql2xloginretrycount,
51 "Specify an alternate value for the NVRAM login retry count.");
52
Andrew Vasqueza7a167b2006-06-23 16:10:29 -070053int ql2xallocfwdump = 1;
54module_param(ql2xallocfwdump, int, S_IRUGO|S_IRUSR);
55MODULE_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 Vasquez11010fe2006-10-06 09:54:59 -070060int ql2xextended_error_logging;
Andrew Vasquez27d94032007-03-12 10:41:30 -070061module_param(ql2xextended_error_logging, int, S_IRUGO|S_IWUSR);
Andrew Vasquez11010fe2006-10-06 09:54:59 -070062MODULE_PARM_DESC(ql2xextended_error_logging,
Andrew Vasquez01819442006-06-23 16:11:10 -070063 "Option to enable extended error logging, "
64 "Default is 0 - no logging. 1 - log errors.");
65
Linus Torvalds1da177e2005-04-16 15:20:36 -070066static void qla2x00_free_device(scsi_qla_host_t *);
67
Andrew Vasquez7e47e5c2008-04-24 15:21:26 -070068int ql2xfdmienable=1;
Andrew Vasquezcca53352005-08-26 19:08:30 -070069module_param(ql2xfdmienable, int, S_IRUGO|S_IRUSR);
70MODULE_PARM_DESC(ql2xfdmienable,
71 "Enables FDMI registratons "
72 "Default is 0 - no FDMI. 1 - perfom FDMI.");
73
Andrew Vasquezdf7baa52006-10-13 09:33:39 -070074#define MAX_Q_DEPTH 32
75static int ql2xmaxqdepth = MAX_Q_DEPTH;
76module_param(ql2xmaxqdepth, int, S_IRUGO|S_IWUSR);
77MODULE_PARM_DESC(ql2xmaxqdepth,
78 "Maximum queue depth to report for target devices.");
79
80int ql2xqfullrampup = 120;
81module_param(ql2xqfullrampup, int, S_IRUGO|S_IWUSR);
82MODULE_PARM_DESC(ql2xqfullrampup,
83 "Number of seconds to wait to begin to ramp-up the queue "
84 "depth for a device after a queue-full condition has been "
85 "detected. Default is 120 seconds.");
86
Andrew Vasqueze5896bd2008-07-10 16:55:52 -070087int ql2xiidmaenable=1;
88module_param(ql2xiidmaenable, int, S_IRUGO|S_IRUSR);
89MODULE_PARM_DESC(ql2xiidmaenable,
90 "Enables iIDMA settings "
91 "Default is 1 - perform iIDMA. 0 - no iIDMA.");
92
Anirban Chakraborty73208df2008-12-09 16:45:39 -080093int ql2xmaxqueues = 1;
94module_param(ql2xmaxqueues, int, S_IRUGO|S_IRUSR);
95MODULE_PARM_DESC(ql2xmaxqueues,
96 "Enables MQ settings "
97 "Default is 1 for single queue. Set it to number \
98 of queues in MQ mode.");
Linus Torvalds1da177e2005-04-16 15:20:36 -070099/*
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700100 * SCSI host template entry points
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101 */
102static int qla2xxx_slave_configure(struct scsi_device * device);
f4f051e2005-04-17 15:02:26 -0500103static int qla2xxx_slave_alloc(struct scsi_device *);
Andrew Vasquez1e99e332006-11-22 08:24:48 -0800104static int qla2xxx_scan_finished(struct Scsi_Host *, unsigned long time);
105static void qla2xxx_scan_start(struct Scsi_Host *);
f4f051e2005-04-17 15:02:26 -0500106static void qla2xxx_slave_destroy(struct scsi_device *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700107static int qla2x00_queuecommand(struct scsi_cmnd *cmd,
108 void (*fn)(struct scsi_cmnd *));
Andrew Vasquezfca29702005-07-06 10:31:47 -0700109static int qla24xx_queuecommand(struct scsi_cmnd *cmd,
110 void (*fn)(struct scsi_cmnd *));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700111static int qla2xxx_eh_abort(struct scsi_cmnd *);
112static int qla2xxx_eh_device_reset(struct scsi_cmnd *);
Andrew Vasquez523ec772008-04-03 13:13:24 -0700113static int qla2xxx_eh_target_reset(struct scsi_cmnd *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700114static int qla2xxx_eh_bus_reset(struct scsi_cmnd *);
115static int qla2xxx_eh_host_reset(struct scsi_cmnd *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116
Andrew Vasquezce7e4af2005-08-26 19:09:30 -0700117static int qla2x00_change_queue_depth(struct scsi_device *, int);
118static int qla2x00_change_queue_type(struct scsi_device *, int);
119
Adrian Bunka824ebb2008-01-17 09:02:15 -0800120static struct scsi_host_template qla2x00_driver_template = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700121 .module = THIS_MODULE,
Andrew Vasquezcb630672006-05-17 15:09:45 -0700122 .name = QLA2XXX_DRIVER_NAME,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123 .queuecommand = qla2x00_queuecommand,
124
125 .eh_abort_handler = qla2xxx_eh_abort,
126 .eh_device_reset_handler = qla2xxx_eh_device_reset,
Andrew Vasquez523ec772008-04-03 13:13:24 -0700127 .eh_target_reset_handler = qla2xxx_eh_target_reset,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700128 .eh_bus_reset_handler = qla2xxx_eh_bus_reset,
129 .eh_host_reset_handler = qla2xxx_eh_host_reset,
130
131 .slave_configure = qla2xxx_slave_configure,
132
f4f051e2005-04-17 15:02:26 -0500133 .slave_alloc = qla2xxx_slave_alloc,
134 .slave_destroy = qla2xxx_slave_destroy,
Andrew Vasquez1e99e332006-11-22 08:24:48 -0800135 .scan_finished = qla2xxx_scan_finished,
136 .scan_start = qla2xxx_scan_start,
Andrew Vasquezce7e4af2005-08-26 19:09:30 -0700137 .change_queue_depth = qla2x00_change_queue_depth,
138 .change_queue_type = qla2x00_change_queue_type,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700139 .this_id = -1,
140 .cmd_per_lun = 3,
141 .use_clustering = ENABLE_CLUSTERING,
142 .sg_tablesize = SG_ALL,
143
144 /*
145 * The RISC allows for each command to transfer (2^32-1) bytes of data,
146 * which equates to 0x800000 sectors.
147 */
148 .max_sectors = 0xFFFF,
Andrew Vasquezafb046e2005-08-26 19:09:40 -0700149 .shost_attrs = qla2x00_host_attrs,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700150};
151
Seokmann Ju2c3dfe32007-07-05 13:16:51 -0700152struct scsi_host_template qla24xx_driver_template = {
Andrew Vasquezfca29702005-07-06 10:31:47 -0700153 .module = THIS_MODULE,
Andrew Vasquezcb630672006-05-17 15:09:45 -0700154 .name = QLA2XXX_DRIVER_NAME,
Andrew Vasquezfca29702005-07-06 10:31:47 -0700155 .queuecommand = qla24xx_queuecommand,
156
157 .eh_abort_handler = qla2xxx_eh_abort,
158 .eh_device_reset_handler = qla2xxx_eh_device_reset,
Andrew Vasquez523ec772008-04-03 13:13:24 -0700159 .eh_target_reset_handler = qla2xxx_eh_target_reset,
Andrew Vasquezfca29702005-07-06 10:31:47 -0700160 .eh_bus_reset_handler = qla2xxx_eh_bus_reset,
161 .eh_host_reset_handler = qla2xxx_eh_host_reset,
162
163 .slave_configure = qla2xxx_slave_configure,
164
165 .slave_alloc = qla2xxx_slave_alloc,
166 .slave_destroy = qla2xxx_slave_destroy,
Andrew Vasquezed677082007-03-12 10:41:27 -0700167 .scan_finished = qla2xxx_scan_finished,
168 .scan_start = qla2xxx_scan_start,
Andrew Vasquezce7e4af2005-08-26 19:09:30 -0700169 .change_queue_depth = qla2x00_change_queue_depth,
170 .change_queue_type = qla2x00_change_queue_type,
Andrew Vasquezfca29702005-07-06 10:31:47 -0700171 .this_id = -1,
172 .cmd_per_lun = 3,
173 .use_clustering = ENABLE_CLUSTERING,
174 .sg_tablesize = SG_ALL,
175
176 .max_sectors = 0xFFFF,
Andrew Vasquezafb046e2005-08-26 19:09:40 -0700177 .shost_attrs = qla2x00_host_attrs,
Andrew Vasquezfca29702005-07-06 10:31:47 -0700178};
179
Linus Torvalds1da177e2005-04-16 15:20:36 -0700180static struct scsi_transport_template *qla2xxx_transport_template = NULL;
Seokmann Ju2c3dfe32007-07-05 13:16:51 -0700181struct scsi_transport_template *qla2xxx_transport_vport_template = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700182
Linus Torvalds1da177e2005-04-16 15:20:36 -0700183/* TODO Convert to inlines
184 *
185 * Timer routines
186 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700187
Seokmann Ju2c3dfe32007-07-05 13:16:51 -0700188__inline__ void
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800189qla2x00_start_timer(scsi_qla_host_t *vha, void *func, unsigned long interval)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700190{
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800191 init_timer(&vha->timer);
192 vha->timer.expires = jiffies + interval * HZ;
193 vha->timer.data = (unsigned long)vha;
194 vha->timer.function = (void (*)(unsigned long))func;
195 add_timer(&vha->timer);
196 vha->timer_active = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700197}
198
199static inline void
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800200qla2x00_restart_timer(scsi_qla_host_t *vha, unsigned long interval)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700201{
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800202 mod_timer(&vha->timer, jiffies + interval * HZ);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203}
204
Adrian Bunka824ebb2008-01-17 09:02:15 -0800205static __inline__ void
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800206qla2x00_stop_timer(scsi_qla_host_t *vha)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700207{
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800208 del_timer_sync(&vha->timer);
209 vha->timer_active = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700210}
211
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212static int qla2x00_do_dpc(void *data);
213
214static void qla2x00_rst_aen(scsi_qla_host_t *);
215
Anirban Chakraborty73208df2008-12-09 16:45:39 -0800216static int qla2x00_mem_alloc(struct qla_hw_data *, uint16_t, uint16_t,
217 struct req_que **, struct rsp_que **);
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800218static void qla2x00_mem_free(struct qla_hw_data *);
219static void qla2x00_sp_free_dma(srb_t *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700220
Linus Torvalds1da177e2005-04-16 15:20:36 -0700221/* -------------------------------------------------------------------------- */
Anirban Chakraborty73208df2008-12-09 16:45:39 -0800222static int qla2x00_alloc_queues(struct qla_hw_data *ha)
223{
224 ha->req_q_map = kzalloc(sizeof(struct req_que *) * ha->max_queues,
225 GFP_KERNEL);
226 if (!ha->req_q_map) {
227 qla_printk(KERN_WARNING, ha,
228 "Unable to allocate memory for request queue ptrs\n");
229 goto fail_req_map;
230 }
231
232 ha->rsp_q_map = kzalloc(sizeof(struct rsp_que *) * ha->max_queues,
233 GFP_KERNEL);
234 if (!ha->rsp_q_map) {
235 qla_printk(KERN_WARNING, ha,
236 "Unable to allocate memory for response queue ptrs\n");
237 goto fail_rsp_map;
238 }
239 set_bit(0, ha->rsp_qid_map);
240 set_bit(0, ha->req_qid_map);
241 return 1;
242
243fail_rsp_map:
244 kfree(ha->req_q_map);
245 ha->req_q_map = NULL;
246fail_req_map:
247 return -ENOMEM;
248}
249
250static void qla2x00_free_que(struct qla_hw_data *ha, struct req_que *req,
251 struct rsp_que *rsp)
252{
253 if (rsp && rsp->ring)
254 dma_free_coherent(&ha->pdev->dev,
255 (rsp->length + 1) * sizeof(response_t),
256 rsp->ring, rsp->dma);
257
258 kfree(rsp);
259 rsp = NULL;
260 if (req && req->ring)
261 dma_free_coherent(&ha->pdev->dev,
262 (req->length + 1) * sizeof(request_t),
263 req->ring, req->dma);
264
265 kfree(req);
266 req = NULL;
267}
268
269static void qla2x00_free_queues(struct qla_hw_data *ha)
270{
271 struct req_que *req;
272 struct rsp_que *rsp;
273 int cnt;
274
275 for (cnt = 0; cnt < ha->max_queues; cnt++) {
276 rsp = ha->rsp_q_map[cnt];
277 req = ha->req_q_map[cnt];
278 qla2x00_free_que(ha, req, rsp);
279 }
280 kfree(ha->rsp_q_map);
281 ha->rsp_q_map = NULL;
282
283 kfree(ha->req_q_map);
284 ha->req_q_map = NULL;
285}
286
Linus Torvalds1da177e2005-04-16 15:20:36 -0700287static char *
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800288qla2x00_pci_info_str(struct scsi_qla_host *vha, char *str)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700289{
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800290 struct qla_hw_data *ha = vha->hw;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700291 static char *pci_bus_modes[] = {
292 "33", "66", "100", "133",
293 };
294 uint16_t pci_bus;
295
296 strcpy(str, "PCI");
297 pci_bus = (ha->pci_attr & (BIT_9 | BIT_10)) >> 9;
298 if (pci_bus) {
299 strcat(str, "-X (");
300 strcat(str, pci_bus_modes[pci_bus]);
301 } else {
302 pci_bus = (ha->pci_attr & BIT_8) >> 8;
303 strcat(str, " (");
304 strcat(str, pci_bus_modes[pci_bus]);
305 }
306 strcat(str, " MHz)");
307
308 return (str);
309}
310
Andrew Vasquezfca29702005-07-06 10:31:47 -0700311static char *
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800312qla24xx_pci_info_str(struct scsi_qla_host *vha, char *str)
Andrew Vasquezfca29702005-07-06 10:31:47 -0700313{
314 static char *pci_bus_modes[] = { "33", "66", "100", "133", };
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800315 struct qla_hw_data *ha = vha->hw;
Andrew Vasquezfca29702005-07-06 10:31:47 -0700316 uint32_t pci_bus;
317 int pcie_reg;
318
319 pcie_reg = pci_find_capability(ha->pdev, PCI_CAP_ID_EXP);
320 if (pcie_reg) {
321 char lwstr[6];
322 uint16_t pcie_lstat, lspeed, lwidth;
323
324 pcie_reg += 0x12;
325 pci_read_config_word(ha->pdev, pcie_reg, &pcie_lstat);
326 lspeed = pcie_lstat & (BIT_0 | BIT_1 | BIT_2 | BIT_3);
327 lwidth = (pcie_lstat &
328 (BIT_4 | BIT_5 | BIT_6 | BIT_7 | BIT_8 | BIT_9)) >> 4;
329
330 strcpy(str, "PCIe (");
331 if (lspeed == 1)
Andrew Vasquezc87a0d82008-04-03 13:13:21 -0700332 strcat(str, "2.5GT/s ");
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -0700333 else if (lspeed == 2)
Andrew Vasquezc87a0d82008-04-03 13:13:21 -0700334 strcat(str, "5.0GT/s ");
Andrew Vasquezfca29702005-07-06 10:31:47 -0700335 else
336 strcat(str, "<unknown> ");
337 snprintf(lwstr, sizeof(lwstr), "x%d)", lwidth);
338 strcat(str, lwstr);
339
340 return str;
341 }
342
343 strcpy(str, "PCI");
344 pci_bus = (ha->pci_attr & CSRX_PCIX_BUS_MODE_MASK) >> 8;
345 if (pci_bus == 0 || pci_bus == 8) {
346 strcat(str, " (");
347 strcat(str, pci_bus_modes[pci_bus >> 3]);
348 } else {
349 strcat(str, "-X ");
350 if (pci_bus & BIT_2)
351 strcat(str, "Mode 2");
352 else
353 strcat(str, "Mode 1");
354 strcat(str, " (");
355 strcat(str, pci_bus_modes[pci_bus & ~BIT_2]);
356 }
357 strcat(str, " MHz)");
358
359 return str;
360}
361
Adrian Bunke5f82ab2006-11-08 19:55:50 -0800362static char *
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800363qla2x00_fw_version_str(struct scsi_qla_host *vha, char *str)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700364{
365 char un_str[10];
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800366 struct qla_hw_data *ha = vha->hw;
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700367
Linus Torvalds1da177e2005-04-16 15:20:36 -0700368 sprintf(str, "%d.%02d.%02d ", ha->fw_major_version,
369 ha->fw_minor_version,
370 ha->fw_subminor_version);
371
372 if (ha->fw_attributes & BIT_9) {
373 strcat(str, "FLX");
374 return (str);
375 }
376
377 switch (ha->fw_attributes & 0xFF) {
378 case 0x7:
379 strcat(str, "EF");
380 break;
381 case 0x17:
382 strcat(str, "TP");
383 break;
384 case 0x37:
385 strcat(str, "IP");
386 break;
387 case 0x77:
388 strcat(str, "VI");
389 break;
390 default:
391 sprintf(un_str, "(%x)", ha->fw_attributes);
392 strcat(str, un_str);
393 break;
394 }
395 if (ha->fw_attributes & 0x100)
396 strcat(str, "X");
397
398 return (str);
399}
400
Adrian Bunke5f82ab2006-11-08 19:55:50 -0800401static char *
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800402qla24xx_fw_version_str(struct scsi_qla_host *vha, char *str)
Andrew Vasquezfca29702005-07-06 10:31:47 -0700403{
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800404 struct qla_hw_data *ha = vha->hw;
Andrew Vasquezf0883ac2005-07-08 17:58:43 -0700405
Andrew Vasquez3a03eb72009-01-05 11:18:11 -0800406 sprintf(str, "%d.%02d.%02d (%x)", ha->fw_major_version,
407 ha->fw_minor_version, ha->fw_subminor_version, ha->fw_attributes);
Andrew Vasquezfca29702005-07-06 10:31:47 -0700408 return str;
Andrew Vasquezfca29702005-07-06 10:31:47 -0700409}
410
411static inline srb_t *
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800412qla2x00_get_new_sp(scsi_qla_host_t *vha, fc_port_t *fcport,
Andrew Vasquezfca29702005-07-06 10:31:47 -0700413 struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
414{
415 srb_t *sp;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800416 struct qla_hw_data *ha = vha->hw;
Andrew Vasquezfca29702005-07-06 10:31:47 -0700417
418 sp = mempool_alloc(ha->srb_mempool, GFP_ATOMIC);
419 if (!sp)
420 return sp;
421
Andrew Vasquezfca29702005-07-06 10:31:47 -0700422 sp->fcport = fcport;
423 sp->cmd = cmd;
Anirban Chakraborty17d98632008-12-18 10:06:15 -0800424 sp->que = ha->req_q_map[0];
Andrew Vasquezfca29702005-07-06 10:31:47 -0700425 sp->flags = 0;
426 CMD_SP(cmd) = (void *)sp;
427 cmd->scsi_done = done;
428
429 return sp;
430}
431
Linus Torvalds1da177e2005-04-16 15:20:36 -0700432static int
f4f051e2005-04-17 15:02:26 -0500433qla2x00_queuecommand(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700434{
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800435 scsi_qla_host_t *vha = shost_priv(cmd->device->host);
bdf79622005-04-17 15:06:53 -0500436 fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata;
James.Smart@Emulex.Com19a7b4a2005-10-18 12:03:35 -0400437 struct fc_rport *rport = starget_to_rport(scsi_target(cmd->device));
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800438 struct qla_hw_data *ha = vha->hw;
f4f051e2005-04-17 15:02:26 -0500439 srb_t *sp;
440 int rval;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700441
Seokmann Ju14e660e2007-09-20 14:07:36 -0700442 if (unlikely(pci_channel_offline(ha->pdev))) {
443 cmd->result = DID_REQUEUE << 16;
444 goto qc_fail_command;
445 }
446
James.Smart@Emulex.Com19a7b4a2005-10-18 12:03:35 -0400447 rval = fc_remote_port_chkready(rport);
448 if (rval) {
449 cmd->result = rval;
f4f051e2005-04-17 15:02:26 -0500450 goto qc_fail_command;
451 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700452
andrew.vasquez@qlogic.com387f96b2006-02-07 08:45:45 -0800453 /* Close window on fcport/rport state-transitioning. */
Mike Christie7b594132008-08-17 15:24:40 -0500454 if (fcport->drport)
455 goto qc_target_busy;
andrew.vasquez@qlogic.com387f96b2006-02-07 08:45:45 -0800456
f4f051e2005-04-17 15:02:26 -0500457 if (atomic_read(&fcport->state) != FCS_ONLINE) {
458 if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD ||
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800459 atomic_read(&vha->loop_state) == LOOP_DEAD) {
f4f051e2005-04-17 15:02:26 -0500460 cmd->result = DID_NO_CONNECT << 16;
461 goto qc_fail_command;
462 }
Mike Christie7b594132008-08-17 15:24:40 -0500463 goto qc_target_busy;
f4f051e2005-04-17 15:02:26 -0500464 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700465
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800466 spin_unlock_irq(vha->host->host_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700467
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800468 sp = qla2x00_get_new_sp(vha, fcport, cmd, done);
Andrew Vasquezfca29702005-07-06 10:31:47 -0700469 if (!sp)
f4f051e2005-04-17 15:02:26 -0500470 goto qc_host_busy_lock;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700471
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800472 rval = ha->isp_ops->start_scsi(sp);
f4f051e2005-04-17 15:02:26 -0500473 if (rval != QLA_SUCCESS)
474 goto qc_host_busy_free_sp;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700475
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800476 spin_lock_irq(vha->host->host_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700477
f4f051e2005-04-17 15:02:26 -0500478 return 0;
479
480qc_host_busy_free_sp:
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800481 qla2x00_sp_free_dma(sp);
f4f051e2005-04-17 15:02:26 -0500482 mempool_free(sp, ha->srb_mempool);
483
484qc_host_busy_lock:
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800485 spin_lock_irq(vha->host->host_lock);
f4f051e2005-04-17 15:02:26 -0500486 return SCSI_MLQUEUE_HOST_BUSY;
487
Mike Christie7b594132008-08-17 15:24:40 -0500488qc_target_busy:
489 return SCSI_MLQUEUE_TARGET_BUSY;
490
f4f051e2005-04-17 15:02:26 -0500491qc_fail_command:
492 done(cmd);
493
494 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700495}
496
Andrew Vasquezfca29702005-07-06 10:31:47 -0700497
498static int
499qla24xx_queuecommand(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
500{
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800501 scsi_qla_host_t *vha = shost_priv(cmd->device->host);
Andrew Vasquezfca29702005-07-06 10:31:47 -0700502 fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata;
James.Smart@Emulex.Com19a7b4a2005-10-18 12:03:35 -0400503 struct fc_rport *rport = starget_to_rport(scsi_target(cmd->device));
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800504 struct qla_hw_data *ha = vha->hw;
505 struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);
Andrew Vasquezfca29702005-07-06 10:31:47 -0700506 srb_t *sp;
507 int rval;
508
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800509 if (unlikely(pci_channel_offline(ha->pdev))) {
Seokmann Ju14e660e2007-09-20 14:07:36 -0700510 cmd->result = DID_REQUEUE << 16;
511 goto qc24_fail_command;
512 }
513
James.Smart@Emulex.Com19a7b4a2005-10-18 12:03:35 -0400514 rval = fc_remote_port_chkready(rport);
515 if (rval) {
516 cmd->result = rval;
Andrew Vasquezfca29702005-07-06 10:31:47 -0700517 goto qc24_fail_command;
518 }
519
andrew.vasquez@qlogic.com387f96b2006-02-07 08:45:45 -0800520 /* Close window on fcport/rport state-transitioning. */
Mike Christie7b594132008-08-17 15:24:40 -0500521 if (fcport->drport)
522 goto qc24_target_busy;
andrew.vasquez@qlogic.com387f96b2006-02-07 08:45:45 -0800523
Andrew Vasquezfca29702005-07-06 10:31:47 -0700524 if (atomic_read(&fcport->state) != FCS_ONLINE) {
525 if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD ||
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800526 atomic_read(&base_vha->loop_state) == LOOP_DEAD) {
Andrew Vasquezfca29702005-07-06 10:31:47 -0700527 cmd->result = DID_NO_CONNECT << 16;
528 goto qc24_fail_command;
529 }
Mike Christie7b594132008-08-17 15:24:40 -0500530 goto qc24_target_busy;
Andrew Vasquezfca29702005-07-06 10:31:47 -0700531 }
532
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800533 spin_unlock_irq(vha->host->host_lock);
Andrew Vasquezfca29702005-07-06 10:31:47 -0700534
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800535 sp = qla2x00_get_new_sp(base_vha, fcport, cmd, done);
Andrew Vasquezfca29702005-07-06 10:31:47 -0700536 if (!sp)
537 goto qc24_host_busy_lock;
538
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800539 rval = ha->isp_ops->start_scsi(sp);
Andrew Vasquezfca29702005-07-06 10:31:47 -0700540 if (rval != QLA_SUCCESS)
541 goto qc24_host_busy_free_sp;
542
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800543 spin_lock_irq(vha->host->host_lock);
Andrew Vasquezfca29702005-07-06 10:31:47 -0700544
545 return 0;
546
547qc24_host_busy_free_sp:
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800548 qla2x00_sp_free_dma(sp);
549 mempool_free(sp, ha->srb_mempool);
Andrew Vasquezfca29702005-07-06 10:31:47 -0700550
551qc24_host_busy_lock:
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800552 spin_lock_irq(vha->host->host_lock);
Andrew Vasquezfca29702005-07-06 10:31:47 -0700553 return SCSI_MLQUEUE_HOST_BUSY;
554
Mike Christie7b594132008-08-17 15:24:40 -0500555qc24_target_busy:
556 return SCSI_MLQUEUE_TARGET_BUSY;
557
Andrew Vasquezfca29702005-07-06 10:31:47 -0700558qc24_fail_command:
559 done(cmd);
560
561 return 0;
562}
563
564
Linus Torvalds1da177e2005-04-16 15:20:36 -0700565/*
566 * qla2x00_eh_wait_on_command
567 * Waits for the command to be returned by the Firmware for some
568 * max time.
569 *
570 * Input:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700571 * cmd = Scsi Command to wait on.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700572 *
573 * Return:
574 * Not Found : 0
575 * Found : 1
576 */
577static int
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800578qla2x00_eh_wait_on_command(struct scsi_cmnd *cmd)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700579{
Andrew Vasquezfe74c712005-08-26 19:10:10 -0700580#define ABORT_POLLING_PERIOD 1000
581#define ABORT_WAIT_ITER ((10 * 1000) / (ABORT_POLLING_PERIOD))
f4f051e2005-04-17 15:02:26 -0500582 unsigned long wait_iter = ABORT_WAIT_ITER;
583 int ret = QLA_SUCCESS;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700584
f4f051e2005-04-17 15:02:26 -0500585 while (CMD_SP(cmd)) {
Andrew Vasquezfe74c712005-08-26 19:10:10 -0700586 msleep(ABORT_POLLING_PERIOD);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700587
f4f051e2005-04-17 15:02:26 -0500588 if (--wait_iter)
589 break;
590 }
591 if (CMD_SP(cmd))
592 ret = QLA_FUNCTION_FAILED;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700593
f4f051e2005-04-17 15:02:26 -0500594 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700595}
596
597/*
598 * qla2x00_wait_for_hba_online
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700599 * Wait till the HBA is online after going through
Linus Torvalds1da177e2005-04-16 15:20:36 -0700600 * <= MAX_RETRIES_OF_ISP_ABORT or
601 * finally HBA is disabled ie marked offline
602 *
603 * Input:
604 * ha - pointer to host adapter structure
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700605 *
606 * Note:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700607 * Does context switching-Release SPIN_LOCK
608 * (if any) before calling this routine.
609 *
610 * Return:
611 * Success (Adapter is online) : 0
612 * Failed (Adapter is offline/disabled) : 1
613 */
andrew.vasquez@qlogic.com854165f2006-01-31 16:05:17 -0800614int
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800615qla2x00_wait_for_hba_online(scsi_qla_host_t *vha)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700616{
Andrew Vasquezfca29702005-07-06 10:31:47 -0700617 int return_status;
618 unsigned long wait_online;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800619 struct qla_hw_data *ha = vha->hw;
620 scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700621
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700622 wait_online = jiffies + (MAX_LOOP_TIMEOUT * HZ);
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800623 while (((test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags)) ||
624 test_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags) ||
625 test_bit(ISP_ABORT_RETRY, &base_vha->dpc_flags) ||
626 ha->dpc_active) && time_before(jiffies, wait_online)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700627
628 msleep(1000);
629 }
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800630 if (base_vha->flags.online)
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700631 return_status = QLA_SUCCESS;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700632 else
633 return_status = QLA_FUNCTION_FAILED;
634
Linus Torvalds1da177e2005-04-16 15:20:36 -0700635 return (return_status);
636}
637
638/*
639 * qla2x00_wait_for_loop_ready
640 * Wait for MAX_LOOP_TIMEOUT(5 min) value for loop
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700641 * to be in LOOP_READY state.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700642 * Input:
643 * ha - pointer to host adapter structure
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700644 *
645 * Note:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700646 * Does context switching-Release SPIN_LOCK
647 * (if any) before calling this routine.
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700648 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700649 *
650 * Return:
651 * Success (LOOP_READY) : 0
652 * Failed (LOOP_NOT_READY) : 1
653 */
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700654static inline int
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800655qla2x00_wait_for_loop_ready(scsi_qla_host_t *vha)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700656{
657 int return_status = QLA_SUCCESS;
658 unsigned long loop_timeout ;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800659 struct qla_hw_data *ha = vha->hw;
660 scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700661
662 /* wait for 5 min at the max for loop to be ready */
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700663 loop_timeout = jiffies + (MAX_LOOP_TIMEOUT * HZ);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700664
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800665 while ((!atomic_read(&base_vha->loop_down_timer) &&
666 atomic_read(&base_vha->loop_state) == LOOP_DOWN) ||
667 atomic_read(&base_vha->loop_state) != LOOP_READY) {
668 if (atomic_read(&base_vha->loop_state) == LOOP_DEAD) {
Ravi Anand57680082006-05-17 15:08:44 -0700669 return_status = QLA_FUNCTION_FAILED;
670 break;
671 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700672 msleep(1000);
673 if (time_after_eq(jiffies, loop_timeout)) {
674 return_status = QLA_FUNCTION_FAILED;
675 break;
676 }
677 }
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700678 return (return_status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700679}
680
Seokmann Ju5f3a9a22008-07-10 16:55:47 -0700681void
682qla2x00_abort_fcport_cmds(fc_port_t *fcport)
683{
Anirban Chakraborty73208df2008-12-09 16:45:39 -0800684 int cnt, que, id;
Seokmann Ju5f3a9a22008-07-10 16:55:47 -0700685 unsigned long flags;
686 srb_t *sp;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800687 scsi_qla_host_t *vha = fcport->vha;
688 struct qla_hw_data *ha = vha->hw;
Anirban Chakraborty73208df2008-12-09 16:45:39 -0800689 struct req_que *req;
Seokmann Ju5f3a9a22008-07-10 16:55:47 -0700690
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800691 spin_lock_irqsave(&ha->hardware_lock, flags);
Anirban Chakraborty73208df2008-12-09 16:45:39 -0800692 for (que = 0; que < QLA_MAX_HOST_QUES; que++) {
693 id = vha->req_ques[que];
694 req = ha->req_q_map[id];
695 if (!req)
Seokmann Ju5f3a9a22008-07-10 16:55:47 -0700696 continue;
Anirban Chakraborty73208df2008-12-09 16:45:39 -0800697 for (cnt = 1; cnt < MAX_OUTSTANDING_COMMANDS; cnt++) {
698 sp = req->outstanding_cmds[cnt];
699 if (!sp)
700 continue;
701 if (sp->fcport != fcport)
702 continue;
Seokmann Ju5f3a9a22008-07-10 16:55:47 -0700703
Anirban Chakraborty73208df2008-12-09 16:45:39 -0800704 spin_unlock_irqrestore(&ha->hardware_lock, flags);
705 if (ha->isp_ops->abort_command(vha, sp, req)) {
Seokmann Ju5f3a9a22008-07-10 16:55:47 -0700706 DEBUG2(qla_printk(KERN_WARNING, ha,
Anirban Chakraborty73208df2008-12-09 16:45:39 -0800707 "Abort failed -- %lx\n",
708 sp->cmd->serial_number));
709 } else {
710 if (qla2x00_eh_wait_on_command(sp->cmd) !=
711 QLA_SUCCESS)
712 DEBUG2(qla_printk(KERN_WARNING, ha,
713 "Abort failed while waiting -- %lx\n",
714 sp->cmd->serial_number));
715 }
716 spin_lock_irqsave(&ha->hardware_lock, flags);
Seokmann Ju5f3a9a22008-07-10 16:55:47 -0700717 }
Seokmann Ju5f3a9a22008-07-10 16:55:47 -0700718 }
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800719 spin_unlock_irqrestore(&ha->hardware_lock, flags);
Seokmann Ju5f3a9a22008-07-10 16:55:47 -0700720}
721
Andrew Vasquez07db5182006-10-02 12:00:49 -0700722static void
723qla2x00_block_error_handler(struct scsi_cmnd *cmnd)
724{
725 struct Scsi_Host *shost = cmnd->device->host;
726 struct fc_rport *rport = starget_to_rport(scsi_target(cmnd->device));
727 unsigned long flags;
728
729 spin_lock_irqsave(shost->host_lock, flags);
730 while (rport->port_state == FC_PORTSTATE_BLOCKED) {
731 spin_unlock_irqrestore(shost->host_lock, flags);
732 msleep(1000);
733 spin_lock_irqsave(shost->host_lock, flags);
734 }
735 spin_unlock_irqrestore(shost->host_lock, flags);
736 return;
737}
738
Linus Torvalds1da177e2005-04-16 15:20:36 -0700739/**************************************************************************
740* qla2xxx_eh_abort
741*
742* Description:
743* The abort function will abort the specified command.
744*
745* Input:
746* cmd = Linux SCSI command packet to be aborted.
747*
748* Returns:
749* Either SUCCESS or FAILED.
750*
751* Note:
Michael Reed2ea00202006-04-27 16:25:30 -0700752* Only return FAILED if command not returned by firmware.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700753**************************************************************************/
Adrian Bunke5f82ab2006-11-08 19:55:50 -0800754static int
Linus Torvalds1da177e2005-04-16 15:20:36 -0700755qla2xxx_eh_abort(struct scsi_cmnd *cmd)
756{
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800757 scsi_qla_host_t *vha = shost_priv(cmd->device->host);
f4f051e2005-04-17 15:02:26 -0500758 srb_t *sp;
Anirban Chakraborty17d98632008-12-18 10:06:15 -0800759 int ret, i;
f4f051e2005-04-17 15:02:26 -0500760 unsigned int id, lun;
761 unsigned long serial;
Andrew Vasquez18e144d2005-05-27 15:04:47 -0700762 unsigned long flags;
Michael Reed2ea00202006-04-27 16:25:30 -0700763 int wait = 0;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800764 struct qla_hw_data *ha = vha->hw;
Anirban Chakraborty73208df2008-12-09 16:45:39 -0800765 struct req_que *req;
Anirban Chakraborty17d98632008-12-18 10:06:15 -0800766 srb_t *spt;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700767
Andrew Vasquez07db5182006-10-02 12:00:49 -0700768 qla2x00_block_error_handler(cmd);
769
f4f051e2005-04-17 15:02:26 -0500770 if (!CMD_SP(cmd))
Michael Reed2ea00202006-04-27 16:25:30 -0700771 return SUCCESS;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700772
Michael Reed2ea00202006-04-27 16:25:30 -0700773 ret = SUCCESS;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700774
f4f051e2005-04-17 15:02:26 -0500775 id = cmd->device->id;
776 lun = cmd->device->lun;
777 serial = cmd->serial_number;
Anirban Chakraborty17d98632008-12-18 10:06:15 -0800778 spt = (srb_t *) CMD_SP(cmd);
779 if (!spt)
780 return SUCCESS;
781 req = spt->que;
f4f051e2005-04-17 15:02:26 -0500782
783 /* Check active list for command command. */
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800784 spin_lock_irqsave(&ha->hardware_lock, flags);
Anirban Chakraborty17d98632008-12-18 10:06:15 -0800785 for (i = 1; i < MAX_OUTSTANDING_COMMANDS; i++) {
786 sp = req->outstanding_cmds[i];
787
788 if (sp == NULL)
f4f051e2005-04-17 15:02:26 -0500789 continue;
790
Anirban Chakraborty17d98632008-12-18 10:06:15 -0800791 if (sp->cmd != cmd)
792 continue;
f4f051e2005-04-17 15:02:26 -0500793
Anirban Chakraborty17d98632008-12-18 10:06:15 -0800794 DEBUG2(printk("%s(%ld): aborting sp %p from RISC."
795 " pid=%ld.\n", __func__, vha->host_no, sp, serial));
f4f051e2005-04-17 15:02:26 -0500796
Anirban Chakraborty17d98632008-12-18 10:06:15 -0800797 spin_unlock_irqrestore(&ha->hardware_lock, flags);
798 if (ha->isp_ops->abort_command(vha, sp, req)) {
799 DEBUG2(printk("%s(%ld): abort_command "
800 "mbx failed.\n", __func__, vha->host_no));
Andrew Vasquez2ac4b642009-01-22 09:45:35 -0800801 ret = FAILED;
Anirban Chakraborty17d98632008-12-18 10:06:15 -0800802 } else {
803 DEBUG3(printk("%s(%ld): abort_command "
804 "mbx success.\n", __func__, vha->host_no));
805 wait = 1;
f4f051e2005-04-17 15:02:26 -0500806 }
Anirban Chakraborty17d98632008-12-18 10:06:15 -0800807 spin_lock_irqsave(&ha->hardware_lock, flags);
808 break;
f4f051e2005-04-17 15:02:26 -0500809 }
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800810 spin_unlock_irqrestore(&ha->hardware_lock, flags);
f4f051e2005-04-17 15:02:26 -0500811
812 /* Wait for the command to be returned. */
Michael Reed2ea00202006-04-27 16:25:30 -0700813 if (wait) {
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800814 if (qla2x00_eh_wait_on_command(cmd) != QLA_SUCCESS) {
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700815 qla_printk(KERN_ERR, ha,
f4f051e2005-04-17 15:02:26 -0500816 "scsi(%ld:%d:%d): Abort handler timed out -- %lx "
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800817 "%x.\n", vha->host_no, id, lun, serial, ret);
Michael Reed2ea00202006-04-27 16:25:30 -0700818 ret = FAILED;
f4f051e2005-04-17 15:02:26 -0500819 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700820 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700821
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700822 qla_printk(KERN_INFO, ha,
Michael Reed2ea00202006-04-27 16:25:30 -0700823 "scsi(%ld:%d:%d): Abort command issued -- %d %lx %x.\n",
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800824 vha->host_no, id, lun, wait, serial, ret);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700825
f4f051e2005-04-17 15:02:26 -0500826 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700827}
828
Andrew Vasquez523ec772008-04-03 13:13:24 -0700829enum nexus_wait_type {
830 WAIT_HOST = 0,
831 WAIT_TARGET,
832 WAIT_LUN,
833};
834
Linus Torvalds1da177e2005-04-16 15:20:36 -0700835static int
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800836qla2x00_eh_wait_for_pending_commands(scsi_qla_host_t *vha, unsigned int t,
Anirban Chakraborty17d98632008-12-18 10:06:15 -0800837 unsigned int l, srb_t *sp, enum nexus_wait_type type)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700838{
Anirban Chakraborty17d98632008-12-18 10:06:15 -0800839 int cnt, match, status;
Andrew Vasquez18e144d2005-05-27 15:04:47 -0700840 unsigned long flags;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800841 struct qla_hw_data *ha = vha->hw;
Anirban Chakraborty73208df2008-12-09 16:45:39 -0800842 struct req_que *req;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700843
Andrew Vasquez523ec772008-04-03 13:13:24 -0700844 status = QLA_SUCCESS;
Anirban Chakraborty17d98632008-12-18 10:06:15 -0800845 if (!sp)
846 return status;
847
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800848 spin_lock_irqsave(&ha->hardware_lock, flags);
Anirban Chakraborty17d98632008-12-18 10:06:15 -0800849 req = sp->que;
850 for (cnt = 1; status == QLA_SUCCESS &&
851 cnt < MAX_OUTSTANDING_COMMANDS; cnt++) {
852 sp = req->outstanding_cmds[cnt];
853 if (!sp)
Andrew Vasquez523ec772008-04-03 13:13:24 -0700854 continue;
Andrew Vasquez19851f12008-08-13 21:37:00 -0700855
Anirban Chakraborty17d98632008-12-18 10:06:15 -0800856 if (vha->vp_idx != sp->fcport->vha->vp_idx)
857 continue;
858 match = 0;
859 switch (type) {
860 case WAIT_HOST:
861 match = 1;
862 break;
863 case WAIT_TARGET:
864 match = sp->cmd->device->id == t;
865 break;
866 case WAIT_LUN:
867 match = (sp->cmd->device->id == t &&
868 sp->cmd->device->lun == l);
869 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700870 }
Anirban Chakraborty17d98632008-12-18 10:06:15 -0800871 if (!match)
872 continue;
873
874 spin_unlock_irqrestore(&ha->hardware_lock, flags);
875 status = qla2x00_eh_wait_on_command(sp->cmd);
876 spin_lock_irqsave(&ha->hardware_lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700877 }
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800878 spin_unlock_irqrestore(&ha->hardware_lock, flags);
Andrew Vasquez523ec772008-04-03 13:13:24 -0700879
880 return status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700881}
882
Andrew Vasquez523ec772008-04-03 13:13:24 -0700883static char *reset_errors[] = {
884 "HBA not online",
885 "HBA not ready",
886 "Task management failed",
887 "Waiting for command completions",
888};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700889
Andrew Vasquez523ec772008-04-03 13:13:24 -0700890static int
891__qla2xxx_eh_generic_reset(char *name, enum nexus_wait_type type,
892 struct scsi_cmnd *cmd, int (*do_reset)(struct fc_port *, unsigned int))
893{
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800894 scsi_qla_host_t *vha = shost_priv(cmd->device->host);
Andrew Vasquez523ec772008-04-03 13:13:24 -0700895 fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata;
896 int err;
897
898 qla2x00_block_error_handler(cmd);
899
900 if (!fcport)
901 return FAILED;
902
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800903 qla_printk(KERN_INFO, vha->hw, "scsi(%ld:%d:%d): %s RESET ISSUED.\n",
904 vha->host_no, cmd->device->id, cmd->device->lun, name);
Andrew Vasquez523ec772008-04-03 13:13:24 -0700905
906 err = 0;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800907 if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS)
Andrew Vasquez523ec772008-04-03 13:13:24 -0700908 goto eh_reset_failed;
909 err = 1;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800910 if (qla2x00_wait_for_loop_ready(vha) != QLA_SUCCESS)
Andrew Vasquez523ec772008-04-03 13:13:24 -0700911 goto eh_reset_failed;
912 err = 2;
913 if (do_reset(fcport, cmd->device->lun) != QLA_SUCCESS)
914 goto eh_reset_failed;
915 err = 3;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800916 if (qla2x00_eh_wait_for_pending_commands(vha, cmd->device->id,
Anirban Chakraborty17d98632008-12-18 10:06:15 -0800917 cmd->device->lun, (srb_t *) CMD_SP(cmd), type) != QLA_SUCCESS)
Andrew Vasquez523ec772008-04-03 13:13:24 -0700918 goto eh_reset_failed;
919
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800920 qla_printk(KERN_INFO, vha->hw, "scsi(%ld:%d:%d): %s RESET SUCCEEDED.\n",
921 vha->host_no, cmd->device->id, cmd->device->lun, name);
Andrew Vasquez523ec772008-04-03 13:13:24 -0700922
923 return SUCCESS;
924
925 eh_reset_failed:
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800926 qla_printk(KERN_INFO, vha->hw, "scsi(%ld:%d:%d): %s RESET FAILED: %s.\n"
927 , vha->host_no, cmd->device->id, cmd->device->lun, name,
Andrew Vasquez523ec772008-04-03 13:13:24 -0700928 reset_errors[err]);
929 return FAILED;
930}
931
Adrian Bunke5f82ab2006-11-08 19:55:50 -0800932static int
Linus Torvalds1da177e2005-04-16 15:20:36 -0700933qla2xxx_eh_device_reset(struct scsi_cmnd *cmd)
934{
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800935 scsi_qla_host_t *vha = shost_priv(cmd->device->host);
936 struct qla_hw_data *ha = vha->hw;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700937
Andrew Vasquez523ec772008-04-03 13:13:24 -0700938 return __qla2xxx_eh_generic_reset("DEVICE", WAIT_LUN, cmd,
939 ha->isp_ops->lun_reset);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700940}
941
Linus Torvalds1da177e2005-04-16 15:20:36 -0700942static int
Andrew Vasquez523ec772008-04-03 13:13:24 -0700943qla2xxx_eh_target_reset(struct scsi_cmnd *cmd)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700944{
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800945 scsi_qla_host_t *vha = shost_priv(cmd->device->host);
946 struct qla_hw_data *ha = vha->hw;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700947
Andrew Vasquez523ec772008-04-03 13:13:24 -0700948 return __qla2xxx_eh_generic_reset("TARGET", WAIT_TARGET, cmd,
949 ha->isp_ops->target_reset);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700950}
951
Linus Torvalds1da177e2005-04-16 15:20:36 -0700952/**************************************************************************
953* qla2xxx_eh_bus_reset
954*
955* Description:
956* The bus reset function will reset the bus and abort any executing
957* commands.
958*
959* Input:
960* cmd = Linux SCSI command packet of the command that cause the
961* bus reset.
962*
963* Returns:
964* SUCCESS/FAILURE (defined as macro in scsi.h).
965*
966**************************************************************************/
Adrian Bunke5f82ab2006-11-08 19:55:50 -0800967static int
Linus Torvalds1da177e2005-04-16 15:20:36 -0700968qla2xxx_eh_bus_reset(struct scsi_cmnd *cmd)
969{
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800970 scsi_qla_host_t *vha = shost_priv(cmd->device->host);
bdf79622005-04-17 15:06:53 -0500971 fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata;
Seokmann Ju2c3dfe32007-07-05 13:16:51 -0700972 int ret = FAILED;
f4f051e2005-04-17 15:02:26 -0500973 unsigned int id, lun;
974 unsigned long serial;
Anirban Chakraborty17d98632008-12-18 10:06:15 -0800975 srb_t *sp = (srb_t *) CMD_SP(cmd);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700976
Andrew Vasquez07db5182006-10-02 12:00:49 -0700977 qla2x00_block_error_handler(cmd);
978
f4f051e2005-04-17 15:02:26 -0500979 id = cmd->device->id;
980 lun = cmd->device->lun;
981 serial = cmd->serial_number;
982
Vladislav Bolkhovitinb0328be2006-08-01 13:48:15 -0700983 if (!fcport)
f4f051e2005-04-17 15:02:26 -0500984 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700985
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800986 qla_printk(KERN_INFO, vha->hw,
Anirban Chakraborty749af3d2008-11-14 13:48:12 -0800987 "scsi(%ld:%d:%d): BUS RESET ISSUED.\n", vha->host_no, id, lun);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700988
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800989 if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700990 DEBUG2(printk("%s failed:board disabled\n",__func__));
f4f051e2005-04-17 15:02:26 -0500991 goto eh_bus_reset_done;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700992 }
993
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800994 if (qla2x00_wait_for_loop_ready(vha) == QLA_SUCCESS) {
995 if (qla2x00_loop_reset(vha) == QLA_SUCCESS)
f4f051e2005-04-17 15:02:26 -0500996 ret = SUCCESS;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700997 }
f4f051e2005-04-17 15:02:26 -0500998 if (ret == FAILED)
999 goto eh_bus_reset_done;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001000
Andrew Vasquez9a41a622005-09-20 13:25:53 -07001001 /* Flush outstanding commands. */
Anirban Chakraborty17d98632008-12-18 10:06:15 -08001002 if (qla2x00_eh_wait_for_pending_commands(vha, 0, 0, sp, WAIT_HOST) !=
Andrew Vasquez523ec772008-04-03 13:13:24 -07001003 QLA_SUCCESS)
Andrew Vasquez9a41a622005-09-20 13:25:53 -07001004 ret = FAILED;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001005
f4f051e2005-04-17 15:02:26 -05001006eh_bus_reset_done:
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001007 qla_printk(KERN_INFO, vha->hw, "%s: reset %s\n", __func__,
f4f051e2005-04-17 15:02:26 -05001008 (ret == FAILED) ? "failed" : "succeded");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001009
f4f051e2005-04-17 15:02:26 -05001010 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001011}
1012
1013/**************************************************************************
1014* qla2xxx_eh_host_reset
1015*
1016* Description:
1017* The reset function will reset the Adapter.
1018*
1019* Input:
1020* cmd = Linux SCSI command packet of the command that cause the
1021* adapter reset.
1022*
1023* Returns:
1024* Either SUCCESS or FAILED.
1025*
1026* Note:
1027**************************************************************************/
Adrian Bunke5f82ab2006-11-08 19:55:50 -08001028static int
Linus Torvalds1da177e2005-04-16 15:20:36 -07001029qla2xxx_eh_host_reset(struct scsi_cmnd *cmd)
1030{
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001031 scsi_qla_host_t *vha = shost_priv(cmd->device->host);
bdf79622005-04-17 15:06:53 -05001032 fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001033 struct qla_hw_data *ha = vha->hw;
Seokmann Ju2c3dfe32007-07-05 13:16:51 -07001034 int ret = FAILED;
f4f051e2005-04-17 15:02:26 -05001035 unsigned int id, lun;
1036 unsigned long serial;
Anirban Chakraborty17d98632008-12-18 10:06:15 -08001037 srb_t *sp = (srb_t *) CMD_SP(cmd);
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001038 scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001039
Andrew Vasquez07db5182006-10-02 12:00:49 -07001040 qla2x00_block_error_handler(cmd);
1041
f4f051e2005-04-17 15:02:26 -05001042 id = cmd->device->id;
1043 lun = cmd->device->lun;
1044 serial = cmd->serial_number;
1045
Vladislav Bolkhovitinb0328be2006-08-01 13:48:15 -07001046 if (!fcport)
f4f051e2005-04-17 15:02:26 -05001047 return ret;
1048
Linus Torvalds1da177e2005-04-16 15:20:36 -07001049 qla_printk(KERN_INFO, ha,
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001050 "scsi(%ld:%d:%d): ADAPTER RESET ISSUED.\n", vha->host_no, id, lun);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001051
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001052 if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS)
f4f051e2005-04-17 15:02:26 -05001053 goto eh_host_reset_lock;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001054
1055 /*
1056 * Fixme-may be dpc thread is active and processing
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -07001057 * loop_resync,so wait a while for it to
Linus Torvalds1da177e2005-04-16 15:20:36 -07001058 * be completed and then issue big hammer.Otherwise
1059 * it may cause I/O failure as big hammer marks the
1060 * devices as lost kicking of the port_down_timer
1061 * while dpc is stuck for the mailbox to complete.
1062 */
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001063 qla2x00_wait_for_loop_ready(vha);
1064 if (vha != base_vha) {
1065 if (qla2x00_vp_abort_isp(vha))
f4f051e2005-04-17 15:02:26 -05001066 goto eh_host_reset_lock;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001067 } else {
1068 set_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags);
1069 if (qla2x00_abort_isp(base_vha)) {
1070 clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags);
1071 /* failed. schedule dpc to try */
1072 set_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags);
1073
1074 if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS)
1075 goto eh_host_reset_lock;
1076 }
1077 clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags);
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -07001078 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001079
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001080 /* Waiting for command to be returned to OS.*/
Anirban Chakraborty17d98632008-12-18 10:06:15 -08001081 if (qla2x00_eh_wait_for_pending_commands(vha, 0, 0, sp, WAIT_HOST) ==
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001082 QLA_SUCCESS)
f4f051e2005-04-17 15:02:26 -05001083 ret = SUCCESS;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001084
f4f051e2005-04-17 15:02:26 -05001085eh_host_reset_lock:
f4f051e2005-04-17 15:02:26 -05001086 qla_printk(KERN_INFO, ha, "%s: reset %s\n", __func__,
1087 (ret == FAILED) ? "failed" : "succeded");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001088
f4f051e2005-04-17 15:02:26 -05001089 return ret;
1090}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001091
1092/*
1093* qla2x00_loop_reset
1094* Issue loop reset.
1095*
1096* Input:
1097* ha = adapter block pointer.
1098*
1099* Returns:
1100* 0 = success
1101*/
Andrew Vasqueza4722cf2008-01-17 09:02:12 -08001102int
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001103qla2x00_loop_reset(scsi_qla_host_t *vha)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001104{
Andrew Vasquez0c8c39a2006-12-13 19:20:30 -08001105 int ret;
bdf79622005-04-17 15:06:53 -05001106 struct fc_port *fcport;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001107 struct qla_hw_data *ha = vha->hw;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001108
Anirban Chakraborty749af3d2008-11-14 13:48:12 -08001109 if (ha->flags.enable_lip_full_login && !vha->vp_idx) {
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001110 ret = qla2x00_full_login_lip(vha);
Andrew Vasquez0c8c39a2006-12-13 19:20:30 -08001111 if (ret != QLA_SUCCESS) {
Anirban Chakraborty749af3d2008-11-14 13:48:12 -08001112 DEBUG2_3(printk("%s(%ld): failed: "
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001113 "full_login_lip=%d.\n", __func__, vha->host_no,
Andrew Vasquez0c8c39a2006-12-13 19:20:30 -08001114 ret));
Anirban Chakraborty749af3d2008-11-14 13:48:12 -08001115 }
1116 atomic_set(&vha->loop_state, LOOP_DOWN);
1117 atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME);
1118 qla2x00_mark_all_devices_lost(vha, 0);
1119 qla2x00_wait_for_loop_ready(vha);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001120 }
1121
Anirban Chakraborty749af3d2008-11-14 13:48:12 -08001122 if (ha->flags.enable_lip_reset && !vha->vp_idx) {
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001123 ret = qla2x00_lip_reset(vha);
Andrew Vasquez0c8c39a2006-12-13 19:20:30 -08001124 if (ret != QLA_SUCCESS) {
Anirban Chakraborty749af3d2008-11-14 13:48:12 -08001125 DEBUG2_3(printk("%s(%ld): failed: "
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001126 "lip_reset=%d.\n", __func__, vha->host_no, ret));
1127 } else
1128 qla2x00_wait_for_loop_ready(vha);
Andrew Vasquez0c8c39a2006-12-13 19:20:30 -08001129 }
1130
1131 if (ha->flags.enable_target_reset) {
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001132 list_for_each_entry(fcport, &vha->vp_fcports, list) {
bdf79622005-04-17 15:06:53 -05001133 if (fcport->port_type != FCT_TARGET)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001134 continue;
1135
Andrew Vasquez523ec772008-04-03 13:13:24 -07001136 ret = ha->isp_ops->target_reset(fcport, 0);
Andrew Vasquez0c8c39a2006-12-13 19:20:30 -08001137 if (ret != QLA_SUCCESS) {
1138 DEBUG2_3(printk("%s(%ld): bus_reset failed: "
1139 "target_reset=%d d_id=%x.\n", __func__,
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001140 vha->host_no, ret, fcport->d_id.b24));
Andrew Vasquez0c8c39a2006-12-13 19:20:30 -08001141 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001142 }
1143 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001144 /* Issue marker command only when we are going to start the I/O */
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001145 vha->marker_needed = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001146
Andrew Vasquez0c8c39a2006-12-13 19:20:30 -08001147 return QLA_SUCCESS;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001148}
1149
Andrew Vasquezdf4bf0b2008-01-31 12:33:46 -08001150void
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001151qla2x00_abort_all_cmds(scsi_qla_host_t *vha, int res)
Andrew Vasquezdf4bf0b2008-01-31 12:33:46 -08001152{
Anirban Chakraborty73208df2008-12-09 16:45:39 -08001153 int que, cnt;
Andrew Vasquezdf4bf0b2008-01-31 12:33:46 -08001154 unsigned long flags;
1155 srb_t *sp;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001156 struct qla_hw_data *ha = vha->hw;
Anirban Chakraborty73208df2008-12-09 16:45:39 -08001157 struct req_que *req;
Andrew Vasquezdf4bf0b2008-01-31 12:33:46 -08001158
1159 spin_lock_irqsave(&ha->hardware_lock, flags);
Anirban Chakraborty29bdccb2009-01-08 15:41:08 -08001160 for (que = 0; que < ha->max_queues; que++) {
1161 req = ha->req_q_map[que];
Anirban Chakraborty73208df2008-12-09 16:45:39 -08001162 if (!req)
1163 continue;
1164 for (cnt = 1; cnt < MAX_OUTSTANDING_COMMANDS; cnt++) {
1165 sp = req->outstanding_cmds[cnt];
Andrew Vasquez444786d2009-01-05 11:18:10 -08001166 if (sp && sp->fcport->vha == vha) {
Anirban Chakraborty73208df2008-12-09 16:45:39 -08001167 req->outstanding_cmds[cnt] = NULL;
1168 sp->cmd->result = res;
1169 qla2x00_sp_compl(ha, sp);
1170 }
Andrew Vasquezdf4bf0b2008-01-31 12:33:46 -08001171 }
1172 }
1173 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1174}
1175
f4f051e2005-04-17 15:02:26 -05001176static int
1177qla2xxx_slave_alloc(struct scsi_device *sdev)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001178{
bdf79622005-04-17 15:06:53 -05001179 struct fc_rport *rport = starget_to_rport(scsi_target(sdev));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001180
James.Smart@Emulex.Com19a7b4a2005-10-18 12:03:35 -04001181 if (!rport || fc_remote_port_chkready(rport))
f4f051e2005-04-17 15:02:26 -05001182 return -ENXIO;
1183
James.Smart@Emulex.Com19a7b4a2005-10-18 12:03:35 -04001184 sdev->hostdata = *(fc_port_t **)rport->dd_data;
f4f051e2005-04-17 15:02:26 -05001185
1186 return 0;
1187}
1188
1189static int
1190qla2xxx_slave_configure(struct scsi_device *sdev)
1191{
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001192 scsi_qla_host_t *vha = shost_priv(sdev->host);
1193 struct qla_hw_data *ha = vha->hw;
8482e1182005-04-17 15:04:54 -05001194 struct fc_rport *rport = starget_to_rport(sdev->sdev_target);
Anirban Chakraborty29bdccb2009-01-08 15:41:08 -08001195 struct req_que *req = ha->req_q_map[vha->req_ques[0]];
8482e1182005-04-17 15:04:54 -05001196
f4f051e2005-04-17 15:02:26 -05001197 if (sdev->tagged_supported)
Anirban Chakraborty73208df2008-12-09 16:45:39 -08001198 scsi_activate_tcq(sdev, req->max_q_depth);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001199 else
Anirban Chakraborty73208df2008-12-09 16:45:39 -08001200 scsi_deactivate_tcq(sdev, req->max_q_depth);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001201
Andrew Vasquez85821c92008-07-10 16:55:48 -07001202 rport->dev_loss_tmo = ha->port_down_retry_count;
8482e1182005-04-17 15:04:54 -05001203
f4f051e2005-04-17 15:02:26 -05001204 return 0;
1205}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001206
f4f051e2005-04-17 15:02:26 -05001207static void
1208qla2xxx_slave_destroy(struct scsi_device *sdev)
1209{
1210 sdev->hostdata = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001211}
1212
Andrew Vasquezce7e4af2005-08-26 19:09:30 -07001213static int
1214qla2x00_change_queue_depth(struct scsi_device *sdev, int qdepth)
1215{
1216 scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), qdepth);
1217 return sdev->queue_depth;
1218}
1219
1220static int
1221qla2x00_change_queue_type(struct scsi_device *sdev, int tag_type)
1222{
1223 if (sdev->tagged_supported) {
1224 scsi_set_tag_type(sdev, tag_type);
1225 if (tag_type)
1226 scsi_activate_tcq(sdev, sdev->queue_depth);
1227 else
1228 scsi_deactivate_tcq(sdev, sdev->queue_depth);
1229 } else
1230 tag_type = 0;
1231
1232 return tag_type;
1233}
1234
Linus Torvalds1da177e2005-04-16 15:20:36 -07001235/**
1236 * qla2x00_config_dma_addressing() - Configure OS DMA addressing method.
1237 * @ha: HA context
1238 *
1239 * At exit, the @ha's flags.enable_64bit_addressing set to indicated
1240 * supported addressing method.
1241 */
1242static void
Andrew Vasquez53303c42009-01-22 09:45:37 -08001243qla2x00_config_dma_addressing(struct qla_hw_data *ha)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001244{
Andrew Vasquez7524f9b2005-08-26 19:08:00 -07001245 /* Assume a 32bit DMA mask. */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001246 ha->flags.enable_64bit_addressing = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001247
Andrew Vasquez7524f9b2005-08-26 19:08:00 -07001248 if (!dma_set_mask(&ha->pdev->dev, DMA_64BIT_MASK)) {
1249 /* Any upper-dword bits set? */
1250 if (MSD(dma_get_required_mask(&ha->pdev->dev)) &&
1251 !pci_set_consistent_dma_mask(ha->pdev, DMA_64BIT_MASK)) {
1252 /* Ok, a 64bit DMA mask is applicable. */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001253 ha->flags.enable_64bit_addressing = 1;
Andrew Vasquezfd34f552007-07-19 15:06:00 -07001254 ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
1255 ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
Andrew Vasquez7524f9b2005-08-26 19:08:00 -07001256 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001257 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001258 }
Andrew Vasquez7524f9b2005-08-26 19:08:00 -07001259
1260 dma_set_mask(&ha->pdev->dev, DMA_32BIT_MASK);
1261 pci_set_consistent_dma_mask(ha->pdev, DMA_32BIT_MASK);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001262}
1263
Andrew Vasquezfd34f552007-07-19 15:06:00 -07001264static void
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001265qla2x00_enable_intrs(struct qla_hw_data *ha)
Andrew Vasquezfd34f552007-07-19 15:06:00 -07001266{
1267 unsigned long flags = 0;
1268 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
1269
1270 spin_lock_irqsave(&ha->hardware_lock, flags);
1271 ha->interrupts_on = 1;
1272 /* enable risc and host interrupts */
1273 WRT_REG_WORD(&reg->ictrl, ICR_EN_INT | ICR_EN_RISC);
1274 RD_REG_WORD(&reg->ictrl);
1275 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1276
1277}
1278
1279static void
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001280qla2x00_disable_intrs(struct qla_hw_data *ha)
Andrew Vasquezfd34f552007-07-19 15:06:00 -07001281{
1282 unsigned long flags = 0;
1283 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
1284
1285 spin_lock_irqsave(&ha->hardware_lock, flags);
1286 ha->interrupts_on = 0;
1287 /* disable risc and host interrupts */
1288 WRT_REG_WORD(&reg->ictrl, 0);
1289 RD_REG_WORD(&reg->ictrl);
1290 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1291}
1292
1293static void
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001294qla24xx_enable_intrs(struct qla_hw_data *ha)
Andrew Vasquezfd34f552007-07-19 15:06:00 -07001295{
1296 unsigned long flags = 0;
1297 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
1298
1299 spin_lock_irqsave(&ha->hardware_lock, flags);
1300 ha->interrupts_on = 1;
1301 WRT_REG_DWORD(&reg->ictrl, ICRX_EN_RISC_INT);
1302 RD_REG_DWORD(&reg->ictrl);
1303 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1304}
1305
1306static void
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001307qla24xx_disable_intrs(struct qla_hw_data *ha)
Andrew Vasquezfd34f552007-07-19 15:06:00 -07001308{
1309 unsigned long flags = 0;
1310 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
1311
Andrew Vasquez124f85e2009-01-05 11:18:06 -08001312 if (IS_NOPOLLING_TYPE(ha))
1313 return;
Andrew Vasquezfd34f552007-07-19 15:06:00 -07001314 spin_lock_irqsave(&ha->hardware_lock, flags);
1315 ha->interrupts_on = 0;
1316 WRT_REG_DWORD(&reg->ictrl, 0);
1317 RD_REG_DWORD(&reg->ictrl);
1318 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1319}
1320
1321static struct isp_operations qla2100_isp_ops = {
1322 .pci_config = qla2100_pci_config,
1323 .reset_chip = qla2x00_reset_chip,
1324 .chip_diag = qla2x00_chip_diag,
1325 .config_rings = qla2x00_config_rings,
1326 .reset_adapter = qla2x00_reset_adapter,
1327 .nvram_config = qla2x00_nvram_config,
1328 .update_fw_options = qla2x00_update_fw_options,
1329 .load_risc = qla2x00_load_risc,
1330 .pci_info_str = qla2x00_pci_info_str,
1331 .fw_version_str = qla2x00_fw_version_str,
1332 .intr_handler = qla2100_intr_handler,
1333 .enable_intrs = qla2x00_enable_intrs,
1334 .disable_intrs = qla2x00_disable_intrs,
1335 .abort_command = qla2x00_abort_command,
Andrew Vasquez523ec772008-04-03 13:13:24 -07001336 .target_reset = qla2x00_abort_target,
1337 .lun_reset = qla2x00_lun_reset,
Andrew Vasquezfd34f552007-07-19 15:06:00 -07001338 .fabric_login = qla2x00_login_fabric,
1339 .fabric_logout = qla2x00_fabric_logout,
1340 .calc_req_entries = qla2x00_calc_iocbs_32,
1341 .build_iocbs = qla2x00_build_scsi_iocbs_32,
1342 .prep_ms_iocb = qla2x00_prep_ms_iocb,
1343 .prep_ms_fdmi_iocb = qla2x00_prep_ms_fdmi_iocb,
1344 .read_nvram = qla2x00_read_nvram_data,
1345 .write_nvram = qla2x00_write_nvram_data,
1346 .fw_dump = qla2100_fw_dump,
1347 .beacon_on = NULL,
1348 .beacon_off = NULL,
1349 .beacon_blink = NULL,
1350 .read_optrom = qla2x00_read_optrom_data,
1351 .write_optrom = qla2x00_write_optrom_data,
1352 .get_flash_version = qla2x00_get_flash_version,
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001353 .start_scsi = qla2x00_start_scsi,
Andrew Vasquezfd34f552007-07-19 15:06:00 -07001354};
1355
1356static struct isp_operations qla2300_isp_ops = {
1357 .pci_config = qla2300_pci_config,
1358 .reset_chip = qla2x00_reset_chip,
1359 .chip_diag = qla2x00_chip_diag,
1360 .config_rings = qla2x00_config_rings,
1361 .reset_adapter = qla2x00_reset_adapter,
1362 .nvram_config = qla2x00_nvram_config,
1363 .update_fw_options = qla2x00_update_fw_options,
1364 .load_risc = qla2x00_load_risc,
1365 .pci_info_str = qla2x00_pci_info_str,
1366 .fw_version_str = qla2x00_fw_version_str,
1367 .intr_handler = qla2300_intr_handler,
1368 .enable_intrs = qla2x00_enable_intrs,
1369 .disable_intrs = qla2x00_disable_intrs,
1370 .abort_command = qla2x00_abort_command,
Andrew Vasquez523ec772008-04-03 13:13:24 -07001371 .target_reset = qla2x00_abort_target,
1372 .lun_reset = qla2x00_lun_reset,
Andrew Vasquezfd34f552007-07-19 15:06:00 -07001373 .fabric_login = qla2x00_login_fabric,
1374 .fabric_logout = qla2x00_fabric_logout,
1375 .calc_req_entries = qla2x00_calc_iocbs_32,
1376 .build_iocbs = qla2x00_build_scsi_iocbs_32,
1377 .prep_ms_iocb = qla2x00_prep_ms_iocb,
1378 .prep_ms_fdmi_iocb = qla2x00_prep_ms_fdmi_iocb,
1379 .read_nvram = qla2x00_read_nvram_data,
1380 .write_nvram = qla2x00_write_nvram_data,
1381 .fw_dump = qla2300_fw_dump,
1382 .beacon_on = qla2x00_beacon_on,
1383 .beacon_off = qla2x00_beacon_off,
1384 .beacon_blink = qla2x00_beacon_blink,
1385 .read_optrom = qla2x00_read_optrom_data,
1386 .write_optrom = qla2x00_write_optrom_data,
1387 .get_flash_version = qla2x00_get_flash_version,
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001388 .start_scsi = qla2x00_start_scsi,
Andrew Vasquezfd34f552007-07-19 15:06:00 -07001389};
1390
1391static struct isp_operations qla24xx_isp_ops = {
1392 .pci_config = qla24xx_pci_config,
1393 .reset_chip = qla24xx_reset_chip,
1394 .chip_diag = qla24xx_chip_diag,
1395 .config_rings = qla24xx_config_rings,
1396 .reset_adapter = qla24xx_reset_adapter,
1397 .nvram_config = qla24xx_nvram_config,
1398 .update_fw_options = qla24xx_update_fw_options,
1399 .load_risc = qla24xx_load_risc,
1400 .pci_info_str = qla24xx_pci_info_str,
1401 .fw_version_str = qla24xx_fw_version_str,
1402 .intr_handler = qla24xx_intr_handler,
1403 .enable_intrs = qla24xx_enable_intrs,
1404 .disable_intrs = qla24xx_disable_intrs,
1405 .abort_command = qla24xx_abort_command,
Andrew Vasquez523ec772008-04-03 13:13:24 -07001406 .target_reset = qla24xx_abort_target,
1407 .lun_reset = qla24xx_lun_reset,
Andrew Vasquezfd34f552007-07-19 15:06:00 -07001408 .fabric_login = qla24xx_login_fabric,
1409 .fabric_logout = qla24xx_fabric_logout,
1410 .calc_req_entries = NULL,
1411 .build_iocbs = NULL,
1412 .prep_ms_iocb = qla24xx_prep_ms_iocb,
1413 .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb,
1414 .read_nvram = qla24xx_read_nvram_data,
1415 .write_nvram = qla24xx_write_nvram_data,
1416 .fw_dump = qla24xx_fw_dump,
1417 .beacon_on = qla24xx_beacon_on,
1418 .beacon_off = qla24xx_beacon_off,
1419 .beacon_blink = qla24xx_beacon_blink,
1420 .read_optrom = qla24xx_read_optrom_data,
1421 .write_optrom = qla24xx_write_optrom_data,
1422 .get_flash_version = qla24xx_get_flash_version,
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001423 .start_scsi = qla24xx_start_scsi,
Andrew Vasquezfd34f552007-07-19 15:06:00 -07001424};
1425
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001426static struct isp_operations qla25xx_isp_ops = {
1427 .pci_config = qla25xx_pci_config,
1428 .reset_chip = qla24xx_reset_chip,
1429 .chip_diag = qla24xx_chip_diag,
1430 .config_rings = qla24xx_config_rings,
1431 .reset_adapter = qla24xx_reset_adapter,
1432 .nvram_config = qla24xx_nvram_config,
1433 .update_fw_options = qla24xx_update_fw_options,
1434 .load_risc = qla24xx_load_risc,
1435 .pci_info_str = qla24xx_pci_info_str,
1436 .fw_version_str = qla24xx_fw_version_str,
1437 .intr_handler = qla24xx_intr_handler,
1438 .enable_intrs = qla24xx_enable_intrs,
1439 .disable_intrs = qla24xx_disable_intrs,
1440 .abort_command = qla24xx_abort_command,
Andrew Vasquez523ec772008-04-03 13:13:24 -07001441 .target_reset = qla24xx_abort_target,
1442 .lun_reset = qla24xx_lun_reset,
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001443 .fabric_login = qla24xx_login_fabric,
1444 .fabric_logout = qla24xx_fabric_logout,
1445 .calc_req_entries = NULL,
1446 .build_iocbs = NULL,
1447 .prep_ms_iocb = qla24xx_prep_ms_iocb,
1448 .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb,
1449 .read_nvram = qla25xx_read_nvram_data,
1450 .write_nvram = qla25xx_write_nvram_data,
1451 .fw_dump = qla25xx_fw_dump,
1452 .beacon_on = qla24xx_beacon_on,
1453 .beacon_off = qla24xx_beacon_off,
1454 .beacon_blink = qla24xx_beacon_blink,
Andrew Vasquez338c9162007-09-20 14:07:33 -07001455 .read_optrom = qla25xx_read_optrom_data,
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001456 .write_optrom = qla24xx_write_optrom_data,
1457 .get_flash_version = qla24xx_get_flash_version,
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001458 .start_scsi = qla24xx_start_scsi,
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001459};
1460
Andrew Vasquez3a03eb72009-01-05 11:18:11 -08001461static struct isp_operations qla81xx_isp_ops = {
1462 .pci_config = qla25xx_pci_config,
1463 .reset_chip = qla24xx_reset_chip,
1464 .chip_diag = qla24xx_chip_diag,
1465 .config_rings = qla24xx_config_rings,
1466 .reset_adapter = qla24xx_reset_adapter,
1467 .nvram_config = qla81xx_nvram_config,
1468 .update_fw_options = qla81xx_update_fw_options,
Andrew Vasquezeaac30b2009-01-22 09:45:32 -08001469 .load_risc = qla81xx_load_risc,
Andrew Vasquez3a03eb72009-01-05 11:18:11 -08001470 .pci_info_str = qla24xx_pci_info_str,
1471 .fw_version_str = qla24xx_fw_version_str,
1472 .intr_handler = qla24xx_intr_handler,
1473 .enable_intrs = qla24xx_enable_intrs,
1474 .disable_intrs = qla24xx_disable_intrs,
1475 .abort_command = qla24xx_abort_command,
1476 .target_reset = qla24xx_abort_target,
1477 .lun_reset = qla24xx_lun_reset,
1478 .fabric_login = qla24xx_login_fabric,
1479 .fabric_logout = qla24xx_fabric_logout,
1480 .calc_req_entries = NULL,
1481 .build_iocbs = NULL,
1482 .prep_ms_iocb = qla24xx_prep_ms_iocb,
1483 .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb,
1484 .read_nvram = qla25xx_read_nvram_data,
1485 .write_nvram = qla25xx_write_nvram_data,
1486 .fw_dump = qla81xx_fw_dump,
1487 .beacon_on = qla24xx_beacon_on,
1488 .beacon_off = qla24xx_beacon_off,
1489 .beacon_blink = qla24xx_beacon_blink,
1490 .read_optrom = qla25xx_read_optrom_data,
1491 .write_optrom = qla24xx_write_optrom_data,
1492 .get_flash_version = qla24xx_get_flash_version,
1493 .start_scsi = qla24xx_start_scsi,
Andrew Vasquez3a03eb72009-01-05 11:18:11 -08001494};
1495
andrew.vasquez@qlogic.comea5b6382006-03-09 14:27:08 -08001496static inline void
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001497qla2x00_set_isp_flags(struct qla_hw_data *ha)
andrew.vasquez@qlogic.comea5b6382006-03-09 14:27:08 -08001498{
1499 ha->device_type = DT_EXTENDED_IDS;
1500 switch (ha->pdev->device) {
1501 case PCI_DEVICE_ID_QLOGIC_ISP2100:
1502 ha->device_type |= DT_ISP2100;
1503 ha->device_type &= ~DT_EXTENDED_IDS;
Andrew Vasquez441d1072006-05-17 15:09:34 -07001504 ha->fw_srisc_address = RISC_START_ADDRESS_2100;
andrew.vasquez@qlogic.comea5b6382006-03-09 14:27:08 -08001505 break;
1506 case PCI_DEVICE_ID_QLOGIC_ISP2200:
1507 ha->device_type |= DT_ISP2200;
1508 ha->device_type &= ~DT_EXTENDED_IDS;
Andrew Vasquez441d1072006-05-17 15:09:34 -07001509 ha->fw_srisc_address = RISC_START_ADDRESS_2100;
andrew.vasquez@qlogic.comea5b6382006-03-09 14:27:08 -08001510 break;
1511 case PCI_DEVICE_ID_QLOGIC_ISP2300:
1512 ha->device_type |= DT_ISP2300;
andrew.vasquez@qlogic.com4a59f712006-03-09 14:27:39 -08001513 ha->device_type |= DT_ZIO_SUPPORTED;
Andrew Vasquez441d1072006-05-17 15:09:34 -07001514 ha->fw_srisc_address = RISC_START_ADDRESS_2300;
andrew.vasquez@qlogic.comea5b6382006-03-09 14:27:08 -08001515 break;
1516 case PCI_DEVICE_ID_QLOGIC_ISP2312:
1517 ha->device_type |= DT_ISP2312;
andrew.vasquez@qlogic.com4a59f712006-03-09 14:27:39 -08001518 ha->device_type |= DT_ZIO_SUPPORTED;
Andrew Vasquez441d1072006-05-17 15:09:34 -07001519 ha->fw_srisc_address = RISC_START_ADDRESS_2300;
andrew.vasquez@qlogic.comea5b6382006-03-09 14:27:08 -08001520 break;
1521 case PCI_DEVICE_ID_QLOGIC_ISP2322:
1522 ha->device_type |= DT_ISP2322;
andrew.vasquez@qlogic.com4a59f712006-03-09 14:27:39 -08001523 ha->device_type |= DT_ZIO_SUPPORTED;
andrew.vasquez@qlogic.comea5b6382006-03-09 14:27:08 -08001524 if (ha->pdev->subsystem_vendor == 0x1028 &&
1525 ha->pdev->subsystem_device == 0x0170)
1526 ha->device_type |= DT_OEM_001;
Andrew Vasquez441d1072006-05-17 15:09:34 -07001527 ha->fw_srisc_address = RISC_START_ADDRESS_2300;
andrew.vasquez@qlogic.comea5b6382006-03-09 14:27:08 -08001528 break;
1529 case PCI_DEVICE_ID_QLOGIC_ISP6312:
1530 ha->device_type |= DT_ISP6312;
Andrew Vasquez441d1072006-05-17 15:09:34 -07001531 ha->fw_srisc_address = RISC_START_ADDRESS_2300;
andrew.vasquez@qlogic.comea5b6382006-03-09 14:27:08 -08001532 break;
1533 case PCI_DEVICE_ID_QLOGIC_ISP6322:
1534 ha->device_type |= DT_ISP6322;
Andrew Vasquez441d1072006-05-17 15:09:34 -07001535 ha->fw_srisc_address = RISC_START_ADDRESS_2300;
andrew.vasquez@qlogic.comea5b6382006-03-09 14:27:08 -08001536 break;
1537 case PCI_DEVICE_ID_QLOGIC_ISP2422:
1538 ha->device_type |= DT_ISP2422;
andrew.vasquez@qlogic.com4a59f712006-03-09 14:27:39 -08001539 ha->device_type |= DT_ZIO_SUPPORTED;
Andrew Vasqueze4289242007-07-19 15:05:56 -07001540 ha->device_type |= DT_FWI2;
Andrew Vasquezc76f2c02007-07-19 15:05:57 -07001541 ha->device_type |= DT_IIDMA;
Andrew Vasquez441d1072006-05-17 15:09:34 -07001542 ha->fw_srisc_address = RISC_START_ADDRESS_2400;
andrew.vasquez@qlogic.comea5b6382006-03-09 14:27:08 -08001543 break;
1544 case PCI_DEVICE_ID_QLOGIC_ISP2432:
1545 ha->device_type |= DT_ISP2432;
andrew.vasquez@qlogic.com4a59f712006-03-09 14:27:39 -08001546 ha->device_type |= DT_ZIO_SUPPORTED;
Andrew Vasqueze4289242007-07-19 15:05:56 -07001547 ha->device_type |= DT_FWI2;
Andrew Vasquezc76f2c02007-07-19 15:05:57 -07001548 ha->device_type |= DT_IIDMA;
Andrew Vasquez441d1072006-05-17 15:09:34 -07001549 ha->fw_srisc_address = RISC_START_ADDRESS_2400;
andrew.vasquez@qlogic.comea5b6382006-03-09 14:27:08 -08001550 break;
Harihara Kadayam4d4df192008-04-03 13:13:26 -07001551 case PCI_DEVICE_ID_QLOGIC_ISP8432:
1552 ha->device_type |= DT_ISP8432;
1553 ha->device_type |= DT_ZIO_SUPPORTED;
1554 ha->device_type |= DT_FWI2;
1555 ha->device_type |= DT_IIDMA;
1556 ha->fw_srisc_address = RISC_START_ADDRESS_2400;
1557 break;
andrew.vasquez@qlogic.com044cc6c2006-03-09 14:27:13 -08001558 case PCI_DEVICE_ID_QLOGIC_ISP5422:
1559 ha->device_type |= DT_ISP5422;
Andrew Vasqueze4289242007-07-19 15:05:56 -07001560 ha->device_type |= DT_FWI2;
Andrew Vasquez441d1072006-05-17 15:09:34 -07001561 ha->fw_srisc_address = RISC_START_ADDRESS_2400;
andrew.vasquez@qlogic.comea5b6382006-03-09 14:27:08 -08001562 break;
andrew.vasquez@qlogic.com044cc6c2006-03-09 14:27:13 -08001563 case PCI_DEVICE_ID_QLOGIC_ISP5432:
1564 ha->device_type |= DT_ISP5432;
Andrew Vasqueze4289242007-07-19 15:05:56 -07001565 ha->device_type |= DT_FWI2;
Andrew Vasquez441d1072006-05-17 15:09:34 -07001566 ha->fw_srisc_address = RISC_START_ADDRESS_2400;
andrew.vasquez@qlogic.comea5b6382006-03-09 14:27:08 -08001567 break;
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001568 case PCI_DEVICE_ID_QLOGIC_ISP2532:
1569 ha->device_type |= DT_ISP2532;
1570 ha->device_type |= DT_ZIO_SUPPORTED;
1571 ha->device_type |= DT_FWI2;
1572 ha->device_type |= DT_IIDMA;
andrew.vasquez@qlogic.comea5b6382006-03-09 14:27:08 -08001573 ha->fw_srisc_address = RISC_START_ADDRESS_2400;
1574 break;
Andrew Vasquez3a03eb72009-01-05 11:18:11 -08001575 case PCI_DEVICE_ID_QLOGIC_ISP8001:
1576 ha->device_type |= DT_ISP8001;
1577 ha->device_type |= DT_ZIO_SUPPORTED;
1578 ha->device_type |= DT_FWI2;
1579 ha->device_type |= DT_IIDMA;
1580 ha->fw_srisc_address = RISC_START_ADDRESS_2400;
1581 break;
andrew.vasquez@qlogic.comea5b6382006-03-09 14:27:08 -08001582 }
1583}
1584
Linus Torvalds1da177e2005-04-16 15:20:36 -07001585static int
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001586qla2x00_iospace_config(struct qla_hw_data *ha)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001587{
Andrew Vasquez37765412008-01-17 09:02:09 -08001588 resource_size_t pio;
Anirban Chakraborty73208df2008-12-09 16:45:39 -08001589 uint16_t msix;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001590
Andrew Vasquez285d0322007-10-19 15:59:17 -07001591 if (pci_request_selected_regions(ha->pdev, ha->bars,
1592 QLA2XXX_DRIVER_NAME)) {
1593 qla_printk(KERN_WARNING, ha,
1594 "Failed to reserve PIO/MMIO regions (%s)\n",
1595 pci_name(ha->pdev));
1596
1597 goto iospace_error_exit;
1598 }
1599 if (!(ha->bars & 1))
1600 goto skip_pio;
1601
Linus Torvalds1da177e2005-04-16 15:20:36 -07001602 /* We only need PIO for Flash operations on ISP2312 v2 chips. */
1603 pio = pci_resource_start(ha->pdev, 0);
Andrew Vasquez37765412008-01-17 09:02:09 -08001604 if (pci_resource_flags(ha->pdev, 0) & IORESOURCE_IO) {
1605 if (pci_resource_len(ha->pdev, 0) < MIN_IOBASE_LEN) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001606 qla_printk(KERN_WARNING, ha,
1607 "Invalid PCI I/O region size (%s)...\n",
1608 pci_name(ha->pdev));
1609 pio = 0;
1610 }
1611 } else {
1612 qla_printk(KERN_WARNING, ha,
1613 "region #0 not a PIO resource (%s)...\n",
1614 pci_name(ha->pdev));
1615 pio = 0;
1616 }
Andrew Vasquez285d0322007-10-19 15:59:17 -07001617 ha->pio_address = pio;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001618
Andrew Vasquez285d0322007-10-19 15:59:17 -07001619skip_pio:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001620 /* Use MMIO operations for all accesses. */
Andrew Vasquez37765412008-01-17 09:02:09 -08001621 if (!(pci_resource_flags(ha->pdev, 1) & IORESOURCE_MEM)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001622 qla_printk(KERN_ERR, ha,
Andrew Vasquez37765412008-01-17 09:02:09 -08001623 "region #1 not an MMIO resource (%s), aborting\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -07001624 pci_name(ha->pdev));
1625 goto iospace_error_exit;
1626 }
Andrew Vasquez37765412008-01-17 09:02:09 -08001627 if (pci_resource_len(ha->pdev, 1) < MIN_IOBASE_LEN) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001628 qla_printk(KERN_ERR, ha,
1629 "Invalid PCI mem region size (%s), aborting\n",
1630 pci_name(ha->pdev));
1631 goto iospace_error_exit;
1632 }
1633
Andrew Vasquez37765412008-01-17 09:02:09 -08001634 ha->iobase = ioremap(pci_resource_start(ha->pdev, 1), MIN_IOBASE_LEN);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001635 if (!ha->iobase) {
1636 qla_printk(KERN_ERR, ha,
1637 "cannot remap MMIO (%s), aborting\n", pci_name(ha->pdev));
1638
1639 goto iospace_error_exit;
1640 }
1641
Anirban Chakraborty73208df2008-12-09 16:45:39 -08001642 /* Determine queue resources */
1643 ha->max_queues = 1;
Andrew Vasquez3a03eb72009-01-05 11:18:11 -08001644 if (ql2xmaxqueues <= 1 || (!IS_QLA25XX(ha) && !IS_QLA81XX(ha)))
Anirban Chakraborty17d98632008-12-18 10:06:15 -08001645 goto mqiobase_exit;
1646 ha->mqiobase = ioremap(pci_resource_start(ha->pdev, 3),
1647 pci_resource_len(ha->pdev, 3));
1648 if (ha->mqiobase) {
1649 /* Read MSIX vector size of the board */
1650 pci_read_config_word(ha->pdev, QLA_PCI_MSIX_CONTROL, &msix);
1651 ha->msix_count = msix;
1652 /* Max queues are bounded by available msix vectors */
1653 /* queue 0 uses two msix vectors */
1654 if (ha->msix_count - 1 < ql2xmaxqueues)
1655 ha->max_queues = ha->msix_count - 1;
1656 else if (ql2xmaxqueues > QLA_MQ_SIZE)
1657 ha->max_queues = QLA_MQ_SIZE;
1658 else
1659 ha->max_queues = ql2xmaxqueues;
1660 qla_printk(KERN_INFO, ha,
1661 "MSI-X vector count: %d\n", msix);
Anirban Chakraborty73208df2008-12-09 16:45:39 -08001662 }
Anirban Chakraborty17d98632008-12-18 10:06:15 -08001663
1664mqiobase_exit:
Anirban Chakraborty73208df2008-12-09 16:45:39 -08001665 ha->msix_count = ha->max_queues + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001666 return (0);
1667
1668iospace_error_exit:
1669 return (-ENOMEM);
1670}
1671
Andrew Vasquezabbd8872005-07-06 10:30:05 -07001672static void
Andrew Vasquez1e99e332006-11-22 08:24:48 -08001673qla2xxx_scan_start(struct Scsi_Host *shost)
1674{
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001675 scsi_qla_host_t *vha = shost_priv(shost);
Andrew Vasquez1e99e332006-11-22 08:24:48 -08001676
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001677 set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags);
1678 set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags);
1679 set_bit(RSCN_UPDATE, &vha->dpc_flags);
1680 set_bit(NPIV_CONFIG_NEEDED, &vha->dpc_flags);
Andrew Vasquez1e99e332006-11-22 08:24:48 -08001681}
1682
1683static int
1684qla2xxx_scan_finished(struct Scsi_Host *shost, unsigned long time)
1685{
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001686 scsi_qla_host_t *vha = shost_priv(shost);
Andrew Vasquez1e99e332006-11-22 08:24:48 -08001687
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001688 if (!vha->host)
Andrew Vasquez1e99e332006-11-22 08:24:48 -08001689 return 1;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001690 if (time > vha->hw->loop_reset_delay * HZ)
Andrew Vasquez1e99e332006-11-22 08:24:48 -08001691 return 1;
1692
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001693 return atomic_read(&vha->loop_state) == LOOP_READY;
Andrew Vasquez1e99e332006-11-22 08:24:48 -08001694}
1695
Linus Torvalds1da177e2005-04-16 15:20:36 -07001696/*
1697 * PCI driver interface
1698 */
Andrew Vasquez7ee61392006-06-23 16:11:22 -07001699static int __devinit
1700qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001701{
Andrew Vasqueza1541d52005-06-09 17:21:28 -07001702 int ret = -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001703 struct Scsi_Host *host;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001704 scsi_qla_host_t *base_vha = NULL;
1705 struct qla_hw_data *ha;
Andrew Vasquez29856e22007-08-12 18:22:52 -07001706 char pci_info[30];
Linus Torvalds1da177e2005-04-16 15:20:36 -07001707 char fw_str[30];
Andrew Vasquez54333832005-11-09 15:49:04 -08001708 struct scsi_host_template *sht;
Anirban Chakrabortyc51da4e2008-11-10 15:53:20 -08001709 int bars, max_id, mem_only = 0;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001710 uint16_t req_length = 0, rsp_length = 0;
Anirban Chakraborty73208df2008-12-09 16:45:39 -08001711 struct req_que *req = NULL;
1712 struct rsp_que *rsp = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001713
Andrew Vasquez285d0322007-10-19 15:59:17 -07001714 bars = pci_select_bars(pdev, IORESOURCE_MEM | IORESOURCE_IO);
1715 sht = &qla2x00_driver_template;
1716 if (pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2422 ||
1717 pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2432 ||
Harihara Kadayam4d4df192008-04-03 13:13:26 -07001718 pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8432 ||
Andrew Vasquez285d0322007-10-19 15:59:17 -07001719 pdev->device == PCI_DEVICE_ID_QLOGIC_ISP5422 ||
1720 pdev->device == PCI_DEVICE_ID_QLOGIC_ISP5432 ||
Andrew Vasquez3a03eb72009-01-05 11:18:11 -08001721 pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2532 ||
1722 pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8001) {
Andrew Vasquez285d0322007-10-19 15:59:17 -07001723 bars = pci_select_bars(pdev, IORESOURCE_MEM);
1724 sht = &qla24xx_driver_template;
Benjamin Herrenschmidt09483912007-12-20 15:28:09 +11001725 mem_only = 1;
Andrew Vasquez285d0322007-10-19 15:59:17 -07001726 }
1727
Benjamin Herrenschmidt09483912007-12-20 15:28:09 +11001728 if (mem_only) {
1729 if (pci_enable_device_mem(pdev))
1730 goto probe_out;
1731 } else {
1732 if (pci_enable_device(pdev))
1733 goto probe_out;
1734 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001735
Jesse Barnes09276782008-10-18 17:33:19 -07001736 /* This may fail but that's ok */
1737 pci_enable_pcie_error_reporting(pdev);
Seokmann Ju14e660e2007-09-20 14:07:36 -07001738
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001739 ha = kzalloc(sizeof(struct qla_hw_data), GFP_KERNEL);
1740 if (!ha) {
1741 DEBUG(printk("Unable to allocate memory for ha\n"));
1742 goto probe_out;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001743 }
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001744 ha->pdev = pdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001745
1746 /* Clear our data area */
Andrew Vasquez285d0322007-10-19 15:59:17 -07001747 ha->bars = bars;
Benjamin Herrenschmidt09483912007-12-20 15:28:09 +11001748 ha->mem_only = mem_only;
Andrew Vasquezdf4bf0b2008-01-31 12:33:46 -08001749 spin_lock_init(&ha->hardware_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001750
andrew.vasquez@qlogic.comea5b6382006-03-09 14:27:08 -08001751 /* Set ISP-type information. */
1752 qla2x00_set_isp_flags(ha);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001753 /* Configure PCI I/O space */
1754 ret = qla2x00_iospace_config(ha);
Andrew Vasqueza1541d52005-06-09 17:21:28 -07001755 if (ret)
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001756 goto probe_hw_failed;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001757
Linus Torvalds1da177e2005-04-16 15:20:36 -07001758 qla_printk(KERN_INFO, ha,
Andrew Vasquez54333832005-11-09 15:49:04 -08001759 "Found an ISP%04X, irq %d, iobase 0x%p\n", pdev->device, pdev->irq,
1760 ha->iobase);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001761
Linus Torvalds1da177e2005-04-16 15:20:36 -07001762 ha->prev_topology = 0;
Andrew Vasquezfca29702005-07-06 10:31:47 -07001763 ha->init_cb_size = sizeof(init_cb_t);
Andrew Vasquezd8b45212006-10-02 12:00:43 -07001764 ha->link_data_rate = PORT_SPEED_UNKNOWN;
andrew.vasquez@qlogic.com854165f2006-01-31 16:05:17 -08001765 ha->optrom_size = OPTROM_SIZE_2300;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001766
Andrew Vasquezabbd8872005-07-06 10:30:05 -07001767 /* Assign ISP specific operations. */
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001768 max_id = MAX_TARGETS_2200;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001769 if (IS_QLA2100(ha)) {
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001770 max_id = MAX_TARGETS_2100;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001771 ha->mbx_count = MAILBOX_REGISTER_COUNT_2100;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001772 req_length = REQUEST_ENTRY_CNT_2100;
1773 rsp_length = RESPONSE_ENTRY_CNT_2100;
1774 ha->max_loop_id = SNS_LAST_LOOP_ID_2100;
Andrew Vasquezabbd8872005-07-06 10:30:05 -07001775 ha->gid_list_info_size = 4;
Andrew Vasquez3a03eb72009-01-05 11:18:11 -08001776 ha->flash_conf_off = ~0;
1777 ha->flash_data_off = ~0;
1778 ha->nvram_conf_off = ~0;
1779 ha->nvram_data_off = ~0;
Andrew Vasquezfd34f552007-07-19 15:06:00 -07001780 ha->isp_ops = &qla2100_isp_ops;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001781 } else if (IS_QLA2200(ha)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001782 ha->mbx_count = MAILBOX_REGISTER_COUNT;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001783 req_length = REQUEST_ENTRY_CNT_2200;
1784 rsp_length = RESPONSE_ENTRY_CNT_2100;
1785 ha->max_loop_id = SNS_LAST_LOOP_ID_2100;
Andrew Vasquezabbd8872005-07-06 10:30:05 -07001786 ha->gid_list_info_size = 4;
Andrew Vasquez3a03eb72009-01-05 11:18:11 -08001787 ha->flash_conf_off = ~0;
1788 ha->flash_data_off = ~0;
1789 ha->nvram_conf_off = ~0;
1790 ha->nvram_data_off = ~0;
Andrew Vasquezfd34f552007-07-19 15:06:00 -07001791 ha->isp_ops = &qla2100_isp_ops;
Andrew Vasquezfca29702005-07-06 10:31:47 -07001792 } else if (IS_QLA23XX(ha)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001793 ha->mbx_count = MAILBOX_REGISTER_COUNT;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001794 req_length = REQUEST_ENTRY_CNT_2200;
1795 rsp_length = RESPONSE_ENTRY_CNT_2300;
1796 ha->max_loop_id = SNS_LAST_LOOP_ID_2300;
Andrew Vasquezabbd8872005-07-06 10:30:05 -07001797 ha->gid_list_info_size = 6;
andrew.vasquez@qlogic.com854165f2006-01-31 16:05:17 -08001798 if (IS_QLA2322(ha) || IS_QLA6322(ha))
1799 ha->optrom_size = OPTROM_SIZE_2322;
Andrew Vasquez3a03eb72009-01-05 11:18:11 -08001800 ha->flash_conf_off = ~0;
1801 ha->flash_data_off = ~0;
1802 ha->nvram_conf_off = ~0;
1803 ha->nvram_data_off = ~0;
Andrew Vasquezfd34f552007-07-19 15:06:00 -07001804 ha->isp_ops = &qla2300_isp_ops;
Harihara Kadayam4d4df192008-04-03 13:13:26 -07001805 } else if (IS_QLA24XX_TYPE(ha)) {
Andrew Vasquezfca29702005-07-06 10:31:47 -07001806 ha->mbx_count = MAILBOX_REGISTER_COUNT;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001807 req_length = REQUEST_ENTRY_CNT_24XX;
1808 rsp_length = RESPONSE_ENTRY_CNT_2300;
1809 ha->max_loop_id = SNS_LAST_LOOP_ID_2300;
Seokmann Ju2c3dfe32007-07-05 13:16:51 -07001810 ha->init_cb_size = sizeof(struct mid_init_cb_24xx);
Andrew Vasquezfca29702005-07-06 10:31:47 -07001811 ha->gid_list_info_size = 8;
andrew.vasquez@qlogic.com854165f2006-01-31 16:05:17 -08001812 ha->optrom_size = OPTROM_SIZE_24XX;
Anirban Chakraborty73208df2008-12-09 16:45:39 -08001813 ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA24XX;
Andrew Vasquezfd34f552007-07-19 15:06:00 -07001814 ha->isp_ops = &qla24xx_isp_ops;
Andrew Vasquez3a03eb72009-01-05 11:18:11 -08001815 ha->flash_conf_off = FARX_ACCESS_FLASH_CONF;
1816 ha->flash_data_off = FARX_ACCESS_FLASH_DATA;
1817 ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF;
1818 ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA;
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001819 } else if (IS_QLA25XX(ha)) {
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001820 ha->mbx_count = MAILBOX_REGISTER_COUNT;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001821 req_length = REQUEST_ENTRY_CNT_24XX;
1822 rsp_length = RESPONSE_ENTRY_CNT_2300;
1823 ha->max_loop_id = SNS_LAST_LOOP_ID_2300;
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001824 ha->init_cb_size = sizeof(struct mid_init_cb_24xx);
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001825 ha->gid_list_info_size = 8;
1826 ha->optrom_size = OPTROM_SIZE_25XX;
Anirban Chakraborty73208df2008-12-09 16:45:39 -08001827 ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX;
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001828 ha->isp_ops = &qla25xx_isp_ops;
Andrew Vasquez3a03eb72009-01-05 11:18:11 -08001829 ha->flash_conf_off = FARX_ACCESS_FLASH_CONF;
1830 ha->flash_data_off = FARX_ACCESS_FLASH_DATA;
1831 ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF;
1832 ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA;
1833 } else if (IS_QLA81XX(ha)) {
1834 ha->mbx_count = MAILBOX_REGISTER_COUNT;
1835 req_length = REQUEST_ENTRY_CNT_24XX;
1836 rsp_length = RESPONSE_ENTRY_CNT_2300;
1837 ha->max_loop_id = SNS_LAST_LOOP_ID_2300;
1838 ha->init_cb_size = sizeof(struct mid_init_cb_81xx);
1839 ha->gid_list_info_size = 8;
1840 ha->optrom_size = OPTROM_SIZE_81XX;
1841 ha->isp_ops = &qla81xx_isp_ops;
1842 ha->flash_conf_off = FARX_ACCESS_FLASH_CONF_81XX;
1843 ha->flash_data_off = FARX_ACCESS_FLASH_DATA_81XX;
1844 ha->nvram_conf_off = ~0;
1845 ha->nvram_data_off = ~0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001846 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001847
matthias@kaehlcke.net6c2f5272008-05-12 22:21:11 -07001848 mutex_init(&ha->vport_lock);
Marcus Barrow0b05a1f2008-01-17 09:02:13 -08001849 init_completion(&ha->mbx_cmd_comp);
1850 complete(&ha->mbx_cmd_comp);
1851 init_completion(&ha->mbx_intr_comp);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001852
Seokmann Ju2c3dfe32007-07-05 13:16:51 -07001853 set_bit(0, (unsigned long *) ha->vp_idx_map);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001854
Andrew Vasquez53303c42009-01-22 09:45:37 -08001855 qla2x00_config_dma_addressing(ha);
Anirban Chakraborty73208df2008-12-09 16:45:39 -08001856 ret = qla2x00_mem_alloc(ha, req_length, rsp_length, &req, &rsp);
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001857 if (!ret) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001858 qla_printk(KERN_WARNING, ha,
1859 "[ERROR] Failed to allocate memory for adapter\n");
1860
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001861 goto probe_hw_failed;
1862 }
1863
Anirban Chakraborty73208df2008-12-09 16:45:39 -08001864 req->max_q_depth = MAX_Q_DEPTH;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001865 if (ql2xmaxqdepth != 0 && ql2xmaxqdepth <= 0xffffU)
Anirban Chakraborty73208df2008-12-09 16:45:39 -08001866 req->max_q_depth = ql2xmaxqdepth;
1867
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001868
1869 base_vha = qla2x00_create_host(sht, ha);
1870 if (!base_vha) {
1871 qla_printk(KERN_WARNING, ha,
1872 "[ERROR] Failed to allocate memory for scsi_host\n");
1873
Andrew Vasqueza1541d52005-06-09 17:21:28 -07001874 ret = -ENOMEM;
Anirban Chakraborty6e9f21f2009-01-22 09:45:28 -08001875 qla2x00_mem_free(ha);
1876 qla2x00_free_que(ha, req, rsp);
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001877 goto probe_hw_failed;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001878 }
1879
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001880 pci_set_drvdata(pdev, base_vha);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001881
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001882 host = base_vha->host;
Anirban Chakraborty73208df2008-12-09 16:45:39 -08001883 base_vha->req_ques[0] = req->id;
1884 host->can_queue = req->length + 128;
1885 if (IS_QLA2XXX_MIDTYPE(ha))
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001886 base_vha->mgmt_svr_loop_id = 10 + base_vha->vp_idx;
Anirban Chakraborty73208df2008-12-09 16:45:39 -08001887 else
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001888 base_vha->mgmt_svr_loop_id = MANAGEMENT_SERVER +
1889 base_vha->vp_idx;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001890 if (IS_QLA2100(ha))
1891 host->sg_tablesize = 32;
1892 host->max_id = max_id;
Andrew Vasqueza1541d52005-06-09 17:21:28 -07001893 host->this_id = 255;
1894 host->cmd_per_lun = 3;
Seokmann Ju711c1d92008-07-10 16:55:51 -07001895 host->unique_id = host->host_no;
Andrew Vasqueza1541d52005-06-09 17:21:28 -07001896 host->max_cmd_len = MAX_CMDSZ;
Andrew Vasquez75bc4192006-05-17 15:09:22 -07001897 host->max_channel = MAX_BUSES - 1;
Andrew Vasqueza1541d52005-06-09 17:21:28 -07001898 host->max_lun = MAX_LUNS;
1899 host->transportt = qla2xxx_transport_template;
1900
Anirban Chakraborty73208df2008-12-09 16:45:39 -08001901 /* Set up the irqs */
1902 ret = qla2x00_request_irqs(ha, rsp);
1903 if (ret)
Anirban Chakraborty6e9f21f2009-01-22 09:45:28 -08001904 goto probe_init_failed;
Anirban Chakraborty73208df2008-12-09 16:45:39 -08001905 /* Alloc arrays of request and response ring ptrs */
1906 if (!qla2x00_alloc_queues(ha)) {
1907 qla_printk(KERN_WARNING, ha,
1908 "[ERROR] Failed to allocate memory for queue"
1909 " pointers\n");
Anirban Chakraborty6e9f21f2009-01-22 09:45:28 -08001910 goto probe_init_failed;
Anirban Chakraborty73208df2008-12-09 16:45:39 -08001911 }
1912 ha->rsp_q_map[0] = rsp;
1913 ha->req_q_map[0] = req;
1914
Andrew Vasquez08029992009-03-24 09:07:55 -07001915 /* FWI2-capable only. */
1916 req->req_q_in = &ha->iobase->isp24.req_q_in;
1917 req->req_q_out = &ha->iobase->isp24.req_q_out;
1918 rsp->rsp_q_in = &ha->iobase->isp24.rsp_q_in;
1919 rsp->rsp_q_out = &ha->iobase->isp24.rsp_q_out;
Anirban Chakraborty17d98632008-12-18 10:06:15 -08001920 if (ha->mqenable) {
Andrew Vasquez08029992009-03-24 09:07:55 -07001921 req->req_q_in = &ha->mqiobase->isp25mq.req_q_in;
1922 req->req_q_out = &ha->mqiobase->isp25mq.req_q_out;
1923 rsp->rsp_q_in = &ha->mqiobase->isp25mq.rsp_q_in;
1924 rsp->rsp_q_out = &ha->mqiobase->isp25mq.rsp_q_out;
Anirban Chakraborty17d98632008-12-18 10:06:15 -08001925 }
1926
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001927 if (qla2x00_initialize_adapter(base_vha)) {
1928 qla_printk(KERN_WARNING, ha,
1929 "Failed to initialize adapter\n");
1930
1931 DEBUG2(printk("scsi(%ld): Failed to initialize adapter - "
1932 "Adapter flags %x.\n",
1933 base_vha->host_no, base_vha->device_flags));
1934
1935 ret = -ENODEV;
1936 goto probe_failed;
1937 }
1938
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001939 /*
1940 * Startup the kernel thread for this host adapter
1941 */
1942 ha->dpc_thread = kthread_create(qla2x00_do_dpc, ha,
1943 "%s_dpc", base_vha->host_str);
1944 if (IS_ERR(ha->dpc_thread)) {
1945 qla_printk(KERN_WARNING, ha,
1946 "Unable to start DPC thread!\n");
1947 ret = PTR_ERR(ha->dpc_thread);
1948 goto probe_failed;
1949 }
1950
1951 list_add_tail(&base_vha->list, &ha->vp_list);
1952 base_vha->host->irq = ha->pdev->irq;
1953
Linus Torvalds1da177e2005-04-16 15:20:36 -07001954 /* Initialized the timer */
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001955 qla2x00_start_timer(base_vha, qla2x00_timer, WATCH_INTERVAL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001956
1957 DEBUG2(printk("DEBUG: detect hba %ld at address = %p\n",
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001958 base_vha->host_no, ha));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001959
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001960 base_vha->flags.init_done = 1;
1961 base_vha->flags.online = 1;
Andrew Vasquezd19044c2006-11-22 08:22:19 -08001962
Andrew Vasqueza1541d52005-06-09 17:21:28 -07001963 ret = scsi_add_host(host, &pdev->dev);
1964 if (ret)
1965 goto probe_failed;
1966
Andrew Vasquez048feec2008-09-11 22:19:45 -07001967 ha->isp_ops->enable_intrs(ha);
1968
Andrew Vasquez1e99e332006-11-22 08:24:48 -08001969 scsi_scan_host(host);
1970
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001971 qla2x00_alloc_sysfs_attr(base_vha);
Andrew Vasqueza1541d52005-06-09 17:21:28 -07001972
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001973 qla2x00_init_host_attr(base_vha);
Andrew Vasqueza1541d52005-06-09 17:21:28 -07001974
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001975 qla2x00_dfs_setup(base_vha);
Andrew Vasquezdf613b92008-01-17 09:02:17 -08001976
Linus Torvalds1da177e2005-04-16 15:20:36 -07001977 qla_printk(KERN_INFO, ha, "\n"
1978 " QLogic Fibre Channel HBA Driver: %s\n"
1979 " QLogic %s - %s\n"
Andrew Vasquez54333832005-11-09 15:49:04 -08001980 " ISP%04X: %s @ %s hdma%c, host#=%ld, fw=%s\n",
1981 qla2x00_version_str, ha->model_number,
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001982 ha->model_desc ? ha->model_desc : "", pdev->device,
1983 ha->isp_ops->pci_info_str(base_vha, pci_info), pci_name(pdev),
1984 ha->flags.enable_64bit_addressing ? '+' : '-', base_vha->host_no,
1985 ha->isp_ops->fw_version_str(base_vha, fw_str));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001986
Linus Torvalds1da177e2005-04-16 15:20:36 -07001987 return 0;
1988
Anirban Chakraborty6e9f21f2009-01-22 09:45:28 -08001989probe_init_failed:
1990 qla2x00_free_que(ha, req, rsp);
1991 ha->max_queues = 0;
1992
Linus Torvalds1da177e2005-04-16 15:20:36 -07001993probe_failed:
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001994 qla2x00_free_device(base_vha);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001995
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001996 scsi_host_put(base_vha->host);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001997
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001998probe_hw_failed:
1999 if (ha->iobase)
2000 iounmap(ha->iobase);
2001
2002 pci_release_selected_regions(ha->pdev, ha->bars);
2003 kfree(ha);
2004 ha = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002005
Andrew Vasqueza1541d52005-06-09 17:21:28 -07002006probe_out:
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002007 pci_disable_device(pdev);
Andrew Vasqueza1541d52005-06-09 17:21:28 -07002008 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002009}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002010
Adrian Bunk4c993f72008-01-14 00:55:16 -08002011static void
Andrew Vasquez7ee61392006-06-23 16:11:22 -07002012qla2x00_remove_one(struct pci_dev *pdev)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002013{
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002014 scsi_qla_host_t *base_vha, *vha, *temp;
2015 struct qla_hw_data *ha;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002016
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002017 base_vha = pci_get_drvdata(pdev);
2018 ha = base_vha->hw;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002019
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002020 list_for_each_entry_safe(vha, temp, &ha->vp_list, list) {
2021 if (vha && vha->fc_vport)
2022 fc_vport_terminate(vha->fc_vport);
2023 }
Andrew Vasquezc795c1e2008-08-13 21:37:01 -07002024
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002025 set_bit(UNLOADING, &base_vha->dpc_flags);
Andrew Vasquezc795c1e2008-08-13 21:37:01 -07002026
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002027 qla2x00_dfs_remove(base_vha);
Andrew Vasquezdf613b92008-01-17 09:02:17 -08002028
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002029 qla84xx_put_chip(base_vha);
Harihara Kadayam4d4df192008-04-03 13:13:26 -07002030
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002031 qla2x00_free_sysfs_attr(base_vha);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002032
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002033 fc_remove_host(base_vha->host);
bdf79622005-04-17 15:06:53 -05002034
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002035 scsi_remove_host(base_vha->host);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002036
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002037 qla2x00_free_device(base_vha);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002038
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002039 scsi_host_put(base_vha->host);
2040
2041 if (ha->iobase)
2042 iounmap(ha->iobase);
2043
Anirban Chakraborty73208df2008-12-09 16:45:39 -08002044 if (ha->mqiobase)
2045 iounmap(ha->mqiobase);
2046
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002047 pci_release_selected_regions(ha->pdev, ha->bars);
2048 kfree(ha);
2049 ha = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002050
Bernhard Walle665db932007-03-28 00:49:49 +02002051 pci_disable_device(pdev);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002052 pci_set_drvdata(pdev, NULL);
2053}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002054
2055static void
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002056qla2x00_free_device(scsi_qla_host_t *vha)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002057{
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002058 struct qla_hw_data *ha = vha->hw;
2059 qla2x00_abort_all_cmds(vha, DID_NO_CONNECT << 16);
Andrew Vasquezdf4bf0b2008-01-31 12:33:46 -08002060
Linus Torvalds1da177e2005-04-16 15:20:36 -07002061 /* Disable timer */
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002062 if (vha->timer_active)
2063 qla2x00_stop_timer(vha);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002064
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002065 vha->flags.online = 0;
Andrew Vasquezdf4bf0b2008-01-31 12:33:46 -08002066
Linus Torvalds1da177e2005-04-16 15:20:36 -07002067 /* Kill the kernel thread for this host */
Christoph Hellwig39a11242006-02-14 18:46:22 +01002068 if (ha->dpc_thread) {
2069 struct task_struct *t = ha->dpc_thread;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002070
Christoph Hellwig39a11242006-02-14 18:46:22 +01002071 /*
2072 * qla2xxx_wake_dpc checks for ->dpc_thread
2073 * so we need to zero it out.
2074 */
2075 ha->dpc_thread = NULL;
2076 kthread_stop(t);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002077 }
2078
Andrew Vasquezdf613b92008-01-17 09:02:17 -08002079 if (ha->flags.fce_enabled)
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002080 qla2x00_disable_fce_trace(vha, NULL, NULL);
Andrew Vasquezdf613b92008-01-17 09:02:17 -08002081
Andrew Vasqueza7a167b2006-06-23 16:10:29 -07002082 if (ha->eft)
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002083 qla2x00_disable_eft_trace(vha);
Andrew Vasqueza7a167b2006-06-23 16:10:29 -07002084
Andrew Vasquezf6ef3b12005-08-26 19:10:20 -07002085 /* Stop currently executing firmware. */
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002086 qla2x00_try_to_stop_firmware(vha);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002087
Andrew Vasquezf6ef3b12005-08-26 19:10:20 -07002088 /* turn-off interrupts on the card */
2089 if (ha->interrupts_on)
Andrew Vasquezfd34f552007-07-19 15:06:00 -07002090 ha->isp_ops->disable_intrs(ha);
Andrew Vasquezf6ef3b12005-08-26 19:10:20 -07002091
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002092 qla2x00_free_irqs(vha);
2093
Andrew Vasquezf6ef3b12005-08-26 19:10:20 -07002094 qla2x00_mem_free(ha);
Anirban Chakraborty73208df2008-12-09 16:45:39 -08002095
2096 qla2x00_free_queues(ha);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002097}
2098
andrew.vasquez@qlogic.comd97994d2006-01-20 14:53:13 -08002099static inline void
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002100qla2x00_schedule_rport_del(struct scsi_qla_host *vha, fc_port_t *fcport,
andrew.vasquez@qlogic.comd97994d2006-01-20 14:53:13 -08002101 int defer)
2102{
andrew.vasquez@qlogic.comd97994d2006-01-20 14:53:13 -08002103 struct fc_rport *rport;
2104
2105 if (!fcport->rport)
2106 return;
2107
2108 rport = fcport->rport;
2109 if (defer) {
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002110 spin_lock_irq(vha->host->host_lock);
andrew.vasquez@qlogic.comd97994d2006-01-20 14:53:13 -08002111 fcport->drport = rport;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002112 spin_unlock_irq(vha->host->host_lock);
2113 set_bit(FCPORT_UPDATE_NEEDED, &vha->dpc_flags);
2114 qla2xxx_wake_dpc(vha);
Seokmann Ju5f3a9a22008-07-10 16:55:47 -07002115 } else
andrew.vasquez@qlogic.comd97994d2006-01-20 14:53:13 -08002116 fc_remote_port_delete(rport);
andrew.vasquez@qlogic.comd97994d2006-01-20 14:53:13 -08002117}
2118
Linus Torvalds1da177e2005-04-16 15:20:36 -07002119/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002120 * qla2x00_mark_device_lost Updates fcport state when device goes offline.
2121 *
2122 * Input: ha = adapter block pointer. fcport = port structure pointer.
2123 *
2124 * Return: None.
2125 *
2126 * Context:
2127 */
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002128void qla2x00_mark_device_lost(scsi_qla_host_t *vha, fc_port_t *fcport,
andrew.vasquez@qlogic.comd97994d2006-01-20 14:53:13 -08002129 int do_login, int defer)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002130{
Seokmann Ju2c3dfe32007-07-05 13:16:51 -07002131 if (atomic_read(&fcport->state) == FCS_ONLINE &&
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002132 vha->vp_idx == fcport->vp_idx) {
2133 atomic_set(&fcport->state, FCS_DEVICE_LOST);
2134 qla2x00_schedule_rport_del(vha, fcport, defer);
2135 }
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -07002136 /*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002137 * We may need to retry the login, so don't change the state of the
2138 * port but do the retries.
2139 */
2140 if (atomic_read(&fcport->state) != FCS_DEVICE_DEAD)
2141 atomic_set(&fcport->state, FCS_DEVICE_LOST);
2142
2143 if (!do_login)
2144 return;
2145
2146 if (fcport->login_retry == 0) {
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002147 fcport->login_retry = vha->hw->login_retry_count;
2148 set_bit(RELOGIN_NEEDED, &vha->dpc_flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002149
2150 DEBUG(printk("scsi(%ld): Port login retry: "
2151 "%02x%02x%02x%02x%02x%02x%02x%02x, "
2152 "id = 0x%04x retry cnt=%d\n",
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002153 vha->host_no,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002154 fcport->port_name[0],
2155 fcport->port_name[1],
2156 fcport->port_name[2],
2157 fcport->port_name[3],
2158 fcport->port_name[4],
2159 fcport->port_name[5],
2160 fcport->port_name[6],
2161 fcport->port_name[7],
2162 fcport->loop_id,
2163 fcport->login_retry));
2164 }
2165}
2166
2167/*
2168 * qla2x00_mark_all_devices_lost
2169 * Updates fcport state when device goes offline.
2170 *
2171 * Input:
2172 * ha = adapter block pointer.
2173 * fcport = port structure pointer.
2174 *
2175 * Return:
2176 * None.
2177 *
2178 * Context:
2179 */
2180void
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002181qla2x00_mark_all_devices_lost(scsi_qla_host_t *vha, int defer)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002182{
2183 fc_port_t *fcport;
2184
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002185 list_for_each_entry(fcport, &vha->vp_fcports, list) {
2186 if (vha->vp_idx != fcport->vp_idx)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002187 continue;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002188 /*
2189 * No point in marking the device as lost, if the device is
2190 * already DEAD.
2191 */
2192 if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD)
2193 continue;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002194 if (atomic_read(&fcport->state) == FCS_ONLINE) {
2195 atomic_set(&fcport->state, FCS_DEVICE_LOST);
2196 qla2x00_schedule_rport_del(vha, fcport, defer);
2197 } else
2198 atomic_set(&fcport->state, FCS_DEVICE_LOST);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002199 }
2200}
2201
2202/*
2203* qla2x00_mem_alloc
2204* Allocates adapter memory.
2205*
2206* Returns:
2207* 0 = success.
Andrew Vasqueze8711082008-01-31 12:33:48 -08002208* !0 = failure.
Linus Torvalds1da177e2005-04-16 15:20:36 -07002209*/
Andrew Vasqueze8711082008-01-31 12:33:48 -08002210static int
Anirban Chakraborty73208df2008-12-09 16:45:39 -08002211qla2x00_mem_alloc(struct qla_hw_data *ha, uint16_t req_len, uint16_t rsp_len,
2212 struct req_que **req, struct rsp_que **rsp)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002213{
2214 char name[16];
Linus Torvalds1da177e2005-04-16 15:20:36 -07002215
Andrew Vasqueze8711082008-01-31 12:33:48 -08002216 ha->init_cb = dma_alloc_coherent(&ha->pdev->dev, ha->init_cb_size,
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002217 &ha->init_cb_dma, GFP_KERNEL);
Andrew Vasqueze8711082008-01-31 12:33:48 -08002218 if (!ha->init_cb)
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002219 goto fail;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002220
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002221 ha->gid_list = dma_alloc_coherent(&ha->pdev->dev, GID_LIST_SIZE,
2222 &ha->gid_list_dma, GFP_KERNEL);
2223 if (!ha->gid_list)
Andrew Vasqueze8711082008-01-31 12:33:48 -08002224 goto fail_free_init_cb;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002225
Andrew Vasqueze8711082008-01-31 12:33:48 -08002226 ha->srb_mempool = mempool_create_slab_pool(SRB_MIN_REQ, srb_cachep);
2227 if (!ha->srb_mempool)
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002228 goto fail_free_gid_list;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002229
Andrew Vasqueze8711082008-01-31 12:33:48 -08002230 /* Get memory for cached NVRAM */
2231 ha->nvram = kzalloc(MAX_NVRAM_SIZE, GFP_KERNEL);
2232 if (!ha->nvram)
2233 goto fail_free_srb_mempool;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002234
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002235 snprintf(name, sizeof(name), "%s_%d", QLA2XXX_DRIVER_NAME,
2236 ha->pdev->device);
2237 ha->s_dma_pool = dma_pool_create(name, &ha->pdev->dev,
2238 DMA_POOL_SIZE, 8, 0);
2239 if (!ha->s_dma_pool)
2240 goto fail_free_nvram;
2241
Andrew Vasqueze8711082008-01-31 12:33:48 -08002242 /* Allocate memory for SNS commands */
2243 if (IS_QLA2100(ha) || IS_QLA2200(ha)) {
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002244 /* Get consistent memory allocated for SNS commands */
Andrew Vasqueze8711082008-01-31 12:33:48 -08002245 ha->sns_cmd = dma_alloc_coherent(&ha->pdev->dev,
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002246 sizeof(struct sns_cmd_pkt), &ha->sns_cmd_dma, GFP_KERNEL);
Andrew Vasqueze8711082008-01-31 12:33:48 -08002247 if (!ha->sns_cmd)
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002248 goto fail_dma_pool;
Andrew Vasqueze8711082008-01-31 12:33:48 -08002249 } else {
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002250 /* Get consistent memory allocated for MS IOCB */
Andrew Vasqueze8711082008-01-31 12:33:48 -08002251 ha->ms_iocb = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL,
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002252 &ha->ms_iocb_dma);
Andrew Vasqueze8711082008-01-31 12:33:48 -08002253 if (!ha->ms_iocb)
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002254 goto fail_dma_pool;
2255 /* Get consistent memory allocated for CT SNS commands */
Andrew Vasqueze8711082008-01-31 12:33:48 -08002256 ha->ct_sns = dma_alloc_coherent(&ha->pdev->dev,
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002257 sizeof(struct ct_sns_pkt), &ha->ct_sns_dma, GFP_KERNEL);
Andrew Vasqueze8711082008-01-31 12:33:48 -08002258 if (!ha->ct_sns)
2259 goto fail_free_ms_iocb;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002260 }
2261
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002262 /* Allocate memory for request ring */
Anirban Chakraborty73208df2008-12-09 16:45:39 -08002263 *req = kzalloc(sizeof(struct req_que), GFP_KERNEL);
2264 if (!*req) {
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002265 DEBUG(printk("Unable to allocate memory for req\n"));
2266 goto fail_req;
2267 }
Anirban Chakraborty73208df2008-12-09 16:45:39 -08002268 (*req)->length = req_len;
2269 (*req)->ring = dma_alloc_coherent(&ha->pdev->dev,
2270 ((*req)->length + 1) * sizeof(request_t),
2271 &(*req)->dma, GFP_KERNEL);
2272 if (!(*req)->ring) {
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002273 DEBUG(printk("Unable to allocate memory for req_ring\n"));
2274 goto fail_req_ring;
2275 }
2276 /* Allocate memory for response ring */
Anirban Chakraborty73208df2008-12-09 16:45:39 -08002277 *rsp = kzalloc(sizeof(struct rsp_que), GFP_KERNEL);
2278 if (!*rsp) {
2279 qla_printk(KERN_WARNING, ha,
2280 "Unable to allocate memory for rsp\n");
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002281 goto fail_rsp;
2282 }
Anirban Chakraborty73208df2008-12-09 16:45:39 -08002283 (*rsp)->hw = ha;
2284 (*rsp)->length = rsp_len;
2285 (*rsp)->ring = dma_alloc_coherent(&ha->pdev->dev,
2286 ((*rsp)->length + 1) * sizeof(response_t),
2287 &(*rsp)->dma, GFP_KERNEL);
2288 if (!(*rsp)->ring) {
2289 qla_printk(KERN_WARNING, ha,
2290 "Unable to allocate memory for rsp_ring\n");
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002291 goto fail_rsp_ring;
2292 }
Anirban Chakraborty73208df2008-12-09 16:45:39 -08002293 (*req)->rsp = *rsp;
2294 (*rsp)->req = *req;
2295 /* Allocate memory for NVRAM data for vports */
2296 if (ha->nvram_npiv_size) {
2297 ha->npiv_info = kzalloc(sizeof(struct qla_npiv_entry) *
2298 ha->nvram_npiv_size, GFP_KERNEL);
2299 if (!ha->npiv_info) {
2300 qla_printk(KERN_WARNING, ha,
2301 "Unable to allocate memory for npiv info\n");
2302 goto fail_npiv_info;
2303 }
2304 } else
2305 ha->npiv_info = NULL;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002306
2307 INIT_LIST_HEAD(&ha->vp_list);
2308 return 1;
2309
Anirban Chakraborty73208df2008-12-09 16:45:39 -08002310fail_npiv_info:
2311 dma_free_coherent(&ha->pdev->dev, ((*rsp)->length + 1) *
2312 sizeof(response_t), (*rsp)->ring, (*rsp)->dma);
2313 (*rsp)->ring = NULL;
2314 (*rsp)->dma = 0;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002315fail_rsp_ring:
Anirban Chakraborty73208df2008-12-09 16:45:39 -08002316 kfree(*rsp);
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002317fail_rsp:
Anirban Chakraborty73208df2008-12-09 16:45:39 -08002318 dma_free_coherent(&ha->pdev->dev, ((*req)->length + 1) *
2319 sizeof(request_t), (*req)->ring, (*req)->dma);
2320 (*req)->ring = NULL;
2321 (*req)->dma = 0;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002322fail_req_ring:
Anirban Chakraborty73208df2008-12-09 16:45:39 -08002323 kfree(*req);
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002324fail_req:
2325 dma_free_coherent(&ha->pdev->dev, sizeof(struct ct_sns_pkt),
2326 ha->ct_sns, ha->ct_sns_dma);
2327 ha->ct_sns = NULL;
2328 ha->ct_sns_dma = 0;
Andrew Vasqueze8711082008-01-31 12:33:48 -08002329fail_free_ms_iocb:
2330 dma_pool_free(ha->s_dma_pool, ha->ms_iocb, ha->ms_iocb_dma);
2331 ha->ms_iocb = NULL;
2332 ha->ms_iocb_dma = 0;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002333fail_dma_pool:
2334 dma_pool_destroy(ha->s_dma_pool);
2335 ha->s_dma_pool = NULL;
Andrew Vasqueze8711082008-01-31 12:33:48 -08002336fail_free_nvram:
2337 kfree(ha->nvram);
2338 ha->nvram = NULL;
2339fail_free_srb_mempool:
2340 mempool_destroy(ha->srb_mempool);
2341 ha->srb_mempool = NULL;
Andrew Vasqueze8711082008-01-31 12:33:48 -08002342fail_free_gid_list:
2343 dma_free_coherent(&ha->pdev->dev, GID_LIST_SIZE, ha->gid_list,
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002344 ha->gid_list_dma);
Andrew Vasqueze8711082008-01-31 12:33:48 -08002345 ha->gid_list = NULL;
2346 ha->gid_list_dma = 0;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002347fail_free_init_cb:
2348 dma_free_coherent(&ha->pdev->dev, ha->init_cb_size, ha->init_cb,
2349 ha->init_cb_dma);
2350 ha->init_cb = NULL;
2351 ha->init_cb_dma = 0;
Andrew Vasqueze8711082008-01-31 12:33:48 -08002352fail:
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002353 DEBUG(printk("%s: Memory allocation failure\n", __func__));
Andrew Vasqueze8711082008-01-31 12:33:48 -08002354 return -ENOMEM;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002355}
2356
2357/*
2358* qla2x00_mem_free
2359* Frees all adapter allocated memory.
2360*
2361* Input:
2362* ha = adapter block pointer.
2363*/
Adrian Bunka824ebb2008-01-17 09:02:15 -08002364static void
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002365qla2x00_mem_free(struct qla_hw_data *ha)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002366{
Andrew Vasqueze8711082008-01-31 12:33:48 -08002367 if (ha->srb_mempool)
2368 mempool_destroy(ha->srb_mempool);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002369
Andrew Vasquezdf613b92008-01-17 09:02:17 -08002370 if (ha->fce)
2371 dma_free_coherent(&ha->pdev->dev, FCE_SIZE, ha->fce,
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002372 ha->fce_dma);
Andrew Vasquezdf613b92008-01-17 09:02:17 -08002373
Andrew Vasqueza7a167b2006-06-23 16:10:29 -07002374 if (ha->fw_dump) {
2375 if (ha->eft)
2376 dma_free_coherent(&ha->pdev->dev,
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002377 ntohl(ha->fw_dump->eft_size), ha->eft, ha->eft_dma);
Andrew Vasqueza7a167b2006-06-23 16:10:29 -07002378 vfree(ha->fw_dump);
2379 }
2380
Linus Torvalds1da177e2005-04-16 15:20:36 -07002381 if (ha->sns_cmd)
2382 dma_free_coherent(&ha->pdev->dev, sizeof(struct sns_cmd_pkt),
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002383 ha->sns_cmd, ha->sns_cmd_dma);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002384
2385 if (ha->ct_sns)
2386 dma_free_coherent(&ha->pdev->dev, sizeof(struct ct_sns_pkt),
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002387 ha->ct_sns, ha->ct_sns_dma);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002388
Andrew Vasquez88729e52006-06-23 16:10:50 -07002389 if (ha->sfp_data)
2390 dma_pool_free(ha->s_dma_pool, ha->sfp_data, ha->sfp_data_dma);
2391
Linus Torvalds1da177e2005-04-16 15:20:36 -07002392 if (ha->ms_iocb)
2393 dma_pool_free(ha->s_dma_pool, ha->ms_iocb, ha->ms_iocb_dma);
2394
Linus Torvalds1da177e2005-04-16 15:20:36 -07002395 if (ha->s_dma_pool)
2396 dma_pool_destroy(ha->s_dma_pool);
2397
Seokmann Ju2c3dfe32007-07-05 13:16:51 -07002398
Linus Torvalds1da177e2005-04-16 15:20:36 -07002399 if (ha->gid_list)
2400 dma_free_coherent(&ha->pdev->dev, GID_LIST_SIZE, ha->gid_list,
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002401 ha->gid_list_dma);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002402
Linus Torvalds1da177e2005-04-16 15:20:36 -07002403
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002404 if (ha->init_cb)
2405 dma_free_coherent(&ha->pdev->dev, ha->init_cb_size,
2406 ha->init_cb, ha->init_cb_dma);
2407 vfree(ha->optrom_buffer);
2408 kfree(ha->nvram);
Anirban Chakraborty73208df2008-12-09 16:45:39 -08002409 kfree(ha->npiv_info);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002410
Andrew Vasqueze8711082008-01-31 12:33:48 -08002411 ha->srb_mempool = NULL;
Andrew Vasqueza7a167b2006-06-23 16:10:29 -07002412 ha->eft = NULL;
2413 ha->eft_dma = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002414 ha->sns_cmd = NULL;
2415 ha->sns_cmd_dma = 0;
2416 ha->ct_sns = NULL;
2417 ha->ct_sns_dma = 0;
2418 ha->ms_iocb = NULL;
2419 ha->ms_iocb_dma = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002420 ha->init_cb = NULL;
2421 ha->init_cb_dma = 0;
2422
2423 ha->s_dma_pool = NULL;
2424
Linus Torvalds1da177e2005-04-16 15:20:36 -07002425 ha->gid_list = NULL;
2426 ha->gid_list_dma = 0;
2427
Linus Torvalds1da177e2005-04-16 15:20:36 -07002428 ha->fw_dump = NULL;
Andrew Vasquezfca29702005-07-06 10:31:47 -07002429 ha->fw_dumped = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002430 ha->fw_dump_reading = 0;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002431}
2432
2433struct scsi_qla_host *qla2x00_create_host(struct scsi_host_template *sht,
2434 struct qla_hw_data *ha)
2435{
2436 struct Scsi_Host *host;
2437 struct scsi_qla_host *vha = NULL;
2438
2439 host = scsi_host_alloc(sht, sizeof(scsi_qla_host_t));
2440 if (host == NULL) {
2441 printk(KERN_WARNING
2442 "qla2xxx: Couldn't allocate host from scsi layer!\n");
2443 goto fail;
2444 }
2445
2446 /* Clear our data area */
2447 vha = shost_priv(host);
2448 memset(vha, 0, sizeof(scsi_qla_host_t));
2449
2450 vha->host = host;
2451 vha->host_no = host->host_no;
2452 vha->hw = ha;
2453
2454 INIT_LIST_HEAD(&vha->vp_fcports);
2455 INIT_LIST_HEAD(&vha->work_list);
2456 INIT_LIST_HEAD(&vha->list);
2457
2458 sprintf(vha->host_str, "%s_%ld", QLA2XXX_DRIVER_NAME, vha->host_no);
2459 return vha;
2460
2461fail:
2462 return vha;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002463}
2464
Adrian Bunk01ef66b2008-04-24 15:21:27 -07002465static struct qla_work_evt *
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002466qla2x00_alloc_work(struct scsi_qla_host *vha, enum qla_work_type type,
Andrew Vasquez0971de72008-04-03 13:13:18 -07002467 int locked)
2468{
2469 struct qla_work_evt *e;
2470
2471 e = kzalloc(sizeof(struct qla_work_evt), locked ? GFP_ATOMIC:
2472 GFP_KERNEL);
2473 if (!e)
2474 return NULL;
2475
2476 INIT_LIST_HEAD(&e->list);
2477 e->type = type;
2478 e->flags = QLA_EVT_FLAG_FREE;
2479 return e;
2480}
2481
Adrian Bunk01ef66b2008-04-24 15:21:27 -07002482static int
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002483qla2x00_post_work(struct scsi_qla_host *vha, struct qla_work_evt *e, int locked)
Andrew Vasquez0971de72008-04-03 13:13:18 -07002484{
Andrew Mortonbf6583b2008-07-24 08:31:48 -07002485 unsigned long uninitialized_var(flags);
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002486 struct qla_hw_data *ha = vha->hw;
Andrew Vasquez0971de72008-04-03 13:13:18 -07002487
2488 if (!locked)
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002489 spin_lock_irqsave(&ha->hardware_lock, flags);
2490 list_add_tail(&e->list, &vha->work_list);
2491 qla2xxx_wake_dpc(vha);
Andrew Vasquez0971de72008-04-03 13:13:18 -07002492 if (!locked)
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002493 spin_unlock_irqrestore(&ha->hardware_lock, flags);
Andrew Vasquez0971de72008-04-03 13:13:18 -07002494 return QLA_SUCCESS;
2495}
2496
2497int
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002498qla2x00_post_aen_work(struct scsi_qla_host *vha, enum fc_host_event_code code,
Andrew Vasquez0971de72008-04-03 13:13:18 -07002499 u32 data)
2500{
2501 struct qla_work_evt *e;
2502
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002503 e = qla2x00_alloc_work(vha, QLA_EVT_AEN, 1);
Andrew Vasquez0971de72008-04-03 13:13:18 -07002504 if (!e)
2505 return QLA_FUNCTION_FAILED;
2506
2507 e->u.aen.code = code;
2508 e->u.aen.data = data;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002509 return qla2x00_post_work(vha, e, 1);
Andrew Vasquez0971de72008-04-03 13:13:18 -07002510}
2511
Andrew Vasquez8a659572009-02-08 20:50:12 -08002512int
2513qla2x00_post_idc_ack_work(struct scsi_qla_host *vha, uint16_t *mb)
2514{
2515 struct qla_work_evt *e;
2516
2517 e = qla2x00_alloc_work(vha, QLA_EVT_IDC_ACK, 1);
2518 if (!e)
2519 return QLA_FUNCTION_FAILED;
2520
2521 memcpy(e->u.idc_ack.mb, mb, QLA_IDC_ACK_REGS * sizeof(uint16_t));
2522 return qla2x00_post_work(vha, e, 1);
2523}
2524
Andrew Vasquez0971de72008-04-03 13:13:18 -07002525static void
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002526qla2x00_do_work(struct scsi_qla_host *vha)
Andrew Vasquez0971de72008-04-03 13:13:18 -07002527{
2528 struct qla_work_evt *e;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002529 struct qla_hw_data *ha = vha->hw;
Andrew Vasquez0971de72008-04-03 13:13:18 -07002530
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002531 spin_lock_irq(&ha->hardware_lock);
2532 while (!list_empty(&vha->work_list)) {
2533 e = list_entry(vha->work_list.next, struct qla_work_evt, list);
Andrew Vasquez0971de72008-04-03 13:13:18 -07002534 list_del_init(&e->list);
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002535 spin_unlock_irq(&ha->hardware_lock);
Andrew Vasquez0971de72008-04-03 13:13:18 -07002536
2537 switch (e->type) {
2538 case QLA_EVT_AEN:
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002539 fc_host_post_event(vha->host, fc_get_event_number(),
Andrew Vasquez0971de72008-04-03 13:13:18 -07002540 e->u.aen.code, e->u.aen.data);
2541 break;
Andrew Vasquez8a659572009-02-08 20:50:12 -08002542 case QLA_EVT_IDC_ACK:
2543 qla81xx_idc_ack(vha, e->u.idc_ack.mb);
2544 break;
Andrew Vasquez0971de72008-04-03 13:13:18 -07002545 }
2546 if (e->flags & QLA_EVT_FLAG_FREE)
2547 kfree(e);
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002548 spin_lock_irq(&ha->hardware_lock);
Andrew Vasquez0971de72008-04-03 13:13:18 -07002549 }
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002550 spin_unlock_irq(&ha->hardware_lock);
2551}
2552/* Relogins all the fcports of a vport
2553 * Context: dpc thread
2554 */
2555void qla2x00_relogin(struct scsi_qla_host *vha)
2556{
2557 fc_port_t *fcport;
Andrew Vasquezc6b2fca2009-03-05 11:07:03 -08002558 int status;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002559 uint16_t next_loopid = 0;
2560 struct qla_hw_data *ha = vha->hw;
2561
2562 list_for_each_entry(fcport, &vha->vp_fcports, list) {
2563 /*
2564 * If the port is not ONLINE then try to login
2565 * to it if we haven't run out of retries.
2566 */
2567 if (atomic_read(&fcport->state) !=
2568 FCS_ONLINE && fcport->login_retry) {
2569
2570 if (fcport->flags & FCF_FABRIC_DEVICE) {
2571 if (fcport->flags & FCF_TAPE_PRESENT)
2572 ha->isp_ops->fabric_logout(vha,
2573 fcport->loop_id,
2574 fcport->d_id.b.domain,
2575 fcport->d_id.b.area,
2576 fcport->d_id.b.al_pa);
2577
2578 status = qla2x00_fabric_login(vha, fcport,
2579 &next_loopid);
2580 } else
2581 status = qla2x00_local_device_login(vha,
2582 fcport);
2583
2584 fcport->login_retry--;
2585 if (status == QLA_SUCCESS) {
2586 fcport->old_loop_id = fcport->loop_id;
2587
2588 DEBUG(printk("scsi(%ld): port login OK: logged "
2589 "in ID 0x%x\n", vha->host_no, fcport->loop_id));
2590
2591 qla2x00_update_fcport(vha, fcport);
2592
2593 } else if (status == 1) {
2594 set_bit(RELOGIN_NEEDED, &vha->dpc_flags);
2595 /* retry the login again */
2596 DEBUG(printk("scsi(%ld): Retrying"
2597 " %d login again loop_id 0x%x\n",
2598 vha->host_no, fcport->login_retry,
2599 fcport->loop_id));
2600 } else {
2601 fcport->login_retry = 0;
2602 }
2603
2604 if (fcport->login_retry == 0 && status != QLA_SUCCESS)
2605 fcport->loop_id = FC_NO_LOOP_ID;
2606 }
2607 if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags))
2608 break;
2609 }
Andrew Vasquez0971de72008-04-03 13:13:18 -07002610}
2611
Linus Torvalds1da177e2005-04-16 15:20:36 -07002612/**************************************************************************
2613* qla2x00_do_dpc
2614* This kernel thread is a task that is schedule by the interrupt handler
2615* to perform the background processing for interrupts.
2616*
2617* Notes:
2618* This task always run in the context of a kernel thread. It
2619* is kick-off by the driver's detect code and starts up
2620* up one per adapter. It immediately goes to sleep and waits for
2621* some fibre event. When either the interrupt handler or
2622* the timer routine detects a event it will one of the task
2623* bits then wake us up.
2624**************************************************************************/
2625static int
2626qla2x00_do_dpc(void *data)
2627{
Seokmann Ju2c3dfe32007-07-05 13:16:51 -07002628 int rval;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002629 scsi_qla_host_t *base_vha;
2630 struct qla_hw_data *ha;
Seokmann Ju99363ef2008-01-31 12:33:51 -08002631
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002632 ha = (struct qla_hw_data *)data;
2633 base_vha = pci_get_drvdata(ha->pdev);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002634
Linus Torvalds1da177e2005-04-16 15:20:36 -07002635 set_user_nice(current, -20);
2636
Christoph Hellwig39a11242006-02-14 18:46:22 +01002637 while (!kthread_should_stop()) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002638 DEBUG3(printk("qla2x00: DPC handler sleeping\n"));
2639
Christoph Hellwig39a11242006-02-14 18:46:22 +01002640 set_current_state(TASK_INTERRUPTIBLE);
2641 schedule();
2642 __set_current_state(TASK_RUNNING);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002643
2644 DEBUG3(printk("qla2x00: DPC handler waking up\n"));
2645
2646 /* Initialization not yet finished. Don't do anything yet. */
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002647 if (!base_vha->flags.init_done)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002648 continue;
2649
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002650 DEBUG3(printk("scsi(%ld): DPC handler\n", base_vha->host_no));
Linus Torvalds1da177e2005-04-16 15:20:36 -07002651
2652 ha->dpc_active = 1;
2653
Linus Torvalds1da177e2005-04-16 15:20:36 -07002654 if (ha->flags.mbox_busy) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002655 ha->dpc_active = 0;
2656 continue;
2657 }
2658
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002659 qla2x00_do_work(base_vha);
Andrew Vasquez0971de72008-04-03 13:13:18 -07002660
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002661 if (test_and_clear_bit(ISP_ABORT_NEEDED,
2662 &base_vha->dpc_flags)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002663
2664 DEBUG(printk("scsi(%ld): dpc: sched "
2665 "qla2x00_abort_isp ha = %p\n",
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002666 base_vha->host_no, ha));
Linus Torvalds1da177e2005-04-16 15:20:36 -07002667 if (!(test_and_set_bit(ABORT_ISP_ACTIVE,
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002668 &base_vha->dpc_flags))) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002669
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002670 if (qla2x00_abort_isp(base_vha)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002671 /* failed. retry later */
2672 set_bit(ISP_ABORT_NEEDED,
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002673 &base_vha->dpc_flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002674 }
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002675 clear_bit(ABORT_ISP_ACTIVE,
2676 &base_vha->dpc_flags);
Seokmann Ju99363ef2008-01-31 12:33:51 -08002677 }
2678
Linus Torvalds1da177e2005-04-16 15:20:36 -07002679 DEBUG(printk("scsi(%ld): dpc: qla2x00_abort_isp end\n",
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002680 base_vha->host_no));
Linus Torvalds1da177e2005-04-16 15:20:36 -07002681 }
2682
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002683 if (test_bit(FCPORT_UPDATE_NEEDED, &base_vha->dpc_flags)) {
2684 qla2x00_update_fcports(base_vha);
2685 clear_bit(FCPORT_UPDATE_NEEDED, &base_vha->dpc_flags);
Andrew Vasquezc9c5ced2008-07-24 08:31:49 -07002686 }
andrew.vasquez@qlogic.comd97994d2006-01-20 14:53:13 -08002687
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002688 if (test_and_clear_bit(RESET_MARKER_NEEDED,
2689 &base_vha->dpc_flags) &&
2690 (!(test_and_set_bit(RESET_ACTIVE, &base_vha->dpc_flags)))) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002691
2692 DEBUG(printk("scsi(%ld): qla2x00_reset_marker()\n",
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002693 base_vha->host_no));
Linus Torvalds1da177e2005-04-16 15:20:36 -07002694
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002695 qla2x00_rst_aen(base_vha);
2696 clear_bit(RESET_ACTIVE, &base_vha->dpc_flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002697 }
2698
2699 /* Retry each device up to login retry count */
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002700 if ((test_and_clear_bit(RELOGIN_NEEDED,
2701 &base_vha->dpc_flags)) &&
2702 !test_bit(LOOP_RESYNC_NEEDED, &base_vha->dpc_flags) &&
2703 atomic_read(&base_vha->loop_state) != LOOP_DOWN) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002704
2705 DEBUG(printk("scsi(%ld): qla2x00_port_login()\n",
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002706 base_vha->host_no));
2707 qla2x00_relogin(base_vha);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002708
Linus Torvalds1da177e2005-04-16 15:20:36 -07002709 DEBUG(printk("scsi(%ld): qla2x00_port_login - end\n",
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002710 base_vha->host_no));
Linus Torvalds1da177e2005-04-16 15:20:36 -07002711 }
2712
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002713 if (test_and_clear_bit(LOOP_RESYNC_NEEDED,
2714 &base_vha->dpc_flags)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002715
2716 DEBUG(printk("scsi(%ld): qla2x00_loop_resync()\n",
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002717 base_vha->host_no));
Linus Torvalds1da177e2005-04-16 15:20:36 -07002718
2719 if (!(test_and_set_bit(LOOP_RESYNC_ACTIVE,
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002720 &base_vha->dpc_flags))) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002721
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002722 rval = qla2x00_loop_resync(base_vha);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002723
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002724 clear_bit(LOOP_RESYNC_ACTIVE,
2725 &base_vha->dpc_flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002726 }
2727
2728 DEBUG(printk("scsi(%ld): qla2x00_loop_resync - end\n",
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002729 base_vha->host_no));
Linus Torvalds1da177e2005-04-16 15:20:36 -07002730 }
2731
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002732 if (test_bit(NPIV_CONFIG_NEEDED, &base_vha->dpc_flags) &&
2733 atomic_read(&base_vha->loop_state) == LOOP_READY) {
2734 clear_bit(NPIV_CONFIG_NEEDED, &base_vha->dpc_flags);
2735 qla2xxx_flash_npiv_conf(base_vha);
Andrew Vasquez272976c2008-09-11 21:22:50 -07002736 }
2737
Linus Torvalds1da177e2005-04-16 15:20:36 -07002738 if (!ha->interrupts_on)
Andrew Vasquezfd34f552007-07-19 15:06:00 -07002739 ha->isp_ops->enable_intrs(ha);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002740
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002741 if (test_and_clear_bit(BEACON_BLINK_NEEDED,
2742 &base_vha->dpc_flags))
2743 ha->isp_ops->beacon_blink(base_vha);
andrew.vasquez@qlogic.comf6df1442006-01-31 16:05:07 -08002744
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002745 qla2x00_do_dpc_all_vps(base_vha);
Seokmann Ju2c3dfe32007-07-05 13:16:51 -07002746
Linus Torvalds1da177e2005-04-16 15:20:36 -07002747 ha->dpc_active = 0;
2748 } /* End of while(1) */
2749
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002750 DEBUG(printk("scsi(%ld): DPC handler exiting\n", base_vha->host_no));
Linus Torvalds1da177e2005-04-16 15:20:36 -07002751
2752 /*
2753 * Make sure that nobody tries to wake us up again.
2754 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07002755 ha->dpc_active = 0;
2756
Christoph Hellwig39a11242006-02-14 18:46:22 +01002757 return 0;
2758}
2759
2760void
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002761qla2xxx_wake_dpc(struct scsi_qla_host *vha)
Christoph Hellwig39a11242006-02-14 18:46:22 +01002762{
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002763 struct qla_hw_data *ha = vha->hw;
Andrew Vasquezc795c1e2008-08-13 21:37:01 -07002764 struct task_struct *t = ha->dpc_thread;
2765
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002766 if (!test_bit(UNLOADING, &vha->dpc_flags) && t)
Andrew Vasquezc795c1e2008-08-13 21:37:01 -07002767 wake_up_process(t);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002768}
2769
2770/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002771* qla2x00_rst_aen
2772* Processes asynchronous reset.
2773*
2774* Input:
2775* ha = adapter block pointer.
2776*/
2777static void
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002778qla2x00_rst_aen(scsi_qla_host_t *vha)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002779{
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002780 if (vha->flags.online && !vha->flags.reset_active &&
2781 !atomic_read(&vha->loop_down_timer) &&
2782 !(test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags))) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002783 do {
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002784 clear_bit(RESET_MARKER_NEEDED, &vha->dpc_flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002785
2786 /*
2787 * Issue marker command only when we are going to start
2788 * the I/O.
2789 */
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002790 vha->marker_needed = 1;
2791 } while (!atomic_read(&vha->loop_down_timer) &&
2792 (test_bit(RESET_MARKER_NEEDED, &vha->dpc_flags)));
Linus Torvalds1da177e2005-04-16 15:20:36 -07002793 }
2794}
2795
f4f051e2005-04-17 15:02:26 -05002796static void
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002797qla2x00_sp_free_dma(srb_t *sp)
f4f051e2005-04-17 15:02:26 -05002798{
2799 struct scsi_cmnd *cmd = sp->cmd;
2800
2801 if (sp->flags & SRB_DMA_VALID) {
FUJITA Tomonori385d70b2007-05-26 01:55:38 +09002802 scsi_dma_unmap(cmd);
f4f051e2005-04-17 15:02:26 -05002803 sp->flags &= ~SRB_DMA_VALID;
2804 }
Andrew Vasquezfca29702005-07-06 10:31:47 -07002805 CMD_SP(cmd) = NULL;
f4f051e2005-04-17 15:02:26 -05002806}
2807
2808void
Anirban Chakraborty73208df2008-12-09 16:45:39 -08002809qla2x00_sp_compl(struct qla_hw_data *ha, srb_t *sp)
f4f051e2005-04-17 15:02:26 -05002810{
2811 struct scsi_cmnd *cmd = sp->cmd;
2812
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002813 qla2x00_sp_free_dma(sp);
f4f051e2005-04-17 15:02:26 -05002814
f4f051e2005-04-17 15:02:26 -05002815 mempool_free(sp, ha->srb_mempool);
2816
2817 cmd->scsi_done(cmd);
2818}
bdf79622005-04-17 15:06:53 -05002819
Linus Torvalds1da177e2005-04-16 15:20:36 -07002820/**************************************************************************
2821* qla2x00_timer
2822*
2823* Description:
2824* One second timer
2825*
2826* Context: Interrupt
2827***************************************************************************/
Seokmann Ju2c3dfe32007-07-05 13:16:51 -07002828void
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002829qla2x00_timer(scsi_qla_host_t *vha)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002830{
Linus Torvalds1da177e2005-04-16 15:20:36 -07002831 unsigned long cpu_flags = 0;
2832 fc_port_t *fcport;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002833 int start_dpc = 0;
2834 int index;
2835 srb_t *sp;
f4f051e2005-04-17 15:02:26 -05002836 int t;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002837 struct qla_hw_data *ha = vha->hw;
Anirban Chakraborty73208df2008-12-09 16:45:39 -08002838 struct req_que *req;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002839 /*
2840 * Ports - Port down timer.
2841 *
2842 * Whenever, a port is in the LOST state we start decrementing its port
2843 * down timer every second until it reaches zero. Once it reaches zero
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -07002844 * the port it marked DEAD.
Linus Torvalds1da177e2005-04-16 15:20:36 -07002845 */
2846 t = 0;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002847 list_for_each_entry(fcport, &vha->vp_fcports, list) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002848 if (fcport->port_type != FCT_TARGET)
2849 continue;
2850
2851 if (atomic_read(&fcport->state) == FCS_DEVICE_LOST) {
2852
2853 if (atomic_read(&fcport->port_down_timer) == 0)
2854 continue;
2855
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -07002856 if (atomic_dec_and_test(&fcport->port_down_timer) != 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002857 atomic_set(&fcport->state, FCS_DEVICE_DEAD);
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -07002858
Linus Torvalds1da177e2005-04-16 15:20:36 -07002859 DEBUG(printk("scsi(%ld): fcport-%d - port retry count: "
Andrew Vasquezfca29702005-07-06 10:31:47 -07002860 "%d remaining\n",
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002861 vha->host_no,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002862 t, atomic_read(&fcport->port_down_timer)));
2863 }
2864 t++;
2865 } /* End of for fcport */
2866
Linus Torvalds1da177e2005-04-16 15:20:36 -07002867
2868 /* Loop down handler. */
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002869 if (atomic_read(&vha->loop_down_timer) > 0 &&
2870 !(test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags))
2871 && vha->flags.online) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002872
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002873 if (atomic_read(&vha->loop_down_timer) ==
2874 vha->loop_down_abort_time) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002875
2876 DEBUG(printk("scsi(%ld): Loop Down - aborting the "
2877 "queues before time expire\n",
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002878 vha->host_no));
Linus Torvalds1da177e2005-04-16 15:20:36 -07002879
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002880 if (!IS_QLA2100(ha) && vha->link_down_timeout)
2881 atomic_set(&vha->loop_state, LOOP_DEAD);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002882
2883 /* Schedule an ISP abort to return any tape commands. */
Seokmann Ju2c3dfe32007-07-05 13:16:51 -07002884 /* NPIV - scan physical port only */
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002885 if (!vha->vp_idx) {
Seokmann Ju2c3dfe32007-07-05 13:16:51 -07002886 spin_lock_irqsave(&ha->hardware_lock,
2887 cpu_flags);
Anirban Chakraborty73208df2008-12-09 16:45:39 -08002888 req = ha->req_q_map[0];
Seokmann Ju2c3dfe32007-07-05 13:16:51 -07002889 for (index = 1;
2890 index < MAX_OUTSTANDING_COMMANDS;
2891 index++) {
2892 fc_port_t *sfcp;
bdf79622005-04-17 15:06:53 -05002893
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002894 sp = req->outstanding_cmds[index];
Seokmann Ju2c3dfe32007-07-05 13:16:51 -07002895 if (!sp)
2896 continue;
2897 sfcp = sp->fcport;
2898 if (!(sfcp->flags & FCF_TAPE_PRESENT))
2899 continue;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002900
Seokmann Ju2c3dfe32007-07-05 13:16:51 -07002901 set_bit(ISP_ABORT_NEEDED,
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002902 &vha->dpc_flags);
Seokmann Ju2c3dfe32007-07-05 13:16:51 -07002903 break;
2904 }
2905 spin_unlock_irqrestore(&ha->hardware_lock,
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002906 cpu_flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002907 }
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002908 set_bit(ABORT_QUEUES_NEEDED, &vha->dpc_flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002909 start_dpc++;
2910 }
2911
2912 /* if the loop has been down for 4 minutes, reinit adapter */
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002913 if (atomic_dec_and_test(&vha->loop_down_timer) != 0) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002914 DEBUG(printk("scsi(%ld): Loop down exceed 4 mins - "
2915 "restarting queues.\n",
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002916 vha->host_no));
Linus Torvalds1da177e2005-04-16 15:20:36 -07002917
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002918 set_bit(RESTART_QUEUES_NEEDED, &vha->dpc_flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002919 start_dpc++;
2920
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002921 if (!(vha->device_flags & DFLG_NO_CABLE) &&
2922 !vha->vp_idx) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002923 DEBUG(printk("scsi(%ld): Loop down - "
2924 "aborting ISP.\n",
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002925 vha->host_no));
Linus Torvalds1da177e2005-04-16 15:20:36 -07002926 qla_printk(KERN_WARNING, ha,
2927 "Loop down - aborting ISP.\n");
2928
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002929 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002930 }
2931 }
Andrew Vasquezfca29702005-07-06 10:31:47 -07002932 DEBUG3(printk("scsi(%ld): Loop Down - seconds remaining %d\n",
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002933 vha->host_no,
2934 atomic_read(&vha->loop_down_timer)));
Linus Torvalds1da177e2005-04-16 15:20:36 -07002935 }
2936
andrew.vasquez@qlogic.comf6df1442006-01-31 16:05:07 -08002937 /* Check if beacon LED needs to be blinked */
2938 if (ha->beacon_blink_led == 1) {
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002939 set_bit(BEACON_BLINK_NEEDED, &vha->dpc_flags);
andrew.vasquez@qlogic.comf6df1442006-01-31 16:05:07 -08002940 start_dpc++;
2941 }
2942
Andrew Vasquez550bf572008-04-24 15:21:23 -07002943 /* Process any deferred work. */
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002944 if (!list_empty(&vha->work_list))
Andrew Vasquez550bf572008-04-24 15:21:23 -07002945 start_dpc++;
2946
Linus Torvalds1da177e2005-04-16 15:20:36 -07002947 /* Schedule the DPC routine if needed */
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002948 if ((test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) ||
2949 test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags) ||
2950 test_bit(FCPORT_UPDATE_NEEDED, &vha->dpc_flags) ||
Linus Torvalds1da177e2005-04-16 15:20:36 -07002951 start_dpc ||
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002952 test_bit(RESET_MARKER_NEEDED, &vha->dpc_flags) ||
2953 test_bit(BEACON_BLINK_NEEDED, &vha->dpc_flags) ||
2954 test_bit(VP_DPC_NEEDED, &vha->dpc_flags) ||
2955 test_bit(RELOGIN_NEEDED, &vha->dpc_flags)))
2956 qla2xxx_wake_dpc(vha);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002957
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002958 qla2x00_restart_timer(vha, WATCH_INTERVAL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002959}
2960
Andrew Vasquez54333832005-11-09 15:49:04 -08002961/* Firmware interface routines. */
2962
Andrew Vasquez3a03eb72009-01-05 11:18:11 -08002963#define FW_BLOBS 7
Andrew Vasquez54333832005-11-09 15:49:04 -08002964#define FW_ISP21XX 0
2965#define FW_ISP22XX 1
2966#define FW_ISP2300 2
2967#define FW_ISP2322 3
andrew.vasquez@qlogic.com48c02fd2006-03-09 14:27:18 -08002968#define FW_ISP24XX 4
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07002969#define FW_ISP25XX 5
Andrew Vasquez3a03eb72009-01-05 11:18:11 -08002970#define FW_ISP81XX 6
Andrew Vasquez54333832005-11-09 15:49:04 -08002971
Andrew Vasquezbb8ee492006-10-02 12:00:48 -07002972#define FW_FILE_ISP21XX "ql2100_fw.bin"
2973#define FW_FILE_ISP22XX "ql2200_fw.bin"
2974#define FW_FILE_ISP2300 "ql2300_fw.bin"
2975#define FW_FILE_ISP2322 "ql2322_fw.bin"
2976#define FW_FILE_ISP24XX "ql2400_fw.bin"
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07002977#define FW_FILE_ISP25XX "ql2500_fw.bin"
Andrew Vasquez3a03eb72009-01-05 11:18:11 -08002978#define FW_FILE_ISP81XX "ql8100_fw.bin"
Andrew Vasquezbb8ee492006-10-02 12:00:48 -07002979
Daniel Walkere1e82b62008-05-12 22:21:10 -07002980static DEFINE_MUTEX(qla_fw_lock);
Andrew Vasquez54333832005-11-09 15:49:04 -08002981
2982static struct fw_blob qla_fw_blobs[FW_BLOBS] = {
Andrew Vasquezbb8ee492006-10-02 12:00:48 -07002983 { .name = FW_FILE_ISP21XX, .segs = { 0x1000, 0 }, },
2984 { .name = FW_FILE_ISP22XX, .segs = { 0x1000, 0 }, },
2985 { .name = FW_FILE_ISP2300, .segs = { 0x800, 0 }, },
2986 { .name = FW_FILE_ISP2322, .segs = { 0x800, 0x1c000, 0x1e000, 0 }, },
2987 { .name = FW_FILE_ISP24XX, },
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07002988 { .name = FW_FILE_ISP25XX, },
Andrew Vasquez3a03eb72009-01-05 11:18:11 -08002989 { .name = FW_FILE_ISP81XX, },
Andrew Vasquez54333832005-11-09 15:49:04 -08002990};
2991
2992struct fw_blob *
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002993qla2x00_request_firmware(scsi_qla_host_t *vha)
Andrew Vasquez54333832005-11-09 15:49:04 -08002994{
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002995 struct qla_hw_data *ha = vha->hw;
Andrew Vasquez54333832005-11-09 15:49:04 -08002996 struct fw_blob *blob;
2997
2998 blob = NULL;
2999 if (IS_QLA2100(ha)) {
3000 blob = &qla_fw_blobs[FW_ISP21XX];
3001 } else if (IS_QLA2200(ha)) {
3002 blob = &qla_fw_blobs[FW_ISP22XX];
andrew.vasquez@qlogic.com48c02fd2006-03-09 14:27:18 -08003003 } else if (IS_QLA2300(ha) || IS_QLA2312(ha) || IS_QLA6312(ha)) {
Andrew Vasquez54333832005-11-09 15:49:04 -08003004 blob = &qla_fw_blobs[FW_ISP2300];
andrew.vasquez@qlogic.com48c02fd2006-03-09 14:27:18 -08003005 } else if (IS_QLA2322(ha) || IS_QLA6322(ha)) {
Andrew Vasquez54333832005-11-09 15:49:04 -08003006 blob = &qla_fw_blobs[FW_ISP2322];
Harihara Kadayam4d4df192008-04-03 13:13:26 -07003007 } else if (IS_QLA24XX_TYPE(ha)) {
Andrew Vasquez54333832005-11-09 15:49:04 -08003008 blob = &qla_fw_blobs[FW_ISP24XX];
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07003009 } else if (IS_QLA25XX(ha)) {
3010 blob = &qla_fw_blobs[FW_ISP25XX];
Andrew Vasquez3a03eb72009-01-05 11:18:11 -08003011 } else if (IS_QLA81XX(ha)) {
3012 blob = &qla_fw_blobs[FW_ISP81XX];
Andrew Vasquez54333832005-11-09 15:49:04 -08003013 }
3014
Daniel Walkere1e82b62008-05-12 22:21:10 -07003015 mutex_lock(&qla_fw_lock);
Andrew Vasquez54333832005-11-09 15:49:04 -08003016 if (blob->fw)
3017 goto out;
3018
3019 if (request_firmware(&blob->fw, blob->name, &ha->pdev->dev)) {
3020 DEBUG2(printk("scsi(%ld): Failed to load firmware image "
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003021 "(%s).\n", vha->host_no, blob->name));
Andrew Vasquez54333832005-11-09 15:49:04 -08003022 blob->fw = NULL;
3023 blob = NULL;
3024 goto out;
3025 }
3026
3027out:
Daniel Walkere1e82b62008-05-12 22:21:10 -07003028 mutex_unlock(&qla_fw_lock);
Andrew Vasquez54333832005-11-09 15:49:04 -08003029 return blob;
3030}
3031
3032static void
3033qla2x00_release_firmware(void)
3034{
3035 int idx;
3036
Daniel Walkere1e82b62008-05-12 22:21:10 -07003037 mutex_lock(&qla_fw_lock);
Andrew Vasquez54333832005-11-09 15:49:04 -08003038 for (idx = 0; idx < FW_BLOBS; idx++)
3039 if (qla_fw_blobs[idx].fw)
3040 release_firmware(qla_fw_blobs[idx].fw);
Daniel Walkere1e82b62008-05-12 22:21:10 -07003041 mutex_unlock(&qla_fw_lock);
Andrew Vasquez54333832005-11-09 15:49:04 -08003042}
3043
Seokmann Ju14e660e2007-09-20 14:07:36 -07003044static pci_ers_result_t
3045qla2xxx_pci_error_detected(struct pci_dev *pdev, pci_channel_state_t state)
3046{
3047 switch (state) {
3048 case pci_channel_io_normal:
3049 return PCI_ERS_RESULT_CAN_RECOVER;
3050 case pci_channel_io_frozen:
3051 pci_disable_device(pdev);
3052 return PCI_ERS_RESULT_NEED_RESET;
3053 case pci_channel_io_perm_failure:
3054 qla2x00_remove_one(pdev);
3055 return PCI_ERS_RESULT_DISCONNECT;
3056 }
3057 return PCI_ERS_RESULT_NEED_RESET;
3058}
3059
3060static pci_ers_result_t
3061qla2xxx_pci_mmio_enabled(struct pci_dev *pdev)
3062{
3063 int risc_paused = 0;
3064 uint32_t stat;
3065 unsigned long flags;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003066 scsi_qla_host_t *base_vha = pci_get_drvdata(pdev);
3067 struct qla_hw_data *ha = base_vha->hw;
Seokmann Ju14e660e2007-09-20 14:07:36 -07003068 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
3069 struct device_reg_24xx __iomem *reg24 = &ha->iobase->isp24;
3070
3071 spin_lock_irqsave(&ha->hardware_lock, flags);
3072 if (IS_QLA2100(ha) || IS_QLA2200(ha)){
3073 stat = RD_REG_DWORD(&reg->hccr);
3074 if (stat & HCCR_RISC_PAUSE)
3075 risc_paused = 1;
3076 } else if (IS_QLA23XX(ha)) {
3077 stat = RD_REG_DWORD(&reg->u.isp2300.host_status);
3078 if (stat & HSR_RISC_PAUSED)
3079 risc_paused = 1;
3080 } else if (IS_FWI2_CAPABLE(ha)) {
3081 stat = RD_REG_DWORD(&reg24->host_status);
3082 if (stat & HSRX_RISC_PAUSED)
3083 risc_paused = 1;
3084 }
3085 spin_unlock_irqrestore(&ha->hardware_lock, flags);
3086
3087 if (risc_paused) {
3088 qla_printk(KERN_INFO, ha, "RISC paused -- mmio_enabled, "
3089 "Dumping firmware!\n");
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003090 ha->isp_ops->fw_dump(base_vha, 0);
Seokmann Ju14e660e2007-09-20 14:07:36 -07003091
3092 return PCI_ERS_RESULT_NEED_RESET;
3093 } else
3094 return PCI_ERS_RESULT_RECOVERED;
3095}
3096
3097static pci_ers_result_t
3098qla2xxx_pci_slot_reset(struct pci_dev *pdev)
3099{
3100 pci_ers_result_t ret = PCI_ERS_RESULT_DISCONNECT;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003101 scsi_qla_host_t *base_vha = pci_get_drvdata(pdev);
3102 struct qla_hw_data *ha = base_vha->hw;
Benjamin Herrenschmidt09483912007-12-20 15:28:09 +11003103 int rc;
Seokmann Ju14e660e2007-09-20 14:07:36 -07003104
Benjamin Herrenschmidt09483912007-12-20 15:28:09 +11003105 if (ha->mem_only)
3106 rc = pci_enable_device_mem(pdev);
3107 else
3108 rc = pci_enable_device(pdev);
3109
3110 if (rc) {
Seokmann Ju14e660e2007-09-20 14:07:36 -07003111 qla_printk(KERN_WARNING, ha,
3112 "Can't re-enable PCI device after reset.\n");
3113
3114 return ret;
3115 }
3116 pci_set_master(pdev);
3117
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003118 if (ha->isp_ops->pci_config(base_vha))
Seokmann Ju14e660e2007-09-20 14:07:36 -07003119 return ret;
3120
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003121 set_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags);
3122 if (qla2x00_abort_isp(base_vha) == QLA_SUCCESS)
Seokmann Ju14e660e2007-09-20 14:07:36 -07003123 ret = PCI_ERS_RESULT_RECOVERED;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003124 clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags);
Seokmann Ju14e660e2007-09-20 14:07:36 -07003125
3126 return ret;
3127}
3128
3129static void
3130qla2xxx_pci_resume(struct pci_dev *pdev)
3131{
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003132 scsi_qla_host_t *base_vha = pci_get_drvdata(pdev);
3133 struct qla_hw_data *ha = base_vha->hw;
Seokmann Ju14e660e2007-09-20 14:07:36 -07003134 int ret;
3135
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003136 ret = qla2x00_wait_for_hba_online(base_vha);
Seokmann Ju14e660e2007-09-20 14:07:36 -07003137 if (ret != QLA_SUCCESS) {
3138 qla_printk(KERN_ERR, ha,
3139 "the device failed to resume I/O "
3140 "from slot/link_reset");
3141 }
3142 pci_cleanup_aer_uncorrect_error_status(pdev);
3143}
3144
3145static struct pci_error_handlers qla2xxx_err_handler = {
3146 .error_detected = qla2xxx_pci_error_detected,
3147 .mmio_enabled = qla2xxx_pci_mmio_enabled,
3148 .slot_reset = qla2xxx_pci_slot_reset,
3149 .resume = qla2xxx_pci_resume,
3150};
3151
Andrew Vasquez54333832005-11-09 15:49:04 -08003152static struct pci_device_id qla2xxx_pci_tbl[] = {
Andrew Vasquez47f5e062006-05-17 15:09:39 -07003153 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2100) },
3154 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2200) },
3155 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2300) },
3156 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2312) },
3157 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2322) },
3158 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP6312) },
3159 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP6322) },
3160 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2422) },
3161 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2432) },
Harihara Kadayam4d4df192008-04-03 13:13:26 -07003162 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8432) },
Andrew Vasquez47f5e062006-05-17 15:09:39 -07003163 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP5422) },
3164 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP5432) },
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07003165 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2532) },
Andrew Vasquez3a03eb72009-01-05 11:18:11 -08003166 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8001) },
Andrew Vasquez54333832005-11-09 15:49:04 -08003167 { 0 },
3168};
3169MODULE_DEVICE_TABLE(pci, qla2xxx_pci_tbl);
3170
Andrew Vasquezfca29702005-07-06 10:31:47 -07003171static struct pci_driver qla2xxx_pci_driver = {
Andrew Vasquezcb630672006-05-17 15:09:45 -07003172 .name = QLA2XXX_DRIVER_NAME,
James Bottomley0a21ef12005-12-01 12:51:50 -06003173 .driver = {
3174 .owner = THIS_MODULE,
3175 },
Andrew Vasquezfca29702005-07-06 10:31:47 -07003176 .id_table = qla2xxx_pci_tbl,
Andrew Vasquez7ee61392006-06-23 16:11:22 -07003177 .probe = qla2x00_probe_one,
Adrian Bunk4c993f72008-01-14 00:55:16 -08003178 .remove = qla2x00_remove_one,
Seokmann Ju14e660e2007-09-20 14:07:36 -07003179 .err_handler = &qla2xxx_err_handler,
Andrew Vasquezfca29702005-07-06 10:31:47 -07003180};
3181
Linus Torvalds1da177e2005-04-16 15:20:36 -07003182/**
3183 * qla2x00_module_init - Module initialization.
3184 **/
3185static int __init
3186qla2x00_module_init(void)
3187{
Andrew Vasquezfca29702005-07-06 10:31:47 -07003188 int ret = 0;
3189
Linus Torvalds1da177e2005-04-16 15:20:36 -07003190 /* Allocate cache for SRBs. */
Andrew Vasquez 354d6b22005-04-23 02:47:27 -04003191 srb_cachep = kmem_cache_create("qla2xxx_srbs", sizeof(srb_t), 0,
Paul Mundt20c2df82007-07-20 10:11:58 +09003192 SLAB_HWCACHE_ALIGN, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003193 if (srb_cachep == NULL) {
3194 printk(KERN_ERR
3195 "qla2xxx: Unable to allocate SRB cache...Failing load!\n");
3196 return -ENOMEM;
3197 }
3198
3199 /* Derive version string. */
3200 strcpy(qla2x00_version_str, QLA2XXX_VERSION);
Andrew Vasquez11010fe2006-10-06 09:54:59 -07003201 if (ql2xextended_error_logging)
Andrew Vasquez01819442006-06-23 16:11:10 -07003202 strcat(qla2x00_version_str, "-debug");
3203
Andrew Vasquez1c97a122005-04-21 16:13:36 -04003204 qla2xxx_transport_template =
3205 fc_attach_transport(&qla2xxx_transport_functions);
Seokmann Ju2c3dfe32007-07-05 13:16:51 -07003206 if (!qla2xxx_transport_template) {
3207 kmem_cache_destroy(srb_cachep);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003208 return -ENODEV;
Seokmann Ju2c3dfe32007-07-05 13:16:51 -07003209 }
3210 qla2xxx_transport_vport_template =
3211 fc_attach_transport(&qla2xxx_transport_vport_functions);
3212 if (!qla2xxx_transport_vport_template) {
3213 kmem_cache_destroy(srb_cachep);
3214 fc_release_transport(qla2xxx_transport_template);
3215 return -ENODEV;
3216 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003217
Andrew Vasquezfd9a29f02008-05-12 22:21:08 -07003218 printk(KERN_INFO "QLogic Fibre Channel HBA Driver: %s\n",
3219 qla2x00_version_str);
Andrew Vasquez7ee61392006-06-23 16:11:22 -07003220 ret = pci_register_driver(&qla2xxx_pci_driver);
Andrew Vasquezfca29702005-07-06 10:31:47 -07003221 if (ret) {
3222 kmem_cache_destroy(srb_cachep);
3223 fc_release_transport(qla2xxx_transport_template);
Seokmann Ju2c3dfe32007-07-05 13:16:51 -07003224 fc_release_transport(qla2xxx_transport_vport_template);
Andrew Vasquezfca29702005-07-06 10:31:47 -07003225 }
3226 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003227}
3228
3229/**
3230 * qla2x00_module_exit - Module cleanup.
3231 **/
3232static void __exit
3233qla2x00_module_exit(void)
3234{
Andrew Vasquez7ee61392006-06-23 16:11:22 -07003235 pci_unregister_driver(&qla2xxx_pci_driver);
Andrew Vasquez54333832005-11-09 15:49:04 -08003236 qla2x00_release_firmware();
Andrew Vasquez 354d6b22005-04-23 02:47:27 -04003237 kmem_cache_destroy(srb_cachep);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003238 fc_release_transport(qla2xxx_transport_template);
Seokmann Ju2c3dfe32007-07-05 13:16:51 -07003239 fc_release_transport(qla2xxx_transport_vport_template);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003240}
3241
3242module_init(qla2x00_module_init);
3243module_exit(qla2x00_module_exit);
3244
3245MODULE_AUTHOR("QLogic Corporation");
3246MODULE_DESCRIPTION("QLogic Fibre Channel HBA Driver");
3247MODULE_LICENSE("GPL");
3248MODULE_VERSION(QLA2XXX_VERSION);
Andrew Vasquezbb8ee492006-10-02 12:00:48 -07003249MODULE_FIRMWARE(FW_FILE_ISP21XX);
3250MODULE_FIRMWARE(FW_FILE_ISP22XX);
3251MODULE_FIRMWARE(FW_FILE_ISP2300);
3252MODULE_FIRMWARE(FW_FILE_ISP2322);
3253MODULE_FIRMWARE(FW_FILE_ISP24XX);
Andrew Vasquez61623fc2008-01-31 12:33:45 -08003254MODULE_FIRMWARE(FW_FILE_ISP25XX);
Andrew Vasquez3a03eb72009-01-05 11:18:11 -08003255MODULE_FIRMWARE(FW_FILE_ISP81XX);