nfp: move rtsym helpers to pf code
authorJakub Kicinski <jakub.kicinski@netronome.com>
Tue, 22 May 2018 05:12:43 +0000 (22:12 -0700)
committerDavid S. Miller <davem@davemloft.net>
Wed, 23 May 2018 18:26:18 +0000 (14:26 -0400)
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: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/netronome/nfp/nfp_main.c
drivers/net/ethernet/netronome/nfp/nfp_main.h
drivers/net/ethernet/netronome/nfp/nfp_net_main.c

index 0ade122805ad1deb467035294a2f8939ae8a4139..1ef3623c6e1ca2b89544cff538c05cc7f8e5c78f 100644 (file)
@@ -75,6 +75,38 @@ static const struct pci_device_id 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)
 {
        const char *cp;
index 42211083b51f40a63c4957b2c5ab5b9e567ddba9..5b028486c8949fd78a42ec9a276a5234e62e8f77 100644 (file)
@@ -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);
 
+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 {
        NFP_DUMP_NSP_DIAG = 0,
 };
index 45cd2092e498a3a07d94c8103455abffc7041993..f8abb4cd9cef35574da5c8e88663684437ae4dd6 100644 (file)
@@ -101,48 +101,15 @@ nfp_net_find_port(struct nfp_eth_table *eth_tbl, unsigned int index)
        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)
 {
-       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)
 {
-       return nfp_net_pf_rtsym_read_optional(pf, "_pf%u_net_app_id",
-                                             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);
+       return nfp_pf_rtsym_read_optional(pf, "_pf%u_net_app_id",
+                                         NFP_APP_CORE_NIC);
 }
 
 static void nfp_net_pf_free_vnic(struct nfp_pf *pf, struct nfp_net *nn)
@@ -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))
                return 0;
 
-       ctrl_bar = nfp_net_pf_map_rtsym(pf, "net.ctrl", "_pf%u_net_ctrl_bar",
-                                       NFP_PF_CSR_SLICE_SIZE,
-                                       &pf->ctrl_vnic_bar);
+       ctrl_bar = nfp_pf_map_rtsym(pf, "net.ctrl", "_pf%u_net_ctrl_bar",
+                                   NFP_PF_CSR_SLICE_SIZE, &pf->ctrl_vnic_bar);
        if (IS_ERR(ctrl_bar)) {
                nfp_err(pf->cpp, "Failed to find ctrl vNIC memory symbol\n");
                err = PTR_ERR(ctrl_bar);
@@ -507,8 +473,8 @@ static int nfp_net_pci_map_mem(struct nfp_pf *pf)
        int err;
 
        min_size = pf->max_data_vnics * NFP_PF_CSR_SLICE_SIZE;
-       mem = nfp_net_pf_map_rtsym(pf, "net.bar0", "_pf%d_net_bar0",
-                                  min_size, &pf->data_vnic_bar);
+       mem = nfp_pf_map_rtsym(pf, "net.bar0", "_pf%d_net_bar0",
+                              min_size, &pf->data_vnic_bar);
        if (IS_ERR(mem)) {
                nfp_err(pf->cpp, "Failed to find data vNIC memory symbol\n");
                return PTR_ERR(mem);
@@ -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%d_net_vf_bar",
-                                             NFP_NET_CFG_BAR_SZ *
-                                             pf->limit_vfs, &pf->vf_cfg_bar);
+       pf->vf_cfg_mem = nfp_pf_map_rtsym(pf, "net.vfcfg", "_pf%d_net_vf_bar",
+                                         NFP_NET_CFG_BAR_SZ * pf->limit_vfs,
+                                         &pf->vf_cfg_bar);
        if (IS_ERR(pf->vf_cfg_mem)) {
                if (PTR_ERR(pf->vf_cfg_mem) != -ENOENT) {
                        err = PTR_ERR(pf->vf_cfg_mem);
@@ -541,9 +506,9 @@ 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;
-       pf->vfcfg_tbl2 = nfp_net_pf_map_rtsym(pf, "net.vfcfg_tbl2",
-                                             "_pf%d_net_vf_cfg2",
-                                             min_size, &pf->vfcfg_tbl2_area);
+       pf->vfcfg_tbl2 = nfp_pf_map_rtsym(pf, "net.vfcfg_tbl2",
+                                         "_pf%d_net_vf_cfg2",
+                                         min_size, &pf->vfcfg_tbl2_area);
        if (IS_ERR(pf->vfcfg_tbl2)) {
                if (PTR_ERR(pf->vfcfg_tbl2) != -ENOENT) {
                        err = PTR_ERR(pf->vfcfg_tbl2);