Lines Matching refs:rcfw

56 static int __wait_for_resp(struct bnxt_qplib_rcfw *rcfw, u16 cookie)  in __wait_for_resp()  argument
61 cbit = cookie % rcfw->cmdq_depth; in __wait_for_resp()
62 rc = wait_event_timeout(rcfw->waitq, in __wait_for_resp()
63 !test_bit(cbit, rcfw->cmdq_bitmap), in __wait_for_resp()
68 static int __block_for_resp(struct bnxt_qplib_rcfw *rcfw, u16 cookie) in __block_for_resp() argument
73 cbit = cookie % rcfw->cmdq_depth; in __block_for_resp()
74 if (!test_bit(cbit, rcfw->cmdq_bitmap)) in __block_for_resp()
78 bnxt_qplib_service_creq((unsigned long)rcfw); in __block_for_resp()
79 } while (test_bit(cbit, rcfw->cmdq_bitmap) && --count); in __block_for_resp()
84 static int __send_message(struct bnxt_qplib_rcfw *rcfw, struct cmdq_base *req, in __send_message() argument
88 struct bnxt_qplib_hwq *cmdq = &rcfw->cmdq; in __send_message()
89 u32 cmdq_depth = rcfw->cmdq_depth; in __send_message()
98 if (!test_bit(FIRMWARE_INITIALIZED_FLAG, &rcfw->flags) && in __send_message()
102 dev_err(&rcfw->pdev->dev, in __send_message()
107 if (test_bit(FIRMWARE_INITIALIZED_FLAG, &rcfw->flags) && in __send_message()
109 dev_err(&rcfw->pdev->dev, "RCFW already initialized!\n"); in __send_message()
113 if (test_bit(FIRMWARE_TIMED_OUT, &rcfw->flags)) in __send_message()
121 dev_err(&rcfw->pdev->dev, "RCFW: CMDQ is full!\n"); in __send_message()
127 cookie = rcfw->seq_num & RCFW_MAX_COOKIE_VALUE; in __send_message()
128 cbit = cookie % rcfw->cmdq_depth; in __send_message()
132 set_bit(cbit, rcfw->cmdq_bitmap); in __send_message()
134 crsqe = &rcfw->crsqe_tbl[cbit]; in __send_message()
166 dev_err(&rcfw->pdev->dev, in __send_message()
176 rcfw->seq_num++; in __send_message()
179 rcfw->seq_num++; in __send_message()
182 if (test_bit(FIRMWARE_FIRST_FLAG, &rcfw->flags)) { in __send_message()
189 clear_bit(FIRMWARE_FIRST_FLAG, &rcfw->flags); in __send_message()
194 writel(cmdq_prod, rcfw->cmdq_bar_reg_iomem + in __send_message()
195 rcfw->cmdq_bar_reg_prod_off); in __send_message()
196 writel(RCFW_CMDQ_TRIG_VAL, rcfw->cmdq_bar_reg_iomem + in __send_message()
197 rcfw->cmdq_bar_reg_trig_off); in __send_message()
204 int bnxt_qplib_rcfw_send_message(struct bnxt_qplib_rcfw *rcfw, in bnxt_qplib_rcfw_send_message() argument
216 rc = __send_message(rcfw, req, resp, sb, is_block); in bnxt_qplib_rcfw_send_message()
223 dev_err(&rcfw->pdev->dev, "cmdq[%#x]=%#x send failed\n", in bnxt_qplib_rcfw_send_message()
232 rc = __block_for_resp(rcfw, cookie); in bnxt_qplib_rcfw_send_message()
234 rc = __wait_for_resp(rcfw, cookie); in bnxt_qplib_rcfw_send_message()
237 dev_err(&rcfw->pdev->dev, "cmdq[%#x]=%#x timedout (%d)msec\n", in bnxt_qplib_rcfw_send_message()
239 set_bit(FIRMWARE_TIMED_OUT, &rcfw->flags); in bnxt_qplib_rcfw_send_message()
245 dev_err(&rcfw->pdev->dev, "cmdq[%#x]=%#x status %#x\n", in bnxt_qplib_rcfw_send_message()
253 static int bnxt_qplib_process_func_event(struct bnxt_qplib_rcfw *rcfw, in bnxt_qplib_process_func_event() argument
292 static int bnxt_qplib_process_qp_event(struct bnxt_qplib_rcfw *rcfw, in bnxt_qplib_process_qp_event() argument
295 struct bnxt_qplib_hwq *cmdq = &rcfw->cmdq; in bnxt_qplib_process_qp_event()
309 qp = rcfw->qp_tbl[qp_id].qp_handle; in bnxt_qplib_process_qp_event()
310 dev_dbg(&rcfw->pdev->dev, in bnxt_qplib_process_qp_event()
312 dev_dbg(&rcfw->pdev->dev, in bnxt_qplib_process_qp_event()
319 rcfw->aeq_handler(rcfw, qp_event, qp); in bnxt_qplib_process_qp_event()
337 cbit = cookie % rcfw->cmdq_depth; in bnxt_qplib_process_qp_event()
338 crsqe = &rcfw->crsqe_tbl[cbit]; in bnxt_qplib_process_qp_event()
345 dev_err(&rcfw->pdev->dev, in bnxt_qplib_process_qp_event()
351 if (!test_and_clear_bit(cbit, rcfw->cmdq_bitmap)) in bnxt_qplib_process_qp_event()
352 dev_warn(&rcfw->pdev->dev, in bnxt_qplib_process_qp_event()
358 wake_up(&rcfw->waitq); in bnxt_qplib_process_qp_event()
367 struct bnxt_qplib_rcfw *rcfw = (struct bnxt_qplib_rcfw *)data; in bnxt_qplib_service_creq() local
368 bool gen_p5 = bnxt_qplib_is_chip_gen_p5(rcfw->res->cctx); in bnxt_qplib_service_creq()
369 struct bnxt_qplib_hwq *creq = &rcfw->creq; in bnxt_qplib_service_creq()
393 (rcfw, (struct creq_qp_event *)creqe); in bnxt_qplib_service_creq()
394 rcfw->creq_qp_event_processed++; in bnxt_qplib_service_creq()
398 (rcfw, (struct creq_func_event *)creqe)) in bnxt_qplib_service_creq()
399 rcfw->creq_func_event_processed++; in bnxt_qplib_service_creq()
401 dev_warn(&rcfw->pdev->dev, in bnxt_qplib_service_creq()
406 dev_warn(&rcfw->pdev->dev, in bnxt_qplib_service_creq()
417 bnxt_qplib_ring_creq_db_rearm(rcfw->creq_bar_reg_iomem, in bnxt_qplib_service_creq()
419 rcfw->creq_ring_id, gen_p5); in bnxt_qplib_service_creq()
426 struct bnxt_qplib_rcfw *rcfw = dev_instance; in bnxt_qplib_creq_irq() local
427 struct bnxt_qplib_hwq *creq = &rcfw->creq; in bnxt_qplib_creq_irq()
433 creq_ptr = (struct creq_base **)rcfw->creq.pbl_ptr; in bnxt_qplib_creq_irq()
436 tasklet_schedule(&rcfw->worker); in bnxt_qplib_creq_irq()
442 int bnxt_qplib_deinit_rcfw(struct bnxt_qplib_rcfw *rcfw) in bnxt_qplib_deinit_rcfw() argument
450 rc = bnxt_qplib_rcfw_send_message(rcfw, (void *)&req, (void *)&resp, in bnxt_qplib_deinit_rcfw()
455 clear_bit(FIRMWARE_INITIALIZED_FLAG, &rcfw->flags); in bnxt_qplib_deinit_rcfw()
476 int bnxt_qplib_init_rcfw(struct bnxt_qplib_rcfw *rcfw, in bnxt_qplib_init_rcfw() argument
497 if (is_virtfn || bnxt_qplib_is_chip_gen_p5(rcfw->res->cctx)) in bnxt_qplib_init_rcfw()
551 rc = bnxt_qplib_rcfw_send_message(rcfw, (void *)&req, (void *)&resp, in bnxt_qplib_init_rcfw()
555 set_bit(FIRMWARE_INITIALIZED_FLAG, &rcfw->flags); in bnxt_qplib_init_rcfw()
559 void bnxt_qplib_free_rcfw_channel(struct bnxt_qplib_rcfw *rcfw) in bnxt_qplib_free_rcfw_channel() argument
561 kfree(rcfw->qp_tbl); in bnxt_qplib_free_rcfw_channel()
562 kfree(rcfw->crsqe_tbl); in bnxt_qplib_free_rcfw_channel()
563 bnxt_qplib_free_hwq(rcfw->pdev, &rcfw->cmdq); in bnxt_qplib_free_rcfw_channel()
564 bnxt_qplib_free_hwq(rcfw->pdev, &rcfw->creq); in bnxt_qplib_free_rcfw_channel()
565 rcfw->pdev = NULL; in bnxt_qplib_free_rcfw_channel()
569 struct bnxt_qplib_rcfw *rcfw, in bnxt_qplib_alloc_rcfw_channel() argument
575 rcfw->pdev = pdev; in bnxt_qplib_alloc_rcfw_channel()
576 rcfw->creq.max_elements = BNXT_QPLIB_CREQE_MAX_CNT; in bnxt_qplib_alloc_rcfw_channel()
577 hwq_type = bnxt_qplib_get_hwq_type(rcfw->res); in bnxt_qplib_alloc_rcfw_channel()
578 if (bnxt_qplib_alloc_init_hwq(rcfw->pdev, &rcfw->creq, NULL, in bnxt_qplib_alloc_rcfw_channel()
579 &rcfw->creq.max_elements, in bnxt_qplib_alloc_rcfw_channel()
582 dev_err(&rcfw->pdev->dev, in bnxt_qplib_alloc_rcfw_channel()
587 rcfw->cmdq_depth = BNXT_QPLIB_CMDQE_MAX_CNT_256; in bnxt_qplib_alloc_rcfw_channel()
589 rcfw->cmdq_depth = BNXT_QPLIB_CMDQE_MAX_CNT_8192; in bnxt_qplib_alloc_rcfw_channel()
591 rcfw->cmdq.max_elements = rcfw->cmdq_depth; in bnxt_qplib_alloc_rcfw_channel()
593 (rcfw->pdev, &rcfw->cmdq, NULL, in bnxt_qplib_alloc_rcfw_channel()
594 &rcfw->cmdq.max_elements, in bnxt_qplib_alloc_rcfw_channel()
596 bnxt_qplib_cmdqe_page_size(rcfw->cmdq_depth), in bnxt_qplib_alloc_rcfw_channel()
598 dev_err(&rcfw->pdev->dev, in bnxt_qplib_alloc_rcfw_channel()
603 rcfw->crsqe_tbl = kcalloc(rcfw->cmdq.max_elements, in bnxt_qplib_alloc_rcfw_channel()
604 sizeof(*rcfw->crsqe_tbl), GFP_KERNEL); in bnxt_qplib_alloc_rcfw_channel()
605 if (!rcfw->crsqe_tbl) in bnxt_qplib_alloc_rcfw_channel()
608 rcfw->qp_tbl_size = qp_tbl_sz; in bnxt_qplib_alloc_rcfw_channel()
609 rcfw->qp_tbl = kcalloc(qp_tbl_sz, sizeof(struct bnxt_qplib_qp_node), in bnxt_qplib_alloc_rcfw_channel()
611 if (!rcfw->qp_tbl) in bnxt_qplib_alloc_rcfw_channel()
617 bnxt_qplib_free_rcfw_channel(rcfw); in bnxt_qplib_alloc_rcfw_channel()
621 void bnxt_qplib_rcfw_stop_irq(struct bnxt_qplib_rcfw *rcfw, bool kill) in bnxt_qplib_rcfw_stop_irq() argument
623 bool gen_p5 = bnxt_qplib_is_chip_gen_p5(rcfw->res->cctx); in bnxt_qplib_rcfw_stop_irq()
625 tasklet_disable(&rcfw->worker); in bnxt_qplib_rcfw_stop_irq()
627 bnxt_qplib_ring_creq_db(rcfw->creq_bar_reg_iomem, rcfw->creq.cons, in bnxt_qplib_rcfw_stop_irq()
628 rcfw->creq.max_elements, rcfw->creq_ring_id, in bnxt_qplib_rcfw_stop_irq()
631 synchronize_irq(rcfw->vector); in bnxt_qplib_rcfw_stop_irq()
633 tasklet_kill(&rcfw->worker); in bnxt_qplib_rcfw_stop_irq()
635 if (rcfw->requested) { in bnxt_qplib_rcfw_stop_irq()
636 free_irq(rcfw->vector, rcfw); in bnxt_qplib_rcfw_stop_irq()
637 rcfw->requested = false; in bnxt_qplib_rcfw_stop_irq()
641 void bnxt_qplib_disable_rcfw_channel(struct bnxt_qplib_rcfw *rcfw) in bnxt_qplib_disable_rcfw_channel() argument
645 bnxt_qplib_rcfw_stop_irq(rcfw, true); in bnxt_qplib_disable_rcfw_channel()
647 iounmap(rcfw->cmdq_bar_reg_iomem); in bnxt_qplib_disable_rcfw_channel()
648 iounmap(rcfw->creq_bar_reg_iomem); in bnxt_qplib_disable_rcfw_channel()
650 indx = find_first_bit(rcfw->cmdq_bitmap, rcfw->bmap_size); in bnxt_qplib_disable_rcfw_channel()
651 if (indx != rcfw->bmap_size) in bnxt_qplib_disable_rcfw_channel()
652 dev_err(&rcfw->pdev->dev, in bnxt_qplib_disable_rcfw_channel()
654 kfree(rcfw->cmdq_bitmap); in bnxt_qplib_disable_rcfw_channel()
655 rcfw->bmap_size = 0; in bnxt_qplib_disable_rcfw_channel()
657 rcfw->cmdq_bar_reg_iomem = NULL; in bnxt_qplib_disable_rcfw_channel()
658 rcfw->creq_bar_reg_iomem = NULL; in bnxt_qplib_disable_rcfw_channel()
659 rcfw->aeq_handler = NULL; in bnxt_qplib_disable_rcfw_channel()
660 rcfw->vector = 0; in bnxt_qplib_disable_rcfw_channel()
663 int bnxt_qplib_rcfw_start_irq(struct bnxt_qplib_rcfw *rcfw, int msix_vector, in bnxt_qplib_rcfw_start_irq() argument
666 bool gen_p5 = bnxt_qplib_is_chip_gen_p5(rcfw->res->cctx); in bnxt_qplib_rcfw_start_irq()
669 if (rcfw->requested) in bnxt_qplib_rcfw_start_irq()
672 rcfw->vector = msix_vector; in bnxt_qplib_rcfw_start_irq()
674 tasklet_init(&rcfw->worker, in bnxt_qplib_rcfw_start_irq()
675 bnxt_qplib_service_creq, (unsigned long)rcfw); in bnxt_qplib_rcfw_start_irq()
677 tasklet_enable(&rcfw->worker); in bnxt_qplib_rcfw_start_irq()
678 rc = request_irq(rcfw->vector, bnxt_qplib_creq_irq, 0, in bnxt_qplib_rcfw_start_irq()
679 "bnxt_qplib_creq", rcfw); in bnxt_qplib_rcfw_start_irq()
682 rcfw->requested = true; in bnxt_qplib_rcfw_start_irq()
683 bnxt_qplib_ring_creq_db_rearm(rcfw->creq_bar_reg_iomem, in bnxt_qplib_rcfw_start_irq()
684 rcfw->creq.cons, rcfw->creq.max_elements, in bnxt_qplib_rcfw_start_irq()
685 rcfw->creq_ring_id, gen_p5); in bnxt_qplib_rcfw_start_irq()
691 struct bnxt_qplib_rcfw *rcfw, in bnxt_qplib_enable_rcfw_channel() argument
703 rcfw->seq_num = 0; in bnxt_qplib_enable_rcfw_channel()
704 set_bit(FIRMWARE_FIRST_FLAG, &rcfw->flags); in bnxt_qplib_enable_rcfw_channel()
705 bmap_size = BITS_TO_LONGS(rcfw->cmdq_depth) * sizeof(unsigned long); in bnxt_qplib_enable_rcfw_channel()
706 rcfw->cmdq_bitmap = kzalloc(bmap_size, GFP_KERNEL); in bnxt_qplib_enable_rcfw_channel()
707 if (!rcfw->cmdq_bitmap) in bnxt_qplib_enable_rcfw_channel()
709 rcfw->bmap_size = bmap_size; in bnxt_qplib_enable_rcfw_channel()
712 rcfw->cmdq_bar_reg = RCFW_COMM_PCI_BAR_REGION; in bnxt_qplib_enable_rcfw_channel()
713 res_base = pci_resource_start(pdev, rcfw->cmdq_bar_reg); in bnxt_qplib_enable_rcfw_channel()
717 rcfw->cmdq_bar_reg_iomem = ioremap_nocache(res_base + in bnxt_qplib_enable_rcfw_channel()
720 if (!rcfw->cmdq_bar_reg_iomem) { in bnxt_qplib_enable_rcfw_channel()
721 dev_err(&rcfw->pdev->dev, "CMDQ BAR region %d mapping failed\n", in bnxt_qplib_enable_rcfw_channel()
722 rcfw->cmdq_bar_reg); in bnxt_qplib_enable_rcfw_channel()
726 rcfw->cmdq_bar_reg_prod_off = virt_fn ? RCFW_VF_COMM_PROD_OFFSET : in bnxt_qplib_enable_rcfw_channel()
729 rcfw->cmdq_bar_reg_trig_off = RCFW_COMM_TRIG_OFFSET; in bnxt_qplib_enable_rcfw_channel()
732 rcfw->creq_bar_reg = RCFW_COMM_CONS_PCI_BAR_REGION; in bnxt_qplib_enable_rcfw_channel()
733 res_base = pci_resource_start(pdev, rcfw->creq_bar_reg); in bnxt_qplib_enable_rcfw_channel()
735 dev_err(&rcfw->pdev->dev, in bnxt_qplib_enable_rcfw_channel()
737 rcfw->creq_bar_reg); in bnxt_qplib_enable_rcfw_channel()
739 rcfw->creq_bar_reg_iomem = ioremap_nocache(res_base + cp_bar_reg_off, in bnxt_qplib_enable_rcfw_channel()
741 if (!rcfw->creq_bar_reg_iomem) { in bnxt_qplib_enable_rcfw_channel()
742 dev_err(&rcfw->pdev->dev, "CREQ BAR region %d mapping failed\n", in bnxt_qplib_enable_rcfw_channel()
743 rcfw->creq_bar_reg); in bnxt_qplib_enable_rcfw_channel()
744 iounmap(rcfw->cmdq_bar_reg_iomem); in bnxt_qplib_enable_rcfw_channel()
745 rcfw->cmdq_bar_reg_iomem = NULL; in bnxt_qplib_enable_rcfw_channel()
748 rcfw->creq_qp_event_processed = 0; in bnxt_qplib_enable_rcfw_channel()
749 rcfw->creq_func_event_processed = 0; in bnxt_qplib_enable_rcfw_channel()
752 rcfw->aeq_handler = aeq_handler; in bnxt_qplib_enable_rcfw_channel()
753 init_waitqueue_head(&rcfw->waitq); in bnxt_qplib_enable_rcfw_channel()
755 rc = bnxt_qplib_rcfw_start_irq(rcfw, msix_vector, true); in bnxt_qplib_enable_rcfw_channel()
757 dev_err(&rcfw->pdev->dev, in bnxt_qplib_enable_rcfw_channel()
759 bnxt_qplib_disable_rcfw_channel(rcfw); in bnxt_qplib_enable_rcfw_channel()
763 init.cmdq_pbl = cpu_to_le64(rcfw->cmdq.pbl[PBL_LVL_0].pg_map_arr[0]); in bnxt_qplib_enable_rcfw_channel()
765 ((rcfw->cmdq_depth << CMDQ_INIT_CMDQ_SIZE_SFT) & in bnxt_qplib_enable_rcfw_channel()
767 ((rcfw->cmdq.level << CMDQ_INIT_CMDQ_LVL_SFT) & in bnxt_qplib_enable_rcfw_channel()
769 init.creq_ring_id = cpu_to_le16(rcfw->creq_ring_id); in bnxt_qplib_enable_rcfw_channel()
772 __iowrite32_copy(rcfw->cmdq_bar_reg_iomem, &init, sizeof(init) / 4); in bnxt_qplib_enable_rcfw_channel()
777 struct bnxt_qplib_rcfw *rcfw, in bnxt_qplib_rcfw_alloc_sbuf() argument
787 sbuf->sb = dma_alloc_coherent(&rcfw->pdev->dev, sbuf->size, in bnxt_qplib_rcfw_alloc_sbuf()
798 void bnxt_qplib_rcfw_free_sbuf(struct bnxt_qplib_rcfw *rcfw, in bnxt_qplib_rcfw_free_sbuf() argument
802 dma_free_coherent(&rcfw->pdev->dev, sbuf->size, in bnxt_qplib_rcfw_free_sbuf()