Lines Matching refs:rcfw

53 static int __wait_for_resp(struct bnxt_qplib_rcfw *rcfw, u16 cookie)  in __wait_for_resp()  argument
59 rc = wait_event_timeout(rcfw->waitq, in __wait_for_resp()
60 !test_bit(cbit, rcfw->cmdq_bitmap), in __wait_for_resp()
65 static int __block_for_resp(struct bnxt_qplib_rcfw *rcfw, u16 cookie) in __block_for_resp() argument
71 if (!test_bit(cbit, rcfw->cmdq_bitmap)) in __block_for_resp()
75 bnxt_qplib_service_creq((unsigned long)rcfw); in __block_for_resp()
76 } while (test_bit(cbit, rcfw->cmdq_bitmap) && --count); in __block_for_resp()
81 static int __send_message(struct bnxt_qplib_rcfw *rcfw, struct cmdq_base *req, in __send_message() argument
85 struct bnxt_qplib_hwq *cmdq = &rcfw->cmdq; in __send_message()
94 if (!test_bit(FIRMWARE_INITIALIZED_FLAG, &rcfw->flags) && in __send_message()
98 dev_err(&rcfw->pdev->dev, in __send_message()
104 if (test_bit(FIRMWARE_INITIALIZED_FLAG, &rcfw->flags) && in __send_message()
106 dev_err(&rcfw->pdev->dev, "QPLIB: RCFW already initialized!"); in __send_message()
110 if (test_bit(FIRMWARE_TIMED_OUT, &rcfw->flags)) in __send_message()
118 dev_err(&rcfw->pdev->dev, "QPLIB: RCFW: CMDQ is full!"); in __send_message()
124 cookie = rcfw->seq_num & RCFW_MAX_COOKIE_VALUE; in __send_message()
129 set_bit(cbit, rcfw->cmdq_bitmap); in __send_message()
131 crsqe = &rcfw->crsqe_tbl[cbit]; in __send_message()
156 dev_err(&rcfw->pdev->dev, in __send_message()
166 rcfw->seq_num++; in __send_message()
169 rcfw->seq_num++; in __send_message()
172 if (test_bit(FIRMWARE_FIRST_FLAG, &rcfw->flags)) { in __send_message()
179 clear_bit(FIRMWARE_FIRST_FLAG, &rcfw->flags); in __send_message()
184 writel(cmdq_prod, rcfw->cmdq_bar_reg_iomem + in __send_message()
185 rcfw->cmdq_bar_reg_prod_off); in __send_message()
186 writel(RCFW_CMDQ_TRIG_VAL, rcfw->cmdq_bar_reg_iomem + in __send_message()
187 rcfw->cmdq_bar_reg_trig_off); in __send_message()
194 int bnxt_qplib_rcfw_send_message(struct bnxt_qplib_rcfw *rcfw, in bnxt_qplib_rcfw_send_message() argument
206 rc = __send_message(rcfw, req, resp, sb, is_block); in bnxt_qplib_rcfw_send_message()
213 dev_err(&rcfw->pdev->dev, "QPLIB: cmdq[%#x]=%#x send failed", in bnxt_qplib_rcfw_send_message()
222 rc = __block_for_resp(rcfw, cookie); in bnxt_qplib_rcfw_send_message()
224 rc = __wait_for_resp(rcfw, cookie); in bnxt_qplib_rcfw_send_message()
227 dev_err(&rcfw->pdev->dev, "QPLIB: cmdq[%#x]=%#x timedout (%d)msec", in bnxt_qplib_rcfw_send_message()
229 set_bit(FIRMWARE_TIMED_OUT, &rcfw->flags); in bnxt_qplib_rcfw_send_message()
235 dev_err(&rcfw->pdev->dev, "QPLIB: cmdq[%#x]=%#x status %#x", in bnxt_qplib_rcfw_send_message()
243 static int bnxt_qplib_process_func_event(struct bnxt_qplib_rcfw *rcfw, in bnxt_qplib_process_func_event() argument
282 static int bnxt_qplib_process_qp_event(struct bnxt_qplib_rcfw *rcfw, in bnxt_qplib_process_qp_event() argument
285 struct bnxt_qplib_hwq *cmdq = &rcfw->cmdq; in bnxt_qplib_process_qp_event()
299 qp = rcfw->qp_tbl[qp_id].qp_handle; in bnxt_qplib_process_qp_event()
300 dev_dbg(&rcfw->pdev->dev, in bnxt_qplib_process_qp_event()
302 dev_dbg(&rcfw->pdev->dev, in bnxt_qplib_process_qp_event()
309 rcfw->aeq_handler(rcfw, qp_event, qp); in bnxt_qplib_process_qp_event()
319 crsqe = &rcfw->crsqe_tbl[cbit]; in bnxt_qplib_process_qp_event()
325 dev_err(&rcfw->pdev->dev, in bnxt_qplib_process_qp_event()
330 if (!test_and_clear_bit(cbit, rcfw->cmdq_bitmap)) in bnxt_qplib_process_qp_event()
331 dev_warn(&rcfw->pdev->dev, in bnxt_qplib_process_qp_event()
337 wake_up(&rcfw->waitq); in bnxt_qplib_process_qp_event()
346 struct bnxt_qplib_rcfw *rcfw = (struct bnxt_qplib_rcfw *)data; in bnxt_qplib_service_creq() local
347 struct bnxt_qplib_hwq *creq = &rcfw->creq; in bnxt_qplib_service_creq()
371 (rcfw, (struct creq_qp_event *)creqe); in bnxt_qplib_service_creq()
372 rcfw->creq_qp_event_processed++; in bnxt_qplib_service_creq()
376 (rcfw, (struct creq_func_event *)creqe)) in bnxt_qplib_service_creq()
377 rcfw->creq_func_event_processed++; in bnxt_qplib_service_creq()
380 (&rcfw->pdev->dev, "QPLIB:aeqe:%#x Not handled", in bnxt_qplib_service_creq()
384 dev_warn(&rcfw->pdev->dev, "QPLIB: creqe with "); in bnxt_qplib_service_creq()
385 dev_warn(&rcfw->pdev->dev, in bnxt_qplib_service_creq()
395 CREQ_DB_REARM(rcfw->creq_bar_reg_iomem, raw_cons, in bnxt_qplib_service_creq()
403 struct bnxt_qplib_rcfw *rcfw = dev_instance; in bnxt_qplib_creq_irq() local
404 struct bnxt_qplib_hwq *creq = &rcfw->creq; in bnxt_qplib_creq_irq()
410 creq_ptr = (struct creq_base **)rcfw->creq.pbl_ptr; in bnxt_qplib_creq_irq()
413 tasklet_schedule(&rcfw->worker); in bnxt_qplib_creq_irq()
419 int bnxt_qplib_deinit_rcfw(struct bnxt_qplib_rcfw *rcfw) in bnxt_qplib_deinit_rcfw() argument
427 rc = bnxt_qplib_rcfw_send_message(rcfw, (void *)&req, (void *)&resp, in bnxt_qplib_deinit_rcfw()
432 clear_bit(FIRMWARE_INITIALIZED_FLAG, &rcfw->flags); in bnxt_qplib_deinit_rcfw()
453 int bnxt_qplib_init_rcfw(struct bnxt_qplib_rcfw *rcfw, in bnxt_qplib_init_rcfw() argument
526 rc = bnxt_qplib_rcfw_send_message(rcfw, (void *)&req, (void *)&resp, in bnxt_qplib_init_rcfw()
530 set_bit(FIRMWARE_INITIALIZED_FLAG, &rcfw->flags); in bnxt_qplib_init_rcfw()
534 void bnxt_qplib_free_rcfw_channel(struct bnxt_qplib_rcfw *rcfw) in bnxt_qplib_free_rcfw_channel() argument
536 kfree(rcfw->qp_tbl); in bnxt_qplib_free_rcfw_channel()
537 kfree(rcfw->crsqe_tbl); in bnxt_qplib_free_rcfw_channel()
538 bnxt_qplib_free_hwq(rcfw->pdev, &rcfw->cmdq); in bnxt_qplib_free_rcfw_channel()
539 bnxt_qplib_free_hwq(rcfw->pdev, &rcfw->creq); in bnxt_qplib_free_rcfw_channel()
540 rcfw->pdev = NULL; in bnxt_qplib_free_rcfw_channel()
544 struct bnxt_qplib_rcfw *rcfw, in bnxt_qplib_alloc_rcfw_channel() argument
547 rcfw->pdev = pdev; in bnxt_qplib_alloc_rcfw_channel()
548 rcfw->creq.max_elements = BNXT_QPLIB_CREQE_MAX_CNT; in bnxt_qplib_alloc_rcfw_channel()
549 if (bnxt_qplib_alloc_init_hwq(rcfw->pdev, &rcfw->creq, NULL, 0, in bnxt_qplib_alloc_rcfw_channel()
550 &rcfw->creq.max_elements, in bnxt_qplib_alloc_rcfw_channel()
553 dev_err(&rcfw->pdev->dev, in bnxt_qplib_alloc_rcfw_channel()
557 rcfw->cmdq.max_elements = BNXT_QPLIB_CMDQE_MAX_CNT; in bnxt_qplib_alloc_rcfw_channel()
558 if (bnxt_qplib_alloc_init_hwq(rcfw->pdev, &rcfw->cmdq, NULL, 0, in bnxt_qplib_alloc_rcfw_channel()
559 &rcfw->cmdq.max_elements, in bnxt_qplib_alloc_rcfw_channel()
562 dev_err(&rcfw->pdev->dev, in bnxt_qplib_alloc_rcfw_channel()
567 rcfw->crsqe_tbl = kcalloc(rcfw->cmdq.max_elements, in bnxt_qplib_alloc_rcfw_channel()
568 sizeof(*rcfw->crsqe_tbl), GFP_KERNEL); in bnxt_qplib_alloc_rcfw_channel()
569 if (!rcfw->crsqe_tbl) in bnxt_qplib_alloc_rcfw_channel()
572 rcfw->qp_tbl_size = qp_tbl_sz; in bnxt_qplib_alloc_rcfw_channel()
573 rcfw->qp_tbl = kcalloc(qp_tbl_sz, sizeof(struct bnxt_qplib_qp_node), in bnxt_qplib_alloc_rcfw_channel()
575 if (!rcfw->qp_tbl) in bnxt_qplib_alloc_rcfw_channel()
581 bnxt_qplib_free_rcfw_channel(rcfw); in bnxt_qplib_alloc_rcfw_channel()
585 void bnxt_qplib_rcfw_stop_irq(struct bnxt_qplib_rcfw *rcfw, bool kill) in bnxt_qplib_rcfw_stop_irq() argument
587 tasklet_disable(&rcfw->worker); in bnxt_qplib_rcfw_stop_irq()
589 CREQ_DB(rcfw->creq_bar_reg_iomem, rcfw->creq.cons, in bnxt_qplib_rcfw_stop_irq()
590 rcfw->creq.max_elements); in bnxt_qplib_rcfw_stop_irq()
592 synchronize_irq(rcfw->vector); in bnxt_qplib_rcfw_stop_irq()
594 tasklet_kill(&rcfw->worker); in bnxt_qplib_rcfw_stop_irq()
596 if (rcfw->requested) { in bnxt_qplib_rcfw_stop_irq()
597 free_irq(rcfw->vector, rcfw); in bnxt_qplib_rcfw_stop_irq()
598 rcfw->requested = false; in bnxt_qplib_rcfw_stop_irq()
602 void bnxt_qplib_disable_rcfw_channel(struct bnxt_qplib_rcfw *rcfw) in bnxt_qplib_disable_rcfw_channel() argument
606 bnxt_qplib_rcfw_stop_irq(rcfw, true); in bnxt_qplib_disable_rcfw_channel()
608 if (rcfw->cmdq_bar_reg_iomem) in bnxt_qplib_disable_rcfw_channel()
609 iounmap(rcfw->cmdq_bar_reg_iomem); in bnxt_qplib_disable_rcfw_channel()
610 rcfw->cmdq_bar_reg_iomem = NULL; in bnxt_qplib_disable_rcfw_channel()
612 if (rcfw->creq_bar_reg_iomem) in bnxt_qplib_disable_rcfw_channel()
613 iounmap(rcfw->creq_bar_reg_iomem); in bnxt_qplib_disable_rcfw_channel()
614 rcfw->creq_bar_reg_iomem = NULL; in bnxt_qplib_disable_rcfw_channel()
616 indx = find_first_bit(rcfw->cmdq_bitmap, rcfw->bmap_size); in bnxt_qplib_disable_rcfw_channel()
617 if (indx != rcfw->bmap_size) in bnxt_qplib_disable_rcfw_channel()
618 dev_err(&rcfw->pdev->dev, in bnxt_qplib_disable_rcfw_channel()
620 kfree(rcfw->cmdq_bitmap); in bnxt_qplib_disable_rcfw_channel()
621 rcfw->bmap_size = 0; in bnxt_qplib_disable_rcfw_channel()
623 rcfw->aeq_handler = NULL; in bnxt_qplib_disable_rcfw_channel()
624 rcfw->vector = 0; in bnxt_qplib_disable_rcfw_channel()
627 int bnxt_qplib_rcfw_start_irq(struct bnxt_qplib_rcfw *rcfw, int msix_vector, in bnxt_qplib_rcfw_start_irq() argument
632 if (rcfw->requested) in bnxt_qplib_rcfw_start_irq()
635 rcfw->vector = msix_vector; in bnxt_qplib_rcfw_start_irq()
637 tasklet_init(&rcfw->worker, in bnxt_qplib_rcfw_start_irq()
638 bnxt_qplib_service_creq, (unsigned long)rcfw); in bnxt_qplib_rcfw_start_irq()
640 tasklet_enable(&rcfw->worker); in bnxt_qplib_rcfw_start_irq()
641 rc = request_irq(rcfw->vector, bnxt_qplib_creq_irq, 0, in bnxt_qplib_rcfw_start_irq()
642 "bnxt_qplib_creq", rcfw); in bnxt_qplib_rcfw_start_irq()
645 rcfw->requested = true; in bnxt_qplib_rcfw_start_irq()
646 CREQ_DB_REARM(rcfw->creq_bar_reg_iomem, rcfw->creq.cons, in bnxt_qplib_rcfw_start_irq()
647 rcfw->creq.max_elements); in bnxt_qplib_rcfw_start_irq()
653 struct bnxt_qplib_rcfw *rcfw, in bnxt_qplib_enable_rcfw_channel() argument
665 rcfw->seq_num = 0; in bnxt_qplib_enable_rcfw_channel()
666 set_bit(FIRMWARE_FIRST_FLAG, &rcfw->flags); in bnxt_qplib_enable_rcfw_channel()
669 rcfw->cmdq_bitmap = kzalloc(bmap_size, GFP_KERNEL); in bnxt_qplib_enable_rcfw_channel()
670 if (!rcfw->cmdq_bitmap) in bnxt_qplib_enable_rcfw_channel()
672 rcfw->bmap_size = bmap_size; in bnxt_qplib_enable_rcfw_channel()
675 rcfw->cmdq_bar_reg = RCFW_COMM_PCI_BAR_REGION; in bnxt_qplib_enable_rcfw_channel()
676 res_base = pci_resource_start(pdev, rcfw->cmdq_bar_reg); in bnxt_qplib_enable_rcfw_channel()
680 rcfw->cmdq_bar_reg_iomem = ioremap_nocache(res_base + in bnxt_qplib_enable_rcfw_channel()
683 if (!rcfw->cmdq_bar_reg_iomem) { in bnxt_qplib_enable_rcfw_channel()
684 dev_err(&rcfw->pdev->dev, in bnxt_qplib_enable_rcfw_channel()
686 rcfw->cmdq_bar_reg); in bnxt_qplib_enable_rcfw_channel()
690 rcfw->cmdq_bar_reg_prod_off = virt_fn ? RCFW_VF_COMM_PROD_OFFSET : in bnxt_qplib_enable_rcfw_channel()
693 rcfw->cmdq_bar_reg_trig_off = RCFW_COMM_TRIG_OFFSET; in bnxt_qplib_enable_rcfw_channel()
696 rcfw->creq_bar_reg = RCFW_COMM_CONS_PCI_BAR_REGION; in bnxt_qplib_enable_rcfw_channel()
697 res_base = pci_resource_start(pdev, rcfw->creq_bar_reg); in bnxt_qplib_enable_rcfw_channel()
699 dev_err(&rcfw->pdev->dev, in bnxt_qplib_enable_rcfw_channel()
701 rcfw->creq_bar_reg); in bnxt_qplib_enable_rcfw_channel()
702 rcfw->creq_bar_reg_iomem = ioremap_nocache(res_base + cp_bar_reg_off, in bnxt_qplib_enable_rcfw_channel()
704 if (!rcfw->creq_bar_reg_iomem) { in bnxt_qplib_enable_rcfw_channel()
705 dev_err(&rcfw->pdev->dev, in bnxt_qplib_enable_rcfw_channel()
707 rcfw->creq_bar_reg); in bnxt_qplib_enable_rcfw_channel()
710 rcfw->creq_qp_event_processed = 0; in bnxt_qplib_enable_rcfw_channel()
711 rcfw->creq_func_event_processed = 0; in bnxt_qplib_enable_rcfw_channel()
714 rcfw->aeq_handler = aeq_handler; in bnxt_qplib_enable_rcfw_channel()
715 init_waitqueue_head(&rcfw->waitq); in bnxt_qplib_enable_rcfw_channel()
717 rc = bnxt_qplib_rcfw_start_irq(rcfw, msix_vector, true); in bnxt_qplib_enable_rcfw_channel()
719 dev_err(&rcfw->pdev->dev, in bnxt_qplib_enable_rcfw_channel()
721 bnxt_qplib_disable_rcfw_channel(rcfw); in bnxt_qplib_enable_rcfw_channel()
725 init.cmdq_pbl = cpu_to_le64(rcfw->cmdq.pbl[PBL_LVL_0].pg_map_arr[0]); in bnxt_qplib_enable_rcfw_channel()
729 ((rcfw->cmdq.level << CMDQ_INIT_CMDQ_LVL_SFT) & in bnxt_qplib_enable_rcfw_channel()
731 init.creq_ring_id = cpu_to_le16(rcfw->creq_ring_id); in bnxt_qplib_enable_rcfw_channel()
734 __iowrite32_copy(rcfw->cmdq_bar_reg_iomem, &init, sizeof(init) / 4); in bnxt_qplib_enable_rcfw_channel()
739 struct bnxt_qplib_rcfw *rcfw, in bnxt_qplib_rcfw_alloc_sbuf() argument
749 sbuf->sb = dma_zalloc_coherent(&rcfw->pdev->dev, sbuf->size, in bnxt_qplib_rcfw_alloc_sbuf()
760 void bnxt_qplib_rcfw_free_sbuf(struct bnxt_qplib_rcfw *rcfw, in bnxt_qplib_rcfw_free_sbuf() argument
764 dma_free_coherent(&rcfw->pdev->dev, sbuf->size, in bnxt_qplib_rcfw_free_sbuf()