Lines Matching +full:sub +full:- +full:mailbox
4 * Copyright (C) 2017-2024 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 *
110 /* Word 0, 1, 2 - BDE is variable */ in lpfc_wqe_cmd_template()
112 /* Word 3 - cmd_buff_len, payload_offset_len is zero */ in lpfc_wqe_cmd_template()
114 /* Word 4 - total_xfer_len is variable */ in lpfc_wqe_cmd_template()
116 /* Word 5 - is zero */ in lpfc_wqe_cmd_template()
118 /* Word 6 - ctxt_tag, xri_tag is variable */ in lpfc_wqe_cmd_template()
121 bf_set(wqe_cmnd, &wqe->fcp_iread.wqe_com, CMD_FCP_IREAD64_WQE); in lpfc_wqe_cmd_template()
122 bf_set(wqe_pu, &wqe->fcp_iread.wqe_com, PARM_READ_CHECK); in lpfc_wqe_cmd_template()
123 bf_set(wqe_class, &wqe->fcp_iread.wqe_com, CLASS3); in lpfc_wqe_cmd_template()
124 bf_set(wqe_ct, &wqe->fcp_iread.wqe_com, SLI4_CT_RPI); in lpfc_wqe_cmd_template()
126 /* Word 8 - abort_tag is variable */ in lpfc_wqe_cmd_template()
128 /* Word 9 - reqtag is variable */ in lpfc_wqe_cmd_template()
130 /* Word 10 - dbde, wqes is variable */ in lpfc_wqe_cmd_template()
131 bf_set(wqe_qosd, &wqe->fcp_iread.wqe_com, 0); in lpfc_wqe_cmd_template()
132 bf_set(wqe_iod, &wqe->fcp_iread.wqe_com, LPFC_WQE_IOD_READ); in lpfc_wqe_cmd_template()
133 bf_set(wqe_lenloc, &wqe->fcp_iread.wqe_com, LPFC_WQE_LENLOC_WORD4); in lpfc_wqe_cmd_template()
134 bf_set(wqe_dbde, &wqe->fcp_iread.wqe_com, 0); in lpfc_wqe_cmd_template()
135 bf_set(wqe_wqes, &wqe->fcp_iread.wqe_com, 1); in lpfc_wqe_cmd_template()
137 /* Word 11 - pbde is variable */ in lpfc_wqe_cmd_template()
138 bf_set(wqe_cmd_type, &wqe->fcp_iread.wqe_com, COMMAND_DATA_IN); in lpfc_wqe_cmd_template()
139 bf_set(wqe_cqid, &wqe->fcp_iread.wqe_com, LPFC_WQE_CQ_ID_DEFAULT); in lpfc_wqe_cmd_template()
140 bf_set(wqe_pbde, &wqe->fcp_iread.wqe_com, 0); in lpfc_wqe_cmd_template()
142 /* Word 12 - is zero */ in lpfc_wqe_cmd_template()
144 /* Word 13, 14, 15 - PBDE is variable */ in lpfc_wqe_cmd_template()
150 /* Word 0, 1, 2 - BDE is variable */ in lpfc_wqe_cmd_template()
152 /* Word 3 - cmd_buff_len, payload_offset_len is zero */ in lpfc_wqe_cmd_template()
154 /* Word 4 - total_xfer_len is variable */ in lpfc_wqe_cmd_template()
156 /* Word 5 - initial_xfer_len is variable */ in lpfc_wqe_cmd_template()
158 /* Word 6 - ctxt_tag, xri_tag is variable */ in lpfc_wqe_cmd_template()
161 bf_set(wqe_cmnd, &wqe->fcp_iwrite.wqe_com, CMD_FCP_IWRITE64_WQE); in lpfc_wqe_cmd_template()
162 bf_set(wqe_pu, &wqe->fcp_iwrite.wqe_com, PARM_READ_CHECK); in lpfc_wqe_cmd_template()
163 bf_set(wqe_class, &wqe->fcp_iwrite.wqe_com, CLASS3); in lpfc_wqe_cmd_template()
164 bf_set(wqe_ct, &wqe->fcp_iwrite.wqe_com, SLI4_CT_RPI); in lpfc_wqe_cmd_template()
166 /* Word 8 - abort_tag is variable */ in lpfc_wqe_cmd_template()
168 /* Word 9 - reqtag is variable */ in lpfc_wqe_cmd_template()
170 /* Word 10 - dbde, wqes is variable */ in lpfc_wqe_cmd_template()
171 bf_set(wqe_qosd, &wqe->fcp_iwrite.wqe_com, 0); in lpfc_wqe_cmd_template()
172 bf_set(wqe_iod, &wqe->fcp_iwrite.wqe_com, LPFC_WQE_IOD_WRITE); in lpfc_wqe_cmd_template()
173 bf_set(wqe_lenloc, &wqe->fcp_iwrite.wqe_com, LPFC_WQE_LENLOC_WORD4); in lpfc_wqe_cmd_template()
174 bf_set(wqe_dbde, &wqe->fcp_iwrite.wqe_com, 0); in lpfc_wqe_cmd_template()
175 bf_set(wqe_wqes, &wqe->fcp_iwrite.wqe_com, 1); in lpfc_wqe_cmd_template()
177 /* Word 11 - pbde is variable */ in lpfc_wqe_cmd_template()
178 bf_set(wqe_cmd_type, &wqe->fcp_iwrite.wqe_com, COMMAND_DATA_OUT); in lpfc_wqe_cmd_template()
179 bf_set(wqe_cqid, &wqe->fcp_iwrite.wqe_com, LPFC_WQE_CQ_ID_DEFAULT); in lpfc_wqe_cmd_template()
180 bf_set(wqe_pbde, &wqe->fcp_iwrite.wqe_com, 0); in lpfc_wqe_cmd_template()
182 /* Word 12 - is zero */ in lpfc_wqe_cmd_template()
184 /* Word 13, 14, 15 - PBDE is variable */ in lpfc_wqe_cmd_template()
190 /* Word 0, 1, 2 - BDE is variable */ in lpfc_wqe_cmd_template()
192 /* Word 3 - payload_offset_len is variable */ in lpfc_wqe_cmd_template()
194 /* Word 4, 5 - is zero */ in lpfc_wqe_cmd_template()
196 /* Word 6 - ctxt_tag, xri_tag is variable */ in lpfc_wqe_cmd_template()
199 bf_set(wqe_cmnd, &wqe->fcp_icmd.wqe_com, CMD_FCP_ICMND64_WQE); in lpfc_wqe_cmd_template()
200 bf_set(wqe_pu, &wqe->fcp_icmd.wqe_com, 0); in lpfc_wqe_cmd_template()
201 bf_set(wqe_class, &wqe->fcp_icmd.wqe_com, CLASS3); in lpfc_wqe_cmd_template()
202 bf_set(wqe_ct, &wqe->fcp_icmd.wqe_com, SLI4_CT_RPI); in lpfc_wqe_cmd_template()
204 /* Word 8 - abort_tag is variable */ in lpfc_wqe_cmd_template()
206 /* Word 9 - reqtag is variable */ in lpfc_wqe_cmd_template()
208 /* Word 10 - dbde, wqes is variable */ in lpfc_wqe_cmd_template()
209 bf_set(wqe_qosd, &wqe->fcp_icmd.wqe_com, 1); in lpfc_wqe_cmd_template()
210 bf_set(wqe_iod, &wqe->fcp_icmd.wqe_com, LPFC_WQE_IOD_NONE); in lpfc_wqe_cmd_template()
211 bf_set(wqe_lenloc, &wqe->fcp_icmd.wqe_com, LPFC_WQE_LENLOC_NONE); in lpfc_wqe_cmd_template()
212 bf_set(wqe_dbde, &wqe->fcp_icmd.wqe_com, 0); in lpfc_wqe_cmd_template()
213 bf_set(wqe_wqes, &wqe->fcp_icmd.wqe_com, 1); in lpfc_wqe_cmd_template()
216 bf_set(wqe_cmd_type, &wqe->fcp_icmd.wqe_com, COMMAND_DATA_IN); in lpfc_wqe_cmd_template()
217 bf_set(wqe_cqid, &wqe->fcp_icmd.wqe_com, LPFC_WQE_CQ_ID_DEFAULT); in lpfc_wqe_cmd_template()
218 bf_set(wqe_pbde, &wqe->fcp_icmd.wqe_com, 0); in lpfc_wqe_cmd_template()
220 /* Word 12, 13, 14, 15 - is zero */ in lpfc_wqe_cmd_template()
225 * lpfc_sli4_pcimem_bcopy - SLI4 memory copy function
252 * lpfc_sli4_wq_put - Put a Work Queue Entry on an Work Queue
260 * -ENOMEM.
276 return -ENOMEM; in lpfc_sli4_wq_put()
278 temp_wqe = lpfc_sli4_qe(q, q->host_index); in lpfc_sli4_wq_put()
281 idx = ((q->host_index + 1) % q->entry_count); in lpfc_sli4_wq_put()
282 if (idx == q->hba_index) { in lpfc_sli4_wq_put()
283 q->WQ_overflow++; in lpfc_sli4_wq_put()
284 return -EBUSY; in lpfc_sli4_wq_put()
286 q->WQ_posted++; in lpfc_sli4_wq_put()
288 if (!((q->host_index + 1) % q->notify_interval)) in lpfc_sli4_wq_put()
289 bf_set(wqe_wqec, &wqe->generic.wqe_com, 1); in lpfc_sli4_wq_put()
291 bf_set(wqe_wqec, &wqe->generic.wqe_com, 0); in lpfc_sli4_wq_put()
292 if (q->phba->sli3_options & LPFC_SLI4_PHWQ_ENABLED) in lpfc_sli4_wq_put()
293 bf_set(wqe_wqid, &wqe->generic.wqe_com, q->queue_id); in lpfc_sli4_wq_put()
294 lpfc_sli4_pcimem_bcopy(wqe, temp_wqe, q->entry_size); in lpfc_sli4_wq_put()
295 if (q->dpp_enable && q->phba->cfg_enable_dpp) { in lpfc_sli4_wq_put()
299 for (i = 0; i < q->entry_size; i += sizeof(uint64_t)) in lpfc_sli4_wq_put()
301 q->dpp_regaddr + i); in lpfc_sli4_wq_put()
303 for (i = 0; i < q->entry_size; i += sizeof(uint32_t)) in lpfc_sli4_wq_put()
305 q->dpp_regaddr + i); in lpfc_sli4_wq_put()
312 host_index = q->host_index; in lpfc_sli4_wq_put()
314 q->host_index = idx; in lpfc_sli4_wq_put()
318 if (q->db_format == LPFC_DB_LIST_FORMAT) { in lpfc_sli4_wq_put()
319 if (q->dpp_enable && q->phba->cfg_enable_dpp) { in lpfc_sli4_wq_put()
323 q->dpp_id); in lpfc_sli4_wq_put()
325 q->queue_id); in lpfc_sli4_wq_put()
328 bf_set(lpfc_wq_db_list_fm_id, &doorbell, q->queue_id); in lpfc_sli4_wq_put()
332 &q->phba->sli4_hba.sli_intf); in lpfc_sli4_wq_put()
337 } else if (q->db_format == LPFC_DB_RING_FORMAT) { in lpfc_sli4_wq_put()
339 bf_set(lpfc_wq_db_ring_fm_id, &doorbell, q->queue_id); in lpfc_sli4_wq_put()
341 return -EINVAL; in lpfc_sli4_wq_put()
343 writel(doorbell.word0, q->db_regaddr); in lpfc_sli4_wq_put()
349 * lpfc_sli4_wq_release - Updates internal hba index for WQ
365 q->hba_index = index; in lpfc_sli4_wq_release()
369 * lpfc_sli4_mq_put - Put a Mailbox Queue Entry on an Mailbox Queue
370 * @q: The Mailbox Queue to operate on.
371 * @mqe: The Mailbox Queue Entry to put on the Work queue.
377 * -ENOMEM.
388 return -ENOMEM; in lpfc_sli4_mq_put()
389 temp_mqe = lpfc_sli4_qe(q, q->host_index); in lpfc_sli4_mq_put()
392 if (((q->host_index + 1) % q->entry_count) == q->hba_index) in lpfc_sli4_mq_put()
393 return -ENOMEM; in lpfc_sli4_mq_put()
394 lpfc_sli4_pcimem_bcopy(mqe, temp_mqe, q->entry_size); in lpfc_sli4_mq_put()
395 /* Save off the mailbox pointer for completion */ in lpfc_sli4_mq_put()
396 q->phba->mbox = (MAILBOX_t *)temp_mqe; in lpfc_sli4_mq_put()
399 q->host_index = ((q->host_index + 1) % q->entry_count); in lpfc_sli4_mq_put()
404 bf_set(lpfc_mq_doorbell_id, &doorbell, q->queue_id); in lpfc_sli4_mq_put()
405 writel(doorbell.word0, q->phba->sli4_hba.MQDBregaddr); in lpfc_sli4_mq_put()
410 * lpfc_sli4_mq_release - Updates internal hba index for MQ
411 * @q: The Mailbox Queue to operate on.
414 * a Mailbox Queue Entry by the HBA. When the HBA indicates that it has consumed
426 /* Clear the mailbox pointer for completion */ in lpfc_sli4_mq_release()
427 q->phba->mbox = NULL; in lpfc_sli4_mq_release()
428 q->hba_index = ((q->hba_index + 1) % q->entry_count); in lpfc_sli4_mq_release()
433 * lpfc_sli4_eq_get - Gets the next valid EQE from a EQ
449 eqe = lpfc_sli4_qe(q, q->host_index); in lpfc_sli4_eq_get()
452 if (bf_get_le32(lpfc_eqe_valid, eqe) != q->qe_valid) in lpfc_sli4_eq_get()
469 * lpfc_sli4_eq_clr_intr - Turn off interrupts from this EQ
482 (q->queue_id >> LPFC_EQID_HI_FIELD_SHIFT)); in lpfc_sli4_eq_clr_intr()
483 bf_set(lpfc_eqcq_doorbell_eqid_lo, &doorbell, q->queue_id); in lpfc_sli4_eq_clr_intr()
484 writel(doorbell.word0, q->phba->sli4_hba.EQDBregaddr); in lpfc_sli4_eq_clr_intr()
488 * lpfc_sli4_if6_eq_clr_intr - Turn off interrupts from this EQ
498 bf_set(lpfc_if6_eq_doorbell_eqid, &doorbell, q->queue_id); in lpfc_sli4_if6_eq_clr_intr()
499 writel(doorbell.word0, q->phba->sli4_hba.EQDBregaddr); in lpfc_sli4_if6_eq_clr_intr()
503 * lpfc_sli4_write_eq_db - write EQ DB for eqe's consumed or arm state
532 (q->queue_id >> LPFC_EQID_HI_FIELD_SHIFT)); in lpfc_sli4_write_eq_db()
533 bf_set(lpfc_eqcq_doorbell_eqid_lo, &doorbell, q->queue_id); in lpfc_sli4_write_eq_db()
534 writel(doorbell.word0, q->phba->sli4_hba.EQDBregaddr); in lpfc_sli4_write_eq_db()
535 /* PCI read to flush PCI pipeline on re-arming for INTx mode */ in lpfc_sli4_write_eq_db()
536 if ((q->phba->intr_type == INTx) && (arm == LPFC_QUEUE_REARM)) in lpfc_sli4_write_eq_db()
537 readl(q->phba->sli4_hba.EQDBregaddr); in lpfc_sli4_write_eq_db()
541 * lpfc_sli4_if6_write_eq_db - write EQ DB for eqe's consumed or arm state
566 bf_set(lpfc_if6_eq_doorbell_eqid, &doorbell, q->queue_id); in lpfc_sli4_if6_write_eq_db()
567 writel(doorbell.word0, q->phba->sli4_hba.EQDBregaddr); in lpfc_sli4_if6_write_eq_db()
568 /* PCI read to flush PCI pipeline on re-arming for INTx mode */ in lpfc_sli4_if6_write_eq_db()
569 if ((q->phba->intr_type == INTx) && (arm == LPFC_QUEUE_REARM)) in lpfc_sli4_if6_write_eq_db()
570 readl(q->phba->sli4_hba.EQDBregaddr); in lpfc_sli4_if6_write_eq_db()
577 if (!phba->sli4_hba.pc_sli4_params.eqav) in __lpfc_sli4_consume_eqe()
580 eq->host_index = ((eq->host_index + 1) % eq->entry_count); in __lpfc_sli4_consume_eqe()
583 if (phba->sli4_hba.pc_sli4_params.eqav && !eq->host_index) in __lpfc_sli4_consume_eqe()
584 eq->qe_valid = (eq->qe_valid) ? 0 : 1; in __lpfc_sli4_consume_eqe()
603 list_for_each_entry(childq, &eq->child_list, list) { in lpfc_sli4_eqcq_flush()
604 if (childq->queue_id == cqid) { in lpfc_sli4_eqcq_flush()
617 /* Clear and re-arm the CQ */ in lpfc_sli4_eqcq_flush()
618 phba->sli4_hba.sli4_write_cq_db(phba, cq, cq_count, in lpfc_sli4_eqcq_flush()
627 /* Clear and re-arm the EQ */ in lpfc_sli4_eqcq_flush()
628 phba->sli4_hba.sli4_write_eq_db(phba, eq, eq_count, LPFC_QUEUE_REARM); in lpfc_sli4_eqcq_flush()
638 if (cmpxchg(&eq->queue_claimed, 0, 1) != 0) in lpfc_sli4_process_eq()
647 if (!(++count % eq->max_proc_limit)) in lpfc_sli4_process_eq()
650 if (!(count % eq->notify_interval)) { in lpfc_sli4_process_eq()
651 phba->sli4_hba.sli4_write_eq_db(phba, eq, consumed, in lpfc_sli4_process_eq()
658 eq->EQ_processed += count; in lpfc_sli4_process_eq()
661 if (count > eq->EQ_max_eqe) in lpfc_sli4_process_eq()
662 eq->EQ_max_eqe = count; in lpfc_sli4_process_eq()
664 xchg(&eq->queue_claimed, 0); in lpfc_sli4_process_eq()
668 phba->sli4_hba.sli4_write_eq_db(phba, eq, consumed, rearm); in lpfc_sli4_process_eq()
674 * lpfc_sli4_cq_get - Gets the next valid CQE from a CQ
690 cqe = lpfc_sli4_qe(q, q->host_index); in lpfc_sli4_cq_get()
693 if (bf_get_le32(lpfc_cqe_valid, cqe) != q->qe_valid) in lpfc_sli4_cq_get()
702 * single 32-bit entity here (vs multi word structure for cq's). in lpfc_sli4_cq_get()
712 if (!phba->sli4_hba.pc_sli4_params.cqav) in __lpfc_sli4_consume_cqe()
715 cq->host_index = ((cq->host_index + 1) % cq->entry_count); in __lpfc_sli4_consume_cqe()
718 if (phba->sli4_hba.pc_sli4_params.cqav && !cq->host_index) in __lpfc_sli4_consume_cqe()
719 cq->qe_valid = (cq->qe_valid) ? 0 : 1; in __lpfc_sli4_consume_cqe()
723 * lpfc_sli4_write_cq_db - write cq DB for entries consumed or arm state.
750 (q->queue_id >> LPFC_CQID_HI_FIELD_SHIFT)); in lpfc_sli4_write_cq_db()
751 bf_set(lpfc_eqcq_doorbell_cqid_lo, &doorbell, q->queue_id); in lpfc_sli4_write_cq_db()
752 writel(doorbell.word0, q->phba->sli4_hba.CQDBregaddr); in lpfc_sli4_write_cq_db()
756 * lpfc_sli4_if6_write_cq_db - write cq DB for entries consumed or arm state.
781 bf_set(lpfc_if6_cq_doorbell_cqid, &doorbell, q->queue_id); in lpfc_sli4_if6_write_cq_db()
782 writel(doorbell.word0, q->phba->sli4_hba.CQDBregaddr); in lpfc_sli4_if6_write_cq_db()
786 * lpfc_sli4_rq_put - Put a Receive Buffer Queue Entry on a Receive Queue
792 * on @q then this function will return -ENOMEM.
807 return -ENOMEM; in lpfc_sli4_rq_put()
808 hq_put_index = hq->host_index; in lpfc_sli4_rq_put()
809 dq_put_index = dq->host_index; in lpfc_sli4_rq_put()
813 if (hq->type != LPFC_HRQ || dq->type != LPFC_DRQ) in lpfc_sli4_rq_put()
814 return -EINVAL; in lpfc_sli4_rq_put()
816 return -EINVAL; in lpfc_sli4_rq_put()
818 if (((hq_put_index + 1) % hq->entry_count) == hq->hba_index) in lpfc_sli4_rq_put()
819 return -EBUSY; in lpfc_sli4_rq_put()
820 lpfc_sli4_pcimem_bcopy(hrqe, temp_hrqe, hq->entry_size); in lpfc_sli4_rq_put()
821 lpfc_sli4_pcimem_bcopy(drqe, temp_drqe, dq->entry_size); in lpfc_sli4_rq_put()
824 hq->host_index = ((hq_put_index + 1) % hq->entry_count); in lpfc_sli4_rq_put()
825 dq->host_index = ((dq_put_index + 1) % dq->entry_count); in lpfc_sli4_rq_put()
826 hq->RQ_buf_posted++; in lpfc_sli4_rq_put()
829 if (!(hq->host_index % hq->notify_interval)) { in lpfc_sli4_rq_put()
831 if (hq->db_format == LPFC_DB_RING_FORMAT) { in lpfc_sli4_rq_put()
833 hq->notify_interval); in lpfc_sli4_rq_put()
834 bf_set(lpfc_rq_db_ring_fm_id, &doorbell, hq->queue_id); in lpfc_sli4_rq_put()
835 } else if (hq->db_format == LPFC_DB_LIST_FORMAT) { in lpfc_sli4_rq_put()
837 hq->notify_interval); in lpfc_sli4_rq_put()
839 hq->host_index); in lpfc_sli4_rq_put()
840 bf_set(lpfc_rq_db_list_fm_id, &doorbell, hq->queue_id); in lpfc_sli4_rq_put()
842 return -EINVAL; in lpfc_sli4_rq_put()
844 writel(doorbell.word0, hq->db_regaddr); in lpfc_sli4_rq_put()
850 * lpfc_sli4_rq_release - Updates internal hba index for RQ
865 if ((hq->type != LPFC_HRQ) || (dq->type != LPFC_DRQ)) in lpfc_sli4_rq_release()
867 hq->hba_index = ((hq->hba_index + 1) % hq->entry_count); in lpfc_sli4_rq_release()
868 dq->hba_index = ((dq->hba_index + 1) % dq->entry_count); in lpfc_sli4_rq_release()
873 * lpfc_cmd_iocb - Get next command iocb entry in the ring
880 * SLI-2/SLI-3 provide different sized iocbs.
885 return (IOCB_t *) (((char *) pring->sli.sli3.cmdringaddr) + in lpfc_cmd_iocb()
886 pring->sli.sli3.cmdidx * phba->iocb_cmd_size); in lpfc_cmd_iocb()
890 * lpfc_resp_iocb - Get next response iocb entry in the ring
897 * SLI-2/SLI-3 provide different sized iocbs.
902 return (IOCB_t *) (((char *) pring->sli.sli3.rspringaddr) + in lpfc_resp_iocb()
903 pring->sli.sli3.rspidx * phba->iocb_rsp_size); in lpfc_resp_iocb()
907 * __lpfc_sli_get_iocbq - Allocates an iocb object from iocb pool
918 struct list_head *lpfc_iocb_list = &phba->lpfc_iocb_list; in __lpfc_sli_get_iocbq()
921 lockdep_assert_held(&phba->hbalock); in __lpfc_sli_get_iocbq()
925 phba->iocb_cnt++; in __lpfc_sli_get_iocbq()
926 if (phba->iocb_cnt > phba->iocb_max) in __lpfc_sli_get_iocbq()
927 phba->iocb_max = phba->iocb_cnt; in __lpfc_sli_get_iocbq()
932 * __lpfc_clear_active_sglq - Remove the active sglq for this XRI.
948 sglq = phba->sli4_hba.lpfc_sglq_active_list[xritag]; in __lpfc_clear_active_sglq()
949 phba->sli4_hba.lpfc_sglq_active_list[xritag] = NULL; in __lpfc_clear_active_sglq()
954 * __lpfc_get_active_sglq - Get the active sglq for this XRI.
970 sglq = phba->sli4_hba.lpfc_sglq_active_list[xritag]; in __lpfc_get_active_sglq()
975 * lpfc_clr_rrq_active - Clears RRQ active bit in xri_bitmap.
989 if (rrq->vport) in lpfc_clr_rrq_active()
990 ndlp = lpfc_findnode_did(rrq->vport, rrq->nlp_DID); in lpfc_clr_rrq_active()
995 if (test_and_clear_bit(xritag, ndlp->active_rrqs_xri_bitmap)) { in lpfc_clr_rrq_active()
996 rrq->send_rrq = 0; in lpfc_clr_rrq_active()
997 rrq->xritag = 0; in lpfc_clr_rrq_active()
998 rrq->rrq_stop_time = 0; in lpfc_clr_rrq_active()
1001 mempool_free(rrq, phba->rrq_pool); in lpfc_clr_rrq_active()
1005 * lpfc_handle_rrq_active - Checks if RRQ has waithed RATOV.
1027 clear_bit(HBA_RRQ_ACTIVE, &phba->hba_flag); in lpfc_handle_rrq_active()
1028 next_time = jiffies + msecs_to_jiffies(1000 * (phba->fc_ratov + 1)); in lpfc_handle_rrq_active()
1029 spin_lock_irqsave(&phba->rrq_list_lock, iflags); in lpfc_handle_rrq_active()
1031 &phba->active_rrq_list, list) { in lpfc_handle_rrq_active()
1032 if (time_after(jiffies, rrq->rrq_stop_time)) in lpfc_handle_rrq_active()
1033 list_move(&rrq->list, &send_rrq); in lpfc_handle_rrq_active()
1034 else if (time_before(rrq->rrq_stop_time, next_time)) in lpfc_handle_rrq_active()
1035 next_time = rrq->rrq_stop_time; in lpfc_handle_rrq_active()
1037 spin_unlock_irqrestore(&phba->rrq_list_lock, iflags); in lpfc_handle_rrq_active()
1038 if ((!list_empty(&phba->active_rrq_list)) && in lpfc_handle_rrq_active()
1039 (!test_bit(FC_UNLOADING, &phba->pport->load_flag))) in lpfc_handle_rrq_active()
1040 mod_timer(&phba->rrq_tmr, next_time); in lpfc_handle_rrq_active()
1042 list_del(&rrq->list); in lpfc_handle_rrq_active()
1043 if (!rrq->send_rrq) { in lpfc_handle_rrq_active()
1045 lpfc_clr_rrq_active(phba, rrq->xritag, rrq); in lpfc_handle_rrq_active()
1050 lpfc_clr_rrq_active(phba, rrq->xritag, in lpfc_handle_rrq_active()
1057 * lpfc_get_active_rrq - Get the active RRQ for this exchange.
1062 * returns NULL = rrq not found in the phba->active_rrq_list.
1068 struct lpfc_hba *phba = vport->phba; in lpfc_get_active_rrq()
1073 if (phba->sli_rev != LPFC_SLI_REV4) in lpfc_get_active_rrq()
1075 spin_lock_irqsave(&phba->rrq_list_lock, iflags); in lpfc_get_active_rrq()
1076 list_for_each_entry_safe(rrq, nextrrq, &phba->active_rrq_list, list) { in lpfc_get_active_rrq()
1077 if (rrq->vport == vport && rrq->xritag == xri && in lpfc_get_active_rrq()
1078 rrq->nlp_DID == did){ in lpfc_get_active_rrq()
1079 list_del(&rrq->list); in lpfc_get_active_rrq()
1080 spin_unlock_irqrestore(&phba->rrq_list_lock, iflags); in lpfc_get_active_rrq()
1084 spin_unlock_irqrestore(&phba->rrq_list_lock, iflags); in lpfc_get_active_rrq()
1089 * lpfc_cleanup_vports_rrqs - Remove and clear the active RRQ for this vport.
1093 * phba->active_rrq_list and clear the rrq.
1100 struct lpfc_hba *phba = vport->phba; in lpfc_cleanup_vports_rrqs()
1106 if (phba->sli_rev != LPFC_SLI_REV4) in lpfc_cleanup_vports_rrqs()
1112 spin_lock_irqsave(&phba->rrq_list_lock, iflags); in lpfc_cleanup_vports_rrqs()
1113 list_for_each_entry_safe(rrq, nextrrq, &phba->active_rrq_list, list) { in lpfc_cleanup_vports_rrqs()
1114 if (rrq->vport != vport) in lpfc_cleanup_vports_rrqs()
1117 if (!ndlp || ndlp == lpfc_findnode_did(vport, rrq->nlp_DID)) in lpfc_cleanup_vports_rrqs()
1118 list_move(&rrq->list, &rrq_list); in lpfc_cleanup_vports_rrqs()
1121 spin_unlock_irqrestore(&phba->rrq_list_lock, iflags); in lpfc_cleanup_vports_rrqs()
1124 list_del(&rrq->list); in lpfc_cleanup_vports_rrqs()
1125 lpfc_clr_rrq_active(phba, rrq->xritag, rrq); in lpfc_cleanup_vports_rrqs()
1130 * lpfc_test_rrq_active - Test RRQ bit in xri_bitmap.
1145 if (!ndlp->active_rrqs_xri_bitmap) in lpfc_test_rrq_active()
1147 if (test_bit(xritag, ndlp->active_rrqs_xri_bitmap)) in lpfc_test_rrq_active()
1154 * lpfc_set_rrq_active - set RRQ active bit in xri_bitmap.
1177 return -EINVAL; in lpfc_set_rrq_active()
1179 if (!phba->cfg_enable_rrq) in lpfc_set_rrq_active()
1180 return -EINVAL; in lpfc_set_rrq_active()
1182 if (test_bit(FC_UNLOADING, &phba->pport->load_flag)) { in lpfc_set_rrq_active()
1183 clear_bit(HBA_RRQ_ACTIVE, &phba->hba_flag); in lpfc_set_rrq_active()
1187 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_set_rrq_active()
1188 if (ndlp->vport && test_bit(FC_UNLOADING, &ndlp->vport->load_flag)) in lpfc_set_rrq_active()
1191 if (!ndlp->active_rrqs_xri_bitmap) in lpfc_set_rrq_active()
1194 if (test_and_set_bit(xritag, ndlp->active_rrqs_xri_bitmap)) in lpfc_set_rrq_active()
1197 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_set_rrq_active()
1198 rrq = mempool_alloc(phba->rrq_pool, GFP_ATOMIC); in lpfc_set_rrq_active()
1203 xritag, rxid, ndlp->nlp_DID, send_rrq); in lpfc_set_rrq_active()
1204 return -EINVAL; in lpfc_set_rrq_active()
1206 if (phba->cfg_enable_rrq == 1) in lpfc_set_rrq_active()
1207 rrq->send_rrq = send_rrq; in lpfc_set_rrq_active()
1209 rrq->send_rrq = 0; in lpfc_set_rrq_active()
1210 rrq->xritag = xritag; in lpfc_set_rrq_active()
1211 rrq->rrq_stop_time = jiffies + in lpfc_set_rrq_active()
1212 msecs_to_jiffies(1000 * (phba->fc_ratov + 1)); in lpfc_set_rrq_active()
1213 rrq->nlp_DID = ndlp->nlp_DID; in lpfc_set_rrq_active()
1214 rrq->vport = ndlp->vport; in lpfc_set_rrq_active()
1215 rrq->rxid = rxid; in lpfc_set_rrq_active()
1217 spin_lock_irqsave(&phba->rrq_list_lock, iflags); in lpfc_set_rrq_active()
1218 empty = list_empty(&phba->active_rrq_list); in lpfc_set_rrq_active()
1219 list_add_tail(&rrq->list, &phba->active_rrq_list); in lpfc_set_rrq_active()
1220 spin_unlock_irqrestore(&phba->rrq_list_lock, iflags); in lpfc_set_rrq_active()
1221 set_bit(HBA_RRQ_ACTIVE, &phba->hba_flag); in lpfc_set_rrq_active()
1226 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_set_rrq_active()
1231 xritag, rxid, ndlp->nlp_DID, send_rrq); in lpfc_set_rrq_active()
1232 return -EINVAL; in lpfc_set_rrq_active()
1236 * __lpfc_sli_get_els_sglq - Allocates an iocb object from sgl pool
1249 struct list_head *lpfc_els_sgl_list = &phba->sli4_hba.lpfc_els_sgl_list; in __lpfc_sli_get_els_sglq()
1259 if (piocbq->cmd_flag & LPFC_IO_FCP) { in __lpfc_sli_get_els_sglq()
1260 lpfc_cmd = piocbq->io_buf; in __lpfc_sli_get_els_sglq()
1261 ndlp = lpfc_cmd->rdata->pnode; in __lpfc_sli_get_els_sglq()
1263 !(piocbq->cmd_flag & LPFC_IO_LIBDFC)) { in __lpfc_sli_get_els_sglq()
1264 ndlp = piocbq->ndlp; in __lpfc_sli_get_els_sglq()
1265 } else if (piocbq->cmd_flag & LPFC_IO_LIBDFC) { in __lpfc_sli_get_els_sglq()
1266 if (piocbq->cmd_flag & LPFC_IO_LOOPBACK) in __lpfc_sli_get_els_sglq()
1269 ndlp = piocbq->ndlp; in __lpfc_sli_get_els_sglq()
1271 ndlp = piocbq->ndlp; in __lpfc_sli_get_els_sglq()
1274 spin_lock(&phba->sli4_hba.sgl_list_lock); in __lpfc_sli_get_els_sglq()
1280 if (ndlp && ndlp->active_rrqs_xri_bitmap && in __lpfc_sli_get_els_sglq()
1281 test_bit(sglq->sli4_lxritag, in __lpfc_sli_get_els_sglq()
1282 ndlp->active_rrqs_xri_bitmap)) { in __lpfc_sli_get_els_sglq()
1286 list_add_tail(&sglq->list, lpfc_els_sgl_list); in __lpfc_sli_get_els_sglq()
1291 list_add_tail(&sglq->list, lpfc_els_sgl_list); in __lpfc_sli_get_els_sglq()
1297 sglq->ndlp = ndlp; in __lpfc_sli_get_els_sglq()
1299 phba->sli4_hba.lpfc_sglq_active_list[sglq->sli4_lxritag] = sglq; in __lpfc_sli_get_els_sglq()
1300 sglq->state = SGL_ALLOCATED; in __lpfc_sli_get_els_sglq()
1302 spin_unlock(&phba->sli4_hba.sgl_list_lock); in __lpfc_sli_get_els_sglq()
1307 * __lpfc_sli_get_nvmet_sglq - Allocates an iocb object from sgl pool
1322 lpfc_nvmet_sgl_list = &phba->sli4_hba.lpfc_nvmet_sgl_list; in __lpfc_sli_get_nvmet_sglq()
1324 lockdep_assert_held(&phba->sli4_hba.sgl_list_lock); in __lpfc_sli_get_nvmet_sglq()
1329 phba->sli4_hba.lpfc_sglq_active_list[sglq->sli4_lxritag] = sglq; in __lpfc_sli_get_nvmet_sglq()
1330 sglq->state = SGL_ALLOCATED; in __lpfc_sli_get_nvmet_sglq()
1335 * lpfc_sli_get_iocbq - Allocates an iocb object from iocb pool
1349 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli_get_iocbq()
1351 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli_get_iocbq()
1356 * __lpfc_sli_release_iocbq_s4 - Release iocb to the iocb pool
1381 if (iocbq->sli4_xritag == NO_XRI) in __lpfc_sli_release_iocbq_s4()
1384 sglq = __lpfc_clear_active_sglq(phba, iocbq->sli4_lxritag); in __lpfc_sli_release_iocbq_s4()
1388 if (iocbq->cmd_flag & LPFC_IO_NVMET) { in __lpfc_sli_release_iocbq_s4()
1389 spin_lock_irqsave(&phba->sli4_hba.sgl_list_lock, in __lpfc_sli_release_iocbq_s4()
1391 sglq->state = SGL_FREED; in __lpfc_sli_release_iocbq_s4()
1392 sglq->ndlp = NULL; in __lpfc_sli_release_iocbq_s4()
1393 list_add_tail(&sglq->list, in __lpfc_sli_release_iocbq_s4()
1394 &phba->sli4_hba.lpfc_nvmet_sgl_list); in __lpfc_sli_release_iocbq_s4()
1396 &phba->sli4_hba.sgl_list_lock, iflag); in __lpfc_sli_release_iocbq_s4()
1400 if ((iocbq->cmd_flag & LPFC_EXCHANGE_BUSY) && in __lpfc_sli_release_iocbq_s4()
1401 (!(unlikely(pci_channel_offline(phba->pcidev)))) && in __lpfc_sli_release_iocbq_s4()
1402 sglq->state != SGL_XRI_ABORTED) { in __lpfc_sli_release_iocbq_s4()
1403 spin_lock_irqsave(&phba->sli4_hba.sgl_list_lock, in __lpfc_sli_release_iocbq_s4()
1407 if (sglq->ndlp && !lpfc_nlp_get(sglq->ndlp)) in __lpfc_sli_release_iocbq_s4()
1408 sglq->ndlp = NULL; in __lpfc_sli_release_iocbq_s4()
1410 list_add(&sglq->list, in __lpfc_sli_release_iocbq_s4()
1411 &phba->sli4_hba.lpfc_abts_els_sgl_list); in __lpfc_sli_release_iocbq_s4()
1413 &phba->sli4_hba.sgl_list_lock, iflag); in __lpfc_sli_release_iocbq_s4()
1415 spin_lock_irqsave(&phba->sli4_hba.sgl_list_lock, in __lpfc_sli_release_iocbq_s4()
1417 sglq->state = SGL_FREED; in __lpfc_sli_release_iocbq_s4()
1418 sglq->ndlp = NULL; in __lpfc_sli_release_iocbq_s4()
1419 list_add_tail(&sglq->list, in __lpfc_sli_release_iocbq_s4()
1420 &phba->sli4_hba.lpfc_els_sgl_list); in __lpfc_sli_release_iocbq_s4()
1422 &phba->sli4_hba.sgl_list_lock, iflag); in __lpfc_sli_release_iocbq_s4()
1425 if (pring && (!list_empty(&pring->txq))) in __lpfc_sli_release_iocbq_s4()
1435 iocbq->sli4_lxritag = NO_XRI; in __lpfc_sli_release_iocbq_s4()
1436 iocbq->sli4_xritag = NO_XRI; in __lpfc_sli_release_iocbq_s4()
1437 iocbq->cmd_flag &= ~(LPFC_IO_NVME | LPFC_IO_NVMET | LPFC_IO_CMF | in __lpfc_sli_release_iocbq_s4()
1439 list_add_tail(&iocbq->list, &phba->lpfc_iocb_list); in __lpfc_sli_release_iocbq_s4()
1444 * __lpfc_sli_release_iocbq_s3 - Release iocb to the iocb pool
1462 iocbq->sli4_xritag = NO_XRI; in __lpfc_sli_release_iocbq_s3()
1463 list_add_tail(&iocbq->list, &phba->lpfc_iocb_list); in __lpfc_sli_release_iocbq_s3()
1467 * __lpfc_sli_release_iocbq - Release iocb to the iocb pool
1479 lockdep_assert_held(&phba->hbalock); in __lpfc_sli_release_iocbq()
1481 phba->__lpfc_sli_release_iocbq(phba, iocbq); in __lpfc_sli_release_iocbq()
1482 phba->iocb_cnt--; in __lpfc_sli_release_iocbq()
1486 * lpfc_sli_release_iocbq - Release iocb to the iocb pool
1501 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli_release_iocbq()
1503 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli_release_iocbq()
1507 * lpfc_sli_cancel_iocbs - Cancel all iocbs from a list.
1511 * @ulpWord4: ULP word-4 in IOCB command field.
1526 if (piocb->cmd_cmpl) { in lpfc_sli_cancel_iocbs()
1527 if (piocb->cmd_flag & LPFC_IO_NVME) { in lpfc_sli_cancel_iocbs()
1531 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_sli_cancel_iocbs()
1533 &piocb->wcqe_cmpl, ulpstatus); in lpfc_sli_cancel_iocbs()
1534 piocb->wcqe_cmpl.parameter = ulpWord4; in lpfc_sli_cancel_iocbs()
1536 piocb->iocb.ulpStatus = ulpstatus; in lpfc_sli_cancel_iocbs()
1537 piocb->iocb.un.ulpWord[4] = ulpWord4; in lpfc_sli_cancel_iocbs()
1539 (piocb->cmd_cmpl) (phba, piocb, piocb); in lpfc_sli_cancel_iocbs()
1549 * lpfc_sli_iocb_cmd_type - Get the iocb type
1652 printk("%s - Unhandled SLI-3 Command x%x\n", in lpfc_sli_iocb_cmd_type()
1665 * lpfc_sli_ring_map - Issue config_ring mbox for all rings
1671 * a config_ring mailbox command for each ring.
1678 struct lpfc_sli *psli = &phba->sli; in lpfc_sli_ring_map()
1683 pmb = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli_ring_map()
1685 return -ENOMEM; in lpfc_sli_ring_map()
1686 pmbox = &pmb->u.mb; in lpfc_sli_ring_map()
1687 phba->link_state = LPFC_INIT_MBX_CMDS; in lpfc_sli_ring_map()
1688 for (i = 0; i < psli->num_rings; i++) { in lpfc_sli_ring_map()
1696 rc, pmbox->mbxCommand, in lpfc_sli_ring_map()
1697 pmbox->mbxStatus, i); in lpfc_sli_ring_map()
1698 phba->link_state = LPFC_HBA_ERROR; in lpfc_sli_ring_map()
1699 ret = -ENXIO; in lpfc_sli_ring_map()
1703 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_sli_ring_map()
1708 * lpfc_sli_ringtxcmpl_put - Adds new iocb to the txcmplq
1729 list_add_tail(&piocb->list, &pring->txcmplq); in lpfc_sli_ringtxcmpl_put()
1730 piocb->cmd_flag |= LPFC_IO_ON_TXCMPLQ; in lpfc_sli_ringtxcmpl_put()
1731 pring->txcmplq_cnt++; in lpfc_sli_ringtxcmpl_put()
1732 if ((unlikely(pring->ringno == LPFC_ELS_RING)) && in lpfc_sli_ringtxcmpl_put()
1736 BUG_ON(!piocb->vport); in lpfc_sli_ringtxcmpl_put()
1737 if (!test_bit(FC_UNLOADING, &piocb->vport->load_flag)) in lpfc_sli_ringtxcmpl_put()
1738 mod_timer(&piocb->vport->els_tmofunc, in lpfc_sli_ringtxcmpl_put()
1740 msecs_to_jiffies(1000 * (phba->fc_ratov << 1))); in lpfc_sli_ringtxcmpl_put()
1747 * lpfc_sli_ringtx_get - Get first element of the txq
1761 lockdep_assert_held(&phba->hbalock); in lpfc_sli_ringtx_get()
1763 list_remove_head((&pring->txq), cmd_iocb, struct lpfc_iocbq, list); in lpfc_sli_ringtx_get()
1768 * lpfc_cmf_sync_cmpl - Process a CMF_SYNC_WQE cmpl
1784 struct lpfc_wcqe_complete *wcqe = &rspiocb->wcqe_cmpl; in lpfc_cmf_sync_cmpl()
1801 wcqe->total_data_placed, in lpfc_cmf_sync_cmpl()
1802 wcqe->parameter); in lpfc_cmf_sync_cmpl()
1807 info = wcqe->parameter; in lpfc_cmf_sync_cmpl()
1808 phba->cmf_active_info = info; in lpfc_cmf_sync_cmpl()
1811 if (info > LPFC_MAX_CMF_INFO || phba->cmf_info_per_interval == info) in lpfc_cmf_sync_cmpl()
1814 phba->cmf_info_per_interval = info; in lpfc_cmf_sync_cmpl()
1829 wqe = &cmdiocb->wqe; in lpfc_cmf_sync_cmpl()
1830 asig = bf_get(cmf_sync_asig, &wqe->cmf_sync); in lpfc_cmf_sync_cmpl()
1831 afpin = bf_get(cmf_sync_afpin, &wqe->cmf_sync); in lpfc_cmf_sync_cmpl()
1832 fpincnt = bf_get(cmf_sync_wfpincnt, &wqe->cmf_sync); in lpfc_cmf_sync_cmpl()
1833 sigcnt = bf_get(cmf_sync_wsigcnt, &wqe->cmf_sync); in lpfc_cmf_sync_cmpl()
1834 if (phba->cmf_max_bytes_per_interval != bw || in lpfc_cmf_sync_cmpl()
1837 if (phba->cmf_max_bytes_per_interval < bw) { in lpfc_cmf_sync_cmpl()
1838 bwdif = bw - phba->cmf_max_bytes_per_interval; in lpfc_cmf_sync_cmpl()
1841 bwdif = phba->cmf_max_bytes_per_interval - bw; in lpfc_cmf_sync_cmpl()
1846 slop = div_u64(phba->cmf_link_byte_count, 200); /*For rounding*/ in lpfc_cmf_sync_cmpl()
1848 phba->cmf_link_byte_count); in lpfc_cmf_sync_cmpl()
1850 phba->cmf_link_byte_count); in lpfc_cmf_sync_cmpl()
1858 if (phba->cmf_max_bytes_per_interval < bw && in lpfc_cmf_sync_cmpl()
1863 else if ((phba->cmf_max_bytes_per_interval > bw) && in lpfc_cmf_sync_cmpl()
1875 phba->cmf_active_info); in lpfc_cmf_sync_cmpl()
1882 phba->cmf_active_info); in lpfc_cmf_sync_cmpl()
1884 wsigmax = bf_get(cmf_sync_wsigmax, &wqe->cmf_sync); in lpfc_cmf_sync_cmpl()
1890 wsigmax, cg, phba->cmf_active_info); in lpfc_cmf_sync_cmpl()
1892 wfpinmax = bf_get(cmf_sync_wfpinmax, &wqe->cmf_sync); in lpfc_cmf_sync_cmpl()
1898 wfpinmax, cg, phba->cmf_active_info); in lpfc_cmf_sync_cmpl()
1904 phba->cmf_active_info); in lpfc_cmf_sync_cmpl()
1912 phba->cmf_last_sync_bw = bw; in lpfc_cmf_sync_cmpl()
1918 * lpfc_issue_cmf_sync_wqe - Issue a CMF_SYNC_WQE
1940 atot = atomic_xchg(&phba->cgn_sync_alarm_cnt, 0); in lpfc_issue_cmf_sync_wqe()
1941 wtot = atomic_xchg(&phba->cgn_sync_warn_cnt, 0); in lpfc_issue_cmf_sync_wqe()
1943 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_issue_cmf_sync_wqe()
1946 if (phba->cmf_active_mode != LPFC_CFG_MANAGED || in lpfc_issue_cmf_sync_wqe()
1947 phba->link_state < LPFC_LINK_UP) { in lpfc_issue_cmf_sync_wqe()
1960 wqe = &sync_buf->wqe; in lpfc_issue_cmf_sync_wqe()
1968 "6441 CMF Init %d - CMF_SYNC_WQE\n", in lpfc_issue_cmf_sync_wqe()
1969 phba->fc_eventTag); in lpfc_issue_cmf_sync_wqe()
1970 bf_set(cmf_sync_op, &wqe->cmf_sync, 1); /* 1=init */ in lpfc_issue_cmf_sync_wqe()
1971 bf_set(cmf_sync_interval, &wqe->cmf_sync, LPFC_CMF_INTERVAL); in lpfc_issue_cmf_sync_wqe()
1975 bf_set(cmf_sync_op, &wqe->cmf_sync, 0); /* 0=recalc */ in lpfc_issue_cmf_sync_wqe()
1976 bf_set(cmf_sync_interval, &wqe->cmf_sync, ms); in lpfc_issue_cmf_sync_wqe()
1980 if (phba->cgn_reg_signal == EDC_CG_SIG_WARN_ALARM) { in lpfc_issue_cmf_sync_wqe()
1982 bf_set(cmf_sync_asig, &wqe->cmf_sync, 1); in lpfc_issue_cmf_sync_wqe()
1985 bf_set(cmf_sync_afpin, &wqe->cmf_sync, 1); in lpfc_issue_cmf_sync_wqe()
1988 if (phba->cgn_reg_signal == EDC_CG_SIG_WARN_ONLY || in lpfc_issue_cmf_sync_wqe()
1989 phba->cgn_reg_signal == EDC_CG_SIG_WARN_ALARM) { in lpfc_issue_cmf_sync_wqe()
1990 cgn_sig_freq = phba->cgn_sig_freq ? phba->cgn_sig_freq : in lpfc_issue_cmf_sync_wqe()
1995 bf_set(cmf_sync_wsigmax, &wqe->cmf_sync, max); in lpfc_issue_cmf_sync_wqe()
1996 bf_set(cmf_sync_wsigcnt, &wqe->cmf_sync, wtot); in lpfc_issue_cmf_sync_wqe()
2000 bf_set(cmf_sync_wfpinmax, &wqe->cmf_sync, 1); in lpfc_issue_cmf_sync_wqe()
2001 bf_set(cmf_sync_wfpincnt, &wqe->cmf_sync, 1); in lpfc_issue_cmf_sync_wqe()
2002 if (phba->cgn_fpin_frequency != LPFC_FPIN_INIT_FREQ) in lpfc_issue_cmf_sync_wqe()
2004 LPFC_MSECS_TO_SECS(phba->cgn_fpin_frequency); in lpfc_issue_cmf_sync_wqe()
2009 wqe->cmf_sync.read_bytes = (u32)(total / LPFC_CMF_BLK_SIZE); in lpfc_issue_cmf_sync_wqe()
2012 bf_set(cmf_sync_ver, &wqe->cmf_sync, LPFC_CMF_SYNC_VER); in lpfc_issue_cmf_sync_wqe()
2013 wqe->cmf_sync.event_tag = phba->fc_eventTag; in lpfc_issue_cmf_sync_wqe()
2014 bf_set(cmf_sync_cmnd, &wqe->cmf_sync, CMD_CMF_SYNC_WQE); in lpfc_issue_cmf_sync_wqe()
2017 bf_set(cmf_sync_reqtag, &wqe->cmf_sync, sync_buf->iotag); in lpfc_issue_cmf_sync_wqe()
2019 bf_set(cmf_sync_qosd, &wqe->cmf_sync, 1); in lpfc_issue_cmf_sync_wqe()
2020 bf_set(cmf_sync_period, &wqe->cmf_sync, warn_sync_period); in lpfc_issue_cmf_sync_wqe()
2022 bf_set(cmf_sync_cmd_type, &wqe->cmf_sync, CMF_SYNC_COMMAND); in lpfc_issue_cmf_sync_wqe()
2023 bf_set(cmf_sync_wqec, &wqe->cmf_sync, 1); in lpfc_issue_cmf_sync_wqe()
2024 bf_set(cmf_sync_cqid, &wqe->cmf_sync, LPFC_WQE_CQ_ID_DEFAULT); in lpfc_issue_cmf_sync_wqe()
2026 sync_buf->vport = phba->pport; in lpfc_issue_cmf_sync_wqe()
2027 sync_buf->cmd_cmpl = lpfc_cmf_sync_cmpl; in lpfc_issue_cmf_sync_wqe()
2028 sync_buf->cmd_dmabuf = NULL; in lpfc_issue_cmf_sync_wqe()
2029 sync_buf->rsp_dmabuf = NULL; in lpfc_issue_cmf_sync_wqe()
2030 sync_buf->bpl_dmabuf = NULL; in lpfc_issue_cmf_sync_wqe()
2031 sync_buf->sli4_xritag = NO_XRI; in lpfc_issue_cmf_sync_wqe()
2033 sync_buf->cmd_flag |= LPFC_IO_CMF; in lpfc_issue_cmf_sync_wqe()
2034 ret_val = lpfc_sli4_issue_wqe(phba, &phba->sli4_hba.hdwq[0], sync_buf); in lpfc_issue_cmf_sync_wqe()
2042 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_issue_cmf_sync_wqe()
2047 * lpfc_sli_next_iocb_slot - Get next iocb slot in the ring
2063 struct lpfc_pgp *pgp = &phba->port_gp[pring->ringno]; in lpfc_sli_next_iocb_slot()
2064 uint32_t max_cmd_idx = pring->sli.sli3.numCiocb; in lpfc_sli_next_iocb_slot()
2066 lockdep_assert_held(&phba->hbalock); in lpfc_sli_next_iocb_slot()
2068 if ((pring->sli.sli3.next_cmdidx == pring->sli.sli3.cmdidx) && in lpfc_sli_next_iocb_slot()
2069 (++pring->sli.sli3.next_cmdidx >= max_cmd_idx)) in lpfc_sli_next_iocb_slot()
2070 pring->sli.sli3.next_cmdidx = 0; in lpfc_sli_next_iocb_slot()
2072 if (unlikely(pring->sli.sli3.local_getidx == in lpfc_sli_next_iocb_slot()
2073 pring->sli.sli3.next_cmdidx)) { in lpfc_sli_next_iocb_slot()
2075 pring->sli.sli3.local_getidx = le32_to_cpu(pgp->cmdGetInx); in lpfc_sli_next_iocb_slot()
2077 if (unlikely(pring->sli.sli3.local_getidx >= max_cmd_idx)) { in lpfc_sli_next_iocb_slot()
2081 pring->ringno, in lpfc_sli_next_iocb_slot()
2082 pring->sli.sli3.local_getidx, in lpfc_sli_next_iocb_slot()
2085 phba->link_state = LPFC_HBA_ERROR; in lpfc_sli_next_iocb_slot()
2090 phba->work_ha |= HA_ERATT; in lpfc_sli_next_iocb_slot()
2091 phba->work_hs = HS_FFER3; in lpfc_sli_next_iocb_slot()
2098 if (pring->sli.sli3.local_getidx == pring->sli.sli3.next_cmdidx) in lpfc_sli_next_iocb_slot()
2106 * lpfc_sli_next_iotag - Get an iotag for the iocb
2123 struct lpfc_sli *psli = &phba->sli; in lpfc_sli_next_iotag()
2126 spin_lock_irq(&phba->hbalock); in lpfc_sli_next_iotag()
2127 iotag = psli->last_iotag; in lpfc_sli_next_iotag()
2128 if(++iotag < psli->iocbq_lookup_len) { in lpfc_sli_next_iotag()
2129 psli->last_iotag = iotag; in lpfc_sli_next_iotag()
2130 psli->iocbq_lookup[iotag] = iocbq; in lpfc_sli_next_iotag()
2131 spin_unlock_irq(&phba->hbalock); in lpfc_sli_next_iotag()
2132 iocbq->iotag = iotag; in lpfc_sli_next_iotag()
2134 } else if (psli->iocbq_lookup_len < (0xffff in lpfc_sli_next_iotag()
2135 - LPFC_IOCBQ_LOOKUP_INCREMENT)) { in lpfc_sli_next_iotag()
2136 new_len = psli->iocbq_lookup_len + LPFC_IOCBQ_LOOKUP_INCREMENT; in lpfc_sli_next_iotag()
2137 spin_unlock_irq(&phba->hbalock); in lpfc_sli_next_iotag()
2141 spin_lock_irq(&phba->hbalock); in lpfc_sli_next_iotag()
2142 old_arr = psli->iocbq_lookup; in lpfc_sli_next_iotag()
2143 if (new_len <= psli->iocbq_lookup_len) { in lpfc_sli_next_iotag()
2146 iotag = psli->last_iotag; in lpfc_sli_next_iotag()
2147 if(++iotag < psli->iocbq_lookup_len) { in lpfc_sli_next_iotag()
2148 psli->last_iotag = iotag; in lpfc_sli_next_iotag()
2149 psli->iocbq_lookup[iotag] = iocbq; in lpfc_sli_next_iotag()
2150 spin_unlock_irq(&phba->hbalock); in lpfc_sli_next_iotag()
2151 iocbq->iotag = iotag; in lpfc_sli_next_iotag()
2154 spin_unlock_irq(&phba->hbalock); in lpfc_sli_next_iotag()
2157 if (psli->iocbq_lookup) in lpfc_sli_next_iotag()
2159 ((psli->last_iotag + 1) * in lpfc_sli_next_iotag()
2161 psli->iocbq_lookup = new_arr; in lpfc_sli_next_iotag()
2162 psli->iocbq_lookup_len = new_len; in lpfc_sli_next_iotag()
2163 psli->last_iotag = iotag; in lpfc_sli_next_iotag()
2164 psli->iocbq_lookup[iotag] = iocbq; in lpfc_sli_next_iotag()
2165 spin_unlock_irq(&phba->hbalock); in lpfc_sli_next_iotag()
2166 iocbq->iotag = iotag; in lpfc_sli_next_iotag()
2171 spin_unlock_irq(&phba->hbalock); in lpfc_sli_next_iotag()
2175 psli->last_iotag); in lpfc_sli_next_iotag()
2181 * lpfc_sli_submit_iocb - Submit an iocb to the firmware
2202 nextiocb->iocb.ulpIoTag = (nextiocb->cmd_cmpl) ? nextiocb->iotag : 0; in lpfc_sli_submit_iocb()
2205 if (pring->ringno == LPFC_ELS_RING) { in lpfc_sli_submit_iocb()
2208 *(((uint32_t *) &nextiocb->iocb) + 4), in lpfc_sli_submit_iocb()
2209 *(((uint32_t *) &nextiocb->iocb) + 6), in lpfc_sli_submit_iocb()
2210 *(((uint32_t *) &nextiocb->iocb) + 7)); in lpfc_sli_submit_iocb()
2216 lpfc_sli_pcimem_bcopy(&nextiocb->iocb, iocb, phba->iocb_cmd_size); in lpfc_sli_submit_iocb()
2218 pring->stats.iocb_cmd++; in lpfc_sli_submit_iocb()
2225 if (nextiocb->cmd_cmpl) in lpfc_sli_submit_iocb()
2234 pring->sli.sli3.cmdidx = pring->sli.sli3.next_cmdidx; in lpfc_sli_submit_iocb()
2235 writel(pring->sli.sli3.cmdidx, &phba->host_gp[pring->ringno].cmdPutInx); in lpfc_sli_submit_iocb()
2239 * lpfc_sli_update_full_ring - Update the chip attention register
2253 int ringno = pring->ringno; in lpfc_sli_update_full_ring()
2255 pring->flag |= LPFC_CALL_RING_AVAILABLE; in lpfc_sli_update_full_ring()
2263 writel((CA_R0ATT|CA_R0CE_REQ) << (ringno*4), phba->CAregaddr); in lpfc_sli_update_full_ring()
2264 readl(phba->CAregaddr); /* flush */ in lpfc_sli_update_full_ring()
2266 pring->stats.iocb_cmd_full++; in lpfc_sli_update_full_ring()
2270 * lpfc_sli_update_ring - Update chip attention register
2281 int ringno = pring->ringno; in lpfc_sli_update_ring()
2286 if (!(phba->sli3_options & LPFC_SLI3_CRP_ENABLED)) { in lpfc_sli_update_ring()
2288 writel(CA_R0ATT << (ringno * 4), phba->CAregaddr); in lpfc_sli_update_ring()
2289 readl(phba->CAregaddr); /* flush */ in lpfc_sli_update_ring()
2294 * lpfc_sli_resume_iocb - Process iocbs in the txq
2308 lockdep_assert_held(&phba->hbalock); in lpfc_sli_resume_iocb()
2319 (!list_empty(&pring->txq)) && in lpfc_sli_resume_iocb()
2320 (pring->ringno != LPFC_FCP_RING || in lpfc_sli_resume_iocb()
2321 phba->sli.sli_flag & LPFC_PROCESS_LA)) { in lpfc_sli_resume_iocb()
2337 * lpfc_sli_next_hbq_slot - Get next hbq entry for the HBQ
2349 struct hbq_s *hbqp = &phba->hbqs[hbqno]; in lpfc_sli_next_hbq_slot()
2351 lockdep_assert_held(&phba->hbalock); in lpfc_sli_next_hbq_slot()
2353 if (hbqp->next_hbqPutIdx == hbqp->hbqPutIdx && in lpfc_sli_next_hbq_slot()
2354 ++hbqp->next_hbqPutIdx >= hbqp->entry_count) in lpfc_sli_next_hbq_slot()
2355 hbqp->next_hbqPutIdx = 0; in lpfc_sli_next_hbq_slot()
2357 if (unlikely(hbqp->local_hbqGetIdx == hbqp->next_hbqPutIdx)) { in lpfc_sli_next_hbq_slot()
2358 uint32_t raw_index = phba->hbq_get[hbqno]; in lpfc_sli_next_hbq_slot()
2361 hbqp->local_hbqGetIdx = getidx; in lpfc_sli_next_hbq_slot()
2363 if (unlikely(hbqp->local_hbqGetIdx >= hbqp->entry_count)) { in lpfc_sli_next_hbq_slot()
2366 "%u is > than hbqp->entry_count %u\n", in lpfc_sli_next_hbq_slot()
2367 hbqno, hbqp->local_hbqGetIdx, in lpfc_sli_next_hbq_slot()
2368 hbqp->entry_count); in lpfc_sli_next_hbq_slot()
2370 phba->link_state = LPFC_HBA_ERROR; in lpfc_sli_next_hbq_slot()
2374 if (hbqp->local_hbqGetIdx == hbqp->next_hbqPutIdx) in lpfc_sli_next_hbq_slot()
2378 return (struct lpfc_hbq_entry *) phba->hbqs[hbqno].hbq_virt + in lpfc_sli_next_hbq_slot()
2379 hbqp->hbqPutIdx; in lpfc_sli_next_hbq_slot()
2383 * lpfc_sli_hbqbuf_free_all - Free all the hbq buffers
2401 spin_lock_irqsave(&phba->hbalock, flags); in lpfc_sli_hbqbuf_free_all()
2404 &phba->hbqs[i].hbq_buffer_list, list) { in lpfc_sli_hbqbuf_free_all()
2406 list_del(&hbq_buf->dbuf.list); in lpfc_sli_hbqbuf_free_all()
2407 (phba->hbqs[i].hbq_free_buffer)(phba, hbq_buf); in lpfc_sli_hbqbuf_free_all()
2409 phba->hbqs[i].buffer_count = 0; in lpfc_sli_hbqbuf_free_all()
2413 phba->hbq_in_use = 0; in lpfc_sli_hbqbuf_free_all()
2414 spin_unlock_irqrestore(&phba->hbalock, flags); in lpfc_sli_hbqbuf_free_all()
2418 * lpfc_sli_hbq_to_firmware - Post the hbq buffer to firmware
2433 lockdep_assert_held(&phba->hbalock); in lpfc_sli_hbq_to_firmware()
2434 return phba->lpfc_sli_hbq_to_firmware(phba, hbqno, hbq_buf); in lpfc_sli_hbq_to_firmware()
2438 * lpfc_sli_hbq_to_firmware_s3 - Post the hbq buffer to SLI3 firmware
2453 dma_addr_t physaddr = hbq_buf->dbuf.phys; in lpfc_sli_hbq_to_firmware_s3()
2455 lockdep_assert_held(&phba->hbalock); in lpfc_sli_hbq_to_firmware_s3()
2459 struct hbq_s *hbqp = &phba->hbqs[hbqno]; in lpfc_sli_hbq_to_firmware_s3()
2461 hbqe->bde.addrHigh = le32_to_cpu(putPaddrHigh(physaddr)); in lpfc_sli_hbq_to_firmware_s3()
2462 hbqe->bde.addrLow = le32_to_cpu(putPaddrLow(physaddr)); in lpfc_sli_hbq_to_firmware_s3()
2463 hbqe->bde.tus.f.bdeSize = hbq_buf->total_size; in lpfc_sli_hbq_to_firmware_s3()
2464 hbqe->bde.tus.f.bdeFlags = 0; in lpfc_sli_hbq_to_firmware_s3()
2465 hbqe->bde.tus.w = le32_to_cpu(hbqe->bde.tus.w); in lpfc_sli_hbq_to_firmware_s3()
2466 hbqe->buffer_tag = le32_to_cpu(hbq_buf->tag); in lpfc_sli_hbq_to_firmware_s3()
2468 hbqp->hbqPutIdx = hbqp->next_hbqPutIdx; in lpfc_sli_hbq_to_firmware_s3()
2469 writel(hbqp->hbqPutIdx, phba->hbq_put + hbqno); in lpfc_sli_hbq_to_firmware_s3()
2471 readl(phba->hbq_put + hbqno); in lpfc_sli_hbq_to_firmware_s3()
2472 list_add_tail(&hbq_buf->dbuf.list, &hbqp->hbq_buffer_list); in lpfc_sli_hbq_to_firmware_s3()
2475 return -ENOMEM; in lpfc_sli_hbq_to_firmware_s3()
2479 * lpfc_sli_hbq_to_firmware_s4 - Post the hbq buffer to SLI4 firmware
2500 hrq = phba->sli4_hba.hdr_rq; in lpfc_sli_hbq_to_firmware_s4()
2501 drq = phba->sli4_hba.dat_rq; in lpfc_sli_hbq_to_firmware_s4()
2503 lockdep_assert_held(&phba->hbalock); in lpfc_sli_hbq_to_firmware_s4()
2504 hrqe.address_lo = putPaddrLow(hbq_buf->hbuf.phys); in lpfc_sli_hbq_to_firmware_s4()
2505 hrqe.address_hi = putPaddrHigh(hbq_buf->hbuf.phys); in lpfc_sli_hbq_to_firmware_s4()
2506 drqe.address_lo = putPaddrLow(hbq_buf->dbuf.phys); in lpfc_sli_hbq_to_firmware_s4()
2507 drqe.address_hi = putPaddrHigh(hbq_buf->dbuf.phys); in lpfc_sli_hbq_to_firmware_s4()
2511 hbq_buf->tag = (rc | (hbqno << 16)); in lpfc_sli_hbq_to_firmware_s4()
2512 list_add_tail(&hbq_buf->dbuf.list, &phba->hbqs[hbqno].hbq_buffer_list); in lpfc_sli_hbq_to_firmware_s4()
2534 * lpfc_sli_hbqbuf_fill_hbqs - Post more hbq buffers to HBQ
2550 if (!phba->hbqs[hbqno].hbq_alloc_buffer) in lpfc_sli_hbqbuf_fill_hbqs()
2553 if ((phba->hbqs[hbqno].buffer_count + count) > in lpfc_sli_hbqbuf_fill_hbqs()
2554 lpfc_hbq_defs[hbqno]->entry_count) in lpfc_sli_hbqbuf_fill_hbqs()
2555 count = lpfc_hbq_defs[hbqno]->entry_count - in lpfc_sli_hbqbuf_fill_hbqs()
2556 phba->hbqs[hbqno].buffer_count; in lpfc_sli_hbqbuf_fill_hbqs()
2561 hbq_buffer = (phba->hbqs[hbqno].hbq_alloc_buffer)(phba); in lpfc_sli_hbqbuf_fill_hbqs()
2564 list_add_tail(&hbq_buffer->dbuf.list, &hbq_buf_list); in lpfc_sli_hbqbuf_fill_hbqs()
2567 spin_lock_irqsave(&phba->hbalock, flags); in lpfc_sli_hbqbuf_fill_hbqs()
2568 if (!phba->hbq_in_use) in lpfc_sli_hbqbuf_fill_hbqs()
2573 hbq_buffer->tag = (phba->hbqs[hbqno].buffer_count | in lpfc_sli_hbqbuf_fill_hbqs()
2576 phba->hbqs[hbqno].buffer_count++; in lpfc_sli_hbqbuf_fill_hbqs()
2579 (phba->hbqs[hbqno].hbq_free_buffer)(phba, hbq_buffer); in lpfc_sli_hbqbuf_fill_hbqs()
2581 spin_unlock_irqrestore(&phba->hbalock, flags); in lpfc_sli_hbqbuf_fill_hbqs()
2584 spin_unlock_irqrestore(&phba->hbalock, flags); in lpfc_sli_hbqbuf_fill_hbqs()
2588 (phba->hbqs[hbqno].hbq_free_buffer)(phba, hbq_buffer); in lpfc_sli_hbqbuf_fill_hbqs()
2594 * lpfc_sli_hbqbuf_add_hbqs - Post more HBQ buffers to firmware
2605 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_sli_hbqbuf_add_hbqs()
2609 lpfc_hbq_defs[qno]->add_count); in lpfc_sli_hbqbuf_add_hbqs()
2613 * lpfc_sli_hbqbuf_init_hbqs - Post initial buffers to the HBQ
2624 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_sli_hbqbuf_init_hbqs()
2626 lpfc_hbq_defs[qno]->entry_count); in lpfc_sli_hbqbuf_init_hbqs()
2629 lpfc_hbq_defs[qno]->init_count); in lpfc_sli_hbqbuf_init_hbqs()
2633 * lpfc_sli_hbqbuf_get - Remove the first hbq off of an hbq list
2650 * lpfc_sli_rqbuf_get - Remove the first dma buffer off of an RQ list
2663 rqbp = hrq->rqbp; in lpfc_sli_rqbuf_get()
2664 list_remove_head(&rqbp->rqb_buffer_list, h_buf, in lpfc_sli_rqbuf_get()
2668 rqbp->buffer_count--; in lpfc_sli_rqbuf_get()
2673 * lpfc_sli_hbqbuf_find - Find the hbq buffer associated with a tag
2692 spin_lock_irq(&phba->hbalock); in lpfc_sli_hbqbuf_find()
2693 list_for_each_entry(d_buf, &phba->hbqs[hbqno].hbq_buffer_list, list) { in lpfc_sli_hbqbuf_find()
2695 if (hbq_buf->tag == tag) { in lpfc_sli_hbqbuf_find()
2696 spin_unlock_irq(&phba->hbalock); in lpfc_sli_hbqbuf_find()
2700 spin_unlock_irq(&phba->hbalock); in lpfc_sli_hbqbuf_find()
2703 tag, phba->hbqs[tag >> 16].buffer_count); in lpfc_sli_hbqbuf_find()
2708 * lpfc_sli_free_hbq - Give back the hbq buffer to firmware
2722 hbqno = hbq_buffer->tag >> 16; in lpfc_sli_free_hbq()
2724 (phba->hbqs[hbqno].hbq_free_buffer)(phba, hbq_buffer); in lpfc_sli_free_hbq()
2729 * lpfc_sli_chk_mbx_command - Check if the mailbox is a legitimate mailbox
2730 * @mbxCommand: mailbox command code.
2732 * This function is called by the mailbox event handler function to verify
2733 * that the completed mailbox command is a legitimate mailbox command. If the
2734 * completed mailbox is not known to the function, it will return MBX_SHUTDOWN
2735 * and the mailbox event handler will take the HBA offline.
2818 * lpfc_sli_wake_mbox_wait - lpfc_sli_issue_mbox_wait mbox completion handler
2820 * @pmboxq: Pointer to mailbox command.
2822 * This is completion handler function for mailbox commands issued from
2824 * mailbox event handler function with no lock held. This function
2826 * of the mailbox.
2838 pmboxq->mbox_flag |= LPFC_MBX_WAKE; in lpfc_sli_wake_mbox_wait()
2839 spin_lock_irqsave(&phba->hbalock, drvr_flag); in lpfc_sli_wake_mbox_wait()
2840 pmbox_done = pmboxq->ctx_u.mbox_wait; in lpfc_sli_wake_mbox_wait()
2843 spin_unlock_irqrestore(&phba->hbalock, drvr_flag); in lpfc_sli_wake_mbox_wait()
2848 * lpfc_sli_def_mbox_cmpl - Default mailbox completion handler
2850 * @pmb: Pointer to mailbox object.
2852 * This function is the default mailbox completion handler. It
2853 * frees the memory resources associated with the completed mailbox
2854 * command. If the completed command is a REG_LOGIN mailbox command,
2855 * this function will issue a UREG_LOGIN to re-claim the RPI.
2860 struct lpfc_vport *vport = pmb->vport; in lpfc_sli_def_mbox_cmpl()
2869 * is in re-discovery driver need to cleanup the RPI. in lpfc_sli_def_mbox_cmpl()
2871 if (!test_bit(FC_UNLOADING, &phba->pport->load_flag) && in lpfc_sli_def_mbox_cmpl()
2872 pmb->u.mb.mbxCommand == MBX_REG_LOGIN64 && in lpfc_sli_def_mbox_cmpl()
2873 !pmb->u.mb.mbxStatus) { in lpfc_sli_def_mbox_cmpl()
2874 mp = pmb->ctx_buf; in lpfc_sli_def_mbox_cmpl()
2876 pmb->ctx_buf = NULL; in lpfc_sli_def_mbox_cmpl()
2877 lpfc_mbuf_free(phba, mp->virt, mp->phys); in lpfc_sli_def_mbox_cmpl()
2880 rpi = pmb->u.mb.un.varWords[0]; in lpfc_sli_def_mbox_cmpl()
2881 vpi = pmb->u.mb.un.varRegLogin.vpi; in lpfc_sli_def_mbox_cmpl()
2882 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_sli_def_mbox_cmpl()
2883 vpi -= phba->sli4_hba.max_cfg_param.vpi_base; in lpfc_sli_def_mbox_cmpl()
2885 pmb->vport = vport; in lpfc_sli_def_mbox_cmpl()
2886 pmb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_sli_def_mbox_cmpl()
2892 if ((pmb->u.mb.mbxCommand == MBX_REG_VPI) && in lpfc_sli_def_mbox_cmpl()
2893 !test_bit(FC_UNLOADING, &phba->pport->load_flag) && in lpfc_sli_def_mbox_cmpl()
2894 !pmb->u.mb.mbxStatus) { in lpfc_sli_def_mbox_cmpl()
2896 spin_lock_irq(shost->host_lock); in lpfc_sli_def_mbox_cmpl()
2897 vport->vpi_state |= LPFC_VPI_REGISTERED; in lpfc_sli_def_mbox_cmpl()
2898 spin_unlock_irq(shost->host_lock); in lpfc_sli_def_mbox_cmpl()
2899 clear_bit(FC_VPORT_NEEDS_REG_VPI, &vport->fc_flag); in lpfc_sli_def_mbox_cmpl()
2902 if (pmb->u.mb.mbxCommand == MBX_REG_LOGIN64) { in lpfc_sli_def_mbox_cmpl()
2903 ndlp = pmb->ctx_ndlp; in lpfc_sli_def_mbox_cmpl()
2907 if (pmb->u.mb.mbxCommand == MBX_UNREG_LOGIN) { in lpfc_sli_def_mbox_cmpl()
2908 ndlp = pmb->ctx_ndlp; in lpfc_sli_def_mbox_cmpl()
2917 ndlp->nlp_rpi, ndlp->nlp_DID, in lpfc_sli_def_mbox_cmpl()
2918 ndlp->nlp_flag, ndlp->nlp_defer_did, in lpfc_sli_def_mbox_cmpl()
2919 ndlp, vport->load_flag, kref_read(&ndlp->kref)); in lpfc_sli_def_mbox_cmpl()
2921 if (test_bit(NLP_UNREG_INP, &ndlp->nlp_flag) && in lpfc_sli_def_mbox_cmpl()
2922 ndlp->nlp_defer_did != NLP_EVT_NOTHING_PENDING) { in lpfc_sli_def_mbox_cmpl()
2923 clear_bit(NLP_UNREG_INP, &ndlp->nlp_flag); in lpfc_sli_def_mbox_cmpl()
2924 ndlp->nlp_defer_did = NLP_EVT_NOTHING_PENDING; in lpfc_sli_def_mbox_cmpl()
2925 lpfc_issue_els_plogi(vport, ndlp->nlp_DID, 0); in lpfc_sli_def_mbox_cmpl()
2927 clear_bit(NLP_UNREG_INP, &ndlp->nlp_flag); in lpfc_sli_def_mbox_cmpl()
2930 /* The unreg_login mailbox is complete and had a in lpfc_sli_def_mbox_cmpl()
2935 pmb->ctx_ndlp = NULL; in lpfc_sli_def_mbox_cmpl()
2940 if (pmb->u.mb.mbxCommand == MBX_RESUME_RPI) { in lpfc_sli_def_mbox_cmpl()
2941 ndlp = pmb->ctx_ndlp; in lpfc_sli_def_mbox_cmpl()
2945 /* Check security permission status on INIT_LINK mailbox command */ in lpfc_sli_def_mbox_cmpl()
2946 if ((pmb->u.mb.mbxCommand == MBX_INIT_LINK) && in lpfc_sli_def_mbox_cmpl()
2947 (pmb->u.mb.mbxStatus == MBXERR_SEC_NO_PERMISSION)) in lpfc_sli_def_mbox_cmpl()
2952 if (bf_get(lpfc_mqe_command, &pmb->u.mqe) == MBX_SLI4_CONFIG) in lpfc_sli_def_mbox_cmpl()
2958 * lpfc_sli4_unreg_rpi_cmpl_clr - mailbox completion handler
2960 * @pmb: Pointer to mailbox object.
2962 * This function is the unreg rpi mailbox completion handler. It
2963 * frees the memory resources associated with the completed mailbox
2966 * the unreg mailbox command completes, this routine puts the
2973 struct lpfc_vport *vport = pmb->vport; in lpfc_sli4_unreg_rpi_cmpl_clr()
2977 ndlp = pmb->ctx_ndlp; in lpfc_sli4_unreg_rpi_cmpl_clr()
2978 if (pmb->u.mb.mbxCommand == MBX_UNREG_LOGIN) { in lpfc_sli4_unreg_rpi_cmpl_clr()
2979 if (phba->sli_rev == LPFC_SLI_REV4 && in lpfc_sli4_unreg_rpi_cmpl_clr()
2981 &phba->sli4_hba.sli_intf) >= in lpfc_sli4_unreg_rpi_cmpl_clr()
2990 vport->vpi, ndlp->nlp_rpi, in lpfc_sli4_unreg_rpi_cmpl_clr()
2991 ndlp->nlp_DID, ndlp->nlp_defer_did, in lpfc_sli4_unreg_rpi_cmpl_clr()
2992 ndlp->nlp_flag, in lpfc_sli4_unreg_rpi_cmpl_clr()
2999 &ndlp->nlp_flag); in lpfc_sli4_unreg_rpi_cmpl_clr()
3000 clear_bit(NLP_LOGO_ACC, &ndlp->nlp_flag); in lpfc_sli4_unreg_rpi_cmpl_clr()
3006 ndlp->nlp_defer_did != in lpfc_sli4_unreg_rpi_cmpl_clr()
3014 ndlp->nlp_rpi, ndlp->nlp_DID, in lpfc_sli4_unreg_rpi_cmpl_clr()
3015 ndlp->nlp_defer_did, ndlp); in lpfc_sli4_unreg_rpi_cmpl_clr()
3016 ndlp->nlp_defer_did = in lpfc_sli4_unreg_rpi_cmpl_clr()
3019 vport, ndlp->nlp_DID, 0); in lpfc_sli4_unreg_rpi_cmpl_clr()
3027 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_sli4_unreg_rpi_cmpl_clr()
3031 * lpfc_sli_handle_mb_event - Handle mailbox completions from firmware
3035 * the completed mailbox commands and gives it to upper layers. The interrupt
3036 * service routine processes mailbox completion interrupt and adds completed
3037 * mailbox commands to the mboxq_cmpl queue and signals the worker thread.
3039 * completed mailbox commands in mboxq_cmpl queue to the upper layers. This
3040 * function returns the mailbox commands to the upper layer by calling the
3041 * completion handler function of each mailbox.
3051 phba->sli.slistat.mbox_event++; in lpfc_sli_handle_mb_event()
3054 spin_lock_irq(&phba->hbalock); in lpfc_sli_handle_mb_event()
3055 list_splice_init(&phba->sli.mboxq_cmpl, &cmplq); in lpfc_sli_handle_mb_event()
3056 spin_unlock_irq(&phba->hbalock); in lpfc_sli_handle_mb_event()
3058 /* Get a Mailbox buffer to setup mailbox commands for callback */ in lpfc_sli_handle_mb_event()
3064 pmbox = &pmb->u.mb; in lpfc_sli_handle_mb_event()
3066 if (pmbox->mbxCommand != MBX_HEARTBEAT) { in lpfc_sli_handle_mb_event()
3067 if (pmb->vport) { in lpfc_sli_handle_mb_event()
3068 lpfc_debugfs_disc_trc(pmb->vport, in lpfc_sli_handle_mb_event()
3071 (uint32_t)pmbox->mbxCommand, in lpfc_sli_handle_mb_event()
3072 pmbox->un.varWords[0], in lpfc_sli_handle_mb_event()
3073 pmbox->un.varWords[1]); in lpfc_sli_handle_mb_event()
3076 lpfc_debugfs_disc_trc(phba->pport, in lpfc_sli_handle_mb_event()
3079 (uint32_t)pmbox->mbxCommand, in lpfc_sli_handle_mb_event()
3080 pmbox->un.varWords[0], in lpfc_sli_handle_mb_event()
3081 pmbox->un.varWords[1]); in lpfc_sli_handle_mb_event()
3088 if (lpfc_sli_chk_mbx_command(pmbox->mbxCommand) == in lpfc_sli_handle_mb_event()
3090 /* Unknown mailbox command compl */ in lpfc_sli_handle_mb_event()
3092 "(%d):0323 Unknown Mailbox command " in lpfc_sli_handle_mb_event()
3094 pmb->vport ? pmb->vport->vpi : in lpfc_sli_handle_mb_event()
3096 pmbox->mbxCommand, in lpfc_sli_handle_mb_event()
3101 phba->link_state = LPFC_HBA_ERROR; in lpfc_sli_handle_mb_event()
3102 phba->work_hs = HS_FFER3; in lpfc_sli_handle_mb_event()
3107 if (pmbox->mbxStatus) { in lpfc_sli_handle_mb_event()
3108 phba->sli.slistat.mbox_stat_err++; in lpfc_sli_handle_mb_event()
3109 if (pmbox->mbxStatus == MBXERR_NO_RESOURCES) { in lpfc_sli_handle_mb_event()
3110 /* Mbox cmd cmpl error - RETRYing */ in lpfc_sli_handle_mb_event()
3114 "error - RETRYing Data: x%x " in lpfc_sli_handle_mb_event()
3116 pmb->vport ? pmb->vport->vpi : in lpfc_sli_handle_mb_event()
3118 pmbox->mbxCommand, in lpfc_sli_handle_mb_event()
3123 pmbox->mbxStatus, in lpfc_sli_handle_mb_event()
3124 pmbox->un.varWords[0], in lpfc_sli_handle_mb_event()
3125 pmb->vport ? pmb->vport->port_state : in lpfc_sli_handle_mb_event()
3127 pmbox->mbxStatus = 0; in lpfc_sli_handle_mb_event()
3128 pmbox->mbxOwner = OWN_HOST; in lpfc_sli_handle_mb_event()
3135 /* Mailbox cmd <cmd> Cmpl <cmpl> */ in lpfc_sli_handle_mb_event()
3137 "(%d):0307 Mailbox cmd x%x (x%x/x%x) Cmpl %ps " in lpfc_sli_handle_mb_event()
3140 pmb->vport ? pmb->vport->vpi : 0, in lpfc_sli_handle_mb_event()
3141 pmbox->mbxCommand, in lpfc_sli_handle_mb_event()
3144 pmb->mbox_cmpl, in lpfc_sli_handle_mb_event()
3146 pmbox->un.varWords[0], in lpfc_sli_handle_mb_event()
3147 pmbox->un.varWords[1], in lpfc_sli_handle_mb_event()
3148 pmbox->un.varWords[2], in lpfc_sli_handle_mb_event()
3149 pmbox->un.varWords[3], in lpfc_sli_handle_mb_event()
3150 pmbox->un.varWords[4], in lpfc_sli_handle_mb_event()
3151 pmbox->un.varWords[5], in lpfc_sli_handle_mb_event()
3152 pmbox->un.varWords[6], in lpfc_sli_handle_mb_event()
3153 pmbox->un.varWords[7], in lpfc_sli_handle_mb_event()
3154 pmbox->un.varWords[8], in lpfc_sli_handle_mb_event()
3155 pmbox->un.varWords[9], in lpfc_sli_handle_mb_event()
3156 pmbox->un.varWords[10]); in lpfc_sli_handle_mb_event()
3158 if (pmb->mbox_cmpl) in lpfc_sli_handle_mb_event()
3159 pmb->mbox_cmpl(phba,pmb); in lpfc_sli_handle_mb_event()
3165 * lpfc_sli_get_buff - Get the buffer associated with the buffer tag
3188 return &hbq_entry->dbuf; in lpfc_sli_get_buff()
3192 * lpfc_nvme_unsol_ls_handler - Process an unsolicited event data buffer
3214 d_buf = piocb->cmd_dmabuf; in lpfc_nvme_unsol_ls_handler()
3217 fc_hdr = nvmebuf->hbuf.virt; in lpfc_nvme_unsol_ls_handler()
3218 oxid = be16_to_cpu(fc_hdr->fh_ox_id); in lpfc_nvme_unsol_ls_handler()
3221 fctl = (fc_hdr->fh_f_ctl[0] << 16 | in lpfc_nvme_unsol_ls_handler()
3222 fc_hdr->fh_f_ctl[1] << 8 | in lpfc_nvme_unsol_ls_handler()
3223 fc_hdr->fh_f_ctl[2]); in lpfc_nvme_unsol_ls_handler()
3224 size = bf_get(lpfc_rcqe_length, &nvmebuf->cq_event.cqe.rcqe_cmpl); in lpfc_nvme_unsol_ls_handler()
3229 if (test_bit(FC_UNLOADING, &phba->pport->load_flag)) { in lpfc_nvme_unsol_ls_handler()
3231 } else if (!(phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME)) { in lpfc_nvme_unsol_ls_handler()
3233 } else if (!phba->nvmet_support && !phba->pport->localport) { in lpfc_nvme_unsol_ls_handler()
3235 } else if (phba->nvmet_support && !phba->targetport) { in lpfc_nvme_unsol_ls_handler()
3237 } else if (unlikely(fc_hdr->fh_r_ctl != FC_RCTL_ELS4_REQ)) { in lpfc_nvme_unsol_ls_handler()
3256 ndlp = lpfc_findnode_did(phba->pport, sid); in lpfc_nvme_unsol_ls_handler()
3258 ((ndlp->nlp_state != NLP_STE_UNMAPPED_NODE) && in lpfc_nvme_unsol_ls_handler()
3259 (ndlp->nlp_state != NLP_STE_MAPPED_NODE))) { in lpfc_nvme_unsol_ls_handler()
3267 axchg->phba = phba; in lpfc_nvme_unsol_ls_handler()
3268 axchg->ndlp = ndlp; in lpfc_nvme_unsol_ls_handler()
3269 axchg->size = size; in lpfc_nvme_unsol_ls_handler()
3270 axchg->oxid = oxid; in lpfc_nvme_unsol_ls_handler()
3271 axchg->sid = sid; in lpfc_nvme_unsol_ls_handler()
3272 axchg->wqeq = NULL; in lpfc_nvme_unsol_ls_handler()
3273 axchg->state = LPFC_NVME_STE_LS_RCV; in lpfc_nvme_unsol_ls_handler()
3274 axchg->entry_cnt = 1; in lpfc_nvme_unsol_ls_handler()
3275 axchg->rqb_buffer = (void *)nvmebuf; in lpfc_nvme_unsol_ls_handler()
3276 axchg->hdwq = &phba->sli4_hba.hdwq[0]; in lpfc_nvme_unsol_ls_handler()
3277 axchg->payload = nvmebuf->dbuf.virt; in lpfc_nvme_unsol_ls_handler()
3278 INIT_LIST_HEAD(&axchg->list); in lpfc_nvme_unsol_ls_handler()
3280 if (phba->nvmet_support) { in lpfc_nvme_unsol_ls_handler()
3282 spin_lock_irq(&ndlp->lock); in lpfc_nvme_unsol_ls_handler()
3283 if (!ret && !(ndlp->fc4_xpt_flags & NLP_XPT_HAS_HH)) { in lpfc_nvme_unsol_ls_handler()
3284 ndlp->fc4_xpt_flags |= NLP_XPT_HAS_HH; in lpfc_nvme_unsol_ls_handler()
3285 spin_unlock_irq(&ndlp->lock); in lpfc_nvme_unsol_ls_handler()
3297 ndlp, ndlp->nlp_DID, in lpfc_nvme_unsol_ls_handler()
3298 ndlp->fc4_xpt_flags, in lpfc_nvme_unsol_ls_handler()
3299 kref_read(&ndlp->kref)); in lpfc_nvme_unsol_ls_handler()
3301 spin_unlock_irq(&ndlp->lock); in lpfc_nvme_unsol_ls_handler()
3307 /* if zero, LS was successfully handled. If non-zero, LS not handled */ in lpfc_nvme_unsol_ls_handler()
3316 (phba->nvmet_support) ? "T" : "I", ret); in lpfc_nvme_unsol_ls_handler()
3319 lpfc_in_buf_free(phba, &nvmebuf->dbuf); in lpfc_nvme_unsol_ls_handler()
3330 * lpfc_complete_unsol_iocb - Complete an unsolicited sequence
3357 if (pring->prt[0].profile) { in lpfc_complete_unsol_iocb()
3358 if (pring->prt[0].lpfc_sli_rcv_unsol_event) in lpfc_complete_unsol_iocb()
3359 (pring->prt[0].lpfc_sli_rcv_unsol_event) (phba, pring, in lpfc_complete_unsol_iocb()
3365 for (i = 0; i < pring->num_mask; i++) { in lpfc_complete_unsol_iocb()
3366 if ((pring->prt[i].rctl == fch_r_ctl) && in lpfc_complete_unsol_iocb()
3367 (pring->prt[i].type == fch_type)) { in lpfc_complete_unsol_iocb()
3368 if (pring->prt[i].lpfc_sli_rcv_unsol_event) in lpfc_complete_unsol_iocb()
3369 (pring->prt[i].lpfc_sli_rcv_unsol_event) in lpfc_complete_unsol_iocb()
3385 irsp = &saveq->iocb; in lpfc_sli_prep_unsol_wqe()
3386 wqe = &saveq->wqe; in lpfc_sli_prep_unsol_wqe()
3389 bf_set(lpfc_wcqe_c_status, &saveq->wcqe_cmpl, irsp->ulpStatus); in lpfc_sli_prep_unsol_wqe()
3390 saveq->wcqe_cmpl.word3 = irsp->ulpBdeCount; in lpfc_sli_prep_unsol_wqe()
3391 saveq->wcqe_cmpl.parameter = irsp->un.ulpWord[4]; in lpfc_sli_prep_unsol_wqe()
3392 saveq->wcqe_cmpl.total_data_placed = irsp->unsli3.rcvsli3.acc_len; in lpfc_sli_prep_unsol_wqe()
3395 bf_set(els_rsp64_sid, &wqe->xmit_els_rsp, irsp->un.rcvels.parmRo); in lpfc_sli_prep_unsol_wqe()
3397 /* rx-id of the response frame */ in lpfc_sli_prep_unsol_wqe()
3398 bf_set(wqe_ctxt_tag, &wqe->xmit_els_rsp.wqe_com, irsp->ulpContext); in lpfc_sli_prep_unsol_wqe()
3400 /* ox-id of the frame */ in lpfc_sli_prep_unsol_wqe()
3401 bf_set(wqe_rcvoxid, &wqe->xmit_els_rsp.wqe_com, in lpfc_sli_prep_unsol_wqe()
3402 irsp->unsli3.rcvsli3.ox_id); in lpfc_sli_prep_unsol_wqe()
3405 bf_set(wqe_els_did, &wqe->xmit_els_rsp.wqe_dest, in lpfc_sli_prep_unsol_wqe()
3406 irsp->un.rcvels.remoteID); in lpfc_sli_prep_unsol_wqe()
3409 for (i = 0; i < irsp->ulpBdeCount; i++) { in lpfc_sli_prep_unsol_wqe()
3412 if (phba->sli3_options & LPFC_SLI3_HBQ_ENABLED) { in lpfc_sli_prep_unsol_wqe()
3415 &irsp->un.ulpWord[0]; in lpfc_sli_prep_unsol_wqe()
3416 saveq->wqe.gen_req.bde.tus.f.bdeSize = in lpfc_sli_prep_unsol_wqe()
3417 hbqe->bde.tus.f.bdeSize; in lpfc_sli_prep_unsol_wqe()
3420 &irsp->unsli3.sli3Words[4]; in lpfc_sli_prep_unsol_wqe()
3421 saveq->unsol_rcv_len = hbqe->bde.tus.f.bdeSize; in lpfc_sli_prep_unsol_wqe()
3428 * lpfc_sli_process_unsol_iocb - Unsolicited iocb handler
3452 irsp = &saveq->iocb; in lpfc_sli_process_unsol_iocb()
3453 saveq->vport = phba->pport; in lpfc_sli_process_unsol_iocb()
3455 if (irsp->ulpCommand == CMD_ASYNC_STATUS) { in lpfc_sli_process_unsol_iocb()
3456 if (pring->lpfc_sli_rcv_async_status) in lpfc_sli_process_unsol_iocb()
3457 pring->lpfc_sli_rcv_async_status(phba, pring, saveq); in lpfc_sli_process_unsol_iocb()
3465 pring->ringno, in lpfc_sli_process_unsol_iocb()
3466 irsp->un.asyncstat.evt_code); in lpfc_sli_process_unsol_iocb()
3470 if ((irsp->ulpCommand == CMD_IOCB_RET_XRI64_CX) && in lpfc_sli_process_unsol_iocb()
3471 (phba->sli3_options & LPFC_SLI3_HBQ_ENABLED)) { in lpfc_sli_process_unsol_iocb()
3472 if (irsp->ulpBdeCount > 0) { in lpfc_sli_process_unsol_iocb()
3474 irsp->un.ulpWord[3]); in lpfc_sli_process_unsol_iocb()
3478 if (irsp->ulpBdeCount > 1) { in lpfc_sli_process_unsol_iocb()
3480 irsp->unsli3.sli3Words[3]); in lpfc_sli_process_unsol_iocb()
3484 if (irsp->ulpBdeCount > 2) { in lpfc_sli_process_unsol_iocb()
3486 irsp->unsli3.sli3Words[7]); in lpfc_sli_process_unsol_iocb()
3493 if (phba->sli3_options & LPFC_SLI3_HBQ_ENABLED) { in lpfc_sli_process_unsol_iocb()
3494 if (irsp->ulpBdeCount != 0) { in lpfc_sli_process_unsol_iocb()
3495 saveq->cmd_dmabuf = lpfc_sli_get_buff(phba, pring, in lpfc_sli_process_unsol_iocb()
3496 irsp->un.ulpWord[3]); in lpfc_sli_process_unsol_iocb()
3497 if (!saveq->cmd_dmabuf) in lpfc_sli_process_unsol_iocb()
3503 pring->ringno, in lpfc_sli_process_unsol_iocb()
3504 irsp->un.ulpWord[3]); in lpfc_sli_process_unsol_iocb()
3506 if (irsp->ulpBdeCount == 2) { in lpfc_sli_process_unsol_iocb()
3507 saveq->bpl_dmabuf = lpfc_sli_get_buff(phba, pring, in lpfc_sli_process_unsol_iocb()
3508 irsp->unsli3.sli3Words[7]); in lpfc_sli_process_unsol_iocb()
3509 if (!saveq->bpl_dmabuf) in lpfc_sli_process_unsol_iocb()
3515 pring->ringno, in lpfc_sli_process_unsol_iocb()
3516 irsp->unsli3.sli3Words[7]); in lpfc_sli_process_unsol_iocb()
3518 list_for_each_entry(iocbq, &saveq->list, list) { in lpfc_sli_process_unsol_iocb()
3519 irsp = &iocbq->iocb; in lpfc_sli_process_unsol_iocb()
3520 if (irsp->ulpBdeCount != 0) { in lpfc_sli_process_unsol_iocb()
3521 iocbq->cmd_dmabuf = lpfc_sli_get_buff(phba, in lpfc_sli_process_unsol_iocb()
3523 irsp->un.ulpWord[3]); in lpfc_sli_process_unsol_iocb()
3524 if (!iocbq->cmd_dmabuf) in lpfc_sli_process_unsol_iocb()
3530 ". tag 0x%x\n", pring->ringno, in lpfc_sli_process_unsol_iocb()
3531 irsp->un.ulpWord[3]); in lpfc_sli_process_unsol_iocb()
3533 if (irsp->ulpBdeCount == 2) { in lpfc_sli_process_unsol_iocb()
3534 iocbq->bpl_dmabuf = lpfc_sli_get_buff(phba, in lpfc_sli_process_unsol_iocb()
3536 irsp->unsli3.sli3Words[7]); in lpfc_sli_process_unsol_iocb()
3537 if (!iocbq->bpl_dmabuf) in lpfc_sli_process_unsol_iocb()
3544 pring->ringno, in lpfc_sli_process_unsol_iocb()
3545 irsp->unsli3.sli3Words[7]); in lpfc_sli_process_unsol_iocb()
3549 paddr = getPaddr(irsp->un.cont64[0].addrHigh, in lpfc_sli_process_unsol_iocb()
3550 irsp->un.cont64[0].addrLow); in lpfc_sli_process_unsol_iocb()
3551 saveq->cmd_dmabuf = lpfc_sli_ringpostbuf_get(phba, pring, in lpfc_sli_process_unsol_iocb()
3553 if (irsp->ulpBdeCount == 2) { in lpfc_sli_process_unsol_iocb()
3554 paddr = getPaddr(irsp->un.cont64[1].addrHigh, in lpfc_sli_process_unsol_iocb()
3555 irsp->un.cont64[1].addrLow); in lpfc_sli_process_unsol_iocb()
3556 saveq->bpl_dmabuf = lpfc_sli_ringpostbuf_get(phba, in lpfc_sli_process_unsol_iocb()
3562 if (irsp->ulpBdeCount != 0 && in lpfc_sli_process_unsol_iocb()
3563 (irsp->ulpCommand == CMD_IOCB_RCV_CONT64_CX || in lpfc_sli_process_unsol_iocb()
3564 irsp->ulpStatus == IOSTAT_INTERMED_RSP)) { in lpfc_sli_process_unsol_iocb()
3568 list_for_each_entry(iocbq, &pring->iocb_continue_saveq, clist) { in lpfc_sli_process_unsol_iocb()
3569 if (iocbq->iocb.unsli3.rcvsli3.ox_id == in lpfc_sli_process_unsol_iocb()
3570 saveq->iocb.unsli3.rcvsli3.ox_id) { in lpfc_sli_process_unsol_iocb()
3571 list_add_tail(&saveq->list, &iocbq->list); in lpfc_sli_process_unsol_iocb()
3577 list_add_tail(&saveq->clist, in lpfc_sli_process_unsol_iocb()
3578 &pring->iocb_continue_saveq); in lpfc_sli_process_unsol_iocb()
3580 if (saveq->iocb.ulpStatus != IOSTAT_INTERMED_RSP) { in lpfc_sli_process_unsol_iocb()
3581 list_del_init(&iocbq->clist); in lpfc_sli_process_unsol_iocb()
3583 irsp = &saveq->iocb; in lpfc_sli_process_unsol_iocb()
3588 if ((irsp->ulpCommand == CMD_RCV_ELS_REQ64_CX) || in lpfc_sli_process_unsol_iocb()
3589 (irsp->ulpCommand == CMD_RCV_ELS_REQ_CX) || in lpfc_sli_process_unsol_iocb()
3590 (irsp->ulpCommand == CMD_IOCB_RCV_ELS64_CX)) { in lpfc_sli_process_unsol_iocb()
3594 w5p = (WORD5 *)&(saveq->iocb.un.ulpWord[5]); in lpfc_sli_process_unsol_iocb()
3595 Rctl = w5p->hcsw.Rctl; in lpfc_sli_process_unsol_iocb()
3596 Type = w5p->hcsw.Type; in lpfc_sli_process_unsol_iocb()
3599 if ((Rctl == 0) && (pring->ringno == LPFC_ELS_RING) && in lpfc_sli_process_unsol_iocb()
3600 (irsp->ulpCommand == CMD_RCV_SEQUENCE64_CX || in lpfc_sli_process_unsol_iocb()
3601 irsp->ulpCommand == CMD_IOCB_RCV_SEQ64_CX)) { in lpfc_sli_process_unsol_iocb()
3604 w5p->hcsw.Rctl = Rctl; in lpfc_sli_process_unsol_iocb()
3605 w5p->hcsw.Type = Type; in lpfc_sli_process_unsol_iocb()
3609 if ((phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) && in lpfc_sli_process_unsol_iocb()
3610 (irsp->ulpCommand == CMD_IOCB_RCV_ELS64_CX || in lpfc_sli_process_unsol_iocb()
3611 irsp->ulpCommand == CMD_IOCB_RCV_SEQ64_CX)) { in lpfc_sli_process_unsol_iocb()
3612 if (irsp->unsli3.rcvsli3.vpi == 0xffff) in lpfc_sli_process_unsol_iocb()
3613 saveq->vport = phba->pport; in lpfc_sli_process_unsol_iocb()
3615 saveq->vport = lpfc_find_vport_by_vpid(phba, in lpfc_sli_process_unsol_iocb()
3616 irsp->unsli3.rcvsli3.vpi); in lpfc_sli_process_unsol_iocb()
3626 pring->ringno, Rctl, Type); in lpfc_sli_process_unsol_iocb()
3632 * lpfc_sli_iocbq_lookup - Find command iocb for the given response iocb
3652 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_sli_iocbq_lookup()
3655 iotag = prspiocb->iocb.ulpIoTag; in lpfc_sli_iocbq_lookup()
3657 if (iotag != 0 && iotag <= phba->sli.last_iotag) { in lpfc_sli_iocbq_lookup()
3658 cmd_iocb = phba->sli.iocbq_lookup[iotag]; in lpfc_sli_iocbq_lookup()
3659 if (cmd_iocb->cmd_flag & LPFC_IO_ON_TXCMPLQ) { in lpfc_sli_iocbq_lookup()
3661 list_del_init(&cmd_iocb->list); in lpfc_sli_iocbq_lookup()
3662 cmd_iocb->cmd_flag &= ~LPFC_IO_ON_TXCMPLQ; in lpfc_sli_iocbq_lookup()
3663 pring->txcmplq_cnt--; in lpfc_sli_iocbq_lookup()
3671 iotag, phba->sli.last_iotag); in lpfc_sli_iocbq_lookup()
3676 * lpfc_sli_iocbq_lookup_by_tag - Find command iocb for the iotag
3693 if (iotag != 0 && iotag <= phba->sli.last_iotag) { in lpfc_sli_iocbq_lookup_by_tag()
3694 cmd_iocb = phba->sli.iocbq_lookup[iotag]; in lpfc_sli_iocbq_lookup_by_tag()
3695 if (cmd_iocb->cmd_flag & LPFC_IO_ON_TXCMPLQ) { in lpfc_sli_iocbq_lookup_by_tag()
3697 list_del_init(&cmd_iocb->list); in lpfc_sli_iocbq_lookup_by_tag()
3698 cmd_iocb->cmd_flag &= ~LPFC_IO_ON_TXCMPLQ; in lpfc_sli_iocbq_lookup_by_tag()
3699 pring->txcmplq_cnt--; in lpfc_sli_iocbq_lookup_by_tag()
3707 iotag, phba->sli.last_iotag, in lpfc_sli_iocbq_lookup_by_tag()
3708 cmd_iocb ? cmd_iocb->cmd_flag : 0xffff); in lpfc_sli_iocbq_lookup_by_tag()
3713 * lpfc_sli_process_sol_iocb - process solicited iocb completion
3718 * This function is called by the ring event handler for non-fcp
3737 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_sli_process_sol_iocb()
3738 spin_lock_irqsave(&pring->ring_lock, iflag); in lpfc_sli_process_sol_iocb()
3740 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_process_sol_iocb()
3742 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_sli_process_sol_iocb()
3743 spin_unlock_irqrestore(&pring->ring_lock, iflag); in lpfc_sli_process_sol_iocb()
3745 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_process_sol_iocb()
3751 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_sli_process_sol_iocb()
3754 iotag = saveq->iocb.ulpIoTag; in lpfc_sli_process_sol_iocb()
3758 if (cmdiocbp->cmd_cmpl) { in lpfc_sli_process_sol_iocb()
3764 (pring->ringno == LPFC_ELS_RING) && in lpfc_sli_process_sol_iocb()
3773 if (pring->ringno == LPFC_ELS_RING) { in lpfc_sli_process_sol_iocb()
3774 if ((phba->sli_rev < LPFC_SLI_REV4) && in lpfc_sli_process_sol_iocb()
3775 (cmdiocbp->cmd_flag & in lpfc_sli_process_sol_iocb()
3777 spin_lock_irqsave(&phba->hbalock, in lpfc_sli_process_sol_iocb()
3779 cmdiocbp->cmd_flag &= in lpfc_sli_process_sol_iocb()
3781 spin_unlock_irqrestore(&phba->hbalock, in lpfc_sli_process_sol_iocb()
3783 saveq->iocb.ulpStatus = in lpfc_sli_process_sol_iocb()
3785 saveq->iocb.un.ulpWord[4] = in lpfc_sli_process_sol_iocb()
3792 spin_lock_irqsave(&phba->hbalock, in lpfc_sli_process_sol_iocb()
3794 saveq->cmd_flag |= LPFC_DELAY_MEM_FREE; in lpfc_sli_process_sol_iocb()
3795 spin_unlock_irqrestore(&phba->hbalock, in lpfc_sli_process_sol_iocb()
3798 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_sli_process_sol_iocb()
3799 if (saveq->cmd_flag & in lpfc_sli_process_sol_iocb()
3808 &phba->hbalock, iflag); in lpfc_sli_process_sol_iocb()
3809 cmdiocbp->cmd_flag |= in lpfc_sli_process_sol_iocb()
3812 &phba->hbalock, iflag); in lpfc_sli_process_sol_iocb()
3814 if (cmdiocbp->cmd_flag & in lpfc_sli_process_sol_iocb()
3822 &phba->hbalock, iflag); in lpfc_sli_process_sol_iocb()
3823 cmdiocbp->cmd_flag &= in lpfc_sli_process_sol_iocb()
3826 &phba->hbalock, iflag); in lpfc_sli_process_sol_iocb()
3842 &phba->hbalock, iflag); in lpfc_sli_process_sol_iocb()
3843 saveq->cmd_flag |= in lpfc_sli_process_sol_iocb()
3846 &phba->hbalock, iflag); in lpfc_sli_process_sol_iocb()
3850 cmdiocbp->cmd_cmpl(phba, cmdiocbp, saveq); in lpfc_sli_process_sol_iocb()
3859 if (pring->ringno != LPFC_ELS_RING) { in lpfc_sli_process_sol_iocb()
3868 pring->ringno, iotag, ulp_status, in lpfc_sli_process_sol_iocb()
3877 * lpfc_sli_rsp_pointers_error - Response ring pointer error handler
3889 struct lpfc_pgp *pgp = &phba->port_gp[pring->ringno]; in lpfc_sli_rsp_pointers_error()
3897 pring->ringno, le32_to_cpu(pgp->rspPutInx), in lpfc_sli_rsp_pointers_error()
3898 pring->sli.sli3.numRiocb); in lpfc_sli_rsp_pointers_error()
3900 phba->link_state = LPFC_HBA_ERROR; in lpfc_sli_rsp_pointers_error()
3906 phba->work_ha |= HA_ERATT; in lpfc_sli_rsp_pointers_error()
3907 phba->work_hs = HS_FFER3; in lpfc_sli_rsp_pointers_error()
3915 * lpfc_poll_eratt - Error attention polling timer timeout handler
3931 if (!test_bit(HBA_SETUP, &phba->hba_flag)) in lpfc_poll_eratt()
3934 if (test_bit(FC_UNLOADING, &phba->pport->load_flag)) in lpfc_poll_eratt()
3938 sli_intr = phba->sli.slistat.sli_intr; in lpfc_poll_eratt()
3940 if (phba->sli.slistat.sli_prev_intr > sli_intr) in lpfc_poll_eratt()
3941 cnt = (((uint64_t)(-1) - phba->sli.slistat.sli_prev_intr) + in lpfc_poll_eratt()
3944 cnt = (sli_intr - phba->sli.slistat.sli_prev_intr); in lpfc_poll_eratt()
3946 /* 64-bit integer division not supported on 32-bit x86 - use do_div */ in lpfc_poll_eratt()
3947 do_div(cnt, phba->eratt_poll_interval); in lpfc_poll_eratt()
3948 phba->sli.slistat.sli_ips = cnt; in lpfc_poll_eratt()
3950 phba->sli.slistat.sli_prev_intr = sli_intr; in lpfc_poll_eratt()
3960 mod_timer(&phba->eratt_poll, in lpfc_poll_eratt()
3962 msecs_to_jiffies(1000 * phba->eratt_poll_interval)); in lpfc_poll_eratt()
3968 * lpfc_sli_handle_fast_ring_event - Handle ring events on FCP ring
3988 struct lpfc_pgp *pgp = &phba->port_gp[pring->ringno]; in lpfc_sli_handle_fast_ring_event()
4000 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_handle_fast_ring_event()
4001 pring->stats.iocb_event++; in lpfc_sli_handle_fast_ring_event()
4007 portRspMax = pring->sli.sli3.numRiocb; in lpfc_sli_handle_fast_ring_event()
4008 portRspPut = le32_to_cpu(pgp->rspPutInx); in lpfc_sli_handle_fast_ring_event()
4011 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_handle_fast_ring_event()
4014 if (phba->fcp_ring_in_use) { in lpfc_sli_handle_fast_ring_event()
4015 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_handle_fast_ring_event()
4018 phba->fcp_ring_in_use = 1; in lpfc_sli_handle_fast_ring_event()
4021 while (pring->sli.sli3.rspidx != portRspPut) { in lpfc_sli_handle_fast_ring_event()
4024 * structure. The copy involves a byte-swap since the in lpfc_sli_handle_fast_ring_event()
4028 phba->last_completion_time = jiffies; in lpfc_sli_handle_fast_ring_event()
4030 if (++pring->sli.sli3.rspidx >= portRspMax) in lpfc_sli_handle_fast_ring_event()
4031 pring->sli.sli3.rspidx = 0; in lpfc_sli_handle_fast_ring_event()
4035 phba->iocb_rsp_size); in lpfc_sli_handle_fast_ring_event()
4039 type = lpfc_sli_iocb_cmd_type(irsp->ulpCommand & CMD_IOCB_MASK); in lpfc_sli_handle_fast_ring_event()
4040 pring->stats.iocb_rsp++; in lpfc_sli_handle_fast_ring_event()
4043 if (unlikely(irsp->ulpStatus)) { in lpfc_sli_handle_fast_ring_event()
4048 if ((irsp->ulpStatus == IOSTAT_LOCAL_REJECT) && in lpfc_sli_handle_fast_ring_event()
4049 ((irsp->un.ulpWord[4] & IOERR_PARAM_MASK) == in lpfc_sli_handle_fast_ring_event()
4051 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_handle_fast_ring_event()
4052 phba->lpfc_rampdown_queue_depth(phba); in lpfc_sli_handle_fast_ring_event()
4053 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_handle_fast_ring_event()
4060 pring->ringno, in lpfc_sli_handle_fast_ring_event()
4061 irsp->un.ulpWord[0], in lpfc_sli_handle_fast_ring_event()
4062 irsp->un.ulpWord[1], in lpfc_sli_handle_fast_ring_event()
4063 irsp->un.ulpWord[2], in lpfc_sli_handle_fast_ring_event()
4064 irsp->un.ulpWord[3], in lpfc_sli_handle_fast_ring_event()
4065 irsp->un.ulpWord[4], in lpfc_sli_handle_fast_ring_event()
4066 irsp->un.ulpWord[5], in lpfc_sli_handle_fast_ring_event()
4067 *(uint32_t *)&irsp->un1, in lpfc_sli_handle_fast_ring_event()
4068 *((uint32_t *)&irsp->un1 + 1)); in lpfc_sli_handle_fast_ring_event()
4078 if (unlikely(irsp->ulpCommand == CMD_XRI_ABORTED_CX)) { in lpfc_sli_handle_fast_ring_event()
4083 irsp->ulpCommand); in lpfc_sli_handle_fast_ring_event()
4091 if (cmdiocbq->cmd_flag & LPFC_DRIVER_ABORTED) in lpfc_sli_handle_fast_ring_event()
4092 cmdiocbq->cmd_flag &= ~LPFC_DRIVER_ABORTED; in lpfc_sli_handle_fast_ring_event()
4093 if (cmdiocbq->cmd_cmpl) { in lpfc_sli_handle_fast_ring_event()
4094 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_handle_fast_ring_event()
4095 cmdiocbq->cmd_cmpl(phba, cmdiocbq, &rspiocbq); in lpfc_sli_handle_fast_ring_event()
4096 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_handle_fast_ring_event()
4100 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_handle_fast_ring_event()
4102 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_handle_fast_ring_event()
4105 if (irsp->ulpCommand == CMD_ADAPTER_MSG) { in lpfc_sli_handle_fast_ring_event()
4110 dev_warn(&((phba->pcidev)->dev), in lpfc_sli_handle_fast_ring_event()
4112 phba->brd_no, adaptermsg); in lpfc_sli_handle_fast_ring_event()
4118 type, irsp->ulpCommand, in lpfc_sli_handle_fast_ring_event()
4119 irsp->ulpStatus, in lpfc_sli_handle_fast_ring_event()
4120 irsp->ulpIoTag, in lpfc_sli_handle_fast_ring_event()
4121 irsp->ulpContext); in lpfc_sli_handle_fast_ring_event()
4129 * been updated, sync the pgp->rspPutInx and fetch the new port in lpfc_sli_handle_fast_ring_event()
4132 writel(pring->sli.sli3.rspidx, in lpfc_sli_handle_fast_ring_event()
4133 &phba->host_gp[pring->ringno].rspGetInx); in lpfc_sli_handle_fast_ring_event()
4135 if (pring->sli.sli3.rspidx == portRspPut) in lpfc_sli_handle_fast_ring_event()
4136 portRspPut = le32_to_cpu(pgp->rspPutInx); in lpfc_sli_handle_fast_ring_event()
4140 pring->stats.iocb_rsp_full++; in lpfc_sli_handle_fast_ring_event()
4141 status = ((CA_R0ATT | CA_R0RE_RSP) << (pring->ringno * 4)); in lpfc_sli_handle_fast_ring_event()
4142 writel(status, phba->CAregaddr); in lpfc_sli_handle_fast_ring_event()
4143 readl(phba->CAregaddr); in lpfc_sli_handle_fast_ring_event()
4145 if ((mask & HA_R0CE_RSP) && (pring->flag & LPFC_CALL_RING_AVAILABLE)) { in lpfc_sli_handle_fast_ring_event()
4146 pring->flag &= ~LPFC_CALL_RING_AVAILABLE; in lpfc_sli_handle_fast_ring_event()
4147 pring->stats.iocb_cmd_empty++; in lpfc_sli_handle_fast_ring_event()
4150 pring->sli.sli3.local_getidx = le32_to_cpu(pgp->cmdGetInx); in lpfc_sli_handle_fast_ring_event()
4153 if ((pring->lpfc_sli_cmd_available)) in lpfc_sli_handle_fast_ring_event()
4154 (pring->lpfc_sli_cmd_available) (phba, pring); in lpfc_sli_handle_fast_ring_event()
4158 phba->fcp_ring_in_use = 0; in lpfc_sli_handle_fast_ring_event()
4159 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_handle_fast_ring_event()
4164 * lpfc_sli_sp_handle_rspiocb - Handle slow-path response iocb
4169 * This function is called from the worker thread when there is a slow-path
4198 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_sp_handle_rspiocb()
4200 list_add_tail(&rspiocbp->list, &pring->iocb_continueq); in lpfc_sli_sp_handle_rspiocb()
4201 pring->iocb_continueq_cnt++; in lpfc_sli_sp_handle_rspiocb()
4208 saveq = list_get_first(&pring->iocb_continueq, in lpfc_sli_sp_handle_rspiocb()
4210 list_del_init(&pring->iocb_continueq); in lpfc_sli_sp_handle_rspiocb()
4211 pring->iocb_continueq_cnt = 0; in lpfc_sli_sp_handle_rspiocb()
4213 pring->stats.iocb_rsp++; in lpfc_sli_sp_handle_rspiocb()
4222 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_sp_handle_rspiocb()
4223 phba->lpfc_rampdown_queue_depth(phba); in lpfc_sli_sp_handle_rspiocb()
4224 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_sp_handle_rspiocb()
4229 if (phba->sli_rev < LPFC_SLI_REV4) { in lpfc_sli_sp_handle_rspiocb()
4230 irsp = &rspiocbp->iocb; in lpfc_sli_sp_handle_rspiocb()
4238 pring->ringno, ulp_status, in lpfc_sli_sp_handle_rspiocb()
4260 pring->ringno, in lpfc_sli_sp_handle_rspiocb()
4261 rspiocbp->wcqe_cmpl.word0, in lpfc_sli_sp_handle_rspiocb()
4262 rspiocbp->wcqe_cmpl.total_data_placed, in lpfc_sli_sp_handle_rspiocb()
4263 rspiocbp->wcqe_cmpl.parameter, in lpfc_sli_sp_handle_rspiocb()
4264 rspiocbp->wcqe_cmpl.word3); in lpfc_sli_sp_handle_rspiocb()
4279 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_sp_handle_rspiocb()
4281 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_sp_handle_rspiocb()
4284 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_sp_handle_rspiocb()
4286 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_sp_handle_rspiocb()
4297 if (cmdiocb->cmd_cmpl) { in lpfc_sli_sp_handle_rspiocb()
4298 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_sp_handle_rspiocb()
4299 cmdiocb->cmd_cmpl(phba, cmdiocb, saveq); in lpfc_sli_sp_handle_rspiocb()
4300 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_sp_handle_rspiocb()
4311 memcpy(&adaptermsg[0], (uint8_t *)&rspiocbp->wqe, in lpfc_sli_sp_handle_rspiocb()
4313 dev_warn(&((phba->pcidev)->dev), in lpfc_sli_sp_handle_rspiocb()
4315 phba->brd_no, adaptermsg); in lpfc_sli_sp_handle_rspiocb()
4332 &saveq->list, list) { in lpfc_sli_sp_handle_rspiocb()
4333 list_del_init(&rspiocbp->list); in lpfc_sli_sp_handle_rspiocb()
4339 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_sp_handle_rspiocb()
4344 * lpfc_sli_handle_slow_ring_event - Wrapper func for handling slow-path iocbs
4356 phba->lpfc_sli_handle_slow_ring_event(phba, pring, mask); in lpfc_sli_handle_slow_ring_event()
4360 * lpfc_sli_handle_slow_ring_event_s3 - Handle SLI3 ring event for non-FCP rings
4366 * for non-fcp rings. The caller does not hold any lock. The function will
4382 pgp = &phba->port_gp[pring->ringno]; in lpfc_sli_handle_slow_ring_event_s3()
4383 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_handle_slow_ring_event_s3()
4384 pring->stats.iocb_event++; in lpfc_sli_handle_slow_ring_event_s3()
4390 portRspMax = pring->sli.sli3.numRiocb; in lpfc_sli_handle_slow_ring_event_s3()
4391 portRspPut = le32_to_cpu(pgp->rspPutInx); in lpfc_sli_handle_slow_ring_event_s3()
4400 pring->ringno, portRspPut, portRspMax); in lpfc_sli_handle_slow_ring_event_s3()
4402 phba->link_state = LPFC_HBA_ERROR; in lpfc_sli_handle_slow_ring_event_s3()
4403 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_handle_slow_ring_event_s3()
4405 phba->work_hs = HS_FFER3; in lpfc_sli_handle_slow_ring_event_s3()
4412 while (pring->sli.sli3.rspidx != portRspPut) { in lpfc_sli_handle_slow_ring_event_s3()
4428 phba->last_completion_time = jiffies; in lpfc_sli_handle_slow_ring_event_s3()
4436 lpfc_sli_pcimem_bcopy(entry, &rspiocbp->iocb, in lpfc_sli_handle_slow_ring_event_s3()
4437 phba->iocb_rsp_size); in lpfc_sli_handle_slow_ring_event_s3()
4438 irsp = &rspiocbp->iocb; in lpfc_sli_handle_slow_ring_event_s3()
4440 if (++pring->sli.sli3.rspidx >= portRspMax) in lpfc_sli_handle_slow_ring_event_s3()
4441 pring->sli.sli3.rspidx = 0; in lpfc_sli_handle_slow_ring_event_s3()
4443 if (pring->ringno == LPFC_ELS_RING) { in lpfc_sli_handle_slow_ring_event_s3()
4451 writel(pring->sli.sli3.rspidx, in lpfc_sli_handle_slow_ring_event_s3()
4452 &phba->host_gp[pring->ringno].rspGetInx); in lpfc_sli_handle_slow_ring_event_s3()
4454 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_handle_slow_ring_event_s3()
4457 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_handle_slow_ring_event_s3()
4461 * the pgp->rspPutInx in the MAILBOX_tand fetch the new port in lpfc_sli_handle_slow_ring_event_s3()
4464 if (pring->sli.sli3.rspidx == portRspPut) { in lpfc_sli_handle_slow_ring_event_s3()
4465 portRspPut = le32_to_cpu(pgp->rspPutInx); in lpfc_sli_handle_slow_ring_event_s3()
4467 } /* while (pring->sli.sli3.rspidx != portRspPut) */ in lpfc_sli_handle_slow_ring_event_s3()
4471 pring->stats.iocb_rsp_full++; in lpfc_sli_handle_slow_ring_event_s3()
4473 status = ((CA_R0ATT | CA_R0RE_RSP) << (pring->ringno * 4)); in lpfc_sli_handle_slow_ring_event_s3()
4474 writel(status, phba->CAregaddr); in lpfc_sli_handle_slow_ring_event_s3()
4475 readl(phba->CAregaddr); /* flush */ in lpfc_sli_handle_slow_ring_event_s3()
4477 if ((mask & HA_R0CE_RSP) && (pring->flag & LPFC_CALL_RING_AVAILABLE)) { in lpfc_sli_handle_slow_ring_event_s3()
4478 pring->flag &= ~LPFC_CALL_RING_AVAILABLE; in lpfc_sli_handle_slow_ring_event_s3()
4479 pring->stats.iocb_cmd_empty++; in lpfc_sli_handle_slow_ring_event_s3()
4482 pring->sli.sli3.local_getidx = le32_to_cpu(pgp->cmdGetInx); in lpfc_sli_handle_slow_ring_event_s3()
4485 if ((pring->lpfc_sli_cmd_available)) in lpfc_sli_handle_slow_ring_event_s3()
4486 (pring->lpfc_sli_cmd_available) (phba, pring); in lpfc_sli_handle_slow_ring_event_s3()
4490 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_handle_slow_ring_event_s3()
4495 * lpfc_sli_handle_slow_ring_event_s4 - Handle SLI4 slow-path els events
4501 * ELS response iocb on the driver internal slow-path response iocb worker
4516 clear_bit(HBA_SP_QUEUE_EVT, &phba->hba_flag); in lpfc_sli_handle_slow_ring_event_s4()
4517 while (!list_empty(&phba->sli4_hba.sp_queue_event)) { in lpfc_sli_handle_slow_ring_event_s4()
4519 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_handle_slow_ring_event_s4()
4520 list_remove_head(&phba->sli4_hba.sp_queue_event, in lpfc_sli_handle_slow_ring_event_s4()
4522 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_handle_slow_ring_event_s4()
4524 switch (bf_get(lpfc_wcqe_c_code, &cq_event->cqe.wcqe_cmpl)) { in lpfc_sli_handle_slow_ring_event_s4()
4554 * lpfc_sli_abort_iocb_ring - Abort all iocbs in the ring
4571 if (pring->ringno == LPFC_ELS_RING) { in lpfc_sli_abort_iocb_ring()
4574 offline = pci_channel_offline(phba->pcidev); in lpfc_sli_abort_iocb_ring()
4579 if (phba->sli_rev >= LPFC_SLI_REV4) { in lpfc_sli_abort_iocb_ring()
4580 spin_lock_irq(&pring->ring_lock); in lpfc_sli_abort_iocb_ring()
4581 list_splice_init(&pring->txq, &tx_completions); in lpfc_sli_abort_iocb_ring()
4582 pring->txq_cnt = 0; in lpfc_sli_abort_iocb_ring()
4585 list_splice_init(&pring->txcmplq, in lpfc_sli_abort_iocb_ring()
4590 &pring->txcmplq, list) in lpfc_sli_abort_iocb_ring()
4594 spin_unlock_irq(&pring->ring_lock); in lpfc_sli_abort_iocb_ring()
4596 spin_lock_irq(&phba->hbalock); in lpfc_sli_abort_iocb_ring()
4597 list_splice_init(&pring->txq, &tx_completions); in lpfc_sli_abort_iocb_ring()
4598 pring->txq_cnt = 0; in lpfc_sli_abort_iocb_ring()
4601 list_splice_init(&pring->txcmplq, &txcmplq_completions); in lpfc_sli_abort_iocb_ring()
4605 &pring->txcmplq, list) in lpfc_sli_abort_iocb_ring()
4609 spin_unlock_irq(&phba->hbalock); in lpfc_sli_abort_iocb_ring()
4626 * lpfc_sli_abort_fcp_rings - Abort all iocbs in all FCP rings
4637 struct lpfc_sli *psli = &phba->sli; in lpfc_sli_abort_fcp_rings()
4642 if (phba->sli_rev >= LPFC_SLI_REV4) { in lpfc_sli_abort_fcp_rings()
4643 for (i = 0; i < phba->cfg_hdw_queue; i++) { in lpfc_sli_abort_fcp_rings()
4644 pring = phba->sli4_hba.hdwq[i].io_wq->pring; in lpfc_sli_abort_fcp_rings()
4648 pring = &psli->sli3_ring[LPFC_FCP_RING]; in lpfc_sli_abort_fcp_rings()
4654 * lpfc_sli_flush_io_rings - flush all iocbs in the IO ring
4668 struct lpfc_sli *psli = &phba->sli; in lpfc_sli_flush_io_rings()
4674 set_bit(HBA_IOQ_FLUSH, &phba->hba_flag); in lpfc_sli_flush_io_rings()
4677 if (phba->sli_rev >= LPFC_SLI_REV4) { in lpfc_sli_flush_io_rings()
4678 for (i = 0; i < phba->cfg_hdw_queue; i++) { in lpfc_sli_flush_io_rings()
4679 if (!phba->sli4_hba.hdwq || in lpfc_sli_flush_io_rings()
4680 !phba->sli4_hba.hdwq[i].io_wq) { in lpfc_sli_flush_io_rings()
4684 phba->pport->load_flag, in lpfc_sli_flush_io_rings()
4685 phba->hba_flag, in lpfc_sli_flush_io_rings()
4686 phba->link_state, in lpfc_sli_flush_io_rings()
4687 phba->sli.sli_flag); in lpfc_sli_flush_io_rings()
4690 pring = phba->sli4_hba.hdwq[i].io_wq->pring; in lpfc_sli_flush_io_rings()
4692 spin_lock_irq(&pring->ring_lock); in lpfc_sli_flush_io_rings()
4694 list_splice_init(&pring->txq, &txq); in lpfc_sli_flush_io_rings()
4696 &pring->txcmplq, list) in lpfc_sli_flush_io_rings()
4697 piocb->cmd_flag &= ~LPFC_IO_ON_TXCMPLQ; in lpfc_sli_flush_io_rings()
4699 list_splice_init(&pring->txcmplq, &txcmplq); in lpfc_sli_flush_io_rings()
4700 pring->txq_cnt = 0; in lpfc_sli_flush_io_rings()
4701 pring->txcmplq_cnt = 0; in lpfc_sli_flush_io_rings()
4702 spin_unlock_irq(&pring->ring_lock); in lpfc_sli_flush_io_rings()
4712 if (unlikely(pci_channel_offline(phba->pcidev))) in lpfc_sli_flush_io_rings()
4716 pring = &psli->sli3_ring[LPFC_FCP_RING]; in lpfc_sli_flush_io_rings()
4718 spin_lock_irq(&phba->hbalock); in lpfc_sli_flush_io_rings()
4720 list_splice_init(&pring->txq, &txq); in lpfc_sli_flush_io_rings()
4722 &pring->txcmplq, list) in lpfc_sli_flush_io_rings()
4723 piocb->cmd_flag &= ~LPFC_IO_ON_TXCMPLQ; in lpfc_sli_flush_io_rings()
4725 list_splice_init(&pring->txcmplq, &txcmplq); in lpfc_sli_flush_io_rings()
4726 pring->txq_cnt = 0; in lpfc_sli_flush_io_rings()
4727 pring->txcmplq_cnt = 0; in lpfc_sli_flush_io_rings()
4728 spin_unlock_irq(&phba->hbalock); in lpfc_sli_flush_io_rings()
4740 * lpfc_sli_brdready_s3 - Check for sli3 host ready status
4760 if (lpfc_readl(phba->HSregaddr, &status)) in lpfc_sli_brdready_s3()
4763 set_bit(HBA_NEEDS_CFG_PORT, &phba->hba_flag); in lpfc_sli_brdready_s3()
4784 phba->pport->port_state = LPFC_VPORT_UNKNOWN; in lpfc_sli_brdready_s3()
4788 if (lpfc_readl(phba->HSregaddr, &status)) { in lpfc_sli_brdready_s3()
4800 readl(phba->MBslimaddr + 0xa8), in lpfc_sli_brdready_s3()
4801 readl(phba->MBslimaddr + 0xac)); in lpfc_sli_brdready_s3()
4802 phba->link_state = LPFC_HBA_ERROR; in lpfc_sli_brdready_s3()
4810 * lpfc_sli_brdready_s4 - Check for sli4 host ready status
4830 phba->pport->port_state = LPFC_VPORT_UNKNOWN; in lpfc_sli_brdready_s4()
4837 phba->link_state = LPFC_HBA_ERROR; in lpfc_sli_brdready_s4()
4840 phba->sli4_hba.intr_enable = 0; in lpfc_sli_brdready_s4()
4842 clear_bit(HBA_SETUP, &phba->hba_flag); in lpfc_sli_brdready_s4()
4847 * lpfc_sli_brdready - Wrapper func for checking the hba readyness
4857 return phba->lpfc_sli_brdready(phba, mask); in lpfc_sli_brdready()
4863 * lpfc_reset_barrier - Make HBA ready for HBA reset
4878 lockdep_assert_held(&phba->hbalock); in lpfc_reset_barrier()
4880 pci_read_config_byte(phba->pcidev, PCI_HEADER_TYPE, &hdrtype); in lpfc_reset_barrier()
4882 (FC_JEDEC_ID(phba->vpd.rev.biuRev) != HELIOS_JEDEC_ID && in lpfc_reset_barrier()
4883 FC_JEDEC_ID(phba->vpd.rev.biuRev) != THOR_JEDEC_ID)) in lpfc_reset_barrier()
4890 resp_buf = phba->MBslimaddr; in lpfc_reset_barrier()
4893 if (lpfc_readl(phba->HCregaddr, &hc_copy)) in lpfc_reset_barrier()
4895 writel((hc_copy & ~HC_ERINT_ENA), phba->HCregaddr); in lpfc_reset_barrier()
4896 readl(phba->HCregaddr); /* flush */ in lpfc_reset_barrier()
4897 phba->link_flag |= LS_IGNORE_ERATT; in lpfc_reset_barrier()
4899 if (lpfc_readl(phba->HAregaddr, &ha_copy)) in lpfc_reset_barrier()
4903 writel(HA_ERATT, phba->HAregaddr); in lpfc_reset_barrier()
4904 phba->pport->stopped = 1; in lpfc_reset_barrier()
4912 mbox_buf = phba->MBslimaddr; in lpfc_reset_barrier()
4927 if (phba->sli.sli_flag & LPFC_SLI_ACTIVE || in lpfc_reset_barrier()
4928 phba->pport->stopped) in lpfc_reset_barrier()
4948 if (lpfc_readl(phba->HAregaddr, &ha_copy)) in lpfc_reset_barrier()
4956 if (readl(phba->HAregaddr) & HA_ERATT) { in lpfc_reset_barrier()
4957 writel(HA_ERATT, phba->HAregaddr); in lpfc_reset_barrier()
4958 phba->pport->stopped = 1; in lpfc_reset_barrier()
4962 phba->link_flag &= ~LS_IGNORE_ERATT; in lpfc_reset_barrier()
4963 writel(hc_copy, phba->HCregaddr); in lpfc_reset_barrier()
4964 readl(phba->HCregaddr); /* flush */ in lpfc_reset_barrier()
4968 * lpfc_sli_brdkill - Issue a kill_board mailbox command
4971 * This function issues a kill_board mailbox command and waits for
4988 psli = &phba->sli; in lpfc_sli_brdkill()
4993 phba->pport->port_state, psli->sli_flag); in lpfc_sli_brdkill()
4995 pmb = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli_brdkill()
5000 spin_lock_irq(&phba->hbalock); in lpfc_sli_brdkill()
5001 if (lpfc_readl(phba->HCregaddr, &status)) { in lpfc_sli_brdkill()
5002 spin_unlock_irq(&phba->hbalock); in lpfc_sli_brdkill()
5003 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_sli_brdkill()
5007 writel(status, phba->HCregaddr); in lpfc_sli_brdkill()
5008 readl(phba->HCregaddr); /* flush */ in lpfc_sli_brdkill()
5009 phba->link_flag |= LS_IGNORE_ERATT; in lpfc_sli_brdkill()
5010 spin_unlock_irq(&phba->hbalock); in lpfc_sli_brdkill()
5013 pmb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_sli_brdkill()
5018 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_sli_brdkill()
5022 spin_lock_irq(&phba->hbalock); in lpfc_sli_brdkill()
5023 phba->link_flag &= ~LS_IGNORE_ERATT; in lpfc_sli_brdkill()
5024 spin_unlock_irq(&phba->hbalock); in lpfc_sli_brdkill()
5028 spin_lock_irq(&phba->hbalock); in lpfc_sli_brdkill()
5029 psli->sli_flag &= ~LPFC_SLI_ACTIVE; in lpfc_sli_brdkill()
5030 spin_unlock_irq(&phba->hbalock); in lpfc_sli_brdkill()
5032 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_sli_brdkill()
5039 if (lpfc_readl(phba->HAregaddr, &ha_copy)) in lpfc_sli_brdkill()
5043 if (lpfc_readl(phba->HAregaddr, &ha_copy)) in lpfc_sli_brdkill()
5047 del_timer_sync(&psli->mbox_tmo); in lpfc_sli_brdkill()
5049 writel(HA_ERATT, phba->HAregaddr); in lpfc_sli_brdkill()
5050 phba->pport->stopped = 1; in lpfc_sli_brdkill()
5052 spin_lock_irq(&phba->hbalock); in lpfc_sli_brdkill()
5053 psli->sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; in lpfc_sli_brdkill()
5054 psli->mbox_active = NULL; in lpfc_sli_brdkill()
5055 phba->link_flag &= ~LS_IGNORE_ERATT; in lpfc_sli_brdkill()
5056 spin_unlock_irq(&phba->hbalock); in lpfc_sli_brdkill()
5059 phba->link_state = LPFC_HBA_ERROR; in lpfc_sli_brdkill()
5065 * lpfc_sli_brdreset - Reset a sli-2 or sli-3 HBA
5083 psli = &phba->sli; in lpfc_sli_brdreset()
5088 (phba->pport) ? phba->pport->port_state : 0, in lpfc_sli_brdreset()
5089 psli->sli_flag); in lpfc_sli_brdreset()
5092 phba->fc_eventTag = 0; in lpfc_sli_brdreset()
5093 phba->link_events = 0; in lpfc_sli_brdreset()
5094 set_bit(HBA_NEEDS_CFG_PORT, &phba->hba_flag); in lpfc_sli_brdreset()
5095 if (phba->pport) { in lpfc_sli_brdreset()
5096 phba->pport->fc_myDID = 0; in lpfc_sli_brdreset()
5097 phba->pport->fc_prevDID = 0; in lpfc_sli_brdreset()
5101 if (pci_read_config_word(phba->pcidev, PCI_COMMAND, &cfg_value)) in lpfc_sli_brdreset()
5102 return -EIO; in lpfc_sli_brdreset()
5104 pci_write_config_word(phba->pcidev, PCI_COMMAND, in lpfc_sli_brdreset()
5108 psli->sli_flag &= ~(LPFC_SLI_ACTIVE | LPFC_PROCESS_LA); in lpfc_sli_brdreset()
5111 writel(HC_INITFF, phba->HCregaddr); in lpfc_sli_brdreset()
5113 readl(phba->HCregaddr); /* flush */ in lpfc_sli_brdreset()
5114 writel(0, phba->HCregaddr); in lpfc_sli_brdreset()
5115 readl(phba->HCregaddr); /* flush */ in lpfc_sli_brdreset()
5118 pci_write_config_word(phba->pcidev, PCI_COMMAND, cfg_value); in lpfc_sli_brdreset()
5121 for (i = 0; i < psli->num_rings; i++) { in lpfc_sli_brdreset()
5122 pring = &psli->sli3_ring[i]; in lpfc_sli_brdreset()
5123 pring->flag = 0; in lpfc_sli_brdreset()
5124 pring->sli.sli3.rspidx = 0; in lpfc_sli_brdreset()
5125 pring->sli.sli3.next_cmdidx = 0; in lpfc_sli_brdreset()
5126 pring->sli.sli3.local_getidx = 0; in lpfc_sli_brdreset()
5127 pring->sli.sli3.cmdidx = 0; in lpfc_sli_brdreset()
5128 pring->missbufcnt = 0; in lpfc_sli_brdreset()
5131 phba->link_state = LPFC_WARM_START; in lpfc_sli_brdreset()
5136 * lpfc_sli4_brdreset - Reset a sli-4 HBA
5148 struct lpfc_sli *psli = &phba->sli; in lpfc_sli4_brdreset()
5155 phba->pport->port_state, psli->sli_flag, in lpfc_sli4_brdreset()
5156 phba->hba_flag); in lpfc_sli4_brdreset()
5159 phba->fc_eventTag = 0; in lpfc_sli4_brdreset()
5160 phba->link_events = 0; in lpfc_sli4_brdreset()
5161 phba->pport->fc_myDID = 0; in lpfc_sli4_brdreset()
5162 phba->pport->fc_prevDID = 0; in lpfc_sli4_brdreset()
5163 clear_bit(HBA_SETUP, &phba->hba_flag); in lpfc_sli4_brdreset()
5165 spin_lock_irq(&phba->hbalock); in lpfc_sli4_brdreset()
5166 psli->sli_flag &= ~(LPFC_PROCESS_LA); in lpfc_sli4_brdreset()
5167 phba->fcf.fcf_flag = 0; in lpfc_sli4_brdreset()
5168 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_brdreset()
5175 if (pci_read_config_word(phba->pcidev, PCI_COMMAND, &cfg_value)) { in lpfc_sli4_brdreset()
5178 return -EIO; in lpfc_sli4_brdreset()
5181 pci_write_config_word(phba->pcidev, PCI_COMMAND, (cfg_value & in lpfc_sli4_brdreset()
5188 pci_write_config_word(phba->pcidev, PCI_COMMAND, cfg_value); in lpfc_sli4_brdreset()
5194 * lpfc_sli_brdrestart_s3 - Restart a sli-3 hba
5199 * This function writes MBX_RESTART mailbox command to the SLIM and
5203 * The function does not guarantee completion of MBX_RESTART mailbox
5213 spin_lock_irq(&phba->hbalock); in lpfc_sli_brdrestart_s3()
5215 psli = &phba->sli; in lpfc_sli_brdrestart_s3()
5220 (phba->pport) ? phba->pport->port_state : 0, in lpfc_sli_brdrestart_s3()
5221 psli->sli_flag); in lpfc_sli_brdrestart_s3()
5229 to_slim = phba->MBslimaddr; in lpfc_sli_brdrestart_s3()
5234 if (phba->pport && phba->pport->port_state) in lpfc_sli_brdrestart_s3()
5238 to_slim = phba->MBslimaddr + sizeof (uint32_t); in lpfc_sli_brdrestart_s3()
5243 if (phba->pport) in lpfc_sli_brdrestart_s3()
5244 phba->pport->stopped = 0; in lpfc_sli_brdrestart_s3()
5245 phba->link_state = LPFC_INIT_START; in lpfc_sli_brdrestart_s3()
5246 phba->hba_flag = 0; in lpfc_sli_brdrestart_s3()
5247 spin_unlock_irq(&phba->hbalock); in lpfc_sli_brdrestart_s3()
5249 memset(&psli->lnk_stat_offsets, 0, sizeof(psli->lnk_stat_offsets)); in lpfc_sli_brdrestart_s3()
5250 psli->stats_start = ktime_get_seconds(); in lpfc_sli_brdrestart_s3()
5261 * lpfc_sli_brdrestart_s4 - Restart the sli-4 hba
5272 struct lpfc_sli *psli = &phba->sli; in lpfc_sli_brdrestart_s4()
5278 phba->pport->port_state, psli->sli_flag); in lpfc_sli_brdrestart_s4()
5284 phba->link_state = LPFC_HBA_ERROR; in lpfc_sli_brdrestart_s4()
5288 spin_lock_irq(&phba->hbalock); in lpfc_sli_brdrestart_s4()
5289 phba->pport->stopped = 0; in lpfc_sli_brdrestart_s4()
5290 phba->link_state = LPFC_INIT_START; in lpfc_sli_brdrestart_s4()
5291 phba->hba_flag = 0; in lpfc_sli_brdrestart_s4()
5292 /* Preserve FA-PWWN expectation */ in lpfc_sli_brdrestart_s4()
5293 phba->sli4_hba.fawwpn_flag &= LPFC_FAWWPN_FABRIC; in lpfc_sli_brdrestart_s4()
5294 spin_unlock_irq(&phba->hbalock); in lpfc_sli_brdrestart_s4()
5296 memset(&psli->lnk_stat_offsets, 0, sizeof(psli->lnk_stat_offsets)); in lpfc_sli_brdrestart_s4()
5297 psli->stats_start = ktime_get_seconds(); in lpfc_sli_brdrestart_s4()
5307 * lpfc_sli_brdrestart - Wrapper func for restarting hba
5316 return phba->lpfc_sli_brdrestart(phba); in lpfc_sli_brdrestart()
5320 * lpfc_sli_chipset_init - Wait for the restart of the HBA after a restart
5335 if (lpfc_readl(phba->HSregaddr, &status)) in lpfc_sli_chipset_init()
5336 return -EIO; in lpfc_sli_chipset_init()
5357 readl(phba->MBslimaddr + 0xa8), in lpfc_sli_chipset_init()
5358 readl(phba->MBslimaddr + 0xac)); in lpfc_sli_chipset_init()
5359 phba->link_state = LPFC_HBA_ERROR; in lpfc_sli_chipset_init()
5360 return -ETIMEDOUT; in lpfc_sli_chipset_init()
5372 readl(phba->MBslimaddr + 0xa8), in lpfc_sli_chipset_init()
5373 readl(phba->MBslimaddr + 0xac)); in lpfc_sli_chipset_init()
5374 phba->link_state = LPFC_HBA_ERROR; in lpfc_sli_chipset_init()
5375 return -EIO; in lpfc_sli_chipset_init()
5387 phba->pport->port_state = LPFC_VPORT_UNKNOWN; in lpfc_sli_chipset_init()
5391 if (lpfc_readl(phba->HSregaddr, &status)) in lpfc_sli_chipset_init()
5392 return -EIO; in lpfc_sli_chipset_init()
5403 readl(phba->MBslimaddr + 0xa8), in lpfc_sli_chipset_init()
5404 readl(phba->MBslimaddr + 0xac)); in lpfc_sli_chipset_init()
5405 phba->link_state = LPFC_HBA_ERROR; in lpfc_sli_chipset_init()
5406 return -EIO; in lpfc_sli_chipset_init()
5409 set_bit(HBA_NEEDS_CFG_PORT, &phba->hba_flag); in lpfc_sli_chipset_init()
5412 writel(0, phba->HCregaddr); in lpfc_sli_chipset_init()
5413 readl(phba->HCregaddr); /* flush */ in lpfc_sli_chipset_init()
5416 writel(0xffffffff, phba->HAregaddr); in lpfc_sli_chipset_init()
5417 readl(phba->HAregaddr); /* flush */ in lpfc_sli_chipset_init()
5422 * lpfc_sli_hbq_count - Get the number of HBQs to be configured
5434 * lpfc_sli_hbq_entry_count - Calculate total number of hbq entries
5448 count += lpfc_hbq_defs[i]->entry_count; in lpfc_sli_hbq_entry_count()
5453 * lpfc_sli_hbq_size - Calculate memory required for all hbq entries
5465 * lpfc_sli_hbq_setup - configure and initialize HBQs
5482 /* Get a Mailbox buffer to setup mailbox in lpfc_sli_hbq_setup()
5485 pmb = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli_hbq_setup()
5488 return -ENOMEM; in lpfc_sli_hbq_setup()
5490 pmbox = &pmb->u.mb; in lpfc_sli_hbq_setup()
5493 phba->link_state = LPFC_INIT_MBX_CMDS; in lpfc_sli_hbq_setup()
5494 phba->hbq_in_use = 1; in lpfc_sli_hbq_setup()
5498 phba->hbqs[hbqno].next_hbqPutIdx = 0; in lpfc_sli_hbq_setup()
5499 phba->hbqs[hbqno].hbqPutIdx = 0; in lpfc_sli_hbq_setup()
5500 phba->hbqs[hbqno].local_hbqGetIdx = 0; in lpfc_sli_hbq_setup()
5501 phba->hbqs[hbqno].entry_count = in lpfc_sli_hbq_setup()
5502 lpfc_hbq_defs[hbqno]->entry_count; in lpfc_sli_hbq_setup()
5505 hbq_entry_index += phba->hbqs[hbqno].entry_count; in lpfc_sli_hbq_setup()
5515 pmbox->mbxCommand, in lpfc_sli_hbq_setup()
5516 pmbox->mbxStatus, hbqno); in lpfc_sli_hbq_setup()
5518 phba->link_state = LPFC_HBA_ERROR; in lpfc_sli_hbq_setup()
5519 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_sli_hbq_setup()
5520 return -ENXIO; in lpfc_sli_hbq_setup()
5523 phba->hbq_count = hbq_count; in lpfc_sli_hbq_setup()
5525 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_sli_hbq_setup()
5534 * lpfc_sli4_rb_setup - Initialize and post RBs to HBA
5545 phba->hbq_in_use = 1; in lpfc_sli4_rb_setup()
5551 if (phba->cfg_enable_mds_diags && phba->mds_diags_support) in lpfc_sli4_rb_setup()
5552 phba->hbqs[LPFC_ELS_HBQ].entry_count = in lpfc_sli4_rb_setup()
5553 lpfc_hbq_defs[LPFC_ELS_HBQ]->entry_count >> 1; in lpfc_sli4_rb_setup()
5555 phba->hbqs[LPFC_ELS_HBQ].entry_count = in lpfc_sli4_rb_setup()
5556 lpfc_hbq_defs[LPFC_ELS_HBQ]->entry_count; in lpfc_sli4_rb_setup()
5557 phba->hbq_count = 1; in lpfc_sli4_rb_setup()
5564 * lpfc_sli_config_port - Issue config port mailbox command
5566 * @sli_mode: sli mode - 2/3
5569 * to issue config_port mailbox command. This function restarts the
5570 * HBA firmware and issues a config_port mailbox command to configure
5582 pmb = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli_config_port()
5584 phba->link_state = LPFC_HBA_ERROR; in lpfc_sli_config_port()
5585 return -ENOMEM; in lpfc_sli_config_port()
5588 phba->sli_rev = sli_mode; in lpfc_sli_config_port()
5590 spin_lock_irq(&phba->hbalock); in lpfc_sli_config_port()
5591 phba->sli.sli_flag |= LPFC_SLI_MBOX_ACTIVE; in lpfc_sli_config_port()
5592 spin_unlock_irq(&phba->hbalock); in lpfc_sli_config_port()
5593 phba->pport->port_state = LPFC_VPORT_UNKNOWN; in lpfc_sli_config_port()
5599 spin_lock_irq(&phba->hbalock); in lpfc_sli_config_port()
5600 phba->sli.sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; in lpfc_sli_config_port()
5601 spin_unlock_irq(&phba->hbalock); in lpfc_sli_config_port()
5604 /* Call pre CONFIG_PORT mailbox command initialization. A in lpfc_sli_config_port()
5610 if (rc == -ERESTART) { in lpfc_sli_config_port()
5611 phba->link_state = LPFC_LINK_UNKNOWN; in lpfc_sli_config_port()
5616 phba->link_state = LPFC_INIT_MBX_CMDS; in lpfc_sli_config_port()
5619 phba->sli3_options &= ~(LPFC_SLI3_NPIV_ENABLED | in lpfc_sli_config_port()
5627 pmb->u.mb.mbxCommand, pmb->u.mb.mbxStatus, 0); in lpfc_sli_config_port()
5628 spin_lock_irq(&phba->hbalock); in lpfc_sli_config_port()
5629 phba->sli.sli_flag &= ~LPFC_SLI_ACTIVE; in lpfc_sli_config_port()
5630 spin_unlock_irq(&phba->hbalock); in lpfc_sli_config_port()
5631 rc = -ENXIO; in lpfc_sli_config_port()
5633 /* Allow asynchronous mailbox command to go through */ in lpfc_sli_config_port()
5634 spin_lock_irq(&phba->hbalock); in lpfc_sli_config_port()
5635 phba->sli.sli_flag &= ~LPFC_SLI_ASYNC_MBX_BLK; in lpfc_sli_config_port()
5636 spin_unlock_irq(&phba->hbalock); in lpfc_sli_config_port()
5639 if ((pmb->u.mb.un.varCfgPort.casabt == 1) && in lpfc_sli_config_port()
5640 (pmb->u.mb.un.varCfgPort.gasabt == 0)) in lpfc_sli_config_port()
5646 rc = -EINVAL; in lpfc_sli_config_port()
5649 if (pmb->u.mb.un.varCfgPort.sli_mode == 3) { in lpfc_sli_config_port()
5650 if (!pmb->u.mb.un.varCfgPort.cMA) { in lpfc_sli_config_port()
5651 rc = -ENXIO; in lpfc_sli_config_port()
5654 if (phba->max_vpi && pmb->u.mb.un.varCfgPort.gmv) { in lpfc_sli_config_port()
5655 phba->sli3_options |= LPFC_SLI3_NPIV_ENABLED; in lpfc_sli_config_port()
5656 phba->max_vpi = pmb->u.mb.un.varCfgPort.max_vpi; in lpfc_sli_config_port()
5657 phba->max_vports = (phba->max_vpi > phba->max_vports) ? in lpfc_sli_config_port()
5658 phba->max_vpi : phba->max_vports; in lpfc_sli_config_port()
5661 phba->max_vpi = 0; in lpfc_sli_config_port()
5662 if (pmb->u.mb.un.varCfgPort.gerbm) in lpfc_sli_config_port()
5663 phba->sli3_options |= LPFC_SLI3_HBQ_ENABLED; in lpfc_sli_config_port()
5664 if (pmb->u.mb.un.varCfgPort.gcrp) in lpfc_sli_config_port()
5665 phba->sli3_options |= LPFC_SLI3_CRP_ENABLED; in lpfc_sli_config_port()
5667 phba->hbq_get = phba->mbox->us.s3_pgp.hbq_get; in lpfc_sli_config_port()
5668 phba->port_gp = phba->mbox->us.s3_pgp.port; in lpfc_sli_config_port()
5670 if (phba->sli3_options & LPFC_SLI3_BG_ENABLED) { in lpfc_sli_config_port()
5671 if (pmb->u.mb.un.varCfgPort.gbg == 0) { in lpfc_sli_config_port()
5672 phba->cfg_enable_bg = 0; in lpfc_sli_config_port()
5673 phba->sli3_options &= ~LPFC_SLI3_BG_ENABLED; in lpfc_sli_config_port()
5680 phba->hbq_get = NULL; in lpfc_sli_config_port()
5681 phba->port_gp = phba->mbox->us.s2.port; in lpfc_sli_config_port()
5682 phba->max_vpi = 0; in lpfc_sli_config_port()
5685 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_sli_config_port()
5691 * lpfc_sli_hba_setup - SLI initialization function
5697 * locks. This function issues config_port mailbox command to configure
5699 * calls the config_port_post function to issue init_link mailbox
5711 if (test_bit(HBA_NEEDS_CFG_PORT, &phba->hba_flag)) { in lpfc_sli_hba_setup()
5714 return -EIO; in lpfc_sli_hba_setup()
5715 clear_bit(HBA_NEEDS_CFG_PORT, &phba->hba_flag); in lpfc_sli_hba_setup()
5717 phba->fcp_embed_io = 0; /* SLI4 FC support only */ in lpfc_sli_hba_setup()
5719 if (phba->sli_rev == 3) { in lpfc_sli_hba_setup()
5720 phba->iocb_cmd_size = SLI3_IOCB_CMD_SIZE; in lpfc_sli_hba_setup()
5721 phba->iocb_rsp_size = SLI3_IOCB_RSP_SIZE; in lpfc_sli_hba_setup()
5723 phba->iocb_cmd_size = SLI2_IOCB_CMD_SIZE; in lpfc_sli_hba_setup()
5724 phba->iocb_rsp_size = SLI2_IOCB_RSP_SIZE; in lpfc_sli_hba_setup()
5725 phba->sli3_options = 0; in lpfc_sli_hba_setup()
5730 phba->sli_rev, phba->max_vpi); in lpfc_sli_hba_setup()
5737 if (phba->sli_rev == LPFC_SLI_REV3) { in lpfc_sli_hba_setup()
5740 * and initialized once only - at driver load. A port in lpfc_sli_hba_setup()
5743 if ((phba->vpi_bmask == NULL) && (phba->vpi_ids == NULL)) { in lpfc_sli_hba_setup()
5744 longs = (phba->max_vpi + BITS_PER_LONG) / BITS_PER_LONG; in lpfc_sli_hba_setup()
5745 phba->vpi_bmask = kcalloc(longs, in lpfc_sli_hba_setup()
5748 if (!phba->vpi_bmask) { in lpfc_sli_hba_setup()
5749 rc = -ENOMEM; in lpfc_sli_hba_setup()
5753 phba->vpi_ids = kcalloc(phba->max_vpi + 1, in lpfc_sli_hba_setup()
5756 if (!phba->vpi_ids) { in lpfc_sli_hba_setup()
5757 kfree(phba->vpi_bmask); in lpfc_sli_hba_setup()
5758 rc = -ENOMEM; in lpfc_sli_hba_setup()
5761 for (i = 0; i < phba->max_vpi; i++) in lpfc_sli_hba_setup()
5762 phba->vpi_ids[i] = i; in lpfc_sli_hba_setup()
5767 if (phba->sli3_options & LPFC_SLI3_HBQ_ENABLED) { in lpfc_sli_hba_setup()
5772 spin_lock_irq(&phba->hbalock); in lpfc_sli_hba_setup()
5773 phba->sli.sli_flag |= LPFC_PROCESS_LA; in lpfc_sli_hba_setup()
5774 spin_unlock_irq(&phba->hbalock); in lpfc_sli_hba_setup()
5783 phba->link_state = LPFC_HBA_ERROR; in lpfc_sli_hba_setup()
5790 * lpfc_sli4_read_fcoe_params - Read fcoe params from conf region
5793 * This function issue a dump mailbox command to read config region
5807 phba->valid_vlan = 0; in lpfc_sli4_read_fcoe_params()
5808 phba->fc_map[0] = LPFC_FCOE_FCF_MAP0; in lpfc_sli4_read_fcoe_params()
5809 phba->fc_map[1] = LPFC_FCOE_FCF_MAP1; in lpfc_sli4_read_fcoe_params()
5810 phba->fc_map[2] = LPFC_FCOE_FCF_MAP2; in lpfc_sli4_read_fcoe_params()
5812 mboxq = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_read_fcoe_params()
5814 return -ENOMEM; in lpfc_sli4_read_fcoe_params()
5816 mqe = &mboxq->u.mqe; in lpfc_sli4_read_fcoe_params()
5818 rc = -ENOMEM; in lpfc_sli4_read_fcoe_params()
5822 mp = mboxq->ctx_buf; in lpfc_sli4_read_fcoe_params()
5826 "(%d):2571 Mailbox cmd x%x Status x%x " in lpfc_sli4_read_fcoe_params()
5830 mboxq->vport ? mboxq->vport->vpi : 0, in lpfc_sli4_read_fcoe_params()
5833 mqe->un.mb_words[0], mqe->un.mb_words[1], in lpfc_sli4_read_fcoe_params()
5834 mqe->un.mb_words[2], mqe->un.mb_words[3], in lpfc_sli4_read_fcoe_params()
5835 mqe->un.mb_words[4], mqe->un.mb_words[5], in lpfc_sli4_read_fcoe_params()
5836 mqe->un.mb_words[6], mqe->un.mb_words[7], in lpfc_sli4_read_fcoe_params()
5837 mqe->un.mb_words[8], mqe->un.mb_words[9], in lpfc_sli4_read_fcoe_params()
5838 mqe->un.mb_words[10], mqe->un.mb_words[11], in lpfc_sli4_read_fcoe_params()
5839 mqe->un.mb_words[12], mqe->un.mb_words[13], in lpfc_sli4_read_fcoe_params()
5840 mqe->un.mb_words[14], mqe->un.mb_words[15], in lpfc_sli4_read_fcoe_params()
5841 mqe->un.mb_words[16], mqe->un.mb_words[50], in lpfc_sli4_read_fcoe_params()
5842 mboxq->mcqe.word0, in lpfc_sli4_read_fcoe_params()
5843 mboxq->mcqe.mcqe_tag0, mboxq->mcqe.mcqe_tag1, in lpfc_sli4_read_fcoe_params()
5844 mboxq->mcqe.trailer); in lpfc_sli4_read_fcoe_params()
5847 rc = -EIO; in lpfc_sli4_read_fcoe_params()
5850 data_length = mqe->un.mb_words[5]; in lpfc_sli4_read_fcoe_params()
5852 rc = -EIO; in lpfc_sli4_read_fcoe_params()
5856 lpfc_parse_fcoe_conf(phba, mp->virt, data_length); in lpfc_sli4_read_fcoe_params()
5865 * lpfc_sli4_read_rev - Issue READ_REV and collect vpd data
5872 * This routine executes a READ_REV SLI4 mailbox command. In
5876 * 0 - successful
5877 * -ENOMEM - could not allocated memory.
5890 return -ENOMEM; in lpfc_sli4_read_rev()
5894 * mailbox command. in lpfc_sli4_read_rev()
5897 dmabuf->virt = dma_alloc_coherent(&phba->pcidev->dev, dma_size, in lpfc_sli4_read_rev()
5898 &dmabuf->phys, GFP_KERNEL); in lpfc_sli4_read_rev()
5899 if (!dmabuf->virt) { in lpfc_sli4_read_rev()
5901 return -ENOMEM; in lpfc_sli4_read_rev()
5910 mqe = &mboxq->u.mqe; in lpfc_sli4_read_rev()
5911 mqe->un.read_rev.vpd_paddr_high = putPaddrHigh(dmabuf->phys); in lpfc_sli4_read_rev()
5912 mqe->un.read_rev.vpd_paddr_low = putPaddrLow(dmabuf->phys); in lpfc_sli4_read_rev()
5913 mqe->un.read_rev.word1 &= 0x0000FFFF; in lpfc_sli4_read_rev()
5914 bf_set(lpfc_mbx_rd_rev_vpd, &mqe->un.read_rev, 1); in lpfc_sli4_read_rev()
5915 bf_set(lpfc_mbx_rd_rev_avail_len, &mqe->un.read_rev, dma_size); in lpfc_sli4_read_rev()
5919 dma_free_coherent(&phba->pcidev->dev, dma_size, in lpfc_sli4_read_rev()
5920 dmabuf->virt, dmabuf->phys); in lpfc_sli4_read_rev()
5922 return -EIO; in lpfc_sli4_read_rev()
5930 if (mqe->un.read_rev.avail_vpd_len < *vpd_size) in lpfc_sli4_read_rev()
5931 *vpd_size = mqe->un.read_rev.avail_vpd_len; in lpfc_sli4_read_rev()
5933 memcpy(vpd, dmabuf->virt, *vpd_size); in lpfc_sli4_read_rev()
5935 dma_free_coherent(&phba->pcidev->dev, dma_size, in lpfc_sli4_read_rev()
5936 dmabuf->virt, dmabuf->phys); in lpfc_sli4_read_rev()
5942 * lpfc_sli4_get_ctl_attr - Retrieve SLI4 device controller attributes
5949 * 0 - successful
5950 * otherwise - failed to retrieve controller attributes
5964 mboxq = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_get_ctl_attr()
5966 return -ENOMEM; in lpfc_sli4_get_ctl_attr()
5979 rc = -ENOMEM; in lpfc_sli4_get_ctl_attr()
5983 virtaddr = mboxq->sge_array->addr[0]; in lpfc_sli4_get_ctl_attr()
5985 shdr = &mbx_cntl_attr->cfg_shdr; in lpfc_sli4_get_ctl_attr()
5986 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_sli4_get_ctl_attr()
5987 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_sli4_get_ctl_attr()
5990 "3085 Mailbox x%x (x%x/x%x) failed, " in lpfc_sli4_get_ctl_attr()
5992 bf_get(lpfc_mqe_command, &mboxq->u.mqe), in lpfc_sli4_get_ctl_attr()
5996 rc = -ENXIO; in lpfc_sli4_get_ctl_attr()
6000 cntl_attr = &mbx_cntl_attr->cntl_attr; in lpfc_sli4_get_ctl_attr()
6001 phba->sli4_hba.lnk_info.lnk_dv = LPFC_LNK_DAT_VAL; in lpfc_sli4_get_ctl_attr()
6002 phba->sli4_hba.lnk_info.lnk_tp = in lpfc_sli4_get_ctl_attr()
6004 phba->sli4_hba.lnk_info.lnk_no = in lpfc_sli4_get_ctl_attr()
6006 phba->sli4_hba.flash_id = bf_get(lpfc_cntl_attr_flash_id, cntl_attr); in lpfc_sli4_get_ctl_attr()
6007 phba->sli4_hba.asic_rev = bf_get(lpfc_cntl_attr_asic_rev, cntl_attr); in lpfc_sli4_get_ctl_attr()
6009 memset(phba->BIOSVersion, 0, sizeof(phba->BIOSVersion)); in lpfc_sli4_get_ctl_attr()
6010 strlcat(phba->BIOSVersion, (char *)cntl_attr->bios_ver_str, in lpfc_sli4_get_ctl_attr()
6011 sizeof(phba->BIOSVersion)); in lpfc_sli4_get_ctl_attr()
6016 phba->sli4_hba.lnk_info.lnk_tp, in lpfc_sli4_get_ctl_attr()
6017 phba->sli4_hba.lnk_info.lnk_no, in lpfc_sli4_get_ctl_attr()
6018 phba->BIOSVersion, phba->sli4_hba.flash_id, in lpfc_sli4_get_ctl_attr()
6019 phba->sli4_hba.asic_rev); in lpfc_sli4_get_ctl_attr()
6021 if (bf_get(lpfc_mqe_command, &mboxq->u.mqe) == MBX_SLI4_CONFIG) in lpfc_sli4_get_ctl_attr()
6024 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_get_ctl_attr()
6029 * lpfc_sli4_retrieve_pport_name - Retrieve SLI4 device physical port name
6036 * 0 - successful
6037 * otherwise - failed to retrieve physical port name
6050 phba->sli4_hba.lnk_info.lnk_dv = LPFC_LNK_DAT_INVAL; in lpfc_sli4_retrieve_pport_name()
6051 phba->sli4_hba.pport_name_sta = LPFC_SLI4_PPNAME_NON; in lpfc_sli4_retrieve_pport_name()
6053 mboxq = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_retrieve_pport_name()
6055 return -ENOMEM; in lpfc_sli4_retrieve_pport_name()
6057 phba->sli4_hba.lnk_info.lnk_dv = LPFC_LNK_DAT_INVAL; in lpfc_sli4_retrieve_pport_name()
6060 if (phba->sli4_hba.fawwpn_flag & LPFC_FAWWPN_CONFIG) in lpfc_sli4_retrieve_pport_name()
6061 phba->sli4_hba.fawwpn_flag |= LPFC_FAWWPN_FABRIC; in lpfc_sli4_retrieve_pport_name()
6063 if (phba->sli4_hba.lnk_info.lnk_dv == LPFC_LNK_DAT_VAL) in lpfc_sli4_retrieve_pport_name()
6074 sizeof(struct lpfc_mbx_get_port_name) - in lpfc_sli4_retrieve_pport_name()
6077 get_port_name = &mboxq->u.mqe.un.get_port_name; in lpfc_sli4_retrieve_pport_name()
6078 shdr = (union lpfc_sli4_cfg_shdr *)&get_port_name->header.cfg_shdr; in lpfc_sli4_retrieve_pport_name()
6079 bf_set(lpfc_mbox_hdr_version, &shdr->request, LPFC_OPCODE_VERSION_1); in lpfc_sli4_retrieve_pport_name()
6080 bf_set(lpfc_mbx_get_port_name_lnk_type, &get_port_name->u.request, in lpfc_sli4_retrieve_pport_name()
6081 phba->sli4_hba.lnk_info.lnk_tp); in lpfc_sli4_retrieve_pport_name()
6083 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_sli4_retrieve_pport_name()
6084 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_sli4_retrieve_pport_name()
6087 "3087 Mailbox x%x (x%x/x%x) failed: " in lpfc_sli4_retrieve_pport_name()
6089 bf_get(lpfc_mqe_command, &mboxq->u.mqe), in lpfc_sli4_retrieve_pport_name()
6093 rc = -ENXIO; in lpfc_sli4_retrieve_pport_name()
6096 switch (phba->sli4_hba.lnk_info.lnk_no) { in lpfc_sli4_retrieve_pport_name()
6099 &get_port_name->u.response); in lpfc_sli4_retrieve_pport_name()
6100 phba->sli4_hba.pport_name_sta = LPFC_SLI4_PPNAME_GET; in lpfc_sli4_retrieve_pport_name()
6104 &get_port_name->u.response); in lpfc_sli4_retrieve_pport_name()
6105 phba->sli4_hba.pport_name_sta = LPFC_SLI4_PPNAME_GET; in lpfc_sli4_retrieve_pport_name()
6109 &get_port_name->u.response); in lpfc_sli4_retrieve_pport_name()
6110 phba->sli4_hba.pport_name_sta = LPFC_SLI4_PPNAME_GET; in lpfc_sli4_retrieve_pport_name()
6114 &get_port_name->u.response); in lpfc_sli4_retrieve_pport_name()
6115 phba->sli4_hba.pport_name_sta = LPFC_SLI4_PPNAME_GET; in lpfc_sli4_retrieve_pport_name()
6121 if (phba->sli4_hba.pport_name_sta == LPFC_SLI4_PPNAME_GET) { in lpfc_sli4_retrieve_pport_name()
6122 phba->Port[0] = cport_name; in lpfc_sli4_retrieve_pport_name()
6123 phba->Port[1] = '\0'; in lpfc_sli4_retrieve_pport_name()
6125 "3091 SLI get port name: %s\n", phba->Port); in lpfc_sli4_retrieve_pport_name()
6129 if (bf_get(lpfc_mqe_command, &mboxq->u.mqe) == MBX_SLI4_CONFIG) in lpfc_sli4_retrieve_pport_name()
6132 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_retrieve_pport_name()
6137 * lpfc_sli4_arm_cqeq_intr - Arm sli-4 device completion and event queues
6147 struct lpfc_sli4_hba *sli4_hba = &phba->sli4_hba; in lpfc_sli4_arm_cqeq_intr()
6151 sli4_hba->sli4_write_cq_db(phba, sli4_hba->mbx_cq, 0, LPFC_QUEUE_REARM); in lpfc_sli4_arm_cqeq_intr()
6152 sli4_hba->sli4_write_cq_db(phba, sli4_hba->els_cq, 0, LPFC_QUEUE_REARM); in lpfc_sli4_arm_cqeq_intr()
6153 if (sli4_hba->nvmels_cq) in lpfc_sli4_arm_cqeq_intr()
6154 sli4_hba->sli4_write_cq_db(phba, sli4_hba->nvmels_cq, 0, in lpfc_sli4_arm_cqeq_intr()
6157 if (sli4_hba->hdwq) { in lpfc_sli4_arm_cqeq_intr()
6159 for (qidx = 0; qidx < phba->cfg_hdw_queue; qidx++) { in lpfc_sli4_arm_cqeq_intr()
6160 qp = &sli4_hba->hdwq[qidx]; in lpfc_sli4_arm_cqeq_intr()
6162 sli4_hba->sli4_write_cq_db(phba, qp->io_cq, 0, in lpfc_sli4_arm_cqeq_intr()
6167 for (qidx = 0; qidx < phba->cfg_irq_chann; qidx++) { in lpfc_sli4_arm_cqeq_intr()
6168 eq = sli4_hba->hba_eq_hdl[qidx].eq; in lpfc_sli4_arm_cqeq_intr()
6170 sli4_hba->sli4_write_eq_db(phba, eq, in lpfc_sli4_arm_cqeq_intr()
6175 if (phba->nvmet_support) { in lpfc_sli4_arm_cqeq_intr()
6176 for (qidx = 0; qidx < phba->cfg_nvmet_mrq; qidx++) { in lpfc_sli4_arm_cqeq_intr()
6177 sli4_hba->sli4_write_cq_db(phba, in lpfc_sli4_arm_cqeq_intr()
6178 sli4_hba->nvmet_cqset[qidx], 0, in lpfc_sli4_arm_cqeq_intr()
6185 * lpfc_sli4_get_avail_extnt_rsrc - Get available resource extent count.
6209 mbox = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_get_avail_extnt_rsrc()
6211 return -ENOMEM; in lpfc_sli4_get_avail_extnt_rsrc()
6214 length = (sizeof(struct lpfc_mbx_get_rsrc_extent_info) - in lpfc_sli4_get_avail_extnt_rsrc()
6220 /* Send an extents count of 0 - the GET doesn't use it. */ in lpfc_sli4_get_avail_extnt_rsrc()
6224 rc = -EIO; in lpfc_sli4_get_avail_extnt_rsrc()
6228 if (!phba->sli4_hba.intr_enable) in lpfc_sli4_get_avail_extnt_rsrc()
6235 rc = -EIO; in lpfc_sli4_get_avail_extnt_rsrc()
6239 rsrc_info = &mbox->u.mqe.un.rsrc_extent_info; in lpfc_sli4_get_avail_extnt_rsrc()
6241 &rsrc_info->header.cfg_shdr.response)) { in lpfc_sli4_get_avail_extnt_rsrc()
6246 &rsrc_info->header.cfg_shdr.response), in lpfc_sli4_get_avail_extnt_rsrc()
6248 &rsrc_info->header.cfg_shdr.response)); in lpfc_sli4_get_avail_extnt_rsrc()
6249 rc = -EIO; in lpfc_sli4_get_avail_extnt_rsrc()
6254 &rsrc_info->u.rsp); in lpfc_sli4_get_avail_extnt_rsrc()
6256 &rsrc_info->u.rsp); in lpfc_sli4_get_avail_extnt_rsrc()
6259 "3162 Retrieved extents type-%d from port: count:%d, " in lpfc_sli4_get_avail_extnt_rsrc()
6263 mempool_free(mbox, phba->mbox_mem_pool); in lpfc_sli4_get_avail_extnt_rsrc()
6268 * lpfc_sli4_chk_avail_extnt_rsrc - Check for available SLI4 resource extents.
6278 * -Error: error indicates problem.
6297 return -EIO; in lpfc_sli4_chk_avail_extnt_rsrc()
6301 rsrc_blk_list = &phba->sli4_hba.lpfc_rpi_blk_list; in lpfc_sli4_chk_avail_extnt_rsrc()
6304 rsrc_blk_list = &phba->lpfc_vpi_blk_list; in lpfc_sli4_chk_avail_extnt_rsrc()
6307 rsrc_blk_list = &phba->sli4_hba.lpfc_xri_blk_list; in lpfc_sli4_chk_avail_extnt_rsrc()
6310 rsrc_blk_list = &phba->sli4_hba.lpfc_vfi_blk_list; in lpfc_sli4_chk_avail_extnt_rsrc()
6318 if (rsrc_entry->rsrc_size != rsrc_ext_size) in lpfc_sli4_chk_avail_extnt_rsrc()
6329 * lpfc_sli4_cfg_post_extnts -
6334 * @mbox: pointer to the caller's allocated mailbox structure.
6342 * -Error: Error value describes the condition found.
6358 * Calculate the size of an embedded mailbox. The uint32_t in lpfc_sli4_cfg_post_extnts()
6359 * accounts for extents-specific word. in lpfc_sli4_cfg_post_extnts()
6361 emb_len = sizeof(MAILBOX_t) - sizeof(struct mbox_header) - in lpfc_sli4_cfg_post_extnts()
6366 * mailbox. If not true, reconfigure to a non-embedded mailbox. in lpfc_sli4_cfg_post_extnts()
6384 return -ENOMEM; in lpfc_sli4_cfg_post_extnts()
6388 return -EIO; in lpfc_sli4_cfg_post_extnts()
6390 if (!phba->sli4_hba.intr_enable) in lpfc_sli4_cfg_post_extnts()
6398 rc = -EIO; in lpfc_sli4_cfg_post_extnts()
6403 * lpfc_sli4_alloc_extent - Allocate an SLI4 resource extent.
6433 return -EIO; in lpfc_sli4_alloc_extent()
6441 return -ENOMEM; in lpfc_sli4_alloc_extent()
6445 "2903 Post resource extents type-0x%x: " in lpfc_sli4_alloc_extent()
6448 mbox = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_alloc_extent()
6450 return -ENOMEM; in lpfc_sli4_alloc_extent()
6454 rc = -EIO; in lpfc_sli4_alloc_extent()
6465 rsrc_ext = &mbox->u.mqe.un.alloc_rsrc_extents; in lpfc_sli4_alloc_extent()
6466 id_array = &rsrc_ext->u.rsp.id[0]; in lpfc_sli4_alloc_extent()
6467 rsrc_cnt = bf_get(lpfc_mbx_rsrc_cnt, &rsrc_ext->u.rsp); in lpfc_sli4_alloc_extent()
6469 virtaddr = mbox->sge_array->addr[0]; in lpfc_sli4_alloc_extent()
6472 id_array = &n_rsrc->id; in lpfc_sli4_alloc_extent()
6475 longs = ((rsrc_cnt * rsrc_size) + BITS_PER_LONG - 1) / BITS_PER_LONG; in lpfc_sli4_alloc_extent()
6485 phba->sli4_hba.rpi_bmask = kcalloc(longs, in lpfc_sli4_alloc_extent()
6488 if (unlikely(!phba->sli4_hba.rpi_bmask)) { in lpfc_sli4_alloc_extent()
6489 rc = -ENOMEM; in lpfc_sli4_alloc_extent()
6492 phba->sli4_hba.rpi_ids = kcalloc(rsrc_id_cnt, in lpfc_sli4_alloc_extent()
6495 if (unlikely(!phba->sli4_hba.rpi_ids)) { in lpfc_sli4_alloc_extent()
6496 kfree(phba->sli4_hba.rpi_bmask); in lpfc_sli4_alloc_extent()
6497 rc = -ENOMEM; in lpfc_sli4_alloc_extent()
6506 phba->sli4_hba.next_rpi = rsrc_id_cnt; in lpfc_sli4_alloc_extent()
6509 bmask = phba->sli4_hba.rpi_bmask; in lpfc_sli4_alloc_extent()
6510 ids = phba->sli4_hba.rpi_ids; in lpfc_sli4_alloc_extent()
6511 ext_blk_list = &phba->sli4_hba.lpfc_rpi_blk_list; in lpfc_sli4_alloc_extent()
6514 phba->vpi_bmask = kcalloc(longs, sizeof(unsigned long), in lpfc_sli4_alloc_extent()
6516 if (unlikely(!phba->vpi_bmask)) { in lpfc_sli4_alloc_extent()
6517 rc = -ENOMEM; in lpfc_sli4_alloc_extent()
6520 phba->vpi_ids = kcalloc(rsrc_id_cnt, sizeof(uint16_t), in lpfc_sli4_alloc_extent()
6522 if (unlikely(!phba->vpi_ids)) { in lpfc_sli4_alloc_extent()
6523 kfree(phba->vpi_bmask); in lpfc_sli4_alloc_extent()
6524 rc = -ENOMEM; in lpfc_sli4_alloc_extent()
6529 bmask = phba->vpi_bmask; in lpfc_sli4_alloc_extent()
6530 ids = phba->vpi_ids; in lpfc_sli4_alloc_extent()
6531 ext_blk_list = &phba->lpfc_vpi_blk_list; in lpfc_sli4_alloc_extent()
6534 phba->sli4_hba.xri_bmask = kcalloc(longs, in lpfc_sli4_alloc_extent()
6537 if (unlikely(!phba->sli4_hba.xri_bmask)) { in lpfc_sli4_alloc_extent()
6538 rc = -ENOMEM; in lpfc_sli4_alloc_extent()
6541 phba->sli4_hba.max_cfg_param.xri_used = 0; in lpfc_sli4_alloc_extent()
6542 phba->sli4_hba.xri_ids = kcalloc(rsrc_id_cnt, in lpfc_sli4_alloc_extent()
6545 if (unlikely(!phba->sli4_hba.xri_ids)) { in lpfc_sli4_alloc_extent()
6546 kfree(phba->sli4_hba.xri_bmask); in lpfc_sli4_alloc_extent()
6547 rc = -ENOMEM; in lpfc_sli4_alloc_extent()
6552 bmask = phba->sli4_hba.xri_bmask; in lpfc_sli4_alloc_extent()
6553 ids = phba->sli4_hba.xri_ids; in lpfc_sli4_alloc_extent()
6554 ext_blk_list = &phba->sli4_hba.lpfc_xri_blk_list; in lpfc_sli4_alloc_extent()
6557 phba->sli4_hba.vfi_bmask = kcalloc(longs, in lpfc_sli4_alloc_extent()
6560 if (unlikely(!phba->sli4_hba.vfi_bmask)) { in lpfc_sli4_alloc_extent()
6561 rc = -ENOMEM; in lpfc_sli4_alloc_extent()
6564 phba->sli4_hba.vfi_ids = kcalloc(rsrc_id_cnt, in lpfc_sli4_alloc_extent()
6567 if (unlikely(!phba->sli4_hba.vfi_ids)) { in lpfc_sli4_alloc_extent()
6568 kfree(phba->sli4_hba.vfi_bmask); in lpfc_sli4_alloc_extent()
6569 rc = -ENOMEM; in lpfc_sli4_alloc_extent()
6574 bmask = phba->sli4_hba.vfi_bmask; in lpfc_sli4_alloc_extent()
6575 ids = phba->sli4_hba.vfi_ids; in lpfc_sli4_alloc_extent()
6576 ext_blk_list = &phba->sli4_hba.lpfc_vfi_blk_list; in lpfc_sli4_alloc_extent()
6603 rc = -ENOMEM; in lpfc_sli4_alloc_extent()
6608 rsrc_blks->rsrc_start = rsrc_id; in lpfc_sli4_alloc_extent()
6609 rsrc_blks->rsrc_size = rsrc_size; in lpfc_sli4_alloc_extent()
6610 list_add_tail(&rsrc_blks->list, ext_blk_list); in lpfc_sli4_alloc_extent()
6613 phba->sli4_hba.io_xri_start = rsrc_start + in lpfc_sli4_alloc_extent()
6634 * lpfc_sli4_dealloc_extent - Deallocate an SLI4 resource extent.
6651 mbox = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_dealloc_extent()
6653 return -ENOMEM; in lpfc_sli4_dealloc_extent()
6656 * This function sends an embedded mailbox because it only sends the in lpfc_sli4_dealloc_extent()
6660 length = (sizeof(struct lpfc_mbx_dealloc_rsrc_extents) - in lpfc_sli4_dealloc_extent()
6666 /* Send an extents count of 0 - the dealloc doesn't use it. */ in lpfc_sli4_dealloc_extent()
6670 rc = -EIO; in lpfc_sli4_dealloc_extent()
6673 if (!phba->sli4_hba.intr_enable) in lpfc_sli4_dealloc_extent()
6680 rc = -EIO; in lpfc_sli4_dealloc_extent()
6684 dealloc_rsrc = &mbox->u.mqe.un.dealloc_rsrc_extents; in lpfc_sli4_dealloc_extent()
6686 &dealloc_rsrc->header.cfg_shdr.response)) { in lpfc_sli4_dealloc_extent()
6689 "for type %d - Status 0x%x Add'l Status 0x%x. " in lpfc_sli4_dealloc_extent()
6693 &dealloc_rsrc->header.cfg_shdr.response), in lpfc_sli4_dealloc_extent()
6695 &dealloc_rsrc->header.cfg_shdr.response)); in lpfc_sli4_dealloc_extent()
6696 rc = -EIO; in lpfc_sli4_dealloc_extent()
6703 kfree(phba->vpi_bmask); in lpfc_sli4_dealloc_extent()
6704 kfree(phba->vpi_ids); in lpfc_sli4_dealloc_extent()
6705 bf_set(lpfc_vpi_rsrc_rdy, &phba->sli4_hba.sli4_flags, 0); in lpfc_sli4_dealloc_extent()
6707 &phba->lpfc_vpi_blk_list, list) { in lpfc_sli4_dealloc_extent()
6708 list_del_init(&rsrc_blk->list); in lpfc_sli4_dealloc_extent()
6711 phba->sli4_hba.max_cfg_param.vpi_used = 0; in lpfc_sli4_dealloc_extent()
6714 kfree(phba->sli4_hba.xri_bmask); in lpfc_sli4_dealloc_extent()
6715 kfree(phba->sli4_hba.xri_ids); in lpfc_sli4_dealloc_extent()
6717 &phba->sli4_hba.lpfc_xri_blk_list, list) { in lpfc_sli4_dealloc_extent()
6718 list_del_init(&rsrc_blk->list); in lpfc_sli4_dealloc_extent()
6723 kfree(phba->sli4_hba.vfi_bmask); in lpfc_sli4_dealloc_extent()
6724 kfree(phba->sli4_hba.vfi_ids); in lpfc_sli4_dealloc_extent()
6725 bf_set(lpfc_vfi_rsrc_rdy, &phba->sli4_hba.sli4_flags, 0); in lpfc_sli4_dealloc_extent()
6727 &phba->sli4_hba.lpfc_vfi_blk_list, list) { in lpfc_sli4_dealloc_extent()
6728 list_del_init(&rsrc_blk->list); in lpfc_sli4_dealloc_extent()
6735 &phba->sli4_hba.lpfc_rpi_blk_list, list) { in lpfc_sli4_dealloc_extent()
6736 list_del_init(&rsrc_blk->list); in lpfc_sli4_dealloc_extent()
6744 bf_set(lpfc_idx_rsrc_rdy, &phba->sli4_hba.sli4_flags, 0); in lpfc_sli4_dealloc_extent()
6747 mempool_free(mbox, phba->mbox_mem_pool); in lpfc_sli4_dealloc_extent()
6758 len = sizeof(struct lpfc_mbx_set_feature) - in lpfc_set_features()
6767 &mbox->u.mqe.un.set_feature, 1); in lpfc_set_features()
6768 mbox->u.mqe.un.set_feature.feature = LPFC_SET_UE_RECOVERY; in lpfc_set_features()
6769 mbox->u.mqe.un.set_feature.param_len = 8; in lpfc_set_features()
6773 &mbox->u.mqe.un.set_feature, 1); in lpfc_set_features()
6775 &mbox->u.mqe.un.set_feature, 1); in lpfc_set_features()
6776 mbox->u.mqe.un.set_feature.feature = LPFC_SET_MDS_DIAGS; in lpfc_set_features()
6777 mbox->u.mqe.un.set_feature.param_len = 8; in lpfc_set_features()
6780 if (phba->cmf_active_mode == LPFC_CFG_OFF) in lpfc_set_features()
6783 sig_freq = phba->cgn_sig_freq; in lpfc_set_features()
6785 if (phba->cgn_reg_signal == EDC_CG_SIG_WARN_ALARM) { in lpfc_set_features()
6787 &mbox->u.mqe.un.set_feature, sig_freq); in lpfc_set_features()
6789 &mbox->u.mqe.un.set_feature, sig_freq); in lpfc_set_features()
6792 if (phba->cgn_reg_signal == EDC_CG_SIG_WARN_ONLY) in lpfc_set_features()
6794 &mbox->u.mqe.un.set_feature, sig_freq); in lpfc_set_features()
6796 if (phba->cmf_active_mode == LPFC_CFG_OFF || in lpfc_set_features()
6797 phba->cgn_reg_signal == EDC_CG_SIG_NOTSUPPORTED) in lpfc_set_features()
6803 &mbox->u.mqe.un.set_feature, sig_freq); in lpfc_set_features()
6805 mbox->u.mqe.un.set_feature.feature = LPFC_SET_CGN_SIGNAL; in lpfc_set_features()
6806 mbox->u.mqe.un.set_feature.param_len = 12; in lpfc_set_features()
6810 &mbox->u.mqe.un.set_feature, LPFC_ENABLE_DUAL_DUMP); in lpfc_set_features()
6812 &mbox->u.mqe.un.set_feature, 0); in lpfc_set_features()
6813 mbox->u.mqe.un.set_feature.feature = LPFC_SET_DUAL_DUMP; in lpfc_set_features()
6814 mbox->u.mqe.un.set_feature.param_len = 4; in lpfc_set_features()
6817 mbox->u.mqe.un.set_feature.feature = LPFC_SET_ENABLE_MI; in lpfc_set_features()
6818 mbox->u.mqe.un.set_feature.param_len = 4; in lpfc_set_features()
6819 bf_set(lpfc_mbx_set_feature_milunq, &mbox->u.mqe.un.set_feature, in lpfc_set_features()
6820 phba->pport->cfg_lun_queue_depth); in lpfc_set_features()
6821 bf_set(lpfc_mbx_set_feature_mi, &mbox->u.mqe.un.set_feature, in lpfc_set_features()
6822 phba->sli4_hba.pc_sli4_params.mi_ver); in lpfc_set_features()
6825 mbox->u.mqe.un.set_feature.feature = LPFC_SET_LD_SIGNAL; in lpfc_set_features()
6826 mbox->u.mqe.un.set_feature.param_len = 16; in lpfc_set_features()
6828 &mbox->u.mqe.un.set_feature, LPFC_QUERY_LDS_OP); in lpfc_set_features()
6831 mbox->u.mqe.un.set_feature.feature = LPFC_SET_ENABLE_CMF; in lpfc_set_features()
6832 mbox->u.mqe.un.set_feature.param_len = 4; in lpfc_set_features()
6834 &mbox->u.mqe.un.set_feature, 1); in lpfc_set_features()
6850 struct lpfc_ras_fwlog *ras_fwlog = &phba->ras_fwlog; in lpfc_ras_stop_fwlog()
6852 spin_lock_irq(&phba->ras_fwlog_lock); in lpfc_ras_stop_fwlog()
6853 ras_fwlog->state = INACTIVE; in lpfc_ras_stop_fwlog()
6854 spin_unlock_irq(&phba->ras_fwlog_lock); in lpfc_ras_stop_fwlog()
6858 phba->sli4_hba.conf_regs_memmap_p + LPFC_CTL_PDEV_CTL_OFFSET); in lpfc_ras_stop_fwlog()
6865 * lpfc_sli4_ras_dma_free - Free memory allocated for FW logging.
6874 struct lpfc_ras_fwlog *ras_fwlog = &phba->ras_fwlog; in lpfc_sli4_ras_dma_free()
6877 if (!list_empty(&ras_fwlog->fwlog_buff_list)) { in lpfc_sli4_ras_dma_free()
6879 &ras_fwlog->fwlog_buff_list, in lpfc_sli4_ras_dma_free()
6881 list_del(&dmabuf->list); in lpfc_sli4_ras_dma_free()
6882 dma_free_coherent(&phba->pcidev->dev, in lpfc_sli4_ras_dma_free()
6884 dmabuf->virt, dmabuf->phys); in lpfc_sli4_ras_dma_free()
6889 if (ras_fwlog->lwpd.virt) { in lpfc_sli4_ras_dma_free()
6890 dma_free_coherent(&phba->pcidev->dev, in lpfc_sli4_ras_dma_free()
6892 ras_fwlog->lwpd.virt, in lpfc_sli4_ras_dma_free()
6893 ras_fwlog->lwpd.phys); in lpfc_sli4_ras_dma_free()
6894 ras_fwlog->lwpd.virt = NULL; in lpfc_sli4_ras_dma_free()
6897 spin_lock_irq(&phba->ras_fwlog_lock); in lpfc_sli4_ras_dma_free()
6898 ras_fwlog->state = INACTIVE; in lpfc_sli4_ras_dma_free()
6899 spin_unlock_irq(&phba->ras_fwlog_lock); in lpfc_sli4_ras_dma_free()
6917 struct lpfc_ras_fwlog *ras_fwlog = &phba->ras_fwlog; in lpfc_sli4_ras_dma_alloc()
6922 INIT_LIST_HEAD(&ras_fwlog->fwlog_buff_list); in lpfc_sli4_ras_dma_alloc()
6925 ras_fwlog->lwpd.virt = dma_alloc_coherent(&phba->pcidev->dev, in lpfc_sli4_ras_dma_alloc()
6927 &ras_fwlog->lwpd.phys, in lpfc_sli4_ras_dma_alloc()
6929 if (!ras_fwlog->lwpd.virt) { in lpfc_sli4_ras_dma_alloc()
6933 return -ENOMEM; in lpfc_sli4_ras_dma_alloc()
6936 ras_fwlog->fw_buffcount = fwlog_buff_count; in lpfc_sli4_ras_dma_alloc()
6937 for (i = 0; i < ras_fwlog->fw_buffcount; i++) { in lpfc_sli4_ras_dma_alloc()
6941 rc = -ENOMEM; in lpfc_sli4_ras_dma_alloc()
6947 dmabuf->virt = dma_alloc_coherent(&phba->pcidev->dev, in lpfc_sli4_ras_dma_alloc()
6949 &dmabuf->phys, GFP_KERNEL); in lpfc_sli4_ras_dma_alloc()
6950 if (!dmabuf->virt) { in lpfc_sli4_ras_dma_alloc()
6952 rc = -ENOMEM; in lpfc_sli4_ras_dma_alloc()
6957 dmabuf->buffer_tag = i; in lpfc_sli4_ras_dma_alloc()
6958 list_add_tail(&dmabuf->list, &ras_fwlog->fwlog_buff_list); in lpfc_sli4_ras_dma_alloc()
6971 * @pmb: pointer to the driver internal queue element for mailbox command.
6981 struct lpfc_ras_fwlog *ras_fwlog = &phba->ras_fwlog; in lpfc_sli4_ras_mbox_cmpl()
6983 mb = &pmb->u.mb; in lpfc_sli4_ras_mbox_cmpl()
6986 &pmb->u.mqe.un.ras_fwlog.header.cfg_shdr; in lpfc_sli4_ras_mbox_cmpl()
6987 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_sli4_ras_mbox_cmpl()
6988 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_sli4_ras_mbox_cmpl()
6990 if (mb->mbxStatus != MBX_SUCCESS || shdr_status) { in lpfc_sli4_ras_mbox_cmpl()
6992 "6188 FW LOG mailbox " in lpfc_sli4_ras_mbox_cmpl()
6995 shdr_status, shdr_add_status, mb->mbxStatus); in lpfc_sli4_ras_mbox_cmpl()
6997 ras_fwlog->ras_hwsupport = false; in lpfc_sli4_ras_mbox_cmpl()
7001 spin_lock_irq(&phba->ras_fwlog_lock); in lpfc_sli4_ras_mbox_cmpl()
7002 ras_fwlog->state = ACTIVE; in lpfc_sli4_ras_mbox_cmpl()
7003 spin_unlock_irq(&phba->ras_fwlog_lock); in lpfc_sli4_ras_mbox_cmpl()
7004 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_sli4_ras_mbox_cmpl()
7011 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_sli4_ras_mbox_cmpl()
7020 * Initialize memory and post mailbox command to enable FW logging in host
7028 struct lpfc_ras_fwlog *ras_fwlog = &phba->ras_fwlog; in lpfc_sli4_ras_fwlog_init()
7035 spin_lock_irq(&phba->ras_fwlog_lock); in lpfc_sli4_ras_fwlog_init()
7036 ras_fwlog->state = INACTIVE; in lpfc_sli4_ras_fwlog_init()
7037 spin_unlock_irq(&phba->ras_fwlog_lock); in lpfc_sli4_ras_fwlog_init()
7040 phba->cfg_ras_fwlog_buffsize); in lpfc_sli4_ras_fwlog_init()
7044 * If re-enabling FW logging support use earlier allocated in lpfc_sli4_ras_fwlog_init()
7047 if (!ras_fwlog->lwpd.virt) { in lpfc_sli4_ras_fwlog_init()
7056 /* Setup Mailbox command */ in lpfc_sli4_ras_fwlog_init()
7057 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_ras_fwlog_init()
7061 rc = -ENOMEM; in lpfc_sli4_ras_fwlog_init()
7065 ras_fwlog->fw_loglevel = fwlog_level; in lpfc_sli4_ras_fwlog_init()
7066 len = (sizeof(struct lpfc_mbx_set_ras_fwlog) - in lpfc_sli4_ras_fwlog_init()
7073 mbx_fwlog = (struct lpfc_mbx_set_ras_fwlog *)&mbox->u.mqe.un.ras_fwlog; in lpfc_sli4_ras_fwlog_init()
7074 bf_set(lpfc_fwlog_enable, &mbx_fwlog->u.request, in lpfc_sli4_ras_fwlog_init()
7076 bf_set(lpfc_fwlog_loglvl, &mbx_fwlog->u.request, in lpfc_sli4_ras_fwlog_init()
7077 ras_fwlog->fw_loglevel); in lpfc_sli4_ras_fwlog_init()
7078 bf_set(lpfc_fwlog_buffcnt, &mbx_fwlog->u.request, in lpfc_sli4_ras_fwlog_init()
7079 ras_fwlog->fw_buffcount); in lpfc_sli4_ras_fwlog_init()
7080 bf_set(lpfc_fwlog_buffsz, &mbx_fwlog->u.request, in lpfc_sli4_ras_fwlog_init()
7084 list_for_each_entry(dmabuf, &ras_fwlog->fwlog_buff_list, list) { in lpfc_sli4_ras_fwlog_init()
7085 memset(dmabuf->virt, 0, LPFC_RAS_MAX_ENTRY_SIZE); in lpfc_sli4_ras_fwlog_init()
7087 mbx_fwlog->u.request.buff_fwlog[dmabuf->buffer_tag].addr_lo = in lpfc_sli4_ras_fwlog_init()
7088 putPaddrLow(dmabuf->phys); in lpfc_sli4_ras_fwlog_init()
7090 mbx_fwlog->u.request.buff_fwlog[dmabuf->buffer_tag].addr_hi = in lpfc_sli4_ras_fwlog_init()
7091 putPaddrHigh(dmabuf->phys); in lpfc_sli4_ras_fwlog_init()
7095 mbx_fwlog->u.request.lwpd.addr_lo = putPaddrLow(ras_fwlog->lwpd.phys); in lpfc_sli4_ras_fwlog_init()
7096 mbx_fwlog->u.request.lwpd.addr_hi = putPaddrHigh(ras_fwlog->lwpd.phys); in lpfc_sli4_ras_fwlog_init()
7098 spin_lock_irq(&phba->ras_fwlog_lock); in lpfc_sli4_ras_fwlog_init()
7099 ras_fwlog->state = REG_INPROGRESS; in lpfc_sli4_ras_fwlog_init()
7100 spin_unlock_irq(&phba->ras_fwlog_lock); in lpfc_sli4_ras_fwlog_init()
7101 mbox->vport = phba->pport; in lpfc_sli4_ras_fwlog_init()
7102 mbox->mbox_cmpl = lpfc_sli4_ras_mbox_cmpl; in lpfc_sli4_ras_fwlog_init()
7108 "6191 FW-Log Mailbox failed. " in lpfc_sli4_ras_fwlog_init()
7110 bf_get(lpfc_mqe_status, &mbox->u.mqe)); in lpfc_sli4_ras_fwlog_init()
7111 mempool_free(mbox, phba->mbox_mem_pool); in lpfc_sli4_ras_fwlog_init()
7112 rc = -EIO; in lpfc_sli4_ras_fwlog_init()
7124 * lpfc_sli4_ras_setup - Check if RAS supported on the adapter
7136 lpfc_sli4_ras_fwlog_init(phba, phba->cfg_ras_fwlog_level, in lpfc_sli4_ras_setup()
7141 * lpfc_sli4_alloc_resource_identifiers - Allocate all SLI4 resource extents.
7153 if (!phba->sli4_hba.rpi_hdrs_in_use) in lpfc_sli4_alloc_resource_identifiers()
7154 phba->sli4_hba.next_rpi = phba->sli4_hba.max_cfg_param.max_rpi; in lpfc_sli4_alloc_resource_identifiers()
7155 if (phba->sli4_hba.extents_in_use) { in lpfc_sli4_alloc_resource_identifiers()
7161 if (bf_get(lpfc_idx_rsrc_rdy, &phba->sli4_hba.sli4_flags) == in lpfc_sli4_alloc_resource_identifiers()
7164 * Extent-based resources are set - the driver could in lpfc_sli4_alloc_resource_identifiers()
7224 bf_set(lpfc_idx_rsrc_rdy, &phba->sli4_hba.sli4_flags, in lpfc_sli4_alloc_resource_identifiers()
7233 * need any action - just exit. in lpfc_sli4_alloc_resource_identifiers()
7235 if (bf_get(lpfc_idx_rsrc_rdy, &phba->sli4_hba.sli4_flags) == in lpfc_sli4_alloc_resource_identifiers()
7241 count = phba->sli4_hba.max_cfg_param.max_rpi; in lpfc_sli4_alloc_resource_identifiers()
7246 rc = -EINVAL; in lpfc_sli4_alloc_resource_identifiers()
7249 base = phba->sli4_hba.max_cfg_param.rpi_base; in lpfc_sli4_alloc_resource_identifiers()
7250 longs = (count + BITS_PER_LONG - 1) / BITS_PER_LONG; in lpfc_sli4_alloc_resource_identifiers()
7251 phba->sli4_hba.rpi_bmask = kcalloc(longs, in lpfc_sli4_alloc_resource_identifiers()
7254 if (unlikely(!phba->sli4_hba.rpi_bmask)) { in lpfc_sli4_alloc_resource_identifiers()
7255 rc = -ENOMEM; in lpfc_sli4_alloc_resource_identifiers()
7258 phba->sli4_hba.rpi_ids = kcalloc(count, sizeof(uint16_t), in lpfc_sli4_alloc_resource_identifiers()
7260 if (unlikely(!phba->sli4_hba.rpi_ids)) { in lpfc_sli4_alloc_resource_identifiers()
7261 rc = -ENOMEM; in lpfc_sli4_alloc_resource_identifiers()
7266 phba->sli4_hba.rpi_ids[i] = base + i; in lpfc_sli4_alloc_resource_identifiers()
7269 count = phba->sli4_hba.max_cfg_param.max_vpi; in lpfc_sli4_alloc_resource_identifiers()
7274 rc = -EINVAL; in lpfc_sli4_alloc_resource_identifiers()
7277 base = phba->sli4_hba.max_cfg_param.vpi_base; in lpfc_sli4_alloc_resource_identifiers()
7278 longs = (count + BITS_PER_LONG - 1) / BITS_PER_LONG; in lpfc_sli4_alloc_resource_identifiers()
7279 phba->vpi_bmask = kcalloc(longs, sizeof(unsigned long), in lpfc_sli4_alloc_resource_identifiers()
7281 if (unlikely(!phba->vpi_bmask)) { in lpfc_sli4_alloc_resource_identifiers()
7282 rc = -ENOMEM; in lpfc_sli4_alloc_resource_identifiers()
7285 phba->vpi_ids = kcalloc(count, sizeof(uint16_t), in lpfc_sli4_alloc_resource_identifiers()
7287 if (unlikely(!phba->vpi_ids)) { in lpfc_sli4_alloc_resource_identifiers()
7288 rc = -ENOMEM; in lpfc_sli4_alloc_resource_identifiers()
7293 phba->vpi_ids[i] = base + i; in lpfc_sli4_alloc_resource_identifiers()
7296 count = phba->sli4_hba.max_cfg_param.max_xri; in lpfc_sli4_alloc_resource_identifiers()
7301 rc = -EINVAL; in lpfc_sli4_alloc_resource_identifiers()
7304 base = phba->sli4_hba.max_cfg_param.xri_base; in lpfc_sli4_alloc_resource_identifiers()
7305 longs = (count + BITS_PER_LONG - 1) / BITS_PER_LONG; in lpfc_sli4_alloc_resource_identifiers()
7306 phba->sli4_hba.xri_bmask = kcalloc(longs, in lpfc_sli4_alloc_resource_identifiers()
7309 if (unlikely(!phba->sli4_hba.xri_bmask)) { in lpfc_sli4_alloc_resource_identifiers()
7310 rc = -ENOMEM; in lpfc_sli4_alloc_resource_identifiers()
7313 phba->sli4_hba.max_cfg_param.xri_used = 0; in lpfc_sli4_alloc_resource_identifiers()
7314 phba->sli4_hba.xri_ids = kcalloc(count, sizeof(uint16_t), in lpfc_sli4_alloc_resource_identifiers()
7316 if (unlikely(!phba->sli4_hba.xri_ids)) { in lpfc_sli4_alloc_resource_identifiers()
7317 rc = -ENOMEM; in lpfc_sli4_alloc_resource_identifiers()
7322 phba->sli4_hba.xri_ids[i] = base + i; in lpfc_sli4_alloc_resource_identifiers()
7325 count = phba->sli4_hba.max_cfg_param.max_vfi; in lpfc_sli4_alloc_resource_identifiers()
7330 rc = -EINVAL; in lpfc_sli4_alloc_resource_identifiers()
7333 base = phba->sli4_hba.max_cfg_param.vfi_base; in lpfc_sli4_alloc_resource_identifiers()
7334 longs = (count + BITS_PER_LONG - 1) / BITS_PER_LONG; in lpfc_sli4_alloc_resource_identifiers()
7335 phba->sli4_hba.vfi_bmask = kcalloc(longs, in lpfc_sli4_alloc_resource_identifiers()
7338 if (unlikely(!phba->sli4_hba.vfi_bmask)) { in lpfc_sli4_alloc_resource_identifiers()
7339 rc = -ENOMEM; in lpfc_sli4_alloc_resource_identifiers()
7342 phba->sli4_hba.vfi_ids = kcalloc(count, sizeof(uint16_t), in lpfc_sli4_alloc_resource_identifiers()
7344 if (unlikely(!phba->sli4_hba.vfi_ids)) { in lpfc_sli4_alloc_resource_identifiers()
7345 rc = -ENOMEM; in lpfc_sli4_alloc_resource_identifiers()
7350 phba->sli4_hba.vfi_ids[i] = base + i; in lpfc_sli4_alloc_resource_identifiers()
7356 bf_set(lpfc_idx_rsrc_rdy, &phba->sli4_hba.sli4_flags, in lpfc_sli4_alloc_resource_identifiers()
7362 kfree(phba->sli4_hba.vfi_bmask); in lpfc_sli4_alloc_resource_identifiers()
7363 phba->sli4_hba.vfi_bmask = NULL; in lpfc_sli4_alloc_resource_identifiers()
7365 kfree(phba->sli4_hba.xri_ids); in lpfc_sli4_alloc_resource_identifiers()
7366 phba->sli4_hba.xri_ids = NULL; in lpfc_sli4_alloc_resource_identifiers()
7368 kfree(phba->sli4_hba.xri_bmask); in lpfc_sli4_alloc_resource_identifiers()
7369 phba->sli4_hba.xri_bmask = NULL; in lpfc_sli4_alloc_resource_identifiers()
7371 kfree(phba->vpi_ids); in lpfc_sli4_alloc_resource_identifiers()
7372 phba->vpi_ids = NULL; in lpfc_sli4_alloc_resource_identifiers()
7374 kfree(phba->vpi_bmask); in lpfc_sli4_alloc_resource_identifiers()
7375 phba->vpi_bmask = NULL; in lpfc_sli4_alloc_resource_identifiers()
7377 kfree(phba->sli4_hba.rpi_ids); in lpfc_sli4_alloc_resource_identifiers()
7378 phba->sli4_hba.rpi_ids = NULL; in lpfc_sli4_alloc_resource_identifiers()
7380 kfree(phba->sli4_hba.rpi_bmask); in lpfc_sli4_alloc_resource_identifiers()
7381 phba->sli4_hba.rpi_bmask = NULL; in lpfc_sli4_alloc_resource_identifiers()
7387 * lpfc_sli4_dealloc_resource_identifiers - Deallocate all SLI4 resource extents.
7396 if (phba->sli4_hba.extents_in_use) { in lpfc_sli4_dealloc_resource_identifiers()
7402 kfree(phba->vpi_bmask); in lpfc_sli4_dealloc_resource_identifiers()
7403 phba->sli4_hba.max_cfg_param.vpi_used = 0; in lpfc_sli4_dealloc_resource_identifiers()
7404 kfree(phba->vpi_ids); in lpfc_sli4_dealloc_resource_identifiers()
7405 bf_set(lpfc_vpi_rsrc_rdy, &phba->sli4_hba.sli4_flags, 0); in lpfc_sli4_dealloc_resource_identifiers()
7406 kfree(phba->sli4_hba.xri_bmask); in lpfc_sli4_dealloc_resource_identifiers()
7407 kfree(phba->sli4_hba.xri_ids); in lpfc_sli4_dealloc_resource_identifiers()
7408 kfree(phba->sli4_hba.vfi_bmask); in lpfc_sli4_dealloc_resource_identifiers()
7409 kfree(phba->sli4_hba.vfi_ids); in lpfc_sli4_dealloc_resource_identifiers()
7410 bf_set(lpfc_vfi_rsrc_rdy, &phba->sli4_hba.sli4_flags, 0); in lpfc_sli4_dealloc_resource_identifiers()
7411 bf_set(lpfc_idx_rsrc_rdy, &phba->sli4_hba.sli4_flags, 0); in lpfc_sli4_dealloc_resource_identifiers()
7418 * lpfc_sli4_get_allocated_extnts - Get the port's allocated extents.
7446 blk_list_head = &phba->lpfc_vpi_blk_list; in lpfc_sli4_get_allocated_extnts()
7449 blk_list_head = &phba->sli4_hba.lpfc_xri_blk_list; in lpfc_sli4_get_allocated_extnts()
7452 blk_list_head = &phba->sli4_hba.lpfc_vfi_blk_list; in lpfc_sli4_get_allocated_extnts()
7455 blk_list_head = &phba->sli4_hba.lpfc_rpi_blk_list; in lpfc_sli4_get_allocated_extnts()
7458 return -EIO; in lpfc_sli4_get_allocated_extnts()
7465 * The GET_ALLOCATED mailbox does not return the size, in lpfc_sli4_get_allocated_extnts()
7471 *extnt_size = rsrc_blk->rsrc_size; in lpfc_sli4_get_allocated_extnts()
7477 * Calculate the size of an embedded mailbox. The uint32_t in lpfc_sli4_get_allocated_extnts()
7478 * accounts for extents-specific word. in lpfc_sli4_get_allocated_extnts()
7480 emb_len = sizeof(MAILBOX_t) - sizeof(struct mbox_header) - in lpfc_sli4_get_allocated_extnts()
7485 * mailbox. If not true, reconfigure to a non-embedded mailbox. in lpfc_sli4_get_allocated_extnts()
7496 mbox = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_get_allocated_extnts()
7498 return -ENOMEM; in lpfc_sli4_get_allocated_extnts()
7509 rc = -ENOMEM; in lpfc_sli4_get_allocated_extnts()
7514 rc = -EIO; in lpfc_sli4_get_allocated_extnts()
7518 if (!phba->sli4_hba.intr_enable) in lpfc_sli4_get_allocated_extnts()
7526 rc = -EIO; in lpfc_sli4_get_allocated_extnts()
7537 rsrc_ext = &mbox->u.mqe.un.alloc_rsrc_extents; in lpfc_sli4_get_allocated_extnts()
7538 shdr = &rsrc_ext->header.cfg_shdr; in lpfc_sli4_get_allocated_extnts()
7539 *extnt_cnt = bf_get(lpfc_mbx_rsrc_cnt, &rsrc_ext->u.rsp); in lpfc_sli4_get_allocated_extnts()
7541 virtaddr = mbox->sge_array->addr[0]; in lpfc_sli4_get_allocated_extnts()
7543 shdr = &n_rsrc->cfg_shdr; in lpfc_sli4_get_allocated_extnts()
7547 if (bf_get(lpfc_mbox_hdr_status, &shdr->response)) { in lpfc_sli4_get_allocated_extnts()
7550 "for type %d - Status 0x%x Add'l Status 0x%x.\n", in lpfc_sli4_get_allocated_extnts()
7552 bf_get(lpfc_mbox_hdr_status, &shdr->response), in lpfc_sli4_get_allocated_extnts()
7553 bf_get(lpfc_mbox_hdr_add_status, &shdr->response)); in lpfc_sli4_get_allocated_extnts()
7554 rc = -EIO; in lpfc_sli4_get_allocated_extnts()
7563 * lpfc_sli4_repost_sgl_list - Repost the buffers sgl pages as block
7571 * of buffer sgls which contains contiguous xris and uses the non-embedded
7572 * SGL block post mailbox commands to post them to the port. For single
7573 * buffer sgl with non-contiguous xri, if any, it shall use embedded SGL post
7574 * mailbox command for posting.
7576 * Returns: 0 = success, non-zero failure.
7594 spin_lock_irq(&phba->hbalock); in lpfc_sli4_repost_sgl_list()
7595 spin_lock(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_repost_sgl_list()
7597 spin_unlock(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_repost_sgl_list()
7598 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_repost_sgl_list()
7603 list_del_init(&sglq_entry->list); in lpfc_sli4_repost_sgl_list()
7606 (sglq_entry->sli4_xritag != last_xritag + 1)) { in lpfc_sli4_repost_sgl_list()
7609 post_cnt = block_cnt - 1; in lpfc_sli4_repost_sgl_list()
7611 list_add_tail(&sglq_entry->list, &prep_sgl_list); in lpfc_sli4_repost_sgl_list()
7615 list_add_tail(&sglq_entry->list, &prep_sgl_list); in lpfc_sli4_repost_sgl_list()
7616 /* enough sgls for non-embed sgl mbox command */ in lpfc_sli4_repost_sgl_list()
7627 last_xritag = sglq_entry->sli4_xritag; in lpfc_sli4_repost_sgl_list()
7637 sglq_entry->phys, 0, in lpfc_sli4_repost_sgl_list()
7638 sglq_entry->sli4_xritag); in lpfc_sli4_repost_sgl_list()
7641 list_add_tail(&sglq_entry->list, in lpfc_sli4_repost_sgl_list()
7649 sglq_entry->sli4_xritag); in lpfc_sli4_repost_sgl_list()
7650 list_add_tail(&sglq_entry->list, in lpfc_sli4_repost_sgl_list()
7652 total_cnt--; in lpfc_sli4_repost_sgl_list()
7674 "3160 Failed to post sgl-list, " in lpfc_sli4_repost_sgl_list()
7675 "xritag:x%x-x%x\n", in lpfc_sli4_repost_sgl_list()
7676 sglq_entry_first->sli4_xritag, in lpfc_sli4_repost_sgl_list()
7677 (sglq_entry_first->sli4_xritag + in lpfc_sli4_repost_sgl_list()
7678 post_cnt - 1)); in lpfc_sli4_repost_sgl_list()
7680 total_cnt -= post_cnt; in lpfc_sli4_repost_sgl_list()
7696 spin_lock_irq(&phba->hbalock); in lpfc_sli4_repost_sgl_list()
7697 spin_lock(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_repost_sgl_list()
7699 spin_unlock(&phba->sli4_hba.sgl_list_lock); in lpfc_sli4_repost_sgl_list()
7700 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_repost_sgl_list()
7706 return -EIO; in lpfc_sli4_repost_sgl_list()
7714 * lpfc_sli4_repost_io_sgl_list - Repost all the allocated nvme buffer sgls
7723 * Returns: 0 = success, non-zero failure.
7737 phba, &post_nblist, phba->sli4_hba.io_xri_cnt); in lpfc_sli4_repost_io_sgl_list()
7740 rc = -EIO; in lpfc_sli4_repost_io_sgl_list()
7750 len = sizeof(struct lpfc_mbx_set_host_data) - in lpfc_set_host_data()
7756 mbox->u.mqe.un.set_host_data.param_id = LPFC_SET_HOST_OS_DRIVER_VERSION; in lpfc_set_host_data()
7757 mbox->u.mqe.un.set_host_data.param_len = in lpfc_set_host_data()
7759 snprintf(mbox->u.mqe.un.set_host_data.un.data, in lpfc_set_host_data()
7762 test_bit(HBA_FCOE_MODE, &phba->hba_flag) ? "FCoE" : "FC"); in lpfc_set_host_data()
7777 rqbp = hrq->rqbp; in lpfc_post_rq_buffer()
7779 spin_lock_irqsave(&phba->hbalock, flags); in lpfc_post_rq_buffer()
7781 if (rqbp->buffer_count + i >= rqbp->entry_count - 1) { in lpfc_post_rq_buffer()
7782 spin_unlock_irqrestore(&phba->hbalock, flags); in lpfc_post_rq_buffer()
7785 spin_unlock_irqrestore(&phba->hbalock, flags); in lpfc_post_rq_buffer()
7787 rqb_buffer = rqbp->rqb_alloc_buffer(phba); in lpfc_post_rq_buffer()
7790 rqb_buffer->hrq = hrq; in lpfc_post_rq_buffer()
7791 rqb_buffer->drq = drq; in lpfc_post_rq_buffer()
7792 rqb_buffer->idx = idx; in lpfc_post_rq_buffer()
7793 list_add_tail(&rqb_buffer->hbuf.list, &rqb_buf_list); in lpfc_post_rq_buffer()
7796 spin_lock_irqsave(&phba->hbalock, flags); in lpfc_post_rq_buffer()
7801 hrqe.address_lo = putPaddrLow(rqb_buffer->hbuf.phys); in lpfc_post_rq_buffer()
7802 hrqe.address_hi = putPaddrHigh(rqb_buffer->hbuf.phys); in lpfc_post_rq_buffer()
7803 drqe.address_lo = putPaddrLow(rqb_buffer->dbuf.phys); in lpfc_post_rq_buffer()
7804 drqe.address_hi = putPaddrHigh(rqb_buffer->dbuf.phys); in lpfc_post_rq_buffer()
7810 hrq->queue_id, in lpfc_post_rq_buffer()
7811 hrq->host_index, in lpfc_post_rq_buffer()
7812 hrq->hba_index, in lpfc_post_rq_buffer()
7813 hrq->entry_count, in lpfc_post_rq_buffer()
7814 drq->host_index, in lpfc_post_rq_buffer()
7815 drq->hba_index); in lpfc_post_rq_buffer()
7816 rqbp->rqb_free_buffer(phba, rqb_buffer); in lpfc_post_rq_buffer()
7818 list_add_tail(&rqb_buffer->hbuf.list, in lpfc_post_rq_buffer()
7819 &rqbp->rqb_buffer_list); in lpfc_post_rq_buffer()
7820 rqbp->buffer_count++; in lpfc_post_rq_buffer()
7823 spin_unlock_irqrestore(&phba->hbalock, flags); in lpfc_post_rq_buffer()
7834 &pmb->u.mqe.un.sli4_config.header.cfg_shdr; in lpfc_mbx_cmpl_read_lds_params()
7835 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_mbx_cmpl_read_lds_params()
7836 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_mbx_cmpl_read_lds_params()
7837 if (shdr_status || shdr_add_status || pmb->u.mb.mbxStatus) { in lpfc_mbx_cmpl_read_lds_params()
7842 shdr_add_status, pmb->u.mb.mbxStatus); in lpfc_mbx_cmpl_read_lds_params()
7843 phba->degrade_activate_threshold = 0; in lpfc_mbx_cmpl_read_lds_params()
7844 phba->degrade_deactivate_threshold = 0; in lpfc_mbx_cmpl_read_lds_params()
7845 phba->fec_degrade_interval = 0; in lpfc_mbx_cmpl_read_lds_params()
7849 phba->degrade_activate_threshold = pmb->u.mqe.un.set_feature.word7; in lpfc_mbx_cmpl_read_lds_params()
7850 phba->degrade_deactivate_threshold = pmb->u.mqe.un.set_feature.word8; in lpfc_mbx_cmpl_read_lds_params()
7851 phba->fec_degrade_interval = pmb->u.mqe.un.set_feature.word10; in lpfc_mbx_cmpl_read_lds_params()
7855 phba->degrade_activate_threshold, in lpfc_mbx_cmpl_read_lds_params()
7856 phba->degrade_deactivate_threshold, in lpfc_mbx_cmpl_read_lds_params()
7857 phba->fec_degrade_interval); in lpfc_mbx_cmpl_read_lds_params()
7859 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_mbx_cmpl_read_lds_params()
7868 mboxq = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_read_lds_params()
7870 return -ENOMEM; in lpfc_read_lds_params()
7873 mboxq->vport = phba->pport; in lpfc_read_lds_params()
7874 mboxq->mbox_cmpl = lpfc_mbx_cmpl_read_lds_params; in lpfc_read_lds_params()
7877 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_read_lds_params()
7878 return -EIO; in lpfc_read_lds_params()
7886 struct lpfc_vport *vport = pmb->vport; in lpfc_mbx_cmpl_cgn_set_ftrs()
7892 * is done. (2) Mailbox failed and send FPIN support only. in lpfc_mbx_cmpl_cgn_set_ftrs()
7895 &pmb->u.mqe.un.sli4_config.header.cfg_shdr; in lpfc_mbx_cmpl_cgn_set_ftrs()
7896 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_mbx_cmpl_cgn_set_ftrs()
7897 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_mbx_cmpl_cgn_set_ftrs()
7898 if (shdr_status || shdr_add_status || pmb->u.mb.mbxStatus) { in lpfc_mbx_cmpl_cgn_set_ftrs()
7904 pmb->u.mb.mbxStatus); in lpfc_mbx_cmpl_cgn_set_ftrs()
7906 phba->cgn_reg_signal = EDC_CG_SIG_NOTSUPPORTED; in lpfc_mbx_cmpl_cgn_set_ftrs()
7907 phba->cgn_reg_fpin = LPFC_CGN_FPIN_WARN | LPFC_CGN_FPIN_ALARM; in lpfc_mbx_cmpl_cgn_set_ftrs()
7912 phba->cgn_acqe_cnt = 0; in lpfc_mbx_cmpl_cgn_set_ftrs()
7915 &pmb->u.mqe.un.set_feature); in lpfc_mbx_cmpl_cgn_set_ftrs()
7917 &pmb->u.mqe.un.set_feature); in lpfc_mbx_cmpl_cgn_set_ftrs()
7921 phba->cgn_reg_signal, phba->cgn_reg_fpin); in lpfc_mbx_cmpl_cgn_set_ftrs()
7923 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_mbx_cmpl_cgn_set_ftrs()
7937 mboxq = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_config_cgn_signal()
7942 mboxq->vport = phba->pport; in lpfc_config_cgn_signal()
7943 mboxq->mbox_cmpl = lpfc_mbx_cmpl_cgn_set_ftrs; in lpfc_config_cgn_signal()
7948 phba->cgn_sig_freq, lpfc_acqe_cgn_frequency, in lpfc_config_cgn_signal()
7949 phba->cgn_reg_signal, phba->cgn_reg_fpin); in lpfc_config_cgn_signal()
7957 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_config_cgn_signal()
7960 phba->cgn_reg_fpin = LPFC_CGN_FPIN_WARN | LPFC_CGN_FPIN_ALARM; in lpfc_config_cgn_signal()
7961 phba->cgn_reg_signal = EDC_CG_SIG_NOTSUPPORTED; in lpfc_config_cgn_signal()
7962 lpfc_issue_els_rdf(phba->pport, 0); in lpfc_config_cgn_signal()
7963 return -EIO; in lpfc_config_cgn_signal()
7967 * lpfc_init_idle_stat_hb - Initialize idle_stat tracking
7970 * This routine initializes the per-eq idle_stat to dynamically dictate
7985 hdwq = &phba->sli4_hba.hdwq[phba->sli4_hba.cpu_map[i].hdwq]; in lpfc_init_idle_stat_hb()
7986 eq = hdwq->hba_eq; in lpfc_init_idle_stat_hb()
7989 if (eq->chann != i) in lpfc_init_idle_stat_hb()
7992 idle_stat = &phba->sli4_hba.idle_stat[i]; in lpfc_init_idle_stat_hb()
7994 idle_stat->prev_idle = get_cpu_idle_time(i, &wall, 1); in lpfc_init_idle_stat_hb()
7995 idle_stat->prev_wall = wall; in lpfc_init_idle_stat_hb()
7997 if (phba->nvmet_support || in lpfc_init_idle_stat_hb()
7998 phba->cmf_active_mode != LPFC_CFG_OFF || in lpfc_init_idle_stat_hb()
7999 phba->intr_type != MSIX) in lpfc_init_idle_stat_hb()
8000 eq->poll_mode = LPFC_QUEUE_WORK; in lpfc_init_idle_stat_hb()
8002 eq->poll_mode = LPFC_THREADED_IRQ; in lpfc_init_idle_stat_hb()
8005 if (!phba->nvmet_support && phba->intr_type == MSIX) in lpfc_init_idle_stat_hb()
8006 schedule_delayed_work(&phba->idle_stat_delay_work, in lpfc_init_idle_stat_hb()
8014 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); in lpfc_sli4_dip()
8019 if (lpfc_readl(phba->sli4_hba.u.if_type2.STATUSregaddr, in lpfc_sli4_dip()
8031 * lpfc_rx_monitor_create_ring - Initialize ring buffer for rx_monitor
8036 * 0 - Success
8037 * ENOMEM - Failure to kmalloc
8042 rx_monitor->ring = kmalloc_array(entries, sizeof(struct rx_info_entry), in lpfc_rx_monitor_create_ring()
8044 if (!rx_monitor->ring) in lpfc_rx_monitor_create_ring()
8045 return -ENOMEM; in lpfc_rx_monitor_create_ring()
8047 rx_monitor->head_idx = 0; in lpfc_rx_monitor_create_ring()
8048 rx_monitor->tail_idx = 0; in lpfc_rx_monitor_create_ring()
8049 spin_lock_init(&rx_monitor->lock); in lpfc_rx_monitor_create_ring()
8050 rx_monitor->entries = entries; in lpfc_rx_monitor_create_ring()
8056 * lpfc_rx_monitor_destroy_ring - Free ring buffer for rx_monitor
8063 kfree(rx_monitor->ring); in lpfc_rx_monitor_destroy_ring()
8064 rx_monitor->ring = NULL; in lpfc_rx_monitor_destroy_ring()
8065 rx_monitor->entries = 0; in lpfc_rx_monitor_destroy_ring()
8066 rx_monitor->head_idx = 0; in lpfc_rx_monitor_destroy_ring()
8067 rx_monitor->tail_idx = 0; in lpfc_rx_monitor_destroy_ring()
8071 * lpfc_rx_monitor_record - Insert an entry into rx_monitor's ring
8085 struct rx_info_entry *ring = rx_monitor->ring; in lpfc_rx_monitor_record()
8086 u32 *head_idx = &rx_monitor->head_idx; in lpfc_rx_monitor_record()
8087 u32 *tail_idx = &rx_monitor->tail_idx; in lpfc_rx_monitor_record()
8088 spinlock_t *ring_lock = &rx_monitor->lock; in lpfc_rx_monitor_record()
8089 u32 ring_size = rx_monitor->entries; in lpfc_rx_monitor_record()
8103 * lpfc_rx_monitor_report - Read out rx_monitor's ring
8122 struct rx_info_entry *ring = rx_monitor->ring; in lpfc_rx_monitor_report()
8124 u32 *head_idx = &rx_monitor->head_idx; in lpfc_rx_monitor_report()
8125 u32 *tail_idx = &rx_monitor->tail_idx; in lpfc_rx_monitor_report()
8126 spinlock_t *ring_lock = &rx_monitor->lock; in lpfc_rx_monitor_report()
8127 u32 ring_size = rx_monitor->entries; in lpfc_rx_monitor_report()
8136 scnprintf(buf, buf_len, "\t%-16s%-16s%-16s%-16s%-8s%-8s%-8s" in lpfc_rx_monitor_report()
8137 "%-8s%-8s%-8s%-16s\n", in lpfc_rx_monitor_report()
8155 "%03d:\t%-16llu%-16llu%-16llu%-16llu%-8llu" in lpfc_rx_monitor_report()
8156 "%-8llu%-8llu%-8u%-8u%-8u%u(%u)\n", in lpfc_rx_monitor_report()
8157 *head_idx, entry->max_bytes_per_interval, in lpfc_rx_monitor_report()
8158 entry->cmf_bytes, entry->total_bytes, in lpfc_rx_monitor_report()
8159 entry->rcv_bytes, entry->avg_io_latency, in lpfc_rx_monitor_report()
8160 entry->avg_io_size, entry->max_read_cnt, in lpfc_rx_monitor_report()
8161 entry->cmf_busy, entry->io_cnt, in lpfc_rx_monitor_report()
8162 entry->cmf_info, entry->timer_utilization, in lpfc_rx_monitor_report()
8163 entry->timer_interval); in lpfc_rx_monitor_report()
8176 cnt, entry->max_bytes_per_interval, in lpfc_rx_monitor_report()
8177 entry->total_bytes, entry->rcv_bytes, in lpfc_rx_monitor_report()
8178 entry->avg_io_latency, in lpfc_rx_monitor_report()
8179 entry->avg_io_size, entry->cmf_info, in lpfc_rx_monitor_report()
8180 entry->timer_utilization, in lpfc_rx_monitor_report()
8181 entry->timer_interval, *head_idx); in lpfc_rx_monitor_report()
8197 * lpfc_cmf_setup - Initialize idle_stat tracking
8215 mboxq = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_cmf_setup()
8217 return -ENOMEM; in lpfc_cmf_setup()
8219 sli4_params = &phba->sli4_hba.pc_sli4_params; in lpfc_cmf_setup()
8222 if (sli4_params->mi_ver) { in lpfc_cmf_setup()
8226 &mboxq->u.mqe.un.set_feature); in lpfc_cmf_setup()
8233 sli4_params->mi_ver = mi_ver; in lpfc_cmf_setup()
8238 sli4_params->mi_ver = 0; in lpfc_cmf_setup()
8244 "6245 Enable MI Mailbox x%x (x%x/x%x) " in lpfc_cmf_setup()
8246 bf_get(lpfc_mqe_command, &mboxq->u.mqe), in lpfc_cmf_setup()
8251 rc, sli4_params->mi_ver); in lpfc_cmf_setup()
8259 if (sli4_params->mi_ver) in lpfc_cmf_setup()
8260 phba->cfg_fdmi_on = LPFC_FDMI_SUPPORT; in lpfc_cmf_setup()
8263 if (sli4_params->cmf) { in lpfc_cmf_setup()
8267 &mboxq->u.mqe.un.set_feature); in lpfc_cmf_setup()
8271 phba->cmf_active_mode); in lpfc_cmf_setup()
8275 "6219 Enable CMF Mailbox x%x (x%x/x%x) " in lpfc_cmf_setup()
8277 bf_get(lpfc_mqe_command, &mboxq->u.mqe), in lpfc_cmf_setup()
8283 sli4_params->cmf = 0; in lpfc_cmf_setup()
8284 phba->cmf_active_mode = LPFC_CFG_OFF; in lpfc_cmf_setup()
8289 if (!phba->cgn_i) { in lpfc_cmf_setup()
8292 mp->virt = dma_alloc_coherent in lpfc_cmf_setup()
8293 (&phba->pcidev->dev, in lpfc_cmf_setup()
8295 &mp->phys, GFP_KERNEL); in lpfc_cmf_setup()
8296 if (!mp || !mp->virt) { in lpfc_cmf_setup()
8301 sli4_params->cmf = 0; in lpfc_cmf_setup()
8302 phba->cmf_active_mode = LPFC_CFG_OFF; in lpfc_cmf_setup()
8305 phba->cgn_i = mp; in lpfc_cmf_setup()
8312 atomic64_set(&phba->cgn_acqe_stat.alarm, 0); in lpfc_cmf_setup()
8313 atomic64_set(&phba->cgn_acqe_stat.warn, 0); in lpfc_cmf_setup()
8322 sli4_params->cmf = 0; in lpfc_cmf_setup()
8327 sli4_params->cmf = 0; in lpfc_cmf_setup()
8338 if (sli4_params->cmf && sli4_params->mi_ver) { in lpfc_cmf_setup()
8341 dma_free_coherent(&phba->pcidev->dev, in lpfc_cmf_setup()
8343 phba->cgn_i->virt, phba->cgn_i->phys); in lpfc_cmf_setup()
8344 kfree(phba->cgn_i); in lpfc_cmf_setup()
8345 phba->cgn_i = NULL; in lpfc_cmf_setup()
8347 phba->cmf_active_mode = LPFC_CFG_OFF; in lpfc_cmf_setup()
8348 sli4_params->cmf = 0; in lpfc_cmf_setup()
8354 sli4_params->mi_ver, sli4_params->cmf, in lpfc_cmf_setup()
8355 phba->cmf_active_mode); in lpfc_cmf_setup()
8357 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_cmf_setup()
8360 atomic_set(&phba->cgn_fabric_warn_cnt, 0); in lpfc_cmf_setup()
8361 atomic_set(&phba->cgn_fabric_alarm_cnt, 0); in lpfc_cmf_setup()
8362 atomic_set(&phba->cgn_sync_alarm_cnt, 0); in lpfc_cmf_setup()
8363 atomic_set(&phba->cgn_sync_warn_cnt, 0); in lpfc_cmf_setup()
8364 atomic_set(&phba->cgn_driver_evt_cnt, 0); in lpfc_cmf_setup()
8365 atomic_set(&phba->cgn_latency_evt_cnt, 0); in lpfc_cmf_setup()
8366 atomic64_set(&phba->cgn_latency_evt, 0); in lpfc_cmf_setup()
8368 phba->cmf_interval_rate = LPFC_CMF_INTERVAL; in lpfc_cmf_setup()
8371 if (!phba->rx_monitor) { in lpfc_cmf_setup()
8372 phba->rx_monitor = kzalloc(sizeof(*phba->rx_monitor), in lpfc_cmf_setup()
8375 if (!phba->rx_monitor) { in lpfc_cmf_setup()
8379 return -ENOMEM; in lpfc_cmf_setup()
8383 if (lpfc_rx_monitor_create_ring(phba->rx_monitor, in lpfc_cmf_setup()
8385 kfree(phba->rx_monitor); in lpfc_cmf_setup()
8386 phba->rx_monitor = NULL; in lpfc_cmf_setup()
8390 return -ENOMEM; in lpfc_cmf_setup()
8408 mboxq = (LPFC_MBOXQ_t *)mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_set_host_tm()
8410 return -ENOMEM; in lpfc_set_host_tm()
8412 len = sizeof(struct lpfc_mbx_set_host_data) - in lpfc_set_host_tm()
8418 mboxq->u.mqe.un.set_host_data.param_id = LPFC_SET_HOST_DATE_TIME; in lpfc_set_host_tm()
8419 mboxq->u.mqe.un.set_host_data.param_len = in lpfc_set_host_tm()
8421 tm = &mboxq->u.mqe.un.set_host_data.un.tm; in lpfc_set_host_tm()
8426 year = broken.tm_year - 100; in lpfc_set_host_tm()
8438 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_set_host_tm()
8443 * lpfc_sli4_hba_setup - SLI4 device initialization PCI function
8460 struct Scsi_Host *shost = lpfc_shost_from_vport(phba->pport); in lpfc_sli4_hba_setup()
8461 struct lpfc_vport *vport = phba->pport; in lpfc_sli4_hba_setup()
8469 return -ENODEV; in lpfc_sli4_hba_setup()
8474 return -ENODEV; in lpfc_sli4_hba_setup()
8476 spin_lock_irq(&phba->hbalock); in lpfc_sli4_hba_setup()
8477 phba->sli.sli_flag |= LPFC_SLI_ACTIVE; in lpfc_sli4_hba_setup()
8478 flg = phba->sli.sli_flag; in lpfc_sli4_hba_setup()
8479 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_hba_setup()
8485 spin_lock_irq(&phba->hbalock); in lpfc_sli4_hba_setup()
8486 flg = phba->sli.sli_flag; in lpfc_sli4_hba_setup()
8487 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_hba_setup()
8490 clear_bit(HBA_SETUP, &phba->hba_flag); in lpfc_sli4_hba_setup()
8495 * Allocate a single mailbox container for initializing the in lpfc_sli4_hba_setup()
8498 mboxq = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_hba_setup()
8500 return -ENOMEM; in lpfc_sli4_hba_setup()
8506 rc = -ENOMEM; in lpfc_sli4_hba_setup()
8516 mqe = &mboxq->u.mqe; in lpfc_sli4_hba_setup()
8517 phba->sli_rev = bf_get(lpfc_mbx_rd_rev_sli_lvl, &mqe->un.read_rev); in lpfc_sli4_hba_setup()
8518 if (bf_get(lpfc_mbx_rd_rev_fcoe, &mqe->un.read_rev)) { in lpfc_sli4_hba_setup()
8519 set_bit(HBA_FCOE_MODE, &phba->hba_flag); in lpfc_sli4_hba_setup()
8520 phba->fcp_embed_io = 0; /* SLI4 FC support only */ in lpfc_sli4_hba_setup()
8522 clear_bit(HBA_FCOE_MODE, &phba->hba_flag); in lpfc_sli4_hba_setup()
8525 if (bf_get(lpfc_mbx_rd_rev_cee_ver, &mqe->un.read_rev) == in lpfc_sli4_hba_setup()
8527 set_bit(HBA_FIP_SUPPORT, &phba->hba_flag); in lpfc_sli4_hba_setup()
8529 clear_bit(HBA_FIP_SUPPORT, &phba->hba_flag); in lpfc_sli4_hba_setup()
8531 clear_bit(HBA_IOQ_FLUSH, &phba->hba_flag); in lpfc_sli4_hba_setup()
8533 if (phba->sli_rev != LPFC_SLI_REV4) { in lpfc_sli4_hba_setup()
8537 phba->sli_rev, in lpfc_sli4_hba_setup()
8538 test_bit(HBA_FCOE_MODE, &phba->hba_flag) ? 1 : 0); in lpfc_sli4_hba_setup()
8539 rc = -EIO; in lpfc_sli4_hba_setup()
8553 if (test_bit(HBA_FCOE_MODE, &phba->hba_flag) && in lpfc_sli4_hba_setup()
8560 * is considered as non-fatal. in lpfc_sli4_hba_setup()
8566 "physical port name: %s.\n", phba->Port); in lpfc_sli4_hba_setup()
8587 phba->vpd.rev.biuRev = mqe->un.read_rev.first_hw_rev; in lpfc_sli4_hba_setup()
8588 phba->vpd.rev.smRev = mqe->un.read_rev.second_hw_rev; in lpfc_sli4_hba_setup()
8594 if ((bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) == in lpfc_sli4_hba_setup()
8596 (phba->vpd.rev.biuRev == LPFC_G7_ASIC_1) && in lpfc_sli4_hba_setup()
8597 (phba->vpd.rev.smRev == 0) && in lpfc_sli4_hba_setup()
8598 (phba->cfg_nvme_embed_cmd == 1)) in lpfc_sli4_hba_setup()
8599 phba->cfg_nvme_embed_cmd = 0; in lpfc_sli4_hba_setup()
8601 phba->vpd.rev.endecRev = mqe->un.read_rev.third_hw_rev; in lpfc_sli4_hba_setup()
8602 phba->vpd.rev.fcphHigh = bf_get(lpfc_mbx_rd_rev_fcph_high, in lpfc_sli4_hba_setup()
8603 &mqe->un.read_rev); in lpfc_sli4_hba_setup()
8604 phba->vpd.rev.fcphLow = bf_get(lpfc_mbx_rd_rev_fcph_low, in lpfc_sli4_hba_setup()
8605 &mqe->un.read_rev); in lpfc_sli4_hba_setup()
8606 phba->vpd.rev.feaLevelHigh = bf_get(lpfc_mbx_rd_rev_ftr_lvl_high, in lpfc_sli4_hba_setup()
8607 &mqe->un.read_rev); in lpfc_sli4_hba_setup()
8608 phba->vpd.rev.feaLevelLow = bf_get(lpfc_mbx_rd_rev_ftr_lvl_low, in lpfc_sli4_hba_setup()
8609 &mqe->un.read_rev); in lpfc_sli4_hba_setup()
8610 phba->vpd.rev.sli1FwRev = mqe->un.read_rev.fw_id_rev; in lpfc_sli4_hba_setup()
8611 memcpy(phba->vpd.rev.sli1FwName, mqe->un.read_rev.fw_name, 16); in lpfc_sli4_hba_setup()
8612 phba->vpd.rev.sli2FwRev = mqe->un.read_rev.ulp_fw_id_rev; in lpfc_sli4_hba_setup()
8613 memcpy(phba->vpd.rev.sli2FwName, mqe->un.read_rev.ulp_fw_name, 16); in lpfc_sli4_hba_setup()
8614 phba->vpd.rev.opFwRev = mqe->un.read_rev.fw_id_rev; in lpfc_sli4_hba_setup()
8615 memcpy(phba->vpd.rev.opFwName, mqe->un.read_rev.fw_name, 16); in lpfc_sli4_hba_setup()
8619 mboxq->vport ? mboxq->vport->vpi : 0, in lpfc_sli4_hba_setup()
8621 phba->vpd.rev.opFwName, in lpfc_sli4_hba_setup()
8622 phba->vpd.rev.fcphHigh, phba->vpd.rev.fcphLow, in lpfc_sli4_hba_setup()
8623 phba->vpd.rev.feaLevelHigh, phba->vpd.rev.feaLevelLow); in lpfc_sli4_hba_setup()
8625 if (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) == in lpfc_sli4_hba_setup()
8630 set_bit(HBA_RECOVERABLE_UE, &phba->hba_flag); in lpfc_sli4_hba_setup()
8632 phba->eratt_poll_interval = 1; in lpfc_sli4_hba_setup()
8633 phba->sli4_hba.ue_to_sr = bf_get( in lpfc_sli4_hba_setup()
8635 &mboxq->u.mqe.un.set_feature); in lpfc_sli4_hba_setup()
8636 phba->sli4_hba.ue_to_rp = bf_get( in lpfc_sli4_hba_setup()
8638 &mboxq->u.mqe.un.set_feature); in lpfc_sli4_hba_setup()
8642 if (phba->cfg_enable_mds_diags && phba->mds_diags_support) { in lpfc_sli4_hba_setup()
8647 phba->mds_diags_support = 0; in lpfc_sli4_hba_setup()
8657 rc = -EIO; in lpfc_sli4_hba_setup()
8662 if (phba->cfg_vmid_app_header && !(bf_get(lpfc_mbx_rq_ftr_rsp_ashdr, in lpfc_sli4_hba_setup()
8663 &mqe->un.req_ftrs))) { in lpfc_sli4_hba_setup()
8664 bf_set(lpfc_ftr_ashdr, &phba->sli4_hba.sli4_flags, 0); in lpfc_sli4_hba_setup()
8665 phba->cfg_vmid_app_header = 0; in lpfc_sli4_hba_setup()
8674 if (!(bf_get(lpfc_mbx_rq_ftr_rsp_fcpi, &mqe->un.req_ftrs))) { in lpfc_sli4_hba_setup()
8681 if (test_bit(HBA_FCOE_MODE, &phba->hba_flag)) { in lpfc_sli4_hba_setup()
8682 if (bf_get(lpfc_mbx_rq_ftr_rsp_perfh, &mqe->un.req_ftrs)) in lpfc_sli4_hba_setup()
8683 phba->sli3_options |= LPFC_SLI4_PERFH_ENABLED; in lpfc_sli4_hba_setup()
8685 phba->sli3_options &= ~LPFC_SLI4_PERFH_ENABLED; in lpfc_sli4_hba_setup()
8693 if (phba->sli3_options & LPFC_SLI3_BG_ENABLED) { in lpfc_sli4_hba_setup()
8694 if (!(bf_get(lpfc_mbx_rq_ftr_rsp_dif, &mqe->un.req_ftrs))) { in lpfc_sli4_hba_setup()
8695 phba->cfg_enable_bg = 0; in lpfc_sli4_hba_setup()
8696 phba->sli3_options &= ~LPFC_SLI3_BG_ENABLED; in lpfc_sli4_hba_setup()
8701 if (phba->max_vpi && phba->cfg_enable_npiv && in lpfc_sli4_hba_setup()
8702 !(bf_get(lpfc_mbx_rq_ftr_rsp_npiv, &mqe->un.req_ftrs))) in lpfc_sli4_hba_setup()
8708 "x%x x%x x%x\n", mqe->un.req_ftrs.word2, in lpfc_sli4_hba_setup()
8709 mqe->un.req_ftrs.word3, phba->cfg_enable_bg, in lpfc_sli4_hba_setup()
8710 phba->cfg_enable_npiv, phba->max_vpi); in lpfc_sli4_hba_setup()
8711 if (!(bf_get(lpfc_mbx_rq_ftr_rsp_dif, &mqe->un.req_ftrs))) in lpfc_sli4_hba_setup()
8712 phba->cfg_enable_bg = 0; in lpfc_sli4_hba_setup()
8713 if (!(bf_get(lpfc_mbx_rq_ftr_rsp_npiv, &mqe->un.req_ftrs))) in lpfc_sli4_hba_setup()
8714 phba->cfg_enable_npiv = 0; in lpfc_sli4_hba_setup()
8718 spin_lock_irq(&phba->hbalock); in lpfc_sli4_hba_setup()
8719 phba->sli3_options |= (LPFC_SLI3_NPIV_ENABLED | LPFC_SLI3_HBQ_ENABLED); in lpfc_sli4_hba_setup()
8720 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_hba_setup()
8725 dd = bf_get(lpfc_mbx_set_feature_dd, &mboxq->u.mqe.un.set_feature); in lpfc_sli4_hba_setup()
8731 "6447 Dual Dump Mailbox x%x (x%x/x%x) failed, " in lpfc_sli4_hba_setup()
8733 bf_get(lpfc_mqe_command, &mboxq->u.mqe), in lpfc_sli4_hba_setup()
8764 rc = lpfc_read_sparam(phba, mboxq, vport->vpi); in lpfc_sli4_hba_setup()
8766 phba->link_state = LPFC_HBA_ERROR; in lpfc_sli4_hba_setup()
8767 rc = -ENOMEM; in lpfc_sli4_hba_setup()
8771 mboxq->vport = vport; in lpfc_sli4_hba_setup()
8773 mp = mboxq->ctx_buf; in lpfc_sli4_hba_setup()
8775 memcpy(&vport->fc_sparam, mp->virt, sizeof(struct serv_parm)); in lpfc_sli4_hba_setup()
8784 lpfc_mbuf_free(phba, mp->virt, mp->phys); in lpfc_sli4_hba_setup()
8786 mboxq->ctx_buf = NULL; in lpfc_sli4_hba_setup()
8792 phba->link_state = LPFC_HBA_ERROR; in lpfc_sli4_hba_setup()
8793 rc = -EIO; in lpfc_sli4_hba_setup()
8800 fc_host_node_name(shost) = wwn_to_u64(vport->fc_nodename.u.wwn); in lpfc_sli4_hba_setup()
8801 fc_host_port_name(shost) = wwn_to_u64(vport->fc_portname.u.wwn); in lpfc_sli4_hba_setup()
8808 rc = -ENODEV; in lpfc_sli4_hba_setup()
8822 /* update host els xri-sgl sizes and mappings */ in lpfc_sli4_hba_setup()
8826 "1400 Failed to update xri-sgl size and " in lpfc_sli4_hba_setup()
8832 rc = lpfc_sli4_repost_sgl_list(phba, &phba->sli4_hba.lpfc_els_sgl_list, in lpfc_sli4_hba_setup()
8833 phba->sli4_hba.els_xri_cnt); in lpfc_sli4_hba_setup()
8838 rc = -ENODEV; in lpfc_sli4_hba_setup()
8841 phba->sli4_hba.els_xri_cnt = rc; in lpfc_sli4_hba_setup()
8843 if (phba->nvmet_support) { in lpfc_sli4_hba_setup()
8844 /* update host nvmet xri-sgl sizes and mappings */ in lpfc_sli4_hba_setup()
8848 "6308 Failed to update nvmet-sgl size " in lpfc_sli4_hba_setup()
8856 &phba->sli4_hba.lpfc_nvmet_sgl_list, in lpfc_sli4_hba_setup()
8857 phba->sli4_hba.nvmet_xri_cnt); in lpfc_sli4_hba_setup()
8862 rc = -ENODEV; in lpfc_sli4_hba_setup()
8865 phba->sli4_hba.nvmet_xri_cnt = rc; in lpfc_sli4_hba_setup()
8870 cnt = phba->sli4_hba.nvmet_xri_cnt + in lpfc_sli4_hba_setup()
8871 phba->sli4_hba.max_cfg_param.max_xri; in lpfc_sli4_hba_setup()
8873 /* update host common xri-sgl sizes and mappings */ in lpfc_sli4_hba_setup()
8877 "6082 Failed to update nvme-sgl size " in lpfc_sli4_hba_setup()
8890 rc = -ENODEV; in lpfc_sli4_hba_setup()
8896 cnt = phba->sli4_hba.max_cfg_param.max_xri; in lpfc_sli4_hba_setup()
8899 if (!phba->sli.iocbq_lookup) { in lpfc_sli4_hba_setup()
8912 if (phba->nvmet_support) in lpfc_sli4_hba_setup()
8915 if (phba->nvmet_support && phba->cfg_nvmet_mrq) { in lpfc_sli4_hba_setup()
8917 for (i = 0; i < phba->cfg_nvmet_mrq; i++) { in lpfc_sli4_hba_setup()
8918 rqbp = phba->sli4_hba.nvmet_mrq_hdr[i]->rqbp; in lpfc_sli4_hba_setup()
8919 INIT_LIST_HEAD(&rqbp->rqb_buffer_list); in lpfc_sli4_hba_setup()
8920 rqbp->rqb_alloc_buffer = lpfc_sli4_nvmet_alloc; in lpfc_sli4_hba_setup()
8921 rqbp->rqb_free_buffer = lpfc_sli4_nvmet_free; in lpfc_sli4_hba_setup()
8922 rqbp->entry_count = LPFC_NVMET_RQE_DEF_COUNT; in lpfc_sli4_hba_setup()
8923 rqbp->buffer_count = 0; in lpfc_sli4_hba_setup()
8926 phba, phba->sli4_hba.nvmet_mrq_hdr[i], in lpfc_sli4_hba_setup()
8927 phba->sli4_hba.nvmet_mrq_data[i], in lpfc_sli4_hba_setup()
8928 phba->cfg_nvmet_mrq_post, i); in lpfc_sli4_hba_setup()
8938 rc = -ENODEV; in lpfc_sli4_hba_setup()
8942 if (!test_bit(HBA_FCOE_MODE, &phba->hba_flag)) { in lpfc_sli4_hba_setup()
8943 if ((phba->nvmet_support == 0) || (phba->cfg_nvmet_mrq == 1)) { in lpfc_sli4_hba_setup()
8948 mboxq->vport = phba->pport; in lpfc_sli4_hba_setup()
8953 phba->fcf.fcfi = bf_get(lpfc_reg_fcfi_fcfi, in lpfc_sli4_hba_setup()
8954 &mboxq->u.mqe.un.reg_fcfi); in lpfc_sli4_hba_setup()
8960 mboxq->vport = phba->pport; in lpfc_sli4_hba_setup()
8965 phba->fcf.fcfi = bf_get(lpfc_reg_fcfi_mrq_fcfi, in lpfc_sli4_hba_setup()
8966 &mboxq->u.mqe.un.reg_fcfi_mrq); in lpfc_sli4_hba_setup()
8970 mboxq->vport = phba->pport; in lpfc_sli4_hba_setup()
8983 if (phba->nvmet_support == 0) { in lpfc_sli4_hba_setup()
8984 if (phba->sli4_hba.io_xri_cnt == 0) { in lpfc_sli4_hba_setup()
8986 phba, phba->sli4_hba.io_xri_max); in lpfc_sli4_hba_setup()
8988 rc = -ENOMEM; in lpfc_sli4_hba_setup()
8992 if (phba->cfg_xri_rebalancing) in lpfc_sli4_hba_setup()
8996 phba->cfg_xri_rebalancing = 0; in lpfc_sli4_hba_setup()
8999 /* Allow asynchronous mailbox command to go through */ in lpfc_sli4_hba_setup()
9000 spin_lock_irq(&phba->hbalock); in lpfc_sli4_hba_setup()
9001 phba->sli.sli_flag &= ~LPFC_SLI_ASYNC_MBX_BLK; in lpfc_sli4_hba_setup()
9002 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_hba_setup()
9008 phba->fcf.fcf_flag = 0; in lpfc_sli4_hba_setup()
9009 phba->fcf.current_rec.flag = 0; in lpfc_sli4_hba_setup()
9012 mod_timer(&vport->els_tmofunc, in lpfc_sli4_hba_setup()
9013 jiffies + msecs_to_jiffies(1000 * (phba->fc_ratov * 2))); in lpfc_sli4_hba_setup()
9016 mod_timer(&phba->hb_tmofunc, in lpfc_sli4_hba_setup()
9018 clear_bit(HBA_HBEAT_INP, &phba->hba_flag); in lpfc_sli4_hba_setup()
9019 clear_bit(HBA_HBEAT_TMO, &phba->hba_flag); in lpfc_sli4_hba_setup()
9020 phba->last_completion_time = jiffies; in lpfc_sli4_hba_setup()
9023 if (phba->cfg_auto_imax) in lpfc_sli4_hba_setup()
9024 queue_delayed_work(phba->wq, &phba->eq_delay_work, in lpfc_sli4_hba_setup()
9031 mod_timer(&phba->eratt_poll, in lpfc_sli4_hba_setup()
9032 jiffies + msecs_to_jiffies(1000 * phba->eratt_poll_interval)); in lpfc_sli4_hba_setup()
9038 spin_lock_irq(&phba->hbalock); in lpfc_sli4_hba_setup()
9039 phba->link_state = LPFC_LINK_DOWN; in lpfc_sli4_hba_setup()
9042 if (bf_get(lpfc_conf_trunk_port0, &phba->sli4_hba)) in lpfc_sli4_hba_setup()
9043 phba->trunk_link.link0.state = LPFC_LINK_DOWN; in lpfc_sli4_hba_setup()
9044 if (bf_get(lpfc_conf_trunk_port1, &phba->sli4_hba)) in lpfc_sli4_hba_setup()
9045 phba->trunk_link.link1.state = LPFC_LINK_DOWN; in lpfc_sli4_hba_setup()
9046 if (bf_get(lpfc_conf_trunk_port2, &phba->sli4_hba)) in lpfc_sli4_hba_setup()
9047 phba->trunk_link.link2.state = LPFC_LINK_DOWN; in lpfc_sli4_hba_setup()
9048 if (bf_get(lpfc_conf_trunk_port3, &phba->sli4_hba)) in lpfc_sli4_hba_setup()
9049 phba->trunk_link.link3.state = LPFC_LINK_DOWN; in lpfc_sli4_hba_setup()
9050 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_hba_setup()
9056 phba->sli4_hba.intr_enable = 1; in lpfc_sli4_hba_setup()
9061 if (!test_bit(HBA_FCOE_MODE, &phba->hba_flag) && in lpfc_sli4_hba_setup()
9062 test_bit(LINK_DISABLED, &phba->hba_flag)) { in lpfc_sli4_hba_setup()
9073 } else if (phba->cfg_suppress_link_up == LPFC_INITIALIZE_LINK) { in lpfc_sli4_hba_setup()
9075 if (!(phba->link_flag & LS_LOOPBACK_MODE)) { in lpfc_sli4_hba_setup()
9076 rc = phba->lpfc_hba_init_link(phba, MBX_NOWAIT); in lpfc_sli4_hba_setup()
9081 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_hba_setup()
9086 set_bit(HBA_SETUP, &phba->hba_flag); in lpfc_sli4_hba_setup()
9102 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_hba_setup()
9107 * lpfc_mbox_timeout - Timeout call back function for mbox timer
9110 * This is the callback function for mailbox timer. The mailbox
9111 * timer is armed when a new mailbox command is issued and the timer
9112 * is deleted when the mailbox complete. The function is called by
9113 * the kernel timer code when a mailbox does not complete within
9115 * process the mailbox timeout and returns. All the processing is
9125 spin_lock_irqsave(&phba->pport->work_port_lock, iflag); in lpfc_mbox_timeout()
9126 tmo_posted = phba->pport->work_port_events & WORKER_MBOX_TMO; in lpfc_mbox_timeout()
9128 phba->pport->work_port_events |= WORKER_MBOX_TMO; in lpfc_mbox_timeout()
9129 spin_unlock_irqrestore(&phba->pport->work_port_lock, iflag); in lpfc_mbox_timeout()
9137 * lpfc_sli4_mbox_completions_pending - check to see if any mailbox completions
9141 * This function checks if any mailbox completions are present on the mailbox
9154 if (unlikely(!phba) || (phba->sli_rev != LPFC_SLI_REV4)) in lpfc_sli4_mbox_completions_pending()
9157 /* Check for completions on mailbox completion queue */ in lpfc_sli4_mbox_completions_pending()
9159 mcq = phba->sli4_hba.mbx_cq; in lpfc_sli4_mbox_completions_pending()
9160 idx = mcq->hba_index; in lpfc_sli4_mbox_completions_pending()
9161 qe_valid = mcq->qe_valid; in lpfc_sli4_mbox_completions_pending()
9170 idx = (idx + 1) % mcq->entry_count; in lpfc_sli4_mbox_completions_pending()
9171 if (mcq->hba_index == idx) in lpfc_sli4_mbox_completions_pending()
9175 if (phba->sli4_hba.pc_sli4_params.cqav && !idx) in lpfc_sli4_mbox_completions_pending()
9183 * lpfc_sli4_process_missed_mbox_completions - process mbox completions
9188 * maybe missed causing erroneous mailbox timeouts to occur. This function
9189 * checks to see if mbox completions are on the mailbox completion queue
9191 * mailbox completion queue.
9196 struct lpfc_sli4_hba *sli4_hba = &phba->sli4_hba; in lpfc_sli4_process_missed_mbox_completions()
9202 if (unlikely(!phba) || (phba->sli_rev != LPFC_SLI_REV4)) in lpfc_sli4_process_missed_mbox_completions()
9206 if (sli4_hba->hdwq) { in lpfc_sli4_process_missed_mbox_completions()
9207 for (eqidx = 0; eqidx < phba->cfg_irq_chann; eqidx++) { in lpfc_sli4_process_missed_mbox_completions()
9208 eq = phba->sli4_hba.hba_eq_hdl[eqidx].eq; in lpfc_sli4_process_missed_mbox_completions()
9209 if (eq && eq->queue_id == sli4_hba->mbx_cq->assoc_qid) { in lpfc_sli4_process_missed_mbox_completions()
9220 sli4_hba->sli4_eq_clr_intr(fpeq); in lpfc_sli4_process_missed_mbox_completions()
9229 * mailbox commands, async events, els commands, receive queue data in lpfc_sli4_process_missed_mbox_completions()
9238 /* Always clear and re-arm the EQ */ in lpfc_sli4_process_missed_mbox_completions()
9239 sli4_hba->sli4_write_eq_db(phba, fpeq, 0, LPFC_QUEUE_REARM); in lpfc_sli4_process_missed_mbox_completions()
9246 * lpfc_mbox_timeout_handler - Worker thread function to handle mailbox timeout
9249 * This function is called from worker thread when a mailbox command times out.
9256 LPFC_MBOXQ_t *pmbox = phba->sli.mbox_active; in lpfc_mbox_timeout_handler()
9259 struct lpfc_sli *psli = &phba->sli; in lpfc_mbox_timeout_handler()
9261 /* If the mailbox completed, process the completion */ in lpfc_mbox_timeout_handler()
9264 if (!(psli->sli_flag & LPFC_SLI_ACTIVE)) in lpfc_mbox_timeout_handler()
9268 mb = &pmbox->u.mb; in lpfc_mbox_timeout_handler()
9271 * worklist and the mailbox actually completing. When this in lpfc_mbox_timeout_handler()
9274 spin_lock_irq(&phba->hbalock); in lpfc_mbox_timeout_handler()
9278 "0353 Active Mailbox cleared - mailbox timeout " in lpfc_mbox_timeout_handler()
9280 spin_unlock_irq(&phba->hbalock); in lpfc_mbox_timeout_handler()
9286 "0310 Mailbox command x%x timeout Data: x%x x%x x%px\n", in lpfc_mbox_timeout_handler()
9287 mb->mbxCommand, in lpfc_mbox_timeout_handler()
9288 phba->pport->port_state, in lpfc_mbox_timeout_handler()
9289 phba->sli.sli_flag, in lpfc_mbox_timeout_handler()
9290 phba->sli.mbox_active); in lpfc_mbox_timeout_handler()
9291 spin_unlock_irq(&phba->hbalock); in lpfc_mbox_timeout_handler()
9297 set_bit(MBX_TMO_ERR, &phba->bit_flags); in lpfc_mbox_timeout_handler()
9298 spin_lock_irq(&phba->pport->work_port_lock); in lpfc_mbox_timeout_handler()
9299 phba->pport->work_port_events &= ~WORKER_MBOX_TMO; in lpfc_mbox_timeout_handler()
9300 spin_unlock_irq(&phba->pport->work_port_lock); in lpfc_mbox_timeout_handler()
9301 spin_lock_irq(&phba->hbalock); in lpfc_mbox_timeout_handler()
9302 phba->link_state = LPFC_LINK_UNKNOWN; in lpfc_mbox_timeout_handler()
9303 psli->sli_flag &= ~LPFC_SLI_ACTIVE; in lpfc_mbox_timeout_handler()
9304 spin_unlock_irq(&phba->hbalock); in lpfc_mbox_timeout_handler()
9307 "0345 Resetting board due to mailbox timeout\n"); in lpfc_mbox_timeout_handler()
9314 * lpfc_sli_issue_mbox_s3 - Issue an SLI3 mailbox command to firmware
9316 * @pmbox: Pointer to mailbox object.
9317 * @flag: Flag indicating how the mailbox need to be processed.
9320 * to submit a mailbox command to firmware with SLI-3 interface spec. This
9322 * The mailbox command can be submitted in polling mode, in which case
9324 * mailbox.
9325 * If the mailbox is submitted in no_wait mode (not polling) the
9327 * for the mailbox completion. The no_wait is supported only when HBA
9328 * is in SLI2/SLI3 mode - interrupts are enabled.
9329 * The SLI interface allows only one mailbox pending at a time. If the
9330 * mailbox is issued in polling mode and there is already a mailbox
9331 * pending, then the function will return an error. If the mailbox is issued
9332 * in NO_WAIT mode and there is a mailbox pending already, the function
9333 * will return MBX_BUSY after queuing the mailbox into mailbox queue.
9334 * The sli layer owns the mailbox object until the completion of mailbox
9336 * return codes the caller owns the mailbox command after the return of
9344 struct lpfc_sli *psli = &phba->sli; in lpfc_sli_issue_mbox_s3()
9354 spin_lock_irqsave(&phba->hbalock, drvr_flag); in lpfc_sli_issue_mbox_s3()
9356 phba->sli.sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; in lpfc_sli_issue_mbox_s3()
9358 if (unlikely(psli->sli_flag & LPFC_SLI_ASYNC_MBX_BLK)) { in lpfc_sli_issue_mbox_s3()
9359 spin_unlock_irqrestore(&phba->hbalock, drvr_flag); in lpfc_sli_issue_mbox_s3()
9365 spin_unlock_irqrestore(&phba->hbalock, drvr_flag); in lpfc_sli_issue_mbox_s3()
9370 if (pmbox->mbox_cmpl && pmbox->mbox_cmpl != lpfc_sli_def_mbox_cmpl && in lpfc_sli_issue_mbox_s3()
9371 pmbox->mbox_cmpl != lpfc_sli_wake_mbox_wait) { in lpfc_sli_issue_mbox_s3()
9372 if(!pmbox->vport) { in lpfc_sli_issue_mbox_s3()
9373 spin_unlock_irqrestore(&phba->hbalock, drvr_flag); in lpfc_sli_issue_mbox_s3()
9377 pmbox->u.mb.mbxCommand); in lpfc_sli_issue_mbox_s3()
9384 if (unlikely(pci_channel_offline(phba->pcidev))) { in lpfc_sli_issue_mbox_s3()
9385 spin_unlock_irqrestore(&phba->hbalock, drvr_flag); in lpfc_sli_issue_mbox_s3()
9390 if (unlikely(test_bit(DEFER_ERATT, &phba->hba_flag))) { in lpfc_sli_issue_mbox_s3()
9391 spin_unlock_irqrestore(&phba->hbalock, drvr_flag); in lpfc_sli_issue_mbox_s3()
9395 psli = &phba->sli; in lpfc_sli_issue_mbox_s3()
9397 mbx = &pmbox->u.mb; in lpfc_sli_issue_mbox_s3()
9400 if (phba->link_state == LPFC_HBA_ERROR) { in lpfc_sli_issue_mbox_s3()
9401 spin_unlock_irqrestore(&phba->hbalock, drvr_flag); in lpfc_sli_issue_mbox_s3()
9405 "(%d):0311 Mailbox command x%x cannot " in lpfc_sli_issue_mbox_s3()
9407 pmbox->vport ? pmbox->vport->vpi : 0, in lpfc_sli_issue_mbox_s3()
9408 pmbox->u.mb.mbxCommand, psli->sli_flag, flag); in lpfc_sli_issue_mbox_s3()
9412 if (mbx->mbxCommand != MBX_KILL_BOARD && flag & MBX_NOWAIT) { in lpfc_sli_issue_mbox_s3()
9413 if (lpfc_readl(phba->HCregaddr, &hc_copy) || in lpfc_sli_issue_mbox_s3()
9415 spin_unlock_irqrestore(&phba->hbalock, drvr_flag); in lpfc_sli_issue_mbox_s3()
9417 "(%d):2528 Mailbox command x%x cannot " in lpfc_sli_issue_mbox_s3()
9419 pmbox->vport ? pmbox->vport->vpi : 0, in lpfc_sli_issue_mbox_s3()
9420 pmbox->u.mb.mbxCommand, psli->sli_flag, flag); in lpfc_sli_issue_mbox_s3()
9425 if (psli->sli_flag & LPFC_SLI_MBOX_ACTIVE) { in lpfc_sli_issue_mbox_s3()
9432 spin_unlock_irqrestore(&phba->hbalock, drvr_flag); in lpfc_sli_issue_mbox_s3()
9436 "(%d):2529 Mailbox command x%x " in lpfc_sli_issue_mbox_s3()
9438 pmbox->vport ? pmbox->vport->vpi : 0, in lpfc_sli_issue_mbox_s3()
9439 pmbox->u.mb.mbxCommand, in lpfc_sli_issue_mbox_s3()
9440 psli->sli_flag, flag); in lpfc_sli_issue_mbox_s3()
9444 if (!(psli->sli_flag & LPFC_SLI_ACTIVE)) { in lpfc_sli_issue_mbox_s3()
9445 spin_unlock_irqrestore(&phba->hbalock, drvr_flag); in lpfc_sli_issue_mbox_s3()
9448 "(%d):2530 Mailbox command x%x " in lpfc_sli_issue_mbox_s3()
9450 pmbox->vport ? pmbox->vport->vpi : 0, in lpfc_sli_issue_mbox_s3()
9451 pmbox->u.mb.mbxCommand, in lpfc_sli_issue_mbox_s3()
9452 psli->sli_flag, flag); in lpfc_sli_issue_mbox_s3()
9456 /* Another mailbox command is still being processed, queue this in lpfc_sli_issue_mbox_s3()
9461 /* Mbox cmd issue - BUSY */ in lpfc_sli_issue_mbox_s3()
9463 "(%d):0308 Mbox cmd issue - BUSY Data: " in lpfc_sli_issue_mbox_s3()
9465 pmbox->vport ? pmbox->vport->vpi : 0xffffff, in lpfc_sli_issue_mbox_s3()
9466 mbx->mbxCommand, in lpfc_sli_issue_mbox_s3()
9467 phba->pport ? phba->pport->port_state : 0xff, in lpfc_sli_issue_mbox_s3()
9468 psli->sli_flag, flag); in lpfc_sli_issue_mbox_s3()
9470 psli->slistat.mbox_busy++; in lpfc_sli_issue_mbox_s3()
9471 spin_unlock_irqrestore(&phba->hbalock, drvr_flag); in lpfc_sli_issue_mbox_s3()
9473 if (pmbox->vport) { in lpfc_sli_issue_mbox_s3()
9474 lpfc_debugfs_disc_trc(pmbox->vport, in lpfc_sli_issue_mbox_s3()
9477 (uint32_t)mbx->mbxCommand, in lpfc_sli_issue_mbox_s3()
9478 mbx->un.varWords[0], mbx->un.varWords[1]); in lpfc_sli_issue_mbox_s3()
9481 lpfc_debugfs_disc_trc(phba->pport, in lpfc_sli_issue_mbox_s3()
9484 (uint32_t)mbx->mbxCommand, in lpfc_sli_issue_mbox_s3()
9485 mbx->un.varWords[0], mbx->un.varWords[1]); in lpfc_sli_issue_mbox_s3()
9491 psli->sli_flag |= LPFC_SLI_MBOX_ACTIVE; in lpfc_sli_issue_mbox_s3()
9495 if (!(psli->sli_flag & LPFC_SLI_ACTIVE) && in lpfc_sli_issue_mbox_s3()
9496 (mbx->mbxCommand != MBX_KILL_BOARD)) { in lpfc_sli_issue_mbox_s3()
9497 psli->sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; in lpfc_sli_issue_mbox_s3()
9498 spin_unlock_irqrestore(&phba->hbalock, drvr_flag); in lpfc_sli_issue_mbox_s3()
9501 "(%d):2531 Mailbox command x%x " in lpfc_sli_issue_mbox_s3()
9503 pmbox->vport ? pmbox->vport->vpi : 0, in lpfc_sli_issue_mbox_s3()
9504 pmbox->u.mb.mbxCommand, in lpfc_sli_issue_mbox_s3()
9505 psli->sli_flag, flag); in lpfc_sli_issue_mbox_s3()
9511 mod_timer(&psli->mbox_tmo, jiffies + timeout); in lpfc_sli_issue_mbox_s3()
9514 /* Mailbox cmd <cmd> issue */ in lpfc_sli_issue_mbox_s3()
9516 "(%d):0309 Mailbox cmd x%x issue Data: x%x x%x " in lpfc_sli_issue_mbox_s3()
9518 pmbox->vport ? pmbox->vport->vpi : 0, in lpfc_sli_issue_mbox_s3()
9519 mbx->mbxCommand, in lpfc_sli_issue_mbox_s3()
9520 phba->pport ? phba->pport->port_state : 0xff, in lpfc_sli_issue_mbox_s3()
9521 psli->sli_flag, flag); in lpfc_sli_issue_mbox_s3()
9523 if (mbx->mbxCommand != MBX_HEARTBEAT) { in lpfc_sli_issue_mbox_s3()
9524 if (pmbox->vport) { in lpfc_sli_issue_mbox_s3()
9525 lpfc_debugfs_disc_trc(pmbox->vport, in lpfc_sli_issue_mbox_s3()
9528 (uint32_t)mbx->mbxCommand, in lpfc_sli_issue_mbox_s3()
9529 mbx->un.varWords[0], mbx->un.varWords[1]); in lpfc_sli_issue_mbox_s3()
9532 lpfc_debugfs_disc_trc(phba->pport, in lpfc_sli_issue_mbox_s3()
9535 (uint32_t)mbx->mbxCommand, in lpfc_sli_issue_mbox_s3()
9536 mbx->un.varWords[0], mbx->un.varWords[1]); in lpfc_sli_issue_mbox_s3()
9540 psli->slistat.mbox_cmd++; in lpfc_sli_issue_mbox_s3()
9541 evtctr = psli->slistat.mbox_event; in lpfc_sli_issue_mbox_s3()
9544 mbx->mbxOwner = OWN_CHIP; in lpfc_sli_issue_mbox_s3()
9546 if (psli->sli_flag & LPFC_SLI_ACTIVE) { in lpfc_sli_issue_mbox_s3()
9548 if (pmbox->in_ext_byte_len || pmbox->out_ext_byte_len) { in lpfc_sli_issue_mbox_s3()
9549 *(((uint32_t *)mbx) + pmbox->mbox_offset_word) in lpfc_sli_issue_mbox_s3()
9550 = (uint8_t *)phba->mbox_ext in lpfc_sli_issue_mbox_s3()
9551 - (uint8_t *)phba->mbox; in lpfc_sli_issue_mbox_s3()
9554 /* Copy the mailbox extension data */ in lpfc_sli_issue_mbox_s3()
9555 if (pmbox->in_ext_byte_len && pmbox->ext_buf) { in lpfc_sli_issue_mbox_s3()
9556 lpfc_sli_pcimem_bcopy(pmbox->ext_buf, in lpfc_sli_issue_mbox_s3()
9557 (uint8_t *)phba->mbox_ext, in lpfc_sli_issue_mbox_s3()
9558 pmbox->in_ext_byte_len); in lpfc_sli_issue_mbox_s3()
9561 lpfc_sli_pcimem_bcopy(mbx, phba->mbox, MAILBOX_CMD_SIZE); in lpfc_sli_issue_mbox_s3()
9564 if (pmbox->in_ext_byte_len || pmbox->out_ext_byte_len) in lpfc_sli_issue_mbox_s3()
9565 *(((uint32_t *)mbx) + pmbox->mbox_offset_word) in lpfc_sli_issue_mbox_s3()
9568 /* Copy the mailbox extension data */ in lpfc_sli_issue_mbox_s3()
9569 if (pmbox->in_ext_byte_len && pmbox->ext_buf) in lpfc_sli_issue_mbox_s3()
9570 lpfc_memcpy_to_slim(phba->MBslimaddr + in lpfc_sli_issue_mbox_s3()
9572 pmbox->ext_buf, pmbox->in_ext_byte_len); in lpfc_sli_issue_mbox_s3()
9574 if (mbx->mbxCommand == MBX_CONFIG_PORT) in lpfc_sli_issue_mbox_s3()
9576 lpfc_sli_pcimem_bcopy(mbx, phba->mbox, in lpfc_sli_issue_mbox_s3()
9581 to_slim = phba->MBslimaddr + sizeof (uint32_t); in lpfc_sli_issue_mbox_s3()
9582 lpfc_memcpy_to_slim(to_slim, &mbx->un.varWords[0], in lpfc_sli_issue_mbox_s3()
9583 MAILBOX_CMD_SIZE - sizeof (uint32_t)); in lpfc_sli_issue_mbox_s3()
9587 to_slim = phba->MBslimaddr; in lpfc_sli_issue_mbox_s3()
9591 if (mbx->mbxCommand == MBX_CONFIG_PORT) in lpfc_sli_issue_mbox_s3()
9592 /* switch over to host mailbox */ in lpfc_sli_issue_mbox_s3()
9593 psli->sli_flag |= LPFC_SLI_ACTIVE; in lpfc_sli_issue_mbox_s3()
9600 /* Set up reference to mailbox command */ in lpfc_sli_issue_mbox_s3()
9601 psli->mbox_active = pmbox; in lpfc_sli_issue_mbox_s3()
9603 writel(CA_MBATT, phba->CAregaddr); in lpfc_sli_issue_mbox_s3()
9604 readl(phba->CAregaddr); /* flush */ in lpfc_sli_issue_mbox_s3()
9609 /* Set up null reference to mailbox command */ in lpfc_sli_issue_mbox_s3()
9610 psli->mbox_active = NULL; in lpfc_sli_issue_mbox_s3()
9612 writel(CA_MBATT, phba->CAregaddr); in lpfc_sli_issue_mbox_s3()
9613 readl(phba->CAregaddr); /* flush */ in lpfc_sli_issue_mbox_s3()
9615 if (psli->sli_flag & LPFC_SLI_ACTIVE) { in lpfc_sli_issue_mbox_s3()
9617 word0 = *((uint32_t *)phba->mbox); in lpfc_sli_issue_mbox_s3()
9621 if (lpfc_readl(phba->MBslimaddr, &word0)) { in lpfc_sli_issue_mbox_s3()
9622 spin_unlock_irqrestore(&phba->hbalock, in lpfc_sli_issue_mbox_s3()
9629 if (lpfc_readl(phba->HAregaddr, &ha_copy)) { in lpfc_sli_issue_mbox_s3()
9630 spin_unlock_irqrestore(&phba->hbalock, in lpfc_sli_issue_mbox_s3()
9640 (phba->link_state > LPFC_WARM_START))) { in lpfc_sli_issue_mbox_s3()
9642 psli->sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; in lpfc_sli_issue_mbox_s3()
9643 spin_unlock_irqrestore(&phba->hbalock, in lpfc_sli_issue_mbox_s3()
9651 && (evtctr != psli->slistat.mbox_event)) in lpfc_sli_issue_mbox_s3()
9655 spin_unlock_irqrestore(&phba->hbalock, in lpfc_sli_issue_mbox_s3()
9658 spin_lock_irqsave(&phba->hbalock, drvr_flag); in lpfc_sli_issue_mbox_s3()
9661 if (psli->sli_flag & LPFC_SLI_ACTIVE) { in lpfc_sli_issue_mbox_s3()
9663 word0 = *((uint32_t *)phba->mbox); in lpfc_sli_issue_mbox_s3()
9665 if (mbx->mbxCommand == MBX_CONFIG_PORT) { in lpfc_sli_issue_mbox_s3()
9669 slimword0 = readl(phba->MBslimaddr); in lpfc_sli_issue_mbox_s3()
9672 && slimmb->mbxStatus) { in lpfc_sli_issue_mbox_s3()
9673 psli->sli_flag &= in lpfc_sli_issue_mbox_s3()
9680 word0 = readl(phba->MBslimaddr); in lpfc_sli_issue_mbox_s3()
9683 if (lpfc_readl(phba->HAregaddr, &ha_copy)) { in lpfc_sli_issue_mbox_s3()
9684 spin_unlock_irqrestore(&phba->hbalock, in lpfc_sli_issue_mbox_s3()
9690 if (psli->sli_flag & LPFC_SLI_ACTIVE) { in lpfc_sli_issue_mbox_s3()
9692 lpfc_sli_pcimem_bcopy(phba->mbox, mbx, in lpfc_sli_issue_mbox_s3()
9694 /* Copy the mailbox extension data */ in lpfc_sli_issue_mbox_s3()
9695 if (pmbox->out_ext_byte_len && pmbox->ext_buf) { in lpfc_sli_issue_mbox_s3()
9696 lpfc_sli_pcimem_bcopy(phba->mbox_ext, in lpfc_sli_issue_mbox_s3()
9697 pmbox->ext_buf, in lpfc_sli_issue_mbox_s3()
9698 pmbox->out_ext_byte_len); in lpfc_sli_issue_mbox_s3()
9702 lpfc_memcpy_from_slim(mbx, phba->MBslimaddr, in lpfc_sli_issue_mbox_s3()
9704 /* Copy the mailbox extension data */ in lpfc_sli_issue_mbox_s3()
9705 if (pmbox->out_ext_byte_len && pmbox->ext_buf) { in lpfc_sli_issue_mbox_s3()
9707 pmbox->ext_buf, in lpfc_sli_issue_mbox_s3()
9708 phba->MBslimaddr + in lpfc_sli_issue_mbox_s3()
9710 pmbox->out_ext_byte_len); in lpfc_sli_issue_mbox_s3()
9714 writel(HA_MBATT, phba->HAregaddr); in lpfc_sli_issue_mbox_s3()
9715 readl(phba->HAregaddr); /* flush */ in lpfc_sli_issue_mbox_s3()
9717 psli->sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; in lpfc_sli_issue_mbox_s3()
9718 status = mbx->mbxStatus; in lpfc_sli_issue_mbox_s3()
9721 spin_unlock_irqrestore(&phba->hbalock, drvr_flag); in lpfc_sli_issue_mbox_s3()
9726 pmbox->u.mb.mbxStatus = MBX_NOT_FINISHED; in lpfc_sli_issue_mbox_s3()
9733 * lpfc_sli4_async_mbox_block - Block posting SLI4 asynchronous mailbox command
9736 * The function blocks the posting of SLI4 asynchronous mailbox commands from
9737 * the driver internal pending mailbox queue. It will then try to wait out the
9738 * possible outstanding mailbox command before return.
9741 * 0 - the outstanding mailbox command completed; otherwise, the wait for
9742 * the outstanding mailbox command timed out.
9747 struct lpfc_sli *psli = &phba->sli; in lpfc_sli4_async_mbox_block()
9754 /* Mark the asynchronous mailbox command posting as blocked */ in lpfc_sli4_async_mbox_block()
9755 spin_lock_irq(&phba->hbalock); in lpfc_sli4_async_mbox_block()
9756 psli->sli_flag |= LPFC_SLI_ASYNC_MBX_BLK; in lpfc_sli4_async_mbox_block()
9757 /* Determine how long we might wait for the active mailbox in lpfc_sli4_async_mbox_block()
9760 if (phba->sli.mbox_active) in lpfc_sli4_async_mbox_block()
9762 phba->sli.mbox_active) * in lpfc_sli4_async_mbox_block()
9764 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_mbox_block()
9766 /* Make sure the mailbox is really active */ in lpfc_sli4_async_mbox_block()
9770 /* Wait for the outstanding mailbox command to complete */ in lpfc_sli4_async_mbox_block()
9771 while (phba->sli.mbox_active) { in lpfc_sli4_async_mbox_block()
9772 /* Check active mailbox complete status every 2ms */ in lpfc_sli4_async_mbox_block()
9781 spin_lock_irq(&phba->hbalock); in lpfc_sli4_async_mbox_block()
9782 if (phba->sli.mbox_active) { in lpfc_sli4_async_mbox_block()
9783 mboxq = phba->sli.mbox_active; in lpfc_sli4_async_mbox_block()
9784 cmd = mboxq->u.mb.mbxCommand; in lpfc_sli4_async_mbox_block()
9789 sli_flag = psli->sli_flag; in lpfc_sli4_async_mbox_block()
9790 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_mbox_block()
9792 "2352 Mailbox command x%x " in lpfc_sli4_async_mbox_block()
9798 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_mbox_block()
9806 /* Can not cleanly block async mailbox command, fails it */ in lpfc_sli4_async_mbox_block()
9808 spin_lock_irq(&phba->hbalock); in lpfc_sli4_async_mbox_block()
9809 psli->sli_flag &= ~LPFC_SLI_ASYNC_MBX_BLK; in lpfc_sli4_async_mbox_block()
9810 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_mbox_block()
9816 * lpfc_sli4_async_mbox_unblock - Block posting SLI4 async mailbox command
9819 * The function unblocks and resume posting of SLI4 asynchronous mailbox
9820 * commands from the driver internal pending mailbox queue. It makes sure
9821 * that there is no outstanding mailbox command before resuming posting
9822 * asynchronous mailbox commands. If, for any reason, there is outstanding
9823 * mailbox command, it will try to wait it out before resuming asynchronous
9824 * mailbox command posting.
9829 struct lpfc_sli *psli = &phba->sli; in lpfc_sli4_async_mbox_unblock()
9831 spin_lock_irq(&phba->hbalock); in lpfc_sli4_async_mbox_unblock()
9832 if (!(psli->sli_flag & LPFC_SLI_ASYNC_MBX_BLK)) { in lpfc_sli4_async_mbox_unblock()
9833 /* Asynchronous mailbox posting is not blocked, do nothing */ in lpfc_sli4_async_mbox_unblock()
9834 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_mbox_unblock()
9838 /* Outstanding synchronous mailbox command is guaranteed to be done, in lpfc_sli4_async_mbox_unblock()
9839 * successful or timeout, after timing-out the outstanding mailbox in lpfc_sli4_async_mbox_unblock()
9841 * mailbox command and resume in lpfc_sli4_async_mbox_unblock()
9843 psli->sli_flag &= ~LPFC_SLI_ASYNC_MBX_BLK; in lpfc_sli4_async_mbox_unblock()
9844 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_mbox_unblock()
9846 /* wake up worker thread to post asynchronous mailbox command */ in lpfc_sli4_async_mbox_unblock()
9851 * lpfc_sli4_wait_bmbx_ready - Wait for bootstrap mailbox register ready
9853 * @mboxq: Pointer to mailbox object.
9855 * The function waits for the bootstrap mailbox register ready bit from
9856 * port for twice the regular mailbox command timeout value.
9858 * 0 - no timeout on waiting for bootstrap mailbox register ready.
9859 * MBXERR_ERROR - wait for bootstrap mailbox register timed out or port
9868 struct lpfc_register portstat_reg = {-1}; in lpfc_sli4_wait_bmbx_ready()
9870 /* Sanity check - there is no point to wait if the port is in an in lpfc_sli4_wait_bmbx_ready()
9873 if (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) >= in lpfc_sli4_wait_bmbx_ready()
9875 if (lpfc_readl(phba->sli4_hba.u.if_type2.STATUSregaddr, in lpfc_sli4_wait_bmbx_ready()
9890 bmbx_reg.word0 = readl(phba->sli4_hba.BMBXregaddr); in lpfc_sli4_wait_bmbx_ready()
9903 * lpfc_sli4_post_sync_mbox - Post an SLI4 mailbox to the bootstrap mailbox
9905 * @mboxq: Pointer to mailbox object.
9907 * The function posts a mailbox to the port. The mailbox is expected
9910 * mailbox by polling for its completion.
9915 * MBX_SUCCESS - mailbox posted successfully
9925 struct lpfc_sli *psli = &phba->sli; in lpfc_sli4_post_sync_mbox()
9926 struct lpfc_mqe *mb = &mboxq->u.mqe; in lpfc_sli4_post_sync_mbox()
9931 * Only one mailbox can be active to the bootstrap mailbox region in lpfc_sli4_post_sync_mbox()
9934 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli4_post_sync_mbox()
9935 if (psli->sli_flag & LPFC_SLI_MBOX_ACTIVE) { in lpfc_sli4_post_sync_mbox()
9936 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli4_post_sync_mbox()
9938 "(%d):2532 Mailbox command x%x (x%x/x%x) " in lpfc_sli4_post_sync_mbox()
9940 mboxq->vport ? mboxq->vport->vpi : 0, in lpfc_sli4_post_sync_mbox()
9941 mboxq->u.mb.mbxCommand, in lpfc_sli4_post_sync_mbox()
9944 psli->sli_flag, MBX_POLL); in lpfc_sli4_post_sync_mbox()
9948 psli->sli_flag |= LPFC_SLI_MBOX_ACTIVE; in lpfc_sli4_post_sync_mbox()
9949 phba->sli.mbox_active = mboxq; in lpfc_sli4_post_sync_mbox()
9950 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli4_post_sync_mbox()
9958 * in the mailbox post. Then copy the caller's mailbox contents to in lpfc_sli4_post_sync_mbox()
9959 * the bmbx mailbox region. in lpfc_sli4_post_sync_mbox()
9962 memset(phba->sli4_hba.bmbx.avirt, 0, sizeof(struct lpfc_bmbx_create)); in lpfc_sli4_post_sync_mbox()
9963 lpfc_sli4_pcimem_bcopy(mb, phba->sli4_hba.bmbx.avirt, in lpfc_sli4_post_sync_mbox()
9966 /* Post the high mailbox dma address to the port and wait for ready. */ in lpfc_sli4_post_sync_mbox()
9967 dma_address = &phba->sli4_hba.bmbx.dma_address; in lpfc_sli4_post_sync_mbox()
9968 writel(dma_address->addr_hi, phba->sli4_hba.BMBXregaddr); in lpfc_sli4_post_sync_mbox()
9970 /* wait for bootstrap mbox register for hi-address write done */ in lpfc_sli4_post_sync_mbox()
9975 /* Post the low mailbox dma address to the port. */ in lpfc_sli4_post_sync_mbox()
9976 writel(dma_address->addr_lo, phba->sli4_hba.BMBXregaddr); in lpfc_sli4_post_sync_mbox()
9984 * Read the CQ to ensure the mailbox has completed. in lpfc_sli4_post_sync_mbox()
9985 * If so, update the mailbox status so that the upper layers in lpfc_sli4_post_sync_mbox()
9988 lpfc_sli4_pcimem_bcopy(phba->sli4_hba.bmbx.avirt, mb, in lpfc_sli4_post_sync_mbox()
9990 mbox_rgn = (struct lpfc_bmbx_create *) phba->sli4_hba.bmbx.avirt; in lpfc_sli4_post_sync_mbox()
9991 lpfc_sli4_pcimem_bcopy(&mbox_rgn->mcqe, &mboxq->mcqe, in lpfc_sli4_post_sync_mbox()
9993 mcqe_status = bf_get(lpfc_mcqe_status, &mbox_rgn->mcqe); in lpfc_sli4_post_sync_mbox()
9995 * When the CQE status indicates a failure and the mailbox status in lpfc_sli4_post_sync_mbox()
9996 * indicates success then copy the CQE status into the mailbox status in lpfc_sli4_post_sync_mbox()
10008 "(%d):0356 Mailbox cmd x%x (x%x/x%x) Status x%x " in lpfc_sli4_post_sync_mbox()
10011 mboxq->vport ? mboxq->vport->vpi : 0, mbx_cmnd, in lpfc_sli4_post_sync_mbox()
10015 mb->un.mb_words[0], mb->un.mb_words[1], in lpfc_sli4_post_sync_mbox()
10016 mb->un.mb_words[2], mb->un.mb_words[3], in lpfc_sli4_post_sync_mbox()
10017 mb->un.mb_words[4], mb->un.mb_words[5], in lpfc_sli4_post_sync_mbox()
10018 mb->un.mb_words[6], mb->un.mb_words[7], in lpfc_sli4_post_sync_mbox()
10019 mb->un.mb_words[8], mb->un.mb_words[9], in lpfc_sli4_post_sync_mbox()
10020 mb->un.mb_words[10], mb->un.mb_words[11], in lpfc_sli4_post_sync_mbox()
10021 mb->un.mb_words[12], mboxq->mcqe.word0, in lpfc_sli4_post_sync_mbox()
10022 mboxq->mcqe.mcqe_tag0, mboxq->mcqe.mcqe_tag1, in lpfc_sli4_post_sync_mbox()
10023 mboxq->mcqe.trailer); in lpfc_sli4_post_sync_mbox()
10026 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli4_post_sync_mbox()
10027 psli->sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; in lpfc_sli4_post_sync_mbox()
10028 phba->sli.mbox_active = NULL; in lpfc_sli4_post_sync_mbox()
10029 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli4_post_sync_mbox()
10034 * lpfc_sli_issue_mbox_s4 - Issue an SLI4 mailbox command to firmware
10036 * @mboxq: Pointer to mailbox object.
10037 * @flag: Flag indicating how the mailbox need to be processed.
10040 * a mailbox command to firmware with SLI-4 interface spec.
10042 * Return codes the caller owns the mailbox command after the return of the
10049 struct lpfc_sli *psli = &phba->sli; in lpfc_sli_issue_mbox_s4()
10053 /* dump from issue mailbox command if setup */ in lpfc_sli_issue_mbox_s4()
10054 lpfc_idiag_mbxacc_dump_issue_mbox(phba, &mboxq->u.mb); in lpfc_sli_issue_mbox_s4()
10059 "(%d):2544 Mailbox command x%x (x%x/x%x) " in lpfc_sli_issue_mbox_s4()
10061 mboxq->vport ? mboxq->vport->vpi : 0, in lpfc_sli_issue_mbox_s4()
10062 mboxq->u.mb.mbxCommand, in lpfc_sli_issue_mbox_s4()
10065 psli->sli_flag, flag); in lpfc_sli_issue_mbox_s4()
10070 if (!phba->sli4_hba.intr_enable) { in lpfc_sli_issue_mbox_s4()
10074 rc = -EIO; in lpfc_sli_issue_mbox_s4()
10077 "(%d):2541 Mailbox command x%x " in lpfc_sli_issue_mbox_s4()
10081 mboxq->vport ? mboxq->vport->vpi : 0, in lpfc_sli_issue_mbox_s4()
10082 mboxq->u.mb.mbxCommand, in lpfc_sli_issue_mbox_s4()
10087 bf_get(lpfc_mqe_status, &mboxq->u.mqe), in lpfc_sli_issue_mbox_s4()
10088 bf_get(lpfc_mcqe_status, &mboxq->mcqe), in lpfc_sli_issue_mbox_s4()
10090 &mboxq->mcqe), in lpfc_sli_issue_mbox_s4()
10091 psli->sli_flag, flag); in lpfc_sli_issue_mbox_s4()
10095 "(%d):2542 Try to issue mailbox command " in lpfc_sli_issue_mbox_s4()
10097 "mailbox command queue: x%x x%x\n", in lpfc_sli_issue_mbox_s4()
10098 mboxq->vport ? mboxq->vport->vpi : 0, in lpfc_sli_issue_mbox_s4()
10099 mboxq->u.mb.mbxCommand, in lpfc_sli_issue_mbox_s4()
10102 psli->sli_flag, flag); in lpfc_sli_issue_mbox_s4()
10103 /* Try to block the asynchronous mailbox posting */ in lpfc_sli_issue_mbox_s4()
10111 "(%d):2597 Sync Mailbox command " in lpfc_sli_issue_mbox_s4()
10115 mboxq->vport ? mboxq->vport->vpi : 0, in lpfc_sli_issue_mbox_s4()
10116 mboxq->u.mb.mbxCommand, in lpfc_sli_issue_mbox_s4()
10121 bf_get(lpfc_mqe_status, &mboxq->u.mqe), in lpfc_sli_issue_mbox_s4()
10122 bf_get(lpfc_mcqe_status, &mboxq->mcqe), in lpfc_sli_issue_mbox_s4()
10124 &mboxq->mcqe), in lpfc_sli_issue_mbox_s4()
10125 psli->sli_flag, flag); in lpfc_sli_issue_mbox_s4()
10126 /* Unblock the async mailbox posting afterward */ in lpfc_sli_issue_mbox_s4()
10132 /* Now, interrupt mode asynchronous mailbox command */ in lpfc_sli_issue_mbox_s4()
10136 "(%d):2543 Mailbox command x%x (x%x/x%x) " in lpfc_sli_issue_mbox_s4()
10138 mboxq->vport ? mboxq->vport->vpi : 0, in lpfc_sli_issue_mbox_s4()
10139 mboxq->u.mb.mbxCommand, in lpfc_sli_issue_mbox_s4()
10142 psli->sli_flag, flag); in lpfc_sli_issue_mbox_s4()
10146 /* Put the mailbox command to the driver internal FIFO */ in lpfc_sli_issue_mbox_s4()
10147 psli->slistat.mbox_busy++; in lpfc_sli_issue_mbox_s4()
10148 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli_issue_mbox_s4()
10150 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli_issue_mbox_s4()
10152 "(%d):0354 Mbox cmd issue - Enqueue Data: " in lpfc_sli_issue_mbox_s4()
10154 mboxq->vport ? mboxq->vport->vpi : 0xffffff, in lpfc_sli_issue_mbox_s4()
10155 bf_get(lpfc_mqe_command, &mboxq->u.mqe), in lpfc_sli_issue_mbox_s4()
10158 mboxq->u.mb.un.varUnregLogin.rpi, in lpfc_sli_issue_mbox_s4()
10159 phba->pport->port_state, in lpfc_sli_issue_mbox_s4()
10160 psli->sli_flag, MBX_NOWAIT); in lpfc_sli_issue_mbox_s4()
10161 /* Wake up worker thread to transport mailbox command from head */ in lpfc_sli_issue_mbox_s4()
10171 * lpfc_sli4_post_async_mbox - Post an SLI4 mailbox command to device
10174 * This function is called by worker thread to send a mailbox command to
10181 struct lpfc_sli *psli = &phba->sli; in lpfc_sli4_post_async_mbox()
10188 /* Check interrupt mode before post async mailbox command */ in lpfc_sli4_post_async_mbox()
10189 if (unlikely(!phba->sli4_hba.intr_enable)) in lpfc_sli4_post_async_mbox()
10192 /* Check for mailbox command service token */ in lpfc_sli4_post_async_mbox()
10193 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_post_async_mbox()
10194 if (unlikely(psli->sli_flag & LPFC_SLI_ASYNC_MBX_BLK)) { in lpfc_sli4_post_async_mbox()
10195 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_post_async_mbox()
10198 if (psli->sli_flag & LPFC_SLI_MBOX_ACTIVE) { in lpfc_sli4_post_async_mbox()
10199 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_post_async_mbox()
10202 if (unlikely(phba->sli.mbox_active)) { in lpfc_sli4_post_async_mbox()
10203 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_post_async_mbox()
10205 "0384 There is pending active mailbox cmd\n"); in lpfc_sli4_post_async_mbox()
10208 /* Take the mailbox command service token */ in lpfc_sli4_post_async_mbox()
10209 psli->sli_flag |= LPFC_SLI_MBOX_ACTIVE; in lpfc_sli4_post_async_mbox()
10211 /* Get the next mailbox command from head of queue */ in lpfc_sli4_post_async_mbox()
10214 /* If no more mailbox command waiting for post, we're done */ in lpfc_sli4_post_async_mbox()
10216 psli->sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; in lpfc_sli4_post_async_mbox()
10217 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_post_async_mbox()
10220 phba->sli.mbox_active = mboxq; in lpfc_sli4_post_async_mbox()
10221 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_post_async_mbox()
10223 /* Check device readiness for posting mailbox command */ in lpfc_sli4_post_async_mbox()
10226 /* Driver clean routine will clean up pending mailbox */ in lpfc_sli4_post_async_mbox()
10230 mqe = &mboxq->u.mqe; in lpfc_sli4_post_async_mbox()
10233 /* Start timer for the mbox_tmo and log some mailbox post messages */ in lpfc_sli4_post_async_mbox()
10234 mod_timer(&psli->mbox_tmo, (jiffies + in lpfc_sli4_post_async_mbox()
10238 "(%d):0355 Mailbox cmd x%x (x%x/x%x) issue Data: " in lpfc_sli4_post_async_mbox()
10240 mboxq->vport ? mboxq->vport->vpi : 0, mbx_cmnd, in lpfc_sli4_post_async_mbox()
10243 phba->pport->port_state, psli->sli_flag); in lpfc_sli4_post_async_mbox()
10246 if (mboxq->vport) { in lpfc_sli4_post_async_mbox()
10247 lpfc_debugfs_disc_trc(mboxq->vport, in lpfc_sli4_post_async_mbox()
10250 mbx_cmnd, mqe->un.mb_words[0], in lpfc_sli4_post_async_mbox()
10251 mqe->un.mb_words[1]); in lpfc_sli4_post_async_mbox()
10253 lpfc_debugfs_disc_trc(phba->pport, in lpfc_sli4_post_async_mbox()
10256 mbx_cmnd, mqe->un.mb_words[0], in lpfc_sli4_post_async_mbox()
10257 mqe->un.mb_words[1]); in lpfc_sli4_post_async_mbox()
10260 psli->slistat.mbox_cmd++; in lpfc_sli4_post_async_mbox()
10262 /* Post the mailbox command to the port */ in lpfc_sli4_post_async_mbox()
10263 rc = lpfc_sli4_mq_put(phba->sli4_hba.mbx_wq, mqe); in lpfc_sli4_post_async_mbox()
10266 "(%d):2533 Mailbox command x%x (x%x/x%x) " in lpfc_sli4_post_async_mbox()
10268 mboxq->vport ? mboxq->vport->vpi : 0, in lpfc_sli4_post_async_mbox()
10269 mboxq->u.mb.mbxCommand, in lpfc_sli4_post_async_mbox()
10272 psli->sli_flag, MBX_NOWAIT); in lpfc_sli4_post_async_mbox()
10279 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_post_async_mbox()
10280 if (phba->sli.mbox_active) { in lpfc_sli4_post_async_mbox()
10281 mboxq->u.mb.mbxStatus = MBX_NOT_FINISHED; in lpfc_sli4_post_async_mbox()
10284 psli->sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; in lpfc_sli4_post_async_mbox()
10285 phba->sli.mbox_active = NULL; in lpfc_sli4_post_async_mbox()
10287 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_post_async_mbox()
10293 * lpfc_sli_issue_mbox - Wrapper func for issuing mailbox command
10295 * @pmbox: Pointer to mailbox object.
10296 * @flag: Flag indicating how the mailbox need to be processed.
10298 * This routine wraps the actual SLI3 or SLI4 mailbox issuing routine from
10301 * Return codes the caller owns the mailbox command after the return of the
10307 return phba->lpfc_sli_issue_mbox(phba, pmbox, flag); in lpfc_sli_issue_mbox()
10311 * lpfc_mbox_api_table_setup - Set up mbox api function jump table
10313 * @dev_grp: The HBA PCI-Device group number.
10317 * Returns: 0 - success, -ENODEV - failure.
10325 phba->lpfc_sli_issue_mbox = lpfc_sli_issue_mbox_s3; in lpfc_mbox_api_table_setup()
10326 phba->lpfc_sli_handle_slow_ring_event = in lpfc_mbox_api_table_setup()
10328 phba->lpfc_sli_hbq_to_firmware = lpfc_sli_hbq_to_firmware_s3; in lpfc_mbox_api_table_setup()
10329 phba->lpfc_sli_brdrestart = lpfc_sli_brdrestart_s3; in lpfc_mbox_api_table_setup()
10330 phba->lpfc_sli_brdready = lpfc_sli_brdready_s3; in lpfc_mbox_api_table_setup()
10333 phba->lpfc_sli_issue_mbox = lpfc_sli_issue_mbox_s4; in lpfc_mbox_api_table_setup()
10334 phba->lpfc_sli_handle_slow_ring_event = in lpfc_mbox_api_table_setup()
10336 phba->lpfc_sli_hbq_to_firmware = lpfc_sli_hbq_to_firmware_s4; in lpfc_mbox_api_table_setup()
10337 phba->lpfc_sli_brdrestart = lpfc_sli_brdrestart_s4; in lpfc_mbox_api_table_setup()
10338 phba->lpfc_sli_brdready = lpfc_sli_brdready_s4; in lpfc_mbox_api_table_setup()
10342 "1420 Invalid HBA PCI-device group: 0x%x\n", in lpfc_mbox_api_table_setup()
10344 return -ENODEV; in lpfc_mbox_api_table_setup()
10350 * __lpfc_sli_ringtx_put - Add an iocb to the txq
10364 if (phba->sli_rev == LPFC_SLI_REV4) in __lpfc_sli_ringtx_put()
10365 lockdep_assert_held(&pring->ring_lock); in __lpfc_sli_ringtx_put()
10367 lockdep_assert_held(&phba->hbalock); in __lpfc_sli_ringtx_put()
10369 list_add_tail(&piocb->list, &pring->txq); in __lpfc_sli_ringtx_put()
10373 * lpfc_sli_next_iocb - Get the next iocb in the txq
10395 lockdep_assert_held(&phba->hbalock); in lpfc_sli_next_iocb()
10407 * __lpfc_sli_issue_iocb_s3 - SLI3 device lockless ver of lpfc_sli_issue_iocb
10414 * an iocb command to an HBA with SLI-3 interface spec. If the PCI slot is
10434 struct lpfc_sli_ring *pring = &phba->sli.sli3_ring[ring_number]; in __lpfc_sli_issue_iocb_s3()
10436 lockdep_assert_held(&phba->hbalock); in __lpfc_sli_issue_iocb_s3()
10438 if (piocb->cmd_cmpl && (!piocb->vport) && in __lpfc_sli_issue_iocb_s3()
10439 (piocb->iocb.ulpCommand != CMD_ABORT_XRI_CN) && in __lpfc_sli_issue_iocb_s3()
10440 (piocb->iocb.ulpCommand != CMD_CLOSE_XRI_CN)) { in __lpfc_sli_issue_iocb_s3()
10443 piocb->iocb.ulpCommand); in __lpfc_sli_issue_iocb_s3()
10450 if (unlikely(pci_channel_offline(phba->pcidev))) in __lpfc_sli_issue_iocb_s3()
10454 if (unlikely(test_bit(DEFER_ERATT, &phba->hba_flag))) in __lpfc_sli_issue_iocb_s3()
10460 if (unlikely(phba->link_state < LPFC_LINK_DOWN)) in __lpfc_sli_issue_iocb_s3()
10467 if (unlikely(pring->flag & LPFC_STOP_IOCB_EVENT)) in __lpfc_sli_issue_iocb_s3()
10470 if (unlikely(phba->link_state == LPFC_LINK_DOWN)) { in __lpfc_sli_issue_iocb_s3()
10475 switch (piocb->iocb.ulpCommand) { in __lpfc_sli_issue_iocb_s3()
10482 if (piocb->cmd_cmpl) in __lpfc_sli_issue_iocb_s3()
10483 piocb->cmd_cmpl = NULL; in __lpfc_sli_issue_iocb_s3()
10497 } else if (unlikely(pring->ringno == LPFC_FCP_RING && in __lpfc_sli_issue_iocb_s3()
10498 !(phba->sli.sli_flag & LPFC_PROCESS_LA))) { in __lpfc_sli_issue_iocb_s3()
10517 pring->stats.iocb_cmd_delay++; in __lpfc_sli_issue_iocb_s3()
10530 * __lpfc_sli_issue_fcp_io_s3 - SLI3 device for sending fcp io iocb
10537 * send an iocb command to an HBA with SLI-3 interface spec.
10550 spin_lock_irqsave(&phba->hbalock, iflags); in __lpfc_sli_issue_fcp_io_s3()
10552 spin_unlock_irqrestore(&phba->hbalock, iflags); in __lpfc_sli_issue_fcp_io_s3()
10558 * __lpfc_sli_issue_fcp_io_s4 - SLI4 device for sending fcp io wqe
10565 * an wqe command to an HBA with SLI-4 interface spec.
10575 struct lpfc_io_buf *lpfc_cmd = piocb->io_buf; in __lpfc_sli_issue_fcp_io_s4()
10578 return lpfc_sli4_issue_wqe(phba, lpfc_cmd->hdwq, piocb); in __lpfc_sli_issue_fcp_io_s4()
10584 struct lpfc_iocbq *piocb = &lpfc_cmd->cur_iocbq; in lpfc_prep_embed_io()
10585 union lpfc_wqe128 *wqe = &lpfc_cmd->cur_iocbq.wqe; in lpfc_prep_embed_io()
10590 sgl = (struct sli4_sge_le *)lpfc_cmd->dma_sgl; in lpfc_prep_embed_io()
10592 if (phba->fcp_embed_io) { in lpfc_prep_embed_io()
10596 fcp_cmnd = lpfc_cmd->fcp_cmnd; in lpfc_prep_embed_io()
10598 /* Word 0-2 - FCP_CMND */ in lpfc_prep_embed_io()
10599 type_size = le32_to_cpu(sgl->sge_len); in lpfc_prep_embed_io()
10601 wqe->generic.bde.tus.w = type_size; in lpfc_prep_embed_io()
10602 wqe->generic.bde.addrHigh = 0; in lpfc_prep_embed_io()
10603 wqe->generic.bde.addrLow = 72; /* Word 18 */ in lpfc_prep_embed_io()
10605 bf_set(wqe_wqes, &wqe->fcp_iwrite.wqe_com, 1); in lpfc_prep_embed_io()
10606 bf_set(wqe_dbde, &wqe->fcp_iwrite.wqe_com, 0); in lpfc_prep_embed_io()
10608 /* Word 18-29 FCP CMND Payload */ in lpfc_prep_embed_io()
10609 ptr = &wqe->words[18]; in lpfc_prep_embed_io()
10610 lpfc_sli_pcimem_bcopy(fcp_cmnd, ptr, le32_to_cpu(sgl->sge_len)); in lpfc_prep_embed_io()
10612 /* Word 0-2 - Inline BDE */ in lpfc_prep_embed_io()
10613 wqe->generic.bde.tus.f.bdeFlags = BUFF_TYPE_BDE_64; in lpfc_prep_embed_io()
10614 wqe->generic.bde.tus.f.bdeSize = le32_to_cpu(sgl->sge_len); in lpfc_prep_embed_io()
10615 wqe->generic.bde.addrHigh = le32_to_cpu(sgl->addr_hi); in lpfc_prep_embed_io()
10616 wqe->generic.bde.addrLow = le32_to_cpu(sgl->addr_lo); in lpfc_prep_embed_io()
10619 bf_set(wqe_dbde, &wqe->generic.wqe_com, 1); in lpfc_prep_embed_io()
10620 bf_set(wqe_wqes, &wqe->generic.wqe_com, 0); in lpfc_prep_embed_io()
10624 if (unlikely(piocb->cmd_flag & LPFC_IO_VMID)) { in lpfc_prep_embed_io()
10625 if (phba->pport->vmid_flag & LPFC_VMID_TYPE_PRIO) { in lpfc_prep_embed_io()
10626 bf_set(wqe_ccpe, &wqe->fcp_iwrite.wqe_com, 1); in lpfc_prep_embed_io()
10627 bf_set(wqe_ccp, &wqe->fcp_iwrite.wqe_com, in lpfc_prep_embed_io()
10628 (piocb->vmid_tag.cs_ctl_vmid)); in lpfc_prep_embed_io()
10629 } else if (phba->cfg_vmid_app_header) { in lpfc_prep_embed_io()
10630 bf_set(wqe_appid, &wqe->fcp_iwrite.wqe_com, 1); in lpfc_prep_embed_io()
10631 bf_set(wqe_wqes, &wqe->fcp_iwrite.wqe_com, 1); in lpfc_prep_embed_io()
10632 wqe->words[31] = piocb->vmid_tag.app_id; in lpfc_prep_embed_io()
10638 * __lpfc_sli_issue_iocb_s4 - SLI4 device lockless ver of lpfc_sli_issue_iocb
10645 * an iocb command to an HBA with SLI-4 interface spec.
10662 if ((piocb->cmd_flag & LPFC_IO_FCP) || in __lpfc_sli_issue_iocb_s4()
10663 (piocb->cmd_flag & LPFC_USE_FCPWQIDX)) { in __lpfc_sli_issue_iocb_s4()
10664 wq = phba->sli4_hba.hdwq[piocb->hba_wqidx].io_wq; in __lpfc_sli_issue_iocb_s4()
10666 wq = phba->sli4_hba.els_wq; in __lpfc_sli_issue_iocb_s4()
10670 pring = wq->pring; in __lpfc_sli_issue_iocb_s4()
10676 lockdep_assert_held(&pring->ring_lock); in __lpfc_sli_issue_iocb_s4()
10677 wqe = &piocb->wqe; in __lpfc_sli_issue_iocb_s4()
10678 if (piocb->sli4_xritag == NO_XRI) { in __lpfc_sli_issue_iocb_s4()
10694 } else if (piocb->cmd_flag & LPFC_IO_FCP) { in __lpfc_sli_issue_iocb_s4()
10703 sglq = __lpfc_get_active_sglq(phba, piocb->sli4_lxritag); in __lpfc_sli_issue_iocb_s4()
10709 piocb->sli4_lxritag = sglq->sli4_lxritag; in __lpfc_sli_issue_iocb_s4()
10710 piocb->sli4_xritag = sglq->sli4_xritag; in __lpfc_sli_issue_iocb_s4()
10717 piocb->abort_bls == LPFC_ABTS_UNSOL_INT) in __lpfc_sli_issue_iocb_s4()
10718 bf_set(xmit_bls_rsp64_rxid, &wqe->xmit_bls_rsp, in __lpfc_sli_issue_iocb_s4()
10719 piocb->sli4_xritag); in __lpfc_sli_issue_iocb_s4()
10721 bf_set(wqe_xri_tag, &wqe->generic.wqe_com, in __lpfc_sli_issue_iocb_s4()
10722 piocb->sli4_xritag); in __lpfc_sli_issue_iocb_s4()
10737 * lpfc_sli_issue_fcp_io - Wrapper func for issuing fcp i/o
10739 * This routine wraps the actual fcp i/o function for issusing WQE for sli-4
10740 * or IOCB for sli-3 function.
10744 * IOCB_ERROR - Error
10745 * IOCB_SUCCESS - Success
10746 * IOCB_BUSY - Busy
10752 return phba->__lpfc_sli_issue_fcp_io(phba, ring_number, piocb, flag); in lpfc_sli_issue_fcp_io()
10756 * __lpfc_sli_issue_iocb - Wrapper func of lockless version for issuing iocb
10762 * IOCB_ERROR - Error
10763 * IOCB_SUCCESS - Success
10764 * IOCB_BUSY - Busy
10770 return phba->__lpfc_sli_issue_iocb(phba, ring_number, piocb, flag); in __lpfc_sli_issue_iocb()
10779 struct lpfc_hba *phba = vport->phba; in __lpfc_sli_prep_els_req_rsp_s3()
10782 cmd = &cmdiocbq->iocb; in __lpfc_sli_prep_els_req_rsp_s3()
10785 cmd->un.elsreq64.bdl.addrHigh = putPaddrHigh(bmp->phys); in __lpfc_sli_prep_els_req_rsp_s3()
10786 cmd->un.elsreq64.bdl.addrLow = putPaddrLow(bmp->phys); in __lpfc_sli_prep_els_req_rsp_s3()
10787 cmd->un.elsreq64.bdl.bdeFlags = BUFF_TYPE_BLP_64; in __lpfc_sli_prep_els_req_rsp_s3()
10790 cmd->un.elsreq64.bdl.bdeSize = (2 * sizeof(struct ulp_bde64)); in __lpfc_sli_prep_els_req_rsp_s3()
10791 cmd->un.elsreq64.remoteID = did; /* DID */ in __lpfc_sli_prep_els_req_rsp_s3()
10792 cmd->ulpCommand = CMD_ELS_REQUEST64_CR; in __lpfc_sli_prep_els_req_rsp_s3()
10793 cmd->ulpTimeout = tmo; in __lpfc_sli_prep_els_req_rsp_s3()
10795 cmd->un.elsreq64.bdl.bdeSize = sizeof(struct ulp_bde64); in __lpfc_sli_prep_els_req_rsp_s3()
10796 cmd->un.genreq64.xmit_els_remoteID = did; /* DID */ in __lpfc_sli_prep_els_req_rsp_s3()
10797 cmd->ulpCommand = CMD_XMIT_ELS_RSP64_CX; in __lpfc_sli_prep_els_req_rsp_s3()
10798 cmd->ulpPU = PARM_NPIV_DID; in __lpfc_sli_prep_els_req_rsp_s3()
10800 cmd->ulpBdeCount = 1; in __lpfc_sli_prep_els_req_rsp_s3()
10801 cmd->ulpLe = 1; in __lpfc_sli_prep_els_req_rsp_s3()
10802 cmd->ulpClass = CLASS3; in __lpfc_sli_prep_els_req_rsp_s3()
10805 if (phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) { in __lpfc_sli_prep_els_req_rsp_s3()
10807 cmd->un.elsreq64.myID = vport->fc_myDID; in __lpfc_sli_prep_els_req_rsp_s3()
10810 cmd->ulpContext = phba->vpi_ids[vport->vpi]; in __lpfc_sli_prep_els_req_rsp_s3()
10813 cmd->ulpCt_h = 0; in __lpfc_sli_prep_els_req_rsp_s3()
10816 cmd->ulpCt_l = 0; /* context = invalid RPI */ in __lpfc_sli_prep_els_req_rsp_s3()
10818 cmd->ulpCt_l = 1; /* context = VPI */ in __lpfc_sli_prep_els_req_rsp_s3()
10828 struct lpfc_hba *phba = vport->phba; in __lpfc_sli_prep_els_req_rsp_s4()
10833 wqe = &cmdiocbq->wqe; in __lpfc_sli_prep_els_req_rsp_s4()
10836 /* Word 0 - 2 BDE */ in __lpfc_sli_prep_els_req_rsp_s4()
10837 bde = (struct ulp_bde64_le *)&wqe->generic.bde; in __lpfc_sli_prep_els_req_rsp_s4()
10838 bde->addr_low = cpu_to_le32(putPaddrLow(bmp->phys)); in __lpfc_sli_prep_els_req_rsp_s4()
10839 bde->addr_high = cpu_to_le32(putPaddrHigh(bmp->phys)); in __lpfc_sli_prep_els_req_rsp_s4()
10840 bde->type_size = cpu_to_le32(cmd_size); in __lpfc_sli_prep_els_req_rsp_s4()
10841 bde->type_size |= cpu_to_le32(ULP_BDE64_TYPE_BDE_64); in __lpfc_sli_prep_els_req_rsp_s4()
10844 bf_set(wqe_cmnd, &wqe->els_req.wqe_com, CMD_ELS_REQUEST64_WQE); in __lpfc_sli_prep_els_req_rsp_s4()
10847 wqe->els_req.payload_len = cmd_size; in __lpfc_sli_prep_els_req_rsp_s4()
10848 wqe->els_req.max_response_payload_len = FCELSSIZE; in __lpfc_sli_prep_els_req_rsp_s4()
10851 bf_set(wqe_els_did, &wqe->els_req.wqe_dest, did); in __lpfc_sli_prep_els_req_rsp_s4()
10853 /* Word 11 - ELS_ID */ in __lpfc_sli_prep_els_req_rsp_s4()
10865 if (!vport->fc_myDID) { in __lpfc_sli_prep_els_req_rsp_s4()
10875 bf_set(wqe_els_id, &wqe->els_req.wqe_com, els_id); in __lpfc_sli_prep_els_req_rsp_s4()
10878 bf_set(wqe_els_did, &wqe->xmit_els_rsp.wqe_dest, did); in __lpfc_sli_prep_els_req_rsp_s4()
10881 wqe->xmit_els_rsp.response_payload_len = cmd_size; in __lpfc_sli_prep_els_req_rsp_s4()
10883 bf_set(wqe_cmnd, &wqe->xmit_els_rsp.wqe_com, in __lpfc_sli_prep_els_req_rsp_s4()
10887 bf_set(wqe_tmo, &wqe->generic.wqe_com, tmo); in __lpfc_sli_prep_els_req_rsp_s4()
10888 bf_set(wqe_reqtag, &wqe->generic.wqe_com, cmdiocbq->iotag); in __lpfc_sli_prep_els_req_rsp_s4()
10889 bf_set(wqe_class, &wqe->generic.wqe_com, CLASS3); in __lpfc_sli_prep_els_req_rsp_s4()
10895 if ((phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) || in __lpfc_sli_prep_els_req_rsp_s4()
10896 test_bit(FC_PT2PT, &vport->fc_flag)) { in __lpfc_sli_prep_els_req_rsp_s4()
10898 bf_set(els_req64_sid, &wqe->els_req, vport->fc_myDID); in __lpfc_sli_prep_els_req_rsp_s4()
10901 bf_set(wqe_ctxt_tag, &wqe->els_req.wqe_com, in __lpfc_sli_prep_els_req_rsp_s4()
10902 phba->vpi_ids[vport->vpi]); in __lpfc_sli_prep_els_req_rsp_s4()
10907 bf_set(wqe_ct, &wqe->generic.wqe_com, 0); in __lpfc_sli_prep_els_req_rsp_s4()
10909 bf_set(wqe_ct, &wqe->generic.wqe_com, 1); in __lpfc_sli_prep_els_req_rsp_s4()
10919 phba->__lpfc_sli_prep_els_req_rsp(cmdiocbq, vport, bmp, cmd_size, did, in lpfc_sli_prep_els_req_rsp()
10929 cmd = &cmdiocbq->iocb; in __lpfc_sli_prep_gen_req_s3()
10932 cmd->un.genreq64.bdl.addrHigh = putPaddrHigh(bmp->phys); in __lpfc_sli_prep_gen_req_s3()
10933 cmd->un.genreq64.bdl.addrLow = putPaddrLow(bmp->phys); in __lpfc_sli_prep_gen_req_s3()
10934 cmd->un.genreq64.bdl.bdeFlags = BUFF_TYPE_BLP_64; in __lpfc_sli_prep_gen_req_s3()
10935 cmd->un.genreq64.bdl.bdeSize = num_entry * sizeof(struct ulp_bde64); in __lpfc_sli_prep_gen_req_s3()
10937 cmd->un.genreq64.w5.hcsw.Rctl = FC_RCTL_DD_UNSOL_CTL; in __lpfc_sli_prep_gen_req_s3()
10938 cmd->un.genreq64.w5.hcsw.Type = FC_TYPE_CT; in __lpfc_sli_prep_gen_req_s3()
10939 cmd->un.genreq64.w5.hcsw.Fctl = (SI | LA); in __lpfc_sli_prep_gen_req_s3()
10941 cmd->ulpContext = rpi; in __lpfc_sli_prep_gen_req_s3()
10942 cmd->ulpClass = CLASS3; in __lpfc_sli_prep_gen_req_s3()
10943 cmd->ulpCommand = CMD_GEN_REQUEST64_CR; in __lpfc_sli_prep_gen_req_s3()
10944 cmd->ulpBdeCount = 1; in __lpfc_sli_prep_gen_req_s3()
10945 cmd->ulpLe = 1; in __lpfc_sli_prep_gen_req_s3()
10946 cmd->ulpOwner = OWN_CHIP; in __lpfc_sli_prep_gen_req_s3()
10947 cmd->ulpTimeout = tmo; in __lpfc_sli_prep_gen_req_s3()
10958 cmdwqe = &cmdiocbq->wqe; in __lpfc_sli_prep_gen_req_s4()
10962 bpl = (struct ulp_bde64_le *)bmp->virt; in __lpfc_sli_prep_gen_req_s4()
10975 /* Words 0 - 2 */ in __lpfc_sli_prep_gen_req_s4()
10976 bde = (struct ulp_bde64_le *)&cmdwqe->generic.bde; in __lpfc_sli_prep_gen_req_s4()
10977 bde->addr_low = bpl->addr_low; in __lpfc_sli_prep_gen_req_s4()
10978 bde->addr_high = bpl->addr_high; in __lpfc_sli_prep_gen_req_s4()
10979 bde->type_size = cpu_to_le32(xmit_len); in __lpfc_sli_prep_gen_req_s4()
10980 bde->type_size |= cpu_to_le32(ULP_BDE64_TYPE_BDE_64); in __lpfc_sli_prep_gen_req_s4()
10983 cmdwqe->gen_req.request_payload_len = xmit_len; in __lpfc_sli_prep_gen_req_s4()
10986 bf_set(wqe_type, &cmdwqe->gen_req.wge_ctl, FC_TYPE_CT); in __lpfc_sli_prep_gen_req_s4()
10987 bf_set(wqe_rctl, &cmdwqe->gen_req.wge_ctl, FC_RCTL_DD_UNSOL_CTL); in __lpfc_sli_prep_gen_req_s4()
10988 bf_set(wqe_si, &cmdwqe->gen_req.wge_ctl, 1); in __lpfc_sli_prep_gen_req_s4()
10989 bf_set(wqe_la, &cmdwqe->gen_req.wge_ctl, 1); in __lpfc_sli_prep_gen_req_s4()
10992 bf_set(wqe_ctxt_tag, &cmdwqe->gen_req.wqe_com, rpi); in __lpfc_sli_prep_gen_req_s4()
10995 bf_set(wqe_tmo, &cmdwqe->gen_req.wqe_com, tmo); in __lpfc_sli_prep_gen_req_s4()
10996 bf_set(wqe_class, &cmdwqe->gen_req.wqe_com, CLASS3); in __lpfc_sli_prep_gen_req_s4()
10997 bf_set(wqe_cmnd, &cmdwqe->gen_req.wqe_com, CMD_GEN_REQUEST64_CR); in __lpfc_sli_prep_gen_req_s4()
10998 bf_set(wqe_ct, &cmdwqe->gen_req.wqe_com, SLI4_CT_RPI); in __lpfc_sli_prep_gen_req_s4()
11001 cmdwqe->gen_req.max_response_payload_len = total_len - xmit_len; in __lpfc_sli_prep_gen_req_s4()
11008 phba->__lpfc_sli_prep_gen_req(cmdiocbq, bmp, rpi, num_entry, tmo); in lpfc_sli_prep_gen_req()
11018 icmd = &cmdiocbq->iocb; in __lpfc_sli_prep_xmit_seq64_s3()
11021 icmd->un.xseq64.bdl.addrHigh = putPaddrHigh(bmp->phys); in __lpfc_sli_prep_xmit_seq64_s3()
11022 icmd->un.xseq64.bdl.addrLow = putPaddrLow(bmp->phys); in __lpfc_sli_prep_xmit_seq64_s3()
11023 icmd->un.xseq64.bdl.bdeFlags = BUFF_TYPE_BLP_64; in __lpfc_sli_prep_xmit_seq64_s3()
11024 icmd->un.xseq64.bdl.bdeSize = (num_entry * sizeof(struct ulp_bde64)); in __lpfc_sli_prep_xmit_seq64_s3()
11025 icmd->un.xseq64.w5.hcsw.Fctl = LA; in __lpfc_sli_prep_xmit_seq64_s3()
11027 icmd->un.xseq64.w5.hcsw.Fctl |= LS; in __lpfc_sli_prep_xmit_seq64_s3()
11028 icmd->un.xseq64.w5.hcsw.Dfctl = 0; in __lpfc_sli_prep_xmit_seq64_s3()
11029 icmd->un.xseq64.w5.hcsw.Rctl = rctl; in __lpfc_sli_prep_xmit_seq64_s3()
11030 icmd->un.xseq64.w5.hcsw.Type = FC_TYPE_CT; in __lpfc_sli_prep_xmit_seq64_s3()
11032 icmd->ulpBdeCount = 1; in __lpfc_sli_prep_xmit_seq64_s3()
11033 icmd->ulpLe = 1; in __lpfc_sli_prep_xmit_seq64_s3()
11034 icmd->ulpClass = CLASS3; in __lpfc_sli_prep_xmit_seq64_s3()
11038 icmd->ulpContext = rpi; in __lpfc_sli_prep_xmit_seq64_s3()
11039 icmd->ulpCommand = CMD_XMIT_SEQUENCE64_CR; in __lpfc_sli_prep_xmit_seq64_s3()
11042 icmd->ulpContext = ox_id; in __lpfc_sli_prep_xmit_seq64_s3()
11043 icmd->ulpCommand = CMD_XMIT_SEQUENCE64_CX; in __lpfc_sli_prep_xmit_seq64_s3()
11058 wqe = &cmdiocbq->wqe; in __lpfc_sli_prep_xmit_seq64_s4()
11061 /* Words 0 - 2 */ in __lpfc_sli_prep_xmit_seq64_s4()
11062 bpl = (struct ulp_bde64 *)bmp->virt; in __lpfc_sli_prep_xmit_seq64_s4()
11063 wqe->xmit_sequence.bde.addrHigh = bpl->addrHigh; in __lpfc_sli_prep_xmit_seq64_s4()
11064 wqe->xmit_sequence.bde.addrLow = bpl->addrLow; in __lpfc_sli_prep_xmit_seq64_s4()
11065 wqe->xmit_sequence.bde.tus.w = bpl->tus.w; in __lpfc_sli_prep_xmit_seq64_s4()
11068 bf_set(wqe_ls, &wqe->xmit_sequence.wge_ctl, last_seq); in __lpfc_sli_prep_xmit_seq64_s4()
11069 bf_set(wqe_la, &wqe->xmit_sequence.wge_ctl, 1); in __lpfc_sli_prep_xmit_seq64_s4()
11070 bf_set(wqe_dfctl, &wqe->xmit_sequence.wge_ctl, 0); in __lpfc_sli_prep_xmit_seq64_s4()
11071 bf_set(wqe_rctl, &wqe->xmit_sequence.wge_ctl, rctl); in __lpfc_sli_prep_xmit_seq64_s4()
11072 bf_set(wqe_type, &wqe->xmit_sequence.wge_ctl, FC_TYPE_CT); in __lpfc_sli_prep_xmit_seq64_s4()
11075 bf_set(wqe_ctxt_tag, &wqe->xmit_sequence.wqe_com, rpi); in __lpfc_sli_prep_xmit_seq64_s4()
11077 bf_set(wqe_cmnd, &wqe->xmit_sequence.wqe_com, in __lpfc_sli_prep_xmit_seq64_s4()
11081 bf_set(wqe_class, &wqe->xmit_sequence.wqe_com, CLASS3); in __lpfc_sli_prep_xmit_seq64_s4()
11084 bf_set(wqe_rcvoxid, &wqe->xmit_sequence.wqe_com, ox_id); in __lpfc_sli_prep_xmit_seq64_s4()
11086 if (cmdiocbq->cmd_flag & (LPFC_IO_LIBDFC | LPFC_IO_LOOPBACK)) { in __lpfc_sli_prep_xmit_seq64_s4()
11088 if (cmdiocbq->cmd_flag & LPFC_IO_VMID) { in __lpfc_sli_prep_xmit_seq64_s4()
11089 bf_set(wqe_appid, &wqe->xmit_sequence.wqe_com, 1); in __lpfc_sli_prep_xmit_seq64_s4()
11090 bf_set(wqe_wqes, &wqe->xmit_sequence.wqe_com, 1); in __lpfc_sli_prep_xmit_seq64_s4()
11091 wqe->words[31] = LOOPBACK_SRC_APPID; in __lpfc_sli_prep_xmit_seq64_s4()
11095 wqe->xmit_sequence.xmit_len = full_size; in __lpfc_sli_prep_xmit_seq64_s4()
11098 wqe->xmit_sequence.xmit_len = in __lpfc_sli_prep_xmit_seq64_s4()
11099 wqe->xmit_sequence.bde.tus.f.bdeSize; in __lpfc_sli_prep_xmit_seq64_s4()
11107 phba->__lpfc_sli_prep_xmit_seq64(cmdiocbq, bmp, rpi, ox_id, num_entry, in lpfc_sli_prep_xmit_seq64()
11118 icmd = &cmdiocbq->iocb; in __lpfc_sli_prep_abort_xri_s3()
11122 icmd->un.acxri.abortContextTag = ulp_context; in __lpfc_sli_prep_abort_xri_s3()
11123 icmd->un.acxri.abortIoTag = iotag; in __lpfc_sli_prep_abort_xri_s3()
11127 icmd->ulpCommand = CMD_CLOSE_XRI_CN; in __lpfc_sli_prep_abort_xri_s3()
11130 icmd->un.acxri.abortType = ABORT_TYPE_ABTS; in __lpfc_sli_prep_abort_xri_s3()
11133 icmd->ulpClass = ulp_class; in __lpfc_sli_prep_abort_xri_s3()
11134 icmd->ulpCommand = CMD_ABORT_XRI_CN; in __lpfc_sli_prep_abort_xri_s3()
11138 icmd->ulpLe = 1; in __lpfc_sli_prep_abort_xri_s3()
11148 wqe = &cmdiocbq->wqe; in __lpfc_sli_prep_abort_xri_s4()
11152 bf_set(abort_cmd_criteria, &wqe->abort_cmd, T_XRI_TAG); in __lpfc_sli_prep_abort_xri_s4()
11154 bf_set(abort_cmd_ia, &wqe->abort_cmd, 1); in __lpfc_sli_prep_abort_xri_s4()
11156 bf_set(abort_cmd_ia, &wqe->abort_cmd, 0); in __lpfc_sli_prep_abort_xri_s4()
11159 bf_set(wqe_cmnd, &wqe->abort_cmd.wqe_com, CMD_ABORT_XRI_WQE); in __lpfc_sli_prep_abort_xri_s4()
11162 wqe->abort_cmd.wqe_com.abort_tag = ulp_context; in __lpfc_sli_prep_abort_xri_s4()
11165 bf_set(wqe_reqtag, &wqe->abort_cmd.wqe_com, iotag); in __lpfc_sli_prep_abort_xri_s4()
11168 bf_set(wqe_qosd, &wqe->abort_cmd.wqe_com, 1); in __lpfc_sli_prep_abort_xri_s4()
11172 bf_set(wqe_wqec, &wqe->abort_cmd.wqe_com, 1); in __lpfc_sli_prep_abort_xri_s4()
11173 bf_set(wqe_cqid, &wqe->abort_cmd.wqe_com, cqid); in __lpfc_sli_prep_abort_xri_s4()
11174 bf_set(wqe_cmd_type, &wqe->abort_cmd.wqe_com, OTHER_COMMAND); in __lpfc_sli_prep_abort_xri_s4()
11182 phba->__lpfc_sli_prep_abort_xri(cmdiocbq, ulp_context, iotag, ulp_class, in lpfc_sli_prep_abort_xri()
11187 * lpfc_sli_api_table_setup - Set up sli api function jump table
11189 * @dev_grp: The HBA PCI-Device group number.
11193 * Returns: 0 - success, -ENODEV - failure.
11201 phba->__lpfc_sli_issue_iocb = __lpfc_sli_issue_iocb_s3; in lpfc_sli_api_table_setup()
11202 phba->__lpfc_sli_release_iocbq = __lpfc_sli_release_iocbq_s3; in lpfc_sli_api_table_setup()
11203 phba->__lpfc_sli_issue_fcp_io = __lpfc_sli_issue_fcp_io_s3; in lpfc_sli_api_table_setup()
11204 phba->__lpfc_sli_prep_els_req_rsp = __lpfc_sli_prep_els_req_rsp_s3; in lpfc_sli_api_table_setup()
11205 phba->__lpfc_sli_prep_gen_req = __lpfc_sli_prep_gen_req_s3; in lpfc_sli_api_table_setup()
11206 phba->__lpfc_sli_prep_xmit_seq64 = __lpfc_sli_prep_xmit_seq64_s3; in lpfc_sli_api_table_setup()
11207 phba->__lpfc_sli_prep_abort_xri = __lpfc_sli_prep_abort_xri_s3; in lpfc_sli_api_table_setup()
11210 phba->__lpfc_sli_issue_iocb = __lpfc_sli_issue_iocb_s4; in lpfc_sli_api_table_setup()
11211 phba->__lpfc_sli_release_iocbq = __lpfc_sli_release_iocbq_s4; in lpfc_sli_api_table_setup()
11212 phba->__lpfc_sli_issue_fcp_io = __lpfc_sli_issue_fcp_io_s4; in lpfc_sli_api_table_setup()
11213 phba->__lpfc_sli_prep_els_req_rsp = __lpfc_sli_prep_els_req_rsp_s4; in lpfc_sli_api_table_setup()
11214 phba->__lpfc_sli_prep_gen_req = __lpfc_sli_prep_gen_req_s4; in lpfc_sli_api_table_setup()
11215 phba->__lpfc_sli_prep_xmit_seq64 = __lpfc_sli_prep_xmit_seq64_s4; in lpfc_sli_api_table_setup()
11216 phba->__lpfc_sli_prep_abort_xri = __lpfc_sli_prep_abort_xri_s4; in lpfc_sli_api_table_setup()
11220 "1419 Invalid HBA PCI-device group: 0x%x\n", in lpfc_sli_api_table_setup()
11222 return -ENODEV; in lpfc_sli_api_table_setup()
11228 * lpfc_sli4_calc_ring - Calculates which ring to use
11242 if (piocb->cmd_flag & (LPFC_IO_FCP | LPFC_USE_FCPWQIDX)) { in lpfc_sli4_calc_ring()
11243 if (unlikely(!phba->sli4_hba.hdwq)) in lpfc_sli4_calc_ring()
11249 if (!(piocb->cmd_flag & LPFC_USE_FCPWQIDX)) { in lpfc_sli4_calc_ring()
11250 lpfc_cmd = piocb->io_buf; in lpfc_sli4_calc_ring()
11251 piocb->hba_wqidx = lpfc_cmd->hdwq_no; in lpfc_sli4_calc_ring()
11253 return phba->sli4_hba.hdwq[piocb->hba_wqidx].io_wq->pring; in lpfc_sli4_calc_ring()
11255 if (unlikely(!phba->sli4_hba.els_wq)) in lpfc_sli4_calc_ring()
11257 piocb->hba_wqidx = 0; in lpfc_sli4_calc_ring()
11258 return phba->sli4_hba.els_wq->pring; in lpfc_sli4_calc_ring()
11264 struct lpfc_hba *phba = eq->phba; in lpfc_sli4_poll_eq()
11268 * for re-schedule, but we are good for io submission in lpfc_sli4_poll_eq()
11275 if (READ_ONCE(eq->mode) == LPFC_EQ_POLL) in lpfc_sli4_poll_eq()
11288 * lpfc_sli_issue_iocb - Wrapper function for __lpfc_sli_issue_iocb
11310 if (unlikely(pci_channel_offline(phba->pcidev))) in lpfc_sli_issue_iocb()
11313 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_sli_issue_iocb()
11316 eq = phba->sli4_hba.hdwq[piocb->hba_wqidx].hba_eq; in lpfc_sli_issue_iocb()
11322 spin_lock_irqsave(&pring->ring_lock, iflags); in lpfc_sli_issue_iocb()
11324 spin_unlock_irqrestore(&pring->ring_lock, iflags); in lpfc_sli_issue_iocb()
11329 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli_issue_iocb()
11331 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli_issue_iocb()
11337 * lpfc_extra_ring_setup - Extra ring setup function
11353 psli = &phba->sli; in lpfc_extra_ring_setup()
11358 pring = &psli->sli3_ring[LPFC_FCP_RING]; in lpfc_extra_ring_setup()
11359 pring->sli.sli3.numCiocb -= SLI2_IOCB_CMD_R1XTRA_ENTRIES; in lpfc_extra_ring_setup()
11360 pring->sli.sli3.numRiocb -= SLI2_IOCB_RSP_R1XTRA_ENTRIES; in lpfc_extra_ring_setup()
11361 pring->sli.sli3.numCiocb -= SLI2_IOCB_CMD_R3XTRA_ENTRIES; in lpfc_extra_ring_setup()
11362 pring->sli.sli3.numRiocb -= SLI2_IOCB_RSP_R3XTRA_ENTRIES; in lpfc_extra_ring_setup()
11365 pring = &psli->sli3_ring[LPFC_EXTRA_RING]; in lpfc_extra_ring_setup()
11367 pring->sli.sli3.numCiocb += SLI2_IOCB_CMD_R1XTRA_ENTRIES; in lpfc_extra_ring_setup()
11368 pring->sli.sli3.numRiocb += SLI2_IOCB_RSP_R1XTRA_ENTRIES; in lpfc_extra_ring_setup()
11369 pring->sli.sli3.numCiocb += SLI2_IOCB_CMD_R3XTRA_ENTRIES; in lpfc_extra_ring_setup()
11370 pring->sli.sli3.numRiocb += SLI2_IOCB_RSP_R3XTRA_ENTRIES; in lpfc_extra_ring_setup()
11373 pring->iotag_max = 4096; in lpfc_extra_ring_setup()
11374 pring->num_mask = 1; in lpfc_extra_ring_setup()
11375 pring->prt[0].profile = 0; /* Mask 0 */ in lpfc_extra_ring_setup()
11376 pring->prt[0].rctl = phba->cfg_multi_ring_rctl; in lpfc_extra_ring_setup()
11377 pring->prt[0].type = phba->cfg_multi_ring_type; in lpfc_extra_ring_setup()
11378 pring->prt[0].lpfc_sli_rcv_unsol_event = NULL; in lpfc_extra_ring_setup()
11387 struct lpfc_work_evt *evtp = &ndlp->recovery_evt; in lpfc_sli_post_recovery_event()
11393 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli_post_recovery_event()
11394 if (!list_empty(&evtp->evt_listp)) { in lpfc_sli_post_recovery_event()
11395 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli_post_recovery_event()
11400 evtp->evt_arg1 = ndlp; in lpfc_sli_post_recovery_event()
11401 evtp->evt = LPFC_EVT_RECOVER_PORT; in lpfc_sli_post_recovery_event()
11402 list_add_tail(&evtp->evt_listp, &phba->work_list); in lpfc_sli_post_recovery_event()
11403 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli_post_recovery_event()
11408 /* lpfc_sli_abts_err_handler - handle a failed ABTS request from an SLI3 port.
11428 /* The rpi in the ulpContext is vport-sensitive. */ in lpfc_sli_abts_err_handler()
11429 vpi = iocbq->iocb.un.asyncstat.sub_ctxt_tag; in lpfc_sli_abts_err_handler()
11430 rpi = iocbq->iocb.ulpContext; in lpfc_sli_abts_err_handler()
11435 vpi, rpi, iocbq->iocb.ulpStatus); in lpfc_sli_abts_err_handler()
11444 if (iocbq->iocb.ulpStatus == IOSTAT_LOCAL_REJECT) in lpfc_sli_abts_err_handler()
11452 vpi, rpi, iocbq->iocb.ulpStatus, in lpfc_sli_abts_err_handler()
11453 iocbq->iocb.ulpContext); in lpfc_sli_abts_err_handler()
11456 /* lpfc_sli4_abts_err_handler - handle a failed ABTS request from an SLI4 port.
11483 ndlp->vport->vpi, phba->sli4_hba.rpi_ids[ndlp->nlp_rpi], in lpfc_sli4_abts_err_handler()
11486 axri->parameter); in lpfc_sli4_abts_err_handler()
11493 ext_status = axri->parameter & IOERR_PARAM_MASK; in lpfc_sli4_abts_err_handler()
11500 * lpfc_sli_async_event_handler - ASYNC iocb handler function
11522 icmd = &iocbq->iocb; in lpfc_sli_async_event_handler()
11523 evt_code = icmd->un.asyncstat.evt_code; in lpfc_sli_async_event_handler()
11528 temp_event_data.data = (uint32_t) icmd->ulpContext; in lpfc_sli_async_event_handler()
11535 (uint32_t) icmd->ulpContext); in lpfc_sli_async_event_handler()
11541 (uint32_t) icmd->ulpContext); in lpfc_sli_async_event_handler()
11545 shost = lpfc_shost_from_vport(phba->pport); in lpfc_sli_async_event_handler()
11562 pring->ringno, icmd->un.asyncstat.evt_code, in lpfc_sli_async_event_handler()
11574 * lpfc_sli4_setup - SLI ring setup function
11589 pring = phba->sli4_hba.els_wq->pring; in lpfc_sli4_setup()
11590 pring->num_mask = LPFC_MAX_RING_MASK; in lpfc_sli4_setup()
11591 pring->prt[0].profile = 0; /* Mask 0 */ in lpfc_sli4_setup()
11592 pring->prt[0].rctl = FC_RCTL_ELS_REQ; in lpfc_sli4_setup()
11593 pring->prt[0].type = FC_TYPE_ELS; in lpfc_sli4_setup()
11594 pring->prt[0].lpfc_sli_rcv_unsol_event = in lpfc_sli4_setup()
11596 pring->prt[1].profile = 0; /* Mask 1 */ in lpfc_sli4_setup()
11597 pring->prt[1].rctl = FC_RCTL_ELS_REP; in lpfc_sli4_setup()
11598 pring->prt[1].type = FC_TYPE_ELS; in lpfc_sli4_setup()
11599 pring->prt[1].lpfc_sli_rcv_unsol_event = in lpfc_sli4_setup()
11601 pring->prt[2].profile = 0; /* Mask 2 */ in lpfc_sli4_setup()
11603 pring->prt[2].rctl = FC_RCTL_DD_UNSOL_CTL; in lpfc_sli4_setup()
11605 pring->prt[2].type = FC_TYPE_CT; in lpfc_sli4_setup()
11606 pring->prt[2].lpfc_sli_rcv_unsol_event = in lpfc_sli4_setup()
11608 pring->prt[3].profile = 0; /* Mask 3 */ in lpfc_sli4_setup()
11610 pring->prt[3].rctl = FC_RCTL_DD_SOL_CTL; in lpfc_sli4_setup()
11612 pring->prt[3].type = FC_TYPE_CT; in lpfc_sli4_setup()
11613 pring->prt[3].lpfc_sli_rcv_unsol_event = in lpfc_sli4_setup()
11619 * lpfc_sli_setup - SLI ring setup function
11633 struct lpfc_sli *psli = &phba->sli; in lpfc_sli_setup()
11636 psli->num_rings = MAX_SLI3_CONFIGURED_RINGS; in lpfc_sli_setup()
11637 psli->sli_flag = 0; in lpfc_sli_setup()
11639 psli->iocbq_lookup = NULL; in lpfc_sli_setup()
11640 psli->iocbq_lookup_len = 0; in lpfc_sli_setup()
11641 psli->last_iotag = 0; in lpfc_sli_setup()
11643 for (i = 0; i < psli->num_rings; i++) { in lpfc_sli_setup()
11644 pring = &psli->sli3_ring[i]; in lpfc_sli_setup()
11646 case LPFC_FCP_RING: /* ring 0 - FCP */ in lpfc_sli_setup()
11648 pring->sli.sli3.numCiocb = SLI2_IOCB_CMD_R0_ENTRIES; in lpfc_sli_setup()
11649 pring->sli.sli3.numRiocb = SLI2_IOCB_RSP_R0_ENTRIES; in lpfc_sli_setup()
11650 pring->sli.sli3.numCiocb += in lpfc_sli_setup()
11652 pring->sli.sli3.numRiocb += in lpfc_sli_setup()
11654 pring->sli.sli3.numCiocb += in lpfc_sli_setup()
11656 pring->sli.sli3.numRiocb += in lpfc_sli_setup()
11658 pring->sli.sli3.sizeCiocb = (phba->sli_rev == 3) ? in lpfc_sli_setup()
11661 pring->sli.sli3.sizeRiocb = (phba->sli_rev == 3) ? in lpfc_sli_setup()
11664 pring->iotag_ctr = 0; in lpfc_sli_setup()
11665 pring->iotag_max = in lpfc_sli_setup()
11666 (phba->cfg_hba_queue_depth * 2); in lpfc_sli_setup()
11667 pring->fast_iotag = pring->iotag_max; in lpfc_sli_setup()
11668 pring->num_mask = 0; in lpfc_sli_setup()
11670 case LPFC_EXTRA_RING: /* ring 1 - EXTRA */ in lpfc_sli_setup()
11672 pring->sli.sli3.numCiocb = SLI2_IOCB_CMD_R1_ENTRIES; in lpfc_sli_setup()
11673 pring->sli.sli3.numRiocb = SLI2_IOCB_RSP_R1_ENTRIES; in lpfc_sli_setup()
11674 pring->sli.sli3.sizeCiocb = (phba->sli_rev == 3) ? in lpfc_sli_setup()
11677 pring->sli.sli3.sizeRiocb = (phba->sli_rev == 3) ? in lpfc_sli_setup()
11680 pring->iotag_max = phba->cfg_hba_queue_depth; in lpfc_sli_setup()
11681 pring->num_mask = 0; in lpfc_sli_setup()
11683 case LPFC_ELS_RING: /* ring 2 - ELS / CT */ in lpfc_sli_setup()
11685 pring->sli.sli3.numCiocb = SLI2_IOCB_CMD_R2_ENTRIES; in lpfc_sli_setup()
11686 pring->sli.sli3.numRiocb = SLI2_IOCB_RSP_R2_ENTRIES; in lpfc_sli_setup()
11687 pring->sli.sli3.sizeCiocb = (phba->sli_rev == 3) ? in lpfc_sli_setup()
11690 pring->sli.sli3.sizeRiocb = (phba->sli_rev == 3) ? in lpfc_sli_setup()
11693 pring->fast_iotag = 0; in lpfc_sli_setup()
11694 pring->iotag_ctr = 0; in lpfc_sli_setup()
11695 pring->iotag_max = 4096; in lpfc_sli_setup()
11696 pring->lpfc_sli_rcv_async_status = in lpfc_sli_setup()
11698 pring->num_mask = LPFC_MAX_RING_MASK; in lpfc_sli_setup()
11699 pring->prt[0].profile = 0; /* Mask 0 */ in lpfc_sli_setup()
11700 pring->prt[0].rctl = FC_RCTL_ELS_REQ; in lpfc_sli_setup()
11701 pring->prt[0].type = FC_TYPE_ELS; in lpfc_sli_setup()
11702 pring->prt[0].lpfc_sli_rcv_unsol_event = in lpfc_sli_setup()
11704 pring->prt[1].profile = 0; /* Mask 1 */ in lpfc_sli_setup()
11705 pring->prt[1].rctl = FC_RCTL_ELS_REP; in lpfc_sli_setup()
11706 pring->prt[1].type = FC_TYPE_ELS; in lpfc_sli_setup()
11707 pring->prt[1].lpfc_sli_rcv_unsol_event = in lpfc_sli_setup()
11709 pring->prt[2].profile = 0; /* Mask 2 */ in lpfc_sli_setup()
11711 pring->prt[2].rctl = FC_RCTL_DD_UNSOL_CTL; in lpfc_sli_setup()
11713 pring->prt[2].type = FC_TYPE_CT; in lpfc_sli_setup()
11714 pring->prt[2].lpfc_sli_rcv_unsol_event = in lpfc_sli_setup()
11716 pring->prt[3].profile = 0; /* Mask 3 */ in lpfc_sli_setup()
11718 pring->prt[3].rctl = FC_RCTL_DD_SOL_CTL; in lpfc_sli_setup()
11720 pring->prt[3].type = FC_TYPE_CT; in lpfc_sli_setup()
11721 pring->prt[3].lpfc_sli_rcv_unsol_event = in lpfc_sli_setup()
11725 totiocbsize += (pring->sli.sli3.numCiocb * in lpfc_sli_setup()
11726 pring->sli.sli3.sizeCiocb) + in lpfc_sli_setup()
11727 (pring->sli.sli3.numRiocb * pring->sli.sli3.sizeRiocb); in lpfc_sli_setup()
11733 phba->brd_no, totiocbsize, in lpfc_sli_setup()
11736 if (phba->cfg_multi_ring_support == 2) in lpfc_sli_setup()
11743 * lpfc_sli4_queue_init - Queue initialization function
11746 * lpfc_sli4_queue_init sets up mailbox queues and iocb queues for each
11760 psli = &phba->sli; in lpfc_sli4_queue_init()
11761 spin_lock_irq(&phba->hbalock); in lpfc_sli4_queue_init()
11762 INIT_LIST_HEAD(&psli->mboxq); in lpfc_sli4_queue_init()
11763 INIT_LIST_HEAD(&psli->mboxq_cmpl); in lpfc_sli4_queue_init()
11765 for (i = 0; i < phba->cfg_hdw_queue; i++) { in lpfc_sli4_queue_init()
11766 pring = phba->sli4_hba.hdwq[i].io_wq->pring; in lpfc_sli4_queue_init()
11767 pring->flag = 0; in lpfc_sli4_queue_init()
11768 pring->ringno = LPFC_FCP_RING; in lpfc_sli4_queue_init()
11769 pring->txcmplq_cnt = 0; in lpfc_sli4_queue_init()
11770 INIT_LIST_HEAD(&pring->txq); in lpfc_sli4_queue_init()
11771 INIT_LIST_HEAD(&pring->txcmplq); in lpfc_sli4_queue_init()
11772 INIT_LIST_HEAD(&pring->iocb_continueq); in lpfc_sli4_queue_init()
11773 spin_lock_init(&pring->ring_lock); in lpfc_sli4_queue_init()
11775 pring = phba->sli4_hba.els_wq->pring; in lpfc_sli4_queue_init()
11776 pring->flag = 0; in lpfc_sli4_queue_init()
11777 pring->ringno = LPFC_ELS_RING; in lpfc_sli4_queue_init()
11778 pring->txcmplq_cnt = 0; in lpfc_sli4_queue_init()
11779 INIT_LIST_HEAD(&pring->txq); in lpfc_sli4_queue_init()
11780 INIT_LIST_HEAD(&pring->txcmplq); in lpfc_sli4_queue_init()
11781 INIT_LIST_HEAD(&pring->iocb_continueq); in lpfc_sli4_queue_init()
11782 spin_lock_init(&pring->ring_lock); in lpfc_sli4_queue_init()
11784 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_queue_init()
11785 pring = phba->sli4_hba.nvmels_wq->pring; in lpfc_sli4_queue_init()
11786 pring->flag = 0; in lpfc_sli4_queue_init()
11787 pring->ringno = LPFC_ELS_RING; in lpfc_sli4_queue_init()
11788 pring->txcmplq_cnt = 0; in lpfc_sli4_queue_init()
11789 INIT_LIST_HEAD(&pring->txq); in lpfc_sli4_queue_init()
11790 INIT_LIST_HEAD(&pring->txcmplq); in lpfc_sli4_queue_init()
11791 INIT_LIST_HEAD(&pring->iocb_continueq); in lpfc_sli4_queue_init()
11792 spin_lock_init(&pring->ring_lock); in lpfc_sli4_queue_init()
11795 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_queue_init()
11799 * lpfc_sli_queue_init - Queue initialization function
11802 * lpfc_sli_queue_init sets up mailbox queues and iocb queues for each
11816 psli = &phba->sli; in lpfc_sli_queue_init()
11817 spin_lock_irq(&phba->hbalock); in lpfc_sli_queue_init()
11818 INIT_LIST_HEAD(&psli->mboxq); in lpfc_sli_queue_init()
11819 INIT_LIST_HEAD(&psli->mboxq_cmpl); in lpfc_sli_queue_init()
11821 for (i = 0; i < psli->num_rings; i++) { in lpfc_sli_queue_init()
11822 pring = &psli->sli3_ring[i]; in lpfc_sli_queue_init()
11823 pring->ringno = i; in lpfc_sli_queue_init()
11824 pring->sli.sli3.next_cmdidx = 0; in lpfc_sli_queue_init()
11825 pring->sli.sli3.local_getidx = 0; in lpfc_sli_queue_init()
11826 pring->sli.sli3.cmdidx = 0; in lpfc_sli_queue_init()
11827 INIT_LIST_HEAD(&pring->iocb_continueq); in lpfc_sli_queue_init()
11828 INIT_LIST_HEAD(&pring->iocb_continue_saveq); in lpfc_sli_queue_init()
11829 INIT_LIST_HEAD(&pring->postbufq); in lpfc_sli_queue_init()
11830 pring->flag = 0; in lpfc_sli_queue_init()
11831 INIT_LIST_HEAD(&pring->txq); in lpfc_sli_queue_init()
11832 INIT_LIST_HEAD(&pring->txcmplq); in lpfc_sli_queue_init()
11833 spin_lock_init(&pring->ring_lock); in lpfc_sli_queue_init()
11835 spin_unlock_irq(&phba->hbalock); in lpfc_sli_queue_init()
11839 * lpfc_sli_mbox_sys_flush - Flush mailbox command sub-system
11842 * This routine flushes the mailbox command subsystem. It will unconditionally
11843 * flush all the mailbox commands in the three possible stages in the mailbox
11844 * command sub-system: pending mailbox command queue; the outstanding mailbox
11845 * command; and completed mailbox command queue. It is caller's responsibility
11846 * to make sure that the driver is in the proper state to flush the mailbox
11847 * command sub-system. Namely, the posting of mailbox commands into the
11848 * pending mailbox command queue from the various clients must be stopped;
11850 * mailbox command (such as in EEH or ERATT conditions) or the outstanding
11851 * mailbox command has been completed.
11857 struct lpfc_sli *psli = &phba->sli; in lpfc_sli_mbox_sys_flush()
11861 /* Disable softirqs, including timers from obtaining phba->hbalock */ in lpfc_sli_mbox_sys_flush()
11864 /* Flush all the mailbox commands in the mbox system */ in lpfc_sli_mbox_sys_flush()
11865 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_mbox_sys_flush()
11867 /* The pending mailbox command queue */ in lpfc_sli_mbox_sys_flush()
11868 list_splice_init(&phba->sli.mboxq, &completions); in lpfc_sli_mbox_sys_flush()
11869 /* The outstanding active mailbox command */ in lpfc_sli_mbox_sys_flush()
11870 if (psli->mbox_active) { in lpfc_sli_mbox_sys_flush()
11871 list_add_tail(&psli->mbox_active->list, &completions); in lpfc_sli_mbox_sys_flush()
11872 psli->mbox_active = NULL; in lpfc_sli_mbox_sys_flush()
11873 psli->sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; in lpfc_sli_mbox_sys_flush()
11875 /* The completed mailbox command queue */ in lpfc_sli_mbox_sys_flush()
11876 list_splice_init(&phba->sli.mboxq_cmpl, &completions); in lpfc_sli_mbox_sys_flush()
11877 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_mbox_sys_flush()
11879 /* Enable softirqs again, done with phba->hbalock */ in lpfc_sli_mbox_sys_flush()
11882 /* Return all flushed mailbox commands with MBX_NOT_FINISHED status */ in lpfc_sli_mbox_sys_flush()
11885 pmb->u.mb.mbxStatus = MBX_NOT_FINISHED; in lpfc_sli_mbox_sys_flush()
11886 if (pmb->mbox_cmpl) in lpfc_sli_mbox_sys_flush()
11887 pmb->mbox_cmpl(phba, pmb); in lpfc_sli_mbox_sys_flush()
11892 * lpfc_sli_host_down - Vport cleanup function
11899 * - Free discovery resources associated with this virtual
11901 * - Free iocbs associated with this virtual port in
11903 * - Send abort for all iocb commands associated with this
11912 struct lpfc_hba *phba = vport->phba; in lpfc_sli_host_down()
11913 struct lpfc_sli *psli = &phba->sli; in lpfc_sli_host_down()
11923 spin_lock_irqsave(&phba->hbalock, flags); in lpfc_sli_host_down()
11930 if (phba->sli_rev != LPFC_SLI_REV4) { in lpfc_sli_host_down()
11931 for (i = 0; i < psli->num_rings; i++) { in lpfc_sli_host_down()
11932 pring = &psli->sli3_ring[i]; in lpfc_sli_host_down()
11933 prev_pring_flag = pring->flag; in lpfc_sli_host_down()
11935 if (pring->ringno == LPFC_ELS_RING) { in lpfc_sli_host_down()
11936 pring->flag |= LPFC_DEFERRED_RING_EVENT; in lpfc_sli_host_down()
11938 set_bit(LPFC_DATA_READY, &phba->data_flags); in lpfc_sli_host_down()
11941 &pring->txq, list) { in lpfc_sli_host_down()
11942 if (iocb->vport != vport) in lpfc_sli_host_down()
11944 list_move_tail(&iocb->list, &completions); in lpfc_sli_host_down()
11947 &pring->txcmplq, list) { in lpfc_sli_host_down()
11948 if (iocb->vport != vport) in lpfc_sli_host_down()
11953 pring->flag = prev_pring_flag; in lpfc_sli_host_down()
11956 list_for_each_entry(qp, &phba->sli4_hba.lpfc_wq_list, wq_list) { in lpfc_sli_host_down()
11957 pring = qp->pring; in lpfc_sli_host_down()
11960 if (pring == phba->sli4_hba.els_wq->pring) { in lpfc_sli_host_down()
11961 pring->flag |= LPFC_DEFERRED_RING_EVENT; in lpfc_sli_host_down()
11963 set_bit(LPFC_DATA_READY, &phba->data_flags); in lpfc_sli_host_down()
11965 prev_pring_flag = pring->flag; in lpfc_sli_host_down()
11966 spin_lock(&pring->ring_lock); in lpfc_sli_host_down()
11968 &pring->txq, list) { in lpfc_sli_host_down()
11969 if (iocb->vport != vport) in lpfc_sli_host_down()
11971 list_move_tail(&iocb->list, &completions); in lpfc_sli_host_down()
11973 spin_unlock(&pring->ring_lock); in lpfc_sli_host_down()
11975 &pring->txcmplq, list) { in lpfc_sli_host_down()
11976 if (iocb->vport != vport) in lpfc_sli_host_down()
11981 pring->flag = prev_pring_flag; in lpfc_sli_host_down()
11984 spin_unlock_irqrestore(&phba->hbalock, flags); in lpfc_sli_host_down()
11996 * lpfc_sli_hba_down - Resource cleanup function for the HBA
11999 * This function cleans up all iocb, buffers, mailbox commands
12003 * - Free discovery resources for each virtual port
12004 * - Cleanup any pending fabric iocbs
12005 * - Iterate through the iocb txq and free each entry
12007 * - Free up any buffer posted to the HBA
12008 * - Free mailbox commands in the mailbox queue.
12014 struct lpfc_sli *psli = &phba->sli; in lpfc_sli_hba_down()
12021 /* Shutdown the mailbox command sub-system */ in lpfc_sli_hba_down()
12026 /* Disable softirqs, including timers from obtaining phba->hbalock */ in lpfc_sli_hba_down()
12031 spin_lock_irqsave(&phba->hbalock, flags); in lpfc_sli_hba_down()
12037 if (phba->sli_rev != LPFC_SLI_REV4) { in lpfc_sli_hba_down()
12038 for (i = 0; i < psli->num_rings; i++) { in lpfc_sli_hba_down()
12039 pring = &psli->sli3_ring[i]; in lpfc_sli_hba_down()
12041 if (pring->ringno == LPFC_ELS_RING) { in lpfc_sli_hba_down()
12042 pring->flag |= LPFC_DEFERRED_RING_EVENT; in lpfc_sli_hba_down()
12044 set_bit(LPFC_DATA_READY, &phba->data_flags); in lpfc_sli_hba_down()
12046 list_splice_init(&pring->txq, &completions); in lpfc_sli_hba_down()
12049 list_for_each_entry(qp, &phba->sli4_hba.lpfc_wq_list, wq_list) { in lpfc_sli_hba_down()
12050 pring = qp->pring; in lpfc_sli_hba_down()
12053 spin_lock(&pring->ring_lock); in lpfc_sli_hba_down()
12054 list_splice_init(&pring->txq, &completions); in lpfc_sli_hba_down()
12055 spin_unlock(&pring->ring_lock); in lpfc_sli_hba_down()
12056 if (pring == phba->sli4_hba.els_wq->pring) { in lpfc_sli_hba_down()
12057 pring->flag |= LPFC_DEFERRED_RING_EVENT; in lpfc_sli_hba_down()
12059 set_bit(LPFC_DATA_READY, &phba->data_flags); in lpfc_sli_hba_down()
12063 spin_unlock_irqrestore(&phba->hbalock, flags); in lpfc_sli_hba_down()
12069 spin_lock_irqsave(&phba->hbalock, flags); in lpfc_sli_hba_down()
12070 list_splice_init(&phba->elsbuf, &completions); in lpfc_sli_hba_down()
12071 phba->elsbuf_cnt = 0; in lpfc_sli_hba_down()
12072 phba->elsbuf_prev_cnt = 0; in lpfc_sli_hba_down()
12073 spin_unlock_irqrestore(&phba->hbalock, flags); in lpfc_sli_hba_down()
12078 lpfc_mbuf_free(phba, buf_ptr->virt, buf_ptr->phys); in lpfc_sli_hba_down()
12082 /* Enable softirqs again, done with phba->hbalock */ in lpfc_sli_hba_down()
12086 del_timer_sync(&psli->mbox_tmo); in lpfc_sli_hba_down()
12088 spin_lock_irqsave(&phba->pport->work_port_lock, flags); in lpfc_sli_hba_down()
12089 phba->pport->work_port_events &= ~WORKER_MBOX_TMO; in lpfc_sli_hba_down()
12090 spin_unlock_irqrestore(&phba->pport->work_port_lock, flags); in lpfc_sli_hba_down()
12096 * lpfc_sli_pcimem_bcopy - SLI memory copy function
12126 * lpfc_sli_bemem_bcopy - SLI memory copy function
12153 * lpfc_sli_ringpostbuf_put - Function to add a buffer to postbufq
12168 spin_lock_irq(&phba->hbalock); in lpfc_sli_ringpostbuf_put()
12169 list_add_tail(&mp->list, &pring->postbufq); in lpfc_sli_ringpostbuf_put()
12170 pring->postbufq_cnt++; in lpfc_sli_ringpostbuf_put()
12171 spin_unlock_irq(&phba->hbalock); in lpfc_sli_ringpostbuf_put()
12176 * lpfc_sli_get_buffer_tag - allocates a tag for a CMD_QUE_XRI64_CX buffer
12181 * tag is bit wise or-ed with QUE_BUFTAG_BIT to make sure that the tag
12189 spin_lock_irq(&phba->hbalock); in lpfc_sli_get_buffer_tag()
12190 phba->buffer_tag_count++; in lpfc_sli_get_buffer_tag()
12195 phba->buffer_tag_count |= QUE_BUFTAG_BIT; in lpfc_sli_get_buffer_tag()
12196 spin_unlock_irq(&phba->hbalock); in lpfc_sli_get_buffer_tag()
12197 return phba->buffer_tag_count; in lpfc_sli_get_buffer_tag()
12201 * lpfc_sli_ring_taggedbuf_get - find HBQ buffer associated with given tag
12206 * Buffers posted using CMD_QUE_XRI64_CX iocb are in pring->postbufq
12209 * This function searches the pring->postbufq list using the tag
12220 struct list_head *slp = &pring->postbufq; in lpfc_sli_ring_taggedbuf_get()
12223 spin_lock_irq(&phba->hbalock); in lpfc_sli_ring_taggedbuf_get()
12224 list_for_each_entry_safe(mp, next_mp, &pring->postbufq, list) { in lpfc_sli_ring_taggedbuf_get()
12225 if (mp->buffer_tag == tag) { in lpfc_sli_ring_taggedbuf_get()
12226 list_del_init(&mp->list); in lpfc_sli_ring_taggedbuf_get()
12227 pring->postbufq_cnt--; in lpfc_sli_ring_taggedbuf_get()
12228 spin_unlock_irq(&phba->hbalock); in lpfc_sli_ring_taggedbuf_get()
12233 spin_unlock_irq(&phba->hbalock); in lpfc_sli_ring_taggedbuf_get()
12237 pring->ringno, (unsigned long) tag, in lpfc_sli_ring_taggedbuf_get()
12238 slp->next, slp->prev, pring->postbufq_cnt); in lpfc_sli_ring_taggedbuf_get()
12244 * lpfc_sli_ringpostbuf_get - search buffers for unsolicited CT and ELS events
12264 struct list_head *slp = &pring->postbufq; in lpfc_sli_ringpostbuf_get()
12267 spin_lock_irq(&phba->hbalock); in lpfc_sli_ringpostbuf_get()
12268 list_for_each_entry_safe(mp, next_mp, &pring->postbufq, list) { in lpfc_sli_ringpostbuf_get()
12269 if (mp->phys == phys) { in lpfc_sli_ringpostbuf_get()
12270 list_del_init(&mp->list); in lpfc_sli_ringpostbuf_get()
12271 pring->postbufq_cnt--; in lpfc_sli_ringpostbuf_get()
12272 spin_unlock_irq(&phba->hbalock); in lpfc_sli_ringpostbuf_get()
12277 spin_unlock_irq(&phba->hbalock); in lpfc_sli_ringpostbuf_get()
12281 pring->ringno, (unsigned long long)phys, in lpfc_sli_ringpostbuf_get()
12282 slp->next, slp->prev, pring->postbufq_cnt); in lpfc_sli_ringpostbuf_get()
12287 * lpfc_sli_abort_els_cmpl - Completion handler for the els abort iocbs
12310 if (phba->sli_rev < LPFC_SLI_REV4) { in lpfc_sli_abort_els_cmpl()
12323 (phba->sli_rev == LPFC_SLI_REV4) ? in lpfc_sli_abort_els_cmpl()
12325 cmdiocb->iocb.ulpIoTag, in lpfc_sli_abort_els_cmpl()
12333 * lpfc_ignore_els_cmpl - Completion handler for aborted ELS command
12347 struct lpfc_nodelist *ndlp = cmdiocb->ndlp; in lpfc_ignore_els_cmpl()
12356 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_ignore_els_cmpl()
12359 irsp = &rspiocb->iocb; in lpfc_ignore_els_cmpl()
12360 iotag = irsp->ulpIoTag; in lpfc_ignore_els_cmpl()
12366 if (cmdiocb->context_un.mbox) { in lpfc_ignore_els_cmpl()
12367 mbox = cmdiocb->context_un.mbox; in lpfc_ignore_els_cmpl()
12369 cmdiocb->context_un.mbox = NULL; in lpfc_ignore_els_cmpl()
12377 ulp_command, kref_read(&cmdiocb->ndlp->kref), in lpfc_ignore_els_cmpl()
12378 ulp_status, ulp_word4, iotag, cmdiocb->ndlp); in lpfc_ignore_els_cmpl()
12392 * lpfc_sli_issue_abort_iotag - Abort function for a command iocb
12410 struct lpfc_vport *vport = cmdiocb->vport; in lpfc_sli_issue_abort_iotag()
12427 cmdiocb->cmd_flag & LPFC_DRIVER_ABORTED) in lpfc_sli_issue_abort_iotag()
12431 if (cmdiocb->cmd_flag & LPFC_IO_FABRIC) in lpfc_sli_issue_abort_iotag()
12432 cmdiocb->fabric_cmd_cmpl = lpfc_ignore_els_cmpl; in lpfc_sli_issue_abort_iotag()
12434 cmdiocb->cmd_cmpl = lpfc_ignore_els_cmpl; in lpfc_sli_issue_abort_iotag()
12442 if (test_bit(FC_UNLOADING, &vport->load_flag) && in lpfc_sli_issue_abort_iotag()
12443 pring->ringno == LPFC_ELS_RING) { in lpfc_sli_issue_abort_iotag()
12444 if (cmdiocb->cmd_flag & LPFC_IO_FABRIC) in lpfc_sli_issue_abort_iotag()
12445 cmdiocb->fabric_cmd_cmpl = lpfc_ignore_els_cmpl; in lpfc_sli_issue_abort_iotag()
12447 cmdiocb->cmd_cmpl = lpfc_ignore_els_cmpl; in lpfc_sli_issue_abort_iotag()
12459 cmdiocb->cmd_flag |= LPFC_DRIVER_ABORTED; in lpfc_sli_issue_abort_iotag()
12461 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_sli_issue_abort_iotag()
12462 ulp_context = cmdiocb->sli4_xritag; in lpfc_sli_issue_abort_iotag()
12463 iotag = abtsiocbp->iotag; in lpfc_sli_issue_abort_iotag()
12465 iotag = cmdiocb->iocb.ulpIoTag; in lpfc_sli_issue_abort_iotag()
12466 if (pring->ringno == LPFC_ELS_RING) { in lpfc_sli_issue_abort_iotag()
12467 ndlp = cmdiocb->ndlp; in lpfc_sli_issue_abort_iotag()
12468 ulp_context = ndlp->nlp_rpi; in lpfc_sli_issue_abort_iotag()
12470 ulp_context = cmdiocb->iocb.ulpContext; in lpfc_sli_issue_abort_iotag()
12475 if (test_bit(FC_UNLOADING, &vport->load_flag) || in lpfc_sli_issue_abort_iotag()
12476 phba->link_state < LPFC_LINK_UP || in lpfc_sli_issue_abort_iotag()
12477 (phba->sli_rev == LPFC_SLI_REV4 && in lpfc_sli_issue_abort_iotag()
12478 phba->sli4_hba.link_state.status == LPFC_FC_LA_TYPE_LINK_DOWN) || in lpfc_sli_issue_abort_iotag()
12479 (phba->link_flag & LS_EXTERNAL_LOOPBACK)) in lpfc_sli_issue_abort_iotag()
12485 cmdiocb->iocb.ulpClass, in lpfc_sli_issue_abort_iotag()
12489 abtsiocbp->hba_wqidx = cmdiocb->hba_wqidx; in lpfc_sli_issue_abort_iotag()
12490 if (cmdiocb->cmd_flag & LPFC_IO_FCP) in lpfc_sli_issue_abort_iotag()
12491 abtsiocbp->cmd_flag |= (LPFC_IO_FCP | LPFC_USE_FCPWQIDX); in lpfc_sli_issue_abort_iotag()
12493 if (cmdiocb->cmd_flag & LPFC_IO_FOF) in lpfc_sli_issue_abort_iotag()
12494 abtsiocbp->cmd_flag |= LPFC_IO_FOF; in lpfc_sli_issue_abort_iotag()
12497 abtsiocbp->cmd_cmpl = cmpl; in lpfc_sli_issue_abort_iotag()
12499 abtsiocbp->cmd_cmpl = lpfc_sli_abort_els_cmpl; in lpfc_sli_issue_abort_iotag()
12500 abtsiocbp->vport = vport; in lpfc_sli_issue_abort_iotag()
12502 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_sli_issue_abort_iotag()
12507 spin_lock_irqsave(&pring->ring_lock, iflags); in lpfc_sli_issue_abort_iotag()
12508 retval = __lpfc_sli_issue_iocb(phba, pring->ringno, in lpfc_sli_issue_abort_iotag()
12510 spin_unlock_irqrestore(&pring->ring_lock, iflags); in lpfc_sli_issue_abort_iotag()
12512 retval = __lpfc_sli_issue_iocb(phba, pring->ringno, in lpfc_sli_issue_abort_iotag()
12522 ulp_context, (phba->sli_rev == LPFC_SLI_REV4) ? in lpfc_sli_issue_abort_iotag()
12523 cmdiocb->iotag : iotag, iotag, cmdiocb, abtsiocbp, in lpfc_sli_issue_abort_iotag()
12524 retval, ia, abtsiocbp->cmd_cmpl); in lpfc_sli_issue_abort_iotag()
12526 cmdiocb->cmd_flag &= ~LPFC_DRIVER_ABORTED; in lpfc_sli_issue_abort_iotag()
12539 * lpfc_sli_hba_iocb_abort - Abort all iocbs to an hba.
12547 struct lpfc_sli *psli = &phba->sli; in lpfc_sli_hba_iocb_abort()
12552 if (phba->sli_rev != LPFC_SLI_REV4) { in lpfc_sli_hba_iocb_abort()
12553 for (i = 0; i < psli->num_rings; i++) { in lpfc_sli_hba_iocb_abort()
12554 pring = &psli->sli3_ring[i]; in lpfc_sli_hba_iocb_abort()
12559 list_for_each_entry(qp, &phba->sli4_hba.lpfc_wq_list, wq_list) { in lpfc_sli_hba_iocb_abort()
12560 pring = qp->pring; in lpfc_sli_hba_iocb_abort()
12568 * lpfc_sli_validate_fcp_iocb_for_abort - filter iocbs appropriate for FCP aborts
12575 * -ENODEV, if a null iocb or vport ptr is encountered
12576 * -EINVAL, if the iocb is not an FCP I/O, not on the TX cmpl queue, premarked as
12587 if (!iocbq || iocbq->vport != vport) in lpfc_sli_validate_fcp_iocb_for_abort()
12588 return -ENODEV; in lpfc_sli_validate_fcp_iocb_for_abort()
12593 ulp_command = get_job_cmnd(vport->phba, iocbq); in lpfc_sli_validate_fcp_iocb_for_abort()
12594 if (!(iocbq->cmd_flag & LPFC_IO_FCP) || in lpfc_sli_validate_fcp_iocb_for_abort()
12595 !(iocbq->cmd_flag & LPFC_IO_ON_TXCMPLQ) || in lpfc_sli_validate_fcp_iocb_for_abort()
12596 (iocbq->cmd_flag & LPFC_DRIVER_ABORTED) || in lpfc_sli_validate_fcp_iocb_for_abort()
12600 return -EINVAL; in lpfc_sli_validate_fcp_iocb_for_abort()
12606 * lpfc_sli_validate_fcp_iocb - validate commands associated with a SCSI target
12639 if (lpfc_cmd->pCmd == NULL) in lpfc_sli_validate_fcp_iocb()
12644 if ((lpfc_cmd->rdata) && (lpfc_cmd->rdata->pnode) && in lpfc_sli_validate_fcp_iocb()
12645 (lpfc_cmd->rdata->pnode->nlp_sid == tgt_id) && in lpfc_sli_validate_fcp_iocb()
12646 (scsilun_to_int(&lpfc_cmd->fcp_cmnd->fcp_lun) == lun_id)) in lpfc_sli_validate_fcp_iocb()
12650 if ((lpfc_cmd->rdata) && (lpfc_cmd->rdata->pnode) && in lpfc_sli_validate_fcp_iocb()
12651 (lpfc_cmd->rdata->pnode->nlp_sid == tgt_id)) in lpfc_sli_validate_fcp_iocb()
12667 * lpfc_sli_sum_iocb - Function to count the number of FCP iocbs pending
12689 struct lpfc_hba *phba = vport->phba; in lpfc_sli_sum_iocb()
12695 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli_sum_iocb()
12696 for (i = 1, sum = 0; i <= phba->sli.last_iotag; i++) { in lpfc_sli_sum_iocb()
12697 iocbq = phba->sli.iocbq_lookup[i]; in lpfc_sli_sum_iocb()
12699 if (!iocbq || iocbq->vport != vport) in lpfc_sli_sum_iocb()
12701 if (!(iocbq->cmd_flag & LPFC_IO_FCP) || in lpfc_sli_sum_iocb()
12702 !(iocbq->cmd_flag & LPFC_IO_ON_TXCMPLQ)) in lpfc_sli_sum_iocb()
12718 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli_sum_iocb()
12724 * lpfc_sli_abort_fcp_cmpl - Completion handler function for aborted FCP IOCBs
12741 (phba->sli_rev == LPFC_SLI_REV4) ? in lpfc_sli_abort_fcp_cmpl()
12742 cmdiocb->sli4_xritag : in lpfc_sli_abort_fcp_cmpl()
12743 cmdiocb->iocb.un.acxri.abortContextTag, in lpfc_sli_abort_fcp_cmpl()
12745 cmdiocb->iotag, get_job_ulpstatus(phba, rspiocb), in lpfc_sli_abort_fcp_cmpl()
12752 * lpfc_sli_abort_iocb - issue abort for all commands on a host/target/LUN
12781 struct lpfc_hba *phba = vport->phba; in lpfc_sli_abort_iocb()
12789 if (test_bit(HBA_IOQ_FLUSH, &phba->hba_flag)) in lpfc_sli_abort_iocb()
12792 for (i = 1; i <= phba->sli.last_iotag; i++) { in lpfc_sli_abort_iocb()
12793 iocbq = phba->sli.iocbq_lookup[i]; in lpfc_sli_abort_iocb()
12802 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli_abort_iocb()
12803 if (phba->sli_rev == LPFC_SLI_REV3) { in lpfc_sli_abort_iocb()
12804 pring = &phba->sli.sli3_ring[LPFC_FCP_RING]; in lpfc_sli_abort_iocb()
12805 } else if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_sli_abort_iocb()
12810 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli_abort_iocb()
12819 * lpfc_sli_abort_taskmgmt - issue abort for all commands on a host/target/LUN
12848 struct lpfc_hba *phba = vport->phba; in lpfc_sli_abort_taskmgmt()
12860 if (test_bit(HBA_IOQ_FLUSH, &phba->hba_flag)) in lpfc_sli_abort_taskmgmt()
12865 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli_abort_taskmgmt()
12866 for (i = 1; i <= phba->sli.last_iotag; i++) { in lpfc_sli_abort_taskmgmt()
12867 iocbq = phba->sli.iocbq_lookup[i]; in lpfc_sli_abort_taskmgmt()
12878 spin_lock(&lpfc_cmd->buf_lock); in lpfc_sli_abort_taskmgmt()
12880 if (!lpfc_cmd->pCmd) { in lpfc_sli_abort_taskmgmt()
12881 spin_unlock(&lpfc_cmd->buf_lock); in lpfc_sli_abort_taskmgmt()
12885 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_sli_abort_taskmgmt()
12887 phba->sli4_hba.hdwq[iocbq->hba_wqidx].io_wq->pring; in lpfc_sli_abort_taskmgmt()
12889 spin_unlock(&lpfc_cmd->buf_lock); in lpfc_sli_abort_taskmgmt()
12893 spin_lock(&pring_s4->ring_lock); in lpfc_sli_abort_taskmgmt()
12900 if ((iocbq->cmd_flag & LPFC_DRIVER_ABORTED) || in lpfc_sli_abort_taskmgmt()
12901 !(iocbq->cmd_flag & LPFC_IO_ON_TXCMPLQ)) { in lpfc_sli_abort_taskmgmt()
12902 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_sli_abort_taskmgmt()
12903 spin_unlock(&pring_s4->ring_lock); in lpfc_sli_abort_taskmgmt()
12904 spin_unlock(&lpfc_cmd->buf_lock); in lpfc_sli_abort_taskmgmt()
12911 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_sli_abort_taskmgmt()
12912 spin_unlock(&pring_s4->ring_lock); in lpfc_sli_abort_taskmgmt()
12913 spin_unlock(&lpfc_cmd->buf_lock); in lpfc_sli_abort_taskmgmt()
12917 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_sli_abort_taskmgmt()
12918 iotag = abtsiocbq->iotag; in lpfc_sli_abort_taskmgmt()
12919 ulp_context = iocbq->sli4_xritag; in lpfc_sli_abort_taskmgmt()
12920 cqid = lpfc_cmd->hdwq->io_cq_map; in lpfc_sli_abort_taskmgmt()
12922 iotag = iocbq->iocb.ulpIoTag; in lpfc_sli_abort_taskmgmt()
12923 if (pring->ringno == LPFC_ELS_RING) { in lpfc_sli_abort_taskmgmt()
12924 ndlp = iocbq->ndlp; in lpfc_sli_abort_taskmgmt()
12925 ulp_context = ndlp->nlp_rpi; in lpfc_sli_abort_taskmgmt()
12927 ulp_context = iocbq->iocb.ulpContext; in lpfc_sli_abort_taskmgmt()
12931 ndlp = lpfc_cmd->rdata->pnode; in lpfc_sli_abort_taskmgmt()
12934 (ndlp && ndlp->nlp_state == NLP_STE_MAPPED_NODE) && in lpfc_sli_abort_taskmgmt()
12935 !(phba->link_flag & LS_EXTERNAL_LOOPBACK)) in lpfc_sli_abort_taskmgmt()
12941 iocbq->iocb.ulpClass, cqid, in lpfc_sli_abort_taskmgmt()
12944 abtsiocbq->vport = vport; in lpfc_sli_abort_taskmgmt()
12947 abtsiocbq->hba_wqidx = iocbq->hba_wqidx; in lpfc_sli_abort_taskmgmt()
12948 if (iocbq->cmd_flag & LPFC_IO_FCP) in lpfc_sli_abort_taskmgmt()
12949 abtsiocbq->cmd_flag |= LPFC_USE_FCPWQIDX; in lpfc_sli_abort_taskmgmt()
12950 if (iocbq->cmd_flag & LPFC_IO_FOF) in lpfc_sli_abort_taskmgmt()
12951 abtsiocbq->cmd_flag |= LPFC_IO_FOF; in lpfc_sli_abort_taskmgmt()
12954 abtsiocbq->cmd_cmpl = lpfc_sli_abort_fcp_cmpl; in lpfc_sli_abort_taskmgmt()
12960 iocbq->cmd_flag |= LPFC_DRIVER_ABORTED; in lpfc_sli_abort_taskmgmt()
12962 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_sli_abort_taskmgmt()
12963 ret_val = __lpfc_sli_issue_iocb(phba, pring_s4->ringno, in lpfc_sli_abort_taskmgmt()
12965 spin_unlock(&pring_s4->ring_lock); in lpfc_sli_abort_taskmgmt()
12967 ret_val = __lpfc_sli_issue_iocb(phba, pring->ringno, in lpfc_sli_abort_taskmgmt()
12971 spin_unlock(&lpfc_cmd->buf_lock); in lpfc_sli_abort_taskmgmt()
12978 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli_abort_taskmgmt()
12983 * lpfc_sli_wake_iocb_wait - lpfc_sli_issue_iocb_wait's completion handler
13009 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli_wake_iocb_wait()
13010 if (cmdiocbq->cmd_flag & LPFC_IO_WAKE_TMO) { in lpfc_sli_wake_iocb_wait()
13018 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli_wake_iocb_wait()
13019 cmdiocbq->cmd_cmpl = cmdiocbq->wait_cmd_cmpl; in lpfc_sli_wake_iocb_wait()
13020 cmdiocbq->wait_cmd_cmpl = NULL; in lpfc_sli_wake_iocb_wait()
13021 if (cmdiocbq->cmd_cmpl) in lpfc_sli_wake_iocb_wait()
13022 cmdiocbq->cmd_cmpl(phba, cmdiocbq, NULL); in lpfc_sli_wake_iocb_wait()
13029 cmdiocbq->cmd_flag |= LPFC_IO_WAKE; in lpfc_sli_wake_iocb_wait()
13030 if (cmdiocbq->rsp_iocb && rspiocbq) in lpfc_sli_wake_iocb_wait()
13031 memcpy((char *)cmdiocbq->rsp_iocb + offset, in lpfc_sli_wake_iocb_wait()
13032 (char *)rspiocbq + offset, sizeof(*rspiocbq) - offset); in lpfc_sli_wake_iocb_wait()
13035 if ((cmdiocbq->cmd_flag & LPFC_IO_FCP) && in lpfc_sli_wake_iocb_wait()
13036 !(cmdiocbq->cmd_flag & LPFC_IO_LIBDFC)) { in lpfc_sli_wake_iocb_wait()
13039 if (rspiocbq && (rspiocbq->cmd_flag & LPFC_EXCHANGE_BUSY)) in lpfc_sli_wake_iocb_wait()
13040 lpfc_cmd->flags |= LPFC_SBUF_XBUSY; in lpfc_sli_wake_iocb_wait()
13042 lpfc_cmd->flags &= ~LPFC_SBUF_XBUSY; in lpfc_sli_wake_iocb_wait()
13045 pdone_q = cmdiocbq->context_un.wait_queue; in lpfc_sli_wake_iocb_wait()
13048 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli_wake_iocb_wait()
13053 * lpfc_chk_iocb_flg - Test IOCB flag with lock held.
13071 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_chk_iocb_flg()
13072 ret = piocbq->cmd_flag & flag; in lpfc_chk_iocb_flg()
13073 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_chk_iocb_flg()
13079 * lpfc_sli_issue_iocb_wait - Synchronous function to issue iocb commands
13098 * non-interruptible wait.
13132 if (phba->sli_rev >= LPFC_SLI_REV4) { in lpfc_sli_issue_iocb_wait()
13137 pring = &phba->sli.sli3_ring[ring_number]; in lpfc_sli_issue_iocb_wait()
13143 if (piocb->rsp_iocb) in lpfc_sli_issue_iocb_wait()
13145 piocb->rsp_iocb = prspiocbq; in lpfc_sli_issue_iocb_wait()
13148 piocb->wait_cmd_cmpl = piocb->cmd_cmpl; in lpfc_sli_issue_iocb_wait()
13149 piocb->cmd_cmpl = lpfc_sli_wake_iocb_wait; in lpfc_sli_issue_iocb_wait()
13150 piocb->context_un.wait_queue = &done_q; in lpfc_sli_issue_iocb_wait()
13151 piocb->cmd_flag &= ~(LPFC_IO_WAKE | LPFC_IO_WAKE_TMO); in lpfc_sli_issue_iocb_wait()
13153 if (phba->cfg_poll & DISABLE_FCP_RING_INT) { in lpfc_sli_issue_iocb_wait()
13154 if (lpfc_readl(phba->HCregaddr, &creg_val)) in lpfc_sli_issue_iocb_wait()
13157 writel(creg_val, phba->HCregaddr); in lpfc_sli_issue_iocb_wait()
13158 readl(phba->HCregaddr); /* flush */ in lpfc_sli_issue_iocb_wait()
13168 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli_issue_iocb_wait()
13169 if (!(piocb->cmd_flag & LPFC_IO_WAKE)) { in lpfc_sli_issue_iocb_wait()
13177 piocb->cmd_flag |= LPFC_IO_WAKE_TMO; in lpfc_sli_issue_iocb_wait()
13179 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli_issue_iocb_wait()
13184 * status or not - that's for the caller to check. in lpfc_sli_issue_iocb_wait()
13190 "0338 IOCB wait timeout error - no " in lpfc_sli_issue_iocb_wait()
13201 if (phba->cfg_log_verbose & LOG_SLI) { in lpfc_sli_issue_iocb_wait()
13202 list_for_each_entry(iocb, &pring->txq, list) { in lpfc_sli_issue_iocb_wait()
13205 list_for_each_entry(iocb, &pring->txcmplq, list) { in lpfc_sli_issue_iocb_wait()
13210 phba->iocb_cnt, txq_cnt, txcmplq_cnt); in lpfc_sli_issue_iocb_wait()
13220 if (phba->cfg_poll & DISABLE_FCP_RING_INT) { in lpfc_sli_issue_iocb_wait()
13221 if (lpfc_readl(phba->HCregaddr, &creg_val)) in lpfc_sli_issue_iocb_wait()
13224 writel(creg_val, phba->HCregaddr); in lpfc_sli_issue_iocb_wait()
13225 readl(phba->HCregaddr); /* flush */ in lpfc_sli_issue_iocb_wait()
13229 piocb->rsp_iocb = NULL; in lpfc_sli_issue_iocb_wait()
13231 piocb->context_un.wait_queue = NULL; in lpfc_sli_issue_iocb_wait()
13232 piocb->cmd_cmpl = NULL; in lpfc_sli_issue_iocb_wait()
13237 * lpfc_sli_issue_mbox_wait - Synchronous function to issue mailbox
13239 * @pmboxq: Pointer to driver mailbox object.
13242 * This function issues the mailbox to firmware and waits for the
13243 * mailbox command to complete. If the mailbox command is not
13245 * The function waits for the mailbox completion using an
13248 * should not free the mailbox resources, if this function returns
13250 * This function will sleep while waiting for mailbox completion.
13254 * This function assumes that the mailbox completion occurs while
13256 * the worker thread which processes mailbox completion.
13270 pmboxq->mbox_flag &= ~LPFC_MBX_WAKE; in lpfc_sli_issue_mbox_wait()
13272 pmboxq->mbox_cmpl = lpfc_sli_wake_mbox_wait; in lpfc_sli_issue_mbox_wait()
13276 pmboxq->ctx_u.mbox_wait = &mbox_done; in lpfc_sli_issue_mbox_wait()
13283 spin_lock_irqsave(&phba->hbalock, flag); in lpfc_sli_issue_mbox_wait()
13284 pmboxq->ctx_u.mbox_wait = NULL; in lpfc_sli_issue_mbox_wait()
13286 * if LPFC_MBX_WAKE flag is set the mailbox is completed in lpfc_sli_issue_mbox_wait()
13289 if (pmboxq->mbox_flag & LPFC_MBX_WAKE) { in lpfc_sli_issue_mbox_wait()
13293 pmboxq->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_sli_issue_mbox_wait()
13295 spin_unlock_irqrestore(&phba->hbalock, flag); in lpfc_sli_issue_mbox_wait()
13301 * lpfc_sli_mbox_sys_shutdown - shutdown mailbox command sub-system
13303 * @mbx_action: Mailbox shutdown options.
13305 * This function is called to shutdown the driver's mailbox sub-system.
13306 * It first marks the mailbox sub-system is in a block state to prevent
13307 * the asynchronous mailbox command from issued off the pending mailbox
13308 * command queue. If the mailbox command sub-system shutdown is due to
13310 * the mailbox sub-system flush routine to forcefully bring down the
13311 * mailbox sub-system. Otherwise, if it is due to normal condition (such
13313 * outstanding mailbox command to complete before invoking the mailbox
13314 * sub-system flush routine to gracefully bring down mailbox sub-system.
13319 struct lpfc_sli *psli = &phba->sli; in lpfc_sli_mbox_sys_shutdown()
13330 /* Disable softirqs, including timers from obtaining phba->hbalock */ in lpfc_sli_mbox_sys_shutdown()
13333 spin_lock_irq(&phba->hbalock); in lpfc_sli_mbox_sys_shutdown()
13334 psli->sli_flag |= LPFC_SLI_ASYNC_MBX_BLK; in lpfc_sli_mbox_sys_shutdown()
13336 if (psli->sli_flag & LPFC_SLI_ACTIVE) { in lpfc_sli_mbox_sys_shutdown()
13337 /* Determine how long we might wait for the active mailbox in lpfc_sli_mbox_sys_shutdown()
13340 if (phba->sli.mbox_active) in lpfc_sli_mbox_sys_shutdown()
13342 phba->sli.mbox_active) * in lpfc_sli_mbox_sys_shutdown()
13344 spin_unlock_irq(&phba->hbalock); in lpfc_sli_mbox_sys_shutdown()
13346 /* Enable softirqs again, done with phba->hbalock */ in lpfc_sli_mbox_sys_shutdown()
13349 while (phba->sli.mbox_active) { in lpfc_sli_mbox_sys_shutdown()
13350 /* Check active mailbox complete status every 2ms */ in lpfc_sli_mbox_sys_shutdown()
13353 /* Timeout, let the mailbox flush routine to in lpfc_sli_mbox_sys_shutdown()
13354 * forcefully release active mailbox command in lpfc_sli_mbox_sys_shutdown()
13359 spin_unlock_irq(&phba->hbalock); in lpfc_sli_mbox_sys_shutdown()
13361 /* Enable softirqs again, done with phba->hbalock */ in lpfc_sli_mbox_sys_shutdown()
13369 * lpfc_sli_eratt_read - read sli-3 error attention events
13385 if (lpfc_readl(phba->HAregaddr, &ha_copy)) in lpfc_sli_eratt_read()
13394 if ((HS_FFER1 & phba->work_hs) && in lpfc_sli_eratt_read()
13396 HS_FFER6 | HS_FFER7 | HS_FFER8) & phba->work_hs)) { in lpfc_sli_eratt_read()
13397 set_bit(DEFER_ERATT, &phba->hba_flag); in lpfc_sli_eratt_read()
13399 writel(0, phba->HCregaddr); in lpfc_sli_eratt_read()
13400 readl(phba->HCregaddr); in lpfc_sli_eratt_read()
13404 phba->work_ha |= HA_ERATT; in lpfc_sli_eratt_read()
13406 set_bit(HBA_ERATT_HANDLED, &phba->hba_flag); in lpfc_sli_eratt_read()
13413 phba->work_hs |= UNPLUG_ERR; in lpfc_sli_eratt_read()
13415 phba->work_ha |= HA_ERATT; in lpfc_sli_eratt_read()
13417 set_bit(HBA_ERATT_HANDLED, &phba->hba_flag); in lpfc_sli_eratt_read()
13422 * lpfc_sli4_eratt_read - read sli-4 error attention events
13444 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); in lpfc_sli4_eratt_read()
13447 if (lpfc_readl(phba->sli4_hba.u.if_type0.UERRLOregaddr, in lpfc_sli4_eratt_read()
13449 lpfc_readl(phba->sli4_hba.u.if_type0.UERRHIregaddr, in lpfc_sli4_eratt_read()
13451 phba->work_hs |= UNPLUG_ERR; in lpfc_sli4_eratt_read()
13452 phba->work_ha |= HA_ERATT; in lpfc_sli4_eratt_read()
13453 set_bit(HBA_ERATT_HANDLED, &phba->hba_flag); in lpfc_sli4_eratt_read()
13456 if ((~phba->sli4_hba.ue_mask_lo & uerr_sta_lo) || in lpfc_sli4_eratt_read()
13457 (~phba->sli4_hba.ue_mask_hi & uerr_sta_hi)) { in lpfc_sli4_eratt_read()
13464 phba->sli4_hba.ue_mask_lo, in lpfc_sli4_eratt_read()
13465 phba->sli4_hba.ue_mask_hi); in lpfc_sli4_eratt_read()
13466 phba->work_status[0] = uerr_sta_lo; in lpfc_sli4_eratt_read()
13467 phba->work_status[1] = uerr_sta_hi; in lpfc_sli4_eratt_read()
13468 phba->work_ha |= HA_ERATT; in lpfc_sli4_eratt_read()
13469 set_bit(HBA_ERATT_HANDLED, &phba->hba_flag); in lpfc_sli4_eratt_read()
13475 if (lpfc_readl(phba->sli4_hba.u.if_type2.STATUSregaddr, in lpfc_sli4_eratt_read()
13477 lpfc_readl(phba->sli4_hba.PSMPHRregaddr, in lpfc_sli4_eratt_read()
13479 phba->work_hs |= UNPLUG_ERR; in lpfc_sli4_eratt_read()
13480 phba->work_ha |= HA_ERATT; in lpfc_sli4_eratt_read()
13481 set_bit(HBA_ERATT_HANDLED, &phba->hba_flag); in lpfc_sli4_eratt_read()
13485 phba->work_status[0] = in lpfc_sli4_eratt_read()
13486 readl(phba->sli4_hba.u.if_type2.ERR1regaddr); in lpfc_sli4_eratt_read()
13487 phba->work_status[1] = in lpfc_sli4_eratt_read()
13488 readl(phba->sli4_hba.u.if_type2.ERR2regaddr); in lpfc_sli4_eratt_read()
13490 if (phba->work_status[0] == in lpfc_sli4_eratt_read()
13492 phba->work_status[1] == SLIPORT_ERR2_REG_FW_RESTART) in lpfc_sli4_eratt_read()
13501 phba->work_status[0], in lpfc_sli4_eratt_read()
13502 phba->work_status[1]); in lpfc_sli4_eratt_read()
13503 phba->work_ha |= HA_ERATT; in lpfc_sli4_eratt_read()
13504 set_bit(HBA_ERATT_HANDLED, &phba->hba_flag); in lpfc_sli4_eratt_read()
13520 * lpfc_sli_check_eratt - check error attention events
13537 if (phba->link_flag & LS_IGNORE_ERATT) in lpfc_sli_check_eratt()
13541 if (test_bit(HBA_ERATT_HANDLED, &phba->hba_flag)) in lpfc_sli_check_eratt()
13549 if (unlikely(test_bit(DEFER_ERATT, &phba->hba_flag))) in lpfc_sli_check_eratt()
13552 spin_lock_irq(&phba->hbalock); in lpfc_sli_check_eratt()
13554 if (unlikely(pci_channel_offline(phba->pcidev))) { in lpfc_sli_check_eratt()
13555 spin_unlock_irq(&phba->hbalock); in lpfc_sli_check_eratt()
13559 switch (phba->sli_rev) { in lpfc_sli_check_eratt()
13572 phba->sli_rev); in lpfc_sli_check_eratt()
13576 spin_unlock_irq(&phba->hbalock); in lpfc_sli_check_eratt()
13582 * lpfc_intr_state_check - Check device state for interrupt handling
13589 * interrupt should be handled, otherwise -EIO.
13595 if (unlikely(pci_channel_offline(phba->pcidev))) in lpfc_intr_state_check()
13596 return -EIO; in lpfc_intr_state_check()
13599 phba->sli.slistat.sli_intr++; in lpfc_intr_state_check()
13602 if (unlikely(phba->link_state < LPFC_LINK_DOWN)) in lpfc_intr_state_check()
13603 return -EIO; in lpfc_intr_state_check()
13609 * lpfc_sli_sp_intr_handler - Slow-path interrupt handler to SLI-3 device
13614 * service routine when device with SLI-3 interface spec is enabled with
13615 * MSI-X multi-message interrupt mode and there are slow-path events in
13616 * the HBA. However, when the device is enabled with either MSI or Pin-IRQ
13617 * interrupt mode, this function is called as part of the device-level
13657 * individual interrupt handler in MSI-X multi-message interrupt mode in lpfc_sli_sp_intr_handler()
13659 if (phba->intr_type == MSIX) { in lpfc_sli_sp_intr_handler()
13663 /* Need to read HA REG for slow-path events */ in lpfc_sli_sp_intr_handler()
13664 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_sp_intr_handler()
13665 if (lpfc_readl(phba->HAregaddr, &ha_copy)) in lpfc_sli_sp_intr_handler()
13670 if (phba->link_flag & LS_IGNORE_ERATT) in lpfc_sli_sp_intr_handler()
13675 &phba->hba_flag)) in lpfc_sli_sp_intr_handler()
13684 if (unlikely(test_bit(DEFER_ERATT, &phba->hba_flag))) { in lpfc_sli_sp_intr_handler()
13685 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_sp_intr_handler()
13689 /* Clear up only attention source related to slow-path */ in lpfc_sli_sp_intr_handler()
13690 if (lpfc_readl(phba->HCregaddr, &hc_copy)) in lpfc_sli_sp_intr_handler()
13695 phba->HCregaddr); in lpfc_sli_sp_intr_handler()
13697 phba->HAregaddr); in lpfc_sli_sp_intr_handler()
13698 writel(hc_copy, phba->HCregaddr); in lpfc_sli_sp_intr_handler()
13699 readl(phba->HAregaddr); /* flush */ in lpfc_sli_sp_intr_handler()
13700 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_sp_intr_handler()
13702 ha_copy = phba->ha_copy; in lpfc_sli_sp_intr_handler()
13704 work_ha_copy = ha_copy & phba->work_ha_mask; in lpfc_sli_sp_intr_handler()
13708 if (phba->sli.sli_flag & LPFC_PROCESS_LA) { in lpfc_sli_sp_intr_handler()
13713 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_sp_intr_handler()
13714 phba->sli.sli_flag &= ~LPFC_PROCESS_LA; in lpfc_sli_sp_intr_handler()
13715 if (lpfc_readl(phba->HCregaddr, &control)) in lpfc_sli_sp_intr_handler()
13718 writel(control, phba->HCregaddr); in lpfc_sli_sp_intr_handler()
13719 readl(phba->HCregaddr); /* flush */ in lpfc_sli_sp_intr_handler()
13720 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_sp_intr_handler()
13735 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_sp_intr_handler()
13736 if (lpfc_readl(phba->HCregaddr, &control)) in lpfc_sli_sp_intr_handler()
13742 (uint32_t)phba->sli.slistat.sli_intr); in lpfc_sli_sp_intr_handler()
13748 phba->work_ha, work_ha_copy, in lpfc_sli_sp_intr_handler()
13750 &phba->work_waitq)); in lpfc_sli_sp_intr_handler()
13754 writel(control, phba->HCregaddr); in lpfc_sli_sp_intr_handler()
13755 readl(phba->HCregaddr); /* flush */ in lpfc_sli_sp_intr_handler()
13761 phba->work_ha, work_ha_copy, in lpfc_sli_sp_intr_handler()
13763 &phba->work_waitq)); in lpfc_sli_sp_intr_handler()
13765 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_sp_intr_handler()
13768 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_sp_intr_handler()
13776 if ((HS_FFER1 & phba->work_hs) && in lpfc_sli_sp_intr_handler()
13779 phba->work_hs)) { in lpfc_sli_sp_intr_handler()
13780 set_bit(DEFER_ERATT, &phba->hba_flag); in lpfc_sli_sp_intr_handler()
13782 writel(0, phba->HCregaddr); in lpfc_sli_sp_intr_handler()
13783 readl(phba->HCregaddr); in lpfc_sli_sp_intr_handler()
13787 if ((work_ha_copy & HA_MBATT) && (phba->sli.mbox_active)) { in lpfc_sli_sp_intr_handler()
13788 pmb = phba->sli.mbox_active; in lpfc_sli_sp_intr_handler()
13789 pmbox = &pmb->u.mb; in lpfc_sli_sp_intr_handler()
13790 mbox = phba->mbox; in lpfc_sli_sp_intr_handler()
13791 vport = pmb->vport; in lpfc_sli_sp_intr_handler()
13795 if (pmbox->mbxOwner != OWN_HOST) { in lpfc_sli_sp_intr_handler()
13796 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_sp_intr_handler()
13798 * Stray Mailbox Interrupt, mbxCommand <cmd> in lpfc_sli_sp_intr_handler()
13802 "(%d):0304 Stray Mailbox " in lpfc_sli_sp_intr_handler()
13805 (vport ? vport->vpi : 0), in lpfc_sli_sp_intr_handler()
13806 pmbox->mbxCommand, in lpfc_sli_sp_intr_handler()
13807 pmbox->mbxStatus); in lpfc_sli_sp_intr_handler()
13808 /* clear mailbox attention bit */ in lpfc_sli_sp_intr_handler()
13811 phba->sli.mbox_active = NULL; in lpfc_sli_sp_intr_handler()
13812 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_sp_intr_handler()
13813 phba->last_completion_time = jiffies; in lpfc_sli_sp_intr_handler()
13814 del_timer(&phba->sli.mbox_tmo); in lpfc_sli_sp_intr_handler()
13815 if (pmb->mbox_cmpl) { in lpfc_sli_sp_intr_handler()
13818 if (pmb->out_ext_byte_len && in lpfc_sli_sp_intr_handler()
13819 pmb->ext_buf) in lpfc_sli_sp_intr_handler()
13821 phba->mbox_ext, in lpfc_sli_sp_intr_handler()
13822 pmb->ext_buf, in lpfc_sli_sp_intr_handler()
13823 pmb->out_ext_byte_len); in lpfc_sli_sp_intr_handler()
13825 if (pmb->mbox_flag & LPFC_MBX_IMED_UNREG) { in lpfc_sli_sp_intr_handler()
13826 pmb->mbox_flag &= ~LPFC_MBX_IMED_UNREG; in lpfc_sli_sp_intr_handler()
13832 (uint32_t)pmbox->mbxStatus, in lpfc_sli_sp_intr_handler()
13833 pmbox->un.varWords[0], 0); in lpfc_sli_sp_intr_handler()
13835 if (!pmbox->mbxStatus) { in lpfc_sli_sp_intr_handler()
13836 mp = pmb->ctx_buf; in lpfc_sli_sp_intr_handler()
13837 ndlp = pmb->ctx_ndlp; in lpfc_sli_sp_intr_handler()
13845 vport->vpi, in lpfc_sli_sp_intr_handler()
13846 pmbox->un.varWords[0], in lpfc_sli_sp_intr_handler()
13848 pmb->mbox_cmpl = in lpfc_sli_sp_intr_handler()
13850 pmb->ctx_buf = mp; in lpfc_sli_sp_intr_handler()
13851 pmb->ctx_ndlp = ndlp; in lpfc_sli_sp_intr_handler()
13852 pmb->vport = vport; in lpfc_sli_sp_intr_handler()
13867 &phba->pport->work_port_lock, in lpfc_sli_sp_intr_handler()
13869 phba->pport->work_port_events &= in lpfc_sli_sp_intr_handler()
13872 &phba->pport->work_port_lock, in lpfc_sli_sp_intr_handler()
13878 if (pmbox->mbxCommand == MBX_HEARTBEAT) { in lpfc_sli_sp_intr_handler()
13880 phba->sli.mbox_active = NULL; in lpfc_sli_sp_intr_handler()
13881 phba->sli.sli_flag &= in lpfc_sli_sp_intr_handler()
13883 if (pmb->mbox_cmpl) in lpfc_sli_sp_intr_handler()
13884 pmb->mbox_cmpl(phba, pmb); in lpfc_sli_sp_intr_handler()
13891 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_sp_intr_handler()
13894 (phba->sli.mbox_active == NULL)) { in lpfc_sli_sp_intr_handler()
13896 /* Process next mailbox command if there is one */ in lpfc_sli_sp_intr_handler()
13908 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_sp_intr_handler()
13909 phba->work_ha |= work_ha_copy; in lpfc_sli_sp_intr_handler()
13910 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_sp_intr_handler()
13915 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_sp_intr_handler()
13921 * lpfc_sli_fp_intr_handler - Fast-path interrupt handler to SLI-3 device.
13926 * service routine when device with SLI-3 interface spec is enabled with
13927 * MSI-X multi-message interrupt mode and there is a fast-path FCP IOCB
13929 * MSI or Pin-IRQ interrupt mode, this function is called as part of the
13930 * device-level interrupt handler. When the PCI slot is in error recovery
13932 * process the interrupt. The SCSI FCP fast-path ring event are handled in
13958 * individual interrupt handler in MSI-X multi-message interrupt mode in lpfc_sli_fp_intr_handler()
13960 if (phba->intr_type == MSIX) { in lpfc_sli_fp_intr_handler()
13965 if (lpfc_readl(phba->HAregaddr, &ha_copy)) in lpfc_sli_fp_intr_handler()
13972 if (unlikely(test_bit(DEFER_ERATT, &phba->hba_flag))) in lpfc_sli_fp_intr_handler()
13975 /* Clear up only attention source related to fast-path */ in lpfc_sli_fp_intr_handler()
13976 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_fp_intr_handler()
13978 phba->HAregaddr); in lpfc_sli_fp_intr_handler()
13979 readl(phba->HAregaddr); /* flush */ in lpfc_sli_fp_intr_handler()
13980 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_fp_intr_handler()
13982 ha_copy = phba->ha_copy; in lpfc_sli_fp_intr_handler()
13987 ha_copy &= ~(phba->work_ha_mask); in lpfc_sli_fp_intr_handler()
13991 pring = &phba->sli.sli3_ring[LPFC_FCP_RING]; in lpfc_sli_fp_intr_handler()
13995 if (phba->cfg_multi_ring_support == 2) { in lpfc_sli_fp_intr_handler()
14004 &phba->sli.sli3_ring[LPFC_EXTRA_RING], in lpfc_sli_fp_intr_handler()
14012 * lpfc_sli_intr_handler - Device-level interrupt handler to SLI-3 device
14016 * This function is the HBA device-level interrupt handler to device with
14017 * SLI-3 interface spec, called from the PCI layer when either MSI or
14018 * Pin-IRQ interrupt mode is enabled and there is an event in the HBA which
14019 * requires driver attention. This function invokes the slow-path interrupt
14020 * attention handling function and fast-path interrupt attention handling
14049 spin_lock(&phba->hbalock); in lpfc_sli_intr_handler()
14050 if (lpfc_readl(phba->HAregaddr, &phba->ha_copy)) { in lpfc_sli_intr_handler()
14051 spin_unlock(&phba->hbalock); in lpfc_sli_intr_handler()
14055 if (unlikely(!phba->ha_copy)) { in lpfc_sli_intr_handler()
14056 spin_unlock(&phba->hbalock); in lpfc_sli_intr_handler()
14058 } else if (phba->ha_copy & HA_ERATT) { in lpfc_sli_intr_handler()
14059 if (test_and_set_bit(HBA_ERATT_HANDLED, &phba->hba_flag)) in lpfc_sli_intr_handler()
14061 phba->ha_copy &= ~HA_ERATT; in lpfc_sli_intr_handler()
14067 if (unlikely(test_bit(DEFER_ERATT, &phba->hba_flag))) { in lpfc_sli_intr_handler()
14068 spin_unlock(&phba->hbalock); in lpfc_sli_intr_handler()
14073 if (lpfc_readl(phba->HCregaddr, &hc_copy)) { in lpfc_sli_intr_handler()
14074 spin_unlock(&phba->hbalock); in lpfc_sli_intr_handler()
14079 phba->HCregaddr); in lpfc_sli_intr_handler()
14080 writel((phba->ha_copy & ~(HA_LATT | HA_ERATT)), phba->HAregaddr); in lpfc_sli_intr_handler()
14081 writel(hc_copy, phba->HCregaddr); in lpfc_sli_intr_handler()
14082 readl(phba->HAregaddr); /* flush */ in lpfc_sli_intr_handler()
14083 spin_unlock(&phba->hbalock); in lpfc_sli_intr_handler()
14086 * Invokes slow-path host attention interrupt handling as appropriate. in lpfc_sli_intr_handler()
14089 /* status of events with mailbox and link attention */ in lpfc_sli_intr_handler()
14090 status1 = phba->ha_copy & (HA_MBATT | HA_LATT | HA_ERATT); in lpfc_sli_intr_handler()
14093 status2 = (phba->ha_copy & (HA_RXMASK << (4*LPFC_ELS_RING))); in lpfc_sli_intr_handler()
14102 * Invoke fast-path host attention interrupt handling as appropriate. in lpfc_sli_intr_handler()
14106 status1 = (phba->ha_copy & (HA_RXMASK << (4*LPFC_FCP_RING))); in lpfc_sli_intr_handler()
14110 if (phba->cfg_multi_ring_support == 2) { in lpfc_sli_intr_handler()
14111 status2 = (phba->ha_copy & (HA_RXMASK << (4*LPFC_EXTRA_RING))); in lpfc_sli_intr_handler()
14121 /* Return device-level interrupt handling status */ in lpfc_sli_intr_handler()
14126 * lpfc_sli4_els_xri_abort_event_proc - Process els xri abort event
14138 clear_bit(ELS_XRI_ABORT_EVENT, &phba->hba_flag); in lpfc_sli4_els_xri_abort_event_proc()
14141 spin_lock_irqsave(&phba->sli4_hba.els_xri_abrt_list_lock, iflags); in lpfc_sli4_els_xri_abort_event_proc()
14142 while (!list_empty(&phba->sli4_hba.sp_els_xri_aborted_work_queue)) { in lpfc_sli4_els_xri_abort_event_proc()
14144 list_remove_head(&phba->sli4_hba.sp_els_xri_aborted_work_queue, in lpfc_sli4_els_xri_abort_event_proc()
14146 spin_unlock_irqrestore(&phba->sli4_hba.els_xri_abrt_list_lock, in lpfc_sli4_els_xri_abort_event_proc()
14149 lpfc_sli4_els_xri_aborted(phba, &cq_event->cqe.wcqe_axri); in lpfc_sli4_els_xri_abort_event_proc()
14153 spin_lock_irqsave(&phba->sli4_hba.els_xri_abrt_list_lock, in lpfc_sli4_els_xri_abort_event_proc()
14156 spin_unlock_irqrestore(&phba->sli4_hba.els_xri_abrt_list_lock, iflags); in lpfc_sli4_els_xri_abort_event_proc()
14160 * lpfc_sli4_els_preprocess_rspiocbq - Get response iocbq from els wcqe
14162 * @irspiocbq: Pointer to work-queue completion queue entry.
14164 * This routine handles an ELS work-queue completion event and construct
14183 wcqe = &irspiocbq->cq_event.cqe.wcqe_cmpl; in lpfc_sli4_els_preprocess_rspiocbq()
14184 spin_lock_irqsave(&pring->ring_lock, iflags); in lpfc_sli4_els_preprocess_rspiocbq()
14185 pring->stats.iocb_event++; in lpfc_sli4_els_preprocess_rspiocbq()
14190 spin_unlock_irqrestore(&pring->ring_lock, iflags); in lpfc_sli4_els_preprocess_rspiocbq()
14194 wcqe->word0, wcqe->total_data_placed, in lpfc_sli4_els_preprocess_rspiocbq()
14195 wcqe->parameter, wcqe->word3); in lpfc_sli4_els_preprocess_rspiocbq()
14200 memcpy(&irspiocbq->wqe, &cmdiocbq->wqe, sizeof(union lpfc_wqe128)); in lpfc_sli4_els_preprocess_rspiocbq()
14201 memcpy(&irspiocbq->wcqe_cmpl, wcqe, sizeof(*wcqe)); in lpfc_sli4_els_preprocess_rspiocbq()
14205 spin_unlock_irqrestore(&pring->ring_lock, iflags); in lpfc_sli4_els_preprocess_rspiocbq()
14208 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_els_preprocess_rspiocbq()
14209 irspiocbq->cmd_flag |= LPFC_EXCHANGE_BUSY; in lpfc_sli4_els_preprocess_rspiocbq()
14210 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_els_preprocess_rspiocbq()
14230 memcpy(&cq_event->cqe, entry, size); in lpfc_cq_event_setup()
14235 * lpfc_sli4_sp_handle_async_event - Handle an asynchronous event
14237 * @mcqe: Pointer to mailbox completion queue entry.
14239 * This routine process a mailbox completion queue entry with asynchronous
14252 "word2:x%x, word3:x%x\n", mcqe->word0, in lpfc_sli4_sp_handle_async_event()
14253 mcqe->mcqe_tag0, mcqe->mcqe_tag1, mcqe->trailer); in lpfc_sli4_sp_handle_async_event()
14259 spin_lock_irqsave(&phba->sli4_hba.asynce_list_lock, iflags); in lpfc_sli4_sp_handle_async_event()
14260 list_add_tail(&cq_event->list, &phba->sli4_hba.sp_asynce_work_queue); in lpfc_sli4_sp_handle_async_event()
14261 spin_unlock_irqrestore(&phba->sli4_hba.asynce_list_lock, iflags); in lpfc_sli4_sp_handle_async_event()
14264 set_bit(ASYNC_EVENT, &phba->hba_flag); in lpfc_sli4_sp_handle_async_event()
14270 * lpfc_sli4_sp_handle_mbox_event - Handle a mailbox completion event
14272 * @mcqe: Pointer to mailbox completion queue entry.
14274 * This routine process a mailbox completion queue entry with mailbox
14293 /* If not a mailbox complete MCQE, out by checking mailbox consume */ in lpfc_sli4_sp_handle_mbox_event()
14298 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_mbox_event()
14299 pmb = phba->sli.mbox_active; in lpfc_sli4_sp_handle_mbox_event()
14303 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_mbox_event()
14306 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_mbox_event()
14307 mqe = &pmb->u.mqe; in lpfc_sli4_sp_handle_mbox_event()
14308 pmbox = (MAILBOX_t *)&pmb->u.mqe; in lpfc_sli4_sp_handle_mbox_event()
14309 mbox = phba->mbox; in lpfc_sli4_sp_handle_mbox_event()
14310 vport = pmb->vport; in lpfc_sli4_sp_handle_mbox_event()
14313 phba->last_completion_time = jiffies; in lpfc_sli4_sp_handle_mbox_event()
14314 del_timer(&phba->sli.mbox_tmo); in lpfc_sli4_sp_handle_mbox_event()
14316 /* Move mbox data to caller's mailbox region, do endian swapping */ in lpfc_sli4_sp_handle_mbox_event()
14317 if (pmb->mbox_cmpl && mbox) in lpfc_sli4_sp_handle_mbox_event()
14330 if (pmb->mbox_flag & LPFC_MBX_IMED_UNREG) { in lpfc_sli4_sp_handle_mbox_event()
14331 pmb->mbox_flag &= ~LPFC_MBX_IMED_UNREG; in lpfc_sli4_sp_handle_mbox_event()
14335 pmbox->un.varWords[0], 0); in lpfc_sli4_sp_handle_mbox_event()
14337 mp = pmb->ctx_buf; in lpfc_sli4_sp_handle_mbox_event()
14338 ndlp = pmb->ctx_ndlp; in lpfc_sli4_sp_handle_mbox_event()
14343 * starting another mailbox transaction. in lpfc_sli4_sp_handle_mbox_event()
14345 set_bit(NLP_UNREG_INP, &ndlp->nlp_flag); in lpfc_sli4_sp_handle_mbox_event()
14346 lpfc_unreg_login(phba, vport->vpi, in lpfc_sli4_sp_handle_mbox_event()
14347 pmbox->un.varWords[0], pmb); in lpfc_sli4_sp_handle_mbox_event()
14348 pmb->mbox_cmpl = lpfc_mbx_cmpl_dflt_rpi; in lpfc_sli4_sp_handle_mbox_event()
14349 pmb->ctx_buf = mp; in lpfc_sli4_sp_handle_mbox_event()
14354 * this mailbox completes. in lpfc_sli4_sp_handle_mbox_event()
14356 pmb->ctx_ndlp = ndlp; in lpfc_sli4_sp_handle_mbox_event()
14357 pmb->vport = vport; in lpfc_sli4_sp_handle_mbox_event()
14368 spin_lock_irqsave(&phba->pport->work_port_lock, iflags); in lpfc_sli4_sp_handle_mbox_event()
14369 phba->pport->work_port_events &= ~WORKER_MBOX_TMO; in lpfc_sli4_sp_handle_mbox_event()
14370 spin_unlock_irqrestore(&phba->pport->work_port_lock, iflags); in lpfc_sli4_sp_handle_mbox_event()
14373 if (pmbox->mbxCommand == MBX_HEARTBEAT) { in lpfc_sli4_sp_handle_mbox_event()
14374 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_mbox_event()
14375 /* Release the mailbox command posting token */ in lpfc_sli4_sp_handle_mbox_event()
14376 phba->sli.sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; in lpfc_sli4_sp_handle_mbox_event()
14377 phba->sli.mbox_active = NULL; in lpfc_sli4_sp_handle_mbox_event()
14379 lpfc_sli4_mq_release(phba->sli4_hba.mbx_wq); in lpfc_sli4_sp_handle_mbox_event()
14380 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_mbox_event()
14386 if (pmb->mbox_cmpl) in lpfc_sli4_sp_handle_mbox_event()
14387 pmb->mbox_cmpl(phba, pmb); in lpfc_sli4_sp_handle_mbox_event()
14391 /* There is mailbox completion work to queue to the worker thread */ in lpfc_sli4_sp_handle_mbox_event()
14392 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_mbox_event()
14394 phba->work_ha |= HA_MBATT; in lpfc_sli4_sp_handle_mbox_event()
14395 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_mbox_event()
14399 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_mbox_event()
14400 /* Release the mailbox command posting token */ in lpfc_sli4_sp_handle_mbox_event()
14401 phba->sli.sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; in lpfc_sli4_sp_handle_mbox_event()
14402 /* Setting active mailbox pointer need to be in sync to flag clear */ in lpfc_sli4_sp_handle_mbox_event()
14403 phba->sli.mbox_active = NULL; in lpfc_sli4_sp_handle_mbox_event()
14405 lpfc_sli4_mq_release(phba->sli4_hba.mbx_wq); in lpfc_sli4_sp_handle_mbox_event()
14406 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_mbox_event()
14407 /* Wake up worker thread to post the next pending mailbox command */ in lpfc_sli4_sp_handle_mbox_event()
14412 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_mbox_event()
14414 lpfc_sli4_mq_release(phba->sli4_hba.mbx_wq); in lpfc_sli4_sp_handle_mbox_event()
14415 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_mbox_event()
14420 * lpfc_sli4_sp_handle_mcqe - Process a mailbox completion queue entry
14423 * @cqe: Pointer to mailbox completion queue entry.
14425 * This routine process a mailbox completion queue entry, it invokes the
14426 * proper mailbox complete handling or asynchronous event handling routine
14438 cq->CQ_mbox++; in lpfc_sli4_sp_handle_mcqe()
14440 /* Copy the mailbox MCQE and convert endian order as needed */ in lpfc_sli4_sp_handle_mcqe()
14452 * lpfc_sli4_sp_handle_els_wcqe - Handle els work-queue completion event
14455 * @wcqe: Pointer to work-queue completion queue entry.
14457 * This routine handles an ELS work-queue completion event.
14467 struct lpfc_sli_ring *pring = cq->pring; in lpfc_sli4_sp_handle_els_wcqe()
14478 wcqe->word0, wcqe->total_data_placed, in lpfc_sli4_sp_handle_els_wcqe()
14479 wcqe->parameter, wcqe->word3); in lpfc_sli4_sp_handle_els_wcqe()
14485 if (!list_empty(&pring->txq)) in lpfc_sli4_sp_handle_els_wcqe()
14487 if (!list_empty(&pring->txcmplq)) in lpfc_sli4_sp_handle_els_wcqe()
14492 txq_cnt, phba->iocb_cnt, in lpfc_sli4_sp_handle_els_wcqe()
14497 /* Save off the slow-path queue event for work thread to process */ in lpfc_sli4_sp_handle_els_wcqe()
14498 memcpy(&irspiocbq->cq_event.cqe.wcqe_cmpl, wcqe, sizeof(*wcqe)); in lpfc_sli4_sp_handle_els_wcqe()
14499 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_els_wcqe()
14500 list_add_tail(&irspiocbq->cq_event.list, in lpfc_sli4_sp_handle_els_wcqe()
14501 &phba->sli4_hba.sp_queue_event); in lpfc_sli4_sp_handle_els_wcqe()
14502 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_els_wcqe()
14503 set_bit(HBA_SP_QUEUE_EVT, &phba->hba_flag); in lpfc_sli4_sp_handle_els_wcqe()
14509 * lpfc_sli4_sp_handle_rel_wcqe - Handle slow-path WQ entry consumed event
14511 * @wcqe: Pointer to work-queue completion queue entry.
14513 * This routine handles slow-path WQ entry consumed event by invoking the
14514 * proper WQ release routine to the slow-path WQ.
14521 if (unlikely(!phba->sli4_hba.els_wq)) in lpfc_sli4_sp_handle_rel_wcqe()
14523 /* Check for the slow-path ELS work queue */ in lpfc_sli4_sp_handle_rel_wcqe()
14524 if (bf_get(lpfc_wcqe_r_wq_id, wcqe) == phba->sli4_hba.els_wq->queue_id) in lpfc_sli4_sp_handle_rel_wcqe()
14525 lpfc_sli4_wq_release(phba->sli4_hba.els_wq, in lpfc_sli4_sp_handle_rel_wcqe()
14529 "2579 Slow-path wqe consume event carries " in lpfc_sli4_sp_handle_rel_wcqe()
14530 "miss-matched qid: wcqe-qid=x%x, sp-qid=x%x\n", in lpfc_sli4_sp_handle_rel_wcqe()
14532 phba->sli4_hba.els_wq->queue_id); in lpfc_sli4_sp_handle_rel_wcqe()
14536 * lpfc_sli4_sp_handle_abort_xri_wcqe - Handle a xri abort event
14539 * @wcqe: Pointer to work-queue completion queue entry.
14554 switch (cq->subtype) { in lpfc_sli4_sp_handle_abort_xri_wcqe()
14556 lpfc_sli4_io_xri_aborted(phba, wcqe, cq->hdwq); in lpfc_sli4_sp_handle_abort_xri_wcqe()
14557 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_sp_handle_abort_xri_wcqe()
14559 if (phba->nvmet_support) in lpfc_sli4_sp_handle_abort_xri_wcqe()
14571 cq_event->hdwq = cq->hdwq; in lpfc_sli4_sp_handle_abort_xri_wcqe()
14572 spin_lock_irqsave(&phba->sli4_hba.els_xri_abrt_list_lock, in lpfc_sli4_sp_handle_abort_xri_wcqe()
14574 list_add_tail(&cq_event->list, in lpfc_sli4_sp_handle_abort_xri_wcqe()
14575 &phba->sli4_hba.sp_els_xri_aborted_work_queue); in lpfc_sli4_sp_handle_abort_xri_wcqe()
14577 set_bit(ELS_XRI_ABORT_EVENT, &phba->hba_flag); in lpfc_sli4_sp_handle_abort_xri_wcqe()
14578 spin_unlock_irqrestore(&phba->sli4_hba.els_xri_abrt_list_lock, in lpfc_sli4_sp_handle_abort_xri_wcqe()
14586 cq->subtype, wcqe->word0, wcqe->parameter, in lpfc_sli4_sp_handle_abort_xri_wcqe()
14587 wcqe->word2, wcqe->word3); in lpfc_sli4_sp_handle_abort_xri_wcqe()
14597 * lpfc_sli4_sp_handle_rcqe - Process a receive-queue completion queue entry
14599 * @rcqe: Pointer to receive-queue completion queue entry.
14601 * This routine process a receive-queue completion queue entry.
14610 struct lpfc_queue *hrq = phba->sli4_hba.hdr_rq; in lpfc_sli4_sp_handle_rcqe()
14611 struct lpfc_queue *drq = phba->sli4_hba.dat_rq; in lpfc_sli4_sp_handle_rcqe()
14625 if (rq_id != hrq->queue_id) in lpfc_sli4_sp_handle_rcqe()
14635 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_rcqe()
14637 dma_buf = lpfc_sli_hbqbuf_get(&phba->hbqs[0].hbq_buffer_list); in lpfc_sli4_sp_handle_rcqe()
14639 hrq->RQ_no_buf_found++; in lpfc_sli4_sp_handle_rcqe()
14640 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_rcqe()
14643 hrq->RQ_rcv_buf++; in lpfc_sli4_sp_handle_rcqe()
14644 hrq->RQ_buf_posted--; in lpfc_sli4_sp_handle_rcqe()
14645 memcpy(&dma_buf->cq_event.cqe.rcqe_cmpl, rcqe, sizeof(*rcqe)); in lpfc_sli4_sp_handle_rcqe()
14647 fc_hdr = (struct fc_frame_header *)dma_buf->hbuf.virt; in lpfc_sli4_sp_handle_rcqe()
14649 if (fc_hdr->fh_r_ctl == FC_RCTL_MDS_DIAGS || in lpfc_sli4_sp_handle_rcqe()
14650 fc_hdr->fh_r_ctl == FC_RCTL_DD_UNSOL_DATA) { in lpfc_sli4_sp_handle_rcqe()
14651 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_rcqe()
14653 if (!test_bit(FC_UNLOADING, &phba->pport->load_flag)) in lpfc_sli4_sp_handle_rcqe()
14654 lpfc_sli4_handle_mds_loopback(phba->pport, in lpfc_sli4_sp_handle_rcqe()
14657 lpfc_in_buf_free(phba, &dma_buf->dbuf); in lpfc_sli4_sp_handle_rcqe()
14662 list_add_tail(&dma_buf->cq_event.list, in lpfc_sli4_sp_handle_rcqe()
14663 &phba->sli4_hba.sp_queue_event); in lpfc_sli4_sp_handle_rcqe()
14664 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_rcqe()
14666 set_bit(HBA_SP_QUEUE_EVT, &phba->hba_flag); in lpfc_sli4_sp_handle_rcqe()
14670 if (phba->nvmet_support) { in lpfc_sli4_sp_handle_rcqe()
14671 tgtp = phba->targetport->private; in lpfc_sli4_sp_handle_rcqe()
14675 status, hrq->RQ_buf_posted, in lpfc_sli4_sp_handle_rcqe()
14676 hrq->RQ_no_posted_buf, in lpfc_sli4_sp_handle_rcqe()
14677 atomic_read(&tgtp->rcv_fcp_cmd_in), in lpfc_sli4_sp_handle_rcqe()
14678 atomic_read(&tgtp->rcv_fcp_cmd_out), in lpfc_sli4_sp_handle_rcqe()
14679 atomic_read(&tgtp->xmt_fcp_release)); in lpfc_sli4_sp_handle_rcqe()
14684 hrq->RQ_no_posted_buf++; in lpfc_sli4_sp_handle_rcqe()
14686 set_bit(HBA_POST_RECEIVE_BUFFER, &phba->hba_flag); in lpfc_sli4_sp_handle_rcqe()
14693 status, rcqe->word0, rcqe->word1, in lpfc_sli4_sp_handle_rcqe()
14694 rcqe->word2, rcqe->word3); in lpfc_sli4_sp_handle_rcqe()
14701 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_rcqe()
14703 dma_buf = lpfc_sli_hbqbuf_get(&phba->hbqs[0].hbq_buffer_list); in lpfc_sli4_sp_handle_rcqe()
14705 hrq->RQ_no_buf_found++; in lpfc_sli4_sp_handle_rcqe()
14706 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_rcqe()
14709 hrq->RQ_rcv_buf++; in lpfc_sli4_sp_handle_rcqe()
14710 hrq->RQ_buf_posted--; in lpfc_sli4_sp_handle_rcqe()
14711 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_rcqe()
14712 lpfc_in_buf_free(phba, &dma_buf->dbuf); in lpfc_sli4_sp_handle_rcqe()
14716 "2565 Unexpected RQE Status x%x, w0-3 x%08x " in lpfc_sli4_sp_handle_rcqe()
14718 status, rcqe->word0, rcqe->word1, in lpfc_sli4_sp_handle_rcqe()
14719 rcqe->word2, rcqe->word3); in lpfc_sli4_sp_handle_rcqe()
14727 * lpfc_sli4_sp_handle_cqe - Process a slow path completion queue entry
14732 * This routine process a slow-path work-queue or receive queue completion queue
14751 phba->last_completion_time = jiffies; in lpfc_sli4_sp_handle_cqe()
14762 phba->last_completion_time = jiffies; in lpfc_sli4_sp_handle_cqe()
14769 phba->last_completion_time = jiffies; in lpfc_sli4_sp_handle_cqe()
14783 * lpfc_sli4_sp_handle_eqe - Process a slow-path event queue entry
14785 * @eqe: Pointer to fast-path event queue entry.
14786 * @speq: Pointer to slow-path event queue.
14788 * This routine process a event queue entry from the slow-path event queue.
14807 list_for_each_entry(childq, &speq->child_list, list) { in lpfc_sli4_sp_handle_eqe()
14808 if (childq->queue_id == cqid) { in lpfc_sli4_sp_handle_eqe()
14814 if (phba->sli.sli_flag & LPFC_SLI_ACTIVE) in lpfc_sli4_sp_handle_eqe()
14816 "0365 Slow-path CQ identifier " in lpfc_sli4_sp_handle_eqe()
14822 cq->assoc_qp = speq; in lpfc_sli4_sp_handle_eqe()
14825 ret = queue_work(phba->wq, &cq->spwork); in lpfc_sli4_sp_handle_eqe()
14827 ret = queue_work_on(cq->chann, phba->wq, &cq->spwork); in lpfc_sli4_sp_handle_eqe()
14833 cqid, cq->queue_id, raw_smp_processor_id()); in lpfc_sli4_sp_handle_eqe()
14837 * __lpfc_sli4_process_cq - Process elements of a CQ
14866 /* default - no reschedule */ in __lpfc_sli4_process_cq()
14869 if (cmpxchg(&cq->queue_claimed, 0, 1) != 0) in __lpfc_sli4_process_cq()
14873 cq->q_flag = 0; in __lpfc_sli4_process_cq()
14880 if (!(++count % cq->max_proc_limit)) in __lpfc_sli4_process_cq()
14883 if (!(count % cq->notify_interval)) { in __lpfc_sli4_process_cq()
14884 phba->sli4_hba.sli4_write_cq_db(phba, cq, consumed, in __lpfc_sli4_process_cq()
14887 cq->assoc_qp->q_flag |= HBA_EQ_DELAY_CHK; in __lpfc_sli4_process_cq()
14891 cq->q_flag |= HBA_NVMET_CQ_NOTIFY; in __lpfc_sli4_process_cq()
14895 if (count >= phba->cfg_cq_poll_threshold) { in __lpfc_sli4_process_cq()
14901 if (count > cq->CQ_max_cqe) in __lpfc_sli4_process_cq()
14902 cq->CQ_max_cqe = count; in __lpfc_sli4_process_cq()
14904 cq->assoc_qp->EQ_cqe_cnt += count; in __lpfc_sli4_process_cq()
14910 "qid=%d\n", cq->queue_id); in __lpfc_sli4_process_cq()
14912 xchg(&cq->queue_claimed, 0); in __lpfc_sli4_process_cq()
14915 phba->sli4_hba.sli4_write_cq_db(phba, cq, consumed, in __lpfc_sli4_process_cq()
14922 * __lpfc_sli4_sp_process_cq - Process a slow-path event queue entry
14931 * the second is the delay parameter. If non-zero, rather than rearming
14939 struct lpfc_hba *phba = cq->phba; in __lpfc_sli4_sp_process_cq()
14945 switch (cq->type) { in __lpfc_sli4_sp_process_cq()
14952 if (cq->subtype == LPFC_IO) in __lpfc_sli4_sp_process_cq()
14964 cq->type); in __lpfc_sli4_sp_process_cq()
14970 ret = queue_delayed_work(phba->wq, &cq->sched_spwork, in __lpfc_sli4_sp_process_cq()
14973 ret = queue_delayed_work_on(cq->chann, phba->wq, in __lpfc_sli4_sp_process_cq()
14974 &cq->sched_spwork, delay); in __lpfc_sli4_sp_process_cq()
14979 cq->queue_id, cq->chann); in __lpfc_sli4_sp_process_cq()
14988 * lpfc_sli4_sp_process_cq - slow-path work handler when started by
14992 * translates from the work handler and calls the slow-path handler.
15003 * lpfc_sli4_dly_sp_process_cq - slow-path work handler when started by timer
15006 * translates from the work handler and calls the slow-path handler.
15018 * lpfc_sli4_fp_handle_fcp_wcqe - Process fast-path work queue completion entry
15021 * @wcqe: Pointer to work-queue completion queue entry.
15023 * This routine process a fast-path work queue completion entry from fast-path
15030 struct lpfc_sli_ring *pring = cq->pring; in lpfc_sli4_fp_handle_fcp_wcqe()
15041 ((wcqe->parameter & IOERR_PARAM_MASK) == in lpfc_sli4_fp_handle_fcp_wcqe()
15043 phba->lpfc_rampdown_queue_depth(phba); in lpfc_sli4_fp_handle_fcp_wcqe()
15050 wcqe->word0, wcqe->total_data_placed, in lpfc_sli4_fp_handle_fcp_wcqe()
15051 wcqe->parameter, wcqe->word3); in lpfc_sli4_fp_handle_fcp_wcqe()
15055 spin_lock_irqsave(&pring->ring_lock, iflags); in lpfc_sli4_fp_handle_fcp_wcqe()
15056 pring->stats.iocb_event++; in lpfc_sli4_fp_handle_fcp_wcqe()
15059 spin_unlock_irqrestore(&pring->ring_lock, iflags); in lpfc_sli4_fp_handle_fcp_wcqe()
15068 cmdiocbq->isr_timestamp = cq->isr_timestamp; in lpfc_sli4_fp_handle_fcp_wcqe()
15071 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_fp_handle_fcp_wcqe()
15072 cmdiocbq->cmd_flag |= LPFC_EXCHANGE_BUSY; in lpfc_sli4_fp_handle_fcp_wcqe()
15073 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_fp_handle_fcp_wcqe()
15076 if (cmdiocbq->cmd_cmpl) { in lpfc_sli4_fp_handle_fcp_wcqe()
15078 if (!(cmdiocbq->cmd_flag & LPFC_IO_FCP) && in lpfc_sli4_fp_handle_fcp_wcqe()
15079 cmdiocbq->cmd_flag & LPFC_DRIVER_ABORTED) { in lpfc_sli4_fp_handle_fcp_wcqe()
15080 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_fp_handle_fcp_wcqe()
15081 cmdiocbq->cmd_flag &= ~LPFC_DRIVER_ABORTED; in lpfc_sli4_fp_handle_fcp_wcqe()
15082 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_fp_handle_fcp_wcqe()
15086 memcpy(&cmdiocbq->wcqe_cmpl, wcqe, in lpfc_sli4_fp_handle_fcp_wcqe()
15088 cmdiocbq->cmd_cmpl(phba, cmdiocbq, cmdiocbq); in lpfc_sli4_fp_handle_fcp_wcqe()
15098 * lpfc_sli4_fp_handle_rel_wcqe - Handle fast-path WQ entry consumed event
15101 * @wcqe: Pointer to work-queue completion queue entry.
15103 * This routine handles an fast-path WQ entry consumed event by invoking the
15104 * proper WQ release routine to the slow-path WQ.
15114 /* Check for fast-path FCP work queue release */ in lpfc_sli4_fp_handle_rel_wcqe()
15116 list_for_each_entry(childwq, &cq->child_list, list) { in lpfc_sli4_fp_handle_rel_wcqe()
15117 if (childwq->queue_id == hba_wqid) { in lpfc_sli4_fp_handle_rel_wcqe()
15120 if (childwq->q_flag & HBA_NVMET_WQFULL) in lpfc_sli4_fp_handle_rel_wcqe()
15129 "2580 Fast-path wqe consume event carries " in lpfc_sli4_fp_handle_rel_wcqe()
15130 "miss-matched qid: wcqe-qid=x%x\n", hba_wqid); in lpfc_sli4_fp_handle_rel_wcqe()
15134 * lpfc_sli4_nvmet_handle_rcqe - Process a receive-queue completion queue entry
15137 * @rcqe: Pointer to receive-queue completion queue entry.
15139 * This routine process a receive-queue completion queue entry.
15157 if ((phba->nvmet_support == 0) || in lpfc_sli4_nvmet_handle_rcqe()
15158 (phba->sli4_hba.nvmet_cqset == NULL)) in lpfc_sli4_nvmet_handle_rcqe()
15161 idx = cq->queue_id - phba->sli4_hba.nvmet_cqset[0]->queue_id; in lpfc_sli4_nvmet_handle_rcqe()
15162 hrq = phba->sli4_hba.nvmet_mrq_hdr[idx]; in lpfc_sli4_nvmet_handle_rcqe()
15163 drq = phba->sli4_hba.nvmet_mrq_data[idx]; in lpfc_sli4_nvmet_handle_rcqe()
15174 if ((phba->nvmet_support == 0) || in lpfc_sli4_nvmet_handle_rcqe()
15175 (rq_id != hrq->queue_id)) in lpfc_sli4_nvmet_handle_rcqe()
15185 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_nvmet_handle_rcqe()
15189 hrq->RQ_no_buf_found++; in lpfc_sli4_nvmet_handle_rcqe()
15190 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_nvmet_handle_rcqe()
15193 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_nvmet_handle_rcqe()
15194 hrq->RQ_rcv_buf++; in lpfc_sli4_nvmet_handle_rcqe()
15195 hrq->RQ_buf_posted--; in lpfc_sli4_nvmet_handle_rcqe()
15196 fc_hdr = (struct fc_frame_header *)dma_buf->hbuf.virt; in lpfc_sli4_nvmet_handle_rcqe()
15199 fctl = (fc_hdr->fh_f_ctl[0] << 16 | in lpfc_sli4_nvmet_handle_rcqe()
15200 fc_hdr->fh_f_ctl[1] << 8 | in lpfc_sli4_nvmet_handle_rcqe()
15201 fc_hdr->fh_f_ctl[2]); in lpfc_sli4_nvmet_handle_rcqe()
15205 (fc_hdr->fh_seq_cnt != 0)) /* 0 byte swapped is still 0 */ in lpfc_sli4_nvmet_handle_rcqe()
15208 if (fc_hdr->fh_type == FC_TYPE_FCP) { in lpfc_sli4_nvmet_handle_rcqe()
15209 dma_buf->bytes_recv = bf_get(lpfc_rcqe_length, rcqe); in lpfc_sli4_nvmet_handle_rcqe()
15211 phba, idx, dma_buf, cq->isr_timestamp, in lpfc_sli4_nvmet_handle_rcqe()
15212 cq->q_flag & HBA_NVMET_CQ_NOTIFY); in lpfc_sli4_nvmet_handle_rcqe()
15216 lpfc_rq_buf_free(phba, &dma_buf->hbuf); in lpfc_sli4_nvmet_handle_rcqe()
15219 if (phba->nvmet_support) { in lpfc_sli4_nvmet_handle_rcqe()
15220 tgtp = phba->targetport->private; in lpfc_sli4_nvmet_handle_rcqe()
15224 status, hrq->RQ_buf_posted, in lpfc_sli4_nvmet_handle_rcqe()
15225 hrq->RQ_no_posted_buf, in lpfc_sli4_nvmet_handle_rcqe()
15226 atomic_read(&tgtp->rcv_fcp_cmd_in), in lpfc_sli4_nvmet_handle_rcqe()
15227 atomic_read(&tgtp->rcv_fcp_cmd_out), in lpfc_sli4_nvmet_handle_rcqe()
15228 atomic_read(&tgtp->xmt_fcp_release)); in lpfc_sli4_nvmet_handle_rcqe()
15233 hrq->RQ_no_posted_buf++; in lpfc_sli4_nvmet_handle_rcqe()
15240 status, rcqe->word0, rcqe->word1, in lpfc_sli4_nvmet_handle_rcqe()
15241 rcqe->word2, rcqe->word3); in lpfc_sli4_nvmet_handle_rcqe()
15248 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_nvmet_handle_rcqe()
15252 hrq->RQ_no_buf_found++; in lpfc_sli4_nvmet_handle_rcqe()
15253 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_nvmet_handle_rcqe()
15256 hrq->RQ_rcv_buf++; in lpfc_sli4_nvmet_handle_rcqe()
15257 hrq->RQ_buf_posted--; in lpfc_sli4_nvmet_handle_rcqe()
15258 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_nvmet_handle_rcqe()
15259 lpfc_rq_buf_free(phba, &dma_buf->hbuf); in lpfc_sli4_nvmet_handle_rcqe()
15263 "2576 Unexpected RQE Status x%x, w0-3 x%08x " in lpfc_sli4_nvmet_handle_rcqe()
15265 status, rcqe->word0, rcqe->word1, in lpfc_sli4_nvmet_handle_rcqe()
15266 rcqe->word2, rcqe->word3); in lpfc_sli4_nvmet_handle_rcqe()
15274 * lpfc_sli4_fp_handle_cqe - Process fast-path work queue completion entry
15277 * @cqe: Pointer to fast-path completion queue entry.
15279 * This routine process a fast-path work queue completion entry from fast-path
15298 cq->CQ_wq++; in lpfc_sli4_fp_handle_cqe()
15300 phba->last_completion_time = jiffies; in lpfc_sli4_fp_handle_cqe()
15301 if (cq->subtype == LPFC_IO || cq->subtype == LPFC_NVME_LS) in lpfc_sli4_fp_handle_cqe()
15306 cq->CQ_release_wqe++; in lpfc_sli4_fp_handle_cqe()
15312 cq->CQ_xri_aborted++; in lpfc_sli4_fp_handle_cqe()
15314 phba->last_completion_time = jiffies; in lpfc_sli4_fp_handle_cqe()
15320 phba->last_completion_time = jiffies; in lpfc_sli4_fp_handle_cqe()
15321 if (cq->subtype == LPFC_NVMET) { in lpfc_sli4_fp_handle_cqe()
15336 * __lpfc_sli4_hba_process_cq - Process a fast-path event queue entry
15345 * the second is the delay parameter. If non-zero, rather than rearming
15353 struct lpfc_hba *phba = cq->phba; in __lpfc_sli4_hba_process_cq()
15364 ret = queue_delayed_work(phba->wq, &cq->sched_irqwork, in __lpfc_sli4_hba_process_cq()
15367 ret = queue_delayed_work_on(cq->chann, phba->wq, in __lpfc_sli4_hba_process_cq()
15368 &cq->sched_irqwork, delay); in __lpfc_sli4_hba_process_cq()
15373 cq->queue_id, cq->chann); in __lpfc_sli4_hba_process_cq()
15382 * lpfc_sli4_hba_process_cq - fast-path work handler when started by
15386 * translates from the work handler and calls the fast-path handler.
15397 * lpfc_sli4_hba_handle_eqe - Process a fast-path event queue entry
15400 * @eqe: Pointer to fast-path event queue entry.
15403 * This routine process a event queue entry from the fast-path event queue.
15415 uint32_t qidx = eq->hdwq; in lpfc_sli4_hba_handle_eqe()
15432 if (cqid <= phba->sli4_hba.cq_max) { in lpfc_sli4_hba_handle_eqe()
15433 cq = phba->sli4_hba.cq_lookup[cqid]; in lpfc_sli4_hba_handle_eqe()
15439 if (phba->cfg_nvmet_mrq && phba->sli4_hba.nvmet_cqset) { in lpfc_sli4_hba_handle_eqe()
15440 id = phba->sli4_hba.nvmet_cqset[0]->queue_id; in lpfc_sli4_hba_handle_eqe()
15441 if ((cqid >= id) && (cqid < (id + phba->cfg_nvmet_mrq))) { in lpfc_sli4_hba_handle_eqe()
15443 cq = phba->sli4_hba.nvmet_cqset[cqid - id]; in lpfc_sli4_hba_handle_eqe()
15448 if (phba->sli4_hba.nvmels_cq && in lpfc_sli4_hba_handle_eqe()
15449 (cqid == phba->sli4_hba.nvmels_cq->queue_id)) { in lpfc_sli4_hba_handle_eqe()
15451 cq = phba->sli4_hba.nvmels_cq; in lpfc_sli4_hba_handle_eqe()
15457 phba->sli4_hba.hdwq[qidx].hba_eq); in lpfc_sli4_hba_handle_eqe()
15462 if (unlikely(cqid != cq->queue_id)) { in lpfc_sli4_hba_handle_eqe()
15464 "0368 Miss-matched fast-path completion " in lpfc_sli4_hba_handle_eqe()
15466 cqid, cq->queue_id); in lpfc_sli4_hba_handle_eqe()
15472 if (phba->ktime_on) in lpfc_sli4_hba_handle_eqe()
15473 cq->isr_timestamp = ktime_get_ns(); in lpfc_sli4_hba_handle_eqe()
15475 cq->isr_timestamp = 0; in lpfc_sli4_hba_handle_eqe()
15485 ret = queue_work(phba->wq, &cq->irqwork); in lpfc_sli4_hba_handle_eqe()
15487 ret = queue_work_on(cq->chann, phba->wq, &cq->irqwork); in lpfc_sli4_hba_handle_eqe()
15492 cqid, cq->queue_id, in lpfc_sli4_hba_handle_eqe()
15499 * lpfc_sli4_dly_hba_process_cq - fast-path work handler when started by timer
15502 * translates from the work handler and calls the fast-path handler.
15514 * lpfc_sli4_hba_intr_handler - HBA interrupt handler to SLI-4 device
15519 * service routine when device with SLI-4 interface spec is enabled with
15520 * MSI-X multi-message interrupt mode and there is a fast-path FCP IOCB
15522 * MSI or Pin-IRQ interrupt mode, this function is called as part of the
15523 * device-level interrupt handler. When the PCI slot is in error recovery
15525 * process the interrupt. The SCSI FCP fast-path ring event are handled in
15528 * the FCP EQ to FCP CQ are one-to-one map such that the FCP EQ index is
15553 phba = hba_eq_hdl->phba; in lpfc_sli4_hba_intr_handler()
15554 hba_eqidx = hba_eq_hdl->idx; in lpfc_sli4_hba_intr_handler()
15558 if (unlikely(!phba->sli4_hba.hdwq)) in lpfc_sli4_hba_intr_handler()
15562 fpeq = phba->sli4_hba.hba_eq_hdl[hba_eqidx].eq; in lpfc_sli4_hba_intr_handler()
15569 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli4_hba_intr_handler()
15570 if (phba->link_state < LPFC_LINK_DOWN) in lpfc_sli4_hba_intr_handler()
15573 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli4_hba_intr_handler()
15577 switch (fpeq->poll_mode) { in lpfc_sli4_hba_intr_handler()
15580 if (phba->cmf_active_mode == LPFC_CFG_OFF) in lpfc_sli4_hba_intr_handler()
15585 eqi = this_cpu_ptr(phba->sli4_hba.eq_info); in lpfc_sli4_hba_intr_handler()
15586 eqi->icnt++; in lpfc_sli4_hba_intr_handler()
15588 fpeq->last_cpu = raw_smp_processor_id(); in lpfc_sli4_hba_intr_handler()
15590 if (eqi->icnt > LPFC_EQD_ISR_TRIGGER && in lpfc_sli4_hba_intr_handler()
15591 fpeq->q_flag & HBA_EQ_DELAY_CHK && in lpfc_sli4_hba_intr_handler()
15592 phba->cfg_auto_imax && in lpfc_sli4_hba_intr_handler()
15593 fpeq->q_mode != LPFC_MAX_AUTO_EQ_DELAY && in lpfc_sli4_hba_intr_handler()
15594 phba->sli.sli_flag & LPFC_SLI_USE_EQDR) in lpfc_sli4_hba_intr_handler()
15603 fpeq->EQ_no_entry++; in lpfc_sli4_hba_intr_handler()
15604 if (phba->intr_type == MSIX) in lpfc_sli4_hba_intr_handler()
15605 /* MSI-X treated interrupt served as no EQ share INT */ in lpfc_sli4_hba_intr_handler()
15607 "0358 MSI-X interrupt with no EQE\n"); in lpfc_sli4_hba_intr_handler()
15609 /* Non MSI-X treated on interrupt as EQ share INT */ in lpfc_sli4_hba_intr_handler()
15618 * lpfc_sli4_intr_handler - Device-level interrupt handler for SLI-4 device
15622 * This function is the device-level interrupt handler to device with SLI-4
15623 * interface spec, called from the PCI layer when either MSI or Pin-IRQ
15625 * driver attention. This function invokes the slow-path interrupt attention
15626 * handling function and fast-path interrupt attention handling function in
15649 * Invoke fast-path host attention interrupt handling as appropriate. in lpfc_sli4_intr_handler()
15651 for (qidx = 0; qidx < phba->cfg_irq_chann; qidx++) { in lpfc_sli4_intr_handler()
15653 &phba->sli4_hba.hba_eq_hdl[qidx]); in lpfc_sli4_intr_handler()
15668 list_for_each_entry_rcu(eq, &phba->poll_list, _poll_list) in lpfc_sli4_poll_hbtimer()
15670 if (!list_empty(&phba->poll_list)) in lpfc_sli4_poll_hbtimer()
15671 mod_timer(&phba->cpuhp_poll_timer, in lpfc_sli4_poll_hbtimer()
15679 struct lpfc_hba *phba = eq->phba; in lpfc_sli4_add_to_poll_list()
15682 if (list_empty(&phba->poll_list)) in lpfc_sli4_add_to_poll_list()
15683 mod_timer(&phba->cpuhp_poll_timer, in lpfc_sli4_add_to_poll_list()
15686 list_add_rcu(&eq->_poll_list, &phba->poll_list); in lpfc_sli4_add_to_poll_list()
15692 struct lpfc_hba *phba = eq->phba; in lpfc_sli4_remove_from_poll_list()
15695 * by RE-ARMING the eq's ASAP in lpfc_sli4_remove_from_poll_list()
15697 list_del_rcu(&eq->_poll_list); in lpfc_sli4_remove_from_poll_list()
15700 if (list_empty(&phba->poll_list)) in lpfc_sli4_remove_from_poll_list()
15701 del_timer_sync(&phba->cpuhp_poll_timer); in lpfc_sli4_remove_from_poll_list()
15708 list_for_each_entry_safe(eq, next, &phba->poll_list, _poll_list) in lpfc_sli4_cleanup_poll_list()
15709 list_del(&eq->_poll_list); in lpfc_sli4_cleanup_poll_list()
15711 INIT_LIST_HEAD(&phba->poll_list); in lpfc_sli4_cleanup_poll_list()
15718 if (mode == eq->mode) in __lpfc_sli4_switch_eqmode()
15726 * scheduler for a high priority process. Yes, the inte- in __lpfc_sli4_switch_eqmode()
15731 WRITE_ONCE(eq->mode, mode); in __lpfc_sli4_switch_eqmode()
15740 * deal with it. This is just a draining phase for int- in __lpfc_sli4_switch_eqmode()
15758 struct lpfc_hba *phba = eq->phba; in lpfc_sli4_stop_polling()
15765 * receives a completion. But since eq's are in disa- in lpfc_sli4_stop_polling()
15769 phba->sli4_hba.sli4_write_eq_db(phba, eq, 0, LPFC_QUEUE_REARM); in lpfc_sli4_stop_polling()
15773 * lpfc_sli4_queue_free - free a queue structure and associated memory
15788 if (!list_empty(&queue->wq_list)) in lpfc_sli4_queue_free()
15789 list_del(&queue->wq_list); in lpfc_sli4_queue_free()
15791 while (!list_empty(&queue->page_list)) { in lpfc_sli4_queue_free()
15792 list_remove_head(&queue->page_list, dmabuf, struct lpfc_dmabuf, in lpfc_sli4_queue_free()
15794 dma_free_coherent(&queue->phba->pcidev->dev, queue->page_size, in lpfc_sli4_queue_free()
15795 dmabuf->virt, dmabuf->phys); in lpfc_sli4_queue_free()
15798 if (queue->rqbp) { in lpfc_sli4_queue_free()
15799 lpfc_free_rq_buffer(queue->phba, queue); in lpfc_sli4_queue_free()
15800 kfree(queue->rqbp); in lpfc_sli4_queue_free()
15803 if (!list_empty(&queue->cpu_list)) in lpfc_sli4_queue_free()
15804 list_del(&queue->cpu_list); in lpfc_sli4_queue_free()
15811 * lpfc_sli4_queue_alloc - Allocate and initialize a queue structure
15828 uint32_t hw_page_size = phba->sli4_hba.pc_sli4_params.if_page_sz; in lpfc_sli4_queue_alloc()
15831 if (!phba->sli4_hba.pc_sli4_params.supported) in lpfc_sli4_queue_alloc()
15837 if (pgcnt > phba->sli4_hba.pc_sli4_params.wqpcnt) in lpfc_sli4_queue_alloc()
15838 pgcnt = phba->sli4_hba.pc_sli4_params.wqpcnt; in lpfc_sli4_queue_alloc()
15845 INIT_LIST_HEAD(&queue->list); in lpfc_sli4_queue_alloc()
15846 INIT_LIST_HEAD(&queue->_poll_list); in lpfc_sli4_queue_alloc()
15847 INIT_LIST_HEAD(&queue->wq_list); in lpfc_sli4_queue_alloc()
15848 INIT_LIST_HEAD(&queue->wqfull_list); in lpfc_sli4_queue_alloc()
15849 INIT_LIST_HEAD(&queue->page_list); in lpfc_sli4_queue_alloc()
15850 INIT_LIST_HEAD(&queue->child_list); in lpfc_sli4_queue_alloc()
15851 INIT_LIST_HEAD(&queue->cpu_list); in lpfc_sli4_queue_alloc()
15856 queue->page_count = pgcnt; in lpfc_sli4_queue_alloc()
15857 queue->q_pgs = (void **)&queue[1]; in lpfc_sli4_queue_alloc()
15858 queue->entry_cnt_per_pg = hw_page_size / entry_size; in lpfc_sli4_queue_alloc()
15859 queue->entry_size = entry_size; in lpfc_sli4_queue_alloc()
15860 queue->entry_count = entry_count; in lpfc_sli4_queue_alloc()
15861 queue->page_size = hw_page_size; in lpfc_sli4_queue_alloc()
15862 queue->phba = phba; in lpfc_sli4_queue_alloc()
15864 for (x = 0; x < queue->page_count; x++) { in lpfc_sli4_queue_alloc()
15866 dev_to_node(&phba->pcidev->dev)); in lpfc_sli4_queue_alloc()
15869 dmabuf->virt = dma_alloc_coherent(&phba->pcidev->dev, in lpfc_sli4_queue_alloc()
15870 hw_page_size, &dmabuf->phys, in lpfc_sli4_queue_alloc()
15872 if (!dmabuf->virt) { in lpfc_sli4_queue_alloc()
15876 dmabuf->buffer_tag = x; in lpfc_sli4_queue_alloc()
15877 list_add_tail(&dmabuf->list, &queue->page_list); in lpfc_sli4_queue_alloc()
15879 queue->q_pgs[x] = dmabuf->virt; in lpfc_sli4_queue_alloc()
15881 INIT_WORK(&queue->irqwork, lpfc_sli4_hba_process_cq); in lpfc_sli4_queue_alloc()
15882 INIT_WORK(&queue->spwork, lpfc_sli4_sp_process_cq); in lpfc_sli4_queue_alloc()
15883 INIT_DELAYED_WORK(&queue->sched_irqwork, lpfc_sli4_dly_hba_process_cq); in lpfc_sli4_queue_alloc()
15884 INIT_DELAYED_WORK(&queue->sched_spwork, lpfc_sli4_dly_sp_process_cq); in lpfc_sli4_queue_alloc()
15895 * lpfc_dual_chute_pci_bar_map - Map pci base address register to host memory
15906 if (!phba->pcidev) in lpfc_dual_chute_pci_bar_map()
15911 return phba->pci_bar0_memmap_p; in lpfc_dual_chute_pci_bar_map()
15913 return phba->pci_bar2_memmap_p; in lpfc_dual_chute_pci_bar_map()
15915 return phba->pci_bar4_memmap_p; in lpfc_dual_chute_pci_bar_map()
15923 * lpfc_modify_hba_eq_delay - Modify Delay Multiplier on EQs
15931 * or by mailbox command. The mailbox command allows several EQs to be
15934 * The @phba struct is used to send a mailbox command to HBA. The @startq
15938 * mailbox commands to finish before returning.
15941 * enough memory this function will return -ENOMEM. If a mailbox command
15942 * fails this function will return -ENXIO. Note: on ENXIO, some EQs may
15958 if (startq >= phba->cfg_irq_chann) in lpfc_modify_hba_eq_delay()
15969 if (phba->sli.sli_flag & LPFC_SLI_USE_EQDR) { in lpfc_modify_hba_eq_delay()
15970 for (qidx = startq; qidx < phba->cfg_irq_chann; qidx++) { in lpfc_modify_hba_eq_delay()
15971 eq = phba->sli4_hba.hba_eq_hdl[qidx].eq; in lpfc_modify_hba_eq_delay()
15983 /* Otherwise, set values by mailbox cmd */ in lpfc_modify_hba_eq_delay()
15985 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_modify_hba_eq_delay()
15988 "6428 Failed allocating mailbox cmd buffer." in lpfc_modify_hba_eq_delay()
15992 length = (sizeof(struct lpfc_mbx_modify_eq_delay) - in lpfc_modify_hba_eq_delay()
15997 eq_delay = &mbox->u.mqe.un.eq_delay; in lpfc_modify_hba_eq_delay()
16002 dmult--; in lpfc_modify_hba_eq_delay()
16006 for (qidx = startq; qidx < phba->cfg_irq_chann; qidx++) { in lpfc_modify_hba_eq_delay()
16007 eq = phba->sli4_hba.hba_eq_hdl[qidx].eq; in lpfc_modify_hba_eq_delay()
16010 eq->q_mode = usdelay; in lpfc_modify_hba_eq_delay()
16011 eq_delay->u.request.eq[cnt].eq_id = eq->queue_id; in lpfc_modify_hba_eq_delay()
16012 eq_delay->u.request.eq[cnt].phase = 0; in lpfc_modify_hba_eq_delay()
16013 eq_delay->u.request.eq[cnt].delay_multi = dmult; in lpfc_modify_hba_eq_delay()
16018 eq_delay->u.request.num_eq = cnt; in lpfc_modify_hba_eq_delay()
16020 mbox->vport = phba->pport; in lpfc_modify_hba_eq_delay()
16021 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_modify_hba_eq_delay()
16022 mbox->ctx_ndlp = NULL; in lpfc_modify_hba_eq_delay()
16024 shdr = (union lpfc_sli4_cfg_shdr *) &eq_delay->header.cfg_shdr; in lpfc_modify_hba_eq_delay()
16025 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_modify_hba_eq_delay()
16026 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_modify_hba_eq_delay()
16029 "2512 MODIFY_EQ_DELAY mailbox failed with " in lpfc_modify_hba_eq_delay()
16033 mempool_free(mbox, phba->mbox_mem_pool); in lpfc_modify_hba_eq_delay()
16038 * lpfc_eq_create - Create an Event Queue on the HBA
16044 * described by @phba by sending an EQ_CREATE mailbox command to the HBA.
16046 * The @phba struct is used to send mailbox command to HBA. The @eq struct
16049 * function will send the EQ_CREATE mailbox command to the HBA to setup the
16050 * event queue. This function is asynchronous and will wait for the mailbox
16054 * memory this function will return -ENOMEM. If the queue create mailbox command
16055 * fails this function will return -ENXIO.
16067 uint32_t hw_page_size = phba->sli4_hba.pc_sli4_params.if_page_sz; in lpfc_eq_create()
16071 return -ENODEV; in lpfc_eq_create()
16072 if (!phba->sli4_hba.pc_sli4_params.supported) in lpfc_eq_create()
16075 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_eq_create()
16077 return -ENOMEM; in lpfc_eq_create()
16078 length = (sizeof(struct lpfc_mbx_eq_create) - in lpfc_eq_create()
16083 eq_create = &mbox->u.mqe.un.eq_create; in lpfc_eq_create()
16084 shdr = (union lpfc_sli4_cfg_shdr *) &eq_create->header.cfg_shdr; in lpfc_eq_create()
16085 bf_set(lpfc_mbx_eq_create_num_pages, &eq_create->u.request, in lpfc_eq_create()
16086 eq->page_count); in lpfc_eq_create()
16087 bf_set(lpfc_eq_context_size, &eq_create->u.request.context, in lpfc_eq_create()
16089 bf_set(lpfc_eq_context_valid, &eq_create->u.request.context, 1); in lpfc_eq_create()
16092 if (phba->sli4_hba.pc_sli4_params.eqav) { in lpfc_eq_create()
16093 bf_set(lpfc_mbox_hdr_version, &shdr->request, in lpfc_eq_create()
16095 bf_set(lpfc_eq_context_autovalid, &eq_create->u.request.context, in lpfc_eq_create()
16096 phba->sli4_hba.pc_sli4_params.eqav); in lpfc_eq_create()
16101 bf_set(lpfc_eq_context_delay_multi, &eq_create->u.request.context, in lpfc_eq_create()
16103 switch (eq->entry_count) { in lpfc_eq_create()
16107 eq->entry_count); in lpfc_eq_create()
16108 if (eq->entry_count < 256) { in lpfc_eq_create()
16109 status = -EINVAL; in lpfc_eq_create()
16114 bf_set(lpfc_eq_context_count, &eq_create->u.request.context, in lpfc_eq_create()
16118 bf_set(lpfc_eq_context_count, &eq_create->u.request.context, in lpfc_eq_create()
16122 bf_set(lpfc_eq_context_count, &eq_create->u.request.context, in lpfc_eq_create()
16126 bf_set(lpfc_eq_context_count, &eq_create->u.request.context, in lpfc_eq_create()
16130 bf_set(lpfc_eq_context_count, &eq_create->u.request.context, in lpfc_eq_create()
16134 list_for_each_entry(dmabuf, &eq->page_list, list) { in lpfc_eq_create()
16135 memset(dmabuf->virt, 0, hw_page_size); in lpfc_eq_create()
16136 eq_create->u.request.page[dmabuf->buffer_tag].addr_lo = in lpfc_eq_create()
16137 putPaddrLow(dmabuf->phys); in lpfc_eq_create()
16138 eq_create->u.request.page[dmabuf->buffer_tag].addr_hi = in lpfc_eq_create()
16139 putPaddrHigh(dmabuf->phys); in lpfc_eq_create()
16141 mbox->vport = phba->pport; in lpfc_eq_create()
16142 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_eq_create()
16143 mbox->ctx_buf = NULL; in lpfc_eq_create()
16144 mbox->ctx_ndlp = NULL; in lpfc_eq_create()
16146 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_eq_create()
16147 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_eq_create()
16150 "2500 EQ_CREATE mailbox failed with " in lpfc_eq_create()
16153 status = -ENXIO; in lpfc_eq_create()
16155 eq->type = LPFC_EQ; in lpfc_eq_create()
16156 eq->subtype = LPFC_NONE; in lpfc_eq_create()
16157 eq->queue_id = bf_get(lpfc_mbx_eq_create_q_id, &eq_create->u.response); in lpfc_eq_create()
16158 if (eq->queue_id == 0xFFFF) in lpfc_eq_create()
16159 status = -ENXIO; in lpfc_eq_create()
16160 eq->host_index = 0; in lpfc_eq_create()
16161 eq->notify_interval = LPFC_EQ_NOTIFY_INTRVL; in lpfc_eq_create()
16162 eq->max_proc_limit = LPFC_EQ_MAX_PROC_LIMIT; in lpfc_eq_create()
16164 mempool_free(mbox, phba->mbox_mem_pool); in lpfc_eq_create()
16169 * lpfc_sli4_hba_intr_handler_th - SLI4 HBA threaded interrupt handler
16177 * IRQ_HANDLED - interrupt is handled
16178 * IRQ_NONE - otherwise
16191 phba = hba_eq_hdl->phba; in lpfc_sli4_hba_intr_handler_th()
16192 hba_eqidx = hba_eq_hdl->idx; in lpfc_sli4_hba_intr_handler_th()
16196 if (unlikely(!phba->sli4_hba.hdwq)) in lpfc_sli4_hba_intr_handler_th()
16200 fpeq = phba->sli4_hba.hba_eq_hdl[hba_eqidx].eq; in lpfc_sli4_hba_intr_handler_th()
16204 eqi = per_cpu_ptr(phba->sli4_hba.eq_info, raw_smp_processor_id()); in lpfc_sli4_hba_intr_handler_th()
16205 eqi->icnt++; in lpfc_sli4_hba_intr_handler_th()
16207 fpeq->last_cpu = raw_smp_processor_id(); in lpfc_sli4_hba_intr_handler_th()
16209 if (eqi->icnt > LPFC_EQD_ISR_TRIGGER && in lpfc_sli4_hba_intr_handler_th()
16210 fpeq->q_flag & HBA_EQ_DELAY_CHK && in lpfc_sli4_hba_intr_handler_th()
16211 phba->cfg_auto_imax && in lpfc_sli4_hba_intr_handler_th()
16212 fpeq->q_mode != LPFC_MAX_AUTO_EQ_DELAY && in lpfc_sli4_hba_intr_handler_th()
16213 phba->sli.sli_flag & LPFC_SLI_USE_EQDR) in lpfc_sli4_hba_intr_handler_th()
16221 fpeq->EQ_no_entry++; in lpfc_sli4_hba_intr_handler_th()
16222 if (phba->intr_type == MSIX) in lpfc_sli4_hba_intr_handler_th()
16223 /* MSI-X treated interrupt served as no EQ share INT */ in lpfc_sli4_hba_intr_handler_th()
16225 "3358 MSI-X interrupt with no EQE\n"); in lpfc_sli4_hba_intr_handler_th()
16227 /* Non MSI-X treated on interrupt as EQ share INT */ in lpfc_sli4_hba_intr_handler_th()
16234 * lpfc_cq_create - Create a Completion Queue on the HBA
16242 * described by @phba by sending a CQ_CREATE mailbox command to the HBA.
16244 * The @phba struct is used to send mailbox command to HBA. The @cq struct
16248 * function will send the CQ_CREATE mailbox command to the HBA to setup the
16249 * completion queue. This function is asynchronous and will wait for the mailbox
16253 * memory this function will return -ENOMEM. If the queue create mailbox command
16254 * fails this function will return -ENXIO.
16269 return -ENODEV; in lpfc_cq_create()
16271 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_cq_create()
16273 return -ENOMEM; in lpfc_cq_create()
16274 length = (sizeof(struct lpfc_mbx_cq_create) - in lpfc_cq_create()
16279 cq_create = &mbox->u.mqe.un.cq_create; in lpfc_cq_create()
16280 shdr = (union lpfc_sli4_cfg_shdr *) &cq_create->header.cfg_shdr; in lpfc_cq_create()
16281 bf_set(lpfc_mbx_cq_create_num_pages, &cq_create->u.request, in lpfc_cq_create()
16282 cq->page_count); in lpfc_cq_create()
16283 bf_set(lpfc_cq_context_event, &cq_create->u.request.context, 1); in lpfc_cq_create()
16284 bf_set(lpfc_cq_context_valid, &cq_create->u.request.context, 1); in lpfc_cq_create()
16285 bf_set(lpfc_mbox_hdr_version, &shdr->request, in lpfc_cq_create()
16286 phba->sli4_hba.pc_sli4_params.cqv); in lpfc_cq_create()
16287 if (phba->sli4_hba.pc_sli4_params.cqv == LPFC_Q_CREATE_VERSION_2) { in lpfc_cq_create()
16288 bf_set(lpfc_mbx_cq_create_page_size, &cq_create->u.request, in lpfc_cq_create()
16289 (cq->page_size / SLI4_PAGE_SIZE)); in lpfc_cq_create()
16290 bf_set(lpfc_cq_eq_id_2, &cq_create->u.request.context, in lpfc_cq_create()
16291 eq->queue_id); in lpfc_cq_create()
16292 bf_set(lpfc_cq_context_autovalid, &cq_create->u.request.context, in lpfc_cq_create()
16293 phba->sli4_hba.pc_sli4_params.cqav); in lpfc_cq_create()
16295 bf_set(lpfc_cq_eq_id, &cq_create->u.request.context, in lpfc_cq_create()
16296 eq->queue_id); in lpfc_cq_create()
16298 switch (cq->entry_count) { in lpfc_cq_create()
16301 if (phba->sli4_hba.pc_sli4_params.cqv == in lpfc_cq_create()
16303 cq_create->u.request.context.lpfc_cq_context_count = in lpfc_cq_create()
16304 cq->entry_count; in lpfc_cq_create()
16306 &cq_create->u.request.context, in lpfc_cq_create()
16315 cq->entry_count, cq->entry_size, in lpfc_cq_create()
16316 cq->page_count); in lpfc_cq_create()
16317 if (cq->entry_count < 256) { in lpfc_cq_create()
16318 status = -EINVAL; in lpfc_cq_create()
16323 bf_set(lpfc_cq_context_count, &cq_create->u.request.context, in lpfc_cq_create()
16327 bf_set(lpfc_cq_context_count, &cq_create->u.request.context, in lpfc_cq_create()
16331 bf_set(lpfc_cq_context_count, &cq_create->u.request.context, in lpfc_cq_create()
16335 list_for_each_entry(dmabuf, &cq->page_list, list) { in lpfc_cq_create()
16336 memset(dmabuf->virt, 0, cq->page_size); in lpfc_cq_create()
16337 cq_create->u.request.page[dmabuf->buffer_tag].addr_lo = in lpfc_cq_create()
16338 putPaddrLow(dmabuf->phys); in lpfc_cq_create()
16339 cq_create->u.request.page[dmabuf->buffer_tag].addr_hi = in lpfc_cq_create()
16340 putPaddrHigh(dmabuf->phys); in lpfc_cq_create()
16344 /* The IOCTL status is embedded in the mailbox subheader. */ in lpfc_cq_create()
16345 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_cq_create()
16346 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_cq_create()
16349 "2501 CQ_CREATE mailbox failed with " in lpfc_cq_create()
16352 status = -ENXIO; in lpfc_cq_create()
16355 cq->queue_id = bf_get(lpfc_mbx_cq_create_q_id, &cq_create->u.response); in lpfc_cq_create()
16356 if (cq->queue_id == 0xFFFF) { in lpfc_cq_create()
16357 status = -ENXIO; in lpfc_cq_create()
16361 list_add_tail(&cq->list, &eq->child_list); in lpfc_cq_create()
16363 cq->type = type; in lpfc_cq_create()
16364 cq->subtype = subtype; in lpfc_cq_create()
16365 cq->queue_id = bf_get(lpfc_mbx_cq_create_q_id, &cq_create->u.response); in lpfc_cq_create()
16366 cq->assoc_qid = eq->queue_id; in lpfc_cq_create()
16367 cq->assoc_qp = eq; in lpfc_cq_create()
16368 cq->host_index = 0; in lpfc_cq_create()
16369 cq->notify_interval = LPFC_CQ_NOTIFY_INTRVL; in lpfc_cq_create()
16370 cq->max_proc_limit = min(phba->cfg_cq_max_proc_limit, cq->entry_count); in lpfc_cq_create()
16372 if (cq->queue_id > phba->sli4_hba.cq_max) in lpfc_cq_create()
16373 phba->sli4_hba.cq_max = cq->queue_id; in lpfc_cq_create()
16375 mempool_free(mbox, phba->mbox_mem_pool); in lpfc_cq_create()
16380 * lpfc_cq_create_set - Create a set of Completion Queues on the HBA for MRQ
16389 * described by @phba by sending a CREATE_CQ_SET mailbox command to the HBA.
16391 * The @phba struct is used to send mailbox command to HBA. The @cq struct
16395 * function will send the CREATE_CQ_SET mailbox command to the HBA to setup the
16396 * completion queue. This function is asynchronous and will wait for the mailbox
16400 * memory this function will return -ENOMEM. If the queue create mailbox command
16401 * fails this function will return -ENXIO.
16417 uint32_t hw_page_size = phba->sli4_hba.pc_sli4_params.if_page_sz; in lpfc_cq_create_set()
16420 numcq = phba->cfg_nvmet_mrq; in lpfc_cq_create_set()
16422 return -ENODEV; in lpfc_cq_create_set()
16424 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_cq_create_set()
16426 return -ENOMEM; in lpfc_cq_create_set()
16429 length += ((numcq * cqp[0]->page_count) * in lpfc_cq_create_set()
16439 status = -ENOMEM; in lpfc_cq_create_set()
16442 cq_set = mbox->sge_array->addr[0]; in lpfc_cq_create_set()
16443 shdr = (union lpfc_sli4_cfg_shdr *)&cq_set->cfg_shdr; in lpfc_cq_create_set()
16444 bf_set(lpfc_mbox_hdr_version, &shdr->request, 0); in lpfc_cq_create_set()
16450 status = -ENOMEM; in lpfc_cq_create_set()
16453 if (!phba->sli4_hba.pc_sli4_params.supported) in lpfc_cq_create_set()
16454 hw_page_size = cq->page_size; in lpfc_cq_create_set()
16459 &cq_set->u.request, in lpfc_cq_create_set()
16462 &cq_set->u.request, cq->page_count); in lpfc_cq_create_set()
16464 &cq_set->u.request, 1); in lpfc_cq_create_set()
16466 &cq_set->u.request, 1); in lpfc_cq_create_set()
16468 &cq_set->u.request, 0); in lpfc_cq_create_set()
16470 &cq_set->u.request, numcq); in lpfc_cq_create_set()
16472 &cq_set->u.request, in lpfc_cq_create_set()
16473 phba->sli4_hba.pc_sli4_params.cqav); in lpfc_cq_create_set()
16474 switch (cq->entry_count) { in lpfc_cq_create_set()
16477 if (phba->sli4_hba.pc_sli4_params.cqv == in lpfc_cq_create_set()
16480 &cq_set->u.request, in lpfc_cq_create_set()
16481 cq->entry_count); in lpfc_cq_create_set()
16483 &cq_set->u.request, in lpfc_cq_create_set()
16491 cq->entry_count); in lpfc_cq_create_set()
16492 if (cq->entry_count < 256) { in lpfc_cq_create_set()
16493 status = -EINVAL; in lpfc_cq_create_set()
16499 &cq_set->u.request, LPFC_CQ_CNT_256); in lpfc_cq_create_set()
16503 &cq_set->u.request, LPFC_CQ_CNT_512); in lpfc_cq_create_set()
16507 &cq_set->u.request, LPFC_CQ_CNT_1024); in lpfc_cq_create_set()
16511 &cq_set->u.request, eq->queue_id); in lpfc_cq_create_set()
16515 &cq_set->u.request, eq->queue_id); in lpfc_cq_create_set()
16519 &cq_set->u.request, eq->queue_id); in lpfc_cq_create_set()
16523 &cq_set->u.request, eq->queue_id); in lpfc_cq_create_set()
16527 &cq_set->u.request, eq->queue_id); in lpfc_cq_create_set()
16531 &cq_set->u.request, eq->queue_id); in lpfc_cq_create_set()
16535 &cq_set->u.request, eq->queue_id); in lpfc_cq_create_set()
16539 &cq_set->u.request, eq->queue_id); in lpfc_cq_create_set()
16543 &cq_set->u.request, eq->queue_id); in lpfc_cq_create_set()
16547 &cq_set->u.request, eq->queue_id); in lpfc_cq_create_set()
16551 &cq_set->u.request, eq->queue_id); in lpfc_cq_create_set()
16555 &cq_set->u.request, eq->queue_id); in lpfc_cq_create_set()
16559 &cq_set->u.request, eq->queue_id); in lpfc_cq_create_set()
16563 &cq_set->u.request, eq->queue_id); in lpfc_cq_create_set()
16567 &cq_set->u.request, eq->queue_id); in lpfc_cq_create_set()
16571 &cq_set->u.request, eq->queue_id); in lpfc_cq_create_set()
16576 list_add_tail(&cq->list, &eq->child_list); in lpfc_cq_create_set()
16578 cq->type = type; in lpfc_cq_create_set()
16579 cq->subtype = subtype; in lpfc_cq_create_set()
16580 cq->assoc_qid = eq->queue_id; in lpfc_cq_create_set()
16581 cq->assoc_qp = eq; in lpfc_cq_create_set()
16582 cq->host_index = 0; in lpfc_cq_create_set()
16583 cq->notify_interval = LPFC_CQ_NOTIFY_INTRVL; in lpfc_cq_create_set()
16584 cq->max_proc_limit = min(phba->cfg_cq_max_proc_limit, in lpfc_cq_create_set()
16585 cq->entry_count); in lpfc_cq_create_set()
16586 cq->chann = idx; in lpfc_cq_create_set()
16589 list_for_each_entry(dmabuf, &cq->page_list, list) { in lpfc_cq_create_set()
16590 memset(dmabuf->virt, 0, hw_page_size); in lpfc_cq_create_set()
16591 cnt = page_idx + dmabuf->buffer_tag; in lpfc_cq_create_set()
16592 cq_set->u.request.page[cnt].addr_lo = in lpfc_cq_create_set()
16593 putPaddrLow(dmabuf->phys); in lpfc_cq_create_set()
16594 cq_set->u.request.page[cnt].addr_hi = in lpfc_cq_create_set()
16595 putPaddrHigh(dmabuf->phys); in lpfc_cq_create_set()
16603 /* The IOCTL status is embedded in the mailbox subheader. */ in lpfc_cq_create_set()
16604 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_cq_create_set()
16605 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_cq_create_set()
16608 "3119 CQ_CREATE_SET mailbox failed with " in lpfc_cq_create_set()
16611 status = -ENXIO; in lpfc_cq_create_set()
16614 rc = bf_get(lpfc_mbx_cq_create_set_base_id, &cq_set->u.response); in lpfc_cq_create_set()
16616 status = -ENXIO; in lpfc_cq_create_set()
16622 cq->queue_id = rc + idx; in lpfc_cq_create_set()
16623 if (cq->queue_id > phba->sli4_hba.cq_max) in lpfc_cq_create_set()
16624 phba->sli4_hba.cq_max = cq->queue_id; in lpfc_cq_create_set()
16633 * lpfc_mq_create_fb_init - Send MCC_CREATE without async events registration
16635 * @mq: The queue structure to use to create the mailbox queue.
16654 length = (sizeof(struct lpfc_mbx_mq_create) - in lpfc_mq_create_fb_init()
16659 mq_create = &mbox->u.mqe.un.mq_create; in lpfc_mq_create_fb_init()
16660 bf_set(lpfc_mbx_mq_create_num_pages, &mq_create->u.request, in lpfc_mq_create_fb_init()
16661 mq->page_count); in lpfc_mq_create_fb_init()
16662 bf_set(lpfc_mq_context_cq_id, &mq_create->u.request.context, in lpfc_mq_create_fb_init()
16663 cq->queue_id); in lpfc_mq_create_fb_init()
16664 bf_set(lpfc_mq_context_valid, &mq_create->u.request.context, 1); in lpfc_mq_create_fb_init()
16665 switch (mq->entry_count) { in lpfc_mq_create_fb_init()
16667 bf_set(lpfc_mq_context_ring_size, &mq_create->u.request.context, in lpfc_mq_create_fb_init()
16671 bf_set(lpfc_mq_context_ring_size, &mq_create->u.request.context, in lpfc_mq_create_fb_init()
16675 bf_set(lpfc_mq_context_ring_size, &mq_create->u.request.context, in lpfc_mq_create_fb_init()
16679 bf_set(lpfc_mq_context_ring_size, &mq_create->u.request.context, in lpfc_mq_create_fb_init()
16683 list_for_each_entry(dmabuf, &mq->page_list, list) { in lpfc_mq_create_fb_init()
16684 mq_create->u.request.page[dmabuf->buffer_tag].addr_lo = in lpfc_mq_create_fb_init()
16685 putPaddrLow(dmabuf->phys); in lpfc_mq_create_fb_init()
16686 mq_create->u.request.page[dmabuf->buffer_tag].addr_hi = in lpfc_mq_create_fb_init()
16687 putPaddrHigh(dmabuf->phys); in lpfc_mq_create_fb_init()
16692 * lpfc_mq_create - Create a mailbox Queue on the HBA
16694 * @mq: The queue structure to use to create the mailbox queue.
16698 * This function creates a mailbox queue, as detailed in @mq, on a port,
16699 * described by @phba by sending a MQ_CREATE mailbox command to the HBA.
16701 * The @phba struct is used to send mailbox command to HBA. The @cq struct
16704 * function will send the MQ_CREATE mailbox command to the HBA to setup the
16705 * mailbox queue. This function is asynchronous and will wait for the mailbox
16709 * memory this function will return -ENOMEM. If the queue create mailbox command
16710 * fails this function will return -ENXIO.
16723 uint32_t hw_page_size = phba->sli4_hba.pc_sli4_params.if_page_sz; in lpfc_mq_create()
16727 return -ENODEV; in lpfc_mq_create()
16728 if (!phba->sli4_hba.pc_sli4_params.supported) in lpfc_mq_create()
16731 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_mq_create()
16733 return -ENOMEM; in lpfc_mq_create()
16734 length = (sizeof(struct lpfc_mbx_mq_create_ext) - in lpfc_mq_create()
16740 mq_create_ext = &mbox->u.mqe.un.mq_create_ext; in lpfc_mq_create()
16741 shdr = (union lpfc_sli4_cfg_shdr *) &mq_create_ext->header.cfg_shdr; in lpfc_mq_create()
16743 &mq_create_ext->u.request, mq->page_count); in lpfc_mq_create()
16745 &mq_create_ext->u.request, 1); in lpfc_mq_create()
16747 &mq_create_ext->u.request, 1); in lpfc_mq_create()
16749 &mq_create_ext->u.request, 1); in lpfc_mq_create()
16751 &mq_create_ext->u.request, 1); in lpfc_mq_create()
16753 &mq_create_ext->u.request, 1); in lpfc_mq_create()
16754 bf_set(lpfc_mq_context_valid, &mq_create_ext->u.request.context, 1); in lpfc_mq_create()
16755 bf_set(lpfc_mbox_hdr_version, &shdr->request, in lpfc_mq_create()
16756 phba->sli4_hba.pc_sli4_params.mqv); in lpfc_mq_create()
16757 if (phba->sli4_hba.pc_sli4_params.mqv == LPFC_Q_CREATE_VERSION_1) in lpfc_mq_create()
16758 bf_set(lpfc_mbx_mq_create_ext_cq_id, &mq_create_ext->u.request, in lpfc_mq_create()
16759 cq->queue_id); in lpfc_mq_create()
16761 bf_set(lpfc_mq_context_cq_id, &mq_create_ext->u.request.context, in lpfc_mq_create()
16762 cq->queue_id); in lpfc_mq_create()
16763 switch (mq->entry_count) { in lpfc_mq_create()
16767 mq->entry_count); in lpfc_mq_create()
16768 if (mq->entry_count < 16) { in lpfc_mq_create()
16769 status = -EINVAL; in lpfc_mq_create()
16775 &mq_create_ext->u.request.context, in lpfc_mq_create()
16780 &mq_create_ext->u.request.context, in lpfc_mq_create()
16785 &mq_create_ext->u.request.context, in lpfc_mq_create()
16790 &mq_create_ext->u.request.context, in lpfc_mq_create()
16794 list_for_each_entry(dmabuf, &mq->page_list, list) { in lpfc_mq_create()
16795 memset(dmabuf->virt, 0, hw_page_size); in lpfc_mq_create()
16796 mq_create_ext->u.request.page[dmabuf->buffer_tag].addr_lo = in lpfc_mq_create()
16797 putPaddrLow(dmabuf->phys); in lpfc_mq_create()
16798 mq_create_ext->u.request.page[dmabuf->buffer_tag].addr_hi = in lpfc_mq_create()
16799 putPaddrHigh(dmabuf->phys); in lpfc_mq_create()
16802 mq->queue_id = bf_get(lpfc_mbx_mq_create_q_id, in lpfc_mq_create()
16803 &mq_create_ext->u.response); in lpfc_mq_create()
16810 mq_create = &mbox->u.mqe.un.mq_create; in lpfc_mq_create()
16812 shdr = (union lpfc_sli4_cfg_shdr *) &mq_create->header.cfg_shdr; in lpfc_mq_create()
16813 mq->queue_id = bf_get(lpfc_mbx_mq_create_q_id, in lpfc_mq_create()
16814 &mq_create->u.response); in lpfc_mq_create()
16817 /* The IOCTL status is embedded in the mailbox subheader. */ in lpfc_mq_create()
16818 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_mq_create()
16819 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_mq_create()
16822 "2502 MQ_CREATE mailbox failed with " in lpfc_mq_create()
16825 status = -ENXIO; in lpfc_mq_create()
16828 if (mq->queue_id == 0xFFFF) { in lpfc_mq_create()
16829 status = -ENXIO; in lpfc_mq_create()
16832 mq->type = LPFC_MQ; in lpfc_mq_create()
16833 mq->assoc_qid = cq->queue_id; in lpfc_mq_create()
16834 mq->subtype = subtype; in lpfc_mq_create()
16835 mq->host_index = 0; in lpfc_mq_create()
16836 mq->hba_index = 0; in lpfc_mq_create()
16839 list_add_tail(&mq->list, &cq->child_list); in lpfc_mq_create()
16841 mempool_free(mbox, phba->mbox_mem_pool); in lpfc_mq_create()
16846 * lpfc_wq_create - Create a Work Queue on the HBA
16853 * by @phba by sending a WQ_CREATE mailbox command to the HBA.
16855 * The @phba struct is used to send mailbox command to HBA. The @wq struct
16859 * function will send the WQ_CREATE mailbox command to the HBA to setup the
16860 * work queue. This function is asynchronous and will wait for the mailbox
16864 * memory this function will return -ENOMEM. If the queue create mailbox command
16865 * fails this function will return -ENXIO.
16877 uint32_t hw_page_size = phba->sli4_hba.pc_sli4_params.if_page_sz; in lpfc_wq_create()
16891 return -ENODEV; in lpfc_wq_create()
16892 if (!phba->sli4_hba.pc_sli4_params.supported) in lpfc_wq_create()
16893 hw_page_size = wq->page_size; in lpfc_wq_create()
16895 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_wq_create()
16897 return -ENOMEM; in lpfc_wq_create()
16898 length = (sizeof(struct lpfc_mbx_wq_create) - in lpfc_wq_create()
16903 wq_create = &mbox->u.mqe.un.wq_create; in lpfc_wq_create()
16904 shdr = (union lpfc_sli4_cfg_shdr *) &wq_create->header.cfg_shdr; in lpfc_wq_create()
16905 bf_set(lpfc_mbx_wq_create_num_pages, &wq_create->u.request, in lpfc_wq_create()
16906 wq->page_count); in lpfc_wq_create()
16907 bf_set(lpfc_mbx_wq_create_cq_id, &wq_create->u.request, in lpfc_wq_create()
16908 cq->queue_id); in lpfc_wq_create()
16911 bf_set(lpfc_mbox_hdr_version, &shdr->request, in lpfc_wq_create()
16912 phba->sli4_hba.pc_sli4_params.wqv); in lpfc_wq_create()
16914 if ((phba->sli4_hba.pc_sli4_params.wqsize & LPFC_WQ_SZ128_SUPPORT) || in lpfc_wq_create()
16915 (wq->page_size > SLI4_PAGE_SIZE)) in lpfc_wq_create()
16922 bf_set(lpfc_mbx_wq_create_wqe_count, &wq_create->u.request_1, in lpfc_wq_create()
16923 wq->entry_count); in lpfc_wq_create()
16924 bf_set(lpfc_mbox_hdr_version, &shdr->request, in lpfc_wq_create()
16927 switch (wq->entry_size) { in lpfc_wq_create()
16931 &wq_create->u.request_1, in lpfc_wq_create()
16936 &wq_create->u.request_1, in lpfc_wq_create()
16941 bf_set(lpfc_mbx_wq_create_dpp_req, &wq_create->u.request_1, 1); in lpfc_wq_create()
16943 &wq_create->u.request_1, in lpfc_wq_create()
16944 (wq->page_size / SLI4_PAGE_SIZE)); in lpfc_wq_create()
16945 page = wq_create->u.request_1.page; in lpfc_wq_create()
16948 page = wq_create->u.request.page; in lpfc_wq_create()
16952 list_for_each_entry(dmabuf, &wq->page_list, list) { in lpfc_wq_create()
16953 memset(dmabuf->virt, 0, hw_page_size); in lpfc_wq_create()
16954 page[dmabuf->buffer_tag].addr_lo = putPaddrLow(dmabuf->phys); in lpfc_wq_create()
16955 page[dmabuf->buffer_tag].addr_hi = putPaddrHigh(dmabuf->phys); in lpfc_wq_create()
16958 if (phba->sli4_hba.fw_func_mode & LPFC_DUA_MODE) in lpfc_wq_create()
16959 bf_set(lpfc_mbx_wq_create_dua, &wq_create->u.request, 1); in lpfc_wq_create()
16962 /* The IOCTL status is embedded in the mailbox subheader. */ in lpfc_wq_create()
16963 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_wq_create()
16964 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_wq_create()
16967 "2503 WQ_CREATE mailbox failed with " in lpfc_wq_create()
16970 status = -ENXIO; in lpfc_wq_create()
16975 wq->queue_id = bf_get(lpfc_mbx_wq_create_q_id, in lpfc_wq_create()
16976 &wq_create->u.response); in lpfc_wq_create()
16978 wq->queue_id = bf_get(lpfc_mbx_wq_create_v1_q_id, in lpfc_wq_create()
16979 &wq_create->u.response_1); in lpfc_wq_create()
16981 if (wq->queue_id == 0xFFFF) { in lpfc_wq_create()
16982 status = -ENXIO; in lpfc_wq_create()
16986 wq->db_format = LPFC_DB_LIST_FORMAT; in lpfc_wq_create()
16988 if (phba->sli4_hba.fw_func_mode & LPFC_DUA_MODE) { in lpfc_wq_create()
16989 wq->db_format = bf_get(lpfc_mbx_wq_create_db_format, in lpfc_wq_create()
16990 &wq_create->u.response); in lpfc_wq_create()
16991 if ((wq->db_format != LPFC_DB_LIST_FORMAT) && in lpfc_wq_create()
16992 (wq->db_format != LPFC_DB_RING_FORMAT)) { in lpfc_wq_create()
16996 wq->queue_id, wq->db_format); in lpfc_wq_create()
16997 status = -EINVAL; in lpfc_wq_create()
17001 &wq_create->u.response); in lpfc_wq_create()
17008 wq->queue_id, pci_barset); in lpfc_wq_create()
17009 status = -ENOMEM; in lpfc_wq_create()
17012 db_offset = wq_create->u.response.doorbell_offset; in lpfc_wq_create()
17018 wq->queue_id, db_offset); in lpfc_wq_create()
17019 status = -EINVAL; in lpfc_wq_create()
17022 wq->db_regaddr = bar_memmap_p + db_offset; in lpfc_wq_create()
17025 "format:x%x\n", wq->queue_id, in lpfc_wq_create()
17026 pci_barset, db_offset, wq->db_format); in lpfc_wq_create()
17028 wq->db_regaddr = phba->sli4_hba.WQDBregaddr; in lpfc_wq_create()
17031 wq->dpp_enable = bf_get(lpfc_mbx_wq_create_dpp_rsp, in lpfc_wq_create()
17032 &wq_create->u.response_1); in lpfc_wq_create()
17033 if (wq->dpp_enable) { in lpfc_wq_create()
17035 &wq_create->u.response_1); in lpfc_wq_create()
17042 wq->queue_id, pci_barset); in lpfc_wq_create()
17043 status = -ENOMEM; in lpfc_wq_create()
17046 db_offset = wq_create->u.response_1.doorbell_offset; in lpfc_wq_create()
17047 wq->db_regaddr = bar_memmap_p + db_offset; in lpfc_wq_create()
17048 wq->dpp_id = bf_get(lpfc_mbx_wq_create_dpp_id, in lpfc_wq_create()
17049 &wq_create->u.response_1); in lpfc_wq_create()
17051 &wq_create->u.response_1); in lpfc_wq_create()
17058 wq->queue_id, dpp_barset); in lpfc_wq_create()
17059 status = -ENOMEM; in lpfc_wq_create()
17062 dpp_offset = wq_create->u.response_1.dpp_offset; in lpfc_wq_create()
17063 wq->dpp_regaddr = bar_memmap_p + dpp_offset; in lpfc_wq_create()
17068 wq->queue_id, pci_barset, db_offset, in lpfc_wq_create()
17069 wq->dpp_id, dpp_barset, dpp_offset); in lpfc_wq_create()
17073 pg_addr = (unsigned long)(wq->dpp_regaddr) & PAGE_MASK; in lpfc_wq_create()
17078 "Write on WQ[%d] - disable DPP\n", in lpfc_wq_create()
17079 wq->queue_id); in lpfc_wq_create()
17080 phba->cfg_enable_dpp = 0; in lpfc_wq_create()
17083 phba->cfg_enable_dpp = 0; in lpfc_wq_create()
17086 wq->db_regaddr = phba->sli4_hba.WQDBregaddr; in lpfc_wq_create()
17088 wq->pring = kzalloc(sizeof(struct lpfc_sli_ring), GFP_KERNEL); in lpfc_wq_create()
17089 if (wq->pring == NULL) { in lpfc_wq_create()
17090 status = -ENOMEM; in lpfc_wq_create()
17093 wq->type = LPFC_WQ; in lpfc_wq_create()
17094 wq->assoc_qid = cq->queue_id; in lpfc_wq_create()
17095 wq->subtype = subtype; in lpfc_wq_create()
17096 wq->host_index = 0; in lpfc_wq_create()
17097 wq->hba_index = 0; in lpfc_wq_create()
17098 wq->notify_interval = LPFC_WQ_NOTIFY_INTRVL; in lpfc_wq_create()
17101 list_add_tail(&wq->list, &cq->child_list); in lpfc_wq_create()
17103 mempool_free(mbox, phba->mbox_mem_pool); in lpfc_wq_create()
17108 * lpfc_rq_create - Create a Receive Queue on the HBA
17116 * @drq, on a port, described by @phba by sending a RQ_CREATE mailbox command
17119 * The @phba struct is used to send mailbox command to HBA. The @drq and @hrq
17123 * This function will send the RQ_CREATE mailbox command to the HBA to setup the
17125 * mailbox command to finish before continuing.
17128 * memory this function will return -ENOMEM. If the queue create mailbox command
17129 * fails this function will return -ENXIO.
17141 uint32_t hw_page_size = phba->sli4_hba.pc_sli4_params.if_page_sz; in lpfc_rq_create()
17148 return -ENODEV; in lpfc_rq_create()
17149 if (!phba->sli4_hba.pc_sli4_params.supported) in lpfc_rq_create()
17152 if (hrq->entry_count != drq->entry_count) in lpfc_rq_create()
17153 return -EINVAL; in lpfc_rq_create()
17154 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_rq_create()
17156 return -ENOMEM; in lpfc_rq_create()
17157 length = (sizeof(struct lpfc_mbx_rq_create) - in lpfc_rq_create()
17162 rq_create = &mbox->u.mqe.un.rq_create; in lpfc_rq_create()
17163 shdr = (union lpfc_sli4_cfg_shdr *) &rq_create->header.cfg_shdr; in lpfc_rq_create()
17164 bf_set(lpfc_mbox_hdr_version, &shdr->request, in lpfc_rq_create()
17165 phba->sli4_hba.pc_sli4_params.rqv); in lpfc_rq_create()
17166 if (phba->sli4_hba.pc_sli4_params.rqv == LPFC_Q_CREATE_VERSION_1) { in lpfc_rq_create()
17168 &rq_create->u.request.context, in lpfc_rq_create()
17169 hrq->entry_count); in lpfc_rq_create()
17170 rq_create->u.request.context.buffer_size = LPFC_HDR_BUF_SIZE; in lpfc_rq_create()
17172 &rq_create->u.request.context, in lpfc_rq_create()
17175 &rq_create->u.request.context, in lpfc_rq_create()
17178 switch (hrq->entry_count) { in lpfc_rq_create()
17182 hrq->entry_count); in lpfc_rq_create()
17183 if (hrq->entry_count < 512) { in lpfc_rq_create()
17184 status = -EINVAL; in lpfc_rq_create()
17190 &rq_create->u.request.context, in lpfc_rq_create()
17195 &rq_create->u.request.context, in lpfc_rq_create()
17200 &rq_create->u.request.context, in lpfc_rq_create()
17205 &rq_create->u.request.context, in lpfc_rq_create()
17209 bf_set(lpfc_rq_context_buf_size, &rq_create->u.request.context, in lpfc_rq_create()
17212 bf_set(lpfc_rq_context_cq_id, &rq_create->u.request.context, in lpfc_rq_create()
17213 cq->queue_id); in lpfc_rq_create()
17214 bf_set(lpfc_mbx_rq_create_num_pages, &rq_create->u.request, in lpfc_rq_create()
17215 hrq->page_count); in lpfc_rq_create()
17216 list_for_each_entry(dmabuf, &hrq->page_list, list) { in lpfc_rq_create()
17217 memset(dmabuf->virt, 0, hw_page_size); in lpfc_rq_create()
17218 rq_create->u.request.page[dmabuf->buffer_tag].addr_lo = in lpfc_rq_create()
17219 putPaddrLow(dmabuf->phys); in lpfc_rq_create()
17220 rq_create->u.request.page[dmabuf->buffer_tag].addr_hi = in lpfc_rq_create()
17221 putPaddrHigh(dmabuf->phys); in lpfc_rq_create()
17223 if (phba->sli4_hba.fw_func_mode & LPFC_DUA_MODE) in lpfc_rq_create()
17224 bf_set(lpfc_mbx_rq_create_dua, &rq_create->u.request, 1); in lpfc_rq_create()
17227 /* The IOCTL status is embedded in the mailbox subheader. */ in lpfc_rq_create()
17228 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_rq_create()
17229 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_rq_create()
17232 "2504 RQ_CREATE mailbox failed with " in lpfc_rq_create()
17235 status = -ENXIO; in lpfc_rq_create()
17238 hrq->queue_id = bf_get(lpfc_mbx_rq_create_q_id, &rq_create->u.response); in lpfc_rq_create()
17239 if (hrq->queue_id == 0xFFFF) { in lpfc_rq_create()
17240 status = -ENXIO; in lpfc_rq_create()
17244 if (phba->sli4_hba.fw_func_mode & LPFC_DUA_MODE) { in lpfc_rq_create()
17245 hrq->db_format = bf_get(lpfc_mbx_rq_create_db_format, in lpfc_rq_create()
17246 &rq_create->u.response); in lpfc_rq_create()
17247 if ((hrq->db_format != LPFC_DB_LIST_FORMAT) && in lpfc_rq_create()
17248 (hrq->db_format != LPFC_DB_RING_FORMAT)) { in lpfc_rq_create()
17251 "supported: x%x\n", hrq->queue_id, in lpfc_rq_create()
17252 hrq->db_format); in lpfc_rq_create()
17253 status = -EINVAL; in lpfc_rq_create()
17258 &rq_create->u.response); in lpfc_rq_create()
17263 "barset:x%x\n", hrq->queue_id, in lpfc_rq_create()
17265 status = -ENOMEM; in lpfc_rq_create()
17269 db_offset = rq_create->u.response.doorbell_offset; in lpfc_rq_create()
17274 "supported: x%x\n", hrq->queue_id, in lpfc_rq_create()
17276 status = -EINVAL; in lpfc_rq_create()
17279 hrq->db_regaddr = bar_memmap_p + db_offset; in lpfc_rq_create()
17282 "format:x%x\n", hrq->queue_id, pci_barset, in lpfc_rq_create()
17283 db_offset, hrq->db_format); in lpfc_rq_create()
17285 hrq->db_format = LPFC_DB_RING_FORMAT; in lpfc_rq_create()
17286 hrq->db_regaddr = phba->sli4_hba.RQDBregaddr; in lpfc_rq_create()
17288 hrq->type = LPFC_HRQ; in lpfc_rq_create()
17289 hrq->assoc_qid = cq->queue_id; in lpfc_rq_create()
17290 hrq->subtype = subtype; in lpfc_rq_create()
17291 hrq->host_index = 0; in lpfc_rq_create()
17292 hrq->hba_index = 0; in lpfc_rq_create()
17293 hrq->notify_interval = LPFC_RQ_NOTIFY_INTRVL; in lpfc_rq_create()
17299 bf_set(lpfc_mbox_hdr_version, &shdr->request, in lpfc_rq_create()
17300 phba->sli4_hba.pc_sli4_params.rqv); in lpfc_rq_create()
17301 if (phba->sli4_hba.pc_sli4_params.rqv == LPFC_Q_CREATE_VERSION_1) { in lpfc_rq_create()
17303 &rq_create->u.request.context, hrq->entry_count); in lpfc_rq_create()
17305 rq_create->u.request.context.buffer_size = in lpfc_rq_create()
17308 rq_create->u.request.context.buffer_size = in lpfc_rq_create()
17310 bf_set(lpfc_rq_context_rqe_size, &rq_create->u.request.context, in lpfc_rq_create()
17312 bf_set(lpfc_rq_context_page_size, &rq_create->u.request.context, in lpfc_rq_create()
17315 switch (drq->entry_count) { in lpfc_rq_create()
17319 drq->entry_count); in lpfc_rq_create()
17320 if (drq->entry_count < 512) { in lpfc_rq_create()
17321 status = -EINVAL; in lpfc_rq_create()
17327 &rq_create->u.request.context, in lpfc_rq_create()
17332 &rq_create->u.request.context, in lpfc_rq_create()
17337 &rq_create->u.request.context, in lpfc_rq_create()
17342 &rq_create->u.request.context, in lpfc_rq_create()
17348 &rq_create->u.request.context, in lpfc_rq_create()
17352 &rq_create->u.request.context, in lpfc_rq_create()
17355 bf_set(lpfc_rq_context_cq_id, &rq_create->u.request.context, in lpfc_rq_create()
17356 cq->queue_id); in lpfc_rq_create()
17357 bf_set(lpfc_mbx_rq_create_num_pages, &rq_create->u.request, in lpfc_rq_create()
17358 drq->page_count); in lpfc_rq_create()
17359 list_for_each_entry(dmabuf, &drq->page_list, list) { in lpfc_rq_create()
17360 rq_create->u.request.page[dmabuf->buffer_tag].addr_lo = in lpfc_rq_create()
17361 putPaddrLow(dmabuf->phys); in lpfc_rq_create()
17362 rq_create->u.request.page[dmabuf->buffer_tag].addr_hi = in lpfc_rq_create()
17363 putPaddrHigh(dmabuf->phys); in lpfc_rq_create()
17365 if (phba->sli4_hba.fw_func_mode & LPFC_DUA_MODE) in lpfc_rq_create()
17366 bf_set(lpfc_mbx_rq_create_dua, &rq_create->u.request, 1); in lpfc_rq_create()
17368 /* The IOCTL status is embedded in the mailbox subheader. */ in lpfc_rq_create()
17369 shdr = (union lpfc_sli4_cfg_shdr *) &rq_create->header.cfg_shdr; in lpfc_rq_create()
17370 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_rq_create()
17371 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_rq_create()
17373 status = -ENXIO; in lpfc_rq_create()
17376 drq->queue_id = bf_get(lpfc_mbx_rq_create_q_id, &rq_create->u.response); in lpfc_rq_create()
17377 if (drq->queue_id == 0xFFFF) { in lpfc_rq_create()
17378 status = -ENXIO; in lpfc_rq_create()
17381 drq->type = LPFC_DRQ; in lpfc_rq_create()
17382 drq->assoc_qid = cq->queue_id; in lpfc_rq_create()
17383 drq->subtype = subtype; in lpfc_rq_create()
17384 drq->host_index = 0; in lpfc_rq_create()
17385 drq->hba_index = 0; in lpfc_rq_create()
17386 drq->notify_interval = LPFC_RQ_NOTIFY_INTRVL; in lpfc_rq_create()
17389 list_add_tail(&hrq->list, &cq->child_list); in lpfc_rq_create()
17390 list_add_tail(&drq->list, &cq->child_list); in lpfc_rq_create()
17393 mempool_free(mbox, phba->mbox_mem_pool); in lpfc_rq_create()
17398 * lpfc_mrq_create - Create MRQ Receive Queues on the HBA
17406 * @drq, on a port, described by @phba by sending a RQ_CREATE mailbox command
17409 * The @phba struct is used to send mailbox command to HBA. The @drq and @hrq
17413 * This function will send the RQ_CREATE mailbox command to the HBA to setup the
17415 * mailbox command to finish before continuing.
17418 * memory this function will return -ENOMEM. If the queue create mailbox command
17419 * fails this function will return -ENXIO.
17434 uint32_t hw_page_size = phba->sli4_hba.pc_sli4_params.if_page_sz; in lpfc_mrq_create()
17436 numrq = phba->cfg_nvmet_mrq; in lpfc_mrq_create()
17439 return -ENODEV; in lpfc_mrq_create()
17440 if (!phba->sli4_hba.pc_sli4_params.supported) in lpfc_mrq_create()
17443 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_mrq_create()
17445 return -ENOMEM; in lpfc_mrq_create()
17448 length += ((2 * numrq * hrqp[0]->page_count) * in lpfc_mrq_create()
17459 status = -ENOMEM; in lpfc_mrq_create()
17465 rq_create = mbox->sge_array->addr[0]; in lpfc_mrq_create()
17466 shdr = (union lpfc_sli4_cfg_shdr *)&rq_create->cfg_shdr; in lpfc_mrq_create()
17468 bf_set(lpfc_mbox_hdr_version, &shdr->request, LPFC_Q_CREATE_VERSION_2); in lpfc_mrq_create()
17478 status = -ENODEV; in lpfc_mrq_create()
17482 if (hrq->entry_count != drq->entry_count) { in lpfc_mrq_create()
17483 status = -EINVAL; in lpfc_mrq_create()
17489 &rq_create->u.request, in lpfc_mrq_create()
17490 hrq->page_count); in lpfc_mrq_create()
17492 &rq_create->u.request, (numrq * 2)); in lpfc_mrq_create()
17493 bf_set(lpfc_mbx_rq_create_dnb, &rq_create->u.request, in lpfc_mrq_create()
17496 &rq_create->u.request.context, in lpfc_mrq_create()
17497 cq->queue_id); in lpfc_mrq_create()
17499 &rq_create->u.request.context, in lpfc_mrq_create()
17502 &rq_create->u.request.context, in lpfc_mrq_create()
17505 &rq_create->u.request.context, in lpfc_mrq_create()
17506 hrq->entry_count); in lpfc_mrq_create()
17508 &rq_create->u.request.context, in lpfc_mrq_create()
17511 &rq_create->u.request.context, in lpfc_mrq_create()
17515 list_for_each_entry(dmabuf, &hrq->page_list, list) { in lpfc_mrq_create()
17516 memset(dmabuf->virt, 0, hw_page_size); in lpfc_mrq_create()
17517 cnt = page_idx + dmabuf->buffer_tag; in lpfc_mrq_create()
17518 rq_create->u.request.page[cnt].addr_lo = in lpfc_mrq_create()
17519 putPaddrLow(dmabuf->phys); in lpfc_mrq_create()
17520 rq_create->u.request.page[cnt].addr_hi = in lpfc_mrq_create()
17521 putPaddrHigh(dmabuf->phys); in lpfc_mrq_create()
17527 list_for_each_entry(dmabuf, &drq->page_list, list) { in lpfc_mrq_create()
17528 memset(dmabuf->virt, 0, hw_page_size); in lpfc_mrq_create()
17529 cnt = page_idx + dmabuf->buffer_tag; in lpfc_mrq_create()
17530 rq_create->u.request.page[cnt].addr_lo = in lpfc_mrq_create()
17531 putPaddrLow(dmabuf->phys); in lpfc_mrq_create()
17532 rq_create->u.request.page[cnt].addr_hi = in lpfc_mrq_create()
17533 putPaddrHigh(dmabuf->phys); in lpfc_mrq_create()
17538 hrq->db_format = LPFC_DB_RING_FORMAT; in lpfc_mrq_create()
17539 hrq->db_regaddr = phba->sli4_hba.RQDBregaddr; in lpfc_mrq_create()
17540 hrq->type = LPFC_HRQ; in lpfc_mrq_create()
17541 hrq->assoc_qid = cq->queue_id; in lpfc_mrq_create()
17542 hrq->subtype = subtype; in lpfc_mrq_create()
17543 hrq->host_index = 0; in lpfc_mrq_create()
17544 hrq->hba_index = 0; in lpfc_mrq_create()
17545 hrq->notify_interval = LPFC_RQ_NOTIFY_INTRVL; in lpfc_mrq_create()
17547 drq->db_format = LPFC_DB_RING_FORMAT; in lpfc_mrq_create()
17548 drq->db_regaddr = phba->sli4_hba.RQDBregaddr; in lpfc_mrq_create()
17549 drq->type = LPFC_DRQ; in lpfc_mrq_create()
17550 drq->assoc_qid = cq->queue_id; in lpfc_mrq_create()
17551 drq->subtype = subtype; in lpfc_mrq_create()
17552 drq->host_index = 0; in lpfc_mrq_create()
17553 drq->hba_index = 0; in lpfc_mrq_create()
17554 drq->notify_interval = LPFC_RQ_NOTIFY_INTRVL; in lpfc_mrq_create()
17556 list_add_tail(&hrq->list, &cq->child_list); in lpfc_mrq_create()
17557 list_add_tail(&drq->list, &cq->child_list); in lpfc_mrq_create()
17561 /* The IOCTL status is embedded in the mailbox subheader. */ in lpfc_mrq_create()
17562 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_mrq_create()
17563 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_mrq_create()
17566 "3120 RQ_CREATE mailbox failed with " in lpfc_mrq_create()
17569 status = -ENXIO; in lpfc_mrq_create()
17572 rc = bf_get(lpfc_mbx_rq_create_q_id, &rq_create->u.response); in lpfc_mrq_create()
17574 status = -ENXIO; in lpfc_mrq_create()
17581 hrq->queue_id = rc + (2 * idx); in lpfc_mrq_create()
17583 drq->queue_id = rc + (2 * idx) + 1; in lpfc_mrq_create()
17592 * lpfc_eq_destroy - Destroy an event Queue on the HBA
17596 * This function destroys a queue, as detailed in @eq by sending an mailbox
17601 * On success this function will return a zero. If the queue destroy mailbox
17602 * command fails this function will return -ENXIO.
17614 return -ENODEV; in lpfc_eq_destroy()
17616 if (!(phba->sli.sli_flag & LPFC_SLI_ACTIVE)) in lpfc_eq_destroy()
17619 mbox = mempool_alloc(eq->phba->mbox_mem_pool, GFP_KERNEL); in lpfc_eq_destroy()
17621 return -ENOMEM; in lpfc_eq_destroy()
17622 length = (sizeof(struct lpfc_mbx_eq_destroy) - in lpfc_eq_destroy()
17627 bf_set(lpfc_mbx_eq_destroy_q_id, &mbox->u.mqe.un.eq_destroy.u.request, in lpfc_eq_destroy()
17628 eq->queue_id); in lpfc_eq_destroy()
17629 mbox->vport = eq->phba->pport; in lpfc_eq_destroy()
17630 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_eq_destroy()
17632 rc = lpfc_sli_issue_mbox(eq->phba, mbox, MBX_POLL); in lpfc_eq_destroy()
17633 /* The IOCTL status is embedded in the mailbox subheader. */ in lpfc_eq_destroy()
17635 &mbox->u.mqe.un.eq_destroy.header.cfg_shdr; in lpfc_eq_destroy()
17636 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_eq_destroy()
17637 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_eq_destroy()
17640 "2505 EQ_DESTROY mailbox failed with " in lpfc_eq_destroy()
17643 status = -ENXIO; in lpfc_eq_destroy()
17645 mempool_free(mbox, eq->phba->mbox_mem_pool); in lpfc_eq_destroy()
17649 list_del_init(&eq->list); in lpfc_eq_destroy()
17655 * lpfc_cq_destroy - Destroy a Completion Queue on the HBA
17659 * This function destroys a queue, as detailed in @cq by sending an mailbox
17664 * On success this function will return a zero. If the queue destroy mailbox
17665 * command fails this function will return -ENXIO.
17677 return -ENODEV; in lpfc_cq_destroy()
17679 if (!(phba->sli.sli_flag & LPFC_SLI_ACTIVE)) in lpfc_cq_destroy()
17682 mbox = mempool_alloc(cq->phba->mbox_mem_pool, GFP_KERNEL); in lpfc_cq_destroy()
17684 return -ENOMEM; in lpfc_cq_destroy()
17685 length = (sizeof(struct lpfc_mbx_cq_destroy) - in lpfc_cq_destroy()
17690 bf_set(lpfc_mbx_cq_destroy_q_id, &mbox->u.mqe.un.cq_destroy.u.request, in lpfc_cq_destroy()
17691 cq->queue_id); in lpfc_cq_destroy()
17692 mbox->vport = cq->phba->pport; in lpfc_cq_destroy()
17693 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_cq_destroy()
17694 rc = lpfc_sli_issue_mbox(cq->phba, mbox, MBX_POLL); in lpfc_cq_destroy()
17695 /* The IOCTL status is embedded in the mailbox subheader. */ in lpfc_cq_destroy()
17697 &mbox->u.mqe.un.wq_create.header.cfg_shdr; in lpfc_cq_destroy()
17698 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_cq_destroy()
17699 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_cq_destroy()
17702 "2506 CQ_DESTROY mailbox failed with " in lpfc_cq_destroy()
17705 status = -ENXIO; in lpfc_cq_destroy()
17707 mempool_free(mbox, cq->phba->mbox_mem_pool); in lpfc_cq_destroy()
17711 list_del_init(&cq->list); in lpfc_cq_destroy()
17716 * lpfc_mq_destroy - Destroy a Mailbox Queue on the HBA
17720 * This function destroys a queue, as detailed in @mq by sending an mailbox
17725 * On success this function will return a zero. If the queue destroy mailbox
17726 * command fails this function will return -ENXIO.
17738 return -ENODEV; in lpfc_mq_destroy()
17740 if (!(phba->sli.sli_flag & LPFC_SLI_ACTIVE)) in lpfc_mq_destroy()
17743 mbox = mempool_alloc(mq->phba->mbox_mem_pool, GFP_KERNEL); in lpfc_mq_destroy()
17745 return -ENOMEM; in lpfc_mq_destroy()
17746 length = (sizeof(struct lpfc_mbx_mq_destroy) - in lpfc_mq_destroy()
17751 bf_set(lpfc_mbx_mq_destroy_q_id, &mbox->u.mqe.un.mq_destroy.u.request, in lpfc_mq_destroy()
17752 mq->queue_id); in lpfc_mq_destroy()
17753 mbox->vport = mq->phba->pport; in lpfc_mq_destroy()
17754 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_mq_destroy()
17755 rc = lpfc_sli_issue_mbox(mq->phba, mbox, MBX_POLL); in lpfc_mq_destroy()
17756 /* The IOCTL status is embedded in the mailbox subheader. */ in lpfc_mq_destroy()
17758 &mbox->u.mqe.un.mq_destroy.header.cfg_shdr; in lpfc_mq_destroy()
17759 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_mq_destroy()
17760 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_mq_destroy()
17763 "2507 MQ_DESTROY mailbox failed with " in lpfc_mq_destroy()
17766 status = -ENXIO; in lpfc_mq_destroy()
17768 mempool_free(mbox, mq->phba->mbox_mem_pool); in lpfc_mq_destroy()
17772 list_del_init(&mq->list); in lpfc_mq_destroy()
17777 * lpfc_wq_destroy - Destroy a Work Queue on the HBA
17781 * This function destroys a queue, as detailed in @wq by sending an mailbox
17786 * On success this function will return a zero. If the queue destroy mailbox
17787 * command fails this function will return -ENXIO.
17799 return -ENODEV; in lpfc_wq_destroy()
17801 if (!(phba->sli.sli_flag & LPFC_SLI_ACTIVE)) in lpfc_wq_destroy()
17804 mbox = mempool_alloc(wq->phba->mbox_mem_pool, GFP_KERNEL); in lpfc_wq_destroy()
17806 return -ENOMEM; in lpfc_wq_destroy()
17807 length = (sizeof(struct lpfc_mbx_wq_destroy) - in lpfc_wq_destroy()
17812 bf_set(lpfc_mbx_wq_destroy_q_id, &mbox->u.mqe.un.wq_destroy.u.request, in lpfc_wq_destroy()
17813 wq->queue_id); in lpfc_wq_destroy()
17814 mbox->vport = wq->phba->pport; in lpfc_wq_destroy()
17815 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_wq_destroy()
17816 rc = lpfc_sli_issue_mbox(wq->phba, mbox, MBX_POLL); in lpfc_wq_destroy()
17818 &mbox->u.mqe.un.wq_destroy.header.cfg_shdr; in lpfc_wq_destroy()
17819 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_wq_destroy()
17820 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_wq_destroy()
17823 "2508 WQ_DESTROY mailbox failed with " in lpfc_wq_destroy()
17826 status = -ENXIO; in lpfc_wq_destroy()
17828 mempool_free(mbox, wq->phba->mbox_mem_pool); in lpfc_wq_destroy()
17832 list_del_init(&wq->list); in lpfc_wq_destroy()
17833 kfree(wq->pring); in lpfc_wq_destroy()
17834 wq->pring = NULL; in lpfc_wq_destroy()
17839 * lpfc_rq_destroy - Destroy a Receive Queue on the HBA
17844 * This function destroys a queue, as detailed in @rq by sending an mailbox
17849 * On success this function will return a zero. If the queue destroy mailbox
17850 * command fails this function will return -ENXIO.
17863 return -ENODEV; in lpfc_rq_destroy()
17865 if (!(phba->sli.sli_flag & LPFC_SLI_ACTIVE)) in lpfc_rq_destroy()
17868 mbox = mempool_alloc(hrq->phba->mbox_mem_pool, GFP_KERNEL); in lpfc_rq_destroy()
17870 return -ENOMEM; in lpfc_rq_destroy()
17871 length = (sizeof(struct lpfc_mbx_rq_destroy) - in lpfc_rq_destroy()
17876 bf_set(lpfc_mbx_rq_destroy_q_id, &mbox->u.mqe.un.rq_destroy.u.request, in lpfc_rq_destroy()
17877 hrq->queue_id); in lpfc_rq_destroy()
17878 mbox->vport = hrq->phba->pport; in lpfc_rq_destroy()
17879 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_rq_destroy()
17880 rc = lpfc_sli_issue_mbox(hrq->phba, mbox, MBX_POLL); in lpfc_rq_destroy()
17881 /* The IOCTL status is embedded in the mailbox subheader. */ in lpfc_rq_destroy()
17883 &mbox->u.mqe.un.rq_destroy.header.cfg_shdr; in lpfc_rq_destroy()
17884 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_rq_destroy()
17885 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_rq_destroy()
17888 "2509 RQ_DESTROY mailbox failed with " in lpfc_rq_destroy()
17891 mempool_free(mbox, hrq->phba->mbox_mem_pool); in lpfc_rq_destroy()
17892 return -ENXIO; in lpfc_rq_destroy()
17894 bf_set(lpfc_mbx_rq_destroy_q_id, &mbox->u.mqe.un.rq_destroy.u.request, in lpfc_rq_destroy()
17895 drq->queue_id); in lpfc_rq_destroy()
17896 rc = lpfc_sli_issue_mbox(drq->phba, mbox, MBX_POLL); in lpfc_rq_destroy()
17898 &mbox->u.mqe.un.rq_destroy.header.cfg_shdr; in lpfc_rq_destroy()
17899 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_rq_destroy()
17900 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_rq_destroy()
17903 "2510 RQ_DESTROY mailbox failed with " in lpfc_rq_destroy()
17906 status = -ENXIO; in lpfc_rq_destroy()
17908 mempool_free(mbox, hrq->phba->mbox_mem_pool); in lpfc_rq_destroy()
17911 list_del_init(&hrq->list); in lpfc_rq_destroy()
17912 list_del_init(&drq->list); in lpfc_rq_destroy()
17917 * lpfc_sli4_post_sgl - Post scatter gather list for an XRI to HBA
17935 * 0 - Success
17936 * -ENXIO, -ENOMEM - Failure
17954 return -EINVAL; in lpfc_sli4_post_sgl()
17957 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_post_sgl()
17959 return -ENOMEM; in lpfc_sli4_post_sgl()
17963 sizeof(struct lpfc_mbx_post_sgl_pages) - in lpfc_sli4_post_sgl()
17967 &mbox->u.mqe.un.post_sgl_pages; in lpfc_sli4_post_sgl()
17971 post_sgl_pages->sgl_pg_pairs[0].sgl_pg0_addr_lo = in lpfc_sli4_post_sgl()
17973 post_sgl_pages->sgl_pg_pairs[0].sgl_pg0_addr_hi = in lpfc_sli4_post_sgl()
17976 post_sgl_pages->sgl_pg_pairs[0].sgl_pg1_addr_lo = in lpfc_sli4_post_sgl()
17978 post_sgl_pages->sgl_pg_pairs[0].sgl_pg1_addr_hi = in lpfc_sli4_post_sgl()
17980 if (!phba->sli4_hba.intr_enable) in lpfc_sli4_post_sgl()
17986 /* The IOCTL status is embedded in the mailbox subheader. */ in lpfc_sli4_post_sgl()
17987 shdr = (union lpfc_sli4_cfg_shdr *) &post_sgl_pages->header.cfg_shdr; in lpfc_sli4_post_sgl()
17988 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_sli4_post_sgl()
17989 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_sli4_post_sgl()
17990 if (!phba->sli4_hba.intr_enable) in lpfc_sli4_post_sgl()
17991 mempool_free(mbox, phba->mbox_mem_pool); in lpfc_sli4_post_sgl()
17993 mempool_free(mbox, phba->mbox_mem_pool); in lpfc_sli4_post_sgl()
17996 "2511 POST_SGL mailbox failed with " in lpfc_sli4_post_sgl()
18004 * lpfc_sli4_alloc_xri - Get an available rpi in the device's range
18008 * HBA consistent with the SLI-4 interface spec. This routine
18025 spin_lock_irq(&phba->hbalock); in lpfc_sli4_alloc_xri()
18026 xri = find_first_zero_bit(phba->sli4_hba.xri_bmask, in lpfc_sli4_alloc_xri()
18027 phba->sli4_hba.max_cfg_param.max_xri); in lpfc_sli4_alloc_xri()
18028 if (xri >= phba->sli4_hba.max_cfg_param.max_xri) { in lpfc_sli4_alloc_xri()
18029 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_alloc_xri()
18032 set_bit(xri, phba->sli4_hba.xri_bmask); in lpfc_sli4_alloc_xri()
18033 phba->sli4_hba.max_cfg_param.xri_used++; in lpfc_sli4_alloc_xri()
18035 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_alloc_xri()
18040 * __lpfc_sli4_free_xri - Release an xri for reuse.
18050 if (test_and_clear_bit(xri, phba->sli4_hba.xri_bmask)) { in __lpfc_sli4_free_xri()
18051 phba->sli4_hba.max_cfg_param.xri_used--; in __lpfc_sli4_free_xri()
18056 * lpfc_sli4_free_xri - Release an xri for reuse.
18066 spin_lock_irq(&phba->hbalock); in lpfc_sli4_free_xri()
18068 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_free_xri()
18072 * lpfc_sli4_next_xritag - Get an xritag for the io
18092 phba->sli4_hba.max_cfg_param.max_xri, in lpfc_sli4_next_xritag()
18093 phba->sli4_hba.max_cfg_param.xri_used); in lpfc_sli4_next_xritag()
18098 * lpfc_sli4_post_sgl_list - post a block of ELS sgls to the port.
18104 * HBA using non-embedded mailbox command. No Lock is held. This routine
18131 return -ENOMEM; in lpfc_sli4_post_sgl_list()
18134 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_post_sgl_list()
18136 return -ENOMEM; in lpfc_sli4_post_sgl_list()
18138 /* Allocate DMA memory and set up the non-embedded mailbox command */ in lpfc_sli4_post_sgl_list()
18149 return -ENOMEM; in lpfc_sli4_post_sgl_list()
18151 /* Set up the SGL pages in the non-embedded DMA pages */ in lpfc_sli4_post_sgl_list()
18152 viraddr = mbox->sge_array->addr[0]; in lpfc_sli4_post_sgl_list()
18154 sgl_pg_pairs = &sgl->sgl_pg_pairs; in lpfc_sli4_post_sgl_list()
18159 sgl_pg_pairs->sgl_pg0_addr_lo = in lpfc_sli4_post_sgl_list()
18160 cpu_to_le32(putPaddrLow(sglq_entry->phys)); in lpfc_sli4_post_sgl_list()
18161 sgl_pg_pairs->sgl_pg0_addr_hi = in lpfc_sli4_post_sgl_list()
18162 cpu_to_le32(putPaddrHigh(sglq_entry->phys)); in lpfc_sli4_post_sgl_list()
18163 sgl_pg_pairs->sgl_pg1_addr_lo = in lpfc_sli4_post_sgl_list()
18165 sgl_pg_pairs->sgl_pg1_addr_hi = in lpfc_sli4_post_sgl_list()
18170 xritag_start = sglq_entry->sli4_xritag; in lpfc_sli4_post_sgl_list()
18178 sgl->word0 = cpu_to_le32(sgl->word0); in lpfc_sli4_post_sgl_list()
18180 if (!phba->sli4_hba.intr_enable) in lpfc_sli4_post_sgl_list()
18186 shdr = (union lpfc_sli4_cfg_shdr *) &sgl->cfg_shdr; in lpfc_sli4_post_sgl_list()
18187 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_sli4_post_sgl_list()
18188 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_sli4_post_sgl_list()
18189 if (!phba->sli4_hba.intr_enable) in lpfc_sli4_post_sgl_list()
18195 "2513 POST_SGL_BLOCK mailbox command failed " in lpfc_sli4_post_sgl_list()
18198 rc = -ENXIO; in lpfc_sli4_post_sgl_list()
18204 * lpfc_sli4_post_io_sgl_block - post a block of nvme sgl list to firmware
18210 * SCSI buffer list @nblist to the HBA using non-embedded mailbox command.
18238 return -ENOMEM; in lpfc_sli4_post_io_sgl_block()
18240 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_post_io_sgl_block()
18244 return -ENOMEM; in lpfc_sli4_post_io_sgl_block()
18247 /* Allocate DMA memory and set up the non-embedded mailbox command */ in lpfc_sli4_post_io_sgl_block()
18258 return -ENOMEM; in lpfc_sli4_post_io_sgl_block()
18261 /* Get the first SGE entry from the non-embedded DMA memory */ in lpfc_sli4_post_io_sgl_block()
18262 viraddr = mbox->sge_array->addr[0]; in lpfc_sli4_post_io_sgl_block()
18264 /* Set up the SGL pages in the non-embedded DMA pages */ in lpfc_sli4_post_io_sgl_block()
18266 sgl_pg_pairs = &sgl->sgl_pg_pairs; in lpfc_sli4_post_io_sgl_block()
18271 sgl_pg_pairs->sgl_pg0_addr_lo = in lpfc_sli4_post_io_sgl_block()
18272 cpu_to_le32(putPaddrLow(lpfc_ncmd->dma_phys_sgl)); in lpfc_sli4_post_io_sgl_block()
18273 sgl_pg_pairs->sgl_pg0_addr_hi = in lpfc_sli4_post_io_sgl_block()
18274 cpu_to_le32(putPaddrHigh(lpfc_ncmd->dma_phys_sgl)); in lpfc_sli4_post_io_sgl_block()
18275 if (phba->cfg_sg_dma_buf_size > SGL_PAGE_SIZE) in lpfc_sli4_post_io_sgl_block()
18276 pdma_phys_bpl1 = lpfc_ncmd->dma_phys_sgl + in lpfc_sli4_post_io_sgl_block()
18280 sgl_pg_pairs->sgl_pg1_addr_lo = in lpfc_sli4_post_io_sgl_block()
18282 sgl_pg_pairs->sgl_pg1_addr_hi = in lpfc_sli4_post_io_sgl_block()
18286 xritag_start = lpfc_ncmd->cur_iocbq.sli4_xritag; in lpfc_sli4_post_io_sgl_block()
18293 sgl->word0 = cpu_to_le32(sgl->word0); in lpfc_sli4_post_io_sgl_block()
18295 if (!phba->sli4_hba.intr_enable) { in lpfc_sli4_post_io_sgl_block()
18301 shdr = (union lpfc_sli4_cfg_shdr *)&sgl->cfg_shdr; in lpfc_sli4_post_io_sgl_block()
18302 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_sli4_post_io_sgl_block()
18303 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_sli4_post_io_sgl_block()
18304 if (!phba->sli4_hba.intr_enable) in lpfc_sli4_post_io_sgl_block()
18310 "6125 POST_SGL_BLOCK mailbox command failed " in lpfc_sli4_post_io_sgl_block()
18313 rc = -ENXIO; in lpfc_sli4_post_io_sgl_block()
18319 * lpfc_sli4_post_io_sgl_list - Post blocks of nvme buffer sgls from a list
18326 * uses the non-embedded SGL block post mailbox commands to post to the port.
18327 * For single NVME buffer sgl with non-contiguous xri, if any, it shall use
18328 * embedded SGL post mailbox command for posting. The @post_nblist passed in
18331 * Returns: 0 = failure, non-zero number of successfully posted buffers.
18349 return -EINVAL; in lpfc_sli4_post_io_sgl_list()
18351 sgl_size = phba->cfg_sg_dma_buf_size; in lpfc_sli4_post_io_sgl_list()
18353 list_del_init(&lpfc_ncmd->list); in lpfc_sli4_post_io_sgl_list()
18356 (lpfc_ncmd->cur_iocbq.sli4_xritag != last_xritag + 1)) { in lpfc_sli4_post_io_sgl_list()
18359 post_cnt = block_cnt - 1; in lpfc_sli4_post_io_sgl_list()
18361 list_add_tail(&lpfc_ncmd->list, &prep_nblist); in lpfc_sli4_post_io_sgl_list()
18365 list_add_tail(&lpfc_ncmd->list, &prep_nblist); in lpfc_sli4_post_io_sgl_list()
18366 /* enough sgls for non-embed sgl mbox command */ in lpfc_sli4_post_io_sgl_list()
18374 last_xritag = lpfc_ncmd->cur_iocbq.sli4_xritag; in lpfc_sli4_post_io_sgl_list()
18383 /* last single sgl with non-contiguous xri */ in lpfc_sli4_post_io_sgl_list()
18386 lpfc_ncmd->dma_phys_sgl + in lpfc_sli4_post_io_sgl_list()
18390 cur_xritag = lpfc_ncmd->cur_iocbq.sli4_xritag; in lpfc_sli4_post_io_sgl_list()
18392 phba, lpfc_ncmd->dma_phys_sgl, in lpfc_sli4_post_io_sgl_list()
18396 lpfc_ncmd->flags |= in lpfc_sli4_post_io_sgl_list()
18400 lpfc_ncmd->flags &= in lpfc_sli4_post_io_sgl_list()
18402 lpfc_ncmd->status = IOSTAT_SUCCESS; in lpfc_sli4_post_io_sgl_list()
18406 list_add_tail(&lpfc_ncmd->list, &nvme_nblist); in lpfc_sli4_post_io_sgl_list()
18425 /* put posted NVME buffer-sgl posted on NVME buffer sgl list */ in lpfc_sli4_post_io_sgl_list()
18431 lpfc_ncmd->flags |= LPFC_SBUF_NOT_POSTED; in lpfc_sli4_post_io_sgl_list()
18434 lpfc_ncmd->flags &= ~LPFC_SBUF_NOT_POSTED; in lpfc_sli4_post_io_sgl_list()
18435 lpfc_ncmd->status = IOSTAT_SUCCESS; in lpfc_sli4_post_io_sgl_list()
18438 list_add_tail(&lpfc_ncmd->list, &nvme_nblist); in lpfc_sli4_post_io_sgl_list()
18448 * lpfc_fc_frame_check - Check that this frame is a valid frame to handle
18467 switch (fc_hdr->fh_r_ctl) { in lpfc_fc_frame_check()
18478 case FC_RCTL_ELS4_REQ: /* FC-4 ELS request */ in lpfc_fc_frame_check()
18479 case FC_RCTL_ELS4_REP: /* FC-4 ELS reply */ in lpfc_fc_frame_check()
18505 switch (fc_hdr->fh_type) { in lpfc_fc_frame_check()
18518 if (unlikely(phba->link_flag == LS_LOOPBACK_MODE && in lpfc_fc_frame_check()
18519 phba->cfg_vmid_app_header)) { in lpfc_fc_frame_check()
18521 if (fc_hdr->fh_df_ctl & LPFC_FC_16B_DEVICE_HEADER) { in lpfc_fc_frame_check()
18523 if (be32_to_cpu(fc_app_hdr->src_app_id) != in lpfc_fc_frame_check()
18529 be32_to_cpu(fc_app_hdr->src_app_id)); in lpfc_fc_frame_check()
18538 fc_hdr->fh_df_ctl); in lpfc_fc_frame_check()
18547 fc_hdr->fh_r_ctl, fc_hdr->fh_type, in lpfc_fc_frame_check()
18556 fc_hdr->fh_r_ctl, fc_hdr->fh_type); in lpfc_fc_frame_check()
18561 * lpfc_fc_hdr_get_vfi - Get the VFI from an FC frame
18573 if (fc_hdr->fh_r_ctl != FC_RCTL_VFTH) in lpfc_fc_hdr_get_vfi()
18579 * lpfc_fc_frame_to_vport - Finds the vport that a frame is destined to
18600 return phba->pport; in lpfc_fc_frame_to_vport()
18601 if (test_bit(FC_PT2PT, &phba->pport->fc_flag) && in lpfc_fc_frame_to_vport()
18602 phba->link_state != LPFC_HBA_READY) in lpfc_fc_frame_to_vport()
18603 return phba->pport; in lpfc_fc_frame_to_vport()
18607 for (i = 0; i <= phba->max_vpi && vports[i] != NULL; i++) { in lpfc_fc_frame_to_vport()
18608 if (phba->fcf.fcfi == fcfi && in lpfc_fc_frame_to_vport()
18609 vports[i]->vfi == lpfc_fc_hdr_get_vfi(fc_hdr) && in lpfc_fc_frame_to_vport()
18610 vports[i]->fc_myDID == did) { in lpfc_fc_frame_to_vport()
18621 * lpfc_update_rcv_time_stamp - Update vport's rcv seq time stamp
18637 h_buf = list_get_first(&vport->rcv_buffer_list, in lpfc_update_rcv_time_stamp()
18642 vport->rcv_buffer_time_stamp = dmabuf->time_stamp; in lpfc_update_rcv_time_stamp()
18646 * lpfc_cleanup_rcv_buffers - Cleans up all outstanding receive sequences.
18661 list_for_each_entry_safe(h_buf, hnext, &vport->rcv_buffer_list, list) { in lpfc_cleanup_rcv_buffers()
18663 list_del_init(&dmabuf->hbuf.list); in lpfc_cleanup_rcv_buffers()
18665 &dmabuf->dbuf.list, list) { in lpfc_cleanup_rcv_buffers()
18666 list_del_init(&d_buf->list); in lpfc_cleanup_rcv_buffers()
18667 lpfc_in_buf_free(vport->phba, d_buf); in lpfc_cleanup_rcv_buffers()
18669 lpfc_in_buf_free(vport->phba, &dmabuf->dbuf); in lpfc_cleanup_rcv_buffers()
18674 * lpfc_rcv_seq_check_edtov - Cleans up timed out receive sequences.
18694 timeout = (msecs_to_jiffies(vport->phba->fc_edtov) + in lpfc_rcv_seq_check_edtov()
18695 vport->rcv_buffer_time_stamp); in lpfc_rcv_seq_check_edtov()
18696 if (list_empty(&vport->rcv_buffer_list) || in lpfc_rcv_seq_check_edtov()
18700 list_for_each_entry_safe(h_buf, hnext, &vport->rcv_buffer_list, list) { in lpfc_rcv_seq_check_edtov()
18702 timeout = (msecs_to_jiffies(vport->phba->fc_edtov) + in lpfc_rcv_seq_check_edtov()
18703 dmabuf->time_stamp); in lpfc_rcv_seq_check_edtov()
18707 list_del_init(&dmabuf->hbuf.list); in lpfc_rcv_seq_check_edtov()
18709 &dmabuf->dbuf.list, list) { in lpfc_rcv_seq_check_edtov()
18710 list_del_init(&d_buf->list); in lpfc_rcv_seq_check_edtov()
18711 lpfc_in_buf_free(vport->phba, d_buf); in lpfc_rcv_seq_check_edtov()
18713 lpfc_in_buf_free(vport->phba, &dmabuf->dbuf); in lpfc_rcv_seq_check_edtov()
18720 * lpfc_fc_frame_add - Adds a frame to the vport's list of received sequences
18743 INIT_LIST_HEAD(&dmabuf->dbuf.list); in lpfc_fc_frame_add()
18744 dmabuf->time_stamp = jiffies; in lpfc_fc_frame_add()
18745 new_hdr = (struct fc_frame_header *)dmabuf->hbuf.virt; in lpfc_fc_frame_add()
18748 list_for_each_entry(h_buf, &vport->rcv_buffer_list, list) { in lpfc_fc_frame_add()
18749 temp_hdr = (struct fc_frame_header *)h_buf->virt; in lpfc_fc_frame_add()
18750 if ((temp_hdr->fh_seq_id != new_hdr->fh_seq_id) || in lpfc_fc_frame_add()
18751 (temp_hdr->fh_ox_id != new_hdr->fh_ox_id) || in lpfc_fc_frame_add()
18752 (memcmp(&temp_hdr->fh_s_id, &new_hdr->fh_s_id, 3))) in lpfc_fc_frame_add()
18763 list_add_tail(&dmabuf->hbuf.list, &vport->rcv_buffer_list); in lpfc_fc_frame_add()
18767 temp_hdr = seq_dmabuf->hbuf.virt; in lpfc_fc_frame_add()
18768 if (be16_to_cpu(new_hdr->fh_seq_cnt) < in lpfc_fc_frame_add()
18769 be16_to_cpu(temp_hdr->fh_seq_cnt)) { in lpfc_fc_frame_add()
18770 list_del_init(&seq_dmabuf->hbuf.list); in lpfc_fc_frame_add()
18771 list_add_tail(&dmabuf->hbuf.list, &vport->rcv_buffer_list); in lpfc_fc_frame_add()
18772 list_add_tail(&dmabuf->dbuf.list, &seq_dmabuf->dbuf.list); in lpfc_fc_frame_add()
18777 list_move_tail(&seq_dmabuf->hbuf.list, &vport->rcv_buffer_list); in lpfc_fc_frame_add()
18778 seq_dmabuf->time_stamp = jiffies; in lpfc_fc_frame_add()
18780 if (list_empty(&seq_dmabuf->dbuf.list)) { in lpfc_fc_frame_add()
18781 list_add_tail(&dmabuf->dbuf.list, &seq_dmabuf->dbuf.list); in lpfc_fc_frame_add()
18785 d_buf = list_entry(seq_dmabuf->dbuf.list.prev, typeof(*d_buf), list); in lpfc_fc_frame_add()
18788 temp_hdr = (struct fc_frame_header *)temp_dmabuf->hbuf.virt; in lpfc_fc_frame_add()
18793 if (be16_to_cpu(new_hdr->fh_seq_cnt) > in lpfc_fc_frame_add()
18794 be16_to_cpu(temp_hdr->fh_seq_cnt)) { in lpfc_fc_frame_add()
18795 list_add(&dmabuf->dbuf.list, &temp_dmabuf->dbuf.list); in lpfc_fc_frame_add()
18800 if (&d_buf->list == &seq_dmabuf->dbuf.list) in lpfc_fc_frame_add()
18802 d_buf = list_entry(d_buf->list.prev, typeof(*d_buf), list); in lpfc_fc_frame_add()
18811 * lpfc_sli4_abort_partial_seq - Abort partially assembled unsol sequence
18821 * true -- if there is matching partially assembled sequence present and all
18823 * false -- if there is no matching partially assembled sequence present so
18836 INIT_LIST_HEAD(&dmabuf->dbuf.list); in lpfc_sli4_abort_partial_seq()
18837 INIT_LIST_HEAD(&dmabuf->hbuf.list); in lpfc_sli4_abort_partial_seq()
18838 new_hdr = (struct fc_frame_header *)dmabuf->hbuf.virt; in lpfc_sli4_abort_partial_seq()
18839 list_for_each_entry(h_buf, &vport->rcv_buffer_list, list) { in lpfc_sli4_abort_partial_seq()
18840 temp_hdr = (struct fc_frame_header *)h_buf->virt; in lpfc_sli4_abort_partial_seq()
18841 if ((temp_hdr->fh_seq_id != new_hdr->fh_seq_id) || in lpfc_sli4_abort_partial_seq()
18842 (temp_hdr->fh_ox_id != new_hdr->fh_ox_id) || in lpfc_sli4_abort_partial_seq()
18843 (memcmp(&temp_hdr->fh_s_id, &new_hdr->fh_s_id, 3))) in lpfc_sli4_abort_partial_seq()
18853 &seq_dmabuf->dbuf.list, list) { in lpfc_sli4_abort_partial_seq()
18854 list_del_init(&d_buf->list); in lpfc_sli4_abort_partial_seq()
18855 lpfc_in_buf_free(vport->phba, d_buf); in lpfc_sli4_abort_partial_seq()
18863 * lpfc_sli4_abort_ulp_seq - Abort assembled unsol sequence from ulp
18873 * true -- if there is matching pending context of the sequence cleaned
18875 * false -- if there is no matching pending context of the sequence present
18881 struct lpfc_hba *phba = vport->phba; in lpfc_sli4_abort_ulp_seq()
18885 if (phba->sli_rev < LPFC_SLI_REV4) in lpfc_sli4_abort_ulp_seq()
18897 * lpfc_sli4_seq_abort_rsp_cmpl - BLS ABORT RSP seq abort iocb complete handler
18912 lpfc_nlp_put(cmd_iocbq->ndlp); in lpfc_sli4_seq_abort_rsp_cmpl()
18917 if (rsp_iocbq && rsp_iocbq->iocb.ulpStatus) in lpfc_sli4_seq_abort_rsp_cmpl()
18925 * lpfc_sli4_xri_inrange - check xri is in range of xris owned by driver.
18938 for (i = 0; i < phba->sli4_hba.max_cfg_param.max_xri; i++) { in lpfc_sli4_xri_inrange()
18939 if (xri == phba->sli4_hba.xri_ids[i]) in lpfc_sli4_xri_inrange()
18946 * lpfc_sli4_seq_abort_rsp - bls rsp to sequence abort
18958 struct lpfc_hba *phba = vport->phba; in lpfc_sli4_seq_abort_rsp()
18970 oxid = be16_to_cpu(fc_hdr->fh_ox_id); in lpfc_sli4_seq_abort_rsp()
18971 rxid = be16_to_cpu(fc_hdr->fh_rx_id); in lpfc_sli4_seq_abort_rsp()
18991 icmd = &ctiocb->wqe; in lpfc_sli4_seq_abort_rsp()
18996 ctiocb->ndlp = lpfc_nlp_get(ndlp); in lpfc_sli4_seq_abort_rsp()
18997 if (!ctiocb->ndlp) { in lpfc_sli4_seq_abort_rsp()
19002 ctiocb->vport = vport; in lpfc_sli4_seq_abort_rsp()
19003 ctiocb->cmd_cmpl = lpfc_sli4_seq_abort_rsp_cmpl; in lpfc_sli4_seq_abort_rsp()
19004 ctiocb->sli4_lxritag = NO_XRI; in lpfc_sli4_seq_abort_rsp()
19005 ctiocb->sli4_xritag = NO_XRI; in lpfc_sli4_seq_abort_rsp()
19006 ctiocb->abort_rctl = FC_RCTL_BA_ACC; in lpfc_sli4_seq_abort_rsp()
19026 ctiocb->abort_rctl = FC_RCTL_BA_RJT; in lpfc_sli4_seq_abort_rsp()
19027 bf_set(xmit_bls_rsp64_rjt_vspec, &icmd->xmit_bls_rsp, 0); in lpfc_sli4_seq_abort_rsp()
19028 bf_set(xmit_bls_rsp64_rjt_expc, &icmd->xmit_bls_rsp, in lpfc_sli4_seq_abort_rsp()
19030 bf_set(xmit_bls_rsp64_rjt_rsnc, &icmd->xmit_bls_rsp, in lpfc_sli4_seq_abort_rsp()
19039 ctiocb->abort_rctl = FC_RCTL_BA_RJT; in lpfc_sli4_seq_abort_rsp()
19040 bf_set(xmit_bls_rsp64_rjt_vspec, &icmd->xmit_bls_rsp, 0); in lpfc_sli4_seq_abort_rsp()
19041 bf_set(xmit_bls_rsp64_rjt_expc, &icmd->xmit_bls_rsp, in lpfc_sli4_seq_abort_rsp()
19043 bf_set(xmit_bls_rsp64_rjt_rsnc, &icmd->xmit_bls_rsp, in lpfc_sli4_seq_abort_rsp()
19052 ctiocb->abort_bls = LPFC_ABTS_UNSOL_RSP; in lpfc_sli4_seq_abort_rsp()
19053 bf_set(xmit_bls_rsp64_rxid, &icmd->xmit_bls_rsp, rxid); in lpfc_sli4_seq_abort_rsp()
19059 ctiocb->abort_bls = LPFC_ABTS_UNSOL_INT; in lpfc_sli4_seq_abort_rsp()
19063 bf_set(xmit_bls_rsp64_oxid, &icmd->xmit_bls_rsp, oxid); in lpfc_sli4_seq_abort_rsp()
19064 bf_set(xmit_bls_rsp64_oxid, &icmd->xmit_bls_rsp, rxid); in lpfc_sli4_seq_abort_rsp()
19067 bf_set(wqe_els_did, &icmd->xmit_bls_rsp.wqe_dest, in lpfc_sli4_seq_abort_rsp()
19068 ndlp->nlp_DID); in lpfc_sli4_seq_abort_rsp()
19069 bf_set(xmit_bls_rsp64_temprpi, &icmd->xmit_bls_rsp, in lpfc_sli4_seq_abort_rsp()
19070 phba->sli4_hba.rpi_ids[ndlp->nlp_rpi]); in lpfc_sli4_seq_abort_rsp()
19071 bf_set(wqe_cmnd, &icmd->generic.wqe_com, CMD_XMIT_BLS_RSP64_CX); in lpfc_sli4_seq_abort_rsp()
19076 ctiocb->abort_rctl, oxid, phba->link_state); in lpfc_sli4_seq_abort_rsp()
19083 ctiocb->abort_rctl, oxid, in lpfc_sli4_seq_abort_rsp()
19084 phba->link_state); in lpfc_sli4_seq_abort_rsp()
19086 ctiocb->ndlp = NULL; in lpfc_sli4_seq_abort_rsp()
19093 if (ndlp->nlp_state == NLP_STE_UNUSED_NODE && in lpfc_sli4_seq_abort_rsp()
19094 !test_bit(NLP_DROPPED, &ndlp->nlp_flag) && in lpfc_sli4_seq_abort_rsp()
19095 !(ndlp->fc4_xpt_flags & (NVME_XPT_REGD | SCSI_XPT_REGD))) { in lpfc_sli4_seq_abort_rsp()
19096 set_bit(NLP_DROPPED, &ndlp->nlp_flag); in lpfc_sli4_seq_abort_rsp()
19102 * lpfc_sli4_handle_unsol_abort - Handle sli-4 unsolicited abort event
19106 * This function handles an SLI-4 unsolicited abort event. If the unsolicited
19118 struct lpfc_hba *phba = vport->phba; in lpfc_sli4_handle_unsol_abort()
19124 memcpy(&fc_hdr, dmabuf->hbuf.virt, sizeof(struct fc_frame_header)); in lpfc_sli4_handle_unsol_abort()
19136 lpfc_in_buf_free(phba, &dmabuf->dbuf); in lpfc_sli4_handle_unsol_abort()
19138 if (phba->nvmet_support) { in lpfc_sli4_handle_unsol_abort()
19148 * lpfc_seq_complete - Indicates if a sequence is complete
19168 hdr = (struct fc_frame_header *)dmabuf->hbuf.virt; in lpfc_seq_complete()
19170 if (hdr->fh_seq_cnt != seq_count) in lpfc_seq_complete()
19172 fctl = (hdr->fh_f_ctl[0] << 16 | in lpfc_seq_complete()
19173 hdr->fh_f_ctl[1] << 8 | in lpfc_seq_complete()
19174 hdr->fh_f_ctl[2]); in lpfc_seq_complete()
19178 list_for_each_entry(d_buf, &dmabuf->dbuf.list, list) { in lpfc_seq_complete()
19180 hdr = (struct fc_frame_header *)seq_dmabuf->hbuf.virt; in lpfc_seq_complete()
19182 if (++seq_count != be16_to_cpu(hdr->fh_seq_cnt)) in lpfc_seq_complete()
19184 fctl = (hdr->fh_f_ctl[0] << 16 | in lpfc_seq_complete()
19185 hdr->fh_f_ctl[1] << 8 | in lpfc_seq_complete()
19186 hdr->fh_f_ctl[2]); in lpfc_seq_complete()
19195 * lpfc_prep_seq - Prep sequence for ULP processing
19217 fc_hdr = (struct fc_frame_header *)seq_dmabuf->hbuf.virt; in lpfc_prep_seq()
19219 list_del_init(&seq_dmabuf->hbuf.list); in lpfc_prep_seq()
19225 first_iocbq = lpfc_sli_get_iocbq(vport->phba); in lpfc_prep_seq()
19228 first_iocbq->wcqe_cmpl.total_data_placed = 0; in lpfc_prep_seq()
19229 bf_set(lpfc_wcqe_c_status, &first_iocbq->wcqe_cmpl, in lpfc_prep_seq()
19231 first_iocbq->vport = vport; in lpfc_prep_seq()
19235 bf_set(els_rsp64_sid, &first_iocbq->wqe.xmit_els_rsp, in lpfc_prep_seq()
19239 bf_set(wqe_ctxt_tag, &first_iocbq->wqe.xmit_els_rsp.wqe_com, in lpfc_prep_seq()
19241 bf_set(wqe_rcvoxid, &first_iocbq->wqe.xmit_els_rsp.wqe_com, in lpfc_prep_seq()
19242 be16_to_cpu(fc_hdr->fh_ox_id)); in lpfc_prep_seq()
19246 &seq_dmabuf->cq_event.cqe.rcqe_cmpl); in lpfc_prep_seq()
19248 first_iocbq->cmd_dmabuf = &seq_dmabuf->dbuf; in lpfc_prep_seq()
19249 first_iocbq->bpl_dmabuf = NULL; in lpfc_prep_seq()
19251 first_iocbq->wcqe_cmpl.word3 = 1; in lpfc_prep_seq()
19254 first_iocbq->wqe.gen_req.bde.tus.f.bdeSize = in lpfc_prep_seq()
19257 first_iocbq->wqe.gen_req.bde.tus.f.bdeSize = tot_len; in lpfc_prep_seq()
19259 first_iocbq->wcqe_cmpl.total_data_placed = tot_len; in lpfc_prep_seq()
19260 bf_set(wqe_els_did, &first_iocbq->wqe.xmit_els_rsp.wqe_dest, in lpfc_prep_seq()
19268 list_for_each_entry_safe(d_buf, n_buf, &seq_dmabuf->dbuf.list, list) { in lpfc_prep_seq()
19270 lpfc_in_buf_free(vport->phba, d_buf); in lpfc_prep_seq()
19273 if (!iocbq->bpl_dmabuf) { in lpfc_prep_seq()
19274 iocbq->bpl_dmabuf = d_buf; in lpfc_prep_seq()
19275 iocbq->wcqe_cmpl.word3++; in lpfc_prep_seq()
19279 &hbq_buf->cq_event.cqe.rcqe_cmpl); in lpfc_prep_seq()
19280 iocbq->unsol_rcv_len = len; in lpfc_prep_seq()
19281 iocbq->wcqe_cmpl.total_data_placed += len; in lpfc_prep_seq()
19284 iocbq = lpfc_sli_get_iocbq(vport->phba); in lpfc_prep_seq()
19288 &first_iocbq->wcqe_cmpl, in lpfc_prep_seq()
19290 first_iocbq->wcqe_cmpl.parameter = in lpfc_prep_seq()
19293 lpfc_in_buf_free(vport->phba, d_buf); in lpfc_prep_seq()
19299 &hbq_buf->cq_event.cqe.rcqe_cmpl); in lpfc_prep_seq()
19300 iocbq->cmd_dmabuf = d_buf; in lpfc_prep_seq()
19301 iocbq->bpl_dmabuf = NULL; in lpfc_prep_seq()
19302 iocbq->wcqe_cmpl.word3 = 1; in lpfc_prep_seq()
19305 iocbq->wqe.xmit_els_rsp.bde.tus.f.bdeSize = in lpfc_prep_seq()
19308 iocbq->wqe.xmit_els_rsp.bde.tus.f.bdeSize = in lpfc_prep_seq()
19312 iocbq->wcqe_cmpl.total_data_placed = tot_len; in lpfc_prep_seq()
19313 bf_set(wqe_els_did, &iocbq->wqe.xmit_els_rsp.wqe_dest, in lpfc_prep_seq()
19315 list_add_tail(&iocbq->list, &first_iocbq->list); in lpfc_prep_seq()
19320 lpfc_in_buf_free(vport->phba, &seq_dmabuf->dbuf); in lpfc_prep_seq()
19331 struct lpfc_hba *phba = vport->phba; in lpfc_sli4_send_seq_to_ulp()
19333 fc_hdr = (struct fc_frame_header *)seq_dmabuf->hbuf.virt; in lpfc_sli4_send_seq_to_ulp()
19340 fc_hdr->fh_r_ctl, fc_hdr->fh_type); in lpfc_sli4_send_seq_to_ulp()
19344 phba->sli4_hba.els_wq->pring, in lpfc_sli4_send_seq_to_ulp()
19345 iocbq, fc_hdr->fh_r_ctl, in lpfc_sli4_send_seq_to_ulp()
19346 fc_hdr->fh_type)) { in lpfc_sli4_send_seq_to_ulp()
19351 fc_hdr->fh_r_ctl, fc_hdr->fh_type); in lpfc_sli4_send_seq_to_ulp()
19352 lpfc_in_buf_free(phba, &seq_dmabuf->dbuf); in lpfc_sli4_send_seq_to_ulp()
19357 &iocbq->list, list) { in lpfc_sli4_send_seq_to_ulp()
19358 list_del_init(&curr_iocb->list); in lpfc_sli4_send_seq_to_ulp()
19368 struct lpfc_dmabuf *pcmd = cmdiocb->cmd_dmabuf; in lpfc_sli4_mds_loopback_cmpl()
19370 if (pcmd && pcmd->virt) in lpfc_sli4_mds_loopback_cmpl()
19371 dma_pool_free(phba->lpfc_drb_pool, pcmd->virt, pcmd->phys); in lpfc_sli4_mds_loopback_cmpl()
19382 struct lpfc_hba *phba = vport->phba; in lpfc_sli4_handle_mds_loopback()
19390 fc_hdr = (struct fc_frame_header *)dmabuf->hbuf.virt; in lpfc_sli4_handle_mds_loopback()
19391 frame_len = bf_get(lpfc_rcqe_length, &dmabuf->cq_event.cqe.rcqe_cmpl); in lpfc_sli4_handle_mds_loopback()
19397 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_handle_mds_loopback()
19398 list_add_tail(&dmabuf->cq_event.list, in lpfc_sli4_handle_mds_loopback()
19399 &phba->sli4_hba.sp_queue_event); in lpfc_sli4_handle_mds_loopback()
19400 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_handle_mds_loopback()
19401 set_bit(HBA_SP_QUEUE_EVT, &phba->hba_flag); in lpfc_sli4_handle_mds_loopback()
19409 pcmd->virt = dma_pool_alloc(phba->lpfc_drb_pool, GFP_KERNEL, in lpfc_sli4_handle_mds_loopback()
19410 &pcmd->phys); in lpfc_sli4_handle_mds_loopback()
19411 if (!pcmd || !pcmd->virt) in lpfc_sli4_handle_mds_loopback()
19414 INIT_LIST_HEAD(&pcmd->list); in lpfc_sli4_handle_mds_loopback()
19417 memcpy(pcmd->virt, dmabuf->dbuf.virt, frame_len); in lpfc_sli4_handle_mds_loopback()
19419 iocbq->cmd_dmabuf = pcmd; in lpfc_sli4_handle_mds_loopback()
19420 iocbq->vport = vport; in lpfc_sli4_handle_mds_loopback()
19421 iocbq->cmd_flag &= ~LPFC_FIP_ELS_ID_MASK; in lpfc_sli4_handle_mds_loopback()
19422 iocbq->cmd_flag |= LPFC_USE_FCPWQIDX; in lpfc_sli4_handle_mds_loopback()
19423 iocbq->num_bdes = 0; in lpfc_sli4_handle_mds_loopback()
19425 pwqe = &iocbq->wqe; in lpfc_sli4_handle_mds_loopback()
19427 pwqe->gen_req.bde.addrHigh = putPaddrHigh(pcmd->phys); in lpfc_sli4_handle_mds_loopback()
19428 pwqe->gen_req.bde.addrLow = putPaddrLow(pcmd->phys); in lpfc_sli4_handle_mds_loopback()
19429 pwqe->gen_req.bde.tus.f.bdeSize = frame_len; in lpfc_sli4_handle_mds_loopback()
19430 pwqe->gen_req.bde.tus.f.bdeFlags = BUFF_TYPE_BDE_64; in lpfc_sli4_handle_mds_loopback()
19432 pwqe->send_frame.frame_len = frame_len; in lpfc_sli4_handle_mds_loopback()
19433 pwqe->send_frame.fc_hdr_wd0 = be32_to_cpu(*((__be32 *)fc_hdr)); in lpfc_sli4_handle_mds_loopback()
19434 pwqe->send_frame.fc_hdr_wd1 = be32_to_cpu(*((__be32 *)fc_hdr + 1)); in lpfc_sli4_handle_mds_loopback()
19435 pwqe->send_frame.fc_hdr_wd2 = be32_to_cpu(*((__be32 *)fc_hdr + 2)); in lpfc_sli4_handle_mds_loopback()
19436 pwqe->send_frame.fc_hdr_wd3 = be32_to_cpu(*((__be32 *)fc_hdr + 3)); in lpfc_sli4_handle_mds_loopback()
19437 pwqe->send_frame.fc_hdr_wd4 = be32_to_cpu(*((__be32 *)fc_hdr + 4)); in lpfc_sli4_handle_mds_loopback()
19438 pwqe->send_frame.fc_hdr_wd5 = be32_to_cpu(*((__be32 *)fc_hdr + 5)); in lpfc_sli4_handle_mds_loopback()
19440 pwqe->generic.wqe_com.word7 = 0; in lpfc_sli4_handle_mds_loopback()
19441 pwqe->generic.wqe_com.word10 = 0; in lpfc_sli4_handle_mds_loopback()
19443 bf_set(wqe_cmnd, &pwqe->generic.wqe_com, CMD_SEND_FRAME); in lpfc_sli4_handle_mds_loopback()
19444 bf_set(wqe_sof, &pwqe->generic.wqe_com, 0x2E); /* SOF byte */ in lpfc_sli4_handle_mds_loopback()
19445 bf_set(wqe_eof, &pwqe->generic.wqe_com, 0x41); /* EOF byte */ in lpfc_sli4_handle_mds_loopback()
19446 bf_set(wqe_lenloc, &pwqe->generic.wqe_com, 1); in lpfc_sli4_handle_mds_loopback()
19447 bf_set(wqe_xbl, &pwqe->generic.wqe_com, 1); in lpfc_sli4_handle_mds_loopback()
19448 bf_set(wqe_dbde, &pwqe->generic.wqe_com, 1); in lpfc_sli4_handle_mds_loopback()
19449 bf_set(wqe_xc, &pwqe->generic.wqe_com, 1); in lpfc_sli4_handle_mds_loopback()
19450 bf_set(wqe_cmd_type, &pwqe->generic.wqe_com, 0xA); in lpfc_sli4_handle_mds_loopback()
19451 bf_set(wqe_cqid, &pwqe->generic.wqe_com, LPFC_WQE_CQ_ID_DEFAULT); in lpfc_sli4_handle_mds_loopback()
19452 bf_set(wqe_xri_tag, &pwqe->generic.wqe_com, iocbq->sli4_xritag); in lpfc_sli4_handle_mds_loopback()
19453 bf_set(wqe_reqtag, &pwqe->generic.wqe_com, iocbq->iotag); in lpfc_sli4_handle_mds_loopback()
19454 bf_set(wqe_class, &pwqe->generic.wqe_com, CLASS3); in lpfc_sli4_handle_mds_loopback()
19455 pwqe->generic.wqe_com.abort_tag = iocbq->iotag; in lpfc_sli4_handle_mds_loopback()
19457 iocbq->cmd_cmpl = lpfc_sli4_mds_loopback_cmpl; in lpfc_sli4_handle_mds_loopback()
19463 lpfc_in_buf_free(phba, &dmabuf->dbuf); in lpfc_sli4_handle_mds_loopback()
19469 if (pcmd && pcmd->virt) in lpfc_sli4_handle_mds_loopback()
19470 dma_pool_free(phba->lpfc_drb_pool, pcmd->virt, pcmd->phys); in lpfc_sli4_handle_mds_loopback()
19474 lpfc_in_buf_free(phba, &dmabuf->dbuf); in lpfc_sli4_handle_mds_loopback()
19478 * lpfc_sli4_handle_received_buffer - Handle received buffers from firmware
19500 fc_hdr = (struct fc_frame_header *)dmabuf->hbuf.virt; in lpfc_sli4_handle_received_buffer()
19502 if (fc_hdr->fh_r_ctl == FC_RCTL_MDS_DIAGS || in lpfc_sli4_handle_received_buffer()
19503 fc_hdr->fh_r_ctl == FC_RCTL_DD_UNSOL_DATA) { in lpfc_sli4_handle_received_buffer()
19504 vport = phba->pport; in lpfc_sli4_handle_received_buffer()
19506 if (!test_bit(FC_UNLOADING, &phba->pport->load_flag)) in lpfc_sli4_handle_received_buffer()
19509 lpfc_in_buf_free(phba, &dmabuf->dbuf); in lpfc_sli4_handle_received_buffer()
19515 lpfc_in_buf_free(phba, &dmabuf->dbuf); in lpfc_sli4_handle_received_buffer()
19520 &dmabuf->cq_event.cqe.rcqe_cmpl) == CQE_CODE_RECEIVE_V1)) in lpfc_sli4_handle_received_buffer()
19522 &dmabuf->cq_event.cqe.rcqe_cmpl); in lpfc_sli4_handle_received_buffer()
19525 &dmabuf->cq_event.cqe.rcqe_cmpl); in lpfc_sli4_handle_received_buffer()
19527 if (fc_hdr->fh_r_ctl == 0xF4 && fc_hdr->fh_type == 0xFF) { in lpfc_sli4_handle_received_buffer()
19528 vport = phba->pport; in lpfc_sli4_handle_received_buffer()
19532 &dmabuf->cq_event.cqe.rcqe_cmpl)); in lpfc_sli4_handle_received_buffer()
19544 lpfc_in_buf_free(phba, &dmabuf->dbuf); in lpfc_sli4_handle_received_buffer()
19549 if (!(vport->vpi_state & LPFC_VPI_REGISTERED) && in lpfc_sli4_handle_received_buffer()
19556 if (!test_bit(FC_PT2PT, &vport->fc_flag) || in lpfc_sli4_handle_received_buffer()
19557 phba->link_state == LPFC_HBA_READY) { in lpfc_sli4_handle_received_buffer()
19558 lpfc_in_buf_free(phba, &dmabuf->dbuf); in lpfc_sli4_handle_received_buffer()
19564 if (fc_hdr->fh_r_ctl == FC_RCTL_BA_ABTS) { in lpfc_sli4_handle_received_buffer()
19572 /* unable to add frame to vport - throw it out */ in lpfc_sli4_handle_received_buffer()
19573 lpfc_in_buf_free(phba, &dmabuf->dbuf); in lpfc_sli4_handle_received_buffer()
19585 * lpfc_sli4_post_all_rpi_hdrs - Post the rpi header memory region to the port
19589 * HBA consistent with the SLI-4 interface spec. This routine
19598 * 0 - successful
19599 * -EIO - The mailbox failed to complete successfully.
19613 if (!phba->sli4_hba.rpi_hdrs_in_use) in lpfc_sli4_post_all_rpi_hdrs()
19615 if (phba->sli4_hba.extents_in_use) in lpfc_sli4_post_all_rpi_hdrs()
19616 return -EIO; in lpfc_sli4_post_all_rpi_hdrs()
19618 list_for_each_entry(rpi_page, &phba->sli4_hba.lpfc_rpi_hdr_list, list) { in lpfc_sli4_post_all_rpi_hdrs()
19624 if (bf_get(lpfc_rpi_rsrc_rdy, &phba->sli4_hba.sli4_flags) != in lpfc_sli4_post_all_rpi_hdrs()
19626 rpi_page->start_rpi = phba->sli4_hba.rpi_ids[lrpi]; in lpfc_sli4_post_all_rpi_hdrs()
19633 rc = -EIO; in lpfc_sli4_post_all_rpi_hdrs()
19639 bf_set(lpfc_rpi_rsrc_rdy, &phba->sli4_hba.sli4_flags, in lpfc_sli4_post_all_rpi_hdrs()
19645 * lpfc_sli4_post_rpi_hdr - Post an rpi header memory region to the port
19650 * HBA consistent with the SLI-4 interface spec. This memory region
19654 * 0 - successful
19655 * -ENOMEM - No available memory
19656 * -EIO - The mailbox failed to complete successfully.
19668 if (!phba->sli4_hba.rpi_hdrs_in_use) in lpfc_sli4_post_rpi_hdr()
19670 if (phba->sli4_hba.extents_in_use) in lpfc_sli4_post_rpi_hdr()
19671 return -EIO; in lpfc_sli4_post_rpi_hdr()
19673 /* The port is notified of the header region via a mailbox command. */ in lpfc_sli4_post_rpi_hdr()
19674 mboxq = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_post_rpi_hdr()
19678 "SLI_CONFIG_SPECIAL mailbox command\n"); in lpfc_sli4_post_rpi_hdr()
19679 return -ENOMEM; in lpfc_sli4_post_rpi_hdr()
19683 hdr_tmpl = &mboxq->u.mqe.un.hdr_tmpl; in lpfc_sli4_post_rpi_hdr()
19686 sizeof(struct lpfc_mbx_post_hdr_tmpl) - in lpfc_sli4_post_rpi_hdr()
19693 rpi_page->start_rpi); in lpfc_sli4_post_rpi_hdr()
19695 hdr_tmpl, rpi_page->page_count); in lpfc_sli4_post_rpi_hdr()
19697 hdr_tmpl->rpi_paddr_lo = putPaddrLow(rpi_page->dmabuf->phys); in lpfc_sli4_post_rpi_hdr()
19698 hdr_tmpl->rpi_paddr_hi = putPaddrHigh(rpi_page->dmabuf->phys); in lpfc_sli4_post_rpi_hdr()
19700 shdr = (union lpfc_sli4_cfg_shdr *) &hdr_tmpl->header.cfg_shdr; in lpfc_sli4_post_rpi_hdr()
19701 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_sli4_post_rpi_hdr()
19702 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_sli4_post_rpi_hdr()
19703 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_post_rpi_hdr()
19706 "2514 POST_RPI_HDR mailbox failed with " in lpfc_sli4_post_rpi_hdr()
19709 rc = -ENXIO; in lpfc_sli4_post_rpi_hdr()
19712 * The next_rpi stores the next logical module-64 rpi value used in lpfc_sli4_post_rpi_hdr()
19715 spin_lock_irq(&phba->hbalock); in lpfc_sli4_post_rpi_hdr()
19716 phba->sli4_hba.next_rpi = rpi_page->next_rpi; in lpfc_sli4_post_rpi_hdr()
19717 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_post_rpi_hdr()
19723 * lpfc_sli4_alloc_rpi - Get an available rpi in the device's range
19727 * HBA consistent with the SLI-4 interface spec. This routine
19748 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli4_alloc_rpi()
19749 max_rpi = phba->sli4_hba.max_cfg_param.max_rpi; in lpfc_sli4_alloc_rpi()
19750 rpi_limit = phba->sli4_hba.next_rpi; in lpfc_sli4_alloc_rpi()
19752 rpi = find_first_zero_bit(phba->sli4_hba.rpi_bmask, rpi_limit); in lpfc_sli4_alloc_rpi()
19756 set_bit(rpi, phba->sli4_hba.rpi_bmask); in lpfc_sli4_alloc_rpi()
19757 phba->sli4_hba.max_cfg_param.rpi_used++; in lpfc_sli4_alloc_rpi()
19758 phba->sli4_hba.rpi_count++; in lpfc_sli4_alloc_rpi()
19770 (phba->sli4_hba.rpi_count >= max_rpi)) { in lpfc_sli4_alloc_rpi()
19771 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli4_alloc_rpi()
19779 if (!phba->sli4_hba.rpi_hdrs_in_use) { in lpfc_sli4_alloc_rpi()
19780 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli4_alloc_rpi()
19790 rpi_remaining = phba->sli4_hba.next_rpi - phba->sli4_hba.rpi_count; in lpfc_sli4_alloc_rpi()
19791 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli4_alloc_rpi()
19799 lrpi = rpi_hdr->start_rpi; in lpfc_sli4_alloc_rpi()
19800 rpi_hdr->start_rpi = phba->sli4_hba.rpi_ids[lrpi]; in lpfc_sli4_alloc_rpi()
19809 * __lpfc_sli4_free_rpi - Release an rpi for reuse.
19826 if (test_and_clear_bit(rpi, phba->sli4_hba.rpi_bmask)) { in __lpfc_sli4_free_rpi()
19827 phba->sli4_hba.rpi_count--; in __lpfc_sli4_free_rpi()
19828 phba->sli4_hba.max_cfg_param.rpi_used--; in __lpfc_sli4_free_rpi()
19838 * lpfc_sli4_free_rpi - Release an rpi for reuse.
19848 spin_lock_irq(&phba->hbalock); in lpfc_sli4_free_rpi()
19850 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_free_rpi()
19854 * lpfc_sli4_remove_rpis - Remove the rpi bitmask region
19863 kfree(phba->sli4_hba.rpi_bmask); in lpfc_sli4_remove_rpis()
19864 kfree(phba->sli4_hba.rpi_ids); in lpfc_sli4_remove_rpis()
19865 bf_set(lpfc_rpi_rsrc_rdy, &phba->sli4_hba.sli4_flags, 0); in lpfc_sli4_remove_rpis()
19869 * lpfc_sli4_resume_rpi - Remove the rpi bitmask region
19871 * @cmpl: completion call-back.
19883 struct lpfc_hba *phba = ndlp->phba; in lpfc_sli4_resume_rpi()
19886 /* The port is notified of the header region via a mailbox command. */ in lpfc_sli4_resume_rpi()
19887 mboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_resume_rpi()
19889 return -ENOMEM; in lpfc_sli4_resume_rpi()
19901 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_resume_rpi()
19902 return -EIO; in lpfc_sli4_resume_rpi()
19908 mboxq->mbox_cmpl = cmpl; in lpfc_sli4_resume_rpi()
19909 mboxq->ctx_u.save_iocb = iocbq; in lpfc_sli4_resume_rpi()
19911 mboxq->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_sli4_resume_rpi()
19912 mboxq->ctx_ndlp = ndlp; in lpfc_sli4_resume_rpi()
19913 mboxq->vport = ndlp->vport; in lpfc_sli4_resume_rpi()
19917 "2010 Resume RPI Mailbox failed " in lpfc_sli4_resume_rpi()
19919 bf_get(lpfc_mqe_status, &mboxq->u.mqe)); in lpfc_sli4_resume_rpi()
19921 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_resume_rpi()
19922 return -EIO; in lpfc_sli4_resume_rpi()
19928 * lpfc_sli4_init_vpi - Initialize a vpi with the port
19935 * -Evalue otherwise
19944 struct lpfc_hba *phba = vport->phba; in lpfc_sli4_init_vpi()
19945 mboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_init_vpi()
19947 return -ENOMEM; in lpfc_sli4_init_vpi()
19948 lpfc_init_vpi(phba, mboxq, vport->vpi); in lpfc_sli4_init_vpi()
19953 "2022 INIT VPI Mailbox failed " in lpfc_sli4_init_vpi()
19955 bf_get(lpfc_mqe_status, &mboxq->u.mqe)); in lpfc_sli4_init_vpi()
19956 retval = -EIO; in lpfc_sli4_init_vpi()
19959 mempool_free(mboxq, vport->phba->mbox_mem_pool); in lpfc_sli4_init_vpi()
19965 * lpfc_mbx_cmpl_add_fcf_record - add fcf mbox completion handler.
19967 * @mboxq: Pointer to mailbox object.
19971 * care of the nonembedded mailbox operations.
19980 virt_addr = mboxq->sge_array->addr[0]; in lpfc_mbx_cmpl_add_fcf_record()
19981 /* The IOCTL status is embedded in the mailbox subheader. */ in lpfc_mbx_cmpl_add_fcf_record()
19983 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_mbx_cmpl_add_fcf_record()
19984 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_mbx_cmpl_add_fcf_record()
19989 "2558 ADD_FCF_RECORD mailbox failed with " in lpfc_mbx_cmpl_add_fcf_record()
19997 * lpfc_sli4_add_fcf_record - Manually add an FCF Record.
20003 * care of the nonembedded mailbox operations.
20016 mboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_add_fcf_record()
20020 return -ENOMEM; in lpfc_sli4_add_fcf_record()
20026 /* Allocate DMA memory and set up the non-embedded mailbox command */ in lpfc_sli4_add_fcf_record()
20036 return -ENOMEM; in lpfc_sli4_add_fcf_record()
20040 * Get the first SGE entry from the non-embedded DMA memory. This in lpfc_sli4_add_fcf_record()
20044 virt_addr = mboxq->sge_array->addr[0]; in lpfc_sli4_add_fcf_record()
20060 mboxq->vport = phba->pport; in lpfc_sli4_add_fcf_record()
20061 mboxq->mbox_cmpl = lpfc_mbx_cmpl_add_fcf_record; in lpfc_sli4_add_fcf_record()
20065 "2515 ADD_FCF_RECORD mailbox failed with " in lpfc_sli4_add_fcf_record()
20068 rc = -EIO; in lpfc_sli4_add_fcf_record()
20076 * lpfc_sli4_build_dflt_fcf_record - Build the driver's default FCF Record.
20091 fcf_record->max_rcv_size = LPFC_FCOE_MAX_RCV_SIZE; in lpfc_sli4_build_dflt_fcf_record()
20092 fcf_record->fka_adv_period = LPFC_FCOE_FKA_ADV_PER; in lpfc_sli4_build_dflt_fcf_record()
20093 fcf_record->fip_priority = LPFC_FCOE_FIP_PRIORITY; in lpfc_sli4_build_dflt_fcf_record()
20094 bf_set(lpfc_fcf_record_mac_0, fcf_record, phba->fc_map[0]); in lpfc_sli4_build_dflt_fcf_record()
20095 bf_set(lpfc_fcf_record_mac_1, fcf_record, phba->fc_map[1]); in lpfc_sli4_build_dflt_fcf_record()
20096 bf_set(lpfc_fcf_record_mac_2, fcf_record, phba->fc_map[2]); in lpfc_sli4_build_dflt_fcf_record()
20100 bf_set(lpfc_fcf_record_fc_map_0, fcf_record, phba->fc_map[0]); in lpfc_sli4_build_dflt_fcf_record()
20101 bf_set(lpfc_fcf_record_fc_map_1, fcf_record, phba->fc_map[1]); in lpfc_sli4_build_dflt_fcf_record()
20102 bf_set(lpfc_fcf_record_fc_map_2, fcf_record, phba->fc_map[2]); in lpfc_sli4_build_dflt_fcf_record()
20109 if (phba->valid_vlan) { in lpfc_sli4_build_dflt_fcf_record()
20110 fcf_record->vlan_bitmap[phba->vlan_id / 8] in lpfc_sli4_build_dflt_fcf_record()
20111 = 1 << (phba->vlan_id % 8); in lpfc_sli4_build_dflt_fcf_record()
20116 * lpfc_sli4_fcf_scan_read_fcf_rec - Read hba fcf record for fcf scan.
20124 * Return 0 if the mailbox command is submitted successfully, none 0
20133 phba->fcoe_eventtag_at_fcf_scan = phba->fcoe_eventtag; in lpfc_sli4_fcf_scan_read_fcf_rec()
20134 phba->fcoe_cvl_eventtag_attn = phba->fcoe_cvl_eventtag; in lpfc_sli4_fcf_scan_read_fcf_rec()
20135 mboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_fcf_scan_read_fcf_rec()
20140 error = -ENOMEM; in lpfc_sli4_fcf_scan_read_fcf_rec()
20143 /* Construct the read FCF record mailbox command */ in lpfc_sli4_fcf_scan_read_fcf_rec()
20146 error = -EINVAL; in lpfc_sli4_fcf_scan_read_fcf_rec()
20149 /* Issue the mailbox command asynchronously */ in lpfc_sli4_fcf_scan_read_fcf_rec()
20150 mboxq->vport = phba->pport; in lpfc_sli4_fcf_scan_read_fcf_rec()
20151 mboxq->mbox_cmpl = lpfc_mbx_cmpl_fcf_scan_read_fcf_rec; in lpfc_sli4_fcf_scan_read_fcf_rec()
20153 set_bit(FCF_TS_INPROG, &phba->hba_flag); in lpfc_sli4_fcf_scan_read_fcf_rec()
20157 error = -EIO; in lpfc_sli4_fcf_scan_read_fcf_rec()
20161 phba->fcf.eligible_fcf_cnt = 0; in lpfc_sli4_fcf_scan_read_fcf_rec()
20169 clear_bit(FCF_TS_INPROG, &phba->hba_flag); in lpfc_sli4_fcf_scan_read_fcf_rec()
20175 * lpfc_sli4_fcf_rr_read_fcf_rec - Read hba fcf record for roundrobin fcf.
20182 * Return 0 if the mailbox command is submitted successfully, none 0
20191 mboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_fcf_rr_read_fcf_rec()
20196 error = -ENOMEM; in lpfc_sli4_fcf_rr_read_fcf_rec()
20199 /* Construct the read FCF record mailbox command */ in lpfc_sli4_fcf_rr_read_fcf_rec()
20202 error = -EINVAL; in lpfc_sli4_fcf_rr_read_fcf_rec()
20205 /* Issue the mailbox command asynchronously */ in lpfc_sli4_fcf_rr_read_fcf_rec()
20206 mboxq->vport = phba->pport; in lpfc_sli4_fcf_rr_read_fcf_rec()
20207 mboxq->mbox_cmpl = lpfc_mbx_cmpl_fcf_rr_read_fcf_rec; in lpfc_sli4_fcf_rr_read_fcf_rec()
20210 error = -EIO; in lpfc_sli4_fcf_rr_read_fcf_rec()
20221 * lpfc_sli4_read_fcf_rec - Read hba fcf record for update eligible fcf bmask.
20228 * Return 0 if the mailbox command is submitted successfully, none 0
20237 mboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_read_fcf_rec()
20242 error = -ENOMEM; in lpfc_sli4_read_fcf_rec()
20245 /* Construct the read FCF record mailbox command */ in lpfc_sli4_read_fcf_rec()
20248 error = -EINVAL; in lpfc_sli4_read_fcf_rec()
20251 /* Issue the mailbox command asynchronously */ in lpfc_sli4_read_fcf_rec()
20252 mboxq->vport = phba->pport; in lpfc_sli4_read_fcf_rec()
20253 mboxq->mbox_cmpl = lpfc_mbx_cmpl_read_fcf_rec; in lpfc_sli4_read_fcf_rec()
20256 error = -EIO; in lpfc_sli4_read_fcf_rec()
20288 last_index = find_first_bit(phba->fcf.fcf_rr_bmask, in lpfc_check_next_fcf_pri_level()
20294 spin_lock_irq(&phba->hbalock); in lpfc_check_next_fcf_pri_level()
20295 if (list_empty(&phba->fcf.fcf_pri_list) || in lpfc_check_next_fcf_pri_level()
20296 list_is_singular(&phba->fcf.fcf_pri_list)) { in lpfc_check_next_fcf_pri_level()
20297 spin_unlock_irq(&phba->hbalock); in lpfc_check_next_fcf_pri_level()
20302 spin_unlock_irq(&phba->hbalock); in lpfc_check_next_fcf_pri_level()
20309 memset(phba->fcf.fcf_rr_bmask, 0, in lpfc_check_next_fcf_pri_level()
20310 sizeof(*phba->fcf.fcf_rr_bmask)); in lpfc_check_next_fcf_pri_level()
20311 spin_lock_irq(&phba->hbalock); in lpfc_check_next_fcf_pri_level()
20312 list_for_each_entry(fcf_pri, &phba->fcf.fcf_pri_list, list) { in lpfc_check_next_fcf_pri_level()
20313 if (fcf_pri->fcf_rec.flag & LPFC_FCF_FLOGI_FAILED) in lpfc_check_next_fcf_pri_level()
20320 next_fcf_pri = fcf_pri->fcf_rec.priority; in lpfc_check_next_fcf_pri_level()
20321 spin_unlock_irq(&phba->hbalock); in lpfc_check_next_fcf_pri_level()
20322 if (fcf_pri->fcf_rec.priority == next_fcf_pri) { in lpfc_check_next_fcf_pri_level()
20324 fcf_pri->fcf_rec.fcf_index); in lpfc_check_next_fcf_pri_level()
20328 spin_lock_irq(&phba->hbalock); in lpfc_check_next_fcf_pri_level()
20335 if (!next_fcf_pri && !list_empty(&phba->fcf.fcf_pri_list)) { in lpfc_check_next_fcf_pri_level()
20336 list_for_each_entry(fcf_pri, &phba->fcf.fcf_pri_list, list) { in lpfc_check_next_fcf_pri_level()
20337 fcf_pri->fcf_rec.flag &= ~LPFC_FCF_FLOGI_FAILED; in lpfc_check_next_fcf_pri_level()
20343 next_fcf_pri = fcf_pri->fcf_rec.priority; in lpfc_check_next_fcf_pri_level()
20344 spin_unlock_irq(&phba->hbalock); in lpfc_check_next_fcf_pri_level()
20345 if (fcf_pri->fcf_rec.priority == next_fcf_pri) { in lpfc_check_next_fcf_pri_level()
20347 fcf_pri->fcf_rec.fcf_index); in lpfc_check_next_fcf_pri_level()
20351 spin_lock_irq(&phba->hbalock); in lpfc_check_next_fcf_pri_level()
20355 spin_unlock_irq(&phba->hbalock); in lpfc_check_next_fcf_pri_level()
20360 * lpfc_sli4_fcf_rr_next_index_get - Get next eligible fcf record index
20376 next_fcf_index = phba->fcf.current_rec.fcf_indx; in lpfc_sli4_fcf_rr_next_index_get()
20381 next_fcf_index = find_next_bit(phba->fcf.fcf_rr_bmask, in lpfc_sli4_fcf_rr_next_index_get()
20385 /* Wrap around condition on phba->fcf.fcf_rr_bmask */ in lpfc_sli4_fcf_rr_next_index_get()
20392 next_fcf_index = find_first_bit(phba->fcf.fcf_rr_bmask, in lpfc_sli4_fcf_rr_next_index_get()
20399 next_fcf_index == phba->fcf.current_rec.fcf_indx) { in lpfc_sli4_fcf_rr_next_index_get()
20415 phba->fcf.fcf_pri[next_fcf_index].fcf_rec.flag & in lpfc_sli4_fcf_rr_next_index_get()
20417 if (list_is_singular(&phba->fcf.fcf_pri_list)) in lpfc_sli4_fcf_rr_next_index_get()
20431 * lpfc_sli4_fcf_rr_index_set - Set bmask with eligible fcf record index
20441 * -EINVAL.
20451 return -EINVAL; in lpfc_sli4_fcf_rr_index_set()
20454 set_bit(fcf_index, phba->fcf.fcf_rr_bmask); in lpfc_sli4_fcf_rr_index_set()
20464 * lpfc_sli4_fcf_rr_index_clear - Clear bmask from eligible fcf record index
20485 spin_lock_irq(&phba->hbalock); in lpfc_sli4_fcf_rr_index_clear()
20486 list_for_each_entry_safe(fcf_pri, fcf_pri_next, &phba->fcf.fcf_pri_list, in lpfc_sli4_fcf_rr_index_clear()
20488 if (fcf_pri->fcf_rec.fcf_index == fcf_index) { in lpfc_sli4_fcf_rr_index_clear()
20489 list_del_init(&fcf_pri->list); in lpfc_sli4_fcf_rr_index_clear()
20493 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_fcf_rr_index_clear()
20494 clear_bit(fcf_index, phba->fcf.fcf_rr_bmask); in lpfc_sli4_fcf_rr_index_clear()
20502 * lpfc_mbx_cmpl_redisc_fcf_table - completion routine for rediscover FCF table
20506 * This routine is the completion routine for the rediscover FCF table mailbox
20507 * command. If the mailbox command returned failure, it will try to stop the
20516 redisc_fcf = &mbox->u.mqe.un.redisc_fcf_tbl; in lpfc_mbx_cmpl_redisc_fcf_table()
20519 &redisc_fcf->header.cfg_shdr.response); in lpfc_mbx_cmpl_redisc_fcf_table()
20521 &redisc_fcf->header.cfg_shdr.response); in lpfc_mbx_cmpl_redisc_fcf_table()
20527 if (phba->fcf.fcf_flag & FCF_ACVL_DISC) { in lpfc_mbx_cmpl_redisc_fcf_table()
20528 spin_lock_irq(&phba->hbalock); in lpfc_mbx_cmpl_redisc_fcf_table()
20529 phba->fcf.fcf_flag &= ~FCF_ACVL_DISC; in lpfc_mbx_cmpl_redisc_fcf_table()
20530 spin_unlock_irq(&phba->hbalock); in lpfc_mbx_cmpl_redisc_fcf_table()
20533 * last resort to re-try current registered FCF entry. in lpfc_mbx_cmpl_redisc_fcf_table()
20537 spin_lock_irq(&phba->hbalock); in lpfc_mbx_cmpl_redisc_fcf_table()
20538 phba->fcf.fcf_flag &= ~FCF_DEAD_DISC; in lpfc_mbx_cmpl_redisc_fcf_table()
20539 spin_unlock_irq(&phba->hbalock); in lpfc_mbx_cmpl_redisc_fcf_table()
20557 mempool_free(mbox, phba->mbox_mem_pool); in lpfc_mbx_cmpl_redisc_fcf_table()
20561 * lpfc_sli4_redisc_fcf_table - Request to rediscover entire FCF table by port.
20577 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_redisc_fcf_table()
20582 return -ENOMEM; in lpfc_sli4_redisc_fcf_table()
20585 length = (sizeof(struct lpfc_mbx_redisc_fcf_tbl) - in lpfc_sli4_redisc_fcf_table()
20591 redisc_fcf = &mbox->u.mqe.un.redisc_fcf_tbl; in lpfc_sli4_redisc_fcf_table()
20595 /* Issue the mailbox command asynchronously */ in lpfc_sli4_redisc_fcf_table()
20596 mbox->vport = phba->pport; in lpfc_sli4_redisc_fcf_table()
20597 mbox->mbox_cmpl = lpfc_mbx_cmpl_redisc_fcf_table; in lpfc_sli4_redisc_fcf_table()
20601 mempool_free(mbox, phba->mbox_mem_pool); in lpfc_sli4_redisc_fcf_table()
20602 return -EIO; in lpfc_sli4_redisc_fcf_table()
20608 * lpfc_sli4_fcf_dead_failthrough - Failthrough routine to fcf dead event
20624 link_state = phba->link_state; in lpfc_sli4_fcf_dead_failthrough()
20626 phba->link_state = link_state; in lpfc_sli4_fcf_dead_failthrough()
20633 * lpfc_sli_get_config_region23 - Get sli3 port region 23 data.
20638 * mailbox command. When it successfully retrieves data, the size of the data
20652 pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli_get_config_region23()
20655 "2600 failed to allocate mailbox memory\n"); in lpfc_sli_get_config_region23()
20658 mb = &pmb->u.mb; in lpfc_sli_get_config_region23()
20668 rc, mb->mbxStatus); in lpfc_sli_get_config_region23()
20669 mb->un.varDmp.word_cnt = 0; in lpfc_sli_get_config_region23()
20673 * mailbox error, either way we are done. in lpfc_sli_get_config_region23()
20675 if (mb->un.varDmp.word_cnt == 0) in lpfc_sli_get_config_region23()
20678 if (mb->un.varDmp.word_cnt > DMP_RGN23_SIZE - offset) in lpfc_sli_get_config_region23()
20679 mb->un.varDmp.word_cnt = DMP_RGN23_SIZE - offset; in lpfc_sli_get_config_region23()
20683 mb->un.varDmp.word_cnt); in lpfc_sli_get_config_region23()
20684 offset += mb->un.varDmp.word_cnt; in lpfc_sli_get_config_region23()
20685 } while (mb->un.varDmp.word_cnt && offset < DMP_RGN23_SIZE); in lpfc_sli_get_config_region23()
20687 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_sli_get_config_region23()
20692 * lpfc_sli4_get_config_region23 - Get sli4 port region 23 data.
20697 * mailbox command. When it successfully retrieves data, the size of the data
20712 mboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_get_config_region23()
20715 "3105 failed to allocate mailbox memory\n"); in lpfc_sli4_get_config_region23()
20721 mqe = &mboxq->u.mqe; in lpfc_sli4_get_config_region23()
20722 mp = mboxq->ctx_buf; in lpfc_sli4_get_config_region23()
20726 data_length = mqe->un.mb_words[5]; in lpfc_sli4_get_config_region23()
20733 lpfc_sli_pcimem_bcopy((char *)mp->virt, rgn23_data, data_length); in lpfc_sli4_get_config_region23()
20740 * lpfc_sli_read_link_ste - Read region 23 to decide if link is disabled.
20759 if (phba->sli_rev < LPFC_SLI_REV4) in lpfc_sli_read_link_ste()
20763 &phba->sli4_hba.sli_intf); in lpfc_sli_read_link_ste()
20809 * Search for configured port state sub-TLV. in lpfc_sli_read_link_ste()
20826 set_bit(LINK_DISABLED, &phba->hba_flag); in lpfc_sli_read_link_ste()
20838 * lpfc_log_fw_write_cmpl - logs firmware write completion status
20859 phba->sli4_hba.flash_id, phba->sli4_hba.asic_rev, in lpfc_log_fw_write_cmpl()
20869 phba->sli4_hba.flash_id); in lpfc_log_fw_write_cmpl()
20876 phba->sli4_hba.asic_rev); in lpfc_log_fw_write_cmpl()
20923 * lpfc_wr_object - write an object to the firmware
20929 * This routine will create a wr_object mailbox command to send to the port.
20930 * the mailbox command will be constructed using the dma buffers described in
20932 * BDEs that the imbedded mailbox can support. The @offset variable will be
20934 * the offset after the write object mailbox has completed. @size is used to
20956 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_wr_object()
20958 return -ENOMEM; in lpfc_wr_object()
20962 sizeof(struct lpfc_mbx_wr_object) - in lpfc_wr_object()
20965 wr_object = (struct lpfc_mbx_wr_object *)&mbox->u.mqe.un.wr_object; in lpfc_wr_object()
20966 wr_object->u.request.write_offset = *offset; in lpfc_wr_object()
20967 sprintf((uint8_t *)wr_object->u.request.object_name, "/"); in lpfc_wr_object()
20968 wr_object->u.request.object_name[0] = in lpfc_wr_object()
20969 cpu_to_le32(wr_object->u.request.object_name[0]); in lpfc_wr_object()
20970 bf_set(lpfc_wr_object_eof, &wr_object->u.request, 0); in lpfc_wr_object()
20974 wr_object->u.request.bde[i].addrLow = putPaddrLow(dmabuf->phys); in lpfc_wr_object()
20975 wr_object->u.request.bde[i].addrHigh = in lpfc_wr_object()
20976 putPaddrHigh(dmabuf->phys); in lpfc_wr_object()
20978 wr_object->u.request.bde[i].tus.f.bdeSize = in lpfc_wr_object()
20979 (size - written); in lpfc_wr_object()
20980 written += (size - written); in lpfc_wr_object()
20981 bf_set(lpfc_wr_object_eof, &wr_object->u.request, 1); in lpfc_wr_object()
20982 bf_set(lpfc_wr_object_eas, &wr_object->u.request, 1); in lpfc_wr_object()
20985 wr_object->u.request.bde[i].tus.f.bdeSize = in lpfc_wr_object()
20991 wr_object->u.request.bde_count = i; in lpfc_wr_object()
20992 bf_set(lpfc_wr_object_write_length, &wr_object->u.request, written); in lpfc_wr_object()
20993 if (!phba->sli4_hba.intr_enable) in lpfc_wr_object()
21003 /* The IOCTL status is embedded in the mailbox subheader. */ in lpfc_wr_object()
21005 &wr_object->header.cfg_shdr.response); in lpfc_wr_object()
21007 &wr_object->header.cfg_shdr.response); in lpfc_wr_object()
21009 &wr_object->header.cfg_shdr.response); in lpfc_wr_object()
21012 &wr_object->u.response); in lpfc_wr_object()
21014 &wr_object->u.response); in lpfc_wr_object()
21019 "3025 Write Object mailbox failed with " in lpfc_wr_object()
21024 rc = -ENXIO; in lpfc_wr_object()
21027 *offset += wr_object->u.response.actual_write_length; in lpfc_wr_object()
21035 if (!phba->sli4_hba.intr_enable) in lpfc_wr_object()
21036 mempool_free(mbox, phba->mbox_mem_pool); in lpfc_wr_object()
21038 mempool_free(mbox, phba->mbox_mem_pool); in lpfc_wr_object()
21044 * lpfc_cleanup_pending_mbox - Free up vport discovery mailbox commands.
21048 * and REG_VPI mailbox commands associated with the vport. This function
21055 struct lpfc_hba *phba = vport->phba; in lpfc_cleanup_pending_mbox()
21062 /* Clean up internally queued mailbox commands with the vport */ in lpfc_cleanup_pending_mbox()
21063 spin_lock_irq(&phba->hbalock); in lpfc_cleanup_pending_mbox()
21064 list_for_each_entry_safe(mb, nextmb, &phba->sli.mboxq, list) { in lpfc_cleanup_pending_mbox()
21065 if (mb->vport != vport) in lpfc_cleanup_pending_mbox()
21068 if ((mb->u.mb.mbxCommand != MBX_REG_LOGIN64) && in lpfc_cleanup_pending_mbox()
21069 (mb->u.mb.mbxCommand != MBX_REG_VPI)) in lpfc_cleanup_pending_mbox()
21072 list_move_tail(&mb->list, &mbox_cmd_list); in lpfc_cleanup_pending_mbox()
21074 /* Clean up active mailbox command with the vport */ in lpfc_cleanup_pending_mbox()
21075 mb = phba->sli.mbox_active; in lpfc_cleanup_pending_mbox()
21076 if (mb && (mb->vport == vport)) { in lpfc_cleanup_pending_mbox()
21077 if ((mb->u.mb.mbxCommand == MBX_REG_LOGIN64) || in lpfc_cleanup_pending_mbox()
21078 (mb->u.mb.mbxCommand == MBX_REG_VPI)) in lpfc_cleanup_pending_mbox()
21079 mb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_cleanup_pending_mbox()
21080 if (mb->u.mb.mbxCommand == MBX_REG_LOGIN64) { in lpfc_cleanup_pending_mbox()
21081 act_mbx_ndlp = mb->ctx_ndlp; in lpfc_cleanup_pending_mbox()
21088 /* Unregister the RPI when mailbox complete */ in lpfc_cleanup_pending_mbox()
21089 mb->mbox_flag |= LPFC_MBX_IMED_UNREG; in lpfc_cleanup_pending_mbox()
21092 /* Cleanup any mailbox completions which are not yet processed */ in lpfc_cleanup_pending_mbox()
21095 list_for_each_entry(mb, &phba->sli.mboxq_cmpl, list) { in lpfc_cleanup_pending_mbox()
21100 if ((mb->vport != vport) || in lpfc_cleanup_pending_mbox()
21101 (mb->mbox_flag & LPFC_MBX_IMED_UNREG)) in lpfc_cleanup_pending_mbox()
21104 if ((mb->u.mb.mbxCommand != MBX_REG_LOGIN64) && in lpfc_cleanup_pending_mbox()
21105 (mb->u.mb.mbxCommand != MBX_REG_VPI)) in lpfc_cleanup_pending_mbox()
21108 mb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_cleanup_pending_mbox()
21109 if (mb->u.mb.mbxCommand == MBX_REG_LOGIN64) { in lpfc_cleanup_pending_mbox()
21110 ndlp = mb->ctx_ndlp; in lpfc_cleanup_pending_mbox()
21111 /* Unregister the RPI when mailbox complete */ in lpfc_cleanup_pending_mbox()
21112 mb->mbox_flag |= LPFC_MBX_IMED_UNREG; in lpfc_cleanup_pending_mbox()
21114 clear_bit(NLP_IGNR_REG_CMPL, &ndlp->nlp_flag); in lpfc_cleanup_pending_mbox()
21120 spin_unlock_irq(&phba->hbalock); in lpfc_cleanup_pending_mbox()
21122 /* Release the cleaned-up mailbox commands */ in lpfc_cleanup_pending_mbox()
21125 if (mb->u.mb.mbxCommand == MBX_REG_LOGIN64) { in lpfc_cleanup_pending_mbox()
21126 ndlp = mb->ctx_ndlp; in lpfc_cleanup_pending_mbox()
21127 mb->ctx_ndlp = NULL; in lpfc_cleanup_pending_mbox()
21129 clear_bit(NLP_IGNR_REG_CMPL, &ndlp->nlp_flag); in lpfc_cleanup_pending_mbox()
21136 /* Release the ndlp with the cleaned-up active mailbox command */ in lpfc_cleanup_pending_mbox()
21138 clear_bit(NLP_IGNR_REG_CMPL, &act_mbx_ndlp->nlp_flag); in lpfc_cleanup_pending_mbox()
21144 * lpfc_drain_txq - Drain the txq
21166 if (phba->link_flag & LS_MDS_LOOPBACK) { in lpfc_drain_txq()
21168 wq = phba->sli4_hba.hdwq[0].io_wq; in lpfc_drain_txq()
21171 pring = wq->pring; in lpfc_drain_txq()
21173 wq = phba->sli4_hba.els_wq; in lpfc_drain_txq()
21179 if (unlikely(!pring) || list_empty(&pring->txq)) in lpfc_drain_txq()
21182 spin_lock_irqsave(&pring->ring_lock, iflags); in lpfc_drain_txq()
21183 list_for_each_entry(piocbq, &pring->txq, list) { in lpfc_drain_txq()
21187 if (txq_cnt > pring->txq_max) in lpfc_drain_txq()
21188 pring->txq_max = txq_cnt; in lpfc_drain_txq()
21190 spin_unlock_irqrestore(&pring->ring_lock, iflags); in lpfc_drain_txq()
21192 while (!list_empty(&pring->txq)) { in lpfc_drain_txq()
21193 spin_lock_irqsave(&pring->ring_lock, iflags); in lpfc_drain_txq()
21197 spin_unlock_irqrestore(&pring->ring_lock, iflags); in lpfc_drain_txq()
21203 txq_cnt--; in lpfc_drain_txq()
21205 ret = __lpfc_sli_issue_iocb(phba, pring->ringno, piocbq, 0); in lpfc_drain_txq()
21208 fail_msg = " - Cannot send IO "; in lpfc_drain_txq()
21209 piocbq->cmd_flag &= ~LPFC_DRIVER_ABORTED; in lpfc_drain_txq()
21212 piocbq->cmd_flag |= LPFC_DRIVER_ABORTED; in lpfc_drain_txq()
21217 fail_msg, piocbq->iotag, in lpfc_drain_txq()
21218 piocbq->sli4_xritag, ret, in lpfc_drain_txq()
21219 piocbq->cmd_flag); in lpfc_drain_txq()
21220 list_add_tail(&piocbq->list, &completions); in lpfc_drain_txq()
21223 spin_unlock_irqrestore(&pring->ring_lock, iflags); in lpfc_drain_txq()
21235 * lpfc_wqe_bpl2sgl - Convert the bpl/bde to a sgl.
21270 sgl = (struct sli4_sge *)sglq->sgl; in lpfc_wqe_bpl2sgl()
21271 wqe = &pwqeq->wqe; in lpfc_wqe_bpl2sgl()
21272 pwqeq->iocb.ulpIoTag = pwqeq->iotag; in lpfc_wqe_bpl2sgl()
21274 cmd = bf_get(wqe_cmnd, &wqe->generic.wqe_com); in lpfc_wqe_bpl2sgl()
21276 return sglq->sli4_xritag; in lpfc_wqe_bpl2sgl()
21277 numBdes = pwqeq->num_bdes; in lpfc_wqe_bpl2sgl()
21283 if (pwqeq->bpl_dmabuf) in lpfc_wqe_bpl2sgl()
21284 dmabuf = pwqeq->bpl_dmabuf; in lpfc_wqe_bpl2sgl()
21288 bpl = (struct ulp_bde64 *)dmabuf->virt; in lpfc_wqe_bpl2sgl()
21294 sgl->addr_hi = bpl->addrHigh; in lpfc_wqe_bpl2sgl()
21295 sgl->addr_lo = bpl->addrLow; in lpfc_wqe_bpl2sgl()
21297 sgl->word2 = le32_to_cpu(sgl->word2); in lpfc_wqe_bpl2sgl()
21305 bde.tus.w = le32_to_cpu(bpl->tus.w); in lpfc_wqe_bpl2sgl()
21306 sgl->sge_len = cpu_to_le32(bde.tus.f.bdeSize); in lpfc_wqe_bpl2sgl()
21314 if (bpl->tus.f.bdeFlags == BUFF_TYPE_BDE_64I) in lpfc_wqe_bpl2sgl()
21332 bpl->tus.f.bdeFlags); in lpfc_wqe_bpl2sgl()
21340 sgl->word2 = cpu_to_le32(sgl->word2); in lpfc_wqe_bpl2sgl()
21344 } else if (wqe->gen_req.bde.tus.f.bdeFlags == BUFF_TYPE_BDE_64) { in lpfc_wqe_bpl2sgl()
21349 sgl->addr_hi = cpu_to_le32(wqe->gen_req.bde.addrHigh); in lpfc_wqe_bpl2sgl()
21350 sgl->addr_lo = cpu_to_le32(wqe->gen_req.bde.addrLow); in lpfc_wqe_bpl2sgl()
21351 sgl->word2 = le32_to_cpu(sgl->word2); in lpfc_wqe_bpl2sgl()
21353 sgl->word2 = cpu_to_le32(sgl->word2); in lpfc_wqe_bpl2sgl()
21354 sgl->sge_len = cpu_to_le32(wqe->gen_req.bde.tus.f.bdeSize); in lpfc_wqe_bpl2sgl()
21356 return sglq->sli4_xritag; in lpfc_wqe_bpl2sgl()
21360 * lpfc_sli4_issue_wqe - Issue an SLI4 Work Queue Entry (WQE)
21369 union lpfc_wqe128 *wqe = &pwqe->wqe; in lpfc_sli4_issue_wqe()
21378 if (pwqe->cmd_flag & LPFC_IO_NVME_LS) { in lpfc_sli4_issue_wqe()
21379 pring = phba->sli4_hba.nvmels_wq->pring; in lpfc_sli4_issue_wqe()
21380 lpfc_qp_spin_lock_irqsave(&pring->ring_lock, iflags, in lpfc_sli4_issue_wqe()
21384 spin_unlock_irqrestore(&pring->ring_lock, iflags); in lpfc_sli4_issue_wqe()
21387 pwqe->sli4_lxritag = sglq->sli4_lxritag; in lpfc_sli4_issue_wqe()
21388 pwqe->sli4_xritag = sglq->sli4_xritag; in lpfc_sli4_issue_wqe()
21390 spin_unlock_irqrestore(&pring->ring_lock, iflags); in lpfc_sli4_issue_wqe()
21393 bf_set(wqe_xri_tag, &pwqe->wqe.xmit_bls_rsp.wqe_com, in lpfc_sli4_issue_wqe()
21394 pwqe->sli4_xritag); in lpfc_sli4_issue_wqe()
21395 ret = lpfc_sli4_wq_put(phba->sli4_hba.nvmels_wq, wqe); in lpfc_sli4_issue_wqe()
21397 spin_unlock_irqrestore(&pring->ring_lock, iflags); in lpfc_sli4_issue_wqe()
21402 spin_unlock_irqrestore(&pring->ring_lock, iflags); in lpfc_sli4_issue_wqe()
21404 lpfc_sli4_poll_eq(qp->hba_eq); in lpfc_sli4_issue_wqe()
21409 if (pwqe->cmd_flag & (LPFC_IO_NVME | LPFC_IO_FCP | LPFC_IO_CMF)) { in lpfc_sli4_issue_wqe()
21411 wq = qp->io_wq; in lpfc_sli4_issue_wqe()
21412 pring = wq->pring; in lpfc_sli4_issue_wqe()
21414 bf_set(wqe_cqid, &wqe->generic.wqe_com, qp->io_cq_map); in lpfc_sli4_issue_wqe()
21416 lpfc_qp_spin_lock_irqsave(&pring->ring_lock, iflags, in lpfc_sli4_issue_wqe()
21420 spin_unlock_irqrestore(&pring->ring_lock, iflags); in lpfc_sli4_issue_wqe()
21424 spin_unlock_irqrestore(&pring->ring_lock, iflags); in lpfc_sli4_issue_wqe()
21426 lpfc_sli4_poll_eq(qp->hba_eq); in lpfc_sli4_issue_wqe()
21431 if (pwqe->cmd_flag & LPFC_IO_NVMET) { in lpfc_sli4_issue_wqe()
21433 wq = qp->io_wq; in lpfc_sli4_issue_wqe()
21434 pring = wq->pring; in lpfc_sli4_issue_wqe()
21436 ctxp = pwqe->context_un.axchg; in lpfc_sli4_issue_wqe()
21437 sglq = ctxp->ctxbuf->sglq; in lpfc_sli4_issue_wqe()
21438 if (pwqe->sli4_xritag == NO_XRI) { in lpfc_sli4_issue_wqe()
21439 pwqe->sli4_lxritag = sglq->sli4_lxritag; in lpfc_sli4_issue_wqe()
21440 pwqe->sli4_xritag = sglq->sli4_xritag; in lpfc_sli4_issue_wqe()
21442 bf_set(wqe_xri_tag, &pwqe->wqe.xmit_bls_rsp.wqe_com, in lpfc_sli4_issue_wqe()
21443 pwqe->sli4_xritag); in lpfc_sli4_issue_wqe()
21444 bf_set(wqe_cqid, &wqe->generic.wqe_com, qp->io_cq_map); in lpfc_sli4_issue_wqe()
21446 lpfc_qp_spin_lock_irqsave(&pring->ring_lock, iflags, in lpfc_sli4_issue_wqe()
21450 spin_unlock_irqrestore(&pring->ring_lock, iflags); in lpfc_sli4_issue_wqe()
21454 spin_unlock_irqrestore(&pring->ring_lock, iflags); in lpfc_sli4_issue_wqe()
21456 lpfc_sli4_poll_eq(qp->hba_eq); in lpfc_sli4_issue_wqe()
21463 * lpfc_sli4_issue_abort_iotag - SLI-4 WQE init & issue for the Abort
21472 * RETURNS 0 - SUCCESS
21479 struct lpfc_vport *vport = cmdiocb->vport; in lpfc_sli4_issue_abort_iotag()
21484 u16 xritag = cmdiocb->sli4_xritag; in lpfc_sli4_issue_abort_iotag()
21497 cmdiocb->cmd_flag |= LPFC_DRIVER_ABORTED; in lpfc_sli4_issue_abort_iotag()
21499 abtswqe = &abtsiocb->wqe; in lpfc_sli4_issue_abort_iotag()
21502 if (!lpfc_is_link_up(phba) || (phba->link_flag & LS_EXTERNAL_LOOPBACK)) in lpfc_sli4_issue_abort_iotag()
21503 bf_set(abort_cmd_ia, &abtswqe->abort_cmd, 1); in lpfc_sli4_issue_abort_iotag()
21504 bf_set(abort_cmd_criteria, &abtswqe->abort_cmd, T_XRI_TAG); in lpfc_sli4_issue_abort_iotag()
21505 abtswqe->abort_cmd.rsrvd5 = 0; in lpfc_sli4_issue_abort_iotag()
21506 abtswqe->abort_cmd.wqe_com.abort_tag = xritag; in lpfc_sli4_issue_abort_iotag()
21507 bf_set(wqe_reqtag, &abtswqe->abort_cmd.wqe_com, abtsiocb->iotag); in lpfc_sli4_issue_abort_iotag()
21508 bf_set(wqe_cmnd, &abtswqe->abort_cmd.wqe_com, CMD_ABORT_XRI_CX); in lpfc_sli4_issue_abort_iotag()
21509 bf_set(wqe_xri_tag, &abtswqe->generic.wqe_com, 0); in lpfc_sli4_issue_abort_iotag()
21510 bf_set(wqe_qosd, &abtswqe->abort_cmd.wqe_com, 1); in lpfc_sli4_issue_abort_iotag()
21511 bf_set(wqe_lenloc, &abtswqe->abort_cmd.wqe_com, LPFC_WQE_LENLOC_NONE); in lpfc_sli4_issue_abort_iotag()
21512 bf_set(wqe_cmd_type, &abtswqe->abort_cmd.wqe_com, OTHER_COMMAND); in lpfc_sli4_issue_abort_iotag()
21515 abtsiocb->hba_wqidx = cmdiocb->hba_wqidx; in lpfc_sli4_issue_abort_iotag()
21516 abtsiocb->cmd_flag |= LPFC_USE_FCPWQIDX; in lpfc_sli4_issue_abort_iotag()
21517 if (cmdiocb->cmd_flag & LPFC_IO_FCP) in lpfc_sli4_issue_abort_iotag()
21518 abtsiocb->cmd_flag |= LPFC_IO_FCP; in lpfc_sli4_issue_abort_iotag()
21519 if (cmdiocb->cmd_flag & LPFC_IO_NVME) in lpfc_sli4_issue_abort_iotag()
21520 abtsiocb->cmd_flag |= LPFC_IO_NVME; in lpfc_sli4_issue_abort_iotag()
21521 if (cmdiocb->cmd_flag & LPFC_IO_FOF) in lpfc_sli4_issue_abort_iotag()
21522 abtsiocb->cmd_flag |= LPFC_IO_FOF; in lpfc_sli4_issue_abort_iotag()
21523 abtsiocb->vport = vport; in lpfc_sli4_issue_abort_iotag()
21524 abtsiocb->cmd_cmpl = cmpl; in lpfc_sli4_issue_abort_iotag()
21527 retval = lpfc_sli4_issue_wqe(phba, lpfc_cmd->hdwq, abtsiocb); in lpfc_sli4_issue_abort_iotag()
21532 xritag, cmdiocb->iotag, abtsiocb->iotag, retval); in lpfc_sli4_issue_abort_iotag()
21535 cmdiocb->cmd_flag &= ~LPFC_DRIVER_ABORTED; in lpfc_sli4_issue_abort_iotag()
21544 * lpfc_snapshot_mxp - Snapshot pbl, pvt and busy count
21565 qp = &phba->sli4_hba.hdwq[hwqid]; in lpfc_snapshot_mxp()
21566 multixri_pool = qp->p_multixri_pool; in lpfc_snapshot_mxp()
21570 if (multixri_pool->stat_snapshot_taken == LPFC_MXP_SNAPSHOT_TAKEN) { in lpfc_snapshot_mxp()
21571 pvt_pool = &qp->p_multixri_pool->pvt_pool; in lpfc_snapshot_mxp()
21572 pbl_pool = &qp->p_multixri_pool->pbl_pool; in lpfc_snapshot_mxp()
21573 txcmplq_cnt = qp->io_wq->pring->txcmplq_cnt; in lpfc_snapshot_mxp()
21575 multixri_pool->stat_pbl_count = pbl_pool->count; in lpfc_snapshot_mxp()
21576 multixri_pool->stat_pvt_count = pvt_pool->count; in lpfc_snapshot_mxp()
21577 multixri_pool->stat_busy_count = txcmplq_cnt; in lpfc_snapshot_mxp()
21580 multixri_pool->stat_snapshot_taken++; in lpfc_snapshot_mxp()
21585 * lpfc_adjust_pvt_pool_count - Adjust private pool count
21598 multixri_pool = phba->sli4_hba.hdwq[hwqid].p_multixri_pool; in lpfc_adjust_pvt_pool_count()
21601 io_req_count = multixri_pool->io_req_count; in lpfc_adjust_pvt_pool_count()
21602 prev_io_req_count = multixri_pool->prev_io_req_count; in lpfc_adjust_pvt_pool_count()
21606 multixri_pool->prev_io_req_count = io_req_count; in lpfc_adjust_pvt_pool_count()
21616 * lpfc_adjust_high_watermark - Adjust high watermark
21634 qp = &phba->sli4_hba.hdwq[hwqid]; in lpfc_adjust_high_watermark()
21635 multixri_pool = qp->p_multixri_pool; in lpfc_adjust_high_watermark()
21638 xri_limit = multixri_pool->xri_limit; in lpfc_adjust_high_watermark()
21643 txcmplq_cnt = qp->io_wq->pring->txcmplq_cnt; in lpfc_adjust_high_watermark()
21644 abts_io_bufs = qp->abts_scsi_io_bufs; in lpfc_adjust_high_watermark()
21645 abts_io_bufs += qp->abts_nvme_io_bufs; in lpfc_adjust_high_watermark()
21650 multixri_pool->pvt_pool.high_watermark = new_watermark; in lpfc_adjust_high_watermark()
21653 multixri_pool->stat_max_hwm = max(multixri_pool->stat_max_hwm, in lpfc_adjust_high_watermark()
21659 * lpfc_move_xri_pvt_to_pbl - Move some XRIs from private to public pool
21665 * The first step moves (all - low_watermark) amount of XRIs.
21679 qp = &phba->sli4_hba.hdwq[hwqid]; in lpfc_move_xri_pvt_to_pbl()
21680 pbl_pool = &qp->p_multixri_pool->pbl_pool; in lpfc_move_xri_pvt_to_pbl()
21681 pvt_pool = &qp->p_multixri_pool->pvt_pool; in lpfc_move_xri_pvt_to_pbl()
21684 lpfc_qp_spin_lock_irqsave(&pbl_pool->lock, iflag, qp, mv_to_pub_pool); in lpfc_move_xri_pvt_to_pbl()
21685 lpfc_qp_spin_lock(&pvt_pool->lock, qp, mv_from_pvt_pool); in lpfc_move_xri_pvt_to_pbl()
21687 if (pvt_pool->count > pvt_pool->low_watermark) { in lpfc_move_xri_pvt_to_pbl()
21688 /* Step 1: move (all - low_watermark) from pvt_pool in lpfc_move_xri_pvt_to_pbl()
21695 &pvt_pool->list, list) { in lpfc_move_xri_pvt_to_pbl()
21696 list_move_tail(&lpfc_ncmd->list, &tmp_list); in lpfc_move_xri_pvt_to_pbl()
21698 if (tmp_count >= pvt_pool->low_watermark) in lpfc_move_xri_pvt_to_pbl()
21703 list_splice_init(&pvt_pool->list, &pbl_pool->list); in lpfc_move_xri_pvt_to_pbl()
21706 list_splice(&tmp_list, &pvt_pool->list); in lpfc_move_xri_pvt_to_pbl()
21708 pbl_pool->count += (pvt_pool->count - tmp_count); in lpfc_move_xri_pvt_to_pbl()
21709 pvt_pool->count = tmp_count; in lpfc_move_xri_pvt_to_pbl()
21712 list_splice_init(&pvt_pool->list, &pbl_pool->list); in lpfc_move_xri_pvt_to_pbl()
21713 pbl_pool->count += pvt_pool->count; in lpfc_move_xri_pvt_to_pbl()
21714 pvt_pool->count = 0; in lpfc_move_xri_pvt_to_pbl()
21717 spin_unlock(&pvt_pool->lock); in lpfc_move_xri_pvt_to_pbl()
21718 spin_unlock_irqrestore(&pbl_pool->lock, iflag); in lpfc_move_xri_pvt_to_pbl()
21722 * _lpfc_move_xri_pbl_to_pvt - Move some XRIs from public to private pool
21734 * true - if XRIs are successfully moved from the specified pbl_pool to the
21736 * false - if the specified pbl_pool is empty or locked by someone else
21748 ret = spin_trylock_irqsave(&pbl_pool->lock, iflag); in _lpfc_move_xri_pbl_to_pvt()
21750 if (pbl_pool->count) { in _lpfc_move_xri_pbl_to_pvt()
21752 lpfc_qp_spin_lock(&pvt_pool->lock, qp, mv_to_pvt_pool); in _lpfc_move_xri_pbl_to_pvt()
21755 &pbl_pool->list, in _lpfc_move_xri_pbl_to_pvt()
21757 list_move_tail(&lpfc_ncmd->list, in _lpfc_move_xri_pbl_to_pvt()
21758 &pvt_pool->list); in _lpfc_move_xri_pbl_to_pvt()
21759 pvt_pool->count++; in _lpfc_move_xri_pbl_to_pvt()
21760 pbl_pool->count--; in _lpfc_move_xri_pbl_to_pvt()
21761 count--; in _lpfc_move_xri_pbl_to_pvt()
21766 spin_unlock(&pvt_pool->lock); in _lpfc_move_xri_pbl_to_pvt()
21767 spin_unlock_irqrestore(&pbl_pool->lock, iflag); in _lpfc_move_xri_pbl_to_pvt()
21770 spin_unlock_irqrestore(&pbl_pool->lock, iflag); in _lpfc_move_xri_pbl_to_pvt()
21777 * lpfc_move_xri_pbl_to_pvt - Move some XRIs from public to private pool
21799 qp = &phba->sli4_hba.hdwq[hwqid]; in lpfc_move_xri_pbl_to_pvt()
21800 multixri_pool = qp->p_multixri_pool; in lpfc_move_xri_pbl_to_pvt()
21801 pvt_pool = &multixri_pool->pvt_pool; in lpfc_move_xri_pbl_to_pvt()
21802 pbl_pool = &multixri_pool->pbl_pool; in lpfc_move_xri_pbl_to_pvt()
21808 multixri_pool->local_pbl_hit_count++; in lpfc_move_xri_pbl_to_pvt()
21813 hwq_count = phba->cfg_hdw_queue; in lpfc_move_xri_pbl_to_pvt()
21816 next_hwqid = multixri_pool->rrb_next_hwqid; in lpfc_move_xri_pbl_to_pvt()
21823 phba->sli4_hba.hdwq[next_hwqid].p_multixri_pool; in lpfc_move_xri_pbl_to_pvt()
21824 pbl_pool = &next_multixri_pool->pbl_pool; in lpfc_move_xri_pbl_to_pvt()
21830 /* Exit while-loop if success or all hwqid are checked */ in lpfc_move_xri_pbl_to_pvt()
21831 } while (!ret && next_hwqid != multixri_pool->rrb_next_hwqid); in lpfc_move_xri_pbl_to_pvt()
21834 multixri_pool->rrb_next_hwqid = next_hwqid; in lpfc_move_xri_pbl_to_pvt()
21838 multixri_pool->pbl_empty_count++; in lpfc_move_xri_pbl_to_pvt()
21844 multixri_pool->local_pbl_hit_count++; in lpfc_move_xri_pbl_to_pvt()
21846 multixri_pool->other_pbl_hit_count++; in lpfc_move_xri_pbl_to_pvt()
21852 * lpfc_keep_pvt_pool_above_lowwm - Keep pvt_pool above low watermark
21864 multixri_pool = phba->sli4_hba.hdwq[hwqid].p_multixri_pool; in lpfc_keep_pvt_pool_above_lowwm()
21865 pvt_pool = &multixri_pool->pvt_pool; in lpfc_keep_pvt_pool_above_lowwm()
21867 if (pvt_pool->count < pvt_pool->low_watermark) in lpfc_keep_pvt_pool_above_lowwm()
21872 * lpfc_release_io_buf - Return one IO buf back to free pool
21896 lpfc_ncmd->nvmeCmd = NULL; in lpfc_release_io_buf()
21897 lpfc_ncmd->cur_iocbq.cmd_cmpl = NULL; in lpfc_release_io_buf()
21899 if (phba->cfg_xpsgl && !phba->nvmet_support && in lpfc_release_io_buf()
21900 !list_empty(&lpfc_ncmd->dma_sgl_xtra_list)) in lpfc_release_io_buf()
21903 if (!list_empty(&lpfc_ncmd->dma_cmd_rsp_list)) in lpfc_release_io_buf()
21906 if (phba->cfg_xri_rebalancing) { in lpfc_release_io_buf()
21907 if (lpfc_ncmd->expedite) { in lpfc_release_io_buf()
21909 epd_pool = &phba->epd_pool; in lpfc_release_io_buf()
21910 spin_lock_irqsave(&epd_pool->lock, iflag); in lpfc_release_io_buf()
21911 list_add_tail(&lpfc_ncmd->list, &epd_pool->list); in lpfc_release_io_buf()
21912 epd_pool->count++; in lpfc_release_io_buf()
21913 spin_unlock_irqrestore(&epd_pool->lock, iflag); in lpfc_release_io_buf()
21921 if (!qp->p_multixri_pool) in lpfc_release_io_buf()
21924 pbl_pool = &qp->p_multixri_pool->pbl_pool; in lpfc_release_io_buf()
21925 pvt_pool = &qp->p_multixri_pool->pvt_pool; in lpfc_release_io_buf()
21927 txcmplq_cnt = qp->io_wq->pring->txcmplq_cnt; in lpfc_release_io_buf()
21928 abts_io_bufs = qp->abts_scsi_io_bufs; in lpfc_release_io_buf()
21929 abts_io_bufs += qp->abts_nvme_io_bufs; in lpfc_release_io_buf()
21931 xri_owned = pvt_pool->count + txcmplq_cnt + abts_io_bufs; in lpfc_release_io_buf()
21932 xri_limit = qp->p_multixri_pool->xri_limit; in lpfc_release_io_buf()
21936 qp->p_multixri_pool->below_limit_count++; in lpfc_release_io_buf()
21938 qp->p_multixri_pool->above_limit_count++; in lpfc_release_io_buf()
21944 if ((pvt_pool->count < pvt_pool->low_watermark) || in lpfc_release_io_buf()
21946 pvt_pool->count < pvt_pool->high_watermark)) { in lpfc_release_io_buf()
21947 lpfc_qp_spin_lock_irqsave(&pvt_pool->lock, iflag, in lpfc_release_io_buf()
21949 list_add_tail(&lpfc_ncmd->list, in lpfc_release_io_buf()
21950 &pvt_pool->list); in lpfc_release_io_buf()
21951 pvt_pool->count++; in lpfc_release_io_buf()
21952 spin_unlock_irqrestore(&pvt_pool->lock, iflag); in lpfc_release_io_buf()
21954 lpfc_qp_spin_lock_irqsave(&pbl_pool->lock, iflag, in lpfc_release_io_buf()
21956 list_add_tail(&lpfc_ncmd->list, in lpfc_release_io_buf()
21957 &pbl_pool->list); in lpfc_release_io_buf()
21958 pbl_pool->count++; in lpfc_release_io_buf()
21959 spin_unlock_irqrestore(&pbl_pool->lock, iflag); in lpfc_release_io_buf()
21962 lpfc_qp_spin_lock_irqsave(&qp->io_buf_list_put_lock, iflag, in lpfc_release_io_buf()
21964 list_add_tail(&lpfc_ncmd->list, in lpfc_release_io_buf()
21965 &qp->lpfc_io_buf_list_put); in lpfc_release_io_buf()
21966 qp->put_io_bufs++; in lpfc_release_io_buf()
21967 spin_unlock_irqrestore(&qp->io_buf_list_put_lock, in lpfc_release_io_buf()
21973 * lpfc_get_io_buf_from_private_pool - Get one free IO buf from private pool
21982 * pointer to one free IO buf - if private pool is not empty
21983 * NULL - if private pool is empty
21995 lpfc_qp_spin_lock_irqsave(&pvt_pool->lock, iflag, qp, alloc_pvt_pool); in lpfc_get_io_buf_from_private_pool()
21997 &pvt_pool->list, list) { in lpfc_get_io_buf_from_private_pool()
21999 phba, ndlp, lpfc_ncmd->cur_iocbq.sli4_lxritag)) in lpfc_get_io_buf_from_private_pool()
22001 list_del(&lpfc_ncmd->list); in lpfc_get_io_buf_from_private_pool()
22002 pvt_pool->count--; in lpfc_get_io_buf_from_private_pool()
22003 spin_unlock_irqrestore(&pvt_pool->lock, iflag); in lpfc_get_io_buf_from_private_pool()
22006 spin_unlock_irqrestore(&pvt_pool->lock, iflag); in lpfc_get_io_buf_from_private_pool()
22012 * lpfc_get_io_buf_from_expedite_pool - Get one free IO buf from expedite pool
22018 * pointer to one free IO buf - if expedite pool is not empty
22019 * NULL - if expedite pool is empty
22029 epd_pool = &phba->epd_pool; in lpfc_get_io_buf_from_expedite_pool()
22031 spin_lock_irqsave(&epd_pool->lock, iflag); in lpfc_get_io_buf_from_expedite_pool()
22032 if (epd_pool->count > 0) { in lpfc_get_io_buf_from_expedite_pool()
22034 &epd_pool->list, list) { in lpfc_get_io_buf_from_expedite_pool()
22035 list_del(&iter->list); in lpfc_get_io_buf_from_expedite_pool()
22036 epd_pool->count--; in lpfc_get_io_buf_from_expedite_pool()
22041 spin_unlock_irqrestore(&epd_pool->lock, iflag); in lpfc_get_io_buf_from_expedite_pool()
22047 * lpfc_get_io_buf_from_multixri_pools - Get one free IO bufs
22066 * pointer to one free IO buf - if private pool is not empty
22067 * NULL - if private pool is empty
22079 qp = &phba->sli4_hba.hdwq[hwqid]; in lpfc_get_io_buf_from_multixri_pools()
22087 multixri_pool = qp->p_multixri_pool; in lpfc_get_io_buf_from_multixri_pools()
22094 pvt_pool = &multixri_pool->pvt_pool; in lpfc_get_io_buf_from_multixri_pools()
22101 multixri_pool->io_req_count++; in lpfc_get_io_buf_from_multixri_pools()
22104 if (pvt_pool->count == 0) in lpfc_get_io_buf_from_multixri_pools()
22111 lpfc_ncmd->hdwq = qp; in lpfc_get_io_buf_from_multixri_pools()
22112 lpfc_ncmd->hdwq_no = hwqid; in lpfc_get_io_buf_from_multixri_pools()
22129 qp = &phba->sli4_hba.hdwq[idx]; in lpfc_io_buf()
22131 &qp->lpfc_io_buf_list_get, list) { in lpfc_io_buf()
22133 lpfc_cmd->cur_iocbq.sli4_lxritag)) in lpfc_io_buf()
22136 if (lpfc_cmd->flags & LPFC_SBUF_NOT_POSTED) in lpfc_io_buf()
22139 list_del_init(&lpfc_cmd->list); in lpfc_io_buf()
22140 qp->get_io_bufs--; in lpfc_io_buf()
22141 lpfc_cmd->hdwq = qp; in lpfc_io_buf()
22142 lpfc_cmd->hdwq_no = idx; in lpfc_io_buf()
22149 * lpfc_get_io_buf - Get one IO buffer from free pool
22163 * NULL - Error
22164 * Pointer to lpfc_io_buf - Success
22174 qp = &phba->sli4_hba.hdwq[hwqid]; in lpfc_get_io_buf()
22183 if (phba->cfg_xri_rebalancing) in lpfc_get_io_buf()
22187 lpfc_qp_spin_lock_irqsave(&qp->io_buf_list_get_lock, iflag, in lpfc_get_io_buf()
22189 if (qp->get_io_bufs > LPFC_NVME_EXPEDITE_XRICNT || expedite) in lpfc_get_io_buf()
22192 lpfc_qp_spin_lock(&qp->io_buf_list_put_lock, in lpfc_get_io_buf()
22194 list_splice(&qp->lpfc_io_buf_list_put, in lpfc_get_io_buf()
22195 &qp->lpfc_io_buf_list_get); in lpfc_get_io_buf()
22196 qp->get_io_bufs += qp->put_io_bufs; in lpfc_get_io_buf()
22197 INIT_LIST_HEAD(&qp->lpfc_io_buf_list_put); in lpfc_get_io_buf()
22198 qp->put_io_bufs = 0; in lpfc_get_io_buf()
22199 spin_unlock(&qp->io_buf_list_put_lock); in lpfc_get_io_buf()
22200 if (qp->get_io_bufs > LPFC_NVME_EXPEDITE_XRICNT || in lpfc_get_io_buf()
22204 spin_unlock_irqrestore(&qp->io_buf_list_get_lock, iflag); in lpfc_get_io_buf()
22211 * lpfc_read_object - Retrieve object data from HBA
22225 * to use interrupt-based completions, code is needed to fully cleanup
22240 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_read_object()
22242 return -ENOMEM; in lpfc_read_object()
22243 length = (sizeof(struct lpfc_mbx_read_object) - in lpfc_read_object()
22248 read_object = &mbox->u.mqe.un.read_object; in lpfc_read_object()
22249 shdr = (union lpfc_sli4_cfg_shdr *)&read_object->header.cfg_shdr; in lpfc_read_object()
22251 bf_set(lpfc_mbox_hdr_version, &shdr->request, LPFC_Q_CREATE_VERSION_0); in lpfc_read_object()
22252 bf_set(lpfc_mbx_rd_object_rlen, &read_object->u.request, datasz); in lpfc_read_object()
22253 read_object->u.request.rd_object_offset = 0; in lpfc_read_object()
22254 read_object->u.request.rd_object_cnt = 1; in lpfc_read_object()
22256 memset((void *)read_object->u.request.rd_object_name, 0, in lpfc_read_object()
22260 read_object->u.request.rd_object_name[j] = in lpfc_read_object()
22265 pcmd->virt = lpfc_mbuf_alloc(phba, MEM_PRI, &pcmd->phys); in lpfc_read_object()
22266 if (!pcmd || !pcmd->virt) { in lpfc_read_object()
22268 mempool_free(mbox, phba->mbox_mem_pool); in lpfc_read_object()
22269 return -ENOMEM; in lpfc_read_object()
22271 memset((void *)pcmd->virt, 0, LPFC_BPL_SIZE); in lpfc_read_object()
22272 read_object->u.request.rd_object_hbuf[0].pa_lo = in lpfc_read_object()
22273 putPaddrLow(pcmd->phys); in lpfc_read_object()
22274 read_object->u.request.rd_object_hbuf[0].pa_hi = in lpfc_read_object()
22275 putPaddrHigh(pcmd->phys); in lpfc_read_object()
22276 read_object->u.request.rd_object_hbuf[0].length = LPFC_BPL_SIZE; in lpfc_read_object()
22278 mbox->vport = phba->pport; in lpfc_read_object()
22279 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_read_object()
22280 mbox->ctx_ndlp = NULL; in lpfc_read_object()
22283 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_read_object()
22284 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_read_object()
22290 byte_cnt = -ENOENT; in lpfc_read_object()
22293 "2625 READ_OBJECT mailbox failed with " in lpfc_read_object()
22296 byte_cnt = -ENXIO; in lpfc_read_object()
22299 length = read_object->u.response.rd_object_actual_rlen; in lpfc_read_object()
22300 eof = bf_get(lpfc_mbx_rd_object_eof, &read_object->u.response); in lpfc_read_object()
22312 lpfc_sli_pcimem_bcopy(pcmd->virt, datap, byte_cnt); in lpfc_read_object()
22316 /* This is an embedded SLI4 mailbox with an external buffer allocated. in lpfc_read_object()
22319 lpfc_mbuf_free(phba, pcmd->virt, pcmd->phys); in lpfc_read_object()
22326 * lpfc_get_sgl_per_hdwq - Get one SGL chunk from hdwq's pool
22334 * NULL - Error
22335 * Pointer to sli4_hybrid_sgl - Success
22343 struct lpfc_sli4_hdw_queue *hdwq = lpfc_buf->hdwq; in lpfc_get_sgl_per_hdwq()
22344 struct list_head *buf_list = &hdwq->sgl_list; in lpfc_get_sgl_per_hdwq()
22347 spin_lock_irqsave(&hdwq->hdwq_lock, iflags); in lpfc_get_sgl_per_hdwq()
22353 list_move_tail(&list_entry->list_node, in lpfc_get_sgl_per_hdwq()
22354 &lpfc_buf->dma_sgl_xtra_list); in lpfc_get_sgl_per_hdwq()
22359 spin_unlock_irqrestore(&hdwq->hdwq_lock, iflags); in lpfc_get_sgl_per_hdwq()
22361 cpu_to_node(hdwq->io_wq->chann)); in lpfc_get_sgl_per_hdwq()
22366 lpfc_buf->hdwq_no, __func__); in lpfc_get_sgl_per_hdwq()
22370 tmp->dma_sgl = dma_pool_alloc(phba->lpfc_sg_dma_buf_pool, in lpfc_get_sgl_per_hdwq()
22371 GFP_ATOMIC, &tmp->dma_phys_sgl); in lpfc_get_sgl_per_hdwq()
22372 if (!tmp->dma_sgl) { in lpfc_get_sgl_per_hdwq()
22376 lpfc_buf->hdwq_no, __func__); in lpfc_get_sgl_per_hdwq()
22381 spin_lock_irqsave(&hdwq->hdwq_lock, iflags); in lpfc_get_sgl_per_hdwq()
22382 list_add_tail(&tmp->list_node, &lpfc_buf->dma_sgl_xtra_list); in lpfc_get_sgl_per_hdwq()
22385 allocated_sgl = list_last_entry(&lpfc_buf->dma_sgl_xtra_list, in lpfc_get_sgl_per_hdwq()
22389 spin_unlock_irqrestore(&hdwq->hdwq_lock, iflags); in lpfc_get_sgl_per_hdwq()
22395 * lpfc_put_sgl_per_hdwq - Put one SGL chunk into hdwq pool
22402 * 0 - Success
22403 * -EINVAL - Error
22411 struct lpfc_sli4_hdw_queue *hdwq = lpfc_buf->hdwq; in lpfc_put_sgl_per_hdwq()
22412 struct list_head *buf_list = &hdwq->sgl_list; in lpfc_put_sgl_per_hdwq()
22415 spin_lock_irqsave(&hdwq->hdwq_lock, iflags); in lpfc_put_sgl_per_hdwq()
22417 if (likely(!list_empty(&lpfc_buf->dma_sgl_xtra_list))) { in lpfc_put_sgl_per_hdwq()
22419 &lpfc_buf->dma_sgl_xtra_list, in lpfc_put_sgl_per_hdwq()
22421 list_move_tail(&list_entry->list_node, in lpfc_put_sgl_per_hdwq()
22425 rc = -EINVAL; in lpfc_put_sgl_per_hdwq()
22428 spin_unlock_irqrestore(&hdwq->hdwq_lock, iflags); in lpfc_put_sgl_per_hdwq()
22433 * lpfc_free_sgl_per_hdwq - Free all SGL chunks of hdwq pool
22446 struct list_head *buf_list = &hdwq->sgl_list; in lpfc_free_sgl_per_hdwq()
22451 spin_lock_irqsave(&hdwq->hdwq_lock, iflags); in lpfc_free_sgl_per_hdwq()
22456 list_del(&list_entry->list_node); in lpfc_free_sgl_per_hdwq()
22457 dma_pool_free(phba->lpfc_sg_dma_buf_pool, in lpfc_free_sgl_per_hdwq()
22458 list_entry->dma_sgl, in lpfc_free_sgl_per_hdwq()
22459 list_entry->dma_phys_sgl); in lpfc_free_sgl_per_hdwq()
22463 spin_unlock_irqrestore(&hdwq->hdwq_lock, iflags); in lpfc_free_sgl_per_hdwq()
22467 * lpfc_get_cmd_rsp_buf_per_hdwq - Get one CMD/RSP buffer from hdwq
22475 * NULL - Error
22476 * Pointer to fcp_cmd_rsp_buf - Success
22485 struct lpfc_sli4_hdw_queue *hdwq = lpfc_buf->hdwq; in lpfc_get_cmd_rsp_buf_per_hdwq()
22486 struct list_head *buf_list = &hdwq->cmd_rsp_buf_list; in lpfc_get_cmd_rsp_buf_per_hdwq()
22489 spin_lock_irqsave(&hdwq->hdwq_lock, iflags); in lpfc_get_cmd_rsp_buf_per_hdwq()
22496 list_move_tail(&list_entry->list_node, in lpfc_get_cmd_rsp_buf_per_hdwq()
22497 &lpfc_buf->dma_cmd_rsp_list); in lpfc_get_cmd_rsp_buf_per_hdwq()
22502 spin_unlock_irqrestore(&hdwq->hdwq_lock, iflags); in lpfc_get_cmd_rsp_buf_per_hdwq()
22504 cpu_to_node(hdwq->io_wq->chann)); in lpfc_get_cmd_rsp_buf_per_hdwq()
22509 lpfc_buf->hdwq_no, __func__); in lpfc_get_cmd_rsp_buf_per_hdwq()
22513 tmp->fcp_cmnd = dma_pool_zalloc(phba->lpfc_cmd_rsp_buf_pool, in lpfc_get_cmd_rsp_buf_per_hdwq()
22515 &tmp->fcp_cmd_rsp_dma_handle); in lpfc_get_cmd_rsp_buf_per_hdwq()
22517 if (!tmp->fcp_cmnd) { in lpfc_get_cmd_rsp_buf_per_hdwq()
22521 lpfc_buf->hdwq_no, __func__); in lpfc_get_cmd_rsp_buf_per_hdwq()
22526 tmp->fcp_rsp = (struct fcp_rsp *)((uint8_t *)tmp->fcp_cmnd + in lpfc_get_cmd_rsp_buf_per_hdwq()
22529 spin_lock_irqsave(&hdwq->hdwq_lock, iflags); in lpfc_get_cmd_rsp_buf_per_hdwq()
22530 list_add_tail(&tmp->list_node, &lpfc_buf->dma_cmd_rsp_list); in lpfc_get_cmd_rsp_buf_per_hdwq()
22533 allocated_buf = list_last_entry(&lpfc_buf->dma_cmd_rsp_list, in lpfc_get_cmd_rsp_buf_per_hdwq()
22537 spin_unlock_irqrestore(&hdwq->hdwq_lock, iflags); in lpfc_get_cmd_rsp_buf_per_hdwq()
22543 * lpfc_put_cmd_rsp_buf_per_hdwq - Put one CMD/RSP buffer into hdwq pool
22550 * 0 - Success
22551 * -EINVAL - Error
22560 struct lpfc_sli4_hdw_queue *hdwq = lpfc_buf->hdwq; in lpfc_put_cmd_rsp_buf_per_hdwq()
22561 struct list_head *buf_list = &hdwq->cmd_rsp_buf_list; in lpfc_put_cmd_rsp_buf_per_hdwq()
22564 spin_lock_irqsave(&hdwq->hdwq_lock, iflags); in lpfc_put_cmd_rsp_buf_per_hdwq()
22566 if (likely(!list_empty(&lpfc_buf->dma_cmd_rsp_list))) { in lpfc_put_cmd_rsp_buf_per_hdwq()
22568 &lpfc_buf->dma_cmd_rsp_list, in lpfc_put_cmd_rsp_buf_per_hdwq()
22570 list_move_tail(&list_entry->list_node, in lpfc_put_cmd_rsp_buf_per_hdwq()
22574 rc = -EINVAL; in lpfc_put_cmd_rsp_buf_per_hdwq()
22577 spin_unlock_irqrestore(&hdwq->hdwq_lock, iflags); in lpfc_put_cmd_rsp_buf_per_hdwq()
22582 * lpfc_free_cmd_rsp_buf_per_hdwq - Free all CMD/RSP chunks of hdwq pool
22595 struct list_head *buf_list = &hdwq->cmd_rsp_buf_list; in lpfc_free_cmd_rsp_buf_per_hdwq()
22600 spin_lock_irqsave(&hdwq->hdwq_lock, iflags); in lpfc_free_cmd_rsp_buf_per_hdwq()
22606 list_del(&list_entry->list_node); in lpfc_free_cmd_rsp_buf_per_hdwq()
22607 dma_pool_free(phba->lpfc_cmd_rsp_buf_pool, in lpfc_free_cmd_rsp_buf_per_hdwq()
22608 list_entry->fcp_cmnd, in lpfc_free_cmd_rsp_buf_per_hdwq()
22609 list_entry->fcp_cmd_rsp_dma_handle); in lpfc_free_cmd_rsp_buf_per_hdwq()
22613 spin_unlock_irqrestore(&hdwq->hdwq_lock, iflags); in lpfc_free_cmd_rsp_buf_per_hdwq()
22617 * lpfc_sli_prep_wqe - Prepare WQE for the command to be posted
22635 union lpfc_wqe128 *wqe = &job->wqe; in lpfc_sli_prep_wqe()
22638 fip = test_bit(HBA_FIP_SUPPORT, &phba->hba_flag); in lpfc_sli_prep_wqe()
22640 if (job->cmd_flag & LPFC_IO_FCP) in lpfc_sli_prep_wqe()
22642 else if (fip && (job->cmd_flag & LPFC_FIP_ELS_ID_MASK)) in lpfc_sli_prep_wqe()
22647 abort_tag = job->iotag; in lpfc_sli_prep_wqe()
22648 cmnd = bf_get(wqe_cmnd, &wqe->els_req.wqe_com); in lpfc_sli_prep_wqe()
22652 ndlp = job->ndlp; in lpfc_sli_prep_wqe()
22655 &phba->sli4_hba.sli_intf); in lpfc_sli_prep_wqe()
22657 pcmd = (u32 *)job->cmd_dmabuf->virt; in lpfc_sli_prep_wqe()
22668 bf_set(els_req64_sp, &wqe->els_req, 1); in lpfc_sli_prep_wqe()
22669 bf_set(els_req64_sid, &wqe->els_req, in lpfc_sli_prep_wqe()
22670 job->vport->fc_myDID); in lpfc_sli_prep_wqe()
22673 !(phba->fc_topology == in lpfc_sli_prep_wqe()
22675 bf_set(els_req64_sid, &wqe->els_req, 0); in lpfc_sli_prep_wqe()
22677 bf_set(wqe_ct, &wqe->els_req.wqe_com, 1); in lpfc_sli_prep_wqe()
22678 bf_set(wqe_ctxt_tag, &wqe->els_req.wqe_com, in lpfc_sli_prep_wqe()
22679 phba->vpi_ids[job->vport->vpi]); in lpfc_sli_prep_wqe()
22681 bf_set(wqe_ct, &wqe->els_req.wqe_com, 0); in lpfc_sli_prep_wqe()
22682 bf_set(wqe_ctxt_tag, &wqe->els_req.wqe_com, in lpfc_sli_prep_wqe()
22683 phba->sli4_hba.rpi_ids[ndlp->nlp_rpi]); in lpfc_sli_prep_wqe()
22687 bf_set(wqe_temp_rpi, &wqe->els_req.wqe_com, in lpfc_sli_prep_wqe()
22688 phba->sli4_hba.rpi_ids[ndlp->nlp_rpi]); in lpfc_sli_prep_wqe()
22690 bf_set(wqe_dbde, &wqe->els_req.wqe_com, 1); in lpfc_sli_prep_wqe()
22691 bf_set(wqe_iod, &wqe->els_req.wqe_com, LPFC_WQE_IOD_READ); in lpfc_sli_prep_wqe()
22692 bf_set(wqe_qosd, &wqe->els_req.wqe_com, 1); in lpfc_sli_prep_wqe()
22693 bf_set(wqe_lenloc, &wqe->els_req.wqe_com, LPFC_WQE_LENLOC_NONE); in lpfc_sli_prep_wqe()
22694 bf_set(wqe_ebde_cnt, &wqe->els_req.wqe_com, 0); in lpfc_sli_prep_wqe()
22697 ndlp = job->ndlp; in lpfc_sli_prep_wqe()
22700 wqe->xmit_els_rsp.word4 = 0; in lpfc_sli_prep_wqe()
22703 &phba->sli4_hba.sli_intf); in lpfc_sli_prep_wqe()
22705 if (test_bit(FC_PT2PT, &job->vport->fc_flag)) { in lpfc_sli_prep_wqe()
22706 bf_set(els_rsp64_sp, &wqe->xmit_els_rsp, 1); in lpfc_sli_prep_wqe()
22707 bf_set(els_rsp64_sid, &wqe->xmit_els_rsp, in lpfc_sli_prep_wqe()
22708 job->vport->fc_myDID); in lpfc_sli_prep_wqe()
22709 if (job->vport->fc_myDID == Fabric_DID) { in lpfc_sli_prep_wqe()
22711 &wqe->xmit_els_rsp.wqe_dest, 0); in lpfc_sli_prep_wqe()
22716 bf_set(wqe_dbde, &wqe->xmit_els_rsp.wqe_com, 1); in lpfc_sli_prep_wqe()
22717 bf_set(wqe_iod, &wqe->xmit_els_rsp.wqe_com, LPFC_WQE_IOD_WRITE); in lpfc_sli_prep_wqe()
22718 bf_set(wqe_qosd, &wqe->xmit_els_rsp.wqe_com, 1); in lpfc_sli_prep_wqe()
22719 bf_set(wqe_lenloc, &wqe->xmit_els_rsp.wqe_com, in lpfc_sli_prep_wqe()
22721 bf_set(wqe_ebde_cnt, &wqe->xmit_els_rsp.wqe_com, 0); in lpfc_sli_prep_wqe()
22723 if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) { in lpfc_sli_prep_wqe()
22724 bf_set(els_rsp64_sp, &wqe->xmit_els_rsp, 1); in lpfc_sli_prep_wqe()
22725 bf_set(els_rsp64_sid, &wqe->xmit_els_rsp, in lpfc_sli_prep_wqe()
22726 job->vport->fc_myDID); in lpfc_sli_prep_wqe()
22727 bf_set(wqe_ct, &wqe->xmit_els_rsp.wqe_com, 1); in lpfc_sli_prep_wqe()
22730 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_sli_prep_wqe()
22731 bf_set(wqe_rsp_temp_rpi, &wqe->xmit_els_rsp, in lpfc_sli_prep_wqe()
22732 phba->sli4_hba.rpi_ids[ndlp->nlp_rpi]); in lpfc_sli_prep_wqe()
22734 if (bf_get(wqe_ct, &wqe->xmit_els_rsp.wqe_com)) in lpfc_sli_prep_wqe()
22735 bf_set(wqe_ctxt_tag, &wqe->xmit_els_rsp.wqe_com, in lpfc_sli_prep_wqe()
22736 phba->vpi_ids[job->vport->vpi]); in lpfc_sli_prep_wqe()
22742 bf_set(wqe_dbde, &wqe->gen_req.wqe_com, 1); in lpfc_sli_prep_wqe()
22743 bf_set(wqe_iod, &wqe->gen_req.wqe_com, LPFC_WQE_IOD_READ); in lpfc_sli_prep_wqe()
22744 bf_set(wqe_qosd, &wqe->gen_req.wqe_com, 1); in lpfc_sli_prep_wqe()
22745 bf_set(wqe_lenloc, &wqe->gen_req.wqe_com, LPFC_WQE_LENLOC_NONE); in lpfc_sli_prep_wqe()
22746 bf_set(wqe_ebde_cnt, &wqe->gen_req.wqe_com, 0); in lpfc_sli_prep_wqe()
22750 if (phba->link_flag & LS_LOOPBACK_MODE) in lpfc_sli_prep_wqe()
22751 bf_set(wqe_xo, &wqe->xmit_sequence.wge_ctl, 1); in lpfc_sli_prep_wqe()
22753 wqe->xmit_sequence.rsvd3 = 0; in lpfc_sli_prep_wqe()
22754 bf_set(wqe_pu, &wqe->xmit_sequence.wqe_com, 0); in lpfc_sli_prep_wqe()
22755 bf_set(wqe_dbde, &wqe->xmit_sequence.wqe_com, 1); in lpfc_sli_prep_wqe()
22756 bf_set(wqe_iod, &wqe->xmit_sequence.wqe_com, in lpfc_sli_prep_wqe()
22758 bf_set(wqe_lenloc, &wqe->xmit_sequence.wqe_com, in lpfc_sli_prep_wqe()
22760 bf_set(wqe_ebde_cnt, &wqe->xmit_sequence.wqe_com, 0); in lpfc_sli_prep_wqe()
22764 bf_set(xmit_bls_rsp64_seqcnthi, &wqe->xmit_bls_rsp, 0xffff); in lpfc_sli_prep_wqe()
22765 bf_set(wqe_xmit_bls_pt, &wqe->xmit_bls_rsp.wqe_dest, 0x1); in lpfc_sli_prep_wqe()
22766 bf_set(wqe_ct, &wqe->xmit_bls_rsp.wqe_com, 1); in lpfc_sli_prep_wqe()
22767 bf_set(wqe_ctxt_tag, &wqe->xmit_bls_rsp.wqe_com, in lpfc_sli_prep_wqe()
22768 phba->vpi_ids[phba->pport->vpi]); in lpfc_sli_prep_wqe()
22769 bf_set(wqe_qosd, &wqe->xmit_bls_rsp.wqe_com, 1); in lpfc_sli_prep_wqe()
22770 bf_set(wqe_lenloc, &wqe->xmit_bls_rsp.wqe_com, in lpfc_sli_prep_wqe()
22772 /* Overwrite the pre-set comnd type with OTHER_COMMAND */ in lpfc_sli_prep_wqe()
22778 /* cases already formatted for sli4 wqe - no chgs necessary */ in lpfc_sli_prep_wqe()
22788 wqe->generic.wqe_com.abort_tag = abort_tag; in lpfc_sli_prep_wqe()
22789 bf_set(wqe_reqtag, &wqe->generic.wqe_com, job->iotag); in lpfc_sli_prep_wqe()
22790 bf_set(wqe_cmd_type, &wqe->generic.wqe_com, command_type); in lpfc_sli_prep_wqe()
22791 bf_set(wqe_cqid, &wqe->generic.wqe_com, LPFC_WQE_CQ_ID_DEFAULT); in lpfc_sli_prep_wqe()