aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/qla2xxx
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/qla2xxx')
-rw-r--r--drivers/scsi/qla2xxx/qla_attr.c5
-rw-r--r--drivers/scsi/qla2xxx/qla_dbg.c4
-rw-r--r--drivers/scsi/qla2xxx/qla_def.h46
-rw-r--r--drivers/scsi/qla2xxx/qla_gbl.h13
-rw-r--r--drivers/scsi/qla2xxx/qla_gs.c5
-rw-r--r--drivers/scsi/qla2xxx/qla_init.c252
-rw-r--r--drivers/scsi/qla2xxx/qla_inline.h39
-rw-r--r--drivers/scsi/qla2xxx/qla_iocb.c4
-rw-r--r--drivers/scsi/qla2xxx/qla_isr.c5
-rw-r--r--drivers/scsi/qla2xxx/qla_os.c101
10 files changed, 275 insertions, 199 deletions
diff --git a/drivers/scsi/qla2xxx/qla_attr.c b/drivers/scsi/qla2xxx/qla_attr.c
index 9bc1f153f7ea..30c381c3abcc 100644
--- a/drivers/scsi/qla2xxx/qla_attr.c
+++ b/drivers/scsi/qla2xxx/qla_attr.c
@@ -93,10 +93,7 @@ qla2x00_sysfs_write_fw_dump(struct kobject *kobj, char *buf, loff_t off,
93 "Firmware dump ready for read on (%ld).\n", 93 "Firmware dump ready for read on (%ld).\n",
94 ha->host_no); 94 ha->host_no);
95 memset(ha->fw_dump_buffer, 0, dump_size); 95 memset(ha->fw_dump_buffer, 0, dump_size);
96 if (IS_QLA2100(ha) || IS_QLA2200(ha)) 96 ha->isp_ops.ascii_fw_dump(ha);
97 qla2100_ascii_fw_dump(ha);
98 else
99 qla2300_ascii_fw_dump(ha);
100 ha->fw_dump_buffer_len = strlen(ha->fw_dump_buffer); 97 ha->fw_dump_buffer_len = strlen(ha->fw_dump_buffer);
101 } 98 }
102 break; 99 break;
diff --git a/drivers/scsi/qla2xxx/qla_dbg.c b/drivers/scsi/qla2xxx/qla_dbg.c
index 329d1a1fa547..20f4ed1cd7ff 100644
--- a/drivers/scsi/qla2xxx/qla_dbg.c
+++ b/drivers/scsi/qla2xxx/qla_dbg.c
@@ -405,7 +405,7 @@ qla2300_ascii_fw_dump(scsi_qla_host_t *ha)
405 fw = ha->fw_dump; 405 fw = ha->fw_dump;
406 406
407 qla_uprintf(&uiter, "%s Firmware Version %s\n", ha->model_number, 407 qla_uprintf(&uiter, "%s Firmware Version %s\n", ha->model_number,
408 qla2x00_get_fw_version_str(ha, fw_info)); 408 ha->isp_ops.fw_version_str(ha, fw_info));
409 409
410 qla_uprintf(&uiter, "\n[==>BEG]\n"); 410 qla_uprintf(&uiter, "\n[==>BEG]\n");
411 411
@@ -819,7 +819,7 @@ qla2100_ascii_fw_dump(scsi_qla_host_t *ha)
819 fw = ha->fw_dump; 819 fw = ha->fw_dump;
820 820
821 qla_uprintf(&uiter, "%s Firmware Version %s\n", ha->model_number, 821 qla_uprintf(&uiter, "%s Firmware Version %s\n", ha->model_number,
822 qla2x00_get_fw_version_str(ha, fw_info)); 822 ha->isp_ops.fw_version_str(ha, fw_info));
823 823
824 qla_uprintf(&uiter, "\n[==>BEG]\n"); 824 qla_uprintf(&uiter, "\n[==>BEG]\n");
825 825
diff --git a/drivers/scsi/qla2xxx/qla_def.h b/drivers/scsi/qla2xxx/qla_def.h
index 83a32e403e29..24e22dc2fe57 100644
--- a/drivers/scsi/qla2xxx/qla_def.h
+++ b/drivers/scsi/qla2xxx/qla_def.h
@@ -33,6 +33,7 @@
33#include <linux/mempool.h> 33#include <linux/mempool.h>
34#include <linux/spinlock.h> 34#include <linux/spinlock.h>
35#include <linux/completion.h> 35#include <linux/completion.h>
36#include <linux/interrupt.h>
36#include <asm/semaphore.h> 37#include <asm/semaphore.h>
37 38
38#include <scsi/scsi.h> 39#include <scsi/scsi.h>
@@ -1950,6 +1951,47 @@ struct gid_list_info {
1950#define GID_LIST_SIZE (sizeof(struct gid_list_info) * MAX_FIBRE_DEVICES) 1951#define GID_LIST_SIZE (sizeof(struct gid_list_info) * MAX_FIBRE_DEVICES)
1951 1952
1952/* 1953/*
1954 * ISP operations
1955 */
1956struct isp_operations {
1957
1958 int (*pci_config) (struct scsi_qla_host *);
1959 void (*reset_chip) (struct scsi_qla_host *);
1960 int (*chip_diag) (struct scsi_qla_host *);
1961 void (*config_rings) (struct scsi_qla_host *);
1962 void (*reset_adapter) (struct scsi_qla_host *);
1963 int (*nvram_config) (struct scsi_qla_host *);
1964 void (*update_fw_options) (struct scsi_qla_host *);
1965 int (*load_risc) (struct scsi_qla_host *, uint32_t *);
1966
1967 char * (*pci_info_str) (struct scsi_qla_host *, char *);
1968 char * (*fw_version_str) (struct scsi_qla_host *, char *);
1969
1970 irqreturn_t (*intr_handler) (int, void *, struct pt_regs *);
1971 void (*enable_intrs) (struct scsi_qla_host *);
1972 void (*disable_intrs) (struct scsi_qla_host *);
1973
1974 int (*abort_command) (struct scsi_qla_host *, srb_t *);
1975 int (*abort_target) (struct fc_port *);
1976 int (*fabric_login) (struct scsi_qla_host *, uint16_t, uint8_t,
1977 uint8_t, uint8_t, uint16_t *, uint8_t);
1978 int (*fabric_logout) (struct scsi_qla_host *, uint16_t);
1979
1980 uint16_t (*calc_req_entries) (uint16_t);
1981 void (*build_iocbs) (srb_t *, cmd_entry_t *, uint16_t);
1982 ms_iocb_entry_t * (*prep_ms_iocb) (struct scsi_qla_host *, uint32_t,
1983 uint32_t);
1984
1985 uint8_t * (*read_nvram) (struct scsi_qla_host *, uint8_t *,
1986 uint32_t, uint32_t);
1987 int (*write_nvram) (struct scsi_qla_host *, uint8_t *, uint32_t,
1988 uint32_t);
1989
1990 void (*fw_dump) (struct scsi_qla_host *, int);
1991 void (*ascii_fw_dump) (struct scsi_qla_host *);
1992};
1993
1994/*
1953 * Linux Host Adapter structure 1995 * Linux Host Adapter structure
1954 */ 1996 */
1955typedef struct scsi_qla_host { 1997typedef struct scsi_qla_host {
@@ -2055,8 +2097,7 @@ typedef struct scsi_qla_host {
2055 uint16_t rsp_ring_index; /* Current index. */ 2097 uint16_t rsp_ring_index; /* Current index. */
2056 uint16_t response_q_length; 2098 uint16_t response_q_length;
2057 2099
2058 uint16_t (*calc_request_entries)(uint16_t); 2100 struct isp_operations isp_ops;
2059 void (*build_scsi_iocbs)(srb_t *, cmd_entry_t *, uint16_t);
2060 2101
2061 /* Outstandings ISP commands. */ 2102 /* Outstandings ISP commands. */
2062 srb_t *outstanding_cmds[MAX_OUTSTANDING_COMMANDS]; 2103 srb_t *outstanding_cmds[MAX_OUTSTANDING_COMMANDS];
@@ -2149,6 +2190,7 @@ typedef struct scsi_qla_host {
2149 2190
2150 dma_addr_t gid_list_dma; 2191 dma_addr_t gid_list_dma;
2151 struct gid_list_info *gid_list; 2192 struct gid_list_info *gid_list;
2193 int gid_list_info_size;
2152 2194
2153 dma_addr_t rlc_rsp_dma; 2195 dma_addr_t rlc_rsp_dma;
2154 rpt_lun_cmd_rsp_t *rlc_rsp; 2196 rpt_lun_cmd_rsp_t *rlc_rsp;
diff --git a/drivers/scsi/qla2xxx/qla_gbl.h b/drivers/scsi/qla2xxx/qla_gbl.h
index 164866b199e6..6bea7ac622c7 100644
--- a/drivers/scsi/qla2xxx/qla_gbl.h
+++ b/drivers/scsi/qla2xxx/qla_gbl.h
@@ -32,6 +32,17 @@ extern int qla2x00_probe_one(struct pci_dev *, struct qla_board_info *);
32 * Global Function Prototypes in qla_init.c source file. 32 * Global Function Prototypes in qla_init.c source file.
33 */ 33 */
34extern int qla2x00_initialize_adapter(scsi_qla_host_t *); 34extern int qla2x00_initialize_adapter(scsi_qla_host_t *);
35
36extern int qla2100_pci_config(struct scsi_qla_host *);
37extern int qla2300_pci_config(struct scsi_qla_host *);
38extern void qla2x00_reset_chip(struct scsi_qla_host *);
39extern int qla2x00_chip_diag(struct scsi_qla_host *);
40extern void qla2x00_config_rings(struct scsi_qla_host *);
41extern void qla2x00_reset_adapter(struct scsi_qla_host *);
42extern int qla2x00_nvram_config(struct scsi_qla_host *);
43extern void qla2x00_update_fw_options(struct scsi_qla_host *);
44extern int qla2x00_load_risc(struct scsi_qla_host *, uint32_t *);
45
35extern fc_port_t *qla2x00_alloc_fcport(scsi_qla_host_t *, int); 46extern fc_port_t *qla2x00_alloc_fcport(scsi_qla_host_t *, int);
36 47
37extern int qla2x00_loop_resync(scsi_qla_host_t *); 48extern int qla2x00_loop_resync(scsi_qla_host_t *);
@@ -205,6 +216,8 @@ extern void qla2x00_print_scsi_cmd(struct scsi_cmnd *);
205/* 216/*
206 * Global Function Prototypes in qla_gs.c source file. 217 * Global Function Prototypes in qla_gs.c source file.
207 */ 218 */
219extern ms_iocb_entry_t *qla2x00_prep_ms_iocb(scsi_qla_host_t *, uint32_t,
220 uint32_t);
208extern int qla2x00_ga_nxt(scsi_qla_host_t *, fc_port_t *); 221extern int qla2x00_ga_nxt(scsi_qla_host_t *, fc_port_t *);
209extern int qla2x00_gid_pt(scsi_qla_host_t *, sw_info_t *); 222extern int qla2x00_gid_pt(scsi_qla_host_t *, sw_info_t *);
210extern int qla2x00_gpn_id(scsi_qla_host_t *, sw_info_t *); 223extern int qla2x00_gpn_id(scsi_qla_host_t *, sw_info_t *);
diff --git a/drivers/scsi/qla2xxx/qla_gs.c b/drivers/scsi/qla2xxx/qla_gs.c
index 531dad95896c..644c56431366 100644
--- a/drivers/scsi/qla2xxx/qla_gs.c
+++ b/drivers/scsi/qla2xxx/qla_gs.c
@@ -18,9 +18,6 @@
18 */ 18 */
19#include "qla_def.h" 19#include "qla_def.h"
20 20
21static inline ms_iocb_entry_t *
22qla2x00_prep_ms_iocb(scsi_qla_host_t *, uint32_t, uint32_t);
23
24static inline struct ct_sns_req * 21static inline struct ct_sns_req *
25qla2x00_prep_ct_req(struct ct_sns_req *, uint16_t, uint16_t); 22qla2x00_prep_ct_req(struct ct_sns_req *, uint16_t, uint16_t);
26 23
@@ -42,7 +39,7 @@ static int qla2x00_sns_rnn_id(scsi_qla_host_t *);
42 * 39 *
43 * Returns a pointer to the @ha's ms_iocb. 40 * Returns a pointer to the @ha's ms_iocb.
44 */ 41 */
45static inline ms_iocb_entry_t * 42ms_iocb_entry_t *
46qla2x00_prep_ms_iocb(scsi_qla_host_t *ha, uint32_t req_size, uint32_t rsp_size) 43qla2x00_prep_ms_iocb(scsi_qla_host_t *ha, uint32_t req_size, uint32_t rsp_size)
47{ 44{
48 ms_iocb_entry_t *ms_pkt; 45 ms_iocb_entry_t *ms_pkt;
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c
index 7629558eba25..27b7f9259f28 100644
--- a/drivers/scsi/qla2xxx/qla_init.c
+++ b/drivers/scsi/qla2xxx/qla_init.c
@@ -34,17 +34,13 @@
34/* 34/*
35* QLogic ISP2x00 Hardware Support Function Prototypes. 35* QLogic ISP2x00 Hardware Support Function Prototypes.
36*/ 36*/
37static int qla2x00_pci_config(scsi_qla_host_t *);
38static int qla2x00_isp_firmware(scsi_qla_host_t *); 37static int qla2x00_isp_firmware(scsi_qla_host_t *);
39static void qla2x00_reset_chip(scsi_qla_host_t *);
40static int qla2x00_chip_diag(scsi_qla_host_t *);
41static void qla2x00_resize_request_q(scsi_qla_host_t *); 38static void qla2x00_resize_request_q(scsi_qla_host_t *);
42static int qla2x00_setup_chip(scsi_qla_host_t *); 39static int qla2x00_setup_chip(scsi_qla_host_t *);
43static void qla2x00_init_response_q_entries(scsi_qla_host_t *); 40static void qla2x00_init_response_q_entries(scsi_qla_host_t *);
44static int qla2x00_init_rings(scsi_qla_host_t *); 41static int qla2x00_init_rings(scsi_qla_host_t *);
45static int qla2x00_fw_ready(scsi_qla_host_t *); 42static int qla2x00_fw_ready(scsi_qla_host_t *);
46static int qla2x00_configure_hba(scsi_qla_host_t *); 43static int qla2x00_configure_hba(scsi_qla_host_t *);
47static int qla2x00_nvram_config(scsi_qla_host_t *);
48static int qla2x00_configure_loop(scsi_qla_host_t *); 44static int qla2x00_configure_loop(scsi_qla_host_t *);
49static int qla2x00_configure_local_loop(scsi_qla_host_t *); 45static int qla2x00_configure_local_loop(scsi_qla_host_t *);
50static void qla2x00_update_fcport(scsi_qla_host_t *, fc_port_t *); 46static void qla2x00_update_fcport(scsi_qla_host_t *, fc_port_t *);
@@ -55,7 +51,6 @@ static int qla2x00_fabric_dev_login(scsi_qla_host_t *, fc_port_t *,
55 uint16_t *); 51 uint16_t *);
56 52
57static int qla2x00_restart_isp(scsi_qla_host_t *); 53static int qla2x00_restart_isp(scsi_qla_host_t *);
58static void qla2x00_reset_adapter(scsi_qla_host_t *);
59 54
60/****************************************************************************/ 55/****************************************************************************/
61/* QLogic ISP2x00 Hardware Support Functions. */ 56/* QLogic ISP2x00 Hardware Support Functions. */
@@ -92,17 +87,17 @@ qla2x00_initialize_adapter(scsi_qla_host_t *ha)
92 ha->isp_abort_cnt = 0; 87 ha->isp_abort_cnt = 0;
93 ha->beacon_blink_led = 0; 88 ha->beacon_blink_led = 0;
94 89
95 rval = qla2x00_pci_config(ha); 90 rval = ha->isp_ops.pci_config(ha);
96 if (rval) { 91 if (rval) {
97 DEBUG2(printk("scsi(%ld): Unable to configure PCI space=n", 92 DEBUG2(printk("scsi(%ld): Unable to configure PCI space=n",
98 ha->host_no)); 93 ha->host_no));
99 return (rval); 94 return (rval);
100 } 95 }
101 96
102 qla2x00_reset_chip(ha); 97 ha->isp_ops.reset_chip(ha);
103 98
104 qla_printk(KERN_INFO, ha, "Configure NVRAM parameters...\n"); 99 qla_printk(KERN_INFO, ha, "Configure NVRAM parameters...\n");
105 qla2x00_nvram_config(ha); 100 ha->isp_ops.nvram_config(ha);
106 101
107 qla_printk(KERN_INFO, ha, "Verifying loaded RISC code...\n"); 102 qla_printk(KERN_INFO, ha, "Verifying loaded RISC code...\n");
108 103
@@ -115,7 +110,7 @@ qla2x00_initialize_adapter(scsi_qla_host_t *ha)
115 110
116 /* If firmware needs to be loaded */ 111 /* If firmware needs to be loaded */
117 if (qla2x00_isp_firmware(ha) != QLA_SUCCESS) { 112 if (qla2x00_isp_firmware(ha) != QLA_SUCCESS) {
118 if ((rval = qla2x00_chip_diag(ha)) == QLA_SUCCESS) { 113 if ((rval = ha->isp_ops.chip_diag(ha)) == QLA_SUCCESS) {
119 rval = qla2x00_setup_chip(ha); 114 rval = qla2x00_setup_chip(ha);
120 } 115 }
121 } 116 }
@@ -190,110 +185,130 @@ check_fw_ready_again:
190} 185}
191 186
192/** 187/**
193 * qla2x00_pci_config() - Setup device PCI configuration registers. 188 * qla2100_pci_config() - Setup ISP21xx PCI configuration registers.
194 * @ha: HA context 189 * @ha: HA context
195 * 190 *
196 * Returns 0 on success. 191 * Returns 0 on success.
197 */ 192 */
198static int 193int
199qla2x00_pci_config(scsi_qla_host_t *ha) 194qla2100_pci_config(scsi_qla_host_t *ha)
200{ 195{
201 uint16_t w, mwi; 196 uint16_t w, mwi;
202 unsigned long flags = 0; 197 unsigned long flags;
203 uint32_t cnt;
204 198
205 qla_printk(KERN_INFO, ha, "Configuring PCI space...\n"); 199 qla_printk(KERN_INFO, ha, "Configuring PCI space...\n");
206 200
207 /*
208 * Turn on PCI master; for system BIOSes that don't turn it on by
209 * default.
210 */
211 pci_set_master(ha->pdev); 201 pci_set_master(ha->pdev);
212 mwi = 0; 202 mwi = 0;
213 if (pci_set_mwi(ha->pdev)) 203 if (pci_set_mwi(ha->pdev))
214 mwi = PCI_COMMAND_INVALIDATE; 204 mwi = PCI_COMMAND_INVALIDATE;
215 pci_read_config_word(ha->pdev, PCI_REVISION_ID, &ha->revision); 205 pci_read_config_word(ha->pdev, PCI_REVISION_ID, &ha->revision);
216 206
217 if (!ha->iobase)
218 return (QLA_FUNCTION_FAILED);
219
220 /*
221 * We want to respect framework's setting of PCI configuration space
222 * command register and also want to make sure that all bits of
223 * interest to us are properly set in command register.
224 */
225 pci_read_config_word(ha->pdev, PCI_COMMAND, &w); 207 pci_read_config_word(ha->pdev, PCI_COMMAND, &w);
226 w |= mwi | (PCI_COMMAND_PARITY | PCI_COMMAND_SERR); 208 w |= mwi | (PCI_COMMAND_PARITY | PCI_COMMAND_SERR);
209 pci_write_config_word(ha->pdev, PCI_COMMAND, w);
210
211 /* Reset expansion ROM address decode enable */
212 pci_read_config_word(ha->pdev, PCI_ROM_ADDRESS, &w);
213 w &= ~PCI_ROM_ADDRESS_ENABLE;
214 pci_write_config_word(ha->pdev, PCI_ROM_ADDRESS, w);
227 215
228 /* Get PCI bus information. */ 216 /* Get PCI bus information. */
229 spin_lock_irqsave(&ha->hardware_lock, flags); 217 spin_lock_irqsave(&ha->hardware_lock, flags);
230 ha->pci_attr = RD_REG_WORD(&ha->iobase->ctrl_status); 218 ha->pci_attr = RD_REG_WORD(&ha->iobase->ctrl_status);
231 spin_unlock_irqrestore(&ha->hardware_lock, flags); 219 spin_unlock_irqrestore(&ha->hardware_lock, flags);
232 220
233 if (!IS_QLA2100(ha) && !IS_QLA2200(ha)) { 221 return QLA_SUCCESS;
234 pci_write_config_byte(ha->pdev, PCI_LATENCY_TIMER, 0x80); 222}
235 223
236 /* PCI Specification Revision 2.3 changes */ 224/**
237 if (IS_QLA2322(ha) || IS_QLA6322(ha)) 225 * qla2300_pci_config() - Setup ISP23xx PCI configuration registers.
238 /* Command Register - Reset Interrupt Disable. */ 226 * @ha: HA context
239 w &= ~PCI_COMMAND_INTX_DISABLE; 227 *
228 * Returns 0 on success.
229 */
230int
231qla2300_pci_config(scsi_qla_host_t *ha)
232{
233 uint16_t w, mwi;
234 unsigned long flags = 0;
235 uint32_t cnt;
240 236
241 /* 237 qla_printk(KERN_INFO, ha, "Configuring PCI space...\n");
242 * If this is a 2300 card and not 2312, reset the
243 * COMMAND_INVALIDATE due to a bug in the 2300. Unfortunately,
244 * the 2310 also reports itself as a 2300 so we need to get the
245 * fb revision level -- a 6 indicates it really is a 2300 and
246 * not a 2310.
247 */
248 if (IS_QLA2300(ha)) {
249 spin_lock_irqsave(&ha->hardware_lock, flags);
250 238
251 /* Pause RISC. */ 239 pci_set_master(ha->pdev);
252 WRT_REG_WORD(&ha->iobase->hccr, HCCR_PAUSE_RISC); 240 mwi = 0;
253 for (cnt = 0; cnt < 30000; cnt++) { 241 if (pci_set_mwi(ha->pdev))
254 if ((RD_REG_WORD(&ha->iobase->hccr) & 242 mwi = PCI_COMMAND_INVALIDATE;
255 HCCR_RISC_PAUSE) != 0) 243 pci_read_config_word(ha->pdev, PCI_REVISION_ID, &ha->revision);
256 break;
257
258 udelay(10);
259 }
260 244
261 /* Select FPM registers. */ 245 pci_read_config_word(ha->pdev, PCI_COMMAND, &w);
262 WRT_REG_WORD(&ha->iobase->ctrl_status, 0x20); 246 w |= mwi | (PCI_COMMAND_PARITY | PCI_COMMAND_SERR);
263 RD_REG_WORD(&ha->iobase->ctrl_status);
264 247
265 /* Get the fb rev level */ 248 if (IS_QLA2322(ha) || IS_QLA6322(ha))
266 ha->fb_rev = RD_FB_CMD_REG(ha, ha->iobase); 249 w &= ~PCI_COMMAND_INTX_DISABLE;
267 250
268 if (ha->fb_rev == FPM_2300) 251 /*
269 w &= ~PCI_COMMAND_INVALIDATE; 252 * If this is a 2300 card and not 2312, reset the
253 * COMMAND_INVALIDATE due to a bug in the 2300. Unfortunately,
254 * the 2310 also reports itself as a 2300 so we need to get the
255 * fb revision level -- a 6 indicates it really is a 2300 and
256 * not a 2310.
257 */
258 if (IS_QLA2300(ha)) {
259 spin_lock_irqsave(&ha->hardware_lock, flags);
270 260
271 /* Deselect FPM registers. */ 261 /* Pause RISC. */
272 WRT_REG_WORD(&ha->iobase->ctrl_status, 0x0); 262 WRT_REG_WORD(&ha->iobase->hccr, HCCR_PAUSE_RISC);
273 RD_REG_WORD(&ha->iobase->ctrl_status); 263 for (cnt = 0; cnt < 30000; cnt++) {
264 if ((RD_REG_WORD(&ha->iobase->hccr) &
265 HCCR_RISC_PAUSE) != 0)
266 break;
274 267
275 /* Release RISC module. */ 268 udelay(10);
276 WRT_REG_WORD(&ha->iobase->hccr, HCCR_RELEASE_RISC); 269 }
277 for (cnt = 0; cnt < 30000; cnt++) {
278 if ((RD_REG_WORD(&ha->iobase->hccr) &
279 HCCR_RISC_PAUSE) == 0)
280 break;
281
282 udelay(10);
283 }
284 270
285 spin_unlock_irqrestore(&ha->hardware_lock, flags); 271 /* Select FPM registers. */
272 WRT_REG_WORD(&ha->iobase->ctrl_status, 0x20);
273 RD_REG_WORD(&ha->iobase->ctrl_status);
274
275 /* Get the fb rev level */
276 ha->fb_rev = RD_FB_CMD_REG(ha, ha->iobase);
277
278 if (ha->fb_rev == FPM_2300)
279 w &= ~PCI_COMMAND_INVALIDATE;
280
281 /* Deselect FPM registers. */
282 WRT_REG_WORD(&ha->iobase->ctrl_status, 0x0);
283 RD_REG_WORD(&ha->iobase->ctrl_status);
284
285 /* Release RISC module. */
286 WRT_REG_WORD(&ha->iobase->hccr, HCCR_RELEASE_RISC);
287 for (cnt = 0; cnt < 30000; cnt++) {
288 if ((RD_REG_WORD(&ha->iobase->hccr) &
289 HCCR_RISC_PAUSE) == 0)
290 break;
291
292 udelay(10);
286 } 293 }
287 }
288 294
295 spin_unlock_irqrestore(&ha->hardware_lock, flags);
296 }
289 pci_write_config_word(ha->pdev, PCI_COMMAND, w); 297 pci_write_config_word(ha->pdev, PCI_COMMAND, w);
290 298
299 pci_write_config_byte(ha->pdev, PCI_LATENCY_TIMER, 0x80);
300
291 /* Reset expansion ROM address decode enable */ 301 /* Reset expansion ROM address decode enable */
292 pci_read_config_word(ha->pdev, PCI_ROM_ADDRESS, &w); 302 pci_read_config_word(ha->pdev, PCI_ROM_ADDRESS, &w);
293 w &= ~PCI_ROM_ADDRESS_ENABLE; 303 w &= ~PCI_ROM_ADDRESS_ENABLE;
294 pci_write_config_word(ha->pdev, PCI_ROM_ADDRESS, w); 304 pci_write_config_word(ha->pdev, PCI_ROM_ADDRESS, w);
295 305
296 return (QLA_SUCCESS); 306 /* Get PCI bus information. */
307 spin_lock_irqsave(&ha->hardware_lock, flags);
308 ha->pci_attr = RD_REG_WORD(&ha->iobase->ctrl_status);
309 spin_unlock_irqrestore(&ha->hardware_lock, flags);
310
311 return QLA_SUCCESS;
297} 312}
298 313
299/** 314/**
@@ -333,7 +348,7 @@ qla2x00_isp_firmware(scsi_qla_host_t *ha)
333 * 348 *
334 * Returns 0 on success. 349 * Returns 0 on success.
335 */ 350 */
336static void 351void
337qla2x00_reset_chip(scsi_qla_host_t *ha) 352qla2x00_reset_chip(scsi_qla_host_t *ha)
338{ 353{
339 unsigned long flags = 0; 354 unsigned long flags = 0;
@@ -342,8 +357,7 @@ qla2x00_reset_chip(scsi_qla_host_t *ha)
342 unsigned long mbx_flags = 0; 357 unsigned long mbx_flags = 0;
343 uint16_t cmd; 358 uint16_t cmd;
344 359
345 /* Disable ISP interrupts. */ 360 ha->isp_ops.disable_intrs(ha);
346 qla2x00_disable_intrs(ha);
347 361
348 spin_lock_irqsave(&ha->hardware_lock, flags); 362 spin_lock_irqsave(&ha->hardware_lock, flags);
349 363
@@ -487,7 +501,7 @@ qla2x00_reset_chip(scsi_qla_host_t *ha)
487 * 501 *
488 * Returns 0 on success. 502 * Returns 0 on success.
489 */ 503 */
490static int 504int
491qla2x00_chip_diag(scsi_qla_host_t *ha) 505qla2x00_chip_diag(scsi_qla_host_t *ha)
492{ 506{
493 int rval; 507 int rval;
@@ -802,7 +816,7 @@ qla2x00_init_response_q_entries(scsi_qla_host_t *ha)
802 * 816 *
803 * Returns 0 on success. 817 * Returns 0 on success.
804 */ 818 */
805static void 819void
806qla2x00_update_fw_options(scsi_qla_host_t *ha) 820qla2x00_update_fw_options(scsi_qla_host_t *ha)
807{ 821{
808 uint16_t swing, emphasis, tx_sens, rx_sens; 822 uint16_t swing, emphasis, tx_sens, rx_sens;
@@ -872,6 +886,28 @@ qla2x00_update_fw_options(scsi_qla_host_t *ha)
872 qla2x00_set_fw_options(ha, ha->fw_options); 886 qla2x00_set_fw_options(ha, ha->fw_options);
873} 887}
874 888
889void
890qla2x00_config_rings(struct scsi_qla_host *ha)
891{
892 device_reg_t __iomem *reg = ha->iobase;
893
894 /* Setup ring parameters in initialization control block. */
895 ha->init_cb->request_q_outpointer = __constant_cpu_to_le16(0);
896 ha->init_cb->response_q_inpointer = __constant_cpu_to_le16(0);
897 ha->init_cb->request_q_length = cpu_to_le16(ha->request_q_length);
898 ha->init_cb->response_q_length = cpu_to_le16(ha->response_q_length);
899 ha->init_cb->request_q_address[0] = cpu_to_le32(LSD(ha->request_dma));
900 ha->init_cb->request_q_address[1] = cpu_to_le32(MSD(ha->request_dma));
901 ha->init_cb->response_q_address[0] = cpu_to_le32(LSD(ha->response_dma));
902 ha->init_cb->response_q_address[1] = cpu_to_le32(MSD(ha->response_dma));
903
904 WRT_REG_WORD(ISP_REQ_Q_IN(ha, reg), 0);
905 WRT_REG_WORD(ISP_REQ_Q_OUT(ha, reg), 0);
906 WRT_REG_WORD(ISP_RSP_Q_IN(ha, reg), 0);
907 WRT_REG_WORD(ISP_RSP_Q_OUT(ha, reg), 0);
908 RD_REG_WORD(ISP_RSP_Q_OUT(ha, reg)); /* PCI Posting. */
909}
910
875/** 911/**
876 * qla2x00_init_rings() - Initializes firmware. 912 * qla2x00_init_rings() - Initializes firmware.
877 * @ha: HA context 913 * @ha: HA context
@@ -887,7 +923,6 @@ qla2x00_init_rings(scsi_qla_host_t *ha)
887 int rval; 923 int rval;
888 unsigned long flags = 0; 924 unsigned long flags = 0;
889 int cnt; 925 int cnt;
890 device_reg_t __iomem *reg = ha->iobase;
891 926
892 spin_lock_irqsave(&ha->hardware_lock, flags); 927 spin_lock_irqsave(&ha->hardware_lock, flags);
893 928
@@ -908,29 +943,15 @@ qla2x00_init_rings(scsi_qla_host_t *ha)
908 ha->response_ring_ptr = ha->response_ring; 943 ha->response_ring_ptr = ha->response_ring;
909 ha->rsp_ring_index = 0; 944 ha->rsp_ring_index = 0;
910 945
911 /* Setup ring parameters in initialization control block. */
912 ha->init_cb->request_q_outpointer = __constant_cpu_to_le16(0);
913 ha->init_cb->response_q_inpointer = __constant_cpu_to_le16(0);
914 ha->init_cb->request_q_length = cpu_to_le16(ha->request_q_length);
915 ha->init_cb->response_q_length = cpu_to_le16(ha->response_q_length);
916 ha->init_cb->request_q_address[0] = cpu_to_le32(LSD(ha->request_dma));
917 ha->init_cb->request_q_address[1] = cpu_to_le32(MSD(ha->request_dma));
918 ha->init_cb->response_q_address[0] = cpu_to_le32(LSD(ha->response_dma));
919 ha->init_cb->response_q_address[1] = cpu_to_le32(MSD(ha->response_dma));
920
921 /* Initialize response queue entries */ 946 /* Initialize response queue entries */
922 qla2x00_init_response_q_entries(ha); 947 qla2x00_init_response_q_entries(ha);
923 948
924 WRT_REG_WORD(ISP_REQ_Q_IN(ha, reg), 0); 949 ha->isp_ops.config_rings(ha);
925 WRT_REG_WORD(ISP_REQ_Q_OUT(ha, reg), 0);
926 WRT_REG_WORD(ISP_RSP_Q_IN(ha, reg), 0);
927 WRT_REG_WORD(ISP_RSP_Q_OUT(ha, reg), 0);
928 RD_REG_WORD(ISP_RSP_Q_OUT(ha, reg)); /* PCI Posting. */
929 950
930 spin_unlock_irqrestore(&ha->hardware_lock, flags); 951 spin_unlock_irqrestore(&ha->hardware_lock, flags);
931 952
932 /* Update any ISP specific firmware options before initialization. */ 953 /* Update any ISP specific firmware options before initialization. */
933 qla2x00_update_fw_options(ha); 954 ha->isp_ops.update_fw_options(ha);
934 955
935 DEBUG(printk("scsi(%ld): Issue init firmware.\n", ha->host_no)); 956 DEBUG(printk("scsi(%ld): Issue init firmware.\n", ha->host_no));
936 rval = qla2x00_init_firmware(ha, sizeof(init_cb_t)); 957 rval = qla2x00_init_firmware(ha, sizeof(init_cb_t));
@@ -1165,7 +1186,7 @@ qla2x00_configure_hba(scsi_qla_host_t *ha)
1165* Returns: 1186* Returns:
1166* 0 = success. 1187* 0 = success.
1167*/ 1188*/
1168static int 1189int
1169qla2x00_nvram_config(scsi_qla_host_t *ha) 1190qla2x00_nvram_config(scsi_qla_host_t *ha)
1170{ 1191{
1171 int rval; 1192 int rval;
@@ -1698,15 +1719,13 @@ qla2x00_configure_local_loop(scsi_qla_host_t *ha)
1698 domain = ((struct gid_list_info *)id_iter)->domain; 1719 domain = ((struct gid_list_info *)id_iter)->domain;
1699 area = ((struct gid_list_info *)id_iter)->area; 1720 area = ((struct gid_list_info *)id_iter)->area;
1700 al_pa = ((struct gid_list_info *)id_iter)->al_pa; 1721 al_pa = ((struct gid_list_info *)id_iter)->al_pa;
1701 if (IS_QLA2100(ha) || IS_QLA2200(ha)) { 1722 if (IS_QLA2100(ha) || IS_QLA2200(ha))
1702 loop_id = (uint16_t) 1723 loop_id = (uint16_t)
1703 ((struct gid_list_info *)id_iter)->loop_id_2100; 1724 ((struct gid_list_info *)id_iter)->loop_id_2100;
1704 id_iter += 4; 1725 else
1705 } else {
1706 loop_id = le16_to_cpu( 1726 loop_id = le16_to_cpu(
1707 ((struct gid_list_info *)id_iter)->loop_id); 1727 ((struct gid_list_info *)id_iter)->loop_id);
1708 id_iter += 6; 1728 id_iter += ha->gid_list_info_size;
1709 }
1710 1729
1711 /* Bypass reserved domain fields. */ 1730 /* Bypass reserved domain fields. */
1712 if ((domain & 0xf0) == 0xf0) 1731 if ((domain & 0xf0) == 0xf0)
@@ -1937,8 +1956,8 @@ qla2x00_configure_fabric(scsi_qla_host_t *ha)
1937 } 1956 }
1938 do { 1957 do {
1939 /* Ensure we are logged into the SNS. */ 1958 /* Ensure we are logged into the SNS. */
1940 qla2x00_login_fabric(ha, SIMPLE_NAME_SERVER, 0xff, 0xff, 0xfc, 1959 ha->isp_ops.fabric_login(ha, SIMPLE_NAME_SERVER, 0xff, 0xff,
1941 mb, BIT_1 | BIT_0); 1960 0xfc, mb, BIT_1 | BIT_0);
1942 if (mb[0] != MBS_COMMAND_COMPLETE) { 1961 if (mb[0] != MBS_COMMAND_COMPLETE) {
1943 DEBUG2(qla_printk(KERN_INFO, ha, 1962 DEBUG2(qla_printk(KERN_INFO, ha,
1944 "Failed SNS login: loop_id=%x mb[0]=%x mb[1]=%x " 1963 "Failed SNS login: loop_id=%x mb[0]=%x mb[1]=%x "
@@ -1992,7 +2011,7 @@ qla2x00_configure_fabric(scsi_qla_host_t *ha)
1992 fcport->port_type != FCT_INITIATOR && 2011 fcport->port_type != FCT_INITIATOR &&
1993 fcport->port_type != FCT_BROADCAST) { 2012 fcport->port_type != FCT_BROADCAST) {
1994 2013
1995 qla2x00_fabric_logout(ha, 2014 ha->isp_ops.fabric_logout(ha,
1996 fcport->loop_id); 2015 fcport->loop_id);
1997 fcport->loop_id = FC_NO_LOOP_ID; 2016 fcport->loop_id = FC_NO_LOOP_ID;
1998 } 2017 }
@@ -2238,7 +2257,7 @@ qla2x00_find_all_fabric_devs(scsi_qla_host_t *ha, struct list_head *new_fcports)
2238 (fcport->flags & FCF_TAPE_PRESENT) == 0 && 2257 (fcport->flags & FCF_TAPE_PRESENT) == 0 &&
2239 fcport->port_type != FCT_INITIATOR && 2258 fcport->port_type != FCT_INITIATOR &&
2240 fcport->port_type != FCT_BROADCAST) { 2259 fcport->port_type != FCT_BROADCAST) {
2241 qla2x00_fabric_logout(ha, fcport->loop_id); 2260 ha->isp_ops.fabric_logout(ha, fcport->loop_id);
2242 fcport->loop_id = FC_NO_LOOP_ID; 2261 fcport->loop_id = FC_NO_LOOP_ID;
2243 } 2262 }
2244 2263
@@ -2497,7 +2516,7 @@ qla2x00_fabric_dev_login(scsi_qla_host_t *ha, fc_port_t *fcport,
2497 if (rval == QLA_SUCCESS) { 2516 if (rval == QLA_SUCCESS) {
2498 rval = qla2x00_get_port_database(ha, fcport, 0); 2517 rval = qla2x00_get_port_database(ha, fcport, 0);
2499 if (rval != QLA_SUCCESS) { 2518 if (rval != QLA_SUCCESS) {
2500 qla2x00_fabric_logout(ha, fcport->loop_id); 2519 ha->isp_ops.fabric_logout(ha, fcport->loop_id);
2501 } else { 2520 } else {
2502 qla2x00_update_fcport(ha, fcport); 2521 qla2x00_update_fcport(ha, fcport);
2503 } 2522 }
@@ -2539,7 +2558,7 @@ qla2x00_fabric_login(scsi_qla_host_t *ha, fc_port_t *fcport,
2539 fcport->d_id.b.area, fcport->d_id.b.al_pa)); 2558 fcport->d_id.b.area, fcport->d_id.b.al_pa));
2540 2559
2541 /* Login fcport on switch. */ 2560 /* Login fcport on switch. */
2542 qla2x00_login_fabric(ha, fcport->loop_id, 2561 ha->isp_ops.fabric_login(ha, fcport->loop_id,
2543 fcport->d_id.b.domain, fcport->d_id.b.area, 2562 fcport->d_id.b.domain, fcport->d_id.b.area,
2544 fcport->d_id.b.al_pa, mb, BIT_0); 2563 fcport->d_id.b.al_pa, mb, BIT_0);
2545 if (mb[0] == MBS_PORT_ID_USED) { 2564 if (mb[0] == MBS_PORT_ID_USED) {
@@ -2602,7 +2621,7 @@ qla2x00_fabric_login(scsi_qla_host_t *ha, fc_port_t *fcport,
2602 * dead. 2621 * dead.
2603 */ 2622 */
2604 *next_loopid = fcport->loop_id; 2623 *next_loopid = fcport->loop_id;
2605 qla2x00_fabric_logout(ha, fcport->loop_id); 2624 ha->isp_ops.fabric_logout(ha, fcport->loop_id);
2606 qla2x00_mark_device_lost(ha, fcport, 1); 2625 qla2x00_mark_device_lost(ha, fcport, 1);
2607 2626
2608 rval = 1; 2627 rval = 1;
@@ -2618,7 +2637,7 @@ qla2x00_fabric_login(scsi_qla_host_t *ha, fc_port_t *fcport,
2618 fcport->d_id.b.al_pa, fcport->loop_id, jiffies)); 2637 fcport->d_id.b.al_pa, fcport->loop_id, jiffies));
2619 2638
2620 *next_loopid = fcport->loop_id; 2639 *next_loopid = fcport->loop_id;
2621 qla2x00_fabric_logout(ha, fcport->loop_id); 2640 ha->isp_ops.fabric_logout(ha, fcport->loop_id);
2622 fcport->loop_id = FC_NO_LOOP_ID; 2641 fcport->loop_id = FC_NO_LOOP_ID;
2623 atomic_set(&fcport->state, FCS_DEVICE_DEAD); 2642 atomic_set(&fcport->state, FCS_DEVICE_DEAD);
2624 2643
@@ -2763,7 +2782,7 @@ qla2x00_abort_isp(scsi_qla_host_t *ha)
2763 2782
2764 qla_printk(KERN_INFO, ha, 2783 qla_printk(KERN_INFO, ha,
2765 "Performing ISP error recovery - ha= %p.\n", ha); 2784 "Performing ISP error recovery - ha= %p.\n", ha);
2766 qla2x00_reset_chip(ha); 2785 ha->isp_ops.reset_chip(ha);
2767 2786
2768 atomic_set(&ha->loop_down_timer, LOOP_DOWN_TIME); 2787 atomic_set(&ha->loop_down_timer, LOOP_DOWN_TIME);
2769 if (atomic_read(&ha->loop_state) != LOOP_DOWN) { 2788 if (atomic_read(&ha->loop_state) != LOOP_DOWN) {
@@ -2789,7 +2808,7 @@ qla2x00_abort_isp(scsi_qla_host_t *ha)
2789 } 2808 }
2790 spin_unlock_irqrestore(&ha->hardware_lock, flags); 2809 spin_unlock_irqrestore(&ha->hardware_lock, flags);
2791 2810
2792 qla2x00_nvram_config(ha); 2811 ha->isp_ops.nvram_config(ha);
2793 2812
2794 if (!qla2x00_restart_isp(ha)) { 2813 if (!qla2x00_restart_isp(ha)) {
2795 clear_bit(RESET_MARKER_NEEDED, &ha->dpc_flags); 2814 clear_bit(RESET_MARKER_NEEDED, &ha->dpc_flags);
@@ -2804,8 +2823,7 @@ qla2x00_abort_isp(scsi_qla_host_t *ha)
2804 2823
2805 ha->flags.online = 1; 2824 ha->flags.online = 1;
2806 2825
2807 /* Enable ISP interrupts. */ 2826 ha->isp_ops.enable_intrs(ha);
2808 qla2x00_enable_intrs(ha);
2809 2827
2810 ha->isp_abort_cnt = 0; 2828 ha->isp_abort_cnt = 0;
2811 clear_bit(ISP_ABORT_RETRY, &ha->dpc_flags); 2829 clear_bit(ISP_ABORT_RETRY, &ha->dpc_flags);
@@ -2820,7 +2838,7 @@ qla2x00_abort_isp(scsi_qla_host_t *ha)
2820 * The next call disables the board 2838 * The next call disables the board
2821 * completely. 2839 * completely.
2822 */ 2840 */
2823 qla2x00_reset_adapter(ha); 2841 ha->isp_ops.reset_adapter(ha);
2824 ha->flags.online = 0; 2842 ha->flags.online = 0;
2825 clear_bit(ISP_ABORT_RETRY, 2843 clear_bit(ISP_ABORT_RETRY,
2826 &ha->dpc_flags); 2844 &ha->dpc_flags);
@@ -2877,7 +2895,7 @@ qla2x00_restart_isp(scsi_qla_host_t *ha)
2877 /* If firmware needs to be loaded */ 2895 /* If firmware needs to be loaded */
2878 if (qla2x00_isp_firmware(ha)) { 2896 if (qla2x00_isp_firmware(ha)) {
2879 ha->flags.online = 0; 2897 ha->flags.online = 0;
2880 if (!(status = qla2x00_chip_diag(ha))) { 2898 if (!(status = ha->isp_ops.chip_diag(ha))) {
2881 if (IS_QLA2100(ha) || IS_QLA2200(ha)) { 2899 if (IS_QLA2100(ha) || IS_QLA2200(ha)) {
2882 status = qla2x00_setup_chip(ha); 2900 status = qla2x00_setup_chip(ha);
2883 goto done; 2901 goto done;
@@ -2951,14 +2969,14 @@ qla2x00_restart_isp(scsi_qla_host_t *ha)
2951* Input: 2969* Input:
2952* ha = adapter block pointer. 2970* ha = adapter block pointer.
2953*/ 2971*/
2954static void 2972void
2955qla2x00_reset_adapter(scsi_qla_host_t *ha) 2973qla2x00_reset_adapter(scsi_qla_host_t *ha)
2956{ 2974{
2957 unsigned long flags = 0; 2975 unsigned long flags = 0;
2958 device_reg_t __iomem *reg = ha->iobase; 2976 device_reg_t __iomem *reg = ha->iobase;
2959 2977
2960 ha->flags.online = 0; 2978 ha->flags.online = 0;
2961 qla2x00_disable_intrs(ha); 2979 ha->isp_ops.disable_intrs(ha);
2962 2980
2963 /* Reset RISC processor. */ 2981 /* Reset RISC processor. */
2964 spin_lock_irqsave(&ha->hardware_lock, flags); 2982 spin_lock_irqsave(&ha->hardware_lock, flags);
diff --git a/drivers/scsi/qla2xxx/qla_inline.h b/drivers/scsi/qla2xxx/qla_inline.h
index 6a05d1b8d48a..8f99febc15db 100644
--- a/drivers/scsi/qla2xxx/qla_inline.h
+++ b/drivers/scsi/qla2xxx/qla_inline.h
@@ -117,46 +117,9 @@ static __inline__ void qla2x00_poll(scsi_qla_host_t *);
117static inline void 117static inline void
118qla2x00_poll(scsi_qla_host_t *ha) 118qla2x00_poll(scsi_qla_host_t *ha)
119{ 119{
120 if (IS_QLA2100(ha) || IS_QLA2200(ha)) 120 ha->isp_ops.intr_handler(0, ha, NULL);
121 qla2100_intr_handler(0, ha, NULL);
122 else
123 qla2300_intr_handler(0, ha, NULL);
124} 121}
125 122
126
127static __inline__ void qla2x00_enable_intrs(scsi_qla_host_t *);
128static __inline__ void qla2x00_disable_intrs(scsi_qla_host_t *);
129
130static inline void
131qla2x00_enable_intrs(scsi_qla_host_t *ha)
132{
133 unsigned long flags = 0;
134 device_reg_t __iomem *reg = ha->iobase;
135
136 spin_lock_irqsave(&ha->hardware_lock, flags);
137 ha->interrupts_on = 1;
138 /* enable risc and host interrupts */
139 WRT_REG_WORD(&reg->ictrl, ICR_EN_INT | ICR_EN_RISC);
140 RD_REG_WORD(&reg->ictrl);
141 spin_unlock_irqrestore(&ha->hardware_lock, flags);
142
143}
144
145static inline void
146qla2x00_disable_intrs(scsi_qla_host_t *ha)
147{
148 unsigned long flags = 0;
149 device_reg_t __iomem *reg = ha->iobase;
150
151 spin_lock_irqsave(&ha->hardware_lock, flags);
152 ha->interrupts_on = 0;
153 /* disable risc and host interrupts */
154 WRT_REG_WORD(&reg->ictrl, 0);
155 RD_REG_WORD(&reg->ictrl);
156 spin_unlock_irqrestore(&ha->hardware_lock, flags);
157}
158
159
160static __inline__ int qla2x00_is_wwn_zero(uint8_t *); 123static __inline__ int qla2x00_is_wwn_zero(uint8_t *);
161 124
162/* 125/*
diff --git a/drivers/scsi/qla2xxx/qla_iocb.c b/drivers/scsi/qla2xxx/qla_iocb.c
index ecaf9f83b2d4..5e079b5d9392 100644
--- a/drivers/scsi/qla2xxx/qla_iocb.c
+++ b/drivers/scsi/qla2xxx/qla_iocb.c
@@ -369,7 +369,7 @@ qla2x00_start_scsi(srb_t *sp)
369 } 369 }
370 370
371 /* Calculate the number of request entries needed. */ 371 /* Calculate the number of request entries needed. */
372 req_cnt = (ha->calc_request_entries)(tot_dsds); 372 req_cnt = ha->isp_ops.calc_req_entries(tot_dsds);
373 if (ha->req_q_cnt < (req_cnt + 2)) { 373 if (ha->req_q_cnt < (req_cnt + 2)) {
374 cnt = RD_REG_WORD_RELAXED(ISP_REQ_Q_OUT(ha, reg)); 374 cnt = RD_REG_WORD_RELAXED(ISP_REQ_Q_OUT(ha, reg));
375 if (ha->req_ring_index < cnt) 375 if (ha->req_ring_index < cnt)
@@ -419,7 +419,7 @@ qla2x00_start_scsi(srb_t *sp)
419 cmd_pkt->byte_count = cpu_to_le32((uint32_t)cmd->request_bufflen); 419 cmd_pkt->byte_count = cpu_to_le32((uint32_t)cmd->request_bufflen);
420 420
421 /* Build IOCB segments */ 421 /* Build IOCB segments */
422 (ha->build_scsi_iocbs)(sp, cmd_pkt, tot_dsds); 422 ha->isp_ops.build_iocbs(sp, cmd_pkt, tot_dsds);
423 423
424 /* Set total data segment count. */ 424 /* Set total data segment count. */
425 cmd_pkt->entry_count = (uint8_t)req_cnt; 425 cmd_pkt->entry_count = (uint8_t)req_cnt;
diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c
index e7a8b74157a5..117b56242ee2 100644
--- a/drivers/scsi/qla2xxx/qla_isr.c
+++ b/drivers/scsi/qla2xxx/qla_isr.c
@@ -356,10 +356,7 @@ qla2x00_async_event(scsi_qla_host_t *ha, uint32_t mbx)
356 "ISP System Error - mbx1=%xh mbx2=%xh mbx3=%xh.\n", 356 "ISP System Error - mbx1=%xh mbx2=%xh mbx3=%xh.\n",
357 mb[1], mb[2], mb[3]); 357 mb[1], mb[2], mb[3]);
358 358
359 if (IS_QLA2100(ha) || IS_QLA2200(ha)) 359 ha->isp_ops.fw_dump(ha, 1);
360 qla2100_fw_dump(ha, 1);
361 else
362 qla2300_fw_dump(ha, 1);
363 360
364 if (mb[1] == 0) { 361 if (mb[1] == 0) {
365 qla_printk(KERN_INFO, ha, 362 qla_printk(KERN_INFO, ha,
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c
index 0b12498b7672..549122dc68e6 100644
--- a/drivers/scsi/qla2xxx/qla_os.c
+++ b/drivers/scsi/qla2xxx/qla_os.c
@@ -178,7 +178,7 @@ void qla2x00_sp_compl(scsi_qla_host_t *ha, srb_t *);
178/* -------------------------------------------------------------------------- */ 178/* -------------------------------------------------------------------------- */
179 179
180static char * 180static char *
181qla2x00_get_pci_info_str(struct scsi_qla_host *ha, char *str) 181qla2x00_pci_info_str(struct scsi_qla_host *ha, char *str)
182{ 182{
183 static char *pci_bus_modes[] = { 183 static char *pci_bus_modes[] = {
184 "33", "66", "100", "133", 184 "33", "66", "100", "133",
@@ -201,7 +201,7 @@ qla2x00_get_pci_info_str(struct scsi_qla_host *ha, char *str)
201} 201}
202 202
203char * 203char *
204qla2x00_get_fw_version_str(struct scsi_qla_host *ha, char *str) 204qla2x00_fw_version_str(struct scsi_qla_host *ha, char *str)
205{ 205{
206 char un_str[10]; 206 char un_str[10];
207 207
@@ -493,7 +493,7 @@ qla2xxx_eh_abort(struct scsi_cmnd *cmd)
493 DEBUG3(qla2x00_print_scsi_cmd(cmd);) 493 DEBUG3(qla2x00_print_scsi_cmd(cmd);)
494 494
495 spin_unlock_irqrestore(&ha->hardware_lock, flags); 495 spin_unlock_irqrestore(&ha->hardware_lock, flags);
496 if (qla2x00_abort_command(ha, sp)) { 496 if (ha->isp_ops.abort_command(ha, sp)) {
497 DEBUG2(printk("%s(%ld): abort_command " 497 DEBUG2(printk("%s(%ld): abort_command "
498 "mbx failed.\n", __func__, ha->host_no)); 498 "mbx failed.\n", __func__, ha->host_no));
499 } else { 499 } else {
@@ -624,7 +624,7 @@ qla2xxx_eh_device_reset(struct scsi_cmnd *cmd)
624#if defined(LOGOUT_AFTER_DEVICE_RESET) 624#if defined(LOGOUT_AFTER_DEVICE_RESET)
625 if (ret == SUCCESS) { 625 if (ret == SUCCESS) {
626 if (fcport->flags & FC_FABRIC_DEVICE) { 626 if (fcport->flags & FC_FABRIC_DEVICE) {
627 qla2x00_fabric_logout(ha, fcport->loop_id); 627 ha->isp_ops.fabric_logout(ha, fcport->loop_id);
628 qla2x00_mark_device_lost(ha, fcport); 628 qla2x00_mark_device_lost(ha, fcport);
629 } 629 }
630 } 630 }
@@ -925,7 +925,7 @@ static int
925qla2x00_device_reset(scsi_qla_host_t *ha, fc_port_t *reset_fcport) 925qla2x00_device_reset(scsi_qla_host_t *ha, fc_port_t *reset_fcport)
926{ 926{
927 /* Abort Target command will clear Reservation */ 927 /* Abort Target command will clear Reservation */
928 return qla2x00_abort_target(reset_fcport); 928 return ha->isp_ops.abort_target(reset_fcport);
929} 929}
930 930
931static int 931static int
@@ -989,8 +989,6 @@ qla2x00_config_dma_addressing(scsi_qla_host_t *ha)
989{ 989{
990 /* Assume 32bit DMA address */ 990 /* Assume 32bit DMA address */
991 ha->flags.enable_64bit_addressing = 0; 991 ha->flags.enable_64bit_addressing = 0;
992 ha->calc_request_entries = qla2x00_calc_iocbs_32;
993 ha->build_scsi_iocbs = qla2x00_build_scsi_iocbs_32;
994 992
995 /* 993 /*
996 * Given the two variants pci_set_dma_mask(), allow the compiler to 994 * Given the two variants pci_set_dma_mask(), allow the compiler to
@@ -999,8 +997,8 @@ qla2x00_config_dma_addressing(scsi_qla_host_t *ha)
999 if (sizeof(dma_addr_t) > 4) { 997 if (sizeof(dma_addr_t) > 4) {
1000 if (pci_set_dma_mask(ha->pdev, DMA_64BIT_MASK) == 0) { 998 if (pci_set_dma_mask(ha->pdev, DMA_64BIT_MASK) == 0) {
1001 ha->flags.enable_64bit_addressing = 1; 999 ha->flags.enable_64bit_addressing = 1;
1002 ha->calc_request_entries = qla2x00_calc_iocbs_64; 1000 ha->isp_ops.calc_req_entries = qla2x00_calc_iocbs_64;
1003 ha->build_scsi_iocbs = qla2x00_build_scsi_iocbs_64; 1001 ha->isp_ops.build_iocbs = qla2x00_build_scsi_iocbs_64;
1004 1002
1005 if (pci_set_consistent_dma_mask(ha->pdev, 1003 if (pci_set_consistent_dma_mask(ha->pdev,
1006 DMA_64BIT_MASK)) { 1004 DMA_64BIT_MASK)) {
@@ -1087,6 +1085,35 @@ iospace_error_exit:
1087 return (-ENOMEM); 1085 return (-ENOMEM);
1088} 1086}
1089 1087
1088static void
1089qla2x00_enable_intrs(scsi_qla_host_t *ha)
1090{
1091 unsigned long flags = 0;
1092 device_reg_t __iomem *reg = ha->iobase;
1093
1094 spin_lock_irqsave(&ha->hardware_lock, flags);
1095 ha->interrupts_on = 1;
1096 /* enable risc and host interrupts */
1097 WRT_REG_WORD(&reg->ictrl, ICR_EN_INT | ICR_EN_RISC);
1098 RD_REG_WORD(&reg->ictrl);
1099 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1100
1101}
1102
1103static void
1104qla2x00_disable_intrs(scsi_qla_host_t *ha)
1105{
1106 unsigned long flags = 0;
1107 device_reg_t __iomem *reg = ha->iobase;
1108
1109 spin_lock_irqsave(&ha->hardware_lock, flags);
1110 ha->interrupts_on = 0;
1111 /* disable risc and host interrupts */
1112 WRT_REG_WORD(&reg->ictrl, 0);
1113 RD_REG_WORD(&reg->ictrl);
1114 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1115}
1116
1090/* 1117/*
1091 * PCI driver interface 1118 * PCI driver interface
1092 */ 1119 */
@@ -1140,6 +1167,28 @@ int qla2x00_probe_one(struct pci_dev *pdev, struct qla_board_info *brd_info)
1140 ha->prev_topology = 0; 1167 ha->prev_topology = 0;
1141 ha->ports = MAX_BUSES; 1168 ha->ports = MAX_BUSES;
1142 1169
1170 /* Assign ISP specific operations. */
1171 ha->isp_ops.pci_config = qla2100_pci_config;
1172 ha->isp_ops.reset_chip = qla2x00_reset_chip;
1173 ha->isp_ops.chip_diag = qla2x00_chip_diag;
1174 ha->isp_ops.config_rings = qla2x00_config_rings;
1175 ha->isp_ops.reset_adapter = qla2x00_reset_adapter;
1176 ha->isp_ops.nvram_config = qla2x00_nvram_config;
1177 ha->isp_ops.update_fw_options = qla2x00_update_fw_options;
1178 ha->isp_ops.pci_info_str = qla2x00_pci_info_str;
1179 ha->isp_ops.fw_version_str = qla2x00_fw_version_str;
1180 ha->isp_ops.intr_handler = qla2100_intr_handler;
1181 ha->isp_ops.enable_intrs = qla2x00_enable_intrs;
1182 ha->isp_ops.disable_intrs = qla2x00_disable_intrs;
1183 ha->isp_ops.abort_command = qla2x00_abort_command;
1184 ha->isp_ops.abort_target = qla2x00_abort_target;
1185 ha->isp_ops.fabric_login = qla2x00_login_fabric;
1186 ha->isp_ops.fabric_logout = qla2x00_fabric_logout;
1187 ha->isp_ops.calc_req_entries = qla2x00_calc_iocbs_32;
1188 ha->isp_ops.build_iocbs = qla2x00_build_scsi_iocbs_32;
1189 ha->isp_ops.prep_ms_iocb = qla2x00_prep_ms_iocb;
1190 ha->isp_ops.fw_dump = qla2100_fw_dump;
1191 ha->isp_ops.ascii_fw_dump = qla2100_ascii_fw_dump;
1143 if (IS_QLA2100(ha)) { 1192 if (IS_QLA2100(ha)) {
1144 host->max_id = MAX_TARGETS_2100; 1193 host->max_id = MAX_TARGETS_2100;
1145 ha->mbx_count = MAILBOX_REGISTER_COUNT_2100; 1194 ha->mbx_count = MAILBOX_REGISTER_COUNT_2100;
@@ -1147,18 +1196,25 @@ int qla2x00_probe_one(struct pci_dev *pdev, struct qla_board_info *brd_info)
1147 ha->response_q_length = RESPONSE_ENTRY_CNT_2100; 1196 ha->response_q_length = RESPONSE_ENTRY_CNT_2100;
1148 ha->last_loop_id = SNS_LAST_LOOP_ID_2100; 1197 ha->last_loop_id = SNS_LAST_LOOP_ID_2100;
1149 host->sg_tablesize = 32; 1198 host->sg_tablesize = 32;
1199 ha->gid_list_info_size = 4;
1150 } else if (IS_QLA2200(ha)) { 1200 } else if (IS_QLA2200(ha)) {
1151 host->max_id = MAX_TARGETS_2200; 1201 host->max_id = MAX_TARGETS_2200;
1152 ha->mbx_count = MAILBOX_REGISTER_COUNT; 1202 ha->mbx_count = MAILBOX_REGISTER_COUNT;
1153 ha->request_q_length = REQUEST_ENTRY_CNT_2200; 1203 ha->request_q_length = REQUEST_ENTRY_CNT_2200;
1154 ha->response_q_length = RESPONSE_ENTRY_CNT_2100; 1204 ha->response_q_length = RESPONSE_ENTRY_CNT_2100;
1155 ha->last_loop_id = SNS_LAST_LOOP_ID_2100; 1205 ha->last_loop_id = SNS_LAST_LOOP_ID_2100;
1206 ha->gid_list_info_size = 4;
1156 } else /*if (IS_QLA2300(ha))*/ { 1207 } else /*if (IS_QLA2300(ha))*/ {
1157 host->max_id = MAX_TARGETS_2200; 1208 host->max_id = MAX_TARGETS_2200;
1158 ha->mbx_count = MAILBOX_REGISTER_COUNT; 1209 ha->mbx_count = MAILBOX_REGISTER_COUNT;
1159 ha->request_q_length = REQUEST_ENTRY_CNT_2200; 1210 ha->request_q_length = REQUEST_ENTRY_CNT_2200;
1160 ha->response_q_length = RESPONSE_ENTRY_CNT_2300; 1211 ha->response_q_length = RESPONSE_ENTRY_CNT_2300;
1161 ha->last_loop_id = SNS_LAST_LOOP_ID_2300; 1212 ha->last_loop_id = SNS_LAST_LOOP_ID_2300;
1213 ha->isp_ops.pci_config = qla2300_pci_config;
1214 ha->isp_ops.intr_handler = qla2300_intr_handler;
1215 ha->isp_ops.fw_dump = qla2300_fw_dump;
1216 ha->isp_ops.ascii_fw_dump = qla2300_ascii_fw_dump;
1217 ha->gid_list_info_size = 6;
1162 } 1218 }
1163 host->can_queue = ha->request_q_length + 128; 1219 host->can_queue = ha->request_q_length + 128;
1164 1220
@@ -1229,12 +1285,8 @@ int qla2x00_probe_one(struct pci_dev *pdev, struct qla_board_info *brd_info)
1229 host->max_lun = MAX_LUNS; 1285 host->max_lun = MAX_LUNS;
1230 host->transportt = qla2xxx_transport_template; 1286 host->transportt = qla2xxx_transport_template;
1231 1287
1232 if (IS_QLA2100(ha) || IS_QLA2200(ha)) 1288 ret = request_irq(host->irq, ha->isp_ops.intr_handler,
1233 ret = request_irq(host->irq, qla2100_intr_handler, 1289 SA_INTERRUPT|SA_SHIRQ, ha->brd_info->drv_name, ha);
1234 SA_INTERRUPT|SA_SHIRQ, ha->brd_info->drv_name, ha);
1235 else
1236 ret = request_irq(host->irq, qla2300_intr_handler,
1237 SA_INTERRUPT|SA_SHIRQ, ha->brd_info->drv_name, ha);
1238 if (ret) { 1290 if (ret) {
1239 qla_printk(KERN_WARNING, ha, 1291 qla_printk(KERN_WARNING, ha,
1240 "Failed to reserve interrupt %d already in use.\n", 1292 "Failed to reserve interrupt %d already in use.\n",
@@ -1250,8 +1302,7 @@ int qla2x00_probe_one(struct pci_dev *pdev, struct qla_board_info *brd_info)
1250 1302
1251 reg = ha->iobase; 1303 reg = ha->iobase;
1252 1304
1253 /* Disable ISP interrupts. */ 1305 ha->isp_ops.disable_intrs(ha);
1254 qla2x00_disable_intrs(ha);
1255 1306
1256 /* Ensure mailbox registers are free. */ 1307 /* Ensure mailbox registers are free. */
1257 spin_lock_irqsave(&ha->hardware_lock, flags); 1308 spin_lock_irqsave(&ha->hardware_lock, flags);
@@ -1270,8 +1321,7 @@ int qla2x00_probe_one(struct pci_dev *pdev, struct qla_board_info *brd_info)
1270 } 1321 }
1271 spin_unlock_irqrestore(&ha->hardware_lock, flags); 1322 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1272 1323
1273 /* Enable chip interrupts. */ 1324 ha->isp_ops.enable_intrs(ha);
1274 qla2x00_enable_intrs(ha);
1275 1325
1276 /* v2.19.5b6 */ 1326 /* v2.19.5b6 */
1277 /* 1327 /*
@@ -1306,9 +1356,9 @@ int qla2x00_probe_one(struct pci_dev *pdev, struct qla_board_info *brd_info)
1306 " QLogic %s - %s\n" 1356 " QLogic %s - %s\n"
1307 " %s: %s @ %s hdma%c, host#=%ld, fw=%s\n", qla2x00_version_str, 1357 " %s: %s @ %s hdma%c, host#=%ld, fw=%s\n", qla2x00_version_str,
1308 ha->model_number, ha->model_desc ? ha->model_desc: "", 1358 ha->model_number, ha->model_desc ? ha->model_desc: "",
1309 ha->brd_info->isp_name, qla2x00_get_pci_info_str(ha, pci_info), 1359 ha->brd_info->isp_name, ha->isp_ops.pci_info_str(ha, pci_info),
1310 pci_name(ha->pdev), ha->flags.enable_64bit_addressing ? '+': '-', 1360 pci_name(ha->pdev), ha->flags.enable_64bit_addressing ? '+': '-',
1311 ha->host_no, qla2x00_get_fw_version_str(ha, fw_str)); 1361 ha->host_no, ha->isp_ops.fw_version_str(ha, fw_str));
1312 1362
1313 /* Go with fc_rport registration. */ 1363 /* Go with fc_rport registration. */
1314 list_for_each_entry(fcport, &ha->fcports, list) 1364 list_for_each_entry(fcport, &ha->fcports, list)
@@ -1362,7 +1412,7 @@ qla2x00_free_device(scsi_qla_host_t *ha)
1362 1412
1363 /* turn-off interrupts on the card */ 1413 /* turn-off interrupts on the card */
1364 if (ha->interrupts_on) 1414 if (ha->interrupts_on)
1365 qla2x00_disable_intrs(ha); 1415 ha->isp_ops.disable_intrs(ha);
1366 1416
1367 /* Disable timer */ 1417 /* Disable timer */
1368 if (ha->timer_active) 1418 if (ha->timer_active)
@@ -1951,9 +2001,8 @@ qla2x00_do_dpc(void *data)
1951 if (fcport->flags & FCF_FABRIC_DEVICE) { 2001 if (fcport->flags & FCF_FABRIC_DEVICE) {
1952 if (fcport->flags & 2002 if (fcport->flags &
1953 FCF_TAPE_PRESENT) 2003 FCF_TAPE_PRESENT)
1954 qla2x00_fabric_logout( 2004 ha->isp_ops.fabric_logout(
1955 ha, 2005 ha, fcport->loop_id);
1956 fcport->loop_id);
1957 status = qla2x00_fabric_login( 2006 status = qla2x00_fabric_login(
1958 ha, fcport, &next_loopid); 2007 ha, fcport, &next_loopid);
1959 } else 2008 } else
@@ -2034,7 +2083,7 @@ qla2x00_do_dpc(void *data)
2034 } 2083 }
2035 2084
2036 if (!ha->interrupts_on) 2085 if (!ha->interrupts_on)
2037 qla2x00_enable_intrs(ha); 2086 ha->isp_ops.enable_intrs(ha);
2038 2087
2039 ha->dpc_active = 0; 2088 ha->dpc_active = 0;
2040 } /* End of while(1) */ 2089 } /* End of while(1) */