Lines Matching +full:timeout +full:- +full:ulp +full:- +full:ms
1 // SPDX-License-Identifier: GPL-2.0-only
7 * linux-drivers@broadcom.com
91 struct be_queue_info *mccq = &phba->ctrl.mcc_obj.q; in alloc_mcc_wrb()
95 spin_lock(&phba->ctrl.mcc_lock); in alloc_mcc_wrb()
96 if (mccq->used == mccq->len) { in alloc_mcc_wrb()
100 mccq->used, phba->ctrl.mcc_tag_available); in alloc_mcc_wrb()
104 if (!phba->ctrl.mcc_tag_available) in alloc_mcc_wrb()
107 tag = phba->ctrl.mcc_tag[phba->ctrl.mcc_alloc_index]; in alloc_mcc_wrb()
112 phba->ctrl.mcc_tag_available, in alloc_mcc_wrb()
113 phba->ctrl.mcc_alloc_index); in alloc_mcc_wrb()
119 phba->ctrl.mcc_tag[phba->ctrl.mcc_alloc_index] = 0; in alloc_mcc_wrb()
120 phba->ctrl.mcc_tag_status[tag] = 0; in alloc_mcc_wrb()
121 phba->ctrl.ptag_state[tag].tag_state = 0; in alloc_mcc_wrb()
122 phba->ctrl.ptag_state[tag].cbfn = NULL; in alloc_mcc_wrb()
123 phba->ctrl.mcc_tag_available--; in alloc_mcc_wrb()
124 if (phba->ctrl.mcc_alloc_index == (MAX_MCC_CMD - 1)) in alloc_mcc_wrb()
125 phba->ctrl.mcc_alloc_index = 0; in alloc_mcc_wrb()
127 phba->ctrl.mcc_alloc_index++; in alloc_mcc_wrb()
131 wrb->tag0 = tag; in alloc_mcc_wrb()
132 wrb->tag0 |= (mccq->head << MCC_Q_WRB_IDX_SHIFT) & MCC_Q_WRB_IDX_MASK; in alloc_mcc_wrb()
134 mccq->used++; in alloc_mcc_wrb()
137 spin_unlock(&phba->ctrl.mcc_lock); in alloc_mcc_wrb()
143 struct be_queue_info *mccq = &ctrl->mcc_obj.q; in free_mcc_wrb()
145 spin_lock(&ctrl->mcc_lock); in free_mcc_wrb()
147 ctrl->mcc_tag[ctrl->mcc_free_index] = tag; in free_mcc_wrb()
148 if (ctrl->mcc_free_index == (MAX_MCC_CMD - 1)) in free_mcc_wrb()
149 ctrl->mcc_free_index = 0; in free_mcc_wrb()
151 ctrl->mcc_free_index++; in free_mcc_wrb()
152 ctrl->mcc_tag_available++; in free_mcc_wrb()
153 mccq->used--; in free_mcc_wrb()
154 spin_unlock(&ctrl->mcc_lock); in free_mcc_wrb()
158 * beiscsi_mcc_compl_status - Return the status of MCC completion
166 * Failure: Non-Zero
173 struct be_queue_info *mccq = &phba->ctrl.mcc_obj.q; in __beiscsi_mcc_compl_status()
181 mcc_tag_status = phba->ctrl.mcc_tag_status[tag]; in __beiscsi_mcc_compl_status()
187 mbx_hdr = (struct be_cmd_req_hdr *)mbx_cmd_mem->va; in __beiscsi_mcc_compl_status()
203 mbx_hdr->subsystem, mbx_hdr->opcode, in __beiscsi_mcc_compl_status()
205 rc = -EIO; in __beiscsi_mcc_compl_status()
212 mbx_resp_hdr->response_length, in __beiscsi_mcc_compl_status()
213 mbx_resp_hdr->actual_resp_len); in __beiscsi_mcc_compl_status()
214 rc = -EAGAIN; in __beiscsi_mcc_compl_status()
222 * beiscsi_mccq_compl_wait()- Process completion in MCC CQ
232 * Failure: Non-Zero
244 return -EINVAL; in beiscsi_mccq_compl_wait()
249 &phba->ctrl.ptag_state[tag].tag_state); in beiscsi_mccq_compl_wait()
250 return -EIO; in beiscsi_mccq_compl_wait()
254 rc = wait_event_interruptible_timeout(phba->ctrl.mcc_wait[tag], in beiscsi_mccq_compl_wait()
255 phba->ctrl.mcc_tag_status[tag], in beiscsi_mccq_compl_wait()
263 if (!test_bit(BEISCSI_HBA_ONLINE, &phba->state)) { in beiscsi_mccq_compl_wait()
265 &phba->ctrl.ptag_state[tag].tag_state); in beiscsi_mccq_compl_wait()
266 return -EIO; in beiscsi_mccq_compl_wait()
270 * If MBOX cmd timeout expired, tag and resource allocated in beiscsi_mccq_compl_wait()
277 * PCI/DMA memory allocated and posted in non-embedded mode in beiscsi_mccq_compl_wait()
282 tag_mem = &phba->ctrl.ptag_state[tag].tag_mem_state; in beiscsi_mccq_compl_wait()
284 tag_mem->size = mbx_cmd_mem->size; in beiscsi_mccq_compl_wait()
285 tag_mem->va = mbx_cmd_mem->va; in beiscsi_mccq_compl_wait()
286 tag_mem->dma = mbx_cmd_mem->dma; in beiscsi_mccq_compl_wait()
288 tag_mem->size = 0; in beiscsi_mccq_compl_wait()
293 &phba->ctrl.ptag_state[tag].tag_state); in beiscsi_mccq_compl_wait()
299 return -EBUSY; in beiscsi_mccq_compl_wait()
304 free_mcc_wrb(&phba->ctrl, tag); in beiscsi_mccq_compl_wait()
309 * beiscsi_process_mbox_compl()- Check the MBX completion status
317 * Failure: Non-Zero
322 struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem); in beiscsi_process_mbox_compl()
323 struct beiscsi_hba *phba = pci_get_drvdata(ctrl->pdev); in beiscsi_process_mbox_compl()
332 if (!compl->flags) { in beiscsi_process_mbox_compl()
336 return -EBUSY; in beiscsi_process_mbox_compl()
338 compl->flags = le32_to_cpu(compl->flags); in beiscsi_process_mbox_compl()
339 WARN_ON((compl->flags & CQE_FLAGS_VALID_MASK) == 0); in beiscsi_process_mbox_compl()
346 compl_status = (compl->status >> CQE_STATUS_COMPL_SHIFT) & in beiscsi_process_mbox_compl()
348 extd_status = (compl->status >> CQE_STATUS_EXTD_SHIFT) & in beiscsi_process_mbox_compl()
351 compl->flags = 0; in beiscsi_process_mbox_compl()
358 hdr->subsystem, hdr->opcode, compl_status, extd_status); in beiscsi_process_mbox_compl()
369 phba->port_speed = evt->port_speed; in beiscsi_process_async_link()
372 * This has been newly introduced in SKH-R Firmware 10.0.338.45. in beiscsi_process_async_link()
374 if (evt->port_link_status & BE_ASYNC_LINK_UP_MASK) { in beiscsi_process_async_link()
375 set_bit(BEISCSI_HBA_LINK_UP, &phba->state); in beiscsi_process_async_link()
376 if (test_bit(BEISCSI_HBA_BOOT_FOUND, &phba->state)) in beiscsi_process_async_link()
380 evt->physical_port, evt->event_tag); in beiscsi_process_async_link()
382 clear_bit(BEISCSI_HBA_LINK_UP, &phba->state); in beiscsi_process_async_link()
385 evt->physical_port, evt->event_tag); in beiscsi_process_async_link()
386 iscsi_host_for_each_session(phba->shost, in beiscsi_process_async_link()
393 …"Optics faulted/incorrectly installed/not installed - Reseat optics, if issue not resolved, replac…
394 "Optics of two types installed - Remove one optic or install matching pair of optics.",
395 "Incompatible optics - Replace with compatible optics for card to function.",
396 "Unqualified optics - Replace with Avago optics for Warranty and Technical Support.",
397 "Uncertified optics - Replace with Avago Certified optics to enable link operation."
408 evt_type = compl->flags >> ASYNC_TRAILER_EVENT_TYPE_SHIFT; in beiscsi_process_async_sli()
416 state = async_sli->event_data1 >> in beiscsi_process_async_sli()
417 (phba->fw_config.phys_port * 8) & 0xff; in beiscsi_process_async_sli()
418 le = async_sli->event_data2 >> in beiscsi_process_async_sli()
419 (phba->fw_config.phys_port * 8) & 0xff; in beiscsi_process_async_sli()
421 old_state = phba->optic_state; in beiscsi_process_async_sli()
422 phba->optic_state = state; in beiscsi_process_async_sli()
428 phba->port_name, async_sli->event_data1); in beiscsi_process_async_sli()
433 /* log link effect for unqualified-4, uncertified-5 optics */ in beiscsi_process_async_sli()
436 " Link is non-operational." : in beiscsi_process_async_sli()
438 /* 1 - info */ in beiscsi_process_async_sli()
441 /* 2 - error */ in beiscsi_process_async_sli()
446 if (old_state != phba->optic_state) in beiscsi_process_async_sli()
448 phba->port_name, in beiscsi_process_async_sli()
460 evt_code = compl->flags >> ASYNC_TRAILER_EVENT_CODE_SHIFT; in beiscsi_process_async_event()
467 if (test_bit(BEISCSI_HBA_BOOT_FOUND, &phba->state)) in beiscsi_process_async_event()
481 evt_code, compl->status, compl->flags); in beiscsi_process_async_event()
487 struct beiscsi_hba *phba = pci_get_drvdata(ctrl->pdev); in beiscsi_process_mcc_compl()
493 tag = (compl->tag0 & MCC_Q_CMD_TAG_MASK); in beiscsi_process_mcc_compl()
494 wrb_idx = (compl->tag0 & CQE_STATUS_WRB_MASK) >> CQE_STATUS_WRB_SHIFT; in beiscsi_process_mcc_compl()
497 &ctrl->ptag_state[tag].tag_state)) { in beiscsi_process_mcc_compl()
505 clear_bit(MCC_TAG_STATE_RUNNING, &ctrl->ptag_state[tag].tag_state); in beiscsi_process_mcc_compl()
507 if (test_bit(MCC_TAG_STATE_TIMEOUT, &ctrl->ptag_state[tag].tag_state)) { in beiscsi_process_mcc_compl()
511 "BC_%d : MBX Completion for timeout Command from FW\n"); in beiscsi_process_mcc_compl()
514 * Only for non-embedded cmd, PCI resource is allocated. in beiscsi_process_mcc_compl()
516 tag_mem = &ctrl->ptag_state[tag].tag_mem_state; in beiscsi_process_mcc_compl()
517 if (tag_mem->size) { in beiscsi_process_mcc_compl()
518 dma_free_coherent(&ctrl->pdev->dev, tag_mem->size, in beiscsi_process_mcc_compl()
519 tag_mem->va, tag_mem->dma); in beiscsi_process_mcc_compl()
520 tag_mem->size = 0; in beiscsi_process_mcc_compl()
526 compl_status = (compl->status >> CQE_STATUS_COMPL_SHIFT) & in beiscsi_process_mcc_compl()
528 extd_status = (compl->status >> CQE_STATUS_EXTD_SHIFT) & in beiscsi_process_mcc_compl()
534 ctrl->mcc_tag_status[tag] = CQE_VALID_MASK; in beiscsi_process_mcc_compl()
535 ctrl->mcc_tag_status[tag] |= (wrb_idx << CQE_STATUS_WRB_SHIFT); in beiscsi_process_mcc_compl()
536 ctrl->mcc_tag_status[tag] |= (extd_status << CQE_STATUS_ADDL_SHIFT) & in beiscsi_process_mcc_compl()
538 ctrl->mcc_tag_status[tag] |= (compl_status & CQE_STATUS_MASK); in beiscsi_process_mcc_compl()
540 if (test_bit(MCC_TAG_STATE_ASYNC, &ctrl->ptag_state[tag].tag_state)) { in beiscsi_process_mcc_compl()
541 if (ctrl->ptag_state[tag].cbfn) in beiscsi_process_mcc_compl()
542 ctrl->ptag_state[tag].cbfn(phba, tag); in beiscsi_process_mcc_compl()
550 if (test_bit(MCC_TAG_STATE_IGNORE, &ctrl->ptag_state[tag].tag_state)) { in beiscsi_process_mcc_compl()
557 wake_up_interruptible(&ctrl->mcc_wait[tag]); in beiscsi_process_mcc_compl()
563 struct be_queue_info *mccq = &phba->ctrl.mcc_obj.q; in be_mcc_notify()
566 set_bit(MCC_TAG_STATE_RUNNING, &phba->ctrl.ptag_state[tag].tag_state); in be_mcc_notify()
567 val |= mccq->id & DB_MCCQ_RING_ID_MASK; in be_mcc_notify()
571 iowrite32(val, phba->db_va + DB_MCCQ_OFFSET); in be_mcc_notify()
575 * be_mbox_db_ready_poll()- Check ready status
583 * Failure: Non-Zero
587 /* wait 30s for generic non-flash MBOX operation */ in be_mbox_db_ready_poll()
589 void __iomem *db = ctrl->db + MPU_MAILBOX_DB_OFFSET; in be_mbox_db_ready_poll()
590 struct beiscsi_hba *phba = pci_get_drvdata(ctrl->pdev); in be_mbox_db_ready_poll()
591 unsigned long timeout; in be_mbox_db_ready_poll() local
598 timeout = jiffies + msecs_to_jiffies(BEISCSI_MBX_RDY_BIT_TIMEOUT); in be_mbox_db_ready_poll()
601 return -EIO; in be_mbox_db_ready_poll()
605 return -EIO; in be_mbox_db_ready_poll()
611 if (time_after(jiffies, timeout)) in be_mbox_db_ready_poll()
613 /* 1ms sleep is enough in most cases */ in be_mbox_db_ready_poll()
620 set_bit(BEISCSI_HBA_FW_TIMEOUT, &phba->state); in be_mbox_db_ready_poll()
621 return -EBUSY; in be_mbox_db_ready_poll()
633 * Failure: Non-Zero
639 void __iomem *db = ctrl->db + MPU_MAILBOX_DB_OFFSET; in be_mbox_notify()
640 struct be_dma_mem *mbox_mem = &ctrl->mbox_mem; in be_mbox_notify()
641 struct be_mcc_mailbox *mbox = mbox_mem->va; in be_mbox_notify()
649 val |= (upper_32_bits(mbox_mem->dma) >> 2) << 2; in be_mbox_notify()
659 val |= (u32) (mbox_mem->dma >> 4) << 2; in be_mbox_notify()
669 status = beiscsi_process_mbox_compl(ctrl, &mbox->compl); in be_mbox_notify()
677 wrb->emb_sgecnt_special |= MCC_WRB_EMBEDDED_MASK; in be_wrb_hdr_prepare()
679 wrb->emb_sgecnt_special |= (sge_cnt & MCC_WRB_SGE_CNT_MASK) << in be_wrb_hdr_prepare()
681 wrb->payload_length = payload_len; in be_wrb_hdr_prepare()
688 req_hdr->opcode = opcode; in be_cmd_hdr_prepare()
689 req_hdr->subsystem = subsystem; in be_cmd_hdr_prepare()
690 req_hdr->request_length = cpu_to_le32(cmd_len - sizeof(*req_hdr)); in be_cmd_hdr_prepare()
691 req_hdr->timeout = BEISCSI_FW_MBX_TIMEOUT; in be_cmd_hdr_prepare()
698 u64 dma = (u64) mem->dma; in be_cmd_page_addrs_prepare()
700 buf_pages = min(PAGES_4K_SPANNED(mem->va, mem->size), max_pages); in be_cmd_page_addrs_prepare()
721 multiplier = (MAX_INTR_RATE - interrupt_rate) * round; in eq_delay_to_mult()
732 return &((struct be_mcc_mailbox *)(mbox_mem->va))->wrb; in wrb_from_mbox()
738 struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem); in beiscsi_cmd_eq_create()
741 struct be_dma_mem *q_mem = &eq->dma_mem; in beiscsi_cmd_eq_create()
744 mutex_lock(&ctrl->mbox_lock); in beiscsi_cmd_eq_create()
749 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, in beiscsi_cmd_eq_create()
752 req->num_pages = cpu_to_le16(PAGES_4K_SPANNED(q_mem->va, q_mem->size)); in beiscsi_cmd_eq_create()
754 AMAP_SET_BITS(struct amap_eq_context, func, req->context, in beiscsi_cmd_eq_create()
755 PCI_FUNC(ctrl->pdev->devfn)); in beiscsi_cmd_eq_create()
756 AMAP_SET_BITS(struct amap_eq_context, valid, req->context, 1); in beiscsi_cmd_eq_create()
757 AMAP_SET_BITS(struct amap_eq_context, size, req->context, 0); in beiscsi_cmd_eq_create()
758 AMAP_SET_BITS(struct amap_eq_context, count, req->context, in beiscsi_cmd_eq_create()
759 __ilog2_u32(eq->len / 256)); in beiscsi_cmd_eq_create()
760 AMAP_SET_BITS(struct amap_eq_context, delaymult, req->context, in beiscsi_cmd_eq_create()
762 be_dws_cpu_to_le(req->context, sizeof(req->context)); in beiscsi_cmd_eq_create()
764 be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem); in beiscsi_cmd_eq_create()
768 eq->id = le16_to_cpu(resp->eq_id); in beiscsi_cmd_eq_create()
769 eq->created = true; in beiscsi_cmd_eq_create()
771 mutex_unlock(&ctrl->mbox_lock); in beiscsi_cmd_eq_create()
779 struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem); in beiscsi_cmd_cq_create()
782 struct beiscsi_hba *phba = pci_get_drvdata(ctrl->pdev); in beiscsi_cmd_cq_create()
783 struct be_dma_mem *q_mem = &cq->dma_mem; in beiscsi_cmd_cq_create()
784 void *ctxt = &req->context; in beiscsi_cmd_cq_create()
787 mutex_lock(&ctrl->mbox_lock); in beiscsi_cmd_cq_create()
792 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, in beiscsi_cmd_cq_create()
795 req->num_pages = cpu_to_le16(PAGES_4K_SPANNED(q_mem->va, q_mem->size)); in beiscsi_cmd_cq_create()
801 __ilog2_u32(cq->len / 256)); in beiscsi_cmd_cq_create()
805 AMAP_SET_BITS(struct amap_cq_context, eqid, ctxt, eq->id); in beiscsi_cmd_cq_create()
808 PCI_FUNC(ctrl->pdev->devfn)); in beiscsi_cmd_cq_create()
810 req->hdr.version = MBX_CMD_VER2; in beiscsi_cmd_cq_create()
811 req->page_size = 1; in beiscsi_cmd_cq_create()
817 __ilog2_u32(cq->len / 256)); in beiscsi_cmd_cq_create()
820 AMAP_SET_BITS(struct amap_cq_context_v2, eqid, ctxt, eq->id); in beiscsi_cmd_cq_create()
824 be_dws_cpu_to_le(ctxt, sizeof(req->context)); in beiscsi_cmd_cq_create()
826 be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem); in beiscsi_cmd_cq_create()
830 cq->id = le16_to_cpu(resp->cq_id); in beiscsi_cmd_cq_create()
831 cq->created = true; in beiscsi_cmd_cq_create()
837 mutex_unlock(&ctrl->mbox_lock); in beiscsi_cmd_cq_create()
856 struct be_dma_mem *q_mem = &mccq->dma_mem; in beiscsi_cmd_mccq_create()
861 mutex_lock(&phba->ctrl.mbox_lock); in beiscsi_cmd_mccq_create()
862 ctrl = &phba->ctrl; in beiscsi_cmd_mccq_create()
863 wrb = wrb_from_mbox(&ctrl->mbox_mem); in beiscsi_cmd_mccq_create()
866 ctxt = &req->context; in beiscsi_cmd_mccq_create()
870 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, in beiscsi_cmd_mccq_create()
873 req->num_pages = PAGES_4K_SPANNED(q_mem->va, q_mem->size); in beiscsi_cmd_mccq_create()
874 req->async_evt_bitmap = 1 << ASYNC_EVENT_CODE_LINK_STATE; in beiscsi_cmd_mccq_create()
875 req->async_evt_bitmap |= 1 << ASYNC_EVENT_CODE_ISCSI; in beiscsi_cmd_mccq_create()
876 req->async_evt_bitmap |= 1 << ASYNC_EVENT_CODE_SLI; in beiscsi_cmd_mccq_create()
879 PCI_FUNC(phba->pcidev->devfn)); in beiscsi_cmd_mccq_create()
882 be_encoded_q_len(mccq->len)); in beiscsi_cmd_mccq_create()
883 AMAP_SET_BITS(struct amap_mcc_context, cq_id, ctxt, cq->id); in beiscsi_cmd_mccq_create()
885 be_dws_cpu_to_le(ctxt, sizeof(req->context)); in beiscsi_cmd_mccq_create()
887 be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem); in beiscsi_cmd_mccq_create()
892 mccq->id = le16_to_cpu(resp->id); in beiscsi_cmd_mccq_create()
893 mccq->created = true; in beiscsi_cmd_mccq_create()
895 mutex_unlock(&phba->ctrl.mbox_lock); in beiscsi_cmd_mccq_create()
903 struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem); in beiscsi_cmd_q_destroy()
905 struct beiscsi_hba *phba = pci_get_drvdata(ctrl->pdev); in beiscsi_cmd_q_destroy()
913 mutex_lock(&ctrl->mbox_lock); in beiscsi_cmd_q_destroy()
943 mutex_unlock(&ctrl->mbox_lock); in beiscsi_cmd_q_destroy()
946 be_cmd_hdr_prepare(&req->hdr, subsys, opcode, sizeof(*req)); in beiscsi_cmd_q_destroy()
948 req->id = cpu_to_le16(q->id); in beiscsi_cmd_q_destroy()
952 mutex_unlock(&ctrl->mbox_lock); in beiscsi_cmd_q_destroy()
957 * be_cmd_create_default_pdu_queue()- Create DEFQ for the adapter
964 * @ulp_num: Bind to which ULP
966 * Create HDR/Data DEFQ for the passed ULP. Unsol PDU are posted
971 * Failure: Non-Zero Value
980 struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem); in be_cmd_create_default_pdu_queue()
982 struct be_dma_mem *q_mem = &dq->dma_mem; in be_cmd_create_default_pdu_queue()
983 struct beiscsi_hba *phba = pci_get_drvdata(ctrl->pdev); in be_cmd_create_default_pdu_queue()
984 void *ctxt = &req->context; in be_cmd_create_default_pdu_queue()
987 mutex_lock(&ctrl->mbox_lock); in be_cmd_create_default_pdu_queue()
992 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI, in be_cmd_create_default_pdu_queue()
995 req->num_pages = PAGES_4K_SPANNED(q_mem->va, q_mem->size); in be_cmd_create_default_pdu_queue()
996 if (phba->fw_config.dual_ulp_aware) { in be_cmd_create_default_pdu_queue()
997 req->ulp_num = ulp_num; in be_cmd_create_default_pdu_queue()
998 req->dua_feature |= (1 << BEISCSI_DUAL_ULP_AWARE_BIT); in be_cmd_create_default_pdu_queue()
999 req->dua_feature |= (1 << BEISCSI_BIND_Q_TO_ULP_BIT); in be_cmd_create_default_pdu_queue()
1008 pci_func_id, ctxt, PCI_FUNC(ctrl->pdev->devfn)); in be_cmd_create_default_pdu_queue()
1016 cq_id_recv, ctxt, cq->id); in be_cmd_create_default_pdu_queue()
1029 cq_id_recv, ctxt, cq->id); in be_cmd_create_default_pdu_queue()
1032 be_dws_cpu_to_le(ctxt, sizeof(req->context)); in be_cmd_create_default_pdu_queue()
1034 be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem); in be_cmd_create_default_pdu_queue()
1041 dq->id = le16_to_cpu(resp->id); in be_cmd_create_default_pdu_queue()
1042 dq->created = true; in be_cmd_create_default_pdu_queue()
1044 defq_ring = &phba->phwi_ctrlr->default_pdu_hdr[ulp_num]; in be_cmd_create_default_pdu_queue()
1046 defq_ring = &phba->phwi_ctrlr-> in be_cmd_create_default_pdu_queue()
1049 defq_ring->id = dq->id; in be_cmd_create_default_pdu_queue()
1051 if (!phba->fw_config.dual_ulp_aware) { in be_cmd_create_default_pdu_queue()
1052 defq_ring->ulp_num = BEISCSI_ULP0; in be_cmd_create_default_pdu_queue()
1053 defq_ring->doorbell_offset = DB_RXULP0_OFFSET; in be_cmd_create_default_pdu_queue()
1055 defq_ring->ulp_num = resp->ulp_num; in be_cmd_create_default_pdu_queue()
1056 defq_ring->doorbell_offset = resp->doorbell_offset; in be_cmd_create_default_pdu_queue()
1059 mutex_unlock(&ctrl->mbox_lock); in be_cmd_create_default_pdu_queue()
1065 * be_cmd_wrbq_create()- Create WRBQ
1070 * @ulp_num: ULP on which the WRBQ is to be created
1081 struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem); in be_cmd_wrbq_create()
1084 struct beiscsi_hba *phba = pci_get_drvdata(ctrl->pdev); in be_cmd_wrbq_create()
1087 mutex_lock(&ctrl->mbox_lock); in be_cmd_wrbq_create()
1092 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI, in be_cmd_wrbq_create()
1094 req->num_pages = PAGES_4K_SPANNED(q_mem->va, q_mem->size); in be_cmd_wrbq_create()
1096 if (phba->fw_config.dual_ulp_aware) { in be_cmd_wrbq_create()
1097 req->ulp_num = ulp_num; in be_cmd_wrbq_create()
1098 req->dua_feature |= (1 << BEISCSI_DUAL_ULP_AWARE_BIT); in be_cmd_wrbq_create()
1099 req->dua_feature |= (1 << BEISCSI_BIND_Q_TO_ULP_BIT); in be_cmd_wrbq_create()
1102 be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem); in be_cmd_wrbq_create()
1106 wrbq->id = le16_to_cpu(resp->cid); in be_cmd_wrbq_create()
1107 wrbq->created = true; in be_cmd_wrbq_create()
1109 pwrb_context->cid = wrbq->id; in be_cmd_wrbq_create()
1110 if (!phba->fw_config.dual_ulp_aware) { in be_cmd_wrbq_create()
1111 pwrb_context->doorbell_offset = DB_TXULP0_OFFSET; in be_cmd_wrbq_create()
1112 pwrb_context->ulp_num = BEISCSI_ULP0; in be_cmd_wrbq_create()
1114 pwrb_context->ulp_num = resp->ulp_num; in be_cmd_wrbq_create()
1115 pwrb_context->doorbell_offset = resp->doorbell_offset; in be_cmd_wrbq_create()
1118 mutex_unlock(&ctrl->mbox_lock); in be_cmd_wrbq_create()
1125 struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem); in be_cmd_iscsi_post_template_hdr()
1129 mutex_lock(&ctrl->mbox_lock); in be_cmd_iscsi_post_template_hdr()
1133 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, in be_cmd_iscsi_post_template_hdr()
1137 req->num_pages = PAGES_4K_SPANNED(q_mem->va, q_mem->size); in be_cmd_iscsi_post_template_hdr()
1138 req->type = BEISCSI_TEMPLATE_HDR_TYPE_ISCSI; in be_cmd_iscsi_post_template_hdr()
1139 be_cmd_page_addrs_prepare(req->pages, ARRAY_SIZE(req->pages), q_mem); in be_cmd_iscsi_post_template_hdr()
1142 mutex_unlock(&ctrl->mbox_lock); in be_cmd_iscsi_post_template_hdr()
1148 struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem); in be_cmd_iscsi_remove_template_hdr()
1152 mutex_lock(&ctrl->mbox_lock); in be_cmd_iscsi_remove_template_hdr()
1156 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, in be_cmd_iscsi_remove_template_hdr()
1160 req->type = BEISCSI_TEMPLATE_HDR_TYPE_ISCSI; in be_cmd_iscsi_remove_template_hdr()
1163 mutex_unlock(&ctrl->mbox_lock); in be_cmd_iscsi_remove_template_hdr()
1171 struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem); in be_cmd_iscsi_post_sgl_pages()
1173 struct beiscsi_hba *phba = pci_get_drvdata(ctrl->pdev); in be_cmd_iscsi_post_sgl_pages()
1181 mutex_lock(&ctrl->mbox_lock); in be_cmd_iscsi_post_sgl_pages()
1185 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI, in be_cmd_iscsi_post_sgl_pages()
1190 req->num_pages = min(num_pages, curr_pages); in be_cmd_iscsi_post_sgl_pages()
1191 req->page_offset = page_offset; in be_cmd_iscsi_post_sgl_pages()
1192 be_cmd_page_addrs_prepare(req->pages, req->num_pages, q_mem); in be_cmd_iscsi_post_sgl_pages()
1193 q_mem->dma = q_mem->dma + (req->num_pages * PAGE_SIZE); in be_cmd_iscsi_post_sgl_pages()
1194 page_offset += req->num_pages; in be_cmd_iscsi_post_sgl_pages()
1195 num_pages -= req->num_pages; in be_cmd_iscsi_post_sgl_pages()
1198 req->num_pages = temp_num_pages; in be_cmd_iscsi_post_sgl_pages()
1209 mutex_unlock(&ctrl->mbox_lock); in be_cmd_iscsi_post_sgl_pages()
1216 * be_cmd_set_vlan()- Configure VLAN paramters on the adapter
1231 struct be_ctrl_info *ctrl = &phba->ctrl; in be_cmd_set_vlan()
1233 if (mutex_lock_interruptible(&ctrl->mbox_lock)) in be_cmd_set_vlan()
1237 mutex_unlock(&ctrl->mbox_lock); in be_cmd_set_vlan()
1243 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI, in be_cmd_set_vlan()
1247 req->interface_hndl = phba->interface_handle; in be_cmd_set_vlan()
1248 req->vlan_priority = vlan_tag; in be_cmd_set_vlan()
1251 mutex_unlock(&ctrl->mbox_lock); in be_cmd_set_vlan()
1260 struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem); in beiscsi_check_supported_fw()
1265 nonemb_cmd.va = dma_alloc_coherent(&ctrl->pdev->dev, in beiscsi_check_supported_fw()
1272 return -ENOMEM; in beiscsi_check_supported_fw()
1277 mutex_lock(&ctrl->mbox_lock); in beiscsi_check_supported_fw()
1280 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, in beiscsi_check_supported_fw()
1282 sge->pa_hi = cpu_to_le32(upper_32_bits(nonemb_cmd.dma)); in beiscsi_check_supported_fw()
1283 sge->pa_lo = cpu_to_le32(nonemb_cmd.dma & 0xFFFFFFFF); in beiscsi_check_supported_fw()
1284 sge->len = cpu_to_le32(nonemb_cmd.size); in beiscsi_check_supported_fw()
1293 resp->params.hba_attribs in beiscsi_check_supported_fw()
1295 resp->params.hba_attribs. in beiscsi_check_supported_fw()
1298 phba->fw_config.iscsi_features = in beiscsi_check_supported_fw()
1299 resp->params.hba_attribs.iscsi_features; in beiscsi_check_supported_fw()
1301 "BM_%d : phba->fw_config.iscsi_features = %d\n", in beiscsi_check_supported_fw()
1302 phba->fw_config.iscsi_features); in beiscsi_check_supported_fw()
1303 memcpy(phba->fw_ver_str, resp->params.hba_attribs. in beiscsi_check_supported_fw()
1308 mutex_unlock(&ctrl->mbox_lock); in beiscsi_check_supported_fw()
1310 dma_free_coherent(&ctrl->pdev->dev, nonemb_cmd.size, in beiscsi_check_supported_fw()
1317 * beiscsi_get_fw_config()- Get the FW config for the function
1326 * Failure: Non-Zero Value
1331 struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem); in beiscsi_get_fw_config()
1334 int status = -EINVAL; in beiscsi_get_fw_config()
1337 mutex_lock(&ctrl->mbox_lock); in beiscsi_get_fw_config()
1341 be_cmd_hdr_prepare(&pfw_cfg->hdr, CMD_SUBSYSTEM_COMMON, in beiscsi_get_fw_config()
1352 phba->fw_config.phys_port = pfw_cfg->phys_port; in beiscsi_get_fw_config()
1353 if (phba->fw_config.phys_port >= BEISCSI_PHYS_PORT_MAX) { in beiscsi_get_fw_config()
1356 phba->fw_config.phys_port); in beiscsi_get_fw_config()
1362 phba->fw_config.eqid_count = pfw_cfg->eqid_count; in beiscsi_get_fw_config()
1363 phba->fw_config.cqid_count = pfw_cfg->cqid_count; in beiscsi_get_fw_config()
1364 if (phba->fw_config.eqid_count == 0 || in beiscsi_get_fw_config()
1365 phba->fw_config.eqid_count > 2048) { in beiscsi_get_fw_config()
1368 phba->fw_config.eqid_count); in beiscsi_get_fw_config()
1371 if (phba->fw_config.cqid_count == 0 || in beiscsi_get_fw_config()
1372 phba->fw_config.cqid_count > 4096) { in beiscsi_get_fw_config()
1375 phba->fw_config.cqid_count); in beiscsi_get_fw_config()
1380 phba->fw_config.eqid_count, in beiscsi_get_fw_config()
1381 phba->fw_config.cqid_count); in beiscsi_get_fw_config()
1385 * Check on which all ULP iSCSI Protocol is loaded. in beiscsi_get_fw_config()
1386 * Set the Bit for those ULP. This set flag is used in beiscsi_get_fw_config()
1387 * at all places in the code to check on which ULP in beiscsi_get_fw_config()
1391 if (pfw_cfg->ulp[ulp_num].ulp_mode & in beiscsi_get_fw_config()
1393 set_bit(ulp_num, &phba->fw_config.ulp_supported); in beiscsi_get_fw_config()
1395 /* Get the CID, ICD and Chain count for each ULP */ in beiscsi_get_fw_config()
1396 phba->fw_config.iscsi_cid_start[ulp_num] = in beiscsi_get_fw_config()
1397 pfw_cfg->ulp[ulp_num].sq_base; in beiscsi_get_fw_config()
1398 phba->fw_config.iscsi_cid_count[ulp_num] = in beiscsi_get_fw_config()
1399 pfw_cfg->ulp[ulp_num].sq_count; in beiscsi_get_fw_config()
1401 phba->fw_config.iscsi_icd_start[ulp_num] = in beiscsi_get_fw_config()
1402 pfw_cfg->ulp[ulp_num].icd_base; in beiscsi_get_fw_config()
1403 phba->fw_config.iscsi_icd_count[ulp_num] = in beiscsi_get_fw_config()
1404 pfw_cfg->ulp[ulp_num].icd_count; in beiscsi_get_fw_config()
1406 phba->fw_config.iscsi_chain_start[ulp_num] = in beiscsi_get_fw_config()
1407 pfw_cfg->chain_icd[ulp_num].chain_base; in beiscsi_get_fw_config()
1408 phba->fw_config.iscsi_chain_count[ulp_num] = in beiscsi_get_fw_config()
1409 pfw_cfg->chain_icd[ulp_num].chain_count; in beiscsi_get_fw_config()
1412 "BG_%d : Function loaded on ULP : %d\n" in beiscsi_get_fw_config()
1418 phba->fw_config. in beiscsi_get_fw_config()
1420 phba->fw_config. in beiscsi_get_fw_config()
1422 phba->fw_config. in beiscsi_get_fw_config()
1424 phba->fw_config. in beiscsi_get_fw_config()
1429 if (phba->fw_config.ulp_supported == 0) { in beiscsi_get_fw_config()
1432 pfw_cfg->ulp[BEISCSI_ULP0].ulp_mode, in beiscsi_get_fw_config()
1433 pfw_cfg->ulp[BEISCSI_ULP1].ulp_mode); in beiscsi_get_fw_config()
1438 * ICD is shared among ULPs. Use icd_count of any one loaded ULP in beiscsi_get_fw_config()
1441 if (test_bit(ulp_num, &phba->fw_config.ulp_supported)) in beiscsi_get_fw_config()
1443 icd_count = phba->fw_config.iscsi_icd_count[ulp_num]; in beiscsi_get_fw_config()
1459 * Check FW is dual ULP aware i.e. can handle either in beiscsi_get_fw_config()
1462 phba->fw_config.dual_ulp_aware = (pfw_cfg->function_mode & in beiscsi_get_fw_config()
1467 phba->fw_config.dual_ulp_aware); in beiscsi_get_fw_config()
1472 mutex_unlock(&ctrl->mbox_lock); in beiscsi_get_fw_config()
1477 * beiscsi_get_port_name()- Get port name for the function
1490 mutex_lock(&ctrl->mbox_lock); in beiscsi_get_port_name()
1491 wrb = wrb_from_mbox(&ctrl->mbox_mem); in beiscsi_get_port_name()
1496 be_cmd_hdr_prepare(&ioctl->h.req_hdr, CMD_SUBSYSTEM_COMMON, in beiscsi_get_port_name()
1500 phba->port_name = 0; in beiscsi_get_port_name()
1502 phba->port_name = ioctl->p.resp.port_names >> in beiscsi_get_port_name()
1503 (phba->fw_config.phys_port * 8) & 0xff; in beiscsi_get_port_name()
1507 ret, ioctl->h.resp_hdr.status); in beiscsi_get_port_name()
1510 if (phba->port_name == 0) in beiscsi_get_port_name()
1511 phba->port_name = '?'; in beiscsi_get_port_name()
1513 mutex_unlock(&ctrl->mbox_lock); in beiscsi_get_port_name()
1519 struct be_ctrl_info *ctrl = &phba->ctrl; in beiscsi_set_host_data()
1527 mutex_lock(&ctrl->mbox_lock); in beiscsi_set_host_data()
1528 wrb = wrb_from_mbox(&ctrl->mbox_mem); in beiscsi_set_host_data()
1533 be_cmd_hdr_prepare(&ioctl->h.req_hdr, CMD_SUBSYSTEM_COMMON, in beiscsi_set_host_data()
1536 ioctl->param.req.param_id = BE_CMD_SET_HOST_PARAM_ID; in beiscsi_set_host_data()
1537 ioctl->param.req.param_len = in beiscsi_set_host_data()
1538 snprintf((char *)ioctl->param.req.param_data, in beiscsi_set_host_data()
1539 sizeof(ioctl->param.req.param_data), in beiscsi_set_host_data()
1541 ioctl->param.req.param_len = ALIGN(ioctl->param.req.param_len + 1, 4); in beiscsi_set_host_data()
1542 if (ioctl->param.req.param_len > BE_CMD_MAX_DRV_VERSION) in beiscsi_set_host_data()
1543 ioctl->param.req.param_len = BE_CMD_MAX_DRV_VERSION; in beiscsi_set_host_data()
1559 mutex_unlock(&ctrl->mbox_lock); in beiscsi_set_host_data()
1565 struct be_ctrl_info *ctrl = &phba->ctrl; in beiscsi_set_uer_feature()
1570 mutex_lock(&ctrl->mbox_lock); in beiscsi_set_uer_feature()
1571 wrb = wrb_from_mbox(&ctrl->mbox_mem); in beiscsi_set_uer_feature()
1576 be_cmd_hdr_prepare(&ioctl->h.req_hdr, CMD_SUBSYSTEM_COMMON, in beiscsi_set_uer_feature()
1579 ioctl->feature = BE_CMD_SET_FEATURE_UER; in beiscsi_set_uer_feature()
1580 ioctl->param_len = sizeof(ioctl->param.req); in beiscsi_set_uer_feature()
1581 ioctl->param.req.uer = BE_CMD_UER_SUPP_BIT; in beiscsi_set_uer_feature()
1584 phba->ue2rp = ioctl->param.resp.ue2rp; in beiscsi_set_uer_feature()
1585 set_bit(BEISCSI_HBA_UER_SUPP, &phba->state); in beiscsi_set_uer_feature()
1599 mutex_unlock(&ctrl->mbox_lock); in beiscsi_set_uer_feature()
1608 sem = ioread32(phba->csr_va + SLIPORT_SEMAPHORE_OFFSET_BEx); in beiscsi_get_post_stage()
1610 pci_read_config_dword(phba->pcidev, in beiscsi_get_post_stage()
1620 while (loop--) { in beiscsi_check_fw_rdy()
1641 struct be_ctrl_info *ctrl = &phba->ctrl; in beiscsi_cmd_function_reset()
1642 struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem); in beiscsi_cmd_function_reset()
1646 mutex_lock(&ctrl->mbox_lock); in beiscsi_cmd_function_reset()
1650 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_COMMON, in beiscsi_cmd_function_reset()
1654 mutex_unlock(&ctrl->mbox_lock); in beiscsi_cmd_function_reset()
1660 struct be_mcc_wrb *wrb = wrb_from_mbox(&ctrl->mbox_mem); in beiscsi_cmd_special_wrb()
1661 struct beiscsi_hba *phba = pci_get_drvdata(ctrl->pdev); in beiscsi_cmd_special_wrb()
1665 mutex_lock(&ctrl->mbox_lock); in beiscsi_cmd_special_wrb()
1696 mutex_unlock(&ctrl->mbox_lock); in beiscsi_cmd_special_wrb()
1707 return -EIO; in beiscsi_init_sliport()
1710 phba->state &= ~BEISCSI_HBA_IN_ERR; in beiscsi_init_sliport()
1713 phba->state &= ~BEISCSI_HBA_UER_SUPP; in beiscsi_init_sliport()
1727 return beiscsi_cmd_special_wrb(&phba->ctrl, 1); in beiscsi_init_sliport()
1731 * beiscsi_cmd_iscsi_cleanup()- Inform FW to cleanup EP data structures.
1733 * @ulp: ULP number.
1737 * Failure: Non-Zero Value
1739 int beiscsi_cmd_iscsi_cleanup(struct beiscsi_hba *phba, unsigned short ulp) in beiscsi_cmd_iscsi_cleanup() argument
1741 struct be_ctrl_info *ctrl = &phba->ctrl; in beiscsi_cmd_iscsi_cleanup()
1748 mutex_lock(&ctrl->mbox_lock); in beiscsi_cmd_iscsi_cleanup()
1749 wrb = wrb_from_mbox(&ctrl->mbox_mem); in beiscsi_cmd_iscsi_cleanup()
1751 hdr_ring_id = HWI_GET_DEF_HDRQ_ID(phba, ulp); in beiscsi_cmd_iscsi_cleanup()
1752 data_ring_id = HWI_GET_DEF_BUFQ_ID(phba, ulp); in beiscsi_cmd_iscsi_cleanup()
1756 be_cmd_hdr_prepare(&req->hdr, CMD_SUBSYSTEM_ISCSI, in beiscsi_cmd_iscsi_cleanup()
1758 req->chute = (1 << ulp); in beiscsi_cmd_iscsi_cleanup()
1759 /* BE2/BE3 FW creates 8-bit ring id */ in beiscsi_cmd_iscsi_cleanup()
1760 req->hdr_ring_id = hdr_ring_id; in beiscsi_cmd_iscsi_cleanup()
1761 req->data_ring_id = data_ring_id; in beiscsi_cmd_iscsi_cleanup()
1765 be_cmd_hdr_prepare(&req_v1->hdr, CMD_SUBSYSTEM_ISCSI, in beiscsi_cmd_iscsi_cleanup()
1768 req_v1->hdr.version = 1; in beiscsi_cmd_iscsi_cleanup()
1769 req_v1->chute = (1 << ulp); in beiscsi_cmd_iscsi_cleanup()
1770 req_v1->hdr_ring_id = cpu_to_le16(hdr_ring_id); in beiscsi_cmd_iscsi_cleanup()
1771 req_v1->data_ring_id = cpu_to_le16(data_ring_id); in beiscsi_cmd_iscsi_cleanup()
1777 "BG_%d : %s failed %d\n", __func__, ulp); in beiscsi_cmd_iscsi_cleanup()
1778 mutex_unlock(&ctrl->mbox_lock); in beiscsi_cmd_iscsi_cleanup()
1783 * beiscsi_detect_ue()- Detect Unrecoverable Error on adapter
1795 pci_read_config_dword(phba->pcidev, in beiscsi_detect_ue()
1797 pci_read_config_dword(phba->pcidev, in beiscsi_detect_ue()
1800 pci_read_config_dword(phba->pcidev, in beiscsi_detect_ue()
1803 pci_read_config_dword(phba->pcidev, in beiscsi_detect_ue()
1812 set_bit(BEISCSI_HBA_IN_UE, &phba->state); in beiscsi_detect_ue()
1839 * beiscsi_detect_tpe()- Detect Transient Parity Error on adapter
1854 set_bit(BEISCSI_HBA_IN_TPE, &phba->state); in beiscsi_detect_tpe()