Lines Matching refs:vf

37 static void otx2vf_process_vfaf_mbox_msg(struct otx2_nic *vf,  in otx2vf_process_vfaf_mbox_msg()  argument
41 dev_err(vf->dev, in otx2vf_process_vfaf_mbox_msg()
47 dev_err(vf->dev, in otx2vf_process_vfaf_mbox_msg()
54 dev_err(vf->dev, in otx2vf_process_vfaf_mbox_msg()
62 vf->pcifunc = msg->pcifunc; in otx2vf_process_vfaf_mbox_msg()
65 mbox_handler_msix_offset(vf, (struct msix_offset_rsp *)msg); in otx2vf_process_vfaf_mbox_msg()
68 mbox_handler_npa_lf_alloc(vf, (struct npa_lf_alloc_rsp *)msg); in otx2vf_process_vfaf_mbox_msg()
71 mbox_handler_nix_lf_alloc(vf, (struct nix_lf_alloc_rsp *)msg); in otx2vf_process_vfaf_mbox_msg()
74 mbox_handler_nix_txsch_alloc(vf, in otx2vf_process_vfaf_mbox_msg()
78 mbox_handler_nix_bp_enable(vf, (struct nix_bp_cfg_rsp *)msg); in otx2vf_process_vfaf_mbox_msg()
82 dev_err(vf->dev, in otx2vf_process_vfaf_mbox_msg()
115 static int otx2vf_process_mbox_msg_up(struct otx2_nic *vf, in otx2vf_process_mbox_msg_up() argument
123 otx2_reply_invalid_msg(&vf->mbox.mbox_up, 0, 0, req->id); in otx2vf_process_mbox_msg_up()
130 &vf->mbox.mbox_up, 0, in otx2vf_process_mbox_msg_up()
140 vf, (struct cgx_link_info_msg *)req, rsp); in otx2vf_process_mbox_msg_up()
143 otx2_reply_invalid_msg(&vf->mbox.mbox_up, 0, 0, req->id); in otx2vf_process_mbox_msg_up()
156 struct otx2_nic *vf; in otx2vf_vfaf_mbox_up_handler() local
160 vf = vf_mbox->pfvf; in otx2vf_vfaf_mbox_up_handler()
172 otx2vf_process_mbox_msg_up(vf, msg); in otx2vf_vfaf_mbox_up_handler()
181 struct otx2_nic *vf = (struct otx2_nic *)vf_irq; in otx2vf_vfaf_mbox_intr_handler() local
187 otx2_write64(vf, RVU_VF_INT, BIT_ULL(0)); in otx2vf_vfaf_mbox_intr_handler()
193 mbox = &vf->mbox.mbox; in otx2vf_vfaf_mbox_intr_handler()
201 vf->mbox.num_msgs = hdr->num_msgs; in otx2vf_vfaf_mbox_intr_handler()
205 queue_work(vf->mbox_wq, &vf->mbox.mbox_wrk); in otx2vf_vfaf_mbox_intr_handler()
208 mbox = &vf->mbox.mbox_up; in otx2vf_vfaf_mbox_intr_handler()
214 vf->mbox.up_num_msgs = hdr->num_msgs; in otx2vf_vfaf_mbox_intr_handler()
218 queue_work(vf->mbox_wq, &vf->mbox.mbox_up_wrk); in otx2vf_vfaf_mbox_intr_handler()
224 static void otx2vf_disable_mbox_intr(struct otx2_nic *vf) in otx2vf_disable_mbox_intr() argument
226 int vector = pci_irq_vector(vf->pdev, RVU_VF_INT_VEC_MBOX); in otx2vf_disable_mbox_intr()
229 otx2_write64(vf, RVU_VF_INT_ENA_W1C, BIT_ULL(0)); in otx2vf_disable_mbox_intr()
230 free_irq(vector, vf); in otx2vf_disable_mbox_intr()
233 static int otx2vf_register_mbox_intr(struct otx2_nic *vf, bool probe_pf) in otx2vf_register_mbox_intr() argument
235 struct otx2_hw *hw = &vf->hw; in otx2vf_register_mbox_intr()
243 err = request_irq(pci_irq_vector(vf->pdev, RVU_VF_INT_VEC_MBOX), in otx2vf_register_mbox_intr()
244 otx2vf_vfaf_mbox_intr_handler, 0, irq_name, vf); in otx2vf_register_mbox_intr()
246 dev_err(vf->dev, in otx2vf_register_mbox_intr()
254 otx2_write64(vf, RVU_VF_INT, BIT_ULL(0)); in otx2vf_register_mbox_intr()
255 otx2_write64(vf, RVU_VF_INT_ENA_W1S, BIT_ULL(0)); in otx2vf_register_mbox_intr()
261 req = otx2_mbox_alloc_msg_ready(&vf->mbox); in otx2vf_register_mbox_intr()
263 otx2vf_disable_mbox_intr(vf); in otx2vf_register_mbox_intr()
267 err = otx2_sync_mbox_msg(&vf->mbox); in otx2vf_register_mbox_intr()
269 dev_warn(vf->dev, in otx2vf_register_mbox_intr()
271 otx2vf_disable_mbox_intr(vf); in otx2vf_register_mbox_intr()
277 static void otx2vf_vfaf_mbox_destroy(struct otx2_nic *vf) in otx2vf_vfaf_mbox_destroy() argument
279 struct mbox *mbox = &vf->mbox; in otx2vf_vfaf_mbox_destroy()
281 if (vf->mbox_wq) { in otx2vf_vfaf_mbox_destroy()
282 destroy_workqueue(vf->mbox_wq); in otx2vf_vfaf_mbox_destroy()
283 vf->mbox_wq = NULL; in otx2vf_vfaf_mbox_destroy()
286 if (mbox->mbox.hwbase && !test_bit(CN10K_MBOX, &vf->hw.cap_flag)) in otx2vf_vfaf_mbox_destroy()
293 static int otx2vf_vfaf_mbox_init(struct otx2_nic *vf) in otx2vf_vfaf_mbox_init() argument
295 struct mbox *mbox = &vf->mbox; in otx2vf_vfaf_mbox_init()
299 mbox->pfvf = vf; in otx2vf_vfaf_mbox_init()
300 vf->mbox_wq = alloc_workqueue("otx2_vfaf_mailbox", in otx2vf_vfaf_mbox_init()
303 if (!vf->mbox_wq) in otx2vf_vfaf_mbox_init()
306 if (test_bit(CN10K_MBOX, &vf->hw.cap_flag)) { in otx2vf_vfaf_mbox_init()
310 hwbase = vf->reg_base + RVU_VF_MBOX_REGION; in otx2vf_vfaf_mbox_init()
316 hwbase = ioremap_wc(pci_resource_start(vf->pdev, in otx2vf_vfaf_mbox_init()
318 pci_resource_len(vf->pdev, in otx2vf_vfaf_mbox_init()
321 dev_err(vf->dev, "Unable to map VFAF mailbox region\n"); in otx2vf_vfaf_mbox_init()
327 err = otx2_mbox_init(&mbox->mbox, hwbase, vf->pdev, vf->reg_base, in otx2vf_vfaf_mbox_init()
332 err = otx2_mbox_init(&mbox->mbox_up, hwbase, vf->pdev, vf->reg_base, in otx2vf_vfaf_mbox_init()
337 err = otx2_mbox_bbuf_init(mbox, vf->pdev); in otx2vf_vfaf_mbox_init()
347 if (hwbase && !test_bit(CN10K_MBOX, &vf->hw.cap_flag)) in otx2vf_vfaf_mbox_init()
349 destroy_workqueue(vf->mbox_wq); in otx2vf_vfaf_mbox_init()
355 struct otx2_nic *vf; in otx2vf_open() local
363 vf = netdev_priv(netdev); in otx2vf_open()
364 if (is_otx2_lbkvf(vf->pdev)) { in otx2vf_open()
380 struct otx2_nic *vf = netdev_priv(netdev); in otx2vf_xmit() local
385 sq = &vf->qset.sq[qidx]; in otx2vf_xmit()
405 struct otx2_nic *vf = netdev_priv(netdev); in otx2vf_set_rx_mode() local
407 queue_work(vf->otx2_wq, &vf->rx_mode_work); in otx2vf_set_rx_mode()
412 struct otx2_nic *vf = container_of(work, struct otx2_nic, rx_mode_work); in otx2vf_do_set_rx_mode() local
413 struct net_device *netdev = vf->netdev; in otx2vf_do_set_rx_mode()
417 mutex_lock(&vf->mbox.lock); in otx2vf_do_set_rx_mode()
419 req = otx2_mbox_alloc_msg_nix_set_rx_mode(&vf->mbox); in otx2vf_do_set_rx_mode()
421 mutex_unlock(&vf->mbox.lock); in otx2vf_do_set_rx_mode()
434 otx2_sync_mbox_msg(&vf->mbox); in otx2vf_do_set_rx_mode()
436 mutex_unlock(&vf->mbox.lock); in otx2vf_do_set_rx_mode()
459 struct otx2_nic *vf = container_of(work, struct otx2_nic, reset_task); in otx2vf_reset_task() local
463 if (netif_running(vf->netdev)) { in otx2vf_reset_task()
464 otx2vf_stop(vf->netdev); in otx2vf_reset_task()
465 vf->reset_count++; in otx2vf_reset_task()
466 otx2vf_open(vf->netdev); in otx2vf_reset_task()
477 struct otx2_nic *vf = netdev_priv(netdev); in otx2vf_set_features() local
481 otx2_mcam_flow_del(vf); in otx2vf_set_features()
485 if (!otx2_get_maxflows(vf->flow_cfg)) { in otx2vf_set_features()
507 static int otx2_wq_init(struct otx2_nic *vf) in otx2_wq_init() argument
509 vf->otx2_wq = create_singlethread_workqueue("otx2vf_wq"); in otx2_wq_init()
510 if (!vf->otx2_wq) in otx2_wq_init()
513 INIT_WORK(&vf->rx_mode_work, otx2vf_do_set_rx_mode); in otx2_wq_init()
514 INIT_WORK(&vf->reset_task, otx2vf_reset_task); in otx2_wq_init()
518 static int otx2vf_realloc_msix_vectors(struct otx2_nic *vf) in otx2vf_realloc_msix_vectors() argument
520 struct otx2_hw *hw = &vf->hw; in otx2vf_realloc_msix_vectors()
526 otx2vf_disable_mbox_intr(vf); in otx2vf_realloc_msix_vectors()
530 dev_err(vf->dev, "%s: Failed to realloc %d IRQ vectors\n", in otx2vf_realloc_msix_vectors()
535 return otx2vf_register_mbox_intr(vf, false); in otx2vf_realloc_msix_vectors()
543 struct otx2_nic *vf; in otx2vf_probe() local
568 netdev = alloc_etherdev_mqs(sizeof(*vf), qcount, qcount); in otx2vf_probe()
576 vf = netdev_priv(netdev); in otx2vf_probe()
577 vf->netdev = netdev; in otx2vf_probe()
578 vf->pdev = pdev; in otx2vf_probe()
579 vf->dev = dev; in otx2vf_probe()
580 vf->iommu_domain = iommu_get_domain_for_dev(dev); in otx2vf_probe()
582 vf->flags |= OTX2_FLAG_INTF_DOWN; in otx2vf_probe()
583 hw = &vf->hw; in otx2vf_probe()
584 hw->pdev = vf->pdev; in otx2vf_probe()
611 vf->reg_base = pcim_iomap(pdev, PCI_CFG_REG_BAR_NUM, 0); in otx2vf_probe()
612 if (!vf->reg_base) { in otx2vf_probe()
618 otx2_setup_dev_hw_settings(vf); in otx2vf_probe()
620 err = otx2vf_vfaf_mbox_init(vf); in otx2vf_probe()
625 err = otx2vf_register_mbox_intr(vf, true); in otx2vf_probe()
630 err = otx2_attach_npa_nix(vf); in otx2vf_probe()
634 err = otx2vf_realloc_msix_vectors(vf); in otx2vf_probe()
642 err = cn10k_lmtst_init(vf); in otx2vf_probe()
647 otx2_ptp_init(vf); in otx2vf_probe()
672 netdev->max_mtu = otx2_get_max_mtu(vf); in otx2vf_probe()
675 if (is_otx2_lbkvf(vf->pdev)) { in otx2vf_probe()
678 n = (vf->pcifunc >> RVU_PFVF_FUNC_SHIFT) & RVU_PFVF_FUNC_MASK; in otx2vf_probe()
690 err = otx2_wq_init(vf); in otx2vf_probe()
696 err = otx2vf_mcam_flow_init(vf); in otx2vf_probe()
700 err = otx2_register_dl(vf); in otx2vf_probe()
705 vf->flags |= OTX2_FLAG_RX_PAUSE_ENABLED; in otx2vf_probe()
706 vf->flags |= OTX2_FLAG_TX_PAUSE_ENABLED; in otx2vf_probe()
713 if (test_bit(CN10K_LMTST, &vf->hw.cap_flag)) in otx2vf_probe()
714 qmem_free(vf->dev, vf->dync_lmt); in otx2vf_probe()
715 otx2_detach_resources(&vf->mbox); in otx2vf_probe()
717 otx2vf_disable_mbox_intr(vf); in otx2vf_probe()
719 otx2vf_vfaf_mbox_destroy(vf); in otx2vf_probe()
733 struct otx2_nic *vf; in otx2vf_remove() local
738 vf = netdev_priv(netdev); in otx2vf_remove()
740 cancel_work_sync(&vf->reset_task); in otx2vf_remove()
741 otx2_unregister_dl(vf); in otx2vf_remove()
743 if (vf->otx2_wq) in otx2vf_remove()
744 destroy_workqueue(vf->otx2_wq); in otx2vf_remove()
745 otx2vf_disable_mbox_intr(vf); in otx2vf_remove()
746 otx2_detach_resources(&vf->mbox); in otx2vf_remove()
747 if (test_bit(CN10K_LMTST, &vf->hw.cap_flag)) in otx2vf_remove()
748 qmem_free(vf->dev, vf->dync_lmt); in otx2vf_remove()
749 otx2vf_vfaf_mbox_destroy(vf); in otx2vf_remove()
750 pci_free_irq_vectors(vf->pdev); in otx2vf_remove()