aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/qla4xxx/ql4_init.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/qla4xxx/ql4_init.c')
-rw-r--r--drivers/scsi/qla4xxx/ql4_init.c240
1 files changed, 156 insertions, 84 deletions
diff --git a/drivers/scsi/qla4xxx/ql4_init.c b/drivers/scsi/qla4xxx/ql4_init.c
index 5510df8a7fa6..266ebd45396d 100644
--- a/drivers/scsi/qla4xxx/ql4_init.c
+++ b/drivers/scsi/qla4xxx/ql4_init.c
@@ -11,8 +11,8 @@
11#include "ql4_dbg.h" 11#include "ql4_dbg.h"
12#include "ql4_inline.h" 12#include "ql4_inline.h"
13 13
14static struct ddb_entry * qla4xxx_alloc_ddb(struct scsi_qla_host *ha, 14static struct ddb_entry *qla4xxx_alloc_ddb(struct scsi_qla_host *ha,
15 uint32_t fw_ddb_index); 15 uint32_t fw_ddb_index);
16 16
17static void ql4xxx_set_mac_number(struct scsi_qla_host *ha) 17static void ql4xxx_set_mac_number(struct scsi_qla_host *ha)
18{ 18{
@@ -51,8 +51,8 @@ static void ql4xxx_set_mac_number(struct scsi_qla_host *ha)
51 * This routine deallocates and unlinks the specified ddb_entry from the 51 * This routine deallocates and unlinks the specified ddb_entry from the
52 * adapter's 52 * adapter's
53 **/ 53 **/
54static void qla4xxx_free_ddb(struct scsi_qla_host *ha, 54void qla4xxx_free_ddb(struct scsi_qla_host *ha,
55 struct ddb_entry *ddb_entry) 55 struct ddb_entry *ddb_entry)
56{ 56{
57 /* Remove device entry from list */ 57 /* Remove device entry from list */
58 list_del_init(&ddb_entry->list); 58 list_del_init(&ddb_entry->list);
@@ -86,6 +86,25 @@ void qla4xxx_free_ddb_list(struct scsi_qla_host *ha)
86} 86}
87 87
88/** 88/**
89 * qla4xxx_init_response_q_entries() - Initializes response queue entries.
90 * @ha: HA context
91 *
92 * Beginning of request ring has initialization control block already built
93 * by nvram config routine.
94 **/
95static void qla4xxx_init_response_q_entries(struct scsi_qla_host *ha)
96{
97 uint16_t cnt;
98 struct response *pkt;
99
100 pkt = (struct response *)ha->response_ptr;
101 for (cnt = 0; cnt < RESPONSE_QUEUE_DEPTH; cnt++) {
102 pkt->signature = RESPONSE_PROCESSED;
103 pkt++;
104 }
105}
106
107/**
89 * qla4xxx_init_rings - initialize hw queues 108 * qla4xxx_init_rings - initialize hw queues
90 * @ha: pointer to host adapter structure. 109 * @ha: pointer to host adapter structure.
91 * 110 *
@@ -109,19 +128,31 @@ int qla4xxx_init_rings(struct scsi_qla_host *ha)
109 ha->response_out = 0; 128 ha->response_out = 0;
110 ha->response_ptr = &ha->response_ring[ha->response_out]; 129 ha->response_ptr = &ha->response_ring[ha->response_out];
111 130
112 /* 131 if (is_qla8022(ha)) {
113 * Initialize DMA Shadow registers. The firmware is really supposed to 132 writel(0,
114 * take care of this, but on some uniprocessor systems, the shadow 133 (unsigned long __iomem *)&ha->qla4_8xxx_reg->req_q_out);
115 * registers aren't cleared-- causing the interrupt_handler to think 134 writel(0,
116 * there are responses to be processed when there aren't. 135 (unsigned long __iomem *)&ha->qla4_8xxx_reg->rsp_q_in);
117 */ 136 writel(0,
118 ha->shadow_regs->req_q_out = __constant_cpu_to_le32(0); 137 (unsigned long __iomem *)&ha->qla4_8xxx_reg->rsp_q_out);
119 ha->shadow_regs->rsp_q_in = __constant_cpu_to_le32(0); 138 } else {
120 wmb(); 139 /*
140 * Initialize DMA Shadow registers. The firmware is really
141 * supposed to take care of this, but on some uniprocessor
142 * systems, the shadow registers aren't cleared-- causing
143 * the interrupt_handler to think there are responses to be
144 * processed when there aren't.
145 */
146 ha->shadow_regs->req_q_out = __constant_cpu_to_le32(0);
147 ha->shadow_regs->rsp_q_in = __constant_cpu_to_le32(0);
148 wmb();
121 149
122 writel(0, &ha->reg->req_q_in); 150 writel(0, &ha->reg->req_q_in);
123 writel(0, &ha->reg->rsp_q_out); 151 writel(0, &ha->reg->rsp_q_out);
124 readl(&ha->reg->rsp_q_out); 152 readl(&ha->reg->rsp_q_out);
153 }
154
155 qla4xxx_init_response_q_entries(ha);
125 156
126 spin_unlock_irqrestore(&ha->hardware_lock, flags); 157 spin_unlock_irqrestore(&ha->hardware_lock, flags);
127 158
@@ -129,11 +160,11 @@ int qla4xxx_init_rings(struct scsi_qla_host *ha)
129} 160}
130 161
131/** 162/**
132 * qla4xxx_validate_mac_address - validate adapter MAC address(es) 163 * qla4xxx_get_sys_info - validate adapter MAC address(es)
133 * @ha: pointer to host adapter structure. 164 * @ha: pointer to host adapter structure.
134 * 165 *
135 **/ 166 **/
136static int qla4xxx_validate_mac_address(struct scsi_qla_host *ha) 167int qla4xxx_get_sys_info(struct scsi_qla_host *ha)
137{ 168{
138 struct flash_sys_info *sys_info; 169 struct flash_sys_info *sys_info;
139 dma_addr_t sys_info_dma; 170 dma_addr_t sys_info_dma;
@@ -145,7 +176,7 @@ static int qla4xxx_validate_mac_address(struct scsi_qla_host *ha)
145 DEBUG2(printk("scsi%ld: %s: Unable to allocate dma buffer.\n", 176 DEBUG2(printk("scsi%ld: %s: Unable to allocate dma buffer.\n",
146 ha->host_no, __func__)); 177 ha->host_no, __func__));
147 178
148 goto exit_validate_mac_no_free; 179 goto exit_get_sys_info_no_free;
149 } 180 }
150 memset(sys_info, 0, sizeof(*sys_info)); 181 memset(sys_info, 0, sizeof(*sys_info));
151 182
@@ -155,7 +186,7 @@ static int qla4xxx_validate_mac_address(struct scsi_qla_host *ha)
155 DEBUG2(printk("scsi%ld: %s: get_flash FLASH_OFFSET_SYS_INFO " 186 DEBUG2(printk("scsi%ld: %s: get_flash FLASH_OFFSET_SYS_INFO "
156 "failed\n", ha->host_no, __func__)); 187 "failed\n", ha->host_no, __func__));
157 188
158 goto exit_validate_mac; 189 goto exit_get_sys_info;
159 } 190 }
160 191
161 /* Save M.A.C. address & serial_number */ 192 /* Save M.A.C. address & serial_number */
@@ -168,11 +199,11 @@ static int qla4xxx_validate_mac_address(struct scsi_qla_host *ha)
168 199
169 status = QLA_SUCCESS; 200 status = QLA_SUCCESS;
170 201
171 exit_validate_mac: 202exit_get_sys_info:
172 dma_free_coherent(&ha->pdev->dev, sizeof(*sys_info), sys_info, 203 dma_free_coherent(&ha->pdev->dev, sizeof(*sys_info), sys_info,
173 sys_info_dma); 204 sys_info_dma);
174 205
175 exit_validate_mac_no_free: 206exit_get_sys_info_no_free:
176 return status; 207 return status;
177} 208}
178 209
@@ -266,7 +297,7 @@ static int qla4xxx_fw_ready(struct scsi_qla_host *ha)
266 uint32_t timeout_count; 297 uint32_t timeout_count;
267 int ready = 0; 298 int ready = 0;
268 299
269 DEBUG2(dev_info(&ha->pdev->dev, "Waiting for Firmware Ready..\n")); 300 DEBUG2(ql4_printk(KERN_INFO, ha, "Waiting for Firmware Ready..\n"));
270 for (timeout_count = ADAPTER_INIT_TOV; timeout_count > 0; 301 for (timeout_count = ADAPTER_INIT_TOV; timeout_count > 0;
271 timeout_count--) { 302 timeout_count--) {
272 if (test_and_clear_bit(DPC_GET_DHCP_IP_ADDR, &ha->dpc_flags)) 303 if (test_and_clear_bit(DPC_GET_DHCP_IP_ADDR, &ha->dpc_flags))
@@ -339,29 +370,29 @@ static int qla4xxx_fw_ready(struct scsi_qla_host *ha)
339 370
340 if (!qla4xxx_wait_for_ip_config(ha) || 371 if (!qla4xxx_wait_for_ip_config(ha) ||
341 timeout_count == 1) { 372 timeout_count == 1) {
342 DEBUG2(dev_info(&ha->pdev->dev, 373 DEBUG2(ql4_printk(KERN_INFO, ha,
343 "Firmware Ready..\n")); 374 "Firmware Ready..\n"));
344 /* The firmware is ready to process SCSI 375 /* The firmware is ready to process SCSI
345 commands. */ 376 commands. */
346 DEBUG2(dev_info(&ha->pdev->dev, 377 DEBUG2(ql4_printk(KERN_INFO, ha,
347 "scsi%ld: %s: MEDIA TYPE" 378 "scsi%ld: %s: MEDIA TYPE"
348 " - %s\n", ha->host_no, 379 " - %s\n", ha->host_no,
349 __func__, (ha->addl_fw_state & 380 __func__, (ha->addl_fw_state &
350 FW_ADDSTATE_OPTICAL_MEDIA) 381 FW_ADDSTATE_OPTICAL_MEDIA)
351 != 0 ? "OPTICAL" : "COPPER")); 382 != 0 ? "OPTICAL" : "COPPER"));
352 DEBUG2(dev_info(&ha->pdev->dev, 383 DEBUG2(ql4_printk(KERN_INFO, ha,
353 "scsi%ld: %s: DHCPv4 STATE" 384 "scsi%ld: %s: DHCPv4 STATE"
354 " Enabled %s\n", ha->host_no, 385 " Enabled %s\n", ha->host_no,
355 __func__, (ha->addl_fw_state & 386 __func__, (ha->addl_fw_state &
356 FW_ADDSTATE_DHCPv4_ENABLED) != 0 ? 387 FW_ADDSTATE_DHCPv4_ENABLED) != 0 ?
357 "YES" : "NO")); 388 "YES" : "NO"));
358 DEBUG2(dev_info(&ha->pdev->dev, 389 DEBUG2(ql4_printk(KERN_INFO, ha,
359 "scsi%ld: %s: LINK %s\n", 390 "scsi%ld: %s: LINK %s\n",
360 ha->host_no, __func__, 391 ha->host_no, __func__,
361 (ha->addl_fw_state & 392 (ha->addl_fw_state &
362 FW_ADDSTATE_LINK_UP) != 0 ? 393 FW_ADDSTATE_LINK_UP) != 0 ?
363 "UP" : "DOWN")); 394 "UP" : "DOWN"));
364 DEBUG2(dev_info(&ha->pdev->dev, 395 DEBUG2(ql4_printk(KERN_INFO, ha,
365 "scsi%ld: %s: iSNS Service " 396 "scsi%ld: %s: iSNS Service "
366 "Started %s\n", 397 "Started %s\n",
367 ha->host_no, __func__, 398 ha->host_no, __func__,
@@ -399,6 +430,7 @@ static int qla4xxx_fw_ready(struct scsi_qla_host *ha)
399 DEBUG2(printk("scsi%ld: %s: FW initialized, but " 430 DEBUG2(printk("scsi%ld: %s: FW initialized, but "
400 "auto-discovery still in process\n", 431 "auto-discovery still in process\n",
401 ha->host_no, __func__)); 432 ha->host_no, __func__));
433 ready = 1;
402 } 434 }
403 435
404 return ready; 436 return ready;
@@ -413,7 +445,7 @@ static int qla4xxx_init_firmware(struct scsi_qla_host *ha)
413{ 445{
414 int status = QLA_ERROR; 446 int status = QLA_ERROR;
415 447
416 dev_info(&ha->pdev->dev, "Initializing firmware..\n"); 448 ql4_printk(KERN_INFO, ha, "Initializing firmware..\n");
417 if (qla4xxx_initialize_fw_cb(ha) == QLA_ERROR) { 449 if (qla4xxx_initialize_fw_cb(ha) == QLA_ERROR) {
418 DEBUG2(printk("scsi%ld: %s: Failed to initialize firmware " 450 DEBUG2(printk("scsi%ld: %s: Failed to initialize firmware "
419 "control block\n", ha->host_no, __func__)); 451 "control block\n", ha->host_no, __func__));
@@ -443,17 +475,17 @@ static struct ddb_entry* qla4xxx_get_ddb_entry(struct scsi_qla_host *ha,
443 if (fw_ddb_entry == NULL) { 475 if (fw_ddb_entry == NULL) {
444 DEBUG2(printk("scsi%ld: %s: Unable to allocate dma buffer.\n", 476 DEBUG2(printk("scsi%ld: %s: Unable to allocate dma buffer.\n",
445 ha->host_no, __func__)); 477 ha->host_no, __func__));
446 return NULL; 478 goto exit_get_ddb_entry_no_free;
447 } 479 }
448 480
449 if (qla4xxx_get_fwddb_entry(ha, fw_ddb_index, fw_ddb_entry, 481 if (qla4xxx_get_fwddb_entry(ha, fw_ddb_index, fw_ddb_entry,
450 fw_ddb_entry_dma, NULL, NULL, 482 fw_ddb_entry_dma, NULL, NULL,
451 &device_state, NULL, NULL, NULL) == 483 &device_state, NULL, NULL, NULL) ==
452 QLA_ERROR) { 484 QLA_ERROR) {
453 DEBUG2(printk("scsi%ld: %s: failed get_ddb_entry for " 485 DEBUG2(printk("scsi%ld: %s: failed get_ddb_entry for "
454 "fw_ddb_index %d\n", ha->host_no, __func__, 486 "fw_ddb_index %d\n", ha->host_no, __func__,
455 fw_ddb_index)); 487 fw_ddb_index));
456 return NULL; 488 goto exit_get_ddb_entry;
457 } 489 }
458 490
459 /* Allocate DDB if not already allocated. */ 491 /* Allocate DDB if not already allocated. */
@@ -471,6 +503,7 @@ static struct ddb_entry* qla4xxx_get_ddb_entry(struct scsi_qla_host *ha,
471 } 503 }
472 } 504 }
473 505
506 /* if not found allocate new ddb */
474 if (!found) { 507 if (!found) {
475 DEBUG2(printk("scsi%ld: %s: ddb[%d] not found - allocating " 508 DEBUG2(printk("scsi%ld: %s: ddb[%d] not found - allocating "
476 "new ddb\n", ha->host_no, __func__, 509 "new ddb\n", ha->host_no, __func__,
@@ -479,10 +512,11 @@ static struct ddb_entry* qla4xxx_get_ddb_entry(struct scsi_qla_host *ha,
479 ddb_entry = qla4xxx_alloc_ddb(ha, fw_ddb_index); 512 ddb_entry = qla4xxx_alloc_ddb(ha, fw_ddb_index);
480 } 513 }
481 514
482 /* if not found allocate new ddb */ 515exit_get_ddb_entry:
483 dma_free_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry), fw_ddb_entry, 516 dma_free_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry), fw_ddb_entry,
484 fw_ddb_entry_dma); 517 fw_ddb_entry_dma);
485 518
519exit_get_ddb_entry_no_free:
486 return ddb_entry; 520 return ddb_entry;
487} 521}
488 522
@@ -510,7 +544,8 @@ static int qla4xxx_update_ddb_entry(struct scsi_qla_host *ha,
510 if (ddb_entry == NULL) { 544 if (ddb_entry == NULL) {
511 DEBUG2(printk("scsi%ld: %s: ddb_entry is NULL\n", ha->host_no, 545 DEBUG2(printk("scsi%ld: %s: ddb_entry is NULL\n", ha->host_no,
512 __func__)); 546 __func__));
513 goto exit_update_ddb; 547
548 goto exit_update_ddb_no_free;
514 } 549 }
515 550
516 /* Make sure the dma buffer is valid */ 551 /* Make sure the dma buffer is valid */
@@ -521,7 +556,7 @@ static int qla4xxx_update_ddb_entry(struct scsi_qla_host *ha,
521 DEBUG2(printk("scsi%ld: %s: Unable to allocate dma buffer.\n", 556 DEBUG2(printk("scsi%ld: %s: Unable to allocate dma buffer.\n",
522 ha->host_no, __func__)); 557 ha->host_no, __func__));
523 558
524 goto exit_update_ddb; 559 goto exit_update_ddb_no_free;
525 } 560 }
526 561
527 if (qla4xxx_get_fwddb_entry(ha, fw_ddb_index, fw_ddb_entry, 562 if (qla4xxx_get_fwddb_entry(ha, fw_ddb_index, fw_ddb_entry,
@@ -529,7 +564,7 @@ static int qla4xxx_update_ddb_entry(struct scsi_qla_host *ha,
529 &ddb_entry->fw_ddb_device_state, &conn_err, 564 &ddb_entry->fw_ddb_device_state, &conn_err,
530 &ddb_entry->tcp_source_port_num, 565 &ddb_entry->tcp_source_port_num,
531 &ddb_entry->connection_id) == 566 &ddb_entry->connection_id) ==
532 QLA_ERROR) { 567 QLA_ERROR) {
533 DEBUG2(printk("scsi%ld: %s: failed get_ddb_entry for " 568 DEBUG2(printk("scsi%ld: %s: failed get_ddb_entry for "
534 "fw_ddb_index %d\n", ha->host_no, __func__, 569 "fw_ddb_index %d\n", ha->host_no, __func__,
535 fw_ddb_index)); 570 fw_ddb_index));
@@ -559,6 +594,9 @@ static int qla4xxx_update_ddb_entry(struct scsi_qla_host *ha,
559 memcpy(&ddb_entry->iscsi_name[0], &fw_ddb_entry->iscsi_name[0], 594 memcpy(&ddb_entry->iscsi_name[0], &fw_ddb_entry->iscsi_name[0],
560 min(sizeof(ddb_entry->iscsi_name), 595 min(sizeof(ddb_entry->iscsi_name),
561 sizeof(fw_ddb_entry->iscsi_name))); 596 sizeof(fw_ddb_entry->iscsi_name)));
597 memcpy(&ddb_entry->iscsi_alias[0], &fw_ddb_entry->iscsi_alias[0],
598 min(sizeof(ddb_entry->iscsi_alias),
599 sizeof(fw_ddb_entry->iscsi_alias)));
562 memcpy(&ddb_entry->ip_addr[0], &fw_ddb_entry->ip_addr[0], 600 memcpy(&ddb_entry->ip_addr[0], &fw_ddb_entry->ip_addr[0],
563 min(sizeof(ddb_entry->ip_addr), sizeof(fw_ddb_entry->ip_addr))); 601 min(sizeof(ddb_entry->ip_addr), sizeof(fw_ddb_entry->ip_addr)));
564 602
@@ -580,21 +618,19 @@ static int qla4xxx_update_ddb_entry(struct scsi_qla_host *ha,
580 min(sizeof(ddb_entry->link_local_ipv6_addr), 618 min(sizeof(ddb_entry->link_local_ipv6_addr),
581 sizeof(fw_ddb_entry->link_local_ipv6_addr))); 619 sizeof(fw_ddb_entry->link_local_ipv6_addr)));
582 620
583 DEBUG2(dev_info(&ha->pdev->dev, "%s: DDB[%d] osIdx = %d " 621 DEBUG2(ql4_printk(KERN_INFO, ha, "%s: DDB[%d] State %04x"
584 "State %04x ConnErr %08x IP %pI6 " 622 " ConnErr %08x IP %pI6 "
585 ":%04d \"%s\"\n", 623 ":%04d \"%s\"\n",
586 __func__, fw_ddb_index, 624 __func__, fw_ddb_index,
587 ddb_entry->os_target_id,
588 ddb_entry->fw_ddb_device_state, 625 ddb_entry->fw_ddb_device_state,
589 conn_err, fw_ddb_entry->ip_addr, 626 conn_err, fw_ddb_entry->ip_addr,
590 le16_to_cpu(fw_ddb_entry->port), 627 le16_to_cpu(fw_ddb_entry->port),
591 fw_ddb_entry->iscsi_name)); 628 fw_ddb_entry->iscsi_name));
592 } else 629 } else
593 DEBUG2(dev_info(&ha->pdev->dev, "%s: DDB[%d] osIdx = %d " 630 DEBUG2(ql4_printk(KERN_INFO, ha, "%s: DDB[%d] State %04x"
594 "State %04x ConnErr %08x IP %pI4 " 631 " ConnErr %08x IP %pI4 "
595 ":%04d \"%s\"\n", 632 ":%04d \"%s\"\n",
596 __func__, fw_ddb_index, 633 __func__, fw_ddb_index,
597 ddb_entry->os_target_id,
598 ddb_entry->fw_ddb_device_state, 634 ddb_entry->fw_ddb_device_state,
599 conn_err, fw_ddb_entry->ip_addr, 635 conn_err, fw_ddb_entry->ip_addr,
600 le16_to_cpu(fw_ddb_entry->port), 636 le16_to_cpu(fw_ddb_entry->port),
@@ -604,6 +640,7 @@ exit_update_ddb:
604 dma_free_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry), 640 dma_free_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry),
605 fw_ddb_entry, fw_ddb_entry_dma); 641 fw_ddb_entry, fw_ddb_entry_dma);
606 642
643exit_update_ddb_no_free:
607 return status; 644 return status;
608} 645}
609 646
@@ -660,18 +697,18 @@ int qla4_is_relogin_allowed(struct scsi_qla_host *ha, uint32_t conn_err)
660 err_code = ((conn_err & 0x00ff0000) >> 16); 697 err_code = ((conn_err & 0x00ff0000) >> 16);
661 login_rsp_sts_class = ((conn_err & 0x0000ff00) >> 8); 698 login_rsp_sts_class = ((conn_err & 0x0000ff00) >> 8);
662 if (err_code == 0x1c || err_code == 0x06) { 699 if (err_code == 0x1c || err_code == 0x06) {
663 DEBUG2(dev_info(&ha->pdev->dev, 700 DEBUG2(ql4_printk(KERN_INFO, ha,
664 ": conn_err=0x%08x, send target completed" 701 ": conn_err=0x%08x, send target completed"
665 " or access denied failure\n", conn_err)); 702 " or access denied failure\n", conn_err));
666 relogin = 0; 703 relogin = 0;
667 } 704 }
668 if ((err_code == 0x08) && (login_rsp_sts_class == 0x02)) { 705 if ((err_code == 0x08) && (login_rsp_sts_class == 0x02)) {
669 /* Login Response PDU returned an error. 706 /* Login Response PDU returned an error.
670 Login Response Status in Error Code Detail 707 Login Response Status in Error Code Detail
671 indicates login should not be retried.*/ 708 indicates login should not be retried.*/
672 DEBUG2(dev_info(&ha->pdev->dev, 709 DEBUG2(ql4_printk(KERN_INFO, ha,
673 ": conn_err=0x%08x, do not retry relogin\n", 710 ": conn_err=0x%08x, do not retry relogin\n",
674 conn_err)); 711 conn_err));
675 relogin = 0; 712 relogin = 0;
676 } 713 }
677 714
@@ -688,7 +725,7 @@ int qla4_is_relogin_allowed(struct scsi_qla_host *ha, uint32_t conn_err)
688 **/ 725 **/
689static int qla4xxx_build_ddb_list(struct scsi_qla_host *ha) 726static int qla4xxx_build_ddb_list(struct scsi_qla_host *ha)
690{ 727{
691 int status = QLA_SUCCESS; 728 int status = QLA_ERROR;
692 uint32_t fw_ddb_index = 0; 729 uint32_t fw_ddb_index = 0;
693 uint32_t next_fw_ddb_index = 0; 730 uint32_t next_fw_ddb_index = 0;
694 uint32_t ddb_state; 731 uint32_t ddb_state;
@@ -702,12 +739,13 @@ static int qla4xxx_build_ddb_list(struct scsi_qla_host *ha)
702 fw_ddb_entry = dma_alloc_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry), 739 fw_ddb_entry = dma_alloc_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry),
703 &fw_ddb_entry_dma, GFP_KERNEL); 740 &fw_ddb_entry_dma, GFP_KERNEL);
704 if (fw_ddb_entry == NULL) { 741 if (fw_ddb_entry == NULL) {
705 DEBUG2(dev_info(&ha->pdev->dev, "%s: DMA alloc failed\n", 742 DEBUG2(ql4_printk(KERN_INFO, ha, "%s: DMA alloc failed\n",
706 __func__)); 743 __func__));
707 return QLA_ERROR; 744
745 goto exit_build_ddb_list_no_free;
708 } 746 }
709 747
710 dev_info(&ha->pdev->dev, "Initializing DDBs ...\n"); 748 ql4_printk(KERN_INFO, ha, "Initializing DDBs ...\n");
711 for (fw_ddb_index = 0; fw_ddb_index < MAX_DDB_ENTRIES; 749 for (fw_ddb_index = 0; fw_ddb_index < MAX_DDB_ENTRIES;
712 fw_ddb_index = next_fw_ddb_index) { 750 fw_ddb_index = next_fw_ddb_index) {
713 /* First, let's see if a device exists here */ 751 /* First, let's see if a device exists here */
@@ -719,7 +757,7 @@ static int qla4xxx_build_ddb_list(struct scsi_qla_host *ha)
719 DEBUG2(printk("scsi%ld: %s: get_ddb_entry, " 757 DEBUG2(printk("scsi%ld: %s: get_ddb_entry, "
720 "fw_ddb_index %d failed", ha->host_no, 758 "fw_ddb_index %d failed", ha->host_no,
721 __func__, fw_ddb_index)); 759 __func__, fw_ddb_index));
722 return QLA_ERROR; 760 goto exit_build_ddb_list;
723 } 761 }
724 762
725 DEBUG2(printk("scsi%ld: %s: Getting DDB[%d] ddbstate=0x%x, " 763 DEBUG2(printk("scsi%ld: %s: Getting DDB[%d] ddbstate=0x%x, "
@@ -749,7 +787,7 @@ static int qla4xxx_build_ddb_list(struct scsi_qla_host *ha)
749 "get_ddb_entry %d failed\n", 787 "get_ddb_entry %d failed\n",
750 ha->host_no, 788 ha->host_no,
751 __func__, fw_ddb_index)); 789 __func__, fw_ddb_index));
752 return QLA_ERROR; 790 goto exit_build_ddb_list;
753 } 791 }
754 } 792 }
755 } 793 }
@@ -769,7 +807,7 @@ static int qla4xxx_build_ddb_list(struct scsi_qla_host *ha)
769 DEBUG2(printk("scsi%ld: %s: Unable to allocate memory " 807 DEBUG2(printk("scsi%ld: %s: Unable to allocate memory "
770 "for device at fw_ddb_index %d\n", 808 "for device at fw_ddb_index %d\n",
771 ha->host_no, __func__, fw_ddb_index)); 809 ha->host_no, __func__, fw_ddb_index));
772 return QLA_ERROR; 810 goto exit_build_ddb_list;
773 } 811 }
774 /* Fill in the device structure */ 812 /* Fill in the device structure */
775 if (qla4xxx_update_ddb_entry(ha, ddb_entry, fw_ddb_index) == 813 if (qla4xxx_update_ddb_entry(ha, ddb_entry, fw_ddb_index) ==
@@ -777,11 +815,10 @@ static int qla4xxx_build_ddb_list(struct scsi_qla_host *ha)
777 ha->fw_ddb_index_map[fw_ddb_index] = 815 ha->fw_ddb_index_map[fw_ddb_index] =
778 (struct ddb_entry *)INVALID_ENTRY; 816 (struct ddb_entry *)INVALID_ENTRY;
779 817
780
781 DEBUG2(printk("scsi%ld: %s: update_ddb_entry failed " 818 DEBUG2(printk("scsi%ld: %s: update_ddb_entry failed "
782 "for fw_ddb_index %d.\n", 819 "for fw_ddb_index %d.\n",
783 ha->host_no, __func__, fw_ddb_index)); 820 ha->host_no, __func__, fw_ddb_index));
784 return QLA_ERROR; 821 goto exit_build_ddb_list;
785 } 822 }
786 823
787next_one: 824next_one:
@@ -791,8 +828,14 @@ next_one:
791 break; 828 break;
792 } 829 }
793 830
794 dev_info(&ha->pdev->dev, "DDB list done..\n"); 831 status = QLA_SUCCESS;
832 ql4_printk(KERN_INFO, ha, "DDB list done..\n");
833
834exit_build_ddb_list:
835 dma_free_coherent(&ha->pdev->dev, sizeof(*fw_ddb_entry), fw_ddb_entry,
836 fw_ddb_entry_dma);
795 837
838exit_build_ddb_list_no_free:
796 return status; 839 return status;
797} 840}
798 841
@@ -951,6 +994,9 @@ static int qla4xxx_initialize_ddb_list(struct scsi_qla_host *ha)
951 994
952 qla4xxx_flush_AENS(ha); 995 qla4xxx_flush_AENS(ha);
953 996
997 /* Wait for an AEN */
998 qla4xxx_devices_ready(ha);
999
954 /* 1000 /*
955 * First perform device discovery for active 1001 * First perform device discovery for active
956 * fw ddb indexes and build 1002 * fw ddb indexes and build
@@ -959,9 +1005,6 @@ static int qla4xxx_initialize_ddb_list(struct scsi_qla_host *ha)
959 if ((status = qla4xxx_build_ddb_list(ha)) == QLA_ERROR) 1005 if ((status = qla4xxx_build_ddb_list(ha)) == QLA_ERROR)
960 return status; 1006 return status;
961 1007
962 /* Wait for an AEN */
963 qla4xxx_devices_ready(ha);
964
965 /* 1008 /*
966 * Targets can come online after the inital discovery, so processing 1009 * Targets can come online after the inital discovery, so processing
967 * the aens here will catch them. 1010 * the aens here will catch them.
@@ -973,7 +1016,7 @@ static int qla4xxx_initialize_ddb_list(struct scsi_qla_host *ha)
973} 1016}
974 1017
975/** 1018/**
976 * qla4xxx_update_ddb_list - update the driver ddb list 1019 * qla4xxx_reinitialize_ddb_list - update the driver ddb list
977 * @ha: pointer to host adapter structure. 1020 * @ha: pointer to host adapter structure.
978 * 1021 *
979 * This routine obtains device information from the F/W database after 1022 * This routine obtains device information from the F/W database after
@@ -993,6 +1036,7 @@ int qla4xxx_reinitialize_ddb_list(struct scsi_qla_host *ha)
993 DEBUG2(printk ("scsi%ld: %s: ddb index [%d] marked " 1036 DEBUG2(printk ("scsi%ld: %s: ddb index [%d] marked "
994 "ONLINE\n", ha->host_no, __func__, 1037 "ONLINE\n", ha->host_no, __func__,
995 ddb_entry->fw_ddb_index)); 1038 ddb_entry->fw_ddb_index));
1039 iscsi_unblock_session(ddb_entry->sess);
996 } else if (atomic_read(&ddb_entry->state) == DDB_STATE_ONLINE) 1040 } else if (atomic_read(&ddb_entry->state) == DDB_STATE_ONLINE)
997 qla4xxx_mark_device_missing(ha, ddb_entry); 1041 qla4xxx_mark_device_missing(ha, ddb_entry);
998 } 1042 }
@@ -1016,7 +1060,7 @@ int qla4xxx_relogin_device(struct scsi_qla_host *ha,
1016 (uint16_t)RELOGIN_TOV); 1060 (uint16_t)RELOGIN_TOV);
1017 atomic_set(&ddb_entry->relogin_timer, relogin_timer); 1061 atomic_set(&ddb_entry->relogin_timer, relogin_timer);
1018 1062
1019 DEBUG2(printk("scsi%ld: Relogin index [%d]. TOV=%d\n", ha->host_no, 1063 DEBUG2(printk("scsi%ld: Relogin ddb [%d]. TOV=%d\n", ha->host_no,
1020 ddb_entry->fw_ddb_index, relogin_timer)); 1064 ddb_entry->fw_ddb_index, relogin_timer));
1021 1065
1022 qla4xxx_set_ddb_entry(ha, ddb_entry->fw_ddb_index, 0); 1066 qla4xxx_set_ddb_entry(ha, ddb_entry->fw_ddb_index, 0);
@@ -1039,17 +1083,17 @@ static int qla4xxx_config_nvram(struct scsi_qla_host *ha)
1039 } 1083 }
1040 1084
1041 /* Get EEPRom Parameters from NVRAM and validate */ 1085 /* Get EEPRom Parameters from NVRAM and validate */
1042 dev_info(&ha->pdev->dev, "Configuring NVRAM ...\n"); 1086 ql4_printk(KERN_INFO, ha, "Configuring NVRAM ...\n");
1043 if (qla4xxx_is_nvram_configuration_valid(ha) == QLA_SUCCESS) { 1087 if (qla4xxx_is_nvram_configuration_valid(ha) == QLA_SUCCESS) {
1044 spin_lock_irqsave(&ha->hardware_lock, flags); 1088 spin_lock_irqsave(&ha->hardware_lock, flags);
1045 extHwConfig.Asuint32_t = 1089 extHwConfig.Asuint32_t =
1046 rd_nvram_word(ha, eeprom_ext_hw_conf_offset(ha)); 1090 rd_nvram_word(ha, eeprom_ext_hw_conf_offset(ha));
1047 spin_unlock_irqrestore(&ha->hardware_lock, flags); 1091 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1048 } else { 1092 } else {
1049 dev_warn(&ha->pdev->dev, 1093 ql4_printk(KERN_WARNING, ha,
1050 "scsi%ld: %s: EEProm checksum invalid. " 1094 "scsi%ld: %s: EEProm checksum invalid. "
1051 "Please update your EEPROM\n", ha->host_no, 1095 "Please update your EEPROM\n", ha->host_no,
1052 __func__); 1096 __func__);
1053 1097
1054 /* Attempt to set defaults */ 1098 /* Attempt to set defaults */
1055 if (is_qla4010(ha)) 1099 if (is_qla4010(ha))
@@ -1073,12 +1117,21 @@ static int qla4xxx_config_nvram(struct scsi_qla_host *ha)
1073 return QLA_SUCCESS; 1117 return QLA_SUCCESS;
1074} 1118}
1075 1119
1076static void qla4x00_pci_config(struct scsi_qla_host *ha) 1120/**
1121 * qla4_8xxx_pci_config() - Setup ISP82xx PCI configuration registers.
1122 * @ha: HA context
1123 */
1124void qla4_8xxx_pci_config(struct scsi_qla_host *ha)
1125{
1126 pci_set_master(ha->pdev);
1127}
1128
1129void qla4xxx_pci_config(struct scsi_qla_host *ha)
1077{ 1130{
1078 uint16_t w; 1131 uint16_t w;
1079 int status; 1132 int status;
1080 1133
1081 dev_info(&ha->pdev->dev, "Configuring PCI space...\n"); 1134 ql4_printk(KERN_INFO, ha, "Configuring PCI space...\n");
1082 1135
1083 pci_set_master(ha->pdev); 1136 pci_set_master(ha->pdev);
1084 status = pci_set_mwi(ha->pdev); 1137 status = pci_set_mwi(ha->pdev);
@@ -1100,7 +1153,7 @@ static int qla4xxx_start_firmware_from_flash(struct scsi_qla_host *ha)
1100 unsigned long flags; 1153 unsigned long flags;
1101 uint32_t mbox_status; 1154 uint32_t mbox_status;
1102 1155
1103 dev_info(&ha->pdev->dev, "Starting firmware ...\n"); 1156 ql4_printk(KERN_INFO, ha, "Starting firmware ...\n");
1104 1157
1105 /* 1158 /*
1106 * Start firmware from flash ROM 1159 * Start firmware from flash ROM
@@ -1204,7 +1257,7 @@ int ql4xxx_lock_drvr_wait(struct scsi_qla_host *a)
1204 * This routine performs the necessary steps to start the firmware for 1257 * This routine performs the necessary steps to start the firmware for
1205 * the QLA4010 adapter. 1258 * the QLA4010 adapter.
1206 **/ 1259 **/
1207static int qla4xxx_start_firmware(struct scsi_qla_host *ha) 1260int qla4xxx_start_firmware(struct scsi_qla_host *ha)
1208{ 1261{
1209 unsigned long flags = 0; 1262 unsigned long flags = 0;
1210 uint32_t mbox_status; 1263 uint32_t mbox_status;
@@ -1283,7 +1336,8 @@ static int qla4xxx_start_firmware(struct scsi_qla_host *ha)
1283 if (soft_reset) { 1336 if (soft_reset) {
1284 DEBUG(printk("scsi%ld: %s: Issue Soft Reset\n", ha->host_no, 1337 DEBUG(printk("scsi%ld: %s: Issue Soft Reset\n", ha->host_no,
1285 __func__)); 1338 __func__));
1286 status = qla4xxx_soft_reset(ha); 1339 status = qla4xxx_soft_reset(ha); /* NOTE: acquires drvr
1340 * lock again, but ok */
1287 if (status == QLA_ERROR) { 1341 if (status == QLA_ERROR) {
1288 DEBUG(printk("scsi%d: %s: Soft Reset failed!\n", 1342 DEBUG(printk("scsi%d: %s: Soft Reset failed!\n",
1289 ha->host_no, __func__)); 1343 ha->host_no, __func__));
@@ -1304,7 +1358,6 @@ static int qla4xxx_start_firmware(struct scsi_qla_host *ha)
1304 1358
1305 ql4xxx_unlock_drvr(ha); 1359 ql4xxx_unlock_drvr(ha);
1306 if (status == QLA_SUCCESS) { 1360 if (status == QLA_SUCCESS) {
1307 qla4xxx_get_fw_version(ha);
1308 if (test_and_clear_bit(AF_GET_CRASH_RECORD, &ha->flags)) 1361 if (test_and_clear_bit(AF_GET_CRASH_RECORD, &ha->flags))
1309 qla4xxx_get_crash_record(ha); 1362 qla4xxx_get_crash_record(ha);
1310 } else { 1363 } else {
@@ -1331,18 +1384,21 @@ int qla4xxx_initialize_adapter(struct scsi_qla_host *ha,
1331 int status = QLA_ERROR; 1384 int status = QLA_ERROR;
1332 int8_t ip_address[IP_ADDR_LEN] = {0} ; 1385 int8_t ip_address[IP_ADDR_LEN] = {0} ;
1333 1386
1334 clear_bit(AF_ONLINE, &ha->flags);
1335 ha->eeprom_cmd_data = 0; 1387 ha->eeprom_cmd_data = 0;
1336 1388
1337 qla4x00_pci_config(ha); 1389 ql4_printk(KERN_INFO, ha, "Configuring PCI space...\n");
1390 ha->isp_ops->pci_config(ha);
1338 1391
1339 qla4xxx_disable_intrs(ha); 1392 ha->isp_ops->disable_intrs(ha);
1340 1393
1341 /* Initialize the Host adapter request/response queues and firmware */ 1394 /* Initialize the Host adapter request/response queues and firmware */
1342 if (qla4xxx_start_firmware(ha) == QLA_ERROR) 1395 if (ha->isp_ops->start_firmware(ha) == QLA_ERROR)
1343 goto exit_init_hba; 1396 goto exit_init_hba;
1344 1397
1345 if (qla4xxx_validate_mac_address(ha) == QLA_ERROR) 1398 if (qla4xxx_get_fw_version(ha) == QLA_ERROR)
1399 goto exit_init_hba;
1400
1401 if (ha->isp_ops->get_sys_info(ha) == QLA_ERROR)
1346 goto exit_init_hba; 1402 goto exit_init_hba;
1347 1403
1348 if (qla4xxx_init_local_data(ha) == QLA_ERROR) 1404 if (qla4xxx_init_local_data(ha) == QLA_ERROR)
@@ -1395,6 +1451,8 @@ int qla4xxx_initialize_adapter(struct scsi_qla_host *ha,
1395exit_init_online: 1451exit_init_online:
1396 set_bit(AF_ONLINE, &ha->flags); 1452 set_bit(AF_ONLINE, &ha->flags);
1397exit_init_hba: 1453exit_init_hba:
1454 DEBUG2(printk("scsi%ld: initialize adapter: %s\n", ha->host_no,
1455 status == QLA_ERROR ? "FAILED" : "SUCCEDED"));
1398 return status; 1456 return status;
1399} 1457}
1400 1458
@@ -1487,7 +1545,10 @@ int qla4xxx_process_ddb_changed(struct scsi_qla_host *ha, uint32_t fw_ddb_index,
1487 ddb_entry->fw_ddb_device_state, state, fw_ddb_index)); 1545 ddb_entry->fw_ddb_device_state, state, fw_ddb_index));
1488 if (old_fw_ddb_device_state == state && 1546 if (old_fw_ddb_device_state == state &&
1489 state == DDB_DS_SESSION_ACTIVE) { 1547 state == DDB_DS_SESSION_ACTIVE) {
1490 /* Do nothing, state not changed. */ 1548 if (atomic_read(&ddb_entry->state) != DDB_STATE_ONLINE) {
1549 atomic_set(&ddb_entry->state, DDB_STATE_ONLINE);
1550 iscsi_unblock_session(ddb_entry->sess);
1551 }
1491 return QLA_SUCCESS; 1552 return QLA_SUCCESS;
1492 } 1553 }
1493 1554
@@ -1511,7 +1572,7 @@ int qla4xxx_process_ddb_changed(struct scsi_qla_host *ha, uint32_t fw_ddb_index,
1511 } else { 1572 } else {
1512 /* Device went away, mark device missing */ 1573 /* Device went away, mark device missing */
1513 if (atomic_read(&ddb_entry->state) == DDB_STATE_ONLINE) { 1574 if (atomic_read(&ddb_entry->state) == DDB_STATE_ONLINE) {
1514 DEBUG2(dev_info(&ha->pdev->dev, "%s mark missing " 1575 DEBUG2(ql4_printk(KERN_INFO, ha, "%s mark missing "
1515 "ddb_entry 0x%p sess 0x%p conn 0x%p\n", 1576 "ddb_entry 0x%p sess 0x%p conn 0x%p\n",
1516 __func__, ddb_entry, 1577 __func__, ddb_entry,
1517 ddb_entry->sess, ddb_entry->conn)); 1578 ddb_entry->sess, ddb_entry->conn));
@@ -1543,9 +1604,20 @@ int qla4xxx_process_ddb_changed(struct scsi_qla_host *ha, uint32_t fw_ddb_index,
1543 atomic_set(&ddb_entry->relogin_timer, 0); 1604 atomic_set(&ddb_entry->relogin_timer, 0);
1544 atomic_set(&ddb_entry->retry_relogin_timer, 1605 atomic_set(&ddb_entry->retry_relogin_timer,
1545 ddb_entry->default_time2wait + 4); 1606 ddb_entry->default_time2wait + 4);
1607 DEBUG(printk("scsi%ld: %s: ddb[%d] "
1608 "initiate relogin after %d seconds\n",
1609 ha->host_no, __func__,
1610 ddb_entry->fw_ddb_index,
1611 ddb_entry->default_time2wait + 4));
1612 } else {
1613 DEBUG(printk("scsi%ld: %s: ddb[%d] "
1614 "relogin not initiated, state = %d, "
1615 "ddb_entry->flags = 0x%lx\n",
1616 ha->host_no, __func__,
1617 ddb_entry->fw_ddb_index,
1618 ddb_entry->fw_ddb_device_state,
1619 ddb_entry->flags));
1546 } 1620 }
1547 } 1621 }
1548
1549 return QLA_SUCCESS; 1622 return QLA_SUCCESS;
1550} 1623}
1551