blob: 185ea8bcb9e275252a19ebf25ceecf2a48c19d79 [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
68static void qla2x00_config_dma_addressing(scsi_qla_host_t *ha);
69
Andrew Vasquez7e47e5c2008-04-24 15:21:26 -070070int ql2xfdmienable=1;
Andrew Vasquezcca53352005-08-26 19:08:30 -070071module_param(ql2xfdmienable, int, S_IRUGO|S_IRUSR);
72MODULE_PARM_DESC(ql2xfdmienable,
73 "Enables FDMI registratons "
74 "Default is 0 - no FDMI. 1 - perfom FDMI.");
75
Andrew Vasquezdf7baa52006-10-13 09:33:39 -070076#define MAX_Q_DEPTH 32
77static int ql2xmaxqdepth = MAX_Q_DEPTH;
78module_param(ql2xmaxqdepth, int, S_IRUGO|S_IWUSR);
79MODULE_PARM_DESC(ql2xmaxqdepth,
80 "Maximum queue depth to report for target devices.");
81
82int ql2xqfullrampup = 120;
83module_param(ql2xqfullrampup, int, S_IRUGO|S_IWUSR);
84MODULE_PARM_DESC(ql2xqfullrampup,
85 "Number of seconds to wait to begin to ramp-up the queue "
86 "depth for a device after a queue-full condition has been "
87 "detected. Default is 120 seconds.");
88
Andrew Vasqueze5896bd2008-07-10 16:55:52 -070089int ql2xiidmaenable=1;
90module_param(ql2xiidmaenable, int, S_IRUGO|S_IRUSR);
91MODULE_PARM_DESC(ql2xiidmaenable,
92 "Enables iIDMA settings "
93 "Default is 1 - perform iIDMA. 0 - no iIDMA.");
94
Anirban Chakraborty73208df2008-12-09 16:45:39 -080095int ql2xmaxqueues = 1;
96module_param(ql2xmaxqueues, int, S_IRUGO|S_IRUSR);
97MODULE_PARM_DESC(ql2xmaxqueues,
98 "Enables MQ settings "
99 "Default is 1 for single queue. Set it to number \
100 of queues in MQ mode.");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700101/*
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700102 * SCSI host template entry points
Linus Torvalds1da177e2005-04-16 15:20:36 -0700103 */
104static int qla2xxx_slave_configure(struct scsi_device * device);
f4f051e2005-04-17 15:02:26 -0500105static int qla2xxx_slave_alloc(struct scsi_device *);
Andrew Vasquez1e99e332006-11-22 08:24:48 -0800106static int qla2xxx_scan_finished(struct Scsi_Host *, unsigned long time);
107static void qla2xxx_scan_start(struct Scsi_Host *);
f4f051e2005-04-17 15:02:26 -0500108static void qla2xxx_slave_destroy(struct scsi_device *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700109static int qla2x00_queuecommand(struct scsi_cmnd *cmd,
110 void (*fn)(struct scsi_cmnd *));
Andrew Vasquezfca29702005-07-06 10:31:47 -0700111static int qla24xx_queuecommand(struct scsi_cmnd *cmd,
112 void (*fn)(struct scsi_cmnd *));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700113static int qla2xxx_eh_abort(struct scsi_cmnd *);
114static int qla2xxx_eh_device_reset(struct scsi_cmnd *);
Andrew Vasquez523ec772008-04-03 13:13:24 -0700115static int qla2xxx_eh_target_reset(struct scsi_cmnd *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700116static int qla2xxx_eh_bus_reset(struct scsi_cmnd *);
117static int qla2xxx_eh_host_reset(struct scsi_cmnd *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700118
Andrew Vasquezce7e4af2005-08-26 19:09:30 -0700119static int qla2x00_change_queue_depth(struct scsi_device *, int);
120static int qla2x00_change_queue_type(struct scsi_device *, int);
121
Adrian Bunka824ebb2008-01-17 09:02:15 -0800122static struct scsi_host_template qla2x00_driver_template = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700123 .module = THIS_MODULE,
Andrew Vasquezcb630672006-05-17 15:09:45 -0700124 .name = QLA2XXX_DRIVER_NAME,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700125 .queuecommand = qla2x00_queuecommand,
126
127 .eh_abort_handler = qla2xxx_eh_abort,
128 .eh_device_reset_handler = qla2xxx_eh_device_reset,
Andrew Vasquez523ec772008-04-03 13:13:24 -0700129 .eh_target_reset_handler = qla2xxx_eh_target_reset,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700130 .eh_bus_reset_handler = qla2xxx_eh_bus_reset,
131 .eh_host_reset_handler = qla2xxx_eh_host_reset,
132
133 .slave_configure = qla2xxx_slave_configure,
134
f4f051e2005-04-17 15:02:26 -0500135 .slave_alloc = qla2xxx_slave_alloc,
136 .slave_destroy = qla2xxx_slave_destroy,
Andrew Vasquez1e99e332006-11-22 08:24:48 -0800137 .scan_finished = qla2xxx_scan_finished,
138 .scan_start = qla2xxx_scan_start,
Andrew Vasquezce7e4af2005-08-26 19:09:30 -0700139 .change_queue_depth = qla2x00_change_queue_depth,
140 .change_queue_type = qla2x00_change_queue_type,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700141 .this_id = -1,
142 .cmd_per_lun = 3,
143 .use_clustering = ENABLE_CLUSTERING,
144 .sg_tablesize = SG_ALL,
145
146 /*
147 * The RISC allows for each command to transfer (2^32-1) bytes of data,
148 * which equates to 0x800000 sectors.
149 */
150 .max_sectors = 0xFFFF,
Andrew Vasquezafb046e2005-08-26 19:09:40 -0700151 .shost_attrs = qla2x00_host_attrs,
Linus Torvalds1da177e2005-04-16 15:20:36 -0700152};
153
Seokmann Ju2c3dfe32007-07-05 13:16:51 -0700154struct scsi_host_template qla24xx_driver_template = {
Andrew Vasquezfca29702005-07-06 10:31:47 -0700155 .module = THIS_MODULE,
Andrew Vasquezcb630672006-05-17 15:09:45 -0700156 .name = QLA2XXX_DRIVER_NAME,
Andrew Vasquezfca29702005-07-06 10:31:47 -0700157 .queuecommand = qla24xx_queuecommand,
158
159 .eh_abort_handler = qla2xxx_eh_abort,
160 .eh_device_reset_handler = qla2xxx_eh_device_reset,
Andrew Vasquez523ec772008-04-03 13:13:24 -0700161 .eh_target_reset_handler = qla2xxx_eh_target_reset,
Andrew Vasquezfca29702005-07-06 10:31:47 -0700162 .eh_bus_reset_handler = qla2xxx_eh_bus_reset,
163 .eh_host_reset_handler = qla2xxx_eh_host_reset,
164
165 .slave_configure = qla2xxx_slave_configure,
166
167 .slave_alloc = qla2xxx_slave_alloc,
168 .slave_destroy = qla2xxx_slave_destroy,
Andrew Vasquezed677082007-03-12 10:41:27 -0700169 .scan_finished = qla2xxx_scan_finished,
170 .scan_start = qla2xxx_scan_start,
Andrew Vasquezce7e4af2005-08-26 19:09:30 -0700171 .change_queue_depth = qla2x00_change_queue_depth,
172 .change_queue_type = qla2x00_change_queue_type,
Andrew Vasquezfca29702005-07-06 10:31:47 -0700173 .this_id = -1,
174 .cmd_per_lun = 3,
175 .use_clustering = ENABLE_CLUSTERING,
176 .sg_tablesize = SG_ALL,
177
178 .max_sectors = 0xFFFF,
Andrew Vasquezafb046e2005-08-26 19:09:40 -0700179 .shost_attrs = qla2x00_host_attrs,
Andrew Vasquezfca29702005-07-06 10:31:47 -0700180};
181
Linus Torvalds1da177e2005-04-16 15:20:36 -0700182static struct scsi_transport_template *qla2xxx_transport_template = NULL;
Seokmann Ju2c3dfe32007-07-05 13:16:51 -0700183struct scsi_transport_template *qla2xxx_transport_vport_template = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700184
Linus Torvalds1da177e2005-04-16 15:20:36 -0700185/* TODO Convert to inlines
186 *
187 * Timer routines
188 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700189
Seokmann Ju2c3dfe32007-07-05 13:16:51 -0700190__inline__ void
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800191qla2x00_start_timer(scsi_qla_host_t *vha, void *func, unsigned long interval)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700192{
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800193 init_timer(&vha->timer);
194 vha->timer.expires = jiffies + interval * HZ;
195 vha->timer.data = (unsigned long)vha;
196 vha->timer.function = (void (*)(unsigned long))func;
197 add_timer(&vha->timer);
198 vha->timer_active = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700199}
200
201static inline void
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800202qla2x00_restart_timer(scsi_qla_host_t *vha, unsigned long interval)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700203{
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800204 mod_timer(&vha->timer, jiffies + interval * HZ);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700205}
206
Adrian Bunka824ebb2008-01-17 09:02:15 -0800207static __inline__ void
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800208qla2x00_stop_timer(scsi_qla_host_t *vha)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700209{
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800210 del_timer_sync(&vha->timer);
211 vha->timer_active = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700212}
213
Linus Torvalds1da177e2005-04-16 15:20:36 -0700214static int qla2x00_do_dpc(void *data);
215
216static void qla2x00_rst_aen(scsi_qla_host_t *);
217
Anirban Chakraborty73208df2008-12-09 16:45:39 -0800218static int qla2x00_mem_alloc(struct qla_hw_data *, uint16_t, uint16_t,
219 struct req_que **, struct rsp_que **);
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800220static void qla2x00_mem_free(struct qla_hw_data *);
221static void qla2x00_sp_free_dma(srb_t *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700222
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223/* -------------------------------------------------------------------------- */
Anirban Chakraborty73208df2008-12-09 16:45:39 -0800224static int qla2x00_alloc_queues(struct qla_hw_data *ha)
225{
226 ha->req_q_map = kzalloc(sizeof(struct req_que *) * ha->max_queues,
227 GFP_KERNEL);
228 if (!ha->req_q_map) {
229 qla_printk(KERN_WARNING, ha,
230 "Unable to allocate memory for request queue ptrs\n");
231 goto fail_req_map;
232 }
233
234 ha->rsp_q_map = kzalloc(sizeof(struct rsp_que *) * ha->max_queues,
235 GFP_KERNEL);
236 if (!ha->rsp_q_map) {
237 qla_printk(KERN_WARNING, ha,
238 "Unable to allocate memory for response queue ptrs\n");
239 goto fail_rsp_map;
240 }
241 set_bit(0, ha->rsp_qid_map);
242 set_bit(0, ha->req_qid_map);
243 return 1;
244
245fail_rsp_map:
246 kfree(ha->req_q_map);
247 ha->req_q_map = NULL;
248fail_req_map:
249 return -ENOMEM;
250}
251
252static void qla2x00_free_que(struct qla_hw_data *ha, struct req_que *req,
253 struct rsp_que *rsp)
254{
255 if (rsp && rsp->ring)
256 dma_free_coherent(&ha->pdev->dev,
257 (rsp->length + 1) * sizeof(response_t),
258 rsp->ring, rsp->dma);
259
260 kfree(rsp);
261 rsp = NULL;
262 if (req && req->ring)
263 dma_free_coherent(&ha->pdev->dev,
264 (req->length + 1) * sizeof(request_t),
265 req->ring, req->dma);
266
267 kfree(req);
268 req = NULL;
269}
270
271static void qla2x00_free_queues(struct qla_hw_data *ha)
272{
273 struct req_que *req;
274 struct rsp_que *rsp;
275 int cnt;
276
277 for (cnt = 0; cnt < ha->max_queues; cnt++) {
278 rsp = ha->rsp_q_map[cnt];
279 req = ha->req_q_map[cnt];
280 qla2x00_free_que(ha, req, rsp);
281 }
282 kfree(ha->rsp_q_map);
283 ha->rsp_q_map = NULL;
284
285 kfree(ha->req_q_map);
286 ha->req_q_map = NULL;
287}
288
Linus Torvalds1da177e2005-04-16 15:20:36 -0700289static char *
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800290qla2x00_pci_info_str(struct scsi_qla_host *vha, char *str)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700291{
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800292 struct qla_hw_data *ha = vha->hw;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700293 static char *pci_bus_modes[] = {
294 "33", "66", "100", "133",
295 };
296 uint16_t pci_bus;
297
298 strcpy(str, "PCI");
299 pci_bus = (ha->pci_attr & (BIT_9 | BIT_10)) >> 9;
300 if (pci_bus) {
301 strcat(str, "-X (");
302 strcat(str, pci_bus_modes[pci_bus]);
303 } else {
304 pci_bus = (ha->pci_attr & BIT_8) >> 8;
305 strcat(str, " (");
306 strcat(str, pci_bus_modes[pci_bus]);
307 }
308 strcat(str, " MHz)");
309
310 return (str);
311}
312
Andrew Vasquezfca29702005-07-06 10:31:47 -0700313static char *
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800314qla24xx_pci_info_str(struct scsi_qla_host *vha, char *str)
Andrew Vasquezfca29702005-07-06 10:31:47 -0700315{
316 static char *pci_bus_modes[] = { "33", "66", "100", "133", };
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800317 struct qla_hw_data *ha = vha->hw;
Andrew Vasquezfca29702005-07-06 10:31:47 -0700318 uint32_t pci_bus;
319 int pcie_reg;
320
321 pcie_reg = pci_find_capability(ha->pdev, PCI_CAP_ID_EXP);
322 if (pcie_reg) {
323 char lwstr[6];
324 uint16_t pcie_lstat, lspeed, lwidth;
325
326 pcie_reg += 0x12;
327 pci_read_config_word(ha->pdev, pcie_reg, &pcie_lstat);
328 lspeed = pcie_lstat & (BIT_0 | BIT_1 | BIT_2 | BIT_3);
329 lwidth = (pcie_lstat &
330 (BIT_4 | BIT_5 | BIT_6 | BIT_7 | BIT_8 | BIT_9)) >> 4;
331
332 strcpy(str, "PCIe (");
333 if (lspeed == 1)
Andrew Vasquezc87a0d82008-04-03 13:13:21 -0700334 strcat(str, "2.5GT/s ");
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -0700335 else if (lspeed == 2)
Andrew Vasquezc87a0d82008-04-03 13:13:21 -0700336 strcat(str, "5.0GT/s ");
Andrew Vasquezfca29702005-07-06 10:31:47 -0700337 else
338 strcat(str, "<unknown> ");
339 snprintf(lwstr, sizeof(lwstr), "x%d)", lwidth);
340 strcat(str, lwstr);
341
342 return str;
343 }
344
345 strcpy(str, "PCI");
346 pci_bus = (ha->pci_attr & CSRX_PCIX_BUS_MODE_MASK) >> 8;
347 if (pci_bus == 0 || pci_bus == 8) {
348 strcat(str, " (");
349 strcat(str, pci_bus_modes[pci_bus >> 3]);
350 } else {
351 strcat(str, "-X ");
352 if (pci_bus & BIT_2)
353 strcat(str, "Mode 2");
354 else
355 strcat(str, "Mode 1");
356 strcat(str, " (");
357 strcat(str, pci_bus_modes[pci_bus & ~BIT_2]);
358 }
359 strcat(str, " MHz)");
360
361 return str;
362}
363
Adrian Bunke5f82ab2006-11-08 19:55:50 -0800364static char *
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800365qla2x00_fw_version_str(struct scsi_qla_host *vha, char *str)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700366{
367 char un_str[10];
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800368 struct qla_hw_data *ha = vha->hw;
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700369
Linus Torvalds1da177e2005-04-16 15:20:36 -0700370 sprintf(str, "%d.%02d.%02d ", ha->fw_major_version,
371 ha->fw_minor_version,
372 ha->fw_subminor_version);
373
374 if (ha->fw_attributes & BIT_9) {
375 strcat(str, "FLX");
376 return (str);
377 }
378
379 switch (ha->fw_attributes & 0xFF) {
380 case 0x7:
381 strcat(str, "EF");
382 break;
383 case 0x17:
384 strcat(str, "TP");
385 break;
386 case 0x37:
387 strcat(str, "IP");
388 break;
389 case 0x77:
390 strcat(str, "VI");
391 break;
392 default:
393 sprintf(un_str, "(%x)", ha->fw_attributes);
394 strcat(str, un_str);
395 break;
396 }
397 if (ha->fw_attributes & 0x100)
398 strcat(str, "X");
399
400 return (str);
401}
402
Adrian Bunke5f82ab2006-11-08 19:55:50 -0800403static char *
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800404qla24xx_fw_version_str(struct scsi_qla_host *vha, char *str)
Andrew Vasquezfca29702005-07-06 10:31:47 -0700405{
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800406 struct qla_hw_data *ha = vha->hw;
Andrew Vasquezf0883ac2005-07-08 17:58:43 -0700407
Andrew Vasquez3a03eb72009-01-05 11:18:11 -0800408 sprintf(str, "%d.%02d.%02d (%x)", ha->fw_major_version,
409 ha->fw_minor_version, ha->fw_subminor_version, ha->fw_attributes);
Andrew Vasquezfca29702005-07-06 10:31:47 -0700410 return str;
Andrew Vasquezfca29702005-07-06 10:31:47 -0700411}
412
413static inline srb_t *
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800414qla2x00_get_new_sp(scsi_qla_host_t *vha, fc_port_t *fcport,
Andrew Vasquezfca29702005-07-06 10:31:47 -0700415 struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
416{
417 srb_t *sp;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800418 struct qla_hw_data *ha = vha->hw;
Andrew Vasquezfca29702005-07-06 10:31:47 -0700419
420 sp = mempool_alloc(ha->srb_mempool, GFP_ATOMIC);
421 if (!sp)
422 return sp;
423
Andrew Vasquezfca29702005-07-06 10:31:47 -0700424 sp->fcport = fcport;
425 sp->cmd = cmd;
Anirban Chakraborty17d98632008-12-18 10:06:15 -0800426 sp->que = ha->req_q_map[0];
Andrew Vasquezfca29702005-07-06 10:31:47 -0700427 sp->flags = 0;
428 CMD_SP(cmd) = (void *)sp;
429 cmd->scsi_done = done;
430
431 return sp;
432}
433
Linus Torvalds1da177e2005-04-16 15:20:36 -0700434static int
f4f051e2005-04-17 15:02:26 -0500435qla2x00_queuecommand(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
Linus Torvalds1da177e2005-04-16 15:20:36 -0700436{
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800437 scsi_qla_host_t *vha = shost_priv(cmd->device->host);
bdf79622005-04-17 15:06:53 -0500438 fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata;
James.Smart@Emulex.Com19a7b4a2005-10-18 12:03:35 -0400439 struct fc_rport *rport = starget_to_rport(scsi_target(cmd->device));
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800440 struct qla_hw_data *ha = vha->hw;
f4f051e2005-04-17 15:02:26 -0500441 srb_t *sp;
442 int rval;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700443
Seokmann Ju14e660e2007-09-20 14:07:36 -0700444 if (unlikely(pci_channel_offline(ha->pdev))) {
445 cmd->result = DID_REQUEUE << 16;
446 goto qc_fail_command;
447 }
448
James.Smart@Emulex.Com19a7b4a2005-10-18 12:03:35 -0400449 rval = fc_remote_port_chkready(rport);
450 if (rval) {
451 cmd->result = rval;
f4f051e2005-04-17 15:02:26 -0500452 goto qc_fail_command;
453 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700454
andrew.vasquez@qlogic.com387f96b2006-02-07 08:45:45 -0800455 /* Close window on fcport/rport state-transitioning. */
Mike Christie7b594132008-08-17 15:24:40 -0500456 if (fcport->drport)
457 goto qc_target_busy;
andrew.vasquez@qlogic.com387f96b2006-02-07 08:45:45 -0800458
f4f051e2005-04-17 15:02:26 -0500459 if (atomic_read(&fcport->state) != FCS_ONLINE) {
460 if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD ||
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800461 atomic_read(&vha->loop_state) == LOOP_DEAD) {
f4f051e2005-04-17 15:02:26 -0500462 cmd->result = DID_NO_CONNECT << 16;
463 goto qc_fail_command;
464 }
Mike Christie7b594132008-08-17 15:24:40 -0500465 goto qc_target_busy;
f4f051e2005-04-17 15:02:26 -0500466 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700467
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800468 spin_unlock_irq(vha->host->host_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700469
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800470 sp = qla2x00_get_new_sp(vha, fcport, cmd, done);
Andrew Vasquezfca29702005-07-06 10:31:47 -0700471 if (!sp)
f4f051e2005-04-17 15:02:26 -0500472 goto qc_host_busy_lock;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700473
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800474 rval = ha->isp_ops->start_scsi(sp);
f4f051e2005-04-17 15:02:26 -0500475 if (rval != QLA_SUCCESS)
476 goto qc_host_busy_free_sp;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700477
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800478 spin_lock_irq(vha->host->host_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700479
f4f051e2005-04-17 15:02:26 -0500480 return 0;
481
482qc_host_busy_free_sp:
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800483 qla2x00_sp_free_dma(sp);
f4f051e2005-04-17 15:02:26 -0500484 mempool_free(sp, ha->srb_mempool);
485
486qc_host_busy_lock:
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800487 spin_lock_irq(vha->host->host_lock);
f4f051e2005-04-17 15:02:26 -0500488 return SCSI_MLQUEUE_HOST_BUSY;
489
Mike Christie7b594132008-08-17 15:24:40 -0500490qc_target_busy:
491 return SCSI_MLQUEUE_TARGET_BUSY;
492
f4f051e2005-04-17 15:02:26 -0500493qc_fail_command:
494 done(cmd);
495
496 return 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700497}
498
Andrew Vasquezfca29702005-07-06 10:31:47 -0700499
500static int
501qla24xx_queuecommand(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
502{
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800503 scsi_qla_host_t *vha = shost_priv(cmd->device->host);
Andrew Vasquezfca29702005-07-06 10:31:47 -0700504 fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata;
James.Smart@Emulex.Com19a7b4a2005-10-18 12:03:35 -0400505 struct fc_rport *rport = starget_to_rport(scsi_target(cmd->device));
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800506 struct qla_hw_data *ha = vha->hw;
507 struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);
Andrew Vasquezfca29702005-07-06 10:31:47 -0700508 srb_t *sp;
509 int rval;
510
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800511 if (unlikely(pci_channel_offline(ha->pdev))) {
Seokmann Ju14e660e2007-09-20 14:07:36 -0700512 cmd->result = DID_REQUEUE << 16;
513 goto qc24_fail_command;
514 }
515
James.Smart@Emulex.Com19a7b4a2005-10-18 12:03:35 -0400516 rval = fc_remote_port_chkready(rport);
517 if (rval) {
518 cmd->result = rval;
Andrew Vasquezfca29702005-07-06 10:31:47 -0700519 goto qc24_fail_command;
520 }
521
andrew.vasquez@qlogic.com387f96b2006-02-07 08:45:45 -0800522 /* Close window on fcport/rport state-transitioning. */
Mike Christie7b594132008-08-17 15:24:40 -0500523 if (fcport->drport)
524 goto qc24_target_busy;
andrew.vasquez@qlogic.com387f96b2006-02-07 08:45:45 -0800525
Andrew Vasquezfca29702005-07-06 10:31:47 -0700526 if (atomic_read(&fcport->state) != FCS_ONLINE) {
527 if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD ||
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800528 atomic_read(&base_vha->loop_state) == LOOP_DEAD) {
Andrew Vasquezfca29702005-07-06 10:31:47 -0700529 cmd->result = DID_NO_CONNECT << 16;
530 goto qc24_fail_command;
531 }
Mike Christie7b594132008-08-17 15:24:40 -0500532 goto qc24_target_busy;
Andrew Vasquezfca29702005-07-06 10:31:47 -0700533 }
534
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800535 spin_unlock_irq(vha->host->host_lock);
Andrew Vasquezfca29702005-07-06 10:31:47 -0700536
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800537 sp = qla2x00_get_new_sp(base_vha, fcport, cmd, done);
Andrew Vasquezfca29702005-07-06 10:31:47 -0700538 if (!sp)
539 goto qc24_host_busy_lock;
540
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800541 rval = ha->isp_ops->start_scsi(sp);
Andrew Vasquezfca29702005-07-06 10:31:47 -0700542 if (rval != QLA_SUCCESS)
543 goto qc24_host_busy_free_sp;
544
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800545 spin_lock_irq(vha->host->host_lock);
Andrew Vasquezfca29702005-07-06 10:31:47 -0700546
547 return 0;
548
549qc24_host_busy_free_sp:
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800550 qla2x00_sp_free_dma(sp);
551 mempool_free(sp, ha->srb_mempool);
Andrew Vasquezfca29702005-07-06 10:31:47 -0700552
553qc24_host_busy_lock:
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800554 spin_lock_irq(vha->host->host_lock);
Andrew Vasquezfca29702005-07-06 10:31:47 -0700555 return SCSI_MLQUEUE_HOST_BUSY;
556
Mike Christie7b594132008-08-17 15:24:40 -0500557qc24_target_busy:
558 return SCSI_MLQUEUE_TARGET_BUSY;
559
Andrew Vasquezfca29702005-07-06 10:31:47 -0700560qc24_fail_command:
561 done(cmd);
562
563 return 0;
564}
565
566
Linus Torvalds1da177e2005-04-16 15:20:36 -0700567/*
568 * qla2x00_eh_wait_on_command
569 * Waits for the command to be returned by the Firmware for some
570 * max time.
571 *
572 * Input:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700573 * cmd = Scsi Command to wait on.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700574 *
575 * Return:
576 * Not Found : 0
577 * Found : 1
578 */
579static int
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800580qla2x00_eh_wait_on_command(struct scsi_cmnd *cmd)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700581{
Andrew Vasquezfe74c712005-08-26 19:10:10 -0700582#define ABORT_POLLING_PERIOD 1000
583#define ABORT_WAIT_ITER ((10 * 1000) / (ABORT_POLLING_PERIOD))
f4f051e2005-04-17 15:02:26 -0500584 unsigned long wait_iter = ABORT_WAIT_ITER;
585 int ret = QLA_SUCCESS;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700586
f4f051e2005-04-17 15:02:26 -0500587 while (CMD_SP(cmd)) {
Andrew Vasquezfe74c712005-08-26 19:10:10 -0700588 msleep(ABORT_POLLING_PERIOD);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700589
f4f051e2005-04-17 15:02:26 -0500590 if (--wait_iter)
591 break;
592 }
593 if (CMD_SP(cmd))
594 ret = QLA_FUNCTION_FAILED;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700595
f4f051e2005-04-17 15:02:26 -0500596 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700597}
598
599/*
600 * qla2x00_wait_for_hba_online
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700601 * Wait till the HBA is online after going through
Linus Torvalds1da177e2005-04-16 15:20:36 -0700602 * <= MAX_RETRIES_OF_ISP_ABORT or
603 * finally HBA is disabled ie marked offline
604 *
605 * Input:
606 * ha - pointer to host adapter structure
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700607 *
608 * Note:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700609 * Does context switching-Release SPIN_LOCK
610 * (if any) before calling this routine.
611 *
612 * Return:
613 * Success (Adapter is online) : 0
614 * Failed (Adapter is offline/disabled) : 1
615 */
andrew.vasquez@qlogic.com854165f2006-01-31 16:05:17 -0800616int
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800617qla2x00_wait_for_hba_online(scsi_qla_host_t *vha)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700618{
Andrew Vasquezfca29702005-07-06 10:31:47 -0700619 int return_status;
620 unsigned long wait_online;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800621 struct qla_hw_data *ha = vha->hw;
622 scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700623
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700624 wait_online = jiffies + (MAX_LOOP_TIMEOUT * HZ);
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800625 while (((test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags)) ||
626 test_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags) ||
627 test_bit(ISP_ABORT_RETRY, &base_vha->dpc_flags) ||
628 ha->dpc_active) && time_before(jiffies, wait_online)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700629
630 msleep(1000);
631 }
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800632 if (base_vha->flags.online)
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700633 return_status = QLA_SUCCESS;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700634 else
635 return_status = QLA_FUNCTION_FAILED;
636
Linus Torvalds1da177e2005-04-16 15:20:36 -0700637 return (return_status);
638}
639
640/*
641 * qla2x00_wait_for_loop_ready
642 * Wait for MAX_LOOP_TIMEOUT(5 min) value for loop
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700643 * to be in LOOP_READY state.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700644 * Input:
645 * ha - pointer to host adapter structure
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700646 *
647 * Note:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700648 * Does context switching-Release SPIN_LOCK
649 * (if any) before calling this routine.
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700650 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700651 *
652 * Return:
653 * Success (LOOP_READY) : 0
654 * Failed (LOOP_NOT_READY) : 1
655 */
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700656static inline int
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800657qla2x00_wait_for_loop_ready(scsi_qla_host_t *vha)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700658{
659 int return_status = QLA_SUCCESS;
660 unsigned long loop_timeout ;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800661 struct qla_hw_data *ha = vha->hw;
662 scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700663
664 /* wait for 5 min at the max for loop to be ready */
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700665 loop_timeout = jiffies + (MAX_LOOP_TIMEOUT * HZ);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700666
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800667 while ((!atomic_read(&base_vha->loop_down_timer) &&
668 atomic_read(&base_vha->loop_state) == LOOP_DOWN) ||
669 atomic_read(&base_vha->loop_state) != LOOP_READY) {
670 if (atomic_read(&base_vha->loop_state) == LOOP_DEAD) {
Ravi Anand57680082006-05-17 15:08:44 -0700671 return_status = QLA_FUNCTION_FAILED;
672 break;
673 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700674 msleep(1000);
675 if (time_after_eq(jiffies, loop_timeout)) {
676 return_status = QLA_FUNCTION_FAILED;
677 break;
678 }
679 }
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700680 return (return_status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700681}
682
Seokmann Ju5f3a9a22008-07-10 16:55:47 -0700683void
684qla2x00_abort_fcport_cmds(fc_port_t *fcport)
685{
Anirban Chakraborty73208df2008-12-09 16:45:39 -0800686 int cnt, que, id;
Seokmann Ju5f3a9a22008-07-10 16:55:47 -0700687 unsigned long flags;
688 srb_t *sp;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800689 scsi_qla_host_t *vha = fcport->vha;
690 struct qla_hw_data *ha = vha->hw;
Anirban Chakraborty73208df2008-12-09 16:45:39 -0800691 struct req_que *req;
Seokmann Ju5f3a9a22008-07-10 16:55:47 -0700692
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800693 spin_lock_irqsave(&ha->hardware_lock, flags);
Anirban Chakraborty73208df2008-12-09 16:45:39 -0800694 for (que = 0; que < QLA_MAX_HOST_QUES; que++) {
695 id = vha->req_ques[que];
696 req = ha->req_q_map[id];
697 if (!req)
Seokmann Ju5f3a9a22008-07-10 16:55:47 -0700698 continue;
Anirban Chakraborty73208df2008-12-09 16:45:39 -0800699 for (cnt = 1; cnt < MAX_OUTSTANDING_COMMANDS; cnt++) {
700 sp = req->outstanding_cmds[cnt];
701 if (!sp)
702 continue;
703 if (sp->fcport != fcport)
704 continue;
Seokmann Ju5f3a9a22008-07-10 16:55:47 -0700705
Anirban Chakraborty73208df2008-12-09 16:45:39 -0800706 spin_unlock_irqrestore(&ha->hardware_lock, flags);
707 if (ha->isp_ops->abort_command(vha, sp, req)) {
Seokmann Ju5f3a9a22008-07-10 16:55:47 -0700708 DEBUG2(qla_printk(KERN_WARNING, ha,
Anirban Chakraborty73208df2008-12-09 16:45:39 -0800709 "Abort failed -- %lx\n",
710 sp->cmd->serial_number));
711 } else {
712 if (qla2x00_eh_wait_on_command(sp->cmd) !=
713 QLA_SUCCESS)
714 DEBUG2(qla_printk(KERN_WARNING, ha,
715 "Abort failed while waiting -- %lx\n",
716 sp->cmd->serial_number));
717 }
718 spin_lock_irqsave(&ha->hardware_lock, flags);
Seokmann Ju5f3a9a22008-07-10 16:55:47 -0700719 }
Seokmann Ju5f3a9a22008-07-10 16:55:47 -0700720 }
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800721 spin_unlock_irqrestore(&ha->hardware_lock, flags);
Seokmann Ju5f3a9a22008-07-10 16:55:47 -0700722}
723
Andrew Vasquez07db5182006-10-02 12:00:49 -0700724static void
725qla2x00_block_error_handler(struct scsi_cmnd *cmnd)
726{
727 struct Scsi_Host *shost = cmnd->device->host;
728 struct fc_rport *rport = starget_to_rport(scsi_target(cmnd->device));
729 unsigned long flags;
730
731 spin_lock_irqsave(shost->host_lock, flags);
732 while (rport->port_state == FC_PORTSTATE_BLOCKED) {
733 spin_unlock_irqrestore(shost->host_lock, flags);
734 msleep(1000);
735 spin_lock_irqsave(shost->host_lock, flags);
736 }
737 spin_unlock_irqrestore(shost->host_lock, flags);
738 return;
739}
740
Linus Torvalds1da177e2005-04-16 15:20:36 -0700741/**************************************************************************
742* qla2xxx_eh_abort
743*
744* Description:
745* The abort function will abort the specified command.
746*
747* Input:
748* cmd = Linux SCSI command packet to be aborted.
749*
750* Returns:
751* Either SUCCESS or FAILED.
752*
753* Note:
Michael Reed2ea00202006-04-27 16:25:30 -0700754* Only return FAILED if command not returned by firmware.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700755**************************************************************************/
Adrian Bunke5f82ab2006-11-08 19:55:50 -0800756static int
Linus Torvalds1da177e2005-04-16 15:20:36 -0700757qla2xxx_eh_abort(struct scsi_cmnd *cmd)
758{
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800759 scsi_qla_host_t *vha = shost_priv(cmd->device->host);
f4f051e2005-04-17 15:02:26 -0500760 srb_t *sp;
Anirban Chakraborty17d98632008-12-18 10:06:15 -0800761 int ret, i;
f4f051e2005-04-17 15:02:26 -0500762 unsigned int id, lun;
763 unsigned long serial;
Andrew Vasquez18e144d2005-05-27 15:04:47 -0700764 unsigned long flags;
Michael Reed2ea00202006-04-27 16:25:30 -0700765 int wait = 0;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800766 struct qla_hw_data *ha = vha->hw;
Anirban Chakraborty73208df2008-12-09 16:45:39 -0800767 struct req_que *req;
Anirban Chakraborty17d98632008-12-18 10:06:15 -0800768 srb_t *spt;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700769
Andrew Vasquez07db5182006-10-02 12:00:49 -0700770 qla2x00_block_error_handler(cmd);
771
f4f051e2005-04-17 15:02:26 -0500772 if (!CMD_SP(cmd))
Michael Reed2ea00202006-04-27 16:25:30 -0700773 return SUCCESS;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700774
Michael Reed2ea00202006-04-27 16:25:30 -0700775 ret = SUCCESS;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700776
f4f051e2005-04-17 15:02:26 -0500777 id = cmd->device->id;
778 lun = cmd->device->lun;
779 serial = cmd->serial_number;
Anirban Chakraborty17d98632008-12-18 10:06:15 -0800780 spt = (srb_t *) CMD_SP(cmd);
781 if (!spt)
782 return SUCCESS;
783 req = spt->que;
f4f051e2005-04-17 15:02:26 -0500784
785 /* Check active list for command command. */
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800786 spin_lock_irqsave(&ha->hardware_lock, flags);
Anirban Chakraborty17d98632008-12-18 10:06:15 -0800787 for (i = 1; i < MAX_OUTSTANDING_COMMANDS; i++) {
788 sp = req->outstanding_cmds[i];
789
790 if (sp == NULL)
f4f051e2005-04-17 15:02:26 -0500791 continue;
792
Anirban Chakraborty17d98632008-12-18 10:06:15 -0800793 if (sp->cmd != cmd)
794 continue;
f4f051e2005-04-17 15:02:26 -0500795
Anirban Chakraborty17d98632008-12-18 10:06:15 -0800796 DEBUG2(printk("%s(%ld): aborting sp %p from RISC."
797 " pid=%ld.\n", __func__, vha->host_no, sp, serial));
f4f051e2005-04-17 15:02:26 -0500798
Anirban Chakraborty17d98632008-12-18 10:06:15 -0800799 spin_unlock_irqrestore(&ha->hardware_lock, flags);
800 if (ha->isp_ops->abort_command(vha, sp, req)) {
801 DEBUG2(printk("%s(%ld): abort_command "
802 "mbx failed.\n", __func__, vha->host_no));
803 } else {
804 DEBUG3(printk("%s(%ld): abort_command "
805 "mbx success.\n", __func__, vha->host_no));
806 wait = 1;
f4f051e2005-04-17 15:02:26 -0500807 }
Anirban Chakraborty17d98632008-12-18 10:06:15 -0800808 spin_lock_irqsave(&ha->hardware_lock, flags);
809 break;
f4f051e2005-04-17 15:02:26 -0500810 }
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800811 spin_unlock_irqrestore(&ha->hardware_lock, flags);
f4f051e2005-04-17 15:02:26 -0500812
813 /* Wait for the command to be returned. */
Michael Reed2ea00202006-04-27 16:25:30 -0700814 if (wait) {
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800815 if (qla2x00_eh_wait_on_command(cmd) != QLA_SUCCESS) {
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700816 qla_printk(KERN_ERR, ha,
f4f051e2005-04-17 15:02:26 -0500817 "scsi(%ld:%d:%d): Abort handler timed out -- %lx "
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800818 "%x.\n", vha->host_no, id, lun, serial, ret);
Michael Reed2ea00202006-04-27 16:25:30 -0700819 ret = FAILED;
f4f051e2005-04-17 15:02:26 -0500820 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700821 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700822
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700823 qla_printk(KERN_INFO, ha,
Michael Reed2ea00202006-04-27 16:25:30 -0700824 "scsi(%ld:%d:%d): Abort command issued -- %d %lx %x.\n",
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800825 vha->host_no, id, lun, wait, serial, ret);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700826
f4f051e2005-04-17 15:02:26 -0500827 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700828}
829
Andrew Vasquez523ec772008-04-03 13:13:24 -0700830enum nexus_wait_type {
831 WAIT_HOST = 0,
832 WAIT_TARGET,
833 WAIT_LUN,
834};
835
Linus Torvalds1da177e2005-04-16 15:20:36 -0700836static int
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800837qla2x00_eh_wait_for_pending_commands(scsi_qla_host_t *vha, unsigned int t,
Anirban Chakraborty17d98632008-12-18 10:06:15 -0800838 unsigned int l, srb_t *sp, enum nexus_wait_type type)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700839{
Anirban Chakraborty17d98632008-12-18 10:06:15 -0800840 int cnt, match, status;
Andrew Vasquez18e144d2005-05-27 15:04:47 -0700841 unsigned long flags;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800842 struct qla_hw_data *ha = vha->hw;
Anirban Chakraborty73208df2008-12-09 16:45:39 -0800843 struct req_que *req;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700844
Andrew Vasquez523ec772008-04-03 13:13:24 -0700845 status = QLA_SUCCESS;
Anirban Chakraborty17d98632008-12-18 10:06:15 -0800846 if (!sp)
847 return status;
848
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800849 spin_lock_irqsave(&ha->hardware_lock, flags);
Anirban Chakraborty17d98632008-12-18 10:06:15 -0800850 req = sp->que;
851 for (cnt = 1; status == QLA_SUCCESS &&
852 cnt < MAX_OUTSTANDING_COMMANDS; cnt++) {
853 sp = req->outstanding_cmds[cnt];
854 if (!sp)
Andrew Vasquez523ec772008-04-03 13:13:24 -0700855 continue;
Andrew Vasquez19851f12008-08-13 21:37:00 -0700856
Anirban Chakraborty17d98632008-12-18 10:06:15 -0800857 if (vha->vp_idx != sp->fcport->vha->vp_idx)
858 continue;
859 match = 0;
860 switch (type) {
861 case WAIT_HOST:
862 match = 1;
863 break;
864 case WAIT_TARGET:
865 match = sp->cmd->device->id == t;
866 break;
867 case WAIT_LUN:
868 match = (sp->cmd->device->id == t &&
869 sp->cmd->device->lun == l);
870 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700871 }
Anirban Chakraborty17d98632008-12-18 10:06:15 -0800872 if (!match)
873 continue;
874
875 spin_unlock_irqrestore(&ha->hardware_lock, flags);
876 status = qla2x00_eh_wait_on_command(sp->cmd);
877 spin_lock_irqsave(&ha->hardware_lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700878 }
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800879 spin_unlock_irqrestore(&ha->hardware_lock, flags);
Andrew Vasquez523ec772008-04-03 13:13:24 -0700880
881 return status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700882}
883
Andrew Vasquez523ec772008-04-03 13:13:24 -0700884static char *reset_errors[] = {
885 "HBA not online",
886 "HBA not ready",
887 "Task management failed",
888 "Waiting for command completions",
889};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700890
Andrew Vasquez523ec772008-04-03 13:13:24 -0700891static int
892__qla2xxx_eh_generic_reset(char *name, enum nexus_wait_type type,
893 struct scsi_cmnd *cmd, int (*do_reset)(struct fc_port *, unsigned int))
894{
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800895 scsi_qla_host_t *vha = shost_priv(cmd->device->host);
Andrew Vasquez523ec772008-04-03 13:13:24 -0700896 fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata;
897 int err;
898
899 qla2x00_block_error_handler(cmd);
900
901 if (!fcport)
902 return FAILED;
903
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800904 qla_printk(KERN_INFO, vha->hw, "scsi(%ld:%d:%d): %s RESET ISSUED.\n",
905 vha->host_no, cmd->device->id, cmd->device->lun, name);
Andrew Vasquez523ec772008-04-03 13:13:24 -0700906
907 err = 0;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800908 if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS)
Andrew Vasquez523ec772008-04-03 13:13:24 -0700909 goto eh_reset_failed;
910 err = 1;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800911 if (qla2x00_wait_for_loop_ready(vha) != QLA_SUCCESS)
Andrew Vasquez523ec772008-04-03 13:13:24 -0700912 goto eh_reset_failed;
913 err = 2;
914 if (do_reset(fcport, cmd->device->lun) != QLA_SUCCESS)
915 goto eh_reset_failed;
916 err = 3;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800917 if (qla2x00_eh_wait_for_pending_commands(vha, cmd->device->id,
Anirban Chakraborty17d98632008-12-18 10:06:15 -0800918 cmd->device->lun, (srb_t *) CMD_SP(cmd), type) != QLA_SUCCESS)
Andrew Vasquez523ec772008-04-03 13:13:24 -0700919 goto eh_reset_failed;
920
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800921 qla_printk(KERN_INFO, vha->hw, "scsi(%ld:%d:%d): %s RESET SUCCEEDED.\n",
922 vha->host_no, cmd->device->id, cmd->device->lun, name);
Andrew Vasquez523ec772008-04-03 13:13:24 -0700923
924 return SUCCESS;
925
926 eh_reset_failed:
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800927 qla_printk(KERN_INFO, vha->hw, "scsi(%ld:%d:%d): %s RESET FAILED: %s.\n"
928 , vha->host_no, cmd->device->id, cmd->device->lun, name,
Andrew Vasquez523ec772008-04-03 13:13:24 -0700929 reset_errors[err]);
930 return FAILED;
931}
932
Adrian Bunke5f82ab2006-11-08 19:55:50 -0800933static int
Linus Torvalds1da177e2005-04-16 15:20:36 -0700934qla2xxx_eh_device_reset(struct scsi_cmnd *cmd)
935{
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800936 scsi_qla_host_t *vha = shost_priv(cmd->device->host);
937 struct qla_hw_data *ha = vha->hw;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700938
Andrew Vasquez523ec772008-04-03 13:13:24 -0700939 return __qla2xxx_eh_generic_reset("DEVICE", WAIT_LUN, cmd,
940 ha->isp_ops->lun_reset);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700941}
942
Linus Torvalds1da177e2005-04-16 15:20:36 -0700943static int
Andrew Vasquez523ec772008-04-03 13:13:24 -0700944qla2xxx_eh_target_reset(struct scsi_cmnd *cmd)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700945{
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800946 scsi_qla_host_t *vha = shost_priv(cmd->device->host);
947 struct qla_hw_data *ha = vha->hw;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700948
Andrew Vasquez523ec772008-04-03 13:13:24 -0700949 return __qla2xxx_eh_generic_reset("TARGET", WAIT_TARGET, cmd,
950 ha->isp_ops->target_reset);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700951}
952
Linus Torvalds1da177e2005-04-16 15:20:36 -0700953/**************************************************************************
954* qla2xxx_eh_bus_reset
955*
956* Description:
957* The bus reset function will reset the bus and abort any executing
958* commands.
959*
960* Input:
961* cmd = Linux SCSI command packet of the command that cause the
962* bus reset.
963*
964* Returns:
965* SUCCESS/FAILURE (defined as macro in scsi.h).
966*
967**************************************************************************/
Adrian Bunke5f82ab2006-11-08 19:55:50 -0800968static int
Linus Torvalds1da177e2005-04-16 15:20:36 -0700969qla2xxx_eh_bus_reset(struct scsi_cmnd *cmd)
970{
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800971 scsi_qla_host_t *vha = shost_priv(cmd->device->host);
bdf79622005-04-17 15:06:53 -0500972 fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata;
Seokmann Ju2c3dfe32007-07-05 13:16:51 -0700973 int ret = FAILED;
f4f051e2005-04-17 15:02:26 -0500974 unsigned int id, lun;
975 unsigned long serial;
Anirban Chakraborty17d98632008-12-18 10:06:15 -0800976 srb_t *sp = (srb_t *) CMD_SP(cmd);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700977
Andrew Vasquez07db5182006-10-02 12:00:49 -0700978 qla2x00_block_error_handler(cmd);
979
f4f051e2005-04-17 15:02:26 -0500980 id = cmd->device->id;
981 lun = cmd->device->lun;
982 serial = cmd->serial_number;
983
Vladislav Bolkhovitinb0328be2006-08-01 13:48:15 -0700984 if (!fcport)
f4f051e2005-04-17 15:02:26 -0500985 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700986
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800987 qla_printk(KERN_INFO, vha->hw,
Anirban Chakraborty749af3d2008-11-14 13:48:12 -0800988 "scsi(%ld:%d:%d): BUS RESET ISSUED.\n", vha->host_no, id, lun);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700989
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800990 if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700991 DEBUG2(printk("%s failed:board disabled\n",__func__));
f4f051e2005-04-17 15:02:26 -0500992 goto eh_bus_reset_done;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700993 }
994
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800995 if (qla2x00_wait_for_loop_ready(vha) == QLA_SUCCESS) {
996 if (qla2x00_loop_reset(vha) == QLA_SUCCESS)
f4f051e2005-04-17 15:02:26 -0500997 ret = SUCCESS;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700998 }
f4f051e2005-04-17 15:02:26 -0500999 if (ret == FAILED)
1000 goto eh_bus_reset_done;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001001
Andrew Vasquez9a41a622005-09-20 13:25:53 -07001002 /* Flush outstanding commands. */
Anirban Chakraborty17d98632008-12-18 10:06:15 -08001003 if (qla2x00_eh_wait_for_pending_commands(vha, 0, 0, sp, WAIT_HOST) !=
Andrew Vasquez523ec772008-04-03 13:13:24 -07001004 QLA_SUCCESS)
Andrew Vasquez9a41a622005-09-20 13:25:53 -07001005 ret = FAILED;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001006
f4f051e2005-04-17 15:02:26 -05001007eh_bus_reset_done:
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001008 qla_printk(KERN_INFO, vha->hw, "%s: reset %s\n", __func__,
f4f051e2005-04-17 15:02:26 -05001009 (ret == FAILED) ? "failed" : "succeded");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001010
f4f051e2005-04-17 15:02:26 -05001011 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001012}
1013
1014/**************************************************************************
1015* qla2xxx_eh_host_reset
1016*
1017* Description:
1018* The reset function will reset the Adapter.
1019*
1020* Input:
1021* cmd = Linux SCSI command packet of the command that cause the
1022* adapter reset.
1023*
1024* Returns:
1025* Either SUCCESS or FAILED.
1026*
1027* Note:
1028**************************************************************************/
Adrian Bunke5f82ab2006-11-08 19:55:50 -08001029static int
Linus Torvalds1da177e2005-04-16 15:20:36 -07001030qla2xxx_eh_host_reset(struct scsi_cmnd *cmd)
1031{
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001032 scsi_qla_host_t *vha = shost_priv(cmd->device->host);
bdf79622005-04-17 15:06:53 -05001033 fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001034 struct qla_hw_data *ha = vha->hw;
Seokmann Ju2c3dfe32007-07-05 13:16:51 -07001035 int ret = FAILED;
f4f051e2005-04-17 15:02:26 -05001036 unsigned int id, lun;
1037 unsigned long serial;
Anirban Chakraborty17d98632008-12-18 10:06:15 -08001038 srb_t *sp = (srb_t *) CMD_SP(cmd);
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001039 scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001040
Andrew Vasquez07db5182006-10-02 12:00:49 -07001041 qla2x00_block_error_handler(cmd);
1042
f4f051e2005-04-17 15:02:26 -05001043 id = cmd->device->id;
1044 lun = cmd->device->lun;
1045 serial = cmd->serial_number;
1046
Vladislav Bolkhovitinb0328be2006-08-01 13:48:15 -07001047 if (!fcport)
f4f051e2005-04-17 15:02:26 -05001048 return ret;
1049
Linus Torvalds1da177e2005-04-16 15:20:36 -07001050 qla_printk(KERN_INFO, ha,
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001051 "scsi(%ld:%d:%d): ADAPTER RESET ISSUED.\n", vha->host_no, id, lun);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001052
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001053 if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS)
f4f051e2005-04-17 15:02:26 -05001054 goto eh_host_reset_lock;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001055
1056 /*
1057 * Fixme-may be dpc thread is active and processing
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -07001058 * loop_resync,so wait a while for it to
Linus Torvalds1da177e2005-04-16 15:20:36 -07001059 * be completed and then issue big hammer.Otherwise
1060 * it may cause I/O failure as big hammer marks the
1061 * devices as lost kicking of the port_down_timer
1062 * while dpc is stuck for the mailbox to complete.
1063 */
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001064 qla2x00_wait_for_loop_ready(vha);
1065 if (vha != base_vha) {
1066 if (qla2x00_vp_abort_isp(vha))
f4f051e2005-04-17 15:02:26 -05001067 goto eh_host_reset_lock;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001068 } else {
1069 set_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags);
1070 if (qla2x00_abort_isp(base_vha)) {
1071 clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags);
1072 /* failed. schedule dpc to try */
1073 set_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags);
1074
1075 if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS)
1076 goto eh_host_reset_lock;
1077 }
1078 clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags);
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -07001079 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001080
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001081 /* Waiting for command to be returned to OS.*/
Anirban Chakraborty17d98632008-12-18 10:06:15 -08001082 if (qla2x00_eh_wait_for_pending_commands(vha, 0, 0, sp, WAIT_HOST) ==
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001083 QLA_SUCCESS)
f4f051e2005-04-17 15:02:26 -05001084 ret = SUCCESS;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001085
f4f051e2005-04-17 15:02:26 -05001086eh_host_reset_lock:
f4f051e2005-04-17 15:02:26 -05001087 qla_printk(KERN_INFO, ha, "%s: reset %s\n", __func__,
1088 (ret == FAILED) ? "failed" : "succeded");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001089
f4f051e2005-04-17 15:02:26 -05001090 return ret;
1091}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001092
1093/*
1094* qla2x00_loop_reset
1095* Issue loop reset.
1096*
1097* Input:
1098* ha = adapter block pointer.
1099*
1100* Returns:
1101* 0 = success
1102*/
Andrew Vasqueza4722cf2008-01-17 09:02:12 -08001103int
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001104qla2x00_loop_reset(scsi_qla_host_t *vha)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001105{
Andrew Vasquez0c8c39a2006-12-13 19:20:30 -08001106 int ret;
bdf79622005-04-17 15:06:53 -05001107 struct fc_port *fcport;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001108 struct qla_hw_data *ha = vha->hw;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001109
Anirban Chakraborty749af3d2008-11-14 13:48:12 -08001110 if (ha->flags.enable_lip_full_login && !vha->vp_idx) {
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001111 ret = qla2x00_full_login_lip(vha);
Andrew Vasquez0c8c39a2006-12-13 19:20:30 -08001112 if (ret != QLA_SUCCESS) {
Anirban Chakraborty749af3d2008-11-14 13:48:12 -08001113 DEBUG2_3(printk("%s(%ld): failed: "
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001114 "full_login_lip=%d.\n", __func__, vha->host_no,
Andrew Vasquez0c8c39a2006-12-13 19:20:30 -08001115 ret));
Anirban Chakraborty749af3d2008-11-14 13:48:12 -08001116 }
1117 atomic_set(&vha->loop_state, LOOP_DOWN);
1118 atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME);
1119 qla2x00_mark_all_devices_lost(vha, 0);
1120 qla2x00_wait_for_loop_ready(vha);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001121 }
1122
Anirban Chakraborty749af3d2008-11-14 13:48:12 -08001123 if (ha->flags.enable_lip_reset && !vha->vp_idx) {
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001124 ret = qla2x00_lip_reset(vha);
Andrew Vasquez0c8c39a2006-12-13 19:20:30 -08001125 if (ret != QLA_SUCCESS) {
Anirban Chakraborty749af3d2008-11-14 13:48:12 -08001126 DEBUG2_3(printk("%s(%ld): failed: "
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001127 "lip_reset=%d.\n", __func__, vha->host_no, ret));
1128 } else
1129 qla2x00_wait_for_loop_ready(vha);
Andrew Vasquez0c8c39a2006-12-13 19:20:30 -08001130 }
1131
1132 if (ha->flags.enable_target_reset) {
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001133 list_for_each_entry(fcport, &vha->vp_fcports, list) {
bdf79622005-04-17 15:06:53 -05001134 if (fcport->port_type != FCT_TARGET)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001135 continue;
1136
Andrew Vasquez523ec772008-04-03 13:13:24 -07001137 ret = ha->isp_ops->target_reset(fcport, 0);
Andrew Vasquez0c8c39a2006-12-13 19:20:30 -08001138 if (ret != QLA_SUCCESS) {
1139 DEBUG2_3(printk("%s(%ld): bus_reset failed: "
1140 "target_reset=%d d_id=%x.\n", __func__,
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001141 vha->host_no, ret, fcport->d_id.b24));
Andrew Vasquez0c8c39a2006-12-13 19:20:30 -08001142 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001143 }
1144 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001145 /* Issue marker command only when we are going to start the I/O */
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001146 vha->marker_needed = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001147
Andrew Vasquez0c8c39a2006-12-13 19:20:30 -08001148 return QLA_SUCCESS;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001149}
1150
Andrew Vasquezdf4bf0b2008-01-31 12:33:46 -08001151void
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001152qla2x00_abort_all_cmds(scsi_qla_host_t *vha, int res)
Andrew Vasquezdf4bf0b2008-01-31 12:33:46 -08001153{
Anirban Chakraborty73208df2008-12-09 16:45:39 -08001154 int que, cnt;
Andrew Vasquezdf4bf0b2008-01-31 12:33:46 -08001155 unsigned long flags;
1156 srb_t *sp;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001157 struct qla_hw_data *ha = vha->hw;
Anirban Chakraborty73208df2008-12-09 16:45:39 -08001158 struct req_que *req;
Andrew Vasquezdf4bf0b2008-01-31 12:33:46 -08001159
1160 spin_lock_irqsave(&ha->hardware_lock, flags);
Anirban Chakraborty29bdccb2009-01-08 15:41:08 -08001161 for (que = 0; que < ha->max_queues; que++) {
1162 req = ha->req_q_map[que];
Anirban Chakraborty73208df2008-12-09 16:45:39 -08001163 if (!req)
1164 continue;
1165 for (cnt = 1; cnt < MAX_OUTSTANDING_COMMANDS; cnt++) {
1166 sp = req->outstanding_cmds[cnt];
Andrew Vasquez444786d2009-01-05 11:18:10 -08001167 if (sp && sp->fcport->vha == vha) {
Anirban Chakraborty73208df2008-12-09 16:45:39 -08001168 req->outstanding_cmds[cnt] = NULL;
1169 sp->cmd->result = res;
1170 qla2x00_sp_compl(ha, sp);
1171 }
Andrew Vasquezdf4bf0b2008-01-31 12:33:46 -08001172 }
1173 }
1174 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1175}
1176
f4f051e2005-04-17 15:02:26 -05001177static int
1178qla2xxx_slave_alloc(struct scsi_device *sdev)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001179{
bdf79622005-04-17 15:06:53 -05001180 struct fc_rport *rport = starget_to_rport(scsi_target(sdev));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001181
James.Smart@Emulex.Com19a7b4a2005-10-18 12:03:35 -04001182 if (!rport || fc_remote_port_chkready(rport))
f4f051e2005-04-17 15:02:26 -05001183 return -ENXIO;
1184
James.Smart@Emulex.Com19a7b4a2005-10-18 12:03:35 -04001185 sdev->hostdata = *(fc_port_t **)rport->dd_data;
f4f051e2005-04-17 15:02:26 -05001186
1187 return 0;
1188}
1189
1190static int
1191qla2xxx_slave_configure(struct scsi_device *sdev)
1192{
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001193 scsi_qla_host_t *vha = shost_priv(sdev->host);
1194 struct qla_hw_data *ha = vha->hw;
8482e1182005-04-17 15:04:54 -05001195 struct fc_rport *rport = starget_to_rport(sdev->sdev_target);
Anirban Chakraborty29bdccb2009-01-08 15:41:08 -08001196 struct req_que *req = ha->req_q_map[vha->req_ques[0]];
8482e1182005-04-17 15:04:54 -05001197
f4f051e2005-04-17 15:02:26 -05001198 if (sdev->tagged_supported)
Anirban Chakraborty73208df2008-12-09 16:45:39 -08001199 scsi_activate_tcq(sdev, req->max_q_depth);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001200 else
Anirban Chakraborty73208df2008-12-09 16:45:39 -08001201 scsi_deactivate_tcq(sdev, req->max_q_depth);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001202
Andrew Vasquez85821c92008-07-10 16:55:48 -07001203 rport->dev_loss_tmo = ha->port_down_retry_count;
8482e1182005-04-17 15:04:54 -05001204
f4f051e2005-04-17 15:02:26 -05001205 return 0;
1206}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001207
f4f051e2005-04-17 15:02:26 -05001208static void
1209qla2xxx_slave_destroy(struct scsi_device *sdev)
1210{
1211 sdev->hostdata = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001212}
1213
Andrew Vasquezce7e4af2005-08-26 19:09:30 -07001214static int
1215qla2x00_change_queue_depth(struct scsi_device *sdev, int qdepth)
1216{
1217 scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), qdepth);
1218 return sdev->queue_depth;
1219}
1220
1221static int
1222qla2x00_change_queue_type(struct scsi_device *sdev, int tag_type)
1223{
1224 if (sdev->tagged_supported) {
1225 scsi_set_tag_type(sdev, tag_type);
1226 if (tag_type)
1227 scsi_activate_tcq(sdev, sdev->queue_depth);
1228 else
1229 scsi_deactivate_tcq(sdev, sdev->queue_depth);
1230 } else
1231 tag_type = 0;
1232
1233 return tag_type;
1234}
1235
Linus Torvalds1da177e2005-04-16 15:20:36 -07001236/**
1237 * qla2x00_config_dma_addressing() - Configure OS DMA addressing method.
1238 * @ha: HA context
1239 *
1240 * At exit, the @ha's flags.enable_64bit_addressing set to indicated
1241 * supported addressing method.
1242 */
1243static void
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001244qla2x00_config_dma_addressing(scsi_qla_host_t *vha)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001245{
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001246 struct qla_hw_data *ha = vha->hw;
Andrew Vasquez7524f9b2005-08-26 19:08:00 -07001247 /* Assume a 32bit DMA mask. */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001248 ha->flags.enable_64bit_addressing = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001249
Andrew Vasquez7524f9b2005-08-26 19:08:00 -07001250 if (!dma_set_mask(&ha->pdev->dev, DMA_64BIT_MASK)) {
1251 /* Any upper-dword bits set? */
1252 if (MSD(dma_get_required_mask(&ha->pdev->dev)) &&
1253 !pci_set_consistent_dma_mask(ha->pdev, DMA_64BIT_MASK)) {
1254 /* Ok, a 64bit DMA mask is applicable. */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001255 ha->flags.enable_64bit_addressing = 1;
Andrew Vasquezfd34f552007-07-19 15:06:00 -07001256 ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
1257 ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
Andrew Vasquez7524f9b2005-08-26 19:08:00 -07001258 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001259 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001260 }
Andrew Vasquez7524f9b2005-08-26 19:08:00 -07001261
1262 dma_set_mask(&ha->pdev->dev, DMA_32BIT_MASK);
1263 pci_set_consistent_dma_mask(ha->pdev, DMA_32BIT_MASK);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001264}
1265
Andrew Vasquezfd34f552007-07-19 15:06:00 -07001266static void
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001267qla2x00_enable_intrs(struct qla_hw_data *ha)
Andrew Vasquezfd34f552007-07-19 15:06:00 -07001268{
1269 unsigned long flags = 0;
1270 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
1271
1272 spin_lock_irqsave(&ha->hardware_lock, flags);
1273 ha->interrupts_on = 1;
1274 /* enable risc and host interrupts */
1275 WRT_REG_WORD(&reg->ictrl, ICR_EN_INT | ICR_EN_RISC);
1276 RD_REG_WORD(&reg->ictrl);
1277 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1278
1279}
1280
1281static void
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001282qla2x00_disable_intrs(struct qla_hw_data *ha)
Andrew Vasquezfd34f552007-07-19 15:06:00 -07001283{
1284 unsigned long flags = 0;
1285 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
1286
1287 spin_lock_irqsave(&ha->hardware_lock, flags);
1288 ha->interrupts_on = 0;
1289 /* disable risc and host interrupts */
1290 WRT_REG_WORD(&reg->ictrl, 0);
1291 RD_REG_WORD(&reg->ictrl);
1292 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1293}
1294
1295static void
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001296qla24xx_enable_intrs(struct qla_hw_data *ha)
Andrew Vasquezfd34f552007-07-19 15:06:00 -07001297{
1298 unsigned long flags = 0;
1299 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
1300
1301 spin_lock_irqsave(&ha->hardware_lock, flags);
1302 ha->interrupts_on = 1;
1303 WRT_REG_DWORD(&reg->ictrl, ICRX_EN_RISC_INT);
1304 RD_REG_DWORD(&reg->ictrl);
1305 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1306}
1307
1308static void
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001309qla24xx_disable_intrs(struct qla_hw_data *ha)
Andrew Vasquezfd34f552007-07-19 15:06:00 -07001310{
1311 unsigned long flags = 0;
1312 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
1313
Andrew Vasquez124f85e2009-01-05 11:18:06 -08001314 if (IS_NOPOLLING_TYPE(ha))
1315 return;
Andrew Vasquezfd34f552007-07-19 15:06:00 -07001316 spin_lock_irqsave(&ha->hardware_lock, flags);
1317 ha->interrupts_on = 0;
1318 WRT_REG_DWORD(&reg->ictrl, 0);
1319 RD_REG_DWORD(&reg->ictrl);
1320 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1321}
1322
1323static struct isp_operations qla2100_isp_ops = {
1324 .pci_config = qla2100_pci_config,
1325 .reset_chip = qla2x00_reset_chip,
1326 .chip_diag = qla2x00_chip_diag,
1327 .config_rings = qla2x00_config_rings,
1328 .reset_adapter = qla2x00_reset_adapter,
1329 .nvram_config = qla2x00_nvram_config,
1330 .update_fw_options = qla2x00_update_fw_options,
1331 .load_risc = qla2x00_load_risc,
1332 .pci_info_str = qla2x00_pci_info_str,
1333 .fw_version_str = qla2x00_fw_version_str,
1334 .intr_handler = qla2100_intr_handler,
1335 .enable_intrs = qla2x00_enable_intrs,
1336 .disable_intrs = qla2x00_disable_intrs,
1337 .abort_command = qla2x00_abort_command,
Andrew Vasquez523ec772008-04-03 13:13:24 -07001338 .target_reset = qla2x00_abort_target,
1339 .lun_reset = qla2x00_lun_reset,
Andrew Vasquezfd34f552007-07-19 15:06:00 -07001340 .fabric_login = qla2x00_login_fabric,
1341 .fabric_logout = qla2x00_fabric_logout,
1342 .calc_req_entries = qla2x00_calc_iocbs_32,
1343 .build_iocbs = qla2x00_build_scsi_iocbs_32,
1344 .prep_ms_iocb = qla2x00_prep_ms_iocb,
1345 .prep_ms_fdmi_iocb = qla2x00_prep_ms_fdmi_iocb,
1346 .read_nvram = qla2x00_read_nvram_data,
1347 .write_nvram = qla2x00_write_nvram_data,
1348 .fw_dump = qla2100_fw_dump,
1349 .beacon_on = NULL,
1350 .beacon_off = NULL,
1351 .beacon_blink = NULL,
1352 .read_optrom = qla2x00_read_optrom_data,
1353 .write_optrom = qla2x00_write_optrom_data,
1354 .get_flash_version = qla2x00_get_flash_version,
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001355 .start_scsi = qla2x00_start_scsi,
Anirban Chakraborty17d98632008-12-18 10:06:15 -08001356 .wrt_req_reg = NULL,
1357 .wrt_rsp_reg = NULL,
1358 .rd_req_reg = NULL,
Andrew Vasquezfd34f552007-07-19 15:06:00 -07001359};
1360
1361static struct isp_operations qla2300_isp_ops = {
1362 .pci_config = qla2300_pci_config,
1363 .reset_chip = qla2x00_reset_chip,
1364 .chip_diag = qla2x00_chip_diag,
1365 .config_rings = qla2x00_config_rings,
1366 .reset_adapter = qla2x00_reset_adapter,
1367 .nvram_config = qla2x00_nvram_config,
1368 .update_fw_options = qla2x00_update_fw_options,
1369 .load_risc = qla2x00_load_risc,
1370 .pci_info_str = qla2x00_pci_info_str,
1371 .fw_version_str = qla2x00_fw_version_str,
1372 .intr_handler = qla2300_intr_handler,
1373 .enable_intrs = qla2x00_enable_intrs,
1374 .disable_intrs = qla2x00_disable_intrs,
1375 .abort_command = qla2x00_abort_command,
Andrew Vasquez523ec772008-04-03 13:13:24 -07001376 .target_reset = qla2x00_abort_target,
1377 .lun_reset = qla2x00_lun_reset,
Andrew Vasquezfd34f552007-07-19 15:06:00 -07001378 .fabric_login = qla2x00_login_fabric,
1379 .fabric_logout = qla2x00_fabric_logout,
1380 .calc_req_entries = qla2x00_calc_iocbs_32,
1381 .build_iocbs = qla2x00_build_scsi_iocbs_32,
1382 .prep_ms_iocb = qla2x00_prep_ms_iocb,
1383 .prep_ms_fdmi_iocb = qla2x00_prep_ms_fdmi_iocb,
1384 .read_nvram = qla2x00_read_nvram_data,
1385 .write_nvram = qla2x00_write_nvram_data,
1386 .fw_dump = qla2300_fw_dump,
1387 .beacon_on = qla2x00_beacon_on,
1388 .beacon_off = qla2x00_beacon_off,
1389 .beacon_blink = qla2x00_beacon_blink,
1390 .read_optrom = qla2x00_read_optrom_data,
1391 .write_optrom = qla2x00_write_optrom_data,
1392 .get_flash_version = qla2x00_get_flash_version,
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001393 .start_scsi = qla2x00_start_scsi,
Anirban Chakraborty17d98632008-12-18 10:06:15 -08001394 .wrt_req_reg = NULL,
1395 .wrt_rsp_reg = NULL,
1396 .rd_req_reg = NULL,
Andrew Vasquezfd34f552007-07-19 15:06:00 -07001397};
1398
1399static struct isp_operations qla24xx_isp_ops = {
1400 .pci_config = qla24xx_pci_config,
1401 .reset_chip = qla24xx_reset_chip,
1402 .chip_diag = qla24xx_chip_diag,
1403 .config_rings = qla24xx_config_rings,
1404 .reset_adapter = qla24xx_reset_adapter,
1405 .nvram_config = qla24xx_nvram_config,
1406 .update_fw_options = qla24xx_update_fw_options,
1407 .load_risc = qla24xx_load_risc,
1408 .pci_info_str = qla24xx_pci_info_str,
1409 .fw_version_str = qla24xx_fw_version_str,
1410 .intr_handler = qla24xx_intr_handler,
1411 .enable_intrs = qla24xx_enable_intrs,
1412 .disable_intrs = qla24xx_disable_intrs,
1413 .abort_command = qla24xx_abort_command,
Andrew Vasquez523ec772008-04-03 13:13:24 -07001414 .target_reset = qla24xx_abort_target,
1415 .lun_reset = qla24xx_lun_reset,
Andrew Vasquezfd34f552007-07-19 15:06:00 -07001416 .fabric_login = qla24xx_login_fabric,
1417 .fabric_logout = qla24xx_fabric_logout,
1418 .calc_req_entries = NULL,
1419 .build_iocbs = NULL,
1420 .prep_ms_iocb = qla24xx_prep_ms_iocb,
1421 .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb,
1422 .read_nvram = qla24xx_read_nvram_data,
1423 .write_nvram = qla24xx_write_nvram_data,
1424 .fw_dump = qla24xx_fw_dump,
1425 .beacon_on = qla24xx_beacon_on,
1426 .beacon_off = qla24xx_beacon_off,
1427 .beacon_blink = qla24xx_beacon_blink,
1428 .read_optrom = qla24xx_read_optrom_data,
1429 .write_optrom = qla24xx_write_optrom_data,
1430 .get_flash_version = qla24xx_get_flash_version,
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001431 .start_scsi = qla24xx_start_scsi,
Anirban Chakraborty17d98632008-12-18 10:06:15 -08001432 .wrt_req_reg = qla24xx_wrt_req_reg,
1433 .wrt_rsp_reg = qla24xx_wrt_rsp_reg,
1434 .rd_req_reg = qla24xx_rd_req_reg,
Andrew Vasquezfd34f552007-07-19 15:06:00 -07001435};
1436
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001437static struct isp_operations qla25xx_isp_ops = {
1438 .pci_config = qla25xx_pci_config,
1439 .reset_chip = qla24xx_reset_chip,
1440 .chip_diag = qla24xx_chip_diag,
1441 .config_rings = qla24xx_config_rings,
1442 .reset_adapter = qla24xx_reset_adapter,
1443 .nvram_config = qla24xx_nvram_config,
1444 .update_fw_options = qla24xx_update_fw_options,
1445 .load_risc = qla24xx_load_risc,
1446 .pci_info_str = qla24xx_pci_info_str,
1447 .fw_version_str = qla24xx_fw_version_str,
1448 .intr_handler = qla24xx_intr_handler,
1449 .enable_intrs = qla24xx_enable_intrs,
1450 .disable_intrs = qla24xx_disable_intrs,
1451 .abort_command = qla24xx_abort_command,
Andrew Vasquez523ec772008-04-03 13:13:24 -07001452 .target_reset = qla24xx_abort_target,
1453 .lun_reset = qla24xx_lun_reset,
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001454 .fabric_login = qla24xx_login_fabric,
1455 .fabric_logout = qla24xx_fabric_logout,
1456 .calc_req_entries = NULL,
1457 .build_iocbs = NULL,
1458 .prep_ms_iocb = qla24xx_prep_ms_iocb,
1459 .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb,
1460 .read_nvram = qla25xx_read_nvram_data,
1461 .write_nvram = qla25xx_write_nvram_data,
1462 .fw_dump = qla25xx_fw_dump,
1463 .beacon_on = qla24xx_beacon_on,
1464 .beacon_off = qla24xx_beacon_off,
1465 .beacon_blink = qla24xx_beacon_blink,
Andrew Vasquez338c9162007-09-20 14:07:33 -07001466 .read_optrom = qla25xx_read_optrom_data,
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001467 .write_optrom = qla24xx_write_optrom_data,
1468 .get_flash_version = qla24xx_get_flash_version,
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001469 .start_scsi = qla24xx_start_scsi,
Anirban Chakraborty17d98632008-12-18 10:06:15 -08001470 .wrt_req_reg = qla24xx_wrt_req_reg,
1471 .wrt_rsp_reg = qla24xx_wrt_rsp_reg,
1472 .rd_req_reg = qla24xx_rd_req_reg,
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001473};
1474
Andrew Vasquez3a03eb72009-01-05 11:18:11 -08001475static struct isp_operations qla81xx_isp_ops = {
1476 .pci_config = qla25xx_pci_config,
1477 .reset_chip = qla24xx_reset_chip,
1478 .chip_diag = qla24xx_chip_diag,
1479 .config_rings = qla24xx_config_rings,
1480 .reset_adapter = qla24xx_reset_adapter,
1481 .nvram_config = qla81xx_nvram_config,
1482 .update_fw_options = qla81xx_update_fw_options,
1483 .load_risc = qla24xx_load_risc,
1484 .pci_info_str = qla24xx_pci_info_str,
1485 .fw_version_str = qla24xx_fw_version_str,
1486 .intr_handler = qla24xx_intr_handler,
1487 .enable_intrs = qla24xx_enable_intrs,
1488 .disable_intrs = qla24xx_disable_intrs,
1489 .abort_command = qla24xx_abort_command,
1490 .target_reset = qla24xx_abort_target,
1491 .lun_reset = qla24xx_lun_reset,
1492 .fabric_login = qla24xx_login_fabric,
1493 .fabric_logout = qla24xx_fabric_logout,
1494 .calc_req_entries = NULL,
1495 .build_iocbs = NULL,
1496 .prep_ms_iocb = qla24xx_prep_ms_iocb,
1497 .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb,
1498 .read_nvram = qla25xx_read_nvram_data,
1499 .write_nvram = qla25xx_write_nvram_data,
1500 .fw_dump = qla81xx_fw_dump,
1501 .beacon_on = qla24xx_beacon_on,
1502 .beacon_off = qla24xx_beacon_off,
1503 .beacon_blink = qla24xx_beacon_blink,
1504 .read_optrom = qla25xx_read_optrom_data,
1505 .write_optrom = qla24xx_write_optrom_data,
1506 .get_flash_version = qla24xx_get_flash_version,
1507 .start_scsi = qla24xx_start_scsi,
1508 .wrt_req_reg = qla24xx_wrt_req_reg,
1509 .wrt_rsp_reg = qla24xx_wrt_rsp_reg,
1510 .rd_req_reg = qla24xx_rd_req_reg,
1511};
1512
andrew.vasquez@qlogic.comea5b6382006-03-09 14:27:08 -08001513static inline void
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001514qla2x00_set_isp_flags(struct qla_hw_data *ha)
andrew.vasquez@qlogic.comea5b6382006-03-09 14:27:08 -08001515{
1516 ha->device_type = DT_EXTENDED_IDS;
1517 switch (ha->pdev->device) {
1518 case PCI_DEVICE_ID_QLOGIC_ISP2100:
1519 ha->device_type |= DT_ISP2100;
1520 ha->device_type &= ~DT_EXTENDED_IDS;
Andrew Vasquez441d1072006-05-17 15:09:34 -07001521 ha->fw_srisc_address = RISC_START_ADDRESS_2100;
andrew.vasquez@qlogic.comea5b6382006-03-09 14:27:08 -08001522 break;
1523 case PCI_DEVICE_ID_QLOGIC_ISP2200:
1524 ha->device_type |= DT_ISP2200;
1525 ha->device_type &= ~DT_EXTENDED_IDS;
Andrew Vasquez441d1072006-05-17 15:09:34 -07001526 ha->fw_srisc_address = RISC_START_ADDRESS_2100;
andrew.vasquez@qlogic.comea5b6382006-03-09 14:27:08 -08001527 break;
1528 case PCI_DEVICE_ID_QLOGIC_ISP2300:
1529 ha->device_type |= DT_ISP2300;
andrew.vasquez@qlogic.com4a59f712006-03-09 14:27:39 -08001530 ha->device_type |= DT_ZIO_SUPPORTED;
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_ISP2312:
1534 ha->device_type |= DT_ISP2312;
andrew.vasquez@qlogic.com4a59f712006-03-09 14:27:39 -08001535 ha->device_type |= DT_ZIO_SUPPORTED;
Andrew Vasquez441d1072006-05-17 15:09:34 -07001536 ha->fw_srisc_address = RISC_START_ADDRESS_2300;
andrew.vasquez@qlogic.comea5b6382006-03-09 14:27:08 -08001537 break;
1538 case PCI_DEVICE_ID_QLOGIC_ISP2322:
1539 ha->device_type |= DT_ISP2322;
andrew.vasquez@qlogic.com4a59f712006-03-09 14:27:39 -08001540 ha->device_type |= DT_ZIO_SUPPORTED;
andrew.vasquez@qlogic.comea5b6382006-03-09 14:27:08 -08001541 if (ha->pdev->subsystem_vendor == 0x1028 &&
1542 ha->pdev->subsystem_device == 0x0170)
1543 ha->device_type |= DT_OEM_001;
Andrew Vasquez441d1072006-05-17 15:09:34 -07001544 ha->fw_srisc_address = RISC_START_ADDRESS_2300;
andrew.vasquez@qlogic.comea5b6382006-03-09 14:27:08 -08001545 break;
1546 case PCI_DEVICE_ID_QLOGIC_ISP6312:
1547 ha->device_type |= DT_ISP6312;
Andrew Vasquez441d1072006-05-17 15:09:34 -07001548 ha->fw_srisc_address = RISC_START_ADDRESS_2300;
andrew.vasquez@qlogic.comea5b6382006-03-09 14:27:08 -08001549 break;
1550 case PCI_DEVICE_ID_QLOGIC_ISP6322:
1551 ha->device_type |= DT_ISP6322;
Andrew Vasquez441d1072006-05-17 15:09:34 -07001552 ha->fw_srisc_address = RISC_START_ADDRESS_2300;
andrew.vasquez@qlogic.comea5b6382006-03-09 14:27:08 -08001553 break;
1554 case PCI_DEVICE_ID_QLOGIC_ISP2422:
1555 ha->device_type |= DT_ISP2422;
andrew.vasquez@qlogic.com4a59f712006-03-09 14:27:39 -08001556 ha->device_type |= DT_ZIO_SUPPORTED;
Andrew Vasqueze4289242007-07-19 15:05:56 -07001557 ha->device_type |= DT_FWI2;
Andrew Vasquezc76f2c02007-07-19 15:05:57 -07001558 ha->device_type |= DT_IIDMA;
Andrew Vasquez441d1072006-05-17 15:09:34 -07001559 ha->fw_srisc_address = RISC_START_ADDRESS_2400;
andrew.vasquez@qlogic.comea5b6382006-03-09 14:27:08 -08001560 break;
1561 case PCI_DEVICE_ID_QLOGIC_ISP2432:
1562 ha->device_type |= DT_ISP2432;
andrew.vasquez@qlogic.com4a59f712006-03-09 14:27:39 -08001563 ha->device_type |= DT_ZIO_SUPPORTED;
Andrew Vasqueze4289242007-07-19 15:05:56 -07001564 ha->device_type |= DT_FWI2;
Andrew Vasquezc76f2c02007-07-19 15:05:57 -07001565 ha->device_type |= DT_IIDMA;
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;
Harihara Kadayam4d4df192008-04-03 13:13:26 -07001568 case PCI_DEVICE_ID_QLOGIC_ISP8432:
1569 ha->device_type |= DT_ISP8432;
1570 ha->device_type |= DT_ZIO_SUPPORTED;
1571 ha->device_type |= DT_FWI2;
1572 ha->device_type |= DT_IIDMA;
1573 ha->fw_srisc_address = RISC_START_ADDRESS_2400;
1574 break;
andrew.vasquez@qlogic.com044cc6c2006-03-09 14:27:13 -08001575 case PCI_DEVICE_ID_QLOGIC_ISP5422:
1576 ha->device_type |= DT_ISP5422;
Andrew Vasqueze4289242007-07-19 15:05:56 -07001577 ha->device_type |= DT_FWI2;
Andrew Vasquez441d1072006-05-17 15:09:34 -07001578 ha->fw_srisc_address = RISC_START_ADDRESS_2400;
andrew.vasquez@qlogic.comea5b6382006-03-09 14:27:08 -08001579 break;
andrew.vasquez@qlogic.com044cc6c2006-03-09 14:27:13 -08001580 case PCI_DEVICE_ID_QLOGIC_ISP5432:
1581 ha->device_type |= DT_ISP5432;
Andrew Vasqueze4289242007-07-19 15:05:56 -07001582 ha->device_type |= DT_FWI2;
Andrew Vasquez441d1072006-05-17 15:09:34 -07001583 ha->fw_srisc_address = RISC_START_ADDRESS_2400;
andrew.vasquez@qlogic.comea5b6382006-03-09 14:27:08 -08001584 break;
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001585 case PCI_DEVICE_ID_QLOGIC_ISP2532:
1586 ha->device_type |= DT_ISP2532;
1587 ha->device_type |= DT_ZIO_SUPPORTED;
1588 ha->device_type |= DT_FWI2;
1589 ha->device_type |= DT_IIDMA;
andrew.vasquez@qlogic.comea5b6382006-03-09 14:27:08 -08001590 ha->fw_srisc_address = RISC_START_ADDRESS_2400;
1591 break;
Andrew Vasquez3a03eb72009-01-05 11:18:11 -08001592 case PCI_DEVICE_ID_QLOGIC_ISP8001:
1593 ha->device_type |= DT_ISP8001;
1594 ha->device_type |= DT_ZIO_SUPPORTED;
1595 ha->device_type |= DT_FWI2;
1596 ha->device_type |= DT_IIDMA;
1597 ha->fw_srisc_address = RISC_START_ADDRESS_2400;
1598 break;
andrew.vasquez@qlogic.comea5b6382006-03-09 14:27:08 -08001599 }
1600}
1601
Linus Torvalds1da177e2005-04-16 15:20:36 -07001602static int
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001603qla2x00_iospace_config(struct qla_hw_data *ha)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001604{
Andrew Vasquez37765412008-01-17 09:02:09 -08001605 resource_size_t pio;
Anirban Chakraborty73208df2008-12-09 16:45:39 -08001606 uint16_t msix;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001607
Andrew Vasquez285d0322007-10-19 15:59:17 -07001608 if (pci_request_selected_regions(ha->pdev, ha->bars,
1609 QLA2XXX_DRIVER_NAME)) {
1610 qla_printk(KERN_WARNING, ha,
1611 "Failed to reserve PIO/MMIO regions (%s)\n",
1612 pci_name(ha->pdev));
1613
1614 goto iospace_error_exit;
1615 }
1616 if (!(ha->bars & 1))
1617 goto skip_pio;
1618
Linus Torvalds1da177e2005-04-16 15:20:36 -07001619 /* We only need PIO for Flash operations on ISP2312 v2 chips. */
1620 pio = pci_resource_start(ha->pdev, 0);
Andrew Vasquez37765412008-01-17 09:02:09 -08001621 if (pci_resource_flags(ha->pdev, 0) & IORESOURCE_IO) {
1622 if (pci_resource_len(ha->pdev, 0) < MIN_IOBASE_LEN) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001623 qla_printk(KERN_WARNING, ha,
1624 "Invalid PCI I/O region size (%s)...\n",
1625 pci_name(ha->pdev));
1626 pio = 0;
1627 }
1628 } else {
1629 qla_printk(KERN_WARNING, ha,
1630 "region #0 not a PIO resource (%s)...\n",
1631 pci_name(ha->pdev));
1632 pio = 0;
1633 }
Andrew Vasquez285d0322007-10-19 15:59:17 -07001634 ha->pio_address = pio;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001635
Andrew Vasquez285d0322007-10-19 15:59:17 -07001636skip_pio:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001637 /* Use MMIO operations for all accesses. */
Andrew Vasquez37765412008-01-17 09:02:09 -08001638 if (!(pci_resource_flags(ha->pdev, 1) & IORESOURCE_MEM)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001639 qla_printk(KERN_ERR, ha,
Andrew Vasquez37765412008-01-17 09:02:09 -08001640 "region #1 not an MMIO resource (%s), aborting\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -07001641 pci_name(ha->pdev));
1642 goto iospace_error_exit;
1643 }
Andrew Vasquez37765412008-01-17 09:02:09 -08001644 if (pci_resource_len(ha->pdev, 1) < MIN_IOBASE_LEN) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001645 qla_printk(KERN_ERR, ha,
1646 "Invalid PCI mem region size (%s), aborting\n",
1647 pci_name(ha->pdev));
1648 goto iospace_error_exit;
1649 }
1650
Andrew Vasquez37765412008-01-17 09:02:09 -08001651 ha->iobase = ioremap(pci_resource_start(ha->pdev, 1), MIN_IOBASE_LEN);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001652 if (!ha->iobase) {
1653 qla_printk(KERN_ERR, ha,
1654 "cannot remap MMIO (%s), aborting\n", pci_name(ha->pdev));
1655
1656 goto iospace_error_exit;
1657 }
1658
Anirban Chakraborty73208df2008-12-09 16:45:39 -08001659 /* Determine queue resources */
1660 ha->max_queues = 1;
Andrew Vasquez3a03eb72009-01-05 11:18:11 -08001661 if (ql2xmaxqueues <= 1 || (!IS_QLA25XX(ha) && !IS_QLA81XX(ha)))
Anirban Chakraborty17d98632008-12-18 10:06:15 -08001662 goto mqiobase_exit;
1663 ha->mqiobase = ioremap(pci_resource_start(ha->pdev, 3),
1664 pci_resource_len(ha->pdev, 3));
1665 if (ha->mqiobase) {
1666 /* Read MSIX vector size of the board */
1667 pci_read_config_word(ha->pdev, QLA_PCI_MSIX_CONTROL, &msix);
1668 ha->msix_count = msix;
1669 /* Max queues are bounded by available msix vectors */
1670 /* queue 0 uses two msix vectors */
1671 if (ha->msix_count - 1 < ql2xmaxqueues)
1672 ha->max_queues = ha->msix_count - 1;
1673 else if (ql2xmaxqueues > QLA_MQ_SIZE)
1674 ha->max_queues = QLA_MQ_SIZE;
1675 else
1676 ha->max_queues = ql2xmaxqueues;
1677 qla_printk(KERN_INFO, ha,
1678 "MSI-X vector count: %d\n", msix);
Anirban Chakraborty73208df2008-12-09 16:45:39 -08001679 }
Anirban Chakraborty17d98632008-12-18 10:06:15 -08001680
1681mqiobase_exit:
Anirban Chakraborty73208df2008-12-09 16:45:39 -08001682 ha->msix_count = ha->max_queues + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001683 return (0);
1684
1685iospace_error_exit:
1686 return (-ENOMEM);
1687}
1688
Andrew Vasquezabbd8872005-07-06 10:30:05 -07001689static void
Andrew Vasquez1e99e332006-11-22 08:24:48 -08001690qla2xxx_scan_start(struct Scsi_Host *shost)
1691{
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001692 scsi_qla_host_t *vha = shost_priv(shost);
Andrew Vasquez1e99e332006-11-22 08:24:48 -08001693
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001694 set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags);
1695 set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags);
1696 set_bit(RSCN_UPDATE, &vha->dpc_flags);
1697 set_bit(NPIV_CONFIG_NEEDED, &vha->dpc_flags);
Andrew Vasquez1e99e332006-11-22 08:24:48 -08001698}
1699
1700static int
1701qla2xxx_scan_finished(struct Scsi_Host *shost, unsigned long time)
1702{
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001703 scsi_qla_host_t *vha = shost_priv(shost);
Andrew Vasquez1e99e332006-11-22 08:24:48 -08001704
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001705 if (!vha->host)
Andrew Vasquez1e99e332006-11-22 08:24:48 -08001706 return 1;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001707 if (time > vha->hw->loop_reset_delay * HZ)
Andrew Vasquez1e99e332006-11-22 08:24:48 -08001708 return 1;
1709
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001710 return atomic_read(&vha->loop_state) == LOOP_READY;
Andrew Vasquez1e99e332006-11-22 08:24:48 -08001711}
1712
Linus Torvalds1da177e2005-04-16 15:20:36 -07001713/*
1714 * PCI driver interface
1715 */
Andrew Vasquez7ee61392006-06-23 16:11:22 -07001716static int __devinit
1717qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001718{
Andrew Vasqueza1541d52005-06-09 17:21:28 -07001719 int ret = -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001720 struct Scsi_Host *host;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001721 scsi_qla_host_t *base_vha = NULL;
1722 struct qla_hw_data *ha;
Andrew Vasquez29856e22007-08-12 18:22:52 -07001723 char pci_info[30];
Linus Torvalds1da177e2005-04-16 15:20:36 -07001724 char fw_str[30];
Andrew Vasquez54333832005-11-09 15:49:04 -08001725 struct scsi_host_template *sht;
Anirban Chakrabortyc51da4e2008-11-10 15:53:20 -08001726 int bars, max_id, mem_only = 0;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001727 uint16_t req_length = 0, rsp_length = 0;
Anirban Chakraborty73208df2008-12-09 16:45:39 -08001728 struct req_que *req = NULL;
1729 struct rsp_que *rsp = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001730
Andrew Vasquez285d0322007-10-19 15:59:17 -07001731 bars = pci_select_bars(pdev, IORESOURCE_MEM | IORESOURCE_IO);
1732 sht = &qla2x00_driver_template;
1733 if (pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2422 ||
1734 pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2432 ||
Harihara Kadayam4d4df192008-04-03 13:13:26 -07001735 pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8432 ||
Andrew Vasquez285d0322007-10-19 15:59:17 -07001736 pdev->device == PCI_DEVICE_ID_QLOGIC_ISP5422 ||
1737 pdev->device == PCI_DEVICE_ID_QLOGIC_ISP5432 ||
Andrew Vasquez3a03eb72009-01-05 11:18:11 -08001738 pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2532 ||
1739 pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8001) {
Andrew Vasquez285d0322007-10-19 15:59:17 -07001740 bars = pci_select_bars(pdev, IORESOURCE_MEM);
1741 sht = &qla24xx_driver_template;
Benjamin Herrenschmidt09483912007-12-20 15:28:09 +11001742 mem_only = 1;
Andrew Vasquez285d0322007-10-19 15:59:17 -07001743 }
1744
Benjamin Herrenschmidt09483912007-12-20 15:28:09 +11001745 if (mem_only) {
1746 if (pci_enable_device_mem(pdev))
1747 goto probe_out;
1748 } else {
1749 if (pci_enable_device(pdev))
1750 goto probe_out;
1751 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001752
Jesse Barnes09276782008-10-18 17:33:19 -07001753 /* This may fail but that's ok */
1754 pci_enable_pcie_error_reporting(pdev);
Seokmann Ju14e660e2007-09-20 14:07:36 -07001755
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001756 ha = kzalloc(sizeof(struct qla_hw_data), GFP_KERNEL);
1757 if (!ha) {
1758 DEBUG(printk("Unable to allocate memory for ha\n"));
1759 goto probe_out;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001760 }
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001761 ha->pdev = pdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001762
1763 /* Clear our data area */
Andrew Vasquez285d0322007-10-19 15:59:17 -07001764 ha->bars = bars;
Benjamin Herrenschmidt09483912007-12-20 15:28:09 +11001765 ha->mem_only = mem_only;
Andrew Vasquezdf4bf0b2008-01-31 12:33:46 -08001766 spin_lock_init(&ha->hardware_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001767
andrew.vasquez@qlogic.comea5b6382006-03-09 14:27:08 -08001768 /* Set ISP-type information. */
1769 qla2x00_set_isp_flags(ha);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001770 /* Configure PCI I/O space */
1771 ret = qla2x00_iospace_config(ha);
Andrew Vasqueza1541d52005-06-09 17:21:28 -07001772 if (ret)
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001773 goto probe_hw_failed;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001774
Linus Torvalds1da177e2005-04-16 15:20:36 -07001775 qla_printk(KERN_INFO, ha,
Andrew Vasquez54333832005-11-09 15:49:04 -08001776 "Found an ISP%04X, irq %d, iobase 0x%p\n", pdev->device, pdev->irq,
1777 ha->iobase);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001778
Linus Torvalds1da177e2005-04-16 15:20:36 -07001779 ha->prev_topology = 0;
Andrew Vasquezfca29702005-07-06 10:31:47 -07001780 ha->init_cb_size = sizeof(init_cb_t);
Andrew Vasquezd8b45212006-10-02 12:00:43 -07001781 ha->link_data_rate = PORT_SPEED_UNKNOWN;
andrew.vasquez@qlogic.com854165f2006-01-31 16:05:17 -08001782 ha->optrom_size = OPTROM_SIZE_2300;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001783
Andrew Vasquezabbd8872005-07-06 10:30:05 -07001784 /* Assign ISP specific operations. */
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001785 max_id = MAX_TARGETS_2200;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001786 if (IS_QLA2100(ha)) {
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001787 max_id = MAX_TARGETS_2100;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001788 ha->mbx_count = MAILBOX_REGISTER_COUNT_2100;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001789 req_length = REQUEST_ENTRY_CNT_2100;
1790 rsp_length = RESPONSE_ENTRY_CNT_2100;
1791 ha->max_loop_id = SNS_LAST_LOOP_ID_2100;
Andrew Vasquezabbd8872005-07-06 10:30:05 -07001792 ha->gid_list_info_size = 4;
Andrew Vasquez3a03eb72009-01-05 11:18:11 -08001793 ha->flash_conf_off = ~0;
1794 ha->flash_data_off = ~0;
1795 ha->nvram_conf_off = ~0;
1796 ha->nvram_data_off = ~0;
Andrew Vasquezfd34f552007-07-19 15:06:00 -07001797 ha->isp_ops = &qla2100_isp_ops;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001798 } else if (IS_QLA2200(ha)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001799 ha->mbx_count = MAILBOX_REGISTER_COUNT;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001800 req_length = REQUEST_ENTRY_CNT_2200;
1801 rsp_length = RESPONSE_ENTRY_CNT_2100;
1802 ha->max_loop_id = SNS_LAST_LOOP_ID_2100;
Andrew Vasquezabbd8872005-07-06 10:30:05 -07001803 ha->gid_list_info_size = 4;
Andrew Vasquez3a03eb72009-01-05 11:18:11 -08001804 ha->flash_conf_off = ~0;
1805 ha->flash_data_off = ~0;
1806 ha->nvram_conf_off = ~0;
1807 ha->nvram_data_off = ~0;
Andrew Vasquezfd34f552007-07-19 15:06:00 -07001808 ha->isp_ops = &qla2100_isp_ops;
Andrew Vasquezfca29702005-07-06 10:31:47 -07001809 } else if (IS_QLA23XX(ha)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001810 ha->mbx_count = MAILBOX_REGISTER_COUNT;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001811 req_length = REQUEST_ENTRY_CNT_2200;
1812 rsp_length = RESPONSE_ENTRY_CNT_2300;
1813 ha->max_loop_id = SNS_LAST_LOOP_ID_2300;
Andrew Vasquezabbd8872005-07-06 10:30:05 -07001814 ha->gid_list_info_size = 6;
andrew.vasquez@qlogic.com854165f2006-01-31 16:05:17 -08001815 if (IS_QLA2322(ha) || IS_QLA6322(ha))
1816 ha->optrom_size = OPTROM_SIZE_2322;
Andrew Vasquez3a03eb72009-01-05 11:18:11 -08001817 ha->flash_conf_off = ~0;
1818 ha->flash_data_off = ~0;
1819 ha->nvram_conf_off = ~0;
1820 ha->nvram_data_off = ~0;
Andrew Vasquezfd34f552007-07-19 15:06:00 -07001821 ha->isp_ops = &qla2300_isp_ops;
Harihara Kadayam4d4df192008-04-03 13:13:26 -07001822 } else if (IS_QLA24XX_TYPE(ha)) {
Andrew Vasquezfca29702005-07-06 10:31:47 -07001823 ha->mbx_count = MAILBOX_REGISTER_COUNT;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001824 req_length = REQUEST_ENTRY_CNT_24XX;
1825 rsp_length = RESPONSE_ENTRY_CNT_2300;
1826 ha->max_loop_id = SNS_LAST_LOOP_ID_2300;
Seokmann Ju2c3dfe32007-07-05 13:16:51 -07001827 ha->init_cb_size = sizeof(struct mid_init_cb_24xx);
Andrew Vasquezfca29702005-07-06 10:31:47 -07001828 ha->gid_list_info_size = 8;
andrew.vasquez@qlogic.com854165f2006-01-31 16:05:17 -08001829 ha->optrom_size = OPTROM_SIZE_24XX;
Anirban Chakraborty73208df2008-12-09 16:45:39 -08001830 ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA24XX;
Andrew Vasquezfd34f552007-07-19 15:06:00 -07001831 ha->isp_ops = &qla24xx_isp_ops;
Andrew Vasquez3a03eb72009-01-05 11:18:11 -08001832 ha->flash_conf_off = FARX_ACCESS_FLASH_CONF;
1833 ha->flash_data_off = FARX_ACCESS_FLASH_DATA;
1834 ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF;
1835 ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA;
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001836 } else if (IS_QLA25XX(ha)) {
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001837 ha->mbx_count = MAILBOX_REGISTER_COUNT;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001838 req_length = REQUEST_ENTRY_CNT_24XX;
1839 rsp_length = RESPONSE_ENTRY_CNT_2300;
1840 ha->max_loop_id = SNS_LAST_LOOP_ID_2300;
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001841 ha->init_cb_size = sizeof(struct mid_init_cb_24xx);
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001842 ha->gid_list_info_size = 8;
1843 ha->optrom_size = OPTROM_SIZE_25XX;
Anirban Chakraborty73208df2008-12-09 16:45:39 -08001844 ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX;
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001845 ha->isp_ops = &qla25xx_isp_ops;
Andrew Vasquez3a03eb72009-01-05 11:18:11 -08001846 ha->flash_conf_off = FARX_ACCESS_FLASH_CONF;
1847 ha->flash_data_off = FARX_ACCESS_FLASH_DATA;
1848 ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF;
1849 ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA;
1850 } else if (IS_QLA81XX(ha)) {
1851 ha->mbx_count = MAILBOX_REGISTER_COUNT;
1852 req_length = REQUEST_ENTRY_CNT_24XX;
1853 rsp_length = RESPONSE_ENTRY_CNT_2300;
1854 ha->max_loop_id = SNS_LAST_LOOP_ID_2300;
1855 ha->init_cb_size = sizeof(struct mid_init_cb_81xx);
1856 ha->gid_list_info_size = 8;
1857 ha->optrom_size = OPTROM_SIZE_81XX;
1858 ha->isp_ops = &qla81xx_isp_ops;
1859 ha->flash_conf_off = FARX_ACCESS_FLASH_CONF_81XX;
1860 ha->flash_data_off = FARX_ACCESS_FLASH_DATA_81XX;
1861 ha->nvram_conf_off = ~0;
1862 ha->nvram_data_off = ~0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001863 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001864
matthias@kaehlcke.net6c2f5272008-05-12 22:21:11 -07001865 mutex_init(&ha->vport_lock);
Marcus Barrow0b05a1f2008-01-17 09:02:13 -08001866 init_completion(&ha->mbx_cmd_comp);
1867 complete(&ha->mbx_cmd_comp);
1868 init_completion(&ha->mbx_intr_comp);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001869
Seokmann Ju2c3dfe32007-07-05 13:16:51 -07001870 set_bit(0, (unsigned long *) ha->vp_idx_map);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001871
Anirban Chakraborty73208df2008-12-09 16:45:39 -08001872 ret = qla2x00_mem_alloc(ha, req_length, rsp_length, &req, &rsp);
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001873 if (!ret) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001874 qla_printk(KERN_WARNING, ha,
1875 "[ERROR] Failed to allocate memory for adapter\n");
1876
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001877 goto probe_hw_failed;
1878 }
1879
Anirban Chakraborty73208df2008-12-09 16:45:39 -08001880 req->max_q_depth = MAX_Q_DEPTH;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001881 if (ql2xmaxqdepth != 0 && ql2xmaxqdepth <= 0xffffU)
Anirban Chakraborty73208df2008-12-09 16:45:39 -08001882 req->max_q_depth = ql2xmaxqdepth;
1883
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001884
1885 base_vha = qla2x00_create_host(sht, ha);
1886 if (!base_vha) {
1887 qla_printk(KERN_WARNING, ha,
1888 "[ERROR] Failed to allocate memory for scsi_host\n");
1889
Andrew Vasqueza1541d52005-06-09 17:21:28 -07001890 ret = -ENOMEM;
Anirban Chakraborty6e9f21f2009-01-22 09:45:28 -08001891 qla2x00_mem_free(ha);
1892 qla2x00_free_que(ha, req, rsp);
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001893 goto probe_hw_failed;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001894 }
1895
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001896 pci_set_drvdata(pdev, base_vha);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001897
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001898 qla2x00_config_dma_addressing(base_vha);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001899
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001900 host = base_vha->host;
Anirban Chakraborty73208df2008-12-09 16:45:39 -08001901 base_vha->req_ques[0] = req->id;
1902 host->can_queue = req->length + 128;
1903 if (IS_QLA2XXX_MIDTYPE(ha))
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001904 base_vha->mgmt_svr_loop_id = 10 + base_vha->vp_idx;
Anirban Chakraborty73208df2008-12-09 16:45:39 -08001905 else
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001906 base_vha->mgmt_svr_loop_id = MANAGEMENT_SERVER +
1907 base_vha->vp_idx;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001908 if (IS_QLA2100(ha))
1909 host->sg_tablesize = 32;
1910 host->max_id = max_id;
Andrew Vasqueza1541d52005-06-09 17:21:28 -07001911 host->this_id = 255;
1912 host->cmd_per_lun = 3;
Seokmann Ju711c1d92008-07-10 16:55:51 -07001913 host->unique_id = host->host_no;
Andrew Vasqueza1541d52005-06-09 17:21:28 -07001914 host->max_cmd_len = MAX_CMDSZ;
Andrew Vasquez75bc4192006-05-17 15:09:22 -07001915 host->max_channel = MAX_BUSES - 1;
Andrew Vasqueza1541d52005-06-09 17:21:28 -07001916 host->max_lun = MAX_LUNS;
1917 host->transportt = qla2xxx_transport_template;
1918
Anirban Chakraborty73208df2008-12-09 16:45:39 -08001919 /* Set up the irqs */
1920 ret = qla2x00_request_irqs(ha, rsp);
1921 if (ret)
Anirban Chakraborty6e9f21f2009-01-22 09:45:28 -08001922 goto probe_init_failed;
Anirban Chakraborty73208df2008-12-09 16:45:39 -08001923 /* Alloc arrays of request and response ring ptrs */
1924 if (!qla2x00_alloc_queues(ha)) {
1925 qla_printk(KERN_WARNING, ha,
1926 "[ERROR] Failed to allocate memory for queue"
1927 " pointers\n");
Anirban Chakraborty6e9f21f2009-01-22 09:45:28 -08001928 goto probe_init_failed;
Anirban Chakraborty73208df2008-12-09 16:45:39 -08001929 }
1930 ha->rsp_q_map[0] = rsp;
1931 ha->req_q_map[0] = req;
1932
Anirban Chakraborty17d98632008-12-18 10:06:15 -08001933 if (ha->mqenable) {
1934 ha->isp_ops->wrt_req_reg = qla25xx_wrt_req_reg;
1935 ha->isp_ops->wrt_rsp_reg = qla25xx_wrt_rsp_reg;
1936 ha->isp_ops->rd_req_reg = qla25xx_rd_req_reg;
1937 }
1938
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001939 if (qla2x00_initialize_adapter(base_vha)) {
1940 qla_printk(KERN_WARNING, ha,
1941 "Failed to initialize adapter\n");
1942
1943 DEBUG2(printk("scsi(%ld): Failed to initialize adapter - "
1944 "Adapter flags %x.\n",
1945 base_vha->host_no, base_vha->device_flags));
1946
1947 ret = -ENODEV;
1948 goto probe_failed;
1949 }
1950
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001951 /*
1952 * Startup the kernel thread for this host adapter
1953 */
1954 ha->dpc_thread = kthread_create(qla2x00_do_dpc, ha,
1955 "%s_dpc", base_vha->host_str);
1956 if (IS_ERR(ha->dpc_thread)) {
1957 qla_printk(KERN_WARNING, ha,
1958 "Unable to start DPC thread!\n");
1959 ret = PTR_ERR(ha->dpc_thread);
1960 goto probe_failed;
1961 }
1962
1963 list_add_tail(&base_vha->list, &ha->vp_list);
1964 base_vha->host->irq = ha->pdev->irq;
1965
Linus Torvalds1da177e2005-04-16 15:20:36 -07001966 /* Initialized the timer */
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001967 qla2x00_start_timer(base_vha, qla2x00_timer, WATCH_INTERVAL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001968
1969 DEBUG2(printk("DEBUG: detect hba %ld at address = %p\n",
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001970 base_vha->host_no, ha));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001971
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001972 base_vha->flags.init_done = 1;
1973 base_vha->flags.online = 1;
Andrew Vasquezd19044c2006-11-22 08:22:19 -08001974
Andrew Vasqueza1541d52005-06-09 17:21:28 -07001975 ret = scsi_add_host(host, &pdev->dev);
1976 if (ret)
1977 goto probe_failed;
1978
Andrew Vasquez048feec2008-09-11 22:19:45 -07001979 ha->isp_ops->enable_intrs(ha);
1980
Andrew Vasquez1e99e332006-11-22 08:24:48 -08001981 scsi_scan_host(host);
1982
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001983 qla2x00_alloc_sysfs_attr(base_vha);
Andrew Vasqueza1541d52005-06-09 17:21:28 -07001984
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001985 qla2x00_init_host_attr(base_vha);
Andrew Vasqueza1541d52005-06-09 17:21:28 -07001986
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001987 qla2x00_dfs_setup(base_vha);
Andrew Vasquezdf613b92008-01-17 09:02:17 -08001988
Linus Torvalds1da177e2005-04-16 15:20:36 -07001989 qla_printk(KERN_INFO, ha, "\n"
1990 " QLogic Fibre Channel HBA Driver: %s\n"
1991 " QLogic %s - %s\n"
Andrew Vasquez54333832005-11-09 15:49:04 -08001992 " ISP%04X: %s @ %s hdma%c, host#=%ld, fw=%s\n",
1993 qla2x00_version_str, ha->model_number,
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001994 ha->model_desc ? ha->model_desc : "", pdev->device,
1995 ha->isp_ops->pci_info_str(base_vha, pci_info), pci_name(pdev),
1996 ha->flags.enable_64bit_addressing ? '+' : '-', base_vha->host_no,
1997 ha->isp_ops->fw_version_str(base_vha, fw_str));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001998
Linus Torvalds1da177e2005-04-16 15:20:36 -07001999 return 0;
2000
Anirban Chakraborty6e9f21f2009-01-22 09:45:28 -08002001probe_init_failed:
2002 qla2x00_free_que(ha, req, rsp);
2003 ha->max_queues = 0;
2004
Linus Torvalds1da177e2005-04-16 15:20:36 -07002005probe_failed:
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002006 qla2x00_free_device(base_vha);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002007
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002008 scsi_host_put(base_vha->host);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002009
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002010probe_hw_failed:
2011 if (ha->iobase)
2012 iounmap(ha->iobase);
2013
2014 pci_release_selected_regions(ha->pdev, ha->bars);
2015 kfree(ha);
2016 ha = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002017
Andrew Vasqueza1541d52005-06-09 17:21:28 -07002018probe_out:
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002019 pci_disable_device(pdev);
Andrew Vasqueza1541d52005-06-09 17:21:28 -07002020 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002021}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002022
Adrian Bunk4c993f72008-01-14 00:55:16 -08002023static void
Andrew Vasquez7ee61392006-06-23 16:11:22 -07002024qla2x00_remove_one(struct pci_dev *pdev)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002025{
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002026 scsi_qla_host_t *base_vha, *vha, *temp;
2027 struct qla_hw_data *ha;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002028
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002029 base_vha = pci_get_drvdata(pdev);
2030 ha = base_vha->hw;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002031
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002032 list_for_each_entry_safe(vha, temp, &ha->vp_list, list) {
2033 if (vha && vha->fc_vport)
2034 fc_vport_terminate(vha->fc_vport);
2035 }
Andrew Vasquezc795c1e2008-08-13 21:37:01 -07002036
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002037 set_bit(UNLOADING, &base_vha->dpc_flags);
Andrew Vasquezc795c1e2008-08-13 21:37:01 -07002038
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002039 qla2x00_dfs_remove(base_vha);
Andrew Vasquezdf613b92008-01-17 09:02:17 -08002040
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002041 qla84xx_put_chip(base_vha);
Harihara Kadayam4d4df192008-04-03 13:13:26 -07002042
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002043 qla2x00_free_sysfs_attr(base_vha);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002044
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002045 fc_remove_host(base_vha->host);
bdf79622005-04-17 15:06:53 -05002046
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002047 scsi_remove_host(base_vha->host);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002048
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002049 qla2x00_free_device(base_vha);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002050
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002051 scsi_host_put(base_vha->host);
2052
2053 if (ha->iobase)
2054 iounmap(ha->iobase);
2055
Anirban Chakraborty73208df2008-12-09 16:45:39 -08002056 if (ha->mqiobase)
2057 iounmap(ha->mqiobase);
2058
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002059 pci_release_selected_regions(ha->pdev, ha->bars);
2060 kfree(ha);
2061 ha = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002062
Bernhard Walle665db932007-03-28 00:49:49 +02002063 pci_disable_device(pdev);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002064 pci_set_drvdata(pdev, NULL);
2065}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002066
2067static void
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002068qla2x00_free_device(scsi_qla_host_t *vha)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002069{
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002070 struct qla_hw_data *ha = vha->hw;
2071 qla2x00_abort_all_cmds(vha, DID_NO_CONNECT << 16);
Andrew Vasquezdf4bf0b2008-01-31 12:33:46 -08002072
Linus Torvalds1da177e2005-04-16 15:20:36 -07002073 /* Disable timer */
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002074 if (vha->timer_active)
2075 qla2x00_stop_timer(vha);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002076
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002077 vha->flags.online = 0;
Andrew Vasquezdf4bf0b2008-01-31 12:33:46 -08002078
Linus Torvalds1da177e2005-04-16 15:20:36 -07002079 /* Kill the kernel thread for this host */
Christoph Hellwig39a11242006-02-14 18:46:22 +01002080 if (ha->dpc_thread) {
2081 struct task_struct *t = ha->dpc_thread;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002082
Christoph Hellwig39a11242006-02-14 18:46:22 +01002083 /*
2084 * qla2xxx_wake_dpc checks for ->dpc_thread
2085 * so we need to zero it out.
2086 */
2087 ha->dpc_thread = NULL;
2088 kthread_stop(t);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002089 }
2090
Andrew Vasquezdf613b92008-01-17 09:02:17 -08002091 if (ha->flags.fce_enabled)
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002092 qla2x00_disable_fce_trace(vha, NULL, NULL);
Andrew Vasquezdf613b92008-01-17 09:02:17 -08002093
Andrew Vasqueza7a167b2006-06-23 16:10:29 -07002094 if (ha->eft)
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002095 qla2x00_disable_eft_trace(vha);
Andrew Vasqueza7a167b2006-06-23 16:10:29 -07002096
Andrew Vasquezf6ef3b12005-08-26 19:10:20 -07002097 /* Stop currently executing firmware. */
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002098 qla2x00_try_to_stop_firmware(vha);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002099
Andrew Vasquezf6ef3b12005-08-26 19:10:20 -07002100 /* turn-off interrupts on the card */
2101 if (ha->interrupts_on)
Andrew Vasquezfd34f552007-07-19 15:06:00 -07002102 ha->isp_ops->disable_intrs(ha);
Andrew Vasquezf6ef3b12005-08-26 19:10:20 -07002103
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002104 qla2x00_free_irqs(vha);
2105
Andrew Vasquezf6ef3b12005-08-26 19:10:20 -07002106 qla2x00_mem_free(ha);
Anirban Chakraborty73208df2008-12-09 16:45:39 -08002107
2108 qla2x00_free_queues(ha);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002109}
2110
andrew.vasquez@qlogic.comd97994d2006-01-20 14:53:13 -08002111static inline void
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002112qla2x00_schedule_rport_del(struct scsi_qla_host *vha, fc_port_t *fcport,
andrew.vasquez@qlogic.comd97994d2006-01-20 14:53:13 -08002113 int defer)
2114{
andrew.vasquez@qlogic.comd97994d2006-01-20 14:53:13 -08002115 struct fc_rport *rport;
2116
2117 if (!fcport->rport)
2118 return;
2119
2120 rport = fcport->rport;
2121 if (defer) {
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002122 spin_lock_irq(vha->host->host_lock);
andrew.vasquez@qlogic.comd97994d2006-01-20 14:53:13 -08002123 fcport->drport = rport;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002124 spin_unlock_irq(vha->host->host_lock);
2125 set_bit(FCPORT_UPDATE_NEEDED, &vha->dpc_flags);
2126 qla2xxx_wake_dpc(vha);
Seokmann Ju5f3a9a22008-07-10 16:55:47 -07002127 } else
andrew.vasquez@qlogic.comd97994d2006-01-20 14:53:13 -08002128 fc_remote_port_delete(rport);
andrew.vasquez@qlogic.comd97994d2006-01-20 14:53:13 -08002129}
2130
Linus Torvalds1da177e2005-04-16 15:20:36 -07002131/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002132 * qla2x00_mark_device_lost Updates fcport state when device goes offline.
2133 *
2134 * Input: ha = adapter block pointer. fcport = port structure pointer.
2135 *
2136 * Return: None.
2137 *
2138 * Context:
2139 */
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002140void qla2x00_mark_device_lost(scsi_qla_host_t *vha, fc_port_t *fcport,
andrew.vasquez@qlogic.comd97994d2006-01-20 14:53:13 -08002141 int do_login, int defer)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002142{
Seokmann Ju2c3dfe32007-07-05 13:16:51 -07002143 if (atomic_read(&fcport->state) == FCS_ONLINE &&
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002144 vha->vp_idx == fcport->vp_idx) {
2145 atomic_set(&fcport->state, FCS_DEVICE_LOST);
2146 qla2x00_schedule_rport_del(vha, fcport, defer);
2147 }
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -07002148 /*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002149 * We may need to retry the login, so don't change the state of the
2150 * port but do the retries.
2151 */
2152 if (atomic_read(&fcport->state) != FCS_DEVICE_DEAD)
2153 atomic_set(&fcport->state, FCS_DEVICE_LOST);
2154
2155 if (!do_login)
2156 return;
2157
2158 if (fcport->login_retry == 0) {
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002159 fcport->login_retry = vha->hw->login_retry_count;
2160 set_bit(RELOGIN_NEEDED, &vha->dpc_flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002161
2162 DEBUG(printk("scsi(%ld): Port login retry: "
2163 "%02x%02x%02x%02x%02x%02x%02x%02x, "
2164 "id = 0x%04x retry cnt=%d\n",
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002165 vha->host_no,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002166 fcport->port_name[0],
2167 fcport->port_name[1],
2168 fcport->port_name[2],
2169 fcport->port_name[3],
2170 fcport->port_name[4],
2171 fcport->port_name[5],
2172 fcport->port_name[6],
2173 fcport->port_name[7],
2174 fcport->loop_id,
2175 fcport->login_retry));
2176 }
2177}
2178
2179/*
2180 * qla2x00_mark_all_devices_lost
2181 * Updates fcport state when device goes offline.
2182 *
2183 * Input:
2184 * ha = adapter block pointer.
2185 * fcport = port structure pointer.
2186 *
2187 * Return:
2188 * None.
2189 *
2190 * Context:
2191 */
2192void
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002193qla2x00_mark_all_devices_lost(scsi_qla_host_t *vha, int defer)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002194{
2195 fc_port_t *fcport;
2196
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002197 list_for_each_entry(fcport, &vha->vp_fcports, list) {
2198 if (vha->vp_idx != fcport->vp_idx)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002199 continue;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002200 /*
2201 * No point in marking the device as lost, if the device is
2202 * already DEAD.
2203 */
2204 if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD)
2205 continue;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002206 if (atomic_read(&fcport->state) == FCS_ONLINE) {
2207 atomic_set(&fcport->state, FCS_DEVICE_LOST);
2208 qla2x00_schedule_rport_del(vha, fcport, defer);
2209 } else
2210 atomic_set(&fcport->state, FCS_DEVICE_LOST);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002211 }
2212}
2213
2214/*
2215* qla2x00_mem_alloc
2216* Allocates adapter memory.
2217*
2218* Returns:
2219* 0 = success.
Andrew Vasqueze8711082008-01-31 12:33:48 -08002220* !0 = failure.
Linus Torvalds1da177e2005-04-16 15:20:36 -07002221*/
Andrew Vasqueze8711082008-01-31 12:33:48 -08002222static int
Anirban Chakraborty73208df2008-12-09 16:45:39 -08002223qla2x00_mem_alloc(struct qla_hw_data *ha, uint16_t req_len, uint16_t rsp_len,
2224 struct req_que **req, struct rsp_que **rsp)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002225{
2226 char name[16];
Linus Torvalds1da177e2005-04-16 15:20:36 -07002227
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002228 ha->init_cb_size = sizeof(init_cb_t);
2229 if (IS_QLA2XXX_MIDTYPE(ha))
2230 ha->init_cb_size = sizeof(struct mid_init_cb_24xx);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002231
Andrew Vasqueze8711082008-01-31 12:33:48 -08002232 ha->init_cb = dma_alloc_coherent(&ha->pdev->dev, ha->init_cb_size,
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002233 &ha->init_cb_dma, GFP_KERNEL);
Andrew Vasqueze8711082008-01-31 12:33:48 -08002234 if (!ha->init_cb)
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002235 goto fail;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002236
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002237 ha->gid_list = dma_alloc_coherent(&ha->pdev->dev, GID_LIST_SIZE,
2238 &ha->gid_list_dma, GFP_KERNEL);
2239 if (!ha->gid_list)
Andrew Vasqueze8711082008-01-31 12:33:48 -08002240 goto fail_free_init_cb;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002241
Andrew Vasqueze8711082008-01-31 12:33:48 -08002242 ha->srb_mempool = mempool_create_slab_pool(SRB_MIN_REQ, srb_cachep);
2243 if (!ha->srb_mempool)
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002244 goto fail_free_gid_list;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002245
Andrew Vasqueze8711082008-01-31 12:33:48 -08002246 /* Get memory for cached NVRAM */
2247 ha->nvram = kzalloc(MAX_NVRAM_SIZE, GFP_KERNEL);
2248 if (!ha->nvram)
2249 goto fail_free_srb_mempool;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002250
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002251 snprintf(name, sizeof(name), "%s_%d", QLA2XXX_DRIVER_NAME,
2252 ha->pdev->device);
2253 ha->s_dma_pool = dma_pool_create(name, &ha->pdev->dev,
2254 DMA_POOL_SIZE, 8, 0);
2255 if (!ha->s_dma_pool)
2256 goto fail_free_nvram;
2257
Andrew Vasqueze8711082008-01-31 12:33:48 -08002258 /* Allocate memory for SNS commands */
2259 if (IS_QLA2100(ha) || IS_QLA2200(ha)) {
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002260 /* Get consistent memory allocated for SNS commands */
Andrew Vasqueze8711082008-01-31 12:33:48 -08002261 ha->sns_cmd = dma_alloc_coherent(&ha->pdev->dev,
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002262 sizeof(struct sns_cmd_pkt), &ha->sns_cmd_dma, GFP_KERNEL);
Andrew Vasqueze8711082008-01-31 12:33:48 -08002263 if (!ha->sns_cmd)
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002264 goto fail_dma_pool;
Andrew Vasqueze8711082008-01-31 12:33:48 -08002265 } else {
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002266 /* Get consistent memory allocated for MS IOCB */
Andrew Vasqueze8711082008-01-31 12:33:48 -08002267 ha->ms_iocb = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL,
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002268 &ha->ms_iocb_dma);
Andrew Vasqueze8711082008-01-31 12:33:48 -08002269 if (!ha->ms_iocb)
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002270 goto fail_dma_pool;
2271 /* Get consistent memory allocated for CT SNS commands */
Andrew Vasqueze8711082008-01-31 12:33:48 -08002272 ha->ct_sns = dma_alloc_coherent(&ha->pdev->dev,
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002273 sizeof(struct ct_sns_pkt), &ha->ct_sns_dma, GFP_KERNEL);
Andrew Vasqueze8711082008-01-31 12:33:48 -08002274 if (!ha->ct_sns)
2275 goto fail_free_ms_iocb;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002276 }
2277
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002278 /* Allocate memory for request ring */
Anirban Chakraborty73208df2008-12-09 16:45:39 -08002279 *req = kzalloc(sizeof(struct req_que), GFP_KERNEL);
2280 if (!*req) {
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002281 DEBUG(printk("Unable to allocate memory for req\n"));
2282 goto fail_req;
2283 }
Anirban Chakraborty73208df2008-12-09 16:45:39 -08002284 (*req)->length = req_len;
2285 (*req)->ring = dma_alloc_coherent(&ha->pdev->dev,
2286 ((*req)->length + 1) * sizeof(request_t),
2287 &(*req)->dma, GFP_KERNEL);
2288 if (!(*req)->ring) {
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002289 DEBUG(printk("Unable to allocate memory for req_ring\n"));
2290 goto fail_req_ring;
2291 }
2292 /* Allocate memory for response ring */
Anirban Chakraborty73208df2008-12-09 16:45:39 -08002293 *rsp = kzalloc(sizeof(struct rsp_que), GFP_KERNEL);
2294 if (!*rsp) {
2295 qla_printk(KERN_WARNING, ha,
2296 "Unable to allocate memory for rsp\n");
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002297 goto fail_rsp;
2298 }
Anirban Chakraborty73208df2008-12-09 16:45:39 -08002299 (*rsp)->hw = ha;
2300 (*rsp)->length = rsp_len;
2301 (*rsp)->ring = dma_alloc_coherent(&ha->pdev->dev,
2302 ((*rsp)->length + 1) * sizeof(response_t),
2303 &(*rsp)->dma, GFP_KERNEL);
2304 if (!(*rsp)->ring) {
2305 qla_printk(KERN_WARNING, ha,
2306 "Unable to allocate memory for rsp_ring\n");
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002307 goto fail_rsp_ring;
2308 }
Anirban Chakraborty73208df2008-12-09 16:45:39 -08002309 (*req)->rsp = *rsp;
2310 (*rsp)->req = *req;
2311 /* Allocate memory for NVRAM data for vports */
2312 if (ha->nvram_npiv_size) {
2313 ha->npiv_info = kzalloc(sizeof(struct qla_npiv_entry) *
2314 ha->nvram_npiv_size, GFP_KERNEL);
2315 if (!ha->npiv_info) {
2316 qla_printk(KERN_WARNING, ha,
2317 "Unable to allocate memory for npiv info\n");
2318 goto fail_npiv_info;
2319 }
2320 } else
2321 ha->npiv_info = NULL;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002322
2323 INIT_LIST_HEAD(&ha->vp_list);
2324 return 1;
2325
Anirban Chakraborty73208df2008-12-09 16:45:39 -08002326fail_npiv_info:
2327 dma_free_coherent(&ha->pdev->dev, ((*rsp)->length + 1) *
2328 sizeof(response_t), (*rsp)->ring, (*rsp)->dma);
2329 (*rsp)->ring = NULL;
2330 (*rsp)->dma = 0;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002331fail_rsp_ring:
Anirban Chakraborty73208df2008-12-09 16:45:39 -08002332 kfree(*rsp);
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002333fail_rsp:
Anirban Chakraborty73208df2008-12-09 16:45:39 -08002334 dma_free_coherent(&ha->pdev->dev, ((*req)->length + 1) *
2335 sizeof(request_t), (*req)->ring, (*req)->dma);
2336 (*req)->ring = NULL;
2337 (*req)->dma = 0;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002338fail_req_ring:
Anirban Chakraborty73208df2008-12-09 16:45:39 -08002339 kfree(*req);
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002340fail_req:
2341 dma_free_coherent(&ha->pdev->dev, sizeof(struct ct_sns_pkt),
2342 ha->ct_sns, ha->ct_sns_dma);
2343 ha->ct_sns = NULL;
2344 ha->ct_sns_dma = 0;
Andrew Vasqueze8711082008-01-31 12:33:48 -08002345fail_free_ms_iocb:
2346 dma_pool_free(ha->s_dma_pool, ha->ms_iocb, ha->ms_iocb_dma);
2347 ha->ms_iocb = NULL;
2348 ha->ms_iocb_dma = 0;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002349fail_dma_pool:
2350 dma_pool_destroy(ha->s_dma_pool);
2351 ha->s_dma_pool = NULL;
Andrew Vasqueze8711082008-01-31 12:33:48 -08002352fail_free_nvram:
2353 kfree(ha->nvram);
2354 ha->nvram = NULL;
2355fail_free_srb_mempool:
2356 mempool_destroy(ha->srb_mempool);
2357 ha->srb_mempool = NULL;
Andrew Vasqueze8711082008-01-31 12:33:48 -08002358fail_free_gid_list:
2359 dma_free_coherent(&ha->pdev->dev, GID_LIST_SIZE, ha->gid_list,
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002360 ha->gid_list_dma);
Andrew Vasqueze8711082008-01-31 12:33:48 -08002361 ha->gid_list = NULL;
2362 ha->gid_list_dma = 0;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002363fail_free_init_cb:
2364 dma_free_coherent(&ha->pdev->dev, ha->init_cb_size, ha->init_cb,
2365 ha->init_cb_dma);
2366 ha->init_cb = NULL;
2367 ha->init_cb_dma = 0;
Andrew Vasqueze8711082008-01-31 12:33:48 -08002368fail:
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002369 DEBUG(printk("%s: Memory allocation failure\n", __func__));
Andrew Vasqueze8711082008-01-31 12:33:48 -08002370 return -ENOMEM;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002371}
2372
2373/*
2374* qla2x00_mem_free
2375* Frees all adapter allocated memory.
2376*
2377* Input:
2378* ha = adapter block pointer.
2379*/
Adrian Bunka824ebb2008-01-17 09:02:15 -08002380static void
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002381qla2x00_mem_free(struct qla_hw_data *ha)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002382{
Andrew Vasqueze8711082008-01-31 12:33:48 -08002383 if (ha->srb_mempool)
2384 mempool_destroy(ha->srb_mempool);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002385
Andrew Vasquezdf613b92008-01-17 09:02:17 -08002386 if (ha->fce)
2387 dma_free_coherent(&ha->pdev->dev, FCE_SIZE, ha->fce,
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002388 ha->fce_dma);
Andrew Vasquezdf613b92008-01-17 09:02:17 -08002389
Andrew Vasqueza7a167b2006-06-23 16:10:29 -07002390 if (ha->fw_dump) {
2391 if (ha->eft)
2392 dma_free_coherent(&ha->pdev->dev,
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002393 ntohl(ha->fw_dump->eft_size), ha->eft, ha->eft_dma);
Andrew Vasqueza7a167b2006-06-23 16:10:29 -07002394 vfree(ha->fw_dump);
2395 }
2396
Linus Torvalds1da177e2005-04-16 15:20:36 -07002397 if (ha->sns_cmd)
2398 dma_free_coherent(&ha->pdev->dev, sizeof(struct sns_cmd_pkt),
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002399 ha->sns_cmd, ha->sns_cmd_dma);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002400
2401 if (ha->ct_sns)
2402 dma_free_coherent(&ha->pdev->dev, sizeof(struct ct_sns_pkt),
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002403 ha->ct_sns, ha->ct_sns_dma);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002404
Andrew Vasquez88729e52006-06-23 16:10:50 -07002405 if (ha->sfp_data)
2406 dma_pool_free(ha->s_dma_pool, ha->sfp_data, ha->sfp_data_dma);
2407
Linus Torvalds1da177e2005-04-16 15:20:36 -07002408 if (ha->ms_iocb)
2409 dma_pool_free(ha->s_dma_pool, ha->ms_iocb, ha->ms_iocb_dma);
2410
Linus Torvalds1da177e2005-04-16 15:20:36 -07002411 if (ha->s_dma_pool)
2412 dma_pool_destroy(ha->s_dma_pool);
2413
Seokmann Ju2c3dfe32007-07-05 13:16:51 -07002414
Linus Torvalds1da177e2005-04-16 15:20:36 -07002415 if (ha->gid_list)
2416 dma_free_coherent(&ha->pdev->dev, GID_LIST_SIZE, ha->gid_list,
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002417 ha->gid_list_dma);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002418
Linus Torvalds1da177e2005-04-16 15:20:36 -07002419
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002420 if (ha->init_cb)
2421 dma_free_coherent(&ha->pdev->dev, ha->init_cb_size,
2422 ha->init_cb, ha->init_cb_dma);
2423 vfree(ha->optrom_buffer);
2424 kfree(ha->nvram);
Anirban Chakraborty73208df2008-12-09 16:45:39 -08002425 kfree(ha->npiv_info);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002426
Andrew Vasqueze8711082008-01-31 12:33:48 -08002427 ha->srb_mempool = NULL;
Andrew Vasqueza7a167b2006-06-23 16:10:29 -07002428 ha->eft = NULL;
2429 ha->eft_dma = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002430 ha->sns_cmd = NULL;
2431 ha->sns_cmd_dma = 0;
2432 ha->ct_sns = NULL;
2433 ha->ct_sns_dma = 0;
2434 ha->ms_iocb = NULL;
2435 ha->ms_iocb_dma = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002436 ha->init_cb = NULL;
2437 ha->init_cb_dma = 0;
2438
2439 ha->s_dma_pool = NULL;
2440
Linus Torvalds1da177e2005-04-16 15:20:36 -07002441 ha->gid_list = NULL;
2442 ha->gid_list_dma = 0;
2443
Linus Torvalds1da177e2005-04-16 15:20:36 -07002444 ha->fw_dump = NULL;
Andrew Vasquezfca29702005-07-06 10:31:47 -07002445 ha->fw_dumped = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002446 ha->fw_dump_reading = 0;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002447}
2448
2449struct scsi_qla_host *qla2x00_create_host(struct scsi_host_template *sht,
2450 struct qla_hw_data *ha)
2451{
2452 struct Scsi_Host *host;
2453 struct scsi_qla_host *vha = NULL;
2454
2455 host = scsi_host_alloc(sht, sizeof(scsi_qla_host_t));
2456 if (host == NULL) {
2457 printk(KERN_WARNING
2458 "qla2xxx: Couldn't allocate host from scsi layer!\n");
2459 goto fail;
2460 }
2461
2462 /* Clear our data area */
2463 vha = shost_priv(host);
2464 memset(vha, 0, sizeof(scsi_qla_host_t));
2465
2466 vha->host = host;
2467 vha->host_no = host->host_no;
2468 vha->hw = ha;
2469
2470 INIT_LIST_HEAD(&vha->vp_fcports);
2471 INIT_LIST_HEAD(&vha->work_list);
2472 INIT_LIST_HEAD(&vha->list);
2473
2474 sprintf(vha->host_str, "%s_%ld", QLA2XXX_DRIVER_NAME, vha->host_no);
2475 return vha;
2476
2477fail:
2478 return vha;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002479}
2480
Adrian Bunk01ef66b2008-04-24 15:21:27 -07002481static struct qla_work_evt *
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002482qla2x00_alloc_work(struct scsi_qla_host *vha, enum qla_work_type type,
Andrew Vasquez0971de72008-04-03 13:13:18 -07002483 int locked)
2484{
2485 struct qla_work_evt *e;
2486
2487 e = kzalloc(sizeof(struct qla_work_evt), locked ? GFP_ATOMIC:
2488 GFP_KERNEL);
2489 if (!e)
2490 return NULL;
2491
2492 INIT_LIST_HEAD(&e->list);
2493 e->type = type;
2494 e->flags = QLA_EVT_FLAG_FREE;
2495 return e;
2496}
2497
Adrian Bunk01ef66b2008-04-24 15:21:27 -07002498static int
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002499qla2x00_post_work(struct scsi_qla_host *vha, struct qla_work_evt *e, int locked)
Andrew Vasquez0971de72008-04-03 13:13:18 -07002500{
Andrew Mortonbf6583b2008-07-24 08:31:48 -07002501 unsigned long uninitialized_var(flags);
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002502 struct qla_hw_data *ha = vha->hw;
Andrew Vasquez0971de72008-04-03 13:13:18 -07002503
2504 if (!locked)
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002505 spin_lock_irqsave(&ha->hardware_lock, flags);
2506 list_add_tail(&e->list, &vha->work_list);
2507 qla2xxx_wake_dpc(vha);
Andrew Vasquez0971de72008-04-03 13:13:18 -07002508 if (!locked)
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002509 spin_unlock_irqrestore(&ha->hardware_lock, flags);
Andrew Vasquez0971de72008-04-03 13:13:18 -07002510 return QLA_SUCCESS;
2511}
2512
2513int
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002514qla2x00_post_aen_work(struct scsi_qla_host *vha, enum fc_host_event_code code,
Andrew Vasquez0971de72008-04-03 13:13:18 -07002515 u32 data)
2516{
2517 struct qla_work_evt *e;
2518
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002519 e = qla2x00_alloc_work(vha, QLA_EVT_AEN, 1);
Andrew Vasquez0971de72008-04-03 13:13:18 -07002520 if (!e)
2521 return QLA_FUNCTION_FAILED;
2522
2523 e->u.aen.code = code;
2524 e->u.aen.data = data;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002525 return qla2x00_post_work(vha, e, 1);
Andrew Vasquez0971de72008-04-03 13:13:18 -07002526}
2527
2528static void
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002529qla2x00_do_work(struct scsi_qla_host *vha)
Andrew Vasquez0971de72008-04-03 13:13:18 -07002530{
2531 struct qla_work_evt *e;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002532 struct qla_hw_data *ha = vha->hw;
Andrew Vasquez0971de72008-04-03 13:13:18 -07002533
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002534 spin_lock_irq(&ha->hardware_lock);
2535 while (!list_empty(&vha->work_list)) {
2536 e = list_entry(vha->work_list.next, struct qla_work_evt, list);
Andrew Vasquez0971de72008-04-03 13:13:18 -07002537 list_del_init(&e->list);
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002538 spin_unlock_irq(&ha->hardware_lock);
Andrew Vasquez0971de72008-04-03 13:13:18 -07002539
2540 switch (e->type) {
2541 case QLA_EVT_AEN:
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002542 fc_host_post_event(vha->host, fc_get_event_number(),
Andrew Vasquez0971de72008-04-03 13:13:18 -07002543 e->u.aen.code, e->u.aen.data);
2544 break;
2545 }
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;
2558 uint8_t status;
2559 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);