2 * QLogic iSCSI HBA Driver
3 * Copyright (c) 2003-2006 QLogic Corporation
5 * See LICENSE.qla4xxx for copyright and licensing details.
7 #include <linux/moduleparam.h>
8 #include <linux/slab.h>
10 #include <scsi/scsi_tcq.h>
11 #include <scsi/scsicam.h>
14 #include "ql4_version.h"
17 #include "ql4_inline.h"
22 static char qla4xxx_version_str
[40];
25 * SRB allocation cache
27 static struct kmem_cache
*srb_cachep
;
30 * Module parameter information and variables
32 int ql4xdiscoverywait
= 60;
33 module_param(ql4xdiscoverywait
, int, S_IRUGO
| S_IWUSR
);
34 MODULE_PARM_DESC(ql4xdiscoverywait
, "Discovery wait time");
36 int ql4xdontresethba
= 0;
37 module_param(ql4xdontresethba
, int, S_IRUGO
| S_IWUSR
);
38 MODULE_PARM_DESC(ql4xdontresethba
,
39 "Don't reset the HBA for driver recovery \n"
40 " 0 - It will reset HBA (Default)\n"
41 " 1 - It will NOT reset HBA");
43 int ql4xextended_error_logging
= 0; /* 0 = off, 1 = log errors */
44 module_param(ql4xextended_error_logging
, int, S_IRUGO
| S_IWUSR
);
45 MODULE_PARM_DESC(ql4xextended_error_logging
,
46 "Option to enable extended error logging, "
47 "Default is 0 - no logging, 1 - debug logging");
49 int ql4xenablemsix
= 1;
50 module_param(ql4xenablemsix
, int, S_IRUGO
|S_IWUSR
);
51 MODULE_PARM_DESC(ql4xenablemsix
,
52 "Set to enable MSI or MSI-X interrupt mechanism.\n"
53 " 0 = enable INTx interrupt mechanism.\n"
54 " 1 = enable MSI-X interrupt mechanism (Default).\n"
55 " 2 = enable MSI interrupt mechanism.");
57 #define QL4_DEF_QDEPTH 32
60 * SCSI host template entry points
62 static void qla4xxx_config_dma_addressing(struct scsi_qla_host
*ha
);
65 * iSCSI template entry points
67 static int qla4xxx_tgt_dscvr(struct Scsi_Host
*shost
,
68 enum iscsi_tgt_dscvr type
, uint32_t enable
,
69 struct sockaddr
*dst_addr
);
70 static int qla4xxx_conn_get_param(struct iscsi_cls_conn
*conn
,
71 enum iscsi_param param
, char *buf
);
72 static int qla4xxx_sess_get_param(struct iscsi_cls_session
*sess
,
73 enum iscsi_param param
, char *buf
);
74 static int qla4xxx_host_get_param(struct Scsi_Host
*shost
,
75 enum iscsi_host_param param
, char *buf
);
76 static void qla4xxx_recovery_timedout(struct iscsi_cls_session
*session
);
77 static enum blk_eh_timer_return
qla4xxx_eh_cmd_timed_out(struct scsi_cmnd
*sc
);
80 * SCSI host template entry points
82 static int qla4xxx_queuecommand(struct Scsi_Host
*h
, struct scsi_cmnd
*cmd
);
83 static int qla4xxx_eh_abort(struct scsi_cmnd
*cmd
);
84 static int qla4xxx_eh_device_reset(struct scsi_cmnd
*cmd
);
85 static int qla4xxx_eh_target_reset(struct scsi_cmnd
*cmd
);
86 static int qla4xxx_eh_host_reset(struct scsi_cmnd
*cmd
);
87 static int qla4xxx_slave_alloc(struct scsi_device
*device
);
88 static int qla4xxx_slave_configure(struct scsi_device
*device
);
89 static void qla4xxx_slave_destroy(struct scsi_device
*sdev
);
90 static void qla4xxx_scan_start(struct Scsi_Host
*shost
);
92 static struct qla4_8xxx_legacy_intr_set legacy_intr
[] =
93 QLA82XX_LEGACY_INTR_CONFIG
;
95 static struct scsi_host_template qla4xxx_driver_template
= {
96 .module
= THIS_MODULE
,
98 .proc_name
= DRIVER_NAME
,
99 .queuecommand
= qla4xxx_queuecommand
,
101 .eh_abort_handler
= qla4xxx_eh_abort
,
102 .eh_device_reset_handler
= qla4xxx_eh_device_reset
,
103 .eh_target_reset_handler
= qla4xxx_eh_target_reset
,
104 .eh_host_reset_handler
= qla4xxx_eh_host_reset
,
105 .eh_timed_out
= qla4xxx_eh_cmd_timed_out
,
107 .slave_configure
= qla4xxx_slave_configure
,
108 .slave_alloc
= qla4xxx_slave_alloc
,
109 .slave_destroy
= qla4xxx_slave_destroy
,
111 .scan_finished
= iscsi_scan_finished
,
112 .scan_start
= qla4xxx_scan_start
,
116 .use_clustering
= ENABLE_CLUSTERING
,
117 .sg_tablesize
= SG_ALL
,
119 .max_sectors
= 0xFFFF,
122 static struct iscsi_transport qla4xxx_iscsi_transport
= {
123 .owner
= THIS_MODULE
,
125 .caps
= CAP_FW_DB
| CAP_SENDTARGETS_OFFLOAD
|
126 CAP_DATA_PATH_OFFLOAD
,
127 .param_mask
= ISCSI_CONN_PORT
| ISCSI_CONN_ADDRESS
|
128 ISCSI_TARGET_NAME
| ISCSI_TPGT
|
130 .host_param_mask
= ISCSI_HOST_HWADDRESS
|
131 ISCSI_HOST_IPADDRESS
|
132 ISCSI_HOST_INITIATOR_NAME
,
133 .tgt_dscvr
= qla4xxx_tgt_dscvr
,
134 .get_conn_param
= qla4xxx_conn_get_param
,
135 .get_session_param
= qla4xxx_sess_get_param
,
136 .get_host_param
= qla4xxx_host_get_param
,
137 .session_recovery_timedout
= qla4xxx_recovery_timedout
,
140 static struct scsi_transport_template
*qla4xxx_scsi_transport
;
142 static enum blk_eh_timer_return
qla4xxx_eh_cmd_timed_out(struct scsi_cmnd
*sc
)
144 struct iscsi_cls_session
*session
;
145 struct ddb_entry
*ddb_entry
;
147 session
= starget_to_session(scsi_target(sc
->device
));
148 ddb_entry
= session
->dd_data
;
150 /* if we are not logged in then the LLD is going to clean up the cmd */
151 if (atomic_read(&ddb_entry
->state
) != DDB_STATE_ONLINE
)
152 return BLK_EH_RESET_TIMER
;
154 return BLK_EH_NOT_HANDLED
;
157 static void qla4xxx_recovery_timedout(struct iscsi_cls_session
*session
)
159 struct ddb_entry
*ddb_entry
= session
->dd_data
;
160 struct scsi_qla_host
*ha
= ddb_entry
->ha
;
162 if (atomic_read(&ddb_entry
->state
) != DDB_STATE_ONLINE
) {
163 atomic_set(&ddb_entry
->state
, DDB_STATE_DEAD
);
165 DEBUG2(printk("scsi%ld: %s: ddb [%d] session recovery timeout "
166 "of (%d) secs exhausted, marking device DEAD.\n",
167 ha
->host_no
, __func__
, ddb_entry
->fw_ddb_index
,
168 QL4_SESS_RECOVERY_TMO
));
172 static int qla4xxx_host_get_param(struct Scsi_Host
*shost
,
173 enum iscsi_host_param param
, char *buf
)
175 struct scsi_qla_host
*ha
= to_qla_host(shost
);
179 case ISCSI_HOST_PARAM_HWADDRESS
:
180 len
= sysfs_format_mac(buf
, ha
->my_mac
, MAC_ADDR_LEN
);
182 case ISCSI_HOST_PARAM_IPADDRESS
:
183 len
= sprintf(buf
, "%d.%d.%d.%d\n", ha
->ip_address
[0],
184 ha
->ip_address
[1], ha
->ip_address
[2],
187 case ISCSI_HOST_PARAM_INITIATOR_NAME
:
188 len
= sprintf(buf
, "%s\n", ha
->name_string
);
197 static int qla4xxx_sess_get_param(struct iscsi_cls_session
*sess
,
198 enum iscsi_param param
, char *buf
)
200 struct ddb_entry
*ddb_entry
= sess
->dd_data
;
204 case ISCSI_PARAM_TARGET_NAME
:
205 len
= snprintf(buf
, PAGE_SIZE
- 1, "%s\n",
206 ddb_entry
->iscsi_name
);
208 case ISCSI_PARAM_TPGT
:
209 len
= sprintf(buf
, "%u\n", ddb_entry
->tpgt
);
211 case ISCSI_PARAM_TARGET_ALIAS
:
212 len
= snprintf(buf
, PAGE_SIZE
- 1, "%s\n",
213 ddb_entry
->iscsi_alias
);
222 static int qla4xxx_conn_get_param(struct iscsi_cls_conn
*conn
,
223 enum iscsi_param param
, char *buf
)
225 struct iscsi_cls_session
*session
;
226 struct ddb_entry
*ddb_entry
;
229 session
= iscsi_dev_to_session(conn
->dev
.parent
);
230 ddb_entry
= session
->dd_data
;
233 case ISCSI_PARAM_CONN_PORT
:
234 len
= sprintf(buf
, "%hu\n", ddb_entry
->port
);
236 case ISCSI_PARAM_CONN_ADDRESS
:
237 /* TODO: what are the ipv6 bits */
238 len
= sprintf(buf
, "%pI4\n", &ddb_entry
->ip_addr
);
247 static int qla4xxx_tgt_dscvr(struct Scsi_Host
*shost
,
248 enum iscsi_tgt_dscvr type
, uint32_t enable
,
249 struct sockaddr
*dst_addr
)
251 struct scsi_qla_host
*ha
;
252 struct sockaddr_in
*addr
;
253 struct sockaddr_in6
*addr6
;
256 ha
= (struct scsi_qla_host
*) shost
->hostdata
;
259 case ISCSI_TGT_DSCVR_SEND_TARGETS
:
260 if (dst_addr
->sa_family
== AF_INET
) {
261 addr
= (struct sockaddr_in
*)dst_addr
;
262 if (qla4xxx_send_tgts(ha
, (char *)&addr
->sin_addr
,
263 addr
->sin_port
) != QLA_SUCCESS
)
265 } else if (dst_addr
->sa_family
== AF_INET6
) {
267 * TODO: fix qla4xxx_send_tgts
269 addr6
= (struct sockaddr_in6
*)dst_addr
;
270 if (qla4xxx_send_tgts(ha
, (char *)&addr6
->sin6_addr
,
271 addr6
->sin6_port
) != QLA_SUCCESS
)
282 void qla4xxx_destroy_sess(struct ddb_entry
*ddb_entry
)
284 if (!ddb_entry
->sess
)
287 if (ddb_entry
->conn
) {
288 atomic_set(&ddb_entry
->state
, DDB_STATE_DEAD
);
289 iscsi_remove_session(ddb_entry
->sess
);
291 iscsi_free_session(ddb_entry
->sess
);
294 int qla4xxx_add_sess(struct ddb_entry
*ddb_entry
)
298 ddb_entry
->sess
->recovery_tmo
= QL4_SESS_RECOVERY_TMO
;
300 err
= iscsi_add_session(ddb_entry
->sess
, ddb_entry
->fw_ddb_index
);
302 DEBUG2(printk(KERN_ERR
"Could not add session.\n"));
306 ddb_entry
->conn
= iscsi_create_conn(ddb_entry
->sess
, 0, 0);
307 if (!ddb_entry
->conn
) {
308 iscsi_remove_session(ddb_entry
->sess
);
309 DEBUG2(printk(KERN_ERR
"Could not add connection.\n"));
313 /* finally ready to go */
314 iscsi_unblock_session(ddb_entry
->sess
);
318 struct ddb_entry
*qla4xxx_alloc_sess(struct scsi_qla_host
*ha
)
320 struct ddb_entry
*ddb_entry
;
321 struct iscsi_cls_session
*sess
;
323 sess
= iscsi_alloc_session(ha
->host
, &qla4xxx_iscsi_transport
,
324 sizeof(struct ddb_entry
));
328 ddb_entry
= sess
->dd_data
;
329 memset(ddb_entry
, 0, sizeof(*ddb_entry
));
331 ddb_entry
->sess
= sess
;
335 static void qla4xxx_scan_start(struct Scsi_Host
*shost
)
337 struct scsi_qla_host
*ha
= shost_priv(shost
);
338 struct ddb_entry
*ddb_entry
, *ddbtemp
;
340 /* finish setup of sessions that were already setup in firmware */
341 list_for_each_entry_safe(ddb_entry
, ddbtemp
, &ha
->ddb_list
, list
) {
342 if (ddb_entry
->fw_ddb_device_state
== DDB_DS_SESSION_ACTIVE
)
343 qla4xxx_add_sess(ddb_entry
);
351 static void qla4xxx_start_timer(struct scsi_qla_host
*ha
, void *func
,
352 unsigned long interval
)
354 DEBUG(printk("scsi: %s: Starting timer thread for adapter %d\n",
355 __func__
, ha
->host
->host_no
));
356 init_timer(&ha
->timer
);
357 ha
->timer
.expires
= jiffies
+ interval
* HZ
;
358 ha
->timer
.data
= (unsigned long)ha
;
359 ha
->timer
.function
= (void (*)(unsigned long))func
;
360 add_timer(&ha
->timer
);
361 ha
->timer_active
= 1;
364 static void qla4xxx_stop_timer(struct scsi_qla_host
*ha
)
366 del_timer_sync(&ha
->timer
);
367 ha
->timer_active
= 0;
371 * qla4xxx_mark_device_missing - mark a device as missing.
372 * @ha: Pointer to host adapter structure.
373 * @ddb_entry: Pointer to device database entry
375 * This routine marks a device missing and close connection.
377 void qla4xxx_mark_device_missing(struct scsi_qla_host
*ha
,
378 struct ddb_entry
*ddb_entry
)
380 if ((atomic_read(&ddb_entry
->state
) != DDB_STATE_DEAD
)) {
381 atomic_set(&ddb_entry
->state
, DDB_STATE_MISSING
);
382 DEBUG2(printk("scsi%ld: ddb [%d] marked MISSING\n",
383 ha
->host_no
, ddb_entry
->fw_ddb_index
));
385 DEBUG2(printk("scsi%ld: ddb [%d] DEAD\n", ha
->host_no
,
386 ddb_entry
->fw_ddb_index
))
388 iscsi_block_session(ddb_entry
->sess
);
389 iscsi_conn_error_event(ddb_entry
->conn
, ISCSI_ERR_CONN_FAILED
);
393 * qla4xxx_mark_all_devices_missing - mark all devices as missing.
394 * @ha: Pointer to host adapter structure.
396 * This routine marks a device missing and resets the relogin retry count.
398 void qla4xxx_mark_all_devices_missing(struct scsi_qla_host
*ha
)
400 struct ddb_entry
*ddb_entry
, *ddbtemp
;
401 list_for_each_entry_safe(ddb_entry
, ddbtemp
, &ha
->ddb_list
, list
) {
402 qla4xxx_mark_device_missing(ha
, ddb_entry
);
406 static struct srb
* qla4xxx_get_new_srb(struct scsi_qla_host
*ha
,
407 struct ddb_entry
*ddb_entry
,
408 struct scsi_cmnd
*cmd
,
409 void (*done
)(struct scsi_cmnd
*))
413 srb
= mempool_alloc(ha
->srb_mempool
, GFP_ATOMIC
);
417 kref_init(&srb
->srb_ref
);
419 srb
->ddb
= ddb_entry
;
422 CMD_SP(cmd
) = (void *)srb
;
423 cmd
->scsi_done
= done
;
428 static void qla4xxx_srb_free_dma(struct scsi_qla_host
*ha
, struct srb
*srb
)
430 struct scsi_cmnd
*cmd
= srb
->cmd
;
432 if (srb
->flags
& SRB_DMA_VALID
) {
434 srb
->flags
&= ~SRB_DMA_VALID
;
439 void qla4xxx_srb_compl(struct kref
*ref
)
441 struct srb
*srb
= container_of(ref
, struct srb
, srb_ref
);
442 struct scsi_cmnd
*cmd
= srb
->cmd
;
443 struct scsi_qla_host
*ha
= srb
->ha
;
445 qla4xxx_srb_free_dma(ha
, srb
);
447 mempool_free(srb
, ha
->srb_mempool
);
453 * qla4xxx_queuecommand - scsi layer issues scsi command to driver.
454 * @cmd: Pointer to Linux's SCSI command structure
455 * @done_fn: Function that the driver calls to notify the SCSI mid-layer
456 * that the command has been processed.
459 * This routine is invoked by Linux to send a SCSI command to the driver.
460 * The mid-level driver tries to ensure that queuecommand never gets
461 * invoked concurrently with itself or the interrupt handler (although
462 * the interrupt handler may call this routine as part of request-
463 * completion handling). Unfortunely, it sometimes calls the scheduler
464 * in interrupt context which is a big NO! NO!.
466 static int qla4xxx_queuecommand_lck(struct scsi_cmnd
*cmd
,
467 void (*done
)(struct scsi_cmnd
*))
469 struct scsi_qla_host
*ha
= to_qla_host(cmd
->device
->host
);
470 struct ddb_entry
*ddb_entry
= cmd
->device
->hostdata
;
471 struct iscsi_cls_session
*sess
= ddb_entry
->sess
;
475 if (test_bit(AF_EEH_BUSY
, &ha
->flags
)) {
476 if (test_bit(AF_PCI_CHANNEL_IO_PERM_FAILURE
, &ha
->flags
))
477 cmd
->result
= DID_NO_CONNECT
<< 16;
479 cmd
->result
= DID_REQUEUE
<< 16;
480 goto qc_fail_command
;
484 cmd
->result
= DID_IMM_RETRY
<< 16;
485 goto qc_fail_command
;
488 rval
= iscsi_session_chkready(sess
);
491 goto qc_fail_command
;
494 if (atomic_read(&ddb_entry
->state
) != DDB_STATE_ONLINE
) {
495 if (atomic_read(&ddb_entry
->state
) == DDB_STATE_DEAD
) {
496 cmd
->result
= DID_NO_CONNECT
<< 16;
497 goto qc_fail_command
;
499 return SCSI_MLQUEUE_TARGET_BUSY
;
502 if (test_bit(DPC_RESET_HA_INTR
, &ha
->dpc_flags
) ||
503 test_bit(DPC_RESET_ACTIVE
, &ha
->dpc_flags
) ||
504 test_bit(DPC_RESET_HA
, &ha
->dpc_flags
) ||
505 test_bit(DPC_HA_UNRECOVERABLE
, &ha
->dpc_flags
) ||
506 test_bit(DPC_HA_NEED_QUIESCENT
, &ha
->dpc_flags
) ||
507 !test_bit(AF_ONLINE
, &ha
->flags
) ||
508 test_bit(DPC_RESET_HA_FW_CONTEXT
, &ha
->dpc_flags
))
511 spin_unlock_irq(ha
->host
->host_lock
);
513 srb
= qla4xxx_get_new_srb(ha
, ddb_entry
, cmd
, done
);
515 goto qc_host_busy_lock
;
517 rval
= qla4xxx_send_command_to_isp(ha
, srb
);
518 if (rval
!= QLA_SUCCESS
)
519 goto qc_host_busy_free_sp
;
521 spin_lock_irq(ha
->host
->host_lock
);
524 qc_host_busy_free_sp
:
525 qla4xxx_srb_free_dma(ha
, srb
);
526 mempool_free(srb
, ha
->srb_mempool
);
529 spin_lock_irq(ha
->host
->host_lock
);
532 return SCSI_MLQUEUE_HOST_BUSY
;
540 static DEF_SCSI_QCMD(qla4xxx_queuecommand
)
543 * qla4xxx_mem_free - frees memory allocated to adapter
544 * @ha: Pointer to host adapter structure.
546 * Frees memory previously allocated by qla4xxx_mem_alloc
548 static void qla4xxx_mem_free(struct scsi_qla_host
*ha
)
551 dma_free_coherent(&ha
->pdev
->dev
, ha
->queues_len
, ha
->queues
,
557 ha
->request_ring
= NULL
;
559 ha
->response_ring
= NULL
;
560 ha
->response_dma
= 0;
561 ha
->shadow_regs
= NULL
;
562 ha
->shadow_regs_dma
= 0;
566 mempool_destroy(ha
->srb_mempool
);
568 ha
->srb_mempool
= NULL
;
570 /* release io space registers */
571 if (is_qla8022(ha
)) {
574 (struct device_reg_82xx __iomem
*)ha
->nx_pcibase
);
577 pci_release_regions(ha
->pdev
);
581 * qla4xxx_mem_alloc - allocates memory for use by adapter.
582 * @ha: Pointer to host adapter structure
584 * Allocates DMA memory for request and response queues. Also allocates memory
587 static int qla4xxx_mem_alloc(struct scsi_qla_host
*ha
)
591 /* Allocate contiguous block of DMA memory for queues. */
592 ha
->queues_len
= ((REQUEST_QUEUE_DEPTH
* QUEUE_SIZE
) +
593 (RESPONSE_QUEUE_DEPTH
* QUEUE_SIZE
) +
594 sizeof(struct shadow_regs
) +
596 (PAGE_SIZE
- 1)) & ~(PAGE_SIZE
- 1);
597 ha
->queues
= dma_alloc_coherent(&ha
->pdev
->dev
, ha
->queues_len
,
598 &ha
->queues_dma
, GFP_KERNEL
);
599 if (ha
->queues
== NULL
) {
600 ql4_printk(KERN_WARNING
, ha
,
601 "Memory Allocation failed - queues.\n");
603 goto mem_alloc_error_exit
;
605 memset(ha
->queues
, 0, ha
->queues_len
);
608 * As per RISC alignment requirements -- the bus-address must be a
609 * multiple of the request-ring size (in bytes).
612 if ((unsigned long)ha
->queues_dma
& (MEM_ALIGN_VALUE
- 1))
613 align
= MEM_ALIGN_VALUE
- ((unsigned long)ha
->queues_dma
&
614 (MEM_ALIGN_VALUE
- 1));
616 /* Update request and response queue pointers. */
617 ha
->request_dma
= ha
->queues_dma
+ align
;
618 ha
->request_ring
= (struct queue_entry
*) (ha
->queues
+ align
);
619 ha
->response_dma
= ha
->queues_dma
+ align
+
620 (REQUEST_QUEUE_DEPTH
* QUEUE_SIZE
);
621 ha
->response_ring
= (struct queue_entry
*) (ha
->queues
+ align
+
622 (REQUEST_QUEUE_DEPTH
*
624 ha
->shadow_regs_dma
= ha
->queues_dma
+ align
+
625 (REQUEST_QUEUE_DEPTH
* QUEUE_SIZE
) +
626 (RESPONSE_QUEUE_DEPTH
* QUEUE_SIZE
);
627 ha
->shadow_regs
= (struct shadow_regs
*) (ha
->queues
+ align
+
628 (REQUEST_QUEUE_DEPTH
*
630 (RESPONSE_QUEUE_DEPTH
*
633 /* Allocate memory for srb pool. */
634 ha
->srb_mempool
= mempool_create(SRB_MIN_REQ
, mempool_alloc_slab
,
635 mempool_free_slab
, srb_cachep
);
636 if (ha
->srb_mempool
== NULL
) {
637 ql4_printk(KERN_WARNING
, ha
,
638 "Memory Allocation failed - SRB Pool.\n");
640 goto mem_alloc_error_exit
;
645 mem_alloc_error_exit
:
646 qla4xxx_mem_free(ha
);
651 * qla4_8xxx_check_fw_alive - Check firmware health
652 * @ha: Pointer to host adapter structure.
656 static void qla4_8xxx_check_fw_alive(struct scsi_qla_host
*ha
)
658 uint32_t fw_heartbeat_counter
, halt_status
;
660 fw_heartbeat_counter
= qla4_8xxx_rd_32(ha
, QLA82XX_PEG_ALIVE_COUNTER
);
661 /* If PEG_ALIVE_COUNTER is 0xffffffff, AER/EEH is in progress, ignore */
662 if (fw_heartbeat_counter
== 0xffffffff) {
663 DEBUG2(printk(KERN_WARNING
"scsi%ld: %s: Device in frozen "
664 "state, QLA82XX_PEG_ALIVE_COUNTER is 0xffffffff\n",
665 ha
->host_no
, __func__
));
669 if (ha
->fw_heartbeat_counter
== fw_heartbeat_counter
) {
670 ha
->seconds_since_last_heartbeat
++;
671 /* FW not alive after 2 seconds */
672 if (ha
->seconds_since_last_heartbeat
== 2) {
673 ha
->seconds_since_last_heartbeat
= 0;
674 halt_status
= qla4_8xxx_rd_32(ha
,
675 QLA82XX_PEG_HALT_STATUS1
);
677 /* Since we cannot change dev_state in interrupt
678 * context, set appropriate DPC flag then wakeup
680 if (halt_status
& HALT_STATUS_UNRECOVERABLE
)
681 set_bit(DPC_HA_UNRECOVERABLE
, &ha
->dpc_flags
);
683 printk("scsi%ld: %s: detect abort needed!\n",
684 ha
->host_no
, __func__
);
685 set_bit(DPC_RESET_HA
, &ha
->dpc_flags
);
687 qla4xxx_wake_dpc(ha
);
688 qla4xxx_mailbox_premature_completion(ha
);
691 ha
->seconds_since_last_heartbeat
= 0;
693 ha
->fw_heartbeat_counter
= fw_heartbeat_counter
;
697 * qla4_8xxx_watchdog - Poll dev state
698 * @ha: Pointer to host adapter structure.
702 void qla4_8xxx_watchdog(struct scsi_qla_host
*ha
)
706 dev_state
= qla4_8xxx_rd_32(ha
, QLA82XX_CRB_DEV_STATE
);
708 /* don't poll if reset is going on */
709 if (!test_bit(DPC_RESET_ACTIVE
, &ha
->dpc_flags
)) {
710 if (dev_state
== QLA82XX_DEV_NEED_RESET
&&
711 !test_bit(DPC_RESET_HA
, &ha
->dpc_flags
)) {
712 printk("scsi%ld: %s: HW State: NEED RESET!\n",
713 ha
->host_no
, __func__
);
714 set_bit(DPC_RESET_HA
, &ha
->dpc_flags
);
715 qla4xxx_wake_dpc(ha
);
716 qla4xxx_mailbox_premature_completion(ha
);
717 } else if (dev_state
== QLA82XX_DEV_NEED_QUIESCENT
&&
718 !test_bit(DPC_HA_NEED_QUIESCENT
, &ha
->dpc_flags
)) {
719 printk("scsi%ld: %s: HW State: NEED QUIES!\n",
720 ha
->host_no
, __func__
);
721 set_bit(DPC_HA_NEED_QUIESCENT
, &ha
->dpc_flags
);
722 qla4xxx_wake_dpc(ha
);
724 /* Check firmware health */
725 qla4_8xxx_check_fw_alive(ha
);
731 * qla4xxx_timer - checks every second for work to do.
732 * @ha: Pointer to host adapter structure.
734 static void qla4xxx_timer(struct scsi_qla_host
*ha
)
736 struct ddb_entry
*ddb_entry
, *dtemp
;
740 /* If we are in the middle of AER/EEH processing
741 * skip any processing and reschedule the timer
743 if (test_bit(AF_EEH_BUSY
, &ha
->flags
)) {
744 mod_timer(&ha
->timer
, jiffies
+ HZ
);
748 /* Hardware read to trigger an EEH error during mailbox waits. */
749 if (!pci_channel_offline(ha
->pdev
))
750 pci_read_config_word(ha
->pdev
, PCI_VENDOR_ID
, &w
);
752 if (test_bit(AF_HBA_GOING_AWAY
, &ha
->flags
)) {
753 DEBUG2(ql4_printk(KERN_INFO
, ha
, "%s exited. HBA GOING AWAY\n",
758 if (is_qla8022(ha
)) {
759 qla4_8xxx_watchdog(ha
);
762 /* Search for relogin's to time-out and port down retry. */
763 list_for_each_entry_safe(ddb_entry
, dtemp
, &ha
->ddb_list
, list
) {
764 /* Count down time between sending relogins */
765 if (adapter_up(ha
) &&
766 !test_bit(DF_RELOGIN
, &ddb_entry
->flags
) &&
767 atomic_read(&ddb_entry
->state
) != DDB_STATE_ONLINE
) {
768 if (atomic_read(&ddb_entry
->retry_relogin_timer
) !=
770 if (atomic_read(&ddb_entry
->retry_relogin_timer
)
772 atomic_set(&ddb_entry
->
775 set_bit(DPC_RELOGIN_DEVICE
,
777 set_bit(DF_RELOGIN
, &ddb_entry
->flags
);
778 DEBUG2(printk("scsi%ld: %s: ddb [%d]"
780 ha
->host_no
, __func__
,
781 ddb_entry
->fw_ddb_index
));
783 atomic_dec(&ddb_entry
->
784 retry_relogin_timer
);
788 /* Wait for relogin to timeout */
789 if (atomic_read(&ddb_entry
->relogin_timer
) &&
790 (atomic_dec_and_test(&ddb_entry
->relogin_timer
) != 0)) {
792 * If the relogin times out and the device is
793 * still NOT ONLINE then try and relogin again.
795 if (atomic_read(&ddb_entry
->state
) !=
797 ddb_entry
->fw_ddb_device_state
==
798 DDB_DS_SESSION_FAILED
) {
799 /* Reset retry relogin timer */
800 atomic_inc(&ddb_entry
->relogin_retry_count
);
801 DEBUG2(printk("scsi%ld: ddb [%d] relogin"
802 " timed out-retrying"
805 ddb_entry
->fw_ddb_index
,
806 atomic_read(&ddb_entry
->
807 relogin_retry_count
))
810 DEBUG(printk("scsi%ld:%d:%d: ddb [%d] "
811 "initate relogin after"
813 ha
->host_no
, ddb_entry
->bus
,
815 ddb_entry
->fw_ddb_index
,
816 ddb_entry
->default_time2wait
+ 4)
819 atomic_set(&ddb_entry
->retry_relogin_timer
,
820 ddb_entry
->default_time2wait
+ 4);
825 if (!is_qla8022(ha
)) {
826 /* Check for heartbeat interval. */
827 if (ha
->firmware_options
& FWOPT_HEARTBEAT_ENABLE
&&
828 ha
->heartbeat_interval
!= 0) {
829 ha
->seconds_since_last_heartbeat
++;
830 if (ha
->seconds_since_last_heartbeat
>
831 ha
->heartbeat_interval
+ 2)
832 set_bit(DPC_RESET_HA
, &ha
->dpc_flags
);
836 /* Wakeup the dpc routine for this adapter, if needed. */
838 test_bit(DPC_RESET_HA
, &ha
->dpc_flags
) ||
839 test_bit(DPC_RETRY_RESET_HA
, &ha
->dpc_flags
) ||
840 test_bit(DPC_RELOGIN_DEVICE
, &ha
->dpc_flags
) ||
841 test_bit(DPC_RESET_HA_FW_CONTEXT
, &ha
->dpc_flags
) ||
842 test_bit(DPC_RESET_HA_INTR
, &ha
->dpc_flags
) ||
843 test_bit(DPC_GET_DHCP_IP_ADDR
, &ha
->dpc_flags
) ||
844 test_bit(DPC_LINK_CHANGED
, &ha
->dpc_flags
) ||
845 test_bit(DPC_HA_UNRECOVERABLE
, &ha
->dpc_flags
) ||
846 test_bit(DPC_HA_NEED_QUIESCENT
, &ha
->dpc_flags
) ||
847 test_bit(DPC_AEN
, &ha
->dpc_flags
)) &&
848 !test_bit(AF_DPC_SCHEDULED
, &ha
->flags
) &&
850 DEBUG2(printk("scsi%ld: %s: scheduling dpc routine"
851 " - dpc flags = 0x%lx\n",
852 ha
->host_no
, __func__
, ha
->dpc_flags
));
853 qla4xxx_wake_dpc(ha
);
856 /* Reschedule timer thread to call us back in one second */
857 mod_timer(&ha
->timer
, jiffies
+ HZ
);
859 DEBUG2(ha
->seconds_since_last_intr
++);
863 * qla4xxx_cmd_wait - waits for all outstanding commands to complete
864 * @ha: Pointer to host adapter structure.
866 * This routine stalls the driver until all outstanding commands are returned.
867 * Caller must release the Hardware Lock prior to calling this routine.
869 static int qla4xxx_cmd_wait(struct scsi_qla_host
*ha
)
873 struct scsi_cmnd
*cmd
;
875 unsigned long wtime
= jiffies
+ (WAIT_CMD_TOV
* HZ
);
877 DEBUG2(ql4_printk(KERN_INFO
, ha
, "Wait up to %d seconds for cmds to "
878 "complete\n", WAIT_CMD_TOV
));
880 while (!time_after_eq(jiffies
, wtime
)) {
881 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
882 /* Find a command that hasn't completed. */
883 for (index
= 0; index
< ha
->host
->can_queue
; index
++) {
884 cmd
= scsi_host_find_tag(ha
->host
, index
);
886 * We cannot just check if the index is valid,
887 * becase if we are run from the scsi eh, then
888 * the scsi/block layer is going to prevent
889 * the tag from being released.
891 if (cmd
!= NULL
&& CMD_SP(cmd
))
894 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
896 /* If No Commands are pending, wait is complete */
897 if (index
== ha
->host
->can_queue
)
902 /* If we timed out on waiting for commands to come back
907 int qla4xxx_hw_reset(struct scsi_qla_host
*ha
)
909 uint32_t ctrl_status
;
910 unsigned long flags
= 0;
912 DEBUG2(printk(KERN_ERR
"scsi%ld: %s\n", ha
->host_no
, __func__
));
914 if (ql4xxx_lock_drvr_wait(ha
) != QLA_SUCCESS
)
917 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
920 * If the SCSI Reset Interrupt bit is set, clear it.
921 * Otherwise, the Soft Reset won't work.
923 ctrl_status
= readw(&ha
->reg
->ctrl_status
);
924 if ((ctrl_status
& CSR_SCSI_RESET_INTR
) != 0)
925 writel(set_rmask(CSR_SCSI_RESET_INTR
), &ha
->reg
->ctrl_status
);
927 /* Issue Soft Reset */
928 writel(set_rmask(CSR_SOFT_RESET
), &ha
->reg
->ctrl_status
);
929 readl(&ha
->reg
->ctrl_status
);
931 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
936 * qla4xxx_soft_reset - performs soft reset.
937 * @ha: Pointer to host adapter structure.
939 int qla4xxx_soft_reset(struct scsi_qla_host
*ha
)
941 uint32_t max_wait_time
;
942 unsigned long flags
= 0;
944 uint32_t ctrl_status
;
946 status
= qla4xxx_hw_reset(ha
);
947 if (status
!= QLA_SUCCESS
)
951 /* Wait until the Network Reset Intr bit is cleared */
952 max_wait_time
= RESET_INTR_TOV
;
954 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
955 ctrl_status
= readw(&ha
->reg
->ctrl_status
);
956 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
958 if ((ctrl_status
& CSR_NET_RESET_INTR
) == 0)
962 } while ((--max_wait_time
));
964 if ((ctrl_status
& CSR_NET_RESET_INTR
) != 0) {
965 DEBUG2(printk(KERN_WARNING
966 "scsi%ld: Network Reset Intr not cleared by "
967 "Network function, clearing it now!\n",
969 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
970 writel(set_rmask(CSR_NET_RESET_INTR
), &ha
->reg
->ctrl_status
);
971 readl(&ha
->reg
->ctrl_status
);
972 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
975 /* Wait until the firmware tells us the Soft Reset is done */
976 max_wait_time
= SOFT_RESET_TOV
;
978 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
979 ctrl_status
= readw(&ha
->reg
->ctrl_status
);
980 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
982 if ((ctrl_status
& CSR_SOFT_RESET
) == 0) {
983 status
= QLA_SUCCESS
;
988 } while ((--max_wait_time
));
991 * Also, make sure that the SCSI Reset Interrupt bit has been cleared
992 * after the soft reset has taken place.
994 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
995 ctrl_status
= readw(&ha
->reg
->ctrl_status
);
996 if ((ctrl_status
& CSR_SCSI_RESET_INTR
) != 0) {
997 writel(set_rmask(CSR_SCSI_RESET_INTR
), &ha
->reg
->ctrl_status
);
998 readl(&ha
->reg
->ctrl_status
);
1000 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
1002 /* If soft reset fails then most probably the bios on other
1003 * function is also enabled.
1004 * Since the initialization is sequential the other fn
1005 * wont be able to acknowledge the soft reset.
1006 * Issue a force soft reset to workaround this scenario.
1008 if (max_wait_time
== 0) {
1009 /* Issue Force Soft Reset */
1010 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
1011 writel(set_rmask(CSR_FORCE_SOFT_RESET
), &ha
->reg
->ctrl_status
);
1012 readl(&ha
->reg
->ctrl_status
);
1013 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
1014 /* Wait until the firmware tells us the Soft Reset is done */
1015 max_wait_time
= SOFT_RESET_TOV
;
1017 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
1018 ctrl_status
= readw(&ha
->reg
->ctrl_status
);
1019 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
1021 if ((ctrl_status
& CSR_FORCE_SOFT_RESET
) == 0) {
1022 status
= QLA_SUCCESS
;
1027 } while ((--max_wait_time
));
1034 * qla4xxx_abort_active_cmds - returns all outstanding i/o requests to O.S.
1035 * @ha: Pointer to host adapter structure.
1036 * @res: returned scsi status
1038 * This routine is called just prior to a HARD RESET to return all
1039 * outstanding commands back to the Operating System.
1040 * Caller should make sure that the following locks are released
1041 * before this calling routine: Hardware lock, and io_request_lock.
1043 static void qla4xxx_abort_active_cmds(struct scsi_qla_host
*ha
, int res
)
1047 unsigned long flags
;
1049 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
1050 for (i
= 0; i
< ha
->host
->can_queue
; i
++) {
1051 srb
= qla4xxx_del_from_active_array(ha
, i
);
1053 srb
->cmd
->result
= res
;
1054 kref_put(&srb
->srb_ref
, qla4xxx_srb_compl
);
1057 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
1060 void qla4xxx_dead_adapter_cleanup(struct scsi_qla_host
*ha
)
1062 clear_bit(AF_ONLINE
, &ha
->flags
);
1064 /* Disable the board */
1065 ql4_printk(KERN_INFO
, ha
, "Disabling the board\n");
1066 set_bit(AF_HBA_GOING_AWAY
, &ha
->flags
);
1068 qla4xxx_abort_active_cmds(ha
, DID_NO_CONNECT
<< 16);
1069 qla4xxx_mark_all_devices_missing(ha
);
1070 clear_bit(AF_INIT_DONE
, &ha
->flags
);
1074 * qla4xxx_recover_adapter - recovers adapter after a fatal error
1075 * @ha: Pointer to host adapter structure.
1077 static int qla4xxx_recover_adapter(struct scsi_qla_host
*ha
)
1079 int status
= QLA_ERROR
;
1080 uint8_t reset_chip
= 0;
1082 /* Stall incoming I/O until we are done */
1083 scsi_block_requests(ha
->host
);
1084 clear_bit(AF_ONLINE
, &ha
->flags
);
1086 DEBUG2(ql4_printk(KERN_INFO
, ha
, "%s: adapter OFFLINE\n", __func__
));
1088 set_bit(DPC_RESET_ACTIVE
, &ha
->dpc_flags
);
1090 if (test_bit(DPC_RESET_HA
, &ha
->dpc_flags
))
1093 /* For the DPC_RESET_HA_INTR case (ISP-4xxx specific)
1094 * do not reset adapter, jump to initialize_adapter */
1095 if (test_bit(DPC_RESET_HA_INTR
, &ha
->dpc_flags
)) {
1096 status
= QLA_SUCCESS
;
1097 goto recover_ha_init_adapter
;
1100 /* For the ISP-82xx adapter, issue a stop_firmware if invoked
1101 * from eh_host_reset or ioctl module */
1102 if (is_qla8022(ha
) && !reset_chip
&&
1103 test_bit(DPC_RESET_HA_FW_CONTEXT
, &ha
->dpc_flags
)) {
1105 DEBUG2(ql4_printk(KERN_INFO
, ha
,
1106 "scsi%ld: %s - Performing stop_firmware...\n",
1107 ha
->host_no
, __func__
));
1108 status
= ha
->isp_ops
->reset_firmware(ha
);
1109 if (status
== QLA_SUCCESS
) {
1110 if (!test_bit(AF_FW_RECOVERY
, &ha
->flags
))
1111 qla4xxx_cmd_wait(ha
);
1112 ha
->isp_ops
->disable_intrs(ha
);
1113 qla4xxx_process_aen(ha
, FLUSH_DDB_CHANGED_AENS
);
1114 qla4xxx_abort_active_cmds(ha
, DID_RESET
<< 16);
1116 /* If the stop_firmware fails then
1117 * reset the entire chip */
1119 clear_bit(DPC_RESET_HA_FW_CONTEXT
, &ha
->dpc_flags
);
1120 set_bit(DPC_RESET_HA
, &ha
->dpc_flags
);
1124 /* Issue full chip reset if recovering from a catastrophic error,
1125 * or if stop_firmware fails for ISP-82xx.
1126 * This is the default case for ISP-4xxx */
1127 if (!is_qla8022(ha
) || reset_chip
) {
1128 if (!test_bit(AF_FW_RECOVERY
, &ha
->flags
))
1129 qla4xxx_cmd_wait(ha
);
1130 qla4xxx_process_aen(ha
, FLUSH_DDB_CHANGED_AENS
);
1131 qla4xxx_abort_active_cmds(ha
, DID_RESET
<< 16);
1132 DEBUG2(ql4_printk(KERN_INFO
, ha
,
1133 "scsi%ld: %s - Performing chip reset..\n",
1134 ha
->host_no
, __func__
));
1135 status
= ha
->isp_ops
->reset_chip(ha
);
1138 /* Flush any pending ddb changed AENs */
1139 qla4xxx_process_aen(ha
, FLUSH_DDB_CHANGED_AENS
);
1141 recover_ha_init_adapter
:
1142 /* Upon successful firmware/chip reset, re-initialize the adapter */
1143 if (status
== QLA_SUCCESS
) {
1144 /* For ISP-4xxx, force function 1 to always initialize
1145 * before function 3 to prevent both funcions from
1146 * stepping on top of the other */
1147 if (!is_qla8022(ha
) && (ha
->mac_index
== 3))
1150 /* NOTE: AF_ONLINE flag set upon successful completion of
1151 * qla4xxx_initialize_adapter */
1152 status
= qla4xxx_initialize_adapter(ha
, PRESERVE_DDB_LIST
);
1155 /* Retry failed adapter initialization, if necessary
1156 * Do not retry initialize_adapter for RESET_HA_INTR (ISP-4xxx specific)
1157 * case to prevent ping-pong resets between functions */
1158 if (!test_bit(AF_ONLINE
, &ha
->flags
) &&
1159 !test_bit(DPC_RESET_HA_INTR
, &ha
->dpc_flags
)) {
1160 /* Adapter initialization failed, see if we can retry
1162 * Since we don't want to block the DPC for too long
1163 * with multiple resets in the same thread,
1164 * utilize DPC to retry */
1165 if (!test_bit(DPC_RETRY_RESET_HA
, &ha
->dpc_flags
)) {
1166 ha
->retry_reset_ha_cnt
= MAX_RESET_HA_RETRIES
;
1167 DEBUG2(printk("scsi%ld: recover adapter - retrying "
1168 "(%d) more times\n", ha
->host_no
,
1169 ha
->retry_reset_ha_cnt
));
1170 set_bit(DPC_RETRY_RESET_HA
, &ha
->dpc_flags
);
1173 if (ha
->retry_reset_ha_cnt
> 0) {
1174 /* Schedule another Reset HA--DPC will retry */
1175 ha
->retry_reset_ha_cnt
--;
1176 DEBUG2(printk("scsi%ld: recover adapter - "
1177 "retry remaining %d\n",
1179 ha
->retry_reset_ha_cnt
));
1183 if (ha
->retry_reset_ha_cnt
== 0) {
1184 /* Recover adapter retries have been exhausted.
1186 DEBUG2(printk("scsi%ld: recover adapter "
1187 "failed - board disabled\n",
1189 qla4xxx_dead_adapter_cleanup(ha
);
1190 clear_bit(DPC_RETRY_RESET_HA
, &ha
->dpc_flags
);
1191 clear_bit(DPC_RESET_HA
, &ha
->dpc_flags
);
1192 clear_bit(DPC_RESET_HA_FW_CONTEXT
,
1198 clear_bit(DPC_RESET_HA
, &ha
->dpc_flags
);
1199 clear_bit(DPC_RESET_HA_FW_CONTEXT
, &ha
->dpc_flags
);
1200 clear_bit(DPC_RETRY_RESET_HA
, &ha
->dpc_flags
);
1203 ha
->adapter_error_count
++;
1205 if (test_bit(AF_ONLINE
, &ha
->flags
))
1206 ha
->isp_ops
->enable_intrs(ha
);
1208 scsi_unblock_requests(ha
->host
);
1210 clear_bit(DPC_RESET_ACTIVE
, &ha
->dpc_flags
);
1211 DEBUG2(printk("scsi%ld: recover adapter: %s\n", ha
->host_no
,
1212 status
== QLA_ERROR
? "FAILED" : "SUCCEDED"));
1217 void qla4xxx_wake_dpc(struct scsi_qla_host
*ha
)
1219 if (ha
->dpc_thread
&&
1220 !test_bit(AF_DPC_SCHEDULED
, &ha
->flags
)) {
1221 set_bit(AF_DPC_SCHEDULED
, &ha
->flags
);
1222 queue_work(ha
->dpc_thread
, &ha
->dpc_work
);
1227 * qla4xxx_do_dpc - dpc routine
1228 * @data: in our case pointer to adapter structure
1230 * This routine is a task that is schedule by the interrupt handler
1231 * to perform the background processing for interrupts. We put it
1232 * on a task queue that is consumed whenever the scheduler runs; that's
1233 * so you can do anything (i.e. put the process to sleep etc). In fact,
1234 * the mid-level tries to sleep when it reaches the driver threshold
1235 * "host->can_queue". This can cause a panic if we were in our interrupt code.
1237 static void qla4xxx_do_dpc(struct work_struct
*work
)
1239 struct scsi_qla_host
*ha
=
1240 container_of(work
, struct scsi_qla_host
, dpc_work
);
1241 struct ddb_entry
*ddb_entry
, *dtemp
;
1242 int status
= QLA_ERROR
;
1244 DEBUG2(printk("scsi%ld: %s: DPC handler waking up."
1245 "flags = 0x%08lx, dpc_flags = 0x%08lx\n",
1246 ha
->host_no
, __func__
, ha
->flags
, ha
->dpc_flags
))
1248 /* Initialization not yet finished. Don't do anything yet. */
1249 if (!test_bit(AF_INIT_DONE
, &ha
->flags
))
1252 if (test_bit(AF_EEH_BUSY
, &ha
->flags
)) {
1253 DEBUG2(printk(KERN_INFO
"scsi%ld: %s: flags = %lx\n",
1254 ha
->host_no
, __func__
, ha
->flags
));
1258 /* HBA is in the process of being permanently disabled.
1259 * Don't process anything */
1260 if (test_bit(AF_HBA_GOING_AWAY
, &ha
->flags
))
1263 if (is_qla8022(ha
)) {
1264 if (test_bit(DPC_HA_UNRECOVERABLE
, &ha
->dpc_flags
)) {
1265 qla4_8xxx_idc_lock(ha
);
1266 qla4_8xxx_wr_32(ha
, QLA82XX_CRB_DEV_STATE
,
1267 QLA82XX_DEV_FAILED
);
1268 qla4_8xxx_idc_unlock(ha
);
1269 ql4_printk(KERN_INFO
, ha
, "HW State: FAILED\n");
1270 qla4_8xxx_device_state_handler(ha
);
1272 if (test_and_clear_bit(DPC_HA_NEED_QUIESCENT
, &ha
->dpc_flags
)) {
1273 qla4_8xxx_need_qsnt_handler(ha
);
1277 if (!test_bit(DPC_RESET_ACTIVE
, &ha
->dpc_flags
) &&
1278 (test_bit(DPC_RESET_HA
, &ha
->dpc_flags
) ||
1279 test_bit(DPC_RESET_HA_INTR
, &ha
->dpc_flags
) ||
1280 test_bit(DPC_RESET_HA_FW_CONTEXT
, &ha
->dpc_flags
))) {
1281 if (ql4xdontresethba
) {
1282 DEBUG2(printk("scsi%ld: %s: Don't Reset HBA\n",
1283 ha
->host_no
, __func__
));
1284 clear_bit(DPC_RESET_HA
, &ha
->dpc_flags
);
1285 clear_bit(DPC_RESET_HA_INTR
, &ha
->dpc_flags
);
1286 clear_bit(DPC_RESET_HA_FW_CONTEXT
, &ha
->dpc_flags
);
1287 goto dpc_post_reset_ha
;
1289 if (test_bit(DPC_RESET_HA_FW_CONTEXT
, &ha
->dpc_flags
) ||
1290 test_bit(DPC_RESET_HA
, &ha
->dpc_flags
))
1291 qla4xxx_recover_adapter(ha
);
1293 if (test_bit(DPC_RESET_HA_INTR
, &ha
->dpc_flags
)) {
1294 uint8_t wait_time
= RESET_INTR_TOV
;
1296 while ((readw(&ha
->reg
->ctrl_status
) &
1297 (CSR_SOFT_RESET
| CSR_FORCE_SOFT_RESET
)) != 0) {
1298 if (--wait_time
== 0)
1303 DEBUG2(printk("scsi%ld: %s: SR|FSR "
1304 "bit not cleared-- resetting\n",
1305 ha
->host_no
, __func__
));
1306 qla4xxx_abort_active_cmds(ha
, DID_RESET
<< 16);
1307 if (ql4xxx_lock_drvr_wait(ha
) == QLA_SUCCESS
) {
1308 qla4xxx_process_aen(ha
, FLUSH_DDB_CHANGED_AENS
);
1309 status
= qla4xxx_recover_adapter(ha
);
1311 clear_bit(DPC_RESET_HA_INTR
, &ha
->dpc_flags
);
1312 if (status
== QLA_SUCCESS
)
1313 ha
->isp_ops
->enable_intrs(ha
);
1318 /* ---- process AEN? --- */
1319 if (test_and_clear_bit(DPC_AEN
, &ha
->dpc_flags
))
1320 qla4xxx_process_aen(ha
, PROCESS_ALL_AENS
);
1322 /* ---- Get DHCP IP Address? --- */
1323 if (test_and_clear_bit(DPC_GET_DHCP_IP_ADDR
, &ha
->dpc_flags
))
1324 qla4xxx_get_dhcp_ip_address(ha
);
1326 /* ---- link change? --- */
1327 if (test_and_clear_bit(DPC_LINK_CHANGED
, &ha
->dpc_flags
)) {
1328 if (!test_bit(AF_LINK_UP
, &ha
->flags
)) {
1329 /* ---- link down? --- */
1330 list_for_each_entry_safe(ddb_entry
, dtemp
,
1331 &ha
->ddb_list
, list
) {
1332 if (atomic_read(&ddb_entry
->state
) ==
1334 qla4xxx_mark_device_missing(ha
,
1338 /* ---- link up? --- *
1339 * F/W will auto login to all devices ONLY ONCE after
1340 * link up during driver initialization and runtime
1341 * fatal error recovery. Therefore, the driver must
1342 * manually relogin to devices when recovering from
1343 * connection failures, logouts, expired KATO, etc. */
1345 list_for_each_entry_safe(ddb_entry
, dtemp
,
1346 &ha
->ddb_list
, list
) {
1347 if ((atomic_read(&ddb_entry
->state
) ==
1348 DDB_STATE_MISSING
) ||
1349 (atomic_read(&ddb_entry
->state
) ==
1351 if (ddb_entry
->fw_ddb_device_state
==
1352 DDB_DS_SESSION_ACTIVE
) {
1353 atomic_set(&ddb_entry
->state
,
1355 ql4_printk(KERN_INFO
, ha
,
1356 "scsi%ld: %s: ddb[%d]"
1358 ha
->host_no
, __func__
,
1359 ddb_entry
->fw_ddb_index
);
1361 iscsi_unblock_session(
1364 qla4xxx_relogin_device(
1372 /* ---- relogin device? --- */
1373 if (adapter_up(ha
) &&
1374 test_and_clear_bit(DPC_RELOGIN_DEVICE
, &ha
->dpc_flags
)) {
1375 list_for_each_entry_safe(ddb_entry
, dtemp
,
1376 &ha
->ddb_list
, list
) {
1377 if (test_and_clear_bit(DF_RELOGIN
, &ddb_entry
->flags
) &&
1378 atomic_read(&ddb_entry
->state
) != DDB_STATE_ONLINE
)
1379 qla4xxx_relogin_device(ha
, ddb_entry
);
1382 * If mbx cmd times out there is no point
1383 * in continuing further.
1384 * With large no of targets this can hang
1387 if (test_bit(DPC_RESET_HA
, &ha
->dpc_flags
)) {
1388 printk(KERN_WARNING
"scsi%ld: %s: "
1389 "need to reset hba\n",
1390 ha
->host_no
, __func__
);
1397 clear_bit(AF_DPC_SCHEDULED
, &ha
->flags
);
1401 * qla4xxx_free_adapter - release the adapter
1402 * @ha: pointer to adapter structure
1404 static void qla4xxx_free_adapter(struct scsi_qla_host
*ha
)
1407 if (test_bit(AF_INTERRUPTS_ON
, &ha
->flags
)) {
1408 /* Turn-off interrupts on the card. */
1409 ha
->isp_ops
->disable_intrs(ha
);
1412 /* Remove timer thread, if present */
1413 if (ha
->timer_active
)
1414 qla4xxx_stop_timer(ha
);
1416 /* Kill the kernel thread for this host */
1418 destroy_workqueue(ha
->dpc_thread
);
1420 /* Put firmware in known state */
1421 ha
->isp_ops
->reset_firmware(ha
);
1423 if (is_qla8022(ha
)) {
1424 qla4_8xxx_idc_lock(ha
);
1425 qla4_8xxx_clear_drv_active(ha
);
1426 qla4_8xxx_idc_unlock(ha
);
1429 /* Detach interrupts */
1430 if (test_and_clear_bit(AF_IRQ_ATTACHED
, &ha
->flags
))
1431 qla4xxx_free_irqs(ha
);
1433 /* free extra memory */
1434 qla4xxx_mem_free(ha
);
1437 int qla4_8xxx_iospace_config(struct scsi_qla_host
*ha
)
1440 uint8_t revision_id
;
1441 unsigned long mem_base
, mem_len
, db_base
, db_len
;
1442 struct pci_dev
*pdev
= ha
->pdev
;
1444 status
= pci_request_regions(pdev
, DRIVER_NAME
);
1447 "scsi(%ld) Failed to reserve PIO regions (%s) "
1448 "status=%d\n", ha
->host_no
, pci_name(pdev
), status
);
1449 goto iospace_error_exit
;
1452 pci_read_config_byte(pdev
, PCI_REVISION_ID
, &revision_id
);
1453 DEBUG2(printk(KERN_INFO
"%s: revision-id=%d\n",
1454 __func__
, revision_id
));
1455 ha
->revision_id
= revision_id
;
1457 /* remap phys address */
1458 mem_base
= pci_resource_start(pdev
, 0); /* 0 is for BAR 0 */
1459 mem_len
= pci_resource_len(pdev
, 0);
1460 DEBUG2(printk(KERN_INFO
"%s: ioremap from %lx a size of %lx\n",
1461 __func__
, mem_base
, mem_len
));
1463 /* mapping of pcibase pointer */
1464 ha
->nx_pcibase
= (unsigned long)ioremap(mem_base
, mem_len
);
1465 if (!ha
->nx_pcibase
) {
1467 "cannot remap MMIO (%s), aborting\n", pci_name(pdev
));
1468 pci_release_regions(ha
->pdev
);
1469 goto iospace_error_exit
;
1472 /* Mapping of IO base pointer, door bell read and write pointer */
1474 /* mapping of IO base pointer */
1476 (struct device_reg_82xx __iomem
*)((uint8_t *)ha
->nx_pcibase
+
1477 0xbc000 + (ha
->pdev
->devfn
<< 11));
1479 db_base
= pci_resource_start(pdev
, 4); /* doorbell is on bar 4 */
1480 db_len
= pci_resource_len(pdev
, 4);
1482 ha
->nx_db_wr_ptr
= (ha
->pdev
->devfn
== 4 ? QLA82XX_CAM_RAM_DB1
:
1483 QLA82XX_CAM_RAM_DB2
);
1491 * qla4xxx_iospace_config - maps registers
1492 * @ha: pointer to adapter structure
1494 * This routines maps HBA's registers from the pci address space
1495 * into the kernel virtual address space for memory mapped i/o.
1497 int qla4xxx_iospace_config(struct scsi_qla_host
*ha
)
1499 unsigned long pio
, pio_len
, pio_flags
;
1500 unsigned long mmio
, mmio_len
, mmio_flags
;
1502 pio
= pci_resource_start(ha
->pdev
, 0);
1503 pio_len
= pci_resource_len(ha
->pdev
, 0);
1504 pio_flags
= pci_resource_flags(ha
->pdev
, 0);
1505 if (pio_flags
& IORESOURCE_IO
) {
1506 if (pio_len
< MIN_IOBASE_LEN
) {
1507 ql4_printk(KERN_WARNING
, ha
,
1508 "Invalid PCI I/O region size\n");
1512 ql4_printk(KERN_WARNING
, ha
, "region #0 not a PIO resource\n");
1516 /* Use MMIO operations for all accesses. */
1517 mmio
= pci_resource_start(ha
->pdev
, 1);
1518 mmio_len
= pci_resource_len(ha
->pdev
, 1);
1519 mmio_flags
= pci_resource_flags(ha
->pdev
, 1);
1521 if (!(mmio_flags
& IORESOURCE_MEM
)) {
1522 ql4_printk(KERN_ERR
, ha
,
1523 "region #0 not an MMIO resource, aborting\n");
1525 goto iospace_error_exit
;
1528 if (mmio_len
< MIN_IOBASE_LEN
) {
1529 ql4_printk(KERN_ERR
, ha
,
1530 "Invalid PCI mem region size, aborting\n");
1531 goto iospace_error_exit
;
1534 if (pci_request_regions(ha
->pdev
, DRIVER_NAME
)) {
1535 ql4_printk(KERN_WARNING
, ha
,
1536 "Failed to reserve PIO/MMIO regions\n");
1538 goto iospace_error_exit
;
1541 ha
->pio_address
= pio
;
1542 ha
->pio_length
= pio_len
;
1543 ha
->reg
= ioremap(mmio
, MIN_IOBASE_LEN
);
1545 ql4_printk(KERN_ERR
, ha
,
1546 "cannot remap MMIO, aborting\n");
1548 goto iospace_error_exit
;
1557 static struct isp_operations qla4xxx_isp_ops
= {
1558 .iospace_config
= qla4xxx_iospace_config
,
1559 .pci_config
= qla4xxx_pci_config
,
1560 .disable_intrs
= qla4xxx_disable_intrs
,
1561 .enable_intrs
= qla4xxx_enable_intrs
,
1562 .start_firmware
= qla4xxx_start_firmware
,
1563 .intr_handler
= qla4xxx_intr_handler
,
1564 .interrupt_service_routine
= qla4xxx_interrupt_service_routine
,
1565 .reset_chip
= qla4xxx_soft_reset
,
1566 .reset_firmware
= qla4xxx_hw_reset
,
1567 .queue_iocb
= qla4xxx_queue_iocb
,
1568 .complete_iocb
= qla4xxx_complete_iocb
,
1569 .rd_shdw_req_q_out
= qla4xxx_rd_shdw_req_q_out
,
1570 .rd_shdw_rsp_q_in
= qla4xxx_rd_shdw_rsp_q_in
,
1571 .get_sys_info
= qla4xxx_get_sys_info
,
1574 static struct isp_operations qla4_8xxx_isp_ops
= {
1575 .iospace_config
= qla4_8xxx_iospace_config
,
1576 .pci_config
= qla4_8xxx_pci_config
,
1577 .disable_intrs
= qla4_8xxx_disable_intrs
,
1578 .enable_intrs
= qla4_8xxx_enable_intrs
,
1579 .start_firmware
= qla4_8xxx_load_risc
,
1580 .intr_handler
= qla4_8xxx_intr_handler
,
1581 .interrupt_service_routine
= qla4_8xxx_interrupt_service_routine
,
1582 .reset_chip
= qla4_8xxx_isp_reset
,
1583 .reset_firmware
= qla4_8xxx_stop_firmware
,
1584 .queue_iocb
= qla4_8xxx_queue_iocb
,
1585 .complete_iocb
= qla4_8xxx_complete_iocb
,
1586 .rd_shdw_req_q_out
= qla4_8xxx_rd_shdw_req_q_out
,
1587 .rd_shdw_rsp_q_in
= qla4_8xxx_rd_shdw_rsp_q_in
,
1588 .get_sys_info
= qla4_8xxx_get_sys_info
,
1591 uint16_t qla4xxx_rd_shdw_req_q_out(struct scsi_qla_host
*ha
)
1593 return (uint16_t)le32_to_cpu(ha
->shadow_regs
->req_q_out
);
1596 uint16_t qla4_8xxx_rd_shdw_req_q_out(struct scsi_qla_host
*ha
)
1598 return (uint16_t)le32_to_cpu(readl(&ha
->qla4_8xxx_reg
->req_q_out
));
1601 uint16_t qla4xxx_rd_shdw_rsp_q_in(struct scsi_qla_host
*ha
)
1603 return (uint16_t)le32_to_cpu(ha
->shadow_regs
->rsp_q_in
);
1606 uint16_t qla4_8xxx_rd_shdw_rsp_q_in(struct scsi_qla_host
*ha
)
1608 return (uint16_t)le32_to_cpu(readl(&ha
->qla4_8xxx_reg
->rsp_q_in
));
1612 * qla4xxx_probe_adapter - callback function to probe HBA
1613 * @pdev: pointer to pci_dev structure
1614 * @pci_device_id: pointer to pci_device entry
1616 * This routine will probe for Qlogic 4xxx iSCSI host adapters.
1617 * It returns zero if successful. It also initializes all data necessary for
1620 static int __devinit
qla4xxx_probe_adapter(struct pci_dev
*pdev
,
1621 const struct pci_device_id
*ent
)
1623 int ret
= -ENODEV
, status
;
1624 struct Scsi_Host
*host
;
1625 struct scsi_qla_host
*ha
;
1626 uint8_t init_retry_count
= 0;
1628 struct qla4_8xxx_legacy_intr_set
*nx_legacy_intr
;
1630 if (pci_enable_device(pdev
))
1633 host
= scsi_host_alloc(&qla4xxx_driver_template
, sizeof(*ha
));
1636 "qla4xxx: Couldn't allocate host from scsi layer!\n");
1637 goto probe_disable_device
;
1640 /* Clear our data area */
1641 ha
= (struct scsi_qla_host
*) host
->hostdata
;
1642 memset(ha
, 0, sizeof(*ha
));
1644 /* Save the information from PCI BIOS. */
1647 ha
->host_no
= host
->host_no
;
1649 pci_enable_pcie_error_reporting(pdev
);
1651 /* Setup Runtime configurable options */
1652 if (is_qla8022(ha
)) {
1653 ha
->isp_ops
= &qla4_8xxx_isp_ops
;
1654 rwlock_init(&ha
->hw_lock
);
1655 ha
->qdr_sn_window
= -1;
1656 ha
->ddr_mn_window
= -1;
1657 ha
->curr_window
= 255;
1658 ha
->func_num
= PCI_FUNC(ha
->pdev
->devfn
);
1659 nx_legacy_intr
= &legacy_intr
[ha
->func_num
];
1660 ha
->nx_legacy_intr
.int_vec_bit
= nx_legacy_intr
->int_vec_bit
;
1661 ha
->nx_legacy_intr
.tgt_status_reg
=
1662 nx_legacy_intr
->tgt_status_reg
;
1663 ha
->nx_legacy_intr
.tgt_mask_reg
= nx_legacy_intr
->tgt_mask_reg
;
1664 ha
->nx_legacy_intr
.pci_int_reg
= nx_legacy_intr
->pci_int_reg
;
1666 ha
->isp_ops
= &qla4xxx_isp_ops
;
1669 /* Set EEH reset type to fundamental if required by hba */
1671 pdev
->needs_freset
= 1;
1673 /* Configure PCI I/O space. */
1674 ret
= ha
->isp_ops
->iospace_config(ha
);
1676 goto probe_failed_ioconfig
;
1678 ql4_printk(KERN_INFO
, ha
, "Found an ISP%04x, irq %d, iobase 0x%p\n",
1679 pdev
->device
, pdev
->irq
, ha
->reg
);
1681 qla4xxx_config_dma_addressing(ha
);
1683 /* Initialize lists and spinlocks. */
1684 INIT_LIST_HEAD(&ha
->ddb_list
);
1685 INIT_LIST_HEAD(&ha
->free_srb_q
);
1687 mutex_init(&ha
->mbox_sem
);
1688 init_completion(&ha
->mbx_intr_comp
);
1690 spin_lock_init(&ha
->hardware_lock
);
1692 /* Allocate dma buffers */
1693 if (qla4xxx_mem_alloc(ha
)) {
1694 ql4_printk(KERN_WARNING
, ha
,
1695 "[ERROR] Failed to allocate memory for adapter\n");
1702 (void) qla4_8xxx_get_flash_info(ha
);
1705 * Initialize the Host adapter request/response queues and
1707 * NOTE: interrupts enabled upon successful completion
1709 status
= qla4xxx_initialize_adapter(ha
, REBUILD_DDB_LIST
);
1710 while ((!test_bit(AF_ONLINE
, &ha
->flags
)) &&
1711 init_retry_count
++ < MAX_INIT_RETRIES
) {
1712 DEBUG2(printk("scsi: %s: retrying adapter initialization "
1713 "(%d)\n", __func__
, init_retry_count
));
1715 if (ha
->isp_ops
->reset_chip(ha
) == QLA_ERROR
)
1718 status
= qla4xxx_initialize_adapter(ha
, REBUILD_DDB_LIST
);
1721 if (!test_bit(AF_ONLINE
, &ha
->flags
)) {
1722 ql4_printk(KERN_WARNING
, ha
, "Failed to initialize adapter\n");
1728 host
->cmd_per_lun
= 3;
1729 host
->max_channel
= 0;
1730 host
->max_lun
= MAX_LUNS
- 1;
1731 host
->max_id
= MAX_TARGETS
;
1732 host
->max_cmd_len
= IOCB_MAX_CDB_LEN
;
1733 host
->can_queue
= MAX_SRBS
;
1734 host
->transportt
= qla4xxx_scsi_transport
;
1736 ret
= scsi_init_shared_tag_map(host
, MAX_SRBS
);
1738 ql4_printk(KERN_WARNING
, ha
,
1739 "scsi_init_shared_tag_map failed\n");
1743 /* Startup the kernel thread for this host adapter. */
1744 DEBUG2(printk("scsi: %s: Starting kernel thread for "
1745 "qla4xxx_dpc\n", __func__
));
1746 sprintf(buf
, "qla4xxx_%lu_dpc", ha
->host_no
);
1747 ha
->dpc_thread
= create_singlethread_workqueue(buf
);
1748 if (!ha
->dpc_thread
) {
1749 ql4_printk(KERN_WARNING
, ha
, "Unable to start DPC thread!\n");
1753 INIT_WORK(&ha
->dpc_work
, qla4xxx_do_dpc
);
1755 /* For ISP-82XX, request_irqs is called in qla4_8xxx_load_risc
1756 * (which is called indirectly by qla4xxx_initialize_adapter),
1757 * so that irqs will be registered after crbinit but before
1760 if (!is_qla8022(ha
)) {
1761 ret
= qla4xxx_request_irqs(ha
);
1763 ql4_printk(KERN_WARNING
, ha
, "Failed to reserve "
1764 "interrupt %d already in use.\n", pdev
->irq
);
1769 pci_save_state(ha
->pdev
);
1770 ha
->isp_ops
->enable_intrs(ha
);
1772 /* Start timer thread. */
1773 qla4xxx_start_timer(ha
, qla4xxx_timer
, 1);
1775 set_bit(AF_INIT_DONE
, &ha
->flags
);
1777 pci_set_drvdata(pdev
, ha
);
1779 ret
= scsi_add_host(host
, &pdev
->dev
);
1784 " QLogic iSCSI HBA Driver version: %s\n"
1785 " QLogic ISP%04x @ %s, host#=%ld, fw=%02d.%02d.%02d.%02d\n",
1786 qla4xxx_version_str
, ha
->pdev
->device
, pci_name(ha
->pdev
),
1787 ha
->host_no
, ha
->firmware_version
[0], ha
->firmware_version
[1],
1788 ha
->patch_number
, ha
->build_number
);
1789 scsi_scan_host(host
);
1793 qla4xxx_free_adapter(ha
);
1795 probe_failed_ioconfig
:
1796 pci_disable_pcie_error_reporting(pdev
);
1797 scsi_host_put(ha
->host
);
1799 probe_disable_device
:
1800 pci_disable_device(pdev
);
1806 * qla4xxx_remove_adapter - calback function to remove adapter.
1807 * @pci_dev: PCI device pointer
1809 static void __devexit
qla4xxx_remove_adapter(struct pci_dev
*pdev
)
1811 struct scsi_qla_host
*ha
;
1813 ha
= pci_get_drvdata(pdev
);
1815 set_bit(AF_HBA_GOING_AWAY
, &ha
->flags
);
1817 /* remove devs from iscsi_sessions to scsi_devices */
1818 qla4xxx_free_ddb_list(ha
);
1820 scsi_remove_host(ha
->host
);
1822 qla4xxx_free_adapter(ha
);
1824 scsi_host_put(ha
->host
);
1826 pci_disable_pcie_error_reporting(pdev
);
1827 pci_disable_device(pdev
);
1828 pci_set_drvdata(pdev
, NULL
);
1832 * qla4xxx_config_dma_addressing() - Configure OS DMA addressing method.
1835 * At exit, the @ha's flags.enable_64bit_addressing set to indicated
1836 * supported addressing method.
1838 static void qla4xxx_config_dma_addressing(struct scsi_qla_host
*ha
)
1842 /* Update our PCI device dma_mask for full 64 bit mask */
1843 if (pci_set_dma_mask(ha
->pdev
, DMA_BIT_MASK(64)) == 0) {
1844 if (pci_set_consistent_dma_mask(ha
->pdev
, DMA_BIT_MASK(64))) {
1845 dev_dbg(&ha
->pdev
->dev
,
1846 "Failed to set 64 bit PCI consistent mask; "
1848 retval
= pci_set_consistent_dma_mask(ha
->pdev
,
1852 retval
= pci_set_dma_mask(ha
->pdev
, DMA_BIT_MASK(32));
1855 static int qla4xxx_slave_alloc(struct scsi_device
*sdev
)
1857 struct iscsi_cls_session
*sess
= starget_to_session(sdev
->sdev_target
);
1858 struct ddb_entry
*ddb
= sess
->dd_data
;
1860 sdev
->hostdata
= ddb
;
1861 sdev
->tagged_supported
= 1;
1862 scsi_activate_tcq(sdev
, QL4_DEF_QDEPTH
);
1866 static int qla4xxx_slave_configure(struct scsi_device
*sdev
)
1868 sdev
->tagged_supported
= 1;
1872 static void qla4xxx_slave_destroy(struct scsi_device
*sdev
)
1874 scsi_deactivate_tcq(sdev
, 1);
1878 * qla4xxx_del_from_active_array - returns an active srb
1879 * @ha: Pointer to host adapter structure.
1880 * @index: index into the active_array
1882 * This routine removes and returns the srb at the specified index
1884 struct srb
*qla4xxx_del_from_active_array(struct scsi_qla_host
*ha
,
1887 struct srb
*srb
= NULL
;
1888 struct scsi_cmnd
*cmd
= NULL
;
1890 cmd
= scsi_host_find_tag(ha
->host
, index
);
1894 srb
= (struct srb
*)CMD_SP(cmd
);
1898 /* update counters */
1899 if (srb
->flags
& SRB_DMA_VALID
) {
1900 ha
->req_q_count
+= srb
->iocb_cnt
;
1901 ha
->iocb_cnt
-= srb
->iocb_cnt
;
1903 srb
->cmd
->host_scribble
=
1904 (unsigned char *)(unsigned long) MAX_SRBS
;
1910 * qla4xxx_eh_wait_on_command - waits for command to be returned by firmware
1911 * @ha: Pointer to host adapter structure.
1912 * @cmd: Scsi Command to wait on.
1914 * This routine waits for the command to be returned by the Firmware
1915 * for some max time.
1917 static int qla4xxx_eh_wait_on_command(struct scsi_qla_host
*ha
,
1918 struct scsi_cmnd
*cmd
)
1922 uint32_t max_wait_time
= EH_WAIT_CMD_TOV
;
1925 /* Dont wait on command if PCI error is being handled
1928 if (unlikely(pci_channel_offline(ha
->pdev
)) ||
1929 (test_bit(AF_EEH_BUSY
, &ha
->flags
))) {
1930 ql4_printk(KERN_WARNING
, ha
, "scsi%ld: Return from %s\n",
1931 ha
->host_no
, __func__
);
1936 /* Checking to see if its returned to OS */
1937 rp
= (struct srb
*) CMD_SP(cmd
);
1944 } while (max_wait_time
--);
1950 * qla4xxx_wait_for_hba_online - waits for HBA to come online
1951 * @ha: Pointer to host adapter structure
1953 static int qla4xxx_wait_for_hba_online(struct scsi_qla_host
*ha
)
1955 unsigned long wait_online
;
1957 wait_online
= jiffies
+ (HBA_ONLINE_TOV
* HZ
);
1958 while (time_before(jiffies
, wait_online
)) {
1970 * qla4xxx_eh_wait_for_commands - wait for active cmds to finish.
1971 * @ha: pointer to HBA
1975 * This function waits for all outstanding commands to a lun to complete. It
1976 * returns 0 if all pending commands are returned and 1 otherwise.
1978 static int qla4xxx_eh_wait_for_commands(struct scsi_qla_host
*ha
,
1979 struct scsi_target
*stgt
,
1980 struct scsi_device
*sdev
)
1984 struct scsi_cmnd
*cmd
;
1987 * Waiting for all commands for the designated target or dev
1988 * in the active array
1990 for (cnt
= 0; cnt
< ha
->host
->can_queue
; cnt
++) {
1991 cmd
= scsi_host_find_tag(ha
->host
, cnt
);
1992 if (cmd
&& stgt
== scsi_target(cmd
->device
) &&
1993 (!sdev
|| sdev
== cmd
->device
)) {
1994 if (!qla4xxx_eh_wait_on_command(ha
, cmd
)) {
2004 * qla4xxx_eh_abort - callback for abort task.
2005 * @cmd: Pointer to Linux's SCSI command structure
2007 * This routine is called by the Linux OS to abort the specified
2010 static int qla4xxx_eh_abort(struct scsi_cmnd
*cmd
)
2012 struct scsi_qla_host
*ha
= to_qla_host(cmd
->device
->host
);
2013 unsigned int id
= cmd
->device
->id
;
2014 unsigned int lun
= cmd
->device
->lun
;
2015 unsigned long serial
= cmd
->serial_number
;
2016 unsigned long flags
;
2017 struct srb
*srb
= NULL
;
2021 ql4_printk(KERN_INFO
, ha
,
2022 "scsi%ld:%d:%d: Abort command issued cmd=%p, pid=%ld\n",
2023 ha
->host_no
, id
, lun
, cmd
, serial
);
2025 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
2026 srb
= (struct srb
*) CMD_SP(cmd
);
2028 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
2031 kref_get(&srb
->srb_ref
);
2032 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
2034 if (qla4xxx_abort_task(ha
, srb
) != QLA_SUCCESS
) {
2035 DEBUG3(printk("scsi%ld:%d:%d: Abort_task mbx failed.\n",
2036 ha
->host_no
, id
, lun
));
2039 DEBUG3(printk("scsi%ld:%d:%d: Abort_task mbx success.\n",
2040 ha
->host_no
, id
, lun
));
2044 kref_put(&srb
->srb_ref
, qla4xxx_srb_compl
);
2046 /* Wait for command to complete */
2048 if (!qla4xxx_eh_wait_on_command(ha
, cmd
)) {
2049 DEBUG2(printk("scsi%ld:%d:%d: Abort handler timed out\n",
2050 ha
->host_no
, id
, lun
));
2055 ql4_printk(KERN_INFO
, ha
,
2056 "scsi%ld:%d:%d: Abort command - %s\n",
2057 ha
->host_no
, id
, lun
, (ret
== SUCCESS
) ? "succeded" : "failed");
2063 * qla4xxx_eh_device_reset - callback for target reset.
2064 * @cmd: Pointer to Linux's SCSI command structure
2066 * This routine is called by the Linux OS to reset all luns on the
2069 static int qla4xxx_eh_device_reset(struct scsi_cmnd
*cmd
)
2071 struct scsi_qla_host
*ha
= to_qla_host(cmd
->device
->host
);
2072 struct ddb_entry
*ddb_entry
= cmd
->device
->hostdata
;
2073 int ret
= FAILED
, stat
;
2078 ret
= iscsi_block_scsi_eh(cmd
);
2083 ql4_printk(KERN_INFO
, ha
,
2084 "scsi%ld:%d:%d:%d: DEVICE RESET ISSUED.\n", ha
->host_no
,
2085 cmd
->device
->channel
, cmd
->device
->id
, cmd
->device
->lun
);
2087 DEBUG2(printk(KERN_INFO
2088 "scsi%ld: DEVICE_RESET cmd=%p jiffies = 0x%lx, to=%x,"
2089 "dpc_flags=%lx, status=%x allowed=%d\n", ha
->host_no
,
2090 cmd
, jiffies
, cmd
->request
->timeout
/ HZ
,
2091 ha
->dpc_flags
, cmd
->result
, cmd
->allowed
));
2093 /* FIXME: wait for hba to go online */
2094 stat
= qla4xxx_reset_lun(ha
, ddb_entry
, cmd
->device
->lun
);
2095 if (stat
!= QLA_SUCCESS
) {
2096 ql4_printk(KERN_INFO
, ha
, "DEVICE RESET FAILED. %d\n", stat
);
2097 goto eh_dev_reset_done
;
2100 if (qla4xxx_eh_wait_for_commands(ha
, scsi_target(cmd
->device
),
2102 ql4_printk(KERN_INFO
, ha
,
2103 "DEVICE RESET FAILED - waiting for "
2105 goto eh_dev_reset_done
;
2109 if (qla4xxx_send_marker_iocb(ha
, ddb_entry
, cmd
->device
->lun
,
2110 MM_LUN_RESET
) != QLA_SUCCESS
)
2111 goto eh_dev_reset_done
;
2113 ql4_printk(KERN_INFO
, ha
,
2114 "scsi(%ld:%d:%d:%d): DEVICE RESET SUCCEEDED.\n",
2115 ha
->host_no
, cmd
->device
->channel
, cmd
->device
->id
,
2126 * qla4xxx_eh_target_reset - callback for target reset.
2127 * @cmd: Pointer to Linux's SCSI command structure
2129 * This routine is called by the Linux OS to reset the target.
2131 static int qla4xxx_eh_target_reset(struct scsi_cmnd
*cmd
)
2133 struct scsi_qla_host
*ha
= to_qla_host(cmd
->device
->host
);
2134 struct ddb_entry
*ddb_entry
= cmd
->device
->hostdata
;
2140 ret
= iscsi_block_scsi_eh(cmd
);
2144 starget_printk(KERN_INFO
, scsi_target(cmd
->device
),
2145 "WARM TARGET RESET ISSUED.\n");
2147 DEBUG2(printk(KERN_INFO
2148 "scsi%ld: TARGET_DEVICE_RESET cmd=%p jiffies = 0x%lx, "
2149 "to=%x,dpc_flags=%lx, status=%x allowed=%d\n",
2150 ha
->host_no
, cmd
, jiffies
, cmd
->request
->timeout
/ HZ
,
2151 ha
->dpc_flags
, cmd
->result
, cmd
->allowed
));
2153 stat
= qla4xxx_reset_target(ha
, ddb_entry
);
2154 if (stat
!= QLA_SUCCESS
) {
2155 starget_printk(KERN_INFO
, scsi_target(cmd
->device
),
2156 "WARM TARGET RESET FAILED.\n");
2160 if (qla4xxx_eh_wait_for_commands(ha
, scsi_target(cmd
->device
),
2162 starget_printk(KERN_INFO
, scsi_target(cmd
->device
),
2163 "WARM TARGET DEVICE RESET FAILED - "
2164 "waiting for commands.\n");
2169 if (qla4xxx_send_marker_iocb(ha
, ddb_entry
, cmd
->device
->lun
,
2170 MM_TGT_WARM_RESET
) != QLA_SUCCESS
) {
2171 starget_printk(KERN_INFO
, scsi_target(cmd
->device
),
2172 "WARM TARGET DEVICE RESET FAILED - "
2173 "marker iocb failed.\n");
2177 starget_printk(KERN_INFO
, scsi_target(cmd
->device
),
2178 "WARM TARGET RESET SUCCEEDED.\n");
2183 * qla4xxx_eh_host_reset - kernel callback
2184 * @cmd: Pointer to Linux's SCSI command structure
2186 * This routine is invoked by the Linux kernel to perform fatal error
2187 * recovery on the specified adapter.
2189 static int qla4xxx_eh_host_reset(struct scsi_cmnd
*cmd
)
2191 int return_status
= FAILED
;
2192 struct scsi_qla_host
*ha
;
2194 ha
= (struct scsi_qla_host
*) cmd
->device
->host
->hostdata
;
2196 if (ql4xdontresethba
) {
2197 DEBUG2(printk("scsi%ld: %s: Don't Reset HBA\n",
2198 ha
->host_no
, __func__
));
2202 ql4_printk(KERN_INFO
, ha
,
2203 "scsi(%ld:%d:%d:%d): HOST RESET ISSUED.\n", ha
->host_no
,
2204 cmd
->device
->channel
, cmd
->device
->id
, cmd
->device
->lun
);
2206 if (qla4xxx_wait_for_hba_online(ha
) != QLA_SUCCESS
) {
2207 DEBUG2(printk("scsi%ld:%d: %s: Unable to reset host. Adapter "
2208 "DEAD.\n", ha
->host_no
, cmd
->device
->channel
,
2214 if (!test_bit(DPC_RESET_HA
, &ha
->dpc_flags
)) {
2216 set_bit(DPC_RESET_HA_FW_CONTEXT
, &ha
->dpc_flags
);
2218 set_bit(DPC_RESET_HA
, &ha
->dpc_flags
);
2221 if (qla4xxx_recover_adapter(ha
) == QLA_SUCCESS
)
2222 return_status
= SUCCESS
;
2224 ql4_printk(KERN_INFO
, ha
, "HOST RESET %s.\n",
2225 return_status
== FAILED
? "FAILED" : "SUCCEDED");
2227 return return_status
;
2230 /* PCI AER driver recovers from all correctable errors w/o
2231 * driver intervention. For uncorrectable errors PCI AER
2232 * driver calls the following device driver's callbacks
2234 * - Fatal Errors - link_reset
2235 * - Non-Fatal Errors - driver's pci_error_detected() which
2236 * returns CAN_RECOVER, NEED_RESET or DISCONNECT.
2238 * PCI AER driver calls
2239 * CAN_RECOVER - driver's pci_mmio_enabled(), mmio_enabled
2240 * returns RECOVERED or NEED_RESET if fw_hung
2241 * NEED_RESET - driver's slot_reset()
2242 * DISCONNECT - device is dead & cannot recover
2243 * RECOVERED - driver's pci_resume()
2245 static pci_ers_result_t
2246 qla4xxx_pci_error_detected(struct pci_dev
*pdev
, pci_channel_state_t state
)
2248 struct scsi_qla_host
*ha
= pci_get_drvdata(pdev
);
2250 ql4_printk(KERN_WARNING
, ha
, "scsi%ld: %s: error detected:state %x\n",
2251 ha
->host_no
, __func__
, state
);
2253 if (!is_aer_supported(ha
))
2254 return PCI_ERS_RESULT_NONE
;
2257 case pci_channel_io_normal
:
2258 clear_bit(AF_EEH_BUSY
, &ha
->flags
);
2259 return PCI_ERS_RESULT_CAN_RECOVER
;
2260 case pci_channel_io_frozen
:
2261 set_bit(AF_EEH_BUSY
, &ha
->flags
);
2262 qla4xxx_mailbox_premature_completion(ha
);
2263 qla4xxx_free_irqs(ha
);
2264 pci_disable_device(pdev
);
2265 /* Return back all IOs */
2266 qla4xxx_abort_active_cmds(ha
, DID_RESET
<< 16);
2267 return PCI_ERS_RESULT_NEED_RESET
;
2268 case pci_channel_io_perm_failure
:
2269 set_bit(AF_EEH_BUSY
, &ha
->flags
);
2270 set_bit(AF_PCI_CHANNEL_IO_PERM_FAILURE
, &ha
->flags
);
2271 qla4xxx_abort_active_cmds(ha
, DID_NO_CONNECT
<< 16);
2272 return PCI_ERS_RESULT_DISCONNECT
;
2274 return PCI_ERS_RESULT_NEED_RESET
;
2278 * qla4xxx_pci_mmio_enabled() gets called if
2279 * qla4xxx_pci_error_detected() returns PCI_ERS_RESULT_CAN_RECOVER
2280 * and read/write to the device still works.
2282 static pci_ers_result_t
2283 qla4xxx_pci_mmio_enabled(struct pci_dev
*pdev
)
2285 struct scsi_qla_host
*ha
= pci_get_drvdata(pdev
);
2287 if (!is_aer_supported(ha
))
2288 return PCI_ERS_RESULT_NONE
;
2290 return PCI_ERS_RESULT_RECOVERED
;
2293 static uint32_t qla4_8xxx_error_recovery(struct scsi_qla_host
*ha
)
2295 uint32_t rval
= QLA_ERROR
;
2298 struct pci_dev
*other_pdev
= NULL
;
2300 ql4_printk(KERN_WARNING
, ha
, "scsi%ld: In %s\n", ha
->host_no
, __func__
);
2302 set_bit(DPC_RESET_ACTIVE
, &ha
->dpc_flags
);
2304 if (test_bit(AF_ONLINE
, &ha
->flags
)) {
2305 clear_bit(AF_ONLINE
, &ha
->flags
);
2306 qla4xxx_mark_all_devices_missing(ha
);
2307 qla4xxx_process_aen(ha
, FLUSH_DDB_CHANGED_AENS
);
2310 fn
= PCI_FUNC(ha
->pdev
->devfn
);
2313 ql4_printk(KERN_INFO
, ha
, "scsi%ld: %s: Finding PCI device at "
2314 "func %x\n", ha
->host_no
, __func__
, fn
);
2315 /* Get the pci device given the domain, bus,
2316 * slot/function number */
2318 pci_get_domain_bus_and_slot(pci_domain_nr(ha
->pdev
->bus
),
2319 ha
->pdev
->bus
->number
, PCI_DEVFN(PCI_SLOT(ha
->pdev
->devfn
),
2325 if (atomic_read(&other_pdev
->enable_cnt
)) {
2326 ql4_printk(KERN_INFO
, ha
, "scsi%ld: %s: Found PCI "
2327 "func in enabled state%x\n", ha
->host_no
,
2329 pci_dev_put(other_pdev
);
2332 pci_dev_put(other_pdev
);
2335 /* The first function on the card, the reset owner will
2336 * start & initialize the firmware. The other functions
2337 * on the card will reset the firmware context
2340 ql4_printk(KERN_INFO
, ha
, "scsi%ld: %s: devfn being reset "
2341 "0x%x is the owner\n", ha
->host_no
, __func__
,
2344 qla4_8xxx_idc_lock(ha
);
2345 qla4_8xxx_wr_32(ha
, QLA82XX_CRB_DEV_STATE
,
2348 qla4_8xxx_wr_32(ha
, QLA82XX_CRB_DRV_IDC_VERSION
,
2349 QLA82XX_IDC_VERSION
);
2351 qla4_8xxx_idc_unlock(ha
);
2352 clear_bit(AF_FW_RECOVERY
, &ha
->flags
);
2353 rval
= qla4xxx_initialize_adapter(ha
, PRESERVE_DDB_LIST
);
2354 qla4_8xxx_idc_lock(ha
);
2356 if (rval
!= QLA_SUCCESS
) {
2357 ql4_printk(KERN_INFO
, ha
, "scsi%ld: %s: HW State: "
2358 "FAILED\n", ha
->host_no
, __func__
);
2359 qla4_8xxx_clear_drv_active(ha
);
2360 qla4_8xxx_wr_32(ha
, QLA82XX_CRB_DEV_STATE
,
2361 QLA82XX_DEV_FAILED
);
2363 ql4_printk(KERN_INFO
, ha
, "scsi%ld: %s: HW State: "
2364 "READY\n", ha
->host_no
, __func__
);
2365 qla4_8xxx_wr_32(ha
, QLA82XX_CRB_DEV_STATE
,
2367 /* Clear driver state register */
2368 qla4_8xxx_wr_32(ha
, QLA82XX_CRB_DRV_STATE
, 0);
2369 qla4_8xxx_set_drv_active(ha
);
2370 ret
= qla4xxx_request_irqs(ha
);
2372 ql4_printk(KERN_WARNING
, ha
, "Failed to "
2373 "reserve interrupt %d already in use.\n",
2377 ha
->isp_ops
->enable_intrs(ha
);
2381 qla4_8xxx_idc_unlock(ha
);
2383 ql4_printk(KERN_INFO
, ha
, "scsi%ld: %s: devfn 0x%x is not "
2384 "the reset owner\n", ha
->host_no
, __func__
,
2386 if ((qla4_8xxx_rd_32(ha
, QLA82XX_CRB_DEV_STATE
) ==
2387 QLA82XX_DEV_READY
)) {
2388 clear_bit(AF_FW_RECOVERY
, &ha
->flags
);
2389 rval
= qla4xxx_initialize_adapter(ha
,
2391 if (rval
== QLA_SUCCESS
) {
2392 ret
= qla4xxx_request_irqs(ha
);
2394 ql4_printk(KERN_WARNING
, ha
, "Failed to"
2395 " reserve interrupt %d already in"
2396 " use.\n", ha
->pdev
->irq
);
2399 ha
->isp_ops
->enable_intrs(ha
);
2403 qla4_8xxx_idc_lock(ha
);
2404 qla4_8xxx_set_drv_active(ha
);
2405 qla4_8xxx_idc_unlock(ha
);
2408 clear_bit(DPC_RESET_ACTIVE
, &ha
->dpc_flags
);
2412 static pci_ers_result_t
2413 qla4xxx_pci_slot_reset(struct pci_dev
*pdev
)
2415 pci_ers_result_t ret
= PCI_ERS_RESULT_DISCONNECT
;
2416 struct scsi_qla_host
*ha
= pci_get_drvdata(pdev
);
2419 ql4_printk(KERN_WARNING
, ha
, "scsi%ld: %s: slot_reset\n",
2420 ha
->host_no
, __func__
);
2422 if (!is_aer_supported(ha
))
2423 return PCI_ERS_RESULT_NONE
;
2425 /* Restore the saved state of PCIe device -
2426 * BAR registers, PCI Config space, PCIX, MSI,
2429 pci_restore_state(pdev
);
2431 /* pci_restore_state() clears the saved_state flag of the device
2432 * save restored state which resets saved_state flag
2434 pci_save_state(pdev
);
2436 /* Initialize device or resume if in suspended state */
2437 rc
= pci_enable_device(pdev
);
2439 ql4_printk(KERN_WARNING
, ha
, "scsi%ld: %s: Cant re-enable "
2440 "device after reset\n", ha
->host_no
, __func__
);
2441 goto exit_slot_reset
;
2444 ha
->isp_ops
->disable_intrs(ha
);
2446 if (is_qla8022(ha
)) {
2447 if (qla4_8xxx_error_recovery(ha
) == QLA_SUCCESS
) {
2448 ret
= PCI_ERS_RESULT_RECOVERED
;
2449 goto exit_slot_reset
;
2451 goto exit_slot_reset
;
2455 ql4_printk(KERN_WARNING
, ha
, "scsi%ld: %s: Return=%x\n"
2456 "device after reset\n", ha
->host_no
, __func__
, ret
);
2461 qla4xxx_pci_resume(struct pci_dev
*pdev
)
2463 struct scsi_qla_host
*ha
= pci_get_drvdata(pdev
);
2466 ql4_printk(KERN_WARNING
, ha
, "scsi%ld: %s: pci_resume\n",
2467 ha
->host_no
, __func__
);
2469 ret
= qla4xxx_wait_for_hba_online(ha
);
2470 if (ret
!= QLA_SUCCESS
) {
2471 ql4_printk(KERN_ERR
, ha
, "scsi%ld: %s: the device failed to "
2472 "resume I/O from slot/link_reset\n", ha
->host_no
,
2476 pci_cleanup_aer_uncorrect_error_status(pdev
);
2477 clear_bit(AF_EEH_BUSY
, &ha
->flags
);
2480 static struct pci_error_handlers qla4xxx_err_handler
= {
2481 .error_detected
= qla4xxx_pci_error_detected
,
2482 .mmio_enabled
= qla4xxx_pci_mmio_enabled
,
2483 .slot_reset
= qla4xxx_pci_slot_reset
,
2484 .resume
= qla4xxx_pci_resume
,
2487 static struct pci_device_id qla4xxx_pci_tbl
[] = {
2489 .vendor
= PCI_VENDOR_ID_QLOGIC
,
2490 .device
= PCI_DEVICE_ID_QLOGIC_ISP4010
,
2491 .subvendor
= PCI_ANY_ID
,
2492 .subdevice
= PCI_ANY_ID
,
2495 .vendor
= PCI_VENDOR_ID_QLOGIC
,
2496 .device
= PCI_DEVICE_ID_QLOGIC_ISP4022
,
2497 .subvendor
= PCI_ANY_ID
,
2498 .subdevice
= PCI_ANY_ID
,
2501 .vendor
= PCI_VENDOR_ID_QLOGIC
,
2502 .device
= PCI_DEVICE_ID_QLOGIC_ISP4032
,
2503 .subvendor
= PCI_ANY_ID
,
2504 .subdevice
= PCI_ANY_ID
,
2507 .vendor
= PCI_VENDOR_ID_QLOGIC
,
2508 .device
= PCI_DEVICE_ID_QLOGIC_ISP8022
,
2509 .subvendor
= PCI_ANY_ID
,
2510 .subdevice
= PCI_ANY_ID
,
2514 MODULE_DEVICE_TABLE(pci
, qla4xxx_pci_tbl
);
2516 static struct pci_driver qla4xxx_pci_driver
= {
2517 .name
= DRIVER_NAME
,
2518 .id_table
= qla4xxx_pci_tbl
,
2519 .probe
= qla4xxx_probe_adapter
,
2520 .remove
= qla4xxx_remove_adapter
,
2521 .err_handler
= &qla4xxx_err_handler
,
2524 static int __init
qla4xxx_module_init(void)
2528 /* Allocate cache for SRBs. */
2529 srb_cachep
= kmem_cache_create("qla4xxx_srbs", sizeof(struct srb
), 0,
2530 SLAB_HWCACHE_ALIGN
, NULL
);
2531 if (srb_cachep
== NULL
) {
2533 "%s: Unable to allocate SRB cache..."
2534 "Failing load!\n", DRIVER_NAME
);
2539 /* Derive version string. */
2540 strcpy(qla4xxx_version_str
, QLA4XXX_DRIVER_VERSION
);
2541 if (ql4xextended_error_logging
)
2542 strcat(qla4xxx_version_str
, "-debug");
2544 qla4xxx_scsi_transport
=
2545 iscsi_register_transport(&qla4xxx_iscsi_transport
);
2546 if (!qla4xxx_scsi_transport
){
2548 goto release_srb_cache
;
2551 ret
= pci_register_driver(&qla4xxx_pci_driver
);
2553 goto unregister_transport
;
2555 printk(KERN_INFO
"QLogic iSCSI HBA Driver\n");
2558 unregister_transport
:
2559 iscsi_unregister_transport(&qla4xxx_iscsi_transport
);
2561 kmem_cache_destroy(srb_cachep
);
2566 static void __exit
qla4xxx_module_exit(void)
2568 pci_unregister_driver(&qla4xxx_pci_driver
);
2569 iscsi_unregister_transport(&qla4xxx_iscsi_transport
);
2570 kmem_cache_destroy(srb_cachep
);
2573 module_init(qla4xxx_module_init
);
2574 module_exit(qla4xxx_module_exit
);
2576 MODULE_AUTHOR("QLogic Corporation");
2577 MODULE_DESCRIPTION("QLogic iSCSI HBA Driver");
2578 MODULE_LICENSE("GPL");
2579 MODULE_VERSION(QLA4XXX_DRIVER_VERSION
);