Lines Matching refs:cptpf

16 static void cptpf_enable_vfpf_mbox_intr(struct otx2_cptpf_dev *cptpf,  in cptpf_enable_vfpf_mbox_intr()  argument
22 otx2_cpt_write64(cptpf->reg_base, BLKADDR_RVUM, 0, in cptpf_enable_vfpf_mbox_intr()
24 otx2_cpt_write64(cptpf->reg_base, BLKADDR_RVUM, 0, in cptpf_enable_vfpf_mbox_intr()
29 otx2_cpt_write64(cptpf->reg_base, BLKADDR_RVUM, 0, in cptpf_enable_vfpf_mbox_intr()
36 otx2_cpt_write64(cptpf->reg_base, BLKADDR_RVUM, 0, in cptpf_enable_vfpf_mbox_intr()
42 static void cptpf_disable_vfpf_mbox_intr(struct otx2_cptpf_dev *cptpf, in cptpf_disable_vfpf_mbox_intr() argument
48 otx2_cpt_write64(cptpf->reg_base, BLKADDR_RVUM, 0, in cptpf_disable_vfpf_mbox_intr()
50 otx2_cpt_write64(cptpf->reg_base, BLKADDR_RVUM, 0, in cptpf_disable_vfpf_mbox_intr()
53 otx2_cpt_write64(cptpf->reg_base, BLKADDR_RVUM, 0, in cptpf_disable_vfpf_mbox_intr()
56 vector = pci_irq_vector(cptpf->pdev, RVU_PF_INT_VEC_VFPF_MBOX0); in cptpf_disable_vfpf_mbox_intr()
57 free_irq(vector, cptpf); in cptpf_disable_vfpf_mbox_intr()
60 otx2_cpt_write64(cptpf->reg_base, BLKADDR_RVUM, 0, in cptpf_disable_vfpf_mbox_intr()
62 vector = pci_irq_vector(cptpf->pdev, RVU_PF_INT_VEC_VFPF_MBOX1); in cptpf_disable_vfpf_mbox_intr()
63 free_irq(vector, cptpf); in cptpf_disable_vfpf_mbox_intr()
67 static void cptpf_enable_vf_flr_me_intrs(struct otx2_cptpf_dev *cptpf, in cptpf_enable_vf_flr_me_intrs() argument
71 otx2_cpt_write64(cptpf->reg_base, BLKADDR_RVUM, 0, RVU_PF_VFFLR_INTX(0), in cptpf_enable_vf_flr_me_intrs()
75 otx2_cpt_write64(cptpf->reg_base, BLKADDR_RVUM, 0, in cptpf_enable_vf_flr_me_intrs()
78 otx2_cpt_write64(cptpf->reg_base, BLKADDR_RVUM, 0, RVU_PF_VFME_INTX(0), in cptpf_enable_vf_flr_me_intrs()
81 otx2_cpt_write64(cptpf->reg_base, BLKADDR_RVUM, 0, in cptpf_enable_vf_flr_me_intrs()
87 otx2_cpt_write64(cptpf->reg_base, BLKADDR_RVUM, 0, RVU_PF_VFFLR_INTX(1), in cptpf_enable_vf_flr_me_intrs()
89 otx2_cpt_write64(cptpf->reg_base, BLKADDR_RVUM, 0, in cptpf_enable_vf_flr_me_intrs()
92 otx2_cpt_write64(cptpf->reg_base, BLKADDR_RVUM, 0, RVU_PF_VFME_INTX(1), in cptpf_enable_vf_flr_me_intrs()
94 otx2_cpt_write64(cptpf->reg_base, BLKADDR_RVUM, 0, in cptpf_enable_vf_flr_me_intrs()
98 static void cptpf_disable_vf_flr_me_intrs(struct otx2_cptpf_dev *cptpf, in cptpf_disable_vf_flr_me_intrs() argument
104 otx2_cpt_write64(cptpf->reg_base, BLKADDR_RVUM, 0, in cptpf_disable_vf_flr_me_intrs()
106 vector = pci_irq_vector(cptpf->pdev, RVU_PF_INT_VEC_VFFLR0); in cptpf_disable_vf_flr_me_intrs()
107 free_irq(vector, cptpf); in cptpf_disable_vf_flr_me_intrs()
110 otx2_cpt_write64(cptpf->reg_base, BLKADDR_RVUM, 0, in cptpf_disable_vf_flr_me_intrs()
112 vector = pci_irq_vector(cptpf->pdev, RVU_PF_INT_VEC_VFME0); in cptpf_disable_vf_flr_me_intrs()
113 free_irq(vector, cptpf); in cptpf_disable_vf_flr_me_intrs()
118 otx2_cpt_write64(cptpf->reg_base, BLKADDR_RVUM, 0, in cptpf_disable_vf_flr_me_intrs()
120 vector = pci_irq_vector(cptpf->pdev, RVU_PF_INT_VEC_VFFLR1); in cptpf_disable_vf_flr_me_intrs()
121 free_irq(vector, cptpf); in cptpf_disable_vf_flr_me_intrs()
123 otx2_cpt_write64(cptpf->reg_base, BLKADDR_RVUM, 0, in cptpf_disable_vf_flr_me_intrs()
125 vector = pci_irq_vector(cptpf->pdev, RVU_PF_INT_VEC_VFME1); in cptpf_disable_vf_flr_me_intrs()
126 free_irq(vector, cptpf); in cptpf_disable_vf_flr_me_intrs()
175 struct otx2_cptpf_dev *cptpf = arg; in cptpf_vf_flr_intr() local
178 if (cptpf->max_vfs > 64) in cptpf_vf_flr_intr()
182 intr = otx2_cpt_read64(cptpf->reg_base, BLKADDR_RVUM, 0, in cptpf_vf_flr_intr()
191 queue_work(cptpf->flr_wq, &cptpf->flr_work[dev].work); in cptpf_vf_flr_intr()
193 otx2_cpt_write64(cptpf->reg_base, BLKADDR_RVUM, 0, in cptpf_vf_flr_intr()
196 otx2_cpt_write64(cptpf->reg_base, BLKADDR_RVUM, 0, in cptpf_vf_flr_intr()
206 struct otx2_cptpf_dev *cptpf = arg; in cptpf_vf_me_intr() local
210 if (cptpf->max_vfs > 64) in cptpf_vf_me_intr()
214 intr = otx2_cpt_read64(cptpf->reg_base, BLKADDR_RVUM, 0, in cptpf_vf_me_intr()
221 otx2_cpt_write64(cptpf->reg_base, BLKADDR_RVUM, 0, in cptpf_vf_me_intr()
224 otx2_cpt_write64(cptpf->reg_base, BLKADDR_RVUM, 0, in cptpf_vf_me_intr()
231 static void cptpf_unregister_vfpf_intr(struct otx2_cptpf_dev *cptpf, in cptpf_unregister_vfpf_intr() argument
234 cptpf_disable_vfpf_mbox_intr(cptpf, num_vfs); in cptpf_unregister_vfpf_intr()
235 cptpf_disable_vf_flr_me_intrs(cptpf, num_vfs); in cptpf_unregister_vfpf_intr()
238 static int cptpf_register_vfpf_intr(struct otx2_cptpf_dev *cptpf, int num_vfs) in cptpf_register_vfpf_intr() argument
240 struct pci_dev *pdev = cptpf->pdev; in cptpf_register_vfpf_intr()
247 cptpf); in cptpf_register_vfpf_intr()
255 ret = request_irq(vector, cptpf_vf_flr_intr, 0, "CPTPF FLR0", cptpf); in cptpf_register_vfpf_intr()
263 ret = request_irq(vector, cptpf_vf_me_intr, 0, "CPTPF ME0", cptpf); in cptpf_register_vfpf_intr()
273 "CPTVFPF Mbox1", cptpf); in cptpf_register_vfpf_intr()
282 cptpf); in cptpf_register_vfpf_intr()
291 cptpf); in cptpf_register_vfpf_intr()
298 cptpf_enable_vfpf_mbox_intr(cptpf, num_vfs); in cptpf_register_vfpf_intr()
299 cptpf_enable_vf_flr_me_intrs(cptpf, num_vfs); in cptpf_register_vfpf_intr()
305 free_irq(vector, cptpf); in cptpf_register_vfpf_intr()
308 free_irq(vector, cptpf); in cptpf_register_vfpf_intr()
311 free_irq(vector, cptpf); in cptpf_register_vfpf_intr()
314 free_irq(vector, cptpf); in cptpf_register_vfpf_intr()
317 free_irq(vector, cptpf); in cptpf_register_vfpf_intr()
330 static int cptpf_flr_wq_init(struct otx2_cptpf_dev *cptpf, int num_vfs) in cptpf_flr_wq_init() argument
334 cptpf->flr_wq = alloc_ordered_workqueue("cptpf_flr_wq", 0); in cptpf_flr_wq_init()
335 if (!cptpf->flr_wq) in cptpf_flr_wq_init()
338 cptpf->flr_work = kcalloc(num_vfs, sizeof(struct cptpf_flr_work), in cptpf_flr_wq_init()
340 if (!cptpf->flr_work) in cptpf_flr_wq_init()
344 cptpf->flr_work[vf].pf = cptpf; in cptpf_flr_wq_init()
345 INIT_WORK(&cptpf->flr_work[vf].work, cptpf_flr_wq_handler); in cptpf_flr_wq_init()
350 destroy_workqueue(cptpf->flr_wq); in cptpf_flr_wq_init()
354 static int cptpf_vfpf_mbox_init(struct otx2_cptpf_dev *cptpf, int num_vfs) in cptpf_vfpf_mbox_init() argument
356 struct device *dev = &cptpf->pdev->dev; in cptpf_vfpf_mbox_init()
360 cptpf->vfpf_mbox_wq = alloc_workqueue("cpt_vfpf_mailbox", in cptpf_vfpf_mbox_init()
363 if (!cptpf->vfpf_mbox_wq) in cptpf_vfpf_mbox_init()
367 if (test_bit(CN10K_MBOX, &cptpf->cap_flag)) in cptpf_vfpf_mbox_init()
368 vfpf_mbox_base = readq(cptpf->reg_base + RVU_PF_VF_MBOX_ADDR); in cptpf_vfpf_mbox_init()
370 vfpf_mbox_base = readq(cptpf->reg_base + RVU_PF_VF_BAR4_ADDR); in cptpf_vfpf_mbox_init()
377 cptpf->vfpf_mbox_base = devm_ioremap_wc(dev, vfpf_mbox_base, in cptpf_vfpf_mbox_init()
378 MBOX_SIZE * cptpf->max_vfs); in cptpf_vfpf_mbox_init()
379 if (!cptpf->vfpf_mbox_base) { in cptpf_vfpf_mbox_init()
384 err = otx2_mbox_init(&cptpf->vfpf_mbox, cptpf->vfpf_mbox_base, in cptpf_vfpf_mbox_init()
385 cptpf->pdev, cptpf->reg_base, MBOX_DIR_PFVF, in cptpf_vfpf_mbox_init()
391 cptpf->vf[i].vf_id = i; in cptpf_vfpf_mbox_init()
392 cptpf->vf[i].cptpf = cptpf; in cptpf_vfpf_mbox_init()
393 cptpf->vf[i].intr_idx = i % 64; in cptpf_vfpf_mbox_init()
394 INIT_WORK(&cptpf->vf[i].vfpf_mbox_work, in cptpf_vfpf_mbox_init()
400 destroy_workqueue(cptpf->vfpf_mbox_wq); in cptpf_vfpf_mbox_init()
404 static void cptpf_vfpf_mbox_destroy(struct otx2_cptpf_dev *cptpf) in cptpf_vfpf_mbox_destroy() argument
406 destroy_workqueue(cptpf->vfpf_mbox_wq); in cptpf_vfpf_mbox_destroy()
407 otx2_mbox_destroy(&cptpf->vfpf_mbox); in cptpf_vfpf_mbox_destroy()
410 static void cptpf_disable_afpf_mbox_intr(struct otx2_cptpf_dev *cptpf) in cptpf_disable_afpf_mbox_intr() argument
413 otx2_cpt_write64(cptpf->reg_base, BLKADDR_RVUM, 0, RVU_PF_INT_ENA_W1C, in cptpf_disable_afpf_mbox_intr()
416 otx2_cpt_write64(cptpf->reg_base, BLKADDR_RVUM, 0, RVU_PF_INT, 0x1ULL); in cptpf_disable_afpf_mbox_intr()
419 static int cptpf_register_afpf_mbox_intr(struct otx2_cptpf_dev *cptpf) in cptpf_register_afpf_mbox_intr() argument
421 struct pci_dev *pdev = cptpf->pdev; in cptpf_register_afpf_mbox_intr()
428 "CPTAFPF Mbox", cptpf); in cptpf_register_afpf_mbox_intr()
435 otx2_cpt_write64(cptpf->reg_base, BLKADDR_RVUM, 0, RVU_PF_INT, 0x1ULL); in cptpf_register_afpf_mbox_intr()
437 otx2_cpt_write64(cptpf->reg_base, BLKADDR_RVUM, 0, RVU_PF_INT_ENA_W1S, in cptpf_register_afpf_mbox_intr()
440 ret = otx2_cpt_send_ready_msg(&cptpf->afpf_mbox, cptpf->pdev); in cptpf_register_afpf_mbox_intr()
444 cptpf_disable_afpf_mbox_intr(cptpf); in cptpf_register_afpf_mbox_intr()
450 static int cptpf_afpf_mbox_init(struct otx2_cptpf_dev *cptpf) in cptpf_afpf_mbox_init() argument
452 struct pci_dev *pdev = cptpf->pdev; in cptpf_afpf_mbox_init()
456 cptpf->afpf_mbox_wq = alloc_workqueue("cpt_afpf_mailbox", in cptpf_afpf_mbox_init()
459 if (!cptpf->afpf_mbox_wq) in cptpf_afpf_mbox_init()
464 cptpf->afpf_mbox_base = devm_ioremap_wc(&pdev->dev, offset, MBOX_SIZE); in cptpf_afpf_mbox_init()
465 if (!cptpf->afpf_mbox_base) { in cptpf_afpf_mbox_init()
471 err = otx2_mbox_init(&cptpf->afpf_mbox, cptpf->afpf_mbox_base, in cptpf_afpf_mbox_init()
472 pdev, cptpf->reg_base, MBOX_DIR_PFAF, 1); in cptpf_afpf_mbox_init()
476 INIT_WORK(&cptpf->afpf_mbox_work, otx2_cptpf_afpf_mbox_handler); in cptpf_afpf_mbox_init()
477 mutex_init(&cptpf->lock); in cptpf_afpf_mbox_init()
481 destroy_workqueue(cptpf->afpf_mbox_wq); in cptpf_afpf_mbox_init()
485 static void cptpf_afpf_mbox_destroy(struct otx2_cptpf_dev *cptpf) in cptpf_afpf_mbox_destroy() argument
487 destroy_workqueue(cptpf->afpf_mbox_wq); in cptpf_afpf_mbox_destroy()
488 otx2_mbox_destroy(&cptpf->afpf_mbox); in cptpf_afpf_mbox_destroy()
494 struct otx2_cptpf_dev *cptpf = dev_get_drvdata(dev); in kvf_limits_show() local
496 return sprintf(buf, "%d\n", cptpf->kvf_limits); in kvf_limits_show()
503 struct otx2_cptpf_dev *cptpf = dev_get_drvdata(dev); in kvf_limits_store() local
515 cptpf->kvf_limits = lfs_num; in kvf_limits_store()
530 static int cpt_is_pf_usable(struct otx2_cptpf_dev *cptpf) in cpt_is_pf_usable() argument
534 rev = otx2_cpt_read64(cptpf->reg_base, BLKADDR_RVUM, 0, in cpt_is_pf_usable()
542 dev_warn(&cptpf->pdev->dev, in cpt_is_pf_usable()
549 static int cptx_device_reset(struct otx2_cptpf_dev *cptpf, int blkaddr) in cptx_device_reset() argument
554 ret = otx2_cpt_write_af_reg(&cptpf->afpf_mbox, cptpf->pdev, in cptx_device_reset()
560 ret = otx2_cpt_read_af_reg(&cptpf->afpf_mbox, cptpf->pdev, in cptx_device_reset()
576 static int cptpf_device_reset(struct otx2_cptpf_dev *cptpf) in cptpf_device_reset() argument
580 if (cptpf->has_cpt1) { in cptpf_device_reset()
581 ret = cptx_device_reset(cptpf, BLKADDR_CPT1); in cptpf_device_reset()
585 return cptx_device_reset(cptpf, BLKADDR_CPT0); in cptpf_device_reset()
588 static void cptpf_check_block_implemented(struct otx2_cptpf_dev *cptpf) in cptpf_check_block_implemented() argument
592 cfg = otx2_cpt_read64(cptpf->reg_base, BLKADDR_RVUM, 0, in cptpf_check_block_implemented()
595 cptpf->has_cpt1 = true; in cptpf_check_block_implemented()
598 static int cptpf_device_init(struct otx2_cptpf_dev *cptpf) in cptpf_device_init() argument
604 cptpf_check_block_implemented(cptpf); in cptpf_device_init()
606 ret = cptpf_device_reset(cptpf); in cptpf_device_init()
611 ret = otx2_cpt_read_af_reg(&cptpf->afpf_mbox, cptpf->pdev, in cptpf_device_init()
617 cptpf->eng_grps.avail.max_se_cnt = af_cnsts1.s.se; in cptpf_device_init()
618 cptpf->eng_grps.avail.max_ie_cnt = af_cnsts1.s.ie; in cptpf_device_init()
619 cptpf->eng_grps.avail.max_ae_cnt = af_cnsts1.s.ae; in cptpf_device_init()
622 ret = otx2_cpt_disable_all_cores(cptpf); in cptpf_device_init()
629 struct otx2_cptpf_dev *cptpf = pci_get_drvdata(pdev); in cptpf_sriov_disable() local
636 cptpf_unregister_vfpf_intr(cptpf, num_vfs); in cptpf_sriov_disable()
637 cptpf_flr_wq_destroy(cptpf); in cptpf_sriov_disable()
638 cptpf_vfpf_mbox_destroy(cptpf); in cptpf_sriov_disable()
640 cptpf->enabled_vfs = 0; in cptpf_sriov_disable()
647 struct otx2_cptpf_dev *cptpf = pci_get_drvdata(pdev); in cptpf_sriov_enable() local
651 ret = cptpf_vfpf_mbox_init(cptpf, num_vfs); in cptpf_sriov_enable()
655 ret = cptpf_flr_wq_init(cptpf, num_vfs); in cptpf_sriov_enable()
659 ret = cptpf_register_vfpf_intr(cptpf, num_vfs); in cptpf_sriov_enable()
664 ret = otx2_cpt_discover_eng_capabilities(cptpf); in cptpf_sriov_enable()
668 ret = otx2_cpt_create_eng_grps(cptpf, &cptpf->eng_grps); in cptpf_sriov_enable()
672 cptpf->enabled_vfs = num_vfs; in cptpf_sriov_enable()
677 dev_notice(&cptpf->pdev->dev, "VFs enabled: %d\n", num_vfs); in cptpf_sriov_enable()
683 cptpf_unregister_vfpf_intr(cptpf, num_vfs); in cptpf_sriov_enable()
684 cptpf->enabled_vfs = 0; in cptpf_sriov_enable()
686 cptpf_flr_wq_destroy(cptpf); in cptpf_sriov_enable()
688 cptpf_vfpf_mbox_destroy(cptpf); in cptpf_sriov_enable()
705 struct otx2_cptpf_dev *cptpf; in otx2_cptpf_probe() local
708 cptpf = devm_kzalloc(dev, sizeof(*cptpf), GFP_KERNEL); in otx2_cptpf_probe()
709 if (!cptpf) in otx2_cptpf_probe()
731 pci_set_drvdata(pdev, cptpf); in otx2_cptpf_probe()
732 cptpf->pdev = pdev; in otx2_cptpf_probe()
734 cptpf->reg_base = pcim_iomap_table(pdev)[PCI_PF_REG_BAR_NUM]; in otx2_cptpf_probe()
737 err = cpt_is_pf_usable(cptpf); in otx2_cptpf_probe()
748 otx2_cpt_set_hw_caps(pdev, &cptpf->cap_flag); in otx2_cptpf_probe()
750 err = cptpf_afpf_mbox_init(cptpf); in otx2_cptpf_probe()
754 err = cptpf_register_afpf_mbox_intr(cptpf); in otx2_cptpf_probe()
758 cptpf->max_vfs = pci_sriov_get_totalvfs(pdev); in otx2_cptpf_probe()
760 err = cn10k_cptpf_lmtst_init(cptpf); in otx2_cptpf_probe()
765 err = cptpf_device_init(cptpf); in otx2_cptpf_probe()
770 err = otx2_cpt_init_eng_grps(pdev, &cptpf->eng_grps); in otx2_cptpf_probe()
778 err = otx2_cpt_register_dl(cptpf); in otx2_cptpf_probe()
787 otx2_cpt_cleanup_eng_grps(pdev, &cptpf->eng_grps); in otx2_cptpf_probe()
789 cptpf_disable_afpf_mbox_intr(cptpf); in otx2_cptpf_probe()
791 cptpf_afpf_mbox_destroy(cptpf); in otx2_cptpf_probe()
799 struct otx2_cptpf_dev *cptpf = pci_get_drvdata(pdev); in otx2_cptpf_remove() local
801 if (!cptpf) in otx2_cptpf_remove()
805 otx2_cpt_unregister_dl(cptpf); in otx2_cptpf_remove()
809 otx2_cpt_cleanup_eng_grps(pdev, &cptpf->eng_grps); in otx2_cptpf_remove()
811 cptpf_disable_afpf_mbox_intr(cptpf); in otx2_cptpf_remove()
813 cptpf_afpf_mbox_destroy(cptpf); in otx2_cptpf_remove()