Lines Matching refs:cptpf

18 static void cptpf_enable_vfpf_mbox_intr(struct otx2_cptpf_dev *cptpf,  in cptpf_enable_vfpf_mbox_intr()  argument
24 otx2_cpt_write64(cptpf->reg_base, BLKADDR_RVUM, 0, in cptpf_enable_vfpf_mbox_intr()
26 otx2_cpt_write64(cptpf->reg_base, BLKADDR_RVUM, 0, in cptpf_enable_vfpf_mbox_intr()
31 otx2_cpt_write64(cptpf->reg_base, BLKADDR_RVUM, 0, in cptpf_enable_vfpf_mbox_intr()
38 otx2_cpt_write64(cptpf->reg_base, BLKADDR_RVUM, 0, in cptpf_enable_vfpf_mbox_intr()
44 static void cptpf_disable_vfpf_mbox_intr(struct otx2_cptpf_dev *cptpf, in cptpf_disable_vfpf_mbox_intr() argument
50 otx2_cpt_write64(cptpf->reg_base, BLKADDR_RVUM, 0, in cptpf_disable_vfpf_mbox_intr()
52 otx2_cpt_write64(cptpf->reg_base, BLKADDR_RVUM, 0, in cptpf_disable_vfpf_mbox_intr()
55 otx2_cpt_write64(cptpf->reg_base, BLKADDR_RVUM, 0, in cptpf_disable_vfpf_mbox_intr()
58 vector = pci_irq_vector(cptpf->pdev, RVU_PF_INT_VEC_VFPF_MBOX0); in cptpf_disable_vfpf_mbox_intr()
59 free_irq(vector, cptpf); in cptpf_disable_vfpf_mbox_intr()
62 otx2_cpt_write64(cptpf->reg_base, BLKADDR_RVUM, 0, in cptpf_disable_vfpf_mbox_intr()
64 vector = pci_irq_vector(cptpf->pdev, RVU_PF_INT_VEC_VFPF_MBOX1); in cptpf_disable_vfpf_mbox_intr()
65 free_irq(vector, cptpf); in cptpf_disable_vfpf_mbox_intr()
69 static void cptpf_enable_vf_flr_me_intrs(struct otx2_cptpf_dev *cptpf, in cptpf_enable_vf_flr_me_intrs() argument
73 otx2_cpt_write64(cptpf->reg_base, BLKADDR_RVUM, 0, RVU_PF_VFFLR_INTX(0), in cptpf_enable_vf_flr_me_intrs()
77 otx2_cpt_write64(cptpf->reg_base, BLKADDR_RVUM, 0, in cptpf_enable_vf_flr_me_intrs()
80 otx2_cpt_write64(cptpf->reg_base, BLKADDR_RVUM, 0, RVU_PF_VFME_INTX(0), in cptpf_enable_vf_flr_me_intrs()
83 otx2_cpt_write64(cptpf->reg_base, BLKADDR_RVUM, 0, in cptpf_enable_vf_flr_me_intrs()
89 otx2_cpt_write64(cptpf->reg_base, BLKADDR_RVUM, 0, RVU_PF_VFFLR_INTX(1), in cptpf_enable_vf_flr_me_intrs()
91 otx2_cpt_write64(cptpf->reg_base, BLKADDR_RVUM, 0, in cptpf_enable_vf_flr_me_intrs()
94 otx2_cpt_write64(cptpf->reg_base, BLKADDR_RVUM, 0, RVU_PF_VFME_INTX(1), in cptpf_enable_vf_flr_me_intrs()
96 otx2_cpt_write64(cptpf->reg_base, BLKADDR_RVUM, 0, in cptpf_enable_vf_flr_me_intrs()
100 static void cptpf_disable_vf_flr_me_intrs(struct otx2_cptpf_dev *cptpf, in cptpf_disable_vf_flr_me_intrs() argument
106 otx2_cpt_write64(cptpf->reg_base, BLKADDR_RVUM, 0, in cptpf_disable_vf_flr_me_intrs()
108 vector = pci_irq_vector(cptpf->pdev, RVU_PF_INT_VEC_VFFLR0); in cptpf_disable_vf_flr_me_intrs()
109 free_irq(vector, cptpf); in cptpf_disable_vf_flr_me_intrs()
112 otx2_cpt_write64(cptpf->reg_base, BLKADDR_RVUM, 0, in cptpf_disable_vf_flr_me_intrs()
114 vector = pci_irq_vector(cptpf->pdev, RVU_PF_INT_VEC_VFME0); in cptpf_disable_vf_flr_me_intrs()
115 free_irq(vector, cptpf); in cptpf_disable_vf_flr_me_intrs()
120 otx2_cpt_write64(cptpf->reg_base, BLKADDR_RVUM, 0, in cptpf_disable_vf_flr_me_intrs()
122 vector = pci_irq_vector(cptpf->pdev, RVU_PF_INT_VEC_VFFLR1); in cptpf_disable_vf_flr_me_intrs()
123 free_irq(vector, cptpf); in cptpf_disable_vf_flr_me_intrs()
125 otx2_cpt_write64(cptpf->reg_base, BLKADDR_RVUM, 0, in cptpf_disable_vf_flr_me_intrs()
127 vector = pci_irq_vector(cptpf->pdev, RVU_PF_INT_VEC_VFME1); in cptpf_disable_vf_flr_me_intrs()
128 free_irq(vector, cptpf); in cptpf_disable_vf_flr_me_intrs()
177 struct otx2_cptpf_dev *cptpf = arg; in cptpf_vf_flr_intr() local
180 if (cptpf->max_vfs > 64) in cptpf_vf_flr_intr()
184 intr = otx2_cpt_read64(cptpf->reg_base, BLKADDR_RVUM, 0, in cptpf_vf_flr_intr()
193 queue_work(cptpf->flr_wq, &cptpf->flr_work[dev].work); in cptpf_vf_flr_intr()
195 otx2_cpt_write64(cptpf->reg_base, BLKADDR_RVUM, 0, in cptpf_vf_flr_intr()
198 otx2_cpt_write64(cptpf->reg_base, BLKADDR_RVUM, 0, in cptpf_vf_flr_intr()
208 struct otx2_cptpf_dev *cptpf = arg; in cptpf_vf_me_intr() local
212 if (cptpf->max_vfs > 64) in cptpf_vf_me_intr()
216 intr = otx2_cpt_read64(cptpf->reg_base, BLKADDR_RVUM, 0, in cptpf_vf_me_intr()
223 otx2_cpt_write64(cptpf->reg_base, BLKADDR_RVUM, 0, in cptpf_vf_me_intr()
226 otx2_cpt_write64(cptpf->reg_base, BLKADDR_RVUM, 0, in cptpf_vf_me_intr()
233 static void cptpf_unregister_vfpf_intr(struct otx2_cptpf_dev *cptpf, in cptpf_unregister_vfpf_intr() argument
236 cptpf_disable_vfpf_mbox_intr(cptpf, num_vfs); in cptpf_unregister_vfpf_intr()
237 cptpf_disable_vf_flr_me_intrs(cptpf, num_vfs); in cptpf_unregister_vfpf_intr()
240 static int cptpf_register_vfpf_intr(struct otx2_cptpf_dev *cptpf, int num_vfs) in cptpf_register_vfpf_intr() argument
242 struct pci_dev *pdev = cptpf->pdev; in cptpf_register_vfpf_intr()
249 cptpf); in cptpf_register_vfpf_intr()
257 ret = request_irq(vector, cptpf_vf_flr_intr, 0, "CPTPF FLR0", cptpf); in cptpf_register_vfpf_intr()
265 ret = request_irq(vector, cptpf_vf_me_intr, 0, "CPTPF ME0", cptpf); in cptpf_register_vfpf_intr()
275 "CPTVFPF Mbox1", cptpf); in cptpf_register_vfpf_intr()
284 cptpf); in cptpf_register_vfpf_intr()
293 cptpf); in cptpf_register_vfpf_intr()
300 cptpf_enable_vfpf_mbox_intr(cptpf, num_vfs); in cptpf_register_vfpf_intr()
301 cptpf_enable_vf_flr_me_intrs(cptpf, num_vfs); in cptpf_register_vfpf_intr()
307 free_irq(vector, cptpf); in cptpf_register_vfpf_intr()
310 free_irq(vector, cptpf); in cptpf_register_vfpf_intr()
313 free_irq(vector, cptpf); in cptpf_register_vfpf_intr()
316 free_irq(vector, cptpf); in cptpf_register_vfpf_intr()
319 free_irq(vector, cptpf); in cptpf_register_vfpf_intr()
332 static int cptpf_flr_wq_init(struct otx2_cptpf_dev *cptpf, int num_vfs) in cptpf_flr_wq_init() argument
336 cptpf->flr_wq = alloc_ordered_workqueue("cptpf_flr_wq", 0); in cptpf_flr_wq_init()
337 if (!cptpf->flr_wq) in cptpf_flr_wq_init()
340 cptpf->flr_work = kcalloc(num_vfs, sizeof(struct cptpf_flr_work), in cptpf_flr_wq_init()
342 if (!cptpf->flr_work) in cptpf_flr_wq_init()
346 cptpf->flr_work[vf].pf = cptpf; in cptpf_flr_wq_init()
347 INIT_WORK(&cptpf->flr_work[vf].work, cptpf_flr_wq_handler); in cptpf_flr_wq_init()
352 destroy_workqueue(cptpf->flr_wq); in cptpf_flr_wq_init()
356 static int cptpf_vfpf_mbox_init(struct otx2_cptpf_dev *cptpf, int num_vfs) in cptpf_vfpf_mbox_init() argument
358 struct device *dev = &cptpf->pdev->dev; in cptpf_vfpf_mbox_init()
362 cptpf->vfpf_mbox_wq = in cptpf_vfpf_mbox_init()
365 if (!cptpf->vfpf_mbox_wq) in cptpf_vfpf_mbox_init()
369 if (test_bit(CN10K_MBOX, &cptpf->cap_flag)) in cptpf_vfpf_mbox_init()
370 vfpf_mbox_base = readq(cptpf->reg_base + RVU_PF_VF_MBOX_ADDR); in cptpf_vfpf_mbox_init()
372 vfpf_mbox_base = readq(cptpf->reg_base + RVU_PF_VF_BAR4_ADDR); in cptpf_vfpf_mbox_init()
379 cptpf->vfpf_mbox_base = devm_ioremap_wc(dev, vfpf_mbox_base, in cptpf_vfpf_mbox_init()
380 MBOX_SIZE * cptpf->max_vfs); in cptpf_vfpf_mbox_init()
381 if (!cptpf->vfpf_mbox_base) { in cptpf_vfpf_mbox_init()
386 err = otx2_mbox_init(&cptpf->vfpf_mbox, cptpf->vfpf_mbox_base, in cptpf_vfpf_mbox_init()
387 cptpf->pdev, cptpf->reg_base, MBOX_DIR_PFVF, in cptpf_vfpf_mbox_init()
393 cptpf->vf[i].vf_id = i; in cptpf_vfpf_mbox_init()
394 cptpf->vf[i].cptpf = cptpf; in cptpf_vfpf_mbox_init()
395 cptpf->vf[i].intr_idx = i % 64; in cptpf_vfpf_mbox_init()
396 INIT_WORK(&cptpf->vf[i].vfpf_mbox_work, in cptpf_vfpf_mbox_init()
402 destroy_workqueue(cptpf->vfpf_mbox_wq); in cptpf_vfpf_mbox_init()
406 static void cptpf_vfpf_mbox_destroy(struct otx2_cptpf_dev *cptpf) in cptpf_vfpf_mbox_destroy() argument
408 destroy_workqueue(cptpf->vfpf_mbox_wq); in cptpf_vfpf_mbox_destroy()
409 otx2_mbox_destroy(&cptpf->vfpf_mbox); in cptpf_vfpf_mbox_destroy()
412 static void cptpf_disable_afpf_mbox_intr(struct otx2_cptpf_dev *cptpf) in cptpf_disable_afpf_mbox_intr() argument
415 otx2_cpt_write64(cptpf->reg_base, BLKADDR_RVUM, 0, RVU_PF_INT_ENA_W1C, in cptpf_disable_afpf_mbox_intr()
418 otx2_cpt_write64(cptpf->reg_base, BLKADDR_RVUM, 0, RVU_PF_INT, 0x1ULL); in cptpf_disable_afpf_mbox_intr()
421 static int cptpf_register_afpf_mbox_intr(struct otx2_cptpf_dev *cptpf) in cptpf_register_afpf_mbox_intr() argument
423 struct pci_dev *pdev = cptpf->pdev; in cptpf_register_afpf_mbox_intr()
430 "CPTAFPF Mbox", cptpf); in cptpf_register_afpf_mbox_intr()
437 otx2_cpt_write64(cptpf->reg_base, BLKADDR_RVUM, 0, RVU_PF_INT, 0x1ULL); in cptpf_register_afpf_mbox_intr()
439 otx2_cpt_write64(cptpf->reg_base, BLKADDR_RVUM, 0, RVU_PF_INT_ENA_W1S, in cptpf_register_afpf_mbox_intr()
442 ret = otx2_cpt_send_ready_msg(&cptpf->afpf_mbox, cptpf->pdev); in cptpf_register_afpf_mbox_intr()
446 cptpf_disable_afpf_mbox_intr(cptpf); in cptpf_register_afpf_mbox_intr()
452 static int cptpf_afpf_mbox_init(struct otx2_cptpf_dev *cptpf) in cptpf_afpf_mbox_init() argument
454 struct pci_dev *pdev = cptpf->pdev; in cptpf_afpf_mbox_init()
458 cptpf->afpf_mbox_wq = in cptpf_afpf_mbox_init()
461 if (!cptpf->afpf_mbox_wq) in cptpf_afpf_mbox_init()
466 cptpf->afpf_mbox_base = devm_ioremap_wc(&pdev->dev, offset, MBOX_SIZE); in cptpf_afpf_mbox_init()
467 if (!cptpf->afpf_mbox_base) { in cptpf_afpf_mbox_init()
473 err = otx2_mbox_init(&cptpf->afpf_mbox, cptpf->afpf_mbox_base, in cptpf_afpf_mbox_init()
474 pdev, cptpf->reg_base, MBOX_DIR_PFAF, 1); in cptpf_afpf_mbox_init()
478 err = otx2_mbox_init(&cptpf->afpf_mbox_up, cptpf->afpf_mbox_base, in cptpf_afpf_mbox_init()
479 pdev, cptpf->reg_base, MBOX_DIR_PFAF_UP, 1); in cptpf_afpf_mbox_init()
483 INIT_WORK(&cptpf->afpf_mbox_work, otx2_cptpf_afpf_mbox_handler); in cptpf_afpf_mbox_init()
484 INIT_WORK(&cptpf->afpf_mbox_up_work, otx2_cptpf_afpf_mbox_up_handler); in cptpf_afpf_mbox_init()
485 mutex_init(&cptpf->lock); in cptpf_afpf_mbox_init()
490 otx2_mbox_destroy(&cptpf->afpf_mbox); in cptpf_afpf_mbox_init()
492 destroy_workqueue(cptpf->afpf_mbox_wq); in cptpf_afpf_mbox_init()
496 static void cptpf_afpf_mbox_destroy(struct otx2_cptpf_dev *cptpf) in cptpf_afpf_mbox_destroy() argument
498 destroy_workqueue(cptpf->afpf_mbox_wq); in cptpf_afpf_mbox_destroy()
499 otx2_mbox_destroy(&cptpf->afpf_mbox); in cptpf_afpf_mbox_destroy()
500 otx2_mbox_destroy(&cptpf->afpf_mbox_up); in cptpf_afpf_mbox_destroy()
506 struct otx2_cptpf_dev *cptpf = dev_get_drvdata(dev); in sso_pf_func_ovrd_show() local
508 return sprintf(buf, "%d\n", cptpf->sso_pf_func_ovrd); in sso_pf_func_ovrd_show()
515 struct otx2_cptpf_dev *cptpf = dev_get_drvdata(dev); in sso_pf_func_ovrd_store() local
518 if (!(cptpf->pdev->revision == CPT_UC_RID_CN9K_B0)) in sso_pf_func_ovrd_store()
524 cptpf->sso_pf_func_ovrd = sso_pf_func_ovrd; in sso_pf_func_ovrd_store()
532 struct otx2_cptpf_dev *cptpf = dev_get_drvdata(dev); in kvf_limits_show() local
534 return sprintf(buf, "%d\n", cptpf->kvf_limits); in kvf_limits_show()
541 struct otx2_cptpf_dev *cptpf = dev_get_drvdata(dev); in kvf_limits_store() local
553 cptpf->kvf_limits = lfs_num; in kvf_limits_store()
571 static int cpt_is_pf_usable(struct otx2_cptpf_dev *cptpf) in cpt_is_pf_usable() argument
575 rev = otx2_cpt_read64(cptpf->reg_base, BLKADDR_RVUM, 0, in cpt_is_pf_usable()
583 dev_warn(&cptpf->pdev->dev, in cpt_is_pf_usable()
590 static int cptx_device_reset(struct otx2_cptpf_dev *cptpf, int blkaddr) in cptx_device_reset() argument
595 ret = otx2_cpt_write_af_reg(&cptpf->afpf_mbox, cptpf->pdev, in cptx_device_reset()
601 ret = otx2_cpt_read_af_reg(&cptpf->afpf_mbox, cptpf->pdev, in cptx_device_reset()
617 static int cptpf_device_reset(struct otx2_cptpf_dev *cptpf) in cptpf_device_reset() argument
621 if (cptpf->has_cpt1) { in cptpf_device_reset()
622 ret = cptx_device_reset(cptpf, BLKADDR_CPT1); in cptpf_device_reset()
626 return cptx_device_reset(cptpf, BLKADDR_CPT0); in cptpf_device_reset()
629 static void cptpf_check_block_implemented(struct otx2_cptpf_dev *cptpf) in cptpf_check_block_implemented() argument
633 cfg = otx2_cpt_read64(cptpf->reg_base, BLKADDR_RVUM, 0, in cptpf_check_block_implemented()
636 cptpf->has_cpt1 = true; in cptpf_check_block_implemented()
639 static int cptpf_device_init(struct otx2_cptpf_dev *cptpf) in cptpf_device_init() argument
645 cptpf_check_block_implemented(cptpf); in cptpf_device_init()
647 ret = cptpf_device_reset(cptpf); in cptpf_device_init()
652 ret = otx2_cpt_read_af_reg(&cptpf->afpf_mbox, cptpf->pdev, in cptpf_device_init()
658 cptpf->eng_grps.avail.max_se_cnt = af_cnsts1.s.se; in cptpf_device_init()
659 cptpf->eng_grps.avail.max_ie_cnt = af_cnsts1.s.ie; in cptpf_device_init()
660 cptpf->eng_grps.avail.max_ae_cnt = af_cnsts1.s.ae; in cptpf_device_init()
663 ret = otx2_cpt_disable_all_cores(cptpf); in cptpf_device_init()
670 struct otx2_cptpf_dev *cptpf = pci_get_drvdata(pdev); in cptpf_sriov_disable() local
677 cptpf_unregister_vfpf_intr(cptpf, num_vfs); in cptpf_sriov_disable()
678 cptpf_flr_wq_destroy(cptpf); in cptpf_sriov_disable()
679 cptpf_vfpf_mbox_destroy(cptpf); in cptpf_sriov_disable()
681 cptpf->enabled_vfs = 0; in cptpf_sriov_disable()
688 struct otx2_cptpf_dev *cptpf = pci_get_drvdata(pdev); in cptpf_sriov_enable() local
692 ret = cptpf_vfpf_mbox_init(cptpf, num_vfs); in cptpf_sriov_enable()
696 ret = cptpf_flr_wq_init(cptpf, num_vfs); in cptpf_sriov_enable()
700 ret = cptpf_register_vfpf_intr(cptpf, num_vfs); in cptpf_sriov_enable()
705 ret = otx2_cpt_discover_eng_capabilities(cptpf); in cptpf_sriov_enable()
709 ret = otx2_cpt_create_eng_grps(cptpf, &cptpf->eng_grps); in cptpf_sriov_enable()
713 cptpf->enabled_vfs = num_vfs; in cptpf_sriov_enable()
718 dev_notice(&cptpf->pdev->dev, "VFs enabled: %d\n", num_vfs); in cptpf_sriov_enable()
724 cptpf_unregister_vfpf_intr(cptpf, num_vfs); in cptpf_sriov_enable()
725 cptpf->enabled_vfs = 0; in cptpf_sriov_enable()
727 cptpf_flr_wq_destroy(cptpf); in cptpf_sriov_enable()
729 cptpf_vfpf_mbox_destroy(cptpf); in cptpf_sriov_enable()
746 struct otx2_cptpf_dev *cptpf; in otx2_cptpf_probe() local
749 cptpf = devm_kzalloc(dev, sizeof(*cptpf), GFP_KERNEL); in otx2_cptpf_probe()
750 if (!cptpf) in otx2_cptpf_probe()
772 pci_set_drvdata(pdev, cptpf); in otx2_cptpf_probe()
773 cptpf->pdev = pdev; in otx2_cptpf_probe()
775 cptpf->reg_base = pcim_iomap_table(pdev)[PCI_PF_REG_BAR_NUM]; in otx2_cptpf_probe()
778 err = cpt_is_pf_usable(cptpf); in otx2_cptpf_probe()
789 otx2_cpt_set_hw_caps(pdev, &cptpf->cap_flag); in otx2_cptpf_probe()
791 err = cptpf_afpf_mbox_init(cptpf); in otx2_cptpf_probe()
795 err = cptpf_register_afpf_mbox_intr(cptpf); in otx2_cptpf_probe()
799 cptpf->max_vfs = pci_sriov_get_totalvfs(pdev); in otx2_cptpf_probe()
801 err = cn10k_cptpf_lmtst_init(cptpf); in otx2_cptpf_probe()
806 err = cptpf_device_init(cptpf); in otx2_cptpf_probe()
811 err = otx2_cpt_init_eng_grps(pdev, &cptpf->eng_grps); in otx2_cptpf_probe()
819 err = otx2_cpt_register_dl(cptpf); in otx2_cptpf_probe()
828 otx2_cpt_cleanup_eng_grps(pdev, &cptpf->eng_grps); in otx2_cptpf_probe()
830 cptpf_disable_afpf_mbox_intr(cptpf); in otx2_cptpf_probe()
832 cptpf_afpf_mbox_destroy(cptpf); in otx2_cptpf_probe()
840 struct otx2_cptpf_dev *cptpf = pci_get_drvdata(pdev); in otx2_cptpf_remove() local
842 if (!cptpf) in otx2_cptpf_remove()
846 otx2_cpt_unregister_dl(cptpf); in otx2_cptpf_remove()
850 otx2_cpt_cleanup_eng_grps(pdev, &cptpf->eng_grps); in otx2_cptpf_remove()
852 cptpf_disable_afpf_mbox_intr(cptpf); in otx2_cptpf_remove()
854 cptpf_afpf_mbox_destroy(cptpf); in otx2_cptpf_remove()