• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-WNDR4500-V1.0.1.40_1.0.68/src/linux/linux-2.6/drivers/scsi/qla2xxx/

Lines Matching defs:ha

45 static int qla2x00_find_new_loop_id(scsi_qla_host_t *ha, fc_port_t *dev);
56 * ha = adapter block pointer.
62 qla2x00_initialize_adapter(scsi_qla_host_t *ha)
67 ha->flags.online = 0;
68 ha->flags.reset_active = 0;
69 atomic_set(&ha->loop_down_timer, LOOP_DOWN_TIME);
70 atomic_set(&ha->loop_state, LOOP_DOWN);
71 ha->device_flags = DFLG_NO_CABLE;
72 ha->dpc_flags = 0;
73 ha->flags.management_server_logged_in = 0;
74 ha->marker_needed = 0;
75 ha->mbx_flags = 0;
76 ha->isp_abort_cnt = 0;
77 ha->beacon_blink_led = 0;
78 set_bit(REGISTER_FDMI_NEEDED, &ha->dpc_flags);
80 qla_printk(KERN_INFO, ha, "Configuring PCI space...\n");
81 rval = ha->isp_ops.pci_config(ha);
84 ha->host_no));
88 ha->isp_ops.reset_chip(ha);
90 ha->isp_ops.get_flash_version(ha, ha->request_ring);
92 qla_printk(KERN_INFO, ha, "Configure NVRAM parameters...\n");
94 ha->isp_ops.nvram_config(ha);
96 if (ha->flags.disable_serdes) {
98 qla_printk(KERN_INFO, ha, "Masking HBA WWPN "
100 ha->port_name[0], ha->port_name[1],
101 ha->port_name[2], ha->port_name[3],
102 ha->port_name[4], ha->port_name[5],
103 ha->port_name[6], ha->port_name[7]);
107 qla_printk(KERN_INFO, ha, "Verifying loaded RISC code...\n");
109 if (qla2x00_isp_firmware(ha) != QLA_SUCCESS) {
110 rval = ha->isp_ops.chip_diag(ha);
113 rval = qla2x00_setup_chip(ha);
117 rval = qla2x00_init_rings(ha);
124 * @ha: HA context
129 qla2100_pci_config(scsi_qla_host_t *ha)
135 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
137 pci_set_master(ha->pdev);
138 ret = pci_set_mwi(ha->pdev);
140 pci_read_config_word(ha->pdev, PCI_COMMAND, &w);
142 pci_write_config_word(ha->pdev, PCI_COMMAND, w);
145 pci_read_config_dword(ha->pdev, PCI_ROM_ADDRESS, &d);
147 pci_write_config_dword(ha->pdev, PCI_ROM_ADDRESS, d);
150 spin_lock_irqsave(&ha->hardware_lock, flags);
151 ha->pci_attr = RD_REG_WORD(&reg->ctrl_status);
152 spin_unlock_irqrestore(&ha->hardware_lock, flags);
159 * @ha: HA context
164 qla2300_pci_config(scsi_qla_host_t *ha)
171 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
173 pci_set_master(ha->pdev);
174 ret = pci_set_mwi(ha->pdev);
176 pci_read_config_word(ha->pdev, PCI_COMMAND, &w);
179 if (IS_QLA2322(ha) || IS_QLA6322(ha))
181 pci_write_config_word(ha->pdev, PCI_COMMAND, w);
190 if (IS_QLA2300(ha)) {
191 spin_lock_irqsave(&ha->hardware_lock, flags);
207 ha->fb_rev = RD_FB_CMD_REG(ha, reg);
209 if (ha->fb_rev == FPM_2300)
210 pci_clear_mwi(ha->pdev);
225 spin_unlock_irqrestore(&ha->hardware_lock, flags);
228 pci_write_config_byte(ha->pdev, PCI_LATENCY_TIMER, 0x80);
231 pci_read_config_dword(ha->pdev, PCI_ROM_ADDRESS, &d);
233 pci_write_config_dword(ha->pdev, PCI_ROM_ADDRESS, d);
236 spin_lock_irqsave(&ha->hardware_lock, flags);
237 ha->pci_attr = RD_REG_WORD(&reg->ctrl_status);
238 spin_unlock_irqrestore(&ha->hardware_lock, flags);
245 * @ha: HA context
250 qla24xx_pci_config(scsi_qla_host_t *ha)
256 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
259 pci_set_master(ha->pdev);
260 ret = pci_set_mwi(ha->pdev);
262 pci_read_config_word(ha->pdev, PCI_COMMAND, &w);
265 pci_write_config_word(ha->pdev, PCI_COMMAND, w);
267 pci_write_config_byte(ha->pdev, PCI_LATENCY_TIMER, 0x80);
270 pcix_cmd_reg = pci_find_capability(ha->pdev, PCI_CAP_ID_PCIX);
275 pci_read_config_word(ha->pdev, pcix_cmd_reg, &pcix_cmd);
278 pci_write_config_word(ha->pdev, pcix_cmd_reg, pcix_cmd);
282 pcie_dctl_reg = pci_find_capability(ha->pdev, PCI_CAP_ID_EXP);
287 pci_read_config_word(ha->pdev, pcie_dctl_reg, &pcie_dctl);
290 pci_write_config_word(ha->pdev, pcie_dctl_reg, pcie_dctl);
294 pci_read_config_dword(ha->pdev, PCI_ROM_ADDRESS, &d);
296 pci_write_config_dword(ha->pdev, PCI_ROM_ADDRESS, d);
298 pci_read_config_word(ha->pdev, PCI_REVISION_ID, &ha->chip_revision);
301 spin_lock_irqsave(&ha->hardware_lock, flags);
302 ha->pci_attr = RD_REG_DWORD(&reg->ctrl_status);
303 spin_unlock_irqrestore(&ha->hardware_lock, flags);
310 * @ha: HA context
315 qla2x00_isp_firmware(scsi_qla_host_t *ha)
322 if (ha->flags.disable_risc_code_load) {
324 ha->host_no));
325 qla_printk(KERN_INFO, ha, "RISC CODE NOT loaded\n");
328 rval = qla2x00_verify_checksum(ha, ha->fw_srisc_address);
333 ha->host_no));
341 * @ha: HA context
346 qla2x00_reset_chip(scsi_qla_host_t *ha)
349 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
353 ha->isp_ops.disable_intrs(ha);
355 spin_lock_irqsave(&ha->hardware_lock, flags);
359 pci_read_config_word(ha->pdev, PCI_COMMAND, &cmd);
361 pci_write_config_word(ha->pdev, PCI_COMMAND, cmd);
363 if (!IS_QLA2100(ha)) {
366 if (IS_QLA2200(ha) || IS_QLA2300(ha)) {
387 if (!IS_QLA2200(ha)) {
397 if (IS_QLA2200(ha)) {
398 WRT_FB_CMD_REG(ha, reg, 0xa000);
399 RD_FB_CMD_REG(ha, reg); /* PCI Posting. */
401 WRT_FB_CMD_REG(ha, reg, 0x00fc);
405 if ((RD_FB_CMD_REG(ha, reg) & 0xff) == 0)
431 if (IS_QLA2100(ha) || IS_QLA2200(ha) || IS_QLA2300(ha)) {
456 if (IS_QLA2100(ha) || IS_QLA2200(ha) || IS_QLA2300(ha)) {
458 if (RD_MAILBOX_REG(ha, reg, 0) != MBS_BUSY)
468 pci_write_config_word(ha->pdev, PCI_COMMAND, cmd);
471 if (!IS_QLA2100(ha)) {
476 spin_unlock_irqrestore(&ha->hardware_lock, flags);
481 * @ha: HA context
486 qla24xx_reset_risc(scsi_qla_host_t *ha)
489 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
493 spin_lock_irqsave(&ha->hardware_lock, flags);
506 pci_read_config_word(ha->pdev, PCI_COMMAND, &wd);
541 spin_unlock_irqrestore(&ha->hardware_lock, flags);
546 * @ha: HA context
551 qla24xx_reset_chip(scsi_qla_host_t *ha)
553 ha->isp_ops.disable_intrs(ha);
556 qla24xx_reset_risc(ha);
561 * @ha: HA context
566 qla2x00_chip_diag(scsi_qla_host_t *ha)
569 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
579 ha->host_no, (u_long)&reg->flash_address));
581 spin_lock_irqsave(&ha->hardware_lock, flags);
602 ha->host_no));
608 if (IS_QLA2100(ha) || IS_QLA2200(ha) || IS_QLA2300(ha)) {
609 data = qla2x00_debounce_register(MAILBOX_REG(ha, reg, 0));
612 data = RD_MAILBOX_REG(ha, reg, 0);
622 DEBUG3(printk("scsi(%ld): Checking product ID of chip\n", ha->host_no));
624 mb[1] = RD_MAILBOX_REG(ha, reg, 1);
625 mb[2] = RD_MAILBOX_REG(ha, reg, 2);
626 mb[3] = RD_MAILBOX_REG(ha, reg, 3);
627 mb[4] = qla2x00_debounce_register(MAILBOX_REG(ha, reg, 4));
630 qla_printk(KERN_WARNING, ha,
635 ha->product_id[0] = mb[1];
636 ha->product_id[1] = mb[2];
637 ha->product_id[2] = mb[3];
638 ha->product_id[3] = mb[4];
641 if (ha->request_q_length > 1024)
642 ha->fw_transfer_size = REQUEST_ENTRY_SIZE * 1024;
644 ha->fw_transfer_size = REQUEST_ENTRY_SIZE *
645 ha->request_q_length;
647 if (IS_QLA2200(ha) &&
648 RD_MAILBOX_REG(ha, reg, 7) == QLA2200A_RISC_ROM_VER) {
651 ha->host_no));
653 ha->device_type |= DT_ISP2200A;
654 ha->fw_transfer_size = 128;
658 spin_unlock_irqrestore(&ha->hardware_lock, flags);
660 DEBUG3(printk("scsi(%ld): Checking mailboxes.\n", ha->host_no));
661 rval = qla2x00_mbx_reg_test(ha);
664 ha->host_no));
665 qla_printk(KERN_WARNING, ha,
672 spin_lock_irqsave(&ha->hardware_lock, flags);
677 "****\n", ha->host_no));
679 spin_unlock_irqrestore(&ha->hardware_lock, flags);
686 * @ha: HA context
691 qla24xx_chip_diag(scsi_qla_host_t *ha)
696 qla24xx_reset_risc(ha);
698 ha->fw_transfer_size = REQUEST_ENTRY_SIZE * 1024;
700 rval = qla2x00_mbx_reg_test(ha);
703 ha->host_no));
704 qla_printk(KERN_WARNING, ha,
715 qla2x00_alloc_fw_dump(scsi_qla_host_t *ha)
723 if (ha->fw_dump) {
724 qla_printk(KERN_WARNING, ha,
729 ha->fw_dumped = 0;
731 if (IS_QLA2100(ha) || IS_QLA2200(ha)) {
733 } else if (IS_QLA23XX(ha)) {
735 mem_size = (ha->fw_memory_size - 0x11000 + 1) *
737 } else if (IS_QLA24XX(ha) || IS_QLA54XX(ha)) {
739 mem_size = (ha->fw_memory_size - 0x100000 + 1) *
743 eft = dma_alloc_coherent(&ha->pdev->dev, EFT_SIZE, &eft_dma,
746 qla_printk(KERN_WARNING, ha, "Unable to allocate "
751 rval = qla2x00_trace_control(ha, TC_ENABLE, eft_dma,
754 qla_printk(KERN_WARNING, ha, "Unable to initialize "
756 dma_free_coherent(&ha->pdev->dev, EFT_SIZE, eft,
761 qla_printk(KERN_INFO, ha, "Allocated (%d KB) for EFT...\n",
766 ha->eft_dma = eft_dma;
767 ha->eft = eft;
770 req_q_size = ha->request_q_length * sizeof(request_t);
771 rsp_q_size = ha->response_q_length * sizeof(response_t);
777 ha->fw_dump = vmalloc(dump_size);
778 if (!ha->fw_dump) {
779 qla_printk(KERN_WARNING, ha, "Unable to allocate (%d KB) for "
782 if (ha->eft) {
783 dma_free_coherent(&ha->pdev->dev, eft_size, ha->eft,
784 ha->eft_dma);
785 ha->eft = NULL;
786 ha->eft_dma = 0;
791 qla_printk(KERN_INFO, ha, "Allocated (%d KB) for firmware dump...\n",
794 ha->fw_dump_len = dump_size;
795 ha->fw_dump->signature[0] = 'Q';
796 ha->fw_dump->signature[1] = 'L';
797 ha->fw_dump->signature[2] = 'G';
798 ha->fw_dump->signature[3] = 'C';
799 ha->fw_dump->version = __constant_htonl(1);
801 ha->fw_dump->fixed_size = htonl(fixed_size);
802 ha->fw_dump->mem_size = htonl(mem_size);
803 ha->fw_dump->req_q_size = htonl(req_q_size);
804 ha->fw_dump->rsp_q_size = htonl(rsp_q_size);
806 ha->fw_dump->eft_size = htonl(eft_size);
807 ha->fw_dump->eft_addr_l = htonl(LSD(ha->eft_dma));
808 ha->fw_dump->eft_addr_h = htonl(MSD(ha->eft_dma));
810 ha->fw_dump->header_size =
816 * @ha: HA context
821 qla2x00_resize_request_q(scsi_qla_host_t *ha)
830 if (IS_QLA2100(ha) || IS_QLA2200(ha))
834 rval = qla2x00_get_resource_cnts(ha, NULL, NULL, NULL, &fw_iocb_cnt);
840 if (ha->request_q_length >= request_q_length)
844 request_ring = dma_alloc_coherent(&ha->pdev->dev,
851 qla_printk(KERN_INFO, ha, "Extended memory detected (%d KB)...\n",
852 (ha->fw_memory_size + 1) / 1024);
853 qla_printk(KERN_INFO, ha, "Resizing request queue depth "
854 "(%d -> %d)...\n", ha->request_q_length, request_q_length);
857 dma_free_coherent(&ha->pdev->dev,
858 (ha->request_q_length + 1) * sizeof(request_t), ha->request_ring,
859 ha->request_dma);
862 ha->request_q_length = request_q_length;
863 ha->request_ring = request_ring;
864 ha->request_dma = request_dma;
869 * @ha: HA context
874 qla2x00_setup_chip(scsi_qla_host_t *ha)
880 rval = ha->isp_ops.load_risc(ha, &srisc_address);
883 "code.\n", ha->host_no));
885 rval = qla2x00_verify_checksum(ha, srisc_address);
889 "firmware.\n", ha->host_no));
891 rval = qla2x00_execute_fw(ha, srisc_address);
893 if (rval == QLA_SUCCESS && ha->fw_major_version == 0) {
894 qla2x00_get_fw_version(ha,
895 &ha->fw_major_version,
896 &ha->fw_minor_version,
897 &ha->fw_subminor_version,
898 &ha->fw_attributes, &ha->fw_memory_size);
899 qla2x00_resize_request_q(ha);
902 qla2x00_alloc_fw_dump(ha);
907 ha->host_no));
913 ha->host_no));
921 * @ha: HA context
929 qla2x00_init_response_q_entries(scsi_qla_host_t *ha)
934 pkt = ha->response_ring_ptr;
935 for (cnt = 0; cnt < ha->response_q_length; cnt++) {
944 * @ha: HA context
949 qla2x00_update_fw_options(scsi_qla_host_t *ha)
953 memset(ha->fw_options, 0, sizeof(ha->fw_options));
954 qla2x00_get_fw_options(ha, ha->fw_options);
956 if (IS_QLA2100(ha) || IS_QLA2200(ha))
961 ha->host_no));
962 DEBUG3(qla2x00_dump_buffer((uint8_t *)&ha->fw_seriallink_options,
963 sizeof(ha->fw_seriallink_options)));
965 ha->fw_options[1] &= ~FO1_SET_EMPHASIS_SWING;
966 if (ha->fw_seriallink_options[3] & BIT_2) {
967 ha->fw_options[1] |= FO1_SET_EMPHASIS_SWING;
970 swing = ha->fw_seriallink_options[2] & (BIT_2 | BIT_1 | BIT_0);
971 emphasis = (ha->fw_seriallink_options[2] &
973 tx_sens = ha->fw_seriallink_options[0] &
975 rx_sens = (ha->fw_seriallink_options[0] &
977 ha->fw_options[10] = (emphasis << 14) | (swing << 8);
978 if (IS_QLA2300(ha) || IS_QLA2312(ha) || IS_QLA6312(ha)) {
981 ha->fw_options[10] |= (tx_sens << 4) | rx_sens;
982 } else if (IS_QLA2322(ha) || IS_QLA6322(ha))
983 ha->fw_options[10] |= BIT_5 |
988 swing = (ha->fw_seriallink_options[2] &
990 emphasis = ha->fw_seriallink_options[3] & (BIT_1 | BIT_0);
991 tx_sens = ha->fw_seriallink_options[1] &
993 rx_sens = (ha->fw_seriallink_options[1] &
995 ha->fw_options[11] = (emphasis << 14) | (swing << 8);
996 if (IS_QLA2300(ha) || IS_QLA2312(ha) || IS_QLA6312(ha)) {
999 ha->fw_options[11] |= (tx_sens << 4) | rx_sens;
1000 } else if (IS_QLA2322(ha) || IS_QLA6322(ha))
1001 ha->fw_options[11] |= BIT_5 |
1008 ha->fw_options[3] |= BIT_13;
1011 if (ha->flags.enable_led_scheme)
1012 ha->fw_options[2] |= BIT_12;
1015 if (IS_QLA6312(ha))
1016 ha->fw_options[2] |= BIT_13;
1019 qla2x00_set_fw_options(ha, ha->fw_options);
1023 qla24xx_update_fw_options(scsi_qla_host_t *ha)
1028 if ((le16_to_cpu(ha->fw_seriallink_options24[0]) & BIT_0) == 0)
1031 rval = qla2x00_set_serdes_params(ha,
1032 le16_to_cpu(ha->fw_seriallink_options24[1]),
1033 le16_to_cpu(ha->fw_seriallink_options24[2]),
1034 le16_to_cpu(ha->fw_seriallink_options24[3]));
1036 qla_printk(KERN_WARNING, ha,
1042 qla2x00_config_rings(struct scsi_qla_host *ha)
1044 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
1047 ha->init_cb->request_q_outpointer = __constant_cpu_to_le16(0);
1048 ha->init_cb->response_q_inpointer = __constant_cpu_to_le16(0);
1049 ha->init_cb->request_q_length = cpu_to_le16(ha->request_q_length);
1050 ha->init_cb->response_q_length = cpu_to_le16(ha->response_q_length);
1051 ha->init_cb->request_q_address[0] = cpu_to_le32(LSD(ha->request_dma));
1052 ha->init_cb->request_q_address[1] = cpu_to_le32(MSD(ha->request_dma));
1053 ha->init_cb->response_q_address[0] = cpu_to_le32(LSD(ha->response_dma));
1054 ha->init_cb->response_q_address[1] = cpu_to_le32(MSD(ha->response_dma));
1056 WRT_REG_WORD(ISP_REQ_Q_IN(ha, reg), 0);
1057 WRT_REG_WORD(ISP_REQ_Q_OUT(ha, reg), 0);
1058 WRT_REG_WORD(ISP_RSP_Q_IN(ha, reg), 0);
1059 WRT_REG_WORD(ISP_RSP_Q_OUT(ha, reg), 0);
1060 RD_REG_WORD(ISP_RSP_Q_OUT(ha, reg)); /* PCI Posting. */
1064 qla24xx_config_rings(struct scsi_qla_host *ha)
1066 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
1070 icb = (struct init_cb_24xx *)ha->init_cb;
1073 icb->request_q_length = cpu_to_le16(ha->request_q_length);
1074 icb->response_q_length = cpu_to_le16(ha->response_q_length);
1075 icb->request_q_address[0] = cpu_to_le32(LSD(ha->request_dma));
1076 icb->request_q_address[1] = cpu_to_le32(MSD(ha->request_dma));
1077 icb->response_q_address[0] = cpu_to_le32(LSD(ha->response_dma));
1078 icb->response_q_address[1] = cpu_to_le32(MSD(ha->response_dma));
1089 * @ha: HA context
1097 qla2x00_init_rings(scsi_qla_host_t *ha)
1103 spin_lock_irqsave(&ha->hardware_lock, flags);
1107 ha->outstanding_cmds[cnt] = NULL;
1109 ha->current_outstanding_cmd = 0;
1112 ha->rscn_in_ptr = 0;
1113 ha->rscn_out_ptr = 0;
1116 ha->request_ring_ptr = ha->request_ring;
1117 ha->req_ring_index = 0;
1118 ha->req_q_cnt = ha->request_q_length;
1119 ha->response_ring_ptr = ha->response_ring;
1120 ha->rsp_ring_index = 0;
1123 qla2x00_init_response_q_entries(ha);
1125 ha->isp_ops.config_rings(ha);
1127 spin_unlock_irqrestore(&ha->hardware_lock, flags);
1130 ha->isp_ops.update_fw_options(ha);
1132 DEBUG(printk("scsi(%ld): Issue init firmware.\n", ha->host_no));
1133 rval = qla2x00_init_firmware(ha, ha->init_cb_size);
1136 ha->host_no));
1139 ha->host_no));
1147 * @ha: HA context
1152 qla2x00_fw_ready(scsi_qla_host_t *ha)
1169 if ((wait_time = (ha->retry_count*ha->login_timeout) + 5) < min_wait) {
1180 if (!ha->flags.init_done)
1181 qla_printk(KERN_INFO, ha, "Waiting for LIP to complete...\n");
1184 ha->host_no));
1187 rval = qla2x00_get_firmware_state(ha, &fw_state);
1190 ha->device_flags &= ~DFLG_NO_CABLE;
1194 ha->host_no));
1196 qla2x00_get_retry_cnt(ha, &ha->retry_count,
1197 &ha->login_timeout, &ha->r_a_tov);
1205 if (atomic_read(&ha->loop_down_timer) &&
1211 qla_printk(KERN_INFO, ha,
1214 ha->device_flags |= DFLG_NO_CABLE;
1231 ha->host_no, fw_state, jiffies));
1235 ha->host_no, fw_state, jiffies));
1239 ha->host_no));
1250 * ha = adapter state pointer.
1259 qla2x00_configure_hba(scsi_qla_host_t *ha)
1270 rval = qla2x00_get_adapter_id(ha,
1273 if (LOOP_TRANSITION(ha) || atomic_read(&ha->loop_down_timer) ||
1276 __func__, ha->host_no));
1278 qla_printk(KERN_WARNING, ha,
1280 set_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
1286 qla_printk(KERN_INFO, ha,
1291 ha->loop_id = loop_id;
1294 ha->min_external_loopid = SNS_FIRST_LOOP_ID;
1295 ha->operating_mode = LOOP;
1300 ha->host_no));
1301 ha->current_topology = ISP_CFG_NL;
1307 ha->host_no));
1308 ha->current_topology = ISP_CFG_FL;
1314 ha->host_no));
1315 ha->operating_mode = P2P;
1316 ha->current_topology = ISP_CFG_N;
1322 ha->host_no));
1323 ha->operating_mode = P2P;
1324 ha->current_topology = ISP_CFG_F;
1331 ha->host_no, topo));
1332 ha->current_topology = ISP_CFG_NL;
1339 ha->d_id.b.domain = domain;
1340 ha->d_id.b.area = area;
1341 ha->d_id.b.al_pa = al_pa;
1343 if (!ha->flags.init_done)
1344 qla_printk(KERN_INFO, ha,
1346 connect_type, ha->loop_id);
1349 DEBUG2_3(printk("scsi(%ld): FAILED.\n", ha->host_no));
1351 DEBUG3(printk("scsi(%ld): exiting normally.\n", ha->host_no));
1358 qla2x00_set_model_info(scsi_qla_host_t *ha, uint8_t *model, size_t len, char *def)
1364 strncpy(ha->model_number, model, len);
1365 st = en = ha->model_number;
1373 index = (ha->pdev->subsystem_device & 0xff);
1374 if (ha->pdev->subsystem_vendor == PCI_VENDOR_ID_QLOGIC &&
1376 ha->model_desc = qla2x00_model_name[index * 2 + 1];
1378 index = (ha->pdev->subsystem_device & 0xff);
1379 if (ha->pdev->subsystem_vendor == PCI_VENDOR_ID_QLOGIC &&
1381 strcpy(ha->model_number,
1383 ha->model_desc = qla2x00_model_name[index * 2 + 1];
1385 strcpy(ha->model_number, def);
1393 static void qla2xxx_nvram_wwn_from_ofw(scsi_qla_host_t *ha, nvram_t *nv)
1396 struct pci_dev *pdev = ha->pdev;
1415 * ha = adapter block pointer.
1425 qla2x00_nvram_config(scsi_qla_host_t *ha)
1431 init_cb_t *icb = ha->init_cb;
1432 nvram_t *nv = (nvram_t *)ha->request_ring;
1433 uint8_t *ptr = (uint8_t *)ha->request_ring;
1434 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
1439 ha->nvram_size = sizeof(nvram_t);
1440 ha->nvram_base = 0;
1441 if (!IS_QLA2100(ha) && !IS_QLA2200(ha) && !IS_QLA2300(ha))
1443 ha->nvram_base = 0x80;
1446 ha->isp_ops.read_nvram(ha, ptr, ha->nvram_base, ha->nvram_size);
1447 for (cnt = 0, chksum = 0; cnt < ha->nvram_size; cnt++)
1450 DEBUG5(printk("scsi(%ld): Contents of NVRAM\n", ha->host_no));
1451 DEBUG5(qla2x00_dump_buffer((uint8_t *)ha->request_ring,
1452 ha->nvram_size));
1458 qla_printk(KERN_WARNING, ha, "Inconsistent NVRAM detected: "
1461 qla_printk(KERN_WARNING, ha, "Falling back to functioning (yet "
1467 memset(nv, 0, ha->nvram_size);
1470 if (IS_QLA23XX(ha)) {
1477 } else if (IS_QLA2200(ha)) {
1483 } else if (IS_QLA2100(ha)) {
1498 qla2xxx_nvram_wwn_from_ofw(ha, nv);
1523 if (IS_QLA23XX(ha))
1529 memset(icb, 0, ha->init_cb_size);
1539 if (IS_QLA23XX(ha)) {
1544 if (IS_QLA2300(ha)) {
1545 if (ha->fb_rev == FPM_2310) {
1546 strcpy(ha->model_number, "QLA2310");
1548 strcpy(ha->model_number, "QLA2300");
1551 qla2x00_set_model_info(ha, nv->model_number,
1554 } else if (IS_QLA2200(ha)) {
1566 strcpy(ha->model_number, "QLA22xx");
1567 } else /*if (IS_QLA2100(ha))*/ {
1568 strcpy(ha->model_number, "QLA2100");
1607 ha->flags.disable_risc_code_load = ((nv->host_p[0] & BIT_4) ? 1 : 0);
1609 if (!IS_QLA2100(ha) && !IS_QLA2200(ha))
1610 ha->flags.disable_risc_code_load = 0;
1611 ha->flags.enable_lip_reset = ((nv->host_p[1] & BIT_1) ? 1 : 0);
1612 ha->flags.enable_lip_full_login = ((nv->host_p[1] & BIT_2) ? 1 : 0);
1613 ha->flags.enable_target_reset = ((nv->host_p[1] & BIT_3) ? 1 : 0);
1614 ha->flags.enable_led_scheme = (nv->special_options[1] & BIT_4) ? 1 : 0;
1615 ha->flags.disable_serdes = 0;
1617 ha->operating_mode =
1620 memcpy(ha->fw_seriallink_options, nv->seriallink_options,
1621 sizeof(ha->fw_seriallink_options));
1624 ha->serial0 = icb->port_name[5];
1625 ha->serial1 = icb->port_name[6];
1626 ha->serial2 = icb->port_name[7];
1627 ha->node_name = icb->node_name;
1628 ha->port_name = icb->port_name;
1632 ha->retry_count = nv->retry_count;
1639 ha->login_timeout = nv->login_timeout;
1643 ha->r_a_tov = 200;
1645 ha->loop_reset_delay = nv->reset_delay;
1658 ha->loop_down_abort_time =
1661 ha->link_down_timeout = nv->link_down_timeout;
1662 ha->loop_down_abort_time =
1663 (LOOP_DOWN_TIME - ha->link_down_timeout);
1669 ha->port_down_retry_count = nv->port_down_retry_count;
1671 ha->port_down_retry_count = qlport_down_retry;
1673 ha->login_retry_count = nv->retry_count;
1674 if (ha->port_down_retry_count == nv->port_down_retry_count &&
1675 ha->port_down_retry_count > 3)
1676 ha->login_retry_count = ha->port_down_retry_count;
1677 else if (ha->port_down_retry_count > (int)ha->login_retry_count)
1678 ha->login_retry_count = ha->port_down_retry_count;
1680 ha->login_retry_count = ql2xloginretrycount;
1687 if (IS_QLA2100(ha) || IS_QLA2200(ha)) {
1696 ha->flags.process_response_queue = 1;
1699 if (!ha->flags.init_done) {
1700 ha->zio_mode = icb->add_firmware_options[0] &
1702 ha->zio_timer = icb->interrupt_delay_timer ?
1707 ha->flags.process_response_queue = 0;
1708 if (ha->zio_mode != QLA_ZIO_DISABLED) {
1709 ha->zio_mode = QLA_ZIO_MODE_6;
1712 "delay (%d us).\n", ha->host_no, ha->zio_mode,
1713 ha->zio_timer * 100));
1714 qla_printk(KERN_INFO, ha,
1716 ha->zio_mode, ha->zio_timer * 100);
1718 icb->add_firmware_options[0] |= (uint8_t)ha->zio_mode;
1719 icb->interrupt_delay_timer = (uint8_t)ha->zio_timer;
1720 ha->flags.process_response_queue = 1;
1726 "scsi(%ld): NVRAM configuration failed!\n", ha->host_no));
1749 * @ha: HA context
1755 qla2x00_alloc_fcport(scsi_qla_host_t *ha, gfp_t flags)
1765 fcport->ha = ha;
1781 * ha = adapter block pointer.
1789 qla2x00_configure_loop(scsi_qla_host_t *ha)
1797 if (test_bit(LOCAL_LOOP_UPDATE, &ha->dpc_flags)) {
1798 rval = qla2x00_configure_hba(ha);
1801 ha->host_no));
1806 save_flags = flags = ha->dpc_flags;
1808 ha->host_no, flags));
1814 clear_bit(LOCAL_LOOP_UPDATE, &ha->dpc_flags);
1815 clear_bit(RSCN_UPDATE, &ha->dpc_flags);
1818 if (ha->current_topology == ISP_CFG_FL &&
1821 ha->flags.rscn_queue_overflow = 1;
1824 } else if (ha->current_topology == ISP_CFG_F &&
1827 ha->flags.rscn_queue_overflow = 1;
1831 } else if (ha->current_topology == ISP_CFG_N) {
1834 } else if (!ha->flags.online ||
1837 ha->flags.rscn_queue_overflow = 1;
1843 if (test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags)) {
1846 rval = qla2x00_configure_local_loop(ha);
1851 if (LOOP_TRANSITION(ha)) {
1854 rval = qla2x00_configure_fabric(ha);
1859 if (atomic_read(&ha->loop_down_timer) ||
1860 test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags)) {
1863 atomic_set(&ha->loop_state, LOOP_READY);
1865 DEBUG(printk("scsi(%ld): LOOP READY\n", ha->host_no));
1871 __func__, ha->host_no));
1877 if (test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags)) {
1879 set_bit(LOCAL_LOOP_UPDATE, &ha->dpc_flags);
1881 set_bit(RSCN_UPDATE, &ha->dpc_flags);
1894 * ha = adapter block pointer.
1900 qla2x00_configure_local_loop(scsi_qla_host_t *ha)
1917 DEBUG3(printk("scsi(%ld): Getting FCAL position map\n", ha->host_no));
1918 DEBUG3(qla2x00_get_fcal_position_map(ha, NULL));
1921 memset(ha->gid_list, 0, GID_LIST_SIZE);
1922 rval = qla2x00_get_id_list(ha, ha->gid_list, ha->gid_list_dma,
1928 ha->host_no, entries));
1929 DEBUG3(qla2x00_dump_buffer((uint8_t *)ha->gid_list,
1933 new_fcport = qla2x00_alloc_fcport(ha, GFP_KERNEL);
1943 list_for_each_entry(fcport, &ha->fcports, list) {
1950 ha->host_no, fcport->loop_id));
1958 id_iter = (char *)ha->gid_list;
1963 if (IS_QLA2100(ha) || IS_QLA2200(ha))
1969 id_iter += ha->gid_list_info_size;
1977 (area != ha->d_id.b.area || domain != ha->d_id.b.domain))
1989 rval2 = qla2x00_get_port_database(ha, new_fcport, 0);
1994 ha->host_no, rval2, new_fcport->loop_id));
1996 ha->host_no));
1997 set_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags);
2004 list_for_each_entry(fcport, &ha->fcports, list) {
2024 list_add_tail(&new_fcport->list, &ha->fcports);
2028 new_fcport = qla2x00_alloc_fcport(ha, GFP_KERNEL);
2037 switch (ha->link_data_rate) {
2049 qla2x00_update_fcport(ha, fcport);
2059 "rval=%x\n", ha->host_no, rval));
2063 ha->device_flags |= DFLG_LOCAL_DEVICES;
2064 ha->device_flags &= ~DFLG_RETRY_LOCAL_DEVICES;
2071 qla2x00_probe_for_all_luns(scsi_qla_host_t *ha)
2075 qla2x00_mark_all_devices_lost(ha, 0);
2076 list_for_each_entry(fcport, &ha->fcports, list) {
2080 qla2x00_update_fcport(ha, fcport);
2085 qla2x00_iidma_fcport(scsi_qla_host_t *ha, fc_port_t *fcport)
2092 if (!IS_QLA24XX(ha))
2108 ha->host_no, fcport->port_name[0], fcport->port_name[1],
2119 rval = qla2x00_set_idma_speed(ha, fcport->loop_id, port_speed, mb);
2123 ha->host_no, fcport->port_name[0], fcport->port_name[1],
2129 DEBUG2(qla_printk(KERN_INFO, ha,
2141 qla2x00_reg_remote_port(scsi_qla_host_t *ha, fc_port_t *fcport)
2157 rport = fc_remote_port_add(ha->host, 0, &rport_ids);
2159 qla_printk(KERN_WARNING, ha,
2178 rport->scsi_target_id < ha->host->max_id)
2187 * ha = adapter block pointer.
2198 qla2x00_update_fcport(scsi_qla_host_t *ha, fc_port_t *fcport)
2200 fcport->ha = ha;
2202 fcport->port_login_retry_count = ha->port_down_retry_count *
2204 atomic_set(&fcport->port_down_timer, ha->port_down_retry_count *
2208 qla2x00_iidma_fcport(ha, fcport);
2212 qla2x00_reg_remote_port(ha, fcport);
2220 * ha = adapter block pointer.
2227 qla2x00_configure_fabric(scsi_qla_host_t *ha)
2237 if (IS_QLA24XX(ha) || IS_QLA54XX(ha))
2241 rval = qla2x00_get_port_name(ha, loop_id, ha->fabric_node_name, 1);
2244 "Port\n", ha->host_no));
2246 ha->device_flags &= ~SWITCH_FOUND;
2249 ha->device_flags |= SWITCH_FOUND;
2252 rval2 = qla2x00_device_resync(ha);
2260 test_and_clear_bit(REGISTER_FDMI_NEEDED, &ha->dpc_flags))
2261 qla2x00_fdmi_register(ha);
2264 if (IS_QLA24XX(ha) || IS_QLA54XX(ha))
2268 ha->isp_ops.fabric_login(ha, loop_id, 0xff, 0xff,
2271 DEBUG2(qla_printk(KERN_INFO, ha,
2278 if (test_and_clear_bit(REGISTER_FC4_NEEDED, &ha->dpc_flags)) {
2279 if (qla2x00_rft_id(ha)) {
2282 "TYPE failed.\n", ha->host_no));
2284 if (qla2x00_rff_id(ha)) {
2287 "Features failed.\n", ha->host_no));
2289 if (qla2x00_rnn_id(ha)) {
2292 "failed.\n", ha->host_no));
2293 } else if (qla2x00_rsnn_nn(ha)) {
2296 "Node Name failed.\n", ha->host_no));
2300 rval = qla2x00_find_all_fabric_devs(ha, &new_fcports);
2308 list_for_each_entry(fcport, &ha->fcports, list) {
2309 if (test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags))
2316 qla2x00_mark_device_lost(ha, fcport,
2322 ha->isp_ops.fabric_logout(ha,
2333 next_loopid = ha->min_external_loopid;
2339 list_for_each_entry(fcport, &ha->fcports, list) {
2340 if (atomic_read(&ha->loop_down_timer) ||
2341 test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags))
2350 rval = qla2x00_find_new_loop_id(ha, fcport);
2357 qla2x00_fabric_dev_login(ha, fcport, &next_loopid);
2369 if (atomic_read(&ha->loop_down_timer) ||
2370 test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags))
2375 rval = qla2x00_find_new_loop_id(ha, fcport);
2382 list_move_tail(&fcport->list, &ha->fcports);
2385 qla2x00_fabric_dev_login(ha, fcport, &next_loopid);
2397 "rval=%d\n", ha->host_no, rval));
2408 * ha = adapter block pointer.
2418 qla2x00_find_all_fabric_devs(scsi_qla_host_t *ha, struct list_head *new_fcports)
2437 "on GA_NXT\n", ha->host_no));
2440 if (qla2x00_gid_pt(ha, swl) != QLA_SUCCESS) {
2443 } else if (qla2x00_gpn_id(ha, swl) != QLA_SUCCESS) {
2446 } else if (qla2x00_gnn_id(ha, swl) != QLA_SUCCESS) {
2449 } else if (qla2x00_gfpn_id(ha, swl) == QLA_SUCCESS) {
2450 qla2x00_gpsc(ha, swl);
2456 new_fcport = qla2x00_alloc_fcport(ha, GFP_KERNEL);
2468 loop_id = ha->min_external_loopid;
2469 for (; loop_id <= ha->last_loop_id; loop_id++) {
2470 if (qla2x00_is_reserved_id(ha, loop_id))
2473 if (atomic_read(&ha->loop_down_timer) || LOOP_TRANSITION(ha))
2496 rval = qla2x00_ga_nxt(ha, new_fcport);
2498 qla_printk(KERN_WARNING, ha,
2517 ha->host_no, new_fcport->d_id.b.domain,
2523 if (new_fcport->d_id.b24 == ha->d_id.b24)
2528 (ha->d_id.b24 & 0xffff00)) && ha->current_topology ==
2538 list_for_each_entry(fcport, &ha->fcports, list) {
2582 ha->isp_ops.fabric_logout(ha, fcport->loop_id,
2599 new_fcport = qla2x00_alloc_fcport(ha, GFP_KERNEL);
2612 ha->device_flags |= DFLG_FABRIC_DEVICES;
2622 * ha: adapter state pointer.
2632 qla2x00_find_new_loop_id(scsi_qla_host_t *ha, fc_port_t *dev)
2646 if (dev->loop_id == ha->loop_id) {
2651 while (qla2x00_is_reserved_id(ha, dev->loop_id)) {
2656 if (dev->loop_id > ha->last_loop_id) {
2658 dev->loop_id = ha->min_external_loopid;
2664 list_for_each_entry(fcport, &ha->fcports, list) {
2696 * ha = adapter block pointer.
2702 qla2x00_device_resync(scsi_qla_host_t *ha)
2714 while (ha->rscn_out_ptr != ha->rscn_in_ptr ||
2715 ha->flags.rscn_queue_overflow) {
2717 rscn_entry = ha->rscn_queue[ha->rscn_out_ptr];
2725 ha->host_no, ha->rscn_out_ptr, format, d_id.b.domain,
2728 ha->rscn_out_ptr++;
2729 if (ha->rscn_out_ptr == MAX_RSCN_COUNT)
2730 ha->rscn_out_ptr = 0;
2733 for (rscn_out_iter = ha->rscn_out_ptr;
2734 !ha->flags.rscn_queue_overflow &&
2735 rscn_out_iter != ha->rscn_in_ptr;
2739 if (rscn_entry != ha->rscn_queue[rscn_out_iter])
2743 "entry found at [%d].\n", ha->host_no,
2746 ha->rscn_out_ptr = rscn_out_iter;
2750 if (ha->flags.rscn_queue_overflow) {
2752 "overflow.\n", ha->host_no));
2755 ha->flags.rscn_queue_overflow = 0;
2771 ha->rscn_out_ptr = ha->rscn_in_ptr;
2777 list_for_each_entry(fcport, &ha->fcports, list) {
2786 qla2x00_mark_device_lost(ha, fcport,
2801 * ha: adapter state pointer.
2813 qla2x00_fabric_dev_login(scsi_qla_host_t *ha, fc_port_t *fcport,
2823 rval = qla2x00_fabric_login(ha, fcport, next_loopid);
2829 rval = qla2x00_get_port_database(ha, fcport, opts);
2831 ha->isp_ops.fabric_logout(ha, fcport->loop_id,
2834 qla2x00_mark_device_lost(ha, fcport, 1, 0);
2836 qla2x00_update_fcport(ha, fcport);
2848 * ha = adapter block pointer.
2858 qla2x00_fabric_login(scsi_qla_host_t *ha, fc_port_t *fcport,
2872 ha->host_no, fcport->loop_id, fcport->d_id.b.domain,
2876 ha->isp_ops.fabric_login(ha, fcport->loop_id,
2932 rval = qla2x00_find_new_loop_id(ha, fcport);
2944 ha->isp_ops.fabric_logout(ha, fcport->loop_id,
2947 qla2x00_mark_device_lost(ha, fcport, 1, 0);
2957 __func__, ha->host_no, mb[0],
2962 ha->isp_ops.fabric_logout(ha, fcport->loop_id,
2981 * ha = adapter block pointer.
2990 qla2x00_local_device_login(scsi_qla_host_t *ha, fc_port_t *fcport)
2996 rval = qla2x00_login_local_device(ha, fcport, mb, BIT_0);
3014 * ha = adapter block pointer.
3020 qla2x00_loop_resync(scsi_qla_host_t *ha)
3027 atomic_set(&ha->loop_state, LOOP_UPDATE);
3028 clear_bit(ISP_ABORT_RETRY, &ha->dpc_flags);
3029 if (ha->flags.online) {
3030 if (!(rval = qla2x00_fw_ready(ha))) {
3034 atomic_set(&ha->loop_state, LOOP_UPDATE);
3037 qla2x00_marker(ha, 0, 0, MK_SYNC_ALL);
3038 ha->marker_needed = 0;
3041 clear_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags);
3043 qla2x00_configure_loop(ha);
3045 } while (!atomic_read(&ha->loop_down_timer) &&
3046 !(test_bit(ISP_ABORT_NEEDED, &ha->dpc_flags)) &&
3048 (test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags)));
3052 if (test_bit(ISP_ABORT_NEEDED, &ha->dpc_flags)) {
3064 qla2x00_rescan_fcports(scsi_qla_host_t *ha)
3070 list_for_each_entry(fcport, &ha->fcports, list) {
3074 qla2x00_update_fcport(ha, fcport);
3079 qla2x00_probe_for_all_luns(ha);
3083 qla2x00_update_fcports(scsi_qla_host_t *ha)
3088 list_for_each_entry(fcport, &ha->fcports, list)
3098 * ha = adapter block pointer.
3104 qla2x00_abort_isp(scsi_qla_host_t *ha)
3112 if (ha->flags.online) {
3113 ha->flags.online = 0;
3114 clear_bit(ISP_ABORT_NEEDED, &ha->dpc_flags);
3116 qla_printk(KERN_INFO, ha,
3117 "Performing ISP error recovery - ha= %p.\n", ha);
3118 ha->isp_ops.reset_chip(ha);
3120 atomic_set(&ha->loop_down_timer, LOOP_DOWN_TIME);
3121 if (atomic_read(&ha->loop_state) != LOOP_DOWN) {
3122 atomic_set(&ha->loop_state, LOOP_DOWN);
3123 qla2x00_mark_all_devices_lost(ha, 0);
3125 if (!atomic_read(&ha->loop_down_timer))
3126 atomic_set(&ha->loop_down_timer,
3130 spin_lock_irqsave(&ha->hardware_lock, flags);
3133 sp = ha->outstanding_cmds[cnt];
3135 ha->outstanding_cmds[cnt] = NULL;
3139 qla2x00_sp_compl(ha, sp);
3142 spin_unlock_irqrestore(&ha->hardware_lock, flags);
3144 ha->isp_ops.get_flash_version(ha, ha->request_ring);
3146 ha->isp_ops.nvram_config(ha);
3148 if (!qla2x00_restart_isp(ha)) {
3149 clear_bit(RESET_MARKER_NEEDED, &ha->dpc_flags);
3151 if (!atomic_read(&ha->loop_down_timer)) {
3156 ha->marker_needed = 1;
3159 ha->flags.online = 1;
3161 ha->isp_ops.enable_intrs(ha);
3163 ha->isp_abort_cnt = 0;
3164 clear_bit(ISP_ABORT_RETRY, &ha->dpc_flags);
3166 if (ha->eft) {
3167 rval = qla2x00_trace_control(ha, TC_ENABLE,
3168 ha->eft_dma, EFT_NUM_BUFFERS);
3170 qla_printk(KERN_WARNING, ha,
3176 ha->flags.online = 1;
3177 if (test_bit(ISP_ABORT_RETRY, &ha->dpc_flags)) {
3178 if (ha->isp_abort_cnt == 0) {
3179 qla_printk(KERN_WARNING, ha,
3186 ha->isp_ops.reset_adapter(ha);
3187 ha->flags.online = 0;
3189 &ha->dpc_flags);
3192 ha->isp_abort_cnt--;
3195 ha->host_no, ha->isp_abort_cnt));
3199 ha->isp_abort_cnt = MAX_RETRIES_OF_ISP_ABORT;
3202 ha->host_no, ha->isp_abort_cnt));
3203 set_bit(ISP_ABORT_RETRY, &ha->dpc_flags);
3211 qla_printk(KERN_INFO, ha,
3216 ha->host_no));
3227 * ha = adapter block pointer.
3233 qla2x00_restart_isp(scsi_qla_host_t *ha)
3236 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
3241 if (qla2x00_isp_firmware(ha)) {
3242 ha->flags.online = 0;
3243 if (!(status = ha->isp_ops.chip_diag(ha))) {
3244 if (IS_QLA2100(ha) || IS_QLA2200(ha)) {
3245 status = qla2x00_setup_chip(ha);
3249 spin_lock_irqsave(&ha->hardware_lock, flags);
3251 if (!IS_QLA24XX(ha) && !IS_QLA54XX(ha)) {
3261 spin_unlock_irqrestore(&ha->hardware_lock, flags);
3263 status = qla2x00_setup_chip(ha);
3265 spin_lock_irqsave(&ha->hardware_lock, flags);
3267 if (!IS_QLA24XX(ha) && !IS_QLA54XX(ha)) {
3269 if (IS_QLA2300(ha))
3283 spin_unlock_irqrestore(&ha->hardware_lock, flags);
3288 if (!status && !(status = qla2x00_init_rings(ha))) {
3289 clear_bit(RESET_MARKER_NEEDED, &ha->dpc_flags);
3290 if (!(status = qla2x00_fw_ready(ha))) {
3295 qla2x00_marker(ha, 0, 0, MK_SYNC_ALL);
3297 ha->flags.online = 1;
3301 clear_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags);
3302 qla2x00_configure_loop(ha);
3304 } while (!atomic_read(&ha->loop_down_timer) &&
3305 !(test_bit(ISP_ABORT_NEEDED, &ha->dpc_flags)) &&
3307 (test_bit(LOOP_RESYNC_NEEDED, &ha->dpc_flags)));
3311 if ((ha->device_flags & DFLG_NO_CABLE))
3326 * ha = adapter block pointer.
3329 qla2x00_reset_adapter(scsi_qla_host_t *ha)
3332 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp;
3334 ha->flags.online = 0;
3335 ha->isp_ops.disable_intrs(ha);
3337 spin_lock_irqsave(&ha->hardware_lock, flags);
3342 spin_unlock_irqrestore(&ha->hardware_lock, flags);
3346 qla24xx_reset_adapter(scsi_qla_host_t *ha)
3349 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24;
3351 ha->flags.online = 0;
3352 ha->isp_ops.disable_intrs(ha);
3354 spin_lock_irqsave(&ha->hardware_lock, flags);
3359 spin_unlock_irqrestore(&ha->hardware_lock, flags);
3365 static void qla24xx_nvram_wwn_from_ofw(scsi_qla_host_t *ha, struct nvram_24xx *nv)
3368 struct pci_dev *pdev = ha->pdev;
3384 qla24xx_nvram_config(scsi_qla_host_t *ha)
3395 icb = (struct init_cb_24xx *)ha->init_cb;
3396 nv = (struct nvram_24xx *)ha->request_ring;
3399 ha->nvram_size = sizeof(struct nvram_24xx);
3400 ha->nvram_base = FA_NVRAM_FUNC0_ADDR;
3401 ha->vpd_size = FA_NVRAM_VPD_SIZE;
3402 ha->vpd_base = FA_NVRAM_VPD0_ADDR;
3403 if (PCI_FUNC(ha->pdev->devfn)) {
3404 ha->nvram_base = FA_NVRAM_FUNC1_ADDR;
3405 ha->vpd_base = FA_NVRAM_VPD1_ADDR;
3410 ha->isp_ops.read_nvram(ha, (uint8_t *)dptr, ha->nvram_base,
3411 ha->nvram_size);
3412 for (cnt = 0, chksum = 0; cnt < ha->nvram_size >> 2; cnt++)
3415 DEBUG5(printk("scsi(%ld): Contents of NVRAM\n", ha->host_no));
3416 DEBUG5(qla2x00_dump_buffer((uint8_t *)ha->request_ring,
3417 ha->nvram_size));
3424 qla_printk(KERN_WARNING, ha, "Inconsistent NVRAM detected: "
3427 qla_printk(KERN_WARNING, ha, "Falling back to functioning (yet "
3433 memset(nv, 0, ha->nvram_size);
3441 nv->port_name[1] = 0x00 + PCI_FUNC(ha->pdev->devfn);
3456 qla24xx_nvram_wwn_from_ofw(ha, nv);
3499 qla2x00_set_model_info(ha, nv->model_name, sizeof(nv->model_name),
3519 ha->flags.disable_risc_code_load = 0;
3520 ha->flags.enable_lip_reset = 0;
3521 ha->flags.enable_lip_full_login =
3523 ha->flags.enable_target_reset =
3525 ha->flags.enable_led_scheme = 0;
3526 ha->flags.disable_serdes = le32_to_cpu(nv->host_p) & BIT_5 ? 1: 0;
3528 ha->operating_mode = (le32_to_cpu(icb->firmware_options_2) &
3531 memcpy(ha->fw_seriallink_options24, nv->seriallink_options,
3532 sizeof(ha->fw_seriallink_options24));
3535 ha->serial0 = icb->port_name[5];
3536 ha->serial1 = icb->port_name[6];
3537 ha->serial2 = icb->port_name[7];
3538 ha->node_name = icb->node_name;
3539 ha->port_name = icb->port_name;
3543 ha->retry_count = le16_to_cpu(nv->login_retry_count);
3550 ha->login_timeout = le16_to_cpu(nv->login_timeout);
3554 ha->r_a_tov = 200;
3556 ha->loop_reset_delay = nv->reset_delay;
3569 ha->loop_down_abort_time =
3572 ha->link_down_timeout = le16_to_cpu(nv->link_down_timeout);
3573 ha->loop_down_abort_time =
3574 (LOOP_DOWN_TIME - ha->link_down_timeout);
3578 ha->port_down_retry_count = le16_to_cpu(nv->port_down_retry_count);
3580 ha->port_down_retry_count = qlport_down_retry;
3583 ha->login_retry_count = le16_to_cpu(nv->login_retry_count);
3584 if (ha->port_down_retry_count ==
3586 ha->port_down_retry_count > 3)
3587 ha->login_retry_count = ha->port_down_retry_count;
3588 else if (ha->port_down_retry_count > (int)ha->login_retry_count)
3589 ha->login_retry_count = ha->port_down_retry_count;
3591 ha->login_retry_count = ql2xloginretrycount;
3594 if (!ha->flags.init_done) {
3595 ha->zio_mode = le32_to_cpu(icb->firmware_options_2) &
3597 ha->zio_timer = le16_to_cpu(icb->interrupt_delay_timer) ?
3602 ha->flags.process_response_queue = 0;
3603 if (ha->zio_mode != QLA_ZIO_DISABLED) {
3604 ha->zio_mode = QLA_ZIO_MODE_6;
3607 "(%d us).\n", ha->host_no, ha->zio_mode,
3608 ha->zio_timer * 100));
3609 qla_printk(KERN_INFO, ha,
3611 ha->zio_mode, ha->zio_timer * 100);
3614 (uint32_t)ha->zio_mode);
3615 icb->interrupt_delay_timer = cpu_to_le16(ha->zio_timer);
3616 ha->flags.process_response_queue = 1;
3621 "scsi(%ld): NVRAM configuration failed!\n", ha->host_no));
3627 qla24xx_load_risc_flash(scsi_qla_host_t *ha, uint32_t *srisc_addr)
3641 dcode = (uint32_t *)ha->request_ring;
3645 qla24xx_read_flash_data(ha, dcode, faddr + 4, 4);
3652 qla_printk(KERN_WARNING, ha,
3654 qla_printk(KERN_WARNING, ha,
3663 qla24xx_read_flash_data(ha, dcode, faddr, 4);
3671 dlen = (uint32_t)(ha->fw_transfer_size >> 2);
3677 ha->host_no, risc_addr, dlen, faddr));
3679 qla24xx_read_flash_data(ha, dcode, faddr, dlen);
3683 rval = qla2x00_load_ram(ha, ha->request_dma, risc_addr,
3687 "segment %d of firmware\n", ha->host_no,
3689 qla_printk(KERN_WARNING, ha,
3711 qla2x00_load_risc(scsi_qla_host_t *ha, uint32_t *srisc_addr)
3720 blob = qla2x00_request_firmware(ha);
3722 qla_printk(KERN_ERR, ha, "Firmware image unavailable.\n");
3723 qla_printk(KERN_ERR, ha, "Firmware images can be retrieved "
3730 wcode = (uint16_t *)ha->request_ring;
3737 qla_printk(KERN_WARNING, ha,
3747 qla_printk(KERN_WARNING, ha,
3749 qla_printk(KERN_WARNING, ha,
3764 qla_printk(KERN_WARNING, ha,
3772 wlen = (uint16_t)(ha->fw_transfer_size >> 1);
3777 "addr %x, number of words 0x%x.\n", ha->host_no,
3783 rval = qla2x00_load_ram(ha, ha->request_dma, risc_addr,
3787 "segment %d of firmware\n", ha->host_no,
3789 qla_printk(KERN_WARNING, ha,
3811 qla24xx_load_risc(scsi_qla_host_t *ha, uint32_t *srisc_addr)
3823 blob = qla2x00_request_firmware(ha);
3825 qla_printk(KERN_ERR, ha, "Firmware image unavailable.\n");
3826 qla_printk(KERN_ERR, ha, "Firmware images can be retrieved "
3830 qla_printk(KERN_ERR, ha, "Attempting to load (potentially "
3832 return qla24xx_load_risc_flash(ha, srisc_addr);
3838 dcode = (uint32_t *)ha->request_ring;
3845 qla_printk(KERN_WARNING, ha,
3856 qla_printk(KERN_WARNING, ha,
3858 qla_printk(KERN_WARNING, ha,
3872 qla_printk(KERN_WARNING, ha,
3881 dlen = (uint32_t)(ha->fw_transfer_size >> 2);
3886 "addr %x, number of dwords 0x%x.\n", ha->host_no,
3892 rval = qla2x00_load_ram(ha, ha->request_dma, risc_addr,
3896 "segment %d of firmware\n", ha->host_no,
3898 qla_printk(KERN_WARNING, ha,
3920 qla2x00_try_to_stop_firmware(scsi_qla_host_t *ha)
3924 if (!IS_QLA24XX(ha) && !IS_QLA54XX(ha))
3926 if (!ha->fw_major_version)
3929 ret = qla2x00_stop_firmware(ha);
3931 qla2x00_reset_chip(ha);
3932 if (qla2x00_chip_diag(ha) != QLA_SUCCESS)
3934 if (qla2x00_setup_chip(ha) != QLA_SUCCESS)
3936 qla_printk(KERN_INFO, ha,
3938 ret = qla2x00_stop_firmware(ha);