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

nfp: move rtsym helpers to pf code

nfp_net_pf_rtsym_read_optional() and nfp_net_pf_map_rtsym() are not
really related to networking code.  Move them to the PF code and
remove the net from their names.  They will soon be needed by code
outside of nfp_net_main.c anyway.
Signed-off-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e95a5f54
...@@ -75,6 +75,38 @@ static const struct pci_device_id nfp_pci_device_ids[] = { ...@@ -75,6 +75,38 @@ static const struct pci_device_id nfp_pci_device_ids[] = {
}; };
MODULE_DEVICE_TABLE(pci, nfp_pci_device_ids); MODULE_DEVICE_TABLE(pci, nfp_pci_device_ids);
int nfp_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), format, nfp_cppcore_pcie_unit(pf->cpp));
val = nfp_rtsym_read_le(pf->rtbl, name, &err);
if (err) {
if (err == -ENOENT)
return default_val;
nfp_err(pf->cpp, "Unable to read symbol %s\n", name);
return err;
}
return val;
}
u8 __iomem *
nfp_pf_map_rtsym(struct nfp_pf *pf, const char *name, const char *sym_fmt,
unsigned int min_size, struct nfp_cpp_area **area)
{
char pf_symbol[256];
snprintf(pf_symbol, sizeof(pf_symbol), sym_fmt,
nfp_cppcore_pcie_unit(pf->cpp));
return nfp_rtsym_map(pf->rtbl, pf_symbol, name, min_size, area);
}
static bool nfp_board_ready(struct nfp_pf *pf) static bool nfp_board_ready(struct nfp_pf *pf)
{ {
const char *cp; const char *cp;
......
...@@ -177,6 +177,12 @@ nfp_net_get_mac_addr(struct nfp_pf *pf, struct net_device *netdev, ...@@ -177,6 +177,12 @@ nfp_net_get_mac_addr(struct nfp_pf *pf, struct net_device *netdev,
bool nfp_ctrl_tx(struct nfp_net *nn, struct sk_buff *skb); bool nfp_ctrl_tx(struct nfp_net *nn, struct sk_buff *skb);
int nfp_pf_rtsym_read_optional(struct nfp_pf *pf, const char *format,
unsigned int default_val);
u8 __iomem *
nfp_pf_map_rtsym(struct nfp_pf *pf, const char *name, const char *sym_fmt,
unsigned int min_size, struct nfp_cpp_area **area);
enum nfp_dump_diag { enum nfp_dump_diag {
NFP_DUMP_NSP_DIAG = 0, NFP_DUMP_NSP_DIAG = 0,
}; };
......
...@@ -101,50 +101,17 @@ nfp_net_find_port(struct nfp_eth_table *eth_tbl, unsigned int index) ...@@ -101,50 +101,17 @@ nfp_net_find_port(struct nfp_eth_table *eth_tbl, unsigned int index)
return NULL; return NULL;
} }
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), format, nfp_cppcore_pcie_unit(pf->cpp));
val = nfp_rtsym_read_le(pf->rtbl, name, &err);
if (err) {
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) 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); return nfp_pf_rtsym_read_optional(pf, "nfd_cfg_pf%u_num_ports", 1);
} }
static int nfp_net_pf_get_app_id(struct nfp_pf *pf) static int nfp_net_pf_get_app_id(struct nfp_pf *pf)
{ {
return nfp_net_pf_rtsym_read_optional(pf, "_pf%u_net_app_id", return nfp_pf_rtsym_read_optional(pf, "_pf%u_net_app_id",
NFP_APP_CORE_NIC); NFP_APP_CORE_NIC);
} }
static u8 __iomem *
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)
{
char pf_symbol[256];
snprintf(pf_symbol, sizeof(pf_symbol), sym_fmt,
nfp_cppcore_pcie_unit(pf->cpp));
return nfp_rtsym_map(pf->rtbl, pf_symbol, name, min_size, area);
}
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)
{ {
if (nfp_net_is_data_vnic(nn)) if (nfp_net_is_data_vnic(nn))
...@@ -379,9 +346,8 @@ nfp_net_pf_app_init(struct nfp_pf *pf, u8 __iomem *qc_bar, unsigned int stride) ...@@ -379,9 +346,8 @@ nfp_net_pf_app_init(struct nfp_pf *pf, u8 __iomem *qc_bar, unsigned int stride)
if (!nfp_app_needs_ctrl_vnic(pf->app)) if (!nfp_app_needs_ctrl_vnic(pf->app))
return 0; return 0;
ctrl_bar = nfp_net_pf_map_rtsym(pf, "net.ctrl", "_pf%u_net_ctrl_bar", ctrl_bar = nfp_pf_map_rtsym(pf, "net.ctrl", "_pf%u_net_ctrl_bar",
NFP_PF_CSR_SLICE_SIZE, NFP_PF_CSR_SLICE_SIZE, &pf->ctrl_vnic_bar);
&pf->ctrl_vnic_bar);
if (IS_ERR(ctrl_bar)) { if (IS_ERR(ctrl_bar)) {
nfp_err(pf->cpp, "Failed to find ctrl vNIC memory symbol\n"); nfp_err(pf->cpp, "Failed to find ctrl vNIC memory symbol\n");
err = PTR_ERR(ctrl_bar); err = PTR_ERR(ctrl_bar);
...@@ -507,7 +473,7 @@ static int nfp_net_pci_map_mem(struct nfp_pf *pf) ...@@ -507,7 +473,7 @@ static int nfp_net_pci_map_mem(struct nfp_pf *pf)
int err; int err;
min_size = 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.bar0", "_pf%d_net_bar0", mem = nfp_pf_map_rtsym(pf, "net.bar0", "_pf%d_net_bar0",
min_size, &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");
...@@ -528,10 +494,9 @@ static int nfp_net_pci_map_mem(struct nfp_pf *pf) ...@@ -528,10 +494,9 @@ static int nfp_net_pci_map_mem(struct nfp_pf *pf)
} }
} }
pf->vf_cfg_mem = nfp_net_pf_map_rtsym(pf, "net.vfcfg", pf->vf_cfg_mem = nfp_pf_map_rtsym(pf, "net.vfcfg", "_pf%d_net_vf_bar",
"_pf%d_net_vf_bar", NFP_NET_CFG_BAR_SZ * pf->limit_vfs,
NFP_NET_CFG_BAR_SZ * &pf->vf_cfg_bar);
pf->limit_vfs, &pf->vf_cfg_bar);
if (IS_ERR(pf->vf_cfg_mem)) { if (IS_ERR(pf->vf_cfg_mem)) {
if (PTR_ERR(pf->vf_cfg_mem) != -ENOENT) { if (PTR_ERR(pf->vf_cfg_mem) != -ENOENT) {
err = PTR_ERR(pf->vf_cfg_mem); err = PTR_ERR(pf->vf_cfg_mem);
...@@ -541,7 +506,7 @@ static int nfp_net_pci_map_mem(struct nfp_pf *pf) ...@@ -541,7 +506,7 @@ static int nfp_net_pci_map_mem(struct nfp_pf *pf)
} }
min_size = NFP_NET_VF_CFG_SZ * pf->limit_vfs + NFP_NET_VF_CFG_MB_SZ; min_size = NFP_NET_VF_CFG_SZ * pf->limit_vfs + NFP_NET_VF_CFG_MB_SZ;
pf->vfcfg_tbl2 = nfp_net_pf_map_rtsym(pf, "net.vfcfg_tbl2", pf->vfcfg_tbl2 = nfp_pf_map_rtsym(pf, "net.vfcfg_tbl2",
"_pf%d_net_vf_cfg2", "_pf%d_net_vf_cfg2",
min_size, &pf->vfcfg_tbl2_area); min_size, &pf->vfcfg_tbl2_area);
if (IS_ERR(pf->vfcfg_tbl2)) { if (IS_ERR(pf->vfcfg_tbl2)) {
......
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