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()
492 static int otx2_wq_init(struct otx2_nic *vf) in otx2_wq_init() argument
494 vf->otx2_wq = create_singlethread_workqueue("otx2vf_wq"); in otx2_wq_init()
495 if (!vf->otx2_wq) in otx2_wq_init()
498 INIT_WORK(&vf->rx_mode_work, otx2vf_do_set_rx_mode); in otx2_wq_init()
499 INIT_WORK(&vf->reset_task, otx2vf_reset_task); in otx2_wq_init()
503 static int otx2vf_realloc_msix_vectors(struct otx2_nic *vf) in otx2vf_realloc_msix_vectors() argument
505 struct otx2_hw *hw = &vf->hw; in otx2vf_realloc_msix_vectors()
511 otx2vf_disable_mbox_intr(vf); in otx2vf_realloc_msix_vectors()
515 dev_err(vf->dev, "%s: Failed to realloc %d IRQ vectors\n", in otx2vf_realloc_msix_vectors()
520 return otx2vf_register_mbox_intr(vf, false); in otx2vf_realloc_msix_vectors()
528 struct otx2_nic *vf; in otx2vf_probe() local
553 netdev = alloc_etherdev_mqs(sizeof(*vf), qcount, qcount); in otx2vf_probe()
561 vf = netdev_priv(netdev); in otx2vf_probe()
562 vf->netdev = netdev; in otx2vf_probe()
563 vf->pdev = pdev; in otx2vf_probe()
564 vf->dev = dev; in otx2vf_probe()
565 vf->iommu_domain = iommu_get_domain_for_dev(dev); in otx2vf_probe()
567 vf->flags |= OTX2_FLAG_INTF_DOWN; in otx2vf_probe()
568 hw = &vf->hw; in otx2vf_probe()
569 hw->pdev = vf->pdev; in otx2vf_probe()
599 vf->reg_base = pcim_iomap(pdev, PCI_CFG_REG_BAR_NUM, 0); in otx2vf_probe()
600 if (!vf->reg_base) { in otx2vf_probe()
606 otx2_setup_dev_hw_settings(vf); in otx2vf_probe()
608 err = otx2vf_vfaf_mbox_init(vf); in otx2vf_probe()
613 err = otx2vf_register_mbox_intr(vf, true); in otx2vf_probe()
618 err = otx2_attach_npa_nix(vf); in otx2vf_probe()
622 err = otx2vf_realloc_msix_vectors(vf); in otx2vf_probe()
630 err = cn10k_lmtst_init(vf); in otx2vf_probe()
635 otx2_ptp_init(vf); in otx2vf_probe()
661 netdev->max_mtu = otx2_get_max_mtu(vf); in otx2vf_probe()
664 if (is_otx2_lbkvf(vf->pdev)) { in otx2vf_probe()
667 n = (vf->pcifunc >> RVU_PFVF_FUNC_SHIFT) & RVU_PFVF_FUNC_MASK; in otx2vf_probe()
679 err = otx2_wq_init(vf); in otx2vf_probe()
685 err = otx2vf_mcam_flow_init(vf); in otx2vf_probe()
689 err = otx2_init_tc(vf); in otx2vf_probe()
693 err = otx2_register_dl(vf); in otx2vf_probe()
706 otx2_shutdown_tc(vf); in otx2vf_probe()
710 otx2_ptp_destroy(vf); in otx2vf_probe()
712 if (test_bit(CN10K_LMTST, &vf->hw.cap_flag)) in otx2vf_probe()
713 qmem_free(vf->dev, vf->dync_lmt); in otx2vf_probe()
714 otx2_detach_resources(&vf->mbox); in otx2vf_probe()
716 otx2vf_disable_mbox_intr(vf); in otx2vf_probe()
718 otx2vf_vfaf_mbox_destroy(vf); in otx2vf_probe()
732 struct otx2_nic *vf; in otx2vf_remove() local
737 vf = netdev_priv(netdev); in otx2vf_remove()
740 if (vf->flags & OTX2_FLAG_RX_PAUSE_ENABLED || in otx2vf_remove()
741 (vf->flags & OTX2_FLAG_TX_PAUSE_ENABLED)) { in otx2vf_remove()
742 vf->flags &= ~OTX2_FLAG_RX_PAUSE_ENABLED; in otx2vf_remove()
743 vf->flags &= ~OTX2_FLAG_TX_PAUSE_ENABLED; in otx2vf_remove()
744 otx2_config_pause_frm(vf); in otx2vf_remove()
749 if (vf->pfc_en) { in otx2vf_remove()
750 vf->pfc_en = 0; in otx2vf_remove()
751 otx2_config_priority_flow_ctrl(vf); in otx2vf_remove()
755 cancel_work_sync(&vf->reset_task); in otx2vf_remove()
756 otx2_unregister_dl(vf); in otx2vf_remove()
758 if (vf->otx2_wq) in otx2vf_remove()
759 destroy_workqueue(vf->otx2_wq); in otx2vf_remove()
760 otx2_ptp_destroy(vf); in otx2vf_remove()
761 otx2_mcam_flow_del(vf); in otx2vf_remove()
762 otx2_shutdown_tc(vf); in otx2vf_remove()
763 otx2vf_disable_mbox_intr(vf); in otx2vf_remove()
764 otx2_detach_resources(&vf->mbox); in otx2vf_remove()
765 if (test_bit(CN10K_LMTST, &vf->hw.cap_flag)) in otx2vf_remove()
766 qmem_free(vf->dev, vf->dync_lmt); in otx2vf_remove()
767 otx2vf_vfaf_mbox_destroy(vf); in otx2vf_remove()
768 pci_free_irq_vectors(vf->pdev); in otx2vf_remove()