diff options
-rw-r--r-- | drivers/net/ethernet/netronome/nfp/nfp_main.c | 43 | ||||
-rw-r--r-- | drivers/net/ethernet/netronome/nfp/nfp_net_main.c | 23 |
2 files changed, 43 insertions, 23 deletions
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_main.c b/drivers/net/ethernet/netronome/nfp/nfp_main.c index f055b1774d65..424707d41fbd 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_main.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_main.c | |||
@@ -74,6 +74,45 @@ static const struct pci_device_id nfp_pci_device_ids[] = { | |||
74 | }; | 74 | }; |
75 | MODULE_DEVICE_TABLE(pci, nfp_pci_device_ids); | 75 | MODULE_DEVICE_TABLE(pci, nfp_pci_device_ids); |
76 | 76 | ||
77 | static bool nfp_board_ready(struct nfp_pf *pf) | ||
78 | { | ||
79 | const char *cp; | ||
80 | long state; | ||
81 | int err; | ||
82 | |||
83 | cp = nfp_hwinfo_lookup(pf->hwinfo, "board.state"); | ||
84 | if (!cp) | ||
85 | return false; | ||
86 | |||
87 | err = kstrtol(cp, 0, &state); | ||
88 | if (err < 0) | ||
89 | return false; | ||
90 | |||
91 | return state == 15; | ||
92 | } | ||
93 | |||
94 | static int nfp_pf_board_state_wait(struct nfp_pf *pf) | ||
95 | { | ||
96 | const unsigned long wait_until = jiffies + 10 * HZ; | ||
97 | |||
98 | while (!nfp_board_ready(pf)) { | ||
99 | if (time_is_before_eq_jiffies(wait_until)) { | ||
100 | nfp_err(pf->cpp, "NFP board initialization timeout\n"); | ||
101 | return -EINVAL; | ||
102 | } | ||
103 | |||
104 | nfp_info(pf->cpp, "waiting for board initialization\n"); | ||
105 | if (msleep_interruptible(500)) | ||
106 | return -ERESTARTSYS; | ||
107 | |||
108 | /* Refresh cached information */ | ||
109 | kfree(pf->hwinfo); | ||
110 | pf->hwinfo = nfp_hwinfo_read(pf->cpp); | ||
111 | } | ||
112 | |||
113 | return 0; | ||
114 | } | ||
115 | |||
77 | static int nfp_pcie_sriov_read_nfd_limit(struct nfp_pf *pf) | 116 | static int nfp_pcie_sriov_read_nfd_limit(struct nfp_pf *pf) |
78 | { | 117 | { |
79 | int err; | 118 | int err; |
@@ -425,6 +464,10 @@ static int nfp_pci_probe(struct pci_dev *pdev, | |||
425 | nfp_hwinfo_lookup(pf->hwinfo, "assembly.revision"), | 464 | nfp_hwinfo_lookup(pf->hwinfo, "assembly.revision"), |
426 | nfp_hwinfo_lookup(pf->hwinfo, "cpld.version")); | 465 | nfp_hwinfo_lookup(pf->hwinfo, "cpld.version")); |
427 | 466 | ||
467 | err = nfp_pf_board_state_wait(pf); | ||
468 | if (err) | ||
469 | goto err_hwinfo_free; | ||
470 | |||
428 | err = devlink_register(devlink, &pdev->dev); | 471 | err = devlink_register(devlink, &pdev->dev); |
429 | if (err) | 472 | if (err) |
430 | goto err_hwinfo_free; | 473 | goto err_hwinfo_free; |
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_main.c b/drivers/net/ethernet/netronome/nfp/nfp_net_main.c index 5abb9ba31e7d..ff373acd28f3 100644 --- a/drivers/net/ethernet/netronome/nfp/nfp_net_main.c +++ b/drivers/net/ethernet/netronome/nfp/nfp_net_main.c | |||
@@ -64,23 +64,6 @@ | |||
64 | 64 | ||
65 | #define NFP_PF_CSR_SLICE_SIZE (32 * 1024) | 65 | #define NFP_PF_CSR_SLICE_SIZE (32 * 1024) |
66 | 66 | ||
67 | static int nfp_is_ready(struct nfp_pf *pf) | ||
68 | { | ||
69 | const char *cp; | ||
70 | long state; | ||
71 | int err; | ||
72 | |||
73 | cp = nfp_hwinfo_lookup(pf->hwinfo, "board.state"); | ||
74 | if (!cp) | ||
75 | return 0; | ||
76 | |||
77 | err = kstrtol(cp, 0, &state); | ||
78 | if (err < 0) | ||
79 | return 0; | ||
80 | |||
81 | return state == 15; | ||
82 | } | ||
83 | |||
84 | /** | 67 | /** |
85 | * nfp_net_get_mac_addr() - Get the MAC address. | 68 | * nfp_net_get_mac_addr() - Get the MAC address. |
86 | * @pf: NFP PF handle | 69 | * @pf: NFP PF handle |
@@ -725,12 +708,6 @@ int nfp_net_pci_probe(struct nfp_pf *pf) | |||
725 | 708 | ||
726 | INIT_WORK(&pf->port_refresh_work, nfp_net_refresh_vnics); | 709 | INIT_WORK(&pf->port_refresh_work, nfp_net_refresh_vnics); |
727 | 710 | ||
728 | /* Verify that the board has completed initialization */ | ||
729 | if (!nfp_is_ready(pf)) { | ||
730 | nfp_err(pf->cpp, "NFP is not ready for NIC operation.\n"); | ||
731 | return -EINVAL; | ||
732 | } | ||
733 | |||
734 | if (!pf->rtbl) { | 711 | if (!pf->rtbl) { |
735 | nfp_err(pf->cpp, "No %s, giving up.\n", | 712 | nfp_err(pf->cpp, "No %s, giving up.\n", |
736 | pf->fw_loaded ? "symbol table" : "firmware found"); | 713 | pf->fw_loaded ? "symbol table" : "firmware found"); |