Netdev List
 help / color / mirror / Atom feed
From: Jakub Kicinski <jakub.kicinski@netronome.com>
To: netdev@vger.kernel.org
Cc: kubakici@wp.pl, oss-drivers@netronome.com,
	Simon Horman <simon.horman@netronome.com>
Subject: [PATCH net-next 01/13] nfp: add nfp_cppcore_pcie_unit() helper
Date: Fri, 19 May 2017 15:01:43 -0700	[thread overview]
Message-ID: <20170519220155.27857-2-jakub.kicinski@netronome.com> (raw)
In-Reply-To: <20170519220155.27857-1-jakub.kicinski@netronome.com>

From: Simon Horman <simon.horman@netronome.com>

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: Simon Horman <simon.horman@netronome.com>
Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com>
---
 drivers/net/ethernet/netronome/nfp/nfp_net_main.c    | 16 ++++------------
 drivers/net/ethernet/netronome/nfp/nfpcore/nfp_cpp.h | 11 +++++++++++
 2 files changed, 15 insertions(+), 12 deletions(-)

diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_main.c b/drivers/net/ethernet/netronome/nfp/nfp_net_main.c
index 8cb87cbe1120..16115973112c 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_net_main.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_net_main.c
@@ -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)
 {
 	char name[256];
-	u16 interface;
-	int pcie_pf;
 	int err = 0;
 	u64 val;
 
-	interface = nfp_cpp_interface(pf->cpp);
-	pcie_pf = NFP_CPP_INTERFACE_UNIT_of(interface);
-
-	snprintf(name, sizeof(name), "nfd_cfg_pf%d_num_ports", pcie_pf);
+	snprintf(name, sizeof(name), "nfd_cfg_pf%u_num_ports",
+		 nfp_cppcore_pcie_unit(pf->cpp));
 
 	val = nfp_rtsym_read_le(pf->cpp, name, &err);
 	/* Default to one port */
@@ -241,13 +237,9 @@ static u8 __iomem *nfp_net_pf_map_ctrl_bar(struct nfp_pf *pf)
 	const struct nfp_rtsym *ctrl_sym;
 	u8 __iomem *ctrl_bar;
 	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);
 	if (!ctrl_sym) {
diff --git a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_cpp.h b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_cpp.h
index edecc0a27485..154b0b594184 100644
--- a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_cpp.h
+++ b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_cpp.h
@@ -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_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_command {
-- 
2.11.0

  reply	other threads:[~2017-05-19 22:02 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-19 22:01 [PATCH net-next 00/13] nfp: introduce nfp_port and nfp_app Jakub Kicinski
2017-05-19 22:01 ` Jakub Kicinski [this message]
2017-05-19 22:01 ` [PATCH net-next 02/13] nfp: make nfp_net alloc/init/cleanup/free not depend on netdevs Jakub Kicinski
2017-05-19 22:01 ` [PATCH net-next 03/13] nfp: rename netdev/port to vNIC Jakub Kicinski
2017-05-19 22:01 ` [PATCH net-next 04/13] nfp: add nfp_net_pf_free_vnic() function Jakub Kicinski
2017-05-19 22:01 ` [PATCH net-next 05/13] nfp: introduce very minimal nfp_app Jakub Kicinski
2017-05-21 17:23   ` David Miller
2017-05-19 22:01 ` [PATCH net-next 06/13] nfp: disallow mixing vNICs with and without NSP port entry Jakub Kicinski
2017-05-19 22:01 ` [PATCH net-next 07/13] nfp: introduce nfp_port Jakub Kicinski
2017-05-19 22:01 ` [PATCH net-next 08/13] nfp: update port state in place Jakub Kicinski
2017-05-19 22:01 ` [PATCH net-next 09/13] nfp: move refresh tracking into the port structure Jakub Kicinski
2017-05-19 22:01 ` [PATCH net-next 10/13] nfp: provide linking on port structures Jakub Kicinski
2017-05-19 22:01 ` [PATCH net-next 11/13] nfp: mark port state as stale after reconfig Jakub Kicinski
2017-05-19 22:01 ` [PATCH net-next 12/13] nfp: mark port state as stale if update failed Jakub Kicinski
2017-05-19 22:01 ` [PATCH net-next 13/13] nfp: refresh port state before reporting autonegotiation Jakub Kicinski

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170519220155.27857-2-jakub.kicinski@netronome.com \
    --to=jakub.kicinski@netronome.com \
    --cc=kubakici@wp.pl \
    --cc=netdev@vger.kernel.org \
    --cc=oss-drivers@netronome.com \
    --cc=simon.horman@netronome.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox