Lines Matching +full:dsd +full:- +full:path
1 // SPDX-License-Identifier: GPL-2.0-only
7 * Copyright (C) 2004 - 2010 Vladislav Bolkhovitin <vst@vlnb.net>
8 * Copyright (C) 2004 - 2005 Leonid Stoljar
10 * Copyright (C) 2006 - 2010 ID7 Ltd.
14 * Copyright (C) 2010-2013 Nicholas A. Bellinger <nab@kernel.org>
37 "Enables Sequence level error recovery (aka FC Tape). Default is 0 - no SLER. 1 - Enable SLER.");
43 "\"exclusive\" - initiator mode will be enabled on load, "
46 "\"disabled\" - initiator mode will never be enabled; "
47 "\"dual\" - Initiator Modes will be enabled. Target Mode can be activated "
49 "\"enabled\" (default) - initiator mode will always stay enabled.");
93 * - Either context is IRQ and only IRQ handler can modify HW data,
96 * - Or access to target mode variables from struct qla_tgt doesn't
157 scsi_qla_host_t *base_vha = pci_get_drvdata(vha->hw->pdev); in qlt_do_generation_tick()
158 *dest = atomic_inc_return(&base_vha->generation_tick); in qlt_do_generation_tick()
167 if (unlikely(vha->marker_needed != 0)) { in qlt_issue_marker()
173 vha->vp_idx); in qlt_issue_marker()
186 if (vha->d_id.b.area == d_id.area && in qla_find_host_by_d_id()
187 vha->d_id.b.domain == d_id.domain && in qla_find_host_by_d_id()
188 vha->d_id.b.al_pa == d_id.al_pa) in qla_find_host_by_d_id()
193 host = btree_lookup32(&vha->hw->host_map, key); in qla_find_host_by_d_id()
205 spin_lock_irqsave(&vha->hw->tgt.q_full_lock, flags); in qlt_incr_num_pend_cmds()
207 vha->hw->tgt.num_pend_cmds++; in qlt_incr_num_pend_cmds()
208 if (vha->hw->tgt.num_pend_cmds > vha->qla_stats.stat_max_pend_cmds) in qlt_incr_num_pend_cmds()
209 vha->qla_stats.stat_max_pend_cmds = in qlt_incr_num_pend_cmds()
210 vha->hw->tgt.num_pend_cmds; in qlt_incr_num_pend_cmds()
211 spin_unlock_irqrestore(&vha->hw->tgt.q_full_lock, flags); in qlt_incr_num_pend_cmds()
217 spin_lock_irqsave(&vha->hw->tgt.q_full_lock, flags); in qlt_decr_num_pend_cmds()
218 vha->hw->tgt.num_pend_cmds--; in qlt_decr_num_pend_cmds()
219 spin_unlock_irqrestore(&vha->hw->tgt.q_full_lock, flags); in qlt_decr_num_pend_cmds()
227 struct qla_tgt *tgt = vha->vha_tgt.qla_tgt; in qlt_queue_unknown_atio()
230 if (tgt->tgt_stop) { in qlt_queue_unknown_atio()
233 vha->vp_idx); in qlt_queue_unknown_atio()
241 u->vha = vha; in qlt_queue_unknown_atio()
242 memcpy(&u->atio, atio, sizeof(*atio)); in qlt_queue_unknown_atio()
243 INIT_LIST_HEAD(&u->cmd_list); in qlt_queue_unknown_atio()
245 spin_lock_irqsave(&vha->cmd_list_lock, flags); in qlt_queue_unknown_atio()
246 list_add_tail(&u->cmd_list, &vha->unknown_atio_list); in qlt_queue_unknown_atio()
247 spin_unlock_irqrestore(&vha->cmd_list_lock, flags); in qlt_queue_unknown_atio()
249 schedule_delayed_work(&vha->unknown_atio_work, 1); in qlt_queue_unknown_atio()
255 qlt_send_term_exchange(vha->hw->base_qpair, NULL, atio, ha_locked, 0); in qlt_queue_unknown_atio()
264 struct qla_tgt *tgt = vha->vha_tgt.qla_tgt; in qlt_try_to_dequeue_unknown_atios()
268 list_for_each_entry_safe(u, t, &vha->unknown_atio_list, cmd_list) { in qlt_try_to_dequeue_unknown_atios()
269 if (u->aborted) { in qlt_try_to_dequeue_unknown_atios()
273 qlt_send_term_exchange(vha->hw->base_qpair, NULL, in qlt_try_to_dequeue_unknown_atios()
274 &u->atio, ha_locked, 0); in qlt_try_to_dequeue_unknown_atios()
278 host = qla_find_host_by_d_id(vha, u->atio.u.isp24.fcp_hdr.d_id); in qlt_try_to_dequeue_unknown_atios()
282 qlt_24xx_atio_pkt(host, &u->atio, ha_locked); in qlt_try_to_dequeue_unknown_atios()
283 } else if (tgt->tgt_stop) { in qlt_try_to_dequeue_unknown_atios()
287 qlt_send_term_exchange(vha->hw->base_qpair, NULL, in qlt_try_to_dequeue_unknown_atios()
288 &u->atio, ha_locked, 0); in qlt_try_to_dequeue_unknown_atios()
294 schedule_delayed_work(&vha->unknown_atio_work, in qlt_try_to_dequeue_unknown_atios()
301 spin_lock_irqsave(&vha->cmd_list_lock, flags); in qlt_try_to_dequeue_unknown_atios()
302 list_del(&u->cmd_list); in qlt_try_to_dequeue_unknown_atios()
303 spin_unlock_irqrestore(&vha->cmd_list_lock, flags); in qlt_try_to_dequeue_unknown_atios()
321 __func__, vha->vp_idx, atio->u.raw.entry_type, in qlt_24xx_atio_pkt_all_vps()
322 be16_to_cpu(atio->u.isp24.fcp_hdr.ox_id)); in qlt_24xx_atio_pkt_all_vps()
324 switch (atio->u.raw.entry_type) { in qlt_24xx_atio_pkt_all_vps()
328 atio->u.isp24.fcp_hdr.d_id); in qlt_24xx_atio_pkt_all_vps()
332 "with unknown d_id %x:%x:%x\n", vha->vp_idx, in qlt_24xx_atio_pkt_all_vps()
333 atio->u.isp24.fcp_hdr.d_id.domain, in qlt_24xx_atio_pkt_all_vps()
334 atio->u.isp24.fcp_hdr.d_id.area, in qlt_24xx_atio_pkt_all_vps()
335 atio->u.isp24.fcp_hdr.d_id.al_pa); in qlt_24xx_atio_pkt_all_vps()
341 if (unlikely(!list_empty(&vha->unknown_atio_list))) in qlt_24xx_atio_pkt_all_vps()
356 if ((entry->u.isp24.vp_index != 0xFF) && in qlt_24xx_atio_pkt_all_vps()
357 (entry->u.isp24.nport_handle != cpu_to_le16(0xFFFF))) { in qlt_24xx_atio_pkt_all_vps()
359 entry->u.isp24.vp_index); in qlt_24xx_atio_pkt_all_vps()
365 vha->vp_idx, entry->u.isp24.vp_index); in qlt_24xx_atio_pkt_all_vps()
383 entry->vp_index); in qlt_24xx_atio_pkt_all_vps()
390 vha->vp_idx, entry->vp_index); in qlt_24xx_atio_pkt_all_vps()
394 spin_lock_irqsave(&host->hw->hardware_lock, flags); in qlt_24xx_atio_pkt_all_vps()
397 spin_unlock_irqrestore(&host->hw->hardware_lock, flags); in qlt_24xx_atio_pkt_all_vps()
406 "type %x\n", vha->vp_idx, atio->u.raw.entry_type); in qlt_24xx_atio_pkt_all_vps()
416 switch (pkt->entry_type) { in qlt_response_pkt_all_vps()
420 vha->vp_idx, __func__); in qlt_response_pkt_all_vps()
426 entry->vp_index); in qlt_response_pkt_all_vps()
431 vha->vp_idx, entry->vp_index); in qlt_response_pkt_all_vps()
444 host = qla_find_host_by_vp_idx(vha, entry->u.isp24.vp_index); in qlt_response_pkt_all_vps()
449 vha->vp_idx, entry->u.isp24.vp_index); in qlt_response_pkt_all_vps()
461 if (0xFF != entry->u.isp24.vp_index) { in qlt_response_pkt_all_vps()
463 entry->u.isp24.vp_index); in qlt_response_pkt_all_vps()
469 "vp_index %d\n", vha->vp_idx, in qlt_response_pkt_all_vps()
470 entry->u.isp24.vp_index); in qlt_response_pkt_all_vps()
483 entry->vp_index); in qlt_response_pkt_all_vps()
488 "vp_index %d\n", vha->vp_idx, entry->vp_index); in qlt_response_pkt_all_vps()
500 entry->vp_index); in qlt_response_pkt_all_vps()
505 "vp_index %d\n", vha->vp_idx, entry->vp_index); in qlt_response_pkt_all_vps()
530 e->u.nack.fcport = fcport; in qla24xx_post_nack_work()
531 e->u.nack.type = type; in qla24xx_post_nack_work()
532 memcpy(e->u.nack.iocb, ntfy, sizeof(struct imm_ntfy_from_isp)); in qla24xx_post_nack_work()
538 struct scsi_qla_host *vha = sp->vha; in qla2x00_async_nack_sp_done()
542 "Async done-%s res %x %8phC type %d\n", in qla2x00_async_nack_sp_done()
543 sp->name, res, sp->fcport->port_name, sp->type); in qla2x00_async_nack_sp_done()
545 spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); in qla2x00_async_nack_sp_done()
546 sp->fcport->flags &= ~FCF_ASYNC_SENT; in qla2x00_async_nack_sp_done()
547 sp->fcport->chip_reset = vha->hw->base_qpair->chip_reset; in qla2x00_async_nack_sp_done()
549 switch (sp->type) { in qla2x00_async_nack_sp_done()
551 sp->fcport->login_gen++; in qla2x00_async_nack_sp_done()
552 sp->fcport->fw_login_state = DSC_LS_PLOGI_COMP; in qla2x00_async_nack_sp_done()
553 sp->fcport->logout_on_delete = 1; in qla2x00_async_nack_sp_done()
554 sp->fcport->plogi_nack_done_deadline = jiffies + HZ; in qla2x00_async_nack_sp_done()
555 sp->fcport->send_els_logo = 0; in qla2x00_async_nack_sp_done()
557 if (sp->fcport->flags & FCF_FCSP_DEVICE) { in qla2x00_async_nack_sp_done()
559 "%s %8phC edif: PLOGI- AUTH WAIT\n", __func__, in qla2x00_async_nack_sp_done()
560 sp->fcport->port_name); in qla2x00_async_nack_sp_done()
561 qla2x00_set_fcport_disc_state(sp->fcport, in qla2x00_async_nack_sp_done()
564 sp->fcport->d_id.b24); in qla2x00_async_nack_sp_done()
565 qla_edb_eventcreate(vha, VND_CMD_AUTH_STATE_NEEDED, sp->fcport->d_id.b24, in qla2x00_async_nack_sp_done()
566 0, sp->fcport); in qla2x00_async_nack_sp_done()
571 sp->fcport->fw_login_state = DSC_LS_PRLI_COMP; in qla2x00_async_nack_sp_done()
572 sp->fcport->deleted = 0; in qla2x00_async_nack_sp_done()
573 sp->fcport->send_els_logo = 0; in qla2x00_async_nack_sp_done()
575 if (!sp->fcport->login_succ && in qla2x00_async_nack_sp_done()
576 !IS_SW_RESV_ADDR(sp->fcport->d_id)) { in qla2x00_async_nack_sp_done()
577 sp->fcport->login_succ = 1; in qla2x00_async_nack_sp_done()
579 vha->fcport_count++; in qla2x00_async_nack_sp_done()
580 spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); in qla2x00_async_nack_sp_done()
581 qla24xx_sched_upd_fcport(sp->fcport); in qla2x00_async_nack_sp_done()
582 spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); in qla2x00_async_nack_sp_done()
584 sp->fcport->login_retry = 0; in qla2x00_async_nack_sp_done()
585 qla2x00_set_fcport_disc_state(sp->fcport, in qla2x00_async_nack_sp_done()
587 sp->fcport->deleted = 0; in qla2x00_async_nack_sp_done()
588 sp->fcport->logout_on_delete = 1; in qla2x00_async_nack_sp_done()
593 sp->fcport->login_gen++; in qla2x00_async_nack_sp_done()
594 sp->fcport->fw_login_state = DSC_LS_PORT_UNAVAIL; in qla2x00_async_nack_sp_done()
595 qlt_logo_completion_handler(sp->fcport, MBS_COMMAND_COMPLETE); in qla2x00_async_nack_sp_done()
598 spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); in qla2x00_async_nack_sp_done()
600 kref_put(&sp->cmd_kref, qla2x00_sp_release); in qla2x00_async_nack_sp_done()
610 fcport->flags |= FCF_ASYNC_SENT; in qla24xx_async_notify_ack()
613 fcport->fw_login_state = DSC_LS_PLOGI_PEND; in qla24xx_async_notify_ack()
615 if (vha->hw->flags.edif_enabled && in qla24xx_async_notify_ack()
616 (le16_to_cpu(ntfy->u.isp24.flags) & NOTIFY24XX_FLAGS_FCSP)) in qla24xx_async_notify_ack()
617 fcport->flags |= FCF_FCSP_DEVICE; in qla24xx_async_notify_ack()
620 fcport->fw_login_state = DSC_LS_PRLI_PEND; in qla24xx_async_notify_ack()
621 fcport->deleted = 0; in qla24xx_async_notify_ack()
625 fcport->fw_login_state = DSC_LS_LOGO_PEND; in qla24xx_async_notify_ack()
634 sp->type = type; in qla24xx_async_notify_ack()
635 sp->name = "nack"; in qla24xx_async_notify_ack()
639 sp->u.iocb_cmd.u.nack.ntfy = ntfy; in qla24xx_async_notify_ack()
642 "Async-%s %8phC hndl %x %s\n", in qla24xx_async_notify_ack()
643 sp->name, fcport->port_name, sp->handle, c); in qla24xx_async_notify_ack()
652 kref_put(&sp->cmd_kref, qla2x00_sp_release); in qla24xx_async_notify_ack()
654 fcport->flags &= ~FCF_ASYNC_SENT; in qla24xx_async_notify_ack()
662 switch (e->u.nack.type) { in qla24xx_do_nack_work()
664 t = e->u.nack.fcport; in qla24xx_do_nack_work()
665 flush_work(&t->del_work); in qla24xx_do_nack_work()
666 flush_work(&t->free_work); in qla24xx_do_nack_work()
667 mutex_lock(&vha->vha_tgt.tgt_mutex); in qla24xx_do_nack_work()
668 t = qlt_create_sess(vha, e->u.nack.fcport, 0); in qla24xx_do_nack_work()
669 mutex_unlock(&vha->vha_tgt.tgt_mutex); in qla24xx_do_nack_work()
674 vha->hw->tgt.tgt_ops->put_sess(e->u.nack.fcport); in qla24xx_do_nack_work()
678 qla24xx_async_notify_ack(vha, e->u.nack.fcport, in qla24xx_do_nack_work()
679 (struct imm_ntfy_from_isp *)e->u.nack.iocb, e->u.nack.type); in qla24xx_do_nack_work()
687 if (!fcport || !fcport->vha || !fcport->vha->hw) in qla24xx_delete_sess_fn()
690 ha = fcport->vha->hw; in qla24xx_delete_sess_fn()
692 if (fcport->se_sess) { in qla24xx_delete_sess_fn()
693 ha->tgt.tgt_ops->shutdown_sess(fcport); in qla24xx_delete_sess_fn()
694 ha->tgt.tgt_ops->put_sess(fcport); in qla24xx_delete_sess_fn()
705 struct qla_hw_data *ha = vha->hw; in qlt_fc_port_added()
706 struct qla_tgt *tgt = vha->vha_tgt.qla_tgt; in qlt_fc_port_added()
710 if (!vha->hw->tgt.tgt_ops) in qlt_fc_port_added()
713 spin_lock_irqsave(&ha->tgt.sess_lock, flags); in qlt_fc_port_added()
714 if (tgt->tgt_stop) { in qlt_fc_port_added()
715 spin_unlock_irqrestore(&ha->tgt.sess_lock, flags); in qlt_fc_port_added()
719 if (fcport->disc_state == DSC_DELETE_PEND) { in qlt_fc_port_added()
720 spin_unlock_irqrestore(&ha->tgt.sess_lock, flags); in qlt_fc_port_added()
724 if (!sess->se_sess) { in qlt_fc_port_added()
725 spin_unlock_irqrestore(&ha->tgt.sess_lock, flags); in qlt_fc_port_added()
727 mutex_lock(&vha->vha_tgt.tgt_mutex); in qlt_fc_port_added()
729 mutex_unlock(&vha->vha_tgt.tgt_mutex); in qlt_fc_port_added()
731 spin_lock_irqsave(&ha->tgt.sess_lock, flags); in qlt_fc_port_added()
733 if (fcport->fw_login_state == DSC_LS_PRLI_COMP) { in qlt_fc_port_added()
734 spin_unlock_irqrestore(&ha->tgt.sess_lock, flags); in qlt_fc_port_added()
738 if (!kref_get_unless_zero(&sess->sess_kref)) { in qlt_fc_port_added()
741 __func__, sess->port_name); in qlt_fc_port_added()
742 spin_unlock_irqrestore(&ha->tgt.sess_lock, flags); in qlt_fc_port_added()
748 "(loop ID %d) reappeared\n", vha->vp_idx, in qlt_fc_port_added()
749 sess->local ? "local " : "", sess->port_name, sess->loop_id); in qlt_fc_port_added()
754 ha->tgt.tgt_ops->update_sess(sess, fcport->d_id, in qlt_fc_port_added()
755 fcport->loop_id, in qlt_fc_port_added()
756 (fcport->flags & FCF_CONF_COMP_SUPPORTED)); in qlt_fc_port_added()
759 if (sess && sess->local) { in qlt_fc_port_added()
762 "port %8phC (loop ID %d) became global\n", vha->vp_idx, in qlt_fc_port_added()
763 fcport->port_name, sess->loop_id); in qlt_fc_port_added()
764 sess->local = 0; in qlt_fc_port_added()
766 spin_unlock_irqrestore(&ha->tgt.sess_lock, flags); in qlt_fc_port_added()
768 ha->tgt.tgt_ops->put_sess(sess); in qlt_fc_port_added()
772 * This is a zero-base ref-counting solution, since hardware_lock
782 lockdep_assert_held(&vha->hw->hardware_lock); in qlt_plogi_ack_find_add()
784 list_for_each_entry(pla, &vha->plogi_ack_list, list) { in qlt_plogi_ack_find_add()
785 if (pla->id.b24 == id->b24) { in qlt_plogi_ack_find_add()
789 pla->iocb.u.isp24.port_name); in qlt_plogi_ack_find_add()
790 qlt_send_term_imm_notif(vha, &pla->iocb, 1); in qlt_plogi_ack_find_add()
791 memcpy(&pla->iocb, iocb, sizeof(pla->iocb)); in qlt_plogi_ack_find_add()
800 vha->vp_idx); in qlt_plogi_ack_find_add()
804 memcpy(&pla->iocb, iocb, sizeof(pla->iocb)); in qlt_plogi_ack_find_add()
805 pla->id = *id; in qlt_plogi_ack_find_add()
806 list_add_tail(&pla->list, &vha->plogi_ack_list); in qlt_plogi_ack_find_add()
814 struct imm_ntfy_from_isp *iocb = &pla->iocb; in qlt_plogi_ack_unref()
817 fc_port_t *fcport = pla->fcport; in qlt_plogi_ack_unref()
819 BUG_ON(!pla->ref_count); in qlt_plogi_ack_unref()
820 pla->ref_count--; in qlt_plogi_ack_unref()
822 if (pla->ref_count) in qlt_plogi_ack_unref()
827 " exch %#x ox_id %#x\n", iocb->u.isp24.port_name, in qlt_plogi_ack_unref()
828 iocb->u.isp24.port_id[2], iocb->u.isp24.port_id[1], in qlt_plogi_ack_unref()
829 iocb->u.isp24.port_id[0], in qlt_plogi_ack_unref()
830 le16_to_cpu(iocb->u.isp24.nport_handle), in qlt_plogi_ack_unref()
831 iocb->u.isp24.exchange_address, iocb->ox_id); in qlt_plogi_ack_unref()
833 port_id.b.domain = iocb->u.isp24.port_id[2]; in qlt_plogi_ack_unref()
834 port_id.b.area = iocb->u.isp24.port_id[1]; in qlt_plogi_ack_unref()
835 port_id.b.al_pa = iocb->u.isp24.port_id[0]; in qlt_plogi_ack_unref()
838 loop_id = le16_to_cpu(iocb->u.isp24.nport_handle); in qlt_plogi_ack_unref()
840 fcport->loop_id = loop_id; in qlt_plogi_ack_unref()
841 fcport->d_id = port_id; in qlt_plogi_ack_unref()
842 if (iocb->u.isp24.status_subcode == ELS_PLOGI) in qlt_plogi_ack_unref()
847 list_for_each_entry(fcport, &vha->vp_fcports, list) { in qlt_plogi_ack_unref()
848 if (fcport->plogi_link[QLT_PLOGI_LINK_SAME_WWN] == pla) in qlt_plogi_ack_unref()
849 fcport->plogi_link[QLT_PLOGI_LINK_SAME_WWN] = NULL; in qlt_plogi_ack_unref()
850 if (fcport->plogi_link[QLT_PLOGI_LINK_CONFLICT] == pla) in qlt_plogi_ack_unref()
851 fcport->plogi_link[QLT_PLOGI_LINK_CONFLICT] = NULL; in qlt_plogi_ack_unref()
854 list_del(&pla->list); in qlt_plogi_ack_unref()
862 struct imm_ntfy_from_isp *iocb = &pla->iocb; in qlt_plogi_ack_link()
864 pla->ref_count++; in qlt_plogi_ack_link()
869 sess, link, sess->port_name, in qlt_plogi_ack_link()
870 iocb->u.isp24.port_name, iocb->u.isp24.port_id[2], in qlt_plogi_ack_link()
871 iocb->u.isp24.port_id[1], iocb->u.isp24.port_id[0], in qlt_plogi_ack_link()
872 pla->ref_count, pla, link); in qlt_plogi_ack_link()
875 switch (sess->disc_state) { in qlt_plogi_ack_link()
878 pla->ref_count--; in qlt_plogi_ack_link()
885 if (sess->plogi_link[link]) in qlt_plogi_ack_link()
886 qlt_plogi_ack_unref(vha, sess->plogi_link[link]); in qlt_plogi_ack_link()
889 pla->fcport = sess; in qlt_plogi_ack_link()
891 sess->plogi_link[link] = pla; in qlt_plogi_ack_link()
914 if (test_bit(PFLG_DRIVER_REMOVING, &vha->pci_flags)) { in qlt_send_first_logo()
919 mutex_lock(&vha->vha_tgt.tgt_mutex); in qlt_send_first_logo()
921 list_for_each_entry(tmp, &vha->logo_list, list) { in qlt_send_first_logo()
922 if (tmp->id.b24 == logo->id.b24) { in qlt_send_first_logo()
923 tmp->cmd_count += logo->cmd_count; in qlt_send_first_logo()
924 mutex_unlock(&vha->vha_tgt.tgt_mutex); in qlt_send_first_logo()
929 list_add_tail(&logo->list, &vha->logo_list); in qlt_send_first_logo()
931 mutex_unlock(&vha->vha_tgt.tgt_mutex); in qlt_send_first_logo()
933 res = qla24xx_els_dcmd_iocb(vha, ELS_DCMD_LOGO, logo->id); in qlt_send_first_logo()
935 mutex_lock(&vha->vha_tgt.tgt_mutex); in qlt_send_first_logo()
936 list_del(&logo->list); in qlt_send_first_logo()
937 mutex_unlock(&vha->vha_tgt.tgt_mutex); in qlt_send_first_logo()
942 logo->id.b.domain, logo->id.b.area, logo->id.b.al_pa, in qlt_send_first_logo()
943 logo->cmd_count, res); in qlt_send_first_logo()
950 struct qla_tgt *tgt = sess->tgt; in qlt_free_session_done()
951 struct scsi_qla_host *vha = sess->vha; in qlt_free_session_done()
952 struct qla_hw_data *ha = vha->hw; in qlt_free_session_done()
955 scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); in qlt_free_session_done()
957 sess->plogi_link[QLT_PLOGI_LINK_SAME_WWN]; in qlt_free_session_done()
962 __func__, sess->se_sess, sess, sess->port_name, sess->loop_id, in qlt_free_session_done()
963 sess->d_id.b.domain, sess->d_id.b.area, sess->d_id.b.al_pa, in qlt_free_session_done()
964 sess->logout_on_delete, sess->keep_nport_handle, in qlt_free_session_done()
965 sess->send_els_logo); in qlt_free_session_done()
967 if (!IS_SW_RESV_ADDR(sess->d_id)) { in qlt_free_session_done()
970 if (sess->send_els_logo) { in qlt_free_session_done()
973 logo.id = sess->d_id; in qlt_free_session_done()
978 sess->send_els_logo = 0; in qlt_free_session_done()
981 if (sess->logout_on_delete && sess->loop_id != FC_NO_LOOP_ID) { in qlt_free_session_done()
985 (own->iocb.u.isp24.status_subcode == ELS_PLOGI)) { in qlt_free_session_done()
986 sess->logout_completed = 0; in qlt_free_session_done()
995 } else if (own && (own->iocb.u.isp24.status_subcode == in qlt_free_session_done()
996 ELS_PRLI) && ha->flags.rida_fmt2) { in qlt_free_session_done()
1006 } /* if sess->logout_on_delete */ in qlt_free_session_done()
1008 if (sess->nvme_flag & NVME_FLAG_REGISTERED && in qlt_free_session_done()
1009 !(sess->nvme_flag & NVME_FLAG_DELETING)) { in qlt_free_session_done()
1010 sess->nvme_flag |= NVME_FLAG_DELETING; in qlt_free_session_done()
1014 if (ha->flags.edif_enabled && in qlt_free_session_done()
1015 (!own || own->iocb.u.isp24.status_subcode == ELS_PLOGI)) { in qlt_free_session_done()
1016 sess->edif.authok = 0; in qlt_free_session_done()
1017 if (!ha->flags.host_shutting_down) { in qlt_free_session_done()
1020 __func__, sess->port_name); in qlt_free_session_done()
1036 if (sess->se_sess != NULL) in qlt_free_session_done()
1037 ha->tgt.tgt_ops->free_session(sess); in qlt_free_session_done()
1043 while (!READ_ONCE(sess->logout_completed)) { in qlt_free_session_done()
1054 * long enough for log-out to complete before advancing. Otherwise, in qlt_free_session_done()
1055 * straddling logout can interfere with re-login attempt. in qlt_free_session_done()
1066 if (!(sess->flags & FCF_FCP2_DEVICE) && in qlt_free_session_done()
1067 qla2x00_eh_wait_for_pending_commands(sess->vha, sess->d_id.b24, 0, WAIT_TARGET)) { in qlt_free_session_done()
1070 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); in qlt_free_session_done()
1075 if (sess->logo_ack_needed) { in qlt_free_session_done()
1076 sess->logo_ack_needed = 0; in qlt_free_session_done()
1078 (struct imm_ntfy_from_isp *)sess->iocb, SRB_NACK_LOGO); in qlt_free_session_done()
1081 spin_lock_irqsave(&ha->tgt.sess_lock, flags); in qlt_free_session_done()
1082 if (sess->se_sess) { in qlt_free_session_done()
1083 sess->se_sess = NULL; in qlt_free_session_done()
1084 if (tgt && !IS_SW_RESV_ADDR(sess->d_id)) in qlt_free_session_done()
1085 tgt->sess_count--; in qlt_free_session_done()
1089 sess->fw_login_state = DSC_LS_PORT_UNAVAIL; in qlt_free_session_done()
1091 if (sess->login_succ && !IS_SW_RESV_ADDR(sess->d_id)) { in qlt_free_session_done()
1092 vha->fcport_count--; in qlt_free_session_done()
1093 sess->login_succ = 0; in qlt_free_session_done()
1098 if (sess->conflict) { in qlt_free_session_done()
1099 sess->conflict->login_pause = 0; in qlt_free_session_done()
1100 sess->conflict = NULL; in qlt_free_session_done()
1101 if (!test_bit(UNLOADING, &vha->dpc_flags)) in qlt_free_session_done()
1102 set_bit(RELOGIN_NEEDED, &vha->dpc_flags); in qlt_free_session_done()
1107 sess->plogi_link[QLT_PLOGI_LINK_CONFLICT]; in qlt_free_session_done()
1110 own = sess->plogi_link[QLT_PLOGI_LINK_SAME_WWN]; in qlt_free_session_done()
1113 iocb = &con->iocb; in qlt_free_session_done()
1117 sess->se_sess, sess, sess->port_name, in qlt_free_session_done()
1119 own ? own->ref_count : -1, in qlt_free_session_done()
1120 iocb->u.isp24.port_name, con->ref_count); in qlt_free_session_done()
1122 sess->plogi_link[QLT_PLOGI_LINK_CONFLICT] = NULL; in qlt_free_session_done()
1126 sess->se_sess, sess, sess->port_name, in qlt_free_session_done()
1129 own ? own->ref_count : -1); in qlt_free_session_done()
1133 sess->fw_login_state = DSC_LS_PLOGI_PEND; in qlt_free_session_done()
1135 sess->plogi_link[QLT_PLOGI_LINK_SAME_WWN] = NULL; in qlt_free_session_done()
1139 sess->explicit_logout = 0; in qlt_free_session_done()
1140 spin_unlock_irqrestore(&ha->tgt.sess_lock, flags); in qlt_free_session_done()
1144 spin_lock_irqsave(&vha->work_lock, flags); in qlt_free_session_done()
1145 sess->flags &= ~FCF_ASYNC_SENT; in qlt_free_session_done()
1146 sess->deleted = QLA_SESS_DELETED; in qlt_free_session_done()
1147 sess->free_pending = 0; in qlt_free_session_done()
1148 spin_unlock_irqrestore(&vha->work_lock, flags); in qlt_free_session_done()
1152 sess, sess->port_name, vha->fcport_count); in qlt_free_session_done()
1154 if (tgt && (tgt->sess_count == 0)) in qlt_free_session_done()
1155 wake_up_all(&tgt->waitQ); in qlt_free_session_done()
1157 if (!test_bit(PFLG_DRIVER_REMOVING, &base_vha->pci_flags) && in qlt_free_session_done()
1158 !(vha->vp_idx && test_bit(VPORT_DELETE, &vha->dpc_flags)) && in qlt_free_session_done()
1159 (!tgt || !tgt->tgt_stop) && !LOOP_TRANSITION(vha)) { in qlt_free_session_done()
1160 switch (vha->host->active_mode) { in qlt_free_session_done()
1163 set_bit(RELOGIN_NEEDED, &vha->dpc_flags); in qlt_free_session_done()
1168 /* no-op */ in qlt_free_session_done()
1173 if (vha->fcport_count == 0) in qlt_free_session_done()
1174 wake_up_all(&vha->fcport_waitQ); in qlt_free_session_done()
1177 /* ha->tgt.sess_lock supposed to be held on entry */
1180 struct scsi_qla_host *vha = sess->vha; in qlt_unreg_sess()
1183 ql_dbg(ql_dbg_disc, sess->vha, 0x210a, in qlt_unreg_sess()
1185 __func__, sess, sess->port_name); in qlt_unreg_sess()
1187 spin_lock_irqsave(&sess->vha->work_lock, flags); in qlt_unreg_sess()
1188 if (sess->free_pending) { in qlt_unreg_sess()
1189 spin_unlock_irqrestore(&sess->vha->work_lock, flags); in qlt_unreg_sess()
1192 sess->free_pending = 1; in qlt_unreg_sess()
1197 sess->flags |= FCF_ASYNC_SENT; in qlt_unreg_sess()
1198 sess->deleted = QLA_SESS_DELETION_IN_PROGRESS; in qlt_unreg_sess()
1199 spin_unlock_irqrestore(&sess->vha->work_lock, flags); in qlt_unreg_sess()
1201 if (sess->se_sess) in qlt_unreg_sess()
1202 vha->hw->tgt.tgt_ops->clear_nacl_from_fcport_map(sess); in qlt_unreg_sess()
1205 sess->last_rscn_gen = sess->rscn_gen; in qlt_unreg_sess()
1206 sess->last_login_gen = sess->login_gen; in qlt_unreg_sess()
1208 queue_work(sess->vha->hw->wq, &sess->free_work); in qlt_unreg_sess()
1214 struct qla_hw_data *ha = vha->hw; in qlt_reset()
1221 loop_id = le16_to_cpu(n->u.isp24.nport_handle); in qlt_reset()
1224 atomic_inc(&vha->vha_tgt.qla_tgt->tgt_global_resets_count); in qlt_reset()
1225 spin_lock_irqsave(&ha->tgt.sess_lock, flags); in qlt_reset()
1226 qlt_clear_tgt_db(vha->vha_tgt.qla_tgt); in qlt_reset()
1227 spin_unlock_irqrestore(&ha->tgt.sess_lock, flags); in qlt_reset()
1229 spin_lock_irqsave(&ha->tgt.sess_lock, flags); in qlt_reset()
1230 sess = ha->tgt.tgt_ops->find_sess_by_loop_id(vha, loop_id); in qlt_reset()
1231 spin_unlock_irqrestore(&ha->tgt.sess_lock, flags); in qlt_reset()
1237 res = -ESRCH; in qlt_reset()
1243 "loop_id %d)\n", vha->host_no, sess, sess->port_name, in qlt_reset()
1251 if (sess->chip_reset != sess->vha->hw->base_qpair->chip_reset) { in qla24xx_chk_fcp_state()
1252 sess->logout_on_delete = 0; in qla24xx_chk_fcp_state()
1253 sess->logo_ack_needed = 0; in qla24xx_chk_fcp_state()
1254 sess->fw_login_state = DSC_LS_PORT_UNAVAIL; in qla24xx_chk_fcp_state()
1260 struct qla_tgt *tgt = sess->tgt; in qlt_schedule_sess_for_deletion()
1264 switch (sess->disc_state) { in qlt_schedule_sess_for_deletion()
1268 if (!sess->plogi_link[QLT_PLOGI_LINK_SAME_WWN] && in qlt_schedule_sess_for_deletion()
1269 !sess->plogi_link[QLT_PLOGI_LINK_CONFLICT]) { in qlt_schedule_sess_for_deletion()
1270 if (tgt && tgt->tgt_stop && tgt->sess_count == 0) in qlt_schedule_sess_for_deletion()
1271 wake_up_all(&tgt->waitQ); in qlt_schedule_sess_for_deletion()
1273 if (sess->vha->fcport_count == 0) in qlt_schedule_sess_for_deletion()
1274 wake_up_all(&sess->vha->fcport_waitQ); in qlt_schedule_sess_for_deletion()
1283 sess->next_disc_state = DSC_DELETE_PEND; in qlt_schedule_sess_for_deletion()
1284 sec = jiffies_to_msecs(jiffies - in qlt_schedule_sess_for_deletion()
1285 sess->jiffies_at_registration)/1000; in qlt_schedule_sess_for_deletion()
1286 if (sess->sec_since_registration < sec && sec && !(sec % 5)) { in qlt_schedule_sess_for_deletion()
1287 sess->sec_since_registration = sec; in qlt_schedule_sess_for_deletion()
1288 ql_dbg(ql_dbg_disc, sess->vha, 0xffff, in qlt_schedule_sess_for_deletion()
1290 __func__, sess->port_name, sec); in qlt_schedule_sess_for_deletion()
1297 spin_lock_irqsave(&sess->vha->work_lock, flags); in qlt_schedule_sess_for_deletion()
1298 if (sess->deleted == QLA_SESS_DELETION_IN_PROGRESS) { in qlt_schedule_sess_for_deletion()
1299 spin_unlock_irqrestore(&sess->vha->work_lock, flags); in qlt_schedule_sess_for_deletion()
1302 sess->deleted = QLA_SESS_DELETION_IN_PROGRESS; in qlt_schedule_sess_for_deletion()
1303 spin_unlock_irqrestore(&sess->vha->work_lock, flags); in qlt_schedule_sess_for_deletion()
1305 sess->prli_pend_timer = 0; in qlt_schedule_sess_for_deletion()
1310 ql_dbg(ql_log_warn, sess->vha, 0xe001, in qlt_schedule_sess_for_deletion()
1312 sess, sess->port_name, sess->fc4_type); in qlt_schedule_sess_for_deletion()
1314 WARN_ON(!queue_work(sess->vha->hw->wq, &sess->del_work)); in qlt_schedule_sess_for_deletion()
1320 scsi_qla_host_t *vha = tgt->vha; in qlt_clear_tgt_db()
1322 list_for_each_entry(sess, &vha->vp_fcports, list) { in qlt_clear_tgt_db()
1323 if (sess->se_sess) in qlt_clear_tgt_db()
1333 struct qla_hw_data *ha = vha->hw; in qla24xx_get_loop_id()
1339 gid_list = dma_alloc_coherent(&ha->pdev->dev, qla2x00_gid_list_size(ha), in qla24xx_get_loop_id()
1344 vha->vp_idx, qla2x00_gid_list_size(ha)); in qla24xx_get_loop_id()
1345 return -ENOMEM; in qla24xx_get_loop_id()
1353 vha->vp_idx, rc); in qla24xx_get_loop_id()
1354 res = -EBUSY; in qla24xx_get_loop_id()
1359 res = -ENOENT; in qla24xx_get_loop_id()
1361 if (gid->al_pa == s_id.al_pa && in qla24xx_get_loop_id()
1362 gid->area == s_id.area && in qla24xx_get_loop_id()
1363 gid->domain == s_id.domain) { in qla24xx_get_loop_id()
1364 *loop_id = le16_to_cpu(gid->loop_id); in qla24xx_get_loop_id()
1368 gid = (void *)gid + ha->gid_list_info_size; in qla24xx_get_loop_id()
1372 dma_free_coherent(&ha->pdev->dev, qla2x00_gid_list_size(ha), in qla24xx_get_loop_id()
1386 struct qla_hw_data *ha = vha->hw; in qlt_create_sess()
1390 if (vha->vha_tgt.qla_tgt->tgt_stop) in qlt_create_sess()
1393 if (fcport->se_sess) { in qlt_create_sess()
1394 if (!kref_get_unless_zero(&sess->sess_kref)) { in qlt_create_sess()
1397 __func__, sess->port_name); in qlt_create_sess()
1402 sess->tgt = vha->vha_tgt.qla_tgt; in qlt_create_sess()
1403 sess->local = local; in qlt_create_sess()
1411 sess->logout_on_delete = 1; in qlt_create_sess()
1412 sess->keep_nport_handle = 0; in qlt_create_sess()
1413 sess->logout_completed = 0; in qlt_create_sess()
1415 if (ha->tgt.tgt_ops->check_initiator_node_acl(vha, in qlt_create_sess()
1416 &fcport->port_name[0], sess) < 0) { in qlt_create_sess()
1419 vha->vp_idx, fcport->port_name); in qlt_create_sess()
1422 kref_init(&fcport->sess_kref); in qlt_create_sess()
1424 * Take an extra reference to ->sess_kref here to handle in qlt_create_sess()
1425 * fc_port access across ->tgt.sess_lock reaquire. in qlt_create_sess()
1427 if (!kref_get_unless_zero(&sess->sess_kref)) { in qlt_create_sess()
1430 __func__, sess->port_name); in qlt_create_sess()
1434 spin_lock_irqsave(&ha->tgt.sess_lock, flags); in qlt_create_sess()
1435 if (!IS_SW_RESV_ADDR(sess->d_id)) in qlt_create_sess()
1436 vha->vha_tgt.qla_tgt->sess_count++; in qlt_create_sess()
1438 qlt_do_generation_tick(vha, &sess->generation); in qlt_create_sess()
1439 spin_unlock_irqrestore(&ha->tgt.sess_lock, flags); in qlt_create_sess()
1444 sess, sess->se_sess, vha->vha_tgt.qla_tgt, in qlt_create_sess()
1445 vha->vha_tgt.qla_tgt->sess_count); in qlt_create_sess()
1450 vha->vp_idx, local ? "local " : "", fcport->port_name, in qlt_create_sess()
1451 fcport->loop_id, sess->d_id.b.domain, sess->d_id.b.area, in qlt_create_sess()
1452 sess->d_id.b.al_pa, sess->conf_compl_supported ? "" : "not "); in qlt_create_sess()
1458 * max_gen - specifies maximum session generation
1464 struct qla_tgt *tgt = vha->vha_tgt.qla_tgt; in qlt_fc_port_deleted()
1468 if (!vha->hw->tgt.tgt_ops) in qlt_fc_port_deleted()
1474 spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); in qlt_fc_port_deleted()
1475 if (tgt->tgt_stop) { in qlt_fc_port_deleted()
1476 spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); in qlt_fc_port_deleted()
1479 if (!sess->se_sess) { in qlt_fc_port_deleted()
1480 spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); in qlt_fc_port_deleted()
1484 if (max_gen - sess->generation < 0) { in qlt_fc_port_deleted()
1485 spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); in qlt_fc_port_deleted()
1489 sess->se_sess, sess, sess->port_name, max_gen, in qlt_fc_port_deleted()
1490 sess->generation); in qlt_fc_port_deleted()
1496 sess->local = 1; in qlt_fc_port_deleted()
1497 spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); in qlt_fc_port_deleted()
1503 struct qla_hw_data *ha = tgt->ha; in test_tgt_sess_count()
1510 spin_lock_irqsave(&ha->tgt.sess_lock, flags); in test_tgt_sess_count()
1511 ql_dbg(ql_dbg_tgt, tgt->vha, 0xe002, in test_tgt_sess_count()
1513 tgt, tgt->sess_count); in test_tgt_sess_count()
1514 res = (tgt->sess_count == 0); in test_tgt_sess_count()
1515 spin_unlock_irqrestore(&ha->tgt.sess_lock, flags); in test_tgt_sess_count()
1523 struct scsi_qla_host *vha = tgt->vha; in qlt_stop_phase1()
1524 struct qla_hw_data *ha = tgt->ha; in qlt_stop_phase1()
1527 mutex_lock(&ha->optrom_mutex); in qlt_stop_phase1()
1530 if (tgt->tgt_stop || tgt->tgt_stopped) { in qlt_stop_phase1()
1532 "Already in tgt->tgt_stop or tgt_stopped state\n"); in qlt_stop_phase1()
1534 mutex_unlock(&ha->optrom_mutex); in qlt_stop_phase1()
1535 return -EPERM; in qlt_stop_phase1()
1539 vha->host_no, vha); in qlt_stop_phase1()
1544 mutex_lock(&vha->vha_tgt.tgt_mutex); in qlt_stop_phase1()
1545 tgt->tgt_stop = 1; in qlt_stop_phase1()
1547 mutex_unlock(&vha->vha_tgt.tgt_mutex); in qlt_stop_phase1()
1552 spin_lock_irqsave(&tgt->sess_work_lock, flags); in qlt_stop_phase1()
1554 spin_unlock_irqrestore(&tgt->sess_work_lock, flags); in qlt_stop_phase1()
1555 flush_work(&tgt->sess_work); in qlt_stop_phase1()
1556 spin_lock_irqsave(&tgt->sess_work_lock, flags); in qlt_stop_phase1()
1557 } while (!list_empty(&tgt->sess_works_list)); in qlt_stop_phase1()
1558 spin_unlock_irqrestore(&tgt->sess_work_lock, flags); in qlt_stop_phase1()
1561 "Waiting for tgt %p: sess_count=%d\n", tgt, tgt->sess_count); in qlt_stop_phase1()
1563 wait_event_timeout(tgt->waitQ, test_tgt_sess_count(tgt), 10*HZ); in qlt_stop_phase1()
1566 if (!ha->flags.host_shutting_down && in qlt_stop_phase1()
1571 wait_event_timeout(tgt->waitQ, test_tgt_sess_count(tgt), 10*HZ); in qlt_stop_phase1()
1572 mutex_unlock(&ha->optrom_mutex); in qlt_stop_phase1()
1581 scsi_qla_host_t *vha = tgt->vha; in qlt_stop_phase2()
1583 if (tgt->tgt_stopped) { in qlt_stop_phase2()
1585 "Already in tgt->tgt_stopped state\n"); in qlt_stop_phase2()
1589 if (!tgt->tgt_stop) { in qlt_stop_phase2()
1596 mutex_lock(&tgt->ha->optrom_mutex); in qlt_stop_phase2()
1597 mutex_lock(&vha->vha_tgt.tgt_mutex); in qlt_stop_phase2()
1598 tgt->tgt_stop = 0; in qlt_stop_phase2()
1599 tgt->tgt_stopped = 1; in qlt_stop_phase2()
1600 mutex_unlock(&vha->vha_tgt.tgt_mutex); in qlt_stop_phase2()
1601 mutex_unlock(&tgt->ha->optrom_mutex); in qlt_stop_phase2()
1606 switch (vha->qlini_mode) { in qlt_stop_phase2()
1608 vha->flags.online = 1; in qlt_stop_phase2()
1609 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); in qlt_stop_phase2()
1617 /* Called from qlt_remove_target() -> qla2x00_remove_one() */
1620 scsi_qla_host_t *vha = tgt->vha; in qlt_release()
1625 struct qla_hw_data *ha = vha->hw; in qlt_release()
1627 if (!tgt->tgt_stop && !tgt->tgt_stopped) in qlt_release()
1630 if (!tgt->tgt_stopped) in qlt_release()
1633 for (i = 0; i < vha->hw->max_qpairs + 1; i++) { in qlt_release()
1636 h = &tgt->qphints[i]; in qlt_release()
1637 if (h->qpair) { in qlt_release()
1638 spin_lock_irqsave(h->qpair->qp_lock_ptr, flags); in qlt_release()
1639 list_del(&h->hint_elem); in qlt_release()
1640 spin_unlock_irqrestore(h->qpair->qp_lock_ptr, flags); in qlt_release()
1641 h->qpair = NULL; in qlt_release()
1644 kfree(tgt->qphints); in qlt_release()
1646 list_del(&vha->vha_tgt.qla_tgt->tgt_list_entry); in qlt_release()
1649 btree_for_each_safe64(&tgt->lun_qpair_map, key, node) in qlt_release()
1650 btree_remove64(&tgt->lun_qpair_map, key); in qlt_release()
1652 btree_destroy64(&tgt->lun_qpair_map); in qlt_release()
1654 if (vha->vp_idx) in qlt_release()
1655 if (ha->tgt.tgt_ops && in qlt_release()
1656 ha->tgt.tgt_ops->remove_target && in qlt_release()
1657 vha->vha_tgt.target_lport_ptr) in qlt_release()
1658 ha->tgt.tgt_ops->remove_target(vha); in qlt_release()
1660 vha->vha_tgt.qla_tgt = NULL; in qlt_release()
1668 /* ha->hardware_lock supposed to be held on entry */
1677 ql_dbg(ql_dbg_tgt_mgt, tgt->vha, 0xf050, in qlt_sched_sess_work()
1680 return -ENOMEM; in qlt_sched_sess_work()
1683 ql_dbg(ql_dbg_tgt_mgt, tgt->vha, 0xf00e, in qlt_sched_sess_work()
1688 prm->type = type; in qlt_sched_sess_work()
1689 memcpy(&prm->tm_iocb, param, param_size); in qlt_sched_sess_work()
1691 spin_lock_irqsave(&tgt->sess_work_lock, flags); in qlt_sched_sess_work()
1692 list_add_tail(&prm->sess_works_list_entry, &tgt->sess_works_list); in qlt_sched_sess_work()
1693 spin_unlock_irqrestore(&tgt->sess_work_lock, flags); in qlt_sched_sess_work()
1695 schedule_work(&tgt->sess_work); in qlt_sched_sess_work()
1701 * ha->hardware_lock supposed to be held on entry. Might drop it, then reaquire
1708 struct scsi_qla_host *vha = qpair->vha; in qlt_send_notify_ack()
1709 struct qla_hw_data *ha = vha->hw; in qlt_send_notify_ack()
1713 if (!ha->flags.fw_started) in qlt_send_notify_ack()
1722 "request packet\n", vha->vp_idx, __func__); in qlt_send_notify_ack()
1726 if (vha->vha_tgt.qla_tgt != NULL) in qlt_send_notify_ack()
1727 vha->vha_tgt.qla_tgt->notify_ack_expected++; in qlt_send_notify_ack()
1729 pkt->entry_type = NOTIFY_ACK_TYPE; in qlt_send_notify_ack()
1730 pkt->entry_count = 1; in qlt_send_notify_ack()
1733 nack->ox_id = ntfy->ox_id; in qlt_send_notify_ack()
1735 nack->u.isp24.handle = QLA_TGT_SKIP_HANDLE; in qlt_send_notify_ack()
1736 nack->u.isp24.nport_handle = ntfy->u.isp24.nport_handle; in qlt_send_notify_ack()
1737 if (le16_to_cpu(ntfy->u.isp24.status) == IMM_NTFY_ELS) { in qlt_send_notify_ack()
1738 nack->u.isp24.flags = ntfy->u.isp24.flags & in qlt_send_notify_ack()
1741 nack->u.isp24.srr_rx_id = ntfy->u.isp24.srr_rx_id; in qlt_send_notify_ack()
1742 nack->u.isp24.status = ntfy->u.isp24.status; in qlt_send_notify_ack()
1743 nack->u.isp24.status_subcode = ntfy->u.isp24.status_subcode; in qlt_send_notify_ack()
1744 nack->u.isp24.fw_handle = ntfy->u.isp24.fw_handle; in qlt_send_notify_ack()
1745 nack->u.isp24.exchange_address = ntfy->u.isp24.exchange_address; in qlt_send_notify_ack()
1746 nack->u.isp24.srr_rel_offs = ntfy->u.isp24.srr_rel_offs; in qlt_send_notify_ack()
1747 nack->u.isp24.srr_ui = ntfy->u.isp24.srr_ui; in qlt_send_notify_ack()
1748 nack->u.isp24.srr_flags = cpu_to_le16(srr_flags); in qlt_send_notify_ack()
1749 nack->u.isp24.srr_reject_code = srr_reject_code; in qlt_send_notify_ack()
1750 nack->u.isp24.srr_reject_code_expl = srr_explan; in qlt_send_notify_ack()
1751 nack->u.isp24.vp_index = ntfy->u.isp24.vp_index; in qlt_send_notify_ack()
1754 if (ntfy->u.isp24.status_subcode == ELS_PLOGI && in qlt_send_notify_ack()
1755 (le16_to_cpu(ntfy->u.isp24.flags) & NOTIFY24XX_FLAGS_FCSP)) { in qlt_send_notify_ack()
1756 nack->u.isp24.flags |= cpu_to_le16(NOTIFY_ACK_FLAGS_FCSP); in qlt_send_notify_ack()
1761 vha->vp_idx, nack->u.isp24.status); in qlt_send_notify_ack()
1765 qla2x00_start_iocbs(vha, qpair->req); in qlt_send_notify_ack()
1770 struct scsi_qla_host *vha = mcmd->vha; in qlt_build_abts_resp_iocb()
1771 struct qla_hw_data *ha = vha->hw; in qlt_build_abts_resp_iocb()
1777 struct abts_recv_from_24xx *abts = &mcmd->orig_iocb.abts; in qlt_build_abts_resp_iocb()
1778 struct qla_qpair *qpair = mcmd->qpair; in qlt_build_abts_resp_iocb()
1782 ha, mcmd->fc_tm_rsp); in qlt_build_abts_resp_iocb()
1788 vha->vp_idx, __func__); in qlt_build_abts_resp_iocb()
1789 return -EAGAIN; in qlt_build_abts_resp_iocb()
1792 resp = (struct abts_resp_to_24xx *)qpair->req->ring_ptr; in qlt_build_abts_resp_iocb()
1802 return -EAGAIN; in qlt_build_abts_resp_iocb()
1804 qpair->req->outstanding_cmds[h] = (srb_t *)mcmd; in qlt_build_abts_resp_iocb()
1807 resp->handle = make_handle(qpair->req->id, h); in qlt_build_abts_resp_iocb()
1808 resp->entry_type = ABTS_RESP_24XX; in qlt_build_abts_resp_iocb()
1809 resp->entry_count = 1; in qlt_build_abts_resp_iocb()
1810 resp->nport_handle = abts->nport_handle; in qlt_build_abts_resp_iocb()
1811 resp->vp_index = vha->vp_idx; in qlt_build_abts_resp_iocb()
1812 resp->sof_type = abts->sof_type; in qlt_build_abts_resp_iocb()
1813 resp->exchange_address = abts->exchange_address; in qlt_build_abts_resp_iocb()
1814 resp->fcp_hdr_le = abts->fcp_hdr_le; in qlt_build_abts_resp_iocb()
1819 resp->fcp_hdr_le.f_ctl[0] = *p++; in qlt_build_abts_resp_iocb()
1820 resp->fcp_hdr_le.f_ctl[1] = *p++; in qlt_build_abts_resp_iocb()
1821 resp->fcp_hdr_le.f_ctl[2] = *p; in qlt_build_abts_resp_iocb()
1823 resp->fcp_hdr_le.d_id = abts->fcp_hdr_le.s_id; in qlt_build_abts_resp_iocb()
1824 resp->fcp_hdr_le.s_id = abts->fcp_hdr_le.d_id; in qlt_build_abts_resp_iocb()
1826 resp->exchange_addr_to_abort = abts->exchange_addr_to_abort; in qlt_build_abts_resp_iocb()
1827 if (mcmd->fc_tm_rsp == FCP_TMF_CMPL) { in qlt_build_abts_resp_iocb()
1828 resp->fcp_hdr_le.r_ctl = R_CTL_BASIC_LINK_SERV | R_CTL_B_ACC; in qlt_build_abts_resp_iocb()
1829 resp->payload.ba_acct.seq_id_valid = SEQ_ID_INVALID; in qlt_build_abts_resp_iocb()
1830 resp->payload.ba_acct.low_seq_cnt = 0x0000; in qlt_build_abts_resp_iocb()
1831 resp->payload.ba_acct.high_seq_cnt = cpu_to_le16(0xFFFF); in qlt_build_abts_resp_iocb()
1832 resp->payload.ba_acct.ox_id = abts->fcp_hdr_le.ox_id; in qlt_build_abts_resp_iocb()
1833 resp->payload.ba_acct.rx_id = abts->fcp_hdr_le.rx_id; in qlt_build_abts_resp_iocb()
1835 resp->fcp_hdr_le.r_ctl = R_CTL_BASIC_LINK_SERV | R_CTL_B_RJT; in qlt_build_abts_resp_iocb()
1836 resp->payload.ba_rjt.reason_code = in qlt_build_abts_resp_iocb()
1841 vha->vha_tgt.qla_tgt->abts_resp_expected++; in qlt_build_abts_resp_iocb()
1845 if (qpair->reqq_start_iocbs) in qlt_build_abts_resp_iocb()
1846 qpair->reqq_start_iocbs(qpair); in qlt_build_abts_resp_iocb()
1848 qla2x00_start_iocbs(vha, qpair->req); in qlt_build_abts_resp_iocb()
1854 * ha->hardware_lock supposed to be held on entry. Might drop it, then reaquire
1860 struct scsi_qla_host *vha = qpair->vha; in qlt_24xx_send_abts_resp()
1861 struct qla_hw_data *ha = vha->hw; in qlt_24xx_send_abts_resp()
1875 "request packet", vha->vp_idx, __func__); in qlt_24xx_send_abts_resp()
1879 resp->entry_type = ABTS_RESP_24XX; in qlt_24xx_send_abts_resp()
1880 resp->handle = QLA_TGT_SKIP_HANDLE; in qlt_24xx_send_abts_resp()
1881 resp->entry_count = 1; in qlt_24xx_send_abts_resp()
1882 resp->nport_handle = abts->nport_handle; in qlt_24xx_send_abts_resp()
1883 resp->vp_index = vha->vp_idx; in qlt_24xx_send_abts_resp()
1884 resp->sof_type = abts->sof_type; in qlt_24xx_send_abts_resp()
1885 resp->exchange_address = abts->exchange_address; in qlt_24xx_send_abts_resp()
1886 resp->fcp_hdr_le = abts->fcp_hdr_le; in qlt_24xx_send_abts_resp()
1891 resp->fcp_hdr_le.f_ctl[0] = *p++; in qlt_24xx_send_abts_resp()
1892 resp->fcp_hdr_le.f_ctl[1] = *p++; in qlt_24xx_send_abts_resp()
1893 resp->fcp_hdr_le.f_ctl[2] = *p; in qlt_24xx_send_abts_resp()
1895 resp->fcp_hdr_le.d_id = abts->fcp_hdr_le.d_id; in qlt_24xx_send_abts_resp()
1896 resp->fcp_hdr_le.s_id = abts->fcp_hdr_le.s_id; in qlt_24xx_send_abts_resp()
1898 resp->fcp_hdr_le.d_id = abts->fcp_hdr_le.s_id; in qlt_24xx_send_abts_resp()
1899 resp->fcp_hdr_le.s_id = abts->fcp_hdr_le.d_id; in qlt_24xx_send_abts_resp()
1901 resp->exchange_addr_to_abort = abts->exchange_addr_to_abort; in qlt_24xx_send_abts_resp()
1903 resp->fcp_hdr_le.r_ctl = R_CTL_BASIC_LINK_SERV | R_CTL_B_ACC; in qlt_24xx_send_abts_resp()
1904 resp->payload.ba_acct.seq_id_valid = SEQ_ID_INVALID; in qlt_24xx_send_abts_resp()
1905 resp->payload.ba_acct.low_seq_cnt = 0x0000; in qlt_24xx_send_abts_resp()
1906 resp->payload.ba_acct.high_seq_cnt = cpu_to_le16(0xFFFF); in qlt_24xx_send_abts_resp()
1907 resp->payload.ba_acct.ox_id = abts->fcp_hdr_le.ox_id; in qlt_24xx_send_abts_resp()
1908 resp->payload.ba_acct.rx_id = abts->fcp_hdr_le.rx_id; in qlt_24xx_send_abts_resp()
1910 resp->fcp_hdr_le.r_ctl = R_CTL_BASIC_LINK_SERV | R_CTL_B_RJT; in qlt_24xx_send_abts_resp()
1911 resp->payload.ba_rjt.reason_code = in qlt_24xx_send_abts_resp()
1916 vha->vha_tgt.qla_tgt->abts_resp_expected++; in qlt_24xx_send_abts_resp()
1920 if (qpair->reqq_start_iocbs) in qlt_24xx_send_abts_resp()
1921 qpair->reqq_start_iocbs(qpair); in qlt_24xx_send_abts_resp()
1923 qla2x00_start_iocbs(vha, qpair->req); in qlt_24xx_send_abts_resp()
1927 * ha->hardware_lock supposed to be held on entry. Might drop it, then reaquire
1940 "request packet\n", vha->vp_idx, __func__); in qlt_24xx_retry_term_exchange()
1946 entry = &mcmd->orig_iocb.abts; in qlt_24xx_retry_term_exchange()
1956 ctio->entry_type = CTIO_TYPE7; in qlt_24xx_retry_term_exchange()
1957 ctio->entry_count = 1; in qlt_24xx_retry_term_exchange()
1958 ctio->nport_handle = entry->nport_handle; in qlt_24xx_retry_term_exchange()
1959 ctio->handle = QLA_TGT_SKIP_HANDLE | CTIO_COMPLETION_HANDLE_MARK; in qlt_24xx_retry_term_exchange()
1960 ctio->timeout = cpu_to_le16(QLA_TGT_TIMEOUT); in qlt_24xx_retry_term_exchange()
1961 ctio->vp_index = vha->vp_idx; in qlt_24xx_retry_term_exchange()
1962 ctio->exchange_addr = entry->exchange_addr_to_abort; in qlt_24xx_retry_term_exchange()
1966 ctio->initiator_id = entry->fcp_hdr_le.s_id; in qlt_24xx_retry_term_exchange()
1968 if (mcmd->flags & QLA24XX_MGMT_ABORT_IO_ATTR_VALID) in qlt_24xx_retry_term_exchange()
1969 tmp |= (mcmd->abort_io_attr << 9); in qlt_24xx_retry_term_exchange()
1970 else if (qpair->retry_term_cnt & 1) in qlt_24xx_retry_term_exchange()
1973 ctio->initiator_id = entry->fcp_hdr_le.d_id; in qlt_24xx_retry_term_exchange()
1975 if (qpair->retry_term_cnt & 1) in qlt_24xx_retry_term_exchange()
1978 ctio->u.status1.flags = cpu_to_le16(tmp); in qlt_24xx_retry_term_exchange()
1979 ctio->u.status1.ox_id = entry->fcp_hdr_le.ox_id; in qlt_24xx_retry_term_exchange()
1983 le16_to_cpu(ctio->u.status1.flags), in qlt_24xx_retry_term_exchange()
1984 le16_to_cpu(ctio->u.status1.ox_id), in qlt_24xx_retry_term_exchange()
1985 (mcmd && mcmd->flags & QLA24XX_MGMT_ABORT_IO_ATTR_VALID) ? 1 : 0); in qlt_24xx_retry_term_exchange()
1989 if (qpair->reqq_start_iocbs) in qlt_24xx_retry_term_exchange()
1990 qpair->reqq_start_iocbs(qpair); in qlt_24xx_retry_term_exchange()
1992 qla2x00_start_iocbs(vha, qpair->req); in qlt_24xx_retry_term_exchange()
2015 spin_lock_irqsave(&vha->cmd_list_lock, flags); in abort_cmds_for_lun()
2016 list_for_each_entry(op, &vha->unknown_atio_list, cmd_list) { in abort_cmds_for_lun()
2020 op_key = sid_to_key(op->atio.u.isp24.fcp_hdr.s_id); in abort_cmds_for_lun()
2022 (struct scsi_lun *)&op->atio.u.isp24.fcp_cmnd.lun); in abort_cmds_for_lun()
2024 op->aborted = true; in abort_cmds_for_lun()
2027 list_for_each_entry(cmd, &vha->qla_cmd_list, cmd_list) { in abort_cmds_for_lun()
2031 cmd_key = sid_to_key(cmd->atio.u.isp24.fcp_hdr.s_id); in abort_cmds_for_lun()
2033 (struct scsi_lun *)&cmd->atio.u.isp24.fcp_cmnd.lun); in abort_cmds_for_lun()
2035 cmd->aborted = 1; in abort_cmds_for_lun()
2037 spin_unlock_irqrestore(&vha->cmd_list_lock, flags); in abort_cmds_for_lun()
2043 struct qla_tgt *tgt = vha->vha_tgt.qla_tgt; in qlt_find_qphint()
2046 if (vha->flags.qpairs_available) { in qlt_find_qphint()
2047 h = btree_lookup64(&tgt->lun_qpair_map, unpacked_lun); in qlt_find_qphint()
2049 h = &tgt->qphints[0]; in qlt_find_qphint()
2051 h = &tgt->qphints[0]; in qlt_find_qphint()
2061 struct qla_hw_data *ha = mcmd->vha->hw; in qlt_do_tmr_work()
2066 switch (mcmd->tmr_func) { in qlt_do_tmr_work()
2068 tag = le32_to_cpu(mcmd->orig_iocb.abts.exchange_addr_to_abort); in qlt_do_tmr_work()
2075 rc = ha->tgt.tgt_ops->handle_tmr(mcmd, mcmd->unpacked_lun, in qlt_do_tmr_work()
2076 mcmd->tmr_func, tag); in qlt_do_tmr_work()
2079 spin_lock_irqsave(mcmd->qpair->qp_lock_ptr, flags); in qlt_do_tmr_work()
2080 switch (mcmd->tmr_func) { in qlt_do_tmr_work()
2082 mcmd->fc_tm_rsp = FCP_TMF_REJECTED; in qlt_do_tmr_work()
2090 qlt_send_busy(mcmd->qpair, &mcmd->orig_iocb.atio, in qlt_do_tmr_work()
2097 qlt_send_notify_ack(mcmd->qpair, in qlt_do_tmr_work()
2098 &mcmd->orig_iocb.imm_ntfy, 0, 0, 0, 0, 0, 0); in qlt_do_tmr_work()
2101 spin_unlock_irqrestore(mcmd->qpair->qp_lock_ptr, flags); in qlt_do_tmr_work()
2103 ql_dbg(ql_dbg_tgt_mgt, mcmd->vha, 0xf052, in qlt_do_tmr_work()
2104 "qla_target(%d): tgt_ops->handle_tmr() failed: %d\n", in qlt_do_tmr_work()
2105 mcmd->vha->vp_idx, rc); in qlt_do_tmr_work()
2110 /* ha->hardware_lock supposed to be held on entry */
2114 struct qla_hw_data *ha = vha->hw; in __qlt_24xx_handle_abts()
2116 struct qla_qpair_hint *h = &vha->vha_tgt.qla_tgt->qphints[0]; in __qlt_24xx_handle_abts()
2121 vha->vp_idx, abts->exchange_addr_to_abort); in __qlt_24xx_handle_abts()
2127 vha->vp_idx, __func__); in __qlt_24xx_handle_abts()
2128 return -ENOMEM; in __qlt_24xx_handle_abts()
2131 mcmd->cmd_type = TYPE_TGT_TMCMD; in __qlt_24xx_handle_abts()
2132 mcmd->sess = sess; in __qlt_24xx_handle_abts()
2133 memcpy(&mcmd->orig_iocb.abts, abts, sizeof(mcmd->orig_iocb.abts)); in __qlt_24xx_handle_abts()
2134 mcmd->reset_count = ha->base_qpair->chip_reset; in __qlt_24xx_handle_abts()
2135 mcmd->tmr_func = QLA_TGT_ABTS; in __qlt_24xx_handle_abts()
2136 mcmd->qpair = h->qpair; in __qlt_24xx_handle_abts()
2137 mcmd->vha = vha; in __qlt_24xx_handle_abts()
2140 * LUN is looked up by target-core internally based on the passed in __qlt_24xx_handle_abts()
2141 * abts->exchange_addr_to_abort tag. in __qlt_24xx_handle_abts()
2143 mcmd->se_cmd.cpuid = h->cpuid; in __qlt_24xx_handle_abts()
2145 abort_cmd = ha->tgt.tgt_ops->find_cmd_by_tag(sess, in __qlt_24xx_handle_abts()
2146 le32_to_cpu(abts->exchange_addr_to_abort)); in __qlt_24xx_handle_abts()
2149 return -EIO; in __qlt_24xx_handle_abts()
2151 mcmd->unpacked_lun = abort_cmd->se_cmd.orig_fe_lun; in __qlt_24xx_handle_abts()
2153 if (abort_cmd->qpair) { in __qlt_24xx_handle_abts()
2154 mcmd->qpair = abort_cmd->qpair; in __qlt_24xx_handle_abts()
2155 mcmd->se_cmd.cpuid = abort_cmd->se_cmd.cpuid; in __qlt_24xx_handle_abts()
2156 mcmd->abort_io_attr = abort_cmd->atio.u.isp24.attr; in __qlt_24xx_handle_abts()
2157 mcmd->flags = QLA24XX_MGMT_ABORT_IO_ATTR_VALID; in __qlt_24xx_handle_abts()
2160 INIT_WORK(&mcmd->work, qlt_do_tmr_work); in __qlt_24xx_handle_abts()
2161 queue_work_on(mcmd->se_cmd.cpuid, qla_tgt_wq, &mcmd->work); in __qlt_24xx_handle_abts()
2167 * ha->hardware_lock supposed to be held on entry. Might drop it, then reaquire
2172 struct qla_hw_data *ha = vha->hw; in qlt_24xx_handle_abts()
2174 uint32_t tag = le32_to_cpu(abts->exchange_addr_to_abort); in qlt_24xx_handle_abts()
2179 if (le32_to_cpu(abts->fcp_hdr_le.parameter) & ABTS_PARAM_ABORT_SEQ) { in qlt_24xx_handle_abts()
2182 "supported\n", vha->vp_idx); in qlt_24xx_handle_abts()
2183 qlt_24xx_send_abts_resp(ha->base_qpair, abts, FCP_TMF_REJECTED, in qlt_24xx_handle_abts()
2191 "Address received\n", vha->vp_idx); in qlt_24xx_handle_abts()
2192 qlt_24xx_send_abts_resp(ha->base_qpair, abts, FCP_TMF_REJECTED, in qlt_24xx_handle_abts()
2199 "tag=%d, param=%x)\n", vha->vp_idx, abts->fcp_hdr_le.s_id.domain, in qlt_24xx_handle_abts()
2200 abts->fcp_hdr_le.s_id.area, abts->fcp_hdr_le.s_id.al_pa, tag, in qlt_24xx_handle_abts()
2201 le32_to_cpu(abts->fcp_hdr_le.parameter)); in qlt_24xx_handle_abts()
2203 s_id = le_id_to_be(abts->fcp_hdr_le.s_id); in qlt_24xx_handle_abts()
2205 spin_lock_irqsave(&ha->tgt.sess_lock, flags); in qlt_24xx_handle_abts()
2206 sess = ha->tgt.tgt_ops->find_sess_by_s_id(vha, s_id); in qlt_24xx_handle_abts()
2209 "qla_target(%d): task abort for non-existent session\n", in qlt_24xx_handle_abts()
2210 vha->vp_idx); in qlt_24xx_handle_abts()
2211 spin_unlock_irqrestore(&ha->tgt.sess_lock, flags); in qlt_24xx_handle_abts()
2213 qlt_24xx_send_abts_resp(ha->base_qpair, abts, FCP_TMF_REJECTED, in qlt_24xx_handle_abts()
2217 spin_unlock_irqrestore(&ha->tgt.sess_lock, flags); in qlt_24xx_handle_abts()
2220 if (sess->deleted) { in qlt_24xx_handle_abts()
2221 qlt_24xx_send_abts_resp(ha->base_qpair, abts, FCP_TMF_REJECTED, in qlt_24xx_handle_abts()
2230 vha->vp_idx, rc); in qlt_24xx_handle_abts()
2231 qlt_24xx_send_abts_resp(ha->base_qpair, abts, FCP_TMF_REJECTED, in qlt_24xx_handle_abts()
2238 * ha->hardware_lock supposed to be held on entry. Might drop it, then reaquire
2243 struct scsi_qla_host *ha = mcmd->vha; in qlt_24xx_send_task_mgmt_ctio()
2244 struct atio_from_isp *atio = &mcmd->orig_iocb.atio; in qlt_24xx_send_task_mgmt_ctio()
2257 "request packet\n", ha->vp_idx, __func__); in qlt_24xx_send_task_mgmt_ctio()
2261 ctio->entry_type = CTIO_TYPE7; in qlt_24xx_send_task_mgmt_ctio()
2262 ctio->entry_count = 1; in qlt_24xx_send_task_mgmt_ctio()
2263 ctio->handle = QLA_TGT_SKIP_HANDLE | CTIO_COMPLETION_HANDLE_MARK; in qlt_24xx_send_task_mgmt_ctio()
2264 ctio->nport_handle = cpu_to_le16(mcmd->sess->loop_id); in qlt_24xx_send_task_mgmt_ctio()
2265 ctio->timeout = cpu_to_le16(QLA_TGT_TIMEOUT); in qlt_24xx_send_task_mgmt_ctio()
2266 ctio->vp_index = ha->vp_idx; in qlt_24xx_send_task_mgmt_ctio()
2267 ctio->initiator_id = be_id_to_le(atio->u.isp24.fcp_hdr.s_id); in qlt_24xx_send_task_mgmt_ctio()
2268 ctio->exchange_addr = atio->u.isp24.exchange_addr; in qlt_24xx_send_task_mgmt_ctio()
2269 temp = (atio->u.isp24.attr << 9)| in qlt_24xx_send_task_mgmt_ctio()
2271 ctio->u.status1.flags = cpu_to_le16(temp); in qlt_24xx_send_task_mgmt_ctio()
2272 temp = be16_to_cpu(atio->u.isp24.fcp_hdr.ox_id); in qlt_24xx_send_task_mgmt_ctio()
2273 ctio->u.status1.ox_id = cpu_to_le16(temp); in qlt_24xx_send_task_mgmt_ctio()
2274 ctio->u.status1.scsi_status = in qlt_24xx_send_task_mgmt_ctio()
2276 ctio->u.status1.response_len = cpu_to_le16(8); in qlt_24xx_send_task_mgmt_ctio()
2277 ctio->u.status1.sense_data[0] = resp_code; in qlt_24xx_send_task_mgmt_ctio()
2281 if (qpair->reqq_start_iocbs) in qlt_24xx_send_task_mgmt_ctio()
2282 qpair->reqq_start_iocbs(qpair); in qlt_24xx_send_task_mgmt_ctio()
2284 qla2x00_start_iocbs(ha, qpair->req); in qlt_24xx_send_task_mgmt_ctio()
2294 * ha->hardware_lock supposed to be held on entry. Might drop it, then
2300 struct atio_from_isp *atio = &cmd->atio; in qlt_send_resp_ctio()
2303 struct scsi_qla_host *vha = cmd->vha; in qlt_send_resp_ctio()
2314 vha->host_no, __func__); in qlt_send_resp_ctio()
2318 ctio->entry_type = CTIO_TYPE7; in qlt_send_resp_ctio()
2319 ctio->entry_count = 1; in qlt_send_resp_ctio()
2320 ctio->handle = QLA_TGT_SKIP_HANDLE; in qlt_send_resp_ctio()
2321 ctio->nport_handle = cpu_to_le16(cmd->sess->loop_id); in qlt_send_resp_ctio()
2322 ctio->timeout = cpu_to_le16(QLA_TGT_TIMEOUT); in qlt_send_resp_ctio()
2323 ctio->vp_index = vha->vp_idx; in qlt_send_resp_ctio()
2324 ctio->initiator_id = be_id_to_le(atio->u.isp24.fcp_hdr.s_id); in qlt_send_resp_ctio()
2325 ctio->exchange_addr = atio->u.isp24.exchange_addr; in qlt_send_resp_ctio()
2326 temp = (atio->u.isp24.attr << 9) | in qlt_send_resp_ctio()
2328 ctio->u.status1.flags = cpu_to_le16(temp); in qlt_send_resp_ctio()
2329 temp = be16_to_cpu(atio->u.isp24.fcp_hdr.ox_id); in qlt_send_resp_ctio()
2330 ctio->u.status1.ox_id = cpu_to_le16(temp); in qlt_send_resp_ctio()
2331 ctio->u.status1.scsi_status = in qlt_send_resp_ctio()
2333 ctio->u.status1.response_len = cpu_to_le16(18); in qlt_send_resp_ctio()
2334 ctio->u.status1.residual = cpu_to_le32(get_datalen_for_atio(atio)); in qlt_send_resp_ctio()
2336 if (ctio->u.status1.residual != 0) in qlt_send_resp_ctio()
2337 ctio->u.status1.scsi_status |= in qlt_send_resp_ctio()
2341 ctio->u.status1.sense_data[0] = 0x70; in qlt_send_resp_ctio()
2342 ctio->u.status1.sense_data[2] = sense_key; in qlt_send_resp_ctio()
2344 ctio->u.status1.sense_data[7] = 0xa; in qlt_send_resp_ctio()
2346 ctio->u.status1.sense_data[12] = asc; in qlt_send_resp_ctio()
2347 ctio->u.status1.sense_data[13] = ascq; in qlt_send_resp_ctio()
2352 if (qpair->reqq_start_iocbs) in qlt_send_resp_ctio()
2353 qpair->reqq_start_iocbs(qpair); in qlt_send_resp_ctio()
2355 qla2x00_start_iocbs(vha, qpair->req); in qlt_send_resp_ctio()
2364 struct scsi_qla_host *vha = mcmd->sess->vha; in qlt_xmit_tm_rsp()
2365 struct qla_hw_data *ha = vha->hw; in qlt_xmit_tm_rsp()
2367 struct qla_qpair *qpair = mcmd->qpair; in qlt_xmit_tm_rsp()
2372 mcmd, mcmd->fc_tm_rsp, mcmd->flags); in qlt_xmit_tm_rsp()
2374 spin_lock_irqsave(qpair->qp_lock_ptr, flags); in qlt_xmit_tm_rsp()
2376 if (!vha->flags.online || mcmd->reset_count != qpair->chip_reset) { in qlt_xmit_tm_rsp()
2382 "RESET-TMR online/active/old-count/new-count = %d/%d/%d/%d.\n", in qlt_xmit_tm_rsp()
2383 vha->flags.online, qla2x00_reset_active(vha), in qlt_xmit_tm_rsp()
2384 mcmd->reset_count, qpair->chip_reset); in qlt_xmit_tm_rsp()
2385 ha->tgt.tgt_ops->free_mcmd(mcmd); in qlt_xmit_tm_rsp()
2386 spin_unlock_irqrestore(qpair->qp_lock_ptr, flags); in qlt_xmit_tm_rsp()
2390 if (mcmd->flags == QLA24XX_MGMT_SEND_NACK) { in qlt_xmit_tm_rsp()
2391 switch (mcmd->orig_iocb.imm_ntfy.u.isp24.status_subcode) { in qlt_xmit_tm_rsp()
2397 mcmd->sess->port_name, mcmd->fc_tm_rsp, in qlt_xmit_tm_rsp()
2398 mcmd->flags); in qlt_xmit_tm_rsp()
2399 qlt_schedule_sess_for_deletion(mcmd->sess); in qlt_xmit_tm_rsp()
2402 qlt_send_notify_ack(vha->hw->base_qpair, in qlt_xmit_tm_rsp()
2403 &mcmd->orig_iocb.imm_ntfy, 0, 0, 0, 0, 0, 0); in qlt_xmit_tm_rsp()
2407 if (mcmd->orig_iocb.atio.u.raw.entry_type == ABTS_RECV_24XX) { in qlt_xmit_tm_rsp()
2412 mcmd->fc_tm_rsp); in qlt_xmit_tm_rsp()
2415 * Make the callback for ->free_mcmd() to queue_work() and invoke in qlt_xmit_tm_rsp()
2417 * target_put_sess_cmd() call will be made from TFO->check_stop_free() in qlt_xmit_tm_rsp()
2418 * -> tcm_qla2xxx_check_stop_free() to release the TMR associated se_cmd in qlt_xmit_tm_rsp()
2419 * descriptor after TFO->queue_tm_rsp() -> tcm_qla2xxx_queue_tm_rsp() -> in qlt_xmit_tm_rsp()
2423 ha->tgt.tgt_ops->free_mcmd(mcmd); in qlt_xmit_tm_rsp()
2425 spin_unlock_irqrestore(qpair->qp_lock_ptr, flags); in qlt_xmit_tm_rsp()
2432 struct qla_tgt_cmd *cmd = prm->cmd; in qlt_pci_map_calc_cnt()
2434 BUG_ON(cmd->sg_cnt == 0); in qlt_pci_map_calc_cnt()
2436 prm->sg = (struct scatterlist *)cmd->sg; in qlt_pci_map_calc_cnt()
2437 prm->seg_cnt = dma_map_sg(&cmd->qpair->pdev->dev, cmd->sg, in qlt_pci_map_calc_cnt()
2438 cmd->sg_cnt, cmd->dma_data_direction); in qlt_pci_map_calc_cnt()
2439 if (unlikely(prm->seg_cnt == 0)) in qlt_pci_map_calc_cnt()
2442 prm->cmd->sg_mapped = 1; in qlt_pci_map_calc_cnt()
2444 if (cmd->se_cmd.prot_op == TARGET_PROT_NORMAL) { in qlt_pci_map_calc_cnt()
2449 if (prm->seg_cnt > QLA_TGT_DATASEGS_PER_CMD_24XX) in qlt_pci_map_calc_cnt()
2450 prm->req_cnt += DIV_ROUND_UP(prm->seg_cnt - in qlt_pci_map_calc_cnt()
2455 if ((cmd->se_cmd.prot_op == TARGET_PROT_DIN_INSERT) || in qlt_pci_map_calc_cnt()
2456 (cmd->se_cmd.prot_op == TARGET_PROT_DOUT_STRIP)) { in qlt_pci_map_calc_cnt()
2457 prm->seg_cnt = DIV_ROUND_UP(cmd->bufflen, cmd->blk_sz); in qlt_pci_map_calc_cnt()
2458 prm->tot_dsds = prm->seg_cnt; in qlt_pci_map_calc_cnt()
2460 prm->tot_dsds = prm->seg_cnt; in qlt_pci_map_calc_cnt()
2462 if (cmd->prot_sg_cnt) { in qlt_pci_map_calc_cnt()
2463 prm->prot_sg = cmd->prot_sg; in qlt_pci_map_calc_cnt()
2464 prm->prot_seg_cnt = dma_map_sg(&cmd->qpair->pdev->dev, in qlt_pci_map_calc_cnt()
2465 cmd->prot_sg, cmd->prot_sg_cnt, in qlt_pci_map_calc_cnt()
2466 cmd->dma_data_direction); in qlt_pci_map_calc_cnt()
2467 if (unlikely(prm->prot_seg_cnt == 0)) in qlt_pci_map_calc_cnt()
2470 if ((cmd->se_cmd.prot_op == TARGET_PROT_DIN_INSERT) || in qlt_pci_map_calc_cnt()
2471 (cmd->se_cmd.prot_op == TARGET_PROT_DOUT_STRIP)) { in qlt_pci_map_calc_cnt()
2473 prm->prot_seg_cnt = DIV_ROUND_UP(cmd->bufflen, in qlt_pci_map_calc_cnt()
2474 cmd->blk_sz); in qlt_pci_map_calc_cnt()
2475 prm->tot_dsds += prm->prot_seg_cnt; in qlt_pci_map_calc_cnt()
2477 prm->tot_dsds += prm->prot_seg_cnt; in qlt_pci_map_calc_cnt()
2484 ql_dbg_qp(ql_dbg_tgt, prm->cmd->qpair, 0xe04d, in qlt_pci_map_calc_cnt()
2486 0, prm->cmd->sg_cnt); in qlt_pci_map_calc_cnt()
2487 return -1; in qlt_pci_map_calc_cnt()
2495 if (!cmd->sg_mapped) in qlt_unmap_sg()
2498 qpair = cmd->qpair; in qlt_unmap_sg()
2500 dma_unmap_sg(&qpair->pdev->dev, cmd->sg, cmd->sg_cnt, in qlt_unmap_sg()
2501 cmd->dma_data_direction); in qlt_unmap_sg()
2502 cmd->sg_mapped = 0; in qlt_unmap_sg()
2504 if (cmd->prot_sg_cnt) in qlt_unmap_sg()
2505 dma_unmap_sg(&qpair->pdev->dev, cmd->prot_sg, cmd->prot_sg_cnt, in qlt_unmap_sg()
2506 cmd->dma_data_direction); in qlt_unmap_sg()
2508 if (!cmd->ctx) in qlt_unmap_sg()
2510 ha = vha->hw; in qlt_unmap_sg()
2511 if (cmd->ctx_dsd_alloced) in qlt_unmap_sg()
2512 qla2x00_clean_dsd_pool(ha, cmd->ctx); in qlt_unmap_sg()
2514 dma_pool_free(ha->dl_dma_pool, cmd->ctx, cmd->ctx->crc_ctx_dma); in qlt_unmap_sg()
2521 struct req_que *req = qpair->req; in qlt_check_reserve_free_req()
2523 if (req->cnt < (req_cnt + 2)) { in qlt_check_reserve_free_req()
2524 cnt = (uint16_t)(qpair->use_shadow_reg ? *req->out_ptr : in qlt_check_reserve_free_req()
2525 rd_reg_dword_relaxed(req->req_q_out)); in qlt_check_reserve_free_req()
2527 if (req->ring_index < cnt) in qlt_check_reserve_free_req()
2528 req->cnt = cnt - req->ring_index; in qlt_check_reserve_free_req()
2530 req->cnt = req->length - (req->ring_index - cnt); in qlt_check_reserve_free_req()
2532 if (unlikely(req->cnt < (req_cnt + 2))) in qlt_check_reserve_free_req()
2533 return -EAGAIN; in qlt_check_reserve_free_req()
2536 req->cnt -= req_cnt; in qlt_check_reserve_free_req()
2542 * ha->hardware_lock supposed to be held on entry. Might drop it, then reaquire
2547 req->ring_index++; in qlt_get_req_pkt()
2548 if (req->ring_index == req->length) { in qlt_get_req_pkt()
2549 req->ring_index = 0; in qlt_get_req_pkt()
2550 req->ring_ptr = req->ring; in qlt_get_req_pkt()
2552 req->ring_ptr++; in qlt_get_req_pkt()
2554 return (cont_entry_t *)req->ring_ptr; in qlt_get_req_pkt()
2557 /* ha->hardware_lock supposed to be held on entry */
2563 struct req_que *req = qpair->req; in qlt_make_handle()
2565 h = req->current_outstanding_cmd; in qlt_make_handle()
2567 for (index = 1; index < req->num_outstanding_cmds; index++) { in qlt_make_handle()
2569 if (h == req->num_outstanding_cmds) in qlt_make_handle()
2575 if (!req->outstanding_cmds[h]) { in qlt_make_handle()
2582 req->current_outstanding_cmd = h; in qlt_make_handle()
2584 ql_dbg(ql_dbg_io, qpair->vha, 0x305b, in qlt_make_handle()
2586 qpair->vha->vp_idx); in qlt_make_handle()
2593 /* ha->hardware_lock supposed to be held on entry */
2599 struct atio_from_isp *atio = &prm->cmd->atio; in qlt_24xx_build_ctio_pkt()
2601 struct qla_tgt_cmd *cmd = prm->cmd; in qlt_24xx_build_ctio_pkt()
2603 pkt = (struct ctio7_to_24xx *)qpair->req->ring_ptr; in qlt_24xx_build_ctio_pkt()
2604 prm->pkt = pkt; in qlt_24xx_build_ctio_pkt()
2607 pkt->entry_type = CTIO_TYPE7; in qlt_24xx_build_ctio_pkt()
2608 pkt->entry_count = (uint8_t)prm->req_cnt; in qlt_24xx_build_ctio_pkt()
2609 pkt->vp_index = prm->cmd->vp_idx; in qlt_24xx_build_ctio_pkt()
2618 return -EAGAIN; in qlt_24xx_build_ctio_pkt()
2620 qpair->req->outstanding_cmds[h] = (srb_t *)prm->cmd; in qlt_24xx_build_ctio_pkt()
2622 pkt->handle = make_handle(qpair->req->id, h); in qlt_24xx_build_ctio_pkt()
2623 pkt->handle |= CTIO_COMPLETION_HANDLE_MARK; in qlt_24xx_build_ctio_pkt()
2624 pkt->nport_handle = cpu_to_le16(prm->cmd->loop_id); in qlt_24xx_build_ctio_pkt()
2625 pkt->timeout = cpu_to_le16(QLA_TGT_TIMEOUT); in qlt_24xx_build_ctio_pkt()
2626 pkt->initiator_id = be_id_to_le(atio->u.isp24.fcp_hdr.s_id); in qlt_24xx_build_ctio_pkt()
2627 pkt->exchange_addr = atio->u.isp24.exchange_addr; in qlt_24xx_build_ctio_pkt()
2628 temp = atio->u.isp24.attr << 9; in qlt_24xx_build_ctio_pkt()
2629 pkt->u.status0.flags |= cpu_to_le16(temp); in qlt_24xx_build_ctio_pkt()
2630 temp = be16_to_cpu(atio->u.isp24.fcp_hdr.ox_id); in qlt_24xx_build_ctio_pkt()
2631 pkt->u.status0.ox_id = cpu_to_le16(temp); in qlt_24xx_build_ctio_pkt()
2632 pkt->u.status0.relative_offset = cpu_to_le32(prm->cmd->offset); in qlt_24xx_build_ctio_pkt()
2634 if (cmd->edif) { in qlt_24xx_build_ctio_pkt()
2635 if (cmd->dma_data_direction == DMA_TO_DEVICE) in qlt_24xx_build_ctio_pkt()
2636 prm->cmd->sess->edif.rx_bytes += cmd->bufflen; in qlt_24xx_build_ctio_pkt()
2637 if (cmd->dma_data_direction == DMA_FROM_DEVICE) in qlt_24xx_build_ctio_pkt()
2638 prm->cmd->sess->edif.tx_bytes += cmd->bufflen; in qlt_24xx_build_ctio_pkt()
2640 pkt->u.status0.edif_flags |= EF_EN_EDIF; in qlt_24xx_build_ctio_pkt()
2647 * ha->hardware_lock supposed to be held on entry. We have already made sure
2656 while (prm->seg_cnt > 0) { in qlt_load_cont_data_segments()
2659 prm->cmd->qpair->req); in qlt_load_cont_data_segments()
2663 * 64-bit specific fields used for 32-bit in qlt_load_cont_data_segments()
2670 cont_pkt64->entry_count = 1; in qlt_load_cont_data_segments()
2671 cont_pkt64->sys_define = 0; in qlt_load_cont_data_segments()
2673 cont_pkt64->entry_type = CONTINUE_A64_TYPE; in qlt_load_cont_data_segments()
2674 cur_dsd = cont_pkt64->dsd; in qlt_load_cont_data_segments()
2678 cnt < QLA_TGT_DATASEGS_PER_CONT_24XX && prm->seg_cnt; in qlt_load_cont_data_segments()
2679 cnt++, prm->seg_cnt--) { in qlt_load_cont_data_segments()
2680 append_dsd64(&cur_dsd, prm->sg); in qlt_load_cont_data_segments()
2681 prm->sg = sg_next(prm->sg); in qlt_load_cont_data_segments()
2687 * ha->hardware_lock supposed to be held on entry. We have already made sure
2694 struct ctio7_to_24xx *pkt24 = (struct ctio7_to_24xx *)prm->pkt; in qlt_load_data_segments()
2696 pkt24->u.status0.transfer_length = cpu_to_le32(prm->cmd->bufflen); in qlt_load_data_segments()
2699 cur_dsd = &pkt24->u.status0.dsd; in qlt_load_data_segments()
2702 if (prm->seg_cnt) in qlt_load_data_segments()
2703 pkt24->dseg_count = cpu_to_le16(prm->seg_cnt); in qlt_load_data_segments()
2705 if (prm->seg_cnt == 0) { in qlt_load_data_segments()
2707 cur_dsd->address = 0; in qlt_load_data_segments()
2708 cur_dsd->length = 0; in qlt_load_data_segments()
2716 (cnt < QLA_TGT_DATASEGS_PER_CMD_24XX) && prm->seg_cnt; in qlt_load_data_segments()
2717 cnt++, prm->seg_cnt--) { in qlt_load_data_segments()
2718 append_dsd64(&cur_dsd, prm->sg); in qlt_load_data_segments()
2719 prm->sg = sg_next(prm->sg); in qlt_load_data_segments()
2727 return cmd->bufflen > 0; in qlt_has_data()
2736 if (prm->sense_buffer && (prm->sense_buffer[12] == 0x10)) { in qlt_print_dif_err()
2737 cmd = prm->cmd; in qlt_print_dif_err()
2738 vha = cmd->vha; in qlt_print_dif_err()
2740 switch (prm->sense_buffer[13]) { in qlt_print_dif_err()
2745 cmd->lba, cmd->lba, cmd->num_blks, &cmd->se_cmd, in qlt_print_dif_err()
2746 cmd->atio.u.isp24.exchange_addr); in qlt_print_dif_err()
2752 cmd->lba, cmd->lba, cmd->num_blks, &cmd->se_cmd, in qlt_print_dif_err()
2753 cmd->atio.u.isp24.exchange_addr); in qlt_print_dif_err()
2759 cmd->lba, cmd->lba, cmd->num_blks, &cmd->se_cmd, in qlt_print_dif_err()
2760 cmd->atio.u.isp24.exchange_addr); in qlt_print_dif_err()
2766 cmd->lba, cmd->lba, cmd->num_blks, &cmd->se_cmd, in qlt_print_dif_err()
2767 cmd->atio.u.isp24.exchange_addr); in qlt_print_dif_err()
2770 ql_dump_buffer(ql_dbg_tgt_dif, vha, 0xe011, cmd->cdb, 16); in qlt_print_dif_err()
2775 * Called without ha->hardware_lock held
2781 struct se_cmd *se_cmd = &cmd->se_cmd; in qlt_pre_xmit_response()
2782 struct qla_qpair *qpair = cmd->qpair; in qlt_pre_xmit_response()
2784 prm->cmd = cmd; in qlt_pre_xmit_response()
2785 prm->tgt = cmd->tgt; in qlt_pre_xmit_response()
2786 prm->pkt = NULL; in qlt_pre_xmit_response()
2787 prm->rq_result = scsi_status; in qlt_pre_xmit_response()
2788 prm->sense_buffer = &cmd->sense_buffer[0]; in qlt_pre_xmit_response()
2789 prm->sense_buffer_len = TRANSPORT_SENSE_BUFFER; in qlt_pre_xmit_response()
2790 prm->sg = NULL; in qlt_pre_xmit_response()
2791 prm->seg_cnt = -1; in qlt_pre_xmit_response()
2792 prm->req_cnt = 1; in qlt_pre_xmit_response()
2793 prm->residual = 0; in qlt_pre_xmit_response()
2794 prm->add_status_pkt = 0; in qlt_pre_xmit_response()
2795 prm->prot_sg = NULL; in qlt_pre_xmit_response()
2796 prm->prot_seg_cnt = 0; in qlt_pre_xmit_response()
2797 prm->tot_dsds = 0; in qlt_pre_xmit_response()
2801 return -EAGAIN; in qlt_pre_xmit_response()
2804 *full_req_cnt = prm->req_cnt; in qlt_pre_xmit_response()
2806 if (se_cmd->se_cmd_flags & SCF_UNDERFLOW_BIT) { in qlt_pre_xmit_response()
2807 prm->residual = se_cmd->residual_count; in qlt_pre_xmit_response()
2810 prm->residual, se_cmd->tag, in qlt_pre_xmit_response()
2811 se_cmd->t_task_cdb ? se_cmd->t_task_cdb[0] : 0, in qlt_pre_xmit_response()
2812 cmd->bufflen, prm->rq_result); in qlt_pre_xmit_response()
2813 prm->rq_result |= SS_RESIDUAL_UNDER; in qlt_pre_xmit_response()
2814 } else if (se_cmd->se_cmd_flags & SCF_OVERFLOW_BIT) { in qlt_pre_xmit_response()
2815 prm->residual = se_cmd->residual_count; in qlt_pre_xmit_response()
2818 prm->residual, se_cmd->tag, se_cmd->t_task_cdb ? in qlt_pre_xmit_response()
2819 se_cmd->t_task_cdb[0] : 0, cmd->bufflen, prm->rq_result); in qlt_pre_xmit_response()
2820 prm->rq_result |= SS_RESIDUAL_OVER; in qlt_pre_xmit_response()
2829 if (QLA_TGT_SENSE_VALID(prm->sense_buffer) || in qlt_pre_xmit_response()
2830 (IS_FWI2_CAPABLE(cmd->vha->hw) && in qlt_pre_xmit_response()
2831 (prm->rq_result != 0))) { in qlt_pre_xmit_response()
2832 prm->add_status_pkt = 1; in qlt_pre_xmit_response()
2844 if (cmd->qpair->enable_class_2) in qlt_need_explicit_conf()
2848 return cmd->conf_compl_supported; in qlt_need_explicit_conf()
2850 return cmd->qpair->enable_explicit_conf && in qlt_need_explicit_conf()
2851 cmd->conf_compl_supported; in qlt_need_explicit_conf()
2857 prm->sense_buffer_len = min_t(uint32_t, prm->sense_buffer_len, in qlt_24xx_init_ctio_to_isp()
2858 (uint32_t)sizeof(ctio->u.status1.sense_data)); in qlt_24xx_init_ctio_to_isp()
2859 ctio->u.status0.flags |= cpu_to_le16(CTIO7_FLAGS_SEND_STATUS); in qlt_24xx_init_ctio_to_isp()
2860 if (qlt_need_explicit_conf(prm->cmd, 0)) { in qlt_24xx_init_ctio_to_isp()
2861 ctio->u.status0.flags |= cpu_to_le16( in qlt_24xx_init_ctio_to_isp()
2865 ctio->u.status0.residual = cpu_to_le32(prm->residual); in qlt_24xx_init_ctio_to_isp()
2866 ctio->u.status0.scsi_status = cpu_to_le16(prm->rq_result); in qlt_24xx_init_ctio_to_isp()
2867 if (QLA_TGT_SENSE_VALID(prm->sense_buffer)) { in qlt_24xx_init_ctio_to_isp()
2870 if (qlt_need_explicit_conf(prm->cmd, 1)) { in qlt_24xx_init_ctio_to_isp()
2871 if ((prm->rq_result & SS_SCSI_STATUS_BYTE) != 0) { in qlt_24xx_init_ctio_to_isp()
2872 ql_dbg_qp(ql_dbg_tgt, prm->cmd->qpair, 0xe017, in qlt_24xx_init_ctio_to_isp()
2878 ctio->u.status1.flags |= cpu_to_le16( in qlt_24xx_init_ctio_to_isp()
2883 ctio->u.status1.flags &= in qlt_24xx_init_ctio_to_isp()
2885 ctio->u.status1.flags |= in qlt_24xx_init_ctio_to_isp()
2887 ctio->u.status1.scsi_status |= in qlt_24xx_init_ctio_to_isp()
2889 ctio->u.status1.sense_length = in qlt_24xx_init_ctio_to_isp()
2890 cpu_to_le16(prm->sense_buffer_len); in qlt_24xx_init_ctio_to_isp()
2891 for (i = 0; i < prm->sense_buffer_len/4; i++) { in qlt_24xx_init_ctio_to_isp()
2895 &((uint32_t *)prm->sense_buffer)[i]); in qlt_24xx_init_ctio_to_isp()
2897 &((uint32_t *)ctio->u.status1.sense_data)[i]); in qlt_24xx_init_ctio_to_isp()
2902 ctio->u.status1.flags &= in qlt_24xx_init_ctio_to_isp()
2904 ctio->u.status1.flags |= in qlt_24xx_init_ctio_to_isp()
2906 ctio->u.status1.sense_length = 0; in qlt_24xx_init_ctio_to_isp()
2907 memset(ctio->u.status1.sense_data, 0, in qlt_24xx_init_ctio_to_isp()
2908 sizeof(ctio->u.status1.sense_data)); in qlt_24xx_init_ctio_to_isp()
2917 switch (se_cmd->prot_op) { in qlt_hba_err_chk_enabled()
2940 switch (se_cmd->prot_op) { in qla_tgt_ref_mask_check()
2955 * qla_tgt_set_dif_tags - Extract Ref and App tags from SCSI command
2961 struct se_cmd *se_cmd = &cmd->se_cmd; in qla_tgt_set_dif_tags()
2962 uint32_t lba = 0xffffffff & se_cmd->t_task_lba; in qla_tgt_set_dif_tags()
2963 scsi_qla_host_t *vha = cmd->tgt->vha; in qla_tgt_set_dif_tags()
2964 struct qla_hw_data *ha = vha->hw; in qla_tgt_set_dif_tags()
2972 ctx->app_tag = 0; in qla_tgt_set_dif_tags()
2973 ctx->app_tag_mask[0] = 0x0; in qla_tgt_set_dif_tags()
2974 ctx->app_tag_mask[1] = 0x0; in qla_tgt_set_dif_tags()
2977 if ((se_cmd->prot_type == TARGET_DIF_TYPE1_PROT) || in qla_tgt_set_dif_tags()
2978 (se_cmd->prot_type == TARGET_DIF_TYPE2_PROT)) in qla_tgt_set_dif_tags()
2980 else if (se_cmd->prot_type == TARGET_DIF_TYPE3_PROT) in qla_tgt_set_dif_tags()
2984 t32 = ha->tgt.tgt_ops->get_dif_tags(cmd, pfw_prot_opts); in qla_tgt_set_dif_tags()
2986 switch (se_cmd->prot_type) { in qla_tgt_set_dif_tags()
2993 ctx->ref_tag = cpu_to_le32(lba); in qla_tgt_set_dif_tags()
2995 ctx->ref_tag_mask[0] = 0xff; in qla_tgt_set_dif_tags()
2996 ctx->ref_tag_mask[1] = 0xff; in qla_tgt_set_dif_tags()
2997 ctx->ref_tag_mask[2] = 0xff; in qla_tgt_set_dif_tags()
2998 ctx->ref_tag_mask[3] = 0xff; in qla_tgt_set_dif_tags()
3005 ctx->ref_tag = cpu_to_le32(lba); in qla_tgt_set_dif_tags()
3007 !(ha->tgt.tgt_ops->chk_dif_tags(t32))) { in qla_tgt_set_dif_tags()
3012 ctx->ref_tag_mask[0] = 0xff; in qla_tgt_set_dif_tags()
3013 ctx->ref_tag_mask[1] = 0xff; in qla_tgt_set_dif_tags()
3014 ctx->ref_tag_mask[2] = 0xff; in qla_tgt_set_dif_tags()
3015 ctx->ref_tag_mask[3] = 0xff; in qla_tgt_set_dif_tags()
3022 ctx->ref_tag = cpu_to_le32(lba); in qla_tgt_set_dif_tags()
3024 !(ha->tgt.tgt_ops->chk_dif_tags(t32))) { in qla_tgt_set_dif_tags()
3029 ctx->ref_tag_mask[0] = 0xff; in qla_tgt_set_dif_tags()
3030 ctx->ref_tag_mask[1] = 0xff; in qla_tgt_set_dif_tags()
3031 ctx->ref_tag_mask[2] = 0xff; in qla_tgt_set_dif_tags()
3032 ctx->ref_tag_mask[3] = 0xff; in qla_tgt_set_dif_tags()
3037 ctx->ref_tag_mask[0] = ctx->ref_tag_mask[1] = in qla_tgt_set_dif_tags()
3038 ctx->ref_tag_mask[2] = ctx->ref_tag_mask[3] = 0x00; in qla_tgt_set_dif_tags()
3056 struct qla_tgt_cmd *cmd = prm->cmd; in qlt_build_ctio_crc2_pkt()
3057 struct se_cmd *se_cmd = &cmd->se_cmd; in qlt_build_ctio_crc2_pkt()
3059 struct atio_from_isp *atio = &prm->cmd->atio; in qlt_build_ctio_crc2_pkt()
3062 scsi_qla_host_t *vha = cmd->vha; in qlt_build_ctio_crc2_pkt()
3064 ha = vha->hw; in qlt_build_ctio_crc2_pkt()
3066 pkt = (struct ctio_crc2_to_fw *)qpair->req->ring_ptr; in qlt_build_ctio_crc2_pkt()
3067 prm->pkt = pkt; in qlt_build_ctio_crc2_pkt()
3070 ql_dbg_qp(ql_dbg_tgt, cmd->qpair, 0xe071, in qlt_build_ctio_crc2_pkt()
3072 cmd->vp_idx, __func__, se_cmd, se_cmd->prot_op, in qlt_build_ctio_crc2_pkt()
3073 prm->prot_sg, prm->prot_seg_cnt, se_cmd->t_task_lba); in qlt_build_ctio_crc2_pkt()
3075 if ((se_cmd->prot_op == TARGET_PROT_DIN_INSERT) || in qlt_build_ctio_crc2_pkt()
3076 (se_cmd->prot_op == TARGET_PROT_DOUT_STRIP)) in qlt_build_ctio_crc2_pkt()
3080 data_bytes = cmd->bufflen; in qlt_build_ctio_crc2_pkt()
3081 dif_bytes = (data_bytes / cmd->blk_sz) * 8; in qlt_build_ctio_crc2_pkt()
3083 switch (se_cmd->prot_op) { in qlt_build_ctio_crc2_pkt()
3087 if (cmd->prot_sg_cnt) in qlt_build_ctio_crc2_pkt()
3105 if ((se_cmd->prot_type == TARGET_DIF_TYPE1_PROT) || in qlt_build_ctio_crc2_pkt()
3106 (se_cmd->prot_type == TARGET_DIF_TYPE2_PROT)) in qlt_build_ctio_crc2_pkt()
3108 else if (se_cmd->prot_type == TARGET_DIF_TYPE3_PROT) in qlt_build_ctio_crc2_pkt()
3112 switch (se_cmd->prot_op) { in qlt_build_ctio_crc2_pkt()
3124 /* FUTURE: does tcm require T10CRC<->IPCKSUM conversion? */ in qlt_build_ctio_crc2_pkt()
3131 /* ---- PKT ---- */ in qlt_build_ctio_crc2_pkt()
3133 pkt->entry_type = CTIO_CRC2; in qlt_build_ctio_crc2_pkt()
3134 pkt->entry_count = 1; in qlt_build_ctio_crc2_pkt()
3135 pkt->vp_index = cmd->vp_idx; in qlt_build_ctio_crc2_pkt()
3144 return -EAGAIN; in qlt_build_ctio_crc2_pkt()
3146 qpair->req->outstanding_cmds[h] = (srb_t *)prm->cmd; in qlt_build_ctio_crc2_pkt()
3148 pkt->handle = make_handle(qpair->req->id, h); in qlt_build_ctio_crc2_pkt()
3149 pkt->handle |= CTIO_COMPLETION_HANDLE_MARK; in qlt_build_ctio_crc2_pkt()
3150 pkt->nport_handle = cpu_to_le16(prm->cmd->loop_id); in qlt_build_ctio_crc2_pkt()
3151 pkt->timeout = cpu_to_le16(QLA_TGT_TIMEOUT); in qlt_build_ctio_crc2_pkt()
3152 pkt->initiator_id = be_id_to_le(atio->u.isp24.fcp_hdr.s_id); in qlt_build_ctio_crc2_pkt()
3153 pkt->exchange_addr = atio->u.isp24.exchange_addr; in qlt_build_ctio_crc2_pkt()
3156 t16 = be16_to_cpu(atio->u.isp24.fcp_hdr.ox_id); in qlt_build_ctio_crc2_pkt()
3157 pkt->ox_id = cpu_to_le16(t16); in qlt_build_ctio_crc2_pkt()
3159 t16 = (atio->u.isp24.attr << 9); in qlt_build_ctio_crc2_pkt()
3160 pkt->flags |= cpu_to_le16(t16); in qlt_build_ctio_crc2_pkt()
3161 pkt->relative_offset = cpu_to_le32(prm->cmd->offset); in qlt_build_ctio_crc2_pkt()
3164 if (cmd->dma_data_direction == DMA_TO_DEVICE) in qlt_build_ctio_crc2_pkt()
3165 pkt->flags = cpu_to_le16(CTIO7_FLAGS_DATA_IN); in qlt_build_ctio_crc2_pkt()
3166 else if (cmd->dma_data_direction == DMA_FROM_DEVICE) in qlt_build_ctio_crc2_pkt()
3167 pkt->flags = cpu_to_le16(CTIO7_FLAGS_DATA_OUT); in qlt_build_ctio_crc2_pkt()
3169 pkt->dseg_count = cpu_to_le16(prm->tot_dsds); in qlt_build_ctio_crc2_pkt()
3171 pkt->transfer_length = cpu_to_le32(transfer_length); in qlt_build_ctio_crc2_pkt()
3173 /* ----- CRC context -------- */ in qlt_build_ctio_crc2_pkt()
3176 crc_ctx_pkt = cmd->ctx = in qlt_build_ctio_crc2_pkt()
3177 dma_pool_zalloc(ha->dl_dma_pool, GFP_ATOMIC, &crc_ctx_dma); in qlt_build_ctio_crc2_pkt()
3182 crc_ctx_pkt->crc_ctx_dma = crc_ctx_dma; in qlt_build_ctio_crc2_pkt()
3183 INIT_LIST_HEAD(&crc_ctx_pkt->dsd_list); in qlt_build_ctio_crc2_pkt()
3186 crc_ctx_pkt->handle = pkt->handle; in qlt_build_ctio_crc2_pkt()
3190 put_unaligned_le64(crc_ctx_dma, &pkt->crc_context_address); in qlt_build_ctio_crc2_pkt()
3191 pkt->crc_context_len = cpu_to_le16(CRC_CONTEXT_LEN_FW); in qlt_build_ctio_crc2_pkt()
3194 cur_dsd = &crc_ctx_pkt->u.nobundling.data_dsd[0]; in qlt_build_ctio_crc2_pkt()
3201 crc_ctx_pkt->u.bundling.dif_byte_count = cpu_to_le32(dif_bytes); in qlt_build_ctio_crc2_pkt()
3202 crc_ctx_pkt->u.bundling.dseg_count = in qlt_build_ctio_crc2_pkt()
3203 cpu_to_le16(prm->tot_dsds - prm->prot_seg_cnt); in qlt_build_ctio_crc2_pkt()
3204 cur_dsd = &crc_ctx_pkt->u.bundling.data_dsd[0]; in qlt_build_ctio_crc2_pkt()
3208 crc_ctx_pkt->blk_size = cpu_to_le16(cmd->blk_sz); in qlt_build_ctio_crc2_pkt()
3209 crc_ctx_pkt->prot_opts = cpu_to_le16(fw_prot_opts); in qlt_build_ctio_crc2_pkt()
3210 crc_ctx_pkt->byte_count = cpu_to_le32(data_bytes); in qlt_build_ctio_crc2_pkt()
3211 crc_ctx_pkt->guard_seed = cpu_to_le16(0); in qlt_build_ctio_crc2_pkt()
3215 tc.blk_sz = cmd->blk_sz; in qlt_build_ctio_crc2_pkt()
3216 tc.bufflen = cmd->bufflen; in qlt_build_ctio_crc2_pkt()
3217 tc.sg = cmd->sg; in qlt_build_ctio_crc2_pkt()
3218 tc.prot_sg = cmd->prot_sg; in qlt_build_ctio_crc2_pkt()
3220 tc.ctx_dsd_alloced = &cmd->ctx_dsd_alloced; in qlt_build_ctio_crc2_pkt()
3223 pkt->flags |= cpu_to_le16(CTIO7_FLAGS_DSD_PTR); in qlt_build_ctio_crc2_pkt()
3225 if (!bundling && prm->prot_seg_cnt) { in qlt_build_ctio_crc2_pkt()
3227 prm->tot_dsds, &tc)) in qlt_build_ctio_crc2_pkt()
3230 (prm->tot_dsds - prm->prot_seg_cnt), &tc)) in qlt_build_ctio_crc2_pkt()
3233 if (bundling && prm->prot_seg_cnt) { in qlt_build_ctio_crc2_pkt()
3235 pkt->add_flags |= CTIO_CRC2_AF_DIF_DSD_ENA; in qlt_build_ctio_crc2_pkt()
3237 cur_dsd = &crc_ctx_pkt->u.bundling.dif_dsd; in qlt_build_ctio_crc2_pkt()
3239 prm->prot_seg_cnt, cmd)) in qlt_build_ctio_crc2_pkt()
3246 qpair->req->outstanding_cmds[h] = NULL; in qlt_build_ctio_crc2_pkt()
3258 struct scsi_qla_host *vha = cmd->vha; in qlt_xmit_response()
3259 struct qla_qpair *qpair = cmd->qpair; in qlt_xmit_response()
3266 if (!qpair->fw_started || (cmd->reset_count != qpair->chip_reset) || in qlt_xmit_response()
3267 (cmd->sess && cmd->sess->deleted)) { in qlt_xmit_response()
3268 cmd->state = QLA_TGT_STATE_PROCESSED; in qlt_xmit_response()
3273 …"is_send_status=%d, cmd->bufflen=%d, cmd->sg_cnt=%d, cmd->dma_data_direction=%d se_cmd[%p] qp %d\n… in qlt_xmit_response()
3275 1 : 0, cmd->bufflen, cmd->sg_cnt, cmd->dma_data_direction, in qlt_xmit_response()
3276 &cmd->se_cmd, qpair->id); in qlt_xmit_response()
3284 spin_lock_irqsave(qpair->qp_lock_ptr, flags); in qlt_xmit_response()
3287 qpair->tgt_counters.core_qla_snd_status++; in qlt_xmit_response()
3289 qpair->tgt_counters.core_qla_que_buf++; in qlt_xmit_response()
3291 if (!qpair->fw_started || cmd->reset_count != qpair->chip_reset) { in qlt_xmit_response()
3296 cmd->state = QLA_TGT_STATE_PROCESSED; in qlt_xmit_response()
3298 "RESET-RSP online/active/old-count/new-count = %d/%d/%d/%d.\n", in qlt_xmit_response()
3299 vha->flags.online, qla2x00_reset_active(vha), in qlt_xmit_response()
3300 cmd->reset_count, qpair->chip_reset); in qlt_xmit_response()
3310 if (cmd->se_cmd.prot_op && (xmit_type & QLA_TGT_XMIT_DATA)) in qlt_xmit_response()
3315 qpair->req->cnt += full_req_cnt; in qlt_xmit_response()
3322 pkt->u.status0.flags |= in qlt_xmit_response()
3326 if (cmd->se_cmd.prot_op == TARGET_PROT_NORMAL) in qlt_xmit_response()
3331 pkt->u.status0.scsi_status = in qlt_xmit_response()
3333 if (!cmd->edif) in qlt_xmit_response()
3334 pkt->u.status0.residual = in qlt_xmit_response()
3337 pkt->u.status0.flags |= cpu_to_le16( in qlt_xmit_response()
3340 pkt->u.status0.flags |= in qlt_xmit_response()
3355 qpair->req); in qlt_xmit_response()
3367 ctio->entry_count = 1; in qlt_xmit_response()
3368 ctio->entry_type = CTIO_TYPE7; in qlt_xmit_response()
3369 ctio->dseg_count = 0; in qlt_xmit_response()
3370 ctio->u.status1.flags &= ~cpu_to_le16( in qlt_xmit_response()
3374 pkt->handle |= CTIO_INTERMEDIATE_HANDLE_MARK; in qlt_xmit_response()
3375 pkt->u.status0.flags |= cpu_to_le16( in qlt_xmit_response()
3380 * There should be no residual of CTIO-CRC2 data. in qlt_xmit_response()
3389 cmd->state = QLA_TGT_STATE_PROCESSED; /* Mid-level is done processing */ in qlt_xmit_response()
3390 cmd->cmd_sent_to_fw = 1; in qlt_xmit_response()
3391 cmd->ctio_flags = le16_to_cpu(pkt->u.status0.flags); in qlt_xmit_response()
3395 if (qpair->reqq_start_iocbs) in qlt_xmit_response()
3396 qpair->reqq_start_iocbs(qpair); in qlt_xmit_response()
3398 qla2x00_start_iocbs(vha, qpair->req); in qlt_xmit_response()
3399 spin_unlock_irqrestore(qpair->qp_lock_ptr, flags); in qlt_xmit_response()
3405 spin_unlock_irqrestore(qpair->qp_lock_ptr, flags); in qlt_xmit_response()
3414 struct scsi_qla_host *vha = cmd->vha; in qlt_rdy_to_xfer()
3415 struct qla_tgt *tgt = cmd->tgt; in qlt_rdy_to_xfer()
3419 struct qla_qpair *qpair = cmd->qpair; in qlt_rdy_to_xfer()
3427 if (!qpair->fw_started || (cmd->reset_count != qpair->chip_reset) || in qlt_rdy_to_xfer()
3428 (cmd->sess && cmd->sess->deleted)) { in qlt_rdy_to_xfer()
3433 cmd->aborted = 1; in qlt_rdy_to_xfer()
3434 cmd->write_data_transferred = 0; in qlt_rdy_to_xfer()
3435 cmd->state = QLA_TGT_STATE_DATA_IN; in qlt_rdy_to_xfer()
3436 vha->hw->tgt.tgt_ops->handle_data(cmd); in qlt_rdy_to_xfer()
3438 "RESET-XFR online/active/old-count/new-count = %d/%d/%d/%d.\n", in qlt_rdy_to_xfer()
3439 vha->flags.online, qla2x00_reset_active(vha), in qlt_rdy_to_xfer()
3440 cmd->reset_count, qpair->chip_reset); in qlt_rdy_to_xfer()
3446 return -EAGAIN; in qlt_rdy_to_xfer()
3448 spin_lock_irqsave(qpair->qp_lock_ptr, flags); in qlt_rdy_to_xfer()
3453 if (cmd->se_cmd.prot_op) in qlt_rdy_to_xfer()
3459 qpair->req->cnt += prm.req_cnt; in qlt_rdy_to_xfer()
3464 pkt->u.status0.flags |= cpu_to_le16(CTIO7_FLAGS_DATA_OUT | in qlt_rdy_to_xfer()
3467 if (cmd->se_cmd.prot_op == TARGET_PROT_NORMAL) in qlt_rdy_to_xfer()
3470 cmd->state = QLA_TGT_STATE_NEED_DATA; in qlt_rdy_to_xfer()
3471 cmd->cmd_sent_to_fw = 1; in qlt_rdy_to_xfer()
3472 cmd->ctio_flags = le16_to_cpu(pkt->u.status0.flags); in qlt_rdy_to_xfer()
3476 if (qpair->reqq_start_iocbs) in qlt_rdy_to_xfer()
3477 qpair->reqq_start_iocbs(qpair); in qlt_rdy_to_xfer()
3479 qla2x00_start_iocbs(vha, qpair->req); in qlt_rdy_to_xfer()
3480 spin_unlock_irqrestore(qpair->qp_lock_ptr, flags); in qlt_rdy_to_xfer()
3486 spin_unlock_irqrestore(qpair->qp_lock_ptr, flags); in qlt_rdy_to_xfer()
3500 uint8_t *ap = &sts->actual_dif[0]; in qlt_handle_dif_error()
3501 uint8_t *ep = &sts->expected_dif[0]; in qlt_handle_dif_error()
3502 uint64_t lba = cmd->se_cmd.t_task_lba; in qlt_handle_dif_error()
3505 struct scsi_qla_host *vha = cmd->vha; in qlt_handle_dif_error()
3507 cmd->trc_flags |= TRC_DIF_ERR; in qlt_handle_dif_error()
3509 cmd->a_guard = get_unaligned_be16(ap + 0); in qlt_handle_dif_error()
3510 cmd->a_app_tag = get_unaligned_be16(ap + 2); in qlt_handle_dif_error()
3511 cmd->a_ref_tag = get_unaligned_be32(ap + 4); in qlt_handle_dif_error()
3513 cmd->e_guard = get_unaligned_be16(ep + 0); in qlt_handle_dif_error()
3514 cmd->e_app_tag = get_unaligned_be16(ep + 2); in qlt_handle_dif_error()
3515 cmd->e_ref_tag = get_unaligned_be32(ep + 4); in qlt_handle_dif_error()
3518 "%s: aborted %d state %d\n", __func__, cmd->aborted, cmd->state); in qlt_handle_dif_error()
3523 if (cmd->e_app_tag != cmd->a_app_tag) { in qlt_handle_dif_error()
3526 cmd->cdb[0], lba, (lba+cmd->num_blks), cmd->num_blks, in qlt_handle_dif_error()
3527 cmd->a_ref_tag, cmd->e_ref_tag, cmd->a_app_tag, in qlt_handle_dif_error()
3528 cmd->e_app_tag, cmd->a_guard, cmd->e_guard, cmd, in qlt_handle_dif_error()
3529 cmd->atio.u.isp24.fcp_hdr.ox_id); in qlt_handle_dif_error()
3531 cmd->dif_err_code = DIF_ERR_APP; in qlt_handle_dif_error()
3539 if (cmd->e_ref_tag != cmd->a_ref_tag) { in qlt_handle_dif_error()
3542 cmd->cdb[0], lba, (lba+cmd->num_blks), cmd->num_blks, in qlt_handle_dif_error()
3543 cmd->a_ref_tag, cmd->e_ref_tag, cmd->a_app_tag, in qlt_handle_dif_error()
3544 cmd->e_app_tag, cmd->a_guard, cmd->e_guard, cmd, in qlt_handle_dif_error()
3545 cmd->atio.u.isp24.fcp_hdr.ox_id); in qlt_handle_dif_error()
3547 cmd->dif_err_code = DIF_ERR_REF; in qlt_handle_dif_error()
3556 if (cmd->e_guard != cmd->a_guard) { in qlt_handle_dif_error()
3559 cmd->cdb[0], lba, (lba+cmd->num_blks), cmd->num_blks, in qlt_handle_dif_error()
3560 cmd->a_ref_tag, cmd->e_ref_tag, cmd->a_app_tag, in qlt_handle_dif_error()
3561 cmd->e_app_tag, cmd->a_guard, cmd->e_guard, cmd, in qlt_handle_dif_error()
3562 cmd->atio.u.isp24.fcp_hdr.ox_id); in qlt_handle_dif_error()
3564 cmd->dif_err_code = DIF_ERR_GRD; in qlt_handle_dif_error()
3571 switch (cmd->state) { in qlt_handle_dif_error()
3574 cmd->state = QLA_TGT_STATE_DATA_IN; in qlt_handle_dif_error()
3575 vha->hw->tgt.tgt_ops->handle_data(cmd); in qlt_handle_dif_error()
3578 spin_lock_irqsave(&cmd->cmd_lock, flags); in qlt_handle_dif_error()
3579 if (cmd->aborted) { in qlt_handle_dif_error()
3580 spin_unlock_irqrestore(&cmd->cmd_lock, flags); in qlt_handle_dif_error()
3581 vha->hw->tgt.tgt_ops->free_cmd(cmd); in qlt_handle_dif_error()
3584 spin_unlock_irqrestore(&cmd->cmd_lock, flags); in qlt_handle_dif_error()
3591 vha->hw->tgt.tgt_ops->free_cmd(cmd); in qlt_handle_dif_error()
3602 struct qla_hw_data *ha = vha->hw; in __qlt_send_term_imm_notif()
3613 "request packet\n", vha->vp_idx, __func__); in __qlt_send_term_imm_notif()
3614 return -ENOMEM; in __qlt_send_term_imm_notif()
3617 pkt->entry_type = NOTIFY_ACK_TYPE; in __qlt_send_term_imm_notif()
3618 pkt->entry_count = 1; in __qlt_send_term_imm_notif()
3619 pkt->handle = QLA_TGT_SKIP_HANDLE; in __qlt_send_term_imm_notif()
3622 nack->ox_id = ntfy->ox_id; in __qlt_send_term_imm_notif()
3624 nack->u.isp24.nport_handle = ntfy->u.isp24.nport_handle; in __qlt_send_term_imm_notif()
3625 if (le16_to_cpu(ntfy->u.isp24.status) == IMM_NTFY_ELS) { in __qlt_send_term_imm_notif()
3626 nack->u.isp24.flags = ntfy->u.isp24.flags & in __qlt_send_term_imm_notif()
3631 nack->u.isp24.flags |= in __qlt_send_term_imm_notif()
3634 nack->u.isp24.srr_rx_id = ntfy->u.isp24.srr_rx_id; in __qlt_send_term_imm_notif()
3635 nack->u.isp24.status = ntfy->u.isp24.status; in __qlt_send_term_imm_notif()
3636 nack->u.isp24.status_subcode = ntfy->u.isp24.status_subcode; in __qlt_send_term_imm_notif()
3637 nack->u.isp24.fw_handle = ntfy->u.isp24.fw_handle; in __qlt_send_term_imm_notif()
3638 nack->u.isp24.exchange_address = ntfy->u.isp24.exchange_address; in __qlt_send_term_imm_notif()
3639 nack->u.isp24.srr_rel_offs = ntfy->u.isp24.srr_rel_offs; in __qlt_send_term_imm_notif()
3640 nack->u.isp24.srr_ui = ntfy->u.isp24.srr_ui; in __qlt_send_term_imm_notif()
3641 nack->u.isp24.vp_index = ntfy->u.isp24.vp_index; in __qlt_send_term_imm_notif()
3643 qla2x00_start_iocbs(vha, vha->req); in __qlt_send_term_imm_notif()
3665 struct scsi_qla_host *vha = qpair->vha; in __qlt_send_term_exchange()
3667 struct qla_hw_data *ha = vha->hw; in __qlt_send_term_exchange()
3675 vha = cmd->vha; in __qlt_send_term_exchange()
3681 "request packet\n", vha->vp_idx, __func__); in __qlt_send_term_exchange()
3682 return -ENOMEM; in __qlt_send_term_exchange()
3686 if (cmd->state < QLA_TGT_STATE_PROCESSED) { in __qlt_send_term_exchange()
3689 "incorrect state %d\n", vha->vp_idx, cmd, in __qlt_send_term_exchange()
3690 cmd->state); in __qlt_send_term_exchange()
3695 qpair->tgt_counters.num_term_xchg_sent++; in __qlt_send_term_exchange()
3696 pkt->entry_count = 1; in __qlt_send_term_exchange()
3697 pkt->handle = QLA_TGT_SKIP_HANDLE | CTIO_COMPLETION_HANDLE_MARK; in __qlt_send_term_exchange()
3700 ctio24->entry_type = CTIO_TYPE7; in __qlt_send_term_exchange()
3701 ctio24->nport_handle = cpu_to_le16(CTIO7_NHANDLE_UNRECOGNIZED); in __qlt_send_term_exchange()
3702 ctio24->timeout = cpu_to_le16(QLA_TGT_TIMEOUT); in __qlt_send_term_exchange()
3703 ctio24->vp_index = vha->vp_idx; in __qlt_send_term_exchange()
3704 ctio24->initiator_id = be_id_to_le(atio->u.isp24.fcp_hdr.s_id); in __qlt_send_term_exchange()
3705 ctio24->exchange_addr = atio->u.isp24.exchange_addr; in __qlt_send_term_exchange()
3706 temp = (atio->u.isp24.attr << 9) | CTIO7_FLAGS_STATUS_MODE_1 | in __qlt_send_term_exchange()
3708 ctio24->u.status1.flags = cpu_to_le16(temp); in __qlt_send_term_exchange()
3709 temp = be16_to_cpu(atio->u.isp24.fcp_hdr.ox_id); in __qlt_send_term_exchange()
3710 ctio24->u.status1.ox_id = cpu_to_le16(temp); in __qlt_send_term_exchange()
3714 if (qpair->reqq_start_iocbs) in __qlt_send_term_exchange()
3715 qpair->reqq_start_iocbs(qpair); in __qlt_send_term_exchange()
3717 qla2x00_start_iocbs(vha, qpair->req); in __qlt_send_term_exchange()
3731 vha = cmd->vha; in qlt_send_term_exchange()
3733 vha = qpair->vha; in qlt_send_term_exchange()
3737 if (rc == -ENOMEM) in qlt_send_term_exchange()
3741 spin_lock_irqsave(qpair->qp_lock_ptr, flags); in qlt_send_term_exchange()
3743 if (rc == -ENOMEM) in qlt_send_term_exchange()
3747 if (cmd && !ul_abort && !cmd->aborted) { in qlt_send_term_exchange()
3748 if (cmd->sg_mapped) in qlt_send_term_exchange()
3750 vha->hw->tgt.tgt_ops->free_cmd(cmd); in qlt_send_term_exchange()
3754 spin_unlock_irqrestore(qpair->qp_lock_ptr, flags); in qlt_send_term_exchange()
3764 vha->hw->tgt.leak_exchg_thresh_hold = in qlt_init_term_exchange()
3765 (vha->hw->cur_fw_xcb_count/100) * LEAK_EXCHG_THRESH_HOLD_PERCENT; in qlt_init_term_exchange()
3768 if (!list_empty(&vha->hw->tgt.q_full_list)) { in qlt_init_term_exchange()
3770 list_splice_init(&vha->hw->tgt.q_full_list, &free_list); in qlt_init_term_exchange()
3773 list_del(&cmd->cmd_list); in qlt_init_term_exchange()
3778 vha->hw->tgt.num_qfull_cmds_alloc--; in qlt_init_term_exchange()
3781 vha->hw->tgt.num_qfull_cmds_dropped = 0; in qlt_init_term_exchange()
3788 total_leaked = vha->hw->tgt.num_qfull_cmds_dropped; in qlt_chk_exch_leak_thresh_hold()
3790 if (vha->hw->tgt.leak_exchg_thresh_hold && in qlt_chk_exch_leak_thresh_hold()
3791 (total_leaked > vha->hw->tgt.leak_exchg_thresh_hold)) { in qlt_chk_exch_leak_thresh_hold()
3795 total_leaked, vha->hw->cur_fw_xcb_count); in qlt_chk_exch_leak_thresh_hold()
3797 if (IS_P3P_TYPE(vha->hw)) in qlt_chk_exch_leak_thresh_hold()
3798 set_bit(FCOE_CTX_RESET_NEEDED, &vha->dpc_flags); in qlt_chk_exch_leak_thresh_hold()
3800 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); in qlt_chk_exch_leak_thresh_hold()
3808 struct qla_tgt *tgt = cmd->tgt; in qlt_abort_cmd()
3809 struct scsi_qla_host *vha = tgt->vha; in qlt_abort_cmd()
3810 struct se_cmd *se_cmd = &cmd->se_cmd; in qlt_abort_cmd()
3815 "(se_cmd=%p, tag=%llu)", vha->vp_idx, cmd, &cmd->se_cmd, in qlt_abort_cmd()
3816 se_cmd->tag); in qlt_abort_cmd()
3818 spin_lock_irqsave(&cmd->cmd_lock, flags); in qlt_abort_cmd()
3819 if (cmd->aborted) { in qlt_abort_cmd()
3820 if (cmd->sg_mapped) in qlt_abort_cmd()
3823 spin_unlock_irqrestore(&cmd->cmd_lock, flags); in qlt_abort_cmd()
3825 * It's normal to see 2 calls in this path: in qlt_abort_cmd()
3827 * 2) TCM TMR - drain_state_list in qlt_abort_cmd()
3831 "se_cmd_flags %x\n", cmd, cmd->se_cmd.transport_state, in qlt_abort_cmd()
3832 cmd->se_cmd.t_state, cmd->se_cmd.se_cmd_flags); in qlt_abort_cmd()
3833 return -EIO; in qlt_abort_cmd()
3835 cmd->aborted = 1; in qlt_abort_cmd()
3836 cmd->trc_flags |= TRC_ABORT; in qlt_abort_cmd()
3837 spin_unlock_irqrestore(&cmd->cmd_lock, flags); in qlt_abort_cmd()
3839 qlt_send_term_exchange(cmd->qpair, cmd, &cmd->atio, 0, 1); in qlt_abort_cmd()
3846 struct fc_port *sess = cmd->sess; in qlt_free_cmd()
3848 ql_dbg(ql_dbg_tgt, cmd->vha, 0xe074, in qlt_free_cmd()
3850 __func__, &cmd->se_cmd, in qlt_free_cmd()
3851 be16_to_cpu(cmd->atio.u.isp24.fcp_hdr.ox_id)); in qlt_free_cmd()
3853 BUG_ON(cmd->cmd_in_wq); in qlt_free_cmd()
3855 if (!cmd->q_full) in qlt_free_cmd()
3856 qlt_decr_num_pend_cmds(cmd->vha); in qlt_free_cmd()
3858 BUG_ON(cmd->sg_mapped); in qlt_free_cmd()
3859 cmd->jiffies_at_free = get_jiffies_64(); in qlt_free_cmd()
3861 if (!sess || !sess->se_sess) { in qlt_free_cmd()
3865 cmd->jiffies_at_free = get_jiffies_64(); in qlt_free_cmd()
3866 cmd->vha->hw->tgt.tgt_ops->rel_cmd(cmd); in qlt_free_cmd()
3871 * ha->hardware_lock supposed to be held on entry. Might drop it, then reaquire
3877 struct scsi_qla_host *vha = qpair->vha; in qlt_term_ctio_exchange()
3879 if (cmd->se_cmd.prot_op) in qlt_term_ctio_exchange()
3883 cmd->lba, cmd->lba, in qlt_term_ctio_exchange()
3884 cmd->num_blks, &cmd->se_cmd, in qlt_term_ctio_exchange()
3885 cmd->atio.u.isp24.exchange_addr, in qlt_term_ctio_exchange()
3886 cmd->se_cmd.prot_op, in qlt_term_ctio_exchange()
3887 prot_op_str(cmd->se_cmd.prot_op)); in qlt_term_ctio_exchange()
3892 term = !(c->flags & in qlt_term_ctio_exchange()
3898 qlt_send_term_exchange(qpair, cmd, &cmd->atio, 1, 0); in qlt_term_ctio_exchange()
3904 /* ha->hardware_lock supposed to be held on entry */
3916 if (qid == rsp->req->id) { in qlt_ctio_to_cmd()
3917 req = rsp->req; in qlt_ctio_to_cmd()
3918 } else if (vha->hw->req_q_map[qid]) { in qlt_ctio_to_cmd()
3921 vha->vp_idx, rsp->id, handle); in qlt_ctio_to_cmd()
3922 req = vha->hw->req_q_map[qid]; in qlt_ctio_to_cmd()
3930 if (unlikely(h >= req->num_outstanding_cmds)) { in qlt_ctio_to_cmd()
3933 vha->vp_idx, handle); in qlt_ctio_to_cmd()
3937 cmd = req->outstanding_cmds[h]; in qlt_ctio_to_cmd()
3940 … "qla_target(%d): Suspicious: unable to find the command with handle %x req->id %d rsp->id %d\n", in qlt_ctio_to_cmd()
3941 vha->vp_idx, handle, req->id, rsp->id); in qlt_ctio_to_cmd()
3944 req->outstanding_cmds[h] = NULL; in qlt_ctio_to_cmd()
3949 "support NULL handles\n", vha->vp_idx); in qlt_ctio_to_cmd()
3957 * ha->hardware_lock supposed to be held on entry. Might drop it, then reaquire
3962 struct qla_hw_data *ha = vha->hw; in qlt_do_ctio_completion()
3965 struct qla_qpair *qpair = rsp->qpair; in qlt_do_ctio_completion()
3981 if ((le16_to_cpu(((struct ctio7_from_24xx *)ctio)->flags) & CTIO7_FLAGS_DATA_OUT) && in qlt_do_ctio_completion()
3982 cmd->sess) { in qlt_do_ctio_completion()
3983 qlt_chk_edif_rx_sa_delete_pending(vha, cmd->sess, in qlt_do_ctio_completion()
3987 se_cmd = &cmd->se_cmd; in qlt_do_ctio_completion()
3988 cmd->cmd_sent_to_fw = 0; in qlt_do_ctio_completion()
3996 dev_info(&vha->hw->pdev->dev, in qlt_do_ctio_completion()
3998 vha->vp_idx, cmd->atio.u.isp24.attr, in qlt_do_ctio_completion()
3999 ((cmd->ctio_flags >> 9) & 0xf), in qlt_do_ctio_completion()
4000 cmd->ctio_flags); in qlt_do_ctio_completion()
4013 "TIMEOUT=b, INVALID_RX_ID=8)\n", vha->vp_idx, in qlt_do_ctio_completion()
4014 status, cmd->state, se_cmd); in qlt_do_ctio_completion()
4025 "received (state %x, se_cmd %p)\n", vha->vp_idx, in qlt_do_ctio_completion()
4027 status, cmd->state, se_cmd); in qlt_do_ctio_completion()
4029 if (logged_out && cmd->sess) { in qlt_do_ctio_completion()
4034 cmd->sess->send_els_logo = 1; in qlt_do_ctio_completion()
4037 __func__, __LINE__, cmd->sess->port_name); in qlt_do_ctio_completion()
4039 qlt_schedule_sess_for_deletion(cmd->sess); in qlt_do_ctio_completion()
4050 vha->vp_idx, status, cmd->state, se_cmd, in qlt_do_ctio_completion()
4051 *((u64 *)&crc->actual_dif[0]), in qlt_do_ctio_completion()
4052 *((u64 *)&crc->expected_dif[0])); in qlt_do_ctio_completion()
4064 vha->vp_idx, status, cmd->state, se_cmd); in qlt_do_ctio_completion()
4070 vha->vp_idx, status, cmd->state, se_cmd); in qlt_do_ctio_completion()
4075 /* "cmd->aborted" means in qlt_do_ctio_completion()
4081 if ((cmd->state != QLA_TGT_STATE_NEED_DATA) && in qlt_do_ctio_completion()
4082 (!cmd->aborted)) { in qlt_do_ctio_completion()
4083 cmd->trc_flags |= TRC_CTIO_ERR; in qlt_do_ctio_completion()
4089 if (cmd->state == QLA_TGT_STATE_PROCESSED) { in qlt_do_ctio_completion()
4090 cmd->trc_flags |= TRC_CTIO_DONE; in qlt_do_ctio_completion()
4091 } else if (cmd->state == QLA_TGT_STATE_NEED_DATA) { in qlt_do_ctio_completion()
4092 cmd->state = QLA_TGT_STATE_DATA_IN; in qlt_do_ctio_completion()
4095 cmd->write_data_transferred = 1; in qlt_do_ctio_completion()
4097 ha->tgt.tgt_ops->handle_data(cmd); in qlt_do_ctio_completion()
4099 } else if (cmd->aborted) { in qlt_do_ctio_completion()
4100 cmd->trc_flags |= TRC_CTIO_ABORTED; in qlt_do_ctio_completion()
4102 "Aborted command %p (tag %lld) finished\n", cmd, se_cmd->tag); in qlt_do_ctio_completion()
4104 cmd->trc_flags |= TRC_CTIO_STRANGE; in qlt_do_ctio_completion()
4107 "not return a CTIO complete\n", vha->vp_idx, cmd->state); in qlt_do_ctio_completion()
4111 !cmd->aborted) { in qlt_do_ctio_completion()
4116 ha->tgt.tgt_ops->free_cmd(cmd); in qlt_do_ctio_completion()
4152 * Process context for I/O path into tcm_qla2xxx code
4156 scsi_qla_host_t *vha = cmd->vha; in __qlt_do_work()
4157 struct qla_hw_data *ha = vha->hw; in __qlt_do_work()
4158 struct fc_port *sess = cmd->sess; in __qlt_do_work()
4159 struct atio_from_isp *atio = &cmd->atio; in __qlt_do_work()
4164 struct qla_qpair *qpair = cmd->qpair; in __qlt_do_work()
4166 cmd->cmd_in_wq = 0; in __qlt_do_work()
4167 cmd->trc_flags |= TRC_DO_WORK; in __qlt_do_work()
4169 if (cmd->aborted) { in __qlt_do_work()
4172 cmd->atio.u.isp24.exchange_addr); in __qlt_do_work()
4176 spin_lock_init(&cmd->cmd_lock); in __qlt_do_work()
4177 cdb = &atio->u.isp24.fcp_cmnd.cdb[0]; in __qlt_do_work()
4178 cmd->se_cmd.tag = le32_to_cpu(atio->u.isp24.exchange_addr); in __qlt_do_work()
4180 if (atio->u.isp24.fcp_cmnd.rddata && in __qlt_do_work()
4181 atio->u.isp24.fcp_cmnd.wrdata) { in __qlt_do_work()
4184 } else if (atio->u.isp24.fcp_cmnd.rddata) in __qlt_do_work()
4186 else if (atio->u.isp24.fcp_cmnd.wrdata) in __qlt_do_work()
4192 atio->u.isp24.fcp_cmnd.task_attr); in __qlt_do_work()
4195 ret = ha->tgt.tgt_ops->handle_cmd(vha, cmd, cdb, data_length, in __qlt_do_work()
4202 ha->tgt.tgt_ops->put_sess(sess); in __qlt_do_work()
4211 cmd->trc_flags |= TRC_DO_WORK_ERR; in __qlt_do_work()
4212 spin_lock_irqsave(qpair->qp_lock_ptr, flags); in __qlt_do_work()
4213 qlt_send_term_exchange(qpair, NULL, &cmd->atio, 1, 0); in __qlt_do_work()
4216 cmd->vha->hw->tgt.tgt_ops->rel_cmd(cmd); in __qlt_do_work()
4217 spin_unlock_irqrestore(qpair->qp_lock_ptr, flags); in __qlt_do_work()
4219 ha->tgt.tgt_ops->put_sess(sess); in __qlt_do_work()
4225 scsi_qla_host_t *vha = cmd->vha; in qlt_do_work()
4228 spin_lock_irqsave(&vha->cmd_list_lock, flags); in qlt_do_work()
4229 list_del(&cmd->cmd_list); in qlt_do_work()
4230 spin_unlock_irqrestore(&vha->cmd_list_lock, flags); in qlt_do_work()
4238 struct qla_hw_data *ha = vha->hw; in qlt_clr_qp_table()
4239 struct qla_tgt *tgt = vha->vha_tgt.qla_tgt; in qlt_clr_qp_table()
4245 ha->tgt.num_act_qpairs); in qlt_clr_qp_table()
4247 spin_lock_irqsave(&ha->tgt.atio_lock, flags); in qlt_clr_qp_table()
4249 btree_for_each_safe64(&tgt->lun_qpair_map, key, node) in qlt_clr_qp_table()
4250 btree_remove64(&tgt->lun_qpair_map, key); in qlt_clr_qp_table()
4252 ha->base_qpair->lun_cnt = 0; in qlt_clr_qp_table()
4253 for (key = 0; key < ha->max_qpairs; key++) in qlt_clr_qp_table()
4254 if (ha->queue_pair_map[key]) in qlt_clr_qp_table()
4255 ha->queue_pair_map[key]->lun_cnt = 0; in qlt_clr_qp_table()
4257 spin_unlock_irqrestore(&ha->tgt.atio_lock, flags); in qlt_clr_qp_table()
4264 struct qla_tgt *tgt = vha->vha_tgt.qla_tgt; in qlt_assign_qpair()
4267 if (vha->flags.qpairs_available) { in qlt_assign_qpair()
4268 h = btree_lookup64(&tgt->lun_qpair_map, cmd->unpacked_lun); in qlt_assign_qpair()
4273 pci_get_drvdata(vha->hw->pdev); in qlt_assign_qpair()
4275 qpair = vha->hw->base_qpair; in qlt_assign_qpair()
4276 if (qpair->lun_cnt == 0) { in qlt_assign_qpair()
4277 qpair->lun_cnt++; in qlt_assign_qpair()
4280 rc = btree_insert64(&tgt->lun_qpair_map, in qlt_assign_qpair()
4281 cmd->unpacked_lun, h, GFP_ATOMIC); in qlt_assign_qpair()
4283 qpair->lun_cnt--; in qlt_assign_qpair()
4286 cmd->unpacked_lun); in qlt_assign_qpair()
4290 lcnt = qpair->lun_cnt; in qlt_assign_qpair()
4294 list_for_each_entry(qp, &base_vha->qp_list, in qlt_assign_qpair()
4296 if (qp->lun_cnt == 0) { in qlt_assign_qpair()
4297 qp->lun_cnt++; in qlt_assign_qpair()
4300 rc = btree_insert64(&tgt->lun_qpair_map, in qlt_assign_qpair()
4301 cmd->unpacked_lun, h, GFP_ATOMIC); in qlt_assign_qpair()
4303 qp->lun_cnt--; in qlt_assign_qpair()
4306 cmd->unpacked_lun); in qlt_assign_qpair()
4311 if (qp->lun_cnt < lcnt) { in qlt_assign_qpair()
4312 lcnt = qp->lun_cnt; in qlt_assign_qpair()
4319 qpair->lun_cnt++; in qlt_assign_qpair()
4322 rc = btree_insert64(&tgt->lun_qpair_map, in qlt_assign_qpair()
4323 cmd->unpacked_lun, h, GFP_ATOMIC); in qlt_assign_qpair()
4325 qpair->lun_cnt--; in qlt_assign_qpair()
4328 cmd->unpacked_lun); in qlt_assign_qpair()
4332 h = &tgt->qphints[0]; in qlt_assign_qpair()
4335 cmd->qpair = h->qpair; in qlt_assign_qpair()
4336 cmd->se_cmd.cpuid = h->cpuid; in qlt_assign_qpair()
4345 cmd = vha->hw->tgt.tgt_ops->get_cmd(sess); in qlt_get_tag()
4349 cmd->cmd_type = TYPE_TGT_CMD; in qlt_get_tag()
4350 memcpy(&cmd->atio, atio, sizeof(*atio)); in qlt_get_tag()
4351 INIT_LIST_HEAD(&cmd->sess_cmd_list); in qlt_get_tag()
4352 cmd->state = QLA_TGT_STATE_NEW; in qlt_get_tag()
4353 cmd->tgt = vha->vha_tgt.qla_tgt; in qlt_get_tag()
4355 cmd->vha = vha; in qlt_get_tag()
4356 cmd->sess = sess; in qlt_get_tag()
4357 cmd->loop_id = sess->loop_id; in qlt_get_tag()
4358 cmd->conf_compl_supported = sess->conf_compl_supported; in qlt_get_tag()
4360 cmd->trc_flags = 0; in qlt_get_tag()
4361 cmd->jiffies_at_alloc = get_jiffies_64(); in qlt_get_tag()
4363 cmd->unpacked_lun = scsilun_to_int( in qlt_get_tag()
4364 (struct scsi_lun *)&atio->u.isp24.fcp_cmnd.lun); in qlt_get_tag()
4366 cmd->reset_count = vha->hw->base_qpair->chip_reset; in qlt_get_tag()
4367 cmd->vp_idx = vha->vp_idx; in qlt_get_tag()
4368 cmd->edif = sess->edif.enable; in qlt_get_tag()
4373 /* ha->hardware_lock supposed to be held on entry */
4377 struct qla_hw_data *ha = vha->hw; in qlt_handle_cmd_for_atio()
4378 struct qla_tgt *tgt = vha->vha_tgt.qla_tgt; in qlt_handle_cmd_for_atio()
4384 if (unlikely(tgt->tgt_stop)) { in qlt_handle_cmd_for_atio()
4387 return -ENODEV; in qlt_handle_cmd_for_atio()
4390 id = be_to_port_id(atio->u.isp24.fcp_hdr.s_id); in qlt_handle_cmd_for_atio()
4392 return -EBUSY; in qlt_handle_cmd_for_atio()
4394 sess = ha->tgt.tgt_ops->find_sess_by_s_id(vha, atio->u.isp24.fcp_hdr.s_id); in qlt_handle_cmd_for_atio()
4396 return -EFAULT; in qlt_handle_cmd_for_atio()
4400 if (sess->deleted) { in qlt_handle_cmd_for_atio()
4404 return -EFAULT; in qlt_handle_cmd_for_atio()
4408 * Do kref_get() before returning + dropping qla_hw_data->hardware_lock. in qlt_handle_cmd_for_atio()
4410 if (!kref_get_unless_zero(&sess->sess_kref)) { in qlt_handle_cmd_for_atio()
4413 __func__, sess->port_name, in qlt_handle_cmd_for_atio()
4414 be16_to_cpu(atio->u.isp24.fcp_hdr.ox_id)); in qlt_handle_cmd_for_atio()
4415 return -EFAULT; in qlt_handle_cmd_for_atio()
4421 "qla_target(%d): Allocation of cmd failed\n", vha->vp_idx); in qlt_handle_cmd_for_atio()
4422 ha->tgt.tgt_ops->put_sess(sess); in qlt_handle_cmd_for_atio()
4423 return -EBUSY; in qlt_handle_cmd_for_atio()
4426 cmd->cmd_in_wq = 1; in qlt_handle_cmd_for_atio()
4427 cmd->trc_flags |= TRC_NEW_CMD; in qlt_handle_cmd_for_atio()
4429 spin_lock_irqsave(&vha->cmd_list_lock, flags); in qlt_handle_cmd_for_atio()
4430 list_add_tail(&cmd->cmd_list, &vha->qla_cmd_list); in qlt_handle_cmd_for_atio()
4431 spin_unlock_irqrestore(&vha->cmd_list_lock, flags); in qlt_handle_cmd_for_atio()
4433 INIT_WORK(&cmd->work, qlt_do_work); in qlt_handle_cmd_for_atio()
4434 if (vha->flags.qpairs_available) { in qlt_handle_cmd_for_atio()
4435 queue_work_on(cmd->se_cmd.cpuid, qla_tgt_wq, &cmd->work); in qlt_handle_cmd_for_atio()
4436 } else if (ha->msix_count) { in qlt_handle_cmd_for_atio()
4437 if (cmd->atio.u.isp24.fcp_cmnd.rddata) in qlt_handle_cmd_for_atio()
4438 queue_work(qla_tgt_wq, &cmd->work); in qlt_handle_cmd_for_atio()
4440 queue_work_on(cmd->se_cmd.cpuid, qla_tgt_wq, in qlt_handle_cmd_for_atio()
4441 &cmd->work); in qlt_handle_cmd_for_atio()
4443 queue_work(qla_tgt_wq, &cmd->work); in qlt_handle_cmd_for_atio()
4449 /* ha->hardware_lock supposed to be held on entry */
4453 struct scsi_qla_host *vha = sess->vha; in qlt_issue_task_mgmt()
4454 struct qla_hw_data *ha = vha->hw; in qlt_issue_task_mgmt()
4457 struct qla_qpair_hint *h = &vha->vha_tgt.qla_tgt->qphints[0]; in qlt_issue_task_mgmt()
4464 "leak\n", vha->vp_idx); in qlt_issue_task_mgmt()
4465 return -ENOMEM; in qlt_issue_task_mgmt()
4468 mcmd->sess = sess; in qlt_issue_task_mgmt()
4471 memcpy(&mcmd->orig_iocb.imm_ntfy, iocb, in qlt_issue_task_mgmt()
4472 sizeof(mcmd->orig_iocb.imm_ntfy)); in qlt_issue_task_mgmt()
4474 mcmd->tmr_func = fn; in qlt_issue_task_mgmt()
4475 mcmd->flags = flags; in qlt_issue_task_mgmt()
4476 mcmd->reset_count = ha->base_qpair->chip_reset; in qlt_issue_task_mgmt()
4477 mcmd->qpair = h->qpair; in qlt_issue_task_mgmt()
4478 mcmd->vha = vha; in qlt_issue_task_mgmt()
4479 mcmd->se_cmd.cpuid = h->cpuid; in qlt_issue_task_mgmt()
4480 mcmd->unpacked_lun = lun; in qlt_issue_task_mgmt()
4486 abort_cmds_for_lun(vha, lun, a->u.isp24.fcp_hdr.s_id); in qlt_issue_task_mgmt()
4489 h = qlt_find_qphint(vha, mcmd->unpacked_lun); in qlt_issue_task_mgmt()
4490 mcmd->qpair = h->qpair; in qlt_issue_task_mgmt()
4491 mcmd->se_cmd.cpuid = h->cpuid; in qlt_issue_task_mgmt()
4499 /* no-op */ in qlt_issue_task_mgmt()
4503 INIT_WORK(&mcmd->work, qlt_do_tmr_work); in qlt_issue_task_mgmt()
4504 queue_work_on(mcmd->se_cmd.cpuid, qla_tgt_wq, in qlt_issue_task_mgmt()
4505 &mcmd->work); in qlt_issue_task_mgmt()
4510 /* ha->hardware_lock supposed to be held on entry */
4514 struct qla_hw_data *ha = vha->hw; in qlt_handle_task_mgmt()
4520 fn = a->u.isp24.fcp_cmnd.task_mgmt_flags; in qlt_handle_task_mgmt()
4522 spin_lock_irqsave(&ha->tgt.sess_lock, flags); in qlt_handle_task_mgmt()
4523 sess = ha->tgt.tgt_ops->find_sess_by_s_id(vha, in qlt_handle_task_mgmt()
4524 a->u.isp24.fcp_hdr.s_id); in qlt_handle_task_mgmt()
4525 spin_unlock_irqrestore(&ha->tgt.sess_lock, flags); in qlt_handle_task_mgmt()
4528 scsilun_to_int((struct scsi_lun *)&a->u.isp24.fcp_cmnd.lun); in qlt_handle_task_mgmt()
4530 if (sess == NULL || sess->deleted) in qlt_handle_task_mgmt()
4531 return -EFAULT; in qlt_handle_task_mgmt()
4536 /* ha->hardware_lock supposed to be held on entry */
4541 struct qla_hw_data *ha = vha->hw; in __qlt_abort_task()
4550 vha->vp_idx, __func__); in __qlt_abort_task()
4551 return -ENOMEM; in __qlt_abort_task()
4555 mcmd->sess = sess; in __qlt_abort_task()
4556 memcpy(&mcmd->orig_iocb.imm_ntfy, iocb, in __qlt_abort_task()
4557 sizeof(mcmd->orig_iocb.imm_ntfy)); in __qlt_abort_task()
4560 scsilun_to_int((struct scsi_lun *)&a->u.isp24.fcp_cmnd.lun); in __qlt_abort_task()
4561 mcmd->reset_count = ha->base_qpair->chip_reset; in __qlt_abort_task()
4562 mcmd->tmr_func = QLA_TGT_2G_ABORT_TASK; in __qlt_abort_task()
4563 mcmd->qpair = ha->base_qpair; in __qlt_abort_task()
4565 rc = ha->tgt.tgt_ops->handle_tmr(mcmd, unpacked_lun, mcmd->tmr_func, in __qlt_abort_task()
4566 le16_to_cpu(iocb->u.isp2x.seq_id)); in __qlt_abort_task()
4569 "qla_target(%d): tgt_ops->handle_tmr() failed: %d\n", in __qlt_abort_task()
4570 vha->vp_idx, rc); in __qlt_abort_task()
4572 return -EFAULT; in __qlt_abort_task()
4578 /* ha->hardware_lock supposed to be held on entry */
4582 struct qla_hw_data *ha = vha->hw; in qlt_abort_task()
4589 spin_lock_irqsave(&ha->tgt.sess_lock, flags); in qlt_abort_task()
4590 sess = ha->tgt.tgt_ops->find_sess_by_loop_id(vha, loop_id); in qlt_abort_task()
4591 spin_unlock_irqrestore(&ha->tgt.sess_lock, flags); in qlt_abort_task()
4596 "session\n", vha->vp_idx); in qlt_abort_task()
4597 return qlt_sched_sess_work(vha->vha_tgt.qla_tgt, in qlt_abort_task()
4607 ql_dbg(ql_dbg_tgt_mgt, fcport->vha, 0xf093, in qlt_logo_completion_handler()
4612 fcport->se_sess, in qlt_logo_completion_handler()
4614 fcport->port_name, fcport->loop_id, in qlt_logo_completion_handler()
4615 fcport->d_id.b.domain, fcport->d_id.b.area, in qlt_logo_completion_handler()
4616 fcport->d_id.b.al_pa, rc); in qlt_logo_completion_handler()
4619 fcport->logout_completed = 1; in qlt_logo_completion_handler()
4623 * ha->hardware_lock supposed to be held on entry (to protect tgt->sess_list)
4638 list_for_each_entry(other_sess, &vha->vp_fcports, list) { in qlt_find_sess_invalidate_other()
4640 other_wwn = wwn_to_u64(other_sess->port_name); in qlt_find_sess_invalidate_other()
4649 if (port_id.b24 == other_sess->d_id.b24) { in qlt_find_sess_invalidate_other()
4650 if (loop_id != other_sess->loop_id) { in qlt_find_sess_invalidate_other()
4653 other_sess, other_sess->loop_id, other_wwn); in qlt_find_sess_invalidate_other()
4669 other_sess, other_sess->loop_id, other_wwn); in qlt_find_sess_invalidate_other()
4671 other_sess->keep_nport_handle = 1; in qlt_find_sess_invalidate_other()
4672 if (other_sess->disc_state != DSC_DELETED) in qlt_find_sess_invalidate_other()
4680 if ((loop_id == other_sess->loop_id) && in qlt_find_sess_invalidate_other()
4684 other_sess, other_sess->loop_id, other_wwn); in qlt_find_sess_invalidate_other()
4704 key = (((u32)s_id->b.domain << 16) | in abort_cmds_for_s_id()
4705 ((u32)s_id->b.area << 8) | in abort_cmds_for_s_id()
4706 ((u32)s_id->b.al_pa)); in abort_cmds_for_s_id()
4708 spin_lock_irqsave(&vha->cmd_list_lock, flags); in abort_cmds_for_s_id()
4709 list_for_each_entry(op, &vha->unknown_atio_list, cmd_list) { in abort_cmds_for_s_id()
4710 uint32_t op_key = sid_to_key(op->atio.u.isp24.fcp_hdr.s_id); in abort_cmds_for_s_id()
4713 op->aborted = true; in abort_cmds_for_s_id()
4718 list_for_each_entry(cmd, &vha->qla_cmd_list, cmd_list) { in abort_cmds_for_s_id()
4719 uint32_t cmd_key = sid_to_key(cmd->atio.u.isp24.fcp_hdr.s_id); in abort_cmds_for_s_id()
4722 cmd->aborted = 1; in abort_cmds_for_s_id()
4726 spin_unlock_irqrestore(&vha->cmd_list_lock, flags); in abort_cmds_for_s_id()
4742 lockdep_assert_held(&vha->hw->hardware_lock); in qlt_handle_login()
4744 wwn = wwn_to_u64(iocb->u.isp24.port_name); in qlt_handle_login()
4746 port_id.b.domain = iocb->u.isp24.port_id[2]; in qlt_handle_login()
4747 port_id.b.area = iocb->u.isp24.port_id[1]; in qlt_handle_login()
4748 port_id.b.al_pa = iocb->u.isp24.port_id[0]; in qlt_handle_login()
4751 loop_id = le16_to_cpu(iocb->u.isp24.nport_handle); in qlt_handle_login()
4757 spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); in qlt_handle_login()
4760 spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); in qlt_handle_login()
4774 if (vha->hw->flags.edif_enabled && in qlt_handle_login()
4775 !(vha->e_dbell.db_flags & EDB_ACTIVE) && in qlt_handle_login()
4776 iocb->u.isp24.status_subcode == ELS_PLOGI && in qlt_handle_login()
4777 !(le16_to_cpu(iocb->u.isp24.flags) & NOTIFY24XX_FLAGS_FCSP)) { in qlt_handle_login()
4785 if (vha->hw->flags.edif_enabled) { in qlt_handle_login()
4792 } else if (iocb->u.isp24.status_subcode == ELS_PLOGI && in qlt_handle_login()
4793 !(le16_to_cpu(iocb->u.isp24.flags) & NOTIFY24XX_FLAGS_FCSP)) { in qlt_handle_login()
4807 iocb->u.isp24.port_name); in qlt_handle_login()
4813 conflict_sess->login_gen++; in qlt_handle_login()
4819 pla->ref_count++; in qlt_handle_login()
4822 __func__, __LINE__, iocb->u.isp24.port_name); in qlt_handle_login()
4823 if (iocb->u.isp24.status_subcode == ELS_PLOGI) in qlt_handle_login()
4825 iocb->u.isp24.port_name, in qlt_handle_login()
4826 iocb->u.isp24.u.plogi.node_name, in qlt_handle_login()
4830 iocb->u.isp24.port_name, NULL, in qlt_handle_login()
4836 if (sess->disc_state == DSC_UPD_FCPORT) { in qlt_handle_login()
4844 sess->next_disc_state = DSC_DELETE_PEND; in qlt_handle_login()
4845 sec = jiffies_to_msecs(jiffies - in qlt_handle_login()
4846 sess->jiffies_at_registration) / 1000; in qlt_handle_login()
4847 if (sess->sec_since_registration < sec && sec && in qlt_handle_login()
4849 sess->sec_since_registration = sec; in qlt_handle_login()
4851 "%s %8phC - Slow Rport registration (%d Sec)\n", in qlt_handle_login()
4852 __func__, sess->port_name, sec); in qlt_handle_login()
4856 list_del(&pla->list); in qlt_handle_login()
4865 sess->d_id = port_id; in qlt_handle_login()
4866 sess->login_gen++; in qlt_handle_login()
4867 sess->loop_id = loop_id; in qlt_handle_login()
4869 if (iocb->u.isp24.status_subcode == ELS_PLOGI) { in qlt_handle_login()
4871 if (N2N_TOPO(vha->hw) && fcport_is_bigger(sess)) in qlt_handle_login()
4872 vha->d_id = sess->d_id; in qlt_handle_login()
4875 "%s %8phC - send port online\n", in qlt_handle_login()
4876 __func__, sess->port_name); in qlt_handle_login()
4879 sess->d_id.b24); in qlt_handle_login()
4882 if (iocb->u.isp24.status_subcode == ELS_PRLI) { in qlt_handle_login()
4883 sess->fw_login_state = DSC_LS_PRLI_PEND; in qlt_handle_login()
4884 sess->local = 0; in qlt_handle_login()
4885 sess->loop_id = loop_id; in qlt_handle_login()
4886 sess->d_id = port_id; in qlt_handle_login()
4887 sess->fw_login_state = DSC_LS_PRLI_PEND; in qlt_handle_login()
4888 wd3_lo = le16_to_cpu(iocb->u.isp24.u.prli.wd3_lo); in qlt_handle_login()
4891 sess->conf_compl_supported = 1; in qlt_handle_login()
4894 sess->port_type = FCT_INITIATOR; in qlt_handle_login()
4896 sess->port_type = FCT_TARGET; in qlt_handle_login()
4899 sess->fw_login_state = DSC_LS_PLOGI_PEND; in qlt_handle_login()
4904 __func__, __LINE__, sess->port_name, sess->disc_state); in qlt_handle_login()
4906 switch (sess->disc_state) { in qlt_handle_login()
4931 sess->keep_nport_handle = ((sess->loop_id == loop_id) && in qlt_handle_login()
4932 (sess->d_id.b24 == port_id.b24)); in qlt_handle_login()
4936 __func__, __LINE__, sess->port_name); in qlt_handle_login()
4947 * ha->hardware_lock supposed to be held on entry. Might drop it, then reaquire
4952 struct qla_tgt *tgt = vha->vha_tgt.qla_tgt; in qlt_24xx_handle_els()
4953 struct qla_hw_data *ha = vha->hw; in qlt_24xx_handle_els()
4962 lockdep_assert_held(&ha->hardware_lock); in qlt_24xx_handle_els()
4964 wwn = wwn_to_u64(iocb->u.isp24.port_name); in qlt_24xx_handle_els()
4966 port_id.b.domain = iocb->u.isp24.port_id[2]; in qlt_24xx_handle_els()
4967 port_id.b.area = iocb->u.isp24.port_id[1]; in qlt_24xx_handle_els()
4968 port_id.b.al_pa = iocb->u.isp24.port_id[0]; in qlt_24xx_handle_els()
4971 loop_id = le16_to_cpu(iocb->u.isp24.nport_handle); in qlt_24xx_handle_els()
4975 vha->vp_idx, iocb->u.isp24.port_id[2], in qlt_24xx_handle_els()
4976 iocb->u.isp24.port_id[1], iocb->u.isp24.port_id[0], in qlt_24xx_handle_els()
4977 iocb->u.isp24.status_subcode, loop_id, in qlt_24xx_handle_els()
4978 iocb->u.isp24.port_name); in qlt_24xx_handle_els()
4983 switch (iocb->u.isp24.status_subcode) { in qlt_24xx_handle_els()
4991 iocb->u.isp24.port_name, 1); in qlt_24xx_handle_els()
4993 if (vha->hw->flags.edif_enabled && sess && in qlt_24xx_handle_els()
4994 (!(sess->flags & FCF_FCSP_DEVICE) || in qlt_24xx_handle_els()
4995 !sess->edif.authok)) { in qlt_24xx_handle_els()
4998 __func__, __LINE__, iocb->u.isp24.port_name); in qlt_24xx_handle_els()
5003 if (sess && sess->plogi_link[QLT_PLOGI_LINK_SAME_WWN]) { in qlt_24xx_handle_els()
5007 iocb->u.isp24.port_name); in qlt_24xx_handle_els()
5021 wd3_lo = le16_to_cpu(iocb->u.isp24.u.prli.wd3_lo); in qlt_24xx_handle_els()
5024 spin_lock_irqsave(&tgt->ha->tgt.sess_lock, flags); in qlt_24xx_handle_els()
5027 spin_unlock_irqrestore(&tgt->ha->tgt.sess_lock, flags); in qlt_24xx_handle_els()
5031 switch (conflict_sess->disc_state) { in qlt_24xx_handle_els()
5038 conflict_sess, conflict_sess->port_name); in qlt_24xx_handle_els()
5039 conflict_sess->fw_login_state = in qlt_24xx_handle_els()
5051 if (vha->hw->flags.edif_enabled && sess && in qlt_24xx_handle_els()
5052 (!(sess->flags & FCF_FCSP_DEVICE) || in qlt_24xx_handle_els()
5053 !sess->edif.authok)) { in qlt_24xx_handle_els()
5056 __func__, __LINE__, iocb->u.isp24.port_name); in qlt_24xx_handle_els()
5061 spin_lock_irqsave(&tgt->ha->tgt.sess_lock, flags); in qlt_24xx_handle_els()
5062 switch (sess->fw_login_state) { in qlt_24xx_handle_els()
5072 switch (sess->disc_state) { in qlt_24xx_handle_els()
5074 spin_unlock_irqrestore(&tgt->ha->tgt.sess_lock, in qlt_24xx_handle_els()
5077 sec = jiffies_to_msecs(jiffies - in qlt_24xx_handle_els()
5078 sess->jiffies_at_registration)/1000; in qlt_24xx_handle_els()
5079 if (sess->sec_since_registration < sec && sec && in qlt_24xx_handle_els()
5081 sess->sec_since_registration = sec; in qlt_24xx_handle_els()
5082 ql_dbg(ql_dbg_disc, sess->vha, 0xffff, in qlt_24xx_handle_els()
5084 __func__, sess->port_name, sec); in qlt_24xx_handle_els()
5100 spin_unlock_irqrestore(&tgt->ha->tgt.sess_lock, in qlt_24xx_handle_els()
5104 * PLOGI could finish. Will force him to re-try, in qlt_24xx_handle_els()
5107 ql_log(ql_log_warn, sess->vha, 0xf095, in qlt_24xx_handle_els()
5121 sess->loop_id, sess, iocb->u.isp24.nport_handle); in qlt_24xx_handle_els()
5123 sess->local = 0; in qlt_24xx_handle_els()
5124 sess->loop_id = loop_id; in qlt_24xx_handle_els()
5125 sess->d_id = port_id; in qlt_24xx_handle_els()
5126 sess->fw_login_state = DSC_LS_PRLI_PEND; in qlt_24xx_handle_els()
5129 sess->conf_compl_supported = 1; in qlt_24xx_handle_els()
5132 sess->port_type = FCT_INITIATOR; in qlt_24xx_handle_els()
5134 sess->port_type = FCT_TARGET; in qlt_24xx_handle_els()
5136 spin_unlock_irqrestore(&tgt->ha->tgt.sess_lock, flags); in qlt_24xx_handle_els()
5141 if (ha->current_topology != ISP_CFG_F) { in qlt_24xx_handle_els()
5145 __func__, __LINE__, sess->port_name); in qlt_24xx_handle_els()
5150 set_bit(LOOP_RESYNC_NEEDED, &vha->dpc_flags); in qlt_24xx_handle_els()
5151 set_bit(LOCAL_LOOP_UPDATE, &vha->dpc_flags); in qlt_24xx_handle_els()
5158 __func__, __LINE__, sess->port_name); in qlt_24xx_handle_els()
5167 if (le16_to_cpu(iocb->u.isp24.flags) & in qlt_24xx_handle_els()
5177 spin_lock_irqsave(&ha->tgt.sess_lock, flags); in qlt_24xx_handle_els()
5179 spin_unlock_irqrestore(&ha->tgt.sess_lock, flags); in qlt_24xx_handle_els()
5182 sess->login_gen++; in qlt_24xx_handle_els()
5183 sess->fw_login_state = DSC_LS_LOGO_PEND; in qlt_24xx_handle_els()
5184 sess->logo_ack_needed = 1; in qlt_24xx_handle_els()
5185 memcpy(sess->iocb, iocb, IOCB_SIZE); in qlt_24xx_handle_els()
5212 struct qla_tgt *tgt = vha->vha_tgt.qla_tgt; in qlt_24xx_handle_els()
5214 if (tgt->link_reinit_iocb_pending) { in qlt_24xx_handle_els()
5215 qlt_send_notify_ack(ha->base_qpair, in qlt_24xx_handle_els()
5216 &tgt->link_reinit_iocb, 0, 0, 0, 0, 0, 0); in qlt_24xx_handle_els()
5217 tgt->link_reinit_iocb_pending = 0; in qlt_24xx_handle_els()
5221 iocb->u.isp24.port_name, 1); in qlt_24xx_handle_els()
5225 sess, sess->loop_id, loop_id, in qlt_24xx_handle_els()
5226 sess->disc_state, sess->fw_login_state); in qlt_24xx_handle_els()
5237 "received\n", vha->vp_idx, iocb->u.isp24.status_subcode); in qlt_24xx_handle_els()
5244 vha->vp_idx, iocb->u.isp24.status_subcode, res); in qlt_24xx_handle_els()
5250 * ha->hardware_lock supposed to be held on entry.
5256 struct qla_hw_data *ha = vha->hw; in qlt_handle_imm_notify()
5261 lockdep_assert_held(&ha->hardware_lock); in qlt_handle_imm_notify()
5263 status = le16_to_cpu(iocb->u.isp2x.status); in qlt_handle_imm_notify()
5269 vha->vp_idx, le16_to_cpu(iocb->u.isp24.nport_handle), in qlt_handle_imm_notify()
5270 iocb->u.isp24.status_subcode); in qlt_handle_imm_notify()
5279 struct qla_tgt *tgt = vha->vha_tgt.qla_tgt; in qlt_handle_imm_notify()
5283 "subcode %x)\n", vha->vp_idx, in qlt_handle_imm_notify()
5284 le16_to_cpu(iocb->u.isp24.nport_handle), in qlt_handle_imm_notify()
5285 iocb->u.isp24.status_subcode); in qlt_handle_imm_notify()
5286 if (tgt->link_reinit_iocb_pending) { in qlt_handle_imm_notify()
5287 qlt_send_notify_ack(ha->base_qpair, in qlt_handle_imm_notify()
5288 &tgt->link_reinit_iocb, 0, 0, 0, 0, 0, 0); in qlt_handle_imm_notify()
5290 memcpy(&tgt->link_reinit_iocb, iocb, sizeof(*iocb)); in qlt_handle_imm_notify()
5291 tgt->link_reinit_iocb_pending = 1; in qlt_handle_imm_notify()
5303 "%#x, subcode %x)\n", vha->vp_idx, in qlt_handle_imm_notify()
5304 le16_to_cpu(iocb->u.isp24.nport_handle), in qlt_handle_imm_notify()
5305 iocb->u.isp24.status_subcode); in qlt_handle_imm_notify()
5314 "qla_target(%d): Global TPRLO (%x)\n", vha->vp_idx, status); in qlt_handle_imm_notify()
5322 "qla_target(%d): Port config changed (%x)\n", vha->vp_idx, in qlt_handle_imm_notify()
5332 vha->vp_idx); in qlt_handle_imm_notify()
5342 "resource count)\n", vha->vp_idx); in qlt_handle_imm_notify()
5347 "qla_target(%d): Abort Task (S %08x I %#x -> " in qlt_handle_imm_notify()
5348 "L %#x)\n", vha->vp_idx, in qlt_handle_imm_notify()
5349 le16_to_cpu(iocb->u.isp2x.seq_id), in qlt_handle_imm_notify()
5351 le16_to_cpu(iocb->u.isp2x.lun)); in qlt_handle_imm_notify()
5359 vha->vp_idx, vha->host_no); in qlt_handle_imm_notify()
5365 vha->vp_idx, iocb->u.isp2x.task_flags); in qlt_handle_imm_notify()
5375 "notify status %x\n", vha->vp_idx, status); in qlt_handle_imm_notify()
5380 qlt_send_notify_ack(ha->base_qpair, iocb, add_flags, 0, 0, 0, in qlt_handle_imm_notify()
5385 * ha->hardware_lock supposed to be held on entry. Might drop it, then reaquire
5391 struct scsi_qla_host *vha = qpair->vha; in __qlt_send_busy()
5393 struct qla_hw_data *ha = vha->hw; in __qlt_send_busy()
5400 id = be_to_port_id(atio->u.isp24.fcp_hdr.s_id); in __qlt_send_busy()
5402 spin_lock_irqsave(&ha->tgt.sess_lock, flags); in __qlt_send_busy()
5404 spin_unlock_irqrestore(&ha->tgt.sess_lock, flags); in __qlt_send_busy()
5415 "request packet", vha->vp_idx, __func__); in __qlt_send_busy()
5416 return -ENOMEM; in __qlt_send_busy()
5419 qpair->tgt_counters.num_q_full_sent++; in __qlt_send_busy()
5420 pkt->entry_count = 1; in __qlt_send_busy()
5421 pkt->handle = QLA_TGT_SKIP_HANDLE | CTIO_COMPLETION_HANDLE_MARK; in __qlt_send_busy()
5424 ctio24->entry_type = CTIO_TYPE7; in __qlt_send_busy()
5425 ctio24->nport_handle = cpu_to_le16(sess->loop_id); in __qlt_send_busy()
5426 ctio24->timeout = cpu_to_le16(QLA_TGT_TIMEOUT); in __qlt_send_busy()
5427 ctio24->vp_index = vha->vp_idx; in __qlt_send_busy()
5428 ctio24->initiator_id = be_id_to_le(atio->u.isp24.fcp_hdr.s_id); in __qlt_send_busy()
5429 ctio24->exchange_addr = atio->u.isp24.exchange_addr; in __qlt_send_busy()
5430 temp = (atio->u.isp24.attr << 9) | in __qlt_send_busy()
5433 ctio24->u.status1.flags = cpu_to_le16(temp); in __qlt_send_busy()
5438 ctio24->u.status1.ox_id = in __qlt_send_busy()
5439 cpu_to_le16(be16_to_cpu(atio->u.isp24.fcp_hdr.ox_id)); in __qlt_send_busy()
5440 ctio24->u.status1.scsi_status = cpu_to_le16(status); in __qlt_send_busy()
5442 ctio24->u.status1.residual = cpu_to_le32(get_datalen_for_atio(atio)); in __qlt_send_busy()
5444 if (ctio24->u.status1.residual != 0) in __qlt_send_busy()
5445 ctio24->u.status1.scsi_status |= cpu_to_le16(SS_RESIDUAL_UNDER); in __qlt_send_busy()
5449 if (qpair->reqq_start_iocbs) in __qlt_send_busy()
5450 qpair->reqq_start_iocbs(qpair); in __qlt_send_busy()
5452 qla2x00_start_iocbs(vha, qpair->req); in __qlt_send_busy()
5465 struct qla_tgt *tgt = vha->vha_tgt.qla_tgt; in qlt_alloc_qfull_cmd()
5466 struct qla_hw_data *ha = vha->hw; in qlt_alloc_qfull_cmd()
5471 if (unlikely(tgt->tgt_stop)) { in qlt_alloc_qfull_cmd()
5477 if ((vha->hw->tgt.num_qfull_cmds_alloc + 1) > MAX_QFULL_CMDS_ALLOC) { in qlt_alloc_qfull_cmd()
5478 vha->hw->tgt.num_qfull_cmds_dropped++; in qlt_alloc_qfull_cmd()
5479 if (vha->hw->tgt.num_qfull_cmds_dropped > in qlt_alloc_qfull_cmd()
5480 vha->qla_stats.stat_max_qfull_cmds_dropped) in qlt_alloc_qfull_cmd()
5481 vha->qla_stats.stat_max_qfull_cmds_dropped = in qlt_alloc_qfull_cmd()
5482 vha->hw->tgt.num_qfull_cmds_dropped; in qlt_alloc_qfull_cmd()
5486 vha->vp_idx, __func__, in qlt_alloc_qfull_cmd()
5487 vha->hw->tgt.num_qfull_cmds_dropped); in qlt_alloc_qfull_cmd()
5493 sess = ha->tgt.tgt_ops->find_sess_by_s_id in qlt_alloc_qfull_cmd()
5494 (vha, atio->u.isp24.fcp_hdr.s_id); in qlt_alloc_qfull_cmd()
5498 cmd = ha->tgt.tgt_ops->get_cmd(sess); in qlt_alloc_qfull_cmd()
5502 vha->vp_idx, __func__); in qlt_alloc_qfull_cmd()
5504 vha->hw->tgt.num_qfull_cmds_dropped++; in qlt_alloc_qfull_cmd()
5505 if (vha->hw->tgt.num_qfull_cmds_dropped > in qlt_alloc_qfull_cmd()
5506 vha->qla_stats.stat_max_qfull_cmds_dropped) in qlt_alloc_qfull_cmd()
5507 vha->qla_stats.stat_max_qfull_cmds_dropped = in qlt_alloc_qfull_cmd()
5508 vha->hw->tgt.num_qfull_cmds_dropped; in qlt_alloc_qfull_cmd()
5515 INIT_LIST_HEAD(&cmd->cmd_list); in qlt_alloc_qfull_cmd()
5516 memcpy(&cmd->atio, atio, sizeof(*atio)); in qlt_alloc_qfull_cmd()
5518 cmd->tgt = vha->vha_tgt.qla_tgt; in qlt_alloc_qfull_cmd()
5519 cmd->vha = vha; in qlt_alloc_qfull_cmd()
5520 cmd->reset_count = ha->base_qpair->chip_reset; in qlt_alloc_qfull_cmd()
5521 cmd->q_full = 1; in qlt_alloc_qfull_cmd()
5522 cmd->qpair = ha->base_qpair; in qlt_alloc_qfull_cmd()
5525 cmd->q_full = 1; in qlt_alloc_qfull_cmd()
5527 cmd->state = status; in qlt_alloc_qfull_cmd()
5529 cmd->term_exchg = 1; in qlt_alloc_qfull_cmd()
5531 spin_lock_irqsave(&vha->hw->tgt.q_full_lock, flags); in qlt_alloc_qfull_cmd()
5532 list_add_tail(&cmd->cmd_list, &vha->hw->tgt.q_full_list); in qlt_alloc_qfull_cmd()
5534 vha->hw->tgt.num_qfull_cmds_alloc++; in qlt_alloc_qfull_cmd()
5535 if (vha->hw->tgt.num_qfull_cmds_alloc > in qlt_alloc_qfull_cmd()
5536 vha->qla_stats.stat_max_qfull_cmds_alloc) in qlt_alloc_qfull_cmd()
5537 vha->qla_stats.stat_max_qfull_cmds_alloc = in qlt_alloc_qfull_cmd()
5538 vha->hw->tgt.num_qfull_cmds_alloc; in qlt_alloc_qfull_cmd()
5539 spin_unlock_irqrestore(&vha->hw->tgt.q_full_lock, flags); in qlt_alloc_qfull_cmd()
5545 struct scsi_qla_host *vha = qpair->vha; in qlt_free_qfull_cmds()
5546 struct qla_hw_data *ha = vha->hw; in qlt_free_qfull_cmds()
5552 if (list_empty(&ha->tgt.q_full_list)) in qlt_free_qfull_cmds()
5558 spin_lock_irqsave(&vha->hw->tgt.q_full_lock, flags); in qlt_free_qfull_cmds()
5559 if (list_empty(&ha->tgt.q_full_list)) { in qlt_free_qfull_cmds()
5560 spin_unlock_irqrestore(&vha->hw->tgt.q_full_lock, flags); in qlt_free_qfull_cmds()
5564 list_splice_init(&vha->hw->tgt.q_full_list, &q_full_list); in qlt_free_qfull_cmds()
5565 spin_unlock_irqrestore(&vha->hw->tgt.q_full_lock, flags); in qlt_free_qfull_cmds()
5567 spin_lock_irqsave(qpair->qp_lock_ptr, flags); in qlt_free_qfull_cmds()
5569 if (cmd->q_full) in qlt_free_qfull_cmds()
5570 /* cmd->state is a borrowed field to hold status */ in qlt_free_qfull_cmds()
5571 rc = __qlt_send_busy(qpair, &cmd->atio, cmd->state); in qlt_free_qfull_cmds()
5572 else if (cmd->term_exchg) in qlt_free_qfull_cmds()
5573 rc = __qlt_send_term_exchange(qpair, NULL, &cmd->atio); in qlt_free_qfull_cmds()
5575 if (rc == -ENOMEM) in qlt_free_qfull_cmds()
5578 if (cmd->q_full) in qlt_free_qfull_cmds()
5581 be16_to_cpu(cmd->atio.u.isp24.fcp_hdr.ox_id)); in qlt_free_qfull_cmds()
5582 else if (cmd->term_exchg) in qlt_free_qfull_cmds()
5585 be16_to_cpu(cmd->atio.u.isp24.fcp_hdr.ox_id)); in qlt_free_qfull_cmds()
5591 list_move_tail(&cmd->cmd_list, &free_list); in qlt_free_qfull_cmds()
5594 vha->hw->tgt.num_qfull_cmds_alloc--; in qlt_free_qfull_cmds()
5596 spin_unlock_irqrestore(qpair->qp_lock_ptr, flags); in qlt_free_qfull_cmds()
5601 list_del(&cmd->cmd_list); in qlt_free_qfull_cmds()
5609 spin_lock_irqsave(&vha->hw->tgt.q_full_lock, flags); in qlt_free_qfull_cmds()
5610 list_splice(&q_full_list, &vha->hw->tgt.q_full_list); in qlt_free_qfull_cmds()
5611 spin_unlock_irqrestore(&vha->hw->tgt.q_full_lock, flags); in qlt_free_qfull_cmds()
5622 struct scsi_qla_host *vha = qpair->vha; in qlt_send_busy()
5625 if (rc == -ENOMEM) in qlt_send_busy()
5633 struct qla_hw_data *ha = vha->hw; in qlt_chk_qfull_thresh_hold()
5636 if (ha->tgt.num_pend_cmds < Q_FULL_THRESH_HOLD(ha)) in qlt_chk_qfull_thresh_hold()
5640 spin_lock_irqsave(&ha->hardware_lock, flags); in qlt_chk_qfull_thresh_hold()
5643 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qlt_chk_qfull_thresh_hold()
5648 /* ha->hardware_lock supposed to be held on entry */
5653 struct qla_hw_data *ha = vha->hw; in qlt_24xx_atio_pkt()
5654 struct qla_tgt *tgt = vha->vha_tgt.qla_tgt; in qlt_24xx_atio_pkt()
5668 tgt->atio_irq_cmd_count++; in qlt_24xx_atio_pkt()
5670 switch (atio->u.raw.entry_type) { in qlt_24xx_atio_pkt()
5672 if (unlikely(atio->u.isp24.exchange_addr == in qlt_24xx_atio_pkt()
5677 "sending QUEUE_FULL\n", vha->vp_idx); in qlt_24xx_atio_pkt()
5679 spin_lock_irqsave(&ha->hardware_lock, flags); in qlt_24xx_atio_pkt()
5680 qlt_send_busy(ha->base_qpair, atio, qla_sam_status); in qlt_24xx_atio_pkt()
5682 spin_unlock_irqrestore(&ha->hardware_lock, in qlt_24xx_atio_pkt()
5687 if (likely(atio->u.isp24.fcp_cmnd.task_mgmt_flags == 0)) { in qlt_24xx_atio_pkt()
5688 rc = qlt_chk_qfull_thresh_hold(vha, ha->base_qpair, in qlt_24xx_atio_pkt()
5691 tgt->atio_irq_cmd_count--; in qlt_24xx_atio_pkt()
5700 spin_lock_irqsave(&ha->hardware_lock, flags); in qlt_24xx_atio_pkt()
5702 case -ENODEV: in qlt_24xx_atio_pkt()
5706 case -EBADF: in qlt_24xx_atio_pkt()
5709 qlt_send_term_exchange(ha->base_qpair, NULL, in qlt_24xx_atio_pkt()
5712 case -EBUSY: in qlt_24xx_atio_pkt()
5715 vha->vp_idx); in qlt_24xx_atio_pkt()
5716 qlt_send_busy(ha->base_qpair, atio, in qlt_24xx_atio_pkt()
5722 vha->vp_idx); in qlt_24xx_atio_pkt()
5723 qlt_send_busy(ha->base_qpair, atio, in qlt_24xx_atio_pkt()
5728 spin_unlock_irqrestore(&ha->hardware_lock, in qlt_24xx_atio_pkt()
5735 if (unlikely(atio->u.isp2x.entry_status != 0)) { in qlt_24xx_atio_pkt()
5738 "with error status %x\n", vha->vp_idx, in qlt_24xx_atio_pkt()
5739 atio->u.raw.entry_type, in qlt_24xx_atio_pkt()
5740 atio->u.isp2x.entry_status); in qlt_24xx_atio_pkt()
5746 spin_lock_irqsave(&ha->hardware_lock, flags); in qlt_24xx_atio_pkt()
5749 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qlt_24xx_atio_pkt()
5756 "type %x\n", vha->vp_idx, atio->u.raw.entry_type); in qlt_24xx_atio_pkt()
5760 tgt->atio_irq_cmd_count--; in qlt_24xx_atio_pkt()
5771 struct qla_hw_data *ha = vha->hw; in qlt_chk_unresolv_exchg()
5780 if (qpair->retry_term_exchg_addr == entry->exchange_addr_to_abort && in qlt_chk_unresolv_exchg()
5781 qpair->retry_term_jiff == jiffies) { in qlt_chk_unresolv_exchg()
5783 qpair->retry_term_cnt++; in qlt_chk_unresolv_exchg()
5784 if (qpair->retry_term_cnt >= 5) { in qlt_chk_unresolv_exchg()
5785 rc = -EIO; in qlt_chk_unresolv_exchg()
5786 qpair->retry_term_cnt = 0; in qlt_chk_unresolv_exchg()
5792 if (qpair == ha->base_qpair) in qlt_chk_unresolv_exchg()
5793 ha->isp_ops->fw_dump(vha); in qlt_chk_unresolv_exchg()
5797 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); in qlt_chk_unresolv_exchg()
5800 } else if (qpair->retry_term_jiff != jiffies) { in qlt_chk_unresolv_exchg()
5801 qpair->retry_term_exchg_addr = entry->exchange_addr_to_abort; in qlt_chk_unresolv_exchg()
5802 qpair->retry_term_cnt = 0; in qlt_chk_unresolv_exchg()
5803 qpair->retry_term_jiff = jiffies; in qlt_chk_unresolv_exchg()
5815 u32 h = pkt->handle & ~QLA_TGT_HANDLE_MASK; in qlt_handle_abts_completion()
5817 struct qla_hw_data *ha = vha->hw; in qlt_handle_abts_completion()
5819 mcmd = qlt_ctio_to_cmd(vha, rsp, pkt->handle, pkt); in qlt_handle_abts_completion()
5823 vha->vp_idx); in qlt_handle_abts_completion()
5828 vha = mcmd->vha; in qlt_handle_abts_completion()
5829 vha->vha_tgt.qla_tgt->abts_resp_expected--; in qlt_handle_abts_completion()
5833 entry->compl_status); in qlt_handle_abts_completion()
5835 if (le16_to_cpu(entry->compl_status) != ABTS_RESP_COMPL_SUCCESS) { in qlt_handle_abts_completion()
5836 if (le32_to_cpu(entry->error_subcode1) == 0x1E && in qlt_handle_abts_completion()
5837 le32_to_cpu(entry->error_subcode2) == 0) { in qlt_handle_abts_completion()
5838 if (qlt_chk_unresolv_exchg(vha, rsp->qpair, entry)) { in qlt_handle_abts_completion()
5839 ha->tgt.tgt_ops->free_mcmd(mcmd); in qlt_handle_abts_completion()
5842 qlt_24xx_retry_term_exchange(vha, rsp->qpair, in qlt_handle_abts_completion()
5847 vha->vp_idx, entry->compl_status, in qlt_handle_abts_completion()
5848 entry->error_subcode1, in qlt_handle_abts_completion()
5849 entry->error_subcode2); in qlt_handle_abts_completion()
5850 ha->tgt.tgt_ops->free_mcmd(mcmd); in qlt_handle_abts_completion()
5853 ha->tgt.tgt_ops->free_mcmd(mcmd); in qlt_handle_abts_completion()
5857 /* ha->hardware_lock supposed to be held on entry */
5862 struct qla_tgt *tgt = vha->vha_tgt.qla_tgt; in qlt_response_pkt()
5867 vha->vp_idx, pkt->entry_type, vha->hw); in qlt_response_pkt()
5876 switch (pkt->entry_type) { in qlt_response_pkt()
5882 qlt_do_ctio_completion(vha, rsp, entry->handle, in qlt_response_pkt()
5883 le16_to_cpu(entry->status)|(pkt->entry_status << 16), in qlt_response_pkt()
5893 if (atio->u.isp2x.status != in qlt_response_pkt()
5897 "status %x received\n", vha->vp_idx, in qlt_response_pkt()
5898 le16_to_cpu(atio->u.isp2x.status)); in qlt_response_pkt()
5902 rc = qlt_chk_qfull_thresh_hold(vha, rsp->qpair, atio, 1); in qlt_response_pkt()
5909 case -ENODEV: in qlt_response_pkt()
5913 case -EBADF: in qlt_response_pkt()
5916 qlt_send_term_exchange(rsp->qpair, NULL, in qlt_response_pkt()
5919 case -EBUSY: in qlt_response_pkt()
5922 vha->vp_idx); in qlt_response_pkt()
5923 qlt_send_busy(rsp->qpair, atio, in qlt_response_pkt()
5929 vha->vp_idx); in qlt_response_pkt()
5930 qlt_send_busy(rsp->qpair, atio, in qlt_response_pkt()
5942 qlt_do_ctio_completion(vha, rsp, entry->handle, in qlt_response_pkt()
5943 le16_to_cpu(entry->status)|(pkt->entry_status << 16), in qlt_response_pkt()
5952 qlt_do_ctio_completion(vha, rsp, entry->handle, in qlt_response_pkt()
5953 le16_to_cpu(entry->status)|(pkt->entry_status << 16), in qlt_response_pkt()
5964 if (tgt->notify_ack_expected > 0) { in qlt_response_pkt()
5969 le16_to_cpu(entry->u.isp2x.seq_id), in qlt_response_pkt()
5970 le16_to_cpu(entry->u.isp2x.status)); in qlt_response_pkt()
5971 tgt->notify_ack_expected--; in qlt_response_pkt()
5972 if (entry->u.isp2x.status != in qlt_response_pkt()
5976 "failed %x\n", vha->vp_idx, in qlt_response_pkt()
5977 le16_to_cpu(entry->u.isp2x.status)); in qlt_response_pkt()
5982 vha->vp_idx); in qlt_response_pkt()
5988 "ABTS_RECV_24XX: instance %d\n", vha->vp_idx); in qlt_response_pkt()
5993 if (tgt->abts_resp_expected > 0) { in qlt_response_pkt()
5998 "received\n", vha->vp_idx); in qlt_response_pkt()
6005 "type %x\n", vha->vp_idx, pkt->entry_type); in qlt_response_pkt()
6012 * ha->hardware_lock supposed to be held on entry. Might drop it, then reaquire
6017 struct qla_hw_data *ha = vha->hw; in qlt_async_event()
6018 struct qla_tgt *tgt = vha->vha_tgt.qla_tgt; in qlt_async_event()
6021 if (!tgt || tgt->tgt_stop || tgt->tgt_stopped) in qlt_async_event()
6040 "occurred", vha->vp_idx, code); in qlt_async_event()
6042 case MBA_WAKEUP_THRES: /* Request Queue Wake-up. */ in qlt_async_event()
6043 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); in qlt_async_event()
6050 "(m[0]=%x, m[1]=%x, m[2]=%x, m[3]=%x)", vha->vp_idx, in qlt_async_event()
6052 if (tgt->link_reinit_iocb_pending) { in qlt_async_event()
6053 qlt_send_notify_ack(ha->base_qpair, in qlt_async_event()
6054 &tgt->link_reinit_iocb, in qlt_async_event()
6056 tgt->link_reinit_iocb_pending = 0; in qlt_async_event()
6067 "(m[0]=%x, m[1]=%x, m[2]=%x, m[3]=%x)", vha->vp_idx, code, in qlt_async_event()
6074 vha->vp_idx, in qlt_async_event()
6079 vha->hw->exch_starvation++; in qlt_async_event()
6080 if (vha->hw->exch_starvation > 5) { in qlt_async_event()
6082 "Exchange starvation-. Resetting RISC\n"); in qlt_async_event()
6084 vha->hw->exch_starvation = 0; in qlt_async_event()
6085 if (IS_P3P_TYPE(vha->hw)) in qlt_async_event()
6087 &vha->dpc_flags); in qlt_async_event()
6090 &vha->dpc_flags); in qlt_async_event()
6100 "m[2]=%x, m[3]=%x)", vha->vp_idx, code, in qlt_async_event()
6107 vha->hw->exch_starvation = 0; in qlt_async_event()
6130 vha->vp_idx); in qlt_get_port_database()
6134 fcport->loop_id = loop_id; in qlt_get_port_database()
6140 "information -- get_port_database() returned %x " in qlt_get_port_database()
6141 "(loop_id=0x%04x)", vha->vp_idx, rc, loop_id); in qlt_get_port_database()
6147 spin_lock_irqsave(&vha->hw->tgt.sess_lock, flags); in qlt_get_port_database()
6148 tfcp = qla2x00_find_fcport_by_wwpn(vha, fcport->port_name, 1); in qlt_get_port_database()
6151 tfcp->d_id = fcport->d_id; in qlt_get_port_database()
6152 tfcp->port_type = fcport->port_type; in qlt_get_port_database()
6153 tfcp->supported_classes = fcport->supported_classes; in qlt_get_port_database()
6154 tfcp->flags |= fcport->flags; in qlt_get_port_database()
6155 tfcp->scan_state = QLA_FCPORT_FOUND; in qlt_get_port_database()
6160 if (vha->hw->current_topology == ISP_CFG_F) in qlt_get_port_database()
6161 fcport->flags |= FCF_FABRIC_DEVICE; in qlt_get_port_database()
6163 list_add_tail(&fcport->list, &vha->vp_fcports); in qlt_get_port_database()
6164 if (!IS_SW_RESV_ADDR(fcport->d_id)) in qlt_get_port_database()
6165 vha->fcport_count++; in qlt_get_port_database()
6166 fcport->login_gen++; in qlt_get_port_database()
6168 fcport->login_succ = 1; in qlt_get_port_database()
6172 fcport->deleted = 0; in qlt_get_port_database()
6173 spin_unlock_irqrestore(&vha->hw->tgt.sess_lock, flags); in qlt_get_port_database()
6175 switch (vha->host->active_mode) { in qlt_get_port_database()
6179 if (!IS_IIDMA_CAPABLE(vha->hw) || !vha->hw->flags.gpsc_supported) { in qlt_get_port_database()
6184 __func__, __LINE__, fcport->port_name, vha->fcport_count); in qlt_get_port_database()
6220 mutex_lock(&vha->vha_tgt.tgt_mutex); in qlt_make_local_sess()
6224 atomic_read(&vha->vha_tgt.qla_tgt->tgt_global_resets_count); in qlt_make_local_sess()
6228 mutex_unlock(&vha->vha_tgt.tgt_mutex); in qlt_make_local_sess()
6233 vha->vp_idx, s_id.domain, s_id.area, s_id.al_pa); in qlt_make_local_sess()
6235 if (rc == -ENOENT) { in qlt_make_local_sess()
6248 mutex_unlock(&vha->vha_tgt.tgt_mutex); in qlt_make_local_sess()
6253 atomic_read(&vha->vha_tgt.qla_tgt->tgt_global_resets_count)) { in qlt_make_local_sess()
6256 "(counter was %d, new %d), retrying", vha->vp_idx, in qlt_make_local_sess()
6258 atomic_read(&vha->vha_tgt. in qlt_make_local_sess()
6259 qla_tgt->tgt_global_resets_count)); in qlt_make_local_sess()
6265 mutex_unlock(&vha->vha_tgt.tgt_mutex); in qlt_make_local_sess()
6273 struct scsi_qla_host *vha = tgt->vha; in qlt_abort_work()
6274 struct qla_hw_data *ha = vha->hw; in qlt_abort_work()
6280 spin_lock_irqsave(&ha->tgt.sess_lock, flags2); in qlt_abort_work()
6282 if (tgt->tgt_stop) in qlt_abort_work()
6285 s_id = le_id_to_be(prm->abts.fcp_hdr_le.s_id); in qlt_abort_work()
6287 sess = ha->tgt.tgt_ops->find_sess_by_s_id(vha, s_id); in qlt_abort_work()
6289 spin_unlock_irqrestore(&ha->tgt.sess_lock, flags2); in qlt_abort_work()
6294 spin_lock_irqsave(&ha->tgt.sess_lock, flags2); in qlt_abort_work()
6298 if (sess->deleted) { in qlt_abort_work()
6303 if (!kref_get_unless_zero(&sess->sess_kref)) { in qlt_abort_work()
6306 __func__, sess->port_name); in qlt_abort_work()
6312 rc = __qlt_24xx_handle_abts(vha, &prm->abts, sess); in qlt_abort_work()
6313 spin_unlock_irqrestore(&ha->tgt.sess_lock, flags2); in qlt_abort_work()
6315 ha->tgt.tgt_ops->put_sess(sess); in qlt_abort_work()
6322 spin_unlock_irqrestore(&ha->tgt.sess_lock, flags2); in qlt_abort_work()
6325 spin_lock_irqsave(&ha->hardware_lock, flags); in qlt_abort_work()
6326 qlt_24xx_send_abts_resp(ha->base_qpair, &prm->abts, in qlt_abort_work()
6328 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qlt_abort_work()
6334 struct scsi_qla_host *vha = tgt->vha; in qlt_sess_work_fn()
6339 spin_lock_irqsave(&tgt->sess_work_lock, flags); in qlt_sess_work_fn()
6340 while (!list_empty(&tgt->sess_works_list)) { in qlt_sess_work_fn()
6342 tgt->sess_works_list.next, typeof(*prm), in qlt_sess_work_fn()
6349 list_del(&prm->sess_works_list_entry); in qlt_sess_work_fn()
6351 spin_unlock_irqrestore(&tgt->sess_work_lock, flags); in qlt_sess_work_fn()
6353 switch (prm->type) { in qlt_sess_work_fn()
6362 spin_lock_irqsave(&tgt->sess_work_lock, flags); in qlt_sess_work_fn()
6366 spin_unlock_irqrestore(&tgt->sess_work_lock, flags); in qlt_sess_work_fn()
6386 "Registering target for host %ld(%p).\n", base_vha->host_no, ha); in qlt_add_target()
6388 BUG_ON(base_vha->vha_tgt.qla_tgt != NULL); in qlt_add_target()
6394 return -ENOMEM; in qlt_add_target()
6397 tgt->qphints = kcalloc(ha->max_qpairs + 1, in qlt_add_target()
6400 if (!tgt->qphints) { in qlt_add_target()
6404 return -ENOMEM; in qlt_add_target()
6409 rc = btree_init64(&tgt->lun_qpair_map); in qlt_add_target()
6411 kfree(tgt->qphints); in qlt_add_target()
6415 return -EIO; in qlt_add_target()
6417 h = &tgt->qphints[0]; in qlt_add_target()
6418 h->qpair = ha->base_qpair; in qlt_add_target()
6419 INIT_LIST_HEAD(&h->hint_elem); in qlt_add_target()
6420 h->cpuid = ha->base_qpair->cpuid; in qlt_add_target()
6421 list_add_tail(&h->hint_elem, &ha->base_qpair->hints_list); in qlt_add_target()
6423 for (i = 0; i < ha->max_qpairs; i++) { in qlt_add_target()
6426 struct qla_qpair *qpair = ha->queue_pair_map[i]; in qlt_add_target()
6428 h = &tgt->qphints[i + 1]; in qlt_add_target()
6429 INIT_LIST_HEAD(&h->hint_elem); in qlt_add_target()
6431 h->qpair = qpair; in qlt_add_target()
6432 spin_lock_irqsave(qpair->qp_lock_ptr, flags); in qlt_add_target()
6433 list_add_tail(&h->hint_elem, &qpair->hints_list); in qlt_add_target()
6434 spin_unlock_irqrestore(qpair->qp_lock_ptr, flags); in qlt_add_target()
6435 h->cpuid = qpair->cpuid; in qlt_add_target()
6439 tgt->ha = ha; in qlt_add_target()
6440 tgt->vha = base_vha; in qlt_add_target()
6441 init_waitqueue_head(&tgt->waitQ); in qlt_add_target()
6442 spin_lock_init(&tgt->sess_work_lock); in qlt_add_target()
6443 INIT_WORK(&tgt->sess_work, qlt_sess_work_fn); in qlt_add_target()
6444 INIT_LIST_HEAD(&tgt->sess_works_list); in qlt_add_target()
6445 atomic_set(&tgt->tgt_global_resets_count, 0); in qlt_add_target()
6447 base_vha->vha_tgt.qla_tgt = tgt; in qlt_add_target()
6451 base_vha->vp_idx); in qlt_add_target()
6453 tgt->sg_tablesize = QLA_TGT_MAX_SG_24XX(base_vha->req->length - 3); in qlt_add_target()
6456 list_add_tail(&tgt->tgt_list_entry, &qla_tgt_glist); in qlt_add_target()
6459 if (ha->tgt.tgt_ops && ha->tgt.tgt_ops->add_target) in qlt_add_target()
6460 ha->tgt.tgt_ops->add_target(base_vha); in qlt_add_target()
6468 if (!vha->vha_tgt.qla_tgt) in qlt_remove_target()
6471 if (vha->fc_vport) { in qlt_remove_target()
6472 qlt_release(vha->vha_tgt.qla_tgt); in qlt_remove_target()
6480 vha->host_no, ha); in qlt_remove_target()
6481 qlt_release(vha->vha_tgt.qla_tgt); in qlt_remove_target()
6491 btree_for_each_safe32(&ha->host_map, key, node) in qla_remove_hostmap()
6492 btree_remove32(&ha->host_map, key); in qla_remove_hostmap()
6494 btree_destroy32(&ha->host_map); in qla_remove_hostmap()
6500 pr_debug("qla2xxx HW vha->node_name: %8phC\n", vha->node_name); in qlt_lport_dump()
6501 pr_debug("qla2xxx HW vha->port_name: %8phC\n", vha->port_name); in qlt_lport_dump()
6507 * qlt_lport_register - register lport with external module
6529 vha = tgt->vha; in qlt_lport_register()
6530 ha = vha->hw; in qlt_lport_register()
6532 host = vha->host; in qlt_lport_register()
6536 if (!(host->hostt->supported_mode & MODE_TARGET)) in qlt_lport_register()
6539 if (vha->qlini_mode == QLA2XXX_INI_MODE_ENABLED) in qlt_lport_register()
6542 spin_lock_irqsave(&ha->hardware_lock, flags); in qlt_lport_register()
6543 if ((!npiv_wwpn || !npiv_wwnn) && host->active_mode & MODE_TARGET) { in qlt_lport_register()
6545 host->host_no); in qlt_lport_register()
6546 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qlt_lport_register()
6549 if (tgt->tgt_stop) { in qlt_lport_register()
6551 host->host_no); in qlt_lport_register()
6552 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qlt_lport_register()
6555 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qlt_lport_register()
6565 if (memcmp(vha->port_name, b, WWN_SIZE)) { in qlt_lport_register()
6578 return -ENODEV; in qlt_lport_register()
6583 * qlt_lport_deregister - Degister lport
6589 struct qla_hw_data *ha = vha->hw; in qlt_lport_deregister()
6590 struct Scsi_Host *sh = vha->host; in qlt_lport_deregister()
6594 vha->vha_tgt.target_lport_ptr = NULL; in qlt_lport_deregister()
6595 ha->tgt.tgt_ops = NULL; in qlt_lport_deregister()
6606 switch (vha->qlini_mode) { in qlt_set_mode()
6609 vha->host->active_mode = MODE_TARGET; in qlt_set_mode()
6612 vha->host->active_mode = MODE_INITIATOR; in qlt_set_mode()
6615 vha->host->active_mode = MODE_DUAL; in qlt_set_mode()
6625 switch (vha->qlini_mode) { in qlt_clear_mode()
6627 vha->host->active_mode = MODE_UNKNOWN; in qlt_clear_mode()
6630 vha->host->active_mode = MODE_INITIATOR; in qlt_clear_mode()
6634 vha->host->active_mode = MODE_INITIATOR; in qlt_clear_mode()
6642 * qla_tgt_enable_vha - NO LOCK HELD
6649 struct qla_hw_data *ha = vha->hw; in qlt_enable_vha()
6650 struct qla_tgt *tgt = vha->vha_tgt.qla_tgt; in qlt_enable_vha()
6652 scsi_qla_host_t *base_vha = pci_get_drvdata(ha->pdev); in qlt_enable_vha()
6661 if (vha->qlini_mode == QLA2XXX_INI_MODE_ENABLED) in qlt_enable_vha()
6664 if (ha->tgt.num_act_qpairs > ha->max_qpairs) in qlt_enable_vha()
6665 ha->tgt.num_act_qpairs = ha->max_qpairs; in qlt_enable_vha()
6666 spin_lock_irqsave(&ha->hardware_lock, flags); in qlt_enable_vha()
6667 tgt->tgt_stopped = 0; in qlt_enable_vha()
6669 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qlt_enable_vha()
6671 mutex_lock(&ha->optrom_mutex); in qlt_enable_vha()
6674 if (vha->vp_idx) { in qlt_enable_vha()
6678 set_bit(ISP_ABORT_NEEDED, &base_vha->dpc_flags); in qlt_enable_vha()
6683 mutex_unlock(&ha->optrom_mutex); in qlt_enable_vha()
6688 * qla_tgt_disable_vha - NO LOCK HELD
6694 struct qla_hw_data *ha = vha->hw; in qlt_disable_vha()
6695 struct qla_tgt *tgt = vha->vha_tgt.qla_tgt; in qlt_disable_vha()
6706 spin_lock_irqsave(&ha->hardware_lock, flags); in qlt_disable_vha()
6708 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qlt_disable_vha()
6710 set_bit(ISP_ABORT_NEEDED, &vha->dpc_flags); in qlt_disable_vha()
6730 vha->vha_tgt.qla_tgt = NULL; in qlt_vport_create()
6732 mutex_init(&vha->vha_tgt.tgt_mutex); in qlt_vport_create()
6733 mutex_init(&vha->vha_tgt.tgt_host_action_mutex); in qlt_vport_create()
6735 INIT_LIST_HEAD(&vha->unknown_atio_list); in qlt_vport_create()
6736 INIT_DELAYED_WORK(&vha->unknown_atio_work, qlt_unknown_atio_work_fn); in qlt_vport_create()
6746 ha->tgt.atio_q_length = ATIO_ENTRY_CNT_24XX; in qlt_vport_create()
6756 * FC-4 Feature bit 0 indicates target functionality to the name server. in qlt_rff_id()
6769 * qlt_init_atio_q_entries() - Initializes ATIO queue entries.
6780 struct qla_hw_data *ha = vha->hw; in qlt_init_atio_q_entries()
6782 struct atio_from_isp *pkt = (struct atio_from_isp *)ha->tgt.atio_ring; in qlt_init_atio_q_entries()
6787 for (cnt = 0; cnt < ha->tgt.atio_q_length; cnt++) { in qlt_init_atio_q_entries()
6788 pkt->u.raw.signature = cpu_to_le32(ATIO_PROCESSED); in qlt_init_atio_q_entries()
6795 * qlt_24xx_process_atio_queue() - Process ATIO queue entries.
6801 struct qla_hw_data *ha = vha->hw; in qlt_24xx_process_atio_queue()
6805 if (!ha->flags.fw_started) in qlt_24xx_process_atio_queue()
6808 while ((ha->tgt.atio_ring_ptr->signature != ATIO_PROCESSED) || in qlt_24xx_process_atio_queue()
6809 fcpcmd_is_corrupted(ha->tgt.atio_ring_ptr)) { in qlt_24xx_process_atio_queue()
6810 pkt = (struct atio_from_isp *)ha->tgt.atio_ring_ptr; in qlt_24xx_process_atio_queue()
6811 cnt = pkt->u.raw.entry_count; in qlt_24xx_process_atio_queue()
6813 if (unlikely(fcpcmd_is_corrupted(ha->tgt.atio_ring_ptr))) { in qlt_24xx_process_atio_queue()
6821 &pkt->u.isp24.fcp_hdr.s_id, in qlt_24xx_process_atio_queue()
6822 be16_to_cpu(pkt->u.isp24.fcp_hdr.ox_id), in qlt_24xx_process_atio_queue()
6823 pkt->u.isp24.exchange_addr, pkt); in qlt_24xx_process_atio_queue()
6826 qlt_send_term_exchange(ha->base_qpair, NULL, pkt, in qlt_24xx_process_atio_queue()
6834 ha->tgt.atio_ring_index++; in qlt_24xx_process_atio_queue()
6835 if (ha->tgt.atio_ring_index == ha->tgt.atio_q_length) { in qlt_24xx_process_atio_queue()
6836 ha->tgt.atio_ring_index = 0; in qlt_24xx_process_atio_queue()
6837 ha->tgt.atio_ring_ptr = ha->tgt.atio_ring; in qlt_24xx_process_atio_queue()
6839 ha->tgt.atio_ring_ptr++; in qlt_24xx_process_atio_queue()
6841 pkt->u.raw.signature = cpu_to_le32(ATIO_PROCESSED); in qlt_24xx_process_atio_queue()
6842 pkt = (struct atio_from_isp *)ha->tgt.atio_ring_ptr; in qlt_24xx_process_atio_queue()
6848 wrt_reg_dword(ISP_ATIO_Q_OUT(vha), ha->tgt.atio_ring_index); in qlt_24xx_process_atio_queue()
6854 struct qla_hw_data *ha = vha->hw; in qlt_24xx_config_rings()
6855 struct qla_msix_entry *msix = &ha->msix_entries[2]; in qlt_24xx_config_rings()
6856 struct init_cb_24xx *icb = (struct init_cb_24xx *)ha->init_cb; in qlt_24xx_config_rings()
6865 if (ha->flags.msix_enabled) { in qlt_24xx_config_rings()
6867 icb->msix_atio = cpu_to_le16(msix->entry); in qlt_24xx_config_rings()
6868 icb->firmware_options_2 &= cpu_to_le32(~BIT_26); in qlt_24xx_config_rings()
6871 msix->entry); in qlt_24xx_config_rings()
6876 icb->msix_atio = 0; in qlt_24xx_config_rings()
6877 icb->firmware_options_2 |= cpu_to_le32(BIT_26); in qlt_24xx_config_rings()
6887 struct qla_hw_data *ha = vha->hw; in qlt_24xx_config_nvram_stage1()
6894 if (!ha->tgt.saved_set) { in qlt_24xx_config_nvram_stage1()
6896 ha->tgt.saved_exchange_count = nv->exchange_count; in qlt_24xx_config_nvram_stage1()
6897 ha->tgt.saved_firmware_options_1 = in qlt_24xx_config_nvram_stage1()
6898 nv->firmware_options_1; in qlt_24xx_config_nvram_stage1()
6899 ha->tgt.saved_firmware_options_2 = in qlt_24xx_config_nvram_stage1()
6900 nv->firmware_options_2; in qlt_24xx_config_nvram_stage1()
6901 ha->tgt.saved_firmware_options_3 = in qlt_24xx_config_nvram_stage1()
6902 nv->firmware_options_3; in qlt_24xx_config_nvram_stage1()
6903 ha->tgt.saved_set = 1; in qlt_24xx_config_nvram_stage1()
6907 nv->exchange_count = cpu_to_le16(0xFFFF); in qlt_24xx_config_nvram_stage1()
6909 nv->exchange_count = cpu_to_le16(vha->ql2xexchoffld); in qlt_24xx_config_nvram_stage1()
6912 nv->firmware_options_1 |= cpu_to_le32(BIT_4); in qlt_24xx_config_nvram_stage1()
6916 nv->firmware_options_1 |= cpu_to_le32(BIT_5); in qlt_24xx_config_nvram_stage1()
6919 nv->firmware_options_1 &= cpu_to_le32(~BIT_13); in qlt_24xx_config_nvram_stage1()
6921 nv->firmware_options_1 &= cpu_to_le32(~BIT_9); in qlt_24xx_config_nvram_stage1()
6924 nv->firmware_options_2 |= cpu_to_le32(BIT_12); in qlt_24xx_config_nvram_stage1()
6927 nv->firmware_options_2 &= cpu_to_le32(~BIT_12); in qlt_24xx_config_nvram_stage1()
6930 nv->host_p &= cpu_to_le32(~BIT_10); in qlt_24xx_config_nvram_stage1()
6937 nv->firmware_options_1 &= cpu_to_le32(~BIT_15); in qlt_24xx_config_nvram_stage1()
6939 nv->firmware_options_2 |= cpu_to_le32(BIT_14); in qlt_24xx_config_nvram_stage1()
6942 /* Change Loop-prefer to Pt-Pt */ in qlt_24xx_config_nvram_stage1()
6944 nv->firmware_options_2 &= cpu_to_le32(tmp); in qlt_24xx_config_nvram_stage1()
6946 nv->firmware_options_2 |= cpu_to_le32(tmp); in qlt_24xx_config_nvram_stage1()
6949 if (ha->tgt.saved_set) { in qlt_24xx_config_nvram_stage1()
6950 nv->exchange_count = ha->tgt.saved_exchange_count; in qlt_24xx_config_nvram_stage1()
6951 nv->firmware_options_1 = in qlt_24xx_config_nvram_stage1()
6952 ha->tgt.saved_firmware_options_1; in qlt_24xx_config_nvram_stage1()
6953 nv->firmware_options_2 = in qlt_24xx_config_nvram_stage1()
6954 ha->tgt.saved_firmware_options_2; in qlt_24xx_config_nvram_stage1()
6955 nv->firmware_options_3 = in qlt_24xx_config_nvram_stage1()
6956 ha->tgt.saved_firmware_options_3; in qlt_24xx_config_nvram_stage1()
6961 if (ha->base_qpair->enable_class_2) { in qlt_24xx_config_nvram_stage1()
6962 if (vha->flags.init_done) in qlt_24xx_config_nvram_stage1()
6963 fc_host_supported_classes(vha->host) = in qlt_24xx_config_nvram_stage1()
6966 nv->firmware_options_2 |= cpu_to_le32(BIT_8); in qlt_24xx_config_nvram_stage1()
6968 if (vha->flags.init_done) in qlt_24xx_config_nvram_stage1()
6969 fc_host_supported_classes(vha->host) = FC_COS_CLASS3; in qlt_24xx_config_nvram_stage1()
6971 nv->firmware_options_2 &= ~cpu_to_le32(BIT_8); in qlt_24xx_config_nvram_stage1()
6979 struct qla_hw_data *ha = vha->hw; in qlt_24xx_config_nvram_stage2()
6984 if (ha->tgt.node_name_set) { in qlt_24xx_config_nvram_stage2()
6985 memcpy(icb->node_name, ha->tgt.tgt_node_name, WWN_SIZE); in qlt_24xx_config_nvram_stage2()
6986 icb->firmware_options_1 |= cpu_to_le32(BIT_14); in qlt_24xx_config_nvram_stage2()
6993 struct qla_hw_data *ha = vha->hw; in qlt_81xx_config_nvram_stage1()
7000 if (!ha->tgt.saved_set) { in qlt_81xx_config_nvram_stage1()
7002 ha->tgt.saved_exchange_count = nv->exchange_count; in qlt_81xx_config_nvram_stage1()
7003 ha->tgt.saved_firmware_options_1 = in qlt_81xx_config_nvram_stage1()
7004 nv->firmware_options_1; in qlt_81xx_config_nvram_stage1()
7005 ha->tgt.saved_firmware_options_2 = in qlt_81xx_config_nvram_stage1()
7006 nv->firmware_options_2; in qlt_81xx_config_nvram_stage1()
7007 ha->tgt.saved_firmware_options_3 = in qlt_81xx_config_nvram_stage1()
7008 nv->firmware_options_3; in qlt_81xx_config_nvram_stage1()
7009 ha->tgt.saved_set = 1; in qlt_81xx_config_nvram_stage1()
7013 nv->exchange_count = cpu_to_le16(0xFFFF); in qlt_81xx_config_nvram_stage1()
7015 nv->exchange_count = cpu_to_le16(vha->ql2xexchoffld); in qlt_81xx_config_nvram_stage1()
7018 nv->firmware_options_1 |= cpu_to_le32(BIT_4); in qlt_81xx_config_nvram_stage1()
7022 nv->firmware_options_1 |= cpu_to_le32(BIT_5); in qlt_81xx_config_nvram_stage1()
7024 nv->firmware_options_1 &= cpu_to_le32(~BIT_13); in qlt_81xx_config_nvram_stage1()
7026 nv->firmware_options_1 &= cpu_to_le32(~BIT_9); in qlt_81xx_config_nvram_stage1()
7033 nv->firmware_options_1 &= cpu_to_le32(~BIT_15); in qlt_81xx_config_nvram_stage1()
7036 nv->firmware_options_2 |= cpu_to_le32(BIT_12); in qlt_81xx_config_nvram_stage1()
7039 nv->firmware_options_2 &= cpu_to_le32(~BIT_12); in qlt_81xx_config_nvram_stage1()
7042 nv->host_p &= cpu_to_le32(~BIT_10); in qlt_81xx_config_nvram_stage1()
7044 nv->firmware_options_2 |= cpu_to_le32(BIT_14); in qlt_81xx_config_nvram_stage1()
7046 /* Change Loop-prefer to Pt-Pt */ in qlt_81xx_config_nvram_stage1()
7048 nv->firmware_options_2 &= cpu_to_le32(tmp); in qlt_81xx_config_nvram_stage1()
7050 nv->firmware_options_2 |= cpu_to_le32(tmp); in qlt_81xx_config_nvram_stage1()
7052 if (ha->tgt.saved_set) { in qlt_81xx_config_nvram_stage1()
7053 nv->exchange_count = ha->tgt.saved_exchange_count; in qlt_81xx_config_nvram_stage1()
7054 nv->firmware_options_1 = in qlt_81xx_config_nvram_stage1()
7055 ha->tgt.saved_firmware_options_1; in qlt_81xx_config_nvram_stage1()
7056 nv->firmware_options_2 = in qlt_81xx_config_nvram_stage1()
7057 ha->tgt.saved_firmware_options_2; in qlt_81xx_config_nvram_stage1()
7058 nv->firmware_options_3 = in qlt_81xx_config_nvram_stage1()
7059 ha->tgt.saved_firmware_options_3; in qlt_81xx_config_nvram_stage1()
7064 if (ha->base_qpair->enable_class_2) { in qlt_81xx_config_nvram_stage1()
7065 if (vha->flags.init_done) in qlt_81xx_config_nvram_stage1()
7066 fc_host_supported_classes(vha->host) = in qlt_81xx_config_nvram_stage1()
7069 nv->firmware_options_2 |= cpu_to_le32(BIT_8); in qlt_81xx_config_nvram_stage1()
7071 if (vha->flags.init_done) in qlt_81xx_config_nvram_stage1()
7072 fc_host_supported_classes(vha->host) = FC_COS_CLASS3; in qlt_81xx_config_nvram_stage1()
7074 nv->firmware_options_2 &= ~cpu_to_le32(BIT_8); in qlt_81xx_config_nvram_stage1()
7082 struct qla_hw_data *ha = vha->hw; in qlt_81xx_config_nvram_stage2()
7087 if (ha->tgt.node_name_set) { in qlt_81xx_config_nvram_stage2()
7088 memcpy(icb->node_name, ha->tgt.tgt_node_name, WWN_SIZE); in qlt_81xx_config_nvram_stage2()
7089 icb->firmware_options_1 |= cpu_to_le32(BIT_14); in qlt_81xx_config_nvram_stage2()
7099 ha->msix_count += 1; /* For ATIO Q */ in qlt_83xx_iospace_config()
7109 vpmod->options_idx1 &= ~BIT_5; in qlt_modify_vp_config()
7113 vpmod->options_idx1 &= ~BIT_4; in qlt_modify_vp_config()
7119 mutex_init(&base_vha->vha_tgt.tgt_mutex); in qlt_probe_one_stage1()
7123 if (ha->mqenable || IS_QLA83XX(ha) || IS_QLA27XX(ha) || IS_QLA28XX(ha)) { in qlt_probe_one_stage1()
7124 ISP_ATIO_Q_IN(base_vha) = &ha->mqiobase->isp25mq.atio_q_in; in qlt_probe_one_stage1()
7125 ISP_ATIO_Q_OUT(base_vha) = &ha->mqiobase->isp25mq.atio_q_out; in qlt_probe_one_stage1()
7127 ISP_ATIO_Q_IN(base_vha) = &ha->iobase->isp24.atio_q_in; in qlt_probe_one_stage1()
7128 ISP_ATIO_Q_OUT(base_vha) = &ha->iobase->isp24.atio_q_out; in qlt_probe_one_stage1()
7131 mutex_init(&base_vha->vha_tgt.tgt_host_action_mutex); in qlt_probe_one_stage1()
7133 INIT_LIST_HEAD(&base_vha->unknown_atio_list); in qlt_probe_one_stage1()
7134 INIT_DELAYED_WORK(&base_vha->unknown_atio_work, in qlt_probe_one_stage1()
7151 ha = rsp->hw; in qla83xx_msix_atio_q()
7152 vha = pci_get_drvdata(ha->pdev); in qla83xx_msix_atio_q()
7154 spin_lock_irqsave(&ha->tgt.atio_lock, flags); in qla83xx_msix_atio_q()
7158 spin_unlock_irqrestore(&ha->tgt.atio_lock, flags); in qla83xx_msix_atio_q()
7168 scsi_qla_host_t *vha = op->vha; in qlt_handle_abts_recv_work()
7169 struct qla_hw_data *ha = vha->hw; in qlt_handle_abts_recv_work()
7173 (op->chip_reset != ha->base_qpair->chip_reset)) in qlt_handle_abts_recv_work()
7176 spin_lock_irqsave(&ha->tgt.atio_lock, flags); in qlt_handle_abts_recv_work()
7178 spin_unlock_irqrestore(&ha->tgt.atio_lock, flags); in qlt_handle_abts_recv_work()
7180 spin_lock_irqsave(&ha->hardware_lock, flags); in qlt_handle_abts_recv_work()
7181 qlt_response_pkt_all_vps(vha, op->rsp, (response_t *)&op->atio); in qlt_handle_abts_recv_work()
7182 spin_unlock_irqrestore(&ha->hardware_lock, flags); in qlt_handle_abts_recv_work()
7203 memcpy(&op->atio, pkt, sizeof(*pkt)); in qlt_handle_abts_recv()
7204 op->vha = vha; in qlt_handle_abts_recv()
7205 op->chip_reset = vha->hw->base_qpair->chip_reset; in qlt_handle_abts_recv()
7206 op->rsp = rsp; in qlt_handle_abts_recv()
7207 INIT_WORK(&op->work, qlt_handle_abts_recv_work); in qlt_handle_abts_recv()
7208 queue_work(qla_tgt_wq, &op->work); in qlt_handle_abts_recv()
7218 ha->tgt.atio_ring = dma_alloc_coherent(&ha->pdev->dev, in qlt_mem_alloc()
7219 (ha->tgt.atio_q_length + 1) * sizeof(struct atio_from_isp), in qlt_mem_alloc()
7220 &ha->tgt.atio_dma, GFP_KERNEL); in qlt_mem_alloc()
7221 if (!ha->tgt.atio_ring) { in qlt_mem_alloc()
7222 return -ENOMEM; in qlt_mem_alloc()
7233 if (ha->tgt.atio_ring) { in qlt_mem_free()
7234 dma_free_coherent(&ha->pdev->dev, (ha->tgt.atio_q_length + 1) * in qlt_mem_free()
7235 sizeof(struct atio_from_isp), ha->tgt.atio_ring, in qlt_mem_free()
7236 ha->tgt.atio_dma); in qlt_mem_free()
7238 ha->tgt.atio_ring = NULL; in qlt_mem_free()
7239 ha->tgt.atio_dma = 0; in qlt_mem_free()
7268 return -EINVAL; in qlt_init()
7280 return -ENOMEM; in qlt_init()
7290 ret = -ENOMEM; in qlt_init()
7299 ret = -ENOMEM; in qlt_init()
7307 ret = -ENOMEM; in qlt_init()
7311 * Return 1 to signal that initiator-mode is being disabled in qlt_init()