Skip to content

Commit 69394af

Browse files
Jakub Kicinskidavem330
authored andcommitted
nfp: turn reading PCIe RTsym parameters into a helper
Turn the function to read number of ports into a generic helper. While at it make sure we propagate all errors other than -ENOENT. Signed-off-by: Jakub Kicinski <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 5c91435 commit 69394af

File tree

1 file changed

+17
-7
lines changed

1 file changed

+17
-7
lines changed

drivers/net/ethernet/netronome/nfp/nfp_net_main.c

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -191,26 +191,32 @@ nfp_net_find_port(struct nfp_eth_table *eth_tbl, unsigned int id)
191191
return NULL;
192192
}
193193

194-
static unsigned int nfp_net_pf_get_num_ports(struct nfp_pf *pf)
194+
static int
195+
nfp_net_pf_rtsym_read_optional(struct nfp_pf *pf, const char *format,
196+
unsigned int default_val)
195197
{
196198
char name[256];
197199
int err = 0;
198200
u64 val;
199201

200-
snprintf(name, sizeof(name), "nfd_cfg_pf%u_num_ports",
201-
nfp_cppcore_pcie_unit(pf->cpp));
202+
snprintf(name, sizeof(name), format, nfp_cppcore_pcie_unit(pf->cpp));
202203

203204
val = nfp_rtsym_read_le(pf->cpp, name, &err);
204-
/* Default to one port/vNIC */
205205
if (err) {
206-
if (err != -ENOENT)
207-
nfp_err(pf->cpp, "Unable to read adapter vNIC count\n");
208-
val = 1;
206+
if (err == -ENOENT)
207+
return default_val;
208+
nfp_err(pf->cpp, "Unable to read symbol %s\n", name);
209+
return err;
209210
}
210211

211212
return val;
212213
}
213214

215+
static int nfp_net_pf_get_num_ports(struct nfp_pf *pf)
216+
{
217+
return nfp_net_pf_rtsym_read_optional(pf, "nfd_cfg_pf%u_num_ports", 1);
218+
}
219+
214220
static unsigned int
215221
nfp_net_pf_total_qcs(struct nfp_pf *pf, void __iomem *ctrl_bar,
216222
unsigned int stride, u32 start_off, u32 num_off)
@@ -675,6 +681,10 @@ int nfp_net_pci_probe(struct nfp_pf *pf)
675681

676682
mutex_lock(&pf->lock);
677683
pf->max_data_vnics = nfp_net_pf_get_num_ports(pf);
684+
if ((int)pf->max_data_vnics < 0) {
685+
err = pf->max_data_vnics;
686+
goto err_unlock;
687+
}
678688

679689
ctrl_bar = nfp_net_pf_map_ctrl_bar(pf);
680690
if (!ctrl_bar) {

0 commit comments

Comments
 (0)