2 * QLogic Fibre Channel HBA Driver
3 * Copyright (c) 2003-2008 QLogic Corporation
5 * See LICENSE.qla2xxx for copyright and licensing details.
9 #include <linux/moduleparam.h>
10 #include <linux/vmalloc.h>
11 #include <linux/delay.h>
12 #include <linux/kthread.h>
14 #include <scsi/scsi_tcq.h>
15 #include <scsi/scsicam.h>
16 #include <scsi/scsi_transport.h>
17 #include <scsi/scsi_transport_fc.h>
22 char qla2x00_version_str
[40];
25 * SRB allocation cache
27 static struct kmem_cache
*srb_cachep
;
30 int ql2xlogintimeout
= 20;
31 module_param(ql2xlogintimeout
, int, S_IRUGO
|S_IRUSR
);
32 MODULE_PARM_DESC(ql2xlogintimeout
,
33 "Login timeout value in seconds.");
35 int qlport_down_retry
;
36 module_param(qlport_down_retry
, int, S_IRUGO
|S_IRUSR
);
37 MODULE_PARM_DESC(qlport_down_retry
,
38 "Maximum number of command retries to a port that returns "
39 "a PORT-DOWN status.");
41 int ql2xplogiabsentdevice
;
42 module_param(ql2xplogiabsentdevice
, int, S_IRUGO
|S_IWUSR
);
43 MODULE_PARM_DESC(ql2xplogiabsentdevice
,
44 "Option to enable PLOGI to devices that are not present after "
45 "a Fabric scan. This is needed for several broken switches. "
46 "Default is 0 - no PLOGI. 1 - perfom PLOGI.");
48 int ql2xloginretrycount
= 0;
49 module_param(ql2xloginretrycount
, int, S_IRUGO
|S_IRUSR
);
50 MODULE_PARM_DESC(ql2xloginretrycount
,
51 "Specify an alternate value for the NVRAM login retry count.");
53 int ql2xallocfwdump
= 1;
54 module_param(ql2xallocfwdump
, int, S_IRUGO
|S_IRUSR
);
55 MODULE_PARM_DESC(ql2xallocfwdump
,
56 "Option to enable allocation of memory for a firmware dump "
57 "during HBA initialization. Memory allocation requirements "
58 "vary by ISP type. Default is 1 - allocate memory.");
60 int ql2xextended_error_logging
;
61 module_param(ql2xextended_error_logging
, int, S_IRUGO
|S_IWUSR
);
62 MODULE_PARM_DESC(ql2xextended_error_logging
,
63 "Option to enable extended error logging, "
64 "Default is 0 - no logging. 1 - log errors.");
66 static void qla2x00_free_device(scsi_qla_host_t
*);
68 static void qla2x00_config_dma_addressing(scsi_qla_host_t
*ha
);
71 module_param(ql2xfdmienable
, int, S_IRUGO
|S_IRUSR
);
72 MODULE_PARM_DESC(ql2xfdmienable
,
73 "Enables FDMI registratons "
74 "Default is 0 - no FDMI. 1 - perfom FDMI.");
76 #define MAX_Q_DEPTH 32
77 static int ql2xmaxqdepth
= MAX_Q_DEPTH
;
78 module_param(ql2xmaxqdepth
, int, S_IRUGO
|S_IWUSR
);
79 MODULE_PARM_DESC(ql2xmaxqdepth
,
80 "Maximum queue depth to report for target devices.");
82 int ql2xqfullrampup
= 120;
83 module_param(ql2xqfullrampup
, int, S_IRUGO
|S_IWUSR
);
84 MODULE_PARM_DESC(ql2xqfullrampup
,
85 "Number of seconds to wait to begin to ramp-up the queue "
86 "depth for a device after a queue-full condition has been "
87 "detected. Default is 120 seconds.");
90 * SCSI host template entry points
92 static int qla2xxx_slave_configure(struct scsi_device
* device
);
93 static int qla2xxx_slave_alloc(struct scsi_device
*);
94 static int qla2xxx_scan_finished(struct Scsi_Host
*, unsigned long time
);
95 static void qla2xxx_scan_start(struct Scsi_Host
*);
96 static void qla2xxx_slave_destroy(struct scsi_device
*);
97 static int qla2x00_queuecommand(struct scsi_cmnd
*cmd
,
98 void (*fn
)(struct scsi_cmnd
*));
99 static int qla24xx_queuecommand(struct scsi_cmnd
*cmd
,
100 void (*fn
)(struct scsi_cmnd
*));
101 static int qla2xxx_eh_abort(struct scsi_cmnd
*);
102 static int qla2xxx_eh_device_reset(struct scsi_cmnd
*);
103 static int qla2xxx_eh_bus_reset(struct scsi_cmnd
*);
104 static int qla2xxx_eh_host_reset(struct scsi_cmnd
*);
106 static int qla2x00_change_queue_depth(struct scsi_device
*, int);
107 static int qla2x00_change_queue_type(struct scsi_device
*, int);
109 static struct scsi_host_template qla2x00_driver_template
= {
110 .module
= THIS_MODULE
,
111 .name
= QLA2XXX_DRIVER_NAME
,
112 .queuecommand
= qla2x00_queuecommand
,
114 .eh_abort_handler
= qla2xxx_eh_abort
,
115 .eh_device_reset_handler
= qla2xxx_eh_device_reset
,
116 .eh_bus_reset_handler
= qla2xxx_eh_bus_reset
,
117 .eh_host_reset_handler
= qla2xxx_eh_host_reset
,
119 .slave_configure
= qla2xxx_slave_configure
,
121 .slave_alloc
= qla2xxx_slave_alloc
,
122 .slave_destroy
= qla2xxx_slave_destroy
,
123 .scan_finished
= qla2xxx_scan_finished
,
124 .scan_start
= qla2xxx_scan_start
,
125 .change_queue_depth
= qla2x00_change_queue_depth
,
126 .change_queue_type
= qla2x00_change_queue_type
,
129 .use_clustering
= ENABLE_CLUSTERING
,
130 .sg_tablesize
= SG_ALL
,
133 * The RISC allows for each command to transfer (2^32-1) bytes of data,
134 * which equates to 0x800000 sectors.
136 .max_sectors
= 0xFFFF,
137 .shost_attrs
= qla2x00_host_attrs
,
140 struct scsi_host_template qla24xx_driver_template
= {
141 .module
= THIS_MODULE
,
142 .name
= QLA2XXX_DRIVER_NAME
,
143 .queuecommand
= qla24xx_queuecommand
,
145 .eh_abort_handler
= qla2xxx_eh_abort
,
146 .eh_device_reset_handler
= qla2xxx_eh_device_reset
,
147 .eh_bus_reset_handler
= qla2xxx_eh_bus_reset
,
148 .eh_host_reset_handler
= qla2xxx_eh_host_reset
,
150 .slave_configure
= qla2xxx_slave_configure
,
152 .slave_alloc
= qla2xxx_slave_alloc
,
153 .slave_destroy
= qla2xxx_slave_destroy
,
154 .scan_finished
= qla2xxx_scan_finished
,
155 .scan_start
= qla2xxx_scan_start
,
156 .change_queue_depth
= qla2x00_change_queue_depth
,
157 .change_queue_type
= qla2x00_change_queue_type
,
160 .use_clustering
= ENABLE_CLUSTERING
,
161 .sg_tablesize
= SG_ALL
,
163 .max_sectors
= 0xFFFF,
164 .shost_attrs
= qla2x00_host_attrs
,
167 static struct scsi_transport_template
*qla2xxx_transport_template
= NULL
;
168 struct scsi_transport_template
*qla2xxx_transport_vport_template
= NULL
;
170 /* TODO Convert to inlines
176 qla2x00_start_timer(scsi_qla_host_t
*ha
, void *func
, unsigned long interval
)
178 init_timer(&ha
->timer
);
179 ha
->timer
.expires
= jiffies
+ interval
* HZ
;
180 ha
->timer
.data
= (unsigned long)ha
;
181 ha
->timer
.function
= (void (*)(unsigned long))func
;
182 add_timer(&ha
->timer
);
183 ha
->timer_active
= 1;
187 qla2x00_restart_timer(scsi_qla_host_t
*ha
, unsigned long interval
)
189 mod_timer(&ha
->timer
, jiffies
+ interval
* HZ
);
192 static __inline__
void
193 qla2x00_stop_timer(scsi_qla_host_t
*ha
)
195 del_timer_sync(&ha
->timer
);
196 ha
->timer_active
= 0;
199 static int qla2x00_do_dpc(void *data
);
201 static void qla2x00_rst_aen(scsi_qla_host_t
*);
203 static int qla2x00_mem_alloc(scsi_qla_host_t
*);
204 static void qla2x00_mem_free(scsi_qla_host_t
*ha
);
205 static void qla2x00_sp_free_dma(scsi_qla_host_t
*, srb_t
*);
207 /* -------------------------------------------------------------------------- */
210 qla2x00_pci_info_str(struct scsi_qla_host
*ha
, char *str
)
212 static char *pci_bus_modes
[] = {
213 "33", "66", "100", "133",
218 pci_bus
= (ha
->pci_attr
& (BIT_9
| BIT_10
)) >> 9;
221 strcat(str
, pci_bus_modes
[pci_bus
]);
223 pci_bus
= (ha
->pci_attr
& BIT_8
) >> 8;
225 strcat(str
, pci_bus_modes
[pci_bus
]);
227 strcat(str
, " MHz)");
233 qla24xx_pci_info_str(struct scsi_qla_host
*ha
, char *str
)
235 static char *pci_bus_modes
[] = { "33", "66", "100", "133", };
239 pcie_reg
= pci_find_capability(ha
->pdev
, PCI_CAP_ID_EXP
);
242 uint16_t pcie_lstat
, lspeed
, lwidth
;
245 pci_read_config_word(ha
->pdev
, pcie_reg
, &pcie_lstat
);
246 lspeed
= pcie_lstat
& (BIT_0
| BIT_1
| BIT_2
| BIT_3
);
247 lwidth
= (pcie_lstat
&
248 (BIT_4
| BIT_5
| BIT_6
| BIT_7
| BIT_8
| BIT_9
)) >> 4;
250 strcpy(str
, "PCIe (");
252 strcat(str
, "2.5Gb/s ");
253 else if (lspeed
== 2)
254 strcat(str
, "5.0Gb/s ");
256 strcat(str
, "<unknown> ");
257 snprintf(lwstr
, sizeof(lwstr
), "x%d)", lwidth
);
264 pci_bus
= (ha
->pci_attr
& CSRX_PCIX_BUS_MODE_MASK
) >> 8;
265 if (pci_bus
== 0 || pci_bus
== 8) {
267 strcat(str
, pci_bus_modes
[pci_bus
>> 3]);
271 strcat(str
, "Mode 2");
273 strcat(str
, "Mode 1");
275 strcat(str
, pci_bus_modes
[pci_bus
& ~BIT_2
]);
277 strcat(str
, " MHz)");
283 qla2x00_fw_version_str(struct scsi_qla_host
*ha
, char *str
)
287 sprintf(str
, "%d.%02d.%02d ", ha
->fw_major_version
,
288 ha
->fw_minor_version
,
289 ha
->fw_subminor_version
);
291 if (ha
->fw_attributes
& BIT_9
) {
296 switch (ha
->fw_attributes
& 0xFF) {
310 sprintf(un_str
, "(%x)", ha
->fw_attributes
);
314 if (ha
->fw_attributes
& 0x100)
321 qla24xx_fw_version_str(struct scsi_qla_host
*ha
, char *str
)
323 sprintf(str
, "%d.%02d.%02d ", ha
->fw_major_version
,
324 ha
->fw_minor_version
,
325 ha
->fw_subminor_version
);
327 if (ha
->fw_attributes
& BIT_0
)
328 strcat(str
, "[Class 2] ");
329 if (ha
->fw_attributes
& BIT_1
)
330 strcat(str
, "[IP] ");
331 if (ha
->fw_attributes
& BIT_2
)
332 strcat(str
, "[Multi-ID] ");
333 if (ha
->fw_attributes
& BIT_3
)
334 strcat(str
, "[SB-2] ");
335 if (ha
->fw_attributes
& BIT_4
)
336 strcat(str
, "[T10 CRC] ");
337 if (ha
->fw_attributes
& BIT_5
)
338 strcat(str
, "[VI] ");
339 if (ha
->fw_attributes
& BIT_13
)
340 strcat(str
, "[Experimental]");
344 static inline srb_t
*
345 qla2x00_get_new_sp(scsi_qla_host_t
*ha
, fc_port_t
*fcport
,
346 struct scsi_cmnd
*cmd
, void (*done
)(struct scsi_cmnd
*))
350 sp
= mempool_alloc(ha
->srb_mempool
, GFP_ATOMIC
);
358 CMD_SP(cmd
) = (void *)sp
;
359 cmd
->scsi_done
= done
;
365 qla2x00_queuecommand(struct scsi_cmnd
*cmd
, void (*done
)(struct scsi_cmnd
*))
367 scsi_qla_host_t
*ha
= shost_priv(cmd
->device
->host
);
368 fc_port_t
*fcport
= (struct fc_port
*) cmd
->device
->hostdata
;
369 struct fc_rport
*rport
= starget_to_rport(scsi_target(cmd
->device
));
373 if (unlikely(pci_channel_offline(ha
->pdev
))) {
374 cmd
->result
= DID_REQUEUE
<< 16;
375 goto qc_fail_command
;
378 rval
= fc_remote_port_chkready(rport
);
381 goto qc_fail_command
;
384 /* Close window on fcport/rport state-transitioning. */
385 if (!*(fc_port_t
**)rport
->dd_data
) {
386 cmd
->result
= DID_IMM_RETRY
<< 16;
387 goto qc_fail_command
;
390 if (atomic_read(&fcport
->state
) != FCS_ONLINE
) {
391 if (atomic_read(&fcport
->state
) == FCS_DEVICE_DEAD
||
392 atomic_read(&ha
->loop_state
) == LOOP_DEAD
) {
393 cmd
->result
= DID_NO_CONNECT
<< 16;
394 goto qc_fail_command
;
399 spin_unlock_irq(ha
->host
->host_lock
);
401 sp
= qla2x00_get_new_sp(ha
, fcport
, cmd
, done
);
403 goto qc_host_busy_lock
;
405 rval
= qla2x00_start_scsi(sp
);
406 if (rval
!= QLA_SUCCESS
)
407 goto qc_host_busy_free_sp
;
409 spin_lock_irq(ha
->host
->host_lock
);
413 qc_host_busy_free_sp
:
414 qla2x00_sp_free_dma(ha
, sp
);
415 mempool_free(sp
, ha
->srb_mempool
);
418 spin_lock_irq(ha
->host
->host_lock
);
421 return SCSI_MLQUEUE_HOST_BUSY
;
431 qla24xx_queuecommand(struct scsi_cmnd
*cmd
, void (*done
)(struct scsi_cmnd
*))
433 scsi_qla_host_t
*ha
= shost_priv(cmd
->device
->host
);
434 fc_port_t
*fcport
= (struct fc_port
*) cmd
->device
->hostdata
;
435 struct fc_rport
*rport
= starget_to_rport(scsi_target(cmd
->device
));
438 scsi_qla_host_t
*pha
= to_qla_parent(ha
);
440 if (unlikely(pci_channel_offline(ha
->pdev
))) {
441 cmd
->result
= DID_REQUEUE
<< 16;
442 goto qc24_fail_command
;
445 rval
= fc_remote_port_chkready(rport
);
448 goto qc24_fail_command
;
451 /* Close window on fcport/rport state-transitioning. */
452 if (!*(fc_port_t
**)rport
->dd_data
) {
453 cmd
->result
= DID_IMM_RETRY
<< 16;
454 goto qc24_fail_command
;
457 if (atomic_read(&fcport
->state
) != FCS_ONLINE
) {
458 if (atomic_read(&fcport
->state
) == FCS_DEVICE_DEAD
||
459 atomic_read(&pha
->loop_state
) == LOOP_DEAD
) {
460 cmd
->result
= DID_NO_CONNECT
<< 16;
461 goto qc24_fail_command
;
466 spin_unlock_irq(ha
->host
->host_lock
);
468 sp
= qla2x00_get_new_sp(pha
, fcport
, cmd
, done
);
470 goto qc24_host_busy_lock
;
472 rval
= qla24xx_start_scsi(sp
);
473 if (rval
!= QLA_SUCCESS
)
474 goto qc24_host_busy_free_sp
;
476 spin_lock_irq(ha
->host
->host_lock
);
480 qc24_host_busy_free_sp
:
481 qla2x00_sp_free_dma(pha
, sp
);
482 mempool_free(sp
, pha
->srb_mempool
);
485 spin_lock_irq(ha
->host
->host_lock
);
488 return SCSI_MLQUEUE_HOST_BUSY
;
498 * qla2x00_eh_wait_on_command
499 * Waits for the command to be returned by the Firmware for some
503 * ha = actual ha whose done queue will contain the command
504 * returned by firmware.
505 * cmd = Scsi Command to wait on.
506 * flag = Abort/Reset(Bus or Device Reset)
513 qla2x00_eh_wait_on_command(scsi_qla_host_t
*ha
, struct scsi_cmnd
*cmd
)
515 #define ABORT_POLLING_PERIOD 1000
516 #define ABORT_WAIT_ITER ((10 * 1000) / (ABORT_POLLING_PERIOD))
517 unsigned long wait_iter
= ABORT_WAIT_ITER
;
518 int ret
= QLA_SUCCESS
;
520 while (CMD_SP(cmd
)) {
521 msleep(ABORT_POLLING_PERIOD
);
527 ret
= QLA_FUNCTION_FAILED
;
533 * qla2x00_wait_for_hba_online
534 * Wait till the HBA is online after going through
535 * <= MAX_RETRIES_OF_ISP_ABORT or
536 * finally HBA is disabled ie marked offline
539 * ha - pointer to host adapter structure
542 * Does context switching-Release SPIN_LOCK
543 * (if any) before calling this routine.
546 * Success (Adapter is online) : 0
547 * Failed (Adapter is offline/disabled) : 1
550 qla2x00_wait_for_hba_online(scsi_qla_host_t
*ha
)
553 unsigned long wait_online
;
554 scsi_qla_host_t
*pha
= to_qla_parent(ha
);
556 wait_online
= jiffies
+ (MAX_LOOP_TIMEOUT
* HZ
);
557 while (((test_bit(ISP_ABORT_NEEDED
, &pha
->dpc_flags
)) ||
558 test_bit(ABORT_ISP_ACTIVE
, &pha
->dpc_flags
) ||
559 test_bit(ISP_ABORT_RETRY
, &pha
->dpc_flags
) ||
560 pha
->dpc_active
) && time_before(jiffies
, wait_online
)) {
564 if (pha
->flags
.online
)
565 return_status
= QLA_SUCCESS
;
567 return_status
= QLA_FUNCTION_FAILED
;
569 DEBUG2(printk("%s return_status=%d\n",__func__
,return_status
));
571 return (return_status
);
575 * qla2x00_wait_for_loop_ready
576 * Wait for MAX_LOOP_TIMEOUT(5 min) value for loop
577 * to be in LOOP_READY state.
579 * ha - pointer to host adapter structure
582 * Does context switching-Release SPIN_LOCK
583 * (if any) before calling this routine.
587 * Success (LOOP_READY) : 0
588 * Failed (LOOP_NOT_READY) : 1
591 qla2x00_wait_for_loop_ready(scsi_qla_host_t
*ha
)
593 int return_status
= QLA_SUCCESS
;
594 unsigned long loop_timeout
;
595 scsi_qla_host_t
*pha
= to_qla_parent(ha
);
597 /* wait for 5 min at the max for loop to be ready */
598 loop_timeout
= jiffies
+ (MAX_LOOP_TIMEOUT
* HZ
);
600 while ((!atomic_read(&pha
->loop_down_timer
) &&
601 atomic_read(&pha
->loop_state
) == LOOP_DOWN
) ||
602 atomic_read(&pha
->loop_state
) != LOOP_READY
) {
603 if (atomic_read(&pha
->loop_state
) == LOOP_DEAD
) {
604 return_status
= QLA_FUNCTION_FAILED
;
608 if (time_after_eq(jiffies
, loop_timeout
)) {
609 return_status
= QLA_FUNCTION_FAILED
;
613 return (return_status
);
617 qla2x00_block_error_handler(struct scsi_cmnd
*cmnd
)
619 struct Scsi_Host
*shost
= cmnd
->device
->host
;
620 struct fc_rport
*rport
= starget_to_rport(scsi_target(cmnd
->device
));
623 spin_lock_irqsave(shost
->host_lock
, flags
);
624 while (rport
->port_state
== FC_PORTSTATE_BLOCKED
) {
625 spin_unlock_irqrestore(shost
->host_lock
, flags
);
627 spin_lock_irqsave(shost
->host_lock
, flags
);
629 spin_unlock_irqrestore(shost
->host_lock
, flags
);
633 /**************************************************************************
637 * The abort function will abort the specified command.
640 * cmd = Linux SCSI command packet to be aborted.
643 * Either SUCCESS or FAILED.
646 * Only return FAILED if command not returned by firmware.
647 **************************************************************************/
649 qla2xxx_eh_abort(struct scsi_cmnd
*cmd
)
651 scsi_qla_host_t
*ha
= shost_priv(cmd
->device
->host
);
654 unsigned int id
, lun
;
655 unsigned long serial
;
658 scsi_qla_host_t
*pha
= to_qla_parent(ha
);
660 qla2x00_block_error_handler(cmd
);
667 id
= cmd
->device
->id
;
668 lun
= cmd
->device
->lun
;
669 serial
= cmd
->serial_number
;
671 /* Check active list for command command. */
672 spin_lock_irqsave(&pha
->hardware_lock
, flags
);
673 for (i
= 1; i
< MAX_OUTSTANDING_COMMANDS
; i
++) {
674 sp
= pha
->outstanding_cmds
[i
];
682 DEBUG2(printk("%s(%ld): aborting sp %p from RISC. pid=%ld.\n",
683 __func__
, ha
->host_no
, sp
, serial
));
685 spin_unlock_irqrestore(&pha
->hardware_lock
, flags
);
686 if (ha
->isp_ops
->abort_command(ha
, sp
)) {
687 DEBUG2(printk("%s(%ld): abort_command "
688 "mbx failed.\n", __func__
, ha
->host_no
));
690 DEBUG3(printk("%s(%ld): abort_command "
691 "mbx success.\n", __func__
, ha
->host_no
));
694 spin_lock_irqsave(&pha
->hardware_lock
, flags
);
698 spin_unlock_irqrestore(&pha
->hardware_lock
, flags
);
700 /* Wait for the command to be returned. */
702 if (qla2x00_eh_wait_on_command(ha
, cmd
) != QLA_SUCCESS
) {
703 qla_printk(KERN_ERR
, ha
,
704 "scsi(%ld:%d:%d): Abort handler timed out -- %lx "
705 "%x.\n", ha
->host_no
, id
, lun
, serial
, ret
);
710 qla_printk(KERN_INFO
, ha
,
711 "scsi(%ld:%d:%d): Abort command issued -- %d %lx %x.\n",
712 ha
->host_no
, id
, lun
, wait
, serial
, ret
);
717 /**************************************************************************
718 * qla2x00_eh_wait_for_pending_target_commands
721 * Waits for all the commands to come back from the specified target.
724 * ha - pointer to scsi_qla_host structure.
727 * Either SUCCESS or FAILED.
730 **************************************************************************/
732 qla2x00_eh_wait_for_pending_target_commands(scsi_qla_host_t
*ha
, unsigned int t
)
737 struct scsi_cmnd
*cmd
;
739 scsi_qla_host_t
*pha
= to_qla_parent(ha
);
744 * Waiting for all commands for the designated target in the active
747 for (cnt
= 1; cnt
< MAX_OUTSTANDING_COMMANDS
; cnt
++) {
748 spin_lock_irqsave(&pha
->hardware_lock
, flags
);
749 sp
= pha
->outstanding_cmds
[cnt
];
752 spin_unlock_irqrestore(&pha
->hardware_lock
, flags
);
753 if (cmd
->device
->id
== t
&&
754 ha
->vp_idx
== sp
->ha
->vp_idx
) {
755 if (!qla2x00_eh_wait_on_command(ha
, cmd
)) {
761 spin_unlock_irqrestore(&pha
->hardware_lock
, flags
);
768 /**************************************************************************
769 * qla2xxx_eh_device_reset
772 * The device reset function will reset the target and abort any
773 * executing commands.
775 * NOTE: The use of SP is undefined within this context. Do *NOT*
776 * attempt to use this value, even if you determine it is
780 * cmd = Linux SCSI command packet of the command that cause the
784 * SUCCESS/FAILURE (defined as macro in scsi.h).
786 **************************************************************************/
788 qla2xxx_eh_device_reset(struct scsi_cmnd
*cmd
)
790 scsi_qla_host_t
*ha
= shost_priv(cmd
->device
->host
);
791 fc_port_t
*fcport
= (struct fc_port
*) cmd
->device
->hostdata
;
793 unsigned int id
, lun
;
794 unsigned long serial
;
796 qla2x00_block_error_handler(cmd
);
798 id
= cmd
->device
->id
;
799 lun
= cmd
->device
->lun
;
800 serial
= cmd
->serial_number
;
805 qla_printk(KERN_INFO
, ha
,
806 "scsi(%ld:%d:%d): DEVICE RESET ISSUED.\n", ha
->host_no
, id
, lun
);
808 if (qla2x00_wait_for_hba_online(ha
) != QLA_SUCCESS
)
809 goto eh_dev_reset_done
;
811 if (qla2x00_wait_for_loop_ready(ha
) == QLA_SUCCESS
) {
812 if (ha
->isp_ops
->abort_target(fcport
) == 0)
815 DEBUG2(printk(KERN_INFO
816 "%s failed: loop not ready\n",__func__
));
820 DEBUG3(printk("%s(%ld): device reset failed\n",
821 __func__
, ha
->host_no
));
822 qla_printk(KERN_INFO
, ha
, "%s: device reset failed\n",
825 goto eh_dev_reset_done
;
828 /* Flush outstanding commands. */
829 if (qla2x00_eh_wait_for_pending_target_commands(ha
, id
))
832 DEBUG3(printk("%s(%ld): failed while waiting for commands\n",
833 __func__
, ha
->host_no
));
834 qla_printk(KERN_INFO
, ha
,
835 "%s: failed while waiting for commands\n", __func__
);
837 qla_printk(KERN_INFO
, ha
,
838 "scsi(%ld:%d:%d): DEVICE RESET SUCCEEDED.\n", ha
->host_no
,
844 /**************************************************************************
845 * qla2x00_eh_wait_for_pending_commands
848 * Waits for all the commands to come back from the specified host.
851 * ha - pointer to scsi_qla_host structure.
858 **************************************************************************/
860 qla2x00_eh_wait_for_pending_commands(scsi_qla_host_t
*ha
)
865 struct scsi_cmnd
*cmd
;
871 * Waiting for all commands for the designated target in the active
874 for (cnt
= 1; cnt
< MAX_OUTSTANDING_COMMANDS
; cnt
++) {
875 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
876 sp
= ha
->outstanding_cmds
[cnt
];
879 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
880 status
= qla2x00_eh_wait_on_command(ha
, cmd
);
885 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
892 /**************************************************************************
893 * qla2xxx_eh_bus_reset
896 * The bus reset function will reset the bus and abort any executing
900 * cmd = Linux SCSI command packet of the command that cause the
904 * SUCCESS/FAILURE (defined as macro in scsi.h).
906 **************************************************************************/
908 qla2xxx_eh_bus_reset(struct scsi_cmnd
*cmd
)
910 scsi_qla_host_t
*ha
= shost_priv(cmd
->device
->host
);
911 scsi_qla_host_t
*pha
= to_qla_parent(ha
);
912 fc_port_t
*fcport
= (struct fc_port
*) cmd
->device
->hostdata
;
914 unsigned int id
, lun
;
915 unsigned long serial
;
917 qla2x00_block_error_handler(cmd
);
919 id
= cmd
->device
->id
;
920 lun
= cmd
->device
->lun
;
921 serial
= cmd
->serial_number
;
926 qla_printk(KERN_INFO
, ha
,
927 "scsi(%ld:%d:%d): LOOP RESET ISSUED.\n", ha
->host_no
, id
, lun
);
929 if (qla2x00_wait_for_hba_online(ha
) != QLA_SUCCESS
) {
930 DEBUG2(printk("%s failed:board disabled\n",__func__
));
931 goto eh_bus_reset_done
;
934 if (qla2x00_wait_for_loop_ready(ha
) == QLA_SUCCESS
) {
935 if (qla2x00_loop_reset(ha
) == QLA_SUCCESS
)
939 goto eh_bus_reset_done
;
941 /* Flush outstanding commands. */
942 if (!qla2x00_eh_wait_for_pending_commands(pha
))
946 qla_printk(KERN_INFO
, ha
, "%s: reset %s\n", __func__
,
947 (ret
== FAILED
) ? "failed" : "succeded");
952 /**************************************************************************
953 * qla2xxx_eh_host_reset
956 * The reset function will reset the Adapter.
959 * cmd = Linux SCSI command packet of the command that cause the
963 * Either SUCCESS or FAILED.
966 **************************************************************************/
968 qla2xxx_eh_host_reset(struct scsi_cmnd
*cmd
)
970 scsi_qla_host_t
*ha
= shost_priv(cmd
->device
->host
);
971 fc_port_t
*fcport
= (struct fc_port
*) cmd
->device
->hostdata
;
973 unsigned int id
, lun
;
974 unsigned long serial
;
975 scsi_qla_host_t
*pha
= to_qla_parent(ha
);
977 qla2x00_block_error_handler(cmd
);
979 id
= cmd
->device
->id
;
980 lun
= cmd
->device
->lun
;
981 serial
= cmd
->serial_number
;
986 qla_printk(KERN_INFO
, ha
,
987 "scsi(%ld:%d:%d): ADAPTER RESET ISSUED.\n", ha
->host_no
, id
, lun
);
989 if (qla2x00_wait_for_hba_online(ha
) != QLA_SUCCESS
)
990 goto eh_host_reset_lock
;
993 * Fixme-may be dpc thread is active and processing
994 * loop_resync,so wait a while for it to
995 * be completed and then issue big hammer.Otherwise
996 * it may cause I/O failure as big hammer marks the
997 * devices as lost kicking of the port_down_timer
998 * while dpc is stuck for the mailbox to complete.
1000 qla2x00_wait_for_loop_ready(ha
);
1001 set_bit(ABORT_ISP_ACTIVE
, &pha
->dpc_flags
);
1002 if (qla2x00_abort_isp(pha
)) {
1003 clear_bit(ABORT_ISP_ACTIVE
, &pha
->dpc_flags
);
1004 /* failed. schedule dpc to try */
1005 set_bit(ISP_ABORT_NEEDED
, &pha
->dpc_flags
);
1007 if (qla2x00_wait_for_hba_online(ha
) != QLA_SUCCESS
)
1008 goto eh_host_reset_lock
;
1010 clear_bit(ABORT_ISP_ACTIVE
, &pha
->dpc_flags
);
1012 /* Waiting for our command in done_queue to be returned to OS.*/
1013 if (qla2x00_eh_wait_for_pending_commands(pha
))
1017 qla2x00_vp_abort_isp(ha
);
1020 qla_printk(KERN_INFO
, ha
, "%s: reset %s\n", __func__
,
1021 (ret
== FAILED
) ? "failed" : "succeded");
1027 * qla2x00_loop_reset
1031 * ha = adapter block pointer.
1037 qla2x00_loop_reset(scsi_qla_host_t
*ha
)
1040 struct fc_port
*fcport
;
1042 if (ha
->flags
.enable_lip_full_login
) {
1043 ret
= qla2x00_full_login_lip(ha
);
1044 if (ret
!= QLA_SUCCESS
) {
1045 DEBUG2_3(printk("%s(%ld): bus_reset failed: "
1046 "full_login_lip=%d.\n", __func__
, ha
->host_no
,
1049 atomic_set(&ha
->loop_state
, LOOP_DOWN
);
1050 atomic_set(&ha
->loop_down_timer
, LOOP_DOWN_TIME
);
1051 qla2x00_mark_all_devices_lost(ha
, 0);
1052 qla2x00_wait_for_loop_ready(ha
);
1055 if (ha
->flags
.enable_lip_reset
) {
1056 ret
= qla2x00_lip_reset(ha
);
1057 if (ret
!= QLA_SUCCESS
) {
1058 DEBUG2_3(printk("%s(%ld): bus_reset failed: "
1059 "lip_reset=%d.\n", __func__
, ha
->host_no
, ret
));
1061 qla2x00_wait_for_loop_ready(ha
);
1064 if (ha
->flags
.enable_target_reset
) {
1065 list_for_each_entry(fcport
, &ha
->fcports
, list
) {
1066 if (fcport
->port_type
!= FCT_TARGET
)
1069 ret
= ha
->isp_ops
->abort_target(fcport
);
1070 if (ret
!= QLA_SUCCESS
) {
1071 DEBUG2_3(printk("%s(%ld): bus_reset failed: "
1072 "target_reset=%d d_id=%x.\n", __func__
,
1073 ha
->host_no
, ret
, fcport
->d_id
.b24
));
1078 /* Issue marker command only when we are going to start the I/O */
1079 ha
->marker_needed
= 1;
1085 qla2x00_abort_all_cmds(scsi_qla_host_t
*ha
, int res
)
1088 unsigned long flags
;
1091 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
1092 for (cnt
= 1; cnt
< MAX_OUTSTANDING_COMMANDS
; cnt
++) {
1093 sp
= ha
->outstanding_cmds
[cnt
];
1095 ha
->outstanding_cmds
[cnt
] = NULL
;
1097 sp
->cmd
->result
= res
;
1098 sp
->cmd
->host_scribble
= (unsigned char *)NULL
;
1099 qla2x00_sp_compl(ha
, sp
);
1102 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
1106 qla2xxx_slave_alloc(struct scsi_device
*sdev
)
1108 struct fc_rport
*rport
= starget_to_rport(scsi_target(sdev
));
1110 if (!rport
|| fc_remote_port_chkready(rport
))
1113 sdev
->hostdata
= *(fc_port_t
**)rport
->dd_data
;
1119 qla2xxx_slave_configure(struct scsi_device
*sdev
)
1121 scsi_qla_host_t
*ha
= shost_priv(sdev
->host
);
1122 struct fc_rport
*rport
= starget_to_rport(sdev
->sdev_target
);
1124 if (sdev
->tagged_supported
)
1125 scsi_activate_tcq(sdev
, ha
->max_q_depth
);
1127 scsi_deactivate_tcq(sdev
, ha
->max_q_depth
);
1129 rport
->dev_loss_tmo
= ha
->port_down_retry_count
+ 5;
1135 qla2xxx_slave_destroy(struct scsi_device
*sdev
)
1137 sdev
->hostdata
= NULL
;
1141 qla2x00_change_queue_depth(struct scsi_device
*sdev
, int qdepth
)
1143 scsi_adjust_queue_depth(sdev
, scsi_get_tag_type(sdev
), qdepth
);
1144 return sdev
->queue_depth
;
1148 qla2x00_change_queue_type(struct scsi_device
*sdev
, int tag_type
)
1150 if (sdev
->tagged_supported
) {
1151 scsi_set_tag_type(sdev
, tag_type
);
1153 scsi_activate_tcq(sdev
, sdev
->queue_depth
);
1155 scsi_deactivate_tcq(sdev
, sdev
->queue_depth
);
1163 * qla2x00_config_dma_addressing() - Configure OS DMA addressing method.
1166 * At exit, the @ha's flags.enable_64bit_addressing set to indicated
1167 * supported addressing method.
1170 qla2x00_config_dma_addressing(scsi_qla_host_t
*ha
)
1172 /* Assume a 32bit DMA mask. */
1173 ha
->flags
.enable_64bit_addressing
= 0;
1175 if (!dma_set_mask(&ha
->pdev
->dev
, DMA_64BIT_MASK
)) {
1176 /* Any upper-dword bits set? */
1177 if (MSD(dma_get_required_mask(&ha
->pdev
->dev
)) &&
1178 !pci_set_consistent_dma_mask(ha
->pdev
, DMA_64BIT_MASK
)) {
1179 /* Ok, a 64bit DMA mask is applicable. */
1180 ha
->flags
.enable_64bit_addressing
= 1;
1181 ha
->isp_ops
->calc_req_entries
= qla2x00_calc_iocbs_64
;
1182 ha
->isp_ops
->build_iocbs
= qla2x00_build_scsi_iocbs_64
;
1187 dma_set_mask(&ha
->pdev
->dev
, DMA_32BIT_MASK
);
1188 pci_set_consistent_dma_mask(ha
->pdev
, DMA_32BIT_MASK
);
1192 qla2x00_enable_intrs(scsi_qla_host_t
*ha
)
1194 unsigned long flags
= 0;
1195 struct device_reg_2xxx __iomem
*reg
= &ha
->iobase
->isp
;
1197 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
1198 ha
->interrupts_on
= 1;
1199 /* enable risc and host interrupts */
1200 WRT_REG_WORD(®
->ictrl
, ICR_EN_INT
| ICR_EN_RISC
);
1201 RD_REG_WORD(®
->ictrl
);
1202 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
1207 qla2x00_disable_intrs(scsi_qla_host_t
*ha
)
1209 unsigned long flags
= 0;
1210 struct device_reg_2xxx __iomem
*reg
= &ha
->iobase
->isp
;
1212 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
1213 ha
->interrupts_on
= 0;
1214 /* disable risc and host interrupts */
1215 WRT_REG_WORD(®
->ictrl
, 0);
1216 RD_REG_WORD(®
->ictrl
);
1217 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
1221 qla24xx_enable_intrs(scsi_qla_host_t
*ha
)
1223 unsigned long flags
= 0;
1224 struct device_reg_24xx __iomem
*reg
= &ha
->iobase
->isp24
;
1226 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
1227 ha
->interrupts_on
= 1;
1228 WRT_REG_DWORD(®
->ictrl
, ICRX_EN_RISC_INT
);
1229 RD_REG_DWORD(®
->ictrl
);
1230 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
1234 qla24xx_disable_intrs(scsi_qla_host_t
*ha
)
1236 unsigned long flags
= 0;
1237 struct device_reg_24xx __iomem
*reg
= &ha
->iobase
->isp24
;
1239 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
1240 ha
->interrupts_on
= 0;
1241 WRT_REG_DWORD(®
->ictrl
, 0);
1242 RD_REG_DWORD(®
->ictrl
);
1243 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
1246 static struct isp_operations qla2100_isp_ops
= {
1247 .pci_config
= qla2100_pci_config
,
1248 .reset_chip
= qla2x00_reset_chip
,
1249 .chip_diag
= qla2x00_chip_diag
,
1250 .config_rings
= qla2x00_config_rings
,
1251 .reset_adapter
= qla2x00_reset_adapter
,
1252 .nvram_config
= qla2x00_nvram_config
,
1253 .update_fw_options
= qla2x00_update_fw_options
,
1254 .load_risc
= qla2x00_load_risc
,
1255 .pci_info_str
= qla2x00_pci_info_str
,
1256 .fw_version_str
= qla2x00_fw_version_str
,
1257 .intr_handler
= qla2100_intr_handler
,
1258 .enable_intrs
= qla2x00_enable_intrs
,
1259 .disable_intrs
= qla2x00_disable_intrs
,
1260 .abort_command
= qla2x00_abort_command
,
1261 .abort_target
= qla2x00_abort_target
,
1262 .fabric_login
= qla2x00_login_fabric
,
1263 .fabric_logout
= qla2x00_fabric_logout
,
1264 .calc_req_entries
= qla2x00_calc_iocbs_32
,
1265 .build_iocbs
= qla2x00_build_scsi_iocbs_32
,
1266 .prep_ms_iocb
= qla2x00_prep_ms_iocb
,
1267 .prep_ms_fdmi_iocb
= qla2x00_prep_ms_fdmi_iocb
,
1268 .read_nvram
= qla2x00_read_nvram_data
,
1269 .write_nvram
= qla2x00_write_nvram_data
,
1270 .fw_dump
= qla2100_fw_dump
,
1273 .beacon_blink
= NULL
,
1274 .read_optrom
= qla2x00_read_optrom_data
,
1275 .write_optrom
= qla2x00_write_optrom_data
,
1276 .get_flash_version
= qla2x00_get_flash_version
,
1279 static struct isp_operations qla2300_isp_ops
= {
1280 .pci_config
= qla2300_pci_config
,
1281 .reset_chip
= qla2x00_reset_chip
,
1282 .chip_diag
= qla2x00_chip_diag
,
1283 .config_rings
= qla2x00_config_rings
,
1284 .reset_adapter
= qla2x00_reset_adapter
,
1285 .nvram_config
= qla2x00_nvram_config
,
1286 .update_fw_options
= qla2x00_update_fw_options
,
1287 .load_risc
= qla2x00_load_risc
,
1288 .pci_info_str
= qla2x00_pci_info_str
,
1289 .fw_version_str
= qla2x00_fw_version_str
,
1290 .intr_handler
= qla2300_intr_handler
,
1291 .enable_intrs
= qla2x00_enable_intrs
,
1292 .disable_intrs
= qla2x00_disable_intrs
,
1293 .abort_command
= qla2x00_abort_command
,
1294 .abort_target
= qla2x00_abort_target
,
1295 .fabric_login
= qla2x00_login_fabric
,
1296 .fabric_logout
= qla2x00_fabric_logout
,
1297 .calc_req_entries
= qla2x00_calc_iocbs_32
,
1298 .build_iocbs
= qla2x00_build_scsi_iocbs_32
,
1299 .prep_ms_iocb
= qla2x00_prep_ms_iocb
,
1300 .prep_ms_fdmi_iocb
= qla2x00_prep_ms_fdmi_iocb
,
1301 .read_nvram
= qla2x00_read_nvram_data
,
1302 .write_nvram
= qla2x00_write_nvram_data
,
1303 .fw_dump
= qla2300_fw_dump
,
1304 .beacon_on
= qla2x00_beacon_on
,
1305 .beacon_off
= qla2x00_beacon_off
,
1306 .beacon_blink
= qla2x00_beacon_blink
,
1307 .read_optrom
= qla2x00_read_optrom_data
,
1308 .write_optrom
= qla2x00_write_optrom_data
,
1309 .get_flash_version
= qla2x00_get_flash_version
,
1312 static struct isp_operations qla24xx_isp_ops
= {
1313 .pci_config
= qla24xx_pci_config
,
1314 .reset_chip
= qla24xx_reset_chip
,
1315 .chip_diag
= qla24xx_chip_diag
,
1316 .config_rings
= qla24xx_config_rings
,
1317 .reset_adapter
= qla24xx_reset_adapter
,
1318 .nvram_config
= qla24xx_nvram_config
,
1319 .update_fw_options
= qla24xx_update_fw_options
,
1320 .load_risc
= qla24xx_load_risc
,
1321 .pci_info_str
= qla24xx_pci_info_str
,
1322 .fw_version_str
= qla24xx_fw_version_str
,
1323 .intr_handler
= qla24xx_intr_handler
,
1324 .enable_intrs
= qla24xx_enable_intrs
,
1325 .disable_intrs
= qla24xx_disable_intrs
,
1326 .abort_command
= qla24xx_abort_command
,
1327 .abort_target
= qla24xx_abort_target
,
1328 .fabric_login
= qla24xx_login_fabric
,
1329 .fabric_logout
= qla24xx_fabric_logout
,
1330 .calc_req_entries
= NULL
,
1331 .build_iocbs
= NULL
,
1332 .prep_ms_iocb
= qla24xx_prep_ms_iocb
,
1333 .prep_ms_fdmi_iocb
= qla24xx_prep_ms_fdmi_iocb
,
1334 .read_nvram
= qla24xx_read_nvram_data
,
1335 .write_nvram
= qla24xx_write_nvram_data
,
1336 .fw_dump
= qla24xx_fw_dump
,
1337 .beacon_on
= qla24xx_beacon_on
,
1338 .beacon_off
= qla24xx_beacon_off
,
1339 .beacon_blink
= qla24xx_beacon_blink
,
1340 .read_optrom
= qla24xx_read_optrom_data
,
1341 .write_optrom
= qla24xx_write_optrom_data
,
1342 .get_flash_version
= qla24xx_get_flash_version
,
1345 static struct isp_operations qla25xx_isp_ops
= {
1346 .pci_config
= qla25xx_pci_config
,
1347 .reset_chip
= qla24xx_reset_chip
,
1348 .chip_diag
= qla24xx_chip_diag
,
1349 .config_rings
= qla24xx_config_rings
,
1350 .reset_adapter
= qla24xx_reset_adapter
,
1351 .nvram_config
= qla24xx_nvram_config
,
1352 .update_fw_options
= qla24xx_update_fw_options
,
1353 .load_risc
= qla24xx_load_risc
,
1354 .pci_info_str
= qla24xx_pci_info_str
,
1355 .fw_version_str
= qla24xx_fw_version_str
,
1356 .intr_handler
= qla24xx_intr_handler
,
1357 .enable_intrs
= qla24xx_enable_intrs
,
1358 .disable_intrs
= qla24xx_disable_intrs
,
1359 .abort_command
= qla24xx_abort_command
,
1360 .abort_target
= qla24xx_abort_target
,
1361 .fabric_login
= qla24xx_login_fabric
,
1362 .fabric_logout
= qla24xx_fabric_logout
,
1363 .calc_req_entries
= NULL
,
1364 .build_iocbs
= NULL
,
1365 .prep_ms_iocb
= qla24xx_prep_ms_iocb
,
1366 .prep_ms_fdmi_iocb
= qla24xx_prep_ms_fdmi_iocb
,
1367 .read_nvram
= qla25xx_read_nvram_data
,
1368 .write_nvram
= qla25xx_write_nvram_data
,
1369 .fw_dump
= qla25xx_fw_dump
,
1370 .beacon_on
= qla24xx_beacon_on
,
1371 .beacon_off
= qla24xx_beacon_off
,
1372 .beacon_blink
= qla24xx_beacon_blink
,
1373 .read_optrom
= qla25xx_read_optrom_data
,
1374 .write_optrom
= qla24xx_write_optrom_data
,
1375 .get_flash_version
= qla24xx_get_flash_version
,
1379 qla2x00_set_isp_flags(scsi_qla_host_t
*ha
)
1381 ha
->device_type
= DT_EXTENDED_IDS
;
1382 switch (ha
->pdev
->device
) {
1383 case PCI_DEVICE_ID_QLOGIC_ISP2100
:
1384 ha
->device_type
|= DT_ISP2100
;
1385 ha
->device_type
&= ~DT_EXTENDED_IDS
;
1386 ha
->fw_srisc_address
= RISC_START_ADDRESS_2100
;
1388 case PCI_DEVICE_ID_QLOGIC_ISP2200
:
1389 ha
->device_type
|= DT_ISP2200
;
1390 ha
->device_type
&= ~DT_EXTENDED_IDS
;
1391 ha
->fw_srisc_address
= RISC_START_ADDRESS_2100
;
1393 case PCI_DEVICE_ID_QLOGIC_ISP2300
:
1394 ha
->device_type
|= DT_ISP2300
;
1395 ha
->device_type
|= DT_ZIO_SUPPORTED
;
1396 ha
->fw_srisc_address
= RISC_START_ADDRESS_2300
;
1398 case PCI_DEVICE_ID_QLOGIC_ISP2312
:
1399 ha
->device_type
|= DT_ISP2312
;
1400 ha
->device_type
|= DT_ZIO_SUPPORTED
;
1401 ha
->fw_srisc_address
= RISC_START_ADDRESS_2300
;
1403 case PCI_DEVICE_ID_QLOGIC_ISP2322
:
1404 ha
->device_type
|= DT_ISP2322
;
1405 ha
->device_type
|= DT_ZIO_SUPPORTED
;
1406 if (ha
->pdev
->subsystem_vendor
== 0x1028 &&
1407 ha
->pdev
->subsystem_device
== 0x0170)
1408 ha
->device_type
|= DT_OEM_001
;
1409 ha
->fw_srisc_address
= RISC_START_ADDRESS_2300
;
1411 case PCI_DEVICE_ID_QLOGIC_ISP6312
:
1412 ha
->device_type
|= DT_ISP6312
;
1413 ha
->fw_srisc_address
= RISC_START_ADDRESS_2300
;
1415 case PCI_DEVICE_ID_QLOGIC_ISP6322
:
1416 ha
->device_type
|= DT_ISP6322
;
1417 ha
->fw_srisc_address
= RISC_START_ADDRESS_2300
;
1419 case PCI_DEVICE_ID_QLOGIC_ISP2422
:
1420 ha
->device_type
|= DT_ISP2422
;
1421 ha
->device_type
|= DT_ZIO_SUPPORTED
;
1422 ha
->device_type
|= DT_FWI2
;
1423 ha
->device_type
|= DT_IIDMA
;
1424 ha
->fw_srisc_address
= RISC_START_ADDRESS_2400
;
1426 case PCI_DEVICE_ID_QLOGIC_ISP2432
:
1427 ha
->device_type
|= DT_ISP2432
;
1428 ha
->device_type
|= DT_ZIO_SUPPORTED
;
1429 ha
->device_type
|= DT_FWI2
;
1430 ha
->device_type
|= DT_IIDMA
;
1431 ha
->fw_srisc_address
= RISC_START_ADDRESS_2400
;
1433 case PCI_DEVICE_ID_QLOGIC_ISP5422
:
1434 ha
->device_type
|= DT_ISP5422
;
1435 ha
->device_type
|= DT_FWI2
;
1436 ha
->fw_srisc_address
= RISC_START_ADDRESS_2400
;
1438 case PCI_DEVICE_ID_QLOGIC_ISP5432
:
1439 ha
->device_type
|= DT_ISP5432
;
1440 ha
->device_type
|= DT_FWI2
;
1441 ha
->fw_srisc_address
= RISC_START_ADDRESS_2400
;
1443 case PCI_DEVICE_ID_QLOGIC_ISP2532
:
1444 ha
->device_type
|= DT_ISP2532
;
1445 ha
->device_type
|= DT_ZIO_SUPPORTED
;
1446 ha
->device_type
|= DT_FWI2
;
1447 ha
->device_type
|= DT_IIDMA
;
1448 ha
->fw_srisc_address
= RISC_START_ADDRESS_2400
;
1454 qla2x00_iospace_config(scsi_qla_host_t
*ha
)
1456 resource_size_t pio
;
1458 if (pci_request_selected_regions(ha
->pdev
, ha
->bars
,
1459 QLA2XXX_DRIVER_NAME
)) {
1460 qla_printk(KERN_WARNING
, ha
,
1461 "Failed to reserve PIO/MMIO regions (%s)\n",
1462 pci_name(ha
->pdev
));
1464 goto iospace_error_exit
;
1466 if (!(ha
->bars
& 1))
1469 /* We only need PIO for Flash operations on ISP2312 v2 chips. */
1470 pio
= pci_resource_start(ha
->pdev
, 0);
1471 if (pci_resource_flags(ha
->pdev
, 0) & IORESOURCE_IO
) {
1472 if (pci_resource_len(ha
->pdev
, 0) < MIN_IOBASE_LEN
) {
1473 qla_printk(KERN_WARNING
, ha
,
1474 "Invalid PCI I/O region size (%s)...\n",
1475 pci_name(ha
->pdev
));
1479 qla_printk(KERN_WARNING
, ha
,
1480 "region #0 not a PIO resource (%s)...\n",
1481 pci_name(ha
->pdev
));
1484 ha
->pio_address
= pio
;
1487 /* Use MMIO operations for all accesses. */
1488 if (!(pci_resource_flags(ha
->pdev
, 1) & IORESOURCE_MEM
)) {
1489 qla_printk(KERN_ERR
, ha
,
1490 "region #1 not an MMIO resource (%s), aborting\n",
1491 pci_name(ha
->pdev
));
1492 goto iospace_error_exit
;
1494 if (pci_resource_len(ha
->pdev
, 1) < MIN_IOBASE_LEN
) {
1495 qla_printk(KERN_ERR
, ha
,
1496 "Invalid PCI mem region size (%s), aborting\n",
1497 pci_name(ha
->pdev
));
1498 goto iospace_error_exit
;
1501 ha
->iobase
= ioremap(pci_resource_start(ha
->pdev
, 1), MIN_IOBASE_LEN
);
1503 qla_printk(KERN_ERR
, ha
,
1504 "cannot remap MMIO (%s), aborting\n", pci_name(ha
->pdev
));
1506 goto iospace_error_exit
;
1516 qla2xxx_scan_start(struct Scsi_Host
*shost
)
1518 scsi_qla_host_t
*ha
= shost_priv(shost
);
1520 set_bit(LOOP_RESYNC_NEEDED
, &ha
->dpc_flags
);
1521 set_bit(LOCAL_LOOP_UPDATE
, &ha
->dpc_flags
);
1522 set_bit(RSCN_UPDATE
, &ha
->dpc_flags
);
1526 qla2xxx_scan_finished(struct Scsi_Host
*shost
, unsigned long time
)
1528 scsi_qla_host_t
*ha
= shost_priv(shost
);
1532 if (time
> ha
->loop_reset_delay
* HZ
)
1535 return atomic_read(&ha
->loop_state
) == LOOP_READY
;
1539 * PCI driver interface
1541 static int __devinit
1542 qla2x00_probe_one(struct pci_dev
*pdev
, const struct pci_device_id
*id
)
1545 struct Scsi_Host
*host
;
1546 scsi_qla_host_t
*ha
;
1549 struct scsi_host_template
*sht
;
1550 int bars
, mem_only
= 0;
1552 bars
= pci_select_bars(pdev
, IORESOURCE_MEM
| IORESOURCE_IO
);
1553 sht
= &qla2x00_driver_template
;
1554 if (pdev
->device
== PCI_DEVICE_ID_QLOGIC_ISP2422
||
1555 pdev
->device
== PCI_DEVICE_ID_QLOGIC_ISP2432
||
1556 pdev
->device
== PCI_DEVICE_ID_QLOGIC_ISP5422
||
1557 pdev
->device
== PCI_DEVICE_ID_QLOGIC_ISP5432
||
1558 pdev
->device
== PCI_DEVICE_ID_QLOGIC_ISP2532
) {
1559 bars
= pci_select_bars(pdev
, IORESOURCE_MEM
);
1560 sht
= &qla24xx_driver_template
;
1565 if (pci_enable_device_mem(pdev
))
1568 if (pci_enable_device(pdev
))
1572 if (pci_find_aer_capability(pdev
))
1573 if (pci_enable_pcie_error_reporting(pdev
))
1576 host
= scsi_host_alloc(sht
, sizeof(scsi_qla_host_t
));
1579 "qla2xxx: Couldn't allocate host from scsi layer!\n");
1580 goto probe_disable_device
;
1583 /* Clear our data area */
1584 ha
= shost_priv(host
);
1585 memset(ha
, 0, sizeof(scsi_qla_host_t
));
1589 ha
->host_no
= host
->host_no
;
1590 sprintf(ha
->host_str
, "%s_%ld", QLA2XXX_DRIVER_NAME
, ha
->host_no
);
1593 ha
->mem_only
= mem_only
;
1594 spin_lock_init(&ha
->hardware_lock
);
1596 /* Set ISP-type information. */
1597 qla2x00_set_isp_flags(ha
);
1599 /* Configure PCI I/O space */
1600 ret
= qla2x00_iospace_config(ha
);
1604 qla_printk(KERN_INFO
, ha
,
1605 "Found an ISP%04X, irq %d, iobase 0x%p\n", pdev
->device
, pdev
->irq
,
1608 ha
->prev_topology
= 0;
1609 ha
->init_cb_size
= sizeof(init_cb_t
);
1610 ha
->mgmt_svr_loop_id
= MANAGEMENT_SERVER
+ ha
->vp_idx
;
1611 ha
->link_data_rate
= PORT_SPEED_UNKNOWN
;
1612 ha
->optrom_size
= OPTROM_SIZE_2300
;
1614 ha
->max_q_depth
= MAX_Q_DEPTH
;
1615 if (ql2xmaxqdepth
!= 0 && ql2xmaxqdepth
<= 0xffffU
)
1616 ha
->max_q_depth
= ql2xmaxqdepth
;
1618 /* Assign ISP specific operations. */
1619 if (IS_QLA2100(ha
)) {
1620 host
->max_id
= MAX_TARGETS_2100
;
1621 ha
->mbx_count
= MAILBOX_REGISTER_COUNT_2100
;
1622 ha
->request_q_length
= REQUEST_ENTRY_CNT_2100
;
1623 ha
->response_q_length
= RESPONSE_ENTRY_CNT_2100
;
1624 ha
->last_loop_id
= SNS_LAST_LOOP_ID_2100
;
1625 host
->sg_tablesize
= 32;
1626 ha
->gid_list_info_size
= 4;
1627 ha
->isp_ops
= &qla2100_isp_ops
;
1628 } else if (IS_QLA2200(ha
)) {
1629 host
->max_id
= MAX_TARGETS_2200
;
1630 ha
->mbx_count
= MAILBOX_REGISTER_COUNT
;
1631 ha
->request_q_length
= REQUEST_ENTRY_CNT_2200
;
1632 ha
->response_q_length
= RESPONSE_ENTRY_CNT_2100
;
1633 ha
->last_loop_id
= SNS_LAST_LOOP_ID_2100
;
1634 ha
->gid_list_info_size
= 4;
1635 ha
->isp_ops
= &qla2100_isp_ops
;
1636 } else if (IS_QLA23XX(ha
)) {
1637 host
->max_id
= MAX_TARGETS_2200
;
1638 ha
->mbx_count
= MAILBOX_REGISTER_COUNT
;
1639 ha
->request_q_length
= REQUEST_ENTRY_CNT_2200
;
1640 ha
->response_q_length
= RESPONSE_ENTRY_CNT_2300
;
1641 ha
->last_loop_id
= SNS_LAST_LOOP_ID_2300
;
1642 ha
->gid_list_info_size
= 6;
1643 if (IS_QLA2322(ha
) || IS_QLA6322(ha
))
1644 ha
->optrom_size
= OPTROM_SIZE_2322
;
1645 ha
->isp_ops
= &qla2300_isp_ops
;
1646 } else if (IS_QLA24XX(ha
) || IS_QLA54XX(ha
)) {
1647 host
->max_id
= MAX_TARGETS_2200
;
1648 ha
->mbx_count
= MAILBOX_REGISTER_COUNT
;
1649 ha
->request_q_length
= REQUEST_ENTRY_CNT_24XX
;
1650 ha
->response_q_length
= RESPONSE_ENTRY_CNT_2300
;
1651 ha
->last_loop_id
= SNS_LAST_LOOP_ID_2300
;
1652 ha
->init_cb_size
= sizeof(struct mid_init_cb_24xx
);
1653 ha
->mgmt_svr_loop_id
= 10 + ha
->vp_idx
;
1654 ha
->gid_list_info_size
= 8;
1655 ha
->optrom_size
= OPTROM_SIZE_24XX
;
1656 ha
->isp_ops
= &qla24xx_isp_ops
;
1657 } else if (IS_QLA25XX(ha
)) {
1658 host
->max_id
= MAX_TARGETS_2200
;
1659 ha
->mbx_count
= MAILBOX_REGISTER_COUNT
;
1660 ha
->request_q_length
= REQUEST_ENTRY_CNT_24XX
;
1661 ha
->response_q_length
= RESPONSE_ENTRY_CNT_2300
;
1662 ha
->last_loop_id
= SNS_LAST_LOOP_ID_2300
;
1663 ha
->init_cb_size
= sizeof(struct mid_init_cb_24xx
);
1664 ha
->mgmt_svr_loop_id
= 10 + ha
->vp_idx
;
1665 ha
->gid_list_info_size
= 8;
1666 ha
->optrom_size
= OPTROM_SIZE_25XX
;
1667 ha
->isp_ops
= &qla25xx_isp_ops
;
1668 ha
->hw_event_start
= PCI_FUNC(pdev
->devfn
) ?
1669 FA_HW_EVENT1_ADDR
: FA_HW_EVENT0_ADDR
;
1671 host
->can_queue
= ha
->request_q_length
+ 128;
1673 /* load the F/W, read paramaters, and init the H/W */
1674 ha
->instance
= num_hosts
;
1676 init_MUTEX(&ha
->vport_sem
);
1677 init_completion(&ha
->mbx_cmd_comp
);
1678 complete(&ha
->mbx_cmd_comp
);
1679 init_completion(&ha
->mbx_intr_comp
);
1681 INIT_LIST_HEAD(&ha
->list
);
1682 INIT_LIST_HEAD(&ha
->fcports
);
1683 INIT_LIST_HEAD(&ha
->vp_list
);
1684 INIT_LIST_HEAD(&ha
->work_list
);
1686 set_bit(0, (unsigned long *) ha
->vp_idx_map
);
1688 qla2x00_config_dma_addressing(ha
);
1689 if (qla2x00_mem_alloc(ha
)) {
1690 qla_printk(KERN_WARNING
, ha
,
1691 "[ERROR] Failed to allocate memory for adapter\n");
1697 if (qla2x00_initialize_adapter(ha
)) {
1698 qla_printk(KERN_WARNING
, ha
,
1699 "Failed to initialize adapter\n");
1701 DEBUG2(printk("scsi(%ld): Failed to initialize adapter - "
1702 "Adapter flags %x.\n",
1703 ha
->host_no
, ha
->device_flags
));
1710 * Startup the kernel thread for this host adapter
1712 ha
->dpc_thread
= kthread_create(qla2x00_do_dpc
, ha
,
1713 "%s_dpc", ha
->host_str
);
1714 if (IS_ERR(ha
->dpc_thread
)) {
1715 qla_printk(KERN_WARNING
, ha
,
1716 "Unable to start DPC thread!\n");
1717 ret
= PTR_ERR(ha
->dpc_thread
);
1721 host
->this_id
= 255;
1722 host
->cmd_per_lun
= 3;
1723 host
->unique_id
= ha
->instance
;
1724 host
->max_cmd_len
= MAX_CMDSZ
;
1725 host
->max_channel
= MAX_BUSES
- 1;
1726 host
->max_lun
= MAX_LUNS
;
1727 host
->transportt
= qla2xxx_transport_template
;
1729 ret
= qla2x00_request_irqs(ha
);
1733 /* Initialized the timer */
1734 qla2x00_start_timer(ha
, qla2x00_timer
, WATCH_INTERVAL
);
1736 DEBUG2(printk("DEBUG: detect hba %ld at address = %p\n",
1739 pci_set_drvdata(pdev
, ha
);
1741 ha
->flags
.init_done
= 1;
1742 ha
->flags
.online
= 1;
1746 ret
= scsi_add_host(host
, &pdev
->dev
);
1750 scsi_scan_host(host
);
1752 qla2x00_alloc_sysfs_attr(ha
);
1754 qla2x00_init_host_attr(ha
);
1756 qla2x00_dfs_setup(ha
);
1758 qla_printk(KERN_INFO
, ha
, "\n"
1759 " QLogic Fibre Channel HBA Driver: %s\n"
1761 " ISP%04X: %s @ %s hdma%c, host#=%ld, fw=%s\n",
1762 qla2x00_version_str
, ha
->model_number
,
1763 ha
->model_desc
? ha
->model_desc
: "", pdev
->device
,
1764 ha
->isp_ops
->pci_info_str(ha
, pci_info
), pci_name(pdev
),
1765 ha
->flags
.enable_64bit_addressing
? '+': '-', ha
->host_no
,
1766 ha
->isp_ops
->fw_version_str(ha
, fw_str
));
1771 qla2x00_free_device(ha
);
1773 scsi_host_put(host
);
1775 probe_disable_device
:
1776 pci_disable_device(pdev
);
1783 qla2x00_remove_one(struct pci_dev
*pdev
)
1785 scsi_qla_host_t
*ha
;
1787 ha
= pci_get_drvdata(pdev
);
1789 qla2x00_dfs_remove(ha
);
1791 qla2x00_free_sysfs_attr(ha
);
1793 fc_remove_host(ha
->host
);
1795 scsi_remove_host(ha
->host
);
1797 qla2x00_free_device(ha
);
1799 scsi_host_put(ha
->host
);
1801 pci_disable_device(pdev
);
1802 pci_set_drvdata(pdev
, NULL
);
1806 qla2x00_free_device(scsi_qla_host_t
*ha
)
1808 qla2x00_abort_all_cmds(ha
, DID_NO_CONNECT
<< 16);
1811 if (ha
->timer_active
)
1812 qla2x00_stop_timer(ha
);
1814 ha
->flags
.online
= 0;
1816 /* Kill the kernel thread for this host */
1817 if (ha
->dpc_thread
) {
1818 struct task_struct
*t
= ha
->dpc_thread
;
1821 * qla2xxx_wake_dpc checks for ->dpc_thread
1822 * so we need to zero it out.
1824 ha
->dpc_thread
= NULL
;
1828 if (ha
->flags
.fce_enabled
)
1829 qla2x00_disable_fce_trace(ha
, NULL
, NULL
);
1832 qla2x00_disable_eft_trace(ha
);
1834 /* Stop currently executing firmware. */
1835 qla2x00_try_to_stop_firmware(ha
);
1837 /* turn-off interrupts on the card */
1838 if (ha
->interrupts_on
)
1839 ha
->isp_ops
->disable_intrs(ha
);
1841 qla2x00_mem_free(ha
);
1843 qla2x00_free_irqs(ha
);
1845 /* release io space registers */
1847 iounmap(ha
->iobase
);
1848 pci_release_selected_regions(ha
->pdev
, ha
->bars
);
1852 qla2x00_schedule_rport_del(struct scsi_qla_host
*ha
, fc_port_t
*fcport
,
1855 unsigned long flags
;
1856 struct fc_rport
*rport
;
1861 rport
= fcport
->rport
;
1863 spin_lock_irqsave(&fcport
->rport_lock
, flags
);
1864 fcport
->drport
= rport
;
1865 fcport
->rport
= NULL
;
1866 *(fc_port_t
**)rport
->dd_data
= NULL
;
1867 spin_unlock_irqrestore(&fcport
->rport_lock
, flags
);
1868 set_bit(FCPORT_UPDATE_NEEDED
, &ha
->dpc_flags
);
1870 spin_lock_irqsave(&fcport
->rport_lock
, flags
);
1871 fcport
->rport
= NULL
;
1872 *(fc_port_t
**)rport
->dd_data
= NULL
;
1873 spin_unlock_irqrestore(&fcport
->rport_lock
, flags
);
1874 fc_remote_port_delete(rport
);
1879 * qla2x00_mark_device_lost Updates fcport state when device goes offline.
1881 * Input: ha = adapter block pointer. fcport = port structure pointer.
1887 void qla2x00_mark_device_lost(scsi_qla_host_t
*ha
, fc_port_t
*fcport
,
1888 int do_login
, int defer
)
1890 if (atomic_read(&fcport
->state
) == FCS_ONLINE
&&
1891 ha
->vp_idx
== fcport
->vp_idx
)
1892 qla2x00_schedule_rport_del(ha
, fcport
, defer
);
1895 * We may need to retry the login, so don't change the state of the
1896 * port but do the retries.
1898 if (atomic_read(&fcport
->state
) != FCS_DEVICE_DEAD
)
1899 atomic_set(&fcport
->state
, FCS_DEVICE_LOST
);
1904 if (fcport
->login_retry
== 0) {
1905 fcport
->login_retry
= ha
->login_retry_count
;
1906 set_bit(RELOGIN_NEEDED
, &ha
->dpc_flags
);
1908 DEBUG(printk("scsi(%ld): Port login retry: "
1909 "%02x%02x%02x%02x%02x%02x%02x%02x, "
1910 "id = 0x%04x retry cnt=%d\n",
1912 fcport
->port_name
[0],
1913 fcport
->port_name
[1],
1914 fcport
->port_name
[2],
1915 fcport
->port_name
[3],
1916 fcport
->port_name
[4],
1917 fcport
->port_name
[5],
1918 fcport
->port_name
[6],
1919 fcport
->port_name
[7],
1921 fcport
->login_retry
));
1926 * qla2x00_mark_all_devices_lost
1927 * Updates fcport state when device goes offline.
1930 * ha = adapter block pointer.
1931 * fcport = port structure pointer.
1939 qla2x00_mark_all_devices_lost(scsi_qla_host_t
*ha
, int defer
)
1942 scsi_qla_host_t
*pha
= to_qla_parent(ha
);
1944 list_for_each_entry(fcport
, &pha
->fcports
, list
) {
1945 if (ha
->vp_idx
!= 0 && ha
->vp_idx
!= fcport
->vp_idx
)
1948 * No point in marking the device as lost, if the device is
1951 if (atomic_read(&fcport
->state
) == FCS_DEVICE_DEAD
)
1953 if (atomic_read(&fcport
->state
) == FCS_ONLINE
) {
1955 qla2x00_schedule_rport_del(ha
, fcport
, defer
);
1956 else if (ha
->vp_idx
== fcport
->vp_idx
)
1957 qla2x00_schedule_rport_del(ha
, fcport
, defer
);
1959 atomic_set(&fcport
->state
, FCS_DEVICE_LOST
);
1963 qla2xxx_wake_dpc(ha
);
1968 * Allocates adapter memory.
1975 qla2x00_mem_alloc(scsi_qla_host_t
*ha
)
1979 ha
->request_ring
= dma_alloc_coherent(&ha
->pdev
->dev
,
1980 (ha
->request_q_length
+ 1) * sizeof(request_t
), &ha
->request_dma
,
1982 if (!ha
->request_ring
)
1985 ha
->response_ring
= dma_alloc_coherent(&ha
->pdev
->dev
,
1986 (ha
->response_q_length
+ 1) * sizeof(response_t
),
1987 &ha
->response_dma
, GFP_KERNEL
);
1988 if (!ha
->response_ring
)
1989 goto fail_free_request_ring
;
1991 ha
->gid_list
= dma_alloc_coherent(&ha
->pdev
->dev
, GID_LIST_SIZE
,
1992 &ha
->gid_list_dma
, GFP_KERNEL
);
1994 goto fail_free_response_ring
;
1996 ha
->init_cb
= dma_alloc_coherent(&ha
->pdev
->dev
, ha
->init_cb_size
,
1997 &ha
->init_cb_dma
, GFP_KERNEL
);
1999 goto fail_free_gid_list
;
2001 snprintf(name
, sizeof(name
), "%s_%ld", QLA2XXX_DRIVER_NAME
,
2003 ha
->s_dma_pool
= dma_pool_create(name
, &ha
->pdev
->dev
,
2004 DMA_POOL_SIZE
, 8, 0);
2005 if (!ha
->s_dma_pool
)
2006 goto fail_free_init_cb
;
2008 ha
->srb_mempool
= mempool_create_slab_pool(SRB_MIN_REQ
, srb_cachep
);
2009 if (!ha
->srb_mempool
)
2010 goto fail_free_s_dma_pool
;
2012 /* Get memory for cached NVRAM */
2013 ha
->nvram
= kzalloc(MAX_NVRAM_SIZE
, GFP_KERNEL
);
2015 goto fail_free_srb_mempool
;
2017 /* Allocate memory for SNS commands */
2018 if (IS_QLA2100(ha
) || IS_QLA2200(ha
)) {
2019 /* Get consistent memory allocated for SNS commands */
2020 ha
->sns_cmd
= dma_alloc_coherent(&ha
->pdev
->dev
,
2021 sizeof(struct sns_cmd_pkt
), &ha
->sns_cmd_dma
, GFP_KERNEL
);
2023 goto fail_free_nvram
;
2025 /* Get consistent memory allocated for MS IOCB */
2026 ha
->ms_iocb
= dma_pool_alloc(ha
->s_dma_pool
, GFP_KERNEL
,
2029 goto fail_free_nvram
;
2031 /* Get consistent memory allocated for CT SNS commands */
2032 ha
->ct_sns
= dma_alloc_coherent(&ha
->pdev
->dev
,
2033 sizeof(struct ct_sns_pkt
), &ha
->ct_sns_dma
, GFP_KERNEL
);
2035 goto fail_free_ms_iocb
;
2041 dma_pool_free(ha
->s_dma_pool
, ha
->ms_iocb
, ha
->ms_iocb_dma
);
2043 ha
->ms_iocb_dma
= 0;
2047 fail_free_srb_mempool
:
2048 mempool_destroy(ha
->srb_mempool
);
2049 ha
->srb_mempool
= NULL
;
2050 fail_free_s_dma_pool
:
2051 dma_pool_destroy(ha
->s_dma_pool
);
2052 ha
->s_dma_pool
= NULL
;
2054 dma_free_coherent(&ha
->pdev
->dev
, ha
->init_cb_size
, ha
->init_cb
,
2057 ha
->init_cb_dma
= 0;
2059 dma_free_coherent(&ha
->pdev
->dev
, GID_LIST_SIZE
, ha
->gid_list
,
2061 ha
->gid_list
= NULL
;
2062 ha
->gid_list_dma
= 0;
2063 fail_free_response_ring
:
2064 dma_free_coherent(&ha
->pdev
->dev
, (ha
->response_q_length
+ 1) *
2065 sizeof(response_t
), ha
->response_ring
, ha
->response_dma
);
2066 ha
->response_ring
= NULL
;
2067 ha
->response_dma
= 0;
2068 fail_free_request_ring
:
2069 dma_free_coherent(&ha
->pdev
->dev
, (ha
->request_q_length
+ 1) *
2070 sizeof(request_t
), ha
->request_ring
, ha
->request_dma
);
2071 ha
->request_ring
= NULL
;
2072 ha
->request_dma
= 0;
2079 * Frees all adapter allocated memory.
2082 * ha = adapter block pointer.
2085 qla2x00_mem_free(scsi_qla_host_t
*ha
)
2087 struct list_head
*fcpl
, *fcptemp
;
2090 if (ha
->srb_mempool
)
2091 mempool_destroy(ha
->srb_mempool
);
2094 dma_free_coherent(&ha
->pdev
->dev
, FCE_SIZE
, ha
->fce
,
2099 dma_free_coherent(&ha
->pdev
->dev
,
2100 ntohl(ha
->fw_dump
->eft_size
), ha
->eft
, ha
->eft_dma
);
2105 dma_free_coherent(&ha
->pdev
->dev
, sizeof(struct sns_cmd_pkt
),
2106 ha
->sns_cmd
, ha
->sns_cmd_dma
);
2109 dma_free_coherent(&ha
->pdev
->dev
, sizeof(struct ct_sns_pkt
),
2110 ha
->ct_sns
, ha
->ct_sns_dma
);
2113 dma_pool_free(ha
->s_dma_pool
, ha
->sfp_data
, ha
->sfp_data_dma
);
2116 dma_pool_free(ha
->s_dma_pool
, ha
->ms_iocb
, ha
->ms_iocb_dma
);
2119 dma_pool_destroy(ha
->s_dma_pool
);
2122 dma_free_coherent(&ha
->pdev
->dev
, ha
->init_cb_size
,
2123 ha
->init_cb
, ha
->init_cb_dma
);
2126 dma_free_coherent(&ha
->pdev
->dev
, GID_LIST_SIZE
, ha
->gid_list
,
2129 if (ha
->response_ring
)
2130 dma_free_coherent(&ha
->pdev
->dev
,
2131 (ha
->response_q_length
+ 1) * sizeof(response_t
),
2132 ha
->response_ring
, ha
->response_dma
);
2134 if (ha
->request_ring
)
2135 dma_free_coherent(&ha
->pdev
->dev
,
2136 (ha
->request_q_length
+ 1) * sizeof(request_t
),
2137 ha
->request_ring
, ha
->request_dma
);
2139 ha
->srb_mempool
= NULL
;
2143 ha
->sns_cmd_dma
= 0;
2147 ha
->ms_iocb_dma
= 0;
2149 ha
->init_cb_dma
= 0;
2151 ha
->s_dma_pool
= NULL
;
2153 ha
->gid_list
= NULL
;
2154 ha
->gid_list_dma
= 0;
2156 ha
->response_ring
= NULL
;
2157 ha
->response_dma
= 0;
2158 ha
->request_ring
= NULL
;
2159 ha
->request_dma
= 0;
2161 list_for_each_safe(fcpl
, fcptemp
, &ha
->fcports
) {
2162 fcport
= list_entry(fcpl
, fc_port_t
, list
);
2165 list_del_init(&fcport
->list
);
2168 INIT_LIST_HEAD(&ha
->fcports
);
2172 ha
->fw_dump_reading
= 0;
2174 vfree(ha
->optrom_buffer
);
2178 struct qla_work_evt
*
2179 qla2x00_alloc_work(struct scsi_qla_host
*ha
, enum qla_work_type type
,
2182 struct qla_work_evt
*e
;
2184 e
= kzalloc(sizeof(struct qla_work_evt
), locked
? GFP_ATOMIC
:
2189 INIT_LIST_HEAD(&e
->list
);
2191 e
->flags
= QLA_EVT_FLAG_FREE
;
2196 qla2x00_post_work(struct scsi_qla_host
*ha
, struct qla_work_evt
*e
, int locked
)
2198 unsigned long flags
;
2201 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
2202 list_add_tail(&e
->list
, &ha
->work_list
);
2203 qla2xxx_wake_dpc(ha
);
2205 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
2210 qla2x00_post_aen_work(struct scsi_qla_host
*ha
, enum fc_host_event_code code
,
2213 struct qla_work_evt
*e
;
2215 e
= qla2x00_alloc_work(ha
, QLA_EVT_AEN
, 1);
2217 return QLA_FUNCTION_FAILED
;
2219 e
->u
.aen
.code
= code
;
2220 e
->u
.aen
.data
= data
;
2221 return qla2x00_post_work(ha
, e
, 1);
2225 qla2x00_post_hwe_work(struct scsi_qla_host
*ha
, uint16_t code
, uint16_t d1
,
2226 uint16_t d2
, uint16_t d3
)
2228 struct qla_work_evt
*e
;
2230 e
= qla2x00_alloc_work(ha
, QLA_EVT_HWE_LOG
, 1);
2232 return QLA_FUNCTION_FAILED
;
2234 e
->u
.hwe
.code
= code
;
2238 return qla2x00_post_work(ha
, e
, 1);
2242 qla2x00_do_work(struct scsi_qla_host
*ha
)
2244 struct qla_work_evt
*e
;
2246 spin_lock_irq(&ha
->hardware_lock
);
2247 while (!list_empty(&ha
->work_list
)) {
2248 e
= list_entry(ha
->work_list
.next
, struct qla_work_evt
, list
);
2249 list_del_init(&e
->list
);
2250 spin_unlock_irq(&ha
->hardware_lock
);
2254 fc_host_post_event(ha
->host
, fc_get_event_number(),
2255 e
->u
.aen
.code
, e
->u
.aen
.data
);
2257 case QLA_EVT_HWE_LOG
:
2258 qla2xxx_hw_event_log(ha
, e
->u
.hwe
.code
, e
->u
.hwe
.d1
,
2259 e
->u
.hwe
.d2
, e
->u
.hwe
.d3
);
2262 if (e
->flags
& QLA_EVT_FLAG_FREE
)
2264 spin_lock_irq(&ha
->hardware_lock
);
2266 spin_unlock_irq(&ha
->hardware_lock
);
2269 /**************************************************************************
2271 * This kernel thread is a task that is schedule by the interrupt handler
2272 * to perform the background processing for interrupts.
2275 * This task always run in the context of a kernel thread. It
2276 * is kick-off by the driver's detect code and starts up
2277 * up one per adapter. It immediately goes to sleep and waits for
2278 * some fibre event. When either the interrupt handler or
2279 * the timer routine detects a event it will one of the task
2280 * bits then wake us up.
2281 **************************************************************************/
2283 qla2x00_do_dpc(void *data
)
2286 scsi_qla_host_t
*ha
;
2289 uint16_t next_loopid
;
2290 struct scsi_qla_host
*vha
;
2294 ha
= (scsi_qla_host_t
*)data
;
2296 set_user_nice(current
, -20);
2298 while (!kthread_should_stop()) {
2299 DEBUG3(printk("qla2x00: DPC handler sleeping\n"));
2301 set_current_state(TASK_INTERRUPTIBLE
);
2303 __set_current_state(TASK_RUNNING
);
2305 DEBUG3(printk("qla2x00: DPC handler waking up\n"));
2307 /* Initialization not yet finished. Don't do anything yet. */
2308 if (!ha
->flags
.init_done
)
2311 DEBUG3(printk("scsi(%ld): DPC handler\n", ha
->host_no
));
2315 if (ha
->flags
.mbox_busy
) {
2320 qla2x00_do_work(ha
);
2322 if (test_and_clear_bit(ISP_ABORT_NEEDED
, &ha
->dpc_flags
)) {
2324 DEBUG(printk("scsi(%ld): dpc: sched "
2325 "qla2x00_abort_isp ha = %p\n",
2327 if (!(test_and_set_bit(ABORT_ISP_ACTIVE
,
2330 if (qla2x00_abort_isp(ha
)) {
2331 /* failed. retry later */
2332 set_bit(ISP_ABORT_NEEDED
,
2335 clear_bit(ABORT_ISP_ACTIVE
, &ha
->dpc_flags
);
2338 for_each_mapped_vp_idx(ha
, i
) {
2339 list_for_each_entry(vha
, &ha
->vp_list
,
2341 if (i
== vha
->vp_idx
) {
2342 set_bit(ISP_ABORT_NEEDED
,
2349 DEBUG(printk("scsi(%ld): dpc: qla2x00_abort_isp end\n",
2353 if (test_and_clear_bit(FCPORT_UPDATE_NEEDED
, &ha
->dpc_flags
))
2354 qla2x00_update_fcports(ha
);
2356 if (test_and_clear_bit(RESET_MARKER_NEEDED
, &ha
->dpc_flags
) &&
2357 (!(test_and_set_bit(RESET_ACTIVE
, &ha
->dpc_flags
)))) {
2359 DEBUG(printk("scsi(%ld): qla2x00_reset_marker()\n",
2362 qla2x00_rst_aen(ha
);
2363 clear_bit(RESET_ACTIVE
, &ha
->dpc_flags
);
2366 /* Retry each device up to login retry count */
2367 if ((test_and_clear_bit(RELOGIN_NEEDED
, &ha
->dpc_flags
)) &&
2368 !test_bit(LOOP_RESYNC_NEEDED
, &ha
->dpc_flags
) &&
2369 atomic_read(&ha
->loop_state
) != LOOP_DOWN
) {
2371 DEBUG(printk("scsi(%ld): qla2x00_port_login()\n",
2375 list_for_each_entry(fcport
, &ha
->fcports
, list
) {
2377 * If the port is not ONLINE then try to login
2378 * to it if we haven't run out of retries.
2380 if (atomic_read(&fcport
->state
) != FCS_ONLINE
&&
2381 fcport
->login_retry
) {
2383 if (fcport
->flags
& FCF_FABRIC_DEVICE
) {
2386 ha
->isp_ops
->fabric_logout(
2387 ha
, fcport
->loop_id
,
2388 fcport
->d_id
.b
.domain
,
2389 fcport
->d_id
.b
.area
,
2390 fcport
->d_id
.b
.al_pa
);
2391 status
= qla2x00_fabric_login(
2392 ha
, fcport
, &next_loopid
);
2395 qla2x00_local_device_login(
2398 fcport
->login_retry
--;
2399 if (status
== QLA_SUCCESS
) {
2400 fcport
->old_loop_id
= fcport
->loop_id
;
2402 DEBUG(printk("scsi(%ld): port login OK: logged in ID 0x%x\n",
2403 ha
->host_no
, fcport
->loop_id
));
2405 qla2x00_update_fcport(ha
,
2407 } else if (status
== 1) {
2408 set_bit(RELOGIN_NEEDED
, &ha
->dpc_flags
);
2409 /* retry the login again */
2410 DEBUG(printk("scsi(%ld): Retrying %d login again loop_id 0x%x\n",
2412 fcport
->login_retry
, fcport
->loop_id
));
2414 fcport
->login_retry
= 0;
2416 if (fcport
->login_retry
== 0)
2417 fcport
->loop_id
= FC_NO_LOOP_ID
;
2419 if (test_bit(LOOP_RESYNC_NEEDED
, &ha
->dpc_flags
))
2422 DEBUG(printk("scsi(%ld): qla2x00_port_login - end\n",
2426 if (test_and_clear_bit(LOOP_RESYNC_NEEDED
, &ha
->dpc_flags
)) {
2428 DEBUG(printk("scsi(%ld): qla2x00_loop_resync()\n",
2431 if (!(test_and_set_bit(LOOP_RESYNC_ACTIVE
,
2434 rval
= qla2x00_loop_resync(ha
);
2436 clear_bit(LOOP_RESYNC_ACTIVE
, &ha
->dpc_flags
);
2439 DEBUG(printk("scsi(%ld): qla2x00_loop_resync - end\n",
2443 if (!ha
->interrupts_on
)
2444 ha
->isp_ops
->enable_intrs(ha
);
2446 if (test_and_clear_bit(BEACON_BLINK_NEEDED
, &ha
->dpc_flags
))
2447 ha
->isp_ops
->beacon_blink(ha
);
2449 qla2x00_do_dpc_all_vps(ha
);
2452 } /* End of while(1) */
2454 DEBUG(printk("scsi(%ld): DPC handler exiting\n", ha
->host_no
));
2457 * Make sure that nobody tries to wake us up again.
2465 qla2xxx_wake_dpc(scsi_qla_host_t
*ha
)
2468 wake_up_process(ha
->dpc_thread
);
2473 * Processes asynchronous reset.
2476 * ha = adapter block pointer.
2479 qla2x00_rst_aen(scsi_qla_host_t
*ha
)
2481 if (ha
->flags
.online
&& !ha
->flags
.reset_active
&&
2482 !atomic_read(&ha
->loop_down_timer
) &&
2483 !(test_bit(ABORT_ISP_ACTIVE
, &ha
->dpc_flags
))) {
2485 clear_bit(RESET_MARKER_NEEDED
, &ha
->dpc_flags
);
2488 * Issue marker command only when we are going to start
2491 ha
->marker_needed
= 1;
2492 } while (!atomic_read(&ha
->loop_down_timer
) &&
2493 (test_bit(RESET_MARKER_NEEDED
, &ha
->dpc_flags
)));
2498 qla2x00_sp_free_dma(scsi_qla_host_t
*ha
, srb_t
*sp
)
2500 struct scsi_cmnd
*cmd
= sp
->cmd
;
2502 if (sp
->flags
& SRB_DMA_VALID
) {
2503 scsi_dma_unmap(cmd
);
2504 sp
->flags
&= ~SRB_DMA_VALID
;
2510 qla2x00_sp_compl(scsi_qla_host_t
*ha
, srb_t
*sp
)
2512 struct scsi_cmnd
*cmd
= sp
->cmd
;
2514 qla2x00_sp_free_dma(ha
, sp
);
2516 mempool_free(sp
, ha
->srb_mempool
);
2518 cmd
->scsi_done(cmd
);
2521 /**************************************************************************
2527 * Context: Interrupt
2528 ***************************************************************************/
2530 qla2x00_timer(scsi_qla_host_t
*ha
)
2532 unsigned long cpu_flags
= 0;
2538 scsi_qla_host_t
*pha
= to_qla_parent(ha
);
2541 * Ports - Port down timer.
2543 * Whenever, a port is in the LOST state we start decrementing its port
2544 * down timer every second until it reaches zero. Once it reaches zero
2545 * the port it marked DEAD.
2548 list_for_each_entry(fcport
, &ha
->fcports
, list
) {
2549 if (fcport
->port_type
!= FCT_TARGET
)
2552 if (atomic_read(&fcport
->state
) == FCS_DEVICE_LOST
) {
2554 if (atomic_read(&fcport
->port_down_timer
) == 0)
2557 if (atomic_dec_and_test(&fcport
->port_down_timer
) != 0)
2558 atomic_set(&fcport
->state
, FCS_DEVICE_DEAD
);
2560 DEBUG(printk("scsi(%ld): fcport-%d - port retry count: "
2563 t
, atomic_read(&fcport
->port_down_timer
)));
2566 } /* End of for fcport */
2569 /* Loop down handler. */
2570 if (atomic_read(&ha
->loop_down_timer
) > 0 &&
2571 !(test_bit(ABORT_ISP_ACTIVE
, &ha
->dpc_flags
)) && ha
->flags
.online
) {
2573 if (atomic_read(&ha
->loop_down_timer
) ==
2574 ha
->loop_down_abort_time
) {
2576 DEBUG(printk("scsi(%ld): Loop Down - aborting the "
2577 "queues before time expire\n",
2580 if (!IS_QLA2100(ha
) && ha
->link_down_timeout
)
2581 atomic_set(&ha
->loop_state
, LOOP_DEAD
);
2583 /* Schedule an ISP abort to return any tape commands. */
2584 /* NPIV - scan physical port only */
2586 spin_lock_irqsave(&ha
->hardware_lock
,
2589 index
< MAX_OUTSTANDING_COMMANDS
;
2593 sp
= ha
->outstanding_cmds
[index
];
2597 if (!(sfcp
->flags
& FCF_TAPE_PRESENT
))
2600 set_bit(ISP_ABORT_NEEDED
,
2604 spin_unlock_irqrestore(&ha
->hardware_lock
,
2607 set_bit(ABORT_QUEUES_NEEDED
, &ha
->dpc_flags
);
2611 /* if the loop has been down for 4 minutes, reinit adapter */
2612 if (atomic_dec_and_test(&ha
->loop_down_timer
) != 0) {
2613 DEBUG(printk("scsi(%ld): Loop down exceed 4 mins - "
2614 "restarting queues.\n",
2617 set_bit(RESTART_QUEUES_NEEDED
, &ha
->dpc_flags
);
2620 if (!(ha
->device_flags
& DFLG_NO_CABLE
)) {
2621 DEBUG(printk("scsi(%ld): Loop down - "
2624 qla_printk(KERN_WARNING
, ha
,
2625 "Loop down - aborting ISP.\n");
2627 set_bit(ISP_ABORT_NEEDED
, &ha
->dpc_flags
);
2630 DEBUG3(printk("scsi(%ld): Loop Down - seconds remaining %d\n",
2632 atomic_read(&ha
->loop_down_timer
)));
2635 /* Check if beacon LED needs to be blinked */
2636 if (ha
->beacon_blink_led
== 1) {
2637 set_bit(BEACON_BLINK_NEEDED
, &ha
->dpc_flags
);
2641 /* Schedule the DPC routine if needed */
2642 if ((test_bit(ISP_ABORT_NEEDED
, &ha
->dpc_flags
) ||
2643 test_bit(LOOP_RESYNC_NEEDED
, &ha
->dpc_flags
) ||
2644 test_bit(FCPORT_UPDATE_NEEDED
, &ha
->dpc_flags
) ||
2646 test_bit(RESET_MARKER_NEEDED
, &ha
->dpc_flags
) ||
2647 test_bit(BEACON_BLINK_NEEDED
, &ha
->dpc_flags
) ||
2648 test_bit(VP_DPC_NEEDED
, &ha
->dpc_flags
) ||
2649 test_bit(RELOGIN_NEEDED
, &ha
->dpc_flags
)))
2650 qla2xxx_wake_dpc(pha
);
2652 qla2x00_restart_timer(ha
, WATCH_INTERVAL
);
2655 /* Firmware interface routines. */
2658 #define FW_ISP21XX 0
2659 #define FW_ISP22XX 1
2660 #define FW_ISP2300 2
2661 #define FW_ISP2322 3
2662 #define FW_ISP24XX 4
2663 #define FW_ISP25XX 5
2665 #define FW_FILE_ISP21XX "ql2100_fw.bin"
2666 #define FW_FILE_ISP22XX "ql2200_fw.bin"
2667 #define FW_FILE_ISP2300 "ql2300_fw.bin"
2668 #define FW_FILE_ISP2322 "ql2322_fw.bin"
2669 #define FW_FILE_ISP24XX "ql2400_fw.bin"
2670 #define FW_FILE_ISP25XX "ql2500_fw.bin"
2672 static DECLARE_MUTEX(qla_fw_lock
);
2674 static struct fw_blob qla_fw_blobs
[FW_BLOBS
] = {
2675 { .name
= FW_FILE_ISP21XX
, .segs
= { 0x1000, 0 }, },
2676 { .name
= FW_FILE_ISP22XX
, .segs
= { 0x1000, 0 }, },
2677 { .name
= FW_FILE_ISP2300
, .segs
= { 0x800, 0 }, },
2678 { .name
= FW_FILE_ISP2322
, .segs
= { 0x800, 0x1c000, 0x1e000, 0 }, },
2679 { .name
= FW_FILE_ISP24XX
, },
2680 { .name
= FW_FILE_ISP25XX
, },
2684 qla2x00_request_firmware(scsi_qla_host_t
*ha
)
2686 struct fw_blob
*blob
;
2689 if (IS_QLA2100(ha
)) {
2690 blob
= &qla_fw_blobs
[FW_ISP21XX
];
2691 } else if (IS_QLA2200(ha
)) {
2692 blob
= &qla_fw_blobs
[FW_ISP22XX
];
2693 } else if (IS_QLA2300(ha
) || IS_QLA2312(ha
) || IS_QLA6312(ha
)) {
2694 blob
= &qla_fw_blobs
[FW_ISP2300
];
2695 } else if (IS_QLA2322(ha
) || IS_QLA6322(ha
)) {
2696 blob
= &qla_fw_blobs
[FW_ISP2322
];
2697 } else if (IS_QLA24XX(ha
) || IS_QLA54XX(ha
)) {
2698 blob
= &qla_fw_blobs
[FW_ISP24XX
];
2699 } else if (IS_QLA25XX(ha
)) {
2700 blob
= &qla_fw_blobs
[FW_ISP25XX
];
2707 if (request_firmware(&blob
->fw
, blob
->name
, &ha
->pdev
->dev
)) {
2708 DEBUG2(printk("scsi(%ld): Failed to load firmware image "
2709 "(%s).\n", ha
->host_no
, blob
->name
));
2721 qla2x00_release_firmware(void)
2726 for (idx
= 0; idx
< FW_BLOBS
; idx
++)
2727 if (qla_fw_blobs
[idx
].fw
)
2728 release_firmware(qla_fw_blobs
[idx
].fw
);
2732 static pci_ers_result_t
2733 qla2xxx_pci_error_detected(struct pci_dev
*pdev
, pci_channel_state_t state
)
2736 case pci_channel_io_normal
:
2737 return PCI_ERS_RESULT_CAN_RECOVER
;
2738 case pci_channel_io_frozen
:
2739 pci_disable_device(pdev
);
2740 return PCI_ERS_RESULT_NEED_RESET
;
2741 case pci_channel_io_perm_failure
:
2742 qla2x00_remove_one(pdev
);
2743 return PCI_ERS_RESULT_DISCONNECT
;
2745 return PCI_ERS_RESULT_NEED_RESET
;
2748 static pci_ers_result_t
2749 qla2xxx_pci_mmio_enabled(struct pci_dev
*pdev
)
2751 int risc_paused
= 0;
2753 unsigned long flags
;
2754 scsi_qla_host_t
*ha
= pci_get_drvdata(pdev
);
2755 struct device_reg_2xxx __iomem
*reg
= &ha
->iobase
->isp
;
2756 struct device_reg_24xx __iomem
*reg24
= &ha
->iobase
->isp24
;
2758 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
2759 if (IS_QLA2100(ha
) || IS_QLA2200(ha
)){
2760 stat
= RD_REG_DWORD(®
->hccr
);
2761 if (stat
& HCCR_RISC_PAUSE
)
2763 } else if (IS_QLA23XX(ha
)) {
2764 stat
= RD_REG_DWORD(®
->u
.isp2300
.host_status
);
2765 if (stat
& HSR_RISC_PAUSED
)
2767 } else if (IS_FWI2_CAPABLE(ha
)) {
2768 stat
= RD_REG_DWORD(®24
->host_status
);
2769 if (stat
& HSRX_RISC_PAUSED
)
2772 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
2775 qla_printk(KERN_INFO
, ha
, "RISC paused -- mmio_enabled, "
2776 "Dumping firmware!\n");
2777 ha
->isp_ops
->fw_dump(ha
, 0);
2779 return PCI_ERS_RESULT_NEED_RESET
;
2781 return PCI_ERS_RESULT_RECOVERED
;
2784 static pci_ers_result_t
2785 qla2xxx_pci_slot_reset(struct pci_dev
*pdev
)
2787 pci_ers_result_t ret
= PCI_ERS_RESULT_DISCONNECT
;
2788 scsi_qla_host_t
*ha
= pci_get_drvdata(pdev
);
2792 rc
= pci_enable_device_mem(pdev
);
2794 rc
= pci_enable_device(pdev
);
2797 qla_printk(KERN_WARNING
, ha
,
2798 "Can't re-enable PCI device after reset.\n");
2802 pci_set_master(pdev
);
2804 if (ha
->isp_ops
->pci_config(ha
))
2807 set_bit(ABORT_ISP_ACTIVE
, &ha
->dpc_flags
);
2808 if (qla2x00_abort_isp(ha
)== QLA_SUCCESS
)
2809 ret
= PCI_ERS_RESULT_RECOVERED
;
2810 clear_bit(ABORT_ISP_ACTIVE
, &ha
->dpc_flags
);
2816 qla2xxx_pci_resume(struct pci_dev
*pdev
)
2818 scsi_qla_host_t
*ha
= pci_get_drvdata(pdev
);
2821 ret
= qla2x00_wait_for_hba_online(ha
);
2822 if (ret
!= QLA_SUCCESS
) {
2823 qla_printk(KERN_ERR
, ha
,
2824 "the device failed to resume I/O "
2825 "from slot/link_reset");
2827 pci_cleanup_aer_uncorrect_error_status(pdev
);
2830 static struct pci_error_handlers qla2xxx_err_handler
= {
2831 .error_detected
= qla2xxx_pci_error_detected
,
2832 .mmio_enabled
= qla2xxx_pci_mmio_enabled
,
2833 .slot_reset
= qla2xxx_pci_slot_reset
,
2834 .resume
= qla2xxx_pci_resume
,
2837 static struct pci_device_id qla2xxx_pci_tbl
[] = {
2838 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC
, PCI_DEVICE_ID_QLOGIC_ISP2100
) },
2839 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC
, PCI_DEVICE_ID_QLOGIC_ISP2200
) },
2840 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC
, PCI_DEVICE_ID_QLOGIC_ISP2300
) },
2841 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC
, PCI_DEVICE_ID_QLOGIC_ISP2312
) },
2842 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC
, PCI_DEVICE_ID_QLOGIC_ISP2322
) },
2843 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC
, PCI_DEVICE_ID_QLOGIC_ISP6312
) },
2844 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC
, PCI_DEVICE_ID_QLOGIC_ISP6322
) },
2845 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC
, PCI_DEVICE_ID_QLOGIC_ISP2422
) },
2846 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC
, PCI_DEVICE_ID_QLOGIC_ISP2432
) },
2847 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC
, PCI_DEVICE_ID_QLOGIC_ISP5422
) },
2848 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC
, PCI_DEVICE_ID_QLOGIC_ISP5432
) },
2849 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC
, PCI_DEVICE_ID_QLOGIC_ISP2532
) },
2852 MODULE_DEVICE_TABLE(pci
, qla2xxx_pci_tbl
);
2854 static struct pci_driver qla2xxx_pci_driver
= {
2855 .name
= QLA2XXX_DRIVER_NAME
,
2857 .owner
= THIS_MODULE
,
2859 .id_table
= qla2xxx_pci_tbl
,
2860 .probe
= qla2x00_probe_one
,
2861 .remove
= qla2x00_remove_one
,
2862 .err_handler
= &qla2xxx_err_handler
,
2866 * qla2x00_module_init - Module initialization.
2869 qla2x00_module_init(void)
2873 /* Allocate cache for SRBs. */
2874 srb_cachep
= kmem_cache_create("qla2xxx_srbs", sizeof(srb_t
), 0,
2875 SLAB_HWCACHE_ALIGN
, NULL
);
2876 if (srb_cachep
== NULL
) {
2878 "qla2xxx: Unable to allocate SRB cache...Failing load!\n");
2882 /* Derive version string. */
2883 strcpy(qla2x00_version_str
, QLA2XXX_VERSION
);
2884 if (ql2xextended_error_logging
)
2885 strcat(qla2x00_version_str
, "-debug");
2887 qla2xxx_transport_template
=
2888 fc_attach_transport(&qla2xxx_transport_functions
);
2889 if (!qla2xxx_transport_template
) {
2890 kmem_cache_destroy(srb_cachep
);
2893 qla2xxx_transport_vport_template
=
2894 fc_attach_transport(&qla2xxx_transport_vport_functions
);
2895 if (!qla2xxx_transport_vport_template
) {
2896 kmem_cache_destroy(srb_cachep
);
2897 fc_release_transport(qla2xxx_transport_template
);
2901 printk(KERN_INFO
"QLogic Fibre Channel HBA Driver\n");
2902 ret
= pci_register_driver(&qla2xxx_pci_driver
);
2904 kmem_cache_destroy(srb_cachep
);
2905 fc_release_transport(qla2xxx_transport_template
);
2906 fc_release_transport(qla2xxx_transport_vport_template
);
2912 * qla2x00_module_exit - Module cleanup.
2915 qla2x00_module_exit(void)
2917 pci_unregister_driver(&qla2xxx_pci_driver
);
2918 qla2x00_release_firmware();
2919 kmem_cache_destroy(srb_cachep
);
2920 fc_release_transport(qla2xxx_transport_template
);
2921 fc_release_transport(qla2xxx_transport_vport_template
);
2924 module_init(qla2x00_module_init
);
2925 module_exit(qla2x00_module_exit
);
2927 MODULE_AUTHOR("QLogic Corporation");
2928 MODULE_DESCRIPTION("QLogic Fibre Channel HBA Driver");
2929 MODULE_LICENSE("GPL");
2930 MODULE_VERSION(QLA2XXX_VERSION
);
2931 MODULE_FIRMWARE(FW_FILE_ISP21XX
);
2932 MODULE_FIRMWARE(FW_FILE_ISP22XX
);
2933 MODULE_FIRMWARE(FW_FILE_ISP2300
);
2934 MODULE_FIRMWARE(FW_FILE_ISP2322
);
2935 MODULE_FIRMWARE(FW_FILE_ISP24XX
);
2936 MODULE_FIRMWARE(FW_FILE_ISP25XX
);