return NULL;
}
-static unsigned int nfp_net_pf_get_num_ports(struct nfp_pf *pf)
+static int
+nfp_net_pf_rtsym_read_optional(struct nfp_pf *pf, const char *format,
+ unsigned int default_val)
{
char name[256];
int err = 0;
u64 val;
- snprintf(name, sizeof(name), "nfd_cfg_pf%u_num_ports",
- nfp_cppcore_pcie_unit(pf->cpp));
+ snprintf(name, sizeof(name), format, nfp_cppcore_pcie_unit(pf->cpp));
val = nfp_rtsym_read_le(pf->cpp, name, &err);
- /* Default to one port/vNIC */
if (err) {
- if (err != -ENOENT)
- nfp_err(pf->cpp, "Unable to read adapter vNIC count\n");
- val = 1;
+ if (err == -ENOENT)
+ return default_val;
+ nfp_err(pf->cpp, "Unable to read symbol %s\n", name);
+ return err;
}
return val;
}
+static int nfp_net_pf_get_num_ports(struct nfp_pf *pf)
+{
+ return nfp_net_pf_rtsym_read_optional(pf, "nfd_cfg_pf%u_num_ports", 1);
+}
+
static unsigned int
nfp_net_pf_total_qcs(struct nfp_pf *pf, void __iomem *ctrl_bar,
unsigned int stride, u32 start_off, u32 num_off)
mutex_lock(&pf->lock);
pf->max_data_vnics = nfp_net_pf_get_num_ports(pf);
+ if ((int)pf->max_data_vnics < 0) {
+ err = pf->max_data_vnics;
+ goto err_unlock;
+ }
ctrl_bar = nfp_net_pf_map_ctrl_bar(pf);
if (!ctrl_bar) {