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