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()
7380 return -ENODEV; in lpfc_sli4_hba_setup()
7385 return -ENODEV; in lpfc_sli4_hba_setup()
7387 spin_lock_irq(&phba->hbalock); in lpfc_sli4_hba_setup()
7388 phba->sli.sli_flag |= LPFC_SLI_ACTIVE; in lpfc_sli4_hba_setup()
7389 flg = phba->sli.sli_flag; in lpfc_sli4_hba_setup()
7390 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_hba_setup()
7396 spin_lock_irq(&phba->hbalock); in lpfc_sli4_hba_setup()
7397 flg = phba->sli.sli_flag; in lpfc_sli4_hba_setup()
7398 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_hba_setup()
7405 * Allocate a single mailbox container for initializing the in lpfc_sli4_hba_setup()
7408 mboxq = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_hba_setup()
7410 return -ENOMEM; in lpfc_sli4_hba_setup()
7416 rc = -ENOMEM; in lpfc_sli4_hba_setup()
7426 mqe = &mboxq->u.mqe; in lpfc_sli4_hba_setup()
7427 phba->sli_rev = bf_get(lpfc_mbx_rd_rev_sli_lvl, &mqe->un.read_rev); in lpfc_sli4_hba_setup()
7428 if (bf_get(lpfc_mbx_rd_rev_fcoe, &mqe->un.read_rev)) { in lpfc_sli4_hba_setup()
7429 phba->hba_flag |= HBA_FCOE_MODE; in lpfc_sli4_hba_setup()
7430 phba->fcp_embed_io = 0; /* SLI4 FC support only */ in lpfc_sli4_hba_setup()
7432 phba->hba_flag &= ~HBA_FCOE_MODE; in lpfc_sli4_hba_setup()
7435 if (bf_get(lpfc_mbx_rd_rev_cee_ver, &mqe->un.read_rev) == in lpfc_sli4_hba_setup()
7437 phba->hba_flag |= HBA_FIP_SUPPORT; in lpfc_sli4_hba_setup()
7439 phba->hba_flag &= ~HBA_FIP_SUPPORT; in lpfc_sli4_hba_setup()
7441 phba->hba_flag &= ~HBA_IOQ_FLUSH; in lpfc_sli4_hba_setup()
7443 if (phba->sli_rev != LPFC_SLI_REV4) { in lpfc_sli4_hba_setup()
7447 phba->sli_rev, phba->hba_flag & HBA_FCOE_MODE); in lpfc_sli4_hba_setup()
7448 rc = -EIO; in lpfc_sli4_hba_setup()
7458 if (phba->hba_flag & HBA_FCOE_MODE && in lpfc_sli4_hba_setup()
7465 * is considered as non-fatal. in lpfc_sli4_hba_setup()
7471 "physical port name: %s.\n", phba->Port); in lpfc_sli4_hba_setup()
7494 phba->vpd.rev.biuRev = mqe->un.read_rev.first_hw_rev; in lpfc_sli4_hba_setup()
7495 phba->vpd.rev.smRev = mqe->un.read_rev.second_hw_rev; in lpfc_sli4_hba_setup()
7501 if ((bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) == in lpfc_sli4_hba_setup()
7503 (phba->vpd.rev.biuRev == LPFC_G7_ASIC_1) && in lpfc_sli4_hba_setup()
7504 (phba->vpd.rev.smRev == 0) && in lpfc_sli4_hba_setup()
7505 (phba->cfg_nvme_embed_cmd == 1)) in lpfc_sli4_hba_setup()
7506 phba->cfg_nvme_embed_cmd = 0; in lpfc_sli4_hba_setup()
7508 phba->vpd.rev.endecRev = mqe->un.read_rev.third_hw_rev; in lpfc_sli4_hba_setup()
7509 phba->vpd.rev.fcphHigh = bf_get(lpfc_mbx_rd_rev_fcph_high, in lpfc_sli4_hba_setup()
7510 &mqe->un.read_rev); in lpfc_sli4_hba_setup()
7511 phba->vpd.rev.fcphLow = bf_get(lpfc_mbx_rd_rev_fcph_low, in lpfc_sli4_hba_setup()
7512 &mqe->un.read_rev); in lpfc_sli4_hba_setup()
7513 phba->vpd.rev.feaLevelHigh = bf_get(lpfc_mbx_rd_rev_ftr_lvl_high, in lpfc_sli4_hba_setup()
7514 &mqe->un.read_rev); in lpfc_sli4_hba_setup()
7515 phba->vpd.rev.feaLevelLow = bf_get(lpfc_mbx_rd_rev_ftr_lvl_low, in lpfc_sli4_hba_setup()
7516 &mqe->un.read_rev); in lpfc_sli4_hba_setup()
7517 phba->vpd.rev.sli1FwRev = mqe->un.read_rev.fw_id_rev; in lpfc_sli4_hba_setup()
7518 memcpy(phba->vpd.rev.sli1FwName, mqe->un.read_rev.fw_name, 16); in lpfc_sli4_hba_setup()
7519 phba->vpd.rev.sli2FwRev = mqe->un.read_rev.ulp_fw_id_rev; in lpfc_sli4_hba_setup()
7520 memcpy(phba->vpd.rev.sli2FwName, mqe->un.read_rev.ulp_fw_name, 16); in lpfc_sli4_hba_setup()
7521 phba->vpd.rev.opFwRev = mqe->un.read_rev.fw_id_rev; in lpfc_sli4_hba_setup()
7522 memcpy(phba->vpd.rev.opFwName, mqe->un.read_rev.fw_name, 16); in lpfc_sli4_hba_setup()
7526 mboxq->vport ? mboxq->vport->vpi : 0, in lpfc_sli4_hba_setup()
7528 phba->vpd.rev.opFwName, in lpfc_sli4_hba_setup()
7529 phba->vpd.rev.fcphHigh, phba->vpd.rev.fcphLow, in lpfc_sli4_hba_setup()
7530 phba->vpd.rev.feaLevelHigh, phba->vpd.rev.feaLevelLow); in lpfc_sli4_hba_setup()
7532 if (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) == in lpfc_sli4_hba_setup()
7537 phba->hba_flag |= HBA_RECOVERABLE_UE; in lpfc_sli4_hba_setup()
7539 phba->eratt_poll_interval = 1; in lpfc_sli4_hba_setup()
7540 phba->sli4_hba.ue_to_sr = bf_get( in lpfc_sli4_hba_setup()
7542 &mboxq->u.mqe.un.set_feature); in lpfc_sli4_hba_setup()
7543 phba->sli4_hba.ue_to_rp = bf_get( in lpfc_sli4_hba_setup()
7545 &mboxq->u.mqe.un.set_feature); in lpfc_sli4_hba_setup()
7549 if (phba->cfg_enable_mds_diags && phba->mds_diags_support) { in lpfc_sli4_hba_setup()
7554 phba->mds_diags_support = 0; in lpfc_sli4_hba_setup()
7564 rc = -EIO; in lpfc_sli4_hba_setup()
7572 if (!(bf_get(lpfc_mbx_rq_ftr_rsp_fcpi, &mqe->un.req_ftrs))) { in lpfc_sli4_hba_setup()
7579 if (phba->hba_flag & HBA_FCOE_MODE) { in lpfc_sli4_hba_setup()
7580 if (bf_get(lpfc_mbx_rq_ftr_rsp_perfh, &mqe->un.req_ftrs)) in lpfc_sli4_hba_setup()
7581 phba->sli3_options |= LPFC_SLI4_PERFH_ENABLED; in lpfc_sli4_hba_setup()
7583 phba->sli3_options &= ~LPFC_SLI4_PERFH_ENABLED; in lpfc_sli4_hba_setup()
7591 if (phba->sli3_options & LPFC_SLI3_BG_ENABLED) { in lpfc_sli4_hba_setup()
7592 if (!(bf_get(lpfc_mbx_rq_ftr_rsp_dif, &mqe->un.req_ftrs))) { in lpfc_sli4_hba_setup()
7593 phba->cfg_enable_bg = 0; in lpfc_sli4_hba_setup()
7594 phba->sli3_options &= ~LPFC_SLI3_BG_ENABLED; in lpfc_sli4_hba_setup()
7599 if (phba->max_vpi && phba->cfg_enable_npiv && in lpfc_sli4_hba_setup()
7600 !(bf_get(lpfc_mbx_rq_ftr_rsp_npiv, &mqe->un.req_ftrs))) in lpfc_sli4_hba_setup()
7606 "x%x x%x x%x\n", mqe->un.req_ftrs.word2, in lpfc_sli4_hba_setup()
7607 mqe->un.req_ftrs.word3, phba->cfg_enable_bg, in lpfc_sli4_hba_setup()
7608 phba->cfg_enable_npiv, phba->max_vpi); in lpfc_sli4_hba_setup()
7609 if (!(bf_get(lpfc_mbx_rq_ftr_rsp_dif, &mqe->un.req_ftrs))) in lpfc_sli4_hba_setup()
7610 phba->cfg_enable_bg = 0; in lpfc_sli4_hba_setup()
7611 if (!(bf_get(lpfc_mbx_rq_ftr_rsp_npiv, &mqe->un.req_ftrs))) in lpfc_sli4_hba_setup()
7612 phba->cfg_enable_npiv = 0; in lpfc_sli4_hba_setup()
7616 spin_lock_irq(&phba->hbalock); in lpfc_sli4_hba_setup()
7617 phba->sli3_options |= (LPFC_SLI3_NPIV_ENABLED | LPFC_SLI3_HBQ_ENABLED); in lpfc_sli4_hba_setup()
7618 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_hba_setup()
7623 dd = bf_get(lpfc_mbx_set_feature_dd, &mboxq->u.mqe.un.set_feature); in lpfc_sli4_hba_setup()
7629 "6447 Dual Dump Mailbox x%x (x%x/x%x) failed, " in lpfc_sli4_hba_setup()
7631 bf_get(lpfc_mqe_command, &mboxq->u.mqe), in lpfc_sli4_hba_setup()
7659 rc = lpfc_read_sparam(phba, mboxq, vport->vpi); in lpfc_sli4_hba_setup()
7661 phba->link_state = LPFC_HBA_ERROR; in lpfc_sli4_hba_setup()
7662 rc = -ENOMEM; in lpfc_sli4_hba_setup()
7666 mboxq->vport = vport; in lpfc_sli4_hba_setup()
7668 mp = (struct lpfc_dmabuf *)mboxq->ctx_buf; in lpfc_sli4_hba_setup()
7670 memcpy(&vport->fc_sparam, mp->virt, sizeof(struct serv_parm)); in lpfc_sli4_hba_setup()
7678 lpfc_mbuf_free(phba, mp->virt, mp->phys); in lpfc_sli4_hba_setup()
7680 mboxq->ctx_buf = NULL; in lpfc_sli4_hba_setup()
7686 phba->link_state = LPFC_HBA_ERROR; in lpfc_sli4_hba_setup()
7687 rc = -EIO; in lpfc_sli4_hba_setup()
7694 fc_host_node_name(shost) = wwn_to_u64(vport->fc_nodename.u.wwn); in lpfc_sli4_hba_setup()
7695 fc_host_port_name(shost) = wwn_to_u64(vport->fc_portname.u.wwn); in lpfc_sli4_hba_setup()
7702 rc = -ENODEV; in lpfc_sli4_hba_setup()
7716 /* update host els xri-sgl sizes and mappings */ in lpfc_sli4_hba_setup()
7720 "1400 Failed to update xri-sgl size and " in lpfc_sli4_hba_setup()
7726 rc = lpfc_sli4_repost_sgl_list(phba, &phba->sli4_hba.lpfc_els_sgl_list, in lpfc_sli4_hba_setup()
7727 phba->sli4_hba.els_xri_cnt); in lpfc_sli4_hba_setup()
7732 rc = -ENODEV; in lpfc_sli4_hba_setup()
7735 phba->sli4_hba.els_xri_cnt = rc; in lpfc_sli4_hba_setup()
7737 if (phba->nvmet_support) { in lpfc_sli4_hba_setup()
7738 /* update host nvmet xri-sgl sizes and mappings */ in lpfc_sli4_hba_setup()
7742 "6308 Failed to update nvmet-sgl size " in lpfc_sli4_hba_setup()
7750 &phba->sli4_hba.lpfc_nvmet_sgl_list, in lpfc_sli4_hba_setup()
7751 phba->sli4_hba.nvmet_xri_cnt); in lpfc_sli4_hba_setup()
7756 rc = -ENODEV; in lpfc_sli4_hba_setup()
7759 phba->sli4_hba.nvmet_xri_cnt = rc; in lpfc_sli4_hba_setup()
7764 cnt = phba->sli4_hba.nvmet_xri_cnt + in lpfc_sli4_hba_setup()
7765 phba->sli4_hba.max_cfg_param.max_xri; in lpfc_sli4_hba_setup()
7767 /* update host common xri-sgl sizes and mappings */ in lpfc_sli4_hba_setup()
7771 "6082 Failed to update nvme-sgl size " in lpfc_sli4_hba_setup()
7784 rc = -ENODEV; in lpfc_sli4_hba_setup()
7790 cnt = phba->sli4_hba.max_cfg_param.max_xri; in lpfc_sli4_hba_setup()
7793 if (!phba->sli.iocbq_lookup) { in lpfc_sli4_hba_setup()
7806 if (phba->nvmet_support) in lpfc_sli4_hba_setup()
7809 if (phba->nvmet_support && phba->cfg_nvmet_mrq) { in lpfc_sli4_hba_setup()
7811 for (i = 0; i < phba->cfg_nvmet_mrq; i++) { in lpfc_sli4_hba_setup()
7812 rqbp = phba->sli4_hba.nvmet_mrq_hdr[i]->rqbp; in lpfc_sli4_hba_setup()
7813 INIT_LIST_HEAD(&rqbp->rqb_buffer_list); in lpfc_sli4_hba_setup()
7814 rqbp->rqb_alloc_buffer = lpfc_sli4_nvmet_alloc; in lpfc_sli4_hba_setup()
7815 rqbp->rqb_free_buffer = lpfc_sli4_nvmet_free; in lpfc_sli4_hba_setup()
7816 rqbp->entry_count = LPFC_NVMET_RQE_DEF_COUNT; in lpfc_sli4_hba_setup()
7817 rqbp->buffer_count = 0; in lpfc_sli4_hba_setup()
7820 phba, phba->sli4_hba.nvmet_mrq_hdr[i], in lpfc_sli4_hba_setup()
7821 phba->sli4_hba.nvmet_mrq_data[i], in lpfc_sli4_hba_setup()
7822 phba->cfg_nvmet_mrq_post, i); in lpfc_sli4_hba_setup()
7832 rc = -ENODEV; in lpfc_sli4_hba_setup()
7837 if (!(phba->hba_flag & HBA_FCOE_MODE)) { in lpfc_sli4_hba_setup()
7838 if ((phba->nvmet_support == 0) || (phba->cfg_nvmet_mrq == 1)) { in lpfc_sli4_hba_setup()
7843 mboxq->vport = phba->pport; in lpfc_sli4_hba_setup()
7848 phba->fcf.fcfi = bf_get(lpfc_reg_fcfi_fcfi, in lpfc_sli4_hba_setup()
7849 &mboxq->u.mqe.un.reg_fcfi); in lpfc_sli4_hba_setup()
7855 mboxq->vport = phba->pport; in lpfc_sli4_hba_setup()
7860 phba->fcf.fcfi = bf_get(lpfc_reg_fcfi_mrq_fcfi, in lpfc_sli4_hba_setup()
7861 &mboxq->u.mqe.un.reg_fcfi_mrq); in lpfc_sli4_hba_setup()
7865 mboxq->vport = phba->pport; in lpfc_sli4_hba_setup()
7878 if (phba->nvmet_support == 0) { in lpfc_sli4_hba_setup()
7879 if (phba->sli4_hba.io_xri_cnt == 0) { in lpfc_sli4_hba_setup()
7881 phba, phba->sli4_hba.io_xri_max); in lpfc_sli4_hba_setup()
7883 rc = -ENOMEM; in lpfc_sli4_hba_setup()
7887 if (phba->cfg_xri_rebalancing) in lpfc_sli4_hba_setup()
7891 phba->cfg_xri_rebalancing = 0; in lpfc_sli4_hba_setup()
7894 /* Allow asynchronous mailbox command to go through */ in lpfc_sli4_hba_setup()
7895 spin_lock_irq(&phba->hbalock); in lpfc_sli4_hba_setup()
7896 phba->sli.sli_flag &= ~LPFC_SLI_ASYNC_MBX_BLK; in lpfc_sli4_hba_setup()
7897 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_hba_setup()
7903 phba->fcf.fcf_flag = 0; in lpfc_sli4_hba_setup()
7904 phba->fcf.current_rec.flag = 0; in lpfc_sli4_hba_setup()
7907 mod_timer(&vport->els_tmofunc, in lpfc_sli4_hba_setup()
7908 jiffies + msecs_to_jiffies(1000 * (phba->fc_ratov * 2))); in lpfc_sli4_hba_setup()
7911 mod_timer(&phba->hb_tmofunc, in lpfc_sli4_hba_setup()
7913 phba->hb_outstanding = 0; in lpfc_sli4_hba_setup()
7914 phba->last_completion_time = jiffies; in lpfc_sli4_hba_setup()
7917 if (phba->cfg_auto_imax) in lpfc_sli4_hba_setup()
7918 queue_delayed_work(phba->wq, &phba->eq_delay_work, in lpfc_sli4_hba_setup()
7925 mod_timer(&phba->eratt_poll, in lpfc_sli4_hba_setup()
7926 jiffies + msecs_to_jiffies(1000 * phba->eratt_poll_interval)); in lpfc_sli4_hba_setup()
7929 if (phba->cfg_aer_support == 1 && !(phba->hba_flag & HBA_AER_ENABLED)) { in lpfc_sli4_hba_setup()
7930 rc = pci_enable_pcie_error_reporting(phba->pcidev); in lpfc_sli4_hba_setup()
7935 spin_lock_irq(&phba->hbalock); in lpfc_sli4_hba_setup()
7936 phba->hba_flag |= HBA_AER_ENABLED; in lpfc_sli4_hba_setup()
7937 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_hba_setup()
7942 phba->cfg_aer_support = 0; in lpfc_sli4_hba_setup()
7951 spin_lock_irq(&phba->hbalock); in lpfc_sli4_hba_setup()
7952 phba->link_state = LPFC_LINK_DOWN; in lpfc_sli4_hba_setup()
7955 if (bf_get(lpfc_conf_trunk_port0, &phba->sli4_hba)) in lpfc_sli4_hba_setup()
7956 phba->trunk_link.link0.state = LPFC_LINK_DOWN; in lpfc_sli4_hba_setup()
7957 if (bf_get(lpfc_conf_trunk_port1, &phba->sli4_hba)) in lpfc_sli4_hba_setup()
7958 phba->trunk_link.link1.state = LPFC_LINK_DOWN; in lpfc_sli4_hba_setup()
7959 if (bf_get(lpfc_conf_trunk_port2, &phba->sli4_hba)) in lpfc_sli4_hba_setup()
7960 phba->trunk_link.link2.state = LPFC_LINK_DOWN; in lpfc_sli4_hba_setup()
7961 if (bf_get(lpfc_conf_trunk_port3, &phba->sli4_hba)) in lpfc_sli4_hba_setup()
7962 phba->trunk_link.link3.state = LPFC_LINK_DOWN; in lpfc_sli4_hba_setup()
7963 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_hba_setup()
7969 phba->sli4_hba.intr_enable = 1; in lpfc_sli4_hba_setup()
7971 if (!(phba->hba_flag & HBA_FCOE_MODE) && in lpfc_sli4_hba_setup()
7972 (phba->hba_flag & LINK_DISABLED)) { in lpfc_sli4_hba_setup()
7983 } else if (phba->cfg_suppress_link_up == LPFC_INITIALIZE_LINK) { in lpfc_sli4_hba_setup()
7985 if (!(phba->link_flag & LS_LOOPBACK_MODE)) { in lpfc_sli4_hba_setup()
7986 rc = phba->lpfc_hba_init_link(phba, MBX_NOWAIT); in lpfc_sli4_hba_setup()
7991 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_hba_setup()
8006 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_hba_setup()
8011 * lpfc_mbox_timeout - Timeout call back function for mbox timer
8014 * This is the callback function for mailbox timer. The mailbox
8015 * timer is armed when a new mailbox command is issued and the timer
8016 * is deleted when the mailbox complete. The function is called by
8017 * the kernel timer code when a mailbox does not complete within
8019 * process the mailbox timeout and returns. All the processing is
8029 spin_lock_irqsave(&phba->pport->work_port_lock, iflag); in lpfc_mbox_timeout()
8030 tmo_posted = phba->pport->work_port_events & WORKER_MBOX_TMO; in lpfc_mbox_timeout()
8032 phba->pport->work_port_events |= WORKER_MBOX_TMO; in lpfc_mbox_timeout()
8033 spin_unlock_irqrestore(&phba->pport->work_port_lock, iflag); in lpfc_mbox_timeout()
8041 * lpfc_sli4_mbox_completions_pending - check to see if any mailbox completions
8045 * This function checks if any mailbox completions are present on the mailbox
8058 if (unlikely(!phba) || (phba->sli_rev != LPFC_SLI_REV4)) in lpfc_sli4_mbox_completions_pending()
8061 /* Check for completions on mailbox completion queue */ in lpfc_sli4_mbox_completions_pending()
8063 mcq = phba->sli4_hba.mbx_cq; in lpfc_sli4_mbox_completions_pending()
8064 idx = mcq->hba_index; in lpfc_sli4_mbox_completions_pending()
8065 qe_valid = mcq->qe_valid; in lpfc_sli4_mbox_completions_pending()
8074 idx = (idx + 1) % mcq->entry_count; in lpfc_sli4_mbox_completions_pending()
8075 if (mcq->hba_index == idx) in lpfc_sli4_mbox_completions_pending()
8079 if (phba->sli4_hba.pc_sli4_params.cqav && !idx) in lpfc_sli4_mbox_completions_pending()
8087 * lpfc_sli4_process_missed_mbox_completions - process mbox completions
8092 * maybe missed causing erroneous mailbox timeouts to occur. This function
8093 * checks to see if mbox completions are on the mailbox completion queue
8095 * mailbox completion queue.
8100 struct lpfc_sli4_hba *sli4_hba = &phba->sli4_hba; in lpfc_sli4_process_missed_mbox_completions()
8106 if (unlikely(!phba) || (phba->sli_rev != LPFC_SLI_REV4)) in lpfc_sli4_process_missed_mbox_completions()
8110 if (sli4_hba->hdwq) { in lpfc_sli4_process_missed_mbox_completions()
8111 for (eqidx = 0; eqidx < phba->cfg_irq_chann; eqidx++) { in lpfc_sli4_process_missed_mbox_completions()
8112 eq = phba->sli4_hba.hba_eq_hdl[eqidx].eq; in lpfc_sli4_process_missed_mbox_completions()
8113 if (eq && eq->queue_id == sli4_hba->mbx_cq->assoc_qid) { in lpfc_sli4_process_missed_mbox_completions()
8124 sli4_hba->sli4_eq_clr_intr(fpeq); in lpfc_sli4_process_missed_mbox_completions()
8133 * mailbox commands, async events, els commands, receive queue data in lpfc_sli4_process_missed_mbox_completions()
8141 /* Always clear and re-arm the EQ */ in lpfc_sli4_process_missed_mbox_completions()
8142 sli4_hba->sli4_write_eq_db(phba, fpeq, 0, LPFC_QUEUE_REARM); in lpfc_sli4_process_missed_mbox_completions()
8149 * lpfc_mbox_timeout_handler - Worker thread function to handle mailbox timeout
8152 * This function is called from worker thread when a mailbox command times out.
8159 LPFC_MBOXQ_t *pmbox = phba->sli.mbox_active; in lpfc_mbox_timeout_handler()
8162 struct lpfc_sli *psli = &phba->sli; in lpfc_mbox_timeout_handler()
8164 /* If the mailbox completed, process the completion and return */ in lpfc_mbox_timeout_handler()
8169 mb = &pmbox->u.mb; in lpfc_mbox_timeout_handler()
8172 * worklist and the mailbox actually completing. When this in lpfc_mbox_timeout_handler()
8175 spin_lock_irq(&phba->hbalock); in lpfc_mbox_timeout_handler()
8179 "0353 Active Mailbox cleared - mailbox timeout " in lpfc_mbox_timeout_handler()
8181 spin_unlock_irq(&phba->hbalock); in lpfc_mbox_timeout_handler()
8187 "0310 Mailbox command x%x timeout Data: x%x x%x x%px\n", in lpfc_mbox_timeout_handler()
8188 mb->mbxCommand, in lpfc_mbox_timeout_handler()
8189 phba->pport->port_state, in lpfc_mbox_timeout_handler()
8190 phba->sli.sli_flag, in lpfc_mbox_timeout_handler()
8191 phba->sli.mbox_active); in lpfc_mbox_timeout_handler()
8192 spin_unlock_irq(&phba->hbalock); in lpfc_mbox_timeout_handler()
8198 spin_lock_irq(&phba->pport->work_port_lock); in lpfc_mbox_timeout_handler()
8199 phba->pport->work_port_events &= ~WORKER_MBOX_TMO; in lpfc_mbox_timeout_handler()
8200 spin_unlock_irq(&phba->pport->work_port_lock); in lpfc_mbox_timeout_handler()
8201 spin_lock_irq(&phba->hbalock); in lpfc_mbox_timeout_handler()
8202 phba->link_state = LPFC_LINK_UNKNOWN; in lpfc_mbox_timeout_handler()
8203 psli->sli_flag &= ~LPFC_SLI_ACTIVE; in lpfc_mbox_timeout_handler()
8204 spin_unlock_irq(&phba->hbalock); in lpfc_mbox_timeout_handler()
8209 "0345 Resetting board due to mailbox timeout\n"); in lpfc_mbox_timeout_handler()
8216 * lpfc_sli_issue_mbox_s3 - Issue an SLI3 mailbox command to firmware
8218 * @pmbox: Pointer to mailbox object.
8219 * @flag: Flag indicating how the mailbox need to be processed.
8222 * to submit a mailbox command to firmware with SLI-3 interface spec. This
8224 * The mailbox command can be submitted in polling mode, in which case
8226 * mailbox.
8227 * If the mailbox is submitted in no_wait mode (not polling) the
8229 * for the mailbox completion. The no_wait is supported only when HBA
8230 * is in SLI2/SLI3 mode - interrupts are enabled.
8231 * The SLI interface allows only one mailbox pending at a time. If the
8232 * mailbox is issued in polling mode and there is already a mailbox
8233 * pending, then the function will return an error. If the mailbox is issued
8234 * in NO_WAIT mode and there is a mailbox pending already, the function
8235 * will return MBX_BUSY after queuing the mailbox into mailbox queue.
8236 * The sli layer owns the mailbox object until the completion of mailbox
8238 * return codes the caller owns the mailbox command after the return of
8246 struct lpfc_sli *psli = &phba->sli; in lpfc_sli_issue_mbox_s3()
8256 spin_lock_irqsave(&phba->hbalock, drvr_flag); in lpfc_sli_issue_mbox_s3()
8258 phba->sli.sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; in lpfc_sli_issue_mbox_s3()
8260 if (unlikely(psli->sli_flag & LPFC_SLI_ASYNC_MBX_BLK)) { in lpfc_sli_issue_mbox_s3()
8261 spin_unlock_irqrestore(&phba->hbalock, drvr_flag); in lpfc_sli_issue_mbox_s3()
8267 spin_unlock_irqrestore(&phba->hbalock, drvr_flag); in lpfc_sli_issue_mbox_s3()
8272 if (pmbox->mbox_cmpl && pmbox->mbox_cmpl != lpfc_sli_def_mbox_cmpl && in lpfc_sli_issue_mbox_s3()
8273 pmbox->mbox_cmpl != lpfc_sli_wake_mbox_wait) { in lpfc_sli_issue_mbox_s3()
8274 if(!pmbox->vport) { in lpfc_sli_issue_mbox_s3()
8275 spin_unlock_irqrestore(&phba->hbalock, drvr_flag); in lpfc_sli_issue_mbox_s3()
8279 pmbox->u.mb.mbxCommand); in lpfc_sli_issue_mbox_s3()
8286 if (unlikely(pci_channel_offline(phba->pcidev))) { in lpfc_sli_issue_mbox_s3()
8287 spin_unlock_irqrestore(&phba->hbalock, drvr_flag); in lpfc_sli_issue_mbox_s3()
8292 if (unlikely(phba->hba_flag & DEFER_ERATT)) { in lpfc_sli_issue_mbox_s3()
8293 spin_unlock_irqrestore(&phba->hbalock, drvr_flag); in lpfc_sli_issue_mbox_s3()
8297 psli = &phba->sli; in lpfc_sli_issue_mbox_s3()
8299 mbx = &pmbox->u.mb; in lpfc_sli_issue_mbox_s3()
8302 if (phba->link_state == LPFC_HBA_ERROR) { in lpfc_sli_issue_mbox_s3()
8303 spin_unlock_irqrestore(&phba->hbalock, drvr_flag); in lpfc_sli_issue_mbox_s3()
8307 "(%d):0311 Mailbox command x%x cannot " in lpfc_sli_issue_mbox_s3()
8309 pmbox->vport ? pmbox->vport->vpi : 0, in lpfc_sli_issue_mbox_s3()
8310 pmbox->u.mb.mbxCommand, psli->sli_flag, flag); in lpfc_sli_issue_mbox_s3()
8314 if (mbx->mbxCommand != MBX_KILL_BOARD && flag & MBX_NOWAIT) { in lpfc_sli_issue_mbox_s3()
8315 if (lpfc_readl(phba->HCregaddr, &hc_copy) || in lpfc_sli_issue_mbox_s3()
8317 spin_unlock_irqrestore(&phba->hbalock, drvr_flag); in lpfc_sli_issue_mbox_s3()
8319 "(%d):2528 Mailbox command x%x cannot " in lpfc_sli_issue_mbox_s3()
8321 pmbox->vport ? pmbox->vport->vpi : 0, in lpfc_sli_issue_mbox_s3()
8322 pmbox->u.mb.mbxCommand, psli->sli_flag, flag); in lpfc_sli_issue_mbox_s3()
8327 if (psli->sli_flag & LPFC_SLI_MBOX_ACTIVE) { in lpfc_sli_issue_mbox_s3()
8334 spin_unlock_irqrestore(&phba->hbalock, drvr_flag); in lpfc_sli_issue_mbox_s3()
8338 "(%d):2529 Mailbox command x%x " in lpfc_sli_issue_mbox_s3()
8340 pmbox->vport ? pmbox->vport->vpi : 0, in lpfc_sli_issue_mbox_s3()
8341 pmbox->u.mb.mbxCommand, in lpfc_sli_issue_mbox_s3()
8342 psli->sli_flag, flag); in lpfc_sli_issue_mbox_s3()
8346 if (!(psli->sli_flag & LPFC_SLI_ACTIVE)) { in lpfc_sli_issue_mbox_s3()
8347 spin_unlock_irqrestore(&phba->hbalock, drvr_flag); in lpfc_sli_issue_mbox_s3()
8350 "(%d):2530 Mailbox command x%x " in lpfc_sli_issue_mbox_s3()
8352 pmbox->vport ? pmbox->vport->vpi : 0, in lpfc_sli_issue_mbox_s3()
8353 pmbox->u.mb.mbxCommand, in lpfc_sli_issue_mbox_s3()
8354 psli->sli_flag, flag); in lpfc_sli_issue_mbox_s3()
8358 /* Another mailbox command is still being processed, queue this in lpfc_sli_issue_mbox_s3()
8363 /* Mbox cmd issue - BUSY */ in lpfc_sli_issue_mbox_s3()
8365 "(%d):0308 Mbox cmd issue - BUSY Data: " in lpfc_sli_issue_mbox_s3()
8367 pmbox->vport ? pmbox->vport->vpi : 0xffffff, in lpfc_sli_issue_mbox_s3()
8368 mbx->mbxCommand, in lpfc_sli_issue_mbox_s3()
8369 phba->pport ? phba->pport->port_state : 0xff, in lpfc_sli_issue_mbox_s3()
8370 psli->sli_flag, flag); in lpfc_sli_issue_mbox_s3()
8372 psli->slistat.mbox_busy++; in lpfc_sli_issue_mbox_s3()
8373 spin_unlock_irqrestore(&phba->hbalock, drvr_flag); in lpfc_sli_issue_mbox_s3()
8375 if (pmbox->vport) { in lpfc_sli_issue_mbox_s3()
8376 lpfc_debugfs_disc_trc(pmbox->vport, in lpfc_sli_issue_mbox_s3()
8379 (uint32_t)mbx->mbxCommand, in lpfc_sli_issue_mbox_s3()
8380 mbx->un.varWords[0], mbx->un.varWords[1]); in lpfc_sli_issue_mbox_s3()
8383 lpfc_debugfs_disc_trc(phba->pport, in lpfc_sli_issue_mbox_s3()
8386 (uint32_t)mbx->mbxCommand, in lpfc_sli_issue_mbox_s3()
8387 mbx->un.varWords[0], mbx->un.varWords[1]); in lpfc_sli_issue_mbox_s3()
8393 psli->sli_flag |= LPFC_SLI_MBOX_ACTIVE; in lpfc_sli_issue_mbox_s3()
8397 if (!(psli->sli_flag & LPFC_SLI_ACTIVE) && in lpfc_sli_issue_mbox_s3()
8398 (mbx->mbxCommand != MBX_KILL_BOARD)) { in lpfc_sli_issue_mbox_s3()
8399 psli->sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; in lpfc_sli_issue_mbox_s3()
8400 spin_unlock_irqrestore(&phba->hbalock, drvr_flag); in lpfc_sli_issue_mbox_s3()
8403 "(%d):2531 Mailbox command x%x " in lpfc_sli_issue_mbox_s3()
8405 pmbox->vport ? pmbox->vport->vpi : 0, in lpfc_sli_issue_mbox_s3()
8406 pmbox->u.mb.mbxCommand, in lpfc_sli_issue_mbox_s3()
8407 psli->sli_flag, flag); in lpfc_sli_issue_mbox_s3()
8413 mod_timer(&psli->mbox_tmo, jiffies + timeout); in lpfc_sli_issue_mbox_s3()
8416 /* Mailbox cmd <cmd> issue */ in lpfc_sli_issue_mbox_s3()
8418 "(%d):0309 Mailbox cmd x%x issue Data: x%x x%x " in lpfc_sli_issue_mbox_s3()
8420 pmbox->vport ? pmbox->vport->vpi : 0, in lpfc_sli_issue_mbox_s3()
8421 mbx->mbxCommand, in lpfc_sli_issue_mbox_s3()
8422 phba->pport ? phba->pport->port_state : 0xff, in lpfc_sli_issue_mbox_s3()
8423 psli->sli_flag, flag); in lpfc_sli_issue_mbox_s3()
8425 if (mbx->mbxCommand != MBX_HEARTBEAT) { in lpfc_sli_issue_mbox_s3()
8426 if (pmbox->vport) { in lpfc_sli_issue_mbox_s3()
8427 lpfc_debugfs_disc_trc(pmbox->vport, in lpfc_sli_issue_mbox_s3()
8430 (uint32_t)mbx->mbxCommand, in lpfc_sli_issue_mbox_s3()
8431 mbx->un.varWords[0], mbx->un.varWords[1]); in lpfc_sli_issue_mbox_s3()
8434 lpfc_debugfs_disc_trc(phba->pport, in lpfc_sli_issue_mbox_s3()
8437 (uint32_t)mbx->mbxCommand, in lpfc_sli_issue_mbox_s3()
8438 mbx->un.varWords[0], mbx->un.varWords[1]); in lpfc_sli_issue_mbox_s3()
8442 psli->slistat.mbox_cmd++; in lpfc_sli_issue_mbox_s3()
8443 evtctr = psli->slistat.mbox_event; in lpfc_sli_issue_mbox_s3()
8446 mbx->mbxOwner = OWN_CHIP; in lpfc_sli_issue_mbox_s3()
8448 if (psli->sli_flag & LPFC_SLI_ACTIVE) { in lpfc_sli_issue_mbox_s3()
8450 if (pmbox->in_ext_byte_len || pmbox->out_ext_byte_len) { in lpfc_sli_issue_mbox_s3()
8451 *(((uint32_t *)mbx) + pmbox->mbox_offset_word) in lpfc_sli_issue_mbox_s3()
8452 = (uint8_t *)phba->mbox_ext in lpfc_sli_issue_mbox_s3()
8453 - (uint8_t *)phba->mbox; in lpfc_sli_issue_mbox_s3()
8456 /* Copy the mailbox extension data */ in lpfc_sli_issue_mbox_s3()
8457 if (pmbox->in_ext_byte_len && pmbox->ctx_buf) { in lpfc_sli_issue_mbox_s3()
8458 lpfc_sli_pcimem_bcopy(pmbox->ctx_buf, in lpfc_sli_issue_mbox_s3()
8459 (uint8_t *)phba->mbox_ext, in lpfc_sli_issue_mbox_s3()
8460 pmbox->in_ext_byte_len); in lpfc_sli_issue_mbox_s3()
8463 lpfc_sli_pcimem_bcopy(mbx, phba->mbox, MAILBOX_CMD_SIZE); in lpfc_sli_issue_mbox_s3()
8466 if (pmbox->in_ext_byte_len || pmbox->out_ext_byte_len) in lpfc_sli_issue_mbox_s3()
8467 *(((uint32_t *)mbx) + pmbox->mbox_offset_word) in lpfc_sli_issue_mbox_s3()
8470 /* Copy the mailbox extension data */ in lpfc_sli_issue_mbox_s3()
8471 if (pmbox->in_ext_byte_len && pmbox->ctx_buf) in lpfc_sli_issue_mbox_s3()
8472 lpfc_memcpy_to_slim(phba->MBslimaddr + in lpfc_sli_issue_mbox_s3()
8474 pmbox->ctx_buf, pmbox->in_ext_byte_len); in lpfc_sli_issue_mbox_s3()
8476 if (mbx->mbxCommand == MBX_CONFIG_PORT) in lpfc_sli_issue_mbox_s3()
8478 lpfc_sli_pcimem_bcopy(mbx, phba->mbox, in lpfc_sli_issue_mbox_s3()
8483 to_slim = phba->MBslimaddr + sizeof (uint32_t); in lpfc_sli_issue_mbox_s3()
8484 lpfc_memcpy_to_slim(to_slim, &mbx->un.varWords[0], in lpfc_sli_issue_mbox_s3()
8485 MAILBOX_CMD_SIZE - sizeof (uint32_t)); in lpfc_sli_issue_mbox_s3()
8489 to_slim = phba->MBslimaddr; in lpfc_sli_issue_mbox_s3()
8493 if (mbx->mbxCommand == MBX_CONFIG_PORT) in lpfc_sli_issue_mbox_s3()
8494 /* switch over to host mailbox */ in lpfc_sli_issue_mbox_s3()
8495 psli->sli_flag |= LPFC_SLI_ACTIVE; in lpfc_sli_issue_mbox_s3()
8502 /* Set up reference to mailbox command */ in lpfc_sli_issue_mbox_s3()
8503 psli->mbox_active = pmbox; in lpfc_sli_issue_mbox_s3()
8505 writel(CA_MBATT, phba->CAregaddr); in lpfc_sli_issue_mbox_s3()
8506 readl(phba->CAregaddr); /* flush */ in lpfc_sli_issue_mbox_s3()
8511 /* Set up null reference to mailbox command */ in lpfc_sli_issue_mbox_s3()
8512 psli->mbox_active = NULL; in lpfc_sli_issue_mbox_s3()
8514 writel(CA_MBATT, phba->CAregaddr); in lpfc_sli_issue_mbox_s3()
8515 readl(phba->CAregaddr); /* flush */ in lpfc_sli_issue_mbox_s3()
8517 if (psli->sli_flag & LPFC_SLI_ACTIVE) { in lpfc_sli_issue_mbox_s3()
8519 word0 = *((uint32_t *)phba->mbox); in lpfc_sli_issue_mbox_s3()
8523 if (lpfc_readl(phba->MBslimaddr, &word0)) { in lpfc_sli_issue_mbox_s3()
8524 spin_unlock_irqrestore(&phba->hbalock, in lpfc_sli_issue_mbox_s3()
8531 if (lpfc_readl(phba->HAregaddr, &ha_copy)) { in lpfc_sli_issue_mbox_s3()
8532 spin_unlock_irqrestore(&phba->hbalock, in lpfc_sli_issue_mbox_s3()
8542 (phba->link_state > LPFC_WARM_START))) { in lpfc_sli_issue_mbox_s3()
8544 psli->sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; in lpfc_sli_issue_mbox_s3()
8545 spin_unlock_irqrestore(&phba->hbalock, in lpfc_sli_issue_mbox_s3()
8553 && (evtctr != psli->slistat.mbox_event)) in lpfc_sli_issue_mbox_s3()
8557 spin_unlock_irqrestore(&phba->hbalock, in lpfc_sli_issue_mbox_s3()
8560 spin_lock_irqsave(&phba->hbalock, drvr_flag); in lpfc_sli_issue_mbox_s3()
8563 if (psli->sli_flag & LPFC_SLI_ACTIVE) { in lpfc_sli_issue_mbox_s3()
8565 word0 = *((uint32_t *)phba->mbox); in lpfc_sli_issue_mbox_s3()
8567 if (mbx->mbxCommand == MBX_CONFIG_PORT) { in lpfc_sli_issue_mbox_s3()
8571 slimword0 = readl(phba->MBslimaddr); in lpfc_sli_issue_mbox_s3()
8574 && slimmb->mbxStatus) { in lpfc_sli_issue_mbox_s3()
8575 psli->sli_flag &= in lpfc_sli_issue_mbox_s3()
8582 word0 = readl(phba->MBslimaddr); in lpfc_sli_issue_mbox_s3()
8585 if (lpfc_readl(phba->HAregaddr, &ha_copy)) { in lpfc_sli_issue_mbox_s3()
8586 spin_unlock_irqrestore(&phba->hbalock, in lpfc_sli_issue_mbox_s3()
8592 if (psli->sli_flag & LPFC_SLI_ACTIVE) { in lpfc_sli_issue_mbox_s3()
8594 lpfc_sli_pcimem_bcopy(phba->mbox, mbx, in lpfc_sli_issue_mbox_s3()
8596 /* Copy the mailbox extension data */ in lpfc_sli_issue_mbox_s3()
8597 if (pmbox->out_ext_byte_len && pmbox->ctx_buf) { in lpfc_sli_issue_mbox_s3()
8598 lpfc_sli_pcimem_bcopy(phba->mbox_ext, in lpfc_sli_issue_mbox_s3()
8599 pmbox->ctx_buf, in lpfc_sli_issue_mbox_s3()
8600 pmbox->out_ext_byte_len); in lpfc_sli_issue_mbox_s3()
8604 lpfc_memcpy_from_slim(mbx, phba->MBslimaddr, in lpfc_sli_issue_mbox_s3()
8606 /* Copy the mailbox extension data */ in lpfc_sli_issue_mbox_s3()
8607 if (pmbox->out_ext_byte_len && pmbox->ctx_buf) { in lpfc_sli_issue_mbox_s3()
8609 pmbox->ctx_buf, in lpfc_sli_issue_mbox_s3()
8610 phba->MBslimaddr + in lpfc_sli_issue_mbox_s3()
8612 pmbox->out_ext_byte_len); in lpfc_sli_issue_mbox_s3()
8616 writel(HA_MBATT, phba->HAregaddr); in lpfc_sli_issue_mbox_s3()
8617 readl(phba->HAregaddr); /* flush */ in lpfc_sli_issue_mbox_s3()
8619 psli->sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; in lpfc_sli_issue_mbox_s3()
8620 status = mbx->mbxStatus; in lpfc_sli_issue_mbox_s3()
8623 spin_unlock_irqrestore(&phba->hbalock, drvr_flag); in lpfc_sli_issue_mbox_s3()
8628 pmbox->u.mb.mbxStatus = MBX_NOT_FINISHED; in lpfc_sli_issue_mbox_s3()
8635 * lpfc_sli4_async_mbox_block - Block posting SLI4 asynchronous mailbox command
8638 * The function blocks the posting of SLI4 asynchronous mailbox commands from
8639 * the driver internal pending mailbox queue. It will then try to wait out the
8640 * possible outstanding mailbox command before return.
8643 * 0 - the outstanding mailbox command completed; otherwise, the wait for
8644 * the outstanding mailbox command timed out.
8649 struct lpfc_sli *psli = &phba->sli; in lpfc_sli4_async_mbox_block()
8653 /* Mark the asynchronous mailbox command posting as blocked */ in lpfc_sli4_async_mbox_block()
8654 spin_lock_irq(&phba->hbalock); in lpfc_sli4_async_mbox_block()
8655 psli->sli_flag |= LPFC_SLI_ASYNC_MBX_BLK; in lpfc_sli4_async_mbox_block()
8656 /* Determine how long we might wait for the active mailbox in lpfc_sli4_async_mbox_block()
8659 if (phba->sli.mbox_active) in lpfc_sli4_async_mbox_block()
8661 phba->sli.mbox_active) * in lpfc_sli4_async_mbox_block()
8663 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_mbox_block()
8665 /* Make sure the mailbox is really active */ in lpfc_sli4_async_mbox_block()
8669 /* Wait for the outstnading mailbox command to complete */ in lpfc_sli4_async_mbox_block()
8670 while (phba->sli.mbox_active) { in lpfc_sli4_async_mbox_block()
8671 /* Check active mailbox complete status every 2ms */ in lpfc_sli4_async_mbox_block()
8680 /* Can not cleanly block async mailbox command, fails it */ in lpfc_sli4_async_mbox_block()
8682 spin_lock_irq(&phba->hbalock); in lpfc_sli4_async_mbox_block()
8683 psli->sli_flag &= ~LPFC_SLI_ASYNC_MBX_BLK; in lpfc_sli4_async_mbox_block()
8684 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_mbox_block()
8690 * lpfc_sli4_async_mbox_unblock - Block posting SLI4 async mailbox command
8693 * The function unblocks and resume posting of SLI4 asynchronous mailbox
8694 * commands from the driver internal pending mailbox queue. It makes sure
8695 * that there is no outstanding mailbox command before resuming posting
8696 * asynchronous mailbox commands. If, for any reason, there is outstanding
8697 * mailbox command, it will try to wait it out before resuming asynchronous
8698 * mailbox command posting.
8703 struct lpfc_sli *psli = &phba->sli; in lpfc_sli4_async_mbox_unblock()
8705 spin_lock_irq(&phba->hbalock); in lpfc_sli4_async_mbox_unblock()
8706 if (!(psli->sli_flag & LPFC_SLI_ASYNC_MBX_BLK)) { in lpfc_sli4_async_mbox_unblock()
8707 /* Asynchronous mailbox posting is not blocked, do nothing */ in lpfc_sli4_async_mbox_unblock()
8708 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_mbox_unblock()
8712 /* Outstanding synchronous mailbox command is guaranteed to be done, in lpfc_sli4_async_mbox_unblock()
8713 * successful or timeout, after timing-out the outstanding mailbox in lpfc_sli4_async_mbox_unblock()
8715 * mailbox command and resume in lpfc_sli4_async_mbox_unblock()
8717 psli->sli_flag &= ~LPFC_SLI_ASYNC_MBX_BLK; in lpfc_sli4_async_mbox_unblock()
8718 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_mbox_unblock()
8720 /* wake up worker thread to post asynchronous mailbox command */ in lpfc_sli4_async_mbox_unblock()
8725 * lpfc_sli4_wait_bmbx_ready - Wait for bootstrap mailbox register ready
8727 * @mboxq: Pointer to mailbox object.
8729 * The function waits for the bootstrap mailbox register ready bit from
8730 * port for twice the regular mailbox command timeout value.
8732 * 0 - no timeout on waiting for bootstrap mailbox register ready.
8733 * MBXERR_ERROR - wait for bootstrap mailbox register timed out.
8746 bmbx_reg.word0 = readl(phba->sli4_hba.BMBXregaddr); in lpfc_sli4_wait_bmbx_ready()
8759 * lpfc_sli4_post_sync_mbox - Post an SLI4 mailbox to the bootstrap mailbox
8761 * @mboxq: Pointer to mailbox object.
8763 * The function posts a mailbox to the port. The mailbox is expected
8766 * mailbox by polling for its completion.
8771 * MBX_SUCCESS - mailbox posted successfully
8781 struct lpfc_sli *psli = &phba->sli; in lpfc_sli4_post_sync_mbox()
8782 struct lpfc_mqe *mb = &mboxq->u.mqe; in lpfc_sli4_post_sync_mbox()
8787 * Only one mailbox can be active to the bootstrap mailbox region in lpfc_sli4_post_sync_mbox()
8790 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli4_post_sync_mbox()
8791 if (psli->sli_flag & LPFC_SLI_MBOX_ACTIVE) { in lpfc_sli4_post_sync_mbox()
8792 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli4_post_sync_mbox()
8794 "(%d):2532 Mailbox command x%x (x%x/x%x) " in lpfc_sli4_post_sync_mbox()
8796 mboxq->vport ? mboxq->vport->vpi : 0, in lpfc_sli4_post_sync_mbox()
8797 mboxq->u.mb.mbxCommand, in lpfc_sli4_post_sync_mbox()
8800 psli->sli_flag, MBX_POLL); in lpfc_sli4_post_sync_mbox()
8804 psli->sli_flag |= LPFC_SLI_MBOX_ACTIVE; in lpfc_sli4_post_sync_mbox()
8805 phba->sli.mbox_active = mboxq; in lpfc_sli4_post_sync_mbox()
8806 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli4_post_sync_mbox()
8814 * in the mailbox post. Then copy the caller's mailbox contents to in lpfc_sli4_post_sync_mbox()
8815 * the bmbx mailbox region. in lpfc_sli4_post_sync_mbox()
8818 memset(phba->sli4_hba.bmbx.avirt, 0, sizeof(struct lpfc_bmbx_create)); in lpfc_sli4_post_sync_mbox()
8819 lpfc_sli4_pcimem_bcopy(mb, phba->sli4_hba.bmbx.avirt, in lpfc_sli4_post_sync_mbox()
8822 /* Post the high mailbox dma address to the port and wait for ready. */ in lpfc_sli4_post_sync_mbox()
8823 dma_address = &phba->sli4_hba.bmbx.dma_address; in lpfc_sli4_post_sync_mbox()
8824 writel(dma_address->addr_hi, phba->sli4_hba.BMBXregaddr); in lpfc_sli4_post_sync_mbox()
8826 /* wait for bootstrap mbox register for hi-address write done */ in lpfc_sli4_post_sync_mbox()
8831 /* Post the low mailbox dma address to the port. */ in lpfc_sli4_post_sync_mbox()
8832 writel(dma_address->addr_lo, phba->sli4_hba.BMBXregaddr); in lpfc_sli4_post_sync_mbox()
8840 * Read the CQ to ensure the mailbox has completed. in lpfc_sli4_post_sync_mbox()
8841 * If so, update the mailbox status so that the upper layers in lpfc_sli4_post_sync_mbox()
8844 lpfc_sli4_pcimem_bcopy(phba->sli4_hba.bmbx.avirt, mb, in lpfc_sli4_post_sync_mbox()
8846 mbox_rgn = (struct lpfc_bmbx_create *) phba->sli4_hba.bmbx.avirt; in lpfc_sli4_post_sync_mbox()
8847 lpfc_sli4_pcimem_bcopy(&mbox_rgn->mcqe, &mboxq->mcqe, in lpfc_sli4_post_sync_mbox()
8849 mcqe_status = bf_get(lpfc_mcqe_status, &mbox_rgn->mcqe); in lpfc_sli4_post_sync_mbox()
8851 * When the CQE status indicates a failure and the mailbox status in lpfc_sli4_post_sync_mbox()
8852 * indicates success then copy the CQE status into the mailbox status in lpfc_sli4_post_sync_mbox()
8864 "(%d):0356 Mailbox cmd x%x (x%x/x%x) Status x%x " in lpfc_sli4_post_sync_mbox()
8867 mboxq->vport ? mboxq->vport->vpi : 0, mbx_cmnd, in lpfc_sli4_post_sync_mbox()
8871 mb->un.mb_words[0], mb->un.mb_words[1], in lpfc_sli4_post_sync_mbox()
8872 mb->un.mb_words[2], mb->un.mb_words[3], in lpfc_sli4_post_sync_mbox()
8873 mb->un.mb_words[4], mb->un.mb_words[5], in lpfc_sli4_post_sync_mbox()
8874 mb->un.mb_words[6], mb->un.mb_words[7], in lpfc_sli4_post_sync_mbox()
8875 mb->un.mb_words[8], mb->un.mb_words[9], in lpfc_sli4_post_sync_mbox()
8876 mb->un.mb_words[10], mb->un.mb_words[11], in lpfc_sli4_post_sync_mbox()
8877 mb->un.mb_words[12], mboxq->mcqe.word0, in lpfc_sli4_post_sync_mbox()
8878 mboxq->mcqe.mcqe_tag0, mboxq->mcqe.mcqe_tag1, in lpfc_sli4_post_sync_mbox()
8879 mboxq->mcqe.trailer); in lpfc_sli4_post_sync_mbox()
8882 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli4_post_sync_mbox()
8883 psli->sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; in lpfc_sli4_post_sync_mbox()
8884 phba->sli.mbox_active = NULL; in lpfc_sli4_post_sync_mbox()
8885 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli4_post_sync_mbox()
8890 * lpfc_sli_issue_mbox_s4 - Issue an SLI4 mailbox command to firmware
8892 * @mboxq: Pointer to mailbox object.
8893 * @flag: Flag indicating how the mailbox need to be processed.
8896 * a mailbox command to firmware with SLI-4 interface spec.
8898 * Return codes the caller owns the mailbox command after the return of the
8905 struct lpfc_sli *psli = &phba->sli; in lpfc_sli_issue_mbox_s4()
8909 /* dump from issue mailbox command if setup */ in lpfc_sli_issue_mbox_s4()
8910 lpfc_idiag_mbxacc_dump_issue_mbox(phba, &mboxq->u.mb); in lpfc_sli_issue_mbox_s4()
8915 "(%d):2544 Mailbox command x%x (x%x/x%x) " in lpfc_sli_issue_mbox_s4()
8917 mboxq->vport ? mboxq->vport->vpi : 0, in lpfc_sli_issue_mbox_s4()
8918 mboxq->u.mb.mbxCommand, in lpfc_sli_issue_mbox_s4()
8921 psli->sli_flag, flag); in lpfc_sli_issue_mbox_s4()
8926 if (!phba->sli4_hba.intr_enable) { in lpfc_sli_issue_mbox_s4()
8930 rc = -EIO; in lpfc_sli_issue_mbox_s4()
8933 "(%d):2541 Mailbox command x%x " in lpfc_sli_issue_mbox_s4()
8937 mboxq->vport ? mboxq->vport->vpi : 0, in lpfc_sli_issue_mbox_s4()
8938 mboxq->u.mb.mbxCommand, in lpfc_sli_issue_mbox_s4()
8943 bf_get(lpfc_mqe_status, &mboxq->u.mqe), in lpfc_sli_issue_mbox_s4()
8944 bf_get(lpfc_mcqe_status, &mboxq->mcqe), in lpfc_sli_issue_mbox_s4()
8946 &mboxq->mcqe), in lpfc_sli_issue_mbox_s4()
8947 psli->sli_flag, flag); in lpfc_sli_issue_mbox_s4()
8951 "(%d):2542 Try to issue mailbox command " in lpfc_sli_issue_mbox_s4()
8953 "mailbox command queue: x%x x%x\n", in lpfc_sli_issue_mbox_s4()
8954 mboxq->vport ? mboxq->vport->vpi : 0, in lpfc_sli_issue_mbox_s4()
8955 mboxq->u.mb.mbxCommand, in lpfc_sli_issue_mbox_s4()
8958 psli->sli_flag, flag); in lpfc_sli_issue_mbox_s4()
8959 /* Try to block the asynchronous mailbox posting */ in lpfc_sli_issue_mbox_s4()
8967 "(%d):2597 Sync Mailbox command " in lpfc_sli_issue_mbox_s4()
8971 mboxq->vport ? mboxq->vport->vpi : 0, in lpfc_sli_issue_mbox_s4()
8972 mboxq->u.mb.mbxCommand, in lpfc_sli_issue_mbox_s4()
8977 bf_get(lpfc_mqe_status, &mboxq->u.mqe), in lpfc_sli_issue_mbox_s4()
8978 bf_get(lpfc_mcqe_status, &mboxq->mcqe), in lpfc_sli_issue_mbox_s4()
8980 &mboxq->mcqe), in lpfc_sli_issue_mbox_s4()
8981 psli->sli_flag, flag); in lpfc_sli_issue_mbox_s4()
8982 /* Unblock the async mailbox posting afterward */ in lpfc_sli_issue_mbox_s4()
8988 /* Now, interrupt mode asynchronous mailbox command */ in lpfc_sli_issue_mbox_s4()
8992 "(%d):2543 Mailbox command x%x (x%x/x%x) " in lpfc_sli_issue_mbox_s4()
8994 mboxq->vport ? mboxq->vport->vpi : 0, in lpfc_sli_issue_mbox_s4()
8995 mboxq->u.mb.mbxCommand, in lpfc_sli_issue_mbox_s4()
8998 psli->sli_flag, flag); in lpfc_sli_issue_mbox_s4()
9002 /* Put the mailbox command to the driver internal FIFO */ in lpfc_sli_issue_mbox_s4()
9003 psli->slistat.mbox_busy++; in lpfc_sli_issue_mbox_s4()
9004 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli_issue_mbox_s4()
9006 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli_issue_mbox_s4()
9008 "(%d):0354 Mbox cmd issue - Enqueue Data: " in lpfc_sli_issue_mbox_s4()
9010 mboxq->vport ? mboxq->vport->vpi : 0xffffff, in lpfc_sli_issue_mbox_s4()
9011 bf_get(lpfc_mqe_command, &mboxq->u.mqe), in lpfc_sli_issue_mbox_s4()
9014 phba->pport->port_state, in lpfc_sli_issue_mbox_s4()
9015 psli->sli_flag, MBX_NOWAIT); in lpfc_sli_issue_mbox_s4()
9016 /* Wake up worker thread to transport mailbox command from head */ in lpfc_sli_issue_mbox_s4()
9026 * lpfc_sli4_post_async_mbox - Post an SLI4 mailbox command to device
9029 * This function is called by worker thread to send a mailbox command to
9036 struct lpfc_sli *psli = &phba->sli; in lpfc_sli4_post_async_mbox()
9043 /* Check interrupt mode before post async mailbox command */ in lpfc_sli4_post_async_mbox()
9044 if (unlikely(!phba->sli4_hba.intr_enable)) in lpfc_sli4_post_async_mbox()
9047 /* Check for mailbox command service token */ in lpfc_sli4_post_async_mbox()
9048 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_post_async_mbox()
9049 if (unlikely(psli->sli_flag & LPFC_SLI_ASYNC_MBX_BLK)) { in lpfc_sli4_post_async_mbox()
9050 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_post_async_mbox()
9053 if (psli->sli_flag & LPFC_SLI_MBOX_ACTIVE) { in lpfc_sli4_post_async_mbox()
9054 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_post_async_mbox()
9057 if (unlikely(phba->sli.mbox_active)) { in lpfc_sli4_post_async_mbox()
9058 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_post_async_mbox()
9060 "0384 There is pending active mailbox cmd\n"); in lpfc_sli4_post_async_mbox()
9063 /* Take the mailbox command service token */ in lpfc_sli4_post_async_mbox()
9064 psli->sli_flag |= LPFC_SLI_MBOX_ACTIVE; in lpfc_sli4_post_async_mbox()
9066 /* Get the next mailbox command from head of queue */ in lpfc_sli4_post_async_mbox()
9069 /* If no more mailbox command waiting for post, we're done */ in lpfc_sli4_post_async_mbox()
9071 psli->sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; in lpfc_sli4_post_async_mbox()
9072 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_post_async_mbox()
9075 phba->sli.mbox_active = mboxq; in lpfc_sli4_post_async_mbox()
9076 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_post_async_mbox()
9078 /* Check device readiness for posting mailbox command */ in lpfc_sli4_post_async_mbox()
9081 /* Driver clean routine will clean up pending mailbox */ in lpfc_sli4_post_async_mbox()
9085 mqe = &mboxq->u.mqe; in lpfc_sli4_post_async_mbox()
9088 /* Start timer for the mbox_tmo and log some mailbox post messages */ in lpfc_sli4_post_async_mbox()
9089 mod_timer(&psli->mbox_tmo, (jiffies + in lpfc_sli4_post_async_mbox()
9093 "(%d):0355 Mailbox cmd x%x (x%x/x%x) issue Data: " in lpfc_sli4_post_async_mbox()
9095 mboxq->vport ? mboxq->vport->vpi : 0, mbx_cmnd, in lpfc_sli4_post_async_mbox()
9098 phba->pport->port_state, psli->sli_flag); in lpfc_sli4_post_async_mbox()
9101 if (mboxq->vport) { in lpfc_sli4_post_async_mbox()
9102 lpfc_debugfs_disc_trc(mboxq->vport, in lpfc_sli4_post_async_mbox()
9105 mbx_cmnd, mqe->un.mb_words[0], in lpfc_sli4_post_async_mbox()
9106 mqe->un.mb_words[1]); in lpfc_sli4_post_async_mbox()
9108 lpfc_debugfs_disc_trc(phba->pport, in lpfc_sli4_post_async_mbox()
9111 mbx_cmnd, mqe->un.mb_words[0], in lpfc_sli4_post_async_mbox()
9112 mqe->un.mb_words[1]); in lpfc_sli4_post_async_mbox()
9115 psli->slistat.mbox_cmd++; in lpfc_sli4_post_async_mbox()
9117 /* Post the mailbox command to the port */ in lpfc_sli4_post_async_mbox()
9118 rc = lpfc_sli4_mq_put(phba->sli4_hba.mbx_wq, mqe); in lpfc_sli4_post_async_mbox()
9121 "(%d):2533 Mailbox command x%x (x%x/x%x) " in lpfc_sli4_post_async_mbox()
9123 mboxq->vport ? mboxq->vport->vpi : 0, in lpfc_sli4_post_async_mbox()
9124 mboxq->u.mb.mbxCommand, in lpfc_sli4_post_async_mbox()
9127 psli->sli_flag, MBX_NOWAIT); in lpfc_sli4_post_async_mbox()
9134 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_post_async_mbox()
9135 if (phba->sli.mbox_active) { in lpfc_sli4_post_async_mbox()
9136 mboxq->u.mb.mbxStatus = MBX_NOT_FINISHED; in lpfc_sli4_post_async_mbox()
9139 psli->sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; in lpfc_sli4_post_async_mbox()
9140 phba->sli.mbox_active = NULL; in lpfc_sli4_post_async_mbox()
9142 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_post_async_mbox()
9148 * lpfc_sli_issue_mbox - Wrapper func for issuing mailbox command
9150 * @pmbox: Pointer to mailbox object.
9151 * @flag: Flag indicating how the mailbox need to be processed.
9153 * This routine wraps the actual SLI3 or SLI4 mailbox issuing routine from
9156 * Return codes the caller owns the mailbox command after the return of the
9162 return phba->lpfc_sli_issue_mbox(phba, pmbox, flag); in lpfc_sli_issue_mbox()
9166 * lpfc_mbox_api_table_setup - Set up mbox api function jump table
9168 * @dev_grp: The HBA PCI-Device group number.
9172 * Returns: 0 - success, -ENODEV - failure.
9180 phba->lpfc_sli_issue_mbox = lpfc_sli_issue_mbox_s3; in lpfc_mbox_api_table_setup()
9181 phba->lpfc_sli_handle_slow_ring_event = in lpfc_mbox_api_table_setup()
9183 phba->lpfc_sli_hbq_to_firmware = lpfc_sli_hbq_to_firmware_s3; in lpfc_mbox_api_table_setup()
9184 phba->lpfc_sli_brdrestart = lpfc_sli_brdrestart_s3; in lpfc_mbox_api_table_setup()
9185 phba->lpfc_sli_brdready = lpfc_sli_brdready_s3; in lpfc_mbox_api_table_setup()
9188 phba->lpfc_sli_issue_mbox = lpfc_sli_issue_mbox_s4; in lpfc_mbox_api_table_setup()
9189 phba->lpfc_sli_handle_slow_ring_event = in lpfc_mbox_api_table_setup()
9191 phba->lpfc_sli_hbq_to_firmware = lpfc_sli_hbq_to_firmware_s4; in lpfc_mbox_api_table_setup()
9192 phba->lpfc_sli_brdrestart = lpfc_sli_brdrestart_s4; in lpfc_mbox_api_table_setup()
9193 phba->lpfc_sli_brdready = lpfc_sli_brdready_s4; in lpfc_mbox_api_table_setup()
9197 "1420 Invalid HBA PCI-device group: 0x%x\n", in lpfc_mbox_api_table_setup()
9199 return -ENODEV; in lpfc_mbox_api_table_setup()
9206 * __lpfc_sli_ringtx_put - Add an iocb to the txq
9220 if (phba->sli_rev == LPFC_SLI_REV4) in __lpfc_sli_ringtx_put()
9221 lockdep_assert_held(&pring->ring_lock); in __lpfc_sli_ringtx_put()
9223 lockdep_assert_held(&phba->hbalock); in __lpfc_sli_ringtx_put()
9225 list_add_tail(&piocb->list, &pring->txq); in __lpfc_sli_ringtx_put()
9229 * lpfc_sli_next_iocb - Get the next iocb in the txq
9251 lockdep_assert_held(&phba->hbalock); in lpfc_sli_next_iocb()
9263 * __lpfc_sli_issue_iocb_s3 - SLI3 device lockless ver of lpfc_sli_issue_iocb
9270 * an iocb command to an HBA with SLI-3 interface spec. If the PCI slot is
9290 struct lpfc_sli_ring *pring = &phba->sli.sli3_ring[ring_number]; in __lpfc_sli_issue_iocb_s3()
9292 lockdep_assert_held(&phba->hbalock); in __lpfc_sli_issue_iocb_s3()
9294 if (piocb->iocb_cmpl && (!piocb->vport) && in __lpfc_sli_issue_iocb_s3()
9295 (piocb->iocb.ulpCommand != CMD_ABORT_XRI_CN) && in __lpfc_sli_issue_iocb_s3()
9296 (piocb->iocb.ulpCommand != CMD_CLOSE_XRI_CN)) { in __lpfc_sli_issue_iocb_s3()
9299 piocb->iocb.ulpCommand); in __lpfc_sli_issue_iocb_s3()
9306 if (unlikely(pci_channel_offline(phba->pcidev))) in __lpfc_sli_issue_iocb_s3()
9310 if (unlikely(phba->hba_flag & DEFER_ERATT)) in __lpfc_sli_issue_iocb_s3()
9316 if (unlikely(phba->link_state < LPFC_LINK_DOWN)) in __lpfc_sli_issue_iocb_s3()
9323 if (unlikely(pring->flag & LPFC_STOP_IOCB_EVENT)) in __lpfc_sli_issue_iocb_s3()
9326 if (unlikely(phba->link_state == LPFC_LINK_DOWN)) { in __lpfc_sli_issue_iocb_s3()
9331 switch (piocb->iocb.ulpCommand) { in __lpfc_sli_issue_iocb_s3()
9334 if (!(phba->sli.sli_flag & LPFC_MENLO_MAINT) || in __lpfc_sli_issue_iocb_s3()
9335 (piocb->iocb.un.genreq64.w5.hcsw.Rctl != in __lpfc_sli_issue_iocb_s3()
9337 (piocb->iocb.un.genreq64.w5.hcsw.Type != in __lpfc_sli_issue_iocb_s3()
9348 if (piocb->iocb_cmpl) in __lpfc_sli_issue_iocb_s3()
9349 piocb->iocb_cmpl = NULL; in __lpfc_sli_issue_iocb_s3()
9363 } else if (unlikely(pring->ringno == LPFC_FCP_RING && in __lpfc_sli_issue_iocb_s3()
9364 !(phba->sli.sli_flag & LPFC_PROCESS_LA))) { in __lpfc_sli_issue_iocb_s3()
9383 pring->stats.iocb_cmd_delay++; in __lpfc_sli_issue_iocb_s3()
9396 * lpfc_sli4_bpl2sgl - Convert the bpl/bde to a sgl.
9430 sgl = (struct sli4_sge *)sglq->sgl; in lpfc_sli4_bpl2sgl()
9431 icmd = &piocbq->iocb; in lpfc_sli4_bpl2sgl()
9432 if (icmd->ulpCommand == CMD_XMIT_BLS_RSP64_CX) in lpfc_sli4_bpl2sgl()
9433 return sglq->sli4_xritag; in lpfc_sli4_bpl2sgl()
9434 if (icmd->un.genreq64.bdl.bdeFlags == BUFF_TYPE_BLP_64) { in lpfc_sli4_bpl2sgl()
9435 numBdes = icmd->un.genreq64.bdl.bdeSize / in lpfc_sli4_bpl2sgl()
9441 if (piocbq->context3) in lpfc_sli4_bpl2sgl()
9442 dmabuf = (struct lpfc_dmabuf *)piocbq->context3; in lpfc_sli4_bpl2sgl()
9446 bpl = (struct ulp_bde64 *)dmabuf->virt; in lpfc_sli4_bpl2sgl()
9452 sgl->addr_hi = bpl->addrHigh; in lpfc_sli4_bpl2sgl()
9453 sgl->addr_lo = bpl->addrLow; in lpfc_sli4_bpl2sgl()
9455 sgl->word2 = le32_to_cpu(sgl->word2); in lpfc_sli4_bpl2sgl()
9463 bde.tus.w = le32_to_cpu(bpl->tus.w); in lpfc_sli4_bpl2sgl()
9464 sgl->sge_len = cpu_to_le32(bde.tus.f.bdeSize); in lpfc_sli4_bpl2sgl()
9469 if (piocbq->iocb.ulpCommand == CMD_GEN_REQUEST64_CR) { in lpfc_sli4_bpl2sgl()
9471 if (bpl->tus.f.bdeFlags == BUFF_TYPE_BDE_64I) in lpfc_sli4_bpl2sgl()
9481 sgl->word2 = cpu_to_le32(sgl->word2); in lpfc_sli4_bpl2sgl()
9485 } else if (icmd->un.genreq64.bdl.bdeFlags == BUFF_TYPE_BDE_64) { in lpfc_sli4_bpl2sgl()
9490 sgl->addr_hi = in lpfc_sli4_bpl2sgl()
9491 cpu_to_le32(icmd->un.genreq64.bdl.addrHigh); in lpfc_sli4_bpl2sgl()
9492 sgl->addr_lo = in lpfc_sli4_bpl2sgl()
9493 cpu_to_le32(icmd->un.genreq64.bdl.addrLow); in lpfc_sli4_bpl2sgl()
9494 sgl->word2 = le32_to_cpu(sgl->word2); in lpfc_sli4_bpl2sgl()
9496 sgl->word2 = cpu_to_le32(sgl->word2); in lpfc_sli4_bpl2sgl()
9497 sgl->sge_len = in lpfc_sli4_bpl2sgl()
9498 cpu_to_le32(icmd->un.genreq64.bdl.bdeSize); in lpfc_sli4_bpl2sgl()
9500 return sglq->sli4_xritag; in lpfc_sli4_bpl2sgl()
9504 * lpfc_sli_iocb2wqe - Convert the IOCB to a work queue entry.
9538 fip = phba->hba_flag & HBA_FIP_SUPPORT; in lpfc_sli4_iocb2wqe()
9540 if (iocbq->iocb_flag & LPFC_IO_FCP) in lpfc_sli4_iocb2wqe()
9542 else if (fip && (iocbq->iocb_flag & LPFC_FIP_ELS_ID_MASK)) in lpfc_sli4_iocb2wqe()
9547 if (phba->fcp_embed_io) in lpfc_sli4_iocb2wqe()
9550 memcpy(wqe, &iocbq->iocb, sizeof(union lpfc_wqe)); in lpfc_sli4_iocb2wqe()
9552 wqe->generic.wqe_com.word7 = 0; in lpfc_sli4_iocb2wqe()
9553 wqe->generic.wqe_com.word10 = 0; in lpfc_sli4_iocb2wqe()
9555 abort_tag = (uint32_t) iocbq->iotag; in lpfc_sli4_iocb2wqe()
9556 xritag = iocbq->sli4_xritag; in lpfc_sli4_iocb2wqe()
9557 /* words0-2 bpl convert bde */ in lpfc_sli4_iocb2wqe()
9558 if (iocbq->iocb.un.genreq64.bdl.bdeFlags == BUFF_TYPE_BLP_64) { in lpfc_sli4_iocb2wqe()
9559 numBdes = iocbq->iocb.un.genreq64.bdl.bdeSize / in lpfc_sli4_iocb2wqe()
9562 ((struct lpfc_dmabuf *)iocbq->context3)->virt; in lpfc_sli4_iocb2wqe()
9567 wqe->generic.bde.addrHigh = le32_to_cpu(bpl->addrHigh); in lpfc_sli4_iocb2wqe()
9568 wqe->generic.bde.addrLow = le32_to_cpu(bpl->addrLow); in lpfc_sli4_iocb2wqe()
9572 wqe->generic.bde.tus.w = le32_to_cpu(bpl->tus.w); in lpfc_sli4_iocb2wqe()
9573 xmit_len = wqe->generic.bde.tus.f.bdeSize; in lpfc_sli4_iocb2wqe()
9580 xmit_len = iocbq->iocb.un.fcpi64.bdl.bdeSize; in lpfc_sli4_iocb2wqe()
9582 iocbq->iocb.ulpIoTag = iocbq->iotag; in lpfc_sli4_iocb2wqe()
9583 cmnd = iocbq->iocb.ulpCommand; in lpfc_sli4_iocb2wqe()
9585 switch (iocbq->iocb.ulpCommand) { in lpfc_sli4_iocb2wqe()
9587 if (iocbq->iocb_flag & LPFC_IO_LIBDFC) in lpfc_sli4_iocb2wqe()
9588 ndlp = iocbq->context_un.ndlp; in lpfc_sli4_iocb2wqe()
9590 ndlp = (struct lpfc_nodelist *)iocbq->context1; in lpfc_sli4_iocb2wqe()
9591 if (!iocbq->iocb.ulpLe) { in lpfc_sli4_iocb2wqe()
9595 iocbq->iocb.ulpCommand); in lpfc_sli4_iocb2wqe()
9599 wqe->els_req.payload_len = xmit_len; in lpfc_sli4_iocb2wqe()
9601 bf_set(wqe_tmo, &wqe->els_req.wqe_com, in lpfc_sli4_iocb2wqe()
9602 iocbq->iocb.ulpTimeout); in lpfc_sli4_iocb2wqe()
9604 bf_set(els_req64_vf, &wqe->els_req, 0); in lpfc_sli4_iocb2wqe()
9606 bf_set(els_req64_vfid, &wqe->els_req, 0); in lpfc_sli4_iocb2wqe()
9607 ct = ((iocbq->iocb.ulpCt_h << 1) | iocbq->iocb.ulpCt_l); in lpfc_sli4_iocb2wqe()
9608 bf_set(wqe_ctxt_tag, &wqe->els_req.wqe_com, in lpfc_sli4_iocb2wqe()
9609 iocbq->iocb.ulpContext); in lpfc_sli4_iocb2wqe()
9610 bf_set(wqe_ct, &wqe->els_req.wqe_com, ct); in lpfc_sli4_iocb2wqe()
9611 bf_set(wqe_pu, &wqe->els_req.wqe_com, 0); in lpfc_sli4_iocb2wqe()
9614 els_id = ((iocbq->iocb_flag & LPFC_FIP_ELS_ID_MASK) in lpfc_sli4_iocb2wqe()
9617 iocbq->context2)->virt); in lpfc_sli4_iocb2wqe()
9619 &phba->sli4_hba.sli_intf); in lpfc_sli4_iocb2wqe()
9628 bf_set(els_req64_sp, &wqe->els_req, 1); in lpfc_sli4_iocb2wqe()
9629 bf_set(els_req64_sid, &wqe->els_req, in lpfc_sli4_iocb2wqe()
9630 iocbq->vport->fc_myDID); in lpfc_sli4_iocb2wqe()
9632 !(phba->fc_topology == in lpfc_sli4_iocb2wqe()
9634 bf_set(els_req64_sid, &wqe->els_req, 0); in lpfc_sli4_iocb2wqe()
9635 bf_set(wqe_ct, &wqe->els_req.wqe_com, 1); in lpfc_sli4_iocb2wqe()
9636 bf_set(wqe_ctxt_tag, &wqe->els_req.wqe_com, in lpfc_sli4_iocb2wqe()
9637 phba->vpi_ids[iocbq->vport->vpi]); in lpfc_sli4_iocb2wqe()
9638 } else if (pcmd && iocbq->context1) { in lpfc_sli4_iocb2wqe()
9639 bf_set(wqe_ct, &wqe->els_req.wqe_com, 0); in lpfc_sli4_iocb2wqe()
9640 bf_set(wqe_ctxt_tag, &wqe->els_req.wqe_com, in lpfc_sli4_iocb2wqe()
9641 phba->sli4_hba.rpi_ids[ndlp->nlp_rpi]); in lpfc_sli4_iocb2wqe()
9644 bf_set(wqe_temp_rpi, &wqe->els_req.wqe_com, in lpfc_sli4_iocb2wqe()
9645 phba->sli4_hba.rpi_ids[ndlp->nlp_rpi]); in lpfc_sli4_iocb2wqe()
9646 bf_set(wqe_els_id, &wqe->els_req.wqe_com, els_id); in lpfc_sli4_iocb2wqe()
9647 bf_set(wqe_dbde, &wqe->els_req.wqe_com, 1); in lpfc_sli4_iocb2wqe()
9648 bf_set(wqe_iod, &wqe->els_req.wqe_com, LPFC_WQE_IOD_READ); in lpfc_sli4_iocb2wqe()
9649 bf_set(wqe_qosd, &wqe->els_req.wqe_com, 1); in lpfc_sli4_iocb2wqe()
9650 bf_set(wqe_lenloc, &wqe->els_req.wqe_com, LPFC_WQE_LENLOC_NONE); in lpfc_sli4_iocb2wqe()
9651 bf_set(wqe_ebde_cnt, &wqe->els_req.wqe_com, 0); in lpfc_sli4_iocb2wqe()
9652 wqe->els_req.max_response_payload_len = total_len - xmit_len; in lpfc_sli4_iocb2wqe()
9655 bf_set(wqe_ctxt_tag, &wqe->xmit_sequence.wqe_com, in lpfc_sli4_iocb2wqe()
9656 iocbq->iocb.un.ulpWord[3]); in lpfc_sli4_iocb2wqe()
9657 bf_set(wqe_rcvoxid, &wqe->xmit_sequence.wqe_com, in lpfc_sli4_iocb2wqe()
9658 iocbq->iocb.unsli3.rcvsli3.ox_id); in lpfc_sli4_iocb2wqe()
9662 if (phba->link_flag & LS_LOOPBACK_MODE) in lpfc_sli4_iocb2wqe()
9663 bf_set(wqe_xo, &wqe->xmit_sequence.wge_ctl, 1); in lpfc_sli4_iocb2wqe()
9667 wqe->xmit_sequence.rsvd3 = 0; in lpfc_sli4_iocb2wqe()
9670 bf_set(wqe_pu, &wqe->xmit_sequence.wqe_com, 0); in lpfc_sli4_iocb2wqe()
9671 bf_set(wqe_dbde, &wqe->xmit_sequence.wqe_com, 1); in lpfc_sli4_iocb2wqe()
9672 bf_set(wqe_iod, &wqe->xmit_sequence.wqe_com, in lpfc_sli4_iocb2wqe()
9674 bf_set(wqe_lenloc, &wqe->xmit_sequence.wqe_com, in lpfc_sli4_iocb2wqe()
9676 bf_set(wqe_ebde_cnt, &wqe->xmit_sequence.wqe_com, 0); in lpfc_sli4_iocb2wqe()
9677 wqe->xmit_sequence.xmit_len = xmit_len; in lpfc_sli4_iocb2wqe()
9682 wqe->xmit_bcast64.seq_payload_len = xmit_len; in lpfc_sli4_iocb2wqe()
9686 bf_set(wqe_ct, &wqe->xmit_bcast64.wqe_com, in lpfc_sli4_iocb2wqe()
9687 ((iocbq->iocb.ulpCt_h << 1) | iocbq->iocb.ulpCt_l)); in lpfc_sli4_iocb2wqe()
9688 bf_set(wqe_dbde, &wqe->xmit_bcast64.wqe_com, 1); in lpfc_sli4_iocb2wqe()
9689 bf_set(wqe_iod, &wqe->xmit_bcast64.wqe_com, LPFC_WQE_IOD_WRITE); in lpfc_sli4_iocb2wqe()
9690 bf_set(wqe_lenloc, &wqe->xmit_bcast64.wqe_com, in lpfc_sli4_iocb2wqe()
9692 bf_set(wqe_ebde_cnt, &wqe->xmit_bcast64.wqe_com, 0); in lpfc_sli4_iocb2wqe()
9698 bf_set(payload_offset_len, &wqe->fcp_iwrite, in lpfc_sli4_iocb2wqe()
9700 bf_set(cmd_buff_len, &wqe->fcp_iwrite, in lpfc_sli4_iocb2wqe()
9704 bf_set(wqe_erp, &wqe->fcp_iwrite.wqe_com, in lpfc_sli4_iocb2wqe()
9705 iocbq->iocb.ulpFCP2Rcvy); in lpfc_sli4_iocb2wqe()
9706 bf_set(wqe_lnk, &wqe->fcp_iwrite.wqe_com, iocbq->iocb.ulpXS); in lpfc_sli4_iocb2wqe()
9708 bf_set(wqe_iod, &wqe->fcp_iwrite.wqe_com, LPFC_WQE_IOD_WRITE); in lpfc_sli4_iocb2wqe()
9709 bf_set(wqe_lenloc, &wqe->fcp_iwrite.wqe_com, in lpfc_sli4_iocb2wqe()
9711 bf_set(wqe_pu, &wqe->fcp_iwrite.wqe_com, iocbq->iocb.ulpPU); in lpfc_sli4_iocb2wqe()
9712 bf_set(wqe_dbde, &wqe->fcp_iwrite.wqe_com, 1); in lpfc_sli4_iocb2wqe()
9713 if (iocbq->iocb_flag & LPFC_IO_OAS) { in lpfc_sli4_iocb2wqe()
9714 bf_set(wqe_oas, &wqe->fcp_iwrite.wqe_com, 1); in lpfc_sli4_iocb2wqe()
9715 bf_set(wqe_ccpe, &wqe->fcp_iwrite.wqe_com, 1); in lpfc_sli4_iocb2wqe()
9716 if (iocbq->priority) { in lpfc_sli4_iocb2wqe()
9717 bf_set(wqe_ccp, &wqe->fcp_iwrite.wqe_com, in lpfc_sli4_iocb2wqe()
9718 (iocbq->priority << 1)); in lpfc_sli4_iocb2wqe()
9720 bf_set(wqe_ccp, &wqe->fcp_iwrite.wqe_com, in lpfc_sli4_iocb2wqe()
9721 (phba->cfg_XLanePriority << 1)); in lpfc_sli4_iocb2wqe()
9727 if (phba->cfg_enable_pbde) in lpfc_sli4_iocb2wqe()
9728 bf_set(wqe_pbde, &wqe->fcp_iwrite.wqe_com, 1); in lpfc_sli4_iocb2wqe()
9730 bf_set(wqe_pbde, &wqe->fcp_iwrite.wqe_com, 0); in lpfc_sli4_iocb2wqe()
9732 if (phba->fcp_embed_io) { in lpfc_sli4_iocb2wqe()
9740 lpfc_cmd = iocbq->context1; in lpfc_sli4_iocb2wqe()
9741 sgl = (struct sli4_sge *)lpfc_cmd->dma_sgl; in lpfc_sli4_iocb2wqe()
9742 fcp_cmnd = lpfc_cmd->fcp_cmnd; in lpfc_sli4_iocb2wqe()
9744 /* Word 0-2 - FCP_CMND */ in lpfc_sli4_iocb2wqe()
9745 wqe->generic.bde.tus.f.bdeFlags = in lpfc_sli4_iocb2wqe()
9747 wqe->generic.bde.tus.f.bdeSize = sgl->sge_len; in lpfc_sli4_iocb2wqe()
9748 wqe->generic.bde.addrHigh = 0; in lpfc_sli4_iocb2wqe()
9749 wqe->generic.bde.addrLow = 88; /* Word 22 */ in lpfc_sli4_iocb2wqe()
9751 bf_set(wqe_wqes, &wqe->fcp_iwrite.wqe_com, 1); in lpfc_sli4_iocb2wqe()
9752 bf_set(wqe_dbde, &wqe->fcp_iwrite.wqe_com, 0); in lpfc_sli4_iocb2wqe()
9754 /* Word 22-29 FCP CMND Payload */ in lpfc_sli4_iocb2wqe()
9755 ptr = &wqe->words[22]; in lpfc_sli4_iocb2wqe()
9762 bf_set(payload_offset_len, &wqe->fcp_iread, in lpfc_sli4_iocb2wqe()
9764 bf_set(cmd_buff_len, &wqe->fcp_iread, in lpfc_sli4_iocb2wqe()
9768 bf_set(wqe_erp, &wqe->fcp_iread.wqe_com, in lpfc_sli4_iocb2wqe()
9769 iocbq->iocb.ulpFCP2Rcvy); in lpfc_sli4_iocb2wqe()
9770 bf_set(wqe_lnk, &wqe->fcp_iread.wqe_com, iocbq->iocb.ulpXS); in lpfc_sli4_iocb2wqe()
9772 bf_set(wqe_iod, &wqe->fcp_iread.wqe_com, LPFC_WQE_IOD_READ); in lpfc_sli4_iocb2wqe()
9773 bf_set(wqe_lenloc, &wqe->fcp_iread.wqe_com, in lpfc_sli4_iocb2wqe()
9775 bf_set(wqe_pu, &wqe->fcp_iread.wqe_com, iocbq->iocb.ulpPU); in lpfc_sli4_iocb2wqe()
9776 bf_set(wqe_dbde, &wqe->fcp_iread.wqe_com, 1); in lpfc_sli4_iocb2wqe()
9777 if (iocbq->iocb_flag & LPFC_IO_OAS) { in lpfc_sli4_iocb2wqe()
9778 bf_set(wqe_oas, &wqe->fcp_iread.wqe_com, 1); in lpfc_sli4_iocb2wqe()
9779 bf_set(wqe_ccpe, &wqe->fcp_iread.wqe_com, 1); in lpfc_sli4_iocb2wqe()
9780 if (iocbq->priority) { in lpfc_sli4_iocb2wqe()
9781 bf_set(wqe_ccp, &wqe->fcp_iread.wqe_com, in lpfc_sli4_iocb2wqe()
9782 (iocbq->priority << 1)); in lpfc_sli4_iocb2wqe()
9784 bf_set(wqe_ccp, &wqe->fcp_iread.wqe_com, in lpfc_sli4_iocb2wqe()
9785 (phba->cfg_XLanePriority << 1)); in lpfc_sli4_iocb2wqe()
9791 if (phba->cfg_enable_pbde) in lpfc_sli4_iocb2wqe()
9792 bf_set(wqe_pbde, &wqe->fcp_iread.wqe_com, 1); in lpfc_sli4_iocb2wqe()
9794 bf_set(wqe_pbde, &wqe->fcp_iread.wqe_com, 0); in lpfc_sli4_iocb2wqe()
9796 if (phba->fcp_embed_io) { in lpfc_sli4_iocb2wqe()
9804 lpfc_cmd = iocbq->context1; in lpfc_sli4_iocb2wqe()
9805 sgl = (struct sli4_sge *)lpfc_cmd->dma_sgl; in lpfc_sli4_iocb2wqe()
9806 fcp_cmnd = lpfc_cmd->fcp_cmnd; in lpfc_sli4_iocb2wqe()
9808 /* Word 0-2 - FCP_CMND */ in lpfc_sli4_iocb2wqe()
9809 wqe->generic.bde.tus.f.bdeFlags = in lpfc_sli4_iocb2wqe()
9811 wqe->generic.bde.tus.f.bdeSize = sgl->sge_len; in lpfc_sli4_iocb2wqe()
9812 wqe->generic.bde.addrHigh = 0; in lpfc_sli4_iocb2wqe()
9813 wqe->generic.bde.addrLow = 88; /* Word 22 */ in lpfc_sli4_iocb2wqe()
9815 bf_set(wqe_wqes, &wqe->fcp_iread.wqe_com, 1); in lpfc_sli4_iocb2wqe()
9816 bf_set(wqe_dbde, &wqe->fcp_iread.wqe_com, 0); in lpfc_sli4_iocb2wqe()
9818 /* Word 22-29 FCP CMND Payload */ in lpfc_sli4_iocb2wqe()
9819 ptr = &wqe->words[22]; in lpfc_sli4_iocb2wqe()
9826 bf_set(payload_offset_len, &wqe->fcp_icmd, in lpfc_sli4_iocb2wqe()
9828 bf_set(cmd_buff_len, &wqe->fcp_icmd, in lpfc_sli4_iocb2wqe()
9831 bf_set(wqe_pu, &wqe->fcp_icmd.wqe_com, 0); in lpfc_sli4_iocb2wqe()
9833 bf_set(wqe_dbde, &wqe->fcp_icmd.wqe_com, 1); in lpfc_sli4_iocb2wqe()
9834 bf_set(wqe_iod, &wqe->fcp_icmd.wqe_com, LPFC_WQE_IOD_WRITE); in lpfc_sli4_iocb2wqe()
9835 bf_set(wqe_qosd, &wqe->fcp_icmd.wqe_com, 1); in lpfc_sli4_iocb2wqe()
9836 bf_set(wqe_lenloc, &wqe->fcp_icmd.wqe_com, in lpfc_sli4_iocb2wqe()
9838 bf_set(wqe_erp, &wqe->fcp_icmd.wqe_com, in lpfc_sli4_iocb2wqe()
9839 iocbq->iocb.ulpFCP2Rcvy); in lpfc_sli4_iocb2wqe()
9840 if (iocbq->iocb_flag & LPFC_IO_OAS) { in lpfc_sli4_iocb2wqe()
9841 bf_set(wqe_oas, &wqe->fcp_icmd.wqe_com, 1); in lpfc_sli4_iocb2wqe()
9842 bf_set(wqe_ccpe, &wqe->fcp_icmd.wqe_com, 1); in lpfc_sli4_iocb2wqe()
9843 if (iocbq->priority) { in lpfc_sli4_iocb2wqe()
9844 bf_set(wqe_ccp, &wqe->fcp_icmd.wqe_com, in lpfc_sli4_iocb2wqe()
9845 (iocbq->priority << 1)); in lpfc_sli4_iocb2wqe()
9847 bf_set(wqe_ccp, &wqe->fcp_icmd.wqe_com, in lpfc_sli4_iocb2wqe()
9848 (phba->cfg_XLanePriority << 1)); in lpfc_sli4_iocb2wqe()
9853 if (phba->fcp_embed_io) { in lpfc_sli4_iocb2wqe()
9861 lpfc_cmd = iocbq->context1; in lpfc_sli4_iocb2wqe()
9862 sgl = (struct sli4_sge *)lpfc_cmd->dma_sgl; in lpfc_sli4_iocb2wqe()
9863 fcp_cmnd = lpfc_cmd->fcp_cmnd; in lpfc_sli4_iocb2wqe()
9865 /* Word 0-2 - FCP_CMND */ in lpfc_sli4_iocb2wqe()
9866 wqe->generic.bde.tus.f.bdeFlags = in lpfc_sli4_iocb2wqe()
9868 wqe->generic.bde.tus.f.bdeSize = sgl->sge_len; in lpfc_sli4_iocb2wqe()
9869 wqe->generic.bde.addrHigh = 0; in lpfc_sli4_iocb2wqe()
9870 wqe->generic.bde.addrLow = 88; /* Word 22 */ in lpfc_sli4_iocb2wqe()
9872 bf_set(wqe_wqes, &wqe->fcp_icmd.wqe_com, 1); in lpfc_sli4_iocb2wqe()
9873 bf_set(wqe_dbde, &wqe->fcp_icmd.wqe_com, 0); in lpfc_sli4_iocb2wqe()
9875 /* Word 22-29 FCP CMND Payload */ in lpfc_sli4_iocb2wqe()
9876 ptr = &wqe->words[22]; in lpfc_sli4_iocb2wqe()
9885 numBdes = iocbq->iocb.un.genreq64.bdl.bdeSize / in lpfc_sli4_iocb2wqe()
9894 wqe->gen_req.request_payload_len = xmit_len; in lpfc_sli4_iocb2wqe()
9898 if (iocbq->iocb.ulpCt_h || iocbq->iocb.ulpCt_l) { in lpfc_sli4_iocb2wqe()
9899 ct = ((iocbq->iocb.ulpCt_h << 1) | iocbq->iocb.ulpCt_l); in lpfc_sli4_iocb2wqe()
9902 ct, iocbq->iocb.ulpCommand); in lpfc_sli4_iocb2wqe()
9905 bf_set(wqe_ct, &wqe->gen_req.wqe_com, 0); in lpfc_sli4_iocb2wqe()
9906 bf_set(wqe_tmo, &wqe->gen_req.wqe_com, iocbq->iocb.ulpTimeout); in lpfc_sli4_iocb2wqe()
9907 bf_set(wqe_pu, &wqe->gen_req.wqe_com, iocbq->iocb.ulpPU); in lpfc_sli4_iocb2wqe()
9908 bf_set(wqe_dbde, &wqe->gen_req.wqe_com, 1); in lpfc_sli4_iocb2wqe()
9909 bf_set(wqe_iod, &wqe->gen_req.wqe_com, LPFC_WQE_IOD_READ); in lpfc_sli4_iocb2wqe()
9910 bf_set(wqe_qosd, &wqe->gen_req.wqe_com, 1); in lpfc_sli4_iocb2wqe()
9911 bf_set(wqe_lenloc, &wqe->gen_req.wqe_com, LPFC_WQE_LENLOC_NONE); in lpfc_sli4_iocb2wqe()
9912 bf_set(wqe_ebde_cnt, &wqe->gen_req.wqe_com, 0); in lpfc_sli4_iocb2wqe()
9913 wqe->gen_req.max_response_payload_len = total_len - xmit_len; in lpfc_sli4_iocb2wqe()
9917 ndlp = (struct lpfc_nodelist *)iocbq->context1; in lpfc_sli4_iocb2wqe()
9918 /* words0-2 BDE memcpy */ in lpfc_sli4_iocb2wqe()
9920 wqe->xmit_els_rsp.response_payload_len = xmit_len; in lpfc_sli4_iocb2wqe()
9922 wqe->xmit_els_rsp.word4 = 0; in lpfc_sli4_iocb2wqe()
9924 bf_set(wqe_els_did, &wqe->xmit_els_rsp.wqe_dest, in lpfc_sli4_iocb2wqe()
9925 iocbq->iocb.un.xseq64.xmit_els_remoteID); in lpfc_sli4_iocb2wqe()
9928 &phba->sli4_hba.sli_intf); in lpfc_sli4_iocb2wqe()
9930 if (iocbq->vport->fc_flag & FC_PT2PT) { in lpfc_sli4_iocb2wqe()
9931 bf_set(els_rsp64_sp, &wqe->xmit_els_rsp, 1); in lpfc_sli4_iocb2wqe()
9932 bf_set(els_rsp64_sid, &wqe->xmit_els_rsp, in lpfc_sli4_iocb2wqe()
9933 iocbq->vport->fc_myDID); in lpfc_sli4_iocb2wqe()
9934 if (iocbq->vport->fc_myDID == Fabric_DID) { in lpfc_sli4_iocb2wqe()
9936 &wqe->xmit_els_rsp.wqe_dest, 0); in lpfc_sli4_iocb2wqe()
9940 bf_set(wqe_ct, &wqe->xmit_els_rsp.wqe_com, in lpfc_sli4_iocb2wqe()
9941 ((iocbq->iocb.ulpCt_h << 1) | iocbq->iocb.ulpCt_l)); in lpfc_sli4_iocb2wqe()
9942 bf_set(wqe_pu, &wqe->xmit_els_rsp.wqe_com, iocbq->iocb.ulpPU); in lpfc_sli4_iocb2wqe()
9943 bf_set(wqe_rcvoxid, &wqe->xmit_els_rsp.wqe_com, in lpfc_sli4_iocb2wqe()
9944 iocbq->iocb.unsli3.rcvsli3.ox_id); in lpfc_sli4_iocb2wqe()
9945 if (!iocbq->iocb.ulpCt_h && iocbq->iocb.ulpCt_l) in lpfc_sli4_iocb2wqe()
9946 bf_set(wqe_ctxt_tag, &wqe->xmit_els_rsp.wqe_com, in lpfc_sli4_iocb2wqe()
9947 phba->vpi_ids[iocbq->vport->vpi]); in lpfc_sli4_iocb2wqe()
9948 bf_set(wqe_dbde, &wqe->xmit_els_rsp.wqe_com, 1); in lpfc_sli4_iocb2wqe()
9949 bf_set(wqe_iod, &wqe->xmit_els_rsp.wqe_com, LPFC_WQE_IOD_WRITE); in lpfc_sli4_iocb2wqe()
9950 bf_set(wqe_qosd, &wqe->xmit_els_rsp.wqe_com, 1); in lpfc_sli4_iocb2wqe()
9951 bf_set(wqe_lenloc, &wqe->xmit_els_rsp.wqe_com, in lpfc_sli4_iocb2wqe()
9953 bf_set(wqe_ebde_cnt, &wqe->xmit_els_rsp.wqe_com, 0); in lpfc_sli4_iocb2wqe()
9954 bf_set(wqe_rsp_temp_rpi, &wqe->xmit_els_rsp, in lpfc_sli4_iocb2wqe()
9955 phba->sli4_hba.rpi_ids[ndlp->nlp_rpi]); in lpfc_sli4_iocb2wqe()
9957 iocbq->context2)->virt); in lpfc_sli4_iocb2wqe()
9958 if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) { in lpfc_sli4_iocb2wqe()
9959 bf_set(els_rsp64_sp, &wqe->xmit_els_rsp, 1); in lpfc_sli4_iocb2wqe()
9960 bf_set(els_rsp64_sid, &wqe->xmit_els_rsp, in lpfc_sli4_iocb2wqe()
9961 iocbq->vport->fc_myDID); in lpfc_sli4_iocb2wqe()
9962 bf_set(wqe_ct, &wqe->xmit_els_rsp.wqe_com, 1); in lpfc_sli4_iocb2wqe()
9963 bf_set(wqe_ctxt_tag, &wqe->xmit_els_rsp.wqe_com, in lpfc_sli4_iocb2wqe()
9964 phba->vpi_ids[phba->pport->vpi]); in lpfc_sli4_iocb2wqe()
9971 /* words 0-2 memcpy should be 0 rserved */ in lpfc_sli4_iocb2wqe()
9973 abrt_iotag = iocbq->iocb.un.acxri.abortContextTag; in lpfc_sli4_iocb2wqe()
9974 if (abrt_iotag != 0 && abrt_iotag <= phba->sli.last_iotag) { in lpfc_sli4_iocb2wqe()
9975 abrtiocbq = phba->sli.iocbq_lookup[abrt_iotag]; in lpfc_sli4_iocb2wqe()
9976 fip = abrtiocbq->iocb_flag & LPFC_FIP_ELS_ID_MASK; in lpfc_sli4_iocb2wqe()
9980 if ((iocbq->iocb.ulpCommand == CMD_CLOSE_XRI_CN) || fip) in lpfc_sli4_iocb2wqe()
9986 bf_set(abort_cmd_ia, &wqe->abort_cmd, 1); in lpfc_sli4_iocb2wqe()
9988 bf_set(abort_cmd_ia, &wqe->abort_cmd, 0); in lpfc_sli4_iocb2wqe()
9989 bf_set(abort_cmd_criteria, &wqe->abort_cmd, T_XRI_TAG); in lpfc_sli4_iocb2wqe()
9991 wqe->abort_cmd.rsrvd5 = 0; in lpfc_sli4_iocb2wqe()
9992 bf_set(wqe_ct, &wqe->abort_cmd.wqe_com, in lpfc_sli4_iocb2wqe()
9993 ((iocbq->iocb.ulpCt_h << 1) | iocbq->iocb.ulpCt_l)); in lpfc_sli4_iocb2wqe()
9994 abort_tag = iocbq->iocb.un.acxri.abortIoTag; in lpfc_sli4_iocb2wqe()
9999 bf_set(wqe_cmnd, &wqe->abort_cmd.wqe_com, CMD_ABORT_XRI_CX); in lpfc_sli4_iocb2wqe()
10000 bf_set(wqe_qosd, &wqe->abort_cmd.wqe_com, 1); in lpfc_sli4_iocb2wqe()
10001 bf_set(wqe_lenloc, &wqe->abort_cmd.wqe_com, in lpfc_sli4_iocb2wqe()
10008 ndlp = (struct lpfc_nodelist *)iocbq->context1; in lpfc_sli4_iocb2wqe()
10010 * we re-construct this WQE here based on information in in lpfc_sli4_iocb2wqe()
10015 bf_set(xmit_bls_rsp64_oxid, &wqe->xmit_bls_rsp, in lpfc_sli4_iocb2wqe()
10016 bf_get(lpfc_abts_oxid, &iocbq->iocb.un.bls_rsp)); in lpfc_sli4_iocb2wqe()
10017 if (bf_get(lpfc_abts_orig, &iocbq->iocb.un.bls_rsp) == in lpfc_sli4_iocb2wqe()
10023 bf_set(xmit_bls_rsp64_rxid, &wqe->xmit_bls_rsp, in lpfc_sli4_iocb2wqe()
10024 iocbq->sli4_xritag); in lpfc_sli4_iocb2wqe()
10030 bf_set(xmit_bls_rsp64_rxid, &wqe->xmit_bls_rsp, in lpfc_sli4_iocb2wqe()
10031 bf_get(lpfc_abts_rxid, &iocbq->iocb.un.bls_rsp)); in lpfc_sli4_iocb2wqe()
10033 bf_set(xmit_bls_rsp64_seqcnthi, &wqe->xmit_bls_rsp, 0xffff); in lpfc_sli4_iocb2wqe()
10034 bf_set(wqe_xmit_bls_pt, &wqe->xmit_bls_rsp.wqe_dest, 0x1); in lpfc_sli4_iocb2wqe()
10037 bf_set(wqe_els_did, &wqe->xmit_bls_rsp.wqe_dest, in lpfc_sli4_iocb2wqe()
10038 ndlp->nlp_DID); in lpfc_sli4_iocb2wqe()
10039 bf_set(xmit_bls_rsp64_temprpi, &wqe->xmit_bls_rsp, in lpfc_sli4_iocb2wqe()
10040 iocbq->iocb.ulpContext); in lpfc_sli4_iocb2wqe()
10041 bf_set(wqe_ct, &wqe->xmit_bls_rsp.wqe_com, 1); in lpfc_sli4_iocb2wqe()
10042 bf_set(wqe_ctxt_tag, &wqe->xmit_bls_rsp.wqe_com, in lpfc_sli4_iocb2wqe()
10043 phba->vpi_ids[phba->pport->vpi]); in lpfc_sli4_iocb2wqe()
10044 bf_set(wqe_qosd, &wqe->xmit_bls_rsp.wqe_com, 1); in lpfc_sli4_iocb2wqe()
10045 bf_set(wqe_lenloc, &wqe->xmit_bls_rsp.wqe_com, in lpfc_sli4_iocb2wqe()
10047 /* Overwrite the pre-set comnd type with OTHER_COMMAND */ in lpfc_sli4_iocb2wqe()
10049 if (iocbq->iocb.un.xseq64.w5.hcsw.Rctl == FC_RCTL_BA_RJT) { in lpfc_sli4_iocb2wqe()
10050 bf_set(xmit_bls_rsp64_rjt_vspec, &wqe->xmit_bls_rsp, in lpfc_sli4_iocb2wqe()
10051 bf_get(lpfc_vndr_code, &iocbq->iocb.un.bls_rsp)); in lpfc_sli4_iocb2wqe()
10052 bf_set(xmit_bls_rsp64_rjt_expc, &wqe->xmit_bls_rsp, in lpfc_sli4_iocb2wqe()
10053 bf_get(lpfc_rsn_expln, &iocbq->iocb.un.bls_rsp)); in lpfc_sli4_iocb2wqe()
10054 bf_set(xmit_bls_rsp64_rjt_rsnc, &wqe->xmit_bls_rsp, in lpfc_sli4_iocb2wqe()
10055 bf_get(lpfc_rsn_code, &iocbq->iocb.un.bls_rsp)); in lpfc_sli4_iocb2wqe()
10060 bf_set(wqe_cmnd, &wqe->generic.wqe_com, CMD_SEND_FRAME); in lpfc_sli4_iocb2wqe()
10061 bf_set(wqe_sof, &wqe->generic.wqe_com, 0x2E); /* SOF byte */ in lpfc_sli4_iocb2wqe()
10062 bf_set(wqe_eof, &wqe->generic.wqe_com, 0x41); /* EOF byte */ in lpfc_sli4_iocb2wqe()
10063 bf_set(wqe_lenloc, &wqe->generic.wqe_com, 1); in lpfc_sli4_iocb2wqe()
10064 bf_set(wqe_xbl, &wqe->generic.wqe_com, 1); in lpfc_sli4_iocb2wqe()
10065 bf_set(wqe_dbde, &wqe->generic.wqe_com, 1); in lpfc_sli4_iocb2wqe()
10066 bf_set(wqe_xc, &wqe->generic.wqe_com, 1); in lpfc_sli4_iocb2wqe()
10067 bf_set(wqe_cmd_type, &wqe->generic.wqe_com, 0xA); in lpfc_sli4_iocb2wqe()
10068 bf_set(wqe_cqid, &wqe->generic.wqe_com, LPFC_WQE_CQ_ID_DEFAULT); in lpfc_sli4_iocb2wqe()
10069 bf_set(wqe_xri_tag, &wqe->generic.wqe_com, xritag); in lpfc_sli4_iocb2wqe()
10070 bf_set(wqe_reqtag, &wqe->generic.wqe_com, iocbq->iotag); in lpfc_sli4_iocb2wqe()
10075 case CMD_FCP_TSEND64_CX: /* Target mode send xfer-ready */ in lpfc_sli4_iocb2wqe()
10081 iocbq->iocb.ulpCommand); in lpfc_sli4_iocb2wqe()
10086 if (iocbq->iocb_flag & LPFC_IO_DIF_PASS) in lpfc_sli4_iocb2wqe()
10087 bf_set(wqe_dif, &wqe->generic.wqe_com, LPFC_WQE_DIF_PASSTHRU); in lpfc_sli4_iocb2wqe()
10088 else if (iocbq->iocb_flag & LPFC_IO_DIF_STRIP) in lpfc_sli4_iocb2wqe()
10089 bf_set(wqe_dif, &wqe->generic.wqe_com, LPFC_WQE_DIF_STRIP); in lpfc_sli4_iocb2wqe()
10090 else if (iocbq->iocb_flag & LPFC_IO_DIF_INSERT) in lpfc_sli4_iocb2wqe()
10091 bf_set(wqe_dif, &wqe->generic.wqe_com, LPFC_WQE_DIF_INSERT); in lpfc_sli4_iocb2wqe()
10092 iocbq->iocb_flag &= ~(LPFC_IO_DIF_PASS | LPFC_IO_DIF_STRIP | in lpfc_sli4_iocb2wqe()
10094 bf_set(wqe_xri_tag, &wqe->generic.wqe_com, xritag); in lpfc_sli4_iocb2wqe()
10095 bf_set(wqe_reqtag, &wqe->generic.wqe_com, iocbq->iotag); in lpfc_sli4_iocb2wqe()
10096 wqe->generic.wqe_com.abort_tag = abort_tag; in lpfc_sli4_iocb2wqe()
10097 bf_set(wqe_cmd_type, &wqe->generic.wqe_com, command_type); in lpfc_sli4_iocb2wqe()
10098 bf_set(wqe_cmnd, &wqe->generic.wqe_com, cmnd); in lpfc_sli4_iocb2wqe()
10099 bf_set(wqe_class, &wqe->generic.wqe_com, iocbq->iocb.ulpClass); in lpfc_sli4_iocb2wqe()
10100 bf_set(wqe_cqid, &wqe->generic.wqe_com, LPFC_WQE_CQ_ID_DEFAULT); in lpfc_sli4_iocb2wqe()
10105 * __lpfc_sli_issue_iocb_s4 - SLI4 device lockless ver of lpfc_sli_issue_iocb
10112 * an iocb command to an HBA with SLI-4 interface spec.
10128 if ((piocb->iocb_flag & LPFC_IO_FCP) || in __lpfc_sli_issue_iocb_s4()
10129 (piocb->iocb_flag & LPFC_USE_FCPWQIDX)) { in __lpfc_sli_issue_iocb_s4()
10130 wq = phba->sli4_hba.hdwq[piocb->hba_wqidx].io_wq; in __lpfc_sli_issue_iocb_s4()
10132 wq = phba->sli4_hba.els_wq; in __lpfc_sli_issue_iocb_s4()
10136 pring = wq->pring; in __lpfc_sli_issue_iocb_s4()
10142 lockdep_assert_held(&pring->ring_lock); in __lpfc_sli_issue_iocb_s4()
10144 if (piocb->sli4_xritag == NO_XRI) { in __lpfc_sli_issue_iocb_s4()
10145 if (piocb->iocb.ulpCommand == CMD_ABORT_XRI_CN || in __lpfc_sli_issue_iocb_s4()
10146 piocb->iocb.ulpCommand == CMD_CLOSE_XRI_CN) in __lpfc_sli_issue_iocb_s4()
10149 if (!list_empty(&pring->txq)) { in __lpfc_sli_issue_iocb_s4()
10170 } else if (piocb->iocb_flag & LPFC_IO_FCP) in __lpfc_sli_issue_iocb_s4()
10178 sglq = __lpfc_get_active_sglq(phba, piocb->sli4_lxritag); in __lpfc_sli_issue_iocb_s4()
10184 piocb->sli4_lxritag = sglq->sli4_lxritag; in __lpfc_sli_issue_iocb_s4()
10185 piocb->sli4_xritag = sglq->sli4_xritag; in __lpfc_sli_issue_iocb_s4()
10201 * __lpfc_sli_issue_iocb - Wrapper func of lockless version for issuing iocb
10207 * IOCB_ERROR - Error
10208 * IOCB_SUCCESS - Success
10209 * IOCB_BUSY - Busy
10215 return phba->__lpfc_sli_issue_iocb(phba, ring_number, piocb, flag); in __lpfc_sli_issue_iocb()
10219 * lpfc_sli_api_table_setup - Set up sli api function jump table
10221 * @dev_grp: The HBA PCI-Device group number.
10225 * Returns: 0 - success, -ENODEV - failure.
10233 phba->__lpfc_sli_issue_iocb = __lpfc_sli_issue_iocb_s3; in lpfc_sli_api_table_setup()
10234 phba->__lpfc_sli_release_iocbq = __lpfc_sli_release_iocbq_s3; in lpfc_sli_api_table_setup()
10237 phba->__lpfc_sli_issue_iocb = __lpfc_sli_issue_iocb_s4; in lpfc_sli_api_table_setup()
10238 phba->__lpfc_sli_release_iocbq = __lpfc_sli_release_iocbq_s4; in lpfc_sli_api_table_setup()
10242 "1419 Invalid HBA PCI-device group: 0x%x\n", in lpfc_sli_api_table_setup()
10244 return -ENODEV; in lpfc_sli_api_table_setup()
10247 phba->lpfc_get_iocb_from_iocbq = lpfc_get_iocb_from_iocbq; in lpfc_sli_api_table_setup()
10252 * lpfc_sli4_calc_ring - Calculates which ring to use
10266 if (piocb->iocb_flag & (LPFC_IO_FCP | LPFC_USE_FCPWQIDX)) { in lpfc_sli4_calc_ring()
10267 if (unlikely(!phba->sli4_hba.hdwq)) in lpfc_sli4_calc_ring()
10273 if (!(piocb->iocb_flag & LPFC_USE_FCPWQIDX)) { in lpfc_sli4_calc_ring()
10274 lpfc_cmd = (struct lpfc_io_buf *)piocb->context1; in lpfc_sli4_calc_ring()
10275 piocb->hba_wqidx = lpfc_cmd->hdwq_no; in lpfc_sli4_calc_ring()
10277 return phba->sli4_hba.hdwq[piocb->hba_wqidx].io_wq->pring; in lpfc_sli4_calc_ring()
10279 if (unlikely(!phba->sli4_hba.els_wq)) in lpfc_sli4_calc_ring()
10281 piocb->hba_wqidx = 0; in lpfc_sli4_calc_ring()
10282 return phba->sli4_hba.els_wq->pring; in lpfc_sli4_calc_ring()
10287 * lpfc_sli_issue_iocb - Wrapper function for __lpfc_sli_issue_iocb
10308 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_sli_issue_iocb()
10309 eq = phba->sli4_hba.hdwq[piocb->hba_wqidx].hba_eq; in lpfc_sli_issue_iocb()
10315 spin_lock_irqsave(&pring->ring_lock, iflags); in lpfc_sli_issue_iocb()
10317 spin_unlock_irqrestore(&pring->ring_lock, iflags); in lpfc_sli_issue_iocb()
10322 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli_issue_iocb()
10324 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli_issue_iocb()
10330 * lpfc_extra_ring_setup - Extra ring setup function
10346 psli = &phba->sli; in lpfc_extra_ring_setup()
10351 pring = &psli->sli3_ring[LPFC_FCP_RING]; in lpfc_extra_ring_setup()
10352 pring->sli.sli3.numCiocb -= SLI2_IOCB_CMD_R1XTRA_ENTRIES; in lpfc_extra_ring_setup()
10353 pring->sli.sli3.numRiocb -= SLI2_IOCB_RSP_R1XTRA_ENTRIES; in lpfc_extra_ring_setup()
10354 pring->sli.sli3.numCiocb -= SLI2_IOCB_CMD_R3XTRA_ENTRIES; in lpfc_extra_ring_setup()
10355 pring->sli.sli3.numRiocb -= SLI2_IOCB_RSP_R3XTRA_ENTRIES; in lpfc_extra_ring_setup()
10358 pring = &psli->sli3_ring[LPFC_EXTRA_RING]; in lpfc_extra_ring_setup()
10360 pring->sli.sli3.numCiocb += SLI2_IOCB_CMD_R1XTRA_ENTRIES; in lpfc_extra_ring_setup()
10361 pring->sli.sli3.numRiocb += SLI2_IOCB_RSP_R1XTRA_ENTRIES; in lpfc_extra_ring_setup()
10362 pring->sli.sli3.numCiocb += SLI2_IOCB_CMD_R3XTRA_ENTRIES; in lpfc_extra_ring_setup()
10363 pring->sli.sli3.numRiocb += SLI2_IOCB_RSP_R3XTRA_ENTRIES; in lpfc_extra_ring_setup()
10366 pring->iotag_max = 4096; in lpfc_extra_ring_setup()
10367 pring->num_mask = 1; in lpfc_extra_ring_setup()
10368 pring->prt[0].profile = 0; /* Mask 0 */ in lpfc_extra_ring_setup()
10369 pring->prt[0].rctl = phba->cfg_multi_ring_rctl; in lpfc_extra_ring_setup()
10370 pring->prt[0].type = phba->cfg_multi_ring_type; in lpfc_extra_ring_setup()
10371 pring->prt[0].lpfc_sli_rcv_unsol_event = NULL; in lpfc_extra_ring_setup()
10380 struct lpfc_work_evt *evtp = &ndlp->recovery_evt; in lpfc_sli_post_recovery_event()
10382 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli_post_recovery_event()
10383 if (!list_empty(&evtp->evt_listp)) { in lpfc_sli_post_recovery_event()
10384 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli_post_recovery_event()
10389 evtp->evt_arg1 = lpfc_nlp_get(ndlp); in lpfc_sli_post_recovery_event()
10390 if (!evtp->evt_arg1) { in lpfc_sli_post_recovery_event()
10391 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli_post_recovery_event()
10394 evtp->evt = LPFC_EVT_RECOVER_PORT; in lpfc_sli_post_recovery_event()
10395 list_add_tail(&evtp->evt_listp, &phba->work_list); in lpfc_sli_post_recovery_event()
10396 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli_post_recovery_event()
10401 /* lpfc_sli_abts_err_handler - handle a failed ABTS request from an SLI3 port.
10421 /* The rpi in the ulpContext is vport-sensitive. */ in lpfc_sli_abts_err_handler()
10422 vpi = iocbq->iocb.un.asyncstat.sub_ctxt_tag; in lpfc_sli_abts_err_handler()
10423 rpi = iocbq->iocb.ulpContext; in lpfc_sli_abts_err_handler()
10428 vpi, rpi, iocbq->iocb.ulpStatus); in lpfc_sli_abts_err_handler()
10437 if (iocbq->iocb.ulpStatus == IOSTAT_LOCAL_REJECT) in lpfc_sli_abts_err_handler()
10445 iocbq->iocb.ulpContext, iocbq->iocb.ulpStatus, in lpfc_sli_abts_err_handler()
10449 /* lpfc_sli4_abts_err_handler - handle a failed ABTS request from an SLI4 port.
10476 ndlp->vport->vpi, phba->sli4_hba.rpi_ids[ndlp->nlp_rpi], in lpfc_sli4_abts_err_handler()
10479 axri->parameter); in lpfc_sli4_abts_err_handler()
10486 ext_status = axri->parameter & IOERR_PARAM_MASK; in lpfc_sli4_abts_err_handler()
10493 * lpfc_sli_async_event_handler - ASYNC iocb handler function
10515 icmd = &iocbq->iocb; in lpfc_sli_async_event_handler()
10516 evt_code = icmd->un.asyncstat.evt_code; in lpfc_sli_async_event_handler()
10521 temp_event_data.data = (uint32_t) icmd->ulpContext; in lpfc_sli_async_event_handler()
10528 (uint32_t) icmd->ulpContext); in lpfc_sli_async_event_handler()
10534 (uint32_t) icmd->ulpContext); in lpfc_sli_async_event_handler()
10538 shost = lpfc_shost_from_vport(phba->pport); in lpfc_sli_async_event_handler()
10555 pring->ringno, icmd->un.asyncstat.evt_code, in lpfc_sli_async_event_handler()
10567 * lpfc_sli4_setup - SLI ring setup function
10582 pring = phba->sli4_hba.els_wq->pring; in lpfc_sli4_setup()
10583 pring->num_mask = LPFC_MAX_RING_MASK; in lpfc_sli4_setup()
10584 pring->prt[0].profile = 0; /* Mask 0 */ in lpfc_sli4_setup()
10585 pring->prt[0].rctl = FC_RCTL_ELS_REQ; in lpfc_sli4_setup()
10586 pring->prt[0].type = FC_TYPE_ELS; in lpfc_sli4_setup()
10587 pring->prt[0].lpfc_sli_rcv_unsol_event = in lpfc_sli4_setup()
10589 pring->prt[1].profile = 0; /* Mask 1 */ in lpfc_sli4_setup()
10590 pring->prt[1].rctl = FC_RCTL_ELS_REP; in lpfc_sli4_setup()
10591 pring->prt[1].type = FC_TYPE_ELS; in lpfc_sli4_setup()
10592 pring->prt[1].lpfc_sli_rcv_unsol_event = in lpfc_sli4_setup()
10594 pring->prt[2].profile = 0; /* Mask 2 */ in lpfc_sli4_setup()
10596 pring->prt[2].rctl = FC_RCTL_DD_UNSOL_CTL; in lpfc_sli4_setup()
10598 pring->prt[2].type = FC_TYPE_CT; in lpfc_sli4_setup()
10599 pring->prt[2].lpfc_sli_rcv_unsol_event = in lpfc_sli4_setup()
10601 pring->prt[3].profile = 0; /* Mask 3 */ in lpfc_sli4_setup()
10603 pring->prt[3].rctl = FC_RCTL_DD_SOL_CTL; in lpfc_sli4_setup()
10605 pring->prt[3].type = FC_TYPE_CT; in lpfc_sli4_setup()
10606 pring->prt[3].lpfc_sli_rcv_unsol_event = in lpfc_sli4_setup()
10612 * lpfc_sli_setup - SLI ring setup function
10626 struct lpfc_sli *psli = &phba->sli; in lpfc_sli_setup()
10629 psli->num_rings = MAX_SLI3_CONFIGURED_RINGS; in lpfc_sli_setup()
10630 psli->sli_flag = 0; in lpfc_sli_setup()
10632 psli->iocbq_lookup = NULL; in lpfc_sli_setup()
10633 psli->iocbq_lookup_len = 0; in lpfc_sli_setup()
10634 psli->last_iotag = 0; in lpfc_sli_setup()
10636 for (i = 0; i < psli->num_rings; i++) { in lpfc_sli_setup()
10637 pring = &psli->sli3_ring[i]; in lpfc_sli_setup()
10639 case LPFC_FCP_RING: /* ring 0 - FCP */ in lpfc_sli_setup()
10641 pring->sli.sli3.numCiocb = SLI2_IOCB_CMD_R0_ENTRIES; in lpfc_sli_setup()
10642 pring->sli.sli3.numRiocb = SLI2_IOCB_RSP_R0_ENTRIES; in lpfc_sli_setup()
10643 pring->sli.sli3.numCiocb += in lpfc_sli_setup()
10645 pring->sli.sli3.numRiocb += in lpfc_sli_setup()
10647 pring->sli.sli3.numCiocb += in lpfc_sli_setup()
10649 pring->sli.sli3.numRiocb += in lpfc_sli_setup()
10651 pring->sli.sli3.sizeCiocb = (phba->sli_rev == 3) ? in lpfc_sli_setup()
10654 pring->sli.sli3.sizeRiocb = (phba->sli_rev == 3) ? in lpfc_sli_setup()
10657 pring->iotag_ctr = 0; in lpfc_sli_setup()
10658 pring->iotag_max = in lpfc_sli_setup()
10659 (phba->cfg_hba_queue_depth * 2); in lpfc_sli_setup()
10660 pring->fast_iotag = pring->iotag_max; in lpfc_sli_setup()
10661 pring->num_mask = 0; in lpfc_sli_setup()
10663 case LPFC_EXTRA_RING: /* ring 1 - EXTRA */ in lpfc_sli_setup()
10665 pring->sli.sli3.numCiocb = SLI2_IOCB_CMD_R1_ENTRIES; in lpfc_sli_setup()
10666 pring->sli.sli3.numRiocb = SLI2_IOCB_RSP_R1_ENTRIES; in lpfc_sli_setup()
10667 pring->sli.sli3.sizeCiocb = (phba->sli_rev == 3) ? in lpfc_sli_setup()
10670 pring->sli.sli3.sizeRiocb = (phba->sli_rev == 3) ? in lpfc_sli_setup()
10673 pring->iotag_max = phba->cfg_hba_queue_depth; in lpfc_sli_setup()
10674 pring->num_mask = 0; in lpfc_sli_setup()
10676 case LPFC_ELS_RING: /* ring 2 - ELS / CT */ in lpfc_sli_setup()
10678 pring->sli.sli3.numCiocb = SLI2_IOCB_CMD_R2_ENTRIES; in lpfc_sli_setup()
10679 pring->sli.sli3.numRiocb = SLI2_IOCB_RSP_R2_ENTRIES; in lpfc_sli_setup()
10680 pring->sli.sli3.sizeCiocb = (phba->sli_rev == 3) ? in lpfc_sli_setup()
10683 pring->sli.sli3.sizeRiocb = (phba->sli_rev == 3) ? in lpfc_sli_setup()
10686 pring->fast_iotag = 0; in lpfc_sli_setup()
10687 pring->iotag_ctr = 0; in lpfc_sli_setup()
10688 pring->iotag_max = 4096; in lpfc_sli_setup()
10689 pring->lpfc_sli_rcv_async_status = in lpfc_sli_setup()
10691 pring->num_mask = LPFC_MAX_RING_MASK; in lpfc_sli_setup()
10692 pring->prt[0].profile = 0; /* Mask 0 */ in lpfc_sli_setup()
10693 pring->prt[0].rctl = FC_RCTL_ELS_REQ; in lpfc_sli_setup()
10694 pring->prt[0].type = FC_TYPE_ELS; in lpfc_sli_setup()
10695 pring->prt[0].lpfc_sli_rcv_unsol_event = in lpfc_sli_setup()
10697 pring->prt[1].profile = 0; /* Mask 1 */ in lpfc_sli_setup()
10698 pring->prt[1].rctl = FC_RCTL_ELS_REP; in lpfc_sli_setup()
10699 pring->prt[1].type = FC_TYPE_ELS; in lpfc_sli_setup()
10700 pring->prt[1].lpfc_sli_rcv_unsol_event = in lpfc_sli_setup()
10702 pring->prt[2].profile = 0; /* Mask 2 */ in lpfc_sli_setup()
10704 pring->prt[2].rctl = FC_RCTL_DD_UNSOL_CTL; in lpfc_sli_setup()
10706 pring->prt[2].type = FC_TYPE_CT; in lpfc_sli_setup()
10707 pring->prt[2].lpfc_sli_rcv_unsol_event = in lpfc_sli_setup()
10709 pring->prt[3].profile = 0; /* Mask 3 */ in lpfc_sli_setup()
10711 pring->prt[3].rctl = FC_RCTL_DD_SOL_CTL; in lpfc_sli_setup()
10713 pring->prt[3].type = FC_TYPE_CT; in lpfc_sli_setup()
10714 pring->prt[3].lpfc_sli_rcv_unsol_event = in lpfc_sli_setup()
10718 totiocbsize += (pring->sli.sli3.numCiocb * in lpfc_sli_setup()
10719 pring->sli.sli3.sizeCiocb) + in lpfc_sli_setup()
10720 (pring->sli.sli3.numRiocb * pring->sli.sli3.sizeRiocb); in lpfc_sli_setup()
10726 phba->brd_no, totiocbsize, in lpfc_sli_setup()
10729 if (phba->cfg_multi_ring_support == 2) in lpfc_sli_setup()
10736 * lpfc_sli4_queue_init - Queue initialization function
10739 * lpfc_sli4_queue_init sets up mailbox queues and iocb queues for each
10753 psli = &phba->sli; in lpfc_sli4_queue_init()
10754 spin_lock_irq(&phba->hbalock); in lpfc_sli4_queue_init()
10755 INIT_LIST_HEAD(&psli->mboxq); in lpfc_sli4_queue_init()
10756 INIT_LIST_HEAD(&psli->mboxq_cmpl); in lpfc_sli4_queue_init()
10758 for (i = 0; i < phba->cfg_hdw_queue; i++) { in lpfc_sli4_queue_init()
10759 pring = phba->sli4_hba.hdwq[i].io_wq->pring; in lpfc_sli4_queue_init()
10760 pring->flag = 0; in lpfc_sli4_queue_init()
10761 pring->ringno = LPFC_FCP_RING; in lpfc_sli4_queue_init()
10762 pring->txcmplq_cnt = 0; in lpfc_sli4_queue_init()
10763 INIT_LIST_HEAD(&pring->txq); in lpfc_sli4_queue_init()
10764 INIT_LIST_HEAD(&pring->txcmplq); in lpfc_sli4_queue_init()
10765 INIT_LIST_HEAD(&pring->iocb_continueq); in lpfc_sli4_queue_init()
10766 spin_lock_init(&pring->ring_lock); in lpfc_sli4_queue_init()
10768 pring = phba->sli4_hba.els_wq->pring; in lpfc_sli4_queue_init()
10769 pring->flag = 0; in lpfc_sli4_queue_init()
10770 pring->ringno = LPFC_ELS_RING; in lpfc_sli4_queue_init()
10771 pring->txcmplq_cnt = 0; in lpfc_sli4_queue_init()
10772 INIT_LIST_HEAD(&pring->txq); in lpfc_sli4_queue_init()
10773 INIT_LIST_HEAD(&pring->txcmplq); in lpfc_sli4_queue_init()
10774 INIT_LIST_HEAD(&pring->iocb_continueq); in lpfc_sli4_queue_init()
10775 spin_lock_init(&pring->ring_lock); in lpfc_sli4_queue_init()
10777 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_queue_init()
10778 pring = phba->sli4_hba.nvmels_wq->pring; in lpfc_sli4_queue_init()
10779 pring->flag = 0; in lpfc_sli4_queue_init()
10780 pring->ringno = LPFC_ELS_RING; in lpfc_sli4_queue_init()
10781 pring->txcmplq_cnt = 0; in lpfc_sli4_queue_init()
10782 INIT_LIST_HEAD(&pring->txq); in lpfc_sli4_queue_init()
10783 INIT_LIST_HEAD(&pring->txcmplq); in lpfc_sli4_queue_init()
10784 INIT_LIST_HEAD(&pring->iocb_continueq); in lpfc_sli4_queue_init()
10785 spin_lock_init(&pring->ring_lock); in lpfc_sli4_queue_init()
10788 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_queue_init()
10792 * lpfc_sli_queue_init - Queue initialization function
10795 * lpfc_sli_queue_init sets up mailbox queues and iocb queues for each
10809 psli = &phba->sli; in lpfc_sli_queue_init()
10810 spin_lock_irq(&phba->hbalock); in lpfc_sli_queue_init()
10811 INIT_LIST_HEAD(&psli->mboxq); in lpfc_sli_queue_init()
10812 INIT_LIST_HEAD(&psli->mboxq_cmpl); in lpfc_sli_queue_init()
10814 for (i = 0; i < psli->num_rings; i++) { in lpfc_sli_queue_init()
10815 pring = &psli->sli3_ring[i]; in lpfc_sli_queue_init()
10816 pring->ringno = i; in lpfc_sli_queue_init()
10817 pring->sli.sli3.next_cmdidx = 0; in lpfc_sli_queue_init()
10818 pring->sli.sli3.local_getidx = 0; in lpfc_sli_queue_init()
10819 pring->sli.sli3.cmdidx = 0; in lpfc_sli_queue_init()
10820 INIT_LIST_HEAD(&pring->iocb_continueq); in lpfc_sli_queue_init()
10821 INIT_LIST_HEAD(&pring->iocb_continue_saveq); in lpfc_sli_queue_init()
10822 INIT_LIST_HEAD(&pring->postbufq); in lpfc_sli_queue_init()
10823 pring->flag = 0; in lpfc_sli_queue_init()
10824 INIT_LIST_HEAD(&pring->txq); in lpfc_sli_queue_init()
10825 INIT_LIST_HEAD(&pring->txcmplq); in lpfc_sli_queue_init()
10826 spin_lock_init(&pring->ring_lock); in lpfc_sli_queue_init()
10828 spin_unlock_irq(&phba->hbalock); in lpfc_sli_queue_init()
10832 * lpfc_sli_mbox_sys_flush - Flush mailbox command sub-system
10835 * This routine flushes the mailbox command subsystem. It will unconditionally
10836 * flush all the mailbox commands in the three possible stages in the mailbox
10837 * command sub-system: pending mailbox command queue; the outstanding mailbox
10838 * command; and completed mailbox command queue. It is caller's responsibility
10839 * to make sure that the driver is in the proper state to flush the mailbox
10840 * command sub-system. Namely, the posting of mailbox commands into the
10841 * pending mailbox command queue from the various clients must be stopped;
10843 * mailbox command (such as in EEH or ERATT conditions) or the outstanding
10844 * mailbox command has been completed.
10850 struct lpfc_sli *psli = &phba->sli; in lpfc_sli_mbox_sys_flush()
10854 /* Disable softirqs, including timers from obtaining phba->hbalock */ in lpfc_sli_mbox_sys_flush()
10857 /* Flush all the mailbox commands in the mbox system */ in lpfc_sli_mbox_sys_flush()
10858 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_mbox_sys_flush()
10860 /* The pending mailbox command queue */ in lpfc_sli_mbox_sys_flush()
10861 list_splice_init(&phba->sli.mboxq, &completions); in lpfc_sli_mbox_sys_flush()
10862 /* The outstanding active mailbox command */ in lpfc_sli_mbox_sys_flush()
10863 if (psli->mbox_active) { in lpfc_sli_mbox_sys_flush()
10864 list_add_tail(&psli->mbox_active->list, &completions); in lpfc_sli_mbox_sys_flush()
10865 psli->mbox_active = NULL; in lpfc_sli_mbox_sys_flush()
10866 psli->sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; in lpfc_sli_mbox_sys_flush()
10868 /* The completed mailbox command queue */ in lpfc_sli_mbox_sys_flush()
10869 list_splice_init(&phba->sli.mboxq_cmpl, &completions); in lpfc_sli_mbox_sys_flush()
10870 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_mbox_sys_flush()
10872 /* Enable softirqs again, done with phba->hbalock */ in lpfc_sli_mbox_sys_flush()
10875 /* Return all flushed mailbox commands with MBX_NOT_FINISHED status */ in lpfc_sli_mbox_sys_flush()
10878 pmb->u.mb.mbxStatus = MBX_NOT_FINISHED; in lpfc_sli_mbox_sys_flush()
10879 if (pmb->mbox_cmpl) in lpfc_sli_mbox_sys_flush()
10880 pmb->mbox_cmpl(phba, pmb); in lpfc_sli_mbox_sys_flush()
10885 * lpfc_sli_host_down - Vport cleanup function
10892 * - Free discovery resources associated with this virtual
10894 * - Free iocbs associated with this virtual port in
10896 * - Send abort for all iocb commands associated with this
10905 struct lpfc_hba *phba = vport->phba; in lpfc_sli_host_down()
10906 struct lpfc_sli *psli = &phba->sli; in lpfc_sli_host_down()
10916 spin_lock_irqsave(&phba->hbalock, flags); in lpfc_sli_host_down()
10923 if (phba->sli_rev != LPFC_SLI_REV4) { in lpfc_sli_host_down()
10924 for (i = 0; i < psli->num_rings; i++) { in lpfc_sli_host_down()
10925 pring = &psli->sli3_ring[i]; in lpfc_sli_host_down()
10926 prev_pring_flag = pring->flag; in lpfc_sli_host_down()
10928 if (pring->ringno == LPFC_ELS_RING) { in lpfc_sli_host_down()
10929 pring->flag |= LPFC_DEFERRED_RING_EVENT; in lpfc_sli_host_down()
10931 set_bit(LPFC_DATA_READY, &phba->data_flags); in lpfc_sli_host_down()
10934 &pring->txq, list) { in lpfc_sli_host_down()
10935 if (iocb->vport != vport) in lpfc_sli_host_down()
10937 list_move_tail(&iocb->list, &completions); in lpfc_sli_host_down()
10940 &pring->txcmplq, list) { in lpfc_sli_host_down()
10941 if (iocb->vport != vport) in lpfc_sli_host_down()
10945 pring->flag = prev_pring_flag; in lpfc_sli_host_down()
10948 list_for_each_entry(qp, &phba->sli4_hba.lpfc_wq_list, wq_list) { in lpfc_sli_host_down()
10949 pring = qp->pring; in lpfc_sli_host_down()
10952 if (pring == phba->sli4_hba.els_wq->pring) { in lpfc_sli_host_down()
10953 pring->flag |= LPFC_DEFERRED_RING_EVENT; in lpfc_sli_host_down()
10955 set_bit(LPFC_DATA_READY, &phba->data_flags); in lpfc_sli_host_down()
10957 prev_pring_flag = pring->flag; in lpfc_sli_host_down()
10958 spin_lock(&pring->ring_lock); in lpfc_sli_host_down()
10960 &pring->txq, list) { in lpfc_sli_host_down()
10961 if (iocb->vport != vport) in lpfc_sli_host_down()
10963 list_move_tail(&iocb->list, &completions); in lpfc_sli_host_down()
10965 spin_unlock(&pring->ring_lock); in lpfc_sli_host_down()
10967 &pring->txcmplq, list) { in lpfc_sli_host_down()
10968 if (iocb->vport != vport) in lpfc_sli_host_down()
10972 pring->flag = prev_pring_flag; in lpfc_sli_host_down()
10975 spin_unlock_irqrestore(&phba->hbalock, flags); in lpfc_sli_host_down()
10984 * lpfc_sli_hba_down - Resource cleanup function for the HBA
10987 * This function cleans up all iocb, buffers, mailbox commands
10991 * - Free discovery resources for each virtual port
10992 * - Cleanup any pending fabric iocbs
10993 * - Iterate through the iocb txq and free each entry
10995 * - Free up any buffer posted to the HBA
10996 * - Free mailbox commands in the mailbox queue.
11002 struct lpfc_sli *psli = &phba->sli; in lpfc_sli_hba_down()
11009 /* Shutdown the mailbox command sub-system */ in lpfc_sli_hba_down()
11014 /* Disable softirqs, including timers from obtaining phba->hbalock */ in lpfc_sli_hba_down()
11019 spin_lock_irqsave(&phba->hbalock, flags); in lpfc_sli_hba_down()
11025 if (phba->sli_rev != LPFC_SLI_REV4) { in lpfc_sli_hba_down()
11026 for (i = 0; i < psli->num_rings; i++) { in lpfc_sli_hba_down()
11027 pring = &psli->sli3_ring[i]; in lpfc_sli_hba_down()
11029 if (pring->ringno == LPFC_ELS_RING) { in lpfc_sli_hba_down()
11030 pring->flag |= LPFC_DEFERRED_RING_EVENT; in lpfc_sli_hba_down()
11032 set_bit(LPFC_DATA_READY, &phba->data_flags); in lpfc_sli_hba_down()
11034 list_splice_init(&pring->txq, &completions); in lpfc_sli_hba_down()
11037 list_for_each_entry(qp, &phba->sli4_hba.lpfc_wq_list, wq_list) { in lpfc_sli_hba_down()
11038 pring = qp->pring; in lpfc_sli_hba_down()
11041 spin_lock(&pring->ring_lock); in lpfc_sli_hba_down()
11042 list_splice_init(&pring->txq, &completions); in lpfc_sli_hba_down()
11043 spin_unlock(&pring->ring_lock); in lpfc_sli_hba_down()
11044 if (pring == phba->sli4_hba.els_wq->pring) { in lpfc_sli_hba_down()
11045 pring->flag |= LPFC_DEFERRED_RING_EVENT; in lpfc_sli_hba_down()
11047 set_bit(LPFC_DATA_READY, &phba->data_flags); in lpfc_sli_hba_down()
11051 spin_unlock_irqrestore(&phba->hbalock, flags); in lpfc_sli_hba_down()
11057 spin_lock_irqsave(&phba->hbalock, flags); in lpfc_sli_hba_down()
11058 list_splice_init(&phba->elsbuf, &completions); in lpfc_sli_hba_down()
11059 phba->elsbuf_cnt = 0; in lpfc_sli_hba_down()
11060 phba->elsbuf_prev_cnt = 0; in lpfc_sli_hba_down()
11061 spin_unlock_irqrestore(&phba->hbalock, flags); in lpfc_sli_hba_down()
11066 lpfc_mbuf_free(phba, buf_ptr->virt, buf_ptr->phys); in lpfc_sli_hba_down()
11070 /* Enable softirqs again, done with phba->hbalock */ in lpfc_sli_hba_down()
11074 del_timer_sync(&psli->mbox_tmo); in lpfc_sli_hba_down()
11076 spin_lock_irqsave(&phba->pport->work_port_lock, flags); in lpfc_sli_hba_down()
11077 phba->pport->work_port_events &= ~WORKER_MBOX_TMO; in lpfc_sli_hba_down()
11078 spin_unlock_irqrestore(&phba->pport->work_port_lock, flags); in lpfc_sli_hba_down()
11084 * lpfc_sli_pcimem_bcopy - SLI memory copy function
11114 * lpfc_sli_bemem_bcopy - SLI memory copy function
11141 * lpfc_sli_ringpostbuf_put - Function to add a buffer to postbufq
11156 spin_lock_irq(&phba->hbalock); in lpfc_sli_ringpostbuf_put()
11157 list_add_tail(&mp->list, &pring->postbufq); in lpfc_sli_ringpostbuf_put()
11158 pring->postbufq_cnt++; in lpfc_sli_ringpostbuf_put()
11159 spin_unlock_irq(&phba->hbalock); in lpfc_sli_ringpostbuf_put()
11164 * lpfc_sli_get_buffer_tag - allocates a tag for a CMD_QUE_XRI64_CX buffer
11169 * tag is bit wise or-ed with QUE_BUFTAG_BIT to make sure that the tag
11177 spin_lock_irq(&phba->hbalock); in lpfc_sli_get_buffer_tag()
11178 phba->buffer_tag_count++; in lpfc_sli_get_buffer_tag()
11183 phba->buffer_tag_count |= QUE_BUFTAG_BIT; in lpfc_sli_get_buffer_tag()
11184 spin_unlock_irq(&phba->hbalock); in lpfc_sli_get_buffer_tag()
11185 return phba->buffer_tag_count; in lpfc_sli_get_buffer_tag()
11189 * lpfc_sli_ring_taggedbuf_get - find HBQ buffer associated with given tag
11194 * Buffers posted using CMD_QUE_XRI64_CX iocb are in pring->postbufq
11197 * This function searches the pring->postbufq list using the tag
11208 struct list_head *slp = &pring->postbufq; in lpfc_sli_ring_taggedbuf_get()
11211 spin_lock_irq(&phba->hbalock); in lpfc_sli_ring_taggedbuf_get()
11212 list_for_each_entry_safe(mp, next_mp, &pring->postbufq, list) { in lpfc_sli_ring_taggedbuf_get()
11213 if (mp->buffer_tag == tag) { in lpfc_sli_ring_taggedbuf_get()
11214 list_del_init(&mp->list); in lpfc_sli_ring_taggedbuf_get()
11215 pring->postbufq_cnt--; in lpfc_sli_ring_taggedbuf_get()
11216 spin_unlock_irq(&phba->hbalock); in lpfc_sli_ring_taggedbuf_get()
11221 spin_unlock_irq(&phba->hbalock); in lpfc_sli_ring_taggedbuf_get()
11225 pring->ringno, (unsigned long) tag, in lpfc_sli_ring_taggedbuf_get()
11226 slp->next, slp->prev, pring->postbufq_cnt); in lpfc_sli_ring_taggedbuf_get()
11232 * lpfc_sli_ringpostbuf_get - search buffers for unsolicited CT and ELS events
11252 struct list_head *slp = &pring->postbufq; in lpfc_sli_ringpostbuf_get()
11255 spin_lock_irq(&phba->hbalock); in lpfc_sli_ringpostbuf_get()
11256 list_for_each_entry_safe(mp, next_mp, &pring->postbufq, list) { in lpfc_sli_ringpostbuf_get()
11257 if (mp->phys == phys) { in lpfc_sli_ringpostbuf_get()
11258 list_del_init(&mp->list); in lpfc_sli_ringpostbuf_get()
11259 pring->postbufq_cnt--; in lpfc_sli_ringpostbuf_get()
11260 spin_unlock_irq(&phba->hbalock); in lpfc_sli_ringpostbuf_get()
11265 spin_unlock_irq(&phba->hbalock); in lpfc_sli_ringpostbuf_get()
11269 pring->ringno, (unsigned long long)phys, in lpfc_sli_ringpostbuf_get()
11270 slp->next, slp->prev, pring->postbufq_cnt); in lpfc_sli_ringpostbuf_get()
11275 * lpfc_sli_abort_els_cmpl - Completion handler for the els abort iocbs
11289 IOCB_t *irsp = &rspiocb->iocb; in lpfc_sli_abort_els_cmpl()
11293 if (irsp->ulpStatus) { in lpfc_sli_abort_els_cmpl()
11299 abort_context = cmdiocb->iocb.un.acxri.abortContextTag; in lpfc_sli_abort_els_cmpl()
11300 abort_iotag = cmdiocb->iocb.un.acxri.abortIoTag; in lpfc_sli_abort_els_cmpl()
11302 spin_lock_irq(&phba->hbalock); in lpfc_sli_abort_els_cmpl()
11303 if (phba->sli_rev < LPFC_SLI_REV4) { in lpfc_sli_abort_els_cmpl()
11304 if (irsp->ulpCommand == CMD_ABORT_XRI_CX && in lpfc_sli_abort_els_cmpl()
11305 irsp->ulpStatus == IOSTAT_LOCAL_REJECT && in lpfc_sli_abort_els_cmpl()
11306 irsp->un.ulpWord[4] == IOERR_ABORT_REQUESTED) { in lpfc_sli_abort_els_cmpl()
11307 spin_unlock_irq(&phba->hbalock); in lpfc_sli_abort_els_cmpl()
11311 abort_iotag <= phba->sli.last_iotag) in lpfc_sli_abort_els_cmpl()
11313 phba->sli.iocbq_lookup[abort_iotag]; in lpfc_sli_abort_els_cmpl()
11320 abort_iocb = phba->sli.iocbq_lookup[abort_context]; in lpfc_sli_abort_els_cmpl()
11327 irsp->ulpStatus, irsp->un.ulpWord[4]); in lpfc_sli_abort_els_cmpl()
11329 spin_unlock_irq(&phba->hbalock); in lpfc_sli_abort_els_cmpl()
11337 * lpfc_ignore_els_cmpl - Completion handler for aborted ELS command
11351 IOCB_t *irsp = &rspiocb->iocb; in lpfc_ignore_els_cmpl()
11357 irsp->ulpIoTag, irsp->ulpStatus, in lpfc_ignore_els_cmpl()
11358 irsp->un.ulpWord[4], irsp->ulpTimeout); in lpfc_ignore_els_cmpl()
11359 if (cmdiocb->iocb.ulpCommand == CMD_GEN_REQUEST64_CR) in lpfc_ignore_els_cmpl()
11367 * lpfc_sli_abort_iotag_issue - Issue abort for a command iocb
11383 struct lpfc_vport *vport = cmdiocb->vport; in lpfc_sli_abort_iotag_issue()
11396 icmd = &cmdiocb->iocb; in lpfc_sli_abort_iotag_issue()
11397 if (icmd->ulpCommand == CMD_ABORT_XRI_CN || in lpfc_sli_abort_iotag_issue()
11398 icmd->ulpCommand == CMD_CLOSE_XRI_CN || in lpfc_sli_abort_iotag_issue()
11399 (cmdiocb->iocb_flag & LPFC_DRIVER_ABORTED) != 0) in lpfc_sli_abort_iotag_issue()
11410 cmdiocb->iocb_flag |= LPFC_DRIVER_ABORTED; in lpfc_sli_abort_iotag_issue()
11412 iabt = &abtsiocbp->iocb; in lpfc_sli_abort_iotag_issue()
11413 iabt->un.acxri.abortType = ABORT_TYPE_ABTS; in lpfc_sli_abort_iotag_issue()
11414 iabt->un.acxri.abortContextTag = icmd->ulpContext; in lpfc_sli_abort_iotag_issue()
11415 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_sli_abort_iotag_issue()
11416 iabt->un.acxri.abortIoTag = cmdiocb->sli4_xritag; in lpfc_sli_abort_iotag_issue()
11417 iabt->un.acxri.abortContextTag = cmdiocb->iotag; in lpfc_sli_abort_iotag_issue()
11419 iabt->un.acxri.abortIoTag = icmd->ulpIoTag; in lpfc_sli_abort_iotag_issue()
11420 if (pring->ringno == LPFC_ELS_RING) { in lpfc_sli_abort_iotag_issue()
11421 ndlp = (struct lpfc_nodelist *)(cmdiocb->context1); in lpfc_sli_abort_iotag_issue()
11422 iabt->un.acxri.abortContextTag = ndlp->nlp_rpi; in lpfc_sli_abort_iotag_issue()
11425 iabt->ulpLe = 1; in lpfc_sli_abort_iotag_issue()
11426 iabt->ulpClass = icmd->ulpClass; in lpfc_sli_abort_iotag_issue()
11429 abtsiocbp->hba_wqidx = cmdiocb->hba_wqidx; in lpfc_sli_abort_iotag_issue()
11430 if (cmdiocb->iocb_flag & LPFC_IO_FCP) in lpfc_sli_abort_iotag_issue()
11431 abtsiocbp->iocb_flag |= LPFC_USE_FCPWQIDX; in lpfc_sli_abort_iotag_issue()
11432 if (cmdiocb->iocb_flag & LPFC_IO_FOF) in lpfc_sli_abort_iotag_issue()
11433 abtsiocbp->iocb_flag |= LPFC_IO_FOF; in lpfc_sli_abort_iotag_issue()
11435 if (phba->link_state >= LPFC_LINK_UP) in lpfc_sli_abort_iotag_issue()
11436 iabt->ulpCommand = CMD_ABORT_XRI_CN; in lpfc_sli_abort_iotag_issue()
11438 iabt->ulpCommand = CMD_CLOSE_XRI_CN; in lpfc_sli_abort_iotag_issue()
11440 abtsiocbp->iocb_cmpl = lpfc_sli_abort_els_cmpl; in lpfc_sli_abort_iotag_issue()
11441 abtsiocbp->vport = vport; in lpfc_sli_abort_iotag_issue()
11446 iabt->un.acxri.abortIoTag, in lpfc_sli_abort_iotag_issue()
11447 iabt->un.acxri.abortContextTag, in lpfc_sli_abort_iotag_issue()
11448 abtsiocbp->iotag); in lpfc_sli_abort_iotag_issue()
11450 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_sli_abort_iotag_issue()
11455 spin_lock_irqsave(&pring->ring_lock, iflags); in lpfc_sli_abort_iotag_issue()
11456 retval = __lpfc_sli_issue_iocb(phba, pring->ringno, in lpfc_sli_abort_iotag_issue()
11458 spin_unlock_irqrestore(&pring->ring_lock, iflags); in lpfc_sli_abort_iotag_issue()
11460 retval = __lpfc_sli_issue_iocb(phba, pring->ringno, in lpfc_sli_abort_iotag_issue()
11476 * lpfc_sli_issue_abort_iotag - Abort function for a command iocb
11492 struct lpfc_vport *vport = cmdiocb->vport; in lpfc_sli_issue_abort_iotag()
11496 lockdep_assert_held(&phba->hbalock); in lpfc_sli_issue_abort_iotag()
11503 icmd = &cmdiocb->iocb; in lpfc_sli_issue_abort_iotag()
11504 if (icmd->ulpCommand == CMD_ABORT_XRI_CN || in lpfc_sli_issue_abort_iotag()
11505 icmd->ulpCommand == CMD_CLOSE_XRI_CN || in lpfc_sli_issue_abort_iotag()
11506 (cmdiocb->iocb_flag & LPFC_DRIVER_ABORTED) != 0) in lpfc_sli_issue_abort_iotag()
11510 if (cmdiocb->iocb_flag & LPFC_IO_FABRIC) in lpfc_sli_issue_abort_iotag()
11511 cmdiocb->fabric_iocb_cmpl = lpfc_ignore_els_cmpl; in lpfc_sli_issue_abort_iotag()
11513 cmdiocb->iocb_cmpl = lpfc_ignore_els_cmpl; in lpfc_sli_issue_abort_iotag()
11521 if ((vport->load_flag & FC_UNLOADING) && in lpfc_sli_issue_abort_iotag()
11522 (pring->ringno == LPFC_ELS_RING)) { in lpfc_sli_issue_abort_iotag()
11523 if (cmdiocb->iocb_flag & LPFC_IO_FABRIC) in lpfc_sli_issue_abort_iotag()
11524 cmdiocb->fabric_iocb_cmpl = lpfc_ignore_els_cmpl; in lpfc_sli_issue_abort_iotag()
11526 cmdiocb->iocb_cmpl = lpfc_ignore_els_cmpl; in lpfc_sli_issue_abort_iotag()
11543 * lpfc_sli_hba_iocb_abort - Abort all iocbs to an hba.
11551 struct lpfc_sli *psli = &phba->sli; in lpfc_sli_hba_iocb_abort()
11556 if (phba->sli_rev != LPFC_SLI_REV4) { in lpfc_sli_hba_iocb_abort()
11557 for (i = 0; i < psli->num_rings; i++) { in lpfc_sli_hba_iocb_abort()
11558 pring = &psli->sli3_ring[i]; in lpfc_sli_hba_iocb_abort()
11563 list_for_each_entry(qp, &phba->sli4_hba.lpfc_wq_list, wq_list) { in lpfc_sli_hba_iocb_abort()
11564 pring = qp->pring; in lpfc_sli_hba_iocb_abort()
11572 * lpfc_sli_validate_fcp_iocb - find commands associated with a vport or LUN
11602 if (iocbq->vport != vport) in lpfc_sli_validate_fcp_iocb()
11605 if (!(iocbq->iocb_flag & LPFC_IO_FCP) || in lpfc_sli_validate_fcp_iocb()
11606 !(iocbq->iocb_flag & LPFC_IO_ON_TXCMPLQ) || in lpfc_sli_validate_fcp_iocb()
11607 iocbq->iocb_flag & LPFC_DRIVER_ABORTED) in lpfc_sli_validate_fcp_iocb()
11610 icmd = &iocbq->iocb; in lpfc_sli_validate_fcp_iocb()
11611 if (icmd->ulpCommand == CMD_ABORT_XRI_CN || in lpfc_sli_validate_fcp_iocb()
11612 icmd->ulpCommand == CMD_CLOSE_XRI_CN) in lpfc_sli_validate_fcp_iocb()
11617 if (lpfc_cmd->pCmd == NULL) in lpfc_sli_validate_fcp_iocb()
11622 if ((lpfc_cmd->rdata) && (lpfc_cmd->rdata->pnode) && in lpfc_sli_validate_fcp_iocb()
11623 (lpfc_cmd->rdata->pnode->nlp_sid == tgt_id) && in lpfc_sli_validate_fcp_iocb()
11624 (scsilun_to_int(&lpfc_cmd->fcp_cmnd->fcp_lun) == lun_id)) in lpfc_sli_validate_fcp_iocb()
11628 if ((lpfc_cmd->rdata) && (lpfc_cmd->rdata->pnode) && in lpfc_sli_validate_fcp_iocb()
11629 (lpfc_cmd->rdata->pnode->nlp_sid == tgt_id)) in lpfc_sli_validate_fcp_iocb()
11645 * lpfc_sli_sum_iocb - Function to count the number of FCP iocbs pending
11667 struct lpfc_hba *phba = vport->phba; in lpfc_sli_sum_iocb()
11671 spin_lock_irq(&phba->hbalock); in lpfc_sli_sum_iocb()
11672 for (i = 1, sum = 0; i <= phba->sli.last_iotag; i++) { in lpfc_sli_sum_iocb()
11673 iocbq = phba->sli.iocbq_lookup[i]; in lpfc_sli_sum_iocb()
11679 spin_unlock_irq(&phba->hbalock); in lpfc_sli_sum_iocb()
11685 * lpfc_sli_abort_fcp_cmpl - Completion handler function for aborted FCP IOCBs
11702 cmdiocb->iocb.un.acxri.abortContextTag, in lpfc_sli_abort_fcp_cmpl()
11703 cmdiocb->iocb.un.acxri.abortIoTag, in lpfc_sli_abort_fcp_cmpl()
11704 cmdiocb->iotag, rspiocb->iocb.ulpStatus, in lpfc_sli_abort_fcp_cmpl()
11705 rspiocb->iocb.un.ulpWord[4]); in lpfc_sli_abort_fcp_cmpl()
11711 * lpfc_sli_abort_iocb - issue abort for all commands on a host/target/LUN
11735 struct lpfc_hba *phba = vport->phba; in lpfc_sli_abort_iocb()
11744 if (phba->hba_flag & HBA_IOQ_FLUSH) in lpfc_sli_abort_iocb()
11747 for (i = 1; i <= phba->sli.last_iotag; i++) { in lpfc_sli_abort_iocb()
11748 iocbq = phba->sli.iocbq_lookup[i]; in lpfc_sli_abort_iocb()
11758 if (iocbq->iocb_flag & LPFC_DRIVER_ABORTED) in lpfc_sli_abort_iocb()
11769 iocbq->iocb_flag |= LPFC_DRIVER_ABORTED; in lpfc_sli_abort_iocb()
11771 cmd = &iocbq->iocb; in lpfc_sli_abort_iocb()
11772 abtsiocb->iocb.un.acxri.abortType = ABORT_TYPE_ABTS; in lpfc_sli_abort_iocb()
11773 abtsiocb->iocb.un.acxri.abortContextTag = cmd->ulpContext; in lpfc_sli_abort_iocb()
11774 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_sli_abort_iocb()
11775 abtsiocb->iocb.un.acxri.abortIoTag = iocbq->sli4_xritag; in lpfc_sli_abort_iocb()
11777 abtsiocb->iocb.un.acxri.abortIoTag = cmd->ulpIoTag; in lpfc_sli_abort_iocb()
11778 abtsiocb->iocb.ulpLe = 1; in lpfc_sli_abort_iocb()
11779 abtsiocb->iocb.ulpClass = cmd->ulpClass; in lpfc_sli_abort_iocb()
11780 abtsiocb->vport = vport; in lpfc_sli_abort_iocb()
11783 abtsiocb->hba_wqidx = iocbq->hba_wqidx; in lpfc_sli_abort_iocb()
11784 if (iocbq->iocb_flag & LPFC_IO_FCP) in lpfc_sli_abort_iocb()
11785 abtsiocb->iocb_flag |= LPFC_USE_FCPWQIDX; in lpfc_sli_abort_iocb()
11786 if (iocbq->iocb_flag & LPFC_IO_FOF) in lpfc_sli_abort_iocb()
11787 abtsiocb->iocb_flag |= LPFC_IO_FOF; in lpfc_sli_abort_iocb()
11790 abtsiocb->iocb.ulpCommand = CMD_ABORT_XRI_CN; in lpfc_sli_abort_iocb()
11792 abtsiocb->iocb.ulpCommand = CMD_CLOSE_XRI_CN; in lpfc_sli_abort_iocb()
11795 abtsiocb->iocb_cmpl = lpfc_sli_abort_fcp_cmpl; in lpfc_sli_abort_iocb()
11796 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_sli_abort_iocb()
11800 ret_val = lpfc_sli_issue_iocb(phba, pring_s4->ringno, in lpfc_sli_abort_iocb()
11803 ret_val = lpfc_sli_issue_iocb(phba, pring->ringno, in lpfc_sli_abort_iocb()
11816 * lpfc_sli_abort_taskmgmt - issue abort for all commands on a host/target/LUN
11841 struct lpfc_hba *phba = vport->phba; in lpfc_sli_abort_taskmgmt()
11851 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli_abort_taskmgmt()
11854 if (phba->hba_flag & HBA_IOQ_FLUSH) { in lpfc_sli_abort_taskmgmt()
11855 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli_abort_taskmgmt()
11860 for (i = 1; i <= phba->sli.last_iotag; i++) { in lpfc_sli_abort_taskmgmt()
11861 iocbq = phba->sli.iocbq_lookup[i]; in lpfc_sli_abort_taskmgmt()
11869 spin_lock(&lpfc_cmd->buf_lock); in lpfc_sli_abort_taskmgmt()
11871 if (!lpfc_cmd->pCmd) { in lpfc_sli_abort_taskmgmt()
11872 spin_unlock(&lpfc_cmd->buf_lock); in lpfc_sli_abort_taskmgmt()
11876 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_sli_abort_taskmgmt()
11878 phba->sli4_hba.hdwq[iocbq->hba_wqidx].io_wq->pring; in lpfc_sli_abort_taskmgmt()
11880 spin_unlock(&lpfc_cmd->buf_lock); in lpfc_sli_abort_taskmgmt()
11884 spin_lock(&pring_s4->ring_lock); in lpfc_sli_abort_taskmgmt()
11891 if ((iocbq->iocb_flag & LPFC_DRIVER_ABORTED) || in lpfc_sli_abort_taskmgmt()
11892 !(iocbq->iocb_flag & LPFC_IO_ON_TXCMPLQ)) { in lpfc_sli_abort_taskmgmt()
11893 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_sli_abort_taskmgmt()
11894 spin_unlock(&pring_s4->ring_lock); in lpfc_sli_abort_taskmgmt()
11895 spin_unlock(&lpfc_cmd->buf_lock); in lpfc_sli_abort_taskmgmt()
11902 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_sli_abort_taskmgmt()
11903 spin_unlock(&pring_s4->ring_lock); in lpfc_sli_abort_taskmgmt()
11904 spin_unlock(&lpfc_cmd->buf_lock); in lpfc_sli_abort_taskmgmt()
11908 icmd = &iocbq->iocb; in lpfc_sli_abort_taskmgmt()
11909 abtsiocbq->iocb.un.acxri.abortType = ABORT_TYPE_ABTS; in lpfc_sli_abort_taskmgmt()
11910 abtsiocbq->iocb.un.acxri.abortContextTag = icmd->ulpContext; in lpfc_sli_abort_taskmgmt()
11911 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_sli_abort_taskmgmt()
11912 abtsiocbq->iocb.un.acxri.abortIoTag = in lpfc_sli_abort_taskmgmt()
11913 iocbq->sli4_xritag; in lpfc_sli_abort_taskmgmt()
11915 abtsiocbq->iocb.un.acxri.abortIoTag = icmd->ulpIoTag; in lpfc_sli_abort_taskmgmt()
11916 abtsiocbq->iocb.ulpLe = 1; in lpfc_sli_abort_taskmgmt()
11917 abtsiocbq->iocb.ulpClass = icmd->ulpClass; in lpfc_sli_abort_taskmgmt()
11918 abtsiocbq->vport = vport; in lpfc_sli_abort_taskmgmt()
11921 abtsiocbq->hba_wqidx = iocbq->hba_wqidx; in lpfc_sli_abort_taskmgmt()
11922 if (iocbq->iocb_flag & LPFC_IO_FCP) in lpfc_sli_abort_taskmgmt()
11923 abtsiocbq->iocb_flag |= LPFC_USE_FCPWQIDX; in lpfc_sli_abort_taskmgmt()
11924 if (iocbq->iocb_flag & LPFC_IO_FOF) in lpfc_sli_abort_taskmgmt()
11925 abtsiocbq->iocb_flag |= LPFC_IO_FOF; in lpfc_sli_abort_taskmgmt()
11927 ndlp = lpfc_cmd->rdata->pnode; in lpfc_sli_abort_taskmgmt()
11930 (ndlp && ndlp->nlp_state == NLP_STE_MAPPED_NODE)) in lpfc_sli_abort_taskmgmt()
11931 abtsiocbq->iocb.ulpCommand = CMD_ABORT_XRI_CN; in lpfc_sli_abort_taskmgmt()
11933 abtsiocbq->iocb.ulpCommand = CMD_CLOSE_XRI_CN; in lpfc_sli_abort_taskmgmt()
11936 abtsiocbq->iocb_cmpl = lpfc_sli_abort_fcp_cmpl; in lpfc_sli_abort_taskmgmt()
11942 iocbq->iocb_flag |= LPFC_DRIVER_ABORTED; in lpfc_sli_abort_taskmgmt()
11944 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_sli_abort_taskmgmt()
11945 ret_val = __lpfc_sli_issue_iocb(phba, pring_s4->ringno, in lpfc_sli_abort_taskmgmt()
11947 spin_unlock(&pring_s4->ring_lock); in lpfc_sli_abort_taskmgmt()
11949 ret_val = __lpfc_sli_issue_iocb(phba, pring->ringno, in lpfc_sli_abort_taskmgmt()
11953 spin_unlock(&lpfc_cmd->buf_lock); in lpfc_sli_abort_taskmgmt()
11960 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli_abort_taskmgmt()
11965 * lpfc_sli_wake_iocb_wait - lpfc_sli_issue_iocb_wait's completion handler
11990 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli_wake_iocb_wait()
11991 if (cmdiocbq->iocb_flag & LPFC_IO_WAKE_TMO) { in lpfc_sli_wake_iocb_wait()
11999 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli_wake_iocb_wait()
12000 cmdiocbq->iocb_cmpl = cmdiocbq->wait_iocb_cmpl; in lpfc_sli_wake_iocb_wait()
12001 cmdiocbq->wait_iocb_cmpl = NULL; in lpfc_sli_wake_iocb_wait()
12002 if (cmdiocbq->iocb_cmpl) in lpfc_sli_wake_iocb_wait()
12003 (cmdiocbq->iocb_cmpl)(phba, cmdiocbq, NULL); in lpfc_sli_wake_iocb_wait()
12009 cmdiocbq->iocb_flag |= LPFC_IO_WAKE; in lpfc_sli_wake_iocb_wait()
12010 if (cmdiocbq->context2 && rspiocbq) in lpfc_sli_wake_iocb_wait()
12011 memcpy(&((struct lpfc_iocbq *)cmdiocbq->context2)->iocb, in lpfc_sli_wake_iocb_wait()
12012 &rspiocbq->iocb, sizeof(IOCB_t)); in lpfc_sli_wake_iocb_wait()
12015 if ((cmdiocbq->iocb_flag & LPFC_IO_FCP) && in lpfc_sli_wake_iocb_wait()
12016 !(cmdiocbq->iocb_flag & LPFC_IO_LIBDFC)) { in lpfc_sli_wake_iocb_wait()
12019 if (rspiocbq && (rspiocbq->iocb_flag & LPFC_EXCHANGE_BUSY)) in lpfc_sli_wake_iocb_wait()
12020 lpfc_cmd->flags |= LPFC_SBUF_XBUSY; in lpfc_sli_wake_iocb_wait()
12022 lpfc_cmd->flags &= ~LPFC_SBUF_XBUSY; in lpfc_sli_wake_iocb_wait()
12025 pdone_q = cmdiocbq->context_un.wait_queue; in lpfc_sli_wake_iocb_wait()
12028 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli_wake_iocb_wait()
12033 * lpfc_chk_iocb_flg - Test IOCB flag with lock held.
12051 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_chk_iocb_flg()
12052 ret = piocbq->iocb_flag & flag; in lpfc_chk_iocb_flg()
12053 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_chk_iocb_flg()
12059 * lpfc_sli_issue_iocb_wait - Synchronous function to issue iocb commands
12078 * non-interruptible wait.
12112 if (phba->sli_rev >= LPFC_SLI_REV4) in lpfc_sli_issue_iocb_wait()
12115 pring = &phba->sli.sli3_ring[ring_number]; in lpfc_sli_issue_iocb_wait()
12121 if (piocb->context2) in lpfc_sli_issue_iocb_wait()
12123 piocb->context2 = prspiocbq; in lpfc_sli_issue_iocb_wait()
12126 piocb->wait_iocb_cmpl = piocb->iocb_cmpl; in lpfc_sli_issue_iocb_wait()
12127 piocb->iocb_cmpl = lpfc_sli_wake_iocb_wait; in lpfc_sli_issue_iocb_wait()
12128 piocb->context_un.wait_queue = &done_q; in lpfc_sli_issue_iocb_wait()
12129 piocb->iocb_flag &= ~(LPFC_IO_WAKE | LPFC_IO_WAKE_TMO); in lpfc_sli_issue_iocb_wait()
12131 if (phba->cfg_poll & DISABLE_FCP_RING_INT) { in lpfc_sli_issue_iocb_wait()
12132 if (lpfc_readl(phba->HCregaddr, &creg_val)) in lpfc_sli_issue_iocb_wait()
12135 writel(creg_val, phba->HCregaddr); in lpfc_sli_issue_iocb_wait()
12136 readl(phba->HCregaddr); /* flush */ in lpfc_sli_issue_iocb_wait()
12146 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli_issue_iocb_wait()
12147 if (!(piocb->iocb_flag & LPFC_IO_WAKE)) { in lpfc_sli_issue_iocb_wait()
12155 piocb->iocb_flag |= LPFC_IO_WAKE_TMO; in lpfc_sli_issue_iocb_wait()
12157 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli_issue_iocb_wait()
12162 * status or not - that's for the caller to check. in lpfc_sli_issue_iocb_wait()
12168 "0338 IOCB wait timeout error - no " in lpfc_sli_issue_iocb_wait()
12179 if (phba->cfg_log_verbose & LOG_SLI) { in lpfc_sli_issue_iocb_wait()
12180 list_for_each_entry(iocb, &pring->txq, list) { in lpfc_sli_issue_iocb_wait()
12183 list_for_each_entry(iocb, &pring->txcmplq, list) { in lpfc_sli_issue_iocb_wait()
12188 phba->iocb_cnt, txq_cnt, txcmplq_cnt); in lpfc_sli_issue_iocb_wait()
12198 if (phba->cfg_poll & DISABLE_FCP_RING_INT) { in lpfc_sli_issue_iocb_wait()
12199 if (lpfc_readl(phba->HCregaddr, &creg_val)) in lpfc_sli_issue_iocb_wait()
12202 writel(creg_val, phba->HCregaddr); in lpfc_sli_issue_iocb_wait()
12203 readl(phba->HCregaddr); /* flush */ in lpfc_sli_issue_iocb_wait()
12207 piocb->context2 = NULL; in lpfc_sli_issue_iocb_wait()
12209 piocb->context_un.wait_queue = NULL; in lpfc_sli_issue_iocb_wait()
12210 piocb->iocb_cmpl = NULL; in lpfc_sli_issue_iocb_wait()
12215 * lpfc_sli_issue_mbox_wait - Synchronous function to issue mailbox
12217 * @pmboxq: Pointer to driver mailbox object.
12220 * This function issues the mailbox to firmware and waits for the
12221 * mailbox command to complete. If the mailbox command is not
12223 * The function waits for the mailbox completion using an
12226 * should not free the mailbox resources, if this function returns
12228 * This function will sleep while waiting for mailbox completion.
12232 * This function assumes that the mailbox completion occurs while
12234 * the worker thread which processes mailbox completion.
12248 pmboxq->mbox_flag &= ~LPFC_MBX_WAKE; in lpfc_sli_issue_mbox_wait()
12250 pmboxq->mbox_cmpl = lpfc_sli_wake_mbox_wait; in lpfc_sli_issue_mbox_wait()
12254 pmboxq->context3 = &mbox_done; in lpfc_sli_issue_mbox_wait()
12261 spin_lock_irqsave(&phba->hbalock, flag); in lpfc_sli_issue_mbox_wait()
12262 pmboxq->context3 = NULL; in lpfc_sli_issue_mbox_wait()
12264 * if LPFC_MBX_WAKE flag is set the mailbox is completed in lpfc_sli_issue_mbox_wait()
12267 if (pmboxq->mbox_flag & LPFC_MBX_WAKE) { in lpfc_sli_issue_mbox_wait()
12271 pmboxq->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_sli_issue_mbox_wait()
12273 spin_unlock_irqrestore(&phba->hbalock, flag); in lpfc_sli_issue_mbox_wait()
12279 * lpfc_sli_mbox_sys_shutdown - shutdown mailbox command sub-system
12281 * @mbx_action: Mailbox shutdown options.
12283 * This function is called to shutdown the driver's mailbox sub-system.
12284 * It first marks the mailbox sub-system is in a block state to prevent
12285 * the asynchronous mailbox command from issued off the pending mailbox
12286 * command queue. If the mailbox command sub-system shutdown is due to
12288 * the mailbox sub-system flush routine to forcefully bring down the
12289 * mailbox sub-system. Otherwise, if it is due to normal condition (such
12291 * outstanding mailbox command to complete before invoking the mailbox
12292 * sub-system flush routine to gracefully bring down mailbox sub-system.
12297 struct lpfc_sli *psli = &phba->sli; in lpfc_sli_mbox_sys_shutdown()
12308 /* Disable softirqs, including timers from obtaining phba->hbalock */ in lpfc_sli_mbox_sys_shutdown()
12311 spin_lock_irq(&phba->hbalock); in lpfc_sli_mbox_sys_shutdown()
12312 psli->sli_flag |= LPFC_SLI_ASYNC_MBX_BLK; in lpfc_sli_mbox_sys_shutdown()
12314 if (psli->sli_flag & LPFC_SLI_ACTIVE) { in lpfc_sli_mbox_sys_shutdown()
12315 /* Determine how long we might wait for the active mailbox in lpfc_sli_mbox_sys_shutdown()
12318 if (phba->sli.mbox_active) in lpfc_sli_mbox_sys_shutdown()
12320 phba->sli.mbox_active) * in lpfc_sli_mbox_sys_shutdown()
12322 spin_unlock_irq(&phba->hbalock); in lpfc_sli_mbox_sys_shutdown()
12324 /* Enable softirqs again, done with phba->hbalock */ in lpfc_sli_mbox_sys_shutdown()
12327 while (phba->sli.mbox_active) { in lpfc_sli_mbox_sys_shutdown()
12328 /* Check active mailbox complete status every 2ms */ in lpfc_sli_mbox_sys_shutdown()
12331 /* Timeout, let the mailbox flush routine to in lpfc_sli_mbox_sys_shutdown()
12332 * forcefully release active mailbox command in lpfc_sli_mbox_sys_shutdown()
12337 spin_unlock_irq(&phba->hbalock); in lpfc_sli_mbox_sys_shutdown()
12339 /* Enable softirqs again, done with phba->hbalock */ in lpfc_sli_mbox_sys_shutdown()
12347 * lpfc_sli_eratt_read - read sli-3 error attention events
12363 if (lpfc_readl(phba->HAregaddr, &ha_copy)) in lpfc_sli_eratt_read()
12372 if ((HS_FFER1 & phba->work_hs) && in lpfc_sli_eratt_read()
12374 HS_FFER6 | HS_FFER7 | HS_FFER8) & phba->work_hs)) { in lpfc_sli_eratt_read()
12375 phba->hba_flag |= DEFER_ERATT; in lpfc_sli_eratt_read()
12377 writel(0, phba->HCregaddr); in lpfc_sli_eratt_read()
12378 readl(phba->HCregaddr); 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()
12391 phba->work_hs |= UNPLUG_ERR; in lpfc_sli_eratt_read()
12393 phba->work_ha |= HA_ERATT; in lpfc_sli_eratt_read()
12395 phba->hba_flag |= HBA_ERATT_HANDLED; in lpfc_sli_eratt_read()
12400 * lpfc_sli4_eratt_read - read sli-4 error attention events
12422 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); in lpfc_sli4_eratt_read()
12425 if (lpfc_readl(phba->sli4_hba.u.if_type0.UERRLOregaddr, in lpfc_sli4_eratt_read()
12427 lpfc_readl(phba->sli4_hba.u.if_type0.UERRHIregaddr, in lpfc_sli4_eratt_read()
12429 phba->work_hs |= UNPLUG_ERR; in lpfc_sli4_eratt_read()
12430 phba->work_ha |= HA_ERATT; in lpfc_sli4_eratt_read()
12431 phba->hba_flag |= HBA_ERATT_HANDLED; in lpfc_sli4_eratt_read()
12434 if ((~phba->sli4_hba.ue_mask_lo & uerr_sta_lo) || in lpfc_sli4_eratt_read()
12435 (~phba->sli4_hba.ue_mask_hi & uerr_sta_hi)) { in lpfc_sli4_eratt_read()
12442 phba->sli4_hba.ue_mask_lo, in lpfc_sli4_eratt_read()
12443 phba->sli4_hba.ue_mask_hi); in lpfc_sli4_eratt_read()
12444 phba->work_status[0] = uerr_sta_lo; in lpfc_sli4_eratt_read()
12445 phba->work_status[1] = uerr_sta_hi; 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()
12453 if (lpfc_readl(phba->sli4_hba.u.if_type2.STATUSregaddr, in lpfc_sli4_eratt_read()
12455 lpfc_readl(phba->sli4_hba.PSMPHRregaddr, in lpfc_sli4_eratt_read()
12457 phba->work_hs |= UNPLUG_ERR; in lpfc_sli4_eratt_read()
12458 phba->work_ha |= HA_ERATT; in lpfc_sli4_eratt_read()
12459 phba->hba_flag |= HBA_ERATT_HANDLED; in lpfc_sli4_eratt_read()
12463 phba->work_status[0] = in lpfc_sli4_eratt_read()
12464 readl(phba->sli4_hba.u.if_type2.ERR1regaddr); in lpfc_sli4_eratt_read()
12465 phba->work_status[1] = in lpfc_sli4_eratt_read()
12466 readl(phba->sli4_hba.u.if_type2.ERR2regaddr); in lpfc_sli4_eratt_read()
12468 if (phba->work_status[0] == in lpfc_sli4_eratt_read()
12470 phba->work_status[1] == SLIPORT_ERR2_REG_FW_RESTART) in lpfc_sli4_eratt_read()
12479 phba->work_status[0], in lpfc_sli4_eratt_read()
12480 phba->work_status[1]); in lpfc_sli4_eratt_read()
12481 phba->work_ha |= HA_ERATT; in lpfc_sli4_eratt_read()
12482 phba->hba_flag |= HBA_ERATT_HANDLED; in lpfc_sli4_eratt_read()
12498 * lpfc_sli_check_eratt - check error attention events
12515 if (phba->link_flag & LS_IGNORE_ERATT) in lpfc_sli_check_eratt()
12519 spin_lock_irq(&phba->hbalock); in lpfc_sli_check_eratt()
12520 if (phba->hba_flag & HBA_ERATT_HANDLED) { in lpfc_sli_check_eratt()
12522 spin_unlock_irq(&phba->hbalock); in lpfc_sli_check_eratt()
12530 if (unlikely(phba->hba_flag & DEFER_ERATT)) { in lpfc_sli_check_eratt()
12531 spin_unlock_irq(&phba->hbalock); in lpfc_sli_check_eratt()
12536 if (unlikely(pci_channel_offline(phba->pcidev))) { in lpfc_sli_check_eratt()
12537 spin_unlock_irq(&phba->hbalock); in lpfc_sli_check_eratt()
12541 switch (phba->sli_rev) { in lpfc_sli_check_eratt()
12554 phba->sli_rev); in lpfc_sli_check_eratt()
12558 spin_unlock_irq(&phba->hbalock); in lpfc_sli_check_eratt()
12564 * lpfc_intr_state_check - Check device state for interrupt handling
12571 * interrupt should be handled, otherwise -EIO.
12577 if (unlikely(pci_channel_offline(phba->pcidev))) in lpfc_intr_state_check()
12578 return -EIO; in lpfc_intr_state_check()
12581 phba->sli.slistat.sli_intr++; in lpfc_intr_state_check()
12584 if (unlikely(phba->link_state < LPFC_LINK_DOWN)) in lpfc_intr_state_check()
12585 return -EIO; in lpfc_intr_state_check()
12591 * lpfc_sli_sp_intr_handler - Slow-path interrupt handler to SLI-3 device
12596 * service routine when device with SLI-3 interface spec is enabled with
12597 * MSI-X multi-message interrupt mode and there are slow-path events in
12598 * the HBA. However, when the device is enabled with either MSI or Pin-IRQ
12599 * interrupt mode, this function is called as part of the device-level
12639 * individual interrupt handler in MSI-X multi-message interrupt mode in lpfc_sli_sp_intr_handler()
12641 if (phba->intr_type == MSIX) { in lpfc_sli_sp_intr_handler()
12645 /* Need to read HA REG for slow-path events */ in lpfc_sli_sp_intr_handler()
12646 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_sp_intr_handler()
12647 if (lpfc_readl(phba->HAregaddr, &ha_copy)) in lpfc_sli_sp_intr_handler()
12652 if (phba->link_flag & LS_IGNORE_ERATT) in lpfc_sli_sp_intr_handler()
12656 if (phba->hba_flag & HBA_ERATT_HANDLED) in lpfc_sli_sp_intr_handler()
12661 phba->hba_flag |= HBA_ERATT_HANDLED; in lpfc_sli_sp_intr_handler()
12668 if (unlikely(phba->hba_flag & DEFER_ERATT)) { in lpfc_sli_sp_intr_handler()
12669 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_sp_intr_handler()
12673 /* Clear up only attention source related to slow-path */ in lpfc_sli_sp_intr_handler()
12674 if (lpfc_readl(phba->HCregaddr, &hc_copy)) in lpfc_sli_sp_intr_handler()
12679 phba->HCregaddr); in lpfc_sli_sp_intr_handler()
12681 phba->HAregaddr); in lpfc_sli_sp_intr_handler()
12682 writel(hc_copy, phba->HCregaddr); in lpfc_sli_sp_intr_handler()
12683 readl(phba->HAregaddr); /* flush */ in lpfc_sli_sp_intr_handler()
12684 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_sp_intr_handler()
12686 ha_copy = phba->ha_copy; in lpfc_sli_sp_intr_handler()
12688 work_ha_copy = ha_copy & phba->work_ha_mask; in lpfc_sli_sp_intr_handler()
12692 if (phba->sli.sli_flag & LPFC_PROCESS_LA) { in lpfc_sli_sp_intr_handler()
12697 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_sp_intr_handler()
12698 phba->sli.sli_flag &= ~LPFC_PROCESS_LA; in lpfc_sli_sp_intr_handler()
12699 if (lpfc_readl(phba->HCregaddr, &control)) in lpfc_sli_sp_intr_handler()
12702 writel(control, phba->HCregaddr); in lpfc_sli_sp_intr_handler()
12703 readl(phba->HCregaddr); /* flush */ in lpfc_sli_sp_intr_handler()
12704 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_sp_intr_handler()
12719 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_sp_intr_handler()
12720 if (lpfc_readl(phba->HCregaddr, &control)) in lpfc_sli_sp_intr_handler()
12726 (uint32_t)phba->sli.slistat.sli_intr); in lpfc_sli_sp_intr_handler()
12732 phba->work_ha, work_ha_copy, in lpfc_sli_sp_intr_handler()
12734 &phba->work_waitq)); in lpfc_sli_sp_intr_handler()
12738 writel(control, phba->HCregaddr); in lpfc_sli_sp_intr_handler()
12739 readl(phba->HCregaddr); /* flush */ in lpfc_sli_sp_intr_handler()
12745 phba->work_ha, work_ha_copy, in lpfc_sli_sp_intr_handler()
12747 &phba->work_waitq)); in lpfc_sli_sp_intr_handler()
12749 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_sp_intr_handler()
12752 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_sp_intr_handler()
12760 if ((HS_FFER1 & phba->work_hs) && in lpfc_sli_sp_intr_handler()
12763 phba->work_hs)) { in lpfc_sli_sp_intr_handler()
12764 phba->hba_flag |= DEFER_ERATT; in lpfc_sli_sp_intr_handler()
12766 writel(0, phba->HCregaddr); in lpfc_sli_sp_intr_handler()
12767 readl(phba->HCregaddr); in lpfc_sli_sp_intr_handler()
12771 if ((work_ha_copy & HA_MBATT) && (phba->sli.mbox_active)) { in lpfc_sli_sp_intr_handler()
12772 pmb = phba->sli.mbox_active; in lpfc_sli_sp_intr_handler()
12773 pmbox = &pmb->u.mb; in lpfc_sli_sp_intr_handler()
12774 mbox = phba->mbox; in lpfc_sli_sp_intr_handler()
12775 vport = pmb->vport; in lpfc_sli_sp_intr_handler()
12779 if (pmbox->mbxOwner != OWN_HOST) { in lpfc_sli_sp_intr_handler()
12780 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_sp_intr_handler()
12782 * Stray Mailbox Interrupt, mbxCommand <cmd> in lpfc_sli_sp_intr_handler()
12786 "(%d):0304 Stray Mailbox " in lpfc_sli_sp_intr_handler()
12789 (vport ? vport->vpi : 0), in lpfc_sli_sp_intr_handler()
12790 pmbox->mbxCommand, in lpfc_sli_sp_intr_handler()
12791 pmbox->mbxStatus); in lpfc_sli_sp_intr_handler()
12792 /* clear mailbox attention bit */ in lpfc_sli_sp_intr_handler()
12795 phba->sli.mbox_active = NULL; in lpfc_sli_sp_intr_handler()
12796 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_sp_intr_handler()
12797 phba->last_completion_time = jiffies; in lpfc_sli_sp_intr_handler()
12798 del_timer(&phba->sli.mbox_tmo); in lpfc_sli_sp_intr_handler()
12799 if (pmb->mbox_cmpl) { in lpfc_sli_sp_intr_handler()
12802 if (pmb->out_ext_byte_len && in lpfc_sli_sp_intr_handler()
12803 pmb->ctx_buf) in lpfc_sli_sp_intr_handler()
12805 phba->mbox_ext, in lpfc_sli_sp_intr_handler()
12806 pmb->ctx_buf, in lpfc_sli_sp_intr_handler()
12807 pmb->out_ext_byte_len); in lpfc_sli_sp_intr_handler()
12809 if (pmb->mbox_flag & LPFC_MBX_IMED_UNREG) { in lpfc_sli_sp_intr_handler()
12810 pmb->mbox_flag &= ~LPFC_MBX_IMED_UNREG; in lpfc_sli_sp_intr_handler()
12816 (uint32_t)pmbox->mbxStatus, in lpfc_sli_sp_intr_handler()
12817 pmbox->un.varWords[0], 0); in lpfc_sli_sp_intr_handler()
12819 if (!pmbox->mbxStatus) { in lpfc_sli_sp_intr_handler()
12821 (pmb->ctx_buf); in lpfc_sli_sp_intr_handler()
12823 pmb->ctx_ndlp; in lpfc_sli_sp_intr_handler()
12831 vport->vpi, in lpfc_sli_sp_intr_handler()
12832 pmbox->un.varWords[0], in lpfc_sli_sp_intr_handler()
12834 pmb->mbox_cmpl = in lpfc_sli_sp_intr_handler()
12836 pmb->ctx_buf = mp; in lpfc_sli_sp_intr_handler()
12837 pmb->ctx_ndlp = ndlp; in lpfc_sli_sp_intr_handler()
12838 pmb->vport = vport; in lpfc_sli_sp_intr_handler()
12853 &phba->pport->work_port_lock, in lpfc_sli_sp_intr_handler()
12855 phba->pport->work_port_events &= in lpfc_sli_sp_intr_handler()
12858 &phba->pport->work_port_lock, in lpfc_sli_sp_intr_handler()
12863 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_sp_intr_handler()
12866 (phba->sli.mbox_active == NULL)) { in lpfc_sli_sp_intr_handler()
12868 /* Process next mailbox command if there is one */ in lpfc_sli_sp_intr_handler()
12880 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_sp_intr_handler()
12881 phba->work_ha |= work_ha_copy; in lpfc_sli_sp_intr_handler()
12882 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_sp_intr_handler()
12887 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_sp_intr_handler()
12893 * lpfc_sli_fp_intr_handler - Fast-path interrupt handler to SLI-3 device.
12898 * service routine when device with SLI-3 interface spec is enabled with
12899 * MSI-X multi-message interrupt mode and there is a fast-path FCP IOCB
12901 * MSI or Pin-IRQ interrupt mode, this function is called as part of the
12902 * device-level interrupt handler. When the PCI slot is in error recovery
12904 * process the interrupt. The SCSI FCP fast-path ring event are handled in
12930 * individual interrupt handler in MSI-X multi-message interrupt mode in lpfc_sli_fp_intr_handler()
12932 if (phba->intr_type == MSIX) { in lpfc_sli_fp_intr_handler()
12937 if (lpfc_readl(phba->HAregaddr, &ha_copy)) in lpfc_sli_fp_intr_handler()
12939 /* Clear up only attention source related to fast-path */ in lpfc_sli_fp_intr_handler()
12940 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_fp_intr_handler()
12945 if (unlikely(phba->hba_flag & DEFER_ERATT)) { in lpfc_sli_fp_intr_handler()
12946 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_fp_intr_handler()
12950 phba->HAregaddr); in lpfc_sli_fp_intr_handler()
12951 readl(phba->HAregaddr); /* flush */ in lpfc_sli_fp_intr_handler()
12952 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_fp_intr_handler()
12954 ha_copy = phba->ha_copy; in lpfc_sli_fp_intr_handler()
12959 ha_copy &= ~(phba->work_ha_mask); in lpfc_sli_fp_intr_handler()
12963 pring = &phba->sli.sli3_ring[LPFC_FCP_RING]; in lpfc_sli_fp_intr_handler()
12967 if (phba->cfg_multi_ring_support == 2) { in lpfc_sli_fp_intr_handler()
12976 &phba->sli.sli3_ring[LPFC_EXTRA_RING], in lpfc_sli_fp_intr_handler()
12984 * lpfc_sli_intr_handler - Device-level interrupt handler to SLI-3 device
12988 * This function is the HBA device-level interrupt handler to device with
12989 * SLI-3 interface spec, called from the PCI layer when either MSI or
12990 * Pin-IRQ interrupt mode is enabled and there is an event in the HBA which
12991 * requires driver attention. This function invokes the slow-path interrupt
12992 * attention handling function and fast-path interrupt attention handling
13021 spin_lock(&phba->hbalock); in lpfc_sli_intr_handler()
13022 if (lpfc_readl(phba->HAregaddr, &phba->ha_copy)) { in lpfc_sli_intr_handler()
13023 spin_unlock(&phba->hbalock); in lpfc_sli_intr_handler()
13027 if (unlikely(!phba->ha_copy)) { in lpfc_sli_intr_handler()
13028 spin_unlock(&phba->hbalock); in lpfc_sli_intr_handler()
13030 } else if (phba->ha_copy & HA_ERATT) { in lpfc_sli_intr_handler()
13031 if (phba->hba_flag & HBA_ERATT_HANDLED) in lpfc_sli_intr_handler()
13033 phba->ha_copy &= ~HA_ERATT; in lpfc_sli_intr_handler()
13036 phba->hba_flag |= HBA_ERATT_HANDLED; in lpfc_sli_intr_handler()
13042 if (unlikely(phba->hba_flag & DEFER_ERATT)) { in lpfc_sli_intr_handler()
13043 spin_unlock(&phba->hbalock); in lpfc_sli_intr_handler()
13048 if (lpfc_readl(phba->HCregaddr, &hc_copy)) { in lpfc_sli_intr_handler()
13049 spin_unlock(&phba->hbalock); in lpfc_sli_intr_handler()
13054 phba->HCregaddr); in lpfc_sli_intr_handler()
13055 writel((phba->ha_copy & ~(HA_LATT | HA_ERATT)), phba->HAregaddr); in lpfc_sli_intr_handler()
13056 writel(hc_copy, phba->HCregaddr); in lpfc_sli_intr_handler()
13057 readl(phba->HAregaddr); /* flush */ in lpfc_sli_intr_handler()
13058 spin_unlock(&phba->hbalock); in lpfc_sli_intr_handler()
13061 * Invokes slow-path host attention interrupt handling as appropriate. in lpfc_sli_intr_handler()
13064 /* status of events with mailbox and link attention */ in lpfc_sli_intr_handler()
13065 status1 = phba->ha_copy & (HA_MBATT | HA_LATT | HA_ERATT); in lpfc_sli_intr_handler()
13068 status2 = (phba->ha_copy & (HA_RXMASK << (4*LPFC_ELS_RING))); in lpfc_sli_intr_handler()
13077 * Invoke fast-path host attention interrupt handling as appropriate. in lpfc_sli_intr_handler()
13081 status1 = (phba->ha_copy & (HA_RXMASK << (4*LPFC_FCP_RING))); in lpfc_sli_intr_handler()
13085 if (phba->cfg_multi_ring_support == 2) { in lpfc_sli_intr_handler()
13086 status2 = (phba->ha_copy & (HA_RXMASK << (4*LPFC_EXTRA_RING))); in lpfc_sli_intr_handler()
13096 /* Return device-level interrupt handling status */ in lpfc_sli_intr_handler()
13101 * lpfc_sli4_els_xri_abort_event_proc - Process els xri abort event
13113 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_els_xri_abort_event_proc()
13114 phba->hba_flag &= ~ELS_XRI_ABORT_EVENT; in lpfc_sli4_els_xri_abort_event_proc()
13115 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_els_xri_abort_event_proc()
13118 spin_lock_irqsave(&phba->sli4_hba.els_xri_abrt_list_lock, iflags); in lpfc_sli4_els_xri_abort_event_proc()
13119 while (!list_empty(&phba->sli4_hba.sp_els_xri_aborted_work_queue)) { in lpfc_sli4_els_xri_abort_event_proc()
13121 list_remove_head(&phba->sli4_hba.sp_els_xri_aborted_work_queue, in lpfc_sli4_els_xri_abort_event_proc()
13123 spin_unlock_irqrestore(&phba->sli4_hba.els_xri_abrt_list_lock, in lpfc_sli4_els_xri_abort_event_proc()
13126 lpfc_sli4_els_xri_aborted(phba, &cq_event->cqe.wcqe_axri); in lpfc_sli4_els_xri_abort_event_proc()
13130 spin_lock_irqsave(&phba->sli4_hba.els_xri_abrt_list_lock, in lpfc_sli4_els_xri_abort_event_proc()
13133 spin_unlock_irqrestore(&phba->sli4_hba.els_xri_abrt_list_lock, iflags); in lpfc_sli4_els_xri_abort_event_proc()
13137 * lpfc_sli4_iocb_param_transfer - Transfer pIocbOut and cmpl status to pIocbIn
13161 sizeof(struct lpfc_iocbq) - offset); in lpfc_sli4_iocb_param_transfer()
13164 pIocbIn->iocb.ulpStatus = (status & LPFC_IOCB_STATUS_MASK); in lpfc_sli4_iocb_param_transfer()
13165 if (pIocbOut->iocb_flag & LPFC_IO_FCP) in lpfc_sli4_iocb_param_transfer()
13166 if (pIocbIn->iocb.ulpStatus == IOSTAT_FCP_RSP_ERROR) in lpfc_sli4_iocb_param_transfer()
13167 pIocbIn->iocb.un.fcpi.fcpi_parm = in lpfc_sli4_iocb_param_transfer()
13168 pIocbOut->iocb.un.fcpi.fcpi_parm - in lpfc_sli4_iocb_param_transfer()
13169 wcqe->total_data_placed; in lpfc_sli4_iocb_param_transfer()
13171 pIocbIn->iocb.un.ulpWord[4] = wcqe->parameter; in lpfc_sli4_iocb_param_transfer()
13173 pIocbIn->iocb.un.ulpWord[4] = wcqe->parameter; in lpfc_sli4_iocb_param_transfer()
13174 switch (pIocbOut->iocb.ulpCommand) { in lpfc_sli4_iocb_param_transfer()
13176 dmabuf = (struct lpfc_dmabuf *)pIocbOut->context3; in lpfc_sli4_iocb_param_transfer()
13177 bpl = (struct ulp_bde64 *)dmabuf->virt; in lpfc_sli4_iocb_param_transfer()
13183 if (!pIocbOut->context3) in lpfc_sli4_iocb_param_transfer()
13185 numBdes = pIocbOut->iocb.un.genreq64.bdl.bdeSize/ in lpfc_sli4_iocb_param_transfer()
13187 dmabuf = (struct lpfc_dmabuf *)pIocbOut->context3; in lpfc_sli4_iocb_param_transfer()
13188 bpl = (struct ulp_bde64 *)dmabuf->virt; in lpfc_sli4_iocb_param_transfer()
13196 max_response = wcqe->total_data_placed; in lpfc_sli4_iocb_param_transfer()
13199 if (max_response < wcqe->total_data_placed) in lpfc_sli4_iocb_param_transfer()
13200 pIocbIn->iocb.un.genreq64.bdl.bdeSize = max_response; in lpfc_sli4_iocb_param_transfer()
13202 pIocbIn->iocb.un.genreq64.bdl.bdeSize = in lpfc_sli4_iocb_param_transfer()
13203 wcqe->total_data_placed; in lpfc_sli4_iocb_param_transfer()
13208 pIocbIn->iocb.ulpStatus = IOSTAT_LOCAL_REJECT; in lpfc_sli4_iocb_param_transfer()
13211 pIocbIn->iocb.un.ulpWord[4] = IOERR_RX_DMA_FAILED; in lpfc_sli4_iocb_param_transfer()
13213 pIocbIn->iocb.un.ulpWord[4] = IOERR_TX_DMA_FAILED; in lpfc_sli4_iocb_param_transfer()
13215 pIocbIn->iocb.unsli3.sli3_bg.bgstat = 0; in lpfc_sli4_iocb_param_transfer()
13217 pIocbIn->iocb.unsli3.sli3_bg.bgstat |= in lpfc_sli4_iocb_param_transfer()
13220 pIocbIn->iocb.unsli3.sli3_bg.bgstat |= in lpfc_sli4_iocb_param_transfer()
13223 pIocbIn->iocb.unsli3.sli3_bg.bgstat |= in lpfc_sli4_iocb_param_transfer()
13228 pIocbIn->iocb.unsli3.sli3_bg.bgstat |= in lpfc_sli4_iocb_param_transfer()
13230 pIocbIn->iocb.unsli3.sli3_bg.bghm = in lpfc_sli4_iocb_param_transfer()
13231 wcqe->total_data_placed; in lpfc_sli4_iocb_param_transfer()
13238 if (!pIocbIn->iocb.unsli3.sli3_bg.bgstat) in lpfc_sli4_iocb_param_transfer()
13239 pIocbIn->iocb.unsli3.sli3_bg.bgstat |= in lpfc_sli4_iocb_param_transfer()
13246 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_iocb_param_transfer()
13247 pIocbIn->iocb_flag |= LPFC_EXCHANGE_BUSY; in lpfc_sli4_iocb_param_transfer()
13248 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_iocb_param_transfer()
13253 * lpfc_sli4_els_wcqe_to_rspiocbq - Get response iocbq from els wcqe
13255 * @irspiocbq: Pointer to work-queue completion queue entry.
13257 * This routine handles an ELS work-queue completion event and construct
13276 wcqe = &irspiocbq->cq_event.cqe.wcqe_cmpl; in lpfc_sli4_els_wcqe_to_rspiocbq()
13277 pring->stats.iocb_event++; in lpfc_sli4_els_wcqe_to_rspiocbq()
13285 wcqe->word0, wcqe->total_data_placed, in lpfc_sli4_els_wcqe_to_rspiocbq()
13286 wcqe->parameter, wcqe->word3); in lpfc_sli4_els_wcqe_to_rspiocbq()
13291 spin_lock_irqsave(&pring->ring_lock, iflags); in lpfc_sli4_els_wcqe_to_rspiocbq()
13294 spin_unlock_irqrestore(&pring->ring_lock, iflags); in lpfc_sli4_els_wcqe_to_rspiocbq()
13316 memcpy(&cq_event->cqe, entry, size); in lpfc_cq_event_setup()
13321 * lpfc_sli4_sp_handle_async_event - Handle an asynchronous event
13323 * @mcqe: Pointer to mailbox completion queue entry.
13325 * This routine process a mailbox completion queue entry with asynchronous
13338 "word2:x%x, word3:x%x\n", mcqe->word0, in lpfc_sli4_sp_handle_async_event()
13339 mcqe->mcqe_tag0, mcqe->mcqe_tag1, mcqe->trailer); in lpfc_sli4_sp_handle_async_event()
13345 spin_lock_irqsave(&phba->sli4_hba.asynce_list_lock, iflags); in lpfc_sli4_sp_handle_async_event()
13346 list_add_tail(&cq_event->list, &phba->sli4_hba.sp_asynce_work_queue); in lpfc_sli4_sp_handle_async_event()
13347 spin_unlock_irqrestore(&phba->sli4_hba.asynce_list_lock, iflags); in lpfc_sli4_sp_handle_async_event()
13350 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_async_event()
13351 phba->hba_flag |= ASYNC_EVENT; in lpfc_sli4_sp_handle_async_event()
13352 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_async_event()
13358 * lpfc_sli4_sp_handle_mbox_event - Handle a mailbox completion event
13360 * @mcqe: Pointer to mailbox completion queue entry.
13362 * This routine process a mailbox completion queue entry with mailbox
13381 /* If not a mailbox complete MCQE, out by checking mailbox consume */ in lpfc_sli4_sp_handle_mbox_event()
13386 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_mbox_event()
13387 pmb = phba->sli.mbox_active; in lpfc_sli4_sp_handle_mbox_event()
13391 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_mbox_event()
13394 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_mbox_event()
13395 mqe = &pmb->u.mqe; in lpfc_sli4_sp_handle_mbox_event()
13396 pmbox = (MAILBOX_t *)&pmb->u.mqe; in lpfc_sli4_sp_handle_mbox_event()
13397 mbox = phba->mbox; in lpfc_sli4_sp_handle_mbox_event()
13398 vport = pmb->vport; in lpfc_sli4_sp_handle_mbox_event()
13401 phba->last_completion_time = jiffies; in lpfc_sli4_sp_handle_mbox_event()
13402 del_timer(&phba->sli.mbox_tmo); in lpfc_sli4_sp_handle_mbox_event()
13404 /* Move mbox data to caller's mailbox region, do endian swapping */ in lpfc_sli4_sp_handle_mbox_event()
13405 if (pmb->mbox_cmpl && mbox) in lpfc_sli4_sp_handle_mbox_event()
13418 if (pmb->mbox_flag & LPFC_MBX_IMED_UNREG) { in lpfc_sli4_sp_handle_mbox_event()
13419 pmb->mbox_flag &= ~LPFC_MBX_IMED_UNREG; in lpfc_sli4_sp_handle_mbox_event()
13423 pmbox->un.varWords[0], 0); in lpfc_sli4_sp_handle_mbox_event()
13425 mp = (struct lpfc_dmabuf *)(pmb->ctx_buf); in lpfc_sli4_sp_handle_mbox_event()
13426 ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp; in lpfc_sli4_sp_handle_mbox_event()
13430 lpfc_unreg_login(phba, vport->vpi, in lpfc_sli4_sp_handle_mbox_event()
13431 pmbox->un.varWords[0], pmb); in lpfc_sli4_sp_handle_mbox_event()
13432 pmb->mbox_cmpl = lpfc_mbx_cmpl_dflt_rpi; in lpfc_sli4_sp_handle_mbox_event()
13433 pmb->ctx_buf = mp; in lpfc_sli4_sp_handle_mbox_event()
13434 pmb->ctx_ndlp = ndlp; in lpfc_sli4_sp_handle_mbox_event()
13435 pmb->vport = vport; in lpfc_sli4_sp_handle_mbox_event()
13446 spin_lock_irqsave(&phba->pport->work_port_lock, iflags); in lpfc_sli4_sp_handle_mbox_event()
13447 phba->pport->work_port_events &= ~WORKER_MBOX_TMO; in lpfc_sli4_sp_handle_mbox_event()
13448 spin_unlock_irqrestore(&phba->pport->work_port_lock, iflags); in lpfc_sli4_sp_handle_mbox_event()
13450 /* There is mailbox completion work to do */ in lpfc_sli4_sp_handle_mbox_event()
13451 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_mbox_event()
13453 phba->work_ha |= HA_MBATT; in lpfc_sli4_sp_handle_mbox_event()
13454 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_mbox_event()
13458 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_mbox_event()
13459 /* Release the mailbox command posting token */ in lpfc_sli4_sp_handle_mbox_event()
13460 phba->sli.sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; in lpfc_sli4_sp_handle_mbox_event()
13461 /* Setting active mailbox pointer need to be in sync to flag clear */ in lpfc_sli4_sp_handle_mbox_event()
13462 phba->sli.mbox_active = NULL; in lpfc_sli4_sp_handle_mbox_event()
13464 lpfc_sli4_mq_release(phba->sli4_hba.mbx_wq); in lpfc_sli4_sp_handle_mbox_event()
13465 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_mbox_event()
13466 /* Wake up worker thread to post the next pending mailbox command */ in lpfc_sli4_sp_handle_mbox_event()
13471 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_mbox_event()
13473 lpfc_sli4_mq_release(phba->sli4_hba.mbx_wq); in lpfc_sli4_sp_handle_mbox_event()
13474 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_mbox_event()
13479 * lpfc_sli4_sp_handle_mcqe - Process a mailbox completion queue entry
13482 * @cqe: Pointer to mailbox completion queue entry.
13484 * This routine process a mailbox completion queue entry, it invokes the
13485 * proper mailbox complete handling or asynchronous event handling routine
13497 cq->CQ_mbox++; in lpfc_sli4_sp_handle_mcqe()
13499 /* Copy the mailbox MCQE and convert endian order as needed */ in lpfc_sli4_sp_handle_mcqe()
13511 * lpfc_sli4_sp_handle_els_wcqe - Handle els work-queue completion event
13514 * @wcqe: Pointer to work-queue completion queue entry.
13516 * This routine handles an ELS work-queue completion event.
13526 struct lpfc_sli_ring *pring = cq->pring; in lpfc_sli4_sp_handle_els_wcqe()
13537 wcqe->word0, wcqe->total_data_placed, in lpfc_sli4_sp_handle_els_wcqe()
13538 wcqe->parameter, wcqe->word3); in lpfc_sli4_sp_handle_els_wcqe()
13544 if (!list_empty(&pring->txq)) in lpfc_sli4_sp_handle_els_wcqe()
13546 if (!list_empty(&pring->txcmplq)) in lpfc_sli4_sp_handle_els_wcqe()
13551 txq_cnt, phba->iocb_cnt, in lpfc_sli4_sp_handle_els_wcqe()
13556 /* Save off the slow-path queue event for work thread to process */ in lpfc_sli4_sp_handle_els_wcqe()
13557 memcpy(&irspiocbq->cq_event.cqe.wcqe_cmpl, wcqe, sizeof(*wcqe)); in lpfc_sli4_sp_handle_els_wcqe()
13558 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_els_wcqe()
13559 list_add_tail(&irspiocbq->cq_event.list, in lpfc_sli4_sp_handle_els_wcqe()
13560 &phba->sli4_hba.sp_queue_event); in lpfc_sli4_sp_handle_els_wcqe()
13561 phba->hba_flag |= HBA_SP_QUEUE_EVT; in lpfc_sli4_sp_handle_els_wcqe()
13562 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_els_wcqe()
13568 * lpfc_sli4_sp_handle_rel_wcqe - Handle slow-path WQ entry consumed event
13570 * @wcqe: Pointer to work-queue completion queue entry.
13572 * This routine handles slow-path WQ entry consumed event by invoking the
13573 * proper WQ release routine to the slow-path WQ.
13580 if (unlikely(!phba->sli4_hba.els_wq)) in lpfc_sli4_sp_handle_rel_wcqe()
13582 /* Check for the slow-path ELS work queue */ in lpfc_sli4_sp_handle_rel_wcqe()
13583 if (bf_get(lpfc_wcqe_r_wq_id, wcqe) == phba->sli4_hba.els_wq->queue_id) in lpfc_sli4_sp_handle_rel_wcqe()
13584 lpfc_sli4_wq_release(phba->sli4_hba.els_wq, in lpfc_sli4_sp_handle_rel_wcqe()
13588 "2579 Slow-path wqe consume event carries " in lpfc_sli4_sp_handle_rel_wcqe()
13589 "miss-matched qid: wcqe-qid=x%x, sp-qid=x%x\n", in lpfc_sli4_sp_handle_rel_wcqe()
13591 phba->sli4_hba.els_wq->queue_id); in lpfc_sli4_sp_handle_rel_wcqe()
13595 * lpfc_sli4_sp_handle_abort_xri_wcqe - Handle a xri abort event
13598 * @wcqe: Pointer to work-queue completion queue entry.
13613 switch (cq->subtype) { in lpfc_sli4_sp_handle_abort_xri_wcqe()
13615 lpfc_sli4_io_xri_aborted(phba, wcqe, cq->hdwq); in lpfc_sli4_sp_handle_abort_xri_wcqe()
13616 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_sp_handle_abort_xri_wcqe()
13618 if (phba->nvmet_support) in lpfc_sli4_sp_handle_abort_xri_wcqe()
13630 cq_event->hdwq = cq->hdwq; in lpfc_sli4_sp_handle_abort_xri_wcqe()
13631 spin_lock_irqsave(&phba->sli4_hba.els_xri_abrt_list_lock, in lpfc_sli4_sp_handle_abort_xri_wcqe()
13633 list_add_tail(&cq_event->list, in lpfc_sli4_sp_handle_abort_xri_wcqe()
13634 &phba->sli4_hba.sp_els_xri_aborted_work_queue); in lpfc_sli4_sp_handle_abort_xri_wcqe()
13636 phba->hba_flag |= ELS_XRI_ABORT_EVENT; in lpfc_sli4_sp_handle_abort_xri_wcqe()
13637 spin_unlock_irqrestore(&phba->sli4_hba.els_xri_abrt_list_lock, in lpfc_sli4_sp_handle_abort_xri_wcqe()
13645 cq->subtype, wcqe->word0, wcqe->parameter, in lpfc_sli4_sp_handle_abort_xri_wcqe()
13646 wcqe->word2, wcqe->word3); in lpfc_sli4_sp_handle_abort_xri_wcqe()
13656 * lpfc_sli4_sp_handle_rcqe - Process a receive-queue completion queue entry
13658 * @rcqe: Pointer to receive-queue completion queue entry.
13660 * This routine process a receive-queue completion queue entry.
13669 struct lpfc_queue *hrq = phba->sli4_hba.hdr_rq; in lpfc_sli4_sp_handle_rcqe()
13670 struct lpfc_queue *drq = phba->sli4_hba.dat_rq; in lpfc_sli4_sp_handle_rcqe()
13684 if (rq_id != hrq->queue_id) in lpfc_sli4_sp_handle_rcqe()
13694 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_rcqe()
13696 dma_buf = lpfc_sli_hbqbuf_get(&phba->hbqs[0].hbq_buffer_list); in lpfc_sli4_sp_handle_rcqe()
13698 hrq->RQ_no_buf_found++; in lpfc_sli4_sp_handle_rcqe()
13699 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_rcqe()
13702 hrq->RQ_rcv_buf++; in lpfc_sli4_sp_handle_rcqe()
13703 hrq->RQ_buf_posted--; in lpfc_sli4_sp_handle_rcqe()
13704 memcpy(&dma_buf->cq_event.cqe.rcqe_cmpl, rcqe, sizeof(*rcqe)); in lpfc_sli4_sp_handle_rcqe()
13706 fc_hdr = (struct fc_frame_header *)dma_buf->hbuf.virt; in lpfc_sli4_sp_handle_rcqe()
13708 if (fc_hdr->fh_r_ctl == FC_RCTL_MDS_DIAGS || in lpfc_sli4_sp_handle_rcqe()
13709 fc_hdr->fh_r_ctl == FC_RCTL_DD_UNSOL_DATA) { in lpfc_sli4_sp_handle_rcqe()
13710 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_rcqe()
13712 if (!(phba->pport->load_flag & FC_UNLOADING)) in lpfc_sli4_sp_handle_rcqe()
13713 lpfc_sli4_handle_mds_loopback(phba->pport, in lpfc_sli4_sp_handle_rcqe()
13716 lpfc_in_buf_free(phba, &dma_buf->dbuf); in lpfc_sli4_sp_handle_rcqe()
13721 list_add_tail(&dma_buf->cq_event.list, in lpfc_sli4_sp_handle_rcqe()
13722 &phba->sli4_hba.sp_queue_event); in lpfc_sli4_sp_handle_rcqe()
13724 phba->hba_flag |= HBA_SP_QUEUE_EVT; in lpfc_sli4_sp_handle_rcqe()
13725 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_rcqe()
13729 if (phba->nvmet_support) { in lpfc_sli4_sp_handle_rcqe()
13730 tgtp = phba->targetport->private; in lpfc_sli4_sp_handle_rcqe()
13734 status, hrq->RQ_buf_posted, in lpfc_sli4_sp_handle_rcqe()
13735 hrq->RQ_no_posted_buf, in lpfc_sli4_sp_handle_rcqe()
13736 atomic_read(&tgtp->rcv_fcp_cmd_in), in lpfc_sli4_sp_handle_rcqe()
13737 atomic_read(&tgtp->rcv_fcp_cmd_out), in lpfc_sli4_sp_handle_rcqe()
13738 atomic_read(&tgtp->xmt_fcp_release)); in lpfc_sli4_sp_handle_rcqe()
13743 hrq->RQ_no_posted_buf++; in lpfc_sli4_sp_handle_rcqe()
13745 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_rcqe()
13746 phba->hba_flag |= HBA_POST_RECEIVE_BUFFER; in lpfc_sli4_sp_handle_rcqe()
13747 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_rcqe()
13756 * lpfc_sli4_sp_handle_cqe - Process a slow path completion queue entry
13761 * This routine process a slow-path work-queue or receive queue completion queue
13780 phba->last_completion_time = jiffies; in lpfc_sli4_sp_handle_cqe()
13791 phba->last_completion_time = jiffies; in lpfc_sli4_sp_handle_cqe()
13798 phba->last_completion_time = jiffies; in lpfc_sli4_sp_handle_cqe()
13812 * lpfc_sli4_sp_handle_eqe - Process a slow-path event queue entry
13814 * @eqe: Pointer to fast-path event queue entry.
13815 * @speq: Pointer to slow-path event queue.
13817 * This routine process a event queue entry from the slow-path event queue.
13836 list_for_each_entry(childq, &speq->child_list, list) { in lpfc_sli4_sp_handle_eqe()
13837 if (childq->queue_id == cqid) { in lpfc_sli4_sp_handle_eqe()
13843 if (phba->sli.sli_flag & LPFC_SLI_ACTIVE) in lpfc_sli4_sp_handle_eqe()
13845 "0365 Slow-path CQ identifier " in lpfc_sli4_sp_handle_eqe()
13851 cq->assoc_qp = speq; in lpfc_sli4_sp_handle_eqe()
13854 ret = queue_work(phba->wq, &cq->spwork); in lpfc_sli4_sp_handle_eqe()
13856 ret = queue_work_on(cq->chann, phba->wq, &cq->spwork); in lpfc_sli4_sp_handle_eqe()
13862 cqid, cq->queue_id, raw_smp_processor_id()); in lpfc_sli4_sp_handle_eqe()
13866 * __lpfc_sli4_process_cq - Process elements of a CQ
13897 /* default - no reschedule */ in __lpfc_sli4_process_cq()
13900 if (cmpxchg(&cq->queue_claimed, 0, 1) != 0) in __lpfc_sli4_process_cq()
13904 cq->q_flag = 0; in __lpfc_sli4_process_cq()
13911 if (!(++count % cq->max_proc_limit)) in __lpfc_sli4_process_cq()
13914 if (!(count % cq->notify_interval)) { in __lpfc_sli4_process_cq()
13915 phba->sli4_hba.sli4_write_cq_db(phba, cq, consumed, in __lpfc_sli4_process_cq()
13918 cq->assoc_qp->q_flag |= HBA_EQ_DELAY_CHK; in __lpfc_sli4_process_cq()
13922 cq->q_flag |= HBA_NVMET_CQ_NOTIFY; in __lpfc_sli4_process_cq()
13926 if (count >= phba->cfg_cq_poll_threshold) { in __lpfc_sli4_process_cq()
13933 irq_poll_complete(&cq->iop); in __lpfc_sli4_process_cq()
13936 if (count > cq->CQ_max_cqe) in __lpfc_sli4_process_cq()
13937 cq->CQ_max_cqe = count; in __lpfc_sli4_process_cq()
13939 cq->assoc_qp->EQ_cqe_cnt += count; in __lpfc_sli4_process_cq()
13945 "qid=%d\n", cq->queue_id); in __lpfc_sli4_process_cq()
13947 xchg(&cq->queue_claimed, 0); in __lpfc_sli4_process_cq()
13950 phba->sli4_hba.sli4_write_cq_db(phba, cq, consumed, in __lpfc_sli4_process_cq()
13957 * lpfc_sli4_sp_process_cq - Process a slow-path event queue entry
13966 * the second is the delay parameter. If non-zero, rather than rearming
13974 struct lpfc_hba *phba = cq->phba; in __lpfc_sli4_sp_process_cq()
13980 switch (cq->type) { in __lpfc_sli4_sp_process_cq()
13987 if (cq->subtype == LPFC_IO) in __lpfc_sli4_sp_process_cq()
13999 cq->type); in __lpfc_sli4_sp_process_cq()
14005 ret = queue_delayed_work(phba->wq, &cq->sched_spwork, in __lpfc_sli4_sp_process_cq()
14008 ret = queue_delayed_work_on(cq->chann, phba->wq, in __lpfc_sli4_sp_process_cq()
14009 &cq->sched_spwork, delay); in __lpfc_sli4_sp_process_cq()
14014 cq->queue_id, cq->chann); in __lpfc_sli4_sp_process_cq()
14023 * lpfc_sli4_sp_process_cq - slow-path work handler when started by
14027 * translates from the work handler and calls the slow-path handler.
14038 * lpfc_sli4_dly_sp_process_cq - slow-path work handler when started by timer
14041 * translates from the work handler and calls the slow-path handler.
14053 * lpfc_sli4_fp_handle_fcp_wcqe - Process fast-path work queue completion entry
14056 * @wcqe: Pointer to work-queue completion queue entry.
14058 * This routine process a fast-path work queue completion entry from fast-path
14065 struct lpfc_sli_ring *pring = cq->pring; in lpfc_sli4_fp_handle_fcp_wcqe()
14077 ((wcqe->parameter & IOERR_PARAM_MASK) == in lpfc_sli4_fp_handle_fcp_wcqe()
14079 phba->lpfc_rampdown_queue_depth(phba); in lpfc_sli4_fp_handle_fcp_wcqe()
14086 wcqe->word0, wcqe->total_data_placed, in lpfc_sli4_fp_handle_fcp_wcqe()
14087 wcqe->parameter, wcqe->word3); in lpfc_sli4_fp_handle_fcp_wcqe()
14091 spin_lock_irqsave(&pring->ring_lock, iflags); in lpfc_sli4_fp_handle_fcp_wcqe()
14092 pring->stats.iocb_event++; in lpfc_sli4_fp_handle_fcp_wcqe()
14093 spin_unlock_irqrestore(&pring->ring_lock, iflags); in lpfc_sli4_fp_handle_fcp_wcqe()
14104 cmdiocbq->isr_timestamp = cq->isr_timestamp; in lpfc_sli4_fp_handle_fcp_wcqe()
14106 if (cmdiocbq->iocb_cmpl == NULL) { in lpfc_sli4_fp_handle_fcp_wcqe()
14107 if (cmdiocbq->wqe_cmpl) { in lpfc_sli4_fp_handle_fcp_wcqe()
14108 if (cmdiocbq->iocb_flag & LPFC_DRIVER_ABORTED) { in lpfc_sli4_fp_handle_fcp_wcqe()
14109 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_fp_handle_fcp_wcqe()
14110 cmdiocbq->iocb_flag &= ~LPFC_DRIVER_ABORTED; in lpfc_sli4_fp_handle_fcp_wcqe()
14111 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_fp_handle_fcp_wcqe()
14115 (cmdiocbq->wqe_cmpl)(phba, cmdiocbq, wcqe); in lpfc_sli4_fp_handle_fcp_wcqe()
14128 if (cmdiocbq->iocb_flag & LPFC_DRIVER_ABORTED) { in lpfc_sli4_fp_handle_fcp_wcqe()
14129 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_fp_handle_fcp_wcqe()
14130 cmdiocbq->iocb_flag &= ~LPFC_DRIVER_ABORTED; in lpfc_sli4_fp_handle_fcp_wcqe()
14131 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_fp_handle_fcp_wcqe()
14135 (cmdiocbq->iocb_cmpl)(phba, cmdiocbq, &irspiocbq); in lpfc_sli4_fp_handle_fcp_wcqe()
14139 * lpfc_sli4_fp_handle_rel_wcqe - Handle fast-path WQ entry consumed event
14142 * @wcqe: Pointer to work-queue completion queue entry.
14144 * This routine handles an fast-path WQ entry consumed event by invoking the
14145 * proper WQ release routine to the slow-path WQ.
14155 /* Check for fast-path FCP work queue release */ in lpfc_sli4_fp_handle_rel_wcqe()
14157 list_for_each_entry(childwq, &cq->child_list, list) { in lpfc_sli4_fp_handle_rel_wcqe()
14158 if (childwq->queue_id == hba_wqid) { in lpfc_sli4_fp_handle_rel_wcqe()
14161 if (childwq->q_flag & HBA_NVMET_WQFULL) in lpfc_sli4_fp_handle_rel_wcqe()
14170 "2580 Fast-path wqe consume event carries " in lpfc_sli4_fp_handle_rel_wcqe()
14171 "miss-matched qid: wcqe-qid=x%x\n", hba_wqid); in lpfc_sli4_fp_handle_rel_wcqe()
14175 * lpfc_sli4_nvmet_handle_rcqe - Process a receive-queue completion queue entry
14178 * @rcqe: Pointer to receive-queue completion queue entry.
14180 * This routine process a receive-queue completion queue entry.
14198 if ((phba->nvmet_support == 0) || in lpfc_sli4_nvmet_handle_rcqe()
14199 (phba->sli4_hba.nvmet_cqset == NULL)) in lpfc_sli4_nvmet_handle_rcqe()
14202 idx = cq->queue_id - phba->sli4_hba.nvmet_cqset[0]->queue_id; in lpfc_sli4_nvmet_handle_rcqe()
14203 hrq = phba->sli4_hba.nvmet_mrq_hdr[idx]; in lpfc_sli4_nvmet_handle_rcqe()
14204 drq = phba->sli4_hba.nvmet_mrq_data[idx]; in lpfc_sli4_nvmet_handle_rcqe()
14215 if ((phba->nvmet_support == 0) || in lpfc_sli4_nvmet_handle_rcqe()
14216 (rq_id != hrq->queue_id)) in lpfc_sli4_nvmet_handle_rcqe()
14226 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_nvmet_handle_rcqe()
14230 hrq->RQ_no_buf_found++; in lpfc_sli4_nvmet_handle_rcqe()
14231 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_nvmet_handle_rcqe()
14234 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_nvmet_handle_rcqe()
14235 hrq->RQ_rcv_buf++; in lpfc_sli4_nvmet_handle_rcqe()
14236 hrq->RQ_buf_posted--; in lpfc_sli4_nvmet_handle_rcqe()
14237 fc_hdr = (struct fc_frame_header *)dma_buf->hbuf.virt; in lpfc_sli4_nvmet_handle_rcqe()
14240 fctl = (fc_hdr->fh_f_ctl[0] << 16 | in lpfc_sli4_nvmet_handle_rcqe()
14241 fc_hdr->fh_f_ctl[1] << 8 | in lpfc_sli4_nvmet_handle_rcqe()
14242 fc_hdr->fh_f_ctl[2]); in lpfc_sli4_nvmet_handle_rcqe()
14246 (fc_hdr->fh_seq_cnt != 0)) /* 0 byte swapped is still 0 */ in lpfc_sli4_nvmet_handle_rcqe()
14249 if (fc_hdr->fh_type == FC_TYPE_FCP) { in lpfc_sli4_nvmet_handle_rcqe()
14250 dma_buf->bytes_recv = bf_get(lpfc_rcqe_length, rcqe); in lpfc_sli4_nvmet_handle_rcqe()
14252 phba, idx, dma_buf, cq->isr_timestamp, in lpfc_sli4_nvmet_handle_rcqe()
14253 cq->q_flag & HBA_NVMET_CQ_NOTIFY); in lpfc_sli4_nvmet_handle_rcqe()
14257 lpfc_rq_buf_free(phba, &dma_buf->hbuf); in lpfc_sli4_nvmet_handle_rcqe()
14260 if (phba->nvmet_support) { in lpfc_sli4_nvmet_handle_rcqe()
14261 tgtp = phba->targetport->private; in lpfc_sli4_nvmet_handle_rcqe()
14265 status, hrq->RQ_buf_posted, in lpfc_sli4_nvmet_handle_rcqe()
14266 hrq->RQ_no_posted_buf, in lpfc_sli4_nvmet_handle_rcqe()
14267 atomic_read(&tgtp->rcv_fcp_cmd_in), in lpfc_sli4_nvmet_handle_rcqe()
14268 atomic_read(&tgtp->rcv_fcp_cmd_out), in lpfc_sli4_nvmet_handle_rcqe()
14269 atomic_read(&tgtp->xmt_fcp_release)); in lpfc_sli4_nvmet_handle_rcqe()
14274 hrq->RQ_no_posted_buf++; in lpfc_sli4_nvmet_handle_rcqe()
14283 * lpfc_sli4_fp_handle_cqe - Process fast-path work queue completion entry
14286 * @cqe: Pointer to fast-path completion queue entry.
14288 * This routine process a fast-path work queue completion entry from fast-path
14307 cq->CQ_wq++; in lpfc_sli4_fp_handle_cqe()
14309 phba->last_completion_time = jiffies; in lpfc_sli4_fp_handle_cqe()
14310 if (cq->subtype == LPFC_IO || cq->subtype == LPFC_NVME_LS) in lpfc_sli4_fp_handle_cqe()
14315 cq->CQ_release_wqe++; in lpfc_sli4_fp_handle_cqe()
14321 cq->CQ_xri_aborted++; in lpfc_sli4_fp_handle_cqe()
14323 phba->last_completion_time = jiffies; in lpfc_sli4_fp_handle_cqe()
14329 phba->last_completion_time = jiffies; in lpfc_sli4_fp_handle_cqe()
14330 if (cq->subtype == LPFC_NVMET) { in lpfc_sli4_fp_handle_cqe()
14345 * lpfc_sli4_sched_cq_work - Schedules cq work
14351 * cq->chann, then either schedules a softirq or queue_work to complete
14363 switch (cq->poll_mode) { in lpfc_sli4_sched_cq_work()
14365 irq_poll_sched(&cq->iop); in lpfc_sli4_sched_cq_work()
14370 ret = queue_work(phba->wq, &cq->irqwork); in lpfc_sli4_sched_cq_work()
14372 ret = queue_work_on(cq->chann, phba->wq, &cq->irqwork); in lpfc_sli4_sched_cq_work()
14377 cqid, cq->queue_id, in lpfc_sli4_sched_cq_work()
14383 * lpfc_sli4_hba_handle_eqe - Process a fast-path event queue entry
14386 * @eqe: Pointer to fast-path event queue entry.
14388 * This routine process a event queue entry from the fast-path event queue.
14400 uint32_t qidx = eq->hdwq; in lpfc_sli4_hba_handle_eqe()
14416 if (cqid <= phba->sli4_hba.cq_max) { in lpfc_sli4_hba_handle_eqe()
14417 cq = phba->sli4_hba.cq_lookup[cqid]; in lpfc_sli4_hba_handle_eqe()
14423 if (phba->cfg_nvmet_mrq && phba->sli4_hba.nvmet_cqset) { in lpfc_sli4_hba_handle_eqe()
14424 id = phba->sli4_hba.nvmet_cqset[0]->queue_id; in lpfc_sli4_hba_handle_eqe()
14425 if ((cqid >= id) && (cqid < (id + phba->cfg_nvmet_mrq))) { in lpfc_sli4_hba_handle_eqe()
14427 cq = phba->sli4_hba.nvmet_cqset[cqid - id]; in lpfc_sli4_hba_handle_eqe()
14432 if (phba->sli4_hba.nvmels_cq && in lpfc_sli4_hba_handle_eqe()
14433 (cqid == phba->sli4_hba.nvmels_cq->queue_id)) { in lpfc_sli4_hba_handle_eqe()
14435 cq = phba->sli4_hba.nvmels_cq; in lpfc_sli4_hba_handle_eqe()
14441 phba->sli4_hba.hdwq[qidx].hba_eq); in lpfc_sli4_hba_handle_eqe()
14446 if (unlikely(cqid != cq->queue_id)) { in lpfc_sli4_hba_handle_eqe()
14448 "0368 Miss-matched fast-path completion " in lpfc_sli4_hba_handle_eqe()
14450 cqid, cq->queue_id); in lpfc_sli4_hba_handle_eqe()
14456 if (phba->ktime_on) in lpfc_sli4_hba_handle_eqe()
14457 cq->isr_timestamp = ktime_get_ns(); in lpfc_sli4_hba_handle_eqe()
14459 cq->isr_timestamp = 0; in lpfc_sli4_hba_handle_eqe()
14465 * __lpfc_sli4_hba_process_cq - Process a fast-path event queue entry
14475 * the second is the delay parameter. If non-zero, rather than rearming
14484 struct lpfc_hba *phba = cq->phba; in __lpfc_sli4_hba_process_cq()
14495 ret = queue_delayed_work(phba->wq, &cq->sched_irqwork, in __lpfc_sli4_hba_process_cq()
14498 ret = queue_delayed_work_on(cq->chann, phba->wq, in __lpfc_sli4_hba_process_cq()
14499 &cq->sched_irqwork, delay); in __lpfc_sli4_hba_process_cq()
14504 cq->queue_id, cq->chann); in __lpfc_sli4_hba_process_cq()
14513 * lpfc_sli4_hba_process_cq - fast-path work handler when started by
14517 * translates from the work handler and calls the fast-path handler.
14528 * lpfc_sli4_hba_process_cq - fast-path work handler when started by timer
14531 * translates from the work handler and calls the fast-path handler.
14543 * lpfc_sli4_hba_intr_handler - HBA interrupt handler to SLI-4 device
14548 * service routine when device with SLI-4 interface spec is enabled with
14549 * MSI-X multi-message interrupt mode and there is a fast-path FCP IOCB
14551 * MSI or Pin-IRQ interrupt mode, this function is called as part of the
14552 * device-level interrupt handler. When the PCI slot is in error recovery
14554 * process the interrupt. The SCSI FCP fast-path ring event are handled in
14557 * the FCP EQ to FCP CQ are one-to-one map such that the FCP EQ index is
14581 phba = hba_eq_hdl->phba; in lpfc_sli4_hba_intr_handler()
14582 hba_eqidx = hba_eq_hdl->idx; in lpfc_sli4_hba_intr_handler()
14586 if (unlikely(!phba->sli4_hba.hdwq)) in lpfc_sli4_hba_intr_handler()
14590 fpeq = phba->sli4_hba.hba_eq_hdl[hba_eqidx].eq; in lpfc_sli4_hba_intr_handler()
14597 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli4_hba_intr_handler()
14598 if (phba->link_state < LPFC_LINK_DOWN) in lpfc_sli4_hba_intr_handler()
14601 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli4_hba_intr_handler()
14605 eqi = this_cpu_ptr(phba->sli4_hba.eq_info); in lpfc_sli4_hba_intr_handler()
14606 eqi->icnt++; in lpfc_sli4_hba_intr_handler()
14608 fpeq->last_cpu = raw_smp_processor_id(); in lpfc_sli4_hba_intr_handler()
14610 if (eqi->icnt > LPFC_EQD_ISR_TRIGGER && in lpfc_sli4_hba_intr_handler()
14611 fpeq->q_flag & HBA_EQ_DELAY_CHK && in lpfc_sli4_hba_intr_handler()
14612 phba->cfg_auto_imax && in lpfc_sli4_hba_intr_handler()
14613 fpeq->q_mode != LPFC_MAX_AUTO_EQ_DELAY && in lpfc_sli4_hba_intr_handler()
14614 phba->sli.sli_flag & LPFC_SLI_USE_EQDR) in lpfc_sli4_hba_intr_handler()
14621 fpeq->EQ_no_entry++; in lpfc_sli4_hba_intr_handler()
14622 if (phba->intr_type == MSIX) in lpfc_sli4_hba_intr_handler()
14623 /* MSI-X treated interrupt served as no EQ share INT */ in lpfc_sli4_hba_intr_handler()
14625 "0358 MSI-X interrupt with no EQE\n"); in lpfc_sli4_hba_intr_handler()
14627 /* Non MSI-X treated on interrupt as EQ share INT */ in lpfc_sli4_hba_intr_handler()
14635 * lpfc_sli4_intr_handler - Device-level interrupt handler for SLI-4 device
14639 * This function is the device-level interrupt handler to device with SLI-4
14640 * interface spec, called from the PCI layer when either MSI or Pin-IRQ
14642 * driver attention. This function invokes the slow-path interrupt attention
14643 * handling function and fast-path interrupt attention handling function in
14666 * Invoke fast-path host attention interrupt handling as appropriate. in lpfc_sli4_intr_handler()
14668 for (qidx = 0; qidx < phba->cfg_irq_chann; qidx++) { in lpfc_sli4_intr_handler()
14670 &phba->sli4_hba.hba_eq_hdl[qidx]); in lpfc_sli4_intr_handler()
14686 list_for_each_entry_rcu(eq, &phba->poll_list, _poll_list) in lpfc_sli4_poll_hbtimer()
14688 if (!list_empty(&phba->poll_list)) in lpfc_sli4_poll_hbtimer()
14689 mod_timer(&phba->cpuhp_poll_timer, in lpfc_sli4_poll_hbtimer()
14697 struct lpfc_hba *phba = eq->phba; in lpfc_sli4_poll_eq()
14702 * for re-schedule, but we are good for io submission in lpfc_sli4_poll_eq()
14709 if (READ_ONCE(eq->mode) == LPFC_EQ_POLL) in lpfc_sli4_poll_eq()
14724 struct lpfc_hba *phba = eq->phba; in lpfc_sli4_add_to_poll_list()
14727 if (list_empty(&phba->poll_list)) in lpfc_sli4_add_to_poll_list()
14728 mod_timer(&phba->cpuhp_poll_timer, in lpfc_sli4_add_to_poll_list()
14731 list_add_rcu(&eq->_poll_list, &phba->poll_list); in lpfc_sli4_add_to_poll_list()
14737 struct lpfc_hba *phba = eq->phba; in lpfc_sli4_remove_from_poll_list()
14740 * by RE-ARMING the eq's ASAP in lpfc_sli4_remove_from_poll_list()
14742 list_del_rcu(&eq->_poll_list); in lpfc_sli4_remove_from_poll_list()
14745 if (list_empty(&phba->poll_list)) in lpfc_sli4_remove_from_poll_list()
14746 del_timer_sync(&phba->cpuhp_poll_timer); in lpfc_sli4_remove_from_poll_list()
14753 list_for_each_entry_safe(eq, next, &phba->poll_list, _poll_list) in lpfc_sli4_cleanup_poll_list()
14754 list_del(&eq->_poll_list); in lpfc_sli4_cleanup_poll_list()
14756 INIT_LIST_HEAD(&phba->poll_list); in lpfc_sli4_cleanup_poll_list()
14763 if (mode == eq->mode) in __lpfc_sli4_switch_eqmode()
14771 * scheduler for a high priority process. Yes, the inte- in __lpfc_sli4_switch_eqmode()
14776 WRITE_ONCE(eq->mode, mode); in __lpfc_sli4_switch_eqmode()
14785 * deal with it. This is just a draining phase for int- in __lpfc_sli4_switch_eqmode()
14803 struct lpfc_hba *phba = eq->phba; in lpfc_sli4_stop_polling()
14810 * receives a completion. But since eq's are in disa- in lpfc_sli4_stop_polling()
14814 phba->sli4_hba.sli4_write_eq_db(phba, eq, 0, LPFC_QUEUE_REARM); in lpfc_sli4_stop_polling()
14818 * lpfc_sli4_queue_free - free a queue structure and associated memory
14833 if (!list_empty(&queue->wq_list)) in lpfc_sli4_queue_free()
14834 list_del(&queue->wq_list); in lpfc_sli4_queue_free()
14836 while (!list_empty(&queue->page_list)) { in lpfc_sli4_queue_free()
14837 list_remove_head(&queue->page_list, dmabuf, struct lpfc_dmabuf, in lpfc_sli4_queue_free()
14839 dma_free_coherent(&queue->phba->pcidev->dev, queue->page_size, in lpfc_sli4_queue_free()
14840 dmabuf->virt, dmabuf->phys); in lpfc_sli4_queue_free()
14843 if (queue->rqbp) { in lpfc_sli4_queue_free()
14844 lpfc_free_rq_buffer(queue->phba, queue); in lpfc_sli4_queue_free()
14845 kfree(queue->rqbp); in lpfc_sli4_queue_free()
14848 if (!list_empty(&queue->cpu_list)) in lpfc_sli4_queue_free()
14849 list_del(&queue->cpu_list); in lpfc_sli4_queue_free()
14856 * lpfc_sli4_queue_alloc - Allocate and initialize a queue structure
14873 uint32_t hw_page_size = phba->sli4_hba.pc_sli4_params.if_page_sz; in lpfc_sli4_queue_alloc()
14876 if (!phba->sli4_hba.pc_sli4_params.supported) in lpfc_sli4_queue_alloc()
14882 if (pgcnt > phba->sli4_hba.pc_sli4_params.wqpcnt) in lpfc_sli4_queue_alloc()
14883 pgcnt = phba->sli4_hba.pc_sli4_params.wqpcnt; in lpfc_sli4_queue_alloc()
14890 INIT_LIST_HEAD(&queue->list); in lpfc_sli4_queue_alloc()
14891 INIT_LIST_HEAD(&queue->_poll_list); in lpfc_sli4_queue_alloc()
14892 INIT_LIST_HEAD(&queue->wq_list); in lpfc_sli4_queue_alloc()
14893 INIT_LIST_HEAD(&queue->wqfull_list); in lpfc_sli4_queue_alloc()
14894 INIT_LIST_HEAD(&queue->page_list); in lpfc_sli4_queue_alloc()
14895 INIT_LIST_HEAD(&queue->child_list); in lpfc_sli4_queue_alloc()
14896 INIT_LIST_HEAD(&queue->cpu_list); in lpfc_sli4_queue_alloc()
14901 queue->page_count = pgcnt; in lpfc_sli4_queue_alloc()
14902 queue->q_pgs = (void **)&queue[1]; in lpfc_sli4_queue_alloc()
14903 queue->entry_cnt_per_pg = hw_page_size / entry_size; in lpfc_sli4_queue_alloc()
14904 queue->entry_size = entry_size; in lpfc_sli4_queue_alloc()
14905 queue->entry_count = entry_count; in lpfc_sli4_queue_alloc()
14906 queue->page_size = hw_page_size; in lpfc_sli4_queue_alloc()
14907 queue->phba = phba; in lpfc_sli4_queue_alloc()
14909 for (x = 0; x < queue->page_count; x++) { in lpfc_sli4_queue_alloc()
14911 dev_to_node(&phba->pcidev->dev)); in lpfc_sli4_queue_alloc()
14914 dmabuf->virt = dma_alloc_coherent(&phba->pcidev->dev, in lpfc_sli4_queue_alloc()
14915 hw_page_size, &dmabuf->phys, in lpfc_sli4_queue_alloc()
14917 if (!dmabuf->virt) { in lpfc_sli4_queue_alloc()
14921 dmabuf->buffer_tag = x; in lpfc_sli4_queue_alloc()
14922 list_add_tail(&dmabuf->list, &queue->page_list); in lpfc_sli4_queue_alloc()
14924 queue->q_pgs[x] = dmabuf->virt; in lpfc_sli4_queue_alloc()
14926 INIT_WORK(&queue->irqwork, lpfc_sli4_hba_process_cq); in lpfc_sli4_queue_alloc()
14927 INIT_WORK(&queue->spwork, lpfc_sli4_sp_process_cq); in lpfc_sli4_queue_alloc()
14928 INIT_DELAYED_WORK(&queue->sched_irqwork, lpfc_sli4_dly_hba_process_cq); in lpfc_sli4_queue_alloc()
14929 INIT_DELAYED_WORK(&queue->sched_spwork, lpfc_sli4_dly_sp_process_cq); in lpfc_sli4_queue_alloc()
14940 * lpfc_dual_chute_pci_bar_map - Map pci base address register to host memory
14951 if (!phba->pcidev) in lpfc_dual_chute_pci_bar_map()
14956 return phba->pci_bar0_memmap_p; in lpfc_dual_chute_pci_bar_map()
14958 return phba->pci_bar2_memmap_p; in lpfc_dual_chute_pci_bar_map()
14960 return phba->pci_bar4_memmap_p; in lpfc_dual_chute_pci_bar_map()
14968 * lpfc_modify_hba_eq_delay - Modify Delay Multiplier on EQs
14976 * or by mailbox command. The mailbox command allows several EQs to be
14979 * The @phba struct is used to send a mailbox command to HBA. The @startq
14983 * mailbox commands to finish before returning.
14986 * enough memory this function will return -ENOMEM. If a mailbox command
14987 * fails this function will return -ENXIO. Note: on ENXIO, some EQs may
15003 if (startq >= phba->cfg_irq_chann) in lpfc_modify_hba_eq_delay()
15014 if (phba->sli.sli_flag & LPFC_SLI_USE_EQDR) { in lpfc_modify_hba_eq_delay()
15015 for (qidx = startq; qidx < phba->cfg_irq_chann; qidx++) { in lpfc_modify_hba_eq_delay()
15016 eq = phba->sli4_hba.hba_eq_hdl[qidx].eq; in lpfc_modify_hba_eq_delay()
15028 /* Otherwise, set values by mailbox cmd */ in lpfc_modify_hba_eq_delay()
15030 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_modify_hba_eq_delay()
15033 "6428 Failed allocating mailbox cmd buffer." in lpfc_modify_hba_eq_delay()
15037 length = (sizeof(struct lpfc_mbx_modify_eq_delay) - in lpfc_modify_hba_eq_delay()
15042 eq_delay = &mbox->u.mqe.un.eq_delay; in lpfc_modify_hba_eq_delay()
15047 dmult--; in lpfc_modify_hba_eq_delay()
15051 for (qidx = startq; qidx < phba->cfg_irq_chann; qidx++) { in lpfc_modify_hba_eq_delay()
15052 eq = phba->sli4_hba.hba_eq_hdl[qidx].eq; in lpfc_modify_hba_eq_delay()
15055 eq->q_mode = usdelay; in lpfc_modify_hba_eq_delay()
15056 eq_delay->u.request.eq[cnt].eq_id = eq->queue_id; in lpfc_modify_hba_eq_delay()
15057 eq_delay->u.request.eq[cnt].phase = 0; in lpfc_modify_hba_eq_delay()
15058 eq_delay->u.request.eq[cnt].delay_multi = dmult; in lpfc_modify_hba_eq_delay()
15063 eq_delay->u.request.num_eq = cnt; in lpfc_modify_hba_eq_delay()
15065 mbox->vport = phba->pport; in lpfc_modify_hba_eq_delay()
15066 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_modify_hba_eq_delay()
15067 mbox->ctx_buf = NULL; in lpfc_modify_hba_eq_delay()
15068 mbox->ctx_ndlp = NULL; in lpfc_modify_hba_eq_delay()
15070 shdr = (union lpfc_sli4_cfg_shdr *) &eq_delay->header.cfg_shdr; in lpfc_modify_hba_eq_delay()
15071 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_modify_hba_eq_delay()
15072 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_modify_hba_eq_delay()
15075 "2512 MODIFY_EQ_DELAY mailbox failed with " in lpfc_modify_hba_eq_delay()
15079 mempool_free(mbox, phba->mbox_mem_pool); in lpfc_modify_hba_eq_delay()
15084 * lpfc_eq_create - Create an Event Queue on the HBA
15090 * described by @phba by sending an EQ_CREATE mailbox command to the HBA.
15092 * The @phba struct is used to send mailbox command to HBA. The @eq struct
15095 * function will send the EQ_CREATE mailbox command to the HBA to setup the
15096 * event queue. This function is asynchronous and will wait for the mailbox
15100 * memory this function will return -ENOMEM. If the queue create mailbox command
15101 * fails this function will return -ENXIO.
15113 uint32_t hw_page_size = phba->sli4_hba.pc_sli4_params.if_page_sz; in lpfc_eq_create()
15117 return -ENODEV; in lpfc_eq_create()
15118 if (!phba->sli4_hba.pc_sli4_params.supported) in lpfc_eq_create()
15121 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_eq_create()
15123 return -ENOMEM; in lpfc_eq_create()
15124 length = (sizeof(struct lpfc_mbx_eq_create) - in lpfc_eq_create()
15129 eq_create = &mbox->u.mqe.un.eq_create; in lpfc_eq_create()
15130 shdr = (union lpfc_sli4_cfg_shdr *) &eq_create->header.cfg_shdr; in lpfc_eq_create()
15131 bf_set(lpfc_mbx_eq_create_num_pages, &eq_create->u.request, in lpfc_eq_create()
15132 eq->page_count); in lpfc_eq_create()
15133 bf_set(lpfc_eq_context_size, &eq_create->u.request.context, in lpfc_eq_create()
15135 bf_set(lpfc_eq_context_valid, &eq_create->u.request.context, 1); in lpfc_eq_create()
15138 if (phba->sli4_hba.pc_sli4_params.eqav) { in lpfc_eq_create()
15139 bf_set(lpfc_mbox_hdr_version, &shdr->request, in lpfc_eq_create()
15141 bf_set(lpfc_eq_context_autovalid, &eq_create->u.request.context, in lpfc_eq_create()
15142 phba->sli4_hba.pc_sli4_params.eqav); in lpfc_eq_create()
15147 bf_set(lpfc_eq_context_delay_multi, &eq_create->u.request.context, in lpfc_eq_create()
15149 switch (eq->entry_count) { in lpfc_eq_create()
15153 eq->entry_count); in lpfc_eq_create()
15154 if (eq->entry_count < 256) { in lpfc_eq_create()
15155 status = -EINVAL; in lpfc_eq_create()
15160 bf_set(lpfc_eq_context_count, &eq_create->u.request.context, in lpfc_eq_create()
15164 bf_set(lpfc_eq_context_count, &eq_create->u.request.context, in lpfc_eq_create()
15168 bf_set(lpfc_eq_context_count, &eq_create->u.request.context, in lpfc_eq_create()
15172 bf_set(lpfc_eq_context_count, &eq_create->u.request.context, in lpfc_eq_create()
15176 bf_set(lpfc_eq_context_count, &eq_create->u.request.context, in lpfc_eq_create()
15180 list_for_each_entry(dmabuf, &eq->page_list, list) { in lpfc_eq_create()
15181 memset(dmabuf->virt, 0, hw_page_size); in lpfc_eq_create()
15182 eq_create->u.request.page[dmabuf->buffer_tag].addr_lo = in lpfc_eq_create()
15183 putPaddrLow(dmabuf->phys); in lpfc_eq_create()
15184 eq_create->u.request.page[dmabuf->buffer_tag].addr_hi = in lpfc_eq_create()
15185 putPaddrHigh(dmabuf->phys); in lpfc_eq_create()
15187 mbox->vport = phba->pport; in lpfc_eq_create()
15188 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_eq_create()
15189 mbox->ctx_buf = NULL; in lpfc_eq_create()
15190 mbox->ctx_ndlp = NULL; in lpfc_eq_create()
15192 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_eq_create()
15193 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_eq_create()
15196 "2500 EQ_CREATE mailbox failed with " in lpfc_eq_create()
15199 status = -ENXIO; in lpfc_eq_create()
15201 eq->type = LPFC_EQ; in lpfc_eq_create()
15202 eq->subtype = LPFC_NONE; in lpfc_eq_create()
15203 eq->queue_id = bf_get(lpfc_mbx_eq_create_q_id, &eq_create->u.response); in lpfc_eq_create()
15204 if (eq->queue_id == 0xFFFF) in lpfc_eq_create()
15205 status = -ENXIO; in lpfc_eq_create()
15206 eq->host_index = 0; in lpfc_eq_create()
15207 eq->notify_interval = LPFC_EQ_NOTIFY_INTRVL; in lpfc_eq_create()
15208 eq->max_proc_limit = LPFC_EQ_MAX_PROC_LIMIT; in lpfc_eq_create()
15210 mempool_free(mbox, phba->mbox_mem_pool); in lpfc_eq_create()
15224 * lpfc_cq_create - Create a Completion Queue on the HBA
15232 * described by @phba by sending a CQ_CREATE mailbox command to the HBA.
15234 * The @phba struct is used to send mailbox command to HBA. The @cq struct
15238 * function will send the CQ_CREATE mailbox command to the HBA to setup the
15239 * completion queue. This function is asynchronous and will wait for the mailbox
15243 * memory this function will return -ENOMEM. If the queue create mailbox command
15244 * fails this function will return -ENXIO.
15259 return -ENODEV; in lpfc_cq_create()
15261 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_cq_create()
15263 return -ENOMEM; in lpfc_cq_create()
15264 length = (sizeof(struct lpfc_mbx_cq_create) - in lpfc_cq_create()
15269 cq_create = &mbox->u.mqe.un.cq_create; in lpfc_cq_create()
15270 shdr = (union lpfc_sli4_cfg_shdr *) &cq_create->header.cfg_shdr; in lpfc_cq_create()
15271 bf_set(lpfc_mbx_cq_create_num_pages, &cq_create->u.request, in lpfc_cq_create()
15272 cq->page_count); in lpfc_cq_create()
15273 bf_set(lpfc_cq_context_event, &cq_create->u.request.context, 1); in lpfc_cq_create()
15274 bf_set(lpfc_cq_context_valid, &cq_create->u.request.context, 1); in lpfc_cq_create()
15275 bf_set(lpfc_mbox_hdr_version, &shdr->request, in lpfc_cq_create()
15276 phba->sli4_hba.pc_sli4_params.cqv); in lpfc_cq_create()
15277 if (phba->sli4_hba.pc_sli4_params.cqv == LPFC_Q_CREATE_VERSION_2) { in lpfc_cq_create()
15278 bf_set(lpfc_mbx_cq_create_page_size, &cq_create->u.request, in lpfc_cq_create()
15279 (cq->page_size / SLI4_PAGE_SIZE)); in lpfc_cq_create()
15280 bf_set(lpfc_cq_eq_id_2, &cq_create->u.request.context, in lpfc_cq_create()
15281 eq->queue_id); in lpfc_cq_create()
15282 bf_set(lpfc_cq_context_autovalid, &cq_create->u.request.context, in lpfc_cq_create()
15283 phba->sli4_hba.pc_sli4_params.cqav); in lpfc_cq_create()
15285 bf_set(lpfc_cq_eq_id, &cq_create->u.request.context, in lpfc_cq_create()
15286 eq->queue_id); in lpfc_cq_create()
15288 switch (cq->entry_count) { in lpfc_cq_create()
15291 if (phba->sli4_hba.pc_sli4_params.cqv == in lpfc_cq_create()
15293 cq_create->u.request.context.lpfc_cq_context_count = in lpfc_cq_create()
15294 cq->entry_count; in lpfc_cq_create()
15296 &cq_create->u.request.context, in lpfc_cq_create()
15305 cq->entry_count, cq->entry_size, in lpfc_cq_create()
15306 cq->page_count); in lpfc_cq_create()
15307 if (cq->entry_count < 256) { in lpfc_cq_create()
15308 status = -EINVAL; in lpfc_cq_create()
15313 bf_set(lpfc_cq_context_count, &cq_create->u.request.context, in lpfc_cq_create()
15317 bf_set(lpfc_cq_context_count, &cq_create->u.request.context, in lpfc_cq_create()
15321 bf_set(lpfc_cq_context_count, &cq_create->u.request.context, in lpfc_cq_create()
15325 list_for_each_entry(dmabuf, &cq->page_list, list) { in lpfc_cq_create()
15326 memset(dmabuf->virt, 0, cq->page_size); in lpfc_cq_create()
15327 cq_create->u.request.page[dmabuf->buffer_tag].addr_lo = in lpfc_cq_create()
15328 putPaddrLow(dmabuf->phys); in lpfc_cq_create()
15329 cq_create->u.request.page[dmabuf->buffer_tag].addr_hi = in lpfc_cq_create()
15330 putPaddrHigh(dmabuf->phys); in lpfc_cq_create()
15334 /* The IOCTL status is embedded in the mailbox subheader. */ in lpfc_cq_create()
15335 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_cq_create()
15336 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_cq_create()
15339 "2501 CQ_CREATE mailbox failed with " in lpfc_cq_create()
15342 status = -ENXIO; in lpfc_cq_create()
15345 cq->queue_id = bf_get(lpfc_mbx_cq_create_q_id, &cq_create->u.response); in lpfc_cq_create()
15346 if (cq->queue_id == 0xFFFF) { in lpfc_cq_create()
15347 status = -ENXIO; in lpfc_cq_create()
15351 list_add_tail(&cq->list, &eq->child_list); in lpfc_cq_create()
15353 cq->type = type; in lpfc_cq_create()
15354 cq->subtype = subtype; in lpfc_cq_create()
15355 cq->queue_id = bf_get(lpfc_mbx_cq_create_q_id, &cq_create->u.response); in lpfc_cq_create()
15356 cq->assoc_qid = eq->queue_id; in lpfc_cq_create()
15357 cq->assoc_qp = eq; in lpfc_cq_create()
15358 cq->host_index = 0; in lpfc_cq_create()
15359 cq->notify_interval = LPFC_CQ_NOTIFY_INTRVL; in lpfc_cq_create()
15360 cq->max_proc_limit = min(phba->cfg_cq_max_proc_limit, cq->entry_count); in lpfc_cq_create()
15362 if (cq->queue_id > phba->sli4_hba.cq_max) in lpfc_cq_create()
15363 phba->sli4_hba.cq_max = cq->queue_id; in lpfc_cq_create()
15365 irq_poll_init(&cq->iop, LPFC_IRQ_POLL_WEIGHT, lpfc_cq_poll_hdler); in lpfc_cq_create()
15367 mempool_free(mbox, phba->mbox_mem_pool); in lpfc_cq_create()
15372 * lpfc_cq_create_set - Create a set of Completion Queues on the HBA for MRQ
15381 * described by @phba by sending a CREATE_CQ_SET mailbox command to the HBA.
15383 * The @phba struct is used to send mailbox command to HBA. The @cq struct
15387 * function will send the CREATE_CQ_SET mailbox command to the HBA to setup the
15388 * completion queue. This function is asynchronous and will wait for the mailbox
15392 * memory this function will return -ENOMEM. If the queue create mailbox command
15393 * fails this function will return -ENXIO.
15409 uint32_t hw_page_size = phba->sli4_hba.pc_sli4_params.if_page_sz; in lpfc_cq_create_set()
15412 numcq = phba->cfg_nvmet_mrq; in lpfc_cq_create_set()
15414 return -ENODEV; in lpfc_cq_create_set()
15416 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_cq_create_set()
15418 return -ENOMEM; in lpfc_cq_create_set()
15421 length += ((numcq * cqp[0]->page_count) * in lpfc_cq_create_set()
15431 status = -ENOMEM; in lpfc_cq_create_set()
15434 cq_set = mbox->sge_array->addr[0]; in lpfc_cq_create_set()
15435 shdr = (union lpfc_sli4_cfg_shdr *)&cq_set->cfg_shdr; in lpfc_cq_create_set()
15436 bf_set(lpfc_mbox_hdr_version, &shdr->request, 0); in lpfc_cq_create_set()
15442 status = -ENOMEM; in lpfc_cq_create_set()
15445 if (!phba->sli4_hba.pc_sli4_params.supported) in lpfc_cq_create_set()
15446 hw_page_size = cq->page_size; in lpfc_cq_create_set()
15451 &cq_set->u.request, in lpfc_cq_create_set()
15454 &cq_set->u.request, cq->page_count); in lpfc_cq_create_set()
15456 &cq_set->u.request, 1); in lpfc_cq_create_set()
15458 &cq_set->u.request, 1); in lpfc_cq_create_set()
15460 &cq_set->u.request, 0); in lpfc_cq_create_set()
15462 &cq_set->u.request, numcq); in lpfc_cq_create_set()
15464 &cq_set->u.request, in lpfc_cq_create_set()
15465 phba->sli4_hba.pc_sli4_params.cqav); in lpfc_cq_create_set()
15466 switch (cq->entry_count) { in lpfc_cq_create_set()
15469 if (phba->sli4_hba.pc_sli4_params.cqv == in lpfc_cq_create_set()
15472 &cq_set->u.request, in lpfc_cq_create_set()
15473 cq->entry_count); in lpfc_cq_create_set()
15475 &cq_set->u.request, in lpfc_cq_create_set()
15483 cq->entry_count); in lpfc_cq_create_set()
15484 if (cq->entry_count < 256) { in lpfc_cq_create_set()
15485 status = -EINVAL; in lpfc_cq_create_set()
15491 &cq_set->u.request, LPFC_CQ_CNT_256); in lpfc_cq_create_set()
15495 &cq_set->u.request, LPFC_CQ_CNT_512); in lpfc_cq_create_set()
15499 &cq_set->u.request, LPFC_CQ_CNT_1024); in lpfc_cq_create_set()
15503 &cq_set->u.request, eq->queue_id); in lpfc_cq_create_set()
15507 &cq_set->u.request, eq->queue_id); in lpfc_cq_create_set()
15511 &cq_set->u.request, eq->queue_id); in lpfc_cq_create_set()
15515 &cq_set->u.request, eq->queue_id); in lpfc_cq_create_set()
15519 &cq_set->u.request, eq->queue_id); in lpfc_cq_create_set()
15523 &cq_set->u.request, eq->queue_id); in lpfc_cq_create_set()
15527 &cq_set->u.request, eq->queue_id); in lpfc_cq_create_set()
15531 &cq_set->u.request, eq->queue_id); in lpfc_cq_create_set()
15535 &cq_set->u.request, eq->queue_id); in lpfc_cq_create_set()
15539 &cq_set->u.request, eq->queue_id); in lpfc_cq_create_set()
15543 &cq_set->u.request, eq->queue_id); in lpfc_cq_create_set()
15547 &cq_set->u.request, eq->queue_id); in lpfc_cq_create_set()
15551 &cq_set->u.request, eq->queue_id); in lpfc_cq_create_set()
15555 &cq_set->u.request, eq->queue_id); in lpfc_cq_create_set()
15559 &cq_set->u.request, eq->queue_id); in lpfc_cq_create_set()
15563 &cq_set->u.request, eq->queue_id); in lpfc_cq_create_set()
15568 list_add_tail(&cq->list, &eq->child_list); in lpfc_cq_create_set()
15570 cq->type = type; in lpfc_cq_create_set()
15571 cq->subtype = subtype; in lpfc_cq_create_set()
15572 cq->assoc_qid = eq->queue_id; in lpfc_cq_create_set()
15573 cq->assoc_qp = eq; in lpfc_cq_create_set()
15574 cq->host_index = 0; in lpfc_cq_create_set()
15575 cq->notify_interval = LPFC_CQ_NOTIFY_INTRVL; in lpfc_cq_create_set()
15576 cq->max_proc_limit = min(phba->cfg_cq_max_proc_limit, in lpfc_cq_create_set()
15577 cq->entry_count); in lpfc_cq_create_set()
15578 cq->chann = idx; in lpfc_cq_create_set()
15581 list_for_each_entry(dmabuf, &cq->page_list, list) { in lpfc_cq_create_set()
15582 memset(dmabuf->virt, 0, hw_page_size); in lpfc_cq_create_set()
15583 cnt = page_idx + dmabuf->buffer_tag; in lpfc_cq_create_set()
15584 cq_set->u.request.page[cnt].addr_lo = in lpfc_cq_create_set()
15585 putPaddrLow(dmabuf->phys); in lpfc_cq_create_set()
15586 cq_set->u.request.page[cnt].addr_hi = in lpfc_cq_create_set()
15587 putPaddrHigh(dmabuf->phys); in lpfc_cq_create_set()
15595 /* The IOCTL status is embedded in the mailbox subheader. */ in lpfc_cq_create_set()
15596 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_cq_create_set()
15597 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_cq_create_set()
15600 "3119 CQ_CREATE_SET mailbox failed with " in lpfc_cq_create_set()
15603 status = -ENXIO; in lpfc_cq_create_set()
15606 rc = bf_get(lpfc_mbx_cq_create_set_base_id, &cq_set->u.response); in lpfc_cq_create_set()
15608 status = -ENXIO; in lpfc_cq_create_set()
15614 cq->queue_id = rc + idx; in lpfc_cq_create_set()
15615 if (cq->queue_id > phba->sli4_hba.cq_max) in lpfc_cq_create_set()
15616 phba->sli4_hba.cq_max = cq->queue_id; in lpfc_cq_create_set()
15625 * lpfc_mq_create_fb_init - Send MCC_CREATE without async events registration
15627 * @mq: The queue structure to use to create the mailbox queue.
15646 length = (sizeof(struct lpfc_mbx_mq_create) - in lpfc_mq_create_fb_init()
15651 mq_create = &mbox->u.mqe.un.mq_create; in lpfc_mq_create_fb_init()
15652 bf_set(lpfc_mbx_mq_create_num_pages, &mq_create->u.request, in lpfc_mq_create_fb_init()
15653 mq->page_count); in lpfc_mq_create_fb_init()
15654 bf_set(lpfc_mq_context_cq_id, &mq_create->u.request.context, in lpfc_mq_create_fb_init()
15655 cq->queue_id); in lpfc_mq_create_fb_init()
15656 bf_set(lpfc_mq_context_valid, &mq_create->u.request.context, 1); in lpfc_mq_create_fb_init()
15657 switch (mq->entry_count) { in lpfc_mq_create_fb_init()
15659 bf_set(lpfc_mq_context_ring_size, &mq_create->u.request.context, in lpfc_mq_create_fb_init()
15663 bf_set(lpfc_mq_context_ring_size, &mq_create->u.request.context, in lpfc_mq_create_fb_init()
15667 bf_set(lpfc_mq_context_ring_size, &mq_create->u.request.context, in lpfc_mq_create_fb_init()
15671 bf_set(lpfc_mq_context_ring_size, &mq_create->u.request.context, in lpfc_mq_create_fb_init()
15675 list_for_each_entry(dmabuf, &mq->page_list, list) { in lpfc_mq_create_fb_init()
15676 mq_create->u.request.page[dmabuf->buffer_tag].addr_lo = in lpfc_mq_create_fb_init()
15677 putPaddrLow(dmabuf->phys); in lpfc_mq_create_fb_init()
15678 mq_create->u.request.page[dmabuf->buffer_tag].addr_hi = in lpfc_mq_create_fb_init()
15679 putPaddrHigh(dmabuf->phys); in lpfc_mq_create_fb_init()
15684 * lpfc_mq_create - Create a mailbox Queue on the HBA
15686 * @mq: The queue structure to use to create the mailbox queue.
15690 * This function creates a mailbox queue, as detailed in @mq, on a port,
15691 * described by @phba by sending a MQ_CREATE mailbox command to the HBA.
15693 * The @phba struct is used to send mailbox command to HBA. The @cq struct
15696 * function will send the MQ_CREATE mailbox command to the HBA to setup the
15697 * mailbox queue. This function is asynchronous and will wait for the mailbox
15701 * memory this function will return -ENOMEM. If the queue create mailbox command
15702 * fails this function will return -ENXIO.
15715 uint32_t hw_page_size = phba->sli4_hba.pc_sli4_params.if_page_sz; in lpfc_mq_create()
15719 return -ENODEV; in lpfc_mq_create()
15720 if (!phba->sli4_hba.pc_sli4_params.supported) in lpfc_mq_create()
15723 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_mq_create()
15725 return -ENOMEM; in lpfc_mq_create()
15726 length = (sizeof(struct lpfc_mbx_mq_create_ext) - in lpfc_mq_create()
15732 mq_create_ext = &mbox->u.mqe.un.mq_create_ext; in lpfc_mq_create()
15733 shdr = (union lpfc_sli4_cfg_shdr *) &mq_create_ext->header.cfg_shdr; in lpfc_mq_create()
15735 &mq_create_ext->u.request, mq->page_count); in lpfc_mq_create()
15737 &mq_create_ext->u.request, 1); in lpfc_mq_create()
15739 &mq_create_ext->u.request, 1); in lpfc_mq_create()
15741 &mq_create_ext->u.request, 1); in lpfc_mq_create()
15743 &mq_create_ext->u.request, 1); in lpfc_mq_create()
15745 &mq_create_ext->u.request, 1); in lpfc_mq_create()
15746 bf_set(lpfc_mq_context_valid, &mq_create_ext->u.request.context, 1); in lpfc_mq_create()
15747 bf_set(lpfc_mbox_hdr_version, &shdr->request, in lpfc_mq_create()
15748 phba->sli4_hba.pc_sli4_params.mqv); in lpfc_mq_create()
15749 if (phba->sli4_hba.pc_sli4_params.mqv == LPFC_Q_CREATE_VERSION_1) in lpfc_mq_create()
15750 bf_set(lpfc_mbx_mq_create_ext_cq_id, &mq_create_ext->u.request, in lpfc_mq_create()
15751 cq->queue_id); in lpfc_mq_create()
15753 bf_set(lpfc_mq_context_cq_id, &mq_create_ext->u.request.context, in lpfc_mq_create()
15754 cq->queue_id); in lpfc_mq_create()
15755 switch (mq->entry_count) { in lpfc_mq_create()
15759 mq->entry_count); in lpfc_mq_create()
15760 if (mq->entry_count < 16) { in lpfc_mq_create()
15761 status = -EINVAL; in lpfc_mq_create()
15767 &mq_create_ext->u.request.context, in lpfc_mq_create()
15772 &mq_create_ext->u.request.context, in lpfc_mq_create()
15777 &mq_create_ext->u.request.context, in lpfc_mq_create()
15782 &mq_create_ext->u.request.context, in lpfc_mq_create()
15786 list_for_each_entry(dmabuf, &mq->page_list, list) { in lpfc_mq_create()
15787 memset(dmabuf->virt, 0, hw_page_size); in lpfc_mq_create()
15788 mq_create_ext->u.request.page[dmabuf->buffer_tag].addr_lo = in lpfc_mq_create()
15789 putPaddrLow(dmabuf->phys); in lpfc_mq_create()
15790 mq_create_ext->u.request.page[dmabuf->buffer_tag].addr_hi = in lpfc_mq_create()
15791 putPaddrHigh(dmabuf->phys); in lpfc_mq_create()
15794 mq->queue_id = bf_get(lpfc_mbx_mq_create_q_id, in lpfc_mq_create()
15795 &mq_create_ext->u.response); in lpfc_mq_create()
15802 mq_create = &mbox->u.mqe.un.mq_create; in lpfc_mq_create()
15804 shdr = (union lpfc_sli4_cfg_shdr *) &mq_create->header.cfg_shdr; in lpfc_mq_create()
15805 mq->queue_id = bf_get(lpfc_mbx_mq_create_q_id, in lpfc_mq_create()
15806 &mq_create->u.response); in lpfc_mq_create()
15809 /* The IOCTL status is embedded in the mailbox subheader. */ in lpfc_mq_create()
15810 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_mq_create()
15811 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_mq_create()
15814 "2502 MQ_CREATE mailbox failed with " in lpfc_mq_create()
15817 status = -ENXIO; in lpfc_mq_create()
15820 if (mq->queue_id == 0xFFFF) { in lpfc_mq_create()
15821 status = -ENXIO; in lpfc_mq_create()
15824 mq->type = LPFC_MQ; in lpfc_mq_create()
15825 mq->assoc_qid = cq->queue_id; in lpfc_mq_create()
15826 mq->subtype = subtype; in lpfc_mq_create()
15827 mq->host_index = 0; in lpfc_mq_create()
15828 mq->hba_index = 0; in lpfc_mq_create()
15831 list_add_tail(&mq->list, &cq->child_list); in lpfc_mq_create()
15833 mempool_free(mbox, phba->mbox_mem_pool); in lpfc_mq_create()
15838 * lpfc_wq_create - Create a Work Queue on the HBA
15845 * by @phba by sending a WQ_CREATE mailbox command to the HBA.
15847 * The @phba struct is used to send mailbox command to HBA. The @wq struct
15851 * function will send the WQ_CREATE mailbox command to the HBA to setup the
15852 * work queue. This function is asynchronous and will wait for the mailbox
15856 * memory this function will return -ENOMEM. If the queue create mailbox command
15857 * fails this function will return -ENXIO.
15869 uint32_t hw_page_size = phba->sli4_hba.pc_sli4_params.if_page_sz; in lpfc_wq_create()
15883 return -ENODEV; in lpfc_wq_create()
15884 if (!phba->sli4_hba.pc_sli4_params.supported) in lpfc_wq_create()
15885 hw_page_size = wq->page_size; in lpfc_wq_create()
15887 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_wq_create()
15889 return -ENOMEM; in lpfc_wq_create()
15890 length = (sizeof(struct lpfc_mbx_wq_create) - in lpfc_wq_create()
15895 wq_create = &mbox->u.mqe.un.wq_create; in lpfc_wq_create()
15896 shdr = (union lpfc_sli4_cfg_shdr *) &wq_create->header.cfg_shdr; in lpfc_wq_create()
15897 bf_set(lpfc_mbx_wq_create_num_pages, &wq_create->u.request, in lpfc_wq_create()
15898 wq->page_count); in lpfc_wq_create()
15899 bf_set(lpfc_mbx_wq_create_cq_id, &wq_create->u.request, in lpfc_wq_create()
15900 cq->queue_id); in lpfc_wq_create()
15903 bf_set(lpfc_mbox_hdr_version, &shdr->request, in lpfc_wq_create()
15904 phba->sli4_hba.pc_sli4_params.wqv); in lpfc_wq_create()
15906 if ((phba->sli4_hba.pc_sli4_params.wqsize & LPFC_WQ_SZ128_SUPPORT) || in lpfc_wq_create()
15907 (wq->page_size > SLI4_PAGE_SIZE)) in lpfc_wq_create()
15913 if (phba->sli4_hba.pc_sli4_params.wqsize & LPFC_WQ_SZ128_SUPPORT) in lpfc_wq_create()
15920 bf_set(lpfc_mbx_wq_create_wqe_count, &wq_create->u.request_1, in lpfc_wq_create()
15921 wq->entry_count); in lpfc_wq_create()
15922 bf_set(lpfc_mbox_hdr_version, &shdr->request, in lpfc_wq_create()
15925 switch (wq->entry_size) { in lpfc_wq_create()
15929 &wq_create->u.request_1, in lpfc_wq_create()
15934 &wq_create->u.request_1, in lpfc_wq_create()
15939 bf_set(lpfc_mbx_wq_create_dpp_req, &wq_create->u.request_1, 1); in lpfc_wq_create()
15941 &wq_create->u.request_1, in lpfc_wq_create()
15942 (wq->page_size / SLI4_PAGE_SIZE)); in lpfc_wq_create()
15943 page = wq_create->u.request_1.page; in lpfc_wq_create()
15946 page = wq_create->u.request.page; in lpfc_wq_create()
15950 list_for_each_entry(dmabuf, &wq->page_list, list) { in lpfc_wq_create()
15951 memset(dmabuf->virt, 0, hw_page_size); in lpfc_wq_create()
15952 page[dmabuf->buffer_tag].addr_lo = putPaddrLow(dmabuf->phys); in lpfc_wq_create()
15953 page[dmabuf->buffer_tag].addr_hi = putPaddrHigh(dmabuf->phys); in lpfc_wq_create()
15956 if (phba->sli4_hba.fw_func_mode & LPFC_DUA_MODE) in lpfc_wq_create()
15957 bf_set(lpfc_mbx_wq_create_dua, &wq_create->u.request, 1); in lpfc_wq_create()
15960 /* The IOCTL status is embedded in the mailbox subheader. */ in lpfc_wq_create()
15961 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_wq_create()
15962 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_wq_create()
15965 "2503 WQ_CREATE mailbox failed with " in lpfc_wq_create()
15968 status = -ENXIO; in lpfc_wq_create()
15973 wq->queue_id = bf_get(lpfc_mbx_wq_create_q_id, in lpfc_wq_create()
15974 &wq_create->u.response); in lpfc_wq_create()
15976 wq->queue_id = bf_get(lpfc_mbx_wq_create_v1_q_id, in lpfc_wq_create()
15977 &wq_create->u.response_1); in lpfc_wq_create()
15979 if (wq->queue_id == 0xFFFF) { in lpfc_wq_create()
15980 status = -ENXIO; in lpfc_wq_create()
15984 wq->db_format = LPFC_DB_LIST_FORMAT; in lpfc_wq_create()
15986 if (phba->sli4_hba.fw_func_mode & LPFC_DUA_MODE) { in lpfc_wq_create()
15987 wq->db_format = bf_get(lpfc_mbx_wq_create_db_format, in lpfc_wq_create()
15988 &wq_create->u.response); in lpfc_wq_create()
15989 if ((wq->db_format != LPFC_DB_LIST_FORMAT) && in lpfc_wq_create()
15990 (wq->db_format != LPFC_DB_RING_FORMAT)) { in lpfc_wq_create()
15994 wq->queue_id, wq->db_format); in lpfc_wq_create()
15995 status = -EINVAL; in lpfc_wq_create()
15999 &wq_create->u.response); in lpfc_wq_create()
16006 wq->queue_id, pci_barset); in lpfc_wq_create()
16007 status = -ENOMEM; in lpfc_wq_create()
16010 db_offset = wq_create->u.response.doorbell_offset; in lpfc_wq_create()
16016 wq->queue_id, db_offset); in lpfc_wq_create()
16017 status = -EINVAL; in lpfc_wq_create()
16020 wq->db_regaddr = bar_memmap_p + db_offset; in lpfc_wq_create()
16023 "format:x%x\n", wq->queue_id, in lpfc_wq_create()
16024 pci_barset, db_offset, wq->db_format); in lpfc_wq_create()
16026 wq->db_regaddr = phba->sli4_hba.WQDBregaddr; in lpfc_wq_create()
16029 wq->dpp_enable = bf_get(lpfc_mbx_wq_create_dpp_rsp, in lpfc_wq_create()
16030 &wq_create->u.response_1); in lpfc_wq_create()
16031 if (wq->dpp_enable) { in lpfc_wq_create()
16033 &wq_create->u.response_1); in lpfc_wq_create()
16040 wq->queue_id, pci_barset); in lpfc_wq_create()
16041 status = -ENOMEM; in lpfc_wq_create()
16044 db_offset = wq_create->u.response_1.doorbell_offset; in lpfc_wq_create()
16045 wq->db_regaddr = bar_memmap_p + db_offset; in lpfc_wq_create()
16046 wq->dpp_id = bf_get(lpfc_mbx_wq_create_dpp_id, in lpfc_wq_create()
16047 &wq_create->u.response_1); in lpfc_wq_create()
16049 &wq_create->u.response_1); in lpfc_wq_create()
16056 wq->queue_id, dpp_barset); in lpfc_wq_create()
16057 status = -ENOMEM; in lpfc_wq_create()
16060 dpp_offset = wq_create->u.response_1.dpp_offset; in lpfc_wq_create()
16061 wq->dpp_regaddr = bar_memmap_p + dpp_offset; in lpfc_wq_create()
16066 wq->queue_id, pci_barset, db_offset, in lpfc_wq_create()
16067 wq->dpp_id, dpp_barset, dpp_offset); in lpfc_wq_create()
16071 pg_addr = (unsigned long)(wq->dpp_regaddr) & PAGE_MASK; in lpfc_wq_create()
16076 "Write on WQ[%d] - disable DPP\n", in lpfc_wq_create()
16077 wq->queue_id); in lpfc_wq_create()
16078 phba->cfg_enable_dpp = 0; in lpfc_wq_create()
16081 phba->cfg_enable_dpp = 0; in lpfc_wq_create()
16084 wq->db_regaddr = phba->sli4_hba.WQDBregaddr; in lpfc_wq_create()
16086 wq->pring = kzalloc(sizeof(struct lpfc_sli_ring), GFP_KERNEL); in lpfc_wq_create()
16087 if (wq->pring == NULL) { in lpfc_wq_create()
16088 status = -ENOMEM; in lpfc_wq_create()
16091 wq->type = LPFC_WQ; in lpfc_wq_create()
16092 wq->assoc_qid = cq->queue_id; in lpfc_wq_create()
16093 wq->subtype = subtype; in lpfc_wq_create()
16094 wq->host_index = 0; in lpfc_wq_create()
16095 wq->hba_index = 0; in lpfc_wq_create()
16096 wq->notify_interval = LPFC_WQ_NOTIFY_INTRVL; in lpfc_wq_create()
16099 list_add_tail(&wq->list, &cq->child_list); in lpfc_wq_create()
16101 mempool_free(mbox, phba->mbox_mem_pool); in lpfc_wq_create()
16106 * lpfc_rq_create - Create a Receive Queue on the HBA
16114 * @drq, on a port, described by @phba by sending a RQ_CREATE mailbox command
16117 * The @phba struct is used to send mailbox command to HBA. The @drq and @hrq
16121 * This function will send the RQ_CREATE mailbox command to the HBA to setup the
16123 * mailbox command to finish before continuing.
16126 * memory this function will return -ENOMEM. If the queue create mailbox command
16127 * fails this function will return -ENXIO.
16139 uint32_t hw_page_size = phba->sli4_hba.pc_sli4_params.if_page_sz; in lpfc_rq_create()
16146 return -ENODEV; in lpfc_rq_create()
16147 if (!phba->sli4_hba.pc_sli4_params.supported) in lpfc_rq_create()
16150 if (hrq->entry_count != drq->entry_count) in lpfc_rq_create()
16151 return -EINVAL; in lpfc_rq_create()
16152 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_rq_create()
16154 return -ENOMEM; in lpfc_rq_create()
16155 length = (sizeof(struct lpfc_mbx_rq_create) - in lpfc_rq_create()
16160 rq_create = &mbox->u.mqe.un.rq_create; in lpfc_rq_create()
16161 shdr = (union lpfc_sli4_cfg_shdr *) &rq_create->header.cfg_shdr; in lpfc_rq_create()
16162 bf_set(lpfc_mbox_hdr_version, &shdr->request, in lpfc_rq_create()
16163 phba->sli4_hba.pc_sli4_params.rqv); in lpfc_rq_create()
16164 if (phba->sli4_hba.pc_sli4_params.rqv == LPFC_Q_CREATE_VERSION_1) { in lpfc_rq_create()
16166 &rq_create->u.request.context, in lpfc_rq_create()
16167 hrq->entry_count); in lpfc_rq_create()
16168 rq_create->u.request.context.buffer_size = LPFC_HDR_BUF_SIZE; in lpfc_rq_create()
16170 &rq_create->u.request.context, in lpfc_rq_create()
16173 &rq_create->u.request.context, in lpfc_rq_create()
16176 switch (hrq->entry_count) { in lpfc_rq_create()
16180 hrq->entry_count); in lpfc_rq_create()
16181 if (hrq->entry_count < 512) { in lpfc_rq_create()
16182 status = -EINVAL; in lpfc_rq_create()
16188 &rq_create->u.request.context, in lpfc_rq_create()
16193 &rq_create->u.request.context, in lpfc_rq_create()
16198 &rq_create->u.request.context, in lpfc_rq_create()
16203 &rq_create->u.request.context, in lpfc_rq_create()
16207 bf_set(lpfc_rq_context_buf_size, &rq_create->u.request.context, in lpfc_rq_create()
16210 bf_set(lpfc_rq_context_cq_id, &rq_create->u.request.context, in lpfc_rq_create()
16211 cq->queue_id); in lpfc_rq_create()
16212 bf_set(lpfc_mbx_rq_create_num_pages, &rq_create->u.request, in lpfc_rq_create()
16213 hrq->page_count); in lpfc_rq_create()
16214 list_for_each_entry(dmabuf, &hrq->page_list, list) { in lpfc_rq_create()
16215 memset(dmabuf->virt, 0, hw_page_size); in lpfc_rq_create()
16216 rq_create->u.request.page[dmabuf->buffer_tag].addr_lo = in lpfc_rq_create()
16217 putPaddrLow(dmabuf->phys); in lpfc_rq_create()
16218 rq_create->u.request.page[dmabuf->buffer_tag].addr_hi = in lpfc_rq_create()
16219 putPaddrHigh(dmabuf->phys); in lpfc_rq_create()
16221 if (phba->sli4_hba.fw_func_mode & LPFC_DUA_MODE) in lpfc_rq_create()
16222 bf_set(lpfc_mbx_rq_create_dua, &rq_create->u.request, 1); in lpfc_rq_create()
16225 /* The IOCTL status is embedded in the mailbox subheader. */ in lpfc_rq_create()
16226 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_rq_create()
16227 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_rq_create()
16230 "2504 RQ_CREATE mailbox failed with " in lpfc_rq_create()
16233 status = -ENXIO; in lpfc_rq_create()
16236 hrq->queue_id = bf_get(lpfc_mbx_rq_create_q_id, &rq_create->u.response); in lpfc_rq_create()
16237 if (hrq->queue_id == 0xFFFF) { in lpfc_rq_create()
16238 status = -ENXIO; in lpfc_rq_create()
16242 if (phba->sli4_hba.fw_func_mode & LPFC_DUA_MODE) { in lpfc_rq_create()
16243 hrq->db_format = bf_get(lpfc_mbx_rq_create_db_format, in lpfc_rq_create()
16244 &rq_create->u.response); in lpfc_rq_create()
16245 if ((hrq->db_format != LPFC_DB_LIST_FORMAT) && in lpfc_rq_create()
16246 (hrq->db_format != LPFC_DB_RING_FORMAT)) { in lpfc_rq_create()
16249 "supported: x%x\n", hrq->queue_id, in lpfc_rq_create()
16250 hrq->db_format); in lpfc_rq_create()
16251 status = -EINVAL; in lpfc_rq_create()
16256 &rq_create->u.response); in lpfc_rq_create()
16261 "barset:x%x\n", hrq->queue_id, in lpfc_rq_create()
16263 status = -ENOMEM; in lpfc_rq_create()
16267 db_offset = rq_create->u.response.doorbell_offset; in lpfc_rq_create()
16272 "supported: x%x\n", hrq->queue_id, in lpfc_rq_create()
16274 status = -EINVAL; in lpfc_rq_create()
16277 hrq->db_regaddr = bar_memmap_p + db_offset; in lpfc_rq_create()
16280 "format:x%x\n", hrq->queue_id, pci_barset, in lpfc_rq_create()
16281 db_offset, hrq->db_format); in lpfc_rq_create()
16283 hrq->db_format = LPFC_DB_RING_FORMAT; in lpfc_rq_create()
16284 hrq->db_regaddr = phba->sli4_hba.RQDBregaddr; in lpfc_rq_create()
16286 hrq->type = LPFC_HRQ; in lpfc_rq_create()
16287 hrq->assoc_qid = cq->queue_id; in lpfc_rq_create()
16288 hrq->subtype = subtype; in lpfc_rq_create()
16289 hrq->host_index = 0; in lpfc_rq_create()
16290 hrq->hba_index = 0; in lpfc_rq_create()
16291 hrq->notify_interval = LPFC_RQ_NOTIFY_INTRVL; in lpfc_rq_create()
16297 bf_set(lpfc_mbox_hdr_version, &shdr->request, in lpfc_rq_create()
16298 phba->sli4_hba.pc_sli4_params.rqv); in lpfc_rq_create()
16299 if (phba->sli4_hba.pc_sli4_params.rqv == LPFC_Q_CREATE_VERSION_1) { in lpfc_rq_create()
16301 &rq_create->u.request.context, hrq->entry_count); in lpfc_rq_create()
16303 rq_create->u.request.context.buffer_size = in lpfc_rq_create()
16306 rq_create->u.request.context.buffer_size = in lpfc_rq_create()
16308 bf_set(lpfc_rq_context_rqe_size, &rq_create->u.request.context, in lpfc_rq_create()
16310 bf_set(lpfc_rq_context_page_size, &rq_create->u.request.context, in lpfc_rq_create()
16313 switch (drq->entry_count) { in lpfc_rq_create()
16317 drq->entry_count); in lpfc_rq_create()
16318 if (drq->entry_count < 512) { in lpfc_rq_create()
16319 status = -EINVAL; in lpfc_rq_create()
16325 &rq_create->u.request.context, in lpfc_rq_create()
16330 &rq_create->u.request.context, in lpfc_rq_create()
16335 &rq_create->u.request.context, in lpfc_rq_create()
16340 &rq_create->u.request.context, in lpfc_rq_create()
16346 &rq_create->u.request.context, in lpfc_rq_create()
16350 &rq_create->u.request.context, in lpfc_rq_create()
16353 bf_set(lpfc_rq_context_cq_id, &rq_create->u.request.context, in lpfc_rq_create()
16354 cq->queue_id); in lpfc_rq_create()
16355 bf_set(lpfc_mbx_rq_create_num_pages, &rq_create->u.request, in lpfc_rq_create()
16356 drq->page_count); in lpfc_rq_create()
16357 list_for_each_entry(dmabuf, &drq->page_list, list) { in lpfc_rq_create()
16358 rq_create->u.request.page[dmabuf->buffer_tag].addr_lo = in lpfc_rq_create()
16359 putPaddrLow(dmabuf->phys); in lpfc_rq_create()
16360 rq_create->u.request.page[dmabuf->buffer_tag].addr_hi = in lpfc_rq_create()
16361 putPaddrHigh(dmabuf->phys); in lpfc_rq_create()
16363 if (phba->sli4_hba.fw_func_mode & LPFC_DUA_MODE) in lpfc_rq_create()
16364 bf_set(lpfc_mbx_rq_create_dua, &rq_create->u.request, 1); in lpfc_rq_create()
16366 /* The IOCTL status is embedded in the mailbox subheader. */ in lpfc_rq_create()
16367 shdr = (union lpfc_sli4_cfg_shdr *) &rq_create->header.cfg_shdr; in lpfc_rq_create()
16368 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_rq_create()
16369 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_rq_create()
16371 status = -ENXIO; in lpfc_rq_create()
16374 drq->queue_id = bf_get(lpfc_mbx_rq_create_q_id, &rq_create->u.response); in lpfc_rq_create()
16375 if (drq->queue_id == 0xFFFF) { in lpfc_rq_create()
16376 status = -ENXIO; in lpfc_rq_create()
16379 drq->type = LPFC_DRQ; in lpfc_rq_create()
16380 drq->assoc_qid = cq->queue_id; in lpfc_rq_create()
16381 drq->subtype = subtype; in lpfc_rq_create()
16382 drq->host_index = 0; in lpfc_rq_create()
16383 drq->hba_index = 0; in lpfc_rq_create()
16384 drq->notify_interval = LPFC_RQ_NOTIFY_INTRVL; in lpfc_rq_create()
16387 list_add_tail(&hrq->list, &cq->child_list); in lpfc_rq_create()
16388 list_add_tail(&drq->list, &cq->child_list); in lpfc_rq_create()
16391 mempool_free(mbox, phba->mbox_mem_pool); in lpfc_rq_create()
16396 * lpfc_mrq_create - Create MRQ Receive Queues on the HBA
16404 * @drq, on a port, described by @phba by sending a RQ_CREATE mailbox command
16407 * The @phba struct is used to send mailbox command to HBA. The @drq and @hrq
16411 * This function will send the RQ_CREATE mailbox command to the HBA to setup the
16413 * mailbox command to finish before continuing.
16416 * memory this function will return -ENOMEM. If the queue create mailbox command
16417 * fails this function will return -ENXIO.
16432 uint32_t hw_page_size = phba->sli4_hba.pc_sli4_params.if_page_sz; in lpfc_mrq_create()
16434 numrq = phba->cfg_nvmet_mrq; in lpfc_mrq_create()
16437 return -ENODEV; in lpfc_mrq_create()
16438 if (!phba->sli4_hba.pc_sli4_params.supported) in lpfc_mrq_create()
16441 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_mrq_create()
16443 return -ENOMEM; in lpfc_mrq_create()
16446 length += ((2 * numrq * hrqp[0]->page_count) * in lpfc_mrq_create()
16457 status = -ENOMEM; in lpfc_mrq_create()
16463 rq_create = mbox->sge_array->addr[0]; in lpfc_mrq_create()
16464 shdr = (union lpfc_sli4_cfg_shdr *)&rq_create->cfg_shdr; in lpfc_mrq_create()
16466 bf_set(lpfc_mbox_hdr_version, &shdr->request, LPFC_Q_CREATE_VERSION_2); in lpfc_mrq_create()
16476 status = -ENODEV; in lpfc_mrq_create()
16480 if (hrq->entry_count != drq->entry_count) { in lpfc_mrq_create()
16481 status = -EINVAL; in lpfc_mrq_create()
16487 &rq_create->u.request, in lpfc_mrq_create()
16488 hrq->page_count); in lpfc_mrq_create()
16490 &rq_create->u.request, (numrq * 2)); in lpfc_mrq_create()
16491 bf_set(lpfc_mbx_rq_create_dnb, &rq_create->u.request, in lpfc_mrq_create()
16494 &rq_create->u.request.context, in lpfc_mrq_create()
16495 cq->queue_id); in lpfc_mrq_create()
16497 &rq_create->u.request.context, in lpfc_mrq_create()
16500 &rq_create->u.request.context, in lpfc_mrq_create()
16503 &rq_create->u.request.context, in lpfc_mrq_create()
16504 hrq->entry_count); in lpfc_mrq_create()
16506 &rq_create->u.request.context, in lpfc_mrq_create()
16509 &rq_create->u.request.context, in lpfc_mrq_create()
16513 list_for_each_entry(dmabuf, &hrq->page_list, list) { in lpfc_mrq_create()
16514 memset(dmabuf->virt, 0, hw_page_size); in lpfc_mrq_create()
16515 cnt = page_idx + dmabuf->buffer_tag; in lpfc_mrq_create()
16516 rq_create->u.request.page[cnt].addr_lo = in lpfc_mrq_create()
16517 putPaddrLow(dmabuf->phys); in lpfc_mrq_create()
16518 rq_create->u.request.page[cnt].addr_hi = in lpfc_mrq_create()
16519 putPaddrHigh(dmabuf->phys); in lpfc_mrq_create()
16525 list_for_each_entry(dmabuf, &drq->page_list, list) { in lpfc_mrq_create()
16526 memset(dmabuf->virt, 0, hw_page_size); in lpfc_mrq_create()
16527 cnt = page_idx + dmabuf->buffer_tag; in lpfc_mrq_create()
16528 rq_create->u.request.page[cnt].addr_lo = in lpfc_mrq_create()
16529 putPaddrLow(dmabuf->phys); in lpfc_mrq_create()
16530 rq_create->u.request.page[cnt].addr_hi = in lpfc_mrq_create()
16531 putPaddrHigh(dmabuf->phys); in lpfc_mrq_create()
16536 hrq->db_format = LPFC_DB_RING_FORMAT; in lpfc_mrq_create()
16537 hrq->db_regaddr = phba->sli4_hba.RQDBregaddr; in lpfc_mrq_create()
16538 hrq->type = LPFC_HRQ; in lpfc_mrq_create()
16539 hrq->assoc_qid = cq->queue_id; in lpfc_mrq_create()
16540 hrq->subtype = subtype; in lpfc_mrq_create()
16541 hrq->host_index = 0; in lpfc_mrq_create()
16542 hrq->hba_index = 0; in lpfc_mrq_create()
16543 hrq->notify_interval = LPFC_RQ_NOTIFY_INTRVL; in lpfc_mrq_create()
16545 drq->db_format = LPFC_DB_RING_FORMAT; in lpfc_mrq_create()
16546 drq->db_regaddr = phba->sli4_hba.RQDBregaddr; in lpfc_mrq_create()
16547 drq->type = LPFC_DRQ; in lpfc_mrq_create()
16548 drq->assoc_qid = cq->queue_id; in lpfc_mrq_create()
16549 drq->subtype = subtype; in lpfc_mrq_create()
16550 drq->host_index = 0; in lpfc_mrq_create()
16551 drq->hba_index = 0; in lpfc_mrq_create()
16552 drq->notify_interval = LPFC_RQ_NOTIFY_INTRVL; in lpfc_mrq_create()
16554 list_add_tail(&hrq->list, &cq->child_list); in lpfc_mrq_create()
16555 list_add_tail(&drq->list, &cq->child_list); in lpfc_mrq_create()
16559 /* The IOCTL status is embedded in the mailbox subheader. */ in lpfc_mrq_create()
16560 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_mrq_create()
16561 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_mrq_create()
16564 "3120 RQ_CREATE mailbox failed with " in lpfc_mrq_create()
16567 status = -ENXIO; in lpfc_mrq_create()
16570 rc = bf_get(lpfc_mbx_rq_create_q_id, &rq_create->u.response); in lpfc_mrq_create()
16572 status = -ENXIO; in lpfc_mrq_create()
16579 hrq->queue_id = rc + (2 * idx); in lpfc_mrq_create()
16581 drq->queue_id = rc + (2 * idx) + 1; in lpfc_mrq_create()
16590 * lpfc_eq_destroy - Destroy an event Queue on the HBA
16594 * This function destroys a queue, as detailed in @eq by sending an mailbox
16599 * On success this function will return a zero. If the queue destroy mailbox
16600 * command fails this function will return -ENXIO.
16612 return -ENODEV; in lpfc_eq_destroy()
16614 mbox = mempool_alloc(eq->phba->mbox_mem_pool, GFP_KERNEL); in lpfc_eq_destroy()
16616 return -ENOMEM; in lpfc_eq_destroy()
16617 length = (sizeof(struct lpfc_mbx_eq_destroy) - in lpfc_eq_destroy()
16622 bf_set(lpfc_mbx_eq_destroy_q_id, &mbox->u.mqe.un.eq_destroy.u.request, in lpfc_eq_destroy()
16623 eq->queue_id); in lpfc_eq_destroy()
16624 mbox->vport = eq->phba->pport; in lpfc_eq_destroy()
16625 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_eq_destroy()
16627 rc = lpfc_sli_issue_mbox(eq->phba, mbox, MBX_POLL); in lpfc_eq_destroy()
16628 /* The IOCTL status is embedded in the mailbox subheader. */ in lpfc_eq_destroy()
16630 &mbox->u.mqe.un.eq_destroy.header.cfg_shdr; in lpfc_eq_destroy()
16631 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_eq_destroy()
16632 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_eq_destroy()
16635 "2505 EQ_DESTROY mailbox failed with " in lpfc_eq_destroy()
16638 status = -ENXIO; in lpfc_eq_destroy()
16642 list_del_init(&eq->list); in lpfc_eq_destroy()
16643 mempool_free(mbox, eq->phba->mbox_mem_pool); in lpfc_eq_destroy()
16648 * lpfc_cq_destroy - Destroy a Completion Queue on the HBA
16652 * This function destroys a queue, as detailed in @cq by sending an mailbox
16657 * On success this function will return a zero. If the queue destroy mailbox
16658 * command fails this function will return -ENXIO.
16670 return -ENODEV; in lpfc_cq_destroy()
16671 mbox = mempool_alloc(cq->phba->mbox_mem_pool, GFP_KERNEL); in lpfc_cq_destroy()
16673 return -ENOMEM; in lpfc_cq_destroy()
16674 length = (sizeof(struct lpfc_mbx_cq_destroy) - in lpfc_cq_destroy()
16679 bf_set(lpfc_mbx_cq_destroy_q_id, &mbox->u.mqe.un.cq_destroy.u.request, in lpfc_cq_destroy()
16680 cq->queue_id); in lpfc_cq_destroy()
16681 mbox->vport = cq->phba->pport; in lpfc_cq_destroy()
16682 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_cq_destroy()
16683 rc = lpfc_sli_issue_mbox(cq->phba, mbox, MBX_POLL); in lpfc_cq_destroy()
16684 /* The IOCTL status is embedded in the mailbox subheader. */ in lpfc_cq_destroy()
16686 &mbox->u.mqe.un.wq_create.header.cfg_shdr; in lpfc_cq_destroy()
16687 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_cq_destroy()
16688 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_cq_destroy()
16691 "2506 CQ_DESTROY mailbox failed with " in lpfc_cq_destroy()
16694 status = -ENXIO; in lpfc_cq_destroy()
16697 list_del_init(&cq->list); in lpfc_cq_destroy()
16698 mempool_free(mbox, cq->phba->mbox_mem_pool); in lpfc_cq_destroy()
16703 * lpfc_mq_destroy - Destroy a Mailbox Queue on the HBA
16707 * This function destroys a queue, as detailed in @mq by sending an mailbox
16712 * On success this function will return a zero. If the queue destroy mailbox
16713 * command fails this function will return -ENXIO.
16725 return -ENODEV; in lpfc_mq_destroy()
16726 mbox = mempool_alloc(mq->phba->mbox_mem_pool, GFP_KERNEL); in lpfc_mq_destroy()
16728 return -ENOMEM; in lpfc_mq_destroy()
16729 length = (sizeof(struct lpfc_mbx_mq_destroy) - in lpfc_mq_destroy()
16734 bf_set(lpfc_mbx_mq_destroy_q_id, &mbox->u.mqe.un.mq_destroy.u.request, in lpfc_mq_destroy()
16735 mq->queue_id); in lpfc_mq_destroy()
16736 mbox->vport = mq->phba->pport; in lpfc_mq_destroy()
16737 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_mq_destroy()
16738 rc = lpfc_sli_issue_mbox(mq->phba, mbox, MBX_POLL); in lpfc_mq_destroy()
16739 /* The IOCTL status is embedded in the mailbox subheader. */ in lpfc_mq_destroy()
16741 &mbox->u.mqe.un.mq_destroy.header.cfg_shdr; in lpfc_mq_destroy()
16742 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_mq_destroy()
16743 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_mq_destroy()
16746 "2507 MQ_DESTROY mailbox failed with " in lpfc_mq_destroy()
16749 status = -ENXIO; in lpfc_mq_destroy()
16752 list_del_init(&mq->list); in lpfc_mq_destroy()
16753 mempool_free(mbox, mq->phba->mbox_mem_pool); in lpfc_mq_destroy()
16758 * lpfc_wq_destroy - Destroy a Work Queue on the HBA
16762 * This function destroys a queue, as detailed in @wq by sending an mailbox
16767 * On success this function will return a zero. If the queue destroy mailbox
16768 * command fails this function will return -ENXIO.
16780 return -ENODEV; in lpfc_wq_destroy()
16781 mbox = mempool_alloc(wq->phba->mbox_mem_pool, GFP_KERNEL); in lpfc_wq_destroy()
16783 return -ENOMEM; in lpfc_wq_destroy()
16784 length = (sizeof(struct lpfc_mbx_wq_destroy) - in lpfc_wq_destroy()
16789 bf_set(lpfc_mbx_wq_destroy_q_id, &mbox->u.mqe.un.wq_destroy.u.request, in lpfc_wq_destroy()
16790 wq->queue_id); in lpfc_wq_destroy()
16791 mbox->vport = wq->phba->pport; in lpfc_wq_destroy()
16792 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_wq_destroy()
16793 rc = lpfc_sli_issue_mbox(wq->phba, mbox, MBX_POLL); in lpfc_wq_destroy()
16795 &mbox->u.mqe.un.wq_destroy.header.cfg_shdr; in lpfc_wq_destroy()
16796 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_wq_destroy()
16797 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_wq_destroy()
16800 "2508 WQ_DESTROY mailbox failed with " in lpfc_wq_destroy()
16803 status = -ENXIO; in lpfc_wq_destroy()
16806 list_del_init(&wq->list); in lpfc_wq_destroy()
16807 kfree(wq->pring); in lpfc_wq_destroy()
16808 wq->pring = NULL; in lpfc_wq_destroy()
16809 mempool_free(mbox, wq->phba->mbox_mem_pool); in lpfc_wq_destroy()
16814 * lpfc_rq_destroy - Destroy a Receive Queue on the HBA
16819 * This function destroys a queue, as detailed in @rq by sending an mailbox
16824 * On success this function will return a zero. If the queue destroy mailbox
16825 * command fails this function will return -ENXIO.
16838 return -ENODEV; in lpfc_rq_destroy()
16839 mbox = mempool_alloc(hrq->phba->mbox_mem_pool, GFP_KERNEL); in lpfc_rq_destroy()
16841 return -ENOMEM; in lpfc_rq_destroy()
16842 length = (sizeof(struct lpfc_mbx_rq_destroy) - in lpfc_rq_destroy()
16847 bf_set(lpfc_mbx_rq_destroy_q_id, &mbox->u.mqe.un.rq_destroy.u.request, in lpfc_rq_destroy()
16848 hrq->queue_id); in lpfc_rq_destroy()
16849 mbox->vport = hrq->phba->pport; in lpfc_rq_destroy()
16850 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_rq_destroy()
16851 rc = lpfc_sli_issue_mbox(hrq->phba, mbox, MBX_POLL); in lpfc_rq_destroy()
16852 /* The IOCTL status is embedded in the mailbox subheader. */ in lpfc_rq_destroy()
16854 &mbox->u.mqe.un.rq_destroy.header.cfg_shdr; in lpfc_rq_destroy()
16855 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_rq_destroy()
16856 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_rq_destroy()
16859 "2509 RQ_DESTROY mailbox failed with " in lpfc_rq_destroy()
16862 mempool_free(mbox, hrq->phba->mbox_mem_pool); in lpfc_rq_destroy()
16863 return -ENXIO; in lpfc_rq_destroy()
16865 bf_set(lpfc_mbx_rq_destroy_q_id, &mbox->u.mqe.un.rq_destroy.u.request, in lpfc_rq_destroy()
16866 drq->queue_id); in lpfc_rq_destroy()
16867 rc = lpfc_sli_issue_mbox(drq->phba, mbox, MBX_POLL); in lpfc_rq_destroy()
16869 &mbox->u.mqe.un.rq_destroy.header.cfg_shdr; in lpfc_rq_destroy()
16870 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_rq_destroy()
16871 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_rq_destroy()
16874 "2510 RQ_DESTROY mailbox failed with " in lpfc_rq_destroy()
16877 status = -ENXIO; in lpfc_rq_destroy()
16879 list_del_init(&hrq->list); in lpfc_rq_destroy()
16880 list_del_init(&drq->list); in lpfc_rq_destroy()
16881 mempool_free(mbox, hrq->phba->mbox_mem_pool); in lpfc_rq_destroy()
16886 * lpfc_sli4_post_sgl - Post scatter gather list for an XRI to HBA
16904 * 0 - Success
16905 * -ENXIO, -ENOMEM - Failure
16923 return -EINVAL; in lpfc_sli4_post_sgl()
16926 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_post_sgl()
16928 return -ENOMEM; in lpfc_sli4_post_sgl()
16932 sizeof(struct lpfc_mbx_post_sgl_pages) - in lpfc_sli4_post_sgl()
16936 &mbox->u.mqe.un.post_sgl_pages; in lpfc_sli4_post_sgl()
16940 post_sgl_pages->sgl_pg_pairs[0].sgl_pg0_addr_lo = in lpfc_sli4_post_sgl()
16942 post_sgl_pages->sgl_pg_pairs[0].sgl_pg0_addr_hi = in lpfc_sli4_post_sgl()
16945 post_sgl_pages->sgl_pg_pairs[0].sgl_pg1_addr_lo = in lpfc_sli4_post_sgl()
16947 post_sgl_pages->sgl_pg_pairs[0].sgl_pg1_addr_hi = in lpfc_sli4_post_sgl()
16949 if (!phba->sli4_hba.intr_enable) in lpfc_sli4_post_sgl()
16955 /* The IOCTL status is embedded in the mailbox subheader. */ in lpfc_sli4_post_sgl()
16956 shdr = (union lpfc_sli4_cfg_shdr *) &post_sgl_pages->header.cfg_shdr; in lpfc_sli4_post_sgl()
16957 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_sli4_post_sgl()
16958 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_sli4_post_sgl()
16959 if (!phba->sli4_hba.intr_enable) in lpfc_sli4_post_sgl()
16960 mempool_free(mbox, phba->mbox_mem_pool); in lpfc_sli4_post_sgl()
16962 mempool_free(mbox, phba->mbox_mem_pool); in lpfc_sli4_post_sgl()
16965 "2511 POST_SGL mailbox failed with " in lpfc_sli4_post_sgl()
16973 * lpfc_sli4_alloc_xri - Get an available rpi in the device's range
16977 * HBA consistent with the SLI-4 interface spec. This routine
16994 spin_lock_irq(&phba->hbalock); in lpfc_sli4_alloc_xri()
16995 xri = find_next_zero_bit(phba->sli4_hba.xri_bmask, in lpfc_sli4_alloc_xri()
16996 phba->sli4_hba.max_cfg_param.max_xri, 0); in lpfc_sli4_alloc_xri()
16997 if (xri >= phba->sli4_hba.max_cfg_param.max_xri) { in lpfc_sli4_alloc_xri()
16998 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_alloc_xri()
17001 set_bit(xri, phba->sli4_hba.xri_bmask); in lpfc_sli4_alloc_xri()
17002 phba->sli4_hba.max_cfg_param.xri_used++; in lpfc_sli4_alloc_xri()
17004 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_alloc_xri()
17009 * lpfc_sli4_free_xri - Release an xri for reuse.
17019 if (test_and_clear_bit(xri, phba->sli4_hba.xri_bmask)) { in __lpfc_sli4_free_xri()
17020 phba->sli4_hba.max_cfg_param.xri_used--; in __lpfc_sli4_free_xri()
17025 * lpfc_sli4_free_xri - Release an xri for reuse.
17035 spin_lock_irq(&phba->hbalock); in lpfc_sli4_free_xri()
17037 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_free_xri()
17041 * lpfc_sli4_next_xritag - Get an xritag for the io
17061 phba->sli4_hba.max_cfg_param.max_xri, in lpfc_sli4_next_xritag()
17062 phba->sli4_hba.max_cfg_param.xri_used); in lpfc_sli4_next_xritag()
17067 * lpfc_sli4_post_sgl_list - post a block of ELS sgls to the port.
17073 * HBA using non-embedded mailbox command. No Lock is held. This routine
17100 return -ENOMEM; in lpfc_sli4_post_sgl_list()
17103 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_post_sgl_list()
17105 return -ENOMEM; in lpfc_sli4_post_sgl_list()
17107 /* Allocate DMA memory and set up the non-embedded mailbox command */ in lpfc_sli4_post_sgl_list()
17118 return -ENOMEM; in lpfc_sli4_post_sgl_list()
17120 /* Set up the SGL pages in the non-embedded DMA pages */ in lpfc_sli4_post_sgl_list()
17121 viraddr = mbox->sge_array->addr[0]; in lpfc_sli4_post_sgl_list()
17123 sgl_pg_pairs = &sgl->sgl_pg_pairs; in lpfc_sli4_post_sgl_list()
17128 sgl_pg_pairs->sgl_pg0_addr_lo = in lpfc_sli4_post_sgl_list()
17129 cpu_to_le32(putPaddrLow(sglq_entry->phys)); in lpfc_sli4_post_sgl_list()
17130 sgl_pg_pairs->sgl_pg0_addr_hi = in lpfc_sli4_post_sgl_list()
17131 cpu_to_le32(putPaddrHigh(sglq_entry->phys)); in lpfc_sli4_post_sgl_list()
17132 sgl_pg_pairs->sgl_pg1_addr_lo = in lpfc_sli4_post_sgl_list()
17134 sgl_pg_pairs->sgl_pg1_addr_hi = in lpfc_sli4_post_sgl_list()
17139 xritag_start = sglq_entry->sli4_xritag; in lpfc_sli4_post_sgl_list()
17147 sgl->word0 = cpu_to_le32(sgl->word0); in lpfc_sli4_post_sgl_list()
17149 if (!phba->sli4_hba.intr_enable) in lpfc_sli4_post_sgl_list()
17155 shdr = (union lpfc_sli4_cfg_shdr *) &sgl->cfg_shdr; in lpfc_sli4_post_sgl_list()
17156 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_sli4_post_sgl_list()
17157 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_sli4_post_sgl_list()
17158 if (!phba->sli4_hba.intr_enable) in lpfc_sli4_post_sgl_list()
17164 "2513 POST_SGL_BLOCK mailbox command failed " in lpfc_sli4_post_sgl_list()
17167 rc = -ENXIO; in lpfc_sli4_post_sgl_list()
17173 * lpfc_sli4_post_io_sgl_block - post a block of nvme sgl list to firmware
17179 * SCSI buffer list @nblist to the HBA using non-embedded mailbox command.
17207 return -ENOMEM; in lpfc_sli4_post_io_sgl_block()
17209 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_post_io_sgl_block()
17213 return -ENOMEM; in lpfc_sli4_post_io_sgl_block()
17216 /* Allocate DMA memory and set up the non-embedded mailbox command */ in lpfc_sli4_post_io_sgl_block()
17227 return -ENOMEM; in lpfc_sli4_post_io_sgl_block()
17230 /* Get the first SGE entry from the non-embedded DMA memory */ in lpfc_sli4_post_io_sgl_block()
17231 viraddr = mbox->sge_array->addr[0]; in lpfc_sli4_post_io_sgl_block()
17233 /* Set up the SGL pages in the non-embedded DMA pages */ in lpfc_sli4_post_io_sgl_block()
17235 sgl_pg_pairs = &sgl->sgl_pg_pairs; in lpfc_sli4_post_io_sgl_block()
17240 sgl_pg_pairs->sgl_pg0_addr_lo = in lpfc_sli4_post_io_sgl_block()
17241 cpu_to_le32(putPaddrLow(lpfc_ncmd->dma_phys_sgl)); in lpfc_sli4_post_io_sgl_block()
17242 sgl_pg_pairs->sgl_pg0_addr_hi = in lpfc_sli4_post_io_sgl_block()
17243 cpu_to_le32(putPaddrHigh(lpfc_ncmd->dma_phys_sgl)); in lpfc_sli4_post_io_sgl_block()
17244 if (phba->cfg_sg_dma_buf_size > SGL_PAGE_SIZE) in lpfc_sli4_post_io_sgl_block()
17245 pdma_phys_bpl1 = lpfc_ncmd->dma_phys_sgl + in lpfc_sli4_post_io_sgl_block()
17249 sgl_pg_pairs->sgl_pg1_addr_lo = in lpfc_sli4_post_io_sgl_block()
17251 sgl_pg_pairs->sgl_pg1_addr_hi = in lpfc_sli4_post_io_sgl_block()
17255 xritag_start = lpfc_ncmd->cur_iocbq.sli4_xritag; in lpfc_sli4_post_io_sgl_block()
17262 sgl->word0 = cpu_to_le32(sgl->word0); in lpfc_sli4_post_io_sgl_block()
17264 if (!phba->sli4_hba.intr_enable) { in lpfc_sli4_post_io_sgl_block()
17270 shdr = (union lpfc_sli4_cfg_shdr *)&sgl->cfg_shdr; in lpfc_sli4_post_io_sgl_block()
17271 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_sli4_post_io_sgl_block()
17272 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_sli4_post_io_sgl_block()
17273 if (!phba->sli4_hba.intr_enable) in lpfc_sli4_post_io_sgl_block()
17279 "6125 POST_SGL_BLOCK mailbox command failed " in lpfc_sli4_post_io_sgl_block()
17282 rc = -ENXIO; in lpfc_sli4_post_io_sgl_block()
17288 * lpfc_sli4_post_io_sgl_list - Post blocks of nvme buffer sgls from a list
17295 * uses the non-embedded SGL block post mailbox commands to post to the port.
17296 * For single NVME buffer sgl with non-contiguous xri, if any, it shall use
17297 * embedded SGL post mailbox command for posting. The @post_nblist passed in
17300 * Returns: 0 = failure, non-zero number of successfully posted buffers.
17318 return -EINVAL; in lpfc_sli4_post_io_sgl_list()
17320 sgl_size = phba->cfg_sg_dma_buf_size; in lpfc_sli4_post_io_sgl_list()
17322 list_del_init(&lpfc_ncmd->list); in lpfc_sli4_post_io_sgl_list()
17325 (lpfc_ncmd->cur_iocbq.sli4_xritag != last_xritag + 1)) { in lpfc_sli4_post_io_sgl_list()
17328 post_cnt = block_cnt - 1; in lpfc_sli4_post_io_sgl_list()
17330 list_add_tail(&lpfc_ncmd->list, &prep_nblist); in lpfc_sli4_post_io_sgl_list()
17334 list_add_tail(&lpfc_ncmd->list, &prep_nblist); in lpfc_sli4_post_io_sgl_list()
17335 /* enough sgls for non-embed sgl mbox command */ in lpfc_sli4_post_io_sgl_list()
17343 last_xritag = lpfc_ncmd->cur_iocbq.sli4_xritag; in lpfc_sli4_post_io_sgl_list()
17352 /* last single sgl with non-contiguous xri */ in lpfc_sli4_post_io_sgl_list()
17355 lpfc_ncmd->dma_phys_sgl + in lpfc_sli4_post_io_sgl_list()
17359 cur_xritag = lpfc_ncmd->cur_iocbq.sli4_xritag; in lpfc_sli4_post_io_sgl_list()
17361 phba, lpfc_ncmd->dma_phys_sgl, in lpfc_sli4_post_io_sgl_list()
17365 lpfc_ncmd->flags |= in lpfc_sli4_post_io_sgl_list()
17369 lpfc_ncmd->flags &= in lpfc_sli4_post_io_sgl_list()
17371 lpfc_ncmd->status = IOSTAT_SUCCESS; in lpfc_sli4_post_io_sgl_list()
17375 list_add_tail(&lpfc_ncmd->list, &nvme_nblist); in lpfc_sli4_post_io_sgl_list()
17394 /* put posted NVME buffer-sgl posted on NVME buffer sgl list */ in lpfc_sli4_post_io_sgl_list()
17400 lpfc_ncmd->flags |= LPFC_SBUF_NOT_POSTED; in lpfc_sli4_post_io_sgl_list()
17403 lpfc_ncmd->flags &= ~LPFC_SBUF_NOT_POSTED; in lpfc_sli4_post_io_sgl_list()
17404 lpfc_ncmd->status = IOSTAT_SUCCESS; in lpfc_sli4_post_io_sgl_list()
17407 list_add_tail(&lpfc_ncmd->list, &nvme_nblist); in lpfc_sli4_post_io_sgl_list()
17417 * lpfc_fc_frame_check - Check that this frame is a valid frame to handle
17435 switch (fc_hdr->fh_r_ctl) { in lpfc_fc_frame_check()
17446 case FC_RCTL_ELS4_REQ: /* FC-4 ELS request */ in lpfc_fc_frame_check()
17447 case FC_RCTL_ELS4_REP: /* FC-4 ELS reply */ in lpfc_fc_frame_check()
17473 switch (fc_hdr->fh_type) { in lpfc_fc_frame_check()
17489 fc_hdr->fh_r_ctl, fc_hdr->fh_type, in lpfc_fc_frame_check()
17498 fc_hdr->fh_r_ctl, fc_hdr->fh_type); in lpfc_fc_frame_check()
17503 * lpfc_fc_hdr_get_vfi - Get the VFI from an FC frame
17515 if (fc_hdr->fh_r_ctl != FC_RCTL_VFTH) in lpfc_fc_hdr_get_vfi()
17521 * lpfc_fc_frame_to_vport - Finds the vport that a frame is destined to
17542 return phba->pport; in lpfc_fc_frame_to_vport()
17543 if ((phba->pport->fc_flag & FC_PT2PT) && in lpfc_fc_frame_to_vport()
17544 !(phba->link_state == LPFC_HBA_READY)) in lpfc_fc_frame_to_vport()
17545 return phba->pport; in lpfc_fc_frame_to_vport()
17549 for (i = 0; i <= phba->max_vpi && vports[i] != NULL; i++) { in lpfc_fc_frame_to_vport()
17550 if (phba->fcf.fcfi == fcfi && in lpfc_fc_frame_to_vport()
17551 vports[i]->vfi == lpfc_fc_hdr_get_vfi(fc_hdr) && in lpfc_fc_frame_to_vport()
17552 vports[i]->fc_myDID == did) { in lpfc_fc_frame_to_vport()
17563 * lpfc_update_rcv_time_stamp - Update vport's rcv seq time stamp
17579 h_buf = list_get_first(&vport->rcv_buffer_list, in lpfc_update_rcv_time_stamp()
17584 vport->rcv_buffer_time_stamp = dmabuf->time_stamp; in lpfc_update_rcv_time_stamp()
17588 * lpfc_cleanup_rcv_buffers - Cleans up all outstanding receive sequences.
17603 list_for_each_entry_safe(h_buf, hnext, &vport->rcv_buffer_list, list) { in lpfc_cleanup_rcv_buffers()
17605 list_del_init(&dmabuf->hbuf.list); in lpfc_cleanup_rcv_buffers()
17607 &dmabuf->dbuf.list, list) { in lpfc_cleanup_rcv_buffers()
17608 list_del_init(&d_buf->list); in lpfc_cleanup_rcv_buffers()
17609 lpfc_in_buf_free(vport->phba, d_buf); in lpfc_cleanup_rcv_buffers()
17611 lpfc_in_buf_free(vport->phba, &dmabuf->dbuf); in lpfc_cleanup_rcv_buffers()
17616 * lpfc_rcv_seq_check_edtov - Cleans up timed out receive sequences.
17636 timeout = (msecs_to_jiffies(vport->phba->fc_edtov) + in lpfc_rcv_seq_check_edtov()
17637 vport->rcv_buffer_time_stamp); in lpfc_rcv_seq_check_edtov()
17638 if (list_empty(&vport->rcv_buffer_list) || in lpfc_rcv_seq_check_edtov()
17642 list_for_each_entry_safe(h_buf, hnext, &vport->rcv_buffer_list, list) { in lpfc_rcv_seq_check_edtov()
17644 timeout = (msecs_to_jiffies(vport->phba->fc_edtov) + in lpfc_rcv_seq_check_edtov()
17645 dmabuf->time_stamp); in lpfc_rcv_seq_check_edtov()
17649 list_del_init(&dmabuf->hbuf.list); in lpfc_rcv_seq_check_edtov()
17651 &dmabuf->dbuf.list, list) { in lpfc_rcv_seq_check_edtov()
17652 list_del_init(&d_buf->list); in lpfc_rcv_seq_check_edtov()
17653 lpfc_in_buf_free(vport->phba, d_buf); in lpfc_rcv_seq_check_edtov()
17655 lpfc_in_buf_free(vport->phba, &dmabuf->dbuf); in lpfc_rcv_seq_check_edtov()
17662 * lpfc_fc_frame_add - Adds a frame to the vport's list of received sequences
17685 INIT_LIST_HEAD(&dmabuf->dbuf.list); in lpfc_fc_frame_add()
17686 dmabuf->time_stamp = jiffies; in lpfc_fc_frame_add()
17687 new_hdr = (struct fc_frame_header *)dmabuf->hbuf.virt; in lpfc_fc_frame_add()
17690 list_for_each_entry(h_buf, &vport->rcv_buffer_list, list) { in lpfc_fc_frame_add()
17691 temp_hdr = (struct fc_frame_header *)h_buf->virt; in lpfc_fc_frame_add()
17692 if ((temp_hdr->fh_seq_id != new_hdr->fh_seq_id) || in lpfc_fc_frame_add()
17693 (temp_hdr->fh_ox_id != new_hdr->fh_ox_id) || in lpfc_fc_frame_add()
17694 (memcmp(&temp_hdr->fh_s_id, &new_hdr->fh_s_id, 3))) in lpfc_fc_frame_add()
17705 list_add_tail(&dmabuf->hbuf.list, &vport->rcv_buffer_list); in lpfc_fc_frame_add()
17709 temp_hdr = seq_dmabuf->hbuf.virt; in lpfc_fc_frame_add()
17710 if (be16_to_cpu(new_hdr->fh_seq_cnt) < in lpfc_fc_frame_add()
17711 be16_to_cpu(temp_hdr->fh_seq_cnt)) { in lpfc_fc_frame_add()
17712 list_del_init(&seq_dmabuf->hbuf.list); in lpfc_fc_frame_add()
17713 list_add_tail(&dmabuf->hbuf.list, &vport->rcv_buffer_list); in lpfc_fc_frame_add()
17714 list_add_tail(&dmabuf->dbuf.list, &seq_dmabuf->dbuf.list); in lpfc_fc_frame_add()
17719 list_move_tail(&seq_dmabuf->hbuf.list, &vport->rcv_buffer_list); in lpfc_fc_frame_add()
17720 seq_dmabuf->time_stamp = jiffies; in lpfc_fc_frame_add()
17722 if (list_empty(&seq_dmabuf->dbuf.list)) { in lpfc_fc_frame_add()
17723 temp_hdr = dmabuf->hbuf.virt; in lpfc_fc_frame_add()
17724 list_add_tail(&dmabuf->dbuf.list, &seq_dmabuf->dbuf.list); in lpfc_fc_frame_add()
17728 d_buf = list_entry(seq_dmabuf->dbuf.list.prev, typeof(*d_buf), list); in lpfc_fc_frame_add()
17731 temp_hdr = (struct fc_frame_header *)temp_dmabuf->hbuf.virt; in lpfc_fc_frame_add()
17736 if (be16_to_cpu(new_hdr->fh_seq_cnt) > in lpfc_fc_frame_add()
17737 be16_to_cpu(temp_hdr->fh_seq_cnt)) { in lpfc_fc_frame_add()
17738 list_add(&dmabuf->dbuf.list, &temp_dmabuf->dbuf.list); in lpfc_fc_frame_add()
17743 if (&d_buf->list == &seq_dmabuf->dbuf.list) in lpfc_fc_frame_add()
17745 d_buf = list_entry(d_buf->list.prev, typeof(*d_buf), list); in lpfc_fc_frame_add()
17754 * lpfc_sli4_abort_partial_seq - Abort partially assembled unsol sequence
17764 * true -- if there is matching partially assembled sequence present and all
17766 * false -- if there is no matching partially assembled sequence present so
17779 INIT_LIST_HEAD(&dmabuf->dbuf.list); in lpfc_sli4_abort_partial_seq()
17780 INIT_LIST_HEAD(&dmabuf->hbuf.list); in lpfc_sli4_abort_partial_seq()
17781 new_hdr = (struct fc_frame_header *)dmabuf->hbuf.virt; in lpfc_sli4_abort_partial_seq()
17782 list_for_each_entry(h_buf, &vport->rcv_buffer_list, list) { in lpfc_sli4_abort_partial_seq()
17783 temp_hdr = (struct fc_frame_header *)h_buf->virt; in lpfc_sli4_abort_partial_seq()
17784 if ((temp_hdr->fh_seq_id != new_hdr->fh_seq_id) || in lpfc_sli4_abort_partial_seq()
17785 (temp_hdr->fh_ox_id != new_hdr->fh_ox_id) || in lpfc_sli4_abort_partial_seq()
17786 (memcmp(&temp_hdr->fh_s_id, &new_hdr->fh_s_id, 3))) in lpfc_sli4_abort_partial_seq()
17796 &seq_dmabuf->dbuf.list, list) { in lpfc_sli4_abort_partial_seq()
17797 list_del_init(&d_buf->list); in lpfc_sli4_abort_partial_seq()
17798 lpfc_in_buf_free(vport->phba, d_buf); in lpfc_sli4_abort_partial_seq()
17806 * lpfc_sli4_abort_ulp_seq - Abort assembled unsol sequence from ulp
17816 * true -- if there is matching pending context of the sequence cleaned
17818 * false -- if there is no matching pending context of the sequence present
17824 struct lpfc_hba *phba = vport->phba; in lpfc_sli4_abort_ulp_seq()
17828 if (phba->sli_rev < LPFC_SLI_REV4) in lpfc_sli4_abort_ulp_seq()
17840 * lpfc_sli4_seq_abort_rsp_cmpl - BLS ABORT RSP seq abort iocb complete handler
17857 ndlp = (struct lpfc_nodelist *)cmd_iocbq->context1; in lpfc_sli4_seq_abort_rsp_cmpl()
17863 if (rsp_iocbq && rsp_iocbq->iocb.ulpStatus) in lpfc_sli4_seq_abort_rsp_cmpl()
17866 rsp_iocbq->iocb.ulpStatus, in lpfc_sli4_seq_abort_rsp_cmpl()
17867 rsp_iocbq->iocb.un.ulpWord[4]); in lpfc_sli4_seq_abort_rsp_cmpl()
17871 * lpfc_sli4_xri_inrange - check xri is in range of xris owned by driver.
17884 for (i = 0; i < phba->sli4_hba.max_cfg_param.max_xri; i++) { in lpfc_sli4_xri_inrange()
17885 if (xri == phba->sli4_hba.xri_ids[i]) in lpfc_sli4_xri_inrange()
17892 * lpfc_sli4_seq_abort_rsp - bls rsp to sequence abort
17904 struct lpfc_hba *phba = vport->phba; in lpfc_sli4_seq_abort_rsp()
17916 oxid = be16_to_cpu(fc_hdr->fh_ox_id); in lpfc_sli4_seq_abort_rsp()
17917 rxid = be16_to_cpu(fc_hdr->fh_rx_id); in lpfc_sli4_seq_abort_rsp()
17931 /* re-setup ndlp without removing from node list */ in lpfc_sli4_seq_abort_rsp()
17949 icmd = &ctiocb->iocb; in lpfc_sli4_seq_abort_rsp()
17950 icmd->un.xseq64.bdl.bdeSize = 0; in lpfc_sli4_seq_abort_rsp()
17951 icmd->un.xseq64.bdl.ulpIoTag32 = 0; in lpfc_sli4_seq_abort_rsp()
17952 icmd->un.xseq64.w5.hcsw.Dfctl = 0; in lpfc_sli4_seq_abort_rsp()
17953 icmd->un.xseq64.w5.hcsw.Rctl = FC_RCTL_BA_ACC; in lpfc_sli4_seq_abort_rsp()
17954 icmd->un.xseq64.w5.hcsw.Type = FC_TYPE_BLS; in lpfc_sli4_seq_abort_rsp()
17957 icmd->ulpCommand = CMD_XMIT_BLS_RSP64_CX; in lpfc_sli4_seq_abort_rsp()
17958 icmd->ulpBdeCount = 0; in lpfc_sli4_seq_abort_rsp()
17959 icmd->ulpLe = 1; in lpfc_sli4_seq_abort_rsp()
17960 icmd->ulpClass = CLASS3; in lpfc_sli4_seq_abort_rsp()
17961 icmd->ulpContext = phba->sli4_hba.rpi_ids[ndlp->nlp_rpi]; in lpfc_sli4_seq_abort_rsp()
17962 ctiocb->context1 = lpfc_nlp_get(ndlp); in lpfc_sli4_seq_abort_rsp()
17964 ctiocb->vport = phba->pport; in lpfc_sli4_seq_abort_rsp()
17965 ctiocb->iocb_cmpl = lpfc_sli4_seq_abort_rsp_cmpl; in lpfc_sli4_seq_abort_rsp()
17966 ctiocb->sli4_lxritag = NO_XRI; in lpfc_sli4_seq_abort_rsp()
17967 ctiocb->sli4_xritag = NO_XRI; in lpfc_sli4_seq_abort_rsp()
17987 icmd->un.xseq64.w5.hcsw.Rctl = FC_RCTL_BA_RJT; in lpfc_sli4_seq_abort_rsp()
17988 bf_set(lpfc_vndr_code, &icmd->un.bls_rsp, 0); in lpfc_sli4_seq_abort_rsp()
17989 bf_set(lpfc_rsn_expln, &icmd->un.bls_rsp, FC_BA_RJT_INV_XID); in lpfc_sli4_seq_abort_rsp()
17990 bf_set(lpfc_rsn_code, &icmd->un.bls_rsp, FC_BA_RJT_UNABLE); in lpfc_sli4_seq_abort_rsp()
17998 icmd->un.xseq64.w5.hcsw.Rctl = FC_RCTL_BA_RJT; in lpfc_sli4_seq_abort_rsp()
17999 bf_set(lpfc_vndr_code, &icmd->un.bls_rsp, 0); in lpfc_sli4_seq_abort_rsp()
18000 bf_set(lpfc_rsn_expln, &icmd->un.bls_rsp, FC_BA_RJT_INV_XID); in lpfc_sli4_seq_abort_rsp()
18001 bf_set(lpfc_rsn_code, &icmd->un.bls_rsp, FC_BA_RJT_UNABLE); in lpfc_sli4_seq_abort_rsp()
18009 bf_set(lpfc_abts_orig, &icmd->un.bls_rsp, LPFC_ABTS_UNSOL_RSP); in lpfc_sli4_seq_abort_rsp()
18015 bf_set(lpfc_abts_orig, &icmd->un.bls_rsp, LPFC_ABTS_UNSOL_INT); in lpfc_sli4_seq_abort_rsp()
18017 bf_set(lpfc_abts_rxid, &icmd->un.bls_rsp, rxid); in lpfc_sli4_seq_abort_rsp()
18018 bf_set(lpfc_abts_oxid, &icmd->un.bls_rsp, oxid); in lpfc_sli4_seq_abort_rsp()
18023 icmd->un.xseq64.w5.hcsw.Rctl, oxid, phba->link_state); in lpfc_sli4_seq_abort_rsp()
18030 icmd->un.xseq64.w5.hcsw.Rctl, oxid, in lpfc_sli4_seq_abort_rsp()
18031 phba->link_state); in lpfc_sli4_seq_abort_rsp()
18033 ctiocb->context1 = NULL; in lpfc_sli4_seq_abort_rsp()
18039 * lpfc_sli4_handle_unsol_abort - Handle sli-4 unsolicited abort event
18043 * This function handles an SLI-4 unsolicited abort event. If the unsolicited
18055 struct lpfc_hba *phba = vport->phba; in lpfc_sli4_handle_unsol_abort()
18061 memcpy(&fc_hdr, dmabuf->hbuf.virt, sizeof(struct fc_frame_header)); in lpfc_sli4_handle_unsol_abort()
18073 lpfc_in_buf_free(phba, &dmabuf->dbuf); in lpfc_sli4_handle_unsol_abort()
18075 if (phba->nvmet_support) { in lpfc_sli4_handle_unsol_abort()
18085 * lpfc_seq_complete - Indicates if a sequence is complete
18105 hdr = (struct fc_frame_header *)dmabuf->hbuf.virt; in lpfc_seq_complete()
18107 if (hdr->fh_seq_cnt != seq_count) in lpfc_seq_complete()
18109 fctl = (hdr->fh_f_ctl[0] << 16 | in lpfc_seq_complete()
18110 hdr->fh_f_ctl[1] << 8 | in lpfc_seq_complete()
18111 hdr->fh_f_ctl[2]); in lpfc_seq_complete()
18115 list_for_each_entry(d_buf, &dmabuf->dbuf.list, list) { in lpfc_seq_complete()
18117 hdr = (struct fc_frame_header *)seq_dmabuf->hbuf.virt; in lpfc_seq_complete()
18119 if (++seq_count != be16_to_cpu(hdr->fh_seq_cnt)) in lpfc_seq_complete()
18121 fctl = (hdr->fh_f_ctl[0] << 16 | in lpfc_seq_complete()
18122 hdr->fh_f_ctl[1] << 8 | in lpfc_seq_complete()
18123 hdr->fh_f_ctl[2]); in lpfc_seq_complete()
18132 * lpfc_prep_seq - Prep sequence for ULP processing
18155 fc_hdr = (struct fc_frame_header *)seq_dmabuf->hbuf.virt; in lpfc_prep_seq()
18157 list_del_init(&seq_dmabuf->hbuf.list); in lpfc_prep_seq()
18163 first_iocbq = lpfc_sli_get_iocbq(vport->phba); in lpfc_prep_seq()
18166 first_iocbq->iocb.unsli3.rcvsli3.acc_len = 0; in lpfc_prep_seq()
18167 first_iocbq->iocb.ulpStatus = IOSTAT_SUCCESS; in lpfc_prep_seq()
18168 first_iocbq->vport = vport; in lpfc_prep_seq()
18172 first_iocbq->iocb.ulpCommand = CMD_IOCB_RCV_ELS64_CX; in lpfc_prep_seq()
18173 first_iocbq->iocb.un.rcvels.parmRo = in lpfc_prep_seq()
18175 first_iocbq->iocb.ulpPU = PARM_NPIV_DID; in lpfc_prep_seq()
18177 first_iocbq->iocb.ulpCommand = CMD_IOCB_RCV_SEQ64_CX; in lpfc_prep_seq()
18178 first_iocbq->iocb.ulpContext = NO_XRI; in lpfc_prep_seq()
18179 first_iocbq->iocb.unsli3.rcvsli3.ox_id = in lpfc_prep_seq()
18180 be16_to_cpu(fc_hdr->fh_ox_id); in lpfc_prep_seq()
18182 first_iocbq->iocb.unsli3.rcvsli3.vpi = in lpfc_prep_seq()
18183 vport->phba->vpi_ids[vport->vpi]; in lpfc_prep_seq()
18186 &seq_dmabuf->cq_event.cqe.rcqe_cmpl); in lpfc_prep_seq()
18188 first_iocbq->context2 = &seq_dmabuf->dbuf; in lpfc_prep_seq()
18189 first_iocbq->context3 = NULL; in lpfc_prep_seq()
18190 first_iocbq->iocb.ulpBdeCount = 1; in lpfc_prep_seq()
18192 first_iocbq->iocb.un.cont64[0].tus.f.bdeSize = in lpfc_prep_seq()
18195 first_iocbq->iocb.un.cont64[0].tus.f.bdeSize = tot_len; in lpfc_prep_seq()
18197 first_iocbq->iocb.un.rcvels.remoteID = sid; in lpfc_prep_seq()
18199 first_iocbq->iocb.unsli3.rcvsli3.acc_len = tot_len; in lpfc_prep_seq()
18206 list_for_each_entry_safe(d_buf, n_buf, &seq_dmabuf->dbuf.list, list) { in lpfc_prep_seq()
18208 lpfc_in_buf_free(vport->phba, d_buf); in lpfc_prep_seq()
18211 if (!iocbq->context3) { in lpfc_prep_seq()
18212 iocbq->context3 = d_buf; in lpfc_prep_seq()
18213 iocbq->iocb.ulpBdeCount++; in lpfc_prep_seq()
18217 &hbq_buf->cq_event.cqe.rcqe_cmpl); in lpfc_prep_seq()
18219 &iocbq->iocb.unsli3.sli3Words[4]; in lpfc_prep_seq()
18221 pbde->tus.f.bdeSize = LPFC_DATA_BUF_SIZE; in lpfc_prep_seq()
18223 pbde->tus.f.bdeSize = len; in lpfc_prep_seq()
18225 iocbq->iocb.unsli3.rcvsli3.acc_len += len; in lpfc_prep_seq()
18228 iocbq = lpfc_sli_get_iocbq(vport->phba); in lpfc_prep_seq()
18231 first_iocbq->iocb.ulpStatus = in lpfc_prep_seq()
18233 first_iocbq->iocb.un.ulpWord[4] = in lpfc_prep_seq()
18236 lpfc_in_buf_free(vport->phba, d_buf); in lpfc_prep_seq()
18242 &hbq_buf->cq_event.cqe.rcqe_cmpl); in lpfc_prep_seq()
18243 iocbq->context2 = d_buf; in lpfc_prep_seq()
18244 iocbq->context3 = NULL; in lpfc_prep_seq()
18245 iocbq->iocb.ulpBdeCount = 1; in lpfc_prep_seq()
18247 iocbq->iocb.un.cont64[0].tus.f.bdeSize = in lpfc_prep_seq()
18250 iocbq->iocb.un.cont64[0].tus.f.bdeSize = len; in lpfc_prep_seq()
18253 iocbq->iocb.unsli3.rcvsli3.acc_len = tot_len; in lpfc_prep_seq()
18255 iocbq->iocb.un.rcvels.remoteID = sid; in lpfc_prep_seq()
18256 list_add_tail(&iocbq->list, &first_iocbq->list); in lpfc_prep_seq()
18261 lpfc_in_buf_free(vport->phba, &seq_dmabuf->dbuf); in lpfc_prep_seq()
18272 struct lpfc_hba *phba = vport->phba; in lpfc_sli4_send_seq_to_ulp()
18274 fc_hdr = (struct fc_frame_header *)seq_dmabuf->hbuf.virt; in lpfc_sli4_send_seq_to_ulp()
18281 fc_hdr->fh_r_ctl, fc_hdr->fh_type); in lpfc_sli4_send_seq_to_ulp()
18285 phba->sli4_hba.els_wq->pring, in lpfc_sli4_send_seq_to_ulp()
18286 iocbq, fc_hdr->fh_r_ctl, in lpfc_sli4_send_seq_to_ulp()
18287 fc_hdr->fh_type)) { in lpfc_sli4_send_seq_to_ulp()
18292 fc_hdr->fh_r_ctl, fc_hdr->fh_type); in lpfc_sli4_send_seq_to_ulp()
18293 lpfc_in_buf_free(phba, &seq_dmabuf->dbuf); in lpfc_sli4_send_seq_to_ulp()
18298 &iocbq->list, list) { in lpfc_sli4_send_seq_to_ulp()
18299 list_del_init(&curr_iocb->list); in lpfc_sli4_send_seq_to_ulp()
18309 struct lpfc_dmabuf *pcmd = cmdiocb->context2; in lpfc_sli4_mds_loopback_cmpl()
18311 if (pcmd && pcmd->virt) in lpfc_sli4_mds_loopback_cmpl()
18312 dma_pool_free(phba->lpfc_drb_pool, pcmd->virt, pcmd->phys); in lpfc_sli4_mds_loopback_cmpl()
18323 struct lpfc_hba *phba = vport->phba; in lpfc_sli4_handle_mds_loopback()
18331 fc_hdr = (struct fc_frame_header *)dmabuf->hbuf.virt; in lpfc_sli4_handle_mds_loopback()
18332 frame_len = bf_get(lpfc_rcqe_length, &dmabuf->cq_event.cqe.rcqe_cmpl); in lpfc_sli4_handle_mds_loopback()
18338 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_handle_mds_loopback()
18339 list_add_tail(&dmabuf->cq_event.list, in lpfc_sli4_handle_mds_loopback()
18340 &phba->sli4_hba.sp_queue_event); in lpfc_sli4_handle_mds_loopback()
18341 phba->hba_flag |= HBA_SP_QUEUE_EVT; in lpfc_sli4_handle_mds_loopback()
18342 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_handle_mds_loopback()
18350 pcmd->virt = dma_pool_alloc(phba->lpfc_drb_pool, GFP_KERNEL, in lpfc_sli4_handle_mds_loopback()
18351 &pcmd->phys); in lpfc_sli4_handle_mds_loopback()
18352 if (!pcmd || !pcmd->virt) in lpfc_sli4_handle_mds_loopback()
18355 INIT_LIST_HEAD(&pcmd->list); in lpfc_sli4_handle_mds_loopback()
18358 memcpy(pcmd->virt, dmabuf->dbuf.virt, frame_len); in lpfc_sli4_handle_mds_loopback()
18361 iocbq->iocb.un.xseq64.bdl.addrHigh = putPaddrHigh(pcmd->phys); in lpfc_sli4_handle_mds_loopback()
18362 iocbq->iocb.un.xseq64.bdl.addrLow = putPaddrLow(pcmd->phys); in lpfc_sli4_handle_mds_loopback()
18363 iocbq->iocb.un.xseq64.bdl.bdeFlags = BUFF_TYPE_BDE_64; in lpfc_sli4_handle_mds_loopback()
18364 iocbq->iocb.un.xseq64.bdl.bdeSize = frame_len; in lpfc_sli4_handle_mds_loopback()
18366 iocbq->context2 = pcmd; in lpfc_sli4_handle_mds_loopback()
18367 iocbq->vport = vport; in lpfc_sli4_handle_mds_loopback()
18368 iocbq->iocb_flag &= ~LPFC_FIP_ELS_ID_MASK; in lpfc_sli4_handle_mds_loopback()
18369 iocbq->iocb_flag |= LPFC_USE_FCPWQIDX; in lpfc_sli4_handle_mds_loopback()
18375 wqe = (union lpfc_wqe *)&iocbq->iocb; in lpfc_sli4_handle_mds_loopback()
18377 wqe->send_frame.frame_len = frame_len; in lpfc_sli4_handle_mds_loopback()
18378 wqe->send_frame.fc_hdr_wd0 = be32_to_cpu(*((uint32_t *)fc_hdr)); in lpfc_sli4_handle_mds_loopback()
18379 wqe->send_frame.fc_hdr_wd1 = be32_to_cpu(*((uint32_t *)fc_hdr + 1)); in lpfc_sli4_handle_mds_loopback()
18380 wqe->send_frame.fc_hdr_wd2 = be32_to_cpu(*((uint32_t *)fc_hdr + 2)); in lpfc_sli4_handle_mds_loopback()
18381 wqe->send_frame.fc_hdr_wd3 = be32_to_cpu(*((uint32_t *)fc_hdr + 3)); in lpfc_sli4_handle_mds_loopback()
18382 wqe->send_frame.fc_hdr_wd4 = be32_to_cpu(*((uint32_t *)fc_hdr + 4)); in lpfc_sli4_handle_mds_loopback()
18383 wqe->send_frame.fc_hdr_wd5 = be32_to_cpu(*((uint32_t *)fc_hdr + 5)); in lpfc_sli4_handle_mds_loopback()
18385 iocbq->iocb.ulpCommand = CMD_SEND_FRAME; in lpfc_sli4_handle_mds_loopback()
18386 iocbq->iocb.ulpLe = 1; in lpfc_sli4_handle_mds_loopback()
18387 iocbq->iocb_cmpl = lpfc_sli4_mds_loopback_cmpl; in lpfc_sli4_handle_mds_loopback()
18392 lpfc_in_buf_free(phba, &dmabuf->dbuf); in lpfc_sli4_handle_mds_loopback()
18398 if (pcmd && pcmd->virt) in lpfc_sli4_handle_mds_loopback()
18399 dma_pool_free(phba->lpfc_drb_pool, pcmd->virt, pcmd->phys); in lpfc_sli4_handle_mds_loopback()
18403 lpfc_in_buf_free(phba, &dmabuf->dbuf); in lpfc_sli4_handle_mds_loopback()
18407 * lpfc_sli4_handle_received_buffer - Handle received buffers from firmware
18429 fc_hdr = (struct fc_frame_header *)dmabuf->hbuf.virt; in lpfc_sli4_handle_received_buffer()
18431 if (fc_hdr->fh_r_ctl == FC_RCTL_MDS_DIAGS || in lpfc_sli4_handle_received_buffer()
18432 fc_hdr->fh_r_ctl == FC_RCTL_DD_UNSOL_DATA) { in lpfc_sli4_handle_received_buffer()
18433 vport = phba->pport; in lpfc_sli4_handle_received_buffer()
18435 if (!(phba->pport->load_flag & FC_UNLOADING)) in lpfc_sli4_handle_received_buffer()
18438 lpfc_in_buf_free(phba, &dmabuf->dbuf); in lpfc_sli4_handle_received_buffer()
18444 lpfc_in_buf_free(phba, &dmabuf->dbuf); in lpfc_sli4_handle_received_buffer()
18449 &dmabuf->cq_event.cqe.rcqe_cmpl) == CQE_CODE_RECEIVE_V1)) in lpfc_sli4_handle_received_buffer()
18451 &dmabuf->cq_event.cqe.rcqe_cmpl); in lpfc_sli4_handle_received_buffer()
18454 &dmabuf->cq_event.cqe.rcqe_cmpl); in lpfc_sli4_handle_received_buffer()
18456 if (fc_hdr->fh_r_ctl == 0xF4 && fc_hdr->fh_type == 0xFF) { in lpfc_sli4_handle_received_buffer()
18457 vport = phba->pport; in lpfc_sli4_handle_received_buffer()
18461 &dmabuf->cq_event.cqe.rcqe_cmpl)); in lpfc_sli4_handle_received_buffer()
18473 lpfc_in_buf_free(phba, &dmabuf->dbuf); in lpfc_sli4_handle_received_buffer()
18478 if (!(vport->vpi_state & LPFC_VPI_REGISTERED) && in lpfc_sli4_handle_received_buffer()
18485 if (!(vport->fc_flag & FC_PT2PT) || in lpfc_sli4_handle_received_buffer()
18486 (phba->link_state == LPFC_HBA_READY)) { in lpfc_sli4_handle_received_buffer()
18487 lpfc_in_buf_free(phba, &dmabuf->dbuf); in lpfc_sli4_handle_received_buffer()
18493 if (fc_hdr->fh_r_ctl == FC_RCTL_BA_ABTS) { in lpfc_sli4_handle_received_buffer()
18501 /* unable to add frame to vport - throw it out */ in lpfc_sli4_handle_received_buffer()
18502 lpfc_in_buf_free(phba, &dmabuf->dbuf); in lpfc_sli4_handle_received_buffer()
18514 * lpfc_sli4_post_all_rpi_hdrs - Post the rpi header memory region to the port
18518 * HBA consistent with the SLI-4 interface spec. This routine
18527 * 0 - successful
18528 * -EIO - The mailbox failed to complete successfully.
18542 if (!phba->sli4_hba.rpi_hdrs_in_use) in lpfc_sli4_post_all_rpi_hdrs()
18544 if (phba->sli4_hba.extents_in_use) in lpfc_sli4_post_all_rpi_hdrs()
18545 return -EIO; in lpfc_sli4_post_all_rpi_hdrs()
18547 list_for_each_entry(rpi_page, &phba->sli4_hba.lpfc_rpi_hdr_list, list) { in lpfc_sli4_post_all_rpi_hdrs()
18553 if (bf_get(lpfc_rpi_rsrc_rdy, &phba->sli4_hba.sli4_flags) != in lpfc_sli4_post_all_rpi_hdrs()
18555 rpi_page->start_rpi = phba->sli4_hba.rpi_ids[lrpi]; in lpfc_sli4_post_all_rpi_hdrs()
18562 rc = -EIO; in lpfc_sli4_post_all_rpi_hdrs()
18568 bf_set(lpfc_rpi_rsrc_rdy, &phba->sli4_hba.sli4_flags, in lpfc_sli4_post_all_rpi_hdrs()
18574 * lpfc_sli4_post_rpi_hdr - Post an rpi header memory region to the port
18579 * HBA consistent with the SLI-4 interface spec. This memory region
18583 * 0 - successful
18584 * -ENOMEM - No available memory
18585 * -EIO - The mailbox failed to complete successfully.
18597 if (!phba->sli4_hba.rpi_hdrs_in_use) in lpfc_sli4_post_rpi_hdr()
18599 if (phba->sli4_hba.extents_in_use) in lpfc_sli4_post_rpi_hdr()
18600 return -EIO; in lpfc_sli4_post_rpi_hdr()
18602 /* The port is notified of the header region via a mailbox command. */ in lpfc_sli4_post_rpi_hdr()
18603 mboxq = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_post_rpi_hdr()
18607 "SLI_CONFIG_SPECIAL mailbox command\n"); in lpfc_sli4_post_rpi_hdr()
18608 return -ENOMEM; in lpfc_sli4_post_rpi_hdr()
18612 hdr_tmpl = &mboxq->u.mqe.un.hdr_tmpl; in lpfc_sli4_post_rpi_hdr()
18615 sizeof(struct lpfc_mbx_post_hdr_tmpl) - in lpfc_sli4_post_rpi_hdr()
18622 rpi_page->start_rpi); in lpfc_sli4_post_rpi_hdr()
18624 hdr_tmpl, rpi_page->page_count); in lpfc_sli4_post_rpi_hdr()
18626 hdr_tmpl->rpi_paddr_lo = putPaddrLow(rpi_page->dmabuf->phys); in lpfc_sli4_post_rpi_hdr()
18627 hdr_tmpl->rpi_paddr_hi = putPaddrHigh(rpi_page->dmabuf->phys); in lpfc_sli4_post_rpi_hdr()
18629 shdr = (union lpfc_sli4_cfg_shdr *) &hdr_tmpl->header.cfg_shdr; in lpfc_sli4_post_rpi_hdr()
18630 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_sli4_post_rpi_hdr()
18631 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_sli4_post_rpi_hdr()
18632 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_post_rpi_hdr()
18635 "2514 POST_RPI_HDR mailbox failed with " in lpfc_sli4_post_rpi_hdr()
18638 rc = -ENXIO; in lpfc_sli4_post_rpi_hdr()
18641 * The next_rpi stores the next logical module-64 rpi value used in lpfc_sli4_post_rpi_hdr()
18644 spin_lock_irq(&phba->hbalock); in lpfc_sli4_post_rpi_hdr()
18645 phba->sli4_hba.next_rpi = rpi_page->next_rpi; in lpfc_sli4_post_rpi_hdr()
18646 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_post_rpi_hdr()
18652 * lpfc_sli4_alloc_rpi - Get an available rpi in the device's range
18656 * HBA consistent with the SLI-4 interface spec. This routine
18677 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli4_alloc_rpi()
18678 max_rpi = phba->sli4_hba.max_cfg_param.max_rpi; in lpfc_sli4_alloc_rpi()
18679 rpi_limit = phba->sli4_hba.next_rpi; in lpfc_sli4_alloc_rpi()
18681 rpi = find_next_zero_bit(phba->sli4_hba.rpi_bmask, rpi_limit, 0); in lpfc_sli4_alloc_rpi()
18685 set_bit(rpi, phba->sli4_hba.rpi_bmask); in lpfc_sli4_alloc_rpi()
18686 phba->sli4_hba.max_cfg_param.rpi_used++; in lpfc_sli4_alloc_rpi()
18687 phba->sli4_hba.rpi_count++; in lpfc_sli4_alloc_rpi()
18699 (phba->sli4_hba.rpi_count >= max_rpi)) { in lpfc_sli4_alloc_rpi()
18700 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli4_alloc_rpi()
18708 if (!phba->sli4_hba.rpi_hdrs_in_use) { in lpfc_sli4_alloc_rpi()
18709 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli4_alloc_rpi()
18719 rpi_remaining = phba->sli4_hba.next_rpi - phba->sli4_hba.rpi_count; in lpfc_sli4_alloc_rpi()
18720 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli4_alloc_rpi()
18728 lrpi = rpi_hdr->start_rpi; in lpfc_sli4_alloc_rpi()
18729 rpi_hdr->start_rpi = phba->sli4_hba.rpi_ids[lrpi]; in lpfc_sli4_alloc_rpi()
18738 * lpfc_sli4_free_rpi - Release an rpi for reuse.
18755 if (test_and_clear_bit(rpi, phba->sli4_hba.rpi_bmask)) { in __lpfc_sli4_free_rpi()
18756 phba->sli4_hba.rpi_count--; in __lpfc_sli4_free_rpi()
18757 phba->sli4_hba.max_cfg_param.rpi_used--; in __lpfc_sli4_free_rpi()
18767 * lpfc_sli4_free_rpi - Release an rpi for reuse.
18777 spin_lock_irq(&phba->hbalock); in lpfc_sli4_free_rpi()
18779 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_free_rpi()
18783 * lpfc_sli4_remove_rpis - Remove the rpi bitmask region
18792 kfree(phba->sli4_hba.rpi_bmask); in lpfc_sli4_remove_rpis()
18793 kfree(phba->sli4_hba.rpi_ids); in lpfc_sli4_remove_rpis()
18794 bf_set(lpfc_rpi_rsrc_rdy, &phba->sli4_hba.sli4_flags, 0); in lpfc_sli4_remove_rpis()
18798 * lpfc_sli4_resume_rpi - Remove the rpi bitmask region
18800 * @cmpl: completion call-back.
18811 struct lpfc_hba *phba = ndlp->phba; in lpfc_sli4_resume_rpi()
18814 /* The port is notified of the header region via a mailbox command. */ in lpfc_sli4_resume_rpi()
18815 mboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_resume_rpi()
18817 return -ENOMEM; in lpfc_sli4_resume_rpi()
18822 mboxq->mbox_cmpl = cmpl; in lpfc_sli4_resume_rpi()
18823 mboxq->ctx_buf = arg; in lpfc_sli4_resume_rpi()
18824 mboxq->ctx_ndlp = ndlp; in lpfc_sli4_resume_rpi()
18826 mboxq->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_sli4_resume_rpi()
18827 mboxq->vport = ndlp->vport; in lpfc_sli4_resume_rpi()
18831 "2010 Resume RPI Mailbox failed " in lpfc_sli4_resume_rpi()
18833 bf_get(lpfc_mqe_status, &mboxq->u.mqe)); in lpfc_sli4_resume_rpi()
18834 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_resume_rpi()
18835 return -EIO; in lpfc_sli4_resume_rpi()
18841 * lpfc_sli4_init_vpi - Initialize a vpi with the port
18848 * -Evalue otherwise
18857 struct lpfc_hba *phba = vport->phba; in lpfc_sli4_init_vpi()
18858 mboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_init_vpi()
18860 return -ENOMEM; in lpfc_sli4_init_vpi()
18861 lpfc_init_vpi(phba, mboxq, vport->vpi); in lpfc_sli4_init_vpi()
18866 "2022 INIT VPI Mailbox failed " in lpfc_sli4_init_vpi()
18868 bf_get(lpfc_mqe_status, &mboxq->u.mqe)); in lpfc_sli4_init_vpi()
18869 retval = -EIO; in lpfc_sli4_init_vpi()
18872 mempool_free(mboxq, vport->phba->mbox_mem_pool); in lpfc_sli4_init_vpi()
18878 * lpfc_mbx_cmpl_add_fcf_record - add fcf mbox completion handler.
18880 * @mboxq: Pointer to mailbox object.
18884 * care of the nonembedded mailbox operations.
18893 virt_addr = mboxq->sge_array->addr[0]; in lpfc_mbx_cmpl_add_fcf_record()
18894 /* The IOCTL status is embedded in the mailbox subheader. */ in lpfc_mbx_cmpl_add_fcf_record()
18896 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_mbx_cmpl_add_fcf_record()
18897 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_mbx_cmpl_add_fcf_record()
18902 "2558 ADD_FCF_RECORD mailbox failed with " in lpfc_mbx_cmpl_add_fcf_record()
18910 * lpfc_sli4_add_fcf_record - Manually add an FCF Record.
18916 * care of the nonembedded mailbox operations.
18929 mboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_add_fcf_record()
18933 return -ENOMEM; in lpfc_sli4_add_fcf_record()
18939 /* Allocate DMA memory and set up the non-embedded mailbox command */ in lpfc_sli4_add_fcf_record()
18949 return -ENOMEM; in lpfc_sli4_add_fcf_record()
18953 * Get the first SGE entry from the non-embedded DMA memory. This in lpfc_sli4_add_fcf_record()
18957 virt_addr = mboxq->sge_array->addr[0]; in lpfc_sli4_add_fcf_record()
18973 mboxq->vport = phba->pport; in lpfc_sli4_add_fcf_record()
18974 mboxq->mbox_cmpl = lpfc_mbx_cmpl_add_fcf_record; in lpfc_sli4_add_fcf_record()
18978 "2515 ADD_FCF_RECORD mailbox failed with " in lpfc_sli4_add_fcf_record()
18981 rc = -EIO; in lpfc_sli4_add_fcf_record()
18989 * lpfc_sli4_build_dflt_fcf_record - Build the driver's default FCF Record.
19004 fcf_record->max_rcv_size = LPFC_FCOE_MAX_RCV_SIZE; in lpfc_sli4_build_dflt_fcf_record()
19005 fcf_record->fka_adv_period = LPFC_FCOE_FKA_ADV_PER; in lpfc_sli4_build_dflt_fcf_record()
19006 fcf_record->fip_priority = LPFC_FCOE_FIP_PRIORITY; in lpfc_sli4_build_dflt_fcf_record()
19007 bf_set(lpfc_fcf_record_mac_0, fcf_record, phba->fc_map[0]); in lpfc_sli4_build_dflt_fcf_record()
19008 bf_set(lpfc_fcf_record_mac_1, fcf_record, phba->fc_map[1]); in lpfc_sli4_build_dflt_fcf_record()
19009 bf_set(lpfc_fcf_record_mac_2, fcf_record, phba->fc_map[2]); in lpfc_sli4_build_dflt_fcf_record()
19013 bf_set(lpfc_fcf_record_fc_map_0, fcf_record, phba->fc_map[0]); in lpfc_sli4_build_dflt_fcf_record()
19014 bf_set(lpfc_fcf_record_fc_map_1, fcf_record, phba->fc_map[1]); in lpfc_sli4_build_dflt_fcf_record()
19015 bf_set(lpfc_fcf_record_fc_map_2, fcf_record, phba->fc_map[2]); in lpfc_sli4_build_dflt_fcf_record()
19022 if (phba->valid_vlan) { in lpfc_sli4_build_dflt_fcf_record()
19023 fcf_record->vlan_bitmap[phba->vlan_id / 8] in lpfc_sli4_build_dflt_fcf_record()
19024 = 1 << (phba->vlan_id % 8); in lpfc_sli4_build_dflt_fcf_record()
19029 * lpfc_sli4_fcf_scan_read_fcf_rec - Read hba fcf record for fcf scan.
19037 * Return 0 if the mailbox command is submitted successfully, none 0
19046 phba->fcoe_eventtag_at_fcf_scan = phba->fcoe_eventtag; in lpfc_sli4_fcf_scan_read_fcf_rec()
19047 phba->fcoe_cvl_eventtag_attn = phba->fcoe_cvl_eventtag; in lpfc_sli4_fcf_scan_read_fcf_rec()
19048 mboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_fcf_scan_read_fcf_rec()
19053 error = -ENOMEM; in lpfc_sli4_fcf_scan_read_fcf_rec()
19056 /* Construct the read FCF record mailbox command */ in lpfc_sli4_fcf_scan_read_fcf_rec()
19059 error = -EINVAL; in lpfc_sli4_fcf_scan_read_fcf_rec()
19062 /* Issue the mailbox command asynchronously */ in lpfc_sli4_fcf_scan_read_fcf_rec()
19063 mboxq->vport = phba->pport; in lpfc_sli4_fcf_scan_read_fcf_rec()
19064 mboxq->mbox_cmpl = lpfc_mbx_cmpl_fcf_scan_read_fcf_rec; in lpfc_sli4_fcf_scan_read_fcf_rec()
19066 spin_lock_irq(&phba->hbalock); in lpfc_sli4_fcf_scan_read_fcf_rec()
19067 phba->hba_flag |= FCF_TS_INPROG; in lpfc_sli4_fcf_scan_read_fcf_rec()
19068 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_fcf_scan_read_fcf_rec()
19072 error = -EIO; in lpfc_sli4_fcf_scan_read_fcf_rec()
19076 phba->fcf.eligible_fcf_cnt = 0; in lpfc_sli4_fcf_scan_read_fcf_rec()
19084 spin_lock_irq(&phba->hbalock); in lpfc_sli4_fcf_scan_read_fcf_rec()
19085 phba->hba_flag &= ~FCF_TS_INPROG; in lpfc_sli4_fcf_scan_read_fcf_rec()
19086 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_fcf_scan_read_fcf_rec()
19092 * lpfc_sli4_fcf_rr_read_fcf_rec - Read hba fcf record for roundrobin fcf.
19099 * Return 0 if the mailbox command is submitted successfully, none 0
19108 mboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_fcf_rr_read_fcf_rec()
19113 error = -ENOMEM; in lpfc_sli4_fcf_rr_read_fcf_rec()
19116 /* Construct the read FCF record mailbox command */ in lpfc_sli4_fcf_rr_read_fcf_rec()
19119 error = -EINVAL; in lpfc_sli4_fcf_rr_read_fcf_rec()
19122 /* Issue the mailbox command asynchronously */ in lpfc_sli4_fcf_rr_read_fcf_rec()
19123 mboxq->vport = phba->pport; in lpfc_sli4_fcf_rr_read_fcf_rec()
19124 mboxq->mbox_cmpl = lpfc_mbx_cmpl_fcf_rr_read_fcf_rec; in lpfc_sli4_fcf_rr_read_fcf_rec()
19127 error = -EIO; in lpfc_sli4_fcf_rr_read_fcf_rec()
19138 * lpfc_sli4_read_fcf_rec - Read hba fcf record for update eligible fcf bmask.
19145 * Return 0 if the mailbox command is submitted successfully, none 0
19154 mboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_read_fcf_rec()
19159 error = -ENOMEM; in lpfc_sli4_read_fcf_rec()
19162 /* Construct the read FCF record mailbox command */ in lpfc_sli4_read_fcf_rec()
19165 error = -EINVAL; in lpfc_sli4_read_fcf_rec()
19168 /* Issue the mailbox command asynchronously */ in lpfc_sli4_read_fcf_rec()
19169 mboxq->vport = phba->pport; in lpfc_sli4_read_fcf_rec()
19170 mboxq->mbox_cmpl = lpfc_mbx_cmpl_read_fcf_rec; in lpfc_sli4_read_fcf_rec()
19173 error = -EIO; in lpfc_sli4_read_fcf_rec()
19205 last_index = find_first_bit(phba->fcf.fcf_rr_bmask, in lpfc_check_next_fcf_pri_level()
19211 spin_lock_irq(&phba->hbalock); in lpfc_check_next_fcf_pri_level()
19212 if (list_empty(&phba->fcf.fcf_pri_list) || in lpfc_check_next_fcf_pri_level()
19213 list_is_singular(&phba->fcf.fcf_pri_list)) { in lpfc_check_next_fcf_pri_level()
19214 spin_unlock_irq(&phba->hbalock); in lpfc_check_next_fcf_pri_level()
19219 spin_unlock_irq(&phba->hbalock); in lpfc_check_next_fcf_pri_level()
19226 memset(phba->fcf.fcf_rr_bmask, 0, in lpfc_check_next_fcf_pri_level()
19227 sizeof(*phba->fcf.fcf_rr_bmask)); in lpfc_check_next_fcf_pri_level()
19228 spin_lock_irq(&phba->hbalock); in lpfc_check_next_fcf_pri_level()
19229 list_for_each_entry(fcf_pri, &phba->fcf.fcf_pri_list, list) { in lpfc_check_next_fcf_pri_level()
19230 if (fcf_pri->fcf_rec.flag & LPFC_FCF_FLOGI_FAILED) in lpfc_check_next_fcf_pri_level()
19237 next_fcf_pri = fcf_pri->fcf_rec.priority; in lpfc_check_next_fcf_pri_level()
19238 spin_unlock_irq(&phba->hbalock); in lpfc_check_next_fcf_pri_level()
19239 if (fcf_pri->fcf_rec.priority == next_fcf_pri) { in lpfc_check_next_fcf_pri_level()
19241 fcf_pri->fcf_rec.fcf_index); in lpfc_check_next_fcf_pri_level()
19245 spin_lock_irq(&phba->hbalock); in lpfc_check_next_fcf_pri_level()
19252 if (!next_fcf_pri && !list_empty(&phba->fcf.fcf_pri_list)) { in lpfc_check_next_fcf_pri_level()
19253 list_for_each_entry(fcf_pri, &phba->fcf.fcf_pri_list, list) { in lpfc_check_next_fcf_pri_level()
19254 fcf_pri->fcf_rec.flag &= ~LPFC_FCF_FLOGI_FAILED; in lpfc_check_next_fcf_pri_level()
19260 next_fcf_pri = fcf_pri->fcf_rec.priority; in lpfc_check_next_fcf_pri_level()
19261 spin_unlock_irq(&phba->hbalock); in lpfc_check_next_fcf_pri_level()
19262 if (fcf_pri->fcf_rec.priority == next_fcf_pri) { in lpfc_check_next_fcf_pri_level()
19264 fcf_pri->fcf_rec.fcf_index); in lpfc_check_next_fcf_pri_level()
19268 spin_lock_irq(&phba->hbalock); in lpfc_check_next_fcf_pri_level()
19272 spin_unlock_irq(&phba->hbalock); in lpfc_check_next_fcf_pri_level()
19277 * lpfc_sli4_fcf_rr_next_index_get - Get next eligible fcf record index
19293 next_fcf_index = phba->fcf.current_rec.fcf_indx; in lpfc_sli4_fcf_rr_next_index_get()
19298 next_fcf_index = find_next_bit(phba->fcf.fcf_rr_bmask, in lpfc_sli4_fcf_rr_next_index_get()
19302 /* Wrap around condition on phba->fcf.fcf_rr_bmask */ in lpfc_sli4_fcf_rr_next_index_get()
19309 next_fcf_index = find_next_bit(phba->fcf.fcf_rr_bmask, in lpfc_sli4_fcf_rr_next_index_get()
19316 next_fcf_index == phba->fcf.current_rec.fcf_indx) { in lpfc_sli4_fcf_rr_next_index_get()
19332 phba->fcf.fcf_pri[next_fcf_index].fcf_rec.flag & in lpfc_sli4_fcf_rr_next_index_get()
19334 if (list_is_singular(&phba->fcf.fcf_pri_list)) in lpfc_sli4_fcf_rr_next_index_get()
19348 * lpfc_sli4_fcf_rr_index_set - Set bmask with eligible fcf record index
19358 * -EINVAL.
19368 return -EINVAL; in lpfc_sli4_fcf_rr_index_set()
19371 set_bit(fcf_index, phba->fcf.fcf_rr_bmask); in lpfc_sli4_fcf_rr_index_set()
19381 * lpfc_sli4_fcf_rr_index_clear - Clear bmask from eligible fcf record index
19402 spin_lock_irq(&phba->hbalock); in lpfc_sli4_fcf_rr_index_clear()
19403 list_for_each_entry_safe(fcf_pri, fcf_pri_next, &phba->fcf.fcf_pri_list, in lpfc_sli4_fcf_rr_index_clear()
19405 if (fcf_pri->fcf_rec.fcf_index == fcf_index) { in lpfc_sli4_fcf_rr_index_clear()
19406 list_del_init(&fcf_pri->list); in lpfc_sli4_fcf_rr_index_clear()
19410 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_fcf_rr_index_clear()
19411 clear_bit(fcf_index, phba->fcf.fcf_rr_bmask); in lpfc_sli4_fcf_rr_index_clear()
19419 * lpfc_mbx_cmpl_redisc_fcf_table - completion routine for rediscover FCF table
19423 * This routine is the completion routine for the rediscover FCF table mailbox
19424 * command. If the mailbox command returned failure, it will try to stop the
19433 redisc_fcf = &mbox->u.mqe.un.redisc_fcf_tbl; in lpfc_mbx_cmpl_redisc_fcf_table()
19436 &redisc_fcf->header.cfg_shdr.response); in lpfc_mbx_cmpl_redisc_fcf_table()
19438 &redisc_fcf->header.cfg_shdr.response); in lpfc_mbx_cmpl_redisc_fcf_table()
19444 if (phba->fcf.fcf_flag & FCF_ACVL_DISC) { in lpfc_mbx_cmpl_redisc_fcf_table()
19445 spin_lock_irq(&phba->hbalock); in lpfc_mbx_cmpl_redisc_fcf_table()
19446 phba->fcf.fcf_flag &= ~FCF_ACVL_DISC; in lpfc_mbx_cmpl_redisc_fcf_table()
19447 spin_unlock_irq(&phba->hbalock); in lpfc_mbx_cmpl_redisc_fcf_table()
19450 * last resort to re-try current registered FCF entry. in lpfc_mbx_cmpl_redisc_fcf_table()
19454 spin_lock_irq(&phba->hbalock); in lpfc_mbx_cmpl_redisc_fcf_table()
19455 phba->fcf.fcf_flag &= ~FCF_DEAD_DISC; in lpfc_mbx_cmpl_redisc_fcf_table()
19456 spin_unlock_irq(&phba->hbalock); in lpfc_mbx_cmpl_redisc_fcf_table()
19474 mempool_free(mbox, phba->mbox_mem_pool); in lpfc_mbx_cmpl_redisc_fcf_table()
19478 * lpfc_sli4_redisc_fcf_table - Request to rediscover entire FCF table by port.
19494 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_redisc_fcf_table()
19499 return -ENOMEM; in lpfc_sli4_redisc_fcf_table()
19502 length = (sizeof(struct lpfc_mbx_redisc_fcf_tbl) - in lpfc_sli4_redisc_fcf_table()
19508 redisc_fcf = &mbox->u.mqe.un.redisc_fcf_tbl; in lpfc_sli4_redisc_fcf_table()
19512 /* Issue the mailbox command asynchronously */ in lpfc_sli4_redisc_fcf_table()
19513 mbox->vport = phba->pport; in lpfc_sli4_redisc_fcf_table()
19514 mbox->mbox_cmpl = lpfc_mbx_cmpl_redisc_fcf_table; in lpfc_sli4_redisc_fcf_table()
19518 mempool_free(mbox, phba->mbox_mem_pool); in lpfc_sli4_redisc_fcf_table()
19519 return -EIO; in lpfc_sli4_redisc_fcf_table()
19525 * lpfc_sli4_fcf_dead_failthrough - Failthrough routine to fcf dead event
19541 link_state = phba->link_state; in lpfc_sli4_fcf_dead_failthrough()
19543 phba->link_state = link_state; in lpfc_sli4_fcf_dead_failthrough()
19550 * lpfc_sli_get_config_region23 - Get sli3 port region 23 data.
19555 * mailbox command. When it successfully retrieves data, the size of the data
19569 pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli_get_config_region23()
19572 "2600 failed to allocate mailbox memory\n"); in lpfc_sli_get_config_region23()
19575 mb = &pmb->u.mb; in lpfc_sli_get_config_region23()
19585 rc, mb->mbxStatus); in lpfc_sli_get_config_region23()
19586 mb->un.varDmp.word_cnt = 0; in lpfc_sli_get_config_region23()
19590 * mailbox error, either way we are done. in lpfc_sli_get_config_region23()
19592 if (mb->un.varDmp.word_cnt == 0) in lpfc_sli_get_config_region23()
19595 i = mb->un.varDmp.word_cnt * sizeof(uint32_t); in lpfc_sli_get_config_region23()
19597 i = DMP_RGN23_SIZE - offset; in lpfc_sli_get_config_region23()
19603 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_sli_get_config_region23()
19608 * lpfc_sli4_get_config_region23 - Get sli4 port region 23 data.
19613 * mailbox command. When it successfully retrieves data, the size of the data
19628 mboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_get_config_region23()
19631 "3105 failed to allocate mailbox memory\n"); in lpfc_sli4_get_config_region23()
19637 mqe = &mboxq->u.mqe; in lpfc_sli4_get_config_region23()
19638 mp = (struct lpfc_dmabuf *)mboxq->ctx_buf; in lpfc_sli4_get_config_region23()
19642 data_length = mqe->un.mb_words[5]; in lpfc_sli4_get_config_region23()
19649 lpfc_sli_pcimem_bcopy((char *)mp->virt, rgn23_data, data_length); in lpfc_sli4_get_config_region23()
19651 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_get_config_region23()
19653 lpfc_mbuf_free(phba, mp->virt, mp->phys); in lpfc_sli4_get_config_region23()
19660 * lpfc_sli_read_link_ste - Read region 23 to decide if link is disabled.
19679 if (phba->sli_rev < LPFC_SLI_REV4) in lpfc_sli_read_link_ste()
19683 &phba->sli4_hba.sli_intf); in lpfc_sli_read_link_ste()
19729 * Search for configured port state sub-TLV. in lpfc_sli_read_link_ste()
19746 phba->hba_flag |= LINK_DISABLED; in lpfc_sli_read_link_ste()
19758 * lpfc_wr_object - write an object to the firmware
19764 * This routine will create a wr_object mailbox command to send to the port.
19765 * the mailbox command will be constructed using the dma buffers described in
19767 * BDEs that the imbedded mailbox can support. The @offset variable will be
19769 * the offset after the write object mailbox has completed. @size is used to
19789 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_wr_object()
19791 return -ENOMEM; in lpfc_wr_object()
19795 sizeof(struct lpfc_mbx_wr_object) - in lpfc_wr_object()
19798 wr_object = (struct lpfc_mbx_wr_object *)&mbox->u.mqe.un.wr_object; in lpfc_wr_object()
19799 wr_object->u.request.write_offset = *offset; in lpfc_wr_object()
19800 sprintf((uint8_t *)wr_object->u.request.object_name, "/"); in lpfc_wr_object()
19801 wr_object->u.request.object_name[0] = in lpfc_wr_object()
19802 cpu_to_le32(wr_object->u.request.object_name[0]); in lpfc_wr_object()
19803 bf_set(lpfc_wr_object_eof, &wr_object->u.request, 0); in lpfc_wr_object()
19807 wr_object->u.request.bde[i].addrLow = putPaddrLow(dmabuf->phys); in lpfc_wr_object()
19808 wr_object->u.request.bde[i].addrHigh = in lpfc_wr_object()
19809 putPaddrHigh(dmabuf->phys); in lpfc_wr_object()
19811 wr_object->u.request.bde[i].tus.f.bdeSize = in lpfc_wr_object()
19812 (size - written); in lpfc_wr_object()
19813 written += (size - written); in lpfc_wr_object()
19814 bf_set(lpfc_wr_object_eof, &wr_object->u.request, 1); in lpfc_wr_object()
19815 bf_set(lpfc_wr_object_eas, &wr_object->u.request, 1); in lpfc_wr_object()
19818 wr_object->u.request.bde[i].tus.f.bdeSize = in lpfc_wr_object()
19824 wr_object->u.request.bde_count = i; in lpfc_wr_object()
19825 bf_set(lpfc_wr_object_write_length, &wr_object->u.request, written); in lpfc_wr_object()
19826 if (!phba->sli4_hba.intr_enable) in lpfc_wr_object()
19832 /* The IOCTL status is embedded in the mailbox subheader. */ in lpfc_wr_object()
19834 &wr_object->header.cfg_shdr.response); in lpfc_wr_object()
19836 &wr_object->header.cfg_shdr.response); in lpfc_wr_object()
19839 &wr_object->u.response); in lpfc_wr_object()
19844 &wr_object->u.response); in lpfc_wr_object()
19876 if (!phba->sli4_hba.intr_enable) in lpfc_wr_object()
19877 mempool_free(mbox, phba->mbox_mem_pool); in lpfc_wr_object()
19879 mempool_free(mbox, phba->mbox_mem_pool); in lpfc_wr_object()
19882 "3025 Write Object mailbox failed with " in lpfc_wr_object()
19885 rc = -ENXIO; in lpfc_wr_object()
19888 *offset += wr_object->u.response.actual_write_length; in lpfc_wr_object()
19893 * lpfc_cleanup_pending_mbox - Free up vport discovery mailbox commands.
19897 * and REG_VPI mailbox commands associated with the vport. This function
19904 struct lpfc_hba *phba = vport->phba; in lpfc_cleanup_pending_mbox()
19913 /* Clean up internally queued mailbox commands with the vport */ in lpfc_cleanup_pending_mbox()
19914 spin_lock_irq(&phba->hbalock); in lpfc_cleanup_pending_mbox()
19915 list_for_each_entry_safe(mb, nextmb, &phba->sli.mboxq, list) { in lpfc_cleanup_pending_mbox()
19916 if (mb->vport != vport) in lpfc_cleanup_pending_mbox()
19919 if ((mb->u.mb.mbxCommand != MBX_REG_LOGIN64) && in lpfc_cleanup_pending_mbox()
19920 (mb->u.mb.mbxCommand != MBX_REG_VPI)) in lpfc_cleanup_pending_mbox()
19923 list_del(&mb->list); in lpfc_cleanup_pending_mbox()
19924 list_add_tail(&mb->list, &mbox_cmd_list); in lpfc_cleanup_pending_mbox()
19926 /* Clean up active mailbox command with the vport */ in lpfc_cleanup_pending_mbox()
19927 mb = phba->sli.mbox_active; in lpfc_cleanup_pending_mbox()
19928 if (mb && (mb->vport == vport)) { in lpfc_cleanup_pending_mbox()
19929 if ((mb->u.mb.mbxCommand == MBX_REG_LOGIN64) || in lpfc_cleanup_pending_mbox()
19930 (mb->u.mb.mbxCommand == MBX_REG_VPI)) in lpfc_cleanup_pending_mbox()
19931 mb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_cleanup_pending_mbox()
19932 if (mb->u.mb.mbxCommand == MBX_REG_LOGIN64) { in lpfc_cleanup_pending_mbox()
19933 act_mbx_ndlp = (struct lpfc_nodelist *)mb->ctx_ndlp; in lpfc_cleanup_pending_mbox()
19936 /* Unregister the RPI when mailbox complete */ in lpfc_cleanup_pending_mbox()
19937 mb->mbox_flag |= LPFC_MBX_IMED_UNREG; in lpfc_cleanup_pending_mbox()
19940 /* Cleanup any mailbox completions which are not yet processed */ in lpfc_cleanup_pending_mbox()
19943 list_for_each_entry(mb, &phba->sli.mboxq_cmpl, list) { in lpfc_cleanup_pending_mbox()
19948 if ((mb->vport != vport) || in lpfc_cleanup_pending_mbox()
19949 (mb->mbox_flag & LPFC_MBX_IMED_UNREG)) in lpfc_cleanup_pending_mbox()
19952 if ((mb->u.mb.mbxCommand != MBX_REG_LOGIN64) && in lpfc_cleanup_pending_mbox()
19953 (mb->u.mb.mbxCommand != MBX_REG_VPI)) in lpfc_cleanup_pending_mbox()
19956 mb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_cleanup_pending_mbox()
19957 if (mb->u.mb.mbxCommand == MBX_REG_LOGIN64) { in lpfc_cleanup_pending_mbox()
19958 ndlp = (struct lpfc_nodelist *)mb->ctx_ndlp; in lpfc_cleanup_pending_mbox()
19959 /* Unregister the RPI when mailbox complete */ in lpfc_cleanup_pending_mbox()
19960 mb->mbox_flag |= LPFC_MBX_IMED_UNREG; in lpfc_cleanup_pending_mbox()
19962 spin_unlock_irq(&phba->hbalock); in lpfc_cleanup_pending_mbox()
19963 spin_lock(shost->host_lock); in lpfc_cleanup_pending_mbox()
19964 ndlp->nlp_flag &= ~NLP_IGNR_REG_CMPL; in lpfc_cleanup_pending_mbox()
19965 spin_unlock(shost->host_lock); in lpfc_cleanup_pending_mbox()
19966 spin_lock_irq(&phba->hbalock); in lpfc_cleanup_pending_mbox()
19972 spin_unlock_irq(&phba->hbalock); in lpfc_cleanup_pending_mbox()
19974 /* Release the cleaned-up mailbox commands */ in lpfc_cleanup_pending_mbox()
19977 if (mb->u.mb.mbxCommand == MBX_REG_LOGIN64) { in lpfc_cleanup_pending_mbox()
19978 mp = (struct lpfc_dmabuf *)(mb->ctx_buf); in lpfc_cleanup_pending_mbox()
19980 __lpfc_mbuf_free(phba, mp->virt, mp->phys); in lpfc_cleanup_pending_mbox()
19983 mb->ctx_buf = NULL; in lpfc_cleanup_pending_mbox()
19984 ndlp = (struct lpfc_nodelist *)mb->ctx_ndlp; in lpfc_cleanup_pending_mbox()
19985 mb->ctx_ndlp = NULL; in lpfc_cleanup_pending_mbox()
19987 spin_lock(shost->host_lock); in lpfc_cleanup_pending_mbox()
19988 ndlp->nlp_flag &= ~NLP_IGNR_REG_CMPL; in lpfc_cleanup_pending_mbox()
19989 spin_unlock(shost->host_lock); in lpfc_cleanup_pending_mbox()
19993 mempool_free(mb, phba->mbox_mem_pool); in lpfc_cleanup_pending_mbox()
19996 /* Release the ndlp with the cleaned-up active mailbox command */ in lpfc_cleanup_pending_mbox()
19998 spin_lock(shost->host_lock); in lpfc_cleanup_pending_mbox()
19999 act_mbx_ndlp->nlp_flag &= ~NLP_IGNR_REG_CMPL; in lpfc_cleanup_pending_mbox()
20000 spin_unlock(shost->host_lock); in lpfc_cleanup_pending_mbox()
20006 * lpfc_drain_txq - Drain the txq
20029 if (phba->link_flag & LS_MDS_LOOPBACK) { in lpfc_drain_txq()
20031 wq = phba->sli4_hba.hdwq[0].io_wq; in lpfc_drain_txq()
20034 pring = wq->pring; in lpfc_drain_txq()
20036 wq = phba->sli4_hba.els_wq; in lpfc_drain_txq()
20042 if (unlikely(!pring) || list_empty(&pring->txq)) in lpfc_drain_txq()
20045 spin_lock_irqsave(&pring->ring_lock, iflags); in lpfc_drain_txq()
20046 list_for_each_entry(piocbq, &pring->txq, list) { in lpfc_drain_txq()
20050 if (txq_cnt > pring->txq_max) in lpfc_drain_txq()
20051 pring->txq_max = txq_cnt; in lpfc_drain_txq()
20053 spin_unlock_irqrestore(&pring->ring_lock, iflags); in lpfc_drain_txq()
20055 while (!list_empty(&pring->txq)) { in lpfc_drain_txq()
20056 spin_lock_irqsave(&pring->ring_lock, iflags); in lpfc_drain_txq()
20060 spin_unlock_irqrestore(&pring->ring_lock, iflags); in lpfc_drain_txq()
20069 spin_unlock_irqrestore(&pring->ring_lock, iflags); in lpfc_drain_txq()
20072 txq_cnt--; in lpfc_drain_txq()
20077 piocbq->sli4_lxritag = sglq->sli4_lxritag; in lpfc_drain_txq()
20078 piocbq->sli4_xritag = sglq->sli4_xritag; in lpfc_drain_txq()
20084 fail_msg = " - Wq is full"; in lpfc_drain_txq()
20094 piocbq->iotag, piocbq->sli4_xritag); in lpfc_drain_txq()
20095 list_add_tail(&piocbq->list, &completions); in lpfc_drain_txq()
20098 spin_unlock_irqrestore(&pring->ring_lock, iflags); in lpfc_drain_txq()
20109 * lpfc_wqe_bpl2sgl - Convert the bpl/bde to a sgl.
20144 sgl = (struct sli4_sge *)sglq->sgl; in lpfc_wqe_bpl2sgl()
20145 wqe = &pwqeq->wqe; in lpfc_wqe_bpl2sgl()
20146 pwqeq->iocb.ulpIoTag = pwqeq->iotag; in lpfc_wqe_bpl2sgl()
20148 cmd = bf_get(wqe_cmnd, &wqe->generic.wqe_com); in lpfc_wqe_bpl2sgl()
20150 return sglq->sli4_xritag; in lpfc_wqe_bpl2sgl()
20151 numBdes = pwqeq->rsvd2; in lpfc_wqe_bpl2sgl()
20157 if (pwqeq->context3) in lpfc_wqe_bpl2sgl()
20158 dmabuf = (struct lpfc_dmabuf *)pwqeq->context3; in lpfc_wqe_bpl2sgl()
20162 bpl = (struct ulp_bde64 *)dmabuf->virt; in lpfc_wqe_bpl2sgl()
20168 sgl->addr_hi = bpl->addrHigh; in lpfc_wqe_bpl2sgl()
20169 sgl->addr_lo = bpl->addrLow; in lpfc_wqe_bpl2sgl()
20171 sgl->word2 = le32_to_cpu(sgl->word2); in lpfc_wqe_bpl2sgl()
20179 bde.tus.w = le32_to_cpu(bpl->tus.w); in lpfc_wqe_bpl2sgl()
20180 sgl->sge_len = cpu_to_le32(bde.tus.f.bdeSize); in lpfc_wqe_bpl2sgl()
20188 if (bpl->tus.f.bdeFlags == BUFF_TYPE_BDE_64I) in lpfc_wqe_bpl2sgl()
20206 bpl->tus.f.bdeFlags); in lpfc_wqe_bpl2sgl()
20214 sgl->word2 = cpu_to_le32(sgl->word2); in lpfc_wqe_bpl2sgl()
20218 } else if (wqe->gen_req.bde.tus.f.bdeFlags == BUFF_TYPE_BDE_64) { in lpfc_wqe_bpl2sgl()
20223 sgl->addr_hi = cpu_to_le32(wqe->gen_req.bde.addrHigh); in lpfc_wqe_bpl2sgl()
20224 sgl->addr_lo = cpu_to_le32(wqe->gen_req.bde.addrLow); in lpfc_wqe_bpl2sgl()
20225 sgl->word2 = le32_to_cpu(sgl->word2); in lpfc_wqe_bpl2sgl()
20227 sgl->word2 = cpu_to_le32(sgl->word2); in lpfc_wqe_bpl2sgl()
20228 sgl->sge_len = cpu_to_le32(wqe->gen_req.bde.tus.f.bdeSize); in lpfc_wqe_bpl2sgl()
20230 return sglq->sli4_xritag; in lpfc_wqe_bpl2sgl()
20234 * lpfc_sli4_issue_wqe - Issue an SLI4 Work Queue Entry (WQE)
20243 union lpfc_wqe128 *wqe = &pwqe->wqe; in lpfc_sli4_issue_wqe()
20252 if (pwqe->iocb_flag & LPFC_IO_NVME_LS) { in lpfc_sli4_issue_wqe()
20253 pring = phba->sli4_hba.nvmels_wq->pring; in lpfc_sli4_issue_wqe()
20254 lpfc_qp_spin_lock_irqsave(&pring->ring_lock, iflags, in lpfc_sli4_issue_wqe()
20258 spin_unlock_irqrestore(&pring->ring_lock, iflags); in lpfc_sli4_issue_wqe()
20261 pwqe->sli4_lxritag = sglq->sli4_lxritag; in lpfc_sli4_issue_wqe()
20262 pwqe->sli4_xritag = sglq->sli4_xritag; in lpfc_sli4_issue_wqe()
20264 spin_unlock_irqrestore(&pring->ring_lock, iflags); in lpfc_sli4_issue_wqe()
20267 bf_set(wqe_xri_tag, &pwqe->wqe.xmit_bls_rsp.wqe_com, in lpfc_sli4_issue_wqe()
20268 pwqe->sli4_xritag); in lpfc_sli4_issue_wqe()
20269 ret = lpfc_sli4_wq_put(phba->sli4_hba.nvmels_wq, wqe); in lpfc_sli4_issue_wqe()
20271 spin_unlock_irqrestore(&pring->ring_lock, iflags); in lpfc_sli4_issue_wqe()
20276 spin_unlock_irqrestore(&pring->ring_lock, iflags); in lpfc_sli4_issue_wqe()
20278 lpfc_sli4_poll_eq(qp->hba_eq, LPFC_POLL_FASTPATH); in lpfc_sli4_issue_wqe()
20283 if (pwqe->iocb_flag & LPFC_IO_NVME) { in lpfc_sli4_issue_wqe()
20285 wq = qp->io_wq; in lpfc_sli4_issue_wqe()
20286 pring = wq->pring; in lpfc_sli4_issue_wqe()
20288 bf_set(wqe_cqid, &wqe->generic.wqe_com, qp->io_cq_map); in lpfc_sli4_issue_wqe()
20290 lpfc_qp_spin_lock_irqsave(&pring->ring_lock, iflags, in lpfc_sli4_issue_wqe()
20294 spin_unlock_irqrestore(&pring->ring_lock, iflags); in lpfc_sli4_issue_wqe()
20298 spin_unlock_irqrestore(&pring->ring_lock, iflags); in lpfc_sli4_issue_wqe()
20300 lpfc_sli4_poll_eq(qp->hba_eq, LPFC_POLL_FASTPATH); in lpfc_sli4_issue_wqe()
20305 if (pwqe->iocb_flag & LPFC_IO_NVMET) { in lpfc_sli4_issue_wqe()
20307 wq = qp->io_wq; in lpfc_sli4_issue_wqe()
20308 pring = wq->pring; in lpfc_sli4_issue_wqe()
20310 ctxp = pwqe->context2; in lpfc_sli4_issue_wqe()
20311 sglq = ctxp->ctxbuf->sglq; in lpfc_sli4_issue_wqe()
20312 if (pwqe->sli4_xritag == NO_XRI) { in lpfc_sli4_issue_wqe()
20313 pwqe->sli4_lxritag = sglq->sli4_lxritag; in lpfc_sli4_issue_wqe()
20314 pwqe->sli4_xritag = sglq->sli4_xritag; in lpfc_sli4_issue_wqe()
20316 bf_set(wqe_xri_tag, &pwqe->wqe.xmit_bls_rsp.wqe_com, in lpfc_sli4_issue_wqe()
20317 pwqe->sli4_xritag); in lpfc_sli4_issue_wqe()
20318 bf_set(wqe_cqid, &wqe->generic.wqe_com, qp->io_cq_map); in lpfc_sli4_issue_wqe()
20320 lpfc_qp_spin_lock_irqsave(&pring->ring_lock, iflags, in lpfc_sli4_issue_wqe()
20324 spin_unlock_irqrestore(&pring->ring_lock, iflags); in lpfc_sli4_issue_wqe()
20328 spin_unlock_irqrestore(&pring->ring_lock, iflags); in lpfc_sli4_issue_wqe()
20330 lpfc_sli4_poll_eq(qp->hba_eq, LPFC_POLL_FASTPATH); in lpfc_sli4_issue_wqe()
20338 * lpfc_snapshot_mxp - Snapshot pbl, pvt and busy count
20359 qp = &phba->sli4_hba.hdwq[hwqid]; in lpfc_snapshot_mxp()
20360 multixri_pool = qp->p_multixri_pool; in lpfc_snapshot_mxp()
20364 if (multixri_pool->stat_snapshot_taken == LPFC_MXP_SNAPSHOT_TAKEN) { in lpfc_snapshot_mxp()
20365 pvt_pool = &qp->p_multixri_pool->pvt_pool; in lpfc_snapshot_mxp()
20366 pbl_pool = &qp->p_multixri_pool->pbl_pool; in lpfc_snapshot_mxp()
20367 txcmplq_cnt = qp->io_wq->pring->txcmplq_cnt; in lpfc_snapshot_mxp()
20369 multixri_pool->stat_pbl_count = pbl_pool->count; in lpfc_snapshot_mxp()
20370 multixri_pool->stat_pvt_count = pvt_pool->count; in lpfc_snapshot_mxp()
20371 multixri_pool->stat_busy_count = txcmplq_cnt; in lpfc_snapshot_mxp()
20374 multixri_pool->stat_snapshot_taken++; in lpfc_snapshot_mxp()
20379 * lpfc_adjust_pvt_pool_count - Adjust private pool count
20392 multixri_pool = phba->sli4_hba.hdwq[hwqid].p_multixri_pool; in lpfc_adjust_pvt_pool_count()
20395 io_req_count = multixri_pool->io_req_count; in lpfc_adjust_pvt_pool_count()
20396 prev_io_req_count = multixri_pool->prev_io_req_count; in lpfc_adjust_pvt_pool_count()
20400 multixri_pool->prev_io_req_count = io_req_count; in lpfc_adjust_pvt_pool_count()
20410 * lpfc_adjust_high_watermark - Adjust high watermark
20428 qp = &phba->sli4_hba.hdwq[hwqid]; in lpfc_adjust_high_watermark()
20429 multixri_pool = qp->p_multixri_pool; in lpfc_adjust_high_watermark()
20432 xri_limit = multixri_pool->xri_limit; in lpfc_adjust_high_watermark()
20437 txcmplq_cnt = qp->io_wq->pring->txcmplq_cnt; in lpfc_adjust_high_watermark()
20438 abts_io_bufs = qp->abts_scsi_io_bufs; in lpfc_adjust_high_watermark()
20439 abts_io_bufs += qp->abts_nvme_io_bufs; in lpfc_adjust_high_watermark()
20444 multixri_pool->pvt_pool.high_watermark = new_watermark; in lpfc_adjust_high_watermark()
20447 multixri_pool->stat_max_hwm = max(multixri_pool->stat_max_hwm, in lpfc_adjust_high_watermark()
20453 * lpfc_move_xri_pvt_to_pbl - Move some XRIs from private to public pool
20459 * The first step moves (all - low_watermark) amount of XRIs.
20473 qp = &phba->sli4_hba.hdwq[hwqid]; in lpfc_move_xri_pvt_to_pbl()
20474 pbl_pool = &qp->p_multixri_pool->pbl_pool; in lpfc_move_xri_pvt_to_pbl()
20475 pvt_pool = &qp->p_multixri_pool->pvt_pool; in lpfc_move_xri_pvt_to_pbl()
20478 lpfc_qp_spin_lock_irqsave(&pbl_pool->lock, iflag, qp, mv_to_pub_pool); in lpfc_move_xri_pvt_to_pbl()
20479 lpfc_qp_spin_lock(&pvt_pool->lock, qp, mv_from_pvt_pool); in lpfc_move_xri_pvt_to_pbl()
20481 if (pvt_pool->count > pvt_pool->low_watermark) { in lpfc_move_xri_pvt_to_pbl()
20482 /* Step 1: move (all - low_watermark) from pvt_pool in lpfc_move_xri_pvt_to_pbl()
20489 &pvt_pool->list, list) { in lpfc_move_xri_pvt_to_pbl()
20490 list_move_tail(&lpfc_ncmd->list, &tmp_list); in lpfc_move_xri_pvt_to_pbl()
20492 if (tmp_count >= pvt_pool->low_watermark) in lpfc_move_xri_pvt_to_pbl()
20497 list_splice_init(&pvt_pool->list, &pbl_pool->list); in lpfc_move_xri_pvt_to_pbl()
20500 list_splice(&tmp_list, &pvt_pool->list); in lpfc_move_xri_pvt_to_pbl()
20502 pbl_pool->count += (pvt_pool->count - tmp_count); in lpfc_move_xri_pvt_to_pbl()
20503 pvt_pool->count = tmp_count; in lpfc_move_xri_pvt_to_pbl()
20506 list_splice_init(&pvt_pool->list, &pbl_pool->list); in lpfc_move_xri_pvt_to_pbl()
20507 pbl_pool->count += pvt_pool->count; in lpfc_move_xri_pvt_to_pbl()
20508 pvt_pool->count = 0; in lpfc_move_xri_pvt_to_pbl()
20511 spin_unlock(&pvt_pool->lock); in lpfc_move_xri_pvt_to_pbl()
20512 spin_unlock_irqrestore(&pbl_pool->lock, iflag); in lpfc_move_xri_pvt_to_pbl()
20516 * _lpfc_move_xri_pbl_to_pvt - Move some XRIs from public to private pool
20528 * true - if XRIs are successfully moved from the specified pbl_pool to the
20530 * false - if the specified pbl_pool is empty or locked by someone else
20542 ret = spin_trylock_irqsave(&pbl_pool->lock, iflag); in _lpfc_move_xri_pbl_to_pvt()
20544 if (pbl_pool->count) { in _lpfc_move_xri_pbl_to_pvt()
20546 lpfc_qp_spin_lock(&pvt_pool->lock, qp, mv_to_pvt_pool); in _lpfc_move_xri_pbl_to_pvt()
20549 &pbl_pool->list, in _lpfc_move_xri_pbl_to_pvt()
20551 list_move_tail(&lpfc_ncmd->list, in _lpfc_move_xri_pbl_to_pvt()
20552 &pvt_pool->list); in _lpfc_move_xri_pbl_to_pvt()
20553 pvt_pool->count++; in _lpfc_move_xri_pbl_to_pvt()
20554 pbl_pool->count--; in _lpfc_move_xri_pbl_to_pvt()
20555 count--; in _lpfc_move_xri_pbl_to_pvt()
20560 spin_unlock(&pvt_pool->lock); in _lpfc_move_xri_pbl_to_pvt()
20561 spin_unlock_irqrestore(&pbl_pool->lock, iflag); in _lpfc_move_xri_pbl_to_pvt()
20564 spin_unlock_irqrestore(&pbl_pool->lock, iflag); in _lpfc_move_xri_pbl_to_pvt()
20571 * lpfc_move_xri_pbl_to_pvt - Move some XRIs from public to private pool
20593 qp = &phba->sli4_hba.hdwq[hwqid]; in lpfc_move_xri_pbl_to_pvt()
20594 multixri_pool = qp->p_multixri_pool; in lpfc_move_xri_pbl_to_pvt()
20595 pvt_pool = &multixri_pool->pvt_pool; in lpfc_move_xri_pbl_to_pvt()
20596 pbl_pool = &multixri_pool->pbl_pool; in lpfc_move_xri_pbl_to_pvt()
20602 multixri_pool->local_pbl_hit_count++; in lpfc_move_xri_pbl_to_pvt()
20607 hwq_count = phba->cfg_hdw_queue; in lpfc_move_xri_pbl_to_pvt()
20610 next_hwqid = multixri_pool->rrb_next_hwqid; in lpfc_move_xri_pbl_to_pvt()
20617 phba->sli4_hba.hdwq[next_hwqid].p_multixri_pool; in lpfc_move_xri_pbl_to_pvt()
20618 pbl_pool = &next_multixri_pool->pbl_pool; in lpfc_move_xri_pbl_to_pvt()
20624 /* Exit while-loop if success or all hwqid are checked */ in lpfc_move_xri_pbl_to_pvt()
20625 } while (!ret && next_hwqid != multixri_pool->rrb_next_hwqid); in lpfc_move_xri_pbl_to_pvt()
20628 multixri_pool->rrb_next_hwqid = next_hwqid; in lpfc_move_xri_pbl_to_pvt()
20632 multixri_pool->pbl_empty_count++; in lpfc_move_xri_pbl_to_pvt()
20638 multixri_pool->local_pbl_hit_count++; in lpfc_move_xri_pbl_to_pvt()
20640 multixri_pool->other_pbl_hit_count++; in lpfc_move_xri_pbl_to_pvt()
20646 * lpfc_keep_pvt_pool_above_lowwm - Keep pvt_pool above low watermark
20658 multixri_pool = phba->sli4_hba.hdwq[hwqid].p_multixri_pool; in lpfc_keep_pvt_pool_above_lowwm()
20659 pvt_pool = &multixri_pool->pvt_pool; in lpfc_keep_pvt_pool_above_lowwm()
20661 if (pvt_pool->count < pvt_pool->low_watermark) in lpfc_keep_pvt_pool_above_lowwm()
20666 * lpfc_release_io_buf - Return one IO buf back to free pool
20690 lpfc_ncmd->nvmeCmd = NULL; in lpfc_release_io_buf()
20691 lpfc_ncmd->cur_iocbq.wqe_cmpl = NULL; in lpfc_release_io_buf()
20692 lpfc_ncmd->cur_iocbq.iocb_cmpl = NULL; in lpfc_release_io_buf()
20694 if (phba->cfg_xpsgl && !phba->nvmet_support && in lpfc_release_io_buf()
20695 !list_empty(&lpfc_ncmd->dma_sgl_xtra_list)) in lpfc_release_io_buf()
20698 if (!list_empty(&lpfc_ncmd->dma_cmd_rsp_list)) in lpfc_release_io_buf()
20701 if (phba->cfg_xri_rebalancing) { in lpfc_release_io_buf()
20702 if (lpfc_ncmd->expedite) { in lpfc_release_io_buf()
20704 epd_pool = &phba->epd_pool; in lpfc_release_io_buf()
20705 spin_lock_irqsave(&epd_pool->lock, iflag); in lpfc_release_io_buf()
20706 list_add_tail(&lpfc_ncmd->list, &epd_pool->list); in lpfc_release_io_buf()
20707 epd_pool->count++; in lpfc_release_io_buf()
20708 spin_unlock_irqrestore(&epd_pool->lock, iflag); in lpfc_release_io_buf()
20716 if (!qp->p_multixri_pool) in lpfc_release_io_buf()
20719 pbl_pool = &qp->p_multixri_pool->pbl_pool; in lpfc_release_io_buf()
20720 pvt_pool = &qp->p_multixri_pool->pvt_pool; in lpfc_release_io_buf()
20722 txcmplq_cnt = qp->io_wq->pring->txcmplq_cnt; in lpfc_release_io_buf()
20723 abts_io_bufs = qp->abts_scsi_io_bufs; in lpfc_release_io_buf()
20724 abts_io_bufs += qp->abts_nvme_io_bufs; in lpfc_release_io_buf()
20726 xri_owned = pvt_pool->count + txcmplq_cnt + abts_io_bufs; in lpfc_release_io_buf()
20727 xri_limit = qp->p_multixri_pool->xri_limit; in lpfc_release_io_buf()
20731 qp->p_multixri_pool->below_limit_count++; in lpfc_release_io_buf()
20733 qp->p_multixri_pool->above_limit_count++; in lpfc_release_io_buf()
20739 if ((pvt_pool->count < pvt_pool->low_watermark) || in lpfc_release_io_buf()
20741 pvt_pool->count < pvt_pool->high_watermark)) { in lpfc_release_io_buf()
20742 lpfc_qp_spin_lock_irqsave(&pvt_pool->lock, iflag, in lpfc_release_io_buf()
20744 list_add_tail(&lpfc_ncmd->list, in lpfc_release_io_buf()
20745 &pvt_pool->list); in lpfc_release_io_buf()
20746 pvt_pool->count++; in lpfc_release_io_buf()
20747 spin_unlock_irqrestore(&pvt_pool->lock, iflag); in lpfc_release_io_buf()
20749 lpfc_qp_spin_lock_irqsave(&pbl_pool->lock, iflag, in lpfc_release_io_buf()
20751 list_add_tail(&lpfc_ncmd->list, in lpfc_release_io_buf()
20752 &pbl_pool->list); in lpfc_release_io_buf()
20753 pbl_pool->count++; in lpfc_release_io_buf()
20754 spin_unlock_irqrestore(&pbl_pool->lock, iflag); in lpfc_release_io_buf()
20757 lpfc_qp_spin_lock_irqsave(&qp->io_buf_list_put_lock, iflag, in lpfc_release_io_buf()
20759 list_add_tail(&lpfc_ncmd->list, in lpfc_release_io_buf()
20760 &qp->lpfc_io_buf_list_put); in lpfc_release_io_buf()
20761 qp->put_io_bufs++; in lpfc_release_io_buf()
20762 spin_unlock_irqrestore(&qp->io_buf_list_put_lock, in lpfc_release_io_buf()
20768 * lpfc_get_io_buf_from_private_pool - Get one free IO buf from private pool
20777 * pointer to one free IO buf - if private pool is not empty
20778 * NULL - if private pool is empty
20790 lpfc_qp_spin_lock_irqsave(&pvt_pool->lock, iflag, qp, alloc_pvt_pool); in lpfc_get_io_buf_from_private_pool()
20792 &pvt_pool->list, list) { in lpfc_get_io_buf_from_private_pool()
20794 phba, ndlp, lpfc_ncmd->cur_iocbq.sli4_lxritag)) in lpfc_get_io_buf_from_private_pool()
20796 list_del(&lpfc_ncmd->list); in lpfc_get_io_buf_from_private_pool()
20797 pvt_pool->count--; in lpfc_get_io_buf_from_private_pool()
20798 spin_unlock_irqrestore(&pvt_pool->lock, iflag); in lpfc_get_io_buf_from_private_pool()
20801 spin_unlock_irqrestore(&pvt_pool->lock, iflag); in lpfc_get_io_buf_from_private_pool()
20807 * lpfc_get_io_buf_from_expedite_pool - Get one free IO buf from expedite pool
20813 * pointer to one free IO buf - if expedite pool is not empty
20814 * NULL - if expedite pool is empty
20824 epd_pool = &phba->epd_pool; in lpfc_get_io_buf_from_expedite_pool()
20827 spin_lock_irqsave(&epd_pool->lock, iflag); in lpfc_get_io_buf_from_expedite_pool()
20828 if (epd_pool->count > 0) { in lpfc_get_io_buf_from_expedite_pool()
20830 &epd_pool->list, list) { in lpfc_get_io_buf_from_expedite_pool()
20831 list_del(&lpfc_ncmd->list); in lpfc_get_io_buf_from_expedite_pool()
20832 epd_pool->count--; in lpfc_get_io_buf_from_expedite_pool()
20836 spin_unlock_irqrestore(&epd_pool->lock, iflag); in lpfc_get_io_buf_from_expedite_pool()
20842 * lpfc_get_io_buf_from_multixri_pools - Get one free IO bufs
20861 * pointer to one free IO buf - if private pool is not empty
20862 * NULL - if private pool is empty
20874 qp = &phba->sli4_hba.hdwq[hwqid]; in lpfc_get_io_buf_from_multixri_pools()
20876 multixri_pool = qp->p_multixri_pool; in lpfc_get_io_buf_from_multixri_pools()
20877 pvt_pool = &multixri_pool->pvt_pool; in lpfc_get_io_buf_from_multixri_pools()
20878 multixri_pool->io_req_count++; in lpfc_get_io_buf_from_multixri_pools()
20881 if (pvt_pool->count == 0) in lpfc_get_io_buf_from_multixri_pools()
20888 lpfc_ncmd->hdwq = qp; in lpfc_get_io_buf_from_multixri_pools()
20889 lpfc_ncmd->hdwq_no = hwqid; in lpfc_get_io_buf_from_multixri_pools()
20906 qp = &phba->sli4_hba.hdwq[idx]; in lpfc_io_buf()
20908 &qp->lpfc_io_buf_list_get, list) { in lpfc_io_buf()
20910 lpfc_cmd->cur_iocbq.sli4_lxritag)) in lpfc_io_buf()
20913 if (lpfc_cmd->flags & LPFC_SBUF_NOT_POSTED) in lpfc_io_buf()
20916 list_del_init(&lpfc_cmd->list); in lpfc_io_buf()
20917 qp->get_io_bufs--; in lpfc_io_buf()
20918 lpfc_cmd->hdwq = qp; in lpfc_io_buf()
20919 lpfc_cmd->hdwq_no = idx; in lpfc_io_buf()
20926 * lpfc_get_io_buf - Get one IO buffer from free pool
20940 * NULL - Error
20941 * Pointer to lpfc_io_buf - Success
20951 qp = &phba->sli4_hba.hdwq[hwqid]; in lpfc_get_io_buf()
20954 if (phba->cfg_xri_rebalancing) in lpfc_get_io_buf()
20958 lpfc_qp_spin_lock_irqsave(&qp->io_buf_list_get_lock, iflag, in lpfc_get_io_buf()
20960 if (qp->get_io_bufs > LPFC_NVME_EXPEDITE_XRICNT || expedite) in lpfc_get_io_buf()
20963 lpfc_qp_spin_lock(&qp->io_buf_list_put_lock, in lpfc_get_io_buf()
20965 list_splice(&qp->lpfc_io_buf_list_put, in lpfc_get_io_buf()
20966 &qp->lpfc_io_buf_list_get); in lpfc_get_io_buf()
20967 qp->get_io_bufs += qp->put_io_bufs; in lpfc_get_io_buf()
20968 INIT_LIST_HEAD(&qp->lpfc_io_buf_list_put); in lpfc_get_io_buf()
20969 qp->put_io_bufs = 0; in lpfc_get_io_buf()
20970 spin_unlock(&qp->io_buf_list_put_lock); in lpfc_get_io_buf()
20971 if (qp->get_io_bufs > LPFC_NVME_EXPEDITE_XRICNT || in lpfc_get_io_buf()
20975 spin_unlock_irqrestore(&qp->io_buf_list_get_lock, iflag); in lpfc_get_io_buf()
20982 * lpfc_get_sgl_per_hdwq - Get one SGL chunk from hdwq's pool
20990 * NULL - Error
20991 * Pointer to sli4_hybrid_sgl - Success
20999 struct lpfc_sli4_hdw_queue *hdwq = lpfc_buf->hdwq; in lpfc_get_sgl_per_hdwq()
21000 struct list_head *buf_list = &hdwq->sgl_list; in lpfc_get_sgl_per_hdwq()
21003 spin_lock_irqsave(&hdwq->hdwq_lock, iflags); in lpfc_get_sgl_per_hdwq()
21009 list_move_tail(&list_entry->list_node, in lpfc_get_sgl_per_hdwq()
21010 &lpfc_buf->dma_sgl_xtra_list); in lpfc_get_sgl_per_hdwq()
21015 spin_unlock_irqrestore(&hdwq->hdwq_lock, iflags); in lpfc_get_sgl_per_hdwq()
21017 cpu_to_node(hdwq->io_wq->chann)); in lpfc_get_sgl_per_hdwq()
21022 lpfc_buf->hdwq_no, __func__); in lpfc_get_sgl_per_hdwq()
21026 tmp->dma_sgl = dma_pool_alloc(phba->lpfc_sg_dma_buf_pool, in lpfc_get_sgl_per_hdwq()
21027 GFP_ATOMIC, &tmp->dma_phys_sgl); in lpfc_get_sgl_per_hdwq()
21028 if (!tmp->dma_sgl) { in lpfc_get_sgl_per_hdwq()
21032 lpfc_buf->hdwq_no, __func__); in lpfc_get_sgl_per_hdwq()
21037 spin_lock_irqsave(&hdwq->hdwq_lock, iflags); in lpfc_get_sgl_per_hdwq()
21038 list_add_tail(&tmp->list_node, &lpfc_buf->dma_sgl_xtra_list); in lpfc_get_sgl_per_hdwq()
21041 allocated_sgl = list_last_entry(&lpfc_buf->dma_sgl_xtra_list, in lpfc_get_sgl_per_hdwq()
21045 spin_unlock_irqrestore(&hdwq->hdwq_lock, iflags); in lpfc_get_sgl_per_hdwq()
21051 * lpfc_put_sgl_per_hdwq - Put one SGL chunk into hdwq pool
21058 * 0 - Success
21059 * -EINVAL - Error
21067 struct lpfc_sli4_hdw_queue *hdwq = lpfc_buf->hdwq; in lpfc_put_sgl_per_hdwq()
21068 struct list_head *buf_list = &hdwq->sgl_list; in lpfc_put_sgl_per_hdwq()
21071 spin_lock_irqsave(&hdwq->hdwq_lock, iflags); in lpfc_put_sgl_per_hdwq()
21073 if (likely(!list_empty(&lpfc_buf->dma_sgl_xtra_list))) { in lpfc_put_sgl_per_hdwq()
21075 &lpfc_buf->dma_sgl_xtra_list, in lpfc_put_sgl_per_hdwq()
21077 list_move_tail(&list_entry->list_node, in lpfc_put_sgl_per_hdwq()
21081 rc = -EINVAL; in lpfc_put_sgl_per_hdwq()
21084 spin_unlock_irqrestore(&hdwq->hdwq_lock, iflags); in lpfc_put_sgl_per_hdwq()
21089 * lpfc_free_sgl_per_hdwq - Free all SGL chunks of hdwq pool
21102 struct list_head *buf_list = &hdwq->sgl_list; in lpfc_free_sgl_per_hdwq()
21107 spin_lock_irqsave(&hdwq->hdwq_lock, iflags); in lpfc_free_sgl_per_hdwq()
21112 dma_pool_free(phba->lpfc_sg_dma_buf_pool, in lpfc_free_sgl_per_hdwq()
21113 list_entry->dma_sgl, in lpfc_free_sgl_per_hdwq()
21114 list_entry->dma_phys_sgl); in lpfc_free_sgl_per_hdwq()
21115 list_del(&list_entry->list_node); in lpfc_free_sgl_per_hdwq()
21119 spin_unlock_irqrestore(&hdwq->hdwq_lock, iflags); in lpfc_free_sgl_per_hdwq()
21123 * lpfc_get_cmd_rsp_buf_per_hdwq - Get one CMD/RSP buffer from hdwq
21131 * NULL - Error
21132 * Pointer to fcp_cmd_rsp_buf - Success
21141 struct lpfc_sli4_hdw_queue *hdwq = lpfc_buf->hdwq; in lpfc_get_cmd_rsp_buf_per_hdwq()
21142 struct list_head *buf_list = &hdwq->cmd_rsp_buf_list; in lpfc_get_cmd_rsp_buf_per_hdwq()
21145 spin_lock_irqsave(&hdwq->hdwq_lock, iflags); in lpfc_get_cmd_rsp_buf_per_hdwq()
21152 list_move_tail(&list_entry->list_node, in lpfc_get_cmd_rsp_buf_per_hdwq()
21153 &lpfc_buf->dma_cmd_rsp_list); in lpfc_get_cmd_rsp_buf_per_hdwq()
21158 spin_unlock_irqrestore(&hdwq->hdwq_lock, iflags); in lpfc_get_cmd_rsp_buf_per_hdwq()
21160 cpu_to_node(hdwq->io_wq->chann)); in lpfc_get_cmd_rsp_buf_per_hdwq()
21165 lpfc_buf->hdwq_no, __func__); in lpfc_get_cmd_rsp_buf_per_hdwq()
21169 tmp->fcp_cmnd = dma_pool_alloc(phba->lpfc_cmd_rsp_buf_pool, in lpfc_get_cmd_rsp_buf_per_hdwq()
21171 &tmp->fcp_cmd_rsp_dma_handle); in lpfc_get_cmd_rsp_buf_per_hdwq()
21173 if (!tmp->fcp_cmnd) { in lpfc_get_cmd_rsp_buf_per_hdwq()
21177 lpfc_buf->hdwq_no, __func__); in lpfc_get_cmd_rsp_buf_per_hdwq()
21182 tmp->fcp_rsp = (struct fcp_rsp *)((uint8_t *)tmp->fcp_cmnd + in lpfc_get_cmd_rsp_buf_per_hdwq()
21185 spin_lock_irqsave(&hdwq->hdwq_lock, iflags); in lpfc_get_cmd_rsp_buf_per_hdwq()
21186 list_add_tail(&tmp->list_node, &lpfc_buf->dma_cmd_rsp_list); in lpfc_get_cmd_rsp_buf_per_hdwq()
21189 allocated_buf = list_last_entry(&lpfc_buf->dma_cmd_rsp_list, in lpfc_get_cmd_rsp_buf_per_hdwq()
21193 spin_unlock_irqrestore(&hdwq->hdwq_lock, iflags); in lpfc_get_cmd_rsp_buf_per_hdwq()
21199 * lpfc_put_cmd_rsp_buf_per_hdwq - Put one CMD/RSP buffer into hdwq pool
21206 * 0 - Success
21207 * -EINVAL - Error
21216 struct lpfc_sli4_hdw_queue *hdwq = lpfc_buf->hdwq; in lpfc_put_cmd_rsp_buf_per_hdwq()
21217 struct list_head *buf_list = &hdwq->cmd_rsp_buf_list; in lpfc_put_cmd_rsp_buf_per_hdwq()
21220 spin_lock_irqsave(&hdwq->hdwq_lock, iflags); in lpfc_put_cmd_rsp_buf_per_hdwq()
21222 if (likely(!list_empty(&lpfc_buf->dma_cmd_rsp_list))) { in lpfc_put_cmd_rsp_buf_per_hdwq()
21224 &lpfc_buf->dma_cmd_rsp_list, in lpfc_put_cmd_rsp_buf_per_hdwq()
21226 list_move_tail(&list_entry->list_node, in lpfc_put_cmd_rsp_buf_per_hdwq()
21230 rc = -EINVAL; in lpfc_put_cmd_rsp_buf_per_hdwq()
21233 spin_unlock_irqrestore(&hdwq->hdwq_lock, iflags); in lpfc_put_cmd_rsp_buf_per_hdwq()
21238 * lpfc_free_cmd_rsp_buf_per_hdwq - Free all CMD/RSP chunks of hdwq pool
21251 struct list_head *buf_list = &hdwq->cmd_rsp_buf_list; in lpfc_free_cmd_rsp_buf_per_hdwq()
21256 spin_lock_irqsave(&hdwq->hdwq_lock, iflags); in lpfc_free_cmd_rsp_buf_per_hdwq()
21262 dma_pool_free(phba->lpfc_cmd_rsp_buf_pool, in lpfc_free_cmd_rsp_buf_per_hdwq()
21263 list_entry->fcp_cmnd, in lpfc_free_cmd_rsp_buf_per_hdwq()
21264 list_entry->fcp_cmd_rsp_dma_handle); in lpfc_free_cmd_rsp_buf_per_hdwq()
21265 list_del(&list_entry->list_node); in lpfc_free_cmd_rsp_buf_per_hdwq()
21269 spin_unlock_irqrestore(&hdwq->hdwq_lock, iflags); in lpfc_free_cmd_rsp_buf_per_hdwq()