diff options
author | Anirban Chakraborty <anirban.chakraborty@qlogic.com> | 2008-11-06 13:40:51 -0500 |
---|---|---|
committer | James Bottomley <James.Bottomley@HansenPartnership.com> | 2008-12-29 12:24:16 -0500 |
commit | e315cd28b9ef0d7b71e462ac16e18dbaa2f5adfe (patch) | |
tree | 1e20bdd40b56b36f211bde8fff0c63792b088a0a /drivers/scsi/qla2xxx/qla_init.c | |
parent | 7b867cf76fbcc8d77867cbec6f509f71dce8a98f (diff) |
[SCSI] qla2xxx: Code changes for qla data structure refactoring
Following changes have been made:
1. Outstanding commands are based on a request queue, scsi_qla_host
does not maintain it anymore.
2. start_scsi is accessed via isp_ops struct instead of direct
invocation.
3. Interrupt registrations are done using response queue instead of
device id.
Signed-off-by: Anirban Chakraborty <anirban.chakraborty@qlogic.com>
Signed-off-by: James Bottomley <James.Bottomley@HansenPartnership.com>
Diffstat (limited to 'drivers/scsi/qla2xxx/qla_init.c')
-rw-r--r-- | drivers/scsi/qla2xxx/qla_init.c | 1113 |
1 files changed, 563 insertions, 550 deletions
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c index 4218f20f5ed5..7bee87f90f6d 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c | |||
@@ -35,7 +35,7 @@ static int qla2x00_fabric_dev_login(scsi_qla_host_t *, fc_port_t *, | |||
35 | 35 | ||
36 | static int qla2x00_restart_isp(scsi_qla_host_t *); | 36 | static int qla2x00_restart_isp(scsi_qla_host_t *); |
37 | 37 | ||
38 | static int qla2x00_find_new_loop_id(scsi_qla_host_t *ha, fc_port_t *dev); | 38 | static int qla2x00_find_new_loop_id(scsi_qla_host_t *, fc_port_t *); |
39 | 39 | ||
40 | static struct qla_chip_state_84xx *qla84xx_get_chip(struct scsi_qla_host *); | 40 | static struct qla_chip_state_84xx *qla84xx_get_chip(struct scsi_qla_host *); |
41 | static int qla84xx_init_chip(scsi_qla_host_t *); | 41 | static int qla84xx_init_chip(scsi_qla_host_t *); |
@@ -55,77 +55,77 @@ static int qla84xx_init_chip(scsi_qla_host_t *); | |||
55 | * 0 = success | 55 | * 0 = success |
56 | */ | 56 | */ |
57 | int | 57 | int |
58 | qla2x00_initialize_adapter(scsi_qla_host_t *ha) | 58 | qla2x00_initialize_adapter(scsi_qla_host_t *vha) |
59 | { | 59 | { |
60 | int rval; | 60 | int rval; |
61 | 61 | struct qla_hw_data *ha = vha->hw; | |
62 | /* Clear adapter flags. */ | 62 | /* Clear adapter flags. */ |
63 | ha->flags.online = 0; | 63 | vha->flags.online = 0; |
64 | ha->flags.reset_active = 0; | 64 | vha->flags.reset_active = 0; |
65 | atomic_set(&ha->loop_down_timer, LOOP_DOWN_TIME); | 65 | atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME); |
66 | atomic_set(&ha->loop_state, LOOP_DOWN); | 66 | atomic_set(&vha->loop_state, LOOP_DOWN); |
67 | ha->device_flags = DFLG_NO_CABLE; | 67 | vha->device_flags = DFLG_NO_CABLE; |
68 | ha->dpc_flags = 0; | 68 | vha->dpc_flags = 0; |
69 | ha->flags.management_server_logged_in = 0; | 69 | vha->flags.management_server_logged_in = 0; |
70 | ha->marker_needed = 0; | 70 | vha->marker_needed = 0; |
71 | ha->mbx_flags = 0; | 71 | ha->mbx_flags = 0; |
72 | ha->isp_abort_cnt = 0; | 72 | ha->isp_abort_cnt = 0; |
73 | ha->beacon_blink_led = 0; | 73 | ha->beacon_blink_led = 0; |
74 | set_bit(REGISTER_FDMI_NEEDED, &ha->dpc_flags); | 74 | set_bit(REGISTER_FDMI_NEEDED, &vha->dpc_flags); |
75 | 75 | ||
76 | qla_printk(KERN_INFO, ha, "Configuring PCI space...\n"); | 76 | qla_printk(KERN_INFO, ha, "Configuring PCI space...\n"); |
77 | rval = ha->isp_ops->pci_config(ha); | 77 | rval = ha->isp_ops->pci_config(vha); |
78 | if (rval) { | 78 | if (rval) { |
79 | DEBUG2(printk("scsi(%ld): Unable to configure PCI space.\n", | 79 | DEBUG2(printk("scsi(%ld): Unable to configure PCI space.\n", |
80 | ha->host_no)); | 80 | vha->host_no)); |
81 | return (rval); | 81 | return (rval); |
82 | } | 82 | } |
83 | 83 | ||
84 | ha->isp_ops->reset_chip(ha); | 84 | ha->isp_ops->reset_chip(vha); |
85 | 85 | ||
86 | rval = qla2xxx_get_flash_info(ha); | 86 | rval = qla2xxx_get_flash_info(vha); |
87 | if (rval) { | 87 | if (rval) { |
88 | DEBUG2(printk("scsi(%ld): Unable to validate FLASH data.\n", | 88 | DEBUG2(printk("scsi(%ld): Unable to validate FLASH data.\n", |
89 | ha->host_no)); | 89 | vha->host_no)); |
90 | return (rval); | 90 | return (rval); |
91 | } | 91 | } |
92 | 92 | ||
93 | ha->isp_ops->get_flash_version(ha, ha->request_ring); | 93 | ha->isp_ops->get_flash_version(vha, ha->req->ring); |
94 | 94 | ||
95 | qla_printk(KERN_INFO, ha, "Configure NVRAM parameters...\n"); | 95 | qla_printk(KERN_INFO, ha, "Configure NVRAM parameters...\n"); |
96 | 96 | ||
97 | ha->isp_ops->nvram_config(ha); | 97 | ha->isp_ops->nvram_config(vha); |
98 | 98 | ||
99 | if (ha->flags.disable_serdes) { | 99 | if (ha->flags.disable_serdes) { |
100 | /* Mask HBA via NVRAM settings? */ | 100 | /* Mask HBA via NVRAM settings? */ |
101 | qla_printk(KERN_INFO, ha, "Masking HBA WWPN " | 101 | qla_printk(KERN_INFO, ha, "Masking HBA WWPN " |
102 | "%02x%02x%02x%02x%02x%02x%02x%02x (via NVRAM).\n", | 102 | "%02x%02x%02x%02x%02x%02x%02x%02x (via NVRAM).\n", |
103 | ha->port_name[0], ha->port_name[1], | 103 | vha->port_name[0], vha->port_name[1], |
104 | ha->port_name[2], ha->port_name[3], | 104 | vha->port_name[2], vha->port_name[3], |
105 | ha->port_name[4], ha->port_name[5], | 105 | vha->port_name[4], vha->port_name[5], |
106 | ha->port_name[6], ha->port_name[7]); | 106 | vha->port_name[6], vha->port_name[7]); |
107 | return QLA_FUNCTION_FAILED; | 107 | return QLA_FUNCTION_FAILED; |
108 | } | 108 | } |
109 | 109 | ||
110 | qla_printk(KERN_INFO, ha, "Verifying loaded RISC code...\n"); | 110 | qla_printk(KERN_INFO, ha, "Verifying loaded RISC code...\n"); |
111 | 111 | ||
112 | if (qla2x00_isp_firmware(ha) != QLA_SUCCESS) { | 112 | if (qla2x00_isp_firmware(vha) != QLA_SUCCESS) { |
113 | rval = ha->isp_ops->chip_diag(ha); | 113 | rval = ha->isp_ops->chip_diag(vha); |
114 | if (rval) | 114 | if (rval) |
115 | return (rval); | 115 | return (rval); |
116 | rval = qla2x00_setup_chip(ha); | 116 | rval = qla2x00_setup_chip(vha); |
117 | if (rval) | 117 | if (rval) |
118 | return (rval); | 118 | return (rval); |
119 | } | 119 | } |
120 | if (IS_QLA84XX(ha)) { | 120 | if (IS_QLA84XX(ha)) { |
121 | ha->cs84xx = qla84xx_get_chip(ha); | 121 | ha->cs84xx = qla84xx_get_chip(vha); |
122 | if (!ha->cs84xx) { | 122 | if (!ha->cs84xx) { |
123 | qla_printk(KERN_ERR, ha, | 123 | qla_printk(KERN_ERR, ha, |
124 | "Unable to configure ISP84XX.\n"); | 124 | "Unable to configure ISP84XX.\n"); |
125 | return QLA_FUNCTION_FAILED; | 125 | return QLA_FUNCTION_FAILED; |
126 | } | 126 | } |
127 | } | 127 | } |
128 | rval = qla2x00_init_rings(ha); | 128 | rval = qla2x00_init_rings(vha); |
129 | 129 | ||
130 | return (rval); | 130 | return (rval); |
131 | } | 131 | } |
@@ -137,10 +137,11 @@ qla2x00_initialize_adapter(scsi_qla_host_t *ha) | |||
137 | * Returns 0 on success. | 137 | * Returns 0 on success. |
138 | */ | 138 | */ |
139 | int | 139 | int |
140 | qla2100_pci_config(scsi_qla_host_t *ha) | 140 | qla2100_pci_config(scsi_qla_host_t *vha) |
141 | { | 141 | { |
142 | uint16_t w; | 142 | uint16_t w; |
143 | unsigned long flags; | 143 | unsigned long flags; |
144 | struct qla_hw_data *ha = vha->hw; | ||
144 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; | 145 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
145 | 146 | ||
146 | pci_set_master(ha->pdev); | 147 | pci_set_master(ha->pdev); |
@@ -167,11 +168,12 @@ qla2100_pci_config(scsi_qla_host_t *ha) | |||
167 | * Returns 0 on success. | 168 | * Returns 0 on success. |
168 | */ | 169 | */ |
169 | int | 170 | int |
170 | qla2300_pci_config(scsi_qla_host_t *ha) | 171 | qla2300_pci_config(scsi_qla_host_t *vha) |
171 | { | 172 | { |
172 | uint16_t w; | 173 | uint16_t w; |
173 | unsigned long flags = 0; | 174 | unsigned long flags = 0; |
174 | uint32_t cnt; | 175 | uint32_t cnt; |
176 | struct qla_hw_data *ha = vha->hw; | ||
175 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; | 177 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
176 | 178 | ||
177 | pci_set_master(ha->pdev); | 179 | pci_set_master(ha->pdev); |
@@ -248,10 +250,11 @@ qla2300_pci_config(scsi_qla_host_t *ha) | |||
248 | * Returns 0 on success. | 250 | * Returns 0 on success. |
249 | */ | 251 | */ |
250 | int | 252 | int |
251 | qla24xx_pci_config(scsi_qla_host_t *ha) | 253 | qla24xx_pci_config(scsi_qla_host_t *vha) |
252 | { | 254 | { |
253 | uint16_t w; | 255 | uint16_t w; |
254 | unsigned long flags = 0; | 256 | unsigned long flags = 0; |
257 | struct qla_hw_data *ha = vha->hw; | ||
255 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; | 258 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
256 | 259 | ||
257 | pci_set_master(ha->pdev); | 260 | pci_set_master(ha->pdev); |
@@ -291,9 +294,10 @@ qla24xx_pci_config(scsi_qla_host_t *ha) | |||
291 | * Returns 0 on success. | 294 | * Returns 0 on success. |
292 | */ | 295 | */ |
293 | int | 296 | int |
294 | qla25xx_pci_config(scsi_qla_host_t *ha) | 297 | qla25xx_pci_config(scsi_qla_host_t *vha) |
295 | { | 298 | { |
296 | uint16_t w; | 299 | uint16_t w; |
300 | struct qla_hw_data *ha = vha->hw; | ||
297 | 301 | ||
298 | pci_set_master(ha->pdev); | 302 | pci_set_master(ha->pdev); |
299 | pci_try_set_mwi(ha->pdev); | 303 | pci_try_set_mwi(ha->pdev); |
@@ -321,32 +325,33 @@ qla25xx_pci_config(scsi_qla_host_t *ha) | |||
321 | * Returns 0 on success. | 325 | * Returns 0 on success. |
322 | */ | 326 | */ |
323 | static int | 327 | static int |
324 | qla2x00_isp_firmware(scsi_qla_host_t *ha) | 328 | qla2x00_isp_firmware(scsi_qla_host_t *vha) |
325 | { | 329 | { |
326 | int rval; | 330 | int rval; |
327 | uint16_t loop_id, topo, sw_cap; | 331 | uint16_t loop_id, topo, sw_cap; |
328 | uint8_t domain, area, al_pa; | 332 | uint8_t domain, area, al_pa; |
333 | struct qla_hw_data *ha = vha->hw; | ||
329 | 334 | ||
330 | /* Assume loading risc code */ | 335 | /* Assume loading risc code */ |
331 | rval = QLA_FUNCTION_FAILED; | 336 | rval = QLA_FUNCTION_FAILED; |
332 | 337 | ||
333 | if (ha->flags.disable_risc_code_load) { | 338 | if (ha->flags.disable_risc_code_load) { |
334 | DEBUG2(printk("scsi(%ld): RISC CODE NOT loaded\n", | 339 | DEBUG2(printk("scsi(%ld): RISC CODE NOT loaded\n", |
335 | ha->host_no)); | 340 | vha->host_no)); |
336 | qla_printk(KERN_INFO, ha, "RISC CODE NOT loaded\n"); | 341 | qla_printk(KERN_INFO, ha, "RISC CODE NOT loaded\n"); |
337 | 342 | ||
338 | /* Verify checksum of loaded RISC code. */ | 343 | /* Verify checksum of loaded RISC code. */ |
339 | rval = qla2x00_verify_checksum(ha, ha->fw_srisc_address); | 344 | rval = qla2x00_verify_checksum(vha, ha->fw_srisc_address); |
340 | if (rval == QLA_SUCCESS) { | 345 | if (rval == QLA_SUCCESS) { |
341 | /* And, verify we are not in ROM code. */ | 346 | /* And, verify we are not in ROM code. */ |
342 | rval = qla2x00_get_adapter_id(ha, &loop_id, &al_pa, | 347 | rval = qla2x00_get_adapter_id(vha, &loop_id, &al_pa, |
343 | &area, &domain, &topo, &sw_cap); | 348 | &area, &domain, &topo, &sw_cap); |
344 | } | 349 | } |
345 | } | 350 | } |
346 | 351 | ||
347 | if (rval) { | 352 | if (rval) { |
348 | DEBUG2_3(printk("scsi(%ld): **** Load RISC code ****\n", | 353 | DEBUG2_3(printk("scsi(%ld): **** Load RISC code ****\n", |
349 | ha->host_no)); | 354 | vha->host_no)); |
350 | } | 355 | } |
351 | 356 | ||
352 | return (rval); | 357 | return (rval); |
@@ -359,9 +364,10 @@ qla2x00_isp_firmware(scsi_qla_host_t *ha) | |||
359 | * Returns 0 on success. | 364 | * Returns 0 on success. |
360 | */ | 365 | */ |
361 | void | 366 | void |
362 | qla2x00_reset_chip(scsi_qla_host_t *ha) | 367 | qla2x00_reset_chip(scsi_qla_host_t *vha) |
363 | { | 368 | { |
364 | unsigned long flags = 0; | 369 | unsigned long flags = 0; |
370 | struct qla_hw_data *ha = vha->hw; | ||
365 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; | 371 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
366 | uint32_t cnt; | 372 | uint32_t cnt; |
367 | uint16_t cmd; | 373 | uint16_t cmd; |
@@ -499,10 +505,11 @@ qla2x00_reset_chip(scsi_qla_host_t *ha) | |||
499 | * Returns 0 on success. | 505 | * Returns 0 on success. |
500 | */ | 506 | */ |
501 | static inline void | 507 | static inline void |
502 | qla24xx_reset_risc(scsi_qla_host_t *ha) | 508 | qla24xx_reset_risc(scsi_qla_host_t *vha) |
503 | { | 509 | { |
504 | int hw_evt = 0; | 510 | int hw_evt = 0; |
505 | unsigned long flags = 0; | 511 | unsigned long flags = 0; |
512 | struct qla_hw_data *ha = vha->hw; | ||
506 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; | 513 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
507 | uint32_t cnt, d2; | 514 | uint32_t cnt, d2; |
508 | uint16_t wd; | 515 | uint16_t wd; |
@@ -541,7 +548,7 @@ qla24xx_reset_risc(scsi_qla_host_t *ha) | |||
541 | barrier(); | 548 | barrier(); |
542 | } | 549 | } |
543 | if (cnt == 0 || hw_evt) | 550 | if (cnt == 0 || hw_evt) |
544 | qla2xxx_hw_event_log(ha, HW_EVENT_RESET_ERR, | 551 | qla2xxx_hw_event_log(vha, HW_EVENT_RESET_ERR, |
545 | RD_REG_WORD(®->mailbox1), RD_REG_WORD(®->mailbox2), | 552 | RD_REG_WORD(®->mailbox1), RD_REG_WORD(®->mailbox2), |
546 | RD_REG_WORD(®->mailbox3)); | 553 | RD_REG_WORD(®->mailbox3)); |
547 | 554 | ||
@@ -571,12 +578,13 @@ qla24xx_reset_risc(scsi_qla_host_t *ha) | |||
571 | * Returns 0 on success. | 578 | * Returns 0 on success. |
572 | */ | 579 | */ |
573 | void | 580 | void |
574 | qla24xx_reset_chip(scsi_qla_host_t *ha) | 581 | qla24xx_reset_chip(scsi_qla_host_t *vha) |
575 | { | 582 | { |
583 | struct qla_hw_data *ha = vha->hw; | ||
576 | ha->isp_ops->disable_intrs(ha); | 584 | ha->isp_ops->disable_intrs(ha); |
577 | 585 | ||
578 | /* Perform RISC reset. */ | 586 | /* Perform RISC reset. */ |
579 | qla24xx_reset_risc(ha); | 587 | qla24xx_reset_risc(vha); |
580 | } | 588 | } |
581 | 589 | ||
582 | /** | 590 | /** |
@@ -586,9 +594,10 @@ qla24xx_reset_chip(scsi_qla_host_t *ha) | |||
586 | * Returns 0 on success. | 594 | * Returns 0 on success. |
587 | */ | 595 | */ |
588 | int | 596 | int |
589 | qla2x00_chip_diag(scsi_qla_host_t *ha) | 597 | qla2x00_chip_diag(scsi_qla_host_t *vha) |
590 | { | 598 | { |
591 | int rval; | 599 | int rval; |
600 | struct qla_hw_data *ha = vha->hw; | ||
592 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; | 601 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
593 | unsigned long flags = 0; | 602 | unsigned long flags = 0; |
594 | uint16_t data; | 603 | uint16_t data; |
@@ -599,7 +608,7 @@ qla2x00_chip_diag(scsi_qla_host_t *ha) | |||
599 | rval = QLA_FUNCTION_FAILED; | 608 | rval = QLA_FUNCTION_FAILED; |
600 | 609 | ||
601 | DEBUG3(printk("scsi(%ld): Testing device at %lx.\n", | 610 | DEBUG3(printk("scsi(%ld): Testing device at %lx.\n", |
602 | ha->host_no, (u_long)®->flash_address)); | 611 | vha->host_no, (u_long)®->flash_address)); |
603 | 612 | ||
604 | spin_lock_irqsave(&ha->hardware_lock, flags); | 613 | spin_lock_irqsave(&ha->hardware_lock, flags); |
605 | 614 | ||
@@ -662,17 +671,17 @@ qla2x00_chip_diag(scsi_qla_host_t *ha) | |||
662 | ha->product_id[3] = mb[4]; | 671 | ha->product_id[3] = mb[4]; |
663 | 672 | ||
664 | /* Adjust fw RISC transfer size */ | 673 | /* Adjust fw RISC transfer size */ |
665 | if (ha->request_q_length > 1024) | 674 | if (ha->req->length > 1024) |
666 | ha->fw_transfer_size = REQUEST_ENTRY_SIZE * 1024; | 675 | ha->fw_transfer_size = REQUEST_ENTRY_SIZE * 1024; |
667 | else | 676 | else |
668 | ha->fw_transfer_size = REQUEST_ENTRY_SIZE * | 677 | ha->fw_transfer_size = REQUEST_ENTRY_SIZE * |
669 | ha->request_q_length; | 678 | ha->req->length; |
670 | 679 | ||
671 | if (IS_QLA2200(ha) && | 680 | if (IS_QLA2200(ha) && |
672 | RD_MAILBOX_REG(ha, reg, 7) == QLA2200A_RISC_ROM_VER) { | 681 | RD_MAILBOX_REG(ha, reg, 7) == QLA2200A_RISC_ROM_VER) { |
673 | /* Limit firmware transfer size with a 2200A */ | 682 | /* Limit firmware transfer size with a 2200A */ |
674 | DEBUG3(printk("scsi(%ld): Found QLA2200A chip.\n", | 683 | DEBUG3(printk("scsi(%ld): Found QLA2200A chip.\n", |
675 | ha->host_no)); | 684 | vha->host_no)); |
676 | 685 | ||
677 | ha->device_type |= DT_ISP2200A; | 686 | ha->device_type |= DT_ISP2200A; |
678 | ha->fw_transfer_size = 128; | 687 | ha->fw_transfer_size = 128; |
@@ -681,11 +690,11 @@ qla2x00_chip_diag(scsi_qla_host_t *ha) | |||
681 | /* Wrap Incoming Mailboxes Test. */ | 690 | /* Wrap Incoming Mailboxes Test. */ |
682 | spin_unlock_irqrestore(&ha->hardware_lock, flags); | 691 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
683 | 692 | ||
684 | DEBUG3(printk("scsi(%ld): Checking mailboxes.\n", ha->host_no)); | 693 | DEBUG3(printk("scsi(%ld): Checking mailboxes.\n", vha->host_no)); |
685 | rval = qla2x00_mbx_reg_test(ha); | 694 | rval = qla2x00_mbx_reg_test(vha); |
686 | if (rval) { | 695 | if (rval) { |
687 | DEBUG(printk("scsi(%ld): Failed mailbox send register test\n", | 696 | DEBUG(printk("scsi(%ld): Failed mailbox send register test\n", |
688 | ha->host_no)); | 697 | vha->host_no)); |
689 | qla_printk(KERN_WARNING, ha, | 698 | qla_printk(KERN_WARNING, ha, |
690 | "Failed mailbox send register test\n"); | 699 | "Failed mailbox send register test\n"); |
691 | } | 700 | } |
@@ -698,7 +707,7 @@ qla2x00_chip_diag(scsi_qla_host_t *ha) | |||
698 | chip_diag_failed: | 707 | chip_diag_failed: |
699 | if (rval) | 708 | if (rval) |
700 | DEBUG2_3(printk("scsi(%ld): Chip diagnostics **** FAILED " | 709 | DEBUG2_3(printk("scsi(%ld): Chip diagnostics **** FAILED " |
701 | "****\n", ha->host_no)); | 710 | "****\n", vha->host_no)); |
702 | 711 | ||
703 | spin_unlock_irqrestore(&ha->hardware_lock, flags); | 712 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
704 | 713 | ||
@@ -712,19 +721,20 @@ chip_diag_failed: | |||
712 | * Returns 0 on success. | 721 | * Returns 0 on success. |
713 | */ | 722 | */ |
714 | int | 723 | int |
715 | qla24xx_chip_diag(scsi_qla_host_t *ha) | 724 | qla24xx_chip_diag(scsi_qla_host_t *vha) |
716 | { | 725 | { |
717 | int rval; | 726 | int rval; |
727 | struct qla_hw_data *ha = vha->hw; | ||
718 | 728 | ||
719 | /* Perform RISC reset. */ | 729 | /* Perform RISC reset. */ |
720 | qla24xx_reset_risc(ha); | 730 | qla24xx_reset_risc(vha); |
721 | 731 | ||
722 | ha->fw_transfer_size = REQUEST_ENTRY_SIZE * ha->request_q_length; | 732 | ha->fw_transfer_size = REQUEST_ENTRY_SIZE * ha->req->length; |
723 | 733 | ||
724 | rval = qla2x00_mbx_reg_test(ha); | 734 | rval = qla2x00_mbx_reg_test(vha); |
725 | if (rval) { | 735 | if (rval) { |
726 | DEBUG(printk("scsi(%ld): Failed mailbox send register test\n", | 736 | DEBUG(printk("scsi(%ld): Failed mailbox send register test\n", |
727 | ha->host_no)); | 737 | vha->host_no)); |
728 | qla_printk(KERN_WARNING, ha, | 738 | qla_printk(KERN_WARNING, ha, |
729 | "Failed mailbox send register test\n"); | 739 | "Failed mailbox send register test\n"); |
730 | } else { | 740 | } else { |
@@ -736,13 +746,14 @@ qla24xx_chip_diag(scsi_qla_host_t *ha) | |||
736 | } | 746 | } |
737 | 747 | ||
738 | void | 748 | void |
739 | qla2x00_alloc_fw_dump(scsi_qla_host_t *ha) | 749 | qla2x00_alloc_fw_dump(scsi_qla_host_t *vha) |
740 | { | 750 | { |
741 | int rval; | 751 | int rval; |
742 | uint32_t dump_size, fixed_size, mem_size, req_q_size, rsp_q_size, | 752 | uint32_t dump_size, fixed_size, mem_size, req_q_size, rsp_q_size, |
743 | eft_size, fce_size; | 753 | eft_size, fce_size; |
744 | dma_addr_t tc_dma; | 754 | dma_addr_t tc_dma; |
745 | void *tc; | 755 | void *tc; |
756 | struct qla_hw_data *ha = vha->hw; | ||
746 | 757 | ||
747 | if (ha->fw_dump) { | 758 | if (ha->fw_dump) { |
748 | qla_printk(KERN_WARNING, ha, | 759 | qla_printk(KERN_WARNING, ha, |
@@ -778,7 +789,7 @@ qla2x00_alloc_fw_dump(scsi_qla_host_t *ha) | |||
778 | } | 789 | } |
779 | 790 | ||
780 | memset(tc, 0, FCE_SIZE); | 791 | memset(tc, 0, FCE_SIZE); |
781 | rval = qla2x00_enable_fce_trace(ha, tc_dma, FCE_NUM_BUFFERS, | 792 | rval = qla2x00_enable_fce_trace(vha, tc_dma, FCE_NUM_BUFFERS, |
782 | ha->fce_mb, &ha->fce_bufs); | 793 | ha->fce_mb, &ha->fce_bufs); |
783 | if (rval) { | 794 | if (rval) { |
784 | qla_printk(KERN_WARNING, ha, "Unable to initialize " | 795 | qla_printk(KERN_WARNING, ha, "Unable to initialize " |
@@ -807,7 +818,7 @@ try_eft: | |||
807 | } | 818 | } |
808 | 819 | ||
809 | memset(tc, 0, EFT_SIZE); | 820 | memset(tc, 0, EFT_SIZE); |
810 | rval = qla2x00_enable_eft_trace(ha, tc_dma, EFT_NUM_BUFFERS); | 821 | rval = qla2x00_enable_eft_trace(vha, tc_dma, EFT_NUM_BUFFERS); |
811 | if (rval) { | 822 | if (rval) { |
812 | qla_printk(KERN_WARNING, ha, "Unable to initialize " | 823 | qla_printk(KERN_WARNING, ha, "Unable to initialize " |
813 | "EFT (%d).\n", rval); | 824 | "EFT (%d).\n", rval); |
@@ -824,8 +835,8 @@ try_eft: | |||
824 | ha->eft = tc; | 835 | ha->eft = tc; |
825 | } | 836 | } |
826 | cont_alloc: | 837 | cont_alloc: |
827 | req_q_size = ha->request_q_length * sizeof(request_t); | 838 | req_q_size = ha->req->length * sizeof(request_t); |
828 | rsp_q_size = ha->response_q_length * sizeof(response_t); | 839 | rsp_q_size = ha->rsp->length * sizeof(response_t); |
829 | 840 | ||
830 | dump_size = offsetof(struct qla2xxx_fw_dump, isp); | 841 | dump_size = offsetof(struct qla2xxx_fw_dump, isp); |
831 | dump_size += fixed_size + mem_size + req_q_size + rsp_q_size + | 842 | dump_size += fixed_size + mem_size + req_q_size + rsp_q_size + |
@@ -875,27 +886,29 @@ cont_alloc: | |||
875 | * Returns 0 on success. | 886 | * Returns 0 on success. |
876 | */ | 887 | */ |
877 | static void | 888 | static void |
878 | qla2x00_resize_request_q(scsi_qla_host_t *ha) | 889 | qla2x00_resize_request_q(scsi_qla_host_t *vha) |
879 | { | 890 | { |
880 | int rval; | 891 | int rval; |
881 | uint16_t fw_iocb_cnt = 0; | 892 | uint16_t fw_iocb_cnt = 0; |
882 | uint16_t request_q_length = REQUEST_ENTRY_CNT_2XXX_EXT_MEM; | 893 | uint16_t request_q_length = REQUEST_ENTRY_CNT_2XXX_EXT_MEM; |
883 | dma_addr_t request_dma; | 894 | dma_addr_t request_dma; |
884 | request_t *request_ring; | 895 | request_t *request_ring; |
896 | struct qla_hw_data *ha = vha->hw; | ||
897 | struct req_que *req = ha->req; | ||
885 | 898 | ||
886 | /* Valid only on recent ISPs. */ | 899 | /* Valid only on recent ISPs. */ |
887 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) | 900 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) |
888 | return; | 901 | return; |
889 | 902 | ||
890 | /* Retrieve IOCB counts available to the firmware. */ | 903 | /* Retrieve IOCB counts available to the firmware. */ |
891 | rval = qla2x00_get_resource_cnts(ha, NULL, NULL, NULL, &fw_iocb_cnt, | 904 | rval = qla2x00_get_resource_cnts(vha, NULL, NULL, NULL, &fw_iocb_cnt, |
892 | &ha->max_npiv_vports); | 905 | &ha->max_npiv_vports); |
893 | if (rval) | 906 | if (rval) |
894 | return; | 907 | return; |
895 | /* No point in continuing if current settings are sufficient. */ | 908 | /* No point in continuing if current settings are sufficient. */ |
896 | if (fw_iocb_cnt < 1024) | 909 | if (fw_iocb_cnt < 1024) |
897 | return; | 910 | return; |
898 | if (ha->request_q_length >= request_q_length) | 911 | if (req->length >= request_q_length) |
899 | return; | 912 | return; |
900 | 913 | ||
901 | /* Attempt to claim larger area for request queue. */ | 914 | /* Attempt to claim larger area for request queue. */ |
@@ -909,17 +922,17 @@ qla2x00_resize_request_q(scsi_qla_host_t *ha) | |||
909 | qla_printk(KERN_INFO, ha, "Extended memory detected (%d KB)...\n", | 922 | qla_printk(KERN_INFO, ha, "Extended memory detected (%d KB)...\n", |
910 | (ha->fw_memory_size + 1) / 1024); | 923 | (ha->fw_memory_size + 1) / 1024); |
911 | qla_printk(KERN_INFO, ha, "Resizing request queue depth " | 924 | qla_printk(KERN_INFO, ha, "Resizing request queue depth " |
912 | "(%d -> %d)...\n", ha->request_q_length, request_q_length); | 925 | "(%d -> %d)...\n", req->length, request_q_length); |
913 | 926 | ||
914 | /* Clear old allocations. */ | 927 | /* Clear old allocations. */ |
915 | dma_free_coherent(&ha->pdev->dev, | 928 | dma_free_coherent(&ha->pdev->dev, |
916 | (ha->request_q_length + 1) * sizeof(request_t), ha->request_ring, | 929 | (req->length + 1) * sizeof(request_t), req->ring, |
917 | ha->request_dma); | 930 | req->dma); |
918 | 931 | ||
919 | /* Begin using larger queue. */ | 932 | /* Begin using larger queue. */ |
920 | ha->request_q_length = request_q_length; | 933 | req->length = request_q_length; |
921 | ha->request_ring = request_ring; | 934 | req->ring = request_ring; |
922 | ha->request_dma = request_dma; | 935 | req->dma = request_dma; |
923 | } | 936 | } |
924 | 937 | ||
925 | /** | 938 | /** |
@@ -929,10 +942,11 @@ qla2x00_resize_request_q(scsi_qla_host_t *ha) | |||
929 | * Returns 0 on success. | 942 | * Returns 0 on success. |
930 | */ | 943 | */ |
931 | static int | 944 | static int |
932 | qla2x00_setup_chip(scsi_qla_host_t *ha) | 945 | qla2x00_setup_chip(scsi_qla_host_t *vha) |
933 | { | 946 | { |
934 | int rval; | 947 | int rval; |
935 | uint32_t srisc_address = 0; | 948 | uint32_t srisc_address = 0; |
949 | struct qla_hw_data *ha = vha->hw; | ||
936 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; | 950 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
937 | unsigned long flags; | 951 | unsigned long flags; |
938 | 952 | ||
@@ -945,28 +959,27 @@ qla2x00_setup_chip(scsi_qla_host_t *ha) | |||
945 | } | 959 | } |
946 | 960 | ||
947 | /* Load firmware sequences */ | 961 | /* Load firmware sequences */ |
948 | rval = ha->isp_ops->load_risc(ha, &srisc_address); | 962 | rval = ha->isp_ops->load_risc(vha, &srisc_address); |
949 | if (rval == QLA_SUCCESS) { | 963 | if (rval == QLA_SUCCESS) { |
950 | DEBUG(printk("scsi(%ld): Verifying Checksum of loaded RISC " | 964 | DEBUG(printk("scsi(%ld): Verifying Checksum of loaded RISC " |
951 | "code.\n", ha->host_no)); | 965 | "code.\n", vha->host_no)); |
952 | 966 | ||
953 | rval = qla2x00_verify_checksum(ha, srisc_address); | 967 | rval = qla2x00_verify_checksum(vha, srisc_address); |
954 | if (rval == QLA_SUCCESS) { | 968 | if (rval == QLA_SUCCESS) { |
955 | /* Start firmware execution. */ | 969 | /* Start firmware execution. */ |
956 | DEBUG(printk("scsi(%ld): Checksum OK, start " | 970 | DEBUG(printk("scsi(%ld): Checksum OK, start " |
957 | "firmware.\n", ha->host_no)); | 971 | "firmware.\n", vha->host_no)); |
958 | 972 | ||
959 | rval = qla2x00_execute_fw(ha, srisc_address); | 973 | rval = qla2x00_execute_fw(vha, srisc_address); |
960 | /* Retrieve firmware information. */ | 974 | /* Retrieve firmware information. */ |
961 | if (rval == QLA_SUCCESS && ha->fw_major_version == 0) { | 975 | if (rval == QLA_SUCCESS && ha->fw_major_version == 0) { |
962 | qla2x00_get_fw_version(ha, | 976 | qla2x00_get_fw_version(vha, |
963 | &ha->fw_major_version, | 977 | &ha->fw_major_version, |
964 | &ha->fw_minor_version, | 978 | &ha->fw_minor_version, |
965 | &ha->fw_subminor_version, | 979 | &ha->fw_subminor_version, |
966 | &ha->fw_attributes, &ha->fw_memory_size); | 980 | &ha->fw_attributes, &ha->fw_memory_size); |
967 | ha->flags.npiv_supported = 0; | 981 | ha->flags.npiv_supported = 0; |
968 | if ((IS_QLA24XX(ha) || IS_QLA25XX(ha) || | 982 | if (IS_QLA2XXX_MIDTYPE(ha) && |
969 | IS_QLA84XX(ha)) && | ||
970 | (ha->fw_attributes & BIT_2)) { | 983 | (ha->fw_attributes & BIT_2)) { |
971 | ha->flags.npiv_supported = 1; | 984 | ha->flags.npiv_supported = 1; |
972 | if ((!ha->max_npiv_vports) || | 985 | if ((!ha->max_npiv_vports) || |
@@ -975,15 +988,15 @@ qla2x00_setup_chip(scsi_qla_host_t *ha) | |||
975 | ha->max_npiv_vports = | 988 | ha->max_npiv_vports = |
976 | MIN_MULTI_ID_FABRIC - 1; | 989 | MIN_MULTI_ID_FABRIC - 1; |
977 | } | 990 | } |
978 | qla2x00_resize_request_q(ha); | 991 | qla2x00_resize_request_q(vha); |
979 | 992 | ||
980 | if (ql2xallocfwdump) | 993 | if (ql2xallocfwdump) |
981 | qla2x00_alloc_fw_dump(ha); | 994 | qla2x00_alloc_fw_dump(vha); |
982 | } | 995 | } |
983 | } else { | 996 | } else { |
984 | DEBUG2(printk(KERN_INFO | 997 | DEBUG2(printk(KERN_INFO |
985 | "scsi(%ld): ISP Firmware failed checksum.\n", | 998 | "scsi(%ld): ISP Firmware failed checksum.\n", |
986 | ha->host_no)); | 999 | vha->host_no)); |
987 | } | 1000 | } |
988 | } | 1001 | } |
989 | 1002 | ||
@@ -1002,7 +1015,7 @@ qla2x00_setup_chip(scsi_qla_host_t *ha) | |||
1002 | 1015 | ||
1003 | if (rval) { | 1016 | if (rval) { |
1004 | DEBUG2_3(printk("scsi(%ld): Setup chip **** FAILED ****.\n", | 1017 | DEBUG2_3(printk("scsi(%ld): Setup chip **** FAILED ****.\n", |
1005 | ha->host_no)); | 1018 | vha->host_no)); |
1006 | } | 1019 | } |
1007 | 1020 | ||
1008 | return (rval); | 1021 | return (rval); |
@@ -1018,13 +1031,14 @@ qla2x00_setup_chip(scsi_qla_host_t *ha) | |||
1018 | * Returns 0 on success. | 1031 | * Returns 0 on success. |
1019 | */ | 1032 | */ |
1020 | static void | 1033 | static void |
1021 | qla2x00_init_response_q_entries(scsi_qla_host_t *ha) | 1034 | qla2x00_init_response_q_entries(scsi_qla_host_t *vha) |
1022 | { | 1035 | { |
1023 | uint16_t cnt; | 1036 | uint16_t cnt; |
1024 | response_t *pkt; | 1037 | response_t *pkt; |
1038 | struct rsp_que *rsp = vha->hw->rsp; | ||
1025 | 1039 | ||
1026 | pkt = ha->response_ring_ptr; | 1040 | pkt = rsp->ring_ptr; |
1027 | for (cnt = 0; cnt < ha->response_q_length; cnt++) { | 1041 | for (cnt = 0; cnt < rsp->length; cnt++) { |
1028 | pkt->signature = RESPONSE_PROCESSED; | 1042 | pkt->signature = RESPONSE_PROCESSED; |
1029 | pkt++; | 1043 | pkt++; |
1030 | } | 1044 | } |
@@ -1038,19 +1052,20 @@ qla2x00_init_response_q_entries(scsi_qla_host_t *ha) | |||
1038 | * Returns 0 on success. | 1052 | * Returns 0 on success. |
1039 | */ | 1053 | */ |
1040 | void | 1054 | void |
1041 | qla2x00_update_fw_options(scsi_qla_host_t *ha) | 1055 | qla2x00_update_fw_options(scsi_qla_host_t *vha) |
1042 | { | 1056 | { |
1043 | uint16_t swing, emphasis, tx_sens, rx_sens; | 1057 | uint16_t swing, emphasis, tx_sens, rx_sens; |
1058 | struct qla_hw_data *ha = vha->hw; | ||
1044 | 1059 | ||
1045 | memset(ha->fw_options, 0, sizeof(ha->fw_options)); | 1060 | memset(ha->fw_options, 0, sizeof(ha->fw_options)); |
1046 | qla2x00_get_fw_options(ha, ha->fw_options); | 1061 | qla2x00_get_fw_options(vha, ha->fw_options); |
1047 | 1062 | ||
1048 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) | 1063 | if (IS_QLA2100(ha) || IS_QLA2200(ha)) |
1049 | return; | 1064 | return; |
1050 | 1065 | ||
1051 | /* Serial Link options. */ | 1066 | /* Serial Link options. */ |
1052 | DEBUG3(printk("scsi(%ld): Serial link options:\n", | 1067 | DEBUG3(printk("scsi(%ld): Serial link options:\n", |
1053 | ha->host_no)); | 1068 | vha->host_no)); |
1054 | DEBUG3(qla2x00_dump_buffer((uint8_t *)&ha->fw_seriallink_options, | 1069 | DEBUG3(qla2x00_dump_buffer((uint8_t *)&ha->fw_seriallink_options, |
1055 | sizeof(ha->fw_seriallink_options))); | 1070 | sizeof(ha->fw_seriallink_options))); |
1056 | 1071 | ||
@@ -1108,19 +1123,20 @@ qla2x00_update_fw_options(scsi_qla_host_t *ha) | |||
1108 | ha->fw_options[2] |= BIT_13; | 1123 | ha->fw_options[2] |= BIT_13; |
1109 | 1124 | ||
1110 | /* Update firmware options. */ | 1125 | /* Update firmware options. */ |
1111 | qla2x00_set_fw_options(ha, ha->fw_options); | 1126 | qla2x00_set_fw_options(vha, ha->fw_options); |
1112 | } | 1127 | } |
1113 | 1128 | ||
1114 | void | 1129 | void |
1115 | qla24xx_update_fw_options(scsi_qla_host_t *ha) | 1130 | qla24xx_update_fw_options(scsi_qla_host_t *vha) |
1116 | { | 1131 | { |
1117 | int rval; | 1132 | int rval; |
1133 | struct qla_hw_data *ha = vha->hw; | ||
1118 | 1134 | ||
1119 | /* Update Serial Link options. */ | 1135 | /* Update Serial Link options. */ |
1120 | if ((le16_to_cpu(ha->fw_seriallink_options24[0]) & BIT_0) == 0) | 1136 | if ((le16_to_cpu(ha->fw_seriallink_options24[0]) & BIT_0) == 0) |
1121 | return; | 1137 | return; |
1122 | 1138 | ||
1123 | rval = qla2x00_set_serdes_params(ha, | 1139 | rval = qla2x00_set_serdes_params(vha, |
1124 | le16_to_cpu(ha->fw_seriallink_options24[1]), | 1140 | le16_to_cpu(ha->fw_seriallink_options24[1]), |
1125 | le16_to_cpu(ha->fw_seriallink_options24[2]), | 1141 | le16_to_cpu(ha->fw_seriallink_options24[2]), |
1126 | le16_to_cpu(ha->fw_seriallink_options24[3])); | 1142 | le16_to_cpu(ha->fw_seriallink_options24[3])); |
@@ -1131,19 +1147,22 @@ qla24xx_update_fw_options(scsi_qla_host_t *ha) | |||
1131 | } | 1147 | } |
1132 | 1148 | ||
1133 | void | 1149 | void |
1134 | qla2x00_config_rings(struct scsi_qla_host *ha) | 1150 | qla2x00_config_rings(struct scsi_qla_host *vha) |
1135 | { | 1151 | { |
1152 | struct qla_hw_data *ha = vha->hw; | ||
1136 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; | 1153 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
1154 | struct req_que *req = ha->req; | ||
1155 | struct rsp_que *rsp = ha->rsp; | ||
1137 | 1156 | ||
1138 | /* Setup ring parameters in initialization control block. */ | 1157 | /* Setup ring parameters in initialization control block. */ |
1139 | ha->init_cb->request_q_outpointer = __constant_cpu_to_le16(0); | 1158 | ha->init_cb->request_q_outpointer = __constant_cpu_to_le16(0); |
1140 | ha->init_cb->response_q_inpointer = __constant_cpu_to_le16(0); | 1159 | ha->init_cb->response_q_inpointer = __constant_cpu_to_le16(0); |
1141 | ha->init_cb->request_q_length = cpu_to_le16(ha->request_q_length); | 1160 | ha->init_cb->request_q_length = cpu_to_le16(req->length); |
1142 | ha->init_cb->response_q_length = cpu_to_le16(ha->response_q_length); | 1161 | ha->init_cb->response_q_length = cpu_to_le16(rsp->length); |
1143 | ha->init_cb->request_q_address[0] = cpu_to_le32(LSD(ha->request_dma)); | 1162 | ha->init_cb->request_q_address[0] = cpu_to_le32(LSD(req->dma)); |
1144 | ha->init_cb->request_q_address[1] = cpu_to_le32(MSD(ha->request_dma)); | 1163 | ha->init_cb->request_q_address[1] = cpu_to_le32(MSD(req->dma)); |
1145 | ha->init_cb->response_q_address[0] = cpu_to_le32(LSD(ha->response_dma)); | 1164 | ha->init_cb->response_q_address[0] = cpu_to_le32(LSD(rsp->dma)); |
1146 | ha->init_cb->response_q_address[1] = cpu_to_le32(MSD(ha->response_dma)); | 1165 | ha->init_cb->response_q_address[1] = cpu_to_le32(MSD(rsp->dma)); |
1147 | 1166 | ||
1148 | WRT_REG_WORD(ISP_REQ_Q_IN(ha, reg), 0); | 1167 | WRT_REG_WORD(ISP_REQ_Q_IN(ha, reg), 0); |
1149 | WRT_REG_WORD(ISP_REQ_Q_OUT(ha, reg), 0); | 1168 | WRT_REG_WORD(ISP_REQ_Q_OUT(ha, reg), 0); |
@@ -1153,21 +1172,24 @@ qla2x00_config_rings(struct scsi_qla_host *ha) | |||
1153 | } | 1172 | } |
1154 | 1173 | ||
1155 | void | 1174 | void |
1156 | qla24xx_config_rings(struct scsi_qla_host *ha) | 1175 | qla24xx_config_rings(struct scsi_qla_host *vha) |
1157 | { | 1176 | { |
1177 | struct qla_hw_data *ha = vha->hw; | ||
1158 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; | 1178 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
1159 | struct init_cb_24xx *icb; | 1179 | struct init_cb_24xx *icb; |
1180 | struct req_que *req = ha->req; | ||
1181 | struct rsp_que *rsp = ha->rsp; | ||
1160 | 1182 | ||
1161 | /* Setup ring parameters in initialization control block. */ | 1183 | /* Setup ring parameters in initialization control block. */ |
1162 | icb = (struct init_cb_24xx *)ha->init_cb; | 1184 | icb = (struct init_cb_24xx *)ha->init_cb; |
1163 | icb->request_q_outpointer = __constant_cpu_to_le16(0); | 1185 | icb->request_q_outpointer = __constant_cpu_to_le16(0); |
1164 | icb->response_q_inpointer = __constant_cpu_to_le16(0); | 1186 | icb->response_q_inpointer = __constant_cpu_to_le16(0); |
1165 | icb->request_q_length = cpu_to_le16(ha->request_q_length); | 1187 | icb->request_q_length = cpu_to_le16(req->length); |
1166 | icb->response_q_length = cpu_to_le16(ha->response_q_length); | 1188 | icb->response_q_length = cpu_to_le16(rsp->length); |
1167 | icb->request_q_address[0] = cpu_to_le32(LSD(ha->request_dma)); | 1189 | icb->request_q_address[0] = cpu_to_le32(LSD(req->dma)); |
1168 | icb->request_q_address[1] = cpu_to_le32(MSD(ha->request_dma)); | 1190 | icb->request_q_address[1] = cpu_to_le32(MSD(req->dma)); |
1169 | icb->response_q_address[0] = cpu_to_le32(LSD(ha->response_dma)); | 1191 | icb->response_q_address[0] = cpu_to_le32(LSD(rsp->dma)); |
1170 | icb->response_q_address[1] = cpu_to_le32(MSD(ha->response_dma)); | 1192 | icb->response_q_address[1] = cpu_to_le32(MSD(rsp->dma)); |
1171 | 1193 | ||
1172 | WRT_REG_DWORD(®->req_q_in, 0); | 1194 | WRT_REG_DWORD(®->req_q_in, 0); |
1173 | WRT_REG_DWORD(®->req_q_out, 0); | 1195 | WRT_REG_DWORD(®->req_q_out, 0); |
@@ -1186,11 +1208,14 @@ qla24xx_config_rings(struct scsi_qla_host *ha) | |||
1186 | * Returns 0 on success. | 1208 | * Returns 0 on success. |
1187 | */ | 1209 | */ |
1188 | static int | 1210 | static int |
1189 | qla2x00_init_rings(scsi_qla_host_t *ha) | 1211 | qla2x00_init_rings(scsi_qla_host_t *vha) |
1190 | { | 1212 | { |
1191 | int rval; | 1213 | int rval; |
1192 | unsigned long flags = 0; | 1214 | unsigned long flags = 0; |
1193 | int cnt; | 1215 | int cnt; |
1216 | struct qla_hw_data *ha = vha->hw; | ||
1217 | struct req_que *req = ha->req; | ||
1218 | struct rsp_que *rsp = ha->rsp; | ||
1194 | struct mid_init_cb_24xx *mid_init_cb = | 1219 | struct mid_init_cb_24xx *mid_init_cb = |
1195 | (struct mid_init_cb_24xx *) ha->init_cb; | 1220 | (struct mid_init_cb_24xx *) ha->init_cb; |
1196 | 1221 | ||
@@ -1198,45 +1223,45 @@ qla2x00_init_rings(scsi_qla_host_t *ha) | |||
1198 | 1223 | ||
1199 | /* Clear outstanding commands array. */ | 1224 | /* Clear outstanding commands array. */ |
1200 | for (cnt = 0; cnt < MAX_OUTSTANDING_COMMANDS; cnt++) | 1225 | for (cnt = 0; cnt < MAX_OUTSTANDING_COMMANDS; cnt++) |
1201 | ha->outstanding_cmds[cnt] = NULL; | 1226 | req->outstanding_cmds[cnt] = NULL; |
1202 | 1227 | ||
1203 | ha->current_outstanding_cmd = 0; | 1228 | req->current_outstanding_cmd = 0; |
1204 | 1229 | ||
1205 | /* Clear RSCN queue. */ | 1230 | /* Clear RSCN queue. */ |
1206 | ha->rscn_in_ptr = 0; | 1231 | vha->rscn_in_ptr = 0; |
1207 | ha->rscn_out_ptr = 0; | 1232 | vha->rscn_out_ptr = 0; |
1208 | 1233 | ||
1209 | /* Initialize firmware. */ | 1234 | /* Initialize firmware. */ |
1210 | ha->request_ring_ptr = ha->request_ring; | 1235 | req->ring_ptr = req->ring; |
1211 | ha->req_ring_index = 0; | 1236 | req->ring_index = 0; |
1212 | ha->req_q_cnt = ha->request_q_length; | 1237 | req->cnt = req->length; |
1213 | ha->response_ring_ptr = ha->response_ring; | 1238 | rsp->ring_ptr = rsp->ring; |
1214 | ha->rsp_ring_index = 0; | 1239 | rsp->ring_index = 0; |
1215 | 1240 | ||
1216 | /* Initialize response queue entries */ | 1241 | /* Initialize response queue entries */ |
1217 | qla2x00_init_response_q_entries(ha); | 1242 | qla2x00_init_response_q_entries(vha); |
1218 | 1243 | ||
1219 | ha->isp_ops->config_rings(ha); | 1244 | ha->isp_ops->config_rings(vha); |
1220 | 1245 | ||
1221 | spin_unlock_irqrestore(&ha->hardware_lock, flags); | 1246 | spin_unlock_irqrestore(&ha->hardware_lock, flags); |
1222 | 1247 | ||
1223 | /* Update any ISP specific firmware options before initialization. */ | 1248 | /* Update any ISP specific firmware options before initialization. */ |
1224 | ha->isp_ops->update_fw_options(ha); | 1249 | ha->isp_ops->update_fw_options(vha); |
1225 | 1250 | ||
1226 | DEBUG(printk("scsi(%ld): Issue init firmware.\n", ha->host_no)); | 1251 | DEBUG(printk("scsi(%ld): Issue init firmware.\n", vha->host_no)); |
1227 | 1252 | ||
1228 | if (ha->flags.npiv_supported) | 1253 | if (ha->flags.npiv_supported) |
1229 | mid_init_cb->count = cpu_to_le16(ha->max_npiv_vports); | 1254 | mid_init_cb->count = cpu_to_le16(ha->max_npiv_vports); |
1230 | 1255 | ||
1231 | mid_init_cb->options = __constant_cpu_to_le16(BIT_1); | 1256 | mid_init_cb->options = __constant_cpu_to_le16(BIT_1); |
1232 | 1257 | ||
1233 | rval = qla2x00_init_firmware(ha, ha->init_cb_size); | 1258 | rval = qla2x00_init_firmware(vha, ha->init_cb_size); |
1234 | if (rval) { | 1259 | if (rval) { |
1235 | DEBUG2_3(printk("scsi(%ld): Init firmware **** FAILED ****.\n", | 1260 | DEBUG2_3(printk("scsi(%ld): Init firmware **** FAILED ****.\n", |
1236 | ha->host_no)); | 1261 | vha->host_no)); |
1237 | } else { | 1262 | } else { |
1238 | DEBUG3(printk("scsi(%ld): Init firmware -- success.\n", | 1263 | DEBUG3(printk("scsi(%ld): Init firmware -- success.\n", |
1239 | ha->host_no)); | 1264 | vha->host_no)); |
1240 | } | 1265 | } |
1241 | 1266 | ||
1242 | return (rval); | 1267 | return (rval); |
@@ -1249,13 +1274,14 @@ qla2x00_init_rings(scsi_qla_host_t *ha) | |||
1249 | * Returns 0 on success. | 1274 | * Returns 0 on success. |
1250 | */ | 1275 | */ |
1251 | static int | 1276 | static int |
1252 | qla2x00_fw_ready(scsi_qla_host_t *ha) | 1277 | qla2x00_fw_ready(scsi_qla_host_t *vha) |
1253 | { | 1278 | { |
1254 | int rval; | 1279 | int rval; |
1255 | unsigned long wtime, mtime, cs84xx_time; | 1280 | unsigned long wtime, mtime, cs84xx_time; |
1256 | uint16_t min_wait; /* Minimum wait time if loop is down */ | 1281 | uint16_t min_wait; /* Minimum wait time if loop is down */ |
1257 | uint16_t wait_time; /* Wait time if loop is coming ready */ | 1282 | uint16_t wait_time; /* Wait time if loop is coming ready */ |
1258 | uint16_t state[3]; | 1283 | uint16_t state[3]; |
1284 | struct qla_hw_data *ha = vha->hw; | ||
1259 | 1285 | ||
1260 | rval = QLA_SUCCESS; | 1286 | rval = QLA_SUCCESS; |
1261 | 1287 | ||
@@ -1277,29 +1303,29 @@ qla2x00_fw_ready(scsi_qla_host_t *ha) | |||
1277 | wtime = jiffies + (wait_time * HZ); | 1303 | wtime = jiffies + (wait_time * HZ); |
1278 | 1304 | ||
1279 | /* Wait for ISP to finish LIP */ | 1305 | /* Wait for ISP to finish LIP */ |
1280 | if (!ha->flags.init_done) | 1306 | if (!vha->flags.init_done) |
1281 | qla_printk(KERN_INFO, ha, "Waiting for LIP to complete...\n"); | 1307 | qla_printk(KERN_INFO, ha, "Waiting for LIP to complete...\n"); |
1282 | 1308 | ||
1283 | DEBUG3(printk("scsi(%ld): Waiting for LIP to complete...\n", | 1309 | DEBUG3(printk("scsi(%ld): Waiting for LIP to complete...\n", |
1284 | ha->host_no)); | 1310 | vha->host_no)); |
1285 | 1311 | ||
1286 | do { | 1312 | do { |
1287 | rval = qla2x00_get_firmware_state(ha, state); | 1313 | rval = qla2x00_get_firmware_state(vha, state); |
1288 | if (rval == QLA_SUCCESS) { | 1314 | if (rval == QLA_SUCCESS) { |
1289 | if (state[0] < FSTATE_LOSS_OF_SYNC) { | 1315 | if (state[0] < FSTATE_LOSS_OF_SYNC) { |
1290 | ha->device_flags &= ~DFLG_NO_CABLE; | 1316 | vha->device_flags &= ~DFLG_NO_CABLE; |
1291 | } | 1317 | } |
1292 | if (IS_QLA84XX(ha) && state[0] != FSTATE_READY) { | 1318 | if (IS_QLA84XX(ha) && state[0] != FSTATE_READY) { |
1293 | DEBUG16(printk("scsi(%ld): fw_state=%x " | 1319 | DEBUG16(printk("scsi(%ld): fw_state=%x " |
1294 | "84xx=%x.\n", ha->host_no, state[0], | 1320 | "84xx=%x.\n", vha->host_no, state[0], |
1295 | state[2])); | 1321 | state[2])); |
1296 | if ((state[2] & FSTATE_LOGGED_IN) && | 1322 | if ((state[2] & FSTATE_LOGGED_IN) && |
1297 | (state[2] & FSTATE_WAITING_FOR_VERIFY)) { | 1323 | (state[2] & FSTATE_WAITING_FOR_VERIFY)) { |
1298 | DEBUG16(printk("scsi(%ld): Sending " | 1324 | DEBUG16(printk("scsi(%ld): Sending " |
1299 | "verify iocb.\n", ha->host_no)); | 1325 | "verify iocb.\n", vha->host_no)); |
1300 | 1326 | ||
1301 | cs84xx_time = jiffies; | 1327 | cs84xx_time = jiffies; |
1302 | rval = qla84xx_init_chip(ha); | 1328 | rval = qla84xx_init_chip(vha); |
1303 | if (rval != QLA_SUCCESS) | 1329 | if (rval != QLA_SUCCESS) |
1304 | break; | 1330 | break; |
1305 | 1331 | ||
@@ -1309,13 +1335,13 @@ qla2x00_fw_ready(scsi_qla_host_t *ha) | |||
1309 | mtime += cs84xx_time; | 1335 | mtime += cs84xx_time; |
1310 | DEBUG16(printk("scsi(%ld): Increasing " | 1336 | DEBUG16(printk("scsi(%ld): Increasing " |
1311 | "wait time by %ld. New time %ld\n", | 1337 | "wait time by %ld. New time %ld\n", |
1312 | ha->host_no, cs84xx_time, wtime)); | 1338 | vha->host_no, cs84xx_time, wtime)); |
1313 | } | 1339 | } |
1314 | } else if (state[0] == FSTATE_READY) { | 1340 | } else if (state[0] == FSTATE_READY) { |
1315 | DEBUG(printk("scsi(%ld): F/W Ready - OK \n", | 1341 | DEBUG(printk("scsi(%ld): F/W Ready - OK \n", |
1316 | ha->host_no)); | 1342 | vha->host_no)); |
1317 | 1343 | ||
1318 | qla2x00_get_retry_cnt(ha, &ha->retry_count, | 1344 | qla2x00_get_retry_cnt(vha, &ha->retry_count, |
1319 | &ha->login_timeout, &ha->r_a_tov); | 1345 | &ha->login_timeout, &ha->r_a_tov); |
1320 | 1346 | ||
1321 | rval = QLA_SUCCESS; | 1347 | rval = QLA_SUCCESS; |
@@ -1324,7 +1350,7 @@ qla2x00_fw_ready(scsi_qla_host_t *ha) | |||
1324 | 1350 | ||
1325 | rval = QLA_FUNCTION_FAILED; | 1351 | rval = QLA_FUNCTION_FAILED; |
1326 | 1352 | ||
1327 | if (atomic_read(&ha->loop_down_timer) && | 1353 | if (atomic_read(&vha->loop_down_timer) && |
1328 | state[0] != FSTATE_READY) { | 1354 | state[0] != FSTATE_READY) { |
1329 | /* Loop down. Timeout on min_wait for states | 1355 | /* Loop down. Timeout on min_wait for states |
1330 | * other than Wait for Login. | 1356 | * other than Wait for Login. |
@@ -1333,7 +1359,7 @@ qla2x00_fw_ready(scsi_qla_host_t *ha) | |||
1333 | qla_printk(KERN_INFO, ha, | 1359 | qla_printk(KERN_INFO, ha, |
1334 | "Cable is unplugged...\n"); | 1360 | "Cable is unplugged...\n"); |
1335 | 1361 | ||
1336 | ha->device_flags |= DFLG_NO_CABLE; | 1362 | vha->device_flags |= DFLG_NO_CABLE; |
1337 | break; | 1363 | break; |
1338 | } | 1364 | } |
1339 | } | 1365 | } |
@@ -1350,15 +1376,15 @@ qla2x00_fw_ready(scsi_qla_host_t *ha) | |||
1350 | msleep(500); | 1376 | msleep(500); |
1351 | 1377 | ||
1352 | DEBUG3(printk("scsi(%ld): fw_state=%x curr time=%lx.\n", | 1378 | DEBUG3(printk("scsi(%ld): fw_state=%x curr time=%lx.\n", |
1353 | ha->host_no, state[0], jiffies)); | 1379 | vha->host_no, state[0], jiffies)); |
1354 | } while (1); | 1380 | } while (1); |
1355 | 1381 | ||
1356 | DEBUG(printk("scsi(%ld): fw_state=%x curr time=%lx.\n", | 1382 | DEBUG(printk("scsi(%ld): fw_state=%x curr time=%lx.\n", |
1357 | ha->host_no, state[0], jiffies)); | 1383 | vha->host_no, state[0], jiffies)); |
1358 | 1384 | ||
1359 | if (rval) { | 1385 | if (rval) { |
1360 | DEBUG2_3(printk("scsi(%ld): Firmware ready **** FAILED ****.\n", | 1386 | DEBUG2_3(printk("scsi(%ld): Firmware ready **** FAILED ****.\n", |
1361 | ha->host_no)); | 1387 | vha->host_no)); |
1362 | } | 1388 | } |
1363 | 1389 | ||
1364 | return (rval); | 1390 | return (rval); |
@@ -1378,7 +1404,7 @@ qla2x00_fw_ready(scsi_qla_host_t *ha) | |||
1378 | * Kernel context. | 1404 | * Kernel context. |
1379 | */ | 1405 | */ |
1380 | static int | 1406 | static int |
1381 | qla2x00_configure_hba(scsi_qla_host_t *ha) | 1407 | qla2x00_configure_hba(scsi_qla_host_t *vha) |
1382 | { | 1408 | { |
1383 | int rval; | 1409 | int rval; |
1384 | uint16_t loop_id; | 1410 | uint16_t loop_id; |
@@ -1388,19 +1414,20 @@ qla2x00_configure_hba(scsi_qla_host_t *ha) | |||
1388 | uint8_t area; | 1414 | uint8_t area; |
1389 | uint8_t domain; | 1415 | uint8_t domain; |
1390 | char connect_type[22]; | 1416 | char connect_type[22]; |
1417 | struct qla_hw_data *ha = vha->hw; | ||
1391 | 1418 | ||
1392 | /* Get host addresses. */ | 1419 | /* Get host addresses. */ |
1393 | rval = qla2x00_get_adapter_id(ha, | 1420 | rval = qla2x00_get_adapter_id(vha, |
1394 | &loop_id, &al_pa, &area, &domain, &topo, &sw_cap); | 1421 | &loop_id, &al_pa, &area, &domain, &topo, &sw_cap); |
1395 | if (rval != QLA_SUCCESS) { | 1422 | if (rval != QLA_SUCCESS) { |
1396 | if (LOOP_TRANSITION(ha) || atomic_read(&ha->loop_down_timer) || | 1423 | if (LOOP_TRANSITION(vha) || atomic_read(&ha->loop_down_timer) || |
1397 | (rval == QLA_COMMAND_ERROR && loop_id == 0x7)) { | 1424 | (rval == QLA_COMMAND_ERROR && loop_id == 0x7)) { |
1398 | DEBUG2(printk("%s(%ld) Loop is in a transition state\n", | 1425 | DEBUG2(printk("%s(%ld) Loop is in a transition state\n", |
1399 | __func__, ha->host_no)); | 1426 | __func__, vha->host_no)); |
1400 | } else { | 1427 | } else { |
1401 | qla_printk(KERN_WARNING, ha, | 1428 | qla_printk(KERN_WARNING, ha, |
1402 | "ERROR -- Unable to get host loop ID.\n"); | 1429 | "ERROR -- Unable to get host loop ID.\n"); |
1403 | set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags); | 1430 | set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
1404 | } | 1431 | } |
1405 | return (rval); | 1432 | return (rval); |
1406 | } | 1433 | } |
@@ -1411,7 +1438,7 @@ qla2x00_configure_hba(scsi_qla_host_t *ha) | |||
1411 | return (QLA_FUNCTION_FAILED); | 1438 | return (QLA_FUNCTION_FAILED); |
1412 | } | 1439 | } |
1413 | 1440 | ||
1414 | ha->loop_id = loop_id; | 1441 | vha->loop_id = loop_id; |
1415 | 1442 | ||
1416 | /* initialize */ | 1443 | /* initialize */ |
1417 | ha->min_external_loopid = SNS_FIRST_LOOP_ID; | 1444 | ha->min_external_loopid = SNS_FIRST_LOOP_ID; |
@@ -1421,14 +1448,14 @@ qla2x00_configure_hba(scsi_qla_host_t *ha) | |||
1421 | switch (topo) { | 1448 | switch (topo) { |
1422 | case 0: | 1449 | case 0: |
1423 | DEBUG3(printk("scsi(%ld): HBA in NL topology.\n", | 1450 | DEBUG3(printk("scsi(%ld): HBA in NL topology.\n", |
1424 | ha->host_no)); | 1451 | vha->host_no)); |
1425 | ha->current_topology = ISP_CFG_NL; | 1452 | ha->current_topology = ISP_CFG_NL; |
1426 | strcpy(connect_type, "(Loop)"); | 1453 | strcpy(connect_type, "(Loop)"); |
1427 | break; | 1454 | break; |
1428 | 1455 | ||
1429 | case 1: | 1456 | case 1: |
1430 | DEBUG3(printk("scsi(%ld): HBA in FL topology.\n", | 1457 | DEBUG3(printk("scsi(%ld): HBA in FL topology.\n", |
1431 | ha->host_no)); | 1458 | vha->host_no)); |
1432 | ha->switch_cap = sw_cap; | 1459 | ha->switch_cap = sw_cap; |
1433 | ha->current_topology = ISP_CFG_FL; | 1460 | ha->current_topology = ISP_CFG_FL; |
1434 | strcpy(connect_type, "(FL_Port)"); | 1461 | strcpy(connect_type, "(FL_Port)"); |
@@ -1436,7 +1463,7 @@ qla2x00_configure_hba(scsi_qla_host_t *ha) | |||
1436 | 1463 | ||
1437 | case 2: | 1464 | case 2: |
1438 | DEBUG3(printk("scsi(%ld): HBA in N P2P topology.\n", | 1465 | DEBUG3(printk("scsi(%ld): HBA in N P2P topology.\n", |
1439 | ha->host_no)); | 1466 | vha->host_no)); |
1440 | ha->operating_mode = P2P; | 1467 | ha->operating_mode = P2P; |
1441 | ha->current_topology = ISP_CFG_N; | 1468 | ha->current_topology = ISP_CFG_N; |
1442 | strcpy(connect_type, "(N_Port-to-N_Port)"); | 1469 | strcpy(connect_type, "(N_Port-to-N_Port)"); |
@@ -1444,7 +1471,7 @@ qla2x00_configure_hba(scsi_qla_host_t *ha) | |||
1444 | 1471 | ||
1445 | case 3: | 1472 | case 3: |
1446 | DEBUG3(printk("scsi(%ld): HBA in F P2P topology.\n", | 1473 | DEBUG3(printk("scsi(%ld): HBA in F P2P topology.\n", |
1447 | ha->host_no)); | 1474 | vha->host_no)); |
1448 | ha->switch_cap = sw_cap; | 1475 | ha->switch_cap = sw_cap; |
1449 | ha->operating_mode = P2P; | 1476 | ha->operating_mode = P2P; |
1450 | ha->current_topology = ISP_CFG_F; | 1477 | ha->current_topology = ISP_CFG_F; |
@@ -1454,7 +1481,7 @@ qla2x00_configure_hba(scsi_qla_host_t *ha) | |||
1454 | default: | 1481 | default: |
1455 | DEBUG3(printk("scsi(%ld): HBA in unknown topology %x. " | 1482 | DEBUG3(printk("scsi(%ld): HBA in unknown topology %x. " |
1456 | "Using NL.\n", | 1483 | "Using NL.\n", |
1457 | ha->host_no, topo)); | 1484 | vha->host_no, topo)); |
1458 | ha->current_topology = ISP_CFG_NL; | 1485 | ha->current_topology = ISP_CFG_NL; |
1459 | strcpy(connect_type, "(Loop)"); | 1486 | strcpy(connect_type, "(Loop)"); |
1460 | break; | 1487 | break; |
@@ -1462,29 +1489,31 @@ qla2x00_configure_hba(scsi_qla_host_t *ha) | |||
1462 | 1489 | ||
1463 | /* Save Host port and loop ID. */ | 1490 | /* Save Host port and loop ID. */ |
1464 | /* byte order - Big Endian */ | 1491 | /* byte order - Big Endian */ |
1465 | ha->d_id.b.domain = domain; | 1492 | vha->d_id.b.domain = domain; |
1466 | ha->d_id.b.area = area; | 1493 | vha->d_id.b.area = area; |
1467 | ha->d_id.b.al_pa = al_pa; | 1494 | vha->d_id.b.al_pa = al_pa; |
1468 | 1495 | ||
1469 | if (!ha->flags.init_done) | 1496 | if (!vha->flags.init_done) |
1470 | qla_printk(KERN_INFO, ha, | 1497 | qla_printk(KERN_INFO, ha, |
1471 | "Topology - %s, Host Loop address 0x%x\n", | 1498 | "Topology - %s, Host Loop address 0x%x\n", |
1472 | connect_type, ha->loop_id); | 1499 | connect_type, vha->loop_id); |
1473 | 1500 | ||
1474 | if (rval) { | 1501 | if (rval) { |
1475 | DEBUG2_3(printk("scsi(%ld): FAILED.\n", ha->host_no)); | 1502 | DEBUG2_3(printk("scsi(%ld): FAILED.\n", vha->host_no)); |
1476 | } else { | 1503 | } else { |
1477 | DEBUG3(printk("scsi(%ld): exiting normally.\n", ha->host_no)); | 1504 | DEBUG3(printk("scsi(%ld): exiting normally.\n", vha->host_no)); |
1478 | } | 1505 | } |
1479 | 1506 | ||
1480 | return(rval); | 1507 | return(rval); |
1481 | } | 1508 | } |
1482 | 1509 | ||
1483 | static inline void | 1510 | static inline void |
1484 | qla2x00_set_model_info(scsi_qla_host_t *ha, uint8_t *model, size_t len, char *def) | 1511 | qla2x00_set_model_info(scsi_qla_host_t *vha, uint8_t *model, size_t len, |
1512 | char *def) | ||
1485 | { | 1513 | { |
1486 | char *st, *en; | 1514 | char *st, *en; |
1487 | uint16_t index; | 1515 | uint16_t index; |
1516 | struct qla_hw_data *ha = vha->hw; | ||
1488 | 1517 | ||
1489 | if (memcmp(model, BINZERO, len) != 0) { | 1518 | if (memcmp(model, BINZERO, len) != 0) { |
1490 | strncpy(ha->model_number, model, len); | 1519 | strncpy(ha->model_number, model, len); |
@@ -1516,16 +1545,17 @@ qla2x00_set_model_info(scsi_qla_host_t *ha, uint8_t *model, size_t len, char *de | |||
1516 | } | 1545 | } |
1517 | } | 1546 | } |
1518 | if (IS_FWI2_CAPABLE(ha)) | 1547 | if (IS_FWI2_CAPABLE(ha)) |
1519 | qla2xxx_get_vpd_field(ha, "\x82", ha->model_desc, | 1548 | qla2xxx_get_vpd_field(vha, "\x82", ha->model_desc, |
1520 | sizeof(ha->model_desc)); | 1549 | sizeof(ha->model_desc)); |
1521 | } | 1550 | } |
1522 | 1551 | ||
1523 | /* On sparc systems, obtain port and node WWN from firmware | 1552 | /* On sparc systems, obtain port and node WWN from firmware |
1524 | * properties. | 1553 | * properties. |
1525 | */ | 1554 | */ |
1526 | static void qla2xxx_nvram_wwn_from_ofw(scsi_qla_host_t *ha, nvram_t *nv) | 1555 | static void qla2xxx_nvram_wwn_from_ofw(scsi_qla_host_t *vha, nvram_t *nv) |
1527 | { | 1556 | { |
1528 | #ifdef CONFIG_SPARC | 1557 | #ifdef CONFIG_SPARC |
1558 | struct qla_hw_data *ha = vha->hw; | ||
1529 | struct pci_dev *pdev = ha->pdev; | 1559 | struct pci_dev *pdev = ha->pdev; |
1530 | struct device_node *dp = pci_device_to_OF_node(pdev); | 1560 | struct device_node *dp = pci_device_to_OF_node(pdev); |
1531 | const u8 *val; | 1561 | const u8 *val; |
@@ -1555,12 +1585,13 @@ static void qla2xxx_nvram_wwn_from_ofw(scsi_qla_host_t *ha, nvram_t *nv) | |||
1555 | * 0 = success. | 1585 | * 0 = success. |
1556 | */ | 1586 | */ |
1557 | int | 1587 | int |
1558 | qla2x00_nvram_config(scsi_qla_host_t *ha) | 1588 | qla2x00_nvram_config(scsi_qla_host_t *vha) |
1559 | { | 1589 | { |
1560 | int rval; | 1590 | int rval; |
1561 | uint8_t chksum = 0; | 1591 | uint8_t chksum = 0; |
1562 | uint16_t cnt; | 1592 | uint16_t cnt; |
1563 | uint8_t *dptr1, *dptr2; | 1593 | uint8_t *dptr1, *dptr2; |
1594 | struct qla_hw_data *ha = vha->hw; | ||
1564 | init_cb_t *icb = ha->init_cb; | 1595 | init_cb_t *icb = ha->init_cb; |
1565 | nvram_t *nv = ha->nvram; | 1596 | nvram_t *nv = ha->nvram; |
1566 | uint8_t *ptr = ha->nvram; | 1597 | uint8_t *ptr = ha->nvram; |
@@ -1576,11 +1607,11 @@ qla2x00_nvram_config(scsi_qla_host_t *ha) | |||
1576 | ha->nvram_base = 0x80; | 1607 | ha->nvram_base = 0x80; |
1577 | 1608 | ||
1578 | /* Get NVRAM data and calculate checksum. */ | 1609 | /* Get NVRAM data and calculate checksum. */ |
1579 | ha->isp_ops->read_nvram(ha, ptr, ha->nvram_base, ha->nvram_size); | 1610 | ha->isp_ops->read_nvram(vha, ptr, ha->nvram_base, ha->nvram_size); |
1580 | for (cnt = 0, chksum = 0; cnt < ha->nvram_size; cnt++) | 1611 | for (cnt = 0, chksum = 0; cnt < ha->nvram_size; cnt++) |
1581 | chksum += *ptr++; | 1612 | chksum += *ptr++; |
1582 | 1613 | ||
1583 | DEBUG5(printk("scsi(%ld): Contents of NVRAM\n", ha->host_no)); | 1614 | DEBUG5(printk("scsi(%ld): Contents of NVRAM\n", vha->host_no)); |
1584 | DEBUG5(qla2x00_dump_buffer((uint8_t *)nv, ha->nvram_size)); | 1615 | DEBUG5(qla2x00_dump_buffer((uint8_t *)nv, ha->nvram_size)); |
1585 | 1616 | ||
1586 | /* Bad NVRAM data, set defaults parameters. */ | 1617 | /* Bad NVRAM data, set defaults parameters. */ |
@@ -1594,7 +1625,7 @@ qla2x00_nvram_config(scsi_qla_host_t *ha) | |||
1594 | "invalid -- WWPN) defaults.\n"); | 1625 | "invalid -- WWPN) defaults.\n"); |
1595 | 1626 | ||
1596 | if (chksum) | 1627 | if (chksum) |
1597 | qla2xxx_hw_event_log(ha, HW_EVENT_NVRAM_CHKSUM_ERR, 0, | 1628 | qla2xxx_hw_event_log(vha, HW_EVENT_NVRAM_CHKSUM_ERR, 0, |
1598 | MSW(chksum), LSW(chksum)); | 1629 | MSW(chksum), LSW(chksum)); |
1599 | 1630 | ||
1600 | /* | 1631 | /* |
@@ -1631,7 +1662,7 @@ qla2x00_nvram_config(scsi_qla_host_t *ha) | |||
1631 | nv->port_name[3] = 224; | 1662 | nv->port_name[3] = 224; |
1632 | nv->port_name[4] = 139; | 1663 | nv->port_name[4] = 139; |
1633 | 1664 | ||
1634 | qla2xxx_nvram_wwn_from_ofw(ha, nv); | 1665 | qla2xxx_nvram_wwn_from_ofw(vha, nv); |
1635 | 1666 | ||
1636 | nv->login_timeout = 4; | 1667 | nv->login_timeout = 4; |
1637 | 1668 | ||
@@ -1684,7 +1715,7 @@ qla2x00_nvram_config(scsi_qla_host_t *ha) | |||
1684 | strcpy(ha->model_number, "QLA2300"); | 1715 | strcpy(ha->model_number, "QLA2300"); |
1685 | } | 1716 | } |
1686 | } else { | 1717 | } else { |
1687 | qla2x00_set_model_info(ha, nv->model_number, | 1718 | qla2x00_set_model_info(vha, nv->model_number, |
1688 | sizeof(nv->model_number), "QLA23xx"); | 1719 | sizeof(nv->model_number), "QLA23xx"); |
1689 | } | 1720 | } |
1690 | } else if (IS_QLA2200(ha)) { | 1721 | } else if (IS_QLA2200(ha)) { |
@@ -1760,8 +1791,8 @@ qla2x00_nvram_config(scsi_qla_host_t *ha) | |||
1760 | ha->serial0 = icb->port_name[5]; | 1791 | ha->serial0 = icb->port_name[5]; |
1761 | ha->serial1 = icb->port_name[6]; | 1792 | ha->serial1 = icb->port_name[6]; |
1762 | ha->serial2 = icb->port_name[7]; | 1793 | ha->serial2 = icb->port_name[7]; |
1763 | ha->node_name = icb->node_name; | 1794 | memcpy(vha->node_name, icb->node_name, WWN_SIZE); |
1764 | ha->port_name = icb->port_name; | 1795 | memcpy(vha->port_name, icb->port_name, WWN_SIZE); |
1765 | 1796 | ||
1766 | icb->execution_throttle = __constant_cpu_to_le16(0xFFFF); | 1797 | icb->execution_throttle = __constant_cpu_to_le16(0xFFFF); |
1767 | 1798 | ||
@@ -1829,10 +1860,10 @@ qla2x00_nvram_config(scsi_qla_host_t *ha) | |||
1829 | icb->response_accumulation_timer = 3; | 1860 | icb->response_accumulation_timer = 3; |
1830 | icb->interrupt_delay_timer = 5; | 1861 | icb->interrupt_delay_timer = 5; |
1831 | 1862 | ||
1832 | ha->flags.process_response_queue = 1; | 1863 | vha->flags.process_response_queue = 1; |
1833 | } else { | 1864 | } else { |
1834 | /* Enable ZIO. */ | 1865 | /* Enable ZIO. */ |
1835 | if (!ha->flags.init_done) { | 1866 | if (!vha->flags.init_done) { |
1836 | ha->zio_mode = icb->add_firmware_options[0] & | 1867 | ha->zio_mode = icb->add_firmware_options[0] & |
1837 | (BIT_3 | BIT_2 | BIT_1 | BIT_0); | 1868 | (BIT_3 | BIT_2 | BIT_1 | BIT_0); |
1838 | ha->zio_timer = icb->interrupt_delay_timer ? | 1869 | ha->zio_timer = icb->interrupt_delay_timer ? |
@@ -1840,12 +1871,12 @@ qla2x00_nvram_config(scsi_qla_host_t *ha) | |||
1840 | } | 1871 | } |
1841 | icb->add_firmware_options[0] &= | 1872 | icb->add_firmware_options[0] &= |
1842 | ~(BIT_3 | BIT_2 | BIT_1 | BIT_0); | 1873 | ~(BIT_3 | BIT_2 | BIT_1 | BIT_0); |
1843 | ha->flags.process_response_queue = 0; | 1874 | vha->flags.process_response_queue = 0; |
1844 | if (ha->zio_mode != QLA_ZIO_DISABLED) { | 1875 | if (ha->zio_mode != QLA_ZIO_DISABLED) { |
1845 | ha->zio_mode = QLA_ZIO_MODE_6; | 1876 | ha->zio_mode = QLA_ZIO_MODE_6; |
1846 | 1877 | ||
1847 | DEBUG2(printk("scsi(%ld): ZIO mode %d enabled; timer " | 1878 | DEBUG2(printk("scsi(%ld): ZIO mode %d enabled; timer " |
1848 | "delay (%d us).\n", ha->host_no, ha->zio_mode, | 1879 | "delay (%d us).\n", vha->host_no, ha->zio_mode, |
1849 | ha->zio_timer * 100)); | 1880 | ha->zio_timer * 100)); |
1850 | qla_printk(KERN_INFO, ha, | 1881 | qla_printk(KERN_INFO, ha, |
1851 | "ZIO mode %d enabled; timer delay (%d us).\n", | 1882 | "ZIO mode %d enabled; timer delay (%d us).\n", |
@@ -1853,13 +1884,13 @@ qla2x00_nvram_config(scsi_qla_host_t *ha) | |||
1853 | 1884 | ||
1854 | icb->add_firmware_options[0] |= (uint8_t)ha->zio_mode; | 1885 | icb->add_firmware_options[0] |= (uint8_t)ha->zio_mode; |
1855 | icb->interrupt_delay_timer = (uint8_t)ha->zio_timer; | 1886 | icb->interrupt_delay_timer = (uint8_t)ha->zio_timer; |
1856 | ha->flags.process_response_queue = 1; | 1887 | vha->flags.process_response_queue = 1; |
1857 | } | 1888 | } |
1858 | } | 1889 | } |
1859 | 1890 | ||
1860 | if (rval) { | 1891 | if (rval) { |
1861 | DEBUG2_3(printk(KERN_WARNING | 1892 | DEBUG2_3(printk(KERN_WARNING |
1862 | "scsi(%ld): NVRAM configuration failed!\n", ha->host_no)); | 1893 | "scsi(%ld): NVRAM configuration failed!\n", vha->host_no)); |
1863 | } | 1894 | } |
1864 | return (rval); | 1895 | return (rval); |
1865 | } | 1896 | } |
@@ -1870,10 +1901,10 @@ qla2x00_rport_del(void *data) | |||
1870 | fc_port_t *fcport = data; | 1901 | fc_port_t *fcport = data; |
1871 | struct fc_rport *rport; | 1902 | struct fc_rport *rport; |
1872 | 1903 | ||
1873 | spin_lock_irq(fcport->ha->host->host_lock); | 1904 | spin_lock_irq(fcport->vha->host->host_lock); |
1874 | rport = fcport->drport; | 1905 | rport = fcport->drport; |
1875 | fcport->drport = NULL; | 1906 | fcport->drport = NULL; |
1876 | spin_unlock_irq(fcport->ha->host->host_lock); | 1907 | spin_unlock_irq(fcport->vha->host->host_lock); |
1877 | if (rport) | 1908 | if (rport) |
1878 | fc_remote_port_delete(rport); | 1909 | fc_remote_port_delete(rport); |
1879 | } | 1910 | } |
@@ -1886,7 +1917,7 @@ qla2x00_rport_del(void *data) | |||
1886 | * Returns a pointer to the allocated fcport, or NULL, if none available. | 1917 | * Returns a pointer to the allocated fcport, or NULL, if none available. |
1887 | */ | 1918 | */ |
1888 | static fc_port_t * | 1919 | static fc_port_t * |
1889 | qla2x00_alloc_fcport(scsi_qla_host_t *ha, gfp_t flags) | 1920 | qla2x00_alloc_fcport(scsi_qla_host_t *vha, gfp_t flags) |
1890 | { | 1921 | { |
1891 | fc_port_t *fcport; | 1922 | fc_port_t *fcport; |
1892 | 1923 | ||
@@ -1895,8 +1926,8 @@ qla2x00_alloc_fcport(scsi_qla_host_t *ha, gfp_t flags) | |||
1895 | return NULL; | 1926 | return NULL; |
1896 | 1927 | ||
1897 | /* Setup fcport template structure. */ | 1928 | /* Setup fcport template structure. */ |
1898 | fcport->ha = ha; | 1929 | fcport->vha = vha; |
1899 | fcport->vp_idx = ha->vp_idx; | 1930 | fcport->vp_idx = vha->vp_idx; |
1900 | fcport->port_type = FCT_UNKNOWN; | 1931 | fcport->port_type = FCT_UNKNOWN; |
1901 | fcport->loop_id = FC_NO_LOOP_ID; | 1932 | fcport->loop_id = FC_NO_LOOP_ID; |
1902 | atomic_set(&fcport->state, FCS_UNCONFIGURED); | 1933 | atomic_set(&fcport->state, FCS_UNCONFIGURED); |
@@ -1919,100 +1950,98 @@ qla2x00_alloc_fcport(scsi_qla_host_t *ha, gfp_t flags) | |||
1919 | * 2 = database was full and device was not configured. | 1950 | * 2 = database was full and device was not configured. |
1920 | */ | 1951 | */ |
1921 | static int | 1952 | static int |
1922 | qla2x00_configure_loop(scsi_qla_host_t *ha) | 1953 | qla2x00_configure_loop(scsi_qla_host_t *vha) |
1923 | { | 1954 | { |
1924 | int rval; | 1955 | int rval; |
1925 | unsigned long flags, save_flags; | 1956 | unsigned long flags, save_flags; |
1926 | 1957 | struct qla_hw_data *ha = vha->hw; | |
1927 | rval = QLA_SUCCESS; | 1958 | rval = QLA_SUCCESS; |
1928 | 1959 | ||
1929 | /* Get Initiator ID */ | 1960 | /* Get Initiator ID */ |
1930 | if (test_bit(LOCAL_LOOP_UPDATE, &ha->dpc_flags)) { | 1961 | if (test_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags)) { |
1931 | rval = qla2x00_configure_hba(ha); | 1962 | rval = qla2x00_configure_hba(vha); |
1932 | if (rval != QLA_SUCCESS) { | 1963 | if (rval != QLA_SUCCESS) { |
1933 | DEBUG(printk("scsi(%ld): Unable to configure HBA.\n", | 1964 | DEBUG(printk("scsi(%ld): Unable to configure HBA.\n", |
1934 | ha->host_no)); | 1965 | vha->host_no)); |
1935 | return (rval); | 1966 | return (rval); |
1936 | } | 1967 | } |
1937 | } | 1968 | } |
1938 | 1969 | ||
1939 | save_flags = flags = ha->dpc_flags; | 1970 | save_flags = flags = vha->dpc_flags; |
1940 | DEBUG(printk("scsi(%ld): Configure loop -- dpc flags =0x%lx\n", | 1971 | DEBUG(printk("scsi(%ld): Configure loop -- dpc flags =0x%lx\n", |
1941 | ha->host_no, flags)); | 1972 | vha->host_no, flags)); |
1942 | 1973 | ||
1943 | /* | 1974 | /* |
1944 | * If we have both an RSCN and PORT UPDATE pending then handle them | 1975 | * If we have both an RSCN and PORT UPDATE pending then handle them |
1945 | * both at the same time. | 1976 | * both at the same time. |
1946 | */ | 1977 | */ |
1947 | clear_bit(LOCAL_LOOP_UPDATE, &ha->dpc_flags); | 1978 | clear_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); |
1948 | clear_bit(RSCN_UPDATE, &ha->dpc_flags); | 1979 | clear_bit(RSCN_UPDATE, &vha->dpc_flags); |
1949 | 1980 | ||
1950 | /* Determine what we need to do */ | 1981 | /* Determine what we need to do */ |
1951 | if (ha->current_topology == ISP_CFG_FL && | 1982 | if (ha->current_topology == ISP_CFG_FL && |
1952 | (test_bit(LOCAL_LOOP_UPDATE, &flags))) { | 1983 | (test_bit(LOCAL_LOOP_UPDATE, &flags))) { |
1953 | 1984 | ||
1954 | ha->flags.rscn_queue_overflow = 1; | 1985 | vha->flags.rscn_queue_overflow = 1; |
1955 | set_bit(RSCN_UPDATE, &flags); | 1986 | set_bit(RSCN_UPDATE, &flags); |
1956 | 1987 | ||
1957 | } else if (ha->current_topology == ISP_CFG_F && | 1988 | } else if (ha->current_topology == ISP_CFG_F && |
1958 | (test_bit(LOCAL_LOOP_UPDATE, &flags))) { | 1989 | (test_bit(LOCAL_LOOP_UPDATE, &flags))) { |
1959 | 1990 | ||
1960 | ha->flags.rscn_queue_overflow = 1; | 1991 | vha->flags.rscn_queue_overflow = 1; |
1961 | set_bit(RSCN_UPDATE, &flags); | 1992 | set_bit(RSCN_UPDATE, &flags); |
1962 | clear_bit(LOCAL_LOOP_UPDATE, &flags); | 1993 | clear_bit(LOCAL_LOOP_UPDATE, &flags); |
1963 | 1994 | ||
1964 | } else if (ha->current_topology == ISP_CFG_N) { | 1995 | } else if (ha->current_topology == ISP_CFG_N) { |
1965 | clear_bit(RSCN_UPDATE, &flags); | 1996 | clear_bit(RSCN_UPDATE, &flags); |
1966 | 1997 | ||
1967 | } else if (!ha->flags.online || | 1998 | } else if (!vha->flags.online || |
1968 | (test_bit(ABORT_ISP_ACTIVE, &flags))) { | 1999 | (test_bit(ABORT_ISP_ACTIVE, &flags))) { |
1969 | 2000 | ||
1970 | ha->flags.rscn_queue_overflow = 1; | 2001 | vha->flags.rscn_queue_overflow = 1; |
1971 | set_bit(RSCN_UPDATE, &flags); | 2002 | set_bit(RSCN_UPDATE, &flags); |
1972 | set_bit(LOCAL_LOOP_UPDATE, &flags); | 2003 | set_bit(LOCAL_LOOP_UPDATE, &flags); |
1973 | } | 2004 | } |
1974 | 2005 | ||
1975 | if (test_bit(LOCAL_LOOP_UPDATE, &flags)) { | 2006 | if (test_bit(LOCAL_LOOP_UPDATE, &flags)) { |
1976 | if (test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags)) { | 2007 | if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) |
1977 | rval = QLA_FUNCTION_FAILED; | 2008 | rval = QLA_FUNCTION_FAILED; |
1978 | } else { | 2009 | else |
1979 | rval = qla2x00_configure_local_loop(ha); | 2010 | rval = qla2x00_configure_local_loop(vha); |
1980 | } | ||
1981 | } | 2011 | } |
1982 | 2012 | ||
1983 | if (rval == QLA_SUCCESS && test_bit(RSCN_UPDATE, &flags)) { | 2013 | if (rval == QLA_SUCCESS && test_bit(RSCN_UPDATE, &flags)) { |
1984 | if (LOOP_TRANSITION(ha)) { | 2014 | if (LOOP_TRANSITION(vha)) |
1985 | rval = QLA_FUNCTION_FAILED; | 2015 | rval = QLA_FUNCTION_FAILED; |
1986 | } else { | 2016 | else |
1987 | rval = qla2x00_configure_fabric(ha); | 2017 | rval = qla2x00_configure_fabric(vha); |
1988 | } | ||
1989 | } | 2018 | } |
1990 | 2019 | ||
1991 | if (rval == QLA_SUCCESS) { | 2020 | if (rval == QLA_SUCCESS) { |
1992 | if (atomic_read(&ha->loop_down_timer) || | 2021 | if (atomic_read(&vha->loop_down_timer) || |
1993 | test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags)) { | 2022 | test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) { |
1994 | rval = QLA_FUNCTION_FAILED; | 2023 | rval = QLA_FUNCTION_FAILED; |
1995 | } else { | 2024 | } else { |
1996 | atomic_set(&ha->loop_state, LOOP_READY); | 2025 | atomic_set(&vha->loop_state, LOOP_READY); |
1997 | 2026 | ||
1998 | DEBUG(printk("scsi(%ld): LOOP READY\n", ha->host_no)); | 2027 | DEBUG(printk("scsi(%ld): LOOP READY\n", vha->host_no)); |
1999 | } | 2028 | } |
2000 | } | 2029 | } |
2001 | 2030 | ||
2002 | if (rval) { | 2031 | if (rval) { |
2003 | DEBUG2_3(printk("%s(%ld): *** FAILED ***\n", | 2032 | DEBUG2_3(printk("%s(%ld): *** FAILED ***\n", |
2004 | __func__, ha->host_no)); | 2033 | __func__, vha->host_no)); |
2005 | } else { | 2034 | } else { |
2006 | DEBUG3(printk("%s: exiting normally\n", __func__)); | 2035 | DEBUG3(printk("%s: exiting normally\n", __func__)); |
2007 | } | 2036 | } |
2008 | 2037 | ||
2009 | /* Restore state if a resync event occurred during processing */ | 2038 | /* Restore state if a resync event occurred during processing */ |
2010 | if (test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags)) { | 2039 | if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) { |
2011 | if (test_bit(LOCAL_LOOP_UPDATE, &save_flags)) | 2040 | if (test_bit(LOCAL_LOOP_UPDATE, &save_flags)) |
2012 | set_bit(LOCAL_LOOP_UPDATE, &ha->dpc_flags); | 2041 | set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); |
2013 | if (test_bit(RSCN_UPDATE, &save_flags)) { | 2042 | if (test_bit(RSCN_UPDATE, &save_flags)) { |
2014 | ha->flags.rscn_queue_overflow = 1; | 2043 | set_bit(RSCN_UPDATE, &vha->dpc_flags); |
2015 | set_bit(RSCN_UPDATE, &ha->dpc_flags); | 2044 | vha->flags.rscn_queue_overflow = 1; |
2016 | } | 2045 | } |
2017 | } | 2046 | } |
2018 | 2047 | ||
@@ -2032,7 +2061,7 @@ qla2x00_configure_loop(scsi_qla_host_t *ha) | |||
2032 | * 0 = success. | 2061 | * 0 = success. |
2033 | */ | 2062 | */ |
2034 | static int | 2063 | static int |
2035 | qla2x00_configure_local_loop(scsi_qla_host_t *ha) | 2064 | qla2x00_configure_local_loop(scsi_qla_host_t *vha) |
2036 | { | 2065 | { |
2037 | int rval, rval2; | 2066 | int rval, rval2; |
2038 | int found_devs; | 2067 | int found_devs; |
@@ -2044,18 +2073,18 @@ qla2x00_configure_local_loop(scsi_qla_host_t *ha) | |||
2044 | char *id_iter; | 2073 | char *id_iter; |
2045 | uint16_t loop_id; | 2074 | uint16_t loop_id; |
2046 | uint8_t domain, area, al_pa; | 2075 | uint8_t domain, area, al_pa; |
2047 | scsi_qla_host_t *pha = to_qla_parent(ha); | 2076 | struct qla_hw_data *ha = vha->hw; |
2048 | 2077 | ||
2049 | found_devs = 0; | 2078 | found_devs = 0; |
2050 | new_fcport = NULL; | 2079 | new_fcport = NULL; |
2051 | entries = MAX_FIBRE_DEVICES; | 2080 | entries = MAX_FIBRE_DEVICES; |
2052 | 2081 | ||
2053 | DEBUG3(printk("scsi(%ld): Getting FCAL position map\n", ha->host_no)); | 2082 | DEBUG3(printk("scsi(%ld): Getting FCAL position map\n", vha->host_no)); |
2054 | DEBUG3(qla2x00_get_fcal_position_map(ha, NULL)); | 2083 | DEBUG3(qla2x00_get_fcal_position_map(vha, NULL)); |
2055 | 2084 | ||
2056 | /* Get list of logged in devices. */ | 2085 | /* Get list of logged in devices. */ |
2057 | memset(ha->gid_list, 0, GID_LIST_SIZE); | 2086 | memset(ha->gid_list, 0, GID_LIST_SIZE); |
2058 | rval = qla2x00_get_id_list(ha, ha->gid_list, ha->gid_list_dma, | 2087 | rval = qla2x00_get_id_list(vha, ha->gid_list, ha->gid_list_dma, |
2059 | &entries); | 2088 | &entries); |
2060 | if (rval != QLA_SUCCESS) | 2089 | if (rval != QLA_SUCCESS) |
2061 | goto cleanup_allocation; | 2090 | goto cleanup_allocation; |
@@ -2066,7 +2095,7 @@ qla2x00_configure_local_loop(scsi_qla_host_t *ha) | |||
2066 | entries * sizeof(struct gid_list_info))); | 2095 | entries * sizeof(struct gid_list_info))); |
2067 | 2096 | ||
2068 | /* Allocate temporary fcport for any new fcports discovered. */ | 2097 | /* Allocate temporary fcport for any new fcports discovered. */ |
2069 | new_fcport = qla2x00_alloc_fcport(ha, GFP_KERNEL); | 2098 | new_fcport = qla2x00_alloc_fcport(vha, GFP_KERNEL); |
2070 | if (new_fcport == NULL) { | 2099 | if (new_fcport == NULL) { |
2071 | rval = QLA_MEMORY_ALLOC_FAILED; | 2100 | rval = QLA_MEMORY_ALLOC_FAILED; |
2072 | goto cleanup_allocation; | 2101 | goto cleanup_allocation; |
@@ -2076,17 +2105,14 @@ qla2x00_configure_local_loop(scsi_qla_host_t *ha) | |||
2076 | /* | 2105 | /* |
2077 | * Mark local devices that were present with FCF_DEVICE_LOST for now. | 2106 | * Mark local devices that were present with FCF_DEVICE_LOST for now. |
2078 | */ | 2107 | */ |
2079 | list_for_each_entry(fcport, &pha->fcports, list) { | 2108 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
2080 | if (fcport->vp_idx != ha->vp_idx) | ||
2081 | continue; | ||
2082 | |||
2083 | if (atomic_read(&fcport->state) == FCS_ONLINE && | 2109 | if (atomic_read(&fcport->state) == FCS_ONLINE && |
2084 | fcport->port_type != FCT_BROADCAST && | 2110 | fcport->port_type != FCT_BROADCAST && |
2085 | (fcport->flags & FCF_FABRIC_DEVICE) == 0) { | 2111 | (fcport->flags & FCF_FABRIC_DEVICE) == 0) { |
2086 | 2112 | ||
2087 | DEBUG(printk("scsi(%ld): Marking port lost, " | 2113 | DEBUG(printk("scsi(%ld): Marking port lost, " |
2088 | "loop_id=0x%04x\n", | 2114 | "loop_id=0x%04x\n", |
2089 | ha->host_no, fcport->loop_id)); | 2115 | vha->host_no, fcport->loop_id)); |
2090 | 2116 | ||
2091 | atomic_set(&fcport->state, FCS_DEVICE_LOST); | 2117 | atomic_set(&fcport->state, FCS_DEVICE_LOST); |
2092 | fcport->flags &= ~FCF_FARP_DONE; | 2118 | fcport->flags &= ~FCF_FARP_DONE; |
@@ -2113,7 +2139,7 @@ qla2x00_configure_local_loop(scsi_qla_host_t *ha) | |||
2113 | 2139 | ||
2114 | /* Bypass if not same domain and area of adapter. */ | 2140 | /* Bypass if not same domain and area of adapter. */ |
2115 | if (area && domain && | 2141 | if (area && domain && |
2116 | (area != ha->d_id.b.area || domain != ha->d_id.b.domain)) | 2142 | (area != vha->d_id.b.area || domain != vha->d_id.b.domain)) |
2117 | continue; | 2143 | continue; |
2118 | 2144 | ||
2119 | /* Bypass invalid local loop ID. */ | 2145 | /* Bypass invalid local loop ID. */ |
@@ -2125,26 +2151,23 @@ qla2x00_configure_local_loop(scsi_qla_host_t *ha) | |||
2125 | new_fcport->d_id.b.area = area; | 2151 | new_fcport->d_id.b.area = area; |
2126 | new_fcport->d_id.b.al_pa = al_pa; | 2152 | new_fcport->d_id.b.al_pa = al_pa; |
2127 | new_fcport->loop_id = loop_id; | 2153 | new_fcport->loop_id = loop_id; |
2128 | new_fcport->vp_idx = ha->vp_idx; | 2154 | new_fcport->vp_idx = vha->vp_idx; |
2129 | rval2 = qla2x00_get_port_database(ha, new_fcport, 0); | 2155 | rval2 = qla2x00_get_port_database(vha, new_fcport, 0); |
2130 | if (rval2 != QLA_SUCCESS) { | 2156 | if (rval2 != QLA_SUCCESS) { |
2131 | DEBUG2(printk("scsi(%ld): Failed to retrieve fcport " | 2157 | DEBUG2(printk("scsi(%ld): Failed to retrieve fcport " |
2132 | "information -- get_port_database=%x, " | 2158 | "information -- get_port_database=%x, " |
2133 | "loop_id=0x%04x\n", | 2159 | "loop_id=0x%04x\n", |
2134 | ha->host_no, rval2, new_fcport->loop_id)); | 2160 | vha->host_no, rval2, new_fcport->loop_id)); |
2135 | DEBUG2(printk("scsi(%ld): Scheduling resync...\n", | 2161 | DEBUG2(printk("scsi(%ld): Scheduling resync...\n", |
2136 | ha->host_no)); | 2162 | vha->host_no)); |
2137 | set_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags); | 2163 | set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); |
2138 | continue; | 2164 | continue; |
2139 | } | 2165 | } |
2140 | 2166 | ||
2141 | /* Check for matching device in port list. */ | 2167 | /* Check for matching device in port list. */ |
2142 | found = 0; | 2168 | found = 0; |
2143 | fcport = NULL; | 2169 | fcport = NULL; |
2144 | list_for_each_entry(fcport, &pha->fcports, list) { | 2170 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
2145 | if (fcport->vp_idx != ha->vp_idx) | ||
2146 | continue; | ||
2147 | |||
2148 | if (memcmp(new_fcport->port_name, fcport->port_name, | 2171 | if (memcmp(new_fcport->port_name, fcport->port_name, |
2149 | WWN_SIZE)) | 2172 | WWN_SIZE)) |
2150 | continue; | 2173 | continue; |
@@ -2164,17 +2187,15 @@ qla2x00_configure_local_loop(scsi_qla_host_t *ha) | |||
2164 | if (!found) { | 2187 | if (!found) { |
2165 | /* New device, add to fcports list. */ | 2188 | /* New device, add to fcports list. */ |
2166 | new_fcport->flags &= ~FCF_PERSISTENT_BOUND; | 2189 | new_fcport->flags &= ~FCF_PERSISTENT_BOUND; |
2167 | if (ha->parent) { | 2190 | if (vha->vp_idx) { |
2168 | new_fcport->ha = ha; | 2191 | new_fcport->vha = vha; |
2169 | new_fcport->vp_idx = ha->vp_idx; | 2192 | new_fcport->vp_idx = vha->vp_idx; |
2170 | list_add_tail(&new_fcport->vp_fcport, | ||
2171 | &ha->vp_fcports); | ||
2172 | } | 2193 | } |
2173 | list_add_tail(&new_fcport->list, &pha->fcports); | 2194 | list_add_tail(&new_fcport->list, &vha->vp_fcports); |
2174 | 2195 | ||
2175 | /* Allocate a new replacement fcport. */ | 2196 | /* Allocate a new replacement fcport. */ |
2176 | fcport = new_fcport; | 2197 | fcport = new_fcport; |
2177 | new_fcport = qla2x00_alloc_fcport(ha, GFP_KERNEL); | 2198 | new_fcport = qla2x00_alloc_fcport(vha, GFP_KERNEL); |
2178 | if (new_fcport == NULL) { | 2199 | if (new_fcport == NULL) { |
2179 | rval = QLA_MEMORY_ALLOC_FAILED; | 2200 | rval = QLA_MEMORY_ALLOC_FAILED; |
2180 | goto cleanup_allocation; | 2201 | goto cleanup_allocation; |
@@ -2185,7 +2206,7 @@ qla2x00_configure_local_loop(scsi_qla_host_t *ha) | |||
2185 | /* Base iIDMA settings on HBA port speed. */ | 2206 | /* Base iIDMA settings on HBA port speed. */ |
2186 | fcport->fp_speed = ha->link_data_rate; | 2207 | fcport->fp_speed = ha->link_data_rate; |
2187 | 2208 | ||
2188 | qla2x00_update_fcport(ha, fcport); | 2209 | qla2x00_update_fcport(vha, fcport); |
2189 | 2210 | ||
2190 | found_devs++; | 2211 | found_devs++; |
2191 | } | 2212 | } |
@@ -2195,24 +2216,25 @@ cleanup_allocation: | |||
2195 | 2216 | ||
2196 | if (rval != QLA_SUCCESS) { | 2217 | if (rval != QLA_SUCCESS) { |
2197 | DEBUG2(printk("scsi(%ld): Configure local loop error exit: " | 2218 | DEBUG2(printk("scsi(%ld): Configure local loop error exit: " |
2198 | "rval=%x\n", ha->host_no, rval)); | 2219 | "rval=%x\n", vha->host_no, rval)); |
2199 | } | 2220 | } |
2200 | 2221 | ||
2201 | if (found_devs) { | 2222 | if (found_devs) { |
2202 | ha->device_flags |= DFLG_LOCAL_DEVICES; | 2223 | vha->device_flags |= DFLG_LOCAL_DEVICES; |
2203 | ha->device_flags &= ~DFLG_RETRY_LOCAL_DEVICES; | 2224 | vha->device_flags &= ~DFLG_RETRY_LOCAL_DEVICES; |
2204 | } | 2225 | } |
2205 | 2226 | ||
2206 | return (rval); | 2227 | return (rval); |
2207 | } | 2228 | } |
2208 | 2229 | ||
2209 | static void | 2230 | static void |
2210 | qla2x00_iidma_fcport(scsi_qla_host_t *ha, fc_port_t *fcport) | 2231 | qla2x00_iidma_fcport(scsi_qla_host_t *vha, fc_port_t *fcport) |
2211 | { | 2232 | { |
2212 | #define LS_UNKNOWN 2 | 2233 | #define LS_UNKNOWN 2 |
2213 | static char *link_speeds[5] = { "1", "2", "?", "4", "8" }; | 2234 | static char *link_speeds[5] = { "1", "2", "?", "4", "8" }; |
2214 | int rval; | 2235 | int rval; |
2215 | uint16_t mb[6]; | 2236 | uint16_t mb[6]; |
2237 | struct qla_hw_data *ha = vha->hw; | ||
2216 | 2238 | ||
2217 | if (!IS_IIDMA_CAPABLE(ha)) | 2239 | if (!IS_IIDMA_CAPABLE(ha)) |
2218 | return; | 2240 | return; |
@@ -2221,12 +2243,12 @@ qla2x00_iidma_fcport(scsi_qla_host_t *ha, fc_port_t *fcport) | |||
2221 | fcport->fp_speed > ha->link_data_rate) | 2243 | fcport->fp_speed > ha->link_data_rate) |
2222 | return; | 2244 | return; |
2223 | 2245 | ||
2224 | rval = qla2x00_set_idma_speed(ha, fcport->loop_id, fcport->fp_speed, | 2246 | rval = qla2x00_set_idma_speed(vha, fcport->loop_id, fcport->fp_speed, |
2225 | mb); | 2247 | mb); |
2226 | if (rval != QLA_SUCCESS) { | 2248 | if (rval != QLA_SUCCESS) { |
2227 | DEBUG2(printk("scsi(%ld): Unable to adjust iIDMA " | 2249 | DEBUG2(printk("scsi(%ld): Unable to adjust iIDMA " |
2228 | "%02x%02x%02x%02x%02x%02x%02x%02x -- %04x %x %04x %04x.\n", | 2250 | "%02x%02x%02x%02x%02x%02x%02x%02x -- %04x %x %04x %04x.\n", |
2229 | ha->host_no, fcport->port_name[0], fcport->port_name[1], | 2251 | vha->host_no, fcport->port_name[0], fcport->port_name[1], |
2230 | fcport->port_name[2], fcport->port_name[3], | 2252 | fcport->port_name[2], fcport->port_name[3], |
2231 | fcport->port_name[4], fcport->port_name[5], | 2253 | fcport->port_name[4], fcport->port_name[5], |
2232 | fcport->port_name[6], fcport->port_name[7], rval, | 2254 | fcport->port_name[6], fcport->port_name[7], rval, |
@@ -2244,10 +2266,11 @@ qla2x00_iidma_fcport(scsi_qla_host_t *ha, fc_port_t *fcport) | |||
2244 | } | 2266 | } |
2245 | 2267 | ||
2246 | static void | 2268 | static void |
2247 | qla2x00_reg_remote_port(scsi_qla_host_t *ha, fc_port_t *fcport) | 2269 | qla2x00_reg_remote_port(scsi_qla_host_t *vha, fc_port_t *fcport) |
2248 | { | 2270 | { |
2249 | struct fc_rport_identifiers rport_ids; | 2271 | struct fc_rport_identifiers rport_ids; |
2250 | struct fc_rport *rport; | 2272 | struct fc_rport *rport; |
2273 | struct qla_hw_data *ha = vha->hw; | ||
2251 | 2274 | ||
2252 | if (fcport->drport) | 2275 | if (fcport->drport) |
2253 | qla2x00_rport_del(fcport); | 2276 | qla2x00_rport_del(fcport); |
@@ -2257,15 +2280,15 @@ qla2x00_reg_remote_port(scsi_qla_host_t *ha, fc_port_t *fcport) | |||
2257 | rport_ids.port_id = fcport->d_id.b.domain << 16 | | 2280 | rport_ids.port_id = fcport->d_id.b.domain << 16 | |
2258 | fcport->d_id.b.area << 8 | fcport->d_id.b.al_pa; | 2281 | fcport->d_id.b.area << 8 | fcport->d_id.b.al_pa; |
2259 | rport_ids.roles = FC_RPORT_ROLE_UNKNOWN; | 2282 | rport_ids.roles = FC_RPORT_ROLE_UNKNOWN; |
2260 | fcport->rport = rport = fc_remote_port_add(ha->host, 0, &rport_ids); | 2283 | fcport->rport = rport = fc_remote_port_add(vha->host, 0, &rport_ids); |
2261 | if (!rport) { | 2284 | if (!rport) { |
2262 | qla_printk(KERN_WARNING, ha, | 2285 | qla_printk(KERN_WARNING, ha, |
2263 | "Unable to allocate fc remote port!\n"); | 2286 | "Unable to allocate fc remote port!\n"); |
2264 | return; | 2287 | return; |
2265 | } | 2288 | } |
2266 | spin_lock_irq(fcport->ha->host->host_lock); | 2289 | spin_lock_irq(fcport->vha->host->host_lock); |
2267 | *((fc_port_t **)rport->dd_data) = fcport; | 2290 | *((fc_port_t **)rport->dd_data) = fcport; |
2268 | spin_unlock_irq(fcport->ha->host->host_lock); | 2291 | spin_unlock_irq(fcport->vha->host->host_lock); |
2269 | 2292 | ||
2270 | rport->supported_classes = fcport->supported_classes; | 2293 | rport->supported_classes = fcport->supported_classes; |
2271 | 2294 | ||
@@ -2293,23 +2316,23 @@ qla2x00_reg_remote_port(scsi_qla_host_t *ha, fc_port_t *fcport) | |||
2293 | * Kernel context. | 2316 | * Kernel context. |
2294 | */ | 2317 | */ |
2295 | void | 2318 | void |
2296 | qla2x00_update_fcport(scsi_qla_host_t *ha, fc_port_t *fcport) | 2319 | qla2x00_update_fcport(scsi_qla_host_t *vha, fc_port_t *fcport) |
2297 | { | 2320 | { |
2298 | scsi_qla_host_t *pha = to_qla_parent(ha); | 2321 | struct qla_hw_data *ha = vha->hw; |
2299 | 2322 | ||
2300 | fcport->ha = ha; | 2323 | fcport->vha = vha; |
2301 | fcport->login_retry = 0; | 2324 | fcport->login_retry = 0; |
2302 | fcport->port_login_retry_count = pha->port_down_retry_count * | 2325 | fcport->port_login_retry_count = ha->port_down_retry_count * |
2303 | PORT_RETRY_TIME; | 2326 | PORT_RETRY_TIME; |
2304 | atomic_set(&fcport->port_down_timer, pha->port_down_retry_count * | 2327 | atomic_set(&fcport->port_down_timer, ha->port_down_retry_count * |
2305 | PORT_RETRY_TIME); | 2328 | PORT_RETRY_TIME); |
2306 | fcport->flags &= ~FCF_LOGIN_NEEDED; | 2329 | fcport->flags &= ~FCF_LOGIN_NEEDED; |
2307 | 2330 | ||
2308 | qla2x00_iidma_fcport(ha, fcport); | 2331 | qla2x00_iidma_fcport(vha, fcport); |
2309 | 2332 | ||
2310 | atomic_set(&fcport->state, FCS_ONLINE); | 2333 | atomic_set(&fcport->state, FCS_ONLINE); |
2311 | 2334 | ||
2312 | qla2x00_reg_remote_port(ha, fcport); | 2335 | qla2x00_reg_remote_port(vha, fcport); |
2313 | } | 2336 | } |
2314 | 2337 | ||
2315 | /* | 2338 | /* |
@@ -2324,7 +2347,7 @@ qla2x00_update_fcport(scsi_qla_host_t *ha, fc_port_t *fcport) | |||
2324 | * BIT_0 = error | 2347 | * BIT_0 = error |
2325 | */ | 2348 | */ |
2326 | static int | 2349 | static int |
2327 | qla2x00_configure_fabric(scsi_qla_host_t *ha) | 2350 | qla2x00_configure_fabric(scsi_qla_host_t *vha) |
2328 | { | 2351 | { |
2329 | int rval, rval2; | 2352 | int rval, rval2; |
2330 | fc_port_t *fcport, *fcptemp; | 2353 | fc_port_t *fcport, *fcptemp; |
@@ -2332,25 +2355,26 @@ qla2x00_configure_fabric(scsi_qla_host_t *ha) | |||
2332 | uint16_t mb[MAILBOX_REGISTER_COUNT]; | 2355 | uint16_t mb[MAILBOX_REGISTER_COUNT]; |
2333 | uint16_t loop_id; | 2356 | uint16_t loop_id; |
2334 | LIST_HEAD(new_fcports); | 2357 | LIST_HEAD(new_fcports); |
2335 | scsi_qla_host_t *pha = to_qla_parent(ha); | 2358 | struct qla_hw_data *ha = vha->hw; |
2359 | struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); | ||
2336 | 2360 | ||
2337 | /* If FL port exists, then SNS is present */ | 2361 | /* If FL port exists, then SNS is present */ |
2338 | if (IS_FWI2_CAPABLE(ha)) | 2362 | if (IS_FWI2_CAPABLE(ha)) |
2339 | loop_id = NPH_F_PORT; | 2363 | loop_id = NPH_F_PORT; |
2340 | else | 2364 | else |
2341 | loop_id = SNS_FL_PORT; | 2365 | loop_id = SNS_FL_PORT; |
2342 | rval = qla2x00_get_port_name(ha, loop_id, ha->fabric_node_name, 1); | 2366 | rval = qla2x00_get_port_name(vha, loop_id, vha->fabric_node_name, 1); |
2343 | if (rval != QLA_SUCCESS) { | 2367 | if (rval != QLA_SUCCESS) { |
2344 | DEBUG2(printk("scsi(%ld): MBC_GET_PORT_NAME Failed, No FL " | 2368 | DEBUG2(printk("scsi(%ld): MBC_GET_PORT_NAME Failed, No FL " |
2345 | "Port\n", ha->host_no)); | 2369 | "Port\n", vha->host_no)); |
2346 | 2370 | ||
2347 | ha->device_flags &= ~SWITCH_FOUND; | 2371 | vha->device_flags &= ~SWITCH_FOUND; |
2348 | return (QLA_SUCCESS); | 2372 | return (QLA_SUCCESS); |
2349 | } | 2373 | } |
2350 | ha->device_flags |= SWITCH_FOUND; | 2374 | vha->device_flags |= SWITCH_FOUND; |
2351 | 2375 | ||
2352 | /* Mark devices that need re-synchronization. */ | 2376 | /* Mark devices that need re-synchronization. */ |
2353 | rval2 = qla2x00_device_resync(ha); | 2377 | rval2 = qla2x00_device_resync(vha); |
2354 | if (rval2 == QLA_RSCNS_HANDLED) { | 2378 | if (rval2 == QLA_RSCNS_HANDLED) { |
2355 | /* No point doing the scan, just continue. */ | 2379 | /* No point doing the scan, just continue. */ |
2356 | return (QLA_SUCCESS); | 2380 | return (QLA_SUCCESS); |
@@ -2358,15 +2382,15 @@ qla2x00_configure_fabric(scsi_qla_host_t *ha) | |||
2358 | do { | 2382 | do { |
2359 | /* FDMI support. */ | 2383 | /* FDMI support. */ |
2360 | if (ql2xfdmienable && | 2384 | if (ql2xfdmienable && |
2361 | test_and_clear_bit(REGISTER_FDMI_NEEDED, &ha->dpc_flags)) | 2385 | test_and_clear_bit(REGISTER_FDMI_NEEDED, &vha->dpc_flags)) |
2362 | qla2x00_fdmi_register(ha); | 2386 | qla2x00_fdmi_register(vha); |
2363 | 2387 | ||
2364 | /* Ensure we are logged into the SNS. */ | 2388 | /* Ensure we are logged into the SNS. */ |
2365 | if (IS_FWI2_CAPABLE(ha)) | 2389 | if (IS_FWI2_CAPABLE(ha)) |
2366 | loop_id = NPH_SNS; | 2390 | loop_id = NPH_SNS; |
2367 | else | 2391 | else |
2368 | loop_id = SIMPLE_NAME_SERVER; | 2392 | loop_id = SIMPLE_NAME_SERVER; |
2369 | ha->isp_ops->fabric_login(ha, loop_id, 0xff, 0xff, | 2393 | ha->isp_ops->fabric_login(vha, loop_id, 0xff, 0xff, |
2370 | 0xfc, mb, BIT_1 | BIT_0); | 2394 | 0xfc, mb, BIT_1 | BIT_0); |
2371 | if (mb[0] != MBS_COMMAND_COMPLETE) { | 2395 | if (mb[0] != MBS_COMMAND_COMPLETE) { |
2372 | DEBUG2(qla_printk(KERN_INFO, ha, | 2396 | DEBUG2(qla_printk(KERN_INFO, ha, |
@@ -2376,29 +2400,29 @@ qla2x00_configure_fabric(scsi_qla_host_t *ha) | |||
2376 | return (QLA_SUCCESS); | 2400 | return (QLA_SUCCESS); |
2377 | } | 2401 | } |
2378 | 2402 | ||
2379 | if (test_and_clear_bit(REGISTER_FC4_NEEDED, &ha->dpc_flags)) { | 2403 | if (test_and_clear_bit(REGISTER_FC4_NEEDED, &vha->dpc_flags)) { |
2380 | if (qla2x00_rft_id(ha)) { | 2404 | if (qla2x00_rft_id(vha)) { |
2381 | /* EMPTY */ | 2405 | /* EMPTY */ |
2382 | DEBUG2(printk("scsi(%ld): Register FC-4 " | 2406 | DEBUG2(printk("scsi(%ld): Register FC-4 " |
2383 | "TYPE failed.\n", ha->host_no)); | 2407 | "TYPE failed.\n", vha->host_no)); |
2384 | } | 2408 | } |
2385 | if (qla2x00_rff_id(ha)) { | 2409 | if (qla2x00_rff_id(vha)) { |
2386 | /* EMPTY */ | 2410 | /* EMPTY */ |
2387 | DEBUG2(printk("scsi(%ld): Register FC-4 " | 2411 | DEBUG2(printk("scsi(%ld): Register FC-4 " |
2388 | "Features failed.\n", ha->host_no)); | 2412 | "Features failed.\n", vha->host_no)); |
2389 | } | 2413 | } |
2390 | if (qla2x00_rnn_id(ha)) { | 2414 | if (qla2x00_rnn_id(vha)) { |
2391 | /* EMPTY */ | 2415 | /* EMPTY */ |
2392 | DEBUG2(printk("scsi(%ld): Register Node Name " | 2416 | DEBUG2(printk("scsi(%ld): Register Node Name " |
2393 | "failed.\n", ha->host_no)); | 2417 | "failed.\n", vha->host_no)); |
2394 | } else if (qla2x00_rsnn_nn(ha)) { | 2418 | } else if (qla2x00_rsnn_nn(vha)) { |
2395 | /* EMPTY */ | 2419 | /* EMPTY */ |
2396 | DEBUG2(printk("scsi(%ld): Register Symbolic " | 2420 | DEBUG2(printk("scsi(%ld): Register Symbolic " |
2397 | "Node Name failed.\n", ha->host_no)); | 2421 | "Node Name failed.\n", vha->host_no)); |
2398 | } | 2422 | } |
2399 | } | 2423 | } |
2400 | 2424 | ||
2401 | rval = qla2x00_find_all_fabric_devs(ha, &new_fcports); | 2425 | rval = qla2x00_find_all_fabric_devs(vha, &new_fcports); |
2402 | if (rval != QLA_SUCCESS) | 2426 | if (rval != QLA_SUCCESS) |
2403 | break; | 2427 | break; |
2404 | 2428 | ||
@@ -2406,24 +2430,21 @@ qla2x00_configure_fabric(scsi_qla_host_t *ha) | |||
2406 | * Logout all previous fabric devices marked lost, except | 2430 | * Logout all previous fabric devices marked lost, except |
2407 | * tape devices. | 2431 | * tape devices. |
2408 | */ | 2432 | */ |
2409 | list_for_each_entry(fcport, &pha->fcports, list) { | 2433 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
2410 | if (fcport->vp_idx !=ha->vp_idx) | 2434 | if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) |
2411 | continue; | ||
2412 | |||
2413 | if (test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags)) | ||
2414 | break; | 2435 | break; |
2415 | 2436 | ||
2416 | if ((fcport->flags & FCF_FABRIC_DEVICE) == 0) | 2437 | if ((fcport->flags & FCF_FABRIC_DEVICE) == 0) |
2417 | continue; | 2438 | continue; |
2418 | 2439 | ||
2419 | if (atomic_read(&fcport->state) == FCS_DEVICE_LOST) { | 2440 | if (atomic_read(&fcport->state) == FCS_DEVICE_LOST) { |
2420 | qla2x00_mark_device_lost(ha, fcport, | 2441 | qla2x00_mark_device_lost(vha, fcport, |
2421 | ql2xplogiabsentdevice, 0); | 2442 | ql2xplogiabsentdevice, 0); |
2422 | if (fcport->loop_id != FC_NO_LOOP_ID && | 2443 | if (fcport->loop_id != FC_NO_LOOP_ID && |
2423 | (fcport->flags & FCF_TAPE_PRESENT) == 0 && | 2444 | (fcport->flags & FCF_TAPE_PRESENT) == 0 && |
2424 | fcport->port_type != FCT_INITIATOR && | 2445 | fcport->port_type != FCT_INITIATOR && |
2425 | fcport->port_type != FCT_BROADCAST) { | 2446 | fcport->port_type != FCT_BROADCAST) { |
2426 | ha->isp_ops->fabric_logout(ha, | 2447 | ha->isp_ops->fabric_logout(vha, |
2427 | fcport->loop_id, | 2448 | fcport->loop_id, |
2428 | fcport->d_id.b.domain, | 2449 | fcport->d_id.b.domain, |
2429 | fcport->d_id.b.area, | 2450 | fcport->d_id.b.area, |
@@ -2434,18 +2455,15 @@ qla2x00_configure_fabric(scsi_qla_host_t *ha) | |||
2434 | } | 2455 | } |
2435 | 2456 | ||
2436 | /* Starting free loop ID. */ | 2457 | /* Starting free loop ID. */ |
2437 | next_loopid = pha->min_external_loopid; | 2458 | next_loopid = ha->min_external_loopid; |
2438 | 2459 | ||
2439 | /* | 2460 | /* |
2440 | * Scan through our port list and login entries that need to be | 2461 | * Scan through our port list and login entries that need to be |
2441 | * logged in. | 2462 | * logged in. |
2442 | */ | 2463 | */ |
2443 | list_for_each_entry(fcport, &pha->fcports, list) { | 2464 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
2444 | if (fcport->vp_idx != ha->vp_idx) | 2465 | if (atomic_read(&vha->loop_down_timer) || |
2445 | continue; | 2466 | test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) |
2446 | |||
2447 | if (atomic_read(&ha->loop_down_timer) || | ||
2448 | test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags)) | ||
2449 | break; | 2467 | break; |
2450 | 2468 | ||
2451 | if ((fcport->flags & FCF_FABRIC_DEVICE) == 0 || | 2469 | if ((fcport->flags & FCF_FABRIC_DEVICE) == 0 || |
@@ -2455,14 +2473,14 @@ qla2x00_configure_fabric(scsi_qla_host_t *ha) | |||
2455 | if (fcport->loop_id == FC_NO_LOOP_ID) { | 2473 | if (fcport->loop_id == FC_NO_LOOP_ID) { |
2456 | fcport->loop_id = next_loopid; | 2474 | fcport->loop_id = next_loopid; |
2457 | rval = qla2x00_find_new_loop_id( | 2475 | rval = qla2x00_find_new_loop_id( |
2458 | to_qla_parent(ha), fcport); | 2476 | base_vha, fcport); |
2459 | if (rval != QLA_SUCCESS) { | 2477 | if (rval != QLA_SUCCESS) { |
2460 | /* Ran out of IDs to use */ | 2478 | /* Ran out of IDs to use */ |
2461 | break; | 2479 | break; |
2462 | } | 2480 | } |
2463 | } | 2481 | } |
2464 | /* Login and update database */ | 2482 | /* Login and update database */ |
2465 | qla2x00_fabric_dev_login(ha, fcport, &next_loopid); | 2483 | qla2x00_fabric_dev_login(vha, fcport, &next_loopid); |
2466 | } | 2484 | } |
2467 | 2485 | ||
2468 | /* Exit if out of loop IDs. */ | 2486 | /* Exit if out of loop IDs. */ |
@@ -2474,31 +2492,26 @@ qla2x00_configure_fabric(scsi_qla_host_t *ha) | |||
2474 | * Login and add the new devices to our port list. | 2492 | * Login and add the new devices to our port list. |
2475 | */ | 2493 | */ |
2476 | list_for_each_entry_safe(fcport, fcptemp, &new_fcports, list) { | 2494 | list_for_each_entry_safe(fcport, fcptemp, &new_fcports, list) { |
2477 | if (atomic_read(&ha->loop_down_timer) || | 2495 | if (atomic_read(&vha->loop_down_timer) || |
2478 | test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags)) | 2496 | test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) |
2479 | break; | 2497 | break; |
2480 | 2498 | ||
2481 | /* Find a new loop ID to use. */ | 2499 | /* Find a new loop ID to use. */ |
2482 | fcport->loop_id = next_loopid; | 2500 | fcport->loop_id = next_loopid; |
2483 | rval = qla2x00_find_new_loop_id(to_qla_parent(ha), | 2501 | rval = qla2x00_find_new_loop_id(base_vha, fcport); |
2484 | fcport); | ||
2485 | if (rval != QLA_SUCCESS) { | 2502 | if (rval != QLA_SUCCESS) { |
2486 | /* Ran out of IDs to use */ | 2503 | /* Ran out of IDs to use */ |
2487 | break; | 2504 | break; |
2488 | } | 2505 | } |
2489 | 2506 | ||
2490 | /* Login and update database */ | 2507 | /* Login and update database */ |
2491 | qla2x00_fabric_dev_login(ha, fcport, &next_loopid); | 2508 | qla2x00_fabric_dev_login(vha, fcport, &next_loopid); |
2492 | 2509 | ||
2493 | if (ha->parent) { | 2510 | if (vha->vp_idx) { |
2494 | fcport->ha = ha; | 2511 | fcport->vha = vha; |
2495 | fcport->vp_idx = ha->vp_idx; | 2512 | fcport->vp_idx = vha->vp_idx; |
2496 | list_add_tail(&fcport->vp_fcport, | 2513 | } |
2497 | &ha->vp_fcports); | 2514 | list_move_tail(&fcport->list, &vha->vp_fcports); |
2498 | list_move_tail(&fcport->list, | ||
2499 | &ha->parent->fcports); | ||
2500 | } else | ||
2501 | list_move_tail(&fcport->list, &ha->fcports); | ||
2502 | } | 2515 | } |
2503 | } while (0); | 2516 | } while (0); |
2504 | 2517 | ||
@@ -2510,7 +2523,7 @@ qla2x00_configure_fabric(scsi_qla_host_t *ha) | |||
2510 | 2523 | ||
2511 | if (rval) { | 2524 | if (rval) { |
2512 | DEBUG2(printk("scsi(%ld): Configure fabric error exit: " | 2525 | DEBUG2(printk("scsi(%ld): Configure fabric error exit: " |
2513 | "rval=%d\n", ha->host_no, rval)); | 2526 | "rval=%d\n", vha->host_no, rval)); |
2514 | } | 2527 | } |
2515 | 2528 | ||
2516 | return (rval); | 2529 | return (rval); |
@@ -2531,7 +2544,8 @@ qla2x00_configure_fabric(scsi_qla_host_t *ha) | |||
2531 | * Kernel context. | 2544 | * Kernel context. |
2532 | */ | 2545 | */ |
2533 | static int | 2546 | static int |
2534 | qla2x00_find_all_fabric_devs(scsi_qla_host_t *ha, struct list_head *new_fcports) | 2547 | qla2x00_find_all_fabric_devs(scsi_qla_host_t *vha, |
2548 | struct list_head *new_fcports) | ||
2535 | { | 2549 | { |
2536 | int rval; | 2550 | int rval; |
2537 | uint16_t loop_id; | 2551 | uint16_t loop_id; |
@@ -2542,11 +2556,8 @@ qla2x00_find_all_fabric_devs(scsi_qla_host_t *ha, struct list_head *new_fcports) | |||
2542 | int swl_idx; | 2556 | int swl_idx; |
2543 | int first_dev, last_dev; | 2557 | int first_dev, last_dev; |
2544 | port_id_t wrap, nxt_d_id; | 2558 | port_id_t wrap, nxt_d_id; |
2545 | int vp_index; | 2559 | struct qla_hw_data *ha = vha->hw; |
2546 | int empty_vp_index; | 2560 | struct scsi_qla_host *vp, *base_vha = pci_get_drvdata(ha->pdev); |
2547 | int found_vp; | ||
2548 | scsi_qla_host_t *vha; | ||
2549 | scsi_qla_host_t *pha = to_qla_parent(ha); | ||
2550 | 2561 | ||
2551 | rval = QLA_SUCCESS; | 2562 | rval = QLA_SUCCESS; |
2552 | 2563 | ||
@@ -2555,43 +2566,42 @@ qla2x00_find_all_fabric_devs(scsi_qla_host_t *ha, struct list_head *new_fcports) | |||
2555 | if (!swl) { | 2566 | if (!swl) { |
2556 | /*EMPTY*/ | 2567 | /*EMPTY*/ |
2557 | DEBUG2(printk("scsi(%ld): GID_PT allocations failed, fallback " | 2568 | DEBUG2(printk("scsi(%ld): GID_PT allocations failed, fallback " |
2558 | "on GA_NXT\n", ha->host_no)); | 2569 | "on GA_NXT\n", vha->host_no)); |
2559 | } else { | 2570 | } else { |
2560 | if (qla2x00_gid_pt(ha, swl) != QLA_SUCCESS) { | 2571 | if (qla2x00_gid_pt(vha, swl) != QLA_SUCCESS) { |
2561 | kfree(swl); | 2572 | kfree(swl); |
2562 | swl = NULL; | 2573 | swl = NULL; |
2563 | } else if (qla2x00_gpn_id(ha, swl) != QLA_SUCCESS) { | 2574 | } else if (qla2x00_gpn_id(vha, swl) != QLA_SUCCESS) { |
2564 | kfree(swl); | 2575 | kfree(swl); |
2565 | swl = NULL; | 2576 | swl = NULL; |
2566 | } else if (qla2x00_gnn_id(ha, swl) != QLA_SUCCESS) { | 2577 | } else if (qla2x00_gnn_id(vha, swl) != QLA_SUCCESS) { |
2567 | kfree(swl); | 2578 | kfree(swl); |
2568 | swl = NULL; | 2579 | swl = NULL; |
2569 | } else if (ql2xiidmaenable && | 2580 | } else if (ql2xiidmaenable && |
2570 | qla2x00_gfpn_id(ha, swl) == QLA_SUCCESS) { | 2581 | qla2x00_gfpn_id(vha, swl) == QLA_SUCCESS) { |
2571 | qla2x00_gpsc(ha, swl); | 2582 | qla2x00_gpsc(vha, swl); |
2572 | } | 2583 | } |
2573 | } | 2584 | } |
2574 | swl_idx = 0; | 2585 | swl_idx = 0; |
2575 | 2586 | ||
2576 | /* Allocate temporary fcport for any new fcports discovered. */ | 2587 | /* Allocate temporary fcport for any new fcports discovered. */ |
2577 | new_fcport = qla2x00_alloc_fcport(ha, GFP_KERNEL); | 2588 | new_fcport = qla2x00_alloc_fcport(vha, GFP_KERNEL); |
2578 | if (new_fcport == NULL) { | 2589 | if (new_fcport == NULL) { |
2579 | kfree(swl); | 2590 | kfree(swl); |
2580 | return (QLA_MEMORY_ALLOC_FAILED); | 2591 | return (QLA_MEMORY_ALLOC_FAILED); |
2581 | } | 2592 | } |
2582 | new_fcport->flags |= (FCF_FABRIC_DEVICE | FCF_LOGIN_NEEDED); | 2593 | new_fcport->flags |= (FCF_FABRIC_DEVICE | FCF_LOGIN_NEEDED); |
2583 | new_fcport->vp_idx = ha->vp_idx; | ||
2584 | /* Set start port ID scan at adapter ID. */ | 2594 | /* Set start port ID scan at adapter ID. */ |
2585 | first_dev = 1; | 2595 | first_dev = 1; |
2586 | last_dev = 0; | 2596 | last_dev = 0; |
2587 | 2597 | ||
2588 | /* Starting free loop ID. */ | 2598 | /* Starting free loop ID. */ |
2589 | loop_id = pha->min_external_loopid; | 2599 | loop_id = ha->min_external_loopid; |
2590 | for (; loop_id <= ha->last_loop_id; loop_id++) { | 2600 | for (; loop_id <= ha->max_loop_id; loop_id++) { |
2591 | if (qla2x00_is_reserved_id(ha, loop_id)) | 2601 | if (qla2x00_is_reserved_id(vha, loop_id)) |
2592 | continue; | 2602 | continue; |
2593 | 2603 | ||
2594 | if (atomic_read(&ha->loop_down_timer) || LOOP_TRANSITION(ha)) | 2604 | if (atomic_read(&vha->loop_down_timer) || LOOP_TRANSITION(vha)) |
2595 | break; | 2605 | break; |
2596 | 2606 | ||
2597 | if (swl != NULL) { | 2607 | if (swl != NULL) { |
@@ -2614,7 +2624,7 @@ qla2x00_find_all_fabric_devs(scsi_qla_host_t *ha, struct list_head *new_fcports) | |||
2614 | } | 2624 | } |
2615 | } else { | 2625 | } else { |
2616 | /* Send GA_NXT to the switch */ | 2626 | /* Send GA_NXT to the switch */ |
2617 | rval = qla2x00_ga_nxt(ha, new_fcport); | 2627 | rval = qla2x00_ga_nxt(vha, new_fcport); |
2618 | if (rval != QLA_SUCCESS) { | 2628 | if (rval != QLA_SUCCESS) { |
2619 | qla_printk(KERN_WARNING, ha, | 2629 | qla_printk(KERN_WARNING, ha, |
2620 | "SNS scan failed -- assuming zero-entry " | 2630 | "SNS scan failed -- assuming zero-entry " |
@@ -2635,44 +2645,31 @@ qla2x00_find_all_fabric_devs(scsi_qla_host_t *ha, struct list_head *new_fcports) | |||
2635 | first_dev = 0; | 2645 | first_dev = 0; |
2636 | } else if (new_fcport->d_id.b24 == wrap.b24) { | 2646 | } else if (new_fcport->d_id.b24 == wrap.b24) { |
2637 | DEBUG2(printk("scsi(%ld): device wrap (%02x%02x%02x)\n", | 2647 | DEBUG2(printk("scsi(%ld): device wrap (%02x%02x%02x)\n", |
2638 | ha->host_no, new_fcport->d_id.b.domain, | 2648 | vha->host_no, new_fcport->d_id.b.domain, |
2639 | new_fcport->d_id.b.area, new_fcport->d_id.b.al_pa)); | 2649 | new_fcport->d_id.b.area, new_fcport->d_id.b.al_pa)); |
2640 | break; | 2650 | break; |
2641 | } | 2651 | } |
2642 | 2652 | ||
2643 | /* Bypass if same physical adapter. */ | 2653 | /* Bypass if same physical adapter. */ |
2644 | if (new_fcport->d_id.b24 == pha->d_id.b24) | 2654 | if (new_fcport->d_id.b24 == base_vha->d_id.b24) |
2645 | continue; | 2655 | continue; |
2646 | 2656 | ||
2647 | /* Bypass virtual ports of the same host. */ | 2657 | /* Bypass virtual ports of the same host. */ |
2648 | if (pha->num_vhosts) { | 2658 | found = 0; |
2649 | for_each_mapped_vp_idx(pha, vp_index) { | 2659 | if (ha->num_vhosts) { |
2650 | empty_vp_index = 1; | 2660 | list_for_each_entry(vp, &ha->vp_list, list) { |
2651 | found_vp = 0; | 2661 | if (new_fcport->d_id.b24 == vp->d_id.b24) { |
2652 | list_for_each_entry(vha, &pha->vp_list, | 2662 | found = 1; |
2653 | vp_list) { | ||
2654 | if (vp_index == vha->vp_idx) { | ||
2655 | empty_vp_index = 0; | ||
2656 | found_vp = 1; | ||
2657 | break; | ||
2658 | } | ||
2659 | } | ||
2660 | |||
2661 | if (empty_vp_index) | ||
2662 | continue; | ||
2663 | |||
2664 | if (found_vp && | ||
2665 | new_fcport->d_id.b24 == vha->d_id.b24) | ||
2666 | break; | 2663 | break; |
2664 | } | ||
2667 | } | 2665 | } |
2668 | 2666 | if (found) | |
2669 | if (vp_index <= pha->max_npiv_vports) | ||
2670 | continue; | 2667 | continue; |
2671 | } | 2668 | } |
2672 | 2669 | ||
2673 | /* Bypass if same domain and area of adapter. */ | 2670 | /* Bypass if same domain and area of adapter. */ |
2674 | if (((new_fcport->d_id.b24 & 0xffff00) == | 2671 | if (((new_fcport->d_id.b24 & 0xffff00) == |
2675 | (ha->d_id.b24 & 0xffff00)) && ha->current_topology == | 2672 | (vha->d_id.b24 & 0xffff00)) && ha->current_topology == |
2676 | ISP_CFG_FL) | 2673 | ISP_CFG_FL) |
2677 | continue; | 2674 | continue; |
2678 | 2675 | ||
@@ -2682,9 +2679,7 @@ qla2x00_find_all_fabric_devs(scsi_qla_host_t *ha, struct list_head *new_fcports) | |||
2682 | 2679 | ||
2683 | /* Locate matching device in database. */ | 2680 | /* Locate matching device in database. */ |
2684 | found = 0; | 2681 | found = 0; |
2685 | list_for_each_entry(fcport, &pha->fcports, list) { | 2682 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
2686 | if (new_fcport->vp_idx != fcport->vp_idx) | ||
2687 | continue; | ||
2688 | if (memcmp(new_fcport->port_name, fcport->port_name, | 2683 | if (memcmp(new_fcport->port_name, fcport->port_name, |
2689 | WWN_SIZE)) | 2684 | WWN_SIZE)) |
2690 | continue; | 2685 | continue; |
@@ -2728,7 +2723,7 @@ qla2x00_find_all_fabric_devs(scsi_qla_host_t *ha, struct list_head *new_fcports) | |||
2728 | (fcport->flags & FCF_TAPE_PRESENT) == 0 && | 2723 | (fcport->flags & FCF_TAPE_PRESENT) == 0 && |
2729 | fcport->port_type != FCT_INITIATOR && | 2724 | fcport->port_type != FCT_INITIATOR && |
2730 | fcport->port_type != FCT_BROADCAST) { | 2725 | fcport->port_type != FCT_BROADCAST) { |
2731 | ha->isp_ops->fabric_logout(ha, fcport->loop_id, | 2726 | ha->isp_ops->fabric_logout(vha, fcport->loop_id, |
2732 | fcport->d_id.b.domain, fcport->d_id.b.area, | 2727 | fcport->d_id.b.domain, fcport->d_id.b.area, |
2733 | fcport->d_id.b.al_pa); | 2728 | fcport->d_id.b.al_pa); |
2734 | fcport->loop_id = FC_NO_LOOP_ID; | 2729 | fcport->loop_id = FC_NO_LOOP_ID; |
@@ -2739,27 +2734,25 @@ qla2x00_find_all_fabric_devs(scsi_qla_host_t *ha, struct list_head *new_fcports) | |||
2739 | 2734 | ||
2740 | if (found) | 2735 | if (found) |
2741 | continue; | 2736 | continue; |
2742 | |||
2743 | /* If device was not in our fcports list, then add it. */ | 2737 | /* If device was not in our fcports list, then add it. */ |
2744 | list_add_tail(&new_fcport->list, new_fcports); | 2738 | list_add_tail(&new_fcport->list, new_fcports); |
2745 | 2739 | ||
2746 | /* Allocate a new replacement fcport. */ | 2740 | /* Allocate a new replacement fcport. */ |
2747 | nxt_d_id.b24 = new_fcport->d_id.b24; | 2741 | nxt_d_id.b24 = new_fcport->d_id.b24; |
2748 | new_fcport = qla2x00_alloc_fcport(ha, GFP_KERNEL); | 2742 | new_fcport = qla2x00_alloc_fcport(vha, GFP_KERNEL); |
2749 | if (new_fcport == NULL) { | 2743 | if (new_fcport == NULL) { |
2750 | kfree(swl); | 2744 | kfree(swl); |
2751 | return (QLA_MEMORY_ALLOC_FAILED); | 2745 | return (QLA_MEMORY_ALLOC_FAILED); |
2752 | } | 2746 | } |
2753 | new_fcport->flags |= (FCF_FABRIC_DEVICE | FCF_LOGIN_NEEDED); | 2747 | new_fcport->flags |= (FCF_FABRIC_DEVICE | FCF_LOGIN_NEEDED); |
2754 | new_fcport->d_id.b24 = nxt_d_id.b24; | 2748 | new_fcport->d_id.b24 = nxt_d_id.b24; |
2755 | new_fcport->vp_idx = ha->vp_idx; | ||
2756 | } | 2749 | } |
2757 | 2750 | ||
2758 | kfree(swl); | 2751 | kfree(swl); |
2759 | kfree(new_fcport); | 2752 | kfree(new_fcport); |
2760 | 2753 | ||
2761 | if (!list_empty(new_fcports)) | 2754 | if (!list_empty(new_fcports)) |
2762 | ha->device_flags |= DFLG_FABRIC_DEVICES; | 2755 | vha->device_flags |= DFLG_FABRIC_DEVICES; |
2763 | 2756 | ||
2764 | return (rval); | 2757 | return (rval); |
2765 | } | 2758 | } |
@@ -2779,13 +2772,14 @@ qla2x00_find_all_fabric_devs(scsi_qla_host_t *ha, struct list_head *new_fcports) | |||
2779 | * Kernel context. | 2772 | * Kernel context. |
2780 | */ | 2773 | */ |
2781 | static int | 2774 | static int |
2782 | qla2x00_find_new_loop_id(scsi_qla_host_t *ha, fc_port_t *dev) | 2775 | qla2x00_find_new_loop_id(scsi_qla_host_t *vha, fc_port_t *dev) |
2783 | { | 2776 | { |
2784 | int rval; | 2777 | int rval; |
2785 | int found; | 2778 | int found; |
2786 | fc_port_t *fcport; | 2779 | fc_port_t *fcport; |
2787 | uint16_t first_loop_id; | 2780 | uint16_t first_loop_id; |
2788 | scsi_qla_host_t *pha = to_qla_parent(ha); | 2781 | struct qla_hw_data *ha = vha->hw; |
2782 | struct scsi_qla_host *vp; | ||
2789 | 2783 | ||
2790 | rval = QLA_SUCCESS; | 2784 | rval = QLA_SUCCESS; |
2791 | 2785 | ||
@@ -2794,17 +2788,15 @@ qla2x00_find_new_loop_id(scsi_qla_host_t *ha, fc_port_t *dev) | |||
2794 | 2788 | ||
2795 | for (;;) { | 2789 | for (;;) { |
2796 | /* Skip loop ID if already used by adapter. */ | 2790 | /* Skip loop ID if already used by adapter. */ |
2797 | if (dev->loop_id == ha->loop_id) { | 2791 | if (dev->loop_id == vha->loop_id) |
2798 | dev->loop_id++; | 2792 | dev->loop_id++; |
2799 | } | ||
2800 | 2793 | ||
2801 | /* Skip reserved loop IDs. */ | 2794 | /* Skip reserved loop IDs. */ |
2802 | while (qla2x00_is_reserved_id(ha, dev->loop_id)) { | 2795 | while (qla2x00_is_reserved_id(vha, dev->loop_id)) |
2803 | dev->loop_id++; | 2796 | dev->loop_id++; |
2804 | } | ||
2805 | 2797 | ||
2806 | /* Reset loop ID if passed the end. */ | 2798 | /* Reset loop ID if passed the end. */ |
2807 | if (dev->loop_id > ha->last_loop_id) { | 2799 | if (dev->loop_id > ha->max_loop_id) { |
2808 | /* first loop ID. */ | 2800 | /* first loop ID. */ |
2809 | dev->loop_id = ha->min_external_loopid; | 2801 | dev->loop_id = ha->min_external_loopid; |
2810 | } | 2802 | } |
@@ -2812,12 +2804,17 @@ qla2x00_find_new_loop_id(scsi_qla_host_t *ha, fc_port_t *dev) | |||
2812 | /* Check for loop ID being already in use. */ | 2804 | /* Check for loop ID being already in use. */ |
2813 | found = 0; | 2805 | found = 0; |
2814 | fcport = NULL; | 2806 | fcport = NULL; |
2815 | list_for_each_entry(fcport, &pha->fcports, list) { | 2807 | list_for_each_entry(vp, &ha->vp_list, list) { |
2816 | if (fcport->loop_id == dev->loop_id && fcport != dev) { | 2808 | list_for_each_entry(fcport, &vp->vp_fcports, list) { |
2817 | /* ID possibly in use */ | 2809 | if (fcport->loop_id == dev->loop_id && |
2818 | found++; | 2810 | fcport != dev) { |
2819 | break; | 2811 | /* ID possibly in use */ |
2812 | found++; | ||
2813 | break; | ||
2814 | } | ||
2820 | } | 2815 | } |
2816 | if (found) | ||
2817 | break; | ||
2821 | } | 2818 | } |
2822 | 2819 | ||
2823 | /* If not in use then it is free to use. */ | 2820 | /* If not in use then it is free to use. */ |
@@ -2850,7 +2847,7 @@ qla2x00_find_new_loop_id(scsi_qla_host_t *ha, fc_port_t *dev) | |||
2850 | * Kernel context. | 2847 | * Kernel context. |
2851 | */ | 2848 | */ |
2852 | static int | 2849 | static int |
2853 | qla2x00_device_resync(scsi_qla_host_t *ha) | 2850 | qla2x00_device_resync(scsi_qla_host_t *vha) |
2854 | { | 2851 | { |
2855 | int rval; | 2852 | int rval; |
2856 | uint32_t mask; | 2853 | uint32_t mask; |
@@ -2859,14 +2856,13 @@ qla2x00_device_resync(scsi_qla_host_t *ha) | |||
2859 | uint8_t rscn_out_iter; | 2856 | uint8_t rscn_out_iter; |
2860 | uint8_t format; | 2857 | uint8_t format; |
2861 | port_id_t d_id; | 2858 | port_id_t d_id; |
2862 | scsi_qla_host_t *pha = to_qla_parent(ha); | ||
2863 | 2859 | ||
2864 | rval = QLA_RSCNS_HANDLED; | 2860 | rval = QLA_RSCNS_HANDLED; |
2865 | 2861 | ||
2866 | while (ha->rscn_out_ptr != ha->rscn_in_ptr || | 2862 | while (vha->rscn_out_ptr != vha->rscn_in_ptr || |
2867 | ha->flags.rscn_queue_overflow) { | 2863 | vha->flags.rscn_queue_overflow) { |
2868 | 2864 | ||
2869 | rscn_entry = ha->rscn_queue[ha->rscn_out_ptr]; | 2865 | rscn_entry = vha->rscn_queue[vha->rscn_out_ptr]; |
2870 | format = MSB(MSW(rscn_entry)); | 2866 | format = MSB(MSW(rscn_entry)); |
2871 | d_id.b.domain = LSB(MSW(rscn_entry)); | 2867 | d_id.b.domain = LSB(MSW(rscn_entry)); |
2872 | d_id.b.area = MSB(LSW(rscn_entry)); | 2868 | d_id.b.area = MSB(LSW(rscn_entry)); |
@@ -2874,37 +2870,37 @@ qla2x00_device_resync(scsi_qla_host_t *ha) | |||
2874 | 2870 | ||
2875 | DEBUG(printk("scsi(%ld): RSCN queue entry[%d] = " | 2871 | DEBUG(printk("scsi(%ld): RSCN queue entry[%d] = " |
2876 | "[%02x/%02x%02x%02x].\n", | 2872 | "[%02x/%02x%02x%02x].\n", |
2877 | ha->host_no, ha->rscn_out_ptr, format, d_id.b.domain, | 2873 | vha->host_no, vha->rscn_out_ptr, format, d_id.b.domain, |
2878 | d_id.b.area, d_id.b.al_pa)); | 2874 | d_id.b.area, d_id.b.al_pa)); |
2879 | 2875 | ||
2880 | ha->rscn_out_ptr++; | 2876 | vha->rscn_out_ptr++; |
2881 | if (ha->rscn_out_ptr == MAX_RSCN_COUNT) | 2877 | if (vha->rscn_out_ptr == MAX_RSCN_COUNT) |
2882 | ha->rscn_out_ptr = 0; | 2878 | vha->rscn_out_ptr = 0; |
2883 | 2879 | ||
2884 | /* Skip duplicate entries. */ | 2880 | /* Skip duplicate entries. */ |
2885 | for (rscn_out_iter = ha->rscn_out_ptr; | 2881 | for (rscn_out_iter = vha->rscn_out_ptr; |
2886 | !ha->flags.rscn_queue_overflow && | 2882 | !vha->flags.rscn_queue_overflow && |
2887 | rscn_out_iter != ha->rscn_in_ptr; | 2883 | rscn_out_iter != vha->rscn_in_ptr; |
2888 | rscn_out_iter = (rscn_out_iter == | 2884 | rscn_out_iter = (rscn_out_iter == |
2889 | (MAX_RSCN_COUNT - 1)) ? 0: rscn_out_iter + 1) { | 2885 | (MAX_RSCN_COUNT - 1)) ? 0: rscn_out_iter + 1) { |
2890 | 2886 | ||
2891 | if (rscn_entry != ha->rscn_queue[rscn_out_iter]) | 2887 | if (rscn_entry != vha->rscn_queue[rscn_out_iter]) |
2892 | break; | 2888 | break; |
2893 | 2889 | ||
2894 | DEBUG(printk("scsi(%ld): Skipping duplicate RSCN queue " | 2890 | DEBUG(printk("scsi(%ld): Skipping duplicate RSCN queue " |
2895 | "entry found at [%d].\n", ha->host_no, | 2891 | "entry found at [%d].\n", vha->host_no, |
2896 | rscn_out_iter)); | 2892 | rscn_out_iter)); |
2897 | 2893 | ||
2898 | ha->rscn_out_ptr = rscn_out_iter; | 2894 | vha->rscn_out_ptr = rscn_out_iter; |
2899 | } | 2895 | } |
2900 | 2896 | ||
2901 | /* Queue overflow, set switch default case. */ | 2897 | /* Queue overflow, set switch default case. */ |
2902 | if (ha->flags.rscn_queue_overflow) { | 2898 | if (vha->flags.rscn_queue_overflow) { |
2903 | DEBUG(printk("scsi(%ld): device_resync: rscn " | 2899 | DEBUG(printk("scsi(%ld): device_resync: rscn " |
2904 | "overflow.\n", ha->host_no)); | 2900 | "overflow.\n", vha->host_no)); |
2905 | 2901 | ||
2906 | format = 3; | 2902 | format = 3; |
2907 | ha->flags.rscn_queue_overflow = 0; | 2903 | vha->flags.rscn_queue_overflow = 0; |
2908 | } | 2904 | } |
2909 | 2905 | ||
2910 | switch (format) { | 2906 | switch (format) { |
@@ -2920,16 +2916,13 @@ qla2x00_device_resync(scsi_qla_host_t *ha) | |||
2920 | default: | 2916 | default: |
2921 | mask = 0x0; | 2917 | mask = 0x0; |
2922 | d_id.b24 = 0; | 2918 | d_id.b24 = 0; |
2923 | ha->rscn_out_ptr = ha->rscn_in_ptr; | 2919 | vha->rscn_out_ptr = vha->rscn_in_ptr; |
2924 | break; | 2920 | break; |
2925 | } | 2921 | } |
2926 | 2922 | ||
2927 | rval = QLA_SUCCESS; | 2923 | rval = QLA_SUCCESS; |
2928 | 2924 | ||
2929 | list_for_each_entry(fcport, &pha->fcports, list) { | 2925 | list_for_each_entry(fcport, &vha->vp_fcports, list) { |
2930 | if (fcport->vp_idx != ha->vp_idx) | ||
2931 | continue; | ||
2932 | |||
2933 | if ((fcport->flags & FCF_FABRIC_DEVICE) == 0 || | 2926 | if ((fcport->flags & FCF_FABRIC_DEVICE) == 0 || |
2934 | (fcport->d_id.b24 & mask) != d_id.b24 || | 2927 | (fcport->d_id.b24 & mask) != d_id.b24 || |
2935 | fcport->port_type == FCT_BROADCAST) | 2928 | fcport->port_type == FCT_BROADCAST) |
@@ -2938,7 +2931,7 @@ qla2x00_device_resync(scsi_qla_host_t *ha) | |||
2938 | if (atomic_read(&fcport->state) == FCS_ONLINE) { | 2931 | if (atomic_read(&fcport->state) == FCS_ONLINE) { |
2939 | if (format != 3 || | 2932 | if (format != 3 || |
2940 | fcport->port_type != FCT_INITIATOR) { | 2933 | fcport->port_type != FCT_INITIATOR) { |
2941 | qla2x00_mark_device_lost(ha, fcport, | 2934 | qla2x00_mark_device_lost(vha, fcport, |
2942 | 0, 0); | 2935 | 0, 0); |
2943 | } | 2936 | } |
2944 | } | 2937 | } |
@@ -2965,30 +2958,31 @@ qla2x00_device_resync(scsi_qla_host_t *ha) | |||
2965 | * Kernel context. | 2958 | * Kernel context. |
2966 | */ | 2959 | */ |
2967 | static int | 2960 | static int |
2968 | qla2x00_fabric_dev_login(scsi_qla_host_t *ha, fc_port_t *fcport, | 2961 | qla2x00_fabric_dev_login(scsi_qla_host_t *vha, fc_port_t *fcport, |
2969 | uint16_t *next_loopid) | 2962 | uint16_t *next_loopid) |
2970 | { | 2963 | { |
2971 | int rval; | 2964 | int rval; |
2972 | int retry; | 2965 | int retry; |
2973 | uint8_t opts; | 2966 | uint8_t opts; |
2967 | struct qla_hw_data *ha = vha->hw; | ||
2974 | 2968 | ||
2975 | rval = QLA_SUCCESS; | 2969 | rval = QLA_SUCCESS; |
2976 | retry = 0; | 2970 | retry = 0; |
2977 | 2971 | ||
2978 | rval = qla2x00_fabric_login(ha, fcport, next_loopid); | 2972 | rval = qla2x00_fabric_login(vha, fcport, next_loopid); |
2979 | if (rval == QLA_SUCCESS) { | 2973 | if (rval == QLA_SUCCESS) { |
2980 | /* Send an ADISC to tape devices.*/ | 2974 | /* Send an ADISC to tape devices.*/ |
2981 | opts = 0; | 2975 | opts = 0; |
2982 | if (fcport->flags & FCF_TAPE_PRESENT) | 2976 | if (fcport->flags & FCF_TAPE_PRESENT) |
2983 | opts |= BIT_1; | 2977 | opts |= BIT_1; |
2984 | rval = qla2x00_get_port_database(ha, fcport, opts); | 2978 | rval = qla2x00_get_port_database(vha, fcport, opts); |
2985 | if (rval != QLA_SUCCESS) { | 2979 | if (rval != QLA_SUCCESS) { |
2986 | ha->isp_ops->fabric_logout(ha, fcport->loop_id, | 2980 | ha->isp_ops->fabric_logout(vha, fcport->loop_id, |
2987 | fcport->d_id.b.domain, fcport->d_id.b.area, | 2981 | fcport->d_id.b.domain, fcport->d_id.b.area, |
2988 | fcport->d_id.b.al_pa); | 2982 | fcport->d_id.b.al_pa); |
2989 | qla2x00_mark_device_lost(ha, fcport, 1, 0); | 2983 | qla2x00_mark_device_lost(vha, fcport, 1, 0); |
2990 | } else { | 2984 | } else { |
2991 | qla2x00_update_fcport(ha, fcport); | 2985 | qla2x00_update_fcport(vha, fcport); |
2992 | } | 2986 | } |
2993 | } | 2987 | } |
2994 | 2988 | ||
@@ -3010,13 +3004,14 @@ qla2x00_fabric_dev_login(scsi_qla_host_t *ha, fc_port_t *fcport, | |||
3010 | * 3 - Fatal error | 3004 | * 3 - Fatal error |
3011 | */ | 3005 | */ |
3012 | int | 3006 | int |
3013 | qla2x00_fabric_login(scsi_qla_host_t *ha, fc_port_t *fcport, | 3007 | qla2x00_fabric_login(scsi_qla_host_t *vha, fc_port_t *fcport, |
3014 | uint16_t *next_loopid) | 3008 | uint16_t *next_loopid) |
3015 | { | 3009 | { |
3016 | int rval; | 3010 | int rval; |
3017 | int retry; | 3011 | int retry; |
3018 | uint16_t tmp_loopid; | 3012 | uint16_t tmp_loopid; |
3019 | uint16_t mb[MAILBOX_REGISTER_COUNT]; | 3013 | uint16_t mb[MAILBOX_REGISTER_COUNT]; |
3014 | struct qla_hw_data *ha = vha->hw; | ||
3020 | 3015 | ||
3021 | retry = 0; | 3016 | retry = 0; |
3022 | tmp_loopid = 0; | 3017 | tmp_loopid = 0; |
@@ -3024,11 +3019,11 @@ qla2x00_fabric_login(scsi_qla_host_t *ha, fc_port_t *fcport, | |||
3024 | for (;;) { | 3019 | for (;;) { |
3025 | DEBUG(printk("scsi(%ld): Trying Fabric Login w/loop id 0x%04x " | 3020 | DEBUG(printk("scsi(%ld): Trying Fabric Login w/loop id 0x%04x " |
3026 | "for port %02x%02x%02x.\n", | 3021 | "for port %02x%02x%02x.\n", |
3027 | ha->host_no, fcport->loop_id, fcport->d_id.b.domain, | 3022 | vha->host_no, fcport->loop_id, fcport->d_id.b.domain, |
3028 | fcport->d_id.b.area, fcport->d_id.b.al_pa)); | 3023 | fcport->d_id.b.area, fcport->d_id.b.al_pa)); |
3029 | 3024 | ||
3030 | /* Login fcport on switch. */ | 3025 | /* Login fcport on switch. */ |
3031 | ha->isp_ops->fabric_login(ha, fcport->loop_id, | 3026 | ha->isp_ops->fabric_login(vha, fcport->loop_id, |
3032 | fcport->d_id.b.domain, fcport->d_id.b.area, | 3027 | fcport->d_id.b.domain, fcport->d_id.b.area, |
3033 | fcport->d_id.b.al_pa, mb, BIT_0); | 3028 | fcport->d_id.b.al_pa, mb, BIT_0); |
3034 | if (mb[0] == MBS_PORT_ID_USED) { | 3029 | if (mb[0] == MBS_PORT_ID_USED) { |
@@ -3084,7 +3079,7 @@ qla2x00_fabric_login(scsi_qla_host_t *ha, fc_port_t *fcport, | |||
3084 | * Loop ID already used, try next loop ID. | 3079 | * Loop ID already used, try next loop ID. |
3085 | */ | 3080 | */ |
3086 | fcport->loop_id++; | 3081 | fcport->loop_id++; |
3087 | rval = qla2x00_find_new_loop_id(ha, fcport); | 3082 | rval = qla2x00_find_new_loop_id(vha, fcport); |
3088 | if (rval != QLA_SUCCESS) { | 3083 | if (rval != QLA_SUCCESS) { |
3089 | /* Ran out of loop IDs to use */ | 3084 | /* Ran out of loop IDs to use */ |
3090 | break; | 3085 | break; |
@@ -3096,10 +3091,10 @@ qla2x00_fabric_login(scsi_qla_host_t *ha, fc_port_t *fcport, | |||
3096 | * dead. | 3091 | * dead. |
3097 | */ | 3092 | */ |
3098 | *next_loopid = fcport->loop_id; | 3093 | *next_loopid = fcport->loop_id; |
3099 | ha->isp_ops->fabric_logout(ha, fcport->loop_id, | 3094 | ha->isp_ops->fabric_logout(vha, fcport->loop_id, |
3100 | fcport->d_id.b.domain, fcport->d_id.b.area, | 3095 | fcport->d_id.b.domain, fcport->d_id.b.area, |
3101 | fcport->d_id.b.al_pa); | 3096 | fcport->d_id.b.al_pa); |
3102 | qla2x00_mark_device_lost(ha, fcport, 1, 0); | 3097 | qla2x00_mark_device_lost(vha, fcport, 1, 0); |
3103 | 3098 | ||
3104 | rval = 1; | 3099 | rval = 1; |
3105 | break; | 3100 | break; |
@@ -3109,12 +3104,12 @@ qla2x00_fabric_login(scsi_qla_host_t *ha, fc_port_t *fcport, | |||
3109 | */ | 3104 | */ |
3110 | DEBUG2(printk("%s(%ld): failed=%x port_id=%02x%02x%02x " | 3105 | DEBUG2(printk("%s(%ld): failed=%x port_id=%02x%02x%02x " |
3111 | "loop_id=%x jiffies=%lx.\n", | 3106 | "loop_id=%x jiffies=%lx.\n", |
3112 | __func__, ha->host_no, mb[0], | 3107 | __func__, vha->host_no, mb[0], |
3113 | fcport->d_id.b.domain, fcport->d_id.b.area, | 3108 | fcport->d_id.b.domain, fcport->d_id.b.area, |
3114 | fcport->d_id.b.al_pa, fcport->loop_id, jiffies)); | 3109 | fcport->d_id.b.al_pa, fcport->loop_id, jiffies)); |
3115 | 3110 | ||
3116 | *next_loopid = fcport->loop_id; | 3111 | *next_loopid = fcport->loop_id; |
3117 | ha->isp_ops->fabric_logout(ha, fcport->loop_id, | 3112 | ha->isp_ops->fabric_logout(vha, fcport->loop_id, |
3118 | fcport->d_id.b.domain, fcport->d_id.b.area, | 3113 | fcport->d_id.b.domain, fcport->d_id.b.area, |
3119 | fcport->d_id.b.al_pa); | 3114 | fcport->d_id.b.al_pa); |
3120 | fcport->loop_id = FC_NO_LOOP_ID; | 3115 | fcport->loop_id = FC_NO_LOOP_ID; |
@@ -3142,13 +3137,13 @@ qla2x00_fabric_login(scsi_qla_host_t *ha, fc_port_t *fcport, | |||
3142 | * 3 - Fatal error | 3137 | * 3 - Fatal error |
3143 | */ | 3138 | */ |
3144 | int | 3139 | int |
3145 | qla2x00_local_device_login(scsi_qla_host_t *ha, fc_port_t *fcport) | 3140 | qla2x00_local_device_login(scsi_qla_host_t *vha, fc_port_t *fcport) |
3146 | { | 3141 | { |
3147 | int rval; | 3142 | int rval; |
3148 | uint16_t mb[MAILBOX_REGISTER_COUNT]; | 3143 | uint16_t mb[MAILBOX_REGISTER_COUNT]; |
3149 | 3144 | ||
3150 | memset(mb, 0, sizeof(mb)); | 3145 | memset(mb, 0, sizeof(mb)); |
3151 | rval = qla2x00_login_local_device(ha, fcport, mb, BIT_0); | 3146 | rval = qla2x00_login_local_device(vha, fcport, mb, BIT_0); |
3152 | if (rval == QLA_SUCCESS) { | 3147 | if (rval == QLA_SUCCESS) { |
3153 | /* Interrogate mailbox registers for any errors */ | 3148 | /* Interrogate mailbox registers for any errors */ |
3154 | if (mb[0] == MBS_COMMAND_ERROR) | 3149 | if (mb[0] == MBS_COMMAND_ERROR) |
@@ -3172,57 +3167,55 @@ qla2x00_local_device_login(scsi_qla_host_t *ha, fc_port_t *fcport) | |||
3172 | * 0 = success | 3167 | * 0 = success |
3173 | */ | 3168 | */ |
3174 | int | 3169 | int |
3175 | qla2x00_loop_resync(scsi_qla_host_t *ha) | 3170 | qla2x00_loop_resync(scsi_qla_host_t *vha) |
3176 | { | 3171 | { |
3177 | int rval; | 3172 | int rval; |
3178 | uint32_t wait_time; | 3173 | uint32_t wait_time; |
3179 | 3174 | ||
3180 | rval = QLA_SUCCESS; | 3175 | rval = QLA_SUCCESS; |
3181 | 3176 | ||
3182 | atomic_set(&ha->loop_state, LOOP_UPDATE); | 3177 | atomic_set(&vha->loop_state, LOOP_UPDATE); |
3183 | clear_bit(ISP_ABORT_RETRY, &ha->dpc_flags); | 3178 | clear_bit(ISP_ABORT_RETRY, &vha->dpc_flags); |
3184 | if (ha->flags.online) { | 3179 | if (vha->flags.online) { |
3185 | if (!(rval = qla2x00_fw_ready(ha))) { | 3180 | if (!(rval = qla2x00_fw_ready(vha))) { |
3186 | /* Wait at most MAX_TARGET RSCNs for a stable link. */ | 3181 | /* Wait at most MAX_TARGET RSCNs for a stable link. */ |
3187 | wait_time = 256; | 3182 | wait_time = 256; |
3188 | do { | 3183 | do { |
3189 | atomic_set(&ha->loop_state, LOOP_UPDATE); | 3184 | atomic_set(&vha->loop_state, LOOP_UPDATE); |
3190 | 3185 | ||
3191 | /* Issue a marker after FW becomes ready. */ | 3186 | /* Issue a marker after FW becomes ready. */ |
3192 | qla2x00_marker(ha, 0, 0, MK_SYNC_ALL); | 3187 | qla2x00_marker(vha, 0, 0, MK_SYNC_ALL); |
3193 | ha->marker_needed = 0; | 3188 | vha->marker_needed = 0; |
3194 | 3189 | ||
3195 | /* Remap devices on Loop. */ | 3190 | /* Remap devices on Loop. */ |
3196 | clear_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags); | 3191 | clear_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); |
3197 | 3192 | ||
3198 | qla2x00_configure_loop(ha); | 3193 | qla2x00_configure_loop(vha); |
3199 | wait_time--; | 3194 | wait_time--; |
3200 | } while (!atomic_read(&ha->loop_down_timer) && | 3195 | } while (!atomic_read(&vha->loop_down_timer) && |
3201 | !(test_bit(ISP_ABORT_NEEDED, &ha->dpc_flags)) && | 3196 | !(test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags)) |
3202 | wait_time && | 3197 | && wait_time && (test_bit(LOOP_RESYNC_NEEDED, |
3203 | (test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags))); | 3198 | &vha->dpc_flags))); |
3204 | } | 3199 | } |
3205 | } | 3200 | } |
3206 | 3201 | ||
3207 | if (test_bit(ISP_ABORT_NEEDED, &ha->dpc_flags)) { | 3202 | if (test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags)) |
3208 | return (QLA_FUNCTION_FAILED); | 3203 | return (QLA_FUNCTION_FAILED); |
3209 | } | ||
3210 | 3204 | ||
3211 | if (rval) { | 3205 | if (rval) |
3212 | DEBUG2_3(printk("%s(): **** FAILED ****\n", __func__)); | 3206 | DEBUG2_3(printk("%s(): **** FAILED ****\n", __func__)); |
3213 | } | ||
3214 | 3207 | ||
3215 | return (rval); | 3208 | return (rval); |
3216 | } | 3209 | } |
3217 | 3210 | ||
3218 | void | 3211 | void |
3219 | qla2x00_update_fcports(scsi_qla_host_t *ha) | 3212 | qla2x00_update_fcports(scsi_qla_host_t *vha) |
3220 | { | 3213 | { |
3221 | fc_port_t *fcport; | 3214 | fc_port_t *fcport; |
3222 | 3215 | ||
3223 | /* Go with deferred removal of rport references. */ | 3216 | /* Go with deferred removal of rport references. */ |
3224 | list_for_each_entry(fcport, &ha->fcports, list) | 3217 | list_for_each_entry(fcport, &vha->vp_fcports, list) |
3225 | if (fcport->drport && | 3218 | if (fcport && fcport->drport && |
3226 | atomic_read(&fcport->state) != FCS_UNCONFIGURED) | 3219 | atomic_read(&fcport->state) != FCS_UNCONFIGURED) |
3227 | qla2x00_rport_del(fcport); | 3220 | qla2x00_rport_del(fcport); |
3228 | } | 3221 | } |
@@ -3238,63 +3231,64 @@ qla2x00_update_fcports(scsi_qla_host_t *ha) | |||
3238 | * 0 = success | 3231 | * 0 = success |
3239 | */ | 3232 | */ |
3240 | int | 3233 | int |
3241 | qla2x00_abort_isp(scsi_qla_host_t *ha) | 3234 | qla2x00_abort_isp(scsi_qla_host_t *vha) |
3242 | { | 3235 | { |
3243 | int rval; | 3236 | int rval; |
3244 | uint8_t status = 0; | 3237 | uint8_t status = 0; |
3245 | scsi_qla_host_t *vha; | 3238 | struct qla_hw_data *ha = vha->hw; |
3239 | struct scsi_qla_host *vp; | ||
3246 | 3240 | ||
3247 | if (ha->flags.online) { | 3241 | if (vha->flags.online) { |
3248 | ha->flags.online = 0; | 3242 | vha->flags.online = 0; |
3249 | clear_bit(ISP_ABORT_NEEDED, &ha->dpc_flags); | 3243 | clear_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); |
3250 | ha->qla_stats.total_isp_aborts++; | 3244 | ha->qla_stats.total_isp_aborts++; |
3251 | 3245 | ||
3252 | qla_printk(KERN_INFO, ha, | 3246 | qla_printk(KERN_INFO, ha, |
3253 | "Performing ISP error recovery - ha= %p.\n", ha); | 3247 | "Performing ISP error recovery - ha= %p.\n", ha); |
3254 | ha->isp_ops->reset_chip(ha); | 3248 | ha->isp_ops->reset_chip(vha); |
3255 | 3249 | ||
3256 | atomic_set(&ha->loop_down_timer, LOOP_DOWN_TIME); | 3250 | atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME); |
3257 | if (atomic_read(&ha->loop_state) != LOOP_DOWN) { | 3251 | if (atomic_read(&vha->loop_state) != LOOP_DOWN) { |
3258 | atomic_set(&ha->loop_state, LOOP_DOWN); | 3252 | atomic_set(&vha->loop_state, LOOP_DOWN); |
3259 | qla2x00_mark_all_devices_lost(ha, 0); | 3253 | qla2x00_mark_all_devices_lost(vha, 0); |
3260 | list_for_each_entry(vha, &ha->vp_list, vp_list) | 3254 | list_for_each_entry(vp, &ha->vp_list, list) |
3261 | qla2x00_mark_all_devices_lost(vha, 0); | 3255 | qla2x00_mark_all_devices_lost(vp, 0); |
3262 | } else { | 3256 | } else { |
3263 | if (!atomic_read(&ha->loop_down_timer)) | 3257 | if (!atomic_read(&vha->loop_down_timer)) |
3264 | atomic_set(&ha->loop_down_timer, | 3258 | atomic_set(&vha->loop_down_timer, |
3265 | LOOP_DOWN_TIME); | 3259 | LOOP_DOWN_TIME); |
3266 | } | 3260 | } |
3267 | 3261 | ||
3268 | /* Requeue all commands in outstanding command list. */ | 3262 | /* Requeue all commands in outstanding command list. */ |
3269 | qla2x00_abort_all_cmds(ha, DID_RESET << 16); | 3263 | qla2x00_abort_all_cmds(vha, DID_RESET << 16); |
3270 | 3264 | ||
3271 | ha->isp_ops->get_flash_version(ha, ha->request_ring); | 3265 | ha->isp_ops->get_flash_version(vha, ha->req->ring); |
3272 | 3266 | ||
3273 | ha->isp_ops->nvram_config(ha); | 3267 | ha->isp_ops->nvram_config(vha); |
3274 | 3268 | ||
3275 | if (!qla2x00_restart_isp(ha)) { | 3269 | if (!qla2x00_restart_isp(vha)) { |
3276 | clear_bit(RESET_MARKER_NEEDED, &ha->dpc_flags); | 3270 | clear_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); |
3277 | 3271 | ||
3278 | if (!atomic_read(&ha->loop_down_timer)) { | 3272 | if (!atomic_read(&vha->loop_down_timer)) { |
3279 | /* | 3273 | /* |
3280 | * Issue marker command only when we are going | 3274 | * Issue marker command only when we are going |
3281 | * to start the I/O . | 3275 | * to start the I/O . |
3282 | */ | 3276 | */ |
3283 | ha->marker_needed = 1; | 3277 | vha->marker_needed = 1; |
3284 | } | 3278 | } |
3285 | 3279 | ||
3286 | ha->flags.online = 1; | 3280 | vha->flags.online = 1; |
3287 | 3281 | ||
3288 | ha->isp_ops->enable_intrs(ha); | 3282 | ha->isp_ops->enable_intrs(ha); |
3289 | 3283 | ||
3290 | ha->isp_abort_cnt = 0; | 3284 | ha->isp_abort_cnt = 0; |
3291 | clear_bit(ISP_ABORT_RETRY, &ha->dpc_flags); | 3285 | clear_bit(ISP_ABORT_RETRY, &vha->dpc_flags); |
3292 | 3286 | ||
3293 | if (ha->fce) { | 3287 | if (ha->fce) { |
3294 | ha->flags.fce_enabled = 1; | 3288 | ha->flags.fce_enabled = 1; |
3295 | memset(ha->fce, 0, | 3289 | memset(ha->fce, 0, |
3296 | fce_calc_size(ha->fce_bufs)); | 3290 | fce_calc_size(ha->fce_bufs)); |
3297 | rval = qla2x00_enable_fce_trace(ha, | 3291 | rval = qla2x00_enable_fce_trace(vha, |
3298 | ha->fce_dma, ha->fce_bufs, ha->fce_mb, | 3292 | ha->fce_dma, ha->fce_bufs, ha->fce_mb, |
3299 | &ha->fce_bufs); | 3293 | &ha->fce_bufs); |
3300 | if (rval) { | 3294 | if (rval) { |
@@ -3307,7 +3301,7 @@ qla2x00_abort_isp(scsi_qla_host_t *ha) | |||
3307 | 3301 | ||
3308 | if (ha->eft) { | 3302 | if (ha->eft) { |
3309 | memset(ha->eft, 0, EFT_SIZE); | 3303 | memset(ha->eft, 0, EFT_SIZE); |
3310 | rval = qla2x00_enable_eft_trace(ha, | 3304 | rval = qla2x00_enable_eft_trace(vha, |
3311 | ha->eft_dma, EFT_NUM_BUFFERS); | 3305 | ha->eft_dma, EFT_NUM_BUFFERS); |
3312 | if (rval) { | 3306 | if (rval) { |
3313 | qla_printk(KERN_WARNING, ha, | 3307 | qla_printk(KERN_WARNING, ha, |
@@ -3316,8 +3310,8 @@ qla2x00_abort_isp(scsi_qla_host_t *ha) | |||
3316 | } | 3310 | } |
3317 | } | 3311 | } |
3318 | } else { /* failed the ISP abort */ | 3312 | } else { /* failed the ISP abort */ |
3319 | ha->flags.online = 1; | 3313 | vha->flags.online = 1; |
3320 | if (test_bit(ISP_ABORT_RETRY, &ha->dpc_flags)) { | 3314 | if (test_bit(ISP_ABORT_RETRY, &vha->dpc_flags)) { |
3321 | if (ha->isp_abort_cnt == 0) { | 3315 | if (ha->isp_abort_cnt == 0) { |
3322 | qla_printk(KERN_WARNING, ha, | 3316 | qla_printk(KERN_WARNING, ha, |
3323 | "ISP error recovery failed - " | 3317 | "ISP error recovery failed - " |
@@ -3326,37 +3320,41 @@ qla2x00_abort_isp(scsi_qla_host_t *ha) | |||
3326 | * The next call disables the board | 3320 | * The next call disables the board |
3327 | * completely. | 3321 | * completely. |
3328 | */ | 3322 | */ |
3329 | ha->isp_ops->reset_adapter(ha); | 3323 | ha->isp_ops->reset_adapter(vha); |
3330 | ha->flags.online = 0; | 3324 | vha->flags.online = 0; |
3331 | clear_bit(ISP_ABORT_RETRY, | 3325 | clear_bit(ISP_ABORT_RETRY, |
3332 | &ha->dpc_flags); | 3326 | &vha->dpc_flags); |
3333 | status = 0; | 3327 | status = 0; |
3334 | } else { /* schedule another ISP abort */ | 3328 | } else { /* schedule another ISP abort */ |
3335 | ha->isp_abort_cnt--; | 3329 | ha->isp_abort_cnt--; |
3336 | DEBUG(printk("qla%ld: ISP abort - " | 3330 | DEBUG(printk("qla%ld: ISP abort - " |
3337 | "retry remaining %d\n", | 3331 | "retry remaining %d\n", |
3338 | ha->host_no, ha->isp_abort_cnt)); | 3332 | vha->host_no, ha->isp_abort_cnt)); |
3339 | status = 1; | 3333 | status = 1; |
3340 | } | 3334 | } |
3341 | } else { | 3335 | } else { |
3342 | ha->isp_abort_cnt = MAX_RETRIES_OF_ISP_ABORT; | 3336 | ha->isp_abort_cnt = MAX_RETRIES_OF_ISP_ABORT; |
3343 | DEBUG(printk("qla2x00(%ld): ISP error recovery " | 3337 | DEBUG(printk("qla2x00(%ld): ISP error recovery " |
3344 | "- retrying (%d) more times\n", | 3338 | "- retrying (%d) more times\n", |
3345 | ha->host_no, ha->isp_abort_cnt)); | 3339 | vha->host_no, ha->isp_abort_cnt)); |
3346 | set_bit(ISP_ABORT_RETRY, &ha->dpc_flags); | 3340 | set_bit(ISP_ABORT_RETRY, &vha->dpc_flags); |
3347 | status = 1; | 3341 | status = 1; |
3348 | } | 3342 | } |
3349 | } | 3343 | } |
3350 | 3344 | ||
3351 | } | 3345 | } |
3352 | 3346 | ||
3353 | if (status) { | 3347 | if (!status) { |
3348 | DEBUG(printk(KERN_INFO | ||
3349 | "qla2x00_abort_isp(%ld): succeeded.\n", | ||
3350 | vha->host_no)); | ||
3351 | list_for_each_entry(vp, &ha->vp_list, list) { | ||
3352 | if (vp->vp_idx) | ||
3353 | qla2x00_vp_abort_isp(vp); | ||
3354 | } | ||
3355 | } else { | ||
3354 | qla_printk(KERN_INFO, ha, | 3356 | qla_printk(KERN_INFO, ha, |
3355 | "qla2x00_abort_isp: **** FAILED ****\n"); | 3357 | "qla2x00_abort_isp: **** FAILED ****\n"); |
3356 | } else { | ||
3357 | DEBUG(printk(KERN_INFO | ||
3358 | "qla2x00_abort_isp(%ld): exiting.\n", | ||
3359 | ha->host_no)); | ||
3360 | } | 3358 | } |
3361 | 3359 | ||
3362 | return(status); | 3360 | return(status); |
@@ -3373,42 +3371,45 @@ qla2x00_abort_isp(scsi_qla_host_t *ha) | |||
3373 | * 0 = success | 3371 | * 0 = success |
3374 | */ | 3372 | */ |
3375 | static int | 3373 | static int |
3376 | qla2x00_restart_isp(scsi_qla_host_t *ha) | 3374 | qla2x00_restart_isp(scsi_qla_host_t *vha) |
3377 | { | 3375 | { |
3378 | uint8_t status = 0; | 3376 | uint8_t status = 0; |
3379 | uint32_t wait_time; | 3377 | uint32_t wait_time; |
3378 | struct qla_hw_data *ha = vha->hw; | ||
3380 | 3379 | ||
3381 | /* If firmware needs to be loaded */ | 3380 | /* If firmware needs to be loaded */ |
3382 | if (qla2x00_isp_firmware(ha)) { | 3381 | if (qla2x00_isp_firmware(vha)) { |
3383 | ha->flags.online = 0; | 3382 | vha->flags.online = 0; |
3384 | if (!(status = ha->isp_ops->chip_diag(ha))) | 3383 | status = ha->isp_ops->chip_diag(vha); |
3385 | status = qla2x00_setup_chip(ha); | 3384 | if (!status) |
3385 | status = qla2x00_setup_chip(vha); | ||
3386 | } | 3386 | } |
3387 | 3387 | ||
3388 | if (!status && !(status = qla2x00_init_rings(ha))) { | 3388 | if (!status && !(status = qla2x00_init_rings(vha))) { |
3389 | clear_bit(RESET_MARKER_NEEDED, &ha->dpc_flags); | 3389 | clear_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); |
3390 | if (!(status = qla2x00_fw_ready(ha))) { | 3390 | status = qla2x00_fw_ready(vha); |
3391 | if (!status) { | ||
3391 | DEBUG(printk("%s(): Start configure loop, " | 3392 | DEBUG(printk("%s(): Start configure loop, " |
3392 | "status = %d\n", __func__, status)); | 3393 | "status = %d\n", __func__, status)); |
3393 | 3394 | ||
3394 | /* Issue a marker after FW becomes ready. */ | 3395 | /* Issue a marker after FW becomes ready. */ |
3395 | qla2x00_marker(ha, 0, 0, MK_SYNC_ALL); | 3396 | qla2x00_marker(vha, 0, 0, MK_SYNC_ALL); |
3396 | 3397 | ||
3397 | ha->flags.online = 1; | 3398 | vha->flags.online = 1; |
3398 | /* Wait at most MAX_TARGET RSCNs for a stable link. */ | 3399 | /* Wait at most MAX_TARGET RSCNs for a stable link. */ |
3399 | wait_time = 256; | 3400 | wait_time = 256; |
3400 | do { | 3401 | do { |
3401 | clear_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags); | 3402 | clear_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); |
3402 | qla2x00_configure_loop(ha); | 3403 | qla2x00_configure_loop(vha); |
3403 | wait_time--; | 3404 | wait_time--; |
3404 | } while (!atomic_read(&ha->loop_down_timer) && | 3405 | } while (!atomic_read(&vha->loop_down_timer) && |
3405 | !(test_bit(ISP_ABORT_NEEDED, &ha->dpc_flags)) && | 3406 | !(test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags)) |
3406 | wait_time && | 3407 | && wait_time && (test_bit(LOOP_RESYNC_NEEDED, |
3407 | (test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags))); | 3408 | &vha->dpc_flags))); |
3408 | } | 3409 | } |
3409 | 3410 | ||
3410 | /* if no cable then assume it's good */ | 3411 | /* if no cable then assume it's good */ |
3411 | if ((ha->device_flags & DFLG_NO_CABLE)) | 3412 | if ((vha->device_flags & DFLG_NO_CABLE)) |
3412 | status = 0; | 3413 | status = 0; |
3413 | 3414 | ||
3414 | DEBUG(printk("%s(): Configure loop done, status = 0x%x\n", | 3415 | DEBUG(printk("%s(): Configure loop done, status = 0x%x\n", |
@@ -3426,12 +3427,13 @@ qla2x00_restart_isp(scsi_qla_host_t *ha) | |||
3426 | * ha = adapter block pointer. | 3427 | * ha = adapter block pointer. |
3427 | */ | 3428 | */ |
3428 | void | 3429 | void |
3429 | qla2x00_reset_adapter(scsi_qla_host_t *ha) | 3430 | qla2x00_reset_adapter(scsi_qla_host_t *vha) |
3430 | { | 3431 | { |
3431 | unsigned long flags = 0; | 3432 | unsigned long flags = 0; |
3433 | struct qla_hw_data *ha = vha->hw; | ||
3432 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; | 3434 | struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; |
3433 | 3435 | ||
3434 | ha->flags.online = 0; | 3436 | vha->flags.online = 0; |
3435 | ha->isp_ops->disable_intrs(ha); | 3437 | ha->isp_ops->disable_intrs(ha); |
3436 | 3438 | ||
3437 | spin_lock_irqsave(&ha->hardware_lock, flags); | 3439 | spin_lock_irqsave(&ha->hardware_lock, flags); |
@@ -3443,12 +3445,13 @@ qla2x00_reset_adapter(scsi_qla_host_t *ha) | |||
3443 | } | 3445 | } |
3444 | 3446 | ||
3445 | void | 3447 | void |
3446 | qla24xx_reset_adapter(scsi_qla_host_t *ha) | 3448 | qla24xx_reset_adapter(scsi_qla_host_t *vha) |
3447 | { | 3449 | { |
3448 | unsigned long flags = 0; | 3450 | unsigned long flags = 0; |
3451 | struct qla_hw_data *ha = vha->hw; | ||
3449 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; | 3452 | struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; |
3450 | 3453 | ||
3451 | ha->flags.online = 0; | 3454 | vha->flags.online = 0; |
3452 | ha->isp_ops->disable_intrs(ha); | 3455 | ha->isp_ops->disable_intrs(ha); |
3453 | 3456 | ||
3454 | spin_lock_irqsave(&ha->hardware_lock, flags); | 3457 | spin_lock_irqsave(&ha->hardware_lock, flags); |
@@ -3462,9 +3465,11 @@ qla24xx_reset_adapter(scsi_qla_host_t *ha) | |||
3462 | /* On sparc systems, obtain port and node WWN from firmware | 3465 | /* On sparc systems, obtain port and node WWN from firmware |
3463 | * properties. | 3466 | * properties. |
3464 | */ | 3467 | */ |
3465 | static void qla24xx_nvram_wwn_from_ofw(scsi_qla_host_t *ha, struct nvram_24xx *nv) | 3468 | static void qla24xx_nvram_wwn_from_ofw(scsi_qla_host_t *vha, |
3469 | struct nvram_24xx *nv) | ||
3466 | { | 3470 | { |
3467 | #ifdef CONFIG_SPARC | 3471 | #ifdef CONFIG_SPARC |
3472 | struct qla_hw_data *ha = vha->hw; | ||
3468 | struct pci_dev *pdev = ha->pdev; | 3473 | struct pci_dev *pdev = ha->pdev; |
3469 | struct device_node *dp = pci_device_to_OF_node(pdev); | 3474 | struct device_node *dp = pci_device_to_OF_node(pdev); |
3470 | const u8 *val; | 3475 | const u8 *val; |
@@ -3481,7 +3486,7 @@ static void qla24xx_nvram_wwn_from_ofw(scsi_qla_host_t *ha, struct nvram_24xx *n | |||
3481 | } | 3486 | } |
3482 | 3487 | ||
3483 | int | 3488 | int |
3484 | qla24xx_nvram_config(scsi_qla_host_t *ha) | 3489 | qla24xx_nvram_config(scsi_qla_host_t *vha) |
3485 | { | 3490 | { |
3486 | int rval; | 3491 | int rval; |
3487 | struct init_cb_24xx *icb; | 3492 | struct init_cb_24xx *icb; |
@@ -3490,6 +3495,7 @@ qla24xx_nvram_config(scsi_qla_host_t *ha) | |||
3490 | uint8_t *dptr1, *dptr2; | 3495 | uint8_t *dptr1, *dptr2; |
3491 | uint32_t chksum; | 3496 | uint32_t chksum; |
3492 | uint16_t cnt; | 3497 | uint16_t cnt; |
3498 | struct qla_hw_data *ha = vha->hw; | ||
3493 | 3499 | ||
3494 | rval = QLA_SUCCESS; | 3500 | rval = QLA_SUCCESS; |
3495 | icb = (struct init_cb_24xx *)ha->init_cb; | 3501 | icb = (struct init_cb_24xx *)ha->init_cb; |
@@ -3507,12 +3513,12 @@ qla24xx_nvram_config(scsi_qla_host_t *ha) | |||
3507 | 3513 | ||
3508 | /* Get VPD data into cache */ | 3514 | /* Get VPD data into cache */ |
3509 | ha->vpd = ha->nvram + VPD_OFFSET; | 3515 | ha->vpd = ha->nvram + VPD_OFFSET; |
3510 | ha->isp_ops->read_nvram(ha, (uint8_t *)ha->vpd, | 3516 | ha->isp_ops->read_nvram(vha, (uint8_t *)ha->vpd, |
3511 | ha->nvram_base - FA_NVRAM_FUNC0_ADDR, FA_NVRAM_VPD_SIZE * 4); | 3517 | ha->nvram_base - FA_NVRAM_FUNC0_ADDR, FA_NVRAM_VPD_SIZE * 4); |
3512 | 3518 | ||
3513 | /* Get NVRAM data into cache and calculate checksum. */ | 3519 | /* Get NVRAM data into cache and calculate checksum. */ |
3514 | dptr = (uint32_t *)nv; | 3520 | dptr = (uint32_t *)nv; |
3515 | ha->isp_ops->read_nvram(ha, (uint8_t *)dptr, ha->nvram_base, | 3521 | ha->isp_ops->read_nvram(vha, (uint8_t *)dptr, ha->nvram_base, |
3516 | ha->nvram_size); | 3522 | ha->nvram_size); |
3517 | for (cnt = 0, chksum = 0; cnt < ha->nvram_size >> 2; cnt++) | 3523 | for (cnt = 0, chksum = 0; cnt < ha->nvram_size >> 2; cnt++) |
3518 | chksum += le32_to_cpu(*dptr++); | 3524 | chksum += le32_to_cpu(*dptr++); |
@@ -3557,7 +3563,7 @@ qla24xx_nvram_config(scsi_qla_host_t *ha) | |||
3557 | nv->node_name[5] = 0x1c; | 3563 | nv->node_name[5] = 0x1c; |
3558 | nv->node_name[6] = 0x55; | 3564 | nv->node_name[6] = 0x55; |
3559 | nv->node_name[7] = 0x86; | 3565 | nv->node_name[7] = 0x86; |
3560 | qla24xx_nvram_wwn_from_ofw(ha, nv); | 3566 | qla24xx_nvram_wwn_from_ofw(vha, nv); |
3561 | nv->login_retry_count = __constant_cpu_to_le16(8); | 3567 | nv->login_retry_count = __constant_cpu_to_le16(8); |
3562 | nv->interrupt_delay_timer = __constant_cpu_to_le16(0); | 3568 | nv->interrupt_delay_timer = __constant_cpu_to_le16(0); |
3563 | nv->login_timeout = __constant_cpu_to_le16(0); | 3569 | nv->login_timeout = __constant_cpu_to_le16(0); |
@@ -3577,7 +3583,7 @@ qla24xx_nvram_config(scsi_qla_host_t *ha) | |||
3577 | } | 3583 | } |
3578 | 3584 | ||
3579 | /* Reset Initialization control block */ | 3585 | /* Reset Initialization control block */ |
3580 | memset(icb, 0, sizeof(struct init_cb_24xx)); | 3586 | memset(icb, 0, ha->init_cb_size); |
3581 | 3587 | ||
3582 | /* Copy 1st segment. */ | 3588 | /* Copy 1st segment. */ |
3583 | dptr1 = (uint8_t *)icb; | 3589 | dptr1 = (uint8_t *)icb; |
@@ -3600,7 +3606,7 @@ qla24xx_nvram_config(scsi_qla_host_t *ha) | |||
3600 | /* | 3606 | /* |
3601 | * Setup driver NVRAM options. | 3607 | * Setup driver NVRAM options. |
3602 | */ | 3608 | */ |
3603 | qla2x00_set_model_info(ha, nv->model_name, sizeof(nv->model_name), | 3609 | qla2x00_set_model_info(vha, nv->model_name, sizeof(nv->model_name), |
3604 | "QLA2462"); | 3610 | "QLA2462"); |
3605 | 3611 | ||
3606 | /* Use alternate WWN? */ | 3612 | /* Use alternate WWN? */ |
@@ -3639,8 +3645,8 @@ qla24xx_nvram_config(scsi_qla_host_t *ha) | |||
3639 | ha->serial0 = icb->port_name[5]; | 3645 | ha->serial0 = icb->port_name[5]; |
3640 | ha->serial1 = icb->port_name[6]; | 3646 | ha->serial1 = icb->port_name[6]; |
3641 | ha->serial2 = icb->port_name[7]; | 3647 | ha->serial2 = icb->port_name[7]; |
3642 | ha->node_name = icb->node_name; | 3648 | memcpy(vha->node_name, icb->node_name, WWN_SIZE); |
3643 | ha->port_name = icb->port_name; | 3649 | memcpy(vha->port_name, icb->port_name, WWN_SIZE); |
3644 | 3650 | ||
3645 | icb->execution_throttle = __constant_cpu_to_le16(0xFFFF); | 3651 | icb->execution_throttle = __constant_cpu_to_le16(0xFFFF); |
3646 | 3652 | ||
@@ -3695,7 +3701,7 @@ qla24xx_nvram_config(scsi_qla_host_t *ha) | |||
3695 | ha->login_retry_count = ql2xloginretrycount; | 3701 | ha->login_retry_count = ql2xloginretrycount; |
3696 | 3702 | ||
3697 | /* Enable ZIO. */ | 3703 | /* Enable ZIO. */ |
3698 | if (!ha->flags.init_done) { | 3704 | if (!vha->flags.init_done) { |
3699 | ha->zio_mode = le32_to_cpu(icb->firmware_options_2) & | 3705 | ha->zio_mode = le32_to_cpu(icb->firmware_options_2) & |
3700 | (BIT_3 | BIT_2 | BIT_1 | BIT_0); | 3706 | (BIT_3 | BIT_2 | BIT_1 | BIT_0); |
3701 | ha->zio_timer = le16_to_cpu(icb->interrupt_delay_timer) ? | 3707 | ha->zio_timer = le16_to_cpu(icb->interrupt_delay_timer) ? |
@@ -3703,12 +3709,12 @@ qla24xx_nvram_config(scsi_qla_host_t *ha) | |||
3703 | } | 3709 | } |
3704 | icb->firmware_options_2 &= __constant_cpu_to_le32( | 3710 | icb->firmware_options_2 &= __constant_cpu_to_le32( |
3705 | ~(BIT_3 | BIT_2 | BIT_1 | BIT_0)); | 3711 | ~(BIT_3 | BIT_2 | BIT_1 | BIT_0)); |
3706 | ha->flags.process_response_queue = 0; | 3712 | vha->flags.process_response_queue = 0; |
3707 | if (ha->zio_mode != QLA_ZIO_DISABLED) { | 3713 | if (ha->zio_mode != QLA_ZIO_DISABLED) { |
3708 | ha->zio_mode = QLA_ZIO_MODE_6; | 3714 | ha->zio_mode = QLA_ZIO_MODE_6; |
3709 | 3715 | ||
3710 | DEBUG2(printk("scsi(%ld): ZIO mode %d enabled; timer delay " | 3716 | DEBUG2(printk("scsi(%ld): ZIO mode %d enabled; timer delay " |
3711 | "(%d us).\n", ha->host_no, ha->zio_mode, | 3717 | "(%d us).\n", vha->host_no, ha->zio_mode, |
3712 | ha->zio_timer * 100)); | 3718 | ha->zio_timer * 100)); |
3713 | qla_printk(KERN_INFO, ha, | 3719 | qla_printk(KERN_INFO, ha, |
3714 | "ZIO mode %d enabled; timer delay (%d us).\n", | 3720 | "ZIO mode %d enabled; timer delay (%d us).\n", |
@@ -3717,18 +3723,18 @@ qla24xx_nvram_config(scsi_qla_host_t *ha) | |||
3717 | icb->firmware_options_2 |= cpu_to_le32( | 3723 | icb->firmware_options_2 |= cpu_to_le32( |
3718 | (uint32_t)ha->zio_mode); | 3724 | (uint32_t)ha->zio_mode); |
3719 | icb->interrupt_delay_timer = cpu_to_le16(ha->zio_timer); | 3725 | icb->interrupt_delay_timer = cpu_to_le16(ha->zio_timer); |
3720 | ha->flags.process_response_queue = 1; | 3726 | vha->flags.process_response_queue = 1; |
3721 | } | 3727 | } |
3722 | 3728 | ||
3723 | if (rval) { | 3729 | if (rval) { |
3724 | DEBUG2_3(printk(KERN_WARNING | 3730 | DEBUG2_3(printk(KERN_WARNING |
3725 | "scsi(%ld): NVRAM configuration failed!\n", ha->host_no)); | 3731 | "scsi(%ld): NVRAM configuration failed!\n", vha->host_no)); |
3726 | } | 3732 | } |
3727 | return (rval); | 3733 | return (rval); |
3728 | } | 3734 | } |
3729 | 3735 | ||
3730 | static int | 3736 | static int |
3731 | qla24xx_load_risc_flash(scsi_qla_host_t *ha, uint32_t *srisc_addr) | 3737 | qla24xx_load_risc_flash(scsi_qla_host_t *vha, uint32_t *srisc_addr) |
3732 | { | 3738 | { |
3733 | int rval; | 3739 | int rval; |
3734 | int segments, fragment; | 3740 | int segments, fragment; |
@@ -3737,16 +3743,16 @@ qla24xx_load_risc_flash(scsi_qla_host_t *ha, uint32_t *srisc_addr) | |||
3737 | uint32_t risc_addr; | 3743 | uint32_t risc_addr; |
3738 | uint32_t risc_size; | 3744 | uint32_t risc_size; |
3739 | uint32_t i; | 3745 | uint32_t i; |
3740 | 3746 | struct qla_hw_data *ha = vha->hw; | |
3741 | rval = QLA_SUCCESS; | 3747 | rval = QLA_SUCCESS; |
3742 | 3748 | ||
3743 | segments = FA_RISC_CODE_SEGMENTS; | 3749 | segments = FA_RISC_CODE_SEGMENTS; |
3744 | faddr = ha->flt_region_fw; | 3750 | faddr = ha->flt_region_fw; |
3745 | dcode = (uint32_t *)ha->request_ring; | 3751 | dcode = (uint32_t *)ha->req->ring; |
3746 | *srisc_addr = 0; | 3752 | *srisc_addr = 0; |
3747 | 3753 | ||
3748 | /* Validate firmware image by checking version. */ | 3754 | /* Validate firmware image by checking version. */ |
3749 | qla24xx_read_flash_data(ha, dcode, faddr + 4, 4); | 3755 | qla24xx_read_flash_data(vha, dcode, faddr + 4, 4); |
3750 | for (i = 0; i < 4; i++) | 3756 | for (i = 0; i < 4; i++) |
3751 | dcode[i] = be32_to_cpu(dcode[i]); | 3757 | dcode[i] = be32_to_cpu(dcode[i]); |
3752 | if ((dcode[0] == 0xffffffff && dcode[1] == 0xffffffff && | 3758 | if ((dcode[0] == 0xffffffff && dcode[1] == 0xffffffff && |
@@ -3764,7 +3770,7 @@ qla24xx_load_risc_flash(scsi_qla_host_t *ha, uint32_t *srisc_addr) | |||
3764 | 3770 | ||
3765 | while (segments && rval == QLA_SUCCESS) { | 3771 | while (segments && rval == QLA_SUCCESS) { |
3766 | /* Read segment's load information. */ | 3772 | /* Read segment's load information. */ |
3767 | qla24xx_read_flash_data(ha, dcode, faddr, 4); | 3773 | qla24xx_read_flash_data(vha, dcode, faddr, 4); |
3768 | 3774 | ||
3769 | risc_addr = be32_to_cpu(dcode[2]); | 3775 | risc_addr = be32_to_cpu(dcode[2]); |
3770 | *srisc_addr = *srisc_addr == 0 ? risc_addr : *srisc_addr; | 3776 | *srisc_addr = *srisc_addr == 0 ? risc_addr : *srisc_addr; |
@@ -3778,17 +3784,17 @@ qla24xx_load_risc_flash(scsi_qla_host_t *ha, uint32_t *srisc_addr) | |||
3778 | 3784 | ||
3779 | DEBUG7(printk("scsi(%ld): Loading risc segment@ risc " | 3785 | DEBUG7(printk("scsi(%ld): Loading risc segment@ risc " |
3780 | "addr %x, number of dwords 0x%x, offset 0x%x.\n", | 3786 | "addr %x, number of dwords 0x%x, offset 0x%x.\n", |
3781 | ha->host_no, risc_addr, dlen, faddr)); | 3787 | vha->host_no, risc_addr, dlen, faddr)); |
3782 | 3788 | ||
3783 | qla24xx_read_flash_data(ha, dcode, faddr, dlen); | 3789 | qla24xx_read_flash_data(vha, dcode, faddr, dlen); |
3784 | for (i = 0; i < dlen; i++) | 3790 | for (i = 0; i < dlen; i++) |
3785 | dcode[i] = swab32(dcode[i]); | 3791 | dcode[i] = swab32(dcode[i]); |
3786 | 3792 | ||
3787 | rval = qla2x00_load_ram(ha, ha->request_dma, risc_addr, | 3793 | rval = qla2x00_load_ram(vha, ha->req->dma, risc_addr, |
3788 | dlen); | 3794 | dlen); |
3789 | if (rval) { | 3795 | if (rval) { |
3790 | DEBUG(printk("scsi(%ld):[ERROR] Failed to load " | 3796 | DEBUG(printk("scsi(%ld):[ERROR] Failed to load " |
3791 | "segment %d of firmware\n", ha->host_no, | 3797 | "segment %d of firmware\n", vha->host_no, |
3792 | fragment)); | 3798 | fragment)); |
3793 | qla_printk(KERN_WARNING, ha, | 3799 | qla_printk(KERN_WARNING, ha, |
3794 | "[ERROR] Failed to load segment %d of " | 3800 | "[ERROR] Failed to load segment %d of " |
@@ -3812,16 +3818,17 @@ qla24xx_load_risc_flash(scsi_qla_host_t *ha, uint32_t *srisc_addr) | |||
3812 | #define QLA_FW_URL "ftp://ftp.qlogic.com/outgoing/linux/firmware/" | 3818 | #define QLA_FW_URL "ftp://ftp.qlogic.com/outgoing/linux/firmware/" |
3813 | 3819 | ||
3814 | int | 3820 | int |
3815 | qla2x00_load_risc(scsi_qla_host_t *ha, uint32_t *srisc_addr) | 3821 | qla2x00_load_risc(scsi_qla_host_t *vha, uint32_t *srisc_addr) |
3816 | { | 3822 | { |
3817 | int rval; | 3823 | int rval; |
3818 | int i, fragment; | 3824 | int i, fragment; |
3819 | uint16_t *wcode, *fwcode; | 3825 | uint16_t *wcode, *fwcode; |
3820 | uint32_t risc_addr, risc_size, fwclen, wlen, *seg; | 3826 | uint32_t risc_addr, risc_size, fwclen, wlen, *seg; |
3821 | struct fw_blob *blob; | 3827 | struct fw_blob *blob; |
3828 | struct qla_hw_data *ha = vha->hw; | ||
3822 | 3829 | ||
3823 | /* Load firmware blob. */ | 3830 | /* Load firmware blob. */ |
3824 | blob = qla2x00_request_firmware(ha); | 3831 | blob = qla2x00_request_firmware(vha); |
3825 | if (!blob) { | 3832 | if (!blob) { |
3826 | qla_printk(KERN_ERR, ha, "Firmware image unavailable.\n"); | 3833 | qla_printk(KERN_ERR, ha, "Firmware image unavailable.\n"); |
3827 | qla_printk(KERN_ERR, ha, "Firmware images can be retrieved " | 3834 | qla_printk(KERN_ERR, ha, "Firmware images can be retrieved " |
@@ -3831,7 +3838,7 @@ qla2x00_load_risc(scsi_qla_host_t *ha, uint32_t *srisc_addr) | |||
3831 | 3838 | ||
3832 | rval = QLA_SUCCESS; | 3839 | rval = QLA_SUCCESS; |
3833 | 3840 | ||
3834 | wcode = (uint16_t *)ha->request_ring; | 3841 | wcode = (uint16_t *)ha->req->ring; |
3835 | *srisc_addr = 0; | 3842 | *srisc_addr = 0; |
3836 | fwcode = (uint16_t *)blob->fw->data; | 3843 | fwcode = (uint16_t *)blob->fw->data; |
3837 | fwclen = 0; | 3844 | fwclen = 0; |
@@ -3878,17 +3885,17 @@ qla2x00_load_risc(scsi_qla_host_t *ha, uint32_t *srisc_addr) | |||
3878 | wlen = risc_size; | 3885 | wlen = risc_size; |
3879 | 3886 | ||
3880 | DEBUG7(printk("scsi(%ld): Loading risc segment@ risc " | 3887 | DEBUG7(printk("scsi(%ld): Loading risc segment@ risc " |
3881 | "addr %x, number of words 0x%x.\n", ha->host_no, | 3888 | "addr %x, number of words 0x%x.\n", vha->host_no, |
3882 | risc_addr, wlen)); | 3889 | risc_addr, wlen)); |
3883 | 3890 | ||
3884 | for (i = 0; i < wlen; i++) | 3891 | for (i = 0; i < wlen; i++) |
3885 | wcode[i] = swab16(fwcode[i]); | 3892 | wcode[i] = swab16(fwcode[i]); |
3886 | 3893 | ||
3887 | rval = qla2x00_load_ram(ha, ha->request_dma, risc_addr, | 3894 | rval = qla2x00_load_ram(vha, ha->req->dma, risc_addr, |
3888 | wlen); | 3895 | wlen); |
3889 | if (rval) { | 3896 | if (rval) { |
3890 | DEBUG(printk("scsi(%ld):[ERROR] Failed to load " | 3897 | DEBUG(printk("scsi(%ld):[ERROR] Failed to load " |
3891 | "segment %d of firmware\n", ha->host_no, | 3898 | "segment %d of firmware\n", vha->host_no, |
3892 | fragment)); | 3899 | fragment)); |
3893 | qla_printk(KERN_WARNING, ha, | 3900 | qla_printk(KERN_WARNING, ha, |
3894 | "[ERROR] Failed to load segment %d of " | 3901 | "[ERROR] Failed to load segment %d of " |
@@ -3912,7 +3919,7 @@ fail_fw_integrity: | |||
3912 | } | 3919 | } |
3913 | 3920 | ||
3914 | int | 3921 | int |
3915 | qla24xx_load_risc(scsi_qla_host_t *ha, uint32_t *srisc_addr) | 3922 | qla24xx_load_risc(scsi_qla_host_t *vha, uint32_t *srisc_addr) |
3916 | { | 3923 | { |
3917 | int rval; | 3924 | int rval; |
3918 | int segments, fragment; | 3925 | int segments, fragment; |
@@ -3922,9 +3929,10 @@ qla24xx_load_risc(scsi_qla_host_t *ha, uint32_t *srisc_addr) | |||
3922 | uint32_t i; | 3929 | uint32_t i; |
3923 | struct fw_blob *blob; | 3930 | struct fw_blob *blob; |
3924 | uint32_t *fwcode, fwclen; | 3931 | uint32_t *fwcode, fwclen; |
3932 | struct qla_hw_data *ha = vha->hw; | ||
3925 | 3933 | ||
3926 | /* Load firmware blob. */ | 3934 | /* Load firmware blob. */ |
3927 | blob = qla2x00_request_firmware(ha); | 3935 | blob = qla2x00_request_firmware(vha); |
3928 | if (!blob) { | 3936 | if (!blob) { |
3929 | qla_printk(KERN_ERR, ha, "Firmware image unavailable.\n"); | 3937 | qla_printk(KERN_ERR, ha, "Firmware image unavailable.\n"); |
3930 | qla_printk(KERN_ERR, ha, "Firmware images can be retrieved " | 3938 | qla_printk(KERN_ERR, ha, "Firmware images can be retrieved " |
@@ -3933,13 +3941,13 @@ qla24xx_load_risc(scsi_qla_host_t *ha, uint32_t *srisc_addr) | |||
3933 | /* Try to load RISC code from flash. */ | 3941 | /* Try to load RISC code from flash. */ |
3934 | qla_printk(KERN_ERR, ha, "Attempting to load (potentially " | 3942 | qla_printk(KERN_ERR, ha, "Attempting to load (potentially " |
3935 | "outdated) firmware from flash.\n"); | 3943 | "outdated) firmware from flash.\n"); |
3936 | return qla24xx_load_risc_flash(ha, srisc_addr); | 3944 | return qla24xx_load_risc_flash(vha, srisc_addr); |
3937 | } | 3945 | } |
3938 | 3946 | ||
3939 | rval = QLA_SUCCESS; | 3947 | rval = QLA_SUCCESS; |
3940 | 3948 | ||
3941 | segments = FA_RISC_CODE_SEGMENTS; | 3949 | segments = FA_RISC_CODE_SEGMENTS; |
3942 | dcode = (uint32_t *)ha->request_ring; | 3950 | dcode = (uint32_t *)ha->req->ring; |
3943 | *srisc_addr = 0; | 3951 | *srisc_addr = 0; |
3944 | fwcode = (uint32_t *)blob->fw->data; | 3952 | fwcode = (uint32_t *)blob->fw->data; |
3945 | fwclen = 0; | 3953 | fwclen = 0; |
@@ -3987,17 +3995,17 @@ qla24xx_load_risc(scsi_qla_host_t *ha, uint32_t *srisc_addr) | |||
3987 | dlen = risc_size; | 3995 | dlen = risc_size; |
3988 | 3996 | ||
3989 | DEBUG7(printk("scsi(%ld): Loading risc segment@ risc " | 3997 | DEBUG7(printk("scsi(%ld): Loading risc segment@ risc " |
3990 | "addr %x, number of dwords 0x%x.\n", ha->host_no, | 3998 | "addr %x, number of dwords 0x%x.\n", vha->host_no, |
3991 | risc_addr, dlen)); | 3999 | risc_addr, dlen)); |
3992 | 4000 | ||
3993 | for (i = 0; i < dlen; i++) | 4001 | for (i = 0; i < dlen; i++) |
3994 | dcode[i] = swab32(fwcode[i]); | 4002 | dcode[i] = swab32(fwcode[i]); |
3995 | 4003 | ||
3996 | rval = qla2x00_load_ram(ha, ha->request_dma, risc_addr, | 4004 | rval = qla2x00_load_ram(vha, ha->req->dma, risc_addr, |
3997 | dlen); | 4005 | dlen); |
3998 | if (rval) { | 4006 | if (rval) { |
3999 | DEBUG(printk("scsi(%ld):[ERROR] Failed to load " | 4007 | DEBUG(printk("scsi(%ld):[ERROR] Failed to load " |
4000 | "segment %d of firmware\n", ha->host_no, | 4008 | "segment %d of firmware\n", vha->host_no, |
4001 | fragment)); | 4009 | fragment)); |
4002 | qla_printk(KERN_WARNING, ha, | 4010 | qla_printk(KERN_WARNING, ha, |
4003 | "[ERROR] Failed to load segment %d of " | 4011 | "[ERROR] Failed to load segment %d of " |
@@ -4021,49 +4029,51 @@ fail_fw_integrity: | |||
4021 | } | 4029 | } |
4022 | 4030 | ||
4023 | void | 4031 | void |
4024 | qla2x00_try_to_stop_firmware(scsi_qla_host_t *ha) | 4032 | qla2x00_try_to_stop_firmware(scsi_qla_host_t *vha) |
4025 | { | 4033 | { |
4026 | int ret, retries; | 4034 | int ret, retries; |
4035 | struct qla_hw_data *ha = vha->hw; | ||
4027 | 4036 | ||
4028 | if (!IS_FWI2_CAPABLE(ha)) | 4037 | if (!IS_FWI2_CAPABLE(ha)) |
4029 | return; | 4038 | return; |
4030 | if (!ha->fw_major_version) | 4039 | if (!ha->fw_major_version) |
4031 | return; | 4040 | return; |
4032 | 4041 | ||
4033 | ret = qla2x00_stop_firmware(ha); | 4042 | ret = qla2x00_stop_firmware(vha); |
4034 | for (retries = 5; ret != QLA_SUCCESS && ret != QLA_FUNCTION_TIMEOUT && | 4043 | for (retries = 5; ret != QLA_SUCCESS && ret != QLA_FUNCTION_TIMEOUT && |
4035 | retries ; retries--) { | 4044 | retries ; retries--) { |
4036 | ha->isp_ops->reset_chip(ha); | 4045 | ha->isp_ops->reset_chip(vha); |
4037 | if (ha->isp_ops->chip_diag(ha) != QLA_SUCCESS) | 4046 | if (ha->isp_ops->chip_diag(vha) != QLA_SUCCESS) |
4038 | continue; | 4047 | continue; |
4039 | if (qla2x00_setup_chip(ha) != QLA_SUCCESS) | 4048 | if (qla2x00_setup_chip(vha) != QLA_SUCCESS) |
4040 | continue; | 4049 | continue; |
4041 | qla_printk(KERN_INFO, ha, | 4050 | qla_printk(KERN_INFO, ha, |
4042 | "Attempting retry of stop-firmware command...\n"); | 4051 | "Attempting retry of stop-firmware command...\n"); |
4043 | ret = qla2x00_stop_firmware(ha); | 4052 | ret = qla2x00_stop_firmware(vha); |
4044 | } | 4053 | } |
4045 | } | 4054 | } |
4046 | 4055 | ||
4047 | int | 4056 | int |
4048 | qla24xx_configure_vhba(scsi_qla_host_t *ha) | 4057 | qla24xx_configure_vhba(scsi_qla_host_t *vha) |
4049 | { | 4058 | { |
4050 | int rval = QLA_SUCCESS; | 4059 | int rval = QLA_SUCCESS; |
4051 | uint16_t mb[MAILBOX_REGISTER_COUNT]; | 4060 | uint16_t mb[MAILBOX_REGISTER_COUNT]; |
4061 | struct qla_hw_data *ha = vha->hw; | ||
4062 | struct scsi_qla_host *base_vha = pci_get_drvdata(ha->pdev); | ||
4052 | 4063 | ||
4053 | if (!ha->parent) | 4064 | if (!vha->vp_idx) |
4054 | return -EINVAL; | 4065 | return -EINVAL; |
4055 | 4066 | ||
4056 | rval = qla2x00_fw_ready(ha->parent); | 4067 | rval = qla2x00_fw_ready(base_vha); |
4057 | if (rval == QLA_SUCCESS) { | 4068 | if (rval == QLA_SUCCESS) { |
4058 | clear_bit(RESET_MARKER_NEEDED, &ha->dpc_flags); | 4069 | clear_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); |
4059 | qla2x00_marker(ha, 0, 0, MK_SYNC_ALL); | 4070 | qla2x00_marker(vha, 0, 0, MK_SYNC_ALL); |
4060 | } | 4071 | } |
4061 | 4072 | ||
4062 | ha->flags.management_server_logged_in = 0; | 4073 | vha->flags.management_server_logged_in = 0; |
4063 | 4074 | ||
4064 | /* Login to SNS first */ | 4075 | /* Login to SNS first */ |
4065 | qla24xx_login_fabric(ha->parent, NPH_SNS, 0xff, 0xff, 0xfc, | 4076 | ha->isp_ops->fabric_login(vha, NPH_SNS, 0xff, 0xff, 0xfc, mb, BIT_1); |
4066 | mb, BIT_1); | ||
4067 | if (mb[0] != MBS_COMMAND_COMPLETE) { | 4077 | if (mb[0] != MBS_COMMAND_COMPLETE) { |
4068 | DEBUG15(qla_printk(KERN_INFO, ha, | 4078 | DEBUG15(qla_printk(KERN_INFO, ha, |
4069 | "Failed SNS login: loop_id=%x mb[0]=%x mb[1]=%x " | 4079 | "Failed SNS login: loop_id=%x mb[0]=%x mb[1]=%x " |
@@ -4072,11 +4082,11 @@ qla24xx_configure_vhba(scsi_qla_host_t *ha) | |||
4072 | return (QLA_FUNCTION_FAILED); | 4082 | return (QLA_FUNCTION_FAILED); |
4073 | } | 4083 | } |
4074 | 4084 | ||
4075 | atomic_set(&ha->loop_down_timer, 0); | 4085 | atomic_set(&vha->loop_down_timer, 0); |
4076 | atomic_set(&ha->loop_state, LOOP_UP); | 4086 | atomic_set(&vha->loop_state, LOOP_UP); |
4077 | set_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags); | 4087 | set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); |
4078 | set_bit(LOCAL_LOOP_UPDATE, &ha->dpc_flags); | 4088 | set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); |
4079 | rval = qla2x00_loop_resync(ha->parent); | 4089 | rval = qla2x00_loop_resync(base_vha); |
4080 | 4090 | ||
4081 | return rval; | 4091 | return rval; |
4082 | } | 4092 | } |
@@ -4087,9 +4097,10 @@ static LIST_HEAD(qla_cs84xx_list); | |||
4087 | static DEFINE_MUTEX(qla_cs84xx_mutex); | 4097 | static DEFINE_MUTEX(qla_cs84xx_mutex); |
4088 | 4098 | ||
4089 | static struct qla_chip_state_84xx * | 4099 | static struct qla_chip_state_84xx * |
4090 | qla84xx_get_chip(struct scsi_qla_host *ha) | 4100 | qla84xx_get_chip(struct scsi_qla_host *vha) |
4091 | { | 4101 | { |
4092 | struct qla_chip_state_84xx *cs84xx; | 4102 | struct qla_chip_state_84xx *cs84xx; |
4103 | struct qla_hw_data *ha = vha->hw; | ||
4093 | 4104 | ||
4094 | mutex_lock(&qla_cs84xx_mutex); | 4105 | mutex_lock(&qla_cs84xx_mutex); |
4095 | 4106 | ||
@@ -4129,21 +4140,23 @@ __qla84xx_chip_release(struct kref *kref) | |||
4129 | } | 4140 | } |
4130 | 4141 | ||
4131 | void | 4142 | void |
4132 | qla84xx_put_chip(struct scsi_qla_host *ha) | 4143 | qla84xx_put_chip(struct scsi_qla_host *vha) |
4133 | { | 4144 | { |
4145 | struct qla_hw_data *ha = vha->hw; | ||
4134 | if (ha->cs84xx) | 4146 | if (ha->cs84xx) |
4135 | kref_put(&ha->cs84xx->kref, __qla84xx_chip_release); | 4147 | kref_put(&ha->cs84xx->kref, __qla84xx_chip_release); |
4136 | } | 4148 | } |
4137 | 4149 | ||
4138 | static int | 4150 | static int |
4139 | qla84xx_init_chip(scsi_qla_host_t *ha) | 4151 | qla84xx_init_chip(scsi_qla_host_t *vha) |
4140 | { | 4152 | { |
4141 | int rval; | 4153 | int rval; |
4142 | uint16_t status[2]; | 4154 | uint16_t status[2]; |
4155 | struct qla_hw_data *ha = vha->hw; | ||
4143 | 4156 | ||
4144 | mutex_lock(&ha->cs84xx->fw_update_mutex); | 4157 | mutex_lock(&ha->cs84xx->fw_update_mutex); |
4145 | 4158 | ||
4146 | rval = qla84xx_verify_chip(ha, status); | 4159 | rval = qla84xx_verify_chip(vha, status); |
4147 | 4160 | ||
4148 | mutex_unlock(&ha->cs84xx->fw_update_mutex); | 4161 | mutex_unlock(&ha->cs84xx->fw_update_mutex); |
4149 | 4162 | ||