• Home
  • Raw
  • Download

Lines Matching +full:sub +full:- +full:mailbox

4  * Copyright (C) 2017-2020 Broadcom. All Rights Reserved. The term *
6 * Copyright (C) 2004-2016 Emulex. All rights reserved. *
9 * Portions Copyright (C) 2004-2005 Christoph Hellwig *
17 * FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT, ARE *
96 return &iocbq->iocb; in lpfc_get_iocb_from_iocbq()
101 * lpfc_sli4_pcimem_bcopy - SLI4 memory copy function
128 * lpfc_sli4_wq_put - Put a Work Queue Entry on an Work Queue
136 * -ENOMEM.
152 return -ENOMEM; in lpfc_sli4_wq_put()
153 temp_wqe = lpfc_sli4_qe(q, q->host_index); in lpfc_sli4_wq_put()
156 idx = ((q->host_index + 1) % q->entry_count); in lpfc_sli4_wq_put()
157 if (idx == q->hba_index) { in lpfc_sli4_wq_put()
158 q->WQ_overflow++; in lpfc_sli4_wq_put()
159 return -EBUSY; in lpfc_sli4_wq_put()
161 q->WQ_posted++; in lpfc_sli4_wq_put()
163 if (!((q->host_index + 1) % q->notify_interval)) in lpfc_sli4_wq_put()
164 bf_set(wqe_wqec, &wqe->generic.wqe_com, 1); in lpfc_sli4_wq_put()
166 bf_set(wqe_wqec, &wqe->generic.wqe_com, 0); in lpfc_sli4_wq_put()
167 if (q->phba->sli3_options & LPFC_SLI4_PHWQ_ENABLED) in lpfc_sli4_wq_put()
168 bf_set(wqe_wqid, &wqe->generic.wqe_com, q->queue_id); in lpfc_sli4_wq_put()
169 lpfc_sli4_pcimem_bcopy(wqe, temp_wqe, q->entry_size); in lpfc_sli4_wq_put()
170 if (q->dpp_enable && q->phba->cfg_enable_dpp) { in lpfc_sli4_wq_put()
174 for (i = 0; i < q->entry_size; i += sizeof(uint64_t)) in lpfc_sli4_wq_put()
176 q->dpp_regaddr + i); in lpfc_sli4_wq_put()
178 for (i = 0; i < q->entry_size; i += sizeof(uint32_t)) in lpfc_sli4_wq_put()
180 q->dpp_regaddr + i); in lpfc_sli4_wq_put()
187 host_index = q->host_index; in lpfc_sli4_wq_put()
189 q->host_index = idx; in lpfc_sli4_wq_put()
193 if (q->db_format == LPFC_DB_LIST_FORMAT) { in lpfc_sli4_wq_put()
194 if (q->dpp_enable && q->phba->cfg_enable_dpp) { in lpfc_sli4_wq_put()
198 q->dpp_id); in lpfc_sli4_wq_put()
200 q->queue_id); in lpfc_sli4_wq_put()
203 bf_set(lpfc_wq_db_list_fm_id, &doorbell, q->queue_id); in lpfc_sli4_wq_put()
207 &q->phba->sli4_hba.sli_intf); in lpfc_sli4_wq_put()
212 } else if (q->db_format == LPFC_DB_RING_FORMAT) { in lpfc_sli4_wq_put()
214 bf_set(lpfc_wq_db_ring_fm_id, &doorbell, q->queue_id); in lpfc_sli4_wq_put()
216 return -EINVAL; in lpfc_sli4_wq_put()
218 writel(doorbell.word0, q->db_regaddr); in lpfc_sli4_wq_put()
224 * lpfc_sli4_wq_release - Updates internal hba index for WQ
240 q->hba_index = index; in lpfc_sli4_wq_release()
244 * lpfc_sli4_mq_put - Put a Mailbox Queue Entry on an Mailbox Queue
245 * @q: The Mailbox Queue to operate on.
246 * @mqe: The Mailbox Queue Entry to put on the Work queue.
252 * -ENOMEM.
263 return -ENOMEM; in lpfc_sli4_mq_put()
264 temp_mqe = lpfc_sli4_qe(q, q->host_index); in lpfc_sli4_mq_put()
267 if (((q->host_index + 1) % q->entry_count) == q->hba_index) in lpfc_sli4_mq_put()
268 return -ENOMEM; in lpfc_sli4_mq_put()
269 lpfc_sli4_pcimem_bcopy(mqe, temp_mqe, q->entry_size); in lpfc_sli4_mq_put()
270 /* Save off the mailbox pointer for completion */ in lpfc_sli4_mq_put()
271 q->phba->mbox = (MAILBOX_t *)temp_mqe; in lpfc_sli4_mq_put()
274 q->host_index = ((q->host_index + 1) % q->entry_count); in lpfc_sli4_mq_put()
279 bf_set(lpfc_mq_doorbell_id, &doorbell, q->queue_id); in lpfc_sli4_mq_put()
280 writel(doorbell.word0, q->phba->sli4_hba.MQDBregaddr); in lpfc_sli4_mq_put()
285 * lpfc_sli4_mq_release - Updates internal hba index for MQ
286 * @q: The Mailbox Queue to operate on.
289 * a Mailbox Queue Entry by the HBA. When the HBA indicates that it has consumed
301 /* Clear the mailbox pointer for completion */ in lpfc_sli4_mq_release()
302 q->phba->mbox = NULL; in lpfc_sli4_mq_release()
303 q->hba_index = ((q->hba_index + 1) % q->entry_count); in lpfc_sli4_mq_release()
308 * lpfc_sli4_eq_get - Gets the next valid EQE from a EQ
324 eqe = lpfc_sli4_qe(q, q->host_index); in lpfc_sli4_eq_get()
327 if (bf_get_le32(lpfc_eqe_valid, eqe) != q->qe_valid) in lpfc_sli4_eq_get()
344 * lpfc_sli4_eq_clr_intr - Turn off interrupts from this EQ
357 (q->queue_id >> LPFC_EQID_HI_FIELD_SHIFT)); in lpfc_sli4_eq_clr_intr()
358 bf_set(lpfc_eqcq_doorbell_eqid_lo, &doorbell, q->queue_id); in lpfc_sli4_eq_clr_intr()
359 writel(doorbell.word0, q->phba->sli4_hba.EQDBregaddr); in lpfc_sli4_eq_clr_intr()
363 * lpfc_sli4_if6_eq_clr_intr - Turn off interrupts from this EQ
373 bf_set(lpfc_if6_eq_doorbell_eqid, &doorbell, q->queue_id); in lpfc_sli4_if6_eq_clr_intr()
374 writel(doorbell.word0, q->phba->sli4_hba.EQDBregaddr); in lpfc_sli4_if6_eq_clr_intr()
378 * lpfc_sli4_write_eq_db - write EQ DB for eqe's consumed or arm state
407 (q->queue_id >> LPFC_EQID_HI_FIELD_SHIFT)); in lpfc_sli4_write_eq_db()
408 bf_set(lpfc_eqcq_doorbell_eqid_lo, &doorbell, q->queue_id); in lpfc_sli4_write_eq_db()
409 writel(doorbell.word0, q->phba->sli4_hba.EQDBregaddr); in lpfc_sli4_write_eq_db()
410 /* PCI read to flush PCI pipeline on re-arming for INTx mode */ in lpfc_sli4_write_eq_db()
411 if ((q->phba->intr_type == INTx) && (arm == LPFC_QUEUE_REARM)) in lpfc_sli4_write_eq_db()
412 readl(q->phba->sli4_hba.EQDBregaddr); in lpfc_sli4_write_eq_db()
416 * lpfc_sli4_if6_write_eq_db - write EQ DB for eqe's consumed or arm state
441 bf_set(lpfc_if6_eq_doorbell_eqid, &doorbell, q->queue_id); in lpfc_sli4_if6_write_eq_db()
442 writel(doorbell.word0, q->phba->sli4_hba.EQDBregaddr); in lpfc_sli4_if6_write_eq_db()
443 /* PCI read to flush PCI pipeline on re-arming for INTx mode */ in lpfc_sli4_if6_write_eq_db()
444 if ((q->phba->intr_type == INTx) && (arm == LPFC_QUEUE_REARM)) in lpfc_sli4_if6_write_eq_db()
445 readl(q->phba->sli4_hba.EQDBregaddr); in lpfc_sli4_if6_write_eq_db()
452 if (!phba->sli4_hba.pc_sli4_params.eqav) in __lpfc_sli4_consume_eqe()
455 eq->host_index = ((eq->host_index + 1) % eq->entry_count); in __lpfc_sli4_consume_eqe()
458 if (phba->sli4_hba.pc_sli4_params.eqav && !eq->host_index) in __lpfc_sli4_consume_eqe()
459 eq->qe_valid = (eq->qe_valid) ? 0 : 1; in __lpfc_sli4_consume_eqe()
478 list_for_each_entry(childq, &eq->child_list, list) { in lpfc_sli4_eqcq_flush()
479 if (childq->queue_id == cqid) { in lpfc_sli4_eqcq_flush()
492 /* Clear and re-arm the CQ */ in lpfc_sli4_eqcq_flush()
493 phba->sli4_hba.sli4_write_cq_db(phba, cq, cq_count, in lpfc_sli4_eqcq_flush()
502 /* Clear and re-arm the EQ */ in lpfc_sli4_eqcq_flush()
503 phba->sli4_hba.sli4_write_eq_db(phba, eq, eq_count, LPFC_QUEUE_REARM); in lpfc_sli4_eqcq_flush()
513 if (cmpxchg(&eq->queue_claimed, 0, 1) != 0) in lpfc_sli4_process_eq()
522 if (!(++count % eq->max_proc_limit)) in lpfc_sli4_process_eq()
525 if (!(count % eq->notify_interval)) { in lpfc_sli4_process_eq()
526 phba->sli4_hba.sli4_write_eq_db(phba, eq, consumed, in lpfc_sli4_process_eq()
533 eq->EQ_processed += count; in lpfc_sli4_process_eq()
536 if (count > eq->EQ_max_eqe) in lpfc_sli4_process_eq()
537 eq->EQ_max_eqe = count; in lpfc_sli4_process_eq()
539 xchg(&eq->queue_claimed, 0); in lpfc_sli4_process_eq()
543 phba->sli4_hba.sli4_write_eq_db(phba, eq, consumed, rearm); in lpfc_sli4_process_eq()
549 * lpfc_sli4_cq_get - Gets the next valid CQE from a CQ
565 cqe = lpfc_sli4_qe(q, q->host_index); in lpfc_sli4_cq_get()
568 if (bf_get_le32(lpfc_cqe_valid, cqe) != q->qe_valid) in lpfc_sli4_cq_get()
577 * single 32-bit entity here (vs multi word structure for cq's). in lpfc_sli4_cq_get()
587 if (!phba->sli4_hba.pc_sli4_params.cqav) in __lpfc_sli4_consume_cqe()
590 cq->host_index = ((cq->host_index + 1) % cq->entry_count); in __lpfc_sli4_consume_cqe()
593 if (phba->sli4_hba.pc_sli4_params.cqav && !cq->host_index) in __lpfc_sli4_consume_cqe()
594 cq->qe_valid = (cq->qe_valid) ? 0 : 1; in __lpfc_sli4_consume_cqe()
598 * lpfc_sli4_write_cq_db - write cq DB for entries consumed or arm state.
625 (q->queue_id >> LPFC_CQID_HI_FIELD_SHIFT)); in lpfc_sli4_write_cq_db()
626 bf_set(lpfc_eqcq_doorbell_cqid_lo, &doorbell, q->queue_id); in lpfc_sli4_write_cq_db()
627 writel(doorbell.word0, q->phba->sli4_hba.CQDBregaddr); in lpfc_sli4_write_cq_db()
631 * lpfc_sli4_if6_write_cq_db - write cq DB for entries consumed or arm state.
656 bf_set(lpfc_if6_cq_doorbell_cqid, &doorbell, q->queue_id); in lpfc_sli4_if6_write_cq_db()
657 writel(doorbell.word0, q->phba->sli4_hba.CQDBregaddr); in lpfc_sli4_if6_write_cq_db()
661 * lpfc_sli4_rq_put - Put a Receive Buffer Queue Entry on a Receive Queue
667 * on @q then this function will return -ENOMEM.
682 return -ENOMEM; in lpfc_sli4_rq_put()
683 hq_put_index = hq->host_index; in lpfc_sli4_rq_put()
684 dq_put_index = dq->host_index; in lpfc_sli4_rq_put()
688 if (hq->type != LPFC_HRQ || dq->type != LPFC_DRQ) in lpfc_sli4_rq_put()
689 return -EINVAL; in lpfc_sli4_rq_put()
691 return -EINVAL; in lpfc_sli4_rq_put()
693 if (((hq_put_index + 1) % hq->entry_count) == hq->hba_index) in lpfc_sli4_rq_put()
694 return -EBUSY; in lpfc_sli4_rq_put()
695 lpfc_sli4_pcimem_bcopy(hrqe, temp_hrqe, hq->entry_size); in lpfc_sli4_rq_put()
696 lpfc_sli4_pcimem_bcopy(drqe, temp_drqe, dq->entry_size); in lpfc_sli4_rq_put()
699 hq->host_index = ((hq_put_index + 1) % hq->entry_count); in lpfc_sli4_rq_put()
700 dq->host_index = ((dq_put_index + 1) % dq->entry_count); in lpfc_sli4_rq_put()
701 hq->RQ_buf_posted++; in lpfc_sli4_rq_put()
704 if (!(hq->host_index % hq->notify_interval)) { in lpfc_sli4_rq_put()
706 if (hq->db_format == LPFC_DB_RING_FORMAT) { in lpfc_sli4_rq_put()
708 hq->notify_interval); in lpfc_sli4_rq_put()
709 bf_set(lpfc_rq_db_ring_fm_id, &doorbell, hq->queue_id); in lpfc_sli4_rq_put()
710 } else if (hq->db_format == LPFC_DB_LIST_FORMAT) { in lpfc_sli4_rq_put()
712 hq->notify_interval); in lpfc_sli4_rq_put()
714 hq->host_index); in lpfc_sli4_rq_put()
715 bf_set(lpfc_rq_db_list_fm_id, &doorbell, hq->queue_id); in lpfc_sli4_rq_put()
717 return -EINVAL; in lpfc_sli4_rq_put()
719 writel(doorbell.word0, hq->db_regaddr); in lpfc_sli4_rq_put()
725 * lpfc_sli4_rq_release - Updates internal hba index for RQ
740 if ((hq->type != LPFC_HRQ) || (dq->type != LPFC_DRQ)) in lpfc_sli4_rq_release()
742 hq->hba_index = ((hq->hba_index + 1) % hq->entry_count); in lpfc_sli4_rq_release()
743 dq->hba_index = ((dq->hba_index + 1) % dq->entry_count); in lpfc_sli4_rq_release()
748 * lpfc_cmd_iocb - Get next command iocb entry in the ring
755 * SLI-2/SLI-3 provide different sized iocbs.
760 return (IOCB_t *) (((char *) pring->sli.sli3.cmdringaddr) + in lpfc_cmd_iocb()
761 pring->sli.sli3.cmdidx * phba->iocb_cmd_size); in lpfc_cmd_iocb()
765 * lpfc_resp_iocb - Get next response iocb entry in the ring
772 * SLI-2/SLI-3 provide different sized iocbs.
777 return (IOCB_t *) (((char *) pring->sli.sli3.rspringaddr) + in lpfc_resp_iocb()
778 pring->sli.sli3.rspidx * phba->iocb_rsp_size); in lpfc_resp_iocb()
782 * __lpfc_sli_get_iocbq - Allocates an iocb object from iocb pool
793 struct list_head *lpfc_iocb_list = &phba->lpfc_iocb_list; in __lpfc_sli_get_iocbq()
796 lockdep_assert_held(&phba->hbalock); in __lpfc_sli_get_iocbq()
800 phba->iocb_cnt++; in __lpfc_sli_get_iocbq()
801 if (phba->iocb_cnt > phba->iocb_max) in __lpfc_sli_get_iocbq()
802 phba->iocb_max = phba->iocb_cnt; in __lpfc_sli_get_iocbq()
807 * __lpfc_clear_active_sglq - Remove the active sglq for this XRI.
823 sglq = phba->sli4_hba.lpfc_sglq_active_list[xritag]; in __lpfc_clear_active_sglq()
824 phba->sli4_hba.lpfc_sglq_active_list[xritag] = NULL; in __lpfc_clear_active_sglq()
829 * __lpfc_get_active_sglq - Get the active sglq for this XRI.
845 sglq = phba->sli4_hba.lpfc_sglq_active_list[xritag]; in __lpfc_get_active_sglq()
850 * lpfc_clr_rrq_active - Clears RRQ active bit in xri_bitmap.
863 if ((rrq->vport) && NLP_CHK_NODE_ACT(rrq->ndlp)) in lpfc_clr_rrq_active()
864 ndlp = lpfc_findnode_did(rrq->vport, rrq->nlp_DID); in lpfc_clr_rrq_active()
870 if ((!ndlp) && rrq->ndlp) in lpfc_clr_rrq_active()
871 ndlp = rrq->ndlp; in lpfc_clr_rrq_active()
876 if (test_and_clear_bit(xritag, ndlp->active_rrqs_xri_bitmap)) { in lpfc_clr_rrq_active()
877 rrq->send_rrq = 0; in lpfc_clr_rrq_active()
878 rrq->xritag = 0; in lpfc_clr_rrq_active()
879 rrq->rrq_stop_time = 0; in lpfc_clr_rrq_active()
882 mempool_free(rrq, phba->rrq_pool); in lpfc_clr_rrq_active()
886 * lpfc_handle_rrq_active - Checks if RRQ has waithed RATOV.
908 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_handle_rrq_active()
909 phba->hba_flag &= ~HBA_RRQ_ACTIVE; in lpfc_handle_rrq_active()
910 next_time = jiffies + msecs_to_jiffies(1000 * (phba->fc_ratov + 1)); in lpfc_handle_rrq_active()
912 &phba->active_rrq_list, list) { in lpfc_handle_rrq_active()
913 if (time_after(jiffies, rrq->rrq_stop_time)) in lpfc_handle_rrq_active()
914 list_move(&rrq->list, &send_rrq); in lpfc_handle_rrq_active()
915 else if (time_before(rrq->rrq_stop_time, next_time)) in lpfc_handle_rrq_active()
916 next_time = rrq->rrq_stop_time; in lpfc_handle_rrq_active()
918 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_handle_rrq_active()
919 if ((!list_empty(&phba->active_rrq_list)) && in lpfc_handle_rrq_active()
920 (!(phba->pport->load_flag & FC_UNLOADING))) in lpfc_handle_rrq_active()
921 mod_timer(&phba->rrq_tmr, next_time); in lpfc_handle_rrq_active()
923 list_del(&rrq->list); in lpfc_handle_rrq_active()
924 if (!rrq->send_rrq) { in lpfc_handle_rrq_active()
926 lpfc_clr_rrq_active(phba, rrq->xritag, rrq); in lpfc_handle_rrq_active()
931 lpfc_clr_rrq_active(phba, rrq->xritag, in lpfc_handle_rrq_active()
938 * lpfc_get_active_rrq - Get the active RRQ for this exchange.
943 * returns NULL = rrq not found in the phba->active_rrq_list.
949 struct lpfc_hba *phba = vport->phba; in lpfc_get_active_rrq()
954 if (phba->sli_rev != LPFC_SLI_REV4) in lpfc_get_active_rrq()
956 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_get_active_rrq()
957 list_for_each_entry_safe(rrq, nextrrq, &phba->active_rrq_list, list) { in lpfc_get_active_rrq()
958 if (rrq->vport == vport && rrq->xritag == xri && in lpfc_get_active_rrq()
959 rrq->nlp_DID == did){ in lpfc_get_active_rrq()
960 list_del(&rrq->list); in lpfc_get_active_rrq()
961 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_get_active_rrq()
965 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_get_active_rrq()
970 * lpfc_cleanup_vports_rrqs - Remove and clear the active RRQ for this vport.
974 * phba->active_rrq_list and clear the rrq.
981 struct lpfc_hba *phba = vport->phba; in lpfc_cleanup_vports_rrqs()
987 if (phba->sli_rev != LPFC_SLI_REV4) in lpfc_cleanup_vports_rrqs()
993 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_cleanup_vports_rrqs()
994 list_for_each_entry_safe(rrq, nextrrq, &phba->active_rrq_list, list) in lpfc_cleanup_vports_rrqs()
995 if ((rrq->vport == vport) && (!ndlp || rrq->ndlp == ndlp)) in lpfc_cleanup_vports_rrqs()
996 list_move(&rrq->list, &rrq_list); in lpfc_cleanup_vports_rrqs()
997 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_cleanup_vports_rrqs()
1000 list_del(&rrq->list); in lpfc_cleanup_vports_rrqs()
1001 lpfc_clr_rrq_active(phba, rrq->xritag, rrq); in lpfc_cleanup_vports_rrqs()
1006 * lpfc_test_rrq_active - Test RRQ bit in xri_bitmap.
1021 if (!ndlp->active_rrqs_xri_bitmap) in lpfc_test_rrq_active()
1023 if (test_bit(xritag, ndlp->active_rrqs_xri_bitmap)) in lpfc_test_rrq_active()
1030 * lpfc_set_rrq_active - set RRQ active bit in xri_bitmap.
1053 return -EINVAL; in lpfc_set_rrq_active()
1055 if (!phba->cfg_enable_rrq) in lpfc_set_rrq_active()
1056 return -EINVAL; in lpfc_set_rrq_active()
1058 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_set_rrq_active()
1059 if (phba->pport->load_flag & FC_UNLOADING) { in lpfc_set_rrq_active()
1060 phba->hba_flag &= ~HBA_RRQ_ACTIVE; in lpfc_set_rrq_active()
1070 if (ndlp->vport && (ndlp->vport->load_flag & FC_UNLOADING)) in lpfc_set_rrq_active()
1073 if (!ndlp->active_rrqs_xri_bitmap) in lpfc_set_rrq_active()
1076 if (test_and_set_bit(xritag, ndlp->active_rrqs_xri_bitmap)) in lpfc_set_rrq_active()
1079 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_set_rrq_active()
1080 rrq = mempool_alloc(phba->rrq_pool, GFP_ATOMIC); in lpfc_set_rrq_active()
1085 xritag, rxid, ndlp->nlp_DID, send_rrq); in lpfc_set_rrq_active()
1086 return -EINVAL; in lpfc_set_rrq_active()
1088 if (phba->cfg_enable_rrq == 1) in lpfc_set_rrq_active()
1089 rrq->send_rrq = send_rrq; in lpfc_set_rrq_active()
1091 rrq->send_rrq = 0; in lpfc_set_rrq_active()
1092 rrq->xritag = xritag; in lpfc_set_rrq_active()
1093 rrq->rrq_stop_time = jiffies + in lpfc_set_rrq_active()
1094 msecs_to_jiffies(1000 * (phba->fc_ratov + 1)); in lpfc_set_rrq_active()
1095 rrq->ndlp = ndlp; in lpfc_set_rrq_active()
1096 rrq->nlp_DID = ndlp->nlp_DID; in lpfc_set_rrq_active()
1097 rrq->vport = ndlp->vport; in lpfc_set_rrq_active()
1098 rrq->rxid = rxid; in lpfc_set_rrq_active()
1099 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_set_rrq_active()
1100 empty = list_empty(&phba->active_rrq_list); in lpfc_set_rrq_active()
1101 list_add_tail(&rrq->list, &phba->active_rrq_list); in lpfc_set_rrq_active()
1102 phba->hba_flag |= HBA_RRQ_ACTIVE; in lpfc_set_rrq_active()
1105 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_set_rrq_active()
1108 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_set_rrq_active()
1112 xritag, rxid, ndlp->nlp_DID, send_rrq); in lpfc_set_rrq_active()
1113 return -EINVAL; in lpfc_set_rrq_active()
1117 * __lpfc_sli_get_els_sglq - Allocates an iocb object from sgl pool
1130 struct list_head *lpfc_els_sgl_list = &phba->sli4_hba.lpfc_els_sgl_list; in __lpfc_sli_get_els_sglq()
1138 if (piocbq->iocb_flag & LPFC_IO_NVME_LS) in __lpfc_sli_get_els_sglq()
1139 pring = phba->sli4_hba.nvmels_wq->pring; in __lpfc_sli_get_els_sglq()
1143 lockdep_assert_held(&pring->ring_lock); in __lpfc_sli_get_els_sglq()
1145 if (piocbq->iocb_flag & LPFC_IO_FCP) { in __lpfc_sli_get_els_sglq()
1146 lpfc_cmd = (struct lpfc_io_buf *) piocbq->context1; in __lpfc_sli_get_els_sglq()
1147 ndlp = lpfc_cmd->rdata->pnode; in __lpfc_sli_get_els_sglq()
1148 } else if ((piocbq->iocb.ulpCommand == CMD_GEN_REQUEST64_CR) && in __lpfc_sli_get_els_sglq()
1149 !(piocbq->iocb_flag & LPFC_IO_LIBDFC)) { in __lpfc_sli_get_els_sglq()
1150 ndlp = piocbq->context_un.ndlp; in __lpfc_sli_get_els_sglq()
1151 } else if (piocbq->iocb_flag & LPFC_IO_LIBDFC) { in __lpfc_sli_get_els_sglq()
1152 if (piocbq->iocb_flag & LPFC_IO_LOOPBACK) in __lpfc_sli_get_els_sglq()
1155 ndlp = piocbq->context_un.ndlp; in __lpfc_sli_get_els_sglq()
1157 ndlp = piocbq->context1; in __lpfc_sli_get_els_sglq()
1160 spin_lock(&phba->sli4_hba.sgl_list_lock); in __lpfc_sli_get_els_sglq()
1166 if (ndlp && ndlp->active_rrqs_xri_bitmap && in __lpfc_sli_get_els_sglq()
1167 test_bit(sglq->sli4_lxritag, in __lpfc_sli_get_els_sglq()
1168 ndlp->active_rrqs_xri_bitmap)) { in __lpfc_sli_get_els_sglq()
1172 list_add_tail(&sglq->list, lpfc_els_sgl_list); in __lpfc_sli_get_els_sglq()
1177 list_add_tail(&sglq->list, lpfc_els_sgl_list); in __lpfc_sli_get_els_sglq()
1183 sglq->ndlp = ndlp; in __lpfc_sli_get_els_sglq()
1185 phba->sli4_hba.lpfc_sglq_active_list[sglq->sli4_lxritag] = sglq; in __lpfc_sli_get_els_sglq()
1186 sglq->state = SGL_ALLOCATED; in __lpfc_sli_get_els_sglq()
1188 spin_unlock(&phba->sli4_hba.sgl_list_lock); in __lpfc_sli_get_els_sglq()
1193 * __lpfc_sli_get_nvmet_sglq - Allocates an iocb object from sgl pool
1208 lpfc_nvmet_sgl_list = &phba->sli4_hba.lpfc_nvmet_sgl_list; in __lpfc_sli_get_nvmet_sglq()
1210 lockdep_assert_held(&phba->sli4_hba.sgl_list_lock); in __lpfc_sli_get_nvmet_sglq()
1215 phba->sli4_hba.lpfc_sglq_active_list[sglq->sli4_lxritag] = sglq; in __lpfc_sli_get_nvmet_sglq()
1216 sglq->state = SGL_ALLOCATED; in __lpfc_sli_get_nvmet_sglq()
1221 * lpfc_sli_get_iocbq - Allocates an iocb object from iocb pool
1235 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli_get_iocbq()
1237 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli_get_iocbq()
1242 * __lpfc_sli_release_iocbq_s4 - Release iocb to the iocb pool
1268 if (iocbq->sli4_xritag == NO_XRI) in __lpfc_sli_release_iocbq_s4()
1271 sglq = __lpfc_clear_active_sglq(phba, iocbq->sli4_lxritag); in __lpfc_sli_release_iocbq_s4()
1275 if (iocbq->iocb_flag & LPFC_IO_NVMET) { in __lpfc_sli_release_iocbq_s4()
1276 spin_lock_irqsave(&phba->sli4_hba.sgl_list_lock, in __lpfc_sli_release_iocbq_s4()
1278 sglq->state = SGL_FREED; in __lpfc_sli_release_iocbq_s4()
1279 sglq->ndlp = NULL; in __lpfc_sli_release_iocbq_s4()
1280 list_add_tail(&sglq->list, in __lpfc_sli_release_iocbq_s4()
1281 &phba->sli4_hba.lpfc_nvmet_sgl_list); in __lpfc_sli_release_iocbq_s4()
1283 &phba->sli4_hba.sgl_list_lock, iflag); in __lpfc_sli_release_iocbq_s4()
1287 pring = phba->sli4_hba.els_wq->pring; in __lpfc_sli_release_iocbq_s4()
1288 if ((iocbq->iocb_flag & LPFC_EXCHANGE_BUSY) && in __lpfc_sli_release_iocbq_s4()
1289 (sglq->state != SGL_XRI_ABORTED)) { in __lpfc_sli_release_iocbq_s4()
1290 spin_lock_irqsave(&phba->sli4_hba.sgl_list_lock, in __lpfc_sli_release_iocbq_s4()
1292 list_add(&sglq->list, in __lpfc_sli_release_iocbq_s4()
1293 &phba->sli4_hba.lpfc_abts_els_sgl_list); in __lpfc_sli_release_iocbq_s4()
1295 &phba->sli4_hba.sgl_list_lock, iflag); in __lpfc_sli_release_iocbq_s4()
1297 spin_lock_irqsave(&phba->sli4_hba.sgl_list_lock, in __lpfc_sli_release_iocbq_s4()
1299 sglq->state = SGL_FREED; in __lpfc_sli_release_iocbq_s4()
1300 sglq->ndlp = NULL; in __lpfc_sli_release_iocbq_s4()
1301 list_add_tail(&sglq->list, in __lpfc_sli_release_iocbq_s4()
1302 &phba->sli4_hba.lpfc_els_sgl_list); in __lpfc_sli_release_iocbq_s4()
1304 &phba->sli4_hba.sgl_list_lock, iflag); in __lpfc_sli_release_iocbq_s4()
1307 if (!list_empty(&pring->txq)) in __lpfc_sli_release_iocbq_s4()
1316 memset((char *)iocbq + start_clean, 0, sizeof(*iocbq) - start_clean); in __lpfc_sli_release_iocbq_s4()
1317 iocbq->sli4_lxritag = NO_XRI; in __lpfc_sli_release_iocbq_s4()
1318 iocbq->sli4_xritag = NO_XRI; in __lpfc_sli_release_iocbq_s4()
1319 iocbq->iocb_flag &= ~(LPFC_IO_NVME | LPFC_IO_NVMET | in __lpfc_sli_release_iocbq_s4()
1321 list_add_tail(&iocbq->list, &phba->lpfc_iocb_list); in __lpfc_sli_release_iocbq_s4()
1326 * __lpfc_sli_release_iocbq_s3 - Release iocb to the iocb pool
1344 memset((char*)iocbq + start_clean, 0, sizeof(*iocbq) - start_clean); in __lpfc_sli_release_iocbq_s3()
1345 iocbq->sli4_xritag = NO_XRI; in __lpfc_sli_release_iocbq_s3()
1346 list_add_tail(&iocbq->list, &phba->lpfc_iocb_list); in __lpfc_sli_release_iocbq_s3()
1350 * __lpfc_sli_release_iocbq - Release iocb to the iocb pool
1362 lockdep_assert_held(&phba->hbalock); in __lpfc_sli_release_iocbq()
1364 phba->__lpfc_sli_release_iocbq(phba, iocbq); in __lpfc_sli_release_iocbq()
1365 phba->iocb_cnt--; in __lpfc_sli_release_iocbq()
1369 * lpfc_sli_release_iocbq - Release iocb to the iocb pool
1384 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli_release_iocbq()
1386 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli_release_iocbq()
1390 * lpfc_sli_cancel_iocbs - Cancel all iocbs from a list.
1394 * @ulpWord4: ULP word-4 in IOCB command field.
1409 if (!piocb->iocb_cmpl) { in lpfc_sli_cancel_iocbs()
1410 if (piocb->iocb_flag & LPFC_IO_NVME) in lpfc_sli_cancel_iocbs()
1415 piocb->iocb.ulpStatus = ulpstatus; in lpfc_sli_cancel_iocbs()
1416 piocb->iocb.un.ulpWord[4] = ulpWord4; in lpfc_sli_cancel_iocbs()
1417 (piocb->iocb_cmpl) (phba, piocb, piocb); in lpfc_sli_cancel_iocbs()
1424 * lpfc_sli_iocb_cmd_type - Get the iocb type
1527 printk("%s - Unhandled SLI-3 Command x%x\n", in lpfc_sli_iocb_cmd_type()
1540 * lpfc_sli_ring_map - Issue config_ring mbox for all rings
1546 * a config_ring mailbox command for each ring.
1553 struct lpfc_sli *psli = &phba->sli; in lpfc_sli_ring_map()
1558 pmb = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli_ring_map()
1560 return -ENOMEM; in lpfc_sli_ring_map()
1561 pmbox = &pmb->u.mb; in lpfc_sli_ring_map()
1562 phba->link_state = LPFC_INIT_MBX_CMDS; in lpfc_sli_ring_map()
1563 for (i = 0; i < psli->num_rings; i++) { in lpfc_sli_ring_map()
1571 rc, pmbox->mbxCommand, in lpfc_sli_ring_map()
1572 pmbox->mbxStatus, i); in lpfc_sli_ring_map()
1573 phba->link_state = LPFC_HBA_ERROR; in lpfc_sli_ring_map()
1574 ret = -ENXIO; in lpfc_sli_ring_map()
1578 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_sli_ring_map()
1583 * lpfc_sli_ringtxcmpl_put - Adds new iocb to the txcmplq
1599 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_sli_ringtxcmpl_put()
1600 lockdep_assert_held(&pring->ring_lock); in lpfc_sli_ringtxcmpl_put()
1602 lockdep_assert_held(&phba->hbalock); in lpfc_sli_ringtxcmpl_put()
1606 list_add_tail(&piocb->list, &pring->txcmplq); in lpfc_sli_ringtxcmpl_put()
1607 piocb->iocb_flag |= LPFC_IO_ON_TXCMPLQ; in lpfc_sli_ringtxcmpl_put()
1608 pring->txcmplq_cnt++; in lpfc_sli_ringtxcmpl_put()
1610 if ((unlikely(pring->ringno == LPFC_ELS_RING)) && in lpfc_sli_ringtxcmpl_put()
1611 (piocb->iocb.ulpCommand != CMD_ABORT_XRI_CN) && in lpfc_sli_ringtxcmpl_put()
1612 (piocb->iocb.ulpCommand != CMD_CLOSE_XRI_CN)) { in lpfc_sli_ringtxcmpl_put()
1613 BUG_ON(!piocb->vport); in lpfc_sli_ringtxcmpl_put()
1614 if (!(piocb->vport->load_flag & FC_UNLOADING)) in lpfc_sli_ringtxcmpl_put()
1615 mod_timer(&piocb->vport->els_tmofunc, in lpfc_sli_ringtxcmpl_put()
1617 msecs_to_jiffies(1000 * (phba->fc_ratov << 1))); in lpfc_sli_ringtxcmpl_put()
1624 * lpfc_sli_ringtx_get - Get first element of the txq
1638 lockdep_assert_held(&phba->hbalock); in lpfc_sli_ringtx_get()
1640 list_remove_head((&pring->txq), cmd_iocb, struct lpfc_iocbq, list); in lpfc_sli_ringtx_get()
1645 * lpfc_sli_next_iocb_slot - Get next iocb slot in the ring
1661 struct lpfc_pgp *pgp = &phba->port_gp[pring->ringno]; in lpfc_sli_next_iocb_slot()
1662 uint32_t max_cmd_idx = pring->sli.sli3.numCiocb; in lpfc_sli_next_iocb_slot()
1664 lockdep_assert_held(&phba->hbalock); in lpfc_sli_next_iocb_slot()
1666 if ((pring->sli.sli3.next_cmdidx == pring->sli.sli3.cmdidx) && in lpfc_sli_next_iocb_slot()
1667 (++pring->sli.sli3.next_cmdidx >= max_cmd_idx)) in lpfc_sli_next_iocb_slot()
1668 pring->sli.sli3.next_cmdidx = 0; in lpfc_sli_next_iocb_slot()
1670 if (unlikely(pring->sli.sli3.local_getidx == in lpfc_sli_next_iocb_slot()
1671 pring->sli.sli3.next_cmdidx)) { in lpfc_sli_next_iocb_slot()
1673 pring->sli.sli3.local_getidx = le32_to_cpu(pgp->cmdGetInx); in lpfc_sli_next_iocb_slot()
1675 if (unlikely(pring->sli.sli3.local_getidx >= max_cmd_idx)) { in lpfc_sli_next_iocb_slot()
1679 pring->ringno, in lpfc_sli_next_iocb_slot()
1680 pring->sli.sli3.local_getidx, in lpfc_sli_next_iocb_slot()
1683 phba->link_state = LPFC_HBA_ERROR; in lpfc_sli_next_iocb_slot()
1688 phba->work_ha |= HA_ERATT; in lpfc_sli_next_iocb_slot()
1689 phba->work_hs = HS_FFER3; in lpfc_sli_next_iocb_slot()
1696 if (pring->sli.sli3.local_getidx == pring->sli.sli3.next_cmdidx) in lpfc_sli_next_iocb_slot()
1704 * lpfc_sli_next_iotag - Get an iotag for the iocb
1721 struct lpfc_sli *psli = &phba->sli; in lpfc_sli_next_iotag()
1724 spin_lock_irq(&phba->hbalock); in lpfc_sli_next_iotag()
1725 iotag = psli->last_iotag; in lpfc_sli_next_iotag()
1726 if(++iotag < psli->iocbq_lookup_len) { in lpfc_sli_next_iotag()
1727 psli->last_iotag = iotag; in lpfc_sli_next_iotag()
1728 psli->iocbq_lookup[iotag] = iocbq; in lpfc_sli_next_iotag()
1729 spin_unlock_irq(&phba->hbalock); in lpfc_sli_next_iotag()
1730 iocbq->iotag = iotag; in lpfc_sli_next_iotag()
1732 } else if (psli->iocbq_lookup_len < (0xffff in lpfc_sli_next_iotag()
1733 - LPFC_IOCBQ_LOOKUP_INCREMENT)) { in lpfc_sli_next_iotag()
1734 new_len = psli->iocbq_lookup_len + LPFC_IOCBQ_LOOKUP_INCREMENT; in lpfc_sli_next_iotag()
1735 spin_unlock_irq(&phba->hbalock); in lpfc_sli_next_iotag()
1739 spin_lock_irq(&phba->hbalock); in lpfc_sli_next_iotag()
1740 old_arr = psli->iocbq_lookup; in lpfc_sli_next_iotag()
1741 if (new_len <= psli->iocbq_lookup_len) { in lpfc_sli_next_iotag()
1744 iotag = psli->last_iotag; in lpfc_sli_next_iotag()
1745 if(++iotag < psli->iocbq_lookup_len) { in lpfc_sli_next_iotag()
1746 psli->last_iotag = iotag; in lpfc_sli_next_iotag()
1747 psli->iocbq_lookup[iotag] = iocbq; in lpfc_sli_next_iotag()
1748 spin_unlock_irq(&phba->hbalock); in lpfc_sli_next_iotag()
1749 iocbq->iotag = iotag; in lpfc_sli_next_iotag()
1752 spin_unlock_irq(&phba->hbalock); in lpfc_sli_next_iotag()
1755 if (psli->iocbq_lookup) in lpfc_sli_next_iotag()
1757 ((psli->last_iotag + 1) * in lpfc_sli_next_iotag()
1759 psli->iocbq_lookup = new_arr; in lpfc_sli_next_iotag()
1760 psli->iocbq_lookup_len = new_len; in lpfc_sli_next_iotag()
1761 psli->last_iotag = iotag; in lpfc_sli_next_iotag()
1762 psli->iocbq_lookup[iotag] = iocbq; in lpfc_sli_next_iotag()
1763 spin_unlock_irq(&phba->hbalock); in lpfc_sli_next_iotag()
1764 iocbq->iotag = iotag; in lpfc_sli_next_iotag()
1769 spin_unlock_irq(&phba->hbalock); in lpfc_sli_next_iotag()
1773 psli->last_iotag); in lpfc_sli_next_iotag()
1779 * lpfc_sli_submit_iocb - Submit an iocb to the firmware
1800 nextiocb->iocb.ulpIoTag = (nextiocb->iocb_cmpl) ? nextiocb->iotag : 0; in lpfc_sli_submit_iocb()
1803 if (pring->ringno == LPFC_ELS_RING) { in lpfc_sli_submit_iocb()
1806 *(((uint32_t *) &nextiocb->iocb) + 4), in lpfc_sli_submit_iocb()
1807 *(((uint32_t *) &nextiocb->iocb) + 6), in lpfc_sli_submit_iocb()
1808 *(((uint32_t *) &nextiocb->iocb) + 7)); in lpfc_sli_submit_iocb()
1814 lpfc_sli_pcimem_bcopy(&nextiocb->iocb, iocb, phba->iocb_cmd_size); in lpfc_sli_submit_iocb()
1816 pring->stats.iocb_cmd++; in lpfc_sli_submit_iocb()
1823 if (nextiocb->iocb_cmpl) in lpfc_sli_submit_iocb()
1832 pring->sli.sli3.cmdidx = pring->sli.sli3.next_cmdidx; in lpfc_sli_submit_iocb()
1833 writel(pring->sli.sli3.cmdidx, &phba->host_gp[pring->ringno].cmdPutInx); in lpfc_sli_submit_iocb()
1837 * lpfc_sli_update_full_ring - Update the chip attention register
1851 int ringno = pring->ringno; in lpfc_sli_update_full_ring()
1853 pring->flag |= LPFC_CALL_RING_AVAILABLE; in lpfc_sli_update_full_ring()
1861 writel((CA_R0ATT|CA_R0CE_REQ) << (ringno*4), phba->CAregaddr); in lpfc_sli_update_full_ring()
1862 readl(phba->CAregaddr); /* flush */ in lpfc_sli_update_full_ring()
1864 pring->stats.iocb_cmd_full++; in lpfc_sli_update_full_ring()
1868 * lpfc_sli_update_ring - Update chip attention register
1879 int ringno = pring->ringno; in lpfc_sli_update_ring()
1884 if (!(phba->sli3_options & LPFC_SLI3_CRP_ENABLED)) { in lpfc_sli_update_ring()
1886 writel(CA_R0ATT << (ringno * 4), phba->CAregaddr); in lpfc_sli_update_ring()
1887 readl(phba->CAregaddr); /* flush */ in lpfc_sli_update_ring()
1892 * lpfc_sli_resume_iocb - Process iocbs in the txq
1906 lockdep_assert_held(&phba->hbalock); in lpfc_sli_resume_iocb()
1917 (!list_empty(&pring->txq)) && in lpfc_sli_resume_iocb()
1918 (pring->ringno != LPFC_FCP_RING || in lpfc_sli_resume_iocb()
1919 phba->sli.sli_flag & LPFC_PROCESS_LA)) { in lpfc_sli_resume_iocb()
1935 * lpfc_sli_next_hbq_slot - Get next hbq entry for the HBQ
1947 struct hbq_s *hbqp = &phba->hbqs[hbqno]; in lpfc_sli_next_hbq_slot()
1949 lockdep_assert_held(&phba->hbalock); in lpfc_sli_next_hbq_slot()
1951 if (hbqp->next_hbqPutIdx == hbqp->hbqPutIdx && in lpfc_sli_next_hbq_slot()
1952 ++hbqp->next_hbqPutIdx >= hbqp->entry_count) in lpfc_sli_next_hbq_slot()
1953 hbqp->next_hbqPutIdx = 0; in lpfc_sli_next_hbq_slot()
1955 if (unlikely(hbqp->local_hbqGetIdx == hbqp->next_hbqPutIdx)) { in lpfc_sli_next_hbq_slot()
1956 uint32_t raw_index = phba->hbq_get[hbqno]; in lpfc_sli_next_hbq_slot()
1959 hbqp->local_hbqGetIdx = getidx; in lpfc_sli_next_hbq_slot()
1961 if (unlikely(hbqp->local_hbqGetIdx >= hbqp->entry_count)) { in lpfc_sli_next_hbq_slot()
1964 "%u is > than hbqp->entry_count %u\n", in lpfc_sli_next_hbq_slot()
1965 hbqno, hbqp->local_hbqGetIdx, in lpfc_sli_next_hbq_slot()
1966 hbqp->entry_count); in lpfc_sli_next_hbq_slot()
1968 phba->link_state = LPFC_HBA_ERROR; in lpfc_sli_next_hbq_slot()
1972 if (hbqp->local_hbqGetIdx == hbqp->next_hbqPutIdx) in lpfc_sli_next_hbq_slot()
1976 return (struct lpfc_hbq_entry *) phba->hbqs[hbqno].hbq_virt + in lpfc_sli_next_hbq_slot()
1977 hbqp->hbqPutIdx; in lpfc_sli_next_hbq_slot()
1981 * lpfc_sli_hbqbuf_free_all - Free all the hbq buffers
1999 spin_lock_irqsave(&phba->hbalock, flags); in lpfc_sli_hbqbuf_free_all()
2002 &phba->hbqs[i].hbq_buffer_list, list) { in lpfc_sli_hbqbuf_free_all()
2004 list_del(&hbq_buf->dbuf.list); in lpfc_sli_hbqbuf_free_all()
2005 (phba->hbqs[i].hbq_free_buffer)(phba, hbq_buf); in lpfc_sli_hbqbuf_free_all()
2007 phba->hbqs[i].buffer_count = 0; in lpfc_sli_hbqbuf_free_all()
2011 phba->hbq_in_use = 0; in lpfc_sli_hbqbuf_free_all()
2012 spin_unlock_irqrestore(&phba->hbalock, flags); in lpfc_sli_hbqbuf_free_all()
2016 * lpfc_sli_hbq_to_firmware - Post the hbq buffer to firmware
2031 lockdep_assert_held(&phba->hbalock); in lpfc_sli_hbq_to_firmware()
2032 return phba->lpfc_sli_hbq_to_firmware(phba, hbqno, hbq_buf); in lpfc_sli_hbq_to_firmware()
2036 * lpfc_sli_hbq_to_firmware_s3 - Post the hbq buffer to SLI3 firmware
2051 dma_addr_t physaddr = hbq_buf->dbuf.phys; in lpfc_sli_hbq_to_firmware_s3()
2053 lockdep_assert_held(&phba->hbalock); in lpfc_sli_hbq_to_firmware_s3()
2057 struct hbq_s *hbqp = &phba->hbqs[hbqno]; in lpfc_sli_hbq_to_firmware_s3()
2059 hbqe->bde.addrHigh = le32_to_cpu(putPaddrHigh(physaddr)); in lpfc_sli_hbq_to_firmware_s3()
2060 hbqe->bde.addrLow = le32_to_cpu(putPaddrLow(physaddr)); in lpfc_sli_hbq_to_firmware_s3()
2061 hbqe->bde.tus.f.bdeSize = hbq_buf->total_size; in lpfc_sli_hbq_to_firmware_s3()
2062 hbqe->bde.tus.f.bdeFlags = 0; in lpfc_sli_hbq_to_firmware_s3()
2063 hbqe->bde.tus.w = le32_to_cpu(hbqe->bde.tus.w); in lpfc_sli_hbq_to_firmware_s3()
2064 hbqe->buffer_tag = le32_to_cpu(hbq_buf->tag); in lpfc_sli_hbq_to_firmware_s3()
2066 hbqp->hbqPutIdx = hbqp->next_hbqPutIdx; in lpfc_sli_hbq_to_firmware_s3()
2067 writel(hbqp->hbqPutIdx, phba->hbq_put + hbqno); in lpfc_sli_hbq_to_firmware_s3()
2069 readl(phba->hbq_put + hbqno); in lpfc_sli_hbq_to_firmware_s3()
2070 list_add_tail(&hbq_buf->dbuf.list, &hbqp->hbq_buffer_list); in lpfc_sli_hbq_to_firmware_s3()
2073 return -ENOMEM; in lpfc_sli_hbq_to_firmware_s3()
2077 * lpfc_sli_hbq_to_firmware_s4 - Post the hbq buffer to SLI4 firmware
2098 hrq = phba->sli4_hba.hdr_rq; in lpfc_sli_hbq_to_firmware_s4()
2099 drq = phba->sli4_hba.dat_rq; in lpfc_sli_hbq_to_firmware_s4()
2101 lockdep_assert_held(&phba->hbalock); in lpfc_sli_hbq_to_firmware_s4()
2102 hrqe.address_lo = putPaddrLow(hbq_buf->hbuf.phys); in lpfc_sli_hbq_to_firmware_s4()
2103 hrqe.address_hi = putPaddrHigh(hbq_buf->hbuf.phys); in lpfc_sli_hbq_to_firmware_s4()
2104 drqe.address_lo = putPaddrLow(hbq_buf->dbuf.phys); in lpfc_sli_hbq_to_firmware_s4()
2105 drqe.address_hi = putPaddrHigh(hbq_buf->dbuf.phys); in lpfc_sli_hbq_to_firmware_s4()
2109 hbq_buf->tag = (rc | (hbqno << 16)); in lpfc_sli_hbq_to_firmware_s4()
2110 list_add_tail(&hbq_buf->dbuf.list, &phba->hbqs[hbqno].hbq_buffer_list); in lpfc_sli_hbq_to_firmware_s4()
2132 * lpfc_sli_hbqbuf_fill_hbqs - Post more hbq buffers to HBQ
2148 if (!phba->hbqs[hbqno].hbq_alloc_buffer) in lpfc_sli_hbqbuf_fill_hbqs()
2151 if ((phba->hbqs[hbqno].buffer_count + count) > in lpfc_sli_hbqbuf_fill_hbqs()
2152 lpfc_hbq_defs[hbqno]->entry_count) in lpfc_sli_hbqbuf_fill_hbqs()
2153 count = lpfc_hbq_defs[hbqno]->entry_count - in lpfc_sli_hbqbuf_fill_hbqs()
2154 phba->hbqs[hbqno].buffer_count; in lpfc_sli_hbqbuf_fill_hbqs()
2159 hbq_buffer = (phba->hbqs[hbqno].hbq_alloc_buffer)(phba); in lpfc_sli_hbqbuf_fill_hbqs()
2162 list_add_tail(&hbq_buffer->dbuf.list, &hbq_buf_list); in lpfc_sli_hbqbuf_fill_hbqs()
2165 spin_lock_irqsave(&phba->hbalock, flags); in lpfc_sli_hbqbuf_fill_hbqs()
2166 if (!phba->hbq_in_use) in lpfc_sli_hbqbuf_fill_hbqs()
2171 hbq_buffer->tag = (phba->hbqs[hbqno].buffer_count | in lpfc_sli_hbqbuf_fill_hbqs()
2174 phba->hbqs[hbqno].buffer_count++; in lpfc_sli_hbqbuf_fill_hbqs()
2177 (phba->hbqs[hbqno].hbq_free_buffer)(phba, hbq_buffer); in lpfc_sli_hbqbuf_fill_hbqs()
2179 spin_unlock_irqrestore(&phba->hbalock, flags); in lpfc_sli_hbqbuf_fill_hbqs()
2182 spin_unlock_irqrestore(&phba->hbalock, flags); in lpfc_sli_hbqbuf_fill_hbqs()
2186 (phba->hbqs[hbqno].hbq_free_buffer)(phba, hbq_buffer); in lpfc_sli_hbqbuf_fill_hbqs()
2192 * lpfc_sli_hbqbuf_add_hbqs - Post more HBQ buffers to firmware
2203 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_sli_hbqbuf_add_hbqs()
2207 lpfc_hbq_defs[qno]->add_count); in lpfc_sli_hbqbuf_add_hbqs()
2211 * lpfc_sli_hbqbuf_init_hbqs - Post initial buffers to the HBQ
2222 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_sli_hbqbuf_init_hbqs()
2224 lpfc_hbq_defs[qno]->entry_count); in lpfc_sli_hbqbuf_init_hbqs()
2227 lpfc_hbq_defs[qno]->init_count); in lpfc_sli_hbqbuf_init_hbqs()
2231 * lpfc_sli_hbqbuf_get - Remove the first hbq off of an hbq list
2248 * lpfc_sli_rqbuf_get - Remove the first dma buffer off of an RQ list
2261 rqbp = hrq->rqbp; in lpfc_sli_rqbuf_get()
2262 list_remove_head(&rqbp->rqb_buffer_list, h_buf, in lpfc_sli_rqbuf_get()
2266 rqbp->buffer_count--; in lpfc_sli_rqbuf_get()
2271 * lpfc_sli_hbqbuf_find - Find the hbq buffer associated with a tag
2290 spin_lock_irq(&phba->hbalock); in lpfc_sli_hbqbuf_find()
2291 list_for_each_entry(d_buf, &phba->hbqs[hbqno].hbq_buffer_list, list) { in lpfc_sli_hbqbuf_find()
2293 if (hbq_buf->tag == tag) { in lpfc_sli_hbqbuf_find()
2294 spin_unlock_irq(&phba->hbalock); in lpfc_sli_hbqbuf_find()
2298 spin_unlock_irq(&phba->hbalock); in lpfc_sli_hbqbuf_find()
2301 tag, phba->hbqs[tag >> 16].buffer_count); in lpfc_sli_hbqbuf_find()
2306 * lpfc_sli_free_hbq - Give back the hbq buffer to firmware
2320 hbqno = hbq_buffer->tag >> 16; in lpfc_sli_free_hbq()
2322 (phba->hbqs[hbqno].hbq_free_buffer)(phba, hbq_buffer); in lpfc_sli_free_hbq()
2327 * lpfc_sli_chk_mbx_command - Check if the mailbox is a legitimate mailbox
2328 * @mbxCommand: mailbox command code.
2330 * This function is called by the mailbox event handler function to verify
2331 * that the completed mailbox command is a legitimate mailbox command. If the
2332 * completed mailbox is not known to the function, it will return MBX_SHUTDOWN
2333 * and the mailbox event handler will take the HBA offline.
2416 * lpfc_sli_wake_mbox_wait - lpfc_sli_issue_mbox_wait mbox completion handler
2418 * @pmboxq: Pointer to mailbox command.
2420 * This is completion handler function for mailbox commands issued from
2422 * mailbox event handler function with no lock held. This function
2424 * of the mailbox.
2436 pmboxq->mbox_flag |= LPFC_MBX_WAKE; in lpfc_sli_wake_mbox_wait()
2437 spin_lock_irqsave(&phba->hbalock, drvr_flag); in lpfc_sli_wake_mbox_wait()
2438 pmbox_done = (struct completion *)pmboxq->context3; in lpfc_sli_wake_mbox_wait()
2441 spin_unlock_irqrestore(&phba->hbalock, drvr_flag); in lpfc_sli_wake_mbox_wait()
2450 if (ndlp->nlp_flag & NLP_RELEASE_RPI) { in __lpfc_sli_rpi_release()
2451 lpfc_sli4_free_rpi(vport->phba, ndlp->nlp_rpi); in __lpfc_sli_rpi_release()
2452 spin_lock_irqsave(&vport->phba->ndlp_lock, iflags); in __lpfc_sli_rpi_release()
2453 ndlp->nlp_flag &= ~NLP_RELEASE_RPI; in __lpfc_sli_rpi_release()
2454 ndlp->nlp_rpi = LPFC_RPI_ALLOC_ERROR; in __lpfc_sli_rpi_release()
2455 spin_unlock_irqrestore(&vport->phba->ndlp_lock, iflags); in __lpfc_sli_rpi_release()
2457 ndlp->nlp_flag &= ~NLP_UNREG_INP; in __lpfc_sli_rpi_release()
2461 * lpfc_sli_def_mbox_cmpl - Default mailbox completion handler
2463 * @pmb: Pointer to mailbox object.
2465 * This function is the default mailbox completion handler. It
2466 * frees the memory resources associated with the completed mailbox
2467 * command. If the completed command is a REG_LOGIN mailbox command,
2468 * this function will issue a UREG_LOGIN to re-claim the RPI.
2473 struct lpfc_vport *vport = pmb->vport; in lpfc_sli_def_mbox_cmpl()
2480 mp = (struct lpfc_dmabuf *)(pmb->ctx_buf); in lpfc_sli_def_mbox_cmpl()
2483 lpfc_mbuf_free(phba, mp->virt, mp->phys); in lpfc_sli_def_mbox_cmpl()
2489 * is in re-discovery driver need to cleanup the RPI. in lpfc_sli_def_mbox_cmpl()
2491 if (!(phba->pport->load_flag & FC_UNLOADING) && in lpfc_sli_def_mbox_cmpl()
2492 pmb->u.mb.mbxCommand == MBX_REG_LOGIN64 && in lpfc_sli_def_mbox_cmpl()
2493 !pmb->u.mb.mbxStatus) { in lpfc_sli_def_mbox_cmpl()
2494 rpi = pmb->u.mb.un.varWords[0]; in lpfc_sli_def_mbox_cmpl()
2495 vpi = pmb->u.mb.un.varRegLogin.vpi; in lpfc_sli_def_mbox_cmpl()
2496 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_sli_def_mbox_cmpl()
2497 vpi -= phba->sli4_hba.max_cfg_param.vpi_base; in lpfc_sli_def_mbox_cmpl()
2499 pmb->vport = vport; in lpfc_sli_def_mbox_cmpl()
2500 pmb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_sli_def_mbox_cmpl()
2506 if ((pmb->u.mb.mbxCommand == MBX_REG_VPI) && in lpfc_sli_def_mbox_cmpl()
2507 !(phba->pport->load_flag & FC_UNLOADING) && in lpfc_sli_def_mbox_cmpl()
2508 !pmb->u.mb.mbxStatus) { in lpfc_sli_def_mbox_cmpl()
2510 spin_lock_irq(shost->host_lock); in lpfc_sli_def_mbox_cmpl()
2511 vport->vpi_state |= LPFC_VPI_REGISTERED; in lpfc_sli_def_mbox_cmpl()
2512 vport->fc_flag &= ~FC_VPORT_NEEDS_REG_VPI; in lpfc_sli_def_mbox_cmpl()
2513 spin_unlock_irq(shost->host_lock); in lpfc_sli_def_mbox_cmpl()
2516 if (pmb->u.mb.mbxCommand == MBX_REG_LOGIN64) { in lpfc_sli_def_mbox_cmpl()
2517 ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp; in lpfc_sli_def_mbox_cmpl()
2519 pmb->ctx_buf = NULL; in lpfc_sli_def_mbox_cmpl()
2520 pmb->ctx_ndlp = NULL; in lpfc_sli_def_mbox_cmpl()
2523 if (pmb->u.mb.mbxCommand == MBX_UNREG_LOGIN) { in lpfc_sli_def_mbox_cmpl()
2524 ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp; in lpfc_sli_def_mbox_cmpl()
2533 ndlp->nlp_rpi, ndlp->nlp_DID, in lpfc_sli_def_mbox_cmpl()
2534 ndlp->nlp_flag, ndlp->nlp_defer_did, ndlp); in lpfc_sli_def_mbox_cmpl()
2536 if ((ndlp->nlp_flag & NLP_UNREG_INP) && in lpfc_sli_def_mbox_cmpl()
2537 (ndlp->nlp_defer_did != NLP_EVT_NOTHING_PENDING)) { in lpfc_sli_def_mbox_cmpl()
2538 ndlp->nlp_flag &= ~NLP_UNREG_INP; in lpfc_sli_def_mbox_cmpl()
2539 ndlp->nlp_defer_did = NLP_EVT_NOTHING_PENDING; in lpfc_sli_def_mbox_cmpl()
2540 lpfc_issue_els_plogi(vport, ndlp->nlp_DID, 0); in lpfc_sli_def_mbox_cmpl()
2544 if (vport->load_flag & FC_UNLOADING) in lpfc_sli_def_mbox_cmpl()
2546 pmb->ctx_ndlp = NULL; in lpfc_sli_def_mbox_cmpl()
2550 /* Check security permission status on INIT_LINK mailbox command */ in lpfc_sli_def_mbox_cmpl()
2551 if ((pmb->u.mb.mbxCommand == MBX_INIT_LINK) && in lpfc_sli_def_mbox_cmpl()
2552 (pmb->u.mb.mbxStatus == MBXERR_SEC_NO_PERMISSION)) in lpfc_sli_def_mbox_cmpl()
2557 if (bf_get(lpfc_mqe_command, &pmb->u.mqe) == MBX_SLI4_CONFIG) in lpfc_sli_def_mbox_cmpl()
2560 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_sli_def_mbox_cmpl()
2563 * lpfc_sli4_unreg_rpi_cmpl_clr - mailbox completion handler
2565 * @pmb: Pointer to mailbox object.
2567 * This function is the unreg rpi mailbox completion handler. It
2568 * frees the memory resources associated with the completed mailbox
2571 * the unreg mailbox command completes, this routine puts the
2578 struct lpfc_vport *vport = pmb->vport; in lpfc_sli4_unreg_rpi_cmpl_clr()
2581 ndlp = pmb->ctx_ndlp; in lpfc_sli4_unreg_rpi_cmpl_clr()
2582 if (pmb->u.mb.mbxCommand == MBX_UNREG_LOGIN) { in lpfc_sli4_unreg_rpi_cmpl_clr()
2583 if (phba->sli_rev == LPFC_SLI_REV4 && in lpfc_sli4_unreg_rpi_cmpl_clr()
2585 &phba->sli4_hba.sli_intf) >= in lpfc_sli4_unreg_rpi_cmpl_clr()
2593 vport->vpi, ndlp->nlp_rpi, in lpfc_sli4_unreg_rpi_cmpl_clr()
2594 ndlp->nlp_DID, ndlp->nlp_defer_did, in lpfc_sli4_unreg_rpi_cmpl_clr()
2595 ndlp->nlp_flag, in lpfc_sli4_unreg_rpi_cmpl_clr()
2596 ndlp->nlp_usg_map, ndlp); in lpfc_sli4_unreg_rpi_cmpl_clr()
2597 ndlp->nlp_flag &= ~NLP_LOGO_ACC; in lpfc_sli4_unreg_rpi_cmpl_clr()
2603 if ((ndlp->nlp_flag & NLP_UNREG_INP) && in lpfc_sli4_unreg_rpi_cmpl_clr()
2604 (ndlp->nlp_defer_did != in lpfc_sli4_unreg_rpi_cmpl_clr()
2611 ndlp->nlp_rpi, ndlp->nlp_DID, in lpfc_sli4_unreg_rpi_cmpl_clr()
2612 ndlp->nlp_defer_did, ndlp); in lpfc_sli4_unreg_rpi_cmpl_clr()
2613 ndlp->nlp_flag &= ~NLP_UNREG_INP; in lpfc_sli4_unreg_rpi_cmpl_clr()
2614 ndlp->nlp_defer_did = in lpfc_sli4_unreg_rpi_cmpl_clr()
2617 vport, ndlp->nlp_DID, 0); in lpfc_sli4_unreg_rpi_cmpl_clr()
2625 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_sli4_unreg_rpi_cmpl_clr()
2629 * lpfc_sli_handle_mb_event - Handle mailbox completions from firmware
2633 * the completed mailbox commands and gives it to upper layers. The interrupt
2634 * service routine processes mailbox completion interrupt and adds completed
2635 * mailbox commands to the mboxq_cmpl queue and signals the worker thread.
2637 * completed mailbox commands in mboxq_cmpl queue to the upper layers. This
2638 * function returns the mailbox commands to the upper layer by calling the
2639 * completion handler function of each mailbox.
2649 phba->sli.slistat.mbox_event++; in lpfc_sli_handle_mb_event()
2652 spin_lock_irq(&phba->hbalock); in lpfc_sli_handle_mb_event()
2653 list_splice_init(&phba->sli.mboxq_cmpl, &cmplq); in lpfc_sli_handle_mb_event()
2654 spin_unlock_irq(&phba->hbalock); in lpfc_sli_handle_mb_event()
2656 /* Get a Mailbox buffer to setup mailbox commands for callback */ in lpfc_sli_handle_mb_event()
2662 pmbox = &pmb->u.mb; in lpfc_sli_handle_mb_event()
2664 if (pmbox->mbxCommand != MBX_HEARTBEAT) { in lpfc_sli_handle_mb_event()
2665 if (pmb->vport) { in lpfc_sli_handle_mb_event()
2666 lpfc_debugfs_disc_trc(pmb->vport, in lpfc_sli_handle_mb_event()
2669 (uint32_t)pmbox->mbxCommand, in lpfc_sli_handle_mb_event()
2670 pmbox->un.varWords[0], in lpfc_sli_handle_mb_event()
2671 pmbox->un.varWords[1]); in lpfc_sli_handle_mb_event()
2674 lpfc_debugfs_disc_trc(phba->pport, in lpfc_sli_handle_mb_event()
2677 (uint32_t)pmbox->mbxCommand, in lpfc_sli_handle_mb_event()
2678 pmbox->un.varWords[0], in lpfc_sli_handle_mb_event()
2679 pmbox->un.varWords[1]); in lpfc_sli_handle_mb_event()
2686 if (lpfc_sli_chk_mbx_command(pmbox->mbxCommand) == in lpfc_sli_handle_mb_event()
2688 /* Unknown mailbox command compl */ in lpfc_sli_handle_mb_event()
2690 "(%d):0323 Unknown Mailbox command " in lpfc_sli_handle_mb_event()
2692 pmb->vport ? pmb->vport->vpi : in lpfc_sli_handle_mb_event()
2694 pmbox->mbxCommand, in lpfc_sli_handle_mb_event()
2699 phba->link_state = LPFC_HBA_ERROR; in lpfc_sli_handle_mb_event()
2700 phba->work_hs = HS_FFER3; in lpfc_sli_handle_mb_event()
2705 if (pmbox->mbxStatus) { in lpfc_sli_handle_mb_event()
2706 phba->sli.slistat.mbox_stat_err++; in lpfc_sli_handle_mb_event()
2707 if (pmbox->mbxStatus == MBXERR_NO_RESOURCES) { in lpfc_sli_handle_mb_event()
2708 /* Mbox cmd cmpl error - RETRYing */ in lpfc_sli_handle_mb_event()
2712 "error - RETRYing Data: x%x " in lpfc_sli_handle_mb_event()
2714 pmb->vport ? pmb->vport->vpi : in lpfc_sli_handle_mb_event()
2716 pmbox->mbxCommand, in lpfc_sli_handle_mb_event()
2721 pmbox->mbxStatus, in lpfc_sli_handle_mb_event()
2722 pmbox->un.varWords[0], in lpfc_sli_handle_mb_event()
2723 pmb->vport ? pmb->vport->port_state : in lpfc_sli_handle_mb_event()
2725 pmbox->mbxStatus = 0; in lpfc_sli_handle_mb_event()
2726 pmbox->mbxOwner = OWN_HOST; in lpfc_sli_handle_mb_event()
2733 /* Mailbox cmd <cmd> Cmpl <cmpl> */ in lpfc_sli_handle_mb_event()
2735 "(%d):0307 Mailbox cmd x%x (x%x/x%x) Cmpl %ps " in lpfc_sli_handle_mb_event()
2738 pmb->vport ? pmb->vport->vpi : 0, in lpfc_sli_handle_mb_event()
2739 pmbox->mbxCommand, in lpfc_sli_handle_mb_event()
2742 pmb->mbox_cmpl, in lpfc_sli_handle_mb_event()
2744 pmbox->un.varWords[0], in lpfc_sli_handle_mb_event()
2745 pmbox->un.varWords[1], in lpfc_sli_handle_mb_event()
2746 pmbox->un.varWords[2], in lpfc_sli_handle_mb_event()
2747 pmbox->un.varWords[3], in lpfc_sli_handle_mb_event()
2748 pmbox->un.varWords[4], in lpfc_sli_handle_mb_event()
2749 pmbox->un.varWords[5], in lpfc_sli_handle_mb_event()
2750 pmbox->un.varWords[6], in lpfc_sli_handle_mb_event()
2751 pmbox->un.varWords[7], in lpfc_sli_handle_mb_event()
2752 pmbox->un.varWords[8], in lpfc_sli_handle_mb_event()
2753 pmbox->un.varWords[9], in lpfc_sli_handle_mb_event()
2754 pmbox->un.varWords[10]); in lpfc_sli_handle_mb_event()
2756 if (pmb->mbox_cmpl) in lpfc_sli_handle_mb_event()
2757 pmb->mbox_cmpl(phba,pmb); in lpfc_sli_handle_mb_event()
2763 * lpfc_sli_get_buff - Get the buffer associated with the buffer tag
2786 return &hbq_entry->dbuf; in lpfc_sli_get_buff()
2790 * lpfc_nvme_unsol_ls_handler - Process an unsolicited event data buffer
2812 d_buf = piocb->context2; in lpfc_nvme_unsol_ls_handler()
2815 fc_hdr = nvmebuf->hbuf.virt; in lpfc_nvme_unsol_ls_handler()
2816 oxid = be16_to_cpu(fc_hdr->fh_ox_id); in lpfc_nvme_unsol_ls_handler()
2819 fctl = (fc_hdr->fh_f_ctl[0] << 16 | in lpfc_nvme_unsol_ls_handler()
2820 fc_hdr->fh_f_ctl[1] << 8 | in lpfc_nvme_unsol_ls_handler()
2821 fc_hdr->fh_f_ctl[2]); in lpfc_nvme_unsol_ls_handler()
2822 size = bf_get(lpfc_rcqe_length, &nvmebuf->cq_event.cqe.rcqe_cmpl); in lpfc_nvme_unsol_ls_handler()
2827 if (phba->pport->load_flag & FC_UNLOADING) { in lpfc_nvme_unsol_ls_handler()
2829 } else if (!(phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME)) { in lpfc_nvme_unsol_ls_handler()
2831 } else if (!phba->nvmet_support && !phba->pport->localport) { in lpfc_nvme_unsol_ls_handler()
2833 } else if (phba->nvmet_support && !phba->targetport) { in lpfc_nvme_unsol_ls_handler()
2835 } else if (unlikely(fc_hdr->fh_r_ctl != FC_RCTL_ELS4_REQ)) { in lpfc_nvme_unsol_ls_handler()
2854 ndlp = lpfc_findnode_did(phba->pport, sid); in lpfc_nvme_unsol_ls_handler()
2856 ((ndlp->nlp_state != NLP_STE_UNMAPPED_NODE) && in lpfc_nvme_unsol_ls_handler()
2857 (ndlp->nlp_state != NLP_STE_MAPPED_NODE))) { in lpfc_nvme_unsol_ls_handler()
2865 axchg->phba = phba; in lpfc_nvme_unsol_ls_handler()
2866 axchg->ndlp = ndlp; in lpfc_nvme_unsol_ls_handler()
2867 axchg->size = size; in lpfc_nvme_unsol_ls_handler()
2868 axchg->oxid = oxid; in lpfc_nvme_unsol_ls_handler()
2869 axchg->sid = sid; in lpfc_nvme_unsol_ls_handler()
2870 axchg->wqeq = NULL; in lpfc_nvme_unsol_ls_handler()
2871 axchg->state = LPFC_NVME_STE_LS_RCV; in lpfc_nvme_unsol_ls_handler()
2872 axchg->entry_cnt = 1; in lpfc_nvme_unsol_ls_handler()
2873 axchg->rqb_buffer = (void *)nvmebuf; in lpfc_nvme_unsol_ls_handler()
2874 axchg->hdwq = &phba->sli4_hba.hdwq[0]; in lpfc_nvme_unsol_ls_handler()
2875 axchg->payload = nvmebuf->dbuf.virt; in lpfc_nvme_unsol_ls_handler()
2876 INIT_LIST_HEAD(&axchg->list); in lpfc_nvme_unsol_ls_handler()
2878 if (phba->nvmet_support) in lpfc_nvme_unsol_ls_handler()
2883 /* if zero, LS was successfully handled. If non-zero, LS not handled */ in lpfc_nvme_unsol_ls_handler()
2891 (phba->nvmet_support) ? "T" : "I", ret); in lpfc_nvme_unsol_ls_handler()
2896 lpfc_in_buf_free(phba, &nvmebuf->dbuf); in lpfc_nvme_unsol_ls_handler()
2907 * lpfc_complete_unsol_iocb - Complete an unsolicited sequence
2934 if (pring->prt[0].profile) { in lpfc_complete_unsol_iocb()
2935 if (pring->prt[0].lpfc_sli_rcv_unsol_event) in lpfc_complete_unsol_iocb()
2936 (pring->prt[0].lpfc_sli_rcv_unsol_event) (phba, pring, in lpfc_complete_unsol_iocb()
2942 for (i = 0; i < pring->num_mask; i++) { in lpfc_complete_unsol_iocb()
2943 if ((pring->prt[i].rctl == fch_r_ctl) && in lpfc_complete_unsol_iocb()
2944 (pring->prt[i].type == fch_type)) { in lpfc_complete_unsol_iocb()
2945 if (pring->prt[i].lpfc_sli_rcv_unsol_event) in lpfc_complete_unsol_iocb()
2946 (pring->prt[i].lpfc_sli_rcv_unsol_event) in lpfc_complete_unsol_iocb()
2955 * lpfc_sli_process_unsol_iocb - Unsolicited iocb handler
2978 irsp = &(saveq->iocb); in lpfc_sli_process_unsol_iocb()
2980 if (irsp->ulpCommand == CMD_ASYNC_STATUS) { in lpfc_sli_process_unsol_iocb()
2981 if (pring->lpfc_sli_rcv_async_status) in lpfc_sli_process_unsol_iocb()
2982 pring->lpfc_sli_rcv_async_status(phba, pring, saveq); in lpfc_sli_process_unsol_iocb()
2990 pring->ringno, in lpfc_sli_process_unsol_iocb()
2991 irsp->un.asyncstat.evt_code); in lpfc_sli_process_unsol_iocb()
2995 if ((irsp->ulpCommand == CMD_IOCB_RET_XRI64_CX) && in lpfc_sli_process_unsol_iocb()
2996 (phba->sli3_options & LPFC_SLI3_HBQ_ENABLED)) { in lpfc_sli_process_unsol_iocb()
2997 if (irsp->ulpBdeCount > 0) { in lpfc_sli_process_unsol_iocb()
2999 irsp->un.ulpWord[3]); in lpfc_sli_process_unsol_iocb()
3003 if (irsp->ulpBdeCount > 1) { in lpfc_sli_process_unsol_iocb()
3005 irsp->unsli3.sli3Words[3]); in lpfc_sli_process_unsol_iocb()
3009 if (irsp->ulpBdeCount > 2) { in lpfc_sli_process_unsol_iocb()
3011 irsp->unsli3.sli3Words[7]); in lpfc_sli_process_unsol_iocb()
3018 if (phba->sli3_options & LPFC_SLI3_HBQ_ENABLED) { in lpfc_sli_process_unsol_iocb()
3019 if (irsp->ulpBdeCount != 0) { in lpfc_sli_process_unsol_iocb()
3020 saveq->context2 = lpfc_sli_get_buff(phba, pring, in lpfc_sli_process_unsol_iocb()
3021 irsp->un.ulpWord[3]); in lpfc_sli_process_unsol_iocb()
3022 if (!saveq->context2) in lpfc_sli_process_unsol_iocb()
3028 pring->ringno, in lpfc_sli_process_unsol_iocb()
3029 irsp->un.ulpWord[3]); in lpfc_sli_process_unsol_iocb()
3031 if (irsp->ulpBdeCount == 2) { in lpfc_sli_process_unsol_iocb()
3032 saveq->context3 = lpfc_sli_get_buff(phba, pring, in lpfc_sli_process_unsol_iocb()
3033 irsp->unsli3.sli3Words[7]); in lpfc_sli_process_unsol_iocb()
3034 if (!saveq->context3) in lpfc_sli_process_unsol_iocb()
3040 pring->ringno, in lpfc_sli_process_unsol_iocb()
3041 irsp->unsli3.sli3Words[7]); in lpfc_sli_process_unsol_iocb()
3043 list_for_each_entry(iocbq, &saveq->list, list) { in lpfc_sli_process_unsol_iocb()
3044 irsp = &(iocbq->iocb); in lpfc_sli_process_unsol_iocb()
3045 if (irsp->ulpBdeCount != 0) { in lpfc_sli_process_unsol_iocb()
3046 iocbq->context2 = lpfc_sli_get_buff(phba, pring, in lpfc_sli_process_unsol_iocb()
3047 irsp->un.ulpWord[3]); in lpfc_sli_process_unsol_iocb()
3048 if (!iocbq->context2) in lpfc_sli_process_unsol_iocb()
3054 ". tag 0x%x\n", pring->ringno, in lpfc_sli_process_unsol_iocb()
3055 irsp->un.ulpWord[3]); in lpfc_sli_process_unsol_iocb()
3057 if (irsp->ulpBdeCount == 2) { in lpfc_sli_process_unsol_iocb()
3058 iocbq->context3 = lpfc_sli_get_buff(phba, pring, in lpfc_sli_process_unsol_iocb()
3059 irsp->unsli3.sli3Words[7]); in lpfc_sli_process_unsol_iocb()
3060 if (!iocbq->context3) in lpfc_sli_process_unsol_iocb()
3067 pring->ringno, in lpfc_sli_process_unsol_iocb()
3068 irsp->unsli3.sli3Words[7]); in lpfc_sli_process_unsol_iocb()
3072 if (irsp->ulpBdeCount != 0 && in lpfc_sli_process_unsol_iocb()
3073 (irsp->ulpCommand == CMD_IOCB_RCV_CONT64_CX || in lpfc_sli_process_unsol_iocb()
3074 irsp->ulpStatus == IOSTAT_INTERMED_RSP)) { in lpfc_sli_process_unsol_iocb()
3078 list_for_each_entry(iocbq, &pring->iocb_continue_saveq, clist) { in lpfc_sli_process_unsol_iocb()
3079 if (iocbq->iocb.unsli3.rcvsli3.ox_id == in lpfc_sli_process_unsol_iocb()
3080 saveq->iocb.unsli3.rcvsli3.ox_id) { in lpfc_sli_process_unsol_iocb()
3081 list_add_tail(&saveq->list, &iocbq->list); in lpfc_sli_process_unsol_iocb()
3087 list_add_tail(&saveq->clist, in lpfc_sli_process_unsol_iocb()
3088 &pring->iocb_continue_saveq); in lpfc_sli_process_unsol_iocb()
3089 if (saveq->iocb.ulpStatus != IOSTAT_INTERMED_RSP) { in lpfc_sli_process_unsol_iocb()
3090 list_del_init(&iocbq->clist); in lpfc_sli_process_unsol_iocb()
3092 irsp = &(saveq->iocb); in lpfc_sli_process_unsol_iocb()
3096 if ((irsp->ulpCommand == CMD_RCV_ELS_REQ64_CX) || in lpfc_sli_process_unsol_iocb()
3097 (irsp->ulpCommand == CMD_RCV_ELS_REQ_CX) || in lpfc_sli_process_unsol_iocb()
3098 (irsp->ulpCommand == CMD_IOCB_RCV_ELS64_CX)) { in lpfc_sli_process_unsol_iocb()
3102 w5p = (WORD5 *)&(saveq->iocb.un.ulpWord[5]); in lpfc_sli_process_unsol_iocb()
3103 Rctl = w5p->hcsw.Rctl; in lpfc_sli_process_unsol_iocb()
3104 Type = w5p->hcsw.Type; in lpfc_sli_process_unsol_iocb()
3107 if ((Rctl == 0) && (pring->ringno == LPFC_ELS_RING) && in lpfc_sli_process_unsol_iocb()
3108 (irsp->ulpCommand == CMD_RCV_SEQUENCE64_CX || in lpfc_sli_process_unsol_iocb()
3109 irsp->ulpCommand == CMD_IOCB_RCV_SEQ64_CX)) { in lpfc_sli_process_unsol_iocb()
3112 w5p->hcsw.Rctl = Rctl; in lpfc_sli_process_unsol_iocb()
3113 w5p->hcsw.Type = Type; in lpfc_sli_process_unsol_iocb()
3121 pring->ringno, Rctl, Type); in lpfc_sli_process_unsol_iocb()
3127 * lpfc_sli_iocbq_lookup - Find command iocb for the given response iocb
3149 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_sli_iocbq_lookup()
3150 temp_lock = &pring->ring_lock; in lpfc_sli_iocbq_lookup()
3152 temp_lock = &phba->hbalock; in lpfc_sli_iocbq_lookup()
3155 iotag = prspiocb->iocb.ulpIoTag; in lpfc_sli_iocbq_lookup()
3157 if (iotag != 0 && iotag <= phba->sli.last_iotag) { in lpfc_sli_iocbq_lookup()
3158 cmd_iocb = phba->sli.iocbq_lookup[iotag]; in lpfc_sli_iocbq_lookup()
3159 if (cmd_iocb->iocb_flag & LPFC_IO_ON_TXCMPLQ) { in lpfc_sli_iocbq_lookup()
3161 list_del_init(&cmd_iocb->list); in lpfc_sli_iocbq_lookup()
3162 cmd_iocb->iocb_flag &= ~LPFC_IO_ON_TXCMPLQ; in lpfc_sli_iocbq_lookup()
3163 pring->txcmplq_cnt--; in lpfc_sli_iocbq_lookup()
3173 iotag, phba->sli.last_iotag, in lpfc_sli_iocbq_lookup()
3174 *(((uint32_t *) &prspiocb->iocb) + 7)); in lpfc_sli_iocbq_lookup()
3179 * lpfc_sli_iocbq_lookup_by_tag - Find command iocb for the iotag
3198 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_sli_iocbq_lookup_by_tag()
3199 temp_lock = &pring->ring_lock; in lpfc_sli_iocbq_lookup_by_tag()
3201 temp_lock = &phba->hbalock; in lpfc_sli_iocbq_lookup_by_tag()
3204 if (iotag != 0 && iotag <= phba->sli.last_iotag) { in lpfc_sli_iocbq_lookup_by_tag()
3205 cmd_iocb = phba->sli.iocbq_lookup[iotag]; in lpfc_sli_iocbq_lookup_by_tag()
3206 if (cmd_iocb->iocb_flag & LPFC_IO_ON_TXCMPLQ) { in lpfc_sli_iocbq_lookup_by_tag()
3208 list_del_init(&cmd_iocb->list); in lpfc_sli_iocbq_lookup_by_tag()
3209 cmd_iocb->iocb_flag &= ~LPFC_IO_ON_TXCMPLQ; in lpfc_sli_iocbq_lookup_by_tag()
3210 pring->txcmplq_cnt--; in lpfc_sli_iocbq_lookup_by_tag()
3220 iotag, phba->sli.last_iotag, in lpfc_sli_iocbq_lookup_by_tag()
3221 cmd_iocb ? cmd_iocb->iocb_flag : 0xffff); in lpfc_sli_iocbq_lookup_by_tag()
3226 * lpfc_sli_process_sol_iocb - process solicited iocb completion
3231 * This function is called by the ring event handler for non-fcp
3252 if (cmdiocbp->iocb_cmpl) { in lpfc_sli_process_sol_iocb()
3257 if (saveq->iocb.ulpStatus && in lpfc_sli_process_sol_iocb()
3258 (pring->ringno == LPFC_ELS_RING) && in lpfc_sli_process_sol_iocb()
3259 (cmdiocbp->iocb.ulpCommand == in lpfc_sli_process_sol_iocb()
3268 if (pring->ringno == LPFC_ELS_RING) { in lpfc_sli_process_sol_iocb()
3269 if ((phba->sli_rev < LPFC_SLI_REV4) && in lpfc_sli_process_sol_iocb()
3270 (cmdiocbp->iocb_flag & in lpfc_sli_process_sol_iocb()
3272 spin_lock_irqsave(&phba->hbalock, in lpfc_sli_process_sol_iocb()
3274 cmdiocbp->iocb_flag &= in lpfc_sli_process_sol_iocb()
3276 spin_unlock_irqrestore(&phba->hbalock, in lpfc_sli_process_sol_iocb()
3278 saveq->iocb.ulpStatus = in lpfc_sli_process_sol_iocb()
3280 saveq->iocb.un.ulpWord[4] = in lpfc_sli_process_sol_iocb()
3287 spin_lock_irqsave(&phba->hbalock, in lpfc_sli_process_sol_iocb()
3289 saveq->iocb_flag |= LPFC_DELAY_MEM_FREE; in lpfc_sli_process_sol_iocb()
3290 spin_unlock_irqrestore(&phba->hbalock, in lpfc_sli_process_sol_iocb()
3293 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_sli_process_sol_iocb()
3294 if (saveq->iocb_flag & in lpfc_sli_process_sol_iocb()
3303 &phba->hbalock, iflag); in lpfc_sli_process_sol_iocb()
3304 cmdiocbp->iocb_flag |= in lpfc_sli_process_sol_iocb()
3307 &phba->hbalock, iflag); in lpfc_sli_process_sol_iocb()
3309 if (cmdiocbp->iocb_flag & in lpfc_sli_process_sol_iocb()
3317 &phba->hbalock, iflag); in lpfc_sli_process_sol_iocb()
3318 cmdiocbp->iocb_flag &= in lpfc_sli_process_sol_iocb()
3321 &phba->hbalock, iflag); in lpfc_sli_process_sol_iocb()
3322 cmdiocbp->iocb.ulpStatus = in lpfc_sli_process_sol_iocb()
3324 cmdiocbp->iocb.un.ulpWord[4] = in lpfc_sli_process_sol_iocb()
3332 saveq->iocb.ulpStatus = in lpfc_sli_process_sol_iocb()
3334 saveq->iocb.un.ulpWord[4] = in lpfc_sli_process_sol_iocb()
3337 &phba->hbalock, iflag); in lpfc_sli_process_sol_iocb()
3338 saveq->iocb_flag |= in lpfc_sli_process_sol_iocb()
3341 &phba->hbalock, iflag); in lpfc_sli_process_sol_iocb()
3345 (cmdiocbp->iocb_cmpl) (phba, cmdiocbp, saveq); in lpfc_sli_process_sol_iocb()
3354 if (pring->ringno != LPFC_ELS_RING) { in lpfc_sli_process_sol_iocb()
3363 pring->ringno, in lpfc_sli_process_sol_iocb()
3364 saveq->iocb.ulpIoTag, in lpfc_sli_process_sol_iocb()
3365 saveq->iocb.ulpStatus, in lpfc_sli_process_sol_iocb()
3366 saveq->iocb.un.ulpWord[4], in lpfc_sli_process_sol_iocb()
3367 saveq->iocb.ulpCommand, in lpfc_sli_process_sol_iocb()
3368 saveq->iocb.ulpContext); in lpfc_sli_process_sol_iocb()
3376 * lpfc_sli_rsp_pointers_error - Response ring pointer error handler
3388 struct lpfc_pgp *pgp = &phba->port_gp[pring->ringno]; in lpfc_sli_rsp_pointers_error()
3396 pring->ringno, le32_to_cpu(pgp->rspPutInx), in lpfc_sli_rsp_pointers_error()
3397 pring->sli.sli3.numRiocb); in lpfc_sli_rsp_pointers_error()
3399 phba->link_state = LPFC_HBA_ERROR; in lpfc_sli_rsp_pointers_error()
3405 phba->work_ha |= HA_ERATT; in lpfc_sli_rsp_pointers_error()
3406 phba->work_hs = HS_FFER3; in lpfc_sli_rsp_pointers_error()
3414 * lpfc_poll_eratt - Error attention polling timer timeout handler
3432 sli_intr = phba->sli.slistat.sli_intr; in lpfc_poll_eratt()
3434 if (phba->sli.slistat.sli_prev_intr > sli_intr) in lpfc_poll_eratt()
3435 cnt = (((uint64_t)(-1) - phba->sli.slistat.sli_prev_intr) + in lpfc_poll_eratt()
3438 cnt = (sli_intr - phba->sli.slistat.sli_prev_intr); in lpfc_poll_eratt()
3440 /* 64-bit integer division not supported on 32-bit x86 - use do_div */ in lpfc_poll_eratt()
3441 do_div(cnt, phba->eratt_poll_interval); in lpfc_poll_eratt()
3442 phba->sli.slistat.sli_ips = cnt; in lpfc_poll_eratt()
3444 phba->sli.slistat.sli_prev_intr = sli_intr; in lpfc_poll_eratt()
3454 mod_timer(&phba->eratt_poll, in lpfc_poll_eratt()
3456 msecs_to_jiffies(1000 * phba->eratt_poll_interval)); in lpfc_poll_eratt()
3462 * lpfc_sli_handle_fast_ring_event - Handle ring events on FCP ring
3482 struct lpfc_pgp *pgp = &phba->port_gp[pring->ringno]; in lpfc_sli_handle_fast_ring_event()
3494 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_handle_fast_ring_event()
3495 pring->stats.iocb_event++; in lpfc_sli_handle_fast_ring_event()
3501 portRspMax = pring->sli.sli3.numRiocb; in lpfc_sli_handle_fast_ring_event()
3502 portRspPut = le32_to_cpu(pgp->rspPutInx); in lpfc_sli_handle_fast_ring_event()
3505 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_handle_fast_ring_event()
3508 if (phba->fcp_ring_in_use) { in lpfc_sli_handle_fast_ring_event()
3509 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_handle_fast_ring_event()
3512 phba->fcp_ring_in_use = 1; in lpfc_sli_handle_fast_ring_event()
3515 while (pring->sli.sli3.rspidx != portRspPut) { in lpfc_sli_handle_fast_ring_event()
3518 * structure. The copy involves a byte-swap since the in lpfc_sli_handle_fast_ring_event()
3522 phba->last_completion_time = jiffies; in lpfc_sli_handle_fast_ring_event()
3524 if (++pring->sli.sli3.rspidx >= portRspMax) in lpfc_sli_handle_fast_ring_event()
3525 pring->sli.sli3.rspidx = 0; in lpfc_sli_handle_fast_ring_event()
3529 phba->iocb_rsp_size); in lpfc_sli_handle_fast_ring_event()
3533 type = lpfc_sli_iocb_cmd_type(irsp->ulpCommand & CMD_IOCB_MASK); in lpfc_sli_handle_fast_ring_event()
3534 pring->stats.iocb_rsp++; in lpfc_sli_handle_fast_ring_event()
3537 if (unlikely(irsp->ulpStatus)) { in lpfc_sli_handle_fast_ring_event()
3542 if ((irsp->ulpStatus == IOSTAT_LOCAL_REJECT) && in lpfc_sli_handle_fast_ring_event()
3543 ((irsp->un.ulpWord[4] & IOERR_PARAM_MASK) == in lpfc_sli_handle_fast_ring_event()
3545 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_handle_fast_ring_event()
3546 phba->lpfc_rampdown_queue_depth(phba); in lpfc_sli_handle_fast_ring_event()
3547 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_handle_fast_ring_event()
3554 pring->ringno, in lpfc_sli_handle_fast_ring_event()
3555 irsp->un.ulpWord[0], in lpfc_sli_handle_fast_ring_event()
3556 irsp->un.ulpWord[1], in lpfc_sli_handle_fast_ring_event()
3557 irsp->un.ulpWord[2], in lpfc_sli_handle_fast_ring_event()
3558 irsp->un.ulpWord[3], in lpfc_sli_handle_fast_ring_event()
3559 irsp->un.ulpWord[4], in lpfc_sli_handle_fast_ring_event()
3560 irsp->un.ulpWord[5], in lpfc_sli_handle_fast_ring_event()
3561 *(uint32_t *)&irsp->un1, in lpfc_sli_handle_fast_ring_event()
3562 *((uint32_t *)&irsp->un1 + 1)); in lpfc_sli_handle_fast_ring_event()
3572 if (unlikely(irsp->ulpCommand == CMD_XRI_ABORTED_CX)) { in lpfc_sli_handle_fast_ring_event()
3577 irsp->ulpCommand); in lpfc_sli_handle_fast_ring_event()
3581 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_handle_fast_ring_event()
3584 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_handle_fast_ring_event()
3587 if (cmdiocbq->iocb_flag & LPFC_DRIVER_ABORTED) in lpfc_sli_handle_fast_ring_event()
3588 cmdiocbq->iocb_flag &= ~LPFC_DRIVER_ABORTED; in lpfc_sli_handle_fast_ring_event()
3589 if (cmdiocbq->iocb_cmpl) { in lpfc_sli_handle_fast_ring_event()
3590 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_handle_fast_ring_event()
3591 (cmdiocbq->iocb_cmpl)(phba, cmdiocbq, in lpfc_sli_handle_fast_ring_event()
3593 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_handle_fast_ring_event()
3597 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_handle_fast_ring_event()
3599 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_handle_fast_ring_event()
3602 if (irsp->ulpCommand == CMD_ADAPTER_MSG) { in lpfc_sli_handle_fast_ring_event()
3607 dev_warn(&((phba->pcidev)->dev), in lpfc_sli_handle_fast_ring_event()
3609 phba->brd_no, adaptermsg); in lpfc_sli_handle_fast_ring_event()
3615 type, irsp->ulpCommand, in lpfc_sli_handle_fast_ring_event()
3616 irsp->ulpStatus, in lpfc_sli_handle_fast_ring_event()
3617 irsp->ulpIoTag, in lpfc_sli_handle_fast_ring_event()
3618 irsp->ulpContext); in lpfc_sli_handle_fast_ring_event()
3626 * been updated, sync the pgp->rspPutInx and fetch the new port in lpfc_sli_handle_fast_ring_event()
3629 writel(pring->sli.sli3.rspidx, in lpfc_sli_handle_fast_ring_event()
3630 &phba->host_gp[pring->ringno].rspGetInx); in lpfc_sli_handle_fast_ring_event()
3632 if (pring->sli.sli3.rspidx == portRspPut) in lpfc_sli_handle_fast_ring_event()
3633 portRspPut = le32_to_cpu(pgp->rspPutInx); in lpfc_sli_handle_fast_ring_event()
3637 pring->stats.iocb_rsp_full++; in lpfc_sli_handle_fast_ring_event()
3638 status = ((CA_R0ATT | CA_R0RE_RSP) << (pring->ringno * 4)); in lpfc_sli_handle_fast_ring_event()
3639 writel(status, phba->CAregaddr); in lpfc_sli_handle_fast_ring_event()
3640 readl(phba->CAregaddr); in lpfc_sli_handle_fast_ring_event()
3642 if ((mask & HA_R0CE_RSP) && (pring->flag & LPFC_CALL_RING_AVAILABLE)) { in lpfc_sli_handle_fast_ring_event()
3643 pring->flag &= ~LPFC_CALL_RING_AVAILABLE; in lpfc_sli_handle_fast_ring_event()
3644 pring->stats.iocb_cmd_empty++; in lpfc_sli_handle_fast_ring_event()
3647 pring->sli.sli3.local_getidx = le32_to_cpu(pgp->cmdGetInx); in lpfc_sli_handle_fast_ring_event()
3650 if ((pring->lpfc_sli_cmd_available)) in lpfc_sli_handle_fast_ring_event()
3651 (pring->lpfc_sli_cmd_available) (phba, pring); in lpfc_sli_handle_fast_ring_event()
3655 phba->fcp_ring_in_use = 0; in lpfc_sli_handle_fast_ring_event()
3656 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_handle_fast_ring_event()
3661 * lpfc_sli_sp_handle_rspiocb - Handle slow-path response iocb
3666 * This function is called from the worker thread when there is a slow-path
3692 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_sp_handle_rspiocb()
3694 list_add_tail(&rspiocbp->list, &(pring->iocb_continueq)); in lpfc_sli_sp_handle_rspiocb()
3695 pring->iocb_continueq_cnt++; in lpfc_sli_sp_handle_rspiocb()
3698 irsp = &rspiocbp->iocb; in lpfc_sli_sp_handle_rspiocb()
3699 if (irsp->ulpLe) { in lpfc_sli_sp_handle_rspiocb()
3705 saveq = list_get_first(&pring->iocb_continueq, in lpfc_sli_sp_handle_rspiocb()
3707 irsp = &(saveq->iocb); in lpfc_sli_sp_handle_rspiocb()
3708 list_del_init(&pring->iocb_continueq); in lpfc_sli_sp_handle_rspiocb()
3709 pring->iocb_continueq_cnt = 0; in lpfc_sli_sp_handle_rspiocb()
3711 pring->stats.iocb_rsp++; in lpfc_sli_sp_handle_rspiocb()
3717 if ((irsp->ulpStatus == IOSTAT_LOCAL_REJECT) && in lpfc_sli_sp_handle_rspiocb()
3718 ((irsp->un.ulpWord[4] & IOERR_PARAM_MASK) == in lpfc_sli_sp_handle_rspiocb()
3720 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_sp_handle_rspiocb()
3721 phba->lpfc_rampdown_queue_depth(phba); in lpfc_sli_sp_handle_rspiocb()
3722 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_sp_handle_rspiocb()
3725 if (irsp->ulpStatus) { in lpfc_sli_sp_handle_rspiocb()
3734 pring->ringno, in lpfc_sli_sp_handle_rspiocb()
3735 irsp->un.ulpWord[0], in lpfc_sli_sp_handle_rspiocb()
3736 irsp->un.ulpWord[1], in lpfc_sli_sp_handle_rspiocb()
3737 irsp->un.ulpWord[2], in lpfc_sli_sp_handle_rspiocb()
3738 irsp->un.ulpWord[3], in lpfc_sli_sp_handle_rspiocb()
3739 irsp->un.ulpWord[4], in lpfc_sli_sp_handle_rspiocb()
3740 irsp->un.ulpWord[5], in lpfc_sli_sp_handle_rspiocb()
3759 iocb_cmd_type = irsp->ulpCommand & CMD_IOCB_MASK; in lpfc_sli_sp_handle_rspiocb()
3763 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_sp_handle_rspiocb()
3765 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_sp_handle_rspiocb()
3769 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_sp_handle_rspiocb()
3771 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_sp_handle_rspiocb()
3778 if (irsp->ulpCommand != CMD_XRI_ABORTED_CX) { in lpfc_sli_sp_handle_rspiocb()
3779 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_sp_handle_rspiocb()
3782 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_sp_handle_rspiocb()
3786 if (cmdiocbp->iocb_cmpl) { in lpfc_sli_sp_handle_rspiocb()
3787 spin_unlock_irqrestore(&phba->hbalock, in lpfc_sli_sp_handle_rspiocb()
3789 (cmdiocbp->iocb_cmpl)(phba, cmdiocbp, in lpfc_sli_sp_handle_rspiocb()
3791 spin_lock_irqsave(&phba->hbalock, in lpfc_sli_sp_handle_rspiocb()
3800 if (irsp->ulpCommand == CMD_ADAPTER_MSG) { in lpfc_sli_sp_handle_rspiocb()
3805 dev_warn(&((phba->pcidev)->dev), in lpfc_sli_sp_handle_rspiocb()
3807 phba->brd_no, adaptermsg); in lpfc_sli_sp_handle_rspiocb()
3814 irsp->ulpCommand, in lpfc_sli_sp_handle_rspiocb()
3815 irsp->ulpStatus, in lpfc_sli_sp_handle_rspiocb()
3816 irsp->ulpIoTag, in lpfc_sli_sp_handle_rspiocb()
3817 irsp->ulpContext); in lpfc_sli_sp_handle_rspiocb()
3824 &saveq->list, list) { in lpfc_sli_sp_handle_rspiocb()
3825 list_del_init(&rspiocbp->list); in lpfc_sli_sp_handle_rspiocb()
3832 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_sp_handle_rspiocb()
3837 * lpfc_sli_handle_slow_ring_event - Wrapper func for handling slow-path iocbs
3849 phba->lpfc_sli_handle_slow_ring_event(phba, pring, mask); in lpfc_sli_handle_slow_ring_event()
3853 * lpfc_sli_handle_slow_ring_event_s3 - Handle SLI3 ring event for non-FCP rings
3859 * for non-fcp rings. The caller does not hold any lock. The function will
3875 pgp = &phba->port_gp[pring->ringno]; in lpfc_sli_handle_slow_ring_event_s3()
3876 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_handle_slow_ring_event_s3()
3877 pring->stats.iocb_event++; in lpfc_sli_handle_slow_ring_event_s3()
3883 portRspMax = pring->sli.sli3.numRiocb; in lpfc_sli_handle_slow_ring_event_s3()
3884 portRspPut = le32_to_cpu(pgp->rspPutInx); in lpfc_sli_handle_slow_ring_event_s3()
3893 pring->ringno, portRspPut, portRspMax); in lpfc_sli_handle_slow_ring_event_s3()
3895 phba->link_state = LPFC_HBA_ERROR; in lpfc_sli_handle_slow_ring_event_s3()
3896 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_handle_slow_ring_event_s3()
3898 phba->work_hs = HS_FFER3; in lpfc_sli_handle_slow_ring_event_s3()
3905 while (pring->sli.sli3.rspidx != portRspPut) { in lpfc_sli_handle_slow_ring_event_s3()
3921 phba->last_completion_time = jiffies; in lpfc_sli_handle_slow_ring_event_s3()
3929 lpfc_sli_pcimem_bcopy(entry, &rspiocbp->iocb, in lpfc_sli_handle_slow_ring_event_s3()
3930 phba->iocb_rsp_size); in lpfc_sli_handle_slow_ring_event_s3()
3931 irsp = &rspiocbp->iocb; in lpfc_sli_handle_slow_ring_event_s3()
3933 if (++pring->sli.sli3.rspidx >= portRspMax) in lpfc_sli_handle_slow_ring_event_s3()
3934 pring->sli.sli3.rspidx = 0; in lpfc_sli_handle_slow_ring_event_s3()
3936 if (pring->ringno == LPFC_ELS_RING) { in lpfc_sli_handle_slow_ring_event_s3()
3944 writel(pring->sli.sli3.rspidx, in lpfc_sli_handle_slow_ring_event_s3()
3945 &phba->host_gp[pring->ringno].rspGetInx); in lpfc_sli_handle_slow_ring_event_s3()
3947 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_handle_slow_ring_event_s3()
3950 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_handle_slow_ring_event_s3()
3954 * the pgp->rspPutInx in the MAILBOX_tand fetch the new port in lpfc_sli_handle_slow_ring_event_s3()
3957 if (pring->sli.sli3.rspidx == portRspPut) { in lpfc_sli_handle_slow_ring_event_s3()
3958 portRspPut = le32_to_cpu(pgp->rspPutInx); in lpfc_sli_handle_slow_ring_event_s3()
3960 } /* while (pring->sli.sli3.rspidx != portRspPut) */ in lpfc_sli_handle_slow_ring_event_s3()
3964 pring->stats.iocb_rsp_full++; in lpfc_sli_handle_slow_ring_event_s3()
3966 status = ((CA_R0ATT | CA_R0RE_RSP) << (pring->ringno * 4)); in lpfc_sli_handle_slow_ring_event_s3()
3967 writel(status, phba->CAregaddr); in lpfc_sli_handle_slow_ring_event_s3()
3968 readl(phba->CAregaddr); /* flush */ in lpfc_sli_handle_slow_ring_event_s3()
3970 if ((mask & HA_R0CE_RSP) && (pring->flag & LPFC_CALL_RING_AVAILABLE)) { in lpfc_sli_handle_slow_ring_event_s3()
3971 pring->flag &= ~LPFC_CALL_RING_AVAILABLE; in lpfc_sli_handle_slow_ring_event_s3()
3972 pring->stats.iocb_cmd_empty++; in lpfc_sli_handle_slow_ring_event_s3()
3975 pring->sli.sli3.local_getidx = le32_to_cpu(pgp->cmdGetInx); in lpfc_sli_handle_slow_ring_event_s3()
3978 if ((pring->lpfc_sli_cmd_available)) in lpfc_sli_handle_slow_ring_event_s3()
3979 (pring->lpfc_sli_cmd_available) (phba, pring); in lpfc_sli_handle_slow_ring_event_s3()
3983 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_handle_slow_ring_event_s3()
3988 * lpfc_sli_handle_slow_ring_event_s4 - Handle SLI4 slow-path els events
3994 * ELS response iocb on the driver internal slow-path response iocb worker
4009 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_handle_slow_ring_event_s4()
4010 phba->hba_flag &= ~HBA_SP_QUEUE_EVT; in lpfc_sli_handle_slow_ring_event_s4()
4011 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_handle_slow_ring_event_s4()
4012 while (!list_empty(&phba->sli4_hba.sp_queue_event)) { in lpfc_sli_handle_slow_ring_event_s4()
4014 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_handle_slow_ring_event_s4()
4015 list_remove_head(&phba->sli4_hba.sp_queue_event, in lpfc_sli_handle_slow_ring_event_s4()
4017 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_handle_slow_ring_event_s4()
4019 switch (bf_get(lpfc_wcqe_c_code, &cq_event->cqe.wcqe_cmpl)) { in lpfc_sli_handle_slow_ring_event_s4()
4049 * lpfc_sli_abort_iocb_ring - Abort all iocbs in the ring
4064 if (pring->ringno == LPFC_ELS_RING) { in lpfc_sli_abort_iocb_ring()
4071 if (phba->sli_rev >= LPFC_SLI_REV4) { in lpfc_sli_abort_iocb_ring()
4072 spin_lock_irq(&pring->ring_lock); in lpfc_sli_abort_iocb_ring()
4073 list_splice_init(&pring->txq, &completions); in lpfc_sli_abort_iocb_ring()
4074 pring->txq_cnt = 0; in lpfc_sli_abort_iocb_ring()
4075 spin_unlock_irq(&pring->ring_lock); in lpfc_sli_abort_iocb_ring()
4077 spin_lock_irq(&phba->hbalock); in lpfc_sli_abort_iocb_ring()
4079 list_for_each_entry_safe(iocb, next_iocb, &pring->txcmplq, list) in lpfc_sli_abort_iocb_ring()
4081 spin_unlock_irq(&phba->hbalock); in lpfc_sli_abort_iocb_ring()
4083 spin_lock_irq(&phba->hbalock); in lpfc_sli_abort_iocb_ring()
4084 list_splice_init(&pring->txq, &completions); in lpfc_sli_abort_iocb_ring()
4085 pring->txq_cnt = 0; in lpfc_sli_abort_iocb_ring()
4088 list_for_each_entry_safe(iocb, next_iocb, &pring->txcmplq, list) in lpfc_sli_abort_iocb_ring()
4090 spin_unlock_irq(&phba->hbalock); in lpfc_sli_abort_iocb_ring()
4099 * lpfc_sli_abort_fcp_rings - Abort all iocbs in all FCP rings
4110 struct lpfc_sli *psli = &phba->sli; in lpfc_sli_abort_fcp_rings()
4115 if (phba->sli_rev >= LPFC_SLI_REV4) { in lpfc_sli_abort_fcp_rings()
4116 for (i = 0; i < phba->cfg_hdw_queue; i++) { in lpfc_sli_abort_fcp_rings()
4117 pring = phba->sli4_hba.hdwq[i].io_wq->pring; in lpfc_sli_abort_fcp_rings()
4121 pring = &psli->sli3_ring[LPFC_FCP_RING]; in lpfc_sli_abort_fcp_rings()
4127 * lpfc_sli_flush_io_rings - flush all iocbs in the IO ring
4141 struct lpfc_sli *psli = &phba->sli; in lpfc_sli_flush_io_rings()
4146 spin_lock_irq(&phba->hbalock); in lpfc_sli_flush_io_rings()
4147 if (phba->hba_flag & HBA_IOQ_FLUSH || in lpfc_sli_flush_io_rings()
4148 !phba->sli4_hba.hdwq) { in lpfc_sli_flush_io_rings()
4149 spin_unlock_irq(&phba->hbalock); in lpfc_sli_flush_io_rings()
4153 phba->hba_flag |= HBA_IOQ_FLUSH; in lpfc_sli_flush_io_rings()
4154 spin_unlock_irq(&phba->hbalock); in lpfc_sli_flush_io_rings()
4157 if (phba->sli_rev >= LPFC_SLI_REV4) { in lpfc_sli_flush_io_rings()
4158 for (i = 0; i < phba->cfg_hdw_queue; i++) { in lpfc_sli_flush_io_rings()
4159 pring = phba->sli4_hba.hdwq[i].io_wq->pring; in lpfc_sli_flush_io_rings()
4161 spin_lock_irq(&pring->ring_lock); in lpfc_sli_flush_io_rings()
4163 list_splice_init(&pring->txq, &txq); in lpfc_sli_flush_io_rings()
4165 &pring->txcmplq, list) in lpfc_sli_flush_io_rings()
4166 piocb->iocb_flag &= ~LPFC_IO_ON_TXCMPLQ; in lpfc_sli_flush_io_rings()
4168 list_splice_init(&pring->txcmplq, &txcmplq); in lpfc_sli_flush_io_rings()
4169 pring->txq_cnt = 0; in lpfc_sli_flush_io_rings()
4170 pring->txcmplq_cnt = 0; in lpfc_sli_flush_io_rings()
4171 spin_unlock_irq(&pring->ring_lock); in lpfc_sli_flush_io_rings()
4183 pring = &psli->sli3_ring[LPFC_FCP_RING]; in lpfc_sli_flush_io_rings()
4185 spin_lock_irq(&phba->hbalock); in lpfc_sli_flush_io_rings()
4187 list_splice_init(&pring->txq, &txq); in lpfc_sli_flush_io_rings()
4189 &pring->txcmplq, list) in lpfc_sli_flush_io_rings()
4190 piocb->iocb_flag &= ~LPFC_IO_ON_TXCMPLQ; in lpfc_sli_flush_io_rings()
4192 list_splice_init(&pring->txcmplq, &txcmplq); in lpfc_sli_flush_io_rings()
4193 pring->txq_cnt = 0; in lpfc_sli_flush_io_rings()
4194 pring->txcmplq_cnt = 0; in lpfc_sli_flush_io_rings()
4195 spin_unlock_irq(&phba->hbalock); in lpfc_sli_flush_io_rings()
4207 * lpfc_sli_brdready_s3 - Check for sli3 host ready status
4227 if (lpfc_readl(phba->HSregaddr, &status)) in lpfc_sli_brdready_s3()
4249 phba->pport->port_state = LPFC_VPORT_UNKNOWN; in lpfc_sli_brdready_s3()
4253 if (lpfc_readl(phba->HSregaddr, &status)) { in lpfc_sli_brdready_s3()
4265 readl(phba->MBslimaddr + 0xa8), in lpfc_sli_brdready_s3()
4266 readl(phba->MBslimaddr + 0xac)); in lpfc_sli_brdready_s3()
4267 phba->link_state = LPFC_HBA_ERROR; in lpfc_sli_brdready_s3()
4275 * lpfc_sli_brdready_s4 - Check for sli4 host ready status
4295 phba->pport->port_state = LPFC_VPORT_UNKNOWN; in lpfc_sli_brdready_s4()
4302 phba->link_state = LPFC_HBA_ERROR; in lpfc_sli_brdready_s4()
4305 phba->sli4_hba.intr_enable = 0; in lpfc_sli_brdready_s4()
4311 * lpfc_sli_brdready - Wrapper func for checking the hba readyness
4321 return phba->lpfc_sli_brdready(phba, mask); in lpfc_sli_brdready()
4327 * lpfc_reset_barrier - Make HBA ready for HBA reset
4342 lockdep_assert_held(&phba->hbalock); in lpfc_reset_barrier()
4344 pci_read_config_byte(phba->pcidev, PCI_HEADER_TYPE, &hdrtype); in lpfc_reset_barrier()
4346 (FC_JEDEC_ID(phba->vpd.rev.biuRev) != HELIOS_JEDEC_ID && in lpfc_reset_barrier()
4347 FC_JEDEC_ID(phba->vpd.rev.biuRev) != THOR_JEDEC_ID)) in lpfc_reset_barrier()
4354 resp_buf = phba->MBslimaddr; in lpfc_reset_barrier()
4357 if (lpfc_readl(phba->HCregaddr, &hc_copy)) in lpfc_reset_barrier()
4359 writel((hc_copy & ~HC_ERINT_ENA), phba->HCregaddr); in lpfc_reset_barrier()
4360 readl(phba->HCregaddr); /* flush */ in lpfc_reset_barrier()
4361 phba->link_flag |= LS_IGNORE_ERATT; in lpfc_reset_barrier()
4363 if (lpfc_readl(phba->HAregaddr, &ha_copy)) in lpfc_reset_barrier()
4367 writel(HA_ERATT, phba->HAregaddr); in lpfc_reset_barrier()
4368 phba->pport->stopped = 1; in lpfc_reset_barrier()
4372 ((MAILBOX_t *)&mbox)->mbxCommand = MBX_KILL_BOARD; in lpfc_reset_barrier()
4373 ((MAILBOX_t *)&mbox)->mbxOwner = OWN_CHIP; in lpfc_reset_barrier()
4376 mbox_buf = phba->MBslimaddr; in lpfc_reset_barrier()
4391 if (phba->sli.sli_flag & LPFC_SLI_ACTIVE || in lpfc_reset_barrier()
4392 phba->pport->stopped) in lpfc_reset_barrier()
4398 ((MAILBOX_t *)&mbox)->mbxOwner = OWN_HOST; in lpfc_reset_barrier()
4412 if (lpfc_readl(phba->HAregaddr, &ha_copy)) in lpfc_reset_barrier()
4420 if (readl(phba->HAregaddr) & HA_ERATT) { in lpfc_reset_barrier()
4421 writel(HA_ERATT, phba->HAregaddr); in lpfc_reset_barrier()
4422 phba->pport->stopped = 1; in lpfc_reset_barrier()
4426 phba->link_flag &= ~LS_IGNORE_ERATT; in lpfc_reset_barrier()
4427 writel(hc_copy, phba->HCregaddr); in lpfc_reset_barrier()
4428 readl(phba->HCregaddr); /* flush */ in lpfc_reset_barrier()
4432 * lpfc_sli_brdkill - Issue a kill_board mailbox command
4435 * This function issues a kill_board mailbox command and waits for
4452 psli = &phba->sli; in lpfc_sli_brdkill()
4457 phba->pport->port_state, psli->sli_flag); in lpfc_sli_brdkill()
4459 pmb = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli_brdkill()
4464 spin_lock_irq(&phba->hbalock); in lpfc_sli_brdkill()
4465 if (lpfc_readl(phba->HCregaddr, &status)) { in lpfc_sli_brdkill()
4466 spin_unlock_irq(&phba->hbalock); in lpfc_sli_brdkill()
4467 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_sli_brdkill()
4471 writel(status, phba->HCregaddr); in lpfc_sli_brdkill()
4472 readl(phba->HCregaddr); /* flush */ in lpfc_sli_brdkill()
4473 phba->link_flag |= LS_IGNORE_ERATT; in lpfc_sli_brdkill()
4474 spin_unlock_irq(&phba->hbalock); in lpfc_sli_brdkill()
4477 pmb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_sli_brdkill()
4482 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_sli_brdkill()
4486 spin_lock_irq(&phba->hbalock); in lpfc_sli_brdkill()
4487 phba->link_flag &= ~LS_IGNORE_ERATT; in lpfc_sli_brdkill()
4488 spin_unlock_irq(&phba->hbalock); in lpfc_sli_brdkill()
4492 spin_lock_irq(&phba->hbalock); in lpfc_sli_brdkill()
4493 psli->sli_flag &= ~LPFC_SLI_ACTIVE; in lpfc_sli_brdkill()
4494 spin_unlock_irq(&phba->hbalock); in lpfc_sli_brdkill()
4496 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_sli_brdkill()
4503 if (lpfc_readl(phba->HAregaddr, &ha_copy)) in lpfc_sli_brdkill()
4507 if (lpfc_readl(phba->HAregaddr, &ha_copy)) in lpfc_sli_brdkill()
4511 del_timer_sync(&psli->mbox_tmo); in lpfc_sli_brdkill()
4513 writel(HA_ERATT, phba->HAregaddr); in lpfc_sli_brdkill()
4514 phba->pport->stopped = 1; in lpfc_sli_brdkill()
4516 spin_lock_irq(&phba->hbalock); in lpfc_sli_brdkill()
4517 psli->sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; in lpfc_sli_brdkill()
4518 psli->mbox_active = NULL; in lpfc_sli_brdkill()
4519 phba->link_flag &= ~LS_IGNORE_ERATT; in lpfc_sli_brdkill()
4520 spin_unlock_irq(&phba->hbalock); in lpfc_sli_brdkill()
4523 phba->link_state = LPFC_HBA_ERROR; in lpfc_sli_brdkill()
4529 * lpfc_sli_brdreset - Reset a sli-2 or sli-3 HBA
4547 psli = &phba->sli; in lpfc_sli_brdreset()
4552 (phba->pport) ? phba->pport->port_state : 0, in lpfc_sli_brdreset()
4553 psli->sli_flag); in lpfc_sli_brdreset()
4556 phba->fc_eventTag = 0; in lpfc_sli_brdreset()
4557 phba->link_events = 0; in lpfc_sli_brdreset()
4558 if (phba->pport) { in lpfc_sli_brdreset()
4559 phba->pport->fc_myDID = 0; in lpfc_sli_brdreset()
4560 phba->pport->fc_prevDID = 0; in lpfc_sli_brdreset()
4564 if (pci_read_config_word(phba->pcidev, PCI_COMMAND, &cfg_value)) in lpfc_sli_brdreset()
4565 return -EIO; in lpfc_sli_brdreset()
4567 pci_write_config_word(phba->pcidev, PCI_COMMAND, in lpfc_sli_brdreset()
4571 psli->sli_flag &= ~(LPFC_SLI_ACTIVE | LPFC_PROCESS_LA); in lpfc_sli_brdreset()
4574 writel(HC_INITFF, phba->HCregaddr); in lpfc_sli_brdreset()
4576 readl(phba->HCregaddr); /* flush */ in lpfc_sli_brdreset()
4577 writel(0, phba->HCregaddr); in lpfc_sli_brdreset()
4578 readl(phba->HCregaddr); /* flush */ in lpfc_sli_brdreset()
4581 pci_write_config_word(phba->pcidev, PCI_COMMAND, cfg_value); in lpfc_sli_brdreset()
4584 for (i = 0; i < psli->num_rings; i++) { in lpfc_sli_brdreset()
4585 pring = &psli->sli3_ring[i]; in lpfc_sli_brdreset()
4586 pring->flag = 0; in lpfc_sli_brdreset()
4587 pring->sli.sli3.rspidx = 0; in lpfc_sli_brdreset()
4588 pring->sli.sli3.next_cmdidx = 0; in lpfc_sli_brdreset()
4589 pring->sli.sli3.local_getidx = 0; in lpfc_sli_brdreset()
4590 pring->sli.sli3.cmdidx = 0; in lpfc_sli_brdreset()
4591 pring->missbufcnt = 0; in lpfc_sli_brdreset()
4594 phba->link_state = LPFC_WARM_START; in lpfc_sli_brdreset()
4599 * lpfc_sli4_brdreset - Reset a sli-4 HBA
4611 struct lpfc_sli *psli = &phba->sli; in lpfc_sli4_brdreset()
4618 phba->pport->port_state, psli->sli_flag, in lpfc_sli4_brdreset()
4619 phba->hba_flag); in lpfc_sli4_brdreset()
4622 phba->fc_eventTag = 0; in lpfc_sli4_brdreset()
4623 phba->link_events = 0; in lpfc_sli4_brdreset()
4624 phba->pport->fc_myDID = 0; in lpfc_sli4_brdreset()
4625 phba->pport->fc_prevDID = 0; in lpfc_sli4_brdreset()
4627 spin_lock_irq(&phba->hbalock); in lpfc_sli4_brdreset()
4628 psli->sli_flag &= ~(LPFC_PROCESS_LA); in lpfc_sli4_brdreset()
4629 phba->fcf.fcf_flag = 0; in lpfc_sli4_brdreset()
4630 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_brdreset()
4637 if (pci_read_config_word(phba->pcidev, PCI_COMMAND, &cfg_value)) { in lpfc_sli4_brdreset()
4640 return -EIO; in lpfc_sli4_brdreset()
4643 pci_write_config_word(phba->pcidev, PCI_COMMAND, (cfg_value & in lpfc_sli4_brdreset()
4650 pci_write_config_word(phba->pcidev, PCI_COMMAND, cfg_value); in lpfc_sli4_brdreset()
4656 * lpfc_sli_brdrestart_s3 - Restart a sli-3 hba
4661 * This function writes MBX_RESTART mailbox command to the SLIM and
4665 * The function does not guarantee completion of MBX_RESTART mailbox
4677 spin_lock_irq(&phba->hbalock); in lpfc_sli_brdrestart_s3()
4680 hba_aer_enabled = phba->hba_flag & HBA_AER_ENABLED; in lpfc_sli_brdrestart_s3()
4682 psli = &phba->sli; in lpfc_sli_brdrestart_s3()
4687 (phba->pport) ? phba->pport->port_state : 0, in lpfc_sli_brdrestart_s3()
4688 psli->sli_flag); in lpfc_sli_brdrestart_s3()
4692 mb->mbxCommand = MBX_RESTART; in lpfc_sli_brdrestart_s3()
4693 mb->mbxHc = 1; in lpfc_sli_brdrestart_s3()
4697 to_slim = phba->MBslimaddr; in lpfc_sli_brdrestart_s3()
4702 if (phba->pport && phba->pport->port_state) in lpfc_sli_brdrestart_s3()
4706 to_slim = phba->MBslimaddr + sizeof (uint32_t); in lpfc_sli_brdrestart_s3()
4711 if (phba->pport) in lpfc_sli_brdrestart_s3()
4712 phba->pport->stopped = 0; in lpfc_sli_brdrestart_s3()
4713 phba->link_state = LPFC_INIT_START; in lpfc_sli_brdrestart_s3()
4714 phba->hba_flag = 0; in lpfc_sli_brdrestart_s3()
4715 spin_unlock_irq(&phba->hbalock); in lpfc_sli_brdrestart_s3()
4717 memset(&psli->lnk_stat_offsets, 0, sizeof(psli->lnk_stat_offsets)); in lpfc_sli_brdrestart_s3()
4718 psli->stats_start = ktime_get_seconds(); in lpfc_sli_brdrestart_s3()
4725 pci_disable_pcie_error_reporting(phba->pcidev); in lpfc_sli_brdrestart_s3()
4733 * lpfc_sli_brdrestart_s4 - Restart the sli-4 hba
4744 struct lpfc_sli *psli = &phba->sli; in lpfc_sli_brdrestart_s4()
4751 phba->pport->port_state, psli->sli_flag); in lpfc_sli_brdrestart_s4()
4754 hba_aer_enabled = phba->hba_flag & HBA_AER_ENABLED; in lpfc_sli_brdrestart_s4()
4758 phba->link_state = LPFC_HBA_ERROR; in lpfc_sli_brdrestart_s4()
4762 spin_lock_irq(&phba->hbalock); in lpfc_sli_brdrestart_s4()
4763 phba->pport->stopped = 0; in lpfc_sli_brdrestart_s4()
4764 phba->link_state = LPFC_INIT_START; in lpfc_sli_brdrestart_s4()
4765 phba->hba_flag = 0; in lpfc_sli_brdrestart_s4()
4766 spin_unlock_irq(&phba->hbalock); in lpfc_sli_brdrestart_s4()
4768 memset(&psli->lnk_stat_offsets, 0, sizeof(psli->lnk_stat_offsets)); in lpfc_sli_brdrestart_s4()
4769 psli->stats_start = ktime_get_seconds(); in lpfc_sli_brdrestart_s4()
4773 pci_disable_pcie_error_reporting(phba->pcidev); in lpfc_sli_brdrestart_s4()
4783 * lpfc_sli_brdrestart - Wrapper func for restarting hba
4792 return phba->lpfc_sli_brdrestart(phba); in lpfc_sli_brdrestart()
4796 * lpfc_sli_chipset_init - Wait for the restart of the HBA after a restart
4811 if (lpfc_readl(phba->HSregaddr, &status)) in lpfc_sli_chipset_init()
4812 return -EIO; in lpfc_sli_chipset_init()
4833 readl(phba->MBslimaddr + 0xa8), in lpfc_sli_chipset_init()
4834 readl(phba->MBslimaddr + 0xac)); in lpfc_sli_chipset_init()
4835 phba->link_state = LPFC_HBA_ERROR; in lpfc_sli_chipset_init()
4836 return -ETIMEDOUT; in lpfc_sli_chipset_init()
4848 readl(phba->MBslimaddr + 0xa8), in lpfc_sli_chipset_init()
4849 readl(phba->MBslimaddr + 0xac)); in lpfc_sli_chipset_init()
4850 phba->link_state = LPFC_HBA_ERROR; in lpfc_sli_chipset_init()
4851 return -EIO; in lpfc_sli_chipset_init()
4863 phba->pport->port_state = LPFC_VPORT_UNKNOWN; in lpfc_sli_chipset_init()
4867 if (lpfc_readl(phba->HSregaddr, &status)) in lpfc_sli_chipset_init()
4868 return -EIO; in lpfc_sli_chipset_init()
4879 readl(phba->MBslimaddr + 0xa8), in lpfc_sli_chipset_init()
4880 readl(phba->MBslimaddr + 0xac)); in lpfc_sli_chipset_init()
4881 phba->link_state = LPFC_HBA_ERROR; in lpfc_sli_chipset_init()
4882 return -EIO; in lpfc_sli_chipset_init()
4886 writel(0, phba->HCregaddr); in lpfc_sli_chipset_init()
4887 readl(phba->HCregaddr); /* flush */ in lpfc_sli_chipset_init()
4890 writel(0xffffffff, phba->HAregaddr); in lpfc_sli_chipset_init()
4891 readl(phba->HAregaddr); /* flush */ in lpfc_sli_chipset_init()
4896 * lpfc_sli_hbq_count - Get the number of HBQs to be configured
4908 * lpfc_sli_hbq_entry_count - Calculate total number of hbq entries
4922 count += lpfc_hbq_defs[i]->entry_count; in lpfc_sli_hbq_entry_count()
4927 * lpfc_sli_hbq_size - Calculate memory required for all hbq entries
4939 * lpfc_sli_hbq_setup - configure and initialize HBQs
4956 /* Get a Mailbox buffer to setup mailbox in lpfc_sli_hbq_setup()
4959 pmb = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli_hbq_setup()
4962 return -ENOMEM; in lpfc_sli_hbq_setup()
4964 pmbox = &pmb->u.mb; in lpfc_sli_hbq_setup()
4967 phba->link_state = LPFC_INIT_MBX_CMDS; in lpfc_sli_hbq_setup()
4968 phba->hbq_in_use = 1; in lpfc_sli_hbq_setup()
4972 phba->hbqs[hbqno].next_hbqPutIdx = 0; in lpfc_sli_hbq_setup()
4973 phba->hbqs[hbqno].hbqPutIdx = 0; in lpfc_sli_hbq_setup()
4974 phba->hbqs[hbqno].local_hbqGetIdx = 0; in lpfc_sli_hbq_setup()
4975 phba->hbqs[hbqno].entry_count = in lpfc_sli_hbq_setup()
4976 lpfc_hbq_defs[hbqno]->entry_count; in lpfc_sli_hbq_setup()
4979 hbq_entry_index += phba->hbqs[hbqno].entry_count; in lpfc_sli_hbq_setup()
4989 pmbox->mbxCommand, in lpfc_sli_hbq_setup()
4990 pmbox->mbxStatus, hbqno); in lpfc_sli_hbq_setup()
4992 phba->link_state = LPFC_HBA_ERROR; in lpfc_sli_hbq_setup()
4993 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_sli_hbq_setup()
4994 return -ENXIO; in lpfc_sli_hbq_setup()
4997 phba->hbq_count = hbq_count; in lpfc_sli_hbq_setup()
4999 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_sli_hbq_setup()
5008 * lpfc_sli4_rb_setup - Initialize and post RBs to HBA
5019 phba->hbq_in_use = 1; in lpfc_sli4_rb_setup()
5025 if (phba->cfg_enable_mds_diags && phba->mds_diags_support) in lpfc_sli4_rb_setup()
5026 phba->hbqs[LPFC_ELS_HBQ].entry_count = in lpfc_sli4_rb_setup()
5027 lpfc_hbq_defs[LPFC_ELS_HBQ]->entry_count >> 1; in lpfc_sli4_rb_setup()
5029 phba->hbqs[LPFC_ELS_HBQ].entry_count = in lpfc_sli4_rb_setup()
5030 lpfc_hbq_defs[LPFC_ELS_HBQ]->entry_count; in lpfc_sli4_rb_setup()
5031 phba->hbq_count = 1; in lpfc_sli4_rb_setup()
5038 * lpfc_sli_config_port - Issue config port mailbox command
5040 * @sli_mode: sli mode - 2/3
5043 * to issue config_port mailbox command. This function restarts the
5044 * HBA firmware and issues a config_port mailbox command to configure
5056 pmb = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli_config_port()
5058 phba->link_state = LPFC_HBA_ERROR; in lpfc_sli_config_port()
5059 return -ENOMEM; in lpfc_sli_config_port()
5062 phba->sli_rev = sli_mode; in lpfc_sli_config_port()
5064 spin_lock_irq(&phba->hbalock); in lpfc_sli_config_port()
5065 phba->sli.sli_flag |= LPFC_SLI_MBOX_ACTIVE; in lpfc_sli_config_port()
5066 spin_unlock_irq(&phba->hbalock); in lpfc_sli_config_port()
5067 phba->pport->port_state = LPFC_VPORT_UNKNOWN; in lpfc_sli_config_port()
5073 spin_lock_irq(&phba->hbalock); in lpfc_sli_config_port()
5074 phba->sli.sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; in lpfc_sli_config_port()
5075 spin_unlock_irq(&phba->hbalock); in lpfc_sli_config_port()
5078 /* Call pre CONFIG_PORT mailbox command initialization. A in lpfc_sli_config_port()
5084 if (rc == -ERESTART) { in lpfc_sli_config_port()
5085 phba->link_state = LPFC_LINK_UNKNOWN; in lpfc_sli_config_port()
5090 phba->link_state = LPFC_INIT_MBX_CMDS; in lpfc_sli_config_port()
5093 phba->sli3_options &= ~(LPFC_SLI3_NPIV_ENABLED | in lpfc_sli_config_port()
5101 pmb->u.mb.mbxCommand, pmb->u.mb.mbxStatus, 0); in lpfc_sli_config_port()
5102 spin_lock_irq(&phba->hbalock); in lpfc_sli_config_port()
5103 phba->sli.sli_flag &= ~LPFC_SLI_ACTIVE; in lpfc_sli_config_port()
5104 spin_unlock_irq(&phba->hbalock); in lpfc_sli_config_port()
5105 rc = -ENXIO; in lpfc_sli_config_port()
5107 /* Allow asynchronous mailbox command to go through */ in lpfc_sli_config_port()
5108 spin_lock_irq(&phba->hbalock); in lpfc_sli_config_port()
5109 phba->sli.sli_flag &= ~LPFC_SLI_ASYNC_MBX_BLK; in lpfc_sli_config_port()
5110 spin_unlock_irq(&phba->hbalock); in lpfc_sli_config_port()
5113 if ((pmb->u.mb.un.varCfgPort.casabt == 1) && in lpfc_sli_config_port()
5114 (pmb->u.mb.un.varCfgPort.gasabt == 0)) in lpfc_sli_config_port()
5120 rc = -EINVAL; in lpfc_sli_config_port()
5123 if (pmb->u.mb.un.varCfgPort.sli_mode == 3) { in lpfc_sli_config_port()
5124 if (!pmb->u.mb.un.varCfgPort.cMA) { in lpfc_sli_config_port()
5125 rc = -ENXIO; in lpfc_sli_config_port()
5128 if (phba->max_vpi && pmb->u.mb.un.varCfgPort.gmv) { in lpfc_sli_config_port()
5129 phba->sli3_options |= LPFC_SLI3_NPIV_ENABLED; in lpfc_sli_config_port()
5130 phba->max_vpi = pmb->u.mb.un.varCfgPort.max_vpi; in lpfc_sli_config_port()
5131 phba->max_vports = (phba->max_vpi > phba->max_vports) ? in lpfc_sli_config_port()
5132 phba->max_vpi : phba->max_vports; in lpfc_sli_config_port()
5135 phba->max_vpi = 0; in lpfc_sli_config_port()
5136 if (pmb->u.mb.un.varCfgPort.gerbm) in lpfc_sli_config_port()
5137 phba->sli3_options |= LPFC_SLI3_HBQ_ENABLED; in lpfc_sli_config_port()
5138 if (pmb->u.mb.un.varCfgPort.gcrp) in lpfc_sli_config_port()
5139 phba->sli3_options |= LPFC_SLI3_CRP_ENABLED; in lpfc_sli_config_port()
5141 phba->hbq_get = phba->mbox->us.s3_pgp.hbq_get; in lpfc_sli_config_port()
5142 phba->port_gp = phba->mbox->us.s3_pgp.port; in lpfc_sli_config_port()
5144 if (phba->sli3_options & LPFC_SLI3_BG_ENABLED) { in lpfc_sli_config_port()
5145 if (pmb->u.mb.un.varCfgPort.gbg == 0) { in lpfc_sli_config_port()
5146 phba->cfg_enable_bg = 0; in lpfc_sli_config_port()
5147 phba->sli3_options &= ~LPFC_SLI3_BG_ENABLED; in lpfc_sli_config_port()
5154 phba->hbq_get = NULL; in lpfc_sli_config_port()
5155 phba->port_gp = phba->mbox->us.s2.port; in lpfc_sli_config_port()
5156 phba->max_vpi = 0; in lpfc_sli_config_port()
5159 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_sli_config_port()
5165 * lpfc_sli_hba_setup - SLI initialization function
5171 * locks. This function issues config_port mailbox command to configure
5173 * calls the config_port_post function to issue init_link mailbox
5184 switch (phba->cfg_sli_mode) { in lpfc_sli_hba_setup()
5186 if (phba->cfg_enable_npiv) { in lpfc_sli_hba_setup()
5190 phba->cfg_sli_mode); in lpfc_sli_hba_setup()
5201 phba->cfg_sli_mode); in lpfc_sli_hba_setup()
5205 phba->fcp_embed_io = 0; /* SLI4 FC support only */ in lpfc_sli_hba_setup()
5209 if (rc && phba->cfg_sli_mode == 3) in lpfc_sli_hba_setup()
5211 "1820 Unable to select SLI-3. " in lpfc_sli_hba_setup()
5221 if (phba->cfg_aer_support == 1 && !(phba->hba_flag & HBA_AER_ENABLED)) { in lpfc_sli_hba_setup()
5222 rc = pci_enable_pcie_error_reporting(phba->pcidev); in lpfc_sli_hba_setup()
5227 spin_lock_irq(&phba->hbalock); in lpfc_sli_hba_setup()
5228 phba->hba_flag |= HBA_AER_ENABLED; in lpfc_sli_hba_setup()
5229 spin_unlock_irq(&phba->hbalock); in lpfc_sli_hba_setup()
5235 phba->cfg_aer_support = 0; in lpfc_sli_hba_setup()
5239 if (phba->sli_rev == 3) { in lpfc_sli_hba_setup()
5240 phba->iocb_cmd_size = SLI3_IOCB_CMD_SIZE; in lpfc_sli_hba_setup()
5241 phba->iocb_rsp_size = SLI3_IOCB_RSP_SIZE; in lpfc_sli_hba_setup()
5243 phba->iocb_cmd_size = SLI2_IOCB_CMD_SIZE; in lpfc_sli_hba_setup()
5244 phba->iocb_rsp_size = SLI2_IOCB_RSP_SIZE; in lpfc_sli_hba_setup()
5245 phba->sli3_options = 0; in lpfc_sli_hba_setup()
5250 phba->sli_rev, phba->max_vpi); in lpfc_sli_hba_setup()
5257 if (phba->sli_rev == LPFC_SLI_REV3) { in lpfc_sli_hba_setup()
5260 * and initialized once only - at driver load. A port in lpfc_sli_hba_setup()
5263 if ((phba->vpi_bmask == NULL) && (phba->vpi_ids == NULL)) { in lpfc_sli_hba_setup()
5264 longs = (phba->max_vpi + BITS_PER_LONG) / BITS_PER_LONG; in lpfc_sli_hba_setup()
5265 phba->vpi_bmask = kcalloc(longs, in lpfc_sli_hba_setup()
5268 if (!phba->vpi_bmask) { in lpfc_sli_hba_setup()
5269 rc = -ENOMEM; in lpfc_sli_hba_setup()
5273 phba->vpi_ids = kcalloc(phba->max_vpi + 1, in lpfc_sli_hba_setup()
5276 if (!phba->vpi_ids) { in lpfc_sli_hba_setup()
5277 kfree(phba->vpi_bmask); in lpfc_sli_hba_setup()
5278 rc = -ENOMEM; in lpfc_sli_hba_setup()
5281 for (i = 0; i < phba->max_vpi; i++) in lpfc_sli_hba_setup()
5282 phba->vpi_ids[i] = i; in lpfc_sli_hba_setup()
5287 if (phba->sli3_options & LPFC_SLI3_HBQ_ENABLED) { in lpfc_sli_hba_setup()
5292 spin_lock_irq(&phba->hbalock); in lpfc_sli_hba_setup()
5293 phba->sli.sli_flag |= LPFC_PROCESS_LA; in lpfc_sli_hba_setup()
5294 spin_unlock_irq(&phba->hbalock); in lpfc_sli_hba_setup()
5303 phba->link_state = LPFC_HBA_ERROR; in lpfc_sli_hba_setup()
5310 * lpfc_sli4_read_fcoe_params - Read fcoe params from conf region
5313 * This function issue a dump mailbox command to read config region
5327 phba->valid_vlan = 0; in lpfc_sli4_read_fcoe_params()
5328 phba->fc_map[0] = LPFC_FCOE_FCF_MAP0; in lpfc_sli4_read_fcoe_params()
5329 phba->fc_map[1] = LPFC_FCOE_FCF_MAP1; in lpfc_sli4_read_fcoe_params()
5330 phba->fc_map[2] = LPFC_FCOE_FCF_MAP2; in lpfc_sli4_read_fcoe_params()
5332 mboxq = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_read_fcoe_params()
5334 return -ENOMEM; in lpfc_sli4_read_fcoe_params()
5336 mqe = &mboxq->u.mqe; in lpfc_sli4_read_fcoe_params()
5338 rc = -ENOMEM; in lpfc_sli4_read_fcoe_params()
5342 mp = (struct lpfc_dmabuf *)mboxq->ctx_buf; in lpfc_sli4_read_fcoe_params()
5346 "(%d):2571 Mailbox cmd x%x Status x%x " in lpfc_sli4_read_fcoe_params()
5350 mboxq->vport ? mboxq->vport->vpi : 0, in lpfc_sli4_read_fcoe_params()
5353 mqe->un.mb_words[0], mqe->un.mb_words[1], in lpfc_sli4_read_fcoe_params()
5354 mqe->un.mb_words[2], mqe->un.mb_words[3], in lpfc_sli4_read_fcoe_params()
5355 mqe->un.mb_words[4], mqe->un.mb_words[5], in lpfc_sli4_read_fcoe_params()
5356 mqe->un.mb_words[6], mqe->un.mb_words[7], in lpfc_sli4_read_fcoe_params()
5357 mqe->un.mb_words[8], mqe->un.mb_words[9], in lpfc_sli4_read_fcoe_params()
5358 mqe->un.mb_words[10], mqe->un.mb_words[11], in lpfc_sli4_read_fcoe_params()
5359 mqe->un.mb_words[12], mqe->un.mb_words[13], in lpfc_sli4_read_fcoe_params()
5360 mqe->un.mb_words[14], mqe->un.mb_words[15], in lpfc_sli4_read_fcoe_params()
5361 mqe->un.mb_words[16], mqe->un.mb_words[50], in lpfc_sli4_read_fcoe_params()
5362 mboxq->mcqe.word0, in lpfc_sli4_read_fcoe_params()
5363 mboxq->mcqe.mcqe_tag0, mboxq->mcqe.mcqe_tag1, in lpfc_sli4_read_fcoe_params()
5364 mboxq->mcqe.trailer); in lpfc_sli4_read_fcoe_params()
5367 lpfc_mbuf_free(phba, mp->virt, mp->phys); in lpfc_sli4_read_fcoe_params()
5369 rc = -EIO; in lpfc_sli4_read_fcoe_params()
5372 data_length = mqe->un.mb_words[5]; in lpfc_sli4_read_fcoe_params()
5374 lpfc_mbuf_free(phba, mp->virt, mp->phys); in lpfc_sli4_read_fcoe_params()
5376 rc = -EIO; in lpfc_sli4_read_fcoe_params()
5380 lpfc_parse_fcoe_conf(phba, mp->virt, data_length); in lpfc_sli4_read_fcoe_params()
5381 lpfc_mbuf_free(phba, mp->virt, mp->phys); in lpfc_sli4_read_fcoe_params()
5386 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_read_fcoe_params()
5391 * lpfc_sli4_read_rev - Issue READ_REV and collect vpd data
5398 * This routine executes a READ_REV SLI4 mailbox command. In
5402 * 0 - successful
5403 * -ENOMEM - could not allocated memory.
5416 return -ENOMEM; in lpfc_sli4_read_rev()
5420 * mailbox command. in lpfc_sli4_read_rev()
5423 dmabuf->virt = dma_alloc_coherent(&phba->pcidev->dev, dma_size, in lpfc_sli4_read_rev()
5424 &dmabuf->phys, GFP_KERNEL); in lpfc_sli4_read_rev()
5425 if (!dmabuf->virt) { in lpfc_sli4_read_rev()
5427 return -ENOMEM; in lpfc_sli4_read_rev()
5436 mqe = &mboxq->u.mqe; in lpfc_sli4_read_rev()
5437 mqe->un.read_rev.vpd_paddr_high = putPaddrHigh(dmabuf->phys); in lpfc_sli4_read_rev()
5438 mqe->un.read_rev.vpd_paddr_low = putPaddrLow(dmabuf->phys); in lpfc_sli4_read_rev()
5439 mqe->un.read_rev.word1 &= 0x0000FFFF; in lpfc_sli4_read_rev()
5440 bf_set(lpfc_mbx_rd_rev_vpd, &mqe->un.read_rev, 1); in lpfc_sli4_read_rev()
5441 bf_set(lpfc_mbx_rd_rev_avail_len, &mqe->un.read_rev, dma_size); in lpfc_sli4_read_rev()
5445 dma_free_coherent(&phba->pcidev->dev, dma_size, in lpfc_sli4_read_rev()
5446 dmabuf->virt, dmabuf->phys); in lpfc_sli4_read_rev()
5448 return -EIO; in lpfc_sli4_read_rev()
5456 if (mqe->un.read_rev.avail_vpd_len < *vpd_size) in lpfc_sli4_read_rev()
5457 *vpd_size = mqe->un.read_rev.avail_vpd_len; in lpfc_sli4_read_rev()
5459 memcpy(vpd, dmabuf->virt, *vpd_size); in lpfc_sli4_read_rev()
5461 dma_free_coherent(&phba->pcidev->dev, dma_size, in lpfc_sli4_read_rev()
5462 dmabuf->virt, dmabuf->phys); in lpfc_sli4_read_rev()
5468 * lpfc_sli4_get_ctl_attr - Retrieve SLI4 device controller attributes
5475 * 0 - successful
5476 * otherwise - failed to retrieve controller attributes
5490 mboxq = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_get_ctl_attr()
5492 return -ENOMEM; in lpfc_sli4_get_ctl_attr()
5505 rc = -ENOMEM; in lpfc_sli4_get_ctl_attr()
5509 virtaddr = mboxq->sge_array->addr[0]; in lpfc_sli4_get_ctl_attr()
5511 shdr = &mbx_cntl_attr->cfg_shdr; in lpfc_sli4_get_ctl_attr()
5512 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_sli4_get_ctl_attr()
5513 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_sli4_get_ctl_attr()
5516 "3085 Mailbox x%x (x%x/x%x) failed, " in lpfc_sli4_get_ctl_attr()
5518 bf_get(lpfc_mqe_command, &mboxq->u.mqe), in lpfc_sli4_get_ctl_attr()
5522 rc = -ENXIO; in lpfc_sli4_get_ctl_attr()
5526 cntl_attr = &mbx_cntl_attr->cntl_attr; in lpfc_sli4_get_ctl_attr()
5527 phba->sli4_hba.lnk_info.lnk_dv = LPFC_LNK_DAT_VAL; in lpfc_sli4_get_ctl_attr()
5528 phba->sli4_hba.lnk_info.lnk_tp = in lpfc_sli4_get_ctl_attr()
5530 phba->sli4_hba.lnk_info.lnk_no = in lpfc_sli4_get_ctl_attr()
5533 memset(phba->BIOSVersion, 0, sizeof(phba->BIOSVersion)); in lpfc_sli4_get_ctl_attr()
5534 strlcat(phba->BIOSVersion, (char *)cntl_attr->bios_ver_str, in lpfc_sli4_get_ctl_attr()
5535 sizeof(phba->BIOSVersion)); in lpfc_sli4_get_ctl_attr()
5539 phba->sli4_hba.lnk_info.lnk_tp, in lpfc_sli4_get_ctl_attr()
5540 phba->sli4_hba.lnk_info.lnk_no, in lpfc_sli4_get_ctl_attr()
5541 phba->BIOSVersion); in lpfc_sli4_get_ctl_attr()
5543 if (bf_get(lpfc_mqe_command, &mboxq->u.mqe) == MBX_SLI4_CONFIG) in lpfc_sli4_get_ctl_attr()
5546 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_get_ctl_attr()
5551 * lpfc_sli4_retrieve_pport_name - Retrieve SLI4 device physical port name
5558 * 0 - successful
5559 * otherwise - failed to retrieve physical port name
5572 phba->sli4_hba.lnk_info.lnk_dv = LPFC_LNK_DAT_INVAL; in lpfc_sli4_retrieve_pport_name()
5573 phba->sli4_hba.pport_name_sta = LPFC_SLI4_PPNAME_NON; in lpfc_sli4_retrieve_pport_name()
5575 mboxq = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_retrieve_pport_name()
5577 return -ENOMEM; in lpfc_sli4_retrieve_pport_name()
5579 phba->sli4_hba.lnk_info.lnk_dv = LPFC_LNK_DAT_INVAL; in lpfc_sli4_retrieve_pport_name()
5581 if (phba->sli4_hba.lnk_info.lnk_dv == LPFC_LNK_DAT_VAL) in lpfc_sli4_retrieve_pport_name()
5592 sizeof(struct lpfc_mbx_get_port_name) - in lpfc_sli4_retrieve_pport_name()
5595 get_port_name = &mboxq->u.mqe.un.get_port_name; in lpfc_sli4_retrieve_pport_name()
5596 shdr = (union lpfc_sli4_cfg_shdr *)&get_port_name->header.cfg_shdr; in lpfc_sli4_retrieve_pport_name()
5597 bf_set(lpfc_mbox_hdr_version, &shdr->request, LPFC_OPCODE_VERSION_1); in lpfc_sli4_retrieve_pport_name()
5598 bf_set(lpfc_mbx_get_port_name_lnk_type, &get_port_name->u.request, in lpfc_sli4_retrieve_pport_name()
5599 phba->sli4_hba.lnk_info.lnk_tp); in lpfc_sli4_retrieve_pport_name()
5601 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_sli4_retrieve_pport_name()
5602 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_sli4_retrieve_pport_name()
5605 "3087 Mailbox x%x (x%x/x%x) failed: " in lpfc_sli4_retrieve_pport_name()
5607 bf_get(lpfc_mqe_command, &mboxq->u.mqe), in lpfc_sli4_retrieve_pport_name()
5611 rc = -ENXIO; in lpfc_sli4_retrieve_pport_name()
5614 switch (phba->sli4_hba.lnk_info.lnk_no) { in lpfc_sli4_retrieve_pport_name()
5617 &get_port_name->u.response); in lpfc_sli4_retrieve_pport_name()
5618 phba->sli4_hba.pport_name_sta = LPFC_SLI4_PPNAME_GET; in lpfc_sli4_retrieve_pport_name()
5622 &get_port_name->u.response); in lpfc_sli4_retrieve_pport_name()
5623 phba->sli4_hba.pport_name_sta = LPFC_SLI4_PPNAME_GET; in lpfc_sli4_retrieve_pport_name()
5627 &get_port_name->u.response); in lpfc_sli4_retrieve_pport_name()
5628 phba->sli4_hba.pport_name_sta = LPFC_SLI4_PPNAME_GET; in lpfc_sli4_retrieve_pport_name()
5632 &get_port_name->u.response); in lpfc_sli4_retrieve_pport_name()
5633 phba->sli4_hba.pport_name_sta = LPFC_SLI4_PPNAME_GET; in lpfc_sli4_retrieve_pport_name()
5639 if (phba->sli4_hba.pport_name_sta == LPFC_SLI4_PPNAME_GET) { in lpfc_sli4_retrieve_pport_name()
5640 phba->Port[0] = cport_name; in lpfc_sli4_retrieve_pport_name()
5641 phba->Port[1] = '\0'; in lpfc_sli4_retrieve_pport_name()
5643 "3091 SLI get port name: %s\n", phba->Port); in lpfc_sli4_retrieve_pport_name()
5647 if (bf_get(lpfc_mqe_command, &mboxq->u.mqe) == MBX_SLI4_CONFIG) in lpfc_sli4_retrieve_pport_name()
5650 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_retrieve_pport_name()
5655 * lpfc_sli4_arm_cqeq_intr - Arm sli-4 device completion and event queues
5665 struct lpfc_sli4_hba *sli4_hba = &phba->sli4_hba; in lpfc_sli4_arm_cqeq_intr()
5669 sli4_hba->sli4_write_cq_db(phba, sli4_hba->mbx_cq, 0, LPFC_QUEUE_REARM); in lpfc_sli4_arm_cqeq_intr()
5670 sli4_hba->sli4_write_cq_db(phba, sli4_hba->els_cq, 0, LPFC_QUEUE_REARM); in lpfc_sli4_arm_cqeq_intr()
5671 if (sli4_hba->nvmels_cq) in lpfc_sli4_arm_cqeq_intr()
5672 sli4_hba->sli4_write_cq_db(phba, sli4_hba->nvmels_cq, 0, in lpfc_sli4_arm_cqeq_intr()
5675 if (sli4_hba->hdwq) { in lpfc_sli4_arm_cqeq_intr()
5677 for (qidx = 0; qidx < phba->cfg_hdw_queue; qidx++) { in lpfc_sli4_arm_cqeq_intr()
5678 qp = &sli4_hba->hdwq[qidx]; in lpfc_sli4_arm_cqeq_intr()
5680 sli4_hba->sli4_write_cq_db(phba, qp->io_cq, 0, in lpfc_sli4_arm_cqeq_intr()
5685 for (qidx = 0; qidx < phba->cfg_irq_chann; qidx++) { in lpfc_sli4_arm_cqeq_intr()
5686 eq = sli4_hba->hba_eq_hdl[qidx].eq; in lpfc_sli4_arm_cqeq_intr()
5688 sli4_hba->sli4_write_eq_db(phba, eq, in lpfc_sli4_arm_cqeq_intr()
5693 if (phba->nvmet_support) { in lpfc_sli4_arm_cqeq_intr()
5694 for (qidx = 0; qidx < phba->cfg_nvmet_mrq; qidx++) { in lpfc_sli4_arm_cqeq_intr()
5695 sli4_hba->sli4_write_cq_db(phba, in lpfc_sli4_arm_cqeq_intr()
5696 sli4_hba->nvmet_cqset[qidx], 0, in lpfc_sli4_arm_cqeq_intr()
5703 * lpfc_sli4_get_avail_extnt_rsrc - Get available resource extent count.
5724 mbox = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_get_avail_extnt_rsrc()
5726 return -ENOMEM; in lpfc_sli4_get_avail_extnt_rsrc()
5729 length = (sizeof(struct lpfc_mbx_get_rsrc_extent_info) - in lpfc_sli4_get_avail_extnt_rsrc()
5735 /* Send an extents count of 0 - the GET doesn't use it. */ in lpfc_sli4_get_avail_extnt_rsrc()
5739 rc = -EIO; in lpfc_sli4_get_avail_extnt_rsrc()
5743 if (!phba->sli4_hba.intr_enable) in lpfc_sli4_get_avail_extnt_rsrc()
5750 rc = -EIO; in lpfc_sli4_get_avail_extnt_rsrc()
5754 rsrc_info = &mbox->u.mqe.un.rsrc_extent_info; in lpfc_sli4_get_avail_extnt_rsrc()
5756 &rsrc_info->header.cfg_shdr.response)) { in lpfc_sli4_get_avail_extnt_rsrc()
5761 &rsrc_info->header.cfg_shdr.response), in lpfc_sli4_get_avail_extnt_rsrc()
5763 &rsrc_info->header.cfg_shdr.response)); in lpfc_sli4_get_avail_extnt_rsrc()
5764 rc = -EIO; in lpfc_sli4_get_avail_extnt_rsrc()
5769 &rsrc_info->u.rsp); in lpfc_sli4_get_avail_extnt_rsrc()
5771 &rsrc_info->u.rsp); in lpfc_sli4_get_avail_extnt_rsrc()
5774 "3162 Retrieved extents type-%d from port: count:%d, " in lpfc_sli4_get_avail_extnt_rsrc()
5778 mempool_free(mbox, phba->mbox_mem_pool); in lpfc_sli4_get_avail_extnt_rsrc()
5783 * lpfc_sli4_chk_avail_extnt_rsrc - Check for available SLI4 resource extents.
5793 * -Error: error indicates problem.
5812 return -EIO; in lpfc_sli4_chk_avail_extnt_rsrc()
5816 rsrc_blk_list = &phba->sli4_hba.lpfc_rpi_blk_list; in lpfc_sli4_chk_avail_extnt_rsrc()
5819 rsrc_blk_list = &phba->lpfc_vpi_blk_list; in lpfc_sli4_chk_avail_extnt_rsrc()
5822 rsrc_blk_list = &phba->sli4_hba.lpfc_xri_blk_list; in lpfc_sli4_chk_avail_extnt_rsrc()
5825 rsrc_blk_list = &phba->sli4_hba.lpfc_vfi_blk_list; in lpfc_sli4_chk_avail_extnt_rsrc()
5833 if (rsrc_entry->rsrc_size != rsrc_ext_size) in lpfc_sli4_chk_avail_extnt_rsrc()
5844 * lpfc_sli4_cfg_post_extnts -
5849 * @mbox: pointer to the caller's allocated mailbox structure.
5857 * -Error: Error value describes the condition found.
5873 * Calculate the size of an embedded mailbox. The uint32_t in lpfc_sli4_cfg_post_extnts()
5874 * accounts for extents-specific word. in lpfc_sli4_cfg_post_extnts()
5876 emb_len = sizeof(MAILBOX_t) - sizeof(struct mbox_header) - in lpfc_sli4_cfg_post_extnts()
5881 * mailbox. If not true, reconfigure to a non-embedded mailbox. in lpfc_sli4_cfg_post_extnts()
5899 return -ENOMEM; in lpfc_sli4_cfg_post_extnts()
5903 return -EIO; in lpfc_sli4_cfg_post_extnts()
5905 if (!phba->sli4_hba.intr_enable) in lpfc_sli4_cfg_post_extnts()
5913 rc = -EIO; in lpfc_sli4_cfg_post_extnts()
5918 * lpfc_sli4_alloc_extent - Allocate an SLI4 resource extent.
5948 return -EIO; in lpfc_sli4_alloc_extent()
5956 return -ENOMEM; in lpfc_sli4_alloc_extent()
5960 "2903 Post resource extents type-0x%x: " in lpfc_sli4_alloc_extent()
5963 mbox = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_alloc_extent()
5965 return -ENOMEM; in lpfc_sli4_alloc_extent()
5969 rc = -EIO; in lpfc_sli4_alloc_extent()
5980 rsrc_ext = &mbox->u.mqe.un.alloc_rsrc_extents; in lpfc_sli4_alloc_extent()
5981 id_array = &rsrc_ext->u.rsp.id[0]; in lpfc_sli4_alloc_extent()
5982 rsrc_cnt = bf_get(lpfc_mbx_rsrc_cnt, &rsrc_ext->u.rsp); in lpfc_sli4_alloc_extent()
5984 virtaddr = mbox->sge_array->addr[0]; in lpfc_sli4_alloc_extent()
5987 id_array = &n_rsrc->id; in lpfc_sli4_alloc_extent()
5990 longs = ((rsrc_cnt * rsrc_size) + BITS_PER_LONG - 1) / BITS_PER_LONG; in lpfc_sli4_alloc_extent()
6000 phba->sli4_hba.rpi_bmask = kcalloc(longs, in lpfc_sli4_alloc_extent()
6003 if (unlikely(!phba->sli4_hba.rpi_bmask)) { in lpfc_sli4_alloc_extent()
6004 rc = -ENOMEM; in lpfc_sli4_alloc_extent()
6007 phba->sli4_hba.rpi_ids = kcalloc(rsrc_id_cnt, in lpfc_sli4_alloc_extent()
6010 if (unlikely(!phba->sli4_hba.rpi_ids)) { in lpfc_sli4_alloc_extent()
6011 kfree(phba->sli4_hba.rpi_bmask); in lpfc_sli4_alloc_extent()
6012 rc = -ENOMEM; in lpfc_sli4_alloc_extent()
6021 phba->sli4_hba.next_rpi = rsrc_id_cnt; in lpfc_sli4_alloc_extent()
6024 bmask = phba->sli4_hba.rpi_bmask; in lpfc_sli4_alloc_extent()
6025 ids = phba->sli4_hba.rpi_ids; in lpfc_sli4_alloc_extent()
6026 ext_blk_list = &phba->sli4_hba.lpfc_rpi_blk_list; in lpfc_sli4_alloc_extent()
6029 phba->vpi_bmask = kcalloc(longs, sizeof(unsigned long), in lpfc_sli4_alloc_extent()
6031 if (unlikely(!phba->vpi_bmask)) { in lpfc_sli4_alloc_extent()
6032 rc = -ENOMEM; in lpfc_sli4_alloc_extent()
6035 phba->vpi_ids = kcalloc(rsrc_id_cnt, sizeof(uint16_t), in lpfc_sli4_alloc_extent()
6037 if (unlikely(!phba->vpi_ids)) { in lpfc_sli4_alloc_extent()
6038 kfree(phba->vpi_bmask); in lpfc_sli4_alloc_extent()
6039 rc = -ENOMEM; in lpfc_sli4_alloc_extent()
6044 bmask = phba->vpi_bmask; in lpfc_sli4_alloc_extent()
6045 ids = phba->vpi_ids; in lpfc_sli4_alloc_extent()
6046 ext_blk_list = &phba->lpfc_vpi_blk_list; in lpfc_sli4_alloc_extent()
6049 phba->sli4_hba.xri_bmask = kcalloc(longs, in lpfc_sli4_alloc_extent()
6052 if (unlikely(!phba->sli4_hba.xri_bmask)) { in lpfc_sli4_alloc_extent()
6053 rc = -ENOMEM; in lpfc_sli4_alloc_extent()
6056 phba->sli4_hba.max_cfg_param.xri_used = 0; in lpfc_sli4_alloc_extent()
6057 phba->sli4_hba.xri_ids = kcalloc(rsrc_id_cnt, in lpfc_sli4_alloc_extent()
6060 if (unlikely(!phba->sli4_hba.xri_ids)) { in lpfc_sli4_alloc_extent()
6061 kfree(phba->sli4_hba.xri_bmask); in lpfc_sli4_alloc_extent()
6062 rc = -ENOMEM; in lpfc_sli4_alloc_extent()
6067 bmask = phba->sli4_hba.xri_bmask; in lpfc_sli4_alloc_extent()
6068 ids = phba->sli4_hba.xri_ids; in lpfc_sli4_alloc_extent()
6069 ext_blk_list = &phba->sli4_hba.lpfc_xri_blk_list; in lpfc_sli4_alloc_extent()
6072 phba->sli4_hba.vfi_bmask = kcalloc(longs, in lpfc_sli4_alloc_extent()
6075 if (unlikely(!phba->sli4_hba.vfi_bmask)) { in lpfc_sli4_alloc_extent()
6076 rc = -ENOMEM; in lpfc_sli4_alloc_extent()
6079 phba->sli4_hba.vfi_ids = kcalloc(rsrc_id_cnt, in lpfc_sli4_alloc_extent()
6082 if (unlikely(!phba->sli4_hba.vfi_ids)) { in lpfc_sli4_alloc_extent()
6083 kfree(phba->sli4_hba.vfi_bmask); in lpfc_sli4_alloc_extent()
6084 rc = -ENOMEM; in lpfc_sli4_alloc_extent()
6089 bmask = phba->sli4_hba.vfi_bmask; in lpfc_sli4_alloc_extent()
6090 ids = phba->sli4_hba.vfi_ids; in lpfc_sli4_alloc_extent()
6091 ext_blk_list = &phba->sli4_hba.lpfc_vfi_blk_list; in lpfc_sli4_alloc_extent()
6118 rc = -ENOMEM; in lpfc_sli4_alloc_extent()
6123 rsrc_blks->rsrc_start = rsrc_id; in lpfc_sli4_alloc_extent()
6124 rsrc_blks->rsrc_size = rsrc_size; in lpfc_sli4_alloc_extent()
6125 list_add_tail(&rsrc_blks->list, ext_blk_list); in lpfc_sli4_alloc_extent()
6128 phba->sli4_hba.io_xri_start = rsrc_start + in lpfc_sli4_alloc_extent()
6149 * lpfc_sli4_dealloc_extent - Deallocate an SLI4 resource extent.
6166 mbox = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_dealloc_extent()
6168 return -ENOMEM; in lpfc_sli4_dealloc_extent()
6171 * This function sends an embedded mailbox because it only sends the in lpfc_sli4_dealloc_extent()
6175 length = (sizeof(struct lpfc_mbx_dealloc_rsrc_extents) - in lpfc_sli4_dealloc_extent()
6181 /* Send an extents count of 0 - the dealloc doesn't use it. */ in lpfc_sli4_dealloc_extent()
6185 rc = -EIO; in lpfc_sli4_dealloc_extent()
6188 if (!phba->sli4_hba.intr_enable) in lpfc_sli4_dealloc_extent()
6195 rc = -EIO; in lpfc_sli4_dealloc_extent()
6199 dealloc_rsrc = &mbox->u.mqe.un.dealloc_rsrc_extents; in lpfc_sli4_dealloc_extent()
6201 &dealloc_rsrc->header.cfg_shdr.response)) { in lpfc_sli4_dealloc_extent()
6204 "for type %d - Status 0x%x Add'l Status 0x%x. " in lpfc_sli4_dealloc_extent()
6208 &dealloc_rsrc->header.cfg_shdr.response), in lpfc_sli4_dealloc_extent()
6210 &dealloc_rsrc->header.cfg_shdr.response)); in lpfc_sli4_dealloc_extent()
6211 rc = -EIO; in lpfc_sli4_dealloc_extent()
6218 kfree(phba->vpi_bmask); in lpfc_sli4_dealloc_extent()
6219 kfree(phba->vpi_ids); in lpfc_sli4_dealloc_extent()
6220 bf_set(lpfc_vpi_rsrc_rdy, &phba->sli4_hba.sli4_flags, 0); in lpfc_sli4_dealloc_extent()
6222 &phba->lpfc_vpi_blk_list, list) { in lpfc_sli4_dealloc_extent()
6223 list_del_init(&rsrc_blk->list); in lpfc_sli4_dealloc_extent()
6226 phba->sli4_hba.max_cfg_param.vpi_used = 0; in lpfc_sli4_dealloc_extent()
6229 kfree(phba->sli4_hba.xri_bmask); in lpfc_sli4_dealloc_extent()
6230 kfree(phba->sli4_hba.xri_ids); in lpfc_sli4_dealloc_extent()
6232 &phba->sli4_hba.lpfc_xri_blk_list, list) { in lpfc_sli4_dealloc_extent()
6233 list_del_init(&rsrc_blk->list); in lpfc_sli4_dealloc_extent()
6238 kfree(phba->sli4_hba.vfi_bmask); in lpfc_sli4_dealloc_extent()
6239 kfree(phba->sli4_hba.vfi_ids); in lpfc_sli4_dealloc_extent()
6240 bf_set(lpfc_vfi_rsrc_rdy, &phba->sli4_hba.sli4_flags, 0); in lpfc_sli4_dealloc_extent()
6242 &phba->sli4_hba.lpfc_vfi_blk_list, list) { in lpfc_sli4_dealloc_extent()
6243 list_del_init(&rsrc_blk->list); in lpfc_sli4_dealloc_extent()
6250 &phba->sli4_hba.lpfc_rpi_blk_list, list) { in lpfc_sli4_dealloc_extent()
6251 list_del_init(&rsrc_blk->list); in lpfc_sli4_dealloc_extent()
6259 bf_set(lpfc_idx_rsrc_rdy, &phba->sli4_hba.sli4_flags, 0); in lpfc_sli4_dealloc_extent()
6262 mempool_free(mbox, phba->mbox_mem_pool); in lpfc_sli4_dealloc_extent()
6272 len = sizeof(struct lpfc_mbx_set_feature) - in lpfc_set_features()
6281 &mbox->u.mqe.un.set_feature, 1); in lpfc_set_features()
6282 mbox->u.mqe.un.set_feature.feature = LPFC_SET_UE_RECOVERY; in lpfc_set_features()
6283 mbox->u.mqe.un.set_feature.param_len = 8; in lpfc_set_features()
6287 &mbox->u.mqe.un.set_feature, 1); in lpfc_set_features()
6289 &mbox->u.mqe.un.set_feature, 1); in lpfc_set_features()
6290 mbox->u.mqe.un.set_feature.feature = LPFC_SET_MDS_DIAGS; in lpfc_set_features()
6291 mbox->u.mqe.un.set_feature.param_len = 8; in lpfc_set_features()
6295 &mbox->u.mqe.un.set_feature, LPFC_ENABLE_DUAL_DUMP); in lpfc_set_features()
6297 &mbox->u.mqe.un.set_feature, 0); in lpfc_set_features()
6298 mbox->u.mqe.un.set_feature.feature = LPFC_SET_DUAL_DUMP; in lpfc_set_features()
6299 mbox->u.mqe.un.set_feature.param_len = 4; in lpfc_set_features()
6316 struct lpfc_ras_fwlog *ras_fwlog = &phba->ras_fwlog; in lpfc_ras_stop_fwlog()
6318 spin_lock_irq(&phba->hbalock); in lpfc_ras_stop_fwlog()
6319 ras_fwlog->state = INACTIVE; in lpfc_ras_stop_fwlog()
6320 spin_unlock_irq(&phba->hbalock); in lpfc_ras_stop_fwlog()
6324 phba->sli4_hba.conf_regs_memmap_p + LPFC_CTL_PDEV_CTL_OFFSET); in lpfc_ras_stop_fwlog()
6331 * lpfc_sli4_ras_dma_free - Free memory allocated for FW logging.
6340 struct lpfc_ras_fwlog *ras_fwlog = &phba->ras_fwlog; in lpfc_sli4_ras_dma_free()
6343 if (!list_empty(&ras_fwlog->fwlog_buff_list)) { in lpfc_sli4_ras_dma_free()
6345 &ras_fwlog->fwlog_buff_list, in lpfc_sli4_ras_dma_free()
6347 list_del(&dmabuf->list); in lpfc_sli4_ras_dma_free()
6348 dma_free_coherent(&phba->pcidev->dev, in lpfc_sli4_ras_dma_free()
6350 dmabuf->virt, dmabuf->phys); in lpfc_sli4_ras_dma_free()
6355 if (ras_fwlog->lwpd.virt) { in lpfc_sli4_ras_dma_free()
6356 dma_free_coherent(&phba->pcidev->dev, in lpfc_sli4_ras_dma_free()
6358 ras_fwlog->lwpd.virt, in lpfc_sli4_ras_dma_free()
6359 ras_fwlog->lwpd.phys); in lpfc_sli4_ras_dma_free()
6360 ras_fwlog->lwpd.virt = NULL; in lpfc_sli4_ras_dma_free()
6363 spin_lock_irq(&phba->hbalock); in lpfc_sli4_ras_dma_free()
6364 ras_fwlog->state = INACTIVE; in lpfc_sli4_ras_dma_free()
6365 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_ras_dma_free()
6383 struct lpfc_ras_fwlog *ras_fwlog = &phba->ras_fwlog; in lpfc_sli4_ras_dma_alloc()
6388 INIT_LIST_HEAD(&ras_fwlog->fwlog_buff_list); in lpfc_sli4_ras_dma_alloc()
6391 ras_fwlog->lwpd.virt = dma_alloc_coherent(&phba->pcidev->dev, in lpfc_sli4_ras_dma_alloc()
6393 &ras_fwlog->lwpd.phys, in lpfc_sli4_ras_dma_alloc()
6395 if (!ras_fwlog->lwpd.virt) { in lpfc_sli4_ras_dma_alloc()
6399 return -ENOMEM; in lpfc_sli4_ras_dma_alloc()
6402 ras_fwlog->fw_buffcount = fwlog_buff_count; in lpfc_sli4_ras_dma_alloc()
6403 for (i = 0; i < ras_fwlog->fw_buffcount; i++) { in lpfc_sli4_ras_dma_alloc()
6407 rc = -ENOMEM; in lpfc_sli4_ras_dma_alloc()
6413 dmabuf->virt = dma_alloc_coherent(&phba->pcidev->dev, in lpfc_sli4_ras_dma_alloc()
6415 &dmabuf->phys, GFP_KERNEL); in lpfc_sli4_ras_dma_alloc()
6416 if (!dmabuf->virt) { in lpfc_sli4_ras_dma_alloc()
6418 rc = -ENOMEM; in lpfc_sli4_ras_dma_alloc()
6423 dmabuf->buffer_tag = i; in lpfc_sli4_ras_dma_alloc()
6424 list_add_tail(&dmabuf->list, &ras_fwlog->fwlog_buff_list); in lpfc_sli4_ras_dma_alloc()
6437 * @pmb: pointer to the driver internal queue element for mailbox command.
6447 struct lpfc_ras_fwlog *ras_fwlog = &phba->ras_fwlog; in lpfc_sli4_ras_mbox_cmpl()
6449 mb = &pmb->u.mb; in lpfc_sli4_ras_mbox_cmpl()
6452 &pmb->u.mqe.un.ras_fwlog.header.cfg_shdr; in lpfc_sli4_ras_mbox_cmpl()
6453 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_sli4_ras_mbox_cmpl()
6454 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_sli4_ras_mbox_cmpl()
6456 if (mb->mbxStatus != MBX_SUCCESS || shdr_status) { in lpfc_sli4_ras_mbox_cmpl()
6458 "6188 FW LOG mailbox " in lpfc_sli4_ras_mbox_cmpl()
6461 shdr_status, shdr_add_status, mb->mbxStatus); in lpfc_sli4_ras_mbox_cmpl()
6463 ras_fwlog->ras_hwsupport = false; in lpfc_sli4_ras_mbox_cmpl()
6467 spin_lock_irq(&phba->hbalock); in lpfc_sli4_ras_mbox_cmpl()
6468 ras_fwlog->state = ACTIVE; in lpfc_sli4_ras_mbox_cmpl()
6469 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_ras_mbox_cmpl()
6470 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_sli4_ras_mbox_cmpl()
6477 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_sli4_ras_mbox_cmpl()
6486 * Initialize memory and post mailbox command to enable FW logging in host
6494 struct lpfc_ras_fwlog *ras_fwlog = &phba->ras_fwlog; in lpfc_sli4_ras_fwlog_init()
6501 spin_lock_irq(&phba->hbalock); in lpfc_sli4_ras_fwlog_init()
6502 ras_fwlog->state = INACTIVE; in lpfc_sli4_ras_fwlog_init()
6503 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_ras_fwlog_init()
6506 phba->cfg_ras_fwlog_buffsize); in lpfc_sli4_ras_fwlog_init()
6510 * If re-enabling FW logging support use earlier allocated in lpfc_sli4_ras_fwlog_init()
6513 if (!ras_fwlog->lwpd.virt) { in lpfc_sli4_ras_fwlog_init()
6522 /* Setup Mailbox command */ in lpfc_sli4_ras_fwlog_init()
6523 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_ras_fwlog_init()
6527 rc = -ENOMEM; in lpfc_sli4_ras_fwlog_init()
6531 ras_fwlog->fw_loglevel = fwlog_level; in lpfc_sli4_ras_fwlog_init()
6532 len = (sizeof(struct lpfc_mbx_set_ras_fwlog) - in lpfc_sli4_ras_fwlog_init()
6539 mbx_fwlog = (struct lpfc_mbx_set_ras_fwlog *)&mbox->u.mqe.un.ras_fwlog; in lpfc_sli4_ras_fwlog_init()
6540 bf_set(lpfc_fwlog_enable, &mbx_fwlog->u.request, in lpfc_sli4_ras_fwlog_init()
6542 bf_set(lpfc_fwlog_loglvl, &mbx_fwlog->u.request, in lpfc_sli4_ras_fwlog_init()
6543 ras_fwlog->fw_loglevel); in lpfc_sli4_ras_fwlog_init()
6544 bf_set(lpfc_fwlog_buffcnt, &mbx_fwlog->u.request, in lpfc_sli4_ras_fwlog_init()
6545 ras_fwlog->fw_buffcount); in lpfc_sli4_ras_fwlog_init()
6546 bf_set(lpfc_fwlog_buffsz, &mbx_fwlog->u.request, in lpfc_sli4_ras_fwlog_init()
6550 list_for_each_entry(dmabuf, &ras_fwlog->fwlog_buff_list, list) { in lpfc_sli4_ras_fwlog_init()
6551 memset(dmabuf->virt, 0, LPFC_RAS_MAX_ENTRY_SIZE); in lpfc_sli4_ras_fwlog_init()
6553 mbx_fwlog->u.request.buff_fwlog[dmabuf->buffer_tag].addr_lo = in lpfc_sli4_ras_fwlog_init()
6554 putPaddrLow(dmabuf->phys); in lpfc_sli4_ras_fwlog_init()
6556 mbx_fwlog->u.request.buff_fwlog[dmabuf->buffer_tag].addr_hi = in lpfc_sli4_ras_fwlog_init()
6557 putPaddrHigh(dmabuf->phys); in lpfc_sli4_ras_fwlog_init()
6561 mbx_fwlog->u.request.lwpd.addr_lo = putPaddrLow(ras_fwlog->lwpd.phys); in lpfc_sli4_ras_fwlog_init()
6562 mbx_fwlog->u.request.lwpd.addr_hi = putPaddrHigh(ras_fwlog->lwpd.phys); in lpfc_sli4_ras_fwlog_init()
6564 spin_lock_irq(&phba->hbalock); in lpfc_sli4_ras_fwlog_init()
6565 ras_fwlog->state = REG_INPROGRESS; in lpfc_sli4_ras_fwlog_init()
6566 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_ras_fwlog_init()
6567 mbox->vport = phba->pport; in lpfc_sli4_ras_fwlog_init()
6568 mbox->mbox_cmpl = lpfc_sli4_ras_mbox_cmpl; in lpfc_sli4_ras_fwlog_init()
6574 "6191 FW-Log Mailbox failed. " in lpfc_sli4_ras_fwlog_init()
6576 bf_get(lpfc_mqe_status, &mbox->u.mqe)); in lpfc_sli4_ras_fwlog_init()
6577 mempool_free(mbox, phba->mbox_mem_pool); in lpfc_sli4_ras_fwlog_init()
6578 rc = -EIO; in lpfc_sli4_ras_fwlog_init()
6590 * lpfc_sli4_ras_setup - Check if RAS supported on the adapter
6602 lpfc_sli4_ras_fwlog_init(phba, phba->cfg_ras_fwlog_level, in lpfc_sli4_ras_setup()
6607 * lpfc_sli4_alloc_resource_identifiers - Allocate all SLI4 resource extents.
6619 if (!phba->sli4_hba.rpi_hdrs_in_use) in lpfc_sli4_alloc_resource_identifiers()
6620 phba->sli4_hba.next_rpi = phba->sli4_hba.max_cfg_param.max_rpi; in lpfc_sli4_alloc_resource_identifiers()
6621 if (phba->sli4_hba.extents_in_use) { in lpfc_sli4_alloc_resource_identifiers()
6627 if (bf_get(lpfc_idx_rsrc_rdy, &phba->sli4_hba.sli4_flags) == in lpfc_sli4_alloc_resource_identifiers()
6630 * Extent-based resources are set - the driver could in lpfc_sli4_alloc_resource_identifiers()
6690 bf_set(lpfc_idx_rsrc_rdy, &phba->sli4_hba.sli4_flags, in lpfc_sli4_alloc_resource_identifiers()
6699 * need any action - just exit. in lpfc_sli4_alloc_resource_identifiers()
6701 if (bf_get(lpfc_idx_rsrc_rdy, &phba->sli4_hba.sli4_flags) == in lpfc_sli4_alloc_resource_identifiers()
6707 count = phba->sli4_hba.max_cfg_param.max_rpi; in lpfc_sli4_alloc_resource_identifiers()
6712 rc = -EINVAL; in lpfc_sli4_alloc_resource_identifiers()
6715 base = phba->sli4_hba.max_cfg_param.rpi_base; in lpfc_sli4_alloc_resource_identifiers()
6716 longs = (count + BITS_PER_LONG - 1) / BITS_PER_LONG; in lpfc_sli4_alloc_resource_identifiers()
6717 phba->sli4_hba.rpi_bmask = kcalloc(longs, in lpfc_sli4_alloc_resource_identifiers()
6720 if (unlikely(!phba->sli4_hba.rpi_bmask)) { in lpfc_sli4_alloc_resource_identifiers()
6721 rc = -ENOMEM; in lpfc_sli4_alloc_resource_identifiers()
6724 phba->sli4_hba.rpi_ids = kcalloc(count, sizeof(uint16_t), in lpfc_sli4_alloc_resource_identifiers()
6726 if (unlikely(!phba->sli4_hba.rpi_ids)) { in lpfc_sli4_alloc_resource_identifiers()
6727 rc = -ENOMEM; in lpfc_sli4_alloc_resource_identifiers()
6732 phba->sli4_hba.rpi_ids[i] = base + i; in lpfc_sli4_alloc_resource_identifiers()
6735 count = phba->sli4_hba.max_cfg_param.max_vpi; in lpfc_sli4_alloc_resource_identifiers()
6740 rc = -EINVAL; in lpfc_sli4_alloc_resource_identifiers()
6743 base = phba->sli4_hba.max_cfg_param.vpi_base; in lpfc_sli4_alloc_resource_identifiers()
6744 longs = (count + BITS_PER_LONG - 1) / BITS_PER_LONG; in lpfc_sli4_alloc_resource_identifiers()
6745 phba->vpi_bmask = kcalloc(longs, sizeof(unsigned long), in lpfc_sli4_alloc_resource_identifiers()
6747 if (unlikely(!phba->vpi_bmask)) { in lpfc_sli4_alloc_resource_identifiers()
6748 rc = -ENOMEM; in lpfc_sli4_alloc_resource_identifiers()
6751 phba->vpi_ids = kcalloc(count, sizeof(uint16_t), in lpfc_sli4_alloc_resource_identifiers()
6753 if (unlikely(!phba->vpi_ids)) { in lpfc_sli4_alloc_resource_identifiers()
6754 rc = -ENOMEM; in lpfc_sli4_alloc_resource_identifiers()
6759 phba->vpi_ids[i] = base + i; in lpfc_sli4_alloc_resource_identifiers()
6762 count = phba->sli4_hba.max_cfg_param.max_xri; in lpfc_sli4_alloc_resource_identifiers()
6767 rc = -EINVAL; in lpfc_sli4_alloc_resource_identifiers()
6770 base = phba->sli4_hba.max_cfg_param.xri_base; in lpfc_sli4_alloc_resource_identifiers()
6771 longs = (count + BITS_PER_LONG - 1) / BITS_PER_LONG; in lpfc_sli4_alloc_resource_identifiers()
6772 phba->sli4_hba.xri_bmask = kcalloc(longs, in lpfc_sli4_alloc_resource_identifiers()
6775 if (unlikely(!phba->sli4_hba.xri_bmask)) { in lpfc_sli4_alloc_resource_identifiers()
6776 rc = -ENOMEM; in lpfc_sli4_alloc_resource_identifiers()
6779 phba->sli4_hba.max_cfg_param.xri_used = 0; in lpfc_sli4_alloc_resource_identifiers()
6780 phba->sli4_hba.xri_ids = kcalloc(count, sizeof(uint16_t), in lpfc_sli4_alloc_resource_identifiers()
6782 if (unlikely(!phba->sli4_hba.xri_ids)) { in lpfc_sli4_alloc_resource_identifiers()
6783 rc = -ENOMEM; in lpfc_sli4_alloc_resource_identifiers()
6788 phba->sli4_hba.xri_ids[i] = base + i; in lpfc_sli4_alloc_resource_identifiers()
6791 count = phba->sli4_hba.max_cfg_param.max_vfi; in lpfc_sli4_alloc_resource_identifiers()
6796 rc = -EINVAL; in lpfc_sli4_alloc_resource_identifiers()
6799 base = phba->sli4_hba.max_cfg_param.vfi_base; in lpfc_sli4_alloc_resource_identifiers()
6800 longs = (count + BITS_PER_LONG - 1) / BITS_PER_LONG; in lpfc_sli4_alloc_resource_identifiers()
6801 phba->sli4_hba.vfi_bmask = kcalloc(longs, in lpfc_sli4_alloc_resource_identifiers()
6804 if (unlikely(!phba->sli4_hba.vfi_bmask)) { in lpfc_sli4_alloc_resource_identifiers()
6805 rc = -ENOMEM; in lpfc_sli4_alloc_resource_identifiers()
6808 phba->sli4_hba.vfi_ids = kcalloc(count, sizeof(uint16_t), in lpfc_sli4_alloc_resource_identifiers()
6810 if (unlikely(!phba->sli4_hba.vfi_ids)) { in lpfc_sli4_alloc_resource_identifiers()
6811 rc = -ENOMEM; in lpfc_sli4_alloc_resource_identifiers()
6816 phba->sli4_hba.vfi_ids[i] = base + i; in lpfc_sli4_alloc_resource_identifiers()
6822 bf_set(lpfc_idx_rsrc_rdy, &phba->sli4_hba.sli4_flags, in lpfc_sli4_alloc_resource_identifiers()
6828 kfree(phba->sli4_hba.vfi_bmask); in lpfc_sli4_alloc_resource_identifiers()
6829 phba->sli4_hba.vfi_bmask = NULL; in lpfc_sli4_alloc_resource_identifiers()
6831 kfree(phba->sli4_hba.xri_ids); in lpfc_sli4_alloc_resource_identifiers()
6832 phba->sli4_hba.xri_ids = NULL; in lpfc_sli4_alloc_resource_identifiers()
6834 kfree(phba->sli4_hba.xri_bmask); in lpfc_sli4_alloc_resource_identifiers()
6835 phba->sli4_hba.xri_bmask = NULL; in lpfc_sli4_alloc_resource_identifiers()
6837 kfree(phba->vpi_ids); in lpfc_sli4_alloc_resource_identifiers()
6838 phba->vpi_ids = NULL; in lpfc_sli4_alloc_resource_identifiers()
6840 kfree(phba->vpi_bmask); in lpfc_sli4_alloc_resource_identifiers()
6841 phba->vpi_bmask = NULL; in lpfc_sli4_alloc_resource_identifiers()
6843 kfree(phba->sli4_hba.rpi_ids); in lpfc_sli4_alloc_resource_identifiers()
6844 phba->sli4_hba.rpi_ids = NULL; in lpfc_sli4_alloc_resource_identifiers()
6846 kfree(phba->sli4_hba.rpi_bmask); in lpfc_sli4_alloc_resource_identifiers()
6847 phba->sli4_hba.rpi_bmask = NULL; in lpfc_sli4_alloc_resource_identifiers()
6853 * lpfc_sli4_dealloc_resource_identifiers - Deallocate all SLI4 resource extents.
6862 if (phba->sli4_hba.extents_in_use) { in lpfc_sli4_dealloc_resource_identifiers()
6868 kfree(phba->vpi_bmask); in lpfc_sli4_dealloc_resource_identifiers()
6869 phba->sli4_hba.max_cfg_param.vpi_used = 0; in lpfc_sli4_dealloc_resource_identifiers()
6870 kfree(phba->vpi_ids); in lpfc_sli4_dealloc_resource_identifiers()
6871 bf_set(lpfc_vpi_rsrc_rdy, &phba->sli4_hba.sli4_flags, 0); in lpfc_sli4_dealloc_resource_identifiers()
6872 kfree(phba->sli4_hba.xri_bmask); in lpfc_sli4_dealloc_resource_identifiers()
6873 kfree(phba->sli4_hba.xri_ids); in lpfc_sli4_dealloc_resource_identifiers()
6874 kfree(phba->sli4_hba.vfi_bmask); in lpfc_sli4_dealloc_resource_identifiers()
6875 kfree(phba->sli4_hba.vfi_ids); in lpfc_sli4_dealloc_resource_identifiers()
6876 bf_set(lpfc_vfi_rsrc_rdy, &phba->sli4_hba.sli4_flags, 0); in lpfc_sli4_dealloc_resource_identifiers()
6877 bf_set(lpfc_idx_rsrc_rdy, &phba->sli4_hba.sli4_flags, 0); in lpfc_sli4_dealloc_resource_identifiers()
6884 * lpfc_sli4_get_allocated_extnts - Get the port's allocated extents.
6912 blk_list_head = &phba->lpfc_vpi_blk_list; in lpfc_sli4_get_allocated_extnts()
6915 blk_list_head = &phba->sli4_hba.lpfc_xri_blk_list; in lpfc_sli4_get_allocated_extnts()
6918 blk_list_head = &phba->sli4_hba.lpfc_vfi_blk_list; in lpfc_sli4_get_allocated_extnts()
6921 blk_list_head = &phba->sli4_hba.lpfc_rpi_blk_list; in lpfc_sli4_get_allocated_extnts()
6924 return -EIO; in lpfc_sli4_get_allocated_extnts()
6931 * The GET_ALLOCATED mailbox does not return the size, in lpfc_sli4_get_allocated_extnts()
6937 *extnt_size = rsrc_blk->rsrc_size; in lpfc_sli4_get_allocated_extnts()
6943 * Calculate the size of an embedded mailbox. The uint32_t in lpfc_sli4_get_allocated_extnts()
6944 * accounts for extents-specific word. in lpfc_sli4_get_allocated_extnts()
6946 emb_len = sizeof(MAILBOX_t) - sizeof(struct mbox_header) - in lpfc_sli4_get_allocated_extnts()
6951 * mailbox. If not true, reconfigure to a non-embedded mailbox. in lpfc_sli4_get_allocated_extnts()
6962 mbox = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_get_allocated_extnts()
6964 return -ENOMEM; in lpfc_sli4_get_allocated_extnts()
6975 rc = -ENOMEM; in lpfc_sli4_get_allocated_extnts()
6980 rc = -EIO; in lpfc_sli4_get_allocated_extnts()
6984 if (!phba->sli4_hba.intr_enable) in lpfc_sli4_get_allocated_extnts()
6992 rc = -EIO; in lpfc_sli4_get_allocated_extnts()
7003 rsrc_ext = &mbox->u.mqe.un.alloc_rsrc_extents; in lpfc_sli4_get_allocated_extnts()
7004 shdr = &rsrc_ext->header.cfg_shdr; in lpfc_sli4_get_allocated_extnts()
7005 *extnt_cnt = bf_get(lpfc_mbx_rsrc_cnt, &rsrc_ext->u.rsp); in lpfc_sli4_get_allocated_extnts()
7007 virtaddr = mbox->sge_array->addr[0]; in lpfc_sli4_get_allocated_extnts()
7009 shdr = &n_rsrc->cfg_shdr; in lpfc_sli4_get_allocated_extnts()
7013 if (bf_get(lpfc_mbox_hdr_status, &shdr->response)) { in lpfc_sli4_get_allocated_extnts()
7016 "for type %d - Status 0x%x Add'l Status 0x%x.\n", in lpfc_sli4_get_allocated_extnts()
7018 bf_get(lpfc_mbox_hdr_status, &shdr->response), in lpfc_sli4_get_allocated_extnts()
7019 bf_get(lpfc_mbox_hdr_add_status, &shdr->response)); in lpfc_sli4_get_allocated_extnts()
7020 rc = -EIO; in lpfc_sli4_get_allocated_extnts()
7029 * lpfc_sli4_repost_sgl_list - Repost the buffers sgl pages as block
7037 * of buffer sgls which contains contiguous xris and uses the non-embedded
7038 * SGL block post mailbox commands to post them to the port. For single
7039 * buffer sgl with non-contiguous xri, if any, it shall use embedded SGL post
7040 * mailbox command for posting.
7042 * Returns: 0 = success, non-zero failure.
7060 spin_lock_irq(&phba->hbalock); in lpfc_sli4_repost_sgl_list()
7061 spin_lock(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_repost_sgl_list()
7063 spin_unlock(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_repost_sgl_list()
7064 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_repost_sgl_list()
7069 list_del_init(&sglq_entry->list); in lpfc_sli4_repost_sgl_list()
7072 (sglq_entry->sli4_xritag != last_xritag + 1)) { in lpfc_sli4_repost_sgl_list()
7075 post_cnt = block_cnt - 1; in lpfc_sli4_repost_sgl_list()
7077 list_add_tail(&sglq_entry->list, &prep_sgl_list); in lpfc_sli4_repost_sgl_list()
7081 list_add_tail(&sglq_entry->list, &prep_sgl_list); in lpfc_sli4_repost_sgl_list()
7082 /* enough sgls for non-embed sgl mbox command */ in lpfc_sli4_repost_sgl_list()
7093 last_xritag = sglq_entry->sli4_xritag; in lpfc_sli4_repost_sgl_list()
7103 sglq_entry->phys, 0, in lpfc_sli4_repost_sgl_list()
7104 sglq_entry->sli4_xritag); in lpfc_sli4_repost_sgl_list()
7107 list_add_tail(&sglq_entry->list, in lpfc_sli4_repost_sgl_list()
7115 sglq_entry->sli4_xritag); in lpfc_sli4_repost_sgl_list()
7116 list_add_tail(&sglq_entry->list, in lpfc_sli4_repost_sgl_list()
7118 total_cnt--; in lpfc_sli4_repost_sgl_list()
7140 "3160 Failed to post sgl-list, " in lpfc_sli4_repost_sgl_list()
7141 "xritag:x%x-x%x\n", in lpfc_sli4_repost_sgl_list()
7142 sglq_entry_first->sli4_xritag, in lpfc_sli4_repost_sgl_list()
7143 (sglq_entry_first->sli4_xritag + in lpfc_sli4_repost_sgl_list()
7144 post_cnt - 1)); in lpfc_sli4_repost_sgl_list()
7146 total_cnt -= post_cnt; in lpfc_sli4_repost_sgl_list()
7162 spin_lock_irq(&phba->hbalock); in lpfc_sli4_repost_sgl_list()
7163 spin_lock(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_repost_sgl_list()
7165 spin_unlock(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_repost_sgl_list()
7166 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_repost_sgl_list()
7170 return -EIO; in lpfc_sli4_repost_sgl_list()
7178 * lpfc_sli4_repost_io_sgl_list - Repost all the allocated nvme buffer sgls
7187 * Returns: 0 = success, non-zero failure.
7201 phba, &post_nblist, phba->sli4_hba.io_xri_cnt); in lpfc_sli4_repost_io_sgl_list()
7204 rc = -EIO; in lpfc_sli4_repost_io_sgl_list()
7214 len = sizeof(struct lpfc_mbx_set_host_data) - in lpfc_set_host_data()
7220 mbox->u.mqe.un.set_host_data.param_id = LPFC_SET_HOST_OS_DRIVER_VERSION; in lpfc_set_host_data()
7221 mbox->u.mqe.un.set_host_data.param_len = in lpfc_set_host_data()
7223 snprintf(mbox->u.mqe.un.set_host_data.data, in lpfc_set_host_data()
7226 (phba->hba_flag & HBA_FCOE_MODE) ? "FCoE" : "FC"); in lpfc_set_host_data()
7241 rqbp = hrq->rqbp; in lpfc_post_rq_buffer()
7243 spin_lock_irqsave(&phba->hbalock, flags); in lpfc_post_rq_buffer()
7245 if (rqbp->buffer_count + i >= rqbp->entry_count - 1) { in lpfc_post_rq_buffer()
7246 spin_unlock_irqrestore(&phba->hbalock, flags); in lpfc_post_rq_buffer()
7249 spin_unlock_irqrestore(&phba->hbalock, flags); in lpfc_post_rq_buffer()
7251 rqb_buffer = rqbp->rqb_alloc_buffer(phba); in lpfc_post_rq_buffer()
7254 rqb_buffer->hrq = hrq; in lpfc_post_rq_buffer()
7255 rqb_buffer->drq = drq; in lpfc_post_rq_buffer()
7256 rqb_buffer->idx = idx; in lpfc_post_rq_buffer()
7257 list_add_tail(&rqb_buffer->hbuf.list, &rqb_buf_list); in lpfc_post_rq_buffer()
7260 spin_lock_irqsave(&phba->hbalock, flags); in lpfc_post_rq_buffer()
7265 hrqe.address_lo = putPaddrLow(rqb_buffer->hbuf.phys); in lpfc_post_rq_buffer()
7266 hrqe.address_hi = putPaddrHigh(rqb_buffer->hbuf.phys); in lpfc_post_rq_buffer()
7267 drqe.address_lo = putPaddrLow(rqb_buffer->dbuf.phys); in lpfc_post_rq_buffer()
7268 drqe.address_hi = putPaddrHigh(rqb_buffer->dbuf.phys); in lpfc_post_rq_buffer()
7274 hrq->queue_id, in lpfc_post_rq_buffer()
7275 hrq->host_index, in lpfc_post_rq_buffer()
7276 hrq->hba_index, in lpfc_post_rq_buffer()
7277 hrq->entry_count, in lpfc_post_rq_buffer()
7278 drq->host_index, in lpfc_post_rq_buffer()
7279 drq->hba_index); in lpfc_post_rq_buffer()
7280 rqbp->rqb_free_buffer(phba, rqb_buffer); in lpfc_post_rq_buffer()
7282 list_add_tail(&rqb_buffer->hbuf.list, in lpfc_post_rq_buffer()
7283 &rqbp->rqb_buffer_list); in lpfc_post_rq_buffer()
7284 rqbp->buffer_count++; in lpfc_post_rq_buffer()
7287 spin_unlock_irqrestore(&phba->hbalock, flags); in lpfc_post_rq_buffer()
7292 * lpfc_init_idle_stat_hb - Initialize idle_stat tracking
7295 * This routine initializes the per-cq idle_stat to dynamically dictate
7310 hdwq = &phba->sli4_hba.hdwq[phba->sli4_hba.cpu_map[i].hdwq]; in lpfc_init_idle_stat_hb()
7311 cq = hdwq->io_cq; in lpfc_init_idle_stat_hb()
7314 if (cq->chann != i) in lpfc_init_idle_stat_hb()
7317 idle_stat = &phba->sli4_hba.idle_stat[i]; in lpfc_init_idle_stat_hb()
7319 idle_stat->prev_idle = get_cpu_idle_time(i, &wall, 1); in lpfc_init_idle_stat_hb()
7320 idle_stat->prev_wall = wall; in lpfc_init_idle_stat_hb()
7322 if (phba->nvmet_support) in lpfc_init_idle_stat_hb()
7323 cq->poll_mode = LPFC_QUEUE_WORK; in lpfc_init_idle_stat_hb()
7325 cq->poll_mode = LPFC_IRQ_POLL; in lpfc_init_idle_stat_hb()
7328 if (!phba->nvmet_support) in lpfc_init_idle_stat_hb()
7329 schedule_delayed_work(&phba->idle_stat_delay_work, in lpfc_init_idle_stat_hb()
7337 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); in lpfc_sli4_dip()
7342 if (lpfc_readl(phba->sli4_hba.u.if_type2.STATUSregaddr, in lpfc_sli4_dip()
7354 * lpfc_sli4_hba_setup - SLI4 device initialization PCI function
7371 struct Scsi_Host *shost = lpfc_shost_from_vport(phba->pport); in lpfc_sli4_hba_setup()
7372 struct lpfc_vport *vport = phba->pport; in lpfc_sli4_hba_setup()
7379 return -ENODEV; in lpfc_sli4_hba_setup()
7384 return -ENODEV; in lpfc_sli4_hba_setup()
7386 spin_lock_irq(&phba->hbalock); in lpfc_sli4_hba_setup()
7387 phba->sli.sli_flag |= LPFC_SLI_ACTIVE; in lpfc_sli4_hba_setup()
7388 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_hba_setup()
7394 * Allocate a single mailbox container for initializing the in lpfc_sli4_hba_setup()
7397 mboxq = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_hba_setup()
7399 return -ENOMEM; in lpfc_sli4_hba_setup()
7405 rc = -ENOMEM; in lpfc_sli4_hba_setup()
7415 mqe = &mboxq->u.mqe; in lpfc_sli4_hba_setup()
7416 phba->sli_rev = bf_get(lpfc_mbx_rd_rev_sli_lvl, &mqe->un.read_rev); in lpfc_sli4_hba_setup()
7417 if (bf_get(lpfc_mbx_rd_rev_fcoe, &mqe->un.read_rev)) { in lpfc_sli4_hba_setup()
7418 phba->hba_flag |= HBA_FCOE_MODE; in lpfc_sli4_hba_setup()
7419 phba->fcp_embed_io = 0; /* SLI4 FC support only */ in lpfc_sli4_hba_setup()
7421 phba->hba_flag &= ~HBA_FCOE_MODE; in lpfc_sli4_hba_setup()
7424 if (bf_get(lpfc_mbx_rd_rev_cee_ver, &mqe->un.read_rev) == in lpfc_sli4_hba_setup()
7426 phba->hba_flag |= HBA_FIP_SUPPORT; in lpfc_sli4_hba_setup()
7428 phba->hba_flag &= ~HBA_FIP_SUPPORT; in lpfc_sli4_hba_setup()
7430 phba->hba_flag &= ~HBA_IOQ_FLUSH; in lpfc_sli4_hba_setup()
7432 if (phba->sli_rev != LPFC_SLI_REV4) { in lpfc_sli4_hba_setup()
7436 phba->sli_rev, phba->hba_flag & HBA_FCOE_MODE); in lpfc_sli4_hba_setup()
7437 rc = -EIO; in lpfc_sli4_hba_setup()
7447 if (phba->hba_flag & HBA_FCOE_MODE && in lpfc_sli4_hba_setup()
7454 * is considered as non-fatal. in lpfc_sli4_hba_setup()
7460 "physical port name: %s.\n", phba->Port); in lpfc_sli4_hba_setup()
7483 phba->vpd.rev.biuRev = mqe->un.read_rev.first_hw_rev; in lpfc_sli4_hba_setup()
7484 phba->vpd.rev.smRev = mqe->un.read_rev.second_hw_rev; in lpfc_sli4_hba_setup()
7490 if ((bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) == in lpfc_sli4_hba_setup()
7492 (phba->vpd.rev.biuRev == LPFC_G7_ASIC_1) && in lpfc_sli4_hba_setup()
7493 (phba->vpd.rev.smRev == 0) && in lpfc_sli4_hba_setup()
7494 (phba->cfg_nvme_embed_cmd == 1)) in lpfc_sli4_hba_setup()
7495 phba->cfg_nvme_embed_cmd = 0; in lpfc_sli4_hba_setup()
7497 phba->vpd.rev.endecRev = mqe->un.read_rev.third_hw_rev; in lpfc_sli4_hba_setup()
7498 phba->vpd.rev.fcphHigh = bf_get(lpfc_mbx_rd_rev_fcph_high, in lpfc_sli4_hba_setup()
7499 &mqe->un.read_rev); in lpfc_sli4_hba_setup()
7500 phba->vpd.rev.fcphLow = bf_get(lpfc_mbx_rd_rev_fcph_low, in lpfc_sli4_hba_setup()
7501 &mqe->un.read_rev); in lpfc_sli4_hba_setup()
7502 phba->vpd.rev.feaLevelHigh = bf_get(lpfc_mbx_rd_rev_ftr_lvl_high, in lpfc_sli4_hba_setup()
7503 &mqe->un.read_rev); in lpfc_sli4_hba_setup()
7504 phba->vpd.rev.feaLevelLow = bf_get(lpfc_mbx_rd_rev_ftr_lvl_low, in lpfc_sli4_hba_setup()
7505 &mqe->un.read_rev); in lpfc_sli4_hba_setup()
7506 phba->vpd.rev.sli1FwRev = mqe->un.read_rev.fw_id_rev; in lpfc_sli4_hba_setup()
7507 memcpy(phba->vpd.rev.sli1FwName, mqe->un.read_rev.fw_name, 16); in lpfc_sli4_hba_setup()
7508 phba->vpd.rev.sli2FwRev = mqe->un.read_rev.ulp_fw_id_rev; in lpfc_sli4_hba_setup()
7509 memcpy(phba->vpd.rev.sli2FwName, mqe->un.read_rev.ulp_fw_name, 16); in lpfc_sli4_hba_setup()
7510 phba->vpd.rev.opFwRev = mqe->un.read_rev.fw_id_rev; in lpfc_sli4_hba_setup()
7511 memcpy(phba->vpd.rev.opFwName, mqe->un.read_rev.fw_name, 16); in lpfc_sli4_hba_setup()
7515 mboxq->vport ? mboxq->vport->vpi : 0, in lpfc_sli4_hba_setup()
7517 phba->vpd.rev.opFwName, in lpfc_sli4_hba_setup()
7518 phba->vpd.rev.fcphHigh, phba->vpd.rev.fcphLow, in lpfc_sli4_hba_setup()
7519 phba->vpd.rev.feaLevelHigh, phba->vpd.rev.feaLevelLow); in lpfc_sli4_hba_setup()
7521 if (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) == in lpfc_sli4_hba_setup()
7526 phba->hba_flag |= HBA_RECOVERABLE_UE; in lpfc_sli4_hba_setup()
7528 phba->eratt_poll_interval = 1; in lpfc_sli4_hba_setup()
7529 phba->sli4_hba.ue_to_sr = bf_get( in lpfc_sli4_hba_setup()
7531 &mboxq->u.mqe.un.set_feature); in lpfc_sli4_hba_setup()
7532 phba->sli4_hba.ue_to_rp = bf_get( in lpfc_sli4_hba_setup()
7534 &mboxq->u.mqe.un.set_feature); in lpfc_sli4_hba_setup()
7538 if (phba->cfg_enable_mds_diags && phba->mds_diags_support) { in lpfc_sli4_hba_setup()
7543 phba->mds_diags_support = 0; in lpfc_sli4_hba_setup()
7553 rc = -EIO; in lpfc_sli4_hba_setup()
7561 if (!(bf_get(lpfc_mbx_rq_ftr_rsp_fcpi, &mqe->un.req_ftrs))) { in lpfc_sli4_hba_setup()
7568 if (phba->hba_flag & HBA_FCOE_MODE) { in lpfc_sli4_hba_setup()
7569 if (bf_get(lpfc_mbx_rq_ftr_rsp_perfh, &mqe->un.req_ftrs)) in lpfc_sli4_hba_setup()
7570 phba->sli3_options |= LPFC_SLI4_PERFH_ENABLED; in lpfc_sli4_hba_setup()
7572 phba->sli3_options &= ~LPFC_SLI4_PERFH_ENABLED; in lpfc_sli4_hba_setup()
7580 if (phba->sli3_options & LPFC_SLI3_BG_ENABLED) { in lpfc_sli4_hba_setup()
7581 if (!(bf_get(lpfc_mbx_rq_ftr_rsp_dif, &mqe->un.req_ftrs))) { in lpfc_sli4_hba_setup()
7582 phba->cfg_enable_bg = 0; in lpfc_sli4_hba_setup()
7583 phba->sli3_options &= ~LPFC_SLI3_BG_ENABLED; in lpfc_sli4_hba_setup()
7588 if (phba->max_vpi && phba->cfg_enable_npiv && in lpfc_sli4_hba_setup()
7589 !(bf_get(lpfc_mbx_rq_ftr_rsp_npiv, &mqe->un.req_ftrs))) in lpfc_sli4_hba_setup()
7595 "x%x x%x x%x\n", mqe->un.req_ftrs.word2, in lpfc_sli4_hba_setup()
7596 mqe->un.req_ftrs.word3, phba->cfg_enable_bg, in lpfc_sli4_hba_setup()
7597 phba->cfg_enable_npiv, phba->max_vpi); in lpfc_sli4_hba_setup()
7598 if (!(bf_get(lpfc_mbx_rq_ftr_rsp_dif, &mqe->un.req_ftrs))) in lpfc_sli4_hba_setup()
7599 phba->cfg_enable_bg = 0; in lpfc_sli4_hba_setup()
7600 if (!(bf_get(lpfc_mbx_rq_ftr_rsp_npiv, &mqe->un.req_ftrs))) in lpfc_sli4_hba_setup()
7601 phba->cfg_enable_npiv = 0; in lpfc_sli4_hba_setup()
7605 spin_lock_irq(&phba->hbalock); in lpfc_sli4_hba_setup()
7606 phba->sli3_options |= (LPFC_SLI3_NPIV_ENABLED | LPFC_SLI3_HBQ_ENABLED); in lpfc_sli4_hba_setup()
7607 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_hba_setup()
7612 dd = bf_get(lpfc_mbx_set_feature_dd, &mboxq->u.mqe.un.set_feature); in lpfc_sli4_hba_setup()
7618 "6447 Dual Dump Mailbox x%x (x%x/x%x) failed, " in lpfc_sli4_hba_setup()
7620 bf_get(lpfc_mqe_command, &mboxq->u.mqe), in lpfc_sli4_hba_setup()
7648 rc = lpfc_read_sparam(phba, mboxq, vport->vpi); in lpfc_sli4_hba_setup()
7650 phba->link_state = LPFC_HBA_ERROR; in lpfc_sli4_hba_setup()
7651 rc = -ENOMEM; in lpfc_sli4_hba_setup()
7655 mboxq->vport = vport; in lpfc_sli4_hba_setup()
7657 mp = (struct lpfc_dmabuf *)mboxq->ctx_buf; in lpfc_sli4_hba_setup()
7659 memcpy(&vport->fc_sparam, mp->virt, sizeof(struct serv_parm)); in lpfc_sli4_hba_setup()
7667 lpfc_mbuf_free(phba, mp->virt, mp->phys); in lpfc_sli4_hba_setup()
7669 mboxq->ctx_buf = NULL; in lpfc_sli4_hba_setup()
7675 phba->link_state = LPFC_HBA_ERROR; in lpfc_sli4_hba_setup()
7676 rc = -EIO; in lpfc_sli4_hba_setup()
7683 fc_host_node_name(shost) = wwn_to_u64(vport->fc_nodename.u.wwn); in lpfc_sli4_hba_setup()
7684 fc_host_port_name(shost) = wwn_to_u64(vport->fc_portname.u.wwn); in lpfc_sli4_hba_setup()
7691 rc = -ENODEV; in lpfc_sli4_hba_setup()
7705 /* update host els xri-sgl sizes and mappings */ in lpfc_sli4_hba_setup()
7709 "1400 Failed to update xri-sgl size and " in lpfc_sli4_hba_setup()
7715 rc = lpfc_sli4_repost_sgl_list(phba, &phba->sli4_hba.lpfc_els_sgl_list, in lpfc_sli4_hba_setup()
7716 phba->sli4_hba.els_xri_cnt); in lpfc_sli4_hba_setup()
7721 rc = -ENODEV; in lpfc_sli4_hba_setup()
7724 phba->sli4_hba.els_xri_cnt = rc; in lpfc_sli4_hba_setup()
7726 if (phba->nvmet_support) { in lpfc_sli4_hba_setup()
7727 /* update host nvmet xri-sgl sizes and mappings */ in lpfc_sli4_hba_setup()
7731 "6308 Failed to update nvmet-sgl size " in lpfc_sli4_hba_setup()
7739 &phba->sli4_hba.lpfc_nvmet_sgl_list, in lpfc_sli4_hba_setup()
7740 phba->sli4_hba.nvmet_xri_cnt); in lpfc_sli4_hba_setup()
7745 rc = -ENODEV; in lpfc_sli4_hba_setup()
7748 phba->sli4_hba.nvmet_xri_cnt = rc; in lpfc_sli4_hba_setup()
7753 cnt = phba->sli4_hba.nvmet_xri_cnt + in lpfc_sli4_hba_setup()
7754 phba->sli4_hba.max_cfg_param.max_xri; in lpfc_sli4_hba_setup()
7756 /* update host common xri-sgl sizes and mappings */ in lpfc_sli4_hba_setup()
7760 "6082 Failed to update nvme-sgl size " in lpfc_sli4_hba_setup()
7773 rc = -ENODEV; in lpfc_sli4_hba_setup()
7779 cnt = phba->sli4_hba.max_cfg_param.max_xri; in lpfc_sli4_hba_setup()
7782 if (!phba->sli.iocbq_lookup) { in lpfc_sli4_hba_setup()
7795 if (phba->nvmet_support) in lpfc_sli4_hba_setup()
7798 if (phba->nvmet_support && phba->cfg_nvmet_mrq) { in lpfc_sli4_hba_setup()
7800 for (i = 0; i < phba->cfg_nvmet_mrq; i++) { in lpfc_sli4_hba_setup()
7801 rqbp = phba->sli4_hba.nvmet_mrq_hdr[i]->rqbp; in lpfc_sli4_hba_setup()
7802 INIT_LIST_HEAD(&rqbp->rqb_buffer_list); in lpfc_sli4_hba_setup()
7803 rqbp->rqb_alloc_buffer = lpfc_sli4_nvmet_alloc; in lpfc_sli4_hba_setup()
7804 rqbp->rqb_free_buffer = lpfc_sli4_nvmet_free; in lpfc_sli4_hba_setup()
7805 rqbp->entry_count = LPFC_NVMET_RQE_DEF_COUNT; in lpfc_sli4_hba_setup()
7806 rqbp->buffer_count = 0; in lpfc_sli4_hba_setup()
7809 phba, phba->sli4_hba.nvmet_mrq_hdr[i], in lpfc_sli4_hba_setup()
7810 phba->sli4_hba.nvmet_mrq_data[i], in lpfc_sli4_hba_setup()
7811 phba->cfg_nvmet_mrq_post, i); in lpfc_sli4_hba_setup()
7821 rc = -ENODEV; in lpfc_sli4_hba_setup()
7826 if (!(phba->hba_flag & HBA_FCOE_MODE)) { in lpfc_sli4_hba_setup()
7827 if ((phba->nvmet_support == 0) || (phba->cfg_nvmet_mrq == 1)) { in lpfc_sli4_hba_setup()
7832 mboxq->vport = phba->pport; in lpfc_sli4_hba_setup()
7837 phba->fcf.fcfi = bf_get(lpfc_reg_fcfi_fcfi, in lpfc_sli4_hba_setup()
7838 &mboxq->u.mqe.un.reg_fcfi); in lpfc_sli4_hba_setup()
7844 mboxq->vport = phba->pport; in lpfc_sli4_hba_setup()
7849 phba->fcf.fcfi = bf_get(lpfc_reg_fcfi_mrq_fcfi, in lpfc_sli4_hba_setup()
7850 &mboxq->u.mqe.un.reg_fcfi_mrq); in lpfc_sli4_hba_setup()
7854 mboxq->vport = phba->pport; in lpfc_sli4_hba_setup()
7867 if (phba->nvmet_support == 0) { in lpfc_sli4_hba_setup()
7868 if (phba->sli4_hba.io_xri_cnt == 0) { in lpfc_sli4_hba_setup()
7870 phba, phba->sli4_hba.io_xri_max); in lpfc_sli4_hba_setup()
7872 rc = -ENOMEM; in lpfc_sli4_hba_setup()
7876 if (phba->cfg_xri_rebalancing) in lpfc_sli4_hba_setup()
7880 phba->cfg_xri_rebalancing = 0; in lpfc_sli4_hba_setup()
7883 /* Allow asynchronous mailbox command to go through */ in lpfc_sli4_hba_setup()
7884 spin_lock_irq(&phba->hbalock); in lpfc_sli4_hba_setup()
7885 phba->sli.sli_flag &= ~LPFC_SLI_ASYNC_MBX_BLK; in lpfc_sli4_hba_setup()
7886 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_hba_setup()
7892 phba->fcf.fcf_flag = 0; in lpfc_sli4_hba_setup()
7893 phba->fcf.current_rec.flag = 0; in lpfc_sli4_hba_setup()
7896 mod_timer(&vport->els_tmofunc, in lpfc_sli4_hba_setup()
7897 jiffies + msecs_to_jiffies(1000 * (phba->fc_ratov * 2))); in lpfc_sli4_hba_setup()
7900 mod_timer(&phba->hb_tmofunc, in lpfc_sli4_hba_setup()
7902 phba->hb_outstanding = 0; in lpfc_sli4_hba_setup()
7903 phba->last_completion_time = jiffies; in lpfc_sli4_hba_setup()
7906 if (phba->cfg_auto_imax) in lpfc_sli4_hba_setup()
7907 queue_delayed_work(phba->wq, &phba->eq_delay_work, in lpfc_sli4_hba_setup()
7914 mod_timer(&phba->eratt_poll, in lpfc_sli4_hba_setup()
7915 jiffies + msecs_to_jiffies(1000 * phba->eratt_poll_interval)); in lpfc_sli4_hba_setup()
7918 if (phba->cfg_aer_support == 1 && !(phba->hba_flag & HBA_AER_ENABLED)) { in lpfc_sli4_hba_setup()
7919 rc = pci_enable_pcie_error_reporting(phba->pcidev); in lpfc_sli4_hba_setup()
7924 spin_lock_irq(&phba->hbalock); in lpfc_sli4_hba_setup()
7925 phba->hba_flag |= HBA_AER_ENABLED; in lpfc_sli4_hba_setup()
7926 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_hba_setup()
7931 phba->cfg_aer_support = 0; in lpfc_sli4_hba_setup()
7940 spin_lock_irq(&phba->hbalock); in lpfc_sli4_hba_setup()
7941 phba->link_state = LPFC_LINK_DOWN; in lpfc_sli4_hba_setup()
7944 if (bf_get(lpfc_conf_trunk_port0, &phba->sli4_hba)) in lpfc_sli4_hba_setup()
7945 phba->trunk_link.link0.state = LPFC_LINK_DOWN; in lpfc_sli4_hba_setup()
7946 if (bf_get(lpfc_conf_trunk_port1, &phba->sli4_hba)) in lpfc_sli4_hba_setup()
7947 phba->trunk_link.link1.state = LPFC_LINK_DOWN; in lpfc_sli4_hba_setup()
7948 if (bf_get(lpfc_conf_trunk_port2, &phba->sli4_hba)) in lpfc_sli4_hba_setup()
7949 phba->trunk_link.link2.state = LPFC_LINK_DOWN; in lpfc_sli4_hba_setup()
7950 if (bf_get(lpfc_conf_trunk_port3, &phba->sli4_hba)) in lpfc_sli4_hba_setup()
7951 phba->trunk_link.link3.state = LPFC_LINK_DOWN; in lpfc_sli4_hba_setup()
7952 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_hba_setup()
7958 phba->sli4_hba.intr_enable = 1; in lpfc_sli4_hba_setup()
7960 if (!(phba->hba_flag & HBA_FCOE_MODE) && in lpfc_sli4_hba_setup()
7961 (phba->hba_flag & LINK_DISABLED)) { in lpfc_sli4_hba_setup()
7972 } else if (phba->cfg_suppress_link_up == LPFC_INITIALIZE_LINK) { in lpfc_sli4_hba_setup()
7974 if (!(phba->link_flag & LS_LOOPBACK_MODE)) { in lpfc_sli4_hba_setup()
7975 rc = phba->lpfc_hba_init_link(phba, MBX_NOWAIT); in lpfc_sli4_hba_setup()
7980 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_hba_setup()
7995 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_hba_setup()
8000 * lpfc_mbox_timeout - Timeout call back function for mbox timer
8003 * This is the callback function for mailbox timer. The mailbox
8004 * timer is armed when a new mailbox command is issued and the timer
8005 * is deleted when the mailbox complete. The function is called by
8006 * the kernel timer code when a mailbox does not complete within
8008 * process the mailbox timeout and returns. All the processing is
8018 spin_lock_irqsave(&phba->pport->work_port_lock, iflag); in lpfc_mbox_timeout()
8019 tmo_posted = phba->pport->work_port_events & WORKER_MBOX_TMO; in lpfc_mbox_timeout()
8021 phba->pport->work_port_events |= WORKER_MBOX_TMO; in lpfc_mbox_timeout()
8022 spin_unlock_irqrestore(&phba->pport->work_port_lock, iflag); in lpfc_mbox_timeout()
8030 * lpfc_sli4_mbox_completions_pending - check to see if any mailbox completions
8034 * This function checks if any mailbox completions are present on the mailbox
8047 if (unlikely(!phba) || (phba->sli_rev != LPFC_SLI_REV4)) in lpfc_sli4_mbox_completions_pending()
8050 /* Check for completions on mailbox completion queue */ in lpfc_sli4_mbox_completions_pending()
8052 mcq = phba->sli4_hba.mbx_cq; in lpfc_sli4_mbox_completions_pending()
8053 idx = mcq->hba_index; in lpfc_sli4_mbox_completions_pending()
8054 qe_valid = mcq->qe_valid; in lpfc_sli4_mbox_completions_pending()
8063 idx = (idx + 1) % mcq->entry_count; in lpfc_sli4_mbox_completions_pending()
8064 if (mcq->hba_index == idx) in lpfc_sli4_mbox_completions_pending()
8068 if (phba->sli4_hba.pc_sli4_params.cqav && !idx) in lpfc_sli4_mbox_completions_pending()
8076 * lpfc_sli4_process_missed_mbox_completions - process mbox completions
8081 * maybe missed causing erroneous mailbox timeouts to occur. This function
8082 * checks to see if mbox completions are on the mailbox completion queue
8084 * mailbox completion queue.
8089 struct lpfc_sli4_hba *sli4_hba = &phba->sli4_hba; in lpfc_sli4_process_missed_mbox_completions()
8095 if (unlikely(!phba) || (phba->sli_rev != LPFC_SLI_REV4)) in lpfc_sli4_process_missed_mbox_completions()
8099 if (sli4_hba->hdwq) { in lpfc_sli4_process_missed_mbox_completions()
8100 for (eqidx = 0; eqidx < phba->cfg_irq_chann; eqidx++) { in lpfc_sli4_process_missed_mbox_completions()
8101 eq = phba->sli4_hba.hba_eq_hdl[eqidx].eq; in lpfc_sli4_process_missed_mbox_completions()
8102 if (eq && eq->queue_id == sli4_hba->mbx_cq->assoc_qid) { in lpfc_sli4_process_missed_mbox_completions()
8113 sli4_hba->sli4_eq_clr_intr(fpeq); in lpfc_sli4_process_missed_mbox_completions()
8122 * mailbox commands, async events, els commands, receive queue data in lpfc_sli4_process_missed_mbox_completions()
8130 /* Always clear and re-arm the EQ */ in lpfc_sli4_process_missed_mbox_completions()
8131 sli4_hba->sli4_write_eq_db(phba, fpeq, 0, LPFC_QUEUE_REARM); in lpfc_sli4_process_missed_mbox_completions()
8138 * lpfc_mbox_timeout_handler - Worker thread function to handle mailbox timeout
8141 * This function is called from worker thread when a mailbox command times out.
8148 LPFC_MBOXQ_t *pmbox = phba->sli.mbox_active; in lpfc_mbox_timeout_handler()
8151 struct lpfc_sli *psli = &phba->sli; in lpfc_mbox_timeout_handler()
8153 /* If the mailbox completed, process the completion and return */ in lpfc_mbox_timeout_handler()
8158 mb = &pmbox->u.mb; in lpfc_mbox_timeout_handler()
8161 * worklist and the mailbox actually completing. When this in lpfc_mbox_timeout_handler()
8164 spin_lock_irq(&phba->hbalock); in lpfc_mbox_timeout_handler()
8168 "0353 Active Mailbox cleared - mailbox timeout " in lpfc_mbox_timeout_handler()
8170 spin_unlock_irq(&phba->hbalock); in lpfc_mbox_timeout_handler()
8176 "0310 Mailbox command x%x timeout Data: x%x x%x x%px\n", in lpfc_mbox_timeout_handler()
8177 mb->mbxCommand, in lpfc_mbox_timeout_handler()
8178 phba->pport->port_state, in lpfc_mbox_timeout_handler()
8179 phba->sli.sli_flag, in lpfc_mbox_timeout_handler()
8180 phba->sli.mbox_active); in lpfc_mbox_timeout_handler()
8181 spin_unlock_irq(&phba->hbalock); in lpfc_mbox_timeout_handler()
8187 spin_lock_irq(&phba->pport->work_port_lock); in lpfc_mbox_timeout_handler()
8188 phba->pport->work_port_events &= ~WORKER_MBOX_TMO; in lpfc_mbox_timeout_handler()
8189 spin_unlock_irq(&phba->pport->work_port_lock); in lpfc_mbox_timeout_handler()
8190 spin_lock_irq(&phba->hbalock); in lpfc_mbox_timeout_handler()
8191 phba->link_state = LPFC_LINK_UNKNOWN; in lpfc_mbox_timeout_handler()
8192 psli->sli_flag &= ~LPFC_SLI_ACTIVE; in lpfc_mbox_timeout_handler()
8193 spin_unlock_irq(&phba->hbalock); in lpfc_mbox_timeout_handler()
8198 "0345 Resetting board due to mailbox timeout\n"); in lpfc_mbox_timeout_handler()
8205 * lpfc_sli_issue_mbox_s3 - Issue an SLI3 mailbox command to firmware
8207 * @pmbox: Pointer to mailbox object.
8208 * @flag: Flag indicating how the mailbox need to be processed.
8211 * to submit a mailbox command to firmware with SLI-3 interface spec. This
8213 * The mailbox command can be submitted in polling mode, in which case
8215 * mailbox.
8216 * If the mailbox is submitted in no_wait mode (not polling) the
8218 * for the mailbox completion. The no_wait is supported only when HBA
8219 * is in SLI2/SLI3 mode - interrupts are enabled.
8220 * The SLI interface allows only one mailbox pending at a time. If the
8221 * mailbox is issued in polling mode and there is already a mailbox
8222 * pending, then the function will return an error. If the mailbox is issued
8223 * in NO_WAIT mode and there is a mailbox pending already, the function
8224 * will return MBX_BUSY after queuing the mailbox into mailbox queue.
8225 * The sli layer owns the mailbox object until the completion of mailbox
8227 * return codes the caller owns the mailbox command after the return of
8235 struct lpfc_sli *psli = &phba->sli; in lpfc_sli_issue_mbox_s3()
8245 spin_lock_irqsave(&phba->hbalock, drvr_flag); in lpfc_sli_issue_mbox_s3()
8247 phba->sli.sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; in lpfc_sli_issue_mbox_s3()
8249 if (unlikely(psli->sli_flag & LPFC_SLI_ASYNC_MBX_BLK)) { in lpfc_sli_issue_mbox_s3()
8250 spin_unlock_irqrestore(&phba->hbalock, drvr_flag); in lpfc_sli_issue_mbox_s3()
8256 spin_unlock_irqrestore(&phba->hbalock, drvr_flag); in lpfc_sli_issue_mbox_s3()
8261 if (pmbox->mbox_cmpl && pmbox->mbox_cmpl != lpfc_sli_def_mbox_cmpl && in lpfc_sli_issue_mbox_s3()
8262 pmbox->mbox_cmpl != lpfc_sli_wake_mbox_wait) { in lpfc_sli_issue_mbox_s3()
8263 if(!pmbox->vport) { in lpfc_sli_issue_mbox_s3()
8264 spin_unlock_irqrestore(&phba->hbalock, drvr_flag); in lpfc_sli_issue_mbox_s3()
8268 pmbox->u.mb.mbxCommand); in lpfc_sli_issue_mbox_s3()
8275 if (unlikely(pci_channel_offline(phba->pcidev))) { in lpfc_sli_issue_mbox_s3()
8276 spin_unlock_irqrestore(&phba->hbalock, drvr_flag); in lpfc_sli_issue_mbox_s3()
8281 if (unlikely(phba->hba_flag & DEFER_ERATT)) { in lpfc_sli_issue_mbox_s3()
8282 spin_unlock_irqrestore(&phba->hbalock, drvr_flag); in lpfc_sli_issue_mbox_s3()
8286 psli = &phba->sli; in lpfc_sli_issue_mbox_s3()
8288 mbx = &pmbox->u.mb; in lpfc_sli_issue_mbox_s3()
8291 if (phba->link_state == LPFC_HBA_ERROR) { in lpfc_sli_issue_mbox_s3()
8292 spin_unlock_irqrestore(&phba->hbalock, drvr_flag); in lpfc_sli_issue_mbox_s3()
8296 "(%d):0311 Mailbox command x%x cannot " in lpfc_sli_issue_mbox_s3()
8298 pmbox->vport ? pmbox->vport->vpi : 0, in lpfc_sli_issue_mbox_s3()
8299 pmbox->u.mb.mbxCommand, psli->sli_flag, flag); in lpfc_sli_issue_mbox_s3()
8303 if (mbx->mbxCommand != MBX_KILL_BOARD && flag & MBX_NOWAIT) { in lpfc_sli_issue_mbox_s3()
8304 if (lpfc_readl(phba->HCregaddr, &hc_copy) || in lpfc_sli_issue_mbox_s3()
8306 spin_unlock_irqrestore(&phba->hbalock, drvr_flag); in lpfc_sli_issue_mbox_s3()
8308 "(%d):2528 Mailbox command x%x cannot " in lpfc_sli_issue_mbox_s3()
8310 pmbox->vport ? pmbox->vport->vpi : 0, in lpfc_sli_issue_mbox_s3()
8311 pmbox->u.mb.mbxCommand, psli->sli_flag, flag); in lpfc_sli_issue_mbox_s3()
8316 if (psli->sli_flag & LPFC_SLI_MBOX_ACTIVE) { in lpfc_sli_issue_mbox_s3()
8323 spin_unlock_irqrestore(&phba->hbalock, drvr_flag); in lpfc_sli_issue_mbox_s3()
8327 "(%d):2529 Mailbox command x%x " in lpfc_sli_issue_mbox_s3()
8329 pmbox->vport ? pmbox->vport->vpi : 0, in lpfc_sli_issue_mbox_s3()
8330 pmbox->u.mb.mbxCommand, in lpfc_sli_issue_mbox_s3()
8331 psli->sli_flag, flag); in lpfc_sli_issue_mbox_s3()
8335 if (!(psli->sli_flag & LPFC_SLI_ACTIVE)) { in lpfc_sli_issue_mbox_s3()
8336 spin_unlock_irqrestore(&phba->hbalock, drvr_flag); in lpfc_sli_issue_mbox_s3()
8339 "(%d):2530 Mailbox command x%x " in lpfc_sli_issue_mbox_s3()
8341 pmbox->vport ? pmbox->vport->vpi : 0, in lpfc_sli_issue_mbox_s3()
8342 pmbox->u.mb.mbxCommand, in lpfc_sli_issue_mbox_s3()
8343 psli->sli_flag, flag); in lpfc_sli_issue_mbox_s3()
8347 /* Another mailbox command is still being processed, queue this in lpfc_sli_issue_mbox_s3()
8352 /* Mbox cmd issue - BUSY */ in lpfc_sli_issue_mbox_s3()
8354 "(%d):0308 Mbox cmd issue - BUSY Data: " in lpfc_sli_issue_mbox_s3()
8356 pmbox->vport ? pmbox->vport->vpi : 0xffffff, in lpfc_sli_issue_mbox_s3()
8357 mbx->mbxCommand, in lpfc_sli_issue_mbox_s3()
8358 phba->pport ? phba->pport->port_state : 0xff, in lpfc_sli_issue_mbox_s3()
8359 psli->sli_flag, flag); in lpfc_sli_issue_mbox_s3()
8361 psli->slistat.mbox_busy++; in lpfc_sli_issue_mbox_s3()
8362 spin_unlock_irqrestore(&phba->hbalock, drvr_flag); in lpfc_sli_issue_mbox_s3()
8364 if (pmbox->vport) { in lpfc_sli_issue_mbox_s3()
8365 lpfc_debugfs_disc_trc(pmbox->vport, in lpfc_sli_issue_mbox_s3()
8368 (uint32_t)mbx->mbxCommand, in lpfc_sli_issue_mbox_s3()
8369 mbx->un.varWords[0], mbx->un.varWords[1]); in lpfc_sli_issue_mbox_s3()
8372 lpfc_debugfs_disc_trc(phba->pport, in lpfc_sli_issue_mbox_s3()
8375 (uint32_t)mbx->mbxCommand, in lpfc_sli_issue_mbox_s3()
8376 mbx->un.varWords[0], mbx->un.varWords[1]); in lpfc_sli_issue_mbox_s3()
8382 psli->sli_flag |= LPFC_SLI_MBOX_ACTIVE; in lpfc_sli_issue_mbox_s3()
8386 if (!(psli->sli_flag & LPFC_SLI_ACTIVE) && in lpfc_sli_issue_mbox_s3()
8387 (mbx->mbxCommand != MBX_KILL_BOARD)) { in lpfc_sli_issue_mbox_s3()
8388 psli->sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; in lpfc_sli_issue_mbox_s3()
8389 spin_unlock_irqrestore(&phba->hbalock, drvr_flag); in lpfc_sli_issue_mbox_s3()
8392 "(%d):2531 Mailbox command x%x " in lpfc_sli_issue_mbox_s3()
8394 pmbox->vport ? pmbox->vport->vpi : 0, in lpfc_sli_issue_mbox_s3()
8395 pmbox->u.mb.mbxCommand, in lpfc_sli_issue_mbox_s3()
8396 psli->sli_flag, flag); in lpfc_sli_issue_mbox_s3()
8402 mod_timer(&psli->mbox_tmo, jiffies + timeout); in lpfc_sli_issue_mbox_s3()
8405 /* Mailbox cmd <cmd> issue */ in lpfc_sli_issue_mbox_s3()
8407 "(%d):0309 Mailbox cmd x%x issue Data: x%x x%x " in lpfc_sli_issue_mbox_s3()
8409 pmbox->vport ? pmbox->vport->vpi : 0, in lpfc_sli_issue_mbox_s3()
8410 mbx->mbxCommand, in lpfc_sli_issue_mbox_s3()
8411 phba->pport ? phba->pport->port_state : 0xff, in lpfc_sli_issue_mbox_s3()
8412 psli->sli_flag, flag); in lpfc_sli_issue_mbox_s3()
8414 if (mbx->mbxCommand != MBX_HEARTBEAT) { in lpfc_sli_issue_mbox_s3()
8415 if (pmbox->vport) { in lpfc_sli_issue_mbox_s3()
8416 lpfc_debugfs_disc_trc(pmbox->vport, in lpfc_sli_issue_mbox_s3()
8419 (uint32_t)mbx->mbxCommand, in lpfc_sli_issue_mbox_s3()
8420 mbx->un.varWords[0], mbx->un.varWords[1]); in lpfc_sli_issue_mbox_s3()
8423 lpfc_debugfs_disc_trc(phba->pport, in lpfc_sli_issue_mbox_s3()
8426 (uint32_t)mbx->mbxCommand, in lpfc_sli_issue_mbox_s3()
8427 mbx->un.varWords[0], mbx->un.varWords[1]); in lpfc_sli_issue_mbox_s3()
8431 psli->slistat.mbox_cmd++; in lpfc_sli_issue_mbox_s3()
8432 evtctr = psli->slistat.mbox_event; in lpfc_sli_issue_mbox_s3()
8435 mbx->mbxOwner = OWN_CHIP; in lpfc_sli_issue_mbox_s3()
8437 if (psli->sli_flag & LPFC_SLI_ACTIVE) { in lpfc_sli_issue_mbox_s3()
8439 if (pmbox->in_ext_byte_len || pmbox->out_ext_byte_len) { in lpfc_sli_issue_mbox_s3()
8440 *(((uint32_t *)mbx) + pmbox->mbox_offset_word) in lpfc_sli_issue_mbox_s3()
8441 = (uint8_t *)phba->mbox_ext in lpfc_sli_issue_mbox_s3()
8442 - (uint8_t *)phba->mbox; in lpfc_sli_issue_mbox_s3()
8445 /* Copy the mailbox extension data */ in lpfc_sli_issue_mbox_s3()
8446 if (pmbox->in_ext_byte_len && pmbox->ctx_buf) { in lpfc_sli_issue_mbox_s3()
8447 lpfc_sli_pcimem_bcopy(pmbox->ctx_buf, in lpfc_sli_issue_mbox_s3()
8448 (uint8_t *)phba->mbox_ext, in lpfc_sli_issue_mbox_s3()
8449 pmbox->in_ext_byte_len); in lpfc_sli_issue_mbox_s3()
8452 lpfc_sli_pcimem_bcopy(mbx, phba->mbox, MAILBOX_CMD_SIZE); in lpfc_sli_issue_mbox_s3()
8455 if (pmbox->in_ext_byte_len || pmbox->out_ext_byte_len) in lpfc_sli_issue_mbox_s3()
8456 *(((uint32_t *)mbx) + pmbox->mbox_offset_word) in lpfc_sli_issue_mbox_s3()
8459 /* Copy the mailbox extension data */ in lpfc_sli_issue_mbox_s3()
8460 if (pmbox->in_ext_byte_len && pmbox->ctx_buf) in lpfc_sli_issue_mbox_s3()
8461 lpfc_memcpy_to_slim(phba->MBslimaddr + in lpfc_sli_issue_mbox_s3()
8463 pmbox->ctx_buf, pmbox->in_ext_byte_len); in lpfc_sli_issue_mbox_s3()
8465 if (mbx->mbxCommand == MBX_CONFIG_PORT) in lpfc_sli_issue_mbox_s3()
8467 lpfc_sli_pcimem_bcopy(mbx, phba->mbox, in lpfc_sli_issue_mbox_s3()
8472 to_slim = phba->MBslimaddr + sizeof (uint32_t); in lpfc_sli_issue_mbox_s3()
8473 lpfc_memcpy_to_slim(to_slim, &mbx->un.varWords[0], in lpfc_sli_issue_mbox_s3()
8474 MAILBOX_CMD_SIZE - sizeof (uint32_t)); in lpfc_sli_issue_mbox_s3()
8478 to_slim = phba->MBslimaddr; in lpfc_sli_issue_mbox_s3()
8482 if (mbx->mbxCommand == MBX_CONFIG_PORT) in lpfc_sli_issue_mbox_s3()
8483 /* switch over to host mailbox */ in lpfc_sli_issue_mbox_s3()
8484 psli->sli_flag |= LPFC_SLI_ACTIVE; in lpfc_sli_issue_mbox_s3()
8491 /* Set up reference to mailbox command */ in lpfc_sli_issue_mbox_s3()
8492 psli->mbox_active = pmbox; in lpfc_sli_issue_mbox_s3()
8494 writel(CA_MBATT, phba->CAregaddr); in lpfc_sli_issue_mbox_s3()
8495 readl(phba->CAregaddr); /* flush */ in lpfc_sli_issue_mbox_s3()
8500 /* Set up null reference to mailbox command */ in lpfc_sli_issue_mbox_s3()
8501 psli->mbox_active = NULL; in lpfc_sli_issue_mbox_s3()
8503 writel(CA_MBATT, phba->CAregaddr); in lpfc_sli_issue_mbox_s3()
8504 readl(phba->CAregaddr); /* flush */ in lpfc_sli_issue_mbox_s3()
8506 if (psli->sli_flag & LPFC_SLI_ACTIVE) { in lpfc_sli_issue_mbox_s3()
8508 word0 = *((uint32_t *)phba->mbox); in lpfc_sli_issue_mbox_s3()
8512 if (lpfc_readl(phba->MBslimaddr, &word0)) { in lpfc_sli_issue_mbox_s3()
8513 spin_unlock_irqrestore(&phba->hbalock, in lpfc_sli_issue_mbox_s3()
8520 if (lpfc_readl(phba->HAregaddr, &ha_copy)) { in lpfc_sli_issue_mbox_s3()
8521 spin_unlock_irqrestore(&phba->hbalock, in lpfc_sli_issue_mbox_s3()
8531 (phba->link_state > LPFC_WARM_START))) { in lpfc_sli_issue_mbox_s3()
8533 psli->sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; in lpfc_sli_issue_mbox_s3()
8534 spin_unlock_irqrestore(&phba->hbalock, in lpfc_sli_issue_mbox_s3()
8542 && (evtctr != psli->slistat.mbox_event)) in lpfc_sli_issue_mbox_s3()
8546 spin_unlock_irqrestore(&phba->hbalock, in lpfc_sli_issue_mbox_s3()
8549 spin_lock_irqsave(&phba->hbalock, drvr_flag); in lpfc_sli_issue_mbox_s3()
8552 if (psli->sli_flag & LPFC_SLI_ACTIVE) { in lpfc_sli_issue_mbox_s3()
8554 word0 = *((uint32_t *)phba->mbox); in lpfc_sli_issue_mbox_s3()
8556 if (mbx->mbxCommand == MBX_CONFIG_PORT) { in lpfc_sli_issue_mbox_s3()
8560 slimword0 = readl(phba->MBslimaddr); in lpfc_sli_issue_mbox_s3()
8563 && slimmb->mbxStatus) { in lpfc_sli_issue_mbox_s3()
8564 psli->sli_flag &= in lpfc_sli_issue_mbox_s3()
8571 word0 = readl(phba->MBslimaddr); in lpfc_sli_issue_mbox_s3()
8574 if (lpfc_readl(phba->HAregaddr, &ha_copy)) { in lpfc_sli_issue_mbox_s3()
8575 spin_unlock_irqrestore(&phba->hbalock, in lpfc_sli_issue_mbox_s3()
8581 if (psli->sli_flag & LPFC_SLI_ACTIVE) { in lpfc_sli_issue_mbox_s3()
8583 lpfc_sli_pcimem_bcopy(phba->mbox, mbx, in lpfc_sli_issue_mbox_s3()
8585 /* Copy the mailbox extension data */ in lpfc_sli_issue_mbox_s3()
8586 if (pmbox->out_ext_byte_len && pmbox->ctx_buf) { in lpfc_sli_issue_mbox_s3()
8587 lpfc_sli_pcimem_bcopy(phba->mbox_ext, in lpfc_sli_issue_mbox_s3()
8588 pmbox->ctx_buf, in lpfc_sli_issue_mbox_s3()
8589 pmbox->out_ext_byte_len); in lpfc_sli_issue_mbox_s3()
8593 lpfc_memcpy_from_slim(mbx, phba->MBslimaddr, in lpfc_sli_issue_mbox_s3()
8595 /* Copy the mailbox extension data */ in lpfc_sli_issue_mbox_s3()
8596 if (pmbox->out_ext_byte_len && pmbox->ctx_buf) { in lpfc_sli_issue_mbox_s3()
8598 pmbox->ctx_buf, in lpfc_sli_issue_mbox_s3()
8599 phba->MBslimaddr + in lpfc_sli_issue_mbox_s3()
8601 pmbox->out_ext_byte_len); in lpfc_sli_issue_mbox_s3()
8605 writel(HA_MBATT, phba->HAregaddr); in lpfc_sli_issue_mbox_s3()
8606 readl(phba->HAregaddr); /* flush */ in lpfc_sli_issue_mbox_s3()
8608 psli->sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; in lpfc_sli_issue_mbox_s3()
8609 status = mbx->mbxStatus; in lpfc_sli_issue_mbox_s3()
8612 spin_unlock_irqrestore(&phba->hbalock, drvr_flag); in lpfc_sli_issue_mbox_s3()
8617 pmbox->u.mb.mbxStatus = MBX_NOT_FINISHED; in lpfc_sli_issue_mbox_s3()
8624 * lpfc_sli4_async_mbox_block - Block posting SLI4 asynchronous mailbox command
8627 * The function blocks the posting of SLI4 asynchronous mailbox commands from
8628 * the driver internal pending mailbox queue. It will then try to wait out the
8629 * possible outstanding mailbox command before return.
8632 * 0 - the outstanding mailbox command completed; otherwise, the wait for
8633 * the outstanding mailbox command timed out.
8638 struct lpfc_sli *psli = &phba->sli; in lpfc_sli4_async_mbox_block()
8642 /* Mark the asynchronous mailbox command posting as blocked */ in lpfc_sli4_async_mbox_block()
8643 spin_lock_irq(&phba->hbalock); in lpfc_sli4_async_mbox_block()
8644 psli->sli_flag |= LPFC_SLI_ASYNC_MBX_BLK; in lpfc_sli4_async_mbox_block()
8645 /* Determine how long we might wait for the active mailbox in lpfc_sli4_async_mbox_block()
8648 if (phba->sli.mbox_active) in lpfc_sli4_async_mbox_block()
8650 phba->sli.mbox_active) * in lpfc_sli4_async_mbox_block()
8652 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_mbox_block()
8654 /* Make sure the mailbox is really active */ in lpfc_sli4_async_mbox_block()
8658 /* Wait for the outstnading mailbox command to complete */ in lpfc_sli4_async_mbox_block()
8659 while (phba->sli.mbox_active) { in lpfc_sli4_async_mbox_block()
8660 /* Check active mailbox complete status every 2ms */ in lpfc_sli4_async_mbox_block()
8669 /* Can not cleanly block async mailbox command, fails it */ in lpfc_sli4_async_mbox_block()
8671 spin_lock_irq(&phba->hbalock); in lpfc_sli4_async_mbox_block()
8672 psli->sli_flag &= ~LPFC_SLI_ASYNC_MBX_BLK; in lpfc_sli4_async_mbox_block()
8673 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_mbox_block()
8679 * lpfc_sli4_async_mbox_unblock - Block posting SLI4 async mailbox command
8682 * The function unblocks and resume posting of SLI4 asynchronous mailbox
8683 * commands from the driver internal pending mailbox queue. It makes sure
8684 * that there is no outstanding mailbox command before resuming posting
8685 * asynchronous mailbox commands. If, for any reason, there is outstanding
8686 * mailbox command, it will try to wait it out before resuming asynchronous
8687 * mailbox command posting.
8692 struct lpfc_sli *psli = &phba->sli; in lpfc_sli4_async_mbox_unblock()
8694 spin_lock_irq(&phba->hbalock); in lpfc_sli4_async_mbox_unblock()
8695 if (!(psli->sli_flag & LPFC_SLI_ASYNC_MBX_BLK)) { in lpfc_sli4_async_mbox_unblock()
8696 /* Asynchronous mailbox posting is not blocked, do nothing */ in lpfc_sli4_async_mbox_unblock()
8697 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_mbox_unblock()
8701 /* Outstanding synchronous mailbox command is guaranteed to be done, in lpfc_sli4_async_mbox_unblock()
8702 * successful or timeout, after timing-out the outstanding mailbox in lpfc_sli4_async_mbox_unblock()
8704 * mailbox command and resume in lpfc_sli4_async_mbox_unblock()
8706 psli->sli_flag &= ~LPFC_SLI_ASYNC_MBX_BLK; in lpfc_sli4_async_mbox_unblock()
8707 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_mbox_unblock()
8709 /* wake up worker thread to post asynchronous mailbox command */ in lpfc_sli4_async_mbox_unblock()
8714 * lpfc_sli4_wait_bmbx_ready - Wait for bootstrap mailbox register ready
8716 * @mboxq: Pointer to mailbox object.
8718 * The function waits for the bootstrap mailbox register ready bit from
8719 * port for twice the regular mailbox command timeout value.
8721 * 0 - no timeout on waiting for bootstrap mailbox register ready.
8722 * MBXERR_ERROR - wait for bootstrap mailbox register timed out.
8735 bmbx_reg.word0 = readl(phba->sli4_hba.BMBXregaddr); in lpfc_sli4_wait_bmbx_ready()
8748 * lpfc_sli4_post_sync_mbox - Post an SLI4 mailbox to the bootstrap mailbox
8750 * @mboxq: Pointer to mailbox object.
8752 * The function posts a mailbox to the port. The mailbox is expected
8755 * mailbox by polling for its completion.
8760 * MBX_SUCCESS - mailbox posted successfully
8770 struct lpfc_sli *psli = &phba->sli; in lpfc_sli4_post_sync_mbox()
8771 struct lpfc_mqe *mb = &mboxq->u.mqe; in lpfc_sli4_post_sync_mbox()
8776 * Only one mailbox can be active to the bootstrap mailbox region in lpfc_sli4_post_sync_mbox()
8779 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli4_post_sync_mbox()
8780 if (psli->sli_flag & LPFC_SLI_MBOX_ACTIVE) { in lpfc_sli4_post_sync_mbox()
8781 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli4_post_sync_mbox()
8783 "(%d):2532 Mailbox command x%x (x%x/x%x) " in lpfc_sli4_post_sync_mbox()
8785 mboxq->vport ? mboxq->vport->vpi : 0, in lpfc_sli4_post_sync_mbox()
8786 mboxq->u.mb.mbxCommand, in lpfc_sli4_post_sync_mbox()
8789 psli->sli_flag, MBX_POLL); in lpfc_sli4_post_sync_mbox()
8793 psli->sli_flag |= LPFC_SLI_MBOX_ACTIVE; in lpfc_sli4_post_sync_mbox()
8794 phba->sli.mbox_active = mboxq; in lpfc_sli4_post_sync_mbox()
8795 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli4_post_sync_mbox()
8803 * in the mailbox post. Then copy the caller's mailbox contents to in lpfc_sli4_post_sync_mbox()
8804 * the bmbx mailbox region. in lpfc_sli4_post_sync_mbox()
8807 memset(phba->sli4_hba.bmbx.avirt, 0, sizeof(struct lpfc_bmbx_create)); in lpfc_sli4_post_sync_mbox()
8808 lpfc_sli4_pcimem_bcopy(mb, phba->sli4_hba.bmbx.avirt, in lpfc_sli4_post_sync_mbox()
8811 /* Post the high mailbox dma address to the port and wait for ready. */ in lpfc_sli4_post_sync_mbox()
8812 dma_address = &phba->sli4_hba.bmbx.dma_address; in lpfc_sli4_post_sync_mbox()
8813 writel(dma_address->addr_hi, phba->sli4_hba.BMBXregaddr); in lpfc_sli4_post_sync_mbox()
8815 /* wait for bootstrap mbox register for hi-address write done */ in lpfc_sli4_post_sync_mbox()
8820 /* Post the low mailbox dma address to the port. */ in lpfc_sli4_post_sync_mbox()
8821 writel(dma_address->addr_lo, phba->sli4_hba.BMBXregaddr); in lpfc_sli4_post_sync_mbox()
8829 * Read the CQ to ensure the mailbox has completed. in lpfc_sli4_post_sync_mbox()
8830 * If so, update the mailbox status so that the upper layers in lpfc_sli4_post_sync_mbox()
8833 lpfc_sli4_pcimem_bcopy(phba->sli4_hba.bmbx.avirt, mb, in lpfc_sli4_post_sync_mbox()
8835 mbox_rgn = (struct lpfc_bmbx_create *) phba->sli4_hba.bmbx.avirt; in lpfc_sli4_post_sync_mbox()
8836 lpfc_sli4_pcimem_bcopy(&mbox_rgn->mcqe, &mboxq->mcqe, in lpfc_sli4_post_sync_mbox()
8838 mcqe_status = bf_get(lpfc_mcqe_status, &mbox_rgn->mcqe); in lpfc_sli4_post_sync_mbox()
8840 * When the CQE status indicates a failure and the mailbox status in lpfc_sli4_post_sync_mbox()
8841 * indicates success then copy the CQE status into the mailbox status in lpfc_sli4_post_sync_mbox()
8853 "(%d):0356 Mailbox cmd x%x (x%x/x%x) Status x%x " in lpfc_sli4_post_sync_mbox()
8856 mboxq->vport ? mboxq->vport->vpi : 0, mbx_cmnd, in lpfc_sli4_post_sync_mbox()
8860 mb->un.mb_words[0], mb->un.mb_words[1], in lpfc_sli4_post_sync_mbox()
8861 mb->un.mb_words[2], mb->un.mb_words[3], in lpfc_sli4_post_sync_mbox()
8862 mb->un.mb_words[4], mb->un.mb_words[5], in lpfc_sli4_post_sync_mbox()
8863 mb->un.mb_words[6], mb->un.mb_words[7], in lpfc_sli4_post_sync_mbox()
8864 mb->un.mb_words[8], mb->un.mb_words[9], in lpfc_sli4_post_sync_mbox()
8865 mb->un.mb_words[10], mb->un.mb_words[11], in lpfc_sli4_post_sync_mbox()
8866 mb->un.mb_words[12], mboxq->mcqe.word0, in lpfc_sli4_post_sync_mbox()
8867 mboxq->mcqe.mcqe_tag0, mboxq->mcqe.mcqe_tag1, in lpfc_sli4_post_sync_mbox()
8868 mboxq->mcqe.trailer); in lpfc_sli4_post_sync_mbox()
8871 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli4_post_sync_mbox()
8872 psli->sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; in lpfc_sli4_post_sync_mbox()
8873 phba->sli.mbox_active = NULL; in lpfc_sli4_post_sync_mbox()
8874 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli4_post_sync_mbox()
8879 * lpfc_sli_issue_mbox_s4 - Issue an SLI4 mailbox command to firmware
8881 * @mboxq: Pointer to mailbox object.
8882 * @flag: Flag indicating how the mailbox need to be processed.
8885 * a mailbox command to firmware with SLI-4 interface spec.
8887 * Return codes the caller owns the mailbox command after the return of the
8894 struct lpfc_sli *psli = &phba->sli; in lpfc_sli_issue_mbox_s4()
8898 /* dump from issue mailbox command if setup */ in lpfc_sli_issue_mbox_s4()
8899 lpfc_idiag_mbxacc_dump_issue_mbox(phba, &mboxq->u.mb); in lpfc_sli_issue_mbox_s4()
8904 "(%d):2544 Mailbox command x%x (x%x/x%x) " in lpfc_sli_issue_mbox_s4()
8906 mboxq->vport ? mboxq->vport->vpi : 0, in lpfc_sli_issue_mbox_s4()
8907 mboxq->u.mb.mbxCommand, in lpfc_sli_issue_mbox_s4()
8910 psli->sli_flag, flag); in lpfc_sli_issue_mbox_s4()
8915 if (!phba->sli4_hba.intr_enable) { in lpfc_sli_issue_mbox_s4()
8919 rc = -EIO; in lpfc_sli_issue_mbox_s4()
8922 "(%d):2541 Mailbox command x%x " in lpfc_sli_issue_mbox_s4()
8926 mboxq->vport ? mboxq->vport->vpi : 0, in lpfc_sli_issue_mbox_s4()
8927 mboxq->u.mb.mbxCommand, in lpfc_sli_issue_mbox_s4()
8932 bf_get(lpfc_mqe_status, &mboxq->u.mqe), in lpfc_sli_issue_mbox_s4()
8933 bf_get(lpfc_mcqe_status, &mboxq->mcqe), in lpfc_sli_issue_mbox_s4()
8935 &mboxq->mcqe), in lpfc_sli_issue_mbox_s4()
8936 psli->sli_flag, flag); in lpfc_sli_issue_mbox_s4()
8940 "(%d):2542 Try to issue mailbox command " in lpfc_sli_issue_mbox_s4()
8942 "mailbox command queue: x%x x%x\n", in lpfc_sli_issue_mbox_s4()
8943 mboxq->vport ? mboxq->vport->vpi : 0, in lpfc_sli_issue_mbox_s4()
8944 mboxq->u.mb.mbxCommand, in lpfc_sli_issue_mbox_s4()
8947 psli->sli_flag, flag); in lpfc_sli_issue_mbox_s4()
8948 /* Try to block the asynchronous mailbox posting */ in lpfc_sli_issue_mbox_s4()
8956 "(%d):2597 Sync Mailbox command " in lpfc_sli_issue_mbox_s4()
8960 mboxq->vport ? mboxq->vport->vpi : 0, in lpfc_sli_issue_mbox_s4()
8961 mboxq->u.mb.mbxCommand, in lpfc_sli_issue_mbox_s4()
8966 bf_get(lpfc_mqe_status, &mboxq->u.mqe), in lpfc_sli_issue_mbox_s4()
8967 bf_get(lpfc_mcqe_status, &mboxq->mcqe), in lpfc_sli_issue_mbox_s4()
8969 &mboxq->mcqe), in lpfc_sli_issue_mbox_s4()
8970 psli->sli_flag, flag); in lpfc_sli_issue_mbox_s4()
8971 /* Unblock the async mailbox posting afterward */ in lpfc_sli_issue_mbox_s4()
8977 /* Now, interrupt mode asynchronous mailbox command */ in lpfc_sli_issue_mbox_s4()
8981 "(%d):2543 Mailbox command x%x (x%x/x%x) " in lpfc_sli_issue_mbox_s4()
8983 mboxq->vport ? mboxq->vport->vpi : 0, in lpfc_sli_issue_mbox_s4()
8984 mboxq->u.mb.mbxCommand, in lpfc_sli_issue_mbox_s4()
8987 psli->sli_flag, flag); in lpfc_sli_issue_mbox_s4()
8991 /* Put the mailbox command to the driver internal FIFO */ in lpfc_sli_issue_mbox_s4()
8992 psli->slistat.mbox_busy++; in lpfc_sli_issue_mbox_s4()
8993 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli_issue_mbox_s4()
8995 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli_issue_mbox_s4()
8997 "(%d):0354 Mbox cmd issue - Enqueue Data: " in lpfc_sli_issue_mbox_s4()
8999 mboxq->vport ? mboxq->vport->vpi : 0xffffff, in lpfc_sli_issue_mbox_s4()
9000 bf_get(lpfc_mqe_command, &mboxq->u.mqe), in lpfc_sli_issue_mbox_s4()
9003 phba->pport->port_state, in lpfc_sli_issue_mbox_s4()
9004 psli->sli_flag, MBX_NOWAIT); in lpfc_sli_issue_mbox_s4()
9005 /* Wake up worker thread to transport mailbox command from head */ in lpfc_sli_issue_mbox_s4()
9015 * lpfc_sli4_post_async_mbox - Post an SLI4 mailbox command to device
9018 * This function is called by worker thread to send a mailbox command to
9025 struct lpfc_sli *psli = &phba->sli; in lpfc_sli4_post_async_mbox()
9032 /* Check interrupt mode before post async mailbox command */ in lpfc_sli4_post_async_mbox()
9033 if (unlikely(!phba->sli4_hba.intr_enable)) in lpfc_sli4_post_async_mbox()
9036 /* Check for mailbox command service token */ in lpfc_sli4_post_async_mbox()
9037 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_post_async_mbox()
9038 if (unlikely(psli->sli_flag & LPFC_SLI_ASYNC_MBX_BLK)) { in lpfc_sli4_post_async_mbox()
9039 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_post_async_mbox()
9042 if (psli->sli_flag & LPFC_SLI_MBOX_ACTIVE) { in lpfc_sli4_post_async_mbox()
9043 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_post_async_mbox()
9046 if (unlikely(phba->sli.mbox_active)) { in lpfc_sli4_post_async_mbox()
9047 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_post_async_mbox()
9049 "0384 There is pending active mailbox cmd\n"); in lpfc_sli4_post_async_mbox()
9052 /* Take the mailbox command service token */ in lpfc_sli4_post_async_mbox()
9053 psli->sli_flag |= LPFC_SLI_MBOX_ACTIVE; in lpfc_sli4_post_async_mbox()
9055 /* Get the next mailbox command from head of queue */ in lpfc_sli4_post_async_mbox()
9058 /* If no more mailbox command waiting for post, we're done */ in lpfc_sli4_post_async_mbox()
9060 psli->sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; in lpfc_sli4_post_async_mbox()
9061 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_post_async_mbox()
9064 phba->sli.mbox_active = mboxq; in lpfc_sli4_post_async_mbox()
9065 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_post_async_mbox()
9067 /* Check device readiness for posting mailbox command */ in lpfc_sli4_post_async_mbox()
9070 /* Driver clean routine will clean up pending mailbox */ in lpfc_sli4_post_async_mbox()
9074 mqe = &mboxq->u.mqe; in lpfc_sli4_post_async_mbox()
9077 /* Start timer for the mbox_tmo and log some mailbox post messages */ in lpfc_sli4_post_async_mbox()
9078 mod_timer(&psli->mbox_tmo, (jiffies + in lpfc_sli4_post_async_mbox()
9082 "(%d):0355 Mailbox cmd x%x (x%x/x%x) issue Data: " in lpfc_sli4_post_async_mbox()
9084 mboxq->vport ? mboxq->vport->vpi : 0, mbx_cmnd, in lpfc_sli4_post_async_mbox()
9087 phba->pport->port_state, psli->sli_flag); in lpfc_sli4_post_async_mbox()
9090 if (mboxq->vport) { in lpfc_sli4_post_async_mbox()
9091 lpfc_debugfs_disc_trc(mboxq->vport, in lpfc_sli4_post_async_mbox()
9094 mbx_cmnd, mqe->un.mb_words[0], in lpfc_sli4_post_async_mbox()
9095 mqe->un.mb_words[1]); in lpfc_sli4_post_async_mbox()
9097 lpfc_debugfs_disc_trc(phba->pport, in lpfc_sli4_post_async_mbox()
9100 mbx_cmnd, mqe->un.mb_words[0], in lpfc_sli4_post_async_mbox()
9101 mqe->un.mb_words[1]); in lpfc_sli4_post_async_mbox()
9104 psli->slistat.mbox_cmd++; in lpfc_sli4_post_async_mbox()
9106 /* Post the mailbox command to the port */ in lpfc_sli4_post_async_mbox()
9107 rc = lpfc_sli4_mq_put(phba->sli4_hba.mbx_wq, mqe); in lpfc_sli4_post_async_mbox()
9110 "(%d):2533 Mailbox command x%x (x%x/x%x) " in lpfc_sli4_post_async_mbox()
9112 mboxq->vport ? mboxq->vport->vpi : 0, in lpfc_sli4_post_async_mbox()
9113 mboxq->u.mb.mbxCommand, in lpfc_sli4_post_async_mbox()
9116 psli->sli_flag, MBX_NOWAIT); in lpfc_sli4_post_async_mbox()
9123 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_post_async_mbox()
9124 if (phba->sli.mbox_active) { in lpfc_sli4_post_async_mbox()
9125 mboxq->u.mb.mbxStatus = MBX_NOT_FINISHED; in lpfc_sli4_post_async_mbox()
9128 psli->sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; in lpfc_sli4_post_async_mbox()
9129 phba->sli.mbox_active = NULL; in lpfc_sli4_post_async_mbox()
9131 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_post_async_mbox()
9137 * lpfc_sli_issue_mbox - Wrapper func for issuing mailbox command
9139 * @pmbox: Pointer to mailbox object.
9140 * @flag: Flag indicating how the mailbox need to be processed.
9142 * This routine wraps the actual SLI3 or SLI4 mailbox issuing routine from
9145 * Return codes the caller owns the mailbox command after the return of the
9151 return phba->lpfc_sli_issue_mbox(phba, pmbox, flag); in lpfc_sli_issue_mbox()
9155 * lpfc_mbox_api_table_setup - Set up mbox api function jump table
9157 * @dev_grp: The HBA PCI-Device group number.
9161 * Returns: 0 - success, -ENODEV - failure.
9169 phba->lpfc_sli_issue_mbox = lpfc_sli_issue_mbox_s3; in lpfc_mbox_api_table_setup()
9170 phba->lpfc_sli_handle_slow_ring_event = in lpfc_mbox_api_table_setup()
9172 phba->lpfc_sli_hbq_to_firmware = lpfc_sli_hbq_to_firmware_s3; in lpfc_mbox_api_table_setup()
9173 phba->lpfc_sli_brdrestart = lpfc_sli_brdrestart_s3; in lpfc_mbox_api_table_setup()
9174 phba->lpfc_sli_brdready = lpfc_sli_brdready_s3; in lpfc_mbox_api_table_setup()
9177 phba->lpfc_sli_issue_mbox = lpfc_sli_issue_mbox_s4; in lpfc_mbox_api_table_setup()
9178 phba->lpfc_sli_handle_slow_ring_event = in lpfc_mbox_api_table_setup()
9180 phba->lpfc_sli_hbq_to_firmware = lpfc_sli_hbq_to_firmware_s4; in lpfc_mbox_api_table_setup()
9181 phba->lpfc_sli_brdrestart = lpfc_sli_brdrestart_s4; in lpfc_mbox_api_table_setup()
9182 phba->lpfc_sli_brdready = lpfc_sli_brdready_s4; in lpfc_mbox_api_table_setup()
9186 "1420 Invalid HBA PCI-device group: 0x%x\n", in lpfc_mbox_api_table_setup()
9188 return -ENODEV; in lpfc_mbox_api_table_setup()
9195 * __lpfc_sli_ringtx_put - Add an iocb to the txq
9209 if (phba->sli_rev == LPFC_SLI_REV4) in __lpfc_sli_ringtx_put()
9210 lockdep_assert_held(&pring->ring_lock); in __lpfc_sli_ringtx_put()
9212 lockdep_assert_held(&phba->hbalock); in __lpfc_sli_ringtx_put()
9214 list_add_tail(&piocb->list, &pring->txq); in __lpfc_sli_ringtx_put()
9218 * lpfc_sli_next_iocb - Get the next iocb in the txq
9240 lockdep_assert_held(&phba->hbalock); in lpfc_sli_next_iocb()
9252 * __lpfc_sli_issue_iocb_s3 - SLI3 device lockless ver of lpfc_sli_issue_iocb
9259 * an iocb command to an HBA with SLI-3 interface spec. If the PCI slot is
9279 struct lpfc_sli_ring *pring = &phba->sli.sli3_ring[ring_number]; in __lpfc_sli_issue_iocb_s3()
9281 lockdep_assert_held(&phba->hbalock); in __lpfc_sli_issue_iocb_s3()
9283 if (piocb->iocb_cmpl && (!piocb->vport) && in __lpfc_sli_issue_iocb_s3()
9284 (piocb->iocb.ulpCommand != CMD_ABORT_XRI_CN) && in __lpfc_sli_issue_iocb_s3()
9285 (piocb->iocb.ulpCommand != CMD_CLOSE_XRI_CN)) { in __lpfc_sli_issue_iocb_s3()
9288 piocb->iocb.ulpCommand); in __lpfc_sli_issue_iocb_s3()
9295 if (unlikely(pci_channel_offline(phba->pcidev))) in __lpfc_sli_issue_iocb_s3()
9299 if (unlikely(phba->hba_flag & DEFER_ERATT)) in __lpfc_sli_issue_iocb_s3()
9305 if (unlikely(phba->link_state < LPFC_LINK_DOWN)) in __lpfc_sli_issue_iocb_s3()
9312 if (unlikely(pring->flag & LPFC_STOP_IOCB_EVENT)) in __lpfc_sli_issue_iocb_s3()
9315 if (unlikely(phba->link_state == LPFC_LINK_DOWN)) { in __lpfc_sli_issue_iocb_s3()
9320 switch (piocb->iocb.ulpCommand) { in __lpfc_sli_issue_iocb_s3()
9323 if (!(phba->sli.sli_flag & LPFC_MENLO_MAINT) || in __lpfc_sli_issue_iocb_s3()
9324 (piocb->iocb.un.genreq64.w5.hcsw.Rctl != in __lpfc_sli_issue_iocb_s3()
9326 (piocb->iocb.un.genreq64.w5.hcsw.Type != in __lpfc_sli_issue_iocb_s3()
9337 if (piocb->iocb_cmpl) in __lpfc_sli_issue_iocb_s3()
9338 piocb->iocb_cmpl = NULL; in __lpfc_sli_issue_iocb_s3()
9352 } else if (unlikely(pring->ringno == LPFC_FCP_RING && in __lpfc_sli_issue_iocb_s3()
9353 !(phba->sli.sli_flag & LPFC_PROCESS_LA))) { in __lpfc_sli_issue_iocb_s3()
9372 pring->stats.iocb_cmd_delay++; in __lpfc_sli_issue_iocb_s3()
9385 * lpfc_sli4_bpl2sgl - Convert the bpl/bde to a sgl.
9419 sgl = (struct sli4_sge *)sglq->sgl; in lpfc_sli4_bpl2sgl()
9420 icmd = &piocbq->iocb; in lpfc_sli4_bpl2sgl()
9421 if (icmd->ulpCommand == CMD_XMIT_BLS_RSP64_CX) in lpfc_sli4_bpl2sgl()
9422 return sglq->sli4_xritag; in lpfc_sli4_bpl2sgl()
9423 if (icmd->un.genreq64.bdl.bdeFlags == BUFF_TYPE_BLP_64) { in lpfc_sli4_bpl2sgl()
9424 numBdes = icmd->un.genreq64.bdl.bdeSize / in lpfc_sli4_bpl2sgl()
9430 if (piocbq->context3) in lpfc_sli4_bpl2sgl()
9431 dmabuf = (struct lpfc_dmabuf *)piocbq->context3; in lpfc_sli4_bpl2sgl()
9435 bpl = (struct ulp_bde64 *)dmabuf->virt; in lpfc_sli4_bpl2sgl()
9441 sgl->addr_hi = bpl->addrHigh; in lpfc_sli4_bpl2sgl()
9442 sgl->addr_lo = bpl->addrLow; in lpfc_sli4_bpl2sgl()
9444 sgl->word2 = le32_to_cpu(sgl->word2); in lpfc_sli4_bpl2sgl()
9452 bde.tus.w = le32_to_cpu(bpl->tus.w); in lpfc_sli4_bpl2sgl()
9453 sgl->sge_len = cpu_to_le32(bde.tus.f.bdeSize); in lpfc_sli4_bpl2sgl()
9458 if (piocbq->iocb.ulpCommand == CMD_GEN_REQUEST64_CR) { in lpfc_sli4_bpl2sgl()
9460 if (bpl->tus.f.bdeFlags == BUFF_TYPE_BDE_64I) in lpfc_sli4_bpl2sgl()
9470 sgl->word2 = cpu_to_le32(sgl->word2); in lpfc_sli4_bpl2sgl()
9474 } else if (icmd->un.genreq64.bdl.bdeFlags == BUFF_TYPE_BDE_64) { in lpfc_sli4_bpl2sgl()
9479 sgl->addr_hi = in lpfc_sli4_bpl2sgl()
9480 cpu_to_le32(icmd->un.genreq64.bdl.addrHigh); in lpfc_sli4_bpl2sgl()
9481 sgl->addr_lo = in lpfc_sli4_bpl2sgl()
9482 cpu_to_le32(icmd->un.genreq64.bdl.addrLow); in lpfc_sli4_bpl2sgl()
9483 sgl->word2 = le32_to_cpu(sgl->word2); in lpfc_sli4_bpl2sgl()
9485 sgl->word2 = cpu_to_le32(sgl->word2); in lpfc_sli4_bpl2sgl()
9486 sgl->sge_len = in lpfc_sli4_bpl2sgl()
9487 cpu_to_le32(icmd->un.genreq64.bdl.bdeSize); in lpfc_sli4_bpl2sgl()
9489 return sglq->sli4_xritag; in lpfc_sli4_bpl2sgl()
9493 * lpfc_sli_iocb2wqe - Convert the IOCB to a work queue entry.
9527 fip = phba->hba_flag & HBA_FIP_SUPPORT; in lpfc_sli4_iocb2wqe()
9529 if (iocbq->iocb_flag & LPFC_IO_FCP) in lpfc_sli4_iocb2wqe()
9531 else if (fip && (iocbq->iocb_flag & LPFC_FIP_ELS_ID_MASK)) in lpfc_sli4_iocb2wqe()
9536 if (phba->fcp_embed_io) in lpfc_sli4_iocb2wqe()
9539 memcpy(wqe, &iocbq->iocb, sizeof(union lpfc_wqe)); in lpfc_sli4_iocb2wqe()
9541 wqe->generic.wqe_com.word7 = 0; in lpfc_sli4_iocb2wqe()
9542 wqe->generic.wqe_com.word10 = 0; in lpfc_sli4_iocb2wqe()
9544 abort_tag = (uint32_t) iocbq->iotag; in lpfc_sli4_iocb2wqe()
9545 xritag = iocbq->sli4_xritag; in lpfc_sli4_iocb2wqe()
9546 /* words0-2 bpl convert bde */ in lpfc_sli4_iocb2wqe()
9547 if (iocbq->iocb.un.genreq64.bdl.bdeFlags == BUFF_TYPE_BLP_64) { in lpfc_sli4_iocb2wqe()
9548 numBdes = iocbq->iocb.un.genreq64.bdl.bdeSize / in lpfc_sli4_iocb2wqe()
9551 ((struct lpfc_dmabuf *)iocbq->context3)->virt; in lpfc_sli4_iocb2wqe()
9556 wqe->generic.bde.addrHigh = le32_to_cpu(bpl->addrHigh); in lpfc_sli4_iocb2wqe()
9557 wqe->generic.bde.addrLow = le32_to_cpu(bpl->addrLow); in lpfc_sli4_iocb2wqe()
9561 wqe->generic.bde.tus.w = le32_to_cpu(bpl->tus.w); in lpfc_sli4_iocb2wqe()
9562 xmit_len = wqe->generic.bde.tus.f.bdeSize; in lpfc_sli4_iocb2wqe()
9569 xmit_len = iocbq->iocb.un.fcpi64.bdl.bdeSize; in lpfc_sli4_iocb2wqe()
9571 iocbq->iocb.ulpIoTag = iocbq->iotag; in lpfc_sli4_iocb2wqe()
9572 cmnd = iocbq->iocb.ulpCommand; in lpfc_sli4_iocb2wqe()
9574 switch (iocbq->iocb.ulpCommand) { in lpfc_sli4_iocb2wqe()
9576 if (iocbq->iocb_flag & LPFC_IO_LIBDFC) in lpfc_sli4_iocb2wqe()
9577 ndlp = iocbq->context_un.ndlp; in lpfc_sli4_iocb2wqe()
9579 ndlp = (struct lpfc_nodelist *)iocbq->context1; in lpfc_sli4_iocb2wqe()
9580 if (!iocbq->iocb.ulpLe) { in lpfc_sli4_iocb2wqe()
9584 iocbq->iocb.ulpCommand); in lpfc_sli4_iocb2wqe()
9588 wqe->els_req.payload_len = xmit_len; in lpfc_sli4_iocb2wqe()
9590 bf_set(wqe_tmo, &wqe->els_req.wqe_com, in lpfc_sli4_iocb2wqe()
9591 iocbq->iocb.ulpTimeout); in lpfc_sli4_iocb2wqe()
9593 bf_set(els_req64_vf, &wqe->els_req, 0); in lpfc_sli4_iocb2wqe()
9595 bf_set(els_req64_vfid, &wqe->els_req, 0); in lpfc_sli4_iocb2wqe()
9596 ct = ((iocbq->iocb.ulpCt_h << 1) | iocbq->iocb.ulpCt_l); in lpfc_sli4_iocb2wqe()
9597 bf_set(wqe_ctxt_tag, &wqe->els_req.wqe_com, in lpfc_sli4_iocb2wqe()
9598 iocbq->iocb.ulpContext); in lpfc_sli4_iocb2wqe()
9599 bf_set(wqe_ct, &wqe->els_req.wqe_com, ct); in lpfc_sli4_iocb2wqe()
9600 bf_set(wqe_pu, &wqe->els_req.wqe_com, 0); in lpfc_sli4_iocb2wqe()
9603 els_id = ((iocbq->iocb_flag & LPFC_FIP_ELS_ID_MASK) in lpfc_sli4_iocb2wqe()
9606 iocbq->context2)->virt); in lpfc_sli4_iocb2wqe()
9608 &phba->sli4_hba.sli_intf); in lpfc_sli4_iocb2wqe()
9617 bf_set(els_req64_sp, &wqe->els_req, 1); in lpfc_sli4_iocb2wqe()
9618 bf_set(els_req64_sid, &wqe->els_req, in lpfc_sli4_iocb2wqe()
9619 iocbq->vport->fc_myDID); in lpfc_sli4_iocb2wqe()
9621 !(phba->fc_topology == in lpfc_sli4_iocb2wqe()
9623 bf_set(els_req64_sid, &wqe->els_req, 0); in lpfc_sli4_iocb2wqe()
9624 bf_set(wqe_ct, &wqe->els_req.wqe_com, 1); in lpfc_sli4_iocb2wqe()
9625 bf_set(wqe_ctxt_tag, &wqe->els_req.wqe_com, in lpfc_sli4_iocb2wqe()
9626 phba->vpi_ids[iocbq->vport->vpi]); in lpfc_sli4_iocb2wqe()
9627 } else if (pcmd && iocbq->context1) { in lpfc_sli4_iocb2wqe()
9628 bf_set(wqe_ct, &wqe->els_req.wqe_com, 0); in lpfc_sli4_iocb2wqe()
9629 bf_set(wqe_ctxt_tag, &wqe->els_req.wqe_com, in lpfc_sli4_iocb2wqe()
9630 phba->sli4_hba.rpi_ids[ndlp->nlp_rpi]); in lpfc_sli4_iocb2wqe()
9633 bf_set(wqe_temp_rpi, &wqe->els_req.wqe_com, in lpfc_sli4_iocb2wqe()
9634 phba->sli4_hba.rpi_ids[ndlp->nlp_rpi]); in lpfc_sli4_iocb2wqe()
9635 bf_set(wqe_els_id, &wqe->els_req.wqe_com, els_id); in lpfc_sli4_iocb2wqe()
9636 bf_set(wqe_dbde, &wqe->els_req.wqe_com, 1); in lpfc_sli4_iocb2wqe()
9637 bf_set(wqe_iod, &wqe->els_req.wqe_com, LPFC_WQE_IOD_READ); in lpfc_sli4_iocb2wqe()
9638 bf_set(wqe_qosd, &wqe->els_req.wqe_com, 1); in lpfc_sli4_iocb2wqe()
9639 bf_set(wqe_lenloc, &wqe->els_req.wqe_com, LPFC_WQE_LENLOC_NONE); in lpfc_sli4_iocb2wqe()
9640 bf_set(wqe_ebde_cnt, &wqe->els_req.wqe_com, 0); in lpfc_sli4_iocb2wqe()
9641 wqe->els_req.max_response_payload_len = total_len - xmit_len; in lpfc_sli4_iocb2wqe()
9644 bf_set(wqe_ctxt_tag, &wqe->xmit_sequence.wqe_com, in lpfc_sli4_iocb2wqe()
9645 iocbq->iocb.un.ulpWord[3]); in lpfc_sli4_iocb2wqe()
9646 bf_set(wqe_rcvoxid, &wqe->xmit_sequence.wqe_com, in lpfc_sli4_iocb2wqe()
9647 iocbq->iocb.unsli3.rcvsli3.ox_id); in lpfc_sli4_iocb2wqe()
9651 if (phba->link_flag & LS_LOOPBACK_MODE) in lpfc_sli4_iocb2wqe()
9652 bf_set(wqe_xo, &wqe->xmit_sequence.wge_ctl, 1); in lpfc_sli4_iocb2wqe()
9656 wqe->xmit_sequence.rsvd3 = 0; in lpfc_sli4_iocb2wqe()
9659 bf_set(wqe_pu, &wqe->xmit_sequence.wqe_com, 0); in lpfc_sli4_iocb2wqe()
9660 bf_set(wqe_dbde, &wqe->xmit_sequence.wqe_com, 1); in lpfc_sli4_iocb2wqe()
9661 bf_set(wqe_iod, &wqe->xmit_sequence.wqe_com, in lpfc_sli4_iocb2wqe()
9663 bf_set(wqe_lenloc, &wqe->xmit_sequence.wqe_com, in lpfc_sli4_iocb2wqe()
9665 bf_set(wqe_ebde_cnt, &wqe->xmit_sequence.wqe_com, 0); in lpfc_sli4_iocb2wqe()
9666 wqe->xmit_sequence.xmit_len = xmit_len; in lpfc_sli4_iocb2wqe()
9671 wqe->xmit_bcast64.seq_payload_len = xmit_len; in lpfc_sli4_iocb2wqe()
9675 bf_set(wqe_ct, &wqe->xmit_bcast64.wqe_com, in lpfc_sli4_iocb2wqe()
9676 ((iocbq->iocb.ulpCt_h << 1) | iocbq->iocb.ulpCt_l)); in lpfc_sli4_iocb2wqe()
9677 bf_set(wqe_dbde, &wqe->xmit_bcast64.wqe_com, 1); in lpfc_sli4_iocb2wqe()
9678 bf_set(wqe_iod, &wqe->xmit_bcast64.wqe_com, LPFC_WQE_IOD_WRITE); in lpfc_sli4_iocb2wqe()
9679 bf_set(wqe_lenloc, &wqe->xmit_bcast64.wqe_com, in lpfc_sli4_iocb2wqe()
9681 bf_set(wqe_ebde_cnt, &wqe->xmit_bcast64.wqe_com, 0); in lpfc_sli4_iocb2wqe()
9687 bf_set(payload_offset_len, &wqe->fcp_iwrite, in lpfc_sli4_iocb2wqe()
9689 bf_set(cmd_buff_len, &wqe->fcp_iwrite, in lpfc_sli4_iocb2wqe()
9693 bf_set(wqe_erp, &wqe->fcp_iwrite.wqe_com, in lpfc_sli4_iocb2wqe()
9694 iocbq->iocb.ulpFCP2Rcvy); in lpfc_sli4_iocb2wqe()
9695 bf_set(wqe_lnk, &wqe->fcp_iwrite.wqe_com, iocbq->iocb.ulpXS); in lpfc_sli4_iocb2wqe()
9697 bf_set(wqe_iod, &wqe->fcp_iwrite.wqe_com, LPFC_WQE_IOD_WRITE); in lpfc_sli4_iocb2wqe()
9698 bf_set(wqe_lenloc, &wqe->fcp_iwrite.wqe_com, in lpfc_sli4_iocb2wqe()
9700 bf_set(wqe_pu, &wqe->fcp_iwrite.wqe_com, iocbq->iocb.ulpPU); in lpfc_sli4_iocb2wqe()
9701 bf_set(wqe_dbde, &wqe->fcp_iwrite.wqe_com, 1); in lpfc_sli4_iocb2wqe()
9702 if (iocbq->iocb_flag & LPFC_IO_OAS) { in lpfc_sli4_iocb2wqe()
9703 bf_set(wqe_oas, &wqe->fcp_iwrite.wqe_com, 1); in lpfc_sli4_iocb2wqe()
9704 bf_set(wqe_ccpe, &wqe->fcp_iwrite.wqe_com, 1); in lpfc_sli4_iocb2wqe()
9705 if (iocbq->priority) { in lpfc_sli4_iocb2wqe()
9706 bf_set(wqe_ccp, &wqe->fcp_iwrite.wqe_com, in lpfc_sli4_iocb2wqe()
9707 (iocbq->priority << 1)); in lpfc_sli4_iocb2wqe()
9709 bf_set(wqe_ccp, &wqe->fcp_iwrite.wqe_com, in lpfc_sli4_iocb2wqe()
9710 (phba->cfg_XLanePriority << 1)); in lpfc_sli4_iocb2wqe()
9716 if (phba->cfg_enable_pbde) in lpfc_sli4_iocb2wqe()
9717 bf_set(wqe_pbde, &wqe->fcp_iwrite.wqe_com, 1); in lpfc_sli4_iocb2wqe()
9719 bf_set(wqe_pbde, &wqe->fcp_iwrite.wqe_com, 0); in lpfc_sli4_iocb2wqe()
9721 if (phba->fcp_embed_io) { in lpfc_sli4_iocb2wqe()
9729 lpfc_cmd = iocbq->context1; in lpfc_sli4_iocb2wqe()
9730 sgl = (struct sli4_sge *)lpfc_cmd->dma_sgl; in lpfc_sli4_iocb2wqe()
9731 fcp_cmnd = lpfc_cmd->fcp_cmnd; in lpfc_sli4_iocb2wqe()
9733 /* Word 0-2 - FCP_CMND */ in lpfc_sli4_iocb2wqe()
9734 wqe->generic.bde.tus.f.bdeFlags = in lpfc_sli4_iocb2wqe()
9736 wqe->generic.bde.tus.f.bdeSize = sgl->sge_len; in lpfc_sli4_iocb2wqe()
9737 wqe->generic.bde.addrHigh = 0; in lpfc_sli4_iocb2wqe()
9738 wqe->generic.bde.addrLow = 88; /* Word 22 */ in lpfc_sli4_iocb2wqe()
9740 bf_set(wqe_wqes, &wqe->fcp_iwrite.wqe_com, 1); in lpfc_sli4_iocb2wqe()
9741 bf_set(wqe_dbde, &wqe->fcp_iwrite.wqe_com, 0); in lpfc_sli4_iocb2wqe()
9743 /* Word 22-29 FCP CMND Payload */ in lpfc_sli4_iocb2wqe()
9744 ptr = &wqe->words[22]; in lpfc_sli4_iocb2wqe()
9751 bf_set(payload_offset_len, &wqe->fcp_iread, in lpfc_sli4_iocb2wqe()
9753 bf_set(cmd_buff_len, &wqe->fcp_iread, in lpfc_sli4_iocb2wqe()
9757 bf_set(wqe_erp, &wqe->fcp_iread.wqe_com, in lpfc_sli4_iocb2wqe()
9758 iocbq->iocb.ulpFCP2Rcvy); in lpfc_sli4_iocb2wqe()
9759 bf_set(wqe_lnk, &wqe->fcp_iread.wqe_com, iocbq->iocb.ulpXS); in lpfc_sli4_iocb2wqe()
9761 bf_set(wqe_iod, &wqe->fcp_iread.wqe_com, LPFC_WQE_IOD_READ); in lpfc_sli4_iocb2wqe()
9762 bf_set(wqe_lenloc, &wqe->fcp_iread.wqe_com, in lpfc_sli4_iocb2wqe()
9764 bf_set(wqe_pu, &wqe->fcp_iread.wqe_com, iocbq->iocb.ulpPU); in lpfc_sli4_iocb2wqe()
9765 bf_set(wqe_dbde, &wqe->fcp_iread.wqe_com, 1); in lpfc_sli4_iocb2wqe()
9766 if (iocbq->iocb_flag & LPFC_IO_OAS) { in lpfc_sli4_iocb2wqe()
9767 bf_set(wqe_oas, &wqe->fcp_iread.wqe_com, 1); in lpfc_sli4_iocb2wqe()
9768 bf_set(wqe_ccpe, &wqe->fcp_iread.wqe_com, 1); in lpfc_sli4_iocb2wqe()
9769 if (iocbq->priority) { in lpfc_sli4_iocb2wqe()
9770 bf_set(wqe_ccp, &wqe->fcp_iread.wqe_com, in lpfc_sli4_iocb2wqe()
9771 (iocbq->priority << 1)); in lpfc_sli4_iocb2wqe()
9773 bf_set(wqe_ccp, &wqe->fcp_iread.wqe_com, in lpfc_sli4_iocb2wqe()
9774 (phba->cfg_XLanePriority << 1)); in lpfc_sli4_iocb2wqe()
9780 if (phba->cfg_enable_pbde) in lpfc_sli4_iocb2wqe()
9781 bf_set(wqe_pbde, &wqe->fcp_iread.wqe_com, 1); in lpfc_sli4_iocb2wqe()
9783 bf_set(wqe_pbde, &wqe->fcp_iread.wqe_com, 0); in lpfc_sli4_iocb2wqe()
9785 if (phba->fcp_embed_io) { in lpfc_sli4_iocb2wqe()
9793 lpfc_cmd = iocbq->context1; in lpfc_sli4_iocb2wqe()
9794 sgl = (struct sli4_sge *)lpfc_cmd->dma_sgl; in lpfc_sli4_iocb2wqe()
9795 fcp_cmnd = lpfc_cmd->fcp_cmnd; in lpfc_sli4_iocb2wqe()
9797 /* Word 0-2 - FCP_CMND */ in lpfc_sli4_iocb2wqe()
9798 wqe->generic.bde.tus.f.bdeFlags = in lpfc_sli4_iocb2wqe()
9800 wqe->generic.bde.tus.f.bdeSize = sgl->sge_len; in lpfc_sli4_iocb2wqe()
9801 wqe->generic.bde.addrHigh = 0; in lpfc_sli4_iocb2wqe()
9802 wqe->generic.bde.addrLow = 88; /* Word 22 */ in lpfc_sli4_iocb2wqe()
9804 bf_set(wqe_wqes, &wqe->fcp_iread.wqe_com, 1); in lpfc_sli4_iocb2wqe()
9805 bf_set(wqe_dbde, &wqe->fcp_iread.wqe_com, 0); in lpfc_sli4_iocb2wqe()
9807 /* Word 22-29 FCP CMND Payload */ in lpfc_sli4_iocb2wqe()
9808 ptr = &wqe->words[22]; in lpfc_sli4_iocb2wqe()
9815 bf_set(payload_offset_len, &wqe->fcp_icmd, in lpfc_sli4_iocb2wqe()
9817 bf_set(cmd_buff_len, &wqe->fcp_icmd, in lpfc_sli4_iocb2wqe()
9820 bf_set(wqe_pu, &wqe->fcp_icmd.wqe_com, 0); in lpfc_sli4_iocb2wqe()
9822 bf_set(wqe_dbde, &wqe->fcp_icmd.wqe_com, 1); in lpfc_sli4_iocb2wqe()
9823 bf_set(wqe_iod, &wqe->fcp_icmd.wqe_com, LPFC_WQE_IOD_WRITE); in lpfc_sli4_iocb2wqe()
9824 bf_set(wqe_qosd, &wqe->fcp_icmd.wqe_com, 1); in lpfc_sli4_iocb2wqe()
9825 bf_set(wqe_lenloc, &wqe->fcp_icmd.wqe_com, in lpfc_sli4_iocb2wqe()
9827 bf_set(wqe_erp, &wqe->fcp_icmd.wqe_com, in lpfc_sli4_iocb2wqe()
9828 iocbq->iocb.ulpFCP2Rcvy); in lpfc_sli4_iocb2wqe()
9829 if (iocbq->iocb_flag & LPFC_IO_OAS) { in lpfc_sli4_iocb2wqe()
9830 bf_set(wqe_oas, &wqe->fcp_icmd.wqe_com, 1); in lpfc_sli4_iocb2wqe()
9831 bf_set(wqe_ccpe, &wqe->fcp_icmd.wqe_com, 1); in lpfc_sli4_iocb2wqe()
9832 if (iocbq->priority) { in lpfc_sli4_iocb2wqe()
9833 bf_set(wqe_ccp, &wqe->fcp_icmd.wqe_com, in lpfc_sli4_iocb2wqe()
9834 (iocbq->priority << 1)); in lpfc_sli4_iocb2wqe()
9836 bf_set(wqe_ccp, &wqe->fcp_icmd.wqe_com, in lpfc_sli4_iocb2wqe()
9837 (phba->cfg_XLanePriority << 1)); in lpfc_sli4_iocb2wqe()
9842 if (phba->fcp_embed_io) { in lpfc_sli4_iocb2wqe()
9850 lpfc_cmd = iocbq->context1; in lpfc_sli4_iocb2wqe()
9851 sgl = (struct sli4_sge *)lpfc_cmd->dma_sgl; in lpfc_sli4_iocb2wqe()
9852 fcp_cmnd = lpfc_cmd->fcp_cmnd; in lpfc_sli4_iocb2wqe()
9854 /* Word 0-2 - FCP_CMND */ in lpfc_sli4_iocb2wqe()
9855 wqe->generic.bde.tus.f.bdeFlags = in lpfc_sli4_iocb2wqe()
9857 wqe->generic.bde.tus.f.bdeSize = sgl->sge_len; in lpfc_sli4_iocb2wqe()
9858 wqe->generic.bde.addrHigh = 0; in lpfc_sli4_iocb2wqe()
9859 wqe->generic.bde.addrLow = 88; /* Word 22 */ in lpfc_sli4_iocb2wqe()
9861 bf_set(wqe_wqes, &wqe->fcp_icmd.wqe_com, 1); in lpfc_sli4_iocb2wqe()
9862 bf_set(wqe_dbde, &wqe->fcp_icmd.wqe_com, 0); in lpfc_sli4_iocb2wqe()
9864 /* Word 22-29 FCP CMND Payload */ in lpfc_sli4_iocb2wqe()
9865 ptr = &wqe->words[22]; in lpfc_sli4_iocb2wqe()
9874 numBdes = iocbq->iocb.un.genreq64.bdl.bdeSize / in lpfc_sli4_iocb2wqe()
9883 wqe->gen_req.request_payload_len = xmit_len; in lpfc_sli4_iocb2wqe()
9887 if (iocbq->iocb.ulpCt_h || iocbq->iocb.ulpCt_l) { in lpfc_sli4_iocb2wqe()
9888 ct = ((iocbq->iocb.ulpCt_h << 1) | iocbq->iocb.ulpCt_l); in lpfc_sli4_iocb2wqe()
9891 ct, iocbq->iocb.ulpCommand); in lpfc_sli4_iocb2wqe()
9894 bf_set(wqe_ct, &wqe->gen_req.wqe_com, 0); in lpfc_sli4_iocb2wqe()
9895 bf_set(wqe_tmo, &wqe->gen_req.wqe_com, iocbq->iocb.ulpTimeout); in lpfc_sli4_iocb2wqe()
9896 bf_set(wqe_pu, &wqe->gen_req.wqe_com, iocbq->iocb.ulpPU); in lpfc_sli4_iocb2wqe()
9897 bf_set(wqe_dbde, &wqe->gen_req.wqe_com, 1); in lpfc_sli4_iocb2wqe()
9898 bf_set(wqe_iod, &wqe->gen_req.wqe_com, LPFC_WQE_IOD_READ); in lpfc_sli4_iocb2wqe()
9899 bf_set(wqe_qosd, &wqe->gen_req.wqe_com, 1); in lpfc_sli4_iocb2wqe()
9900 bf_set(wqe_lenloc, &wqe->gen_req.wqe_com, LPFC_WQE_LENLOC_NONE); in lpfc_sli4_iocb2wqe()
9901 bf_set(wqe_ebde_cnt, &wqe->gen_req.wqe_com, 0); in lpfc_sli4_iocb2wqe()
9902 wqe->gen_req.max_response_payload_len = total_len - xmit_len; in lpfc_sli4_iocb2wqe()
9906 ndlp = (struct lpfc_nodelist *)iocbq->context1; in lpfc_sli4_iocb2wqe()
9907 /* words0-2 BDE memcpy */ in lpfc_sli4_iocb2wqe()
9909 wqe->xmit_els_rsp.response_payload_len = xmit_len; in lpfc_sli4_iocb2wqe()
9911 wqe->xmit_els_rsp.word4 = 0; in lpfc_sli4_iocb2wqe()
9913 bf_set(wqe_els_did, &wqe->xmit_els_rsp.wqe_dest, in lpfc_sli4_iocb2wqe()
9914 iocbq->iocb.un.xseq64.xmit_els_remoteID); in lpfc_sli4_iocb2wqe()
9917 &phba->sli4_hba.sli_intf); in lpfc_sli4_iocb2wqe()
9919 if (iocbq->vport->fc_flag & FC_PT2PT) { in lpfc_sli4_iocb2wqe()
9920 bf_set(els_rsp64_sp, &wqe->xmit_els_rsp, 1); in lpfc_sli4_iocb2wqe()
9921 bf_set(els_rsp64_sid, &wqe->xmit_els_rsp, in lpfc_sli4_iocb2wqe()
9922 iocbq->vport->fc_myDID); in lpfc_sli4_iocb2wqe()
9923 if (iocbq->vport->fc_myDID == Fabric_DID) { in lpfc_sli4_iocb2wqe()
9925 &wqe->xmit_els_rsp.wqe_dest, 0); in lpfc_sli4_iocb2wqe()
9929 bf_set(wqe_ct, &wqe->xmit_els_rsp.wqe_com, in lpfc_sli4_iocb2wqe()
9930 ((iocbq->iocb.ulpCt_h << 1) | iocbq->iocb.ulpCt_l)); in lpfc_sli4_iocb2wqe()
9931 bf_set(wqe_pu, &wqe->xmit_els_rsp.wqe_com, iocbq->iocb.ulpPU); in lpfc_sli4_iocb2wqe()
9932 bf_set(wqe_rcvoxid, &wqe->xmit_els_rsp.wqe_com, in lpfc_sli4_iocb2wqe()
9933 iocbq->iocb.unsli3.rcvsli3.ox_id); in lpfc_sli4_iocb2wqe()
9934 if (!iocbq->iocb.ulpCt_h && iocbq->iocb.ulpCt_l) in lpfc_sli4_iocb2wqe()
9935 bf_set(wqe_ctxt_tag, &wqe->xmit_els_rsp.wqe_com, in lpfc_sli4_iocb2wqe()
9936 phba->vpi_ids[iocbq->vport->vpi]); in lpfc_sli4_iocb2wqe()
9937 bf_set(wqe_dbde, &wqe->xmit_els_rsp.wqe_com, 1); in lpfc_sli4_iocb2wqe()
9938 bf_set(wqe_iod, &wqe->xmit_els_rsp.wqe_com, LPFC_WQE_IOD_WRITE); in lpfc_sli4_iocb2wqe()
9939 bf_set(wqe_qosd, &wqe->xmit_els_rsp.wqe_com, 1); in lpfc_sli4_iocb2wqe()
9940 bf_set(wqe_lenloc, &wqe->xmit_els_rsp.wqe_com, in lpfc_sli4_iocb2wqe()
9942 bf_set(wqe_ebde_cnt, &wqe->xmit_els_rsp.wqe_com, 0); in lpfc_sli4_iocb2wqe()
9943 bf_set(wqe_rsp_temp_rpi, &wqe->xmit_els_rsp, in lpfc_sli4_iocb2wqe()
9944 phba->sli4_hba.rpi_ids[ndlp->nlp_rpi]); in lpfc_sli4_iocb2wqe()
9946 iocbq->context2)->virt); in lpfc_sli4_iocb2wqe()
9947 if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) { in lpfc_sli4_iocb2wqe()
9948 bf_set(els_rsp64_sp, &wqe->xmit_els_rsp, 1); in lpfc_sli4_iocb2wqe()
9949 bf_set(els_rsp64_sid, &wqe->xmit_els_rsp, in lpfc_sli4_iocb2wqe()
9950 iocbq->vport->fc_myDID); in lpfc_sli4_iocb2wqe()
9951 bf_set(wqe_ct, &wqe->xmit_els_rsp.wqe_com, 1); in lpfc_sli4_iocb2wqe()
9952 bf_set(wqe_ctxt_tag, &wqe->xmit_els_rsp.wqe_com, in lpfc_sli4_iocb2wqe()
9953 phba->vpi_ids[phba->pport->vpi]); in lpfc_sli4_iocb2wqe()
9960 /* words 0-2 memcpy should be 0 rserved */ in lpfc_sli4_iocb2wqe()
9962 abrt_iotag = iocbq->iocb.un.acxri.abortContextTag; in lpfc_sli4_iocb2wqe()
9963 if (abrt_iotag != 0 && abrt_iotag <= phba->sli.last_iotag) { in lpfc_sli4_iocb2wqe()
9964 abrtiocbq = phba->sli.iocbq_lookup[abrt_iotag]; in lpfc_sli4_iocb2wqe()
9965 fip = abrtiocbq->iocb_flag & LPFC_FIP_ELS_ID_MASK; in lpfc_sli4_iocb2wqe()
9969 if ((iocbq->iocb.ulpCommand == CMD_CLOSE_XRI_CN) || fip) in lpfc_sli4_iocb2wqe()
9975 bf_set(abort_cmd_ia, &wqe->abort_cmd, 1); in lpfc_sli4_iocb2wqe()
9977 bf_set(abort_cmd_ia, &wqe->abort_cmd, 0); in lpfc_sli4_iocb2wqe()
9978 bf_set(abort_cmd_criteria, &wqe->abort_cmd, T_XRI_TAG); in lpfc_sli4_iocb2wqe()
9980 wqe->abort_cmd.rsrvd5 = 0; in lpfc_sli4_iocb2wqe()
9981 bf_set(wqe_ct, &wqe->abort_cmd.wqe_com, in lpfc_sli4_iocb2wqe()
9982 ((iocbq->iocb.ulpCt_h << 1) | iocbq->iocb.ulpCt_l)); in lpfc_sli4_iocb2wqe()
9983 abort_tag = iocbq->iocb.un.acxri.abortIoTag; in lpfc_sli4_iocb2wqe()
9988 bf_set(wqe_cmnd, &wqe->abort_cmd.wqe_com, CMD_ABORT_XRI_CX); in lpfc_sli4_iocb2wqe()
9989 bf_set(wqe_qosd, &wqe->abort_cmd.wqe_com, 1); in lpfc_sli4_iocb2wqe()
9990 bf_set(wqe_lenloc, &wqe->abort_cmd.wqe_com, in lpfc_sli4_iocb2wqe()
9997 ndlp = (struct lpfc_nodelist *)iocbq->context1; in lpfc_sli4_iocb2wqe()
9999 * we re-construct this WQE here based on information in in lpfc_sli4_iocb2wqe()
10004 bf_set(xmit_bls_rsp64_oxid, &wqe->xmit_bls_rsp, in lpfc_sli4_iocb2wqe()
10005 bf_get(lpfc_abts_oxid, &iocbq->iocb.un.bls_rsp)); in lpfc_sli4_iocb2wqe()
10006 if (bf_get(lpfc_abts_orig, &iocbq->iocb.un.bls_rsp) == in lpfc_sli4_iocb2wqe()
10012 bf_set(xmit_bls_rsp64_rxid, &wqe->xmit_bls_rsp, in lpfc_sli4_iocb2wqe()
10013 iocbq->sli4_xritag); in lpfc_sli4_iocb2wqe()
10019 bf_set(xmit_bls_rsp64_rxid, &wqe->xmit_bls_rsp, in lpfc_sli4_iocb2wqe()
10020 bf_get(lpfc_abts_rxid, &iocbq->iocb.un.bls_rsp)); in lpfc_sli4_iocb2wqe()
10022 bf_set(xmit_bls_rsp64_seqcnthi, &wqe->xmit_bls_rsp, 0xffff); in lpfc_sli4_iocb2wqe()
10023 bf_set(wqe_xmit_bls_pt, &wqe->xmit_bls_rsp.wqe_dest, 0x1); in lpfc_sli4_iocb2wqe()
10026 bf_set(wqe_els_did, &wqe->xmit_bls_rsp.wqe_dest, in lpfc_sli4_iocb2wqe()
10027 ndlp->nlp_DID); in lpfc_sli4_iocb2wqe()
10028 bf_set(xmit_bls_rsp64_temprpi, &wqe->xmit_bls_rsp, in lpfc_sli4_iocb2wqe()
10029 iocbq->iocb.ulpContext); in lpfc_sli4_iocb2wqe()
10030 bf_set(wqe_ct, &wqe->xmit_bls_rsp.wqe_com, 1); in lpfc_sli4_iocb2wqe()
10031 bf_set(wqe_ctxt_tag, &wqe->xmit_bls_rsp.wqe_com, in lpfc_sli4_iocb2wqe()
10032 phba->vpi_ids[phba->pport->vpi]); in lpfc_sli4_iocb2wqe()
10033 bf_set(wqe_qosd, &wqe->xmit_bls_rsp.wqe_com, 1); in lpfc_sli4_iocb2wqe()
10034 bf_set(wqe_lenloc, &wqe->xmit_bls_rsp.wqe_com, in lpfc_sli4_iocb2wqe()
10036 /* Overwrite the pre-set comnd type with OTHER_COMMAND */ in lpfc_sli4_iocb2wqe()
10038 if (iocbq->iocb.un.xseq64.w5.hcsw.Rctl == FC_RCTL_BA_RJT) { in lpfc_sli4_iocb2wqe()
10039 bf_set(xmit_bls_rsp64_rjt_vspec, &wqe->xmit_bls_rsp, in lpfc_sli4_iocb2wqe()
10040 bf_get(lpfc_vndr_code, &iocbq->iocb.un.bls_rsp)); in lpfc_sli4_iocb2wqe()
10041 bf_set(xmit_bls_rsp64_rjt_expc, &wqe->xmit_bls_rsp, in lpfc_sli4_iocb2wqe()
10042 bf_get(lpfc_rsn_expln, &iocbq->iocb.un.bls_rsp)); in lpfc_sli4_iocb2wqe()
10043 bf_set(xmit_bls_rsp64_rjt_rsnc, &wqe->xmit_bls_rsp, in lpfc_sli4_iocb2wqe()
10044 bf_get(lpfc_rsn_code, &iocbq->iocb.un.bls_rsp)); in lpfc_sli4_iocb2wqe()
10049 bf_set(wqe_cmnd, &wqe->generic.wqe_com, CMD_SEND_FRAME); in lpfc_sli4_iocb2wqe()
10050 bf_set(wqe_sof, &wqe->generic.wqe_com, 0x2E); /* SOF byte */ in lpfc_sli4_iocb2wqe()
10051 bf_set(wqe_eof, &wqe->generic.wqe_com, 0x41); /* EOF byte */ in lpfc_sli4_iocb2wqe()
10052 bf_set(wqe_lenloc, &wqe->generic.wqe_com, 1); in lpfc_sli4_iocb2wqe()
10053 bf_set(wqe_xbl, &wqe->generic.wqe_com, 1); in lpfc_sli4_iocb2wqe()
10054 bf_set(wqe_dbde, &wqe->generic.wqe_com, 1); in lpfc_sli4_iocb2wqe()
10055 bf_set(wqe_xc, &wqe->generic.wqe_com, 1); in lpfc_sli4_iocb2wqe()
10056 bf_set(wqe_cmd_type, &wqe->generic.wqe_com, 0xA); in lpfc_sli4_iocb2wqe()
10057 bf_set(wqe_cqid, &wqe->generic.wqe_com, LPFC_WQE_CQ_ID_DEFAULT); in lpfc_sli4_iocb2wqe()
10058 bf_set(wqe_xri_tag, &wqe->generic.wqe_com, xritag); in lpfc_sli4_iocb2wqe()
10059 bf_set(wqe_reqtag, &wqe->generic.wqe_com, iocbq->iotag); in lpfc_sli4_iocb2wqe()
10064 case CMD_FCP_TSEND64_CX: /* Target mode send xfer-ready */ in lpfc_sli4_iocb2wqe()
10070 iocbq->iocb.ulpCommand); in lpfc_sli4_iocb2wqe()
10075 if (iocbq->iocb_flag & LPFC_IO_DIF_PASS) in lpfc_sli4_iocb2wqe()
10076 bf_set(wqe_dif, &wqe->generic.wqe_com, LPFC_WQE_DIF_PASSTHRU); in lpfc_sli4_iocb2wqe()
10077 else if (iocbq->iocb_flag & LPFC_IO_DIF_STRIP) in lpfc_sli4_iocb2wqe()
10078 bf_set(wqe_dif, &wqe->generic.wqe_com, LPFC_WQE_DIF_STRIP); in lpfc_sli4_iocb2wqe()
10079 else if (iocbq->iocb_flag & LPFC_IO_DIF_INSERT) in lpfc_sli4_iocb2wqe()
10080 bf_set(wqe_dif, &wqe->generic.wqe_com, LPFC_WQE_DIF_INSERT); in lpfc_sli4_iocb2wqe()
10081 iocbq->iocb_flag &= ~(LPFC_IO_DIF_PASS | LPFC_IO_DIF_STRIP | in lpfc_sli4_iocb2wqe()
10083 bf_set(wqe_xri_tag, &wqe->generic.wqe_com, xritag); in lpfc_sli4_iocb2wqe()
10084 bf_set(wqe_reqtag, &wqe->generic.wqe_com, iocbq->iotag); in lpfc_sli4_iocb2wqe()
10085 wqe->generic.wqe_com.abort_tag = abort_tag; in lpfc_sli4_iocb2wqe()
10086 bf_set(wqe_cmd_type, &wqe->generic.wqe_com, command_type); in lpfc_sli4_iocb2wqe()
10087 bf_set(wqe_cmnd, &wqe->generic.wqe_com, cmnd); in lpfc_sli4_iocb2wqe()
10088 bf_set(wqe_class, &wqe->generic.wqe_com, iocbq->iocb.ulpClass); in lpfc_sli4_iocb2wqe()
10089 bf_set(wqe_cqid, &wqe->generic.wqe_com, LPFC_WQE_CQ_ID_DEFAULT); in lpfc_sli4_iocb2wqe()
10094 * __lpfc_sli_issue_iocb_s4 - SLI4 device lockless ver of lpfc_sli_issue_iocb
10101 * an iocb command to an HBA with SLI-4 interface spec.
10117 if ((piocb->iocb_flag & LPFC_IO_FCP) || in __lpfc_sli_issue_iocb_s4()
10118 (piocb->iocb_flag & LPFC_USE_FCPWQIDX)) { in __lpfc_sli_issue_iocb_s4()
10119 wq = phba->sli4_hba.hdwq[piocb->hba_wqidx].io_wq; in __lpfc_sli_issue_iocb_s4()
10121 wq = phba->sli4_hba.els_wq; in __lpfc_sli_issue_iocb_s4()
10125 pring = wq->pring; in __lpfc_sli_issue_iocb_s4()
10131 lockdep_assert_held(&pring->ring_lock); in __lpfc_sli_issue_iocb_s4()
10133 if (piocb->sli4_xritag == NO_XRI) { in __lpfc_sli_issue_iocb_s4()
10134 if (piocb->iocb.ulpCommand == CMD_ABORT_XRI_CN || in __lpfc_sli_issue_iocb_s4()
10135 piocb->iocb.ulpCommand == CMD_CLOSE_XRI_CN) in __lpfc_sli_issue_iocb_s4()
10138 if (!list_empty(&pring->txq)) { in __lpfc_sli_issue_iocb_s4()
10159 } else if (piocb->iocb_flag & LPFC_IO_FCP) in __lpfc_sli_issue_iocb_s4()
10167 sglq = __lpfc_get_active_sglq(phba, piocb->sli4_lxritag); in __lpfc_sli_issue_iocb_s4()
10173 piocb->sli4_lxritag = sglq->sli4_lxritag; in __lpfc_sli_issue_iocb_s4()
10174 piocb->sli4_xritag = sglq->sli4_xritag; in __lpfc_sli_issue_iocb_s4()
10190 * __lpfc_sli_issue_iocb - Wrapper func of lockless version for issuing iocb
10196 * IOCB_ERROR - Error
10197 * IOCB_SUCCESS - Success
10198 * IOCB_BUSY - Busy
10204 return phba->__lpfc_sli_issue_iocb(phba, ring_number, piocb, flag); in __lpfc_sli_issue_iocb()
10208 * lpfc_sli_api_table_setup - Set up sli api function jump table
10210 * @dev_grp: The HBA PCI-Device group number.
10214 * Returns: 0 - success, -ENODEV - failure.
10222 phba->__lpfc_sli_issue_iocb = __lpfc_sli_issue_iocb_s3; in lpfc_sli_api_table_setup()
10223 phba->__lpfc_sli_release_iocbq = __lpfc_sli_release_iocbq_s3; in lpfc_sli_api_table_setup()
10226 phba->__lpfc_sli_issue_iocb = __lpfc_sli_issue_iocb_s4; in lpfc_sli_api_table_setup()
10227 phba->__lpfc_sli_release_iocbq = __lpfc_sli_release_iocbq_s4; in lpfc_sli_api_table_setup()
10231 "1419 Invalid HBA PCI-device group: 0x%x\n", in lpfc_sli_api_table_setup()
10233 return -ENODEV; in lpfc_sli_api_table_setup()
10236 phba->lpfc_get_iocb_from_iocbq = lpfc_get_iocb_from_iocbq; in lpfc_sli_api_table_setup()
10241 * lpfc_sli4_calc_ring - Calculates which ring to use
10255 if (piocb->iocb_flag & (LPFC_IO_FCP | LPFC_USE_FCPWQIDX)) { in lpfc_sli4_calc_ring()
10256 if (unlikely(!phba->sli4_hba.hdwq)) in lpfc_sli4_calc_ring()
10262 if (!(piocb->iocb_flag & LPFC_USE_FCPWQIDX)) { in lpfc_sli4_calc_ring()
10263 lpfc_cmd = (struct lpfc_io_buf *)piocb->context1; in lpfc_sli4_calc_ring()
10264 piocb->hba_wqidx = lpfc_cmd->hdwq_no; in lpfc_sli4_calc_ring()
10266 return phba->sli4_hba.hdwq[piocb->hba_wqidx].io_wq->pring; in lpfc_sli4_calc_ring()
10268 if (unlikely(!phba->sli4_hba.els_wq)) in lpfc_sli4_calc_ring()
10270 piocb->hba_wqidx = 0; in lpfc_sli4_calc_ring()
10271 return phba->sli4_hba.els_wq->pring; in lpfc_sli4_calc_ring()
10276 * lpfc_sli_issue_iocb - Wrapper function for __lpfc_sli_issue_iocb
10297 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_sli_issue_iocb()
10298 eq = phba->sli4_hba.hdwq[piocb->hba_wqidx].hba_eq; in lpfc_sli_issue_iocb()
10304 spin_lock_irqsave(&pring->ring_lock, iflags); in lpfc_sli_issue_iocb()
10306 spin_unlock_irqrestore(&pring->ring_lock, iflags); in lpfc_sli_issue_iocb()
10311 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli_issue_iocb()
10313 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli_issue_iocb()
10319 * lpfc_extra_ring_setup - Extra ring setup function
10335 psli = &phba->sli; in lpfc_extra_ring_setup()
10340 pring = &psli->sli3_ring[LPFC_FCP_RING]; in lpfc_extra_ring_setup()
10341 pring->sli.sli3.numCiocb -= SLI2_IOCB_CMD_R1XTRA_ENTRIES; in lpfc_extra_ring_setup()
10342 pring->sli.sli3.numRiocb -= SLI2_IOCB_RSP_R1XTRA_ENTRIES; in lpfc_extra_ring_setup()
10343 pring->sli.sli3.numCiocb -= SLI2_IOCB_CMD_R3XTRA_ENTRIES; in lpfc_extra_ring_setup()
10344 pring->sli.sli3.numRiocb -= SLI2_IOCB_RSP_R3XTRA_ENTRIES; in lpfc_extra_ring_setup()
10347 pring = &psli->sli3_ring[LPFC_EXTRA_RING]; in lpfc_extra_ring_setup()
10349 pring->sli.sli3.numCiocb += SLI2_IOCB_CMD_R1XTRA_ENTRIES; in lpfc_extra_ring_setup()
10350 pring->sli.sli3.numRiocb += SLI2_IOCB_RSP_R1XTRA_ENTRIES; in lpfc_extra_ring_setup()
10351 pring->sli.sli3.numCiocb += SLI2_IOCB_CMD_R3XTRA_ENTRIES; in lpfc_extra_ring_setup()
10352 pring->sli.sli3.numRiocb += SLI2_IOCB_RSP_R3XTRA_ENTRIES; in lpfc_extra_ring_setup()
10355 pring->iotag_max = 4096; in lpfc_extra_ring_setup()
10356 pring->num_mask = 1; in lpfc_extra_ring_setup()
10357 pring->prt[0].profile = 0; /* Mask 0 */ in lpfc_extra_ring_setup()
10358 pring->prt[0].rctl = phba->cfg_multi_ring_rctl; in lpfc_extra_ring_setup()
10359 pring->prt[0].type = phba->cfg_multi_ring_type; in lpfc_extra_ring_setup()
10360 pring->prt[0].lpfc_sli_rcv_unsol_event = NULL; in lpfc_extra_ring_setup()
10369 struct lpfc_work_evt *evtp = &ndlp->recovery_evt; in lpfc_sli_post_recovery_event()
10371 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli_post_recovery_event()
10372 if (!list_empty(&evtp->evt_listp)) { in lpfc_sli_post_recovery_event()
10373 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli_post_recovery_event()
10378 evtp->evt_arg1 = lpfc_nlp_get(ndlp); in lpfc_sli_post_recovery_event()
10379 if (!evtp->evt_arg1) { in lpfc_sli_post_recovery_event()
10380 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli_post_recovery_event()
10383 evtp->evt = LPFC_EVT_RECOVER_PORT; in lpfc_sli_post_recovery_event()
10384 list_add_tail(&evtp->evt_listp, &phba->work_list); in lpfc_sli_post_recovery_event()
10385 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli_post_recovery_event()
10390 /* lpfc_sli_abts_err_handler - handle a failed ABTS request from an SLI3 port.
10410 /* The rpi in the ulpContext is vport-sensitive. */ in lpfc_sli_abts_err_handler()
10411 vpi = iocbq->iocb.un.asyncstat.sub_ctxt_tag; in lpfc_sli_abts_err_handler()
10412 rpi = iocbq->iocb.ulpContext; in lpfc_sli_abts_err_handler()
10417 vpi, rpi, iocbq->iocb.ulpStatus); in lpfc_sli_abts_err_handler()
10426 if (iocbq->iocb.ulpStatus == IOSTAT_LOCAL_REJECT) in lpfc_sli_abts_err_handler()
10434 iocbq->iocb.ulpContext, iocbq->iocb.ulpStatus, in lpfc_sli_abts_err_handler()
10438 /* lpfc_sli4_abts_err_handler - handle a failed ABTS request from an SLI4 port.
10465 ndlp->vport->vpi, phba->sli4_hba.rpi_ids[ndlp->nlp_rpi], in lpfc_sli4_abts_err_handler()
10468 axri->parameter); in lpfc_sli4_abts_err_handler()
10475 ext_status = axri->parameter & IOERR_PARAM_MASK; in lpfc_sli4_abts_err_handler()
10482 * lpfc_sli_async_event_handler - ASYNC iocb handler function
10504 icmd = &iocbq->iocb; in lpfc_sli_async_event_handler()
10505 evt_code = icmd->un.asyncstat.evt_code; in lpfc_sli_async_event_handler()
10510 temp_event_data.data = (uint32_t) icmd->ulpContext; in lpfc_sli_async_event_handler()
10517 (uint32_t) icmd->ulpContext); in lpfc_sli_async_event_handler()
10523 (uint32_t) icmd->ulpContext); in lpfc_sli_async_event_handler()
10527 shost = lpfc_shost_from_vport(phba->pport); in lpfc_sli_async_event_handler()
10544 pring->ringno, icmd->un.asyncstat.evt_code, in lpfc_sli_async_event_handler()
10556 * lpfc_sli4_setup - SLI ring setup function
10571 pring = phba->sli4_hba.els_wq->pring; in lpfc_sli4_setup()
10572 pring->num_mask = LPFC_MAX_RING_MASK; in lpfc_sli4_setup()
10573 pring->prt[0].profile = 0; /* Mask 0 */ in lpfc_sli4_setup()
10574 pring->prt[0].rctl = FC_RCTL_ELS_REQ; in lpfc_sli4_setup()
10575 pring->prt[0].type = FC_TYPE_ELS; in lpfc_sli4_setup()
10576 pring->prt[0].lpfc_sli_rcv_unsol_event = in lpfc_sli4_setup()
10578 pring->prt[1].profile = 0; /* Mask 1 */ in lpfc_sli4_setup()
10579 pring->prt[1].rctl = FC_RCTL_ELS_REP; in lpfc_sli4_setup()
10580 pring->prt[1].type = FC_TYPE_ELS; in lpfc_sli4_setup()
10581 pring->prt[1].lpfc_sli_rcv_unsol_event = in lpfc_sli4_setup()
10583 pring->prt[2].profile = 0; /* Mask 2 */ in lpfc_sli4_setup()
10585 pring->prt[2].rctl = FC_RCTL_DD_UNSOL_CTL; in lpfc_sli4_setup()
10587 pring->prt[2].type = FC_TYPE_CT; in lpfc_sli4_setup()
10588 pring->prt[2].lpfc_sli_rcv_unsol_event = in lpfc_sli4_setup()
10590 pring->prt[3].profile = 0; /* Mask 3 */ in lpfc_sli4_setup()
10592 pring->prt[3].rctl = FC_RCTL_DD_SOL_CTL; in lpfc_sli4_setup()
10594 pring->prt[3].type = FC_TYPE_CT; in lpfc_sli4_setup()
10595 pring->prt[3].lpfc_sli_rcv_unsol_event = in lpfc_sli4_setup()
10601 * lpfc_sli_setup - SLI ring setup function
10615 struct lpfc_sli *psli = &phba->sli; in lpfc_sli_setup()
10618 psli->num_rings = MAX_SLI3_CONFIGURED_RINGS; in lpfc_sli_setup()
10619 psli->sli_flag = 0; in lpfc_sli_setup()
10621 psli->iocbq_lookup = NULL; in lpfc_sli_setup()
10622 psli->iocbq_lookup_len = 0; in lpfc_sli_setup()
10623 psli->last_iotag = 0; in lpfc_sli_setup()
10625 for (i = 0; i < psli->num_rings; i++) { in lpfc_sli_setup()
10626 pring = &psli->sli3_ring[i]; in lpfc_sli_setup()
10628 case LPFC_FCP_RING: /* ring 0 - FCP */ in lpfc_sli_setup()
10630 pring->sli.sli3.numCiocb = SLI2_IOCB_CMD_R0_ENTRIES; in lpfc_sli_setup()
10631 pring->sli.sli3.numRiocb = SLI2_IOCB_RSP_R0_ENTRIES; in lpfc_sli_setup()
10632 pring->sli.sli3.numCiocb += in lpfc_sli_setup()
10634 pring->sli.sli3.numRiocb += in lpfc_sli_setup()
10636 pring->sli.sli3.numCiocb += in lpfc_sli_setup()
10638 pring->sli.sli3.numRiocb += in lpfc_sli_setup()
10640 pring->sli.sli3.sizeCiocb = (phba->sli_rev == 3) ? in lpfc_sli_setup()
10643 pring->sli.sli3.sizeRiocb = (phba->sli_rev == 3) ? in lpfc_sli_setup()
10646 pring->iotag_ctr = 0; in lpfc_sli_setup()
10647 pring->iotag_max = in lpfc_sli_setup()
10648 (phba->cfg_hba_queue_depth * 2); in lpfc_sli_setup()
10649 pring->fast_iotag = pring->iotag_max; in lpfc_sli_setup()
10650 pring->num_mask = 0; in lpfc_sli_setup()
10652 case LPFC_EXTRA_RING: /* ring 1 - EXTRA */ in lpfc_sli_setup()
10654 pring->sli.sli3.numCiocb = SLI2_IOCB_CMD_R1_ENTRIES; in lpfc_sli_setup()
10655 pring->sli.sli3.numRiocb = SLI2_IOCB_RSP_R1_ENTRIES; in lpfc_sli_setup()
10656 pring->sli.sli3.sizeCiocb = (phba->sli_rev == 3) ? in lpfc_sli_setup()
10659 pring->sli.sli3.sizeRiocb = (phba->sli_rev == 3) ? in lpfc_sli_setup()
10662 pring->iotag_max = phba->cfg_hba_queue_depth; in lpfc_sli_setup()
10663 pring->num_mask = 0; in lpfc_sli_setup()
10665 case LPFC_ELS_RING: /* ring 2 - ELS / CT */ in lpfc_sli_setup()
10667 pring->sli.sli3.numCiocb = SLI2_IOCB_CMD_R2_ENTRIES; in lpfc_sli_setup()
10668 pring->sli.sli3.numRiocb = SLI2_IOCB_RSP_R2_ENTRIES; in lpfc_sli_setup()
10669 pring->sli.sli3.sizeCiocb = (phba->sli_rev == 3) ? in lpfc_sli_setup()
10672 pring->sli.sli3.sizeRiocb = (phba->sli_rev == 3) ? in lpfc_sli_setup()
10675 pring->fast_iotag = 0; in lpfc_sli_setup()
10676 pring->iotag_ctr = 0; in lpfc_sli_setup()
10677 pring->iotag_max = 4096; in lpfc_sli_setup()
10678 pring->lpfc_sli_rcv_async_status = in lpfc_sli_setup()
10680 pring->num_mask = LPFC_MAX_RING_MASK; in lpfc_sli_setup()
10681 pring->prt[0].profile = 0; /* Mask 0 */ in lpfc_sli_setup()
10682 pring->prt[0].rctl = FC_RCTL_ELS_REQ; in lpfc_sli_setup()
10683 pring->prt[0].type = FC_TYPE_ELS; in lpfc_sli_setup()
10684 pring->prt[0].lpfc_sli_rcv_unsol_event = in lpfc_sli_setup()
10686 pring->prt[1].profile = 0; /* Mask 1 */ in lpfc_sli_setup()
10687 pring->prt[1].rctl = FC_RCTL_ELS_REP; in lpfc_sli_setup()
10688 pring->prt[1].type = FC_TYPE_ELS; in lpfc_sli_setup()
10689 pring->prt[1].lpfc_sli_rcv_unsol_event = in lpfc_sli_setup()
10691 pring->prt[2].profile = 0; /* Mask 2 */ in lpfc_sli_setup()
10693 pring->prt[2].rctl = FC_RCTL_DD_UNSOL_CTL; in lpfc_sli_setup()
10695 pring->prt[2].type = FC_TYPE_CT; in lpfc_sli_setup()
10696 pring->prt[2].lpfc_sli_rcv_unsol_event = in lpfc_sli_setup()
10698 pring->prt[3].profile = 0; /* Mask 3 */ in lpfc_sli_setup()
10700 pring->prt[3].rctl = FC_RCTL_DD_SOL_CTL; in lpfc_sli_setup()
10702 pring->prt[3].type = FC_TYPE_CT; in lpfc_sli_setup()
10703 pring->prt[3].lpfc_sli_rcv_unsol_event = in lpfc_sli_setup()
10707 totiocbsize += (pring->sli.sli3.numCiocb * in lpfc_sli_setup()
10708 pring->sli.sli3.sizeCiocb) + in lpfc_sli_setup()
10709 (pring->sli.sli3.numRiocb * pring->sli.sli3.sizeRiocb); in lpfc_sli_setup()
10715 phba->brd_no, totiocbsize, in lpfc_sli_setup()
10718 if (phba->cfg_multi_ring_support == 2) in lpfc_sli_setup()
10725 * lpfc_sli4_queue_init - Queue initialization function
10728 * lpfc_sli4_queue_init sets up mailbox queues and iocb queues for each
10742 psli = &phba->sli; in lpfc_sli4_queue_init()
10743 spin_lock_irq(&phba->hbalock); in lpfc_sli4_queue_init()
10744 INIT_LIST_HEAD(&psli->mboxq); in lpfc_sli4_queue_init()
10745 INIT_LIST_HEAD(&psli->mboxq_cmpl); in lpfc_sli4_queue_init()
10747 for (i = 0; i < phba->cfg_hdw_queue; i++) { in lpfc_sli4_queue_init()
10748 pring = phba->sli4_hba.hdwq[i].io_wq->pring; in lpfc_sli4_queue_init()
10749 pring->flag = 0; in lpfc_sli4_queue_init()
10750 pring->ringno = LPFC_FCP_RING; in lpfc_sli4_queue_init()
10751 pring->txcmplq_cnt = 0; in lpfc_sli4_queue_init()
10752 INIT_LIST_HEAD(&pring->txq); in lpfc_sli4_queue_init()
10753 INIT_LIST_HEAD(&pring->txcmplq); in lpfc_sli4_queue_init()
10754 INIT_LIST_HEAD(&pring->iocb_continueq); in lpfc_sli4_queue_init()
10755 spin_lock_init(&pring->ring_lock); in lpfc_sli4_queue_init()
10757 pring = phba->sli4_hba.els_wq->pring; in lpfc_sli4_queue_init()
10758 pring->flag = 0; in lpfc_sli4_queue_init()
10759 pring->ringno = LPFC_ELS_RING; in lpfc_sli4_queue_init()
10760 pring->txcmplq_cnt = 0; in lpfc_sli4_queue_init()
10761 INIT_LIST_HEAD(&pring->txq); in lpfc_sli4_queue_init()
10762 INIT_LIST_HEAD(&pring->txcmplq); in lpfc_sli4_queue_init()
10763 INIT_LIST_HEAD(&pring->iocb_continueq); in lpfc_sli4_queue_init()
10764 spin_lock_init(&pring->ring_lock); in lpfc_sli4_queue_init()
10766 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_queue_init()
10767 pring = phba->sli4_hba.nvmels_wq->pring; in lpfc_sli4_queue_init()
10768 pring->flag = 0; in lpfc_sli4_queue_init()
10769 pring->ringno = LPFC_ELS_RING; in lpfc_sli4_queue_init()
10770 pring->txcmplq_cnt = 0; in lpfc_sli4_queue_init()
10771 INIT_LIST_HEAD(&pring->txq); in lpfc_sli4_queue_init()
10772 INIT_LIST_HEAD(&pring->txcmplq); in lpfc_sli4_queue_init()
10773 INIT_LIST_HEAD(&pring->iocb_continueq); in lpfc_sli4_queue_init()
10774 spin_lock_init(&pring->ring_lock); in lpfc_sli4_queue_init()
10777 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_queue_init()
10781 * lpfc_sli_queue_init - Queue initialization function
10784 * lpfc_sli_queue_init sets up mailbox queues and iocb queues for each
10798 psli = &phba->sli; in lpfc_sli_queue_init()
10799 spin_lock_irq(&phba->hbalock); in lpfc_sli_queue_init()
10800 INIT_LIST_HEAD(&psli->mboxq); in lpfc_sli_queue_init()
10801 INIT_LIST_HEAD(&psli->mboxq_cmpl); in lpfc_sli_queue_init()
10803 for (i = 0; i < psli->num_rings; i++) { in lpfc_sli_queue_init()
10804 pring = &psli->sli3_ring[i]; in lpfc_sli_queue_init()
10805 pring->ringno = i; in lpfc_sli_queue_init()
10806 pring->sli.sli3.next_cmdidx = 0; in lpfc_sli_queue_init()
10807 pring->sli.sli3.local_getidx = 0; in lpfc_sli_queue_init()
10808 pring->sli.sli3.cmdidx = 0; in lpfc_sli_queue_init()
10809 INIT_LIST_HEAD(&pring->iocb_continueq); in lpfc_sli_queue_init()
10810 INIT_LIST_HEAD(&pring->iocb_continue_saveq); in lpfc_sli_queue_init()
10811 INIT_LIST_HEAD(&pring->postbufq); in lpfc_sli_queue_init()
10812 pring->flag = 0; in lpfc_sli_queue_init()
10813 INIT_LIST_HEAD(&pring->txq); in lpfc_sli_queue_init()
10814 INIT_LIST_HEAD(&pring->txcmplq); in lpfc_sli_queue_init()
10815 spin_lock_init(&pring->ring_lock); in lpfc_sli_queue_init()
10817 spin_unlock_irq(&phba->hbalock); in lpfc_sli_queue_init()
10821 * lpfc_sli_mbox_sys_flush - Flush mailbox command sub-system
10824 * This routine flushes the mailbox command subsystem. It will unconditionally
10825 * flush all the mailbox commands in the three possible stages in the mailbox
10826 * command sub-system: pending mailbox command queue; the outstanding mailbox
10827 * command; and completed mailbox command queue. It is caller's responsibility
10828 * to make sure that the driver is in the proper state to flush the mailbox
10829 * command sub-system. Namely, the posting of mailbox commands into the
10830 * pending mailbox command queue from the various clients must be stopped;
10832 * mailbox command (such as in EEH or ERATT conditions) or the outstanding
10833 * mailbox command has been completed.
10839 struct lpfc_sli *psli = &phba->sli; in lpfc_sli_mbox_sys_flush()
10843 /* Disable softirqs, including timers from obtaining phba->hbalock */ in lpfc_sli_mbox_sys_flush()
10846 /* Flush all the mailbox commands in the mbox system */ in lpfc_sli_mbox_sys_flush()
10847 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_mbox_sys_flush()
10849 /* The pending mailbox command queue */ in lpfc_sli_mbox_sys_flush()
10850 list_splice_init(&phba->sli.mboxq, &completions); in lpfc_sli_mbox_sys_flush()
10851 /* The outstanding active mailbox command */ in lpfc_sli_mbox_sys_flush()
10852 if (psli->mbox_active) { in lpfc_sli_mbox_sys_flush()
10853 list_add_tail(&psli->mbox_active->list, &completions); in lpfc_sli_mbox_sys_flush()
10854 psli->mbox_active = NULL; in lpfc_sli_mbox_sys_flush()
10855 psli->sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; in lpfc_sli_mbox_sys_flush()
10857 /* The completed mailbox command queue */ in lpfc_sli_mbox_sys_flush()
10858 list_splice_init(&phba->sli.mboxq_cmpl, &completions); in lpfc_sli_mbox_sys_flush()
10859 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_mbox_sys_flush()
10861 /* Enable softirqs again, done with phba->hbalock */ in lpfc_sli_mbox_sys_flush()
10864 /* Return all flushed mailbox commands with MBX_NOT_FINISHED status */ in lpfc_sli_mbox_sys_flush()
10867 pmb->u.mb.mbxStatus = MBX_NOT_FINISHED; in lpfc_sli_mbox_sys_flush()
10868 if (pmb->mbox_cmpl) in lpfc_sli_mbox_sys_flush()
10869 pmb->mbox_cmpl(phba, pmb); in lpfc_sli_mbox_sys_flush()
10874 * lpfc_sli_host_down - Vport cleanup function
10881 * - Free discovery resources associated with this virtual
10883 * - Free iocbs associated with this virtual port in
10885 * - Send abort for all iocb commands associated with this
10894 struct lpfc_hba *phba = vport->phba; in lpfc_sli_host_down()
10895 struct lpfc_sli *psli = &phba->sli; in lpfc_sli_host_down()
10905 spin_lock_irqsave(&phba->hbalock, flags); in lpfc_sli_host_down()
10912 if (phba->sli_rev != LPFC_SLI_REV4) { in lpfc_sli_host_down()
10913 for (i = 0; i < psli->num_rings; i++) { in lpfc_sli_host_down()
10914 pring = &psli->sli3_ring[i]; in lpfc_sli_host_down()
10915 prev_pring_flag = pring->flag; in lpfc_sli_host_down()
10917 if (pring->ringno == LPFC_ELS_RING) { in lpfc_sli_host_down()
10918 pring->flag |= LPFC_DEFERRED_RING_EVENT; in lpfc_sli_host_down()
10920 set_bit(LPFC_DATA_READY, &phba->data_flags); in lpfc_sli_host_down()
10923 &pring->txq, list) { in lpfc_sli_host_down()
10924 if (iocb->vport != vport) in lpfc_sli_host_down()
10926 list_move_tail(&iocb->list, &completions); in lpfc_sli_host_down()
10929 &pring->txcmplq, list) { in lpfc_sli_host_down()
10930 if (iocb->vport != vport) in lpfc_sli_host_down()
10934 pring->flag = prev_pring_flag; in lpfc_sli_host_down()
10937 list_for_each_entry(qp, &phba->sli4_hba.lpfc_wq_list, wq_list) { in lpfc_sli_host_down()
10938 pring = qp->pring; in lpfc_sli_host_down()
10941 if (pring == phba->sli4_hba.els_wq->pring) { in lpfc_sli_host_down()
10942 pring->flag |= LPFC_DEFERRED_RING_EVENT; in lpfc_sli_host_down()
10944 set_bit(LPFC_DATA_READY, &phba->data_flags); in lpfc_sli_host_down()
10946 prev_pring_flag = pring->flag; in lpfc_sli_host_down()
10947 spin_lock(&pring->ring_lock); in lpfc_sli_host_down()
10949 &pring->txq, list) { in lpfc_sli_host_down()
10950 if (iocb->vport != vport) in lpfc_sli_host_down()
10952 list_move_tail(&iocb->list, &completions); in lpfc_sli_host_down()
10954 spin_unlock(&pring->ring_lock); in lpfc_sli_host_down()
10956 &pring->txcmplq, list) { in lpfc_sli_host_down()
10957 if (iocb->vport != vport) in lpfc_sli_host_down()
10961 pring->flag = prev_pring_flag; in lpfc_sli_host_down()
10964 spin_unlock_irqrestore(&phba->hbalock, flags); in lpfc_sli_host_down()
10973 * lpfc_sli_hba_down - Resource cleanup function for the HBA
10976 * This function cleans up all iocb, buffers, mailbox commands
10980 * - Free discovery resources for each virtual port
10981 * - Cleanup any pending fabric iocbs
10982 * - Iterate through the iocb txq and free each entry
10984 * - Free up any buffer posted to the HBA
10985 * - Free mailbox commands in the mailbox queue.
10991 struct lpfc_sli *psli = &phba->sli; in lpfc_sli_hba_down()
10998 /* Shutdown the mailbox command sub-system */ in lpfc_sli_hba_down()
11003 /* Disable softirqs, including timers from obtaining phba->hbalock */ in lpfc_sli_hba_down()
11008 spin_lock_irqsave(&phba->hbalock, flags); in lpfc_sli_hba_down()
11014 if (phba->sli_rev != LPFC_SLI_REV4) { in lpfc_sli_hba_down()
11015 for (i = 0; i < psli->num_rings; i++) { in lpfc_sli_hba_down()
11016 pring = &psli->sli3_ring[i]; in lpfc_sli_hba_down()
11018 if (pring->ringno == LPFC_ELS_RING) { in lpfc_sli_hba_down()
11019 pring->flag |= LPFC_DEFERRED_RING_EVENT; in lpfc_sli_hba_down()
11021 set_bit(LPFC_DATA_READY, &phba->data_flags); in lpfc_sli_hba_down()
11023 list_splice_init(&pring->txq, &completions); in lpfc_sli_hba_down()
11026 list_for_each_entry(qp, &phba->sli4_hba.lpfc_wq_list, wq_list) { in lpfc_sli_hba_down()
11027 pring = qp->pring; in lpfc_sli_hba_down()
11030 spin_lock(&pring->ring_lock); in lpfc_sli_hba_down()
11031 list_splice_init(&pring->txq, &completions); in lpfc_sli_hba_down()
11032 spin_unlock(&pring->ring_lock); in lpfc_sli_hba_down()
11033 if (pring == phba->sli4_hba.els_wq->pring) { in lpfc_sli_hba_down()
11034 pring->flag |= LPFC_DEFERRED_RING_EVENT; in lpfc_sli_hba_down()
11036 set_bit(LPFC_DATA_READY, &phba->data_flags); in lpfc_sli_hba_down()
11040 spin_unlock_irqrestore(&phba->hbalock, flags); in lpfc_sli_hba_down()
11046 spin_lock_irqsave(&phba->hbalock, flags); in lpfc_sli_hba_down()
11047 list_splice_init(&phba->elsbuf, &completions); in lpfc_sli_hba_down()
11048 phba->elsbuf_cnt = 0; in lpfc_sli_hba_down()
11049 phba->elsbuf_prev_cnt = 0; in lpfc_sli_hba_down()
11050 spin_unlock_irqrestore(&phba->hbalock, flags); in lpfc_sli_hba_down()
11055 lpfc_mbuf_free(phba, buf_ptr->virt, buf_ptr->phys); in lpfc_sli_hba_down()
11059 /* Enable softirqs again, done with phba->hbalock */ in lpfc_sli_hba_down()
11063 del_timer_sync(&psli->mbox_tmo); in lpfc_sli_hba_down()
11065 spin_lock_irqsave(&phba->pport->work_port_lock, flags); in lpfc_sli_hba_down()
11066 phba->pport->work_port_events &= ~WORKER_MBOX_TMO; in lpfc_sli_hba_down()
11067 spin_unlock_irqrestore(&phba->pport->work_port_lock, flags); in lpfc_sli_hba_down()
11073 * lpfc_sli_pcimem_bcopy - SLI memory copy function
11103 * lpfc_sli_bemem_bcopy - SLI memory copy function
11130 * lpfc_sli_ringpostbuf_put - Function to add a buffer to postbufq
11145 spin_lock_irq(&phba->hbalock); in lpfc_sli_ringpostbuf_put()
11146 list_add_tail(&mp->list, &pring->postbufq); in lpfc_sli_ringpostbuf_put()
11147 pring->postbufq_cnt++; in lpfc_sli_ringpostbuf_put()
11148 spin_unlock_irq(&phba->hbalock); in lpfc_sli_ringpostbuf_put()
11153 * lpfc_sli_get_buffer_tag - allocates a tag for a CMD_QUE_XRI64_CX buffer
11158 * tag is bit wise or-ed with QUE_BUFTAG_BIT to make sure that the tag
11166 spin_lock_irq(&phba->hbalock); in lpfc_sli_get_buffer_tag()
11167 phba->buffer_tag_count++; in lpfc_sli_get_buffer_tag()
11172 phba->buffer_tag_count |= QUE_BUFTAG_BIT; in lpfc_sli_get_buffer_tag()
11173 spin_unlock_irq(&phba->hbalock); in lpfc_sli_get_buffer_tag()
11174 return phba->buffer_tag_count; in lpfc_sli_get_buffer_tag()
11178 * lpfc_sli_ring_taggedbuf_get - find HBQ buffer associated with given tag
11183 * Buffers posted using CMD_QUE_XRI64_CX iocb are in pring->postbufq
11186 * This function searches the pring->postbufq list using the tag
11197 struct list_head *slp = &pring->postbufq; in lpfc_sli_ring_taggedbuf_get()
11200 spin_lock_irq(&phba->hbalock); in lpfc_sli_ring_taggedbuf_get()
11201 list_for_each_entry_safe(mp, next_mp, &pring->postbufq, list) { in lpfc_sli_ring_taggedbuf_get()
11202 if (mp->buffer_tag == tag) { in lpfc_sli_ring_taggedbuf_get()
11203 list_del_init(&mp->list); in lpfc_sli_ring_taggedbuf_get()
11204 pring->postbufq_cnt--; in lpfc_sli_ring_taggedbuf_get()
11205 spin_unlock_irq(&phba->hbalock); in lpfc_sli_ring_taggedbuf_get()
11210 spin_unlock_irq(&phba->hbalock); in lpfc_sli_ring_taggedbuf_get()
11214 pring->ringno, (unsigned long) tag, in lpfc_sli_ring_taggedbuf_get()
11215 slp->next, slp->prev, pring->postbufq_cnt); in lpfc_sli_ring_taggedbuf_get()
11221 * lpfc_sli_ringpostbuf_get - search buffers for unsolicited CT and ELS events
11241 struct list_head *slp = &pring->postbufq; in lpfc_sli_ringpostbuf_get()
11244 spin_lock_irq(&phba->hbalock); in lpfc_sli_ringpostbuf_get()
11245 list_for_each_entry_safe(mp, next_mp, &pring->postbufq, list) { in lpfc_sli_ringpostbuf_get()
11246 if (mp->phys == phys) { in lpfc_sli_ringpostbuf_get()
11247 list_del_init(&mp->list); in lpfc_sli_ringpostbuf_get()
11248 pring->postbufq_cnt--; in lpfc_sli_ringpostbuf_get()
11249 spin_unlock_irq(&phba->hbalock); in lpfc_sli_ringpostbuf_get()
11254 spin_unlock_irq(&phba->hbalock); in lpfc_sli_ringpostbuf_get()
11258 pring->ringno, (unsigned long long)phys, in lpfc_sli_ringpostbuf_get()
11259 slp->next, slp->prev, pring->postbufq_cnt); in lpfc_sli_ringpostbuf_get()
11264 * lpfc_sli_abort_els_cmpl - Completion handler for the els abort iocbs
11278 IOCB_t *irsp = &rspiocb->iocb; in lpfc_sli_abort_els_cmpl()
11282 if (irsp->ulpStatus) { in lpfc_sli_abort_els_cmpl()
11288 abort_context = cmdiocb->iocb.un.acxri.abortContextTag; in lpfc_sli_abort_els_cmpl()
11289 abort_iotag = cmdiocb->iocb.un.acxri.abortIoTag; in lpfc_sli_abort_els_cmpl()
11291 spin_lock_irq(&phba->hbalock); in lpfc_sli_abort_els_cmpl()
11292 if (phba->sli_rev < LPFC_SLI_REV4) { in lpfc_sli_abort_els_cmpl()
11293 if (irsp->ulpCommand == CMD_ABORT_XRI_CX && in lpfc_sli_abort_els_cmpl()
11294 irsp->ulpStatus == IOSTAT_LOCAL_REJECT && in lpfc_sli_abort_els_cmpl()
11295 irsp->un.ulpWord[4] == IOERR_ABORT_REQUESTED) { in lpfc_sli_abort_els_cmpl()
11296 spin_unlock_irq(&phba->hbalock); in lpfc_sli_abort_els_cmpl()
11300 abort_iotag <= phba->sli.last_iotag) in lpfc_sli_abort_els_cmpl()
11302 phba->sli.iocbq_lookup[abort_iotag]; in lpfc_sli_abort_els_cmpl()
11309 abort_iocb = phba->sli.iocbq_lookup[abort_context]; in lpfc_sli_abort_els_cmpl()
11316 irsp->ulpStatus, irsp->un.ulpWord[4]); in lpfc_sli_abort_els_cmpl()
11318 spin_unlock_irq(&phba->hbalock); in lpfc_sli_abort_els_cmpl()
11326 * lpfc_ignore_els_cmpl - Completion handler for aborted ELS command
11340 IOCB_t *irsp = &rspiocb->iocb; in lpfc_ignore_els_cmpl()
11346 irsp->ulpIoTag, irsp->ulpStatus, in lpfc_ignore_els_cmpl()
11347 irsp->un.ulpWord[4], irsp->ulpTimeout); in lpfc_ignore_els_cmpl()
11348 if (cmdiocb->iocb.ulpCommand == CMD_GEN_REQUEST64_CR) in lpfc_ignore_els_cmpl()
11356 * lpfc_sli_abort_iotag_issue - Issue abort for a command iocb
11372 struct lpfc_vport *vport = cmdiocb->vport; in lpfc_sli_abort_iotag_issue()
11385 icmd = &cmdiocb->iocb; in lpfc_sli_abort_iotag_issue()
11386 if (icmd->ulpCommand == CMD_ABORT_XRI_CN || in lpfc_sli_abort_iotag_issue()
11387 icmd->ulpCommand == CMD_CLOSE_XRI_CN || in lpfc_sli_abort_iotag_issue()
11388 (cmdiocb->iocb_flag & LPFC_DRIVER_ABORTED) != 0) in lpfc_sli_abort_iotag_issue()
11399 cmdiocb->iocb_flag |= LPFC_DRIVER_ABORTED; in lpfc_sli_abort_iotag_issue()
11401 iabt = &abtsiocbp->iocb; in lpfc_sli_abort_iotag_issue()
11402 iabt->un.acxri.abortType = ABORT_TYPE_ABTS; in lpfc_sli_abort_iotag_issue()
11403 iabt->un.acxri.abortContextTag = icmd->ulpContext; in lpfc_sli_abort_iotag_issue()
11404 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_sli_abort_iotag_issue()
11405 iabt->un.acxri.abortIoTag = cmdiocb->sli4_xritag; in lpfc_sli_abort_iotag_issue()
11406 iabt->un.acxri.abortContextTag = cmdiocb->iotag; in lpfc_sli_abort_iotag_issue()
11408 iabt->un.acxri.abortIoTag = icmd->ulpIoTag; in lpfc_sli_abort_iotag_issue()
11409 if (pring->ringno == LPFC_ELS_RING) { in lpfc_sli_abort_iotag_issue()
11410 ndlp = (struct lpfc_nodelist *)(cmdiocb->context1); in lpfc_sli_abort_iotag_issue()
11411 iabt->un.acxri.abortContextTag = ndlp->nlp_rpi; in lpfc_sli_abort_iotag_issue()
11414 iabt->ulpLe = 1; in lpfc_sli_abort_iotag_issue()
11415 iabt->ulpClass = icmd->ulpClass; in lpfc_sli_abort_iotag_issue()
11418 abtsiocbp->hba_wqidx = cmdiocb->hba_wqidx; in lpfc_sli_abort_iotag_issue()
11419 if (cmdiocb->iocb_flag & LPFC_IO_FCP) in lpfc_sli_abort_iotag_issue()
11420 abtsiocbp->iocb_flag |= LPFC_USE_FCPWQIDX; in lpfc_sli_abort_iotag_issue()
11421 if (cmdiocb->iocb_flag & LPFC_IO_FOF) in lpfc_sli_abort_iotag_issue()
11422 abtsiocbp->iocb_flag |= LPFC_IO_FOF; in lpfc_sli_abort_iotag_issue()
11424 if (phba->link_state >= LPFC_LINK_UP) in lpfc_sli_abort_iotag_issue()
11425 iabt->ulpCommand = CMD_ABORT_XRI_CN; in lpfc_sli_abort_iotag_issue()
11427 iabt->ulpCommand = CMD_CLOSE_XRI_CN; in lpfc_sli_abort_iotag_issue()
11429 abtsiocbp->iocb_cmpl = lpfc_sli_abort_els_cmpl; in lpfc_sli_abort_iotag_issue()
11430 abtsiocbp->vport = vport; in lpfc_sli_abort_iotag_issue()
11435 iabt->un.acxri.abortIoTag, in lpfc_sli_abort_iotag_issue()
11436 iabt->un.acxri.abortContextTag, in lpfc_sli_abort_iotag_issue()
11437 abtsiocbp->iotag); in lpfc_sli_abort_iotag_issue()
11439 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_sli_abort_iotag_issue()
11444 spin_lock_irqsave(&pring->ring_lock, iflags); in lpfc_sli_abort_iotag_issue()
11445 retval = __lpfc_sli_issue_iocb(phba, pring->ringno, in lpfc_sli_abort_iotag_issue()
11447 spin_unlock_irqrestore(&pring->ring_lock, iflags); in lpfc_sli_abort_iotag_issue()
11449 retval = __lpfc_sli_issue_iocb(phba, pring->ringno, in lpfc_sli_abort_iotag_issue()
11465 * lpfc_sli_issue_abort_iotag - Abort function for a command iocb
11481 struct lpfc_vport *vport = cmdiocb->vport; in lpfc_sli_issue_abort_iotag()
11485 lockdep_assert_held(&phba->hbalock); in lpfc_sli_issue_abort_iotag()
11492 icmd = &cmdiocb->iocb; in lpfc_sli_issue_abort_iotag()
11493 if (icmd->ulpCommand == CMD_ABORT_XRI_CN || in lpfc_sli_issue_abort_iotag()
11494 icmd->ulpCommand == CMD_CLOSE_XRI_CN || in lpfc_sli_issue_abort_iotag()
11495 (cmdiocb->iocb_flag & LPFC_DRIVER_ABORTED) != 0) in lpfc_sli_issue_abort_iotag()
11499 if (cmdiocb->iocb_flag & LPFC_IO_FABRIC) in lpfc_sli_issue_abort_iotag()
11500 cmdiocb->fabric_iocb_cmpl = lpfc_ignore_els_cmpl; in lpfc_sli_issue_abort_iotag()
11502 cmdiocb->iocb_cmpl = lpfc_ignore_els_cmpl; in lpfc_sli_issue_abort_iotag()
11510 if ((vport->load_flag & FC_UNLOADING) && in lpfc_sli_issue_abort_iotag()
11511 (pring->ringno == LPFC_ELS_RING)) { in lpfc_sli_issue_abort_iotag()
11512 if (cmdiocb->iocb_flag & LPFC_IO_FABRIC) in lpfc_sli_issue_abort_iotag()
11513 cmdiocb->fabric_iocb_cmpl = lpfc_ignore_els_cmpl; in lpfc_sli_issue_abort_iotag()
11515 cmdiocb->iocb_cmpl = lpfc_ignore_els_cmpl; in lpfc_sli_issue_abort_iotag()
11532 * lpfc_sli_hba_iocb_abort - Abort all iocbs to an hba.
11540 struct lpfc_sli *psli = &phba->sli; in lpfc_sli_hba_iocb_abort()
11545 if (phba->sli_rev != LPFC_SLI_REV4) { in lpfc_sli_hba_iocb_abort()
11546 for (i = 0; i < psli->num_rings; i++) { in lpfc_sli_hba_iocb_abort()
11547 pring = &psli->sli3_ring[i]; in lpfc_sli_hba_iocb_abort()
11552 list_for_each_entry(qp, &phba->sli4_hba.lpfc_wq_list, wq_list) { in lpfc_sli_hba_iocb_abort()
11553 pring = qp->pring; in lpfc_sli_hba_iocb_abort()
11561 * lpfc_sli_validate_fcp_iocb - find commands associated with a vport or LUN
11591 if (iocbq->vport != vport) in lpfc_sli_validate_fcp_iocb()
11594 if (!(iocbq->iocb_flag & LPFC_IO_FCP) || in lpfc_sli_validate_fcp_iocb()
11595 !(iocbq->iocb_flag & LPFC_IO_ON_TXCMPLQ) || in lpfc_sli_validate_fcp_iocb()
11596 iocbq->iocb_flag & LPFC_DRIVER_ABORTED) in lpfc_sli_validate_fcp_iocb()
11599 icmd = &iocbq->iocb; in lpfc_sli_validate_fcp_iocb()
11600 if (icmd->ulpCommand == CMD_ABORT_XRI_CN || in lpfc_sli_validate_fcp_iocb()
11601 icmd->ulpCommand == CMD_CLOSE_XRI_CN) in lpfc_sli_validate_fcp_iocb()
11606 if (lpfc_cmd->pCmd == NULL) in lpfc_sli_validate_fcp_iocb()
11611 if ((lpfc_cmd->rdata) && (lpfc_cmd->rdata->pnode) && in lpfc_sli_validate_fcp_iocb()
11612 (lpfc_cmd->rdata->pnode->nlp_sid == tgt_id) && in lpfc_sli_validate_fcp_iocb()
11613 (scsilun_to_int(&lpfc_cmd->fcp_cmnd->fcp_lun) == lun_id)) in lpfc_sli_validate_fcp_iocb()
11617 if ((lpfc_cmd->rdata) && (lpfc_cmd->rdata->pnode) && in lpfc_sli_validate_fcp_iocb()
11618 (lpfc_cmd->rdata->pnode->nlp_sid == tgt_id)) in lpfc_sli_validate_fcp_iocb()
11634 * lpfc_sli_sum_iocb - Function to count the number of FCP iocbs pending
11656 struct lpfc_hba *phba = vport->phba; in lpfc_sli_sum_iocb()
11660 spin_lock_irq(&phba->hbalock); in lpfc_sli_sum_iocb()
11661 for (i = 1, sum = 0; i <= phba->sli.last_iotag; i++) { in lpfc_sli_sum_iocb()
11662 iocbq = phba->sli.iocbq_lookup[i]; in lpfc_sli_sum_iocb()
11668 spin_unlock_irq(&phba->hbalock); in lpfc_sli_sum_iocb()
11674 * lpfc_sli_abort_fcp_cmpl - Completion handler function for aborted FCP IOCBs
11691 cmdiocb->iocb.un.acxri.abortContextTag, in lpfc_sli_abort_fcp_cmpl()
11692 cmdiocb->iocb.un.acxri.abortIoTag, in lpfc_sli_abort_fcp_cmpl()
11693 cmdiocb->iotag, rspiocb->iocb.ulpStatus, in lpfc_sli_abort_fcp_cmpl()
11694 rspiocb->iocb.un.ulpWord[4]); in lpfc_sli_abort_fcp_cmpl()
11700 * lpfc_sli_abort_iocb - issue abort for all commands on a host/target/LUN
11724 struct lpfc_hba *phba = vport->phba; in lpfc_sli_abort_iocb()
11733 if (phba->hba_flag & HBA_IOQ_FLUSH) in lpfc_sli_abort_iocb()
11736 for (i = 1; i <= phba->sli.last_iotag; i++) { in lpfc_sli_abort_iocb()
11737 iocbq = phba->sli.iocbq_lookup[i]; in lpfc_sli_abort_iocb()
11747 if (iocbq->iocb_flag & LPFC_DRIVER_ABORTED) in lpfc_sli_abort_iocb()
11758 iocbq->iocb_flag |= LPFC_DRIVER_ABORTED; in lpfc_sli_abort_iocb()
11760 cmd = &iocbq->iocb; in lpfc_sli_abort_iocb()
11761 abtsiocb->iocb.un.acxri.abortType = ABORT_TYPE_ABTS; in lpfc_sli_abort_iocb()
11762 abtsiocb->iocb.un.acxri.abortContextTag = cmd->ulpContext; in lpfc_sli_abort_iocb()
11763 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_sli_abort_iocb()
11764 abtsiocb->iocb.un.acxri.abortIoTag = iocbq->sli4_xritag; in lpfc_sli_abort_iocb()
11766 abtsiocb->iocb.un.acxri.abortIoTag = cmd->ulpIoTag; in lpfc_sli_abort_iocb()
11767 abtsiocb->iocb.ulpLe = 1; in lpfc_sli_abort_iocb()
11768 abtsiocb->iocb.ulpClass = cmd->ulpClass; in lpfc_sli_abort_iocb()
11769 abtsiocb->vport = vport; in lpfc_sli_abort_iocb()
11772 abtsiocb->hba_wqidx = iocbq->hba_wqidx; in lpfc_sli_abort_iocb()
11773 if (iocbq->iocb_flag & LPFC_IO_FCP) in lpfc_sli_abort_iocb()
11774 abtsiocb->iocb_flag |= LPFC_USE_FCPWQIDX; in lpfc_sli_abort_iocb()
11775 if (iocbq->iocb_flag & LPFC_IO_FOF) in lpfc_sli_abort_iocb()
11776 abtsiocb->iocb_flag |= LPFC_IO_FOF; in lpfc_sli_abort_iocb()
11779 abtsiocb->iocb.ulpCommand = CMD_ABORT_XRI_CN; in lpfc_sli_abort_iocb()
11781 abtsiocb->iocb.ulpCommand = CMD_CLOSE_XRI_CN; in lpfc_sli_abort_iocb()
11784 abtsiocb->iocb_cmpl = lpfc_sli_abort_fcp_cmpl; in lpfc_sli_abort_iocb()
11785 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_sli_abort_iocb()
11789 ret_val = lpfc_sli_issue_iocb(phba, pring_s4->ringno, in lpfc_sli_abort_iocb()
11792 ret_val = lpfc_sli_issue_iocb(phba, pring->ringno, in lpfc_sli_abort_iocb()
11805 * lpfc_sli_abort_taskmgmt - issue abort for all commands on a host/target/LUN
11830 struct lpfc_hba *phba = vport->phba; in lpfc_sli_abort_taskmgmt()
11840 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli_abort_taskmgmt()
11843 if (phba->hba_flag & HBA_IOQ_FLUSH) { in lpfc_sli_abort_taskmgmt()
11844 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli_abort_taskmgmt()
11849 for (i = 1; i <= phba->sli.last_iotag; i++) { in lpfc_sli_abort_taskmgmt()
11850 iocbq = phba->sli.iocbq_lookup[i]; in lpfc_sli_abort_taskmgmt()
11858 spin_lock(&lpfc_cmd->buf_lock); in lpfc_sli_abort_taskmgmt()
11860 if (!lpfc_cmd->pCmd) { in lpfc_sli_abort_taskmgmt()
11861 spin_unlock(&lpfc_cmd->buf_lock); in lpfc_sli_abort_taskmgmt()
11865 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_sli_abort_taskmgmt()
11867 phba->sli4_hba.hdwq[iocbq->hba_wqidx].io_wq->pring; in lpfc_sli_abort_taskmgmt()
11869 spin_unlock(&lpfc_cmd->buf_lock); in lpfc_sli_abort_taskmgmt()
11873 spin_lock(&pring_s4->ring_lock); in lpfc_sli_abort_taskmgmt()
11880 if ((iocbq->iocb_flag & LPFC_DRIVER_ABORTED) || in lpfc_sli_abort_taskmgmt()
11881 !(iocbq->iocb_flag & LPFC_IO_ON_TXCMPLQ)) { in lpfc_sli_abort_taskmgmt()
11882 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_sli_abort_taskmgmt()
11883 spin_unlock(&pring_s4->ring_lock); in lpfc_sli_abort_taskmgmt()
11884 spin_unlock(&lpfc_cmd->buf_lock); in lpfc_sli_abort_taskmgmt()
11891 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_sli_abort_taskmgmt()
11892 spin_unlock(&pring_s4->ring_lock); in lpfc_sli_abort_taskmgmt()
11893 spin_unlock(&lpfc_cmd->buf_lock); in lpfc_sli_abort_taskmgmt()
11897 icmd = &iocbq->iocb; in lpfc_sli_abort_taskmgmt()
11898 abtsiocbq->iocb.un.acxri.abortType = ABORT_TYPE_ABTS; in lpfc_sli_abort_taskmgmt()
11899 abtsiocbq->iocb.un.acxri.abortContextTag = icmd->ulpContext; in lpfc_sli_abort_taskmgmt()
11900 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_sli_abort_taskmgmt()
11901 abtsiocbq->iocb.un.acxri.abortIoTag = in lpfc_sli_abort_taskmgmt()
11902 iocbq->sli4_xritag; in lpfc_sli_abort_taskmgmt()
11904 abtsiocbq->iocb.un.acxri.abortIoTag = icmd->ulpIoTag; in lpfc_sli_abort_taskmgmt()
11905 abtsiocbq->iocb.ulpLe = 1; in lpfc_sli_abort_taskmgmt()
11906 abtsiocbq->iocb.ulpClass = icmd->ulpClass; in lpfc_sli_abort_taskmgmt()
11907 abtsiocbq->vport = vport; in lpfc_sli_abort_taskmgmt()
11910 abtsiocbq->hba_wqidx = iocbq->hba_wqidx; in lpfc_sli_abort_taskmgmt()
11911 if (iocbq->iocb_flag & LPFC_IO_FCP) in lpfc_sli_abort_taskmgmt()
11912 abtsiocbq->iocb_flag |= LPFC_USE_FCPWQIDX; in lpfc_sli_abort_taskmgmt()
11913 if (iocbq->iocb_flag & LPFC_IO_FOF) in lpfc_sli_abort_taskmgmt()
11914 abtsiocbq->iocb_flag |= LPFC_IO_FOF; in lpfc_sli_abort_taskmgmt()
11916 ndlp = lpfc_cmd->rdata->pnode; in lpfc_sli_abort_taskmgmt()
11919 (ndlp && ndlp->nlp_state == NLP_STE_MAPPED_NODE)) in lpfc_sli_abort_taskmgmt()
11920 abtsiocbq->iocb.ulpCommand = CMD_ABORT_XRI_CN; in lpfc_sli_abort_taskmgmt()
11922 abtsiocbq->iocb.ulpCommand = CMD_CLOSE_XRI_CN; in lpfc_sli_abort_taskmgmt()
11925 abtsiocbq->iocb_cmpl = lpfc_sli_abort_fcp_cmpl; in lpfc_sli_abort_taskmgmt()
11931 iocbq->iocb_flag |= LPFC_DRIVER_ABORTED; in lpfc_sli_abort_taskmgmt()
11933 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_sli_abort_taskmgmt()
11934 ret_val = __lpfc_sli_issue_iocb(phba, pring_s4->ringno, in lpfc_sli_abort_taskmgmt()
11936 spin_unlock(&pring_s4->ring_lock); in lpfc_sli_abort_taskmgmt()
11938 ret_val = __lpfc_sli_issue_iocb(phba, pring->ringno, in lpfc_sli_abort_taskmgmt()
11942 spin_unlock(&lpfc_cmd->buf_lock); in lpfc_sli_abort_taskmgmt()
11949 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli_abort_taskmgmt()
11954 * lpfc_sli_wake_iocb_wait - lpfc_sli_issue_iocb_wait's completion handler
11979 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli_wake_iocb_wait()
11980 if (cmdiocbq->iocb_flag & LPFC_IO_WAKE_TMO) { in lpfc_sli_wake_iocb_wait()
11988 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli_wake_iocb_wait()
11989 cmdiocbq->iocb_cmpl = cmdiocbq->wait_iocb_cmpl; in lpfc_sli_wake_iocb_wait()
11990 cmdiocbq->wait_iocb_cmpl = NULL; in lpfc_sli_wake_iocb_wait()
11991 if (cmdiocbq->iocb_cmpl) in lpfc_sli_wake_iocb_wait()
11992 (cmdiocbq->iocb_cmpl)(phba, cmdiocbq, NULL); in lpfc_sli_wake_iocb_wait()
11998 cmdiocbq->iocb_flag |= LPFC_IO_WAKE; in lpfc_sli_wake_iocb_wait()
11999 if (cmdiocbq->context2 && rspiocbq) in lpfc_sli_wake_iocb_wait()
12000 memcpy(&((struct lpfc_iocbq *)cmdiocbq->context2)->iocb, in lpfc_sli_wake_iocb_wait()
12001 &rspiocbq->iocb, sizeof(IOCB_t)); in lpfc_sli_wake_iocb_wait()
12004 if ((cmdiocbq->iocb_flag & LPFC_IO_FCP) && in lpfc_sli_wake_iocb_wait()
12005 !(cmdiocbq->iocb_flag & LPFC_IO_LIBDFC)) { in lpfc_sli_wake_iocb_wait()
12008 if (rspiocbq && (rspiocbq->iocb_flag & LPFC_EXCHANGE_BUSY)) in lpfc_sli_wake_iocb_wait()
12009 lpfc_cmd->flags |= LPFC_SBUF_XBUSY; in lpfc_sli_wake_iocb_wait()
12011 lpfc_cmd->flags &= ~LPFC_SBUF_XBUSY; in lpfc_sli_wake_iocb_wait()
12014 pdone_q = cmdiocbq->context_un.wait_queue; in lpfc_sli_wake_iocb_wait()
12017 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli_wake_iocb_wait()
12022 * lpfc_chk_iocb_flg - Test IOCB flag with lock held.
12040 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_chk_iocb_flg()
12041 ret = piocbq->iocb_flag & flag; in lpfc_chk_iocb_flg()
12042 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_chk_iocb_flg()
12048 * lpfc_sli_issue_iocb_wait - Synchronous function to issue iocb commands
12067 * non-interruptible wait.
12101 if (phba->sli_rev >= LPFC_SLI_REV4) in lpfc_sli_issue_iocb_wait()
12104 pring = &phba->sli.sli3_ring[ring_number]; in lpfc_sli_issue_iocb_wait()
12110 if (piocb->context2) in lpfc_sli_issue_iocb_wait()
12112 piocb->context2 = prspiocbq; in lpfc_sli_issue_iocb_wait()
12115 piocb->wait_iocb_cmpl = piocb->iocb_cmpl; in lpfc_sli_issue_iocb_wait()
12116 piocb->iocb_cmpl = lpfc_sli_wake_iocb_wait; in lpfc_sli_issue_iocb_wait()
12117 piocb->context_un.wait_queue = &done_q; in lpfc_sli_issue_iocb_wait()
12118 piocb->iocb_flag &= ~(LPFC_IO_WAKE | LPFC_IO_WAKE_TMO); in lpfc_sli_issue_iocb_wait()
12120 if (phba->cfg_poll & DISABLE_FCP_RING_INT) { in lpfc_sli_issue_iocb_wait()
12121 if (lpfc_readl(phba->HCregaddr, &creg_val)) in lpfc_sli_issue_iocb_wait()
12124 writel(creg_val, phba->HCregaddr); in lpfc_sli_issue_iocb_wait()
12125 readl(phba->HCregaddr); /* flush */ in lpfc_sli_issue_iocb_wait()
12135 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli_issue_iocb_wait()
12136 if (!(piocb->iocb_flag & LPFC_IO_WAKE)) { in lpfc_sli_issue_iocb_wait()
12144 piocb->iocb_flag |= LPFC_IO_WAKE_TMO; in lpfc_sli_issue_iocb_wait()
12146 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli_issue_iocb_wait()
12151 * status or not - that's for the caller to check. in lpfc_sli_issue_iocb_wait()
12157 "0338 IOCB wait timeout error - no " in lpfc_sli_issue_iocb_wait()
12168 if (phba->cfg_log_verbose & LOG_SLI) { in lpfc_sli_issue_iocb_wait()
12169 list_for_each_entry(iocb, &pring->txq, list) { in lpfc_sli_issue_iocb_wait()
12172 list_for_each_entry(iocb, &pring->txcmplq, list) { in lpfc_sli_issue_iocb_wait()
12177 phba->iocb_cnt, txq_cnt, txcmplq_cnt); in lpfc_sli_issue_iocb_wait()
12187 if (phba->cfg_poll & DISABLE_FCP_RING_INT) { in lpfc_sli_issue_iocb_wait()
12188 if (lpfc_readl(phba->HCregaddr, &creg_val)) in lpfc_sli_issue_iocb_wait()
12191 writel(creg_val, phba->HCregaddr); in lpfc_sli_issue_iocb_wait()
12192 readl(phba->HCregaddr); /* flush */ in lpfc_sli_issue_iocb_wait()
12196 piocb->context2 = NULL; in lpfc_sli_issue_iocb_wait()
12198 piocb->context_un.wait_queue = NULL; in lpfc_sli_issue_iocb_wait()
12199 piocb->iocb_cmpl = NULL; in lpfc_sli_issue_iocb_wait()
12204 * lpfc_sli_issue_mbox_wait - Synchronous function to issue mailbox
12206 * @pmboxq: Pointer to driver mailbox object.
12209 * This function issues the mailbox to firmware and waits for the
12210 * mailbox command to complete. If the mailbox command is not
12212 * The function waits for the mailbox completion using an
12215 * should not free the mailbox resources, if this function returns
12217 * This function will sleep while waiting for mailbox completion.
12221 * This function assumes that the mailbox completion occurs while
12223 * the worker thread which processes mailbox completion.
12237 pmboxq->mbox_flag &= ~LPFC_MBX_WAKE; in lpfc_sli_issue_mbox_wait()
12239 pmboxq->mbox_cmpl = lpfc_sli_wake_mbox_wait; in lpfc_sli_issue_mbox_wait()
12243 pmboxq->context3 = &mbox_done; in lpfc_sli_issue_mbox_wait()
12250 spin_lock_irqsave(&phba->hbalock, flag); in lpfc_sli_issue_mbox_wait()
12251 pmboxq->context3 = NULL; in lpfc_sli_issue_mbox_wait()
12253 * if LPFC_MBX_WAKE flag is set the mailbox is completed in lpfc_sli_issue_mbox_wait()
12256 if (pmboxq->mbox_flag & LPFC_MBX_WAKE) { in lpfc_sli_issue_mbox_wait()
12260 pmboxq->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_sli_issue_mbox_wait()
12262 spin_unlock_irqrestore(&phba->hbalock, flag); in lpfc_sli_issue_mbox_wait()
12268 * lpfc_sli_mbox_sys_shutdown - shutdown mailbox command sub-system
12270 * @mbx_action: Mailbox shutdown options.
12272 * This function is called to shutdown the driver's mailbox sub-system.
12273 * It first marks the mailbox sub-system is in a block state to prevent
12274 * the asynchronous mailbox command from issued off the pending mailbox
12275 * command queue. If the mailbox command sub-system shutdown is due to
12277 * the mailbox sub-system flush routine to forcefully bring down the
12278 * mailbox sub-system. Otherwise, if it is due to normal condition (such
12280 * outstanding mailbox command to complete before invoking the mailbox
12281 * sub-system flush routine to gracefully bring down mailbox sub-system.
12286 struct lpfc_sli *psli = &phba->sli; in lpfc_sli_mbox_sys_shutdown()
12297 /* Disable softirqs, including timers from obtaining phba->hbalock */ in lpfc_sli_mbox_sys_shutdown()
12300 spin_lock_irq(&phba->hbalock); in lpfc_sli_mbox_sys_shutdown()
12301 psli->sli_flag |= LPFC_SLI_ASYNC_MBX_BLK; in lpfc_sli_mbox_sys_shutdown()
12303 if (psli->sli_flag & LPFC_SLI_ACTIVE) { in lpfc_sli_mbox_sys_shutdown()
12304 /* Determine how long we might wait for the active mailbox in lpfc_sli_mbox_sys_shutdown()
12307 if (phba->sli.mbox_active) in lpfc_sli_mbox_sys_shutdown()
12309 phba->sli.mbox_active) * in lpfc_sli_mbox_sys_shutdown()
12311 spin_unlock_irq(&phba->hbalock); in lpfc_sli_mbox_sys_shutdown()
12313 /* Enable softirqs again, done with phba->hbalock */ in lpfc_sli_mbox_sys_shutdown()
12316 while (phba->sli.mbox_active) { in lpfc_sli_mbox_sys_shutdown()
12317 /* Check active mailbox complete status every 2ms */ in lpfc_sli_mbox_sys_shutdown()
12320 /* Timeout, let the mailbox flush routine to in lpfc_sli_mbox_sys_shutdown()
12321 * forcefully release active mailbox command in lpfc_sli_mbox_sys_shutdown()
12326 spin_unlock_irq(&phba->hbalock); in lpfc_sli_mbox_sys_shutdown()
12328 /* Enable softirqs again, done with phba->hbalock */ in lpfc_sli_mbox_sys_shutdown()
12336 * lpfc_sli_eratt_read - read sli-3 error attention events
12352 if (lpfc_readl(phba->HAregaddr, &ha_copy)) in lpfc_sli_eratt_read()
12361 if ((HS_FFER1 & phba->work_hs) && in lpfc_sli_eratt_read()
12363 HS_FFER6 | HS_FFER7 | HS_FFER8) & phba->work_hs)) { in lpfc_sli_eratt_read()
12364 phba->hba_flag |= DEFER_ERATT; in lpfc_sli_eratt_read()
12366 writel(0, phba->HCregaddr); in lpfc_sli_eratt_read()
12367 readl(phba->HCregaddr); in lpfc_sli_eratt_read()
12371 phba->work_ha |= HA_ERATT; in lpfc_sli_eratt_read()
12373 phba->hba_flag |= HBA_ERATT_HANDLED; in lpfc_sli_eratt_read()
12380 phba->work_hs |= UNPLUG_ERR; in lpfc_sli_eratt_read()
12382 phba->work_ha |= HA_ERATT; in lpfc_sli_eratt_read()
12384 phba->hba_flag |= HBA_ERATT_HANDLED; in lpfc_sli_eratt_read()
12389 * lpfc_sli4_eratt_read - read sli-4 error attention events
12410 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); in lpfc_sli4_eratt_read()
12413 if (lpfc_readl(phba->sli4_hba.u.if_type0.UERRLOregaddr, in lpfc_sli4_eratt_read()
12415 lpfc_readl(phba->sli4_hba.u.if_type0.UERRHIregaddr, in lpfc_sli4_eratt_read()
12417 phba->work_hs |= UNPLUG_ERR; in lpfc_sli4_eratt_read()
12418 phba->work_ha |= HA_ERATT; in lpfc_sli4_eratt_read()
12419 phba->hba_flag |= HBA_ERATT_HANDLED; in lpfc_sli4_eratt_read()
12422 if ((~phba->sli4_hba.ue_mask_lo & uerr_sta_lo) || in lpfc_sli4_eratt_read()
12423 (~phba->sli4_hba.ue_mask_hi & uerr_sta_hi)) { in lpfc_sli4_eratt_read()
12430 phba->sli4_hba.ue_mask_lo, in lpfc_sli4_eratt_read()
12431 phba->sli4_hba.ue_mask_hi); in lpfc_sli4_eratt_read()
12432 phba->work_status[0] = uerr_sta_lo; in lpfc_sli4_eratt_read()
12433 phba->work_status[1] = uerr_sta_hi; in lpfc_sli4_eratt_read()
12434 phba->work_ha |= HA_ERATT; in lpfc_sli4_eratt_read()
12435 phba->hba_flag |= HBA_ERATT_HANDLED; in lpfc_sli4_eratt_read()
12441 if (lpfc_readl(phba->sli4_hba.u.if_type2.STATUSregaddr, in lpfc_sli4_eratt_read()
12443 lpfc_readl(phba->sli4_hba.PSMPHRregaddr, in lpfc_sli4_eratt_read()
12445 phba->work_hs |= UNPLUG_ERR; in lpfc_sli4_eratt_read()
12446 phba->work_ha |= HA_ERATT; in lpfc_sli4_eratt_read()
12447 phba->hba_flag |= HBA_ERATT_HANDLED; in lpfc_sli4_eratt_read()
12451 phba->work_status[0] = in lpfc_sli4_eratt_read()
12452 readl(phba->sli4_hba.u.if_type2.ERR1regaddr); in lpfc_sli4_eratt_read()
12453 phba->work_status[1] = in lpfc_sli4_eratt_read()
12454 readl(phba->sli4_hba.u.if_type2.ERR2regaddr); in lpfc_sli4_eratt_read()
12462 phba->work_status[0], in lpfc_sli4_eratt_read()
12463 phba->work_status[1]); in lpfc_sli4_eratt_read()
12464 phba->work_ha |= HA_ERATT; in lpfc_sli4_eratt_read()
12465 phba->hba_flag |= HBA_ERATT_HANDLED; in lpfc_sli4_eratt_read()
12481 * lpfc_sli_check_eratt - check error attention events
12498 if (phba->link_flag & LS_IGNORE_ERATT) in lpfc_sli_check_eratt()
12502 spin_lock_irq(&phba->hbalock); in lpfc_sli_check_eratt()
12503 if (phba->hba_flag & HBA_ERATT_HANDLED) { in lpfc_sli_check_eratt()
12505 spin_unlock_irq(&phba->hbalock); in lpfc_sli_check_eratt()
12513 if (unlikely(phba->hba_flag & DEFER_ERATT)) { in lpfc_sli_check_eratt()
12514 spin_unlock_irq(&phba->hbalock); in lpfc_sli_check_eratt()
12519 if (unlikely(pci_channel_offline(phba->pcidev))) { in lpfc_sli_check_eratt()
12520 spin_unlock_irq(&phba->hbalock); in lpfc_sli_check_eratt()
12524 switch (phba->sli_rev) { in lpfc_sli_check_eratt()
12537 phba->sli_rev); in lpfc_sli_check_eratt()
12541 spin_unlock_irq(&phba->hbalock); in lpfc_sli_check_eratt()
12547 * lpfc_intr_state_check - Check device state for interrupt handling
12554 * interrupt should be handled, otherwise -EIO.
12560 if (unlikely(pci_channel_offline(phba->pcidev))) in lpfc_intr_state_check()
12561 return -EIO; in lpfc_intr_state_check()
12564 phba->sli.slistat.sli_intr++; in lpfc_intr_state_check()
12567 if (unlikely(phba->link_state < LPFC_LINK_DOWN)) in lpfc_intr_state_check()
12568 return -EIO; in lpfc_intr_state_check()
12574 * lpfc_sli_sp_intr_handler - Slow-path interrupt handler to SLI-3 device
12579 * service routine when device with SLI-3 interface spec is enabled with
12580 * MSI-X multi-message interrupt mode and there are slow-path events in
12581 * the HBA. However, when the device is enabled with either MSI or Pin-IRQ
12582 * interrupt mode, this function is called as part of the device-level
12622 * individual interrupt handler in MSI-X multi-message interrupt mode in lpfc_sli_sp_intr_handler()
12624 if (phba->intr_type == MSIX) { in lpfc_sli_sp_intr_handler()
12628 /* Need to read HA REG for slow-path events */ in lpfc_sli_sp_intr_handler()
12629 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_sp_intr_handler()
12630 if (lpfc_readl(phba->HAregaddr, &ha_copy)) in lpfc_sli_sp_intr_handler()
12635 if (phba->link_flag & LS_IGNORE_ERATT) in lpfc_sli_sp_intr_handler()
12639 if (phba->hba_flag & HBA_ERATT_HANDLED) in lpfc_sli_sp_intr_handler()
12644 phba->hba_flag |= HBA_ERATT_HANDLED; in lpfc_sli_sp_intr_handler()
12651 if (unlikely(phba->hba_flag & DEFER_ERATT)) { in lpfc_sli_sp_intr_handler()
12652 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_sp_intr_handler()
12656 /* Clear up only attention source related to slow-path */ in lpfc_sli_sp_intr_handler()
12657 if (lpfc_readl(phba->HCregaddr, &hc_copy)) in lpfc_sli_sp_intr_handler()
12662 phba->HCregaddr); in lpfc_sli_sp_intr_handler()
12664 phba->HAregaddr); in lpfc_sli_sp_intr_handler()
12665 writel(hc_copy, phba->HCregaddr); in lpfc_sli_sp_intr_handler()
12666 readl(phba->HAregaddr); /* flush */ in lpfc_sli_sp_intr_handler()
12667 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_sp_intr_handler()
12669 ha_copy = phba->ha_copy; in lpfc_sli_sp_intr_handler()
12671 work_ha_copy = ha_copy & phba->work_ha_mask; in lpfc_sli_sp_intr_handler()
12675 if (phba->sli.sli_flag & LPFC_PROCESS_LA) { in lpfc_sli_sp_intr_handler()
12680 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_sp_intr_handler()
12681 phba->sli.sli_flag &= ~LPFC_PROCESS_LA; in lpfc_sli_sp_intr_handler()
12682 if (lpfc_readl(phba->HCregaddr, &control)) in lpfc_sli_sp_intr_handler()
12685 writel(control, phba->HCregaddr); in lpfc_sli_sp_intr_handler()
12686 readl(phba->HCregaddr); /* flush */ in lpfc_sli_sp_intr_handler()
12687 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_sp_intr_handler()
12702 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_sp_intr_handler()
12703 if (lpfc_readl(phba->HCregaddr, &control)) in lpfc_sli_sp_intr_handler()
12709 (uint32_t)phba->sli.slistat.sli_intr); in lpfc_sli_sp_intr_handler()
12715 phba->work_ha, work_ha_copy, in lpfc_sli_sp_intr_handler()
12717 &phba->work_waitq)); in lpfc_sli_sp_intr_handler()
12721 writel(control, phba->HCregaddr); in lpfc_sli_sp_intr_handler()
12722 readl(phba->HCregaddr); /* flush */ in lpfc_sli_sp_intr_handler()
12728 phba->work_ha, work_ha_copy, in lpfc_sli_sp_intr_handler()
12730 &phba->work_waitq)); in lpfc_sli_sp_intr_handler()
12732 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_sp_intr_handler()
12735 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_sp_intr_handler()
12743 if ((HS_FFER1 & phba->work_hs) && in lpfc_sli_sp_intr_handler()
12746 phba->work_hs)) { in lpfc_sli_sp_intr_handler()
12747 phba->hba_flag |= DEFER_ERATT; in lpfc_sli_sp_intr_handler()
12749 writel(0, phba->HCregaddr); in lpfc_sli_sp_intr_handler()
12750 readl(phba->HCregaddr); in lpfc_sli_sp_intr_handler()
12754 if ((work_ha_copy & HA_MBATT) && (phba->sli.mbox_active)) { in lpfc_sli_sp_intr_handler()
12755 pmb = phba->sli.mbox_active; in lpfc_sli_sp_intr_handler()
12756 pmbox = &pmb->u.mb; in lpfc_sli_sp_intr_handler()
12757 mbox = phba->mbox; in lpfc_sli_sp_intr_handler()
12758 vport = pmb->vport; in lpfc_sli_sp_intr_handler()
12762 if (pmbox->mbxOwner != OWN_HOST) { in lpfc_sli_sp_intr_handler()
12763 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_sp_intr_handler()
12765 * Stray Mailbox Interrupt, mbxCommand <cmd> in lpfc_sli_sp_intr_handler()
12769 "(%d):0304 Stray Mailbox " in lpfc_sli_sp_intr_handler()
12772 (vport ? vport->vpi : 0), in lpfc_sli_sp_intr_handler()
12773 pmbox->mbxCommand, in lpfc_sli_sp_intr_handler()
12774 pmbox->mbxStatus); in lpfc_sli_sp_intr_handler()
12775 /* clear mailbox attention bit */ in lpfc_sli_sp_intr_handler()
12778 phba->sli.mbox_active = NULL; in lpfc_sli_sp_intr_handler()
12779 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_sp_intr_handler()
12780 phba->last_completion_time = jiffies; in lpfc_sli_sp_intr_handler()
12781 del_timer(&phba->sli.mbox_tmo); in lpfc_sli_sp_intr_handler()
12782 if (pmb->mbox_cmpl) { in lpfc_sli_sp_intr_handler()
12785 if (pmb->out_ext_byte_len && in lpfc_sli_sp_intr_handler()
12786 pmb->ctx_buf) in lpfc_sli_sp_intr_handler()
12788 phba->mbox_ext, in lpfc_sli_sp_intr_handler()
12789 pmb->ctx_buf, in lpfc_sli_sp_intr_handler()
12790 pmb->out_ext_byte_len); in lpfc_sli_sp_intr_handler()
12792 if (pmb->mbox_flag & LPFC_MBX_IMED_UNREG) { in lpfc_sli_sp_intr_handler()
12793 pmb->mbox_flag &= ~LPFC_MBX_IMED_UNREG; in lpfc_sli_sp_intr_handler()
12799 (uint32_t)pmbox->mbxStatus, in lpfc_sli_sp_intr_handler()
12800 pmbox->un.varWords[0], 0); in lpfc_sli_sp_intr_handler()
12802 if (!pmbox->mbxStatus) { in lpfc_sli_sp_intr_handler()
12804 (pmb->ctx_buf); in lpfc_sli_sp_intr_handler()
12806 pmb->ctx_ndlp; in lpfc_sli_sp_intr_handler()
12814 vport->vpi, in lpfc_sli_sp_intr_handler()
12815 pmbox->un.varWords[0], in lpfc_sli_sp_intr_handler()
12817 pmb->mbox_cmpl = in lpfc_sli_sp_intr_handler()
12819 pmb->ctx_buf = mp; in lpfc_sli_sp_intr_handler()
12820 pmb->ctx_ndlp = ndlp; in lpfc_sli_sp_intr_handler()
12821 pmb->vport = vport; in lpfc_sli_sp_intr_handler()
12836 &phba->pport->work_port_lock, in lpfc_sli_sp_intr_handler()
12838 phba->pport->work_port_events &= in lpfc_sli_sp_intr_handler()
12841 &phba->pport->work_port_lock, in lpfc_sli_sp_intr_handler()
12846 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_sp_intr_handler()
12849 (phba->sli.mbox_active == NULL)) { in lpfc_sli_sp_intr_handler()
12851 /* Process next mailbox command if there is one */ in lpfc_sli_sp_intr_handler()
12863 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_sp_intr_handler()
12864 phba->work_ha |= work_ha_copy; in lpfc_sli_sp_intr_handler()
12865 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_sp_intr_handler()
12870 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_sp_intr_handler()
12876 * lpfc_sli_fp_intr_handler - Fast-path interrupt handler to SLI-3 device.
12881 * service routine when device with SLI-3 interface spec is enabled with
12882 * MSI-X multi-message interrupt mode and there is a fast-path FCP IOCB
12884 * MSI or Pin-IRQ interrupt mode, this function is called as part of the
12885 * device-level interrupt handler. When the PCI slot is in error recovery
12887 * process the interrupt. The SCSI FCP fast-path ring event are handled in
12913 * individual interrupt handler in MSI-X multi-message interrupt mode in lpfc_sli_fp_intr_handler()
12915 if (phba->intr_type == MSIX) { in lpfc_sli_fp_intr_handler()
12920 if (lpfc_readl(phba->HAregaddr, &ha_copy)) in lpfc_sli_fp_intr_handler()
12922 /* Clear up only attention source related to fast-path */ in lpfc_sli_fp_intr_handler()
12923 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_fp_intr_handler()
12928 if (unlikely(phba->hba_flag & DEFER_ERATT)) { in lpfc_sli_fp_intr_handler()
12929 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_fp_intr_handler()
12933 phba->HAregaddr); in lpfc_sli_fp_intr_handler()
12934 readl(phba->HAregaddr); /* flush */ in lpfc_sli_fp_intr_handler()
12935 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_fp_intr_handler()
12937 ha_copy = phba->ha_copy; in lpfc_sli_fp_intr_handler()
12942 ha_copy &= ~(phba->work_ha_mask); in lpfc_sli_fp_intr_handler()
12946 pring = &phba->sli.sli3_ring[LPFC_FCP_RING]; in lpfc_sli_fp_intr_handler()
12950 if (phba->cfg_multi_ring_support == 2) { in lpfc_sli_fp_intr_handler()
12959 &phba->sli.sli3_ring[LPFC_EXTRA_RING], in lpfc_sli_fp_intr_handler()
12967 * lpfc_sli_intr_handler - Device-level interrupt handler to SLI-3 device
12971 * This function is the HBA device-level interrupt handler to device with
12972 * SLI-3 interface spec, called from the PCI layer when either MSI or
12973 * Pin-IRQ interrupt mode is enabled and there is an event in the HBA which
12974 * requires driver attention. This function invokes the slow-path interrupt
12975 * attention handling function and fast-path interrupt attention handling
13004 spin_lock(&phba->hbalock); in lpfc_sli_intr_handler()
13005 if (lpfc_readl(phba->HAregaddr, &phba->ha_copy)) { in lpfc_sli_intr_handler()
13006 spin_unlock(&phba->hbalock); in lpfc_sli_intr_handler()
13010 if (unlikely(!phba->ha_copy)) { in lpfc_sli_intr_handler()
13011 spin_unlock(&phba->hbalock); in lpfc_sli_intr_handler()
13013 } else if (phba->ha_copy & HA_ERATT) { in lpfc_sli_intr_handler()
13014 if (phba->hba_flag & HBA_ERATT_HANDLED) in lpfc_sli_intr_handler()
13016 phba->ha_copy &= ~HA_ERATT; in lpfc_sli_intr_handler()
13019 phba->hba_flag |= HBA_ERATT_HANDLED; in lpfc_sli_intr_handler()
13025 if (unlikely(phba->hba_flag & DEFER_ERATT)) { in lpfc_sli_intr_handler()
13026 spin_unlock(&phba->hbalock); in lpfc_sli_intr_handler()
13031 if (lpfc_readl(phba->HCregaddr, &hc_copy)) { in lpfc_sli_intr_handler()
13032 spin_unlock(&phba->hbalock); in lpfc_sli_intr_handler()
13037 phba->HCregaddr); in lpfc_sli_intr_handler()
13038 writel((phba->ha_copy & ~(HA_LATT | HA_ERATT)), phba->HAregaddr); in lpfc_sli_intr_handler()
13039 writel(hc_copy, phba->HCregaddr); in lpfc_sli_intr_handler()
13040 readl(phba->HAregaddr); /* flush */ in lpfc_sli_intr_handler()
13041 spin_unlock(&phba->hbalock); in lpfc_sli_intr_handler()
13044 * Invokes slow-path host attention interrupt handling as appropriate. in lpfc_sli_intr_handler()
13047 /* status of events with mailbox and link attention */ in lpfc_sli_intr_handler()
13048 status1 = phba->ha_copy & (HA_MBATT | HA_LATT | HA_ERATT); in lpfc_sli_intr_handler()
13051 status2 = (phba->ha_copy & (HA_RXMASK << (4*LPFC_ELS_RING))); in lpfc_sli_intr_handler()
13060 * Invoke fast-path host attention interrupt handling as appropriate. in lpfc_sli_intr_handler()
13064 status1 = (phba->ha_copy & (HA_RXMASK << (4*LPFC_FCP_RING))); in lpfc_sli_intr_handler()
13068 if (phba->cfg_multi_ring_support == 2) { in lpfc_sli_intr_handler()
13069 status2 = (phba->ha_copy & (HA_RXMASK << (4*LPFC_EXTRA_RING))); in lpfc_sli_intr_handler()
13079 /* Return device-level interrupt handling status */ in lpfc_sli_intr_handler()
13084 * lpfc_sli4_els_xri_abort_event_proc - Process els xri abort event
13096 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_els_xri_abort_event_proc()
13097 phba->hba_flag &= ~ELS_XRI_ABORT_EVENT; in lpfc_sli4_els_xri_abort_event_proc()
13098 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_els_xri_abort_event_proc()
13101 spin_lock_irqsave(&phba->sli4_hba.els_xri_abrt_list_lock, iflags); in lpfc_sli4_els_xri_abort_event_proc()
13102 while (!list_empty(&phba->sli4_hba.sp_els_xri_aborted_work_queue)) { in lpfc_sli4_els_xri_abort_event_proc()
13104 list_remove_head(&phba->sli4_hba.sp_els_xri_aborted_work_queue, in lpfc_sli4_els_xri_abort_event_proc()
13106 spin_unlock_irqrestore(&phba->sli4_hba.els_xri_abrt_list_lock, in lpfc_sli4_els_xri_abort_event_proc()
13109 lpfc_sli4_els_xri_aborted(phba, &cq_event->cqe.wcqe_axri); in lpfc_sli4_els_xri_abort_event_proc()
13113 spin_lock_irqsave(&phba->sli4_hba.els_xri_abrt_list_lock, in lpfc_sli4_els_xri_abort_event_proc()
13116 spin_unlock_irqrestore(&phba->sli4_hba.els_xri_abrt_list_lock, iflags); in lpfc_sli4_els_xri_abort_event_proc()
13120 * lpfc_sli4_iocb_param_transfer - Transfer pIocbOut and cmpl status to pIocbIn
13144 sizeof(struct lpfc_iocbq) - offset); in lpfc_sli4_iocb_param_transfer()
13147 pIocbIn->iocb.ulpStatus = (status & LPFC_IOCB_STATUS_MASK); in lpfc_sli4_iocb_param_transfer()
13148 if (pIocbOut->iocb_flag & LPFC_IO_FCP) in lpfc_sli4_iocb_param_transfer()
13149 if (pIocbIn->iocb.ulpStatus == IOSTAT_FCP_RSP_ERROR) in lpfc_sli4_iocb_param_transfer()
13150 pIocbIn->iocb.un.fcpi.fcpi_parm = in lpfc_sli4_iocb_param_transfer()
13151 pIocbOut->iocb.un.fcpi.fcpi_parm - in lpfc_sli4_iocb_param_transfer()
13152 wcqe->total_data_placed; in lpfc_sli4_iocb_param_transfer()
13154 pIocbIn->iocb.un.ulpWord[4] = wcqe->parameter; in lpfc_sli4_iocb_param_transfer()
13156 pIocbIn->iocb.un.ulpWord[4] = wcqe->parameter; in lpfc_sli4_iocb_param_transfer()
13157 switch (pIocbOut->iocb.ulpCommand) { in lpfc_sli4_iocb_param_transfer()
13159 dmabuf = (struct lpfc_dmabuf *)pIocbOut->context3; in lpfc_sli4_iocb_param_transfer()
13160 bpl = (struct ulp_bde64 *)dmabuf->virt; in lpfc_sli4_iocb_param_transfer()
13166 if (!pIocbOut->context3) in lpfc_sli4_iocb_param_transfer()
13168 numBdes = pIocbOut->iocb.un.genreq64.bdl.bdeSize/ in lpfc_sli4_iocb_param_transfer()
13170 dmabuf = (struct lpfc_dmabuf *)pIocbOut->context3; in lpfc_sli4_iocb_param_transfer()
13171 bpl = (struct ulp_bde64 *)dmabuf->virt; in lpfc_sli4_iocb_param_transfer()
13179 max_response = wcqe->total_data_placed; in lpfc_sli4_iocb_param_transfer()
13182 if (max_response < wcqe->total_data_placed) in lpfc_sli4_iocb_param_transfer()
13183 pIocbIn->iocb.un.genreq64.bdl.bdeSize = max_response; in lpfc_sli4_iocb_param_transfer()
13185 pIocbIn->iocb.un.genreq64.bdl.bdeSize = in lpfc_sli4_iocb_param_transfer()
13186 wcqe->total_data_placed; in lpfc_sli4_iocb_param_transfer()
13191 pIocbIn->iocb.ulpStatus = IOSTAT_LOCAL_REJECT; in lpfc_sli4_iocb_param_transfer()
13194 pIocbIn->iocb.un.ulpWord[4] = IOERR_RX_DMA_FAILED; in lpfc_sli4_iocb_param_transfer()
13196 pIocbIn->iocb.un.ulpWord[4] = IOERR_TX_DMA_FAILED; in lpfc_sli4_iocb_param_transfer()
13198 pIocbIn->iocb.unsli3.sli3_bg.bgstat = 0; in lpfc_sli4_iocb_param_transfer()
13200 pIocbIn->iocb.unsli3.sli3_bg.bgstat |= in lpfc_sli4_iocb_param_transfer()
13203 pIocbIn->iocb.unsli3.sli3_bg.bgstat |= in lpfc_sli4_iocb_param_transfer()
13206 pIocbIn->iocb.unsli3.sli3_bg.bgstat |= in lpfc_sli4_iocb_param_transfer()
13211 pIocbIn->iocb.unsli3.sli3_bg.bgstat |= in lpfc_sli4_iocb_param_transfer()
13213 pIocbIn->iocb.unsli3.sli3_bg.bghm = in lpfc_sli4_iocb_param_transfer()
13214 wcqe->total_data_placed; in lpfc_sli4_iocb_param_transfer()
13221 if (!pIocbIn->iocb.unsli3.sli3_bg.bgstat) in lpfc_sli4_iocb_param_transfer()
13222 pIocbIn->iocb.unsli3.sli3_bg.bgstat |= in lpfc_sli4_iocb_param_transfer()
13229 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_iocb_param_transfer()
13230 pIocbIn->iocb_flag |= LPFC_EXCHANGE_BUSY; in lpfc_sli4_iocb_param_transfer()
13231 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_iocb_param_transfer()
13236 * lpfc_sli4_els_wcqe_to_rspiocbq - Get response iocbq from els wcqe
13238 * @irspiocbq: Pointer to work-queue completion queue entry.
13240 * This routine handles an ELS work-queue completion event and construct
13259 wcqe = &irspiocbq->cq_event.cqe.wcqe_cmpl; in lpfc_sli4_els_wcqe_to_rspiocbq()
13260 pring->stats.iocb_event++; in lpfc_sli4_els_wcqe_to_rspiocbq()
13268 wcqe->word0, wcqe->total_data_placed, in lpfc_sli4_els_wcqe_to_rspiocbq()
13269 wcqe->parameter, wcqe->word3); in lpfc_sli4_els_wcqe_to_rspiocbq()
13274 spin_lock_irqsave(&pring->ring_lock, iflags); in lpfc_sli4_els_wcqe_to_rspiocbq()
13277 spin_unlock_irqrestore(&pring->ring_lock, iflags); in lpfc_sli4_els_wcqe_to_rspiocbq()
13299 memcpy(&cq_event->cqe, entry, size); in lpfc_cq_event_setup()
13304 * lpfc_sli4_sp_handle_async_event - Handle an asynchronous event
13306 * @mcqe: Pointer to mailbox completion queue entry.
13308 * This routine process a mailbox completion queue entry with asynchronous
13321 "word2:x%x, word3:x%x\n", mcqe->word0, in lpfc_sli4_sp_handle_async_event()
13322 mcqe->mcqe_tag0, mcqe->mcqe_tag1, mcqe->trailer); in lpfc_sli4_sp_handle_async_event()
13328 spin_lock_irqsave(&phba->sli4_hba.asynce_list_lock, iflags); in lpfc_sli4_sp_handle_async_event()
13329 list_add_tail(&cq_event->list, &phba->sli4_hba.sp_asynce_work_queue); in lpfc_sli4_sp_handle_async_event()
13330 spin_unlock_irqrestore(&phba->sli4_hba.asynce_list_lock, iflags); in lpfc_sli4_sp_handle_async_event()
13333 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_async_event()
13334 phba->hba_flag |= ASYNC_EVENT; in lpfc_sli4_sp_handle_async_event()
13335 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_async_event()
13341 * lpfc_sli4_sp_handle_mbox_event - Handle a mailbox completion event
13343 * @mcqe: Pointer to mailbox completion queue entry.
13345 * This routine process a mailbox completion queue entry with mailbox
13364 /* If not a mailbox complete MCQE, out by checking mailbox consume */ in lpfc_sli4_sp_handle_mbox_event()
13369 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_mbox_event()
13370 pmb = phba->sli.mbox_active; in lpfc_sli4_sp_handle_mbox_event()
13374 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_mbox_event()
13377 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_mbox_event()
13378 mqe = &pmb->u.mqe; in lpfc_sli4_sp_handle_mbox_event()
13379 pmbox = (MAILBOX_t *)&pmb->u.mqe; in lpfc_sli4_sp_handle_mbox_event()
13380 mbox = phba->mbox; in lpfc_sli4_sp_handle_mbox_event()
13381 vport = pmb->vport; in lpfc_sli4_sp_handle_mbox_event()
13384 phba->last_completion_time = jiffies; in lpfc_sli4_sp_handle_mbox_event()
13385 del_timer(&phba->sli.mbox_tmo); in lpfc_sli4_sp_handle_mbox_event()
13387 /* Move mbox data to caller's mailbox region, do endian swapping */ in lpfc_sli4_sp_handle_mbox_event()
13388 if (pmb->mbox_cmpl && mbox) in lpfc_sli4_sp_handle_mbox_event()
13401 if (pmb->mbox_flag & LPFC_MBX_IMED_UNREG) { in lpfc_sli4_sp_handle_mbox_event()
13402 pmb->mbox_flag &= ~LPFC_MBX_IMED_UNREG; in lpfc_sli4_sp_handle_mbox_event()
13406 pmbox->un.varWords[0], 0); in lpfc_sli4_sp_handle_mbox_event()
13408 mp = (struct lpfc_dmabuf *)(pmb->ctx_buf); in lpfc_sli4_sp_handle_mbox_event()
13409 ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp; in lpfc_sli4_sp_handle_mbox_event()
13413 lpfc_unreg_login(phba, vport->vpi, in lpfc_sli4_sp_handle_mbox_event()
13414 pmbox->un.varWords[0], pmb); in lpfc_sli4_sp_handle_mbox_event()
13415 pmb->mbox_cmpl = lpfc_mbx_cmpl_dflt_rpi; in lpfc_sli4_sp_handle_mbox_event()
13416 pmb->ctx_buf = mp; in lpfc_sli4_sp_handle_mbox_event()
13417 pmb->ctx_ndlp = ndlp; in lpfc_sli4_sp_handle_mbox_event()
13418 pmb->vport = vport; in lpfc_sli4_sp_handle_mbox_event()
13429 spin_lock_irqsave(&phba->pport->work_port_lock, iflags); in lpfc_sli4_sp_handle_mbox_event()
13430 phba->pport->work_port_events &= ~WORKER_MBOX_TMO; in lpfc_sli4_sp_handle_mbox_event()
13431 spin_unlock_irqrestore(&phba->pport->work_port_lock, iflags); in lpfc_sli4_sp_handle_mbox_event()
13433 /* There is mailbox completion work to do */ in lpfc_sli4_sp_handle_mbox_event()
13434 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_mbox_event()
13436 phba->work_ha |= HA_MBATT; in lpfc_sli4_sp_handle_mbox_event()
13437 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_mbox_event()
13441 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_mbox_event()
13442 /* Release the mailbox command posting token */ in lpfc_sli4_sp_handle_mbox_event()
13443 phba->sli.sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; in lpfc_sli4_sp_handle_mbox_event()
13444 /* Setting active mailbox pointer need to be in sync to flag clear */ in lpfc_sli4_sp_handle_mbox_event()
13445 phba->sli.mbox_active = NULL; in lpfc_sli4_sp_handle_mbox_event()
13447 lpfc_sli4_mq_release(phba->sli4_hba.mbx_wq); in lpfc_sli4_sp_handle_mbox_event()
13448 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_mbox_event()
13449 /* Wake up worker thread to post the next pending mailbox command */ in lpfc_sli4_sp_handle_mbox_event()
13454 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_mbox_event()
13456 lpfc_sli4_mq_release(phba->sli4_hba.mbx_wq); in lpfc_sli4_sp_handle_mbox_event()
13457 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_mbox_event()
13462 * lpfc_sli4_sp_handle_mcqe - Process a mailbox completion queue entry
13465 * @cqe: Pointer to mailbox completion queue entry.
13467 * This routine process a mailbox completion queue entry, it invokes the
13468 * proper mailbox complete handling or asynchronous event handling routine
13480 cq->CQ_mbox++; in lpfc_sli4_sp_handle_mcqe()
13482 /* Copy the mailbox MCQE and convert endian order as needed */ in lpfc_sli4_sp_handle_mcqe()
13494 * lpfc_sli4_sp_handle_els_wcqe - Handle els work-queue completion event
13497 * @wcqe: Pointer to work-queue completion queue entry.
13499 * This routine handles an ELS work-queue completion event.
13509 struct lpfc_sli_ring *pring = cq->pring; in lpfc_sli4_sp_handle_els_wcqe()
13520 wcqe->word0, wcqe->total_data_placed, in lpfc_sli4_sp_handle_els_wcqe()
13521 wcqe->parameter, wcqe->word3); in lpfc_sli4_sp_handle_els_wcqe()
13527 if (!list_empty(&pring->txq)) in lpfc_sli4_sp_handle_els_wcqe()
13529 if (!list_empty(&pring->txcmplq)) in lpfc_sli4_sp_handle_els_wcqe()
13534 txq_cnt, phba->iocb_cnt, in lpfc_sli4_sp_handle_els_wcqe()
13539 /* Save off the slow-path queue event for work thread to process */ in lpfc_sli4_sp_handle_els_wcqe()
13540 memcpy(&irspiocbq->cq_event.cqe.wcqe_cmpl, wcqe, sizeof(*wcqe)); in lpfc_sli4_sp_handle_els_wcqe()
13541 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_els_wcqe()
13542 list_add_tail(&irspiocbq->cq_event.list, in lpfc_sli4_sp_handle_els_wcqe()
13543 &phba->sli4_hba.sp_queue_event); in lpfc_sli4_sp_handle_els_wcqe()
13544 phba->hba_flag |= HBA_SP_QUEUE_EVT; in lpfc_sli4_sp_handle_els_wcqe()
13545 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_els_wcqe()
13551 * lpfc_sli4_sp_handle_rel_wcqe - Handle slow-path WQ entry consumed event
13553 * @wcqe: Pointer to work-queue completion queue entry.
13555 * This routine handles slow-path WQ entry consumed event by invoking the
13556 * proper WQ release routine to the slow-path WQ.
13563 if (unlikely(!phba->sli4_hba.els_wq)) in lpfc_sli4_sp_handle_rel_wcqe()
13565 /* Check for the slow-path ELS work queue */ in lpfc_sli4_sp_handle_rel_wcqe()
13566 if (bf_get(lpfc_wcqe_r_wq_id, wcqe) == phba->sli4_hba.els_wq->queue_id) in lpfc_sli4_sp_handle_rel_wcqe()
13567 lpfc_sli4_wq_release(phba->sli4_hba.els_wq, in lpfc_sli4_sp_handle_rel_wcqe()
13571 "2579 Slow-path wqe consume event carries " in lpfc_sli4_sp_handle_rel_wcqe()
13572 "miss-matched qid: wcqe-qid=x%x, sp-qid=x%x\n", in lpfc_sli4_sp_handle_rel_wcqe()
13574 phba->sli4_hba.els_wq->queue_id); in lpfc_sli4_sp_handle_rel_wcqe()
13578 * lpfc_sli4_sp_handle_abort_xri_wcqe - Handle a xri abort event
13581 * @wcqe: Pointer to work-queue completion queue entry.
13596 switch (cq->subtype) { in lpfc_sli4_sp_handle_abort_xri_wcqe()
13598 lpfc_sli4_io_xri_aborted(phba, wcqe, cq->hdwq); in lpfc_sli4_sp_handle_abort_xri_wcqe()
13599 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_sp_handle_abort_xri_wcqe()
13601 if (phba->nvmet_support) in lpfc_sli4_sp_handle_abort_xri_wcqe()
13613 cq_event->hdwq = cq->hdwq; in lpfc_sli4_sp_handle_abort_xri_wcqe()
13614 spin_lock_irqsave(&phba->sli4_hba.els_xri_abrt_list_lock, in lpfc_sli4_sp_handle_abort_xri_wcqe()
13616 list_add_tail(&cq_event->list, in lpfc_sli4_sp_handle_abort_xri_wcqe()
13617 &phba->sli4_hba.sp_els_xri_aborted_work_queue); in lpfc_sli4_sp_handle_abort_xri_wcqe()
13619 phba->hba_flag |= ELS_XRI_ABORT_EVENT; in lpfc_sli4_sp_handle_abort_xri_wcqe()
13620 spin_unlock_irqrestore(&phba->sli4_hba.els_xri_abrt_list_lock, in lpfc_sli4_sp_handle_abort_xri_wcqe()
13628 cq->subtype, wcqe->word0, wcqe->parameter, in lpfc_sli4_sp_handle_abort_xri_wcqe()
13629 wcqe->word2, wcqe->word3); in lpfc_sli4_sp_handle_abort_xri_wcqe()
13639 * lpfc_sli4_sp_handle_rcqe - Process a receive-queue completion queue entry
13641 * @rcqe: Pointer to receive-queue completion queue entry.
13643 * This routine process a receive-queue completion queue entry.
13652 struct lpfc_queue *hrq = phba->sli4_hba.hdr_rq; in lpfc_sli4_sp_handle_rcqe()
13653 struct lpfc_queue *drq = phba->sli4_hba.dat_rq; in lpfc_sli4_sp_handle_rcqe()
13667 if (rq_id != hrq->queue_id) in lpfc_sli4_sp_handle_rcqe()
13677 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_rcqe()
13679 dma_buf = lpfc_sli_hbqbuf_get(&phba->hbqs[0].hbq_buffer_list); in lpfc_sli4_sp_handle_rcqe()
13681 hrq->RQ_no_buf_found++; in lpfc_sli4_sp_handle_rcqe()
13682 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_rcqe()
13685 hrq->RQ_rcv_buf++; in lpfc_sli4_sp_handle_rcqe()
13686 hrq->RQ_buf_posted--; in lpfc_sli4_sp_handle_rcqe()
13687 memcpy(&dma_buf->cq_event.cqe.rcqe_cmpl, rcqe, sizeof(*rcqe)); in lpfc_sli4_sp_handle_rcqe()
13689 fc_hdr = (struct fc_frame_header *)dma_buf->hbuf.virt; in lpfc_sli4_sp_handle_rcqe()
13691 if (fc_hdr->fh_r_ctl == FC_RCTL_MDS_DIAGS || in lpfc_sli4_sp_handle_rcqe()
13692 fc_hdr->fh_r_ctl == FC_RCTL_DD_UNSOL_DATA) { in lpfc_sli4_sp_handle_rcqe()
13693 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_rcqe()
13695 if (!(phba->pport->load_flag & FC_UNLOADING)) in lpfc_sli4_sp_handle_rcqe()
13696 lpfc_sli4_handle_mds_loopback(phba->pport, in lpfc_sli4_sp_handle_rcqe()
13699 lpfc_in_buf_free(phba, &dma_buf->dbuf); in lpfc_sli4_sp_handle_rcqe()
13704 list_add_tail(&dma_buf->cq_event.list, in lpfc_sli4_sp_handle_rcqe()
13705 &phba->sli4_hba.sp_queue_event); in lpfc_sli4_sp_handle_rcqe()
13707 phba->hba_flag |= HBA_SP_QUEUE_EVT; in lpfc_sli4_sp_handle_rcqe()
13708 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_rcqe()
13712 if (phba->nvmet_support) { in lpfc_sli4_sp_handle_rcqe()
13713 tgtp = phba->targetport->private; in lpfc_sli4_sp_handle_rcqe()
13717 status, hrq->RQ_buf_posted, in lpfc_sli4_sp_handle_rcqe()
13718 hrq->RQ_no_posted_buf, in lpfc_sli4_sp_handle_rcqe()
13719 atomic_read(&tgtp->rcv_fcp_cmd_in), in lpfc_sli4_sp_handle_rcqe()
13720 atomic_read(&tgtp->rcv_fcp_cmd_out), in lpfc_sli4_sp_handle_rcqe()
13721 atomic_read(&tgtp->xmt_fcp_release)); in lpfc_sli4_sp_handle_rcqe()
13726 hrq->RQ_no_posted_buf++; in lpfc_sli4_sp_handle_rcqe()
13728 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_rcqe()
13729 phba->hba_flag |= HBA_POST_RECEIVE_BUFFER; in lpfc_sli4_sp_handle_rcqe()
13730 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_rcqe()
13739 * lpfc_sli4_sp_handle_cqe - Process a slow path completion queue entry
13744 * This routine process a slow-path work-queue or receive queue completion queue
13763 phba->last_completion_time = jiffies; in lpfc_sli4_sp_handle_cqe()
13774 phba->last_completion_time = jiffies; in lpfc_sli4_sp_handle_cqe()
13781 phba->last_completion_time = jiffies; in lpfc_sli4_sp_handle_cqe()
13795 * lpfc_sli4_sp_handle_eqe - Process a slow-path event queue entry
13797 * @eqe: Pointer to fast-path event queue entry.
13798 * @speq: Pointer to slow-path event queue.
13800 * This routine process a event queue entry from the slow-path event queue.
13819 list_for_each_entry(childq, &speq->child_list, list) { in lpfc_sli4_sp_handle_eqe()
13820 if (childq->queue_id == cqid) { in lpfc_sli4_sp_handle_eqe()
13826 if (phba->sli.sli_flag & LPFC_SLI_ACTIVE) in lpfc_sli4_sp_handle_eqe()
13828 "0365 Slow-path CQ identifier " in lpfc_sli4_sp_handle_eqe()
13834 cq->assoc_qp = speq; in lpfc_sli4_sp_handle_eqe()
13837 ret = queue_work(phba->wq, &cq->spwork); in lpfc_sli4_sp_handle_eqe()
13839 ret = queue_work_on(cq->chann, phba->wq, &cq->spwork); in lpfc_sli4_sp_handle_eqe()
13845 cqid, cq->queue_id, raw_smp_processor_id()); in lpfc_sli4_sp_handle_eqe()
13849 * __lpfc_sli4_process_cq - Process elements of a CQ
13880 /* default - no reschedule */ in __lpfc_sli4_process_cq()
13883 if (cmpxchg(&cq->queue_claimed, 0, 1) != 0) in __lpfc_sli4_process_cq()
13887 cq->q_flag = 0; in __lpfc_sli4_process_cq()
13894 if (!(++count % cq->max_proc_limit)) in __lpfc_sli4_process_cq()
13897 if (!(count % cq->notify_interval)) { in __lpfc_sli4_process_cq()
13898 phba->sli4_hba.sli4_write_cq_db(phba, cq, consumed, in __lpfc_sli4_process_cq()
13901 cq->assoc_qp->q_flag |= HBA_EQ_DELAY_CHK; in __lpfc_sli4_process_cq()
13905 cq->q_flag |= HBA_NVMET_CQ_NOTIFY; in __lpfc_sli4_process_cq()
13909 if (count >= phba->cfg_cq_poll_threshold) { in __lpfc_sli4_process_cq()
13916 irq_poll_complete(&cq->iop); in __lpfc_sli4_process_cq()
13919 if (count > cq->CQ_max_cqe) in __lpfc_sli4_process_cq()
13920 cq->CQ_max_cqe = count; in __lpfc_sli4_process_cq()
13922 cq->assoc_qp->EQ_cqe_cnt += count; in __lpfc_sli4_process_cq()
13928 "qid=%d\n", cq->queue_id); in __lpfc_sli4_process_cq()
13930 xchg(&cq->queue_claimed, 0); in __lpfc_sli4_process_cq()
13933 phba->sli4_hba.sli4_write_cq_db(phba, cq, consumed, in __lpfc_sli4_process_cq()
13940 * lpfc_sli4_sp_process_cq - Process a slow-path event queue entry
13949 * the second is the delay parameter. If non-zero, rather than rearming
13957 struct lpfc_hba *phba = cq->phba; in __lpfc_sli4_sp_process_cq()
13963 switch (cq->type) { in __lpfc_sli4_sp_process_cq()
13970 if (cq->subtype == LPFC_IO) in __lpfc_sli4_sp_process_cq()
13982 cq->type); in __lpfc_sli4_sp_process_cq()
13988 ret = queue_delayed_work(phba->wq, &cq->sched_spwork, in __lpfc_sli4_sp_process_cq()
13991 ret = queue_delayed_work_on(cq->chann, phba->wq, in __lpfc_sli4_sp_process_cq()
13992 &cq->sched_spwork, delay); in __lpfc_sli4_sp_process_cq()
13997 cq->queue_id, cq->chann); in __lpfc_sli4_sp_process_cq()
14006 * lpfc_sli4_sp_process_cq - slow-path work handler when started by
14010 * translates from the work handler and calls the slow-path handler.
14021 * lpfc_sli4_dly_sp_process_cq - slow-path work handler when started by timer
14024 * translates from the work handler and calls the slow-path handler.
14036 * lpfc_sli4_fp_handle_fcp_wcqe - Process fast-path work queue completion entry
14039 * @wcqe: Pointer to work-queue completion queue entry.
14041 * This routine process a fast-path work queue completion entry from fast-path
14048 struct lpfc_sli_ring *pring = cq->pring; in lpfc_sli4_fp_handle_fcp_wcqe()
14060 ((wcqe->parameter & IOERR_PARAM_MASK) == in lpfc_sli4_fp_handle_fcp_wcqe()
14062 phba->lpfc_rampdown_queue_depth(phba); in lpfc_sli4_fp_handle_fcp_wcqe()
14069 wcqe->word0, wcqe->total_data_placed, in lpfc_sli4_fp_handle_fcp_wcqe()
14070 wcqe->parameter, wcqe->word3); in lpfc_sli4_fp_handle_fcp_wcqe()
14074 spin_lock_irqsave(&pring->ring_lock, iflags); in lpfc_sli4_fp_handle_fcp_wcqe()
14075 pring->stats.iocb_event++; in lpfc_sli4_fp_handle_fcp_wcqe()
14076 spin_unlock_irqrestore(&pring->ring_lock, iflags); in lpfc_sli4_fp_handle_fcp_wcqe()
14087 cmdiocbq->isr_timestamp = cq->isr_timestamp; in lpfc_sli4_fp_handle_fcp_wcqe()
14089 if (cmdiocbq->iocb_cmpl == NULL) { in lpfc_sli4_fp_handle_fcp_wcqe()
14090 if (cmdiocbq->wqe_cmpl) { in lpfc_sli4_fp_handle_fcp_wcqe()
14091 if (cmdiocbq->iocb_flag & LPFC_DRIVER_ABORTED) { in lpfc_sli4_fp_handle_fcp_wcqe()
14092 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_fp_handle_fcp_wcqe()
14093 cmdiocbq->iocb_flag &= ~LPFC_DRIVER_ABORTED; in lpfc_sli4_fp_handle_fcp_wcqe()
14094 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_fp_handle_fcp_wcqe()
14098 (cmdiocbq->wqe_cmpl)(phba, cmdiocbq, wcqe); in lpfc_sli4_fp_handle_fcp_wcqe()
14111 if (cmdiocbq->iocb_flag & LPFC_DRIVER_ABORTED) { in lpfc_sli4_fp_handle_fcp_wcqe()
14112 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_fp_handle_fcp_wcqe()
14113 cmdiocbq->iocb_flag &= ~LPFC_DRIVER_ABORTED; in lpfc_sli4_fp_handle_fcp_wcqe()
14114 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_fp_handle_fcp_wcqe()
14118 (cmdiocbq->iocb_cmpl)(phba, cmdiocbq, &irspiocbq); in lpfc_sli4_fp_handle_fcp_wcqe()
14122 * lpfc_sli4_fp_handle_rel_wcqe - Handle fast-path WQ entry consumed event
14125 * @wcqe: Pointer to work-queue completion queue entry.
14127 * This routine handles an fast-path WQ entry consumed event by invoking the
14128 * proper WQ release routine to the slow-path WQ.
14138 /* Check for fast-path FCP work queue release */ in lpfc_sli4_fp_handle_rel_wcqe()
14140 list_for_each_entry(childwq, &cq->child_list, list) { in lpfc_sli4_fp_handle_rel_wcqe()
14141 if (childwq->queue_id == hba_wqid) { in lpfc_sli4_fp_handle_rel_wcqe()
14144 if (childwq->q_flag & HBA_NVMET_WQFULL) in lpfc_sli4_fp_handle_rel_wcqe()
14153 "2580 Fast-path wqe consume event carries " in lpfc_sli4_fp_handle_rel_wcqe()
14154 "miss-matched qid: wcqe-qid=x%x\n", hba_wqid); in lpfc_sli4_fp_handle_rel_wcqe()
14158 * lpfc_sli4_nvmet_handle_rcqe - Process a receive-queue completion queue entry
14161 * @rcqe: Pointer to receive-queue completion queue entry.
14163 * This routine process a receive-queue completion queue entry.
14181 if ((phba->nvmet_support == 0) || in lpfc_sli4_nvmet_handle_rcqe()
14182 (phba->sli4_hba.nvmet_cqset == NULL)) in lpfc_sli4_nvmet_handle_rcqe()
14185 idx = cq->queue_id - phba->sli4_hba.nvmet_cqset[0]->queue_id; in lpfc_sli4_nvmet_handle_rcqe()
14186 hrq = phba->sli4_hba.nvmet_mrq_hdr[idx]; in lpfc_sli4_nvmet_handle_rcqe()
14187 drq = phba->sli4_hba.nvmet_mrq_data[idx]; in lpfc_sli4_nvmet_handle_rcqe()
14198 if ((phba->nvmet_support == 0) || in lpfc_sli4_nvmet_handle_rcqe()
14199 (rq_id != hrq->queue_id)) in lpfc_sli4_nvmet_handle_rcqe()
14209 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_nvmet_handle_rcqe()
14213 hrq->RQ_no_buf_found++; in lpfc_sli4_nvmet_handle_rcqe()
14214 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_nvmet_handle_rcqe()
14217 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_nvmet_handle_rcqe()
14218 hrq->RQ_rcv_buf++; in lpfc_sli4_nvmet_handle_rcqe()
14219 hrq->RQ_buf_posted--; in lpfc_sli4_nvmet_handle_rcqe()
14220 fc_hdr = (struct fc_frame_header *)dma_buf->hbuf.virt; in lpfc_sli4_nvmet_handle_rcqe()
14223 fctl = (fc_hdr->fh_f_ctl[0] << 16 | in lpfc_sli4_nvmet_handle_rcqe()
14224 fc_hdr->fh_f_ctl[1] << 8 | in lpfc_sli4_nvmet_handle_rcqe()
14225 fc_hdr->fh_f_ctl[2]); in lpfc_sli4_nvmet_handle_rcqe()
14229 (fc_hdr->fh_seq_cnt != 0)) /* 0 byte swapped is still 0 */ in lpfc_sli4_nvmet_handle_rcqe()
14232 if (fc_hdr->fh_type == FC_TYPE_FCP) { in lpfc_sli4_nvmet_handle_rcqe()
14233 dma_buf->bytes_recv = bf_get(lpfc_rcqe_length, rcqe); in lpfc_sli4_nvmet_handle_rcqe()
14235 phba, idx, dma_buf, cq->isr_timestamp, in lpfc_sli4_nvmet_handle_rcqe()
14236 cq->q_flag & HBA_NVMET_CQ_NOTIFY); in lpfc_sli4_nvmet_handle_rcqe()
14240 lpfc_rq_buf_free(phba, &dma_buf->hbuf); in lpfc_sli4_nvmet_handle_rcqe()
14243 if (phba->nvmet_support) { in lpfc_sli4_nvmet_handle_rcqe()
14244 tgtp = phba->targetport->private; in lpfc_sli4_nvmet_handle_rcqe()
14248 status, hrq->RQ_buf_posted, in lpfc_sli4_nvmet_handle_rcqe()
14249 hrq->RQ_no_posted_buf, in lpfc_sli4_nvmet_handle_rcqe()
14250 atomic_read(&tgtp->rcv_fcp_cmd_in), in lpfc_sli4_nvmet_handle_rcqe()
14251 atomic_read(&tgtp->rcv_fcp_cmd_out), in lpfc_sli4_nvmet_handle_rcqe()
14252 atomic_read(&tgtp->xmt_fcp_release)); in lpfc_sli4_nvmet_handle_rcqe()
14257 hrq->RQ_no_posted_buf++; in lpfc_sli4_nvmet_handle_rcqe()
14266 * lpfc_sli4_fp_handle_cqe - Process fast-path work queue completion entry
14269 * @cqe: Pointer to fast-path completion queue entry.
14271 * This routine process a fast-path work queue completion entry from fast-path
14290 cq->CQ_wq++; in lpfc_sli4_fp_handle_cqe()
14292 phba->last_completion_time = jiffies; in lpfc_sli4_fp_handle_cqe()
14293 if (cq->subtype == LPFC_IO || cq->subtype == LPFC_NVME_LS) in lpfc_sli4_fp_handle_cqe()
14298 cq->CQ_release_wqe++; in lpfc_sli4_fp_handle_cqe()
14304 cq->CQ_xri_aborted++; in lpfc_sli4_fp_handle_cqe()
14306 phba->last_completion_time = jiffies; in lpfc_sli4_fp_handle_cqe()
14312 phba->last_completion_time = jiffies; in lpfc_sli4_fp_handle_cqe()
14313 if (cq->subtype == LPFC_NVMET) { in lpfc_sli4_fp_handle_cqe()
14328 * lpfc_sli4_sched_cq_work - Schedules cq work
14334 * cq->chann, then either schedules a softirq or queue_work to complete
14346 switch (cq->poll_mode) { in lpfc_sli4_sched_cq_work()
14348 irq_poll_sched(&cq->iop); in lpfc_sli4_sched_cq_work()
14353 ret = queue_work(phba->wq, &cq->irqwork); in lpfc_sli4_sched_cq_work()
14355 ret = queue_work_on(cq->chann, phba->wq, &cq->irqwork); in lpfc_sli4_sched_cq_work()
14360 cqid, cq->queue_id, in lpfc_sli4_sched_cq_work()
14366 * lpfc_sli4_hba_handle_eqe - Process a fast-path event queue entry
14369 * @eqe: Pointer to fast-path event queue entry.
14371 * This routine process a event queue entry from the fast-path event queue.
14383 uint32_t qidx = eq->hdwq; in lpfc_sli4_hba_handle_eqe()
14399 if (cqid <= phba->sli4_hba.cq_max) { in lpfc_sli4_hba_handle_eqe()
14400 cq = phba->sli4_hba.cq_lookup[cqid]; in lpfc_sli4_hba_handle_eqe()
14406 if (phba->cfg_nvmet_mrq && phba->sli4_hba.nvmet_cqset) { in lpfc_sli4_hba_handle_eqe()
14407 id = phba->sli4_hba.nvmet_cqset[0]->queue_id; in lpfc_sli4_hba_handle_eqe()
14408 if ((cqid >= id) && (cqid < (id + phba->cfg_nvmet_mrq))) { in lpfc_sli4_hba_handle_eqe()
14410 cq = phba->sli4_hba.nvmet_cqset[cqid - id]; in lpfc_sli4_hba_handle_eqe()
14415 if (phba->sli4_hba.nvmels_cq && in lpfc_sli4_hba_handle_eqe()
14416 (cqid == phba->sli4_hba.nvmels_cq->queue_id)) { in lpfc_sli4_hba_handle_eqe()
14418 cq = phba->sli4_hba.nvmels_cq; in lpfc_sli4_hba_handle_eqe()
14424 phba->sli4_hba.hdwq[qidx].hba_eq); in lpfc_sli4_hba_handle_eqe()
14429 if (unlikely(cqid != cq->queue_id)) { in lpfc_sli4_hba_handle_eqe()
14431 "0368 Miss-matched fast-path completion " in lpfc_sli4_hba_handle_eqe()
14433 cqid, cq->queue_id); in lpfc_sli4_hba_handle_eqe()
14439 if (phba->ktime_on) in lpfc_sli4_hba_handle_eqe()
14440 cq->isr_timestamp = ktime_get_ns(); in lpfc_sli4_hba_handle_eqe()
14442 cq->isr_timestamp = 0; in lpfc_sli4_hba_handle_eqe()
14448 * __lpfc_sli4_hba_process_cq - Process a fast-path event queue entry
14458 * the second is the delay parameter. If non-zero, rather than rearming
14467 struct lpfc_hba *phba = cq->phba; in __lpfc_sli4_hba_process_cq()
14478 ret = queue_delayed_work(phba->wq, &cq->sched_irqwork, in __lpfc_sli4_hba_process_cq()
14481 ret = queue_delayed_work_on(cq->chann, phba->wq, in __lpfc_sli4_hba_process_cq()
14482 &cq->sched_irqwork, delay); in __lpfc_sli4_hba_process_cq()
14487 cq->queue_id, cq->chann); in __lpfc_sli4_hba_process_cq()
14496 * lpfc_sli4_hba_process_cq - fast-path work handler when started by
14500 * translates from the work handler and calls the fast-path handler.
14511 * lpfc_sli4_hba_process_cq - fast-path work handler when started by timer
14514 * translates from the work handler and calls the fast-path handler.
14526 * lpfc_sli4_hba_intr_handler - HBA interrupt handler to SLI-4 device
14531 * service routine when device with SLI-4 interface spec is enabled with
14532 * MSI-X multi-message interrupt mode and there is a fast-path FCP IOCB
14534 * MSI or Pin-IRQ interrupt mode, this function is called as part of the
14535 * device-level interrupt handler. When the PCI slot is in error recovery
14537 * process the interrupt. The SCSI FCP fast-path ring event are handled in
14540 * the FCP EQ to FCP CQ are one-to-one map such that the FCP EQ index is
14564 phba = hba_eq_hdl->phba; in lpfc_sli4_hba_intr_handler()
14565 hba_eqidx = hba_eq_hdl->idx; in lpfc_sli4_hba_intr_handler()
14569 if (unlikely(!phba->sli4_hba.hdwq)) in lpfc_sli4_hba_intr_handler()
14573 fpeq = phba->sli4_hba.hba_eq_hdl[hba_eqidx].eq; in lpfc_sli4_hba_intr_handler()
14580 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli4_hba_intr_handler()
14581 if (phba->link_state < LPFC_LINK_DOWN) in lpfc_sli4_hba_intr_handler()
14584 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli4_hba_intr_handler()
14588 eqi = this_cpu_ptr(phba->sli4_hba.eq_info); in lpfc_sli4_hba_intr_handler()
14589 eqi->icnt++; in lpfc_sli4_hba_intr_handler()
14591 fpeq->last_cpu = raw_smp_processor_id(); in lpfc_sli4_hba_intr_handler()
14593 if (eqi->icnt > LPFC_EQD_ISR_TRIGGER && in lpfc_sli4_hba_intr_handler()
14594 fpeq->q_flag & HBA_EQ_DELAY_CHK && in lpfc_sli4_hba_intr_handler()
14595 phba->cfg_auto_imax && in lpfc_sli4_hba_intr_handler()
14596 fpeq->q_mode != LPFC_MAX_AUTO_EQ_DELAY && in lpfc_sli4_hba_intr_handler()
14597 phba->sli.sli_flag & LPFC_SLI_USE_EQDR) in lpfc_sli4_hba_intr_handler()
14604 fpeq->EQ_no_entry++; in lpfc_sli4_hba_intr_handler()
14605 if (phba->intr_type == MSIX) in lpfc_sli4_hba_intr_handler()
14606 /* MSI-X treated interrupt served as no EQ share INT */ in lpfc_sli4_hba_intr_handler()
14608 "0358 MSI-X interrupt with no EQE\n"); in lpfc_sli4_hba_intr_handler()
14610 /* Non MSI-X treated on interrupt as EQ share INT */ in lpfc_sli4_hba_intr_handler()
14618 * lpfc_sli4_intr_handler - Device-level interrupt handler for SLI-4 device
14622 * This function is the device-level interrupt handler to device with SLI-4
14623 * interface spec, called from the PCI layer when either MSI or Pin-IRQ
14625 * driver attention. This function invokes the slow-path interrupt attention
14626 * handling function and fast-path interrupt attention handling function in
14649 * Invoke fast-path host attention interrupt handling as appropriate. in lpfc_sli4_intr_handler()
14651 for (qidx = 0; qidx < phba->cfg_irq_chann; qidx++) { in lpfc_sli4_intr_handler()
14653 &phba->sli4_hba.hba_eq_hdl[qidx]); in lpfc_sli4_intr_handler()
14669 list_for_each_entry_rcu(eq, &phba->poll_list, _poll_list) in lpfc_sli4_poll_hbtimer()
14671 if (!list_empty(&phba->poll_list)) in lpfc_sli4_poll_hbtimer()
14672 mod_timer(&phba->cpuhp_poll_timer, in lpfc_sli4_poll_hbtimer()
14680 struct lpfc_hba *phba = eq->phba; in lpfc_sli4_poll_eq()
14685 * for re-schedule, but we are good for io submission in lpfc_sli4_poll_eq()
14692 if (READ_ONCE(eq->mode) == LPFC_EQ_POLL) in lpfc_sli4_poll_eq()
14707 struct lpfc_hba *phba = eq->phba; in lpfc_sli4_add_to_poll_list()
14710 if (list_empty(&phba->poll_list)) in lpfc_sli4_add_to_poll_list()
14711 mod_timer(&phba->cpuhp_poll_timer, in lpfc_sli4_add_to_poll_list()
14714 list_add_rcu(&eq->_poll_list, &phba->poll_list); in lpfc_sli4_add_to_poll_list()
14720 struct lpfc_hba *phba = eq->phba; in lpfc_sli4_remove_from_poll_list()
14723 * by RE-ARMING the eq's ASAP in lpfc_sli4_remove_from_poll_list()
14725 list_del_rcu(&eq->_poll_list); in lpfc_sli4_remove_from_poll_list()
14728 if (list_empty(&phba->poll_list)) in lpfc_sli4_remove_from_poll_list()
14729 del_timer_sync(&phba->cpuhp_poll_timer); in lpfc_sli4_remove_from_poll_list()
14736 list_for_each_entry_safe(eq, next, &phba->poll_list, _poll_list) in lpfc_sli4_cleanup_poll_list()
14737 list_del(&eq->_poll_list); in lpfc_sli4_cleanup_poll_list()
14739 INIT_LIST_HEAD(&phba->poll_list); in lpfc_sli4_cleanup_poll_list()
14746 if (mode == eq->mode) in __lpfc_sli4_switch_eqmode()
14754 * scheduler for a high priority process. Yes, the inte- in __lpfc_sli4_switch_eqmode()
14759 WRITE_ONCE(eq->mode, mode); in __lpfc_sli4_switch_eqmode()
14768 * deal with it. This is just a draining phase for int- in __lpfc_sli4_switch_eqmode()
14786 struct lpfc_hba *phba = eq->phba; in lpfc_sli4_stop_polling()
14793 * receives a completion. But since eq's are in disa- in lpfc_sli4_stop_polling()
14797 phba->sli4_hba.sli4_write_eq_db(phba, eq, 0, LPFC_QUEUE_REARM); in lpfc_sli4_stop_polling()
14801 * lpfc_sli4_queue_free - free a queue structure and associated memory
14816 if (!list_empty(&queue->wq_list)) in lpfc_sli4_queue_free()
14817 list_del(&queue->wq_list); in lpfc_sli4_queue_free()
14819 while (!list_empty(&queue->page_list)) { in lpfc_sli4_queue_free()
14820 list_remove_head(&queue->page_list, dmabuf, struct lpfc_dmabuf, in lpfc_sli4_queue_free()
14822 dma_free_coherent(&queue->phba->pcidev->dev, queue->page_size, in lpfc_sli4_queue_free()
14823 dmabuf->virt, dmabuf->phys); in lpfc_sli4_queue_free()
14826 if (queue->rqbp) { in lpfc_sli4_queue_free()
14827 lpfc_free_rq_buffer(queue->phba, queue); in lpfc_sli4_queue_free()
14828 kfree(queue->rqbp); in lpfc_sli4_queue_free()
14831 if (!list_empty(&queue->cpu_list)) in lpfc_sli4_queue_free()
14832 list_del(&queue->cpu_list); in lpfc_sli4_queue_free()
14839 * lpfc_sli4_queue_alloc - Allocate and initialize a queue structure
14856 uint32_t hw_page_size = phba->sli4_hba.pc_sli4_params.if_page_sz; in lpfc_sli4_queue_alloc()
14859 if (!phba->sli4_hba.pc_sli4_params.supported) in lpfc_sli4_queue_alloc()
14865 if (pgcnt > phba->sli4_hba.pc_sli4_params.wqpcnt) in lpfc_sli4_queue_alloc()
14866 pgcnt = phba->sli4_hba.pc_sli4_params.wqpcnt; in lpfc_sli4_queue_alloc()
14873 INIT_LIST_HEAD(&queue->list); in lpfc_sli4_queue_alloc()
14874 INIT_LIST_HEAD(&queue->_poll_list); in lpfc_sli4_queue_alloc()
14875 INIT_LIST_HEAD(&queue->wq_list); in lpfc_sli4_queue_alloc()
14876 INIT_LIST_HEAD(&queue->wqfull_list); in lpfc_sli4_queue_alloc()
14877 INIT_LIST_HEAD(&queue->page_list); in lpfc_sli4_queue_alloc()
14878 INIT_LIST_HEAD(&queue->child_list); in lpfc_sli4_queue_alloc()
14879 INIT_LIST_HEAD(&queue->cpu_list); in lpfc_sli4_queue_alloc()
14884 queue->page_count = pgcnt; in lpfc_sli4_queue_alloc()
14885 queue->q_pgs = (void **)&queue[1]; in lpfc_sli4_queue_alloc()
14886 queue->entry_cnt_per_pg = hw_page_size / entry_size; in lpfc_sli4_queue_alloc()
14887 queue->entry_size = entry_size; in lpfc_sli4_queue_alloc()
14888 queue->entry_count = entry_count; in lpfc_sli4_queue_alloc()
14889 queue->page_size = hw_page_size; in lpfc_sli4_queue_alloc()
14890 queue->phba = phba; in lpfc_sli4_queue_alloc()
14892 for (x = 0; x < queue->page_count; x++) { in lpfc_sli4_queue_alloc()
14894 dev_to_node(&phba->pcidev->dev)); in lpfc_sli4_queue_alloc()
14897 dmabuf->virt = dma_alloc_coherent(&phba->pcidev->dev, in lpfc_sli4_queue_alloc()
14898 hw_page_size, &dmabuf->phys, in lpfc_sli4_queue_alloc()
14900 if (!dmabuf->virt) { in lpfc_sli4_queue_alloc()
14904 dmabuf->buffer_tag = x; in lpfc_sli4_queue_alloc()
14905 list_add_tail(&dmabuf->list, &queue->page_list); in lpfc_sli4_queue_alloc()
14907 queue->q_pgs[x] = dmabuf->virt; in lpfc_sli4_queue_alloc()
14909 INIT_WORK(&queue->irqwork, lpfc_sli4_hba_process_cq); in lpfc_sli4_queue_alloc()
14910 INIT_WORK(&queue->spwork, lpfc_sli4_sp_process_cq); in lpfc_sli4_queue_alloc()
14911 INIT_DELAYED_WORK(&queue->sched_irqwork, lpfc_sli4_dly_hba_process_cq); in lpfc_sli4_queue_alloc()
14912 INIT_DELAYED_WORK(&queue->sched_spwork, lpfc_sli4_dly_sp_process_cq); in lpfc_sli4_queue_alloc()
14923 * lpfc_dual_chute_pci_bar_map - Map pci base address register to host memory
14934 if (!phba->pcidev) in lpfc_dual_chute_pci_bar_map()
14939 return phba->pci_bar0_memmap_p; in lpfc_dual_chute_pci_bar_map()
14941 return phba->pci_bar2_memmap_p; in lpfc_dual_chute_pci_bar_map()
14943 return phba->pci_bar4_memmap_p; in lpfc_dual_chute_pci_bar_map()
14951 * lpfc_modify_hba_eq_delay - Modify Delay Multiplier on EQs
14959 * or by mailbox command. The mailbox command allows several EQs to be
14962 * The @phba struct is used to send a mailbox command to HBA. The @startq
14966 * mailbox commands to finish before returning.
14969 * enough memory this function will return -ENOMEM. If a mailbox command
14970 * fails this function will return -ENXIO. Note: on ENXIO, some EQs may
14986 if (startq >= phba->cfg_irq_chann) in lpfc_modify_hba_eq_delay()
14997 if (phba->sli.sli_flag & LPFC_SLI_USE_EQDR) { in lpfc_modify_hba_eq_delay()
14998 for (qidx = startq; qidx < phba->cfg_irq_chann; qidx++) { in lpfc_modify_hba_eq_delay()
14999 eq = phba->sli4_hba.hba_eq_hdl[qidx].eq; in lpfc_modify_hba_eq_delay()
15011 /* Otherwise, set values by mailbox cmd */ in lpfc_modify_hba_eq_delay()
15013 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_modify_hba_eq_delay()
15016 "6428 Failed allocating mailbox cmd buffer." in lpfc_modify_hba_eq_delay()
15020 length = (sizeof(struct lpfc_mbx_modify_eq_delay) - in lpfc_modify_hba_eq_delay()
15025 eq_delay = &mbox->u.mqe.un.eq_delay; in lpfc_modify_hba_eq_delay()
15030 dmult--; in lpfc_modify_hba_eq_delay()
15034 for (qidx = startq; qidx < phba->cfg_irq_chann; qidx++) { in lpfc_modify_hba_eq_delay()
15035 eq = phba->sli4_hba.hba_eq_hdl[qidx].eq; in lpfc_modify_hba_eq_delay()
15038 eq->q_mode = usdelay; in lpfc_modify_hba_eq_delay()
15039 eq_delay->u.request.eq[cnt].eq_id = eq->queue_id; in lpfc_modify_hba_eq_delay()
15040 eq_delay->u.request.eq[cnt].phase = 0; in lpfc_modify_hba_eq_delay()
15041 eq_delay->u.request.eq[cnt].delay_multi = dmult; in lpfc_modify_hba_eq_delay()
15046 eq_delay->u.request.num_eq = cnt; in lpfc_modify_hba_eq_delay()
15048 mbox->vport = phba->pport; in lpfc_modify_hba_eq_delay()
15049 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_modify_hba_eq_delay()
15050 mbox->ctx_buf = NULL; in lpfc_modify_hba_eq_delay()
15051 mbox->ctx_ndlp = NULL; in lpfc_modify_hba_eq_delay()
15053 shdr = (union lpfc_sli4_cfg_shdr *) &eq_delay->header.cfg_shdr; in lpfc_modify_hba_eq_delay()
15054 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_modify_hba_eq_delay()
15055 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_modify_hba_eq_delay()
15058 "2512 MODIFY_EQ_DELAY mailbox failed with " in lpfc_modify_hba_eq_delay()
15062 mempool_free(mbox, phba->mbox_mem_pool); in lpfc_modify_hba_eq_delay()
15067 * lpfc_eq_create - Create an Event Queue on the HBA
15073 * described by @phba by sending an EQ_CREATE mailbox command to the HBA.
15075 * The @phba struct is used to send mailbox command to HBA. The @eq struct
15078 * function will send the EQ_CREATE mailbox command to the HBA to setup the
15079 * event queue. This function is asynchronous and will wait for the mailbox
15083 * memory this function will return -ENOMEM. If the queue create mailbox command
15084 * fails this function will return -ENXIO.
15096 uint32_t hw_page_size = phba->sli4_hba.pc_sli4_params.if_page_sz; in lpfc_eq_create()
15100 return -ENODEV; in lpfc_eq_create()
15101 if (!phba->sli4_hba.pc_sli4_params.supported) in lpfc_eq_create()
15104 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_eq_create()
15106 return -ENOMEM; in lpfc_eq_create()
15107 length = (sizeof(struct lpfc_mbx_eq_create) - in lpfc_eq_create()
15112 eq_create = &mbox->u.mqe.un.eq_create; in lpfc_eq_create()
15113 shdr = (union lpfc_sli4_cfg_shdr *) &eq_create->header.cfg_shdr; in lpfc_eq_create()
15114 bf_set(lpfc_mbx_eq_create_num_pages, &eq_create->u.request, in lpfc_eq_create()
15115 eq->page_count); in lpfc_eq_create()
15116 bf_set(lpfc_eq_context_size, &eq_create->u.request.context, in lpfc_eq_create()
15118 bf_set(lpfc_eq_context_valid, &eq_create->u.request.context, 1); in lpfc_eq_create()
15121 if (phba->sli4_hba.pc_sli4_params.eqav) { in lpfc_eq_create()
15122 bf_set(lpfc_mbox_hdr_version, &shdr->request, in lpfc_eq_create()
15124 bf_set(lpfc_eq_context_autovalid, &eq_create->u.request.context, in lpfc_eq_create()
15125 phba->sli4_hba.pc_sli4_params.eqav); in lpfc_eq_create()
15130 bf_set(lpfc_eq_context_delay_multi, &eq_create->u.request.context, in lpfc_eq_create()
15132 switch (eq->entry_count) { in lpfc_eq_create()
15136 eq->entry_count); in lpfc_eq_create()
15137 if (eq->entry_count < 256) { in lpfc_eq_create()
15138 status = -EINVAL; in lpfc_eq_create()
15143 bf_set(lpfc_eq_context_count, &eq_create->u.request.context, in lpfc_eq_create()
15147 bf_set(lpfc_eq_context_count, &eq_create->u.request.context, in lpfc_eq_create()
15151 bf_set(lpfc_eq_context_count, &eq_create->u.request.context, in lpfc_eq_create()
15155 bf_set(lpfc_eq_context_count, &eq_create->u.request.context, in lpfc_eq_create()
15159 bf_set(lpfc_eq_context_count, &eq_create->u.request.context, in lpfc_eq_create()
15163 list_for_each_entry(dmabuf, &eq->page_list, list) { in lpfc_eq_create()
15164 memset(dmabuf->virt, 0, hw_page_size); in lpfc_eq_create()
15165 eq_create->u.request.page[dmabuf->buffer_tag].addr_lo = in lpfc_eq_create()
15166 putPaddrLow(dmabuf->phys); in lpfc_eq_create()
15167 eq_create->u.request.page[dmabuf->buffer_tag].addr_hi = in lpfc_eq_create()
15168 putPaddrHigh(dmabuf->phys); in lpfc_eq_create()
15170 mbox->vport = phba->pport; in lpfc_eq_create()
15171 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_eq_create()
15172 mbox->ctx_buf = NULL; in lpfc_eq_create()
15173 mbox->ctx_ndlp = NULL; in lpfc_eq_create()
15175 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_eq_create()
15176 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_eq_create()
15179 "2500 EQ_CREATE mailbox failed with " in lpfc_eq_create()
15182 status = -ENXIO; in lpfc_eq_create()
15184 eq->type = LPFC_EQ; in lpfc_eq_create()
15185 eq->subtype = LPFC_NONE; in lpfc_eq_create()
15186 eq->queue_id = bf_get(lpfc_mbx_eq_create_q_id, &eq_create->u.response); in lpfc_eq_create()
15187 if (eq->queue_id == 0xFFFF) in lpfc_eq_create()
15188 status = -ENXIO; in lpfc_eq_create()
15189 eq->host_index = 0; in lpfc_eq_create()
15190 eq->notify_interval = LPFC_EQ_NOTIFY_INTRVL; in lpfc_eq_create()
15191 eq->max_proc_limit = LPFC_EQ_MAX_PROC_LIMIT; in lpfc_eq_create()
15193 mempool_free(mbox, phba->mbox_mem_pool); in lpfc_eq_create()
15207 * lpfc_cq_create - Create a Completion Queue on the HBA
15215 * described by @phba by sending a CQ_CREATE mailbox command to the HBA.
15217 * The @phba struct is used to send mailbox command to HBA. The @cq struct
15221 * function will send the CQ_CREATE mailbox command to the HBA to setup the
15222 * completion queue. This function is asynchronous and will wait for the mailbox
15226 * memory this function will return -ENOMEM. If the queue create mailbox command
15227 * fails this function will return -ENXIO.
15242 return -ENODEV; in lpfc_cq_create()
15244 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_cq_create()
15246 return -ENOMEM; in lpfc_cq_create()
15247 length = (sizeof(struct lpfc_mbx_cq_create) - in lpfc_cq_create()
15252 cq_create = &mbox->u.mqe.un.cq_create; in lpfc_cq_create()
15253 shdr = (union lpfc_sli4_cfg_shdr *) &cq_create->header.cfg_shdr; in lpfc_cq_create()
15254 bf_set(lpfc_mbx_cq_create_num_pages, &cq_create->u.request, in lpfc_cq_create()
15255 cq->page_count); in lpfc_cq_create()
15256 bf_set(lpfc_cq_context_event, &cq_create->u.request.context, 1); in lpfc_cq_create()
15257 bf_set(lpfc_cq_context_valid, &cq_create->u.request.context, 1); in lpfc_cq_create()
15258 bf_set(lpfc_mbox_hdr_version, &shdr->request, in lpfc_cq_create()
15259 phba->sli4_hba.pc_sli4_params.cqv); in lpfc_cq_create()
15260 if (phba->sli4_hba.pc_sli4_params.cqv == LPFC_Q_CREATE_VERSION_2) { in lpfc_cq_create()
15261 bf_set(lpfc_mbx_cq_create_page_size, &cq_create->u.request, in lpfc_cq_create()
15262 (cq->page_size / SLI4_PAGE_SIZE)); in lpfc_cq_create()
15263 bf_set(lpfc_cq_eq_id_2, &cq_create->u.request.context, in lpfc_cq_create()
15264 eq->queue_id); in lpfc_cq_create()
15265 bf_set(lpfc_cq_context_autovalid, &cq_create->u.request.context, in lpfc_cq_create()
15266 phba->sli4_hba.pc_sli4_params.cqav); in lpfc_cq_create()
15268 bf_set(lpfc_cq_eq_id, &cq_create->u.request.context, in lpfc_cq_create()
15269 eq->queue_id); in lpfc_cq_create()
15271 switch (cq->entry_count) { in lpfc_cq_create()
15274 if (phba->sli4_hba.pc_sli4_params.cqv == in lpfc_cq_create()
15276 cq_create->u.request.context.lpfc_cq_context_count = in lpfc_cq_create()
15277 cq->entry_count; in lpfc_cq_create()
15279 &cq_create->u.request.context, in lpfc_cq_create()
15288 cq->entry_count, cq->entry_size, in lpfc_cq_create()
15289 cq->page_count); in lpfc_cq_create()
15290 if (cq->entry_count < 256) { in lpfc_cq_create()
15291 status = -EINVAL; in lpfc_cq_create()
15296 bf_set(lpfc_cq_context_count, &cq_create->u.request.context, in lpfc_cq_create()
15300 bf_set(lpfc_cq_context_count, &cq_create->u.request.context, in lpfc_cq_create()
15304 bf_set(lpfc_cq_context_count, &cq_create->u.request.context, in lpfc_cq_create()
15308 list_for_each_entry(dmabuf, &cq->page_list, list) { in lpfc_cq_create()
15309 memset(dmabuf->virt, 0, cq->page_size); in lpfc_cq_create()
15310 cq_create->u.request.page[dmabuf->buffer_tag].addr_lo = in lpfc_cq_create()
15311 putPaddrLow(dmabuf->phys); in lpfc_cq_create()
15312 cq_create->u.request.page[dmabuf->buffer_tag].addr_hi = in lpfc_cq_create()
15313 putPaddrHigh(dmabuf->phys); in lpfc_cq_create()
15317 /* The IOCTL status is embedded in the mailbox subheader. */ in lpfc_cq_create()
15318 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_cq_create()
15319 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_cq_create()
15322 "2501 CQ_CREATE mailbox failed with " in lpfc_cq_create()
15325 status = -ENXIO; in lpfc_cq_create()
15328 cq->queue_id = bf_get(lpfc_mbx_cq_create_q_id, &cq_create->u.response); in lpfc_cq_create()
15329 if (cq->queue_id == 0xFFFF) { in lpfc_cq_create()
15330 status = -ENXIO; in lpfc_cq_create()
15334 list_add_tail(&cq->list, &eq->child_list); in lpfc_cq_create()
15336 cq->type = type; in lpfc_cq_create()
15337 cq->subtype = subtype; in lpfc_cq_create()
15338 cq->queue_id = bf_get(lpfc_mbx_cq_create_q_id, &cq_create->u.response); in lpfc_cq_create()
15339 cq->assoc_qid = eq->queue_id; in lpfc_cq_create()
15340 cq->assoc_qp = eq; in lpfc_cq_create()
15341 cq->host_index = 0; in lpfc_cq_create()
15342 cq->notify_interval = LPFC_CQ_NOTIFY_INTRVL; in lpfc_cq_create()
15343 cq->max_proc_limit = min(phba->cfg_cq_max_proc_limit, cq->entry_count); in lpfc_cq_create()
15345 if (cq->queue_id > phba->sli4_hba.cq_max) in lpfc_cq_create()
15346 phba->sli4_hba.cq_max = cq->queue_id; in lpfc_cq_create()
15348 irq_poll_init(&cq->iop, LPFC_IRQ_POLL_WEIGHT, lpfc_cq_poll_hdler); in lpfc_cq_create()
15350 mempool_free(mbox, phba->mbox_mem_pool); in lpfc_cq_create()
15355 * lpfc_cq_create_set - Create a set of Completion Queues on the HBA for MRQ
15364 * described by @phba by sending a CREATE_CQ_SET mailbox command to the HBA.
15366 * The @phba struct is used to send mailbox command to HBA. The @cq struct
15370 * function will send the CREATE_CQ_SET mailbox command to the HBA to setup the
15371 * completion queue. This function is asynchronous and will wait for the mailbox
15375 * memory this function will return -ENOMEM. If the queue create mailbox command
15376 * fails this function will return -ENXIO.
15392 uint32_t hw_page_size = phba->sli4_hba.pc_sli4_params.if_page_sz; in lpfc_cq_create_set()
15395 numcq = phba->cfg_nvmet_mrq; in lpfc_cq_create_set()
15397 return -ENODEV; in lpfc_cq_create_set()
15399 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_cq_create_set()
15401 return -ENOMEM; in lpfc_cq_create_set()
15404 length += ((numcq * cqp[0]->page_count) * in lpfc_cq_create_set()
15414 status = -ENOMEM; in lpfc_cq_create_set()
15417 cq_set = mbox->sge_array->addr[0]; in lpfc_cq_create_set()
15418 shdr = (union lpfc_sli4_cfg_shdr *)&cq_set->cfg_shdr; in lpfc_cq_create_set()
15419 bf_set(lpfc_mbox_hdr_version, &shdr->request, 0); in lpfc_cq_create_set()
15425 status = -ENOMEM; in lpfc_cq_create_set()
15428 if (!phba->sli4_hba.pc_sli4_params.supported) in lpfc_cq_create_set()
15429 hw_page_size = cq->page_size; in lpfc_cq_create_set()
15434 &cq_set->u.request, in lpfc_cq_create_set()
15437 &cq_set->u.request, cq->page_count); in lpfc_cq_create_set()
15439 &cq_set->u.request, 1); in lpfc_cq_create_set()
15441 &cq_set->u.request, 1); in lpfc_cq_create_set()
15443 &cq_set->u.request, 0); in lpfc_cq_create_set()
15445 &cq_set->u.request, numcq); in lpfc_cq_create_set()
15447 &cq_set->u.request, in lpfc_cq_create_set()
15448 phba->sli4_hba.pc_sli4_params.cqav); in lpfc_cq_create_set()
15449 switch (cq->entry_count) { in lpfc_cq_create_set()
15452 if (phba->sli4_hba.pc_sli4_params.cqv == in lpfc_cq_create_set()
15455 &cq_set->u.request, in lpfc_cq_create_set()
15456 cq->entry_count); in lpfc_cq_create_set()
15458 &cq_set->u.request, in lpfc_cq_create_set()
15466 cq->entry_count); in lpfc_cq_create_set()
15467 if (cq->entry_count < 256) { in lpfc_cq_create_set()
15468 status = -EINVAL; in lpfc_cq_create_set()
15474 &cq_set->u.request, LPFC_CQ_CNT_256); in lpfc_cq_create_set()
15478 &cq_set->u.request, LPFC_CQ_CNT_512); in lpfc_cq_create_set()
15482 &cq_set->u.request, LPFC_CQ_CNT_1024); in lpfc_cq_create_set()
15486 &cq_set->u.request, eq->queue_id); in lpfc_cq_create_set()
15490 &cq_set->u.request, eq->queue_id); in lpfc_cq_create_set()
15494 &cq_set->u.request, eq->queue_id); in lpfc_cq_create_set()
15498 &cq_set->u.request, eq->queue_id); in lpfc_cq_create_set()
15502 &cq_set->u.request, eq->queue_id); in lpfc_cq_create_set()
15506 &cq_set->u.request, eq->queue_id); in lpfc_cq_create_set()
15510 &cq_set->u.request, eq->queue_id); in lpfc_cq_create_set()
15514 &cq_set->u.request, eq->queue_id); in lpfc_cq_create_set()
15518 &cq_set->u.request, eq->queue_id); in lpfc_cq_create_set()
15522 &cq_set->u.request, eq->queue_id); in lpfc_cq_create_set()
15526 &cq_set->u.request, eq->queue_id); in lpfc_cq_create_set()
15530 &cq_set->u.request, eq->queue_id); in lpfc_cq_create_set()
15534 &cq_set->u.request, eq->queue_id); in lpfc_cq_create_set()
15538 &cq_set->u.request, eq->queue_id); in lpfc_cq_create_set()
15542 &cq_set->u.request, eq->queue_id); in lpfc_cq_create_set()
15546 &cq_set->u.request, eq->queue_id); in lpfc_cq_create_set()
15551 list_add_tail(&cq->list, &eq->child_list); in lpfc_cq_create_set()
15553 cq->type = type; in lpfc_cq_create_set()
15554 cq->subtype = subtype; in lpfc_cq_create_set()
15555 cq->assoc_qid = eq->queue_id; in lpfc_cq_create_set()
15556 cq->assoc_qp = eq; in lpfc_cq_create_set()
15557 cq->host_index = 0; in lpfc_cq_create_set()
15558 cq->notify_interval = LPFC_CQ_NOTIFY_INTRVL; in lpfc_cq_create_set()
15559 cq->max_proc_limit = min(phba->cfg_cq_max_proc_limit, in lpfc_cq_create_set()
15560 cq->entry_count); in lpfc_cq_create_set()
15561 cq->chann = idx; in lpfc_cq_create_set()
15564 list_for_each_entry(dmabuf, &cq->page_list, list) { in lpfc_cq_create_set()
15565 memset(dmabuf->virt, 0, hw_page_size); in lpfc_cq_create_set()
15566 cnt = page_idx + dmabuf->buffer_tag; in lpfc_cq_create_set()
15567 cq_set->u.request.page[cnt].addr_lo = in lpfc_cq_create_set()
15568 putPaddrLow(dmabuf->phys); in lpfc_cq_create_set()
15569 cq_set->u.request.page[cnt].addr_hi = in lpfc_cq_create_set()
15570 putPaddrHigh(dmabuf->phys); in lpfc_cq_create_set()
15578 /* The IOCTL status is embedded in the mailbox subheader. */ in lpfc_cq_create_set()
15579 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_cq_create_set()
15580 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_cq_create_set()
15583 "3119 CQ_CREATE_SET mailbox failed with " in lpfc_cq_create_set()
15586 status = -ENXIO; in lpfc_cq_create_set()
15589 rc = bf_get(lpfc_mbx_cq_create_set_base_id, &cq_set->u.response); in lpfc_cq_create_set()
15591 status = -ENXIO; in lpfc_cq_create_set()
15597 cq->queue_id = rc + idx; in lpfc_cq_create_set()
15598 if (cq->queue_id > phba->sli4_hba.cq_max) in lpfc_cq_create_set()
15599 phba->sli4_hba.cq_max = cq->queue_id; in lpfc_cq_create_set()
15608 * lpfc_mq_create_fb_init - Send MCC_CREATE without async events registration
15610 * @mq: The queue structure to use to create the mailbox queue.
15629 length = (sizeof(struct lpfc_mbx_mq_create) - in lpfc_mq_create_fb_init()
15634 mq_create = &mbox->u.mqe.un.mq_create; in lpfc_mq_create_fb_init()
15635 bf_set(lpfc_mbx_mq_create_num_pages, &mq_create->u.request, in lpfc_mq_create_fb_init()
15636 mq->page_count); in lpfc_mq_create_fb_init()
15637 bf_set(lpfc_mq_context_cq_id, &mq_create->u.request.context, in lpfc_mq_create_fb_init()
15638 cq->queue_id); in lpfc_mq_create_fb_init()
15639 bf_set(lpfc_mq_context_valid, &mq_create->u.request.context, 1); in lpfc_mq_create_fb_init()
15640 switch (mq->entry_count) { in lpfc_mq_create_fb_init()
15642 bf_set(lpfc_mq_context_ring_size, &mq_create->u.request.context, in lpfc_mq_create_fb_init()
15646 bf_set(lpfc_mq_context_ring_size, &mq_create->u.request.context, in lpfc_mq_create_fb_init()
15650 bf_set(lpfc_mq_context_ring_size, &mq_create->u.request.context, in lpfc_mq_create_fb_init()
15654 bf_set(lpfc_mq_context_ring_size, &mq_create->u.request.context, in lpfc_mq_create_fb_init()
15658 list_for_each_entry(dmabuf, &mq->page_list, list) { in lpfc_mq_create_fb_init()
15659 mq_create->u.request.page[dmabuf->buffer_tag].addr_lo = in lpfc_mq_create_fb_init()
15660 putPaddrLow(dmabuf->phys); in lpfc_mq_create_fb_init()
15661 mq_create->u.request.page[dmabuf->buffer_tag].addr_hi = in lpfc_mq_create_fb_init()
15662 putPaddrHigh(dmabuf->phys); in lpfc_mq_create_fb_init()
15667 * lpfc_mq_create - Create a mailbox Queue on the HBA
15669 * @mq: The queue structure to use to create the mailbox queue.
15673 * This function creates a mailbox queue, as detailed in @mq, on a port,
15674 * described by @phba by sending a MQ_CREATE mailbox command to the HBA.
15676 * The @phba struct is used to send mailbox command to HBA. The @cq struct
15679 * function will send the MQ_CREATE mailbox command to the HBA to setup the
15680 * mailbox queue. This function is asynchronous and will wait for the mailbox
15684 * memory this function will return -ENOMEM. If the queue create mailbox command
15685 * fails this function will return -ENXIO.
15698 uint32_t hw_page_size = phba->sli4_hba.pc_sli4_params.if_page_sz; in lpfc_mq_create()
15702 return -ENODEV; in lpfc_mq_create()
15703 if (!phba->sli4_hba.pc_sli4_params.supported) in lpfc_mq_create()
15706 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_mq_create()
15708 return -ENOMEM; in lpfc_mq_create()
15709 length = (sizeof(struct lpfc_mbx_mq_create_ext) - in lpfc_mq_create()
15715 mq_create_ext = &mbox->u.mqe.un.mq_create_ext; in lpfc_mq_create()
15716 shdr = (union lpfc_sli4_cfg_shdr *) &mq_create_ext->header.cfg_shdr; in lpfc_mq_create()
15718 &mq_create_ext->u.request, mq->page_count); in lpfc_mq_create()
15720 &mq_create_ext->u.request, 1); in lpfc_mq_create()
15722 &mq_create_ext->u.request, 1); in lpfc_mq_create()
15724 &mq_create_ext->u.request, 1); in lpfc_mq_create()
15726 &mq_create_ext->u.request, 1); in lpfc_mq_create()
15728 &mq_create_ext->u.request, 1); in lpfc_mq_create()
15729 bf_set(lpfc_mq_context_valid, &mq_create_ext->u.request.context, 1); in lpfc_mq_create()
15730 bf_set(lpfc_mbox_hdr_version, &shdr->request, in lpfc_mq_create()
15731 phba->sli4_hba.pc_sli4_params.mqv); in lpfc_mq_create()
15732 if (phba->sli4_hba.pc_sli4_params.mqv == LPFC_Q_CREATE_VERSION_1) in lpfc_mq_create()
15733 bf_set(lpfc_mbx_mq_create_ext_cq_id, &mq_create_ext->u.request, in lpfc_mq_create()
15734 cq->queue_id); in lpfc_mq_create()
15736 bf_set(lpfc_mq_context_cq_id, &mq_create_ext->u.request.context, in lpfc_mq_create()
15737 cq->queue_id); in lpfc_mq_create()
15738 switch (mq->entry_count) { in lpfc_mq_create()
15742 mq->entry_count); in lpfc_mq_create()
15743 if (mq->entry_count < 16) { in lpfc_mq_create()
15744 status = -EINVAL; in lpfc_mq_create()
15750 &mq_create_ext->u.request.context, in lpfc_mq_create()
15755 &mq_create_ext->u.request.context, in lpfc_mq_create()
15760 &mq_create_ext->u.request.context, in lpfc_mq_create()
15765 &mq_create_ext->u.request.context, in lpfc_mq_create()
15769 list_for_each_entry(dmabuf, &mq->page_list, list) { in lpfc_mq_create()
15770 memset(dmabuf->virt, 0, hw_page_size); in lpfc_mq_create()
15771 mq_create_ext->u.request.page[dmabuf->buffer_tag].addr_lo = in lpfc_mq_create()
15772 putPaddrLow(dmabuf->phys); in lpfc_mq_create()
15773 mq_create_ext->u.request.page[dmabuf->buffer_tag].addr_hi = in lpfc_mq_create()
15774 putPaddrHigh(dmabuf->phys); in lpfc_mq_create()
15777 mq->queue_id = bf_get(lpfc_mbx_mq_create_q_id, in lpfc_mq_create()
15778 &mq_create_ext->u.response); in lpfc_mq_create()
15785 mq_create = &mbox->u.mqe.un.mq_create; in lpfc_mq_create()
15787 shdr = (union lpfc_sli4_cfg_shdr *) &mq_create->header.cfg_shdr; in lpfc_mq_create()
15788 mq->queue_id = bf_get(lpfc_mbx_mq_create_q_id, in lpfc_mq_create()
15789 &mq_create->u.response); in lpfc_mq_create()
15792 /* The IOCTL status is embedded in the mailbox subheader. */ in lpfc_mq_create()
15793 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_mq_create()
15794 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_mq_create()
15797 "2502 MQ_CREATE mailbox failed with " in lpfc_mq_create()
15800 status = -ENXIO; in lpfc_mq_create()
15803 if (mq->queue_id == 0xFFFF) { in lpfc_mq_create()
15804 status = -ENXIO; in lpfc_mq_create()
15807 mq->type = LPFC_MQ; in lpfc_mq_create()
15808 mq->assoc_qid = cq->queue_id; in lpfc_mq_create()
15809 mq->subtype = subtype; in lpfc_mq_create()
15810 mq->host_index = 0; in lpfc_mq_create()
15811 mq->hba_index = 0; in lpfc_mq_create()
15814 list_add_tail(&mq->list, &cq->child_list); in lpfc_mq_create()
15816 mempool_free(mbox, phba->mbox_mem_pool); in lpfc_mq_create()
15821 * lpfc_wq_create - Create a Work Queue on the HBA
15828 * by @phba by sending a WQ_CREATE mailbox command to the HBA.
15830 * The @phba struct is used to send mailbox command to HBA. The @wq struct
15834 * function will send the WQ_CREATE mailbox command to the HBA to setup the
15835 * work queue. This function is asynchronous and will wait for the mailbox
15839 * memory this function will return -ENOMEM. If the queue create mailbox command
15840 * fails this function will return -ENXIO.
15852 uint32_t hw_page_size = phba->sli4_hba.pc_sli4_params.if_page_sz; in lpfc_wq_create()
15866 return -ENODEV; in lpfc_wq_create()
15867 if (!phba->sli4_hba.pc_sli4_params.supported) in lpfc_wq_create()
15868 hw_page_size = wq->page_size; in lpfc_wq_create()
15870 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_wq_create()
15872 return -ENOMEM; in lpfc_wq_create()
15873 length = (sizeof(struct lpfc_mbx_wq_create) - in lpfc_wq_create()
15878 wq_create = &mbox->u.mqe.un.wq_create; in lpfc_wq_create()
15879 shdr = (union lpfc_sli4_cfg_shdr *) &wq_create->header.cfg_shdr; in lpfc_wq_create()
15880 bf_set(lpfc_mbx_wq_create_num_pages, &wq_create->u.request, in lpfc_wq_create()
15881 wq->page_count); in lpfc_wq_create()
15882 bf_set(lpfc_mbx_wq_create_cq_id, &wq_create->u.request, in lpfc_wq_create()
15883 cq->queue_id); in lpfc_wq_create()
15886 bf_set(lpfc_mbox_hdr_version, &shdr->request, in lpfc_wq_create()
15887 phba->sli4_hba.pc_sli4_params.wqv); in lpfc_wq_create()
15889 if ((phba->sli4_hba.pc_sli4_params.wqsize & LPFC_WQ_SZ128_SUPPORT) || in lpfc_wq_create()
15890 (wq->page_size > SLI4_PAGE_SIZE)) in lpfc_wq_create()
15896 if (phba->sli4_hba.pc_sli4_params.wqsize & LPFC_WQ_SZ128_SUPPORT) in lpfc_wq_create()
15903 bf_set(lpfc_mbx_wq_create_wqe_count, &wq_create->u.request_1, in lpfc_wq_create()
15904 wq->entry_count); in lpfc_wq_create()
15905 bf_set(lpfc_mbox_hdr_version, &shdr->request, in lpfc_wq_create()
15908 switch (wq->entry_size) { in lpfc_wq_create()
15912 &wq_create->u.request_1, in lpfc_wq_create()
15917 &wq_create->u.request_1, in lpfc_wq_create()
15922 bf_set(lpfc_mbx_wq_create_dpp_req, &wq_create->u.request_1, 1); in lpfc_wq_create()
15924 &wq_create->u.request_1, in lpfc_wq_create()
15925 (wq->page_size / SLI4_PAGE_SIZE)); in lpfc_wq_create()
15926 page = wq_create->u.request_1.page; in lpfc_wq_create()
15929 page = wq_create->u.request.page; in lpfc_wq_create()
15933 list_for_each_entry(dmabuf, &wq->page_list, list) { in lpfc_wq_create()
15934 memset(dmabuf->virt, 0, hw_page_size); in lpfc_wq_create()
15935 page[dmabuf->buffer_tag].addr_lo = putPaddrLow(dmabuf->phys); in lpfc_wq_create()
15936 page[dmabuf->buffer_tag].addr_hi = putPaddrHigh(dmabuf->phys); in lpfc_wq_create()
15939 if (phba->sli4_hba.fw_func_mode & LPFC_DUA_MODE) in lpfc_wq_create()
15940 bf_set(lpfc_mbx_wq_create_dua, &wq_create->u.request, 1); in lpfc_wq_create()
15943 /* The IOCTL status is embedded in the mailbox subheader. */ in lpfc_wq_create()
15944 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_wq_create()
15945 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_wq_create()
15948 "2503 WQ_CREATE mailbox failed with " in lpfc_wq_create()
15951 status = -ENXIO; in lpfc_wq_create()
15956 wq->queue_id = bf_get(lpfc_mbx_wq_create_q_id, in lpfc_wq_create()
15957 &wq_create->u.response); in lpfc_wq_create()
15959 wq->queue_id = bf_get(lpfc_mbx_wq_create_v1_q_id, in lpfc_wq_create()
15960 &wq_create->u.response_1); in lpfc_wq_create()
15962 if (wq->queue_id == 0xFFFF) { in lpfc_wq_create()
15963 status = -ENXIO; in lpfc_wq_create()
15967 wq->db_format = LPFC_DB_LIST_FORMAT; in lpfc_wq_create()
15969 if (phba->sli4_hba.fw_func_mode & LPFC_DUA_MODE) { in lpfc_wq_create()
15970 wq->db_format = bf_get(lpfc_mbx_wq_create_db_format, in lpfc_wq_create()
15971 &wq_create->u.response); in lpfc_wq_create()
15972 if ((wq->db_format != LPFC_DB_LIST_FORMAT) && in lpfc_wq_create()
15973 (wq->db_format != LPFC_DB_RING_FORMAT)) { in lpfc_wq_create()
15977 wq->queue_id, wq->db_format); in lpfc_wq_create()
15978 status = -EINVAL; in lpfc_wq_create()
15982 &wq_create->u.response); in lpfc_wq_create()
15989 wq->queue_id, pci_barset); in lpfc_wq_create()
15990 status = -ENOMEM; in lpfc_wq_create()
15993 db_offset = wq_create->u.response.doorbell_offset; in lpfc_wq_create()
15999 wq->queue_id, db_offset); in lpfc_wq_create()
16000 status = -EINVAL; in lpfc_wq_create()
16003 wq->db_regaddr = bar_memmap_p + db_offset; in lpfc_wq_create()
16006 "format:x%x\n", wq->queue_id, in lpfc_wq_create()
16007 pci_barset, db_offset, wq->db_format); in lpfc_wq_create()
16009 wq->db_regaddr = phba->sli4_hba.WQDBregaddr; in lpfc_wq_create()
16012 wq->dpp_enable = bf_get(lpfc_mbx_wq_create_dpp_rsp, in lpfc_wq_create()
16013 &wq_create->u.response_1); in lpfc_wq_create()
16014 if (wq->dpp_enable) { in lpfc_wq_create()
16016 &wq_create->u.response_1); in lpfc_wq_create()
16023 wq->queue_id, pci_barset); in lpfc_wq_create()
16024 status = -ENOMEM; in lpfc_wq_create()
16027 db_offset = wq_create->u.response_1.doorbell_offset; in lpfc_wq_create()
16028 wq->db_regaddr = bar_memmap_p + db_offset; in lpfc_wq_create()
16029 wq->dpp_id = bf_get(lpfc_mbx_wq_create_dpp_id, in lpfc_wq_create()
16030 &wq_create->u.response_1); in lpfc_wq_create()
16032 &wq_create->u.response_1); in lpfc_wq_create()
16039 wq->queue_id, dpp_barset); in lpfc_wq_create()
16040 status = -ENOMEM; in lpfc_wq_create()
16043 dpp_offset = wq_create->u.response_1.dpp_offset; in lpfc_wq_create()
16044 wq->dpp_regaddr = bar_memmap_p + dpp_offset; in lpfc_wq_create()
16049 wq->queue_id, pci_barset, db_offset, in lpfc_wq_create()
16050 wq->dpp_id, dpp_barset, dpp_offset); in lpfc_wq_create()
16054 pg_addr = (unsigned long)(wq->dpp_regaddr) & PAGE_MASK; in lpfc_wq_create()
16059 "Write on WQ[%d] - disable DPP\n", in lpfc_wq_create()
16060 wq->queue_id); in lpfc_wq_create()
16061 phba->cfg_enable_dpp = 0; in lpfc_wq_create()
16064 phba->cfg_enable_dpp = 0; in lpfc_wq_create()
16067 wq->db_regaddr = phba->sli4_hba.WQDBregaddr; in lpfc_wq_create()
16069 wq->pring = kzalloc(sizeof(struct lpfc_sli_ring), GFP_KERNEL); in lpfc_wq_create()
16070 if (wq->pring == NULL) { in lpfc_wq_create()
16071 status = -ENOMEM; in lpfc_wq_create()
16074 wq->type = LPFC_WQ; in lpfc_wq_create()
16075 wq->assoc_qid = cq->queue_id; in lpfc_wq_create()
16076 wq->subtype = subtype; in lpfc_wq_create()
16077 wq->host_index = 0; in lpfc_wq_create()
16078 wq->hba_index = 0; in lpfc_wq_create()
16079 wq->notify_interval = LPFC_WQ_NOTIFY_INTRVL; in lpfc_wq_create()
16082 list_add_tail(&wq->list, &cq->child_list); in lpfc_wq_create()
16084 mempool_free(mbox, phba->mbox_mem_pool); in lpfc_wq_create()
16089 * lpfc_rq_create - Create a Receive Queue on the HBA
16097 * @drq, on a port, described by @phba by sending a RQ_CREATE mailbox command
16100 * The @phba struct is used to send mailbox command to HBA. The @drq and @hrq
16104 * This function will send the RQ_CREATE mailbox command to the HBA to setup the
16106 * mailbox command to finish before continuing.
16109 * memory this function will return -ENOMEM. If the queue create mailbox command
16110 * fails this function will return -ENXIO.
16122 uint32_t hw_page_size = phba->sli4_hba.pc_sli4_params.if_page_sz; in lpfc_rq_create()
16129 return -ENODEV; in lpfc_rq_create()
16130 if (!phba->sli4_hba.pc_sli4_params.supported) in lpfc_rq_create()
16133 if (hrq->entry_count != drq->entry_count) in lpfc_rq_create()
16134 return -EINVAL; in lpfc_rq_create()
16135 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_rq_create()
16137 return -ENOMEM; in lpfc_rq_create()
16138 length = (sizeof(struct lpfc_mbx_rq_create) - in lpfc_rq_create()
16143 rq_create = &mbox->u.mqe.un.rq_create; in lpfc_rq_create()
16144 shdr = (union lpfc_sli4_cfg_shdr *) &rq_create->header.cfg_shdr; in lpfc_rq_create()
16145 bf_set(lpfc_mbox_hdr_version, &shdr->request, in lpfc_rq_create()
16146 phba->sli4_hba.pc_sli4_params.rqv); in lpfc_rq_create()
16147 if (phba->sli4_hba.pc_sli4_params.rqv == LPFC_Q_CREATE_VERSION_1) { in lpfc_rq_create()
16149 &rq_create->u.request.context, in lpfc_rq_create()
16150 hrq->entry_count); in lpfc_rq_create()
16151 rq_create->u.request.context.buffer_size = LPFC_HDR_BUF_SIZE; in lpfc_rq_create()
16153 &rq_create->u.request.context, in lpfc_rq_create()
16156 &rq_create->u.request.context, in lpfc_rq_create()
16159 switch (hrq->entry_count) { in lpfc_rq_create()
16163 hrq->entry_count); in lpfc_rq_create()
16164 if (hrq->entry_count < 512) { in lpfc_rq_create()
16165 status = -EINVAL; in lpfc_rq_create()
16171 &rq_create->u.request.context, in lpfc_rq_create()
16176 &rq_create->u.request.context, in lpfc_rq_create()
16181 &rq_create->u.request.context, in lpfc_rq_create()
16186 &rq_create->u.request.context, in lpfc_rq_create()
16190 bf_set(lpfc_rq_context_buf_size, &rq_create->u.request.context, in lpfc_rq_create()
16193 bf_set(lpfc_rq_context_cq_id, &rq_create->u.request.context, in lpfc_rq_create()
16194 cq->queue_id); in lpfc_rq_create()
16195 bf_set(lpfc_mbx_rq_create_num_pages, &rq_create->u.request, in lpfc_rq_create()
16196 hrq->page_count); in lpfc_rq_create()
16197 list_for_each_entry(dmabuf, &hrq->page_list, list) { in lpfc_rq_create()
16198 memset(dmabuf->virt, 0, hw_page_size); in lpfc_rq_create()
16199 rq_create->u.request.page[dmabuf->buffer_tag].addr_lo = in lpfc_rq_create()
16200 putPaddrLow(dmabuf->phys); in lpfc_rq_create()
16201 rq_create->u.request.page[dmabuf->buffer_tag].addr_hi = in lpfc_rq_create()
16202 putPaddrHigh(dmabuf->phys); in lpfc_rq_create()
16204 if (phba->sli4_hba.fw_func_mode & LPFC_DUA_MODE) in lpfc_rq_create()
16205 bf_set(lpfc_mbx_rq_create_dua, &rq_create->u.request, 1); in lpfc_rq_create()
16208 /* The IOCTL status is embedded in the mailbox subheader. */ in lpfc_rq_create()
16209 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_rq_create()
16210 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_rq_create()
16213 "2504 RQ_CREATE mailbox failed with " in lpfc_rq_create()
16216 status = -ENXIO; in lpfc_rq_create()
16219 hrq->queue_id = bf_get(lpfc_mbx_rq_create_q_id, &rq_create->u.response); in lpfc_rq_create()
16220 if (hrq->queue_id == 0xFFFF) { in lpfc_rq_create()
16221 status = -ENXIO; in lpfc_rq_create()
16225 if (phba->sli4_hba.fw_func_mode & LPFC_DUA_MODE) { in lpfc_rq_create()
16226 hrq->db_format = bf_get(lpfc_mbx_rq_create_db_format, in lpfc_rq_create()
16227 &rq_create->u.response); in lpfc_rq_create()
16228 if ((hrq->db_format != LPFC_DB_LIST_FORMAT) && in lpfc_rq_create()
16229 (hrq->db_format != LPFC_DB_RING_FORMAT)) { in lpfc_rq_create()
16232 "supported: x%x\n", hrq->queue_id, in lpfc_rq_create()
16233 hrq->db_format); in lpfc_rq_create()
16234 status = -EINVAL; in lpfc_rq_create()
16239 &rq_create->u.response); in lpfc_rq_create()
16244 "barset:x%x\n", hrq->queue_id, in lpfc_rq_create()
16246 status = -ENOMEM; in lpfc_rq_create()
16250 db_offset = rq_create->u.response.doorbell_offset; in lpfc_rq_create()
16255 "supported: x%x\n", hrq->queue_id, in lpfc_rq_create()
16257 status = -EINVAL; in lpfc_rq_create()
16260 hrq->db_regaddr = bar_memmap_p + db_offset; in lpfc_rq_create()
16263 "format:x%x\n", hrq->queue_id, pci_barset, in lpfc_rq_create()
16264 db_offset, hrq->db_format); in lpfc_rq_create()
16266 hrq->db_format = LPFC_DB_RING_FORMAT; in lpfc_rq_create()
16267 hrq->db_regaddr = phba->sli4_hba.RQDBregaddr; in lpfc_rq_create()
16269 hrq->type = LPFC_HRQ; in lpfc_rq_create()
16270 hrq->assoc_qid = cq->queue_id; in lpfc_rq_create()
16271 hrq->subtype = subtype; in lpfc_rq_create()
16272 hrq->host_index = 0; in lpfc_rq_create()
16273 hrq->hba_index = 0; in lpfc_rq_create()
16274 hrq->notify_interval = LPFC_RQ_NOTIFY_INTRVL; in lpfc_rq_create()
16280 bf_set(lpfc_mbox_hdr_version, &shdr->request, in lpfc_rq_create()
16281 phba->sli4_hba.pc_sli4_params.rqv); in lpfc_rq_create()
16282 if (phba->sli4_hba.pc_sli4_params.rqv == LPFC_Q_CREATE_VERSION_1) { in lpfc_rq_create()
16284 &rq_create->u.request.context, hrq->entry_count); in lpfc_rq_create()
16286 rq_create->u.request.context.buffer_size = in lpfc_rq_create()
16289 rq_create->u.request.context.buffer_size = in lpfc_rq_create()
16291 bf_set(lpfc_rq_context_rqe_size, &rq_create->u.request.context, in lpfc_rq_create()
16293 bf_set(lpfc_rq_context_page_size, &rq_create->u.request.context, in lpfc_rq_create()
16296 switch (drq->entry_count) { in lpfc_rq_create()
16300 drq->entry_count); in lpfc_rq_create()
16301 if (drq->entry_count < 512) { in lpfc_rq_create()
16302 status = -EINVAL; in lpfc_rq_create()
16308 &rq_create->u.request.context, in lpfc_rq_create()
16313 &rq_create->u.request.context, in lpfc_rq_create()
16318 &rq_create->u.request.context, in lpfc_rq_create()
16323 &rq_create->u.request.context, in lpfc_rq_create()
16329 &rq_create->u.request.context, in lpfc_rq_create()
16333 &rq_create->u.request.context, in lpfc_rq_create()
16336 bf_set(lpfc_rq_context_cq_id, &rq_create->u.request.context, in lpfc_rq_create()
16337 cq->queue_id); in lpfc_rq_create()
16338 bf_set(lpfc_mbx_rq_create_num_pages, &rq_create->u.request, in lpfc_rq_create()
16339 drq->page_count); in lpfc_rq_create()
16340 list_for_each_entry(dmabuf, &drq->page_list, list) { in lpfc_rq_create()
16341 rq_create->u.request.page[dmabuf->buffer_tag].addr_lo = in lpfc_rq_create()
16342 putPaddrLow(dmabuf->phys); in lpfc_rq_create()
16343 rq_create->u.request.page[dmabuf->buffer_tag].addr_hi = in lpfc_rq_create()
16344 putPaddrHigh(dmabuf->phys); in lpfc_rq_create()
16346 if (phba->sli4_hba.fw_func_mode & LPFC_DUA_MODE) in lpfc_rq_create()
16347 bf_set(lpfc_mbx_rq_create_dua, &rq_create->u.request, 1); in lpfc_rq_create()
16349 /* The IOCTL status is embedded in the mailbox subheader. */ in lpfc_rq_create()
16350 shdr = (union lpfc_sli4_cfg_shdr *) &rq_create->header.cfg_shdr; in lpfc_rq_create()
16351 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_rq_create()
16352 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_rq_create()
16354 status = -ENXIO; in lpfc_rq_create()
16357 drq->queue_id = bf_get(lpfc_mbx_rq_create_q_id, &rq_create->u.response); in lpfc_rq_create()
16358 if (drq->queue_id == 0xFFFF) { in lpfc_rq_create()
16359 status = -ENXIO; in lpfc_rq_create()
16362 drq->type = LPFC_DRQ; in lpfc_rq_create()
16363 drq->assoc_qid = cq->queue_id; in lpfc_rq_create()
16364 drq->subtype = subtype; in lpfc_rq_create()
16365 drq->host_index = 0; in lpfc_rq_create()
16366 drq->hba_index = 0; in lpfc_rq_create()
16367 drq->notify_interval = LPFC_RQ_NOTIFY_INTRVL; in lpfc_rq_create()
16370 list_add_tail(&hrq->list, &cq->child_list); in lpfc_rq_create()
16371 list_add_tail(&drq->list, &cq->child_list); in lpfc_rq_create()
16374 mempool_free(mbox, phba->mbox_mem_pool); in lpfc_rq_create()
16379 * lpfc_mrq_create - Create MRQ Receive Queues on the HBA
16387 * @drq, on a port, described by @phba by sending a RQ_CREATE mailbox command
16390 * The @phba struct is used to send mailbox command to HBA. The @drq and @hrq
16394 * This function will send the RQ_CREATE mailbox command to the HBA to setup the
16396 * mailbox command to finish before continuing.
16399 * memory this function will return -ENOMEM. If the queue create mailbox command
16400 * fails this function will return -ENXIO.
16415 uint32_t hw_page_size = phba->sli4_hba.pc_sli4_params.if_page_sz; in lpfc_mrq_create()
16417 numrq = phba->cfg_nvmet_mrq; in lpfc_mrq_create()
16420 return -ENODEV; in lpfc_mrq_create()
16421 if (!phba->sli4_hba.pc_sli4_params.supported) in lpfc_mrq_create()
16424 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_mrq_create()
16426 return -ENOMEM; in lpfc_mrq_create()
16429 length += ((2 * numrq * hrqp[0]->page_count) * in lpfc_mrq_create()
16440 status = -ENOMEM; in lpfc_mrq_create()
16446 rq_create = mbox->sge_array->addr[0]; in lpfc_mrq_create()
16447 shdr = (union lpfc_sli4_cfg_shdr *)&rq_create->cfg_shdr; in lpfc_mrq_create()
16449 bf_set(lpfc_mbox_hdr_version, &shdr->request, LPFC_Q_CREATE_VERSION_2); in lpfc_mrq_create()
16459 status = -ENODEV; in lpfc_mrq_create()
16463 if (hrq->entry_count != drq->entry_count) { in lpfc_mrq_create()
16464 status = -EINVAL; in lpfc_mrq_create()
16470 &rq_create->u.request, in lpfc_mrq_create()
16471 hrq->page_count); in lpfc_mrq_create()
16473 &rq_create->u.request, (numrq * 2)); in lpfc_mrq_create()
16474 bf_set(lpfc_mbx_rq_create_dnb, &rq_create->u.request, in lpfc_mrq_create()
16477 &rq_create->u.request.context, in lpfc_mrq_create()
16478 cq->queue_id); in lpfc_mrq_create()
16480 &rq_create->u.request.context, in lpfc_mrq_create()
16483 &rq_create->u.request.context, in lpfc_mrq_create()
16486 &rq_create->u.request.context, in lpfc_mrq_create()
16487 hrq->entry_count); in lpfc_mrq_create()
16489 &rq_create->u.request.context, in lpfc_mrq_create()
16492 &rq_create->u.request.context, in lpfc_mrq_create()
16496 list_for_each_entry(dmabuf, &hrq->page_list, list) { in lpfc_mrq_create()
16497 memset(dmabuf->virt, 0, hw_page_size); in lpfc_mrq_create()
16498 cnt = page_idx + dmabuf->buffer_tag; in lpfc_mrq_create()
16499 rq_create->u.request.page[cnt].addr_lo = in lpfc_mrq_create()
16500 putPaddrLow(dmabuf->phys); in lpfc_mrq_create()
16501 rq_create->u.request.page[cnt].addr_hi = in lpfc_mrq_create()
16502 putPaddrHigh(dmabuf->phys); in lpfc_mrq_create()
16508 list_for_each_entry(dmabuf, &drq->page_list, list) { in lpfc_mrq_create()
16509 memset(dmabuf->virt, 0, hw_page_size); in lpfc_mrq_create()
16510 cnt = page_idx + dmabuf->buffer_tag; in lpfc_mrq_create()
16511 rq_create->u.request.page[cnt].addr_lo = in lpfc_mrq_create()
16512 putPaddrLow(dmabuf->phys); in lpfc_mrq_create()
16513 rq_create->u.request.page[cnt].addr_hi = in lpfc_mrq_create()
16514 putPaddrHigh(dmabuf->phys); in lpfc_mrq_create()
16519 hrq->db_format = LPFC_DB_RING_FORMAT; in lpfc_mrq_create()
16520 hrq->db_regaddr = phba->sli4_hba.RQDBregaddr; in lpfc_mrq_create()
16521 hrq->type = LPFC_HRQ; in lpfc_mrq_create()
16522 hrq->assoc_qid = cq->queue_id; in lpfc_mrq_create()
16523 hrq->subtype = subtype; in lpfc_mrq_create()
16524 hrq->host_index = 0; in lpfc_mrq_create()
16525 hrq->hba_index = 0; in lpfc_mrq_create()
16526 hrq->notify_interval = LPFC_RQ_NOTIFY_INTRVL; in lpfc_mrq_create()
16528 drq->db_format = LPFC_DB_RING_FORMAT; in lpfc_mrq_create()
16529 drq->db_regaddr = phba->sli4_hba.RQDBregaddr; in lpfc_mrq_create()
16530 drq->type = LPFC_DRQ; in lpfc_mrq_create()
16531 drq->assoc_qid = cq->queue_id; in lpfc_mrq_create()
16532 drq->subtype = subtype; in lpfc_mrq_create()
16533 drq->host_index = 0; in lpfc_mrq_create()
16534 drq->hba_index = 0; in lpfc_mrq_create()
16535 drq->notify_interval = LPFC_RQ_NOTIFY_INTRVL; in lpfc_mrq_create()
16537 list_add_tail(&hrq->list, &cq->child_list); in lpfc_mrq_create()
16538 list_add_tail(&drq->list, &cq->child_list); in lpfc_mrq_create()
16542 /* The IOCTL status is embedded in the mailbox subheader. */ in lpfc_mrq_create()
16543 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_mrq_create()
16544 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_mrq_create()
16547 "3120 RQ_CREATE mailbox failed with " in lpfc_mrq_create()
16550 status = -ENXIO; in lpfc_mrq_create()
16553 rc = bf_get(lpfc_mbx_rq_create_q_id, &rq_create->u.response); in lpfc_mrq_create()
16555 status = -ENXIO; in lpfc_mrq_create()
16562 hrq->queue_id = rc + (2 * idx); in lpfc_mrq_create()
16564 drq->queue_id = rc + (2 * idx) + 1; in lpfc_mrq_create()
16573 * lpfc_eq_destroy - Destroy an event Queue on the HBA
16577 * This function destroys a queue, as detailed in @eq by sending an mailbox
16582 * On success this function will return a zero. If the queue destroy mailbox
16583 * command fails this function will return -ENXIO.
16595 return -ENODEV; in lpfc_eq_destroy()
16597 mbox = mempool_alloc(eq->phba->mbox_mem_pool, GFP_KERNEL); in lpfc_eq_destroy()
16599 return -ENOMEM; in lpfc_eq_destroy()
16600 length = (sizeof(struct lpfc_mbx_eq_destroy) - in lpfc_eq_destroy()
16605 bf_set(lpfc_mbx_eq_destroy_q_id, &mbox->u.mqe.un.eq_destroy.u.request, in lpfc_eq_destroy()
16606 eq->queue_id); in lpfc_eq_destroy()
16607 mbox->vport = eq->phba->pport; in lpfc_eq_destroy()
16608 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_eq_destroy()
16610 rc = lpfc_sli_issue_mbox(eq->phba, mbox, MBX_POLL); in lpfc_eq_destroy()
16611 /* The IOCTL status is embedded in the mailbox subheader. */ in lpfc_eq_destroy()
16613 &mbox->u.mqe.un.eq_destroy.header.cfg_shdr; in lpfc_eq_destroy()
16614 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_eq_destroy()
16615 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_eq_destroy()
16618 "2505 EQ_DESTROY mailbox failed with " in lpfc_eq_destroy()
16621 status = -ENXIO; in lpfc_eq_destroy()
16625 list_del_init(&eq->list); in lpfc_eq_destroy()
16626 mempool_free(mbox, eq->phba->mbox_mem_pool); in lpfc_eq_destroy()
16631 * lpfc_cq_destroy - Destroy a Completion Queue on the HBA
16635 * This function destroys a queue, as detailed in @cq by sending an mailbox
16640 * On success this function will return a zero. If the queue destroy mailbox
16641 * command fails this function will return -ENXIO.
16653 return -ENODEV; in lpfc_cq_destroy()
16654 mbox = mempool_alloc(cq->phba->mbox_mem_pool, GFP_KERNEL); in lpfc_cq_destroy()
16656 return -ENOMEM; in lpfc_cq_destroy()
16657 length = (sizeof(struct lpfc_mbx_cq_destroy) - in lpfc_cq_destroy()
16662 bf_set(lpfc_mbx_cq_destroy_q_id, &mbox->u.mqe.un.cq_destroy.u.request, in lpfc_cq_destroy()
16663 cq->queue_id); in lpfc_cq_destroy()
16664 mbox->vport = cq->phba->pport; in lpfc_cq_destroy()
16665 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_cq_destroy()
16666 rc = lpfc_sli_issue_mbox(cq->phba, mbox, MBX_POLL); in lpfc_cq_destroy()
16667 /* The IOCTL status is embedded in the mailbox subheader. */ in lpfc_cq_destroy()
16669 &mbox->u.mqe.un.wq_create.header.cfg_shdr; in lpfc_cq_destroy()
16670 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_cq_destroy()
16671 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_cq_destroy()
16674 "2506 CQ_DESTROY mailbox failed with " in lpfc_cq_destroy()
16677 status = -ENXIO; in lpfc_cq_destroy()
16680 list_del_init(&cq->list); in lpfc_cq_destroy()
16681 mempool_free(mbox, cq->phba->mbox_mem_pool); in lpfc_cq_destroy()
16686 * lpfc_mq_destroy - Destroy a Mailbox Queue on the HBA
16690 * This function destroys a queue, as detailed in @mq by sending an mailbox
16695 * On success this function will return a zero. If the queue destroy mailbox
16696 * command fails this function will return -ENXIO.
16708 return -ENODEV; in lpfc_mq_destroy()
16709 mbox = mempool_alloc(mq->phba->mbox_mem_pool, GFP_KERNEL); in lpfc_mq_destroy()
16711 return -ENOMEM; in lpfc_mq_destroy()
16712 length = (sizeof(struct lpfc_mbx_mq_destroy) - in lpfc_mq_destroy()
16717 bf_set(lpfc_mbx_mq_destroy_q_id, &mbox->u.mqe.un.mq_destroy.u.request, in lpfc_mq_destroy()
16718 mq->queue_id); in lpfc_mq_destroy()
16719 mbox->vport = mq->phba->pport; in lpfc_mq_destroy()
16720 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_mq_destroy()
16721 rc = lpfc_sli_issue_mbox(mq->phba, mbox, MBX_POLL); in lpfc_mq_destroy()
16722 /* The IOCTL status is embedded in the mailbox subheader. */ in lpfc_mq_destroy()
16724 &mbox->u.mqe.un.mq_destroy.header.cfg_shdr; in lpfc_mq_destroy()
16725 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_mq_destroy()
16726 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_mq_destroy()
16729 "2507 MQ_DESTROY mailbox failed with " in lpfc_mq_destroy()
16732 status = -ENXIO; in lpfc_mq_destroy()
16735 list_del_init(&mq->list); in lpfc_mq_destroy()
16736 mempool_free(mbox, mq->phba->mbox_mem_pool); in lpfc_mq_destroy()
16741 * lpfc_wq_destroy - Destroy a Work Queue on the HBA
16745 * This function destroys a queue, as detailed in @wq by sending an mailbox
16750 * On success this function will return a zero. If the queue destroy mailbox
16751 * command fails this function will return -ENXIO.
16763 return -ENODEV; in lpfc_wq_destroy()
16764 mbox = mempool_alloc(wq->phba->mbox_mem_pool, GFP_KERNEL); in lpfc_wq_destroy()
16766 return -ENOMEM; in lpfc_wq_destroy()
16767 length = (sizeof(struct lpfc_mbx_wq_destroy) - in lpfc_wq_destroy()
16772 bf_set(lpfc_mbx_wq_destroy_q_id, &mbox->u.mqe.un.wq_destroy.u.request, in lpfc_wq_destroy()
16773 wq->queue_id); in lpfc_wq_destroy()
16774 mbox->vport = wq->phba->pport; in lpfc_wq_destroy()
16775 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_wq_destroy()
16776 rc = lpfc_sli_issue_mbox(wq->phba, mbox, MBX_POLL); in lpfc_wq_destroy()
16778 &mbox->u.mqe.un.wq_destroy.header.cfg_shdr; in lpfc_wq_destroy()
16779 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_wq_destroy()
16780 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_wq_destroy()
16783 "2508 WQ_DESTROY mailbox failed with " in lpfc_wq_destroy()
16786 status = -ENXIO; in lpfc_wq_destroy()
16789 list_del_init(&wq->list); in lpfc_wq_destroy()
16790 kfree(wq->pring); in lpfc_wq_destroy()
16791 wq->pring = NULL; in lpfc_wq_destroy()
16792 mempool_free(mbox, wq->phba->mbox_mem_pool); in lpfc_wq_destroy()
16797 * lpfc_rq_destroy - Destroy a Receive Queue on the HBA
16802 * This function destroys a queue, as detailed in @rq by sending an mailbox
16807 * On success this function will return a zero. If the queue destroy mailbox
16808 * command fails this function will return -ENXIO.
16821 return -ENODEV; in lpfc_rq_destroy()
16822 mbox = mempool_alloc(hrq->phba->mbox_mem_pool, GFP_KERNEL); in lpfc_rq_destroy()
16824 return -ENOMEM; in lpfc_rq_destroy()
16825 length = (sizeof(struct lpfc_mbx_rq_destroy) - in lpfc_rq_destroy()
16830 bf_set(lpfc_mbx_rq_destroy_q_id, &mbox->u.mqe.un.rq_destroy.u.request, in lpfc_rq_destroy()
16831 hrq->queue_id); in lpfc_rq_destroy()
16832 mbox->vport = hrq->phba->pport; in lpfc_rq_destroy()
16833 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_rq_destroy()
16834 rc = lpfc_sli_issue_mbox(hrq->phba, mbox, MBX_POLL); in lpfc_rq_destroy()
16835 /* The IOCTL status is embedded in the mailbox subheader. */ in lpfc_rq_destroy()
16837 &mbox->u.mqe.un.rq_destroy.header.cfg_shdr; in lpfc_rq_destroy()
16838 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_rq_destroy()
16839 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_rq_destroy()
16842 "2509 RQ_DESTROY mailbox failed with " in lpfc_rq_destroy()
16845 mempool_free(mbox, hrq->phba->mbox_mem_pool); in lpfc_rq_destroy()
16846 return -ENXIO; in lpfc_rq_destroy()
16848 bf_set(lpfc_mbx_rq_destroy_q_id, &mbox->u.mqe.un.rq_destroy.u.request, in lpfc_rq_destroy()
16849 drq->queue_id); in lpfc_rq_destroy()
16850 rc = lpfc_sli_issue_mbox(drq->phba, mbox, MBX_POLL); in lpfc_rq_destroy()
16852 &mbox->u.mqe.un.rq_destroy.header.cfg_shdr; in lpfc_rq_destroy()
16853 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_rq_destroy()
16854 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_rq_destroy()
16857 "2510 RQ_DESTROY mailbox failed with " in lpfc_rq_destroy()
16860 status = -ENXIO; in lpfc_rq_destroy()
16862 list_del_init(&hrq->list); in lpfc_rq_destroy()
16863 list_del_init(&drq->list); in lpfc_rq_destroy()
16864 mempool_free(mbox, hrq->phba->mbox_mem_pool); in lpfc_rq_destroy()
16869 * lpfc_sli4_post_sgl - Post scatter gather list for an XRI to HBA
16887 * 0 - Success
16888 * -ENXIO, -ENOMEM - Failure
16906 return -EINVAL; in lpfc_sli4_post_sgl()
16909 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_post_sgl()
16911 return -ENOMEM; in lpfc_sli4_post_sgl()
16915 sizeof(struct lpfc_mbx_post_sgl_pages) - in lpfc_sli4_post_sgl()
16919 &mbox->u.mqe.un.post_sgl_pages; in lpfc_sli4_post_sgl()
16923 post_sgl_pages->sgl_pg_pairs[0].sgl_pg0_addr_lo = in lpfc_sli4_post_sgl()
16925 post_sgl_pages->sgl_pg_pairs[0].sgl_pg0_addr_hi = in lpfc_sli4_post_sgl()
16928 post_sgl_pages->sgl_pg_pairs[0].sgl_pg1_addr_lo = in lpfc_sli4_post_sgl()
16930 post_sgl_pages->sgl_pg_pairs[0].sgl_pg1_addr_hi = in lpfc_sli4_post_sgl()
16932 if (!phba->sli4_hba.intr_enable) in lpfc_sli4_post_sgl()
16938 /* The IOCTL status is embedded in the mailbox subheader. */ in lpfc_sli4_post_sgl()
16939 shdr = (union lpfc_sli4_cfg_shdr *) &post_sgl_pages->header.cfg_shdr; in lpfc_sli4_post_sgl()
16940 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_sli4_post_sgl()
16941 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_sli4_post_sgl()
16942 if (!phba->sli4_hba.intr_enable) in lpfc_sli4_post_sgl()
16943 mempool_free(mbox, phba->mbox_mem_pool); in lpfc_sli4_post_sgl()
16945 mempool_free(mbox, phba->mbox_mem_pool); in lpfc_sli4_post_sgl()
16948 "2511 POST_SGL mailbox failed with " in lpfc_sli4_post_sgl()
16956 * lpfc_sli4_alloc_xri - Get an available rpi in the device's range
16960 * HBA consistent with the SLI-4 interface spec. This routine
16977 spin_lock_irq(&phba->hbalock); in lpfc_sli4_alloc_xri()
16978 xri = find_next_zero_bit(phba->sli4_hba.xri_bmask, in lpfc_sli4_alloc_xri()
16979 phba->sli4_hba.max_cfg_param.max_xri, 0); in lpfc_sli4_alloc_xri()
16980 if (xri >= phba->sli4_hba.max_cfg_param.max_xri) { in lpfc_sli4_alloc_xri()
16981 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_alloc_xri()
16984 set_bit(xri, phba->sli4_hba.xri_bmask); in lpfc_sli4_alloc_xri()
16985 phba->sli4_hba.max_cfg_param.xri_used++; in lpfc_sli4_alloc_xri()
16987 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_alloc_xri()
16992 * lpfc_sli4_free_xri - Release an xri for reuse.
17002 if (test_and_clear_bit(xri, phba->sli4_hba.xri_bmask)) { in __lpfc_sli4_free_xri()
17003 phba->sli4_hba.max_cfg_param.xri_used--; in __lpfc_sli4_free_xri()
17008 * lpfc_sli4_free_xri - Release an xri for reuse.
17018 spin_lock_irq(&phba->hbalock); in lpfc_sli4_free_xri()
17020 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_free_xri()
17024 * lpfc_sli4_next_xritag - Get an xritag for the io
17044 phba->sli4_hba.max_cfg_param.max_xri, in lpfc_sli4_next_xritag()
17045 phba->sli4_hba.max_cfg_param.xri_used); in lpfc_sli4_next_xritag()
17050 * lpfc_sli4_post_sgl_list - post a block of ELS sgls to the port.
17056 * HBA using non-embedded mailbox command. No Lock is held. This routine
17083 return -ENOMEM; in lpfc_sli4_post_sgl_list()
17086 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_post_sgl_list()
17088 return -ENOMEM; in lpfc_sli4_post_sgl_list()
17090 /* Allocate DMA memory and set up the non-embedded mailbox command */ in lpfc_sli4_post_sgl_list()
17101 return -ENOMEM; in lpfc_sli4_post_sgl_list()
17103 /* Set up the SGL pages in the non-embedded DMA pages */ in lpfc_sli4_post_sgl_list()
17104 viraddr = mbox->sge_array->addr[0]; in lpfc_sli4_post_sgl_list()
17106 sgl_pg_pairs = &sgl->sgl_pg_pairs; in lpfc_sli4_post_sgl_list()
17111 sgl_pg_pairs->sgl_pg0_addr_lo = in lpfc_sli4_post_sgl_list()
17112 cpu_to_le32(putPaddrLow(sglq_entry->phys)); in lpfc_sli4_post_sgl_list()
17113 sgl_pg_pairs->sgl_pg0_addr_hi = in lpfc_sli4_post_sgl_list()
17114 cpu_to_le32(putPaddrHigh(sglq_entry->phys)); in lpfc_sli4_post_sgl_list()
17115 sgl_pg_pairs->sgl_pg1_addr_lo = in lpfc_sli4_post_sgl_list()
17117 sgl_pg_pairs->sgl_pg1_addr_hi = in lpfc_sli4_post_sgl_list()
17122 xritag_start = sglq_entry->sli4_xritag; in lpfc_sli4_post_sgl_list()
17130 sgl->word0 = cpu_to_le32(sgl->word0); in lpfc_sli4_post_sgl_list()
17132 if (!phba->sli4_hba.intr_enable) in lpfc_sli4_post_sgl_list()
17138 shdr = (union lpfc_sli4_cfg_shdr *) &sgl->cfg_shdr; in lpfc_sli4_post_sgl_list()
17139 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_sli4_post_sgl_list()
17140 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_sli4_post_sgl_list()
17141 if (!phba->sli4_hba.intr_enable) in lpfc_sli4_post_sgl_list()
17147 "2513 POST_SGL_BLOCK mailbox command failed " in lpfc_sli4_post_sgl_list()
17150 rc = -ENXIO; in lpfc_sli4_post_sgl_list()
17156 * lpfc_sli4_post_io_sgl_block - post a block of nvme sgl list to firmware
17162 * SCSI buffer list @nblist to the HBA using non-embedded mailbox command.
17190 return -ENOMEM; in lpfc_sli4_post_io_sgl_block()
17192 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_post_io_sgl_block()
17196 return -ENOMEM; in lpfc_sli4_post_io_sgl_block()
17199 /* Allocate DMA memory and set up the non-embedded mailbox command */ in lpfc_sli4_post_io_sgl_block()
17210 return -ENOMEM; in lpfc_sli4_post_io_sgl_block()
17213 /* Get the first SGE entry from the non-embedded DMA memory */ in lpfc_sli4_post_io_sgl_block()
17214 viraddr = mbox->sge_array->addr[0]; in lpfc_sli4_post_io_sgl_block()
17216 /* Set up the SGL pages in the non-embedded DMA pages */ in lpfc_sli4_post_io_sgl_block()
17218 sgl_pg_pairs = &sgl->sgl_pg_pairs; in lpfc_sli4_post_io_sgl_block()
17223 sgl_pg_pairs->sgl_pg0_addr_lo = in lpfc_sli4_post_io_sgl_block()
17224 cpu_to_le32(putPaddrLow(lpfc_ncmd->dma_phys_sgl)); in lpfc_sli4_post_io_sgl_block()
17225 sgl_pg_pairs->sgl_pg0_addr_hi = in lpfc_sli4_post_io_sgl_block()
17226 cpu_to_le32(putPaddrHigh(lpfc_ncmd->dma_phys_sgl)); in lpfc_sli4_post_io_sgl_block()
17227 if (phba->cfg_sg_dma_buf_size > SGL_PAGE_SIZE) in lpfc_sli4_post_io_sgl_block()
17228 pdma_phys_bpl1 = lpfc_ncmd->dma_phys_sgl + in lpfc_sli4_post_io_sgl_block()
17232 sgl_pg_pairs->sgl_pg1_addr_lo = in lpfc_sli4_post_io_sgl_block()
17234 sgl_pg_pairs->sgl_pg1_addr_hi = in lpfc_sli4_post_io_sgl_block()
17238 xritag_start = lpfc_ncmd->cur_iocbq.sli4_xritag; in lpfc_sli4_post_io_sgl_block()
17245 sgl->word0 = cpu_to_le32(sgl->word0); in lpfc_sli4_post_io_sgl_block()
17247 if (!phba->sli4_hba.intr_enable) { in lpfc_sli4_post_io_sgl_block()
17253 shdr = (union lpfc_sli4_cfg_shdr *)&sgl->cfg_shdr; in lpfc_sli4_post_io_sgl_block()
17254 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_sli4_post_io_sgl_block()
17255 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_sli4_post_io_sgl_block()
17256 if (!phba->sli4_hba.intr_enable) in lpfc_sli4_post_io_sgl_block()
17262 "6125 POST_SGL_BLOCK mailbox command failed " in lpfc_sli4_post_io_sgl_block()
17265 rc = -ENXIO; in lpfc_sli4_post_io_sgl_block()
17271 * lpfc_sli4_post_io_sgl_list - Post blocks of nvme buffer sgls from a list
17278 * uses the non-embedded SGL block post mailbox commands to post to the port.
17279 * For single NVME buffer sgl with non-contiguous xri, if any, it shall use
17280 * embedded SGL post mailbox command for posting. The @post_nblist passed in
17283 * Returns: 0 = failure, non-zero number of successfully posted buffers.
17301 return -EINVAL; in lpfc_sli4_post_io_sgl_list()
17303 sgl_size = phba->cfg_sg_dma_buf_size; in lpfc_sli4_post_io_sgl_list()
17305 list_del_init(&lpfc_ncmd->list); in lpfc_sli4_post_io_sgl_list()
17308 (lpfc_ncmd->cur_iocbq.sli4_xritag != last_xritag + 1)) { in lpfc_sli4_post_io_sgl_list()
17311 post_cnt = block_cnt - 1; in lpfc_sli4_post_io_sgl_list()
17313 list_add_tail(&lpfc_ncmd->list, &prep_nblist); in lpfc_sli4_post_io_sgl_list()
17317 list_add_tail(&lpfc_ncmd->list, &prep_nblist); in lpfc_sli4_post_io_sgl_list()
17318 /* enough sgls for non-embed sgl mbox command */ in lpfc_sli4_post_io_sgl_list()
17326 last_xritag = lpfc_ncmd->cur_iocbq.sli4_xritag; in lpfc_sli4_post_io_sgl_list()
17335 /* last single sgl with non-contiguous xri */ in lpfc_sli4_post_io_sgl_list()
17338 lpfc_ncmd->dma_phys_sgl + in lpfc_sli4_post_io_sgl_list()
17342 cur_xritag = lpfc_ncmd->cur_iocbq.sli4_xritag; in lpfc_sli4_post_io_sgl_list()
17344 phba, lpfc_ncmd->dma_phys_sgl, in lpfc_sli4_post_io_sgl_list()
17348 lpfc_ncmd->flags |= in lpfc_sli4_post_io_sgl_list()
17352 lpfc_ncmd->flags &= in lpfc_sli4_post_io_sgl_list()
17354 lpfc_ncmd->status = IOSTAT_SUCCESS; in lpfc_sli4_post_io_sgl_list()
17358 list_add_tail(&lpfc_ncmd->list, &nvme_nblist); in lpfc_sli4_post_io_sgl_list()
17377 /* put posted NVME buffer-sgl posted on NVME buffer sgl list */ in lpfc_sli4_post_io_sgl_list()
17383 lpfc_ncmd->flags |= LPFC_SBUF_NOT_POSTED; in lpfc_sli4_post_io_sgl_list()
17386 lpfc_ncmd->flags &= ~LPFC_SBUF_NOT_POSTED; in lpfc_sli4_post_io_sgl_list()
17387 lpfc_ncmd->status = IOSTAT_SUCCESS; in lpfc_sli4_post_io_sgl_list()
17390 list_add_tail(&lpfc_ncmd->list, &nvme_nblist); in lpfc_sli4_post_io_sgl_list()
17400 * lpfc_fc_frame_check - Check that this frame is a valid frame to handle
17418 switch (fc_hdr->fh_r_ctl) { in lpfc_fc_frame_check()
17429 case FC_RCTL_ELS4_REQ: /* FC-4 ELS request */ in lpfc_fc_frame_check()
17430 case FC_RCTL_ELS4_REP: /* FC-4 ELS reply */ in lpfc_fc_frame_check()
17456 switch (fc_hdr->fh_type) { in lpfc_fc_frame_check()
17472 fc_hdr->fh_r_ctl, fc_hdr->fh_type, in lpfc_fc_frame_check()
17481 fc_hdr->fh_r_ctl, fc_hdr->fh_type); in lpfc_fc_frame_check()
17486 * lpfc_fc_hdr_get_vfi - Get the VFI from an FC frame
17498 if (fc_hdr->fh_r_ctl != FC_RCTL_VFTH) in lpfc_fc_hdr_get_vfi()
17504 * lpfc_fc_frame_to_vport - Finds the vport that a frame is destined to
17525 return phba->pport; in lpfc_fc_frame_to_vport()
17526 if ((phba->pport->fc_flag & FC_PT2PT) && in lpfc_fc_frame_to_vport()
17527 !(phba->link_state == LPFC_HBA_READY)) in lpfc_fc_frame_to_vport()
17528 return phba->pport; in lpfc_fc_frame_to_vport()
17532 for (i = 0; i <= phba->max_vpi && vports[i] != NULL; i++) { in lpfc_fc_frame_to_vport()
17533 if (phba->fcf.fcfi == fcfi && in lpfc_fc_frame_to_vport()
17534 vports[i]->vfi == lpfc_fc_hdr_get_vfi(fc_hdr) && in lpfc_fc_frame_to_vport()
17535 vports[i]->fc_myDID == did) { in lpfc_fc_frame_to_vport()
17546 * lpfc_update_rcv_time_stamp - Update vport's rcv seq time stamp
17562 h_buf = list_get_first(&vport->rcv_buffer_list, in lpfc_update_rcv_time_stamp()
17567 vport->rcv_buffer_time_stamp = dmabuf->time_stamp; in lpfc_update_rcv_time_stamp()
17571 * lpfc_cleanup_rcv_buffers - Cleans up all outstanding receive sequences.
17586 list_for_each_entry_safe(h_buf, hnext, &vport->rcv_buffer_list, list) { in lpfc_cleanup_rcv_buffers()
17588 list_del_init(&dmabuf->hbuf.list); in lpfc_cleanup_rcv_buffers()
17590 &dmabuf->dbuf.list, list) { in lpfc_cleanup_rcv_buffers()
17591 list_del_init(&d_buf->list); in lpfc_cleanup_rcv_buffers()
17592 lpfc_in_buf_free(vport->phba, d_buf); in lpfc_cleanup_rcv_buffers()
17594 lpfc_in_buf_free(vport->phba, &dmabuf->dbuf); in lpfc_cleanup_rcv_buffers()
17599 * lpfc_rcv_seq_check_edtov - Cleans up timed out receive sequences.
17619 timeout = (msecs_to_jiffies(vport->phba->fc_edtov) + in lpfc_rcv_seq_check_edtov()
17620 vport->rcv_buffer_time_stamp); in lpfc_rcv_seq_check_edtov()
17621 if (list_empty(&vport->rcv_buffer_list) || in lpfc_rcv_seq_check_edtov()
17625 list_for_each_entry_safe(h_buf, hnext, &vport->rcv_buffer_list, list) { in lpfc_rcv_seq_check_edtov()
17627 timeout = (msecs_to_jiffies(vport->phba->fc_edtov) + in lpfc_rcv_seq_check_edtov()
17628 dmabuf->time_stamp); in lpfc_rcv_seq_check_edtov()
17632 list_del_init(&dmabuf->hbuf.list); in lpfc_rcv_seq_check_edtov()
17634 &dmabuf->dbuf.list, list) { in lpfc_rcv_seq_check_edtov()
17635 list_del_init(&d_buf->list); in lpfc_rcv_seq_check_edtov()
17636 lpfc_in_buf_free(vport->phba, d_buf); in lpfc_rcv_seq_check_edtov()
17638 lpfc_in_buf_free(vport->phba, &dmabuf->dbuf); in lpfc_rcv_seq_check_edtov()
17645 * lpfc_fc_frame_add - Adds a frame to the vport's list of received sequences
17668 INIT_LIST_HEAD(&dmabuf->dbuf.list); in lpfc_fc_frame_add()
17669 dmabuf->time_stamp = jiffies; in lpfc_fc_frame_add()
17670 new_hdr = (struct fc_frame_header *)dmabuf->hbuf.virt; in lpfc_fc_frame_add()
17673 list_for_each_entry(h_buf, &vport->rcv_buffer_list, list) { in lpfc_fc_frame_add()
17674 temp_hdr = (struct fc_frame_header *)h_buf->virt; in lpfc_fc_frame_add()
17675 if ((temp_hdr->fh_seq_id != new_hdr->fh_seq_id) || in lpfc_fc_frame_add()
17676 (temp_hdr->fh_ox_id != new_hdr->fh_ox_id) || in lpfc_fc_frame_add()
17677 (memcmp(&temp_hdr->fh_s_id, &new_hdr->fh_s_id, 3))) in lpfc_fc_frame_add()
17688 list_add_tail(&dmabuf->hbuf.list, &vport->rcv_buffer_list); in lpfc_fc_frame_add()
17692 temp_hdr = seq_dmabuf->hbuf.virt; in lpfc_fc_frame_add()
17693 if (be16_to_cpu(new_hdr->fh_seq_cnt) < in lpfc_fc_frame_add()
17694 be16_to_cpu(temp_hdr->fh_seq_cnt)) { in lpfc_fc_frame_add()
17695 list_del_init(&seq_dmabuf->hbuf.list); in lpfc_fc_frame_add()
17696 list_add_tail(&dmabuf->hbuf.list, &vport->rcv_buffer_list); in lpfc_fc_frame_add()
17697 list_add_tail(&dmabuf->dbuf.list, &seq_dmabuf->dbuf.list); in lpfc_fc_frame_add()
17702 list_move_tail(&seq_dmabuf->hbuf.list, &vport->rcv_buffer_list); in lpfc_fc_frame_add()
17703 seq_dmabuf->time_stamp = jiffies; in lpfc_fc_frame_add()
17705 if (list_empty(&seq_dmabuf->dbuf.list)) { in lpfc_fc_frame_add()
17706 temp_hdr = dmabuf->hbuf.virt; in lpfc_fc_frame_add()
17707 list_add_tail(&dmabuf->dbuf.list, &seq_dmabuf->dbuf.list); in lpfc_fc_frame_add()
17711 d_buf = list_entry(seq_dmabuf->dbuf.list.prev, typeof(*d_buf), list); in lpfc_fc_frame_add()
17714 temp_hdr = (struct fc_frame_header *)temp_dmabuf->hbuf.virt; in lpfc_fc_frame_add()
17719 if (be16_to_cpu(new_hdr->fh_seq_cnt) > in lpfc_fc_frame_add()
17720 be16_to_cpu(temp_hdr->fh_seq_cnt)) { in lpfc_fc_frame_add()
17721 list_add(&dmabuf->dbuf.list, &temp_dmabuf->dbuf.list); in lpfc_fc_frame_add()
17726 if (&d_buf->list == &seq_dmabuf->dbuf.list) in lpfc_fc_frame_add()
17728 d_buf = list_entry(d_buf->list.prev, typeof(*d_buf), list); in lpfc_fc_frame_add()
17737 * lpfc_sli4_abort_partial_seq - Abort partially assembled unsol sequence
17747 * true -- if there is matching partially assembled sequence present and all
17749 * false -- if there is no matching partially assembled sequence present so
17762 INIT_LIST_HEAD(&dmabuf->dbuf.list); in lpfc_sli4_abort_partial_seq()
17763 INIT_LIST_HEAD(&dmabuf->hbuf.list); in lpfc_sli4_abort_partial_seq()
17764 new_hdr = (struct fc_frame_header *)dmabuf->hbuf.virt; in lpfc_sli4_abort_partial_seq()
17765 list_for_each_entry(h_buf, &vport->rcv_buffer_list, list) { in lpfc_sli4_abort_partial_seq()
17766 temp_hdr = (struct fc_frame_header *)h_buf->virt; in lpfc_sli4_abort_partial_seq()
17767 if ((temp_hdr->fh_seq_id != new_hdr->fh_seq_id) || in lpfc_sli4_abort_partial_seq()
17768 (temp_hdr->fh_ox_id != new_hdr->fh_ox_id) || in lpfc_sli4_abort_partial_seq()
17769 (memcmp(&temp_hdr->fh_s_id, &new_hdr->fh_s_id, 3))) in lpfc_sli4_abort_partial_seq()
17779 &seq_dmabuf->dbuf.list, list) { in lpfc_sli4_abort_partial_seq()
17780 list_del_init(&d_buf->list); in lpfc_sli4_abort_partial_seq()
17781 lpfc_in_buf_free(vport->phba, d_buf); in lpfc_sli4_abort_partial_seq()
17789 * lpfc_sli4_abort_ulp_seq - Abort assembled unsol sequence from ulp
17799 * true -- if there is matching pending context of the sequence cleaned
17801 * false -- if there is no matching pending context of the sequence present
17807 struct lpfc_hba *phba = vport->phba; in lpfc_sli4_abort_ulp_seq()
17811 if (phba->sli_rev < LPFC_SLI_REV4) in lpfc_sli4_abort_ulp_seq()
17823 * lpfc_sli4_seq_abort_rsp_cmpl - BLS ABORT RSP seq abort iocb complete handler
17840 ndlp = (struct lpfc_nodelist *)cmd_iocbq->context1; in lpfc_sli4_seq_abort_rsp_cmpl()
17846 if (rsp_iocbq && rsp_iocbq->iocb.ulpStatus) in lpfc_sli4_seq_abort_rsp_cmpl()
17849 rsp_iocbq->iocb.ulpStatus, in lpfc_sli4_seq_abort_rsp_cmpl()
17850 rsp_iocbq->iocb.un.ulpWord[4]); in lpfc_sli4_seq_abort_rsp_cmpl()
17854 * lpfc_sli4_xri_inrange - check xri is in range of xris owned by driver.
17867 for (i = 0; i < phba->sli4_hba.max_cfg_param.max_xri; i++) { in lpfc_sli4_xri_inrange()
17868 if (xri == phba->sli4_hba.xri_ids[i]) in lpfc_sli4_xri_inrange()
17875 * lpfc_sli4_seq_abort_rsp - bls rsp to sequence abort
17887 struct lpfc_hba *phba = vport->phba; in lpfc_sli4_seq_abort_rsp()
17899 oxid = be16_to_cpu(fc_hdr->fh_ox_id); in lpfc_sli4_seq_abort_rsp()
17900 rxid = be16_to_cpu(fc_hdr->fh_rx_id); in lpfc_sli4_seq_abort_rsp()
17914 /* re-setup ndlp without removing from node list */ in lpfc_sli4_seq_abort_rsp()
17932 icmd = &ctiocb->iocb; in lpfc_sli4_seq_abort_rsp()
17933 icmd->un.xseq64.bdl.bdeSize = 0; in lpfc_sli4_seq_abort_rsp()
17934 icmd->un.xseq64.bdl.ulpIoTag32 = 0; in lpfc_sli4_seq_abort_rsp()
17935 icmd->un.xseq64.w5.hcsw.Dfctl = 0; in lpfc_sli4_seq_abort_rsp()
17936 icmd->un.xseq64.w5.hcsw.Rctl = FC_RCTL_BA_ACC; in lpfc_sli4_seq_abort_rsp()
17937 icmd->un.xseq64.w5.hcsw.Type = FC_TYPE_BLS; in lpfc_sli4_seq_abort_rsp()
17940 icmd->ulpCommand = CMD_XMIT_BLS_RSP64_CX; in lpfc_sli4_seq_abort_rsp()
17941 icmd->ulpBdeCount = 0; in lpfc_sli4_seq_abort_rsp()
17942 icmd->ulpLe = 1; in lpfc_sli4_seq_abort_rsp()
17943 icmd->ulpClass = CLASS3; in lpfc_sli4_seq_abort_rsp()
17944 icmd->ulpContext = phba->sli4_hba.rpi_ids[ndlp->nlp_rpi]; in lpfc_sli4_seq_abort_rsp()
17945 ctiocb->context1 = lpfc_nlp_get(ndlp); in lpfc_sli4_seq_abort_rsp()
17947 ctiocb->vport = phba->pport; in lpfc_sli4_seq_abort_rsp()
17948 ctiocb->iocb_cmpl = lpfc_sli4_seq_abort_rsp_cmpl; in lpfc_sli4_seq_abort_rsp()
17949 ctiocb->sli4_lxritag = NO_XRI; in lpfc_sli4_seq_abort_rsp()
17950 ctiocb->sli4_xritag = NO_XRI; in lpfc_sli4_seq_abort_rsp()
17970 icmd->un.xseq64.w5.hcsw.Rctl = FC_RCTL_BA_RJT; in lpfc_sli4_seq_abort_rsp()
17971 bf_set(lpfc_vndr_code, &icmd->un.bls_rsp, 0); in lpfc_sli4_seq_abort_rsp()
17972 bf_set(lpfc_rsn_expln, &icmd->un.bls_rsp, FC_BA_RJT_INV_XID); in lpfc_sli4_seq_abort_rsp()
17973 bf_set(lpfc_rsn_code, &icmd->un.bls_rsp, FC_BA_RJT_UNABLE); in lpfc_sli4_seq_abort_rsp()
17981 icmd->un.xseq64.w5.hcsw.Rctl = FC_RCTL_BA_RJT; in lpfc_sli4_seq_abort_rsp()
17982 bf_set(lpfc_vndr_code, &icmd->un.bls_rsp, 0); in lpfc_sli4_seq_abort_rsp()
17983 bf_set(lpfc_rsn_expln, &icmd->un.bls_rsp, FC_BA_RJT_INV_XID); in lpfc_sli4_seq_abort_rsp()
17984 bf_set(lpfc_rsn_code, &icmd->un.bls_rsp, FC_BA_RJT_UNABLE); in lpfc_sli4_seq_abort_rsp()
17992 bf_set(lpfc_abts_orig, &icmd->un.bls_rsp, LPFC_ABTS_UNSOL_RSP); in lpfc_sli4_seq_abort_rsp()
17998 bf_set(lpfc_abts_orig, &icmd->un.bls_rsp, LPFC_ABTS_UNSOL_INT); in lpfc_sli4_seq_abort_rsp()
18000 bf_set(lpfc_abts_rxid, &icmd->un.bls_rsp, rxid); in lpfc_sli4_seq_abort_rsp()
18001 bf_set(lpfc_abts_oxid, &icmd->un.bls_rsp, oxid); in lpfc_sli4_seq_abort_rsp()
18006 icmd->un.xseq64.w5.hcsw.Rctl, oxid, phba->link_state); in lpfc_sli4_seq_abort_rsp()
18013 icmd->un.xseq64.w5.hcsw.Rctl, oxid, in lpfc_sli4_seq_abort_rsp()
18014 phba->link_state); in lpfc_sli4_seq_abort_rsp()
18016 ctiocb->context1 = NULL; in lpfc_sli4_seq_abort_rsp()
18022 * lpfc_sli4_handle_unsol_abort - Handle sli-4 unsolicited abort event
18026 * This function handles an SLI-4 unsolicited abort event. If the unsolicited
18038 struct lpfc_hba *phba = vport->phba; in lpfc_sli4_handle_unsol_abort()
18044 memcpy(&fc_hdr, dmabuf->hbuf.virt, sizeof(struct fc_frame_header)); in lpfc_sli4_handle_unsol_abort()
18056 lpfc_in_buf_free(phba, &dmabuf->dbuf); in lpfc_sli4_handle_unsol_abort()
18058 if (phba->nvmet_support) { in lpfc_sli4_handle_unsol_abort()
18068 * lpfc_seq_complete - Indicates if a sequence is complete
18088 hdr = (struct fc_frame_header *)dmabuf->hbuf.virt; in lpfc_seq_complete()
18090 if (hdr->fh_seq_cnt != seq_count) in lpfc_seq_complete()
18092 fctl = (hdr->fh_f_ctl[0] << 16 | in lpfc_seq_complete()
18093 hdr->fh_f_ctl[1] << 8 | in lpfc_seq_complete()
18094 hdr->fh_f_ctl[2]); in lpfc_seq_complete()
18098 list_for_each_entry(d_buf, &dmabuf->dbuf.list, list) { in lpfc_seq_complete()
18100 hdr = (struct fc_frame_header *)seq_dmabuf->hbuf.virt; in lpfc_seq_complete()
18102 if (++seq_count != be16_to_cpu(hdr->fh_seq_cnt)) in lpfc_seq_complete()
18104 fctl = (hdr->fh_f_ctl[0] << 16 | in lpfc_seq_complete()
18105 hdr->fh_f_ctl[1] << 8 | in lpfc_seq_complete()
18106 hdr->fh_f_ctl[2]); in lpfc_seq_complete()
18115 * lpfc_prep_seq - Prep sequence for ULP processing
18138 fc_hdr = (struct fc_frame_header *)seq_dmabuf->hbuf.virt; in lpfc_prep_seq()
18140 list_del_init(&seq_dmabuf->hbuf.list); in lpfc_prep_seq()
18146 first_iocbq = lpfc_sli_get_iocbq(vport->phba); in lpfc_prep_seq()
18149 first_iocbq->iocb.unsli3.rcvsli3.acc_len = 0; in lpfc_prep_seq()
18150 first_iocbq->iocb.ulpStatus = IOSTAT_SUCCESS; in lpfc_prep_seq()
18151 first_iocbq->vport = vport; in lpfc_prep_seq()
18155 first_iocbq->iocb.ulpCommand = CMD_IOCB_RCV_ELS64_CX; in lpfc_prep_seq()
18156 first_iocbq->iocb.un.rcvels.parmRo = in lpfc_prep_seq()
18158 first_iocbq->iocb.ulpPU = PARM_NPIV_DID; in lpfc_prep_seq()
18160 first_iocbq->iocb.ulpCommand = CMD_IOCB_RCV_SEQ64_CX; in lpfc_prep_seq()
18161 first_iocbq->iocb.ulpContext = NO_XRI; in lpfc_prep_seq()
18162 first_iocbq->iocb.unsli3.rcvsli3.ox_id = in lpfc_prep_seq()
18163 be16_to_cpu(fc_hdr->fh_ox_id); in lpfc_prep_seq()
18165 first_iocbq->iocb.unsli3.rcvsli3.vpi = in lpfc_prep_seq()
18166 vport->phba->vpi_ids[vport->vpi]; in lpfc_prep_seq()
18169 &seq_dmabuf->cq_event.cqe.rcqe_cmpl); in lpfc_prep_seq()
18171 first_iocbq->context2 = &seq_dmabuf->dbuf; in lpfc_prep_seq()
18172 first_iocbq->context3 = NULL; in lpfc_prep_seq()
18173 first_iocbq->iocb.ulpBdeCount = 1; in lpfc_prep_seq()
18175 first_iocbq->iocb.un.cont64[0].tus.f.bdeSize = in lpfc_prep_seq()
18178 first_iocbq->iocb.un.cont64[0].tus.f.bdeSize = tot_len; in lpfc_prep_seq()
18180 first_iocbq->iocb.un.rcvels.remoteID = sid; in lpfc_prep_seq()
18182 first_iocbq->iocb.unsli3.rcvsli3.acc_len = tot_len; in lpfc_prep_seq()
18189 list_for_each_entry_safe(d_buf, n_buf, &seq_dmabuf->dbuf.list, list) { in lpfc_prep_seq()
18191 lpfc_in_buf_free(vport->phba, d_buf); in lpfc_prep_seq()
18194 if (!iocbq->context3) { in lpfc_prep_seq()
18195 iocbq->context3 = d_buf; in lpfc_prep_seq()
18196 iocbq->iocb.ulpBdeCount++; in lpfc_prep_seq()
18200 &hbq_buf->cq_event.cqe.rcqe_cmpl); in lpfc_prep_seq()
18202 &iocbq->iocb.unsli3.sli3Words[4]; in lpfc_prep_seq()
18204 pbde->tus.f.bdeSize = LPFC_DATA_BUF_SIZE; in lpfc_prep_seq()
18206 pbde->tus.f.bdeSize = len; in lpfc_prep_seq()
18208 iocbq->iocb.unsli3.rcvsli3.acc_len += len; in lpfc_prep_seq()
18211 iocbq = lpfc_sli_get_iocbq(vport->phba); in lpfc_prep_seq()
18214 first_iocbq->iocb.ulpStatus = in lpfc_prep_seq()
18216 first_iocbq->iocb.un.ulpWord[4] = in lpfc_prep_seq()
18219 lpfc_in_buf_free(vport->phba, d_buf); in lpfc_prep_seq()
18225 &hbq_buf->cq_event.cqe.rcqe_cmpl); in lpfc_prep_seq()
18226 iocbq->context2 = d_buf; in lpfc_prep_seq()
18227 iocbq->context3 = NULL; in lpfc_prep_seq()
18228 iocbq->iocb.ulpBdeCount = 1; in lpfc_prep_seq()
18230 iocbq->iocb.un.cont64[0].tus.f.bdeSize = in lpfc_prep_seq()
18233 iocbq->iocb.un.cont64[0].tus.f.bdeSize = len; in lpfc_prep_seq()
18236 iocbq->iocb.unsli3.rcvsli3.acc_len = tot_len; in lpfc_prep_seq()
18238 iocbq->iocb.un.rcvels.remoteID = sid; in lpfc_prep_seq()
18239 list_add_tail(&iocbq->list, &first_iocbq->list); in lpfc_prep_seq()
18244 lpfc_in_buf_free(vport->phba, &seq_dmabuf->dbuf); in lpfc_prep_seq()
18255 struct lpfc_hba *phba = vport->phba; in lpfc_sli4_send_seq_to_ulp()
18257 fc_hdr = (struct fc_frame_header *)seq_dmabuf->hbuf.virt; in lpfc_sli4_send_seq_to_ulp()
18264 fc_hdr->fh_r_ctl, fc_hdr->fh_type); in lpfc_sli4_send_seq_to_ulp()
18268 phba->sli4_hba.els_wq->pring, in lpfc_sli4_send_seq_to_ulp()
18269 iocbq, fc_hdr->fh_r_ctl, in lpfc_sli4_send_seq_to_ulp()
18270 fc_hdr->fh_type)) in lpfc_sli4_send_seq_to_ulp()
18275 fc_hdr->fh_r_ctl, fc_hdr->fh_type); in lpfc_sli4_send_seq_to_ulp()
18279 &iocbq->list, list) { in lpfc_sli4_send_seq_to_ulp()
18280 list_del_init(&curr_iocb->list); in lpfc_sli4_send_seq_to_ulp()
18290 struct lpfc_dmabuf *pcmd = cmdiocb->context2; in lpfc_sli4_mds_loopback_cmpl()
18292 if (pcmd && pcmd->virt) in lpfc_sli4_mds_loopback_cmpl()
18293 dma_pool_free(phba->lpfc_drb_pool, pcmd->virt, pcmd->phys); in lpfc_sli4_mds_loopback_cmpl()
18304 struct lpfc_hba *phba = vport->phba; in lpfc_sli4_handle_mds_loopback()
18312 fc_hdr = (struct fc_frame_header *)dmabuf->hbuf.virt; in lpfc_sli4_handle_mds_loopback()
18313 frame_len = bf_get(lpfc_rcqe_length, &dmabuf->cq_event.cqe.rcqe_cmpl); in lpfc_sli4_handle_mds_loopback()
18319 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_handle_mds_loopback()
18320 list_add_tail(&dmabuf->cq_event.list, in lpfc_sli4_handle_mds_loopback()
18321 &phba->sli4_hba.sp_queue_event); in lpfc_sli4_handle_mds_loopback()
18322 phba->hba_flag |= HBA_SP_QUEUE_EVT; in lpfc_sli4_handle_mds_loopback()
18323 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_handle_mds_loopback()
18331 pcmd->virt = dma_pool_alloc(phba->lpfc_drb_pool, GFP_KERNEL, in lpfc_sli4_handle_mds_loopback()
18332 &pcmd->phys); in lpfc_sli4_handle_mds_loopback()
18333 if (!pcmd || !pcmd->virt) in lpfc_sli4_handle_mds_loopback()
18336 INIT_LIST_HEAD(&pcmd->list); in lpfc_sli4_handle_mds_loopback()
18339 memcpy(pcmd->virt, dmabuf->dbuf.virt, frame_len); in lpfc_sli4_handle_mds_loopback()
18342 iocbq->iocb.un.xseq64.bdl.addrHigh = putPaddrHigh(pcmd->phys); in lpfc_sli4_handle_mds_loopback()
18343 iocbq->iocb.un.xseq64.bdl.addrLow = putPaddrLow(pcmd->phys); in lpfc_sli4_handle_mds_loopback()
18344 iocbq->iocb.un.xseq64.bdl.bdeFlags = BUFF_TYPE_BDE_64; in lpfc_sli4_handle_mds_loopback()
18345 iocbq->iocb.un.xseq64.bdl.bdeSize = frame_len; in lpfc_sli4_handle_mds_loopback()
18347 iocbq->context2 = pcmd; in lpfc_sli4_handle_mds_loopback()
18348 iocbq->vport = vport; in lpfc_sli4_handle_mds_loopback()
18349 iocbq->iocb_flag &= ~LPFC_FIP_ELS_ID_MASK; in lpfc_sli4_handle_mds_loopback()
18350 iocbq->iocb_flag |= LPFC_USE_FCPWQIDX; in lpfc_sli4_handle_mds_loopback()
18356 wqe = (union lpfc_wqe *)&iocbq->iocb; in lpfc_sli4_handle_mds_loopback()
18358 wqe->send_frame.frame_len = frame_len; in lpfc_sli4_handle_mds_loopback()
18359 wqe->send_frame.fc_hdr_wd0 = be32_to_cpu(*((uint32_t *)fc_hdr)); in lpfc_sli4_handle_mds_loopback()
18360 wqe->send_frame.fc_hdr_wd1 = be32_to_cpu(*((uint32_t *)fc_hdr + 1)); in lpfc_sli4_handle_mds_loopback()
18361 wqe->send_frame.fc_hdr_wd2 = be32_to_cpu(*((uint32_t *)fc_hdr + 2)); in lpfc_sli4_handle_mds_loopback()
18362 wqe->send_frame.fc_hdr_wd3 = be32_to_cpu(*((uint32_t *)fc_hdr + 3)); in lpfc_sli4_handle_mds_loopback()
18363 wqe->send_frame.fc_hdr_wd4 = be32_to_cpu(*((uint32_t *)fc_hdr + 4)); in lpfc_sli4_handle_mds_loopback()
18364 wqe->send_frame.fc_hdr_wd5 = be32_to_cpu(*((uint32_t *)fc_hdr + 5)); in lpfc_sli4_handle_mds_loopback()
18366 iocbq->iocb.ulpCommand = CMD_SEND_FRAME; in lpfc_sli4_handle_mds_loopback()
18367 iocbq->iocb.ulpLe = 1; in lpfc_sli4_handle_mds_loopback()
18368 iocbq->iocb_cmpl = lpfc_sli4_mds_loopback_cmpl; in lpfc_sli4_handle_mds_loopback()
18373 lpfc_in_buf_free(phba, &dmabuf->dbuf); in lpfc_sli4_handle_mds_loopback()
18379 if (pcmd && pcmd->virt) in lpfc_sli4_handle_mds_loopback()
18380 dma_pool_free(phba->lpfc_drb_pool, pcmd->virt, pcmd->phys); in lpfc_sli4_handle_mds_loopback()
18384 lpfc_in_buf_free(phba, &dmabuf->dbuf); in lpfc_sli4_handle_mds_loopback()
18388 * lpfc_sli4_handle_received_buffer - Handle received buffers from firmware
18410 fc_hdr = (struct fc_frame_header *)dmabuf->hbuf.virt; in lpfc_sli4_handle_received_buffer()
18412 if (fc_hdr->fh_r_ctl == FC_RCTL_MDS_DIAGS || in lpfc_sli4_handle_received_buffer()
18413 fc_hdr->fh_r_ctl == FC_RCTL_DD_UNSOL_DATA) { in lpfc_sli4_handle_received_buffer()
18414 vport = phba->pport; in lpfc_sli4_handle_received_buffer()
18416 if (!(phba->pport->load_flag & FC_UNLOADING)) in lpfc_sli4_handle_received_buffer()
18419 lpfc_in_buf_free(phba, &dmabuf->dbuf); in lpfc_sli4_handle_received_buffer()
18425 lpfc_in_buf_free(phba, &dmabuf->dbuf); in lpfc_sli4_handle_received_buffer()
18430 &dmabuf->cq_event.cqe.rcqe_cmpl) == CQE_CODE_RECEIVE_V1)) in lpfc_sli4_handle_received_buffer()
18432 &dmabuf->cq_event.cqe.rcqe_cmpl); in lpfc_sli4_handle_received_buffer()
18435 &dmabuf->cq_event.cqe.rcqe_cmpl); in lpfc_sli4_handle_received_buffer()
18437 if (fc_hdr->fh_r_ctl == 0xF4 && fc_hdr->fh_type == 0xFF) { in lpfc_sli4_handle_received_buffer()
18438 vport = phba->pport; in lpfc_sli4_handle_received_buffer()
18442 &dmabuf->cq_event.cqe.rcqe_cmpl)); in lpfc_sli4_handle_received_buffer()
18454 lpfc_in_buf_free(phba, &dmabuf->dbuf); in lpfc_sli4_handle_received_buffer()
18459 if (!(vport->vpi_state & LPFC_VPI_REGISTERED) && in lpfc_sli4_handle_received_buffer()
18466 if (!(vport->fc_flag & FC_PT2PT) || in lpfc_sli4_handle_received_buffer()
18467 (phba->link_state == LPFC_HBA_READY)) { in lpfc_sli4_handle_received_buffer()
18468 lpfc_in_buf_free(phba, &dmabuf->dbuf); in lpfc_sli4_handle_received_buffer()
18474 if (fc_hdr->fh_r_ctl == FC_RCTL_BA_ABTS) { in lpfc_sli4_handle_received_buffer()
18482 /* unable to add frame to vport - throw it out */ in lpfc_sli4_handle_received_buffer()
18483 lpfc_in_buf_free(phba, &dmabuf->dbuf); in lpfc_sli4_handle_received_buffer()
18495 * lpfc_sli4_post_all_rpi_hdrs - Post the rpi header memory region to the port
18499 * HBA consistent with the SLI-4 interface spec. This routine
18508 * 0 - successful
18509 * -EIO - The mailbox failed to complete successfully.
18523 if (!phba->sli4_hba.rpi_hdrs_in_use) in lpfc_sli4_post_all_rpi_hdrs()
18525 if (phba->sli4_hba.extents_in_use) in lpfc_sli4_post_all_rpi_hdrs()
18526 return -EIO; in lpfc_sli4_post_all_rpi_hdrs()
18528 list_for_each_entry(rpi_page, &phba->sli4_hba.lpfc_rpi_hdr_list, list) { in lpfc_sli4_post_all_rpi_hdrs()
18534 if (bf_get(lpfc_rpi_rsrc_rdy, &phba->sli4_hba.sli4_flags) != in lpfc_sli4_post_all_rpi_hdrs()
18536 rpi_page->start_rpi = phba->sli4_hba.rpi_ids[lrpi]; in lpfc_sli4_post_all_rpi_hdrs()
18543 rc = -EIO; in lpfc_sli4_post_all_rpi_hdrs()
18549 bf_set(lpfc_rpi_rsrc_rdy, &phba->sli4_hba.sli4_flags, in lpfc_sli4_post_all_rpi_hdrs()
18555 * lpfc_sli4_post_rpi_hdr - Post an rpi header memory region to the port
18560 * HBA consistent with the SLI-4 interface spec. This memory region
18564 * 0 - successful
18565 * -ENOMEM - No available memory
18566 * -EIO - The mailbox failed to complete successfully.
18578 if (!phba->sli4_hba.rpi_hdrs_in_use) in lpfc_sli4_post_rpi_hdr()
18580 if (phba->sli4_hba.extents_in_use) in lpfc_sli4_post_rpi_hdr()
18581 return -EIO; in lpfc_sli4_post_rpi_hdr()
18583 /* The port is notified of the header region via a mailbox command. */ in lpfc_sli4_post_rpi_hdr()
18584 mboxq = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_post_rpi_hdr()
18588 "SLI_CONFIG_SPECIAL mailbox command\n"); in lpfc_sli4_post_rpi_hdr()
18589 return -ENOMEM; in lpfc_sli4_post_rpi_hdr()
18593 hdr_tmpl = &mboxq->u.mqe.un.hdr_tmpl; in lpfc_sli4_post_rpi_hdr()
18596 sizeof(struct lpfc_mbx_post_hdr_tmpl) - in lpfc_sli4_post_rpi_hdr()
18603 rpi_page->start_rpi); in lpfc_sli4_post_rpi_hdr()
18605 hdr_tmpl, rpi_page->page_count); in lpfc_sli4_post_rpi_hdr()
18607 hdr_tmpl->rpi_paddr_lo = putPaddrLow(rpi_page->dmabuf->phys); in lpfc_sli4_post_rpi_hdr()
18608 hdr_tmpl->rpi_paddr_hi = putPaddrHigh(rpi_page->dmabuf->phys); in lpfc_sli4_post_rpi_hdr()
18610 shdr = (union lpfc_sli4_cfg_shdr *) &hdr_tmpl->header.cfg_shdr; in lpfc_sli4_post_rpi_hdr()
18611 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_sli4_post_rpi_hdr()
18612 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_sli4_post_rpi_hdr()
18613 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_post_rpi_hdr()
18616 "2514 POST_RPI_HDR mailbox failed with " in lpfc_sli4_post_rpi_hdr()
18619 rc = -ENXIO; in lpfc_sli4_post_rpi_hdr()
18622 * The next_rpi stores the next logical module-64 rpi value used in lpfc_sli4_post_rpi_hdr()
18625 spin_lock_irq(&phba->hbalock); in lpfc_sli4_post_rpi_hdr()
18626 phba->sli4_hba.next_rpi = rpi_page->next_rpi; in lpfc_sli4_post_rpi_hdr()
18627 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_post_rpi_hdr()
18633 * lpfc_sli4_alloc_rpi - Get an available rpi in the device's range
18637 * HBA consistent with the SLI-4 interface spec. This routine
18658 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli4_alloc_rpi()
18659 max_rpi = phba->sli4_hba.max_cfg_param.max_rpi; in lpfc_sli4_alloc_rpi()
18660 rpi_limit = phba->sli4_hba.next_rpi; in lpfc_sli4_alloc_rpi()
18662 rpi = find_next_zero_bit(phba->sli4_hba.rpi_bmask, rpi_limit, 0); in lpfc_sli4_alloc_rpi()
18666 set_bit(rpi, phba->sli4_hba.rpi_bmask); in lpfc_sli4_alloc_rpi()
18667 phba->sli4_hba.max_cfg_param.rpi_used++; in lpfc_sli4_alloc_rpi()
18668 phba->sli4_hba.rpi_count++; in lpfc_sli4_alloc_rpi()
18680 (phba->sli4_hba.rpi_count >= max_rpi)) { in lpfc_sli4_alloc_rpi()
18681 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli4_alloc_rpi()
18689 if (!phba->sli4_hba.rpi_hdrs_in_use) { in lpfc_sli4_alloc_rpi()
18690 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli4_alloc_rpi()
18700 rpi_remaining = phba->sli4_hba.next_rpi - phba->sli4_hba.rpi_count; in lpfc_sli4_alloc_rpi()
18701 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli4_alloc_rpi()
18709 lrpi = rpi_hdr->start_rpi; in lpfc_sli4_alloc_rpi()
18710 rpi_hdr->start_rpi = phba->sli4_hba.rpi_ids[lrpi]; in lpfc_sli4_alloc_rpi()
18719 * lpfc_sli4_free_rpi - Release an rpi for reuse.
18736 if (test_and_clear_bit(rpi, phba->sli4_hba.rpi_bmask)) { in __lpfc_sli4_free_rpi()
18737 phba->sli4_hba.rpi_count--; in __lpfc_sli4_free_rpi()
18738 phba->sli4_hba.max_cfg_param.rpi_used--; in __lpfc_sli4_free_rpi()
18748 * lpfc_sli4_free_rpi - Release an rpi for reuse.
18758 spin_lock_irq(&phba->hbalock); in lpfc_sli4_free_rpi()
18760 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_free_rpi()
18764 * lpfc_sli4_remove_rpis - Remove the rpi bitmask region
18773 kfree(phba->sli4_hba.rpi_bmask); in lpfc_sli4_remove_rpis()
18774 kfree(phba->sli4_hba.rpi_ids); in lpfc_sli4_remove_rpis()
18775 bf_set(lpfc_rpi_rsrc_rdy, &phba->sli4_hba.sli4_flags, 0); in lpfc_sli4_remove_rpis()
18779 * lpfc_sli4_resume_rpi - Remove the rpi bitmask region
18781 * @cmpl: completion call-back.
18792 struct lpfc_hba *phba = ndlp->phba; in lpfc_sli4_resume_rpi()
18795 /* The port is notified of the header region via a mailbox command. */ in lpfc_sli4_resume_rpi()
18796 mboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_resume_rpi()
18798 return -ENOMEM; in lpfc_sli4_resume_rpi()
18803 mboxq->mbox_cmpl = cmpl; in lpfc_sli4_resume_rpi()
18804 mboxq->ctx_buf = arg; in lpfc_sli4_resume_rpi()
18805 mboxq->ctx_ndlp = ndlp; in lpfc_sli4_resume_rpi()
18807 mboxq->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_sli4_resume_rpi()
18808 mboxq->vport = ndlp->vport; in lpfc_sli4_resume_rpi()
18812 "2010 Resume RPI Mailbox failed " in lpfc_sli4_resume_rpi()
18814 bf_get(lpfc_mqe_status, &mboxq->u.mqe)); in lpfc_sli4_resume_rpi()
18815 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_resume_rpi()
18816 return -EIO; in lpfc_sli4_resume_rpi()
18822 * lpfc_sli4_init_vpi - Initialize a vpi with the port
18829 * -Evalue otherwise
18838 struct lpfc_hba *phba = vport->phba; in lpfc_sli4_init_vpi()
18839 mboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_init_vpi()
18841 return -ENOMEM; in lpfc_sli4_init_vpi()
18842 lpfc_init_vpi(phba, mboxq, vport->vpi); in lpfc_sli4_init_vpi()
18847 "2022 INIT VPI Mailbox failed " in lpfc_sli4_init_vpi()
18849 bf_get(lpfc_mqe_status, &mboxq->u.mqe)); in lpfc_sli4_init_vpi()
18850 retval = -EIO; in lpfc_sli4_init_vpi()
18853 mempool_free(mboxq, vport->phba->mbox_mem_pool); in lpfc_sli4_init_vpi()
18859 * lpfc_mbx_cmpl_add_fcf_record - add fcf mbox completion handler.
18861 * @mboxq: Pointer to mailbox object.
18865 * care of the nonembedded mailbox operations.
18874 virt_addr = mboxq->sge_array->addr[0]; in lpfc_mbx_cmpl_add_fcf_record()
18875 /* The IOCTL status is embedded in the mailbox subheader. */ in lpfc_mbx_cmpl_add_fcf_record()
18877 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_mbx_cmpl_add_fcf_record()
18878 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_mbx_cmpl_add_fcf_record()
18883 "2558 ADD_FCF_RECORD mailbox failed with " in lpfc_mbx_cmpl_add_fcf_record()
18891 * lpfc_sli4_add_fcf_record - Manually add an FCF Record.
18897 * care of the nonembedded mailbox operations.
18910 mboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_add_fcf_record()
18914 return -ENOMEM; in lpfc_sli4_add_fcf_record()
18920 /* Allocate DMA memory and set up the non-embedded mailbox command */ in lpfc_sli4_add_fcf_record()
18930 return -ENOMEM; in lpfc_sli4_add_fcf_record()
18934 * Get the first SGE entry from the non-embedded DMA memory. This in lpfc_sli4_add_fcf_record()
18938 virt_addr = mboxq->sge_array->addr[0]; in lpfc_sli4_add_fcf_record()
18954 mboxq->vport = phba->pport; in lpfc_sli4_add_fcf_record()
18955 mboxq->mbox_cmpl = lpfc_mbx_cmpl_add_fcf_record; in lpfc_sli4_add_fcf_record()
18959 "2515 ADD_FCF_RECORD mailbox failed with " in lpfc_sli4_add_fcf_record()
18962 rc = -EIO; in lpfc_sli4_add_fcf_record()
18970 * lpfc_sli4_build_dflt_fcf_record - Build the driver's default FCF Record.
18985 fcf_record->max_rcv_size = LPFC_FCOE_MAX_RCV_SIZE; in lpfc_sli4_build_dflt_fcf_record()
18986 fcf_record->fka_adv_period = LPFC_FCOE_FKA_ADV_PER; in lpfc_sli4_build_dflt_fcf_record()
18987 fcf_record->fip_priority = LPFC_FCOE_FIP_PRIORITY; in lpfc_sli4_build_dflt_fcf_record()
18988 bf_set(lpfc_fcf_record_mac_0, fcf_record, phba->fc_map[0]); in lpfc_sli4_build_dflt_fcf_record()
18989 bf_set(lpfc_fcf_record_mac_1, fcf_record, phba->fc_map[1]); in lpfc_sli4_build_dflt_fcf_record()
18990 bf_set(lpfc_fcf_record_mac_2, fcf_record, phba->fc_map[2]); in lpfc_sli4_build_dflt_fcf_record()
18994 bf_set(lpfc_fcf_record_fc_map_0, fcf_record, phba->fc_map[0]); in lpfc_sli4_build_dflt_fcf_record()
18995 bf_set(lpfc_fcf_record_fc_map_1, fcf_record, phba->fc_map[1]); in lpfc_sli4_build_dflt_fcf_record()
18996 bf_set(lpfc_fcf_record_fc_map_2, fcf_record, phba->fc_map[2]); in lpfc_sli4_build_dflt_fcf_record()
19003 if (phba->valid_vlan) { in lpfc_sli4_build_dflt_fcf_record()
19004 fcf_record->vlan_bitmap[phba->vlan_id / 8] in lpfc_sli4_build_dflt_fcf_record()
19005 = 1 << (phba->vlan_id % 8); in lpfc_sli4_build_dflt_fcf_record()
19010 * lpfc_sli4_fcf_scan_read_fcf_rec - Read hba fcf record for fcf scan.
19018 * Return 0 if the mailbox command is submitted successfully, none 0
19027 phba->fcoe_eventtag_at_fcf_scan = phba->fcoe_eventtag; in lpfc_sli4_fcf_scan_read_fcf_rec()
19028 phba->fcoe_cvl_eventtag_attn = phba->fcoe_cvl_eventtag; in lpfc_sli4_fcf_scan_read_fcf_rec()
19029 mboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_fcf_scan_read_fcf_rec()
19034 error = -ENOMEM; in lpfc_sli4_fcf_scan_read_fcf_rec()
19037 /* Construct the read FCF record mailbox command */ in lpfc_sli4_fcf_scan_read_fcf_rec()
19040 error = -EINVAL; in lpfc_sli4_fcf_scan_read_fcf_rec()
19043 /* Issue the mailbox command asynchronously */ in lpfc_sli4_fcf_scan_read_fcf_rec()
19044 mboxq->vport = phba->pport; in lpfc_sli4_fcf_scan_read_fcf_rec()
19045 mboxq->mbox_cmpl = lpfc_mbx_cmpl_fcf_scan_read_fcf_rec; in lpfc_sli4_fcf_scan_read_fcf_rec()
19047 spin_lock_irq(&phba->hbalock); in lpfc_sli4_fcf_scan_read_fcf_rec()
19048 phba->hba_flag |= FCF_TS_INPROG; in lpfc_sli4_fcf_scan_read_fcf_rec()
19049 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_fcf_scan_read_fcf_rec()
19053 error = -EIO; in lpfc_sli4_fcf_scan_read_fcf_rec()
19057 phba->fcf.eligible_fcf_cnt = 0; in lpfc_sli4_fcf_scan_read_fcf_rec()
19065 spin_lock_irq(&phba->hbalock); in lpfc_sli4_fcf_scan_read_fcf_rec()
19066 phba->hba_flag &= ~FCF_TS_INPROG; in lpfc_sli4_fcf_scan_read_fcf_rec()
19067 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_fcf_scan_read_fcf_rec()
19073 * lpfc_sli4_fcf_rr_read_fcf_rec - Read hba fcf record for roundrobin fcf.
19080 * Return 0 if the mailbox command is submitted successfully, none 0
19089 mboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_fcf_rr_read_fcf_rec()
19094 error = -ENOMEM; in lpfc_sli4_fcf_rr_read_fcf_rec()
19097 /* Construct the read FCF record mailbox command */ in lpfc_sli4_fcf_rr_read_fcf_rec()
19100 error = -EINVAL; in lpfc_sli4_fcf_rr_read_fcf_rec()
19103 /* Issue the mailbox command asynchronously */ in lpfc_sli4_fcf_rr_read_fcf_rec()
19104 mboxq->vport = phba->pport; in lpfc_sli4_fcf_rr_read_fcf_rec()
19105 mboxq->mbox_cmpl = lpfc_mbx_cmpl_fcf_rr_read_fcf_rec; in lpfc_sli4_fcf_rr_read_fcf_rec()
19108 error = -EIO; in lpfc_sli4_fcf_rr_read_fcf_rec()
19119 * lpfc_sli4_read_fcf_rec - Read hba fcf record for update eligible fcf bmask.
19126 * Return 0 if the mailbox command is submitted successfully, none 0
19135 mboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_read_fcf_rec()
19140 error = -ENOMEM; in lpfc_sli4_read_fcf_rec()
19143 /* Construct the read FCF record mailbox command */ in lpfc_sli4_read_fcf_rec()
19146 error = -EINVAL; in lpfc_sli4_read_fcf_rec()
19149 /* Issue the mailbox command asynchronously */ in lpfc_sli4_read_fcf_rec()
19150 mboxq->vport = phba->pport; in lpfc_sli4_read_fcf_rec()
19151 mboxq->mbox_cmpl = lpfc_mbx_cmpl_read_fcf_rec; in lpfc_sli4_read_fcf_rec()
19154 error = -EIO; in lpfc_sli4_read_fcf_rec()
19186 last_index = find_first_bit(phba->fcf.fcf_rr_bmask, in lpfc_check_next_fcf_pri_level()
19192 spin_lock_irq(&phba->hbalock); in lpfc_check_next_fcf_pri_level()
19193 if (list_empty(&phba->fcf.fcf_pri_list) || in lpfc_check_next_fcf_pri_level()
19194 list_is_singular(&phba->fcf.fcf_pri_list)) { in lpfc_check_next_fcf_pri_level()
19195 spin_unlock_irq(&phba->hbalock); in lpfc_check_next_fcf_pri_level()
19200 spin_unlock_irq(&phba->hbalock); in lpfc_check_next_fcf_pri_level()
19207 memset(phba->fcf.fcf_rr_bmask, 0, in lpfc_check_next_fcf_pri_level()
19208 sizeof(*phba->fcf.fcf_rr_bmask)); in lpfc_check_next_fcf_pri_level()
19209 spin_lock_irq(&phba->hbalock); in lpfc_check_next_fcf_pri_level()
19210 list_for_each_entry(fcf_pri, &phba->fcf.fcf_pri_list, list) { in lpfc_check_next_fcf_pri_level()
19211 if (fcf_pri->fcf_rec.flag & LPFC_FCF_FLOGI_FAILED) in lpfc_check_next_fcf_pri_level()
19218 next_fcf_pri = fcf_pri->fcf_rec.priority; in lpfc_check_next_fcf_pri_level()
19219 spin_unlock_irq(&phba->hbalock); in lpfc_check_next_fcf_pri_level()
19220 if (fcf_pri->fcf_rec.priority == next_fcf_pri) { in lpfc_check_next_fcf_pri_level()
19222 fcf_pri->fcf_rec.fcf_index); in lpfc_check_next_fcf_pri_level()
19226 spin_lock_irq(&phba->hbalock); in lpfc_check_next_fcf_pri_level()
19233 if (!next_fcf_pri && !list_empty(&phba->fcf.fcf_pri_list)) { in lpfc_check_next_fcf_pri_level()
19234 list_for_each_entry(fcf_pri, &phba->fcf.fcf_pri_list, list) { in lpfc_check_next_fcf_pri_level()
19235 fcf_pri->fcf_rec.flag &= ~LPFC_FCF_FLOGI_FAILED; in lpfc_check_next_fcf_pri_level()
19241 next_fcf_pri = fcf_pri->fcf_rec.priority; in lpfc_check_next_fcf_pri_level()
19242 spin_unlock_irq(&phba->hbalock); in lpfc_check_next_fcf_pri_level()
19243 if (fcf_pri->fcf_rec.priority == next_fcf_pri) { in lpfc_check_next_fcf_pri_level()
19245 fcf_pri->fcf_rec.fcf_index); in lpfc_check_next_fcf_pri_level()
19249 spin_lock_irq(&phba->hbalock); in lpfc_check_next_fcf_pri_level()
19253 spin_unlock_irq(&phba->hbalock); in lpfc_check_next_fcf_pri_level()
19258 * lpfc_sli4_fcf_rr_next_index_get - Get next eligible fcf record index
19274 next_fcf_index = phba->fcf.current_rec.fcf_indx; in lpfc_sli4_fcf_rr_next_index_get()
19279 next_fcf_index = find_next_bit(phba->fcf.fcf_rr_bmask, in lpfc_sli4_fcf_rr_next_index_get()
19283 /* Wrap around condition on phba->fcf.fcf_rr_bmask */ in lpfc_sli4_fcf_rr_next_index_get()
19290 next_fcf_index = find_next_bit(phba->fcf.fcf_rr_bmask, in lpfc_sli4_fcf_rr_next_index_get()
19297 next_fcf_index == phba->fcf.current_rec.fcf_indx) { in lpfc_sli4_fcf_rr_next_index_get()
19313 phba->fcf.fcf_pri[next_fcf_index].fcf_rec.flag & in lpfc_sli4_fcf_rr_next_index_get()
19315 if (list_is_singular(&phba->fcf.fcf_pri_list)) in lpfc_sli4_fcf_rr_next_index_get()
19329 * lpfc_sli4_fcf_rr_index_set - Set bmask with eligible fcf record index
19339 * -EINVAL.
19349 return -EINVAL; in lpfc_sli4_fcf_rr_index_set()
19352 set_bit(fcf_index, phba->fcf.fcf_rr_bmask); in lpfc_sli4_fcf_rr_index_set()
19362 * lpfc_sli4_fcf_rr_index_clear - Clear bmask from eligible fcf record index
19383 spin_lock_irq(&phba->hbalock); in lpfc_sli4_fcf_rr_index_clear()
19384 list_for_each_entry_safe(fcf_pri, fcf_pri_next, &phba->fcf.fcf_pri_list, in lpfc_sli4_fcf_rr_index_clear()
19386 if (fcf_pri->fcf_rec.fcf_index == fcf_index) { in lpfc_sli4_fcf_rr_index_clear()
19387 list_del_init(&fcf_pri->list); in lpfc_sli4_fcf_rr_index_clear()
19391 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_fcf_rr_index_clear()
19392 clear_bit(fcf_index, phba->fcf.fcf_rr_bmask); in lpfc_sli4_fcf_rr_index_clear()
19400 * lpfc_mbx_cmpl_redisc_fcf_table - completion routine for rediscover FCF table
19404 * This routine is the completion routine for the rediscover FCF table mailbox
19405 * command. If the mailbox command returned failure, it will try to stop the
19414 redisc_fcf = &mbox->u.mqe.un.redisc_fcf_tbl; in lpfc_mbx_cmpl_redisc_fcf_table()
19417 &redisc_fcf->header.cfg_shdr.response); in lpfc_mbx_cmpl_redisc_fcf_table()
19419 &redisc_fcf->header.cfg_shdr.response); in lpfc_mbx_cmpl_redisc_fcf_table()
19425 if (phba->fcf.fcf_flag & FCF_ACVL_DISC) { in lpfc_mbx_cmpl_redisc_fcf_table()
19426 spin_lock_irq(&phba->hbalock); in lpfc_mbx_cmpl_redisc_fcf_table()
19427 phba->fcf.fcf_flag &= ~FCF_ACVL_DISC; in lpfc_mbx_cmpl_redisc_fcf_table()
19428 spin_unlock_irq(&phba->hbalock); in lpfc_mbx_cmpl_redisc_fcf_table()
19431 * last resort to re-try current registered FCF entry. in lpfc_mbx_cmpl_redisc_fcf_table()
19435 spin_lock_irq(&phba->hbalock); in lpfc_mbx_cmpl_redisc_fcf_table()
19436 phba->fcf.fcf_flag &= ~FCF_DEAD_DISC; in lpfc_mbx_cmpl_redisc_fcf_table()
19437 spin_unlock_irq(&phba->hbalock); in lpfc_mbx_cmpl_redisc_fcf_table()
19455 mempool_free(mbox, phba->mbox_mem_pool); in lpfc_mbx_cmpl_redisc_fcf_table()
19459 * lpfc_sli4_redisc_fcf_table - Request to rediscover entire FCF table by port.
19475 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_redisc_fcf_table()
19480 return -ENOMEM; in lpfc_sli4_redisc_fcf_table()
19483 length = (sizeof(struct lpfc_mbx_redisc_fcf_tbl) - in lpfc_sli4_redisc_fcf_table()
19489 redisc_fcf = &mbox->u.mqe.un.redisc_fcf_tbl; in lpfc_sli4_redisc_fcf_table()
19493 /* Issue the mailbox command asynchronously */ in lpfc_sli4_redisc_fcf_table()
19494 mbox->vport = phba->pport; in lpfc_sli4_redisc_fcf_table()
19495 mbox->mbox_cmpl = lpfc_mbx_cmpl_redisc_fcf_table; in lpfc_sli4_redisc_fcf_table()
19499 mempool_free(mbox, phba->mbox_mem_pool); in lpfc_sli4_redisc_fcf_table()
19500 return -EIO; in lpfc_sli4_redisc_fcf_table()
19506 * lpfc_sli4_fcf_dead_failthrough - Failthrough routine to fcf dead event
19522 link_state = phba->link_state; in lpfc_sli4_fcf_dead_failthrough()
19524 phba->link_state = link_state; in lpfc_sli4_fcf_dead_failthrough()
19531 * lpfc_sli_get_config_region23 - Get sli3 port region 23 data.
19536 * mailbox command. When it successfully retrieves data, the size of the data
19550 pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli_get_config_region23()
19553 "2600 failed to allocate mailbox memory\n"); in lpfc_sli_get_config_region23()
19556 mb = &pmb->u.mb; in lpfc_sli_get_config_region23()
19566 rc, mb->mbxStatus); in lpfc_sli_get_config_region23()
19567 mb->un.varDmp.word_cnt = 0; in lpfc_sli_get_config_region23()
19571 * mailbox error, either way we are done. in lpfc_sli_get_config_region23()
19573 if (mb->un.varDmp.word_cnt == 0) in lpfc_sli_get_config_region23()
19576 i = mb->un.varDmp.word_cnt * sizeof(uint32_t); in lpfc_sli_get_config_region23()
19578 i = DMP_RGN23_SIZE - offset; in lpfc_sli_get_config_region23()
19584 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_sli_get_config_region23()
19589 * lpfc_sli4_get_config_region23 - Get sli4 port region 23 data.
19594 * mailbox command. When it successfully retrieves data, the size of the data
19609 mboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_get_config_region23()
19612 "3105 failed to allocate mailbox memory\n"); in lpfc_sli4_get_config_region23()
19618 mqe = &mboxq->u.mqe; in lpfc_sli4_get_config_region23()
19619 mp = (struct lpfc_dmabuf *)mboxq->ctx_buf; in lpfc_sli4_get_config_region23()
19623 data_length = mqe->un.mb_words[5]; in lpfc_sli4_get_config_region23()
19630 lpfc_sli_pcimem_bcopy((char *)mp->virt, rgn23_data, data_length); in lpfc_sli4_get_config_region23()
19632 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_get_config_region23()
19634 lpfc_mbuf_free(phba, mp->virt, mp->phys); in lpfc_sli4_get_config_region23()
19641 * lpfc_sli_read_link_ste - Read region 23 to decide if link is disabled.
19660 if (phba->sli_rev < LPFC_SLI_REV4) in lpfc_sli_read_link_ste()
19664 &phba->sli4_hba.sli_intf); in lpfc_sli_read_link_ste()
19710 * Search for configured port state sub-TLV. in lpfc_sli_read_link_ste()
19727 phba->hba_flag |= LINK_DISABLED; in lpfc_sli_read_link_ste()
19739 * lpfc_wr_object - write an object to the firmware
19745 * This routine will create a wr_object mailbox command to send to the port.
19746 * the mailbox command will be constructed using the dma buffers described in
19748 * BDEs that the imbedded mailbox can support. The @offset variable will be
19750 * the offset after the write object mailbox has completed. @size is used to
19770 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_wr_object()
19772 return -ENOMEM; in lpfc_wr_object()
19776 sizeof(struct lpfc_mbx_wr_object) - in lpfc_wr_object()
19779 wr_object = (struct lpfc_mbx_wr_object *)&mbox->u.mqe.un.wr_object; in lpfc_wr_object()
19780 wr_object->u.request.write_offset = *offset; in lpfc_wr_object()
19781 sprintf((uint8_t *)wr_object->u.request.object_name, "/"); in lpfc_wr_object()
19782 wr_object->u.request.object_name[0] = in lpfc_wr_object()
19783 cpu_to_le32(wr_object->u.request.object_name[0]); in lpfc_wr_object()
19784 bf_set(lpfc_wr_object_eof, &wr_object->u.request, 0); in lpfc_wr_object()
19788 wr_object->u.request.bde[i].addrLow = putPaddrLow(dmabuf->phys); in lpfc_wr_object()
19789 wr_object->u.request.bde[i].addrHigh = in lpfc_wr_object()
19790 putPaddrHigh(dmabuf->phys); in lpfc_wr_object()
19792 wr_object->u.request.bde[i].tus.f.bdeSize = in lpfc_wr_object()
19793 (size - written); in lpfc_wr_object()
19794 written += (size - written); in lpfc_wr_object()
19795 bf_set(lpfc_wr_object_eof, &wr_object->u.request, 1); in lpfc_wr_object()
19796 bf_set(lpfc_wr_object_eas, &wr_object->u.request, 1); in lpfc_wr_object()
19799 wr_object->u.request.bde[i].tus.f.bdeSize = in lpfc_wr_object()
19805 wr_object->u.request.bde_count = i; in lpfc_wr_object()
19806 bf_set(lpfc_wr_object_write_length, &wr_object->u.request, written); in lpfc_wr_object()
19807 if (!phba->sli4_hba.intr_enable) in lpfc_wr_object()
19813 /* The IOCTL status is embedded in the mailbox subheader. */ in lpfc_wr_object()
19815 &wr_object->header.cfg_shdr.response); in lpfc_wr_object()
19817 &wr_object->header.cfg_shdr.response); in lpfc_wr_object()
19820 &wr_object->u.response); in lpfc_wr_object()
19825 &wr_object->u.response); in lpfc_wr_object()
19857 if (!phba->sli4_hba.intr_enable) in lpfc_wr_object()
19858 mempool_free(mbox, phba->mbox_mem_pool); in lpfc_wr_object()
19860 mempool_free(mbox, phba->mbox_mem_pool); in lpfc_wr_object()
19863 "3025 Write Object mailbox failed with " in lpfc_wr_object()
19866 rc = -ENXIO; in lpfc_wr_object()
19869 *offset += wr_object->u.response.actual_write_length; in lpfc_wr_object()
19874 * lpfc_cleanup_pending_mbox - Free up vport discovery mailbox commands.
19878 * and REG_VPI mailbox commands associated with the vport. This function
19885 struct lpfc_hba *phba = vport->phba; in lpfc_cleanup_pending_mbox()
19894 /* Clean up internally queued mailbox commands with the vport */ in lpfc_cleanup_pending_mbox()
19895 spin_lock_irq(&phba->hbalock); in lpfc_cleanup_pending_mbox()
19896 list_for_each_entry_safe(mb, nextmb, &phba->sli.mboxq, list) { in lpfc_cleanup_pending_mbox()
19897 if (mb->vport != vport) in lpfc_cleanup_pending_mbox()
19900 if ((mb->u.mb.mbxCommand != MBX_REG_LOGIN64) && in lpfc_cleanup_pending_mbox()
19901 (mb->u.mb.mbxCommand != MBX_REG_VPI)) in lpfc_cleanup_pending_mbox()
19904 list_del(&mb->list); in lpfc_cleanup_pending_mbox()
19905 list_add_tail(&mb->list, &mbox_cmd_list); in lpfc_cleanup_pending_mbox()
19907 /* Clean up active mailbox command with the vport */ in lpfc_cleanup_pending_mbox()
19908 mb = phba->sli.mbox_active; in lpfc_cleanup_pending_mbox()
19909 if (mb && (mb->vport == vport)) { in lpfc_cleanup_pending_mbox()
19910 if ((mb->u.mb.mbxCommand == MBX_REG_LOGIN64) || in lpfc_cleanup_pending_mbox()
19911 (mb->u.mb.mbxCommand == MBX_REG_VPI)) in lpfc_cleanup_pending_mbox()
19912 mb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_cleanup_pending_mbox()
19913 if (mb->u.mb.mbxCommand == MBX_REG_LOGIN64) { in lpfc_cleanup_pending_mbox()
19914 act_mbx_ndlp = (struct lpfc_nodelist *)mb->ctx_ndlp; in lpfc_cleanup_pending_mbox()
19917 /* Unregister the RPI when mailbox complete */ in lpfc_cleanup_pending_mbox()
19918 mb->mbox_flag |= LPFC_MBX_IMED_UNREG; in lpfc_cleanup_pending_mbox()
19921 /* Cleanup any mailbox completions which are not yet processed */ in lpfc_cleanup_pending_mbox()
19924 list_for_each_entry(mb, &phba->sli.mboxq_cmpl, list) { in lpfc_cleanup_pending_mbox()
19929 if ((mb->vport != vport) || in lpfc_cleanup_pending_mbox()
19930 (mb->mbox_flag & LPFC_MBX_IMED_UNREG)) in lpfc_cleanup_pending_mbox()
19933 if ((mb->u.mb.mbxCommand != MBX_REG_LOGIN64) && in lpfc_cleanup_pending_mbox()
19934 (mb->u.mb.mbxCommand != MBX_REG_VPI)) in lpfc_cleanup_pending_mbox()
19937 mb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_cleanup_pending_mbox()
19938 if (mb->u.mb.mbxCommand == MBX_REG_LOGIN64) { in lpfc_cleanup_pending_mbox()
19939 ndlp = (struct lpfc_nodelist *)mb->ctx_ndlp; in lpfc_cleanup_pending_mbox()
19940 /* Unregister the RPI when mailbox complete */ in lpfc_cleanup_pending_mbox()
19941 mb->mbox_flag |= LPFC_MBX_IMED_UNREG; in lpfc_cleanup_pending_mbox()
19943 spin_unlock_irq(&phba->hbalock); in lpfc_cleanup_pending_mbox()
19944 spin_lock(shost->host_lock); in lpfc_cleanup_pending_mbox()
19945 ndlp->nlp_flag &= ~NLP_IGNR_REG_CMPL; in lpfc_cleanup_pending_mbox()
19946 spin_unlock(shost->host_lock); in lpfc_cleanup_pending_mbox()
19947 spin_lock_irq(&phba->hbalock); in lpfc_cleanup_pending_mbox()
19953 spin_unlock_irq(&phba->hbalock); in lpfc_cleanup_pending_mbox()
19955 /* Release the cleaned-up mailbox commands */ in lpfc_cleanup_pending_mbox()
19958 if (mb->u.mb.mbxCommand == MBX_REG_LOGIN64) { in lpfc_cleanup_pending_mbox()
19959 mp = (struct lpfc_dmabuf *)(mb->ctx_buf); in lpfc_cleanup_pending_mbox()
19961 __lpfc_mbuf_free(phba, mp->virt, mp->phys); in lpfc_cleanup_pending_mbox()
19964 mb->ctx_buf = NULL; in lpfc_cleanup_pending_mbox()
19965 ndlp = (struct lpfc_nodelist *)mb->ctx_ndlp; in lpfc_cleanup_pending_mbox()
19966 mb->ctx_ndlp = NULL; in lpfc_cleanup_pending_mbox()
19968 spin_lock(shost->host_lock); in lpfc_cleanup_pending_mbox()
19969 ndlp->nlp_flag &= ~NLP_IGNR_REG_CMPL; in lpfc_cleanup_pending_mbox()
19970 spin_unlock(shost->host_lock); in lpfc_cleanup_pending_mbox()
19974 mempool_free(mb, phba->mbox_mem_pool); in lpfc_cleanup_pending_mbox()
19977 /* Release the ndlp with the cleaned-up active mailbox command */ in lpfc_cleanup_pending_mbox()
19979 spin_lock(shost->host_lock); in lpfc_cleanup_pending_mbox()
19980 act_mbx_ndlp->nlp_flag &= ~NLP_IGNR_REG_CMPL; in lpfc_cleanup_pending_mbox()
19981 spin_unlock(shost->host_lock); in lpfc_cleanup_pending_mbox()
19987 * lpfc_drain_txq - Drain the txq
20010 if (phba->link_flag & LS_MDS_LOOPBACK) { in lpfc_drain_txq()
20012 wq = phba->sli4_hba.hdwq[0].io_wq; in lpfc_drain_txq()
20015 pring = wq->pring; in lpfc_drain_txq()
20017 wq = phba->sli4_hba.els_wq; in lpfc_drain_txq()
20023 if (unlikely(!pring) || list_empty(&pring->txq)) in lpfc_drain_txq()
20026 spin_lock_irqsave(&pring->ring_lock, iflags); in lpfc_drain_txq()
20027 list_for_each_entry(piocbq, &pring->txq, list) { in lpfc_drain_txq()
20031 if (txq_cnt > pring->txq_max) in lpfc_drain_txq()
20032 pring->txq_max = txq_cnt; in lpfc_drain_txq()
20034 spin_unlock_irqrestore(&pring->ring_lock, iflags); in lpfc_drain_txq()
20036 while (!list_empty(&pring->txq)) { in lpfc_drain_txq()
20037 spin_lock_irqsave(&pring->ring_lock, iflags); in lpfc_drain_txq()
20041 spin_unlock_irqrestore(&pring->ring_lock, iflags); in lpfc_drain_txq()
20050 spin_unlock_irqrestore(&pring->ring_lock, iflags); in lpfc_drain_txq()
20053 txq_cnt--; in lpfc_drain_txq()
20058 piocbq->sli4_lxritag = sglq->sli4_lxritag; in lpfc_drain_txq()
20059 piocbq->sli4_xritag = sglq->sli4_xritag; in lpfc_drain_txq()
20065 fail_msg = " - Wq is full"; in lpfc_drain_txq()
20075 piocbq->iotag, piocbq->sli4_xritag); in lpfc_drain_txq()
20076 list_add_tail(&piocbq->list, &completions); in lpfc_drain_txq()
20079 spin_unlock_irqrestore(&pring->ring_lock, iflags); in lpfc_drain_txq()
20090 * lpfc_wqe_bpl2sgl - Convert the bpl/bde to a sgl.
20125 sgl = (struct sli4_sge *)sglq->sgl; in lpfc_wqe_bpl2sgl()
20126 wqe = &pwqeq->wqe; in lpfc_wqe_bpl2sgl()
20127 pwqeq->iocb.ulpIoTag = pwqeq->iotag; in lpfc_wqe_bpl2sgl()
20129 cmd = bf_get(wqe_cmnd, &wqe->generic.wqe_com); in lpfc_wqe_bpl2sgl()
20131 return sglq->sli4_xritag; in lpfc_wqe_bpl2sgl()
20132 numBdes = pwqeq->rsvd2; in lpfc_wqe_bpl2sgl()
20138 if (pwqeq->context3) in lpfc_wqe_bpl2sgl()
20139 dmabuf = (struct lpfc_dmabuf *)pwqeq->context3; in lpfc_wqe_bpl2sgl()
20143 bpl = (struct ulp_bde64 *)dmabuf->virt; in lpfc_wqe_bpl2sgl()
20149 sgl->addr_hi = bpl->addrHigh; in lpfc_wqe_bpl2sgl()
20150 sgl->addr_lo = bpl->addrLow; in lpfc_wqe_bpl2sgl()
20152 sgl->word2 = le32_to_cpu(sgl->word2); in lpfc_wqe_bpl2sgl()
20160 bde.tus.w = le32_to_cpu(bpl->tus.w); in lpfc_wqe_bpl2sgl()
20161 sgl->sge_len = cpu_to_le32(bde.tus.f.bdeSize); in lpfc_wqe_bpl2sgl()
20169 if (bpl->tus.f.bdeFlags == BUFF_TYPE_BDE_64I) in lpfc_wqe_bpl2sgl()
20187 bpl->tus.f.bdeFlags); in lpfc_wqe_bpl2sgl()
20195 sgl->word2 = cpu_to_le32(sgl->word2); in lpfc_wqe_bpl2sgl()
20199 } else if (wqe->gen_req.bde.tus.f.bdeFlags == BUFF_TYPE_BDE_64) { in lpfc_wqe_bpl2sgl()
20204 sgl->addr_hi = cpu_to_le32(wqe->gen_req.bde.addrHigh); in lpfc_wqe_bpl2sgl()
20205 sgl->addr_lo = cpu_to_le32(wqe->gen_req.bde.addrLow); in lpfc_wqe_bpl2sgl()
20206 sgl->word2 = le32_to_cpu(sgl->word2); in lpfc_wqe_bpl2sgl()
20208 sgl->word2 = cpu_to_le32(sgl->word2); in lpfc_wqe_bpl2sgl()
20209 sgl->sge_len = cpu_to_le32(wqe->gen_req.bde.tus.f.bdeSize); in lpfc_wqe_bpl2sgl()
20211 return sglq->sli4_xritag; in lpfc_wqe_bpl2sgl()
20215 * lpfc_sli4_issue_wqe - Issue an SLI4 Work Queue Entry (WQE)
20224 union lpfc_wqe128 *wqe = &pwqe->wqe; in lpfc_sli4_issue_wqe()
20233 if (pwqe->iocb_flag & LPFC_IO_NVME_LS) { in lpfc_sli4_issue_wqe()
20234 pring = phba->sli4_hba.nvmels_wq->pring; in lpfc_sli4_issue_wqe()
20235 lpfc_qp_spin_lock_irqsave(&pring->ring_lock, iflags, in lpfc_sli4_issue_wqe()
20239 spin_unlock_irqrestore(&pring->ring_lock, iflags); in lpfc_sli4_issue_wqe()
20242 pwqe->sli4_lxritag = sglq->sli4_lxritag; in lpfc_sli4_issue_wqe()
20243 pwqe->sli4_xritag = sglq->sli4_xritag; in lpfc_sli4_issue_wqe()
20245 spin_unlock_irqrestore(&pring->ring_lock, iflags); in lpfc_sli4_issue_wqe()
20248 bf_set(wqe_xri_tag, &pwqe->wqe.xmit_bls_rsp.wqe_com, in lpfc_sli4_issue_wqe()
20249 pwqe->sli4_xritag); in lpfc_sli4_issue_wqe()
20250 ret = lpfc_sli4_wq_put(phba->sli4_hba.nvmels_wq, wqe); in lpfc_sli4_issue_wqe()
20252 spin_unlock_irqrestore(&pring->ring_lock, iflags); in lpfc_sli4_issue_wqe()
20257 spin_unlock_irqrestore(&pring->ring_lock, iflags); in lpfc_sli4_issue_wqe()
20259 lpfc_sli4_poll_eq(qp->hba_eq, LPFC_POLL_FASTPATH); in lpfc_sli4_issue_wqe()
20264 if (pwqe->iocb_flag & LPFC_IO_NVME) { in lpfc_sli4_issue_wqe()
20266 wq = qp->io_wq; in lpfc_sli4_issue_wqe()
20267 pring = wq->pring; in lpfc_sli4_issue_wqe()
20269 bf_set(wqe_cqid, &wqe->generic.wqe_com, qp->io_cq_map); in lpfc_sli4_issue_wqe()
20271 lpfc_qp_spin_lock_irqsave(&pring->ring_lock, iflags, in lpfc_sli4_issue_wqe()
20275 spin_unlock_irqrestore(&pring->ring_lock, iflags); in lpfc_sli4_issue_wqe()
20279 spin_unlock_irqrestore(&pring->ring_lock, iflags); in lpfc_sli4_issue_wqe()
20281 lpfc_sli4_poll_eq(qp->hba_eq, LPFC_POLL_FASTPATH); in lpfc_sli4_issue_wqe()
20286 if (pwqe->iocb_flag & LPFC_IO_NVMET) { in lpfc_sli4_issue_wqe()
20288 wq = qp->io_wq; in lpfc_sli4_issue_wqe()
20289 pring = wq->pring; in lpfc_sli4_issue_wqe()
20291 ctxp = pwqe->context2; in lpfc_sli4_issue_wqe()
20292 sglq = ctxp->ctxbuf->sglq; in lpfc_sli4_issue_wqe()
20293 if (pwqe->sli4_xritag == NO_XRI) { in lpfc_sli4_issue_wqe()
20294 pwqe->sli4_lxritag = sglq->sli4_lxritag; in lpfc_sli4_issue_wqe()
20295 pwqe->sli4_xritag = sglq->sli4_xritag; in lpfc_sli4_issue_wqe()
20297 bf_set(wqe_xri_tag, &pwqe->wqe.xmit_bls_rsp.wqe_com, in lpfc_sli4_issue_wqe()
20298 pwqe->sli4_xritag); in lpfc_sli4_issue_wqe()
20299 bf_set(wqe_cqid, &wqe->generic.wqe_com, qp->io_cq_map); in lpfc_sli4_issue_wqe()
20301 lpfc_qp_spin_lock_irqsave(&pring->ring_lock, iflags, in lpfc_sli4_issue_wqe()
20305 spin_unlock_irqrestore(&pring->ring_lock, iflags); in lpfc_sli4_issue_wqe()
20309 spin_unlock_irqrestore(&pring->ring_lock, iflags); in lpfc_sli4_issue_wqe()
20311 lpfc_sli4_poll_eq(qp->hba_eq, LPFC_POLL_FASTPATH); in lpfc_sli4_issue_wqe()
20319 * lpfc_snapshot_mxp - Snapshot pbl, pvt and busy count
20340 qp = &phba->sli4_hba.hdwq[hwqid]; in lpfc_snapshot_mxp()
20341 multixri_pool = qp->p_multixri_pool; in lpfc_snapshot_mxp()
20345 if (multixri_pool->stat_snapshot_taken == LPFC_MXP_SNAPSHOT_TAKEN) { in lpfc_snapshot_mxp()
20346 pvt_pool = &qp->p_multixri_pool->pvt_pool; in lpfc_snapshot_mxp()
20347 pbl_pool = &qp->p_multixri_pool->pbl_pool; in lpfc_snapshot_mxp()
20348 txcmplq_cnt = qp->io_wq->pring->txcmplq_cnt; in lpfc_snapshot_mxp()
20350 multixri_pool->stat_pbl_count = pbl_pool->count; in lpfc_snapshot_mxp()
20351 multixri_pool->stat_pvt_count = pvt_pool->count; in lpfc_snapshot_mxp()
20352 multixri_pool->stat_busy_count = txcmplq_cnt; in lpfc_snapshot_mxp()
20355 multixri_pool->stat_snapshot_taken++; in lpfc_snapshot_mxp()
20360 * lpfc_adjust_pvt_pool_count - Adjust private pool count
20373 multixri_pool = phba->sli4_hba.hdwq[hwqid].p_multixri_pool; in lpfc_adjust_pvt_pool_count()
20376 io_req_count = multixri_pool->io_req_count; in lpfc_adjust_pvt_pool_count()
20377 prev_io_req_count = multixri_pool->prev_io_req_count; in lpfc_adjust_pvt_pool_count()
20381 multixri_pool->prev_io_req_count = io_req_count; in lpfc_adjust_pvt_pool_count()
20391 * lpfc_adjust_high_watermark - Adjust high watermark
20409 qp = &phba->sli4_hba.hdwq[hwqid]; in lpfc_adjust_high_watermark()
20410 multixri_pool = qp->p_multixri_pool; in lpfc_adjust_high_watermark()
20413 xri_limit = multixri_pool->xri_limit; in lpfc_adjust_high_watermark()
20418 txcmplq_cnt = qp->io_wq->pring->txcmplq_cnt; in lpfc_adjust_high_watermark()
20419 abts_io_bufs = qp->abts_scsi_io_bufs; in lpfc_adjust_high_watermark()
20420 abts_io_bufs += qp->abts_nvme_io_bufs; in lpfc_adjust_high_watermark()
20425 multixri_pool->pvt_pool.high_watermark = new_watermark; in lpfc_adjust_high_watermark()
20428 multixri_pool->stat_max_hwm = max(multixri_pool->stat_max_hwm, in lpfc_adjust_high_watermark()
20434 * lpfc_move_xri_pvt_to_pbl - Move some XRIs from private to public pool
20440 * The first step moves (all - low_watermark) amount of XRIs.
20454 qp = &phba->sli4_hba.hdwq[hwqid]; in lpfc_move_xri_pvt_to_pbl()
20455 pbl_pool = &qp->p_multixri_pool->pbl_pool; in lpfc_move_xri_pvt_to_pbl()
20456 pvt_pool = &qp->p_multixri_pool->pvt_pool; in lpfc_move_xri_pvt_to_pbl()
20459 lpfc_qp_spin_lock_irqsave(&pbl_pool->lock, iflag, qp, mv_to_pub_pool); in lpfc_move_xri_pvt_to_pbl()
20460 lpfc_qp_spin_lock(&pvt_pool->lock, qp, mv_from_pvt_pool); in lpfc_move_xri_pvt_to_pbl()
20462 if (pvt_pool->count > pvt_pool->low_watermark) { in lpfc_move_xri_pvt_to_pbl()
20463 /* Step 1: move (all - low_watermark) from pvt_pool in lpfc_move_xri_pvt_to_pbl()
20470 &pvt_pool->list, list) { in lpfc_move_xri_pvt_to_pbl()
20471 list_move_tail(&lpfc_ncmd->list, &tmp_list); in lpfc_move_xri_pvt_to_pbl()
20473 if (tmp_count >= pvt_pool->low_watermark) in lpfc_move_xri_pvt_to_pbl()
20478 list_splice_init(&pvt_pool->list, &pbl_pool->list); in lpfc_move_xri_pvt_to_pbl()
20481 list_splice(&tmp_list, &pvt_pool->list); in lpfc_move_xri_pvt_to_pbl()
20483 pbl_pool->count += (pvt_pool->count - tmp_count); in lpfc_move_xri_pvt_to_pbl()
20484 pvt_pool->count = tmp_count; in lpfc_move_xri_pvt_to_pbl()
20487 list_splice_init(&pvt_pool->list, &pbl_pool->list); in lpfc_move_xri_pvt_to_pbl()
20488 pbl_pool->count += pvt_pool->count; in lpfc_move_xri_pvt_to_pbl()
20489 pvt_pool->count = 0; in lpfc_move_xri_pvt_to_pbl()
20492 spin_unlock(&pvt_pool->lock); in lpfc_move_xri_pvt_to_pbl()
20493 spin_unlock_irqrestore(&pbl_pool->lock, iflag); in lpfc_move_xri_pvt_to_pbl()
20497 * _lpfc_move_xri_pbl_to_pvt - Move some XRIs from public to private pool
20509 * true - if XRIs are successfully moved from the specified pbl_pool to the
20511 * false - if the specified pbl_pool is empty or locked by someone else
20523 ret = spin_trylock_irqsave(&pbl_pool->lock, iflag); in _lpfc_move_xri_pbl_to_pvt()
20525 if (pbl_pool->count) { in _lpfc_move_xri_pbl_to_pvt()
20527 lpfc_qp_spin_lock(&pvt_pool->lock, qp, mv_to_pvt_pool); in _lpfc_move_xri_pbl_to_pvt()
20530 &pbl_pool->list, in _lpfc_move_xri_pbl_to_pvt()
20532 list_move_tail(&lpfc_ncmd->list, in _lpfc_move_xri_pbl_to_pvt()
20533 &pvt_pool->list); in _lpfc_move_xri_pbl_to_pvt()
20534 pvt_pool->count++; in _lpfc_move_xri_pbl_to_pvt()
20535 pbl_pool->count--; in _lpfc_move_xri_pbl_to_pvt()
20536 count--; in _lpfc_move_xri_pbl_to_pvt()
20541 spin_unlock(&pvt_pool->lock); in _lpfc_move_xri_pbl_to_pvt()
20542 spin_unlock_irqrestore(&pbl_pool->lock, iflag); in _lpfc_move_xri_pbl_to_pvt()
20545 spin_unlock_irqrestore(&pbl_pool->lock, iflag); in _lpfc_move_xri_pbl_to_pvt()
20552 * lpfc_move_xri_pbl_to_pvt - Move some XRIs from public to private pool
20574 qp = &phba->sli4_hba.hdwq[hwqid]; in lpfc_move_xri_pbl_to_pvt()
20575 multixri_pool = qp->p_multixri_pool; in lpfc_move_xri_pbl_to_pvt()
20576 pvt_pool = &multixri_pool->pvt_pool; in lpfc_move_xri_pbl_to_pvt()
20577 pbl_pool = &multixri_pool->pbl_pool; in lpfc_move_xri_pbl_to_pvt()
20583 multixri_pool->local_pbl_hit_count++; in lpfc_move_xri_pbl_to_pvt()
20588 hwq_count = phba->cfg_hdw_queue; in lpfc_move_xri_pbl_to_pvt()
20591 next_hwqid = multixri_pool->rrb_next_hwqid; in lpfc_move_xri_pbl_to_pvt()
20598 phba->sli4_hba.hdwq[next_hwqid].p_multixri_pool; in lpfc_move_xri_pbl_to_pvt()
20599 pbl_pool = &next_multixri_pool->pbl_pool; in lpfc_move_xri_pbl_to_pvt()
20605 /* Exit while-loop if success or all hwqid are checked */ in lpfc_move_xri_pbl_to_pvt()
20606 } while (!ret && next_hwqid != multixri_pool->rrb_next_hwqid); in lpfc_move_xri_pbl_to_pvt()
20609 multixri_pool->rrb_next_hwqid = next_hwqid; in lpfc_move_xri_pbl_to_pvt()
20613 multixri_pool->pbl_empty_count++; in lpfc_move_xri_pbl_to_pvt()
20619 multixri_pool->local_pbl_hit_count++; in lpfc_move_xri_pbl_to_pvt()
20621 multixri_pool->other_pbl_hit_count++; in lpfc_move_xri_pbl_to_pvt()
20627 * lpfc_keep_pvt_pool_above_lowwm - Keep pvt_pool above low watermark
20639 multixri_pool = phba->sli4_hba.hdwq[hwqid].p_multixri_pool; in lpfc_keep_pvt_pool_above_lowwm()
20640 pvt_pool = &multixri_pool->pvt_pool; in lpfc_keep_pvt_pool_above_lowwm()
20642 if (pvt_pool->count < pvt_pool->low_watermark) in lpfc_keep_pvt_pool_above_lowwm()
20647 * lpfc_release_io_buf - Return one IO buf back to free pool
20671 lpfc_ncmd->nvmeCmd = NULL; in lpfc_release_io_buf()
20672 lpfc_ncmd->cur_iocbq.wqe_cmpl = NULL; in lpfc_release_io_buf()
20673 lpfc_ncmd->cur_iocbq.iocb_cmpl = NULL; in lpfc_release_io_buf()
20675 if (phba->cfg_xpsgl && !phba->nvmet_support && in lpfc_release_io_buf()
20676 !list_empty(&lpfc_ncmd->dma_sgl_xtra_list)) in lpfc_release_io_buf()
20679 if (!list_empty(&lpfc_ncmd->dma_cmd_rsp_list)) in lpfc_release_io_buf()
20682 if (phba->cfg_xri_rebalancing) { in lpfc_release_io_buf()
20683 if (lpfc_ncmd->expedite) { in lpfc_release_io_buf()
20685 epd_pool = &phba->epd_pool; in lpfc_release_io_buf()
20686 spin_lock_irqsave(&epd_pool->lock, iflag); in lpfc_release_io_buf()
20687 list_add_tail(&lpfc_ncmd->list, &epd_pool->list); in lpfc_release_io_buf()
20688 epd_pool->count++; in lpfc_release_io_buf()
20689 spin_unlock_irqrestore(&epd_pool->lock, iflag); in lpfc_release_io_buf()
20697 if (!qp->p_multixri_pool) in lpfc_release_io_buf()
20700 pbl_pool = &qp->p_multixri_pool->pbl_pool; in lpfc_release_io_buf()
20701 pvt_pool = &qp->p_multixri_pool->pvt_pool; in lpfc_release_io_buf()
20703 txcmplq_cnt = qp->io_wq->pring->txcmplq_cnt; in lpfc_release_io_buf()
20704 abts_io_bufs = qp->abts_scsi_io_bufs; in lpfc_release_io_buf()
20705 abts_io_bufs += qp->abts_nvme_io_bufs; in lpfc_release_io_buf()
20707 xri_owned = pvt_pool->count + txcmplq_cnt + abts_io_bufs; in lpfc_release_io_buf()
20708 xri_limit = qp->p_multixri_pool->xri_limit; in lpfc_release_io_buf()
20712 qp->p_multixri_pool->below_limit_count++; in lpfc_release_io_buf()
20714 qp->p_multixri_pool->above_limit_count++; in lpfc_release_io_buf()
20720 if ((pvt_pool->count < pvt_pool->low_watermark) || in lpfc_release_io_buf()
20722 pvt_pool->count < pvt_pool->high_watermark)) { in lpfc_release_io_buf()
20723 lpfc_qp_spin_lock_irqsave(&pvt_pool->lock, iflag, in lpfc_release_io_buf()
20725 list_add_tail(&lpfc_ncmd->list, in lpfc_release_io_buf()
20726 &pvt_pool->list); in lpfc_release_io_buf()
20727 pvt_pool->count++; in lpfc_release_io_buf()
20728 spin_unlock_irqrestore(&pvt_pool->lock, iflag); in lpfc_release_io_buf()
20730 lpfc_qp_spin_lock_irqsave(&pbl_pool->lock, iflag, in lpfc_release_io_buf()
20732 list_add_tail(&lpfc_ncmd->list, in lpfc_release_io_buf()
20733 &pbl_pool->list); in lpfc_release_io_buf()
20734 pbl_pool->count++; in lpfc_release_io_buf()
20735 spin_unlock_irqrestore(&pbl_pool->lock, iflag); in lpfc_release_io_buf()
20738 lpfc_qp_spin_lock_irqsave(&qp->io_buf_list_put_lock, iflag, in lpfc_release_io_buf()
20740 list_add_tail(&lpfc_ncmd->list, in lpfc_release_io_buf()
20741 &qp->lpfc_io_buf_list_put); in lpfc_release_io_buf()
20742 qp->put_io_bufs++; in lpfc_release_io_buf()
20743 spin_unlock_irqrestore(&qp->io_buf_list_put_lock, in lpfc_release_io_buf()
20749 * lpfc_get_io_buf_from_private_pool - Get one free IO buf from private pool
20758 * pointer to one free IO buf - if private pool is not empty
20759 * NULL - if private pool is empty
20771 lpfc_qp_spin_lock_irqsave(&pvt_pool->lock, iflag, qp, alloc_pvt_pool); in lpfc_get_io_buf_from_private_pool()
20773 &pvt_pool->list, list) { in lpfc_get_io_buf_from_private_pool()
20775 phba, ndlp, lpfc_ncmd->cur_iocbq.sli4_lxritag)) in lpfc_get_io_buf_from_private_pool()
20777 list_del(&lpfc_ncmd->list); in lpfc_get_io_buf_from_private_pool()
20778 pvt_pool->count--; in lpfc_get_io_buf_from_private_pool()
20779 spin_unlock_irqrestore(&pvt_pool->lock, iflag); in lpfc_get_io_buf_from_private_pool()
20782 spin_unlock_irqrestore(&pvt_pool->lock, iflag); in lpfc_get_io_buf_from_private_pool()
20788 * lpfc_get_io_buf_from_expedite_pool - Get one free IO buf from expedite pool
20794 * pointer to one free IO buf - if expedite pool is not empty
20795 * NULL - if expedite pool is empty
20805 epd_pool = &phba->epd_pool; in lpfc_get_io_buf_from_expedite_pool()
20808 spin_lock_irqsave(&epd_pool->lock, iflag); in lpfc_get_io_buf_from_expedite_pool()
20809 if (epd_pool->count > 0) { in lpfc_get_io_buf_from_expedite_pool()
20811 &epd_pool->list, list) { in lpfc_get_io_buf_from_expedite_pool()
20812 list_del(&lpfc_ncmd->list); in lpfc_get_io_buf_from_expedite_pool()
20813 epd_pool->count--; in lpfc_get_io_buf_from_expedite_pool()
20817 spin_unlock_irqrestore(&epd_pool->lock, iflag); in lpfc_get_io_buf_from_expedite_pool()
20823 * lpfc_get_io_buf_from_multixri_pools - Get one free IO bufs
20842 * pointer to one free IO buf - if private pool is not empty
20843 * NULL - if private pool is empty
20855 qp = &phba->sli4_hba.hdwq[hwqid]; in lpfc_get_io_buf_from_multixri_pools()
20857 multixri_pool = qp->p_multixri_pool; in lpfc_get_io_buf_from_multixri_pools()
20858 pvt_pool = &multixri_pool->pvt_pool; in lpfc_get_io_buf_from_multixri_pools()
20859 multixri_pool->io_req_count++; in lpfc_get_io_buf_from_multixri_pools()
20862 if (pvt_pool->count == 0) in lpfc_get_io_buf_from_multixri_pools()
20869 lpfc_ncmd->hdwq = qp; in lpfc_get_io_buf_from_multixri_pools()
20870 lpfc_ncmd->hdwq_no = hwqid; in lpfc_get_io_buf_from_multixri_pools()
20887 qp = &phba->sli4_hba.hdwq[idx]; in lpfc_io_buf()
20889 &qp->lpfc_io_buf_list_get, list) { in lpfc_io_buf()
20891 lpfc_cmd->cur_iocbq.sli4_lxritag)) in lpfc_io_buf()
20894 if (lpfc_cmd->flags & LPFC_SBUF_NOT_POSTED) in lpfc_io_buf()
20897 list_del_init(&lpfc_cmd->list); in lpfc_io_buf()
20898 qp->get_io_bufs--; in lpfc_io_buf()
20899 lpfc_cmd->hdwq = qp; in lpfc_io_buf()
20900 lpfc_cmd->hdwq_no = idx; in lpfc_io_buf()
20907 * lpfc_get_io_buf - Get one IO buffer from free pool
20921 * NULL - Error
20922 * Pointer to lpfc_io_buf - Success
20932 qp = &phba->sli4_hba.hdwq[hwqid]; in lpfc_get_io_buf()
20935 if (phba->cfg_xri_rebalancing) in lpfc_get_io_buf()
20939 lpfc_qp_spin_lock_irqsave(&qp->io_buf_list_get_lock, iflag, in lpfc_get_io_buf()
20941 if (qp->get_io_bufs > LPFC_NVME_EXPEDITE_XRICNT || expedite) in lpfc_get_io_buf()
20944 lpfc_qp_spin_lock(&qp->io_buf_list_put_lock, in lpfc_get_io_buf()
20946 list_splice(&qp->lpfc_io_buf_list_put, in lpfc_get_io_buf()
20947 &qp->lpfc_io_buf_list_get); in lpfc_get_io_buf()
20948 qp->get_io_bufs += qp->put_io_bufs; in lpfc_get_io_buf()
20949 INIT_LIST_HEAD(&qp->lpfc_io_buf_list_put); in lpfc_get_io_buf()
20950 qp->put_io_bufs = 0; in lpfc_get_io_buf()
20951 spin_unlock(&qp->io_buf_list_put_lock); in lpfc_get_io_buf()
20952 if (qp->get_io_bufs > LPFC_NVME_EXPEDITE_XRICNT || in lpfc_get_io_buf()
20956 spin_unlock_irqrestore(&qp->io_buf_list_get_lock, iflag); in lpfc_get_io_buf()
20963 * lpfc_get_sgl_per_hdwq - Get one SGL chunk from hdwq's pool
20971 * NULL - Error
20972 * Pointer to sli4_hybrid_sgl - Success
20980 struct lpfc_sli4_hdw_queue *hdwq = lpfc_buf->hdwq; in lpfc_get_sgl_per_hdwq()
20981 struct list_head *buf_list = &hdwq->sgl_list; in lpfc_get_sgl_per_hdwq()
20984 spin_lock_irqsave(&hdwq->hdwq_lock, iflags); in lpfc_get_sgl_per_hdwq()
20990 list_move_tail(&list_entry->list_node, in lpfc_get_sgl_per_hdwq()
20991 &lpfc_buf->dma_sgl_xtra_list); in lpfc_get_sgl_per_hdwq()
20996 spin_unlock_irqrestore(&hdwq->hdwq_lock, iflags); in lpfc_get_sgl_per_hdwq()
20998 cpu_to_node(hdwq->io_wq->chann)); in lpfc_get_sgl_per_hdwq()
21003 lpfc_buf->hdwq_no, __func__); in lpfc_get_sgl_per_hdwq()
21007 tmp->dma_sgl = dma_pool_alloc(phba->lpfc_sg_dma_buf_pool, in lpfc_get_sgl_per_hdwq()
21008 GFP_ATOMIC, &tmp->dma_phys_sgl); in lpfc_get_sgl_per_hdwq()
21009 if (!tmp->dma_sgl) { in lpfc_get_sgl_per_hdwq()
21013 lpfc_buf->hdwq_no, __func__); in lpfc_get_sgl_per_hdwq()
21018 spin_lock_irqsave(&hdwq->hdwq_lock, iflags); in lpfc_get_sgl_per_hdwq()
21019 list_add_tail(&tmp->list_node, &lpfc_buf->dma_sgl_xtra_list); in lpfc_get_sgl_per_hdwq()
21022 allocated_sgl = list_last_entry(&lpfc_buf->dma_sgl_xtra_list, in lpfc_get_sgl_per_hdwq()
21026 spin_unlock_irqrestore(&hdwq->hdwq_lock, iflags); in lpfc_get_sgl_per_hdwq()
21032 * lpfc_put_sgl_per_hdwq - Put one SGL chunk into hdwq pool
21039 * 0 - Success
21040 * -EINVAL - Error
21048 struct lpfc_sli4_hdw_queue *hdwq = lpfc_buf->hdwq; in lpfc_put_sgl_per_hdwq()
21049 struct list_head *buf_list = &hdwq->sgl_list; in lpfc_put_sgl_per_hdwq()
21052 spin_lock_irqsave(&hdwq->hdwq_lock, iflags); in lpfc_put_sgl_per_hdwq()
21054 if (likely(!list_empty(&lpfc_buf->dma_sgl_xtra_list))) { in lpfc_put_sgl_per_hdwq()
21056 &lpfc_buf->dma_sgl_xtra_list, in lpfc_put_sgl_per_hdwq()
21058 list_move_tail(&list_entry->list_node, in lpfc_put_sgl_per_hdwq()
21062 rc = -EINVAL; in lpfc_put_sgl_per_hdwq()
21065 spin_unlock_irqrestore(&hdwq->hdwq_lock, iflags); in lpfc_put_sgl_per_hdwq()
21070 * lpfc_free_sgl_per_hdwq - Free all SGL chunks of hdwq pool
21083 struct list_head *buf_list = &hdwq->sgl_list; in lpfc_free_sgl_per_hdwq()
21088 spin_lock_irqsave(&hdwq->hdwq_lock, iflags); in lpfc_free_sgl_per_hdwq()
21093 dma_pool_free(phba->lpfc_sg_dma_buf_pool, in lpfc_free_sgl_per_hdwq()
21094 list_entry->dma_sgl, in lpfc_free_sgl_per_hdwq()
21095 list_entry->dma_phys_sgl); in lpfc_free_sgl_per_hdwq()
21096 list_del(&list_entry->list_node); in lpfc_free_sgl_per_hdwq()
21100 spin_unlock_irqrestore(&hdwq->hdwq_lock, iflags); in lpfc_free_sgl_per_hdwq()
21104 * lpfc_get_cmd_rsp_buf_per_hdwq - Get one CMD/RSP buffer from hdwq
21112 * NULL - Error
21113 * Pointer to fcp_cmd_rsp_buf - Success
21122 struct lpfc_sli4_hdw_queue *hdwq = lpfc_buf->hdwq; in lpfc_get_cmd_rsp_buf_per_hdwq()
21123 struct list_head *buf_list = &hdwq->cmd_rsp_buf_list; in lpfc_get_cmd_rsp_buf_per_hdwq()
21126 spin_lock_irqsave(&hdwq->hdwq_lock, iflags); in lpfc_get_cmd_rsp_buf_per_hdwq()
21133 list_move_tail(&list_entry->list_node, in lpfc_get_cmd_rsp_buf_per_hdwq()
21134 &lpfc_buf->dma_cmd_rsp_list); in lpfc_get_cmd_rsp_buf_per_hdwq()
21139 spin_unlock_irqrestore(&hdwq->hdwq_lock, iflags); in lpfc_get_cmd_rsp_buf_per_hdwq()
21141 cpu_to_node(hdwq->io_wq->chann)); in lpfc_get_cmd_rsp_buf_per_hdwq()
21146 lpfc_buf->hdwq_no, __func__); in lpfc_get_cmd_rsp_buf_per_hdwq()
21150 tmp->fcp_cmnd = dma_pool_alloc(phba->lpfc_cmd_rsp_buf_pool, in lpfc_get_cmd_rsp_buf_per_hdwq()
21152 &tmp->fcp_cmd_rsp_dma_handle); in lpfc_get_cmd_rsp_buf_per_hdwq()
21154 if (!tmp->fcp_cmnd) { in lpfc_get_cmd_rsp_buf_per_hdwq()
21158 lpfc_buf->hdwq_no, __func__); in lpfc_get_cmd_rsp_buf_per_hdwq()
21163 tmp->fcp_rsp = (struct fcp_rsp *)((uint8_t *)tmp->fcp_cmnd + in lpfc_get_cmd_rsp_buf_per_hdwq()
21166 spin_lock_irqsave(&hdwq->hdwq_lock, iflags); in lpfc_get_cmd_rsp_buf_per_hdwq()
21167 list_add_tail(&tmp->list_node, &lpfc_buf->dma_cmd_rsp_list); in lpfc_get_cmd_rsp_buf_per_hdwq()
21170 allocated_buf = list_last_entry(&lpfc_buf->dma_cmd_rsp_list, in lpfc_get_cmd_rsp_buf_per_hdwq()
21174 spin_unlock_irqrestore(&hdwq->hdwq_lock, iflags); in lpfc_get_cmd_rsp_buf_per_hdwq()
21180 * lpfc_put_cmd_rsp_buf_per_hdwq - Put one CMD/RSP buffer into hdwq pool
21187 * 0 - Success
21188 * -EINVAL - Error
21197 struct lpfc_sli4_hdw_queue *hdwq = lpfc_buf->hdwq; in lpfc_put_cmd_rsp_buf_per_hdwq()
21198 struct list_head *buf_list = &hdwq->cmd_rsp_buf_list; in lpfc_put_cmd_rsp_buf_per_hdwq()
21201 spin_lock_irqsave(&hdwq->hdwq_lock, iflags); in lpfc_put_cmd_rsp_buf_per_hdwq()
21203 if (likely(!list_empty(&lpfc_buf->dma_cmd_rsp_list))) { in lpfc_put_cmd_rsp_buf_per_hdwq()
21205 &lpfc_buf->dma_cmd_rsp_list, in lpfc_put_cmd_rsp_buf_per_hdwq()
21207 list_move_tail(&list_entry->list_node, in lpfc_put_cmd_rsp_buf_per_hdwq()
21211 rc = -EINVAL; in lpfc_put_cmd_rsp_buf_per_hdwq()
21214 spin_unlock_irqrestore(&hdwq->hdwq_lock, iflags); in lpfc_put_cmd_rsp_buf_per_hdwq()
21219 * lpfc_free_cmd_rsp_buf_per_hdwq - Free all CMD/RSP chunks of hdwq pool
21232 struct list_head *buf_list = &hdwq->cmd_rsp_buf_list; in lpfc_free_cmd_rsp_buf_per_hdwq()
21237 spin_lock_irqsave(&hdwq->hdwq_lock, iflags); in lpfc_free_cmd_rsp_buf_per_hdwq()
21243 dma_pool_free(phba->lpfc_cmd_rsp_buf_pool, in lpfc_free_cmd_rsp_buf_per_hdwq()
21244 list_entry->fcp_cmnd, in lpfc_free_cmd_rsp_buf_per_hdwq()
21245 list_entry->fcp_cmd_rsp_dma_handle); in lpfc_free_cmd_rsp_buf_per_hdwq()
21246 list_del(&list_entry->list_node); in lpfc_free_cmd_rsp_buf_per_hdwq()
21250 spin_unlock_irqrestore(&hdwq->hdwq_lock, iflags); in lpfc_free_cmd_rsp_buf_per_hdwq()