Lines Matching refs:rcfw
111 static int bnxt_re_is_fw_stalled(struct bnxt_qplib_rcfw *rcfw, in bnxt_re_is_fw_stalled() argument
117 crsqe = &rcfw->crsqe_tbl[cookie]; in bnxt_re_is_fw_stalled()
118 cmdq = &rcfw->cmdq; in bnxt_re_is_fw_stalled()
121 (rcfw->max_timeout * HZ))) { in bnxt_re_is_fw_stalled()
122 dev_warn_ratelimited(&rcfw->pdev->dev, in bnxt_re_is_fw_stalled()
126 rcfw->max_timeout * 1000, in bnxt_re_is_fw_stalled()
145 static int __wait_for_resp(struct bnxt_qplib_rcfw *rcfw, u16 cookie) in __wait_for_resp() argument
151 cmdq = &rcfw->cmdq; in __wait_for_resp()
152 crsqe = &rcfw->crsqe_tbl[cookie]; in __wait_for_resp()
163 msecs_to_jiffies(rcfw->max_timeout * 1000)); in __wait_for_resp()
168 bnxt_qplib_service_creq(&rcfw->creq.creq_tasklet); in __wait_for_resp()
173 ret = bnxt_re_is_fw_stalled(rcfw, cookie); in __wait_for_resp()
192 static int __block_for_resp(struct bnxt_qplib_rcfw *rcfw, u16 cookie) in __block_for_resp() argument
194 struct bnxt_qplib_cmdq_ctx *cmdq = &rcfw->cmdq; in __block_for_resp()
199 crsqe = &rcfw->crsqe_tbl[cookie]; in __block_for_resp()
209 bnxt_qplib_service_creq(&rcfw->creq.creq_tasklet); in __block_for_resp()
235 static void __send_message_no_waiter(struct bnxt_qplib_rcfw *rcfw, in __send_message_no_waiter() argument
238 struct bnxt_qplib_cmdq_ctx *cmdq = &rcfw->cmdq; in __send_message_no_waiter()
249 crsqe = &rcfw->crsqe_tbl[cookie]; in __send_message_no_waiter()
276 atomic_inc(&rcfw->timeout_send); in __send_message_no_waiter()
283 static int __send_message(struct bnxt_qplib_rcfw *rcfw, in __send_message() argument
296 cmdq = &rcfw->cmdq; in __send_message()
298 pdev = rcfw->pdev; in __send_message()
307 crsqe = &rcfw->crsqe_tbl[cookie]; in __send_message()
387 static int __poll_for_resp(struct bnxt_qplib_rcfw *rcfw, u16 cookie) in __poll_for_resp() argument
389 struct bnxt_qplib_cmdq_ctx *cmdq = &rcfw->cmdq; in __poll_for_resp()
395 crsqe = &rcfw->crsqe_tbl[cookie]; in __poll_for_resp()
405 bnxt_qplib_service_creq(&rcfw->creq.creq_tasklet); in __poll_for_resp()
409 (rcfw->max_timeout * 1000)) { in __poll_for_resp()
410 ret = bnxt_re_is_fw_stalled(rcfw, cookie); in __poll_for_resp()
417 static int __send_message_basic_sanity(struct bnxt_qplib_rcfw *rcfw, in __send_message_basic_sanity() argument
423 cmdq = &rcfw->cmdq; in __send_message_basic_sanity()
426 if (test_bit(ERR_DEVICE_DETACHED, &rcfw->cmdq.flags)) in __send_message_basic_sanity()
433 dev_err(&rcfw->pdev->dev, "QPLIB: RCFW already initialized!"); in __send_message_basic_sanity()
441 dev_err(&rcfw->pdev->dev, in __send_message_basic_sanity()
451 static void __destroy_timedout_ah(struct bnxt_qplib_rcfw *rcfw, in __destroy_timedout_ah() argument
463 __send_message_no_waiter(rcfw, &msg); in __destroy_timedout_ah()
464 dev_info_ratelimited(&rcfw->pdev->dev, in __destroy_timedout_ah()
467 atomic_read(&rcfw->timeout_send)); in __destroy_timedout_ah()
483 static int __bnxt_qplib_rcfw_send_message(struct bnxt_qplib_rcfw *rcfw, in __bnxt_qplib_rcfw_send_message() argument
494 rc = __send_message_basic_sanity(rcfw, msg, opcode); in __bnxt_qplib_rcfw_send_message()
498 rc = __send_message(rcfw, msg, opcode); in __bnxt_qplib_rcfw_send_message()
506 rc = __block_for_resp(rcfw, cookie); in __bnxt_qplib_rcfw_send_message()
507 else if (atomic_read(&rcfw->rcfw_intr_enabled)) in __bnxt_qplib_rcfw_send_message()
508 rc = __wait_for_resp(rcfw, cookie); in __bnxt_qplib_rcfw_send_message()
510 rc = __poll_for_resp(rcfw, cookie); in __bnxt_qplib_rcfw_send_message()
513 spin_lock_bh(&rcfw->cmdq.hwq.lock); in __bnxt_qplib_rcfw_send_message()
514 crsqe = &rcfw->crsqe_tbl[cookie]; in __bnxt_qplib_rcfw_send_message()
517 set_bit(FIRMWARE_STALL_DETECTED, &rcfw->cmdq.flags); in __bnxt_qplib_rcfw_send_message()
518 spin_unlock_bh(&rcfw->cmdq.hwq.lock); in __bnxt_qplib_rcfw_send_message()
524 dev_err(&rcfw->pdev->dev, "cmdq[%#x]=%#x status %#x\n", in __bnxt_qplib_rcfw_send_message()
557 int bnxt_qplib_rcfw_send_message(struct bnxt_qplib_rcfw *rcfw, in bnxt_qplib_rcfw_send_message() argument
563 down(&rcfw->rcfw_inflight); in bnxt_qplib_rcfw_send_message()
564 ret = __bnxt_qplib_rcfw_send_message(rcfw, msg); in bnxt_qplib_rcfw_send_message()
565 up(&rcfw->rcfw_inflight); in bnxt_qplib_rcfw_send_message()
567 ret = __bnxt_qplib_rcfw_send_message(rcfw, msg); in bnxt_qplib_rcfw_send_message()
574 static int bnxt_qplib_process_func_event(struct bnxt_qplib_rcfw *rcfw, in bnxt_qplib_process_func_event() argument
613 rc = rcfw->creq.aeq_handler(rcfw, (void *)func_event, NULL); in bnxt_qplib_process_func_event()
617 static int bnxt_qplib_process_qp_event(struct bnxt_qplib_rcfw *rcfw, in bnxt_qplib_process_qp_event() argument
622 struct bnxt_qplib_hwq *hwq = &rcfw->cmdq.hwq; in bnxt_qplib_process_qp_event()
632 pdev = rcfw->pdev; in bnxt_qplib_process_qp_event()
637 spin_lock(&rcfw->tbl_lock); in bnxt_qplib_process_qp_event()
638 tbl_indx = map_qp_id_to_tbl_indx(qp_id, rcfw); in bnxt_qplib_process_qp_event()
639 qp = rcfw->qp_tbl[tbl_indx].qp_handle; in bnxt_qplib_process_qp_event()
641 spin_unlock(&rcfw->tbl_lock); in bnxt_qplib_process_qp_event()
645 rc = rcfw->creq.aeq_handler(rcfw, qp_event, qp); in bnxt_qplib_process_qp_event()
646 spin_unlock(&rcfw->tbl_lock); in bnxt_qplib_process_qp_event()
667 crsqe = &rcfw->crsqe_tbl[cookie]; in bnxt_qplib_process_qp_event()
670 &rcfw->cmdq.flags), in bnxt_qplib_process_qp_event()
680 atomic_dec(&rcfw->timeout_send); in bnxt_qplib_process_qp_event()
720 __destroy_timedout_ah(rcfw, in bnxt_qplib_process_qp_event()
732 struct bnxt_qplib_rcfw *rcfw = from_tasklet(rcfw, t, creq.creq_tasklet); in bnxt_qplib_service_creq() local
733 struct bnxt_qplib_creq_ctx *creq = &rcfw->creq; in bnxt_qplib_service_creq()
750 rcfw->cmdq.last_seen = jiffies; in bnxt_qplib_service_creq()
756 (rcfw, (struct creq_qp_event *)creqe, in bnxt_qplib_service_creq()
762 (rcfw, (struct creq_func_event *)creqe)) in bnxt_qplib_service_creq()
765 dev_warn(&rcfw->pdev->dev, in bnxt_qplib_service_creq()
770 dev_warn(&rcfw->pdev->dev, in bnxt_qplib_service_creq()
783 rcfw->res->cctx, true); in bnxt_qplib_service_creq()
786 wake_up_nr(&rcfw->cmdq.waitq, num_wakeup); in bnxt_qplib_service_creq()
791 struct bnxt_qplib_rcfw *rcfw = dev_instance; in bnxt_qplib_creq_irq() local
796 creq = &rcfw->creq; in bnxt_qplib_creq_irq()
808 int bnxt_qplib_deinit_rcfw(struct bnxt_qplib_rcfw *rcfw) in bnxt_qplib_deinit_rcfw() argument
820 rc = bnxt_qplib_rcfw_send_message(rcfw, &msg); in bnxt_qplib_deinit_rcfw()
824 clear_bit(FIRMWARE_INITIALIZED_FLAG, &rcfw->cmdq.flags); in bnxt_qplib_deinit_rcfw()
828 int bnxt_qplib_init_rcfw(struct bnxt_qplib_rcfw *rcfw, in bnxt_qplib_init_rcfw() argument
854 if (bnxt_qplib_is_chip_gen_p5_p7(rcfw->res->cctx)) in bnxt_qplib_init_rcfw()
907 if (BNXT_RE_HW_RETX(rcfw->res->dattr->dev_cap_flags)) in bnxt_qplib_init_rcfw()
911 rc = bnxt_qplib_rcfw_send_message(rcfw, &msg); in bnxt_qplib_init_rcfw()
914 set_bit(FIRMWARE_INITIALIZED_FLAG, &rcfw->cmdq.flags); in bnxt_qplib_init_rcfw()
918 void bnxt_qplib_free_rcfw_channel(struct bnxt_qplib_rcfw *rcfw) in bnxt_qplib_free_rcfw_channel() argument
920 kfree(rcfw->qp_tbl); in bnxt_qplib_free_rcfw_channel()
921 kfree(rcfw->crsqe_tbl); in bnxt_qplib_free_rcfw_channel()
922 bnxt_qplib_free_hwq(rcfw->res, &rcfw->cmdq.hwq); in bnxt_qplib_free_rcfw_channel()
923 bnxt_qplib_free_hwq(rcfw->res, &rcfw->creq.hwq); in bnxt_qplib_free_rcfw_channel()
924 rcfw->pdev = NULL; in bnxt_qplib_free_rcfw_channel()
928 struct bnxt_qplib_rcfw *rcfw, in bnxt_qplib_alloc_rcfw_channel() argument
937 rcfw->pdev = res->pdev; in bnxt_qplib_alloc_rcfw_channel()
938 cmdq = &rcfw->cmdq; in bnxt_qplib_alloc_rcfw_channel()
939 creq = &rcfw->creq; in bnxt_qplib_alloc_rcfw_channel()
940 rcfw->res = res; in bnxt_qplib_alloc_rcfw_channel()
946 hwq_attr.res = rcfw->res; in bnxt_qplib_alloc_rcfw_channel()
952 dev_err(&rcfw->pdev->dev, in bnxt_qplib_alloc_rcfw_channel()
957 rcfw->cmdq_depth = BNXT_QPLIB_CMDQE_MAX_CNT; in bnxt_qplib_alloc_rcfw_channel()
959 sginfo.pgsize = bnxt_qplib_cmdqe_page_size(rcfw->cmdq_depth); in bnxt_qplib_alloc_rcfw_channel()
960 hwq_attr.depth = rcfw->cmdq_depth & 0x7FFFFFFF; in bnxt_qplib_alloc_rcfw_channel()
964 dev_err(&rcfw->pdev->dev, in bnxt_qplib_alloc_rcfw_channel()
969 rcfw->crsqe_tbl = kcalloc(cmdq->hwq.max_elements, in bnxt_qplib_alloc_rcfw_channel()
970 sizeof(*rcfw->crsqe_tbl), GFP_KERNEL); in bnxt_qplib_alloc_rcfw_channel()
971 if (!rcfw->crsqe_tbl) in bnxt_qplib_alloc_rcfw_channel()
975 rcfw->qp_tbl_size = qp_tbl_sz + 1; in bnxt_qplib_alloc_rcfw_channel()
976 rcfw->qp_tbl = kcalloc(rcfw->qp_tbl_size, sizeof(struct bnxt_qplib_qp_node), in bnxt_qplib_alloc_rcfw_channel()
978 if (!rcfw->qp_tbl) in bnxt_qplib_alloc_rcfw_channel()
980 spin_lock_init(&rcfw->tbl_lock); in bnxt_qplib_alloc_rcfw_channel()
982 rcfw->max_timeout = res->cctx->hwrm_cmd_max_timeout; in bnxt_qplib_alloc_rcfw_channel()
987 bnxt_qplib_free_rcfw_channel(rcfw); in bnxt_qplib_alloc_rcfw_channel()
991 void bnxt_qplib_rcfw_stop_irq(struct bnxt_qplib_rcfw *rcfw, bool kill) in bnxt_qplib_rcfw_stop_irq() argument
995 creq = &rcfw->creq; in bnxt_qplib_rcfw_stop_irq()
1002 bnxt_qplib_ring_nq_db(&creq->creq_db.dbinfo, rcfw->res->cctx, false); in bnxt_qplib_rcfw_stop_irq()
1005 free_irq(creq->msix_vec, rcfw); in bnxt_qplib_rcfw_stop_irq()
1008 atomic_set(&rcfw->rcfw_intr_enabled, 0); in bnxt_qplib_rcfw_stop_irq()
1014 void bnxt_qplib_disable_rcfw_channel(struct bnxt_qplib_rcfw *rcfw) in bnxt_qplib_disable_rcfw_channel() argument
1019 creq = &rcfw->creq; in bnxt_qplib_disable_rcfw_channel()
1020 cmdq = &rcfw->cmdq; in bnxt_qplib_disable_rcfw_channel()
1022 bnxt_qplib_rcfw_stop_irq(rcfw, true); in bnxt_qplib_disable_rcfw_channel()
1033 int bnxt_qplib_rcfw_start_irq(struct bnxt_qplib_rcfw *rcfw, int msix_vector, in bnxt_qplib_rcfw_start_irq() argument
1040 creq = &rcfw->creq; in bnxt_qplib_rcfw_start_irq()
1041 res = rcfw->res; in bnxt_qplib_rcfw_start_irq()
1057 creq->irq_name, rcfw); in bnxt_qplib_rcfw_start_irq()
1067 atomic_inc(&rcfw->rcfw_intr_enabled); in bnxt_qplib_rcfw_start_irq()
1072 static int bnxt_qplib_map_cmdq_mbox(struct bnxt_qplib_rcfw *rcfw) in bnxt_qplib_map_cmdq_mbox() argument
1078 pdev = rcfw->pdev; in bnxt_qplib_map_cmdq_mbox()
1079 mbox = &rcfw->cmdq.cmdq_mbox; in bnxt_qplib_map_cmdq_mbox()
1107 static int bnxt_qplib_map_creq_db(struct bnxt_qplib_rcfw *rcfw, u32 reg_offt) in bnxt_qplib_map_creq_db() argument
1113 pdev = rcfw->pdev; in bnxt_qplib_map_creq_db()
1114 creq_db = &rcfw->creq.creq_db; in bnxt_qplib_map_creq_db()
1135 creq_db->dbinfo.hwq = &rcfw->creq.hwq; in bnxt_qplib_map_creq_db()
1136 creq_db->dbinfo.xid = rcfw->creq.ring_id; in bnxt_qplib_map_creq_db()
1140 static void bnxt_qplib_start_rcfw(struct bnxt_qplib_rcfw *rcfw) in bnxt_qplib_start_rcfw() argument
1147 cmdq = &rcfw->cmdq; in bnxt_qplib_start_rcfw()
1148 creq = &rcfw->creq; in bnxt_qplib_start_rcfw()
1153 cpu_to_le16(((rcfw->cmdq_depth << in bnxt_qplib_start_rcfw()
1164 int bnxt_qplib_enable_rcfw_channel(struct bnxt_qplib_rcfw *rcfw, in bnxt_qplib_enable_rcfw_channel() argument
1173 cmdq = &rcfw->cmdq; in bnxt_qplib_enable_rcfw_channel()
1174 creq = &rcfw->creq; in bnxt_qplib_enable_rcfw_channel()
1186 rc = bnxt_qplib_map_cmdq_mbox(rcfw); in bnxt_qplib_enable_rcfw_channel()
1190 rc = bnxt_qplib_map_creq_db(rcfw, cp_bar_reg_off); in bnxt_qplib_enable_rcfw_channel()
1194 rc = bnxt_qplib_rcfw_start_irq(rcfw, msix_vector, true); in bnxt_qplib_enable_rcfw_channel()
1196 dev_err(&rcfw->pdev->dev, in bnxt_qplib_enable_rcfw_channel()
1198 bnxt_qplib_disable_rcfw_channel(rcfw); in bnxt_qplib_enable_rcfw_channel()
1202 sema_init(&rcfw->rcfw_inflight, RCFW_CMD_NON_BLOCKING_SHADOW_QD); in bnxt_qplib_enable_rcfw_channel()
1203 bnxt_qplib_start_rcfw(rcfw); in bnxt_qplib_enable_rcfw_channel()