Commit cd6f8db9 authored by Simon Horman's avatar Simon Horman Committed by David S. Miller

nfp: add nfp_cppcore_pcie_unit() helper

Add nfp_cppcore_pcie_unit() helper to retrieve the PCIE unit of a CPP
handle and use the new helper as appropriate.
Signed-off-by: default avatarSimon Horman <simon.horman@netronome.com>
Reviewed-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent bd080488
...@@ -190,15 +190,11 @@ nfp_net_find_port(struct nfp_eth_table *eth_tbl, unsigned int id) ...@@ -190,15 +190,11 @@ nfp_net_find_port(struct nfp_eth_table *eth_tbl, unsigned int id)
static unsigned int nfp_net_pf_get_num_ports(struct nfp_pf *pf) static unsigned int nfp_net_pf_get_num_ports(struct nfp_pf *pf)
{ {
char name[256]; char name[256];
u16 interface;
int pcie_pf;
int err = 0; int err = 0;
u64 val; u64 val;
interface = nfp_cpp_interface(pf->cpp); snprintf(name, sizeof(name), "nfd_cfg_pf%u_num_ports",
pcie_pf = NFP_CPP_INTERFACE_UNIT_of(interface); nfp_cppcore_pcie_unit(pf->cpp));
snprintf(name, sizeof(name), "nfd_cfg_pf%d_num_ports", pcie_pf);
val = nfp_rtsym_read_le(pf->cpp, name, &err); val = nfp_rtsym_read_le(pf->cpp, name, &err);
/* Default to one port */ /* Default to one port */
...@@ -241,13 +237,9 @@ static u8 __iomem *nfp_net_pf_map_ctrl_bar(struct nfp_pf *pf) ...@@ -241,13 +237,9 @@ static u8 __iomem *nfp_net_pf_map_ctrl_bar(struct nfp_pf *pf)
const struct nfp_rtsym *ctrl_sym; const struct nfp_rtsym *ctrl_sym;
u8 __iomem *ctrl_bar; u8 __iomem *ctrl_bar;
char pf_symbol[256]; char pf_symbol[256];
u16 interface;
int pcie_pf;
interface = nfp_cpp_interface(pf->cpp);
pcie_pf = NFP_CPP_INTERFACE_UNIT_of(interface);
snprintf(pf_symbol, sizeof(pf_symbol), "_pf%d_net_bar0", pcie_pf); snprintf(pf_symbol, sizeof(pf_symbol), "_pf%u_net_bar0",
nfp_cppcore_pcie_unit(pf->cpp));
ctrl_sym = nfp_rtsym_lookup(pf->cpp, pf_symbol); ctrl_sym = nfp_rtsym_lookup(pf->cpp, pf_symbol);
if (!ctrl_sym) { if (!ctrl_sym) {
......
...@@ -289,6 +289,17 @@ int nfp_cpp_mutex_lock(struct nfp_cpp_mutex *mutex); ...@@ -289,6 +289,17 @@ int nfp_cpp_mutex_lock(struct nfp_cpp_mutex *mutex);
int nfp_cpp_mutex_unlock(struct nfp_cpp_mutex *mutex); int nfp_cpp_mutex_unlock(struct nfp_cpp_mutex *mutex);
int nfp_cpp_mutex_trylock(struct nfp_cpp_mutex *mutex); int nfp_cpp_mutex_trylock(struct nfp_cpp_mutex *mutex);
/**
* nfp_cppcore_pcie_unit() - Get PCI Unit of a CPP handle
* @cpp: CPP handle
*
* Return: PCI unit for the NFP CPP handle
*/
static inline u8 nfp_cppcore_pcie_unit(struct nfp_cpp *cpp)
{
return NFP_CPP_INTERFACE_UNIT_of(nfp_cpp_interface(cpp));
}
struct nfp_cpp_explicit; struct nfp_cpp_explicit;
struct nfp_cpp_explicit_command { struct nfp_cpp_explicit_command {
......
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