blob: 9e656296b757cdffbe2fad1ebf1e877a04f1d97f [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>
Andrew Vasquez3420d362009-10-13 15:16:45 -070014#include <linux/kobject.h>
Tejun Heo5a0e3ad2010-03-24 17:04:11 +090015#include <linux/slab.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070016
17#include <scsi/scsi_tcq.h>
18#include <scsi/scsicam.h>
19#include <scsi/scsi_transport.h>
20#include <scsi/scsi_transport_fc.h>
21
22/*
23 * Driver version
24 */
25char qla2x00_version_str[40];
26
Harish Zunjarrao6a03b4c2010-05-04 15:01:24 -070027static int apidev_major;
28
Linus Torvalds1da177e2005-04-16 15:20:36 -070029/*
30 * SRB allocation cache
31 */
Christoph Lametere18b8902006-12-06 20:33:20 -080032static struct kmem_cache *srb_cachep;
Linus Torvalds1da177e2005-04-16 15:20:36 -070033
Giridhar Malavalia9083012010-04-12 17:59:55 -070034/*
35 * CT6 CTX allocation cache
36 */
37static struct kmem_cache *ctx_cachep;
38
Linus Torvalds1da177e2005-04-16 15:20:36 -070039int ql2xlogintimeout = 20;
40module_param(ql2xlogintimeout, int, S_IRUGO|S_IRUSR);
41MODULE_PARM_DESC(ql2xlogintimeout,
42 "Login timeout value in seconds.");
43
Andrew Vasqueza7b61842007-05-07 07:42:59 -070044int qlport_down_retry;
Linus Torvalds1da177e2005-04-16 15:20:36 -070045module_param(qlport_down_retry, int, S_IRUGO|S_IRUSR);
46MODULE_PARM_DESC(qlport_down_retry,
Jesper Juhl900d9f92006-06-30 02:33:07 -070047 "Maximum number of command retries to a port that returns "
Linus Torvalds1da177e2005-04-16 15:20:36 -070048 "a PORT-DOWN status.");
49
Linus Torvalds1da177e2005-04-16 15:20:36 -070050int ql2xplogiabsentdevice;
51module_param(ql2xplogiabsentdevice, int, S_IRUGO|S_IWUSR);
52MODULE_PARM_DESC(ql2xplogiabsentdevice,
53 "Option to enable PLOGI to devices that are not present after "
Jesper Juhl900d9f92006-06-30 02:33:07 -070054 "a Fabric scan. This is needed for several broken switches. "
Linus Torvalds1da177e2005-04-16 15:20:36 -070055 "Default is 0 - no PLOGI. 1 - perfom PLOGI.");
56
Linus Torvalds1da177e2005-04-16 15:20:36 -070057int ql2xloginretrycount = 0;
58module_param(ql2xloginretrycount, int, S_IRUGO|S_IRUSR);
59MODULE_PARM_DESC(ql2xloginretrycount,
60 "Specify an alternate value for the NVRAM login retry count.");
61
Andrew Vasqueza7a167b2006-06-23 16:10:29 -070062int ql2xallocfwdump = 1;
63module_param(ql2xallocfwdump, int, S_IRUGO|S_IRUSR);
64MODULE_PARM_DESC(ql2xallocfwdump,
65 "Option to enable allocation of memory for a firmware dump "
66 "during HBA initialization. Memory allocation requirements "
67 "vary by ISP type. Default is 1 - allocate memory.");
68
Andrew Vasquez11010fe2006-10-06 09:54:59 -070069int ql2xextended_error_logging;
Andrew Vasquez27d94032007-03-12 10:41:30 -070070module_param(ql2xextended_error_logging, int, S_IRUGO|S_IWUSR);
Andrew Vasquez11010fe2006-10-06 09:54:59 -070071MODULE_PARM_DESC(ql2xextended_error_logging,
Andrew Vasquez01819442006-06-23 16:11:10 -070072 "Option to enable extended error logging, "
73 "Default is 0 - no logging. 1 - log errors.");
74
Giridhar Malavalia9083012010-04-12 17:59:55 -070075int ql2xshiftctondsd = 6;
76module_param(ql2xshiftctondsd, int, S_IRUGO|S_IRUSR);
77MODULE_PARM_DESC(ql2xshiftctondsd,
78 "Set to control shifting of command type processing "
79 "based on total number of SG elements.");
80
Linus Torvalds1da177e2005-04-16 15:20:36 -070081static void qla2x00_free_device(scsi_qla_host_t *);
82
Andrew Vasquez7e47e5c2008-04-24 15:21:26 -070083int ql2xfdmienable=1;
Andrew Vasquezcca53352005-08-26 19:08:30 -070084module_param(ql2xfdmienable, int, S_IRUGO|S_IRUSR);
85MODULE_PARM_DESC(ql2xfdmienable,
Ferenc Wagner7794a5a2010-03-23 18:14:59 +010086 "Enables FDMI registrations. "
87 "0 - no FDMI. Default is 1 - perform FDMI.");
Andrew Vasquezcca53352005-08-26 19:08:30 -070088
Andrew Vasquezdf7baa52006-10-13 09:33:39 -070089#define MAX_Q_DEPTH 32
90static int ql2xmaxqdepth = MAX_Q_DEPTH;
91module_param(ql2xmaxqdepth, int, S_IRUGO|S_IWUSR);
92MODULE_PARM_DESC(ql2xmaxqdepth,
93 "Maximum queue depth to report for target devices.");
94
Arun Easibad75002010-05-04 15:01:30 -070095/* Do not change the value of this after module load */
96int ql2xenabledif = 1;
97module_param(ql2xenabledif, int, S_IRUGO|S_IWUSR);
98MODULE_PARM_DESC(ql2xenabledif,
99 " Enable T10-CRC-DIF "
100 " Default is 0 - No DIF Support. 1 - Enable it");
101
102int ql2xenablehba_err_chk;
103module_param(ql2xenablehba_err_chk, int, S_IRUGO|S_IWUSR);
104MODULE_PARM_DESC(ql2xenablehba_err_chk,
105 " Enable T10-CRC-DIF Error isolation by HBA"
106 " Default is 0 - Error isolation disabled, 1 - Enable it");
107
Andrew Vasqueze5896bd2008-07-10 16:55:52 -0700108int ql2xiidmaenable=1;
109module_param(ql2xiidmaenable, int, S_IRUGO|S_IRUSR);
110MODULE_PARM_DESC(ql2xiidmaenable,
111 "Enables iIDMA settings "
112 "Default is 1 - perform iIDMA. 0 - no iIDMA.");
113
Anirban Chakraborty73208df2008-12-09 16:45:39 -0800114int ql2xmaxqueues = 1;
115module_param(ql2xmaxqueues, int, S_IRUGO|S_IRUSR);
116MODULE_PARM_DESC(ql2xmaxqueues,
117 "Enables MQ settings "
118 "Default is 1 for single queue. Set it to number \
119 of queues in MQ mode.");
Anirban Chakraborty68ca9492009-04-06 22:33:41 -0700120
121int ql2xmultique_tag;
122module_param(ql2xmultique_tag, int, S_IRUGO|S_IRUSR);
123MODULE_PARM_DESC(ql2xmultique_tag,
124 "Enables CPU affinity settings for the driver "
125 "Default is 0 for no affinity of request and response IO. "
126 "Set it to 1 to turn on the cpu affinity.");
Andrew Vasqueze337d902009-04-06 22:33:49 -0700127
128int ql2xfwloadbin;
129module_param(ql2xfwloadbin, int, S_IRUGO|S_IRUSR);
130MODULE_PARM_DESC(ql2xfwloadbin,
131 "Option to specify location from which to load ISP firmware:\n"
132 " 2 -- load firmware via the request_firmware() (hotplug)\n"
133 " interface.\n"
134 " 1 -- load firmware from flash.\n"
135 " 0 -- use default semantics.\n");
136
Andrew Vasquezae97c912010-02-18 10:07:28 -0800137int ql2xetsenable;
138module_param(ql2xetsenable, int, S_IRUGO|S_IRUSR);
139MODULE_PARM_DESC(ql2xetsenable,
140 "Enables firmware ETS burst."
141 "Default is 0 - skip ETS enablement.");
142
Giridhar Malavalia9083012010-04-12 17:59:55 -0700143int ql2xdbwr;
144module_param(ql2xdbwr, int, S_IRUGO|S_IRUSR);
145MODULE_PARM_DESC(ql2xdbwr,
146 "Option to specify scheme for request queue posting\n"
147 " 0 -- Regular doorbell.\n"
148 " 1 -- CAMRAM doorbell (faster).\n");
149
150int ql2xdontresethba;
151module_param(ql2xdontresethba, int, S_IRUGO|S_IRUSR);
152MODULE_PARM_DESC(ql2xdontresethba,
153 "Option to specify reset behaviour\n"
154 " 0 (Default) -- Reset on failure.\n"
155 " 1 -- Do not reset on failure.\n");
156
Giridhar Malavalif4c496c2010-05-04 15:01:33 -0700157int ql2xtargetreset = 1;
158module_param(ql2xtargetreset, int, S_IRUGO|S_IRUSR);
159MODULE_PARM_DESC(ql2xtargetreset,
160 "Enable target reset."
161 "Default is 1 - use hw defaults.");
162
Giridhar Malavalia9083012010-04-12 17:59:55 -0700163
Madhuranath Iyengar38222632010-05-04 15:01:29 -0700164int ql2xasynctmfenable;
165module_param(ql2xasynctmfenable, int, S_IRUGO|S_IRUSR);
166MODULE_PARM_DESC(ql2xasynctmfenable,
167 "Enables issue of TM IOCBs asynchronously via IOCB mechanism"
168 "Default is 0 - Issue TM IOCBs via mailbox mechanism.");
Linus Torvalds1da177e2005-04-16 15:20:36 -0700169/*
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700170 * SCSI host template entry points
Linus Torvalds1da177e2005-04-16 15:20:36 -0700171 */
172static int qla2xxx_slave_configure(struct scsi_device * device);
f4f051e2005-04-17 15:02:26 -0500173static int qla2xxx_slave_alloc(struct scsi_device *);
Andrew Vasquez1e99e332006-11-22 08:24:48 -0800174static int qla2xxx_scan_finished(struct Scsi_Host *, unsigned long time);
175static void qla2xxx_scan_start(struct Scsi_Host *);
f4f051e2005-04-17 15:02:26 -0500176static void qla2xxx_slave_destroy(struct scsi_device *);
Giridhar Malavalia5326f82009-03-24 09:07:56 -0700177static int qla2xxx_queuecommand(struct scsi_cmnd *cmd,
Andrew Vasquezfca29702005-07-06 10:31:47 -0700178 void (*fn)(struct scsi_cmnd *));
Linus Torvalds1da177e2005-04-16 15:20:36 -0700179static int qla2xxx_eh_abort(struct scsi_cmnd *);
180static int qla2xxx_eh_device_reset(struct scsi_cmnd *);
Andrew Vasquez523ec772008-04-03 13:13:24 -0700181static int qla2xxx_eh_target_reset(struct scsi_cmnd *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700182static int qla2xxx_eh_bus_reset(struct scsi_cmnd *);
183static int qla2xxx_eh_host_reset(struct scsi_cmnd *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700184
Mike Christiee881a172009-10-15 17:46:39 -0700185static int qla2x00_change_queue_depth(struct scsi_device *, int, int);
Andrew Vasquezce7e4af2005-08-26 19:09:30 -0700186static int qla2x00_change_queue_type(struct scsi_device *, int);
187
Giridhar Malavalia5326f82009-03-24 09:07:56 -0700188struct scsi_host_template qla2xxx_driver_template = {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700189 .module = THIS_MODULE,
Andrew Vasquezcb630672006-05-17 15:09:45 -0700190 .name = QLA2XXX_DRIVER_NAME,
Giridhar Malavalia5326f82009-03-24 09:07:56 -0700191 .queuecommand = qla2xxx_queuecommand,
Andrew Vasquezfca29702005-07-06 10:31:47 -0700192
193 .eh_abort_handler = qla2xxx_eh_abort,
194 .eh_device_reset_handler = qla2xxx_eh_device_reset,
Andrew Vasquez523ec772008-04-03 13:13:24 -0700195 .eh_target_reset_handler = qla2xxx_eh_target_reset,
Andrew Vasquezfca29702005-07-06 10:31:47 -0700196 .eh_bus_reset_handler = qla2xxx_eh_bus_reset,
197 .eh_host_reset_handler = qla2xxx_eh_host_reset,
198
199 .slave_configure = qla2xxx_slave_configure,
200
201 .slave_alloc = qla2xxx_slave_alloc,
202 .slave_destroy = qla2xxx_slave_destroy,
Andrew Vasquezed677082007-03-12 10:41:27 -0700203 .scan_finished = qla2xxx_scan_finished,
204 .scan_start = qla2xxx_scan_start,
Andrew Vasquezce7e4af2005-08-26 19:09:30 -0700205 .change_queue_depth = qla2x00_change_queue_depth,
206 .change_queue_type = qla2x00_change_queue_type,
Andrew Vasquezfca29702005-07-06 10:31:47 -0700207 .this_id = -1,
208 .cmd_per_lun = 3,
209 .use_clustering = ENABLE_CLUSTERING,
210 .sg_tablesize = SG_ALL,
211
212 .max_sectors = 0xFFFF,
Andrew Vasquezafb046e2005-08-26 19:09:40 -0700213 .shost_attrs = qla2x00_host_attrs,
Andrew Vasquezfca29702005-07-06 10:31:47 -0700214};
215
Linus Torvalds1da177e2005-04-16 15:20:36 -0700216static struct scsi_transport_template *qla2xxx_transport_template = NULL;
Seokmann Ju2c3dfe32007-07-05 13:16:51 -0700217struct scsi_transport_template *qla2xxx_transport_vport_template = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700218
Linus Torvalds1da177e2005-04-16 15:20:36 -0700219/* TODO Convert to inlines
220 *
221 * Timer routines
222 */
Linus Torvalds1da177e2005-04-16 15:20:36 -0700223
Seokmann Ju2c3dfe32007-07-05 13:16:51 -0700224__inline__ void
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800225qla2x00_start_timer(scsi_qla_host_t *vha, void *func, unsigned long interval)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700226{
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800227 init_timer(&vha->timer);
228 vha->timer.expires = jiffies + interval * HZ;
229 vha->timer.data = (unsigned long)vha;
230 vha->timer.function = (void (*)(unsigned long))func;
231 add_timer(&vha->timer);
232 vha->timer_active = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700233}
234
235static inline void
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800236qla2x00_restart_timer(scsi_qla_host_t *vha, unsigned long interval)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700237{
Giridhar Malavalia9083012010-04-12 17:59:55 -0700238 /* Currently used for 82XX only. */
239 if (vha->device_flags & DFLG_DEV_FAILED)
240 return;
241
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800242 mod_timer(&vha->timer, jiffies + interval * HZ);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700243}
244
Adrian Bunka824ebb2008-01-17 09:02:15 -0800245static __inline__ void
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800246qla2x00_stop_timer(scsi_qla_host_t *vha)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700247{
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800248 del_timer_sync(&vha->timer);
249 vha->timer_active = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700250}
251
Linus Torvalds1da177e2005-04-16 15:20:36 -0700252static int qla2x00_do_dpc(void *data);
253
254static void qla2x00_rst_aen(scsi_qla_host_t *);
255
Anirban Chakraborty73208df2008-12-09 16:45:39 -0800256static int qla2x00_mem_alloc(struct qla_hw_data *, uint16_t, uint16_t,
257 struct req_que **, struct rsp_que **);
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800258static void qla2x00_mem_free(struct qla_hw_data *);
259static void qla2x00_sp_free_dma(srb_t *);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700260
Linus Torvalds1da177e2005-04-16 15:20:36 -0700261/* -------------------------------------------------------------------------- */
Anirban Chakraborty73208df2008-12-09 16:45:39 -0800262static int qla2x00_alloc_queues(struct qla_hw_data *ha)
263{
Anirban Chakraborty2afa19a2009-04-06 22:33:40 -0700264 ha->req_q_map = kzalloc(sizeof(struct req_que *) * ha->max_req_queues,
Anirban Chakraborty73208df2008-12-09 16:45:39 -0800265 GFP_KERNEL);
266 if (!ha->req_q_map) {
267 qla_printk(KERN_WARNING, ha,
268 "Unable to allocate memory for request queue ptrs\n");
269 goto fail_req_map;
270 }
271
Anirban Chakraborty2afa19a2009-04-06 22:33:40 -0700272 ha->rsp_q_map = kzalloc(sizeof(struct rsp_que *) * ha->max_rsp_queues,
Anirban Chakraborty73208df2008-12-09 16:45:39 -0800273 GFP_KERNEL);
274 if (!ha->rsp_q_map) {
275 qla_printk(KERN_WARNING, ha,
276 "Unable to allocate memory for response queue ptrs\n");
277 goto fail_rsp_map;
278 }
279 set_bit(0, ha->rsp_qid_map);
280 set_bit(0, ha->req_qid_map);
281 return 1;
282
283fail_rsp_map:
284 kfree(ha->req_q_map);
285 ha->req_q_map = NULL;
286fail_req_map:
287 return -ENOMEM;
288}
289
Anirban Chakraborty2afa19a2009-04-06 22:33:40 -0700290static void qla2x00_free_req_que(struct qla_hw_data *ha, struct req_que *req)
Anirban Chakraborty73208df2008-12-09 16:45:39 -0800291{
Anirban Chakraborty73208df2008-12-09 16:45:39 -0800292 if (req && req->ring)
293 dma_free_coherent(&ha->pdev->dev,
294 (req->length + 1) * sizeof(request_t),
295 req->ring, req->dma);
296
297 kfree(req);
298 req = NULL;
299}
300
Anirban Chakraborty2afa19a2009-04-06 22:33:40 -0700301static void qla2x00_free_rsp_que(struct qla_hw_data *ha, struct rsp_que *rsp)
302{
303 if (rsp && rsp->ring)
304 dma_free_coherent(&ha->pdev->dev,
305 (rsp->length + 1) * sizeof(response_t),
306 rsp->ring, rsp->dma);
307
308 kfree(rsp);
309 rsp = NULL;
310}
311
Anirban Chakraborty73208df2008-12-09 16:45:39 -0800312static void qla2x00_free_queues(struct qla_hw_data *ha)
313{
314 struct req_que *req;
315 struct rsp_que *rsp;
316 int cnt;
317
Anirban Chakraborty2afa19a2009-04-06 22:33:40 -0700318 for (cnt = 0; cnt < ha->max_req_queues; cnt++) {
Anirban Chakraborty73208df2008-12-09 16:45:39 -0800319 req = ha->req_q_map[cnt];
Anirban Chakraborty2afa19a2009-04-06 22:33:40 -0700320 qla2x00_free_req_que(ha, req);
321 }
322 kfree(ha->req_q_map);
323 ha->req_q_map = NULL;
324
325 for (cnt = 0; cnt < ha->max_rsp_queues; cnt++) {
326 rsp = ha->rsp_q_map[cnt];
327 qla2x00_free_rsp_que(ha, rsp);
Anirban Chakraborty73208df2008-12-09 16:45:39 -0800328 }
329 kfree(ha->rsp_q_map);
330 ha->rsp_q_map = NULL;
Anirban Chakraborty73208df2008-12-09 16:45:39 -0800331}
332
Anirban Chakraborty68ca9492009-04-06 22:33:41 -0700333static int qla25xx_setup_mode(struct scsi_qla_host *vha)
334{
335 uint16_t options = 0;
336 int ques, req, ret;
337 struct qla_hw_data *ha = vha->hw;
338
Anirban Chakraborty7163ea82009-08-05 09:18:40 -0700339 if (!(ha->fw_attributes & BIT_6)) {
340 qla_printk(KERN_INFO, ha,
341 "Firmware is not multi-queue capable\n");
342 goto fail;
343 }
Anirban Chakraborty68ca9492009-04-06 22:33:41 -0700344 if (ql2xmultique_tag) {
Anirban Chakraborty68ca9492009-04-06 22:33:41 -0700345 /* create a request queue for IO */
346 options |= BIT_7;
347 req = qla25xx_create_req_que(ha, options, 0, 0, -1,
348 QLA_DEFAULT_QUE_QOS);
349 if (!req) {
350 qla_printk(KERN_WARNING, ha,
351 "Can't create request queue\n");
352 goto fail;
353 }
Anirban Chakraborty7163ea82009-08-05 09:18:40 -0700354 ha->wq = create_workqueue("qla2xxx_wq");
Anirban Chakraborty68ca9492009-04-06 22:33:41 -0700355 vha->req = ha->req_q_map[req];
356 options |= BIT_1;
357 for (ques = 1; ques < ha->max_rsp_queues; ques++) {
358 ret = qla25xx_create_rsp_que(ha, options, 0, 0, req);
359 if (!ret) {
360 qla_printk(KERN_WARNING, ha,
361 "Response Queue create failed\n");
362 goto fail2;
363 }
364 }
Anirban Chakraborty7163ea82009-08-05 09:18:40 -0700365 ha->flags.cpu_affinity_enabled = 1;
366
Anirban Chakraborty68ca9492009-04-06 22:33:41 -0700367 DEBUG2(qla_printk(KERN_INFO, ha,
368 "CPU affinity mode enabled, no. of response"
369 " queues:%d, no. of request queues:%d\n",
370 ha->max_rsp_queues, ha->max_req_queues));
371 }
372 return 0;
373fail2:
374 qla25xx_delete_queues(vha);
Anirban Chakraborty7163ea82009-08-05 09:18:40 -0700375 destroy_workqueue(ha->wq);
376 ha->wq = NULL;
Anirban Chakraborty68ca9492009-04-06 22:33:41 -0700377fail:
378 ha->mqenable = 0;
Anirban Chakraborty7163ea82009-08-05 09:18:40 -0700379 kfree(ha->req_q_map);
380 kfree(ha->rsp_q_map);
381 ha->max_req_queues = ha->max_rsp_queues = 1;
Anirban Chakraborty68ca9492009-04-06 22:33:41 -0700382 return 1;
383}
384
Linus Torvalds1da177e2005-04-16 15:20:36 -0700385static char *
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800386qla2x00_pci_info_str(struct scsi_qla_host *vha, char *str)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700387{
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800388 struct qla_hw_data *ha = vha->hw;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700389 static char *pci_bus_modes[] = {
390 "33", "66", "100", "133",
391 };
392 uint16_t pci_bus;
393
394 strcpy(str, "PCI");
395 pci_bus = (ha->pci_attr & (BIT_9 | BIT_10)) >> 9;
396 if (pci_bus) {
397 strcat(str, "-X (");
398 strcat(str, pci_bus_modes[pci_bus]);
399 } else {
400 pci_bus = (ha->pci_attr & BIT_8) >> 8;
401 strcat(str, " (");
402 strcat(str, pci_bus_modes[pci_bus]);
403 }
404 strcat(str, " MHz)");
405
406 return (str);
407}
408
Andrew Vasquezfca29702005-07-06 10:31:47 -0700409static char *
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800410qla24xx_pci_info_str(struct scsi_qla_host *vha, char *str)
Andrew Vasquezfca29702005-07-06 10:31:47 -0700411{
412 static char *pci_bus_modes[] = { "33", "66", "100", "133", };
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800413 struct qla_hw_data *ha = vha->hw;
Andrew Vasquezfca29702005-07-06 10:31:47 -0700414 uint32_t pci_bus;
415 int pcie_reg;
416
417 pcie_reg = pci_find_capability(ha->pdev, PCI_CAP_ID_EXP);
418 if (pcie_reg) {
419 char lwstr[6];
420 uint16_t pcie_lstat, lspeed, lwidth;
421
422 pcie_reg += 0x12;
423 pci_read_config_word(ha->pdev, pcie_reg, &pcie_lstat);
424 lspeed = pcie_lstat & (BIT_0 | BIT_1 | BIT_2 | BIT_3);
425 lwidth = (pcie_lstat &
426 (BIT_4 | BIT_5 | BIT_6 | BIT_7 | BIT_8 | BIT_9)) >> 4;
427
428 strcpy(str, "PCIe (");
429 if (lspeed == 1)
Andrew Vasquezc87a0d82008-04-03 13:13:21 -0700430 strcat(str, "2.5GT/s ");
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -0700431 else if (lspeed == 2)
Andrew Vasquezc87a0d82008-04-03 13:13:21 -0700432 strcat(str, "5.0GT/s ");
Andrew Vasquezfca29702005-07-06 10:31:47 -0700433 else
434 strcat(str, "<unknown> ");
435 snprintf(lwstr, sizeof(lwstr), "x%d)", lwidth);
436 strcat(str, lwstr);
437
438 return str;
439 }
440
441 strcpy(str, "PCI");
442 pci_bus = (ha->pci_attr & CSRX_PCIX_BUS_MODE_MASK) >> 8;
443 if (pci_bus == 0 || pci_bus == 8) {
444 strcat(str, " (");
445 strcat(str, pci_bus_modes[pci_bus >> 3]);
446 } else {
447 strcat(str, "-X ");
448 if (pci_bus & BIT_2)
449 strcat(str, "Mode 2");
450 else
451 strcat(str, "Mode 1");
452 strcat(str, " (");
453 strcat(str, pci_bus_modes[pci_bus & ~BIT_2]);
454 }
455 strcat(str, " MHz)");
456
457 return str;
458}
459
Adrian Bunke5f82ab2006-11-08 19:55:50 -0800460static char *
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800461qla2x00_fw_version_str(struct scsi_qla_host *vha, char *str)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700462{
463 char un_str[10];
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800464 struct qla_hw_data *ha = vha->hw;
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700465
Linus Torvalds1da177e2005-04-16 15:20:36 -0700466 sprintf(str, "%d.%02d.%02d ", ha->fw_major_version,
467 ha->fw_minor_version,
468 ha->fw_subminor_version);
469
470 if (ha->fw_attributes & BIT_9) {
471 strcat(str, "FLX");
472 return (str);
473 }
474
475 switch (ha->fw_attributes & 0xFF) {
476 case 0x7:
477 strcat(str, "EF");
478 break;
479 case 0x17:
480 strcat(str, "TP");
481 break;
482 case 0x37:
483 strcat(str, "IP");
484 break;
485 case 0x77:
486 strcat(str, "VI");
487 break;
488 default:
489 sprintf(un_str, "(%x)", ha->fw_attributes);
490 strcat(str, un_str);
491 break;
492 }
493 if (ha->fw_attributes & 0x100)
494 strcat(str, "X");
495
496 return (str);
497}
498
Adrian Bunke5f82ab2006-11-08 19:55:50 -0800499static char *
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800500qla24xx_fw_version_str(struct scsi_qla_host *vha, char *str)
Andrew Vasquezfca29702005-07-06 10:31:47 -0700501{
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800502 struct qla_hw_data *ha = vha->hw;
Andrew Vasquezf0883ac2005-07-08 17:58:43 -0700503
Andrew Vasquez3a03eb72009-01-05 11:18:11 -0800504 sprintf(str, "%d.%02d.%02d (%x)", ha->fw_major_version,
505 ha->fw_minor_version, ha->fw_subminor_version, ha->fw_attributes);
Andrew Vasquezfca29702005-07-06 10:31:47 -0700506 return str;
Andrew Vasquezfca29702005-07-06 10:31:47 -0700507}
508
509static inline srb_t *
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800510qla2x00_get_new_sp(scsi_qla_host_t *vha, fc_port_t *fcport,
Andrew Vasquezfca29702005-07-06 10:31:47 -0700511 struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
512{
513 srb_t *sp;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800514 struct qla_hw_data *ha = vha->hw;
Andrew Vasquezfca29702005-07-06 10:31:47 -0700515
516 sp = mempool_alloc(ha->srb_mempool, GFP_ATOMIC);
517 if (!sp)
518 return sp;
519
Giridhar Malavali083a4692010-05-28 15:08:18 -0700520 atomic_set(&sp->ref_count, 1);
Andrew Vasquezfca29702005-07-06 10:31:47 -0700521 sp->fcport = fcport;
522 sp->cmd = cmd;
523 sp->flags = 0;
524 CMD_SP(cmd) = (void *)sp;
525 cmd->scsi_done = done;
Andrew Vasquezcf53b062009-08-20 11:06:04 -0700526 sp->ctx = NULL;
Andrew Vasquezfca29702005-07-06 10:31:47 -0700527
528 return sp;
529}
530
Linus Torvalds1da177e2005-04-16 15:20:36 -0700531static int
Giridhar Malavalia5326f82009-03-24 09:07:56 -0700532qla2xxx_queuecommand(struct scsi_cmnd *cmd, void (*done)(struct scsi_cmnd *))
Andrew Vasquezfca29702005-07-06 10:31:47 -0700533{
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800534 scsi_qla_host_t *vha = shost_priv(cmd->device->host);
Andrew Vasquezfca29702005-07-06 10:31:47 -0700535 fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata;
James.Smart@Emulex.Com19a7b4a2005-10-18 12:03:35 -0400536 struct fc_rport *rport = starget_to_rport(scsi_target(cmd->device));
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800537 struct qla_hw_data *ha = vha->hw;
538 struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev);
Andrew Vasquezfca29702005-07-06 10:31:47 -0700539 srb_t *sp;
540 int rval;
541
Andrew Vasquez85880802009-12-15 21:29:46 -0800542 if (ha->flags.eeh_busy) {
543 if (ha->flags.pci_channel_io_perm_failure)
Seokmann Jub9b12f72009-03-24 09:08:18 -0700544 cmd->result = DID_NO_CONNECT << 16;
Andrew Vasquez85880802009-12-15 21:29:46 -0800545 else
546 cmd->result = DID_REQUEUE << 16;
Seokmann Ju14e660e2007-09-20 14:07:36 -0700547 goto qc24_fail_command;
548 }
549
James.Smart@Emulex.Com19a7b4a2005-10-18 12:03:35 -0400550 rval = fc_remote_port_chkready(rport);
551 if (rval) {
552 cmd->result = rval;
Andrew Vasquezfca29702005-07-06 10:31:47 -0700553 goto qc24_fail_command;
554 }
555
andrew.vasquez@qlogic.com387f96b2006-02-07 08:45:45 -0800556 /* Close window on fcport/rport state-transitioning. */
Mike Christie7b594132008-08-17 15:24:40 -0500557 if (fcport->drport)
558 goto qc24_target_busy;
andrew.vasquez@qlogic.com387f96b2006-02-07 08:45:45 -0800559
Arun Easibad75002010-05-04 15:01:30 -0700560 if (!vha->flags.difdix_supported &&
561 scsi_get_prot_op(cmd) != SCSI_PROT_NORMAL) {
562 DEBUG2(qla_printk(KERN_ERR, ha,
563 "DIF Cap Not Reg, fail DIF capable cmd's:%x\n",
564 cmd->cmnd[0]));
565 cmd->result = DID_NO_CONNECT << 16;
566 goto qc24_fail_command;
567 }
Andrew Vasquezfca29702005-07-06 10:31:47 -0700568 if (atomic_read(&fcport->state) != FCS_ONLINE) {
569 if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD ||
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800570 atomic_read(&base_vha->loop_state) == LOOP_DEAD) {
Andrew Vasquezfca29702005-07-06 10:31:47 -0700571 cmd->result = DID_NO_CONNECT << 16;
572 goto qc24_fail_command;
573 }
Mike Christie7b594132008-08-17 15:24:40 -0500574 goto qc24_target_busy;
Andrew Vasquezfca29702005-07-06 10:31:47 -0700575 }
576
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800577 spin_unlock_irq(vha->host->host_lock);
Andrew Vasquezfca29702005-07-06 10:31:47 -0700578
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800579 sp = qla2x00_get_new_sp(base_vha, fcport, cmd, done);
Andrew Vasquezfca29702005-07-06 10:31:47 -0700580 if (!sp)
581 goto qc24_host_busy_lock;
582
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800583 rval = ha->isp_ops->start_scsi(sp);
Andrew Vasquezfca29702005-07-06 10:31:47 -0700584 if (rval != QLA_SUCCESS)
585 goto qc24_host_busy_free_sp;
586
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800587 spin_lock_irq(vha->host->host_lock);
Andrew Vasquezfca29702005-07-06 10:31:47 -0700588
589 return 0;
590
591qc24_host_busy_free_sp:
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800592 qla2x00_sp_free_dma(sp);
593 mempool_free(sp, ha->srb_mempool);
Andrew Vasquezfca29702005-07-06 10:31:47 -0700594
595qc24_host_busy_lock:
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800596 spin_lock_irq(vha->host->host_lock);
Andrew Vasquezfca29702005-07-06 10:31:47 -0700597 return SCSI_MLQUEUE_HOST_BUSY;
598
Mike Christie7b594132008-08-17 15:24:40 -0500599qc24_target_busy:
600 return SCSI_MLQUEUE_TARGET_BUSY;
601
Andrew Vasquezfca29702005-07-06 10:31:47 -0700602qc24_fail_command:
603 done(cmd);
604
605 return 0;
606}
607
608
Linus Torvalds1da177e2005-04-16 15:20:36 -0700609/*
610 * qla2x00_eh_wait_on_command
611 * Waits for the command to be returned by the Firmware for some
612 * max time.
613 *
614 * Input:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700615 * cmd = Scsi Command to wait on.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700616 *
617 * Return:
618 * Not Found : 0
619 * Found : 1
620 */
621static int
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800622qla2x00_eh_wait_on_command(struct scsi_cmnd *cmd)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700623{
Andrew Vasquezfe74c712005-08-26 19:10:10 -0700624#define ABORT_POLLING_PERIOD 1000
625#define ABORT_WAIT_ITER ((10 * 1000) / (ABORT_POLLING_PERIOD))
f4f051e2005-04-17 15:02:26 -0500626 unsigned long wait_iter = ABORT_WAIT_ITER;
Andrew Vasquez85880802009-12-15 21:29:46 -0800627 scsi_qla_host_t *vha = shost_priv(cmd->device->host);
628 struct qla_hw_data *ha = vha->hw;
f4f051e2005-04-17 15:02:26 -0500629 int ret = QLA_SUCCESS;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700630
Andrew Vasquez85880802009-12-15 21:29:46 -0800631 if (unlikely(pci_channel_offline(ha->pdev)) || ha->flags.eeh_busy) {
632 DEBUG17(qla_printk(KERN_WARNING, ha, "return:eh_wait\n"));
633 return ret;
634 }
635
Lalit Chandivaded9704322009-08-25 11:36:18 -0700636 while (CMD_SP(cmd) && wait_iter--) {
Andrew Vasquezfe74c712005-08-26 19:10:10 -0700637 msleep(ABORT_POLLING_PERIOD);
f4f051e2005-04-17 15:02:26 -0500638 }
639 if (CMD_SP(cmd))
640 ret = QLA_FUNCTION_FAILED;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700641
f4f051e2005-04-17 15:02:26 -0500642 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700643}
644
645/*
646 * qla2x00_wait_for_hba_online
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700647 * Wait till the HBA is online after going through
Linus Torvalds1da177e2005-04-16 15:20:36 -0700648 * <= MAX_RETRIES_OF_ISP_ABORT or
649 * finally HBA is disabled ie marked offline
650 *
651 * Input:
652 * ha - pointer to host adapter structure
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700653 *
654 * Note:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700655 * Does context switching-Release SPIN_LOCK
656 * (if any) before calling this routine.
657 *
658 * Return:
659 * Success (Adapter is online) : 0
660 * Failed (Adapter is offline/disabled) : 1
661 */
andrew.vasquez@qlogic.com854165f2006-01-31 16:05:17 -0800662int
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800663qla2x00_wait_for_hba_online(scsi_qla_host_t *vha)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700664{
Andrew Vasquezfca29702005-07-06 10:31:47 -0700665 int return_status;
666 unsigned long wait_online;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800667 struct qla_hw_data *ha = vha->hw;
668 scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700669
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700670 wait_online = jiffies + (MAX_LOOP_TIMEOUT * HZ);
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800671 while (((test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags)) ||
672 test_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags) ||
673 test_bit(ISP_ABORT_RETRY, &base_vha->dpc_flags) ||
674 ha->dpc_active) && time_before(jiffies, wait_online)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -0700675
676 msleep(1000);
677 }
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800678 if (base_vha->flags.online)
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700679 return_status = QLA_SUCCESS;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700680 else
681 return_status = QLA_FUNCTION_FAILED;
682
Linus Torvalds1da177e2005-04-16 15:20:36 -0700683 return (return_status);
684}
685
Lalit Chandivade86fbee82010-05-04 15:01:32 -0700686/*
687 * qla2x00_wait_for_reset_ready
688 * Wait till the HBA is online after going through
689 * <= MAX_RETRIES_OF_ISP_ABORT or
690 * finally HBA is disabled ie marked offline or flash
691 * operations are in progress.
692 *
693 * Input:
694 * ha - pointer to host adapter structure
695 *
696 * Note:
697 * Does context switching-Release SPIN_LOCK
698 * (if any) before calling this routine.
699 *
700 * Return:
701 * Success (Adapter is online/no flash ops) : 0
702 * Failed (Adapter is offline/disabled/flash ops in progress) : 1
703 */
704int
705qla2x00_wait_for_reset_ready(scsi_qla_host_t *vha)
706{
707 int return_status;
708 unsigned long wait_online;
709 struct qla_hw_data *ha = vha->hw;
710 scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev);
711
712 wait_online = jiffies + (MAX_LOOP_TIMEOUT * HZ);
713 while (((test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags)) ||
714 test_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags) ||
715 test_bit(ISP_ABORT_RETRY, &base_vha->dpc_flags) ||
716 ha->optrom_state != QLA_SWAITING ||
717 ha->dpc_active) && time_before(jiffies, wait_online))
718 msleep(1000);
719
720 if (base_vha->flags.online && ha->optrom_state == QLA_SWAITING)
721 return_status = QLA_SUCCESS;
722 else
723 return_status = QLA_FUNCTION_FAILED;
724
725 DEBUG2(printk("%s return_status=%d\n", __func__, return_status));
726
727 return return_status;
728}
729
Lalit Chandivade2533cf62009-03-24 09:08:07 -0700730int
731qla2x00_wait_for_chip_reset(scsi_qla_host_t *vha)
732{
733 int return_status;
734 unsigned long wait_reset;
735 struct qla_hw_data *ha = vha->hw;
736 scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev);
737
738 wait_reset = jiffies + (MAX_LOOP_TIMEOUT * HZ);
739 while (((test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags)) ||
740 test_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags) ||
741 test_bit(ISP_ABORT_RETRY, &base_vha->dpc_flags) ||
742 ha->dpc_active) && time_before(jiffies, wait_reset)) {
743
744 msleep(1000);
745
746 if (!test_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags) &&
747 ha->flags.chip_reset_done)
748 break;
749 }
750 if (ha->flags.chip_reset_done)
751 return_status = QLA_SUCCESS;
752 else
753 return_status = QLA_FUNCTION_FAILED;
754
755 return return_status;
756}
757
Linus Torvalds1da177e2005-04-16 15:20:36 -0700758/*
759 * qla2x00_wait_for_loop_ready
760 * Wait for MAX_LOOP_TIMEOUT(5 min) value for loop
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700761 * to be in LOOP_READY state.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700762 * Input:
763 * ha - pointer to host adapter structure
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700764 *
765 * Note:
Linus Torvalds1da177e2005-04-16 15:20:36 -0700766 * Does context switching-Release SPIN_LOCK
767 * (if any) before calling this routine.
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700768 *
Linus Torvalds1da177e2005-04-16 15:20:36 -0700769 *
770 * Return:
771 * Success (LOOP_READY) : 0
772 * Failed (LOOP_NOT_READY) : 1
773 */
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700774static inline int
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800775qla2x00_wait_for_loop_ready(scsi_qla_host_t *vha)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700776{
777 int return_status = QLA_SUCCESS;
778 unsigned long loop_timeout ;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800779 struct qla_hw_data *ha = vha->hw;
780 scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700781
782 /* wait for 5 min at the max for loop to be ready */
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700783 loop_timeout = jiffies + (MAX_LOOP_TIMEOUT * HZ);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700784
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800785 while ((!atomic_read(&base_vha->loop_down_timer) &&
786 atomic_read(&base_vha->loop_state) == LOOP_DOWN) ||
787 atomic_read(&base_vha->loop_state) != LOOP_READY) {
788 if (atomic_read(&base_vha->loop_state) == LOOP_DEAD) {
Ravi Anand57680082006-05-17 15:08:44 -0700789 return_status = QLA_FUNCTION_FAILED;
790 break;
791 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700792 msleep(1000);
793 if (time_after_eq(jiffies, loop_timeout)) {
794 return_status = QLA_FUNCTION_FAILED;
795 break;
796 }
797 }
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700798 return (return_status);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700799}
800
Giridhar Malavali083a4692010-05-28 15:08:18 -0700801static void
802sp_get(struct srb *sp)
803{
804 atomic_inc(&sp->ref_count);
805}
806
Linus Torvalds1da177e2005-04-16 15:20:36 -0700807/**************************************************************************
808* qla2xxx_eh_abort
809*
810* Description:
811* The abort function will abort the specified command.
812*
813* Input:
814* cmd = Linux SCSI command packet to be aborted.
815*
816* Returns:
817* Either SUCCESS or FAILED.
818*
819* Note:
Michael Reed2ea00202006-04-27 16:25:30 -0700820* Only return FAILED if command not returned by firmware.
Linus Torvalds1da177e2005-04-16 15:20:36 -0700821**************************************************************************/
Adrian Bunke5f82ab2006-11-08 19:55:50 -0800822static int
Linus Torvalds1da177e2005-04-16 15:20:36 -0700823qla2xxx_eh_abort(struct scsi_cmnd *cmd)
824{
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800825 scsi_qla_host_t *vha = shost_priv(cmd->device->host);
f4f051e2005-04-17 15:02:26 -0500826 srb_t *sp;
Anirban Chakraborty17d98632008-12-18 10:06:15 -0800827 int ret, i;
f4f051e2005-04-17 15:02:26 -0500828 unsigned int id, lun;
829 unsigned long serial;
Andrew Vasquez18e144d2005-05-27 15:04:47 -0700830 unsigned long flags;
Michael Reed2ea00202006-04-27 16:25:30 -0700831 int wait = 0;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800832 struct qla_hw_data *ha = vha->hw;
Anirban Chakraborty67c2e932009-04-06 22:33:42 -0700833 struct req_que *req = vha->req;
Anirban Chakraborty17d98632008-12-18 10:06:15 -0800834 srb_t *spt;
Giridhar Malavali083a4692010-05-28 15:08:18 -0700835 int got_ref = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700836
Christof Schmitt65d430f2009-10-30 17:59:29 +0100837 fc_block_scsi_eh(cmd);
Andrew Vasquez07db5182006-10-02 12:00:49 -0700838
f4f051e2005-04-17 15:02:26 -0500839 if (!CMD_SP(cmd))
Michael Reed2ea00202006-04-27 16:25:30 -0700840 return SUCCESS;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700841
Michael Reed2ea00202006-04-27 16:25:30 -0700842 ret = SUCCESS;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700843
f4f051e2005-04-17 15:02:26 -0500844 id = cmd->device->id;
845 lun = cmd->device->lun;
846 serial = cmd->serial_number;
Anirban Chakraborty17d98632008-12-18 10:06:15 -0800847 spt = (srb_t *) CMD_SP(cmd);
848 if (!spt)
849 return SUCCESS;
f4f051e2005-04-17 15:02:26 -0500850
851 /* Check active list for command command. */
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800852 spin_lock_irqsave(&ha->hardware_lock, flags);
Anirban Chakraborty17d98632008-12-18 10:06:15 -0800853 for (i = 1; i < MAX_OUTSTANDING_COMMANDS; i++) {
854 sp = req->outstanding_cmds[i];
855
856 if (sp == NULL)
f4f051e2005-04-17 15:02:26 -0500857 continue;
Arun Easibad75002010-05-04 15:01:30 -0700858 if ((sp->ctx) && !(sp->flags & SRB_FCP_CMND_DMA_VALID) &&
859 !IS_PROT_IO(sp))
Andrew Vasquezcf53b062009-08-20 11:06:04 -0700860 continue;
Anirban Chakraborty17d98632008-12-18 10:06:15 -0800861 if (sp->cmd != cmd)
862 continue;
f4f051e2005-04-17 15:02:26 -0500863
Anirban Chakraborty17d98632008-12-18 10:06:15 -0800864 DEBUG2(printk("%s(%ld): aborting sp %p from RISC."
865 " pid=%ld.\n", __func__, vha->host_no, sp, serial));
f4f051e2005-04-17 15:02:26 -0500866
Giridhar Malavali083a4692010-05-28 15:08:18 -0700867 /* Get a reference to the sp and drop the lock.*/
868 sp_get(sp);
869 got_ref++;
870
Anirban Chakraborty17d98632008-12-18 10:06:15 -0800871 spin_unlock_irqrestore(&ha->hardware_lock, flags);
Anirban Chakraborty2afa19a2009-04-06 22:33:40 -0700872 if (ha->isp_ops->abort_command(sp)) {
Anirban Chakraborty17d98632008-12-18 10:06:15 -0800873 DEBUG2(printk("%s(%ld): abort_command "
874 "mbx failed.\n", __func__, vha->host_no));
Andrew Vasquez2ac4b642009-01-22 09:45:35 -0800875 ret = FAILED;
Anirban Chakraborty17d98632008-12-18 10:06:15 -0800876 } else {
877 DEBUG3(printk("%s(%ld): abort_command "
878 "mbx success.\n", __func__, vha->host_no));
879 wait = 1;
f4f051e2005-04-17 15:02:26 -0500880 }
Anirban Chakraborty17d98632008-12-18 10:06:15 -0800881 spin_lock_irqsave(&ha->hardware_lock, flags);
882 break;
f4f051e2005-04-17 15:02:26 -0500883 }
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800884 spin_unlock_irqrestore(&ha->hardware_lock, flags);
f4f051e2005-04-17 15:02:26 -0500885
886 /* Wait for the command to be returned. */
Michael Reed2ea00202006-04-27 16:25:30 -0700887 if (wait) {
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800888 if (qla2x00_eh_wait_on_command(cmd) != QLA_SUCCESS) {
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700889 qla_printk(KERN_ERR, ha,
f4f051e2005-04-17 15:02:26 -0500890 "scsi(%ld:%d:%d): Abort handler timed out -- %lx "
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800891 "%x.\n", vha->host_no, id, lun, serial, ret);
Michael Reed2ea00202006-04-27 16:25:30 -0700892 ret = FAILED;
f4f051e2005-04-17 15:02:26 -0500893 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700894 }
Linus Torvalds1da177e2005-04-16 15:20:36 -0700895
Giridhar Malavali083a4692010-05-28 15:08:18 -0700896 if (got_ref)
897 qla2x00_sp_compl(ha, sp);
898
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -0700899 qla_printk(KERN_INFO, ha,
Michael Reed2ea00202006-04-27 16:25:30 -0700900 "scsi(%ld:%d:%d): Abort command issued -- %d %lx %x.\n",
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800901 vha->host_no, id, lun, wait, serial, ret);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700902
f4f051e2005-04-17 15:02:26 -0500903 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700904}
905
Andrew Vasquez523ec772008-04-03 13:13:24 -0700906enum nexus_wait_type {
907 WAIT_HOST = 0,
908 WAIT_TARGET,
909 WAIT_LUN,
910};
911
Linus Torvalds1da177e2005-04-16 15:20:36 -0700912static int
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800913qla2x00_eh_wait_for_pending_commands(scsi_qla_host_t *vha, unsigned int t,
Anirban Chakraborty17d98632008-12-18 10:06:15 -0800914 unsigned int l, srb_t *sp, enum nexus_wait_type type)
Linus Torvalds1da177e2005-04-16 15:20:36 -0700915{
Anirban Chakraborty17d98632008-12-18 10:06:15 -0800916 int cnt, match, status;
Andrew Vasquez18e144d2005-05-27 15:04:47 -0700917 unsigned long flags;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800918 struct qla_hw_data *ha = vha->hw;
Anirban Chakraborty73208df2008-12-09 16:45:39 -0800919 struct req_que *req;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700920
Andrew Vasquez523ec772008-04-03 13:13:24 -0700921 status = QLA_SUCCESS;
Anirban Chakraborty17d98632008-12-18 10:06:15 -0800922 if (!sp)
923 return status;
924
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800925 spin_lock_irqsave(&ha->hardware_lock, flags);
Anirban Chakraborty67c2e932009-04-06 22:33:42 -0700926 req = vha->req;
Anirban Chakraborty17d98632008-12-18 10:06:15 -0800927 for (cnt = 1; status == QLA_SUCCESS &&
928 cnt < MAX_OUTSTANDING_COMMANDS; cnt++) {
929 sp = req->outstanding_cmds[cnt];
930 if (!sp)
Andrew Vasquez523ec772008-04-03 13:13:24 -0700931 continue;
Arun Easibad75002010-05-04 15:01:30 -0700932 if ((sp->ctx) && !IS_PROT_IO(sp))
Andrew Vasquezcf53b062009-08-20 11:06:04 -0700933 continue;
Anirban Chakraborty17d98632008-12-18 10:06:15 -0800934 if (vha->vp_idx != sp->fcport->vha->vp_idx)
935 continue;
936 match = 0;
937 switch (type) {
938 case WAIT_HOST:
939 match = 1;
940 break;
941 case WAIT_TARGET:
942 match = sp->cmd->device->id == t;
943 break;
944 case WAIT_LUN:
945 match = (sp->cmd->device->id == t &&
946 sp->cmd->device->lun == l);
947 break;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700948 }
Anirban Chakraborty17d98632008-12-18 10:06:15 -0800949 if (!match)
950 continue;
951
952 spin_unlock_irqrestore(&ha->hardware_lock, flags);
953 status = qla2x00_eh_wait_on_command(sp->cmd);
954 spin_lock_irqsave(&ha->hardware_lock, flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -0700955 }
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800956 spin_unlock_irqrestore(&ha->hardware_lock, flags);
Andrew Vasquez523ec772008-04-03 13:13:24 -0700957
958 return status;
Linus Torvalds1da177e2005-04-16 15:20:36 -0700959}
960
Giridhar Malavalia9083012010-04-12 17:59:55 -0700961void qla82xx_wait_for_pending_commands(scsi_qla_host_t *vha)
962{
963 int cnt;
964 srb_t *sp;
965 struct req_que *req = vha->req;
966
967 DEBUG2(qla_printk(KERN_INFO, vha->hw,
968 "Waiting for pending commands\n"));
969 for (cnt = 1; cnt < MAX_OUTSTANDING_COMMANDS; cnt++) {
970 sp = req->outstanding_cmds[cnt];
971 if (qla2x00_eh_wait_for_pending_commands(vha, 0, 0,
972 sp, WAIT_HOST) == QLA_SUCCESS) {
973 DEBUG2(qla_printk(KERN_INFO, vha->hw,
974 "Done wait for pending commands\n"));
975 }
976 }
977}
978
Andrew Vasquez523ec772008-04-03 13:13:24 -0700979static char *reset_errors[] = {
980 "HBA not online",
981 "HBA not ready",
982 "Task management failed",
983 "Waiting for command completions",
984};
Linus Torvalds1da177e2005-04-16 15:20:36 -0700985
Andrew Vasquez523ec772008-04-03 13:13:24 -0700986static int
987__qla2xxx_eh_generic_reset(char *name, enum nexus_wait_type type,
Anirban Chakraborty2afa19a2009-04-06 22:33:40 -0700988 struct scsi_cmnd *cmd, int (*do_reset)(struct fc_port *, unsigned int, int))
Andrew Vasquez523ec772008-04-03 13:13:24 -0700989{
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800990 scsi_qla_host_t *vha = shost_priv(cmd->device->host);
Andrew Vasquez523ec772008-04-03 13:13:24 -0700991 fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata;
992 int err;
993
Christof Schmitt65d430f2009-10-30 17:59:29 +0100994 fc_block_scsi_eh(cmd);
Andrew Vasquez523ec772008-04-03 13:13:24 -0700995
996 if (!fcport)
997 return FAILED;
998
Anirban Chakrabortye315cd22008-11-06 10:40:51 -0800999 qla_printk(KERN_INFO, vha->hw, "scsi(%ld:%d:%d): %s RESET ISSUED.\n",
1000 vha->host_no, cmd->device->id, cmd->device->lun, name);
Andrew Vasquez523ec772008-04-03 13:13:24 -07001001
1002 err = 0;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001003 if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS)
Andrew Vasquez523ec772008-04-03 13:13:24 -07001004 goto eh_reset_failed;
1005 err = 1;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001006 if (qla2x00_wait_for_loop_ready(vha) != QLA_SUCCESS)
Andrew Vasquez523ec772008-04-03 13:13:24 -07001007 goto eh_reset_failed;
1008 err = 2;
Anirban Chakraborty2afa19a2009-04-06 22:33:40 -07001009 if (do_reset(fcport, cmd->device->lun, cmd->request->cpu + 1)
1010 != QLA_SUCCESS)
Andrew Vasquez523ec772008-04-03 13:13:24 -07001011 goto eh_reset_failed;
1012 err = 3;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001013 if (qla2x00_eh_wait_for_pending_commands(vha, cmd->device->id,
Anirban Chakraborty17d98632008-12-18 10:06:15 -08001014 cmd->device->lun, (srb_t *) CMD_SP(cmd), type) != QLA_SUCCESS)
Andrew Vasquez523ec772008-04-03 13:13:24 -07001015 goto eh_reset_failed;
1016
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001017 qla_printk(KERN_INFO, vha->hw, "scsi(%ld:%d:%d): %s RESET SUCCEEDED.\n",
1018 vha->host_no, cmd->device->id, cmd->device->lun, name);
Andrew Vasquez523ec772008-04-03 13:13:24 -07001019
1020 return SUCCESS;
1021
1022 eh_reset_failed:
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001023 qla_printk(KERN_INFO, vha->hw, "scsi(%ld:%d:%d): %s RESET FAILED: %s.\n"
1024 , vha->host_no, cmd->device->id, cmd->device->lun, name,
Andrew Vasquez523ec772008-04-03 13:13:24 -07001025 reset_errors[err]);
1026 return FAILED;
1027}
1028
Adrian Bunke5f82ab2006-11-08 19:55:50 -08001029static int
Linus Torvalds1da177e2005-04-16 15:20:36 -07001030qla2xxx_eh_device_reset(struct scsi_cmnd *cmd)
1031{
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001032 scsi_qla_host_t *vha = shost_priv(cmd->device->host);
1033 struct qla_hw_data *ha = vha->hw;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001034
Andrew Vasquez523ec772008-04-03 13:13:24 -07001035 return __qla2xxx_eh_generic_reset("DEVICE", WAIT_LUN, cmd,
1036 ha->isp_ops->lun_reset);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001037}
1038
Linus Torvalds1da177e2005-04-16 15:20:36 -07001039static int
Andrew Vasquez523ec772008-04-03 13:13:24 -07001040qla2xxx_eh_target_reset(struct scsi_cmnd *cmd)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001041{
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001042 scsi_qla_host_t *vha = shost_priv(cmd->device->host);
1043 struct qla_hw_data *ha = vha->hw;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001044
Andrew Vasquez523ec772008-04-03 13:13:24 -07001045 return __qla2xxx_eh_generic_reset("TARGET", WAIT_TARGET, cmd,
1046 ha->isp_ops->target_reset);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001047}
1048
Linus Torvalds1da177e2005-04-16 15:20:36 -07001049/**************************************************************************
1050* qla2xxx_eh_bus_reset
1051*
1052* Description:
1053* The bus reset function will reset the bus and abort any executing
1054* commands.
1055*
1056* Input:
1057* cmd = Linux SCSI command packet of the command that cause the
1058* bus reset.
1059*
1060* Returns:
1061* SUCCESS/FAILURE (defined as macro in scsi.h).
1062*
1063**************************************************************************/
Adrian Bunke5f82ab2006-11-08 19:55:50 -08001064static int
Linus Torvalds1da177e2005-04-16 15:20:36 -07001065qla2xxx_eh_bus_reset(struct scsi_cmnd *cmd)
1066{
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001067 scsi_qla_host_t *vha = shost_priv(cmd->device->host);
bdf79622005-04-17 15:06:53 -05001068 fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata;
Seokmann Ju2c3dfe32007-07-05 13:16:51 -07001069 int ret = FAILED;
f4f051e2005-04-17 15:02:26 -05001070 unsigned int id, lun;
1071 unsigned long serial;
Anirban Chakraborty17d98632008-12-18 10:06:15 -08001072 srb_t *sp = (srb_t *) CMD_SP(cmd);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001073
Christof Schmitt65d430f2009-10-30 17:59:29 +01001074 fc_block_scsi_eh(cmd);
Andrew Vasquez07db5182006-10-02 12:00:49 -07001075
f4f051e2005-04-17 15:02:26 -05001076 id = cmd->device->id;
1077 lun = cmd->device->lun;
1078 serial = cmd->serial_number;
1079
Vladislav Bolkhovitinb0328be2006-08-01 13:48:15 -07001080 if (!fcport)
f4f051e2005-04-17 15:02:26 -05001081 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001082
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001083 qla_printk(KERN_INFO, vha->hw,
Anirban Chakraborty749af3d2008-11-14 13:48:12 -08001084 "scsi(%ld:%d:%d): BUS RESET ISSUED.\n", vha->host_no, id, lun);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001085
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001086 if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001087 DEBUG2(printk("%s failed:board disabled\n",__func__));
f4f051e2005-04-17 15:02:26 -05001088 goto eh_bus_reset_done;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001089 }
1090
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001091 if (qla2x00_wait_for_loop_ready(vha) == QLA_SUCCESS) {
1092 if (qla2x00_loop_reset(vha) == QLA_SUCCESS)
f4f051e2005-04-17 15:02:26 -05001093 ret = SUCCESS;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001094 }
f4f051e2005-04-17 15:02:26 -05001095 if (ret == FAILED)
1096 goto eh_bus_reset_done;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001097
Andrew Vasquez9a41a622005-09-20 13:25:53 -07001098 /* Flush outstanding commands. */
Anirban Chakraborty17d98632008-12-18 10:06:15 -08001099 if (qla2x00_eh_wait_for_pending_commands(vha, 0, 0, sp, WAIT_HOST) !=
Andrew Vasquez523ec772008-04-03 13:13:24 -07001100 QLA_SUCCESS)
Andrew Vasquez9a41a622005-09-20 13:25:53 -07001101 ret = FAILED;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001102
f4f051e2005-04-17 15:02:26 -05001103eh_bus_reset_done:
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001104 qla_printk(KERN_INFO, vha->hw, "%s: reset %s\n", __func__,
f4f051e2005-04-17 15:02:26 -05001105 (ret == FAILED) ? "failed" : "succeded");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001106
f4f051e2005-04-17 15:02:26 -05001107 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001108}
1109
1110/**************************************************************************
1111* qla2xxx_eh_host_reset
1112*
1113* Description:
1114* The reset function will reset the Adapter.
1115*
1116* Input:
1117* cmd = Linux SCSI command packet of the command that cause the
1118* adapter reset.
1119*
1120* Returns:
1121* Either SUCCESS or FAILED.
1122*
1123* Note:
1124**************************************************************************/
Adrian Bunke5f82ab2006-11-08 19:55:50 -08001125static int
Linus Torvalds1da177e2005-04-16 15:20:36 -07001126qla2xxx_eh_host_reset(struct scsi_cmnd *cmd)
1127{
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001128 scsi_qla_host_t *vha = shost_priv(cmd->device->host);
bdf79622005-04-17 15:06:53 -05001129 fc_port_t *fcport = (struct fc_port *) cmd->device->hostdata;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001130 struct qla_hw_data *ha = vha->hw;
Seokmann Ju2c3dfe32007-07-05 13:16:51 -07001131 int ret = FAILED;
f4f051e2005-04-17 15:02:26 -05001132 unsigned int id, lun;
1133 unsigned long serial;
Anirban Chakraborty17d98632008-12-18 10:06:15 -08001134 srb_t *sp = (srb_t *) CMD_SP(cmd);
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001135 scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001136
Christof Schmitt65d430f2009-10-30 17:59:29 +01001137 fc_block_scsi_eh(cmd);
Andrew Vasquez07db5182006-10-02 12:00:49 -07001138
f4f051e2005-04-17 15:02:26 -05001139 id = cmd->device->id;
1140 lun = cmd->device->lun;
1141 serial = cmd->serial_number;
1142
Vladislav Bolkhovitinb0328be2006-08-01 13:48:15 -07001143 if (!fcport)
f4f051e2005-04-17 15:02:26 -05001144 return ret;
1145
Linus Torvalds1da177e2005-04-16 15:20:36 -07001146 qla_printk(KERN_INFO, ha,
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001147 "scsi(%ld:%d:%d): ADAPTER RESET ISSUED.\n", vha->host_no, id, lun);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001148
Lalit Chandivade86fbee82010-05-04 15:01:32 -07001149 if (qla2x00_wait_for_reset_ready(vha) != QLA_SUCCESS)
f4f051e2005-04-17 15:02:26 -05001150 goto eh_host_reset_lock;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001151
1152 /*
1153 * Fixme-may be dpc thread is active and processing
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -07001154 * loop_resync,so wait a while for it to
Linus Torvalds1da177e2005-04-16 15:20:36 -07001155 * be completed and then issue big hammer.Otherwise
1156 * it may cause I/O failure as big hammer marks the
1157 * devices as lost kicking of the port_down_timer
1158 * while dpc is stuck for the mailbox to complete.
1159 */
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001160 qla2x00_wait_for_loop_ready(vha);
1161 if (vha != base_vha) {
1162 if (qla2x00_vp_abort_isp(vha))
f4f051e2005-04-17 15:02:26 -05001163 goto eh_host_reset_lock;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001164 } else {
Giridhar Malavalia9083012010-04-12 17:59:55 -07001165 if (IS_QLA82XX(vha->hw)) {
1166 if (!qla82xx_fcoe_ctx_reset(vha)) {
1167 /* Ctx reset success */
1168 ret = SUCCESS;
1169 goto eh_host_reset_lock;
1170 }
1171 /* fall thru if ctx reset failed */
1172 }
Anirban Chakraborty68ca9492009-04-06 22:33:41 -07001173 if (ha->wq)
1174 flush_workqueue(ha->wq);
1175
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001176 set_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags);
Giridhar Malavalia9083012010-04-12 17:59:55 -07001177 if (ha->isp_ops->abort_isp(base_vha)) {
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001178 clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags);
1179 /* failed. schedule dpc to try */
1180 set_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags);
1181
1182 if (qla2x00_wait_for_hba_online(vha) != QLA_SUCCESS)
1183 goto eh_host_reset_lock;
1184 }
1185 clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags);
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -07001186 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001187
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001188 /* Waiting for command to be returned to OS.*/
Anirban Chakraborty17d98632008-12-18 10:06:15 -08001189 if (qla2x00_eh_wait_for_pending_commands(vha, 0, 0, sp, WAIT_HOST) ==
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001190 QLA_SUCCESS)
f4f051e2005-04-17 15:02:26 -05001191 ret = SUCCESS;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001192
f4f051e2005-04-17 15:02:26 -05001193eh_host_reset_lock:
f4f051e2005-04-17 15:02:26 -05001194 qla_printk(KERN_INFO, ha, "%s: reset %s\n", __func__,
1195 (ret == FAILED) ? "failed" : "succeded");
Linus Torvalds1da177e2005-04-16 15:20:36 -07001196
f4f051e2005-04-17 15:02:26 -05001197 return ret;
1198}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001199
1200/*
1201* qla2x00_loop_reset
1202* Issue loop reset.
1203*
1204* Input:
1205* ha = adapter block pointer.
1206*
1207* Returns:
1208* 0 = success
1209*/
Andrew Vasqueza4722cf2008-01-17 09:02:12 -08001210int
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001211qla2x00_loop_reset(scsi_qla_host_t *vha)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001212{
Andrew Vasquez0c8c39a2006-12-13 19:20:30 -08001213 int ret;
bdf79622005-04-17 15:06:53 -05001214 struct fc_port *fcport;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001215 struct qla_hw_data *ha = vha->hw;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001216
Giridhar Malavalif4c496c2010-05-04 15:01:33 -07001217 if (ql2xtargetreset == 1 && ha->flags.enable_target_reset) {
Andrew Vasquez55e5ed22010-02-18 10:07:25 -08001218 list_for_each_entry(fcport, &vha->vp_fcports, list) {
1219 if (fcport->port_type != FCT_TARGET)
1220 continue;
1221
1222 ret = ha->isp_ops->target_reset(fcport, 0, 0);
1223 if (ret != QLA_SUCCESS) {
1224 DEBUG2_3(printk("%s(%ld): bus_reset failed: "
1225 "target_reset=%d d_id=%x.\n", __func__,
1226 vha->host_no, ret, fcport->d_id.b24));
1227 }
1228 }
1229 }
1230
Giridhar Malavalia9083012010-04-12 17:59:55 -07001231 if (ha->flags.enable_lip_full_login && !IS_QLA8XXX_TYPE(ha)) {
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001232 ret = qla2x00_full_login_lip(vha);
Andrew Vasquez0c8c39a2006-12-13 19:20:30 -08001233 if (ret != QLA_SUCCESS) {
Anirban Chakraborty749af3d2008-11-14 13:48:12 -08001234 DEBUG2_3(printk("%s(%ld): failed: "
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001235 "full_login_lip=%d.\n", __func__, vha->host_no,
Andrew Vasquez0c8c39a2006-12-13 19:20:30 -08001236 ret));
Anirban Chakraborty749af3d2008-11-14 13:48:12 -08001237 }
1238 atomic_set(&vha->loop_state, LOOP_DOWN);
1239 atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME);
1240 qla2x00_mark_all_devices_lost(vha, 0);
1241 qla2x00_wait_for_loop_ready(vha);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001242 }
1243
Andrew Vasquez0d6e61b2009-08-25 11:36:19 -07001244 if (ha->flags.enable_lip_reset) {
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001245 ret = qla2x00_lip_reset(vha);
Andrew Vasquez0c8c39a2006-12-13 19:20:30 -08001246 if (ret != QLA_SUCCESS) {
Anirban Chakraborty749af3d2008-11-14 13:48:12 -08001247 DEBUG2_3(printk("%s(%ld): failed: "
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001248 "lip_reset=%d.\n", __func__, vha->host_no, ret));
1249 } else
1250 qla2x00_wait_for_loop_ready(vha);
Andrew Vasquez0c8c39a2006-12-13 19:20:30 -08001251 }
1252
Linus Torvalds1da177e2005-04-16 15:20:36 -07001253 /* Issue marker command only when we are going to start the I/O */
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001254 vha->marker_needed = 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001255
Andrew Vasquez0c8c39a2006-12-13 19:20:30 -08001256 return QLA_SUCCESS;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001257}
1258
Andrew Vasquezdf4bf0b2008-01-31 12:33:46 -08001259void
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001260qla2x00_abort_all_cmds(scsi_qla_host_t *vha, int res)
Andrew Vasquezdf4bf0b2008-01-31 12:33:46 -08001261{
Anirban Chakraborty73208df2008-12-09 16:45:39 -08001262 int que, cnt;
Andrew Vasquezdf4bf0b2008-01-31 12:33:46 -08001263 unsigned long flags;
1264 srb_t *sp;
Andrew Vasquezac280b62009-08-20 11:06:05 -07001265 struct srb_ctx *ctx;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001266 struct qla_hw_data *ha = vha->hw;
Anirban Chakraborty73208df2008-12-09 16:45:39 -08001267 struct req_que *req;
Andrew Vasquezdf4bf0b2008-01-31 12:33:46 -08001268
1269 spin_lock_irqsave(&ha->hardware_lock, flags);
Anirban Chakraborty2afa19a2009-04-06 22:33:40 -07001270 for (que = 0; que < ha->max_req_queues; que++) {
Anirban Chakraborty29bdccb2009-01-08 15:41:08 -08001271 req = ha->req_q_map[que];
Anirban Chakraborty73208df2008-12-09 16:45:39 -08001272 if (!req)
1273 continue;
1274 for (cnt = 1; cnt < MAX_OUTSTANDING_COMMANDS; cnt++) {
1275 sp = req->outstanding_cmds[cnt];
Andrew Vasqueze612d462009-03-24 09:08:04 -07001276 if (sp) {
Anirban Chakraborty73208df2008-12-09 16:45:39 -08001277 req->outstanding_cmds[cnt] = NULL;
Giridhar Malavalia9083012010-04-12 17:59:55 -07001278 if (!sp->ctx ||
Arun Easibad75002010-05-04 15:01:30 -07001279 (sp->flags & SRB_FCP_CMND_DMA_VALID) ||
1280 IS_PROT_IO(sp)) {
Andrew Vasquezac280b62009-08-20 11:06:05 -07001281 sp->cmd->result = res;
1282 qla2x00_sp_compl(ha, sp);
1283 } else {
1284 ctx = sp->ctx;
Andrew Vasquez6c452a42010-03-19 17:04:02 -07001285 if (ctx->type == SRB_LOGIN_CMD ||
1286 ctx->type == SRB_LOGOUT_CMD) {
Madhuranath Iyengar49163922010-05-04 15:01:28 -07001287 ctx->u.iocb_cmd->free(sp);
Giridhar Malavalidb3ad7f2010-02-18 10:07:24 -08001288 } else {
Andrew Vasquez6c452a42010-03-19 17:04:02 -07001289 struct fc_bsg_job *bsg_job =
Madhuranath Iyengar49163922010-05-04 15:01:28 -07001290 ctx->u.bsg_job;
Andrew Vasquez6c452a42010-03-19 17:04:02 -07001291 if (bsg_job->request->msgcode
1292 == FC_BSG_HST_CT)
Giridhar Malavalidb3ad7f2010-02-18 10:07:24 -08001293 kfree(sp->fcport);
Andrew Vasquez6c452a42010-03-19 17:04:02 -07001294 bsg_job->req->errors = 0;
1295 bsg_job->reply->result = res;
Madhuranath Iyengar49163922010-05-04 15:01:28 -07001296 bsg_job->job_done(bsg_job);
Giridhar Malavalidb3ad7f2010-02-18 10:07:24 -08001297 kfree(sp->ctx);
Andrew Vasquez6c452a42010-03-19 17:04:02 -07001298 mempool_free(sp,
Madhuranath Iyengar49163922010-05-04 15:01:28 -07001299 ha->srb_mempool);
Giridhar Malavalidb3ad7f2010-02-18 10:07:24 -08001300 }
Andrew Vasquezac280b62009-08-20 11:06:05 -07001301 }
Anirban Chakraborty73208df2008-12-09 16:45:39 -08001302 }
Andrew Vasquezdf4bf0b2008-01-31 12:33:46 -08001303 }
1304 }
1305 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1306}
1307
f4f051e2005-04-17 15:02:26 -05001308static int
1309qla2xxx_slave_alloc(struct scsi_device *sdev)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001310{
bdf79622005-04-17 15:06:53 -05001311 struct fc_rport *rport = starget_to_rport(scsi_target(sdev));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001312
James.Smart@Emulex.Com19a7b4a2005-10-18 12:03:35 -04001313 if (!rport || fc_remote_port_chkready(rport))
f4f051e2005-04-17 15:02:26 -05001314 return -ENXIO;
1315
James.Smart@Emulex.Com19a7b4a2005-10-18 12:03:35 -04001316 sdev->hostdata = *(fc_port_t **)rport->dd_data;
f4f051e2005-04-17 15:02:26 -05001317
1318 return 0;
1319}
1320
1321static int
1322qla2xxx_slave_configure(struct scsi_device *sdev)
1323{
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001324 scsi_qla_host_t *vha = shost_priv(sdev->host);
1325 struct qla_hw_data *ha = vha->hw;
8482e1182005-04-17 15:04:54 -05001326 struct fc_rport *rport = starget_to_rport(sdev->sdev_target);
Anirban Chakraborty2afa19a2009-04-06 22:33:40 -07001327 struct req_que *req = vha->req;
8482e1182005-04-17 15:04:54 -05001328
f4f051e2005-04-17 15:02:26 -05001329 if (sdev->tagged_supported)
Anirban Chakraborty73208df2008-12-09 16:45:39 -08001330 scsi_activate_tcq(sdev, req->max_q_depth);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001331 else
Anirban Chakraborty73208df2008-12-09 16:45:39 -08001332 scsi_deactivate_tcq(sdev, req->max_q_depth);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001333
Andrew Vasquez85821c92008-07-10 16:55:48 -07001334 rport->dev_loss_tmo = ha->port_down_retry_count;
8482e1182005-04-17 15:04:54 -05001335
f4f051e2005-04-17 15:02:26 -05001336 return 0;
1337}
Linus Torvalds1da177e2005-04-16 15:20:36 -07001338
f4f051e2005-04-17 15:02:26 -05001339static void
1340qla2xxx_slave_destroy(struct scsi_device *sdev)
1341{
1342 sdev->hostdata = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001343}
1344
Giridhar Malavalic45dd302009-12-02 10:36:54 -08001345static void qla2x00_handle_queue_full(struct scsi_device *sdev, int qdepth)
1346{
1347 fc_port_t *fcport = (struct fc_port *) sdev->hostdata;
1348
1349 if (!scsi_track_queue_full(sdev, qdepth))
1350 return;
1351
1352 DEBUG2(qla_printk(KERN_INFO, fcport->vha->hw,
1353 "scsi(%ld:%d:%d:%d): Queue depth adjusted-down to %d.\n",
1354 fcport->vha->host_no, sdev->channel, sdev->id, sdev->lun,
1355 sdev->queue_depth));
1356}
1357
1358static void qla2x00_adjust_sdev_qdepth_up(struct scsi_device *sdev, int qdepth)
1359{
1360 fc_port_t *fcport = sdev->hostdata;
1361 struct scsi_qla_host *vha = fcport->vha;
1362 struct qla_hw_data *ha = vha->hw;
1363 struct req_que *req = NULL;
1364
1365 req = vha->req;
1366 if (!req)
1367 return;
1368
1369 if (req->max_q_depth <= sdev->queue_depth || req->max_q_depth < qdepth)
1370 return;
1371
1372 if (sdev->ordered_tags)
1373 scsi_adjust_queue_depth(sdev, MSG_ORDERED_TAG, qdepth);
1374 else
1375 scsi_adjust_queue_depth(sdev, MSG_SIMPLE_TAG, qdepth);
1376
1377 DEBUG2(qla_printk(KERN_INFO, ha,
1378 "scsi(%ld:%d:%d:%d): Queue depth adjusted-up to %d.\n",
1379 fcport->vha->host_no, sdev->channel, sdev->id, sdev->lun,
1380 sdev->queue_depth));
1381}
1382
Andrew Vasquezce7e4af2005-08-26 19:09:30 -07001383static int
Mike Christiee881a172009-10-15 17:46:39 -07001384qla2x00_change_queue_depth(struct scsi_device *sdev, int qdepth, int reason)
Andrew Vasquezce7e4af2005-08-26 19:09:30 -07001385{
Giridhar Malavalic45dd302009-12-02 10:36:54 -08001386 switch (reason) {
1387 case SCSI_QDEPTH_DEFAULT:
1388 scsi_adjust_queue_depth(sdev, scsi_get_tag_type(sdev), qdepth);
1389 break;
1390 case SCSI_QDEPTH_QFULL:
1391 qla2x00_handle_queue_full(sdev, qdepth);
1392 break;
1393 case SCSI_QDEPTH_RAMP_UP:
1394 qla2x00_adjust_sdev_qdepth_up(sdev, qdepth);
1395 break;
1396 default:
Roel Kluin08002af2010-01-29 11:25:19 +01001397 return -EOPNOTSUPP;
Giridhar Malavalic45dd302009-12-02 10:36:54 -08001398 }
Mike Christiee881a172009-10-15 17:46:39 -07001399
Andrew Vasquezce7e4af2005-08-26 19:09:30 -07001400 return sdev->queue_depth;
1401}
1402
1403static int
1404qla2x00_change_queue_type(struct scsi_device *sdev, int tag_type)
1405{
1406 if (sdev->tagged_supported) {
1407 scsi_set_tag_type(sdev, tag_type);
1408 if (tag_type)
1409 scsi_activate_tcq(sdev, sdev->queue_depth);
1410 else
1411 scsi_deactivate_tcq(sdev, sdev->queue_depth);
1412 } else
1413 tag_type = 0;
1414
1415 return tag_type;
1416}
1417
Linus Torvalds1da177e2005-04-16 15:20:36 -07001418/**
1419 * qla2x00_config_dma_addressing() - Configure OS DMA addressing method.
1420 * @ha: HA context
1421 *
1422 * At exit, the @ha's flags.enable_64bit_addressing set to indicated
1423 * supported addressing method.
1424 */
1425static void
Andrew Vasquez53303c42009-01-22 09:45:37 -08001426qla2x00_config_dma_addressing(struct qla_hw_data *ha)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001427{
Andrew Vasquez7524f9b2005-08-26 19:08:00 -07001428 /* Assume a 32bit DMA mask. */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001429 ha->flags.enable_64bit_addressing = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001430
Yang Hongyang6a355282009-04-06 19:01:13 -07001431 if (!dma_set_mask(&ha->pdev->dev, DMA_BIT_MASK(64))) {
Andrew Vasquez7524f9b2005-08-26 19:08:00 -07001432 /* Any upper-dword bits set? */
1433 if (MSD(dma_get_required_mask(&ha->pdev->dev)) &&
Yang Hongyang6a355282009-04-06 19:01:13 -07001434 !pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(64))) {
Andrew Vasquez7524f9b2005-08-26 19:08:00 -07001435 /* Ok, a 64bit DMA mask is applicable. */
Linus Torvalds1da177e2005-04-16 15:20:36 -07001436 ha->flags.enable_64bit_addressing = 1;
Andrew Vasquezfd34f552007-07-19 15:06:00 -07001437 ha->isp_ops->calc_req_entries = qla2x00_calc_iocbs_64;
1438 ha->isp_ops->build_iocbs = qla2x00_build_scsi_iocbs_64;
Andrew Vasquez7524f9b2005-08-26 19:08:00 -07001439 return;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001440 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001441 }
Andrew Vasquez7524f9b2005-08-26 19:08:00 -07001442
Yang Hongyang284901a2009-04-06 19:01:15 -07001443 dma_set_mask(&ha->pdev->dev, DMA_BIT_MASK(32));
1444 pci_set_consistent_dma_mask(ha->pdev, DMA_BIT_MASK(32));
Linus Torvalds1da177e2005-04-16 15:20:36 -07001445}
1446
Andrew Vasquezfd34f552007-07-19 15:06:00 -07001447static void
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001448qla2x00_enable_intrs(struct qla_hw_data *ha)
Andrew Vasquezfd34f552007-07-19 15:06:00 -07001449{
1450 unsigned long flags = 0;
1451 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
1452
1453 spin_lock_irqsave(&ha->hardware_lock, flags);
1454 ha->interrupts_on = 1;
1455 /* enable risc and host interrupts */
1456 WRT_REG_WORD(&reg->ictrl, ICR_EN_INT | ICR_EN_RISC);
1457 RD_REG_WORD(&reg->ictrl);
1458 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1459
1460}
1461
1462static void
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001463qla2x00_disable_intrs(struct qla_hw_data *ha)
Andrew Vasquezfd34f552007-07-19 15:06:00 -07001464{
1465 unsigned long flags = 0;
1466 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
1467
1468 spin_lock_irqsave(&ha->hardware_lock, flags);
1469 ha->interrupts_on = 0;
1470 /* disable risc and host interrupts */
1471 WRT_REG_WORD(&reg->ictrl, 0);
1472 RD_REG_WORD(&reg->ictrl);
1473 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1474}
1475
1476static void
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001477qla24xx_enable_intrs(struct qla_hw_data *ha)
Andrew Vasquezfd34f552007-07-19 15:06:00 -07001478{
1479 unsigned long flags = 0;
1480 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
1481
1482 spin_lock_irqsave(&ha->hardware_lock, flags);
1483 ha->interrupts_on = 1;
1484 WRT_REG_DWORD(&reg->ictrl, ICRX_EN_RISC_INT);
1485 RD_REG_DWORD(&reg->ictrl);
1486 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1487}
1488
1489static void
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001490qla24xx_disable_intrs(struct qla_hw_data *ha)
Andrew Vasquezfd34f552007-07-19 15:06:00 -07001491{
1492 unsigned long flags = 0;
1493 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
1494
Andrew Vasquez124f85e2009-01-05 11:18:06 -08001495 if (IS_NOPOLLING_TYPE(ha))
1496 return;
Andrew Vasquezfd34f552007-07-19 15:06:00 -07001497 spin_lock_irqsave(&ha->hardware_lock, flags);
1498 ha->interrupts_on = 0;
1499 WRT_REG_DWORD(&reg->ictrl, 0);
1500 RD_REG_DWORD(&reg->ictrl);
1501 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1502}
1503
1504static struct isp_operations qla2100_isp_ops = {
1505 .pci_config = qla2100_pci_config,
1506 .reset_chip = qla2x00_reset_chip,
1507 .chip_diag = qla2x00_chip_diag,
1508 .config_rings = qla2x00_config_rings,
1509 .reset_adapter = qla2x00_reset_adapter,
1510 .nvram_config = qla2x00_nvram_config,
1511 .update_fw_options = qla2x00_update_fw_options,
1512 .load_risc = qla2x00_load_risc,
1513 .pci_info_str = qla2x00_pci_info_str,
1514 .fw_version_str = qla2x00_fw_version_str,
1515 .intr_handler = qla2100_intr_handler,
1516 .enable_intrs = qla2x00_enable_intrs,
1517 .disable_intrs = qla2x00_disable_intrs,
1518 .abort_command = qla2x00_abort_command,
Andrew Vasquez523ec772008-04-03 13:13:24 -07001519 .target_reset = qla2x00_abort_target,
1520 .lun_reset = qla2x00_lun_reset,
Andrew Vasquezfd34f552007-07-19 15:06:00 -07001521 .fabric_login = qla2x00_login_fabric,
1522 .fabric_logout = qla2x00_fabric_logout,
1523 .calc_req_entries = qla2x00_calc_iocbs_32,
1524 .build_iocbs = qla2x00_build_scsi_iocbs_32,
1525 .prep_ms_iocb = qla2x00_prep_ms_iocb,
1526 .prep_ms_fdmi_iocb = qla2x00_prep_ms_fdmi_iocb,
1527 .read_nvram = qla2x00_read_nvram_data,
1528 .write_nvram = qla2x00_write_nvram_data,
1529 .fw_dump = qla2100_fw_dump,
1530 .beacon_on = NULL,
1531 .beacon_off = NULL,
1532 .beacon_blink = NULL,
1533 .read_optrom = qla2x00_read_optrom_data,
1534 .write_optrom = qla2x00_write_optrom_data,
1535 .get_flash_version = qla2x00_get_flash_version,
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001536 .start_scsi = qla2x00_start_scsi,
Giridhar Malavalia9083012010-04-12 17:59:55 -07001537 .abort_isp = qla2x00_abort_isp,
Andrew Vasquezfd34f552007-07-19 15:06:00 -07001538};
1539
1540static struct isp_operations qla2300_isp_ops = {
1541 .pci_config = qla2300_pci_config,
1542 .reset_chip = qla2x00_reset_chip,
1543 .chip_diag = qla2x00_chip_diag,
1544 .config_rings = qla2x00_config_rings,
1545 .reset_adapter = qla2x00_reset_adapter,
1546 .nvram_config = qla2x00_nvram_config,
1547 .update_fw_options = qla2x00_update_fw_options,
1548 .load_risc = qla2x00_load_risc,
1549 .pci_info_str = qla2x00_pci_info_str,
1550 .fw_version_str = qla2x00_fw_version_str,
1551 .intr_handler = qla2300_intr_handler,
1552 .enable_intrs = qla2x00_enable_intrs,
1553 .disable_intrs = qla2x00_disable_intrs,
1554 .abort_command = qla2x00_abort_command,
Andrew Vasquez523ec772008-04-03 13:13:24 -07001555 .target_reset = qla2x00_abort_target,
1556 .lun_reset = qla2x00_lun_reset,
Andrew Vasquezfd34f552007-07-19 15:06:00 -07001557 .fabric_login = qla2x00_login_fabric,
1558 .fabric_logout = qla2x00_fabric_logout,
1559 .calc_req_entries = qla2x00_calc_iocbs_32,
1560 .build_iocbs = qla2x00_build_scsi_iocbs_32,
1561 .prep_ms_iocb = qla2x00_prep_ms_iocb,
1562 .prep_ms_fdmi_iocb = qla2x00_prep_ms_fdmi_iocb,
1563 .read_nvram = qla2x00_read_nvram_data,
1564 .write_nvram = qla2x00_write_nvram_data,
1565 .fw_dump = qla2300_fw_dump,
1566 .beacon_on = qla2x00_beacon_on,
1567 .beacon_off = qla2x00_beacon_off,
1568 .beacon_blink = qla2x00_beacon_blink,
1569 .read_optrom = qla2x00_read_optrom_data,
1570 .write_optrom = qla2x00_write_optrom_data,
1571 .get_flash_version = qla2x00_get_flash_version,
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001572 .start_scsi = qla2x00_start_scsi,
Giridhar Malavalia9083012010-04-12 17:59:55 -07001573 .abort_isp = qla2x00_abort_isp,
Andrew Vasquezfd34f552007-07-19 15:06:00 -07001574};
1575
1576static struct isp_operations qla24xx_isp_ops = {
1577 .pci_config = qla24xx_pci_config,
1578 .reset_chip = qla24xx_reset_chip,
1579 .chip_diag = qla24xx_chip_diag,
1580 .config_rings = qla24xx_config_rings,
1581 .reset_adapter = qla24xx_reset_adapter,
1582 .nvram_config = qla24xx_nvram_config,
1583 .update_fw_options = qla24xx_update_fw_options,
1584 .load_risc = qla24xx_load_risc,
1585 .pci_info_str = qla24xx_pci_info_str,
1586 .fw_version_str = qla24xx_fw_version_str,
1587 .intr_handler = qla24xx_intr_handler,
1588 .enable_intrs = qla24xx_enable_intrs,
1589 .disable_intrs = qla24xx_disable_intrs,
1590 .abort_command = qla24xx_abort_command,
Andrew Vasquez523ec772008-04-03 13:13:24 -07001591 .target_reset = qla24xx_abort_target,
1592 .lun_reset = qla24xx_lun_reset,
Andrew Vasquezfd34f552007-07-19 15:06:00 -07001593 .fabric_login = qla24xx_login_fabric,
1594 .fabric_logout = qla24xx_fabric_logout,
1595 .calc_req_entries = NULL,
1596 .build_iocbs = NULL,
1597 .prep_ms_iocb = qla24xx_prep_ms_iocb,
1598 .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb,
1599 .read_nvram = qla24xx_read_nvram_data,
1600 .write_nvram = qla24xx_write_nvram_data,
1601 .fw_dump = qla24xx_fw_dump,
1602 .beacon_on = qla24xx_beacon_on,
1603 .beacon_off = qla24xx_beacon_off,
1604 .beacon_blink = qla24xx_beacon_blink,
1605 .read_optrom = qla24xx_read_optrom_data,
1606 .write_optrom = qla24xx_write_optrom_data,
1607 .get_flash_version = qla24xx_get_flash_version,
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001608 .start_scsi = qla24xx_start_scsi,
Giridhar Malavalia9083012010-04-12 17:59:55 -07001609 .abort_isp = qla2x00_abort_isp,
Andrew Vasquezfd34f552007-07-19 15:06:00 -07001610};
1611
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001612static struct isp_operations qla25xx_isp_ops = {
1613 .pci_config = qla25xx_pci_config,
1614 .reset_chip = qla24xx_reset_chip,
1615 .chip_diag = qla24xx_chip_diag,
1616 .config_rings = qla24xx_config_rings,
1617 .reset_adapter = qla24xx_reset_adapter,
1618 .nvram_config = qla24xx_nvram_config,
1619 .update_fw_options = qla24xx_update_fw_options,
1620 .load_risc = qla24xx_load_risc,
1621 .pci_info_str = qla24xx_pci_info_str,
1622 .fw_version_str = qla24xx_fw_version_str,
1623 .intr_handler = qla24xx_intr_handler,
1624 .enable_intrs = qla24xx_enable_intrs,
1625 .disable_intrs = qla24xx_disable_intrs,
1626 .abort_command = qla24xx_abort_command,
Andrew Vasquez523ec772008-04-03 13:13:24 -07001627 .target_reset = qla24xx_abort_target,
1628 .lun_reset = qla24xx_lun_reset,
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001629 .fabric_login = qla24xx_login_fabric,
1630 .fabric_logout = qla24xx_fabric_logout,
1631 .calc_req_entries = NULL,
1632 .build_iocbs = NULL,
1633 .prep_ms_iocb = qla24xx_prep_ms_iocb,
1634 .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb,
1635 .read_nvram = qla25xx_read_nvram_data,
1636 .write_nvram = qla25xx_write_nvram_data,
1637 .fw_dump = qla25xx_fw_dump,
1638 .beacon_on = qla24xx_beacon_on,
1639 .beacon_off = qla24xx_beacon_off,
1640 .beacon_blink = qla24xx_beacon_blink,
Andrew Vasquez338c9162007-09-20 14:07:33 -07001641 .read_optrom = qla25xx_read_optrom_data,
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001642 .write_optrom = qla24xx_write_optrom_data,
1643 .get_flash_version = qla24xx_get_flash_version,
Arun Easibad75002010-05-04 15:01:30 -07001644 .start_scsi = qla24xx_dif_start_scsi,
Giridhar Malavalia9083012010-04-12 17:59:55 -07001645 .abort_isp = qla2x00_abort_isp,
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001646};
1647
Andrew Vasquez3a03eb72009-01-05 11:18:11 -08001648static struct isp_operations qla81xx_isp_ops = {
1649 .pci_config = qla25xx_pci_config,
1650 .reset_chip = qla24xx_reset_chip,
1651 .chip_diag = qla24xx_chip_diag,
1652 .config_rings = qla24xx_config_rings,
1653 .reset_adapter = qla24xx_reset_adapter,
1654 .nvram_config = qla81xx_nvram_config,
1655 .update_fw_options = qla81xx_update_fw_options,
Andrew Vasquezeaac30b2009-01-22 09:45:32 -08001656 .load_risc = qla81xx_load_risc,
Andrew Vasquez3a03eb72009-01-05 11:18:11 -08001657 .pci_info_str = qla24xx_pci_info_str,
1658 .fw_version_str = qla24xx_fw_version_str,
1659 .intr_handler = qla24xx_intr_handler,
1660 .enable_intrs = qla24xx_enable_intrs,
1661 .disable_intrs = qla24xx_disable_intrs,
1662 .abort_command = qla24xx_abort_command,
1663 .target_reset = qla24xx_abort_target,
1664 .lun_reset = qla24xx_lun_reset,
1665 .fabric_login = qla24xx_login_fabric,
1666 .fabric_logout = qla24xx_fabric_logout,
1667 .calc_req_entries = NULL,
1668 .build_iocbs = NULL,
1669 .prep_ms_iocb = qla24xx_prep_ms_iocb,
1670 .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb,
Andrew Vasquez3d79038f2009-03-24 09:08:14 -07001671 .read_nvram = NULL,
1672 .write_nvram = NULL,
Andrew Vasquez3a03eb72009-01-05 11:18:11 -08001673 .fw_dump = qla81xx_fw_dump,
1674 .beacon_on = qla24xx_beacon_on,
1675 .beacon_off = qla24xx_beacon_off,
1676 .beacon_blink = qla24xx_beacon_blink,
1677 .read_optrom = qla25xx_read_optrom_data,
1678 .write_optrom = qla24xx_write_optrom_data,
1679 .get_flash_version = qla24xx_get_flash_version,
1680 .start_scsi = qla24xx_start_scsi,
Giridhar Malavalia9083012010-04-12 17:59:55 -07001681 .abort_isp = qla2x00_abort_isp,
1682};
1683
1684static struct isp_operations qla82xx_isp_ops = {
1685 .pci_config = qla82xx_pci_config,
1686 .reset_chip = qla82xx_reset_chip,
1687 .chip_diag = qla24xx_chip_diag,
1688 .config_rings = qla82xx_config_rings,
1689 .reset_adapter = qla24xx_reset_adapter,
1690 .nvram_config = qla81xx_nvram_config,
1691 .update_fw_options = qla24xx_update_fw_options,
1692 .load_risc = qla82xx_load_risc,
1693 .pci_info_str = qla82xx_pci_info_str,
1694 .fw_version_str = qla24xx_fw_version_str,
1695 .intr_handler = qla82xx_intr_handler,
1696 .enable_intrs = qla82xx_enable_intrs,
1697 .disable_intrs = qla82xx_disable_intrs,
1698 .abort_command = qla24xx_abort_command,
1699 .target_reset = qla24xx_abort_target,
1700 .lun_reset = qla24xx_lun_reset,
1701 .fabric_login = qla24xx_login_fabric,
1702 .fabric_logout = qla24xx_fabric_logout,
1703 .calc_req_entries = NULL,
1704 .build_iocbs = NULL,
1705 .prep_ms_iocb = qla24xx_prep_ms_iocb,
1706 .prep_ms_fdmi_iocb = qla24xx_prep_ms_fdmi_iocb,
1707 .read_nvram = qla24xx_read_nvram_data,
1708 .write_nvram = qla24xx_write_nvram_data,
1709 .fw_dump = qla24xx_fw_dump,
1710 .beacon_on = qla24xx_beacon_on,
1711 .beacon_off = qla24xx_beacon_off,
1712 .beacon_blink = qla24xx_beacon_blink,
1713 .read_optrom = qla82xx_read_optrom_data,
1714 .write_optrom = qla82xx_write_optrom_data,
1715 .get_flash_version = qla24xx_get_flash_version,
1716 .start_scsi = qla82xx_start_scsi,
1717 .abort_isp = qla82xx_abort_isp,
Andrew Vasquez3a03eb72009-01-05 11:18:11 -08001718};
1719
andrew.vasquez@qlogic.comea5b6382006-03-09 14:27:08 -08001720static inline void
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001721qla2x00_set_isp_flags(struct qla_hw_data *ha)
andrew.vasquez@qlogic.comea5b6382006-03-09 14:27:08 -08001722{
1723 ha->device_type = DT_EXTENDED_IDS;
1724 switch (ha->pdev->device) {
1725 case PCI_DEVICE_ID_QLOGIC_ISP2100:
1726 ha->device_type |= DT_ISP2100;
1727 ha->device_type &= ~DT_EXTENDED_IDS;
Andrew Vasquez441d1072006-05-17 15:09:34 -07001728 ha->fw_srisc_address = RISC_START_ADDRESS_2100;
andrew.vasquez@qlogic.comea5b6382006-03-09 14:27:08 -08001729 break;
1730 case PCI_DEVICE_ID_QLOGIC_ISP2200:
1731 ha->device_type |= DT_ISP2200;
1732 ha->device_type &= ~DT_EXTENDED_IDS;
Andrew Vasquez441d1072006-05-17 15:09:34 -07001733 ha->fw_srisc_address = RISC_START_ADDRESS_2100;
andrew.vasquez@qlogic.comea5b6382006-03-09 14:27:08 -08001734 break;
1735 case PCI_DEVICE_ID_QLOGIC_ISP2300:
1736 ha->device_type |= DT_ISP2300;
andrew.vasquez@qlogic.com4a59f712006-03-09 14:27:39 -08001737 ha->device_type |= DT_ZIO_SUPPORTED;
Andrew Vasquez441d1072006-05-17 15:09:34 -07001738 ha->fw_srisc_address = RISC_START_ADDRESS_2300;
andrew.vasquez@qlogic.comea5b6382006-03-09 14:27:08 -08001739 break;
1740 case PCI_DEVICE_ID_QLOGIC_ISP2312:
1741 ha->device_type |= DT_ISP2312;
andrew.vasquez@qlogic.com4a59f712006-03-09 14:27:39 -08001742 ha->device_type |= DT_ZIO_SUPPORTED;
Andrew Vasquez441d1072006-05-17 15:09:34 -07001743 ha->fw_srisc_address = RISC_START_ADDRESS_2300;
andrew.vasquez@qlogic.comea5b6382006-03-09 14:27:08 -08001744 break;
1745 case PCI_DEVICE_ID_QLOGIC_ISP2322:
1746 ha->device_type |= DT_ISP2322;
andrew.vasquez@qlogic.com4a59f712006-03-09 14:27:39 -08001747 ha->device_type |= DT_ZIO_SUPPORTED;
andrew.vasquez@qlogic.comea5b6382006-03-09 14:27:08 -08001748 if (ha->pdev->subsystem_vendor == 0x1028 &&
1749 ha->pdev->subsystem_device == 0x0170)
1750 ha->device_type |= DT_OEM_001;
Andrew Vasquez441d1072006-05-17 15:09:34 -07001751 ha->fw_srisc_address = RISC_START_ADDRESS_2300;
andrew.vasquez@qlogic.comea5b6382006-03-09 14:27:08 -08001752 break;
1753 case PCI_DEVICE_ID_QLOGIC_ISP6312:
1754 ha->device_type |= DT_ISP6312;
Andrew Vasquez441d1072006-05-17 15:09:34 -07001755 ha->fw_srisc_address = RISC_START_ADDRESS_2300;
andrew.vasquez@qlogic.comea5b6382006-03-09 14:27:08 -08001756 break;
1757 case PCI_DEVICE_ID_QLOGIC_ISP6322:
1758 ha->device_type |= DT_ISP6322;
Andrew Vasquez441d1072006-05-17 15:09:34 -07001759 ha->fw_srisc_address = RISC_START_ADDRESS_2300;
andrew.vasquez@qlogic.comea5b6382006-03-09 14:27:08 -08001760 break;
1761 case PCI_DEVICE_ID_QLOGIC_ISP2422:
1762 ha->device_type |= DT_ISP2422;
andrew.vasquez@qlogic.com4a59f712006-03-09 14:27:39 -08001763 ha->device_type |= DT_ZIO_SUPPORTED;
Andrew Vasqueze4289242007-07-19 15:05:56 -07001764 ha->device_type |= DT_FWI2;
Andrew Vasquezc76f2c02007-07-19 15:05:57 -07001765 ha->device_type |= DT_IIDMA;
Andrew Vasquez441d1072006-05-17 15:09:34 -07001766 ha->fw_srisc_address = RISC_START_ADDRESS_2400;
andrew.vasquez@qlogic.comea5b6382006-03-09 14:27:08 -08001767 break;
1768 case PCI_DEVICE_ID_QLOGIC_ISP2432:
1769 ha->device_type |= DT_ISP2432;
andrew.vasquez@qlogic.com4a59f712006-03-09 14:27:39 -08001770 ha->device_type |= DT_ZIO_SUPPORTED;
Andrew Vasqueze4289242007-07-19 15:05:56 -07001771 ha->device_type |= DT_FWI2;
Andrew Vasquezc76f2c02007-07-19 15:05:57 -07001772 ha->device_type |= DT_IIDMA;
Andrew Vasquez441d1072006-05-17 15:09:34 -07001773 ha->fw_srisc_address = RISC_START_ADDRESS_2400;
andrew.vasquez@qlogic.comea5b6382006-03-09 14:27:08 -08001774 break;
Harihara Kadayam4d4df192008-04-03 13:13:26 -07001775 case PCI_DEVICE_ID_QLOGIC_ISP8432:
1776 ha->device_type |= DT_ISP8432;
1777 ha->device_type |= DT_ZIO_SUPPORTED;
1778 ha->device_type |= DT_FWI2;
1779 ha->device_type |= DT_IIDMA;
1780 ha->fw_srisc_address = RISC_START_ADDRESS_2400;
1781 break;
andrew.vasquez@qlogic.com044cc6c2006-03-09 14:27:13 -08001782 case PCI_DEVICE_ID_QLOGIC_ISP5422:
1783 ha->device_type |= DT_ISP5422;
Andrew Vasqueze4289242007-07-19 15:05:56 -07001784 ha->device_type |= DT_FWI2;
Andrew Vasquez441d1072006-05-17 15:09:34 -07001785 ha->fw_srisc_address = RISC_START_ADDRESS_2400;
andrew.vasquez@qlogic.comea5b6382006-03-09 14:27:08 -08001786 break;
andrew.vasquez@qlogic.com044cc6c2006-03-09 14:27:13 -08001787 case PCI_DEVICE_ID_QLOGIC_ISP5432:
1788 ha->device_type |= DT_ISP5432;
Andrew Vasqueze4289242007-07-19 15:05:56 -07001789 ha->device_type |= DT_FWI2;
Andrew Vasquez441d1072006-05-17 15:09:34 -07001790 ha->fw_srisc_address = RISC_START_ADDRESS_2400;
andrew.vasquez@qlogic.comea5b6382006-03-09 14:27:08 -08001791 break;
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07001792 case PCI_DEVICE_ID_QLOGIC_ISP2532:
1793 ha->device_type |= DT_ISP2532;
1794 ha->device_type |= DT_ZIO_SUPPORTED;
1795 ha->device_type |= DT_FWI2;
1796 ha->device_type |= DT_IIDMA;
andrew.vasquez@qlogic.comea5b6382006-03-09 14:27:08 -08001797 ha->fw_srisc_address = RISC_START_ADDRESS_2400;
1798 break;
Andrew Vasquez3a03eb72009-01-05 11:18:11 -08001799 case PCI_DEVICE_ID_QLOGIC_ISP8001:
1800 ha->device_type |= DT_ISP8001;
1801 ha->device_type |= DT_ZIO_SUPPORTED;
1802 ha->device_type |= DT_FWI2;
1803 ha->device_type |= DT_IIDMA;
1804 ha->fw_srisc_address = RISC_START_ADDRESS_2400;
1805 break;
Giridhar Malavalia9083012010-04-12 17:59:55 -07001806 case PCI_DEVICE_ID_QLOGIC_ISP8021:
1807 ha->device_type |= DT_ISP8021;
1808 ha->device_type |= DT_ZIO_SUPPORTED;
1809 ha->device_type |= DT_FWI2;
1810 ha->fw_srisc_address = RISC_START_ADDRESS_2400;
1811 /* Initialize 82XX ISP flags */
1812 qla82xx_init_flags(ha);
1813 break;
andrew.vasquez@qlogic.comea5b6382006-03-09 14:27:08 -08001814 }
Anirban Chakrabortye5b68a62009-04-06 22:33:50 -07001815
Giridhar Malavalia9083012010-04-12 17:59:55 -07001816 if (IS_QLA82XX(ha))
1817 ha->port_no = !(ha->portnum & 1);
1818 else
1819 /* Get adapter physical port no from interrupt pin register. */
1820 pci_read_config_byte(ha->pdev, PCI_INTERRUPT_PIN, &ha->port_no);
1821
Anirban Chakrabortye5b68a62009-04-06 22:33:50 -07001822 if (ha->port_no & 1)
1823 ha->flags.port0 = 1;
1824 else
1825 ha->flags.port0 = 0;
andrew.vasquez@qlogic.comea5b6382006-03-09 14:27:08 -08001826}
1827
Linus Torvalds1da177e2005-04-16 15:20:36 -07001828static int
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001829qla2x00_iospace_config(struct qla_hw_data *ha)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001830{
Andrew Vasquez37765412008-01-17 09:02:09 -08001831 resource_size_t pio;
Anirban Chakraborty73208df2008-12-09 16:45:39 -08001832 uint16_t msix;
Anirban Chakraborty68ca9492009-04-06 22:33:41 -07001833 int cpus;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001834
Giridhar Malavalia9083012010-04-12 17:59:55 -07001835 if (IS_QLA82XX(ha))
1836 return qla82xx_iospace_config(ha);
1837
Andrew Vasquez285d0322007-10-19 15:59:17 -07001838 if (pci_request_selected_regions(ha->pdev, ha->bars,
1839 QLA2XXX_DRIVER_NAME)) {
1840 qla_printk(KERN_WARNING, ha,
1841 "Failed to reserve PIO/MMIO regions (%s)\n",
1842 pci_name(ha->pdev));
1843
1844 goto iospace_error_exit;
1845 }
1846 if (!(ha->bars & 1))
1847 goto skip_pio;
1848
Linus Torvalds1da177e2005-04-16 15:20:36 -07001849 /* We only need PIO for Flash operations on ISP2312 v2 chips. */
1850 pio = pci_resource_start(ha->pdev, 0);
Andrew Vasquez37765412008-01-17 09:02:09 -08001851 if (pci_resource_flags(ha->pdev, 0) & IORESOURCE_IO) {
1852 if (pci_resource_len(ha->pdev, 0) < MIN_IOBASE_LEN) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001853 qla_printk(KERN_WARNING, ha,
1854 "Invalid PCI I/O region size (%s)...\n",
1855 pci_name(ha->pdev));
1856 pio = 0;
1857 }
1858 } else {
1859 qla_printk(KERN_WARNING, ha,
1860 "region #0 not a PIO resource (%s)...\n",
1861 pci_name(ha->pdev));
1862 pio = 0;
1863 }
Andrew Vasquez285d0322007-10-19 15:59:17 -07001864 ha->pio_address = pio;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001865
Andrew Vasquez285d0322007-10-19 15:59:17 -07001866skip_pio:
Linus Torvalds1da177e2005-04-16 15:20:36 -07001867 /* Use MMIO operations for all accesses. */
Andrew Vasquez37765412008-01-17 09:02:09 -08001868 if (!(pci_resource_flags(ha->pdev, 1) & IORESOURCE_MEM)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001869 qla_printk(KERN_ERR, ha,
Andrew Vasquez37765412008-01-17 09:02:09 -08001870 "region #1 not an MMIO resource (%s), aborting\n",
Linus Torvalds1da177e2005-04-16 15:20:36 -07001871 pci_name(ha->pdev));
1872 goto iospace_error_exit;
1873 }
Andrew Vasquez37765412008-01-17 09:02:09 -08001874 if (pci_resource_len(ha->pdev, 1) < MIN_IOBASE_LEN) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07001875 qla_printk(KERN_ERR, ha,
1876 "Invalid PCI mem region size (%s), aborting\n",
1877 pci_name(ha->pdev));
1878 goto iospace_error_exit;
1879 }
1880
Andrew Vasquez37765412008-01-17 09:02:09 -08001881 ha->iobase = ioremap(pci_resource_start(ha->pdev, 1), MIN_IOBASE_LEN);
Linus Torvalds1da177e2005-04-16 15:20:36 -07001882 if (!ha->iobase) {
1883 qla_printk(KERN_ERR, ha,
1884 "cannot remap MMIO (%s), aborting\n", pci_name(ha->pdev));
1885
1886 goto iospace_error_exit;
1887 }
1888
Anirban Chakraborty73208df2008-12-09 16:45:39 -08001889 /* Determine queue resources */
Anirban Chakraborty2afa19a2009-04-06 22:33:40 -07001890 ha->max_req_queues = ha->max_rsp_queues = 1;
Michael Hernandezd84a47c2010-03-19 16:59:18 -07001891 if ((ql2xmaxqueues <= 1 && !ql2xmultique_tag) ||
1892 (ql2xmaxqueues > 1 && ql2xmultique_tag) ||
Anirban Chakraborty2afa19a2009-04-06 22:33:40 -07001893 (!IS_QLA25XX(ha) && !IS_QLA81XX(ha)))
Anirban Chakraborty17d98632008-12-18 10:06:15 -08001894 goto mqiobase_exit;
Michael Hernandezd84a47c2010-03-19 16:59:18 -07001895
Anirban Chakraborty17d98632008-12-18 10:06:15 -08001896 ha->mqiobase = ioremap(pci_resource_start(ha->pdev, 3),
1897 pci_resource_len(ha->pdev, 3));
1898 if (ha->mqiobase) {
1899 /* Read MSIX vector size of the board */
1900 pci_read_config_word(ha->pdev, QLA_PCI_MSIX_CONTROL, &msix);
1901 ha->msix_count = msix;
Anirban Chakraborty68ca9492009-04-06 22:33:41 -07001902 /* Max queues are bounded by available msix vectors */
1903 /* queue 0 uses two msix vectors */
1904 if (ql2xmultique_tag) {
1905 cpus = num_online_cpus();
Anirban Chakraborty27dc9c52009-06-17 10:30:28 -07001906 ha->max_rsp_queues = (ha->msix_count - 1 > cpus) ?
Anirban Chakraborty68ca9492009-04-06 22:33:41 -07001907 (cpus + 1) : (ha->msix_count - 1);
1908 ha->max_req_queues = 2;
1909 } else if (ql2xmaxqueues > 1) {
Anirban Chakraborty2afa19a2009-04-06 22:33:40 -07001910 ha->max_req_queues = ql2xmaxqueues > QLA_MQ_SIZE ?
1911 QLA_MQ_SIZE : ql2xmaxqueues;
1912 DEBUG2(qla_printk(KERN_INFO, ha, "QoS mode set, max no"
1913 " of request queues:%d\n", ha->max_req_queues));
1914 }
Anirban Chakraborty68ca9492009-04-06 22:33:41 -07001915 qla_printk(KERN_INFO, ha,
1916 "MSI-X vector count: %d\n", msix);
Anirban Chakraborty2afa19a2009-04-06 22:33:40 -07001917 } else
1918 qla_printk(KERN_INFO, ha, "BAR 3 not enabled\n");
Anirban Chakraborty17d98632008-12-18 10:06:15 -08001919
1920mqiobase_exit:
Anirban Chakraborty2afa19a2009-04-06 22:33:40 -07001921 ha->msix_count = ha->max_rsp_queues + 1;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001922 return (0);
1923
1924iospace_error_exit:
1925 return (-ENOMEM);
1926}
1927
Andrew Vasquezabbd8872005-07-06 10:30:05 -07001928static void
Andrew Vasquez1e99e332006-11-22 08:24:48 -08001929qla2xxx_scan_start(struct Scsi_Host *shost)
1930{
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001931 scsi_qla_host_t *vha = shost_priv(shost);
Andrew Vasquez1e99e332006-11-22 08:24:48 -08001932
Andrew Vasquezcbc8eb62009-06-03 09:55:17 -07001933 if (vha->hw->flags.running_gold_fw)
1934 return;
1935
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001936 set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags);
1937 set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags);
1938 set_bit(RSCN_UPDATE, &vha->dpc_flags);
1939 set_bit(NPIV_CONFIG_NEEDED, &vha->dpc_flags);
Andrew Vasquez1e99e332006-11-22 08:24:48 -08001940}
1941
1942static int
1943qla2xxx_scan_finished(struct Scsi_Host *shost, unsigned long time)
1944{
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001945 scsi_qla_host_t *vha = shost_priv(shost);
Andrew Vasquez1e99e332006-11-22 08:24:48 -08001946
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001947 if (!vha->host)
Andrew Vasquez1e99e332006-11-22 08:24:48 -08001948 return 1;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001949 if (time > vha->hw->loop_reset_delay * HZ)
Andrew Vasquez1e99e332006-11-22 08:24:48 -08001950 return 1;
1951
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001952 return atomic_read(&vha->loop_state) == LOOP_READY;
Andrew Vasquez1e99e332006-11-22 08:24:48 -08001953}
1954
Linus Torvalds1da177e2005-04-16 15:20:36 -07001955/*
1956 * PCI driver interface
1957 */
Andrew Vasquez7ee61392006-06-23 16:11:22 -07001958static int __devinit
1959qla2x00_probe_one(struct pci_dev *pdev, const struct pci_device_id *id)
Linus Torvalds1da177e2005-04-16 15:20:36 -07001960{
Andrew Vasqueza1541d52005-06-09 17:21:28 -07001961 int ret = -ENODEV;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001962 struct Scsi_Host *host;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001963 scsi_qla_host_t *base_vha = NULL;
1964 struct qla_hw_data *ha;
Andrew Vasquez29856e22007-08-12 18:22:52 -07001965 char pci_info[30];
Linus Torvalds1da177e2005-04-16 15:20:36 -07001966 char fw_str[30];
Andrew Vasquez54333832005-11-09 15:49:04 -08001967 struct scsi_host_template *sht;
Anirban Chakrabortyc51da4e2008-11-10 15:53:20 -08001968 int bars, max_id, mem_only = 0;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001969 uint16_t req_length = 0, rsp_length = 0;
Anirban Chakraborty73208df2008-12-09 16:45:39 -08001970 struct req_que *req = NULL;
1971 struct rsp_que *rsp = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07001972
Andrew Vasquez285d0322007-10-19 15:59:17 -07001973 bars = pci_select_bars(pdev, IORESOURCE_MEM | IORESOURCE_IO);
Giridhar Malavalia5326f82009-03-24 09:07:56 -07001974 sht = &qla2xxx_driver_template;
Andrew Vasquez285d0322007-10-19 15:59:17 -07001975 if (pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2422 ||
1976 pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2432 ||
Harihara Kadayam4d4df192008-04-03 13:13:26 -07001977 pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8432 ||
Andrew Vasquez285d0322007-10-19 15:59:17 -07001978 pdev->device == PCI_DEVICE_ID_QLOGIC_ISP5422 ||
1979 pdev->device == PCI_DEVICE_ID_QLOGIC_ISP5432 ||
Andrew Vasquez3a03eb72009-01-05 11:18:11 -08001980 pdev->device == PCI_DEVICE_ID_QLOGIC_ISP2532 ||
Giridhar Malavalia9083012010-04-12 17:59:55 -07001981 pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8001 ||
1982 pdev->device == PCI_DEVICE_ID_QLOGIC_ISP8021) {
Andrew Vasquez285d0322007-10-19 15:59:17 -07001983 bars = pci_select_bars(pdev, IORESOURCE_MEM);
Benjamin Herrenschmidt09483912007-12-20 15:28:09 +11001984 mem_only = 1;
Andrew Vasquez285d0322007-10-19 15:59:17 -07001985 }
1986
Benjamin Herrenschmidt09483912007-12-20 15:28:09 +11001987 if (mem_only) {
1988 if (pci_enable_device_mem(pdev))
1989 goto probe_out;
1990 } else {
1991 if (pci_enable_device(pdev))
1992 goto probe_out;
1993 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07001994
Jesse Barnes09276782008-10-18 17:33:19 -07001995 /* This may fail but that's ok */
1996 pci_enable_pcie_error_reporting(pdev);
Seokmann Ju14e660e2007-09-20 14:07:36 -07001997
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08001998 ha = kzalloc(sizeof(struct qla_hw_data), GFP_KERNEL);
1999 if (!ha) {
2000 DEBUG(printk("Unable to allocate memory for ha\n"));
2001 goto probe_out;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002002 }
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002003 ha->pdev = pdev;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002004
2005 /* Clear our data area */
Andrew Vasquez285d0322007-10-19 15:59:17 -07002006 ha->bars = bars;
Benjamin Herrenschmidt09483912007-12-20 15:28:09 +11002007 ha->mem_only = mem_only;
Andrew Vasquezdf4bf0b2008-01-31 12:33:46 -08002008 spin_lock_init(&ha->hardware_lock);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002009
andrew.vasquez@qlogic.comea5b6382006-03-09 14:27:08 -08002010 /* Set ISP-type information. */
2011 qla2x00_set_isp_flags(ha);
Duane Grigsbyca79cf62009-12-15 21:29:47 -08002012
2013 /* Set EEH reset type to fundamental if required by hba */
2014 if ( IS_QLA24XX(ha) || IS_QLA25XX(ha) || IS_QLA81XX(ha)) {
2015 pdev->needs_freset = 1;
Duane Grigsbyca79cf62009-12-15 21:29:47 -08002016 }
2017
Linus Torvalds1da177e2005-04-16 15:20:36 -07002018 /* Configure PCI I/O space */
2019 ret = qla2x00_iospace_config(ha);
Andrew Vasqueza1541d52005-06-09 17:21:28 -07002020 if (ret)
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002021 goto probe_hw_failed;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002022
Linus Torvalds1da177e2005-04-16 15:20:36 -07002023 qla_printk(KERN_INFO, ha,
Andrew Vasquez54333832005-11-09 15:49:04 -08002024 "Found an ISP%04X, irq %d, iobase 0x%p\n", pdev->device, pdev->irq,
2025 ha->iobase);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002026
Linus Torvalds1da177e2005-04-16 15:20:36 -07002027 ha->prev_topology = 0;
Andrew Vasquezfca29702005-07-06 10:31:47 -07002028 ha->init_cb_size = sizeof(init_cb_t);
Andrew Vasquezd8b45212006-10-02 12:00:43 -07002029 ha->link_data_rate = PORT_SPEED_UNKNOWN;
andrew.vasquez@qlogic.com854165f2006-01-31 16:05:17 -08002030 ha->optrom_size = OPTROM_SIZE_2300;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002031
Andrew Vasquezabbd8872005-07-06 10:30:05 -07002032 /* Assign ISP specific operations. */
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002033 max_id = MAX_TARGETS_2200;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002034 if (IS_QLA2100(ha)) {
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002035 max_id = MAX_TARGETS_2100;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002036 ha->mbx_count = MAILBOX_REGISTER_COUNT_2100;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002037 req_length = REQUEST_ENTRY_CNT_2100;
2038 rsp_length = RESPONSE_ENTRY_CNT_2100;
2039 ha->max_loop_id = SNS_LAST_LOOP_ID_2100;
Andrew Vasquezabbd8872005-07-06 10:30:05 -07002040 ha->gid_list_info_size = 4;
Andrew Vasquez3a03eb72009-01-05 11:18:11 -08002041 ha->flash_conf_off = ~0;
2042 ha->flash_data_off = ~0;
2043 ha->nvram_conf_off = ~0;
2044 ha->nvram_data_off = ~0;
Andrew Vasquezfd34f552007-07-19 15:06:00 -07002045 ha->isp_ops = &qla2100_isp_ops;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002046 } else if (IS_QLA2200(ha)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002047 ha->mbx_count = MAILBOX_REGISTER_COUNT;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002048 req_length = REQUEST_ENTRY_CNT_2200;
2049 rsp_length = RESPONSE_ENTRY_CNT_2100;
2050 ha->max_loop_id = SNS_LAST_LOOP_ID_2100;
Andrew Vasquezabbd8872005-07-06 10:30:05 -07002051 ha->gid_list_info_size = 4;
Andrew Vasquez3a03eb72009-01-05 11:18:11 -08002052 ha->flash_conf_off = ~0;
2053 ha->flash_data_off = ~0;
2054 ha->nvram_conf_off = ~0;
2055 ha->nvram_data_off = ~0;
Andrew Vasquezfd34f552007-07-19 15:06:00 -07002056 ha->isp_ops = &qla2100_isp_ops;
Andrew Vasquezfca29702005-07-06 10:31:47 -07002057 } else if (IS_QLA23XX(ha)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002058 ha->mbx_count = MAILBOX_REGISTER_COUNT;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002059 req_length = REQUEST_ENTRY_CNT_2200;
2060 rsp_length = RESPONSE_ENTRY_CNT_2300;
2061 ha->max_loop_id = SNS_LAST_LOOP_ID_2300;
Andrew Vasquezabbd8872005-07-06 10:30:05 -07002062 ha->gid_list_info_size = 6;
andrew.vasquez@qlogic.com854165f2006-01-31 16:05:17 -08002063 if (IS_QLA2322(ha) || IS_QLA6322(ha))
2064 ha->optrom_size = OPTROM_SIZE_2322;
Andrew Vasquez3a03eb72009-01-05 11:18:11 -08002065 ha->flash_conf_off = ~0;
2066 ha->flash_data_off = ~0;
2067 ha->nvram_conf_off = ~0;
2068 ha->nvram_data_off = ~0;
Andrew Vasquezfd34f552007-07-19 15:06:00 -07002069 ha->isp_ops = &qla2300_isp_ops;
Harihara Kadayam4d4df192008-04-03 13:13:26 -07002070 } else if (IS_QLA24XX_TYPE(ha)) {
Andrew Vasquezfca29702005-07-06 10:31:47 -07002071 ha->mbx_count = MAILBOX_REGISTER_COUNT;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002072 req_length = REQUEST_ENTRY_CNT_24XX;
2073 rsp_length = RESPONSE_ENTRY_CNT_2300;
2074 ha->max_loop_id = SNS_LAST_LOOP_ID_2300;
Seokmann Ju2c3dfe32007-07-05 13:16:51 -07002075 ha->init_cb_size = sizeof(struct mid_init_cb_24xx);
Andrew Vasquezfca29702005-07-06 10:31:47 -07002076 ha->gid_list_info_size = 8;
andrew.vasquez@qlogic.com854165f2006-01-31 16:05:17 -08002077 ha->optrom_size = OPTROM_SIZE_24XX;
Anirban Chakraborty73208df2008-12-09 16:45:39 -08002078 ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA24XX;
Andrew Vasquezfd34f552007-07-19 15:06:00 -07002079 ha->isp_ops = &qla24xx_isp_ops;
Andrew Vasquez3a03eb72009-01-05 11:18:11 -08002080 ha->flash_conf_off = FARX_ACCESS_FLASH_CONF;
2081 ha->flash_data_off = FARX_ACCESS_FLASH_DATA;
2082 ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF;
2083 ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA;
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07002084 } else if (IS_QLA25XX(ha)) {
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07002085 ha->mbx_count = MAILBOX_REGISTER_COUNT;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002086 req_length = REQUEST_ENTRY_CNT_24XX;
2087 rsp_length = RESPONSE_ENTRY_CNT_2300;
2088 ha->max_loop_id = SNS_LAST_LOOP_ID_2300;
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07002089 ha->init_cb_size = sizeof(struct mid_init_cb_24xx);
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07002090 ha->gid_list_info_size = 8;
2091 ha->optrom_size = OPTROM_SIZE_25XX;
Anirban Chakraborty73208df2008-12-09 16:45:39 -08002092 ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX;
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07002093 ha->isp_ops = &qla25xx_isp_ops;
Andrew Vasquez3a03eb72009-01-05 11:18:11 -08002094 ha->flash_conf_off = FARX_ACCESS_FLASH_CONF;
2095 ha->flash_data_off = FARX_ACCESS_FLASH_DATA;
2096 ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF;
2097 ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA;
2098 } else if (IS_QLA81XX(ha)) {
2099 ha->mbx_count = MAILBOX_REGISTER_COUNT;
2100 req_length = REQUEST_ENTRY_CNT_24XX;
2101 rsp_length = RESPONSE_ENTRY_CNT_2300;
2102 ha->max_loop_id = SNS_LAST_LOOP_ID_2300;
2103 ha->init_cb_size = sizeof(struct mid_init_cb_81xx);
2104 ha->gid_list_info_size = 8;
2105 ha->optrom_size = OPTROM_SIZE_81XX;
Anirban Chakraborty40859ae2009-06-03 09:55:16 -07002106 ha->nvram_npiv_size = QLA_MAX_VPORTS_QLA25XX;
Andrew Vasquez3a03eb72009-01-05 11:18:11 -08002107 ha->isp_ops = &qla81xx_isp_ops;
2108 ha->flash_conf_off = FARX_ACCESS_FLASH_CONF_81XX;
2109 ha->flash_data_off = FARX_ACCESS_FLASH_DATA_81XX;
2110 ha->nvram_conf_off = ~0;
2111 ha->nvram_data_off = ~0;
Giridhar Malavalia9083012010-04-12 17:59:55 -07002112 } else if (IS_QLA82XX(ha)) {
2113 ha->mbx_count = MAILBOX_REGISTER_COUNT;
2114 req_length = REQUEST_ENTRY_CNT_82XX;
2115 rsp_length = RESPONSE_ENTRY_CNT_82XX;
2116 ha->max_loop_id = SNS_LAST_LOOP_ID_2300;
2117 ha->init_cb_size = sizeof(struct mid_init_cb_81xx);
2118 ha->gid_list_info_size = 8;
2119 ha->optrom_size = OPTROM_SIZE_82XX;
2120 ha->isp_ops = &qla82xx_isp_ops;
2121 ha->flash_conf_off = FARX_ACCESS_FLASH_CONF;
2122 ha->flash_data_off = FARX_ACCESS_FLASH_DATA;
2123 ha->nvram_conf_off = FARX_ACCESS_NVRAM_CONF;
2124 ha->nvram_data_off = FARX_ACCESS_NVRAM_DATA;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002125 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07002126
matthias@kaehlcke.net6c2f5272008-05-12 22:21:11 -07002127 mutex_init(&ha->vport_lock);
Marcus Barrow0b05a1f2008-01-17 09:02:13 -08002128 init_completion(&ha->mbx_cmd_comp);
2129 complete(&ha->mbx_cmd_comp);
2130 init_completion(&ha->mbx_intr_comp);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002131
Seokmann Ju2c3dfe32007-07-05 13:16:51 -07002132 set_bit(0, (unsigned long *) ha->vp_idx_map);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002133
Andrew Vasquez53303c42009-01-22 09:45:37 -08002134 qla2x00_config_dma_addressing(ha);
Anirban Chakraborty73208df2008-12-09 16:45:39 -08002135 ret = qla2x00_mem_alloc(ha, req_length, rsp_length, &req, &rsp);
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002136 if (!ret) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07002137 qla_printk(KERN_WARNING, ha,
2138 "[ERROR] Failed to allocate memory for adapter\n");
2139
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002140 goto probe_hw_failed;
2141 }
2142
Anirban Chakraborty73208df2008-12-09 16:45:39 -08002143 req->max_q_depth = MAX_Q_DEPTH;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002144 if (ql2xmaxqdepth != 0 && ql2xmaxqdepth <= 0xffffU)
Anirban Chakraborty73208df2008-12-09 16:45:39 -08002145 req->max_q_depth = ql2xmaxqdepth;
2146
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002147
2148 base_vha = qla2x00_create_host(sht, ha);
2149 if (!base_vha) {
2150 qla_printk(KERN_WARNING, ha,
2151 "[ERROR] Failed to allocate memory for scsi_host\n");
2152
Andrew Vasqueza1541d52005-06-09 17:21:28 -07002153 ret = -ENOMEM;
Anirban Chakraborty6e9f21f2009-01-22 09:45:28 -08002154 qla2x00_mem_free(ha);
Anirban Chakraborty2afa19a2009-04-06 22:33:40 -07002155 qla2x00_free_req_que(ha, req);
2156 qla2x00_free_rsp_que(ha, rsp);
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002157 goto probe_hw_failed;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002158 }
2159
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002160 pci_set_drvdata(pdev, base_vha);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002161
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002162 host = base_vha->host;
Anirban Chakraborty2afa19a2009-04-06 22:33:40 -07002163 base_vha->req = req;
Anirban Chakraborty73208df2008-12-09 16:45:39 -08002164 host->can_queue = req->length + 128;
2165 if (IS_QLA2XXX_MIDTYPE(ha))
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002166 base_vha->mgmt_svr_loop_id = 10 + base_vha->vp_idx;
Anirban Chakraborty73208df2008-12-09 16:45:39 -08002167 else
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002168 base_vha->mgmt_svr_loop_id = MANAGEMENT_SERVER +
2169 base_vha->vp_idx;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002170 if (IS_QLA2100(ha))
2171 host->sg_tablesize = 32;
2172 host->max_id = max_id;
Andrew Vasqueza1541d52005-06-09 17:21:28 -07002173 host->this_id = 255;
2174 host->cmd_per_lun = 3;
Seokmann Ju711c1d92008-07-10 16:55:51 -07002175 host->unique_id = host->host_no;
Andrew Vasqueza1541d52005-06-09 17:21:28 -07002176 host->max_cmd_len = MAX_CMDSZ;
Andrew Vasquez75bc4192006-05-17 15:09:22 -07002177 host->max_channel = MAX_BUSES - 1;
Andrew Vasqueza1541d52005-06-09 17:21:28 -07002178 host->max_lun = MAX_LUNS;
2179 host->transportt = qla2xxx_transport_template;
Giridhar Malavali9a069e12010-01-12 13:02:47 -08002180 sht->vendor_id = (SCSI_NL_VID_TYPE_PCI | PCI_VENDOR_ID_QLOGIC);
Andrew Vasqueza1541d52005-06-09 17:21:28 -07002181
Anirban Chakraborty73208df2008-12-09 16:45:39 -08002182 /* Set up the irqs */
2183 ret = qla2x00_request_irqs(ha, rsp);
2184 if (ret)
Anirban Chakraborty6e9f21f2009-01-22 09:45:28 -08002185 goto probe_init_failed;
Joe Carnuccio90a86fc2010-01-12 13:02:46 -08002186
2187 pci_save_state(pdev);
2188
Anirban Chakraborty73208df2008-12-09 16:45:39 -08002189 /* Alloc arrays of request and response ring ptrs */
Anirban Chakraborty7163ea82009-08-05 09:18:40 -07002190que_init:
Anirban Chakraborty73208df2008-12-09 16:45:39 -08002191 if (!qla2x00_alloc_queues(ha)) {
2192 qla_printk(KERN_WARNING, ha,
2193 "[ERROR] Failed to allocate memory for queue"
2194 " pointers\n");
Anirban Chakraborty6e9f21f2009-01-22 09:45:28 -08002195 goto probe_init_failed;
Anirban Chakraborty73208df2008-12-09 16:45:39 -08002196 }
Giridhar Malavalia9083012010-04-12 17:59:55 -07002197
Anirban Chakraborty73208df2008-12-09 16:45:39 -08002198 ha->rsp_q_map[0] = rsp;
2199 ha->req_q_map[0] = req;
Anirban Chakraborty2afa19a2009-04-06 22:33:40 -07002200 rsp->req = req;
2201 req->rsp = rsp;
2202 set_bit(0, ha->req_qid_map);
2203 set_bit(0, ha->rsp_qid_map);
Andrew Vasquez08029992009-03-24 09:07:55 -07002204 /* FWI2-capable only. */
2205 req->req_q_in = &ha->iobase->isp24.req_q_in;
2206 req->req_q_out = &ha->iobase->isp24.req_q_out;
2207 rsp->rsp_q_in = &ha->iobase->isp24.rsp_q_in;
2208 rsp->rsp_q_out = &ha->iobase->isp24.rsp_q_out;
Anirban Chakraborty17d98632008-12-18 10:06:15 -08002209 if (ha->mqenable) {
Andrew Vasquez08029992009-03-24 09:07:55 -07002210 req->req_q_in = &ha->mqiobase->isp25mq.req_q_in;
2211 req->req_q_out = &ha->mqiobase->isp25mq.req_q_out;
2212 rsp->rsp_q_in = &ha->mqiobase->isp25mq.rsp_q_in;
2213 rsp->rsp_q_out = &ha->mqiobase->isp25mq.rsp_q_out;
Anirban Chakraborty17d98632008-12-18 10:06:15 -08002214 }
2215
Giridhar Malavalia9083012010-04-12 17:59:55 -07002216 if (IS_QLA82XX(ha)) {
2217 req->req_q_out = &ha->iobase->isp82.req_q_out[0];
2218 rsp->rsp_q_in = &ha->iobase->isp82.rsp_q_in[0];
2219 rsp->rsp_q_out = &ha->iobase->isp82.rsp_q_out[0];
2220 }
2221
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002222 if (qla2x00_initialize_adapter(base_vha)) {
2223 qla_printk(KERN_WARNING, ha,
2224 "Failed to initialize adapter\n");
2225
2226 DEBUG2(printk("scsi(%ld): Failed to initialize adapter - "
2227 "Adapter flags %x.\n",
2228 base_vha->host_no, base_vha->device_flags));
2229
Giridhar Malavalia9083012010-04-12 17:59:55 -07002230 if (IS_QLA82XX(ha)) {
2231 qla82xx_idc_lock(ha);
2232 qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE,
2233 QLA82XX_DEV_FAILED);
2234 qla82xx_idc_unlock(ha);
2235 qla_printk(KERN_INFO, ha, "HW State: FAILED\n");
2236 }
2237
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002238 ret = -ENODEV;
2239 goto probe_failed;
2240 }
2241
Anirban Chakraborty7163ea82009-08-05 09:18:40 -07002242 if (ha->mqenable) {
2243 if (qla25xx_setup_mode(base_vha)) {
Anirban Chakraborty68ca9492009-04-06 22:33:41 -07002244 qla_printk(KERN_WARNING, ha,
2245 "Can't create queues, falling back to single"
2246 " queue mode\n");
Anirban Chakraborty7163ea82009-08-05 09:18:40 -07002247 goto que_init;
2248 }
2249 }
Anirban Chakraborty68ca9492009-04-06 22:33:41 -07002250
Andrew Vasquezcbc8eb62009-06-03 09:55:17 -07002251 if (ha->flags.running_gold_fw)
2252 goto skip_dpc;
2253
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002254 /*
2255 * Startup the kernel thread for this host adapter
2256 */
2257 ha->dpc_thread = kthread_create(qla2x00_do_dpc, ha,
2258 "%s_dpc", base_vha->host_str);
2259 if (IS_ERR(ha->dpc_thread)) {
2260 qla_printk(KERN_WARNING, ha,
2261 "Unable to start DPC thread!\n");
2262 ret = PTR_ERR(ha->dpc_thread);
2263 goto probe_failed;
2264 }
2265
Andrew Vasquezcbc8eb62009-06-03 09:55:17 -07002266skip_dpc:
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002267 list_add_tail(&base_vha->list, &ha->vp_list);
2268 base_vha->host->irq = ha->pdev->irq;
2269
Linus Torvalds1da177e2005-04-16 15:20:36 -07002270 /* Initialized the timer */
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002271 qla2x00_start_timer(base_vha, qla2x00_timer, WATCH_INTERVAL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002272
2273 DEBUG2(printk("DEBUG: detect hba %ld at address = %p\n",
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002274 base_vha->host_no, ha));
Linus Torvalds1da177e2005-04-16 15:20:36 -07002275
Arun Easibad75002010-05-04 15:01:30 -07002276 if (IS_QLA25XX(ha) && ql2xenabledif) {
2277 if (ha->fw_attributes & BIT_4) {
2278 base_vha->flags.difdix_supported = 1;
2279 DEBUG18(qla_printk(KERN_INFO, ha,
2280 "Registering for DIF/DIX type 1 and 3"
2281 " protection.\n"));
2282 scsi_host_set_prot(host,
2283 SHOST_DIF_TYPE1_PROTECTION
2284 | SHOST_DIF_TYPE3_PROTECTION
2285 | SHOST_DIX_TYPE1_PROTECTION
2286 | SHOST_DIX_TYPE3_PROTECTION);
2287 scsi_host_set_guard(host, SHOST_DIX_GUARD_CRC);
2288 } else
2289 base_vha->flags.difdix_supported = 0;
2290 }
2291
Giridhar Malavalia9083012010-04-12 17:59:55 -07002292 ha->isp_ops->enable_intrs(ha);
2293
Andrew Vasqueza1541d52005-06-09 17:21:28 -07002294 ret = scsi_add_host(host, &pdev->dev);
2295 if (ret)
2296 goto probe_failed;
2297
Michael Reed14864002009-12-02 09:11:16 -06002298 base_vha->flags.init_done = 1;
2299 base_vha->flags.online = 1;
2300
Andrew Vasquez1e99e332006-11-22 08:24:48 -08002301 scsi_scan_host(host);
2302
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002303 qla2x00_alloc_sysfs_attr(base_vha);
Andrew Vasqueza1541d52005-06-09 17:21:28 -07002304
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002305 qla2x00_init_host_attr(base_vha);
Andrew Vasqueza1541d52005-06-09 17:21:28 -07002306
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002307 qla2x00_dfs_setup(base_vha);
Andrew Vasquezdf613b92008-01-17 09:02:17 -08002308
Linus Torvalds1da177e2005-04-16 15:20:36 -07002309 qla_printk(KERN_INFO, ha, "\n"
2310 " QLogic Fibre Channel HBA Driver: %s\n"
2311 " QLogic %s - %s\n"
Andrew Vasquez54333832005-11-09 15:49:04 -08002312 " ISP%04X: %s @ %s hdma%c, host#=%ld, fw=%s\n",
2313 qla2x00_version_str, ha->model_number,
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002314 ha->model_desc ? ha->model_desc : "", pdev->device,
2315 ha->isp_ops->pci_info_str(base_vha, pci_info), pci_name(pdev),
2316 ha->flags.enable_64bit_addressing ? '+' : '-', base_vha->host_no,
2317 ha->isp_ops->fw_version_str(base_vha, fw_str));
Linus Torvalds1da177e2005-04-16 15:20:36 -07002318
Linus Torvalds1da177e2005-04-16 15:20:36 -07002319 return 0;
2320
Anirban Chakraborty6e9f21f2009-01-22 09:45:28 -08002321probe_init_failed:
Anirban Chakraborty2afa19a2009-04-06 22:33:40 -07002322 qla2x00_free_req_que(ha, req);
2323 qla2x00_free_rsp_que(ha, rsp);
2324 ha->max_req_queues = ha->max_rsp_queues = 0;
Anirban Chakraborty6e9f21f2009-01-22 09:45:28 -08002325
Linus Torvalds1da177e2005-04-16 15:20:36 -07002326probe_failed:
Andrew Vasquezb9978762009-03-24 09:08:05 -07002327 if (base_vha->timer_active)
2328 qla2x00_stop_timer(base_vha);
2329 base_vha->flags.online = 0;
2330 if (ha->dpc_thread) {
2331 struct task_struct *t = ha->dpc_thread;
2332
2333 ha->dpc_thread = NULL;
2334 kthread_stop(t);
2335 }
2336
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002337 qla2x00_free_device(base_vha);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002338
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002339 scsi_host_put(base_vha->host);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002340
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002341probe_hw_failed:
Giridhar Malavalia9083012010-04-12 17:59:55 -07002342 if (IS_QLA82XX(ha)) {
2343 qla82xx_idc_lock(ha);
2344 qla82xx_clear_drv_active(ha);
2345 qla82xx_idc_unlock(ha);
2346 iounmap((device_reg_t __iomem *)ha->nx_pcibase);
2347 if (!ql2xdbwr)
2348 iounmap((device_reg_t __iomem *)ha->nxdb_wr_ptr);
2349 } else {
2350 if (ha->iobase)
2351 iounmap(ha->iobase);
2352 }
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002353 pci_release_selected_regions(ha->pdev, ha->bars);
2354 kfree(ha);
2355 ha = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002356
Andrew Vasqueza1541d52005-06-09 17:21:28 -07002357probe_out:
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002358 pci_disable_device(pdev);
Andrew Vasqueza1541d52005-06-09 17:21:28 -07002359 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002360}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002361
Adrian Bunk4c993f72008-01-14 00:55:16 -08002362static void
Andrew Vasquez7ee61392006-06-23 16:11:22 -07002363qla2x00_remove_one(struct pci_dev *pdev)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002364{
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002365 scsi_qla_host_t *base_vha, *vha, *temp;
2366 struct qla_hw_data *ha;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002367
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002368 base_vha = pci_get_drvdata(pdev);
2369 ha = base_vha->hw;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002370
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002371 list_for_each_entry_safe(vha, temp, &ha->vp_list, list) {
2372 if (vha && vha->fc_vport)
2373 fc_vport_terminate(vha->fc_vport);
2374 }
Andrew Vasquezc795c1e2008-08-13 21:37:01 -07002375
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002376 set_bit(UNLOADING, &base_vha->dpc_flags);
Andrew Vasquezc795c1e2008-08-13 21:37:01 -07002377
Andrew Vasquezb9978762009-03-24 09:08:05 -07002378 qla2x00_abort_all_cmds(base_vha, DID_NO_CONNECT << 16);
2379
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002380 qla2x00_dfs_remove(base_vha);
Andrew Vasquezdf613b92008-01-17 09:02:17 -08002381
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002382 qla84xx_put_chip(base_vha);
Harihara Kadayam4d4df192008-04-03 13:13:26 -07002383
Andrew Vasquezb9978762009-03-24 09:08:05 -07002384 /* Disable timer */
2385 if (base_vha->timer_active)
2386 qla2x00_stop_timer(base_vha);
2387
2388 base_vha->flags.online = 0;
2389
Anirban Chakraborty68ca9492009-04-06 22:33:41 -07002390 /* Flush the work queue and remove it */
2391 if (ha->wq) {
2392 flush_workqueue(ha->wq);
2393 destroy_workqueue(ha->wq);
2394 ha->wq = NULL;
2395 }
2396
Andrew Vasquezb9978762009-03-24 09:08:05 -07002397 /* Kill the kernel thread for this host */
2398 if (ha->dpc_thread) {
2399 struct task_struct *t = ha->dpc_thread;
2400
2401 /*
2402 * qla2xxx_wake_dpc checks for ->dpc_thread
2403 * so we need to zero it out.
2404 */
2405 ha->dpc_thread = NULL;
2406 kthread_stop(t);
2407 }
2408
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002409 qla2x00_free_sysfs_attr(base_vha);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002410
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002411 fc_remove_host(base_vha->host);
bdf79622005-04-17 15:06:53 -05002412
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002413 scsi_remove_host(base_vha->host);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002414
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002415 qla2x00_free_device(base_vha);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002416
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002417 scsi_host_put(base_vha->host);
2418
Giridhar Malavalia9083012010-04-12 17:59:55 -07002419 if (IS_QLA82XX(ha)) {
Giridhar Malavalib9637522010-05-28 15:08:15 -07002420 qla82xx_idc_lock(ha);
2421 qla82xx_clear_drv_active(ha);
2422 qla82xx_idc_unlock(ha);
2423
Giridhar Malavalia9083012010-04-12 17:59:55 -07002424 iounmap((device_reg_t __iomem *)ha->nx_pcibase);
2425 if (!ql2xdbwr)
2426 iounmap((device_reg_t __iomem *)ha->nxdb_wr_ptr);
2427 } else {
2428 if (ha->iobase)
2429 iounmap(ha->iobase);
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002430
Giridhar Malavalia9083012010-04-12 17:59:55 -07002431 if (ha->mqiobase)
2432 iounmap(ha->mqiobase);
2433 }
Anirban Chakraborty73208df2008-12-09 16:45:39 -08002434
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002435 pci_release_selected_regions(ha->pdev, ha->bars);
2436 kfree(ha);
2437 ha = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002438
Joe Carnuccio90a86fc2010-01-12 13:02:46 -08002439 pci_disable_pcie_error_reporting(pdev);
2440
Bernhard Walle665db932007-03-28 00:49:49 +02002441 pci_disable_device(pdev);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002442 pci_set_drvdata(pdev, NULL);
2443}
Linus Torvalds1da177e2005-04-16 15:20:36 -07002444
2445static void
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002446qla2x00_free_device(scsi_qla_host_t *vha)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002447{
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002448 struct qla_hw_data *ha = vha->hw;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002449
Andrew Vasquez85880802009-12-15 21:29:46 -08002450 qla2x00_abort_all_cmds(vha, DID_NO_CONNECT << 16);
2451
2452 /* Disable timer */
2453 if (vha->timer_active)
2454 qla2x00_stop_timer(vha);
2455
2456 /* Kill the kernel thread for this host */
2457 if (ha->dpc_thread) {
2458 struct task_struct *t = ha->dpc_thread;
2459
2460 /*
2461 * qla2xxx_wake_dpc checks for ->dpc_thread
2462 * so we need to zero it out.
2463 */
2464 ha->dpc_thread = NULL;
2465 kthread_stop(t);
2466 }
2467
Anirban Chakraborty2afa19a2009-04-06 22:33:40 -07002468 qla25xx_delete_queues(vha);
2469
Andrew Vasquezdf613b92008-01-17 09:02:17 -08002470 if (ha->flags.fce_enabled)
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002471 qla2x00_disable_fce_trace(vha, NULL, NULL);
Andrew Vasquezdf613b92008-01-17 09:02:17 -08002472
Andrew Vasqueza7a167b2006-06-23 16:10:29 -07002473 if (ha->eft)
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002474 qla2x00_disable_eft_trace(vha);
Andrew Vasqueza7a167b2006-06-23 16:10:29 -07002475
Andrew Vasquezf6ef3b12005-08-26 19:10:20 -07002476 /* Stop currently executing firmware. */
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002477 qla2x00_try_to_stop_firmware(vha);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002478
Andrew Vasquez85880802009-12-15 21:29:46 -08002479 vha->flags.online = 0;
2480
Andrew Vasquezf6ef3b12005-08-26 19:10:20 -07002481 /* turn-off interrupts on the card */
Giridhar Malavalia9083012010-04-12 17:59:55 -07002482 if (ha->interrupts_on) {
2483 vha->flags.init_done = 0;
Andrew Vasquezfd34f552007-07-19 15:06:00 -07002484 ha->isp_ops->disable_intrs(ha);
Giridhar Malavalia9083012010-04-12 17:59:55 -07002485 }
Andrew Vasquezf6ef3b12005-08-26 19:10:20 -07002486
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002487 qla2x00_free_irqs(vha);
2488
Andrew Vasquezf6ef3b12005-08-26 19:10:20 -07002489 qla2x00_mem_free(ha);
Anirban Chakraborty73208df2008-12-09 16:45:39 -08002490
2491 qla2x00_free_queues(ha);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002492}
2493
andrew.vasquez@qlogic.comd97994d2006-01-20 14:53:13 -08002494static inline void
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002495qla2x00_schedule_rport_del(struct scsi_qla_host *vha, fc_port_t *fcport,
andrew.vasquez@qlogic.comd97994d2006-01-20 14:53:13 -08002496 int defer)
2497{
andrew.vasquez@qlogic.comd97994d2006-01-20 14:53:13 -08002498 struct fc_rport *rport;
Andrew Vasquez67becc02009-08-25 11:36:20 -07002499 scsi_qla_host_t *base_vha;
andrew.vasquez@qlogic.comd97994d2006-01-20 14:53:13 -08002500
2501 if (!fcport->rport)
2502 return;
2503
2504 rport = fcport->rport;
2505 if (defer) {
Andrew Vasquez67becc02009-08-25 11:36:20 -07002506 base_vha = pci_get_drvdata(vha->hw->pdev);
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002507 spin_lock_irq(vha->host->host_lock);
andrew.vasquez@qlogic.comd97994d2006-01-20 14:53:13 -08002508 fcport->drport = rport;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002509 spin_unlock_irq(vha->host->host_lock);
Andrew Vasquez67becc02009-08-25 11:36:20 -07002510 set_bit(FCPORT_UPDATE_NEEDED, &base_vha->dpc_flags);
2511 qla2xxx_wake_dpc(base_vha);
Seokmann Ju5f3a9a22008-07-10 16:55:47 -07002512 } else
andrew.vasquez@qlogic.comd97994d2006-01-20 14:53:13 -08002513 fc_remote_port_delete(rport);
andrew.vasquez@qlogic.comd97994d2006-01-20 14:53:13 -08002514}
2515
Linus Torvalds1da177e2005-04-16 15:20:36 -07002516/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002517 * qla2x00_mark_device_lost Updates fcport state when device goes offline.
2518 *
2519 * Input: ha = adapter block pointer. fcport = port structure pointer.
2520 *
2521 * Return: None.
2522 *
2523 * Context:
2524 */
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002525void qla2x00_mark_device_lost(scsi_qla_host_t *vha, fc_port_t *fcport,
andrew.vasquez@qlogic.comd97994d2006-01-20 14:53:13 -08002526 int do_login, int defer)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002527{
Seokmann Ju2c3dfe32007-07-05 13:16:51 -07002528 if (atomic_read(&fcport->state) == FCS_ONLINE &&
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002529 vha->vp_idx == fcport->vp_idx) {
2530 atomic_set(&fcport->state, FCS_DEVICE_LOST);
2531 qla2x00_schedule_rport_del(vha, fcport, defer);
2532 }
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -07002533 /*
Linus Torvalds1da177e2005-04-16 15:20:36 -07002534 * We may need to retry the login, so don't change the state of the
2535 * port but do the retries.
2536 */
2537 if (atomic_read(&fcport->state) != FCS_DEVICE_DEAD)
2538 atomic_set(&fcport->state, FCS_DEVICE_LOST);
2539
2540 if (!do_login)
2541 return;
2542
2543 if (fcport->login_retry == 0) {
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002544 fcport->login_retry = vha->hw->login_retry_count;
2545 set_bit(RELOGIN_NEEDED, &vha->dpc_flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002546
2547 DEBUG(printk("scsi(%ld): Port login retry: "
2548 "%02x%02x%02x%02x%02x%02x%02x%02x, "
2549 "id = 0x%04x retry cnt=%d\n",
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002550 vha->host_no,
Linus Torvalds1da177e2005-04-16 15:20:36 -07002551 fcport->port_name[0],
2552 fcport->port_name[1],
2553 fcport->port_name[2],
2554 fcport->port_name[3],
2555 fcport->port_name[4],
2556 fcport->port_name[5],
2557 fcport->port_name[6],
2558 fcport->port_name[7],
2559 fcport->loop_id,
2560 fcport->login_retry));
2561 }
2562}
2563
2564/*
2565 * qla2x00_mark_all_devices_lost
2566 * Updates fcport state when device goes offline.
2567 *
2568 * Input:
2569 * ha = adapter block pointer.
2570 * fcport = port structure pointer.
2571 *
2572 * Return:
2573 * None.
2574 *
2575 * Context:
2576 */
2577void
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002578qla2x00_mark_all_devices_lost(scsi_qla_host_t *vha, int defer)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002579{
2580 fc_port_t *fcport;
2581
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002582 list_for_each_entry(fcport, &vha->vp_fcports, list) {
Andrew Vasquez0d6e61b2009-08-25 11:36:19 -07002583 if (vha->vp_idx != 0 && vha->vp_idx != fcport->vp_idx)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002584 continue;
Andrew Vasquez0d6e61b2009-08-25 11:36:19 -07002585
Linus Torvalds1da177e2005-04-16 15:20:36 -07002586 /*
2587 * No point in marking the device as lost, if the device is
2588 * already DEAD.
2589 */
2590 if (atomic_read(&fcport->state) == FCS_DEVICE_DEAD)
2591 continue;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002592 if (atomic_read(&fcport->state) == FCS_ONLINE) {
Andrew Vasquez0d6e61b2009-08-25 11:36:19 -07002593 if (defer)
2594 qla2x00_schedule_rport_del(vha, fcport, defer);
2595 else if (vha->vp_idx == fcport->vp_idx)
2596 qla2x00_schedule_rport_del(vha, fcport, defer);
2597 }
2598 atomic_set(&fcport->state, FCS_DEVICE_LOST);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002599 }
2600}
2601
2602/*
2603* qla2x00_mem_alloc
2604* Allocates adapter memory.
2605*
2606* Returns:
2607* 0 = success.
Andrew Vasqueze8711082008-01-31 12:33:48 -08002608* !0 = failure.
Linus Torvalds1da177e2005-04-16 15:20:36 -07002609*/
Andrew Vasqueze8711082008-01-31 12:33:48 -08002610static int
Anirban Chakraborty73208df2008-12-09 16:45:39 -08002611qla2x00_mem_alloc(struct qla_hw_data *ha, uint16_t req_len, uint16_t rsp_len,
2612 struct req_que **req, struct rsp_que **rsp)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002613{
2614 char name[16];
Linus Torvalds1da177e2005-04-16 15:20:36 -07002615
Andrew Vasqueze8711082008-01-31 12:33:48 -08002616 ha->init_cb = dma_alloc_coherent(&ha->pdev->dev, ha->init_cb_size,
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002617 &ha->init_cb_dma, GFP_KERNEL);
Andrew Vasqueze8711082008-01-31 12:33:48 -08002618 if (!ha->init_cb)
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002619 goto fail;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002620
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002621 ha->gid_list = dma_alloc_coherent(&ha->pdev->dev, GID_LIST_SIZE,
2622 &ha->gid_list_dma, GFP_KERNEL);
2623 if (!ha->gid_list)
Andrew Vasqueze8711082008-01-31 12:33:48 -08002624 goto fail_free_init_cb;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002625
Andrew Vasqueze8711082008-01-31 12:33:48 -08002626 ha->srb_mempool = mempool_create_slab_pool(SRB_MIN_REQ, srb_cachep);
2627 if (!ha->srb_mempool)
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002628 goto fail_free_gid_list;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002629
Giridhar Malavalia9083012010-04-12 17:59:55 -07002630 if (IS_QLA82XX(ha)) {
2631 /* Allocate cache for CT6 Ctx. */
2632 if (!ctx_cachep) {
2633 ctx_cachep = kmem_cache_create("qla2xxx_ctx",
2634 sizeof(struct ct6_dsd), 0,
2635 SLAB_HWCACHE_ALIGN, NULL);
2636 if (!ctx_cachep)
2637 goto fail_free_gid_list;
2638 }
2639 ha->ctx_mempool = mempool_create_slab_pool(SRB_MIN_REQ,
2640 ctx_cachep);
2641 if (!ha->ctx_mempool)
2642 goto fail_free_srb_mempool;
2643 }
2644
Andrew Vasqueze8711082008-01-31 12:33:48 -08002645 /* Get memory for cached NVRAM */
2646 ha->nvram = kzalloc(MAX_NVRAM_SIZE, GFP_KERNEL);
2647 if (!ha->nvram)
Giridhar Malavalia9083012010-04-12 17:59:55 -07002648 goto fail_free_ctx_mempool;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002649
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002650 snprintf(name, sizeof(name), "%s_%d", QLA2XXX_DRIVER_NAME,
2651 ha->pdev->device);
2652 ha->s_dma_pool = dma_pool_create(name, &ha->pdev->dev,
2653 DMA_POOL_SIZE, 8, 0);
2654 if (!ha->s_dma_pool)
2655 goto fail_free_nvram;
2656
Arun Easibad75002010-05-04 15:01:30 -07002657 if (IS_QLA82XX(ha) || ql2xenabledif) {
Giridhar Malavalia9083012010-04-12 17:59:55 -07002658 ha->dl_dma_pool = dma_pool_create(name, &ha->pdev->dev,
2659 DSD_LIST_DMA_POOL_SIZE, 8, 0);
2660 if (!ha->dl_dma_pool) {
2661 qla_printk(KERN_WARNING, ha,
2662 "Memory Allocation failed - dl_dma_pool\n");
2663 goto fail_s_dma_pool;
2664 }
2665
2666 ha->fcp_cmnd_dma_pool = dma_pool_create(name, &ha->pdev->dev,
2667 FCP_CMND_DMA_POOL_SIZE, 8, 0);
2668 if (!ha->fcp_cmnd_dma_pool) {
2669 qla_printk(KERN_WARNING, ha,
2670 "Memory Allocation failed - fcp_cmnd_dma_pool\n");
2671 goto fail_dl_dma_pool;
2672 }
2673 }
2674
Andrew Vasqueze8711082008-01-31 12:33:48 -08002675 /* Allocate memory for SNS commands */
2676 if (IS_QLA2100(ha) || IS_QLA2200(ha)) {
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002677 /* Get consistent memory allocated for SNS commands */
Andrew Vasqueze8711082008-01-31 12:33:48 -08002678 ha->sns_cmd = dma_alloc_coherent(&ha->pdev->dev,
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002679 sizeof(struct sns_cmd_pkt), &ha->sns_cmd_dma, GFP_KERNEL);
Andrew Vasqueze8711082008-01-31 12:33:48 -08002680 if (!ha->sns_cmd)
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002681 goto fail_dma_pool;
Andrew Vasqueze8711082008-01-31 12:33:48 -08002682 } else {
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002683 /* Get consistent memory allocated for MS IOCB */
Andrew Vasqueze8711082008-01-31 12:33:48 -08002684 ha->ms_iocb = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL,
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002685 &ha->ms_iocb_dma);
Andrew Vasqueze8711082008-01-31 12:33:48 -08002686 if (!ha->ms_iocb)
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002687 goto fail_dma_pool;
2688 /* Get consistent memory allocated for CT SNS commands */
Andrew Vasqueze8711082008-01-31 12:33:48 -08002689 ha->ct_sns = dma_alloc_coherent(&ha->pdev->dev,
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002690 sizeof(struct ct_sns_pkt), &ha->ct_sns_dma, GFP_KERNEL);
Andrew Vasqueze8711082008-01-31 12:33:48 -08002691 if (!ha->ct_sns)
2692 goto fail_free_ms_iocb;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002693 }
2694
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002695 /* Allocate memory for request ring */
Anirban Chakraborty73208df2008-12-09 16:45:39 -08002696 *req = kzalloc(sizeof(struct req_que), GFP_KERNEL);
2697 if (!*req) {
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002698 DEBUG(printk("Unable to allocate memory for req\n"));
2699 goto fail_req;
2700 }
Anirban Chakraborty73208df2008-12-09 16:45:39 -08002701 (*req)->length = req_len;
2702 (*req)->ring = dma_alloc_coherent(&ha->pdev->dev,
2703 ((*req)->length + 1) * sizeof(request_t),
2704 &(*req)->dma, GFP_KERNEL);
2705 if (!(*req)->ring) {
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002706 DEBUG(printk("Unable to allocate memory for req_ring\n"));
2707 goto fail_req_ring;
2708 }
2709 /* Allocate memory for response ring */
Anirban Chakraborty73208df2008-12-09 16:45:39 -08002710 *rsp = kzalloc(sizeof(struct rsp_que), GFP_KERNEL);
2711 if (!*rsp) {
2712 qla_printk(KERN_WARNING, ha,
2713 "Unable to allocate memory for rsp\n");
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002714 goto fail_rsp;
2715 }
Anirban Chakraborty73208df2008-12-09 16:45:39 -08002716 (*rsp)->hw = ha;
2717 (*rsp)->length = rsp_len;
2718 (*rsp)->ring = dma_alloc_coherent(&ha->pdev->dev,
2719 ((*rsp)->length + 1) * sizeof(response_t),
2720 &(*rsp)->dma, GFP_KERNEL);
2721 if (!(*rsp)->ring) {
2722 qla_printk(KERN_WARNING, ha,
2723 "Unable to allocate memory for rsp_ring\n");
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002724 goto fail_rsp_ring;
2725 }
Anirban Chakraborty73208df2008-12-09 16:45:39 -08002726 (*req)->rsp = *rsp;
2727 (*rsp)->req = *req;
2728 /* Allocate memory for NVRAM data for vports */
2729 if (ha->nvram_npiv_size) {
2730 ha->npiv_info = kzalloc(sizeof(struct qla_npiv_entry) *
2731 ha->nvram_npiv_size, GFP_KERNEL);
2732 if (!ha->npiv_info) {
2733 qla_printk(KERN_WARNING, ha,
2734 "Unable to allocate memory for npiv info\n");
2735 goto fail_npiv_info;
2736 }
2737 } else
2738 ha->npiv_info = NULL;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002739
Andrew Vasquezb64b0e82009-03-24 09:08:01 -07002740 /* Get consistent memory allocated for EX-INIT-CB. */
Giridhar Malavalia9083012010-04-12 17:59:55 -07002741 if (IS_QLA8XXX_TYPE(ha)) {
Andrew Vasquezb64b0e82009-03-24 09:08:01 -07002742 ha->ex_init_cb = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL,
2743 &ha->ex_init_cb_dma);
2744 if (!ha->ex_init_cb)
2745 goto fail_ex_init_cb;
2746 }
2747
Giridhar Malavalia9083012010-04-12 17:59:55 -07002748 INIT_LIST_HEAD(&ha->gbl_dsd_list);
2749
Andrew Vasquez5ff1d582010-05-04 15:01:26 -07002750 /* Get consistent memory allocated for Async Port-Database. */
2751 if (!IS_FWI2_CAPABLE(ha)) {
2752 ha->async_pd = dma_pool_alloc(ha->s_dma_pool, GFP_KERNEL,
2753 &ha->async_pd_dma);
2754 if (!ha->async_pd)
2755 goto fail_async_pd;
2756 }
2757
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002758 INIT_LIST_HEAD(&ha->vp_list);
2759 return 1;
2760
Andrew Vasquez5ff1d582010-05-04 15:01:26 -07002761fail_async_pd:
2762 dma_pool_free(ha->s_dma_pool, ha->ex_init_cb, ha->ex_init_cb_dma);
Andrew Vasquezb64b0e82009-03-24 09:08:01 -07002763fail_ex_init_cb:
2764 kfree(ha->npiv_info);
Anirban Chakraborty73208df2008-12-09 16:45:39 -08002765fail_npiv_info:
2766 dma_free_coherent(&ha->pdev->dev, ((*rsp)->length + 1) *
2767 sizeof(response_t), (*rsp)->ring, (*rsp)->dma);
2768 (*rsp)->ring = NULL;
2769 (*rsp)->dma = 0;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002770fail_rsp_ring:
Anirban Chakraborty73208df2008-12-09 16:45:39 -08002771 kfree(*rsp);
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002772fail_rsp:
Anirban Chakraborty73208df2008-12-09 16:45:39 -08002773 dma_free_coherent(&ha->pdev->dev, ((*req)->length + 1) *
2774 sizeof(request_t), (*req)->ring, (*req)->dma);
2775 (*req)->ring = NULL;
2776 (*req)->dma = 0;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002777fail_req_ring:
Anirban Chakraborty73208df2008-12-09 16:45:39 -08002778 kfree(*req);
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002779fail_req:
2780 dma_free_coherent(&ha->pdev->dev, sizeof(struct ct_sns_pkt),
2781 ha->ct_sns, ha->ct_sns_dma);
2782 ha->ct_sns = NULL;
2783 ha->ct_sns_dma = 0;
Andrew Vasqueze8711082008-01-31 12:33:48 -08002784fail_free_ms_iocb:
2785 dma_pool_free(ha->s_dma_pool, ha->ms_iocb, ha->ms_iocb_dma);
2786 ha->ms_iocb = NULL;
2787 ha->ms_iocb_dma = 0;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002788fail_dma_pool:
Arun Easibad75002010-05-04 15:01:30 -07002789 if (IS_QLA82XX(ha) || ql2xenabledif) {
Giridhar Malavalia9083012010-04-12 17:59:55 -07002790 dma_pool_destroy(ha->fcp_cmnd_dma_pool);
2791 ha->fcp_cmnd_dma_pool = NULL;
2792 }
2793fail_dl_dma_pool:
Arun Easibad75002010-05-04 15:01:30 -07002794 if (IS_QLA82XX(ha) || ql2xenabledif) {
Giridhar Malavalia9083012010-04-12 17:59:55 -07002795 dma_pool_destroy(ha->dl_dma_pool);
2796 ha->dl_dma_pool = NULL;
2797 }
2798fail_s_dma_pool:
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002799 dma_pool_destroy(ha->s_dma_pool);
2800 ha->s_dma_pool = NULL;
Andrew Vasqueze8711082008-01-31 12:33:48 -08002801fail_free_nvram:
2802 kfree(ha->nvram);
2803 ha->nvram = NULL;
Giridhar Malavalia9083012010-04-12 17:59:55 -07002804fail_free_ctx_mempool:
2805 mempool_destroy(ha->ctx_mempool);
2806 ha->ctx_mempool = NULL;
Andrew Vasqueze8711082008-01-31 12:33:48 -08002807fail_free_srb_mempool:
2808 mempool_destroy(ha->srb_mempool);
2809 ha->srb_mempool = NULL;
Andrew Vasqueze8711082008-01-31 12:33:48 -08002810fail_free_gid_list:
2811 dma_free_coherent(&ha->pdev->dev, GID_LIST_SIZE, ha->gid_list,
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002812 ha->gid_list_dma);
Andrew Vasqueze8711082008-01-31 12:33:48 -08002813 ha->gid_list = NULL;
2814 ha->gid_list_dma = 0;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002815fail_free_init_cb:
2816 dma_free_coherent(&ha->pdev->dev, ha->init_cb_size, ha->init_cb,
2817 ha->init_cb_dma);
2818 ha->init_cb = NULL;
2819 ha->init_cb_dma = 0;
Andrew Vasqueze8711082008-01-31 12:33:48 -08002820fail:
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002821 DEBUG(printk("%s: Memory allocation failure\n", __func__));
Andrew Vasqueze8711082008-01-31 12:33:48 -08002822 return -ENOMEM;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002823}
2824
2825/*
2826* qla2x00_mem_free
2827* Frees all adapter allocated memory.
2828*
2829* Input:
2830* ha = adapter block pointer.
2831*/
Adrian Bunka824ebb2008-01-17 09:02:15 -08002832static void
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002833qla2x00_mem_free(struct qla_hw_data *ha)
Linus Torvalds1da177e2005-04-16 15:20:36 -07002834{
Andrew Vasqueze8711082008-01-31 12:33:48 -08002835 if (ha->srb_mempool)
2836 mempool_destroy(ha->srb_mempool);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002837
Andrew Vasquezdf613b92008-01-17 09:02:17 -08002838 if (ha->fce)
2839 dma_free_coherent(&ha->pdev->dev, FCE_SIZE, ha->fce,
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002840 ha->fce_dma);
Andrew Vasquezdf613b92008-01-17 09:02:17 -08002841
Andrew Vasqueza7a167b2006-06-23 16:10:29 -07002842 if (ha->fw_dump) {
2843 if (ha->eft)
2844 dma_free_coherent(&ha->pdev->dev,
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002845 ntohl(ha->fw_dump->eft_size), ha->eft, ha->eft_dma);
Andrew Vasqueza7a167b2006-06-23 16:10:29 -07002846 vfree(ha->fw_dump);
2847 }
2848
Andrew Vasquez11bbc1d2009-06-03 09:55:14 -07002849 if (ha->dcbx_tlv)
2850 dma_free_coherent(&ha->pdev->dev, DCBX_TLV_DATA_SIZE,
2851 ha->dcbx_tlv, ha->dcbx_tlv_dma);
2852
Andrew Vasquezce0423f2009-06-03 09:55:13 -07002853 if (ha->xgmac_data)
2854 dma_free_coherent(&ha->pdev->dev, XGMAC_DATA_SIZE,
2855 ha->xgmac_data, ha->xgmac_data_dma);
2856
Linus Torvalds1da177e2005-04-16 15:20:36 -07002857 if (ha->sns_cmd)
2858 dma_free_coherent(&ha->pdev->dev, sizeof(struct sns_cmd_pkt),
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002859 ha->sns_cmd, ha->sns_cmd_dma);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002860
2861 if (ha->ct_sns)
2862 dma_free_coherent(&ha->pdev->dev, sizeof(struct ct_sns_pkt),
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002863 ha->ct_sns, ha->ct_sns_dma);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002864
Andrew Vasquez88729e52006-06-23 16:10:50 -07002865 if (ha->sfp_data)
2866 dma_pool_free(ha->s_dma_pool, ha->sfp_data, ha->sfp_data_dma);
2867
Joe Carnuccioad0ecd62009-03-24 09:08:12 -07002868 if (ha->edc_data)
2869 dma_pool_free(ha->s_dma_pool, ha->edc_data, ha->edc_data_dma);
2870
Linus Torvalds1da177e2005-04-16 15:20:36 -07002871 if (ha->ms_iocb)
2872 dma_pool_free(ha->s_dma_pool, ha->ms_iocb, ha->ms_iocb_dma);
2873
Andrew Vasquezb64b0e82009-03-24 09:08:01 -07002874 if (ha->ex_init_cb)
Giridhar Malavalia9083012010-04-12 17:59:55 -07002875 dma_pool_free(ha->s_dma_pool,
2876 ha->ex_init_cb, ha->ex_init_cb_dma);
Andrew Vasquezb64b0e82009-03-24 09:08:01 -07002877
Andrew Vasquez5ff1d582010-05-04 15:01:26 -07002878 if (ha->async_pd)
2879 dma_pool_free(ha->s_dma_pool, ha->async_pd, ha->async_pd_dma);
2880
Linus Torvalds1da177e2005-04-16 15:20:36 -07002881 if (ha->s_dma_pool)
2882 dma_pool_destroy(ha->s_dma_pool);
2883
Linus Torvalds1da177e2005-04-16 15:20:36 -07002884 if (ha->gid_list)
2885 dma_free_coherent(&ha->pdev->dev, GID_LIST_SIZE, ha->gid_list,
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002886 ha->gid_list_dma);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002887
Giridhar Malavalia9083012010-04-12 17:59:55 -07002888 if (IS_QLA82XX(ha)) {
2889 if (!list_empty(&ha->gbl_dsd_list)) {
2890 struct dsd_dma *dsd_ptr, *tdsd_ptr;
2891
2892 /* clean up allocated prev pool */
2893 list_for_each_entry_safe(dsd_ptr,
2894 tdsd_ptr, &ha->gbl_dsd_list, list) {
2895 dma_pool_free(ha->dl_dma_pool,
2896 dsd_ptr->dsd_addr, dsd_ptr->dsd_list_dma);
2897 list_del(&dsd_ptr->list);
2898 kfree(dsd_ptr);
2899 }
2900 }
2901 }
2902
2903 if (ha->dl_dma_pool)
2904 dma_pool_destroy(ha->dl_dma_pool);
2905
2906 if (ha->fcp_cmnd_dma_pool)
2907 dma_pool_destroy(ha->fcp_cmnd_dma_pool);
2908
2909 if (ha->ctx_mempool)
2910 mempool_destroy(ha->ctx_mempool);
2911
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002912 if (ha->init_cb)
2913 dma_free_coherent(&ha->pdev->dev, ha->init_cb_size,
Giridhar Malavalia9083012010-04-12 17:59:55 -07002914 ha->init_cb, ha->init_cb_dma);
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002915 vfree(ha->optrom_buffer);
2916 kfree(ha->nvram);
Anirban Chakraborty73208df2008-12-09 16:45:39 -08002917 kfree(ha->npiv_info);
Linus Torvalds1da177e2005-04-16 15:20:36 -07002918
Andrew Vasqueze8711082008-01-31 12:33:48 -08002919 ha->srb_mempool = NULL;
Giridhar Malavalia9083012010-04-12 17:59:55 -07002920 ha->ctx_mempool = NULL;
Andrew Vasqueza7a167b2006-06-23 16:10:29 -07002921 ha->eft = NULL;
2922 ha->eft_dma = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002923 ha->sns_cmd = NULL;
2924 ha->sns_cmd_dma = 0;
2925 ha->ct_sns = NULL;
2926 ha->ct_sns_dma = 0;
2927 ha->ms_iocb = NULL;
2928 ha->ms_iocb_dma = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002929 ha->init_cb = NULL;
2930 ha->init_cb_dma = 0;
Andrew Vasquezb64b0e82009-03-24 09:08:01 -07002931 ha->ex_init_cb = NULL;
2932 ha->ex_init_cb_dma = 0;
Andrew Vasquez5ff1d582010-05-04 15:01:26 -07002933 ha->async_pd = NULL;
2934 ha->async_pd_dma = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002935
2936 ha->s_dma_pool = NULL;
Giridhar Malavalia9083012010-04-12 17:59:55 -07002937 ha->dl_dma_pool = NULL;
2938 ha->fcp_cmnd_dma_pool = NULL;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002939
Linus Torvalds1da177e2005-04-16 15:20:36 -07002940 ha->gid_list = NULL;
2941 ha->gid_list_dma = 0;
2942
Linus Torvalds1da177e2005-04-16 15:20:36 -07002943 ha->fw_dump = NULL;
Andrew Vasquezfca29702005-07-06 10:31:47 -07002944 ha->fw_dumped = 0;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002945 ha->fw_dump_reading = 0;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002946}
2947
2948struct scsi_qla_host *qla2x00_create_host(struct scsi_host_template *sht,
2949 struct qla_hw_data *ha)
2950{
2951 struct Scsi_Host *host;
2952 struct scsi_qla_host *vha = NULL;
2953
2954 host = scsi_host_alloc(sht, sizeof(scsi_qla_host_t));
2955 if (host == NULL) {
2956 printk(KERN_WARNING
2957 "qla2xxx: Couldn't allocate host from scsi layer!\n");
2958 goto fail;
2959 }
2960
2961 /* Clear our data area */
2962 vha = shost_priv(host);
2963 memset(vha, 0, sizeof(scsi_qla_host_t));
2964
2965 vha->host = host;
2966 vha->host_no = host->host_no;
2967 vha->hw = ha;
2968
2969 INIT_LIST_HEAD(&vha->vp_fcports);
2970 INIT_LIST_HEAD(&vha->work_list);
2971 INIT_LIST_HEAD(&vha->list);
2972
Andrew Vasquezf999f4c2009-06-03 09:55:28 -07002973 spin_lock_init(&vha->work_lock);
2974
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08002975 sprintf(vha->host_str, "%s_%ld", QLA2XXX_DRIVER_NAME, vha->host_no);
2976 return vha;
2977
2978fail:
2979 return vha;
Linus Torvalds1da177e2005-04-16 15:20:36 -07002980}
2981
Adrian Bunk01ef66b2008-04-24 15:21:27 -07002982static struct qla_work_evt *
Andrew Vasquezf999f4c2009-06-03 09:55:28 -07002983qla2x00_alloc_work(struct scsi_qla_host *vha, enum qla_work_type type)
Andrew Vasquez0971de72008-04-03 13:13:18 -07002984{
2985 struct qla_work_evt *e;
2986
Andrew Vasquezf999f4c2009-06-03 09:55:28 -07002987 e = kzalloc(sizeof(struct qla_work_evt), GFP_ATOMIC);
Andrew Vasquez0971de72008-04-03 13:13:18 -07002988 if (!e)
2989 return NULL;
2990
2991 INIT_LIST_HEAD(&e->list);
2992 e->type = type;
2993 e->flags = QLA_EVT_FLAG_FREE;
2994 return e;
2995}
2996
Adrian Bunk01ef66b2008-04-24 15:21:27 -07002997static int
Andrew Vasquezf999f4c2009-06-03 09:55:28 -07002998qla2x00_post_work(struct scsi_qla_host *vha, struct qla_work_evt *e)
Andrew Vasquez0971de72008-04-03 13:13:18 -07002999{
Andrew Vasquezf999f4c2009-06-03 09:55:28 -07003000 unsigned long flags;
Andrew Vasquez0971de72008-04-03 13:13:18 -07003001
Andrew Vasquezf999f4c2009-06-03 09:55:28 -07003002 spin_lock_irqsave(&vha->work_lock, flags);
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003003 list_add_tail(&e->list, &vha->work_list);
Andrew Vasquezf999f4c2009-06-03 09:55:28 -07003004 spin_unlock_irqrestore(&vha->work_lock, flags);
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003005 qla2xxx_wake_dpc(vha);
Andrew Vasquezf999f4c2009-06-03 09:55:28 -07003006
Andrew Vasquez0971de72008-04-03 13:13:18 -07003007 return QLA_SUCCESS;
3008}
3009
3010int
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003011qla2x00_post_aen_work(struct scsi_qla_host *vha, enum fc_host_event_code code,
Andrew Vasquez0971de72008-04-03 13:13:18 -07003012 u32 data)
3013{
3014 struct qla_work_evt *e;
3015
Andrew Vasquezf999f4c2009-06-03 09:55:28 -07003016 e = qla2x00_alloc_work(vha, QLA_EVT_AEN);
Andrew Vasquez0971de72008-04-03 13:13:18 -07003017 if (!e)
3018 return QLA_FUNCTION_FAILED;
3019
3020 e->u.aen.code = code;
3021 e->u.aen.data = data;
Andrew Vasquezf999f4c2009-06-03 09:55:28 -07003022 return qla2x00_post_work(vha, e);
Andrew Vasquez0971de72008-04-03 13:13:18 -07003023}
3024
Andrew Vasquez8a659572009-02-08 20:50:12 -08003025int
3026qla2x00_post_idc_ack_work(struct scsi_qla_host *vha, uint16_t *mb)
3027{
3028 struct qla_work_evt *e;
3029
Andrew Vasquezf999f4c2009-06-03 09:55:28 -07003030 e = qla2x00_alloc_work(vha, QLA_EVT_IDC_ACK);
Andrew Vasquez8a659572009-02-08 20:50:12 -08003031 if (!e)
3032 return QLA_FUNCTION_FAILED;
3033
3034 memcpy(e->u.idc_ack.mb, mb, QLA_IDC_ACK_REGS * sizeof(uint16_t));
Andrew Vasquezf999f4c2009-06-03 09:55:28 -07003035 return qla2x00_post_work(vha, e);
Andrew Vasquez8a659572009-02-08 20:50:12 -08003036}
3037
Andrew Vasquezac280b62009-08-20 11:06:05 -07003038#define qla2x00_post_async_work(name, type) \
3039int qla2x00_post_async_##name##_work( \
3040 struct scsi_qla_host *vha, \
3041 fc_port_t *fcport, uint16_t *data) \
3042{ \
3043 struct qla_work_evt *e; \
3044 \
3045 e = qla2x00_alloc_work(vha, type); \
3046 if (!e) \
3047 return QLA_FUNCTION_FAILED; \
3048 \
3049 e->u.logio.fcport = fcport; \
3050 if (data) { \
3051 e->u.logio.data[0] = data[0]; \
3052 e->u.logio.data[1] = data[1]; \
3053 } \
3054 return qla2x00_post_work(vha, e); \
3055}
3056
3057qla2x00_post_async_work(login, QLA_EVT_ASYNC_LOGIN);
3058qla2x00_post_async_work(login_done, QLA_EVT_ASYNC_LOGIN_DONE);
3059qla2x00_post_async_work(logout, QLA_EVT_ASYNC_LOGOUT);
3060qla2x00_post_async_work(logout_done, QLA_EVT_ASYNC_LOGOUT_DONE);
Andrew Vasquez5ff1d582010-05-04 15:01:26 -07003061qla2x00_post_async_work(adisc, QLA_EVT_ASYNC_ADISC);
3062qla2x00_post_async_work(adisc_done, QLA_EVT_ASYNC_ADISC_DONE);
Andrew Vasquezac280b62009-08-20 11:06:05 -07003063
Andrew Vasquez3420d362009-10-13 15:16:45 -07003064int
3065qla2x00_post_uevent_work(struct scsi_qla_host *vha, u32 code)
3066{
3067 struct qla_work_evt *e;
3068
3069 e = qla2x00_alloc_work(vha, QLA_EVT_UEVENT);
3070 if (!e)
3071 return QLA_FUNCTION_FAILED;
3072
3073 e->u.uevent.code = code;
3074 return qla2x00_post_work(vha, e);
3075}
3076
3077static void
3078qla2x00_uevent_emit(struct scsi_qla_host *vha, u32 code)
3079{
3080 char event_string[40];
3081 char *envp[] = { event_string, NULL };
3082
3083 switch (code) {
3084 case QLA_UEVENT_CODE_FW_DUMP:
3085 snprintf(event_string, sizeof(event_string), "FW_DUMP=%ld",
3086 vha->host_no);
3087 break;
3088 default:
3089 /* do nothing */
3090 break;
3091 }
3092 kobject_uevent_env(&vha->hw->pdev->dev.kobj, KOBJ_CHANGE, envp);
3093}
3094
Andrew Vasquezac280b62009-08-20 11:06:05 -07003095void
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003096qla2x00_do_work(struct scsi_qla_host *vha)
Andrew Vasquez0971de72008-04-03 13:13:18 -07003097{
Andrew Vasquezf999f4c2009-06-03 09:55:28 -07003098 struct qla_work_evt *e, *tmp;
3099 unsigned long flags;
3100 LIST_HEAD(work);
Andrew Vasquez0971de72008-04-03 13:13:18 -07003101
Andrew Vasquezf999f4c2009-06-03 09:55:28 -07003102 spin_lock_irqsave(&vha->work_lock, flags);
3103 list_splice_init(&vha->work_list, &work);
3104 spin_unlock_irqrestore(&vha->work_lock, flags);
3105
3106 list_for_each_entry_safe(e, tmp, &work, list) {
Andrew Vasquez0971de72008-04-03 13:13:18 -07003107 list_del_init(&e->list);
Andrew Vasquez0971de72008-04-03 13:13:18 -07003108
3109 switch (e->type) {
3110 case QLA_EVT_AEN:
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003111 fc_host_post_event(vha->host, fc_get_event_number(),
Andrew Vasquez0971de72008-04-03 13:13:18 -07003112 e->u.aen.code, e->u.aen.data);
3113 break;
Andrew Vasquez8a659572009-02-08 20:50:12 -08003114 case QLA_EVT_IDC_ACK:
3115 qla81xx_idc_ack(vha, e->u.idc_ack.mb);
3116 break;
Andrew Vasquezac280b62009-08-20 11:06:05 -07003117 case QLA_EVT_ASYNC_LOGIN:
3118 qla2x00_async_login(vha, e->u.logio.fcport,
3119 e->u.logio.data);
3120 break;
3121 case QLA_EVT_ASYNC_LOGIN_DONE:
3122 qla2x00_async_login_done(vha, e->u.logio.fcport,
3123 e->u.logio.data);
3124 break;
3125 case QLA_EVT_ASYNC_LOGOUT:
3126 qla2x00_async_logout(vha, e->u.logio.fcport);
3127 break;
3128 case QLA_EVT_ASYNC_LOGOUT_DONE:
3129 qla2x00_async_logout_done(vha, e->u.logio.fcport,
3130 e->u.logio.data);
3131 break;
Andrew Vasquez5ff1d582010-05-04 15:01:26 -07003132 case QLA_EVT_ASYNC_ADISC:
3133 qla2x00_async_adisc(vha, e->u.logio.fcport,
3134 e->u.logio.data);
3135 break;
3136 case QLA_EVT_ASYNC_ADISC_DONE:
3137 qla2x00_async_adisc_done(vha, e->u.logio.fcport,
3138 e->u.logio.data);
3139 break;
Andrew Vasquez3420d362009-10-13 15:16:45 -07003140 case QLA_EVT_UEVENT:
3141 qla2x00_uevent_emit(vha, e->u.uevent.code);
3142 break;
Andrew Vasquez0971de72008-04-03 13:13:18 -07003143 }
3144 if (e->flags & QLA_EVT_FLAG_FREE)
3145 kfree(e);
Andrew Vasquez0971de72008-04-03 13:13:18 -07003146 }
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003147}
Andrew Vasquezf999f4c2009-06-03 09:55:28 -07003148
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003149/* Relogins all the fcports of a vport
3150 * Context: dpc thread
3151 */
3152void qla2x00_relogin(struct scsi_qla_host *vha)
3153{
3154 fc_port_t *fcport;
Andrew Vasquezc6b2fca2009-03-05 11:07:03 -08003155 int status;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003156 uint16_t next_loopid = 0;
3157 struct qla_hw_data *ha = vha->hw;
Andrew Vasquezac280b62009-08-20 11:06:05 -07003158 uint16_t data[2];
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003159
3160 list_for_each_entry(fcport, &vha->vp_fcports, list) {
3161 /*
3162 * If the port is not ONLINE then try to login
3163 * to it if we haven't run out of retries.
3164 */
Andrew Vasquez5ff1d582010-05-04 15:01:26 -07003165 if (atomic_read(&fcport->state) != FCS_ONLINE &&
3166 fcport->login_retry && !(fcport->flags & FCF_ASYNC_SENT)) {
Andrew Vasquezac280b62009-08-20 11:06:05 -07003167 fcport->login_retry--;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003168 if (fcport->flags & FCF_FABRIC_DEVICE) {
Andrew Vasquezf08b7252010-01-12 12:59:48 -08003169 if (fcport->flags & FCF_FCP2_DEVICE)
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003170 ha->isp_ops->fabric_logout(vha,
3171 fcport->loop_id,
3172 fcport->d_id.b.domain,
3173 fcport->d_id.b.area,
3174 fcport->d_id.b.al_pa);
3175
Andrew Vasquezac280b62009-08-20 11:06:05 -07003176 if (IS_ALOGIO_CAPABLE(ha)) {
Andrew Vasquez5ff1d582010-05-04 15:01:26 -07003177 fcport->flags |= FCF_ASYNC_SENT;
Andrew Vasquezac280b62009-08-20 11:06:05 -07003178 data[0] = 0;
3179 data[1] = QLA_LOGIO_LOGIN_RETRIED;
3180 status = qla2x00_post_async_login_work(
3181 vha, fcport, data);
3182 if (status == QLA_SUCCESS)
3183 continue;
3184 /* Attempt a retry. */
3185 status = 1;
3186 } else
3187 status = qla2x00_fabric_login(vha,
3188 fcport, &next_loopid);
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003189 } else
3190 status = qla2x00_local_device_login(vha,
3191 fcport);
3192
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003193 if (status == QLA_SUCCESS) {
3194 fcport->old_loop_id = fcport->loop_id;
3195
3196 DEBUG(printk("scsi(%ld): port login OK: logged "
3197 "in ID 0x%x\n", vha->host_no, fcport->loop_id));
3198
3199 qla2x00_update_fcport(vha, fcport);
3200
3201 } else if (status == 1) {
3202 set_bit(RELOGIN_NEEDED, &vha->dpc_flags);
3203 /* retry the login again */
3204 DEBUG(printk("scsi(%ld): Retrying"
3205 " %d login again loop_id 0x%x\n",
3206 vha->host_no, fcport->login_retry,
3207 fcport->loop_id));
3208 } else {
3209 fcport->login_retry = 0;
3210 }
3211
3212 if (fcport->login_retry == 0 && status != QLA_SUCCESS)
3213 fcport->loop_id = FC_NO_LOOP_ID;
3214 }
3215 if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags))
3216 break;
3217 }
Andrew Vasquez0971de72008-04-03 13:13:18 -07003218}
3219
Linus Torvalds1da177e2005-04-16 15:20:36 -07003220/**************************************************************************
3221* qla2x00_do_dpc
3222* This kernel thread is a task that is schedule by the interrupt handler
3223* to perform the background processing for interrupts.
3224*
3225* Notes:
3226* This task always run in the context of a kernel thread. It
3227* is kick-off by the driver's detect code and starts up
3228* up one per adapter. It immediately goes to sleep and waits for
3229* some fibre event. When either the interrupt handler or
3230* the timer routine detects a event it will one of the task
3231* bits then wake us up.
3232**************************************************************************/
3233static int
3234qla2x00_do_dpc(void *data)
3235{
Seokmann Ju2c3dfe32007-07-05 13:16:51 -07003236 int rval;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003237 scsi_qla_host_t *base_vha;
3238 struct qla_hw_data *ha;
Seokmann Ju99363ef2008-01-31 12:33:51 -08003239
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003240 ha = (struct qla_hw_data *)data;
3241 base_vha = pci_get_drvdata(ha->pdev);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003242
Linus Torvalds1da177e2005-04-16 15:20:36 -07003243 set_user_nice(current, -20);
3244
Christoph Hellwig39a11242006-02-14 18:46:22 +01003245 while (!kthread_should_stop()) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003246 DEBUG3(printk("qla2x00: DPC handler sleeping\n"));
3247
Christoph Hellwig39a11242006-02-14 18:46:22 +01003248 set_current_state(TASK_INTERRUPTIBLE);
3249 schedule();
3250 __set_current_state(TASK_RUNNING);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003251
3252 DEBUG3(printk("qla2x00: DPC handler waking up\n"));
3253
3254 /* Initialization not yet finished. Don't do anything yet. */
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003255 if (!base_vha->flags.init_done)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003256 continue;
3257
Andrew Vasquez85880802009-12-15 21:29:46 -08003258 if (ha->flags.eeh_busy) {
3259 DEBUG17(qla_printk(KERN_WARNING, ha,
3260 "qla2x00_do_dpc: dpc_flags: %lx\n",
3261 base_vha->dpc_flags));
3262 continue;
3263 }
3264
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003265 DEBUG3(printk("scsi(%ld): DPC handler\n", base_vha->host_no));
Linus Torvalds1da177e2005-04-16 15:20:36 -07003266
3267 ha->dpc_active = 1;
3268
Linus Torvalds1da177e2005-04-16 15:20:36 -07003269 if (ha->flags.mbox_busy) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003270 ha->dpc_active = 0;
3271 continue;
3272 }
3273
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003274 qla2x00_do_work(base_vha);
Andrew Vasquez0971de72008-04-03 13:13:18 -07003275
Giridhar Malavalia9083012010-04-12 17:59:55 -07003276 if (IS_QLA82XX(ha)) {
3277 if (test_and_clear_bit(ISP_UNRECOVERABLE,
3278 &base_vha->dpc_flags)) {
3279 qla82xx_idc_lock(ha);
3280 qla82xx_wr_32(ha, QLA82XX_CRB_DEV_STATE,
3281 QLA82XX_DEV_FAILED);
3282 qla82xx_idc_unlock(ha);
3283 qla_printk(KERN_INFO, ha,
3284 "HW State: FAILED\n");
3285 qla82xx_device_state_handler(base_vha);
3286 continue;
3287 }
3288
3289 if (test_and_clear_bit(FCOE_CTX_RESET_NEEDED,
3290 &base_vha->dpc_flags)) {
3291
3292 DEBUG(printk(KERN_INFO
3293 "scsi(%ld): dpc: sched "
3294 "qla82xx_fcoe_ctx_reset ha = %p\n",
3295 base_vha->host_no, ha));
3296 if (!(test_and_set_bit(ABORT_ISP_ACTIVE,
3297 &base_vha->dpc_flags))) {
3298 if (qla82xx_fcoe_ctx_reset(base_vha)) {
3299 /* FCoE-ctx reset failed.
3300 * Escalate to chip-reset
3301 */
3302 set_bit(ISP_ABORT_NEEDED,
3303 &base_vha->dpc_flags);
3304 }
3305 clear_bit(ABORT_ISP_ACTIVE,
3306 &base_vha->dpc_flags);
3307 }
3308
3309 DEBUG(printk("scsi(%ld): dpc:"
3310 " qla82xx_fcoe_ctx_reset end\n",
3311 base_vha->host_no));
3312 }
3313 }
3314
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003315 if (test_and_clear_bit(ISP_ABORT_NEEDED,
3316 &base_vha->dpc_flags)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003317
3318 DEBUG(printk("scsi(%ld): dpc: sched "
3319 "qla2x00_abort_isp ha = %p\n",
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003320 base_vha->host_no, ha));
Linus Torvalds1da177e2005-04-16 15:20:36 -07003321 if (!(test_and_set_bit(ABORT_ISP_ACTIVE,
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003322 &base_vha->dpc_flags))) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003323
Giridhar Malavalia9083012010-04-12 17:59:55 -07003324 if (ha->isp_ops->abort_isp(base_vha)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003325 /* failed. retry later */
3326 set_bit(ISP_ABORT_NEEDED,
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003327 &base_vha->dpc_flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003328 }
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003329 clear_bit(ABORT_ISP_ACTIVE,
3330 &base_vha->dpc_flags);
Seokmann Ju99363ef2008-01-31 12:33:51 -08003331 }
3332
Linus Torvalds1da177e2005-04-16 15:20:36 -07003333 DEBUG(printk("scsi(%ld): dpc: qla2x00_abort_isp end\n",
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003334 base_vha->host_no));
Linus Torvalds1da177e2005-04-16 15:20:36 -07003335 }
3336
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003337 if (test_bit(FCPORT_UPDATE_NEEDED, &base_vha->dpc_flags)) {
3338 qla2x00_update_fcports(base_vha);
3339 clear_bit(FCPORT_UPDATE_NEEDED, &base_vha->dpc_flags);
Andrew Vasquezc9c5ced2008-07-24 08:31:49 -07003340 }
andrew.vasquez@qlogic.comd97994d2006-01-20 14:53:13 -08003341
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003342 if (test_and_clear_bit(RESET_MARKER_NEEDED,
3343 &base_vha->dpc_flags) &&
3344 (!(test_and_set_bit(RESET_ACTIVE, &base_vha->dpc_flags)))) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003345
3346 DEBUG(printk("scsi(%ld): qla2x00_reset_marker()\n",
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003347 base_vha->host_no));
Linus Torvalds1da177e2005-04-16 15:20:36 -07003348
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003349 qla2x00_rst_aen(base_vha);
3350 clear_bit(RESET_ACTIVE, &base_vha->dpc_flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003351 }
3352
3353 /* Retry each device up to login retry count */
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003354 if ((test_and_clear_bit(RELOGIN_NEEDED,
3355 &base_vha->dpc_flags)) &&
3356 !test_bit(LOOP_RESYNC_NEEDED, &base_vha->dpc_flags) &&
3357 atomic_read(&base_vha->loop_state) != LOOP_DOWN) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003358
3359 DEBUG(printk("scsi(%ld): qla2x00_port_login()\n",
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003360 base_vha->host_no));
3361 qla2x00_relogin(base_vha);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003362
Linus Torvalds1da177e2005-04-16 15:20:36 -07003363 DEBUG(printk("scsi(%ld): qla2x00_port_login - end\n",
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003364 base_vha->host_no));
Linus Torvalds1da177e2005-04-16 15:20:36 -07003365 }
3366
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003367 if (test_and_clear_bit(LOOP_RESYNC_NEEDED,
3368 &base_vha->dpc_flags)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003369
3370 DEBUG(printk("scsi(%ld): qla2x00_loop_resync()\n",
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003371 base_vha->host_no));
Linus Torvalds1da177e2005-04-16 15:20:36 -07003372
3373 if (!(test_and_set_bit(LOOP_RESYNC_ACTIVE,
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003374 &base_vha->dpc_flags))) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003375
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003376 rval = qla2x00_loop_resync(base_vha);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003377
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003378 clear_bit(LOOP_RESYNC_ACTIVE,
3379 &base_vha->dpc_flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003380 }
3381
3382 DEBUG(printk("scsi(%ld): qla2x00_loop_resync - end\n",
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003383 base_vha->host_no));
Linus Torvalds1da177e2005-04-16 15:20:36 -07003384 }
3385
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003386 if (test_bit(NPIV_CONFIG_NEEDED, &base_vha->dpc_flags) &&
3387 atomic_read(&base_vha->loop_state) == LOOP_READY) {
3388 clear_bit(NPIV_CONFIG_NEEDED, &base_vha->dpc_flags);
3389 qla2xxx_flash_npiv_conf(base_vha);
Andrew Vasquez272976c2008-09-11 21:22:50 -07003390 }
3391
Linus Torvalds1da177e2005-04-16 15:20:36 -07003392 if (!ha->interrupts_on)
Andrew Vasquezfd34f552007-07-19 15:06:00 -07003393 ha->isp_ops->enable_intrs(ha);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003394
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003395 if (test_and_clear_bit(BEACON_BLINK_NEEDED,
3396 &base_vha->dpc_flags))
3397 ha->isp_ops->beacon_blink(base_vha);
andrew.vasquez@qlogic.comf6df1442006-01-31 16:05:07 -08003398
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003399 qla2x00_do_dpc_all_vps(base_vha);
Seokmann Ju2c3dfe32007-07-05 13:16:51 -07003400
Linus Torvalds1da177e2005-04-16 15:20:36 -07003401 ha->dpc_active = 0;
3402 } /* End of while(1) */
3403
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003404 DEBUG(printk("scsi(%ld): DPC handler exiting\n", base_vha->host_no));
Linus Torvalds1da177e2005-04-16 15:20:36 -07003405
3406 /*
3407 * Make sure that nobody tries to wake us up again.
3408 */
Linus Torvalds1da177e2005-04-16 15:20:36 -07003409 ha->dpc_active = 0;
3410
Andrew Vasquezac280b62009-08-20 11:06:05 -07003411 /* Cleanup any residual CTX SRBs. */
3412 qla2x00_abort_all_cmds(base_vha, DID_NO_CONNECT << 16);
3413
Christoph Hellwig39a11242006-02-14 18:46:22 +01003414 return 0;
3415}
3416
3417void
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003418qla2xxx_wake_dpc(struct scsi_qla_host *vha)
Christoph Hellwig39a11242006-02-14 18:46:22 +01003419{
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003420 struct qla_hw_data *ha = vha->hw;
Andrew Vasquezc795c1e2008-08-13 21:37:01 -07003421 struct task_struct *t = ha->dpc_thread;
3422
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003423 if (!test_bit(UNLOADING, &vha->dpc_flags) && t)
Andrew Vasquezc795c1e2008-08-13 21:37:01 -07003424 wake_up_process(t);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003425}
3426
3427/*
Linus Torvalds1da177e2005-04-16 15:20:36 -07003428* qla2x00_rst_aen
3429* Processes asynchronous reset.
3430*
3431* Input:
3432* ha = adapter block pointer.
3433*/
3434static void
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003435qla2x00_rst_aen(scsi_qla_host_t *vha)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003436{
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003437 if (vha->flags.online && !vha->flags.reset_active &&
3438 !atomic_read(&vha->loop_down_timer) &&
3439 !(test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags))) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003440 do {
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003441 clear_bit(RESET_MARKER_NEEDED, &vha->dpc_flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003442
3443 /*
3444 * Issue marker command only when we are going to start
3445 * the I/O.
3446 */
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003447 vha->marker_needed = 1;
3448 } while (!atomic_read(&vha->loop_down_timer) &&
3449 (test_bit(RESET_MARKER_NEEDED, &vha->dpc_flags)));
Linus Torvalds1da177e2005-04-16 15:20:36 -07003450 }
3451}
3452
f4f051e2005-04-17 15:02:26 -05003453static void
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003454qla2x00_sp_free_dma(srb_t *sp)
f4f051e2005-04-17 15:02:26 -05003455{
3456 struct scsi_cmnd *cmd = sp->cmd;
Arun Easibad75002010-05-04 15:01:30 -07003457 struct qla_hw_data *ha = sp->fcport->vha->hw;
f4f051e2005-04-17 15:02:26 -05003458
3459 if (sp->flags & SRB_DMA_VALID) {
FUJITA Tomonori385d70b2007-05-26 01:55:38 +09003460 scsi_dma_unmap(cmd);
f4f051e2005-04-17 15:02:26 -05003461 sp->flags &= ~SRB_DMA_VALID;
3462 }
Arun Easibad75002010-05-04 15:01:30 -07003463
3464 if (sp->flags & SRB_CRC_PROT_DMA_VALID) {
3465 dma_unmap_sg(&ha->pdev->dev, scsi_prot_sglist(cmd),
3466 scsi_prot_sg_count(cmd), cmd->sc_data_direction);
3467 sp->flags &= ~SRB_CRC_PROT_DMA_VALID;
3468 }
3469
3470 if (sp->flags & SRB_CRC_CTX_DSD_VALID) {
3471 /* List assured to be having elements */
3472 qla2x00_clean_dsd_pool(ha, sp);
3473 sp->flags &= ~SRB_CRC_CTX_DSD_VALID;
3474 }
3475
3476 if (sp->flags & SRB_CRC_CTX_DMA_VALID) {
3477 dma_pool_free(ha->dl_dma_pool, sp->ctx,
3478 ((struct crc_context *)sp->ctx)->crc_ctx_dma);
3479 sp->flags &= ~SRB_CRC_CTX_DMA_VALID;
3480 }
3481
Andrew Vasquezfca29702005-07-06 10:31:47 -07003482 CMD_SP(cmd) = NULL;
f4f051e2005-04-17 15:02:26 -05003483}
3484
3485void
Giridhar Malavali083a4692010-05-28 15:08:18 -07003486qla2x00_sp_final_compl(struct qla_hw_data *ha, srb_t *sp)
f4f051e2005-04-17 15:02:26 -05003487{
3488 struct scsi_cmnd *cmd = sp->cmd;
3489
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003490 qla2x00_sp_free_dma(sp);
f4f051e2005-04-17 15:02:26 -05003491
Giridhar Malavalia9083012010-04-12 17:59:55 -07003492 if (sp->flags & SRB_FCP_CMND_DMA_VALID) {
3493 struct ct6_dsd *ctx = sp->ctx;
3494 dma_pool_free(ha->fcp_cmnd_dma_pool, ctx->fcp_cmnd,
3495 ctx->fcp_cmnd_dma);
3496 list_splice(&ctx->dsd_list, &ha->gbl_dsd_list);
3497 ha->gbl_dsd_inuse -= ctx->dsd_use_cnt;
3498 ha->gbl_dsd_avail += ctx->dsd_use_cnt;
3499 mempool_free(sp->ctx, ha->ctx_mempool);
3500 sp->ctx = NULL;
3501 }
f4f051e2005-04-17 15:02:26 -05003502
Giridhar Malavalia9083012010-04-12 17:59:55 -07003503 mempool_free(sp, ha->srb_mempool);
f4f051e2005-04-17 15:02:26 -05003504 cmd->scsi_done(cmd);
3505}
bdf79622005-04-17 15:06:53 -05003506
Giridhar Malavali083a4692010-05-28 15:08:18 -07003507void
3508qla2x00_sp_compl(struct qla_hw_data *ha, srb_t *sp)
3509{
3510 if (atomic_read(&sp->ref_count) == 0) {
3511 DEBUG2(qla_printk(KERN_WARNING, ha,
3512 "SP reference-count to ZERO -- sp=%p\n", sp));
3513 DEBUG2(BUG());
3514 return;
3515 }
3516 if (!atomic_dec_and_test(&sp->ref_count))
3517 return;
3518 qla2x00_sp_final_compl(ha, sp);
3519}
3520
Linus Torvalds1da177e2005-04-16 15:20:36 -07003521/**************************************************************************
3522* qla2x00_timer
3523*
3524* Description:
3525* One second timer
3526*
3527* Context: Interrupt
3528***************************************************************************/
Seokmann Ju2c3dfe32007-07-05 13:16:51 -07003529void
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003530qla2x00_timer(scsi_qla_host_t *vha)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003531{
Linus Torvalds1da177e2005-04-16 15:20:36 -07003532 unsigned long cpu_flags = 0;
3533 fc_port_t *fcport;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003534 int start_dpc = 0;
3535 int index;
3536 srb_t *sp;
f4f051e2005-04-17 15:02:26 -05003537 int t;
Andrew Vasquez85880802009-12-15 21:29:46 -08003538 uint16_t w;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003539 struct qla_hw_data *ha = vha->hw;
Anirban Chakraborty73208df2008-12-09 16:45:39 -08003540 struct req_que *req;
Andrew Vasquez85880802009-12-15 21:29:46 -08003541
Giridhar Malavalia9083012010-04-12 17:59:55 -07003542 if (IS_QLA82XX(ha))
3543 qla82xx_watchdog(vha);
3544
Andrew Vasquez85880802009-12-15 21:29:46 -08003545 /* Hardware read to raise pending EEH errors during mailbox waits. */
3546 if (!pci_channel_offline(ha->pdev))
3547 pci_read_config_word(ha->pdev, PCI_VENDOR_ID, &w);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003548 /*
3549 * Ports - Port down timer.
3550 *
3551 * Whenever, a port is in the LOST state we start decrementing its port
3552 * down timer every second until it reaches zero. Once it reaches zero
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -07003553 * the port it marked DEAD.
Linus Torvalds1da177e2005-04-16 15:20:36 -07003554 */
3555 t = 0;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003556 list_for_each_entry(fcport, &vha->vp_fcports, list) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003557 if (fcport->port_type != FCT_TARGET)
3558 continue;
3559
3560 if (atomic_read(&fcport->state) == FCS_DEVICE_LOST) {
3561
3562 if (atomic_read(&fcport->port_down_timer) == 0)
3563 continue;
3564
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -07003565 if (atomic_dec_and_test(&fcport->port_down_timer) != 0)
Linus Torvalds1da177e2005-04-16 15:20:36 -07003566 atomic_set(&fcport->state, FCS_DEVICE_DEAD);
Andrew Vasquezfa2a1ce2005-07-06 10:32:07 -07003567
Linus Torvalds1da177e2005-04-16 15:20:36 -07003568 DEBUG(printk("scsi(%ld): fcport-%d - port retry count: "
Andrew Vasquezfca29702005-07-06 10:31:47 -07003569 "%d remaining\n",
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003570 vha->host_no,
Linus Torvalds1da177e2005-04-16 15:20:36 -07003571 t, atomic_read(&fcport->port_down_timer)));
3572 }
3573 t++;
3574 } /* End of for fcport */
3575
Linus Torvalds1da177e2005-04-16 15:20:36 -07003576
3577 /* Loop down handler. */
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003578 if (atomic_read(&vha->loop_down_timer) > 0 &&
3579 !(test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags))
3580 && vha->flags.online) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003581
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003582 if (atomic_read(&vha->loop_down_timer) ==
3583 vha->loop_down_abort_time) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003584
3585 DEBUG(printk("scsi(%ld): Loop Down - aborting the "
3586 "queues before time expire\n",
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003587 vha->host_no));
Linus Torvalds1da177e2005-04-16 15:20:36 -07003588
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003589 if (!IS_QLA2100(ha) && vha->link_down_timeout)
3590 atomic_set(&vha->loop_state, LOOP_DEAD);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003591
Andrew Vasquezf08b7252010-01-12 12:59:48 -08003592 /*
3593 * Schedule an ISP abort to return any FCP2-device
3594 * commands.
3595 */
Seokmann Ju2c3dfe32007-07-05 13:16:51 -07003596 /* NPIV - scan physical port only */
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003597 if (!vha->vp_idx) {
Seokmann Ju2c3dfe32007-07-05 13:16:51 -07003598 spin_lock_irqsave(&ha->hardware_lock,
3599 cpu_flags);
Anirban Chakraborty73208df2008-12-09 16:45:39 -08003600 req = ha->req_q_map[0];
Seokmann Ju2c3dfe32007-07-05 13:16:51 -07003601 for (index = 1;
3602 index < MAX_OUTSTANDING_COMMANDS;
3603 index++) {
3604 fc_port_t *sfcp;
bdf79622005-04-17 15:06:53 -05003605
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003606 sp = req->outstanding_cmds[index];
Seokmann Ju2c3dfe32007-07-05 13:16:51 -07003607 if (!sp)
3608 continue;
Arun Easibad75002010-05-04 15:01:30 -07003609 if (sp->ctx && !IS_PROT_IO(sp))
Andrew Vasquezcf53b062009-08-20 11:06:04 -07003610 continue;
Seokmann Ju2c3dfe32007-07-05 13:16:51 -07003611 sfcp = sp->fcport;
Andrew Vasquezf08b7252010-01-12 12:59:48 -08003612 if (!(sfcp->flags & FCF_FCP2_DEVICE))
Seokmann Ju2c3dfe32007-07-05 13:16:51 -07003613 continue;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003614
Seokmann Ju2c3dfe32007-07-05 13:16:51 -07003615 set_bit(ISP_ABORT_NEEDED,
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003616 &vha->dpc_flags);
Seokmann Ju2c3dfe32007-07-05 13:16:51 -07003617 break;
3618 }
3619 spin_unlock_irqrestore(&ha->hardware_lock,
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003620 cpu_flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003621 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003622 start_dpc++;
3623 }
3624
3625 /* if the loop has been down for 4 minutes, reinit adapter */
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003626 if (atomic_dec_and_test(&vha->loop_down_timer) != 0) {
Andrew Vasquez0d6e61b2009-08-25 11:36:19 -07003627 if (!(vha->device_flags & DFLG_NO_CABLE)) {
Linus Torvalds1da177e2005-04-16 15:20:36 -07003628 DEBUG(printk("scsi(%ld): Loop down - "
3629 "aborting ISP.\n",
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003630 vha->host_no));
Linus Torvalds1da177e2005-04-16 15:20:36 -07003631 qla_printk(KERN_WARNING, ha,
3632 "Loop down - aborting ISP.\n");
3633
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003634 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003635 }
3636 }
Andrew Vasquezfca29702005-07-06 10:31:47 -07003637 DEBUG3(printk("scsi(%ld): Loop Down - seconds remaining %d\n",
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003638 vha->host_no,
3639 atomic_read(&vha->loop_down_timer)));
Linus Torvalds1da177e2005-04-16 15:20:36 -07003640 }
3641
andrew.vasquez@qlogic.comf6df1442006-01-31 16:05:07 -08003642 /* Check if beacon LED needs to be blinked */
3643 if (ha->beacon_blink_led == 1) {
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003644 set_bit(BEACON_BLINK_NEEDED, &vha->dpc_flags);
andrew.vasquez@qlogic.comf6df1442006-01-31 16:05:07 -08003645 start_dpc++;
3646 }
3647
Andrew Vasquez550bf572008-04-24 15:21:23 -07003648 /* Process any deferred work. */
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003649 if (!list_empty(&vha->work_list))
Andrew Vasquez550bf572008-04-24 15:21:23 -07003650 start_dpc++;
3651
Linus Torvalds1da177e2005-04-16 15:20:36 -07003652 /* Schedule the DPC routine if needed */
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003653 if ((test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) ||
3654 test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags) ||
3655 test_bit(FCPORT_UPDATE_NEEDED, &vha->dpc_flags) ||
Linus Torvalds1da177e2005-04-16 15:20:36 -07003656 start_dpc ||
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003657 test_bit(RESET_MARKER_NEEDED, &vha->dpc_flags) ||
3658 test_bit(BEACON_BLINK_NEEDED, &vha->dpc_flags) ||
Giridhar Malavalia9083012010-04-12 17:59:55 -07003659 test_bit(ISP_UNRECOVERABLE, &vha->dpc_flags) ||
3660 test_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags) ||
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003661 test_bit(VP_DPC_NEEDED, &vha->dpc_flags) ||
3662 test_bit(RELOGIN_NEEDED, &vha->dpc_flags)))
3663 qla2xxx_wake_dpc(vha);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003664
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003665 qla2x00_restart_timer(vha, WATCH_INTERVAL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003666}
3667
Andrew Vasquez54333832005-11-09 15:49:04 -08003668/* Firmware interface routines. */
3669
Giridhar Malavalia9083012010-04-12 17:59:55 -07003670#define FW_BLOBS 8
Andrew Vasquez54333832005-11-09 15:49:04 -08003671#define FW_ISP21XX 0
3672#define FW_ISP22XX 1
3673#define FW_ISP2300 2
3674#define FW_ISP2322 3
andrew.vasquez@qlogic.com48c02fd2006-03-09 14:27:18 -08003675#define FW_ISP24XX 4
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07003676#define FW_ISP25XX 5
Andrew Vasquez3a03eb72009-01-05 11:18:11 -08003677#define FW_ISP81XX 6
Giridhar Malavalia9083012010-04-12 17:59:55 -07003678#define FW_ISP82XX 7
Andrew Vasquez54333832005-11-09 15:49:04 -08003679
Andrew Vasquezbb8ee492006-10-02 12:00:48 -07003680#define FW_FILE_ISP21XX "ql2100_fw.bin"
3681#define FW_FILE_ISP22XX "ql2200_fw.bin"
3682#define FW_FILE_ISP2300 "ql2300_fw.bin"
3683#define FW_FILE_ISP2322 "ql2322_fw.bin"
3684#define FW_FILE_ISP24XX "ql2400_fw.bin"
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07003685#define FW_FILE_ISP25XX "ql2500_fw.bin"
Andrew Vasquez3a03eb72009-01-05 11:18:11 -08003686#define FW_FILE_ISP81XX "ql8100_fw.bin"
Giridhar Malavalia9083012010-04-12 17:59:55 -07003687#define FW_FILE_ISP82XX "ql8200_fw.bin"
Andrew Vasquezbb8ee492006-10-02 12:00:48 -07003688
Daniel Walkere1e82b62008-05-12 22:21:10 -07003689static DEFINE_MUTEX(qla_fw_lock);
Andrew Vasquez54333832005-11-09 15:49:04 -08003690
3691static struct fw_blob qla_fw_blobs[FW_BLOBS] = {
Andrew Vasquezbb8ee492006-10-02 12:00:48 -07003692 { .name = FW_FILE_ISP21XX, .segs = { 0x1000, 0 }, },
3693 { .name = FW_FILE_ISP22XX, .segs = { 0x1000, 0 }, },
3694 { .name = FW_FILE_ISP2300, .segs = { 0x800, 0 }, },
3695 { .name = FW_FILE_ISP2322, .segs = { 0x800, 0x1c000, 0x1e000, 0 }, },
3696 { .name = FW_FILE_ISP24XX, },
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07003697 { .name = FW_FILE_ISP25XX, },
Andrew Vasquez3a03eb72009-01-05 11:18:11 -08003698 { .name = FW_FILE_ISP81XX, },
Giridhar Malavalia9083012010-04-12 17:59:55 -07003699 { .name = FW_FILE_ISP82XX, },
Andrew Vasquez54333832005-11-09 15:49:04 -08003700};
3701
3702struct fw_blob *
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003703qla2x00_request_firmware(scsi_qla_host_t *vha)
Andrew Vasquez54333832005-11-09 15:49:04 -08003704{
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003705 struct qla_hw_data *ha = vha->hw;
Andrew Vasquez54333832005-11-09 15:49:04 -08003706 struct fw_blob *blob;
3707
3708 blob = NULL;
3709 if (IS_QLA2100(ha)) {
3710 blob = &qla_fw_blobs[FW_ISP21XX];
3711 } else if (IS_QLA2200(ha)) {
3712 blob = &qla_fw_blobs[FW_ISP22XX];
andrew.vasquez@qlogic.com48c02fd2006-03-09 14:27:18 -08003713 } else if (IS_QLA2300(ha) || IS_QLA2312(ha) || IS_QLA6312(ha)) {
Andrew Vasquez54333832005-11-09 15:49:04 -08003714 blob = &qla_fw_blobs[FW_ISP2300];
andrew.vasquez@qlogic.com48c02fd2006-03-09 14:27:18 -08003715 } else if (IS_QLA2322(ha) || IS_QLA6322(ha)) {
Andrew Vasquez54333832005-11-09 15:49:04 -08003716 blob = &qla_fw_blobs[FW_ISP2322];
Harihara Kadayam4d4df192008-04-03 13:13:26 -07003717 } else if (IS_QLA24XX_TYPE(ha)) {
Andrew Vasquez54333832005-11-09 15:49:04 -08003718 blob = &qla_fw_blobs[FW_ISP24XX];
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07003719 } else if (IS_QLA25XX(ha)) {
3720 blob = &qla_fw_blobs[FW_ISP25XX];
Andrew Vasquez3a03eb72009-01-05 11:18:11 -08003721 } else if (IS_QLA81XX(ha)) {
3722 blob = &qla_fw_blobs[FW_ISP81XX];
Giridhar Malavalia9083012010-04-12 17:59:55 -07003723 } else if (IS_QLA82XX(ha)) {
3724 blob = &qla_fw_blobs[FW_ISP82XX];
Andrew Vasquez54333832005-11-09 15:49:04 -08003725 }
3726
Daniel Walkere1e82b62008-05-12 22:21:10 -07003727 mutex_lock(&qla_fw_lock);
Andrew Vasquez54333832005-11-09 15:49:04 -08003728 if (blob->fw)
3729 goto out;
3730
3731 if (request_firmware(&blob->fw, blob->name, &ha->pdev->dev)) {
3732 DEBUG2(printk("scsi(%ld): Failed to load firmware image "
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003733 "(%s).\n", vha->host_no, blob->name));
Andrew Vasquez54333832005-11-09 15:49:04 -08003734 blob->fw = NULL;
3735 blob = NULL;
3736 goto out;
3737 }
3738
3739out:
Daniel Walkere1e82b62008-05-12 22:21:10 -07003740 mutex_unlock(&qla_fw_lock);
Andrew Vasquez54333832005-11-09 15:49:04 -08003741 return blob;
3742}
3743
3744static void
3745qla2x00_release_firmware(void)
3746{
3747 int idx;
3748
Daniel Walkere1e82b62008-05-12 22:21:10 -07003749 mutex_lock(&qla_fw_lock);
Andrew Vasquez54333832005-11-09 15:49:04 -08003750 for (idx = 0; idx < FW_BLOBS; idx++)
3751 if (qla_fw_blobs[idx].fw)
3752 release_firmware(qla_fw_blobs[idx].fw);
Daniel Walkere1e82b62008-05-12 22:21:10 -07003753 mutex_unlock(&qla_fw_lock);
Andrew Vasquez54333832005-11-09 15:49:04 -08003754}
3755
Seokmann Ju14e660e2007-09-20 14:07:36 -07003756static pci_ers_result_t
3757qla2xxx_pci_error_detected(struct pci_dev *pdev, pci_channel_state_t state)
3758{
Andrew Vasquez85880802009-12-15 21:29:46 -08003759 scsi_qla_host_t *vha = pci_get_drvdata(pdev);
3760 struct qla_hw_data *ha = vha->hw;
3761
3762 DEBUG2(qla_printk(KERN_WARNING, ha, "error_detected:state %x\n",
3763 state));
Seokmann Jub9b12f72009-03-24 09:08:18 -07003764
Seokmann Ju14e660e2007-09-20 14:07:36 -07003765 switch (state) {
3766 case pci_channel_io_normal:
Andrew Vasquez85880802009-12-15 21:29:46 -08003767 ha->flags.eeh_busy = 0;
Seokmann Ju14e660e2007-09-20 14:07:36 -07003768 return PCI_ERS_RESULT_CAN_RECOVER;
3769 case pci_channel_io_frozen:
Andrew Vasquez85880802009-12-15 21:29:46 -08003770 ha->flags.eeh_busy = 1;
Joe Carnuccio90a86fc2010-01-12 13:02:46 -08003771 qla2x00_free_irqs(vha);
Seokmann Ju14e660e2007-09-20 14:07:36 -07003772 pci_disable_device(pdev);
3773 return PCI_ERS_RESULT_NEED_RESET;
3774 case pci_channel_io_perm_failure:
Andrew Vasquez85880802009-12-15 21:29:46 -08003775 ha->flags.pci_channel_io_perm_failure = 1;
3776 qla2x00_abort_all_cmds(vha, DID_NO_CONNECT << 16);
Seokmann Ju14e660e2007-09-20 14:07:36 -07003777 return PCI_ERS_RESULT_DISCONNECT;
3778 }
3779 return PCI_ERS_RESULT_NEED_RESET;
3780}
3781
3782static pci_ers_result_t
3783qla2xxx_pci_mmio_enabled(struct pci_dev *pdev)
3784{
3785 int risc_paused = 0;
3786 uint32_t stat;
3787 unsigned long flags;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003788 scsi_qla_host_t *base_vha = pci_get_drvdata(pdev);
3789 struct qla_hw_data *ha = base_vha->hw;
Seokmann Ju14e660e2007-09-20 14:07:36 -07003790 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
3791 struct device_reg_24xx __iomem *reg24 = &ha->iobase->isp24;
3792
3793 spin_lock_irqsave(&ha->hardware_lock, flags);
3794 if (IS_QLA2100(ha) || IS_QLA2200(ha)){
3795 stat = RD_REG_DWORD(&reg->hccr);
3796 if (stat & HCCR_RISC_PAUSE)
3797 risc_paused = 1;
3798 } else if (IS_QLA23XX(ha)) {
3799 stat = RD_REG_DWORD(&reg->u.isp2300.host_status);
3800 if (stat & HSR_RISC_PAUSED)
3801 risc_paused = 1;
3802 } else if (IS_FWI2_CAPABLE(ha)) {
3803 stat = RD_REG_DWORD(&reg24->host_status);
3804 if (stat & HSRX_RISC_PAUSED)
3805 risc_paused = 1;
3806 }
3807 spin_unlock_irqrestore(&ha->hardware_lock, flags);
3808
3809 if (risc_paused) {
3810 qla_printk(KERN_INFO, ha, "RISC paused -- mmio_enabled, "
3811 "Dumping firmware!\n");
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003812 ha->isp_ops->fw_dump(base_vha, 0);
Seokmann Ju14e660e2007-09-20 14:07:36 -07003813
3814 return PCI_ERS_RESULT_NEED_RESET;
3815 } else
3816 return PCI_ERS_RESULT_RECOVERED;
3817}
3818
3819static pci_ers_result_t
3820qla2xxx_pci_slot_reset(struct pci_dev *pdev)
3821{
3822 pci_ers_result_t ret = PCI_ERS_RESULT_DISCONNECT;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003823 scsi_qla_host_t *base_vha = pci_get_drvdata(pdev);
3824 struct qla_hw_data *ha = base_vha->hw;
Joe Carnuccio90a86fc2010-01-12 13:02:46 -08003825 struct rsp_que *rsp;
3826 int rc, retries = 10;
Seokmann Ju14e660e2007-09-20 14:07:36 -07003827
Andrew Vasquez85880802009-12-15 21:29:46 -08003828 DEBUG17(qla_printk(KERN_WARNING, ha, "slot_reset\n"));
3829
Joe Carnuccio90a86fc2010-01-12 13:02:46 -08003830 /* Workaround: qla2xxx driver which access hardware earlier
3831 * needs error state to be pci_channel_io_online.
3832 * Otherwise mailbox command timesout.
3833 */
3834 pdev->error_state = pci_channel_io_normal;
3835
3836 pci_restore_state(pdev);
3837
Richard Lary8c1496b2010-02-18 10:07:29 -08003838 /* pci_restore_state() clears the saved_state flag of the device
3839 * save restored state which resets saved_state flag
3840 */
3841 pci_save_state(pdev);
3842
Benjamin Herrenschmidt09483912007-12-20 15:28:09 +11003843 if (ha->mem_only)
3844 rc = pci_enable_device_mem(pdev);
3845 else
3846 rc = pci_enable_device(pdev);
3847
3848 if (rc) {
Seokmann Ju14e660e2007-09-20 14:07:36 -07003849 qla_printk(KERN_WARNING, ha,
3850 "Can't re-enable PCI device after reset.\n");
Seokmann Ju14e660e2007-09-20 14:07:36 -07003851 return ret;
3852 }
Seokmann Ju14e660e2007-09-20 14:07:36 -07003853
Joe Carnuccio90a86fc2010-01-12 13:02:46 -08003854 rsp = ha->rsp_q_map[0];
3855 if (qla2x00_request_irqs(ha, rsp))
3856 return ret;
3857
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003858 if (ha->isp_ops->pci_config(base_vha))
Seokmann Ju14e660e2007-09-20 14:07:36 -07003859 return ret;
3860
Joe Carnuccio90a86fc2010-01-12 13:02:46 -08003861 while (ha->flags.mbox_busy && retries--)
3862 msleep(1000);
Andrew Vasquez85880802009-12-15 21:29:46 -08003863
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003864 set_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags);
Giridhar Malavalia9083012010-04-12 17:59:55 -07003865 if (ha->isp_ops->abort_isp(base_vha) == QLA_SUCCESS)
Seokmann Ju14e660e2007-09-20 14:07:36 -07003866 ret = PCI_ERS_RESULT_RECOVERED;
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003867 clear_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags);
Seokmann Ju14e660e2007-09-20 14:07:36 -07003868
Joe Carnuccio90a86fc2010-01-12 13:02:46 -08003869
Andrew Vasquez85880802009-12-15 21:29:46 -08003870 DEBUG17(qla_printk(KERN_WARNING, ha,
3871 "slot_reset-return:ret=%x\n", ret));
3872
Seokmann Ju14e660e2007-09-20 14:07:36 -07003873 return ret;
3874}
3875
3876static void
3877qla2xxx_pci_resume(struct pci_dev *pdev)
3878{
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003879 scsi_qla_host_t *base_vha = pci_get_drvdata(pdev);
3880 struct qla_hw_data *ha = base_vha->hw;
Seokmann Ju14e660e2007-09-20 14:07:36 -07003881 int ret;
3882
Andrew Vasquez85880802009-12-15 21:29:46 -08003883 DEBUG17(qla_printk(KERN_WARNING, ha, "pci_resume\n"));
3884
Anirban Chakrabortye315cd22008-11-06 10:40:51 -08003885 ret = qla2x00_wait_for_hba_online(base_vha);
Seokmann Ju14e660e2007-09-20 14:07:36 -07003886 if (ret != QLA_SUCCESS) {
3887 qla_printk(KERN_ERR, ha,
3888 "the device failed to resume I/O "
3889 "from slot/link_reset");
3890 }
Andrew Vasquez85880802009-12-15 21:29:46 -08003891
Lalit Chandivade3e46f032010-05-04 15:01:23 -07003892 pci_cleanup_aer_uncorrect_error_status(pdev);
3893
Andrew Vasquez85880802009-12-15 21:29:46 -08003894 ha->flags.eeh_busy = 0;
Seokmann Ju14e660e2007-09-20 14:07:36 -07003895}
3896
3897static struct pci_error_handlers qla2xxx_err_handler = {
3898 .error_detected = qla2xxx_pci_error_detected,
3899 .mmio_enabled = qla2xxx_pci_mmio_enabled,
3900 .slot_reset = qla2xxx_pci_slot_reset,
3901 .resume = qla2xxx_pci_resume,
3902};
3903
Andrew Vasquez54333832005-11-09 15:49:04 -08003904static struct pci_device_id qla2xxx_pci_tbl[] = {
Andrew Vasquez47f5e062006-05-17 15:09:39 -07003905 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2100) },
3906 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2200) },
3907 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2300) },
3908 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2312) },
3909 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2322) },
3910 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP6312) },
3911 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP6322) },
3912 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2422) },
3913 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2432) },
Harihara Kadayam4d4df192008-04-03 13:13:26 -07003914 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8432) },
Andrew Vasquez47f5e062006-05-17 15:09:39 -07003915 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP5422) },
3916 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP5432) },
Andrew Vasquezc3a2f0d2007-07-19 20:37:34 -07003917 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP2532) },
Andrew Vasquez3a03eb72009-01-05 11:18:11 -08003918 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8001) },
Giridhar Malavalia9083012010-04-12 17:59:55 -07003919 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC, PCI_DEVICE_ID_QLOGIC_ISP8021) },
Andrew Vasquez54333832005-11-09 15:49:04 -08003920 { 0 },
3921};
3922MODULE_DEVICE_TABLE(pci, qla2xxx_pci_tbl);
3923
Andrew Vasquezfca29702005-07-06 10:31:47 -07003924static struct pci_driver qla2xxx_pci_driver = {
Andrew Vasquezcb630672006-05-17 15:09:45 -07003925 .name = QLA2XXX_DRIVER_NAME,
James Bottomley0a21ef12005-12-01 12:51:50 -06003926 .driver = {
3927 .owner = THIS_MODULE,
3928 },
Andrew Vasquezfca29702005-07-06 10:31:47 -07003929 .id_table = qla2xxx_pci_tbl,
Andrew Vasquez7ee61392006-06-23 16:11:22 -07003930 .probe = qla2x00_probe_one,
Adrian Bunk4c993f72008-01-14 00:55:16 -08003931 .remove = qla2x00_remove_one,
Seokmann Ju14e660e2007-09-20 14:07:36 -07003932 .err_handler = &qla2xxx_err_handler,
Andrew Vasquezfca29702005-07-06 10:31:47 -07003933};
3934
Harish Zunjarrao6a03b4c2010-05-04 15:01:24 -07003935static struct file_operations apidev_fops = {
3936 .owner = THIS_MODULE,
3937};
3938
Linus Torvalds1da177e2005-04-16 15:20:36 -07003939/**
3940 * qla2x00_module_init - Module initialization.
3941 **/
3942static int __init
3943qla2x00_module_init(void)
3944{
Andrew Vasquezfca29702005-07-06 10:31:47 -07003945 int ret = 0;
3946
Linus Torvalds1da177e2005-04-16 15:20:36 -07003947 /* Allocate cache for SRBs. */
Andrew Vasquez 354d6b22005-04-23 02:47:27 -04003948 srb_cachep = kmem_cache_create("qla2xxx_srbs", sizeof(srb_t), 0,
Paul Mundt20c2df82007-07-20 10:11:58 +09003949 SLAB_HWCACHE_ALIGN, NULL);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003950 if (srb_cachep == NULL) {
3951 printk(KERN_ERR
3952 "qla2xxx: Unable to allocate SRB cache...Failing load!\n");
3953 return -ENOMEM;
3954 }
3955
3956 /* Derive version string. */
3957 strcpy(qla2x00_version_str, QLA2XXX_VERSION);
Andrew Vasquez11010fe2006-10-06 09:54:59 -07003958 if (ql2xextended_error_logging)
Andrew Vasquez01819442006-06-23 16:11:10 -07003959 strcat(qla2x00_version_str, "-debug");
3960
Andrew Vasquez1c97a122005-04-21 16:13:36 -04003961 qla2xxx_transport_template =
3962 fc_attach_transport(&qla2xxx_transport_functions);
Seokmann Ju2c3dfe32007-07-05 13:16:51 -07003963 if (!qla2xxx_transport_template) {
3964 kmem_cache_destroy(srb_cachep);
Linus Torvalds1da177e2005-04-16 15:20:36 -07003965 return -ENODEV;
Seokmann Ju2c3dfe32007-07-05 13:16:51 -07003966 }
Harish Zunjarrao6a03b4c2010-05-04 15:01:24 -07003967
3968 apidev_major = register_chrdev(0, QLA2XXX_APIDEV, &apidev_fops);
3969 if (apidev_major < 0) {
3970 printk(KERN_WARNING "qla2xxx: Unable to register char device "
3971 "%s\n", QLA2XXX_APIDEV);
3972 }
3973
Seokmann Ju2c3dfe32007-07-05 13:16:51 -07003974 qla2xxx_transport_vport_template =
3975 fc_attach_transport(&qla2xxx_transport_vport_functions);
3976 if (!qla2xxx_transport_vport_template) {
3977 kmem_cache_destroy(srb_cachep);
3978 fc_release_transport(qla2xxx_transport_template);
3979 return -ENODEV;
3980 }
Linus Torvalds1da177e2005-04-16 15:20:36 -07003981
Andrew Vasquezfd9a29f02008-05-12 22:21:08 -07003982 printk(KERN_INFO "QLogic Fibre Channel HBA Driver: %s\n",
3983 qla2x00_version_str);
Andrew Vasquez7ee61392006-06-23 16:11:22 -07003984 ret = pci_register_driver(&qla2xxx_pci_driver);
Andrew Vasquezfca29702005-07-06 10:31:47 -07003985 if (ret) {
3986 kmem_cache_destroy(srb_cachep);
3987 fc_release_transport(qla2xxx_transport_template);
Seokmann Ju2c3dfe32007-07-05 13:16:51 -07003988 fc_release_transport(qla2xxx_transport_vport_template);
Andrew Vasquezfca29702005-07-06 10:31:47 -07003989 }
3990 return ret;
Linus Torvalds1da177e2005-04-16 15:20:36 -07003991}
3992
3993/**
3994 * qla2x00_module_exit - Module cleanup.
3995 **/
3996static void __exit
3997qla2x00_module_exit(void)
3998{
Harish Zunjarrao6a03b4c2010-05-04 15:01:24 -07003999 unregister_chrdev(apidev_major, QLA2XXX_APIDEV);
Andrew Vasquez7ee61392006-06-23 16:11:22 -07004000 pci_unregister_driver(&qla2xxx_pci_driver);
Andrew Vasquez54333832005-11-09 15:49:04 -08004001 qla2x00_release_firmware();
Andrew Vasquez 354d6b22005-04-23 02:47:27 -04004002 kmem_cache_destroy(srb_cachep);
Giridhar Malavalia9083012010-04-12 17:59:55 -07004003 if (ctx_cachep)
4004 kmem_cache_destroy(ctx_cachep);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004005 fc_release_transport(qla2xxx_transport_template);
Seokmann Ju2c3dfe32007-07-05 13:16:51 -07004006 fc_release_transport(qla2xxx_transport_vport_template);
Linus Torvalds1da177e2005-04-16 15:20:36 -07004007}
4008
4009module_init(qla2x00_module_init);
4010module_exit(qla2x00_module_exit);
4011
4012MODULE_AUTHOR("QLogic Corporation");
4013MODULE_DESCRIPTION("QLogic Fibre Channel HBA Driver");
4014MODULE_LICENSE("GPL");
4015MODULE_VERSION(QLA2XXX_VERSION);
Andrew Vasquezbb8ee492006-10-02 12:00:48 -07004016MODULE_FIRMWARE(FW_FILE_ISP21XX);
4017MODULE_FIRMWARE(FW_FILE_ISP22XX);
4018MODULE_FIRMWARE(FW_FILE_ISP2300);
4019MODULE_FIRMWARE(FW_FILE_ISP2322);
4020MODULE_FIRMWARE(FW_FILE_ISP24XX);
Andrew Vasquez61623fc2008-01-31 12:33:45 -08004021MODULE_FIRMWARE(FW_FILE_ISP25XX);