Commit f8473024 authored by Jakub Kicinski's avatar Jakub Kicinski Committed by David S. Miller

nfp: add helper for mapping runtime symbols

Move most of the helper for mapping RTsyms from nfp_net_main.c
to nfpcore.  Use the new helper directly for mapping MAC statistics,
since they don't need to include the PCIe interface ID in the symbol
name.
Signed-off-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: default avatarSimon Horman <simon.horman@netronome.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 064dc319
...@@ -174,31 +174,12 @@ static u8 __iomem * ...@@ -174,31 +174,12 @@ static u8 __iomem *
nfp_net_pf_map_rtsym(struct nfp_pf *pf, const char *name, const char *sym_fmt, nfp_net_pf_map_rtsym(struct nfp_pf *pf, const char *name, const char *sym_fmt,
unsigned int min_size, struct nfp_cpp_area **area) unsigned int min_size, struct nfp_cpp_area **area)
{ {
const struct nfp_rtsym *sym;
char pf_symbol[256]; char pf_symbol[256];
u8 __iomem *mem;
snprintf(pf_symbol, sizeof(pf_symbol), sym_fmt, snprintf(pf_symbol, sizeof(pf_symbol), sym_fmt,
nfp_cppcore_pcie_unit(pf->cpp)); nfp_cppcore_pcie_unit(pf->cpp));
sym = nfp_rtsym_lookup(pf->rtbl, pf_symbol); return nfp_rtsym_map(pf->rtbl, pf_symbol, name, min_size, area);
if (!sym)
return (u8 __iomem *)ERR_PTR(-ENOENT);
if (sym->size < min_size) {
nfp_err(pf->cpp, "PF symbol %s too small\n", pf_symbol);
return (u8 __iomem *)ERR_PTR(-EINVAL);
}
mem = nfp_cpp_map_area(pf->cpp, name, sym->domain, sym->target,
sym->addr, sym->size, area);
if (IS_ERR(mem)) {
nfp_err(pf->cpp, "Failed to map PF symbol %s: %ld\n",
pf_symbol, PTR_ERR(mem));
return mem;
}
return mem;
} }
static void nfp_net_pf_free_vnic(struct nfp_pf *pf, struct nfp_net *nn) static void nfp_net_pf_free_vnic(struct nfp_pf *pf, struct nfp_net *nn)
...@@ -528,23 +509,22 @@ static void nfp_net_pci_unmap_mem(struct nfp_pf *pf) ...@@ -528,23 +509,22 @@ static void nfp_net_pci_unmap_mem(struct nfp_pf *pf)
static int nfp_net_pci_map_mem(struct nfp_pf *pf) static int nfp_net_pci_map_mem(struct nfp_pf *pf)
{ {
u32 ctrl_bar_sz;
u8 __iomem *mem; u8 __iomem *mem;
u32 min_size;
int err; int err;
ctrl_bar_sz = pf->max_data_vnics * NFP_PF_CSR_SLICE_SIZE; min_size = pf->max_data_vnics * NFP_PF_CSR_SLICE_SIZE;
mem = nfp_net_pf_map_rtsym(pf, "net.ctrl", "_pf%d_net_bar0", mem = nfp_net_pf_map_rtsym(pf, "net.ctrl", "_pf%d_net_bar0",
ctrl_bar_sz, &pf->data_vnic_bar); min_size, &pf->data_vnic_bar);
if (IS_ERR(mem)) { if (IS_ERR(mem)) {
nfp_err(pf->cpp, "Failed to find data vNIC memory symbol\n"); nfp_err(pf->cpp, "Failed to find data vNIC memory symbol\n");
return PTR_ERR(mem); return PTR_ERR(mem);
} }
pf->mac_stats_mem = nfp_net_pf_map_rtsym(pf, "net.macstats", min_size = NFP_MAC_STATS_SIZE * (pf->eth_tbl->max_index + 1);
"_mac_stats", pf->mac_stats_mem = nfp_rtsym_map(pf->rtbl, "_mac_stats",
NFP_MAC_STATS_SIZE * "net.macstats", min_size,
(pf->eth_tbl->max_index + 1), &pf->mac_stats_bar);
&pf->mac_stats_bar);
if (IS_ERR(pf->mac_stats_mem)) { if (IS_ERR(pf->mac_stats_mem)) {
if (PTR_ERR(pf->mac_stats_mem) != -ENOENT) { if (PTR_ERR(pf->mac_stats_mem) != -ENOENT) {
err = PTR_ERR(pf->mac_stats_mem); err = PTR_ERR(pf->mac_stats_mem);
......
...@@ -97,7 +97,11 @@ int nfp_rtsym_count(struct nfp_rtsym_table *rtbl); ...@@ -97,7 +97,11 @@ int nfp_rtsym_count(struct nfp_rtsym_table *rtbl);
const struct nfp_rtsym *nfp_rtsym_get(struct nfp_rtsym_table *rtbl, int idx); const struct nfp_rtsym *nfp_rtsym_get(struct nfp_rtsym_table *rtbl, int idx);
const struct nfp_rtsym * const struct nfp_rtsym *
nfp_rtsym_lookup(struct nfp_rtsym_table *rtbl, const char *name); nfp_rtsym_lookup(struct nfp_rtsym_table *rtbl, const char *name);
u64 nfp_rtsym_read_le(struct nfp_rtsym_table *rtbl, const char *name, u64 nfp_rtsym_read_le(struct nfp_rtsym_table *rtbl, const char *name,
int *error); int *error);
u8 __iomem *
nfp_rtsym_map(struct nfp_rtsym_table *rtbl, const char *name, const char *id,
unsigned int min_size, struct nfp_cpp_area **area);
#endif /* NFP_NFFW_H */ #endif /* NFP_NFFW_H */
...@@ -289,3 +289,30 @@ u64 nfp_rtsym_read_le(struct nfp_rtsym_table *rtbl, const char *name, ...@@ -289,3 +289,30 @@ u64 nfp_rtsym_read_le(struct nfp_rtsym_table *rtbl, const char *name,
return ~0ULL; return ~0ULL;
return val; return val;
} }
u8 __iomem *
nfp_rtsym_map(struct nfp_rtsym_table *rtbl, const char *name, const char *id,
unsigned int min_size, struct nfp_cpp_area **area)
{
const struct nfp_rtsym *sym;
u8 __iomem *mem;
sym = nfp_rtsym_lookup(rtbl, name);
if (!sym)
return (u8 __iomem *)ERR_PTR(-ENOENT);
if (sym->size < min_size) {
nfp_err(rtbl->cpp, "Symbol %s too small\n", name);
return (u8 __iomem *)ERR_PTR(-EINVAL);
}
mem = nfp_cpp_map_area(rtbl->cpp, id, sym->domain, sym->target,
sym->addr, sym->size, area);
if (IS_ERR(mem)) {
nfp_err(rtbl->cpp, "Failed to map symbol %s: %ld\n",
name, PTR_ERR(mem));
return mem;
}
return mem;
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment