Lines Matching refs:pf
72 int nfp_pf_rtsym_read_optional(struct nfp_pf *pf, const char *format, in nfp_pf_rtsym_read_optional() argument
79 snprintf(name, sizeof(name), format, nfp_cppcore_pcie_unit(pf->cpp)); in nfp_pf_rtsym_read_optional()
81 val = nfp_rtsym_read_le(pf->rtbl, name, &err); in nfp_pf_rtsym_read_optional()
85 nfp_err(pf->cpp, "Unable to read symbol %s\n", name); in nfp_pf_rtsym_read_optional()
93 nfp_pf_map_rtsym(struct nfp_pf *pf, const char *name, const char *sym_fmt, in nfp_pf_map_rtsym() argument
99 nfp_cppcore_pcie_unit(pf->cpp)); in nfp_pf_map_rtsym()
101 return nfp_rtsym_map(pf->rtbl, pf_symbol, name, min_size, area); in nfp_pf_map_rtsym()
105 int nfp_mbox_cmd(struct nfp_pf *pf, u32 cmd, void *in_data, u64 in_length, in nfp_mbox_cmd() argument
113 if (!pf->mbox) in nfp_mbox_cmd()
116 max_data_sz = nfp_rtsym_size(pf->mbox) - NFP_MBOX_SYM_MIN_SIZE; in nfp_mbox_cmd()
119 err = nfp_rtsym_readl(pf->cpp, pf->mbox, NFP_MBOX_CMD, &val); in nfp_mbox_cmd()
121 nfp_warn(pf->cpp, "failed to issue command (%u): %u, err: %d\n", in nfp_mbox_cmd()
127 n = nfp_rtsym_write(pf->cpp, pf->mbox, NFP_MBOX_DATA, in_data, in nfp_mbox_cmd()
132 err = nfp_rtsym_writeq(pf->cpp, pf->mbox, NFP_MBOX_DATA_LEN, in_length); in nfp_mbox_cmd()
137 err = nfp_rtsym_readl(pf->cpp, pf->mbox, NFP_MBOX_DATA_LEN, &val); in nfp_mbox_cmd()
142 err = nfp_rtsym_writeq(pf->cpp, pf->mbox, NFP_MBOX_CMD, cmd); in nfp_mbox_cmd()
149 err = nfp_rtsym_readl(pf->cpp, pf->mbox, NFP_MBOX_CMD, &val); in nfp_mbox_cmd()
162 err = nfp_rtsym_readl(pf->cpp, pf->mbox, NFP_MBOX_DATA_LEN, &val); in nfp_mbox_cmd()
167 n = nfp_rtsym_read(pf->cpp, pf->mbox, NFP_MBOX_DATA, in nfp_mbox_cmd()
173 err = nfp_rtsym_readl(pf->cpp, pf->mbox, NFP_MBOX_RET, &val); in nfp_mbox_cmd()
182 static bool nfp_board_ready(struct nfp_pf *pf) in nfp_board_ready() argument
188 cp = nfp_hwinfo_lookup(pf->hwinfo, "board.state"); in nfp_board_ready()
199 static int nfp_pf_board_state_wait(struct nfp_pf *pf) in nfp_pf_board_state_wait() argument
203 while (!nfp_board_ready(pf)) { in nfp_pf_board_state_wait()
205 nfp_err(pf->cpp, "NFP board initialization timeout\n"); in nfp_pf_board_state_wait()
209 nfp_info(pf->cpp, "waiting for board initialization\n"); in nfp_pf_board_state_wait()
214 kfree(pf->hwinfo); in nfp_pf_board_state_wait()
215 pf->hwinfo = nfp_hwinfo_read(pf->cpp); in nfp_pf_board_state_wait()
221 static int nfp_pcie_sriov_read_nfd_limit(struct nfp_pf *pf) in nfp_pcie_sriov_read_nfd_limit() argument
225 pf->limit_vfs = nfp_rtsym_read_le(pf->rtbl, "nfd_vf_cfg_max_vfs", &err); in nfp_pcie_sriov_read_nfd_limit()
228 pf->limit_vfs = ~0; in nfp_pcie_sriov_read_nfd_limit()
232 nfp_warn(pf->cpp, "Warning: VF limit read failed: %d\n", err); in nfp_pcie_sriov_read_nfd_limit()
236 err = pci_sriov_set_totalvfs(pf->pdev, pf->limit_vfs); in nfp_pcie_sriov_read_nfd_limit()
238 nfp_warn(pf->cpp, "Failed to set VF count in sysfs: %d\n", err); in nfp_pcie_sriov_read_nfd_limit()
245 struct nfp_pf *pf = pci_get_drvdata(pdev); in nfp_pcie_sriov_enable() local
249 if (num_vfs > pf->limit_vfs) { in nfp_pcie_sriov_enable()
250 nfp_info(pf->cpp, "Firmware limits number of VFs to %u\n", in nfp_pcie_sriov_enable()
251 pf->limit_vfs); in nfp_pcie_sriov_enable()
261 devlink = priv_to_devlink(pf); in nfp_pcie_sriov_enable()
264 err = nfp_app_sriov_enable(pf->app, num_vfs); in nfp_pcie_sriov_enable()
272 pf->num_vfs = num_vfs; in nfp_pcie_sriov_enable()
274 dev_dbg(&pdev->dev, "Created %d VFs.\n", pf->num_vfs); in nfp_pcie_sriov_enable()
290 struct nfp_pf *pf = pci_get_drvdata(pdev); in nfp_pcie_sriov_disable() local
293 devlink = priv_to_devlink(pf); in nfp_pcie_sriov_disable()
306 nfp_app_sriov_disable(pf->app); in nfp_pcie_sriov_disable()
308 pf->num_vfs = 0; in nfp_pcie_sriov_disable()
329 int nfp_flash_update_common(struct nfp_pf *pf, const struct firmware *fw, in nfp_flash_update_common() argument
332 struct device *dev = &pf->pdev->dev; in nfp_flash_update_common()
336 nsp = nfp_nsp_open(pf->cpp); in nfp_flash_update_common()
358 nfp_net_fw_request(struct pci_dev *pdev, struct nfp_pf *pf, const char *name) in nfp_net_fw_request() argument
364 nfp_info(pf->cpp, " %s: %s\n", in nfp_net_fw_request()
380 nfp_net_fw_find(struct pci_dev *pdev, struct nfp_pf *pf) in nfp_net_fw_find() argument
390 nfp_info(pf->cpp, "Looking for firmware file in order of priority:\n"); in nfp_net_fw_find()
393 interface = nfp_cpp_interface(pf->cpp); in nfp_net_fw_find()
394 nfp_cpp_serial(pf->cpp, &serial); in nfp_net_fw_find()
397 fw = nfp_net_fw_request(pdev, pf, fw_name); in nfp_net_fw_find()
403 fw = nfp_net_fw_request(pdev, pf, fw_name); in nfp_net_fw_find()
408 if (!pf->eth_tbl) { in nfp_net_fw_find()
413 fw_model = nfp_hwinfo_lookup(pf->hwinfo, "assembly.partno"); in nfp_net_fw_find()
422 for (i = 0; spc > 0 && i < pf->eth_tbl->count; i += j) { in nfp_net_fw_find()
423 port = &pf->eth_tbl->ports[i]; in nfp_net_fw_find()
425 while (i + j < pf->eth_tbl->count && in nfp_net_fw_find()
440 return nfp_net_fw_request(pdev, pf, fw_name); in nfp_net_fw_find()
479 nfp_fw_load(struct pci_dev *pdev, struct nfp_pf *pf, struct nfp_nsp *nsp) in nfp_fw_load() argument
494 interface = nfp_cpp_interface(pf->cpp); in nfp_fw_load()
529 fw = nfp_net_fw_find(pdev, pf); in nfp_fw_load()
579 pf->unload_fw_on_remove = true; in nfp_fw_load()
585 nfp_nsp_init_ports(struct pci_dev *pdev, struct nfp_pf *pf, in nfp_nsp_init_ports() argument
591 pf->eth_tbl = __nfp_eth_read_ports(pf->cpp, nsp); in nfp_nsp_init_ports()
592 if (!pf->eth_tbl) in nfp_nsp_init_ports()
598 for (i = 0; i < pf->eth_tbl->count; i++) in nfp_nsp_init_ports()
599 needs_reinit |= pf->eth_tbl->ports[i].override_changed; in nfp_nsp_init_ports()
603 kfree(pf->eth_tbl); in nfp_nsp_init_ports()
607 pf->eth_tbl = __nfp_eth_read_ports(pf->cpp, nsp); in nfp_nsp_init_ports()
610 static int nfp_nsp_init(struct pci_dev *pdev, struct nfp_pf *pf) in nfp_nsp_init() argument
615 err = nfp_resource_wait(pf->cpp, NFP_RESOURCE_NSP, 30); in nfp_nsp_init()
619 nsp = nfp_nsp_open(pf->cpp); in nfp_nsp_init()
630 nfp_nsp_init_ports(pdev, pf, nsp); in nfp_nsp_init()
632 pf->nspi = __nfp_nsp_identify(nsp); in nfp_nsp_init()
633 if (pf->nspi) in nfp_nsp_init()
634 dev_info(&pdev->dev, "BSP: %s\n", pf->nspi->version); in nfp_nsp_init()
636 err = nfp_fw_load(pdev, pf, nsp); in nfp_nsp_init()
638 kfree(pf->nspi); in nfp_nsp_init()
639 kfree(pf->eth_tbl); in nfp_nsp_init()
644 pf->fw_loaded = !!err; in nfp_nsp_init()
653 static void nfp_fw_unload(struct nfp_pf *pf) in nfp_fw_unload() argument
658 nsp = nfp_nsp_open(pf->cpp); in nfp_fw_unload()
660 nfp_err(pf->cpp, "Reset failed, can't open NSP\n"); in nfp_fw_unload()
666 dev_warn(&pf->pdev->dev, "Couldn't unload firmware: %d\n", err); in nfp_fw_unload()
668 dev_info(&pf->pdev->dev, "Firmware safely unloaded\n"); in nfp_fw_unload()
673 static int nfp_pf_find_rtsyms(struct nfp_pf *pf) in nfp_pf_find_rtsyms() argument
678 pf_id = nfp_cppcore_pcie_unit(pf->cpp); in nfp_pf_find_rtsyms()
682 pf->mbox = nfp_rtsym_lookup(pf->rtbl, pf_symbol); in nfp_pf_find_rtsyms()
683 if (pf->mbox && nfp_rtsym_size(pf->mbox) < NFP_MBOX_SYM_MIN_SIZE) { in nfp_pf_find_rtsyms()
684 nfp_err(pf->cpp, "PF mailbox symbol too small: %llu < %d\n", in nfp_pf_find_rtsyms()
685 nfp_rtsym_size(pf->mbox), NFP_MBOX_SYM_MIN_SIZE); in nfp_pf_find_rtsyms()
697 struct nfp_pf *pf; in nfp_pci_probe() local
724 devlink = devlink_alloc(&nfp_devlink_ops, sizeof(*pf), &pdev->dev); in nfp_pci_probe()
729 pf = devlink_priv(devlink); in nfp_pci_probe()
730 INIT_LIST_HEAD(&pf->vnics); in nfp_pci_probe()
731 INIT_LIST_HEAD(&pf->ports); in nfp_pci_probe()
732 pci_set_drvdata(pdev, pf); in nfp_pci_probe()
733 pf->pdev = pdev; in nfp_pci_probe()
734 pf->dev_info = dev_info; in nfp_pci_probe()
736 pf->wq = alloc_workqueue("nfp-%s", 0, 2, pci_name(pdev)); in nfp_pci_probe()
737 if (!pf->wq) { in nfp_pci_probe()
742 pf->cpp = nfp_cpp_from_nfp6000_pcie(pdev, dev_info); in nfp_pci_probe()
743 if (IS_ERR(pf->cpp)) { in nfp_pci_probe()
744 err = PTR_ERR(pf->cpp); in nfp_pci_probe()
748 err = nfp_resource_table_init(pf->cpp); in nfp_pci_probe()
752 pf->hwinfo = nfp_hwinfo_read(pf->cpp); in nfp_pci_probe()
755 nfp_hwinfo_lookup(pf->hwinfo, "assembly.vendor"), in nfp_pci_probe()
756 nfp_hwinfo_lookup(pf->hwinfo, "assembly.partno"), in nfp_pci_probe()
757 nfp_hwinfo_lookup(pf->hwinfo, "assembly.serial"), in nfp_pci_probe()
758 nfp_hwinfo_lookup(pf->hwinfo, "assembly.revision"), in nfp_pci_probe()
759 nfp_hwinfo_lookup(pf->hwinfo, "cpld.version")); in nfp_pci_probe()
761 err = nfp_pf_board_state_wait(pf); in nfp_pci_probe()
765 err = nfp_nsp_init(pdev, pf); in nfp_pci_probe()
769 pf->mip = nfp_mip_open(pf->cpp); in nfp_pci_probe()
770 pf->rtbl = __nfp_rtsym_table_read(pf->cpp, pf->mip); in nfp_pci_probe()
772 err = nfp_pf_find_rtsyms(pf); in nfp_pci_probe()
776 pf->dump_flag = NFP_DUMP_NSP_DIAG; in nfp_pci_probe()
777 pf->dumpspec = nfp_net_dump_load_dumpspec(pf->cpp, pf->rtbl); in nfp_pci_probe()
779 err = nfp_pcie_sriov_read_nfd_limit(pf); in nfp_pci_probe()
783 pf->num_vfs = pci_num_vf(pdev); in nfp_pci_probe()
784 if (pf->num_vfs > pf->limit_vfs) { in nfp_pci_probe()
787 pf->num_vfs, pf->limit_vfs); in nfp_pci_probe()
792 err = nfp_net_pci_probe(pf); in nfp_pci_probe()
796 err = nfp_hwmon_register(pf); in nfp_pci_probe()
805 nfp_net_pci_remove(pf); in nfp_pci_probe()
807 kfree(pf->rtbl); in nfp_pci_probe()
808 nfp_mip_close(pf->mip); in nfp_pci_probe()
809 if (pf->unload_fw_on_remove) in nfp_pci_probe()
810 nfp_fw_unload(pf); in nfp_pci_probe()
811 kfree(pf->eth_tbl); in nfp_pci_probe()
812 kfree(pf->nspi); in nfp_pci_probe()
813 vfree(pf->dumpspec); in nfp_pci_probe()
815 kfree(pf->hwinfo); in nfp_pci_probe()
817 nfp_cpp_free(pf->cpp); in nfp_pci_probe()
819 destroy_workqueue(pf->wq); in nfp_pci_probe()
833 struct nfp_pf *pf; in __nfp_pci_shutdown() local
835 pf = pci_get_drvdata(pdev); in __nfp_pci_shutdown()
836 if (!pf) in __nfp_pci_shutdown()
839 nfp_hwmon_unregister(pf); in __nfp_pci_shutdown()
843 nfp_net_pci_remove(pf); in __nfp_pci_shutdown()
845 vfree(pf->dumpspec); in __nfp_pci_shutdown()
846 kfree(pf->rtbl); in __nfp_pci_shutdown()
847 nfp_mip_close(pf->mip); in __nfp_pci_shutdown()
848 if (unload_fw && pf->unload_fw_on_remove) in __nfp_pci_shutdown()
849 nfp_fw_unload(pf); in __nfp_pci_shutdown()
851 destroy_workqueue(pf->wq); in __nfp_pci_shutdown()
853 kfree(pf->hwinfo); in __nfp_pci_shutdown()
854 nfp_cpp_free(pf->cpp); in __nfp_pci_shutdown()
856 kfree(pf->eth_tbl); in __nfp_pci_shutdown()
857 kfree(pf->nspi); in __nfp_pci_shutdown()
858 devlink_free(priv_to_devlink(pf)); in __nfp_pci_shutdown()