Lines Matching full:pf

51 int nfp_pf_rtsym_read_optional(struct nfp_pf *pf, const char *format,  in nfp_pf_rtsym_read_optional()  argument
58 snprintf(name, sizeof(name), format, nfp_cppcore_pcie_unit(pf->cpp)); in nfp_pf_rtsym_read_optional()
60 val = nfp_rtsym_read_le(pf->rtbl, name, &err); in nfp_pf_rtsym_read_optional()
64 nfp_err(pf->cpp, "Unable to read symbol %s\n", name); in nfp_pf_rtsym_read_optional()
72 nfp_pf_map_rtsym(struct nfp_pf *pf, const char *name, const char *sym_fmt, in nfp_pf_map_rtsym() argument
78 nfp_cppcore_pcie_unit(pf->cpp)); in nfp_pf_map_rtsym()
80 return nfp_rtsym_map(pf->rtbl, pf_symbol, name, min_size, area); in nfp_pf_map_rtsym()
84 int nfp_mbox_cmd(struct nfp_pf *pf, u32 cmd, void *in_data, u64 in_length, in nfp_mbox_cmd() argument
92 if (!pf->mbox) in nfp_mbox_cmd()
95 max_data_sz = nfp_rtsym_size(pf->mbox) - NFP_MBOX_SYM_MIN_SIZE; in nfp_mbox_cmd()
98 err = nfp_rtsym_readl(pf->cpp, pf->mbox, NFP_MBOX_CMD, &val); in nfp_mbox_cmd()
100 nfp_warn(pf->cpp, "failed to issue command (%u): %u, err: %d\n", in nfp_mbox_cmd()
106 n = nfp_rtsym_write(pf->cpp, pf->mbox, NFP_MBOX_DATA, in_data, in nfp_mbox_cmd()
111 err = nfp_rtsym_writeq(pf->cpp, pf->mbox, NFP_MBOX_DATA_LEN, in_length); in nfp_mbox_cmd()
116 err = nfp_rtsym_readl(pf->cpp, pf->mbox, NFP_MBOX_DATA_LEN, &val); in nfp_mbox_cmd()
121 err = nfp_rtsym_writeq(pf->cpp, pf->mbox, NFP_MBOX_CMD, cmd); in nfp_mbox_cmd()
128 err = nfp_rtsym_readl(pf->cpp, pf->mbox, NFP_MBOX_CMD, &val); in nfp_mbox_cmd()
141 err = nfp_rtsym_readl(pf->cpp, pf->mbox, NFP_MBOX_DATA_LEN, &val); in nfp_mbox_cmd()
146 n = nfp_rtsym_read(pf->cpp, pf->mbox, NFP_MBOX_DATA, in nfp_mbox_cmd()
152 err = nfp_rtsym_readl(pf->cpp, pf->mbox, NFP_MBOX_RET, &val); in nfp_mbox_cmd()
161 static bool nfp_board_ready(struct nfp_pf *pf) in nfp_board_ready() argument
167 cp = nfp_hwinfo_lookup(pf->hwinfo, "board.state"); in nfp_board_ready()
178 static int nfp_pf_board_state_wait(struct nfp_pf *pf) in nfp_pf_board_state_wait() argument
182 while (!nfp_board_ready(pf)) { in nfp_pf_board_state_wait()
184 nfp_err(pf->cpp, "NFP board initialization timeout\n"); in nfp_pf_board_state_wait()
188 nfp_info(pf->cpp, "waiting for board initialization\n"); in nfp_pf_board_state_wait()
193 kfree(pf->hwinfo); in nfp_pf_board_state_wait()
194 pf->hwinfo = nfp_hwinfo_read(pf->cpp); in nfp_pf_board_state_wait()
200 static int nfp_pcie_sriov_read_nfd_limit(struct nfp_pf *pf) in nfp_pcie_sriov_read_nfd_limit() argument
204 pf->limit_vfs = nfp_rtsym_read_le(pf->rtbl, "nfd_vf_cfg_max_vfs", &err); in nfp_pcie_sriov_read_nfd_limit()
207 pf->limit_vfs = ~0; in nfp_pcie_sriov_read_nfd_limit()
211 nfp_warn(pf->cpp, "Warning: VF limit read failed: %d\n", err); in nfp_pcie_sriov_read_nfd_limit()
215 err = pci_sriov_set_totalvfs(pf->pdev, pf->limit_vfs); in nfp_pcie_sriov_read_nfd_limit()
217 nfp_warn(pf->cpp, "Failed to set VF count in sysfs: %d\n", err); in nfp_pcie_sriov_read_nfd_limit()
224 struct nfp_pf *pf = pci_get_drvdata(pdev); in nfp_pcie_sriov_enable() local
227 if (num_vfs > pf->limit_vfs) { in nfp_pcie_sriov_enable()
228 nfp_info(pf->cpp, "Firmware limits number of VFs to %u\n", in nfp_pcie_sriov_enable()
229 pf->limit_vfs); in nfp_pcie_sriov_enable()
239 mutex_lock(&pf->lock); in nfp_pcie_sriov_enable()
241 err = nfp_app_sriov_enable(pf->app, num_vfs); in nfp_pcie_sriov_enable()
249 pf->num_vfs = num_vfs; in nfp_pcie_sriov_enable()
251 dev_dbg(&pdev->dev, "Created %d VFs.\n", pf->num_vfs); in nfp_pcie_sriov_enable()
253 mutex_unlock(&pf->lock); in nfp_pcie_sriov_enable()
257 mutex_unlock(&pf->lock); in nfp_pcie_sriov_enable()
267 struct nfp_pf *pf = pci_get_drvdata(pdev); in nfp_pcie_sriov_disable() local
269 mutex_lock(&pf->lock); in nfp_pcie_sriov_disable()
277 mutex_unlock(&pf->lock); in nfp_pcie_sriov_disable()
281 nfp_app_sriov_disable(pf->app); in nfp_pcie_sriov_disable()
283 pf->num_vfs = 0; in nfp_pcie_sriov_disable()
285 mutex_unlock(&pf->lock); in nfp_pcie_sriov_disable()
304 int nfp_flash_update_common(struct nfp_pf *pf, const char *path, in nfp_flash_update_common() argument
307 struct device *dev = &pf->pdev->dev; in nfp_flash_update_common()
312 nsp = nfp_nsp_open(pf->cpp); in nfp_flash_update_common()
346 nfp_net_fw_request(struct pci_dev *pdev, struct nfp_pf *pf, const char *name) in nfp_net_fw_request() argument
352 nfp_info(pf->cpp, " %s: %s\n", in nfp_net_fw_request()
363 * @pf: NFP PF Device structure
368 nfp_net_fw_find(struct pci_dev *pdev, struct nfp_pf *pf) in nfp_net_fw_find() argument
378 nfp_info(pf->cpp, "Looking for firmware file in order of priority:\n"); in nfp_net_fw_find()
381 interface = nfp_cpp_interface(pf->cpp); in nfp_net_fw_find()
382 nfp_cpp_serial(pf->cpp, &serial); in nfp_net_fw_find()
385 fw = nfp_net_fw_request(pdev, pf, fw_name); in nfp_net_fw_find()
391 fw = nfp_net_fw_request(pdev, pf, fw_name); in nfp_net_fw_find()
396 if (!pf->eth_tbl) { in nfp_net_fw_find()
401 fw_model = nfp_hwinfo_lookup(pf->hwinfo, "assembly.partno"); in nfp_net_fw_find()
410 for (i = 0; spc > 0 && i < pf->eth_tbl->count; i += j) { in nfp_net_fw_find()
411 port = &pf->eth_tbl->ports[i]; in nfp_net_fw_find()
413 while (i + j < pf->eth_tbl->count && in nfp_net_fw_find()
428 return nfp_net_fw_request(pdev, pf, fw_name); in nfp_net_fw_find()
461 * @pf: NFP PF Device structure
467 nfp_fw_load(struct pci_dev *pdev, struct nfp_pf *pf, struct nfp_nsp *nsp) in nfp_fw_load() argument
482 interface = nfp_cpp_interface(pf->cpp); in nfp_fw_load()
517 fw = nfp_net_fw_find(pdev, pf); in nfp_fw_load()
567 pf->unload_fw_on_remove = true; in nfp_fw_load()
573 nfp_nsp_init_ports(struct pci_dev *pdev, struct nfp_pf *pf, in nfp_nsp_init_ports() argument
579 pf->eth_tbl = __nfp_eth_read_ports(pf->cpp, nsp); in nfp_nsp_init_ports()
580 if (!pf->eth_tbl) in nfp_nsp_init_ports()
586 for (i = 0; i < pf->eth_tbl->count; i++) in nfp_nsp_init_ports()
587 needs_reinit |= pf->eth_tbl->ports[i].override_changed; in nfp_nsp_init_ports()
591 kfree(pf->eth_tbl); in nfp_nsp_init_ports()
595 pf->eth_tbl = __nfp_eth_read_ports(pf->cpp, nsp); in nfp_nsp_init_ports()
598 static int nfp_nsp_init(struct pci_dev *pdev, struct nfp_pf *pf) in nfp_nsp_init() argument
603 err = nfp_resource_wait(pf->cpp, NFP_RESOURCE_NSP, 30); in nfp_nsp_init()
607 nsp = nfp_nsp_open(pf->cpp); in nfp_nsp_init()
618 nfp_nsp_init_ports(pdev, pf, nsp); in nfp_nsp_init()
620 pf->nspi = __nfp_nsp_identify(nsp); in nfp_nsp_init()
621 if (pf->nspi) in nfp_nsp_init()
622 dev_info(&pdev->dev, "BSP: %s\n", pf->nspi->version); in nfp_nsp_init()
624 err = nfp_fw_load(pdev, pf, nsp); in nfp_nsp_init()
626 kfree(pf->nspi); in nfp_nsp_init()
627 kfree(pf->eth_tbl); in nfp_nsp_init()
632 pf->fw_loaded = !!err; in nfp_nsp_init()
641 static void nfp_fw_unload(struct nfp_pf *pf) in nfp_fw_unload() argument
646 nsp = nfp_nsp_open(pf->cpp); in nfp_fw_unload()
648 nfp_err(pf->cpp, "Reset failed, can't open NSP\n"); in nfp_fw_unload()
654 dev_warn(&pf->pdev->dev, "Couldn't unload firmware: %d\n", err); in nfp_fw_unload()
656 dev_info(&pf->pdev->dev, "Firmware safely unloaded\n"); in nfp_fw_unload()
661 static int nfp_pf_find_rtsyms(struct nfp_pf *pf) in nfp_pf_find_rtsyms() argument
666 pf_id = nfp_cppcore_pcie_unit(pf->cpp); in nfp_pf_find_rtsyms()
668 /* Optional per-PCI PF mailbox */ in nfp_pf_find_rtsyms()
670 pf->mbox = nfp_rtsym_lookup(pf->rtbl, pf_symbol); in nfp_pf_find_rtsyms()
671 if (pf->mbox && nfp_rtsym_size(pf->mbox) < NFP_MBOX_SYM_MIN_SIZE) { in nfp_pf_find_rtsyms()
672 nfp_err(pf->cpp, "PF mailbox symbol too small: %llu < %d\n", in nfp_pf_find_rtsyms()
673 nfp_rtsym_size(pf->mbox), NFP_MBOX_SYM_MIN_SIZE); in nfp_pf_find_rtsyms()
684 struct nfp_pf *pf; in nfp_pci_probe() local
689 …dev_warn(&pdev->dev, "Binding NFP VF device to the NFP PF driver, the VF driver is called 'nfp_net… in nfp_pci_probe()
708 devlink = devlink_alloc(&nfp_devlink_ops, sizeof(*pf)); in nfp_pci_probe()
713 pf = devlink_priv(devlink); in nfp_pci_probe()
714 INIT_LIST_HEAD(&pf->vnics); in nfp_pci_probe()
715 INIT_LIST_HEAD(&pf->ports); in nfp_pci_probe()
716 mutex_init(&pf->lock); in nfp_pci_probe()
717 pci_set_drvdata(pdev, pf); in nfp_pci_probe()
718 pf->pdev = pdev; in nfp_pci_probe()
720 pf->wq = alloc_workqueue("nfp-%s", 0, 2, pci_name(pdev)); in nfp_pci_probe()
721 if (!pf->wq) { in nfp_pci_probe()
726 pf->cpp = nfp_cpp_from_nfp6000_pcie(pdev); in nfp_pci_probe()
727 if (IS_ERR_OR_NULL(pf->cpp)) { in nfp_pci_probe()
728 err = PTR_ERR(pf->cpp); in nfp_pci_probe()
734 err = nfp_resource_table_init(pf->cpp); in nfp_pci_probe()
738 pf->hwinfo = nfp_hwinfo_read(pf->cpp); in nfp_pci_probe()
741 nfp_hwinfo_lookup(pf->hwinfo, "assembly.vendor"), in nfp_pci_probe()
742 nfp_hwinfo_lookup(pf->hwinfo, "assembly.partno"), in nfp_pci_probe()
743 nfp_hwinfo_lookup(pf->hwinfo, "assembly.serial"), in nfp_pci_probe()
744 nfp_hwinfo_lookup(pf->hwinfo, "assembly.revision"), in nfp_pci_probe()
745 nfp_hwinfo_lookup(pf->hwinfo, "cpld.version")); in nfp_pci_probe()
747 err = nfp_pf_board_state_wait(pf); in nfp_pci_probe()
751 err = nfp_nsp_init(pdev, pf); in nfp_pci_probe()
755 pf->mip = nfp_mip_open(pf->cpp); in nfp_pci_probe()
756 pf->rtbl = __nfp_rtsym_table_read(pf->cpp, pf->mip); in nfp_pci_probe()
758 err = nfp_pf_find_rtsyms(pf); in nfp_pci_probe()
762 pf->dump_flag = NFP_DUMP_NSP_DIAG; in nfp_pci_probe()
763 pf->dumpspec = nfp_net_dump_load_dumpspec(pf->cpp, pf->rtbl); in nfp_pci_probe()
765 err = nfp_pcie_sriov_read_nfd_limit(pf); in nfp_pci_probe()
769 pf->num_vfs = pci_num_vf(pdev); in nfp_pci_probe()
770 if (pf->num_vfs > pf->limit_vfs) { in nfp_pci_probe()
773 pf->num_vfs, pf->limit_vfs); in nfp_pci_probe()
778 err = nfp_net_pci_probe(pf); in nfp_pci_probe()
782 err = nfp_hwmon_register(pf); in nfp_pci_probe()
791 nfp_net_pci_remove(pf); in nfp_pci_probe()
793 kfree(pf->rtbl); in nfp_pci_probe()
794 nfp_mip_close(pf->mip); in nfp_pci_probe()
795 if (pf->unload_fw_on_remove) in nfp_pci_probe()
796 nfp_fw_unload(pf); in nfp_pci_probe()
797 kfree(pf->eth_tbl); in nfp_pci_probe()
798 kfree(pf->nspi); in nfp_pci_probe()
799 vfree(pf->dumpspec); in nfp_pci_probe()
801 kfree(pf->hwinfo); in nfp_pci_probe()
803 nfp_cpp_free(pf->cpp); in nfp_pci_probe()
805 destroy_workqueue(pf->wq); in nfp_pci_probe()
808 mutex_destroy(&pf->lock); in nfp_pci_probe()
820 struct nfp_pf *pf; in __nfp_pci_shutdown() local
822 pf = pci_get_drvdata(pdev); in __nfp_pci_shutdown()
823 if (!pf) in __nfp_pci_shutdown()
826 nfp_hwmon_unregister(pf); in __nfp_pci_shutdown()
830 nfp_net_pci_remove(pf); in __nfp_pci_shutdown()
832 vfree(pf->dumpspec); in __nfp_pci_shutdown()
833 kfree(pf->rtbl); in __nfp_pci_shutdown()
834 nfp_mip_close(pf->mip); in __nfp_pci_shutdown()
835 if (unload_fw && pf->unload_fw_on_remove) in __nfp_pci_shutdown()
836 nfp_fw_unload(pf); in __nfp_pci_shutdown()
838 destroy_workqueue(pf->wq); in __nfp_pci_shutdown()
840 kfree(pf->hwinfo); in __nfp_pci_shutdown()
841 nfp_cpp_free(pf->cpp); in __nfp_pci_shutdown()
843 kfree(pf->eth_tbl); in __nfp_pci_shutdown()
844 kfree(pf->nspi); in __nfp_pci_shutdown()
845 mutex_destroy(&pf->lock); in __nfp_pci_shutdown()
846 devlink_free(priv_to_devlink(pf)); in __nfp_pci_shutdown()