Commit | Line | Data |
---|---|---|
1da177e4 | 1 | /* |
fa90c54f AV |
2 | * QLogic Fibre Channel HBA Driver |
3 | * Copyright (c) 2003-2005 QLogic Corporation | |
1da177e4 | 4 | * |
fa90c54f | 5 | * See LICENSE.qla2xxx for copyright and licensing details. |
1da177e4 LT |
6 | */ |
7 | #include "qla_def.h" | |
8 | ||
9 | #include <linux/delay.h> | |
0107109e | 10 | #include <linux/vmalloc.h> |
1da177e4 LT |
11 | |
12 | #include "qla_devtbl.h" | |
13 | ||
14 | /* XXX(hch): this is ugly, but we don't want to pull in exioctl.h */ | |
15 | #ifndef EXT_IS_LUN_BIT_SET | |
16 | #define EXT_IS_LUN_BIT_SET(P,L) \ | |
17 | (((P)->mask[L/8] & (0x80 >> (L%8)))?1:0) | |
18 | #define EXT_SET_LUN_BIT(P,L) \ | |
19 | ((P)->mask[L/8] |= (0x80 >> (L%8))) | |
20 | #endif | |
21 | ||
22 | /* | |
23 | * QLogic ISP2x00 Hardware Support Function Prototypes. | |
24 | */ | |
1da177e4 | 25 | static int qla2x00_isp_firmware(scsi_qla_host_t *); |
1da177e4 LT |
26 | static void qla2x00_resize_request_q(scsi_qla_host_t *); |
27 | static int qla2x00_setup_chip(scsi_qla_host_t *); | |
28 | static void qla2x00_init_response_q_entries(scsi_qla_host_t *); | |
29 | static int qla2x00_init_rings(scsi_qla_host_t *); | |
30 | static int qla2x00_fw_ready(scsi_qla_host_t *); | |
31 | static int qla2x00_configure_hba(scsi_qla_host_t *); | |
1da177e4 LT |
32 | static int qla2x00_configure_loop(scsi_qla_host_t *); |
33 | static int qla2x00_configure_local_loop(scsi_qla_host_t *); | |
1da177e4 LT |
34 | static int qla2x00_configure_fabric(scsi_qla_host_t *); |
35 | static int qla2x00_find_all_fabric_devs(scsi_qla_host_t *, struct list_head *); | |
36 | static int qla2x00_device_resync(scsi_qla_host_t *); | |
37 | static int qla2x00_fabric_dev_login(scsi_qla_host_t *, fc_port_t *, | |
38 | uint16_t *); | |
1da177e4 LT |
39 | |
40 | static int qla2x00_restart_isp(scsi_qla_host_t *); | |
1da177e4 | 41 | |
413975a0 AB |
42 | static int qla2x00_find_new_loop_id(scsi_qla_host_t *ha, fc_port_t *dev); |
43 | ||
1da177e4 LT |
44 | /****************************************************************************/ |
45 | /* QLogic ISP2x00 Hardware Support Functions. */ | |
46 | /****************************************************************************/ | |
47 | ||
48 | /* | |
49 | * qla2x00_initialize_adapter | |
50 | * Initialize board. | |
51 | * | |
52 | * Input: | |
53 | * ha = adapter block pointer. | |
54 | * | |
55 | * Returns: | |
56 | * 0 = success | |
57 | */ | |
58 | int | |
59 | qla2x00_initialize_adapter(scsi_qla_host_t *ha) | |
60 | { | |
61 | int rval; | |
1da177e4 LT |
62 | |
63 | /* Clear adapter flags. */ | |
64 | ha->flags.online = 0; | |
65 | ha->flags.reset_active = 0; | |
66 | atomic_set(&ha->loop_down_timer, LOOP_DOWN_TIME); | |
67 | atomic_set(&ha->loop_state, LOOP_DOWN); | |
68 | ha->device_flags = 0; | |
1da177e4 | 69 | ha->dpc_flags = 0; |
1da177e4 LT |
70 | ha->flags.management_server_logged_in = 0; |
71 | ha->marker_needed = 0; | |
72 | ha->mbx_flags = 0; | |
73 | ha->isp_abort_cnt = 0; | |
74 | ha->beacon_blink_led = 0; | |
cca5335c | 75 | set_bit(REGISTER_FDMI_NEEDED, &ha->dpc_flags); |
1da177e4 | 76 | |
0107109e | 77 | qla_printk(KERN_INFO, ha, "Configuring PCI space...\n"); |
abbd8870 | 78 | rval = ha->isp_ops.pci_config(ha); |
1da177e4 LT |
79 | if (rval) { |
80 | DEBUG2(printk("scsi(%ld): Unable to configure PCI space=n", | |
81 | ha->host_no)); | |
82 | return (rval); | |
83 | } | |
84 | ||
abbd8870 | 85 | ha->isp_ops.reset_chip(ha); |
1da177e4 | 86 | |
1da177e4 | 87 | qla_printk(KERN_INFO, ha, "Configure NVRAM parameters...\n"); |
0107109e | 88 | |
abbd8870 | 89 | ha->isp_ops.nvram_config(ha); |
1da177e4 | 90 | |
d4c760c2 AV |
91 | if (ha->flags.disable_serdes) { |
92 | /* Mask HBA via NVRAM settings? */ | |
93 | qla_printk(KERN_INFO, ha, "Masking HBA WWPN " | |
94 | "%02x%02x%02x%02x%02x%02x%02x%02x (via NVRAM).\n", | |
95 | ha->port_name[0], ha->port_name[1], | |
96 | ha->port_name[2], ha->port_name[3], | |
97 | ha->port_name[4], ha->port_name[5], | |
98 | ha->port_name[6], ha->port_name[7]); | |
99 | return QLA_FUNCTION_FAILED; | |
100 | } | |
101 | ||
1da177e4 LT |
102 | qla_printk(KERN_INFO, ha, "Verifying loaded RISC code...\n"); |
103 | ||
d19044c3 AV |
104 | if (qla2x00_isp_firmware(ha) != QLA_SUCCESS) { |
105 | rval = ha->isp_ops.chip_diag(ha); | |
106 | if (rval) | |
107 | return (rval); | |
108 | rval = qla2x00_setup_chip(ha); | |
109 | if (rval) | |
110 | return (rval); | |
1da177e4 | 111 | } |
d19044c3 | 112 | rval = qla2x00_init_rings(ha); |
1da177e4 LT |
113 | |
114 | return (rval); | |
115 | } | |
116 | ||
117 | /** | |
abbd8870 | 118 | * qla2100_pci_config() - Setup ISP21xx PCI configuration registers. |
1da177e4 LT |
119 | * @ha: HA context |
120 | * | |
121 | * Returns 0 on success. | |
122 | */ | |
abbd8870 AV |
123 | int |
124 | qla2100_pci_config(scsi_qla_host_t *ha) | |
1da177e4 | 125 | { |
abbd8870 | 126 | uint16_t w, mwi; |
27b2f679 | 127 | uint32_t d; |
abbd8870 | 128 | unsigned long flags; |
3d71644c | 129 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
1da177e4 | 130 | |
1da177e4 LT |
131 | pci_set_master(ha->pdev); |
132 | mwi = 0; | |
133 | if (pci_set_mwi(ha->pdev)) | |
134 | mwi = PCI_COMMAND_INVALIDATE; | |
1da177e4 | 135 | |
1da177e4 LT |
136 | pci_read_config_word(ha->pdev, PCI_COMMAND, &w); |
137 | w |= mwi | (PCI_COMMAND_PARITY | PCI_COMMAND_SERR); | |
abbd8870 AV |
138 | pci_write_config_word(ha->pdev, PCI_COMMAND, w); |
139 | ||
140 | /* Reset expansion ROM address decode enable */ | |
27b2f679 AK |
141 | pci_read_config_dword(ha->pdev, PCI_ROM_ADDRESS, &d); |
142 | d &= ~PCI_ROM_ADDRESS_ENABLE; | |
143 | pci_write_config_dword(ha->pdev, PCI_ROM_ADDRESS, d); | |
1da177e4 LT |
144 | |
145 | /* Get PCI bus information. */ | |
146 | spin_lock_irqsave(&ha->hardware_lock, flags); | |
3d71644c | 147 | ha->pci_attr = RD_REG_WORD(®->ctrl_status); |
1da177e4 LT |
148 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
149 | ||
abbd8870 AV |
150 | return QLA_SUCCESS; |
151 | } | |
1da177e4 | 152 | |
abbd8870 AV |
153 | /** |
154 | * qla2300_pci_config() - Setup ISP23xx PCI configuration registers. | |
155 | * @ha: HA context | |
156 | * | |
157 | * Returns 0 on success. | |
158 | */ | |
159 | int | |
160 | qla2300_pci_config(scsi_qla_host_t *ha) | |
161 | { | |
162 | uint16_t w, mwi; | |
27b2f679 | 163 | uint32_t d; |
abbd8870 AV |
164 | unsigned long flags = 0; |
165 | uint32_t cnt; | |
3d71644c | 166 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
1da177e4 | 167 | |
abbd8870 AV |
168 | pci_set_master(ha->pdev); |
169 | mwi = 0; | |
170 | if (pci_set_mwi(ha->pdev)) | |
171 | mwi = PCI_COMMAND_INVALIDATE; | |
1da177e4 | 172 | |
abbd8870 AV |
173 | pci_read_config_word(ha->pdev, PCI_COMMAND, &w); |
174 | w |= mwi | (PCI_COMMAND_PARITY | PCI_COMMAND_SERR); | |
1da177e4 | 175 | |
abbd8870 AV |
176 | if (IS_QLA2322(ha) || IS_QLA6322(ha)) |
177 | w &= ~PCI_COMMAND_INTX_DISABLE; | |
1da177e4 | 178 | |
abbd8870 AV |
179 | /* |
180 | * If this is a 2300 card and not 2312, reset the | |
181 | * COMMAND_INVALIDATE due to a bug in the 2300. Unfortunately, | |
182 | * the 2310 also reports itself as a 2300 so we need to get the | |
183 | * fb revision level -- a 6 indicates it really is a 2300 and | |
184 | * not a 2310. | |
185 | */ | |
186 | if (IS_QLA2300(ha)) { | |
187 | spin_lock_irqsave(&ha->hardware_lock, flags); | |
1da177e4 | 188 | |
abbd8870 | 189 | /* Pause RISC. */ |
3d71644c | 190 | WRT_REG_WORD(®->hccr, HCCR_PAUSE_RISC); |
abbd8870 | 191 | for (cnt = 0; cnt < 30000; cnt++) { |
3d71644c | 192 | if ((RD_REG_WORD(®->hccr) & HCCR_RISC_PAUSE) != 0) |
abbd8870 | 193 | break; |
1da177e4 | 194 | |
abbd8870 AV |
195 | udelay(10); |
196 | } | |
1da177e4 | 197 | |
abbd8870 | 198 | /* Select FPM registers. */ |
3d71644c AV |
199 | WRT_REG_WORD(®->ctrl_status, 0x20); |
200 | RD_REG_WORD(®->ctrl_status); | |
abbd8870 AV |
201 | |
202 | /* Get the fb rev level */ | |
3d71644c | 203 | ha->fb_rev = RD_FB_CMD_REG(ha, reg); |
abbd8870 AV |
204 | |
205 | if (ha->fb_rev == FPM_2300) | |
206 | w &= ~PCI_COMMAND_INVALIDATE; | |
207 | ||
208 | /* Deselect FPM registers. */ | |
3d71644c AV |
209 | WRT_REG_WORD(®->ctrl_status, 0x0); |
210 | RD_REG_WORD(®->ctrl_status); | |
abbd8870 AV |
211 | |
212 | /* Release RISC module. */ | |
3d71644c | 213 | WRT_REG_WORD(®->hccr, HCCR_RELEASE_RISC); |
abbd8870 | 214 | for (cnt = 0; cnt < 30000; cnt++) { |
3d71644c | 215 | if ((RD_REG_WORD(®->hccr) & HCCR_RISC_PAUSE) == 0) |
abbd8870 AV |
216 | break; |
217 | ||
218 | udelay(10); | |
1da177e4 | 219 | } |
1da177e4 | 220 | |
abbd8870 AV |
221 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
222 | } | |
1da177e4 LT |
223 | pci_write_config_word(ha->pdev, PCI_COMMAND, w); |
224 | ||
abbd8870 AV |
225 | pci_write_config_byte(ha->pdev, PCI_LATENCY_TIMER, 0x80); |
226 | ||
1da177e4 | 227 | /* Reset expansion ROM address decode enable */ |
27b2f679 AK |
228 | pci_read_config_dword(ha->pdev, PCI_ROM_ADDRESS, &d); |
229 | d &= ~PCI_ROM_ADDRESS_ENABLE; | |
230 | pci_write_config_dword(ha->pdev, PCI_ROM_ADDRESS, d); | |
1da177e4 | 231 | |
abbd8870 AV |
232 | /* Get PCI bus information. */ |
233 | spin_lock_irqsave(&ha->hardware_lock, flags); | |
3d71644c | 234 | ha->pci_attr = RD_REG_WORD(®->ctrl_status); |
abbd8870 AV |
235 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
236 | ||
237 | return QLA_SUCCESS; | |
1da177e4 LT |
238 | } |
239 | ||
0107109e AV |
240 | /** |
241 | * qla24xx_pci_config() - Setup ISP24xx PCI configuration registers. | |
242 | * @ha: HA context | |
243 | * | |
244 | * Returns 0 on success. | |
245 | */ | |
246 | int | |
247 | qla24xx_pci_config(scsi_qla_host_t *ha) | |
248 | { | |
249 | uint16_t w, mwi; | |
27b2f679 | 250 | uint32_t d; |
0107109e AV |
251 | unsigned long flags = 0; |
252 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; | |
253 | int pcix_cmd_reg, pcie_dctl_reg; | |
254 | ||
255 | pci_set_master(ha->pdev); | |
256 | mwi = 0; | |
257 | if (pci_set_mwi(ha->pdev)) | |
258 | mwi = PCI_COMMAND_INVALIDATE; | |
0107109e AV |
259 | |
260 | pci_read_config_word(ha->pdev, PCI_COMMAND, &w); | |
261 | w |= mwi | (PCI_COMMAND_PARITY | PCI_COMMAND_SERR); | |
262 | w &= ~PCI_COMMAND_INTX_DISABLE; | |
263 | pci_write_config_word(ha->pdev, PCI_COMMAND, w); | |
264 | ||
265 | pci_write_config_byte(ha->pdev, PCI_LATENCY_TIMER, 0x80); | |
266 | ||
267 | /* PCI-X -- adjust Maximum Memory Read Byte Count (2048). */ | |
268 | pcix_cmd_reg = pci_find_capability(ha->pdev, PCI_CAP_ID_PCIX); | |
269 | if (pcix_cmd_reg) { | |
270 | uint16_t pcix_cmd; | |
271 | ||
272 | pcix_cmd_reg += PCI_X_CMD; | |
273 | pci_read_config_word(ha->pdev, pcix_cmd_reg, &pcix_cmd); | |
274 | pcix_cmd &= ~PCI_X_CMD_MAX_READ; | |
275 | pcix_cmd |= 0x0008; | |
276 | pci_write_config_word(ha->pdev, pcix_cmd_reg, pcix_cmd); | |
277 | } | |
278 | ||
279 | /* PCIe -- adjust Maximum Read Request Size (2048). */ | |
280 | pcie_dctl_reg = pci_find_capability(ha->pdev, PCI_CAP_ID_EXP); | |
281 | if (pcie_dctl_reg) { | |
282 | uint16_t pcie_dctl; | |
283 | ||
284 | pcie_dctl_reg += PCI_EXP_DEVCTL; | |
285 | pci_read_config_word(ha->pdev, pcie_dctl_reg, &pcie_dctl); | |
286 | pcie_dctl &= ~PCI_EXP_DEVCTL_READRQ; | |
287 | pcie_dctl |= 0x4000; | |
288 | pci_write_config_word(ha->pdev, pcie_dctl_reg, pcie_dctl); | |
289 | } | |
290 | ||
291 | /* Reset expansion ROM address decode enable */ | |
27b2f679 AK |
292 | pci_read_config_dword(ha->pdev, PCI_ROM_ADDRESS, &d); |
293 | d &= ~PCI_ROM_ADDRESS_ENABLE; | |
294 | pci_write_config_dword(ha->pdev, PCI_ROM_ADDRESS, d); | |
0107109e | 295 | |
a8488abe AV |
296 | pci_read_config_word(ha->pdev, PCI_REVISION_ID, &ha->chip_revision); |
297 | ||
0107109e AV |
298 | /* Get PCI bus information. */ |
299 | spin_lock_irqsave(&ha->hardware_lock, flags); | |
300 | ha->pci_attr = RD_REG_DWORD(®->ctrl_status); | |
301 | spin_unlock_irqrestore(&ha->hardware_lock, flags); | |
302 | ||
303 | return QLA_SUCCESS; | |
304 | } | |
305 | ||
1da177e4 LT |
306 | /** |
307 | * qla2x00_isp_firmware() - Choose firmware image. | |
308 | * @ha: HA context | |
309 | * | |
310 | * Returns 0 on success. | |
311 | */ | |
312 | static int | |
313 | qla2x00_isp_firmware(scsi_qla_host_t *ha) | |
314 | { | |
315 | int rval; | |
316 | ||
317 | /* Assume loading risc code */ | |
fa2a1ce5 | 318 | rval = QLA_FUNCTION_FAILED; |
1da177e4 LT |
319 | |
320 | if (ha->flags.disable_risc_code_load) { | |
321 | DEBUG2(printk("scsi(%ld): RISC CODE NOT loaded\n", | |
322 | ha->host_no)); | |
323 | qla_printk(KERN_INFO, ha, "RISC CODE NOT loaded\n"); | |
324 | ||
325 | /* Verify checksum of loaded RISC code. */ | |
441d1072 | 326 | rval = qla2x00_verify_checksum(ha, ha->fw_srisc_address); |
1da177e4 LT |
327 | } |
328 | ||
329 | if (rval) { | |
330 | DEBUG2_3(printk("scsi(%ld): **** Load RISC code ****\n", | |
331 | ha->host_no)); | |
332 | } | |
333 | ||
334 | return (rval); | |
335 | } | |
336 | ||
337 | /** | |
338 | * qla2x00_reset_chip() - Reset ISP chip. | |
339 | * @ha: HA context | |
340 | * | |
341 | * Returns 0 on success. | |
342 | */ | |
abbd8870 | 343 | void |
fa2a1ce5 | 344 | qla2x00_reset_chip(scsi_qla_host_t *ha) |
1da177e4 LT |
345 | { |
346 | unsigned long flags = 0; | |
3d71644c | 347 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
1da177e4 | 348 | uint32_t cnt; |
1da177e4 LT |
349 | uint16_t cmd; |
350 | ||
abbd8870 | 351 | ha->isp_ops.disable_intrs(ha); |
1da177e4 LT |
352 | |
353 | spin_lock_irqsave(&ha->hardware_lock, flags); | |
354 | ||
355 | /* Turn off master enable */ | |
356 | cmd = 0; | |
357 | pci_read_config_word(ha->pdev, PCI_COMMAND, &cmd); | |
358 | cmd &= ~PCI_COMMAND_MASTER; | |
359 | pci_write_config_word(ha->pdev, PCI_COMMAND, cmd); | |
360 | ||
361 | if (!IS_QLA2100(ha)) { | |
362 | /* Pause RISC. */ | |
363 | WRT_REG_WORD(®->hccr, HCCR_PAUSE_RISC); | |
364 | if (IS_QLA2200(ha) || IS_QLA2300(ha)) { | |
365 | for (cnt = 0; cnt < 30000; cnt++) { | |
366 | if ((RD_REG_WORD(®->hccr) & | |
367 | HCCR_RISC_PAUSE) != 0) | |
368 | break; | |
369 | udelay(100); | |
370 | } | |
371 | } else { | |
372 | RD_REG_WORD(®->hccr); /* PCI Posting. */ | |
373 | udelay(10); | |
374 | } | |
375 | ||
376 | /* Select FPM registers. */ | |
377 | WRT_REG_WORD(®->ctrl_status, 0x20); | |
378 | RD_REG_WORD(®->ctrl_status); /* PCI Posting. */ | |
379 | ||
380 | /* FPM Soft Reset. */ | |
381 | WRT_REG_WORD(®->fpm_diag_config, 0x100); | |
382 | RD_REG_WORD(®->fpm_diag_config); /* PCI Posting. */ | |
383 | ||
384 | /* Toggle Fpm Reset. */ | |
385 | if (!IS_QLA2200(ha)) { | |
386 | WRT_REG_WORD(®->fpm_diag_config, 0x0); | |
387 | RD_REG_WORD(®->fpm_diag_config); /* PCI Posting. */ | |
388 | } | |
389 | ||
390 | /* Select frame buffer registers. */ | |
391 | WRT_REG_WORD(®->ctrl_status, 0x10); | |
392 | RD_REG_WORD(®->ctrl_status); /* PCI Posting. */ | |
393 | ||
394 | /* Reset frame buffer FIFOs. */ | |
395 | if (IS_QLA2200(ha)) { | |
396 | WRT_FB_CMD_REG(ha, reg, 0xa000); | |
397 | RD_FB_CMD_REG(ha, reg); /* PCI Posting. */ | |
398 | } else { | |
399 | WRT_FB_CMD_REG(ha, reg, 0x00fc); | |
400 | ||
401 | /* Read back fb_cmd until zero or 3 seconds max */ | |
402 | for (cnt = 0; cnt < 3000; cnt++) { | |
403 | if ((RD_FB_CMD_REG(ha, reg) & 0xff) == 0) | |
404 | break; | |
405 | udelay(100); | |
406 | } | |
407 | } | |
408 | ||
409 | /* Select RISC module registers. */ | |
410 | WRT_REG_WORD(®->ctrl_status, 0); | |
411 | RD_REG_WORD(®->ctrl_status); /* PCI Posting. */ | |
412 | ||
413 | /* Reset RISC processor. */ | |
414 | WRT_REG_WORD(®->hccr, HCCR_RESET_RISC); | |
415 | RD_REG_WORD(®->hccr); /* PCI Posting. */ | |
416 | ||
417 | /* Release RISC processor. */ | |
418 | WRT_REG_WORD(®->hccr, HCCR_RELEASE_RISC); | |
419 | RD_REG_WORD(®->hccr); /* PCI Posting. */ | |
420 | } | |
421 | ||
422 | WRT_REG_WORD(®->hccr, HCCR_CLR_RISC_INT); | |
423 | WRT_REG_WORD(®->hccr, HCCR_CLR_HOST_INT); | |
424 | ||
425 | /* Reset ISP chip. */ | |
426 | WRT_REG_WORD(®->ctrl_status, CSR_ISP_SOFT_RESET); | |
427 | ||
428 | /* Wait for RISC to recover from reset. */ | |
429 | if (IS_QLA2100(ha) || IS_QLA2200(ha) || IS_QLA2300(ha)) { | |
430 | /* | |
431 | * It is necessary to for a delay here since the card doesn't | |
432 | * respond to PCI reads during a reset. On some architectures | |
433 | * this will result in an MCA. | |
434 | */ | |
435 | udelay(20); | |
436 | for (cnt = 30000; cnt; cnt--) { | |
437 | if ((RD_REG_WORD(®->ctrl_status) & | |
438 | CSR_ISP_SOFT_RESET) == 0) | |
439 | break; | |
440 | udelay(100); | |
441 | } | |
442 | } else | |
443 | udelay(10); | |
444 | ||
445 | /* Reset RISC processor. */ | |
446 | WRT_REG_WORD(®->hccr, HCCR_RESET_RISC); | |
447 | ||
448 | WRT_REG_WORD(®->semaphore, 0); | |
449 | ||
450 | /* Release RISC processor. */ | |
451 | WRT_REG_WORD(®->hccr, HCCR_RELEASE_RISC); | |
452 | RD_REG_WORD(®->hccr); /* PCI Posting. */ | |
453 | ||
454 | if (IS_QLA2100(ha) || IS_QLA2200(ha) || IS_QLA2300(ha)) { | |
455 | for (cnt = 0; cnt < 30000; cnt++) { | |
ffb39f03 | 456 | if (RD_MAILBOX_REG(ha, reg, 0) != MBS_BUSY) |
1da177e4 | 457 | break; |
1da177e4 LT |
458 | |
459 | udelay(100); | |
460 | } | |
461 | } else | |
462 | udelay(100); | |
463 | ||
464 | /* Turn on master enable */ | |
465 | cmd |= PCI_COMMAND_MASTER; | |
466 | pci_write_config_word(ha->pdev, PCI_COMMAND, cmd); | |
467 | ||
468 | /* Disable RISC pause on FPM parity error. */ | |
469 | if (!IS_QLA2100(ha)) { | |
470 | WRT_REG_WORD(®->hccr, HCCR_DISABLE_PARITY_PAUSE); | |
471 | RD_REG_WORD(®->hccr); /* PCI Posting. */ | |
472 | } | |
473 | ||
474 | spin_unlock_irqrestore(&ha->hardware_lock, flags); | |
475 | } | |
476 | ||
0107109e | 477 | /** |
88c26663 | 478 | * qla24xx_reset_risc() - Perform full reset of ISP24xx RISC. |
0107109e AV |
479 | * @ha: HA context |
480 | * | |
481 | * Returns 0 on success. | |
482 | */ | |
88c26663 AV |
483 | static inline void |
484 | qla24xx_reset_risc(scsi_qla_host_t *ha) | |
0107109e AV |
485 | { |
486 | unsigned long flags = 0; | |
487 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; | |
488 | uint32_t cnt, d2; | |
335a1cc9 | 489 | uint16_t wd; |
0107109e | 490 | |
0107109e AV |
491 | spin_lock_irqsave(&ha->hardware_lock, flags); |
492 | ||
493 | /* Reset RISC. */ | |
494 | WRT_REG_DWORD(®->ctrl_status, CSRX_DMA_SHUTDOWN|MWB_4096_BYTES); | |
495 | for (cnt = 0; cnt < 30000; cnt++) { | |
496 | if ((RD_REG_DWORD(®->ctrl_status) & CSRX_DMA_ACTIVE) == 0) | |
497 | break; | |
498 | ||
499 | udelay(10); | |
500 | } | |
501 | ||
502 | WRT_REG_DWORD(®->ctrl_status, | |
503 | CSRX_ISP_SOFT_RESET|CSRX_DMA_SHUTDOWN|MWB_4096_BYTES); | |
335a1cc9 | 504 | pci_read_config_word(ha->pdev, PCI_COMMAND, &wd); |
88c26663 | 505 | |
335a1cc9 | 506 | udelay(100); |
88c26663 | 507 | /* Wait for firmware to complete NVRAM accesses. */ |
88c26663 AV |
508 | d2 = (uint32_t) RD_REG_WORD(®->mailbox0); |
509 | for (cnt = 10000 ; cnt && d2; cnt--) { | |
510 | udelay(5); | |
511 | d2 = (uint32_t) RD_REG_WORD(®->mailbox0); | |
512 | barrier(); | |
513 | } | |
514 | ||
335a1cc9 | 515 | /* Wait for soft-reset to complete. */ |
0107109e AV |
516 | d2 = RD_REG_DWORD(®->ctrl_status); |
517 | for (cnt = 6000000 ; cnt && (d2 & CSRX_ISP_SOFT_RESET); cnt--) { | |
518 | udelay(5); | |
519 | d2 = RD_REG_DWORD(®->ctrl_status); | |
520 | barrier(); | |
521 | } | |
522 | ||
523 | WRT_REG_DWORD(®->hccr, HCCRX_SET_RISC_RESET); | |
524 | RD_REG_DWORD(®->hccr); | |
525 | ||
526 | WRT_REG_DWORD(®->hccr, HCCRX_REL_RISC_PAUSE); | |
527 | RD_REG_DWORD(®->hccr); | |
528 | ||
529 | WRT_REG_DWORD(®->hccr, HCCRX_CLR_RISC_RESET); | |
530 | RD_REG_DWORD(®->hccr); | |
531 | ||
532 | d2 = (uint32_t) RD_REG_WORD(®->mailbox0); | |
533 | for (cnt = 6000000 ; cnt && d2; cnt--) { | |
534 | udelay(5); | |
535 | d2 = (uint32_t) RD_REG_WORD(®->mailbox0); | |
536 | barrier(); | |
537 | } | |
538 | ||
539 | spin_unlock_irqrestore(&ha->hardware_lock, flags); | |
540 | } | |
541 | ||
88c26663 AV |
542 | /** |
543 | * qla24xx_reset_chip() - Reset ISP24xx chip. | |
544 | * @ha: HA context | |
545 | * | |
546 | * Returns 0 on success. | |
547 | */ | |
548 | void | |
549 | qla24xx_reset_chip(scsi_qla_host_t *ha) | |
550 | { | |
551 | ha->isp_ops.disable_intrs(ha); | |
552 | ||
553 | /* Perform RISC reset. */ | |
554 | qla24xx_reset_risc(ha); | |
555 | } | |
556 | ||
1da177e4 LT |
557 | /** |
558 | * qla2x00_chip_diag() - Test chip for proper operation. | |
559 | * @ha: HA context | |
560 | * | |
561 | * Returns 0 on success. | |
562 | */ | |
abbd8870 | 563 | int |
1da177e4 LT |
564 | qla2x00_chip_diag(scsi_qla_host_t *ha) |
565 | { | |
566 | int rval; | |
3d71644c | 567 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
1da177e4 LT |
568 | unsigned long flags = 0; |
569 | uint16_t data; | |
570 | uint32_t cnt; | |
571 | uint16_t mb[5]; | |
572 | ||
573 | /* Assume a failed state */ | |
574 | rval = QLA_FUNCTION_FAILED; | |
575 | ||
576 | DEBUG3(printk("scsi(%ld): Testing device at %lx.\n", | |
577 | ha->host_no, (u_long)®->flash_address)); | |
578 | ||
579 | spin_lock_irqsave(&ha->hardware_lock, flags); | |
580 | ||
581 | /* Reset ISP chip. */ | |
582 | WRT_REG_WORD(®->ctrl_status, CSR_ISP_SOFT_RESET); | |
583 | ||
584 | /* | |
585 | * We need to have a delay here since the card will not respond while | |
586 | * in reset causing an MCA on some architectures. | |
587 | */ | |
588 | udelay(20); | |
589 | data = qla2x00_debounce_register(®->ctrl_status); | |
590 | for (cnt = 6000000 ; cnt && (data & CSR_ISP_SOFT_RESET); cnt--) { | |
591 | udelay(5); | |
592 | data = RD_REG_WORD(®->ctrl_status); | |
593 | barrier(); | |
594 | } | |
595 | ||
596 | if (!cnt) | |
597 | goto chip_diag_failed; | |
598 | ||
599 | DEBUG3(printk("scsi(%ld): Reset register cleared by chip reset\n", | |
600 | ha->host_no)); | |
601 | ||
602 | /* Reset RISC processor. */ | |
603 | WRT_REG_WORD(®->hccr, HCCR_RESET_RISC); | |
604 | WRT_REG_WORD(®->hccr, HCCR_RELEASE_RISC); | |
605 | ||
606 | /* Workaround for QLA2312 PCI parity error */ | |
607 | if (IS_QLA2100(ha) || IS_QLA2200(ha) || IS_QLA2300(ha)) { | |
608 | data = qla2x00_debounce_register(MAILBOX_REG(ha, reg, 0)); | |
609 | for (cnt = 6000000; cnt && (data == MBS_BUSY); cnt--) { | |
610 | udelay(5); | |
611 | data = RD_MAILBOX_REG(ha, reg, 0); | |
fa2a1ce5 | 612 | barrier(); |
1da177e4 LT |
613 | } |
614 | } else | |
615 | udelay(10); | |
616 | ||
617 | if (!cnt) | |
618 | goto chip_diag_failed; | |
619 | ||
620 | /* Check product ID of chip */ | |
621 | DEBUG3(printk("scsi(%ld): Checking product ID of chip\n", ha->host_no)); | |
622 | ||
623 | mb[1] = RD_MAILBOX_REG(ha, reg, 1); | |
624 | mb[2] = RD_MAILBOX_REG(ha, reg, 2); | |
625 | mb[3] = RD_MAILBOX_REG(ha, reg, 3); | |
626 | mb[4] = qla2x00_debounce_register(MAILBOX_REG(ha, reg, 4)); | |
627 | if (mb[1] != PROD_ID_1 || (mb[2] != PROD_ID_2 && mb[2] != PROD_ID_2a) || | |
628 | mb[3] != PROD_ID_3) { | |
629 | qla_printk(KERN_WARNING, ha, | |
630 | "Wrong product ID = 0x%x,0x%x,0x%x\n", mb[1], mb[2], mb[3]); | |
631 | ||
632 | goto chip_diag_failed; | |
633 | } | |
634 | ha->product_id[0] = mb[1]; | |
635 | ha->product_id[1] = mb[2]; | |
636 | ha->product_id[2] = mb[3]; | |
637 | ha->product_id[3] = mb[4]; | |
638 | ||
639 | /* Adjust fw RISC transfer size */ | |
640 | if (ha->request_q_length > 1024) | |
641 | ha->fw_transfer_size = REQUEST_ENTRY_SIZE * 1024; | |
642 | else | |
643 | ha->fw_transfer_size = REQUEST_ENTRY_SIZE * | |
644 | ha->request_q_length; | |
645 | ||
646 | if (IS_QLA2200(ha) && | |
647 | RD_MAILBOX_REG(ha, reg, 7) == QLA2200A_RISC_ROM_VER) { | |
648 | /* Limit firmware transfer size with a 2200A */ | |
649 | DEBUG3(printk("scsi(%ld): Found QLA2200A chip.\n", | |
650 | ha->host_no)); | |
651 | ||
ea5b6382 | 652 | ha->device_type |= DT_ISP2200A; |
1da177e4 LT |
653 | ha->fw_transfer_size = 128; |
654 | } | |
655 | ||
656 | /* Wrap Incoming Mailboxes Test. */ | |
657 | spin_unlock_irqrestore(&ha->hardware_lock, flags); | |
658 | ||
659 | DEBUG3(printk("scsi(%ld): Checking mailboxes.\n", ha->host_no)); | |
660 | rval = qla2x00_mbx_reg_test(ha); | |
661 | if (rval) { | |
662 | DEBUG(printk("scsi(%ld): Failed mailbox send register test\n", | |
663 | ha->host_no)); | |
664 | qla_printk(KERN_WARNING, ha, | |
665 | "Failed mailbox send register test\n"); | |
666 | } | |
667 | else { | |
668 | /* Flag a successful rval */ | |
669 | rval = QLA_SUCCESS; | |
670 | } | |
671 | spin_lock_irqsave(&ha->hardware_lock, flags); | |
672 | ||
673 | chip_diag_failed: | |
674 | if (rval) | |
675 | DEBUG2_3(printk("scsi(%ld): Chip diagnostics **** FAILED " | |
676 | "****\n", ha->host_no)); | |
677 | ||
678 | spin_unlock_irqrestore(&ha->hardware_lock, flags); | |
679 | ||
680 | return (rval); | |
681 | } | |
682 | ||
0107109e AV |
683 | /** |
684 | * qla24xx_chip_diag() - Test ISP24xx for proper operation. | |
685 | * @ha: HA context | |
686 | * | |
687 | * Returns 0 on success. | |
688 | */ | |
689 | int | |
690 | qla24xx_chip_diag(scsi_qla_host_t *ha) | |
691 | { | |
692 | int rval; | |
0107109e | 693 | |
88c26663 AV |
694 | /* Perform RISC reset. */ |
695 | qla24xx_reset_risc(ha); | |
0107109e AV |
696 | |
697 | ha->fw_transfer_size = REQUEST_ENTRY_SIZE * 1024; | |
698 | ||
699 | rval = qla2x00_mbx_reg_test(ha); | |
700 | if (rval) { | |
701 | DEBUG(printk("scsi(%ld): Failed mailbox send register test\n", | |
702 | ha->host_no)); | |
703 | qla_printk(KERN_WARNING, ha, | |
704 | "Failed mailbox send register test\n"); | |
705 | } else { | |
706 | /* Flag a successful rval */ | |
707 | rval = QLA_SUCCESS; | |
708 | } | |
709 | ||
710 | return rval; | |
711 | } | |
712 | ||
a7a167bf | 713 | void |
0107109e AV |
714 | qla2x00_alloc_fw_dump(scsi_qla_host_t *ha) |
715 | { | |
a7a167bf AV |
716 | int rval; |
717 | uint32_t dump_size, fixed_size, mem_size, req_q_size, rsp_q_size, | |
718 | eft_size; | |
719 | dma_addr_t eft_dma; | |
720 | void *eft; | |
721 | ||
722 | if (ha->fw_dump) { | |
723 | qla_printk(KERN_WARNING, ha, | |
724 | "Firmware dump previously allocated.\n"); | |
725 | return; | |
726 | } | |
d4e3e04d | 727 | |
0107109e | 728 | ha->fw_dumped = 0; |
a7a167bf | 729 | fixed_size = mem_size = eft_size = 0; |
d4e3e04d | 730 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) { |
a7a167bf | 731 | fixed_size = sizeof(struct qla2100_fw_dump); |
d4e3e04d | 732 | } else if (IS_QLA23XX(ha)) { |
a7a167bf AV |
733 | fixed_size = offsetof(struct qla2300_fw_dump, data_ram); |
734 | mem_size = (ha->fw_memory_size - 0x11000 + 1) * | |
735 | sizeof(uint16_t); | |
736 | } else if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) { | |
737 | fixed_size = offsetof(struct qla24xx_fw_dump, ext_mem); | |
738 | mem_size = (ha->fw_memory_size - 0x100000 + 1) * | |
739 | sizeof(uint32_t); | |
740 | ||
741 | /* Allocate memory for Extended Trace Buffer. */ | |
742 | eft = dma_alloc_coherent(&ha->pdev->dev, EFT_SIZE, &eft_dma, | |
743 | GFP_KERNEL); | |
744 | if (!eft) { | |
745 | qla_printk(KERN_WARNING, ha, "Unable to allocate " | |
746 | "(%d KB) for EFT.\n", EFT_SIZE / 1024); | |
747 | goto cont_alloc; | |
748 | } | |
749 | ||
750 | rval = qla2x00_trace_control(ha, TC_ENABLE, eft_dma, | |
751 | EFT_NUM_BUFFERS); | |
752 | if (rval) { | |
753 | qla_printk(KERN_WARNING, ha, "Unable to initialize " | |
754 | "EFT (%d).\n", rval); | |
755 | dma_free_coherent(&ha->pdev->dev, EFT_SIZE, eft, | |
756 | eft_dma); | |
757 | goto cont_alloc; | |
758 | } | |
759 | ||
760 | qla_printk(KERN_INFO, ha, "Allocated (%d KB) for EFT...\n", | |
761 | EFT_SIZE / 1024); | |
762 | ||
763 | eft_size = EFT_SIZE; | |
764 | memset(eft, 0, eft_size); | |
765 | ha->eft_dma = eft_dma; | |
766 | ha->eft = eft; | |
d4e3e04d | 767 | } |
a7a167bf AV |
768 | cont_alloc: |
769 | req_q_size = ha->request_q_length * sizeof(request_t); | |
770 | rsp_q_size = ha->response_q_length * sizeof(response_t); | |
771 | ||
772 | dump_size = offsetof(struct qla2xxx_fw_dump, isp); | |
773 | dump_size += fixed_size + mem_size + req_q_size + rsp_q_size + | |
774 | eft_size; | |
d4e3e04d AV |
775 | |
776 | ha->fw_dump = vmalloc(dump_size); | |
a7a167bf | 777 | if (!ha->fw_dump) { |
0107109e | 778 | qla_printk(KERN_WARNING, ha, "Unable to allocate (%d KB) for " |
d4e3e04d | 779 | "firmware dump!!!\n", dump_size / 1024); |
a7a167bf AV |
780 | |
781 | if (ha->eft) { | |
782 | dma_free_coherent(&ha->pdev->dev, eft_size, ha->eft, | |
783 | ha->eft_dma); | |
784 | ha->eft = NULL; | |
785 | ha->eft_dma = 0; | |
786 | } | |
787 | return; | |
788 | } | |
789 | ||
790 | qla_printk(KERN_INFO, ha, "Allocated (%d KB) for firmware dump...\n", | |
791 | dump_size / 1024); | |
792 | ||
793 | ha->fw_dump_len = dump_size; | |
794 | ha->fw_dump->signature[0] = 'Q'; | |
795 | ha->fw_dump->signature[1] = 'L'; | |
796 | ha->fw_dump->signature[2] = 'G'; | |
797 | ha->fw_dump->signature[3] = 'C'; | |
798 | ha->fw_dump->version = __constant_htonl(1); | |
799 | ||
800 | ha->fw_dump->fixed_size = htonl(fixed_size); | |
801 | ha->fw_dump->mem_size = htonl(mem_size); | |
802 | ha->fw_dump->req_q_size = htonl(req_q_size); | |
803 | ha->fw_dump->rsp_q_size = htonl(rsp_q_size); | |
804 | ||
805 | ha->fw_dump->eft_size = htonl(eft_size); | |
806 | ha->fw_dump->eft_addr_l = htonl(LSD(ha->eft_dma)); | |
807 | ha->fw_dump->eft_addr_h = htonl(MSD(ha->eft_dma)); | |
808 | ||
809 | ha->fw_dump->header_size = | |
810 | htonl(offsetof(struct qla2xxx_fw_dump, isp)); | |
0107109e AV |
811 | } |
812 | ||
1da177e4 LT |
813 | /** |
814 | * qla2x00_resize_request_q() - Resize request queue given available ISP memory. | |
815 | * @ha: HA context | |
816 | * | |
817 | * Returns 0 on success. | |
818 | */ | |
819 | static void | |
820 | qla2x00_resize_request_q(scsi_qla_host_t *ha) | |
821 | { | |
822 | int rval; | |
823 | uint16_t fw_iocb_cnt = 0; | |
824 | uint16_t request_q_length = REQUEST_ENTRY_CNT_2XXX_EXT_MEM; | |
825 | dma_addr_t request_dma; | |
826 | request_t *request_ring; | |
827 | ||
828 | /* Valid only on recent ISPs. */ | |
829 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) | |
830 | return; | |
831 | ||
832 | /* Retrieve IOCB counts available to the firmware. */ | |
833 | rval = qla2x00_get_resource_cnts(ha, NULL, NULL, NULL, &fw_iocb_cnt); | |
834 | if (rval) | |
835 | return; | |
836 | /* No point in continuing if current settings are sufficient. */ | |
837 | if (fw_iocb_cnt < 1024) | |
838 | return; | |
839 | if (ha->request_q_length >= request_q_length) | |
840 | return; | |
841 | ||
842 | /* Attempt to claim larger area for request queue. */ | |
843 | request_ring = dma_alloc_coherent(&ha->pdev->dev, | |
844 | (request_q_length + 1) * sizeof(request_t), &request_dma, | |
845 | GFP_KERNEL); | |
846 | if (request_ring == NULL) | |
847 | return; | |
848 | ||
849 | /* Resize successful, report extensions. */ | |
850 | qla_printk(KERN_INFO, ha, "Extended memory detected (%d KB)...\n", | |
851 | (ha->fw_memory_size + 1) / 1024); | |
852 | qla_printk(KERN_INFO, ha, "Resizing request queue depth " | |
853 | "(%d -> %d)...\n", ha->request_q_length, request_q_length); | |
854 | ||
855 | /* Clear old allocations. */ | |
856 | dma_free_coherent(&ha->pdev->dev, | |
857 | (ha->request_q_length + 1) * sizeof(request_t), ha->request_ring, | |
858 | ha->request_dma); | |
859 | ||
860 | /* Begin using larger queue. */ | |
861 | ha->request_q_length = request_q_length; | |
862 | ha->request_ring = request_ring; | |
863 | ha->request_dma = request_dma; | |
864 | } | |
865 | ||
866 | /** | |
867 | * qla2x00_setup_chip() - Load and start RISC firmware. | |
868 | * @ha: HA context | |
869 | * | |
870 | * Returns 0 on success. | |
871 | */ | |
872 | static int | |
873 | qla2x00_setup_chip(scsi_qla_host_t *ha) | |
874 | { | |
0107109e AV |
875 | int rval; |
876 | uint32_t srisc_address = 0; | |
1da177e4 LT |
877 | |
878 | /* Load firmware sequences */ | |
0107109e AV |
879 | rval = ha->isp_ops.load_risc(ha, &srisc_address); |
880 | if (rval == QLA_SUCCESS) { | |
1da177e4 LT |
881 | DEBUG(printk("scsi(%ld): Verifying Checksum of loaded RISC " |
882 | "code.\n", ha->host_no)); | |
883 | ||
0107109e | 884 | rval = qla2x00_verify_checksum(ha, srisc_address); |
1da177e4 LT |
885 | if (rval == QLA_SUCCESS) { |
886 | /* Start firmware execution. */ | |
887 | DEBUG(printk("scsi(%ld): Checksum OK, start " | |
888 | "firmware.\n", ha->host_no)); | |
889 | ||
0107109e | 890 | rval = qla2x00_execute_fw(ha, srisc_address); |
1da177e4 LT |
891 | /* Retrieve firmware information. */ |
892 | if (rval == QLA_SUCCESS && ha->fw_major_version == 0) { | |
893 | qla2x00_get_fw_version(ha, | |
894 | &ha->fw_major_version, | |
895 | &ha->fw_minor_version, | |
896 | &ha->fw_subminor_version, | |
897 | &ha->fw_attributes, &ha->fw_memory_size); | |
898 | qla2x00_resize_request_q(ha); | |
a7a167bf AV |
899 | |
900 | if (ql2xallocfwdump) | |
901 | qla2x00_alloc_fw_dump(ha); | |
1da177e4 LT |
902 | } |
903 | } else { | |
904 | DEBUG2(printk(KERN_INFO | |
905 | "scsi(%ld): ISP Firmware failed checksum.\n", | |
906 | ha->host_no)); | |
907 | } | |
908 | } | |
909 | ||
910 | if (rval) { | |
911 | DEBUG2_3(printk("scsi(%ld): Setup chip **** FAILED ****.\n", | |
912 | ha->host_no)); | |
913 | } | |
914 | ||
915 | return (rval); | |
916 | } | |
917 | ||
918 | /** | |
919 | * qla2x00_init_response_q_entries() - Initializes response queue entries. | |
920 | * @ha: HA context | |
921 | * | |
922 | * Beginning of request ring has initialization control block already built | |
923 | * by nvram config routine. | |
924 | * | |
925 | * Returns 0 on success. | |
926 | */ | |
927 | static void | |
928 | qla2x00_init_response_q_entries(scsi_qla_host_t *ha) | |
929 | { | |
930 | uint16_t cnt; | |
931 | response_t *pkt; | |
932 | ||
933 | pkt = ha->response_ring_ptr; | |
934 | for (cnt = 0; cnt < ha->response_q_length; cnt++) { | |
935 | pkt->signature = RESPONSE_PROCESSED; | |
936 | pkt++; | |
937 | } | |
938 | ||
939 | } | |
940 | ||
941 | /** | |
942 | * qla2x00_update_fw_options() - Read and process firmware options. | |
943 | * @ha: HA context | |
944 | * | |
945 | * Returns 0 on success. | |
946 | */ | |
abbd8870 | 947 | void |
1da177e4 LT |
948 | qla2x00_update_fw_options(scsi_qla_host_t *ha) |
949 | { | |
950 | uint16_t swing, emphasis, tx_sens, rx_sens; | |
951 | ||
952 | memset(ha->fw_options, 0, sizeof(ha->fw_options)); | |
953 | qla2x00_get_fw_options(ha, ha->fw_options); | |
954 | ||
955 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) | |
956 | return; | |
957 | ||
958 | /* Serial Link options. */ | |
959 | DEBUG3(printk("scsi(%ld): Serial link options:\n", | |
960 | ha->host_no)); | |
961 | DEBUG3(qla2x00_dump_buffer((uint8_t *)&ha->fw_seriallink_options, | |
962 | sizeof(ha->fw_seriallink_options))); | |
963 | ||
964 | ha->fw_options[1] &= ~FO1_SET_EMPHASIS_SWING; | |
965 | if (ha->fw_seriallink_options[3] & BIT_2) { | |
966 | ha->fw_options[1] |= FO1_SET_EMPHASIS_SWING; | |
967 | ||
968 | /* 1G settings */ | |
969 | swing = ha->fw_seriallink_options[2] & (BIT_2 | BIT_1 | BIT_0); | |
970 | emphasis = (ha->fw_seriallink_options[2] & | |
971 | (BIT_4 | BIT_3)) >> 3; | |
972 | tx_sens = ha->fw_seriallink_options[0] & | |
fa2a1ce5 | 973 | (BIT_3 | BIT_2 | BIT_1 | BIT_0); |
1da177e4 LT |
974 | rx_sens = (ha->fw_seriallink_options[0] & |
975 | (BIT_7 | BIT_6 | BIT_5 | BIT_4)) >> 4; | |
976 | ha->fw_options[10] = (emphasis << 14) | (swing << 8); | |
977 | if (IS_QLA2300(ha) || IS_QLA2312(ha) || IS_QLA6312(ha)) { | |
978 | if (rx_sens == 0x0) | |
979 | rx_sens = 0x3; | |
980 | ha->fw_options[10] |= (tx_sens << 4) | rx_sens; | |
981 | } else if (IS_QLA2322(ha) || IS_QLA6322(ha)) | |
982 | ha->fw_options[10] |= BIT_5 | | |
983 | ((rx_sens & (BIT_1 | BIT_0)) << 2) | | |
984 | (tx_sens & (BIT_1 | BIT_0)); | |
985 | ||
986 | /* 2G settings */ | |
987 | swing = (ha->fw_seriallink_options[2] & | |
988 | (BIT_7 | BIT_6 | BIT_5)) >> 5; | |
989 | emphasis = ha->fw_seriallink_options[3] & (BIT_1 | BIT_0); | |
990 | tx_sens = ha->fw_seriallink_options[1] & | |
fa2a1ce5 | 991 | (BIT_3 | BIT_2 | BIT_1 | BIT_0); |
1da177e4 LT |
992 | rx_sens = (ha->fw_seriallink_options[1] & |
993 | (BIT_7 | BIT_6 | BIT_5 | BIT_4)) >> 4; | |
994 | ha->fw_options[11] = (emphasis << 14) | (swing << 8); | |
995 | if (IS_QLA2300(ha) || IS_QLA2312(ha) || IS_QLA6312(ha)) { | |
996 | if (rx_sens == 0x0) | |
997 | rx_sens = 0x3; | |
998 | ha->fw_options[11] |= (tx_sens << 4) | rx_sens; | |
999 | } else if (IS_QLA2322(ha) || IS_QLA6322(ha)) | |
1000 | ha->fw_options[11] |= BIT_5 | | |
1001 | ((rx_sens & (BIT_1 | BIT_0)) << 2) | | |
1002 | (tx_sens & (BIT_1 | BIT_0)); | |
1003 | } | |
1004 | ||
1005 | /* FCP2 options. */ | |
1006 | /* Return command IOCBs without waiting for an ABTS to complete. */ | |
1007 | ha->fw_options[3] |= BIT_13; | |
1008 | ||
1009 | /* LED scheme. */ | |
1010 | if (ha->flags.enable_led_scheme) | |
1011 | ha->fw_options[2] |= BIT_12; | |
1012 | ||
48c02fde | 1013 | /* Detect ISP6312. */ |
1014 | if (IS_QLA6312(ha)) | |
1015 | ha->fw_options[2] |= BIT_13; | |
1016 | ||
1da177e4 LT |
1017 | /* Update firmware options. */ |
1018 | qla2x00_set_fw_options(ha, ha->fw_options); | |
1019 | } | |
1020 | ||
0107109e AV |
1021 | void |
1022 | qla24xx_update_fw_options(scsi_qla_host_t *ha) | |
1023 | { | |
1024 | int rval; | |
1025 | ||
1026 | /* Update Serial Link options. */ | |
f94097ed | 1027 | if ((le16_to_cpu(ha->fw_seriallink_options24[0]) & BIT_0) == 0) |
0107109e AV |
1028 | return; |
1029 | ||
f94097ed | 1030 | rval = qla2x00_set_serdes_params(ha, |
1031 | le16_to_cpu(ha->fw_seriallink_options24[1]), | |
1032 | le16_to_cpu(ha->fw_seriallink_options24[2]), | |
1033 | le16_to_cpu(ha->fw_seriallink_options24[3])); | |
0107109e AV |
1034 | if (rval != QLA_SUCCESS) { |
1035 | qla_printk(KERN_WARNING, ha, | |
1036 | "Unable to update Serial Link options (%x).\n", rval); | |
1037 | } | |
1038 | } | |
1039 | ||
abbd8870 AV |
1040 | void |
1041 | qla2x00_config_rings(struct scsi_qla_host *ha) | |
1042 | { | |
3d71644c | 1043 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
abbd8870 AV |
1044 | |
1045 | /* Setup ring parameters in initialization control block. */ | |
1046 | ha->init_cb->request_q_outpointer = __constant_cpu_to_le16(0); | |
1047 | ha->init_cb->response_q_inpointer = __constant_cpu_to_le16(0); | |
1048 | ha->init_cb->request_q_length = cpu_to_le16(ha->request_q_length); | |
1049 | ha->init_cb->response_q_length = cpu_to_le16(ha->response_q_length); | |
1050 | ha->init_cb->request_q_address[0] = cpu_to_le32(LSD(ha->request_dma)); | |
1051 | ha->init_cb->request_q_address[1] = cpu_to_le32(MSD(ha->request_dma)); | |
1052 | ha->init_cb->response_q_address[0] = cpu_to_le32(LSD(ha->response_dma)); | |
1053 | ha->init_cb->response_q_address[1] = cpu_to_le32(MSD(ha->response_dma)); | |
1054 | ||
1055 | WRT_REG_WORD(ISP_REQ_Q_IN(ha, reg), 0); | |
1056 | WRT_REG_WORD(ISP_REQ_Q_OUT(ha, reg), 0); | |
1057 | WRT_REG_WORD(ISP_RSP_Q_IN(ha, reg), 0); | |
1058 | WRT_REG_WORD(ISP_RSP_Q_OUT(ha, reg), 0); | |
1059 | RD_REG_WORD(ISP_RSP_Q_OUT(ha, reg)); /* PCI Posting. */ | |
1060 | } | |
1061 | ||
0107109e AV |
1062 | void |
1063 | qla24xx_config_rings(struct scsi_qla_host *ha) | |
1064 | { | |
1065 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; | |
1066 | struct init_cb_24xx *icb; | |
1067 | ||
1068 | /* Setup ring parameters in initialization control block. */ | |
1069 | icb = (struct init_cb_24xx *)ha->init_cb; | |
1070 | icb->request_q_outpointer = __constant_cpu_to_le16(0); | |
1071 | icb->response_q_inpointer = __constant_cpu_to_le16(0); | |
1072 | icb->request_q_length = cpu_to_le16(ha->request_q_length); | |
1073 | icb->response_q_length = cpu_to_le16(ha->response_q_length); | |
1074 | icb->request_q_address[0] = cpu_to_le32(LSD(ha->request_dma)); | |
1075 | icb->request_q_address[1] = cpu_to_le32(MSD(ha->request_dma)); | |
1076 | icb->response_q_address[0] = cpu_to_le32(LSD(ha->response_dma)); | |
1077 | icb->response_q_address[1] = cpu_to_le32(MSD(ha->response_dma)); | |
1078 | ||
1079 | WRT_REG_DWORD(®->req_q_in, 0); | |
1080 | WRT_REG_DWORD(®->req_q_out, 0); | |
1081 | WRT_REG_DWORD(®->rsp_q_in, 0); | |
1082 | WRT_REG_DWORD(®->rsp_q_out, 0); | |
1083 | RD_REG_DWORD(®->rsp_q_out); | |
1084 | } | |
1085 | ||
1da177e4 LT |
1086 | /** |
1087 | * qla2x00_init_rings() - Initializes firmware. | |
1088 | * @ha: HA context | |
1089 | * | |
1090 | * Beginning of request ring has initialization control block already built | |
1091 | * by nvram config routine. | |
1092 | * | |
1093 | * Returns 0 on success. | |
1094 | */ | |
1095 | static int | |
1096 | qla2x00_init_rings(scsi_qla_host_t *ha) | |
1097 | { | |
1098 | int rval; | |
1099 | unsigned long flags = 0; | |
1100 | int cnt; | |
1da177e4 LT |
1101 | |
1102 | spin_lock_irqsave(&ha->hardware_lock, flags); | |
1103 | ||
1104 | /* Clear outstanding commands array. */ | |
1105 | for (cnt = 0; cnt < MAX_OUTSTANDING_COMMANDS; cnt++) | |
1106 | ha->outstanding_cmds[cnt] = NULL; | |
1107 | ||
1108 | ha->current_outstanding_cmd = 0; | |
1109 | ||
1110 | /* Clear RSCN queue. */ | |
1111 | ha->rscn_in_ptr = 0; | |
1112 | ha->rscn_out_ptr = 0; | |
1113 | ||
1114 | /* Initialize firmware. */ | |
1115 | ha->request_ring_ptr = ha->request_ring; | |
1116 | ha->req_ring_index = 0; | |
1117 | ha->req_q_cnt = ha->request_q_length; | |
1118 | ha->response_ring_ptr = ha->response_ring; | |
1119 | ha->rsp_ring_index = 0; | |
1120 | ||
1da177e4 LT |
1121 | /* Initialize response queue entries */ |
1122 | qla2x00_init_response_q_entries(ha); | |
1123 | ||
abbd8870 | 1124 | ha->isp_ops.config_rings(ha); |
1da177e4 LT |
1125 | |
1126 | spin_unlock_irqrestore(&ha->hardware_lock, flags); | |
1127 | ||
1128 | /* Update any ISP specific firmware options before initialization. */ | |
abbd8870 | 1129 | ha->isp_ops.update_fw_options(ha); |
1da177e4 LT |
1130 | |
1131 | DEBUG(printk("scsi(%ld): Issue init firmware.\n", ha->host_no)); | |
0107109e | 1132 | rval = qla2x00_init_firmware(ha, ha->init_cb_size); |
1da177e4 LT |
1133 | if (rval) { |
1134 | DEBUG2_3(printk("scsi(%ld): Init firmware **** FAILED ****.\n", | |
1135 | ha->host_no)); | |
1136 | } else { | |
1137 | DEBUG3(printk("scsi(%ld): Init firmware -- success.\n", | |
1138 | ha->host_no)); | |
1139 | } | |
1140 | ||
1141 | return (rval); | |
1142 | } | |
1143 | ||
1144 | /** | |
1145 | * qla2x00_fw_ready() - Waits for firmware ready. | |
1146 | * @ha: HA context | |
1147 | * | |
1148 | * Returns 0 on success. | |
1149 | */ | |
1150 | static int | |
1151 | qla2x00_fw_ready(scsi_qla_host_t *ha) | |
1152 | { | |
1153 | int rval; | |
1154 | unsigned long wtime, mtime; | |
1155 | uint16_t min_wait; /* Minimum wait time if loop is down */ | |
1156 | uint16_t wait_time; /* Wait time if loop is coming ready */ | |
1157 | uint16_t fw_state; | |
1158 | ||
1159 | rval = QLA_SUCCESS; | |
1160 | ||
1161 | /* 20 seconds for loop down. */ | |
fa2a1ce5 | 1162 | min_wait = 20; |
1da177e4 LT |
1163 | |
1164 | /* | |
1165 | * Firmware should take at most one RATOV to login, plus 5 seconds for | |
1166 | * our own processing. | |
1167 | */ | |
1168 | if ((wait_time = (ha->retry_count*ha->login_timeout) + 5) < min_wait) { | |
1169 | wait_time = min_wait; | |
1170 | } | |
1171 | ||
1172 | /* Min wait time if loop down */ | |
1173 | mtime = jiffies + (min_wait * HZ); | |
1174 | ||
1175 | /* wait time before firmware ready */ | |
1176 | wtime = jiffies + (wait_time * HZ); | |
1177 | ||
1178 | /* Wait for ISP to finish LIP */ | |
1179 | if (!ha->flags.init_done) | |
1180 | qla_printk(KERN_INFO, ha, "Waiting for LIP to complete...\n"); | |
1181 | ||
1182 | DEBUG3(printk("scsi(%ld): Waiting for LIP to complete...\n", | |
1183 | ha->host_no)); | |
1184 | ||
1185 | do { | |
1186 | rval = qla2x00_get_firmware_state(ha, &fw_state); | |
1187 | if (rval == QLA_SUCCESS) { | |
1188 | if (fw_state < FSTATE_LOSS_OF_SYNC) { | |
1189 | ha->device_flags &= ~DFLG_NO_CABLE; | |
1190 | } | |
1191 | if (fw_state == FSTATE_READY) { | |
1192 | DEBUG(printk("scsi(%ld): F/W Ready - OK \n", | |
1193 | ha->host_no)); | |
1194 | ||
1195 | qla2x00_get_retry_cnt(ha, &ha->retry_count, | |
1196 | &ha->login_timeout, &ha->r_a_tov); | |
1197 | ||
1198 | rval = QLA_SUCCESS; | |
1199 | break; | |
1200 | } | |
1201 | ||
1202 | rval = QLA_FUNCTION_FAILED; | |
1203 | ||
1204 | if (atomic_read(&ha->loop_down_timer) && | |
7d7abc77 | 1205 | fw_state != FSTATE_READY) { |
1da177e4 | 1206 | /* Loop down. Timeout on min_wait for states |
fa2a1ce5 AV |
1207 | * other than Wait for Login. |
1208 | */ | |
1da177e4 LT |
1209 | if (time_after_eq(jiffies, mtime)) { |
1210 | qla_printk(KERN_INFO, ha, | |
1211 | "Cable is unplugged...\n"); | |
1212 | ||
1213 | ha->device_flags |= DFLG_NO_CABLE; | |
1214 | break; | |
1215 | } | |
1216 | } | |
1217 | } else { | |
1218 | /* Mailbox cmd failed. Timeout on min_wait. */ | |
1219 | if (time_after_eq(jiffies, mtime)) | |
1220 | break; | |
1221 | } | |
1222 | ||
1223 | if (time_after_eq(jiffies, wtime)) | |
1224 | break; | |
1225 | ||
1226 | /* Delay for a while */ | |
1227 | msleep(500); | |
1228 | ||
1229 | DEBUG3(printk("scsi(%ld): fw_state=%x curr time=%lx.\n", | |
1230 | ha->host_no, fw_state, jiffies)); | |
1231 | } while (1); | |
1232 | ||
1233 | DEBUG(printk("scsi(%ld): fw_state=%x curr time=%lx.\n", | |
1234 | ha->host_no, fw_state, jiffies)); | |
1235 | ||
1236 | if (rval) { | |
1237 | DEBUG2_3(printk("scsi(%ld): Firmware ready **** FAILED ****.\n", | |
1238 | ha->host_no)); | |
1239 | } | |
1240 | ||
1241 | return (rval); | |
1242 | } | |
1243 | ||
1244 | /* | |
1245 | * qla2x00_configure_hba | |
1246 | * Setup adapter context. | |
1247 | * | |
1248 | * Input: | |
1249 | * ha = adapter state pointer. | |
1250 | * | |
1251 | * Returns: | |
1252 | * 0 = success | |
1253 | * | |
1254 | * Context: | |
1255 | * Kernel context. | |
1256 | */ | |
1257 | static int | |
1258 | qla2x00_configure_hba(scsi_qla_host_t *ha) | |
1259 | { | |
1260 | int rval; | |
1261 | uint16_t loop_id; | |
1262 | uint16_t topo; | |
1263 | uint8_t al_pa; | |
1264 | uint8_t area; | |
1265 | uint8_t domain; | |
1266 | char connect_type[22]; | |
1267 | ||
1268 | /* Get host addresses. */ | |
1269 | rval = qla2x00_get_adapter_id(ha, | |
1270 | &loop_id, &al_pa, &area, &domain, &topo); | |
1271 | if (rval != QLA_SUCCESS) { | |
23443b1d | 1272 | if (LOOP_TRANSITION(ha) || atomic_read(&ha->loop_down_timer) || |
33135aa2 RA |
1273 | (rval == QLA_COMMAND_ERROR && loop_id == 0x7)) { |
1274 | DEBUG2(printk("%s(%ld) Loop is in a transition state\n", | |
1275 | __func__, ha->host_no)); | |
1276 | } else { | |
1277 | qla_printk(KERN_WARNING, ha, | |
1278 | "ERROR -- Unable to get host loop ID.\n"); | |
1279 | set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags); | |
1280 | } | |
1da177e4 LT |
1281 | return (rval); |
1282 | } | |
1283 | ||
1284 | if (topo == 4) { | |
1285 | qla_printk(KERN_INFO, ha, | |
1286 | "Cannot get topology - retrying.\n"); | |
1287 | return (QLA_FUNCTION_FAILED); | |
1288 | } | |
1289 | ||
1290 | ha->loop_id = loop_id; | |
1291 | ||
1292 | /* initialize */ | |
1293 | ha->min_external_loopid = SNS_FIRST_LOOP_ID; | |
1294 | ha->operating_mode = LOOP; | |
1295 | ||
1296 | switch (topo) { | |
1297 | case 0: | |
1298 | DEBUG3(printk("scsi(%ld): HBA in NL topology.\n", | |
1299 | ha->host_no)); | |
1300 | ha->current_topology = ISP_CFG_NL; | |
1301 | strcpy(connect_type, "(Loop)"); | |
1302 | break; | |
1303 | ||
1304 | case 1: | |
1305 | DEBUG3(printk("scsi(%ld): HBA in FL topology.\n", | |
1306 | ha->host_no)); | |
1307 | ha->current_topology = ISP_CFG_FL; | |
1308 | strcpy(connect_type, "(FL_Port)"); | |
1309 | break; | |
1310 | ||
1311 | case 2: | |
1312 | DEBUG3(printk("scsi(%ld): HBA in N P2P topology.\n", | |
1313 | ha->host_no)); | |
1314 | ha->operating_mode = P2P; | |
1315 | ha->current_topology = ISP_CFG_N; | |
1316 | strcpy(connect_type, "(N_Port-to-N_Port)"); | |
1317 | break; | |
1318 | ||
1319 | case 3: | |
1320 | DEBUG3(printk("scsi(%ld): HBA in F P2P topology.\n", | |
1321 | ha->host_no)); | |
1322 | ha->operating_mode = P2P; | |
1323 | ha->current_topology = ISP_CFG_F; | |
1324 | strcpy(connect_type, "(F_Port)"); | |
1325 | break; | |
1326 | ||
1327 | default: | |
1328 | DEBUG3(printk("scsi(%ld): HBA in unknown topology %x. " | |
1329 | "Using NL.\n", | |
1330 | ha->host_no, topo)); | |
1331 | ha->current_topology = ISP_CFG_NL; | |
1332 | strcpy(connect_type, "(Loop)"); | |
1333 | break; | |
1334 | } | |
1335 | ||
1336 | /* Save Host port and loop ID. */ | |
1337 | /* byte order - Big Endian */ | |
1338 | ha->d_id.b.domain = domain; | |
1339 | ha->d_id.b.area = area; | |
1340 | ha->d_id.b.al_pa = al_pa; | |
1341 | ||
1342 | if (!ha->flags.init_done) | |
1343 | qla_printk(KERN_INFO, ha, | |
1344 | "Topology - %s, Host Loop address 0x%x\n", | |
1345 | connect_type, ha->loop_id); | |
1346 | ||
1347 | if (rval) { | |
1348 | DEBUG2_3(printk("scsi(%ld): FAILED.\n", ha->host_no)); | |
1349 | } else { | |
1350 | DEBUG3(printk("scsi(%ld): exiting normally.\n", ha->host_no)); | |
1351 | } | |
1352 | ||
1353 | return(rval); | |
1354 | } | |
1355 | ||
1356 | /* | |
1357 | * NVRAM configuration for ISP 2xxx | |
1358 | * | |
1359 | * Input: | |
1360 | * ha = adapter block pointer. | |
1361 | * | |
1362 | * Output: | |
1363 | * initialization control block in response_ring | |
1364 | * host adapters parameters in host adapter block | |
1365 | * | |
1366 | * Returns: | |
1367 | * 0 = success. | |
1368 | */ | |
abbd8870 | 1369 | int |
1da177e4 LT |
1370 | qla2x00_nvram_config(scsi_qla_host_t *ha) |
1371 | { | |
0107109e AV |
1372 | int rval; |
1373 | uint8_t chksum = 0; | |
1374 | uint16_t cnt; | |
1375 | uint8_t *dptr1, *dptr2; | |
1376 | init_cb_t *icb = ha->init_cb; | |
1377 | nvram_t *nv = (nvram_t *)ha->request_ring; | |
1378 | uint8_t *ptr = (uint8_t *)ha->request_ring; | |
3d71644c | 1379 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
1da177e4 LT |
1380 | |
1381 | rval = QLA_SUCCESS; | |
1382 | ||
1383 | /* Determine NVRAM starting address. */ | |
0107109e | 1384 | ha->nvram_size = sizeof(nvram_t); |
1da177e4 LT |
1385 | ha->nvram_base = 0; |
1386 | if (!IS_QLA2100(ha) && !IS_QLA2200(ha) && !IS_QLA2300(ha)) | |
1387 | if ((RD_REG_WORD(®->ctrl_status) >> 14) == 1) | |
1388 | ha->nvram_base = 0x80; | |
1389 | ||
1390 | /* Get NVRAM data and calculate checksum. */ | |
0107109e AV |
1391 | ha->isp_ops.read_nvram(ha, ptr, ha->nvram_base, ha->nvram_size); |
1392 | for (cnt = 0, chksum = 0; cnt < ha->nvram_size; cnt++) | |
1393 | chksum += *ptr++; | |
1da177e4 LT |
1394 | |
1395 | DEBUG5(printk("scsi(%ld): Contents of NVRAM\n", ha->host_no)); | |
1396 | DEBUG5(qla2x00_dump_buffer((uint8_t *)ha->request_ring, | |
0107109e | 1397 | ha->nvram_size)); |
1da177e4 LT |
1398 | |
1399 | /* Bad NVRAM data, set defaults parameters. */ | |
1400 | if (chksum || nv->id[0] != 'I' || nv->id[1] != 'S' || | |
1401 | nv->id[2] != 'P' || nv->id[3] != ' ' || nv->nvram_version < 1) { | |
1402 | /* Reset NVRAM data. */ | |
1403 | qla_printk(KERN_WARNING, ha, "Inconsistent NVRAM detected: " | |
1404 | "checksum=0x%x id=%c version=0x%x.\n", chksum, nv->id[0], | |
1405 | nv->nvram_version); | |
1406 | qla_printk(KERN_WARNING, ha, "Falling back to functioning (yet " | |
1407 | "invalid -- WWPN) defaults.\n"); | |
1408 | ||
1409 | /* | |
1410 | * Set default initialization control block. | |
1411 | */ | |
0107109e | 1412 | memset(nv, 0, ha->nvram_size); |
1da177e4 LT |
1413 | nv->parameter_block_version = ICB_VERSION; |
1414 | ||
1415 | if (IS_QLA23XX(ha)) { | |
1416 | nv->firmware_options[0] = BIT_2 | BIT_1; | |
1417 | nv->firmware_options[1] = BIT_7 | BIT_5; | |
1418 | nv->add_firmware_options[0] = BIT_5; | |
1419 | nv->add_firmware_options[1] = BIT_5 | BIT_4; | |
1420 | nv->frame_payload_size = __constant_cpu_to_le16(2048); | |
1421 | nv->special_options[1] = BIT_7; | |
1422 | } else if (IS_QLA2200(ha)) { | |
1423 | nv->firmware_options[0] = BIT_2 | BIT_1; | |
1424 | nv->firmware_options[1] = BIT_7 | BIT_5; | |
1425 | nv->add_firmware_options[0] = BIT_5; | |
1426 | nv->add_firmware_options[1] = BIT_5 | BIT_4; | |
1427 | nv->frame_payload_size = __constant_cpu_to_le16(1024); | |
1428 | } else if (IS_QLA2100(ha)) { | |
1429 | nv->firmware_options[0] = BIT_3 | BIT_1; | |
1430 | nv->firmware_options[1] = BIT_5; | |
1431 | nv->frame_payload_size = __constant_cpu_to_le16(1024); | |
1432 | } | |
1433 | ||
1434 | nv->max_iocb_allocation = __constant_cpu_to_le16(256); | |
1435 | nv->execution_throttle = __constant_cpu_to_le16(16); | |
1436 | nv->retry_count = 8; | |
1437 | nv->retry_delay = 1; | |
1438 | ||
1439 | nv->port_name[0] = 33; | |
1440 | nv->port_name[3] = 224; | |
1441 | nv->port_name[4] = 139; | |
1442 | ||
1443 | nv->login_timeout = 4; | |
1444 | ||
1445 | /* | |
1446 | * Set default host adapter parameters | |
1447 | */ | |
1448 | nv->host_p[1] = BIT_2; | |
1449 | nv->reset_delay = 5; | |
1450 | nv->port_down_retry_count = 8; | |
1451 | nv->max_luns_per_target = __constant_cpu_to_le16(8); | |
1452 | nv->link_down_timeout = 60; | |
1453 | ||
1454 | rval = 1; | |
1455 | } | |
1456 | ||
1457 | #if defined(CONFIG_IA64_GENERIC) || defined(CONFIG_IA64_SGI_SN2) | |
1458 | /* | |
1459 | * The SN2 does not provide BIOS emulation which means you can't change | |
1460 | * potentially bogus BIOS settings. Force the use of default settings | |
1461 | * for link rate and frame size. Hope that the rest of the settings | |
1462 | * are valid. | |
1463 | */ | |
1464 | if (ia64_platform_is("sn2")) { | |
1465 | nv->frame_payload_size = __constant_cpu_to_le16(2048); | |
1466 | if (IS_QLA23XX(ha)) | |
1467 | nv->special_options[1] = BIT_7; | |
1468 | } | |
1469 | #endif | |
1470 | ||
1471 | /* Reset Initialization control block */ | |
0107109e | 1472 | memset(icb, 0, ha->init_cb_size); |
1da177e4 LT |
1473 | |
1474 | /* | |
1475 | * Setup driver NVRAM options. | |
1476 | */ | |
1477 | nv->firmware_options[0] |= (BIT_6 | BIT_1); | |
1478 | nv->firmware_options[0] &= ~(BIT_5 | BIT_4); | |
1479 | nv->firmware_options[1] |= (BIT_5 | BIT_0); | |
1480 | nv->firmware_options[1] &= ~BIT_4; | |
1481 | ||
1482 | if (IS_QLA23XX(ha)) { | |
1483 | nv->firmware_options[0] |= BIT_2; | |
1484 | nv->firmware_options[0] &= ~BIT_3; | |
0107109e | 1485 | nv->add_firmware_options[1] |= BIT_5 | BIT_4; |
1da177e4 LT |
1486 | |
1487 | if (IS_QLA2300(ha)) { | |
1488 | if (ha->fb_rev == FPM_2310) { | |
1489 | strcpy(ha->model_number, "QLA2310"); | |
1490 | } else { | |
1491 | strcpy(ha->model_number, "QLA2300"); | |
1492 | } | |
1493 | } else { | |
1494 | if (rval == 0 && | |
1495 | memcmp(nv->model_number, BINZERO, | |
1496 | sizeof(nv->model_number)) != 0) { | |
1497 | char *st, *en; | |
1498 | ||
1499 | strncpy(ha->model_number, nv->model_number, | |
1500 | sizeof(nv->model_number)); | |
1501 | st = en = ha->model_number; | |
1502 | en += sizeof(nv->model_number) - 1; | |
1503 | while (en > st) { | |
1504 | if (*en != 0x20 && *en != 0x00) | |
1505 | break; | |
1506 | *en-- = '\0'; | |
1507 | } | |
1508 | } else { | |
1509 | uint16_t index; | |
1510 | ||
1511 | index = (ha->pdev->subsystem_device & 0xff); | |
1512 | if (index < QLA_MODEL_NAMES) { | |
1513 | strcpy(ha->model_number, | |
1328962e | 1514 | qla2x00_model_name[index * 2]); |
1da177e4 | 1515 | ha->model_desc = |
1328962e | 1516 | qla2x00_model_name[index * 2 + 1]; |
1da177e4 LT |
1517 | } else { |
1518 | strcpy(ha->model_number, "QLA23xx"); | |
1519 | } | |
1520 | } | |
1521 | } | |
1522 | } else if (IS_QLA2200(ha)) { | |
1523 | nv->firmware_options[0] |= BIT_2; | |
1524 | /* | |
1525 | * 'Point-to-point preferred, else loop' is not a safe | |
1526 | * connection mode setting. | |
1527 | */ | |
1528 | if ((nv->add_firmware_options[0] & (BIT_6 | BIT_5 | BIT_4)) == | |
1529 | (BIT_5 | BIT_4)) { | |
1530 | /* Force 'loop preferred, else point-to-point'. */ | |
1531 | nv->add_firmware_options[0] &= ~(BIT_6 | BIT_5 | BIT_4); | |
1532 | nv->add_firmware_options[0] |= BIT_5; | |
1533 | } | |
1534 | strcpy(ha->model_number, "QLA22xx"); | |
1535 | } else /*if (IS_QLA2100(ha))*/ { | |
1536 | strcpy(ha->model_number, "QLA2100"); | |
1537 | } | |
1538 | ||
1539 | /* | |
1540 | * Copy over NVRAM RISC parameter block to initialization control block. | |
1541 | */ | |
1542 | dptr1 = (uint8_t *)icb; | |
1543 | dptr2 = (uint8_t *)&nv->parameter_block_version; | |
1544 | cnt = (uint8_t *)&icb->request_q_outpointer - (uint8_t *)&icb->version; | |
1545 | while (cnt--) | |
1546 | *dptr1++ = *dptr2++; | |
1547 | ||
1548 | /* Copy 2nd half. */ | |
1549 | dptr1 = (uint8_t *)icb->add_firmware_options; | |
1550 | cnt = (uint8_t *)icb->reserved_3 - (uint8_t *)icb->add_firmware_options; | |
1551 | while (cnt--) | |
1552 | *dptr1++ = *dptr2++; | |
1553 | ||
5341e868 AV |
1554 | /* Use alternate WWN? */ |
1555 | if (nv->host_p[1] & BIT_7) { | |
1556 | memcpy(icb->node_name, nv->alternate_node_name, WWN_SIZE); | |
1557 | memcpy(icb->port_name, nv->alternate_port_name, WWN_SIZE); | |
1558 | } | |
1559 | ||
1da177e4 LT |
1560 | /* Prepare nodename */ |
1561 | if ((icb->firmware_options[1] & BIT_6) == 0) { | |
1562 | /* | |
1563 | * Firmware will apply the following mask if the nodename was | |
1564 | * not provided. | |
1565 | */ | |
1566 | memcpy(icb->node_name, icb->port_name, WWN_SIZE); | |
1567 | icb->node_name[0] &= 0xF0; | |
1568 | } | |
1569 | ||
1570 | /* | |
1571 | * Set host adapter parameters. | |
1572 | */ | |
0181944f | 1573 | if (nv->host_p[0] & BIT_7) |
11010fec | 1574 | ql2xextended_error_logging = 1; |
1da177e4 LT |
1575 | ha->flags.disable_risc_code_load = ((nv->host_p[0] & BIT_4) ? 1 : 0); |
1576 | /* Always load RISC code on non ISP2[12]00 chips. */ | |
1577 | if (!IS_QLA2100(ha) && !IS_QLA2200(ha)) | |
1578 | ha->flags.disable_risc_code_load = 0; | |
1579 | ha->flags.enable_lip_reset = ((nv->host_p[1] & BIT_1) ? 1 : 0); | |
1580 | ha->flags.enable_lip_full_login = ((nv->host_p[1] & BIT_2) ? 1 : 0); | |
1581 | ha->flags.enable_target_reset = ((nv->host_p[1] & BIT_3) ? 1 : 0); | |
06c22bd1 | 1582 | ha->flags.enable_led_scheme = (nv->special_options[1] & BIT_4) ? 1 : 0; |
d4c760c2 | 1583 | ha->flags.disable_serdes = 0; |
1da177e4 LT |
1584 | |
1585 | ha->operating_mode = | |
1586 | (icb->add_firmware_options[0] & (BIT_6 | BIT_5 | BIT_4)) >> 4; | |
1587 | ||
1588 | memcpy(ha->fw_seriallink_options, nv->seriallink_options, | |
1589 | sizeof(ha->fw_seriallink_options)); | |
1590 | ||
1591 | /* save HBA serial number */ | |
1592 | ha->serial0 = icb->port_name[5]; | |
1593 | ha->serial1 = icb->port_name[6]; | |
1594 | ha->serial2 = icb->port_name[7]; | |
3d71644c AV |
1595 | ha->node_name = icb->node_name; |
1596 | ha->port_name = icb->port_name; | |
1da177e4 LT |
1597 | |
1598 | icb->execution_throttle = __constant_cpu_to_le16(0xFFFF); | |
1599 | ||
1600 | ha->retry_count = nv->retry_count; | |
1601 | ||
1602 | /* Set minimum login_timeout to 4 seconds. */ | |
1603 | if (nv->login_timeout < ql2xlogintimeout) | |
1604 | nv->login_timeout = ql2xlogintimeout; | |
1605 | if (nv->login_timeout < 4) | |
1606 | nv->login_timeout = 4; | |
1607 | ha->login_timeout = nv->login_timeout; | |
1608 | icb->login_timeout = nv->login_timeout; | |
1609 | ||
1610 | /* Set minimum RATOV to 200 tenths of a second. */ | |
1611 | ha->r_a_tov = 200; | |
1612 | ||
1da177e4 LT |
1613 | ha->loop_reset_delay = nv->reset_delay; |
1614 | ||
1da177e4 LT |
1615 | /* Link Down Timeout = 0: |
1616 | * | |
1617 | * When Port Down timer expires we will start returning | |
1618 | * I/O's to OS with "DID_NO_CONNECT". | |
1619 | * | |
1620 | * Link Down Timeout != 0: | |
1621 | * | |
1622 | * The driver waits for the link to come up after link down | |
1623 | * before returning I/Os to OS with "DID_NO_CONNECT". | |
fa2a1ce5 | 1624 | */ |
1da177e4 LT |
1625 | if (nv->link_down_timeout == 0) { |
1626 | ha->loop_down_abort_time = | |
354d6b21 | 1627 | (LOOP_DOWN_TIME - LOOP_DOWN_TIMEOUT); |
1da177e4 LT |
1628 | } else { |
1629 | ha->link_down_timeout = nv->link_down_timeout; | |
1630 | ha->loop_down_abort_time = | |
1631 | (LOOP_DOWN_TIME - ha->link_down_timeout); | |
fa2a1ce5 | 1632 | } |
1da177e4 | 1633 | |
1da177e4 LT |
1634 | /* |
1635 | * Need enough time to try and get the port back. | |
1636 | */ | |
1637 | ha->port_down_retry_count = nv->port_down_retry_count; | |
1638 | if (qlport_down_retry) | |
1639 | ha->port_down_retry_count = qlport_down_retry; | |
1640 | /* Set login_retry_count */ | |
1641 | ha->login_retry_count = nv->retry_count; | |
1642 | if (ha->port_down_retry_count == nv->port_down_retry_count && | |
1643 | ha->port_down_retry_count > 3) | |
1644 | ha->login_retry_count = ha->port_down_retry_count; | |
1645 | else if (ha->port_down_retry_count > (int)ha->login_retry_count) | |
1646 | ha->login_retry_count = ha->port_down_retry_count; | |
1647 | if (ql2xloginretrycount) | |
1648 | ha->login_retry_count = ql2xloginretrycount; | |
1649 | ||
1da177e4 LT |
1650 | icb->lun_enables = __constant_cpu_to_le16(0); |
1651 | icb->command_resource_count = 0; | |
1652 | icb->immediate_notify_resource_count = 0; | |
1653 | icb->timeout = __constant_cpu_to_le16(0); | |
1654 | ||
1655 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) { | |
1656 | /* Enable RIO */ | |
1657 | icb->firmware_options[0] &= ~BIT_3; | |
1658 | icb->add_firmware_options[0] &= | |
1659 | ~(BIT_3 | BIT_2 | BIT_1 | BIT_0); | |
1660 | icb->add_firmware_options[0] |= BIT_2; | |
1661 | icb->response_accumulation_timer = 3; | |
1662 | icb->interrupt_delay_timer = 5; | |
1663 | ||
1664 | ha->flags.process_response_queue = 1; | |
1665 | } else { | |
4fdfefe5 AV |
1666 | /* Enable ZIO. */ |
1667 | if (!ha->flags.init_done) { | |
1668 | ha->zio_mode = icb->add_firmware_options[0] & | |
1669 | (BIT_3 | BIT_2 | BIT_1 | BIT_0); | |
1670 | ha->zio_timer = icb->interrupt_delay_timer ? | |
1671 | icb->interrupt_delay_timer: 2; | |
1672 | } | |
1da177e4 LT |
1673 | icb->add_firmware_options[0] &= |
1674 | ~(BIT_3 | BIT_2 | BIT_1 | BIT_0); | |
4fdfefe5 AV |
1675 | ha->flags.process_response_queue = 0; |
1676 | if (ha->zio_mode != QLA_ZIO_DISABLED) { | |
4a59f71d | 1677 | ha->zio_mode = QLA_ZIO_MODE_6; |
1678 | ||
4fdfefe5 AV |
1679 | DEBUG2(printk("scsi(%ld): ZIO mode %d enabled; timer " |
1680 | "delay (%d us).\n", ha->host_no, ha->zio_mode, | |
1681 | ha->zio_timer * 100)); | |
1da177e4 | 1682 | qla_printk(KERN_INFO, ha, |
4fdfefe5 AV |
1683 | "ZIO mode %d enabled; timer delay (%d us).\n", |
1684 | ha->zio_mode, ha->zio_timer * 100); | |
1da177e4 | 1685 | |
4fdfefe5 AV |
1686 | icb->add_firmware_options[0] |= (uint8_t)ha->zio_mode; |
1687 | icb->interrupt_delay_timer = (uint8_t)ha->zio_timer; | |
1da177e4 LT |
1688 | ha->flags.process_response_queue = 1; |
1689 | } | |
1690 | } | |
1691 | ||
1692 | if (rval) { | |
1693 | DEBUG2_3(printk(KERN_WARNING | |
1694 | "scsi(%ld): NVRAM configuration failed!\n", ha->host_no)); | |
1695 | } | |
1696 | return (rval); | |
1697 | } | |
1698 | ||
19a7b4ae JSEC |
1699 | static void |
1700 | qla2x00_rport_del(void *data) | |
1701 | { | |
1702 | fc_port_t *fcport = data; | |
d97994dc | 1703 | struct fc_rport *rport; |
1704 | unsigned long flags; | |
1705 | ||
1706 | spin_lock_irqsave(&fcport->rport_lock, flags); | |
1707 | rport = fcport->drport; | |
1708 | fcport->drport = NULL; | |
1709 | spin_unlock_irqrestore(&fcport->rport_lock, flags); | |
1710 | if (rport) | |
1711 | fc_remote_port_delete(rport); | |
19a7b4ae | 1712 | |
19a7b4ae JSEC |
1713 | } |
1714 | ||
1da177e4 LT |
1715 | /** |
1716 | * qla2x00_alloc_fcport() - Allocate a generic fcport. | |
1717 | * @ha: HA context | |
1718 | * @flags: allocation flags | |
1719 | * | |
1720 | * Returns a pointer to the allocated fcport, or NULL, if none available. | |
1721 | */ | |
413975a0 | 1722 | static fc_port_t * |
c53033f6 | 1723 | qla2x00_alloc_fcport(scsi_qla_host_t *ha, gfp_t flags) |
1da177e4 LT |
1724 | { |
1725 | fc_port_t *fcport; | |
1726 | ||
1727 | fcport = kmalloc(sizeof(fc_port_t), flags); | |
1728 | if (fcport == NULL) | |
1729 | return (fcport); | |
1730 | ||
1731 | /* Setup fcport template structure. */ | |
1732 | memset(fcport, 0, sizeof (fc_port_t)); | |
1733 | fcport->ha = ha; | |
1734 | fcport->port_type = FCT_UNKNOWN; | |
1735 | fcport->loop_id = FC_NO_LOOP_ID; | |
1da177e4 LT |
1736 | atomic_set(&fcport->state, FCS_UNCONFIGURED); |
1737 | fcport->flags = FCF_RLC_SUPPORT; | |
ad3e0eda | 1738 | fcport->supported_classes = FC_COS_UNSPECIFIED; |
d97994dc | 1739 | spin_lock_init(&fcport->rport_lock); |
1da177e4 LT |
1740 | |
1741 | return (fcport); | |
1742 | } | |
1743 | ||
1744 | /* | |
1745 | * qla2x00_configure_loop | |
1746 | * Updates Fibre Channel Device Database with what is actually on loop. | |
1747 | * | |
1748 | * Input: | |
1749 | * ha = adapter block pointer. | |
1750 | * | |
1751 | * Returns: | |
1752 | * 0 = success. | |
1753 | * 1 = error. | |
1754 | * 2 = database was full and device was not configured. | |
1755 | */ | |
1756 | static int | |
fa2a1ce5 | 1757 | qla2x00_configure_loop(scsi_qla_host_t *ha) |
1da177e4 LT |
1758 | { |
1759 | int rval; | |
1760 | unsigned long flags, save_flags; | |
1761 | ||
1762 | rval = QLA_SUCCESS; | |
1763 | ||
1764 | /* Get Initiator ID */ | |
1765 | if (test_bit(LOCAL_LOOP_UPDATE, &ha->dpc_flags)) { | |
1766 | rval = qla2x00_configure_hba(ha); | |
1767 | if (rval != QLA_SUCCESS) { | |
1768 | DEBUG(printk("scsi(%ld): Unable to configure HBA.\n", | |
1769 | ha->host_no)); | |
1770 | return (rval); | |
1771 | } | |
1772 | } | |
1773 | ||
1774 | save_flags = flags = ha->dpc_flags; | |
1775 | DEBUG(printk("scsi(%ld): Configure loop -- dpc flags =0x%lx\n", | |
1776 | ha->host_no, flags)); | |
1777 | ||
1778 | /* | |
1779 | * If we have both an RSCN and PORT UPDATE pending then handle them | |
1780 | * both at the same time. | |
1781 | */ | |
1782 | clear_bit(LOCAL_LOOP_UPDATE, &ha->dpc_flags); | |
1783 | clear_bit(RSCN_UPDATE, &ha->dpc_flags); | |
1da177e4 LT |
1784 | |
1785 | /* Determine what we need to do */ | |
1786 | if (ha->current_topology == ISP_CFG_FL && | |
1787 | (test_bit(LOCAL_LOOP_UPDATE, &flags))) { | |
1788 | ||
1789 | ha->flags.rscn_queue_overflow = 1; | |
1790 | set_bit(RSCN_UPDATE, &flags); | |
1791 | ||
1792 | } else if (ha->current_topology == ISP_CFG_F && | |
1793 | (test_bit(LOCAL_LOOP_UPDATE, &flags))) { | |
1794 | ||
1795 | ha->flags.rscn_queue_overflow = 1; | |
1796 | set_bit(RSCN_UPDATE, &flags); | |
1797 | clear_bit(LOCAL_LOOP_UPDATE, &flags); | |
21333b48 AV |
1798 | |
1799 | } else if (ha->current_topology == ISP_CFG_N) { | |
1800 | clear_bit(RSCN_UPDATE, &flags); | |
1da177e4 LT |
1801 | |
1802 | } else if (!ha->flags.online || | |
1803 | (test_bit(ABORT_ISP_ACTIVE, &flags))) { | |
1804 | ||
1805 | ha->flags.rscn_queue_overflow = 1; | |
1806 | set_bit(RSCN_UPDATE, &flags); | |
1807 | set_bit(LOCAL_LOOP_UPDATE, &flags); | |
1808 | } | |
1809 | ||
1810 | if (test_bit(LOCAL_LOOP_UPDATE, &flags)) { | |
1811 | if (test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags)) { | |
1812 | rval = QLA_FUNCTION_FAILED; | |
1813 | } else { | |
1814 | rval = qla2x00_configure_local_loop(ha); | |
1815 | } | |
1816 | } | |
1817 | ||
1818 | if (rval == QLA_SUCCESS && test_bit(RSCN_UPDATE, &flags)) { | |
23443b1d | 1819 | if (LOOP_TRANSITION(ha)) { |
1da177e4 LT |
1820 | rval = QLA_FUNCTION_FAILED; |
1821 | } else { | |
1822 | rval = qla2x00_configure_fabric(ha); | |
1823 | } | |
1824 | } | |
1825 | ||
1826 | if (rval == QLA_SUCCESS) { | |
1827 | if (atomic_read(&ha->loop_down_timer) || | |
1828 | test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags)) { | |
1829 | rval = QLA_FUNCTION_FAILED; | |
1830 | } else { | |
1da177e4 LT |
1831 | atomic_set(&ha->loop_state, LOOP_READY); |
1832 | ||
1833 | DEBUG(printk("scsi(%ld): LOOP READY\n", ha->host_no)); | |
1834 | } | |
1835 | } | |
1836 | ||
1837 | if (rval) { | |
1838 | DEBUG2_3(printk("%s(%ld): *** FAILED ***\n", | |
1839 | __func__, ha->host_no)); | |
1840 | } else { | |
1841 | DEBUG3(printk("%s: exiting normally\n", __func__)); | |
1842 | } | |
1843 | ||
1844 | /* Restore state if a resync event occured during processing */ | |
1845 | if (test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags)) { | |
1846 | if (test_bit(LOCAL_LOOP_UPDATE, &save_flags)) | |
1847 | set_bit(LOCAL_LOOP_UPDATE, &ha->dpc_flags); | |
1848 | if (test_bit(RSCN_UPDATE, &save_flags)) | |
1849 | set_bit(RSCN_UPDATE, &ha->dpc_flags); | |
1850 | } | |
1851 | ||
1852 | return (rval); | |
1853 | } | |
1854 | ||
1855 | ||
1856 | ||
1857 | /* | |
1858 | * qla2x00_configure_local_loop | |
1859 | * Updates Fibre Channel Device Database with local loop devices. | |
1860 | * | |
1861 | * Input: | |
1862 | * ha = adapter block pointer. | |
1863 | * | |
1864 | * Returns: | |
1865 | * 0 = success. | |
1866 | */ | |
1867 | static int | |
fa2a1ce5 | 1868 | qla2x00_configure_local_loop(scsi_qla_host_t *ha) |
1da177e4 LT |
1869 | { |
1870 | int rval, rval2; | |
1871 | int found_devs; | |
1872 | int found; | |
1873 | fc_port_t *fcport, *new_fcport; | |
1874 | ||
1875 | uint16_t index; | |
1876 | uint16_t entries; | |
1877 | char *id_iter; | |
1878 | uint16_t loop_id; | |
1879 | uint8_t domain, area, al_pa; | |
1880 | ||
1881 | found_devs = 0; | |
1882 | new_fcport = NULL; | |
1883 | entries = MAX_FIBRE_DEVICES; | |
1884 | ||
1885 | DEBUG3(printk("scsi(%ld): Getting FCAL position map\n", ha->host_no)); | |
1886 | DEBUG3(qla2x00_get_fcal_position_map(ha, NULL)); | |
1887 | ||
1888 | /* Get list of logged in devices. */ | |
1889 | memset(ha->gid_list, 0, GID_LIST_SIZE); | |
1890 | rval = qla2x00_get_id_list(ha, ha->gid_list, ha->gid_list_dma, | |
1891 | &entries); | |
1892 | if (rval != QLA_SUCCESS) | |
1893 | goto cleanup_allocation; | |
1894 | ||
1895 | DEBUG3(printk("scsi(%ld): Entries in ID list (%d)\n", | |
1896 | ha->host_no, entries)); | |
1897 | DEBUG3(qla2x00_dump_buffer((uint8_t *)ha->gid_list, | |
1898 | entries * sizeof(struct gid_list_info))); | |
1899 | ||
1900 | /* Allocate temporary fcport for any new fcports discovered. */ | |
1901 | new_fcport = qla2x00_alloc_fcport(ha, GFP_KERNEL); | |
1902 | if (new_fcport == NULL) { | |
1903 | rval = QLA_MEMORY_ALLOC_FAILED; | |
1904 | goto cleanup_allocation; | |
1905 | } | |
1906 | new_fcport->flags &= ~FCF_FABRIC_DEVICE; | |
1907 | ||
1908 | /* | |
1909 | * Mark local devices that were present with FCF_DEVICE_LOST for now. | |
1910 | */ | |
1911 | list_for_each_entry(fcport, &ha->fcports, list) { | |
1912 | if (atomic_read(&fcport->state) == FCS_ONLINE && | |
1913 | fcport->port_type != FCT_BROADCAST && | |
1914 | (fcport->flags & FCF_FABRIC_DEVICE) == 0) { | |
1915 | ||
1916 | DEBUG(printk("scsi(%ld): Marking port lost, " | |
1917 | "loop_id=0x%04x\n", | |
1918 | ha->host_no, fcport->loop_id)); | |
1919 | ||
1920 | atomic_set(&fcport->state, FCS_DEVICE_LOST); | |
1921 | fcport->flags &= ~FCF_FARP_DONE; | |
1922 | } | |
1923 | } | |
1924 | ||
1925 | /* Add devices to port list. */ | |
1926 | id_iter = (char *)ha->gid_list; | |
1927 | for (index = 0; index < entries; index++) { | |
1928 | domain = ((struct gid_list_info *)id_iter)->domain; | |
1929 | area = ((struct gid_list_info *)id_iter)->area; | |
1930 | al_pa = ((struct gid_list_info *)id_iter)->al_pa; | |
abbd8870 | 1931 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) |
1da177e4 LT |
1932 | loop_id = (uint16_t) |
1933 | ((struct gid_list_info *)id_iter)->loop_id_2100; | |
abbd8870 | 1934 | else |
1da177e4 LT |
1935 | loop_id = le16_to_cpu( |
1936 | ((struct gid_list_info *)id_iter)->loop_id); | |
abbd8870 | 1937 | id_iter += ha->gid_list_info_size; |
1da177e4 LT |
1938 | |
1939 | /* Bypass reserved domain fields. */ | |
1940 | if ((domain & 0xf0) == 0xf0) | |
1941 | continue; | |
1942 | ||
1943 | /* Bypass if not same domain and area of adapter. */ | |
f7d289f6 AV |
1944 | if (area && domain && |
1945 | (area != ha->d_id.b.area || domain != ha->d_id.b.domain)) | |
1da177e4 LT |
1946 | continue; |
1947 | ||
1948 | /* Bypass invalid local loop ID. */ | |
1949 | if (loop_id > LAST_LOCAL_LOOP_ID) | |
1950 | continue; | |
1951 | ||
1952 | /* Fill in member data. */ | |
1953 | new_fcport->d_id.b.domain = domain; | |
1954 | new_fcport->d_id.b.area = area; | |
1955 | new_fcport->d_id.b.al_pa = al_pa; | |
1956 | new_fcport->loop_id = loop_id; | |
1957 | rval2 = qla2x00_get_port_database(ha, new_fcport, 0); | |
1958 | if (rval2 != QLA_SUCCESS) { | |
1959 | DEBUG2(printk("scsi(%ld): Failed to retrieve fcport " | |
1960 | "information -- get_port_database=%x, " | |
1961 | "loop_id=0x%04x\n", | |
1962 | ha->host_no, rval2, new_fcport->loop_id)); | |
c9d02acf | 1963 | DEBUG2(printk("scsi(%ld): Scheduling resync...\n", |
1964 | ha->host_no)); | |
1965 | set_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags); | |
1da177e4 LT |
1966 | continue; |
1967 | } | |
1968 | ||
1969 | /* Check for matching device in port list. */ | |
1970 | found = 0; | |
1971 | fcport = NULL; | |
1972 | list_for_each_entry(fcport, &ha->fcports, list) { | |
1973 | if (memcmp(new_fcport->port_name, fcport->port_name, | |
1974 | WWN_SIZE)) | |
1975 | continue; | |
1976 | ||
1977 | fcport->flags &= ~(FCF_FABRIC_DEVICE | | |
1978 | FCF_PERSISTENT_BOUND); | |
1979 | fcport->loop_id = new_fcport->loop_id; | |
1980 | fcport->port_type = new_fcport->port_type; | |
1981 | fcport->d_id.b24 = new_fcport->d_id.b24; | |
1982 | memcpy(fcport->node_name, new_fcport->node_name, | |
1983 | WWN_SIZE); | |
1984 | ||
1985 | found++; | |
1986 | break; | |
1987 | } | |
1988 | ||
1989 | if (!found) { | |
1990 | /* New device, add to fcports list. */ | |
1991 | new_fcport->flags &= ~FCF_PERSISTENT_BOUND; | |
1992 | list_add_tail(&new_fcport->list, &ha->fcports); | |
1993 | ||
1994 | /* Allocate a new replacement fcport. */ | |
1995 | fcport = new_fcport; | |
1996 | new_fcport = qla2x00_alloc_fcport(ha, GFP_KERNEL); | |
1997 | if (new_fcport == NULL) { | |
1998 | rval = QLA_MEMORY_ALLOC_FAILED; | |
1999 | goto cleanup_allocation; | |
2000 | } | |
2001 | new_fcport->flags &= ~FCF_FABRIC_DEVICE; | |
2002 | } | |
2003 | ||
d8b45213 AV |
2004 | /* Base iIDMA settings on HBA port speed. */ |
2005 | switch (ha->link_data_rate) { | |
2006 | case PORT_SPEED_1GB: | |
2007 | fcport->fp_speed = cpu_to_be16(BIT_15); | |
2008 | break; | |
2009 | case PORT_SPEED_2GB: | |
2010 | fcport->fp_speed = cpu_to_be16(BIT_14); | |
2011 | break; | |
2012 | case PORT_SPEED_4GB: | |
2013 | fcport->fp_speed = cpu_to_be16(BIT_13); | |
2014 | break; | |
2015 | } | |
2016 | ||
1da177e4 LT |
2017 | qla2x00_update_fcport(ha, fcport); |
2018 | ||
2019 | found_devs++; | |
2020 | } | |
2021 | ||
2022 | cleanup_allocation: | |
c9475cb0 | 2023 | kfree(new_fcport); |
1da177e4 LT |
2024 | |
2025 | if (rval != QLA_SUCCESS) { | |
2026 | DEBUG2(printk("scsi(%ld): Configure local loop error exit: " | |
2027 | "rval=%x\n", ha->host_no, rval)); | |
2028 | } | |
2029 | ||
2030 | if (found_devs) { | |
2031 | ha->device_flags |= DFLG_LOCAL_DEVICES; | |
2032 | ha->device_flags &= ~DFLG_RETRY_LOCAL_DEVICES; | |
2033 | } | |
2034 | ||
2035 | return (rval); | |
2036 | } | |
2037 | ||
2038 | static void | |
fa2a1ce5 | 2039 | qla2x00_probe_for_all_luns(scsi_qla_host_t *ha) |
1da177e4 LT |
2040 | { |
2041 | fc_port_t *fcport; | |
2042 | ||
d97994dc | 2043 | qla2x00_mark_all_devices_lost(ha, 0); |
1da177e4 LT |
2044 | list_for_each_entry(fcport, &ha->fcports, list) { |
2045 | if (fcport->port_type != FCT_TARGET) | |
2046 | continue; | |
2047 | ||
fa2a1ce5 | 2048 | qla2x00_update_fcport(ha, fcport); |
1da177e4 LT |
2049 | } |
2050 | } | |
2051 | ||
d8b45213 AV |
2052 | static void |
2053 | qla2x00_iidma_fcport(scsi_qla_host_t *ha, fc_port_t *fcport) | |
2054 | { | |
2055 | #define LS_UNKNOWN 2 | |
2056 | static char *link_speeds[5] = { "1", "2", "?", "4" }; | |
2057 | int rval; | |
2058 | uint16_t port_speed, mb[6]; | |
2059 | ||
2060 | if (!IS_QLA24XX(ha)) | |
2061 | return; | |
2062 | ||
2063 | switch (be16_to_cpu(fcport->fp_speed)) { | |
2064 | case BIT_15: | |
2065 | port_speed = PORT_SPEED_1GB; | |
2066 | break; | |
2067 | case BIT_14: | |
2068 | port_speed = PORT_SPEED_2GB; | |
2069 | break; | |
2070 | case BIT_13: | |
2071 | port_speed = PORT_SPEED_4GB; | |
2072 | break; | |
2073 | default: | |
2074 | DEBUG2(printk("scsi(%ld): %02x%02x%02x%02x%02x%02x%02x%02x -- " | |
2075 | "unsupported FM port operating speed (%04x).\n", | |
2076 | ha->host_no, fcport->port_name[0], fcport->port_name[1], | |
2077 | fcport->port_name[2], fcport->port_name[3], | |
2078 | fcport->port_name[4], fcport->port_name[5], | |
2079 | fcport->port_name[6], fcport->port_name[7], | |
2080 | be16_to_cpu(fcport->fp_speed))); | |
2081 | port_speed = PORT_SPEED_UNKNOWN; | |
2082 | break; | |
2083 | } | |
2084 | if (port_speed == PORT_SPEED_UNKNOWN) | |
2085 | return; | |
2086 | ||
2087 | rval = qla2x00_set_idma_speed(ha, fcport->loop_id, port_speed, mb); | |
2088 | if (rval != QLA_SUCCESS) { | |
2089 | DEBUG2(printk("scsi(%ld): Unable to adjust iIDMA " | |
2090 | "%02x%02x%02x%02x%02x%02x%02x%02x -- %04x %x %04x %04x.\n", | |
2091 | ha->host_no, fcport->port_name[0], fcport->port_name[1], | |
2092 | fcport->port_name[2], fcport->port_name[3], | |
2093 | fcport->port_name[4], fcport->port_name[5], | |
2094 | fcport->port_name[6], fcport->port_name[7], rval, | |
2095 | port_speed, mb[0], mb[1])); | |
2096 | } else { | |
2097 | DEBUG2(qla_printk(KERN_INFO, ha, | |
2098 | "iIDMA adjusted to %s GB/s on " | |
2099 | "%02x%02x%02x%02x%02x%02x%02x%02x.\n", | |
2100 | link_speeds[port_speed], fcport->port_name[0], | |
2101 | fcport->port_name[1], fcport->port_name[2], | |
2102 | fcport->port_name[3], fcport->port_name[4], | |
2103 | fcport->port_name[5], fcport->port_name[6], | |
2104 | fcport->port_name[7])); | |
2105 | } | |
2106 | } | |
2107 | ||
1da177e4 LT |
2108 | /* |
2109 | * qla2x00_update_fcport | |
2110 | * Updates device on list. | |
2111 | * | |
2112 | * Input: | |
2113 | * ha = adapter block pointer. | |
2114 | * fcport = port structure pointer. | |
2115 | * | |
2116 | * Return: | |
2117 | * 0 - Success | |
2118 | * BIT_0 - error | |
2119 | * | |
2120 | * Context: | |
2121 | * Kernel context. | |
2122 | */ | |
052c40c8 | 2123 | void |
1da177e4 LT |
2124 | qla2x00_update_fcport(scsi_qla_host_t *ha, fc_port_t *fcport) |
2125 | { | |
1da177e4 LT |
2126 | fcport->ha = ha; |
2127 | fcport->login_retry = 0; | |
2128 | fcport->port_login_retry_count = ha->port_down_retry_count * | |
2129 | PORT_RETRY_TIME; | |
2130 | atomic_set(&fcport->port_down_timer, ha->port_down_retry_count * | |
2131 | PORT_RETRY_TIME); | |
2132 | fcport->flags &= ~FCF_LOGIN_NEEDED; | |
2133 | ||
d8b45213 AV |
2134 | qla2x00_iidma_fcport(ha, fcport); |
2135 | ||
1da177e4 | 2136 | atomic_set(&fcport->state, FCS_ONLINE); |
bdf79621 | 2137 | |
d19044c3 | 2138 | qla2x00_reg_remote_port(ha, fcport); |
1da177e4 LT |
2139 | } |
2140 | ||
8482e118 | 2141 | void |
2142 | qla2x00_reg_remote_port(scsi_qla_host_t *ha, fc_port_t *fcport) | |
2143 | { | |
2144 | struct fc_rport_identifiers rport_ids; | |
bdf79621 | 2145 | struct fc_rport *rport; |
d97994dc | 2146 | unsigned long flags; |
8482e118 | 2147 | |
d97994dc | 2148 | if (fcport->drport) |
2149 | qla2x00_rport_del(fcport); | |
2150 | if (fcport->rport) | |
2151 | return; | |
8482e118 | 2152 | |
f8b02a85 AV |
2153 | rport_ids.node_name = wwn_to_u64(fcport->node_name); |
2154 | rport_ids.port_name = wwn_to_u64(fcport->port_name); | |
8482e118 | 2155 | rport_ids.port_id = fcport->d_id.b.domain << 16 | |
2156 | fcport->d_id.b.area << 8 | fcport->d_id.b.al_pa; | |
77d74143 | 2157 | rport_ids.roles = FC_RPORT_ROLE_UNKNOWN; |
d97994dc | 2158 | rport = fc_remote_port_add(ha->host, 0, &rport_ids); |
77d74143 AV |
2159 | if (!rport) { |
2160 | qla_printk(KERN_WARNING, ha, | |
2161 | "Unable to allocate fc remote port!\n"); | |
2162 | return; | |
2163 | } | |
d97994dc | 2164 | spin_lock_irqsave(&fcport->rport_lock, flags); |
2165 | fcport->rport = rport; | |
19a7b4ae | 2166 | *((fc_port_t **)rport->dd_data) = fcport; |
d97994dc | 2167 | spin_unlock_irqrestore(&fcport->rport_lock, flags); |
2168 | ||
ad3e0eda | 2169 | rport->supported_classes = fcport->supported_classes; |
77d74143 | 2170 | |
8482e118 | 2171 | rport_ids.roles = FC_RPORT_ROLE_UNKNOWN; |
2172 | if (fcport->port_type == FCT_INITIATOR) | |
2173 | rport_ids.roles |= FC_RPORT_ROLE_FCP_INITIATOR; | |
2174 | if (fcport->port_type == FCT_TARGET) | |
2175 | rport_ids.roles |= FC_RPORT_ROLE_FCP_TARGET; | |
77d74143 | 2176 | fc_remote_port_rolechg(rport, rport_ids.roles); |
1da177e4 | 2177 | |
cc4731f5 AV |
2178 | if (rport->scsi_target_id != -1 && |
2179 | rport->scsi_target_id < ha->host->max_id) | |
bdf79621 | 2180 | fcport->os_target_id = rport->scsi_target_id; |
1da177e4 LT |
2181 | } |
2182 | ||
1da177e4 LT |
2183 | /* |
2184 | * qla2x00_configure_fabric | |
2185 | * Setup SNS devices with loop ID's. | |
2186 | * | |
2187 | * Input: | |
2188 | * ha = adapter block pointer. | |
2189 | * | |
2190 | * Returns: | |
2191 | * 0 = success. | |
2192 | * BIT_0 = error | |
2193 | */ | |
2194 | static int | |
2195 | qla2x00_configure_fabric(scsi_qla_host_t *ha) | |
2196 | { | |
2197 | int rval, rval2; | |
2198 | fc_port_t *fcport, *fcptemp; | |
2199 | uint16_t next_loopid; | |
2200 | uint16_t mb[MAILBOX_REGISTER_COUNT]; | |
0107109e | 2201 | uint16_t loop_id; |
1da177e4 LT |
2202 | LIST_HEAD(new_fcports); |
2203 | ||
2204 | /* If FL port exists, then SNS is present */ | |
044cc6c8 | 2205 | if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) |
0107109e AV |
2206 | loop_id = NPH_F_PORT; |
2207 | else | |
2208 | loop_id = SNS_FL_PORT; | |
90991c85 | 2209 | rval = qla2x00_get_port_name(ha, loop_id, ha->fabric_node_name, 1); |
1da177e4 LT |
2210 | if (rval != QLA_SUCCESS) { |
2211 | DEBUG2(printk("scsi(%ld): MBC_GET_PORT_NAME Failed, No FL " | |
2212 | "Port\n", ha->host_no)); | |
2213 | ||
2214 | ha->device_flags &= ~SWITCH_FOUND; | |
2215 | return (QLA_SUCCESS); | |
2216 | } | |
90991c85 | 2217 | ha->device_flags |= SWITCH_FOUND; |
1da177e4 LT |
2218 | |
2219 | /* Mark devices that need re-synchronization. */ | |
2220 | rval2 = qla2x00_device_resync(ha); | |
2221 | if (rval2 == QLA_RSCNS_HANDLED) { | |
2222 | /* No point doing the scan, just continue. */ | |
2223 | return (QLA_SUCCESS); | |
2224 | } | |
2225 | do { | |
cca5335c AV |
2226 | /* FDMI support. */ |
2227 | if (ql2xfdmienable && | |
2228 | test_and_clear_bit(REGISTER_FDMI_NEEDED, &ha->dpc_flags)) | |
2229 | qla2x00_fdmi_register(ha); | |
2230 | ||
1da177e4 | 2231 | /* Ensure we are logged into the SNS. */ |
044cc6c8 | 2232 | if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) |
0107109e AV |
2233 | loop_id = NPH_SNS; |
2234 | else | |
2235 | loop_id = SIMPLE_NAME_SERVER; | |
2236 | ha->isp_ops.fabric_login(ha, loop_id, 0xff, 0xff, | |
abbd8870 | 2237 | 0xfc, mb, BIT_1 | BIT_0); |
1da177e4 LT |
2238 | if (mb[0] != MBS_COMMAND_COMPLETE) { |
2239 | DEBUG2(qla_printk(KERN_INFO, ha, | |
2240 | "Failed SNS login: loop_id=%x mb[0]=%x mb[1]=%x " | |
0107109e | 2241 | "mb[2]=%x mb[6]=%x mb[7]=%x\n", loop_id, |
1da177e4 LT |
2242 | mb[0], mb[1], mb[2], mb[6], mb[7])); |
2243 | return (QLA_SUCCESS); | |
2244 | } | |
2245 | ||
2246 | if (test_and_clear_bit(REGISTER_FC4_NEEDED, &ha->dpc_flags)) { | |
2247 | if (qla2x00_rft_id(ha)) { | |
2248 | /* EMPTY */ | |
2249 | DEBUG2(printk("scsi(%ld): Register FC-4 " | |
2250 | "TYPE failed.\n", ha->host_no)); | |
2251 | } | |
2252 | if (qla2x00_rff_id(ha)) { | |
2253 | /* EMPTY */ | |
2254 | DEBUG2(printk("scsi(%ld): Register FC-4 " | |
2255 | "Features failed.\n", ha->host_no)); | |
2256 | } | |
2257 | if (qla2x00_rnn_id(ha)) { | |
2258 | /* EMPTY */ | |
2259 | DEBUG2(printk("scsi(%ld): Register Node Name " | |
2260 | "failed.\n", ha->host_no)); | |
2261 | } else if (qla2x00_rsnn_nn(ha)) { | |
2262 | /* EMPTY */ | |
2263 | DEBUG2(printk("scsi(%ld): Register Symbolic " | |
2264 | "Node Name failed.\n", ha->host_no)); | |
2265 | } | |
2266 | } | |
2267 | ||
2268 | rval = qla2x00_find_all_fabric_devs(ha, &new_fcports); | |
2269 | if (rval != QLA_SUCCESS) | |
2270 | break; | |
2271 | ||
2272 | /* | |
2273 | * Logout all previous fabric devices marked lost, except | |
2274 | * tape devices. | |
2275 | */ | |
2276 | list_for_each_entry(fcport, &ha->fcports, list) { | |
2277 | if (test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags)) | |
2278 | break; | |
2279 | ||
2280 | if ((fcport->flags & FCF_FABRIC_DEVICE) == 0) | |
2281 | continue; | |
2282 | ||
2283 | if (atomic_read(&fcport->state) == FCS_DEVICE_LOST) { | |
2284 | qla2x00_mark_device_lost(ha, fcport, | |
d97994dc | 2285 | ql2xplogiabsentdevice, 0); |
1da177e4 LT |
2286 | if (fcport->loop_id != FC_NO_LOOP_ID && |
2287 | (fcport->flags & FCF_TAPE_PRESENT) == 0 && | |
2288 | fcport->port_type != FCT_INITIATOR && | |
2289 | fcport->port_type != FCT_BROADCAST) { | |
abbd8870 | 2290 | ha->isp_ops.fabric_logout(ha, |
1c7c6357 AV |
2291 | fcport->loop_id, |
2292 | fcport->d_id.b.domain, | |
2293 | fcport->d_id.b.area, | |
2294 | fcport->d_id.b.al_pa); | |
1da177e4 LT |
2295 | fcport->loop_id = FC_NO_LOOP_ID; |
2296 | } | |
2297 | } | |
2298 | } | |
2299 | ||
2300 | /* Starting free loop ID. */ | |
2301 | next_loopid = ha->min_external_loopid; | |
2302 | ||
2303 | /* | |
2304 | * Scan through our port list and login entries that need to be | |
2305 | * logged in. | |
2306 | */ | |
2307 | list_for_each_entry(fcport, &ha->fcports, list) { | |
2308 | if (atomic_read(&ha->loop_down_timer) || | |
2309 | test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags)) | |
2310 | break; | |
2311 | ||
2312 | if ((fcport->flags & FCF_FABRIC_DEVICE) == 0 || | |
2313 | (fcport->flags & FCF_LOGIN_NEEDED) == 0) | |
2314 | continue; | |
2315 | ||
2316 | if (fcport->loop_id == FC_NO_LOOP_ID) { | |
2317 | fcport->loop_id = next_loopid; | |
2318 | rval = qla2x00_find_new_loop_id(ha, fcport); | |
2319 | if (rval != QLA_SUCCESS) { | |
2320 | /* Ran out of IDs to use */ | |
2321 | break; | |
2322 | } | |
2323 | } | |
1da177e4 LT |
2324 | /* Login and update database */ |
2325 | qla2x00_fabric_dev_login(ha, fcport, &next_loopid); | |
2326 | } | |
2327 | ||
2328 | /* Exit if out of loop IDs. */ | |
2329 | if (rval != QLA_SUCCESS) { | |
2330 | break; | |
2331 | } | |
2332 | ||
2333 | /* | |
2334 | * Login and add the new devices to our port list. | |
2335 | */ | |
2336 | list_for_each_entry_safe(fcport, fcptemp, &new_fcports, list) { | |
2337 | if (atomic_read(&ha->loop_down_timer) || | |
2338 | test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags)) | |
2339 | break; | |
2340 | ||
2341 | /* Find a new loop ID to use. */ | |
2342 | fcport->loop_id = next_loopid; | |
2343 | rval = qla2x00_find_new_loop_id(ha, fcport); | |
2344 | if (rval != QLA_SUCCESS) { | |
2345 | /* Ran out of IDs to use */ | |
2346 | break; | |
2347 | } | |
2348 | ||
1da177e4 | 2349 | /* Remove device from the new list and add it to DB */ |
179e0917 | 2350 | list_move_tail(&fcport->list, &ha->fcports); |
bdf79621 | 2351 | |
2352 | /* Login and update database */ | |
2353 | qla2x00_fabric_dev_login(ha, fcport, &next_loopid); | |
1da177e4 LT |
2354 | } |
2355 | } while (0); | |
2356 | ||
2357 | /* Free all new device structures not processed. */ | |
2358 | list_for_each_entry_safe(fcport, fcptemp, &new_fcports, list) { | |
2359 | list_del(&fcport->list); | |
2360 | kfree(fcport); | |
2361 | } | |
2362 | ||
2363 | if (rval) { | |
2364 | DEBUG2(printk("scsi(%ld): Configure fabric error exit: " | |
2365 | "rval=%d\n", ha->host_no, rval)); | |
2366 | } | |
2367 | ||
2368 | return (rval); | |
2369 | } | |
2370 | ||
2371 | ||
2372 | /* | |
2373 | * qla2x00_find_all_fabric_devs | |
2374 | * | |
2375 | * Input: | |
2376 | * ha = adapter block pointer. | |
2377 | * dev = database device entry pointer. | |
2378 | * | |
2379 | * Returns: | |
2380 | * 0 = success. | |
2381 | * | |
2382 | * Context: | |
2383 | * Kernel context. | |
2384 | */ | |
2385 | static int | |
2386 | qla2x00_find_all_fabric_devs(scsi_qla_host_t *ha, struct list_head *new_fcports) | |
2387 | { | |
2388 | int rval; | |
2389 | uint16_t loop_id; | |
2390 | fc_port_t *fcport, *new_fcport, *fcptemp; | |
2391 | int found; | |
2392 | ||
2393 | sw_info_t *swl; | |
2394 | int swl_idx; | |
2395 | int first_dev, last_dev; | |
2396 | port_id_t wrap, nxt_d_id; | |
2397 | ||
2398 | rval = QLA_SUCCESS; | |
2399 | ||
2400 | /* Try GID_PT to get device list, else GAN. */ | |
2401 | swl = kmalloc(sizeof(sw_info_t) * MAX_FIBRE_DEVICES, GFP_ATOMIC); | |
2402 | if (swl == NULL) { | |
2403 | /*EMPTY*/ | |
2404 | DEBUG2(printk("scsi(%ld): GID_PT allocations failed, fallback " | |
2405 | "on GA_NXT\n", ha->host_no)); | |
2406 | } else { | |
2407 | memset(swl, 0, sizeof(sw_info_t) * MAX_FIBRE_DEVICES); | |
2408 | if (qla2x00_gid_pt(ha, swl) != QLA_SUCCESS) { | |
2409 | kfree(swl); | |
2410 | swl = NULL; | |
2411 | } else if (qla2x00_gpn_id(ha, swl) != QLA_SUCCESS) { | |
2412 | kfree(swl); | |
2413 | swl = NULL; | |
2414 | } else if (qla2x00_gnn_id(ha, swl) != QLA_SUCCESS) { | |
2415 | kfree(swl); | |
2416 | swl = NULL; | |
d8b45213 AV |
2417 | } else if (qla2x00_gfpn_id(ha, swl) == QLA_SUCCESS) { |
2418 | qla2x00_gpsc(ha, swl); | |
1da177e4 LT |
2419 | } |
2420 | } | |
2421 | swl_idx = 0; | |
2422 | ||
2423 | /* Allocate temporary fcport for any new fcports discovered. */ | |
2424 | new_fcport = qla2x00_alloc_fcport(ha, GFP_KERNEL); | |
2425 | if (new_fcport == NULL) { | |
c9475cb0 | 2426 | kfree(swl); |
1da177e4 LT |
2427 | return (QLA_MEMORY_ALLOC_FAILED); |
2428 | } | |
2429 | new_fcport->flags |= (FCF_FABRIC_DEVICE | FCF_LOGIN_NEEDED); | |
2430 | ||
2431 | /* Set start port ID scan at adapter ID. */ | |
2432 | first_dev = 1; | |
2433 | last_dev = 0; | |
2434 | ||
2435 | /* Starting free loop ID. */ | |
2436 | loop_id = ha->min_external_loopid; | |
1da177e4 | 2437 | for (; loop_id <= ha->last_loop_id; loop_id++) { |
3d71644c | 2438 | if (qla2x00_is_reserved_id(ha, loop_id)) |
1da177e4 LT |
2439 | continue; |
2440 | ||
23443b1d | 2441 | if (atomic_read(&ha->loop_down_timer) || LOOP_TRANSITION(ha)) |
1da177e4 LT |
2442 | break; |
2443 | ||
2444 | if (swl != NULL) { | |
2445 | if (last_dev) { | |
2446 | wrap.b24 = new_fcport->d_id.b24; | |
2447 | } else { | |
2448 | new_fcport->d_id.b24 = swl[swl_idx].d_id.b24; | |
2449 | memcpy(new_fcport->node_name, | |
2450 | swl[swl_idx].node_name, WWN_SIZE); | |
2451 | memcpy(new_fcport->port_name, | |
2452 | swl[swl_idx].port_name, WWN_SIZE); | |
d8b45213 AV |
2453 | memcpy(new_fcport->fabric_port_name, |
2454 | swl[swl_idx].fabric_port_name, WWN_SIZE); | |
2455 | new_fcport->fp_speed = swl[swl_idx].fp_speed; | |
1da177e4 LT |
2456 | |
2457 | if (swl[swl_idx].d_id.b.rsvd_1 != 0) { | |
2458 | last_dev = 1; | |
2459 | } | |
2460 | swl_idx++; | |
2461 | } | |
2462 | } else { | |
2463 | /* Send GA_NXT to the switch */ | |
2464 | rval = qla2x00_ga_nxt(ha, new_fcport); | |
2465 | if (rval != QLA_SUCCESS) { | |
2466 | qla_printk(KERN_WARNING, ha, | |
2467 | "SNS scan failed -- assuming zero-entry " | |
2468 | "result...\n"); | |
2469 | list_for_each_entry_safe(fcport, fcptemp, | |
2470 | new_fcports, list) { | |
2471 | list_del(&fcport->list); | |
2472 | kfree(fcport); | |
2473 | } | |
2474 | rval = QLA_SUCCESS; | |
2475 | break; | |
2476 | } | |
2477 | } | |
2478 | ||
2479 | /* If wrap on switch device list, exit. */ | |
2480 | if (first_dev) { | |
2481 | wrap.b24 = new_fcport->d_id.b24; | |
2482 | first_dev = 0; | |
2483 | } else if (new_fcport->d_id.b24 == wrap.b24) { | |
2484 | DEBUG2(printk("scsi(%ld): device wrap (%02x%02x%02x)\n", | |
2485 | ha->host_no, new_fcport->d_id.b.domain, | |
2486 | new_fcport->d_id.b.area, new_fcport->d_id.b.al_pa)); | |
2487 | break; | |
2488 | } | |
2489 | ||
2490 | /* Bypass if host adapter. */ | |
2491 | if (new_fcport->d_id.b24 == ha->d_id.b24) | |
2492 | continue; | |
2493 | ||
f7d289f6 AV |
2494 | /* Bypass if same domain and area of adapter. */ |
2495 | if (((new_fcport->d_id.b24 & 0xffff00) == | |
2496 | (ha->d_id.b24 & 0xffff00)) && ha->current_topology == | |
2497 | ISP_CFG_FL) | |
2498 | continue; | |
2499 | ||
1da177e4 LT |
2500 | /* Bypass reserved domain fields. */ |
2501 | if ((new_fcport->d_id.b.domain & 0xf0) == 0xf0) | |
2502 | continue; | |
2503 | ||
2504 | /* Locate matching device in database. */ | |
2505 | found = 0; | |
2506 | list_for_each_entry(fcport, &ha->fcports, list) { | |
2507 | if (memcmp(new_fcport->port_name, fcport->port_name, | |
2508 | WWN_SIZE)) | |
2509 | continue; | |
2510 | ||
2511 | found++; | |
2512 | ||
d8b45213 AV |
2513 | /* Update port state. */ |
2514 | memcpy(fcport->fabric_port_name, | |
2515 | new_fcport->fabric_port_name, WWN_SIZE); | |
2516 | fcport->fp_speed = new_fcport->fp_speed; | |
2517 | ||
1da177e4 LT |
2518 | /* |
2519 | * If address the same and state FCS_ONLINE, nothing | |
2520 | * changed. | |
2521 | */ | |
2522 | if (fcport->d_id.b24 == new_fcport->d_id.b24 && | |
2523 | atomic_read(&fcport->state) == FCS_ONLINE) { | |
2524 | break; | |
2525 | } | |
2526 | ||
2527 | /* | |
2528 | * If device was not a fabric device before. | |
2529 | */ | |
2530 | if ((fcport->flags & FCF_FABRIC_DEVICE) == 0) { | |
2531 | fcport->d_id.b24 = new_fcport->d_id.b24; | |
2532 | fcport->loop_id = FC_NO_LOOP_ID; | |
2533 | fcport->flags |= (FCF_FABRIC_DEVICE | | |
2534 | FCF_LOGIN_NEEDED); | |
2535 | fcport->flags &= ~FCF_PERSISTENT_BOUND; | |
2536 | break; | |
2537 | } | |
2538 | ||
2539 | /* | |
2540 | * Port ID changed or device was marked to be updated; | |
2541 | * Log it out if still logged in and mark it for | |
2542 | * relogin later. | |
2543 | */ | |
2544 | fcport->d_id.b24 = new_fcport->d_id.b24; | |
2545 | fcport->flags |= FCF_LOGIN_NEEDED; | |
2546 | if (fcport->loop_id != FC_NO_LOOP_ID && | |
2547 | (fcport->flags & FCF_TAPE_PRESENT) == 0 && | |
2548 | fcport->port_type != FCT_INITIATOR && | |
2549 | fcport->port_type != FCT_BROADCAST) { | |
1c7c6357 AV |
2550 | ha->isp_ops.fabric_logout(ha, fcport->loop_id, |
2551 | fcport->d_id.b.domain, fcport->d_id.b.area, | |
2552 | fcport->d_id.b.al_pa); | |
1da177e4 LT |
2553 | fcport->loop_id = FC_NO_LOOP_ID; |
2554 | } | |
2555 | ||
2556 | break; | |
2557 | } | |
2558 | ||
2559 | if (found) | |
2560 | continue; | |
2561 | ||
2562 | /* If device was not in our fcports list, then add it. */ | |
2563 | list_add_tail(&new_fcport->list, new_fcports); | |
2564 | ||
2565 | /* Allocate a new replacement fcport. */ | |
2566 | nxt_d_id.b24 = new_fcport->d_id.b24; | |
2567 | new_fcport = qla2x00_alloc_fcport(ha, GFP_KERNEL); | |
2568 | if (new_fcport == NULL) { | |
c9475cb0 | 2569 | kfree(swl); |
1da177e4 LT |
2570 | return (QLA_MEMORY_ALLOC_FAILED); |
2571 | } | |
2572 | new_fcport->flags |= (FCF_FABRIC_DEVICE | FCF_LOGIN_NEEDED); | |
2573 | new_fcport->d_id.b24 = nxt_d_id.b24; | |
2574 | } | |
2575 | ||
c9475cb0 JJ |
2576 | kfree(swl); |
2577 | kfree(new_fcport); | |
1da177e4 LT |
2578 | |
2579 | if (!list_empty(new_fcports)) | |
2580 | ha->device_flags |= DFLG_FABRIC_DEVICES; | |
2581 | ||
2582 | return (rval); | |
2583 | } | |
2584 | ||
2585 | /* | |
2586 | * qla2x00_find_new_loop_id | |
2587 | * Scan through our port list and find a new usable loop ID. | |
2588 | * | |
2589 | * Input: | |
2590 | * ha: adapter state pointer. | |
2591 | * dev: port structure pointer. | |
2592 | * | |
2593 | * Returns: | |
2594 | * qla2x00 local function return status code. | |
2595 | * | |
2596 | * Context: | |
2597 | * Kernel context. | |
2598 | */ | |
413975a0 | 2599 | static int |
1da177e4 LT |
2600 | qla2x00_find_new_loop_id(scsi_qla_host_t *ha, fc_port_t *dev) |
2601 | { | |
2602 | int rval; | |
2603 | int found; | |
2604 | fc_port_t *fcport; | |
2605 | uint16_t first_loop_id; | |
2606 | ||
2607 | rval = QLA_SUCCESS; | |
2608 | ||
2609 | /* Save starting loop ID. */ | |
2610 | first_loop_id = dev->loop_id; | |
2611 | ||
2612 | for (;;) { | |
2613 | /* Skip loop ID if already used by adapter. */ | |
2614 | if (dev->loop_id == ha->loop_id) { | |
2615 | dev->loop_id++; | |
2616 | } | |
2617 | ||
2618 | /* Skip reserved loop IDs. */ | |
3d71644c | 2619 | while (qla2x00_is_reserved_id(ha, dev->loop_id)) { |
1da177e4 LT |
2620 | dev->loop_id++; |
2621 | } | |
2622 | ||
2623 | /* Reset loop ID if passed the end. */ | |
2624 | if (dev->loop_id > ha->last_loop_id) { | |
2625 | /* first loop ID. */ | |
2626 | dev->loop_id = ha->min_external_loopid; | |
2627 | } | |
2628 | ||
2629 | /* Check for loop ID being already in use. */ | |
2630 | found = 0; | |
2631 | fcport = NULL; | |
2632 | list_for_each_entry(fcport, &ha->fcports, list) { | |
2633 | if (fcport->loop_id == dev->loop_id && fcport != dev) { | |
2634 | /* ID possibly in use */ | |
2635 | found++; | |
2636 | break; | |
2637 | } | |
2638 | } | |
2639 | ||
2640 | /* If not in use then it is free to use. */ | |
2641 | if (!found) { | |
2642 | break; | |
2643 | } | |
2644 | ||
2645 | /* ID in use. Try next value. */ | |
2646 | dev->loop_id++; | |
2647 | ||
2648 | /* If wrap around. No free ID to use. */ | |
2649 | if (dev->loop_id == first_loop_id) { | |
2650 | dev->loop_id = FC_NO_LOOP_ID; | |
2651 | rval = QLA_FUNCTION_FAILED; | |
2652 | break; | |
2653 | } | |
2654 | } | |
2655 | ||
2656 | return (rval); | |
2657 | } | |
2658 | ||
2659 | /* | |
2660 | * qla2x00_device_resync | |
2661 | * Marks devices in the database that needs resynchronization. | |
2662 | * | |
2663 | * Input: | |
2664 | * ha = adapter block pointer. | |
2665 | * | |
2666 | * Context: | |
2667 | * Kernel context. | |
2668 | */ | |
2669 | static int | |
fa2a1ce5 | 2670 | qla2x00_device_resync(scsi_qla_host_t *ha) |
1da177e4 LT |
2671 | { |
2672 | int rval; | |
1da177e4 LT |
2673 | uint32_t mask; |
2674 | fc_port_t *fcport; | |
2675 | uint32_t rscn_entry; | |
2676 | uint8_t rscn_out_iter; | |
2677 | uint8_t format; | |
2678 | port_id_t d_id; | |
2679 | ||
2680 | rval = QLA_RSCNS_HANDLED; | |
2681 | ||
2682 | while (ha->rscn_out_ptr != ha->rscn_in_ptr || | |
2683 | ha->flags.rscn_queue_overflow) { | |
2684 | ||
2685 | rscn_entry = ha->rscn_queue[ha->rscn_out_ptr]; | |
2686 | format = MSB(MSW(rscn_entry)); | |
2687 | d_id.b.domain = LSB(MSW(rscn_entry)); | |
2688 | d_id.b.area = MSB(LSW(rscn_entry)); | |
2689 | d_id.b.al_pa = LSB(LSW(rscn_entry)); | |
2690 | ||
2691 | DEBUG(printk("scsi(%ld): RSCN queue entry[%d] = " | |
2692 | "[%02x/%02x%02x%02x].\n", | |
2693 | ha->host_no, ha->rscn_out_ptr, format, d_id.b.domain, | |
2694 | d_id.b.area, d_id.b.al_pa)); | |
2695 | ||
2696 | ha->rscn_out_ptr++; | |
2697 | if (ha->rscn_out_ptr == MAX_RSCN_COUNT) | |
2698 | ha->rscn_out_ptr = 0; | |
2699 | ||
2700 | /* Skip duplicate entries. */ | |
2701 | for (rscn_out_iter = ha->rscn_out_ptr; | |
2702 | !ha->flags.rscn_queue_overflow && | |
2703 | rscn_out_iter != ha->rscn_in_ptr; | |
2704 | rscn_out_iter = (rscn_out_iter == | |
2705 | (MAX_RSCN_COUNT - 1)) ? 0: rscn_out_iter + 1) { | |
2706 | ||
2707 | if (rscn_entry != ha->rscn_queue[rscn_out_iter]) | |
2708 | break; | |
2709 | ||
2710 | DEBUG(printk("scsi(%ld): Skipping duplicate RSCN queue " | |
2711 | "entry found at [%d].\n", ha->host_no, | |
2712 | rscn_out_iter)); | |
2713 | ||
2714 | ha->rscn_out_ptr = rscn_out_iter; | |
2715 | } | |
2716 | ||
2717 | /* Queue overflow, set switch default case. */ | |
2718 | if (ha->flags.rscn_queue_overflow) { | |
2719 | DEBUG(printk("scsi(%ld): device_resync: rscn " | |
2720 | "overflow.\n", ha->host_no)); | |
2721 | ||
2722 | format = 3; | |
2723 | ha->flags.rscn_queue_overflow = 0; | |
2724 | } | |
2725 | ||
2726 | switch (format) { | |
2727 | case 0: | |
1da177e4 LT |
2728 | mask = 0xffffff; |
2729 | break; | |
2730 | case 1: | |
2731 | mask = 0xffff00; | |
2732 | break; | |
2733 | case 2: | |
2734 | mask = 0xff0000; | |
2735 | break; | |
2736 | default: | |
2737 | mask = 0x0; | |
2738 | d_id.b24 = 0; | |
2739 | ha->rscn_out_ptr = ha->rscn_in_ptr; | |
2740 | break; | |
2741 | } | |
2742 | ||
2743 | rval = QLA_SUCCESS; | |
2744 | ||
1da177e4 LT |
2745 | list_for_each_entry(fcport, &ha->fcports, list) { |
2746 | if ((fcport->flags & FCF_FABRIC_DEVICE) == 0 || | |
2747 | (fcport->d_id.b24 & mask) != d_id.b24 || | |
2748 | fcport->port_type == FCT_BROADCAST) | |
2749 | continue; | |
2750 | ||
2751 | if (atomic_read(&fcport->state) == FCS_ONLINE) { | |
2752 | if (format != 3 || | |
2753 | fcport->port_type != FCT_INITIATOR) { | |
d97994dc | 2754 | qla2x00_mark_device_lost(ha, fcport, |
2755 | 0, 0); | |
1da177e4 LT |
2756 | } |
2757 | } | |
2758 | fcport->flags &= ~FCF_FARP_DONE; | |
2759 | } | |
2760 | } | |
2761 | return (rval); | |
2762 | } | |
2763 | ||
2764 | /* | |
2765 | * qla2x00_fabric_dev_login | |
2766 | * Login fabric target device and update FC port database. | |
2767 | * | |
2768 | * Input: | |
2769 | * ha: adapter state pointer. | |
2770 | * fcport: port structure list pointer. | |
2771 | * next_loopid: contains value of a new loop ID that can be used | |
2772 | * by the next login attempt. | |
2773 | * | |
2774 | * Returns: | |
2775 | * qla2x00 local function return status code. | |
2776 | * | |
2777 | * Context: | |
2778 | * Kernel context. | |
2779 | */ | |
2780 | static int | |
2781 | qla2x00_fabric_dev_login(scsi_qla_host_t *ha, fc_port_t *fcport, | |
2782 | uint16_t *next_loopid) | |
2783 | { | |
2784 | int rval; | |
2785 | int retry; | |
0107109e | 2786 | uint8_t opts; |
1da177e4 LT |
2787 | |
2788 | rval = QLA_SUCCESS; | |
2789 | retry = 0; | |
2790 | ||
2791 | rval = qla2x00_fabric_login(ha, fcport, next_loopid); | |
2792 | if (rval == QLA_SUCCESS) { | |
0107109e AV |
2793 | /* Send an ADISC to tape devices.*/ |
2794 | opts = 0; | |
2795 | if (fcport->flags & FCF_TAPE_PRESENT) | |
2796 | opts |= BIT_1; | |
2797 | rval = qla2x00_get_port_database(ha, fcport, opts); | |
1da177e4 | 2798 | if (rval != QLA_SUCCESS) { |
1c7c6357 AV |
2799 | ha->isp_ops.fabric_logout(ha, fcport->loop_id, |
2800 | fcport->d_id.b.domain, fcport->d_id.b.area, | |
2801 | fcport->d_id.b.al_pa); | |
d97994dc | 2802 | qla2x00_mark_device_lost(ha, fcport, 1, 0); |
1da177e4 LT |
2803 | } else { |
2804 | qla2x00_update_fcport(ha, fcport); | |
2805 | } | |
2806 | } | |
2807 | ||
2808 | return (rval); | |
2809 | } | |
2810 | ||
2811 | /* | |
2812 | * qla2x00_fabric_login | |
2813 | * Issue fabric login command. | |
2814 | * | |
2815 | * Input: | |
2816 | * ha = adapter block pointer. | |
2817 | * device = pointer to FC device type structure. | |
2818 | * | |
2819 | * Returns: | |
2820 | * 0 - Login successfully | |
2821 | * 1 - Login failed | |
2822 | * 2 - Initiator device | |
2823 | * 3 - Fatal error | |
2824 | */ | |
2825 | int | |
2826 | qla2x00_fabric_login(scsi_qla_host_t *ha, fc_port_t *fcport, | |
2827 | uint16_t *next_loopid) | |
2828 | { | |
2829 | int rval; | |
2830 | int retry; | |
2831 | uint16_t tmp_loopid; | |
2832 | uint16_t mb[MAILBOX_REGISTER_COUNT]; | |
2833 | ||
2834 | retry = 0; | |
2835 | tmp_loopid = 0; | |
2836 | ||
2837 | for (;;) { | |
2838 | DEBUG(printk("scsi(%ld): Trying Fabric Login w/loop id 0x%04x " | |
2839 | "for port %02x%02x%02x.\n", | |
2840 | ha->host_no, fcport->loop_id, fcport->d_id.b.domain, | |
2841 | fcport->d_id.b.area, fcport->d_id.b.al_pa)); | |
2842 | ||
2843 | /* Login fcport on switch. */ | |
abbd8870 | 2844 | ha->isp_ops.fabric_login(ha, fcport->loop_id, |
1da177e4 LT |
2845 | fcport->d_id.b.domain, fcport->d_id.b.area, |
2846 | fcport->d_id.b.al_pa, mb, BIT_0); | |
2847 | if (mb[0] == MBS_PORT_ID_USED) { | |
2848 | /* | |
2849 | * Device has another loop ID. The firmware team | |
0107109e AV |
2850 | * recommends the driver perform an implicit login with |
2851 | * the specified ID again. The ID we just used is save | |
2852 | * here so we return with an ID that can be tried by | |
2853 | * the next login. | |
1da177e4 LT |
2854 | */ |
2855 | retry++; | |
2856 | tmp_loopid = fcport->loop_id; | |
2857 | fcport->loop_id = mb[1]; | |
2858 | ||
2859 | DEBUG(printk("Fabric Login: port in use - next " | |
2860 | "loop id=0x%04x, port Id=%02x%02x%02x.\n", | |
2861 | fcport->loop_id, fcport->d_id.b.domain, | |
2862 | fcport->d_id.b.area, fcport->d_id.b.al_pa)); | |
2863 | ||
2864 | } else if (mb[0] == MBS_COMMAND_COMPLETE) { | |
2865 | /* | |
2866 | * Login succeeded. | |
2867 | */ | |
2868 | if (retry) { | |
2869 | /* A retry occurred before. */ | |
2870 | *next_loopid = tmp_loopid; | |
2871 | } else { | |
2872 | /* | |
2873 | * No retry occurred before. Just increment the | |
2874 | * ID value for next login. | |
2875 | */ | |
2876 | *next_loopid = (fcport->loop_id + 1); | |
2877 | } | |
2878 | ||
2879 | if (mb[1] & BIT_0) { | |
2880 | fcport->port_type = FCT_INITIATOR; | |
2881 | } else { | |
2882 | fcport->port_type = FCT_TARGET; | |
2883 | if (mb[1] & BIT_1) { | |
2884 | fcport->flags |= FCF_TAPE_PRESENT; | |
2885 | } | |
2886 | } | |
2887 | ||
ad3e0eda AV |
2888 | if (mb[10] & BIT_0) |
2889 | fcport->supported_classes |= FC_COS_CLASS2; | |
2890 | if (mb[10] & BIT_1) | |
2891 | fcport->supported_classes |= FC_COS_CLASS3; | |
2892 | ||
1da177e4 LT |
2893 | rval = QLA_SUCCESS; |
2894 | break; | |
2895 | } else if (mb[0] == MBS_LOOP_ID_USED) { | |
2896 | /* | |
2897 | * Loop ID already used, try next loop ID. | |
2898 | */ | |
2899 | fcport->loop_id++; | |
2900 | rval = qla2x00_find_new_loop_id(ha, fcport); | |
2901 | if (rval != QLA_SUCCESS) { | |
2902 | /* Ran out of loop IDs to use */ | |
2903 | break; | |
2904 | } | |
2905 | } else if (mb[0] == MBS_COMMAND_ERROR) { | |
2906 | /* | |
2907 | * Firmware possibly timed out during login. If NO | |
2908 | * retries are left to do then the device is declared | |
2909 | * dead. | |
2910 | */ | |
2911 | *next_loopid = fcport->loop_id; | |
1c7c6357 AV |
2912 | ha->isp_ops.fabric_logout(ha, fcport->loop_id, |
2913 | fcport->d_id.b.domain, fcport->d_id.b.area, | |
2914 | fcport->d_id.b.al_pa); | |
d97994dc | 2915 | qla2x00_mark_device_lost(ha, fcport, 1, 0); |
1da177e4 LT |
2916 | |
2917 | rval = 1; | |
2918 | break; | |
2919 | } else { | |
2920 | /* | |
2921 | * unrecoverable / not handled error | |
2922 | */ | |
2923 | DEBUG2(printk("%s(%ld): failed=%x port_id=%02x%02x%02x " | |
fa2a1ce5 AV |
2924 | "loop_id=%x jiffies=%lx.\n", |
2925 | __func__, ha->host_no, mb[0], | |
1da177e4 LT |
2926 | fcport->d_id.b.domain, fcport->d_id.b.area, |
2927 | fcport->d_id.b.al_pa, fcport->loop_id, jiffies)); | |
2928 | ||
2929 | *next_loopid = fcport->loop_id; | |
1c7c6357 AV |
2930 | ha->isp_ops.fabric_logout(ha, fcport->loop_id, |
2931 | fcport->d_id.b.domain, fcport->d_id.b.area, | |
2932 | fcport->d_id.b.al_pa); | |
1da177e4 | 2933 | fcport->loop_id = FC_NO_LOOP_ID; |
0eedfcf0 | 2934 | fcport->login_retry = 0; |
1da177e4 LT |
2935 | |
2936 | rval = 3; | |
2937 | break; | |
2938 | } | |
2939 | } | |
2940 | ||
2941 | return (rval); | |
2942 | } | |
2943 | ||
2944 | /* | |
2945 | * qla2x00_local_device_login | |
2946 | * Issue local device login command. | |
2947 | * | |
2948 | * Input: | |
2949 | * ha = adapter block pointer. | |
2950 | * loop_id = loop id of device to login to. | |
2951 | * | |
2952 | * Returns (Where's the #define!!!!): | |
2953 | * 0 - Login successfully | |
2954 | * 1 - Login failed | |
2955 | * 3 - Fatal error | |
2956 | */ | |
2957 | int | |
9a52a57c | 2958 | qla2x00_local_device_login(scsi_qla_host_t *ha, fc_port_t *fcport) |
1da177e4 LT |
2959 | { |
2960 | int rval; | |
2961 | uint16_t mb[MAILBOX_REGISTER_COUNT]; | |
2962 | ||
2963 | memset(mb, 0, sizeof(mb)); | |
9a52a57c | 2964 | rval = qla2x00_login_local_device(ha, fcport, mb, BIT_0); |
1da177e4 LT |
2965 | if (rval == QLA_SUCCESS) { |
2966 | /* Interrogate mailbox registers for any errors */ | |
2967 | if (mb[0] == MBS_COMMAND_ERROR) | |
2968 | rval = 1; | |
2969 | else if (mb[0] == MBS_COMMAND_PARAMETER_ERROR) | |
2970 | /* device not in PCB table */ | |
2971 | rval = 3; | |
2972 | } | |
2973 | ||
2974 | return (rval); | |
2975 | } | |
2976 | ||
2977 | /* | |
2978 | * qla2x00_loop_resync | |
2979 | * Resync with fibre channel devices. | |
2980 | * | |
2981 | * Input: | |
2982 | * ha = adapter block pointer. | |
2983 | * | |
2984 | * Returns: | |
2985 | * 0 = success | |
2986 | */ | |
2987 | int | |
fa2a1ce5 | 2988 | qla2x00_loop_resync(scsi_qla_host_t *ha) |
1da177e4 LT |
2989 | { |
2990 | int rval; | |
2991 | uint32_t wait_time; | |
2992 | ||
2993 | rval = QLA_SUCCESS; | |
2994 | ||
2995 | atomic_set(&ha->loop_state, LOOP_UPDATE); | |
1da177e4 LT |
2996 | clear_bit(ISP_ABORT_RETRY, &ha->dpc_flags); |
2997 | if (ha->flags.online) { | |
2998 | if (!(rval = qla2x00_fw_ready(ha))) { | |
2999 | /* Wait at most MAX_TARGET RSCNs for a stable link. */ | |
3000 | wait_time = 256; | |
3001 | do { | |
1da177e4 LT |
3002 | atomic_set(&ha->loop_state, LOOP_UPDATE); |
3003 | ||
0107109e AV |
3004 | /* Issue a marker after FW becomes ready. */ |
3005 | qla2x00_marker(ha, 0, 0, MK_SYNC_ALL); | |
3006 | ha->marker_needed = 0; | |
1da177e4 LT |
3007 | |
3008 | /* Remap devices on Loop. */ | |
3009 | clear_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags); | |
3010 | ||
3011 | qla2x00_configure_loop(ha); | |
3012 | wait_time--; | |
3013 | } while (!atomic_read(&ha->loop_down_timer) && | |
3014 | !(test_bit(ISP_ABORT_NEEDED, &ha->dpc_flags)) && | |
3015 | wait_time && | |
3016 | (test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags))); | |
3017 | } | |
1da177e4 LT |
3018 | } |
3019 | ||
3020 | if (test_bit(ISP_ABORT_NEEDED, &ha->dpc_flags)) { | |
3021 | return (QLA_FUNCTION_FAILED); | |
3022 | } | |
3023 | ||
3024 | if (rval) { | |
3025 | DEBUG2_3(printk("%s(): **** FAILED ****\n", __func__)); | |
3026 | } | |
3027 | ||
3028 | return (rval); | |
3029 | } | |
3030 | ||
1da177e4 LT |
3031 | void |
3032 | qla2x00_rescan_fcports(scsi_qla_host_t *ha) | |
3033 | { | |
3034 | int rescan_done; | |
3035 | fc_port_t *fcport; | |
3036 | ||
3037 | rescan_done = 0; | |
3038 | list_for_each_entry(fcport, &ha->fcports, list) { | |
3039 | if ((fcport->flags & FCF_RESCAN_NEEDED) == 0) | |
3040 | continue; | |
3041 | ||
3042 | qla2x00_update_fcport(ha, fcport); | |
3043 | fcport->flags &= ~FCF_RESCAN_NEEDED; | |
3044 | ||
3045 | rescan_done = 1; | |
3046 | } | |
fa2a1ce5 | 3047 | qla2x00_probe_for_all_luns(ha); |
1da177e4 LT |
3048 | } |
3049 | ||
d97994dc | 3050 | void |
3051 | qla2x00_update_fcports(scsi_qla_host_t *ha) | |
3052 | { | |
3053 | fc_port_t *fcport; | |
3054 | ||
3055 | /* Go with deferred removal of rport references. */ | |
3056 | list_for_each_entry(fcport, &ha->fcports, list) | |
3057 | if (fcport->drport) | |
3058 | qla2x00_rport_del(fcport); | |
3059 | } | |
3060 | ||
1da177e4 LT |
3061 | /* |
3062 | * qla2x00_abort_isp | |
3063 | * Resets ISP and aborts all outstanding commands. | |
3064 | * | |
3065 | * Input: | |
3066 | * ha = adapter block pointer. | |
3067 | * | |
3068 | * Returns: | |
3069 | * 0 = success | |
3070 | */ | |
3071 | int | |
3072 | qla2x00_abort_isp(scsi_qla_host_t *ha) | |
3073 | { | |
476e8978 | 3074 | int rval; |
1da177e4 LT |
3075 | unsigned long flags = 0; |
3076 | uint16_t cnt; | |
3077 | srb_t *sp; | |
3078 | uint8_t status = 0; | |
3079 | ||
3080 | if (ha->flags.online) { | |
3081 | ha->flags.online = 0; | |
3082 | clear_bit(ISP_ABORT_NEEDED, &ha->dpc_flags); | |
1da177e4 LT |
3083 | |
3084 | qla_printk(KERN_INFO, ha, | |
3085 | "Performing ISP error recovery - ha= %p.\n", ha); | |
abbd8870 | 3086 | ha->isp_ops.reset_chip(ha); |
1da177e4 LT |
3087 | |
3088 | atomic_set(&ha->loop_down_timer, LOOP_DOWN_TIME); | |
3089 | if (atomic_read(&ha->loop_state) != LOOP_DOWN) { | |
3090 | atomic_set(&ha->loop_state, LOOP_DOWN); | |
d97994dc | 3091 | qla2x00_mark_all_devices_lost(ha, 0); |
1da177e4 LT |
3092 | } else { |
3093 | if (!atomic_read(&ha->loop_down_timer)) | |
3094 | atomic_set(&ha->loop_down_timer, | |
3095 | LOOP_DOWN_TIME); | |
3096 | } | |
3097 | ||
3098 | spin_lock_irqsave(&ha->hardware_lock, flags); | |
3099 | /* Requeue all commands in outstanding command list. */ | |
3100 | for (cnt = 1; cnt < MAX_OUTSTANDING_COMMANDS; cnt++) { | |
3101 | sp = ha->outstanding_cmds[cnt]; | |
3102 | if (sp) { | |
3103 | ha->outstanding_cmds[cnt] = NULL; | |
1da177e4 | 3104 | sp->flags = 0; |
f4f051eb | 3105 | sp->cmd->result = DID_RESET << 16; |
1da177e4 | 3106 | sp->cmd->host_scribble = (unsigned char *)NULL; |
f4f051eb | 3107 | qla2x00_sp_compl(ha, sp); |
1da177e4 LT |
3108 | } |
3109 | } | |
3110 | spin_unlock_irqrestore(&ha->hardware_lock, flags); | |
3111 | ||
abbd8870 | 3112 | ha->isp_ops.nvram_config(ha); |
1da177e4 LT |
3113 | |
3114 | if (!qla2x00_restart_isp(ha)) { | |
3115 | clear_bit(RESET_MARKER_NEEDED, &ha->dpc_flags); | |
3116 | ||
3117 | if (!atomic_read(&ha->loop_down_timer)) { | |
3118 | /* | |
3119 | * Issue marker command only when we are going | |
3120 | * to start the I/O . | |
3121 | */ | |
3122 | ha->marker_needed = 1; | |
3123 | } | |
3124 | ||
3125 | ha->flags.online = 1; | |
3126 | ||
abbd8870 | 3127 | ha->isp_ops.enable_intrs(ha); |
1da177e4 | 3128 | |
fa2a1ce5 | 3129 | ha->isp_abort_cnt = 0; |
1da177e4 | 3130 | clear_bit(ISP_ABORT_RETRY, &ha->dpc_flags); |
476e8978 AV |
3131 | |
3132 | if (ha->eft) { | |
3133 | rval = qla2x00_trace_control(ha, TC_ENABLE, | |
3134 | ha->eft_dma, EFT_NUM_BUFFERS); | |
3135 | if (rval) { | |
3136 | qla_printk(KERN_WARNING, ha, | |
3137 | "Unable to reinitialize EFT " | |
3138 | "(%d).\n", rval); | |
3139 | } | |
3140 | } | |
1da177e4 LT |
3141 | } else { /* failed the ISP abort */ |
3142 | ha->flags.online = 1; | |
3143 | if (test_bit(ISP_ABORT_RETRY, &ha->dpc_flags)) { | |
3144 | if (ha->isp_abort_cnt == 0) { | |
3145 | qla_printk(KERN_WARNING, ha, | |
3146 | "ISP error recovery failed - " | |
3147 | "board disabled\n"); | |
fa2a1ce5 | 3148 | /* |
1da177e4 LT |
3149 | * The next call disables the board |
3150 | * completely. | |
3151 | */ | |
abbd8870 | 3152 | ha->isp_ops.reset_adapter(ha); |
1da177e4 LT |
3153 | ha->flags.online = 0; |
3154 | clear_bit(ISP_ABORT_RETRY, | |
3155 | &ha->dpc_flags); | |
3156 | status = 0; | |
3157 | } else { /* schedule another ISP abort */ | |
3158 | ha->isp_abort_cnt--; | |
3159 | DEBUG(printk("qla%ld: ISP abort - " | |
0107109e | 3160 | "retry remaining %d\n", |
744f11fd | 3161 | ha->host_no, ha->isp_abort_cnt)); |
1da177e4 LT |
3162 | status = 1; |
3163 | } | |
3164 | } else { | |
3165 | ha->isp_abort_cnt = MAX_RETRIES_OF_ISP_ABORT; | |
3166 | DEBUG(printk("qla2x00(%ld): ISP error recovery " | |
3167 | "- retrying (%d) more times\n", | |
744f11fd | 3168 | ha->host_no, ha->isp_abort_cnt)); |
1da177e4 LT |
3169 | set_bit(ISP_ABORT_RETRY, &ha->dpc_flags); |
3170 | status = 1; | |
3171 | } | |
3172 | } | |
fa2a1ce5 | 3173 | |
1da177e4 LT |
3174 | } |
3175 | ||
3176 | if (status) { | |
3177 | qla_printk(KERN_INFO, ha, | |
3178 | "qla2x00_abort_isp: **** FAILED ****\n"); | |
3179 | } else { | |
3180 | DEBUG(printk(KERN_INFO | |
3181 | "qla2x00_abort_isp(%ld): exiting.\n", | |
744f11fd | 3182 | ha->host_no)); |
1da177e4 LT |
3183 | } |
3184 | ||
3185 | return(status); | |
3186 | } | |
3187 | ||
3188 | /* | |
3189 | * qla2x00_restart_isp | |
3190 | * restarts the ISP after a reset | |
3191 | * | |
3192 | * Input: | |
3193 | * ha = adapter block pointer. | |
3194 | * | |
3195 | * Returns: | |
3196 | * 0 = success | |
3197 | */ | |
3198 | static int | |
3199 | qla2x00_restart_isp(scsi_qla_host_t *ha) | |
3200 | { | |
3201 | uint8_t status = 0; | |
3d71644c | 3202 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
1da177e4 LT |
3203 | unsigned long flags = 0; |
3204 | uint32_t wait_time; | |
3205 | ||
3206 | /* If firmware needs to be loaded */ | |
3207 | if (qla2x00_isp_firmware(ha)) { | |
3208 | ha->flags.online = 0; | |
abbd8870 | 3209 | if (!(status = ha->isp_ops.chip_diag(ha))) { |
1da177e4 LT |
3210 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) { |
3211 | status = qla2x00_setup_chip(ha); | |
3212 | goto done; | |
3213 | } | |
3214 | ||
1da177e4 LT |
3215 | spin_lock_irqsave(&ha->hardware_lock, flags); |
3216 | ||
044cc6c8 | 3217 | if (!IS_QLA24XX(ha) && !IS_QLA54XX(ha)) { |
0107109e AV |
3218 | /* |
3219 | * Disable SRAM, Instruction RAM and GP RAM | |
3220 | * parity. | |
3221 | */ | |
3222 | WRT_REG_WORD(®->hccr, | |
3223 | (HCCR_ENABLE_PARITY + 0x0)); | |
3224 | RD_REG_WORD(®->hccr); | |
3225 | } | |
1da177e4 LT |
3226 | |
3227 | spin_unlock_irqrestore(&ha->hardware_lock, flags); | |
fa2a1ce5 | 3228 | |
1da177e4 LT |
3229 | status = qla2x00_setup_chip(ha); |
3230 | ||
3231 | spin_lock_irqsave(&ha->hardware_lock, flags); | |
fa2a1ce5 | 3232 | |
044cc6c8 | 3233 | if (!IS_QLA24XX(ha) && !IS_QLA54XX(ha)) { |
0107109e AV |
3234 | /* Enable proper parity */ |
3235 | if (IS_QLA2300(ha)) | |
3236 | /* SRAM parity */ | |
3237 | WRT_REG_WORD(®->hccr, | |
3238 | (HCCR_ENABLE_PARITY + 0x1)); | |
3239 | else | |
3240 | /* | |
3241 | * SRAM, Instruction RAM and GP RAM | |
3242 | * parity. | |
3243 | */ | |
3244 | WRT_REG_WORD(®->hccr, | |
3245 | (HCCR_ENABLE_PARITY + 0x7)); | |
3246 | RD_REG_WORD(®->hccr); | |
3247 | } | |
1da177e4 LT |
3248 | |
3249 | spin_unlock_irqrestore(&ha->hardware_lock, flags); | |
3250 | } | |
3251 | } | |
3252 | ||
3253 | done: | |
3254 | if (!status && !(status = qla2x00_init_rings(ha))) { | |
3255 | clear_bit(RESET_MARKER_NEEDED, &ha->dpc_flags); | |
3256 | if (!(status = qla2x00_fw_ready(ha))) { | |
3257 | DEBUG(printk("%s(): Start configure loop, " | |
744f11fd | 3258 | "status = %d\n", __func__, status)); |
0107109e AV |
3259 | |
3260 | /* Issue a marker after FW becomes ready. */ | |
3261 | qla2x00_marker(ha, 0, 0, MK_SYNC_ALL); | |
3262 | ||
1da177e4 LT |
3263 | ha->flags.online = 1; |
3264 | /* Wait at most MAX_TARGET RSCNs for a stable link. */ | |
3265 | wait_time = 256; | |
3266 | do { | |
3267 | clear_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags); | |
3268 | qla2x00_configure_loop(ha); | |
3269 | wait_time--; | |
3270 | } while (!atomic_read(&ha->loop_down_timer) && | |
3271 | !(test_bit(ISP_ABORT_NEEDED, &ha->dpc_flags)) && | |
3272 | wait_time && | |
3273 | (test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags))); | |
3274 | } | |
3275 | ||
3276 | /* if no cable then assume it's good */ | |
fa2a1ce5 | 3277 | if ((ha->device_flags & DFLG_NO_CABLE)) |
1da177e4 LT |
3278 | status = 0; |
3279 | ||
3280 | DEBUG(printk("%s(): Configure loop done, status = 0x%x\n", | |
3281 | __func__, | |
744f11fd | 3282 | status)); |
1da177e4 LT |
3283 | } |
3284 | return (status); | |
3285 | } | |
3286 | ||
3287 | /* | |
3288 | * qla2x00_reset_adapter | |
3289 | * Reset adapter. | |
3290 | * | |
3291 | * Input: | |
3292 | * ha = adapter block pointer. | |
3293 | */ | |
abbd8870 | 3294 | void |
1da177e4 LT |
3295 | qla2x00_reset_adapter(scsi_qla_host_t *ha) |
3296 | { | |
3297 | unsigned long flags = 0; | |
3d71644c | 3298 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
1da177e4 LT |
3299 | |
3300 | ha->flags.online = 0; | |
abbd8870 | 3301 | ha->isp_ops.disable_intrs(ha); |
1da177e4 | 3302 | |
1da177e4 LT |
3303 | spin_lock_irqsave(&ha->hardware_lock, flags); |
3304 | WRT_REG_WORD(®->hccr, HCCR_RESET_RISC); | |
3305 | RD_REG_WORD(®->hccr); /* PCI Posting. */ | |
3306 | WRT_REG_WORD(®->hccr, HCCR_RELEASE_RISC); | |
3307 | RD_REG_WORD(®->hccr); /* PCI Posting. */ | |
3308 | spin_unlock_irqrestore(&ha->hardware_lock, flags); | |
3309 | } | |
0107109e AV |
3310 | |
3311 | void | |
3312 | qla24xx_reset_adapter(scsi_qla_host_t *ha) | |
3313 | { | |
3314 | unsigned long flags = 0; | |
3315 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; | |
3316 | ||
3317 | ha->flags.online = 0; | |
3318 | ha->isp_ops.disable_intrs(ha); | |
3319 | ||
3320 | spin_lock_irqsave(&ha->hardware_lock, flags); | |
3321 | WRT_REG_DWORD(®->hccr, HCCRX_SET_RISC_RESET); | |
3322 | RD_REG_DWORD(®->hccr); | |
3323 | WRT_REG_DWORD(®->hccr, HCCRX_REL_RISC_PAUSE); | |
3324 | RD_REG_DWORD(®->hccr); | |
3325 | spin_unlock_irqrestore(&ha->hardware_lock, flags); | |
3326 | } | |
3327 | ||
3328 | int | |
3329 | qla24xx_nvram_config(scsi_qla_host_t *ha) | |
3330 | { | |
3331 | int rval; | |
3332 | struct init_cb_24xx *icb; | |
3333 | struct nvram_24xx *nv; | |
3334 | uint32_t *dptr; | |
3335 | uint8_t *dptr1, *dptr2; | |
3336 | uint32_t chksum; | |
3337 | uint16_t cnt; | |
3338 | ||
3339 | rval = QLA_SUCCESS; | |
3340 | icb = (struct init_cb_24xx *)ha->init_cb; | |
3341 | nv = (struct nvram_24xx *)ha->request_ring; | |
3342 | ||
3343 | /* Determine NVRAM starting address. */ | |
3344 | ha->nvram_size = sizeof(struct nvram_24xx); | |
3345 | ha->nvram_base = FA_NVRAM_FUNC0_ADDR; | |
6f641790 | 3346 | ha->vpd_size = FA_NVRAM_VPD_SIZE; |
3347 | ha->vpd_base = FA_NVRAM_VPD0_ADDR; | |
3348 | if (PCI_FUNC(ha->pdev->devfn)) { | |
0107109e | 3349 | ha->nvram_base = FA_NVRAM_FUNC1_ADDR; |
6f641790 | 3350 | ha->vpd_base = FA_NVRAM_VPD1_ADDR; |
3351 | } | |
0107109e AV |
3352 | |
3353 | /* Get NVRAM data and calculate checksum. */ | |
3354 | dptr = (uint32_t *)nv; | |
3355 | ha->isp_ops.read_nvram(ha, (uint8_t *)dptr, ha->nvram_base, | |
3356 | ha->nvram_size); | |
3357 | for (cnt = 0, chksum = 0; cnt < ha->nvram_size >> 2; cnt++) | |
3358 | chksum += le32_to_cpu(*dptr++); | |
3359 | ||
3360 | DEBUG5(printk("scsi(%ld): Contents of NVRAM\n", ha->host_no)); | |
3361 | DEBUG5(qla2x00_dump_buffer((uint8_t *)ha->request_ring, | |
3362 | ha->nvram_size)); | |
3363 | ||
3364 | /* Bad NVRAM data, set defaults parameters. */ | |
3365 | if (chksum || nv->id[0] != 'I' || nv->id[1] != 'S' || nv->id[2] != 'P' | |
3366 | || nv->id[3] != ' ' || | |
3367 | nv->nvram_version < __constant_cpu_to_le16(ICB_VERSION)) { | |
3368 | /* Reset NVRAM data. */ | |
3369 | qla_printk(KERN_WARNING, ha, "Inconsistent NVRAM detected: " | |
3370 | "checksum=0x%x id=%c version=0x%x.\n", chksum, nv->id[0], | |
3371 | le16_to_cpu(nv->nvram_version)); | |
3372 | qla_printk(KERN_WARNING, ha, "Falling back to functioning (yet " | |
3373 | "invalid -- WWPN) defaults.\n"); | |
3374 | ||
3375 | /* | |
3376 | * Set default initialization control block. | |
3377 | */ | |
3378 | memset(nv, 0, ha->nvram_size); | |
3379 | nv->nvram_version = __constant_cpu_to_le16(ICB_VERSION); | |
3380 | nv->version = __constant_cpu_to_le16(ICB_VERSION); | |
3381 | nv->frame_payload_size = __constant_cpu_to_le16(2048); | |
3382 | nv->execution_throttle = __constant_cpu_to_le16(0xFFFF); | |
3383 | nv->exchange_count = __constant_cpu_to_le16(0); | |
3384 | nv->hard_address = __constant_cpu_to_le16(124); | |
3385 | nv->port_name[0] = 0x21; | |
3386 | nv->port_name[1] = 0x00 + PCI_FUNC(ha->pdev->devfn); | |
3387 | nv->port_name[2] = 0x00; | |
3388 | nv->port_name[3] = 0xe0; | |
3389 | nv->port_name[4] = 0x8b; | |
3390 | nv->port_name[5] = 0x1c; | |
3391 | nv->port_name[6] = 0x55; | |
3392 | nv->port_name[7] = 0x86; | |
3393 | nv->node_name[0] = 0x20; | |
3394 | nv->node_name[1] = 0x00; | |
3395 | nv->node_name[2] = 0x00; | |
3396 | nv->node_name[3] = 0xe0; | |
3397 | nv->node_name[4] = 0x8b; | |
3398 | nv->node_name[5] = 0x1c; | |
3399 | nv->node_name[6] = 0x55; | |
3400 | nv->node_name[7] = 0x86; | |
3401 | nv->login_retry_count = __constant_cpu_to_le16(8); | |
0107109e AV |
3402 | nv->interrupt_delay_timer = __constant_cpu_to_le16(0); |
3403 | nv->login_timeout = __constant_cpu_to_le16(0); | |
3404 | nv->firmware_options_1 = | |
3405 | __constant_cpu_to_le32(BIT_14|BIT_13|BIT_2|BIT_1); | |
3406 | nv->firmware_options_2 = __constant_cpu_to_le32(2 << 4); | |
3407 | nv->firmware_options_2 |= __constant_cpu_to_le32(BIT_12); | |
3408 | nv->firmware_options_3 = __constant_cpu_to_le32(2 << 13); | |
3409 | nv->host_p = __constant_cpu_to_le32(BIT_11|BIT_10); | |
3410 | nv->efi_parameters = __constant_cpu_to_le32(0); | |
3411 | nv->reset_delay = 5; | |
3412 | nv->max_luns_per_target = __constant_cpu_to_le16(128); | |
3413 | nv->port_down_retry_count = __constant_cpu_to_le16(30); | |
3414 | nv->link_down_timeout = __constant_cpu_to_le16(30); | |
3415 | ||
3416 | rval = 1; | |
3417 | } | |
3418 | ||
3419 | /* Reset Initialization control block */ | |
3420 | memset(icb, 0, sizeof(struct init_cb_24xx)); | |
3421 | ||
3422 | /* Copy 1st segment. */ | |
3423 | dptr1 = (uint8_t *)icb; | |
3424 | dptr2 = (uint8_t *)&nv->version; | |
3425 | cnt = (uint8_t *)&icb->response_q_inpointer - (uint8_t *)&icb->version; | |
3426 | while (cnt--) | |
3427 | *dptr1++ = *dptr2++; | |
3428 | ||
3429 | icb->login_retry_count = nv->login_retry_count; | |
3ea66e28 | 3430 | icb->link_down_on_nos = nv->link_down_on_nos; |
0107109e AV |
3431 | |
3432 | /* Copy 2nd segment. */ | |
3433 | dptr1 = (uint8_t *)&icb->interrupt_delay_timer; | |
3434 | dptr2 = (uint8_t *)&nv->interrupt_delay_timer; | |
3435 | cnt = (uint8_t *)&icb->reserved_3 - | |
3436 | (uint8_t *)&icb->interrupt_delay_timer; | |
3437 | while (cnt--) | |
3438 | *dptr1++ = *dptr2++; | |
3439 | ||
3440 | /* | |
3441 | * Setup driver NVRAM options. | |
3442 | */ | |
3443 | if (memcmp(nv->model_name, BINZERO, sizeof(nv->model_name)) != 0) { | |
3444 | char *st, *en; | |
3445 | uint16_t index; | |
3446 | ||
3447 | strncpy(ha->model_number, nv->model_name, | |
3448 | sizeof(nv->model_name)); | |
3449 | st = en = ha->model_number; | |
3450 | en += sizeof(nv->model_name) - 1; | |
3451 | while (en > st) { | |
3452 | if (*en != 0x20 && *en != 0x00) | |
3453 | break; | |
3454 | *en-- = '\0'; | |
3455 | } | |
3456 | ||
3457 | index = (ha->pdev->subsystem_device & 0xff); | |
3458 | if (index < QLA_MODEL_NAMES) | |
1328962e | 3459 | ha->model_desc = qla2x00_model_name[index * 2 + 1]; |
0107109e AV |
3460 | } else |
3461 | strcpy(ha->model_number, "QLA2462"); | |
3462 | ||
5341e868 AV |
3463 | /* Use alternate WWN? */ |
3464 | if (nv->host_p & __constant_cpu_to_le32(BIT_15)) { | |
3465 | memcpy(icb->node_name, nv->alternate_node_name, WWN_SIZE); | |
3466 | memcpy(icb->port_name, nv->alternate_port_name, WWN_SIZE); | |
3467 | } | |
3468 | ||
0107109e | 3469 | /* Prepare nodename */ |
fd0e7e4d | 3470 | if ((icb->firmware_options_1 & __constant_cpu_to_le32(BIT_14)) == 0) { |
0107109e AV |
3471 | /* |
3472 | * Firmware will apply the following mask if the nodename was | |
3473 | * not provided. | |
3474 | */ | |
3475 | memcpy(icb->node_name, icb->port_name, WWN_SIZE); | |
3476 | icb->node_name[0] &= 0xF0; | |
3477 | } | |
3478 | ||
3479 | /* Set host adapter parameters. */ | |
3480 | ha->flags.disable_risc_code_load = 0; | |
3481 | ha->flags.enable_lip_reset = 1; | |
3482 | ha->flags.enable_lip_full_login = 1; | |
3483 | ha->flags.enable_target_reset = 1; | |
3484 | ha->flags.enable_led_scheme = 0; | |
d4c760c2 | 3485 | ha->flags.disable_serdes = le32_to_cpu(nv->host_p) & BIT_5 ? 1: 0; |
0107109e | 3486 | |
fd0e7e4d AV |
3487 | ha->operating_mode = (le32_to_cpu(icb->firmware_options_2) & |
3488 | (BIT_6 | BIT_5 | BIT_4)) >> 4; | |
0107109e AV |
3489 | |
3490 | memcpy(ha->fw_seriallink_options24, nv->seriallink_options, | |
3491 | sizeof(ha->fw_seriallink_options24)); | |
3492 | ||
3493 | /* save HBA serial number */ | |
3494 | ha->serial0 = icb->port_name[5]; | |
3495 | ha->serial1 = icb->port_name[6]; | |
3496 | ha->serial2 = icb->port_name[7]; | |
3497 | ha->node_name = icb->node_name; | |
3498 | ha->port_name = icb->port_name; | |
3499 | ||
bc8fb3cb | 3500 | icb->execution_throttle = __constant_cpu_to_le16(0xFFFF); |
3501 | ||
0107109e AV |
3502 | ha->retry_count = le16_to_cpu(nv->login_retry_count); |
3503 | ||
3504 | /* Set minimum login_timeout to 4 seconds. */ | |
3505 | if (le16_to_cpu(nv->login_timeout) < ql2xlogintimeout) | |
3506 | nv->login_timeout = cpu_to_le16(ql2xlogintimeout); | |
3507 | if (le16_to_cpu(nv->login_timeout) < 4) | |
3508 | nv->login_timeout = __constant_cpu_to_le16(4); | |
3509 | ha->login_timeout = le16_to_cpu(nv->login_timeout); | |
3510 | icb->login_timeout = cpu_to_le16(nv->login_timeout); | |
3511 | ||
3512 | /* Set minimum RATOV to 200 tenths of a second. */ | |
3513 | ha->r_a_tov = 200; | |
3514 | ||
3515 | ha->loop_reset_delay = nv->reset_delay; | |
3516 | ||
3517 | /* Link Down Timeout = 0: | |
3518 | * | |
3519 | * When Port Down timer expires we will start returning | |
3520 | * I/O's to OS with "DID_NO_CONNECT". | |
3521 | * | |
3522 | * Link Down Timeout != 0: | |
3523 | * | |
3524 | * The driver waits for the link to come up after link down | |
3525 | * before returning I/Os to OS with "DID_NO_CONNECT". | |
3526 | */ | |
3527 | if (le16_to_cpu(nv->link_down_timeout) == 0) { | |
3528 | ha->loop_down_abort_time = | |
3529 | (LOOP_DOWN_TIME - LOOP_DOWN_TIMEOUT); | |
3530 | } else { | |
3531 | ha->link_down_timeout = le16_to_cpu(nv->link_down_timeout); | |
3532 | ha->loop_down_abort_time = | |
3533 | (LOOP_DOWN_TIME - ha->link_down_timeout); | |
3534 | } | |
3535 | ||
3536 | /* Need enough time to try and get the port back. */ | |
3537 | ha->port_down_retry_count = le16_to_cpu(nv->port_down_retry_count); | |
3538 | if (qlport_down_retry) | |
3539 | ha->port_down_retry_count = qlport_down_retry; | |
3540 | ||
3541 | /* Set login_retry_count */ | |
3542 | ha->login_retry_count = le16_to_cpu(nv->login_retry_count); | |
3543 | if (ha->port_down_retry_count == | |
3544 | le16_to_cpu(nv->port_down_retry_count) && | |
3545 | ha->port_down_retry_count > 3) | |
3546 | ha->login_retry_count = ha->port_down_retry_count; | |
3547 | else if (ha->port_down_retry_count > (int)ha->login_retry_count) | |
3548 | ha->login_retry_count = ha->port_down_retry_count; | |
3549 | if (ql2xloginretrycount) | |
3550 | ha->login_retry_count = ql2xloginretrycount; | |
3551 | ||
4fdfefe5 AV |
3552 | /* Enable ZIO. */ |
3553 | if (!ha->flags.init_done) { | |
3554 | ha->zio_mode = le32_to_cpu(icb->firmware_options_2) & | |
3555 | (BIT_3 | BIT_2 | BIT_1 | BIT_0); | |
3556 | ha->zio_timer = le16_to_cpu(icb->interrupt_delay_timer) ? | |
3557 | le16_to_cpu(icb->interrupt_delay_timer): 2; | |
3558 | } | |
3559 | icb->firmware_options_2 &= __constant_cpu_to_le32( | |
3560 | ~(BIT_3 | BIT_2 | BIT_1 | BIT_0)); | |
3561 | ha->flags.process_response_queue = 0; | |
3562 | if (ha->zio_mode != QLA_ZIO_DISABLED) { | |
4a59f71d | 3563 | ha->zio_mode = QLA_ZIO_MODE_6; |
3564 | ||
4fdfefe5 AV |
3565 | DEBUG2(printk("scsi(%ld): ZIO mode %d enabled; timer delay " |
3566 | "(%d us).\n", ha->host_no, ha->zio_mode, | |
3567 | ha->zio_timer * 100)); | |
3568 | qla_printk(KERN_INFO, ha, | |
3569 | "ZIO mode %d enabled; timer delay (%d us).\n", | |
3570 | ha->zio_mode, ha->zio_timer * 100); | |
3571 | ||
3572 | icb->firmware_options_2 |= cpu_to_le32( | |
3573 | (uint32_t)ha->zio_mode); | |
3574 | icb->interrupt_delay_timer = cpu_to_le16(ha->zio_timer); | |
3575 | ha->flags.process_response_queue = 1; | |
3576 | } | |
3577 | ||
0107109e AV |
3578 | if (rval) { |
3579 | DEBUG2_3(printk(KERN_WARNING | |
3580 | "scsi(%ld): NVRAM configuration failed!\n", ha->host_no)); | |
3581 | } | |
3582 | return (rval); | |
3583 | } | |
3584 | ||
413975a0 | 3585 | static int |
d1c61909 AV |
3586 | qla24xx_load_risc_flash(scsi_qla_host_t *ha, uint32_t *srisc_addr) |
3587 | { | |
3588 | int rval; | |
3589 | int segments, fragment; | |
3590 | uint32_t faddr; | |
3591 | uint32_t *dcode, dlen; | |
3592 | uint32_t risc_addr; | |
3593 | uint32_t risc_size; | |
3594 | uint32_t i; | |
3595 | ||
3596 | rval = QLA_SUCCESS; | |
3597 | ||
3598 | segments = FA_RISC_CODE_SEGMENTS; | |
3599 | faddr = FA_RISC_CODE_ADDR; | |
3600 | dcode = (uint32_t *)ha->request_ring; | |
3601 | *srisc_addr = 0; | |
3602 | ||
3603 | /* Validate firmware image by checking version. */ | |
3604 | qla24xx_read_flash_data(ha, dcode, faddr + 4, 4); | |
3605 | for (i = 0; i < 4; i++) | |
3606 | dcode[i] = be32_to_cpu(dcode[i]); | |
3607 | if ((dcode[0] == 0xffffffff && dcode[1] == 0xffffffff && | |
3608 | dcode[2] == 0xffffffff && dcode[3] == 0xffffffff) || | |
3609 | (dcode[0] == 0 && dcode[1] == 0 && dcode[2] == 0 && | |
3610 | dcode[3] == 0)) { | |
3611 | qla_printk(KERN_WARNING, ha, | |
3612 | "Unable to verify integrity of flash firmware image!\n"); | |
3613 | qla_printk(KERN_WARNING, ha, | |
3614 | "Firmware data: %08x %08x %08x %08x!\n", dcode[0], | |
3615 | dcode[1], dcode[2], dcode[3]); | |
3616 | ||
3617 | return QLA_FUNCTION_FAILED; | |
3618 | } | |
3619 | ||
3620 | while (segments && rval == QLA_SUCCESS) { | |
3621 | /* Read segment's load information. */ | |
3622 | qla24xx_read_flash_data(ha, dcode, faddr, 4); | |
3623 | ||
3624 | risc_addr = be32_to_cpu(dcode[2]); | |
3625 | *srisc_addr = *srisc_addr == 0 ? risc_addr : *srisc_addr; | |
3626 | risc_size = be32_to_cpu(dcode[3]); | |
3627 | ||
3628 | fragment = 0; | |
3629 | while (risc_size > 0 && rval == QLA_SUCCESS) { | |
3630 | dlen = (uint32_t)(ha->fw_transfer_size >> 2); | |
3631 | if (dlen > risc_size) | |
3632 | dlen = risc_size; | |
3633 | ||
3634 | DEBUG7(printk("scsi(%ld): Loading risc segment@ risc " | |
3635 | "addr %x, number of dwords 0x%x, offset 0x%x.\n", | |
3636 | ha->host_no, risc_addr, dlen, faddr)); | |
3637 | ||
3638 | qla24xx_read_flash_data(ha, dcode, faddr, dlen); | |
3639 | for (i = 0; i < dlen; i++) | |
3640 | dcode[i] = swab32(dcode[i]); | |
3641 | ||
3642 | rval = qla2x00_load_ram(ha, ha->request_dma, risc_addr, | |
3643 | dlen); | |
3644 | if (rval) { | |
3645 | DEBUG(printk("scsi(%ld):[ERROR] Failed to load " | |
3646 | "segment %d of firmware\n", ha->host_no, | |
3647 | fragment)); | |
3648 | qla_printk(KERN_WARNING, ha, | |
3649 | "[ERROR] Failed to load segment %d of " | |
3650 | "firmware\n", fragment); | |
3651 | break; | |
3652 | } | |
3653 | ||
3654 | faddr += dlen; | |
3655 | risc_addr += dlen; | |
3656 | risc_size -= dlen; | |
3657 | fragment++; | |
3658 | } | |
3659 | ||
3660 | /* Next segment. */ | |
3661 | segments--; | |
3662 | } | |
3663 | ||
3664 | return rval; | |
3665 | } | |
3666 | ||
d1c61909 AV |
3667 | #define QLA_FW_URL "ftp://ftp.qlogic.com/outgoing/linux/firmware/" |
3668 | ||
0107109e | 3669 | int |
5433383e AV |
3670 | qla2x00_load_risc(scsi_qla_host_t *ha, uint32_t *srisc_addr) |
3671 | { | |
3672 | int rval; | |
3673 | int i, fragment; | |
3674 | uint16_t *wcode, *fwcode; | |
3675 | uint32_t risc_addr, risc_size, fwclen, wlen, *seg; | |
3676 | struct fw_blob *blob; | |
3677 | ||
3678 | /* Load firmware blob. */ | |
3679 | blob = qla2x00_request_firmware(ha); | |
3680 | if (!blob) { | |
3681 | qla_printk(KERN_ERR, ha, "Firmware image unavailable.\n"); | |
d1c61909 AV |
3682 | qla_printk(KERN_ERR, ha, "Firmware images can be retrieved " |
3683 | "from: " QLA_FW_URL ".\n"); | |
5433383e AV |
3684 | return QLA_FUNCTION_FAILED; |
3685 | } | |
3686 | ||
3687 | rval = QLA_SUCCESS; | |
3688 | ||
3689 | wcode = (uint16_t *)ha->request_ring; | |
3690 | *srisc_addr = 0; | |
3691 | fwcode = (uint16_t *)blob->fw->data; | |
3692 | fwclen = 0; | |
3693 | ||
3694 | /* Validate firmware image by checking version. */ | |
3695 | if (blob->fw->size < 8 * sizeof(uint16_t)) { | |
3696 | qla_printk(KERN_WARNING, ha, | |
3697 | "Unable to verify integrity of firmware image (%Zd)!\n", | |
3698 | blob->fw->size); | |
3699 | goto fail_fw_integrity; | |
3700 | } | |
3701 | for (i = 0; i < 4; i++) | |
3702 | wcode[i] = be16_to_cpu(fwcode[i + 4]); | |
3703 | if ((wcode[0] == 0xffff && wcode[1] == 0xffff && wcode[2] == 0xffff && | |
3704 | wcode[3] == 0xffff) || (wcode[0] == 0 && wcode[1] == 0 && | |
3705 | wcode[2] == 0 && wcode[3] == 0)) { | |
3706 | qla_printk(KERN_WARNING, ha, | |
3707 | "Unable to verify integrity of firmware image!\n"); | |
3708 | qla_printk(KERN_WARNING, ha, | |
3709 | "Firmware data: %04x %04x %04x %04x!\n", wcode[0], | |
3710 | wcode[1], wcode[2], wcode[3]); | |
3711 | goto fail_fw_integrity; | |
3712 | } | |
3713 | ||
3714 | seg = blob->segs; | |
3715 | while (*seg && rval == QLA_SUCCESS) { | |
3716 | risc_addr = *seg; | |
3717 | *srisc_addr = *srisc_addr == 0 ? *seg : *srisc_addr; | |
3718 | risc_size = be16_to_cpu(fwcode[3]); | |
3719 | ||
3720 | /* Validate firmware image size. */ | |
3721 | fwclen += risc_size * sizeof(uint16_t); | |
3722 | if (blob->fw->size < fwclen) { | |
3723 | qla_printk(KERN_WARNING, ha, | |
3724 | "Unable to verify integrity of firmware image " | |
3725 | "(%Zd)!\n", blob->fw->size); | |
3726 | goto fail_fw_integrity; | |
3727 | } | |
3728 | ||
3729 | fragment = 0; | |
3730 | while (risc_size > 0 && rval == QLA_SUCCESS) { | |
3731 | wlen = (uint16_t)(ha->fw_transfer_size >> 1); | |
3732 | if (wlen > risc_size) | |
3733 | wlen = risc_size; | |
3734 | ||
3735 | DEBUG7(printk("scsi(%ld): Loading risc segment@ risc " | |
3736 | "addr %x, number of words 0x%x.\n", ha->host_no, | |
3737 | risc_addr, wlen)); | |
3738 | ||
3739 | for (i = 0; i < wlen; i++) | |
3740 | wcode[i] = swab16(fwcode[i]); | |
3741 | ||
3742 | rval = qla2x00_load_ram(ha, ha->request_dma, risc_addr, | |
3743 | wlen); | |
3744 | if (rval) { | |
3745 | DEBUG(printk("scsi(%ld):[ERROR] Failed to load " | |
3746 | "segment %d of firmware\n", ha->host_no, | |
3747 | fragment)); | |
3748 | qla_printk(KERN_WARNING, ha, | |
3749 | "[ERROR] Failed to load segment %d of " | |
3750 | "firmware\n", fragment); | |
3751 | break; | |
3752 | } | |
3753 | ||
3754 | fwcode += wlen; | |
3755 | risc_addr += wlen; | |
3756 | risc_size -= wlen; | |
3757 | fragment++; | |
3758 | } | |
3759 | ||
3760 | /* Next segment. */ | |
3761 | seg++; | |
3762 | } | |
3763 | return rval; | |
3764 | ||
3765 | fail_fw_integrity: | |
3766 | return QLA_FUNCTION_FAILED; | |
3767 | } | |
3768 | ||
3769 | int | |
3770 | qla24xx_load_risc(scsi_qla_host_t *ha, uint32_t *srisc_addr) | |
0107109e AV |
3771 | { |
3772 | int rval; | |
3773 | int segments, fragment; | |
3774 | uint32_t *dcode, dlen; | |
3775 | uint32_t risc_addr; | |
3776 | uint32_t risc_size; | |
3777 | uint32_t i; | |
5433383e | 3778 | struct fw_blob *blob; |
0107109e AV |
3779 | uint32_t *fwcode, fwclen; |
3780 | ||
5433383e AV |
3781 | /* Load firmware blob. */ |
3782 | blob = qla2x00_request_firmware(ha); | |
3783 | if (!blob) { | |
3784 | qla_printk(KERN_ERR, ha, "Firmware image unavailable.\n"); | |
d1c61909 AV |
3785 | qla_printk(KERN_ERR, ha, "Firmware images can be retrieved " |
3786 | "from: " QLA_FW_URL ".\n"); | |
3787 | ||
3788 | /* Try to load RISC code from flash. */ | |
3789 | qla_printk(KERN_ERR, ha, "Attempting to load (potentially " | |
3790 | "outdated) firmware from flash.\n"); | |
3791 | return qla24xx_load_risc_flash(ha, srisc_addr); | |
0107109e AV |
3792 | } |
3793 | ||
3794 | rval = QLA_SUCCESS; | |
3795 | ||
3796 | segments = FA_RISC_CODE_SEGMENTS; | |
3797 | dcode = (uint32_t *)ha->request_ring; | |
3798 | *srisc_addr = 0; | |
5433383e | 3799 | fwcode = (uint32_t *)blob->fw->data; |
0107109e AV |
3800 | fwclen = 0; |
3801 | ||
3802 | /* Validate firmware image by checking version. */ | |
5433383e | 3803 | if (blob->fw->size < 8 * sizeof(uint32_t)) { |
0107109e | 3804 | qla_printk(KERN_WARNING, ha, |
5433383e AV |
3805 | "Unable to verify integrity of firmware image (%Zd)!\n", |
3806 | blob->fw->size); | |
0107109e AV |
3807 | goto fail_fw_integrity; |
3808 | } | |
3809 | for (i = 0; i < 4; i++) | |
3810 | dcode[i] = be32_to_cpu(fwcode[i + 4]); | |
3811 | if ((dcode[0] == 0xffffffff && dcode[1] == 0xffffffff && | |
3812 | dcode[2] == 0xffffffff && dcode[3] == 0xffffffff) || | |
3813 | (dcode[0] == 0 && dcode[1] == 0 && dcode[2] == 0 && | |
3814 | dcode[3] == 0)) { | |
3815 | qla_printk(KERN_WARNING, ha, | |
5433383e | 3816 | "Unable to verify integrity of firmware image!\n"); |
0107109e AV |
3817 | qla_printk(KERN_WARNING, ha, |
3818 | "Firmware data: %08x %08x %08x %08x!\n", dcode[0], | |
3819 | dcode[1], dcode[2], dcode[3]); | |
3820 | goto fail_fw_integrity; | |
3821 | } | |
3822 | ||
3823 | while (segments && rval == QLA_SUCCESS) { | |
3824 | risc_addr = be32_to_cpu(fwcode[2]); | |
3825 | *srisc_addr = *srisc_addr == 0 ? risc_addr : *srisc_addr; | |
3826 | risc_size = be32_to_cpu(fwcode[3]); | |
3827 | ||
3828 | /* Validate firmware image size. */ | |
3829 | fwclen += risc_size * sizeof(uint32_t); | |
5433383e | 3830 | if (blob->fw->size < fwclen) { |
0107109e | 3831 | qla_printk(KERN_WARNING, ha, |
5433383e AV |
3832 | "Unable to verify integrity of firmware image " |
3833 | "(%Zd)!\n", blob->fw->size); | |
3834 | ||
0107109e AV |
3835 | goto fail_fw_integrity; |
3836 | } | |
3837 | ||
3838 | fragment = 0; | |
3839 | while (risc_size > 0 && rval == QLA_SUCCESS) { | |
3840 | dlen = (uint32_t)(ha->fw_transfer_size >> 2); | |
3841 | if (dlen > risc_size) | |
3842 | dlen = risc_size; | |
3843 | ||
3844 | DEBUG7(printk("scsi(%ld): Loading risc segment@ risc " | |
3845 | "addr %x, number of dwords 0x%x.\n", ha->host_no, | |
3846 | risc_addr, dlen)); | |
3847 | ||
3848 | for (i = 0; i < dlen; i++) | |
3849 | dcode[i] = swab32(fwcode[i]); | |
3850 | ||
590f98e5 | 3851 | rval = qla2x00_load_ram(ha, ha->request_dma, risc_addr, |
3852 | dlen); | |
0107109e AV |
3853 | if (rval) { |
3854 | DEBUG(printk("scsi(%ld):[ERROR] Failed to load " | |
3855 | "segment %d of firmware\n", ha->host_no, | |
3856 | fragment)); | |
3857 | qla_printk(KERN_WARNING, ha, | |
3858 | "[ERROR] Failed to load segment %d of " | |
3859 | "firmware\n", fragment); | |
3860 | break; | |
3861 | } | |
3862 | ||
3863 | fwcode += dlen; | |
3864 | risc_addr += dlen; | |
3865 | risc_size -= dlen; | |
3866 | fragment++; | |
3867 | } | |
3868 | ||
3869 | /* Next segment. */ | |
3870 | segments--; | |
3871 | } | |
0107109e AV |
3872 | return rval; |
3873 | ||
3874 | fail_fw_integrity: | |
0107109e | 3875 | return QLA_FUNCTION_FAILED; |
0107109e | 3876 | } |
18c6c127 AV |
3877 | |
3878 | void | |
3879 | qla2x00_try_to_stop_firmware(scsi_qla_host_t *ha) | |
3880 | { | |
3881 | int ret, retries; | |
3882 | ||
3883 | if (!IS_QLA24XX(ha) && !IS_QLA54XX(ha)) | |
3884 | return; | |
3885 | ||
3886 | ret = qla2x00_stop_firmware(ha); | |
3887 | for (retries = 5; ret != QLA_SUCCESS && retries ; retries--) { | |
3888 | qla2x00_reset_chip(ha); | |
3889 | if (qla2x00_chip_diag(ha) != QLA_SUCCESS) | |
3890 | continue; | |
3891 | if (qla2x00_setup_chip(ha) != QLA_SUCCESS) | |
3892 | continue; | |
3893 | qla_printk(KERN_INFO, ha, | |
3894 | "Attempting retry of stop-firmware command...\n"); | |
3895 | ret = qla2x00_stop_firmware(ha); | |
3896 | } | |
3897 | } |