Lines Matching +full:dsd +full:- +full:path
1 // SPDX-License-Identifier: GPL-2.0-only
4 * Copyright (c) 2003-2014 QLogic Corporation
52 struct qla_hw_data *ha = vha->hw; in qlafx00_mailbox_command()
53 scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); in qlafx00_mailbox_command()
55 if (ha->pdev->error_state == pci_channel_io_perm_failure) { in qlafx00_mailbox_command()
61 if (vha->device_flags & DFLG_DEV_FAILED) { in qlafx00_mailbox_command()
67 reg = ha->iobase; in qlafx00_mailbox_command()
68 io_lock_on = base_vha->flags.init_done; in qlafx00_mailbox_command()
71 abort_active = test_bit(ABORT_ISP_ACTIVE, &base_vha->dpc_flags); in qlafx00_mailbox_command()
73 if (ha->flags.pci_channel_io_perm_failure) { in qlafx00_mailbox_command()
79 if (ha->flags.isp82xx_fw_hung) { in qlafx00_mailbox_command()
80 /* Setting Link-Down error */ in qlafx00_mailbox_command()
81 mcp->mb[0] = MBS_LINK_DOWN_ERROR; in qlafx00_mailbox_command()
83 "FW hung = %d.\n", ha->flags.isp82xx_fw_hung); in qlafx00_mailbox_command()
93 if (!wait_for_completion_timeout(&ha->mbx_cmd_comp, mcp->tov * HZ)) { in qlafx00_mailbox_command()
97 mcp->mb[0]); in qlafx00_mailbox_command()
101 ha->flags.mbox_busy = 1; in qlafx00_mailbox_command()
103 ha->mcp32 = mcp; in qlafx00_mailbox_command()
106 "Prepare to issue mbox cmd=0x%x.\n", mcp->mb[0]); in qlafx00_mailbox_command()
108 spin_lock_irqsave(&ha->hardware_lock, flags); in qlafx00_mailbox_command()
111 optr = ®->ispfx00.mailbox0; in qlafx00_mailbox_command()
113 iptr = mcp->mb; in qlafx00_mailbox_command()
114 command = mcp->mb[0]; in qlafx00_mailbox_command()
115 mboxes = mcp->out_mb; in qlafx00_mailbox_command()
117 for (cnt = 0; cnt < ha->mbx_count; cnt++) { in qlafx00_mailbox_command()
127 ha->flags.mbox_int = 0; in qlafx00_mailbox_command()
128 clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags); in qlafx00_mailbox_command()
131 (uint8_t *)mcp->mb, 16); in qlafx00_mailbox_command()
133 ((uint8_t *)mcp->mb + 0x10), 16); in qlafx00_mailbox_command()
135 ((uint8_t *)mcp->mb + 0x20), 8); in qlafx00_mailbox_command()
144 set_bit(MBX_INTR_WAIT, &ha->mbx_cmd_flags); in qlafx00_mailbox_command()
146 QLAFX00_SET_HST_INTR(ha, ha->mbx_intr_code); in qlafx00_mailbox_command()
147 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qlafx00_mailbox_command()
149 WARN_ON_ONCE(wait_for_completion_timeout(&ha->mbx_intr_comp, in qlafx00_mailbox_command()
150 mcp->tov * HZ) != 0); in qlafx00_mailbox_command()
155 QLAFX00_SET_HST_INTR(ha, ha->mbx_intr_code); in qlafx00_mailbox_command()
156 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qlafx00_mailbox_command()
158 wait_time = jiffies + mcp->tov * HZ; /* wait at most tov secs */ in qlafx00_mailbox_command()
159 while (!ha->flags.mbox_int) { in qlafx00_mailbox_command()
164 qla2x00_poll(ha->rsp_q_map[0]); in qlafx00_mailbox_command()
166 if (!ha->flags.mbox_int && in qlafx00_mailbox_command()
173 (uint)((jiffies - (wait_time - (mcp->tov * HZ)))/HZ)); in qlafx00_mailbox_command()
177 if (ha->flags.mbox_int) { in qlafx00_mailbox_command()
184 ha->flags.mbox_int = 0; in qlafx00_mailbox_command()
185 clear_bit(MBX_INTERRUPT, &ha->mbx_cmd_flags); in qlafx00_mailbox_command()
187 if (ha->mailbox_out32[0] != MBS_COMMAND_COMPLETE) in qlafx00_mailbox_command()
191 iptr2 = mcp->mb; in qlafx00_mailbox_command()
192 iptr = (uint32_t *)&ha->mailbox_out32[0]; in qlafx00_mailbox_command()
193 mboxes = mcp->in_mb; in qlafx00_mailbox_command()
194 for (cnt = 0; cnt < ha->mbx_count; cnt++) { in qlafx00_mailbox_command()
207 ha->flags.mbox_busy = 0; in qlafx00_mailbox_command()
210 ha->mcp32 = NULL; in qlafx00_mailbox_command()
217 qla2x00_poll(ha->rsp_q_map[0]); in qlafx00_mailbox_command()
221 mcp->mb[0] != MBC_GEN_SYSTEM_ERROR) { in qlafx00_mailbox_command()
222 if (!io_lock_on || (mcp->flags & IOCTL_CMD) || in qlafx00_mailbox_command()
223 ha->flags.eeh_busy) { in qlafx00_mailbox_command()
228 if (!test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) && in qlafx00_mailbox_command()
229 !test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags) && in qlafx00_mailbox_command()
230 !test_bit(ISP_ABORT_RETRY, &vha->dpc_flags)) { in qlafx00_mailbox_command()
235 "abort.\n", command, mcp->mb[0], in qlafx00_mailbox_command()
236 ha->flags.eeh_busy); in qlafx00_mailbox_command()
237 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); in qlafx00_mailbox_command()
245 if (!test_bit(ISP_ABORT_NEEDED, &vha->dpc_flags) && in qlafx00_mailbox_command()
246 !test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags) && in qlafx00_mailbox_command()
247 !test_bit(ISP_ABORT_RETRY, &vha->dpc_flags)) { in qlafx00_mailbox_command()
252 command, mcp->mb[0]); in qlafx00_mailbox_command()
254 set_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags); in qlafx00_mailbox_command()
255 clear_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); in qlafx00_mailbox_command()
256 if (ha->isp_ops->abort_isp(vha)) { in qlafx00_mailbox_command()
259 &vha->dpc_flags); in qlafx00_mailbox_command()
261 clear_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags); in qlafx00_mailbox_command()
270 complete(&ha->mbx_cmd_comp); in qlafx00_mailbox_command()
275 rval, mcp->mb[0], mcp->mb[1], mcp->mb[2], mcp->mb[3], in qlafx00_mailbox_command()
307 mcp->mb[0] = MBC_MR_DRV_SHUTDOWN; in qlafx00_driver_shutdown()
308 mcp->out_mb = MBX_0; in qlafx00_driver_shutdown()
309 mcp->in_mb = MBX_0; in qlafx00_driver_shutdown()
311 mcp->tov = tmo; in qlafx00_driver_shutdown()
313 mcp->tov = MBX_TOV_SECONDS; in qlafx00_driver_shutdown()
314 mcp->flags = 0; in qlafx00_driver_shutdown()
353 mcp->mb[0] = MBC_GET_FIRMWARE_STATE; in qlafx00_get_firmware_state()
354 mcp->out_mb = MBX_0; in qlafx00_get_firmware_state()
355 mcp->in_mb = MBX_1|MBX_0; in qlafx00_get_firmware_state()
356 mcp->tov = MBX_TOV_SECONDS; in qlafx00_get_firmware_state()
357 mcp->flags = 0; in qlafx00_get_firmware_state()
361 states[0] = mcp->mb[1]; in qlafx00_get_firmware_state()
365 "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); in qlafx00_get_firmware_state()
396 struct qla_hw_data *ha = vha->hw; in qlafx00_init_firmware()
401 mcp->mb[0] = MBC_INITIALIZE_FIRMWARE; in qlafx00_init_firmware()
403 mcp->mb[1] = 0; in qlafx00_init_firmware()
404 mcp->mb[2] = MSD(ha->init_cb_dma); in qlafx00_init_firmware()
405 mcp->mb[3] = LSD(ha->init_cb_dma); in qlafx00_init_firmware()
407 mcp->out_mb = MBX_3|MBX_2|MBX_1|MBX_0; in qlafx00_init_firmware()
408 mcp->in_mb = MBX_0; in qlafx00_init_firmware()
409 mcp->buf_size = size; in qlafx00_init_firmware()
410 mcp->flags = MBX_DMA_OUT; in qlafx00_init_firmware()
411 mcp->tov = MBX_TOV_SECONDS; in qlafx00_init_firmware()
416 "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); in qlafx00_init_firmware()
438 mcp->mb[0] = MBC_MAILBOX_REGISTER_TEST; in qlafx00_mbx_reg_test()
439 mcp->mb[1] = 0xAAAA; in qlafx00_mbx_reg_test()
440 mcp->mb[2] = 0x5555; in qlafx00_mbx_reg_test()
441 mcp->mb[3] = 0xAA55; in qlafx00_mbx_reg_test()
442 mcp->mb[4] = 0x55AA; in qlafx00_mbx_reg_test()
443 mcp->mb[5] = 0xA5A5; in qlafx00_mbx_reg_test()
444 mcp->mb[6] = 0x5A5A; in qlafx00_mbx_reg_test()
445 mcp->mb[7] = 0x2525; in qlafx00_mbx_reg_test()
446 mcp->mb[8] = 0xBBBB; in qlafx00_mbx_reg_test()
447 mcp->mb[9] = 0x6666; in qlafx00_mbx_reg_test()
448 mcp->mb[10] = 0xBB66; in qlafx00_mbx_reg_test()
449 mcp->mb[11] = 0x66BB; in qlafx00_mbx_reg_test()
450 mcp->mb[12] = 0xB6B6; in qlafx00_mbx_reg_test()
451 mcp->mb[13] = 0x6B6B; in qlafx00_mbx_reg_test()
452 mcp->mb[14] = 0x3636; in qlafx00_mbx_reg_test()
453 mcp->mb[15] = 0xCCCC; in qlafx00_mbx_reg_test()
456 mcp->out_mb = MBX_15|MBX_14|MBX_13|MBX_12|MBX_11|MBX_10|MBX_9|MBX_8| in qlafx00_mbx_reg_test()
458 mcp->in_mb = MBX_15|MBX_14|MBX_13|MBX_12|MBX_11|MBX_10|MBX_9|MBX_8| in qlafx00_mbx_reg_test()
460 mcp->buf_size = 0; in qlafx00_mbx_reg_test()
461 mcp->flags = MBX_DMA_OUT; in qlafx00_mbx_reg_test()
462 mcp->tov = MBX_TOV_SECONDS; in qlafx00_mbx_reg_test()
465 if (mcp->mb[17] != 0xAAAA || mcp->mb[18] != 0x5555 || in qlafx00_mbx_reg_test()
466 mcp->mb[19] != 0xAA55 || mcp->mb[20] != 0x55AA) in qlafx00_mbx_reg_test()
468 if (mcp->mb[21] != 0xA5A5 || mcp->mb[22] != 0x5A5A || in qlafx00_mbx_reg_test()
469 mcp->mb[23] != 0x2525 || mcp->mb[24] != 0xBBBB) in qlafx00_mbx_reg_test()
471 if (mcp->mb[25] != 0x6666 || mcp->mb[26] != 0xBB66 || in qlafx00_mbx_reg_test()
472 mcp->mb[27] != 0x66BB || mcp->mb[28] != 0xB6B6) in qlafx00_mbx_reg_test()
474 if (mcp->mb[29] != 0x6B6B || mcp->mb[30] != 0x3636 || in qlafx00_mbx_reg_test()
475 mcp->mb[31] != 0xCCCC) in qlafx00_mbx_reg_test()
481 "Failed=%x mb[0]=%x.\n", rval, mcp->mb[0]); in qlafx00_mbx_reg_test()
490 * qlafx00_pci_config() - Setup ISPFx00 PCI configuration registers.
499 struct qla_hw_data *ha = vha->hw; in qlafx00_pci_config()
501 pci_set_master(ha->pdev); in qlafx00_pci_config()
502 pci_try_set_mwi(ha->pdev); in qlafx00_pci_config()
504 pci_read_config_word(ha->pdev, PCI_COMMAND, &w); in qlafx00_pci_config()
507 pci_write_config_word(ha->pdev, PCI_COMMAND, w); in qlafx00_pci_config()
509 /* PCIe -- adjust Maximum Read Request Size (2048). */ in qlafx00_pci_config()
510 if (pci_is_pcie(ha->pdev)) in qlafx00_pci_config()
511 pcie_set_readrq(ha->pdev, 2048); in qlafx00_pci_config()
513 ha->chip_revision = ha->pdev->revision; in qlafx00_pci_config()
519 * qlafx00_soc_cpu_reset() - Perform warm reset of iSA(CPUs being reset on SOC).
527 struct qla_hw_data *ha = vha->hw; in qlafx00_soc_cpu_reset()
532 spin_lock_irqsave(&ha->hardware_lock, flags); in qlafx00_soc_cpu_reset()
615 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qlafx00_soc_cpu_reset()
617 /* Wait 10secs for soft-reset to complete. */ in qlafx00_soc_cpu_reset()
618 for (cnt = 10; cnt; cnt--) { in qlafx00_soc_cpu_reset()
625 * qlafx00_soft_reset() - Soft Reset ISPFx00.
633 struct qla_hw_data *ha = vha->hw; in qlafx00_soft_reset()
636 if (unlikely(pci_channel_offline(ha->pdev) && in qlafx00_soft_reset()
637 ha->flags.pci_channel_io_perm_failure)) in qlafx00_soft_reset()
640 ha->isp_ops->disable_intrs(ha); in qlafx00_soft_reset()
647 * qlafx00_chip_diag() - Test ISPFx00 for proper operation.
656 struct qla_hw_data *ha = vha->hw; in qlafx00_chip_diag()
657 struct req_que *req = ha->req_q_map[0]; in qlafx00_chip_diag()
659 ha->fw_transfer_size = REQUEST_ENTRY_SIZE * req->length; in qlafx00_chip_diag()
675 struct qla_hw_data *ha = vha->hw; in qlafx00_config_rings()
676 struct device_reg_fx00 __iomem *reg = &ha->iobase->ispfx00; in qlafx00_config_rings()
678 wrt_reg_dword(®->req_q_in, 0); in qlafx00_config_rings()
679 wrt_reg_dword(®->req_q_out, 0); in qlafx00_config_rings()
681 wrt_reg_dword(®->rsp_q_in, 0); in qlafx00_config_rings()
682 wrt_reg_dword(®->rsp_q_out, 0); in qlafx00_config_rings()
685 rd_reg_dword(®->rsp_q_out); in qlafx00_config_rings()
691 struct qla_hw_data *ha = vha->hw; in qlafx00_pci_info_str()
693 if (pci_is_pcie(ha->pdev)) in qlafx00_pci_info_str()
701 struct qla_hw_data *ha = vha->hw; in qlafx00_fw_version_str()
703 snprintf(str, size, "%s", ha->mr.fw_version); in qlafx00_fw_version_str()
712 spin_lock_irqsave(&ha->hardware_lock, flags); in qlafx00_enable_intrs()
713 ha->interrupts_on = 1; in qlafx00_enable_intrs()
715 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qlafx00_enable_intrs()
723 spin_lock_irqsave(&ha->hardware_lock, flags); in qlafx00_disable_intrs()
724 ha->interrupts_on = 0; in qlafx00_disable_intrs()
726 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qlafx00_disable_intrs()
744 if (pci_request_selected_regions(ha->pdev, ha->bars, in qlafx00_iospace_config()
746 ql_log_pci(ql_log_fatal, ha->pdev, 0x014e, in qlafx00_iospace_config()
748 pci_name(ha->pdev)); in qlafx00_iospace_config()
753 if (!(pci_resource_flags(ha->pdev, 0) & IORESOURCE_MEM)) { in qlafx00_iospace_config()
754 ql_log_pci(ql_log_warn, ha->pdev, 0x014f, in qlafx00_iospace_config()
756 pci_name(ha->pdev)); in qlafx00_iospace_config()
759 if (pci_resource_len(ha->pdev, 0) < BAR0_LEN_FX00) { in qlafx00_iospace_config()
760 ql_log_pci(ql_log_warn, ha->pdev, 0x0127, in qlafx00_iospace_config()
762 pci_name(ha->pdev)); in qlafx00_iospace_config()
766 ha->cregbase = in qlafx00_iospace_config()
767 ioremap(pci_resource_start(ha->pdev, 0), BAR0_LEN_FX00); in qlafx00_iospace_config()
768 if (!ha->cregbase) { in qlafx00_iospace_config()
769 ql_log_pci(ql_log_fatal, ha->pdev, 0x0128, in qlafx00_iospace_config()
770 "cannot remap MMIO (%s), aborting\n", pci_name(ha->pdev)); in qlafx00_iospace_config()
774 if (!(pci_resource_flags(ha->pdev, 2) & IORESOURCE_MEM)) { in qlafx00_iospace_config()
775 ql_log_pci(ql_log_warn, ha->pdev, 0x0129, in qlafx00_iospace_config()
777 pci_name(ha->pdev)); in qlafx00_iospace_config()
780 if (pci_resource_len(ha->pdev, 2) < BAR2_LEN_FX00) { in qlafx00_iospace_config()
781 ql_log_pci(ql_log_warn, ha->pdev, 0x012a, in qlafx00_iospace_config()
783 pci_name(ha->pdev)); in qlafx00_iospace_config()
787 ha->iobase = in qlafx00_iospace_config()
788 ioremap(pci_resource_start(ha->pdev, 2), BAR2_LEN_FX00); in qlafx00_iospace_config()
789 if (!ha->iobase) { in qlafx00_iospace_config()
790 ql_log_pci(ql_log_fatal, ha->pdev, 0x012b, in qlafx00_iospace_config()
791 "cannot remap MMIO (%s), aborting\n", pci_name(ha->pdev)); in qlafx00_iospace_config()
796 ha->max_req_queues = ha->max_rsp_queues = 1; in qlafx00_iospace_config()
798 ql_log_pci(ql_log_info, ha->pdev, 0x012c, in qlafx00_iospace_config()
800 ha->bars, ha->cregbase, ha->iobase); in qlafx00_iospace_config()
805 return -ENOMEM; in qlafx00_iospace_config()
811 struct qla_hw_data *ha = vha->hw; in qlafx00_save_queue_ptrs()
812 struct req_que *req = ha->req_q_map[0]; in qlafx00_save_queue_ptrs()
813 struct rsp_que *rsp = ha->rsp_q_map[0]; in qlafx00_save_queue_ptrs()
815 req->length_fx00 = req->length; in qlafx00_save_queue_ptrs()
816 req->ring_fx00 = req->ring; in qlafx00_save_queue_ptrs()
817 req->dma_fx00 = req->dma; in qlafx00_save_queue_ptrs()
819 rsp->length_fx00 = rsp->length; in qlafx00_save_queue_ptrs()
820 rsp->ring_fx00 = rsp->ring; in qlafx00_save_queue_ptrs()
821 rsp->dma_fx00 = rsp->dma; in qlafx00_save_queue_ptrs()
825 "req->dma_fx00: 0x%llx\n", req, req->ring_fx00, in qlafx00_save_queue_ptrs()
826 req->length_fx00, (u64)req->dma_fx00); in qlafx00_save_queue_ptrs()
830 "rsp->dma_fx00: 0x%llx\n", rsp, rsp->ring_fx00, in qlafx00_save_queue_ptrs()
831 rsp->length_fx00, (u64)rsp->dma_fx00); in qlafx00_save_queue_ptrs()
837 struct qla_hw_data *ha = vha->hw; in qlafx00_config_queues()
838 struct req_que *req = ha->req_q_map[0]; in qlafx00_config_queues()
839 struct rsp_que *rsp = ha->rsp_q_map[0]; in qlafx00_config_queues()
840 dma_addr_t bar2_hdl = pci_resource_start(ha->pdev, 2); in qlafx00_config_queues()
842 req->length = ha->req_que_len; in qlafx00_config_queues()
843 req->ring = (void __force *)ha->iobase + ha->req_que_off; in qlafx00_config_queues()
844 req->dma = bar2_hdl + ha->req_que_off; in qlafx00_config_queues()
845 if ((!req->ring) || (req->length == 0)) { in qlafx00_config_queues()
846 ql_log_pci(ql_log_info, ha->pdev, 0x012f, in qlafx00_config_queues()
853 "req off 0x%x\n, req->dma: 0x%llx", in qlafx00_config_queues()
854 req, req->ring, req->length, in qlafx00_config_queues()
855 ha->req_que_off, (u64)req->dma); in qlafx00_config_queues()
857 rsp->length = ha->rsp_que_len; in qlafx00_config_queues()
858 rsp->ring = (void __force *)ha->iobase + ha->rsp_que_off; in qlafx00_config_queues()
859 rsp->dma = bar2_hdl + ha->rsp_que_off; in qlafx00_config_queues()
860 if ((!rsp->ring) || (rsp->length == 0)) { in qlafx00_config_queues()
861 ql_log_pci(ql_log_info, ha->pdev, 0x0131, in qlafx00_config_queues()
868 "rsp off 0x%x, rsp->dma: 0x%llx\n", in qlafx00_config_queues()
869 rsp, rsp->ring, rsp->length, in qlafx00_config_queues()
870 ha->rsp_que_off, (u64)rsp->dma); in qlafx00_config_queues()
881 struct qla_hw_data *ha = vha->hw; in qlafx00_init_fw_ready()
882 struct device_reg_fx00 __iomem *reg = &ha->iobase->ispfx00; in qlafx00_init_fw_ready()
888 /* 30 seconds wait - Adjust if required */ in qlafx00_init_fw_ready()
891 pseudo_aen = rd_reg_dword(®->pseudoaen); in qlafx00_init_fw_ready()
893 aenmbx7 = rd_reg_dword(®->initval7); in qlafx00_init_fw_ready()
894 ha->mbx_intr_code = MSW(aenmbx7); in qlafx00_init_fw_ready()
895 ha->rqstq_intr_code = LSW(aenmbx7); in qlafx00_init_fw_ready()
904 aenmbx = rd_reg_dword(®->aenmailbox0); in qlafx00_init_fw_ready()
923 aenmbx7 = rd_reg_dword(®->aenmailbox7); in qlafx00_init_fw_ready()
924 ha->mbx_intr_code = MSW(aenmbx7); in qlafx00_init_fw_ready()
925 ha->rqstq_intr_code = LSW(aenmbx7); in qlafx00_init_fw_ready()
926 ha->req_que_off = rd_reg_dword(®->aenmailbox1); in qlafx00_init_fw_ready()
927 ha->rsp_que_off = rd_reg_dword(®->aenmailbox3); in qlafx00_init_fw_ready()
928 ha->req_que_len = rd_reg_dword(®->aenmailbox5); in qlafx00_init_fw_ready()
929 ha->rsp_que_len = rd_reg_dword(®->aenmailbox6); in qlafx00_init_fw_ready()
930 wrt_reg_dword(®->aenmailbox0, 0); in qlafx00_init_fw_ready()
931 rd_reg_dword_relaxed(®->aenmailbox0); in qlafx00_init_fw_ready()
935 ha->mbx_intr_code, ha->rqstq_intr_code); in qlafx00_init_fw_ready()
961 aenmbx7 = rd_reg_dword(®->initval7); in qlafx00_init_fw_ready()
962 ha->mbx_intr_code = MSW(aenmbx7); in qlafx00_init_fw_ready()
963 ha->rqstq_intr_code = LSW(aenmbx7); in qlafx00_init_fw_ready()
964 ha->req_que_off = rd_reg_dword(®->initval1); in qlafx00_init_fw_ready()
965 ha->rsp_que_off = rd_reg_dword(®->initval3); in qlafx00_init_fw_ready()
966 ha->req_que_len = rd_reg_dword(®->initval5); in qlafx00_init_fw_ready()
967 ha->rsp_que_len = rd_reg_dword(®->initval6); in qlafx00_init_fw_ready()
971 ha->mbx_intr_code, ha->rqstq_intr_code); in qlafx00_init_fw_ready()
1013 rd_reg_dword(®->aenmailbox7)); in qlafx00_init_fw_ready()
1034 * qlafx00_fw_ready() - Waits for firmware ready.
1055 if (!vha->flags.init_done) in qlafx00_fw_ready()
1101 struct qla_hw_data *ha = vha->hw; in qlafx00_find_all_targets()
1105 if (!test_bit(LOOP_RESYNC_ACTIVE, &vha->dpc_flags)) in qlafx00_find_all_targets()
1108 if ((atomic_read(&vha->loop_down_timer) || in qlafx00_find_all_targets()
1110 atomic_set(&vha->loop_down_timer, 0); in qlafx00_find_all_targets()
1111 set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); in qlafx00_find_all_targets()
1118 ha->gid_list, 32); in qlafx00_find_all_targets()
1125 for_each_set_bit(tgt_id, (void *)ha->gid_list, in qlafx00_find_all_targets()
1129 new_fcport->tgt_id = tgt_id; in qlafx00_find_all_targets()
1134 "Target info scan failed -- assuming zero-entry " in qlafx00_find_all_targets()
1141 list_for_each_entry(fcport, &vha->vp_fcports, list) { in qlafx00_find_all_targets()
1142 if (memcmp(new_fcport->port_name, in qlafx00_find_all_targets()
1143 fcport->port_name, WWN_SIZE)) in qlafx00_find_all_targets()
1152 if (fcport->tgt_id == new_fcport->tgt_id && in qlafx00_find_all_targets()
1153 atomic_read(&fcport->state) == FCS_ONLINE) in qlafx00_find_all_targets()
1160 "TGT-ID Change(%s): Present tgt id: " in qlafx00_find_all_targets()
1163 __func__, fcport->tgt_id, in qlafx00_find_all_targets()
1164 atomic_read(&fcport->state), in qlafx00_find_all_targets()
1165 (unsigned long long)wwn_to_u64(fcport->node_name), in qlafx00_find_all_targets()
1166 (unsigned long long)wwn_to_u64(fcport->port_name)); in qlafx00_find_all_targets()
1169 "TGT-ID Announce(%s): Discovered tgt " in qlafx00_find_all_targets()
1171 "wwpn = %llx.\n", __func__, new_fcport->tgt_id, in qlafx00_find_all_targets()
1173 wwn_to_u64(new_fcport->node_name), in qlafx00_find_all_targets()
1175 wwn_to_u64(new_fcport->port_name)); in qlafx00_find_all_targets()
1177 if (atomic_read(&fcport->state) != FCS_ONLINE) { in qlafx00_find_all_targets()
1178 fcport->old_tgt_id = fcport->tgt_id; in qlafx00_find_all_targets()
1179 fcport->tgt_id = new_fcport->tgt_id; in qlafx00_find_all_targets()
1181 "TGT-ID: New fcport Added: %p\n", fcport); in qlafx00_find_all_targets()
1185 " Existing TGT-ID %x did not get " in qlafx00_find_all_targets()
1187 fcport->old_tgt_id); in qlafx00_find_all_targets()
1189 set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); in qlafx00_find_all_targets()
1200 list_add_tail(&new_fcport->list, new_fcports); in qlafx00_find_all_targets()
1230 rval = qlafx00_fx_disc(vha, &vha->hw->mr.fcport, in qlafx00_configure_all_targets()
1233 set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); in qlafx00_configure_all_targets()
1239 set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); in qlafx00_configure_all_targets()
1246 list_for_each_entry(fcport, &vha->vp_fcports, list) { in qlafx00_configure_all_targets()
1247 if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) in qlafx00_configure_all_targets()
1250 if (atomic_read(&fcport->state) == FCS_DEVICE_LOST) { in qlafx00_configure_all_targets()
1251 if (fcport->port_type != FCT_INITIATOR) in qlafx00_configure_all_targets()
1260 if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) in qlafx00_configure_all_targets()
1264 list_move_tail(&fcport->list, &vha->vp_fcports); in qlafx00_configure_all_targets()
1268 fcport->tgt_id, in qlafx00_configure_all_targets()
1269 (unsigned long long)wwn_to_u64(fcport->node_name), in qlafx00_configure_all_targets()
1270 (unsigned long long)wwn_to_u64(fcport->port_name)); in qlafx00_configure_all_targets()
1275 list_del(&fcport->list); in qlafx00_configure_all_targets()
1302 flags = vha->dpc_flags; in qlafx00_configure_devices()
1305 "Configure devices -- dpc flags =0x%lx\n", flags); in qlafx00_configure_devices()
1310 if (test_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags)) { in qlafx00_configure_devices()
1313 atomic_set(&vha->loop_state, LOOP_READY); in qlafx00_configure_devices()
1332 struct qla_hw_data *ha = vha->hw; in qlafx00_abort_isp_cleanup()
1335 vha->flags.online = 0; in qlafx00_abort_isp_cleanup()
1336 ha->mr.fw_hbt_en = 0; in qlafx00_abort_isp_cleanup()
1339 ha->flags.chip_reset_done = 0; in qlafx00_abort_isp_cleanup()
1340 clear_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); in qlafx00_abort_isp_cleanup()
1341 vha->qla_stats.total_isp_aborts++; in qlafx00_abort_isp_cleanup()
1343 "Performing ISP error recovery - ha = %p.\n", ha); in qlafx00_abort_isp_cleanup()
1344 ha->isp_ops->reset_chip(vha); in qlafx00_abort_isp_cleanup()
1347 if (atomic_read(&vha->loop_state) != LOOP_DOWN) { in qlafx00_abort_isp_cleanup()
1348 atomic_set(&vha->loop_state, LOOP_DOWN); in qlafx00_abort_isp_cleanup()
1349 atomic_set(&vha->loop_down_timer, in qlafx00_abort_isp_cleanup()
1352 if (!atomic_read(&vha->loop_down_timer)) in qlafx00_abort_isp_cleanup()
1353 atomic_set(&vha->loop_down_timer, in qlafx00_abort_isp_cleanup()
1358 list_for_each_entry(fcport, &vha->vp_fcports, list) { in qlafx00_abort_isp_cleanup()
1359 fcport->flags = 0; in qlafx00_abort_isp_cleanup()
1360 if (atomic_read(&fcport->state) == FCS_ONLINE) in qlafx00_abort_isp_cleanup()
1364 if (!ha->flags.eeh_busy) { in qlafx00_abort_isp_cleanup()
1375 set_bit(FX00_CRITEMP_RECOVERY, &vha->dpc_flags); in qlafx00_abort_isp_cleanup()
1377 set_bit(FX00_RESET_RECOVERY, &vha->dpc_flags); in qlafx00_abort_isp_cleanup()
1383 "%s Done done - ha=%p.\n", __func__, ha); in qlafx00_abort_isp_cleanup()
1387 * qlafx00_init_response_q_entries() - Initializes response queue entries.
1401 rsp->ring_ptr = rsp->ring; in qlafx00_init_response_q_entries()
1402 rsp->ring_index = 0; in qlafx00_init_response_q_entries()
1403 rsp->status_srb = NULL; in qlafx00_init_response_q_entries()
1404 pkt = rsp->ring_ptr; in qlafx00_init_response_q_entries()
1405 for (cnt = 0; cnt < rsp->length; cnt++) { in qlafx00_init_response_q_entries()
1406 pkt->signature = RESPONSE_PROCESSED; in qlafx00_init_response_q_entries()
1407 wrt_reg_dword((void __force __iomem *)&pkt->signature, in qlafx00_init_response_q_entries()
1417 struct qla_hw_data *ha = vha->hw; in qlafx00_rescan_isp()
1418 struct device_reg_fx00 __iomem *reg = &ha->iobase->ispfx00; in qlafx00_rescan_isp()
1421 qla2x00_request_irqs(ha, ha->rsp_q_map[0]); in qlafx00_rescan_isp()
1423 aenmbx7 = rd_reg_dword(®->aenmailbox7); in qlafx00_rescan_isp()
1424 ha->mbx_intr_code = MSW(aenmbx7); in qlafx00_rescan_isp()
1425 ha->rqstq_intr_code = LSW(aenmbx7); in qlafx00_rescan_isp()
1426 ha->req_que_off = rd_reg_dword(®->aenmailbox1); in qlafx00_rescan_isp()
1427 ha->rsp_que_off = rd_reg_dword(®->aenmailbox3); in qlafx00_rescan_isp()
1428 ha->req_que_len = rd_reg_dword(®->aenmailbox5); in qlafx00_rescan_isp()
1429 ha->rsp_que_len = rd_reg_dword(®->aenmailbox6); in qlafx00_rescan_isp()
1434 ha->mbx_intr_code, ha->rqstq_intr_code, in qlafx00_rescan_isp()
1435 ha->req_que_off, ha->rsp_que_len); in qlafx00_rescan_isp()
1442 vha->flags.online = 1; in qlafx00_rescan_isp()
1445 if ((vha->device_flags & DFLG_NO_CABLE)) in qlafx00_rescan_isp()
1449 &vha->hw->mr.fcport, FXDISC_REG_HOST_INFO)) in qlafx00_rescan_isp()
1453 scsi_unblock_requests(vha->host); in qlafx00_rescan_isp()
1460 struct qla_hw_data *ha = vha->hw; in qlafx00_timer_routine()
1463 struct device_reg_fx00 __iomem *reg = &ha->iobase->ispfx00; in qlafx00_timer_routine()
1467 if (ha->mr.fw_hbt_cnt) in qlafx00_timer_routine()
1468 ha->mr.fw_hbt_cnt--; in qlafx00_timer_routine()
1470 if ((!ha->flags.mr_reset_hdlr_active) && in qlafx00_timer_routine()
1471 (!test_bit(UNLOADING, &vha->dpc_flags)) && in qlafx00_timer_routine()
1472 (!test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags)) && in qlafx00_timer_routine()
1473 (ha->mr.fw_hbt_en)) { in qlafx00_timer_routine()
1474 fw_heart_beat = rd_reg_dword(®->fwheartbeat); in qlafx00_timer_routine()
1475 if (fw_heart_beat != ha->mr.old_fw_hbt_cnt) { in qlafx00_timer_routine()
1476 ha->mr.old_fw_hbt_cnt = fw_heart_beat; in qlafx00_timer_routine()
1477 ha->mr.fw_hbt_miss_cnt = 0; in qlafx00_timer_routine()
1479 ha->mr.fw_hbt_miss_cnt++; in qlafx00_timer_routine()
1480 if (ha->mr.fw_hbt_miss_cnt == in qlafx00_timer_routine()
1483 &vha->dpc_flags); in qlafx00_timer_routine()
1485 ha->mr.fw_hbt_miss_cnt = 0; in qlafx00_timer_routine()
1489 ha->mr.fw_hbt_cnt = QLAFX00_HEARTBEAT_INTERVAL; in qlafx00_timer_routine()
1492 if (test_bit(FX00_RESET_RECOVERY, &vha->dpc_flags)) { in qlafx00_timer_routine()
1494 aenmbx0 = rd_reg_dword(®->aenmailbox0); in qlafx00_timer_routine()
1495 if (ha->mr.fw_reset_timer_exp) { in qlafx00_timer_routine()
1496 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); in qlafx00_timer_routine()
1498 ha->mr.fw_reset_timer_exp = 0; in qlafx00_timer_routine()
1501 set_bit(FX00_TARGET_SCAN, &vha->dpc_flags); in qlafx00_timer_routine()
1502 clear_bit(FX00_RESET_RECOVERY, &vha->dpc_flags); in qlafx00_timer_routine()
1504 ha->mr.fw_reset_timer_tick = QLAFX00_RESET_INTERVAL; in qlafx00_timer_routine()
1506 (!ha->mr.fw_hbt_en)) { in qlafx00_timer_routine()
1507 ha->mr.fw_hbt_en = 1; in qlafx00_timer_routine()
1508 } else if (!ha->mr.fw_reset_timer_tick) { in qlafx00_timer_routine()
1509 if (aenmbx0 == ha->mr.old_aenmbx0_state) in qlafx00_timer_routine()
1510 ha->mr.fw_reset_timer_exp = 1; in qlafx00_timer_routine()
1511 ha->mr.fw_reset_timer_tick = QLAFX00_RESET_INTERVAL; in qlafx00_timer_routine()
1527 ha->mr.fw_reset_timer_tick = in qlafx00_timer_routine()
1530 ha->mr.fw_reset_timer_tick = in qlafx00_timer_routine()
1533 if (ha->mr.old_aenmbx0_state != aenmbx0) { in qlafx00_timer_routine()
1534 ha->mr.old_aenmbx0_state = aenmbx0; in qlafx00_timer_routine()
1535 ha->mr.fw_reset_timer_tick = QLAFX00_RESET_INTERVAL; in qlafx00_timer_routine()
1537 ha->mr.fw_reset_timer_tick--; in qlafx00_timer_routine()
1539 if (test_bit(FX00_CRITEMP_RECOVERY, &vha->dpc_flags)) { in qlafx00_timer_routine()
1544 if (ha->mr.fw_critemp_timer_tick == 0) { in qlafx00_timer_routine()
1550 if (tempc < ha->mr.critical_temperature) { in qlafx00_timer_routine()
1551 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); in qlafx00_timer_routine()
1553 &vha->dpc_flags); in qlafx00_timer_routine()
1556 ha->mr.fw_critemp_timer_tick = in qlafx00_timer_routine()
1559 ha->mr.fw_critemp_timer_tick--; in qlafx00_timer_routine()
1562 if (ha->mr.host_info_resend) { in qlafx00_timer_routine()
1565 * durinng system boot - info should be resend in qlafx00_timer_routine()
1567 if (ha->mr.hinfo_resend_timer_tick == 0) { in qlafx00_timer_routine()
1568 ha->mr.host_info_resend = false; in qlafx00_timer_routine()
1569 set_bit(FX00_HOST_INFO_RESEND, &vha->dpc_flags); in qlafx00_timer_routine()
1570 ha->mr.hinfo_resend_timer_tick = in qlafx00_timer_routine()
1574 ha->mr.hinfo_resend_timer_tick--; in qlafx00_timer_routine()
1582 * Re-initialize after a iSA device reset.
1593 struct qla_hw_data *ha = vha->hw; in qlafx00_reset_initialize()
1595 if (vha->device_flags & DFLG_DEV_FAILED) { in qlafx00_reset_initialize()
1601 ha->flags.mr_reset_hdlr_active = 1; in qlafx00_reset_initialize()
1603 if (vha->flags.online) { in qlafx00_reset_initialize()
1604 scsi_block_requests(vha->host); in qlafx00_reset_initialize()
1610 ha->flags.mr_reset_hdlr_active = 0; in qlafx00_reset_initialize()
1627 struct qla_hw_data *ha = vha->hw; in qlafx00_abort_isp()
1629 if (vha->flags.online) { in qlafx00_abort_isp()
1630 if (unlikely(pci_channel_offline(ha->pdev) && in qlafx00_abort_isp()
1631 ha->flags.pci_channel_io_perm_failure)) { in qlafx00_abort_isp()
1632 clear_bit(ISP_ABORT_RETRY, &vha->dpc_flags); in qlafx00_abort_isp()
1636 scsi_block_requests(vha->host); in qlafx00_abort_isp()
1639 scsi_block_requests(vha->host); in qlafx00_abort_isp()
1640 clear_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); in qlafx00_abort_isp()
1641 vha->qla_stats.total_isp_aborts++; in qlafx00_abort_isp()
1642 ha->isp_ops->reset_chip(vha); in qlafx00_abort_isp()
1643 set_bit(FX00_RESET_RECOVERY, &vha->dpc_flags); in qlafx00_abort_isp()
1660 list_for_each_entry(fcport, &vha->vp_fcports, list) { in qlafx00_get_fcport()
1661 if (fcport->tgt_id == tgt_id) { in qlafx00_get_fcport()
1663 "Matching fcport(%p) found with TGT-ID: 0x%x " in qlafx00_get_fcport()
1665 fcport, fcport->tgt_id, tgt_id); in qlafx00_get_fcport()
1678 "Detach TGT-ID: 0x%x\n", tgt_id); in qlafx00_tgt_detach()
1695 aen_data = evt->u.aenfx.evtcode; in qlafx00_process_aen()
1697 switch (evt->u.aenfx.evtcode) { in qlafx00_process_aen()
1699 if (evt->u.aenfx.mbx[1] == 0) { in qlafx00_process_aen()
1700 if (evt->u.aenfx.mbx[2] == 1) { in qlafx00_process_aen()
1701 if (!vha->flags.fw_tgt_reported) in qlafx00_process_aen()
1702 vha->flags.fw_tgt_reported = 1; in qlafx00_process_aen()
1703 atomic_set(&vha->loop_down_timer, 0); in qlafx00_process_aen()
1704 atomic_set(&vha->loop_state, LOOP_UP); in qlafx00_process_aen()
1705 set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); in qlafx00_process_aen()
1707 } else if (evt->u.aenfx.mbx[2] == 2) { in qlafx00_process_aen()
1708 qlafx00_tgt_detach(vha, evt->u.aenfx.mbx[3]); in qlafx00_process_aen()
1710 } else if (evt->u.aenfx.mbx[1] == 0xffff) { in qlafx00_process_aen()
1711 if (evt->u.aenfx.mbx[2] == 1) { in qlafx00_process_aen()
1712 if (!vha->flags.fw_tgt_reported) in qlafx00_process_aen()
1713 vha->flags.fw_tgt_reported = 1; in qlafx00_process_aen()
1714 set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); in qlafx00_process_aen()
1715 } else if (evt->u.aenfx.mbx[2] == 2) { in qlafx00_process_aen()
1716 vha->device_flags |= DFLG_NO_CABLE; in qlafx00_process_aen()
1733 evt->u.aenfx.evtcode); in qlafx00_process_aen()
1734 scsi_block_requests(vha->host); in qlafx00_process_aen()
1736 scsi_unblock_requests(vha->host); in qlafx00_process_aen()
1740 fc_host_post_event(vha->host, fc_get_event_number(), in qlafx00_process_aen()
1749 port_name = (unsigned long long)wwn_to_u64(pinfo->port_name); in qlafx00_update_host_attr()
1750 node_name = (unsigned long long)wwn_to_u64(pinfo->node_name); in qlafx00_update_host_attr()
1752 fc_host_node_name(vha->host) = node_name; in qlafx00_update_host_attr()
1753 fc_host_port_name(vha->host) = port_name; in qlafx00_update_host_attr()
1754 if (!pinfo->port_type) in qlafx00_update_host_attr()
1755 vha->hw->current_topology = ISP_CFG_F; in qlafx00_update_host_attr()
1756 if (pinfo->link_status == QLAFX00_LINK_STATUS_UP) in qlafx00_update_host_attr()
1757 atomic_set(&vha->loop_state, LOOP_READY); in qlafx00_update_host_attr()
1758 else if (pinfo->link_status == QLAFX00_LINK_STATUS_DOWN) in qlafx00_update_host_attr()
1759 atomic_set(&vha->loop_state, LOOP_DOWN); in qlafx00_update_host_attr()
1760 vha->hw->link_data_rate = (uint16_t)pinfo->link_config; in qlafx00_update_host_attr()
1767 struct srb_iocb *lio = &sp->u.iocb_cmd; in qla2x00_fxdisc_iocb_timeout()
1769 complete(&lio->u.fxiocb.fxiocb_comp); in qla2x00_fxdisc_iocb_timeout()
1774 struct srb_iocb *lio = &sp->u.iocb_cmd; in qla2x00_fxdisc_sp_done()
1776 complete(&lio->u.fxiocb.fxiocb_comp); in qla2x00_fxdisc_sp_done()
1785 struct qla_hw_data *ha = vha->hw; in qlafx00_fx_disc()
1795 sp->type = SRB_FXIOCB_DCMD; in qlafx00_fx_disc()
1796 sp->name = "fxdisc"; in qlafx00_fx_disc()
1799 sp->u.iocb_cmd.timeout = qla2x00_fxdisc_iocb_timeout; in qlafx00_fx_disc()
1801 fdisc = &sp->u.iocb_cmd; in qlafx00_fx_disc()
1804 fdisc->u.fxiocb.flags = in qlafx00_fx_disc()
1806 fdisc->u.fxiocb.rsp_len = sizeof(struct config_info_data); in qlafx00_fx_disc()
1809 fdisc->u.fxiocb.flags = in qlafx00_fx_disc()
1811 fdisc->u.fxiocb.rsp_len = QLAFX00_PORT_DATA_INFO; in qlafx00_fx_disc()
1812 fdisc->u.fxiocb.req_data = cpu_to_le32(fcport->port_id); in qlafx00_fx_disc()
1815 fdisc->u.fxiocb.flags = in qlafx00_fx_disc()
1817 fdisc->u.fxiocb.rsp_len = QLAFX00_TGT_NODE_INFO; in qlafx00_fx_disc()
1818 fdisc->u.fxiocb.req_data = cpu_to_le32(fcport->tgt_id); in qlafx00_fx_disc()
1821 fdisc->u.fxiocb.flags = in qlafx00_fx_disc()
1823 fdisc->u.fxiocb.rsp_len = QLAFX00_TGT_NODE_LIST_SIZE; in qlafx00_fx_disc()
1826 fdisc->u.fxiocb.flags = SRB_FXDISC_REQ_DMA_VALID; in qlafx00_fx_disc()
1827 fdisc->u.fxiocb.req_len = sizeof(struct register_host_info); in qlafx00_fx_disc()
1840 if (fdisc->u.fxiocb.flags & SRB_FXDISC_REQ_DMA_VALID) { in qlafx00_fx_disc()
1841 fdisc->u.fxiocb.req_addr = dma_alloc_coherent(&ha->pdev->dev, in qlafx00_fx_disc()
1842 fdisc->u.fxiocb.req_len, in qlafx00_fx_disc()
1843 &fdisc->u.fxiocb.req_dma_handle, GFP_KERNEL); in qlafx00_fx_disc()
1844 if (!fdisc->u.fxiocb.req_addr) in qlafx00_fx_disc()
1849 fdisc->u.fxiocb.req_addr; in qlafx00_fx_disc()
1850 phost_info = &preg_hsi->hsi; in qlafx00_fx_disc()
1852 phost_info->os_type = OS_TYPE_LINUX; in qlafx00_fx_disc()
1853 strscpy(phost_info->sysname, p_sysid->sysname, in qlafx00_fx_disc()
1854 sizeof(phost_info->sysname)); in qlafx00_fx_disc()
1855 strscpy(phost_info->nodename, p_sysid->nodename, in qlafx00_fx_disc()
1856 sizeof(phost_info->nodename)); in qlafx00_fx_disc()
1857 if (!strcmp(phost_info->nodename, "(none)")) in qlafx00_fx_disc()
1858 ha->mr.host_info_resend = true; in qlafx00_fx_disc()
1859 strscpy(phost_info->release, p_sysid->release, in qlafx00_fx_disc()
1860 sizeof(phost_info->release)); in qlafx00_fx_disc()
1861 strscpy(phost_info->version, p_sysid->version, in qlafx00_fx_disc()
1862 sizeof(phost_info->version)); in qlafx00_fx_disc()
1863 strscpy(phost_info->machine, p_sysid->machine, in qlafx00_fx_disc()
1864 sizeof(phost_info->machine)); in qlafx00_fx_disc()
1865 strscpy(phost_info->domainname, p_sysid->domainname, in qlafx00_fx_disc()
1866 sizeof(phost_info->domainname)); in qlafx00_fx_disc()
1867 strscpy(phost_info->hostdriver, QLA2XXX_VERSION, in qlafx00_fx_disc()
1868 sizeof(phost_info->hostdriver)); in qlafx00_fx_disc()
1869 preg_hsi->utc = (uint64_t)ktime_get_real_seconds(); in qlafx00_fx_disc()
1872 ha->pdev->device); in qlafx00_fx_disc()
1875 phost_info->os_type, in qlafx00_fx_disc()
1876 phost_info->sysname, in qlafx00_fx_disc()
1877 phost_info->nodename); in qlafx00_fx_disc()
1880 phost_info->release, in qlafx00_fx_disc()
1881 phost_info->version); in qlafx00_fx_disc()
1885 phost_info->machine, in qlafx00_fx_disc()
1886 phost_info->domainname, in qlafx00_fx_disc()
1887 phost_info->hostdriver); in qlafx00_fx_disc()
1893 if (fdisc->u.fxiocb.flags & SRB_FXDISC_RESP_DMA_VALID) { in qlafx00_fx_disc()
1894 fdisc->u.fxiocb.rsp_addr = dma_alloc_coherent(&ha->pdev->dev, in qlafx00_fx_disc()
1895 fdisc->u.fxiocb.rsp_len, in qlafx00_fx_disc()
1896 &fdisc->u.fxiocb.rsp_dma_handle, GFP_KERNEL); in qlafx00_fx_disc()
1897 if (!fdisc->u.fxiocb.rsp_addr) in qlafx00_fx_disc()
1901 fdisc->u.fxiocb.req_func_type = cpu_to_le16(fx_type); in qlafx00_fx_disc()
1907 wait_for_completion(&fdisc->u.fxiocb.fxiocb_comp); in qlafx00_fx_disc()
1911 (struct config_info_data *) fdisc->u.fxiocb.rsp_addr; in qlafx00_fx_disc()
1912 memtostr(vha->hw->model_number, pinfo->model_num); in qlafx00_fx_disc()
1913 memtostr(vha->hw->model_desc, pinfo->model_description); in qlafx00_fx_disc()
1914 memcpy(&vha->hw->mr.symbolic_name, pinfo->symbolic_name, in qlafx00_fx_disc()
1915 sizeof(vha->hw->mr.symbolic_name)); in qlafx00_fx_disc()
1916 memcpy(&vha->hw->mr.serial_num, pinfo->serial_num, in qlafx00_fx_disc()
1917 sizeof(vha->hw->mr.serial_num)); in qlafx00_fx_disc()
1918 memcpy(&vha->hw->mr.hw_version, pinfo->hw_version, in qlafx00_fx_disc()
1919 sizeof(vha->hw->mr.hw_version)); in qlafx00_fx_disc()
1920 memcpy(&vha->hw->mr.fw_version, pinfo->fw_version, in qlafx00_fx_disc()
1921 sizeof(vha->hw->mr.fw_version)); in qlafx00_fx_disc()
1922 strim(vha->hw->mr.fw_version); in qlafx00_fx_disc()
1923 memcpy(&vha->hw->mr.uboot_version, pinfo->uboot_version, in qlafx00_fx_disc()
1924 sizeof(vha->hw->mr.uboot_version)); in qlafx00_fx_disc()
1925 memcpy(&vha->hw->mr.fru_serial_num, pinfo->fru_serial_num, in qlafx00_fx_disc()
1926 sizeof(vha->hw->mr.fru_serial_num)); in qlafx00_fx_disc()
1927 vha->hw->mr.critical_temperature = in qlafx00_fx_disc()
1928 (pinfo->nominal_temp_value) ? in qlafx00_fx_disc()
1929 pinfo->nominal_temp_value : QLAFX00_CRITEMP_THRSHLD; in qlafx00_fx_disc()
1930 ha->mr.extended_io_enabled = (pinfo->enabled_capabilities & in qlafx00_fx_disc()
1934 (struct port_info_data *) fdisc->u.fxiocb.rsp_addr; in qlafx00_fx_disc()
1935 memcpy(vha->node_name, pinfo->node_name, WWN_SIZE); in qlafx00_fx_disc()
1936 memcpy(vha->port_name, pinfo->port_name, WWN_SIZE); in qlafx00_fx_disc()
1937 vha->d_id.b.domain = pinfo->port_id[0]; in qlafx00_fx_disc()
1938 vha->d_id.b.area = pinfo->port_id[1]; in qlafx00_fx_disc()
1939 vha->d_id.b.al_pa = pinfo->port_id[2]; in qlafx00_fx_disc()
1945 (struct qlafx00_tgt_node_info *) fdisc->u.fxiocb.rsp_addr; in qlafx00_fx_disc()
1946 memcpy(fcport->node_name, pinfo->tgt_node_wwnn, WWN_SIZE); in qlafx00_fx_disc()
1947 memcpy(fcport->port_name, pinfo->tgt_node_wwpn, WWN_SIZE); in qlafx00_fx_disc()
1948 fcport->port_type = FCT_TARGET; in qlafx00_fx_disc()
1953 (struct qlafx00_tgt_node_info *) fdisc->u.fxiocb.rsp_addr; in qlafx00_fx_disc()
1956 memcpy(vha->hw->gid_list, pinfo, QLAFX00_TGT_NODE_LIST_SIZE); in qlafx00_fx_disc()
1958 fdisc->u.fxiocb.result = in qlafx00_fx_disc()
1959 (fdisc->u.fxiocb.result == in qlafx00_fx_disc()
1963 rval = le32_to_cpu(fdisc->u.fxiocb.result); in qlafx00_fx_disc()
1966 if (fdisc->u.fxiocb.rsp_addr) in qlafx00_fx_disc()
1967 dma_free_coherent(&ha->pdev->dev, fdisc->u.fxiocb.rsp_len, in qlafx00_fx_disc()
1968 fdisc->u.fxiocb.rsp_addr, fdisc->u.fxiocb.rsp_dma_handle); in qlafx00_fx_disc()
1971 if (fdisc->u.fxiocb.req_addr) in qlafx00_fx_disc()
1972 dma_free_coherent(&ha->pdev->dev, fdisc->u.fxiocb.req_len, in qlafx00_fx_disc()
1973 fdisc->u.fxiocb.req_addr, fdisc->u.fxiocb.req_dma_handle); in qlafx00_fx_disc()
1976 kref_put(&sp->cmd_kref, qla2x00_sp_release); in qlafx00_fx_disc()
1995 struct qla_hw_data *ha = vha->hw; in qlafx00_initialize_adapter()
1999 vha->flags.online = 0; in qlafx00_initialize_adapter()
2000 ha->flags.chip_reset_done = 0; in qlafx00_initialize_adapter()
2001 vha->flags.reset_active = 0; in qlafx00_initialize_adapter()
2002 ha->flags.pci_channel_io_perm_failure = 0; in qlafx00_initialize_adapter()
2003 ha->flags.eeh_busy = 0; in qlafx00_initialize_adapter()
2004 atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME); in qlafx00_initialize_adapter()
2005 atomic_set(&vha->loop_state, LOOP_DOWN); in qlafx00_initialize_adapter()
2006 vha->device_flags = DFLG_NO_CABLE; in qlafx00_initialize_adapter()
2007 vha->dpc_flags = 0; in qlafx00_initialize_adapter()
2008 vha->flags.management_server_logged_in = 0; in qlafx00_initialize_adapter()
2009 ha->isp_abort_cnt = 0; in qlafx00_initialize_adapter()
2010 ha->beacon_blink_led = 0; in qlafx00_initialize_adapter()
2012 set_bit(0, ha->req_qid_map); in qlafx00_initialize_adapter()
2013 set_bit(0, ha->rsp_qid_map); in qlafx00_initialize_adapter()
2018 rval = ha->isp_ops->pci_config(vha); in qlafx00_initialize_adapter()
2039 rval = qla2x00_alloc_outstanding_cmds(ha, vha->req); in qlafx00_initialize_adapter()
2044 ha->flags.chip_reset_done = 1; in qlafx00_initialize_adapter()
2065 else if (!vha->hw->flags.eeh_busy) { in qlafx00_fw_state_show()
2069 memset(state, -1, sizeof(state)); in qlafx00_fw_state_show()
2078 (shost_priv(shost)))->hw; in qlafx00_get_host_speed()
2081 switch (ha->link_data_rate) { in qlafx00_get_host_speed()
2104 struct scsi_qla_host *vha = sp->vha; in qlafx00_handle_sense()
2114 SET_CMD_SENSE_PTR(sp, cp->sense_buffer); in qlafx00_handle_sense()
2120 memcpy(cp->sense_buffer, sense_data, sense_len); in qlafx00_handle_sense()
2122 SET_FW_SENSE_LEN(sp, GET_FW_SENSE_LEN(sp) - sense_len); in qlafx00_handle_sense()
2124 SET_CMD_SENSE_PTR(sp, cp->sense_buffer + sense_len); in qlafx00_handle_sense()
2125 track_sense_len -= sense_len; in qlafx00_handle_sense()
2132 rsp->status_srb = sp; in qlafx00_handle_sense()
2133 cp->result = res; in qlafx00_handle_sense()
2139 sp->vha->host_no, cp->device->id, cp->device->lun, in qlafx00_handle_sense()
2142 cp->sense_buffer, sense_len); in qlafx00_handle_sense()
2153 tmf = &sp->u.iocb_cmd; in qlafx00_tm_iocb_entry()
2157 tmf->u.tmf.comp_status = cpstatus; in qlafx00_tm_iocb_entry()
2158 sp->done(sp, 0); in qlafx00_tm_iocb_entry()
2173 abt = &sp->u.iocb_cmd; in qlafx00_abort_iocb_entry()
2174 abt->u.abt.comp_status = pkt->tgt_id_sts; in qlafx00_abort_iocb_entry()
2175 sp->done(sp, 0); in qlafx00_abort_iocb_entry()
2195 if (sp->type == SRB_FXIOCB_DCMD) { in qlafx00_ioctl_iosb_entry()
2196 iocb_job = &sp->u.iocb_cmd; in qlafx00_ioctl_iosb_entry()
2197 iocb_job->u.fxiocb.seq_number = pkt->seq_no; in qlafx00_ioctl_iosb_entry()
2198 iocb_job->u.fxiocb.fw_flags = pkt->fw_iotcl_flags; in qlafx00_ioctl_iosb_entry()
2199 iocb_job->u.fxiocb.result = pkt->status; in qlafx00_ioctl_iosb_entry()
2200 if (iocb_job->u.fxiocb.flags & SRB_FXDISC_RSP_DWRD_VALID) in qlafx00_ioctl_iosb_entry()
2201 iocb_job->u.fxiocb.req_data = in qlafx00_ioctl_iosb_entry()
2202 pkt->dataword_r; in qlafx00_ioctl_iosb_entry()
2204 bsg_job = sp->u.bsg_job; in qlafx00_ioctl_iosb_entry()
2205 bsg_reply = bsg_job->reply; in qlafx00_ioctl_iosb_entry()
2209 fstatus.reserved_1 = pkt->reserved_0; in qlafx00_ioctl_iosb_entry()
2210 fstatus.func_type = pkt->comp_func_num; in qlafx00_ioctl_iosb_entry()
2211 fstatus.ioctl_flags = pkt->fw_iotcl_flags; in qlafx00_ioctl_iosb_entry()
2212 fstatus.ioctl_data = pkt->dataword_r; in qlafx00_ioctl_iosb_entry()
2213 fstatus.adapid = pkt->adapid; in qlafx00_ioctl_iosb_entry()
2214 fstatus.reserved_2 = pkt->dataword_r_extra; in qlafx00_ioctl_iosb_entry()
2215 fstatus.res_count = pkt->residuallen; in qlafx00_ioctl_iosb_entry()
2216 fstatus.status = pkt->status; in qlafx00_ioctl_iosb_entry()
2217 fstatus.seq_number = pkt->seq_no; in qlafx00_ioctl_iosb_entry()
2219 pkt->reserved_2, 20 * sizeof(uint8_t)); in qlafx00_ioctl_iosb_entry()
2221 fw_sts_ptr = bsg_job->reply + sizeof(struct fc_bsg_reply); in qlafx00_ioctl_iosb_entry()
2224 bsg_job->reply_len = sizeof(struct fc_bsg_reply) + in qlafx00_ioctl_iosb_entry()
2228 sp->vha, 0x5080, pkt, sizeof(*pkt)); in qlafx00_ioctl_iosb_entry()
2231 sp->vha, 0x5074, in qlafx00_ioctl_iosb_entry()
2234 res = bsg_reply->result = DID_OK << 16; in qlafx00_ioctl_iosb_entry()
2235 bsg_reply->reply_payload_rcv_len = in qlafx00_ioctl_iosb_entry()
2236 bsg_job->reply_payload.payload_len; in qlafx00_ioctl_iosb_entry()
2238 sp->done(sp, res); in qlafx00_ioctl_iosb_entry()
2242 * qlafx00_status_entry() - Process a Status IOCB entry.
2261 struct qla_hw_data *ha = vha->hw; in qlafx00_status_entry()
2270 comp_status = sts->comp_status; in qlafx00_status_entry()
2271 scsi_status = sts->scsi_status & cpu_to_le16((uint16_t)SS_MASK); in qlafx00_status_entry()
2272 hindex = sts->handle; in qlafx00_status_entry()
2276 req = ha->req_q_map[que]; in qlafx00_status_entry()
2279 if (handle < req->num_outstanding_cmds) in qlafx00_status_entry()
2280 sp = req->outstanding_cmds[handle]; in qlafx00_status_entry()
2288 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); in qlafx00_status_entry()
2293 if (sp->type == SRB_TM_CMD) { in qlafx00_status_entry()
2294 req->outstanding_cmds[handle] = NULL; in qlafx00_status_entry()
2300 /* Fast path completion. */ in qlafx00_status_entry()
2306 req->outstanding_cmds[handle] = NULL; in qlafx00_status_entry()
2318 fcport = sp->fcport; in qlafx00_status_entry()
2323 sense_len = sts->sense_len; in qlafx00_status_entry()
2326 resid_len = le32_to_cpu(sts->residual_len); in qlafx00_status_entry()
2328 fw_resid_len = le32_to_cpu(sts->residual_len); in qlafx00_status_entry()
2329 rsp_info = sense_data = sts->data; in qlafx00_status_entry()
2330 par_sense_len = sizeof(sts->data); in qlafx00_status_entry()
2353 ((unsigned)(scsi_bufflen(cp) - resid) < in qlafx00_status_entry()
2354 cp->underflow)) { in qlafx00_status_entry()
2355 ql_dbg(ql_dbg_io, fcport->vha, 0x3050, in qlafx00_status_entry()
2356 "Mid-layer underflow " in qlafx00_status_entry()
2368 ql_dbg(ql_dbg_io, fcport->vha, 0x3051, in qlafx00_status_entry()
2376 memset(cp->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); in qlafx00_status_entry()
2394 ql_dbg(ql_dbg_io, fcport->vha, 0x3052, in qlafx00_status_entry()
2405 ((unsigned)(scsi_bufflen(cp) - resid) < in qlafx00_status_entry()
2406 cp->underflow)) { in qlafx00_status_entry()
2407 ql_dbg(ql_dbg_io, fcport->vha, 0x3053, in qlafx00_status_entry()
2408 "Mid-layer underflow " in qlafx00_status_entry()
2410 "cp->underflow: 0x%x).\n", in qlafx00_status_entry()
2411 resid, scsi_bufflen(cp), cp->underflow); in qlafx00_status_entry()
2424 ql_dbg(ql_dbg_io, fcport->vha, 0x3054, in qlafx00_status_entry()
2432 ql_dbg(ql_dbg_io, fcport->vha, 0x3055, in qlafx00_status_entry()
2448 ql_dbg(ql_dbg_io, fcport->vha, 0x3056, in qlafx00_status_entry()
2457 memset(cp->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); in qlafx00_status_entry()
2482 ql_dbg(ql_dbg_io, fcport->vha, 0x3057, in qlafx00_status_entry()
2483 "Port down status: port-state=0x%x.\n", in qlafx00_status_entry()
2484 atomic_read(&fcport->state)); in qlafx00_status_entry()
2486 if (atomic_read(&fcport->state) == FCS_ONLINE) in qlafx00_status_entry()
2487 qla2x00_mark_device_lost(fcport->vha, fcport, 1); in qlafx00_status_entry()
2500 ql_dbg(ql_dbg_io, fcport->vha, 0x3058, in qlafx00_status_entry()
2501 "FCP command status: 0x%x-0x%x (0x%x) nexus=%ld:%d:%llu " in qlafx00_status_entry()
2505 comp_status, scsi_status, res, vha->host_no, in qlafx00_status_entry()
2506 cp->device->id, cp->device->lun, fcport->tgt_id, in qlafx00_status_entry()
2507 lscsi_status, cp->cmnd, scsi_bufflen(cp), in qlafx00_status_entry()
2511 if (rsp->status_srb == NULL) in qlafx00_status_entry()
2512 sp->done(sp, res); in qlafx00_status_entry()
2518 * qlafx00_status_cont_entry() - Process a Status Continuations entry.
2528 struct qla_hw_data *ha = rsp->hw; in qlafx00_status_cont_entry()
2529 struct scsi_qla_host *vha = pci_get_drvdata(ha->pdev); in qlafx00_status_cont_entry()
2530 srb_t *sp = rsp->status_srb; in qlafx00_status_cont_entry()
2551 rsp->status_srb = NULL; in qlafx00_status_cont_entry()
2565 if (sense_len > sizeof(pkt->data)) in qlafx00_status_cont_entry()
2566 sense_sz = sizeof(pkt->data); in qlafx00_status_cont_entry()
2573 memcpy(sense_ptr, pkt->data, sense_sz); in qlafx00_status_cont_entry()
2577 sense_len -= sense_sz; in qlafx00_status_cont_entry()
2584 sense_len = (sense_len > sizeof(pkt->data)) ? in qlafx00_status_cont_entry()
2585 (sense_len - sizeof(pkt->data)) : 0; in qlafx00_status_cont_entry()
2590 rsp->status_srb = NULL; in qlafx00_status_cont_entry()
2591 sp->done(sp, cp->result); in qlafx00_status_cont_entry()
2598 * qlafx00_multistatus_entry() - Process Multi response queue entries.
2609 struct qla_hw_data *ha = vha->hw; in qlafx00_multistatus_entry()
2617 handle_count = stsmfx->handle_count; in qlafx00_multistatus_entry()
2622 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); in qlafx00_multistatus_entry()
2627 handle_ptr = &stsmfx->handles[0]; in qlafx00_multistatus_entry()
2633 req = ha->req_q_map[que]; in qlafx00_multistatus_entry()
2636 if (handle < req->num_outstanding_cmds) in qlafx00_multistatus_entry()
2637 sp = req->outstanding_cmds[handle]; in qlafx00_multistatus_entry()
2644 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); in qlafx00_multistatus_entry()
2654 * qlafx00_error_entry() - Process an error entry.
2664 struct qla_hw_data *ha = vha->hw; in qlafx00_error_entry()
2665 const char func[] = "ERROR-IOCB"; in qlafx00_error_entry()
2670 req = ha->req_q_map[que]; in qlafx00_error_entry()
2674 sp->done(sp, res); in qlafx00_error_entry()
2678 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); in qlafx00_error_entry()
2683 * qlafx00_process_response_queue() - Process response queue entries.
2696 lreq_q_in = rd_reg_dword(rsp->rsp_q_in); in qlafx00_process_response_queue()
2697 lreq_q_out = rsp->ring_index; in qlafx00_process_response_queue()
2700 lptr = rsp->ring_ptr; in qlafx00_process_response_queue()
2701 memcpy_fromio(rsp->rsp_pkt, (void __iomem *)lptr, in qlafx00_process_response_queue()
2702 sizeof(rsp->rsp_pkt)); in qlafx00_process_response_queue()
2703 pkt = (struct sts_entry_fx00 *)rsp->rsp_pkt; in qlafx00_process_response_queue()
2705 rsp->ring_index++; in qlafx00_process_response_queue()
2707 if (rsp->ring_index == rsp->length) { in qlafx00_process_response_queue()
2709 rsp->ring_index = 0; in qlafx00_process_response_queue()
2710 rsp->ring_ptr = rsp->ring; in qlafx00_process_response_queue()
2712 rsp->ring_ptr++; in qlafx00_process_response_queue()
2715 if (pkt->entry_status != 0 && in qlafx00_process_response_queue()
2716 pkt->entry_type != IOCTL_IOSB_TYPE_FX00) { in qlafx00_process_response_queue()
2719 pkt->entry_status); in qlafx00_process_response_queue()
2725 switch (pkt->entry_type) { in qlafx00_process_response_queue()
2739 qlafx00_abort_iocb_entry(vha, rsp->req, in qlafx00_process_response_queue()
2744 qlafx00_ioctl_iosb_entry(vha, rsp->req, in qlafx00_process_response_queue()
2752 pkt->entry_type, pkt->entry_status); in qlafx00_process_response_queue()
2758 wrt_reg_dword(rsp->rsp_q_out, rsp->ring_index); in qlafx00_process_response_queue()
2762 * qlafx00_async_event() - Process aynchronous events.
2768 struct qla_hw_data *ha = vha->hw; in qlafx00_async_event()
2772 reg = &ha->iobase->ispfx00; in qlafx00_async_event()
2774 switch (ha->aenmb[0]) { in qlafx00_async_event()
2777 "ISP System Error - mbx1=%x\n", ha->aenmb[0]); in qlafx00_async_event()
2778 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); in qlafx00_async_event()
2784 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); in qlafx00_async_event()
2789 ha->aenmb[1] = rd_reg_dword(®->aenmailbox1); in qlafx00_async_event()
2790 ha->aenmb[2] = rd_reg_dword(®->aenmailbox2); in qlafx00_async_event()
2791 ha->aenmb[3] = rd_reg_dword(®->aenmailbox3); in qlafx00_async_event()
2795 ha->aenmb[0], ha->aenmb[1], ha->aenmb[2], ha->aenmb[3]); in qlafx00_async_event()
2803 ha->aenmb[0]); in qlafx00_async_event()
2810 ha->aenmb[0]); in qlafx00_async_event()
2817 ha->aenmb[0]); in qlafx00_async_event()
2821 ha->aenmb[1] = rd_reg_dword(®->aenmailbox1); in qlafx00_async_event()
2822 ha->aenmb[2] = rd_reg_dword(®->aenmailbox2); in qlafx00_async_event()
2823 ha->aenmb[3] = rd_reg_dword(®->aenmailbox3); in qlafx00_async_event()
2824 ha->aenmb[4] = rd_reg_dword(®->aenmailbox4); in qlafx00_async_event()
2825 ha->aenmb[5] = rd_reg_dword(®->aenmailbox5); in qlafx00_async_event()
2826 ha->aenmb[6] = rd_reg_dword(®->aenmailbox6); in qlafx00_async_event()
2827 ha->aenmb[7] = rd_reg_dword(®->aenmailbox7); in qlafx00_async_event()
2830 ha->aenmb[0], ha->aenmb[1], ha->aenmb[2], ha->aenmb[3], in qlafx00_async_event()
2831 ha->aenmb[4], ha->aenmb[5], ha->aenmb[6], ha->aenmb[7]); in qlafx00_async_event()
2834 qlafx00_post_aenfx_work(vha, ha->aenmb[0], in qlafx00_async_event()
2835 (uint32_t *)ha->aenmb, data_size); in qlafx00_async_event()
2839 * qlafx00_mbx_completion() - Process mailbox command completions.
2848 struct qla_hw_data *ha = vha->hw; in qlafx00_mbx_completion()
2849 struct device_reg_fx00 __iomem *reg = &ha->iobase->ispfx00; in qlafx00_mbx_completion()
2851 if (!ha->mcp32) in qlafx00_mbx_completion()
2855 ha->flags.mbox_int = 1; in qlafx00_mbx_completion()
2856 ha->mailbox_out32[0] = mb0; in qlafx00_mbx_completion()
2857 wptr = ®->mailbox17; in qlafx00_mbx_completion()
2859 for (cnt = 1; cnt < ha->mbx_count; cnt++) { in qlafx00_mbx_completion()
2860 ha->mailbox_out32[cnt] = rd_reg_dword(wptr); in qlafx00_mbx_completion()
2866 * qlafx00_intr_handler() - Process interrupts for the ISPFX00.
2896 ha = rsp->hw; in qlafx00_intr_handler()
2897 reg = &ha->iobase->ispfx00; in qlafx00_intr_handler()
2900 if (unlikely(pci_channel_offline(ha->pdev))) in qlafx00_intr_handler()
2903 spin_lock_irqsave(&ha->hardware_lock, flags); in qlafx00_intr_handler()
2904 vha = pci_get_drvdata(ha->pdev); in qlafx00_intr_handler()
2905 for (iter = 50; iter--; clr_intr = 0) { in qlafx00_intr_handler()
2914 mb[0] = rd_reg_dword(®->mailbox16); in qlafx00_intr_handler()
2920 ha->aenmb[0] = rd_reg_dword(®->aenmailbox0); in qlafx00_intr_handler()
2934 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qlafx00_intr_handler()
2948 req->ring_index++; in qlafx00_prep_cont_type1_iocb()
2949 if (req->ring_index == req->length) { in qlafx00_prep_cont_type1_iocb()
2950 req->ring_index = 0; in qlafx00_prep_cont_type1_iocb()
2951 req->ring_ptr = req->ring; in qlafx00_prep_cont_type1_iocb()
2953 req->ring_ptr++; in qlafx00_prep_cont_type1_iocb()
2956 cont_pkt = (cont_a64_entry_t *)req->ring_ptr; in qlafx00_prep_cont_type1_iocb()
2959 lcont_pkt->entry_type = CONTINUE_A64_TYPE_FX00; in qlafx00_prep_cont_type1_iocb()
2978 vha = sp->vha; in qlafx00_build_scsi_iocbs()
2979 req = vha->req; in qlafx00_build_scsi_iocbs()
2986 lcmd_pkt->entry_type = FX00_COMMAND_TYPE_7; in qlafx00_build_scsi_iocbs()
2989 if (!scsi_bufflen(cmd) || cmd->sc_data_direction == DMA_NONE) { in qlafx00_build_scsi_iocbs()
2990 lcmd_pkt->byte_count = cpu_to_le32(0); in qlafx00_build_scsi_iocbs()
2995 if (cmd->sc_data_direction == DMA_TO_DEVICE) { in qlafx00_build_scsi_iocbs()
2996 lcmd_pkt->cntrl_flags = TMF_WRITE_DATA; in qlafx00_build_scsi_iocbs()
2997 vha->qla_stats.output_bytes += scsi_bufflen(cmd); in qlafx00_build_scsi_iocbs()
2998 } else if (cmd->sc_data_direction == DMA_FROM_DEVICE) { in qlafx00_build_scsi_iocbs()
2999 lcmd_pkt->cntrl_flags = TMF_READ_DATA; in qlafx00_build_scsi_iocbs()
3000 vha->qla_stats.input_bytes += scsi_bufflen(cmd); in qlafx00_build_scsi_iocbs()
3003 /* One DSD is available in the Command Type 3 IOCB */ in qlafx00_build_scsi_iocbs()
3005 cur_dsd = &lcmd_pkt->dsd; in qlafx00_build_scsi_iocbs()
3018 cur_dsd = lcont_pkt.dsd; in qlafx00_build_scsi_iocbs()
3024 avail_dsds--; in qlafx00_build_scsi_iocbs()
3039 * qlafx00_start_scsi() - Send a SCSI command to the ISP
3042 * Returns non-zero if a failure occurred, else zero.
3056 struct scsi_qla_host *vha = sp->vha; in qlafx00_start_scsi()
3057 struct qla_hw_data *ha = vha->hw; in qlafx00_start_scsi()
3063 rsp = ha->rsp_q_map[0]; in qlafx00_start_scsi()
3064 req = vha->req; in qlafx00_start_scsi()
3070 spin_lock_irqsave(&ha->hardware_lock, flags); in qlafx00_start_scsi()
3078 nseg = dma_map_sg(&ha->pdev->dev, scsi_sglist(cmd), in qlafx00_start_scsi()
3079 scsi_sg_count(cmd), cmd->sc_data_direction); in qlafx00_start_scsi()
3087 if (req->cnt < (req_cnt + 2)) { in qlafx00_start_scsi()
3088 cnt = rd_reg_dword_relaxed(req->req_q_out); in qlafx00_start_scsi()
3090 if (req->ring_index < cnt) in qlafx00_start_scsi()
3091 req->cnt = cnt - req->ring_index; in qlafx00_start_scsi()
3093 req->cnt = req->length - in qlafx00_start_scsi()
3094 (req->ring_index - cnt); in qlafx00_start_scsi()
3095 if (req->cnt < (req_cnt + 2)) in qlafx00_start_scsi()
3100 req->current_outstanding_cmd = handle; in qlafx00_start_scsi()
3101 req->outstanding_cmds[handle] = sp; in qlafx00_start_scsi()
3102 sp->handle = handle; in qlafx00_start_scsi()
3103 cmd->host_scribble = (unsigned char *)(unsigned long)handle; in qlafx00_start_scsi()
3104 req->cnt -= req_cnt; in qlafx00_start_scsi()
3106 cmd_pkt = (struct cmd_type_7_fx00 *)req->ring_ptr; in qlafx00_start_scsi()
3110 lcmd_pkt.handle = make_handle(req->id, sp->handle); in qlafx00_start_scsi()
3115 lcmd_pkt.tgt_idx = cpu_to_le16(sp->fcport->tgt_id); in qlafx00_start_scsi()
3117 int_to_scsilun(cmd->device->lun, &llun); in qlafx00_start_scsi()
3122 host_to_adap(cmd->cmnd, lcmd_pkt.fcp_cdb, sizeof(lcmd_pkt.fcp_cdb)); in qlafx00_start_scsi()
3132 lcmd_pkt.entry_status = (uint8_t) rsp->id; in qlafx00_start_scsi()
3135 cmd->cmnd, cmd->cmd_len); in qlafx00_start_scsi()
3143 req->ring_index++; in qlafx00_start_scsi()
3144 if (req->ring_index == req->length) { in qlafx00_start_scsi()
3145 req->ring_index = 0; in qlafx00_start_scsi()
3146 req->ring_ptr = req->ring; in qlafx00_start_scsi()
3148 req->ring_ptr++; in qlafx00_start_scsi()
3150 sp->flags |= SRB_DMA_VALID; in qlafx00_start_scsi()
3153 wrt_reg_dword(req->req_q_in, req->ring_index); in qlafx00_start_scsi()
3154 QLAFX00_SET_HST_INTR(ha, ha->rqstq_intr_code); in qlafx00_start_scsi()
3156 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qlafx00_start_scsi()
3163 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qlafx00_start_scsi()
3171 struct srb_iocb *fxio = &sp->u.iocb_cmd; in qlafx00_tm_iocb()
3172 scsi_qla_host_t *vha = sp->vha; in qlafx00_tm_iocb()
3173 struct req_que *req = vha->req; in qlafx00_tm_iocb()
3180 tm_iocb.handle = make_handle(req->id, sp->handle); in qlafx00_tm_iocb()
3182 tm_iocb.tgt_id = cpu_to_le16(sp->fcport->tgt_id); in qlafx00_tm_iocb()
3183 tm_iocb.control_flags = cpu_to_le32(fxio->u.tmf.flags); in qlafx00_tm_iocb()
3185 int_to_scsilun(fxio->u.tmf.lun, &llun); in qlafx00_tm_iocb()
3198 struct srb_iocb *fxio = &sp->u.iocb_cmd; in qlafx00_abort_iocb()
3199 scsi_qla_host_t *vha = sp->vha; in qlafx00_abort_iocb()
3200 struct req_que *req = vha->req; in qlafx00_abort_iocb()
3206 abt_iocb.handle = make_handle(req->id, sp->handle); in qlafx00_abort_iocb()
3207 abt_iocb.abort_handle = make_handle(req->id, fxio->u.abt.cmd_hndl); in qlafx00_abort_iocb()
3208 abt_iocb.tgt_id_sts = cpu_to_le16(sp->fcport->tgt_id); in qlafx00_abort_iocb()
3209 abt_iocb.req_que_no = cpu_to_le16(req->id); in qlafx00_abort_iocb()
3219 struct srb_iocb *fxio = &sp->u.iocb_cmd; in qlafx00_fxdisc_iocb()
3228 fx_iocb.handle = sp->handle; in qlafx00_fxdisc_iocb()
3231 if (sp->type == SRB_FXIOCB_DCMD) { in qlafx00_fxdisc_iocb()
3233 sp->u.iocb_cmd.u.fxiocb.req_func_type; in qlafx00_fxdisc_iocb()
3234 fx_iocb.adapid = fxio->u.fxiocb.adapter_id; in qlafx00_fxdisc_iocb()
3235 fx_iocb.adapid_hi = fxio->u.fxiocb.adapter_id_hi; in qlafx00_fxdisc_iocb()
3236 fx_iocb.reserved_0 = fxio->u.fxiocb.reserved_0; in qlafx00_fxdisc_iocb()
3237 fx_iocb.reserved_1 = fxio->u.fxiocb.reserved_1; in qlafx00_fxdisc_iocb()
3238 fx_iocb.dataword_extra = fxio->u.fxiocb.req_data_extra; in qlafx00_fxdisc_iocb()
3240 if (fxio->u.fxiocb.flags & SRB_FXDISC_REQ_DMA_VALID) { in qlafx00_fxdisc_iocb()
3243 cpu_to_le16(fxio->u.fxiocb.req_len); in qlafx00_fxdisc_iocb()
3244 put_unaligned_le64(fxio->u.fxiocb.req_dma_handle, in qlafx00_fxdisc_iocb()
3247 cpu_to_le32(fxio->u.fxiocb.req_len); in qlafx00_fxdisc_iocb()
3250 if (fxio->u.fxiocb.flags & SRB_FXDISC_RESP_DMA_VALID) { in qlafx00_fxdisc_iocb()
3253 cpu_to_le16(fxio->u.fxiocb.rsp_len); in qlafx00_fxdisc_iocb()
3254 put_unaligned_le64(fxio->u.fxiocb.rsp_dma_handle, in qlafx00_fxdisc_iocb()
3257 cpu_to_le32(fxio->u.fxiocb.rsp_len); in qlafx00_fxdisc_iocb()
3260 if (fxio->u.fxiocb.flags & SRB_FXDISC_REQ_DWRD_VALID) { in qlafx00_fxdisc_iocb()
3261 fx_iocb.dataword = fxio->u.fxiocb.req_data; in qlafx00_fxdisc_iocb()
3263 fx_iocb.flags = fxio->u.fxiocb.flags; in qlafx00_fxdisc_iocb()
3267 bsg_job = sp->u.bsg_job; in qlafx00_fxdisc_iocb()
3268 bsg_request = bsg_job->request; in qlafx00_fxdisc_iocb()
3270 &bsg_request->rqst_data.h_vendor.vendor_cmd[1]; in qlafx00_fxdisc_iocb()
3272 fx_iocb.func_num = piocb_rqst->func_type; in qlafx00_fxdisc_iocb()
3273 fx_iocb.adapid = piocb_rqst->adapid; in qlafx00_fxdisc_iocb()
3274 fx_iocb.adapid_hi = piocb_rqst->adapid_hi; in qlafx00_fxdisc_iocb()
3275 fx_iocb.reserved_0 = piocb_rqst->reserved_0; in qlafx00_fxdisc_iocb()
3276 fx_iocb.reserved_1 = piocb_rqst->reserved_1; in qlafx00_fxdisc_iocb()
3277 fx_iocb.dataword_extra = piocb_rqst->dataword_extra; in qlafx00_fxdisc_iocb()
3278 fx_iocb.dataword = piocb_rqst->dataword; in qlafx00_fxdisc_iocb()
3279 fx_iocb.req_xfrcnt = piocb_rqst->req_len; in qlafx00_fxdisc_iocb()
3280 fx_iocb.rsp_xfrcnt = piocb_rqst->rsp_len; in qlafx00_fxdisc_iocb()
3282 if (piocb_rqst->flags & SRB_FXDISC_REQ_DMA_VALID) { in qlafx00_fxdisc_iocb()
3290 cpu_to_le16(bsg_job->request_payload.sg_cnt); in qlafx00_fxdisc_iocb()
3292 bsg_job->request_payload.sg_cnt; in qlafx00_fxdisc_iocb()
3295 for_each_sg(bsg_job->request_payload.sg_list, sg, in qlafx00_fxdisc_iocb()
3307 sp->vha->req, &lcont_pkt); in qlafx00_fxdisc_iocb()
3308 cur_dsd = lcont_pkt.dsd; in qlafx00_fxdisc_iocb()
3315 avail_dsds--; in qlafx00_fxdisc_iocb()
3324 sp->vha, 0x3042, in qlafx00_fxdisc_iocb()
3333 sp->vha, 0x3043, in qlafx00_fxdisc_iocb()
3338 if (piocb_rqst->flags & SRB_FXDISC_RESP_DMA_VALID) { in qlafx00_fxdisc_iocb()
3346 cpu_to_le16(bsg_job->reply_payload.sg_cnt); in qlafx00_fxdisc_iocb()
3347 tot_dsds = bsg_job->reply_payload.sg_cnt; in qlafx00_fxdisc_iocb()
3351 for_each_sg(bsg_job->reply_payload.sg_list, sg, in qlafx00_fxdisc_iocb()
3363 sp->vha->req, &lcont_pkt); in qlafx00_fxdisc_iocb()
3364 cur_dsd = lcont_pkt.dsd; in qlafx00_fxdisc_iocb()
3371 avail_dsds--; in qlafx00_fxdisc_iocb()
3380 sp->vha, 0x3045, in qlafx00_fxdisc_iocb()
3389 sp->vha, 0x3046, in qlafx00_fxdisc_iocb()
3394 if (piocb_rqst->flags & SRB_FXDISC_REQ_DWRD_VALID) in qlafx00_fxdisc_iocb()
3395 fx_iocb.dataword = piocb_rqst->dataword; in qlafx00_fxdisc_iocb()
3396 fx_iocb.flags = piocb_rqst->flags; in qlafx00_fxdisc_iocb()
3401 sp->vha, 0x3047, &fx_iocb, sizeof(fx_iocb)); in qlafx00_fxdisc_iocb()