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

4  * Copyright (C) 2017-2023 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 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_handle_rrq_active()
1028 phba->hba_flag &= ~HBA_RRQ_ACTIVE; in lpfc_handle_rrq_active()
1029 next_time = jiffies + msecs_to_jiffies(1000 * (phba->fc_ratov + 1)); 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->hbalock, iflags); in lpfc_handle_rrq_active()
1038 if ((!list_empty(&phba->active_rrq_list)) && in lpfc_handle_rrq_active()
1039 (!(phba->pport->load_flag & FC_UNLOADING))) 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->hbalock, 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->hbalock, iflags); in lpfc_get_active_rrq()
1084 spin_unlock_irqrestore(&phba->hbalock, 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->hbalock, 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->hbalock, 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 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_set_rrq_active()
1183 if (phba->pport->load_flag & FC_UNLOADING) { in lpfc_set_rrq_active()
1184 phba->hba_flag &= ~HBA_RRQ_ACTIVE; in lpfc_set_rrq_active()
1188 if (ndlp->vport && (ndlp->vport->load_flag & FC_UNLOADING)) 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()
1216 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_set_rrq_active()
1217 empty = list_empty(&phba->active_rrq_list); in lpfc_set_rrq_active()
1218 list_add_tail(&rrq->list, &phba->active_rrq_list); in lpfc_set_rrq_active()
1219 phba->hba_flag |= HBA_RRQ_ACTIVE; in lpfc_set_rrq_active()
1222 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_set_rrq_active()
1225 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_set_rrq_active()
1229 xritag, rxid, ndlp->nlp_DID, send_rrq); in lpfc_set_rrq_active()
1230 return -EINVAL; in lpfc_set_rrq_active()
1234 * __lpfc_sli_get_els_sglq - Allocates an iocb object from sgl pool
1247 struct list_head *lpfc_els_sgl_list = &phba->sli4_hba.lpfc_els_sgl_list; in __lpfc_sli_get_els_sglq()
1257 if (piocbq->cmd_flag & LPFC_IO_FCP) { in __lpfc_sli_get_els_sglq()
1258 lpfc_cmd = piocbq->io_buf; in __lpfc_sli_get_els_sglq()
1259 ndlp = lpfc_cmd->rdata->pnode; in __lpfc_sli_get_els_sglq()
1261 !(piocbq->cmd_flag & LPFC_IO_LIBDFC)) { in __lpfc_sli_get_els_sglq()
1262 ndlp = piocbq->ndlp; in __lpfc_sli_get_els_sglq()
1263 } else if (piocbq->cmd_flag & LPFC_IO_LIBDFC) { in __lpfc_sli_get_els_sglq()
1264 if (piocbq->cmd_flag & LPFC_IO_LOOPBACK) in __lpfc_sli_get_els_sglq()
1267 ndlp = piocbq->ndlp; in __lpfc_sli_get_els_sglq()
1269 ndlp = piocbq->ndlp; in __lpfc_sli_get_els_sglq()
1272 spin_lock(&phba->sli4_hba.sgl_list_lock); in __lpfc_sli_get_els_sglq()
1278 if (ndlp && ndlp->active_rrqs_xri_bitmap && in __lpfc_sli_get_els_sglq()
1279 test_bit(sglq->sli4_lxritag, in __lpfc_sli_get_els_sglq()
1280 ndlp->active_rrqs_xri_bitmap)) { in __lpfc_sli_get_els_sglq()
1284 list_add_tail(&sglq->list, lpfc_els_sgl_list); in __lpfc_sli_get_els_sglq()
1289 list_add_tail(&sglq->list, lpfc_els_sgl_list); in __lpfc_sli_get_els_sglq()
1295 sglq->ndlp = ndlp; in __lpfc_sli_get_els_sglq()
1297 phba->sli4_hba.lpfc_sglq_active_list[sglq->sli4_lxritag] = sglq; in __lpfc_sli_get_els_sglq()
1298 sglq->state = SGL_ALLOCATED; in __lpfc_sli_get_els_sglq()
1300 spin_unlock(&phba->sli4_hba.sgl_list_lock); in __lpfc_sli_get_els_sglq()
1305 * __lpfc_sli_get_nvmet_sglq - Allocates an iocb object from sgl pool
1320 lpfc_nvmet_sgl_list = &phba->sli4_hba.lpfc_nvmet_sgl_list; in __lpfc_sli_get_nvmet_sglq()
1322 lockdep_assert_held(&phba->sli4_hba.sgl_list_lock); in __lpfc_sli_get_nvmet_sglq()
1327 phba->sli4_hba.lpfc_sglq_active_list[sglq->sli4_lxritag] = sglq; in __lpfc_sli_get_nvmet_sglq()
1328 sglq->state = SGL_ALLOCATED; in __lpfc_sli_get_nvmet_sglq()
1333 * lpfc_sli_get_iocbq - Allocates an iocb object from iocb pool
1347 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli_get_iocbq()
1349 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli_get_iocbq()
1354 * __lpfc_sli_release_iocbq_s4 - Release iocb to the iocb pool
1379 if (iocbq->sli4_xritag == NO_XRI) in __lpfc_sli_release_iocbq_s4()
1382 sglq = __lpfc_clear_active_sglq(phba, iocbq->sli4_lxritag); in __lpfc_sli_release_iocbq_s4()
1386 if (iocbq->cmd_flag & LPFC_IO_NVMET) { in __lpfc_sli_release_iocbq_s4()
1387 spin_lock_irqsave(&phba->sli4_hba.sgl_list_lock, in __lpfc_sli_release_iocbq_s4()
1389 sglq->state = SGL_FREED; in __lpfc_sli_release_iocbq_s4()
1390 sglq->ndlp = NULL; in __lpfc_sli_release_iocbq_s4()
1391 list_add_tail(&sglq->list, in __lpfc_sli_release_iocbq_s4()
1392 &phba->sli4_hba.lpfc_nvmet_sgl_list); in __lpfc_sli_release_iocbq_s4()
1394 &phba->sli4_hba.sgl_list_lock, iflag); in __lpfc_sli_release_iocbq_s4()
1398 if ((iocbq->cmd_flag & LPFC_EXCHANGE_BUSY) && in __lpfc_sli_release_iocbq_s4()
1399 (!(unlikely(pci_channel_offline(phba->pcidev)))) && in __lpfc_sli_release_iocbq_s4()
1400 sglq->state != SGL_XRI_ABORTED) { in __lpfc_sli_release_iocbq_s4()
1401 spin_lock_irqsave(&phba->sli4_hba.sgl_list_lock, in __lpfc_sli_release_iocbq_s4()
1405 if (sglq->ndlp && !lpfc_nlp_get(sglq->ndlp)) in __lpfc_sli_release_iocbq_s4()
1406 sglq->ndlp = NULL; in __lpfc_sli_release_iocbq_s4()
1408 list_add(&sglq->list, in __lpfc_sli_release_iocbq_s4()
1409 &phba->sli4_hba.lpfc_abts_els_sgl_list); in __lpfc_sli_release_iocbq_s4()
1411 &phba->sli4_hba.sgl_list_lock, iflag); in __lpfc_sli_release_iocbq_s4()
1413 spin_lock_irqsave(&phba->sli4_hba.sgl_list_lock, in __lpfc_sli_release_iocbq_s4()
1415 sglq->state = SGL_FREED; in __lpfc_sli_release_iocbq_s4()
1416 sglq->ndlp = NULL; in __lpfc_sli_release_iocbq_s4()
1417 list_add_tail(&sglq->list, in __lpfc_sli_release_iocbq_s4()
1418 &phba->sli4_hba.lpfc_els_sgl_list); in __lpfc_sli_release_iocbq_s4()
1420 &phba->sli4_hba.sgl_list_lock, iflag); in __lpfc_sli_release_iocbq_s4()
1423 if (pring && (!list_empty(&pring->txq))) in __lpfc_sli_release_iocbq_s4()
1433 iocbq->sli4_lxritag = NO_XRI; in __lpfc_sli_release_iocbq_s4()
1434 iocbq->sli4_xritag = NO_XRI; in __lpfc_sli_release_iocbq_s4()
1435 iocbq->cmd_flag &= ~(LPFC_IO_NVME | LPFC_IO_NVMET | LPFC_IO_CMF | in __lpfc_sli_release_iocbq_s4()
1437 list_add_tail(&iocbq->list, &phba->lpfc_iocb_list); in __lpfc_sli_release_iocbq_s4()
1442 * __lpfc_sli_release_iocbq_s3 - Release iocb to the iocb pool
1460 iocbq->sli4_xritag = NO_XRI; in __lpfc_sli_release_iocbq_s3()
1461 list_add_tail(&iocbq->list, &phba->lpfc_iocb_list); in __lpfc_sli_release_iocbq_s3()
1465 * __lpfc_sli_release_iocbq - Release iocb to the iocb pool
1477 lockdep_assert_held(&phba->hbalock); in __lpfc_sli_release_iocbq()
1479 phba->__lpfc_sli_release_iocbq(phba, iocbq); in __lpfc_sli_release_iocbq()
1480 phba->iocb_cnt--; in __lpfc_sli_release_iocbq()
1484 * lpfc_sli_release_iocbq - Release iocb to the iocb pool
1499 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli_release_iocbq()
1501 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli_release_iocbq()
1505 * lpfc_sli_cancel_iocbs - Cancel all iocbs from a list.
1509 * @ulpWord4: ULP word-4 in IOCB command field.
1524 if (piocb->cmd_cmpl) { in lpfc_sli_cancel_iocbs()
1525 if (piocb->cmd_flag & LPFC_IO_NVME) { in lpfc_sli_cancel_iocbs()
1529 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_sli_cancel_iocbs()
1531 &piocb->wcqe_cmpl, ulpstatus); in lpfc_sli_cancel_iocbs()
1532 piocb->wcqe_cmpl.parameter = ulpWord4; in lpfc_sli_cancel_iocbs()
1534 piocb->iocb.ulpStatus = ulpstatus; in lpfc_sli_cancel_iocbs()
1535 piocb->iocb.un.ulpWord[4] = ulpWord4; in lpfc_sli_cancel_iocbs()
1537 (piocb->cmd_cmpl) (phba, piocb, piocb); in lpfc_sli_cancel_iocbs()
1547 * lpfc_sli_iocb_cmd_type - Get the iocb type
1650 printk("%s - Unhandled SLI-3 Command x%x\n", in lpfc_sli_iocb_cmd_type()
1663 * lpfc_sli_ring_map - Issue config_ring mbox for all rings
1669 * a config_ring mailbox command for each ring.
1676 struct lpfc_sli *psli = &phba->sli; in lpfc_sli_ring_map()
1681 pmb = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli_ring_map()
1683 return -ENOMEM; in lpfc_sli_ring_map()
1684 pmbox = &pmb->u.mb; in lpfc_sli_ring_map()
1685 phba->link_state = LPFC_INIT_MBX_CMDS; in lpfc_sli_ring_map()
1686 for (i = 0; i < psli->num_rings; i++) { in lpfc_sli_ring_map()
1694 rc, pmbox->mbxCommand, in lpfc_sli_ring_map()
1695 pmbox->mbxStatus, i); in lpfc_sli_ring_map()
1696 phba->link_state = LPFC_HBA_ERROR; in lpfc_sli_ring_map()
1697 ret = -ENXIO; in lpfc_sli_ring_map()
1701 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_sli_ring_map()
1706 * lpfc_sli_ringtxcmpl_put - Adds new iocb to the txcmplq
1727 list_add_tail(&piocb->list, &pring->txcmplq); in lpfc_sli_ringtxcmpl_put()
1728 piocb->cmd_flag |= LPFC_IO_ON_TXCMPLQ; in lpfc_sli_ringtxcmpl_put()
1729 pring->txcmplq_cnt++; in lpfc_sli_ringtxcmpl_put()
1730 if ((unlikely(pring->ringno == LPFC_ELS_RING)) && in lpfc_sli_ringtxcmpl_put()
1734 BUG_ON(!piocb->vport); in lpfc_sli_ringtxcmpl_put()
1735 if (!(piocb->vport->load_flag & FC_UNLOADING)) in lpfc_sli_ringtxcmpl_put()
1736 mod_timer(&piocb->vport->els_tmofunc, in lpfc_sli_ringtxcmpl_put()
1738 msecs_to_jiffies(1000 * (phba->fc_ratov << 1))); in lpfc_sli_ringtxcmpl_put()
1745 * lpfc_sli_ringtx_get - Get first element of the txq
1759 lockdep_assert_held(&phba->hbalock); in lpfc_sli_ringtx_get()
1761 list_remove_head((&pring->txq), cmd_iocb, struct lpfc_iocbq, list); in lpfc_sli_ringtx_get()
1766 * lpfc_cmf_sync_cmpl - Process a CMF_SYNC_WQE cmpl
1782 struct lpfc_wcqe_complete *wcqe = &rspiocb->wcqe_cmpl; in lpfc_cmf_sync_cmpl()
1799 wcqe->total_data_placed, in lpfc_cmf_sync_cmpl()
1800 wcqe->parameter); in lpfc_cmf_sync_cmpl()
1805 info = wcqe->parameter; in lpfc_cmf_sync_cmpl()
1806 phba->cmf_active_info = info; in lpfc_cmf_sync_cmpl()
1809 if (info > LPFC_MAX_CMF_INFO || phba->cmf_info_per_interval == info) in lpfc_cmf_sync_cmpl()
1812 phba->cmf_info_per_interval = info; in lpfc_cmf_sync_cmpl()
1827 wqe = &cmdiocb->wqe; in lpfc_cmf_sync_cmpl()
1828 asig = bf_get(cmf_sync_asig, &wqe->cmf_sync); in lpfc_cmf_sync_cmpl()
1829 afpin = bf_get(cmf_sync_afpin, &wqe->cmf_sync); in lpfc_cmf_sync_cmpl()
1830 fpincnt = bf_get(cmf_sync_wfpincnt, &wqe->cmf_sync); in lpfc_cmf_sync_cmpl()
1831 sigcnt = bf_get(cmf_sync_wsigcnt, &wqe->cmf_sync); in lpfc_cmf_sync_cmpl()
1832 if (phba->cmf_max_bytes_per_interval != bw || in lpfc_cmf_sync_cmpl()
1835 if (phba->cmf_max_bytes_per_interval < bw) { in lpfc_cmf_sync_cmpl()
1836 bwdif = bw - phba->cmf_max_bytes_per_interval; in lpfc_cmf_sync_cmpl()
1839 bwdif = phba->cmf_max_bytes_per_interval - bw; in lpfc_cmf_sync_cmpl()
1844 slop = div_u64(phba->cmf_link_byte_count, 200); /*For rounding*/ in lpfc_cmf_sync_cmpl()
1846 phba->cmf_link_byte_count); in lpfc_cmf_sync_cmpl()
1848 phba->cmf_link_byte_count); in lpfc_cmf_sync_cmpl()
1856 if (phba->cmf_max_bytes_per_interval < bw && in lpfc_cmf_sync_cmpl()
1861 else if ((phba->cmf_max_bytes_per_interval > bw) && in lpfc_cmf_sync_cmpl()
1873 phba->cmf_active_info); in lpfc_cmf_sync_cmpl()
1880 phba->cmf_active_info); in lpfc_cmf_sync_cmpl()
1882 wsigmax = bf_get(cmf_sync_wsigmax, &wqe->cmf_sync); in lpfc_cmf_sync_cmpl()
1888 wsigmax, cg, phba->cmf_active_info); in lpfc_cmf_sync_cmpl()
1890 wfpinmax = bf_get(cmf_sync_wfpinmax, &wqe->cmf_sync); in lpfc_cmf_sync_cmpl()
1896 wfpinmax, cg, phba->cmf_active_info); in lpfc_cmf_sync_cmpl()
1902 phba->cmf_active_info); in lpfc_cmf_sync_cmpl()
1910 phba->cmf_last_sync_bw = bw; in lpfc_cmf_sync_cmpl()
1916 * lpfc_issue_cmf_sync_wqe - Issue a CMF_SYNC_WQE
1938 atot = atomic_xchg(&phba->cgn_sync_alarm_cnt, 0); in lpfc_issue_cmf_sync_wqe()
1939 wtot = atomic_xchg(&phba->cgn_sync_warn_cnt, 0); in lpfc_issue_cmf_sync_wqe()
1942 if (phba->cmf_active_mode != LPFC_CFG_MANAGED || in lpfc_issue_cmf_sync_wqe()
1943 phba->link_state == LPFC_LINK_DOWN) in lpfc_issue_cmf_sync_wqe()
1946 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_issue_cmf_sync_wqe()
1955 wqe = &sync_buf->wqe; in lpfc_issue_cmf_sync_wqe()
1963 "6441 CMF Init %d - CMF_SYNC_WQE\n", in lpfc_issue_cmf_sync_wqe()
1964 phba->fc_eventTag); in lpfc_issue_cmf_sync_wqe()
1965 bf_set(cmf_sync_op, &wqe->cmf_sync, 1); /* 1=init */ in lpfc_issue_cmf_sync_wqe()
1966 bf_set(cmf_sync_interval, &wqe->cmf_sync, LPFC_CMF_INTERVAL); in lpfc_issue_cmf_sync_wqe()
1970 bf_set(cmf_sync_op, &wqe->cmf_sync, 0); /* 0=recalc */ in lpfc_issue_cmf_sync_wqe()
1971 bf_set(cmf_sync_interval, &wqe->cmf_sync, ms); in lpfc_issue_cmf_sync_wqe()
1975 if (phba->cgn_reg_signal == EDC_CG_SIG_WARN_ALARM) { in lpfc_issue_cmf_sync_wqe()
1977 bf_set(cmf_sync_asig, &wqe->cmf_sync, 1); in lpfc_issue_cmf_sync_wqe()
1980 bf_set(cmf_sync_afpin, &wqe->cmf_sync, 1); in lpfc_issue_cmf_sync_wqe()
1983 if (phba->cgn_reg_signal == EDC_CG_SIG_WARN_ONLY || in lpfc_issue_cmf_sync_wqe()
1984 phba->cgn_reg_signal == EDC_CG_SIG_WARN_ALARM) { in lpfc_issue_cmf_sync_wqe()
1988 bf_set(cmf_sync_wsigmax, &wqe->cmf_sync, max); in lpfc_issue_cmf_sync_wqe()
1989 bf_set(cmf_sync_wsigcnt, &wqe->cmf_sync, wtot); in lpfc_issue_cmf_sync_wqe()
1993 bf_set(cmf_sync_wfpinmax, &wqe->cmf_sync, 1); in lpfc_issue_cmf_sync_wqe()
1994 bf_set(cmf_sync_wfpincnt, &wqe->cmf_sync, 1); in lpfc_issue_cmf_sync_wqe()
1995 if (phba->cgn_fpin_frequency != LPFC_FPIN_INIT_FREQ) in lpfc_issue_cmf_sync_wqe()
1997 LPFC_MSECS_TO_SECS(phba->cgn_fpin_frequency); in lpfc_issue_cmf_sync_wqe()
2002 wqe->cmf_sync.read_bytes = (u32)(total / LPFC_CMF_BLK_SIZE); in lpfc_issue_cmf_sync_wqe()
2005 bf_set(cmf_sync_ver, &wqe->cmf_sync, LPFC_CMF_SYNC_VER); in lpfc_issue_cmf_sync_wqe()
2006 wqe->cmf_sync.event_tag = phba->fc_eventTag; in lpfc_issue_cmf_sync_wqe()
2007 bf_set(cmf_sync_cmnd, &wqe->cmf_sync, CMD_CMF_SYNC_WQE); in lpfc_issue_cmf_sync_wqe()
2010 bf_set(cmf_sync_reqtag, &wqe->cmf_sync, sync_buf->iotag); in lpfc_issue_cmf_sync_wqe()
2012 bf_set(cmf_sync_qosd, &wqe->cmf_sync, 1); in lpfc_issue_cmf_sync_wqe()
2013 bf_set(cmf_sync_period, &wqe->cmf_sync, warn_sync_period); in lpfc_issue_cmf_sync_wqe()
2015 bf_set(cmf_sync_cmd_type, &wqe->cmf_sync, CMF_SYNC_COMMAND); in lpfc_issue_cmf_sync_wqe()
2016 bf_set(cmf_sync_wqec, &wqe->cmf_sync, 1); in lpfc_issue_cmf_sync_wqe()
2017 bf_set(cmf_sync_cqid, &wqe->cmf_sync, LPFC_WQE_CQ_ID_DEFAULT); in lpfc_issue_cmf_sync_wqe()
2019 sync_buf->vport = phba->pport; in lpfc_issue_cmf_sync_wqe()
2020 sync_buf->cmd_cmpl = lpfc_cmf_sync_cmpl; in lpfc_issue_cmf_sync_wqe()
2021 sync_buf->cmd_dmabuf = NULL; in lpfc_issue_cmf_sync_wqe()
2022 sync_buf->rsp_dmabuf = NULL; in lpfc_issue_cmf_sync_wqe()
2023 sync_buf->bpl_dmabuf = NULL; in lpfc_issue_cmf_sync_wqe()
2024 sync_buf->sli4_xritag = NO_XRI; in lpfc_issue_cmf_sync_wqe()
2026 sync_buf->cmd_flag |= LPFC_IO_CMF; in lpfc_issue_cmf_sync_wqe()
2027 ret_val = lpfc_sli4_issue_wqe(phba, &phba->sli4_hba.hdwq[0], sync_buf); in lpfc_issue_cmf_sync_wqe()
2035 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_issue_cmf_sync_wqe()
2040 * lpfc_sli_next_iocb_slot - Get next iocb slot in the ring
2056 struct lpfc_pgp *pgp = &phba->port_gp[pring->ringno]; in lpfc_sli_next_iocb_slot()
2057 uint32_t max_cmd_idx = pring->sli.sli3.numCiocb; in lpfc_sli_next_iocb_slot()
2059 lockdep_assert_held(&phba->hbalock); in lpfc_sli_next_iocb_slot()
2061 if ((pring->sli.sli3.next_cmdidx == pring->sli.sli3.cmdidx) && in lpfc_sli_next_iocb_slot()
2062 (++pring->sli.sli3.next_cmdidx >= max_cmd_idx)) in lpfc_sli_next_iocb_slot()
2063 pring->sli.sli3.next_cmdidx = 0; in lpfc_sli_next_iocb_slot()
2065 if (unlikely(pring->sli.sli3.local_getidx == in lpfc_sli_next_iocb_slot()
2066 pring->sli.sli3.next_cmdidx)) { in lpfc_sli_next_iocb_slot()
2068 pring->sli.sli3.local_getidx = le32_to_cpu(pgp->cmdGetInx); in lpfc_sli_next_iocb_slot()
2070 if (unlikely(pring->sli.sli3.local_getidx >= max_cmd_idx)) { in lpfc_sli_next_iocb_slot()
2074 pring->ringno, in lpfc_sli_next_iocb_slot()
2075 pring->sli.sli3.local_getidx, in lpfc_sli_next_iocb_slot()
2078 phba->link_state = LPFC_HBA_ERROR; in lpfc_sli_next_iocb_slot()
2083 phba->work_ha |= HA_ERATT; in lpfc_sli_next_iocb_slot()
2084 phba->work_hs = HS_FFER3; in lpfc_sli_next_iocb_slot()
2091 if (pring->sli.sli3.local_getidx == pring->sli.sli3.next_cmdidx) in lpfc_sli_next_iocb_slot()
2099 * lpfc_sli_next_iotag - Get an iotag for the iocb
2116 struct lpfc_sli *psli = &phba->sli; in lpfc_sli_next_iotag()
2119 spin_lock_irq(&phba->hbalock); in lpfc_sli_next_iotag()
2120 iotag = psli->last_iotag; in lpfc_sli_next_iotag()
2121 if(++iotag < psli->iocbq_lookup_len) { in lpfc_sli_next_iotag()
2122 psli->last_iotag = iotag; in lpfc_sli_next_iotag()
2123 psli->iocbq_lookup[iotag] = iocbq; in lpfc_sli_next_iotag()
2124 spin_unlock_irq(&phba->hbalock); in lpfc_sli_next_iotag()
2125 iocbq->iotag = iotag; in lpfc_sli_next_iotag()
2127 } else if (psli->iocbq_lookup_len < (0xffff in lpfc_sli_next_iotag()
2128 - LPFC_IOCBQ_LOOKUP_INCREMENT)) { in lpfc_sli_next_iotag()
2129 new_len = psli->iocbq_lookup_len + LPFC_IOCBQ_LOOKUP_INCREMENT; in lpfc_sli_next_iotag()
2130 spin_unlock_irq(&phba->hbalock); in lpfc_sli_next_iotag()
2134 spin_lock_irq(&phba->hbalock); in lpfc_sli_next_iotag()
2135 old_arr = psli->iocbq_lookup; in lpfc_sli_next_iotag()
2136 if (new_len <= psli->iocbq_lookup_len) { in lpfc_sli_next_iotag()
2139 iotag = psli->last_iotag; in lpfc_sli_next_iotag()
2140 if(++iotag < psli->iocbq_lookup_len) { in lpfc_sli_next_iotag()
2141 psli->last_iotag = iotag; in lpfc_sli_next_iotag()
2142 psli->iocbq_lookup[iotag] = iocbq; in lpfc_sli_next_iotag()
2143 spin_unlock_irq(&phba->hbalock); in lpfc_sli_next_iotag()
2144 iocbq->iotag = iotag; in lpfc_sli_next_iotag()
2147 spin_unlock_irq(&phba->hbalock); in lpfc_sli_next_iotag()
2150 if (psli->iocbq_lookup) in lpfc_sli_next_iotag()
2152 ((psli->last_iotag + 1) * in lpfc_sli_next_iotag()
2154 psli->iocbq_lookup = new_arr; in lpfc_sli_next_iotag()
2155 psli->iocbq_lookup_len = new_len; in lpfc_sli_next_iotag()
2156 psli->last_iotag = iotag; in lpfc_sli_next_iotag()
2157 psli->iocbq_lookup[iotag] = iocbq; in lpfc_sli_next_iotag()
2158 spin_unlock_irq(&phba->hbalock); in lpfc_sli_next_iotag()
2159 iocbq->iotag = iotag; in lpfc_sli_next_iotag()
2164 spin_unlock_irq(&phba->hbalock); in lpfc_sli_next_iotag()
2168 psli->last_iotag); in lpfc_sli_next_iotag()
2174 * lpfc_sli_submit_iocb - Submit an iocb to the firmware
2195 nextiocb->iocb.ulpIoTag = (nextiocb->cmd_cmpl) ? nextiocb->iotag : 0; in lpfc_sli_submit_iocb()
2198 if (pring->ringno == LPFC_ELS_RING) { in lpfc_sli_submit_iocb()
2201 *(((uint32_t *) &nextiocb->iocb) + 4), in lpfc_sli_submit_iocb()
2202 *(((uint32_t *) &nextiocb->iocb) + 6), in lpfc_sli_submit_iocb()
2203 *(((uint32_t *) &nextiocb->iocb) + 7)); in lpfc_sli_submit_iocb()
2209 lpfc_sli_pcimem_bcopy(&nextiocb->iocb, iocb, phba->iocb_cmd_size); in lpfc_sli_submit_iocb()
2211 pring->stats.iocb_cmd++; in lpfc_sli_submit_iocb()
2218 if (nextiocb->cmd_cmpl) in lpfc_sli_submit_iocb()
2227 pring->sli.sli3.cmdidx = pring->sli.sli3.next_cmdidx; in lpfc_sli_submit_iocb()
2228 writel(pring->sli.sli3.cmdidx, &phba->host_gp[pring->ringno].cmdPutInx); in lpfc_sli_submit_iocb()
2232 * lpfc_sli_update_full_ring - Update the chip attention register
2246 int ringno = pring->ringno; in lpfc_sli_update_full_ring()
2248 pring->flag |= LPFC_CALL_RING_AVAILABLE; in lpfc_sli_update_full_ring()
2256 writel((CA_R0ATT|CA_R0CE_REQ) << (ringno*4), phba->CAregaddr); in lpfc_sli_update_full_ring()
2257 readl(phba->CAregaddr); /* flush */ in lpfc_sli_update_full_ring()
2259 pring->stats.iocb_cmd_full++; in lpfc_sli_update_full_ring()
2263 * lpfc_sli_update_ring - Update chip attention register
2274 int ringno = pring->ringno; in lpfc_sli_update_ring()
2279 if (!(phba->sli3_options & LPFC_SLI3_CRP_ENABLED)) { in lpfc_sli_update_ring()
2281 writel(CA_R0ATT << (ringno * 4), phba->CAregaddr); in lpfc_sli_update_ring()
2282 readl(phba->CAregaddr); /* flush */ in lpfc_sli_update_ring()
2287 * lpfc_sli_resume_iocb - Process iocbs in the txq
2301 lockdep_assert_held(&phba->hbalock); in lpfc_sli_resume_iocb()
2312 (!list_empty(&pring->txq)) && in lpfc_sli_resume_iocb()
2313 (pring->ringno != LPFC_FCP_RING || in lpfc_sli_resume_iocb()
2314 phba->sli.sli_flag & LPFC_PROCESS_LA)) { in lpfc_sli_resume_iocb()
2330 * lpfc_sli_next_hbq_slot - Get next hbq entry for the HBQ
2342 struct hbq_s *hbqp = &phba->hbqs[hbqno]; in lpfc_sli_next_hbq_slot()
2344 lockdep_assert_held(&phba->hbalock); in lpfc_sli_next_hbq_slot()
2346 if (hbqp->next_hbqPutIdx == hbqp->hbqPutIdx && in lpfc_sli_next_hbq_slot()
2347 ++hbqp->next_hbqPutIdx >= hbqp->entry_count) in lpfc_sli_next_hbq_slot()
2348 hbqp->next_hbqPutIdx = 0; in lpfc_sli_next_hbq_slot()
2350 if (unlikely(hbqp->local_hbqGetIdx == hbqp->next_hbqPutIdx)) { in lpfc_sli_next_hbq_slot()
2351 uint32_t raw_index = phba->hbq_get[hbqno]; in lpfc_sli_next_hbq_slot()
2354 hbqp->local_hbqGetIdx = getidx; in lpfc_sli_next_hbq_slot()
2356 if (unlikely(hbqp->local_hbqGetIdx >= hbqp->entry_count)) { in lpfc_sli_next_hbq_slot()
2359 "%u is > than hbqp->entry_count %u\n", in lpfc_sli_next_hbq_slot()
2360 hbqno, hbqp->local_hbqGetIdx, in lpfc_sli_next_hbq_slot()
2361 hbqp->entry_count); in lpfc_sli_next_hbq_slot()
2363 phba->link_state = LPFC_HBA_ERROR; in lpfc_sli_next_hbq_slot()
2367 if (hbqp->local_hbqGetIdx == hbqp->next_hbqPutIdx) in lpfc_sli_next_hbq_slot()
2371 return (struct lpfc_hbq_entry *) phba->hbqs[hbqno].hbq_virt + in lpfc_sli_next_hbq_slot()
2372 hbqp->hbqPutIdx; in lpfc_sli_next_hbq_slot()
2376 * lpfc_sli_hbqbuf_free_all - Free all the hbq buffers
2394 spin_lock_irqsave(&phba->hbalock, flags); in lpfc_sli_hbqbuf_free_all()
2397 &phba->hbqs[i].hbq_buffer_list, list) { in lpfc_sli_hbqbuf_free_all()
2399 list_del(&hbq_buf->dbuf.list); in lpfc_sli_hbqbuf_free_all()
2400 (phba->hbqs[i].hbq_free_buffer)(phba, hbq_buf); in lpfc_sli_hbqbuf_free_all()
2402 phba->hbqs[i].buffer_count = 0; in lpfc_sli_hbqbuf_free_all()
2406 phba->hbq_in_use = 0; in lpfc_sli_hbqbuf_free_all()
2407 spin_unlock_irqrestore(&phba->hbalock, flags); in lpfc_sli_hbqbuf_free_all()
2411 * lpfc_sli_hbq_to_firmware - Post the hbq buffer to firmware
2426 lockdep_assert_held(&phba->hbalock); in lpfc_sli_hbq_to_firmware()
2427 return phba->lpfc_sli_hbq_to_firmware(phba, hbqno, hbq_buf); in lpfc_sli_hbq_to_firmware()
2431 * lpfc_sli_hbq_to_firmware_s3 - Post the hbq buffer to SLI3 firmware
2446 dma_addr_t physaddr = hbq_buf->dbuf.phys; in lpfc_sli_hbq_to_firmware_s3()
2448 lockdep_assert_held(&phba->hbalock); in lpfc_sli_hbq_to_firmware_s3()
2452 struct hbq_s *hbqp = &phba->hbqs[hbqno]; in lpfc_sli_hbq_to_firmware_s3()
2454 hbqe->bde.addrHigh = le32_to_cpu(putPaddrHigh(physaddr)); in lpfc_sli_hbq_to_firmware_s3()
2455 hbqe->bde.addrLow = le32_to_cpu(putPaddrLow(physaddr)); in lpfc_sli_hbq_to_firmware_s3()
2456 hbqe->bde.tus.f.bdeSize = hbq_buf->total_size; in lpfc_sli_hbq_to_firmware_s3()
2457 hbqe->bde.tus.f.bdeFlags = 0; in lpfc_sli_hbq_to_firmware_s3()
2458 hbqe->bde.tus.w = le32_to_cpu(hbqe->bde.tus.w); in lpfc_sli_hbq_to_firmware_s3()
2459 hbqe->buffer_tag = le32_to_cpu(hbq_buf->tag); in lpfc_sli_hbq_to_firmware_s3()
2461 hbqp->hbqPutIdx = hbqp->next_hbqPutIdx; in lpfc_sli_hbq_to_firmware_s3()
2462 writel(hbqp->hbqPutIdx, phba->hbq_put + hbqno); in lpfc_sli_hbq_to_firmware_s3()
2464 readl(phba->hbq_put + hbqno); in lpfc_sli_hbq_to_firmware_s3()
2465 list_add_tail(&hbq_buf->dbuf.list, &hbqp->hbq_buffer_list); in lpfc_sli_hbq_to_firmware_s3()
2468 return -ENOMEM; in lpfc_sli_hbq_to_firmware_s3()
2472 * lpfc_sli_hbq_to_firmware_s4 - Post the hbq buffer to SLI4 firmware
2493 hrq = phba->sli4_hba.hdr_rq; in lpfc_sli_hbq_to_firmware_s4()
2494 drq = phba->sli4_hba.dat_rq; in lpfc_sli_hbq_to_firmware_s4()
2496 lockdep_assert_held(&phba->hbalock); in lpfc_sli_hbq_to_firmware_s4()
2497 hrqe.address_lo = putPaddrLow(hbq_buf->hbuf.phys); in lpfc_sli_hbq_to_firmware_s4()
2498 hrqe.address_hi = putPaddrHigh(hbq_buf->hbuf.phys); in lpfc_sli_hbq_to_firmware_s4()
2499 drqe.address_lo = putPaddrLow(hbq_buf->dbuf.phys); in lpfc_sli_hbq_to_firmware_s4()
2500 drqe.address_hi = putPaddrHigh(hbq_buf->dbuf.phys); in lpfc_sli_hbq_to_firmware_s4()
2504 hbq_buf->tag = (rc | (hbqno << 16)); in lpfc_sli_hbq_to_firmware_s4()
2505 list_add_tail(&hbq_buf->dbuf.list, &phba->hbqs[hbqno].hbq_buffer_list); in lpfc_sli_hbq_to_firmware_s4()
2527 * lpfc_sli_hbqbuf_fill_hbqs - Post more hbq buffers to HBQ
2543 if (!phba->hbqs[hbqno].hbq_alloc_buffer) in lpfc_sli_hbqbuf_fill_hbqs()
2546 if ((phba->hbqs[hbqno].buffer_count + count) > in lpfc_sli_hbqbuf_fill_hbqs()
2547 lpfc_hbq_defs[hbqno]->entry_count) in lpfc_sli_hbqbuf_fill_hbqs()
2548 count = lpfc_hbq_defs[hbqno]->entry_count - in lpfc_sli_hbqbuf_fill_hbqs()
2549 phba->hbqs[hbqno].buffer_count; in lpfc_sli_hbqbuf_fill_hbqs()
2554 hbq_buffer = (phba->hbqs[hbqno].hbq_alloc_buffer)(phba); in lpfc_sli_hbqbuf_fill_hbqs()
2557 list_add_tail(&hbq_buffer->dbuf.list, &hbq_buf_list); in lpfc_sli_hbqbuf_fill_hbqs()
2560 spin_lock_irqsave(&phba->hbalock, flags); in lpfc_sli_hbqbuf_fill_hbqs()
2561 if (!phba->hbq_in_use) in lpfc_sli_hbqbuf_fill_hbqs()
2566 hbq_buffer->tag = (phba->hbqs[hbqno].buffer_count | in lpfc_sli_hbqbuf_fill_hbqs()
2569 phba->hbqs[hbqno].buffer_count++; in lpfc_sli_hbqbuf_fill_hbqs()
2572 (phba->hbqs[hbqno].hbq_free_buffer)(phba, hbq_buffer); in lpfc_sli_hbqbuf_fill_hbqs()
2574 spin_unlock_irqrestore(&phba->hbalock, flags); in lpfc_sli_hbqbuf_fill_hbqs()
2577 spin_unlock_irqrestore(&phba->hbalock, flags); in lpfc_sli_hbqbuf_fill_hbqs()
2581 (phba->hbqs[hbqno].hbq_free_buffer)(phba, hbq_buffer); in lpfc_sli_hbqbuf_fill_hbqs()
2587 * lpfc_sli_hbqbuf_add_hbqs - Post more HBQ buffers to firmware
2598 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_sli_hbqbuf_add_hbqs()
2602 lpfc_hbq_defs[qno]->add_count); in lpfc_sli_hbqbuf_add_hbqs()
2606 * lpfc_sli_hbqbuf_init_hbqs - Post initial buffers to the HBQ
2617 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_sli_hbqbuf_init_hbqs()
2619 lpfc_hbq_defs[qno]->entry_count); in lpfc_sli_hbqbuf_init_hbqs()
2622 lpfc_hbq_defs[qno]->init_count); in lpfc_sli_hbqbuf_init_hbqs()
2626 * lpfc_sli_hbqbuf_get - Remove the first hbq off of an hbq list
2643 * lpfc_sli_rqbuf_get - Remove the first dma buffer off of an RQ list
2656 rqbp = hrq->rqbp; in lpfc_sli_rqbuf_get()
2657 list_remove_head(&rqbp->rqb_buffer_list, h_buf, in lpfc_sli_rqbuf_get()
2661 rqbp->buffer_count--; in lpfc_sli_rqbuf_get()
2666 * lpfc_sli_hbqbuf_find - Find the hbq buffer associated with a tag
2685 spin_lock_irq(&phba->hbalock); in lpfc_sli_hbqbuf_find()
2686 list_for_each_entry(d_buf, &phba->hbqs[hbqno].hbq_buffer_list, list) { in lpfc_sli_hbqbuf_find()
2688 if (hbq_buf->tag == tag) { in lpfc_sli_hbqbuf_find()
2689 spin_unlock_irq(&phba->hbalock); in lpfc_sli_hbqbuf_find()
2693 spin_unlock_irq(&phba->hbalock); in lpfc_sli_hbqbuf_find()
2696 tag, phba->hbqs[tag >> 16].buffer_count); in lpfc_sli_hbqbuf_find()
2701 * lpfc_sli_free_hbq - Give back the hbq buffer to firmware
2715 hbqno = hbq_buffer->tag >> 16; in lpfc_sli_free_hbq()
2717 (phba->hbqs[hbqno].hbq_free_buffer)(phba, hbq_buffer); in lpfc_sli_free_hbq()
2722 * lpfc_sli_chk_mbx_command - Check if the mailbox is a legitimate mailbox
2723 * @mbxCommand: mailbox command code.
2725 * This function is called by the mailbox event handler function to verify
2726 * that the completed mailbox command is a legitimate mailbox command. If the
2727 * completed mailbox is not known to the function, it will return MBX_SHUTDOWN
2728 * and the mailbox event handler will take the HBA offline.
2811 * lpfc_sli_wake_mbox_wait - lpfc_sli_issue_mbox_wait mbox completion handler
2813 * @pmboxq: Pointer to mailbox command.
2815 * This is completion handler function for mailbox commands issued from
2817 * mailbox event handler function with no lock held. This function
2819 * of the mailbox.
2831 pmboxq->mbox_flag |= LPFC_MBX_WAKE; in lpfc_sli_wake_mbox_wait()
2832 spin_lock_irqsave(&phba->hbalock, drvr_flag); in lpfc_sli_wake_mbox_wait()
2833 pmbox_done = (struct completion *)pmboxq->context3; in lpfc_sli_wake_mbox_wait()
2836 spin_unlock_irqrestore(&phba->hbalock, drvr_flag); in lpfc_sli_wake_mbox_wait()
2845 if (ndlp->nlp_flag & NLP_RELEASE_RPI) { in __lpfc_sli_rpi_release()
2846 lpfc_sli4_free_rpi(vport->phba, ndlp->nlp_rpi); in __lpfc_sli_rpi_release()
2847 spin_lock_irqsave(&ndlp->lock, iflags); in __lpfc_sli_rpi_release()
2848 ndlp->nlp_flag &= ~NLP_RELEASE_RPI; in __lpfc_sli_rpi_release()
2849 ndlp->nlp_rpi = LPFC_RPI_ALLOC_ERROR; in __lpfc_sli_rpi_release()
2850 spin_unlock_irqrestore(&ndlp->lock, iflags); in __lpfc_sli_rpi_release()
2852 ndlp->nlp_flag &= ~NLP_UNREG_INP; in __lpfc_sli_rpi_release()
2862 * lpfc_sli_def_mbox_cmpl - Default mailbox completion handler
2864 * @pmb: Pointer to mailbox object.
2866 * This function is the default mailbox completion handler. It
2867 * frees the memory resources associated with the completed mailbox
2868 * command. If the completed command is a REG_LOGIN mailbox command,
2869 * this function will issue a UREG_LOGIN to re-claim the RPI.
2874 struct lpfc_vport *vport = pmb->vport; in lpfc_sli_def_mbox_cmpl()
2883 * is in re-discovery driver need to cleanup the RPI. in lpfc_sli_def_mbox_cmpl()
2885 if (!(phba->pport->load_flag & FC_UNLOADING) && in lpfc_sli_def_mbox_cmpl()
2886 pmb->u.mb.mbxCommand == MBX_REG_LOGIN64 && in lpfc_sli_def_mbox_cmpl()
2887 !pmb->u.mb.mbxStatus) { in lpfc_sli_def_mbox_cmpl()
2888 mp = (struct lpfc_dmabuf *)pmb->ctx_buf; in lpfc_sli_def_mbox_cmpl()
2890 pmb->ctx_buf = NULL; in lpfc_sli_def_mbox_cmpl()
2891 lpfc_mbuf_free(phba, mp->virt, mp->phys); in lpfc_sli_def_mbox_cmpl()
2894 rpi = pmb->u.mb.un.varWords[0]; in lpfc_sli_def_mbox_cmpl()
2895 vpi = pmb->u.mb.un.varRegLogin.vpi; in lpfc_sli_def_mbox_cmpl()
2896 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_sli_def_mbox_cmpl()
2897 vpi -= phba->sli4_hba.max_cfg_param.vpi_base; in lpfc_sli_def_mbox_cmpl()
2899 pmb->vport = vport; in lpfc_sli_def_mbox_cmpl()
2900 pmb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_sli_def_mbox_cmpl()
2906 if ((pmb->u.mb.mbxCommand == MBX_REG_VPI) && in lpfc_sli_def_mbox_cmpl()
2907 !(phba->pport->load_flag & FC_UNLOADING) && in lpfc_sli_def_mbox_cmpl()
2908 !pmb->u.mb.mbxStatus) { in lpfc_sli_def_mbox_cmpl()
2910 spin_lock_irq(shost->host_lock); in lpfc_sli_def_mbox_cmpl()
2911 vport->vpi_state |= LPFC_VPI_REGISTERED; in lpfc_sli_def_mbox_cmpl()
2912 vport->fc_flag &= ~FC_VPORT_NEEDS_REG_VPI; in lpfc_sli_def_mbox_cmpl()
2913 spin_unlock_irq(shost->host_lock); in lpfc_sli_def_mbox_cmpl()
2916 if (pmb->u.mb.mbxCommand == MBX_REG_LOGIN64) { in lpfc_sli_def_mbox_cmpl()
2917 ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp; in lpfc_sli_def_mbox_cmpl()
2921 if (pmb->u.mb.mbxCommand == MBX_UNREG_LOGIN) { in lpfc_sli_def_mbox_cmpl()
2922 ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp; in lpfc_sli_def_mbox_cmpl()
2931 ndlp->nlp_rpi, ndlp->nlp_DID, in lpfc_sli_def_mbox_cmpl()
2932 ndlp->nlp_flag, ndlp->nlp_defer_did, in lpfc_sli_def_mbox_cmpl()
2933 ndlp, vport->load_flag, kref_read(&ndlp->kref)); in lpfc_sli_def_mbox_cmpl()
2935 if ((ndlp->nlp_flag & NLP_UNREG_INP) && in lpfc_sli_def_mbox_cmpl()
2936 (ndlp->nlp_defer_did != NLP_EVT_NOTHING_PENDING)) { in lpfc_sli_def_mbox_cmpl()
2937 ndlp->nlp_flag &= ~NLP_UNREG_INP; in lpfc_sli_def_mbox_cmpl()
2938 ndlp->nlp_defer_did = NLP_EVT_NOTHING_PENDING; in lpfc_sli_def_mbox_cmpl()
2939 lpfc_issue_els_plogi(vport, ndlp->nlp_DID, 0); in lpfc_sli_def_mbox_cmpl()
2944 /* The unreg_login mailbox is complete and had a in lpfc_sli_def_mbox_cmpl()
2949 pmb->ctx_ndlp = NULL; in lpfc_sli_def_mbox_cmpl()
2954 if (pmb->u.mb.mbxCommand == MBX_RESUME_RPI) { in lpfc_sli_def_mbox_cmpl()
2955 ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp; in lpfc_sli_def_mbox_cmpl()
2959 /* Check security permission status on INIT_LINK mailbox command */ in lpfc_sli_def_mbox_cmpl()
2960 if ((pmb->u.mb.mbxCommand == MBX_INIT_LINK) && in lpfc_sli_def_mbox_cmpl()
2961 (pmb->u.mb.mbxStatus == MBXERR_SEC_NO_PERMISSION)) in lpfc_sli_def_mbox_cmpl()
2966 if (bf_get(lpfc_mqe_command, &pmb->u.mqe) == MBX_SLI4_CONFIG) in lpfc_sli_def_mbox_cmpl()
2972 * lpfc_sli4_unreg_rpi_cmpl_clr - mailbox completion handler
2974 * @pmb: Pointer to mailbox object.
2976 * This function is the unreg rpi mailbox completion handler. It
2977 * frees the memory resources associated with the completed mailbox
2980 * the unreg mailbox command completes, this routine puts the
2987 struct lpfc_vport *vport = pmb->vport; in lpfc_sli4_unreg_rpi_cmpl_clr()
2990 ndlp = pmb->ctx_ndlp; in lpfc_sli4_unreg_rpi_cmpl_clr()
2991 if (pmb->u.mb.mbxCommand == MBX_UNREG_LOGIN) { in lpfc_sli4_unreg_rpi_cmpl_clr()
2992 if (phba->sli_rev == LPFC_SLI_REV4 && in lpfc_sli4_unreg_rpi_cmpl_clr()
2994 &phba->sli4_hba.sli_intf) >= in lpfc_sli4_unreg_rpi_cmpl_clr()
3003 vport->vpi, ndlp->nlp_rpi, in lpfc_sli4_unreg_rpi_cmpl_clr()
3004 ndlp->nlp_DID, ndlp->nlp_defer_did, in lpfc_sli4_unreg_rpi_cmpl_clr()
3005 ndlp->nlp_flag, in lpfc_sli4_unreg_rpi_cmpl_clr()
3007 ndlp->nlp_flag &= ~NLP_LOGO_ACC; in lpfc_sli4_unreg_rpi_cmpl_clr()
3012 if ((ndlp->nlp_flag & NLP_UNREG_INP) && in lpfc_sli4_unreg_rpi_cmpl_clr()
3013 (ndlp->nlp_defer_did != in lpfc_sli4_unreg_rpi_cmpl_clr()
3021 ndlp->nlp_rpi, ndlp->nlp_DID, in lpfc_sli4_unreg_rpi_cmpl_clr()
3022 ndlp->nlp_defer_did, ndlp); in lpfc_sli4_unreg_rpi_cmpl_clr()
3023 ndlp->nlp_flag &= ~NLP_UNREG_INP; in lpfc_sli4_unreg_rpi_cmpl_clr()
3024 ndlp->nlp_defer_did = in lpfc_sli4_unreg_rpi_cmpl_clr()
3027 vport, ndlp->nlp_DID, 0); in lpfc_sli4_unreg_rpi_cmpl_clr()
3036 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_sli4_unreg_rpi_cmpl_clr()
3040 * lpfc_sli_handle_mb_event - Handle mailbox completions from firmware
3044 * the completed mailbox commands and gives it to upper layers. The interrupt
3045 * service routine processes mailbox completion interrupt and adds completed
3046 * mailbox commands to the mboxq_cmpl queue and signals the worker thread.
3048 * completed mailbox commands in mboxq_cmpl queue to the upper layers. This
3049 * function returns the mailbox commands to the upper layer by calling the
3050 * completion handler function of each mailbox.
3060 phba->sli.slistat.mbox_event++; in lpfc_sli_handle_mb_event()
3063 spin_lock_irq(&phba->hbalock); in lpfc_sli_handle_mb_event()
3064 list_splice_init(&phba->sli.mboxq_cmpl, &cmplq); in lpfc_sli_handle_mb_event()
3065 spin_unlock_irq(&phba->hbalock); in lpfc_sli_handle_mb_event()
3067 /* Get a Mailbox buffer to setup mailbox commands for callback */ in lpfc_sli_handle_mb_event()
3073 pmbox = &pmb->u.mb; in lpfc_sli_handle_mb_event()
3075 if (pmbox->mbxCommand != MBX_HEARTBEAT) { in lpfc_sli_handle_mb_event()
3076 if (pmb->vport) { in lpfc_sli_handle_mb_event()
3077 lpfc_debugfs_disc_trc(pmb->vport, in lpfc_sli_handle_mb_event()
3080 (uint32_t)pmbox->mbxCommand, in lpfc_sli_handle_mb_event()
3081 pmbox->un.varWords[0], in lpfc_sli_handle_mb_event()
3082 pmbox->un.varWords[1]); in lpfc_sli_handle_mb_event()
3085 lpfc_debugfs_disc_trc(phba->pport, in lpfc_sli_handle_mb_event()
3088 (uint32_t)pmbox->mbxCommand, in lpfc_sli_handle_mb_event()
3089 pmbox->un.varWords[0], in lpfc_sli_handle_mb_event()
3090 pmbox->un.varWords[1]); in lpfc_sli_handle_mb_event()
3097 if (lpfc_sli_chk_mbx_command(pmbox->mbxCommand) == in lpfc_sli_handle_mb_event()
3099 /* Unknown mailbox command compl */ in lpfc_sli_handle_mb_event()
3101 "(%d):0323 Unknown Mailbox command " in lpfc_sli_handle_mb_event()
3103 pmb->vport ? pmb->vport->vpi : in lpfc_sli_handle_mb_event()
3105 pmbox->mbxCommand, in lpfc_sli_handle_mb_event()
3110 phba->link_state = LPFC_HBA_ERROR; in lpfc_sli_handle_mb_event()
3111 phba->work_hs = HS_FFER3; in lpfc_sli_handle_mb_event()
3116 if (pmbox->mbxStatus) { in lpfc_sli_handle_mb_event()
3117 phba->sli.slistat.mbox_stat_err++; in lpfc_sli_handle_mb_event()
3118 if (pmbox->mbxStatus == MBXERR_NO_RESOURCES) { in lpfc_sli_handle_mb_event()
3119 /* Mbox cmd cmpl error - RETRYing */ in lpfc_sli_handle_mb_event()
3123 "error - RETRYing Data: x%x " in lpfc_sli_handle_mb_event()
3125 pmb->vport ? pmb->vport->vpi : in lpfc_sli_handle_mb_event()
3127 pmbox->mbxCommand, in lpfc_sli_handle_mb_event()
3132 pmbox->mbxStatus, in lpfc_sli_handle_mb_event()
3133 pmbox->un.varWords[0], in lpfc_sli_handle_mb_event()
3134 pmb->vport ? pmb->vport->port_state : in lpfc_sli_handle_mb_event()
3136 pmbox->mbxStatus = 0; in lpfc_sli_handle_mb_event()
3137 pmbox->mbxOwner = OWN_HOST; in lpfc_sli_handle_mb_event()
3144 /* Mailbox cmd <cmd> Cmpl <cmpl> */ in lpfc_sli_handle_mb_event()
3146 "(%d):0307 Mailbox cmd x%x (x%x/x%x) Cmpl %ps " in lpfc_sli_handle_mb_event()
3149 pmb->vport ? pmb->vport->vpi : 0, in lpfc_sli_handle_mb_event()
3150 pmbox->mbxCommand, in lpfc_sli_handle_mb_event()
3153 pmb->mbox_cmpl, in lpfc_sli_handle_mb_event()
3155 pmbox->un.varWords[0], in lpfc_sli_handle_mb_event()
3156 pmbox->un.varWords[1], in lpfc_sli_handle_mb_event()
3157 pmbox->un.varWords[2], in lpfc_sli_handle_mb_event()
3158 pmbox->un.varWords[3], in lpfc_sli_handle_mb_event()
3159 pmbox->un.varWords[4], in lpfc_sli_handle_mb_event()
3160 pmbox->un.varWords[5], in lpfc_sli_handle_mb_event()
3161 pmbox->un.varWords[6], in lpfc_sli_handle_mb_event()
3162 pmbox->un.varWords[7], in lpfc_sli_handle_mb_event()
3163 pmbox->un.varWords[8], in lpfc_sli_handle_mb_event()
3164 pmbox->un.varWords[9], in lpfc_sli_handle_mb_event()
3165 pmbox->un.varWords[10]); in lpfc_sli_handle_mb_event()
3167 if (pmb->mbox_cmpl) in lpfc_sli_handle_mb_event()
3168 pmb->mbox_cmpl(phba,pmb); in lpfc_sli_handle_mb_event()
3174 * lpfc_sli_get_buff - Get the buffer associated with the buffer tag
3197 return &hbq_entry->dbuf; in lpfc_sli_get_buff()
3201 * lpfc_nvme_unsol_ls_handler - Process an unsolicited event data buffer
3223 d_buf = piocb->cmd_dmabuf; in lpfc_nvme_unsol_ls_handler()
3226 fc_hdr = nvmebuf->hbuf.virt; in lpfc_nvme_unsol_ls_handler()
3227 oxid = be16_to_cpu(fc_hdr->fh_ox_id); in lpfc_nvme_unsol_ls_handler()
3230 fctl = (fc_hdr->fh_f_ctl[0] << 16 | in lpfc_nvme_unsol_ls_handler()
3231 fc_hdr->fh_f_ctl[1] << 8 | in lpfc_nvme_unsol_ls_handler()
3232 fc_hdr->fh_f_ctl[2]); in lpfc_nvme_unsol_ls_handler()
3233 size = bf_get(lpfc_rcqe_length, &nvmebuf->cq_event.cqe.rcqe_cmpl); in lpfc_nvme_unsol_ls_handler()
3238 if (phba->pport->load_flag & FC_UNLOADING) { in lpfc_nvme_unsol_ls_handler()
3240 } else if (!(phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME)) { in lpfc_nvme_unsol_ls_handler()
3242 } else if (!phba->nvmet_support && !phba->pport->localport) { in lpfc_nvme_unsol_ls_handler()
3244 } else if (phba->nvmet_support && !phba->targetport) { in lpfc_nvme_unsol_ls_handler()
3246 } else if (unlikely(fc_hdr->fh_r_ctl != FC_RCTL_ELS4_REQ)) { in lpfc_nvme_unsol_ls_handler()
3265 ndlp = lpfc_findnode_did(phba->pport, sid); in lpfc_nvme_unsol_ls_handler()
3267 ((ndlp->nlp_state != NLP_STE_UNMAPPED_NODE) && in lpfc_nvme_unsol_ls_handler()
3268 (ndlp->nlp_state != NLP_STE_MAPPED_NODE))) { in lpfc_nvme_unsol_ls_handler()
3276 axchg->phba = phba; in lpfc_nvme_unsol_ls_handler()
3277 axchg->ndlp = ndlp; in lpfc_nvme_unsol_ls_handler()
3278 axchg->size = size; in lpfc_nvme_unsol_ls_handler()
3279 axchg->oxid = oxid; in lpfc_nvme_unsol_ls_handler()
3280 axchg->sid = sid; in lpfc_nvme_unsol_ls_handler()
3281 axchg->wqeq = NULL; in lpfc_nvme_unsol_ls_handler()
3282 axchg->state = LPFC_NVME_STE_LS_RCV; in lpfc_nvme_unsol_ls_handler()
3283 axchg->entry_cnt = 1; in lpfc_nvme_unsol_ls_handler()
3284 axchg->rqb_buffer = (void *)nvmebuf; in lpfc_nvme_unsol_ls_handler()
3285 axchg->hdwq = &phba->sli4_hba.hdwq[0]; in lpfc_nvme_unsol_ls_handler()
3286 axchg->payload = nvmebuf->dbuf.virt; in lpfc_nvme_unsol_ls_handler()
3287 INIT_LIST_HEAD(&axchg->list); in lpfc_nvme_unsol_ls_handler()
3289 if (phba->nvmet_support) { in lpfc_nvme_unsol_ls_handler()
3291 spin_lock_irq(&ndlp->lock); in lpfc_nvme_unsol_ls_handler()
3292 if (!ret && !(ndlp->fc4_xpt_flags & NLP_XPT_HAS_HH)) { in lpfc_nvme_unsol_ls_handler()
3293 ndlp->fc4_xpt_flags |= NLP_XPT_HAS_HH; in lpfc_nvme_unsol_ls_handler()
3294 spin_unlock_irq(&ndlp->lock); in lpfc_nvme_unsol_ls_handler()
3306 ndlp, ndlp->nlp_DID, in lpfc_nvme_unsol_ls_handler()
3307 ndlp->fc4_xpt_flags, in lpfc_nvme_unsol_ls_handler()
3308 kref_read(&ndlp->kref)); in lpfc_nvme_unsol_ls_handler()
3310 spin_unlock_irq(&ndlp->lock); in lpfc_nvme_unsol_ls_handler()
3316 /* if zero, LS was successfully handled. If non-zero, LS not handled */ in lpfc_nvme_unsol_ls_handler()
3325 (phba->nvmet_support) ? "T" : "I", ret); in lpfc_nvme_unsol_ls_handler()
3328 lpfc_in_buf_free(phba, &nvmebuf->dbuf); in lpfc_nvme_unsol_ls_handler()
3339 * lpfc_complete_unsol_iocb - Complete an unsolicited sequence
3366 if (pring->prt[0].profile) { in lpfc_complete_unsol_iocb()
3367 if (pring->prt[0].lpfc_sli_rcv_unsol_event) in lpfc_complete_unsol_iocb()
3368 (pring->prt[0].lpfc_sli_rcv_unsol_event) (phba, pring, in lpfc_complete_unsol_iocb()
3374 for (i = 0; i < pring->num_mask; i++) { in lpfc_complete_unsol_iocb()
3375 if ((pring->prt[i].rctl == fch_r_ctl) && in lpfc_complete_unsol_iocb()
3376 (pring->prt[i].type == fch_type)) { in lpfc_complete_unsol_iocb()
3377 if (pring->prt[i].lpfc_sli_rcv_unsol_event) in lpfc_complete_unsol_iocb()
3378 (pring->prt[i].lpfc_sli_rcv_unsol_event) in lpfc_complete_unsol_iocb()
3394 irsp = &saveq->iocb; in lpfc_sli_prep_unsol_wqe()
3395 wqe = &saveq->wqe; in lpfc_sli_prep_unsol_wqe()
3398 bf_set(lpfc_wcqe_c_status, &saveq->wcqe_cmpl, irsp->ulpStatus); in lpfc_sli_prep_unsol_wqe()
3399 saveq->wcqe_cmpl.word3 = irsp->ulpBdeCount; in lpfc_sli_prep_unsol_wqe()
3400 saveq->wcqe_cmpl.parameter = irsp->un.ulpWord[4]; in lpfc_sli_prep_unsol_wqe()
3401 saveq->wcqe_cmpl.total_data_placed = irsp->unsli3.rcvsli3.acc_len; in lpfc_sli_prep_unsol_wqe()
3404 bf_set(els_rsp64_sid, &wqe->xmit_els_rsp, irsp->un.rcvels.parmRo); in lpfc_sli_prep_unsol_wqe()
3406 /* rx-id of the response frame */ in lpfc_sli_prep_unsol_wqe()
3407 bf_set(wqe_ctxt_tag, &wqe->xmit_els_rsp.wqe_com, irsp->ulpContext); in lpfc_sli_prep_unsol_wqe()
3409 /* ox-id of the frame */ in lpfc_sli_prep_unsol_wqe()
3410 bf_set(wqe_rcvoxid, &wqe->xmit_els_rsp.wqe_com, in lpfc_sli_prep_unsol_wqe()
3411 irsp->unsli3.rcvsli3.ox_id); in lpfc_sli_prep_unsol_wqe()
3414 bf_set(wqe_els_did, &wqe->xmit_els_rsp.wqe_dest, in lpfc_sli_prep_unsol_wqe()
3415 irsp->un.rcvels.remoteID); in lpfc_sli_prep_unsol_wqe()
3418 for (i = 0; i < irsp->ulpBdeCount; i++) { in lpfc_sli_prep_unsol_wqe()
3421 if (phba->sli3_options & LPFC_SLI3_HBQ_ENABLED) { in lpfc_sli_prep_unsol_wqe()
3424 &irsp->un.ulpWord[0]; in lpfc_sli_prep_unsol_wqe()
3425 saveq->wqe.gen_req.bde.tus.f.bdeSize = in lpfc_sli_prep_unsol_wqe()
3426 hbqe->bde.tus.f.bdeSize; in lpfc_sli_prep_unsol_wqe()
3429 &irsp->unsli3.sli3Words[4]; in lpfc_sli_prep_unsol_wqe()
3430 saveq->unsol_rcv_len = hbqe->bde.tus.f.bdeSize; in lpfc_sli_prep_unsol_wqe()
3437 * lpfc_sli_process_unsol_iocb - Unsolicited iocb handler
3461 irsp = &saveq->iocb; in lpfc_sli_process_unsol_iocb()
3462 saveq->vport = phba->pport; in lpfc_sli_process_unsol_iocb()
3464 if (irsp->ulpCommand == CMD_ASYNC_STATUS) { in lpfc_sli_process_unsol_iocb()
3465 if (pring->lpfc_sli_rcv_async_status) in lpfc_sli_process_unsol_iocb()
3466 pring->lpfc_sli_rcv_async_status(phba, pring, saveq); in lpfc_sli_process_unsol_iocb()
3474 pring->ringno, in lpfc_sli_process_unsol_iocb()
3475 irsp->un.asyncstat.evt_code); in lpfc_sli_process_unsol_iocb()
3479 if ((irsp->ulpCommand == CMD_IOCB_RET_XRI64_CX) && in lpfc_sli_process_unsol_iocb()
3480 (phba->sli3_options & LPFC_SLI3_HBQ_ENABLED)) { in lpfc_sli_process_unsol_iocb()
3481 if (irsp->ulpBdeCount > 0) { in lpfc_sli_process_unsol_iocb()
3483 irsp->un.ulpWord[3]); in lpfc_sli_process_unsol_iocb()
3487 if (irsp->ulpBdeCount > 1) { in lpfc_sli_process_unsol_iocb()
3489 irsp->unsli3.sli3Words[3]); in lpfc_sli_process_unsol_iocb()
3493 if (irsp->ulpBdeCount > 2) { in lpfc_sli_process_unsol_iocb()
3495 irsp->unsli3.sli3Words[7]); in lpfc_sli_process_unsol_iocb()
3502 if (phba->sli3_options & LPFC_SLI3_HBQ_ENABLED) { in lpfc_sli_process_unsol_iocb()
3503 if (irsp->ulpBdeCount != 0) { in lpfc_sli_process_unsol_iocb()
3504 saveq->cmd_dmabuf = lpfc_sli_get_buff(phba, pring, in lpfc_sli_process_unsol_iocb()
3505 irsp->un.ulpWord[3]); in lpfc_sli_process_unsol_iocb()
3506 if (!saveq->cmd_dmabuf) in lpfc_sli_process_unsol_iocb()
3512 pring->ringno, in lpfc_sli_process_unsol_iocb()
3513 irsp->un.ulpWord[3]); in lpfc_sli_process_unsol_iocb()
3515 if (irsp->ulpBdeCount == 2) { in lpfc_sli_process_unsol_iocb()
3516 saveq->bpl_dmabuf = lpfc_sli_get_buff(phba, pring, in lpfc_sli_process_unsol_iocb()
3517 irsp->unsli3.sli3Words[7]); in lpfc_sli_process_unsol_iocb()
3518 if (!saveq->bpl_dmabuf) in lpfc_sli_process_unsol_iocb()
3524 pring->ringno, in lpfc_sli_process_unsol_iocb()
3525 irsp->unsli3.sli3Words[7]); in lpfc_sli_process_unsol_iocb()
3527 list_for_each_entry(iocbq, &saveq->list, list) { in lpfc_sli_process_unsol_iocb()
3528 irsp = &iocbq->iocb; in lpfc_sli_process_unsol_iocb()
3529 if (irsp->ulpBdeCount != 0) { in lpfc_sli_process_unsol_iocb()
3530 iocbq->cmd_dmabuf = lpfc_sli_get_buff(phba, in lpfc_sli_process_unsol_iocb()
3532 irsp->un.ulpWord[3]); in lpfc_sli_process_unsol_iocb()
3533 if (!iocbq->cmd_dmabuf) in lpfc_sli_process_unsol_iocb()
3539 ". tag 0x%x\n", pring->ringno, in lpfc_sli_process_unsol_iocb()
3540 irsp->un.ulpWord[3]); in lpfc_sli_process_unsol_iocb()
3542 if (irsp->ulpBdeCount == 2) { in lpfc_sli_process_unsol_iocb()
3543 iocbq->bpl_dmabuf = lpfc_sli_get_buff(phba, in lpfc_sli_process_unsol_iocb()
3545 irsp->unsli3.sli3Words[7]); in lpfc_sli_process_unsol_iocb()
3546 if (!iocbq->bpl_dmabuf) in lpfc_sli_process_unsol_iocb()
3553 pring->ringno, in lpfc_sli_process_unsol_iocb()
3554 irsp->unsli3.sli3Words[7]); in lpfc_sli_process_unsol_iocb()
3558 paddr = getPaddr(irsp->un.cont64[0].addrHigh, in lpfc_sli_process_unsol_iocb()
3559 irsp->un.cont64[0].addrLow); in lpfc_sli_process_unsol_iocb()
3560 saveq->cmd_dmabuf = lpfc_sli_ringpostbuf_get(phba, pring, in lpfc_sli_process_unsol_iocb()
3562 if (irsp->ulpBdeCount == 2) { in lpfc_sli_process_unsol_iocb()
3563 paddr = getPaddr(irsp->un.cont64[1].addrHigh, in lpfc_sli_process_unsol_iocb()
3564 irsp->un.cont64[1].addrLow); in lpfc_sli_process_unsol_iocb()
3565 saveq->bpl_dmabuf = lpfc_sli_ringpostbuf_get(phba, in lpfc_sli_process_unsol_iocb()
3571 if (irsp->ulpBdeCount != 0 && in lpfc_sli_process_unsol_iocb()
3572 (irsp->ulpCommand == CMD_IOCB_RCV_CONT64_CX || in lpfc_sli_process_unsol_iocb()
3573 irsp->ulpStatus == IOSTAT_INTERMED_RSP)) { in lpfc_sli_process_unsol_iocb()
3577 list_for_each_entry(iocbq, &pring->iocb_continue_saveq, clist) { in lpfc_sli_process_unsol_iocb()
3578 if (iocbq->iocb.unsli3.rcvsli3.ox_id == in lpfc_sli_process_unsol_iocb()
3579 saveq->iocb.unsli3.rcvsli3.ox_id) { in lpfc_sli_process_unsol_iocb()
3580 list_add_tail(&saveq->list, &iocbq->list); in lpfc_sli_process_unsol_iocb()
3586 list_add_tail(&saveq->clist, in lpfc_sli_process_unsol_iocb()
3587 &pring->iocb_continue_saveq); in lpfc_sli_process_unsol_iocb()
3589 if (saveq->iocb.ulpStatus != IOSTAT_INTERMED_RSP) { in lpfc_sli_process_unsol_iocb()
3590 list_del_init(&iocbq->clist); in lpfc_sli_process_unsol_iocb()
3592 irsp = &saveq->iocb; in lpfc_sli_process_unsol_iocb()
3597 if ((irsp->ulpCommand == CMD_RCV_ELS_REQ64_CX) || in lpfc_sli_process_unsol_iocb()
3598 (irsp->ulpCommand == CMD_RCV_ELS_REQ_CX) || in lpfc_sli_process_unsol_iocb()
3599 (irsp->ulpCommand == CMD_IOCB_RCV_ELS64_CX)) { in lpfc_sli_process_unsol_iocb()
3603 w5p = (WORD5 *)&(saveq->iocb.un.ulpWord[5]); in lpfc_sli_process_unsol_iocb()
3604 Rctl = w5p->hcsw.Rctl; in lpfc_sli_process_unsol_iocb()
3605 Type = w5p->hcsw.Type; in lpfc_sli_process_unsol_iocb()
3608 if ((Rctl == 0) && (pring->ringno == LPFC_ELS_RING) && in lpfc_sli_process_unsol_iocb()
3609 (irsp->ulpCommand == CMD_RCV_SEQUENCE64_CX || in lpfc_sli_process_unsol_iocb()
3610 irsp->ulpCommand == CMD_IOCB_RCV_SEQ64_CX)) { in lpfc_sli_process_unsol_iocb()
3613 w5p->hcsw.Rctl = Rctl; in lpfc_sli_process_unsol_iocb()
3614 w5p->hcsw.Type = Type; in lpfc_sli_process_unsol_iocb()
3618 if ((phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) && in lpfc_sli_process_unsol_iocb()
3619 (irsp->ulpCommand == CMD_IOCB_RCV_ELS64_CX || in lpfc_sli_process_unsol_iocb()
3620 irsp->ulpCommand == CMD_IOCB_RCV_SEQ64_CX)) { in lpfc_sli_process_unsol_iocb()
3621 if (irsp->unsli3.rcvsli3.vpi == 0xffff) in lpfc_sli_process_unsol_iocb()
3622 saveq->vport = phba->pport; in lpfc_sli_process_unsol_iocb()
3624 saveq->vport = lpfc_find_vport_by_vpid(phba, in lpfc_sli_process_unsol_iocb()
3625 irsp->unsli3.rcvsli3.vpi); in lpfc_sli_process_unsol_iocb()
3635 pring->ringno, Rctl, Type); in lpfc_sli_process_unsol_iocb()
3641 * lpfc_sli_iocbq_lookup - Find command iocb for the given response iocb
3661 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_sli_iocbq_lookup()
3664 iotag = prspiocb->iocb.ulpIoTag; in lpfc_sli_iocbq_lookup()
3666 if (iotag != 0 && iotag <= phba->sli.last_iotag) { in lpfc_sli_iocbq_lookup()
3667 cmd_iocb = phba->sli.iocbq_lookup[iotag]; in lpfc_sli_iocbq_lookup()
3668 if (cmd_iocb->cmd_flag & LPFC_IO_ON_TXCMPLQ) { in lpfc_sli_iocbq_lookup()
3670 list_del_init(&cmd_iocb->list); in lpfc_sli_iocbq_lookup()
3671 cmd_iocb->cmd_flag &= ~LPFC_IO_ON_TXCMPLQ; in lpfc_sli_iocbq_lookup()
3672 pring->txcmplq_cnt--; in lpfc_sli_iocbq_lookup()
3680 iotag, phba->sli.last_iotag); in lpfc_sli_iocbq_lookup()
3685 * lpfc_sli_iocbq_lookup_by_tag - Find command iocb for the iotag
3702 if (iotag != 0 && iotag <= phba->sli.last_iotag) { in lpfc_sli_iocbq_lookup_by_tag()
3703 cmd_iocb = phba->sli.iocbq_lookup[iotag]; in lpfc_sli_iocbq_lookup_by_tag()
3704 if (cmd_iocb->cmd_flag & LPFC_IO_ON_TXCMPLQ) { in lpfc_sli_iocbq_lookup_by_tag()
3706 list_del_init(&cmd_iocb->list); in lpfc_sli_iocbq_lookup_by_tag()
3707 cmd_iocb->cmd_flag &= ~LPFC_IO_ON_TXCMPLQ; in lpfc_sli_iocbq_lookup_by_tag()
3708 pring->txcmplq_cnt--; in lpfc_sli_iocbq_lookup_by_tag()
3716 iotag, phba->sli.last_iotag, in lpfc_sli_iocbq_lookup_by_tag()
3717 cmd_iocb ? cmd_iocb->cmd_flag : 0xffff); in lpfc_sli_iocbq_lookup_by_tag()
3722 * lpfc_sli_process_sol_iocb - process solicited iocb completion
3727 * This function is called by the ring event handler for non-fcp
3746 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_sli_process_sol_iocb()
3747 spin_lock_irqsave(&pring->ring_lock, iflag); in lpfc_sli_process_sol_iocb()
3749 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_process_sol_iocb()
3751 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_sli_process_sol_iocb()
3752 spin_unlock_irqrestore(&pring->ring_lock, iflag); in lpfc_sli_process_sol_iocb()
3754 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_process_sol_iocb()
3760 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_sli_process_sol_iocb()
3763 iotag = saveq->iocb.ulpIoTag; in lpfc_sli_process_sol_iocb()
3767 if (cmdiocbp->cmd_cmpl) { in lpfc_sli_process_sol_iocb()
3773 (pring->ringno == LPFC_ELS_RING) && in lpfc_sli_process_sol_iocb()
3782 if (pring->ringno == LPFC_ELS_RING) { in lpfc_sli_process_sol_iocb()
3783 if ((phba->sli_rev < LPFC_SLI_REV4) && in lpfc_sli_process_sol_iocb()
3784 (cmdiocbp->cmd_flag & in lpfc_sli_process_sol_iocb()
3786 spin_lock_irqsave(&phba->hbalock, in lpfc_sli_process_sol_iocb()
3788 cmdiocbp->cmd_flag &= in lpfc_sli_process_sol_iocb()
3790 spin_unlock_irqrestore(&phba->hbalock, in lpfc_sli_process_sol_iocb()
3792 saveq->iocb.ulpStatus = in lpfc_sli_process_sol_iocb()
3794 saveq->iocb.un.ulpWord[4] = in lpfc_sli_process_sol_iocb()
3801 spin_lock_irqsave(&phba->hbalock, in lpfc_sli_process_sol_iocb()
3803 saveq->cmd_flag |= LPFC_DELAY_MEM_FREE; in lpfc_sli_process_sol_iocb()
3804 spin_unlock_irqrestore(&phba->hbalock, in lpfc_sli_process_sol_iocb()
3807 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_sli_process_sol_iocb()
3808 if (saveq->cmd_flag & in lpfc_sli_process_sol_iocb()
3817 &phba->hbalock, iflag); in lpfc_sli_process_sol_iocb()
3818 cmdiocbp->cmd_flag |= in lpfc_sli_process_sol_iocb()
3821 &phba->hbalock, iflag); in lpfc_sli_process_sol_iocb()
3823 if (cmdiocbp->cmd_flag & in lpfc_sli_process_sol_iocb()
3831 &phba->hbalock, iflag); in lpfc_sli_process_sol_iocb()
3832 cmdiocbp->cmd_flag &= in lpfc_sli_process_sol_iocb()
3835 &phba->hbalock, iflag); in lpfc_sli_process_sol_iocb()
3851 &phba->hbalock, iflag); in lpfc_sli_process_sol_iocb()
3852 saveq->cmd_flag |= in lpfc_sli_process_sol_iocb()
3855 &phba->hbalock, iflag); in lpfc_sli_process_sol_iocb()
3859 cmdiocbp->cmd_cmpl(phba, cmdiocbp, saveq); in lpfc_sli_process_sol_iocb()
3868 if (pring->ringno != LPFC_ELS_RING) { in lpfc_sli_process_sol_iocb()
3877 pring->ringno, iotag, ulp_status, in lpfc_sli_process_sol_iocb()
3886 * lpfc_sli_rsp_pointers_error - Response ring pointer error handler
3898 struct lpfc_pgp *pgp = &phba->port_gp[pring->ringno]; in lpfc_sli_rsp_pointers_error()
3906 pring->ringno, le32_to_cpu(pgp->rspPutInx), in lpfc_sli_rsp_pointers_error()
3907 pring->sli.sli3.numRiocb); in lpfc_sli_rsp_pointers_error()
3909 phba->link_state = LPFC_HBA_ERROR; in lpfc_sli_rsp_pointers_error()
3915 phba->work_ha |= HA_ERATT; in lpfc_sli_rsp_pointers_error()
3916 phba->work_hs = HS_FFER3; in lpfc_sli_rsp_pointers_error()
3924 * lpfc_poll_eratt - Error attention polling timer timeout handler
3940 if (!(phba->hba_flag & HBA_SETUP)) in lpfc_poll_eratt()
3943 if (phba->pport->load_flag & FC_UNLOADING) in lpfc_poll_eratt()
3947 sli_intr = phba->sli.slistat.sli_intr; in lpfc_poll_eratt()
3949 if (phba->sli.slistat.sli_prev_intr > sli_intr) in lpfc_poll_eratt()
3950 cnt = (((uint64_t)(-1) - phba->sli.slistat.sli_prev_intr) + in lpfc_poll_eratt()
3953 cnt = (sli_intr - phba->sli.slistat.sli_prev_intr); in lpfc_poll_eratt()
3955 /* 64-bit integer division not supported on 32-bit x86 - use do_div */ in lpfc_poll_eratt()
3956 do_div(cnt, phba->eratt_poll_interval); in lpfc_poll_eratt()
3957 phba->sli.slistat.sli_ips = cnt; in lpfc_poll_eratt()
3959 phba->sli.slistat.sli_prev_intr = sli_intr; in lpfc_poll_eratt()
3969 mod_timer(&phba->eratt_poll, in lpfc_poll_eratt()
3971 msecs_to_jiffies(1000 * phba->eratt_poll_interval)); in lpfc_poll_eratt()
3977 * lpfc_sli_handle_fast_ring_event - Handle ring events on FCP ring
3997 struct lpfc_pgp *pgp = &phba->port_gp[pring->ringno]; in lpfc_sli_handle_fast_ring_event()
4009 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_handle_fast_ring_event()
4010 pring->stats.iocb_event++; in lpfc_sli_handle_fast_ring_event()
4016 portRspMax = pring->sli.sli3.numRiocb; in lpfc_sli_handle_fast_ring_event()
4017 portRspPut = le32_to_cpu(pgp->rspPutInx); in lpfc_sli_handle_fast_ring_event()
4020 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_handle_fast_ring_event()
4023 if (phba->fcp_ring_in_use) { in lpfc_sli_handle_fast_ring_event()
4024 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_handle_fast_ring_event()
4027 phba->fcp_ring_in_use = 1; in lpfc_sli_handle_fast_ring_event()
4030 while (pring->sli.sli3.rspidx != portRspPut) { in lpfc_sli_handle_fast_ring_event()
4033 * structure. The copy involves a byte-swap since the in lpfc_sli_handle_fast_ring_event()
4037 phba->last_completion_time = jiffies; in lpfc_sli_handle_fast_ring_event()
4039 if (++pring->sli.sli3.rspidx >= portRspMax) in lpfc_sli_handle_fast_ring_event()
4040 pring->sli.sli3.rspidx = 0; in lpfc_sli_handle_fast_ring_event()
4044 phba->iocb_rsp_size); in lpfc_sli_handle_fast_ring_event()
4048 type = lpfc_sli_iocb_cmd_type(irsp->ulpCommand & CMD_IOCB_MASK); in lpfc_sli_handle_fast_ring_event()
4049 pring->stats.iocb_rsp++; in lpfc_sli_handle_fast_ring_event()
4052 if (unlikely(irsp->ulpStatus)) { in lpfc_sli_handle_fast_ring_event()
4057 if ((irsp->ulpStatus == IOSTAT_LOCAL_REJECT) && in lpfc_sli_handle_fast_ring_event()
4058 ((irsp->un.ulpWord[4] & IOERR_PARAM_MASK) == in lpfc_sli_handle_fast_ring_event()
4060 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_handle_fast_ring_event()
4061 phba->lpfc_rampdown_queue_depth(phba); in lpfc_sli_handle_fast_ring_event()
4062 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_handle_fast_ring_event()
4069 pring->ringno, in lpfc_sli_handle_fast_ring_event()
4070 irsp->un.ulpWord[0], in lpfc_sli_handle_fast_ring_event()
4071 irsp->un.ulpWord[1], in lpfc_sli_handle_fast_ring_event()
4072 irsp->un.ulpWord[2], in lpfc_sli_handle_fast_ring_event()
4073 irsp->un.ulpWord[3], in lpfc_sli_handle_fast_ring_event()
4074 irsp->un.ulpWord[4], in lpfc_sli_handle_fast_ring_event()
4075 irsp->un.ulpWord[5], in lpfc_sli_handle_fast_ring_event()
4076 *(uint32_t *)&irsp->un1, in lpfc_sli_handle_fast_ring_event()
4077 *((uint32_t *)&irsp->un1 + 1)); in lpfc_sli_handle_fast_ring_event()
4087 if (unlikely(irsp->ulpCommand == CMD_XRI_ABORTED_CX)) { in lpfc_sli_handle_fast_ring_event()
4092 irsp->ulpCommand); in lpfc_sli_handle_fast_ring_event()
4100 if (cmdiocbq->cmd_flag & LPFC_DRIVER_ABORTED) in lpfc_sli_handle_fast_ring_event()
4101 cmdiocbq->cmd_flag &= ~LPFC_DRIVER_ABORTED; in lpfc_sli_handle_fast_ring_event()
4102 if (cmdiocbq->cmd_cmpl) { in lpfc_sli_handle_fast_ring_event()
4103 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_handle_fast_ring_event()
4104 cmdiocbq->cmd_cmpl(phba, cmdiocbq, &rspiocbq); in lpfc_sli_handle_fast_ring_event()
4105 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_handle_fast_ring_event()
4109 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_handle_fast_ring_event()
4111 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_handle_fast_ring_event()
4114 if (irsp->ulpCommand == CMD_ADAPTER_MSG) { in lpfc_sli_handle_fast_ring_event()
4119 dev_warn(&((phba->pcidev)->dev), in lpfc_sli_handle_fast_ring_event()
4121 phba->brd_no, adaptermsg); in lpfc_sli_handle_fast_ring_event()
4127 type, irsp->ulpCommand, in lpfc_sli_handle_fast_ring_event()
4128 irsp->ulpStatus, in lpfc_sli_handle_fast_ring_event()
4129 irsp->ulpIoTag, in lpfc_sli_handle_fast_ring_event()
4130 irsp->ulpContext); in lpfc_sli_handle_fast_ring_event()
4138 * been updated, sync the pgp->rspPutInx and fetch the new port in lpfc_sli_handle_fast_ring_event()
4141 writel(pring->sli.sli3.rspidx, in lpfc_sli_handle_fast_ring_event()
4142 &phba->host_gp[pring->ringno].rspGetInx); in lpfc_sli_handle_fast_ring_event()
4144 if (pring->sli.sli3.rspidx == portRspPut) in lpfc_sli_handle_fast_ring_event()
4145 portRspPut = le32_to_cpu(pgp->rspPutInx); in lpfc_sli_handle_fast_ring_event()
4149 pring->stats.iocb_rsp_full++; in lpfc_sli_handle_fast_ring_event()
4150 status = ((CA_R0ATT | CA_R0RE_RSP) << (pring->ringno * 4)); in lpfc_sli_handle_fast_ring_event()
4151 writel(status, phba->CAregaddr); in lpfc_sli_handle_fast_ring_event()
4152 readl(phba->CAregaddr); in lpfc_sli_handle_fast_ring_event()
4154 if ((mask & HA_R0CE_RSP) && (pring->flag & LPFC_CALL_RING_AVAILABLE)) { in lpfc_sli_handle_fast_ring_event()
4155 pring->flag &= ~LPFC_CALL_RING_AVAILABLE; in lpfc_sli_handle_fast_ring_event()
4156 pring->stats.iocb_cmd_empty++; in lpfc_sli_handle_fast_ring_event()
4159 pring->sli.sli3.local_getidx = le32_to_cpu(pgp->cmdGetInx); in lpfc_sli_handle_fast_ring_event()
4162 if ((pring->lpfc_sli_cmd_available)) in lpfc_sli_handle_fast_ring_event()
4163 (pring->lpfc_sli_cmd_available) (phba, pring); in lpfc_sli_handle_fast_ring_event()
4167 phba->fcp_ring_in_use = 0; in lpfc_sli_handle_fast_ring_event()
4168 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_handle_fast_ring_event()
4173 * lpfc_sli_sp_handle_rspiocb - Handle slow-path response iocb
4178 * This function is called from the worker thread when there is a slow-path
4207 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_sp_handle_rspiocb()
4209 list_add_tail(&rspiocbp->list, &pring->iocb_continueq); in lpfc_sli_sp_handle_rspiocb()
4210 pring->iocb_continueq_cnt++; in lpfc_sli_sp_handle_rspiocb()
4217 saveq = list_get_first(&pring->iocb_continueq, in lpfc_sli_sp_handle_rspiocb()
4219 list_del_init(&pring->iocb_continueq); in lpfc_sli_sp_handle_rspiocb()
4220 pring->iocb_continueq_cnt = 0; in lpfc_sli_sp_handle_rspiocb()
4222 pring->stats.iocb_rsp++; in lpfc_sli_sp_handle_rspiocb()
4231 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_sp_handle_rspiocb()
4232 phba->lpfc_rampdown_queue_depth(phba); in lpfc_sli_sp_handle_rspiocb()
4233 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_sp_handle_rspiocb()
4238 if (phba->sli_rev < LPFC_SLI_REV4) { in lpfc_sli_sp_handle_rspiocb()
4239 irsp = &rspiocbp->iocb; in lpfc_sli_sp_handle_rspiocb()
4247 pring->ringno, ulp_status, in lpfc_sli_sp_handle_rspiocb()
4269 pring->ringno, in lpfc_sli_sp_handle_rspiocb()
4270 rspiocbp->wcqe_cmpl.word0, in lpfc_sli_sp_handle_rspiocb()
4271 rspiocbp->wcqe_cmpl.total_data_placed, in lpfc_sli_sp_handle_rspiocb()
4272 rspiocbp->wcqe_cmpl.parameter, in lpfc_sli_sp_handle_rspiocb()
4273 rspiocbp->wcqe_cmpl.word3); in lpfc_sli_sp_handle_rspiocb()
4288 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_sp_handle_rspiocb()
4290 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_sp_handle_rspiocb()
4293 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_sp_handle_rspiocb()
4295 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_sp_handle_rspiocb()
4306 if (cmdiocb->cmd_cmpl) { in lpfc_sli_sp_handle_rspiocb()
4307 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_sp_handle_rspiocb()
4308 cmdiocb->cmd_cmpl(phba, cmdiocb, saveq); in lpfc_sli_sp_handle_rspiocb()
4309 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_sp_handle_rspiocb()
4320 memcpy(&adaptermsg[0], (uint8_t *)&rspiocbp->wqe, in lpfc_sli_sp_handle_rspiocb()
4322 dev_warn(&((phba->pcidev)->dev), in lpfc_sli_sp_handle_rspiocb()
4324 phba->brd_no, adaptermsg); in lpfc_sli_sp_handle_rspiocb()
4341 &saveq->list, list) { in lpfc_sli_sp_handle_rspiocb()
4342 list_del_init(&rspiocbp->list); in lpfc_sli_sp_handle_rspiocb()
4348 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_sp_handle_rspiocb()
4353 * lpfc_sli_handle_slow_ring_event - Wrapper func for handling slow-path iocbs
4365 phba->lpfc_sli_handle_slow_ring_event(phba, pring, mask); in lpfc_sli_handle_slow_ring_event()
4369 * lpfc_sli_handle_slow_ring_event_s3 - Handle SLI3 ring event for non-FCP rings
4375 * for non-fcp rings. The caller does not hold any lock. The function will
4391 pgp = &phba->port_gp[pring->ringno]; in lpfc_sli_handle_slow_ring_event_s3()
4392 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_handle_slow_ring_event_s3()
4393 pring->stats.iocb_event++; in lpfc_sli_handle_slow_ring_event_s3()
4399 portRspMax = pring->sli.sli3.numRiocb; in lpfc_sli_handle_slow_ring_event_s3()
4400 portRspPut = le32_to_cpu(pgp->rspPutInx); in lpfc_sli_handle_slow_ring_event_s3()
4409 pring->ringno, portRspPut, portRspMax); in lpfc_sli_handle_slow_ring_event_s3()
4411 phba->link_state = LPFC_HBA_ERROR; in lpfc_sli_handle_slow_ring_event_s3()
4412 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_handle_slow_ring_event_s3()
4414 phba->work_hs = HS_FFER3; in lpfc_sli_handle_slow_ring_event_s3()
4421 while (pring->sli.sli3.rspidx != portRspPut) { in lpfc_sli_handle_slow_ring_event_s3()
4437 phba->last_completion_time = jiffies; in lpfc_sli_handle_slow_ring_event_s3()
4445 lpfc_sli_pcimem_bcopy(entry, &rspiocbp->iocb, in lpfc_sli_handle_slow_ring_event_s3()
4446 phba->iocb_rsp_size); in lpfc_sli_handle_slow_ring_event_s3()
4447 irsp = &rspiocbp->iocb; in lpfc_sli_handle_slow_ring_event_s3()
4449 if (++pring->sli.sli3.rspidx >= portRspMax) in lpfc_sli_handle_slow_ring_event_s3()
4450 pring->sli.sli3.rspidx = 0; in lpfc_sli_handle_slow_ring_event_s3()
4452 if (pring->ringno == LPFC_ELS_RING) { in lpfc_sli_handle_slow_ring_event_s3()
4460 writel(pring->sli.sli3.rspidx, in lpfc_sli_handle_slow_ring_event_s3()
4461 &phba->host_gp[pring->ringno].rspGetInx); in lpfc_sli_handle_slow_ring_event_s3()
4463 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_handle_slow_ring_event_s3()
4466 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_handle_slow_ring_event_s3()
4470 * the pgp->rspPutInx in the MAILBOX_tand fetch the new port in lpfc_sli_handle_slow_ring_event_s3()
4473 if (pring->sli.sli3.rspidx == portRspPut) { in lpfc_sli_handle_slow_ring_event_s3()
4474 portRspPut = le32_to_cpu(pgp->rspPutInx); in lpfc_sli_handle_slow_ring_event_s3()
4476 } /* while (pring->sli.sli3.rspidx != portRspPut) */ in lpfc_sli_handle_slow_ring_event_s3()
4480 pring->stats.iocb_rsp_full++; in lpfc_sli_handle_slow_ring_event_s3()
4482 status = ((CA_R0ATT | CA_R0RE_RSP) << (pring->ringno * 4)); in lpfc_sli_handle_slow_ring_event_s3()
4483 writel(status, phba->CAregaddr); in lpfc_sli_handle_slow_ring_event_s3()
4484 readl(phba->CAregaddr); /* flush */ in lpfc_sli_handle_slow_ring_event_s3()
4486 if ((mask & HA_R0CE_RSP) && (pring->flag & LPFC_CALL_RING_AVAILABLE)) { in lpfc_sli_handle_slow_ring_event_s3()
4487 pring->flag &= ~LPFC_CALL_RING_AVAILABLE; in lpfc_sli_handle_slow_ring_event_s3()
4488 pring->stats.iocb_cmd_empty++; in lpfc_sli_handle_slow_ring_event_s3()
4491 pring->sli.sli3.local_getidx = le32_to_cpu(pgp->cmdGetInx); in lpfc_sli_handle_slow_ring_event_s3()
4494 if ((pring->lpfc_sli_cmd_available)) in lpfc_sli_handle_slow_ring_event_s3()
4495 (pring->lpfc_sli_cmd_available) (phba, pring); in lpfc_sli_handle_slow_ring_event_s3()
4499 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_handle_slow_ring_event_s3()
4504 * lpfc_sli_handle_slow_ring_event_s4 - Handle SLI4 slow-path els events
4510 * ELS response iocb on the driver internal slow-path response iocb worker
4525 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_handle_slow_ring_event_s4()
4526 phba->hba_flag &= ~HBA_SP_QUEUE_EVT; in lpfc_sli_handle_slow_ring_event_s4()
4527 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_handle_slow_ring_event_s4()
4528 while (!list_empty(&phba->sli4_hba.sp_queue_event)) { in lpfc_sli_handle_slow_ring_event_s4()
4530 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_handle_slow_ring_event_s4()
4531 list_remove_head(&phba->sli4_hba.sp_queue_event, in lpfc_sli_handle_slow_ring_event_s4()
4533 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_handle_slow_ring_event_s4()
4535 switch (bf_get(lpfc_wcqe_c_code, &cq_event->cqe.wcqe_cmpl)) { in lpfc_sli_handle_slow_ring_event_s4()
4565 * lpfc_sli_abort_iocb_ring - Abort all iocbs in the ring
4582 if (pring->ringno == LPFC_ELS_RING) { in lpfc_sli_abort_iocb_ring()
4585 offline = pci_channel_offline(phba->pcidev); in lpfc_sli_abort_iocb_ring()
4590 if (phba->sli_rev >= LPFC_SLI_REV4) { in lpfc_sli_abort_iocb_ring()
4591 spin_lock_irq(&pring->ring_lock); in lpfc_sli_abort_iocb_ring()
4592 list_splice_init(&pring->txq, &tx_completions); in lpfc_sli_abort_iocb_ring()
4593 pring->txq_cnt = 0; in lpfc_sli_abort_iocb_ring()
4596 list_splice_init(&pring->txcmplq, in lpfc_sli_abort_iocb_ring()
4601 &pring->txcmplq, list) in lpfc_sli_abort_iocb_ring()
4605 spin_unlock_irq(&pring->ring_lock); in lpfc_sli_abort_iocb_ring()
4607 spin_lock_irq(&phba->hbalock); in lpfc_sli_abort_iocb_ring()
4608 list_splice_init(&pring->txq, &tx_completions); in lpfc_sli_abort_iocb_ring()
4609 pring->txq_cnt = 0; in lpfc_sli_abort_iocb_ring()
4612 list_splice_init(&pring->txcmplq, &txcmplq_completions); in lpfc_sli_abort_iocb_ring()
4616 &pring->txcmplq, list) in lpfc_sli_abort_iocb_ring()
4620 spin_unlock_irq(&phba->hbalock); in lpfc_sli_abort_iocb_ring()
4637 * lpfc_sli_abort_fcp_rings - Abort all iocbs in all FCP rings
4648 struct lpfc_sli *psli = &phba->sli; in lpfc_sli_abort_fcp_rings()
4653 if (phba->sli_rev >= LPFC_SLI_REV4) { in lpfc_sli_abort_fcp_rings()
4654 for (i = 0; i < phba->cfg_hdw_queue; i++) { in lpfc_sli_abort_fcp_rings()
4655 pring = phba->sli4_hba.hdwq[i].io_wq->pring; in lpfc_sli_abort_fcp_rings()
4659 pring = &psli->sli3_ring[LPFC_FCP_RING]; in lpfc_sli_abort_fcp_rings()
4665 * lpfc_sli_flush_io_rings - flush all iocbs in the IO ring
4679 struct lpfc_sli *psli = &phba->sli; in lpfc_sli_flush_io_rings()
4684 spin_lock_irq(&phba->hbalock); in lpfc_sli_flush_io_rings()
4686 phba->hba_flag |= HBA_IOQ_FLUSH; in lpfc_sli_flush_io_rings()
4687 spin_unlock_irq(&phba->hbalock); in lpfc_sli_flush_io_rings()
4690 if (phba->sli_rev >= LPFC_SLI_REV4) { in lpfc_sli_flush_io_rings()
4691 for (i = 0; i < phba->cfg_hdw_queue; i++) { in lpfc_sli_flush_io_rings()
4692 pring = phba->sli4_hba.hdwq[i].io_wq->pring; in lpfc_sli_flush_io_rings()
4694 spin_lock_irq(&pring->ring_lock); in lpfc_sli_flush_io_rings()
4696 list_splice_init(&pring->txq, &txq); in lpfc_sli_flush_io_rings()
4698 &pring->txcmplq, list) in lpfc_sli_flush_io_rings()
4699 piocb->cmd_flag &= ~LPFC_IO_ON_TXCMPLQ; in lpfc_sli_flush_io_rings()
4701 list_splice_init(&pring->txcmplq, &txcmplq); in lpfc_sli_flush_io_rings()
4702 pring->txq_cnt = 0; in lpfc_sli_flush_io_rings()
4703 pring->txcmplq_cnt = 0; in lpfc_sli_flush_io_rings()
4704 spin_unlock_irq(&pring->ring_lock); in lpfc_sli_flush_io_rings()
4714 if (unlikely(pci_channel_offline(phba->pcidev))) in lpfc_sli_flush_io_rings()
4718 pring = &psli->sli3_ring[LPFC_FCP_RING]; in lpfc_sli_flush_io_rings()
4720 spin_lock_irq(&phba->hbalock); in lpfc_sli_flush_io_rings()
4722 list_splice_init(&pring->txq, &txq); in lpfc_sli_flush_io_rings()
4724 &pring->txcmplq, list) in lpfc_sli_flush_io_rings()
4725 piocb->cmd_flag &= ~LPFC_IO_ON_TXCMPLQ; in lpfc_sli_flush_io_rings()
4727 list_splice_init(&pring->txcmplq, &txcmplq); in lpfc_sli_flush_io_rings()
4728 pring->txq_cnt = 0; in lpfc_sli_flush_io_rings()
4729 pring->txcmplq_cnt = 0; in lpfc_sli_flush_io_rings()
4730 spin_unlock_irq(&phba->hbalock); in lpfc_sli_flush_io_rings()
4742 * lpfc_sli_brdready_s3 - Check for sli3 host ready status
4762 if (lpfc_readl(phba->HSregaddr, &status)) in lpfc_sli_brdready_s3()
4765 phba->hba_flag |= HBA_NEEDS_CFG_PORT; in lpfc_sli_brdready_s3()
4786 phba->pport->port_state = LPFC_VPORT_UNKNOWN; in lpfc_sli_brdready_s3()
4790 if (lpfc_readl(phba->HSregaddr, &status)) { in lpfc_sli_brdready_s3()
4802 readl(phba->MBslimaddr + 0xa8), in lpfc_sli_brdready_s3()
4803 readl(phba->MBslimaddr + 0xac)); in lpfc_sli_brdready_s3()
4804 phba->link_state = LPFC_HBA_ERROR; in lpfc_sli_brdready_s3()
4812 * lpfc_sli_brdready_s4 - Check for sli4 host ready status
4832 phba->pport->port_state = LPFC_VPORT_UNKNOWN; in lpfc_sli_brdready_s4()
4839 phba->link_state = LPFC_HBA_ERROR; in lpfc_sli_brdready_s4()
4842 phba->sli4_hba.intr_enable = 0; in lpfc_sli_brdready_s4()
4844 phba->hba_flag &= ~HBA_SETUP; in lpfc_sli_brdready_s4()
4849 * lpfc_sli_brdready - Wrapper func for checking the hba readyness
4859 return phba->lpfc_sli_brdready(phba, mask); in lpfc_sli_brdready()
4865 * lpfc_reset_barrier - Make HBA ready for HBA reset
4880 lockdep_assert_held(&phba->hbalock); in lpfc_reset_barrier()
4882 pci_read_config_byte(phba->pcidev, PCI_HEADER_TYPE, &hdrtype); in lpfc_reset_barrier()
4884 (FC_JEDEC_ID(phba->vpd.rev.biuRev) != HELIOS_JEDEC_ID && in lpfc_reset_barrier()
4885 FC_JEDEC_ID(phba->vpd.rev.biuRev) != THOR_JEDEC_ID)) in lpfc_reset_barrier()
4892 resp_buf = phba->MBslimaddr; in lpfc_reset_barrier()
4895 if (lpfc_readl(phba->HCregaddr, &hc_copy)) in lpfc_reset_barrier()
4897 writel((hc_copy & ~HC_ERINT_ENA), phba->HCregaddr); in lpfc_reset_barrier()
4898 readl(phba->HCregaddr); /* flush */ in lpfc_reset_barrier()
4899 phba->link_flag |= LS_IGNORE_ERATT; in lpfc_reset_barrier()
4901 if (lpfc_readl(phba->HAregaddr, &ha_copy)) in lpfc_reset_barrier()
4905 writel(HA_ERATT, phba->HAregaddr); in lpfc_reset_barrier()
4906 phba->pport->stopped = 1; in lpfc_reset_barrier()
4914 mbox_buf = phba->MBslimaddr; in lpfc_reset_barrier()
4929 if (phba->sli.sli_flag & LPFC_SLI_ACTIVE || in lpfc_reset_barrier()
4930 phba->pport->stopped) in lpfc_reset_barrier()
4950 if (lpfc_readl(phba->HAregaddr, &ha_copy)) in lpfc_reset_barrier()
4958 if (readl(phba->HAregaddr) & HA_ERATT) { in lpfc_reset_barrier()
4959 writel(HA_ERATT, phba->HAregaddr); in lpfc_reset_barrier()
4960 phba->pport->stopped = 1; in lpfc_reset_barrier()
4964 phba->link_flag &= ~LS_IGNORE_ERATT; in lpfc_reset_barrier()
4965 writel(hc_copy, phba->HCregaddr); in lpfc_reset_barrier()
4966 readl(phba->HCregaddr); /* flush */ in lpfc_reset_barrier()
4970 * lpfc_sli_brdkill - Issue a kill_board mailbox command
4973 * This function issues a kill_board mailbox command and waits for
4990 psli = &phba->sli; in lpfc_sli_brdkill()
4995 phba->pport->port_state, psli->sli_flag); in lpfc_sli_brdkill()
4997 pmb = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli_brdkill()
5002 spin_lock_irq(&phba->hbalock); in lpfc_sli_brdkill()
5003 if (lpfc_readl(phba->HCregaddr, &status)) { in lpfc_sli_brdkill()
5004 spin_unlock_irq(&phba->hbalock); in lpfc_sli_brdkill()
5005 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_sli_brdkill()
5009 writel(status, phba->HCregaddr); in lpfc_sli_brdkill()
5010 readl(phba->HCregaddr); /* flush */ in lpfc_sli_brdkill()
5011 phba->link_flag |= LS_IGNORE_ERATT; in lpfc_sli_brdkill()
5012 spin_unlock_irq(&phba->hbalock); in lpfc_sli_brdkill()
5015 pmb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_sli_brdkill()
5020 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_sli_brdkill()
5024 spin_lock_irq(&phba->hbalock); in lpfc_sli_brdkill()
5025 phba->link_flag &= ~LS_IGNORE_ERATT; in lpfc_sli_brdkill()
5026 spin_unlock_irq(&phba->hbalock); in lpfc_sli_brdkill()
5030 spin_lock_irq(&phba->hbalock); in lpfc_sli_brdkill()
5031 psli->sli_flag &= ~LPFC_SLI_ACTIVE; in lpfc_sli_brdkill()
5032 spin_unlock_irq(&phba->hbalock); in lpfc_sli_brdkill()
5034 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_sli_brdkill()
5041 if (lpfc_readl(phba->HAregaddr, &ha_copy)) in lpfc_sli_brdkill()
5045 if (lpfc_readl(phba->HAregaddr, &ha_copy)) in lpfc_sli_brdkill()
5049 del_timer_sync(&psli->mbox_tmo); in lpfc_sli_brdkill()
5051 writel(HA_ERATT, phba->HAregaddr); in lpfc_sli_brdkill()
5052 phba->pport->stopped = 1; in lpfc_sli_brdkill()
5054 spin_lock_irq(&phba->hbalock); in lpfc_sli_brdkill()
5055 psli->sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; in lpfc_sli_brdkill()
5056 psli->mbox_active = NULL; in lpfc_sli_brdkill()
5057 phba->link_flag &= ~LS_IGNORE_ERATT; in lpfc_sli_brdkill()
5058 spin_unlock_irq(&phba->hbalock); in lpfc_sli_brdkill()
5061 phba->link_state = LPFC_HBA_ERROR; in lpfc_sli_brdkill()
5067 * lpfc_sli_brdreset - Reset a sli-2 or sli-3 HBA
5085 psli = &phba->sli; in lpfc_sli_brdreset()
5090 (phba->pport) ? phba->pport->port_state : 0, in lpfc_sli_brdreset()
5091 psli->sli_flag); in lpfc_sli_brdreset()
5094 phba->fc_eventTag = 0; in lpfc_sli_brdreset()
5095 phba->link_events = 0; in lpfc_sli_brdreset()
5096 phba->hba_flag |= HBA_NEEDS_CFG_PORT; in lpfc_sli_brdreset()
5097 if (phba->pport) { in lpfc_sli_brdreset()
5098 phba->pport->fc_myDID = 0; in lpfc_sli_brdreset()
5099 phba->pport->fc_prevDID = 0; in lpfc_sli_brdreset()
5103 if (pci_read_config_word(phba->pcidev, PCI_COMMAND, &cfg_value)) in lpfc_sli_brdreset()
5104 return -EIO; in lpfc_sli_brdreset()
5106 pci_write_config_word(phba->pcidev, PCI_COMMAND, in lpfc_sli_brdreset()
5110 psli->sli_flag &= ~(LPFC_SLI_ACTIVE | LPFC_PROCESS_LA); in lpfc_sli_brdreset()
5113 writel(HC_INITFF, phba->HCregaddr); in lpfc_sli_brdreset()
5115 readl(phba->HCregaddr); /* flush */ in lpfc_sli_brdreset()
5116 writel(0, phba->HCregaddr); in lpfc_sli_brdreset()
5117 readl(phba->HCregaddr); /* flush */ in lpfc_sli_brdreset()
5120 pci_write_config_word(phba->pcidev, PCI_COMMAND, cfg_value); in lpfc_sli_brdreset()
5123 for (i = 0; i < psli->num_rings; i++) { in lpfc_sli_brdreset()
5124 pring = &psli->sli3_ring[i]; in lpfc_sli_brdreset()
5125 pring->flag = 0; in lpfc_sli_brdreset()
5126 pring->sli.sli3.rspidx = 0; in lpfc_sli_brdreset()
5127 pring->sli.sli3.next_cmdidx = 0; in lpfc_sli_brdreset()
5128 pring->sli.sli3.local_getidx = 0; in lpfc_sli_brdreset()
5129 pring->sli.sli3.cmdidx = 0; in lpfc_sli_brdreset()
5130 pring->missbufcnt = 0; in lpfc_sli_brdreset()
5133 phba->link_state = LPFC_WARM_START; in lpfc_sli_brdreset()
5138 * lpfc_sli4_brdreset - Reset a sli-4 HBA
5150 struct lpfc_sli *psli = &phba->sli; in lpfc_sli4_brdreset()
5157 phba->pport->port_state, psli->sli_flag, in lpfc_sli4_brdreset()
5158 phba->hba_flag); in lpfc_sli4_brdreset()
5161 phba->fc_eventTag = 0; in lpfc_sli4_brdreset()
5162 phba->link_events = 0; in lpfc_sli4_brdreset()
5163 phba->pport->fc_myDID = 0; in lpfc_sli4_brdreset()
5164 phba->pport->fc_prevDID = 0; in lpfc_sli4_brdreset()
5165 phba->hba_flag &= ~HBA_SETUP; in lpfc_sli4_brdreset()
5167 spin_lock_irq(&phba->hbalock); in lpfc_sli4_brdreset()
5168 psli->sli_flag &= ~(LPFC_PROCESS_LA); in lpfc_sli4_brdreset()
5169 phba->fcf.fcf_flag = 0; in lpfc_sli4_brdreset()
5170 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_brdreset()
5177 if (pci_read_config_word(phba->pcidev, PCI_COMMAND, &cfg_value)) { in lpfc_sli4_brdreset()
5180 return -EIO; in lpfc_sli4_brdreset()
5183 pci_write_config_word(phba->pcidev, PCI_COMMAND, (cfg_value & in lpfc_sli4_brdreset()
5190 pci_write_config_word(phba->pcidev, PCI_COMMAND, cfg_value); in lpfc_sli4_brdreset()
5196 * lpfc_sli_brdrestart_s3 - Restart a sli-3 hba
5201 * This function writes MBX_RESTART mailbox command to the SLIM and
5205 * The function does not guarantee completion of MBX_RESTART mailbox
5215 spin_lock_irq(&phba->hbalock); in lpfc_sli_brdrestart_s3()
5217 psli = &phba->sli; in lpfc_sli_brdrestart_s3()
5222 (phba->pport) ? phba->pport->port_state : 0, in lpfc_sli_brdrestart_s3()
5223 psli->sli_flag); in lpfc_sli_brdrestart_s3()
5231 to_slim = phba->MBslimaddr; in lpfc_sli_brdrestart_s3()
5236 if (phba->pport && phba->pport->port_state) in lpfc_sli_brdrestart_s3()
5240 to_slim = phba->MBslimaddr + sizeof (uint32_t); in lpfc_sli_brdrestart_s3()
5245 if (phba->pport) in lpfc_sli_brdrestart_s3()
5246 phba->pport->stopped = 0; in lpfc_sli_brdrestart_s3()
5247 phba->link_state = LPFC_INIT_START; in lpfc_sli_brdrestart_s3()
5248 phba->hba_flag = 0; in lpfc_sli_brdrestart_s3()
5249 spin_unlock_irq(&phba->hbalock); in lpfc_sli_brdrestart_s3()
5251 memset(&psli->lnk_stat_offsets, 0, sizeof(psli->lnk_stat_offsets)); in lpfc_sli_brdrestart_s3()
5252 psli->stats_start = ktime_get_seconds(); in lpfc_sli_brdrestart_s3()
5263 * lpfc_sli_brdrestart_s4 - Restart the sli-4 hba
5274 struct lpfc_sli *psli = &phba->sli; in lpfc_sli_brdrestart_s4()
5280 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 phba->hba_flag |= HBA_NEEDS_CFG_PORT; 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 (phba->hba_flag & HBA_NEEDS_CFG_PORT) { in lpfc_sli_hba_setup()
5714 return -EIO; in lpfc_sli_hba_setup()
5715 phba->hba_flag &= ~HBA_NEEDS_CFG_PORT; 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 = (struct lpfc_dmabuf *)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->hbalock); in lpfc_ras_stop_fwlog()
6853 ras_fwlog->state = INACTIVE; in lpfc_ras_stop_fwlog()
6854 spin_unlock_irq(&phba->hbalock); 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->hbalock); in lpfc_sli4_ras_dma_free()
6898 ras_fwlog->state = INACTIVE; in lpfc_sli4_ras_dma_free()
6899 spin_unlock_irq(&phba->hbalock); 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->hbalock); in lpfc_sli4_ras_mbox_cmpl()
7002 ras_fwlog->state = ACTIVE; in lpfc_sli4_ras_mbox_cmpl()
7003 spin_unlock_irq(&phba->hbalock); 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->hbalock); in lpfc_sli4_ras_fwlog_init()
7036 ras_fwlog->state = INACTIVE; in lpfc_sli4_ras_fwlog_init()
7037 spin_unlock_irq(&phba->hbalock); 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->hbalock); in lpfc_sli4_ras_fwlog_init()
7099 ras_fwlog->state = REG_INPROGRESS; in lpfc_sli4_ras_fwlog_init()
7100 spin_unlock_irq(&phba->hbalock); 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 (phba->hba_flag & HBA_FCOE_MODE) ? "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 phba->hba_flag &= ~HBA_SETUP; 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 phba->hba_flag |= HBA_FCOE_MODE; in lpfc_sli4_hba_setup()
8520 phba->fcp_embed_io = 0; /* SLI4 FC support only */ in lpfc_sli4_hba_setup()
8522 phba->hba_flag &= ~HBA_FCOE_MODE; 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 phba->hba_flag |= HBA_FIP_SUPPORT; in lpfc_sli4_hba_setup()
8529 phba->hba_flag &= ~HBA_FIP_SUPPORT; in lpfc_sli4_hba_setup()
8531 phba->hba_flag &= ~HBA_IOQ_FLUSH; in lpfc_sli4_hba_setup()
8533 if (phba->sli_rev != LPFC_SLI_REV4) { in lpfc_sli4_hba_setup()
8537 phba->sli_rev, phba->hba_flag & HBA_FCOE_MODE); in lpfc_sli4_hba_setup()
8538 rc = -EIO; in lpfc_sli4_hba_setup()
8552 if (phba->hba_flag & HBA_FCOE_MODE && in lpfc_sli4_hba_setup()
8559 * is considered as non-fatal. in lpfc_sli4_hba_setup()
8565 "physical port name: %s.\n", phba->Port); in lpfc_sli4_hba_setup()
8586 phba->vpd.rev.biuRev = mqe->un.read_rev.first_hw_rev; in lpfc_sli4_hba_setup()
8587 phba->vpd.rev.smRev = mqe->un.read_rev.second_hw_rev; in lpfc_sli4_hba_setup()
8593 if ((bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) == in lpfc_sli4_hba_setup()
8595 (phba->vpd.rev.biuRev == LPFC_G7_ASIC_1) && in lpfc_sli4_hba_setup()
8596 (phba->vpd.rev.smRev == 0) && in lpfc_sli4_hba_setup()
8597 (phba->cfg_nvme_embed_cmd == 1)) in lpfc_sli4_hba_setup()
8598 phba->cfg_nvme_embed_cmd = 0; in lpfc_sli4_hba_setup()
8600 phba->vpd.rev.endecRev = mqe->un.read_rev.third_hw_rev; in lpfc_sli4_hba_setup()
8601 phba->vpd.rev.fcphHigh = bf_get(lpfc_mbx_rd_rev_fcph_high, in lpfc_sli4_hba_setup()
8602 &mqe->un.read_rev); in lpfc_sli4_hba_setup()
8603 phba->vpd.rev.fcphLow = bf_get(lpfc_mbx_rd_rev_fcph_low, in lpfc_sli4_hba_setup()
8604 &mqe->un.read_rev); in lpfc_sli4_hba_setup()
8605 phba->vpd.rev.feaLevelHigh = bf_get(lpfc_mbx_rd_rev_ftr_lvl_high, in lpfc_sli4_hba_setup()
8606 &mqe->un.read_rev); in lpfc_sli4_hba_setup()
8607 phba->vpd.rev.feaLevelLow = bf_get(lpfc_mbx_rd_rev_ftr_lvl_low, in lpfc_sli4_hba_setup()
8608 &mqe->un.read_rev); in lpfc_sli4_hba_setup()
8609 phba->vpd.rev.sli1FwRev = mqe->un.read_rev.fw_id_rev; in lpfc_sli4_hba_setup()
8610 memcpy(phba->vpd.rev.sli1FwName, mqe->un.read_rev.fw_name, 16); in lpfc_sli4_hba_setup()
8611 phba->vpd.rev.sli2FwRev = mqe->un.read_rev.ulp_fw_id_rev; in lpfc_sli4_hba_setup()
8612 memcpy(phba->vpd.rev.sli2FwName, mqe->un.read_rev.ulp_fw_name, 16); in lpfc_sli4_hba_setup()
8613 phba->vpd.rev.opFwRev = mqe->un.read_rev.fw_id_rev; in lpfc_sli4_hba_setup()
8614 memcpy(phba->vpd.rev.opFwName, mqe->un.read_rev.fw_name, 16); in lpfc_sli4_hba_setup()
8618 mboxq->vport ? mboxq->vport->vpi : 0, in lpfc_sli4_hba_setup()
8620 phba->vpd.rev.opFwName, in lpfc_sli4_hba_setup()
8621 phba->vpd.rev.fcphHigh, phba->vpd.rev.fcphLow, in lpfc_sli4_hba_setup()
8622 phba->vpd.rev.feaLevelHigh, phba->vpd.rev.feaLevelLow); in lpfc_sli4_hba_setup()
8624 if (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) == in lpfc_sli4_hba_setup()
8629 phba->hba_flag |= HBA_RECOVERABLE_UE; in lpfc_sli4_hba_setup()
8631 phba->eratt_poll_interval = 1; in lpfc_sli4_hba_setup()
8632 phba->sli4_hba.ue_to_sr = bf_get( in lpfc_sli4_hba_setup()
8634 &mboxq->u.mqe.un.set_feature); in lpfc_sli4_hba_setup()
8635 phba->sli4_hba.ue_to_rp = bf_get( in lpfc_sli4_hba_setup()
8637 &mboxq->u.mqe.un.set_feature); in lpfc_sli4_hba_setup()
8641 if (phba->cfg_enable_mds_diags && phba->mds_diags_support) { in lpfc_sli4_hba_setup()
8646 phba->mds_diags_support = 0; in lpfc_sli4_hba_setup()
8656 rc = -EIO; in lpfc_sli4_hba_setup()
8661 if (phba->cfg_vmid_app_header && !(bf_get(lpfc_mbx_rq_ftr_rsp_ashdr, in lpfc_sli4_hba_setup()
8662 &mqe->un.req_ftrs))) { in lpfc_sli4_hba_setup()
8663 bf_set(lpfc_ftr_ashdr, &phba->sli4_hba.sli4_flags, 0); in lpfc_sli4_hba_setup()
8664 phba->cfg_vmid_app_header = 0; in lpfc_sli4_hba_setup()
8673 if (!(bf_get(lpfc_mbx_rq_ftr_rsp_fcpi, &mqe->un.req_ftrs))) { in lpfc_sli4_hba_setup()
8680 if (phba->hba_flag & HBA_FCOE_MODE) { in lpfc_sli4_hba_setup()
8681 if (bf_get(lpfc_mbx_rq_ftr_rsp_perfh, &mqe->un.req_ftrs)) in lpfc_sli4_hba_setup()
8682 phba->sli3_options |= LPFC_SLI4_PERFH_ENABLED; in lpfc_sli4_hba_setup()
8684 phba->sli3_options &= ~LPFC_SLI4_PERFH_ENABLED; in lpfc_sli4_hba_setup()
8692 if (phba->sli3_options & LPFC_SLI3_BG_ENABLED) { in lpfc_sli4_hba_setup()
8693 if (!(bf_get(lpfc_mbx_rq_ftr_rsp_dif, &mqe->un.req_ftrs))) { in lpfc_sli4_hba_setup()
8694 phba->cfg_enable_bg = 0; in lpfc_sli4_hba_setup()
8695 phba->sli3_options &= ~LPFC_SLI3_BG_ENABLED; in lpfc_sli4_hba_setup()
8700 if (phba->max_vpi && phba->cfg_enable_npiv && in lpfc_sli4_hba_setup()
8701 !(bf_get(lpfc_mbx_rq_ftr_rsp_npiv, &mqe->un.req_ftrs))) in lpfc_sli4_hba_setup()
8707 "x%x x%x x%x\n", mqe->un.req_ftrs.word2, in lpfc_sli4_hba_setup()
8708 mqe->un.req_ftrs.word3, phba->cfg_enable_bg, in lpfc_sli4_hba_setup()
8709 phba->cfg_enable_npiv, phba->max_vpi); in lpfc_sli4_hba_setup()
8710 if (!(bf_get(lpfc_mbx_rq_ftr_rsp_dif, &mqe->un.req_ftrs))) in lpfc_sli4_hba_setup()
8711 phba->cfg_enable_bg = 0; in lpfc_sli4_hba_setup()
8712 if (!(bf_get(lpfc_mbx_rq_ftr_rsp_npiv, &mqe->un.req_ftrs))) in lpfc_sli4_hba_setup()
8713 phba->cfg_enable_npiv = 0; in lpfc_sli4_hba_setup()
8717 spin_lock_irq(&phba->hbalock); in lpfc_sli4_hba_setup()
8718 phba->sli3_options |= (LPFC_SLI3_NPIV_ENABLED | LPFC_SLI3_HBQ_ENABLED); in lpfc_sli4_hba_setup()
8719 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_hba_setup()
8724 dd = bf_get(lpfc_mbx_set_feature_dd, &mboxq->u.mqe.un.set_feature); in lpfc_sli4_hba_setup()
8730 "6447 Dual Dump Mailbox x%x (x%x/x%x) failed, " in lpfc_sli4_hba_setup()
8732 bf_get(lpfc_mqe_command, &mboxq->u.mqe), in lpfc_sli4_hba_setup()
8760 rc = lpfc_read_sparam(phba, mboxq, vport->vpi); in lpfc_sli4_hba_setup()
8762 phba->link_state = LPFC_HBA_ERROR; in lpfc_sli4_hba_setup()
8763 rc = -ENOMEM; in lpfc_sli4_hba_setup()
8767 mboxq->vport = vport; in lpfc_sli4_hba_setup()
8769 mp = (struct lpfc_dmabuf *)mboxq->ctx_buf; in lpfc_sli4_hba_setup()
8771 memcpy(&vport->fc_sparam, mp->virt, sizeof(struct serv_parm)); in lpfc_sli4_hba_setup()
8780 lpfc_mbuf_free(phba, mp->virt, mp->phys); in lpfc_sli4_hba_setup()
8782 mboxq->ctx_buf = NULL; in lpfc_sli4_hba_setup()
8788 phba->link_state = LPFC_HBA_ERROR; in lpfc_sli4_hba_setup()
8789 rc = -EIO; in lpfc_sli4_hba_setup()
8796 fc_host_node_name(shost) = wwn_to_u64(vport->fc_nodename.u.wwn); in lpfc_sli4_hba_setup()
8797 fc_host_port_name(shost) = wwn_to_u64(vport->fc_portname.u.wwn); in lpfc_sli4_hba_setup()
8804 rc = -ENODEV; in lpfc_sli4_hba_setup()
8818 /* update host els xri-sgl sizes and mappings */ in lpfc_sli4_hba_setup()
8822 "1400 Failed to update xri-sgl size and " in lpfc_sli4_hba_setup()
8828 rc = lpfc_sli4_repost_sgl_list(phba, &phba->sli4_hba.lpfc_els_sgl_list, in lpfc_sli4_hba_setup()
8829 phba->sli4_hba.els_xri_cnt); in lpfc_sli4_hba_setup()
8834 rc = -ENODEV; in lpfc_sli4_hba_setup()
8837 phba->sli4_hba.els_xri_cnt = rc; in lpfc_sli4_hba_setup()
8839 if (phba->nvmet_support) { in lpfc_sli4_hba_setup()
8840 /* update host nvmet xri-sgl sizes and mappings */ in lpfc_sli4_hba_setup()
8844 "6308 Failed to update nvmet-sgl size " in lpfc_sli4_hba_setup()
8852 &phba->sli4_hba.lpfc_nvmet_sgl_list, in lpfc_sli4_hba_setup()
8853 phba->sli4_hba.nvmet_xri_cnt); in lpfc_sli4_hba_setup()
8858 rc = -ENODEV; in lpfc_sli4_hba_setup()
8861 phba->sli4_hba.nvmet_xri_cnt = rc; in lpfc_sli4_hba_setup()
8866 cnt = phba->sli4_hba.nvmet_xri_cnt + in lpfc_sli4_hba_setup()
8867 phba->sli4_hba.max_cfg_param.max_xri; in lpfc_sli4_hba_setup()
8869 /* update host common xri-sgl sizes and mappings */ in lpfc_sli4_hba_setup()
8873 "6082 Failed to update nvme-sgl size " in lpfc_sli4_hba_setup()
8886 rc = -ENODEV; in lpfc_sli4_hba_setup()
8892 cnt = phba->sli4_hba.max_cfg_param.max_xri; in lpfc_sli4_hba_setup()
8895 if (!phba->sli.iocbq_lookup) { in lpfc_sli4_hba_setup()
8908 if (phba->nvmet_support) in lpfc_sli4_hba_setup()
8911 if (phba->nvmet_support && phba->cfg_nvmet_mrq) { in lpfc_sli4_hba_setup()
8913 for (i = 0; i < phba->cfg_nvmet_mrq; i++) { in lpfc_sli4_hba_setup()
8914 rqbp = phba->sli4_hba.nvmet_mrq_hdr[i]->rqbp; in lpfc_sli4_hba_setup()
8915 INIT_LIST_HEAD(&rqbp->rqb_buffer_list); in lpfc_sli4_hba_setup()
8916 rqbp->rqb_alloc_buffer = lpfc_sli4_nvmet_alloc; in lpfc_sli4_hba_setup()
8917 rqbp->rqb_free_buffer = lpfc_sli4_nvmet_free; in lpfc_sli4_hba_setup()
8918 rqbp->entry_count = LPFC_NVMET_RQE_DEF_COUNT; in lpfc_sli4_hba_setup()
8919 rqbp->buffer_count = 0; in lpfc_sli4_hba_setup()
8922 phba, phba->sli4_hba.nvmet_mrq_hdr[i], in lpfc_sli4_hba_setup()
8923 phba->sli4_hba.nvmet_mrq_data[i], in lpfc_sli4_hba_setup()
8924 phba->cfg_nvmet_mrq_post, i); in lpfc_sli4_hba_setup()
8934 rc = -ENODEV; in lpfc_sli4_hba_setup()
8939 if (!(phba->hba_flag & HBA_FCOE_MODE)) { in lpfc_sli4_hba_setup()
8940 if ((phba->nvmet_support == 0) || (phba->cfg_nvmet_mrq == 1)) { in lpfc_sli4_hba_setup()
8945 mboxq->vport = phba->pport; in lpfc_sli4_hba_setup()
8950 phba->fcf.fcfi = bf_get(lpfc_reg_fcfi_fcfi, in lpfc_sli4_hba_setup()
8951 &mboxq->u.mqe.un.reg_fcfi); in lpfc_sli4_hba_setup()
8957 mboxq->vport = phba->pport; in lpfc_sli4_hba_setup()
8962 phba->fcf.fcfi = bf_get(lpfc_reg_fcfi_mrq_fcfi, in lpfc_sli4_hba_setup()
8963 &mboxq->u.mqe.un.reg_fcfi_mrq); in lpfc_sli4_hba_setup()
8967 mboxq->vport = phba->pport; in lpfc_sli4_hba_setup()
8980 if (phba->nvmet_support == 0) { in lpfc_sli4_hba_setup()
8981 if (phba->sli4_hba.io_xri_cnt == 0) { in lpfc_sli4_hba_setup()
8983 phba, phba->sli4_hba.io_xri_max); in lpfc_sli4_hba_setup()
8985 rc = -ENOMEM; in lpfc_sli4_hba_setup()
8989 if (phba->cfg_xri_rebalancing) in lpfc_sli4_hba_setup()
8993 phba->cfg_xri_rebalancing = 0; in lpfc_sli4_hba_setup()
8996 /* Allow asynchronous mailbox command to go through */ in lpfc_sli4_hba_setup()
8997 spin_lock_irq(&phba->hbalock); in lpfc_sli4_hba_setup()
8998 phba->sli.sli_flag &= ~LPFC_SLI_ASYNC_MBX_BLK; in lpfc_sli4_hba_setup()
8999 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_hba_setup()
9005 phba->fcf.fcf_flag = 0; in lpfc_sli4_hba_setup()
9006 phba->fcf.current_rec.flag = 0; in lpfc_sli4_hba_setup()
9009 mod_timer(&vport->els_tmofunc, in lpfc_sli4_hba_setup()
9010 jiffies + msecs_to_jiffies(1000 * (phba->fc_ratov * 2))); in lpfc_sli4_hba_setup()
9013 mod_timer(&phba->hb_tmofunc, in lpfc_sli4_hba_setup()
9015 phba->hba_flag &= ~(HBA_HBEAT_INP | HBA_HBEAT_TMO); in lpfc_sli4_hba_setup()
9016 phba->last_completion_time = jiffies; in lpfc_sli4_hba_setup()
9019 if (phba->cfg_auto_imax) in lpfc_sli4_hba_setup()
9020 queue_delayed_work(phba->wq, &phba->eq_delay_work, in lpfc_sli4_hba_setup()
9027 mod_timer(&phba->eratt_poll, in lpfc_sli4_hba_setup()
9028 jiffies + msecs_to_jiffies(1000 * phba->eratt_poll_interval)); in lpfc_sli4_hba_setup()
9034 spin_lock_irq(&phba->hbalock); in lpfc_sli4_hba_setup()
9035 phba->link_state = LPFC_LINK_DOWN; in lpfc_sli4_hba_setup()
9038 if (bf_get(lpfc_conf_trunk_port0, &phba->sli4_hba)) in lpfc_sli4_hba_setup()
9039 phba->trunk_link.link0.state = LPFC_LINK_DOWN; in lpfc_sli4_hba_setup()
9040 if (bf_get(lpfc_conf_trunk_port1, &phba->sli4_hba)) in lpfc_sli4_hba_setup()
9041 phba->trunk_link.link1.state = LPFC_LINK_DOWN; in lpfc_sli4_hba_setup()
9042 if (bf_get(lpfc_conf_trunk_port2, &phba->sli4_hba)) in lpfc_sli4_hba_setup()
9043 phba->trunk_link.link2.state = LPFC_LINK_DOWN; in lpfc_sli4_hba_setup()
9044 if (bf_get(lpfc_conf_trunk_port3, &phba->sli4_hba)) in lpfc_sli4_hba_setup()
9045 phba->trunk_link.link3.state = LPFC_LINK_DOWN; in lpfc_sli4_hba_setup()
9046 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_hba_setup()
9052 phba->sli4_hba.intr_enable = 1; in lpfc_sli4_hba_setup()
9057 if (!(phba->hba_flag & HBA_FCOE_MODE) && in lpfc_sli4_hba_setup()
9058 (phba->hba_flag & LINK_DISABLED)) { in lpfc_sli4_hba_setup()
9069 } else if (phba->cfg_suppress_link_up == LPFC_INITIALIZE_LINK) { in lpfc_sli4_hba_setup()
9071 if (!(phba->link_flag & LS_LOOPBACK_MODE)) { in lpfc_sli4_hba_setup()
9072 rc = phba->lpfc_hba_init_link(phba, MBX_NOWAIT); in lpfc_sli4_hba_setup()
9077 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_hba_setup()
9082 phba->hba_flag |= HBA_SETUP; in lpfc_sli4_hba_setup()
9098 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_hba_setup()
9103 * lpfc_mbox_timeout - Timeout call back function for mbox timer
9106 * This is the callback function for mailbox timer. The mailbox
9107 * timer is armed when a new mailbox command is issued and the timer
9108 * is deleted when the mailbox complete. The function is called by
9109 * the kernel timer code when a mailbox does not complete within
9111 * process the mailbox timeout and returns. All the processing is
9121 spin_lock_irqsave(&phba->pport->work_port_lock, iflag); in lpfc_mbox_timeout()
9122 tmo_posted = phba->pport->work_port_events & WORKER_MBOX_TMO; in lpfc_mbox_timeout()
9124 phba->pport->work_port_events |= WORKER_MBOX_TMO; in lpfc_mbox_timeout()
9125 spin_unlock_irqrestore(&phba->pport->work_port_lock, iflag); in lpfc_mbox_timeout()
9133 * lpfc_sli4_mbox_completions_pending - check to see if any mailbox completions
9137 * This function checks if any mailbox completions are present on the mailbox
9150 if (unlikely(!phba) || (phba->sli_rev != LPFC_SLI_REV4)) in lpfc_sli4_mbox_completions_pending()
9153 /* Check for completions on mailbox completion queue */ in lpfc_sli4_mbox_completions_pending()
9155 mcq = phba->sli4_hba.mbx_cq; in lpfc_sli4_mbox_completions_pending()
9156 idx = mcq->hba_index; in lpfc_sli4_mbox_completions_pending()
9157 qe_valid = mcq->qe_valid; in lpfc_sli4_mbox_completions_pending()
9166 idx = (idx + 1) % mcq->entry_count; in lpfc_sli4_mbox_completions_pending()
9167 if (mcq->hba_index == idx) in lpfc_sli4_mbox_completions_pending()
9171 if (phba->sli4_hba.pc_sli4_params.cqav && !idx) in lpfc_sli4_mbox_completions_pending()
9179 * lpfc_sli4_process_missed_mbox_completions - process mbox completions
9184 * maybe missed causing erroneous mailbox timeouts to occur. This function
9185 * checks to see if mbox completions are on the mailbox completion queue
9187 * mailbox completion queue.
9192 struct lpfc_sli4_hba *sli4_hba = &phba->sli4_hba; in lpfc_sli4_process_missed_mbox_completions()
9198 if (unlikely(!phba) || (phba->sli_rev != LPFC_SLI_REV4)) in lpfc_sli4_process_missed_mbox_completions()
9202 if (sli4_hba->hdwq) { in lpfc_sli4_process_missed_mbox_completions()
9203 for (eqidx = 0; eqidx < phba->cfg_irq_chann; eqidx++) { in lpfc_sli4_process_missed_mbox_completions()
9204 eq = phba->sli4_hba.hba_eq_hdl[eqidx].eq; in lpfc_sli4_process_missed_mbox_completions()
9205 if (eq && eq->queue_id == sli4_hba->mbx_cq->assoc_qid) { in lpfc_sli4_process_missed_mbox_completions()
9216 sli4_hba->sli4_eq_clr_intr(fpeq); in lpfc_sli4_process_missed_mbox_completions()
9225 * mailbox commands, async events, els commands, receive queue data in lpfc_sli4_process_missed_mbox_completions()
9234 /* Always clear and re-arm the EQ */ in lpfc_sli4_process_missed_mbox_completions()
9235 sli4_hba->sli4_write_eq_db(phba, fpeq, 0, LPFC_QUEUE_REARM); in lpfc_sli4_process_missed_mbox_completions()
9242 * lpfc_mbox_timeout_handler - Worker thread function to handle mailbox timeout
9245 * This function is called from worker thread when a mailbox command times out.
9252 LPFC_MBOXQ_t *pmbox = phba->sli.mbox_active; in lpfc_mbox_timeout_handler()
9255 struct lpfc_sli *psli = &phba->sli; in lpfc_mbox_timeout_handler()
9257 /* If the mailbox completed, process the completion */ in lpfc_mbox_timeout_handler()
9260 if (!(psli->sli_flag & LPFC_SLI_ACTIVE)) in lpfc_mbox_timeout_handler()
9264 mb = &pmbox->u.mb; in lpfc_mbox_timeout_handler()
9267 * worklist and the mailbox actually completing. When this in lpfc_mbox_timeout_handler()
9270 spin_lock_irq(&phba->hbalock); in lpfc_mbox_timeout_handler()
9274 "0353 Active Mailbox cleared - mailbox timeout " in lpfc_mbox_timeout_handler()
9276 spin_unlock_irq(&phba->hbalock); in lpfc_mbox_timeout_handler()
9282 "0310 Mailbox command x%x timeout Data: x%x x%x x%px\n", in lpfc_mbox_timeout_handler()
9283 mb->mbxCommand, in lpfc_mbox_timeout_handler()
9284 phba->pport->port_state, in lpfc_mbox_timeout_handler()
9285 phba->sli.sli_flag, in lpfc_mbox_timeout_handler()
9286 phba->sli.mbox_active); in lpfc_mbox_timeout_handler()
9287 spin_unlock_irq(&phba->hbalock); in lpfc_mbox_timeout_handler()
9293 set_bit(MBX_TMO_ERR, &phba->bit_flags); in lpfc_mbox_timeout_handler()
9294 spin_lock_irq(&phba->pport->work_port_lock); in lpfc_mbox_timeout_handler()
9295 phba->pport->work_port_events &= ~WORKER_MBOX_TMO; in lpfc_mbox_timeout_handler()
9296 spin_unlock_irq(&phba->pport->work_port_lock); in lpfc_mbox_timeout_handler()
9297 spin_lock_irq(&phba->hbalock); in lpfc_mbox_timeout_handler()
9298 phba->link_state = LPFC_LINK_UNKNOWN; in lpfc_mbox_timeout_handler()
9299 psli->sli_flag &= ~LPFC_SLI_ACTIVE; in lpfc_mbox_timeout_handler()
9300 spin_unlock_irq(&phba->hbalock); in lpfc_mbox_timeout_handler()
9303 "0345 Resetting board due to mailbox timeout\n"); in lpfc_mbox_timeout_handler()
9310 * lpfc_sli_issue_mbox_s3 - Issue an SLI3 mailbox command to firmware
9312 * @pmbox: Pointer to mailbox object.
9313 * @flag: Flag indicating how the mailbox need to be processed.
9316 * to submit a mailbox command to firmware with SLI-3 interface spec. This
9318 * The mailbox command can be submitted in polling mode, in which case
9320 * mailbox.
9321 * If the mailbox is submitted in no_wait mode (not polling) the
9323 * for the mailbox completion. The no_wait is supported only when HBA
9324 * is in SLI2/SLI3 mode - interrupts are enabled.
9325 * The SLI interface allows only one mailbox pending at a time. If the
9326 * mailbox is issued in polling mode and there is already a mailbox
9327 * pending, then the function will return an error. If the mailbox is issued
9328 * in NO_WAIT mode and there is a mailbox pending already, the function
9329 * will return MBX_BUSY after queuing the mailbox into mailbox queue.
9330 * The sli layer owns the mailbox object until the completion of mailbox
9332 * return codes the caller owns the mailbox command after the return of
9340 struct lpfc_sli *psli = &phba->sli; in lpfc_sli_issue_mbox_s3()
9350 spin_lock_irqsave(&phba->hbalock, drvr_flag); in lpfc_sli_issue_mbox_s3()
9352 phba->sli.sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; in lpfc_sli_issue_mbox_s3()
9354 if (unlikely(psli->sli_flag & LPFC_SLI_ASYNC_MBX_BLK)) { in lpfc_sli_issue_mbox_s3()
9355 spin_unlock_irqrestore(&phba->hbalock, drvr_flag); in lpfc_sli_issue_mbox_s3()
9361 spin_unlock_irqrestore(&phba->hbalock, drvr_flag); in lpfc_sli_issue_mbox_s3()
9366 if (pmbox->mbox_cmpl && pmbox->mbox_cmpl != lpfc_sli_def_mbox_cmpl && in lpfc_sli_issue_mbox_s3()
9367 pmbox->mbox_cmpl != lpfc_sli_wake_mbox_wait) { in lpfc_sli_issue_mbox_s3()
9368 if(!pmbox->vport) { in lpfc_sli_issue_mbox_s3()
9369 spin_unlock_irqrestore(&phba->hbalock, drvr_flag); in lpfc_sli_issue_mbox_s3()
9373 pmbox->u.mb.mbxCommand); in lpfc_sli_issue_mbox_s3()
9380 if (unlikely(pci_channel_offline(phba->pcidev))) { in lpfc_sli_issue_mbox_s3()
9381 spin_unlock_irqrestore(&phba->hbalock, drvr_flag); in lpfc_sli_issue_mbox_s3()
9386 if (unlikely(phba->hba_flag & DEFER_ERATT)) { in lpfc_sli_issue_mbox_s3()
9387 spin_unlock_irqrestore(&phba->hbalock, drvr_flag); in lpfc_sli_issue_mbox_s3()
9391 psli = &phba->sli; in lpfc_sli_issue_mbox_s3()
9393 mbx = &pmbox->u.mb; in lpfc_sli_issue_mbox_s3()
9396 if (phba->link_state == LPFC_HBA_ERROR) { in lpfc_sli_issue_mbox_s3()
9397 spin_unlock_irqrestore(&phba->hbalock, drvr_flag); in lpfc_sli_issue_mbox_s3()
9401 "(%d):0311 Mailbox command x%x cannot " in lpfc_sli_issue_mbox_s3()
9403 pmbox->vport ? pmbox->vport->vpi : 0, in lpfc_sli_issue_mbox_s3()
9404 pmbox->u.mb.mbxCommand, psli->sli_flag, flag); in lpfc_sli_issue_mbox_s3()
9408 if (mbx->mbxCommand != MBX_KILL_BOARD && flag & MBX_NOWAIT) { in lpfc_sli_issue_mbox_s3()
9409 if (lpfc_readl(phba->HCregaddr, &hc_copy) || in lpfc_sli_issue_mbox_s3()
9411 spin_unlock_irqrestore(&phba->hbalock, drvr_flag); in lpfc_sli_issue_mbox_s3()
9413 "(%d):2528 Mailbox command x%x cannot " in lpfc_sli_issue_mbox_s3()
9415 pmbox->vport ? pmbox->vport->vpi : 0, in lpfc_sli_issue_mbox_s3()
9416 pmbox->u.mb.mbxCommand, psli->sli_flag, flag); in lpfc_sli_issue_mbox_s3()
9421 if (psli->sli_flag & LPFC_SLI_MBOX_ACTIVE) { in lpfc_sli_issue_mbox_s3()
9428 spin_unlock_irqrestore(&phba->hbalock, drvr_flag); in lpfc_sli_issue_mbox_s3()
9432 "(%d):2529 Mailbox command x%x " in lpfc_sli_issue_mbox_s3()
9434 pmbox->vport ? pmbox->vport->vpi : 0, in lpfc_sli_issue_mbox_s3()
9435 pmbox->u.mb.mbxCommand, in lpfc_sli_issue_mbox_s3()
9436 psli->sli_flag, flag); in lpfc_sli_issue_mbox_s3()
9440 if (!(psli->sli_flag & LPFC_SLI_ACTIVE)) { in lpfc_sli_issue_mbox_s3()
9441 spin_unlock_irqrestore(&phba->hbalock, drvr_flag); in lpfc_sli_issue_mbox_s3()
9444 "(%d):2530 Mailbox command x%x " in lpfc_sli_issue_mbox_s3()
9446 pmbox->vport ? pmbox->vport->vpi : 0, in lpfc_sli_issue_mbox_s3()
9447 pmbox->u.mb.mbxCommand, in lpfc_sli_issue_mbox_s3()
9448 psli->sli_flag, flag); in lpfc_sli_issue_mbox_s3()
9452 /* Another mailbox command is still being processed, queue this in lpfc_sli_issue_mbox_s3()
9457 /* Mbox cmd issue - BUSY */ in lpfc_sli_issue_mbox_s3()
9459 "(%d):0308 Mbox cmd issue - BUSY Data: " in lpfc_sli_issue_mbox_s3()
9461 pmbox->vport ? pmbox->vport->vpi : 0xffffff, in lpfc_sli_issue_mbox_s3()
9462 mbx->mbxCommand, in lpfc_sli_issue_mbox_s3()
9463 phba->pport ? phba->pport->port_state : 0xff, in lpfc_sli_issue_mbox_s3()
9464 psli->sli_flag, flag); in lpfc_sli_issue_mbox_s3()
9466 psli->slistat.mbox_busy++; in lpfc_sli_issue_mbox_s3()
9467 spin_unlock_irqrestore(&phba->hbalock, drvr_flag); in lpfc_sli_issue_mbox_s3()
9469 if (pmbox->vport) { in lpfc_sli_issue_mbox_s3()
9470 lpfc_debugfs_disc_trc(pmbox->vport, in lpfc_sli_issue_mbox_s3()
9473 (uint32_t)mbx->mbxCommand, in lpfc_sli_issue_mbox_s3()
9474 mbx->un.varWords[0], mbx->un.varWords[1]); in lpfc_sli_issue_mbox_s3()
9477 lpfc_debugfs_disc_trc(phba->pport, in lpfc_sli_issue_mbox_s3()
9480 (uint32_t)mbx->mbxCommand, in lpfc_sli_issue_mbox_s3()
9481 mbx->un.varWords[0], mbx->un.varWords[1]); in lpfc_sli_issue_mbox_s3()
9487 psli->sli_flag |= LPFC_SLI_MBOX_ACTIVE; in lpfc_sli_issue_mbox_s3()
9491 if (!(psli->sli_flag & LPFC_SLI_ACTIVE) && in lpfc_sli_issue_mbox_s3()
9492 (mbx->mbxCommand != MBX_KILL_BOARD)) { in lpfc_sli_issue_mbox_s3()
9493 psli->sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; in lpfc_sli_issue_mbox_s3()
9494 spin_unlock_irqrestore(&phba->hbalock, drvr_flag); in lpfc_sli_issue_mbox_s3()
9497 "(%d):2531 Mailbox command x%x " in lpfc_sli_issue_mbox_s3()
9499 pmbox->vport ? pmbox->vport->vpi : 0, in lpfc_sli_issue_mbox_s3()
9500 pmbox->u.mb.mbxCommand, in lpfc_sli_issue_mbox_s3()
9501 psli->sli_flag, flag); in lpfc_sli_issue_mbox_s3()
9507 mod_timer(&psli->mbox_tmo, jiffies + timeout); in lpfc_sli_issue_mbox_s3()
9510 /* Mailbox cmd <cmd> issue */ in lpfc_sli_issue_mbox_s3()
9512 "(%d):0309 Mailbox cmd x%x issue Data: x%x x%x " in lpfc_sli_issue_mbox_s3()
9514 pmbox->vport ? pmbox->vport->vpi : 0, in lpfc_sli_issue_mbox_s3()
9515 mbx->mbxCommand, in lpfc_sli_issue_mbox_s3()
9516 phba->pport ? phba->pport->port_state : 0xff, in lpfc_sli_issue_mbox_s3()
9517 psli->sli_flag, flag); in lpfc_sli_issue_mbox_s3()
9519 if (mbx->mbxCommand != MBX_HEARTBEAT) { in lpfc_sli_issue_mbox_s3()
9520 if (pmbox->vport) { in lpfc_sli_issue_mbox_s3()
9521 lpfc_debugfs_disc_trc(pmbox->vport, in lpfc_sli_issue_mbox_s3()
9524 (uint32_t)mbx->mbxCommand, in lpfc_sli_issue_mbox_s3()
9525 mbx->un.varWords[0], mbx->un.varWords[1]); in lpfc_sli_issue_mbox_s3()
9528 lpfc_debugfs_disc_trc(phba->pport, in lpfc_sli_issue_mbox_s3()
9531 (uint32_t)mbx->mbxCommand, in lpfc_sli_issue_mbox_s3()
9532 mbx->un.varWords[0], mbx->un.varWords[1]); in lpfc_sli_issue_mbox_s3()
9536 psli->slistat.mbox_cmd++; in lpfc_sli_issue_mbox_s3()
9537 evtctr = psli->slistat.mbox_event; in lpfc_sli_issue_mbox_s3()
9540 mbx->mbxOwner = OWN_CHIP; in lpfc_sli_issue_mbox_s3()
9542 if (psli->sli_flag & LPFC_SLI_ACTIVE) { in lpfc_sli_issue_mbox_s3()
9544 if (pmbox->in_ext_byte_len || pmbox->out_ext_byte_len) { in lpfc_sli_issue_mbox_s3()
9545 *(((uint32_t *)mbx) + pmbox->mbox_offset_word) in lpfc_sli_issue_mbox_s3()
9546 = (uint8_t *)phba->mbox_ext in lpfc_sli_issue_mbox_s3()
9547 - (uint8_t *)phba->mbox; in lpfc_sli_issue_mbox_s3()
9550 /* Copy the mailbox extension data */ in lpfc_sli_issue_mbox_s3()
9551 if (pmbox->in_ext_byte_len && pmbox->ctx_buf) { in lpfc_sli_issue_mbox_s3()
9552 lpfc_sli_pcimem_bcopy(pmbox->ctx_buf, in lpfc_sli_issue_mbox_s3()
9553 (uint8_t *)phba->mbox_ext, in lpfc_sli_issue_mbox_s3()
9554 pmbox->in_ext_byte_len); in lpfc_sli_issue_mbox_s3()
9557 lpfc_sli_pcimem_bcopy(mbx, phba->mbox, MAILBOX_CMD_SIZE); in lpfc_sli_issue_mbox_s3()
9560 if (pmbox->in_ext_byte_len || pmbox->out_ext_byte_len) in lpfc_sli_issue_mbox_s3()
9561 *(((uint32_t *)mbx) + pmbox->mbox_offset_word) in lpfc_sli_issue_mbox_s3()
9564 /* Copy the mailbox extension data */ in lpfc_sli_issue_mbox_s3()
9565 if (pmbox->in_ext_byte_len && pmbox->ctx_buf) in lpfc_sli_issue_mbox_s3()
9566 lpfc_memcpy_to_slim(phba->MBslimaddr + in lpfc_sli_issue_mbox_s3()
9568 pmbox->ctx_buf, pmbox->in_ext_byte_len); in lpfc_sli_issue_mbox_s3()
9570 if (mbx->mbxCommand == MBX_CONFIG_PORT) in lpfc_sli_issue_mbox_s3()
9572 lpfc_sli_pcimem_bcopy(mbx, phba->mbox, in lpfc_sli_issue_mbox_s3()
9577 to_slim = phba->MBslimaddr + sizeof (uint32_t); in lpfc_sli_issue_mbox_s3()
9578 lpfc_memcpy_to_slim(to_slim, &mbx->un.varWords[0], in lpfc_sli_issue_mbox_s3()
9579 MAILBOX_CMD_SIZE - sizeof (uint32_t)); in lpfc_sli_issue_mbox_s3()
9583 to_slim = phba->MBslimaddr; in lpfc_sli_issue_mbox_s3()
9587 if (mbx->mbxCommand == MBX_CONFIG_PORT) in lpfc_sli_issue_mbox_s3()
9588 /* switch over to host mailbox */ in lpfc_sli_issue_mbox_s3()
9589 psli->sli_flag |= LPFC_SLI_ACTIVE; in lpfc_sli_issue_mbox_s3()
9596 /* Set up reference to mailbox command */ in lpfc_sli_issue_mbox_s3()
9597 psli->mbox_active = pmbox; in lpfc_sli_issue_mbox_s3()
9599 writel(CA_MBATT, phba->CAregaddr); in lpfc_sli_issue_mbox_s3()
9600 readl(phba->CAregaddr); /* flush */ in lpfc_sli_issue_mbox_s3()
9605 /* Set up null reference to mailbox command */ in lpfc_sli_issue_mbox_s3()
9606 psli->mbox_active = NULL; in lpfc_sli_issue_mbox_s3()
9608 writel(CA_MBATT, phba->CAregaddr); in lpfc_sli_issue_mbox_s3()
9609 readl(phba->CAregaddr); /* flush */ in lpfc_sli_issue_mbox_s3()
9611 if (psli->sli_flag & LPFC_SLI_ACTIVE) { in lpfc_sli_issue_mbox_s3()
9613 word0 = *((uint32_t *)phba->mbox); in lpfc_sli_issue_mbox_s3()
9617 if (lpfc_readl(phba->MBslimaddr, &word0)) { in lpfc_sli_issue_mbox_s3()
9618 spin_unlock_irqrestore(&phba->hbalock, in lpfc_sli_issue_mbox_s3()
9625 if (lpfc_readl(phba->HAregaddr, &ha_copy)) { in lpfc_sli_issue_mbox_s3()
9626 spin_unlock_irqrestore(&phba->hbalock, in lpfc_sli_issue_mbox_s3()
9636 (phba->link_state > LPFC_WARM_START))) { in lpfc_sli_issue_mbox_s3()
9638 psli->sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; in lpfc_sli_issue_mbox_s3()
9639 spin_unlock_irqrestore(&phba->hbalock, in lpfc_sli_issue_mbox_s3()
9647 && (evtctr != psli->slistat.mbox_event)) in lpfc_sli_issue_mbox_s3()
9651 spin_unlock_irqrestore(&phba->hbalock, in lpfc_sli_issue_mbox_s3()
9654 spin_lock_irqsave(&phba->hbalock, drvr_flag); in lpfc_sli_issue_mbox_s3()
9657 if (psli->sli_flag & LPFC_SLI_ACTIVE) { in lpfc_sli_issue_mbox_s3()
9659 word0 = *((uint32_t *)phba->mbox); in lpfc_sli_issue_mbox_s3()
9661 if (mbx->mbxCommand == MBX_CONFIG_PORT) { in lpfc_sli_issue_mbox_s3()
9665 slimword0 = readl(phba->MBslimaddr); in lpfc_sli_issue_mbox_s3()
9668 && slimmb->mbxStatus) { in lpfc_sli_issue_mbox_s3()
9669 psli->sli_flag &= in lpfc_sli_issue_mbox_s3()
9676 word0 = readl(phba->MBslimaddr); in lpfc_sli_issue_mbox_s3()
9679 if (lpfc_readl(phba->HAregaddr, &ha_copy)) { in lpfc_sli_issue_mbox_s3()
9680 spin_unlock_irqrestore(&phba->hbalock, in lpfc_sli_issue_mbox_s3()
9686 if (psli->sli_flag & LPFC_SLI_ACTIVE) { in lpfc_sli_issue_mbox_s3()
9688 lpfc_sli_pcimem_bcopy(phba->mbox, mbx, in lpfc_sli_issue_mbox_s3()
9690 /* Copy the mailbox extension data */ in lpfc_sli_issue_mbox_s3()
9691 if (pmbox->out_ext_byte_len && pmbox->ctx_buf) { in lpfc_sli_issue_mbox_s3()
9692 lpfc_sli_pcimem_bcopy(phba->mbox_ext, in lpfc_sli_issue_mbox_s3()
9693 pmbox->ctx_buf, in lpfc_sli_issue_mbox_s3()
9694 pmbox->out_ext_byte_len); in lpfc_sli_issue_mbox_s3()
9698 lpfc_memcpy_from_slim(mbx, phba->MBslimaddr, in lpfc_sli_issue_mbox_s3()
9700 /* Copy the mailbox extension data */ in lpfc_sli_issue_mbox_s3()
9701 if (pmbox->out_ext_byte_len && pmbox->ctx_buf) { in lpfc_sli_issue_mbox_s3()
9703 pmbox->ctx_buf, in lpfc_sli_issue_mbox_s3()
9704 phba->MBslimaddr + in lpfc_sli_issue_mbox_s3()
9706 pmbox->out_ext_byte_len); in lpfc_sli_issue_mbox_s3()
9710 writel(HA_MBATT, phba->HAregaddr); in lpfc_sli_issue_mbox_s3()
9711 readl(phba->HAregaddr); /* flush */ in lpfc_sli_issue_mbox_s3()
9713 psli->sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; in lpfc_sli_issue_mbox_s3()
9714 status = mbx->mbxStatus; in lpfc_sli_issue_mbox_s3()
9717 spin_unlock_irqrestore(&phba->hbalock, drvr_flag); in lpfc_sli_issue_mbox_s3()
9722 pmbox->u.mb.mbxStatus = MBX_NOT_FINISHED; in lpfc_sli_issue_mbox_s3()
9729 * lpfc_sli4_async_mbox_block - Block posting SLI4 asynchronous mailbox command
9732 * The function blocks the posting of SLI4 asynchronous mailbox commands from
9733 * the driver internal pending mailbox queue. It will then try to wait out the
9734 * possible outstanding mailbox command before return.
9737 * 0 - the outstanding mailbox command completed; otherwise, the wait for
9738 * the outstanding mailbox command timed out.
9743 struct lpfc_sli *psli = &phba->sli; in lpfc_sli4_async_mbox_block()
9750 /* Mark the asynchronous mailbox command posting as blocked */ in lpfc_sli4_async_mbox_block()
9751 spin_lock_irq(&phba->hbalock); in lpfc_sli4_async_mbox_block()
9752 psli->sli_flag |= LPFC_SLI_ASYNC_MBX_BLK; in lpfc_sli4_async_mbox_block()
9753 /* Determine how long we might wait for the active mailbox in lpfc_sli4_async_mbox_block()
9756 if (phba->sli.mbox_active) in lpfc_sli4_async_mbox_block()
9758 phba->sli.mbox_active) * in lpfc_sli4_async_mbox_block()
9760 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_mbox_block()
9762 /* Make sure the mailbox is really active */ in lpfc_sli4_async_mbox_block()
9766 /* Wait for the outstanding mailbox command to complete */ in lpfc_sli4_async_mbox_block()
9767 while (phba->sli.mbox_active) { in lpfc_sli4_async_mbox_block()
9768 /* Check active mailbox complete status every 2ms */ in lpfc_sli4_async_mbox_block()
9777 spin_lock_irq(&phba->hbalock); in lpfc_sli4_async_mbox_block()
9778 if (phba->sli.mbox_active) { in lpfc_sli4_async_mbox_block()
9779 mboxq = phba->sli.mbox_active; in lpfc_sli4_async_mbox_block()
9780 cmd = mboxq->u.mb.mbxCommand; in lpfc_sli4_async_mbox_block()
9785 sli_flag = psli->sli_flag; in lpfc_sli4_async_mbox_block()
9786 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_mbox_block()
9788 "2352 Mailbox command x%x " in lpfc_sli4_async_mbox_block()
9794 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_mbox_block()
9802 /* Can not cleanly block async mailbox command, fails it */ in lpfc_sli4_async_mbox_block()
9804 spin_lock_irq(&phba->hbalock); in lpfc_sli4_async_mbox_block()
9805 psli->sli_flag &= ~LPFC_SLI_ASYNC_MBX_BLK; in lpfc_sli4_async_mbox_block()
9806 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_mbox_block()
9812 * lpfc_sli4_async_mbox_unblock - Block posting SLI4 async mailbox command
9815 * The function unblocks and resume posting of SLI4 asynchronous mailbox
9816 * commands from the driver internal pending mailbox queue. It makes sure
9817 * that there is no outstanding mailbox command before resuming posting
9818 * asynchronous mailbox commands. If, for any reason, there is outstanding
9819 * mailbox command, it will try to wait it out before resuming asynchronous
9820 * mailbox command posting.
9825 struct lpfc_sli *psli = &phba->sli; in lpfc_sli4_async_mbox_unblock()
9827 spin_lock_irq(&phba->hbalock); in lpfc_sli4_async_mbox_unblock()
9828 if (!(psli->sli_flag & LPFC_SLI_ASYNC_MBX_BLK)) { in lpfc_sli4_async_mbox_unblock()
9829 /* Asynchronous mailbox posting is not blocked, do nothing */ in lpfc_sli4_async_mbox_unblock()
9830 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_mbox_unblock()
9834 /* Outstanding synchronous mailbox command is guaranteed to be done, in lpfc_sli4_async_mbox_unblock()
9835 * successful or timeout, after timing-out the outstanding mailbox in lpfc_sli4_async_mbox_unblock()
9837 * mailbox command and resume in lpfc_sli4_async_mbox_unblock()
9839 psli->sli_flag &= ~LPFC_SLI_ASYNC_MBX_BLK; in lpfc_sli4_async_mbox_unblock()
9840 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_async_mbox_unblock()
9842 /* wake up worker thread to post asynchronous mailbox command */ in lpfc_sli4_async_mbox_unblock()
9847 * lpfc_sli4_wait_bmbx_ready - Wait for bootstrap mailbox register ready
9849 * @mboxq: Pointer to mailbox object.
9851 * The function waits for the bootstrap mailbox register ready bit from
9852 * port for twice the regular mailbox command timeout value.
9854 * 0 - no timeout on waiting for bootstrap mailbox register ready.
9855 * MBXERR_ERROR - wait for bootstrap mailbox register timed out or port
9864 struct lpfc_register portstat_reg = {-1}; in lpfc_sli4_wait_bmbx_ready()
9866 /* Sanity check - there is no point to wait if the port is in an in lpfc_sli4_wait_bmbx_ready()
9869 if (bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf) >= in lpfc_sli4_wait_bmbx_ready()
9871 if (lpfc_readl(phba->sli4_hba.u.if_type2.STATUSregaddr, in lpfc_sli4_wait_bmbx_ready()
9886 bmbx_reg.word0 = readl(phba->sli4_hba.BMBXregaddr); in lpfc_sli4_wait_bmbx_ready()
9899 * lpfc_sli4_post_sync_mbox - Post an SLI4 mailbox to the bootstrap mailbox
9901 * @mboxq: Pointer to mailbox object.
9903 * The function posts a mailbox to the port. The mailbox is expected
9906 * mailbox by polling for its completion.
9911 * MBX_SUCCESS - mailbox posted successfully
9921 struct lpfc_sli *psli = &phba->sli; in lpfc_sli4_post_sync_mbox()
9922 struct lpfc_mqe *mb = &mboxq->u.mqe; in lpfc_sli4_post_sync_mbox()
9927 * Only one mailbox can be active to the bootstrap mailbox region in lpfc_sli4_post_sync_mbox()
9930 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli4_post_sync_mbox()
9931 if (psli->sli_flag & LPFC_SLI_MBOX_ACTIVE) { in lpfc_sli4_post_sync_mbox()
9932 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli4_post_sync_mbox()
9934 "(%d):2532 Mailbox command x%x (x%x/x%x) " in lpfc_sli4_post_sync_mbox()
9936 mboxq->vport ? mboxq->vport->vpi : 0, in lpfc_sli4_post_sync_mbox()
9937 mboxq->u.mb.mbxCommand, in lpfc_sli4_post_sync_mbox()
9940 psli->sli_flag, MBX_POLL); in lpfc_sli4_post_sync_mbox()
9944 psli->sli_flag |= LPFC_SLI_MBOX_ACTIVE; in lpfc_sli4_post_sync_mbox()
9945 phba->sli.mbox_active = mboxq; in lpfc_sli4_post_sync_mbox()
9946 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli4_post_sync_mbox()
9954 * in the mailbox post. Then copy the caller's mailbox contents to in lpfc_sli4_post_sync_mbox()
9955 * the bmbx mailbox region. in lpfc_sli4_post_sync_mbox()
9958 memset(phba->sli4_hba.bmbx.avirt, 0, sizeof(struct lpfc_bmbx_create)); in lpfc_sli4_post_sync_mbox()
9959 lpfc_sli4_pcimem_bcopy(mb, phba->sli4_hba.bmbx.avirt, in lpfc_sli4_post_sync_mbox()
9962 /* Post the high mailbox dma address to the port and wait for ready. */ in lpfc_sli4_post_sync_mbox()
9963 dma_address = &phba->sli4_hba.bmbx.dma_address; in lpfc_sli4_post_sync_mbox()
9964 writel(dma_address->addr_hi, phba->sli4_hba.BMBXregaddr); in lpfc_sli4_post_sync_mbox()
9966 /* wait for bootstrap mbox register for hi-address write done */ in lpfc_sli4_post_sync_mbox()
9971 /* Post the low mailbox dma address to the port. */ in lpfc_sli4_post_sync_mbox()
9972 writel(dma_address->addr_lo, phba->sli4_hba.BMBXregaddr); in lpfc_sli4_post_sync_mbox()
9980 * Read the CQ to ensure the mailbox has completed. in lpfc_sli4_post_sync_mbox()
9981 * If so, update the mailbox status so that the upper layers in lpfc_sli4_post_sync_mbox()
9984 lpfc_sli4_pcimem_bcopy(phba->sli4_hba.bmbx.avirt, mb, in lpfc_sli4_post_sync_mbox()
9986 mbox_rgn = (struct lpfc_bmbx_create *) phba->sli4_hba.bmbx.avirt; in lpfc_sli4_post_sync_mbox()
9987 lpfc_sli4_pcimem_bcopy(&mbox_rgn->mcqe, &mboxq->mcqe, in lpfc_sli4_post_sync_mbox()
9989 mcqe_status = bf_get(lpfc_mcqe_status, &mbox_rgn->mcqe); in lpfc_sli4_post_sync_mbox()
9991 * When the CQE status indicates a failure and the mailbox status in lpfc_sli4_post_sync_mbox()
9992 * indicates success then copy the CQE status into the mailbox status in lpfc_sli4_post_sync_mbox()
10004 "(%d):0356 Mailbox cmd x%x (x%x/x%x) Status x%x " in lpfc_sli4_post_sync_mbox()
10007 mboxq->vport ? mboxq->vport->vpi : 0, mbx_cmnd, in lpfc_sli4_post_sync_mbox()
10011 mb->un.mb_words[0], mb->un.mb_words[1], in lpfc_sli4_post_sync_mbox()
10012 mb->un.mb_words[2], mb->un.mb_words[3], in lpfc_sli4_post_sync_mbox()
10013 mb->un.mb_words[4], mb->un.mb_words[5], in lpfc_sli4_post_sync_mbox()
10014 mb->un.mb_words[6], mb->un.mb_words[7], in lpfc_sli4_post_sync_mbox()
10015 mb->un.mb_words[8], mb->un.mb_words[9], in lpfc_sli4_post_sync_mbox()
10016 mb->un.mb_words[10], mb->un.mb_words[11], in lpfc_sli4_post_sync_mbox()
10017 mb->un.mb_words[12], mboxq->mcqe.word0, in lpfc_sli4_post_sync_mbox()
10018 mboxq->mcqe.mcqe_tag0, mboxq->mcqe.mcqe_tag1, in lpfc_sli4_post_sync_mbox()
10019 mboxq->mcqe.trailer); in lpfc_sli4_post_sync_mbox()
10022 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli4_post_sync_mbox()
10023 psli->sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; in lpfc_sli4_post_sync_mbox()
10024 phba->sli.mbox_active = NULL; in lpfc_sli4_post_sync_mbox()
10025 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli4_post_sync_mbox()
10030 * lpfc_sli_issue_mbox_s4 - Issue an SLI4 mailbox command to firmware
10032 * @mboxq: Pointer to mailbox object.
10033 * @flag: Flag indicating how the mailbox need to be processed.
10036 * a mailbox command to firmware with SLI-4 interface spec.
10038 * Return codes the caller owns the mailbox command after the return of the
10045 struct lpfc_sli *psli = &phba->sli; in lpfc_sli_issue_mbox_s4()
10049 /* dump from issue mailbox command if setup */ in lpfc_sli_issue_mbox_s4()
10050 lpfc_idiag_mbxacc_dump_issue_mbox(phba, &mboxq->u.mb); in lpfc_sli_issue_mbox_s4()
10055 "(%d):2544 Mailbox command x%x (x%x/x%x) " in lpfc_sli_issue_mbox_s4()
10057 mboxq->vport ? mboxq->vport->vpi : 0, in lpfc_sli_issue_mbox_s4()
10058 mboxq->u.mb.mbxCommand, in lpfc_sli_issue_mbox_s4()
10061 psli->sli_flag, flag); in lpfc_sli_issue_mbox_s4()
10066 if (!phba->sli4_hba.intr_enable) { in lpfc_sli_issue_mbox_s4()
10070 rc = -EIO; in lpfc_sli_issue_mbox_s4()
10073 "(%d):2541 Mailbox command x%x " in lpfc_sli_issue_mbox_s4()
10077 mboxq->vport ? mboxq->vport->vpi : 0, in lpfc_sli_issue_mbox_s4()
10078 mboxq->u.mb.mbxCommand, in lpfc_sli_issue_mbox_s4()
10083 bf_get(lpfc_mqe_status, &mboxq->u.mqe), in lpfc_sli_issue_mbox_s4()
10084 bf_get(lpfc_mcqe_status, &mboxq->mcqe), in lpfc_sli_issue_mbox_s4()
10086 &mboxq->mcqe), in lpfc_sli_issue_mbox_s4()
10087 psli->sli_flag, flag); in lpfc_sli_issue_mbox_s4()
10091 "(%d):2542 Try to issue mailbox command " in lpfc_sli_issue_mbox_s4()
10093 "mailbox command queue: x%x x%x\n", in lpfc_sli_issue_mbox_s4()
10094 mboxq->vport ? mboxq->vport->vpi : 0, in lpfc_sli_issue_mbox_s4()
10095 mboxq->u.mb.mbxCommand, in lpfc_sli_issue_mbox_s4()
10098 psli->sli_flag, flag); in lpfc_sli_issue_mbox_s4()
10099 /* Try to block the asynchronous mailbox posting */ in lpfc_sli_issue_mbox_s4()
10107 "(%d):2597 Sync Mailbox command " in lpfc_sli_issue_mbox_s4()
10111 mboxq->vport ? mboxq->vport->vpi : 0, in lpfc_sli_issue_mbox_s4()
10112 mboxq->u.mb.mbxCommand, in lpfc_sli_issue_mbox_s4()
10117 bf_get(lpfc_mqe_status, &mboxq->u.mqe), in lpfc_sli_issue_mbox_s4()
10118 bf_get(lpfc_mcqe_status, &mboxq->mcqe), in lpfc_sli_issue_mbox_s4()
10120 &mboxq->mcqe), in lpfc_sli_issue_mbox_s4()
10121 psli->sli_flag, flag); in lpfc_sli_issue_mbox_s4()
10122 /* Unblock the async mailbox posting afterward */ in lpfc_sli_issue_mbox_s4()
10128 /* Now, interrupt mode asynchronous mailbox command */ in lpfc_sli_issue_mbox_s4()
10132 "(%d):2543 Mailbox command x%x (x%x/x%x) " in lpfc_sli_issue_mbox_s4()
10134 mboxq->vport ? mboxq->vport->vpi : 0, in lpfc_sli_issue_mbox_s4()
10135 mboxq->u.mb.mbxCommand, in lpfc_sli_issue_mbox_s4()
10138 psli->sli_flag, flag); in lpfc_sli_issue_mbox_s4()
10142 /* Put the mailbox command to the driver internal FIFO */ in lpfc_sli_issue_mbox_s4()
10143 psli->slistat.mbox_busy++; in lpfc_sli_issue_mbox_s4()
10144 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli_issue_mbox_s4()
10146 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli_issue_mbox_s4()
10148 "(%d):0354 Mbox cmd issue - Enqueue Data: " in lpfc_sli_issue_mbox_s4()
10150 mboxq->vport ? mboxq->vport->vpi : 0xffffff, in lpfc_sli_issue_mbox_s4()
10151 bf_get(lpfc_mqe_command, &mboxq->u.mqe), in lpfc_sli_issue_mbox_s4()
10154 mboxq->u.mb.un.varUnregLogin.rpi, in lpfc_sli_issue_mbox_s4()
10155 phba->pport->port_state, in lpfc_sli_issue_mbox_s4()
10156 psli->sli_flag, MBX_NOWAIT); in lpfc_sli_issue_mbox_s4()
10157 /* Wake up worker thread to transport mailbox command from head */ in lpfc_sli_issue_mbox_s4()
10167 * lpfc_sli4_post_async_mbox - Post an SLI4 mailbox command to device
10170 * This function is called by worker thread to send a mailbox command to
10177 struct lpfc_sli *psli = &phba->sli; in lpfc_sli4_post_async_mbox()
10184 /* Check interrupt mode before post async mailbox command */ in lpfc_sli4_post_async_mbox()
10185 if (unlikely(!phba->sli4_hba.intr_enable)) in lpfc_sli4_post_async_mbox()
10188 /* Check for mailbox command service token */ in lpfc_sli4_post_async_mbox()
10189 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_post_async_mbox()
10190 if (unlikely(psli->sli_flag & LPFC_SLI_ASYNC_MBX_BLK)) { in lpfc_sli4_post_async_mbox()
10191 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_post_async_mbox()
10194 if (psli->sli_flag & LPFC_SLI_MBOX_ACTIVE) { in lpfc_sli4_post_async_mbox()
10195 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_post_async_mbox()
10198 if (unlikely(phba->sli.mbox_active)) { in lpfc_sli4_post_async_mbox()
10199 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_post_async_mbox()
10201 "0384 There is pending active mailbox cmd\n"); in lpfc_sli4_post_async_mbox()
10204 /* Take the mailbox command service token */ in lpfc_sli4_post_async_mbox()
10205 psli->sli_flag |= LPFC_SLI_MBOX_ACTIVE; in lpfc_sli4_post_async_mbox()
10207 /* Get the next mailbox command from head of queue */ in lpfc_sli4_post_async_mbox()
10210 /* If no more mailbox command waiting for post, we're done */ in lpfc_sli4_post_async_mbox()
10212 psli->sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; in lpfc_sli4_post_async_mbox()
10213 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_post_async_mbox()
10216 phba->sli.mbox_active = mboxq; in lpfc_sli4_post_async_mbox()
10217 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_post_async_mbox()
10219 /* Check device readiness for posting mailbox command */ in lpfc_sli4_post_async_mbox()
10222 /* Driver clean routine will clean up pending mailbox */ in lpfc_sli4_post_async_mbox()
10226 mqe = &mboxq->u.mqe; in lpfc_sli4_post_async_mbox()
10229 /* Start timer for the mbox_tmo and log some mailbox post messages */ in lpfc_sli4_post_async_mbox()
10230 mod_timer(&psli->mbox_tmo, (jiffies + in lpfc_sli4_post_async_mbox()
10234 "(%d):0355 Mailbox cmd x%x (x%x/x%x) issue Data: " in lpfc_sli4_post_async_mbox()
10236 mboxq->vport ? mboxq->vport->vpi : 0, mbx_cmnd, in lpfc_sli4_post_async_mbox()
10239 phba->pport->port_state, psli->sli_flag); in lpfc_sli4_post_async_mbox()
10242 if (mboxq->vport) { in lpfc_sli4_post_async_mbox()
10243 lpfc_debugfs_disc_trc(mboxq->vport, in lpfc_sli4_post_async_mbox()
10246 mbx_cmnd, mqe->un.mb_words[0], in lpfc_sli4_post_async_mbox()
10247 mqe->un.mb_words[1]); in lpfc_sli4_post_async_mbox()
10249 lpfc_debugfs_disc_trc(phba->pport, in lpfc_sli4_post_async_mbox()
10252 mbx_cmnd, mqe->un.mb_words[0], in lpfc_sli4_post_async_mbox()
10253 mqe->un.mb_words[1]); in lpfc_sli4_post_async_mbox()
10256 psli->slistat.mbox_cmd++; in lpfc_sli4_post_async_mbox()
10258 /* Post the mailbox command to the port */ in lpfc_sli4_post_async_mbox()
10259 rc = lpfc_sli4_mq_put(phba->sli4_hba.mbx_wq, mqe); in lpfc_sli4_post_async_mbox()
10262 "(%d):2533 Mailbox command x%x (x%x/x%x) " in lpfc_sli4_post_async_mbox()
10264 mboxq->vport ? mboxq->vport->vpi : 0, in lpfc_sli4_post_async_mbox()
10265 mboxq->u.mb.mbxCommand, in lpfc_sli4_post_async_mbox()
10268 psli->sli_flag, MBX_NOWAIT); in lpfc_sli4_post_async_mbox()
10275 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_post_async_mbox()
10276 if (phba->sli.mbox_active) { in lpfc_sli4_post_async_mbox()
10277 mboxq->u.mb.mbxStatus = MBX_NOT_FINISHED; in lpfc_sli4_post_async_mbox()
10280 psli->sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; in lpfc_sli4_post_async_mbox()
10281 phba->sli.mbox_active = NULL; in lpfc_sli4_post_async_mbox()
10283 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_post_async_mbox()
10289 * lpfc_sli_issue_mbox - Wrapper func for issuing mailbox command
10291 * @pmbox: Pointer to mailbox object.
10292 * @flag: Flag indicating how the mailbox need to be processed.
10294 * This routine wraps the actual SLI3 or SLI4 mailbox issuing routine from
10297 * Return codes the caller owns the mailbox command after the return of the
10303 return phba->lpfc_sli_issue_mbox(phba, pmbox, flag); in lpfc_sli_issue_mbox()
10307 * lpfc_mbox_api_table_setup - Set up mbox api function jump table
10309 * @dev_grp: The HBA PCI-Device group number.
10313 * Returns: 0 - success, -ENODEV - failure.
10321 phba->lpfc_sli_issue_mbox = lpfc_sli_issue_mbox_s3; in lpfc_mbox_api_table_setup()
10322 phba->lpfc_sli_handle_slow_ring_event = in lpfc_mbox_api_table_setup()
10324 phba->lpfc_sli_hbq_to_firmware = lpfc_sli_hbq_to_firmware_s3; in lpfc_mbox_api_table_setup()
10325 phba->lpfc_sli_brdrestart = lpfc_sli_brdrestart_s3; in lpfc_mbox_api_table_setup()
10326 phba->lpfc_sli_brdready = lpfc_sli_brdready_s3; in lpfc_mbox_api_table_setup()
10329 phba->lpfc_sli_issue_mbox = lpfc_sli_issue_mbox_s4; in lpfc_mbox_api_table_setup()
10330 phba->lpfc_sli_handle_slow_ring_event = in lpfc_mbox_api_table_setup()
10332 phba->lpfc_sli_hbq_to_firmware = lpfc_sli_hbq_to_firmware_s4; in lpfc_mbox_api_table_setup()
10333 phba->lpfc_sli_brdrestart = lpfc_sli_brdrestart_s4; in lpfc_mbox_api_table_setup()
10334 phba->lpfc_sli_brdready = lpfc_sli_brdready_s4; in lpfc_mbox_api_table_setup()
10338 "1420 Invalid HBA PCI-device group: 0x%x\n", in lpfc_mbox_api_table_setup()
10340 return -ENODEV; in lpfc_mbox_api_table_setup()
10346 * __lpfc_sli_ringtx_put - Add an iocb to the txq
10360 if (phba->sli_rev == LPFC_SLI_REV4) in __lpfc_sli_ringtx_put()
10361 lockdep_assert_held(&pring->ring_lock); in __lpfc_sli_ringtx_put()
10363 lockdep_assert_held(&phba->hbalock); in __lpfc_sli_ringtx_put()
10365 list_add_tail(&piocb->list, &pring->txq); in __lpfc_sli_ringtx_put()
10369 * lpfc_sli_next_iocb - Get the next iocb in the txq
10391 lockdep_assert_held(&phba->hbalock); in lpfc_sli_next_iocb()
10403 * __lpfc_sli_issue_iocb_s3 - SLI3 device lockless ver of lpfc_sli_issue_iocb
10410 * an iocb command to an HBA with SLI-3 interface spec. If the PCI slot is
10430 struct lpfc_sli_ring *pring = &phba->sli.sli3_ring[ring_number]; in __lpfc_sli_issue_iocb_s3()
10432 lockdep_assert_held(&phba->hbalock); in __lpfc_sli_issue_iocb_s3()
10434 if (piocb->cmd_cmpl && (!piocb->vport) && in __lpfc_sli_issue_iocb_s3()
10435 (piocb->iocb.ulpCommand != CMD_ABORT_XRI_CN) && in __lpfc_sli_issue_iocb_s3()
10436 (piocb->iocb.ulpCommand != CMD_CLOSE_XRI_CN)) { in __lpfc_sli_issue_iocb_s3()
10439 piocb->iocb.ulpCommand); in __lpfc_sli_issue_iocb_s3()
10446 if (unlikely(pci_channel_offline(phba->pcidev))) in __lpfc_sli_issue_iocb_s3()
10450 if (unlikely(phba->hba_flag & DEFER_ERATT)) in __lpfc_sli_issue_iocb_s3()
10456 if (unlikely(phba->link_state < LPFC_LINK_DOWN)) in __lpfc_sli_issue_iocb_s3()
10463 if (unlikely(pring->flag & LPFC_STOP_IOCB_EVENT)) in __lpfc_sli_issue_iocb_s3()
10466 if (unlikely(phba->link_state == LPFC_LINK_DOWN)) { in __lpfc_sli_issue_iocb_s3()
10471 switch (piocb->iocb.ulpCommand) { in __lpfc_sli_issue_iocb_s3()
10478 if (piocb->cmd_cmpl) in __lpfc_sli_issue_iocb_s3()
10479 piocb->cmd_cmpl = NULL; in __lpfc_sli_issue_iocb_s3()
10493 } else if (unlikely(pring->ringno == LPFC_FCP_RING && in __lpfc_sli_issue_iocb_s3()
10494 !(phba->sli.sli_flag & LPFC_PROCESS_LA))) { in __lpfc_sli_issue_iocb_s3()
10513 pring->stats.iocb_cmd_delay++; in __lpfc_sli_issue_iocb_s3()
10526 * __lpfc_sli_issue_fcp_io_s3 - SLI3 device for sending fcp io iocb
10533 * send an iocb command to an HBA with SLI-3 interface spec.
10546 spin_lock_irqsave(&phba->hbalock, iflags); in __lpfc_sli_issue_fcp_io_s3()
10548 spin_unlock_irqrestore(&phba->hbalock, iflags); in __lpfc_sli_issue_fcp_io_s3()
10554 * __lpfc_sli_issue_fcp_io_s4 - SLI4 device for sending fcp io wqe
10561 * an wqe command to an HBA with SLI-4 interface spec.
10571 struct lpfc_io_buf *lpfc_cmd = piocb->io_buf; in __lpfc_sli_issue_fcp_io_s4()
10574 return lpfc_sli4_issue_wqe(phba, lpfc_cmd->hdwq, piocb); in __lpfc_sli_issue_fcp_io_s4()
10580 struct lpfc_iocbq *piocb = &lpfc_cmd->cur_iocbq; in lpfc_prep_embed_io()
10581 union lpfc_wqe128 *wqe = &lpfc_cmd->cur_iocbq.wqe; in lpfc_prep_embed_io()
10585 sgl = (struct sli4_sge *)lpfc_cmd->dma_sgl; in lpfc_prep_embed_io()
10587 if (phba->fcp_embed_io) { in lpfc_prep_embed_io()
10591 fcp_cmnd = lpfc_cmd->fcp_cmnd; in lpfc_prep_embed_io()
10593 /* Word 0-2 - FCP_CMND */ in lpfc_prep_embed_io()
10594 wqe->generic.bde.tus.f.bdeFlags = in lpfc_prep_embed_io()
10596 wqe->generic.bde.tus.f.bdeSize = sgl->sge_len; in lpfc_prep_embed_io()
10597 wqe->generic.bde.addrHigh = 0; in lpfc_prep_embed_io()
10598 wqe->generic.bde.addrLow = 88; /* Word 22 */ in lpfc_prep_embed_io()
10600 bf_set(wqe_wqes, &wqe->fcp_iwrite.wqe_com, 1); in lpfc_prep_embed_io()
10601 bf_set(wqe_dbde, &wqe->fcp_iwrite.wqe_com, 0); in lpfc_prep_embed_io()
10603 /* Word 22-29 FCP CMND Payload */ in lpfc_prep_embed_io()
10604 ptr = &wqe->words[22]; in lpfc_prep_embed_io()
10607 /* Word 0-2 - Inline BDE */ in lpfc_prep_embed_io()
10608 wqe->generic.bde.tus.f.bdeFlags = BUFF_TYPE_BDE_64; in lpfc_prep_embed_io()
10609 wqe->generic.bde.tus.f.bdeSize = sizeof(struct fcp_cmnd); in lpfc_prep_embed_io()
10610 wqe->generic.bde.addrHigh = sgl->addr_hi; in lpfc_prep_embed_io()
10611 wqe->generic.bde.addrLow = sgl->addr_lo; in lpfc_prep_embed_io()
10614 bf_set(wqe_dbde, &wqe->generic.wqe_com, 1); in lpfc_prep_embed_io()
10615 bf_set(wqe_wqes, &wqe->generic.wqe_com, 0); in lpfc_prep_embed_io()
10619 if (unlikely(piocb->cmd_flag & LPFC_IO_VMID)) { in lpfc_prep_embed_io()
10620 if (phba->pport->vmid_flag & LPFC_VMID_TYPE_PRIO) { in lpfc_prep_embed_io()
10621 bf_set(wqe_ccpe, &wqe->fcp_iwrite.wqe_com, 1); in lpfc_prep_embed_io()
10622 bf_set(wqe_ccp, &wqe->fcp_iwrite.wqe_com, in lpfc_prep_embed_io()
10623 (piocb->vmid_tag.cs_ctl_vmid)); in lpfc_prep_embed_io()
10624 } else if (phba->cfg_vmid_app_header) { in lpfc_prep_embed_io()
10625 bf_set(wqe_appid, &wqe->fcp_iwrite.wqe_com, 1); in lpfc_prep_embed_io()
10626 bf_set(wqe_wqes, &wqe->fcp_iwrite.wqe_com, 1); in lpfc_prep_embed_io()
10627 wqe->words[31] = piocb->vmid_tag.app_id; in lpfc_prep_embed_io()
10633 * __lpfc_sli_issue_iocb_s4 - SLI4 device lockless ver of lpfc_sli_issue_iocb
10640 * an iocb command to an HBA with SLI-4 interface spec.
10657 if ((piocb->cmd_flag & LPFC_IO_FCP) || in __lpfc_sli_issue_iocb_s4()
10658 (piocb->cmd_flag & LPFC_USE_FCPWQIDX)) { in __lpfc_sli_issue_iocb_s4()
10659 wq = phba->sli4_hba.hdwq[piocb->hba_wqidx].io_wq; in __lpfc_sli_issue_iocb_s4()
10661 wq = phba->sli4_hba.els_wq; in __lpfc_sli_issue_iocb_s4()
10665 pring = wq->pring; in __lpfc_sli_issue_iocb_s4()
10671 lockdep_assert_held(&pring->ring_lock); in __lpfc_sli_issue_iocb_s4()
10672 wqe = &piocb->wqe; in __lpfc_sli_issue_iocb_s4()
10673 if (piocb->sli4_xritag == NO_XRI) { in __lpfc_sli_issue_iocb_s4()
10689 } else if (piocb->cmd_flag & LPFC_IO_FCP) { in __lpfc_sli_issue_iocb_s4()
10698 sglq = __lpfc_get_active_sglq(phba, piocb->sli4_lxritag); in __lpfc_sli_issue_iocb_s4()
10704 piocb->sli4_lxritag = sglq->sli4_lxritag; in __lpfc_sli_issue_iocb_s4()
10705 piocb->sli4_xritag = sglq->sli4_xritag; in __lpfc_sli_issue_iocb_s4()
10712 piocb->abort_bls == LPFC_ABTS_UNSOL_INT) in __lpfc_sli_issue_iocb_s4()
10713 bf_set(xmit_bls_rsp64_rxid, &wqe->xmit_bls_rsp, in __lpfc_sli_issue_iocb_s4()
10714 piocb->sli4_xritag); in __lpfc_sli_issue_iocb_s4()
10716 bf_set(wqe_xri_tag, &wqe->generic.wqe_com, in __lpfc_sli_issue_iocb_s4()
10717 piocb->sli4_xritag); in __lpfc_sli_issue_iocb_s4()
10732 * lpfc_sli_issue_fcp_io - Wrapper func for issuing fcp i/o
10734 * This routine wraps the actual fcp i/o function for issusing WQE for sli-4
10735 * or IOCB for sli-3 function.
10739 * IOCB_ERROR - Error
10740 * IOCB_SUCCESS - Success
10741 * IOCB_BUSY - Busy
10747 return phba->__lpfc_sli_issue_fcp_io(phba, ring_number, piocb, flag); in lpfc_sli_issue_fcp_io()
10751 * __lpfc_sli_issue_iocb - Wrapper func of lockless version for issuing iocb
10757 * IOCB_ERROR - Error
10758 * IOCB_SUCCESS - Success
10759 * IOCB_BUSY - Busy
10765 return phba->__lpfc_sli_issue_iocb(phba, ring_number, piocb, flag); in __lpfc_sli_issue_iocb()
10774 struct lpfc_hba *phba = vport->phba; in __lpfc_sli_prep_els_req_rsp_s3()
10777 cmd = &cmdiocbq->iocb; in __lpfc_sli_prep_els_req_rsp_s3()
10780 cmd->un.elsreq64.bdl.addrHigh = putPaddrHigh(bmp->phys); in __lpfc_sli_prep_els_req_rsp_s3()
10781 cmd->un.elsreq64.bdl.addrLow = putPaddrLow(bmp->phys); in __lpfc_sli_prep_els_req_rsp_s3()
10782 cmd->un.elsreq64.bdl.bdeFlags = BUFF_TYPE_BLP_64; in __lpfc_sli_prep_els_req_rsp_s3()
10785 cmd->un.elsreq64.bdl.bdeSize = (2 * sizeof(struct ulp_bde64)); in __lpfc_sli_prep_els_req_rsp_s3()
10786 cmd->un.elsreq64.remoteID = did; /* DID */ in __lpfc_sli_prep_els_req_rsp_s3()
10787 cmd->ulpCommand = CMD_ELS_REQUEST64_CR; in __lpfc_sli_prep_els_req_rsp_s3()
10788 cmd->ulpTimeout = tmo; in __lpfc_sli_prep_els_req_rsp_s3()
10790 cmd->un.elsreq64.bdl.bdeSize = sizeof(struct ulp_bde64); in __lpfc_sli_prep_els_req_rsp_s3()
10791 cmd->un.genreq64.xmit_els_remoteID = did; /* DID */ in __lpfc_sli_prep_els_req_rsp_s3()
10792 cmd->ulpCommand = CMD_XMIT_ELS_RSP64_CX; in __lpfc_sli_prep_els_req_rsp_s3()
10793 cmd->ulpPU = PARM_NPIV_DID; in __lpfc_sli_prep_els_req_rsp_s3()
10795 cmd->ulpBdeCount = 1; in __lpfc_sli_prep_els_req_rsp_s3()
10796 cmd->ulpLe = 1; in __lpfc_sli_prep_els_req_rsp_s3()
10797 cmd->ulpClass = CLASS3; in __lpfc_sli_prep_els_req_rsp_s3()
10800 if (phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) { in __lpfc_sli_prep_els_req_rsp_s3()
10802 cmd->un.elsreq64.myID = vport->fc_myDID; in __lpfc_sli_prep_els_req_rsp_s3()
10805 cmd->ulpContext = phba->vpi_ids[vport->vpi]; in __lpfc_sli_prep_els_req_rsp_s3()
10808 cmd->ulpCt_h = 0; in __lpfc_sli_prep_els_req_rsp_s3()
10811 cmd->ulpCt_l = 0; /* context = invalid RPI */ in __lpfc_sli_prep_els_req_rsp_s3()
10813 cmd->ulpCt_l = 1; /* context = VPI */ in __lpfc_sli_prep_els_req_rsp_s3()
10823 struct lpfc_hba *phba = vport->phba; in __lpfc_sli_prep_els_req_rsp_s4()
10828 wqe = &cmdiocbq->wqe; in __lpfc_sli_prep_els_req_rsp_s4()
10831 /* Word 0 - 2 BDE */ in __lpfc_sli_prep_els_req_rsp_s4()
10832 bde = (struct ulp_bde64_le *)&wqe->generic.bde; in __lpfc_sli_prep_els_req_rsp_s4()
10833 bde->addr_low = cpu_to_le32(putPaddrLow(bmp->phys)); in __lpfc_sli_prep_els_req_rsp_s4()
10834 bde->addr_high = cpu_to_le32(putPaddrHigh(bmp->phys)); in __lpfc_sli_prep_els_req_rsp_s4()
10835 bde->type_size = cpu_to_le32(cmd_size); in __lpfc_sli_prep_els_req_rsp_s4()
10836 bde->type_size |= cpu_to_le32(ULP_BDE64_TYPE_BDE_64); in __lpfc_sli_prep_els_req_rsp_s4()
10839 bf_set(wqe_cmnd, &wqe->els_req.wqe_com, CMD_ELS_REQUEST64_WQE); in __lpfc_sli_prep_els_req_rsp_s4()
10842 wqe->els_req.payload_len = cmd_size; in __lpfc_sli_prep_els_req_rsp_s4()
10843 wqe->els_req.max_response_payload_len = FCELSSIZE; in __lpfc_sli_prep_els_req_rsp_s4()
10846 bf_set(wqe_els_did, &wqe->els_req.wqe_dest, did); in __lpfc_sli_prep_els_req_rsp_s4()
10848 /* Word 11 - ELS_ID */ in __lpfc_sli_prep_els_req_rsp_s4()
10860 if (!vport->fc_myDID) { in __lpfc_sli_prep_els_req_rsp_s4()
10870 bf_set(wqe_els_id, &wqe->els_req.wqe_com, els_id); in __lpfc_sli_prep_els_req_rsp_s4()
10873 bf_set(wqe_els_did, &wqe->xmit_els_rsp.wqe_dest, did); in __lpfc_sli_prep_els_req_rsp_s4()
10876 wqe->xmit_els_rsp.response_payload_len = cmd_size; in __lpfc_sli_prep_els_req_rsp_s4()
10878 bf_set(wqe_cmnd, &wqe->xmit_els_rsp.wqe_com, in __lpfc_sli_prep_els_req_rsp_s4()
10882 bf_set(wqe_tmo, &wqe->generic.wqe_com, tmo); in __lpfc_sli_prep_els_req_rsp_s4()
10883 bf_set(wqe_reqtag, &wqe->generic.wqe_com, cmdiocbq->iotag); in __lpfc_sli_prep_els_req_rsp_s4()
10884 bf_set(wqe_class, &wqe->generic.wqe_com, CLASS3); in __lpfc_sli_prep_els_req_rsp_s4()
10890 if ((phba->sli3_options & LPFC_SLI3_NPIV_ENABLED) || in __lpfc_sli_prep_els_req_rsp_s4()
10891 (vport->fc_flag & FC_PT2PT)) { in __lpfc_sli_prep_els_req_rsp_s4()
10893 bf_set(els_req64_sid, &wqe->els_req, vport->fc_myDID); in __lpfc_sli_prep_els_req_rsp_s4()
10896 bf_set(wqe_ctxt_tag, &wqe->els_req.wqe_com, in __lpfc_sli_prep_els_req_rsp_s4()
10897 phba->vpi_ids[vport->vpi]); in __lpfc_sli_prep_els_req_rsp_s4()
10902 bf_set(wqe_ct, &wqe->generic.wqe_com, 0); in __lpfc_sli_prep_els_req_rsp_s4()
10904 bf_set(wqe_ct, &wqe->generic.wqe_com, 1); in __lpfc_sli_prep_els_req_rsp_s4()
10914 phba->__lpfc_sli_prep_els_req_rsp(cmdiocbq, vport, bmp, cmd_size, did, in lpfc_sli_prep_els_req_rsp()
10924 cmd = &cmdiocbq->iocb; in __lpfc_sli_prep_gen_req_s3()
10927 cmd->un.genreq64.bdl.addrHigh = putPaddrHigh(bmp->phys); in __lpfc_sli_prep_gen_req_s3()
10928 cmd->un.genreq64.bdl.addrLow = putPaddrLow(bmp->phys); in __lpfc_sli_prep_gen_req_s3()
10929 cmd->un.genreq64.bdl.bdeFlags = BUFF_TYPE_BLP_64; in __lpfc_sli_prep_gen_req_s3()
10930 cmd->un.genreq64.bdl.bdeSize = num_entry * sizeof(struct ulp_bde64); in __lpfc_sli_prep_gen_req_s3()
10932 cmd->un.genreq64.w5.hcsw.Rctl = FC_RCTL_DD_UNSOL_CTL; in __lpfc_sli_prep_gen_req_s3()
10933 cmd->un.genreq64.w5.hcsw.Type = FC_TYPE_CT; in __lpfc_sli_prep_gen_req_s3()
10934 cmd->un.genreq64.w5.hcsw.Fctl = (SI | LA); in __lpfc_sli_prep_gen_req_s3()
10936 cmd->ulpContext = rpi; in __lpfc_sli_prep_gen_req_s3()
10937 cmd->ulpClass = CLASS3; in __lpfc_sli_prep_gen_req_s3()
10938 cmd->ulpCommand = CMD_GEN_REQUEST64_CR; in __lpfc_sli_prep_gen_req_s3()
10939 cmd->ulpBdeCount = 1; in __lpfc_sli_prep_gen_req_s3()
10940 cmd->ulpLe = 1; in __lpfc_sli_prep_gen_req_s3()
10941 cmd->ulpOwner = OWN_CHIP; in __lpfc_sli_prep_gen_req_s3()
10942 cmd->ulpTimeout = tmo; in __lpfc_sli_prep_gen_req_s3()
10953 cmdwqe = &cmdiocbq->wqe; in __lpfc_sli_prep_gen_req_s4()
10957 bpl = (struct ulp_bde64_le *)bmp->virt; in __lpfc_sli_prep_gen_req_s4()
10970 /* Words 0 - 2 */ in __lpfc_sli_prep_gen_req_s4()
10971 bde = (struct ulp_bde64_le *)&cmdwqe->generic.bde; in __lpfc_sli_prep_gen_req_s4()
10972 bde->addr_low = bpl->addr_low; in __lpfc_sli_prep_gen_req_s4()
10973 bde->addr_high = bpl->addr_high; in __lpfc_sli_prep_gen_req_s4()
10974 bde->type_size = cpu_to_le32(xmit_len); in __lpfc_sli_prep_gen_req_s4()
10975 bde->type_size |= cpu_to_le32(ULP_BDE64_TYPE_BDE_64); in __lpfc_sli_prep_gen_req_s4()
10978 cmdwqe->gen_req.request_payload_len = xmit_len; in __lpfc_sli_prep_gen_req_s4()
10981 bf_set(wqe_type, &cmdwqe->gen_req.wge_ctl, FC_TYPE_CT); in __lpfc_sli_prep_gen_req_s4()
10982 bf_set(wqe_rctl, &cmdwqe->gen_req.wge_ctl, FC_RCTL_DD_UNSOL_CTL); in __lpfc_sli_prep_gen_req_s4()
10983 bf_set(wqe_si, &cmdwqe->gen_req.wge_ctl, 1); in __lpfc_sli_prep_gen_req_s4()
10984 bf_set(wqe_la, &cmdwqe->gen_req.wge_ctl, 1); in __lpfc_sli_prep_gen_req_s4()
10987 bf_set(wqe_ctxt_tag, &cmdwqe->gen_req.wqe_com, rpi); in __lpfc_sli_prep_gen_req_s4()
10990 bf_set(wqe_tmo, &cmdwqe->gen_req.wqe_com, tmo); in __lpfc_sli_prep_gen_req_s4()
10991 bf_set(wqe_class, &cmdwqe->gen_req.wqe_com, CLASS3); in __lpfc_sli_prep_gen_req_s4()
10992 bf_set(wqe_cmnd, &cmdwqe->gen_req.wqe_com, CMD_GEN_REQUEST64_CR); in __lpfc_sli_prep_gen_req_s4()
10993 bf_set(wqe_ct, &cmdwqe->gen_req.wqe_com, SLI4_CT_RPI); in __lpfc_sli_prep_gen_req_s4()
10996 cmdwqe->gen_req.max_response_payload_len = total_len - xmit_len; in __lpfc_sli_prep_gen_req_s4()
11003 phba->__lpfc_sli_prep_gen_req(cmdiocbq, bmp, rpi, num_entry, tmo); in lpfc_sli_prep_gen_req()
11013 icmd = &cmdiocbq->iocb; in __lpfc_sli_prep_xmit_seq64_s3()
11016 icmd->un.xseq64.bdl.addrHigh = putPaddrHigh(bmp->phys); in __lpfc_sli_prep_xmit_seq64_s3()
11017 icmd->un.xseq64.bdl.addrLow = putPaddrLow(bmp->phys); in __lpfc_sli_prep_xmit_seq64_s3()
11018 icmd->un.xseq64.bdl.bdeFlags = BUFF_TYPE_BLP_64; in __lpfc_sli_prep_xmit_seq64_s3()
11019 icmd->un.xseq64.bdl.bdeSize = (num_entry * sizeof(struct ulp_bde64)); in __lpfc_sli_prep_xmit_seq64_s3()
11020 icmd->un.xseq64.w5.hcsw.Fctl = LA; in __lpfc_sli_prep_xmit_seq64_s3()
11022 icmd->un.xseq64.w5.hcsw.Fctl |= LS; in __lpfc_sli_prep_xmit_seq64_s3()
11023 icmd->un.xseq64.w5.hcsw.Dfctl = 0; in __lpfc_sli_prep_xmit_seq64_s3()
11024 icmd->un.xseq64.w5.hcsw.Rctl = rctl; in __lpfc_sli_prep_xmit_seq64_s3()
11025 icmd->un.xseq64.w5.hcsw.Type = FC_TYPE_CT; in __lpfc_sli_prep_xmit_seq64_s3()
11027 icmd->ulpBdeCount = 1; in __lpfc_sli_prep_xmit_seq64_s3()
11028 icmd->ulpLe = 1; in __lpfc_sli_prep_xmit_seq64_s3()
11029 icmd->ulpClass = CLASS3; in __lpfc_sli_prep_xmit_seq64_s3()
11033 icmd->ulpContext = rpi; in __lpfc_sli_prep_xmit_seq64_s3()
11034 icmd->ulpCommand = CMD_XMIT_SEQUENCE64_CR; in __lpfc_sli_prep_xmit_seq64_s3()
11037 icmd->ulpContext = ox_id; in __lpfc_sli_prep_xmit_seq64_s3()
11038 icmd->ulpCommand = CMD_XMIT_SEQUENCE64_CX; in __lpfc_sli_prep_xmit_seq64_s3()
11053 wqe = &cmdiocbq->wqe; in __lpfc_sli_prep_xmit_seq64_s4()
11056 /* Words 0 - 2 */ in __lpfc_sli_prep_xmit_seq64_s4()
11057 bpl = (struct ulp_bde64 *)bmp->virt; in __lpfc_sli_prep_xmit_seq64_s4()
11058 wqe->xmit_sequence.bde.addrHigh = bpl->addrHigh; in __lpfc_sli_prep_xmit_seq64_s4()
11059 wqe->xmit_sequence.bde.addrLow = bpl->addrLow; in __lpfc_sli_prep_xmit_seq64_s4()
11060 wqe->xmit_sequence.bde.tus.w = bpl->tus.w; in __lpfc_sli_prep_xmit_seq64_s4()
11063 bf_set(wqe_ls, &wqe->xmit_sequence.wge_ctl, last_seq); in __lpfc_sli_prep_xmit_seq64_s4()
11064 bf_set(wqe_la, &wqe->xmit_sequence.wge_ctl, 1); in __lpfc_sli_prep_xmit_seq64_s4()
11065 bf_set(wqe_dfctl, &wqe->xmit_sequence.wge_ctl, 0); in __lpfc_sli_prep_xmit_seq64_s4()
11066 bf_set(wqe_rctl, &wqe->xmit_sequence.wge_ctl, rctl); in __lpfc_sli_prep_xmit_seq64_s4()
11067 bf_set(wqe_type, &wqe->xmit_sequence.wge_ctl, FC_TYPE_CT); in __lpfc_sli_prep_xmit_seq64_s4()
11070 bf_set(wqe_ctxt_tag, &wqe->xmit_sequence.wqe_com, rpi); in __lpfc_sli_prep_xmit_seq64_s4()
11072 bf_set(wqe_cmnd, &wqe->xmit_sequence.wqe_com, in __lpfc_sli_prep_xmit_seq64_s4()
11076 bf_set(wqe_class, &wqe->xmit_sequence.wqe_com, CLASS3); in __lpfc_sli_prep_xmit_seq64_s4()
11079 bf_set(wqe_rcvoxid, &wqe->xmit_sequence.wqe_com, ox_id); in __lpfc_sli_prep_xmit_seq64_s4()
11082 if (cmdiocbq->cmd_flag & (LPFC_IO_LIBDFC | LPFC_IO_LOOPBACK)) in __lpfc_sli_prep_xmit_seq64_s4()
11083 wqe->xmit_sequence.xmit_len = full_size; in __lpfc_sli_prep_xmit_seq64_s4()
11085 wqe->xmit_sequence.xmit_len = in __lpfc_sli_prep_xmit_seq64_s4()
11086 wqe->xmit_sequence.bde.tus.f.bdeSize; in __lpfc_sli_prep_xmit_seq64_s4()
11094 phba->__lpfc_sli_prep_xmit_seq64(cmdiocbq, bmp, rpi, ox_id, num_entry, in lpfc_sli_prep_xmit_seq64()
11105 icmd = &cmdiocbq->iocb; in __lpfc_sli_prep_abort_xri_s3()
11109 icmd->un.acxri.abortContextTag = ulp_context; in __lpfc_sli_prep_abort_xri_s3()
11110 icmd->un.acxri.abortIoTag = iotag; in __lpfc_sli_prep_abort_xri_s3()
11114 icmd->ulpCommand = CMD_CLOSE_XRI_CN; in __lpfc_sli_prep_abort_xri_s3()
11117 icmd->un.acxri.abortType = ABORT_TYPE_ABTS; in __lpfc_sli_prep_abort_xri_s3()
11120 icmd->ulpClass = ulp_class; in __lpfc_sli_prep_abort_xri_s3()
11121 icmd->ulpCommand = CMD_ABORT_XRI_CN; in __lpfc_sli_prep_abort_xri_s3()
11125 icmd->ulpLe = 1; in __lpfc_sli_prep_abort_xri_s3()
11135 wqe = &cmdiocbq->wqe; in __lpfc_sli_prep_abort_xri_s4()
11139 bf_set(abort_cmd_criteria, &wqe->abort_cmd, T_XRI_TAG); in __lpfc_sli_prep_abort_xri_s4()
11141 bf_set(abort_cmd_ia, &wqe->abort_cmd, 1); in __lpfc_sli_prep_abort_xri_s4()
11143 bf_set(abort_cmd_ia, &wqe->abort_cmd, 0); in __lpfc_sli_prep_abort_xri_s4()
11146 bf_set(wqe_cmnd, &wqe->abort_cmd.wqe_com, CMD_ABORT_XRI_WQE); in __lpfc_sli_prep_abort_xri_s4()
11149 wqe->abort_cmd.wqe_com.abort_tag = ulp_context; in __lpfc_sli_prep_abort_xri_s4()
11152 bf_set(wqe_reqtag, &wqe->abort_cmd.wqe_com, iotag); in __lpfc_sli_prep_abort_xri_s4()
11155 bf_set(wqe_qosd, &wqe->abort_cmd.wqe_com, 1); in __lpfc_sli_prep_abort_xri_s4()
11159 bf_set(wqe_wqec, &wqe->abort_cmd.wqe_com, 1); in __lpfc_sli_prep_abort_xri_s4()
11160 bf_set(wqe_cqid, &wqe->abort_cmd.wqe_com, cqid); in __lpfc_sli_prep_abort_xri_s4()
11161 bf_set(wqe_cmd_type, &wqe->abort_cmd.wqe_com, OTHER_COMMAND); in __lpfc_sli_prep_abort_xri_s4()
11169 phba->__lpfc_sli_prep_abort_xri(cmdiocbq, ulp_context, iotag, ulp_class, in lpfc_sli_prep_abort_xri()
11174 * lpfc_sli_api_table_setup - Set up sli api function jump table
11176 * @dev_grp: The HBA PCI-Device group number.
11180 * Returns: 0 - success, -ENODEV - failure.
11188 phba->__lpfc_sli_issue_iocb = __lpfc_sli_issue_iocb_s3; in lpfc_sli_api_table_setup()
11189 phba->__lpfc_sli_release_iocbq = __lpfc_sli_release_iocbq_s3; in lpfc_sli_api_table_setup()
11190 phba->__lpfc_sli_issue_fcp_io = __lpfc_sli_issue_fcp_io_s3; in lpfc_sli_api_table_setup()
11191 phba->__lpfc_sli_prep_els_req_rsp = __lpfc_sli_prep_els_req_rsp_s3; in lpfc_sli_api_table_setup()
11192 phba->__lpfc_sli_prep_gen_req = __lpfc_sli_prep_gen_req_s3; in lpfc_sli_api_table_setup()
11193 phba->__lpfc_sli_prep_xmit_seq64 = __lpfc_sli_prep_xmit_seq64_s3; in lpfc_sli_api_table_setup()
11194 phba->__lpfc_sli_prep_abort_xri = __lpfc_sli_prep_abort_xri_s3; in lpfc_sli_api_table_setup()
11197 phba->__lpfc_sli_issue_iocb = __lpfc_sli_issue_iocb_s4; in lpfc_sli_api_table_setup()
11198 phba->__lpfc_sli_release_iocbq = __lpfc_sli_release_iocbq_s4; in lpfc_sli_api_table_setup()
11199 phba->__lpfc_sli_issue_fcp_io = __lpfc_sli_issue_fcp_io_s4; in lpfc_sli_api_table_setup()
11200 phba->__lpfc_sli_prep_els_req_rsp = __lpfc_sli_prep_els_req_rsp_s4; in lpfc_sli_api_table_setup()
11201 phba->__lpfc_sli_prep_gen_req = __lpfc_sli_prep_gen_req_s4; in lpfc_sli_api_table_setup()
11202 phba->__lpfc_sli_prep_xmit_seq64 = __lpfc_sli_prep_xmit_seq64_s4; in lpfc_sli_api_table_setup()
11203 phba->__lpfc_sli_prep_abort_xri = __lpfc_sli_prep_abort_xri_s4; in lpfc_sli_api_table_setup()
11207 "1419 Invalid HBA PCI-device group: 0x%x\n", in lpfc_sli_api_table_setup()
11209 return -ENODEV; in lpfc_sli_api_table_setup()
11215 * lpfc_sli4_calc_ring - Calculates which ring to use
11229 if (piocb->cmd_flag & (LPFC_IO_FCP | LPFC_USE_FCPWQIDX)) { in lpfc_sli4_calc_ring()
11230 if (unlikely(!phba->sli4_hba.hdwq)) in lpfc_sli4_calc_ring()
11236 if (!(piocb->cmd_flag & LPFC_USE_FCPWQIDX)) { in lpfc_sli4_calc_ring()
11237 lpfc_cmd = piocb->io_buf; in lpfc_sli4_calc_ring()
11238 piocb->hba_wqidx = lpfc_cmd->hdwq_no; in lpfc_sli4_calc_ring()
11240 return phba->sli4_hba.hdwq[piocb->hba_wqidx].io_wq->pring; in lpfc_sli4_calc_ring()
11242 if (unlikely(!phba->sli4_hba.els_wq)) in lpfc_sli4_calc_ring()
11244 piocb->hba_wqidx = 0; in lpfc_sli4_calc_ring()
11245 return phba->sli4_hba.els_wq->pring; in lpfc_sli4_calc_ring()
11251 struct lpfc_hba *phba = eq->phba; in lpfc_sli4_poll_eq()
11255 * for re-schedule, but we are good for io submission in lpfc_sli4_poll_eq()
11262 if (READ_ONCE(eq->mode) == LPFC_EQ_POLL) in lpfc_sli4_poll_eq()
11275 * lpfc_sli_issue_iocb - Wrapper function for __lpfc_sli_issue_iocb
11297 if (unlikely(pci_channel_offline(phba->pcidev))) in lpfc_sli_issue_iocb()
11300 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_sli_issue_iocb()
11303 eq = phba->sli4_hba.hdwq[piocb->hba_wqidx].hba_eq; in lpfc_sli_issue_iocb()
11309 spin_lock_irqsave(&pring->ring_lock, iflags); in lpfc_sli_issue_iocb()
11311 spin_unlock_irqrestore(&pring->ring_lock, iflags); in lpfc_sli_issue_iocb()
11316 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli_issue_iocb()
11318 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli_issue_iocb()
11324 * lpfc_extra_ring_setup - Extra ring setup function
11340 psli = &phba->sli; in lpfc_extra_ring_setup()
11345 pring = &psli->sli3_ring[LPFC_FCP_RING]; in lpfc_extra_ring_setup()
11346 pring->sli.sli3.numCiocb -= SLI2_IOCB_CMD_R1XTRA_ENTRIES; in lpfc_extra_ring_setup()
11347 pring->sli.sli3.numRiocb -= SLI2_IOCB_RSP_R1XTRA_ENTRIES; in lpfc_extra_ring_setup()
11348 pring->sli.sli3.numCiocb -= SLI2_IOCB_CMD_R3XTRA_ENTRIES; in lpfc_extra_ring_setup()
11349 pring->sli.sli3.numRiocb -= SLI2_IOCB_RSP_R3XTRA_ENTRIES; in lpfc_extra_ring_setup()
11352 pring = &psli->sli3_ring[LPFC_EXTRA_RING]; in lpfc_extra_ring_setup()
11354 pring->sli.sli3.numCiocb += SLI2_IOCB_CMD_R1XTRA_ENTRIES; in lpfc_extra_ring_setup()
11355 pring->sli.sli3.numRiocb += SLI2_IOCB_RSP_R1XTRA_ENTRIES; in lpfc_extra_ring_setup()
11356 pring->sli.sli3.numCiocb += SLI2_IOCB_CMD_R3XTRA_ENTRIES; in lpfc_extra_ring_setup()
11357 pring->sli.sli3.numRiocb += SLI2_IOCB_RSP_R3XTRA_ENTRIES; in lpfc_extra_ring_setup()
11360 pring->iotag_max = 4096; in lpfc_extra_ring_setup()
11361 pring->num_mask = 1; in lpfc_extra_ring_setup()
11362 pring->prt[0].profile = 0; /* Mask 0 */ in lpfc_extra_ring_setup()
11363 pring->prt[0].rctl = phba->cfg_multi_ring_rctl; in lpfc_extra_ring_setup()
11364 pring->prt[0].type = phba->cfg_multi_ring_type; in lpfc_extra_ring_setup()
11365 pring->prt[0].lpfc_sli_rcv_unsol_event = NULL; in lpfc_extra_ring_setup()
11374 struct lpfc_work_evt *evtp = &ndlp->recovery_evt; in lpfc_sli_post_recovery_event()
11376 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli_post_recovery_event()
11377 if (!list_empty(&evtp->evt_listp)) { in lpfc_sli_post_recovery_event()
11378 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli_post_recovery_event()
11383 evtp->evt_arg1 = lpfc_nlp_get(ndlp); in lpfc_sli_post_recovery_event()
11384 if (!evtp->evt_arg1) { in lpfc_sli_post_recovery_event()
11385 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli_post_recovery_event()
11388 evtp->evt = LPFC_EVT_RECOVER_PORT; in lpfc_sli_post_recovery_event()
11389 list_add_tail(&evtp->evt_listp, &phba->work_list); in lpfc_sli_post_recovery_event()
11390 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli_post_recovery_event()
11395 /* lpfc_sli_abts_err_handler - handle a failed ABTS request from an SLI3 port.
11415 /* The rpi in the ulpContext is vport-sensitive. */ in lpfc_sli_abts_err_handler()
11416 vpi = iocbq->iocb.un.asyncstat.sub_ctxt_tag; in lpfc_sli_abts_err_handler()
11417 rpi = iocbq->iocb.ulpContext; in lpfc_sli_abts_err_handler()
11422 vpi, rpi, iocbq->iocb.ulpStatus); in lpfc_sli_abts_err_handler()
11431 if (iocbq->iocb.ulpStatus == IOSTAT_LOCAL_REJECT) in lpfc_sli_abts_err_handler()
11439 vpi, rpi, iocbq->iocb.ulpStatus, in lpfc_sli_abts_err_handler()
11440 iocbq->iocb.ulpContext); in lpfc_sli_abts_err_handler()
11443 /* lpfc_sli4_abts_err_handler - handle a failed ABTS request from an SLI4 port.
11470 ndlp->vport->vpi, phba->sli4_hba.rpi_ids[ndlp->nlp_rpi], in lpfc_sli4_abts_err_handler()
11473 axri->parameter); in lpfc_sli4_abts_err_handler()
11480 ext_status = axri->parameter & IOERR_PARAM_MASK; in lpfc_sli4_abts_err_handler()
11487 * lpfc_sli_async_event_handler - ASYNC iocb handler function
11509 icmd = &iocbq->iocb; in lpfc_sli_async_event_handler()
11510 evt_code = icmd->un.asyncstat.evt_code; in lpfc_sli_async_event_handler()
11515 temp_event_data.data = (uint32_t) icmd->ulpContext; in lpfc_sli_async_event_handler()
11522 (uint32_t) icmd->ulpContext); in lpfc_sli_async_event_handler()
11528 (uint32_t) icmd->ulpContext); in lpfc_sli_async_event_handler()
11532 shost = lpfc_shost_from_vport(phba->pport); in lpfc_sli_async_event_handler()
11549 pring->ringno, icmd->un.asyncstat.evt_code, in lpfc_sli_async_event_handler()
11561 * lpfc_sli4_setup - SLI ring setup function
11576 pring = phba->sli4_hba.els_wq->pring; in lpfc_sli4_setup()
11577 pring->num_mask = LPFC_MAX_RING_MASK; in lpfc_sli4_setup()
11578 pring->prt[0].profile = 0; /* Mask 0 */ in lpfc_sli4_setup()
11579 pring->prt[0].rctl = FC_RCTL_ELS_REQ; in lpfc_sli4_setup()
11580 pring->prt[0].type = FC_TYPE_ELS; in lpfc_sli4_setup()
11581 pring->prt[0].lpfc_sli_rcv_unsol_event = in lpfc_sli4_setup()
11583 pring->prt[1].profile = 0; /* Mask 1 */ in lpfc_sli4_setup()
11584 pring->prt[1].rctl = FC_RCTL_ELS_REP; in lpfc_sli4_setup()
11585 pring->prt[1].type = FC_TYPE_ELS; in lpfc_sli4_setup()
11586 pring->prt[1].lpfc_sli_rcv_unsol_event = in lpfc_sli4_setup()
11588 pring->prt[2].profile = 0; /* Mask 2 */ in lpfc_sli4_setup()
11590 pring->prt[2].rctl = FC_RCTL_DD_UNSOL_CTL; in lpfc_sli4_setup()
11592 pring->prt[2].type = FC_TYPE_CT; in lpfc_sli4_setup()
11593 pring->prt[2].lpfc_sli_rcv_unsol_event = in lpfc_sli4_setup()
11595 pring->prt[3].profile = 0; /* Mask 3 */ in lpfc_sli4_setup()
11597 pring->prt[3].rctl = FC_RCTL_DD_SOL_CTL; in lpfc_sli4_setup()
11599 pring->prt[3].type = FC_TYPE_CT; in lpfc_sli4_setup()
11600 pring->prt[3].lpfc_sli_rcv_unsol_event = in lpfc_sli4_setup()
11606 * lpfc_sli_setup - SLI ring setup function
11620 struct lpfc_sli *psli = &phba->sli; in lpfc_sli_setup()
11623 psli->num_rings = MAX_SLI3_CONFIGURED_RINGS; in lpfc_sli_setup()
11624 psli->sli_flag = 0; in lpfc_sli_setup()
11626 psli->iocbq_lookup = NULL; in lpfc_sli_setup()
11627 psli->iocbq_lookup_len = 0; in lpfc_sli_setup()
11628 psli->last_iotag = 0; in lpfc_sli_setup()
11630 for (i = 0; i < psli->num_rings; i++) { in lpfc_sli_setup()
11631 pring = &psli->sli3_ring[i]; in lpfc_sli_setup()
11633 case LPFC_FCP_RING: /* ring 0 - FCP */ in lpfc_sli_setup()
11635 pring->sli.sli3.numCiocb = SLI2_IOCB_CMD_R0_ENTRIES; in lpfc_sli_setup()
11636 pring->sli.sli3.numRiocb = SLI2_IOCB_RSP_R0_ENTRIES; in lpfc_sli_setup()
11637 pring->sli.sli3.numCiocb += in lpfc_sli_setup()
11639 pring->sli.sli3.numRiocb += in lpfc_sli_setup()
11641 pring->sli.sli3.numCiocb += in lpfc_sli_setup()
11643 pring->sli.sli3.numRiocb += in lpfc_sli_setup()
11645 pring->sli.sli3.sizeCiocb = (phba->sli_rev == 3) ? in lpfc_sli_setup()
11648 pring->sli.sli3.sizeRiocb = (phba->sli_rev == 3) ? in lpfc_sli_setup()
11651 pring->iotag_ctr = 0; in lpfc_sli_setup()
11652 pring->iotag_max = in lpfc_sli_setup()
11653 (phba->cfg_hba_queue_depth * 2); in lpfc_sli_setup()
11654 pring->fast_iotag = pring->iotag_max; in lpfc_sli_setup()
11655 pring->num_mask = 0; in lpfc_sli_setup()
11657 case LPFC_EXTRA_RING: /* ring 1 - EXTRA */ in lpfc_sli_setup()
11659 pring->sli.sli3.numCiocb = SLI2_IOCB_CMD_R1_ENTRIES; in lpfc_sli_setup()
11660 pring->sli.sli3.numRiocb = SLI2_IOCB_RSP_R1_ENTRIES; in lpfc_sli_setup()
11661 pring->sli.sli3.sizeCiocb = (phba->sli_rev == 3) ? in lpfc_sli_setup()
11664 pring->sli.sli3.sizeRiocb = (phba->sli_rev == 3) ? in lpfc_sli_setup()
11667 pring->iotag_max = phba->cfg_hba_queue_depth; in lpfc_sli_setup()
11668 pring->num_mask = 0; in lpfc_sli_setup()
11670 case LPFC_ELS_RING: /* ring 2 - ELS / CT */ in lpfc_sli_setup()
11672 pring->sli.sli3.numCiocb = SLI2_IOCB_CMD_R2_ENTRIES; in lpfc_sli_setup()
11673 pring->sli.sli3.numRiocb = SLI2_IOCB_RSP_R2_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->fast_iotag = 0; in lpfc_sli_setup()
11681 pring->iotag_ctr = 0; in lpfc_sli_setup()
11682 pring->iotag_max = 4096; in lpfc_sli_setup()
11683 pring->lpfc_sli_rcv_async_status = in lpfc_sli_setup()
11685 pring->num_mask = LPFC_MAX_RING_MASK; in lpfc_sli_setup()
11686 pring->prt[0].profile = 0; /* Mask 0 */ in lpfc_sli_setup()
11687 pring->prt[0].rctl = FC_RCTL_ELS_REQ; in lpfc_sli_setup()
11688 pring->prt[0].type = FC_TYPE_ELS; in lpfc_sli_setup()
11689 pring->prt[0].lpfc_sli_rcv_unsol_event = in lpfc_sli_setup()
11691 pring->prt[1].profile = 0; /* Mask 1 */ in lpfc_sli_setup()
11692 pring->prt[1].rctl = FC_RCTL_ELS_REP; in lpfc_sli_setup()
11693 pring->prt[1].type = FC_TYPE_ELS; in lpfc_sli_setup()
11694 pring->prt[1].lpfc_sli_rcv_unsol_event = in lpfc_sli_setup()
11696 pring->prt[2].profile = 0; /* Mask 2 */ in lpfc_sli_setup()
11698 pring->prt[2].rctl = FC_RCTL_DD_UNSOL_CTL; in lpfc_sli_setup()
11700 pring->prt[2].type = FC_TYPE_CT; in lpfc_sli_setup()
11701 pring->prt[2].lpfc_sli_rcv_unsol_event = in lpfc_sli_setup()
11703 pring->prt[3].profile = 0; /* Mask 3 */ in lpfc_sli_setup()
11705 pring->prt[3].rctl = FC_RCTL_DD_SOL_CTL; in lpfc_sli_setup()
11707 pring->prt[3].type = FC_TYPE_CT; in lpfc_sli_setup()
11708 pring->prt[3].lpfc_sli_rcv_unsol_event = in lpfc_sli_setup()
11712 totiocbsize += (pring->sli.sli3.numCiocb * in lpfc_sli_setup()
11713 pring->sli.sli3.sizeCiocb) + in lpfc_sli_setup()
11714 (pring->sli.sli3.numRiocb * pring->sli.sli3.sizeRiocb); in lpfc_sli_setup()
11720 phba->brd_no, totiocbsize, in lpfc_sli_setup()
11723 if (phba->cfg_multi_ring_support == 2) in lpfc_sli_setup()
11730 * lpfc_sli4_queue_init - Queue initialization function
11733 * lpfc_sli4_queue_init sets up mailbox queues and iocb queues for each
11747 psli = &phba->sli; in lpfc_sli4_queue_init()
11748 spin_lock_irq(&phba->hbalock); in lpfc_sli4_queue_init()
11749 INIT_LIST_HEAD(&psli->mboxq); in lpfc_sli4_queue_init()
11750 INIT_LIST_HEAD(&psli->mboxq_cmpl); in lpfc_sli4_queue_init()
11752 for (i = 0; i < phba->cfg_hdw_queue; i++) { in lpfc_sli4_queue_init()
11753 pring = phba->sli4_hba.hdwq[i].io_wq->pring; in lpfc_sli4_queue_init()
11754 pring->flag = 0; in lpfc_sli4_queue_init()
11755 pring->ringno = LPFC_FCP_RING; in lpfc_sli4_queue_init()
11756 pring->txcmplq_cnt = 0; in lpfc_sli4_queue_init()
11757 INIT_LIST_HEAD(&pring->txq); in lpfc_sli4_queue_init()
11758 INIT_LIST_HEAD(&pring->txcmplq); in lpfc_sli4_queue_init()
11759 INIT_LIST_HEAD(&pring->iocb_continueq); in lpfc_sli4_queue_init()
11760 spin_lock_init(&pring->ring_lock); in lpfc_sli4_queue_init()
11762 pring = phba->sli4_hba.els_wq->pring; in lpfc_sli4_queue_init()
11763 pring->flag = 0; in lpfc_sli4_queue_init()
11764 pring->ringno = LPFC_ELS_RING; in lpfc_sli4_queue_init()
11765 pring->txcmplq_cnt = 0; in lpfc_sli4_queue_init()
11766 INIT_LIST_HEAD(&pring->txq); in lpfc_sli4_queue_init()
11767 INIT_LIST_HEAD(&pring->txcmplq); in lpfc_sli4_queue_init()
11768 INIT_LIST_HEAD(&pring->iocb_continueq); in lpfc_sli4_queue_init()
11769 spin_lock_init(&pring->ring_lock); in lpfc_sli4_queue_init()
11771 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_queue_init()
11772 pring = phba->sli4_hba.nvmels_wq->pring; in lpfc_sli4_queue_init()
11773 pring->flag = 0; in lpfc_sli4_queue_init()
11774 pring->ringno = LPFC_ELS_RING; in lpfc_sli4_queue_init()
11775 pring->txcmplq_cnt = 0; in lpfc_sli4_queue_init()
11776 INIT_LIST_HEAD(&pring->txq); in lpfc_sli4_queue_init()
11777 INIT_LIST_HEAD(&pring->txcmplq); in lpfc_sli4_queue_init()
11778 INIT_LIST_HEAD(&pring->iocb_continueq); in lpfc_sli4_queue_init()
11779 spin_lock_init(&pring->ring_lock); in lpfc_sli4_queue_init()
11782 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_queue_init()
11786 * lpfc_sli_queue_init - Queue initialization function
11789 * lpfc_sli_queue_init sets up mailbox queues and iocb queues for each
11803 psli = &phba->sli; in lpfc_sli_queue_init()
11804 spin_lock_irq(&phba->hbalock); in lpfc_sli_queue_init()
11805 INIT_LIST_HEAD(&psli->mboxq); in lpfc_sli_queue_init()
11806 INIT_LIST_HEAD(&psli->mboxq_cmpl); in lpfc_sli_queue_init()
11808 for (i = 0; i < psli->num_rings; i++) { in lpfc_sli_queue_init()
11809 pring = &psli->sli3_ring[i]; in lpfc_sli_queue_init()
11810 pring->ringno = i; in lpfc_sli_queue_init()
11811 pring->sli.sli3.next_cmdidx = 0; in lpfc_sli_queue_init()
11812 pring->sli.sli3.local_getidx = 0; in lpfc_sli_queue_init()
11813 pring->sli.sli3.cmdidx = 0; in lpfc_sli_queue_init()
11814 INIT_LIST_HEAD(&pring->iocb_continueq); in lpfc_sli_queue_init()
11815 INIT_LIST_HEAD(&pring->iocb_continue_saveq); in lpfc_sli_queue_init()
11816 INIT_LIST_HEAD(&pring->postbufq); in lpfc_sli_queue_init()
11817 pring->flag = 0; in lpfc_sli_queue_init()
11818 INIT_LIST_HEAD(&pring->txq); in lpfc_sli_queue_init()
11819 INIT_LIST_HEAD(&pring->txcmplq); in lpfc_sli_queue_init()
11820 spin_lock_init(&pring->ring_lock); in lpfc_sli_queue_init()
11822 spin_unlock_irq(&phba->hbalock); in lpfc_sli_queue_init()
11826 * lpfc_sli_mbox_sys_flush - Flush mailbox command sub-system
11829 * This routine flushes the mailbox command subsystem. It will unconditionally
11830 * flush all the mailbox commands in the three possible stages in the mailbox
11831 * command sub-system: pending mailbox command queue; the outstanding mailbox
11832 * command; and completed mailbox command queue. It is caller's responsibility
11833 * to make sure that the driver is in the proper state to flush the mailbox
11834 * command sub-system. Namely, the posting of mailbox commands into the
11835 * pending mailbox command queue from the various clients must be stopped;
11837 * mailbox command (such as in EEH or ERATT conditions) or the outstanding
11838 * mailbox command has been completed.
11844 struct lpfc_sli *psli = &phba->sli; in lpfc_sli_mbox_sys_flush()
11848 /* Disable softirqs, including timers from obtaining phba->hbalock */ in lpfc_sli_mbox_sys_flush()
11851 /* Flush all the mailbox commands in the mbox system */ in lpfc_sli_mbox_sys_flush()
11852 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_mbox_sys_flush()
11854 /* The pending mailbox command queue */ in lpfc_sli_mbox_sys_flush()
11855 list_splice_init(&phba->sli.mboxq, &completions); in lpfc_sli_mbox_sys_flush()
11856 /* The outstanding active mailbox command */ in lpfc_sli_mbox_sys_flush()
11857 if (psli->mbox_active) { in lpfc_sli_mbox_sys_flush()
11858 list_add_tail(&psli->mbox_active->list, &completions); in lpfc_sli_mbox_sys_flush()
11859 psli->mbox_active = NULL; in lpfc_sli_mbox_sys_flush()
11860 psli->sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; in lpfc_sli_mbox_sys_flush()
11862 /* The completed mailbox command queue */ in lpfc_sli_mbox_sys_flush()
11863 list_splice_init(&phba->sli.mboxq_cmpl, &completions); in lpfc_sli_mbox_sys_flush()
11864 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_mbox_sys_flush()
11866 /* Enable softirqs again, done with phba->hbalock */ in lpfc_sli_mbox_sys_flush()
11869 /* Return all flushed mailbox commands with MBX_NOT_FINISHED status */ in lpfc_sli_mbox_sys_flush()
11872 pmb->u.mb.mbxStatus = MBX_NOT_FINISHED; in lpfc_sli_mbox_sys_flush()
11873 if (pmb->mbox_cmpl) in lpfc_sli_mbox_sys_flush()
11874 pmb->mbox_cmpl(phba, pmb); in lpfc_sli_mbox_sys_flush()
11879 * lpfc_sli_host_down - Vport cleanup function
11886 * - Free discovery resources associated with this virtual
11888 * - Free iocbs associated with this virtual port in
11890 * - Send abort for all iocb commands associated with this
11899 struct lpfc_hba *phba = vport->phba; in lpfc_sli_host_down()
11900 struct lpfc_sli *psli = &phba->sli; in lpfc_sli_host_down()
11910 spin_lock_irqsave(&phba->hbalock, flags); in lpfc_sli_host_down()
11917 if (phba->sli_rev != LPFC_SLI_REV4) { in lpfc_sli_host_down()
11918 for (i = 0; i < psli->num_rings; i++) { in lpfc_sli_host_down()
11919 pring = &psli->sli3_ring[i]; in lpfc_sli_host_down()
11920 prev_pring_flag = pring->flag; in lpfc_sli_host_down()
11922 if (pring->ringno == LPFC_ELS_RING) { in lpfc_sli_host_down()
11923 pring->flag |= LPFC_DEFERRED_RING_EVENT; in lpfc_sli_host_down()
11925 set_bit(LPFC_DATA_READY, &phba->data_flags); in lpfc_sli_host_down()
11928 &pring->txq, list) { in lpfc_sli_host_down()
11929 if (iocb->vport != vport) in lpfc_sli_host_down()
11931 list_move_tail(&iocb->list, &completions); in lpfc_sli_host_down()
11934 &pring->txcmplq, list) { in lpfc_sli_host_down()
11935 if (iocb->vport != vport) in lpfc_sli_host_down()
11940 pring->flag = prev_pring_flag; in lpfc_sli_host_down()
11943 list_for_each_entry(qp, &phba->sli4_hba.lpfc_wq_list, wq_list) { in lpfc_sli_host_down()
11944 pring = qp->pring; in lpfc_sli_host_down()
11947 if (pring == phba->sli4_hba.els_wq->pring) { in lpfc_sli_host_down()
11948 pring->flag |= LPFC_DEFERRED_RING_EVENT; in lpfc_sli_host_down()
11950 set_bit(LPFC_DATA_READY, &phba->data_flags); in lpfc_sli_host_down()
11952 prev_pring_flag = pring->flag; in lpfc_sli_host_down()
11953 spin_lock(&pring->ring_lock); in lpfc_sli_host_down()
11955 &pring->txq, list) { in lpfc_sli_host_down()
11956 if (iocb->vport != vport) in lpfc_sli_host_down()
11958 list_move_tail(&iocb->list, &completions); in lpfc_sli_host_down()
11960 spin_unlock(&pring->ring_lock); in lpfc_sli_host_down()
11962 &pring->txcmplq, list) { in lpfc_sli_host_down()
11963 if (iocb->vport != vport) in lpfc_sli_host_down()
11968 pring->flag = prev_pring_flag; in lpfc_sli_host_down()
11971 spin_unlock_irqrestore(&phba->hbalock, flags); in lpfc_sli_host_down()
11983 * lpfc_sli_hba_down - Resource cleanup function for the HBA
11986 * This function cleans up all iocb, buffers, mailbox commands
11990 * - Free discovery resources for each virtual port
11991 * - Cleanup any pending fabric iocbs
11992 * - Iterate through the iocb txq and free each entry
11994 * - Free up any buffer posted to the HBA
11995 * - Free mailbox commands in the mailbox queue.
12001 struct lpfc_sli *psli = &phba->sli; in lpfc_sli_hba_down()
12008 /* Shutdown the mailbox command sub-system */ in lpfc_sli_hba_down()
12013 /* Disable softirqs, including timers from obtaining phba->hbalock */ in lpfc_sli_hba_down()
12018 spin_lock_irqsave(&phba->hbalock, flags); in lpfc_sli_hba_down()
12024 if (phba->sli_rev != LPFC_SLI_REV4) { in lpfc_sli_hba_down()
12025 for (i = 0; i < psli->num_rings; i++) { in lpfc_sli_hba_down()
12026 pring = &psli->sli3_ring[i]; in lpfc_sli_hba_down()
12028 if (pring->ringno == LPFC_ELS_RING) { in lpfc_sli_hba_down()
12029 pring->flag |= LPFC_DEFERRED_RING_EVENT; in lpfc_sli_hba_down()
12031 set_bit(LPFC_DATA_READY, &phba->data_flags); in lpfc_sli_hba_down()
12033 list_splice_init(&pring->txq, &completions); in lpfc_sli_hba_down()
12036 list_for_each_entry(qp, &phba->sli4_hba.lpfc_wq_list, wq_list) { in lpfc_sli_hba_down()
12037 pring = qp->pring; in lpfc_sli_hba_down()
12040 spin_lock(&pring->ring_lock); in lpfc_sli_hba_down()
12041 list_splice_init(&pring->txq, &completions); in lpfc_sli_hba_down()
12042 spin_unlock(&pring->ring_lock); in lpfc_sli_hba_down()
12043 if (pring == phba->sli4_hba.els_wq->pring) { in lpfc_sli_hba_down()
12044 pring->flag |= LPFC_DEFERRED_RING_EVENT; in lpfc_sli_hba_down()
12046 set_bit(LPFC_DATA_READY, &phba->data_flags); in lpfc_sli_hba_down()
12050 spin_unlock_irqrestore(&phba->hbalock, flags); in lpfc_sli_hba_down()
12056 spin_lock_irqsave(&phba->hbalock, flags); in lpfc_sli_hba_down()
12057 list_splice_init(&phba->elsbuf, &completions); in lpfc_sli_hba_down()
12058 phba->elsbuf_cnt = 0; in lpfc_sli_hba_down()
12059 phba->elsbuf_prev_cnt = 0; in lpfc_sli_hba_down()
12060 spin_unlock_irqrestore(&phba->hbalock, flags); in lpfc_sli_hba_down()
12065 lpfc_mbuf_free(phba, buf_ptr->virt, buf_ptr->phys); in lpfc_sli_hba_down()
12069 /* Enable softirqs again, done with phba->hbalock */ in lpfc_sli_hba_down()
12073 del_timer_sync(&psli->mbox_tmo); in lpfc_sli_hba_down()
12075 spin_lock_irqsave(&phba->pport->work_port_lock, flags); in lpfc_sli_hba_down()
12076 phba->pport->work_port_events &= ~WORKER_MBOX_TMO; in lpfc_sli_hba_down()
12077 spin_unlock_irqrestore(&phba->pport->work_port_lock, flags); in lpfc_sli_hba_down()
12083 * lpfc_sli_pcimem_bcopy - SLI memory copy function
12113 * lpfc_sli_bemem_bcopy - SLI memory copy function
12140 * lpfc_sli_ringpostbuf_put - Function to add a buffer to postbufq
12155 spin_lock_irq(&phba->hbalock); in lpfc_sli_ringpostbuf_put()
12156 list_add_tail(&mp->list, &pring->postbufq); in lpfc_sli_ringpostbuf_put()
12157 pring->postbufq_cnt++; in lpfc_sli_ringpostbuf_put()
12158 spin_unlock_irq(&phba->hbalock); in lpfc_sli_ringpostbuf_put()
12163 * lpfc_sli_get_buffer_tag - allocates a tag for a CMD_QUE_XRI64_CX buffer
12168 * tag is bit wise or-ed with QUE_BUFTAG_BIT to make sure that the tag
12176 spin_lock_irq(&phba->hbalock); in lpfc_sli_get_buffer_tag()
12177 phba->buffer_tag_count++; in lpfc_sli_get_buffer_tag()
12182 phba->buffer_tag_count |= QUE_BUFTAG_BIT; in lpfc_sli_get_buffer_tag()
12183 spin_unlock_irq(&phba->hbalock); in lpfc_sli_get_buffer_tag()
12184 return phba->buffer_tag_count; in lpfc_sli_get_buffer_tag()
12188 * lpfc_sli_ring_taggedbuf_get - find HBQ buffer associated with given tag
12193 * Buffers posted using CMD_QUE_XRI64_CX iocb are in pring->postbufq
12196 * This function searches the pring->postbufq list using the tag
12207 struct list_head *slp = &pring->postbufq; in lpfc_sli_ring_taggedbuf_get()
12210 spin_lock_irq(&phba->hbalock); in lpfc_sli_ring_taggedbuf_get()
12211 list_for_each_entry_safe(mp, next_mp, &pring->postbufq, list) { in lpfc_sli_ring_taggedbuf_get()
12212 if (mp->buffer_tag == tag) { in lpfc_sli_ring_taggedbuf_get()
12213 list_del_init(&mp->list); in lpfc_sli_ring_taggedbuf_get()
12214 pring->postbufq_cnt--; in lpfc_sli_ring_taggedbuf_get()
12215 spin_unlock_irq(&phba->hbalock); in lpfc_sli_ring_taggedbuf_get()
12220 spin_unlock_irq(&phba->hbalock); in lpfc_sli_ring_taggedbuf_get()
12224 pring->ringno, (unsigned long) tag, in lpfc_sli_ring_taggedbuf_get()
12225 slp->next, slp->prev, pring->postbufq_cnt); in lpfc_sli_ring_taggedbuf_get()
12231 * lpfc_sli_ringpostbuf_get - search buffers for unsolicited CT and ELS events
12251 struct list_head *slp = &pring->postbufq; in lpfc_sli_ringpostbuf_get()
12254 spin_lock_irq(&phba->hbalock); in lpfc_sli_ringpostbuf_get()
12255 list_for_each_entry_safe(mp, next_mp, &pring->postbufq, list) { in lpfc_sli_ringpostbuf_get()
12256 if (mp->phys == phys) { in lpfc_sli_ringpostbuf_get()
12257 list_del_init(&mp->list); in lpfc_sli_ringpostbuf_get()
12258 pring->postbufq_cnt--; in lpfc_sli_ringpostbuf_get()
12259 spin_unlock_irq(&phba->hbalock); in lpfc_sli_ringpostbuf_get()
12264 spin_unlock_irq(&phba->hbalock); in lpfc_sli_ringpostbuf_get()
12268 pring->ringno, (unsigned long long)phys, in lpfc_sli_ringpostbuf_get()
12269 slp->next, slp->prev, pring->postbufq_cnt); in lpfc_sli_ringpostbuf_get()
12274 * lpfc_sli_abort_els_cmpl - Completion handler for the els abort iocbs
12297 if (phba->sli_rev < LPFC_SLI_REV4) { in lpfc_sli_abort_els_cmpl()
12310 (phba->sli_rev == LPFC_SLI_REV4) ? in lpfc_sli_abort_els_cmpl()
12312 cmdiocb->iocb.un.acxri.abortContextTag, in lpfc_sli_abort_els_cmpl()
12322 * lpfc_ignore_els_cmpl - Completion handler for aborted ELS command
12336 struct lpfc_nodelist *ndlp = cmdiocb->ndlp; in lpfc_ignore_els_cmpl()
12345 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_ignore_els_cmpl()
12348 irsp = &rspiocb->iocb; in lpfc_ignore_els_cmpl()
12349 iotag = irsp->ulpIoTag; in lpfc_ignore_els_cmpl()
12355 if (cmdiocb->context_un.mbox) { in lpfc_ignore_els_cmpl()
12356 mbox = cmdiocb->context_un.mbox; in lpfc_ignore_els_cmpl()
12358 cmdiocb->context_un.mbox = NULL; in lpfc_ignore_els_cmpl()
12367 cmdiocb->ndlp); in lpfc_ignore_els_cmpl()
12381 * lpfc_sli_issue_abort_iotag - Abort function for a command iocb
12399 struct lpfc_vport *vport = cmdiocb->vport; in lpfc_sli_issue_abort_iotag()
12416 cmdiocb->cmd_flag & LPFC_DRIVER_ABORTED) in lpfc_sli_issue_abort_iotag()
12420 if (cmdiocb->cmd_flag & LPFC_IO_FABRIC) in lpfc_sli_issue_abort_iotag()
12421 cmdiocb->fabric_cmd_cmpl = lpfc_ignore_els_cmpl; in lpfc_sli_issue_abort_iotag()
12423 cmdiocb->cmd_cmpl = lpfc_ignore_els_cmpl; in lpfc_sli_issue_abort_iotag()
12431 if ((vport->load_flag & FC_UNLOADING) && in lpfc_sli_issue_abort_iotag()
12432 pring->ringno == LPFC_ELS_RING) { in lpfc_sli_issue_abort_iotag()
12433 if (cmdiocb->cmd_flag & LPFC_IO_FABRIC) in lpfc_sli_issue_abort_iotag()
12434 cmdiocb->fabric_cmd_cmpl = lpfc_ignore_els_cmpl; in lpfc_sli_issue_abort_iotag()
12436 cmdiocb->cmd_cmpl = lpfc_ignore_els_cmpl; in lpfc_sli_issue_abort_iotag()
12448 cmdiocb->cmd_flag |= LPFC_DRIVER_ABORTED; in lpfc_sli_issue_abort_iotag()
12450 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_sli_issue_abort_iotag()
12451 ulp_context = cmdiocb->sli4_xritag; in lpfc_sli_issue_abort_iotag()
12452 iotag = abtsiocbp->iotag; in lpfc_sli_issue_abort_iotag()
12454 iotag = cmdiocb->iocb.ulpIoTag; in lpfc_sli_issue_abort_iotag()
12455 if (pring->ringno == LPFC_ELS_RING) { in lpfc_sli_issue_abort_iotag()
12456 ndlp = cmdiocb->ndlp; in lpfc_sli_issue_abort_iotag()
12457 ulp_context = ndlp->nlp_rpi; in lpfc_sli_issue_abort_iotag()
12459 ulp_context = cmdiocb->iocb.ulpContext; in lpfc_sli_issue_abort_iotag()
12463 if (phba->link_state < LPFC_LINK_UP || in lpfc_sli_issue_abort_iotag()
12464 (phba->sli_rev == LPFC_SLI_REV4 && in lpfc_sli_issue_abort_iotag()
12465 phba->sli4_hba.link_state.status == LPFC_FC_LA_TYPE_LINK_DOWN) || in lpfc_sli_issue_abort_iotag()
12466 (phba->link_flag & LS_EXTERNAL_LOOPBACK)) in lpfc_sli_issue_abort_iotag()
12472 cmdiocb->iocb.ulpClass, in lpfc_sli_issue_abort_iotag()
12475 abtsiocbp->vport = vport; in lpfc_sli_issue_abort_iotag()
12478 abtsiocbp->hba_wqidx = cmdiocb->hba_wqidx; in lpfc_sli_issue_abort_iotag()
12479 if (cmdiocb->cmd_flag & LPFC_IO_FCP) in lpfc_sli_issue_abort_iotag()
12480 abtsiocbp->cmd_flag |= (LPFC_IO_FCP | LPFC_USE_FCPWQIDX); in lpfc_sli_issue_abort_iotag()
12482 if (cmdiocb->cmd_flag & LPFC_IO_FOF) in lpfc_sli_issue_abort_iotag()
12483 abtsiocbp->cmd_flag |= LPFC_IO_FOF; in lpfc_sli_issue_abort_iotag()
12486 abtsiocbp->cmd_cmpl = cmpl; in lpfc_sli_issue_abort_iotag()
12488 abtsiocbp->cmd_cmpl = lpfc_sli_abort_els_cmpl; in lpfc_sli_issue_abort_iotag()
12489 abtsiocbp->vport = vport; in lpfc_sli_issue_abort_iotag()
12491 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_sli_issue_abort_iotag()
12496 spin_lock_irqsave(&pring->ring_lock, iflags); in lpfc_sli_issue_abort_iotag()
12497 retval = __lpfc_sli_issue_iocb(phba, pring->ringno, in lpfc_sli_issue_abort_iotag()
12499 spin_unlock_irqrestore(&pring->ring_lock, iflags); in lpfc_sli_issue_abort_iotag()
12501 retval = __lpfc_sli_issue_iocb(phba, pring->ringno, in lpfc_sli_issue_abort_iotag()
12511 ulp_context, (phba->sli_rev == LPFC_SLI_REV4) ? in lpfc_sli_issue_abort_iotag()
12512 cmdiocb->iotag : iotag, iotag, cmdiocb, abtsiocbp, in lpfc_sli_issue_abort_iotag()
12515 cmdiocb->cmd_flag &= ~LPFC_DRIVER_ABORTED; in lpfc_sli_issue_abort_iotag()
12528 * lpfc_sli_hba_iocb_abort - Abort all iocbs to an hba.
12536 struct lpfc_sli *psli = &phba->sli; in lpfc_sli_hba_iocb_abort()
12541 if (phba->sli_rev != LPFC_SLI_REV4) { in lpfc_sli_hba_iocb_abort()
12542 for (i = 0; i < psli->num_rings; i++) { in lpfc_sli_hba_iocb_abort()
12543 pring = &psli->sli3_ring[i]; in lpfc_sli_hba_iocb_abort()
12548 list_for_each_entry(qp, &phba->sli4_hba.lpfc_wq_list, wq_list) { in lpfc_sli_hba_iocb_abort()
12549 pring = qp->pring; in lpfc_sli_hba_iocb_abort()
12557 * lpfc_sli_validate_fcp_iocb_for_abort - filter iocbs appropriate for FCP aborts
12564 * -ENODEV, if a null iocb or vport ptr is encountered
12565 * -EINVAL, if the iocb is not an FCP I/O, not on the TX cmpl queue, premarked as
12576 if (!iocbq || iocbq->vport != vport) in lpfc_sli_validate_fcp_iocb_for_abort()
12577 return -ENODEV; in lpfc_sli_validate_fcp_iocb_for_abort()
12582 ulp_command = get_job_cmnd(vport->phba, iocbq); in lpfc_sli_validate_fcp_iocb_for_abort()
12583 if (!(iocbq->cmd_flag & LPFC_IO_FCP) || in lpfc_sli_validate_fcp_iocb_for_abort()
12584 !(iocbq->cmd_flag & LPFC_IO_ON_TXCMPLQ) || in lpfc_sli_validate_fcp_iocb_for_abort()
12585 (iocbq->cmd_flag & LPFC_DRIVER_ABORTED) || in lpfc_sli_validate_fcp_iocb_for_abort()
12589 return -EINVAL; in lpfc_sli_validate_fcp_iocb_for_abort()
12595 * lpfc_sli_validate_fcp_iocb - validate commands associated with a SCSI target
12628 if (lpfc_cmd->pCmd == NULL) in lpfc_sli_validate_fcp_iocb()
12633 if ((lpfc_cmd->rdata) && (lpfc_cmd->rdata->pnode) && in lpfc_sli_validate_fcp_iocb()
12634 (lpfc_cmd->rdata->pnode->nlp_sid == tgt_id) && in lpfc_sli_validate_fcp_iocb()
12635 (scsilun_to_int(&lpfc_cmd->fcp_cmnd->fcp_lun) == lun_id)) in lpfc_sli_validate_fcp_iocb()
12639 if ((lpfc_cmd->rdata) && (lpfc_cmd->rdata->pnode) && in lpfc_sli_validate_fcp_iocb()
12640 (lpfc_cmd->rdata->pnode->nlp_sid == tgt_id)) in lpfc_sli_validate_fcp_iocb()
12656 * lpfc_sli_sum_iocb - Function to count the number of FCP iocbs pending
12678 struct lpfc_hba *phba = vport->phba; in lpfc_sli_sum_iocb()
12684 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli_sum_iocb()
12685 for (i = 1, sum = 0; i <= phba->sli.last_iotag; i++) { in lpfc_sli_sum_iocb()
12686 iocbq = phba->sli.iocbq_lookup[i]; in lpfc_sli_sum_iocb()
12688 if (!iocbq || iocbq->vport != vport) in lpfc_sli_sum_iocb()
12690 if (!(iocbq->cmd_flag & LPFC_IO_FCP) || in lpfc_sli_sum_iocb()
12691 !(iocbq->cmd_flag & LPFC_IO_ON_TXCMPLQ)) in lpfc_sli_sum_iocb()
12707 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli_sum_iocb()
12713 * lpfc_sli_abort_fcp_cmpl - Completion handler function for aborted FCP IOCBs
12730 (phba->sli_rev == LPFC_SLI_REV4) ? in lpfc_sli_abort_fcp_cmpl()
12731 cmdiocb->sli4_xritag : in lpfc_sli_abort_fcp_cmpl()
12732 cmdiocb->iocb.un.acxri.abortContextTag, in lpfc_sli_abort_fcp_cmpl()
12734 cmdiocb->iotag, get_job_ulpstatus(phba, rspiocb), in lpfc_sli_abort_fcp_cmpl()
12741 * lpfc_sli_abort_iocb - issue abort for all commands on a host/target/LUN
12770 struct lpfc_hba *phba = vport->phba; in lpfc_sli_abort_iocb()
12778 if (phba->hba_flag & HBA_IOQ_FLUSH) in lpfc_sli_abort_iocb()
12781 for (i = 1; i <= phba->sli.last_iotag; i++) { in lpfc_sli_abort_iocb()
12782 iocbq = phba->sli.iocbq_lookup[i]; in lpfc_sli_abort_iocb()
12791 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli_abort_iocb()
12792 if (phba->sli_rev == LPFC_SLI_REV3) { in lpfc_sli_abort_iocb()
12793 pring = &phba->sli.sli3_ring[LPFC_FCP_RING]; in lpfc_sli_abort_iocb()
12794 } else if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_sli_abort_iocb()
12799 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli_abort_iocb()
12808 * lpfc_sli_abort_taskmgmt - issue abort for all commands on a host/target/LUN
12837 struct lpfc_hba *phba = vport->phba; in lpfc_sli_abort_taskmgmt()
12848 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli_abort_taskmgmt()
12851 if (phba->hba_flag & HBA_IOQ_FLUSH) { in lpfc_sli_abort_taskmgmt()
12852 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli_abort_taskmgmt()
12857 for (i = 1; i <= phba->sli.last_iotag; i++) { in lpfc_sli_abort_taskmgmt()
12858 iocbq = phba->sli.iocbq_lookup[i]; in lpfc_sli_abort_taskmgmt()
12869 spin_lock(&lpfc_cmd->buf_lock); in lpfc_sli_abort_taskmgmt()
12871 if (!lpfc_cmd->pCmd) { in lpfc_sli_abort_taskmgmt()
12872 spin_unlock(&lpfc_cmd->buf_lock); in lpfc_sli_abort_taskmgmt()
12876 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_sli_abort_taskmgmt()
12878 phba->sli4_hba.hdwq[iocbq->hba_wqidx].io_wq->pring; in lpfc_sli_abort_taskmgmt()
12880 spin_unlock(&lpfc_cmd->buf_lock); in lpfc_sli_abort_taskmgmt()
12884 spin_lock(&pring_s4->ring_lock); in lpfc_sli_abort_taskmgmt()
12891 if ((iocbq->cmd_flag & LPFC_DRIVER_ABORTED) || in lpfc_sli_abort_taskmgmt()
12892 !(iocbq->cmd_flag & LPFC_IO_ON_TXCMPLQ)) { in lpfc_sli_abort_taskmgmt()
12893 if (phba->sli_rev == LPFC_SLI_REV4) in lpfc_sli_abort_taskmgmt()
12894 spin_unlock(&pring_s4->ring_lock); in lpfc_sli_abort_taskmgmt()
12895 spin_unlock(&lpfc_cmd->buf_lock); 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()
12908 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_sli_abort_taskmgmt()
12909 iotag = abtsiocbq->iotag; in lpfc_sli_abort_taskmgmt()
12910 ulp_context = iocbq->sli4_xritag; in lpfc_sli_abort_taskmgmt()
12911 cqid = lpfc_cmd->hdwq->io_cq_map; in lpfc_sli_abort_taskmgmt()
12913 iotag = iocbq->iocb.ulpIoTag; in lpfc_sli_abort_taskmgmt()
12914 if (pring->ringno == LPFC_ELS_RING) { in lpfc_sli_abort_taskmgmt()
12915 ndlp = iocbq->ndlp; in lpfc_sli_abort_taskmgmt()
12916 ulp_context = ndlp->nlp_rpi; in lpfc_sli_abort_taskmgmt()
12918 ulp_context = iocbq->iocb.ulpContext; in lpfc_sli_abort_taskmgmt()
12922 ndlp = lpfc_cmd->rdata->pnode; in lpfc_sli_abort_taskmgmt()
12925 (ndlp && ndlp->nlp_state == NLP_STE_MAPPED_NODE) && in lpfc_sli_abort_taskmgmt()
12926 !(phba->link_flag & LS_EXTERNAL_LOOPBACK)) in lpfc_sli_abort_taskmgmt()
12932 iocbq->iocb.ulpClass, cqid, in lpfc_sli_abort_taskmgmt()
12935 abtsiocbq->vport = vport; in lpfc_sli_abort_taskmgmt()
12938 abtsiocbq->hba_wqidx = iocbq->hba_wqidx; in lpfc_sli_abort_taskmgmt()
12939 if (iocbq->cmd_flag & LPFC_IO_FCP) in lpfc_sli_abort_taskmgmt()
12940 abtsiocbq->cmd_flag |= LPFC_USE_FCPWQIDX; in lpfc_sli_abort_taskmgmt()
12941 if (iocbq->cmd_flag & LPFC_IO_FOF) in lpfc_sli_abort_taskmgmt()
12942 abtsiocbq->cmd_flag |= LPFC_IO_FOF; in lpfc_sli_abort_taskmgmt()
12945 abtsiocbq->cmd_cmpl = lpfc_sli_abort_fcp_cmpl; in lpfc_sli_abort_taskmgmt()
12951 iocbq->cmd_flag |= LPFC_DRIVER_ABORTED; in lpfc_sli_abort_taskmgmt()
12953 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_sli_abort_taskmgmt()
12954 ret_val = __lpfc_sli_issue_iocb(phba, pring_s4->ringno, in lpfc_sli_abort_taskmgmt()
12956 spin_unlock(&pring_s4->ring_lock); in lpfc_sli_abort_taskmgmt()
12958 ret_val = __lpfc_sli_issue_iocb(phba, pring->ringno, in lpfc_sli_abort_taskmgmt()
12962 spin_unlock(&lpfc_cmd->buf_lock); in lpfc_sli_abort_taskmgmt()
12969 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli_abort_taskmgmt()
12974 * lpfc_sli_wake_iocb_wait - lpfc_sli_issue_iocb_wait's completion handler
13000 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli_wake_iocb_wait()
13001 if (cmdiocbq->cmd_flag & LPFC_IO_WAKE_TMO) { in lpfc_sli_wake_iocb_wait()
13009 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli_wake_iocb_wait()
13010 cmdiocbq->cmd_cmpl = cmdiocbq->wait_cmd_cmpl; in lpfc_sli_wake_iocb_wait()
13011 cmdiocbq->wait_cmd_cmpl = NULL; in lpfc_sli_wake_iocb_wait()
13012 if (cmdiocbq->cmd_cmpl) in lpfc_sli_wake_iocb_wait()
13013 cmdiocbq->cmd_cmpl(phba, cmdiocbq, NULL); in lpfc_sli_wake_iocb_wait()
13020 cmdiocbq->cmd_flag |= LPFC_IO_WAKE; in lpfc_sli_wake_iocb_wait()
13021 if (cmdiocbq->rsp_iocb && rspiocbq) in lpfc_sli_wake_iocb_wait()
13022 memcpy((char *)cmdiocbq->rsp_iocb + offset, in lpfc_sli_wake_iocb_wait()
13023 (char *)rspiocbq + offset, sizeof(*rspiocbq) - offset); in lpfc_sli_wake_iocb_wait()
13026 if ((cmdiocbq->cmd_flag & LPFC_IO_FCP) && in lpfc_sli_wake_iocb_wait()
13027 !(cmdiocbq->cmd_flag & LPFC_IO_LIBDFC)) { in lpfc_sli_wake_iocb_wait()
13030 if (rspiocbq && (rspiocbq->cmd_flag & LPFC_EXCHANGE_BUSY)) in lpfc_sli_wake_iocb_wait()
13031 lpfc_cmd->flags |= LPFC_SBUF_XBUSY; in lpfc_sli_wake_iocb_wait()
13033 lpfc_cmd->flags &= ~LPFC_SBUF_XBUSY; in lpfc_sli_wake_iocb_wait()
13036 pdone_q = cmdiocbq->context_un.wait_queue; in lpfc_sli_wake_iocb_wait()
13039 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli_wake_iocb_wait()
13044 * lpfc_chk_iocb_flg - Test IOCB flag with lock held.
13062 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_chk_iocb_flg()
13063 ret = piocbq->cmd_flag & flag; in lpfc_chk_iocb_flg()
13064 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_chk_iocb_flg()
13070 * lpfc_sli_issue_iocb_wait - Synchronous function to issue iocb commands
13089 * non-interruptible wait.
13123 if (phba->sli_rev >= LPFC_SLI_REV4) { in lpfc_sli_issue_iocb_wait()
13128 pring = &phba->sli.sli3_ring[ring_number]; in lpfc_sli_issue_iocb_wait()
13134 if (piocb->rsp_iocb) in lpfc_sli_issue_iocb_wait()
13136 piocb->rsp_iocb = prspiocbq; in lpfc_sli_issue_iocb_wait()
13139 piocb->wait_cmd_cmpl = piocb->cmd_cmpl; in lpfc_sli_issue_iocb_wait()
13140 piocb->cmd_cmpl = lpfc_sli_wake_iocb_wait; in lpfc_sli_issue_iocb_wait()
13141 piocb->context_un.wait_queue = &done_q; in lpfc_sli_issue_iocb_wait()
13142 piocb->cmd_flag &= ~(LPFC_IO_WAKE | LPFC_IO_WAKE_TMO); in lpfc_sli_issue_iocb_wait()
13144 if (phba->cfg_poll & DISABLE_FCP_RING_INT) { in lpfc_sli_issue_iocb_wait()
13145 if (lpfc_readl(phba->HCregaddr, &creg_val)) in lpfc_sli_issue_iocb_wait()
13148 writel(creg_val, phba->HCregaddr); in lpfc_sli_issue_iocb_wait()
13149 readl(phba->HCregaddr); /* flush */ in lpfc_sli_issue_iocb_wait()
13159 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli_issue_iocb_wait()
13160 if (!(piocb->cmd_flag & LPFC_IO_WAKE)) { in lpfc_sli_issue_iocb_wait()
13168 piocb->cmd_flag |= LPFC_IO_WAKE_TMO; in lpfc_sli_issue_iocb_wait()
13170 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli_issue_iocb_wait()
13175 * status or not - that's for the caller to check. in lpfc_sli_issue_iocb_wait()
13181 "0338 IOCB wait timeout error - no " in lpfc_sli_issue_iocb_wait()
13192 if (phba->cfg_log_verbose & LOG_SLI) { in lpfc_sli_issue_iocb_wait()
13193 list_for_each_entry(iocb, &pring->txq, list) { in lpfc_sli_issue_iocb_wait()
13196 list_for_each_entry(iocb, &pring->txcmplq, list) { in lpfc_sli_issue_iocb_wait()
13201 phba->iocb_cnt, txq_cnt, txcmplq_cnt); in lpfc_sli_issue_iocb_wait()
13211 if (phba->cfg_poll & DISABLE_FCP_RING_INT) { in lpfc_sli_issue_iocb_wait()
13212 if (lpfc_readl(phba->HCregaddr, &creg_val)) in lpfc_sli_issue_iocb_wait()
13215 writel(creg_val, phba->HCregaddr); in lpfc_sli_issue_iocb_wait()
13216 readl(phba->HCregaddr); /* flush */ in lpfc_sli_issue_iocb_wait()
13220 piocb->rsp_iocb = NULL; in lpfc_sli_issue_iocb_wait()
13222 piocb->context_un.wait_queue = NULL; in lpfc_sli_issue_iocb_wait()
13223 piocb->cmd_cmpl = NULL; in lpfc_sli_issue_iocb_wait()
13228 * lpfc_sli_issue_mbox_wait - Synchronous function to issue mailbox
13230 * @pmboxq: Pointer to driver mailbox object.
13233 * This function issues the mailbox to firmware and waits for the
13234 * mailbox command to complete. If the mailbox command is not
13236 * The function waits for the mailbox completion using an
13239 * should not free the mailbox resources, if this function returns
13241 * This function will sleep while waiting for mailbox completion.
13245 * This function assumes that the mailbox completion occurs while
13247 * the worker thread which processes mailbox completion.
13261 pmboxq->mbox_flag &= ~LPFC_MBX_WAKE; in lpfc_sli_issue_mbox_wait()
13263 pmboxq->mbox_cmpl = lpfc_sli_wake_mbox_wait; in lpfc_sli_issue_mbox_wait()
13267 pmboxq->context3 = &mbox_done; in lpfc_sli_issue_mbox_wait()
13274 spin_lock_irqsave(&phba->hbalock, flag); in lpfc_sli_issue_mbox_wait()
13275 pmboxq->context3 = NULL; in lpfc_sli_issue_mbox_wait()
13277 * if LPFC_MBX_WAKE flag is set the mailbox is completed in lpfc_sli_issue_mbox_wait()
13280 if (pmboxq->mbox_flag & LPFC_MBX_WAKE) { in lpfc_sli_issue_mbox_wait()
13284 pmboxq->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_sli_issue_mbox_wait()
13286 spin_unlock_irqrestore(&phba->hbalock, flag); in lpfc_sli_issue_mbox_wait()
13292 * lpfc_sli_mbox_sys_shutdown - shutdown mailbox command sub-system
13294 * @mbx_action: Mailbox shutdown options.
13296 * This function is called to shutdown the driver's mailbox sub-system.
13297 * It first marks the mailbox sub-system is in a block state to prevent
13298 * the asynchronous mailbox command from issued off the pending mailbox
13299 * command queue. If the mailbox command sub-system shutdown is due to
13301 * the mailbox sub-system flush routine to forcefully bring down the
13302 * mailbox sub-system. Otherwise, if it is due to normal condition (such
13304 * outstanding mailbox command to complete before invoking the mailbox
13305 * sub-system flush routine to gracefully bring down mailbox sub-system.
13310 struct lpfc_sli *psli = &phba->sli; in lpfc_sli_mbox_sys_shutdown()
13321 /* Disable softirqs, including timers from obtaining phba->hbalock */ in lpfc_sli_mbox_sys_shutdown()
13324 spin_lock_irq(&phba->hbalock); in lpfc_sli_mbox_sys_shutdown()
13325 psli->sli_flag |= LPFC_SLI_ASYNC_MBX_BLK; in lpfc_sli_mbox_sys_shutdown()
13327 if (psli->sli_flag & LPFC_SLI_ACTIVE) { in lpfc_sli_mbox_sys_shutdown()
13328 /* Determine how long we might wait for the active mailbox in lpfc_sli_mbox_sys_shutdown()
13331 if (phba->sli.mbox_active) in lpfc_sli_mbox_sys_shutdown()
13333 phba->sli.mbox_active) * in lpfc_sli_mbox_sys_shutdown()
13335 spin_unlock_irq(&phba->hbalock); in lpfc_sli_mbox_sys_shutdown()
13337 /* Enable softirqs again, done with phba->hbalock */ in lpfc_sli_mbox_sys_shutdown()
13340 while (phba->sli.mbox_active) { in lpfc_sli_mbox_sys_shutdown()
13341 /* Check active mailbox complete status every 2ms */ in lpfc_sli_mbox_sys_shutdown()
13344 /* Timeout, let the mailbox flush routine to in lpfc_sli_mbox_sys_shutdown()
13345 * forcefully release active mailbox command in lpfc_sli_mbox_sys_shutdown()
13350 spin_unlock_irq(&phba->hbalock); in lpfc_sli_mbox_sys_shutdown()
13352 /* Enable softirqs again, done with phba->hbalock */ in lpfc_sli_mbox_sys_shutdown()
13360 * lpfc_sli_eratt_read - read sli-3 error attention events
13376 if (lpfc_readl(phba->HAregaddr, &ha_copy)) in lpfc_sli_eratt_read()
13385 if ((HS_FFER1 & phba->work_hs) && in lpfc_sli_eratt_read()
13387 HS_FFER6 | HS_FFER7 | HS_FFER8) & phba->work_hs)) { in lpfc_sli_eratt_read()
13388 phba->hba_flag |= DEFER_ERATT; in lpfc_sli_eratt_read()
13390 writel(0, phba->HCregaddr); in lpfc_sli_eratt_read()
13391 readl(phba->HCregaddr); in lpfc_sli_eratt_read()
13395 phba->work_ha |= HA_ERATT; in lpfc_sli_eratt_read()
13397 phba->hba_flag |= HBA_ERATT_HANDLED; in lpfc_sli_eratt_read()
13404 phba->work_hs |= UNPLUG_ERR; in lpfc_sli_eratt_read()
13406 phba->work_ha |= HA_ERATT; in lpfc_sli_eratt_read()
13408 phba->hba_flag |= HBA_ERATT_HANDLED; in lpfc_sli_eratt_read()
13413 * lpfc_sli4_eratt_read - read sli-4 error attention events
13435 if_type = bf_get(lpfc_sli_intf_if_type, &phba->sli4_hba.sli_intf); in lpfc_sli4_eratt_read()
13438 if (lpfc_readl(phba->sli4_hba.u.if_type0.UERRLOregaddr, in lpfc_sli4_eratt_read()
13440 lpfc_readl(phba->sli4_hba.u.if_type0.UERRHIregaddr, in lpfc_sli4_eratt_read()
13442 phba->work_hs |= UNPLUG_ERR; in lpfc_sli4_eratt_read()
13443 phba->work_ha |= HA_ERATT; in lpfc_sli4_eratt_read()
13444 phba->hba_flag |= HBA_ERATT_HANDLED; in lpfc_sli4_eratt_read()
13447 if ((~phba->sli4_hba.ue_mask_lo & uerr_sta_lo) || in lpfc_sli4_eratt_read()
13448 (~phba->sli4_hba.ue_mask_hi & uerr_sta_hi)) { in lpfc_sli4_eratt_read()
13455 phba->sli4_hba.ue_mask_lo, in lpfc_sli4_eratt_read()
13456 phba->sli4_hba.ue_mask_hi); in lpfc_sli4_eratt_read()
13457 phba->work_status[0] = uerr_sta_lo; in lpfc_sli4_eratt_read()
13458 phba->work_status[1] = uerr_sta_hi; in lpfc_sli4_eratt_read()
13459 phba->work_ha |= HA_ERATT; in lpfc_sli4_eratt_read()
13460 phba->hba_flag |= HBA_ERATT_HANDLED; in lpfc_sli4_eratt_read()
13466 if (lpfc_readl(phba->sli4_hba.u.if_type2.STATUSregaddr, in lpfc_sli4_eratt_read()
13468 lpfc_readl(phba->sli4_hba.PSMPHRregaddr, in lpfc_sli4_eratt_read()
13470 phba->work_hs |= UNPLUG_ERR; in lpfc_sli4_eratt_read()
13471 phba->work_ha |= HA_ERATT; in lpfc_sli4_eratt_read()
13472 phba->hba_flag |= HBA_ERATT_HANDLED; in lpfc_sli4_eratt_read()
13476 phba->work_status[0] = in lpfc_sli4_eratt_read()
13477 readl(phba->sli4_hba.u.if_type2.ERR1regaddr); in lpfc_sli4_eratt_read()
13478 phba->work_status[1] = in lpfc_sli4_eratt_read()
13479 readl(phba->sli4_hba.u.if_type2.ERR2regaddr); in lpfc_sli4_eratt_read()
13481 if (phba->work_status[0] == in lpfc_sli4_eratt_read()
13483 phba->work_status[1] == SLIPORT_ERR2_REG_FW_RESTART) in lpfc_sli4_eratt_read()
13492 phba->work_status[0], in lpfc_sli4_eratt_read()
13493 phba->work_status[1]); in lpfc_sli4_eratt_read()
13494 phba->work_ha |= HA_ERATT; in lpfc_sli4_eratt_read()
13495 phba->hba_flag |= HBA_ERATT_HANDLED; in lpfc_sli4_eratt_read()
13511 * lpfc_sli_check_eratt - check error attention events
13528 if (phba->link_flag & LS_IGNORE_ERATT) in lpfc_sli_check_eratt()
13532 spin_lock_irq(&phba->hbalock); in lpfc_sli_check_eratt()
13533 if (phba->hba_flag & HBA_ERATT_HANDLED) { in lpfc_sli_check_eratt()
13535 spin_unlock_irq(&phba->hbalock); in lpfc_sli_check_eratt()
13543 if (unlikely(phba->hba_flag & DEFER_ERATT)) { in lpfc_sli_check_eratt()
13544 spin_unlock_irq(&phba->hbalock); in lpfc_sli_check_eratt()
13549 if (unlikely(pci_channel_offline(phba->pcidev))) { in lpfc_sli_check_eratt()
13550 spin_unlock_irq(&phba->hbalock); in lpfc_sli_check_eratt()
13554 switch (phba->sli_rev) { in lpfc_sli_check_eratt()
13567 phba->sli_rev); in lpfc_sli_check_eratt()
13571 spin_unlock_irq(&phba->hbalock); in lpfc_sli_check_eratt()
13577 * lpfc_intr_state_check - Check device state for interrupt handling
13584 * interrupt should be handled, otherwise -EIO.
13590 if (unlikely(pci_channel_offline(phba->pcidev))) in lpfc_intr_state_check()
13591 return -EIO; in lpfc_intr_state_check()
13594 phba->sli.slistat.sli_intr++; in lpfc_intr_state_check()
13597 if (unlikely(phba->link_state < LPFC_LINK_DOWN)) in lpfc_intr_state_check()
13598 return -EIO; in lpfc_intr_state_check()
13604 * lpfc_sli_sp_intr_handler - Slow-path interrupt handler to SLI-3 device
13609 * service routine when device with SLI-3 interface spec is enabled with
13610 * MSI-X multi-message interrupt mode and there are slow-path events in
13611 * the HBA. However, when the device is enabled with either MSI or Pin-IRQ
13612 * interrupt mode, this function is called as part of the device-level
13652 * individual interrupt handler in MSI-X multi-message interrupt mode in lpfc_sli_sp_intr_handler()
13654 if (phba->intr_type == MSIX) { in lpfc_sli_sp_intr_handler()
13658 /* Need to read HA REG for slow-path events */ in lpfc_sli_sp_intr_handler()
13659 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_sp_intr_handler()
13660 if (lpfc_readl(phba->HAregaddr, &ha_copy)) in lpfc_sli_sp_intr_handler()
13665 if (phba->link_flag & LS_IGNORE_ERATT) in lpfc_sli_sp_intr_handler()
13669 if (phba->hba_flag & HBA_ERATT_HANDLED) in lpfc_sli_sp_intr_handler()
13674 phba->hba_flag |= HBA_ERATT_HANDLED; in lpfc_sli_sp_intr_handler()
13681 if (unlikely(phba->hba_flag & DEFER_ERATT)) { in lpfc_sli_sp_intr_handler()
13682 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_sp_intr_handler()
13686 /* Clear up only attention source related to slow-path */ in lpfc_sli_sp_intr_handler()
13687 if (lpfc_readl(phba->HCregaddr, &hc_copy)) in lpfc_sli_sp_intr_handler()
13692 phba->HCregaddr); in lpfc_sli_sp_intr_handler()
13694 phba->HAregaddr); in lpfc_sli_sp_intr_handler()
13695 writel(hc_copy, phba->HCregaddr); in lpfc_sli_sp_intr_handler()
13696 readl(phba->HAregaddr); /* flush */ in lpfc_sli_sp_intr_handler()
13697 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_sp_intr_handler()
13699 ha_copy = phba->ha_copy; in lpfc_sli_sp_intr_handler()
13701 work_ha_copy = ha_copy & phba->work_ha_mask; in lpfc_sli_sp_intr_handler()
13705 if (phba->sli.sli_flag & LPFC_PROCESS_LA) { in lpfc_sli_sp_intr_handler()
13710 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_sp_intr_handler()
13711 phba->sli.sli_flag &= ~LPFC_PROCESS_LA; in lpfc_sli_sp_intr_handler()
13712 if (lpfc_readl(phba->HCregaddr, &control)) in lpfc_sli_sp_intr_handler()
13715 writel(control, phba->HCregaddr); in lpfc_sli_sp_intr_handler()
13716 readl(phba->HCregaddr); /* flush */ in lpfc_sli_sp_intr_handler()
13717 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_sp_intr_handler()
13732 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_sp_intr_handler()
13733 if (lpfc_readl(phba->HCregaddr, &control)) in lpfc_sli_sp_intr_handler()
13739 (uint32_t)phba->sli.slistat.sli_intr); in lpfc_sli_sp_intr_handler()
13745 phba->work_ha, work_ha_copy, in lpfc_sli_sp_intr_handler()
13747 &phba->work_waitq)); in lpfc_sli_sp_intr_handler()
13751 writel(control, phba->HCregaddr); in lpfc_sli_sp_intr_handler()
13752 readl(phba->HCregaddr); /* flush */ in lpfc_sli_sp_intr_handler()
13758 phba->work_ha, work_ha_copy, in lpfc_sli_sp_intr_handler()
13760 &phba->work_waitq)); in lpfc_sli_sp_intr_handler()
13762 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_sp_intr_handler()
13765 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_sp_intr_handler()
13773 if ((HS_FFER1 & phba->work_hs) && in lpfc_sli_sp_intr_handler()
13776 phba->work_hs)) { in lpfc_sli_sp_intr_handler()
13777 phba->hba_flag |= DEFER_ERATT; in lpfc_sli_sp_intr_handler()
13779 writel(0, phba->HCregaddr); in lpfc_sli_sp_intr_handler()
13780 readl(phba->HCregaddr); in lpfc_sli_sp_intr_handler()
13784 if ((work_ha_copy & HA_MBATT) && (phba->sli.mbox_active)) { in lpfc_sli_sp_intr_handler()
13785 pmb = phba->sli.mbox_active; in lpfc_sli_sp_intr_handler()
13786 pmbox = &pmb->u.mb; in lpfc_sli_sp_intr_handler()
13787 mbox = phba->mbox; in lpfc_sli_sp_intr_handler()
13788 vport = pmb->vport; in lpfc_sli_sp_intr_handler()
13792 if (pmbox->mbxOwner != OWN_HOST) { in lpfc_sli_sp_intr_handler()
13793 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_sp_intr_handler()
13795 * Stray Mailbox Interrupt, mbxCommand <cmd> in lpfc_sli_sp_intr_handler()
13799 "(%d):0304 Stray Mailbox " in lpfc_sli_sp_intr_handler()
13802 (vport ? vport->vpi : 0), in lpfc_sli_sp_intr_handler()
13803 pmbox->mbxCommand, in lpfc_sli_sp_intr_handler()
13804 pmbox->mbxStatus); in lpfc_sli_sp_intr_handler()
13805 /* clear mailbox attention bit */ in lpfc_sli_sp_intr_handler()
13808 phba->sli.mbox_active = NULL; in lpfc_sli_sp_intr_handler()
13809 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_sp_intr_handler()
13810 phba->last_completion_time = jiffies; in lpfc_sli_sp_intr_handler()
13811 del_timer(&phba->sli.mbox_tmo); in lpfc_sli_sp_intr_handler()
13812 if (pmb->mbox_cmpl) { in lpfc_sli_sp_intr_handler()
13815 if (pmb->out_ext_byte_len && in lpfc_sli_sp_intr_handler()
13816 pmb->ctx_buf) in lpfc_sli_sp_intr_handler()
13818 phba->mbox_ext, in lpfc_sli_sp_intr_handler()
13819 pmb->ctx_buf, in lpfc_sli_sp_intr_handler()
13820 pmb->out_ext_byte_len); in lpfc_sli_sp_intr_handler()
13822 if (pmb->mbox_flag & LPFC_MBX_IMED_UNREG) { in lpfc_sli_sp_intr_handler()
13823 pmb->mbox_flag &= ~LPFC_MBX_IMED_UNREG; in lpfc_sli_sp_intr_handler()
13829 (uint32_t)pmbox->mbxStatus, in lpfc_sli_sp_intr_handler()
13830 pmbox->un.varWords[0], 0); in lpfc_sli_sp_intr_handler()
13832 if (!pmbox->mbxStatus) { in lpfc_sli_sp_intr_handler()
13834 (pmb->ctx_buf); in lpfc_sli_sp_intr_handler()
13836 pmb->ctx_ndlp; in lpfc_sli_sp_intr_handler()
13844 vport->vpi, in lpfc_sli_sp_intr_handler()
13845 pmbox->un.varWords[0], in lpfc_sli_sp_intr_handler()
13847 pmb->mbox_cmpl = in lpfc_sli_sp_intr_handler()
13849 pmb->ctx_buf = mp; in lpfc_sli_sp_intr_handler()
13850 pmb->ctx_ndlp = ndlp; in lpfc_sli_sp_intr_handler()
13851 pmb->vport = vport; in lpfc_sli_sp_intr_handler()
13866 &phba->pport->work_port_lock, in lpfc_sli_sp_intr_handler()
13868 phba->pport->work_port_events &= in lpfc_sli_sp_intr_handler()
13871 &phba->pport->work_port_lock, in lpfc_sli_sp_intr_handler()
13877 if (pmbox->mbxCommand == MBX_HEARTBEAT) { in lpfc_sli_sp_intr_handler()
13879 phba->sli.mbox_active = NULL; in lpfc_sli_sp_intr_handler()
13880 phba->sli.sli_flag &= in lpfc_sli_sp_intr_handler()
13882 if (pmb->mbox_cmpl) in lpfc_sli_sp_intr_handler()
13883 pmb->mbox_cmpl(phba, pmb); in lpfc_sli_sp_intr_handler()
13890 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_sp_intr_handler()
13893 (phba->sli.mbox_active == NULL)) { in lpfc_sli_sp_intr_handler()
13895 /* Process next mailbox command if there is one */ in lpfc_sli_sp_intr_handler()
13907 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_sp_intr_handler()
13908 phba->work_ha |= work_ha_copy; in lpfc_sli_sp_intr_handler()
13909 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_sp_intr_handler()
13914 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_sp_intr_handler()
13920 * lpfc_sli_fp_intr_handler - Fast-path interrupt handler to SLI-3 device.
13925 * service routine when device with SLI-3 interface spec is enabled with
13926 * MSI-X multi-message interrupt mode and there is a fast-path FCP IOCB
13928 * MSI or Pin-IRQ interrupt mode, this function is called as part of the
13929 * device-level interrupt handler. When the PCI slot is in error recovery
13931 * process the interrupt. The SCSI FCP fast-path ring event are handled in
13957 * individual interrupt handler in MSI-X multi-message interrupt mode in lpfc_sli_fp_intr_handler()
13959 if (phba->intr_type == MSIX) { in lpfc_sli_fp_intr_handler()
13964 if (lpfc_readl(phba->HAregaddr, &ha_copy)) in lpfc_sli_fp_intr_handler()
13966 /* Clear up only attention source related to fast-path */ in lpfc_sli_fp_intr_handler()
13967 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli_fp_intr_handler()
13972 if (unlikely(phba->hba_flag & DEFER_ERATT)) { in lpfc_sli_fp_intr_handler()
13973 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_fp_intr_handler()
13977 phba->HAregaddr); in lpfc_sli_fp_intr_handler()
13978 readl(phba->HAregaddr); /* flush */ in lpfc_sli_fp_intr_handler()
13979 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli_fp_intr_handler()
13981 ha_copy = phba->ha_copy; in lpfc_sli_fp_intr_handler()
13986 ha_copy &= ~(phba->work_ha_mask); in lpfc_sli_fp_intr_handler()
13990 pring = &phba->sli.sli3_ring[LPFC_FCP_RING]; in lpfc_sli_fp_intr_handler()
13994 if (phba->cfg_multi_ring_support == 2) { in lpfc_sli_fp_intr_handler()
14003 &phba->sli.sli3_ring[LPFC_EXTRA_RING], in lpfc_sli_fp_intr_handler()
14011 * lpfc_sli_intr_handler - Device-level interrupt handler to SLI-3 device
14015 * This function is the HBA device-level interrupt handler to device with
14016 * SLI-3 interface spec, called from the PCI layer when either MSI or
14017 * Pin-IRQ interrupt mode is enabled and there is an event in the HBA which
14018 * requires driver attention. This function invokes the slow-path interrupt
14019 * attention handling function and fast-path interrupt attention handling
14048 spin_lock(&phba->hbalock); in lpfc_sli_intr_handler()
14049 if (lpfc_readl(phba->HAregaddr, &phba->ha_copy)) { in lpfc_sli_intr_handler()
14050 spin_unlock(&phba->hbalock); in lpfc_sli_intr_handler()
14054 if (unlikely(!phba->ha_copy)) { in lpfc_sli_intr_handler()
14055 spin_unlock(&phba->hbalock); in lpfc_sli_intr_handler()
14057 } else if (phba->ha_copy & HA_ERATT) { in lpfc_sli_intr_handler()
14058 if (phba->hba_flag & HBA_ERATT_HANDLED) in lpfc_sli_intr_handler()
14060 phba->ha_copy &= ~HA_ERATT; in lpfc_sli_intr_handler()
14063 phba->hba_flag |= HBA_ERATT_HANDLED; in lpfc_sli_intr_handler()
14069 if (unlikely(phba->hba_flag & DEFER_ERATT)) { in lpfc_sli_intr_handler()
14070 spin_unlock(&phba->hbalock); in lpfc_sli_intr_handler()
14075 if (lpfc_readl(phba->HCregaddr, &hc_copy)) { in lpfc_sli_intr_handler()
14076 spin_unlock(&phba->hbalock); in lpfc_sli_intr_handler()
14081 phba->HCregaddr); in lpfc_sli_intr_handler()
14082 writel((phba->ha_copy & ~(HA_LATT | HA_ERATT)), phba->HAregaddr); in lpfc_sli_intr_handler()
14083 writel(hc_copy, phba->HCregaddr); in lpfc_sli_intr_handler()
14084 readl(phba->HAregaddr); /* flush */ in lpfc_sli_intr_handler()
14085 spin_unlock(&phba->hbalock); in lpfc_sli_intr_handler()
14088 * Invokes slow-path host attention interrupt handling as appropriate. in lpfc_sli_intr_handler()
14091 /* status of events with mailbox and link attention */ in lpfc_sli_intr_handler()
14092 status1 = phba->ha_copy & (HA_MBATT | HA_LATT | HA_ERATT); in lpfc_sli_intr_handler()
14095 status2 = (phba->ha_copy & (HA_RXMASK << (4*LPFC_ELS_RING))); in lpfc_sli_intr_handler()
14104 * Invoke fast-path host attention interrupt handling as appropriate. in lpfc_sli_intr_handler()
14108 status1 = (phba->ha_copy & (HA_RXMASK << (4*LPFC_FCP_RING))); in lpfc_sli_intr_handler()
14112 if (phba->cfg_multi_ring_support == 2) { in lpfc_sli_intr_handler()
14113 status2 = (phba->ha_copy & (HA_RXMASK << (4*LPFC_EXTRA_RING))); in lpfc_sli_intr_handler()
14123 /* Return device-level interrupt handling status */ in lpfc_sli_intr_handler()
14128 * lpfc_sli4_els_xri_abort_event_proc - Process els xri abort event
14140 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_els_xri_abort_event_proc()
14141 phba->hba_flag &= ~ELS_XRI_ABORT_EVENT; in lpfc_sli4_els_xri_abort_event_proc()
14142 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_els_xri_abort_event_proc()
14145 spin_lock_irqsave(&phba->sli4_hba.els_xri_abrt_list_lock, iflags); in lpfc_sli4_els_xri_abort_event_proc()
14146 while (!list_empty(&phba->sli4_hba.sp_els_xri_aborted_work_queue)) { in lpfc_sli4_els_xri_abort_event_proc()
14148 list_remove_head(&phba->sli4_hba.sp_els_xri_aborted_work_queue, in lpfc_sli4_els_xri_abort_event_proc()
14150 spin_unlock_irqrestore(&phba->sli4_hba.els_xri_abrt_list_lock, in lpfc_sli4_els_xri_abort_event_proc()
14153 lpfc_sli4_els_xri_aborted(phba, &cq_event->cqe.wcqe_axri); in lpfc_sli4_els_xri_abort_event_proc()
14157 spin_lock_irqsave(&phba->sli4_hba.els_xri_abrt_list_lock, in lpfc_sli4_els_xri_abort_event_proc()
14160 spin_unlock_irqrestore(&phba->sli4_hba.els_xri_abrt_list_lock, iflags); in lpfc_sli4_els_xri_abort_event_proc()
14164 * lpfc_sli4_els_preprocess_rspiocbq - Get response iocbq from els wcqe
14166 * @irspiocbq: Pointer to work-queue completion queue entry.
14168 * This routine handles an ELS work-queue completion event and construct
14187 wcqe = &irspiocbq->cq_event.cqe.wcqe_cmpl; in lpfc_sli4_els_preprocess_rspiocbq()
14188 spin_lock_irqsave(&pring->ring_lock, iflags); in lpfc_sli4_els_preprocess_rspiocbq()
14189 pring->stats.iocb_event++; in lpfc_sli4_els_preprocess_rspiocbq()
14194 spin_unlock_irqrestore(&pring->ring_lock, iflags); in lpfc_sli4_els_preprocess_rspiocbq()
14198 wcqe->word0, wcqe->total_data_placed, in lpfc_sli4_els_preprocess_rspiocbq()
14199 wcqe->parameter, wcqe->word3); in lpfc_sli4_els_preprocess_rspiocbq()
14204 memcpy(&irspiocbq->wqe, &cmdiocbq->wqe, sizeof(union lpfc_wqe128)); in lpfc_sli4_els_preprocess_rspiocbq()
14205 memcpy(&irspiocbq->wcqe_cmpl, wcqe, sizeof(*wcqe)); in lpfc_sli4_els_preprocess_rspiocbq()
14209 spin_unlock_irqrestore(&pring->ring_lock, iflags); in lpfc_sli4_els_preprocess_rspiocbq()
14212 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_els_preprocess_rspiocbq()
14213 irspiocbq->cmd_flag |= LPFC_EXCHANGE_BUSY; in lpfc_sli4_els_preprocess_rspiocbq()
14214 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_els_preprocess_rspiocbq()
14234 memcpy(&cq_event->cqe, entry, size); in lpfc_cq_event_setup()
14239 * lpfc_sli4_sp_handle_async_event - Handle an asynchronous event
14241 * @mcqe: Pointer to mailbox completion queue entry.
14243 * This routine process a mailbox completion queue entry with asynchronous
14256 "word2:x%x, word3:x%x\n", mcqe->word0, in lpfc_sli4_sp_handle_async_event()
14257 mcqe->mcqe_tag0, mcqe->mcqe_tag1, mcqe->trailer); in lpfc_sli4_sp_handle_async_event()
14263 spin_lock_irqsave(&phba->sli4_hba.asynce_list_lock, iflags); in lpfc_sli4_sp_handle_async_event()
14264 list_add_tail(&cq_event->list, &phba->sli4_hba.sp_asynce_work_queue); in lpfc_sli4_sp_handle_async_event()
14265 spin_unlock_irqrestore(&phba->sli4_hba.asynce_list_lock, iflags); in lpfc_sli4_sp_handle_async_event()
14268 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_async_event()
14269 phba->hba_flag |= ASYNC_EVENT; in lpfc_sli4_sp_handle_async_event()
14270 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_async_event()
14276 * lpfc_sli4_sp_handle_mbox_event - Handle a mailbox completion event
14278 * @mcqe: Pointer to mailbox completion queue entry.
14280 * This routine process a mailbox completion queue entry with mailbox
14299 /* If not a mailbox complete MCQE, out by checking mailbox consume */ in lpfc_sli4_sp_handle_mbox_event()
14304 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_mbox_event()
14305 pmb = phba->sli.mbox_active; in lpfc_sli4_sp_handle_mbox_event()
14309 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_mbox_event()
14312 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_mbox_event()
14313 mqe = &pmb->u.mqe; in lpfc_sli4_sp_handle_mbox_event()
14314 pmbox = (MAILBOX_t *)&pmb->u.mqe; in lpfc_sli4_sp_handle_mbox_event()
14315 mbox = phba->mbox; in lpfc_sli4_sp_handle_mbox_event()
14316 vport = pmb->vport; in lpfc_sli4_sp_handle_mbox_event()
14319 phba->last_completion_time = jiffies; in lpfc_sli4_sp_handle_mbox_event()
14320 del_timer(&phba->sli.mbox_tmo); in lpfc_sli4_sp_handle_mbox_event()
14322 /* Move mbox data to caller's mailbox region, do endian swapping */ in lpfc_sli4_sp_handle_mbox_event()
14323 if (pmb->mbox_cmpl && mbox) in lpfc_sli4_sp_handle_mbox_event()
14336 if (pmb->mbox_flag & LPFC_MBX_IMED_UNREG) { in lpfc_sli4_sp_handle_mbox_event()
14337 pmb->mbox_flag &= ~LPFC_MBX_IMED_UNREG; in lpfc_sli4_sp_handle_mbox_event()
14341 pmbox->un.varWords[0], 0); in lpfc_sli4_sp_handle_mbox_event()
14343 mp = (struct lpfc_dmabuf *)(pmb->ctx_buf); in lpfc_sli4_sp_handle_mbox_event()
14344 ndlp = (struct lpfc_nodelist *)pmb->ctx_ndlp; in lpfc_sli4_sp_handle_mbox_event()
14349 * starting another mailbox transaction. in lpfc_sli4_sp_handle_mbox_event()
14351 spin_lock_irqsave(&ndlp->lock, iflags); in lpfc_sli4_sp_handle_mbox_event()
14352 ndlp->nlp_flag |= NLP_UNREG_INP; in lpfc_sli4_sp_handle_mbox_event()
14353 spin_unlock_irqrestore(&ndlp->lock, iflags); in lpfc_sli4_sp_handle_mbox_event()
14354 lpfc_unreg_login(phba, vport->vpi, in lpfc_sli4_sp_handle_mbox_event()
14355 pmbox->un.varWords[0], pmb); in lpfc_sli4_sp_handle_mbox_event()
14356 pmb->mbox_cmpl = lpfc_mbx_cmpl_dflt_rpi; in lpfc_sli4_sp_handle_mbox_event()
14357 pmb->ctx_buf = mp; in lpfc_sli4_sp_handle_mbox_event()
14362 * this mailbox completes. in lpfc_sli4_sp_handle_mbox_event()
14364 pmb->ctx_ndlp = ndlp; in lpfc_sli4_sp_handle_mbox_event()
14365 pmb->vport = vport; in lpfc_sli4_sp_handle_mbox_event()
14376 spin_lock_irqsave(&phba->pport->work_port_lock, iflags); in lpfc_sli4_sp_handle_mbox_event()
14377 phba->pport->work_port_events &= ~WORKER_MBOX_TMO; in lpfc_sli4_sp_handle_mbox_event()
14378 spin_unlock_irqrestore(&phba->pport->work_port_lock, iflags); in lpfc_sli4_sp_handle_mbox_event()
14381 if (pmbox->mbxCommand == MBX_HEARTBEAT) { in lpfc_sli4_sp_handle_mbox_event()
14382 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_mbox_event()
14383 /* Release the mailbox command posting token */ in lpfc_sli4_sp_handle_mbox_event()
14384 phba->sli.sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; in lpfc_sli4_sp_handle_mbox_event()
14385 phba->sli.mbox_active = NULL; in lpfc_sli4_sp_handle_mbox_event()
14387 lpfc_sli4_mq_release(phba->sli4_hba.mbx_wq); in lpfc_sli4_sp_handle_mbox_event()
14388 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_mbox_event()
14394 if (pmb->mbox_cmpl) in lpfc_sli4_sp_handle_mbox_event()
14395 pmb->mbox_cmpl(phba, pmb); in lpfc_sli4_sp_handle_mbox_event()
14399 /* There is mailbox completion work to queue to the worker thread */ in lpfc_sli4_sp_handle_mbox_event()
14400 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_mbox_event()
14402 phba->work_ha |= HA_MBATT; in lpfc_sli4_sp_handle_mbox_event()
14403 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_mbox_event()
14407 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_mbox_event()
14408 /* Release the mailbox command posting token */ in lpfc_sli4_sp_handle_mbox_event()
14409 phba->sli.sli_flag &= ~LPFC_SLI_MBOX_ACTIVE; in lpfc_sli4_sp_handle_mbox_event()
14410 /* Setting active mailbox pointer need to be in sync to flag clear */ in lpfc_sli4_sp_handle_mbox_event()
14411 phba->sli.mbox_active = NULL; in lpfc_sli4_sp_handle_mbox_event()
14413 lpfc_sli4_mq_release(phba->sli4_hba.mbx_wq); in lpfc_sli4_sp_handle_mbox_event()
14414 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_mbox_event()
14415 /* Wake up worker thread to post the next pending mailbox command */ in lpfc_sli4_sp_handle_mbox_event()
14420 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_mbox_event()
14422 lpfc_sli4_mq_release(phba->sli4_hba.mbx_wq); in lpfc_sli4_sp_handle_mbox_event()
14423 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_mbox_event()
14428 * lpfc_sli4_sp_handle_mcqe - Process a mailbox completion queue entry
14431 * @cqe: Pointer to mailbox completion queue entry.
14433 * This routine process a mailbox completion queue entry, it invokes the
14434 * proper mailbox complete handling or asynchronous event handling routine
14446 cq->CQ_mbox++; in lpfc_sli4_sp_handle_mcqe()
14448 /* Copy the mailbox MCQE and convert endian order as needed */ in lpfc_sli4_sp_handle_mcqe()
14460 * lpfc_sli4_sp_handle_els_wcqe - Handle els work-queue completion event
14463 * @wcqe: Pointer to work-queue completion queue entry.
14465 * This routine handles an ELS work-queue completion event.
14475 struct lpfc_sli_ring *pring = cq->pring; in lpfc_sli4_sp_handle_els_wcqe()
14486 wcqe->word0, wcqe->total_data_placed, in lpfc_sli4_sp_handle_els_wcqe()
14487 wcqe->parameter, wcqe->word3); in lpfc_sli4_sp_handle_els_wcqe()
14493 if (!list_empty(&pring->txq)) in lpfc_sli4_sp_handle_els_wcqe()
14495 if (!list_empty(&pring->txcmplq)) in lpfc_sli4_sp_handle_els_wcqe()
14500 txq_cnt, phba->iocb_cnt, in lpfc_sli4_sp_handle_els_wcqe()
14505 /* Save off the slow-path queue event for work thread to process */ in lpfc_sli4_sp_handle_els_wcqe()
14506 memcpy(&irspiocbq->cq_event.cqe.wcqe_cmpl, wcqe, sizeof(*wcqe)); in lpfc_sli4_sp_handle_els_wcqe()
14507 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_els_wcqe()
14508 list_add_tail(&irspiocbq->cq_event.list, in lpfc_sli4_sp_handle_els_wcqe()
14509 &phba->sli4_hba.sp_queue_event); in lpfc_sli4_sp_handle_els_wcqe()
14510 phba->hba_flag |= HBA_SP_QUEUE_EVT; in lpfc_sli4_sp_handle_els_wcqe()
14511 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_els_wcqe()
14517 * lpfc_sli4_sp_handle_rel_wcqe - Handle slow-path WQ entry consumed event
14519 * @wcqe: Pointer to work-queue completion queue entry.
14521 * This routine handles slow-path WQ entry consumed event by invoking the
14522 * proper WQ release routine to the slow-path WQ.
14529 if (unlikely(!phba->sli4_hba.els_wq)) in lpfc_sli4_sp_handle_rel_wcqe()
14531 /* Check for the slow-path ELS work queue */ in lpfc_sli4_sp_handle_rel_wcqe()
14532 if (bf_get(lpfc_wcqe_r_wq_id, wcqe) == phba->sli4_hba.els_wq->queue_id) in lpfc_sli4_sp_handle_rel_wcqe()
14533 lpfc_sli4_wq_release(phba->sli4_hba.els_wq, in lpfc_sli4_sp_handle_rel_wcqe()
14537 "2579 Slow-path wqe consume event carries " in lpfc_sli4_sp_handle_rel_wcqe()
14538 "miss-matched qid: wcqe-qid=x%x, sp-qid=x%x\n", in lpfc_sli4_sp_handle_rel_wcqe()
14540 phba->sli4_hba.els_wq->queue_id); in lpfc_sli4_sp_handle_rel_wcqe()
14544 * lpfc_sli4_sp_handle_abort_xri_wcqe - Handle a xri abort event
14547 * @wcqe: Pointer to work-queue completion queue entry.
14562 switch (cq->subtype) { in lpfc_sli4_sp_handle_abort_xri_wcqe()
14564 lpfc_sli4_io_xri_aborted(phba, wcqe, cq->hdwq); in lpfc_sli4_sp_handle_abort_xri_wcqe()
14565 if (phba->cfg_enable_fc4_type & LPFC_ENABLE_NVME) { in lpfc_sli4_sp_handle_abort_xri_wcqe()
14567 if (phba->nvmet_support) in lpfc_sli4_sp_handle_abort_xri_wcqe()
14579 cq_event->hdwq = cq->hdwq; in lpfc_sli4_sp_handle_abort_xri_wcqe()
14580 spin_lock_irqsave(&phba->sli4_hba.els_xri_abrt_list_lock, in lpfc_sli4_sp_handle_abort_xri_wcqe()
14582 list_add_tail(&cq_event->list, in lpfc_sli4_sp_handle_abort_xri_wcqe()
14583 &phba->sli4_hba.sp_els_xri_aborted_work_queue); in lpfc_sli4_sp_handle_abort_xri_wcqe()
14585 phba->hba_flag |= ELS_XRI_ABORT_EVENT; in lpfc_sli4_sp_handle_abort_xri_wcqe()
14586 spin_unlock_irqrestore(&phba->sli4_hba.els_xri_abrt_list_lock, in lpfc_sli4_sp_handle_abort_xri_wcqe()
14594 cq->subtype, wcqe->word0, wcqe->parameter, in lpfc_sli4_sp_handle_abort_xri_wcqe()
14595 wcqe->word2, wcqe->word3); in lpfc_sli4_sp_handle_abort_xri_wcqe()
14605 * lpfc_sli4_sp_handle_rcqe - Process a receive-queue completion queue entry
14607 * @rcqe: Pointer to receive-queue completion queue entry.
14609 * This routine process a receive-queue completion queue entry.
14618 struct lpfc_queue *hrq = phba->sli4_hba.hdr_rq; in lpfc_sli4_sp_handle_rcqe()
14619 struct lpfc_queue *drq = phba->sli4_hba.dat_rq; in lpfc_sli4_sp_handle_rcqe()
14633 if (rq_id != hrq->queue_id) in lpfc_sli4_sp_handle_rcqe()
14643 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_rcqe()
14645 dma_buf = lpfc_sli_hbqbuf_get(&phba->hbqs[0].hbq_buffer_list); in lpfc_sli4_sp_handle_rcqe()
14647 hrq->RQ_no_buf_found++; in lpfc_sli4_sp_handle_rcqe()
14648 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_rcqe()
14651 hrq->RQ_rcv_buf++; in lpfc_sli4_sp_handle_rcqe()
14652 hrq->RQ_buf_posted--; in lpfc_sli4_sp_handle_rcqe()
14653 memcpy(&dma_buf->cq_event.cqe.rcqe_cmpl, rcqe, sizeof(*rcqe)); in lpfc_sli4_sp_handle_rcqe()
14655 fc_hdr = (struct fc_frame_header *)dma_buf->hbuf.virt; in lpfc_sli4_sp_handle_rcqe()
14657 if (fc_hdr->fh_r_ctl == FC_RCTL_MDS_DIAGS || in lpfc_sli4_sp_handle_rcqe()
14658 fc_hdr->fh_r_ctl == FC_RCTL_DD_UNSOL_DATA) { in lpfc_sli4_sp_handle_rcqe()
14659 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_rcqe()
14661 if (!(phba->pport->load_flag & FC_UNLOADING)) in lpfc_sli4_sp_handle_rcqe()
14662 lpfc_sli4_handle_mds_loopback(phba->pport, in lpfc_sli4_sp_handle_rcqe()
14665 lpfc_in_buf_free(phba, &dma_buf->dbuf); in lpfc_sli4_sp_handle_rcqe()
14670 list_add_tail(&dma_buf->cq_event.list, in lpfc_sli4_sp_handle_rcqe()
14671 &phba->sli4_hba.sp_queue_event); in lpfc_sli4_sp_handle_rcqe()
14673 phba->hba_flag |= HBA_SP_QUEUE_EVT; in lpfc_sli4_sp_handle_rcqe()
14674 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_rcqe()
14678 if (phba->nvmet_support) { in lpfc_sli4_sp_handle_rcqe()
14679 tgtp = phba->targetport->private; in lpfc_sli4_sp_handle_rcqe()
14683 status, hrq->RQ_buf_posted, in lpfc_sli4_sp_handle_rcqe()
14684 hrq->RQ_no_posted_buf, in lpfc_sli4_sp_handle_rcqe()
14685 atomic_read(&tgtp->rcv_fcp_cmd_in), in lpfc_sli4_sp_handle_rcqe()
14686 atomic_read(&tgtp->rcv_fcp_cmd_out), in lpfc_sli4_sp_handle_rcqe()
14687 atomic_read(&tgtp->xmt_fcp_release)); in lpfc_sli4_sp_handle_rcqe()
14692 hrq->RQ_no_posted_buf++; in lpfc_sli4_sp_handle_rcqe()
14694 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_rcqe()
14695 phba->hba_flag |= HBA_POST_RECEIVE_BUFFER; in lpfc_sli4_sp_handle_rcqe()
14696 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_rcqe()
14703 status, rcqe->word0, rcqe->word1, in lpfc_sli4_sp_handle_rcqe()
14704 rcqe->word2, rcqe->word3); in lpfc_sli4_sp_handle_rcqe()
14711 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_rcqe()
14713 dma_buf = lpfc_sli_hbqbuf_get(&phba->hbqs[0].hbq_buffer_list); in lpfc_sli4_sp_handle_rcqe()
14715 hrq->RQ_no_buf_found++; in lpfc_sli4_sp_handle_rcqe()
14716 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_rcqe()
14719 hrq->RQ_rcv_buf++; in lpfc_sli4_sp_handle_rcqe()
14720 hrq->RQ_buf_posted--; in lpfc_sli4_sp_handle_rcqe()
14721 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_sp_handle_rcqe()
14722 lpfc_in_buf_free(phba, &dma_buf->dbuf); in lpfc_sli4_sp_handle_rcqe()
14726 "2565 Unexpected RQE Status x%x, w0-3 x%08x " in lpfc_sli4_sp_handle_rcqe()
14728 status, rcqe->word0, rcqe->word1, in lpfc_sli4_sp_handle_rcqe()
14729 rcqe->word2, rcqe->word3); in lpfc_sli4_sp_handle_rcqe()
14737 * lpfc_sli4_sp_handle_cqe - Process a slow path completion queue entry
14742 * This routine process a slow-path work-queue or receive queue completion queue
14761 phba->last_completion_time = jiffies; in lpfc_sli4_sp_handle_cqe()
14772 phba->last_completion_time = jiffies; in lpfc_sli4_sp_handle_cqe()
14779 phba->last_completion_time = jiffies; in lpfc_sli4_sp_handle_cqe()
14793 * lpfc_sli4_sp_handle_eqe - Process a slow-path event queue entry
14795 * @eqe: Pointer to fast-path event queue entry.
14796 * @speq: Pointer to slow-path event queue.
14798 * This routine process a event queue entry from the slow-path event queue.
14817 list_for_each_entry(childq, &speq->child_list, list) { in lpfc_sli4_sp_handle_eqe()
14818 if (childq->queue_id == cqid) { in lpfc_sli4_sp_handle_eqe()
14824 if (phba->sli.sli_flag & LPFC_SLI_ACTIVE) in lpfc_sli4_sp_handle_eqe()
14826 "0365 Slow-path CQ identifier " in lpfc_sli4_sp_handle_eqe()
14832 cq->assoc_qp = speq; in lpfc_sli4_sp_handle_eqe()
14835 ret = queue_work(phba->wq, &cq->spwork); in lpfc_sli4_sp_handle_eqe()
14837 ret = queue_work_on(cq->chann, phba->wq, &cq->spwork); in lpfc_sli4_sp_handle_eqe()
14843 cqid, cq->queue_id, raw_smp_processor_id()); in lpfc_sli4_sp_handle_eqe()
14847 * __lpfc_sli4_process_cq - Process elements of a CQ
14876 /* default - no reschedule */ in __lpfc_sli4_process_cq()
14879 if (cmpxchg(&cq->queue_claimed, 0, 1) != 0) in __lpfc_sli4_process_cq()
14883 cq->q_flag = 0; in __lpfc_sli4_process_cq()
14890 if (!(++count % cq->max_proc_limit)) in __lpfc_sli4_process_cq()
14893 if (!(count % cq->notify_interval)) { in __lpfc_sli4_process_cq()
14894 phba->sli4_hba.sli4_write_cq_db(phba, cq, consumed, in __lpfc_sli4_process_cq()
14897 cq->assoc_qp->q_flag |= HBA_EQ_DELAY_CHK; in __lpfc_sli4_process_cq()
14901 cq->q_flag |= HBA_NVMET_CQ_NOTIFY; in __lpfc_sli4_process_cq()
14905 if (count >= phba->cfg_cq_poll_threshold) { in __lpfc_sli4_process_cq()
14911 if (count > cq->CQ_max_cqe) in __lpfc_sli4_process_cq()
14912 cq->CQ_max_cqe = count; in __lpfc_sli4_process_cq()
14914 cq->assoc_qp->EQ_cqe_cnt += count; in __lpfc_sli4_process_cq()
14920 "qid=%d\n", cq->queue_id); in __lpfc_sli4_process_cq()
14922 xchg(&cq->queue_claimed, 0); in __lpfc_sli4_process_cq()
14925 phba->sli4_hba.sli4_write_cq_db(phba, cq, consumed, in __lpfc_sli4_process_cq()
14932 * __lpfc_sli4_sp_process_cq - Process a slow-path event queue entry
14941 * the second is the delay parameter. If non-zero, rather than rearming
14949 struct lpfc_hba *phba = cq->phba; in __lpfc_sli4_sp_process_cq()
14955 switch (cq->type) { in __lpfc_sli4_sp_process_cq()
14962 if (cq->subtype == LPFC_IO) in __lpfc_sli4_sp_process_cq()
14974 cq->type); in __lpfc_sli4_sp_process_cq()
14980 ret = queue_delayed_work(phba->wq, &cq->sched_spwork, in __lpfc_sli4_sp_process_cq()
14983 ret = queue_delayed_work_on(cq->chann, phba->wq, in __lpfc_sli4_sp_process_cq()
14984 &cq->sched_spwork, delay); in __lpfc_sli4_sp_process_cq()
14989 cq->queue_id, cq->chann); in __lpfc_sli4_sp_process_cq()
14998 * lpfc_sli4_sp_process_cq - slow-path work handler when started by
15002 * translates from the work handler and calls the slow-path handler.
15013 * lpfc_sli4_dly_sp_process_cq - slow-path work handler when started by timer
15016 * translates from the work handler and calls the slow-path handler.
15028 * lpfc_sli4_fp_handle_fcp_wcqe - Process fast-path work queue completion entry
15031 * @wcqe: Pointer to work-queue completion queue entry.
15033 * This routine process a fast-path work queue completion entry from fast-path
15040 struct lpfc_sli_ring *pring = cq->pring; in lpfc_sli4_fp_handle_fcp_wcqe()
15051 ((wcqe->parameter & IOERR_PARAM_MASK) == in lpfc_sli4_fp_handle_fcp_wcqe()
15053 phba->lpfc_rampdown_queue_depth(phba); in lpfc_sli4_fp_handle_fcp_wcqe()
15060 wcqe->word0, wcqe->total_data_placed, in lpfc_sli4_fp_handle_fcp_wcqe()
15061 wcqe->parameter, wcqe->word3); in lpfc_sli4_fp_handle_fcp_wcqe()
15065 spin_lock_irqsave(&pring->ring_lock, iflags); in lpfc_sli4_fp_handle_fcp_wcqe()
15066 pring->stats.iocb_event++; in lpfc_sli4_fp_handle_fcp_wcqe()
15069 spin_unlock_irqrestore(&pring->ring_lock, iflags); in lpfc_sli4_fp_handle_fcp_wcqe()
15078 cmdiocbq->isr_timestamp = cq->isr_timestamp; in lpfc_sli4_fp_handle_fcp_wcqe()
15081 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_fp_handle_fcp_wcqe()
15082 cmdiocbq->cmd_flag |= LPFC_EXCHANGE_BUSY; in lpfc_sli4_fp_handle_fcp_wcqe()
15083 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_fp_handle_fcp_wcqe()
15086 if (cmdiocbq->cmd_cmpl) { in lpfc_sli4_fp_handle_fcp_wcqe()
15088 if (!(cmdiocbq->cmd_flag & LPFC_IO_FCP) && in lpfc_sli4_fp_handle_fcp_wcqe()
15089 cmdiocbq->cmd_flag & LPFC_DRIVER_ABORTED) { in lpfc_sli4_fp_handle_fcp_wcqe()
15090 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_fp_handle_fcp_wcqe()
15091 cmdiocbq->cmd_flag &= ~LPFC_DRIVER_ABORTED; in lpfc_sli4_fp_handle_fcp_wcqe()
15092 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_fp_handle_fcp_wcqe()
15096 memcpy(&cmdiocbq->wcqe_cmpl, wcqe, in lpfc_sli4_fp_handle_fcp_wcqe()
15098 cmdiocbq->cmd_cmpl(phba, cmdiocbq, cmdiocbq); in lpfc_sli4_fp_handle_fcp_wcqe()
15108 * lpfc_sli4_fp_handle_rel_wcqe - Handle fast-path WQ entry consumed event
15111 * @wcqe: Pointer to work-queue completion queue entry.
15113 * This routine handles an fast-path WQ entry consumed event by invoking the
15114 * proper WQ release routine to the slow-path WQ.
15124 /* Check for fast-path FCP work queue release */ in lpfc_sli4_fp_handle_rel_wcqe()
15126 list_for_each_entry(childwq, &cq->child_list, list) { in lpfc_sli4_fp_handle_rel_wcqe()
15127 if (childwq->queue_id == hba_wqid) { in lpfc_sli4_fp_handle_rel_wcqe()
15130 if (childwq->q_flag & HBA_NVMET_WQFULL) in lpfc_sli4_fp_handle_rel_wcqe()
15139 "2580 Fast-path wqe consume event carries " in lpfc_sli4_fp_handle_rel_wcqe()
15140 "miss-matched qid: wcqe-qid=x%x\n", hba_wqid); in lpfc_sli4_fp_handle_rel_wcqe()
15144 * lpfc_sli4_nvmet_handle_rcqe - Process a receive-queue completion queue entry
15147 * @rcqe: Pointer to receive-queue completion queue entry.
15149 * This routine process a receive-queue completion queue entry.
15167 if ((phba->nvmet_support == 0) || in lpfc_sli4_nvmet_handle_rcqe()
15168 (phba->sli4_hba.nvmet_cqset == NULL)) in lpfc_sli4_nvmet_handle_rcqe()
15171 idx = cq->queue_id - phba->sli4_hba.nvmet_cqset[0]->queue_id; in lpfc_sli4_nvmet_handle_rcqe()
15172 hrq = phba->sli4_hba.nvmet_mrq_hdr[idx]; in lpfc_sli4_nvmet_handle_rcqe()
15173 drq = phba->sli4_hba.nvmet_mrq_data[idx]; in lpfc_sli4_nvmet_handle_rcqe()
15184 if ((phba->nvmet_support == 0) || in lpfc_sli4_nvmet_handle_rcqe()
15185 (rq_id != hrq->queue_id)) in lpfc_sli4_nvmet_handle_rcqe()
15195 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_nvmet_handle_rcqe()
15199 hrq->RQ_no_buf_found++; in lpfc_sli4_nvmet_handle_rcqe()
15200 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_nvmet_handle_rcqe()
15203 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_nvmet_handle_rcqe()
15204 hrq->RQ_rcv_buf++; in lpfc_sli4_nvmet_handle_rcqe()
15205 hrq->RQ_buf_posted--; in lpfc_sli4_nvmet_handle_rcqe()
15206 fc_hdr = (struct fc_frame_header *)dma_buf->hbuf.virt; in lpfc_sli4_nvmet_handle_rcqe()
15209 fctl = (fc_hdr->fh_f_ctl[0] << 16 | in lpfc_sli4_nvmet_handle_rcqe()
15210 fc_hdr->fh_f_ctl[1] << 8 | in lpfc_sli4_nvmet_handle_rcqe()
15211 fc_hdr->fh_f_ctl[2]); in lpfc_sli4_nvmet_handle_rcqe()
15215 (fc_hdr->fh_seq_cnt != 0)) /* 0 byte swapped is still 0 */ in lpfc_sli4_nvmet_handle_rcqe()
15218 if (fc_hdr->fh_type == FC_TYPE_FCP) { in lpfc_sli4_nvmet_handle_rcqe()
15219 dma_buf->bytes_recv = bf_get(lpfc_rcqe_length, rcqe); in lpfc_sli4_nvmet_handle_rcqe()
15221 phba, idx, dma_buf, cq->isr_timestamp, in lpfc_sli4_nvmet_handle_rcqe()
15222 cq->q_flag & HBA_NVMET_CQ_NOTIFY); in lpfc_sli4_nvmet_handle_rcqe()
15226 lpfc_rq_buf_free(phba, &dma_buf->hbuf); in lpfc_sli4_nvmet_handle_rcqe()
15229 if (phba->nvmet_support) { in lpfc_sli4_nvmet_handle_rcqe()
15230 tgtp = phba->targetport->private; in lpfc_sli4_nvmet_handle_rcqe()
15234 status, hrq->RQ_buf_posted, in lpfc_sli4_nvmet_handle_rcqe()
15235 hrq->RQ_no_posted_buf, in lpfc_sli4_nvmet_handle_rcqe()
15236 atomic_read(&tgtp->rcv_fcp_cmd_in), in lpfc_sli4_nvmet_handle_rcqe()
15237 atomic_read(&tgtp->rcv_fcp_cmd_out), in lpfc_sli4_nvmet_handle_rcqe()
15238 atomic_read(&tgtp->xmt_fcp_release)); in lpfc_sli4_nvmet_handle_rcqe()
15243 hrq->RQ_no_posted_buf++; in lpfc_sli4_nvmet_handle_rcqe()
15250 status, rcqe->word0, rcqe->word1, in lpfc_sli4_nvmet_handle_rcqe()
15251 rcqe->word2, rcqe->word3); in lpfc_sli4_nvmet_handle_rcqe()
15258 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_nvmet_handle_rcqe()
15262 hrq->RQ_no_buf_found++; in lpfc_sli4_nvmet_handle_rcqe()
15263 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_nvmet_handle_rcqe()
15266 hrq->RQ_rcv_buf++; in lpfc_sli4_nvmet_handle_rcqe()
15267 hrq->RQ_buf_posted--; in lpfc_sli4_nvmet_handle_rcqe()
15268 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_nvmet_handle_rcqe()
15269 lpfc_rq_buf_free(phba, &dma_buf->hbuf); in lpfc_sli4_nvmet_handle_rcqe()
15273 "2576 Unexpected RQE Status x%x, w0-3 x%08x " in lpfc_sli4_nvmet_handle_rcqe()
15275 status, rcqe->word0, rcqe->word1, in lpfc_sli4_nvmet_handle_rcqe()
15276 rcqe->word2, rcqe->word3); in lpfc_sli4_nvmet_handle_rcqe()
15284 * lpfc_sli4_fp_handle_cqe - Process fast-path work queue completion entry
15287 * @cqe: Pointer to fast-path completion queue entry.
15289 * This routine process a fast-path work queue completion entry from fast-path
15308 cq->CQ_wq++; in lpfc_sli4_fp_handle_cqe()
15310 phba->last_completion_time = jiffies; in lpfc_sli4_fp_handle_cqe()
15311 if (cq->subtype == LPFC_IO || cq->subtype == LPFC_NVME_LS) in lpfc_sli4_fp_handle_cqe()
15316 cq->CQ_release_wqe++; in lpfc_sli4_fp_handle_cqe()
15322 cq->CQ_xri_aborted++; in lpfc_sli4_fp_handle_cqe()
15324 phba->last_completion_time = jiffies; in lpfc_sli4_fp_handle_cqe()
15330 phba->last_completion_time = jiffies; in lpfc_sli4_fp_handle_cqe()
15331 if (cq->subtype == LPFC_NVMET) { in lpfc_sli4_fp_handle_cqe()
15346 * __lpfc_sli4_hba_process_cq - Process a fast-path event queue entry
15355 * the second is the delay parameter. If non-zero, rather than rearming
15363 struct lpfc_hba *phba = cq->phba; in __lpfc_sli4_hba_process_cq()
15374 ret = queue_delayed_work(phba->wq, &cq->sched_irqwork, in __lpfc_sli4_hba_process_cq()
15377 ret = queue_delayed_work_on(cq->chann, phba->wq, in __lpfc_sli4_hba_process_cq()
15378 &cq->sched_irqwork, delay); in __lpfc_sli4_hba_process_cq()
15383 cq->queue_id, cq->chann); in __lpfc_sli4_hba_process_cq()
15392 * lpfc_sli4_hba_process_cq - fast-path work handler when started by
15396 * translates from the work handler and calls the fast-path handler.
15407 * lpfc_sli4_hba_handle_eqe - Process a fast-path event queue entry
15410 * @eqe: Pointer to fast-path event queue entry.
15413 * This routine process a event queue entry from the fast-path event queue.
15425 uint32_t qidx = eq->hdwq; in lpfc_sli4_hba_handle_eqe()
15442 if (cqid <= phba->sli4_hba.cq_max) { in lpfc_sli4_hba_handle_eqe()
15443 cq = phba->sli4_hba.cq_lookup[cqid]; in lpfc_sli4_hba_handle_eqe()
15449 if (phba->cfg_nvmet_mrq && phba->sli4_hba.nvmet_cqset) { in lpfc_sli4_hba_handle_eqe()
15450 id = phba->sli4_hba.nvmet_cqset[0]->queue_id; in lpfc_sli4_hba_handle_eqe()
15451 if ((cqid >= id) && (cqid < (id + phba->cfg_nvmet_mrq))) { in lpfc_sli4_hba_handle_eqe()
15453 cq = phba->sli4_hba.nvmet_cqset[cqid - id]; in lpfc_sli4_hba_handle_eqe()
15458 if (phba->sli4_hba.nvmels_cq && in lpfc_sli4_hba_handle_eqe()
15459 (cqid == phba->sli4_hba.nvmels_cq->queue_id)) { in lpfc_sli4_hba_handle_eqe()
15461 cq = phba->sli4_hba.nvmels_cq; in lpfc_sli4_hba_handle_eqe()
15467 phba->sli4_hba.hdwq[qidx].hba_eq); in lpfc_sli4_hba_handle_eqe()
15472 if (unlikely(cqid != cq->queue_id)) { in lpfc_sli4_hba_handle_eqe()
15474 "0368 Miss-matched fast-path completion " in lpfc_sli4_hba_handle_eqe()
15476 cqid, cq->queue_id); in lpfc_sli4_hba_handle_eqe()
15482 if (phba->ktime_on) in lpfc_sli4_hba_handle_eqe()
15483 cq->isr_timestamp = ktime_get_ns(); in lpfc_sli4_hba_handle_eqe()
15485 cq->isr_timestamp = 0; in lpfc_sli4_hba_handle_eqe()
15495 ret = queue_work(phba->wq, &cq->irqwork); in lpfc_sli4_hba_handle_eqe()
15497 ret = queue_work_on(cq->chann, phba->wq, &cq->irqwork); in lpfc_sli4_hba_handle_eqe()
15502 cqid, cq->queue_id, in lpfc_sli4_hba_handle_eqe()
15509 * lpfc_sli4_dly_hba_process_cq - fast-path work handler when started by timer
15512 * translates from the work handler and calls the fast-path handler.
15524 * lpfc_sli4_hba_intr_handler - HBA interrupt handler to SLI-4 device
15529 * service routine when device with SLI-4 interface spec is enabled with
15530 * MSI-X multi-message interrupt mode and there is a fast-path FCP IOCB
15532 * MSI or Pin-IRQ interrupt mode, this function is called as part of the
15533 * device-level interrupt handler. When the PCI slot is in error recovery
15535 * process the interrupt. The SCSI FCP fast-path ring event are handled in
15538 * the FCP EQ to FCP CQ are one-to-one map such that the FCP EQ index is
15563 phba = hba_eq_hdl->phba; in lpfc_sli4_hba_intr_handler()
15564 hba_eqidx = hba_eq_hdl->idx; in lpfc_sli4_hba_intr_handler()
15568 if (unlikely(!phba->sli4_hba.hdwq)) in lpfc_sli4_hba_intr_handler()
15572 fpeq = phba->sli4_hba.hba_eq_hdl[hba_eqidx].eq; in lpfc_sli4_hba_intr_handler()
15579 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli4_hba_intr_handler()
15580 if (phba->link_state < LPFC_LINK_DOWN) in lpfc_sli4_hba_intr_handler()
15583 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli4_hba_intr_handler()
15587 switch (fpeq->poll_mode) { in lpfc_sli4_hba_intr_handler()
15590 if (phba->cmf_active_mode == LPFC_CFG_OFF) in lpfc_sli4_hba_intr_handler()
15595 eqi = this_cpu_ptr(phba->sli4_hba.eq_info); in lpfc_sli4_hba_intr_handler()
15596 eqi->icnt++; in lpfc_sli4_hba_intr_handler()
15598 fpeq->last_cpu = raw_smp_processor_id(); in lpfc_sli4_hba_intr_handler()
15600 if (eqi->icnt > LPFC_EQD_ISR_TRIGGER && in lpfc_sli4_hba_intr_handler()
15601 fpeq->q_flag & HBA_EQ_DELAY_CHK && in lpfc_sli4_hba_intr_handler()
15602 phba->cfg_auto_imax && in lpfc_sli4_hba_intr_handler()
15603 fpeq->q_mode != LPFC_MAX_AUTO_EQ_DELAY && in lpfc_sli4_hba_intr_handler()
15604 phba->sli.sli_flag & LPFC_SLI_USE_EQDR) in lpfc_sli4_hba_intr_handler()
15613 fpeq->EQ_no_entry++; in lpfc_sli4_hba_intr_handler()
15614 if (phba->intr_type == MSIX) in lpfc_sli4_hba_intr_handler()
15615 /* MSI-X treated interrupt served as no EQ share INT */ in lpfc_sli4_hba_intr_handler()
15617 "0358 MSI-X interrupt with no EQE\n"); in lpfc_sli4_hba_intr_handler()
15619 /* Non MSI-X treated on interrupt as EQ share INT */ in lpfc_sli4_hba_intr_handler()
15628 * lpfc_sli4_intr_handler - Device-level interrupt handler for SLI-4 device
15632 * This function is the device-level interrupt handler to device with SLI-4
15633 * interface spec, called from the PCI layer when either MSI or Pin-IRQ
15635 * driver attention. This function invokes the slow-path interrupt attention
15636 * handling function and fast-path interrupt attention handling function in
15659 * Invoke fast-path host attention interrupt handling as appropriate. in lpfc_sli4_intr_handler()
15661 for (qidx = 0; qidx < phba->cfg_irq_chann; qidx++) { in lpfc_sli4_intr_handler()
15663 &phba->sli4_hba.hba_eq_hdl[qidx]); in lpfc_sli4_intr_handler()
15678 list_for_each_entry_rcu(eq, &phba->poll_list, _poll_list) in lpfc_sli4_poll_hbtimer()
15680 if (!list_empty(&phba->poll_list)) in lpfc_sli4_poll_hbtimer()
15681 mod_timer(&phba->cpuhp_poll_timer, in lpfc_sli4_poll_hbtimer()
15689 struct lpfc_hba *phba = eq->phba; in lpfc_sli4_add_to_poll_list()
15692 if (list_empty(&phba->poll_list)) in lpfc_sli4_add_to_poll_list()
15693 mod_timer(&phba->cpuhp_poll_timer, in lpfc_sli4_add_to_poll_list()
15696 list_add_rcu(&eq->_poll_list, &phba->poll_list); in lpfc_sli4_add_to_poll_list()
15702 struct lpfc_hba *phba = eq->phba; in lpfc_sli4_remove_from_poll_list()
15705 * by RE-ARMING the eq's ASAP in lpfc_sli4_remove_from_poll_list()
15707 list_del_rcu(&eq->_poll_list); in lpfc_sli4_remove_from_poll_list()
15710 if (list_empty(&phba->poll_list)) in lpfc_sli4_remove_from_poll_list()
15711 del_timer_sync(&phba->cpuhp_poll_timer); in lpfc_sli4_remove_from_poll_list()
15718 list_for_each_entry_safe(eq, next, &phba->poll_list, _poll_list) in lpfc_sli4_cleanup_poll_list()
15719 list_del(&eq->_poll_list); in lpfc_sli4_cleanup_poll_list()
15721 INIT_LIST_HEAD(&phba->poll_list); in lpfc_sli4_cleanup_poll_list()
15728 if (mode == eq->mode) in __lpfc_sli4_switch_eqmode()
15736 * scheduler for a high priority process. Yes, the inte- in __lpfc_sli4_switch_eqmode()
15741 WRITE_ONCE(eq->mode, mode); in __lpfc_sli4_switch_eqmode()
15750 * deal with it. This is just a draining phase for int- in __lpfc_sli4_switch_eqmode()
15768 struct lpfc_hba *phba = eq->phba; in lpfc_sli4_stop_polling()
15775 * receives a completion. But since eq's are in disa- in lpfc_sli4_stop_polling()
15779 phba->sli4_hba.sli4_write_eq_db(phba, eq, 0, LPFC_QUEUE_REARM); in lpfc_sli4_stop_polling()
15783 * lpfc_sli4_queue_free - free a queue structure and associated memory
15798 if (!list_empty(&queue->wq_list)) in lpfc_sli4_queue_free()
15799 list_del(&queue->wq_list); in lpfc_sli4_queue_free()
15801 while (!list_empty(&queue->page_list)) { in lpfc_sli4_queue_free()
15802 list_remove_head(&queue->page_list, dmabuf, struct lpfc_dmabuf, in lpfc_sli4_queue_free()
15804 dma_free_coherent(&queue->phba->pcidev->dev, queue->page_size, in lpfc_sli4_queue_free()
15805 dmabuf->virt, dmabuf->phys); in lpfc_sli4_queue_free()
15808 if (queue->rqbp) { in lpfc_sli4_queue_free()
15809 lpfc_free_rq_buffer(queue->phba, queue); in lpfc_sli4_queue_free()
15810 kfree(queue->rqbp); in lpfc_sli4_queue_free()
15813 if (!list_empty(&queue->cpu_list)) in lpfc_sli4_queue_free()
15814 list_del(&queue->cpu_list); in lpfc_sli4_queue_free()
15821 * lpfc_sli4_queue_alloc - Allocate and initialize a queue structure
15838 uint32_t hw_page_size = phba->sli4_hba.pc_sli4_params.if_page_sz; in lpfc_sli4_queue_alloc()
15841 if (!phba->sli4_hba.pc_sli4_params.supported) in lpfc_sli4_queue_alloc()
15847 if (pgcnt > phba->sli4_hba.pc_sli4_params.wqpcnt) in lpfc_sli4_queue_alloc()
15848 pgcnt = phba->sli4_hba.pc_sli4_params.wqpcnt; in lpfc_sli4_queue_alloc()
15855 INIT_LIST_HEAD(&queue->list); in lpfc_sli4_queue_alloc()
15856 INIT_LIST_HEAD(&queue->_poll_list); in lpfc_sli4_queue_alloc()
15857 INIT_LIST_HEAD(&queue->wq_list); in lpfc_sli4_queue_alloc()
15858 INIT_LIST_HEAD(&queue->wqfull_list); in lpfc_sli4_queue_alloc()
15859 INIT_LIST_HEAD(&queue->page_list); in lpfc_sli4_queue_alloc()
15860 INIT_LIST_HEAD(&queue->child_list); in lpfc_sli4_queue_alloc()
15861 INIT_LIST_HEAD(&queue->cpu_list); in lpfc_sli4_queue_alloc()
15866 queue->page_count = pgcnt; in lpfc_sli4_queue_alloc()
15867 queue->q_pgs = (void **)&queue[1]; in lpfc_sli4_queue_alloc()
15868 queue->entry_cnt_per_pg = hw_page_size / entry_size; in lpfc_sli4_queue_alloc()
15869 queue->entry_size = entry_size; in lpfc_sli4_queue_alloc()
15870 queue->entry_count = entry_count; in lpfc_sli4_queue_alloc()
15871 queue->page_size = hw_page_size; in lpfc_sli4_queue_alloc()
15872 queue->phba = phba; in lpfc_sli4_queue_alloc()
15874 for (x = 0; x < queue->page_count; x++) { in lpfc_sli4_queue_alloc()
15876 dev_to_node(&phba->pcidev->dev)); in lpfc_sli4_queue_alloc()
15879 dmabuf->virt = dma_alloc_coherent(&phba->pcidev->dev, in lpfc_sli4_queue_alloc()
15880 hw_page_size, &dmabuf->phys, in lpfc_sli4_queue_alloc()
15882 if (!dmabuf->virt) { in lpfc_sli4_queue_alloc()
15886 dmabuf->buffer_tag = x; in lpfc_sli4_queue_alloc()
15887 list_add_tail(&dmabuf->list, &queue->page_list); in lpfc_sli4_queue_alloc()
15889 queue->q_pgs[x] = dmabuf->virt; in lpfc_sli4_queue_alloc()
15891 INIT_WORK(&queue->irqwork, lpfc_sli4_hba_process_cq); in lpfc_sli4_queue_alloc()
15892 INIT_WORK(&queue->spwork, lpfc_sli4_sp_process_cq); in lpfc_sli4_queue_alloc()
15893 INIT_DELAYED_WORK(&queue->sched_irqwork, lpfc_sli4_dly_hba_process_cq); in lpfc_sli4_queue_alloc()
15894 INIT_DELAYED_WORK(&queue->sched_spwork, lpfc_sli4_dly_sp_process_cq); in lpfc_sli4_queue_alloc()
15905 * lpfc_dual_chute_pci_bar_map - Map pci base address register to host memory
15916 if (!phba->pcidev) in lpfc_dual_chute_pci_bar_map()
15921 return phba->pci_bar0_memmap_p; in lpfc_dual_chute_pci_bar_map()
15923 return phba->pci_bar2_memmap_p; in lpfc_dual_chute_pci_bar_map()
15925 return phba->pci_bar4_memmap_p; in lpfc_dual_chute_pci_bar_map()
15933 * lpfc_modify_hba_eq_delay - Modify Delay Multiplier on EQs
15941 * or by mailbox command. The mailbox command allows several EQs to be
15944 * The @phba struct is used to send a mailbox command to HBA. The @startq
15948 * mailbox commands to finish before returning.
15951 * enough memory this function will return -ENOMEM. If a mailbox command
15952 * fails this function will return -ENXIO. Note: on ENXIO, some EQs may
15968 if (startq >= phba->cfg_irq_chann) in lpfc_modify_hba_eq_delay()
15979 if (phba->sli.sli_flag & LPFC_SLI_USE_EQDR) { in lpfc_modify_hba_eq_delay()
15980 for (qidx = startq; qidx < phba->cfg_irq_chann; qidx++) { in lpfc_modify_hba_eq_delay()
15981 eq = phba->sli4_hba.hba_eq_hdl[qidx].eq; in lpfc_modify_hba_eq_delay()
15993 /* Otherwise, set values by mailbox cmd */ in lpfc_modify_hba_eq_delay()
15995 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_modify_hba_eq_delay()
15998 "6428 Failed allocating mailbox cmd buffer." in lpfc_modify_hba_eq_delay()
16002 length = (sizeof(struct lpfc_mbx_modify_eq_delay) - in lpfc_modify_hba_eq_delay()
16007 eq_delay = &mbox->u.mqe.un.eq_delay; in lpfc_modify_hba_eq_delay()
16012 dmult--; in lpfc_modify_hba_eq_delay()
16016 for (qidx = startq; qidx < phba->cfg_irq_chann; qidx++) { in lpfc_modify_hba_eq_delay()
16017 eq = phba->sli4_hba.hba_eq_hdl[qidx].eq; in lpfc_modify_hba_eq_delay()
16020 eq->q_mode = usdelay; in lpfc_modify_hba_eq_delay()
16021 eq_delay->u.request.eq[cnt].eq_id = eq->queue_id; in lpfc_modify_hba_eq_delay()
16022 eq_delay->u.request.eq[cnt].phase = 0; in lpfc_modify_hba_eq_delay()
16023 eq_delay->u.request.eq[cnt].delay_multi = dmult; in lpfc_modify_hba_eq_delay()
16028 eq_delay->u.request.num_eq = cnt; in lpfc_modify_hba_eq_delay()
16030 mbox->vport = phba->pport; in lpfc_modify_hba_eq_delay()
16031 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_modify_hba_eq_delay()
16032 mbox->ctx_ndlp = NULL; in lpfc_modify_hba_eq_delay()
16034 shdr = (union lpfc_sli4_cfg_shdr *) &eq_delay->header.cfg_shdr; in lpfc_modify_hba_eq_delay()
16035 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_modify_hba_eq_delay()
16036 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_modify_hba_eq_delay()
16039 "2512 MODIFY_EQ_DELAY mailbox failed with " in lpfc_modify_hba_eq_delay()
16043 mempool_free(mbox, phba->mbox_mem_pool); in lpfc_modify_hba_eq_delay()
16048 * lpfc_eq_create - Create an Event Queue on the HBA
16054 * described by @phba by sending an EQ_CREATE mailbox command to the HBA.
16056 * The @phba struct is used to send mailbox command to HBA. The @eq struct
16059 * function will send the EQ_CREATE mailbox command to the HBA to setup the
16060 * event queue. This function is asynchronous and will wait for the mailbox
16064 * memory this function will return -ENOMEM. If the queue create mailbox command
16065 * fails this function will return -ENXIO.
16077 uint32_t hw_page_size = phba->sli4_hba.pc_sli4_params.if_page_sz; in lpfc_eq_create()
16081 return -ENODEV; in lpfc_eq_create()
16082 if (!phba->sli4_hba.pc_sli4_params.supported) in lpfc_eq_create()
16085 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_eq_create()
16087 return -ENOMEM; in lpfc_eq_create()
16088 length = (sizeof(struct lpfc_mbx_eq_create) - in lpfc_eq_create()
16093 eq_create = &mbox->u.mqe.un.eq_create; in lpfc_eq_create()
16094 shdr = (union lpfc_sli4_cfg_shdr *) &eq_create->header.cfg_shdr; in lpfc_eq_create()
16095 bf_set(lpfc_mbx_eq_create_num_pages, &eq_create->u.request, in lpfc_eq_create()
16096 eq->page_count); in lpfc_eq_create()
16097 bf_set(lpfc_eq_context_size, &eq_create->u.request.context, in lpfc_eq_create()
16099 bf_set(lpfc_eq_context_valid, &eq_create->u.request.context, 1); in lpfc_eq_create()
16102 if (phba->sli4_hba.pc_sli4_params.eqav) { in lpfc_eq_create()
16103 bf_set(lpfc_mbox_hdr_version, &shdr->request, in lpfc_eq_create()
16105 bf_set(lpfc_eq_context_autovalid, &eq_create->u.request.context, in lpfc_eq_create()
16106 phba->sli4_hba.pc_sli4_params.eqav); in lpfc_eq_create()
16111 bf_set(lpfc_eq_context_delay_multi, &eq_create->u.request.context, in lpfc_eq_create()
16113 switch (eq->entry_count) { in lpfc_eq_create()
16117 eq->entry_count); in lpfc_eq_create()
16118 if (eq->entry_count < 256) { in lpfc_eq_create()
16119 status = -EINVAL; in lpfc_eq_create()
16124 bf_set(lpfc_eq_context_count, &eq_create->u.request.context, in lpfc_eq_create()
16128 bf_set(lpfc_eq_context_count, &eq_create->u.request.context, in lpfc_eq_create()
16132 bf_set(lpfc_eq_context_count, &eq_create->u.request.context, in lpfc_eq_create()
16136 bf_set(lpfc_eq_context_count, &eq_create->u.request.context, in lpfc_eq_create()
16140 bf_set(lpfc_eq_context_count, &eq_create->u.request.context, in lpfc_eq_create()
16144 list_for_each_entry(dmabuf, &eq->page_list, list) { in lpfc_eq_create()
16145 memset(dmabuf->virt, 0, hw_page_size); in lpfc_eq_create()
16146 eq_create->u.request.page[dmabuf->buffer_tag].addr_lo = in lpfc_eq_create()
16147 putPaddrLow(dmabuf->phys); in lpfc_eq_create()
16148 eq_create->u.request.page[dmabuf->buffer_tag].addr_hi = in lpfc_eq_create()
16149 putPaddrHigh(dmabuf->phys); in lpfc_eq_create()
16151 mbox->vport = phba->pport; in lpfc_eq_create()
16152 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_eq_create()
16153 mbox->ctx_buf = NULL; in lpfc_eq_create()
16154 mbox->ctx_ndlp = NULL; in lpfc_eq_create()
16156 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_eq_create()
16157 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_eq_create()
16160 "2500 EQ_CREATE mailbox failed with " in lpfc_eq_create()
16163 status = -ENXIO; in lpfc_eq_create()
16165 eq->type = LPFC_EQ; in lpfc_eq_create()
16166 eq->subtype = LPFC_NONE; in lpfc_eq_create()
16167 eq->queue_id = bf_get(lpfc_mbx_eq_create_q_id, &eq_create->u.response); in lpfc_eq_create()
16168 if (eq->queue_id == 0xFFFF) in lpfc_eq_create()
16169 status = -ENXIO; in lpfc_eq_create()
16170 eq->host_index = 0; in lpfc_eq_create()
16171 eq->notify_interval = LPFC_EQ_NOTIFY_INTRVL; in lpfc_eq_create()
16172 eq->max_proc_limit = LPFC_EQ_MAX_PROC_LIMIT; in lpfc_eq_create()
16174 mempool_free(mbox, phba->mbox_mem_pool); in lpfc_eq_create()
16179 * lpfc_sli4_hba_intr_handler_th - SLI4 HBA threaded interrupt handler
16187 * IRQ_HANDLED - interrupt is handled
16188 * IRQ_NONE - otherwise
16201 phba = hba_eq_hdl->phba; in lpfc_sli4_hba_intr_handler_th()
16202 hba_eqidx = hba_eq_hdl->idx; in lpfc_sli4_hba_intr_handler_th()
16206 if (unlikely(!phba->sli4_hba.hdwq)) in lpfc_sli4_hba_intr_handler_th()
16210 fpeq = phba->sli4_hba.hba_eq_hdl[hba_eqidx].eq; in lpfc_sli4_hba_intr_handler_th()
16214 eqi = per_cpu_ptr(phba->sli4_hba.eq_info, raw_smp_processor_id()); in lpfc_sli4_hba_intr_handler_th()
16215 eqi->icnt++; in lpfc_sli4_hba_intr_handler_th()
16217 fpeq->last_cpu = raw_smp_processor_id(); in lpfc_sli4_hba_intr_handler_th()
16219 if (eqi->icnt > LPFC_EQD_ISR_TRIGGER && in lpfc_sli4_hba_intr_handler_th()
16220 fpeq->q_flag & HBA_EQ_DELAY_CHK && in lpfc_sli4_hba_intr_handler_th()
16221 phba->cfg_auto_imax && in lpfc_sli4_hba_intr_handler_th()
16222 fpeq->q_mode != LPFC_MAX_AUTO_EQ_DELAY && in lpfc_sli4_hba_intr_handler_th()
16223 phba->sli.sli_flag & LPFC_SLI_USE_EQDR) in lpfc_sli4_hba_intr_handler_th()
16231 fpeq->EQ_no_entry++; in lpfc_sli4_hba_intr_handler_th()
16232 if (phba->intr_type == MSIX) in lpfc_sli4_hba_intr_handler_th()
16233 /* MSI-X treated interrupt served as no EQ share INT */ in lpfc_sli4_hba_intr_handler_th()
16235 "3358 MSI-X interrupt with no EQE\n"); in lpfc_sli4_hba_intr_handler_th()
16237 /* Non MSI-X treated on interrupt as EQ share INT */ in lpfc_sli4_hba_intr_handler_th()
16244 * lpfc_cq_create - Create a Completion Queue on the HBA
16252 * described by @phba by sending a CQ_CREATE mailbox command to the HBA.
16254 * The @phba struct is used to send mailbox command to HBA. The @cq struct
16258 * function will send the CQ_CREATE mailbox command to the HBA to setup the
16259 * completion queue. This function is asynchronous and will wait for the mailbox
16263 * memory this function will return -ENOMEM. If the queue create mailbox command
16264 * fails this function will return -ENXIO.
16279 return -ENODEV; in lpfc_cq_create()
16281 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_cq_create()
16283 return -ENOMEM; in lpfc_cq_create()
16284 length = (sizeof(struct lpfc_mbx_cq_create) - in lpfc_cq_create()
16289 cq_create = &mbox->u.mqe.un.cq_create; in lpfc_cq_create()
16290 shdr = (union lpfc_sli4_cfg_shdr *) &cq_create->header.cfg_shdr; in lpfc_cq_create()
16291 bf_set(lpfc_mbx_cq_create_num_pages, &cq_create->u.request, in lpfc_cq_create()
16292 cq->page_count); in lpfc_cq_create()
16293 bf_set(lpfc_cq_context_event, &cq_create->u.request.context, 1); in lpfc_cq_create()
16294 bf_set(lpfc_cq_context_valid, &cq_create->u.request.context, 1); in lpfc_cq_create()
16295 bf_set(lpfc_mbox_hdr_version, &shdr->request, in lpfc_cq_create()
16296 phba->sli4_hba.pc_sli4_params.cqv); in lpfc_cq_create()
16297 if (phba->sli4_hba.pc_sli4_params.cqv == LPFC_Q_CREATE_VERSION_2) { in lpfc_cq_create()
16298 bf_set(lpfc_mbx_cq_create_page_size, &cq_create->u.request, in lpfc_cq_create()
16299 (cq->page_size / SLI4_PAGE_SIZE)); in lpfc_cq_create()
16300 bf_set(lpfc_cq_eq_id_2, &cq_create->u.request.context, in lpfc_cq_create()
16301 eq->queue_id); in lpfc_cq_create()
16302 bf_set(lpfc_cq_context_autovalid, &cq_create->u.request.context, in lpfc_cq_create()
16303 phba->sli4_hba.pc_sli4_params.cqav); in lpfc_cq_create()
16305 bf_set(lpfc_cq_eq_id, &cq_create->u.request.context, in lpfc_cq_create()
16306 eq->queue_id); in lpfc_cq_create()
16308 switch (cq->entry_count) { in lpfc_cq_create()
16311 if (phba->sli4_hba.pc_sli4_params.cqv == in lpfc_cq_create()
16313 cq_create->u.request.context.lpfc_cq_context_count = in lpfc_cq_create()
16314 cq->entry_count; in lpfc_cq_create()
16316 &cq_create->u.request.context, in lpfc_cq_create()
16325 cq->entry_count, cq->entry_size, in lpfc_cq_create()
16326 cq->page_count); in lpfc_cq_create()
16327 if (cq->entry_count < 256) { in lpfc_cq_create()
16328 status = -EINVAL; in lpfc_cq_create()
16333 bf_set(lpfc_cq_context_count, &cq_create->u.request.context, in lpfc_cq_create()
16337 bf_set(lpfc_cq_context_count, &cq_create->u.request.context, in lpfc_cq_create()
16341 bf_set(lpfc_cq_context_count, &cq_create->u.request.context, in lpfc_cq_create()
16345 list_for_each_entry(dmabuf, &cq->page_list, list) { in lpfc_cq_create()
16346 memset(dmabuf->virt, 0, cq->page_size); in lpfc_cq_create()
16347 cq_create->u.request.page[dmabuf->buffer_tag].addr_lo = in lpfc_cq_create()
16348 putPaddrLow(dmabuf->phys); in lpfc_cq_create()
16349 cq_create->u.request.page[dmabuf->buffer_tag].addr_hi = in lpfc_cq_create()
16350 putPaddrHigh(dmabuf->phys); in lpfc_cq_create()
16354 /* The IOCTL status is embedded in the mailbox subheader. */ in lpfc_cq_create()
16355 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_cq_create()
16356 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_cq_create()
16359 "2501 CQ_CREATE mailbox failed with " in lpfc_cq_create()
16362 status = -ENXIO; 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 if (cq->queue_id == 0xFFFF) { in lpfc_cq_create()
16367 status = -ENXIO; in lpfc_cq_create()
16371 list_add_tail(&cq->list, &eq->child_list); in lpfc_cq_create()
16373 cq->type = type; in lpfc_cq_create()
16374 cq->subtype = subtype; in lpfc_cq_create()
16375 cq->queue_id = bf_get(lpfc_mbx_cq_create_q_id, &cq_create->u.response); in lpfc_cq_create()
16376 cq->assoc_qid = eq->queue_id; in lpfc_cq_create()
16377 cq->assoc_qp = eq; in lpfc_cq_create()
16378 cq->host_index = 0; in lpfc_cq_create()
16379 cq->notify_interval = LPFC_CQ_NOTIFY_INTRVL; in lpfc_cq_create()
16380 cq->max_proc_limit = min(phba->cfg_cq_max_proc_limit, cq->entry_count); in lpfc_cq_create()
16382 if (cq->queue_id > phba->sli4_hba.cq_max) in lpfc_cq_create()
16383 phba->sli4_hba.cq_max = cq->queue_id; in lpfc_cq_create()
16385 mempool_free(mbox, phba->mbox_mem_pool); in lpfc_cq_create()
16390 * lpfc_cq_create_set - Create a set of Completion Queues on the HBA for MRQ
16399 * described by @phba by sending a CREATE_CQ_SET mailbox command to the HBA.
16401 * The @phba struct is used to send mailbox command to HBA. The @cq struct
16405 * function will send the CREATE_CQ_SET mailbox command to the HBA to setup the
16406 * completion queue. This function is asynchronous and will wait for the mailbox
16410 * memory this function will return -ENOMEM. If the queue create mailbox command
16411 * fails this function will return -ENXIO.
16427 uint32_t hw_page_size = phba->sli4_hba.pc_sli4_params.if_page_sz; in lpfc_cq_create_set()
16430 numcq = phba->cfg_nvmet_mrq; in lpfc_cq_create_set()
16432 return -ENODEV; in lpfc_cq_create_set()
16434 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_cq_create_set()
16436 return -ENOMEM; in lpfc_cq_create_set()
16439 length += ((numcq * cqp[0]->page_count) * in lpfc_cq_create_set()
16449 status = -ENOMEM; in lpfc_cq_create_set()
16452 cq_set = mbox->sge_array->addr[0]; in lpfc_cq_create_set()
16453 shdr = (union lpfc_sli4_cfg_shdr *)&cq_set->cfg_shdr; in lpfc_cq_create_set()
16454 bf_set(lpfc_mbox_hdr_version, &shdr->request, 0); in lpfc_cq_create_set()
16460 status = -ENOMEM; in lpfc_cq_create_set()
16463 if (!phba->sli4_hba.pc_sli4_params.supported) in lpfc_cq_create_set()
16464 hw_page_size = cq->page_size; in lpfc_cq_create_set()
16469 &cq_set->u.request, in lpfc_cq_create_set()
16472 &cq_set->u.request, cq->page_count); in lpfc_cq_create_set()
16474 &cq_set->u.request, 1); in lpfc_cq_create_set()
16476 &cq_set->u.request, 1); in lpfc_cq_create_set()
16478 &cq_set->u.request, 0); in lpfc_cq_create_set()
16480 &cq_set->u.request, numcq); in lpfc_cq_create_set()
16482 &cq_set->u.request, in lpfc_cq_create_set()
16483 phba->sli4_hba.pc_sli4_params.cqav); in lpfc_cq_create_set()
16484 switch (cq->entry_count) { in lpfc_cq_create_set()
16487 if (phba->sli4_hba.pc_sli4_params.cqv == in lpfc_cq_create_set()
16490 &cq_set->u.request, in lpfc_cq_create_set()
16491 cq->entry_count); in lpfc_cq_create_set()
16493 &cq_set->u.request, in lpfc_cq_create_set()
16501 cq->entry_count); in lpfc_cq_create_set()
16502 if (cq->entry_count < 256) { in lpfc_cq_create_set()
16503 status = -EINVAL; in lpfc_cq_create_set()
16509 &cq_set->u.request, LPFC_CQ_CNT_256); in lpfc_cq_create_set()
16513 &cq_set->u.request, LPFC_CQ_CNT_512); in lpfc_cq_create_set()
16517 &cq_set->u.request, LPFC_CQ_CNT_1024); in lpfc_cq_create_set()
16521 &cq_set->u.request, eq->queue_id); in lpfc_cq_create_set()
16525 &cq_set->u.request, eq->queue_id); in lpfc_cq_create_set()
16529 &cq_set->u.request, eq->queue_id); in lpfc_cq_create_set()
16533 &cq_set->u.request, eq->queue_id); in lpfc_cq_create_set()
16537 &cq_set->u.request, eq->queue_id); in lpfc_cq_create_set()
16541 &cq_set->u.request, eq->queue_id); in lpfc_cq_create_set()
16545 &cq_set->u.request, eq->queue_id); in lpfc_cq_create_set()
16549 &cq_set->u.request, eq->queue_id); in lpfc_cq_create_set()
16553 &cq_set->u.request, eq->queue_id); in lpfc_cq_create_set()
16557 &cq_set->u.request, eq->queue_id); in lpfc_cq_create_set()
16561 &cq_set->u.request, eq->queue_id); in lpfc_cq_create_set()
16565 &cq_set->u.request, eq->queue_id); in lpfc_cq_create_set()
16569 &cq_set->u.request, eq->queue_id); in lpfc_cq_create_set()
16573 &cq_set->u.request, eq->queue_id); in lpfc_cq_create_set()
16577 &cq_set->u.request, eq->queue_id); in lpfc_cq_create_set()
16581 &cq_set->u.request, eq->queue_id); in lpfc_cq_create_set()
16586 list_add_tail(&cq->list, &eq->child_list); in lpfc_cq_create_set()
16588 cq->type = type; in lpfc_cq_create_set()
16589 cq->subtype = subtype; in lpfc_cq_create_set()
16590 cq->assoc_qid = eq->queue_id; in lpfc_cq_create_set()
16591 cq->assoc_qp = eq; in lpfc_cq_create_set()
16592 cq->host_index = 0; in lpfc_cq_create_set()
16593 cq->notify_interval = LPFC_CQ_NOTIFY_INTRVL; in lpfc_cq_create_set()
16594 cq->max_proc_limit = min(phba->cfg_cq_max_proc_limit, in lpfc_cq_create_set()
16595 cq->entry_count); in lpfc_cq_create_set()
16596 cq->chann = idx; in lpfc_cq_create_set()
16599 list_for_each_entry(dmabuf, &cq->page_list, list) { in lpfc_cq_create_set()
16600 memset(dmabuf->virt, 0, hw_page_size); in lpfc_cq_create_set()
16601 cnt = page_idx + dmabuf->buffer_tag; in lpfc_cq_create_set()
16602 cq_set->u.request.page[cnt].addr_lo = in lpfc_cq_create_set()
16603 putPaddrLow(dmabuf->phys); in lpfc_cq_create_set()
16604 cq_set->u.request.page[cnt].addr_hi = in lpfc_cq_create_set()
16605 putPaddrHigh(dmabuf->phys); in lpfc_cq_create_set()
16613 /* The IOCTL status is embedded in the mailbox subheader. */ in lpfc_cq_create_set()
16614 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_cq_create_set()
16615 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_cq_create_set()
16618 "3119 CQ_CREATE_SET mailbox failed with " in lpfc_cq_create_set()
16621 status = -ENXIO; in lpfc_cq_create_set()
16624 rc = bf_get(lpfc_mbx_cq_create_set_base_id, &cq_set->u.response); in lpfc_cq_create_set()
16626 status = -ENXIO; in lpfc_cq_create_set()
16632 cq->queue_id = rc + idx; in lpfc_cq_create_set()
16633 if (cq->queue_id > phba->sli4_hba.cq_max) in lpfc_cq_create_set()
16634 phba->sli4_hba.cq_max = cq->queue_id; in lpfc_cq_create_set()
16643 * lpfc_mq_create_fb_init - Send MCC_CREATE without async events registration
16645 * @mq: The queue structure to use to create the mailbox queue.
16664 length = (sizeof(struct lpfc_mbx_mq_create) - in lpfc_mq_create_fb_init()
16669 mq_create = &mbox->u.mqe.un.mq_create; in lpfc_mq_create_fb_init()
16670 bf_set(lpfc_mbx_mq_create_num_pages, &mq_create->u.request, in lpfc_mq_create_fb_init()
16671 mq->page_count); in lpfc_mq_create_fb_init()
16672 bf_set(lpfc_mq_context_cq_id, &mq_create->u.request.context, in lpfc_mq_create_fb_init()
16673 cq->queue_id); in lpfc_mq_create_fb_init()
16674 bf_set(lpfc_mq_context_valid, &mq_create->u.request.context, 1); in lpfc_mq_create_fb_init()
16675 switch (mq->entry_count) { in lpfc_mq_create_fb_init()
16677 bf_set(lpfc_mq_context_ring_size, &mq_create->u.request.context, in lpfc_mq_create_fb_init()
16681 bf_set(lpfc_mq_context_ring_size, &mq_create->u.request.context, in lpfc_mq_create_fb_init()
16685 bf_set(lpfc_mq_context_ring_size, &mq_create->u.request.context, in lpfc_mq_create_fb_init()
16689 bf_set(lpfc_mq_context_ring_size, &mq_create->u.request.context, in lpfc_mq_create_fb_init()
16693 list_for_each_entry(dmabuf, &mq->page_list, list) { in lpfc_mq_create_fb_init()
16694 mq_create->u.request.page[dmabuf->buffer_tag].addr_lo = in lpfc_mq_create_fb_init()
16695 putPaddrLow(dmabuf->phys); in lpfc_mq_create_fb_init()
16696 mq_create->u.request.page[dmabuf->buffer_tag].addr_hi = in lpfc_mq_create_fb_init()
16697 putPaddrHigh(dmabuf->phys); in lpfc_mq_create_fb_init()
16702 * lpfc_mq_create - Create a mailbox Queue on the HBA
16704 * @mq: The queue structure to use to create the mailbox queue.
16708 * This function creates a mailbox queue, as detailed in @mq, on a port,
16709 * described by @phba by sending a MQ_CREATE mailbox command to the HBA.
16711 * The @phba struct is used to send mailbox command to HBA. The @cq struct
16714 * function will send the MQ_CREATE mailbox command to the HBA to setup the
16715 * mailbox queue. This function is asynchronous and will wait for the mailbox
16719 * memory this function will return -ENOMEM. If the queue create mailbox command
16720 * fails this function will return -ENXIO.
16733 uint32_t hw_page_size = phba->sli4_hba.pc_sli4_params.if_page_sz; in lpfc_mq_create()
16737 return -ENODEV; in lpfc_mq_create()
16738 if (!phba->sli4_hba.pc_sli4_params.supported) in lpfc_mq_create()
16741 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_mq_create()
16743 return -ENOMEM; in lpfc_mq_create()
16744 length = (sizeof(struct lpfc_mbx_mq_create_ext) - in lpfc_mq_create()
16750 mq_create_ext = &mbox->u.mqe.un.mq_create_ext; in lpfc_mq_create()
16751 shdr = (union lpfc_sli4_cfg_shdr *) &mq_create_ext->header.cfg_shdr; in lpfc_mq_create()
16753 &mq_create_ext->u.request, mq->page_count); in lpfc_mq_create()
16755 &mq_create_ext->u.request, 1); in lpfc_mq_create()
16757 &mq_create_ext->u.request, 1); in lpfc_mq_create()
16759 &mq_create_ext->u.request, 1); in lpfc_mq_create()
16761 &mq_create_ext->u.request, 1); in lpfc_mq_create()
16763 &mq_create_ext->u.request, 1); in lpfc_mq_create()
16764 bf_set(lpfc_mq_context_valid, &mq_create_ext->u.request.context, 1); in lpfc_mq_create()
16765 bf_set(lpfc_mbox_hdr_version, &shdr->request, in lpfc_mq_create()
16766 phba->sli4_hba.pc_sli4_params.mqv); in lpfc_mq_create()
16767 if (phba->sli4_hba.pc_sli4_params.mqv == LPFC_Q_CREATE_VERSION_1) in lpfc_mq_create()
16768 bf_set(lpfc_mbx_mq_create_ext_cq_id, &mq_create_ext->u.request, in lpfc_mq_create()
16769 cq->queue_id); in lpfc_mq_create()
16771 bf_set(lpfc_mq_context_cq_id, &mq_create_ext->u.request.context, in lpfc_mq_create()
16772 cq->queue_id); in lpfc_mq_create()
16773 switch (mq->entry_count) { in lpfc_mq_create()
16777 mq->entry_count); in lpfc_mq_create()
16778 if (mq->entry_count < 16) { in lpfc_mq_create()
16779 status = -EINVAL; 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()
16795 &mq_create_ext->u.request.context, in lpfc_mq_create()
16800 &mq_create_ext->u.request.context, in lpfc_mq_create()
16804 list_for_each_entry(dmabuf, &mq->page_list, list) { in lpfc_mq_create()
16805 memset(dmabuf->virt, 0, hw_page_size); in lpfc_mq_create()
16806 mq_create_ext->u.request.page[dmabuf->buffer_tag].addr_lo = in lpfc_mq_create()
16807 putPaddrLow(dmabuf->phys); in lpfc_mq_create()
16808 mq_create_ext->u.request.page[dmabuf->buffer_tag].addr_hi = in lpfc_mq_create()
16809 putPaddrHigh(dmabuf->phys); in lpfc_mq_create()
16812 mq->queue_id = bf_get(lpfc_mbx_mq_create_q_id, in lpfc_mq_create()
16813 &mq_create_ext->u.response); in lpfc_mq_create()
16820 mq_create = &mbox->u.mqe.un.mq_create; in lpfc_mq_create()
16822 shdr = (union lpfc_sli4_cfg_shdr *) &mq_create->header.cfg_shdr; in lpfc_mq_create()
16823 mq->queue_id = bf_get(lpfc_mbx_mq_create_q_id, in lpfc_mq_create()
16824 &mq_create->u.response); in lpfc_mq_create()
16827 /* The IOCTL status is embedded in the mailbox subheader. */ in lpfc_mq_create()
16828 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_mq_create()
16829 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_mq_create()
16832 "2502 MQ_CREATE mailbox failed with " in lpfc_mq_create()
16835 status = -ENXIO; in lpfc_mq_create()
16838 if (mq->queue_id == 0xFFFF) { in lpfc_mq_create()
16839 status = -ENXIO; in lpfc_mq_create()
16842 mq->type = LPFC_MQ; in lpfc_mq_create()
16843 mq->assoc_qid = cq->queue_id; in lpfc_mq_create()
16844 mq->subtype = subtype; in lpfc_mq_create()
16845 mq->host_index = 0; in lpfc_mq_create()
16846 mq->hba_index = 0; in lpfc_mq_create()
16849 list_add_tail(&mq->list, &cq->child_list); in lpfc_mq_create()
16851 mempool_free(mbox, phba->mbox_mem_pool); in lpfc_mq_create()
16856 * lpfc_wq_create - Create a Work Queue on the HBA
16863 * by @phba by sending a WQ_CREATE mailbox command to the HBA.
16865 * The @phba struct is used to send mailbox command to HBA. The @wq struct
16869 * function will send the WQ_CREATE mailbox command to the HBA to setup the
16870 * work queue. This function is asynchronous and will wait for the mailbox
16874 * memory this function will return -ENOMEM. If the queue create mailbox command
16875 * fails this function will return -ENXIO.
16887 uint32_t hw_page_size = phba->sli4_hba.pc_sli4_params.if_page_sz; in lpfc_wq_create()
16901 return -ENODEV; in lpfc_wq_create()
16902 if (!phba->sli4_hba.pc_sli4_params.supported) in lpfc_wq_create()
16903 hw_page_size = wq->page_size; in lpfc_wq_create()
16905 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_wq_create()
16907 return -ENOMEM; in lpfc_wq_create()
16908 length = (sizeof(struct lpfc_mbx_wq_create) - in lpfc_wq_create()
16913 wq_create = &mbox->u.mqe.un.wq_create; in lpfc_wq_create()
16914 shdr = (union lpfc_sli4_cfg_shdr *) &wq_create->header.cfg_shdr; in lpfc_wq_create()
16915 bf_set(lpfc_mbx_wq_create_num_pages, &wq_create->u.request, in lpfc_wq_create()
16916 wq->page_count); in lpfc_wq_create()
16917 bf_set(lpfc_mbx_wq_create_cq_id, &wq_create->u.request, in lpfc_wq_create()
16918 cq->queue_id); in lpfc_wq_create()
16921 bf_set(lpfc_mbox_hdr_version, &shdr->request, in lpfc_wq_create()
16922 phba->sli4_hba.pc_sli4_params.wqv); in lpfc_wq_create()
16924 if ((phba->sli4_hba.pc_sli4_params.wqsize & LPFC_WQ_SZ128_SUPPORT) || in lpfc_wq_create()
16925 (wq->page_size > SLI4_PAGE_SIZE)) in lpfc_wq_create()
16932 bf_set(lpfc_mbx_wq_create_wqe_count, &wq_create->u.request_1, in lpfc_wq_create()
16933 wq->entry_count); in lpfc_wq_create()
16934 bf_set(lpfc_mbox_hdr_version, &shdr->request, in lpfc_wq_create()
16937 switch (wq->entry_size) { in lpfc_wq_create()
16941 &wq_create->u.request_1, in lpfc_wq_create()
16946 &wq_create->u.request_1, in lpfc_wq_create()
16951 bf_set(lpfc_mbx_wq_create_dpp_req, &wq_create->u.request_1, 1); in lpfc_wq_create()
16953 &wq_create->u.request_1, in lpfc_wq_create()
16954 (wq->page_size / SLI4_PAGE_SIZE)); in lpfc_wq_create()
16955 page = wq_create->u.request_1.page; in lpfc_wq_create()
16958 page = wq_create->u.request.page; in lpfc_wq_create()
16962 list_for_each_entry(dmabuf, &wq->page_list, list) { in lpfc_wq_create()
16963 memset(dmabuf->virt, 0, hw_page_size); in lpfc_wq_create()
16964 page[dmabuf->buffer_tag].addr_lo = putPaddrLow(dmabuf->phys); in lpfc_wq_create()
16965 page[dmabuf->buffer_tag].addr_hi = putPaddrHigh(dmabuf->phys); in lpfc_wq_create()
16968 if (phba->sli4_hba.fw_func_mode & LPFC_DUA_MODE) in lpfc_wq_create()
16969 bf_set(lpfc_mbx_wq_create_dua, &wq_create->u.request, 1); in lpfc_wq_create()
16972 /* The IOCTL status is embedded in the mailbox subheader. */ in lpfc_wq_create()
16973 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_wq_create()
16974 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_wq_create()
16977 "2503 WQ_CREATE mailbox failed with " in lpfc_wq_create()
16980 status = -ENXIO; in lpfc_wq_create()
16985 wq->queue_id = bf_get(lpfc_mbx_wq_create_q_id, in lpfc_wq_create()
16986 &wq_create->u.response); in lpfc_wq_create()
16988 wq->queue_id = bf_get(lpfc_mbx_wq_create_v1_q_id, in lpfc_wq_create()
16989 &wq_create->u.response_1); in lpfc_wq_create()
16991 if (wq->queue_id == 0xFFFF) { in lpfc_wq_create()
16992 status = -ENXIO; in lpfc_wq_create()
16996 wq->db_format = LPFC_DB_LIST_FORMAT; in lpfc_wq_create()
16998 if (phba->sli4_hba.fw_func_mode & LPFC_DUA_MODE) { in lpfc_wq_create()
16999 wq->db_format = bf_get(lpfc_mbx_wq_create_db_format, in lpfc_wq_create()
17000 &wq_create->u.response); in lpfc_wq_create()
17001 if ((wq->db_format != LPFC_DB_LIST_FORMAT) && in lpfc_wq_create()
17002 (wq->db_format != LPFC_DB_RING_FORMAT)) { in lpfc_wq_create()
17006 wq->queue_id, wq->db_format); in lpfc_wq_create()
17007 status = -EINVAL; in lpfc_wq_create()
17011 &wq_create->u.response); in lpfc_wq_create()
17018 wq->queue_id, pci_barset); in lpfc_wq_create()
17019 status = -ENOMEM; in lpfc_wq_create()
17022 db_offset = wq_create->u.response.doorbell_offset; in lpfc_wq_create()
17028 wq->queue_id, db_offset); in lpfc_wq_create()
17029 status = -EINVAL; in lpfc_wq_create()
17032 wq->db_regaddr = bar_memmap_p + db_offset; in lpfc_wq_create()
17035 "format:x%x\n", wq->queue_id, in lpfc_wq_create()
17036 pci_barset, db_offset, wq->db_format); in lpfc_wq_create()
17038 wq->db_regaddr = phba->sli4_hba.WQDBregaddr; in lpfc_wq_create()
17041 wq->dpp_enable = bf_get(lpfc_mbx_wq_create_dpp_rsp, in lpfc_wq_create()
17042 &wq_create->u.response_1); in lpfc_wq_create()
17043 if (wq->dpp_enable) { in lpfc_wq_create()
17045 &wq_create->u.response_1); in lpfc_wq_create()
17052 wq->queue_id, pci_barset); in lpfc_wq_create()
17053 status = -ENOMEM; in lpfc_wq_create()
17056 db_offset = wq_create->u.response_1.doorbell_offset; in lpfc_wq_create()
17057 wq->db_regaddr = bar_memmap_p + db_offset; in lpfc_wq_create()
17058 wq->dpp_id = bf_get(lpfc_mbx_wq_create_dpp_id, in lpfc_wq_create()
17059 &wq_create->u.response_1); in lpfc_wq_create()
17061 &wq_create->u.response_1); in lpfc_wq_create()
17068 wq->queue_id, dpp_barset); in lpfc_wq_create()
17069 status = -ENOMEM; in lpfc_wq_create()
17072 dpp_offset = wq_create->u.response_1.dpp_offset; in lpfc_wq_create()
17073 wq->dpp_regaddr = bar_memmap_p + dpp_offset; in lpfc_wq_create()
17078 wq->queue_id, pci_barset, db_offset, in lpfc_wq_create()
17079 wq->dpp_id, dpp_barset, dpp_offset); in lpfc_wq_create()
17083 pg_addr = (unsigned long)(wq->dpp_regaddr) & PAGE_MASK; in lpfc_wq_create()
17088 "Write on WQ[%d] - disable DPP\n", in lpfc_wq_create()
17089 wq->queue_id); in lpfc_wq_create()
17090 phba->cfg_enable_dpp = 0; in lpfc_wq_create()
17093 phba->cfg_enable_dpp = 0; in lpfc_wq_create()
17096 wq->db_regaddr = phba->sli4_hba.WQDBregaddr; in lpfc_wq_create()
17098 wq->pring = kzalloc(sizeof(struct lpfc_sli_ring), GFP_KERNEL); in lpfc_wq_create()
17099 if (wq->pring == NULL) { in lpfc_wq_create()
17100 status = -ENOMEM; in lpfc_wq_create()
17103 wq->type = LPFC_WQ; in lpfc_wq_create()
17104 wq->assoc_qid = cq->queue_id; in lpfc_wq_create()
17105 wq->subtype = subtype; in lpfc_wq_create()
17106 wq->host_index = 0; in lpfc_wq_create()
17107 wq->hba_index = 0; in lpfc_wq_create()
17108 wq->notify_interval = LPFC_WQ_NOTIFY_INTRVL; in lpfc_wq_create()
17111 list_add_tail(&wq->list, &cq->child_list); in lpfc_wq_create()
17113 mempool_free(mbox, phba->mbox_mem_pool); in lpfc_wq_create()
17118 * lpfc_rq_create - Create a Receive Queue on the HBA
17126 * @drq, on a port, described by @phba by sending a RQ_CREATE mailbox command
17129 * The @phba struct is used to send mailbox command to HBA. The @drq and @hrq
17133 * This function will send the RQ_CREATE mailbox command to the HBA to setup the
17135 * mailbox command to finish before continuing.
17138 * memory this function will return -ENOMEM. If the queue create mailbox command
17139 * fails this function will return -ENXIO.
17151 uint32_t hw_page_size = phba->sli4_hba.pc_sli4_params.if_page_sz; in lpfc_rq_create()
17158 return -ENODEV; in lpfc_rq_create()
17159 if (!phba->sli4_hba.pc_sli4_params.supported) in lpfc_rq_create()
17162 if (hrq->entry_count != drq->entry_count) in lpfc_rq_create()
17163 return -EINVAL; in lpfc_rq_create()
17164 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_rq_create()
17166 return -ENOMEM; in lpfc_rq_create()
17167 length = (sizeof(struct lpfc_mbx_rq_create) - in lpfc_rq_create()
17172 rq_create = &mbox->u.mqe.un.rq_create; in lpfc_rq_create()
17173 shdr = (union lpfc_sli4_cfg_shdr *) &rq_create->header.cfg_shdr; in lpfc_rq_create()
17174 bf_set(lpfc_mbox_hdr_version, &shdr->request, in lpfc_rq_create()
17175 phba->sli4_hba.pc_sli4_params.rqv); in lpfc_rq_create()
17176 if (phba->sli4_hba.pc_sli4_params.rqv == LPFC_Q_CREATE_VERSION_1) { in lpfc_rq_create()
17178 &rq_create->u.request.context, in lpfc_rq_create()
17179 hrq->entry_count); in lpfc_rq_create()
17180 rq_create->u.request.context.buffer_size = LPFC_HDR_BUF_SIZE; in lpfc_rq_create()
17182 &rq_create->u.request.context, in lpfc_rq_create()
17185 &rq_create->u.request.context, in lpfc_rq_create()
17188 switch (hrq->entry_count) { in lpfc_rq_create()
17192 hrq->entry_count); in lpfc_rq_create()
17193 if (hrq->entry_count < 512) { in lpfc_rq_create()
17194 status = -EINVAL; in lpfc_rq_create()
17200 &rq_create->u.request.context, in lpfc_rq_create()
17205 &rq_create->u.request.context, in lpfc_rq_create()
17210 &rq_create->u.request.context, in lpfc_rq_create()
17215 &rq_create->u.request.context, in lpfc_rq_create()
17219 bf_set(lpfc_rq_context_buf_size, &rq_create->u.request.context, in lpfc_rq_create()
17222 bf_set(lpfc_rq_context_cq_id, &rq_create->u.request.context, in lpfc_rq_create()
17223 cq->queue_id); in lpfc_rq_create()
17224 bf_set(lpfc_mbx_rq_create_num_pages, &rq_create->u.request, in lpfc_rq_create()
17225 hrq->page_count); in lpfc_rq_create()
17226 list_for_each_entry(dmabuf, &hrq->page_list, list) { in lpfc_rq_create()
17227 memset(dmabuf->virt, 0, hw_page_size); in lpfc_rq_create()
17228 rq_create->u.request.page[dmabuf->buffer_tag].addr_lo = in lpfc_rq_create()
17229 putPaddrLow(dmabuf->phys); in lpfc_rq_create()
17230 rq_create->u.request.page[dmabuf->buffer_tag].addr_hi = in lpfc_rq_create()
17231 putPaddrHigh(dmabuf->phys); in lpfc_rq_create()
17233 if (phba->sli4_hba.fw_func_mode & LPFC_DUA_MODE) in lpfc_rq_create()
17234 bf_set(lpfc_mbx_rq_create_dua, &rq_create->u.request, 1); in lpfc_rq_create()
17237 /* The IOCTL status is embedded in the mailbox subheader. */ in lpfc_rq_create()
17238 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_rq_create()
17239 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_rq_create()
17242 "2504 RQ_CREATE mailbox failed with " in lpfc_rq_create()
17245 status = -ENXIO; in lpfc_rq_create()
17248 hrq->queue_id = bf_get(lpfc_mbx_rq_create_q_id, &rq_create->u.response); in lpfc_rq_create()
17249 if (hrq->queue_id == 0xFFFF) { in lpfc_rq_create()
17250 status = -ENXIO; in lpfc_rq_create()
17254 if (phba->sli4_hba.fw_func_mode & LPFC_DUA_MODE) { in lpfc_rq_create()
17255 hrq->db_format = bf_get(lpfc_mbx_rq_create_db_format, in lpfc_rq_create()
17256 &rq_create->u.response); in lpfc_rq_create()
17257 if ((hrq->db_format != LPFC_DB_LIST_FORMAT) && in lpfc_rq_create()
17258 (hrq->db_format != LPFC_DB_RING_FORMAT)) { in lpfc_rq_create()
17261 "supported: x%x\n", hrq->queue_id, in lpfc_rq_create()
17262 hrq->db_format); in lpfc_rq_create()
17263 status = -EINVAL; in lpfc_rq_create()
17268 &rq_create->u.response); in lpfc_rq_create()
17273 "barset:x%x\n", hrq->queue_id, in lpfc_rq_create()
17275 status = -ENOMEM; in lpfc_rq_create()
17279 db_offset = rq_create->u.response.doorbell_offset; in lpfc_rq_create()
17284 "supported: x%x\n", hrq->queue_id, in lpfc_rq_create()
17286 status = -EINVAL; in lpfc_rq_create()
17289 hrq->db_regaddr = bar_memmap_p + db_offset; in lpfc_rq_create()
17292 "format:x%x\n", hrq->queue_id, pci_barset, in lpfc_rq_create()
17293 db_offset, hrq->db_format); in lpfc_rq_create()
17295 hrq->db_format = LPFC_DB_RING_FORMAT; in lpfc_rq_create()
17296 hrq->db_regaddr = phba->sli4_hba.RQDBregaddr; in lpfc_rq_create()
17298 hrq->type = LPFC_HRQ; in lpfc_rq_create()
17299 hrq->assoc_qid = cq->queue_id; in lpfc_rq_create()
17300 hrq->subtype = subtype; in lpfc_rq_create()
17301 hrq->host_index = 0; in lpfc_rq_create()
17302 hrq->hba_index = 0; in lpfc_rq_create()
17303 hrq->notify_interval = LPFC_RQ_NOTIFY_INTRVL; in lpfc_rq_create()
17309 bf_set(lpfc_mbox_hdr_version, &shdr->request, in lpfc_rq_create()
17310 phba->sli4_hba.pc_sli4_params.rqv); in lpfc_rq_create()
17311 if (phba->sli4_hba.pc_sli4_params.rqv == LPFC_Q_CREATE_VERSION_1) { in lpfc_rq_create()
17313 &rq_create->u.request.context, hrq->entry_count); in lpfc_rq_create()
17315 rq_create->u.request.context.buffer_size = in lpfc_rq_create()
17318 rq_create->u.request.context.buffer_size = in lpfc_rq_create()
17320 bf_set(lpfc_rq_context_rqe_size, &rq_create->u.request.context, in lpfc_rq_create()
17322 bf_set(lpfc_rq_context_page_size, &rq_create->u.request.context, in lpfc_rq_create()
17325 switch (drq->entry_count) { in lpfc_rq_create()
17329 drq->entry_count); in lpfc_rq_create()
17330 if (drq->entry_count < 512) { in lpfc_rq_create()
17331 status = -EINVAL; in lpfc_rq_create()
17337 &rq_create->u.request.context, in lpfc_rq_create()
17342 &rq_create->u.request.context, in lpfc_rq_create()
17347 &rq_create->u.request.context, in lpfc_rq_create()
17352 &rq_create->u.request.context, in lpfc_rq_create()
17358 &rq_create->u.request.context, in lpfc_rq_create()
17362 &rq_create->u.request.context, in lpfc_rq_create()
17365 bf_set(lpfc_rq_context_cq_id, &rq_create->u.request.context, in lpfc_rq_create()
17366 cq->queue_id); in lpfc_rq_create()
17367 bf_set(lpfc_mbx_rq_create_num_pages, &rq_create->u.request, in lpfc_rq_create()
17368 drq->page_count); in lpfc_rq_create()
17369 list_for_each_entry(dmabuf, &drq->page_list, list) { in lpfc_rq_create()
17370 rq_create->u.request.page[dmabuf->buffer_tag].addr_lo = in lpfc_rq_create()
17371 putPaddrLow(dmabuf->phys); in lpfc_rq_create()
17372 rq_create->u.request.page[dmabuf->buffer_tag].addr_hi = in lpfc_rq_create()
17373 putPaddrHigh(dmabuf->phys); in lpfc_rq_create()
17375 if (phba->sli4_hba.fw_func_mode & LPFC_DUA_MODE) in lpfc_rq_create()
17376 bf_set(lpfc_mbx_rq_create_dua, &rq_create->u.request, 1); in lpfc_rq_create()
17378 /* The IOCTL status is embedded in the mailbox subheader. */ in lpfc_rq_create()
17379 shdr = (union lpfc_sli4_cfg_shdr *) &rq_create->header.cfg_shdr; in lpfc_rq_create()
17380 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_rq_create()
17381 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_rq_create()
17383 status = -ENXIO; in lpfc_rq_create()
17386 drq->queue_id = bf_get(lpfc_mbx_rq_create_q_id, &rq_create->u.response); in lpfc_rq_create()
17387 if (drq->queue_id == 0xFFFF) { in lpfc_rq_create()
17388 status = -ENXIO; in lpfc_rq_create()
17391 drq->type = LPFC_DRQ; in lpfc_rq_create()
17392 drq->assoc_qid = cq->queue_id; in lpfc_rq_create()
17393 drq->subtype = subtype; in lpfc_rq_create()
17394 drq->host_index = 0; in lpfc_rq_create()
17395 drq->hba_index = 0; in lpfc_rq_create()
17396 drq->notify_interval = LPFC_RQ_NOTIFY_INTRVL; in lpfc_rq_create()
17399 list_add_tail(&hrq->list, &cq->child_list); in lpfc_rq_create()
17400 list_add_tail(&drq->list, &cq->child_list); in lpfc_rq_create()
17403 mempool_free(mbox, phba->mbox_mem_pool); in lpfc_rq_create()
17408 * lpfc_mrq_create - Create MRQ Receive Queues on the HBA
17416 * @drq, on a port, described by @phba by sending a RQ_CREATE mailbox command
17419 * The @phba struct is used to send mailbox command to HBA. The @drq and @hrq
17423 * This function will send the RQ_CREATE mailbox command to the HBA to setup the
17425 * mailbox command to finish before continuing.
17428 * memory this function will return -ENOMEM. If the queue create mailbox command
17429 * fails this function will return -ENXIO.
17444 uint32_t hw_page_size = phba->sli4_hba.pc_sli4_params.if_page_sz; in lpfc_mrq_create()
17446 numrq = phba->cfg_nvmet_mrq; in lpfc_mrq_create()
17449 return -ENODEV; in lpfc_mrq_create()
17450 if (!phba->sli4_hba.pc_sli4_params.supported) in lpfc_mrq_create()
17453 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_mrq_create()
17455 return -ENOMEM; in lpfc_mrq_create()
17458 length += ((2 * numrq * hrqp[0]->page_count) * in lpfc_mrq_create()
17469 status = -ENOMEM; in lpfc_mrq_create()
17475 rq_create = mbox->sge_array->addr[0]; in lpfc_mrq_create()
17476 shdr = (union lpfc_sli4_cfg_shdr *)&rq_create->cfg_shdr; in lpfc_mrq_create()
17478 bf_set(lpfc_mbox_hdr_version, &shdr->request, LPFC_Q_CREATE_VERSION_2); in lpfc_mrq_create()
17488 status = -ENODEV; in lpfc_mrq_create()
17492 if (hrq->entry_count != drq->entry_count) { in lpfc_mrq_create()
17493 status = -EINVAL; in lpfc_mrq_create()
17499 &rq_create->u.request, in lpfc_mrq_create()
17500 hrq->page_count); in lpfc_mrq_create()
17502 &rq_create->u.request, (numrq * 2)); in lpfc_mrq_create()
17503 bf_set(lpfc_mbx_rq_create_dnb, &rq_create->u.request, in lpfc_mrq_create()
17506 &rq_create->u.request.context, in lpfc_mrq_create()
17507 cq->queue_id); in lpfc_mrq_create()
17509 &rq_create->u.request.context, in lpfc_mrq_create()
17512 &rq_create->u.request.context, in lpfc_mrq_create()
17515 &rq_create->u.request.context, in lpfc_mrq_create()
17516 hrq->entry_count); in lpfc_mrq_create()
17518 &rq_create->u.request.context, in lpfc_mrq_create()
17521 &rq_create->u.request.context, in lpfc_mrq_create()
17525 list_for_each_entry(dmabuf, &hrq->page_list, list) { in lpfc_mrq_create()
17526 memset(dmabuf->virt, 0, hw_page_size); in lpfc_mrq_create()
17527 cnt = page_idx + dmabuf->buffer_tag; in lpfc_mrq_create()
17528 rq_create->u.request.page[cnt].addr_lo = in lpfc_mrq_create()
17529 putPaddrLow(dmabuf->phys); in lpfc_mrq_create()
17530 rq_create->u.request.page[cnt].addr_hi = in lpfc_mrq_create()
17531 putPaddrHigh(dmabuf->phys); in lpfc_mrq_create()
17537 list_for_each_entry(dmabuf, &drq->page_list, list) { in lpfc_mrq_create()
17538 memset(dmabuf->virt, 0, hw_page_size); in lpfc_mrq_create()
17539 cnt = page_idx + dmabuf->buffer_tag; in lpfc_mrq_create()
17540 rq_create->u.request.page[cnt].addr_lo = in lpfc_mrq_create()
17541 putPaddrLow(dmabuf->phys); in lpfc_mrq_create()
17542 rq_create->u.request.page[cnt].addr_hi = in lpfc_mrq_create()
17543 putPaddrHigh(dmabuf->phys); in lpfc_mrq_create()
17548 hrq->db_format = LPFC_DB_RING_FORMAT; in lpfc_mrq_create()
17549 hrq->db_regaddr = phba->sli4_hba.RQDBregaddr; in lpfc_mrq_create()
17550 hrq->type = LPFC_HRQ; in lpfc_mrq_create()
17551 hrq->assoc_qid = cq->queue_id; in lpfc_mrq_create()
17552 hrq->subtype = subtype; in lpfc_mrq_create()
17553 hrq->host_index = 0; in lpfc_mrq_create()
17554 hrq->hba_index = 0; in lpfc_mrq_create()
17555 hrq->notify_interval = LPFC_RQ_NOTIFY_INTRVL; in lpfc_mrq_create()
17557 drq->db_format = LPFC_DB_RING_FORMAT; in lpfc_mrq_create()
17558 drq->db_regaddr = phba->sli4_hba.RQDBregaddr; in lpfc_mrq_create()
17559 drq->type = LPFC_DRQ; in lpfc_mrq_create()
17560 drq->assoc_qid = cq->queue_id; in lpfc_mrq_create()
17561 drq->subtype = subtype; in lpfc_mrq_create()
17562 drq->host_index = 0; in lpfc_mrq_create()
17563 drq->hba_index = 0; in lpfc_mrq_create()
17564 drq->notify_interval = LPFC_RQ_NOTIFY_INTRVL; in lpfc_mrq_create()
17566 list_add_tail(&hrq->list, &cq->child_list); in lpfc_mrq_create()
17567 list_add_tail(&drq->list, &cq->child_list); in lpfc_mrq_create()
17571 /* The IOCTL status is embedded in the mailbox subheader. */ in lpfc_mrq_create()
17572 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_mrq_create()
17573 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_mrq_create()
17576 "3120 RQ_CREATE mailbox failed with " in lpfc_mrq_create()
17579 status = -ENXIO; in lpfc_mrq_create()
17582 rc = bf_get(lpfc_mbx_rq_create_q_id, &rq_create->u.response); in lpfc_mrq_create()
17584 status = -ENXIO; in lpfc_mrq_create()
17591 hrq->queue_id = rc + (2 * idx); in lpfc_mrq_create()
17593 drq->queue_id = rc + (2 * idx) + 1; in lpfc_mrq_create()
17602 * lpfc_eq_destroy - Destroy an event Queue on the HBA
17606 * This function destroys a queue, as detailed in @eq by sending an mailbox
17611 * On success this function will return a zero. If the queue destroy mailbox
17612 * command fails this function will return -ENXIO.
17624 return -ENODEV; in lpfc_eq_destroy()
17626 mbox = mempool_alloc(eq->phba->mbox_mem_pool, GFP_KERNEL); in lpfc_eq_destroy()
17628 return -ENOMEM; in lpfc_eq_destroy()
17629 length = (sizeof(struct lpfc_mbx_eq_destroy) - in lpfc_eq_destroy()
17634 bf_set(lpfc_mbx_eq_destroy_q_id, &mbox->u.mqe.un.eq_destroy.u.request, in lpfc_eq_destroy()
17635 eq->queue_id); in lpfc_eq_destroy()
17636 mbox->vport = eq->phba->pport; in lpfc_eq_destroy()
17637 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_eq_destroy()
17639 rc = lpfc_sli_issue_mbox(eq->phba, mbox, MBX_POLL); in lpfc_eq_destroy()
17640 /* The IOCTL status is embedded in the mailbox subheader. */ in lpfc_eq_destroy()
17642 &mbox->u.mqe.un.eq_destroy.header.cfg_shdr; in lpfc_eq_destroy()
17643 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_eq_destroy()
17644 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_eq_destroy()
17647 "2505 EQ_DESTROY mailbox failed with " in lpfc_eq_destroy()
17650 status = -ENXIO; in lpfc_eq_destroy()
17654 list_del_init(&eq->list); in lpfc_eq_destroy()
17655 mempool_free(mbox, eq->phba->mbox_mem_pool); in lpfc_eq_destroy()
17660 * lpfc_cq_destroy - Destroy a Completion Queue on the HBA
17664 * This function destroys a queue, as detailed in @cq by sending an mailbox
17669 * On success this function will return a zero. If the queue destroy mailbox
17670 * command fails this function will return -ENXIO.
17682 return -ENODEV; in lpfc_cq_destroy()
17683 mbox = mempool_alloc(cq->phba->mbox_mem_pool, GFP_KERNEL); in lpfc_cq_destroy()
17685 return -ENOMEM; in lpfc_cq_destroy()
17686 length = (sizeof(struct lpfc_mbx_cq_destroy) - in lpfc_cq_destroy()
17691 bf_set(lpfc_mbx_cq_destroy_q_id, &mbox->u.mqe.un.cq_destroy.u.request, in lpfc_cq_destroy()
17692 cq->queue_id); in lpfc_cq_destroy()
17693 mbox->vport = cq->phba->pport; in lpfc_cq_destroy()
17694 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_cq_destroy()
17695 rc = lpfc_sli_issue_mbox(cq->phba, mbox, MBX_POLL); in lpfc_cq_destroy()
17696 /* The IOCTL status is embedded in the mailbox subheader. */ in lpfc_cq_destroy()
17698 &mbox->u.mqe.un.wq_create.header.cfg_shdr; in lpfc_cq_destroy()
17699 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_cq_destroy()
17700 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_cq_destroy()
17703 "2506 CQ_DESTROY mailbox failed with " in lpfc_cq_destroy()
17706 status = -ENXIO; in lpfc_cq_destroy()
17709 list_del_init(&cq->list); in lpfc_cq_destroy()
17710 mempool_free(mbox, cq->phba->mbox_mem_pool); in lpfc_cq_destroy()
17715 * lpfc_mq_destroy - Destroy a Mailbox Queue on the HBA
17719 * This function destroys a queue, as detailed in @mq by sending an mailbox
17724 * On success this function will return a zero. If the queue destroy mailbox
17725 * command fails this function will return -ENXIO.
17737 return -ENODEV; in lpfc_mq_destroy()
17738 mbox = mempool_alloc(mq->phba->mbox_mem_pool, GFP_KERNEL); in lpfc_mq_destroy()
17740 return -ENOMEM; in lpfc_mq_destroy()
17741 length = (sizeof(struct lpfc_mbx_mq_destroy) - in lpfc_mq_destroy()
17746 bf_set(lpfc_mbx_mq_destroy_q_id, &mbox->u.mqe.un.mq_destroy.u.request, in lpfc_mq_destroy()
17747 mq->queue_id); in lpfc_mq_destroy()
17748 mbox->vport = mq->phba->pport; in lpfc_mq_destroy()
17749 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_mq_destroy()
17750 rc = lpfc_sli_issue_mbox(mq->phba, mbox, MBX_POLL); in lpfc_mq_destroy()
17751 /* The IOCTL status is embedded in the mailbox subheader. */ in lpfc_mq_destroy()
17753 &mbox->u.mqe.un.mq_destroy.header.cfg_shdr; in lpfc_mq_destroy()
17754 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_mq_destroy()
17755 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_mq_destroy()
17758 "2507 MQ_DESTROY mailbox failed with " in lpfc_mq_destroy()
17761 status = -ENXIO; in lpfc_mq_destroy()
17764 list_del_init(&mq->list); in lpfc_mq_destroy()
17765 mempool_free(mbox, mq->phba->mbox_mem_pool); in lpfc_mq_destroy()
17770 * lpfc_wq_destroy - Destroy a Work Queue on the HBA
17774 * This function destroys a queue, as detailed in @wq by sending an mailbox
17779 * On success this function will return a zero. If the queue destroy mailbox
17780 * command fails this function will return -ENXIO.
17792 return -ENODEV; in lpfc_wq_destroy()
17793 mbox = mempool_alloc(wq->phba->mbox_mem_pool, GFP_KERNEL); in lpfc_wq_destroy()
17795 return -ENOMEM; in lpfc_wq_destroy()
17796 length = (sizeof(struct lpfc_mbx_wq_destroy) - in lpfc_wq_destroy()
17801 bf_set(lpfc_mbx_wq_destroy_q_id, &mbox->u.mqe.un.wq_destroy.u.request, in lpfc_wq_destroy()
17802 wq->queue_id); in lpfc_wq_destroy()
17803 mbox->vport = wq->phba->pport; in lpfc_wq_destroy()
17804 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_wq_destroy()
17805 rc = lpfc_sli_issue_mbox(wq->phba, mbox, MBX_POLL); in lpfc_wq_destroy()
17807 &mbox->u.mqe.un.wq_destroy.header.cfg_shdr; in lpfc_wq_destroy()
17808 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_wq_destroy()
17809 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_wq_destroy()
17812 "2508 WQ_DESTROY mailbox failed with " in lpfc_wq_destroy()
17815 status = -ENXIO; in lpfc_wq_destroy()
17818 list_del_init(&wq->list); in lpfc_wq_destroy()
17819 kfree(wq->pring); in lpfc_wq_destroy()
17820 wq->pring = NULL; in lpfc_wq_destroy()
17821 mempool_free(mbox, wq->phba->mbox_mem_pool); in lpfc_wq_destroy()
17826 * lpfc_rq_destroy - Destroy a Receive Queue on the HBA
17831 * This function destroys a queue, as detailed in @rq by sending an mailbox
17836 * On success this function will return a zero. If the queue destroy mailbox
17837 * command fails this function will return -ENXIO.
17850 return -ENODEV; in lpfc_rq_destroy()
17851 mbox = mempool_alloc(hrq->phba->mbox_mem_pool, GFP_KERNEL); in lpfc_rq_destroy()
17853 return -ENOMEM; in lpfc_rq_destroy()
17854 length = (sizeof(struct lpfc_mbx_rq_destroy) - in lpfc_rq_destroy()
17859 bf_set(lpfc_mbx_rq_destroy_q_id, &mbox->u.mqe.un.rq_destroy.u.request, in lpfc_rq_destroy()
17860 hrq->queue_id); in lpfc_rq_destroy()
17861 mbox->vport = hrq->phba->pport; in lpfc_rq_destroy()
17862 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_rq_destroy()
17863 rc = lpfc_sli_issue_mbox(hrq->phba, mbox, MBX_POLL); in lpfc_rq_destroy()
17864 /* The IOCTL status is embedded in the mailbox subheader. */ in lpfc_rq_destroy()
17866 &mbox->u.mqe.un.rq_destroy.header.cfg_shdr; in lpfc_rq_destroy()
17867 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_rq_destroy()
17868 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_rq_destroy()
17871 "2509 RQ_DESTROY mailbox failed with " in lpfc_rq_destroy()
17874 mempool_free(mbox, hrq->phba->mbox_mem_pool); in lpfc_rq_destroy()
17875 return -ENXIO; in lpfc_rq_destroy()
17877 bf_set(lpfc_mbx_rq_destroy_q_id, &mbox->u.mqe.un.rq_destroy.u.request, in lpfc_rq_destroy()
17878 drq->queue_id); in lpfc_rq_destroy()
17879 rc = lpfc_sli_issue_mbox(drq->phba, mbox, MBX_POLL); in lpfc_rq_destroy()
17881 &mbox->u.mqe.un.rq_destroy.header.cfg_shdr; in lpfc_rq_destroy()
17882 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_rq_destroy()
17883 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_rq_destroy()
17886 "2510 RQ_DESTROY mailbox failed with " in lpfc_rq_destroy()
17889 status = -ENXIO; in lpfc_rq_destroy()
17891 list_del_init(&hrq->list); in lpfc_rq_destroy()
17892 list_del_init(&drq->list); in lpfc_rq_destroy()
17893 mempool_free(mbox, hrq->phba->mbox_mem_pool); in lpfc_rq_destroy()
17898 * lpfc_sli4_post_sgl - Post scatter gather list for an XRI to HBA
17916 * 0 - Success
17917 * -ENXIO, -ENOMEM - Failure
17935 return -EINVAL; in lpfc_sli4_post_sgl()
17938 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_post_sgl()
17940 return -ENOMEM; in lpfc_sli4_post_sgl()
17944 sizeof(struct lpfc_mbx_post_sgl_pages) - in lpfc_sli4_post_sgl()
17948 &mbox->u.mqe.un.post_sgl_pages; in lpfc_sli4_post_sgl()
17952 post_sgl_pages->sgl_pg_pairs[0].sgl_pg0_addr_lo = in lpfc_sli4_post_sgl()
17954 post_sgl_pages->sgl_pg_pairs[0].sgl_pg0_addr_hi = in lpfc_sli4_post_sgl()
17957 post_sgl_pages->sgl_pg_pairs[0].sgl_pg1_addr_lo = in lpfc_sli4_post_sgl()
17959 post_sgl_pages->sgl_pg_pairs[0].sgl_pg1_addr_hi = in lpfc_sli4_post_sgl()
17961 if (!phba->sli4_hba.intr_enable) in lpfc_sli4_post_sgl()
17967 /* The IOCTL status is embedded in the mailbox subheader. */ in lpfc_sli4_post_sgl()
17968 shdr = (union lpfc_sli4_cfg_shdr *) &post_sgl_pages->header.cfg_shdr; in lpfc_sli4_post_sgl()
17969 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_sli4_post_sgl()
17970 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_sli4_post_sgl()
17971 if (!phba->sli4_hba.intr_enable) in lpfc_sli4_post_sgl()
17972 mempool_free(mbox, phba->mbox_mem_pool); in lpfc_sli4_post_sgl()
17974 mempool_free(mbox, phba->mbox_mem_pool); in lpfc_sli4_post_sgl()
17977 "2511 POST_SGL mailbox failed with " in lpfc_sli4_post_sgl()
17985 * lpfc_sli4_alloc_xri - Get an available rpi in the device's range
17989 * HBA consistent with the SLI-4 interface spec. This routine
18006 spin_lock_irq(&phba->hbalock); in lpfc_sli4_alloc_xri()
18007 xri = find_first_zero_bit(phba->sli4_hba.xri_bmask, in lpfc_sli4_alloc_xri()
18008 phba->sli4_hba.max_cfg_param.max_xri); in lpfc_sli4_alloc_xri()
18009 if (xri >= phba->sli4_hba.max_cfg_param.max_xri) { in lpfc_sli4_alloc_xri()
18010 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_alloc_xri()
18013 set_bit(xri, phba->sli4_hba.xri_bmask); in lpfc_sli4_alloc_xri()
18014 phba->sli4_hba.max_cfg_param.xri_used++; in lpfc_sli4_alloc_xri()
18016 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_alloc_xri()
18021 * __lpfc_sli4_free_xri - Release an xri for reuse.
18031 if (test_and_clear_bit(xri, phba->sli4_hba.xri_bmask)) { in __lpfc_sli4_free_xri()
18032 phba->sli4_hba.max_cfg_param.xri_used--; in __lpfc_sli4_free_xri()
18037 * lpfc_sli4_free_xri - Release an xri for reuse.
18047 spin_lock_irq(&phba->hbalock); in lpfc_sli4_free_xri()
18049 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_free_xri()
18053 * lpfc_sli4_next_xritag - Get an xritag for the io
18073 phba->sli4_hba.max_cfg_param.max_xri, in lpfc_sli4_next_xritag()
18074 phba->sli4_hba.max_cfg_param.xri_used); in lpfc_sli4_next_xritag()
18079 * lpfc_sli4_post_sgl_list - post a block of ELS sgls to the port.
18085 * HBA using non-embedded mailbox command. No Lock is held. This routine
18112 return -ENOMEM; in lpfc_sli4_post_sgl_list()
18115 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_post_sgl_list()
18117 return -ENOMEM; in lpfc_sli4_post_sgl_list()
18119 /* Allocate DMA memory and set up the non-embedded mailbox command */ in lpfc_sli4_post_sgl_list()
18130 return -ENOMEM; in lpfc_sli4_post_sgl_list()
18132 /* Set up the SGL pages in the non-embedded DMA pages */ in lpfc_sli4_post_sgl_list()
18133 viraddr = mbox->sge_array->addr[0]; in lpfc_sli4_post_sgl_list()
18135 sgl_pg_pairs = &sgl->sgl_pg_pairs; in lpfc_sli4_post_sgl_list()
18140 sgl_pg_pairs->sgl_pg0_addr_lo = in lpfc_sli4_post_sgl_list()
18141 cpu_to_le32(putPaddrLow(sglq_entry->phys)); in lpfc_sli4_post_sgl_list()
18142 sgl_pg_pairs->sgl_pg0_addr_hi = in lpfc_sli4_post_sgl_list()
18143 cpu_to_le32(putPaddrHigh(sglq_entry->phys)); in lpfc_sli4_post_sgl_list()
18144 sgl_pg_pairs->sgl_pg1_addr_lo = in lpfc_sli4_post_sgl_list()
18146 sgl_pg_pairs->sgl_pg1_addr_hi = in lpfc_sli4_post_sgl_list()
18151 xritag_start = sglq_entry->sli4_xritag; in lpfc_sli4_post_sgl_list()
18159 sgl->word0 = cpu_to_le32(sgl->word0); in lpfc_sli4_post_sgl_list()
18161 if (!phba->sli4_hba.intr_enable) in lpfc_sli4_post_sgl_list()
18167 shdr = (union lpfc_sli4_cfg_shdr *) &sgl->cfg_shdr; in lpfc_sli4_post_sgl_list()
18168 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_sli4_post_sgl_list()
18169 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_sli4_post_sgl_list()
18170 if (!phba->sli4_hba.intr_enable) in lpfc_sli4_post_sgl_list()
18176 "2513 POST_SGL_BLOCK mailbox command failed " in lpfc_sli4_post_sgl_list()
18179 rc = -ENXIO; in lpfc_sli4_post_sgl_list()
18185 * lpfc_sli4_post_io_sgl_block - post a block of nvme sgl list to firmware
18191 * SCSI buffer list @nblist to the HBA using non-embedded mailbox command.
18219 return -ENOMEM; in lpfc_sli4_post_io_sgl_block()
18221 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_post_io_sgl_block()
18225 return -ENOMEM; in lpfc_sli4_post_io_sgl_block()
18228 /* Allocate DMA memory and set up the non-embedded mailbox command */ in lpfc_sli4_post_io_sgl_block()
18239 return -ENOMEM; in lpfc_sli4_post_io_sgl_block()
18242 /* Get the first SGE entry from the non-embedded DMA memory */ in lpfc_sli4_post_io_sgl_block()
18243 viraddr = mbox->sge_array->addr[0]; in lpfc_sli4_post_io_sgl_block()
18245 /* Set up the SGL pages in the non-embedded DMA pages */ in lpfc_sli4_post_io_sgl_block()
18247 sgl_pg_pairs = &sgl->sgl_pg_pairs; in lpfc_sli4_post_io_sgl_block()
18252 sgl_pg_pairs->sgl_pg0_addr_lo = in lpfc_sli4_post_io_sgl_block()
18253 cpu_to_le32(putPaddrLow(lpfc_ncmd->dma_phys_sgl)); in lpfc_sli4_post_io_sgl_block()
18254 sgl_pg_pairs->sgl_pg0_addr_hi = in lpfc_sli4_post_io_sgl_block()
18255 cpu_to_le32(putPaddrHigh(lpfc_ncmd->dma_phys_sgl)); in lpfc_sli4_post_io_sgl_block()
18256 if (phba->cfg_sg_dma_buf_size > SGL_PAGE_SIZE) in lpfc_sli4_post_io_sgl_block()
18257 pdma_phys_bpl1 = lpfc_ncmd->dma_phys_sgl + in lpfc_sli4_post_io_sgl_block()
18261 sgl_pg_pairs->sgl_pg1_addr_lo = in lpfc_sli4_post_io_sgl_block()
18263 sgl_pg_pairs->sgl_pg1_addr_hi = in lpfc_sli4_post_io_sgl_block()
18267 xritag_start = lpfc_ncmd->cur_iocbq.sli4_xritag; in lpfc_sli4_post_io_sgl_block()
18274 sgl->word0 = cpu_to_le32(sgl->word0); in lpfc_sli4_post_io_sgl_block()
18276 if (!phba->sli4_hba.intr_enable) { in lpfc_sli4_post_io_sgl_block()
18282 shdr = (union lpfc_sli4_cfg_shdr *)&sgl->cfg_shdr; in lpfc_sli4_post_io_sgl_block()
18283 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_sli4_post_io_sgl_block()
18284 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_sli4_post_io_sgl_block()
18285 if (!phba->sli4_hba.intr_enable) in lpfc_sli4_post_io_sgl_block()
18291 "6125 POST_SGL_BLOCK mailbox command failed " in lpfc_sli4_post_io_sgl_block()
18294 rc = -ENXIO; in lpfc_sli4_post_io_sgl_block()
18300 * lpfc_sli4_post_io_sgl_list - Post blocks of nvme buffer sgls from a list
18307 * uses the non-embedded SGL block post mailbox commands to post to the port.
18308 * For single NVME buffer sgl with non-contiguous xri, if any, it shall use
18309 * embedded SGL post mailbox command for posting. The @post_nblist passed in
18312 * Returns: 0 = failure, non-zero number of successfully posted buffers.
18330 return -EINVAL; in lpfc_sli4_post_io_sgl_list()
18332 sgl_size = phba->cfg_sg_dma_buf_size; in lpfc_sli4_post_io_sgl_list()
18334 list_del_init(&lpfc_ncmd->list); in lpfc_sli4_post_io_sgl_list()
18337 (lpfc_ncmd->cur_iocbq.sli4_xritag != last_xritag + 1)) { in lpfc_sli4_post_io_sgl_list()
18340 post_cnt = block_cnt - 1; in lpfc_sli4_post_io_sgl_list()
18342 list_add_tail(&lpfc_ncmd->list, &prep_nblist); in lpfc_sli4_post_io_sgl_list()
18346 list_add_tail(&lpfc_ncmd->list, &prep_nblist); in lpfc_sli4_post_io_sgl_list()
18347 /* enough sgls for non-embed sgl mbox command */ in lpfc_sli4_post_io_sgl_list()
18355 last_xritag = lpfc_ncmd->cur_iocbq.sli4_xritag; in lpfc_sli4_post_io_sgl_list()
18364 /* last single sgl with non-contiguous xri */ in lpfc_sli4_post_io_sgl_list()
18367 lpfc_ncmd->dma_phys_sgl + in lpfc_sli4_post_io_sgl_list()
18371 cur_xritag = lpfc_ncmd->cur_iocbq.sli4_xritag; in lpfc_sli4_post_io_sgl_list()
18373 phba, lpfc_ncmd->dma_phys_sgl, in lpfc_sli4_post_io_sgl_list()
18377 lpfc_ncmd->flags |= in lpfc_sli4_post_io_sgl_list()
18381 lpfc_ncmd->flags &= in lpfc_sli4_post_io_sgl_list()
18383 lpfc_ncmd->status = IOSTAT_SUCCESS; in lpfc_sli4_post_io_sgl_list()
18387 list_add_tail(&lpfc_ncmd->list, &nvme_nblist); in lpfc_sli4_post_io_sgl_list()
18406 /* put posted NVME buffer-sgl posted on NVME buffer sgl list */ in lpfc_sli4_post_io_sgl_list()
18412 lpfc_ncmd->flags |= LPFC_SBUF_NOT_POSTED; in lpfc_sli4_post_io_sgl_list()
18415 lpfc_ncmd->flags &= ~LPFC_SBUF_NOT_POSTED; in lpfc_sli4_post_io_sgl_list()
18416 lpfc_ncmd->status = IOSTAT_SUCCESS; in lpfc_sli4_post_io_sgl_list()
18419 list_add_tail(&lpfc_ncmd->list, &nvme_nblist); in lpfc_sli4_post_io_sgl_list()
18429 * lpfc_fc_frame_check - Check that this frame is a valid frame to handle
18447 switch (fc_hdr->fh_r_ctl) { in lpfc_fc_frame_check()
18458 case FC_RCTL_ELS4_REQ: /* FC-4 ELS request */ in lpfc_fc_frame_check()
18459 case FC_RCTL_ELS4_REP: /* FC-4 ELS reply */ in lpfc_fc_frame_check()
18485 switch (fc_hdr->fh_type) { in lpfc_fc_frame_check()
18501 fc_hdr->fh_r_ctl, fc_hdr->fh_type, in lpfc_fc_frame_check()
18510 fc_hdr->fh_r_ctl, fc_hdr->fh_type); in lpfc_fc_frame_check()
18515 * lpfc_fc_hdr_get_vfi - Get the VFI from an FC frame
18527 if (fc_hdr->fh_r_ctl != FC_RCTL_VFTH) in lpfc_fc_hdr_get_vfi()
18533 * lpfc_fc_frame_to_vport - Finds the vport that a frame is destined to
18554 return phba->pport; in lpfc_fc_frame_to_vport()
18555 if ((phba->pport->fc_flag & FC_PT2PT) && in lpfc_fc_frame_to_vport()
18556 !(phba->link_state == LPFC_HBA_READY)) in lpfc_fc_frame_to_vport()
18557 return phba->pport; in lpfc_fc_frame_to_vport()
18561 for (i = 0; i <= phba->max_vpi && vports[i] != NULL; i++) { in lpfc_fc_frame_to_vport()
18562 if (phba->fcf.fcfi == fcfi && in lpfc_fc_frame_to_vport()
18563 vports[i]->vfi == lpfc_fc_hdr_get_vfi(fc_hdr) && in lpfc_fc_frame_to_vport()
18564 vports[i]->fc_myDID == did) { in lpfc_fc_frame_to_vport()
18575 * lpfc_update_rcv_time_stamp - Update vport's rcv seq time stamp
18591 h_buf = list_get_first(&vport->rcv_buffer_list, in lpfc_update_rcv_time_stamp()
18596 vport->rcv_buffer_time_stamp = dmabuf->time_stamp; in lpfc_update_rcv_time_stamp()
18600 * lpfc_cleanup_rcv_buffers - Cleans up all outstanding receive sequences.
18615 list_for_each_entry_safe(h_buf, hnext, &vport->rcv_buffer_list, list) { in lpfc_cleanup_rcv_buffers()
18617 list_del_init(&dmabuf->hbuf.list); in lpfc_cleanup_rcv_buffers()
18619 &dmabuf->dbuf.list, list) { in lpfc_cleanup_rcv_buffers()
18620 list_del_init(&d_buf->list); in lpfc_cleanup_rcv_buffers()
18621 lpfc_in_buf_free(vport->phba, d_buf); in lpfc_cleanup_rcv_buffers()
18623 lpfc_in_buf_free(vport->phba, &dmabuf->dbuf); in lpfc_cleanup_rcv_buffers()
18628 * lpfc_rcv_seq_check_edtov - Cleans up timed out receive sequences.
18648 timeout = (msecs_to_jiffies(vport->phba->fc_edtov) + in lpfc_rcv_seq_check_edtov()
18649 vport->rcv_buffer_time_stamp); in lpfc_rcv_seq_check_edtov()
18650 if (list_empty(&vport->rcv_buffer_list) || in lpfc_rcv_seq_check_edtov()
18654 list_for_each_entry_safe(h_buf, hnext, &vport->rcv_buffer_list, list) { in lpfc_rcv_seq_check_edtov()
18656 timeout = (msecs_to_jiffies(vport->phba->fc_edtov) + in lpfc_rcv_seq_check_edtov()
18657 dmabuf->time_stamp); in lpfc_rcv_seq_check_edtov()
18661 list_del_init(&dmabuf->hbuf.list); in lpfc_rcv_seq_check_edtov()
18663 &dmabuf->dbuf.list, list) { in lpfc_rcv_seq_check_edtov()
18664 list_del_init(&d_buf->list); in lpfc_rcv_seq_check_edtov()
18665 lpfc_in_buf_free(vport->phba, d_buf); in lpfc_rcv_seq_check_edtov()
18667 lpfc_in_buf_free(vport->phba, &dmabuf->dbuf); in lpfc_rcv_seq_check_edtov()
18674 * lpfc_fc_frame_add - Adds a frame to the vport's list of received sequences
18697 INIT_LIST_HEAD(&dmabuf->dbuf.list); in lpfc_fc_frame_add()
18698 dmabuf->time_stamp = jiffies; in lpfc_fc_frame_add()
18699 new_hdr = (struct fc_frame_header *)dmabuf->hbuf.virt; in lpfc_fc_frame_add()
18702 list_for_each_entry(h_buf, &vport->rcv_buffer_list, list) { in lpfc_fc_frame_add()
18703 temp_hdr = (struct fc_frame_header *)h_buf->virt; in lpfc_fc_frame_add()
18704 if ((temp_hdr->fh_seq_id != new_hdr->fh_seq_id) || in lpfc_fc_frame_add()
18705 (temp_hdr->fh_ox_id != new_hdr->fh_ox_id) || in lpfc_fc_frame_add()
18706 (memcmp(&temp_hdr->fh_s_id, &new_hdr->fh_s_id, 3))) in lpfc_fc_frame_add()
18717 list_add_tail(&dmabuf->hbuf.list, &vport->rcv_buffer_list); in lpfc_fc_frame_add()
18721 temp_hdr = seq_dmabuf->hbuf.virt; in lpfc_fc_frame_add()
18722 if (be16_to_cpu(new_hdr->fh_seq_cnt) < in lpfc_fc_frame_add()
18723 be16_to_cpu(temp_hdr->fh_seq_cnt)) { in lpfc_fc_frame_add()
18724 list_del_init(&seq_dmabuf->hbuf.list); in lpfc_fc_frame_add()
18725 list_add_tail(&dmabuf->hbuf.list, &vport->rcv_buffer_list); in lpfc_fc_frame_add()
18726 list_add_tail(&dmabuf->dbuf.list, &seq_dmabuf->dbuf.list); in lpfc_fc_frame_add()
18731 list_move_tail(&seq_dmabuf->hbuf.list, &vport->rcv_buffer_list); in lpfc_fc_frame_add()
18732 seq_dmabuf->time_stamp = jiffies; in lpfc_fc_frame_add()
18734 if (list_empty(&seq_dmabuf->dbuf.list)) { in lpfc_fc_frame_add()
18735 list_add_tail(&dmabuf->dbuf.list, &seq_dmabuf->dbuf.list); in lpfc_fc_frame_add()
18739 d_buf = list_entry(seq_dmabuf->dbuf.list.prev, typeof(*d_buf), list); in lpfc_fc_frame_add()
18742 temp_hdr = (struct fc_frame_header *)temp_dmabuf->hbuf.virt; in lpfc_fc_frame_add()
18747 if (be16_to_cpu(new_hdr->fh_seq_cnt) > in lpfc_fc_frame_add()
18748 be16_to_cpu(temp_hdr->fh_seq_cnt)) { in lpfc_fc_frame_add()
18749 list_add(&dmabuf->dbuf.list, &temp_dmabuf->dbuf.list); in lpfc_fc_frame_add()
18754 if (&d_buf->list == &seq_dmabuf->dbuf.list) in lpfc_fc_frame_add()
18756 d_buf = list_entry(d_buf->list.prev, typeof(*d_buf), list); in lpfc_fc_frame_add()
18765 * lpfc_sli4_abort_partial_seq - Abort partially assembled unsol sequence
18775 * true -- if there is matching partially assembled sequence present and all
18777 * false -- if there is no matching partially assembled sequence present so
18790 INIT_LIST_HEAD(&dmabuf->dbuf.list); in lpfc_sli4_abort_partial_seq()
18791 INIT_LIST_HEAD(&dmabuf->hbuf.list); in lpfc_sli4_abort_partial_seq()
18792 new_hdr = (struct fc_frame_header *)dmabuf->hbuf.virt; in lpfc_sli4_abort_partial_seq()
18793 list_for_each_entry(h_buf, &vport->rcv_buffer_list, list) { in lpfc_sli4_abort_partial_seq()
18794 temp_hdr = (struct fc_frame_header *)h_buf->virt; in lpfc_sli4_abort_partial_seq()
18795 if ((temp_hdr->fh_seq_id != new_hdr->fh_seq_id) || in lpfc_sli4_abort_partial_seq()
18796 (temp_hdr->fh_ox_id != new_hdr->fh_ox_id) || in lpfc_sli4_abort_partial_seq()
18797 (memcmp(&temp_hdr->fh_s_id, &new_hdr->fh_s_id, 3))) in lpfc_sli4_abort_partial_seq()
18807 &seq_dmabuf->dbuf.list, list) { in lpfc_sli4_abort_partial_seq()
18808 list_del_init(&d_buf->list); in lpfc_sli4_abort_partial_seq()
18809 lpfc_in_buf_free(vport->phba, d_buf); in lpfc_sli4_abort_partial_seq()
18817 * lpfc_sli4_abort_ulp_seq - Abort assembled unsol sequence from ulp
18827 * true -- if there is matching pending context of the sequence cleaned
18829 * false -- if there is no matching pending context of the sequence present
18835 struct lpfc_hba *phba = vport->phba; in lpfc_sli4_abort_ulp_seq()
18839 if (phba->sli_rev < LPFC_SLI_REV4) in lpfc_sli4_abort_ulp_seq()
18851 * lpfc_sli4_seq_abort_rsp_cmpl - BLS ABORT RSP seq abort iocb complete handler
18866 lpfc_nlp_put(cmd_iocbq->ndlp); in lpfc_sli4_seq_abort_rsp_cmpl()
18871 if (rsp_iocbq && rsp_iocbq->iocb.ulpStatus) in lpfc_sli4_seq_abort_rsp_cmpl()
18879 * lpfc_sli4_xri_inrange - check xri is in range of xris owned by driver.
18892 for (i = 0; i < phba->sli4_hba.max_cfg_param.max_xri; i++) { in lpfc_sli4_xri_inrange()
18893 if (xri == phba->sli4_hba.xri_ids[i]) in lpfc_sli4_xri_inrange()
18900 * lpfc_sli4_seq_abort_rsp - bls rsp to sequence abort
18912 struct lpfc_hba *phba = vport->phba; in lpfc_sli4_seq_abort_rsp()
18924 oxid = be16_to_cpu(fc_hdr->fh_ox_id); in lpfc_sli4_seq_abort_rsp()
18925 rxid = be16_to_cpu(fc_hdr->fh_rx_id); in lpfc_sli4_seq_abort_rsp()
18945 icmd = &ctiocb->wqe; in lpfc_sli4_seq_abort_rsp()
18950 ctiocb->ndlp = lpfc_nlp_get(ndlp); in lpfc_sli4_seq_abort_rsp()
18951 if (!ctiocb->ndlp) { in lpfc_sli4_seq_abort_rsp()
18956 ctiocb->vport = phba->pport; in lpfc_sli4_seq_abort_rsp()
18957 ctiocb->cmd_cmpl = lpfc_sli4_seq_abort_rsp_cmpl; in lpfc_sli4_seq_abort_rsp()
18958 ctiocb->sli4_lxritag = NO_XRI; in lpfc_sli4_seq_abort_rsp()
18959 ctiocb->sli4_xritag = NO_XRI; in lpfc_sli4_seq_abort_rsp()
18960 ctiocb->abort_rctl = FC_RCTL_BA_ACC; in lpfc_sli4_seq_abort_rsp()
18980 ctiocb->abort_rctl = FC_RCTL_BA_RJT; in lpfc_sli4_seq_abort_rsp()
18981 bf_set(xmit_bls_rsp64_rjt_vspec, &icmd->xmit_bls_rsp, 0); in lpfc_sli4_seq_abort_rsp()
18982 bf_set(xmit_bls_rsp64_rjt_expc, &icmd->xmit_bls_rsp, in lpfc_sli4_seq_abort_rsp()
18984 bf_set(xmit_bls_rsp64_rjt_rsnc, &icmd->xmit_bls_rsp, in lpfc_sli4_seq_abort_rsp()
18993 ctiocb->abort_rctl = FC_RCTL_BA_RJT; in lpfc_sli4_seq_abort_rsp()
18994 bf_set(xmit_bls_rsp64_rjt_vspec, &icmd->xmit_bls_rsp, 0); in lpfc_sli4_seq_abort_rsp()
18995 bf_set(xmit_bls_rsp64_rjt_expc, &icmd->xmit_bls_rsp, in lpfc_sli4_seq_abort_rsp()
18997 bf_set(xmit_bls_rsp64_rjt_rsnc, &icmd->xmit_bls_rsp, in lpfc_sli4_seq_abort_rsp()
19006 ctiocb->abort_bls = LPFC_ABTS_UNSOL_RSP; in lpfc_sli4_seq_abort_rsp()
19007 bf_set(xmit_bls_rsp64_rxid, &icmd->xmit_bls_rsp, rxid); in lpfc_sli4_seq_abort_rsp()
19013 ctiocb->abort_bls = LPFC_ABTS_UNSOL_INT; in lpfc_sli4_seq_abort_rsp()
19017 bf_set(xmit_bls_rsp64_oxid, &icmd->xmit_bls_rsp, oxid); in lpfc_sli4_seq_abort_rsp()
19018 bf_set(xmit_bls_rsp64_oxid, &icmd->xmit_bls_rsp, rxid); in lpfc_sli4_seq_abort_rsp()
19021 bf_set(wqe_els_did, &icmd->xmit_bls_rsp.wqe_dest, in lpfc_sli4_seq_abort_rsp()
19022 ndlp->nlp_DID); in lpfc_sli4_seq_abort_rsp()
19023 bf_set(xmit_bls_rsp64_temprpi, &icmd->xmit_bls_rsp, in lpfc_sli4_seq_abort_rsp()
19024 phba->sli4_hba.rpi_ids[ndlp->nlp_rpi]); in lpfc_sli4_seq_abort_rsp()
19025 bf_set(wqe_cmnd, &icmd->generic.wqe_com, CMD_XMIT_BLS_RSP64_CX); in lpfc_sli4_seq_abort_rsp()
19030 ctiocb->abort_rctl, oxid, phba->link_state); in lpfc_sli4_seq_abort_rsp()
19037 ctiocb->abort_rctl, oxid, in lpfc_sli4_seq_abort_rsp()
19038 phba->link_state); in lpfc_sli4_seq_abort_rsp()
19040 ctiocb->ndlp = NULL; in lpfc_sli4_seq_abort_rsp()
19046 * lpfc_sli4_handle_unsol_abort - Handle sli-4 unsolicited abort event
19050 * This function handles an SLI-4 unsolicited abort event. If the unsolicited
19062 struct lpfc_hba *phba = vport->phba; in lpfc_sli4_handle_unsol_abort()
19068 memcpy(&fc_hdr, dmabuf->hbuf.virt, sizeof(struct fc_frame_header)); in lpfc_sli4_handle_unsol_abort()
19080 lpfc_in_buf_free(phba, &dmabuf->dbuf); in lpfc_sli4_handle_unsol_abort()
19082 if (phba->nvmet_support) { in lpfc_sli4_handle_unsol_abort()
19092 * lpfc_seq_complete - Indicates if a sequence is complete
19112 hdr = (struct fc_frame_header *)dmabuf->hbuf.virt; in lpfc_seq_complete()
19114 if (hdr->fh_seq_cnt != seq_count) in lpfc_seq_complete()
19116 fctl = (hdr->fh_f_ctl[0] << 16 | in lpfc_seq_complete()
19117 hdr->fh_f_ctl[1] << 8 | in lpfc_seq_complete()
19118 hdr->fh_f_ctl[2]); in lpfc_seq_complete()
19122 list_for_each_entry(d_buf, &dmabuf->dbuf.list, list) { in lpfc_seq_complete()
19124 hdr = (struct fc_frame_header *)seq_dmabuf->hbuf.virt; in lpfc_seq_complete()
19126 if (++seq_count != be16_to_cpu(hdr->fh_seq_cnt)) in lpfc_seq_complete()
19128 fctl = (hdr->fh_f_ctl[0] << 16 | in lpfc_seq_complete()
19129 hdr->fh_f_ctl[1] << 8 | in lpfc_seq_complete()
19130 hdr->fh_f_ctl[2]); in lpfc_seq_complete()
19139 * lpfc_prep_seq - Prep sequence for ULP processing
19161 fc_hdr = (struct fc_frame_header *)seq_dmabuf->hbuf.virt; in lpfc_prep_seq()
19163 list_del_init(&seq_dmabuf->hbuf.list); in lpfc_prep_seq()
19169 first_iocbq = lpfc_sli_get_iocbq(vport->phba); in lpfc_prep_seq()
19172 first_iocbq->wcqe_cmpl.total_data_placed = 0; in lpfc_prep_seq()
19173 bf_set(lpfc_wcqe_c_status, &first_iocbq->wcqe_cmpl, in lpfc_prep_seq()
19175 first_iocbq->vport = vport; in lpfc_prep_seq()
19179 bf_set(els_rsp64_sid, &first_iocbq->wqe.xmit_els_rsp, in lpfc_prep_seq()
19183 bf_set(wqe_ctxt_tag, &first_iocbq->wqe.xmit_els_rsp.wqe_com, in lpfc_prep_seq()
19185 bf_set(wqe_rcvoxid, &first_iocbq->wqe.xmit_els_rsp.wqe_com, in lpfc_prep_seq()
19186 be16_to_cpu(fc_hdr->fh_ox_id)); in lpfc_prep_seq()
19190 &seq_dmabuf->cq_event.cqe.rcqe_cmpl); in lpfc_prep_seq()
19192 first_iocbq->cmd_dmabuf = &seq_dmabuf->dbuf; in lpfc_prep_seq()
19193 first_iocbq->bpl_dmabuf = NULL; in lpfc_prep_seq()
19195 first_iocbq->wcqe_cmpl.word3 = 1; in lpfc_prep_seq()
19198 first_iocbq->wqe.gen_req.bde.tus.f.bdeSize = in lpfc_prep_seq()
19201 first_iocbq->wqe.gen_req.bde.tus.f.bdeSize = tot_len; in lpfc_prep_seq()
19203 first_iocbq->wcqe_cmpl.total_data_placed = tot_len; in lpfc_prep_seq()
19204 bf_set(wqe_els_did, &first_iocbq->wqe.xmit_els_rsp.wqe_dest, in lpfc_prep_seq()
19212 list_for_each_entry_safe(d_buf, n_buf, &seq_dmabuf->dbuf.list, list) { in lpfc_prep_seq()
19214 lpfc_in_buf_free(vport->phba, d_buf); in lpfc_prep_seq()
19217 if (!iocbq->bpl_dmabuf) { in lpfc_prep_seq()
19218 iocbq->bpl_dmabuf = d_buf; in lpfc_prep_seq()
19219 iocbq->wcqe_cmpl.word3++; in lpfc_prep_seq()
19223 &hbq_buf->cq_event.cqe.rcqe_cmpl); in lpfc_prep_seq()
19224 iocbq->unsol_rcv_len = len; in lpfc_prep_seq()
19225 iocbq->wcqe_cmpl.total_data_placed += len; in lpfc_prep_seq()
19228 iocbq = lpfc_sli_get_iocbq(vport->phba); in lpfc_prep_seq()
19232 &first_iocbq->wcqe_cmpl, in lpfc_prep_seq()
19234 first_iocbq->wcqe_cmpl.parameter = in lpfc_prep_seq()
19237 lpfc_in_buf_free(vport->phba, d_buf); in lpfc_prep_seq()
19243 &hbq_buf->cq_event.cqe.rcqe_cmpl); in lpfc_prep_seq()
19244 iocbq->cmd_dmabuf = d_buf; in lpfc_prep_seq()
19245 iocbq->bpl_dmabuf = NULL; in lpfc_prep_seq()
19246 iocbq->wcqe_cmpl.word3 = 1; in lpfc_prep_seq()
19249 iocbq->wqe.xmit_els_rsp.bde.tus.f.bdeSize = in lpfc_prep_seq()
19252 iocbq->wqe.xmit_els_rsp.bde.tus.f.bdeSize = in lpfc_prep_seq()
19256 iocbq->wcqe_cmpl.total_data_placed = tot_len; in lpfc_prep_seq()
19257 bf_set(wqe_els_did, &iocbq->wqe.xmit_els_rsp.wqe_dest, in lpfc_prep_seq()
19259 list_add_tail(&iocbq->list, &first_iocbq->list); in lpfc_prep_seq()
19264 lpfc_in_buf_free(vport->phba, &seq_dmabuf->dbuf); in lpfc_prep_seq()
19275 struct lpfc_hba *phba = vport->phba; in lpfc_sli4_send_seq_to_ulp()
19277 fc_hdr = (struct fc_frame_header *)seq_dmabuf->hbuf.virt; in lpfc_sli4_send_seq_to_ulp()
19284 fc_hdr->fh_r_ctl, fc_hdr->fh_type); in lpfc_sli4_send_seq_to_ulp()
19288 phba->sli4_hba.els_wq->pring, in lpfc_sli4_send_seq_to_ulp()
19289 iocbq, fc_hdr->fh_r_ctl, in lpfc_sli4_send_seq_to_ulp()
19290 fc_hdr->fh_type)) { in lpfc_sli4_send_seq_to_ulp()
19295 fc_hdr->fh_r_ctl, fc_hdr->fh_type); in lpfc_sli4_send_seq_to_ulp()
19296 lpfc_in_buf_free(phba, &seq_dmabuf->dbuf); in lpfc_sli4_send_seq_to_ulp()
19301 &iocbq->list, list) { in lpfc_sli4_send_seq_to_ulp()
19302 list_del_init(&curr_iocb->list); in lpfc_sli4_send_seq_to_ulp()
19312 struct lpfc_dmabuf *pcmd = cmdiocb->cmd_dmabuf; in lpfc_sli4_mds_loopback_cmpl()
19314 if (pcmd && pcmd->virt) in lpfc_sli4_mds_loopback_cmpl()
19315 dma_pool_free(phba->lpfc_drb_pool, pcmd->virt, pcmd->phys); in lpfc_sli4_mds_loopback_cmpl()
19326 struct lpfc_hba *phba = vport->phba; in lpfc_sli4_handle_mds_loopback()
19334 fc_hdr = (struct fc_frame_header *)dmabuf->hbuf.virt; in lpfc_sli4_handle_mds_loopback()
19335 frame_len = bf_get(lpfc_rcqe_length, &dmabuf->cq_event.cqe.rcqe_cmpl); in lpfc_sli4_handle_mds_loopback()
19341 spin_lock_irqsave(&phba->hbalock, iflags); in lpfc_sli4_handle_mds_loopback()
19342 list_add_tail(&dmabuf->cq_event.list, in lpfc_sli4_handle_mds_loopback()
19343 &phba->sli4_hba.sp_queue_event); in lpfc_sli4_handle_mds_loopback()
19344 phba->hba_flag |= HBA_SP_QUEUE_EVT; in lpfc_sli4_handle_mds_loopback()
19345 spin_unlock_irqrestore(&phba->hbalock, iflags); in lpfc_sli4_handle_mds_loopback()
19353 pcmd->virt = dma_pool_alloc(phba->lpfc_drb_pool, GFP_KERNEL, in lpfc_sli4_handle_mds_loopback()
19354 &pcmd->phys); in lpfc_sli4_handle_mds_loopback()
19355 if (!pcmd || !pcmd->virt) in lpfc_sli4_handle_mds_loopback()
19358 INIT_LIST_HEAD(&pcmd->list); in lpfc_sli4_handle_mds_loopback()
19361 memcpy(pcmd->virt, dmabuf->dbuf.virt, frame_len); in lpfc_sli4_handle_mds_loopback()
19363 iocbq->cmd_dmabuf = pcmd; in lpfc_sli4_handle_mds_loopback()
19364 iocbq->vport = vport; in lpfc_sli4_handle_mds_loopback()
19365 iocbq->cmd_flag &= ~LPFC_FIP_ELS_ID_MASK; in lpfc_sli4_handle_mds_loopback()
19366 iocbq->cmd_flag |= LPFC_USE_FCPWQIDX; in lpfc_sli4_handle_mds_loopback()
19367 iocbq->num_bdes = 0; in lpfc_sli4_handle_mds_loopback()
19369 pwqe = &iocbq->wqe; in lpfc_sli4_handle_mds_loopback()
19371 pwqe->gen_req.bde.addrHigh = putPaddrHigh(pcmd->phys); in lpfc_sli4_handle_mds_loopback()
19372 pwqe->gen_req.bde.addrLow = putPaddrLow(pcmd->phys); in lpfc_sli4_handle_mds_loopback()
19373 pwqe->gen_req.bde.tus.f.bdeSize = frame_len; in lpfc_sli4_handle_mds_loopback()
19374 pwqe->gen_req.bde.tus.f.bdeFlags = BUFF_TYPE_BDE_64; in lpfc_sli4_handle_mds_loopback()
19376 pwqe->send_frame.frame_len = frame_len; in lpfc_sli4_handle_mds_loopback()
19377 pwqe->send_frame.fc_hdr_wd0 = be32_to_cpu(*((__be32 *)fc_hdr)); in lpfc_sli4_handle_mds_loopback()
19378 pwqe->send_frame.fc_hdr_wd1 = be32_to_cpu(*((__be32 *)fc_hdr + 1)); in lpfc_sli4_handle_mds_loopback()
19379 pwqe->send_frame.fc_hdr_wd2 = be32_to_cpu(*((__be32 *)fc_hdr + 2)); in lpfc_sli4_handle_mds_loopback()
19380 pwqe->send_frame.fc_hdr_wd3 = be32_to_cpu(*((__be32 *)fc_hdr + 3)); in lpfc_sli4_handle_mds_loopback()
19381 pwqe->send_frame.fc_hdr_wd4 = be32_to_cpu(*((__be32 *)fc_hdr + 4)); in lpfc_sli4_handle_mds_loopback()
19382 pwqe->send_frame.fc_hdr_wd5 = be32_to_cpu(*((__be32 *)fc_hdr + 5)); in lpfc_sli4_handle_mds_loopback()
19384 pwqe->generic.wqe_com.word7 = 0; in lpfc_sli4_handle_mds_loopback()
19385 pwqe->generic.wqe_com.word10 = 0; in lpfc_sli4_handle_mds_loopback()
19387 bf_set(wqe_cmnd, &pwqe->generic.wqe_com, CMD_SEND_FRAME); in lpfc_sli4_handle_mds_loopback()
19388 bf_set(wqe_sof, &pwqe->generic.wqe_com, 0x2E); /* SOF byte */ in lpfc_sli4_handle_mds_loopback()
19389 bf_set(wqe_eof, &pwqe->generic.wqe_com, 0x41); /* EOF byte */ in lpfc_sli4_handle_mds_loopback()
19390 bf_set(wqe_lenloc, &pwqe->generic.wqe_com, 1); in lpfc_sli4_handle_mds_loopback()
19391 bf_set(wqe_xbl, &pwqe->generic.wqe_com, 1); in lpfc_sli4_handle_mds_loopback()
19392 bf_set(wqe_dbde, &pwqe->generic.wqe_com, 1); in lpfc_sli4_handle_mds_loopback()
19393 bf_set(wqe_xc, &pwqe->generic.wqe_com, 1); in lpfc_sli4_handle_mds_loopback()
19394 bf_set(wqe_cmd_type, &pwqe->generic.wqe_com, 0xA); in lpfc_sli4_handle_mds_loopback()
19395 bf_set(wqe_cqid, &pwqe->generic.wqe_com, LPFC_WQE_CQ_ID_DEFAULT); in lpfc_sli4_handle_mds_loopback()
19396 bf_set(wqe_xri_tag, &pwqe->generic.wqe_com, iocbq->sli4_xritag); in lpfc_sli4_handle_mds_loopback()
19397 bf_set(wqe_reqtag, &pwqe->generic.wqe_com, iocbq->iotag); in lpfc_sli4_handle_mds_loopback()
19398 bf_set(wqe_class, &pwqe->generic.wqe_com, CLASS3); in lpfc_sli4_handle_mds_loopback()
19399 pwqe->generic.wqe_com.abort_tag = iocbq->iotag; in lpfc_sli4_handle_mds_loopback()
19401 iocbq->cmd_cmpl = lpfc_sli4_mds_loopback_cmpl; in lpfc_sli4_handle_mds_loopback()
19407 lpfc_in_buf_free(phba, &dmabuf->dbuf); in lpfc_sli4_handle_mds_loopback()
19413 if (pcmd && pcmd->virt) in lpfc_sli4_handle_mds_loopback()
19414 dma_pool_free(phba->lpfc_drb_pool, pcmd->virt, pcmd->phys); in lpfc_sli4_handle_mds_loopback()
19418 lpfc_in_buf_free(phba, &dmabuf->dbuf); in lpfc_sli4_handle_mds_loopback()
19422 * lpfc_sli4_handle_received_buffer - Handle received buffers from firmware
19444 fc_hdr = (struct fc_frame_header *)dmabuf->hbuf.virt; in lpfc_sli4_handle_received_buffer()
19446 if (fc_hdr->fh_r_ctl == FC_RCTL_MDS_DIAGS || in lpfc_sli4_handle_received_buffer()
19447 fc_hdr->fh_r_ctl == FC_RCTL_DD_UNSOL_DATA) { in lpfc_sli4_handle_received_buffer()
19448 vport = phba->pport; in lpfc_sli4_handle_received_buffer()
19450 if (!(phba->pport->load_flag & FC_UNLOADING)) in lpfc_sli4_handle_received_buffer()
19453 lpfc_in_buf_free(phba, &dmabuf->dbuf); in lpfc_sli4_handle_received_buffer()
19459 lpfc_in_buf_free(phba, &dmabuf->dbuf); in lpfc_sli4_handle_received_buffer()
19464 &dmabuf->cq_event.cqe.rcqe_cmpl) == CQE_CODE_RECEIVE_V1)) in lpfc_sli4_handle_received_buffer()
19466 &dmabuf->cq_event.cqe.rcqe_cmpl); in lpfc_sli4_handle_received_buffer()
19469 &dmabuf->cq_event.cqe.rcqe_cmpl); in lpfc_sli4_handle_received_buffer()
19471 if (fc_hdr->fh_r_ctl == 0xF4 && fc_hdr->fh_type == 0xFF) { in lpfc_sli4_handle_received_buffer()
19472 vport = phba->pport; in lpfc_sli4_handle_received_buffer()
19476 &dmabuf->cq_event.cqe.rcqe_cmpl)); in lpfc_sli4_handle_received_buffer()
19488 lpfc_in_buf_free(phba, &dmabuf->dbuf); in lpfc_sli4_handle_received_buffer()
19493 if (!(vport->vpi_state & LPFC_VPI_REGISTERED) && in lpfc_sli4_handle_received_buffer()
19500 if (!(vport->fc_flag & FC_PT2PT) || in lpfc_sli4_handle_received_buffer()
19501 (phba->link_state == LPFC_HBA_READY)) { in lpfc_sli4_handle_received_buffer()
19502 lpfc_in_buf_free(phba, &dmabuf->dbuf); in lpfc_sli4_handle_received_buffer()
19508 if (fc_hdr->fh_r_ctl == FC_RCTL_BA_ABTS) { in lpfc_sli4_handle_received_buffer()
19516 /* unable to add frame to vport - throw it out */ in lpfc_sli4_handle_received_buffer()
19517 lpfc_in_buf_free(phba, &dmabuf->dbuf); in lpfc_sli4_handle_received_buffer()
19529 * lpfc_sli4_post_all_rpi_hdrs - Post the rpi header memory region to the port
19533 * HBA consistent with the SLI-4 interface spec. This routine
19542 * 0 - successful
19543 * -EIO - The mailbox failed to complete successfully.
19557 if (!phba->sli4_hba.rpi_hdrs_in_use) in lpfc_sli4_post_all_rpi_hdrs()
19559 if (phba->sli4_hba.extents_in_use) in lpfc_sli4_post_all_rpi_hdrs()
19560 return -EIO; in lpfc_sli4_post_all_rpi_hdrs()
19562 list_for_each_entry(rpi_page, &phba->sli4_hba.lpfc_rpi_hdr_list, list) { in lpfc_sli4_post_all_rpi_hdrs()
19568 if (bf_get(lpfc_rpi_rsrc_rdy, &phba->sli4_hba.sli4_flags) != in lpfc_sli4_post_all_rpi_hdrs()
19570 rpi_page->start_rpi = phba->sli4_hba.rpi_ids[lrpi]; in lpfc_sli4_post_all_rpi_hdrs()
19577 rc = -EIO; in lpfc_sli4_post_all_rpi_hdrs()
19583 bf_set(lpfc_rpi_rsrc_rdy, &phba->sli4_hba.sli4_flags, in lpfc_sli4_post_all_rpi_hdrs()
19589 * lpfc_sli4_post_rpi_hdr - Post an rpi header memory region to the port
19594 * HBA consistent with the SLI-4 interface spec. This memory region
19598 * 0 - successful
19599 * -ENOMEM - No available memory
19600 * -EIO - The mailbox failed to complete successfully.
19612 if (!phba->sli4_hba.rpi_hdrs_in_use) in lpfc_sli4_post_rpi_hdr()
19614 if (phba->sli4_hba.extents_in_use) in lpfc_sli4_post_rpi_hdr()
19615 return -EIO; in lpfc_sli4_post_rpi_hdr()
19617 /* The port is notified of the header region via a mailbox command. */ in lpfc_sli4_post_rpi_hdr()
19618 mboxq = (LPFC_MBOXQ_t *) mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_post_rpi_hdr()
19622 "SLI_CONFIG_SPECIAL mailbox command\n"); in lpfc_sli4_post_rpi_hdr()
19623 return -ENOMEM; in lpfc_sli4_post_rpi_hdr()
19627 hdr_tmpl = &mboxq->u.mqe.un.hdr_tmpl; in lpfc_sli4_post_rpi_hdr()
19630 sizeof(struct lpfc_mbx_post_hdr_tmpl) - in lpfc_sli4_post_rpi_hdr()
19637 rpi_page->start_rpi); in lpfc_sli4_post_rpi_hdr()
19639 hdr_tmpl, rpi_page->page_count); in lpfc_sli4_post_rpi_hdr()
19641 hdr_tmpl->rpi_paddr_lo = putPaddrLow(rpi_page->dmabuf->phys); in lpfc_sli4_post_rpi_hdr()
19642 hdr_tmpl->rpi_paddr_hi = putPaddrHigh(rpi_page->dmabuf->phys); in lpfc_sli4_post_rpi_hdr()
19644 shdr = (union lpfc_sli4_cfg_shdr *) &hdr_tmpl->header.cfg_shdr; in lpfc_sli4_post_rpi_hdr()
19645 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_sli4_post_rpi_hdr()
19646 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_sli4_post_rpi_hdr()
19647 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_post_rpi_hdr()
19650 "2514 POST_RPI_HDR mailbox failed with " in lpfc_sli4_post_rpi_hdr()
19653 rc = -ENXIO; in lpfc_sli4_post_rpi_hdr()
19656 * The next_rpi stores the next logical module-64 rpi value used in lpfc_sli4_post_rpi_hdr()
19659 spin_lock_irq(&phba->hbalock); in lpfc_sli4_post_rpi_hdr()
19660 phba->sli4_hba.next_rpi = rpi_page->next_rpi; in lpfc_sli4_post_rpi_hdr()
19661 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_post_rpi_hdr()
19667 * lpfc_sli4_alloc_rpi - Get an available rpi in the device's range
19671 * HBA consistent with the SLI-4 interface spec. This routine
19692 spin_lock_irqsave(&phba->hbalock, iflag); in lpfc_sli4_alloc_rpi()
19693 max_rpi = phba->sli4_hba.max_cfg_param.max_rpi; in lpfc_sli4_alloc_rpi()
19694 rpi_limit = phba->sli4_hba.next_rpi; in lpfc_sli4_alloc_rpi()
19696 rpi = find_first_zero_bit(phba->sli4_hba.rpi_bmask, rpi_limit); in lpfc_sli4_alloc_rpi()
19700 set_bit(rpi, phba->sli4_hba.rpi_bmask); in lpfc_sli4_alloc_rpi()
19701 phba->sli4_hba.max_cfg_param.rpi_used++; in lpfc_sli4_alloc_rpi()
19702 phba->sli4_hba.rpi_count++; in lpfc_sli4_alloc_rpi()
19714 (phba->sli4_hba.rpi_count >= max_rpi)) { in lpfc_sli4_alloc_rpi()
19715 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli4_alloc_rpi()
19723 if (!phba->sli4_hba.rpi_hdrs_in_use) { in lpfc_sli4_alloc_rpi()
19724 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli4_alloc_rpi()
19734 rpi_remaining = phba->sli4_hba.next_rpi - phba->sli4_hba.rpi_count; in lpfc_sli4_alloc_rpi()
19735 spin_unlock_irqrestore(&phba->hbalock, iflag); in lpfc_sli4_alloc_rpi()
19743 lrpi = rpi_hdr->start_rpi; in lpfc_sli4_alloc_rpi()
19744 rpi_hdr->start_rpi = phba->sli4_hba.rpi_ids[lrpi]; in lpfc_sli4_alloc_rpi()
19753 * __lpfc_sli4_free_rpi - Release an rpi for reuse.
19770 if (test_and_clear_bit(rpi, phba->sli4_hba.rpi_bmask)) { in __lpfc_sli4_free_rpi()
19771 phba->sli4_hba.rpi_count--; in __lpfc_sli4_free_rpi()
19772 phba->sli4_hba.max_cfg_param.rpi_used--; in __lpfc_sli4_free_rpi()
19782 * lpfc_sli4_free_rpi - Release an rpi for reuse.
19792 spin_lock_irq(&phba->hbalock); in lpfc_sli4_free_rpi()
19794 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_free_rpi()
19798 * lpfc_sli4_remove_rpis - Remove the rpi bitmask region
19807 kfree(phba->sli4_hba.rpi_bmask); in lpfc_sli4_remove_rpis()
19808 kfree(phba->sli4_hba.rpi_ids); in lpfc_sli4_remove_rpis()
19809 bf_set(lpfc_rpi_rsrc_rdy, &phba->sli4_hba.sli4_flags, 0); in lpfc_sli4_remove_rpis()
19813 * lpfc_sli4_resume_rpi - Remove the rpi bitmask region
19815 * @cmpl: completion call-back.
19826 struct lpfc_hba *phba = ndlp->phba; in lpfc_sli4_resume_rpi()
19829 /* The port is notified of the header region via a mailbox command. */ in lpfc_sli4_resume_rpi()
19830 mboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_resume_rpi()
19832 return -ENOMEM; in lpfc_sli4_resume_rpi()
19844 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_resume_rpi()
19845 return -EIO; in lpfc_sli4_resume_rpi()
19851 mboxq->mbox_cmpl = cmpl; in lpfc_sli4_resume_rpi()
19852 mboxq->ctx_buf = arg; in lpfc_sli4_resume_rpi()
19854 mboxq->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_sli4_resume_rpi()
19855 mboxq->ctx_ndlp = ndlp; in lpfc_sli4_resume_rpi()
19856 mboxq->vport = ndlp->vport; in lpfc_sli4_resume_rpi()
19860 "2010 Resume RPI Mailbox failed " in lpfc_sli4_resume_rpi()
19862 bf_get(lpfc_mqe_status, &mboxq->u.mqe)); in lpfc_sli4_resume_rpi()
19864 mempool_free(mboxq, phba->mbox_mem_pool); in lpfc_sli4_resume_rpi()
19865 return -EIO; in lpfc_sli4_resume_rpi()
19871 * lpfc_sli4_init_vpi - Initialize a vpi with the port
19878 * -Evalue otherwise
19887 struct lpfc_hba *phba = vport->phba; in lpfc_sli4_init_vpi()
19888 mboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_init_vpi()
19890 return -ENOMEM; in lpfc_sli4_init_vpi()
19891 lpfc_init_vpi(phba, mboxq, vport->vpi); in lpfc_sli4_init_vpi()
19896 "2022 INIT VPI Mailbox failed " in lpfc_sli4_init_vpi()
19898 bf_get(lpfc_mqe_status, &mboxq->u.mqe)); in lpfc_sli4_init_vpi()
19899 retval = -EIO; in lpfc_sli4_init_vpi()
19902 mempool_free(mboxq, vport->phba->mbox_mem_pool); in lpfc_sli4_init_vpi()
19908 * lpfc_mbx_cmpl_add_fcf_record - add fcf mbox completion handler.
19910 * @mboxq: Pointer to mailbox object.
19914 * care of the nonembedded mailbox operations.
19923 virt_addr = mboxq->sge_array->addr[0]; in lpfc_mbx_cmpl_add_fcf_record()
19924 /* The IOCTL status is embedded in the mailbox subheader. */ in lpfc_mbx_cmpl_add_fcf_record()
19926 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_mbx_cmpl_add_fcf_record()
19927 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_mbx_cmpl_add_fcf_record()
19932 "2558 ADD_FCF_RECORD mailbox failed with " in lpfc_mbx_cmpl_add_fcf_record()
19940 * lpfc_sli4_add_fcf_record - Manually add an FCF Record.
19946 * care of the nonembedded mailbox operations.
19959 mboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_add_fcf_record()
19963 return -ENOMEM; in lpfc_sli4_add_fcf_record()
19969 /* Allocate DMA memory and set up the non-embedded mailbox command */ in lpfc_sli4_add_fcf_record()
19979 return -ENOMEM; in lpfc_sli4_add_fcf_record()
19983 * Get the first SGE entry from the non-embedded DMA memory. This in lpfc_sli4_add_fcf_record()
19987 virt_addr = mboxq->sge_array->addr[0]; in lpfc_sli4_add_fcf_record()
20003 mboxq->vport = phba->pport; in lpfc_sli4_add_fcf_record()
20004 mboxq->mbox_cmpl = lpfc_mbx_cmpl_add_fcf_record; in lpfc_sli4_add_fcf_record()
20008 "2515 ADD_FCF_RECORD mailbox failed with " in lpfc_sli4_add_fcf_record()
20011 rc = -EIO; in lpfc_sli4_add_fcf_record()
20019 * lpfc_sli4_build_dflt_fcf_record - Build the driver's default FCF Record.
20034 fcf_record->max_rcv_size = LPFC_FCOE_MAX_RCV_SIZE; in lpfc_sli4_build_dflt_fcf_record()
20035 fcf_record->fka_adv_period = LPFC_FCOE_FKA_ADV_PER; in lpfc_sli4_build_dflt_fcf_record()
20036 fcf_record->fip_priority = LPFC_FCOE_FIP_PRIORITY; in lpfc_sli4_build_dflt_fcf_record()
20037 bf_set(lpfc_fcf_record_mac_0, fcf_record, phba->fc_map[0]); in lpfc_sli4_build_dflt_fcf_record()
20038 bf_set(lpfc_fcf_record_mac_1, fcf_record, phba->fc_map[1]); in lpfc_sli4_build_dflt_fcf_record()
20039 bf_set(lpfc_fcf_record_mac_2, fcf_record, phba->fc_map[2]); in lpfc_sli4_build_dflt_fcf_record()
20043 bf_set(lpfc_fcf_record_fc_map_0, fcf_record, phba->fc_map[0]); in lpfc_sli4_build_dflt_fcf_record()
20044 bf_set(lpfc_fcf_record_fc_map_1, fcf_record, phba->fc_map[1]); in lpfc_sli4_build_dflt_fcf_record()
20045 bf_set(lpfc_fcf_record_fc_map_2, fcf_record, phba->fc_map[2]); in lpfc_sli4_build_dflt_fcf_record()
20052 if (phba->valid_vlan) { in lpfc_sli4_build_dflt_fcf_record()
20053 fcf_record->vlan_bitmap[phba->vlan_id / 8] in lpfc_sli4_build_dflt_fcf_record()
20054 = 1 << (phba->vlan_id % 8); in lpfc_sli4_build_dflt_fcf_record()
20059 * lpfc_sli4_fcf_scan_read_fcf_rec - Read hba fcf record for fcf scan.
20067 * Return 0 if the mailbox command is submitted successfully, none 0
20076 phba->fcoe_eventtag_at_fcf_scan = phba->fcoe_eventtag; in lpfc_sli4_fcf_scan_read_fcf_rec()
20077 phba->fcoe_cvl_eventtag_attn = phba->fcoe_cvl_eventtag; in lpfc_sli4_fcf_scan_read_fcf_rec()
20078 mboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_fcf_scan_read_fcf_rec()
20083 error = -ENOMEM; in lpfc_sli4_fcf_scan_read_fcf_rec()
20086 /* Construct the read FCF record mailbox command */ in lpfc_sli4_fcf_scan_read_fcf_rec()
20089 error = -EINVAL; in lpfc_sli4_fcf_scan_read_fcf_rec()
20092 /* Issue the mailbox command asynchronously */ in lpfc_sli4_fcf_scan_read_fcf_rec()
20093 mboxq->vport = phba->pport; in lpfc_sli4_fcf_scan_read_fcf_rec()
20094 mboxq->mbox_cmpl = lpfc_mbx_cmpl_fcf_scan_read_fcf_rec; in lpfc_sli4_fcf_scan_read_fcf_rec()
20096 spin_lock_irq(&phba->hbalock); in lpfc_sli4_fcf_scan_read_fcf_rec()
20097 phba->hba_flag |= FCF_TS_INPROG; in lpfc_sli4_fcf_scan_read_fcf_rec()
20098 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_fcf_scan_read_fcf_rec()
20102 error = -EIO; in lpfc_sli4_fcf_scan_read_fcf_rec()
20106 phba->fcf.eligible_fcf_cnt = 0; in lpfc_sli4_fcf_scan_read_fcf_rec()
20114 spin_lock_irq(&phba->hbalock); in lpfc_sli4_fcf_scan_read_fcf_rec()
20115 phba->hba_flag &= ~FCF_TS_INPROG; in lpfc_sli4_fcf_scan_read_fcf_rec()
20116 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_fcf_scan_read_fcf_rec()
20122 * lpfc_sli4_fcf_rr_read_fcf_rec - Read hba fcf record for roundrobin fcf.
20129 * Return 0 if the mailbox command is submitted successfully, none 0
20138 mboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_fcf_rr_read_fcf_rec()
20143 error = -ENOMEM; in lpfc_sli4_fcf_rr_read_fcf_rec()
20146 /* Construct the read FCF record mailbox command */ in lpfc_sli4_fcf_rr_read_fcf_rec()
20149 error = -EINVAL; in lpfc_sli4_fcf_rr_read_fcf_rec()
20152 /* Issue the mailbox command asynchronously */ in lpfc_sli4_fcf_rr_read_fcf_rec()
20153 mboxq->vport = phba->pport; in lpfc_sli4_fcf_rr_read_fcf_rec()
20154 mboxq->mbox_cmpl = lpfc_mbx_cmpl_fcf_rr_read_fcf_rec; in lpfc_sli4_fcf_rr_read_fcf_rec()
20157 error = -EIO; in lpfc_sli4_fcf_rr_read_fcf_rec()
20168 * lpfc_sli4_read_fcf_rec - Read hba fcf record for update eligible fcf bmask.
20175 * Return 0 if the mailbox command is submitted successfully, none 0
20184 mboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_read_fcf_rec()
20189 error = -ENOMEM; in lpfc_sli4_read_fcf_rec()
20192 /* Construct the read FCF record mailbox command */ in lpfc_sli4_read_fcf_rec()
20195 error = -EINVAL; in lpfc_sli4_read_fcf_rec()
20198 /* Issue the mailbox command asynchronously */ in lpfc_sli4_read_fcf_rec()
20199 mboxq->vport = phba->pport; in lpfc_sli4_read_fcf_rec()
20200 mboxq->mbox_cmpl = lpfc_mbx_cmpl_read_fcf_rec; in lpfc_sli4_read_fcf_rec()
20203 error = -EIO; in lpfc_sli4_read_fcf_rec()
20235 last_index = find_first_bit(phba->fcf.fcf_rr_bmask, in lpfc_check_next_fcf_pri_level()
20241 spin_lock_irq(&phba->hbalock); in lpfc_check_next_fcf_pri_level()
20242 if (list_empty(&phba->fcf.fcf_pri_list) || in lpfc_check_next_fcf_pri_level()
20243 list_is_singular(&phba->fcf.fcf_pri_list)) { in lpfc_check_next_fcf_pri_level()
20244 spin_unlock_irq(&phba->hbalock); in lpfc_check_next_fcf_pri_level()
20249 spin_unlock_irq(&phba->hbalock); in lpfc_check_next_fcf_pri_level()
20256 memset(phba->fcf.fcf_rr_bmask, 0, in lpfc_check_next_fcf_pri_level()
20257 sizeof(*phba->fcf.fcf_rr_bmask)); in lpfc_check_next_fcf_pri_level()
20258 spin_lock_irq(&phba->hbalock); in lpfc_check_next_fcf_pri_level()
20259 list_for_each_entry(fcf_pri, &phba->fcf.fcf_pri_list, list) { in lpfc_check_next_fcf_pri_level()
20260 if (fcf_pri->fcf_rec.flag & LPFC_FCF_FLOGI_FAILED) in lpfc_check_next_fcf_pri_level()
20267 next_fcf_pri = fcf_pri->fcf_rec.priority; in lpfc_check_next_fcf_pri_level()
20268 spin_unlock_irq(&phba->hbalock); in lpfc_check_next_fcf_pri_level()
20269 if (fcf_pri->fcf_rec.priority == next_fcf_pri) { in lpfc_check_next_fcf_pri_level()
20271 fcf_pri->fcf_rec.fcf_index); in lpfc_check_next_fcf_pri_level()
20275 spin_lock_irq(&phba->hbalock); in lpfc_check_next_fcf_pri_level()
20282 if (!next_fcf_pri && !list_empty(&phba->fcf.fcf_pri_list)) { in lpfc_check_next_fcf_pri_level()
20283 list_for_each_entry(fcf_pri, &phba->fcf.fcf_pri_list, list) { in lpfc_check_next_fcf_pri_level()
20284 fcf_pri->fcf_rec.flag &= ~LPFC_FCF_FLOGI_FAILED; in lpfc_check_next_fcf_pri_level()
20290 next_fcf_pri = fcf_pri->fcf_rec.priority; in lpfc_check_next_fcf_pri_level()
20291 spin_unlock_irq(&phba->hbalock); in lpfc_check_next_fcf_pri_level()
20292 if (fcf_pri->fcf_rec.priority == next_fcf_pri) { in lpfc_check_next_fcf_pri_level()
20294 fcf_pri->fcf_rec.fcf_index); in lpfc_check_next_fcf_pri_level()
20298 spin_lock_irq(&phba->hbalock); in lpfc_check_next_fcf_pri_level()
20302 spin_unlock_irq(&phba->hbalock); in lpfc_check_next_fcf_pri_level()
20307 * lpfc_sli4_fcf_rr_next_index_get - Get next eligible fcf record index
20323 next_fcf_index = phba->fcf.current_rec.fcf_indx; in lpfc_sli4_fcf_rr_next_index_get()
20328 next_fcf_index = find_next_bit(phba->fcf.fcf_rr_bmask, in lpfc_sli4_fcf_rr_next_index_get()
20332 /* Wrap around condition on phba->fcf.fcf_rr_bmask */ in lpfc_sli4_fcf_rr_next_index_get()
20339 next_fcf_index = find_first_bit(phba->fcf.fcf_rr_bmask, in lpfc_sli4_fcf_rr_next_index_get()
20346 next_fcf_index == phba->fcf.current_rec.fcf_indx) { in lpfc_sli4_fcf_rr_next_index_get()
20362 phba->fcf.fcf_pri[next_fcf_index].fcf_rec.flag & in lpfc_sli4_fcf_rr_next_index_get()
20364 if (list_is_singular(&phba->fcf.fcf_pri_list)) in lpfc_sli4_fcf_rr_next_index_get()
20378 * lpfc_sli4_fcf_rr_index_set - Set bmask with eligible fcf record index
20388 * -EINVAL.
20398 return -EINVAL; in lpfc_sli4_fcf_rr_index_set()
20401 set_bit(fcf_index, phba->fcf.fcf_rr_bmask); in lpfc_sli4_fcf_rr_index_set()
20411 * lpfc_sli4_fcf_rr_index_clear - Clear bmask from eligible fcf record index
20432 spin_lock_irq(&phba->hbalock); in lpfc_sli4_fcf_rr_index_clear()
20433 list_for_each_entry_safe(fcf_pri, fcf_pri_next, &phba->fcf.fcf_pri_list, in lpfc_sli4_fcf_rr_index_clear()
20435 if (fcf_pri->fcf_rec.fcf_index == fcf_index) { in lpfc_sli4_fcf_rr_index_clear()
20436 list_del_init(&fcf_pri->list); in lpfc_sli4_fcf_rr_index_clear()
20440 spin_unlock_irq(&phba->hbalock); in lpfc_sli4_fcf_rr_index_clear()
20441 clear_bit(fcf_index, phba->fcf.fcf_rr_bmask); in lpfc_sli4_fcf_rr_index_clear()
20449 * lpfc_mbx_cmpl_redisc_fcf_table - completion routine for rediscover FCF table
20453 * This routine is the completion routine for the rediscover FCF table mailbox
20454 * command. If the mailbox command returned failure, it will try to stop the
20463 redisc_fcf = &mbox->u.mqe.un.redisc_fcf_tbl; in lpfc_mbx_cmpl_redisc_fcf_table()
20466 &redisc_fcf->header.cfg_shdr.response); in lpfc_mbx_cmpl_redisc_fcf_table()
20468 &redisc_fcf->header.cfg_shdr.response); in lpfc_mbx_cmpl_redisc_fcf_table()
20474 if (phba->fcf.fcf_flag & FCF_ACVL_DISC) { in lpfc_mbx_cmpl_redisc_fcf_table()
20475 spin_lock_irq(&phba->hbalock); in lpfc_mbx_cmpl_redisc_fcf_table()
20476 phba->fcf.fcf_flag &= ~FCF_ACVL_DISC; in lpfc_mbx_cmpl_redisc_fcf_table()
20477 spin_unlock_irq(&phba->hbalock); in lpfc_mbx_cmpl_redisc_fcf_table()
20480 * last resort to re-try current registered FCF entry. in lpfc_mbx_cmpl_redisc_fcf_table()
20484 spin_lock_irq(&phba->hbalock); in lpfc_mbx_cmpl_redisc_fcf_table()
20485 phba->fcf.fcf_flag &= ~FCF_DEAD_DISC; in lpfc_mbx_cmpl_redisc_fcf_table()
20486 spin_unlock_irq(&phba->hbalock); in lpfc_mbx_cmpl_redisc_fcf_table()
20504 mempool_free(mbox, phba->mbox_mem_pool); in lpfc_mbx_cmpl_redisc_fcf_table()
20508 * lpfc_sli4_redisc_fcf_table - Request to rediscover entire FCF table by port.
20524 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_redisc_fcf_table()
20529 return -ENOMEM; in lpfc_sli4_redisc_fcf_table()
20532 length = (sizeof(struct lpfc_mbx_redisc_fcf_tbl) - in lpfc_sli4_redisc_fcf_table()
20538 redisc_fcf = &mbox->u.mqe.un.redisc_fcf_tbl; in lpfc_sli4_redisc_fcf_table()
20542 /* Issue the mailbox command asynchronously */ in lpfc_sli4_redisc_fcf_table()
20543 mbox->vport = phba->pport; in lpfc_sli4_redisc_fcf_table()
20544 mbox->mbox_cmpl = lpfc_mbx_cmpl_redisc_fcf_table; in lpfc_sli4_redisc_fcf_table()
20548 mempool_free(mbox, phba->mbox_mem_pool); in lpfc_sli4_redisc_fcf_table()
20549 return -EIO; in lpfc_sli4_redisc_fcf_table()
20555 * lpfc_sli4_fcf_dead_failthrough - Failthrough routine to fcf dead event
20571 link_state = phba->link_state; in lpfc_sli4_fcf_dead_failthrough()
20573 phba->link_state = link_state; in lpfc_sli4_fcf_dead_failthrough()
20580 * lpfc_sli_get_config_region23 - Get sli3 port region 23 data.
20585 * mailbox command. When it successfully retrieves data, the size of the data
20599 pmb = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli_get_config_region23()
20602 "2600 failed to allocate mailbox memory\n"); in lpfc_sli_get_config_region23()
20605 mb = &pmb->u.mb; in lpfc_sli_get_config_region23()
20615 rc, mb->mbxStatus); in lpfc_sli_get_config_region23()
20616 mb->un.varDmp.word_cnt = 0; in lpfc_sli_get_config_region23()
20620 * mailbox error, either way we are done. in lpfc_sli_get_config_region23()
20622 if (mb->un.varDmp.word_cnt == 0) in lpfc_sli_get_config_region23()
20625 if (mb->un.varDmp.word_cnt > DMP_RGN23_SIZE - offset) in lpfc_sli_get_config_region23()
20626 mb->un.varDmp.word_cnt = DMP_RGN23_SIZE - offset; in lpfc_sli_get_config_region23()
20630 mb->un.varDmp.word_cnt); in lpfc_sli_get_config_region23()
20631 offset += mb->un.varDmp.word_cnt; in lpfc_sli_get_config_region23()
20632 } while (mb->un.varDmp.word_cnt && offset < DMP_RGN23_SIZE); in lpfc_sli_get_config_region23()
20634 mempool_free(pmb, phba->mbox_mem_pool); in lpfc_sli_get_config_region23()
20639 * lpfc_sli4_get_config_region23 - Get sli4 port region 23 data.
20644 * mailbox command. When it successfully retrieves data, the size of the data
20659 mboxq = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_sli4_get_config_region23()
20662 "3105 failed to allocate mailbox memory\n"); in lpfc_sli4_get_config_region23()
20668 mqe = &mboxq->u.mqe; in lpfc_sli4_get_config_region23()
20669 mp = (struct lpfc_dmabuf *)mboxq->ctx_buf; in lpfc_sli4_get_config_region23()
20673 data_length = mqe->un.mb_words[5]; in lpfc_sli4_get_config_region23()
20680 lpfc_sli_pcimem_bcopy((char *)mp->virt, rgn23_data, data_length); in lpfc_sli4_get_config_region23()
20687 * lpfc_sli_read_link_ste - Read region 23 to decide if link is disabled.
20706 if (phba->sli_rev < LPFC_SLI_REV4) in lpfc_sli_read_link_ste()
20710 &phba->sli4_hba.sli_intf); in lpfc_sli_read_link_ste()
20756 * Search for configured port state sub-TLV. in lpfc_sli_read_link_ste()
20773 phba->hba_flag |= LINK_DISABLED; in lpfc_sli_read_link_ste()
20785 * lpfc_log_fw_write_cmpl - logs firmware write completion status
20806 phba->sli4_hba.flash_id, phba->sli4_hba.asic_rev, in lpfc_log_fw_write_cmpl()
20816 phba->sli4_hba.flash_id); in lpfc_log_fw_write_cmpl()
20823 phba->sli4_hba.asic_rev); in lpfc_log_fw_write_cmpl()
20870 * lpfc_wr_object - write an object to the firmware
20876 * This routine will create a wr_object mailbox command to send to the port.
20877 * the mailbox command will be constructed using the dma buffers described in
20879 * BDEs that the imbedded mailbox can support. The @offset variable will be
20881 * the offset after the write object mailbox has completed. @size is used to
20903 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_wr_object()
20905 return -ENOMEM; in lpfc_wr_object()
20909 sizeof(struct lpfc_mbx_wr_object) - in lpfc_wr_object()
20912 wr_object = (struct lpfc_mbx_wr_object *)&mbox->u.mqe.un.wr_object; in lpfc_wr_object()
20913 wr_object->u.request.write_offset = *offset; in lpfc_wr_object()
20914 sprintf((uint8_t *)wr_object->u.request.object_name, "/"); in lpfc_wr_object()
20915 wr_object->u.request.object_name[0] = in lpfc_wr_object()
20916 cpu_to_le32(wr_object->u.request.object_name[0]); in lpfc_wr_object()
20917 bf_set(lpfc_wr_object_eof, &wr_object->u.request, 0); in lpfc_wr_object()
20921 wr_object->u.request.bde[i].addrLow = putPaddrLow(dmabuf->phys); in lpfc_wr_object()
20922 wr_object->u.request.bde[i].addrHigh = in lpfc_wr_object()
20923 putPaddrHigh(dmabuf->phys); in lpfc_wr_object()
20925 wr_object->u.request.bde[i].tus.f.bdeSize = in lpfc_wr_object()
20926 (size - written); in lpfc_wr_object()
20927 written += (size - written); in lpfc_wr_object()
20928 bf_set(lpfc_wr_object_eof, &wr_object->u.request, 1); in lpfc_wr_object()
20929 bf_set(lpfc_wr_object_eas, &wr_object->u.request, 1); in lpfc_wr_object()
20932 wr_object->u.request.bde[i].tus.f.bdeSize = in lpfc_wr_object()
20938 wr_object->u.request.bde_count = i; in lpfc_wr_object()
20939 bf_set(lpfc_wr_object_write_length, &wr_object->u.request, written); in lpfc_wr_object()
20940 if (!phba->sli4_hba.intr_enable) in lpfc_wr_object()
20950 /* The IOCTL status is embedded in the mailbox subheader. */ in lpfc_wr_object()
20952 &wr_object->header.cfg_shdr.response); in lpfc_wr_object()
20954 &wr_object->header.cfg_shdr.response); in lpfc_wr_object()
20956 &wr_object->header.cfg_shdr.response); in lpfc_wr_object()
20959 &wr_object->u.response); in lpfc_wr_object()
20961 &wr_object->u.response); in lpfc_wr_object()
20966 "3025 Write Object mailbox failed with " in lpfc_wr_object()
20971 rc = -ENXIO; in lpfc_wr_object()
20974 *offset += wr_object->u.response.actual_write_length; in lpfc_wr_object()
20982 if (!phba->sli4_hba.intr_enable) in lpfc_wr_object()
20983 mempool_free(mbox, phba->mbox_mem_pool); in lpfc_wr_object()
20985 mempool_free(mbox, phba->mbox_mem_pool); in lpfc_wr_object()
20991 * lpfc_cleanup_pending_mbox - Free up vport discovery mailbox commands.
20995 * and REG_VPI mailbox commands associated with the vport. This function
21002 struct lpfc_hba *phba = vport->phba; in lpfc_cleanup_pending_mbox()
21009 /* Clean up internally queued mailbox commands with the vport */ in lpfc_cleanup_pending_mbox()
21010 spin_lock_irq(&phba->hbalock); in lpfc_cleanup_pending_mbox()
21011 list_for_each_entry_safe(mb, nextmb, &phba->sli.mboxq, list) { in lpfc_cleanup_pending_mbox()
21012 if (mb->vport != vport) in lpfc_cleanup_pending_mbox()
21015 if ((mb->u.mb.mbxCommand != MBX_REG_LOGIN64) && in lpfc_cleanup_pending_mbox()
21016 (mb->u.mb.mbxCommand != MBX_REG_VPI)) in lpfc_cleanup_pending_mbox()
21019 list_move_tail(&mb->list, &mbox_cmd_list); in lpfc_cleanup_pending_mbox()
21021 /* Clean up active mailbox command with the vport */ in lpfc_cleanup_pending_mbox()
21022 mb = phba->sli.mbox_active; in lpfc_cleanup_pending_mbox()
21023 if (mb && (mb->vport == vport)) { in lpfc_cleanup_pending_mbox()
21024 if ((mb->u.mb.mbxCommand == MBX_REG_LOGIN64) || in lpfc_cleanup_pending_mbox()
21025 (mb->u.mb.mbxCommand == MBX_REG_VPI)) in lpfc_cleanup_pending_mbox()
21026 mb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_cleanup_pending_mbox()
21027 if (mb->u.mb.mbxCommand == MBX_REG_LOGIN64) { in lpfc_cleanup_pending_mbox()
21028 act_mbx_ndlp = (struct lpfc_nodelist *)mb->ctx_ndlp; in lpfc_cleanup_pending_mbox()
21035 /* Unregister the RPI when mailbox complete */ in lpfc_cleanup_pending_mbox()
21036 mb->mbox_flag |= LPFC_MBX_IMED_UNREG; in lpfc_cleanup_pending_mbox()
21039 /* Cleanup any mailbox completions which are not yet processed */ in lpfc_cleanup_pending_mbox()
21042 list_for_each_entry(mb, &phba->sli.mboxq_cmpl, list) { in lpfc_cleanup_pending_mbox()
21047 if ((mb->vport != vport) || in lpfc_cleanup_pending_mbox()
21048 (mb->mbox_flag & LPFC_MBX_IMED_UNREG)) in lpfc_cleanup_pending_mbox()
21051 if ((mb->u.mb.mbxCommand != MBX_REG_LOGIN64) && in lpfc_cleanup_pending_mbox()
21052 (mb->u.mb.mbxCommand != MBX_REG_VPI)) in lpfc_cleanup_pending_mbox()
21055 mb->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_cleanup_pending_mbox()
21056 if (mb->u.mb.mbxCommand == MBX_REG_LOGIN64) { in lpfc_cleanup_pending_mbox()
21057 ndlp = (struct lpfc_nodelist *)mb->ctx_ndlp; in lpfc_cleanup_pending_mbox()
21058 /* Unregister the RPI when mailbox complete */ in lpfc_cleanup_pending_mbox()
21059 mb->mbox_flag |= LPFC_MBX_IMED_UNREG; in lpfc_cleanup_pending_mbox()
21061 spin_unlock_irq(&phba->hbalock); in lpfc_cleanup_pending_mbox()
21062 spin_lock(&ndlp->lock); in lpfc_cleanup_pending_mbox()
21063 ndlp->nlp_flag &= ~NLP_IGNR_REG_CMPL; in lpfc_cleanup_pending_mbox()
21064 spin_unlock(&ndlp->lock); in lpfc_cleanup_pending_mbox()
21065 spin_lock_irq(&phba->hbalock); in lpfc_cleanup_pending_mbox()
21071 spin_unlock_irq(&phba->hbalock); in lpfc_cleanup_pending_mbox()
21073 /* Release the cleaned-up mailbox commands */ in lpfc_cleanup_pending_mbox()
21076 if (mb->u.mb.mbxCommand == MBX_REG_LOGIN64) { in lpfc_cleanup_pending_mbox()
21077 ndlp = (struct lpfc_nodelist *)mb->ctx_ndlp; in lpfc_cleanup_pending_mbox()
21078 mb->ctx_ndlp = NULL; in lpfc_cleanup_pending_mbox()
21080 spin_lock(&ndlp->lock); in lpfc_cleanup_pending_mbox()
21081 ndlp->nlp_flag &= ~NLP_IGNR_REG_CMPL; in lpfc_cleanup_pending_mbox()
21082 spin_unlock(&ndlp->lock); in lpfc_cleanup_pending_mbox()
21089 /* Release the ndlp with the cleaned-up active mailbox command */ in lpfc_cleanup_pending_mbox()
21091 spin_lock(&act_mbx_ndlp->lock); in lpfc_cleanup_pending_mbox()
21092 act_mbx_ndlp->nlp_flag &= ~NLP_IGNR_REG_CMPL; in lpfc_cleanup_pending_mbox()
21093 spin_unlock(&act_mbx_ndlp->lock); in lpfc_cleanup_pending_mbox()
21099 * lpfc_drain_txq - Drain the txq
21121 if (phba->link_flag & LS_MDS_LOOPBACK) { in lpfc_drain_txq()
21123 wq = phba->sli4_hba.hdwq[0].io_wq; in lpfc_drain_txq()
21126 pring = wq->pring; in lpfc_drain_txq()
21128 wq = phba->sli4_hba.els_wq; in lpfc_drain_txq()
21134 if (unlikely(!pring) || list_empty(&pring->txq)) in lpfc_drain_txq()
21137 spin_lock_irqsave(&pring->ring_lock, iflags); in lpfc_drain_txq()
21138 list_for_each_entry(piocbq, &pring->txq, list) { in lpfc_drain_txq()
21142 if (txq_cnt > pring->txq_max) in lpfc_drain_txq()
21143 pring->txq_max = txq_cnt; in lpfc_drain_txq()
21145 spin_unlock_irqrestore(&pring->ring_lock, iflags); in lpfc_drain_txq()
21147 while (!list_empty(&pring->txq)) { in lpfc_drain_txq()
21148 spin_lock_irqsave(&pring->ring_lock, iflags); in lpfc_drain_txq()
21152 spin_unlock_irqrestore(&pring->ring_lock, iflags); in lpfc_drain_txq()
21158 txq_cnt--; in lpfc_drain_txq()
21160 ret = __lpfc_sli_issue_iocb(phba, pring->ringno, piocbq, 0); in lpfc_drain_txq()
21163 fail_msg = " - Cannot send IO "; in lpfc_drain_txq()
21164 piocbq->cmd_flag &= ~LPFC_DRIVER_ABORTED; in lpfc_drain_txq()
21167 piocbq->cmd_flag |= LPFC_DRIVER_ABORTED; in lpfc_drain_txq()
21172 fail_msg, piocbq->iotag, in lpfc_drain_txq()
21173 piocbq->sli4_xritag, ret, in lpfc_drain_txq()
21174 piocbq->cmd_flag); in lpfc_drain_txq()
21175 list_add_tail(&piocbq->list, &completions); in lpfc_drain_txq()
21178 spin_unlock_irqrestore(&pring->ring_lock, iflags); in lpfc_drain_txq()
21190 * lpfc_wqe_bpl2sgl - Convert the bpl/bde to a sgl.
21225 sgl = (struct sli4_sge *)sglq->sgl; in lpfc_wqe_bpl2sgl()
21226 wqe = &pwqeq->wqe; in lpfc_wqe_bpl2sgl()
21227 pwqeq->iocb.ulpIoTag = pwqeq->iotag; in lpfc_wqe_bpl2sgl()
21229 cmd = bf_get(wqe_cmnd, &wqe->generic.wqe_com); in lpfc_wqe_bpl2sgl()
21231 return sglq->sli4_xritag; in lpfc_wqe_bpl2sgl()
21232 numBdes = pwqeq->num_bdes; in lpfc_wqe_bpl2sgl()
21238 if (pwqeq->bpl_dmabuf) in lpfc_wqe_bpl2sgl()
21239 dmabuf = pwqeq->bpl_dmabuf; in lpfc_wqe_bpl2sgl()
21243 bpl = (struct ulp_bde64 *)dmabuf->virt; in lpfc_wqe_bpl2sgl()
21249 sgl->addr_hi = bpl->addrHigh; in lpfc_wqe_bpl2sgl()
21250 sgl->addr_lo = bpl->addrLow; in lpfc_wqe_bpl2sgl()
21252 sgl->word2 = le32_to_cpu(sgl->word2); in lpfc_wqe_bpl2sgl()
21260 bde.tus.w = le32_to_cpu(bpl->tus.w); in lpfc_wqe_bpl2sgl()
21261 sgl->sge_len = cpu_to_le32(bde.tus.f.bdeSize); in lpfc_wqe_bpl2sgl()
21269 if (bpl->tus.f.bdeFlags == BUFF_TYPE_BDE_64I) in lpfc_wqe_bpl2sgl()
21287 bpl->tus.f.bdeFlags); in lpfc_wqe_bpl2sgl()
21295 sgl->word2 = cpu_to_le32(sgl->word2); in lpfc_wqe_bpl2sgl()
21299 } else if (wqe->gen_req.bde.tus.f.bdeFlags == BUFF_TYPE_BDE_64) { in lpfc_wqe_bpl2sgl()
21304 sgl->addr_hi = cpu_to_le32(wqe->gen_req.bde.addrHigh); in lpfc_wqe_bpl2sgl()
21305 sgl->addr_lo = cpu_to_le32(wqe->gen_req.bde.addrLow); in lpfc_wqe_bpl2sgl()
21306 sgl->word2 = le32_to_cpu(sgl->word2); in lpfc_wqe_bpl2sgl()
21308 sgl->word2 = cpu_to_le32(sgl->word2); in lpfc_wqe_bpl2sgl()
21309 sgl->sge_len = cpu_to_le32(wqe->gen_req.bde.tus.f.bdeSize); in lpfc_wqe_bpl2sgl()
21311 return sglq->sli4_xritag; in lpfc_wqe_bpl2sgl()
21315 * lpfc_sli4_issue_wqe - Issue an SLI4 Work Queue Entry (WQE)
21324 union lpfc_wqe128 *wqe = &pwqe->wqe; in lpfc_sli4_issue_wqe()
21333 if (pwqe->cmd_flag & LPFC_IO_NVME_LS) { in lpfc_sli4_issue_wqe()
21334 pring = phba->sli4_hba.nvmels_wq->pring; in lpfc_sli4_issue_wqe()
21335 lpfc_qp_spin_lock_irqsave(&pring->ring_lock, iflags, in lpfc_sli4_issue_wqe()
21339 spin_unlock_irqrestore(&pring->ring_lock, iflags); in lpfc_sli4_issue_wqe()
21342 pwqe->sli4_lxritag = sglq->sli4_lxritag; in lpfc_sli4_issue_wqe()
21343 pwqe->sli4_xritag = sglq->sli4_xritag; in lpfc_sli4_issue_wqe()
21345 spin_unlock_irqrestore(&pring->ring_lock, iflags); in lpfc_sli4_issue_wqe()
21348 bf_set(wqe_xri_tag, &pwqe->wqe.xmit_bls_rsp.wqe_com, in lpfc_sli4_issue_wqe()
21349 pwqe->sli4_xritag); in lpfc_sli4_issue_wqe()
21350 ret = lpfc_sli4_wq_put(phba->sli4_hba.nvmels_wq, wqe); in lpfc_sli4_issue_wqe()
21352 spin_unlock_irqrestore(&pring->ring_lock, iflags); in lpfc_sli4_issue_wqe()
21357 spin_unlock_irqrestore(&pring->ring_lock, iflags); in lpfc_sli4_issue_wqe()
21359 lpfc_sli4_poll_eq(qp->hba_eq); in lpfc_sli4_issue_wqe()
21364 if (pwqe->cmd_flag & (LPFC_IO_NVME | LPFC_IO_FCP | LPFC_IO_CMF)) { in lpfc_sli4_issue_wqe()
21366 wq = qp->io_wq; in lpfc_sli4_issue_wqe()
21367 pring = wq->pring; in lpfc_sli4_issue_wqe()
21369 bf_set(wqe_cqid, &wqe->generic.wqe_com, qp->io_cq_map); in lpfc_sli4_issue_wqe()
21371 lpfc_qp_spin_lock_irqsave(&pring->ring_lock, iflags, in lpfc_sli4_issue_wqe()
21375 spin_unlock_irqrestore(&pring->ring_lock, iflags); in lpfc_sli4_issue_wqe()
21379 spin_unlock_irqrestore(&pring->ring_lock, iflags); in lpfc_sli4_issue_wqe()
21381 lpfc_sli4_poll_eq(qp->hba_eq); in lpfc_sli4_issue_wqe()
21386 if (pwqe->cmd_flag & LPFC_IO_NVMET) { in lpfc_sli4_issue_wqe()
21388 wq = qp->io_wq; in lpfc_sli4_issue_wqe()
21389 pring = wq->pring; in lpfc_sli4_issue_wqe()
21391 ctxp = pwqe->context_un.axchg; in lpfc_sli4_issue_wqe()
21392 sglq = ctxp->ctxbuf->sglq; in lpfc_sli4_issue_wqe()
21393 if (pwqe->sli4_xritag == NO_XRI) { in lpfc_sli4_issue_wqe()
21394 pwqe->sli4_lxritag = sglq->sli4_lxritag; in lpfc_sli4_issue_wqe()
21395 pwqe->sli4_xritag = sglq->sli4_xritag; in lpfc_sli4_issue_wqe()
21397 bf_set(wqe_xri_tag, &pwqe->wqe.xmit_bls_rsp.wqe_com, in lpfc_sli4_issue_wqe()
21398 pwqe->sli4_xritag); in lpfc_sli4_issue_wqe()
21399 bf_set(wqe_cqid, &wqe->generic.wqe_com, qp->io_cq_map); in lpfc_sli4_issue_wqe()
21401 lpfc_qp_spin_lock_irqsave(&pring->ring_lock, iflags, in lpfc_sli4_issue_wqe()
21405 spin_unlock_irqrestore(&pring->ring_lock, iflags); in lpfc_sli4_issue_wqe()
21409 spin_unlock_irqrestore(&pring->ring_lock, iflags); in lpfc_sli4_issue_wqe()
21411 lpfc_sli4_poll_eq(qp->hba_eq); in lpfc_sli4_issue_wqe()
21418 * lpfc_sli4_issue_abort_iotag - SLI-4 WQE init & issue for the Abort
21427 * RETURNS 0 - SUCCESS
21434 struct lpfc_vport *vport = cmdiocb->vport; in lpfc_sli4_issue_abort_iotag()
21439 u16 xritag = cmdiocb->sli4_xritag; in lpfc_sli4_issue_abort_iotag()
21452 cmdiocb->cmd_flag |= LPFC_DRIVER_ABORTED; in lpfc_sli4_issue_abort_iotag()
21454 abtswqe = &abtsiocb->wqe; in lpfc_sli4_issue_abort_iotag()
21457 if (!lpfc_is_link_up(phba) || (phba->link_flag & LS_EXTERNAL_LOOPBACK)) in lpfc_sli4_issue_abort_iotag()
21458 bf_set(abort_cmd_ia, &abtswqe->abort_cmd, 1); in lpfc_sli4_issue_abort_iotag()
21459 bf_set(abort_cmd_criteria, &abtswqe->abort_cmd, T_XRI_TAG); in lpfc_sli4_issue_abort_iotag()
21460 abtswqe->abort_cmd.rsrvd5 = 0; in lpfc_sli4_issue_abort_iotag()
21461 abtswqe->abort_cmd.wqe_com.abort_tag = xritag; in lpfc_sli4_issue_abort_iotag()
21462 bf_set(wqe_reqtag, &abtswqe->abort_cmd.wqe_com, abtsiocb->iotag); in lpfc_sli4_issue_abort_iotag()
21463 bf_set(wqe_cmnd, &abtswqe->abort_cmd.wqe_com, CMD_ABORT_XRI_CX); in lpfc_sli4_issue_abort_iotag()
21464 bf_set(wqe_xri_tag, &abtswqe->generic.wqe_com, 0); in lpfc_sli4_issue_abort_iotag()
21465 bf_set(wqe_qosd, &abtswqe->abort_cmd.wqe_com, 1); in lpfc_sli4_issue_abort_iotag()
21466 bf_set(wqe_lenloc, &abtswqe->abort_cmd.wqe_com, LPFC_WQE_LENLOC_NONE); in lpfc_sli4_issue_abort_iotag()
21467 bf_set(wqe_cmd_type, &abtswqe->abort_cmd.wqe_com, OTHER_COMMAND); in lpfc_sli4_issue_abort_iotag()
21470 abtsiocb->hba_wqidx = cmdiocb->hba_wqidx; in lpfc_sli4_issue_abort_iotag()
21471 abtsiocb->cmd_flag |= LPFC_USE_FCPWQIDX; in lpfc_sli4_issue_abort_iotag()
21472 if (cmdiocb->cmd_flag & LPFC_IO_FCP) in lpfc_sli4_issue_abort_iotag()
21473 abtsiocb->cmd_flag |= LPFC_IO_FCP; in lpfc_sli4_issue_abort_iotag()
21474 if (cmdiocb->cmd_flag & LPFC_IO_NVME) in lpfc_sli4_issue_abort_iotag()
21475 abtsiocb->cmd_flag |= LPFC_IO_NVME; in lpfc_sli4_issue_abort_iotag()
21476 if (cmdiocb->cmd_flag & LPFC_IO_FOF) in lpfc_sli4_issue_abort_iotag()
21477 abtsiocb->cmd_flag |= LPFC_IO_FOF; in lpfc_sli4_issue_abort_iotag()
21478 abtsiocb->vport = vport; in lpfc_sli4_issue_abort_iotag()
21479 abtsiocb->cmd_cmpl = cmpl; in lpfc_sli4_issue_abort_iotag()
21482 retval = lpfc_sli4_issue_wqe(phba, lpfc_cmd->hdwq, abtsiocb); in lpfc_sli4_issue_abort_iotag()
21487 xritag, cmdiocb->iotag, abtsiocb->iotag, retval); in lpfc_sli4_issue_abort_iotag()
21490 cmdiocb->cmd_flag &= ~LPFC_DRIVER_ABORTED; in lpfc_sli4_issue_abort_iotag()
21499 * lpfc_snapshot_mxp - Snapshot pbl, pvt and busy count
21520 qp = &phba->sli4_hba.hdwq[hwqid]; in lpfc_snapshot_mxp()
21521 multixri_pool = qp->p_multixri_pool; in lpfc_snapshot_mxp()
21525 if (multixri_pool->stat_snapshot_taken == LPFC_MXP_SNAPSHOT_TAKEN) { in lpfc_snapshot_mxp()
21526 pvt_pool = &qp->p_multixri_pool->pvt_pool; in lpfc_snapshot_mxp()
21527 pbl_pool = &qp->p_multixri_pool->pbl_pool; in lpfc_snapshot_mxp()
21528 txcmplq_cnt = qp->io_wq->pring->txcmplq_cnt; in lpfc_snapshot_mxp()
21530 multixri_pool->stat_pbl_count = pbl_pool->count; in lpfc_snapshot_mxp()
21531 multixri_pool->stat_pvt_count = pvt_pool->count; in lpfc_snapshot_mxp()
21532 multixri_pool->stat_busy_count = txcmplq_cnt; in lpfc_snapshot_mxp()
21535 multixri_pool->stat_snapshot_taken++; in lpfc_snapshot_mxp()
21540 * lpfc_adjust_pvt_pool_count - Adjust private pool count
21553 multixri_pool = phba->sli4_hba.hdwq[hwqid].p_multixri_pool; in lpfc_adjust_pvt_pool_count()
21556 io_req_count = multixri_pool->io_req_count; in lpfc_adjust_pvt_pool_count()
21557 prev_io_req_count = multixri_pool->prev_io_req_count; in lpfc_adjust_pvt_pool_count()
21561 multixri_pool->prev_io_req_count = io_req_count; in lpfc_adjust_pvt_pool_count()
21571 * lpfc_adjust_high_watermark - Adjust high watermark
21589 qp = &phba->sli4_hba.hdwq[hwqid]; in lpfc_adjust_high_watermark()
21590 multixri_pool = qp->p_multixri_pool; in lpfc_adjust_high_watermark()
21593 xri_limit = multixri_pool->xri_limit; in lpfc_adjust_high_watermark()
21598 txcmplq_cnt = qp->io_wq->pring->txcmplq_cnt; in lpfc_adjust_high_watermark()
21599 abts_io_bufs = qp->abts_scsi_io_bufs; in lpfc_adjust_high_watermark()
21600 abts_io_bufs += qp->abts_nvme_io_bufs; in lpfc_adjust_high_watermark()
21605 multixri_pool->pvt_pool.high_watermark = new_watermark; in lpfc_adjust_high_watermark()
21608 multixri_pool->stat_max_hwm = max(multixri_pool->stat_max_hwm, in lpfc_adjust_high_watermark()
21614 * lpfc_move_xri_pvt_to_pbl - Move some XRIs from private to public pool
21620 * The first step moves (all - low_watermark) amount of XRIs.
21634 qp = &phba->sli4_hba.hdwq[hwqid]; in lpfc_move_xri_pvt_to_pbl()
21635 pbl_pool = &qp->p_multixri_pool->pbl_pool; in lpfc_move_xri_pvt_to_pbl()
21636 pvt_pool = &qp->p_multixri_pool->pvt_pool; in lpfc_move_xri_pvt_to_pbl()
21639 lpfc_qp_spin_lock_irqsave(&pbl_pool->lock, iflag, qp, mv_to_pub_pool); in lpfc_move_xri_pvt_to_pbl()
21640 lpfc_qp_spin_lock(&pvt_pool->lock, qp, mv_from_pvt_pool); in lpfc_move_xri_pvt_to_pbl()
21642 if (pvt_pool->count > pvt_pool->low_watermark) { in lpfc_move_xri_pvt_to_pbl()
21643 /* Step 1: move (all - low_watermark) from pvt_pool in lpfc_move_xri_pvt_to_pbl()
21650 &pvt_pool->list, list) { in lpfc_move_xri_pvt_to_pbl()
21651 list_move_tail(&lpfc_ncmd->list, &tmp_list); in lpfc_move_xri_pvt_to_pbl()
21653 if (tmp_count >= pvt_pool->low_watermark) in lpfc_move_xri_pvt_to_pbl()
21658 list_splice_init(&pvt_pool->list, &pbl_pool->list); in lpfc_move_xri_pvt_to_pbl()
21661 list_splice(&tmp_list, &pvt_pool->list); in lpfc_move_xri_pvt_to_pbl()
21663 pbl_pool->count += (pvt_pool->count - tmp_count); in lpfc_move_xri_pvt_to_pbl()
21664 pvt_pool->count = tmp_count; in lpfc_move_xri_pvt_to_pbl()
21667 list_splice_init(&pvt_pool->list, &pbl_pool->list); in lpfc_move_xri_pvt_to_pbl()
21668 pbl_pool->count += pvt_pool->count; in lpfc_move_xri_pvt_to_pbl()
21669 pvt_pool->count = 0; in lpfc_move_xri_pvt_to_pbl()
21672 spin_unlock(&pvt_pool->lock); in lpfc_move_xri_pvt_to_pbl()
21673 spin_unlock_irqrestore(&pbl_pool->lock, iflag); in lpfc_move_xri_pvt_to_pbl()
21677 * _lpfc_move_xri_pbl_to_pvt - Move some XRIs from public to private pool
21689 * true - if XRIs are successfully moved from the specified pbl_pool to the
21691 * false - if the specified pbl_pool is empty or locked by someone else
21703 ret = spin_trylock_irqsave(&pbl_pool->lock, iflag); in _lpfc_move_xri_pbl_to_pvt()
21705 if (pbl_pool->count) { in _lpfc_move_xri_pbl_to_pvt()
21707 lpfc_qp_spin_lock(&pvt_pool->lock, qp, mv_to_pvt_pool); in _lpfc_move_xri_pbl_to_pvt()
21710 &pbl_pool->list, in _lpfc_move_xri_pbl_to_pvt()
21712 list_move_tail(&lpfc_ncmd->list, in _lpfc_move_xri_pbl_to_pvt()
21713 &pvt_pool->list); in _lpfc_move_xri_pbl_to_pvt()
21714 pvt_pool->count++; in _lpfc_move_xri_pbl_to_pvt()
21715 pbl_pool->count--; in _lpfc_move_xri_pbl_to_pvt()
21716 count--; in _lpfc_move_xri_pbl_to_pvt()
21721 spin_unlock(&pvt_pool->lock); in _lpfc_move_xri_pbl_to_pvt()
21722 spin_unlock_irqrestore(&pbl_pool->lock, iflag); in _lpfc_move_xri_pbl_to_pvt()
21725 spin_unlock_irqrestore(&pbl_pool->lock, iflag); in _lpfc_move_xri_pbl_to_pvt()
21732 * lpfc_move_xri_pbl_to_pvt - Move some XRIs from public to private pool
21754 qp = &phba->sli4_hba.hdwq[hwqid]; in lpfc_move_xri_pbl_to_pvt()
21755 multixri_pool = qp->p_multixri_pool; in lpfc_move_xri_pbl_to_pvt()
21756 pvt_pool = &multixri_pool->pvt_pool; in lpfc_move_xri_pbl_to_pvt()
21757 pbl_pool = &multixri_pool->pbl_pool; in lpfc_move_xri_pbl_to_pvt()
21763 multixri_pool->local_pbl_hit_count++; in lpfc_move_xri_pbl_to_pvt()
21768 hwq_count = phba->cfg_hdw_queue; in lpfc_move_xri_pbl_to_pvt()
21771 next_hwqid = multixri_pool->rrb_next_hwqid; in lpfc_move_xri_pbl_to_pvt()
21778 phba->sli4_hba.hdwq[next_hwqid].p_multixri_pool; in lpfc_move_xri_pbl_to_pvt()
21779 pbl_pool = &next_multixri_pool->pbl_pool; in lpfc_move_xri_pbl_to_pvt()
21785 /* Exit while-loop if success or all hwqid are checked */ in lpfc_move_xri_pbl_to_pvt()
21786 } while (!ret && next_hwqid != multixri_pool->rrb_next_hwqid); in lpfc_move_xri_pbl_to_pvt()
21789 multixri_pool->rrb_next_hwqid = next_hwqid; in lpfc_move_xri_pbl_to_pvt()
21793 multixri_pool->pbl_empty_count++; in lpfc_move_xri_pbl_to_pvt()
21799 multixri_pool->local_pbl_hit_count++; in lpfc_move_xri_pbl_to_pvt()
21801 multixri_pool->other_pbl_hit_count++; in lpfc_move_xri_pbl_to_pvt()
21807 * lpfc_keep_pvt_pool_above_lowwm - Keep pvt_pool above low watermark
21819 multixri_pool = phba->sli4_hba.hdwq[hwqid].p_multixri_pool; in lpfc_keep_pvt_pool_above_lowwm()
21820 pvt_pool = &multixri_pool->pvt_pool; in lpfc_keep_pvt_pool_above_lowwm()
21822 if (pvt_pool->count < pvt_pool->low_watermark) in lpfc_keep_pvt_pool_above_lowwm()
21827 * lpfc_release_io_buf - Return one IO buf back to free pool
21851 lpfc_ncmd->nvmeCmd = NULL; in lpfc_release_io_buf()
21852 lpfc_ncmd->cur_iocbq.cmd_cmpl = NULL; in lpfc_release_io_buf()
21854 if (phba->cfg_xpsgl && !phba->nvmet_support && in lpfc_release_io_buf()
21855 !list_empty(&lpfc_ncmd->dma_sgl_xtra_list)) in lpfc_release_io_buf()
21858 if (!list_empty(&lpfc_ncmd->dma_cmd_rsp_list)) in lpfc_release_io_buf()
21861 if (phba->cfg_xri_rebalancing) { in lpfc_release_io_buf()
21862 if (lpfc_ncmd->expedite) { in lpfc_release_io_buf()
21864 epd_pool = &phba->epd_pool; in lpfc_release_io_buf()
21865 spin_lock_irqsave(&epd_pool->lock, iflag); in lpfc_release_io_buf()
21866 list_add_tail(&lpfc_ncmd->list, &epd_pool->list); in lpfc_release_io_buf()
21867 epd_pool->count++; in lpfc_release_io_buf()
21868 spin_unlock_irqrestore(&epd_pool->lock, iflag); in lpfc_release_io_buf()
21876 if (!qp->p_multixri_pool) in lpfc_release_io_buf()
21879 pbl_pool = &qp->p_multixri_pool->pbl_pool; in lpfc_release_io_buf()
21880 pvt_pool = &qp->p_multixri_pool->pvt_pool; in lpfc_release_io_buf()
21882 txcmplq_cnt = qp->io_wq->pring->txcmplq_cnt; in lpfc_release_io_buf()
21883 abts_io_bufs = qp->abts_scsi_io_bufs; in lpfc_release_io_buf()
21884 abts_io_bufs += qp->abts_nvme_io_bufs; in lpfc_release_io_buf()
21886 xri_owned = pvt_pool->count + txcmplq_cnt + abts_io_bufs; in lpfc_release_io_buf()
21887 xri_limit = qp->p_multixri_pool->xri_limit; in lpfc_release_io_buf()
21891 qp->p_multixri_pool->below_limit_count++; in lpfc_release_io_buf()
21893 qp->p_multixri_pool->above_limit_count++; in lpfc_release_io_buf()
21899 if ((pvt_pool->count < pvt_pool->low_watermark) || in lpfc_release_io_buf()
21901 pvt_pool->count < pvt_pool->high_watermark)) { in lpfc_release_io_buf()
21902 lpfc_qp_spin_lock_irqsave(&pvt_pool->lock, iflag, in lpfc_release_io_buf()
21904 list_add_tail(&lpfc_ncmd->list, in lpfc_release_io_buf()
21905 &pvt_pool->list); in lpfc_release_io_buf()
21906 pvt_pool->count++; in lpfc_release_io_buf()
21907 spin_unlock_irqrestore(&pvt_pool->lock, iflag); in lpfc_release_io_buf()
21909 lpfc_qp_spin_lock_irqsave(&pbl_pool->lock, iflag, in lpfc_release_io_buf()
21911 list_add_tail(&lpfc_ncmd->list, in lpfc_release_io_buf()
21912 &pbl_pool->list); in lpfc_release_io_buf()
21913 pbl_pool->count++; in lpfc_release_io_buf()
21914 spin_unlock_irqrestore(&pbl_pool->lock, iflag); in lpfc_release_io_buf()
21917 lpfc_qp_spin_lock_irqsave(&qp->io_buf_list_put_lock, iflag, in lpfc_release_io_buf()
21919 list_add_tail(&lpfc_ncmd->list, in lpfc_release_io_buf()
21920 &qp->lpfc_io_buf_list_put); in lpfc_release_io_buf()
21921 qp->put_io_bufs++; in lpfc_release_io_buf()
21922 spin_unlock_irqrestore(&qp->io_buf_list_put_lock, in lpfc_release_io_buf()
21928 * lpfc_get_io_buf_from_private_pool - Get one free IO buf from private pool
21937 * pointer to one free IO buf - if private pool is not empty
21938 * NULL - if private pool is empty
21950 lpfc_qp_spin_lock_irqsave(&pvt_pool->lock, iflag, qp, alloc_pvt_pool); in lpfc_get_io_buf_from_private_pool()
21952 &pvt_pool->list, list) { in lpfc_get_io_buf_from_private_pool()
21954 phba, ndlp, lpfc_ncmd->cur_iocbq.sli4_lxritag)) in lpfc_get_io_buf_from_private_pool()
21956 list_del(&lpfc_ncmd->list); in lpfc_get_io_buf_from_private_pool()
21957 pvt_pool->count--; in lpfc_get_io_buf_from_private_pool()
21958 spin_unlock_irqrestore(&pvt_pool->lock, iflag); in lpfc_get_io_buf_from_private_pool()
21961 spin_unlock_irqrestore(&pvt_pool->lock, iflag); in lpfc_get_io_buf_from_private_pool()
21967 * lpfc_get_io_buf_from_expedite_pool - Get one free IO buf from expedite pool
21973 * pointer to one free IO buf - if expedite pool is not empty
21974 * NULL - if expedite pool is empty
21984 epd_pool = &phba->epd_pool; in lpfc_get_io_buf_from_expedite_pool()
21986 spin_lock_irqsave(&epd_pool->lock, iflag); in lpfc_get_io_buf_from_expedite_pool()
21987 if (epd_pool->count > 0) { in lpfc_get_io_buf_from_expedite_pool()
21989 &epd_pool->list, list) { in lpfc_get_io_buf_from_expedite_pool()
21990 list_del(&iter->list); in lpfc_get_io_buf_from_expedite_pool()
21991 epd_pool->count--; in lpfc_get_io_buf_from_expedite_pool()
21996 spin_unlock_irqrestore(&epd_pool->lock, iflag); in lpfc_get_io_buf_from_expedite_pool()
22002 * lpfc_get_io_buf_from_multixri_pools - Get one free IO bufs
22021 * pointer to one free IO buf - if private pool is not empty
22022 * NULL - if private pool is empty
22034 qp = &phba->sli4_hba.hdwq[hwqid]; in lpfc_get_io_buf_from_multixri_pools()
22042 multixri_pool = qp->p_multixri_pool; in lpfc_get_io_buf_from_multixri_pools()
22049 pvt_pool = &multixri_pool->pvt_pool; in lpfc_get_io_buf_from_multixri_pools()
22056 multixri_pool->io_req_count++; in lpfc_get_io_buf_from_multixri_pools()
22059 if (pvt_pool->count == 0) in lpfc_get_io_buf_from_multixri_pools()
22066 lpfc_ncmd->hdwq = qp; in lpfc_get_io_buf_from_multixri_pools()
22067 lpfc_ncmd->hdwq_no = hwqid; in lpfc_get_io_buf_from_multixri_pools()
22084 qp = &phba->sli4_hba.hdwq[idx]; in lpfc_io_buf()
22086 &qp->lpfc_io_buf_list_get, list) { in lpfc_io_buf()
22088 lpfc_cmd->cur_iocbq.sli4_lxritag)) in lpfc_io_buf()
22091 if (lpfc_cmd->flags & LPFC_SBUF_NOT_POSTED) in lpfc_io_buf()
22094 list_del_init(&lpfc_cmd->list); in lpfc_io_buf()
22095 qp->get_io_bufs--; in lpfc_io_buf()
22096 lpfc_cmd->hdwq = qp; in lpfc_io_buf()
22097 lpfc_cmd->hdwq_no = idx; in lpfc_io_buf()
22104 * lpfc_get_io_buf - Get one IO buffer from free pool
22118 * NULL - Error
22119 * Pointer to lpfc_io_buf - Success
22129 qp = &phba->sli4_hba.hdwq[hwqid]; in lpfc_get_io_buf()
22138 if (phba->cfg_xri_rebalancing) in lpfc_get_io_buf()
22142 lpfc_qp_spin_lock_irqsave(&qp->io_buf_list_get_lock, iflag, in lpfc_get_io_buf()
22144 if (qp->get_io_bufs > LPFC_NVME_EXPEDITE_XRICNT || expedite) in lpfc_get_io_buf()
22147 lpfc_qp_spin_lock(&qp->io_buf_list_put_lock, in lpfc_get_io_buf()
22149 list_splice(&qp->lpfc_io_buf_list_put, in lpfc_get_io_buf()
22150 &qp->lpfc_io_buf_list_get); in lpfc_get_io_buf()
22151 qp->get_io_bufs += qp->put_io_bufs; in lpfc_get_io_buf()
22152 INIT_LIST_HEAD(&qp->lpfc_io_buf_list_put); in lpfc_get_io_buf()
22153 qp->put_io_bufs = 0; in lpfc_get_io_buf()
22154 spin_unlock(&qp->io_buf_list_put_lock); in lpfc_get_io_buf()
22155 if (qp->get_io_bufs > LPFC_NVME_EXPEDITE_XRICNT || in lpfc_get_io_buf()
22159 spin_unlock_irqrestore(&qp->io_buf_list_get_lock, iflag); in lpfc_get_io_buf()
22166 * lpfc_read_object - Retrieve object data from HBA
22180 * to use interrupt-based completions, code is needed to fully cleanup
22195 mbox = mempool_alloc(phba->mbox_mem_pool, GFP_KERNEL); in lpfc_read_object()
22197 return -ENOMEM; in lpfc_read_object()
22198 length = (sizeof(struct lpfc_mbx_read_object) - in lpfc_read_object()
22203 read_object = &mbox->u.mqe.un.read_object; in lpfc_read_object()
22204 shdr = (union lpfc_sli4_cfg_shdr *)&read_object->header.cfg_shdr; in lpfc_read_object()
22206 bf_set(lpfc_mbox_hdr_version, &shdr->request, LPFC_Q_CREATE_VERSION_0); in lpfc_read_object()
22207 bf_set(lpfc_mbx_rd_object_rlen, &read_object->u.request, datasz); in lpfc_read_object()
22208 read_object->u.request.rd_object_offset = 0; in lpfc_read_object()
22209 read_object->u.request.rd_object_cnt = 1; in lpfc_read_object()
22211 memset((void *)read_object->u.request.rd_object_name, 0, in lpfc_read_object()
22215 read_object->u.request.rd_object_name[j] = in lpfc_read_object()
22220 pcmd->virt = lpfc_mbuf_alloc(phba, MEM_PRI, &pcmd->phys); in lpfc_read_object()
22221 if (!pcmd || !pcmd->virt) { in lpfc_read_object()
22223 mempool_free(mbox, phba->mbox_mem_pool); in lpfc_read_object()
22224 return -ENOMEM; in lpfc_read_object()
22226 memset((void *)pcmd->virt, 0, LPFC_BPL_SIZE); in lpfc_read_object()
22227 read_object->u.request.rd_object_hbuf[0].pa_lo = in lpfc_read_object()
22228 putPaddrLow(pcmd->phys); in lpfc_read_object()
22229 read_object->u.request.rd_object_hbuf[0].pa_hi = in lpfc_read_object()
22230 putPaddrHigh(pcmd->phys); in lpfc_read_object()
22231 read_object->u.request.rd_object_hbuf[0].length = LPFC_BPL_SIZE; in lpfc_read_object()
22233 mbox->vport = phba->pport; in lpfc_read_object()
22234 mbox->mbox_cmpl = lpfc_sli_def_mbox_cmpl; in lpfc_read_object()
22235 mbox->ctx_ndlp = NULL; in lpfc_read_object()
22238 shdr_status = bf_get(lpfc_mbox_hdr_status, &shdr->response); in lpfc_read_object()
22239 shdr_add_status = bf_get(lpfc_mbox_hdr_add_status, &shdr->response); in lpfc_read_object()
22245 byte_cnt = -ENOENT; in lpfc_read_object()
22248 "2625 READ_OBJECT mailbox failed with " in lpfc_read_object()
22251 byte_cnt = -ENXIO; in lpfc_read_object()
22254 length = read_object->u.response.rd_object_actual_rlen; in lpfc_read_object()
22255 eof = bf_get(lpfc_mbx_rd_object_eof, &read_object->u.response); in lpfc_read_object()
22267 lpfc_sli_pcimem_bcopy(pcmd->virt, datap, byte_cnt); in lpfc_read_object()
22271 /* This is an embedded SLI4 mailbox with an external buffer allocated. in lpfc_read_object()
22274 lpfc_mbuf_free(phba, pcmd->virt, pcmd->phys); in lpfc_read_object()
22281 * lpfc_get_sgl_per_hdwq - Get one SGL chunk from hdwq's pool
22289 * NULL - Error
22290 * Pointer to sli4_hybrid_sgl - Success
22298 struct lpfc_sli4_hdw_queue *hdwq = lpfc_buf->hdwq; in lpfc_get_sgl_per_hdwq()
22299 struct list_head *buf_list = &hdwq->sgl_list; in lpfc_get_sgl_per_hdwq()
22302 spin_lock_irqsave(&hdwq->hdwq_lock, iflags); in lpfc_get_sgl_per_hdwq()
22308 list_move_tail(&list_entry->list_node, in lpfc_get_sgl_per_hdwq()
22309 &lpfc_buf->dma_sgl_xtra_list); in lpfc_get_sgl_per_hdwq()
22314 spin_unlock_irqrestore(&hdwq->hdwq_lock, iflags); in lpfc_get_sgl_per_hdwq()
22316 cpu_to_node(hdwq->io_wq->chann)); in lpfc_get_sgl_per_hdwq()
22321 lpfc_buf->hdwq_no, __func__); in lpfc_get_sgl_per_hdwq()
22325 tmp->dma_sgl = dma_pool_alloc(phba->lpfc_sg_dma_buf_pool, in lpfc_get_sgl_per_hdwq()
22326 GFP_ATOMIC, &tmp->dma_phys_sgl); in lpfc_get_sgl_per_hdwq()
22327 if (!tmp->dma_sgl) { in lpfc_get_sgl_per_hdwq()
22331 lpfc_buf->hdwq_no, __func__); in lpfc_get_sgl_per_hdwq()
22336 spin_lock_irqsave(&hdwq->hdwq_lock, iflags); in lpfc_get_sgl_per_hdwq()
22337 list_add_tail(&tmp->list_node, &lpfc_buf->dma_sgl_xtra_list); in lpfc_get_sgl_per_hdwq()
22340 allocated_sgl = list_last_entry(&lpfc_buf->dma_sgl_xtra_list, in lpfc_get_sgl_per_hdwq()
22344 spin_unlock_irqrestore(&hdwq->hdwq_lock, iflags); in lpfc_get_sgl_per_hdwq()
22350 * lpfc_put_sgl_per_hdwq - Put one SGL chunk into hdwq pool
22357 * 0 - Success
22358 * -EINVAL - Error
22366 struct lpfc_sli4_hdw_queue *hdwq = lpfc_buf->hdwq; in lpfc_put_sgl_per_hdwq()
22367 struct list_head *buf_list = &hdwq->sgl_list; in lpfc_put_sgl_per_hdwq()
22370 spin_lock_irqsave(&hdwq->hdwq_lock, iflags); in lpfc_put_sgl_per_hdwq()
22372 if (likely(!list_empty(&lpfc_buf->dma_sgl_xtra_list))) { in lpfc_put_sgl_per_hdwq()
22374 &lpfc_buf->dma_sgl_xtra_list, in lpfc_put_sgl_per_hdwq()
22376 list_move_tail(&list_entry->list_node, in lpfc_put_sgl_per_hdwq()
22380 rc = -EINVAL; in lpfc_put_sgl_per_hdwq()
22383 spin_unlock_irqrestore(&hdwq->hdwq_lock, iflags); in lpfc_put_sgl_per_hdwq()
22388 * lpfc_free_sgl_per_hdwq - Free all SGL chunks of hdwq pool
22401 struct list_head *buf_list = &hdwq->sgl_list; in lpfc_free_sgl_per_hdwq()
22406 spin_lock_irqsave(&hdwq->hdwq_lock, iflags); in lpfc_free_sgl_per_hdwq()
22411 list_del(&list_entry->list_node); in lpfc_free_sgl_per_hdwq()
22412 dma_pool_free(phba->lpfc_sg_dma_buf_pool, in lpfc_free_sgl_per_hdwq()
22413 list_entry->dma_sgl, in lpfc_free_sgl_per_hdwq()
22414 list_entry->dma_phys_sgl); in lpfc_free_sgl_per_hdwq()
22418 spin_unlock_irqrestore(&hdwq->hdwq_lock, iflags); in lpfc_free_sgl_per_hdwq()
22422 * lpfc_get_cmd_rsp_buf_per_hdwq - Get one CMD/RSP buffer from hdwq
22430 * NULL - Error
22431 * Pointer to fcp_cmd_rsp_buf - Success
22440 struct lpfc_sli4_hdw_queue *hdwq = lpfc_buf->hdwq; in lpfc_get_cmd_rsp_buf_per_hdwq()
22441 struct list_head *buf_list = &hdwq->cmd_rsp_buf_list; in lpfc_get_cmd_rsp_buf_per_hdwq()
22444 spin_lock_irqsave(&hdwq->hdwq_lock, iflags); in lpfc_get_cmd_rsp_buf_per_hdwq()
22451 list_move_tail(&list_entry->list_node, in lpfc_get_cmd_rsp_buf_per_hdwq()
22452 &lpfc_buf->dma_cmd_rsp_list); in lpfc_get_cmd_rsp_buf_per_hdwq()
22457 spin_unlock_irqrestore(&hdwq->hdwq_lock, iflags); in lpfc_get_cmd_rsp_buf_per_hdwq()
22459 cpu_to_node(hdwq->io_wq->chann)); in lpfc_get_cmd_rsp_buf_per_hdwq()
22464 lpfc_buf->hdwq_no, __func__); in lpfc_get_cmd_rsp_buf_per_hdwq()
22468 tmp->fcp_cmnd = dma_pool_zalloc(phba->lpfc_cmd_rsp_buf_pool, in lpfc_get_cmd_rsp_buf_per_hdwq()
22470 &tmp->fcp_cmd_rsp_dma_handle); in lpfc_get_cmd_rsp_buf_per_hdwq()
22472 if (!tmp->fcp_cmnd) { in lpfc_get_cmd_rsp_buf_per_hdwq()
22476 lpfc_buf->hdwq_no, __func__); in lpfc_get_cmd_rsp_buf_per_hdwq()
22481 tmp->fcp_rsp = (struct fcp_rsp *)((uint8_t *)tmp->fcp_cmnd + in lpfc_get_cmd_rsp_buf_per_hdwq()
22484 spin_lock_irqsave(&hdwq->hdwq_lock, iflags); in lpfc_get_cmd_rsp_buf_per_hdwq()
22485 list_add_tail(&tmp->list_node, &lpfc_buf->dma_cmd_rsp_list); in lpfc_get_cmd_rsp_buf_per_hdwq()
22488 allocated_buf = list_last_entry(&lpfc_buf->dma_cmd_rsp_list, in lpfc_get_cmd_rsp_buf_per_hdwq()
22492 spin_unlock_irqrestore(&hdwq->hdwq_lock, iflags); in lpfc_get_cmd_rsp_buf_per_hdwq()
22498 * lpfc_put_cmd_rsp_buf_per_hdwq - Put one CMD/RSP buffer into hdwq pool
22505 * 0 - Success
22506 * -EINVAL - Error
22515 struct lpfc_sli4_hdw_queue *hdwq = lpfc_buf->hdwq; in lpfc_put_cmd_rsp_buf_per_hdwq()
22516 struct list_head *buf_list = &hdwq->cmd_rsp_buf_list; in lpfc_put_cmd_rsp_buf_per_hdwq()
22519 spin_lock_irqsave(&hdwq->hdwq_lock, iflags); in lpfc_put_cmd_rsp_buf_per_hdwq()
22521 if (likely(!list_empty(&lpfc_buf->dma_cmd_rsp_list))) { in lpfc_put_cmd_rsp_buf_per_hdwq()
22523 &lpfc_buf->dma_cmd_rsp_list, in lpfc_put_cmd_rsp_buf_per_hdwq()
22525 list_move_tail(&list_entry->list_node, in lpfc_put_cmd_rsp_buf_per_hdwq()
22529 rc = -EINVAL; in lpfc_put_cmd_rsp_buf_per_hdwq()
22532 spin_unlock_irqrestore(&hdwq->hdwq_lock, iflags); in lpfc_put_cmd_rsp_buf_per_hdwq()
22537 * lpfc_free_cmd_rsp_buf_per_hdwq - Free all CMD/RSP chunks of hdwq pool
22550 struct list_head *buf_list = &hdwq->cmd_rsp_buf_list; in lpfc_free_cmd_rsp_buf_per_hdwq()
22555 spin_lock_irqsave(&hdwq->hdwq_lock, iflags); in lpfc_free_cmd_rsp_buf_per_hdwq()
22561 list_del(&list_entry->list_node); in lpfc_free_cmd_rsp_buf_per_hdwq()
22562 dma_pool_free(phba->lpfc_cmd_rsp_buf_pool, in lpfc_free_cmd_rsp_buf_per_hdwq()
22563 list_entry->fcp_cmnd, in lpfc_free_cmd_rsp_buf_per_hdwq()
22564 list_entry->fcp_cmd_rsp_dma_handle); in lpfc_free_cmd_rsp_buf_per_hdwq()
22568 spin_unlock_irqrestore(&hdwq->hdwq_lock, iflags); in lpfc_free_cmd_rsp_buf_per_hdwq()
22572 * lpfc_sli_prep_wqe - Prepare WQE for the command to be posted
22589 union lpfc_wqe128 *wqe = &job->wqe; in lpfc_sli_prep_wqe()
22592 fip = phba->hba_flag & HBA_FIP_SUPPORT; in lpfc_sli_prep_wqe()
22594 if (job->cmd_flag & LPFC_IO_FCP) in lpfc_sli_prep_wqe()
22596 else if (fip && (job->cmd_flag & LPFC_FIP_ELS_ID_MASK)) in lpfc_sli_prep_wqe()
22601 abort_tag = job->iotag; in lpfc_sli_prep_wqe()
22602 cmnd = bf_get(wqe_cmnd, &wqe->els_req.wqe_com); in lpfc_sli_prep_wqe()
22606 ndlp = job->ndlp; in lpfc_sli_prep_wqe()
22609 &phba->sli4_hba.sli_intf); in lpfc_sli_prep_wqe()
22611 pcmd = (u32 *)job->cmd_dmabuf->virt; in lpfc_sli_prep_wqe()
22622 bf_set(els_req64_sp, &wqe->els_req, 1); in lpfc_sli_prep_wqe()
22623 bf_set(els_req64_sid, &wqe->els_req, in lpfc_sli_prep_wqe()
22624 job->vport->fc_myDID); in lpfc_sli_prep_wqe()
22627 !(phba->fc_topology == in lpfc_sli_prep_wqe()
22629 bf_set(els_req64_sid, &wqe->els_req, 0); in lpfc_sli_prep_wqe()
22631 bf_set(wqe_ct, &wqe->els_req.wqe_com, 1); in lpfc_sli_prep_wqe()
22632 bf_set(wqe_ctxt_tag, &wqe->els_req.wqe_com, in lpfc_sli_prep_wqe()
22633 phba->vpi_ids[job->vport->vpi]); in lpfc_sli_prep_wqe()
22635 bf_set(wqe_ct, &wqe->els_req.wqe_com, 0); in lpfc_sli_prep_wqe()
22636 bf_set(wqe_ctxt_tag, &wqe->els_req.wqe_com, in lpfc_sli_prep_wqe()
22637 phba->sli4_hba.rpi_ids[ndlp->nlp_rpi]); in lpfc_sli_prep_wqe()
22641 bf_set(wqe_temp_rpi, &wqe->els_req.wqe_com, in lpfc_sli_prep_wqe()
22642 phba->sli4_hba.rpi_ids[ndlp->nlp_rpi]); in lpfc_sli_prep_wqe()
22644 bf_set(wqe_dbde, &wqe->els_req.wqe_com, 1); in lpfc_sli_prep_wqe()
22645 bf_set(wqe_iod, &wqe->els_req.wqe_com, LPFC_WQE_IOD_READ); in lpfc_sli_prep_wqe()
22646 bf_set(wqe_qosd, &wqe->els_req.wqe_com, 1); in lpfc_sli_prep_wqe()
22647 bf_set(wqe_lenloc, &wqe->els_req.wqe_com, LPFC_WQE_LENLOC_NONE); in lpfc_sli_prep_wqe()
22648 bf_set(wqe_ebde_cnt, &wqe->els_req.wqe_com, 0); in lpfc_sli_prep_wqe()
22651 ndlp = job->ndlp; in lpfc_sli_prep_wqe()
22654 wqe->xmit_els_rsp.word4 = 0; in lpfc_sli_prep_wqe()
22657 &phba->sli4_hba.sli_intf); in lpfc_sli_prep_wqe()
22659 if (job->vport->fc_flag & FC_PT2PT) { in lpfc_sli_prep_wqe()
22660 bf_set(els_rsp64_sp, &wqe->xmit_els_rsp, 1); in lpfc_sli_prep_wqe()
22661 bf_set(els_rsp64_sid, &wqe->xmit_els_rsp, in lpfc_sli_prep_wqe()
22662 job->vport->fc_myDID); in lpfc_sli_prep_wqe()
22663 if (job->vport->fc_myDID == Fabric_DID) { in lpfc_sli_prep_wqe()
22665 &wqe->xmit_els_rsp.wqe_dest, 0); in lpfc_sli_prep_wqe()
22670 bf_set(wqe_dbde, &wqe->xmit_els_rsp.wqe_com, 1); in lpfc_sli_prep_wqe()
22671 bf_set(wqe_iod, &wqe->xmit_els_rsp.wqe_com, LPFC_WQE_IOD_WRITE); in lpfc_sli_prep_wqe()
22672 bf_set(wqe_qosd, &wqe->xmit_els_rsp.wqe_com, 1); in lpfc_sli_prep_wqe()
22673 bf_set(wqe_lenloc, &wqe->xmit_els_rsp.wqe_com, in lpfc_sli_prep_wqe()
22675 bf_set(wqe_ebde_cnt, &wqe->xmit_els_rsp.wqe_com, 0); in lpfc_sli_prep_wqe()
22677 if (phba->fc_topology == LPFC_TOPOLOGY_LOOP) { in lpfc_sli_prep_wqe()
22678 bf_set(els_rsp64_sp, &wqe->xmit_els_rsp, 1); in lpfc_sli_prep_wqe()
22679 bf_set(els_rsp64_sid, &wqe->xmit_els_rsp, in lpfc_sli_prep_wqe()
22680 job->vport->fc_myDID); in lpfc_sli_prep_wqe()
22681 bf_set(wqe_ct, &wqe->xmit_els_rsp.wqe_com, 1); in lpfc_sli_prep_wqe()
22684 if (phba->sli_rev == LPFC_SLI_REV4) { in lpfc_sli_prep_wqe()
22685 bf_set(wqe_rsp_temp_rpi, &wqe->xmit_els_rsp, in lpfc_sli_prep_wqe()
22686 phba->sli4_hba.rpi_ids[ndlp->nlp_rpi]); in lpfc_sli_prep_wqe()
22688 if (bf_get(wqe_ct, &wqe->xmit_els_rsp.wqe_com)) in lpfc_sli_prep_wqe()
22689 bf_set(wqe_ctxt_tag, &wqe->xmit_els_rsp.wqe_com, in lpfc_sli_prep_wqe()
22690 phba->vpi_ids[job->vport->vpi]); in lpfc_sli_prep_wqe()
22696 bf_set(wqe_dbde, &wqe->gen_req.wqe_com, 1); in lpfc_sli_prep_wqe()
22697 bf_set(wqe_iod, &wqe->gen_req.wqe_com, LPFC_WQE_IOD_READ); in lpfc_sli_prep_wqe()
22698 bf_set(wqe_qosd, &wqe->gen_req.wqe_com, 1); in lpfc_sli_prep_wqe()
22699 bf_set(wqe_lenloc, &wqe->gen_req.wqe_com, LPFC_WQE_LENLOC_NONE); in lpfc_sli_prep_wqe()
22700 bf_set(wqe_ebde_cnt, &wqe->gen_req.wqe_com, 0); in lpfc_sli_prep_wqe()
22704 if (phba->link_flag & LS_LOOPBACK_MODE) in lpfc_sli_prep_wqe()
22705 bf_set(wqe_xo, &wqe->xmit_sequence.wge_ctl, 1); in lpfc_sli_prep_wqe()
22707 wqe->xmit_sequence.rsvd3 = 0; in lpfc_sli_prep_wqe()
22708 bf_set(wqe_pu, &wqe->xmit_sequence.wqe_com, 0); in lpfc_sli_prep_wqe()
22709 bf_set(wqe_dbde, &wqe->xmit_sequence.wqe_com, 1); in lpfc_sli_prep_wqe()
22710 bf_set(wqe_iod, &wqe->xmit_sequence.wqe_com, in lpfc_sli_prep_wqe()
22712 bf_set(wqe_lenloc, &wqe->xmit_sequence.wqe_com, in lpfc_sli_prep_wqe()
22714 bf_set(wqe_ebde_cnt, &wqe->xmit_sequence.wqe_com, 0); in lpfc_sli_prep_wqe()
22718 bf_set(xmit_bls_rsp64_seqcnthi, &wqe->xmit_bls_rsp, 0xffff); in lpfc_sli_prep_wqe()
22719 bf_set(wqe_xmit_bls_pt, &wqe->xmit_bls_rsp.wqe_dest, 0x1); in lpfc_sli_prep_wqe()
22720 bf_set(wqe_ct, &wqe->xmit_bls_rsp.wqe_com, 1); in lpfc_sli_prep_wqe()
22721 bf_set(wqe_ctxt_tag, &wqe->xmit_bls_rsp.wqe_com, in lpfc_sli_prep_wqe()
22722 phba->vpi_ids[phba->pport->vpi]); in lpfc_sli_prep_wqe()
22723 bf_set(wqe_qosd, &wqe->xmit_bls_rsp.wqe_com, 1); in lpfc_sli_prep_wqe()
22724 bf_set(wqe_lenloc, &wqe->xmit_bls_rsp.wqe_com, in lpfc_sli_prep_wqe()
22726 /* Overwrite the pre-set comnd type with OTHER_COMMAND */ in lpfc_sli_prep_wqe()
22732 /* cases already formatted for sli4 wqe - no chgs necessary */ in lpfc_sli_prep_wqe()
22742 wqe->generic.wqe_com.abort_tag = abort_tag; in lpfc_sli_prep_wqe()
22743 bf_set(wqe_reqtag, &wqe->generic.wqe_com, job->iotag); in lpfc_sli_prep_wqe()
22744 bf_set(wqe_cmd_type, &wqe->generic.wqe_com, command_type); in lpfc_sli_prep_wqe()
22745 bf_set(wqe_cqid, &wqe->generic.wqe_com, LPFC_WQE_CQ_ID_DEFAULT); in lpfc_sli_prep_wqe()