Lines Matching +full:ese +full:- +full:present
1 // SPDX-License-Identifier: GPL-2.0-only
4 * Copyright (c) 2003-2014 QLogic Corporation
13 #include <linux/t10-pi.h>
18 #include <linux/nvme-fc-driver.h>
37 void *pkt = &item->iocb; in qla27xx_process_purex_fpin()
38 uint16_t pkt_size = item->size; in qla27xx_process_purex_fpin()
44 "-------- ELS REQ -------\n"); in qla27xx_process_purex_fpin()
48 fc_host_fpin_rcv(vha->host, pkt_size, (char *)pkt); in qla27xx_process_purex_fpin()
63 (struct abts_entry_24xx *)&pkt->iocb; in qla24xx_process_abts()
64 struct qla_hw_data *ha = vha->hw; in qla24xx_process_abts()
75 abts->rx_xch_addr_to_abort, abts->ox_id, abts->rx_id, in qla24xx_process_abts()
76 abts->seq_id, abts->seq_cnt); in qla24xx_process_abts()
78 "-------- ABTS RCV -------\n"); in qla24xx_process_abts()
82 rsp_els = dma_alloc_coherent(&ha->pdev->dev, sizeof(*rsp_els), &dma, in qla24xx_process_abts()
91 rsp_els->entry_type = ELS_IOCB_TYPE; in qla24xx_process_abts()
92 rsp_els->entry_count = 1; in qla24xx_process_abts()
93 rsp_els->nport_handle = cpu_to_le16(~0); in qla24xx_process_abts()
94 rsp_els->rx_xchg_address = abts->rx_xch_addr_to_abort; in qla24xx_process_abts()
95 rsp_els->control_flags = cpu_to_le16(EPD_RX_XCHG); in qla24xx_process_abts()
98 abts->rx_xch_addr_to_abort); in qla24xx_process_abts()
100 "-------- ELS RSP -------\n"); in qla24xx_process_abts()
106 "%s: iocb failed to execute -> %x\n", __func__, rval); in qla24xx_process_abts()
107 } else if (rsp_els->comp_status) { in qla24xx_process_abts()
109 "%s: iocb failed to complete -> completion=%#x subcode=(%#x,%#x)\n", in qla24xx_process_abts()
110 __func__, rsp_els->comp_status, in qla24xx_process_abts()
111 rsp_els->error_subcode_1, rsp_els->error_subcode_2); in qla24xx_process_abts()
120 abts_rsp->entry_type = ABTS_RSP_TYPE; in qla24xx_process_abts()
121 abts_rsp->entry_count = 1; in qla24xx_process_abts()
122 abts_rsp->nport_handle = abts->nport_handle; in qla24xx_process_abts()
123 abts_rsp->vp_idx = abts->vp_idx; in qla24xx_process_abts()
124 abts_rsp->sof_type = abts->sof_type & 0xf0; in qla24xx_process_abts()
125 abts_rsp->rx_xch_addr = abts->rx_xch_addr; in qla24xx_process_abts()
126 abts_rsp->d_id[0] = abts->s_id[0]; in qla24xx_process_abts()
127 abts_rsp->d_id[1] = abts->s_id[1]; in qla24xx_process_abts()
128 abts_rsp->d_id[2] = abts->s_id[2]; in qla24xx_process_abts()
129 abts_rsp->r_ctl = FC_ROUTING_BLD | FC_R_CTL_BLD_BA_ACC; in qla24xx_process_abts()
130 abts_rsp->s_id[0] = abts->d_id[0]; in qla24xx_process_abts()
131 abts_rsp->s_id[1] = abts->d_id[1]; in qla24xx_process_abts()
132 abts_rsp->s_id[2] = abts->d_id[2]; in qla24xx_process_abts()
133 abts_rsp->cs_ctl = abts->cs_ctl; in qla24xx_process_abts()
135 fctl = ~(abts->f_ctl[2] | 0x7F) << 16 | in qla24xx_process_abts()
137 abts_rsp->f_ctl[0] = fctl >> 0 & 0xff; in qla24xx_process_abts()
138 abts_rsp->f_ctl[1] = fctl >> 8 & 0xff; in qla24xx_process_abts()
139 abts_rsp->f_ctl[2] = fctl >> 16 & 0xff; in qla24xx_process_abts()
140 abts_rsp->type = FC_TYPE_BLD; in qla24xx_process_abts()
141 abts_rsp->rx_id = abts->rx_id; in qla24xx_process_abts()
142 abts_rsp->ox_id = abts->ox_id; in qla24xx_process_abts()
143 abts_rsp->payload.ba_acc.aborted_rx_id = abts->rx_id; in qla24xx_process_abts()
144 abts_rsp->payload.ba_acc.aborted_ox_id = abts->ox_id; in qla24xx_process_abts()
145 abts_rsp->payload.ba_acc.high_seq_cnt = cpu_to_le16(~0); in qla24xx_process_abts()
146 abts_rsp->rx_xch_addr_to_abort = abts->rx_xch_addr_to_abort; in qla24xx_process_abts()
149 abts->rx_xch_addr_to_abort); in qla24xx_process_abts()
151 "-------- ELS RSP -------\n"); in qla24xx_process_abts()
157 "%s: iocb failed to execute -> %x\n", __func__, rval); in qla24xx_process_abts()
158 } else if (abts_rsp->comp_status) { in qla24xx_process_abts()
160 "%s: iocb failed to complete -> completion=%#x subcode=(%#x,%#x)\n", in qla24xx_process_abts()
161 __func__, abts_rsp->comp_status, in qla24xx_process_abts()
162 abts_rsp->payload.error.subcode1, in qla24xx_process_abts()
163 abts_rsp->payload.error.subcode2); in qla24xx_process_abts()
169 dma_free_coherent(&ha->pdev->dev, sizeof(*rsp_els), rsp_els, dma); in qla24xx_process_abts()
173 * __qla_consume_iocb - this routine is used to tell fw driver has processed
191 entry_count_remaining = purex->entry_count; in __qla_consume_iocb()
193 new_pkt = rsp_q->ring_ptr; in __qla_consume_iocb()
196 rsp_q->ring_index++; in __qla_consume_iocb()
197 if (rsp_q->ring_index == rsp_q->length) { in __qla_consume_iocb()
198 rsp_q->ring_index = 0; in __qla_consume_iocb()
199 rsp_q->ring_ptr = rsp_q->ring; in __qla_consume_iocb()
201 rsp_q->ring_ptr++; in __qla_consume_iocb()
204 new_pkt->signature = RESPONSE_PROCESSED; in __qla_consume_iocb()
207 --entry_count_remaining; in __qla_consume_iocb()
212 * __qla_copy_purex_to_buffer - extract ELS payload from Purex IOCB
231 entry_count_remaining = purex->entry_count; in __qla_copy_purex_to_buffer()
232 total_bytes = (le16_to_cpu(purex->frame_size) & 0x0FFF) in __qla_copy_purex_to_buffer()
233 - PURX_ELS_HEADER_SIZE; in __qla_copy_purex_to_buffer()
246 return -EIO; in __qla_copy_purex_to_buffer()
250 no_bytes = (pending_bytes > sizeof(purex->els_frame_payload)) ? in __qla_copy_purex_to_buffer()
251 sizeof(purex->els_frame_payload) : pending_bytes; in __qla_copy_purex_to_buffer()
253 memcpy(buf, &purex->els_frame_payload[0], no_bytes); in __qla_copy_purex_to_buffer()
255 pending_bytes -= no_bytes; in __qla_copy_purex_to_buffer()
256 --entry_count_remaining; in __qla_copy_purex_to_buffer()
258 ((response_t *)purex)->signature = RESPONSE_PROCESSED; in __qla_copy_purex_to_buffer()
264 new_pkt = (sts_cont_entry_t *)rsp_q->ring_ptr; in __qla_copy_purex_to_buffer()
267 if (new_pkt->entry_type != STATUS_CONT_TYPE) { in __qla_copy_purex_to_buffer()
274 rsp_q->ring_index++; in __qla_copy_purex_to_buffer()
275 if (rsp_q->ring_index == rsp_q->length) { in __qla_copy_purex_to_buffer()
276 rsp_q->ring_index = 0; in __qla_copy_purex_to_buffer()
277 rsp_q->ring_ptr = rsp_q->ring; in __qla_copy_purex_to_buffer()
279 rsp_q->ring_ptr++; in __qla_copy_purex_to_buffer()
281 no_bytes = (pending_bytes > sizeof(new_pkt->data)) ? in __qla_copy_purex_to_buffer()
282 sizeof(new_pkt->data) : pending_bytes; in __qla_copy_purex_to_buffer()
284 memcpy((buf + buffer_copy_offset), new_pkt->data, in __qla_copy_purex_to_buffer()
287 pending_bytes -= no_bytes; in __qla_copy_purex_to_buffer()
288 --entry_count_remaining; in __qla_copy_purex_to_buffer()
293 memcpy((buf + buffer_copy_offset), new_pkt->data, in __qla_copy_purex_to_buffer()
294 total_bytes - buffer_copy_offset); in __qla_copy_purex_to_buffer()
297 ((response_t *)new_pkt)->signature = RESPONSE_PROCESSED; in __qla_copy_purex_to_buffer()
306 return -EIO; in __qla_copy_purex_to_buffer()
316 * qla2100_intr_handler() - Process interrupts for the ISP2100 and ISP2200.
344 ha = rsp->hw; in qla2100_intr_handler()
345 reg = &ha->iobase->isp; in qla2100_intr_handler()
348 spin_lock_irqsave(&ha->hardware_lock, flags); in qla2100_intr_handler()
349 vha = pci_get_drvdata(ha->pdev); in qla2100_intr_handler()
350 for (iter = 50; iter--; ) { in qla2100_intr_handler()
351 hccr = rd_reg_word(®->hccr); in qla2100_intr_handler()
355 if (pci_channel_offline(ha->pdev)) in qla2100_intr_handler()
363 wrt_reg_word(®->hccr, HCCR_RESET_RISC); in qla2100_intr_handler()
364 rd_reg_word(®->hccr); in qla2100_intr_handler()
366 ha->isp_ops->fw_dump(vha); in qla2100_intr_handler()
367 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); in qla2100_intr_handler()
369 } else if ((rd_reg_word(®->istatus) & ISR_RISC_INT) == 0) in qla2100_intr_handler()
372 if (rd_reg_word(®->semaphore) & BIT_0) { in qla2100_intr_handler()
373 wrt_reg_word(®->hccr, HCCR_CLR_RISC_INT); in qla2100_intr_handler()
374 rd_reg_word(®->hccr); in qla2100_intr_handler()
393 wrt_reg_word(®->semaphore, 0); in qla2100_intr_handler()
394 rd_reg_word(®->semaphore); in qla2100_intr_handler()
398 wrt_reg_word(®->hccr, HCCR_CLR_RISC_INT); in qla2100_intr_handler()
399 rd_reg_word(®->hccr); in qla2100_intr_handler()
403 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla2100_intr_handler()
412 if (reg == 0xffffffff && !pci_channel_offline(vha->hw->pdev)) { in qla2x00_check_reg32_for_disconnect()
413 if (!test_and_set_bit(PFLG_DISCONNECTED, &vha->pci_flags) && in qla2x00_check_reg32_for_disconnect()
414 !test_bit(PFLG_DRIVER_REMOVING, &vha->pci_flags) && in qla2x00_check_reg32_for_disconnect()
415 !test_bit(PFLG_DRIVER_PROBING, &vha->pci_flags)) { in qla2x00_check_reg32_for_disconnect()
430 * qla2300_intr_handler() - Process interrupts for the ISP23xx and ISP63xx.
459 ha = rsp->hw; in qla2300_intr_handler()
460 reg = &ha->iobase->isp; in qla2300_intr_handler()
463 spin_lock_irqsave(&ha->hardware_lock, flags); in qla2300_intr_handler()
464 vha = pci_get_drvdata(ha->pdev); in qla2300_intr_handler()
465 for (iter = 50; iter--; ) { in qla2300_intr_handler()
466 stat = rd_reg_dword(®->u.isp2300.host_status); in qla2300_intr_handler()
470 if (unlikely(pci_channel_offline(ha->pdev))) in qla2300_intr_handler()
473 hccr = rd_reg_word(®->hccr); in qla2300_intr_handler()
477 "Parity error -- HCCR=%x, Dumping " in qla2300_intr_handler()
481 "RISC paused -- HCCR=%x, Dumping " in qla2300_intr_handler()
489 wrt_reg_word(®->hccr, HCCR_RESET_RISC); in qla2300_intr_handler()
490 rd_reg_word(®->hccr); in qla2300_intr_handler()
492 ha->isp_ops->fw_dump(vha); in qla2300_intr_handler()
493 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); in qla2300_intr_handler()
507 wrt_reg_word(®->semaphore, 0); in qla2300_intr_handler()
535 wrt_reg_word(®->hccr, HCCR_CLR_RISC_INT); in qla2300_intr_handler()
536 rd_reg_word_relaxed(®->hccr); in qla2300_intr_handler()
539 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla2300_intr_handler()
545 * qla2x00_mbx_completion() - Process mailbox command completions.
555 struct qla_hw_data *ha = vha->hw; in qla2x00_mbx_completion()
556 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; in qla2x00_mbx_completion()
559 WARN_ON_ONCE(ha->mbx_count > 32); in qla2x00_mbx_completion()
560 mboxes = (1ULL << ha->mbx_count) - 1; in qla2x00_mbx_completion()
561 if (!ha->mcp) in qla2x00_mbx_completion()
564 mboxes = ha->mcp->in_mb; in qla2x00_mbx_completion()
567 ha->flags.mbox_int = 1; in qla2x00_mbx_completion()
568 ha->mailbox_out[0] = mb0; in qla2x00_mbx_completion()
572 for (cnt = 1; cnt < ha->mbx_count; cnt++) { in qla2x00_mbx_completion()
576 ha->mailbox_out[cnt] = qla2x00_debounce_register(wptr); in qla2x00_mbx_completion()
578 ha->mailbox_out[cnt] = rd_reg_word(wptr); in qla2x00_mbx_completion()
591 struct device_reg_24xx __iomem *reg24 = &vha->hw->iobase->isp24; in qla81xx_idc_event()
592 struct device_reg_82xx __iomem *reg82 = &vha->hw->iobase->isp82; in qla81xx_idc_event()
596 /* Seed data -- mailbox1 -> mailbox7. */ in qla81xx_idc_event()
597 if (IS_QLA81XX(vha->hw) || IS_QLA83XX(vha->hw)) in qla81xx_idc_event()
598 wptr = ®24->mailbox1; in qla81xx_idc_event()
599 else if (IS_QLA8044(vha->hw)) in qla81xx_idc_event()
600 wptr = ®82->mailbox_out[1]; in qla81xx_idc_event()
608 "Inter-Driver Communication %s -- " in qla81xx_idc_event()
616 vha->hw->flags.idc_compl_status = 1; in qla81xx_idc_event()
617 if (vha->hw->notify_dcbx_comp && !vha->vp_idx) in qla81xx_idc_event()
618 complete(&vha->hw->dcbx_comp); in qla81xx_idc_event()
623 /* Acknowledgement needed? [Notify && non-zero timeout]. */ in qla81xx_idc_event()
626 "%lu Inter-Driver Communication %s -- ACK timeout=%d.\n", in qla81xx_idc_event()
627 vha->host_no, event[aen & 0xff], timeout); in qla81xx_idc_event()
637 vha->hw->idc_extend_tmo = descr; in qla81xx_idc_event()
639 "%lu Inter-Driver Communication %s -- " in qla81xx_idc_event()
641 vha->host_no, event[aen & 0xff], vha->hw->idc_extend_tmo); in qla81xx_idc_event()
653 #define QLA_LAST_SPEED (ARRAY_SIZE(link_speeds) - 1) in qla2x00_get_link_speed_str()
668 struct qla_hw_data *ha = vha->hw; in qla83xx_handle_8200_aen()
674 * mb[2] = LSW of Peg-Halt Status-1 Register in qla83xx_handle_8200_aen()
675 * mb[6] = MSW of Peg-Halt Status-1 Register in qla83xx_handle_8200_aen()
676 * mb[3] = LSW of Peg-Halt Status-2 register in qla83xx_handle_8200_aen()
677 * mb[7] = MSW of Peg-Halt Status-2 register in qla83xx_handle_8200_aen()
678 * mb[4] = IDC Device-State Register value in qla83xx_handle_8200_aen()
679 * mb[5] = IDC Driver-Presence Register value in qla83xx_handle_8200_aen()
682 "mb[1] = 0x%x PH-status1: mb[2] = 0x%x PH-status1: mb[6] = 0x%x.\n", in qla83xx_handle_8200_aen()
684 ql_dbg(ql_dbg_async, vha, 0x506c, "PH-status2: mb[3] = 0x%x " in qla83xx_handle_8200_aen()
685 "PH-status2: mb[7] = 0x%x Device-State: mb[4] = 0x%x " in qla83xx_handle_8200_aen()
686 "Drv-Presence: mb[5] = 0x%x.\n", mb[3], mb[7], mb[4], mb[5]); in qla83xx_handle_8200_aen()
690 ha->flags.nic_core_hung = 1; in qla83xx_handle_8200_aen()
699 * - PEG-Halt Status-1 Register: in qla83xx_handle_8200_aen()
701 * Bits 0-7 = protocol-engine ID in qla83xx_handle_8200_aen()
702 * Bits 8-28 = f/w error code in qla83xx_handle_8200_aen()
703 * Bits 29-31 = Error-level in qla83xx_handle_8200_aen()
704 * Error-level 0x1 = Non-Fatal error in qla83xx_handle_8200_aen()
705 * Error-level 0x2 = Recoverable Fatal error in qla83xx_handle_8200_aen()
706 * Error-level 0x4 = UnRecoverable Fatal error in qla83xx_handle_8200_aen()
707 * - PEG-Halt Status-2 Register: in qla83xx_handle_8200_aen()
714 ql_log(ql_log_warn, vha, 0x5061, "PegHalt Status-1 " in qla83xx_handle_8200_aen()
718 ql_log(ql_log_warn, vha, 0x5062, "PegHalt Status-2 " in qla83xx_handle_8200_aen()
747 * - PEG-to-FC Status Register: in qla83xx_handle_8200_aen()
749 * Bits 0-7 = Peg-Firmware state in qla83xx_handle_8200_aen()
750 * Bit 8 = N/W Interface Link-up in qla83xx_handle_8200_aen()
752 * Bits 10-11 = SFP Status in qla83xx_handle_8200_aen()
754 * SFP Status 0x1 = SFP+ transceiver not present in qla83xx_handle_8200_aen()
756 * SFP Status 0x3 = SFP+ transceiver present and in qla83xx_handle_8200_aen()
758 * Bits 12-14 = Heartbeat Counter in qla83xx_handle_8200_aen()
760 * Bits 16-17 = SFP Additional Info in qla83xx_handle_8200_aen()
768 * Bits 20-22 = Link Speed in qla83xx_handle_8200_aen()
769 * Bits 23-27 = Reserved in qla83xx_handle_8200_aen()
770 * Bits 28-30 = DCBX Status in qla83xx_handle_8200_aen()
789 "Peg-to-Fc Status Register:\n" in qla83xx_handle_8200_aen()
819 "IDC Device-State changed = 0x%x.\n", mb[4]); in qla83xx_handle_8200_aen()
820 if (ha->flags.nic_core_reset_owner) in qla83xx_handle_8200_aen()
829 struct qla_hw_data *ha = vha->hw; in qla2x00_is_a_vp_did()
835 if (!ha->num_vhosts) in qla2x00_is_a_vp_did()
838 spin_lock_irqsave(&ha->vport_slock, flags); in qla2x00_is_a_vp_did()
839 list_for_each_entry(vp, &ha->vp_list, list) { in qla2x00_is_a_vp_did()
840 vp_did = vp->d_id.b24; in qla2x00_is_a_vp_did()
846 spin_unlock_irqrestore(&ha->vport_slock, flags); in qla2x00_is_a_vp_did()
857 list_for_each_entry_safe(f, tf, &vha->vp_fcports, list) in qla2x00_find_fcport_by_loopid()
858 if (f->loop_id == loop_id) in qla2x00_find_fcport_by_loopid()
869 list_for_each_entry_safe(f, tf, &vha->vp_fcports, list) { in qla2x00_find_fcport_by_wwpn()
870 if (memcmp(f->port_name, wwpn, WWN_SIZE) == 0) { in qla2x00_find_fcport_by_wwpn()
873 else if (f->deleted == 0) in qla2x00_find_fcport_by_wwpn()
887 list_for_each_entry_safe(f, tf, &vha->vp_fcports, list) { in qla2x00_find_fcport_by_nportid()
888 if (f->d_id.b24 == id->b24) { in qla2x00_find_fcport_by_nportid()
891 else if (f->deleted == 0) in qla2x00_find_fcport_by_nportid()
902 struct qla_hw_data *ha = vha->hw; in qla27xx_handle_8200_aen()
918 ha->isp_ops->fw_dump(vha); in qla27xx_handle_8200_aen()
922 ha->isp_ops->mpi_fw_dump(vha, 1); in qla27xx_handle_8200_aen()
925 vha->hw->flags.fw_init_done = 0; in qla27xx_handle_8200_aen()
926 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); in qla27xx_handle_8200_aen()
939 (size - QLA_DEFAULT_PAYLOAD_SIZE), GFP_ATOMIC); in qla24xx_alloc_purex_item()
941 if (atomic_inc_return(&vha->default_item.in_use) == 1) { in qla24xx_alloc_purex_item()
942 item = &vha->default_item; in qla24xx_alloc_purex_item()
956 item->vha = vha; in qla24xx_alloc_purex_item()
957 item->size = size; in qla24xx_alloc_purex_item()
966 struct purex_list *list = &vha->purex_list; in qla24xx_queue_purex_item()
969 pkt->process_item = process_item; in qla24xx_queue_purex_item()
971 spin_lock_irqsave(&list->lock, flags); in qla24xx_queue_purex_item()
972 list_add_tail(&pkt->list, &list->head); in qla24xx_queue_purex_item()
973 spin_unlock_irqrestore(&list->lock, flags); in qla24xx_queue_purex_item()
975 set_bit(PROCESS_PUREX_IOCB, &vha->dpc_flags); in qla24xx_queue_purex_item()
979 * qla24xx_copy_std_pkt() - Copy over purex ELS which is
995 memcpy(&item->iocb, pkt, sizeof(item->iocb)); in qla24xx_copy_std_pkt()
1000 * qla27xx_copy_fpin_pkt() - Copy over fpin packets that can
1019 total_bytes = (le16_to_cpu(purex->frame_size) & 0x0FFF) in qla27xx_copy_fpin_pkt()
1020 - PURX_ELS_HEADER_SIZE; in qla27xx_copy_fpin_pkt()
1022 entry_count = entry_count_remaining = purex->entry_count; in qla27xx_copy_fpin_pkt()
1023 no_bytes = (pending_bytes > sizeof(purex->els_frame_payload)) ? in qla27xx_copy_fpin_pkt()
1024 sizeof(purex->els_frame_payload) : pending_bytes; in qla27xx_copy_fpin_pkt()
1033 fpin_pkt = &item->iocb; in qla27xx_copy_fpin_pkt()
1035 memcpy(fpin_pkt, &purex->els_frame_payload[0], no_bytes); in qla27xx_copy_fpin_pkt()
1037 pending_bytes -= no_bytes; in qla27xx_copy_fpin_pkt()
1038 --entry_count_remaining; in qla27xx_copy_fpin_pkt()
1040 ((response_t *)purex)->signature = RESPONSE_PROCESSED; in qla27xx_copy_fpin_pkt()
1045 if (rsp_q->ring_ptr->signature == RESPONSE_PROCESSED) { in qla27xx_copy_fpin_pkt()
1053 new_pkt = (sts_cont_entry_t *)rsp_q->ring_ptr; in qla27xx_copy_fpin_pkt()
1056 if (new_pkt->entry_type != STATUS_CONT_TYPE) { in qla27xx_copy_fpin_pkt()
1063 rsp_q->ring_index++; in qla27xx_copy_fpin_pkt()
1064 if (rsp_q->ring_index == rsp_q->length) { in qla27xx_copy_fpin_pkt()
1065 rsp_q->ring_index = 0; in qla27xx_copy_fpin_pkt()
1066 rsp_q->ring_ptr = rsp_q->ring; in qla27xx_copy_fpin_pkt()
1068 rsp_q->ring_ptr++; in qla27xx_copy_fpin_pkt()
1070 no_bytes = (pending_bytes > sizeof(new_pkt->data)) ? in qla27xx_copy_fpin_pkt()
1071 sizeof(new_pkt->data) : pending_bytes; in qla27xx_copy_fpin_pkt()
1074 buffer_copy_offset), new_pkt->data, in qla27xx_copy_fpin_pkt()
1077 pending_bytes -= no_bytes; in qla27xx_copy_fpin_pkt()
1078 --entry_count_remaining; in qla27xx_copy_fpin_pkt()
1084 buffer_copy_offset), new_pkt->data, in qla27xx_copy_fpin_pkt()
1085 total_bytes - buffer_copy_offset); in qla27xx_copy_fpin_pkt()
1088 ((response_t *)new_pkt)->signature = RESPONSE_PROCESSED; in qla27xx_copy_fpin_pkt()
1100 host_to_fcp_swap((uint8_t *)&item->iocb, total_bytes); in qla27xx_copy_fpin_pkt()
1105 * qla2x00_async_event() - Process aynchronous events.
1108 * @mb: Mailbox registers (0 - 3)
1116 struct qla_hw_data *ha = vha->hw; in qla2x00_async_event()
1117 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; in qla2x00_async_event()
1118 struct device_reg_24xx __iomem *reg24 = &ha->iobase->isp24; in qla2x00_async_event()
1119 struct device_reg_82xx __iomem *reg82 = &ha->iobase->isp82; in qla2x00_async_event()
1124 if (!vha->hw->flags.fw_started) in qla2x00_async_event()
1184 if (!vha->flags.online) in qla2x00_async_event()
1188 qla2x00_process_completed_request(vha, rsp->req, in qla2x00_async_event()
1196 set_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); in qla2x00_async_event()
1202 vha->hw_err_cnt++; in qla2x00_async_event()
1208 m[0] = rd_reg_word(®24->mailbox4); in qla2x00_async_event()
1209 m[1] = rd_reg_word(®24->mailbox5); in qla2x00_async_event()
1210 m[2] = rd_reg_word(®24->mailbox6); in qla2x00_async_event()
1211 mbx = m[3] = rd_reg_word(®24->mailbox7); in qla2x00_async_event()
1214 "ISP System Error - mbx1=%xh mbx2=%xh mbx3=%xh mbx4=%xh mbx5=%xh mbx6=%xh mbx7=%xh.\n", in qla2x00_async_event()
1218 "ISP System Error - mbx1=%xh mbx2=%xh mbx3=%xh.\n ", in qla2x00_async_event()
1222 rd_reg_word(®24->mailbox7) & BIT_8) in qla2x00_async_event()
1223 ha->isp_ops->mpi_fw_dump(vha, 1); in qla2x00_async_event()
1224 ha->isp_ops->fw_dump(vha); in qla2x00_async_event()
1225 ha->flags.fw_init_done = 0; in qla2x00_async_event()
1233 vha->flags.online = 0; in qla2x00_async_event()
1234 vha->device_flags |= DFLG_DEV_FAILED; in qla2x00_async_event()
1237 if ((mbx & MBX_3) && (ha->port_no == 0)) in qla2x00_async_event()
1239 &vha->dpc_flags); in qla2x00_async_event()
1241 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); in qla2x00_async_event()
1247 vha->flags.online = 0; in qla2x00_async_event()
1248 vha->device_flags |= DFLG_DEV_FAILED; in qla2x00_async_event()
1250 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); in qla2x00_async_event()
1257 vha->hw_err_cnt++; in qla2x00_async_event()
1259 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); in qla2x00_async_event()
1266 vha->hw_err_cnt++; in qla2x00_async_event()
1268 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); in qla2x00_async_event()
1271 case MBA_WAKEUP_THRES: /* Request Queue Wake-up */ in qla2x00_async_event()
1279 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); in qla2x00_async_event()
1283 ha->flags.lip_ae = 1; in qla2x00_async_event()
1288 if (atomic_read(&vha->loop_state) != LOOP_DOWN) { in qla2x00_async_event()
1289 atomic_set(&vha->loop_state, LOOP_DOWN); in qla2x00_async_event()
1290 atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME); in qla2x00_async_event()
1294 if (vha->vp_idx) { in qla2x00_async_event()
1295 atomic_set(&vha->vp_state, VP_FAILED); in qla2x00_async_event()
1296 fc_vport_set_state(vha->fc_vport, FC_VPORT_FAILED); in qla2x00_async_event()
1299 set_bit(REGISTER_FC4_NEEDED, &vha->dpc_flags); in qla2x00_async_event()
1300 set_bit(REGISTER_FDMI_NEEDED, &vha->dpc_flags); in qla2x00_async_event()
1302 vha->flags.management_server_logged_in = 0; in qla2x00_async_event()
1308 ha->link_data_rate = PORT_SPEED_1GB; in qla2x00_async_event()
1310 ha->link_data_rate = mb[1]; in qla2x00_async_event()
1314 qla2x00_get_link_speed_str(ha, ha->link_data_rate)); in qla2x00_async_event()
1322 vha->flags.management_server_logged_in = 0; in qla2x00_async_event()
1323 qla2x00_post_aen_work(vha, FCH_EVT_LINKUP, ha->link_data_rate); in qla2x00_async_event()
1325 if (vha->link_down_time < vha->hw->port_down_retry_count) { in qla2x00_async_event()
1326 vha->short_link_down_cnt++; in qla2x00_async_event()
1327 vha->link_down_time = QLA2XX_MAX_LINK_DOWN_TIME; in qla2x00_async_event()
1334 ha->flags.lip_ae = 0; in qla2x00_async_event()
1335 ha->current_topology = 0; in qla2x00_async_event()
1336 vha->link_down_time = 0; in qla2x00_async_event()
1339 ? rd_reg_word(®24->mailbox4) : 0; in qla2x00_async_event()
1340 mbx = (IS_P3P_TYPE(ha)) ? rd_reg_word(®82->mailbox_out[4]) in qla2x00_async_event()
1346 if (atomic_read(&vha->loop_state) != LOOP_DOWN) { in qla2x00_async_event()
1347 atomic_set(&vha->loop_state, LOOP_DOWN); in qla2x00_async_event()
1348 atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME); in qla2x00_async_event()
1351 * NVRAM in case of FA-WWPN capable ISP in qla2x00_async_event()
1354 if (!vha->vp_idx) { in qla2x00_async_event()
1355 if (ha->flags.fawwpn_enabled && in qla2x00_async_event()
1356 (ha->current_topology == ISP_CFG_F)) { in qla2x00_async_event()
1357 memcpy(vha->port_name, ha->port_name, WWN_SIZE); in qla2x00_async_event()
1358 fc_host_port_name(vha->host) = in qla2x00_async_event()
1359 wwn_to_u64(vha->port_name); in qla2x00_async_event()
1363 wwn_to_u64(vha->port_name)); in qla2x00_async_event()
1366 clear_bit(VP_CONFIG_OK, &vha->vp_flags); in qla2x00_async_event()
1369 vha->device_flags |= DFLG_NO_CABLE; in qla2x00_async_event()
1373 if (vha->vp_idx) { in qla2x00_async_event()
1374 atomic_set(&vha->vp_state, VP_FAILED); in qla2x00_async_event()
1375 fc_vport_set_state(vha->fc_vport, FC_VPORT_FAILED); in qla2x00_async_event()
1378 vha->flags.management_server_logged_in = 0; in qla2x00_async_event()
1379 ha->link_data_rate = PORT_SPEED_UNKNOWN; in qla2x00_async_event()
1387 if (atomic_read(&vha->loop_state) != LOOP_DOWN) { in qla2x00_async_event()
1388 atomic_set(&vha->loop_state, LOOP_DOWN); in qla2x00_async_event()
1389 atomic_set(&vha->loop_down_timer, LOOP_DOWN_TIME); in qla2x00_async_event()
1393 if (vha->vp_idx) { in qla2x00_async_event()
1394 atomic_set(&vha->vp_state, VP_FAILED); in qla2x00_async_event()
1395 fc_vport_set_state(vha->fc_vport, FC_VPORT_FAILED); in qla2x00_async_event()
1398 set_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); in qla2x00_async_event()
1400 ha->operating_mode = LOOP; in qla2x00_async_event()
1401 vha->flags.management_server_logged_in = 0; in qla2x00_async_event()
1406 case MBA_POINT_TO_POINT: /* Point-to-Point */ in qla2x00_async_event()
1407 ha->flags.lip_ae = 0; in qla2x00_async_event()
1414 "DCBX Completed -- %04x %04x %04x.\n", in qla2x00_async_event()
1416 if (ha->notify_dcbx_comp && !vha->vp_idx) in qla2x00_async_event()
1417 complete(&ha->dcbx_comp); in qla2x00_async_event()
1427 if (atomic_read(&vha->loop_state) != LOOP_DOWN) { in qla2x00_async_event()
1428 atomic_set(&vha->loop_state, LOOP_DOWN); in qla2x00_async_event()
1429 if (!atomic_read(&vha->loop_down_timer)) in qla2x00_async_event()
1430 atomic_set(&vha->loop_down_timer, in qla2x00_async_event()
1436 if (vha->vp_idx) { in qla2x00_async_event()
1437 atomic_set(&vha->vp_state, VP_FAILED); in qla2x00_async_event()
1438 fc_vport_set_state(vha->fc_vport, FC_VPORT_FAILED); in qla2x00_async_event()
1441 if (!(test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags))) in qla2x00_async_event()
1442 set_bit(RESET_MARKER_NEEDED, &vha->dpc_flags); in qla2x00_async_event()
1444 set_bit(REGISTER_FC4_NEEDED, &vha->dpc_flags); in qla2x00_async_event()
1445 set_bit(REGISTER_FDMI_NEEDED, &vha->dpc_flags); in qla2x00_async_event()
1447 vha->flags.management_server_logged_in = 0; in qla2x00_async_event()
1457 if (atomic_read(&vha->loop_state) != LOOP_DOWN) { in qla2x00_async_event()
1458 atomic_set(&vha->loop_state, LOOP_DOWN); in qla2x00_async_event()
1459 if (!atomic_read(&vha->loop_down_timer)) in qla2x00_async_event()
1460 atomic_set(&vha->loop_down_timer, in qla2x00_async_event()
1465 if (vha->vp_idx) { in qla2x00_async_event()
1466 atomic_set(&vha->vp_state, VP_FAILED); in qla2x00_async_event()
1467 fc_vport_set_state(vha->fc_vport, FC_VPORT_FAILED); in qla2x00_async_event()
1470 set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); in qla2x00_async_event()
1471 set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); in qla2x00_async_event()
1476 * Handle only global and vn-port update events in qla2x00_async_event()
1492 (mb[1] != 0xffff)) && vha->vp_idx != (mb[3] & 0xff)) in qla2x00_async_event()
1505 set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); in qla2x00_async_event()
1506 set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); in qla2x00_async_event()
1516 set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); in qla2x00_async_event()
1517 set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); in qla2x00_async_event()
1525 if (atomic_read(&fcport->state) != FCS_ONLINE) in qla2x00_async_event()
1529 fcport->loop_id, fcport->d_id.b24); in qla2x00_async_event()
1531 fcport->logout_on_delete = 0; in qla2x00_async_event()
1537 if (atomic_read(&vha->loop_state) != LOOP_DOWN) { in qla2x00_async_event()
1538 atomic_set(&vha->loop_state, LOOP_DOWN); in qla2x00_async_event()
1539 atomic_set(&vha->loop_down_timer, in qla2x00_async_event()
1541 vha->device_flags |= DFLG_NO_CABLE; in qla2x00_async_event()
1545 if (vha->vp_idx) { in qla2x00_async_event()
1546 atomic_set(&vha->vp_state, VP_FAILED); in qla2x00_async_event()
1547 fc_vport_set_state(vha->fc_vport, in qla2x00_async_event()
1552 vha->flags.management_server_logged_in = 0; in qla2x00_async_event()
1553 ha->link_data_rate = PORT_SPEED_UNKNOWN; in qla2x00_async_event()
1562 atomic_set(&vha->loop_down_timer, 0); in qla2x00_async_event()
1563 if (atomic_read(&vha->loop_state) != LOOP_DOWN && in qla2x00_async_event()
1564 !ha->flags.n2n_ae && in qla2x00_async_event()
1565 atomic_read(&vha->loop_state) != LOOP_DEAD) { in qla2x00_async_event()
1579 atomic_set(&vha->loop_state, LOOP_UP); in qla2x00_async_event()
1580 vha->scan.scan_retry = 0; in qla2x00_async_event()
1582 set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); in qla2x00_async_event()
1583 set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); in qla2x00_async_event()
1584 set_bit(VP_CONFIG_OK, &vha->vp_flags); in qla2x00_async_event()
1589 if (vha->vp_idx && test_bit(VP_SCR_NEEDED, &vha->vp_flags)) in qla2x00_async_event()
1592 if (ha->flags.npiv_supported && vha->vp_idx != (mb[3] & 0xff)) in qla2x00_async_event()
1596 "RSCN database changed -- %04x %04x %04x.\n", in qla2x00_async_event()
1600 host_pid = (vha->d_id.b.domain << 16) | (vha->d_id.b.area << 8) in qla2x00_async_event()
1601 | vha->d_id.b.al_pa; in qla2x00_async_event()
1609 /* Ignore reserved bits from RSCN-payload. */ in qla2x00_async_event()
1616 atomic_set(&vha->loop_down_timer, 0); in qla2x00_async_event()
1617 vha->flags.management_server_logged_in = 0; in qla2x00_async_event()
1629 if (!ha->flags.scm_enabled || in qla2x00_async_event()
1654 "Discard RND Frame -- %04x %04x %04x.\n", in qla2x00_async_event()
1656 vha->interface_err_cnt++; in qla2x00_async_event()
1661 "Trace Notification -- %04x %04x.\n", mb[1], mb[2]); in qla2x00_async_event()
1666 "ISP84XX Alert Notification -- %04x %04x %04x.\n", in qla2x00_async_event()
1669 spin_lock_irqsave(&ha->cs84xx->access_lock, flags); in qla2x00_async_event()
1677 ha->cs84xx->op_fw_version = mb[3] << 16 | mb[2]; in qla2x00_async_event()
1680 ha->cs84xx->op_fw_version); in qla2x00_async_event()
1683 ha->cs84xx->diag_fw_version = mb[3] << 16 | mb[2]; in qla2x00_async_event()
1686 ha->cs84xx->diag_fw_version); in qla2x00_async_event()
1689 ha->cs84xx->diag_fw_version = mb[3] << 16 | mb[2]; in qla2x00_async_event()
1690 ha->cs84xx->fw_update = 1; in qla2x00_async_event()
1693 ha->cs84xx->gold_fw_version); in qla2x00_async_event()
1700 spin_unlock_irqrestore(&ha->cs84xx->access_lock, flags); in qla2x00_async_event()
1704 "DCBX Started -- %04x %04x %04x.\n", in qla2x00_async_event()
1709 "DCBX Parameters Updated -- %04x %04x %04x.\n", in qla2x00_async_event()
1714 "FCF Configuration Error -- %04x %04x %04x.\n", in qla2x00_async_event()
1718 if (IS_QLA8031(vha->hw) || IS_QLA8044(ha)) { in qla2x00_async_event()
1719 mb[4] = rd_reg_word(®24->mailbox4); in qla2x00_async_event()
1723 set_bit(ISP_QUIESCE_NEEDED, &vha->dpc_flags); in qla2x00_async_event()
1727 if (atomic_read(&vha->loop_state) == LOOP_DOWN) in qla2x00_async_event()
1728 atomic_set(&vha->loop_down_timer, in qla2x00_async_event()
1735 if (ha->notify_lb_portup_comp && !vha->vp_idx) in qla2x00_async_event()
1736 complete(&ha->lb_portup_comp); in qla2x00_async_event()
1739 if (IS_QLA81XX(vha->hw) || IS_QLA8031(vha->hw) || in qla2x00_async_event()
1746 vha->hw_err_cnt++; in qla2x00_async_event()
1749 mb[4] = rd_reg_word(®24->mailbox4); in qla2x00_async_event()
1750 mb[5] = rd_reg_word(®24->mailbox5); in qla2x00_async_event()
1751 mb[6] = rd_reg_word(®24->mailbox6); in qla2x00_async_event()
1752 mb[7] = rd_reg_word(®24->mailbox7); in qla2x00_async_event()
1756 "skip Heartbeat processing mb0-3=[0x%04x] [0x%04x] [0x%04x] [0x%04x]\n", in qla2x00_async_event()
1764 vha->dport_status &= ~DPORT_DIAG_IN_PROGRESS; in qla2x00_async_event()
1766 "D-Port Diagnostics: %04x %04x %04x %04x\n", in qla2x00_async_event()
1768 memcpy(vha->dport_data, mb, sizeof(vha->dport_data)); in qla2x00_async_event()
1778 "D-Port Diagnostics: result=%s type=%s [sw=%u]\n", in qla2x00_async_event()
1789 "D-Port Diagnostics: reason=%s phase=%u \n", in qla2x00_async_event()
1804 set_bit(DETECT_SFP_CHANGE, &vha->dpc_flags); in qla2x00_async_event()
1819 if (!vha->vp_idx && ha->num_vhosts) in qla2x00_async_event()
1824 * qla2x00_process_completed_request() - Process a Fast Post response.
1834 struct qla_hw_data *ha = vha->hw; in qla2x00_process_completed_request()
1837 if (index >= req->num_outstanding_cmds) { in qla2x00_process_completed_request()
1842 set_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags); in qla2x00_process_completed_request()
1844 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); in qla2x00_process_completed_request()
1848 sp = req->outstanding_cmds[index]; in qla2x00_process_completed_request()
1851 req->outstanding_cmds[index] = NULL; in qla2x00_process_completed_request()
1854 sp->done(sp, DID_OK << 16); in qla2x00_process_completed_request()
1859 set_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags); in qla2x00_process_completed_request()
1861 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); in qla2x00_process_completed_request()
1869 struct qla_hw_data *ha = vha->hw; in qla2x00_get_sp_from_handle()
1874 if (pkt->handle == QLA_SKIP_HANDLE) in qla2x00_get_sp_from_handle()
1877 index = LSW(pkt->handle); in qla2x00_get_sp_from_handle()
1878 if (index >= req->num_outstanding_cmds) { in qla2x00_get_sp_from_handle()
1883 set_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags); in qla2x00_get_sp_from_handle()
1885 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); in qla2x00_get_sp_from_handle()
1888 sp = req->outstanding_cmds[index]; in qla2x00_get_sp_from_handle()
1891 "%s: Invalid completion handle (%x) -- timed-out.\n", in qla2x00_get_sp_from_handle()
1895 if (sp->handle != index) { in qla2x00_get_sp_from_handle()
1898 sp->handle, index); in qla2x00_get_sp_from_handle()
1902 req->outstanding_cmds[index] = NULL; in qla2x00_get_sp_from_handle()
1910 const char func[] = "MBX-IOCB"; in qla2x00_mbx_iocb_entry()
1922 lio = &sp->u.iocb_cmd; in qla2x00_mbx_iocb_entry()
1923 type = sp->name; in qla2x00_mbx_iocb_entry()
1924 fcport = sp->fcport; in qla2x00_mbx_iocb_entry()
1925 data = lio->u.logio.data; in qla2x00_mbx_iocb_entry()
1928 data[1] = lio->u.logio.flags & SRB_LOGIN_RETRIED ? in qla2x00_mbx_iocb_entry()
1930 if (mbx->entry_status) { in qla2x00_mbx_iocb_entry()
1932 "Async-%s error entry - hdl=%x portid=%02x%02x%02x " in qla2x00_mbx_iocb_entry()
1933 "entry-status=%x status=%x state-flag=%x " in qla2x00_mbx_iocb_entry()
1934 "status-flags=%x.\n", type, sp->handle, in qla2x00_mbx_iocb_entry()
1935 fcport->d_id.b.domain, fcport->d_id.b.area, in qla2x00_mbx_iocb_entry()
1936 fcport->d_id.b.al_pa, mbx->entry_status, in qla2x00_mbx_iocb_entry()
1937 le16_to_cpu(mbx->status), le16_to_cpu(mbx->state_flags), in qla2x00_mbx_iocb_entry()
1938 le16_to_cpu(mbx->status_flags)); in qla2x00_mbx_iocb_entry()
1946 status = le16_to_cpu(mbx->status); in qla2x00_mbx_iocb_entry()
1947 if (status == 0x30 && sp->type == SRB_LOGIN_CMD && in qla2x00_mbx_iocb_entry()
1948 le16_to_cpu(mbx->mb0) == MBS_COMMAND_COMPLETE) in qla2x00_mbx_iocb_entry()
1950 if (!status && le16_to_cpu(mbx->mb0) == MBS_COMMAND_COMPLETE) { in qla2x00_mbx_iocb_entry()
1952 "Async-%s complete - hdl=%x portid=%02x%02x%02x mbx1=%x.\n", in qla2x00_mbx_iocb_entry()
1953 type, sp->handle, fcport->d_id.b.domain, in qla2x00_mbx_iocb_entry()
1954 fcport->d_id.b.area, fcport->d_id.b.al_pa, in qla2x00_mbx_iocb_entry()
1955 le16_to_cpu(mbx->mb1)); in qla2x00_mbx_iocb_entry()
1958 if (sp->type == SRB_LOGIN_CMD) { in qla2x00_mbx_iocb_entry()
1959 fcport->port_type = FCT_TARGET; in qla2x00_mbx_iocb_entry()
1960 if (le16_to_cpu(mbx->mb1) & BIT_0) in qla2x00_mbx_iocb_entry()
1961 fcport->port_type = FCT_INITIATOR; in qla2x00_mbx_iocb_entry()
1962 else if (le16_to_cpu(mbx->mb1) & BIT_1) in qla2x00_mbx_iocb_entry()
1963 fcport->flags |= FCF_FCP2_DEVICE; in qla2x00_mbx_iocb_entry()
1968 data[0] = le16_to_cpu(mbx->mb0); in qla2x00_mbx_iocb_entry()
1971 data[1] = le16_to_cpu(mbx->mb1); in qla2x00_mbx_iocb_entry()
1981 "Async-%s failed - hdl=%x portid=%02x%02x%02x status=%x " in qla2x00_mbx_iocb_entry()
1982 "mb0=%x mb1=%x mb2=%x mb6=%x mb7=%x.\n", type, sp->handle, in qla2x00_mbx_iocb_entry()
1983 fcport->d_id.b.domain, fcport->d_id.b.area, fcport->d_id.b.al_pa, in qla2x00_mbx_iocb_entry()
1984 status, le16_to_cpu(mbx->mb0), le16_to_cpu(mbx->mb1), in qla2x00_mbx_iocb_entry()
1985 le16_to_cpu(mbx->mb2), le16_to_cpu(mbx->mb6), in qla2x00_mbx_iocb_entry()
1986 le16_to_cpu(mbx->mb7)); in qla2x00_mbx_iocb_entry()
1989 sp->done(sp, 0); in qla2x00_mbx_iocb_entry()
1996 const char func[] = "MBX-IOCB2"; in qla24xx_mbx_iocb_entry()
1997 struct qla_hw_data *ha = vha->hw; in qla24xx_mbx_iocb_entry()
2007 if (sp->type == SRB_SCSI_CMD || in qla24xx_mbx_iocb_entry()
2008 sp->type == SRB_NVME_CMD || in qla24xx_mbx_iocb_entry()
2009 sp->type == SRB_TM_CMD) { in qla24xx_mbx_iocb_entry()
2011 "Inconsistent event entry type %d\n", sp->type); in qla24xx_mbx_iocb_entry()
2013 set_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags); in qla24xx_mbx_iocb_entry()
2015 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); in qla24xx_mbx_iocb_entry()
2019 si = &sp->u.iocb_cmd; in qla24xx_mbx_iocb_entry()
2020 sz = min(ARRAY_SIZE(pkt->mb), ARRAY_SIZE(sp->u.iocb_cmd.u.mbx.in_mb)); in qla24xx_mbx_iocb_entry()
2023 si->u.mbx.in_mb[i] = pkt->mb[i]; in qla24xx_mbx_iocb_entry()
2025 res = (si->u.mbx.in_mb[0] & MBS_MASK); in qla24xx_mbx_iocb_entry()
2027 sp->done(sp, res); in qla24xx_mbx_iocb_entry()
2042 if (pkt->u.isp2x.status != cpu_to_le16(NOTIFY_ACK_SUCCESS)) in qla24xxx_nack_iocb_entry()
2045 sp->done(sp, res); in qla24xxx_nack_iocb_entry()
2064 switch (sp->type) { in qla2x00_ct_entry()
2066 bsg_job = sp->u.bsg_job; in qla2x00_ct_entry()
2067 bsg_reply = bsg_job->reply; in qla2x00_ct_entry()
2069 type = "ct pass-through"; in qla2x00_ct_entry()
2071 comp_status = le16_to_cpu(pkt->comp_status); in qla2x00_ct_entry()
2077 bsg_reply->reply_data.ctels_reply.status = FC_CTELS_STATUS_OK; in qla2x00_ct_entry()
2078 bsg_job->reply_len = sizeof(struct fc_bsg_reply); in qla2x00_ct_entry()
2083 bsg_reply->reply_payload_rcv_len = in qla2x00_ct_entry()
2084 le16_to_cpu(pkt->rsp_info_len); in qla2x00_ct_entry()
2087 "CT pass-through-%s error comp_status=0x%x total_byte=0x%x.\n", in qla2x00_ct_entry()
2089 bsg_reply->reply_payload_rcv_len); in qla2x00_ct_entry()
2092 "CT pass-through-%s error comp_status=0x%x.\n", in qla2x00_ct_entry()
2095 bsg_reply->reply_payload_rcv_len = 0; in qla2x00_ct_entry()
2101 bsg_reply->reply_payload_rcv_len = in qla2x00_ct_entry()
2102 bsg_job->reply_payload.payload_len; in qla2x00_ct_entry()
2103 bsg_job->reply_len = 0; in qla2x00_ct_entry()
2112 (struct ct_sns_rsp *)sp->u.iocb_cmd.u.ctarg.rsp, in qla2x00_ct_entry()
2113 sp->name); in qla2x00_ct_entry()
2117 sp->done(sp, res); in qla2x00_ct_entry()
2124 struct els_sts_entry_24xx *ese = (struct els_sts_entry_24xx *)pkt; in qla24xx_els_ct_entry() local
2141 bsg_job = sp->u.bsg_job; in qla24xx_els_ct_entry()
2142 vha = sp->vha; in qla24xx_els_ct_entry()
2146 comp_status = fw_status[0] = le16_to_cpu(pkt->comp_status); in qla24xx_els_ct_entry()
2147 fw_status[1] = le32_to_cpu(((struct els_sts_entry_24xx *)pkt)->error_subcode_1); in qla24xx_els_ct_entry()
2148 fw_status[2] = le32_to_cpu(((struct els_sts_entry_24xx *)pkt)->error_subcode_2); in qla24xx_els_ct_entry()
2150 switch (sp->type) { in qla24xx_els_ct_entry()
2160 (struct qla_bsg_auth_els_request *)bsg_job->request; in qla24xx_els_ct_entry()
2164 __func__, sc_to_str(p->e.sub_cmd), in qla24xx_els_ct_entry()
2165 e->d_id[2], e->d_id[1], e->d_id[0], in qla24xx_els_ct_entry()
2166 comp_status, p->e.extra_rx_xchg_address, bsg_job); in qla24xx_els_ct_entry()
2168 if (!(le16_to_cpu(els->control_flags) & ECF_PAYLOAD_DESCR_MASK)) { in qla24xx_els_ct_entry()
2169 if (sp->remap.remapped) { in qla24xx_els_ct_entry()
2170 n = sg_copy_from_buffer(bsg_job->reply_payload.sg_list, in qla24xx_els_ct_entry()
2171 bsg_job->reply_payload.sg_cnt, in qla24xx_els_ct_entry()
2172 sp->remap.rsp.buf, in qla24xx_els_ct_entry()
2173 sp->remap.rsp.len); in qla24xx_els_ct_entry()
2176 __func__, n, sp->remap.rsp.len); in qla24xx_els_ct_entry()
2186 type = "ct pass-through"; in qla24xx_els_ct_entry()
2193 type, sp, sp->type); in qla24xx_els_ct_entry()
2194 sp->done(sp, 0); in qla24xx_els_ct_entry()
2202 res = qla2x00_chk_ms_status(sp->vha, (ms_iocb_entry_t *)pkt, in qla24xx_els_ct_entry()
2203 (struct ct_sns_rsp *)sp->u.iocb_cmd.u.ctarg.rsp, in qla24xx_els_ct_entry()
2204 sp->name); in qla24xx_els_ct_entry()
2205 sp->done(sp, res); in qla24xx_els_ct_entry()
2209 "Unrecognized SRB: (%p) type=%d.\n", sp, sp->type); in qla24xx_els_ct_entry()
2214 els = &sp->u.iocb_cmd; in qla24xx_els_ct_entry()
2215 els->u.els_plogi.fw_status[0] = cpu_to_le32(fw_status[0]); in qla24xx_els_ct_entry()
2216 els->u.els_plogi.fw_status[1] = cpu_to_le32(fw_status[1]); in qla24xx_els_ct_entry()
2217 els->u.els_plogi.fw_status[2] = cpu_to_le32(fw_status[2]); in qla24xx_els_ct_entry()
2218 els->u.els_plogi.comp_status = cpu_to_le16(fw_status[0]); in qla24xx_els_ct_entry()
2224 els->u.els_plogi.len = cpu_to_le16(le32_to_cpu( in qla24xx_els_ct_entry()
2225 ese->total_byte_count)); in qla24xx_els_ct_entry()
2227 if (sp->remap.remapped && in qla24xx_els_ct_entry()
2228 ((u8 *)sp->remap.rsp.buf)[0] == ELS_LS_ACC) { in qla24xx_els_ct_entry()
2230 "%s IOCB Done LS_ACC %02x%02x%02x -> %02x%02x%02x", in qla24xx_els_ct_entry()
2231 __func__, e->s_id[0], e->s_id[2], e->s_id[1], in qla24xx_els_ct_entry()
2232 e->d_id[2], e->d_id[1], e->d_id[0]); in qla24xx_els_ct_entry()
2241 els->u.els_plogi.len = 0; in qla24xx_els_ct_entry()
2243 qlt_schedule_sess_for_deletion(sp->fcport); in qla24xx_els_ct_entry()
2245 els->u.els_plogi.len = 0; in qla24xx_els_ct_entry()
2249 if (sp->remap.remapped && in qla24xx_els_ct_entry()
2250 ((u8 *)sp->remap.rsp.buf)[0] == ELS_LS_RJT) { in qla24xx_els_ct_entry()
2254 type, sp->handle, comp_status); in qla24xx_els_ct_entry()
2257 "subcode 1=0x%x subcode 2=0x%x bytes=0x%x %02x%02x%02x -> %02x%02x%02x\n", in qla24xx_els_ct_entry()
2260 pkt)->total_byte_count), in qla24xx_els_ct_entry()
2261 e->s_id[0], e->s_id[2], e->s_id[1], in qla24xx_els_ct_entry()
2262 e->d_id[2], e->d_id[1], e->d_id[0]); in qla24xx_els_ct_entry()
2264 if (sp->fcport && sp->fcport->flags & FCF_FCSP_DEVICE && in qla24xx_els_ct_entry()
2265 sp->type == SRB_ELS_CMD_HST_NOLOGIN) { in qla24xx_els_ct_entry()
2268 qlt_schedule_sess_for_deletion(sp->fcport); in qla24xx_els_ct_entry()
2273 type, sp->handle, comp_status); in qla24xx_els_ct_entry()
2275 "subcode 1=0x%x subcode 2=0x%x bytes=0x%x %02x%02x%02x -> %02x%02x%02x\n", in qla24xx_els_ct_entry()
2278 pkt)->total_byte_count), in qla24xx_els_ct_entry()
2279 e->s_id[0], e->s_id[2], e->s_id[1], in qla24xx_els_ct_entry()
2280 e->d_id[2], e->d_id[1], e->d_id[0]); in qla24xx_els_ct_entry()
2289 bsg_job = sp->u.bsg_job; in qla24xx_els_ct_entry()
2290 bsg_reply = bsg_job->reply; in qla24xx_els_ct_entry()
2291 bsg_reply->reply_data.ctels_reply.status = FC_CTELS_STATUS_OK; in qla24xx_els_ct_entry()
2292 bsg_job->reply_len = sizeof(struct fc_bsg_reply) + sizeof(fw_status); in qla24xx_els_ct_entry()
2297 bsg_reply->reply_payload_rcv_len = in qla24xx_els_ct_entry()
2298 le32_to_cpu(ese->total_byte_count); in qla24xx_els_ct_entry()
2301 "ELS-CT pass-through-%s error hdl=%x comp_status-status=0x%x " in qla24xx_els_ct_entry()
2303 type, sp->handle, comp_status, fw_status[1], fw_status[2], in qla24xx_els_ct_entry()
2304 le32_to_cpu(ese->total_byte_count)); in qla24xx_els_ct_entry()
2307 "ELS-CT pass-through-%s error hdl=%x comp_status-status=0x%x " in qla24xx_els_ct_entry()
2309 type, sp->handle, comp_status, in qla24xx_els_ct_entry()
2310 le32_to_cpu(ese->error_subcode_1), in qla24xx_els_ct_entry()
2311 le32_to_cpu(ese->error_subcode_2)); in qla24xx_els_ct_entry()
2313 bsg_reply->reply_payload_rcv_len = 0; in qla24xx_els_ct_entry()
2315 memcpy(bsg_job->reply + sizeof(struct fc_bsg_reply), in qla24xx_els_ct_entry()
2322 bsg_reply->reply_payload_rcv_len = bsg_job->reply_payload.payload_len; in qla24xx_els_ct_entry()
2323 bsg_job->reply_len = 0; in qla24xx_els_ct_entry()
2327 sp->done(sp, res); in qla24xx_els_ct_entry()
2334 const char func[] = "LOGIO-IOCB"; in qla24xx_logio_entry()
2347 lio = &sp->u.iocb_cmd; in qla24xx_logio_entry()
2348 type = sp->name; in qla24xx_logio_entry()
2349 fcport = sp->fcport; in qla24xx_logio_entry()
2350 data = lio->u.logio.data; in qla24xx_logio_entry()
2353 data[1] = lio->u.logio.flags & SRB_LOGIN_RETRIED ? in qla24xx_logio_entry()
2355 if (logio->entry_status) { in qla24xx_logio_entry()
2356 ql_log(ql_log_warn, fcport->vha, 0x5034, in qla24xx_logio_entry()
2357 "Async-%s error entry - %8phC hdl=%x" in qla24xx_logio_entry()
2358 "portid=%02x%02x%02x entry-status=%x.\n", in qla24xx_logio_entry()
2359 type, fcport->port_name, sp->handle, fcport->d_id.b.domain, in qla24xx_logio_entry()
2360 fcport->d_id.b.area, fcport->d_id.b.al_pa, in qla24xx_logio_entry()
2361 logio->entry_status); in qla24xx_logio_entry()
2368 if (le16_to_cpu(logio->comp_status) == CS_COMPLETE) { in qla24xx_logio_entry()
2369 ql_dbg(ql_dbg_async, sp->vha, 0x5036, in qla24xx_logio_entry()
2370 "Async-%s complete: handle=%x pid=%06x wwpn=%8phC iop0=%x\n", in qla24xx_logio_entry()
2371 type, sp->handle, fcport->d_id.b24, fcport->port_name, in qla24xx_logio_entry()
2372 le32_to_cpu(logio->io_parameter[0])); in qla24xx_logio_entry()
2374 vha->hw->exch_starvation = 0; in qla24xx_logio_entry()
2377 if (sp->type == SRB_PRLI_CMD) { in qla24xx_logio_entry()
2378 lio->u.logio.iop[0] = in qla24xx_logio_entry()
2379 le32_to_cpu(logio->io_parameter[0]); in qla24xx_logio_entry()
2380 lio->u.logio.iop[1] = in qla24xx_logio_entry()
2381 le32_to_cpu(logio->io_parameter[1]); in qla24xx_logio_entry()
2385 if (sp->type != SRB_LOGIN_CMD) in qla24xx_logio_entry()
2388 lio->u.logio.iop[1] = le32_to_cpu(logio->io_parameter[5]); in qla24xx_logio_entry()
2389 if (le32_to_cpu(logio->io_parameter[5]) & LIO_COMM_FEAT_FCSP) in qla24xx_logio_entry()
2390 fcport->flags |= FCF_FCSP_DEVICE; in qla24xx_logio_entry()
2392 iop[0] = le32_to_cpu(logio->io_parameter[0]); in qla24xx_logio_entry()
2394 fcport->port_type = FCT_TARGET; in qla24xx_logio_entry()
2396 fcport->flags |= FCF_FCP2_DEVICE; in qla24xx_logio_entry()
2398 fcport->port_type = FCT_INITIATOR; in qla24xx_logio_entry()
2401 fcport->flags |= FCF_CONF_COMP_SUPPORTED; in qla24xx_logio_entry()
2403 if (logio->io_parameter[7] || logio->io_parameter[8]) in qla24xx_logio_entry()
2404 fcport->supported_classes |= FC_COS_CLASS2; in qla24xx_logio_entry()
2405 if (logio->io_parameter[9] || logio->io_parameter[10]) in qla24xx_logio_entry()
2406 fcport->supported_classes |= FC_COS_CLASS3; in qla24xx_logio_entry()
2411 iop[0] = le32_to_cpu(logio->io_parameter[0]); in qla24xx_logio_entry()
2412 iop[1] = le32_to_cpu(logio->io_parameter[1]); in qla24xx_logio_entry()
2413 lio->u.logio.iop[0] = iop[0]; in qla24xx_logio_entry()
2414 lio->u.logio.iop[1] = iop[1]; in qla24xx_logio_entry()
2437 vha->hw->exch_starvation++; in qla24xx_logio_entry()
2438 if (vha->hw->exch_starvation > 5) { in qla24xx_logio_entry()
2442 vha->hw->exch_starvation = 0; in qla24xx_logio_entry()
2444 if (IS_P3P_TYPE(vha->hw)) in qla24xx_logio_entry()
2445 set_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags); in qla24xx_logio_entry()
2447 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); in qla24xx_logio_entry()
2457 ql_log(ql_log_warn, sp->vha, 0x5037, "Async-%s failed: " in qla24xx_logio_entry()
2459 type, sp->handle, fcport->d_id.b24, fcport->port_name, in qla24xx_logio_entry()
2460 le16_to_cpu(logio->comp_status), in qla24xx_logio_entry()
2461 le32_to_cpu(logio->io_parameter[0]), in qla24xx_logio_entry()
2462 le32_to_cpu(logio->io_parameter[1])); in qla24xx_logio_entry()
2464 ql_dbg(ql_dbg_disc, sp->vha, 0x5037, "Async-%s failed: " in qla24xx_logio_entry()
2466 type, sp->handle, fcport->d_id.b24, fcport->port_name, in qla24xx_logio_entry()
2467 le16_to_cpu(logio->comp_status), in qla24xx_logio_entry()
2468 le32_to_cpu(logio->io_parameter[0]), in qla24xx_logio_entry()
2469 le32_to_cpu(logio->io_parameter[1])); in qla24xx_logio_entry()
2472 sp->done(sp, 0); in qla24xx_logio_entry()
2478 const char func[] = "TMF-IOCB"; in qla24xx_tm_iocb_entry()
2490 comp_status = le16_to_cpu(sts->comp_status); in qla24xx_tm_iocb_entry()
2491 iocb = &sp->u.iocb_cmd; in qla24xx_tm_iocb_entry()
2492 type = sp->name; in qla24xx_tm_iocb_entry()
2493 fcport = sp->fcport; in qla24xx_tm_iocb_entry()
2494 iocb->u.tmf.data = QLA_SUCCESS; in qla24xx_tm_iocb_entry()
2496 if (sts->entry_status) { in qla24xx_tm_iocb_entry()
2497 ql_log(ql_log_warn, fcport->vha, 0x5038, in qla24xx_tm_iocb_entry()
2498 "Async-%s error - hdl=%x entry-status(%x).\n", in qla24xx_tm_iocb_entry()
2499 type, sp->handle, sts->entry_status); in qla24xx_tm_iocb_entry()
2500 iocb->u.tmf.data = QLA_FUNCTION_FAILED; in qla24xx_tm_iocb_entry()
2501 } else if (sts->comp_status != cpu_to_le16(CS_COMPLETE)) { in qla24xx_tm_iocb_entry()
2502 ql_log(ql_log_warn, fcport->vha, 0x5039, in qla24xx_tm_iocb_entry()
2503 "Async-%s error - hdl=%x completion status(%x).\n", in qla24xx_tm_iocb_entry()
2504 type, sp->handle, comp_status); in qla24xx_tm_iocb_entry()
2505 iocb->u.tmf.data = QLA_FUNCTION_FAILED; in qla24xx_tm_iocb_entry()
2506 } else if ((le16_to_cpu(sts->scsi_status) & in qla24xx_tm_iocb_entry()
2508 host_to_fcp_swap(sts->data, sizeof(sts->data)); in qla24xx_tm_iocb_entry()
2509 if (le32_to_cpu(sts->rsp_data_len) < 4) { in qla24xx_tm_iocb_entry()
2510 ql_log(ql_log_warn, fcport->vha, 0x503b, in qla24xx_tm_iocb_entry()
2511 "Async-%s error - hdl=%x not enough response(%d).\n", in qla24xx_tm_iocb_entry()
2512 type, sp->handle, sts->rsp_data_len); in qla24xx_tm_iocb_entry()
2513 } else if (sts->data[3]) { in qla24xx_tm_iocb_entry()
2514 ql_log(ql_log_warn, fcport->vha, 0x503c, in qla24xx_tm_iocb_entry()
2515 "Async-%s error - hdl=%x response(%x).\n", in qla24xx_tm_iocb_entry()
2516 type, sp->handle, sts->data[3]); in qla24xx_tm_iocb_entry()
2517 iocb->u.tmf.data = QLA_FUNCTION_FAILED; in qla24xx_tm_iocb_entry()
2529 if (atomic_read(&fcport->state) == FCS_ONLINE) { in qla24xx_tm_iocb_entry()
2530 ql_dbg(ql_dbg_disc, fcport->vha, 0x3021, in qla24xx_tm_iocb_entry()
2531 … "-Port to be marked lost on fcport=%02x%02x%02x, current port state= %s comp_status %x.\n", in qla24xx_tm_iocb_entry()
2532 fcport->d_id.b.domain, fcport->d_id.b.area, in qla24xx_tm_iocb_entry()
2533 fcport->d_id.b.al_pa, in qla24xx_tm_iocb_entry()
2545 if (iocb->u.tmf.data != QLA_SUCCESS) in qla24xx_tm_iocb_entry()
2546 ql_dump_buffer(ql_dbg_async + ql_dbg_buffer, sp->vha, 0x5055, in qla24xx_tm_iocb_entry()
2549 sp->done(sp, 0); in qla24xx_tm_iocb_entry()
2561 __le16 comp_status = sts->comp_status; in qla24xx_nvme_iocb_entry()
2564 iocb = &sp->u.iocb_cmd; in qla24xx_nvme_iocb_entry()
2565 fcport = sp->fcport; in qla24xx_nvme_iocb_entry()
2566 iocb->u.nvme.comp_status = comp_status; in qla24xx_nvme_iocb_entry()
2567 state_flags = le16_to_cpu(sts->state_flags); in qla24xx_nvme_iocb_entry()
2568 fd = iocb->u.nvme.desc; in qla24xx_nvme_iocb_entry()
2570 if (unlikely(iocb->u.nvme.aen_op)) in qla24xx_nvme_iocb_entry()
2571 atomic_dec(&sp->vha->hw->nvme_active_aen_cnt); in qla24xx_nvme_iocb_entry()
2573 sp->qpair->cmd_completion_cnt++; in qla24xx_nvme_iocb_entry()
2578 fd->transferred_length = fd->payload_length - in qla24xx_nvme_iocb_entry()
2579 le32_to_cpu(sts->residual_len); in qla24xx_nvme_iocb_entry()
2590 iocb->u.nvme.rsp_pyld_len = 0; in qla24xx_nvme_iocb_entry()
2593 /* Response already DMA'd to fd->rspaddr. */ in qla24xx_nvme_iocb_entry()
2594 iocb->u.nvme.rsp_pyld_len = sts->nvme_rsp_pyld_len; in qla24xx_nvme_iocb_entry()
2597 * Non-zero value in first 12 bytes of NVMe_RSP IU, treat this in qla24xx_nvme_iocb_entry()
2600 iocb->u.nvme.rsp_pyld_len = 0; in qla24xx_nvme_iocb_entry()
2601 fd->transferred_length = 0; in qla24xx_nvme_iocb_entry()
2602 ql_dbg(ql_dbg_io, fcport->vha, 0x307a, in qla24xx_nvme_iocb_entry()
2609 inbuf = (uint32_t *)&sts->nvme_ersp_data; in qla24xx_nvme_iocb_entry()
2610 outbuf = (uint32_t *)fd->rspaddr; in qla24xx_nvme_iocb_entry()
2611 iocb->u.nvme.rsp_pyld_len = sts->nvme_rsp_pyld_len; in qla24xx_nvme_iocb_entry()
2612 if (unlikely(le16_to_cpu(iocb->u.nvme.rsp_pyld_len) > in qla24xx_nvme_iocb_entry()
2616 iocb->u.nvme.rsp_pyld_len); in qla24xx_nvme_iocb_entry()
2617 ql_log(ql_log_warn, fcport->vha, 0x5100, in qla24xx_nvme_iocb_entry()
2619 iocb->u.nvme.rsp_pyld_len); in qla24xx_nvme_iocb_entry()
2621 iocb->u.nvme.rsp_pyld_len = in qla24xx_nvme_iocb_entry()
2624 iter = le16_to_cpu(iocb->u.nvme.rsp_pyld_len) >> 2; in qla24xx_nvme_iocb_entry()
2625 for (; iter; iter--) in qla24xx_nvme_iocb_entry()
2630 struct nvme_fc_ersp_iu *rsp_iu = fd->rspaddr; in qla24xx_nvme_iocb_entry()
2633 tgt_xfer_len = be32_to_cpu(rsp_iu->xfrd_len); in qla24xx_nvme_iocb_entry()
2634 if (fd->transferred_length != tgt_xfer_len) { in qla24xx_nvme_iocb_entry()
2635 ql_log(ql_log_warn, fcport->vha, 0x3079, in qla24xx_nvme_iocb_entry()
2637 tgt_xfer_len, fd->transferred_length); in qla24xx_nvme_iocb_entry()
2649 ql_dbg(ql_dbg_io, fcport->vha, 0x5060, in qla24xx_nvme_iocb_entry()
2650 "NVME-%s ERR Handling - hdl=%x status(%x) tr_len:%x resid=%x ox_id=%x\n", in qla24xx_nvme_iocb_entry()
2651 sp->name, sp->handle, comp_status, in qla24xx_nvme_iocb_entry()
2652 fd->transferred_length, le32_to_cpu(sts->residual_len), in qla24xx_nvme_iocb_entry()
2653 sts->ox_id); in qla24xx_nvme_iocb_entry()
2666 fcport->nvme_flag |= NVME_FLAG_RESETTING; in qla24xx_nvme_iocb_entry()
2667 if (atomic_read(&fcport->state) == FCS_ONLINE) { in qla24xx_nvme_iocb_entry()
2668 ql_dbg(ql_dbg_disc, fcport->vha, 0x3021, in qla24xx_nvme_iocb_entry()
2671 fcport->d_id.b24, port_state_str[FCS_ONLINE], in qla24xx_nvme_iocb_entry()
2679 fd->transferred_length = 0; in qla24xx_nvme_iocb_entry()
2680 iocb->u.nvme.rsp_pyld_len = 0; in qla24xx_nvme_iocb_entry()
2689 sp->done(sp, ret); in qla24xx_nvme_iocb_entry()
2695 const char func[] = "CTRLVP-IOCB"; in qla_ctrlvp_completed()
2703 if (vce->entry_status != 0) { in qla_ctrlvp_completed()
2705 "%s: Failed to complete IOCB -- error status (%x)\n", in qla_ctrlvp_completed()
2706 sp->name, vce->entry_status); in qla_ctrlvp_completed()
2708 } else if (vce->comp_status != cpu_to_le16(CS_COMPLETE)) { in qla_ctrlvp_completed()
2710 "%s: Failed to complete IOCB -- completion status (%x) vpidx %x\n", in qla_ctrlvp_completed()
2711 sp->name, le16_to_cpu(vce->comp_status), in qla_ctrlvp_completed()
2712 le16_to_cpu(vce->vp_idx_failed)); in qla_ctrlvp_completed()
2719 sp->rc = rval; in qla_ctrlvp_completed()
2720 sp->done(sp, rval); in qla_ctrlvp_completed()
2733 switch (pkt->entry_type) { in qla2x00_process_response_entry()
2739 handle_cnt = sts21_entry->handle_count; in qla2x00_process_response_entry()
2741 qla2x00_process_completed_request(vha, rsp->req, in qla2x00_process_response_entry()
2742 sts21_entry->handle[cnt]); in qla2x00_process_response_entry()
2746 handle_cnt = sts22_entry->handle_count; in qla2x00_process_response_entry()
2748 qla2x00_process_completed_request(vha, rsp->req, in qla2x00_process_response_entry()
2749 sts22_entry->handle[cnt]); in qla2x00_process_response_entry()
2755 qla2x00_mbx_iocb_entry(vha, rsp->req, (struct mbx_entry *)pkt); in qla2x00_process_response_entry()
2758 qla2x00_ct_entry(vha, rsp->req, pkt, CT_IOCB_TYPE); in qla2x00_process_response_entry()
2764 pkt->entry_type, pkt->entry_status); in qla2x00_process_response_entry()
2770 * qla2x00_process_response_queue() - Process response queue entries.
2777 struct qla_hw_data *ha = rsp->hw; in qla2x00_process_response_queue()
2778 struct device_reg_2xxx __iomem *reg = &ha->iobase->isp; in qla2x00_process_response_queue()
2781 vha = pci_get_drvdata(ha->pdev); in qla2x00_process_response_queue()
2783 if (!vha->flags.online) in qla2x00_process_response_queue()
2786 while (rsp->ring_ptr->signature != RESPONSE_PROCESSED) { in qla2x00_process_response_queue()
2787 pkt = (sts_entry_t *)rsp->ring_ptr; in qla2x00_process_response_queue()
2789 rsp->ring_index++; in qla2x00_process_response_queue()
2790 if (rsp->ring_index == rsp->length) { in qla2x00_process_response_queue()
2791 rsp->ring_index = 0; in qla2x00_process_response_queue()
2792 rsp->ring_ptr = rsp->ring; in qla2x00_process_response_queue()
2794 rsp->ring_ptr++; in qla2x00_process_response_queue()
2797 if (pkt->entry_status != 0) { in qla2x00_process_response_queue()
2799 ((response_t *)pkt)->signature = RESPONSE_PROCESSED; in qla2x00_process_response_queue()
2805 ((response_t *)pkt)->signature = RESPONSE_PROCESSED; in qla2x00_process_response_queue()
2810 wrt_reg_word(ISP_RSP_Q_OUT(ha, reg), rsp->ring_index); in qla2x00_process_response_queue()
2817 struct scsi_qla_host *vha = sp->vha; in qla2x00_handle_sense()
2825 SET_CMD_SENSE_PTR(sp, cp->sense_buffer); in qla2x00_handle_sense()
2831 memcpy(cp->sense_buffer, sense_data, sense_len); in qla2x00_handle_sense()
2833 SET_CMD_SENSE_PTR(sp, cp->sense_buffer + sense_len); in qla2x00_handle_sense()
2834 track_sense_len -= sense_len; in qla2x00_handle_sense()
2838 rsp->status_srb = sp; in qla2x00_handle_sense()
2839 cp->result = res; in qla2x00_handle_sense()
2845 sp->vha->host_no, cp->device->id, cp->device->lun, in qla2x00_handle_sense()
2848 cp->sense_buffer, sense_len); in qla2x00_handle_sense()
2859 * Checks the guard or meta-data for the type of error
2867 struct scsi_qla_host *vha = sp->vha; in qla2x00_handle_dif_error()
2869 uint8_t *ap = &sts24->data[12]; in qla2x00_handle_dif_error()
2870 uint8_t *ep = &sts24->data[20]; in qla2x00_handle_dif_error()
2893 cmd->cmnd[0], (u64)scsi_get_lba(cmd), a_ref_tag, e_ref_tag, in qla2x00_handle_dif_error()
2908 blocks_done = e_ref_tag - (uint32_t)lba_s + 1; in qla2x00_handle_dif_error()
2910 resid = scsi_bufflen(cmd) - (blocks_done * in qla2x00_handle_dif_error()
2911 cmd->device->sector_size); in qla2x00_handle_dif_error()
2914 cmd->result = DID_OK << 16; in qla2x00_handle_dif_error()
2930 j = blocks_done - k - 1; in qla2x00_handle_dif_error()
2942 spt = page_address(sg_page(sg)) + sg->offset; in qla2x00_handle_dif_error()
2945 spt->app_tag = T10_PI_APP_ESCAPE; in qla2x00_handle_dif_error()
2947 spt->ref_tag = T10_PI_REF_ESCAPE; in qla2x00_handle_dif_error()
2981 struct qla_hw_data *ha = vha->hw; in qla25xx_process_bidir_status_iocb()
2994 if (index >= req->num_outstanding_cmds) { in qla25xx_process_bidir_status_iocb()
2997 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); in qla25xx_process_bidir_status_iocb()
3001 sp = req->outstanding_cmds[index]; in qla25xx_process_bidir_status_iocb()
3005 req->id, index); in qla25xx_process_bidir_status_iocb()
3007 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); in qla25xx_process_bidir_status_iocb()
3012 req->outstanding_cmds[index] = NULL; in qla25xx_process_bidir_status_iocb()
3013 bsg_job = sp->u.bsg_job; in qla25xx_process_bidir_status_iocb()
3014 bsg_request = bsg_job->request; in qla25xx_process_bidir_status_iocb()
3015 bsg_reply = bsg_job->reply; in qla25xx_process_bidir_status_iocb()
3018 comp_status = le16_to_cpu(sts24->comp_status); in qla25xx_process_bidir_status_iocb()
3019 scsi_status = le16_to_cpu(sts24->scsi_status) & SS_MASK; in qla25xx_process_bidir_status_iocb()
3021 comp_status = le16_to_cpu(sts->comp_status); in qla25xx_process_bidir_status_iocb()
3022 scsi_status = le16_to_cpu(sts->scsi_status) & SS_MASK; in qla25xx_process_bidir_status_iocb()
3025 thread_id = bsg_request->rqst_data.h_vendor.vendor_cmd[1]; in qla25xx_process_bidir_status_iocb()
3029 bsg_reply->reply_payload_rcv_len = in qla25xx_process_bidir_status_iocb()
3030 bsg_job->reply_payload.payload_len; in qla25xx_process_bidir_status_iocb()
3031 vha->qla_stats.input_bytes += in qla25xx_process_bidir_status_iocb()
3032 bsg_reply->reply_payload_rcv_len; in qla25xx_process_bidir_status_iocb()
3033 vha->qla_stats.input_requests++; in qla25xx_process_bidir_status_iocb()
3113 bsg_reply->reply_payload_rcv_len = 0; in qla25xx_process_bidir_status_iocb()
3117 bsg_reply->reply_data.vendor_reply.vendor_rsp[0] = rval; in qla25xx_process_bidir_status_iocb()
3118 bsg_job->reply_len = sizeof(struct fc_bsg_reply); in qla25xx_process_bidir_status_iocb()
3121 sp->done(sp, DID_OK << 16); in qla25xx_process_bidir_status_iocb()
3126 * qla2x00_status_entry() - Process a Status IOCB entry.
3147 struct qla_hw_data *ha = vha->hw; in qla2x00_status_entry()
3157 comp_status = le16_to_cpu(sts24->comp_status); in qla2x00_status_entry()
3158 scsi_status = le16_to_cpu(sts24->scsi_status) & SS_MASK; in qla2x00_status_entry()
3159 state_flags = le16_to_cpu(sts24->state_flags); in qla2x00_status_entry()
3161 comp_status = le16_to_cpu(sts->comp_status); in qla2x00_status_entry()
3162 scsi_status = le16_to_cpu(sts->scsi_status) & SS_MASK; in qla2x00_status_entry()
3164 handle = (uint32_t) LSW(sts->handle); in qla2x00_status_entry()
3165 que = MSW(sts->handle); in qla2x00_status_entry()
3166 req = ha->req_q_map[que]; in qla2x00_status_entry()
3170 que >= find_first_zero_bit(ha->req_qid_map, ha->max_req_queues)) { in qla2x00_status_entry()
3173 "que=%u.\n", sts->handle, req, que); in qla2x00_status_entry()
3178 if (handle < req->num_outstanding_cmds) { in qla2x00_status_entry()
3179 sp = req->outstanding_cmds[handle]; in qla2x00_status_entry()
3183 __func__, vha->host_no, sts->handle); in qla2x00_status_entry()
3189 sts->handle); in qla2x00_status_entry()
3191 if (!test_bit(ABORT_ISP_ACTIVE, &vha->dpc_flags)) { in qla2x00_status_entry()
3193 set_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags); in qla2x00_status_entry()
3195 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); in qla2x00_status_entry()
3200 qla_put_iocbs(sp->qpair, &sp->iores); in qla2x00_status_entry()
3202 if (sp->cmd_type != TYPE_SRB) { in qla2x00_status_entry()
3203 req->outstanding_cmds[handle] = NULL; in qla2x00_status_entry()
3205 "Unknown sp->cmd_type %x %p).\n", in qla2x00_status_entry()
3206 sp->cmd_type, sp); in qla2x00_status_entry()
3211 if (sp->type == SRB_NVME_CMD) { in qla2x00_status_entry()
3212 req->outstanding_cmds[handle] = NULL; in qla2x00_status_entry()
3217 if (unlikely((state_flags & BIT_1) && (sp->type == SRB_BIDI_CMD))) { in qla2x00_status_entry()
3223 if (sp->type == SRB_TM_CMD) { in qla2x00_status_entry()
3230 sp->qpair->cmd_completion_cnt++; in qla2x00_status_entry()
3238 req->outstanding_cmds[handle] = NULL; in qla2x00_status_entry()
3243 sts->handle, sp); in qla2x00_status_entry()
3250 fcport = sp->fcport; in qla2x00_status_entry()
3257 sense_len = le32_to_cpu(sts24->sense_len); in qla2x00_status_entry()
3259 rsp_info_len = le32_to_cpu(sts24->rsp_data_len); in qla2x00_status_entry()
3261 resid_len = le32_to_cpu(sts24->rsp_residual_count); in qla2x00_status_entry()
3263 fw_resid_len = le32_to_cpu(sts24->residual_len); in qla2x00_status_entry()
3264 rsp_info = sts24->data; in qla2x00_status_entry()
3265 sense_data = sts24->data; in qla2x00_status_entry()
3266 host_to_fcp_swap(sts24->data, sizeof(sts24->data)); in qla2x00_status_entry()
3267 ox_id = le16_to_cpu(sts24->ox_id); in qla2x00_status_entry()
3268 par_sense_len = sizeof(sts24->data); in qla2x00_status_entry()
3269 sts_qual = le16_to_cpu(sts24->status_qualifier); in qla2x00_status_entry()
3272 sense_len = le16_to_cpu(sts->req_sense_length); in qla2x00_status_entry()
3274 rsp_info_len = le16_to_cpu(sts->rsp_info_len); in qla2x00_status_entry()
3275 resid_len = le32_to_cpu(sts->residual_length); in qla2x00_status_entry()
3276 rsp_info = sts->rsp_info; in qla2x00_status_entry()
3277 sense_data = sts->req_sense_data; in qla2x00_status_entry()
3278 par_sense_len = sizeof(sts->req_sense_data); in qla2x00_status_entry()
3286 par_sense_len -= rsp_info_len; in qla2x00_status_entry()
3289 ql_dbg(ql_dbg_io, fcport->vha, 0x3019, in qla2x00_status_entry()
3326 ((unsigned)(scsi_bufflen(cp) - resid) < in qla2x00_status_entry()
3327 cp->underflow)) { in qla2x00_status_entry()
3328 ql_dbg(ql_dbg_io, fcport->vha, 0x301a, in qla2x00_status_entry()
3329 "Mid-layer underflow detected (0x%x of 0x%x bytes).\n", in qla2x00_status_entry()
3339 ql_dbg(ql_dbg_io, fcport->vha, 0x301b, in qla2x00_status_entry()
3347 memset(cp->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); in qla2x00_status_entry()
3361 ql_log(ql_log_warn, fcport->vha, 0x301d, in qla2x00_status_entry()
3365 vha->interface_err_cnt++; in qla2x00_status_entry()
3372 ((unsigned)(scsi_bufflen(cp) - resid) < in qla2x00_status_entry()
3373 cp->underflow)) { in qla2x00_status_entry()
3374 ql_dbg(ql_dbg_io, fcport->vha, 0x301e, in qla2x00_status_entry()
3375 "Mid-layer underflow detected (0x%x of 0x%x bytes).\n", in qla2x00_status_entry()
3388 ql_log(ql_log_warn, fcport->vha, 0x301f, in qla2x00_status_entry()
3392 vha->interface_err_cnt++; in qla2x00_status_entry()
3397 ql_dbg(ql_dbg_io, fcport->vha, 0x3030, in qla2x00_status_entry()
3412 ql_dbg(ql_dbg_io, fcport->vha, 0x3020, in qla2x00_status_entry()
3420 memset(cp->sense_buffer, 0, SCSI_SENSE_BUFFERSIZE); in qla2x00_status_entry()
3448 else if ((le16_to_cpu(sts->status_flags) & in qla2x00_status_entry()
3453 if (atomic_read(&fcport->state) == FCS_ONLINE) { in qla2x00_status_entry()
3454 ql_dbg(ql_dbg_disc, fcport->vha, 0x3021, in qla2x00_status_entry()
3456 "port state= %s comp_status %x.\n", fcport->d_id.b.domain, in qla2x00_status_entry()
3457 fcport->d_id.b.area, fcport->d_id.b.al_pa, in qla2x00_status_entry()
3472 res = cp->result; in qla2x00_status_entry()
3477 vha->hw_err_cnt++; in qla2x00_status_entry()
3485 cp->device->vendor); in qla2x00_status_entry()
3489 ql_log(ql_log_info, fcport->vha, 0x3022, in qla2x00_status_entry()
3490 …"CS_DMA error: 0x%x-0x%x (0x%x) nexus=%ld:%d:%llu portid=%06x oxid=0x%x cdb=%10phN len=0x%x rsp_in… in qla2x00_status_entry()
3491 comp_status, scsi_status, res, vha->host_no, in qla2x00_status_entry()
3492 cp->device->id, cp->device->lun, fcport->d_id.b24, in qla2x00_status_entry()
3493 ox_id, cp->cmnd, scsi_bufflen(cp), rsp_info_len, in qla2x00_status_entry()
3498 vha->hw_err_cnt++; in qla2x00_status_entry()
3507 ql_dbg(ql_dbg_io, fcport->vha, 0x3022, in qla2x00_status_entry()
3508 …"FCP command status: 0x%x-0x%x (0x%x) nexus=%ld:%d:%llu portid=%02x%02x%02x oxid=0x%x cdb=%10phN l… in qla2x00_status_entry()
3509 comp_status, scsi_status, res, vha->host_no, in qla2x00_status_entry()
3510 cp->device->id, cp->device->lun, fcport->d_id.b.domain, in qla2x00_status_entry()
3511 fcport->d_id.b.area, fcport->d_id.b.al_pa, ox_id, in qla2x00_status_entry()
3512 cp->cmnd, scsi_bufflen(cp), rsp_info_len, in qla2x00_status_entry()
3515 if (rsp->status_srb == NULL) in qla2x00_status_entry()
3516 sp->done(sp, res); in qla2x00_status_entry()
3520 * qla2x00_status_cont_entry() - Process a Status Continuations entry.
3530 struct qla_hw_data *ha = rsp->hw; in qla2x00_status_cont_entry()
3531 struct scsi_qla_host *vha = pci_get_drvdata(ha->pdev); in qla2x00_status_cont_entry()
3532 srb_t *sp = rsp->status_srb; in qla2x00_status_cont_entry()
3548 rsp->status_srb = NULL; in qla2x00_status_cont_entry()
3552 if (sense_len > sizeof(pkt->data)) in qla2x00_status_cont_entry()
3553 sense_sz = sizeof(pkt->data); in qla2x00_status_cont_entry()
3559 host_to_fcp_swap(pkt->data, sizeof(pkt->data)); in qla2x00_status_cont_entry()
3560 memcpy(sense_ptr, pkt->data, sense_sz); in qla2x00_status_cont_entry()
3564 sense_len -= sense_sz; in qla2x00_status_cont_entry()
3572 rsp->status_srb = NULL; in qla2x00_status_cont_entry()
3573 sp->done(sp, cp->result); in qla2x00_status_cont_entry()
3578 * qla2x00_error_entry() - Process an error entry.
3588 struct qla_hw_data *ha = vha->hw; in qla2x00_error_entry()
3589 const char func[] = "ERROR-IOCB"; in qla2x00_error_entry()
3590 uint16_t que = MSW(pkt->handle); in qla2x00_error_entry()
3596 pkt->entry_type, pkt->entry_status, pkt->handle, rsp->id); in qla2x00_error_entry()
3598 if (que >= ha->max_req_queues || !ha->req_q_map[que]) in qla2x00_error_entry()
3601 req = ha->req_q_map[que]; in qla2x00_error_entry()
3603 if (pkt->entry_status & RF_BUSY) in qla2x00_error_entry()
3606 if ((pkt->handle & ~QLA_TGT_HANDLE_MASK) == QLA_TGT_SKIP_HANDLE) in qla2x00_error_entry()
3609 switch (pkt->entry_type) { in qla2x00_error_entry()
3621 qla_put_iocbs(sp->qpair, &sp->iores); in qla2x00_error_entry()
3622 sp->done(sp, res); in qla2x00_error_entry()
3635 "Error entry - invalid handle/queue (%04x).\n", que); in qla2x00_error_entry()
3640 * qla24xx_mbx_completion() - Process mailbox command completions.
3650 struct qla_hw_data *ha = vha->hw; in qla24xx_mbx_completion()
3651 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; in qla24xx_mbx_completion()
3654 WARN_ON_ONCE(ha->mbx_count > 32); in qla24xx_mbx_completion()
3655 mboxes = (1ULL << ha->mbx_count) - 1; in qla24xx_mbx_completion()
3656 if (!ha->mcp) in qla24xx_mbx_completion()
3659 mboxes = ha->mcp->in_mb; in qla24xx_mbx_completion()
3662 ha->flags.mbox_int = 1; in qla24xx_mbx_completion()
3663 ha->mailbox_out[0] = mb0; in qla24xx_mbx_completion()
3665 wptr = ®->mailbox1; in qla24xx_mbx_completion()
3667 for (cnt = 1; cnt < ha->mbx_count; cnt++) { in qla24xx_mbx_completion()
3669 ha->mailbox_out[cnt] = rd_reg_word(wptr); in qla24xx_mbx_completion()
3689 abt = &sp->u.iocb_cmd; in qla24xx_abort_iocb_entry()
3690 abt->u.abt.comp_status = pkt->comp_status; in qla24xx_abort_iocb_entry()
3691 orig_sp = sp->cmd_sp; in qla24xx_abort_iocb_entry()
3696 sp->done(sp, 0); in qla24xx_abort_iocb_entry()
3710 comp_status = le16_to_cpu(pkt->status); in qla24xx_nvme_ls4_iocb()
3711 sp->done(sp, comp_status); in qla24xx_nvme_ls4_iocb()
3715 * qla_chk_cont_iocb_avail - check for all continuation iocbs are available
3720 * Return: 0 all iocbs has arrived, xx- all iocbs have not arrived.
3729 if (pkt->entry_count == 1) in qla_chk_cont_iocb_avail()
3732 /* ring_index was pre-increment. set it back to current pkt */ in qla_chk_cont_iocb_avail()
3733 if (rsp->ring_index == 0) in qla_chk_cont_iocb_avail()
3734 start_pkt_ring_index = rsp->length - 1; in qla_chk_cont_iocb_avail()
3736 start_pkt_ring_index = rsp->ring_index - 1; in qla_chk_cont_iocb_avail()
3740 iocb_cnt = rsp->length - start_pkt_ring_index + rsp_q_in; in qla_chk_cont_iocb_avail()
3742 iocb_cnt = rsp_q_in - start_pkt_ring_index; in qla_chk_cont_iocb_avail()
3744 if (iocb_cnt < pkt->entry_count) in qla_chk_cont_iocb_avail()
3745 rc = -EIO; in qla_chk_cont_iocb_avail()
3748 "%s - ring %p pkt %p entry count %d iocb_cnt %d rsp_q_in %d rc %d\n", in qla_chk_cont_iocb_avail()
3749 __func__, rsp->ring, pkt, pkt->entry_count, iocb_cnt, rsp_q_in, rc); in qla_chk_cont_iocb_avail()
3755 * qla24xx_process_response_queue() - Process response queue entries.
3763 struct qla_hw_data *ha = vha->hw; in qla24xx_process_response_queue()
3769 if (!ha->flags.fw_started) in qla24xx_process_response_queue()
3772 if (rsp->qpair->cpuid != smp_processor_id() || !rsp->qpair->rcv_intr) { in qla24xx_process_response_queue()
3773 rsp->qpair->rcv_intr = 1; in qla24xx_process_response_queue()
3774 qla_cpu_update(rsp->qpair, smp_processor_id()); in qla24xx_process_response_queue()
3779 _rsp_in = _is_shadow_hba ? *(_rsp)->in_ptr : \ in qla24xx_process_response_queue()
3780 rd_reg_dword_relaxed((_rsp)->rsp_q_in); \ in qla24xx_process_response_queue()
3787 while (rsp->ring_index != rsp_in && in qla24xx_process_response_queue()
3788 rsp->ring_ptr->signature != RESPONSE_PROCESSED) { in qla24xx_process_response_queue()
3789 pkt = (struct sts_entry_24xx *)rsp->ring_ptr; in qla24xx_process_response_queue()
3790 cur_ring_index = rsp->ring_index; in qla24xx_process_response_queue()
3792 rsp->ring_index++; in qla24xx_process_response_queue()
3793 if (rsp->ring_index == rsp->length) { in qla24xx_process_response_queue()
3794 rsp->ring_index = 0; in qla24xx_process_response_queue()
3795 rsp->ring_ptr = rsp->ring; in qla24xx_process_response_queue()
3797 rsp->ring_ptr++; in qla24xx_process_response_queue()
3800 if (pkt->entry_status != 0) { in qla24xx_process_response_queue()
3804 ((response_t *)pkt)->signature = RESPONSE_PROCESSED; in qla24xx_process_response_queue()
3810 switch (pkt->entry_type) { in qla24xx_process_response_queue()
3822 qla24xx_logio_entry(vha, rsp->req, in qla24xx_process_response_queue()
3826 qla24xx_els_ct_entry(vha, rsp->req, pkt, CT_IOCB_TYPE); in qla24xx_process_response_queue()
3829 qla24xx_els_ct_entry(vha, rsp->req, pkt, ELS_IOCB_TYPE); in qla24xx_process_response_queue()
3857 rsp->req); in qla24xx_process_response_queue()
3860 if (pkt->handle == QLA_TGT_SKIP_HANDLE) in qla24xx_process_response_queue()
3864 qla24xxx_nack_iocb_entry(vha, rsp->req, in qla24xx_process_response_queue()
3873 qla24xx_abort_iocb_entry(vha, rsp->req, in qla24xx_process_response_queue()
3877 qla24xx_mbx_iocb_entry(vha, rsp->req, in qla24xx_process_response_queue()
3881 qla_ctrlvp_completed(vha, rsp->req, in qla24xx_process_response_queue()
3886 switch (purex_entry->els_frame_payload[3]) { in qla24xx_process_response_queue()
3895 if (!vha->hw->flags.scm_enabled) { in qla24xx_process_response_queue()
3913 * pre-incremented above. Reset them in qla24xx_process_response_queue()
3916 * and re-process. in qla24xx_process_response_queue()
3918 rsp->ring_ptr = (response_t *)pkt; in qla24xx_process_response_queue()
3919 rsp->ring_index = cur_ring_index; in qla24xx_process_response_queue()
3923 purex_entry->els_frame_payload[3]); in qla24xx_process_response_queue()
3931 purex_entry->els_frame_payload[3]); in qla24xx_process_response_queue()
3935 qla28xx_sa_update_iocb_entry(vha, rsp->req, in qla24xx_process_response_queue()
3943 pkt->entry_type, pkt->entry_status); in qla24xx_process_response_queue()
3946 ((response_t *)pkt)->signature = RESPONSE_PROCESSED; in qla24xx_process_response_queue()
3952 struct device_reg_82xx __iomem *reg = &ha->iobase->isp82; in qla24xx_process_response_queue()
3954 wrt_reg_dword(®->rsp_q_out[0], rsp->ring_index); in qla24xx_process_response_queue()
3956 wrt_reg_dword(rsp->rsp_q_out, rsp->ring_index); in qla24xx_process_response_queue()
3965 struct qla_hw_data *ha = vha->hw; in qla2xxx_check_risc_status()
3966 struct device_reg_24xx __iomem *reg = &ha->iobase->isp24; in qla2xxx_check_risc_status()
3973 wrt_reg_dword(®->iobase_addr, 0x7C00); in qla2xxx_check_risc_status()
3974 rd_reg_dword(®->iobase_addr); in qla2xxx_check_risc_status()
3975 wrt_reg_dword(®->iobase_window, 0x0001); in qla2xxx_check_risc_status()
3976 for (cnt = 10000; (rd_reg_dword(®->iobase_window) & BIT_0) == 0 && in qla2xxx_check_risc_status()
3977 rval == QLA_SUCCESS; cnt--) { in qla2xxx_check_risc_status()
3979 wrt_reg_dword(®->iobase_window, 0x0001); in qla2xxx_check_risc_status()
3988 wrt_reg_dword(®->iobase_window, 0x0003); in qla2xxx_check_risc_status()
3989 for (cnt = 100; (rd_reg_dword(®->iobase_window) & BIT_0) == 0 && in qla2xxx_check_risc_status()
3990 rval == QLA_SUCCESS; cnt--) { in qla2xxx_check_risc_status()
3992 wrt_reg_dword(®->iobase_window, 0x0003); in qla2xxx_check_risc_status()
4001 if (rd_reg_dword(®->iobase_c8) & BIT_3) in qla2xxx_check_risc_status()
4003 "Additional code -- 0x55AA.\n"); in qla2xxx_check_risc_status()
4006 wrt_reg_dword(®->iobase_window, 0x0000); in qla2xxx_check_risc_status()
4007 rd_reg_dword(®->iobase_window); in qla2xxx_check_risc_status()
4011 * qla24xx_intr_handler() - Process interrupts for the ISP23xx and ISP24xx.
4041 ha = rsp->hw; in qla24xx_intr_handler()
4042 reg = &ha->iobase->isp24; in qla24xx_intr_handler()
4045 if (unlikely(pci_channel_offline(ha->pdev))) in qla24xx_intr_handler()
4048 spin_lock_irqsave(&ha->hardware_lock, flags); in qla24xx_intr_handler()
4049 vha = pci_get_drvdata(ha->pdev); in qla24xx_intr_handler()
4050 for (iter = 50; iter--; ) { in qla24xx_intr_handler()
4051 stat = rd_reg_dword(®->host_status); in qla24xx_intr_handler()
4055 if (unlikely(pci_channel_offline(ha->pdev))) in qla24xx_intr_handler()
4058 hccr = rd_reg_dword(®->hccr); in qla24xx_intr_handler()
4061 "RISC paused -- HCCR=%x, Dumping firmware.\n", in qla24xx_intr_handler()
4066 ha->isp_ops->fw_dump(vha); in qla24xx_intr_handler()
4067 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); in qla24xx_intr_handler()
4083 mb[1] = rd_reg_word(®->mailbox1); in qla24xx_intr_handler()
4084 mb[2] = rd_reg_word(®->mailbox2); in qla24xx_intr_handler()
4085 mb[3] = rd_reg_word(®->mailbox3); in qla24xx_intr_handler()
4105 wrt_reg_dword(®->hccr, HCCRX_CLR_RISC_INT); in qla24xx_intr_handler()
4106 rd_reg_dword_relaxed(®->hccr); in qla24xx_intr_handler()
4107 if (unlikely(IS_QLA83XX(ha) && (ha->pdev->revision == 1))) in qla24xx_intr_handler()
4111 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla24xx_intr_handler()
4114 spin_lock_irqsave(&ha->tgt.atio_lock, flags); in qla24xx_intr_handler()
4116 spin_unlock_irqrestore(&ha->tgt.atio_lock, flags); in qla24xx_intr_handler()
4137 ha = rsp->hw; in qla24xx_msix_rsp_q()
4138 reg = &ha->iobase->isp24; in qla24xx_msix_rsp_q()
4140 spin_lock_irqsave(&ha->hardware_lock, flags); in qla24xx_msix_rsp_q()
4142 vha = pci_get_drvdata(ha->pdev); in qla24xx_msix_rsp_q()
4144 if (!ha->flags.disable_msix_handshake) { in qla24xx_msix_rsp_q()
4145 wrt_reg_dword(®->hccr, HCCRX_CLR_RISC_INT); in qla24xx_msix_rsp_q()
4146 rd_reg_dword_relaxed(®->hccr); in qla24xx_msix_rsp_q()
4148 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla24xx_msix_rsp_q()
4173 ha = rsp->hw; in qla24xx_msix_default()
4174 reg = &ha->iobase->isp24; in qla24xx_msix_default()
4177 spin_lock_irqsave(&ha->hardware_lock, flags); in qla24xx_msix_default()
4178 vha = pci_get_drvdata(ha->pdev); in qla24xx_msix_default()
4180 stat = rd_reg_dword(®->host_status); in qla24xx_msix_default()
4184 if (unlikely(pci_channel_offline(ha->pdev))) in qla24xx_msix_default()
4187 hccr = rd_reg_dword(®->hccr); in qla24xx_msix_default()
4190 "RISC paused -- HCCR=%x, Dumping firmware.\n", in qla24xx_msix_default()
4194 vha->hw_err_cnt++; in qla24xx_msix_default()
4196 ha->isp_ops->fw_dump(vha); in qla24xx_msix_default()
4197 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); in qla24xx_msix_default()
4213 mb[1] = rd_reg_word(®->mailbox1); in qla24xx_msix_default()
4214 mb[2] = rd_reg_word(®->mailbox2); in qla24xx_msix_default()
4215 mb[3] = rd_reg_word(®->mailbox3); in qla24xx_msix_default()
4235 wrt_reg_dword(®->hccr, HCCRX_CLR_RISC_INT); in qla24xx_msix_default()
4238 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla24xx_msix_default()
4241 spin_lock_irqsave(&ha->tgt.atio_lock, flags); in qla24xx_msix_default()
4243 spin_unlock_irqrestore(&ha->tgt.atio_lock, flags); in qla24xx_msix_default()
4261 ha = qpair->hw; in qla2xxx_msix_rsp_q()
4263 queue_work_on(smp_processor_id(), ha->wq, &qpair->q_work); in qla2xxx_msix_rsp_q()
4282 ha = qpair->hw; in qla2xxx_msix_rsp_q_hs()
4284 reg = &ha->iobase->isp24; in qla2xxx_msix_rsp_q_hs()
4285 spin_lock_irqsave(&ha->hardware_lock, flags); in qla2xxx_msix_rsp_q_hs()
4286 wrt_reg_dword(®->hccr, HCCRX_CLR_RISC_INT); in qla2xxx_msix_rsp_q_hs()
4287 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qla2xxx_msix_rsp_q_hs()
4289 queue_work_on(smp_processor_id(), ha->wq, &qpair->q_work); in qla2xxx_msix_rsp_q_hs()
4319 scsi_qla_host_t *vha = pci_get_drvdata(ha->pdev); in qla24xx_enable_msix()
4331 if (USER_CTRL_IRQ(ha) || !ha->mqiobase) { in qla24xx_enable_msix()
4333 ret = pci_alloc_irq_vectors(ha->pdev, min_vecs, in qla24xx_enable_msix()
4334 min((u16)ha->msix_count, (u16)(num_online_cpus() + min_vecs)), in qla24xx_enable_msix()
4337 ret = pci_alloc_irq_vectors_affinity(ha->pdev, min_vecs, in qla24xx_enable_msix()
4338 min((u16)ha->msix_count, (u16)(num_online_cpus() + min_vecs)), in qla24xx_enable_msix()
4344 "MSI-X: Failed to enable support, " in qla24xx_enable_msix()
4345 "giving up -- %d/%d.\n", in qla24xx_enable_msix()
4346 ha->msix_count, ret); in qla24xx_enable_msix()
4348 } else if (ret < ha->msix_count) { in qla24xx_enable_msix()
4350 "MSI-X: Using %d vectors\n", ret); in qla24xx_enable_msix()
4351 ha->msix_count = ret; in qla24xx_enable_msix()
4353 if (ha->mqiobase && (ql2xmqsupport || ql2xnvmeenable)) { in qla24xx_enable_msix()
4354 ha->max_req_queues = ha->msix_count - 1; in qla24xx_enable_msix()
4358 ha->max_req_queues--; in qla24xx_enable_msix()
4360 ha->max_rsp_queues = ha->max_req_queues; in qla24xx_enable_msix()
4362 ha->max_qpairs = ha->max_req_queues - 1; in qla24xx_enable_msix()
4363 ql_dbg_pci(ql_dbg_init, ha->pdev, 0x0190, in qla24xx_enable_msix()
4364 "Adjusted Max no of queues pairs: %d.\n", ha->max_qpairs); in qla24xx_enable_msix()
4367 vha->irq_offset = desc.pre_vectors; in qla24xx_enable_msix()
4368 ha->msix_entries = kcalloc(ha->msix_count, in qla24xx_enable_msix()
4371 if (!ha->msix_entries) { in qla24xx_enable_msix()
4373 "Failed to allocate memory for ha->msix_entries.\n"); in qla24xx_enable_msix()
4374 ret = -ENOMEM; in qla24xx_enable_msix()
4377 ha->flags.msix_enabled = 1; in qla24xx_enable_msix()
4379 for (i = 0; i < ha->msix_count; i++) { in qla24xx_enable_msix()
4380 qentry = &ha->msix_entries[i]; in qla24xx_enable_msix()
4381 qentry->vector = pci_irq_vector(ha->pdev, i); in qla24xx_enable_msix()
4382 qentry->entry = i; in qla24xx_enable_msix()
4383 qentry->have_irq = 0; in qla24xx_enable_msix()
4384 qentry->in_use = 0; in qla24xx_enable_msix()
4385 qentry->handle = NULL; in qla24xx_enable_msix()
4388 /* Enable MSI-X vectors for the base queue */ in qla24xx_enable_msix()
4390 qentry = &ha->msix_entries[i]; in qla24xx_enable_msix()
4391 qentry->handle = rsp; in qla24xx_enable_msix()
4392 rsp->msix = qentry; in qla24xx_enable_msix()
4393 scnprintf(qentry->name, sizeof(qentry->name), in qla24xx_enable_msix()
4394 "qla2xxx%lu_%s", vha->host_no, msix_entries[i].name); in qla24xx_enable_msix()
4396 ret = request_irq(qentry->vector, in qla24xx_enable_msix()
4400 ret = request_irq(qentry->vector, in qla24xx_enable_msix()
4402 0, qentry->name, rsp); in qla24xx_enable_msix()
4405 qentry->have_irq = 1; in qla24xx_enable_msix()
4406 qentry->in_use = 1; in qla24xx_enable_msix()
4415 qentry = &ha->msix_entries[QLA_ATIO_VECTOR]; in qla24xx_enable_msix()
4416 rsp->msix = qentry; in qla24xx_enable_msix()
4417 qentry->handle = rsp; in qla24xx_enable_msix()
4418 scnprintf(qentry->name, sizeof(qentry->name), in qla24xx_enable_msix()
4419 "qla2xxx%lu_%s", vha->host_no, in qla24xx_enable_msix()
4421 qentry->in_use = 1; in qla24xx_enable_msix()
4422 ret = request_irq(qentry->vector, in qla24xx_enable_msix()
4424 0, qentry->name, rsp); in qla24xx_enable_msix()
4425 qentry->have_irq = 1; in qla24xx_enable_msix()
4431 "MSI-X: unable to register handler -- %x/%d.\n", in qla24xx_enable_msix()
4432 qentry->vector, ret); in qla24xx_enable_msix()
4434 ha->mqenable = 0; in qla24xx_enable_msix()
4438 /* Enable MSI-X vector for response queue update for queue 0 */ in qla24xx_enable_msix()
4440 (ha->msixbase && ha->mqiobase && ha->max_qpairs)) in qla24xx_enable_msix()
4441 ha->mqenable = 1; in qla24xx_enable_msix()
4443 ha->mqenable = 0; in qla24xx_enable_msix()
4447 ha->mqiobase, ha->max_rsp_queues, ha->max_req_queues); in qla24xx_enable_msix()
4450 ha->mqiobase, ha->max_rsp_queues, ha->max_req_queues); in qla24xx_enable_msix()
4456 pci_free_irq_vectors(ha->pdev); in qla24xx_enable_msix()
4464 device_reg_t *reg = ha->iobase; in qla2x00_request_irqs()
4465 scsi_qla_host_t *vha = pci_get_drvdata(ha->pdev); in qla2x00_request_irqs()
4467 /* If possible, enable MSI-X. */ in qla2x00_request_irqs()
4476 if (ha->pdev->subsystem_vendor == PCI_VENDOR_ID_HP && in qla2x00_request_irqs()
4477 (ha->pdev->subsystem_device == 0x7040 || in qla2x00_request_irqs()
4478 ha->pdev->subsystem_device == 0x7041 || in qla2x00_request_irqs()
4479 ha->pdev->subsystem_device == 0x1705)) { in qla2x00_request_irqs()
4481 "MSI-X: Unsupported ISP 2432 SSVID/SSDID (0x%X,0x%X).\n", in qla2x00_request_irqs()
4482 ha->pdev->subsystem_vendor, in qla2x00_request_irqs()
4483 ha->pdev->subsystem_device); in qla2x00_request_irqs()
4487 if (IS_QLA2432(ha) && (ha->pdev->revision < QLA_MSIX_CHIP_REV_24XX)) { in qla2x00_request_irqs()
4489 "MSI-X; Unsupported ISP2432 (0x%X, 0x%X).\n", in qla2x00_request_irqs()
4490 ha->pdev->revision, QLA_MSIX_CHIP_REV_24XX); in qla2x00_request_irqs()
4497 "MSI-X: Enabled (0x%X, 0x%X).\n", in qla2x00_request_irqs()
4498 ha->chip_revision, ha->fw_attributes); in qla2x00_request_irqs()
4505 "Falling back-to MSI mode -- ret=%d.\n", ret); in qla2x00_request_irqs()
4512 ret = pci_alloc_irq_vectors(ha->pdev, 1, 1, PCI_IRQ_MSI); in qla2x00_request_irqs()
4516 ha->flags.msi_enabled = 1; in qla2x00_request_irqs()
4519 "Falling back-to INTa mode -- ret=%d.\n", ret); in qla2x00_request_irqs()
4523 if (!ha->flags.msi_enabled && IS_QLA82XX(ha)) in qla2x00_request_irqs()
4526 ret = request_irq(ha->pdev->irq, ha->isp_ops->intr_handler, in qla2x00_request_irqs()
4527 ha->flags.msi_enabled ? 0 : IRQF_SHARED, in qla2x00_request_irqs()
4532 ha->pdev->irq); in qla2x00_request_irqs()
4534 } else if (!ha->flags.msi_enabled) { in qla2x00_request_irqs()
4537 ha->flags.mr_intr_valid = 1; in qla2x00_request_irqs()
4538 /* Set max_qpair to 0, as MSI-X and MSI in not enabled */ in qla2x00_request_irqs()
4539 ha->max_qpairs = 0; in qla2x00_request_irqs()
4546 spin_lock_irq(&ha->hardware_lock); in qla2x00_request_irqs()
4547 wrt_reg_word(®->isp.semaphore, 0); in qla2x00_request_irqs()
4548 spin_unlock_irq(&ha->hardware_lock); in qla2x00_request_irqs()
4557 struct qla_hw_data *ha = vha->hw; in qla2x00_free_irqs()
4563 * We need to check that ha->rsp_q_map is valid in case we are called in qla2x00_free_irqs()
4566 if (!ha->rsp_q_map || !ha->rsp_q_map[0]) in qla2x00_free_irqs()
4568 rsp = ha->rsp_q_map[0]; in qla2x00_free_irqs()
4570 if (ha->flags.msix_enabled) { in qla2x00_free_irqs()
4571 for (i = 0; i < ha->msix_count; i++) { in qla2x00_free_irqs()
4572 qentry = &ha->msix_entries[i]; in qla2x00_free_irqs()
4573 if (qentry->have_irq) { in qla2x00_free_irqs()
4574 irq_set_affinity_notifier(qentry->vector, NULL); in qla2x00_free_irqs()
4575 free_irq(pci_irq_vector(ha->pdev, i), qentry->handle); in qla2x00_free_irqs()
4578 kfree(ha->msix_entries); in qla2x00_free_irqs()
4579 ha->msix_entries = NULL; in qla2x00_free_irqs()
4580 ha->flags.msix_enabled = 0; in qla2x00_free_irqs()
4582 "Disabled MSI-X.\n"); in qla2x00_free_irqs()
4584 free_irq(pci_irq_vector(ha->pdev, 0), rsp); in qla2x00_free_irqs()
4588 pci_free_irq_vectors(ha->pdev); in qla2x00_free_irqs()
4595 scsi_qla_host_t *vha = pci_get_drvdata(ha->pdev); in qla25xx_request_irq()
4598 scnprintf(msix->name, sizeof(msix->name), in qla25xx_request_irq()
4599 "qla2xxx%lu_qpair%d", vha->host_no, qpair->id); in qla25xx_request_irq()
4600 ret = request_irq(msix->vector, intr->handler, 0, msix->name, qpair); in qla25xx_request_irq()
4603 "MSI-X: Unable to register handler -- %x/%d.\n", in qla25xx_request_irq()
4604 msix->vector, ret); in qla25xx_request_irq()
4607 msix->have_irq = 1; in qla25xx_request_irq()
4608 msix->handle = qpair; in qla25xx_request_irq()