2 * QLogic Fibre Channel HBA Driver
3 * Copyright (c) 2003-2005 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 * Ioctl related information.
33 int ql2xlogintimeout
= 20;
34 module_param(ql2xlogintimeout
, int, S_IRUGO
|S_IRUSR
);
35 MODULE_PARM_DESC(ql2xlogintimeout
,
36 "Login timeout value in seconds.");
38 int qlport_down_retry
;
39 module_param(qlport_down_retry
, int, S_IRUGO
|S_IRUSR
);
40 MODULE_PARM_DESC(qlport_down_retry
,
41 "Maximum number of command retries to a port that returns "
42 "a PORT-DOWN status.");
44 int ql2xplogiabsentdevice
;
45 module_param(ql2xplogiabsentdevice
, int, S_IRUGO
|S_IWUSR
);
46 MODULE_PARM_DESC(ql2xplogiabsentdevice
,
47 "Option to enable PLOGI to devices that are not present after "
48 "a Fabric scan. This is needed for several broken switches. "
49 "Default is 0 - no PLOGI. 1 - perfom PLOGI.");
51 int ql2xloginretrycount
= 0;
52 module_param(ql2xloginretrycount
, int, S_IRUGO
|S_IRUSR
);
53 MODULE_PARM_DESC(ql2xloginretrycount
,
54 "Specify an alternate value for the NVRAM login retry count.");
56 int ql2xallocfwdump
= 1;
57 module_param(ql2xallocfwdump
, int, S_IRUGO
|S_IRUSR
);
58 MODULE_PARM_DESC(ql2xallocfwdump
,
59 "Option to enable allocation of memory for a firmware dump "
60 "during HBA initialization. Memory allocation requirements "
61 "vary by ISP type. Default is 1 - allocate memory.");
63 int ql2xextended_error_logging
;
64 module_param(ql2xextended_error_logging
, int, S_IRUGO
|S_IWUSR
);
65 MODULE_PARM_DESC(ql2xextended_error_logging
,
66 "Option to enable extended error logging, "
67 "Default is 0 - no logging. 1 - log errors.");
69 static void qla2x00_free_device(scsi_qla_host_t
*);
71 static void qla2x00_config_dma_addressing(scsi_qla_host_t
*ha
);
74 module_param(ql2xfdmienable
, int, S_IRUGO
|S_IRUSR
);
75 MODULE_PARM_DESC(ql2xfdmienable
,
76 "Enables FDMI registratons "
77 "Default is 0 - no FDMI. 1 - perfom FDMI.");
79 #define MAX_Q_DEPTH 32
80 static int ql2xmaxqdepth
= MAX_Q_DEPTH
;
81 module_param(ql2xmaxqdepth
, int, S_IRUGO
|S_IWUSR
);
82 MODULE_PARM_DESC(ql2xmaxqdepth
,
83 "Maximum queue depth to report for target devices.");
85 int ql2xqfullrampup
= 120;
86 module_param(ql2xqfullrampup
, int, S_IRUGO
|S_IWUSR
);
87 MODULE_PARM_DESC(ql2xqfullrampup
,
88 "Number of seconds to wait to begin to ramp-up the queue "
89 "depth for a device after a queue-full condition has been "
90 "detected. Default is 120 seconds.");
93 * SCSI host template entry points
95 static int qla2xxx_slave_configure(struct scsi_device
* device
);
96 static int qla2xxx_slave_alloc(struct scsi_device
*);
97 static int qla2xxx_scan_finished(struct Scsi_Host
*, unsigned long time
);
98 static void qla2xxx_scan_start(struct Scsi_Host
*);
99 static void qla2xxx_slave_destroy(struct scsi_device
*);
100 static int qla2x00_queuecommand(struct scsi_cmnd
*cmd
,
101 void (*fn
)(struct scsi_cmnd
*));
102 static int qla24xx_queuecommand(struct scsi_cmnd
*cmd
,
103 void (*fn
)(struct scsi_cmnd
*));
104 static int qla2xxx_eh_abort(struct scsi_cmnd
*);
105 static int qla2xxx_eh_device_reset(struct scsi_cmnd
*);
106 static int qla2xxx_eh_bus_reset(struct scsi_cmnd
*);
107 static int qla2xxx_eh_host_reset(struct scsi_cmnd
*);
108 static int qla2x00_loop_reset(scsi_qla_host_t
*ha
);
109 static int qla2x00_device_reset(scsi_qla_host_t
*, fc_port_t
*);
111 static int qla2x00_change_queue_depth(struct scsi_device
*, int);
112 static int qla2x00_change_queue_type(struct scsi_device
*, int);
114 struct scsi_host_template qla2x00_driver_template
= {
115 .module
= THIS_MODULE
,
116 .name
= QLA2XXX_DRIVER_NAME
,
117 .queuecommand
= qla2x00_queuecommand
,
119 .eh_abort_handler
= qla2xxx_eh_abort
,
120 .eh_device_reset_handler
= qla2xxx_eh_device_reset
,
121 .eh_bus_reset_handler
= qla2xxx_eh_bus_reset
,
122 .eh_host_reset_handler
= qla2xxx_eh_host_reset
,
124 .slave_configure
= qla2xxx_slave_configure
,
126 .slave_alloc
= qla2xxx_slave_alloc
,
127 .slave_destroy
= qla2xxx_slave_destroy
,
128 .scan_finished
= qla2xxx_scan_finished
,
129 .scan_start
= qla2xxx_scan_start
,
130 .change_queue_depth
= qla2x00_change_queue_depth
,
131 .change_queue_type
= qla2x00_change_queue_type
,
134 .use_clustering
= ENABLE_CLUSTERING
,
135 .sg_tablesize
= SG_ALL
,
138 * The RISC allows for each command to transfer (2^32-1) bytes of data,
139 * which equates to 0x800000 sectors.
141 .max_sectors
= 0xFFFF,
142 .shost_attrs
= qla2x00_host_attrs
,
145 struct scsi_host_template qla24xx_driver_template
= {
146 .module
= THIS_MODULE
,
147 .name
= QLA2XXX_DRIVER_NAME
,
148 .queuecommand
= qla24xx_queuecommand
,
150 .eh_abort_handler
= qla2xxx_eh_abort
,
151 .eh_device_reset_handler
= qla2xxx_eh_device_reset
,
152 .eh_bus_reset_handler
= qla2xxx_eh_bus_reset
,
153 .eh_host_reset_handler
= qla2xxx_eh_host_reset
,
155 .slave_configure
= qla2xxx_slave_configure
,
157 .slave_alloc
= qla2xxx_slave_alloc
,
158 .slave_destroy
= qla2xxx_slave_destroy
,
159 .scan_finished
= qla2xxx_scan_finished
,
160 .scan_start
= qla2xxx_scan_start
,
161 .change_queue_depth
= qla2x00_change_queue_depth
,
162 .change_queue_type
= qla2x00_change_queue_type
,
165 .use_clustering
= ENABLE_CLUSTERING
,
166 .sg_tablesize
= SG_ALL
,
168 .max_sectors
= 0xFFFF,
169 .shost_attrs
= qla2x00_host_attrs
,
172 static struct scsi_transport_template
*qla2xxx_transport_template
= NULL
;
173 struct scsi_transport_template
*qla2xxx_transport_vport_template
= NULL
;
175 /* TODO Convert to inlines
180 void qla2x00_timer(scsi_qla_host_t
*);
182 __inline__
void qla2x00_start_timer(scsi_qla_host_t
*,
183 void *, unsigned long);
184 static __inline__
void qla2x00_restart_timer(scsi_qla_host_t
*, unsigned long);
185 __inline__
void qla2x00_stop_timer(scsi_qla_host_t
*);
188 qla2x00_start_timer(scsi_qla_host_t
*ha
, void *func
, unsigned long interval
)
190 init_timer(&ha
->timer
);
191 ha
->timer
.expires
= jiffies
+ interval
* HZ
;
192 ha
->timer
.data
= (unsigned long)ha
;
193 ha
->timer
.function
= (void (*)(unsigned long))func
;
194 add_timer(&ha
->timer
);
195 ha
->timer_active
= 1;
199 qla2x00_restart_timer(scsi_qla_host_t
*ha
, unsigned long interval
)
201 mod_timer(&ha
->timer
, jiffies
+ interval
* HZ
);
205 qla2x00_stop_timer(scsi_qla_host_t
*ha
)
207 del_timer_sync(&ha
->timer
);
208 ha
->timer_active
= 0;
211 static int qla2x00_do_dpc(void *data
);
213 static void qla2x00_rst_aen(scsi_qla_host_t
*);
215 uint8_t qla2x00_mem_alloc(scsi_qla_host_t
*);
216 void qla2x00_mem_free(scsi_qla_host_t
*ha
);
217 static int qla2x00_allocate_sp_pool( scsi_qla_host_t
*ha
);
218 static void qla2x00_free_sp_pool(scsi_qla_host_t
*ha
);
219 static void qla2x00_sp_free_dma(scsi_qla_host_t
*, srb_t
*);
220 void qla2x00_sp_compl(scsi_qla_host_t
*ha
, srb_t
*);
222 /* -------------------------------------------------------------------------- */
225 qla2x00_pci_info_str(struct scsi_qla_host
*ha
, char *str
)
227 static char *pci_bus_modes
[] = {
228 "33", "66", "100", "133",
233 pci_bus
= (ha
->pci_attr
& (BIT_9
| BIT_10
)) >> 9;
236 strcat(str
, pci_bus_modes
[pci_bus
]);
238 pci_bus
= (ha
->pci_attr
& BIT_8
) >> 8;
240 strcat(str
, pci_bus_modes
[pci_bus
]);
242 strcat(str
, " MHz)");
248 qla24xx_pci_info_str(struct scsi_qla_host
*ha
, char *str
)
250 static char *pci_bus_modes
[] = { "33", "66", "100", "133", };
254 pcie_reg
= pci_find_capability(ha
->pdev
, PCI_CAP_ID_EXP
);
257 uint16_t pcie_lstat
, lspeed
, lwidth
;
260 pci_read_config_word(ha
->pdev
, pcie_reg
, &pcie_lstat
);
261 lspeed
= pcie_lstat
& (BIT_0
| BIT_1
| BIT_2
| BIT_3
);
262 lwidth
= (pcie_lstat
&
263 (BIT_4
| BIT_5
| BIT_6
| BIT_7
| BIT_8
| BIT_9
)) >> 4;
265 strcpy(str
, "PCIe (");
267 strcat(str
, "2.5Gb/s ");
268 else if (lspeed
== 2)
269 strcat(str
, "5.0Gb/s ");
271 strcat(str
, "<unknown> ");
272 snprintf(lwstr
, sizeof(lwstr
), "x%d)", lwidth
);
279 pci_bus
= (ha
->pci_attr
& CSRX_PCIX_BUS_MODE_MASK
) >> 8;
280 if (pci_bus
== 0 || pci_bus
== 8) {
282 strcat(str
, pci_bus_modes
[pci_bus
>> 3]);
286 strcat(str
, "Mode 2");
288 strcat(str
, "Mode 1");
290 strcat(str
, pci_bus_modes
[pci_bus
& ~BIT_2
]);
292 strcat(str
, " MHz)");
298 qla2x00_fw_version_str(struct scsi_qla_host
*ha
, char *str
)
302 sprintf(str
, "%d.%02d.%02d ", ha
->fw_major_version
,
303 ha
->fw_minor_version
,
304 ha
->fw_subminor_version
);
306 if (ha
->fw_attributes
& BIT_9
) {
311 switch (ha
->fw_attributes
& 0xFF) {
325 sprintf(un_str
, "(%x)", ha
->fw_attributes
);
329 if (ha
->fw_attributes
& 0x100)
336 qla24xx_fw_version_str(struct scsi_qla_host
*ha
, char *str
)
338 sprintf(str
, "%d.%02d.%02d ", ha
->fw_major_version
,
339 ha
->fw_minor_version
,
340 ha
->fw_subminor_version
);
342 if (ha
->fw_attributes
& BIT_0
)
343 strcat(str
, "[Class 2] ");
344 if (ha
->fw_attributes
& BIT_1
)
345 strcat(str
, "[IP] ");
346 if (ha
->fw_attributes
& BIT_2
)
347 strcat(str
, "[Multi-ID] ");
348 if (ha
->fw_attributes
& BIT_3
)
349 strcat(str
, "[SB-2] ");
350 if (ha
->fw_attributes
& BIT_4
)
351 strcat(str
, "[T10 CRC] ");
352 if (ha
->fw_attributes
& BIT_5
)
353 strcat(str
, "[VI] ");
354 if (ha
->fw_attributes
& BIT_13
)
355 strcat(str
, "[Experimental]");
359 static inline srb_t
*
360 qla2x00_get_new_sp(scsi_qla_host_t
*ha
, fc_port_t
*fcport
,
361 struct scsi_cmnd
*cmd
, void (*done
)(struct scsi_cmnd
*))
365 sp
= mempool_alloc(ha
->srb_mempool
, GFP_ATOMIC
);
373 CMD_SP(cmd
) = (void *)sp
;
374 cmd
->scsi_done
= done
;
380 qla2x00_queuecommand(struct scsi_cmnd
*cmd
, void (*done
)(struct scsi_cmnd
*))
382 scsi_qla_host_t
*ha
= to_qla_host(cmd
->device
->host
);
383 fc_port_t
*fcport
= (struct fc_port
*) cmd
->device
->hostdata
;
384 struct fc_rport
*rport
= starget_to_rport(scsi_target(cmd
->device
));
388 rval
= fc_remote_port_chkready(rport
);
391 goto qc_fail_command
;
394 /* Close window on fcport/rport state-transitioning. */
395 if (!*(fc_port_t
**)rport
->dd_data
) {
396 cmd
->result
= DID_IMM_RETRY
<< 16;
397 goto qc_fail_command
;
400 if (atomic_read(&fcport
->state
) != FCS_ONLINE
) {
401 if (atomic_read(&fcport
->state
) == FCS_DEVICE_DEAD
||
402 atomic_read(&ha
->loop_state
) == LOOP_DEAD
) {
403 cmd
->result
= DID_NO_CONNECT
<< 16;
404 goto qc_fail_command
;
409 spin_unlock_irq(ha
->host
->host_lock
);
411 sp
= qla2x00_get_new_sp(ha
, fcport
, cmd
, done
);
413 goto qc_host_busy_lock
;
415 rval
= qla2x00_start_scsi(sp
);
416 if (rval
!= QLA_SUCCESS
)
417 goto qc_host_busy_free_sp
;
419 spin_lock_irq(ha
->host
->host_lock
);
423 qc_host_busy_free_sp
:
424 qla2x00_sp_free_dma(ha
, sp
);
425 mempool_free(sp
, ha
->srb_mempool
);
428 spin_lock_irq(ha
->host
->host_lock
);
431 return SCSI_MLQUEUE_HOST_BUSY
;
441 qla24xx_queuecommand(struct scsi_cmnd
*cmd
, void (*done
)(struct scsi_cmnd
*))
443 scsi_qla_host_t
*ha
= to_qla_host(cmd
->device
->host
);
444 fc_port_t
*fcport
= (struct fc_port
*) cmd
->device
->hostdata
;
445 struct fc_rport
*rport
= starget_to_rport(scsi_target(cmd
->device
));
448 scsi_qla_host_t
*pha
= to_qla_parent(ha
);
450 rval
= fc_remote_port_chkready(rport
);
453 goto qc24_fail_command
;
456 /* Close window on fcport/rport state-transitioning. */
457 if (!*(fc_port_t
**)rport
->dd_data
) {
458 cmd
->result
= DID_IMM_RETRY
<< 16;
459 goto qc24_fail_command
;
462 if (atomic_read(&fcport
->state
) != FCS_ONLINE
) {
463 if (atomic_read(&fcport
->state
) == FCS_DEVICE_DEAD
||
464 atomic_read(&pha
->loop_state
) == LOOP_DEAD
) {
465 cmd
->result
= DID_NO_CONNECT
<< 16;
466 goto qc24_fail_command
;
471 spin_unlock_irq(ha
->host
->host_lock
);
473 sp
= qla2x00_get_new_sp(pha
, fcport
, cmd
, done
);
475 goto qc24_host_busy_lock
;
477 rval
= qla24xx_start_scsi(sp
);
478 if (rval
!= QLA_SUCCESS
)
479 goto qc24_host_busy_free_sp
;
481 spin_lock_irq(ha
->host
->host_lock
);
485 qc24_host_busy_free_sp
:
486 qla2x00_sp_free_dma(pha
, sp
);
487 mempool_free(sp
, pha
->srb_mempool
);
490 spin_lock_irq(ha
->host
->host_lock
);
493 return SCSI_MLQUEUE_HOST_BUSY
;
503 * qla2x00_eh_wait_on_command
504 * Waits for the command to be returned by the Firmware for some
508 * ha = actual ha whose done queue will contain the command
509 * returned by firmware.
510 * cmd = Scsi Command to wait on.
511 * flag = Abort/Reset(Bus or Device Reset)
518 qla2x00_eh_wait_on_command(scsi_qla_host_t
*ha
, struct scsi_cmnd
*cmd
)
520 #define ABORT_POLLING_PERIOD 1000
521 #define ABORT_WAIT_ITER ((10 * 1000) / (ABORT_POLLING_PERIOD))
522 unsigned long wait_iter
= ABORT_WAIT_ITER
;
523 int ret
= QLA_SUCCESS
;
525 while (CMD_SP(cmd
)) {
526 msleep(ABORT_POLLING_PERIOD
);
532 ret
= QLA_FUNCTION_FAILED
;
538 * qla2x00_wait_for_hba_online
539 * Wait till the HBA is online after going through
540 * <= MAX_RETRIES_OF_ISP_ABORT or
541 * finally HBA is disabled ie marked offline
544 * ha - pointer to host adapter structure
547 * Does context switching-Release SPIN_LOCK
548 * (if any) before calling this routine.
551 * Success (Adapter is online) : 0
552 * Failed (Adapter is offline/disabled) : 1
555 qla2x00_wait_for_hba_online(scsi_qla_host_t
*ha
)
558 unsigned long wait_online
;
559 scsi_qla_host_t
*pha
= to_qla_parent(ha
);
561 wait_online
= jiffies
+ (MAX_LOOP_TIMEOUT
* HZ
);
562 while (((test_bit(ISP_ABORT_NEEDED
, &pha
->dpc_flags
)) ||
563 test_bit(ABORT_ISP_ACTIVE
, &pha
->dpc_flags
) ||
564 test_bit(ISP_ABORT_RETRY
, &pha
->dpc_flags
) ||
565 pha
->dpc_active
) && time_before(jiffies
, wait_online
)) {
569 if (pha
->flags
.online
)
570 return_status
= QLA_SUCCESS
;
572 return_status
= QLA_FUNCTION_FAILED
;
574 DEBUG2(printk("%s return_status=%d\n",__func__
,return_status
));
576 return (return_status
);
580 * qla2x00_wait_for_loop_ready
581 * Wait for MAX_LOOP_TIMEOUT(5 min) value for loop
582 * to be in LOOP_READY state.
584 * ha - pointer to host adapter structure
587 * Does context switching-Release SPIN_LOCK
588 * (if any) before calling this routine.
592 * Success (LOOP_READY) : 0
593 * Failed (LOOP_NOT_READY) : 1
596 qla2x00_wait_for_loop_ready(scsi_qla_host_t
*ha
)
598 int return_status
= QLA_SUCCESS
;
599 unsigned long loop_timeout
;
600 scsi_qla_host_t
*pha
= to_qla_parent(ha
);
602 /* wait for 5 min at the max for loop to be ready */
603 loop_timeout
= jiffies
+ (MAX_LOOP_TIMEOUT
* HZ
);
605 while ((!atomic_read(&pha
->loop_down_timer
) &&
606 atomic_read(&pha
->loop_state
) == LOOP_DOWN
) ||
607 atomic_read(&pha
->loop_state
) != LOOP_READY
) {
608 if (atomic_read(&pha
->loop_state
) == LOOP_DEAD
) {
609 return_status
= QLA_FUNCTION_FAILED
;
613 if (time_after_eq(jiffies
, loop_timeout
)) {
614 return_status
= QLA_FUNCTION_FAILED
;
618 return (return_status
);
622 qla2x00_block_error_handler(struct scsi_cmnd
*cmnd
)
624 struct Scsi_Host
*shost
= cmnd
->device
->host
;
625 struct fc_rport
*rport
= starget_to_rport(scsi_target(cmnd
->device
));
628 spin_lock_irqsave(shost
->host_lock
, flags
);
629 while (rport
->port_state
== FC_PORTSTATE_BLOCKED
) {
630 spin_unlock_irqrestore(shost
->host_lock
, flags
);
632 spin_lock_irqsave(shost
->host_lock
, flags
);
634 spin_unlock_irqrestore(shost
->host_lock
, flags
);
638 /**************************************************************************
642 * The abort function will abort the specified command.
645 * cmd = Linux SCSI command packet to be aborted.
648 * Either SUCCESS or FAILED.
651 * Only return FAILED if command not returned by firmware.
652 **************************************************************************/
654 qla2xxx_eh_abort(struct scsi_cmnd
*cmd
)
656 scsi_qla_host_t
*ha
= to_qla_host(cmd
->device
->host
);
659 unsigned int id
, lun
;
660 unsigned long serial
;
663 scsi_qla_host_t
*pha
= to_qla_parent(ha
);
665 qla2x00_block_error_handler(cmd
);
672 id
= cmd
->device
->id
;
673 lun
= cmd
->device
->lun
;
674 serial
= cmd
->serial_number
;
676 /* Check active list for command command. */
677 spin_lock_irqsave(&pha
->hardware_lock
, flags
);
678 for (i
= 1; i
< MAX_OUTSTANDING_COMMANDS
; i
++) {
679 sp
= pha
->outstanding_cmds
[i
];
687 DEBUG2(printk("%s(%ld): aborting sp %p from RISC. pid=%ld.\n",
688 __func__
, ha
->host_no
, sp
, serial
));
689 DEBUG3(qla2x00_print_scsi_cmd(cmd
));
691 spin_unlock_irqrestore(&pha
->hardware_lock
, flags
);
692 if (ha
->isp_ops
->abort_command(ha
, sp
)) {
693 DEBUG2(printk("%s(%ld): abort_command "
694 "mbx failed.\n", __func__
, ha
->host_no
));
696 DEBUG3(printk("%s(%ld): abort_command "
697 "mbx success.\n", __func__
, ha
->host_no
));
700 spin_lock_irqsave(&pha
->hardware_lock
, flags
);
704 spin_unlock_irqrestore(&pha
->hardware_lock
, flags
);
706 /* Wait for the command to be returned. */
708 if (qla2x00_eh_wait_on_command(ha
, cmd
) != QLA_SUCCESS
) {
709 qla_printk(KERN_ERR
, ha
,
710 "scsi(%ld:%d:%d): Abort handler timed out -- %lx "
711 "%x.\n", ha
->host_no
, id
, lun
, serial
, ret
);
716 qla_printk(KERN_INFO
, ha
,
717 "scsi(%ld:%d:%d): Abort command issued -- %d %lx %x.\n",
718 ha
->host_no
, id
, lun
, wait
, serial
, ret
);
723 /**************************************************************************
724 * qla2x00_eh_wait_for_pending_target_commands
727 * Waits for all the commands to come back from the specified target.
730 * ha - pointer to scsi_qla_host structure.
733 * Either SUCCESS or FAILED.
736 **************************************************************************/
738 qla2x00_eh_wait_for_pending_target_commands(scsi_qla_host_t
*ha
, unsigned int t
)
743 struct scsi_cmnd
*cmd
;
745 scsi_qla_host_t
*pha
= to_qla_parent(ha
);
750 * Waiting for all commands for the designated target in the active
753 for (cnt
= 1; cnt
< MAX_OUTSTANDING_COMMANDS
; cnt
++) {
754 spin_lock_irqsave(&pha
->hardware_lock
, flags
);
755 sp
= pha
->outstanding_cmds
[cnt
];
758 spin_unlock_irqrestore(&pha
->hardware_lock
, flags
);
759 if (cmd
->device
->id
== t
&&
760 ha
->vp_idx
== sp
->ha
->vp_idx
) {
761 if (!qla2x00_eh_wait_on_command(ha
, cmd
)) {
767 spin_unlock_irqrestore(&pha
->hardware_lock
, flags
);
774 /**************************************************************************
775 * qla2xxx_eh_device_reset
778 * The device reset function will reset the target and abort any
779 * executing commands.
781 * NOTE: The use of SP is undefined within this context. Do *NOT*
782 * attempt to use this value, even if you determine it is
786 * cmd = Linux SCSI command packet of the command that cause the
790 * SUCCESS/FAILURE (defined as macro in scsi.h).
792 **************************************************************************/
794 qla2xxx_eh_device_reset(struct scsi_cmnd
*cmd
)
796 scsi_qla_host_t
*ha
= to_qla_host(cmd
->device
->host
);
797 fc_port_t
*fcport
= (struct fc_port
*) cmd
->device
->hostdata
;
799 unsigned int id
, lun
;
800 unsigned long serial
;
802 qla2x00_block_error_handler(cmd
);
804 id
= cmd
->device
->id
;
805 lun
= cmd
->device
->lun
;
806 serial
= cmd
->serial_number
;
811 qla_printk(KERN_INFO
, ha
,
812 "scsi(%ld:%d:%d): DEVICE RESET ISSUED.\n", ha
->host_no
, id
, lun
);
814 if (qla2x00_wait_for_hba_online(ha
) != QLA_SUCCESS
)
815 goto eh_dev_reset_done
;
817 if (qla2x00_wait_for_loop_ready(ha
) == QLA_SUCCESS
) {
818 if (qla2x00_device_reset(ha
, fcport
) == 0)
821 #if defined(LOGOUT_AFTER_DEVICE_RESET)
822 if (ret
== SUCCESS
) {
823 if (fcport
->flags
& FC_FABRIC_DEVICE
) {
824 ha
->isp_ops
->fabric_logout(ha
, fcport
->loop_id
);
825 qla2x00_mark_device_lost(ha
, fcport
, 0, 0);
830 DEBUG2(printk(KERN_INFO
831 "%s failed: loop not ready\n",__func__
));
835 DEBUG3(printk("%s(%ld): device reset failed\n",
836 __func__
, ha
->host_no
));
837 qla_printk(KERN_INFO
, ha
, "%s: device reset failed\n",
840 goto eh_dev_reset_done
;
843 /* Flush outstanding commands. */
844 if (qla2x00_eh_wait_for_pending_target_commands(ha
, id
))
847 DEBUG3(printk("%s(%ld): failed while waiting for commands\n",
848 __func__
, ha
->host_no
));
849 qla_printk(KERN_INFO
, ha
,
850 "%s: failed while waiting for commands\n", __func__
);
852 qla_printk(KERN_INFO
, ha
,
853 "scsi(%ld:%d:%d): DEVICE RESET SUCCEEDED.\n", ha
->host_no
,
859 /**************************************************************************
860 * qla2x00_eh_wait_for_pending_commands
863 * Waits for all the commands to come back from the specified host.
866 * ha - pointer to scsi_qla_host structure.
873 **************************************************************************/
875 qla2x00_eh_wait_for_pending_commands(scsi_qla_host_t
*ha
)
880 struct scsi_cmnd
*cmd
;
886 * Waiting for all commands for the designated target in the active
889 for (cnt
= 1; cnt
< MAX_OUTSTANDING_COMMANDS
; cnt
++) {
890 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
891 sp
= ha
->outstanding_cmds
[cnt
];
894 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
895 status
= qla2x00_eh_wait_on_command(ha
, cmd
);
900 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
907 /**************************************************************************
908 * qla2xxx_eh_bus_reset
911 * The bus reset function will reset the bus and abort any executing
915 * cmd = Linux SCSI command packet of the command that cause the
919 * SUCCESS/FAILURE (defined as macro in scsi.h).
921 **************************************************************************/
923 qla2xxx_eh_bus_reset(struct scsi_cmnd
*cmd
)
925 scsi_qla_host_t
*ha
= to_qla_host(cmd
->device
->host
);
926 scsi_qla_host_t
*pha
= to_qla_parent(ha
);
927 fc_port_t
*fcport
= (struct fc_port
*) cmd
->device
->hostdata
;
929 unsigned int id
, lun
;
930 unsigned long serial
;
932 qla2x00_block_error_handler(cmd
);
934 id
= cmd
->device
->id
;
935 lun
= cmd
->device
->lun
;
936 serial
= cmd
->serial_number
;
941 qla_printk(KERN_INFO
, ha
,
942 "scsi(%ld:%d:%d): LOOP RESET ISSUED.\n", ha
->host_no
, id
, lun
);
944 if (qla2x00_wait_for_hba_online(ha
) != QLA_SUCCESS
) {
945 DEBUG2(printk("%s failed:board disabled\n",__func__
));
946 goto eh_bus_reset_done
;
949 if (qla2x00_wait_for_loop_ready(ha
) == QLA_SUCCESS
) {
950 if (qla2x00_loop_reset(ha
) == QLA_SUCCESS
)
954 goto eh_bus_reset_done
;
956 /* Flush outstanding commands. */
957 if (!qla2x00_eh_wait_for_pending_commands(pha
))
961 qla_printk(KERN_INFO
, ha
, "%s: reset %s\n", __func__
,
962 (ret
== FAILED
) ? "failed" : "succeded");
967 /**************************************************************************
968 * qla2xxx_eh_host_reset
971 * The reset function will reset the Adapter.
974 * cmd = Linux SCSI command packet of the command that cause the
978 * Either SUCCESS or FAILED.
981 **************************************************************************/
983 qla2xxx_eh_host_reset(struct scsi_cmnd
*cmd
)
985 scsi_qla_host_t
*ha
= to_qla_host(cmd
->device
->host
);
986 fc_port_t
*fcport
= (struct fc_port
*) cmd
->device
->hostdata
;
988 unsigned int id
, lun
;
989 unsigned long serial
;
990 scsi_qla_host_t
*pha
= to_qla_parent(ha
);
992 qla2x00_block_error_handler(cmd
);
994 id
= cmd
->device
->id
;
995 lun
= cmd
->device
->lun
;
996 serial
= cmd
->serial_number
;
1001 qla_printk(KERN_INFO
, ha
,
1002 "scsi(%ld:%d:%d): ADAPTER RESET ISSUED.\n", ha
->host_no
, id
, lun
);
1004 if (qla2x00_wait_for_hba_online(ha
) != QLA_SUCCESS
)
1005 goto eh_host_reset_lock
;
1008 * Fixme-may be dpc thread is active and processing
1009 * loop_resync,so wait a while for it to
1010 * be completed and then issue big hammer.Otherwise
1011 * it may cause I/O failure as big hammer marks the
1012 * devices as lost kicking of the port_down_timer
1013 * while dpc is stuck for the mailbox to complete.
1015 qla2x00_wait_for_loop_ready(ha
);
1016 set_bit(ABORT_ISP_ACTIVE
, &pha
->dpc_flags
);
1017 if (qla2x00_abort_isp(pha
)) {
1018 clear_bit(ABORT_ISP_ACTIVE
, &pha
->dpc_flags
);
1019 /* failed. schedule dpc to try */
1020 set_bit(ISP_ABORT_NEEDED
, &pha
->dpc_flags
);
1022 if (qla2x00_wait_for_hba_online(ha
) != QLA_SUCCESS
)
1023 goto eh_host_reset_lock
;
1025 clear_bit(ABORT_ISP_ACTIVE
, &pha
->dpc_flags
);
1027 /* Waiting for our command in done_queue to be returned to OS.*/
1028 if (qla2x00_eh_wait_for_pending_commands(pha
))
1032 qla2x00_vp_abort_isp(ha
);
1035 qla_printk(KERN_INFO
, ha
, "%s: reset %s\n", __func__
,
1036 (ret
== FAILED
) ? "failed" : "succeded");
1042 * qla2x00_loop_reset
1046 * ha = adapter block pointer.
1052 qla2x00_loop_reset(scsi_qla_host_t
*ha
)
1055 struct fc_port
*fcport
;
1057 if (ha
->flags
.enable_lip_full_login
) {
1058 ret
= qla2x00_full_login_lip(ha
);
1059 if (ret
!= QLA_SUCCESS
) {
1060 DEBUG2_3(printk("%s(%ld): bus_reset failed: "
1061 "full_login_lip=%d.\n", __func__
, ha
->host_no
,
1064 atomic_set(&ha
->loop_state
, LOOP_DOWN
);
1065 atomic_set(&ha
->loop_down_timer
, LOOP_DOWN_TIME
);
1066 qla2x00_mark_all_devices_lost(ha
, 0);
1067 qla2x00_wait_for_loop_ready(ha
);
1070 if (ha
->flags
.enable_lip_reset
) {
1071 ret
= qla2x00_lip_reset(ha
);
1072 if (ret
!= QLA_SUCCESS
) {
1073 DEBUG2_3(printk("%s(%ld): bus_reset failed: "
1074 "lip_reset=%d.\n", __func__
, ha
->host_no
, ret
));
1076 qla2x00_wait_for_loop_ready(ha
);
1079 if (ha
->flags
.enable_target_reset
) {
1080 list_for_each_entry(fcport
, &ha
->fcports
, list
) {
1081 if (fcport
->port_type
!= FCT_TARGET
)
1084 ret
= qla2x00_device_reset(ha
, fcport
);
1085 if (ret
!= QLA_SUCCESS
) {
1086 DEBUG2_3(printk("%s(%ld): bus_reset failed: "
1087 "target_reset=%d d_id=%x.\n", __func__
,
1088 ha
->host_no
, ret
, fcport
->d_id
.b24
));
1093 /* Issue marker command only when we are going to start the I/O */
1094 ha
->marker_needed
= 1;
1100 * qla2x00_device_reset
1101 * Issue bus device reset message to the target.
1104 * ha = adapter block pointer.
1106 * TARGET_QUEUE_LOCK must be released.
1107 * ADAPTER_STATE_LOCK must be released.
1113 qla2x00_device_reset(scsi_qla_host_t
*ha
, fc_port_t
*reset_fcport
)
1115 /* Abort Target command will clear Reservation */
1116 return ha
->isp_ops
->abort_target(reset_fcport
);
1120 qla2xxx_slave_alloc(struct scsi_device
*sdev
)
1122 struct fc_rport
*rport
= starget_to_rport(scsi_target(sdev
));
1124 if (!rport
|| fc_remote_port_chkready(rport
))
1127 sdev
->hostdata
= *(fc_port_t
**)rport
->dd_data
;
1133 qla2xxx_slave_configure(struct scsi_device
*sdev
)
1135 scsi_qla_host_t
*ha
= to_qla_host(sdev
->host
);
1136 struct fc_rport
*rport
= starget_to_rport(sdev
->sdev_target
);
1138 if (sdev
->tagged_supported
)
1139 scsi_activate_tcq(sdev
, ha
->max_q_depth
);
1141 scsi_deactivate_tcq(sdev
, ha
->max_q_depth
);
1143 rport
->dev_loss_tmo
= ha
->port_down_retry_count
+ 5;
1149 qla2xxx_slave_destroy(struct scsi_device
*sdev
)
1151 sdev
->hostdata
= NULL
;
1155 qla2x00_change_queue_depth(struct scsi_device
*sdev
, int qdepth
)
1157 scsi_adjust_queue_depth(sdev
, scsi_get_tag_type(sdev
), qdepth
);
1158 return sdev
->queue_depth
;
1162 qla2x00_change_queue_type(struct scsi_device
*sdev
, int tag_type
)
1164 if (sdev
->tagged_supported
) {
1165 scsi_set_tag_type(sdev
, tag_type
);
1167 scsi_activate_tcq(sdev
, sdev
->queue_depth
);
1169 scsi_deactivate_tcq(sdev
, sdev
->queue_depth
);
1177 * qla2x00_config_dma_addressing() - Configure OS DMA addressing method.
1180 * At exit, the @ha's flags.enable_64bit_addressing set to indicated
1181 * supported addressing method.
1184 qla2x00_config_dma_addressing(scsi_qla_host_t
*ha
)
1186 /* Assume a 32bit DMA mask. */
1187 ha
->flags
.enable_64bit_addressing
= 0;
1189 if (!dma_set_mask(&ha
->pdev
->dev
, DMA_64BIT_MASK
)) {
1190 /* Any upper-dword bits set? */
1191 if (MSD(dma_get_required_mask(&ha
->pdev
->dev
)) &&
1192 !pci_set_consistent_dma_mask(ha
->pdev
, DMA_64BIT_MASK
)) {
1193 /* Ok, a 64bit DMA mask is applicable. */
1194 ha
->flags
.enable_64bit_addressing
= 1;
1195 ha
->isp_ops
->calc_req_entries
= qla2x00_calc_iocbs_64
;
1196 ha
->isp_ops
->build_iocbs
= qla2x00_build_scsi_iocbs_64
;
1201 dma_set_mask(&ha
->pdev
->dev
, DMA_32BIT_MASK
);
1202 pci_set_consistent_dma_mask(ha
->pdev
, DMA_32BIT_MASK
);
1206 qla2x00_enable_intrs(scsi_qla_host_t
*ha
)
1208 unsigned long flags
= 0;
1209 struct device_reg_2xxx __iomem
*reg
= &ha
->iobase
->isp
;
1211 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
1212 ha
->interrupts_on
= 1;
1213 /* enable risc and host interrupts */
1214 WRT_REG_WORD(®
->ictrl
, ICR_EN_INT
| ICR_EN_RISC
);
1215 RD_REG_WORD(®
->ictrl
);
1216 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
1221 qla2x00_disable_intrs(scsi_qla_host_t
*ha
)
1223 unsigned long flags
= 0;
1224 struct device_reg_2xxx __iomem
*reg
= &ha
->iobase
->isp
;
1226 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
1227 ha
->interrupts_on
= 0;
1228 /* disable risc and host interrupts */
1229 WRT_REG_WORD(®
->ictrl
, 0);
1230 RD_REG_WORD(®
->ictrl
);
1231 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
1235 qla24xx_enable_intrs(scsi_qla_host_t
*ha
)
1237 unsigned long flags
= 0;
1238 struct device_reg_24xx __iomem
*reg
= &ha
->iobase
->isp24
;
1240 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
1241 ha
->interrupts_on
= 1;
1242 WRT_REG_DWORD(®
->ictrl
, ICRX_EN_RISC_INT
);
1243 RD_REG_DWORD(®
->ictrl
);
1244 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
1248 qla24xx_disable_intrs(scsi_qla_host_t
*ha
)
1250 unsigned long flags
= 0;
1251 struct device_reg_24xx __iomem
*reg
= &ha
->iobase
->isp24
;
1253 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
1254 ha
->interrupts_on
= 0;
1255 WRT_REG_DWORD(®
->ictrl
, 0);
1256 RD_REG_DWORD(®
->ictrl
);
1257 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
1260 static struct isp_operations qla2100_isp_ops
= {
1261 .pci_config
= qla2100_pci_config
,
1262 .reset_chip
= qla2x00_reset_chip
,
1263 .chip_diag
= qla2x00_chip_diag
,
1264 .config_rings
= qla2x00_config_rings
,
1265 .reset_adapter
= qla2x00_reset_adapter
,
1266 .nvram_config
= qla2x00_nvram_config
,
1267 .update_fw_options
= qla2x00_update_fw_options
,
1268 .load_risc
= qla2x00_load_risc
,
1269 .pci_info_str
= qla2x00_pci_info_str
,
1270 .fw_version_str
= qla2x00_fw_version_str
,
1271 .intr_handler
= qla2100_intr_handler
,
1272 .enable_intrs
= qla2x00_enable_intrs
,
1273 .disable_intrs
= qla2x00_disable_intrs
,
1274 .abort_command
= qla2x00_abort_command
,
1275 .abort_target
= qla2x00_abort_target
,
1276 .fabric_login
= qla2x00_login_fabric
,
1277 .fabric_logout
= qla2x00_fabric_logout
,
1278 .calc_req_entries
= qla2x00_calc_iocbs_32
,
1279 .build_iocbs
= qla2x00_build_scsi_iocbs_32
,
1280 .prep_ms_iocb
= qla2x00_prep_ms_iocb
,
1281 .prep_ms_fdmi_iocb
= qla2x00_prep_ms_fdmi_iocb
,
1282 .read_nvram
= qla2x00_read_nvram_data
,
1283 .write_nvram
= qla2x00_write_nvram_data
,
1284 .fw_dump
= qla2100_fw_dump
,
1287 .beacon_blink
= NULL
,
1288 .read_optrom
= qla2x00_read_optrom_data
,
1289 .write_optrom
= qla2x00_write_optrom_data
,
1290 .get_flash_version
= qla2x00_get_flash_version
,
1293 static struct isp_operations qla2300_isp_ops
= {
1294 .pci_config
= qla2300_pci_config
,
1295 .reset_chip
= qla2x00_reset_chip
,
1296 .chip_diag
= qla2x00_chip_diag
,
1297 .config_rings
= qla2x00_config_rings
,
1298 .reset_adapter
= qla2x00_reset_adapter
,
1299 .nvram_config
= qla2x00_nvram_config
,
1300 .update_fw_options
= qla2x00_update_fw_options
,
1301 .load_risc
= qla2x00_load_risc
,
1302 .pci_info_str
= qla2x00_pci_info_str
,
1303 .fw_version_str
= qla2x00_fw_version_str
,
1304 .intr_handler
= qla2300_intr_handler
,
1305 .enable_intrs
= qla2x00_enable_intrs
,
1306 .disable_intrs
= qla2x00_disable_intrs
,
1307 .abort_command
= qla2x00_abort_command
,
1308 .abort_target
= qla2x00_abort_target
,
1309 .fabric_login
= qla2x00_login_fabric
,
1310 .fabric_logout
= qla2x00_fabric_logout
,
1311 .calc_req_entries
= qla2x00_calc_iocbs_32
,
1312 .build_iocbs
= qla2x00_build_scsi_iocbs_32
,
1313 .prep_ms_iocb
= qla2x00_prep_ms_iocb
,
1314 .prep_ms_fdmi_iocb
= qla2x00_prep_ms_fdmi_iocb
,
1315 .read_nvram
= qla2x00_read_nvram_data
,
1316 .write_nvram
= qla2x00_write_nvram_data
,
1317 .fw_dump
= qla2300_fw_dump
,
1318 .beacon_on
= qla2x00_beacon_on
,
1319 .beacon_off
= qla2x00_beacon_off
,
1320 .beacon_blink
= qla2x00_beacon_blink
,
1321 .read_optrom
= qla2x00_read_optrom_data
,
1322 .write_optrom
= qla2x00_write_optrom_data
,
1323 .get_flash_version
= qla2x00_get_flash_version
,
1326 static struct isp_operations qla24xx_isp_ops
= {
1327 .pci_config
= qla24xx_pci_config
,
1328 .reset_chip
= qla24xx_reset_chip
,
1329 .chip_diag
= qla24xx_chip_diag
,
1330 .config_rings
= qla24xx_config_rings
,
1331 .reset_adapter
= qla24xx_reset_adapter
,
1332 .nvram_config
= qla24xx_nvram_config
,
1333 .update_fw_options
= qla24xx_update_fw_options
,
1334 .load_risc
= qla24xx_load_risc
,
1335 .pci_info_str
= qla24xx_pci_info_str
,
1336 .fw_version_str
= qla24xx_fw_version_str
,
1337 .intr_handler
= qla24xx_intr_handler
,
1338 .enable_intrs
= qla24xx_enable_intrs
,
1339 .disable_intrs
= qla24xx_disable_intrs
,
1340 .abort_command
= qla24xx_abort_command
,
1341 .abort_target
= qla24xx_abort_target
,
1342 .fabric_login
= qla24xx_login_fabric
,
1343 .fabric_logout
= qla24xx_fabric_logout
,
1344 .calc_req_entries
= NULL
,
1345 .build_iocbs
= NULL
,
1346 .prep_ms_iocb
= qla24xx_prep_ms_iocb
,
1347 .prep_ms_fdmi_iocb
= qla24xx_prep_ms_fdmi_iocb
,
1348 .read_nvram
= qla24xx_read_nvram_data
,
1349 .write_nvram
= qla24xx_write_nvram_data
,
1350 .fw_dump
= qla24xx_fw_dump
,
1351 .beacon_on
= qla24xx_beacon_on
,
1352 .beacon_off
= qla24xx_beacon_off
,
1353 .beacon_blink
= qla24xx_beacon_blink
,
1354 .read_optrom
= qla24xx_read_optrom_data
,
1355 .write_optrom
= qla24xx_write_optrom_data
,
1356 .get_flash_version
= qla24xx_get_flash_version
,
1359 static struct isp_operations qla25xx_isp_ops
= {
1360 .pci_config
= qla25xx_pci_config
,
1361 .reset_chip
= qla24xx_reset_chip
,
1362 .chip_diag
= qla24xx_chip_diag
,
1363 .config_rings
= qla24xx_config_rings
,
1364 .reset_adapter
= qla24xx_reset_adapter
,
1365 .nvram_config
= qla24xx_nvram_config
,
1366 .update_fw_options
= qla24xx_update_fw_options
,
1367 .load_risc
= qla24xx_load_risc
,
1368 .pci_info_str
= qla24xx_pci_info_str
,
1369 .fw_version_str
= qla24xx_fw_version_str
,
1370 .intr_handler
= qla24xx_intr_handler
,
1371 .enable_intrs
= qla24xx_enable_intrs
,
1372 .disable_intrs
= qla24xx_disable_intrs
,
1373 .abort_command
= qla24xx_abort_command
,
1374 .abort_target
= qla24xx_abort_target
,
1375 .fabric_login
= qla24xx_login_fabric
,
1376 .fabric_logout
= qla24xx_fabric_logout
,
1377 .calc_req_entries
= NULL
,
1378 .build_iocbs
= NULL
,
1379 .prep_ms_iocb
= qla24xx_prep_ms_iocb
,
1380 .prep_ms_fdmi_iocb
= qla24xx_prep_ms_fdmi_iocb
,
1381 .read_nvram
= qla25xx_read_nvram_data
,
1382 .write_nvram
= qla25xx_write_nvram_data
,
1383 .fw_dump
= qla25xx_fw_dump
,
1384 .beacon_on
= qla24xx_beacon_on
,
1385 .beacon_off
= qla24xx_beacon_off
,
1386 .beacon_blink
= qla24xx_beacon_blink
,
1387 .read_optrom
= qla24xx_read_optrom_data
,
1388 .write_optrom
= qla24xx_write_optrom_data
,
1389 .get_flash_version
= qla24xx_get_flash_version
,
1393 qla2x00_set_isp_flags(scsi_qla_host_t
*ha
)
1395 ha
->device_type
= DT_EXTENDED_IDS
;
1396 switch (ha
->pdev
->device
) {
1397 case PCI_DEVICE_ID_QLOGIC_ISP2100
:
1398 ha
->device_type
|= DT_ISP2100
;
1399 ha
->device_type
&= ~DT_EXTENDED_IDS
;
1400 ha
->fw_srisc_address
= RISC_START_ADDRESS_2100
;
1402 case PCI_DEVICE_ID_QLOGIC_ISP2200
:
1403 ha
->device_type
|= DT_ISP2200
;
1404 ha
->device_type
&= ~DT_EXTENDED_IDS
;
1405 ha
->fw_srisc_address
= RISC_START_ADDRESS_2100
;
1407 case PCI_DEVICE_ID_QLOGIC_ISP2300
:
1408 ha
->device_type
|= DT_ISP2300
;
1409 ha
->device_type
|= DT_ZIO_SUPPORTED
;
1410 ha
->fw_srisc_address
= RISC_START_ADDRESS_2300
;
1412 case PCI_DEVICE_ID_QLOGIC_ISP2312
:
1413 ha
->device_type
|= DT_ISP2312
;
1414 ha
->device_type
|= DT_ZIO_SUPPORTED
;
1415 ha
->fw_srisc_address
= RISC_START_ADDRESS_2300
;
1417 case PCI_DEVICE_ID_QLOGIC_ISP2322
:
1418 ha
->device_type
|= DT_ISP2322
;
1419 ha
->device_type
|= DT_ZIO_SUPPORTED
;
1420 if (ha
->pdev
->subsystem_vendor
== 0x1028 &&
1421 ha
->pdev
->subsystem_device
== 0x0170)
1422 ha
->device_type
|= DT_OEM_001
;
1423 ha
->fw_srisc_address
= RISC_START_ADDRESS_2300
;
1425 case PCI_DEVICE_ID_QLOGIC_ISP6312
:
1426 ha
->device_type
|= DT_ISP6312
;
1427 ha
->fw_srisc_address
= RISC_START_ADDRESS_2300
;
1429 case PCI_DEVICE_ID_QLOGIC_ISP6322
:
1430 ha
->device_type
|= DT_ISP6322
;
1431 ha
->fw_srisc_address
= RISC_START_ADDRESS_2300
;
1433 case PCI_DEVICE_ID_QLOGIC_ISP2422
:
1434 ha
->device_type
|= DT_ISP2422
;
1435 ha
->device_type
|= DT_ZIO_SUPPORTED
;
1436 ha
->device_type
|= DT_FWI2
;
1437 ha
->device_type
|= DT_IIDMA
;
1438 ha
->fw_srisc_address
= RISC_START_ADDRESS_2400
;
1440 case PCI_DEVICE_ID_QLOGIC_ISP2432
:
1441 ha
->device_type
|= DT_ISP2432
;
1442 ha
->device_type
|= DT_ZIO_SUPPORTED
;
1443 ha
->device_type
|= DT_FWI2
;
1444 ha
->device_type
|= DT_IIDMA
;
1445 ha
->fw_srisc_address
= RISC_START_ADDRESS_2400
;
1447 case PCI_DEVICE_ID_QLOGIC_ISP5422
:
1448 ha
->device_type
|= DT_ISP5422
;
1449 ha
->device_type
|= DT_FWI2
;
1450 ha
->fw_srisc_address
= RISC_START_ADDRESS_2400
;
1452 case PCI_DEVICE_ID_QLOGIC_ISP5432
:
1453 ha
->device_type
|= DT_ISP5432
;
1454 ha
->device_type
|= DT_FWI2
;
1455 ha
->fw_srisc_address
= RISC_START_ADDRESS_2400
;
1457 case PCI_DEVICE_ID_QLOGIC_ISP2532
:
1458 ha
->device_type
|= DT_ISP2532
;
1459 ha
->device_type
|= DT_ZIO_SUPPORTED
;
1460 ha
->device_type
|= DT_FWI2
;
1461 ha
->device_type
|= DT_IIDMA
;
1462 ha
->fw_srisc_address
= RISC_START_ADDRESS_2400
;
1468 qla2x00_iospace_config(scsi_qla_host_t
*ha
)
1470 unsigned long pio
, pio_len
, pio_flags
;
1471 unsigned long mmio
, mmio_len
, mmio_flags
;
1473 /* We only need PIO for Flash operations on ISP2312 v2 chips. */
1474 pio
= pci_resource_start(ha
->pdev
, 0);
1475 pio_len
= pci_resource_len(ha
->pdev
, 0);
1476 pio_flags
= pci_resource_flags(ha
->pdev
, 0);
1477 if (pio_flags
& IORESOURCE_IO
) {
1478 if (pio_len
< MIN_IOBASE_LEN
) {
1479 qla_printk(KERN_WARNING
, ha
,
1480 "Invalid PCI I/O region size (%s)...\n",
1481 pci_name(ha
->pdev
));
1485 qla_printk(KERN_WARNING
, ha
,
1486 "region #0 not a PIO resource (%s)...\n",
1487 pci_name(ha
->pdev
));
1491 /* Use MMIO operations for all accesses. */
1492 mmio
= pci_resource_start(ha
->pdev
, 1);
1493 mmio_len
= pci_resource_len(ha
->pdev
, 1);
1494 mmio_flags
= pci_resource_flags(ha
->pdev
, 1);
1496 if (!(mmio_flags
& IORESOURCE_MEM
)) {
1497 qla_printk(KERN_ERR
, ha
,
1498 "region #0 not an MMIO resource (%s), aborting\n",
1499 pci_name(ha
->pdev
));
1500 goto iospace_error_exit
;
1502 if (mmio_len
< MIN_IOBASE_LEN
) {
1503 qla_printk(KERN_ERR
, ha
,
1504 "Invalid PCI mem region size (%s), aborting\n",
1505 pci_name(ha
->pdev
));
1506 goto iospace_error_exit
;
1509 if (pci_request_regions(ha
->pdev
, QLA2XXX_DRIVER_NAME
)) {
1510 qla_printk(KERN_WARNING
, ha
,
1511 "Failed to reserve PIO/MMIO regions (%s)\n",
1512 pci_name(ha
->pdev
));
1514 goto iospace_error_exit
;
1517 ha
->pio_address
= pio
;
1518 ha
->pio_length
= pio_len
;
1519 ha
->iobase
= ioremap(mmio
, MIN_IOBASE_LEN
);
1521 qla_printk(KERN_ERR
, ha
,
1522 "cannot remap MMIO (%s), aborting\n", pci_name(ha
->pdev
));
1524 goto iospace_error_exit
;
1534 qla2xxx_scan_start(struct Scsi_Host
*shost
)
1536 scsi_qla_host_t
*ha
= (scsi_qla_host_t
*)shost
->hostdata
;
1538 set_bit(LOOP_RESYNC_NEEDED
, &ha
->dpc_flags
);
1539 set_bit(LOCAL_LOOP_UPDATE
, &ha
->dpc_flags
);
1540 set_bit(RSCN_UPDATE
, &ha
->dpc_flags
);
1544 qla2xxx_scan_finished(struct Scsi_Host
*shost
, unsigned long time
)
1546 scsi_qla_host_t
*ha
= (scsi_qla_host_t
*)shost
->hostdata
;
1550 if (time
> ha
->loop_reset_delay
* HZ
)
1553 return atomic_read(&ha
->loop_state
) == LOOP_READY
;
1557 * PCI driver interface
1559 static int __devinit
1560 qla2x00_probe_one(struct pci_dev
*pdev
, const struct pci_device_id
*id
)
1563 device_reg_t __iomem
*reg
;
1564 struct Scsi_Host
*host
;
1565 scsi_qla_host_t
*ha
;
1566 unsigned long flags
= 0;
1569 struct scsi_host_template
*sht
;
1571 if (pci_enable_device(pdev
))
1574 sht
= &qla2x00_driver_template
;
1575 if (pdev
->device
== PCI_DEVICE_ID_QLOGIC_ISP2422
||
1576 pdev
->device
== PCI_DEVICE_ID_QLOGIC_ISP2432
||
1577 pdev
->device
== PCI_DEVICE_ID_QLOGIC_ISP5422
||
1578 pdev
->device
== PCI_DEVICE_ID_QLOGIC_ISP5432
||
1579 pdev
->device
== PCI_DEVICE_ID_QLOGIC_ISP2532
)
1580 sht
= &qla24xx_driver_template
;
1581 host
= scsi_host_alloc(sht
, sizeof(scsi_qla_host_t
));
1584 "qla2xxx: Couldn't allocate host from scsi layer!\n");
1585 goto probe_disable_device
;
1588 /* Clear our data area */
1589 ha
= (scsi_qla_host_t
*)host
->hostdata
;
1590 memset(ha
, 0, sizeof(scsi_qla_host_t
));
1594 ha
->host_no
= host
->host_no
;
1595 sprintf(ha
->host_str
, "%s_%ld", QLA2XXX_DRIVER_NAME
, ha
->host_no
);
1598 /* Set ISP-type information. */
1599 qla2x00_set_isp_flags(ha
);
1601 /* Configure PCI I/O space */
1602 ret
= qla2x00_iospace_config(ha
);
1606 qla_printk(KERN_INFO
, ha
,
1607 "Found an ISP%04X, irq %d, iobase 0x%p\n", pdev
->device
, pdev
->irq
,
1610 spin_lock_init(&ha
->hardware_lock
);
1612 ha
->prev_topology
= 0;
1613 ha
->init_cb_size
= sizeof(init_cb_t
);
1614 ha
->mgmt_svr_loop_id
= MANAGEMENT_SERVER
+ ha
->vp_idx
;
1615 ha
->link_data_rate
= PORT_SPEED_UNKNOWN
;
1616 ha
->optrom_size
= OPTROM_SIZE_2300
;
1618 ha
->max_q_depth
= MAX_Q_DEPTH
;
1619 if (ql2xmaxqdepth
!= 0 && ql2xmaxqdepth
<= 0xffffU
)
1620 ha
->max_q_depth
= ql2xmaxqdepth
;
1622 /* Assign ISP specific operations. */
1623 if (IS_QLA2100(ha
)) {
1624 host
->max_id
= MAX_TARGETS_2100
;
1625 ha
->mbx_count
= MAILBOX_REGISTER_COUNT_2100
;
1626 ha
->request_q_length
= REQUEST_ENTRY_CNT_2100
;
1627 ha
->response_q_length
= RESPONSE_ENTRY_CNT_2100
;
1628 ha
->last_loop_id
= SNS_LAST_LOOP_ID_2100
;
1629 host
->sg_tablesize
= 32;
1630 ha
->gid_list_info_size
= 4;
1631 ha
->isp_ops
= &qla2100_isp_ops
;
1632 } else if (IS_QLA2200(ha
)) {
1633 host
->max_id
= MAX_TARGETS_2200
;
1634 ha
->mbx_count
= MAILBOX_REGISTER_COUNT
;
1635 ha
->request_q_length
= REQUEST_ENTRY_CNT_2200
;
1636 ha
->response_q_length
= RESPONSE_ENTRY_CNT_2100
;
1637 ha
->last_loop_id
= SNS_LAST_LOOP_ID_2100
;
1638 ha
->gid_list_info_size
= 4;
1639 ha
->isp_ops
= &qla2100_isp_ops
;
1640 } else if (IS_QLA23XX(ha
)) {
1641 host
->max_id
= MAX_TARGETS_2200
;
1642 ha
->mbx_count
= MAILBOX_REGISTER_COUNT
;
1643 ha
->request_q_length
= REQUEST_ENTRY_CNT_2200
;
1644 ha
->response_q_length
= RESPONSE_ENTRY_CNT_2300
;
1645 ha
->last_loop_id
= SNS_LAST_LOOP_ID_2300
;
1646 ha
->gid_list_info_size
= 6;
1647 if (IS_QLA2322(ha
) || IS_QLA6322(ha
))
1648 ha
->optrom_size
= OPTROM_SIZE_2322
;
1649 ha
->isp_ops
= &qla2300_isp_ops
;
1650 } else if (IS_QLA24XX(ha
) || IS_QLA54XX(ha
)) {
1651 host
->max_id
= MAX_TARGETS_2200
;
1652 ha
->mbx_count
= MAILBOX_REGISTER_COUNT
;
1653 ha
->request_q_length
= REQUEST_ENTRY_CNT_24XX
;
1654 ha
->response_q_length
= RESPONSE_ENTRY_CNT_2300
;
1655 ha
->last_loop_id
= SNS_LAST_LOOP_ID_2300
;
1656 ha
->init_cb_size
= sizeof(struct mid_init_cb_24xx
);
1657 ha
->mgmt_svr_loop_id
= 10 + ha
->vp_idx
;
1658 ha
->gid_list_info_size
= 8;
1659 ha
->optrom_size
= OPTROM_SIZE_24XX
;
1660 ha
->isp_ops
= &qla24xx_isp_ops
;
1661 } else if (IS_QLA25XX(ha
)) {
1662 host
->max_id
= MAX_TARGETS_2200
;
1663 ha
->mbx_count
= MAILBOX_REGISTER_COUNT
;
1664 ha
->request_q_length
= REQUEST_ENTRY_CNT_24XX
;
1665 ha
->response_q_length
= RESPONSE_ENTRY_CNT_2300
;
1666 ha
->last_loop_id
= SNS_LAST_LOOP_ID_2300
;
1667 ha
->init_cb_size
= sizeof(struct mid_init_cb_24xx
);
1668 ha
->mgmt_svr_loop_id
= 10 + ha
->vp_idx
;
1669 ha
->gid_list_info_size
= 8;
1670 ha
->optrom_size
= OPTROM_SIZE_25XX
;
1671 ha
->isp_ops
= &qla25xx_isp_ops
;
1673 host
->can_queue
= ha
->request_q_length
+ 128;
1675 /* load the F/W, read paramaters, and init the H/W */
1676 ha
->instance
= num_hosts
;
1678 init_MUTEX(&ha
->mbx_cmd_sem
);
1679 init_MUTEX(&ha
->vport_sem
);
1680 init_MUTEX_LOCKED(&ha
->mbx_intr_sem
);
1682 INIT_LIST_HEAD(&ha
->list
);
1683 INIT_LIST_HEAD(&ha
->fcports
);
1684 INIT_LIST_HEAD(&ha
->vp_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 ha
->isp_ops
->disable_intrs(ha
);
1741 spin_lock_irqsave(&ha
->hardware_lock
, flags
);
1743 if (IS_FWI2_CAPABLE(ha
)) {
1744 WRT_REG_DWORD(®
->isp24
.hccr
, HCCRX_CLR_HOST_INT
);
1745 WRT_REG_DWORD(®
->isp24
.hccr
, HCCRX_CLR_RISC_INT
);
1747 WRT_REG_WORD(®
->isp
.semaphore
, 0);
1748 WRT_REG_WORD(®
->isp
.hccr
, HCCR_CLR_RISC_INT
);
1749 WRT_REG_WORD(®
->isp
.hccr
, HCCR_CLR_HOST_INT
);
1751 /* Enable proper parity */
1752 if (!IS_QLA2100(ha
) && !IS_QLA2200(ha
)) {
1755 WRT_REG_WORD(®
->isp
.hccr
,
1756 (HCCR_ENABLE_PARITY
+ 0x1));
1758 /* SRAM, Instruction RAM and GP RAM parity */
1759 WRT_REG_WORD(®
->isp
.hccr
,
1760 (HCCR_ENABLE_PARITY
+ 0x7));
1763 spin_unlock_irqrestore(&ha
->hardware_lock
, flags
);
1765 ha
->isp_ops
->enable_intrs(ha
);
1767 pci_set_drvdata(pdev
, ha
);
1769 ha
->flags
.init_done
= 1;
1770 ha
->flags
.online
= 1;
1774 ret
= scsi_add_host(host
, &pdev
->dev
);
1778 scsi_scan_host(host
);
1780 qla2x00_alloc_sysfs_attr(ha
);
1782 qla2x00_init_host_attr(ha
);
1784 qla_printk(KERN_INFO
, ha
, "\n"
1785 " QLogic Fibre Channel HBA Driver: %s\n"
1787 " ISP%04X: %s @ %s hdma%c, host#=%ld, fw=%s\n",
1788 qla2x00_version_str
, ha
->model_number
,
1789 ha
->model_desc
? ha
->model_desc
: "", pdev
->device
,
1790 ha
->isp_ops
->pci_info_str(ha
, pci_info
), pci_name(pdev
),
1791 ha
->flags
.enable_64bit_addressing
? '+': '-', ha
->host_no
,
1792 ha
->isp_ops
->fw_version_str(ha
, fw_str
));
1797 qla2x00_free_device(ha
);
1799 scsi_host_put(host
);
1801 probe_disable_device
:
1802 pci_disable_device(pdev
);
1808 static void __devexit
1809 qla2x00_remove_one(struct pci_dev
*pdev
)
1811 scsi_qla_host_t
*ha
;
1813 ha
= pci_get_drvdata(pdev
);
1815 qla2x00_free_sysfs_attr(ha
);
1817 fc_remove_host(ha
->host
);
1819 scsi_remove_host(ha
->host
);
1821 qla2x00_free_device(ha
);
1823 scsi_host_put(ha
->host
);
1825 pci_disable_device(pdev
);
1826 pci_set_drvdata(pdev
, NULL
);
1830 qla2x00_free_device(scsi_qla_host_t
*ha
)
1833 if (ha
->timer_active
)
1834 qla2x00_stop_timer(ha
);
1836 /* Kill the kernel thread for this host */
1837 if (ha
->dpc_thread
) {
1838 struct task_struct
*t
= ha
->dpc_thread
;
1841 * qla2xxx_wake_dpc checks for ->dpc_thread
1842 * so we need to zero it out.
1844 ha
->dpc_thread
= NULL
;
1849 qla2x00_trace_control(ha
, TC_DISABLE
, 0, 0);
1851 ha
->flags
.online
= 0;
1853 /* Stop currently executing firmware. */
1854 qla2x00_try_to_stop_firmware(ha
);
1856 /* turn-off interrupts on the card */
1857 if (ha
->interrupts_on
)
1858 ha
->isp_ops
->disable_intrs(ha
);
1860 qla2x00_mem_free(ha
);
1862 qla2x00_free_irqs(ha
);
1864 /* release io space registers */
1866 iounmap(ha
->iobase
);
1867 pci_release_regions(ha
->pdev
);
1871 qla2x00_schedule_rport_del(struct scsi_qla_host
*ha
, fc_port_t
*fcport
,
1874 unsigned long flags
;
1875 struct fc_rport
*rport
;
1880 rport
= fcport
->rport
;
1882 spin_lock_irqsave(&fcport
->rport_lock
, flags
);
1883 fcport
->drport
= rport
;
1884 fcport
->rport
= NULL
;
1885 *(fc_port_t
**)rport
->dd_data
= NULL
;
1886 spin_unlock_irqrestore(&fcport
->rport_lock
, flags
);
1887 set_bit(FCPORT_UPDATE_NEEDED
, &ha
->dpc_flags
);
1889 spin_lock_irqsave(&fcport
->rport_lock
, flags
);
1890 fcport
->rport
= NULL
;
1891 *(fc_port_t
**)rport
->dd_data
= NULL
;
1892 spin_unlock_irqrestore(&fcport
->rport_lock
, flags
);
1893 fc_remote_port_delete(rport
);
1898 * qla2x00_mark_device_lost Updates fcport state when device goes offline.
1900 * Input: ha = adapter block pointer. fcport = port structure pointer.
1906 void qla2x00_mark_device_lost(scsi_qla_host_t
*ha
, fc_port_t
*fcport
,
1907 int do_login
, int defer
)
1909 if (atomic_read(&fcport
->state
) == FCS_ONLINE
&&
1910 ha
->vp_idx
== fcport
->vp_idx
)
1911 qla2x00_schedule_rport_del(ha
, fcport
, defer
);
1914 * We may need to retry the login, so don't change the state of the
1915 * port but do the retries.
1917 if (atomic_read(&fcport
->state
) != FCS_DEVICE_DEAD
)
1918 atomic_set(&fcport
->state
, FCS_DEVICE_LOST
);
1923 if (fcport
->login_retry
== 0) {
1924 fcport
->login_retry
= ha
->login_retry_count
;
1925 set_bit(RELOGIN_NEEDED
, &ha
->dpc_flags
);
1927 DEBUG(printk("scsi(%ld): Port login retry: "
1928 "%02x%02x%02x%02x%02x%02x%02x%02x, "
1929 "id = 0x%04x retry cnt=%d\n",
1931 fcport
->port_name
[0],
1932 fcport
->port_name
[1],
1933 fcport
->port_name
[2],
1934 fcport
->port_name
[3],
1935 fcport
->port_name
[4],
1936 fcport
->port_name
[5],
1937 fcport
->port_name
[6],
1938 fcport
->port_name
[7],
1940 fcport
->login_retry
));
1945 * qla2x00_mark_all_devices_lost
1946 * Updates fcport state when device goes offline.
1949 * ha = adapter block pointer.
1950 * fcport = port structure pointer.
1958 qla2x00_mark_all_devices_lost(scsi_qla_host_t
*ha
, int defer
)
1961 scsi_qla_host_t
*pha
= to_qla_parent(ha
);
1963 list_for_each_entry(fcport
, &pha
->fcports
, list
) {
1964 if (ha
->vp_idx
!= 0 && ha
->vp_idx
!= fcport
->vp_idx
)
1967 * No point in marking the device as lost, if the device is
1970 if (atomic_read(&fcport
->state
) == FCS_DEVICE_DEAD
)
1972 if (atomic_read(&fcport
->state
) == FCS_ONLINE
) {
1974 qla2x00_schedule_rport_del(ha
, fcport
, defer
);
1975 else if (ha
->vp_idx
== fcport
->vp_idx
)
1976 qla2x00_schedule_rport_del(ha
, fcport
, defer
);
1978 atomic_set(&fcport
->state
, FCS_DEVICE_LOST
);
1982 qla2xxx_wake_dpc(ha
);
1987 * Allocates adapter memory.
1994 qla2x00_mem_alloc(scsi_qla_host_t
*ha
)
2002 * This will loop only once if everything goes well, else some
2003 * number of retries will be performed to get around a kernel
2004 * bug where available mem is not allocated until after a
2005 * little delay and a retry.
2007 ha
->request_ring
= dma_alloc_coherent(&ha
->pdev
->dev
,
2008 (ha
->request_q_length
+ 1) * sizeof(request_t
),
2009 &ha
->request_dma
, GFP_KERNEL
);
2010 if (ha
->request_ring
== NULL
) {
2011 qla_printk(KERN_WARNING
, ha
,
2012 "Memory Allocation failed - request_ring\n");
2014 qla2x00_mem_free(ha
);
2020 ha
->response_ring
= dma_alloc_coherent(&ha
->pdev
->dev
,
2021 (ha
->response_q_length
+ 1) * sizeof(response_t
),
2022 &ha
->response_dma
, GFP_KERNEL
);
2023 if (ha
->response_ring
== NULL
) {
2024 qla_printk(KERN_WARNING
, ha
,
2025 "Memory Allocation failed - response_ring\n");
2027 qla2x00_mem_free(ha
);
2033 ha
->gid_list
= dma_alloc_coherent(&ha
->pdev
->dev
, GID_LIST_SIZE
,
2034 &ha
->gid_list_dma
, GFP_KERNEL
);
2035 if (ha
->gid_list
== NULL
) {
2036 qla_printk(KERN_WARNING
, ha
,
2037 "Memory Allocation failed - gid_list\n");
2039 qla2x00_mem_free(ha
);
2045 /* get consistent memory allocated for init control block */
2046 ha
->init_cb
= dma_alloc_coherent(&ha
->pdev
->dev
,
2047 ha
->init_cb_size
, &ha
->init_cb_dma
, GFP_KERNEL
);
2048 if (ha
->init_cb
== NULL
) {
2049 qla_printk(KERN_WARNING
, ha
,
2050 "Memory Allocation failed - init_cb\n");
2052 qla2x00_mem_free(ha
);
2057 memset(ha
->init_cb
, 0, ha
->init_cb_size
);
2059 snprintf(name
, sizeof(name
), "%s_%ld", QLA2XXX_DRIVER_NAME
,
2061 ha
->s_dma_pool
= dma_pool_create(name
, &ha
->pdev
->dev
,
2062 DMA_POOL_SIZE
, 8, 0);
2063 if (ha
->s_dma_pool
== NULL
) {
2064 qla_printk(KERN_WARNING
, ha
,
2065 "Memory Allocation failed - s_dma_pool\n");
2067 qla2x00_mem_free(ha
);
2073 if (qla2x00_allocate_sp_pool(ha
)) {
2074 qla_printk(KERN_WARNING
, ha
,
2075 "Memory Allocation failed - "
2076 "qla2x00_allocate_sp_pool()\n");
2078 qla2x00_mem_free(ha
);
2084 /* Allocate memory for SNS commands */
2085 if (IS_QLA2100(ha
) || IS_QLA2200(ha
)) {
2086 /* Get consistent memory allocated for SNS commands */
2087 ha
->sns_cmd
= dma_alloc_coherent(&ha
->pdev
->dev
,
2088 sizeof(struct sns_cmd_pkt
), &ha
->sns_cmd_dma
,
2090 if (ha
->sns_cmd
== NULL
) {
2092 qla_printk(KERN_WARNING
, ha
,
2093 "Memory Allocation failed - sns_cmd\n");
2095 qla2x00_mem_free(ha
);
2100 memset(ha
->sns_cmd
, 0, sizeof(struct sns_cmd_pkt
));
2102 /* Get consistent memory allocated for MS IOCB */
2103 ha
->ms_iocb
= dma_pool_alloc(ha
->s_dma_pool
, GFP_KERNEL
,
2105 if (ha
->ms_iocb
== NULL
) {
2107 qla_printk(KERN_WARNING
, ha
,
2108 "Memory Allocation failed - ms_iocb\n");
2110 qla2x00_mem_free(ha
);
2115 memset(ha
->ms_iocb
, 0, sizeof(ms_iocb_entry_t
));
2118 * Get consistent memory allocated for CT SNS
2121 ha
->ct_sns
= dma_alloc_coherent(&ha
->pdev
->dev
,
2122 sizeof(struct ct_sns_pkt
), &ha
->ct_sns_dma
,
2124 if (ha
->ct_sns
== NULL
) {
2126 qla_printk(KERN_WARNING
, ha
,
2127 "Memory Allocation failed - ct_sns\n");
2129 qla2x00_mem_free(ha
);
2134 memset(ha
->ct_sns
, 0, sizeof(struct ct_sns_pkt
));
2136 if (IS_FWI2_CAPABLE(ha
)) {
2138 * Get consistent memory allocated for SFP
2141 ha
->sfp_data
= dma_pool_alloc(ha
->s_dma_pool
,
2142 GFP_KERNEL
, &ha
->sfp_data_dma
);
2143 if (ha
->sfp_data
== NULL
) {
2144 qla_printk(KERN_WARNING
, ha
,
2145 "Memory Allocation failed - "
2148 qla2x00_mem_free(ha
);
2153 memset(ha
->sfp_data
, 0, SFP_BLOCK_SIZE
);
2157 /* Get memory for cached NVRAM */
2158 ha
->nvram
= kzalloc(MAX_NVRAM_SIZE
, GFP_KERNEL
);
2159 if (ha
->nvram
== NULL
) {
2161 qla_printk(KERN_WARNING
, ha
,
2162 "Memory Allocation failed - nvram cache\n");
2164 qla2x00_mem_free(ha
);
2170 /* Done all allocations without any error. */
2173 } while (retry
-- && status
!= 0);
2177 "%s(): **** FAILED ****\n", __func__
);
2185 * Frees all adapter allocated memory.
2188 * ha = adapter block pointer.
2191 qla2x00_mem_free(scsi_qla_host_t
*ha
)
2193 struct list_head
*fcpl
, *fcptemp
;
2198 DEBUG2(printk("%s(): ERROR invalid ha pointer.\n", __func__
));
2203 qla2x00_free_sp_pool(ha
);
2207 dma_free_coherent(&ha
->pdev
->dev
,
2208 ntohl(ha
->fw_dump
->eft_size
), ha
->eft
, ha
->eft_dma
);
2213 dma_free_coherent(&ha
->pdev
->dev
, sizeof(struct sns_cmd_pkt
),
2214 ha
->sns_cmd
, ha
->sns_cmd_dma
);
2217 dma_free_coherent(&ha
->pdev
->dev
, sizeof(struct ct_sns_pkt
),
2218 ha
->ct_sns
, ha
->ct_sns_dma
);
2221 dma_pool_free(ha
->s_dma_pool
, ha
->sfp_data
, ha
->sfp_data_dma
);
2224 dma_pool_free(ha
->s_dma_pool
, ha
->ms_iocb
, ha
->ms_iocb_dma
);
2227 dma_pool_destroy(ha
->s_dma_pool
);
2230 dma_free_coherent(&ha
->pdev
->dev
, ha
->init_cb_size
,
2231 ha
->init_cb
, ha
->init_cb_dma
);
2234 dma_free_coherent(&ha
->pdev
->dev
, GID_LIST_SIZE
, ha
->gid_list
,
2237 if (ha
->response_ring
)
2238 dma_free_coherent(&ha
->pdev
->dev
,
2239 (ha
->response_q_length
+ 1) * sizeof(response_t
),
2240 ha
->response_ring
, ha
->response_dma
);
2242 if (ha
->request_ring
)
2243 dma_free_coherent(&ha
->pdev
->dev
,
2244 (ha
->request_q_length
+ 1) * sizeof(request_t
),
2245 ha
->request_ring
, ha
->request_dma
);
2250 ha
->sns_cmd_dma
= 0;
2254 ha
->ms_iocb_dma
= 0;
2256 ha
->init_cb_dma
= 0;
2258 ha
->s_dma_pool
= NULL
;
2260 ha
->gid_list
= NULL
;
2261 ha
->gid_list_dma
= 0;
2263 ha
->response_ring
= NULL
;
2264 ha
->response_dma
= 0;
2265 ha
->request_ring
= NULL
;
2266 ha
->request_dma
= 0;
2268 list_for_each_safe(fcpl
, fcptemp
, &ha
->fcports
) {
2269 fcport
= list_entry(fcpl
, fc_port_t
, list
);
2272 list_del_init(&fcport
->list
);
2275 INIT_LIST_HEAD(&ha
->fcports
);
2279 ha
->fw_dump_reading
= 0;
2281 vfree(ha
->optrom_buffer
);
2286 * qla2x00_allocate_sp_pool
2287 * This routine is called during initialization to allocate
2288 * memory for local srb_t.
2291 * ha = adapter block pointer.
2297 qla2x00_allocate_sp_pool(scsi_qla_host_t
*ha
)
2302 ha
->srb_mempool
= mempool_create_slab_pool(SRB_MIN_REQ
, srb_cachep
);
2303 if (ha
->srb_mempool
== NULL
) {
2304 qla_printk(KERN_INFO
, ha
, "Unable to allocate SRB mempool.\n");
2305 rval
= QLA_FUNCTION_FAILED
;
2311 * This routine frees all adapter allocated memory.
2315 qla2x00_free_sp_pool( scsi_qla_host_t
*ha
)
2317 if (ha
->srb_mempool
) {
2318 mempool_destroy(ha
->srb_mempool
);
2319 ha
->srb_mempool
= NULL
;
2323 /**************************************************************************
2325 * This kernel thread is a task that is schedule by the interrupt handler
2326 * to perform the background processing for interrupts.
2329 * This task always run in the context of a kernel thread. It
2330 * is kick-off by the driver's detect code and starts up
2331 * up one per adapter. It immediately goes to sleep and waits for
2332 * some fibre event. When either the interrupt handler or
2333 * the timer routine detects a event it will one of the task
2334 * bits then wake us up.
2335 **************************************************************************/
2337 qla2x00_do_dpc(void *data
)
2340 scsi_qla_host_t
*ha
;
2343 uint16_t next_loopid
;
2345 ha
= (scsi_qla_host_t
*)data
;
2347 set_user_nice(current
, -20);
2349 while (!kthread_should_stop()) {
2350 DEBUG3(printk("qla2x00: DPC handler sleeping\n"));
2352 set_current_state(TASK_INTERRUPTIBLE
);
2354 __set_current_state(TASK_RUNNING
);
2356 DEBUG3(printk("qla2x00: DPC handler waking up\n"));
2358 /* Initialization not yet finished. Don't do anything yet. */
2359 if (!ha
->flags
.init_done
)
2362 DEBUG3(printk("scsi(%ld): DPC handler\n", ha
->host_no
));
2366 if (ha
->flags
.mbox_busy
) {
2371 if (test_and_clear_bit(ISP_ABORT_NEEDED
, &ha
->dpc_flags
)) {
2373 DEBUG(printk("scsi(%ld): dpc: sched "
2374 "qla2x00_abort_isp ha = %p\n",
2376 if (!(test_and_set_bit(ABORT_ISP_ACTIVE
,
2379 if (qla2x00_abort_isp(ha
)) {
2380 /* failed. retry later */
2381 set_bit(ISP_ABORT_NEEDED
,
2384 clear_bit(ABORT_ISP_ACTIVE
, &ha
->dpc_flags
);
2386 DEBUG(printk("scsi(%ld): dpc: qla2x00_abort_isp end\n",
2390 if (test_and_clear_bit(FCPORT_UPDATE_NEEDED
, &ha
->dpc_flags
))
2391 qla2x00_update_fcports(ha
);
2393 if (test_and_clear_bit(LOOP_RESET_NEEDED
, &ha
->dpc_flags
)) {
2394 DEBUG(printk("scsi(%ld): dpc: sched loop_reset()\n",
2396 qla2x00_loop_reset(ha
);
2399 if (test_and_clear_bit(RESET_MARKER_NEEDED
, &ha
->dpc_flags
) &&
2400 (!(test_and_set_bit(RESET_ACTIVE
, &ha
->dpc_flags
)))) {
2402 DEBUG(printk("scsi(%ld): qla2x00_reset_marker()\n",
2405 qla2x00_rst_aen(ha
);
2406 clear_bit(RESET_ACTIVE
, &ha
->dpc_flags
);
2409 /* Retry each device up to login retry count */
2410 if ((test_and_clear_bit(RELOGIN_NEEDED
, &ha
->dpc_flags
)) &&
2411 !test_bit(LOOP_RESYNC_NEEDED
, &ha
->dpc_flags
) &&
2412 atomic_read(&ha
->loop_state
) != LOOP_DOWN
) {
2414 DEBUG(printk("scsi(%ld): qla2x00_port_login()\n",
2418 list_for_each_entry(fcport
, &ha
->fcports
, list
) {
2420 * If the port is not ONLINE then try to login
2421 * to it if we haven't run out of retries.
2423 if (atomic_read(&fcport
->state
) != FCS_ONLINE
&&
2424 fcport
->login_retry
) {
2426 fcport
->login_retry
--;
2427 if (fcport
->flags
& FCF_FABRIC_DEVICE
) {
2430 ha
->isp_ops
->fabric_logout(
2431 ha
, fcport
->loop_id
,
2432 fcport
->d_id
.b
.domain
,
2433 fcport
->d_id
.b
.area
,
2434 fcport
->d_id
.b
.al_pa
);
2435 status
= qla2x00_fabric_login(
2436 ha
, fcport
, &next_loopid
);
2439 qla2x00_local_device_login(
2442 if (status
== QLA_SUCCESS
) {
2443 fcport
->old_loop_id
= fcport
->loop_id
;
2445 DEBUG(printk("scsi(%ld): port login OK: logged in ID 0x%x\n",
2446 ha
->host_no
, fcport
->loop_id
));
2448 qla2x00_update_fcport(ha
,
2450 } else if (status
== 1) {
2451 set_bit(RELOGIN_NEEDED
, &ha
->dpc_flags
);
2452 /* retry the login again */
2453 DEBUG(printk("scsi(%ld): Retrying %d login again loop_id 0x%x\n",
2455 fcport
->login_retry
, fcport
->loop_id
));
2457 fcport
->login_retry
= 0;
2460 if (test_bit(LOOP_RESYNC_NEEDED
, &ha
->dpc_flags
))
2463 DEBUG(printk("scsi(%ld): qla2x00_port_login - end\n",
2467 if ((test_bit(LOGIN_RETRY_NEEDED
, &ha
->dpc_flags
)) &&
2468 atomic_read(&ha
->loop_state
) != LOOP_DOWN
) {
2470 clear_bit(LOGIN_RETRY_NEEDED
, &ha
->dpc_flags
);
2471 DEBUG(printk("scsi(%ld): qla2x00_login_retry()\n",
2474 set_bit(LOOP_RESYNC_NEEDED
, &ha
->dpc_flags
);
2476 DEBUG(printk("scsi(%ld): qla2x00_login_retry - end\n",
2480 if (test_and_clear_bit(LOOP_RESYNC_NEEDED
, &ha
->dpc_flags
)) {
2482 DEBUG(printk("scsi(%ld): qla2x00_loop_resync()\n",
2485 if (!(test_and_set_bit(LOOP_RESYNC_ACTIVE
,
2488 rval
= qla2x00_loop_resync(ha
);
2490 clear_bit(LOOP_RESYNC_ACTIVE
, &ha
->dpc_flags
);
2493 DEBUG(printk("scsi(%ld): qla2x00_loop_resync - end\n",
2497 if (test_and_clear_bit(FCPORT_RESCAN_NEEDED
, &ha
->dpc_flags
)) {
2499 DEBUG(printk("scsi(%ld): Rescan flagged fcports...\n",
2502 qla2x00_rescan_fcports(ha
);
2504 DEBUG(printk("scsi(%ld): Rescan flagged fcports..."
2509 if (!ha
->interrupts_on
)
2510 ha
->isp_ops
->enable_intrs(ha
);
2512 if (test_and_clear_bit(BEACON_BLINK_NEEDED
, &ha
->dpc_flags
))
2513 ha
->isp_ops
->beacon_blink(ha
);
2515 qla2x00_do_dpc_all_vps(ha
);
2518 } /* End of while(1) */
2520 DEBUG(printk("scsi(%ld): DPC handler exiting\n", ha
->host_no
));
2523 * Make sure that nobody tries to wake us up again.
2531 qla2xxx_wake_dpc(scsi_qla_host_t
*ha
)
2534 wake_up_process(ha
->dpc_thread
);
2539 * Processes asynchronous reset.
2542 * ha = adapter block pointer.
2545 qla2x00_rst_aen(scsi_qla_host_t
*ha
)
2547 if (ha
->flags
.online
&& !ha
->flags
.reset_active
&&
2548 !atomic_read(&ha
->loop_down_timer
) &&
2549 !(test_bit(ABORT_ISP_ACTIVE
, &ha
->dpc_flags
))) {
2551 clear_bit(RESET_MARKER_NEEDED
, &ha
->dpc_flags
);
2554 * Issue marker command only when we are going to start
2557 ha
->marker_needed
= 1;
2558 } while (!atomic_read(&ha
->loop_down_timer
) &&
2559 (test_bit(RESET_MARKER_NEEDED
, &ha
->dpc_flags
)));
2564 qla2x00_sp_free_dma(scsi_qla_host_t
*ha
, srb_t
*sp
)
2566 struct scsi_cmnd
*cmd
= sp
->cmd
;
2568 if (sp
->flags
& SRB_DMA_VALID
) {
2569 scsi_dma_unmap(cmd
);
2570 sp
->flags
&= ~SRB_DMA_VALID
;
2576 qla2x00_sp_compl(scsi_qla_host_t
*ha
, srb_t
*sp
)
2578 struct scsi_cmnd
*cmd
= sp
->cmd
;
2580 qla2x00_sp_free_dma(ha
, sp
);
2582 mempool_free(sp
, ha
->srb_mempool
);
2584 cmd
->scsi_done(cmd
);
2587 /**************************************************************************
2593 * Context: Interrupt
2594 ***************************************************************************/
2596 qla2x00_timer(scsi_qla_host_t
*ha
)
2598 unsigned long cpu_flags
= 0;
2604 scsi_qla_host_t
*pha
= to_qla_parent(ha
);
2607 * Ports - Port down timer.
2609 * Whenever, a port is in the LOST state we start decrementing its port
2610 * down timer every second until it reaches zero. Once it reaches zero
2611 * the port it marked DEAD.
2614 list_for_each_entry(fcport
, &ha
->fcports
, list
) {
2615 if (fcport
->port_type
!= FCT_TARGET
)
2618 if (atomic_read(&fcport
->state
) == FCS_DEVICE_LOST
) {
2620 if (atomic_read(&fcport
->port_down_timer
) == 0)
2623 if (atomic_dec_and_test(&fcport
->port_down_timer
) != 0)
2624 atomic_set(&fcport
->state
, FCS_DEVICE_DEAD
);
2626 DEBUG(printk("scsi(%ld): fcport-%d - port retry count: "
2629 t
, atomic_read(&fcport
->port_down_timer
)));
2632 } /* End of for fcport */
2635 /* Loop down handler. */
2636 if (atomic_read(&ha
->loop_down_timer
) > 0 &&
2637 !(test_bit(ABORT_ISP_ACTIVE
, &ha
->dpc_flags
)) && ha
->flags
.online
) {
2639 if (atomic_read(&ha
->loop_down_timer
) ==
2640 ha
->loop_down_abort_time
) {
2642 DEBUG(printk("scsi(%ld): Loop Down - aborting the "
2643 "queues before time expire\n",
2646 if (!IS_QLA2100(ha
) && ha
->link_down_timeout
)
2647 atomic_set(&ha
->loop_state
, LOOP_DEAD
);
2649 /* Schedule an ISP abort to return any tape commands. */
2650 /* NPIV - scan physical port only */
2652 spin_lock_irqsave(&ha
->hardware_lock
,
2655 index
< MAX_OUTSTANDING_COMMANDS
;
2659 sp
= ha
->outstanding_cmds
[index
];
2663 if (!(sfcp
->flags
& FCF_TAPE_PRESENT
))
2666 set_bit(ISP_ABORT_NEEDED
,
2670 spin_unlock_irqrestore(&ha
->hardware_lock
,
2673 set_bit(ABORT_QUEUES_NEEDED
, &ha
->dpc_flags
);
2677 /* if the loop has been down for 4 minutes, reinit adapter */
2678 if (atomic_dec_and_test(&ha
->loop_down_timer
) != 0) {
2679 DEBUG(printk("scsi(%ld): Loop down exceed 4 mins - "
2680 "restarting queues.\n",
2683 set_bit(RESTART_QUEUES_NEEDED
, &ha
->dpc_flags
);
2686 if (!(ha
->device_flags
& DFLG_NO_CABLE
)) {
2687 DEBUG(printk("scsi(%ld): Loop down - "
2690 qla_printk(KERN_WARNING
, ha
,
2691 "Loop down - aborting ISP.\n");
2693 set_bit(ISP_ABORT_NEEDED
, &ha
->dpc_flags
);
2696 DEBUG3(printk("scsi(%ld): Loop Down - seconds remaining %d\n",
2698 atomic_read(&ha
->loop_down_timer
)));
2701 /* Check if beacon LED needs to be blinked */
2702 if (ha
->beacon_blink_led
== 1) {
2703 set_bit(BEACON_BLINK_NEEDED
, &ha
->dpc_flags
);
2707 /* Schedule the DPC routine if needed */
2708 if ((test_bit(ISP_ABORT_NEEDED
, &ha
->dpc_flags
) ||
2709 test_bit(LOOP_RESYNC_NEEDED
, &ha
->dpc_flags
) ||
2710 test_bit(LOOP_RESET_NEEDED
, &ha
->dpc_flags
) ||
2711 test_bit(FCPORT_UPDATE_NEEDED
, &ha
->dpc_flags
) ||
2713 test_bit(LOGIN_RETRY_NEEDED
, &ha
->dpc_flags
) ||
2714 test_bit(RESET_MARKER_NEEDED
, &ha
->dpc_flags
) ||
2715 test_bit(BEACON_BLINK_NEEDED
, &ha
->dpc_flags
) ||
2716 test_bit(VP_DPC_NEEDED
, &ha
->dpc_flags
) ||
2717 test_bit(RELOGIN_NEEDED
, &ha
->dpc_flags
)))
2718 qla2xxx_wake_dpc(pha
);
2720 qla2x00_restart_timer(ha
, WATCH_INTERVAL
);
2723 /* XXX(hch): crude hack to emulate a down_timeout() */
2725 qla2x00_down_timeout(struct semaphore
*sema
, unsigned long timeout
)
2727 const unsigned int step
= 100; /* msecs */
2728 unsigned int iterations
= jiffies_to_msecs(timeout
)/100;
2731 if (!down_trylock(sema
))
2733 if (msleep_interruptible(step
))
2735 } while (--iterations
> 0);
2740 /* Firmware interface routines. */
2743 #define FW_ISP21XX 0
2744 #define FW_ISP22XX 1
2745 #define FW_ISP2300 2
2746 #define FW_ISP2322 3
2747 #define FW_ISP24XX 4
2748 #define FW_ISP25XX 5
2750 #define FW_FILE_ISP21XX "ql2100_fw.bin"
2751 #define FW_FILE_ISP22XX "ql2200_fw.bin"
2752 #define FW_FILE_ISP2300 "ql2300_fw.bin"
2753 #define FW_FILE_ISP2322 "ql2322_fw.bin"
2754 #define FW_FILE_ISP24XX "ql2400_fw.bin"
2755 #define FW_FILE_ISP25XX "ql2500_fw.bin"
2757 static DECLARE_MUTEX(qla_fw_lock
);
2759 static struct fw_blob qla_fw_blobs
[FW_BLOBS
] = {
2760 { .name
= FW_FILE_ISP21XX
, .segs
= { 0x1000, 0 }, },
2761 { .name
= FW_FILE_ISP22XX
, .segs
= { 0x1000, 0 }, },
2762 { .name
= FW_FILE_ISP2300
, .segs
= { 0x800, 0 }, },
2763 { .name
= FW_FILE_ISP2322
, .segs
= { 0x800, 0x1c000, 0x1e000, 0 }, },
2764 { .name
= FW_FILE_ISP24XX
, },
2765 { .name
= FW_FILE_ISP25XX
, },
2769 qla2x00_request_firmware(scsi_qla_host_t
*ha
)
2771 struct fw_blob
*blob
;
2774 if (IS_QLA2100(ha
)) {
2775 blob
= &qla_fw_blobs
[FW_ISP21XX
];
2776 } else if (IS_QLA2200(ha
)) {
2777 blob
= &qla_fw_blobs
[FW_ISP22XX
];
2778 } else if (IS_QLA2300(ha
) || IS_QLA2312(ha
) || IS_QLA6312(ha
)) {
2779 blob
= &qla_fw_blobs
[FW_ISP2300
];
2780 } else if (IS_QLA2322(ha
) || IS_QLA6322(ha
)) {
2781 blob
= &qla_fw_blobs
[FW_ISP2322
];
2782 } else if (IS_QLA24XX(ha
) || IS_QLA54XX(ha
)) {
2783 blob
= &qla_fw_blobs
[FW_ISP24XX
];
2784 } else if (IS_QLA25XX(ha
)) {
2785 blob
= &qla_fw_blobs
[FW_ISP25XX
];
2792 if (request_firmware(&blob
->fw
, blob
->name
, &ha
->pdev
->dev
)) {
2793 DEBUG2(printk("scsi(%ld): Failed to load firmware image "
2794 "(%s).\n", ha
->host_no
, blob
->name
));
2806 qla2x00_release_firmware(void)
2811 for (idx
= 0; idx
< FW_BLOBS
; idx
++)
2812 if (qla_fw_blobs
[idx
].fw
)
2813 release_firmware(qla_fw_blobs
[idx
].fw
);
2817 static struct pci_device_id qla2xxx_pci_tbl
[] = {
2818 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC
, PCI_DEVICE_ID_QLOGIC_ISP2100
) },
2819 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC
, PCI_DEVICE_ID_QLOGIC_ISP2200
) },
2820 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC
, PCI_DEVICE_ID_QLOGIC_ISP2300
) },
2821 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC
, PCI_DEVICE_ID_QLOGIC_ISP2312
) },
2822 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC
, PCI_DEVICE_ID_QLOGIC_ISP2322
) },
2823 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC
, PCI_DEVICE_ID_QLOGIC_ISP6312
) },
2824 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC
, PCI_DEVICE_ID_QLOGIC_ISP6322
) },
2825 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC
, PCI_DEVICE_ID_QLOGIC_ISP2422
) },
2826 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC
, PCI_DEVICE_ID_QLOGIC_ISP2432
) },
2827 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC
, PCI_DEVICE_ID_QLOGIC_ISP5422
) },
2828 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC
, PCI_DEVICE_ID_QLOGIC_ISP5432
) },
2829 { PCI_DEVICE(PCI_VENDOR_ID_QLOGIC
, PCI_DEVICE_ID_QLOGIC_ISP2532
) },
2832 MODULE_DEVICE_TABLE(pci
, qla2xxx_pci_tbl
);
2834 static struct pci_driver qla2xxx_pci_driver
= {
2835 .name
= QLA2XXX_DRIVER_NAME
,
2837 .owner
= THIS_MODULE
,
2839 .id_table
= qla2xxx_pci_tbl
,
2840 .probe
= qla2x00_probe_one
,
2841 .remove
= __devexit_p(qla2x00_remove_one
),
2845 * qla2x00_module_init - Module initialization.
2848 qla2x00_module_init(void)
2852 /* Allocate cache for SRBs. */
2853 srb_cachep
= kmem_cache_create("qla2xxx_srbs", sizeof(srb_t
), 0,
2854 SLAB_HWCACHE_ALIGN
, NULL
);
2855 if (srb_cachep
== NULL
) {
2857 "qla2xxx: Unable to allocate SRB cache...Failing load!\n");
2861 /* Derive version string. */
2862 strcpy(qla2x00_version_str
, QLA2XXX_VERSION
);
2863 if (ql2xextended_error_logging
)
2864 strcat(qla2x00_version_str
, "-debug");
2866 qla2xxx_transport_template
=
2867 fc_attach_transport(&qla2xxx_transport_functions
);
2868 if (!qla2xxx_transport_template
) {
2869 kmem_cache_destroy(srb_cachep
);
2872 qla2xxx_transport_vport_template
=
2873 fc_attach_transport(&qla2xxx_transport_vport_functions
);
2874 if (!qla2xxx_transport_vport_template
) {
2875 kmem_cache_destroy(srb_cachep
);
2876 fc_release_transport(qla2xxx_transport_template
);
2880 printk(KERN_INFO
"QLogic Fibre Channel HBA Driver\n");
2881 ret
= pci_register_driver(&qla2xxx_pci_driver
);
2883 kmem_cache_destroy(srb_cachep
);
2884 fc_release_transport(qla2xxx_transport_template
);
2885 fc_release_transport(qla2xxx_transport_vport_template
);
2891 * qla2x00_module_exit - Module cleanup.
2894 qla2x00_module_exit(void)
2896 pci_unregister_driver(&qla2xxx_pci_driver
);
2897 qla2x00_release_firmware();
2898 kmem_cache_destroy(srb_cachep
);
2899 fc_release_transport(qla2xxx_transport_template
);
2900 fc_release_transport(qla2xxx_transport_vport_template
);
2903 module_init(qla2x00_module_init
);
2904 module_exit(qla2x00_module_exit
);
2906 MODULE_AUTHOR("QLogic Corporation");
2907 MODULE_DESCRIPTION("QLogic Fibre Channel HBA Driver");
2908 MODULE_LICENSE("GPL");
2909 MODULE_VERSION(QLA2XXX_VERSION
);
2910 MODULE_FIRMWARE(FW_FILE_ISP21XX
);
2911 MODULE_FIRMWARE(FW_FILE_ISP22XX
);
2912 MODULE_FIRMWARE(FW_FILE_ISP2300
);
2913 MODULE_FIRMWARE(FW_FILE_ISP2322
);
2914 MODULE_FIRMWARE(FW_FILE_ISP24XX
);