From: Simon Horman <simon.horman@netronome.com>
To: David Miller <davem@davemloft.net>,
Jakub Kicinski <jakub.kicinski@netronome.com>
Cc: netdev@vger.kernel.org, oss-drivers@netronome.com,
Or Gerlitz <gerlitz.or@gmail.com>,
Simon Horman <simon.horman@netronome.com>
Subject: [PATCH net-next v2 03/12] nfp: move physical port init into a helper
Date: Tue, 20 Jun 2017 23:36:11 +0200 [thread overview]
Message-ID: <1497994580-6271-4-git-send-email-simon.horman@netronome.com> (raw)
In-Reply-To: <1497994580-6271-1-git-send-email-simon.horman@netronome.com>
From: Jakub Kicinski <jakub.kicinski@netronome.com>
Move MAC/PHY port init into a helper to make it easier to reuse
it in the representor code.
Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: Simon Horman <simon.horman@netronome.com>
---
drivers/net/ethernet/netronome/nfp/nfp_app_nic.c | 23 ++++++----------------
drivers/net/ethernet/netronome/nfp/nfp_port.c | 25 ++++++++++++++++++++++++
drivers/net/ethernet/netronome/nfp/nfp_port.h | 3 +++
3 files changed, 34 insertions(+), 17 deletions(-)
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_app_nic.c b/drivers/net/ethernet/netronome/nfp/nfp_app_nic.c
index 83c65e6291ee..7b966bd3d214 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_app_nic.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_app_nic.c
@@ -42,6 +42,8 @@ static int
nfp_app_nic_vnic_init_phy_port(struct nfp_pf *pf, struct nfp_app *app,
struct nfp_net *nn, unsigned int id)
{
+ int err;
+
if (!pf->eth_tbl)
return 0;
@@ -49,26 +51,13 @@ nfp_app_nic_vnic_init_phy_port(struct nfp_pf *pf, struct nfp_app *app,
if (IS_ERR(nn->port))
return PTR_ERR(nn->port);
- nn->port->eth_id = id;
- nn->port->eth_port = nfp_net_find_port(pf->eth_tbl, id);
-
- /* Check if vNIC has external port associated and cfg is OK */
- if (!nn->port->eth_port) {
- nfp_err(app->cpp,
- "NSP port entries don't match vNICs (no entry for port #%d)\n",
- id);
+ err = nfp_port_init_phy_port(pf, app, nn->port, id);
+ if (err) {
nfp_port_free(nn->port);
- return -EINVAL;
- }
- if (nn->port->eth_port->override_changed) {
- nfp_warn(app->cpp,
- "Config changed for port #%d, reboot required before port will be operational\n",
- id);
- nn->port->type = NFP_PORT_INVALID;
- return 1;
+ return err;
}
- return 0;
+ return nn->port->type == NFP_PORT_INVALID;
}
int nfp_app_nic_vnic_init(struct nfp_app *app, struct nfp_net *nn,
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_port.c b/drivers/net/ethernet/netronome/nfp/nfp_port.c
index a17410ac01ab..19bceeb82225 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_port.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_port.c
@@ -33,6 +33,7 @@
#include <linux/lockdep.h>
+#include "nfpcore/nfp_cpp.h"
#include "nfpcore/nfp_nsp.h"
#include "nfp_app.h"
#include "nfp_main.h"
@@ -112,6 +113,30 @@ nfp_port_get_phys_port_name(struct net_device *netdev, char *name, size_t len)
return 0;
}
+int nfp_port_init_phy_port(struct nfp_pf *pf, struct nfp_app *app,
+ struct nfp_port *port, unsigned int id)
+{
+ port->eth_id = id;
+ port->eth_port = nfp_net_find_port(pf->eth_tbl, id);
+
+ /* Check if vNIC has external port associated and cfg is OK */
+ if (!port->eth_port) {
+ nfp_err(app->cpp,
+ "NSP port entries don't match vNICs (no entry for port #%d)\n",
+ id);
+ return -EINVAL;
+ }
+ if (port->eth_port->override_changed) {
+ nfp_warn(app->cpp,
+ "Config changed for port #%d, reboot required before port will be operational\n",
+ id);
+ port->type = NFP_PORT_INVALID;
+ return 0;
+ }
+
+ return 0;
+}
+
struct nfp_port *
nfp_port_alloc(struct nfp_app *app, enum nfp_port_type type,
struct net_device *netdev)
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_port.h b/drivers/net/ethernet/netronome/nfp/nfp_port.h
index 4d1a9b3fed41..fb28c7071987 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_port.h
+++ b/drivers/net/ethernet/netronome/nfp/nfp_port.h
@@ -104,6 +104,9 @@ nfp_port_alloc(struct nfp_app *app, enum nfp_port_type type,
struct net_device *netdev);
void nfp_port_free(struct nfp_port *port);
+int nfp_port_init_phy_port(struct nfp_pf *pf, struct nfp_app *app,
+ struct nfp_port *port, unsigned int id);
+
int nfp_net_refresh_eth_port(struct nfp_port *port);
void nfp_net_refresh_port_table(struct nfp_port *port);
int nfp_net_refresh_port_table_sync(struct nfp_pf *pf);
--
2.1.4
next prev parent reply other threads:[~2017-06-20 21:36 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-20 21:36 [PATCH net-next v2 00/12] nfp: add flower app with representors Simon Horman
2017-06-20 21:36 ` [PATCH net-next v2 01/12] net: store port/representator id in metadata_dst Simon Horman
2017-06-20 21:36 ` [PATCH net-next v2 02/12] nfp: devlink add support for getting eswitch mode Simon Horman
2017-06-20 21:36 ` Simon Horman [this message]
2017-06-20 21:36 ` [PATCH net-next v2 04/12] nfp: map mac_stats and vf_cfg BARs Simon Horman
2017-06-20 21:36 ` [PATCH net-next v2 05/12] nfp: general representor implementation Simon Horman
2017-06-20 21:36 ` [PATCH net-next v2 06/12] nfp: add stats and xmit helpers for representors Simon Horman
2017-06-20 21:36 ` [PATCH net-next v2 07/12] nfp: app callbacks for SRIOV Simon Horman
2017-06-20 21:36 ` [PATCH net-next v2 08/12] nfp: provide nfp_port to of nfp_net_get_mac_addr() Simon Horman
2017-06-20 21:36 ` [PATCH net-next v2 09/12] nfp: add support for tx/rx with metadata portid Simon Horman
2017-06-20 21:36 ` [PATCH net-next v2 10/12] nfp: add support for control messages for flower app Simon Horman
2017-06-20 21:36 ` [PATCH net-next v2 11/12] nfp: add " Simon Horman
2017-06-21 9:04 ` Or Gerlitz
2017-06-21 9:59 ` Simon Horman
2017-06-20 21:36 ` [PATCH net-next v2 12/12] nfp: add VF and PF representors to " Simon Horman
2017-06-22 14:50 ` Or Gerlitz
2017-06-22 19:08 ` Simon Horman
2017-06-21 19:40 ` [PATCH net-next v2 00/12] nfp: add flower app with representors David Miller
2017-06-22 14:54 ` Or Gerlitz
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=1497994580-6271-4-git-send-email-simon.horman@netronome.com \
--to=simon.horman@netronome.com \
--cc=davem@davemloft.net \
--cc=gerlitz.or@gmail.com \
--cc=jakub.kicinski@netronome.com \
--cc=netdev@vger.kernel.org \
--cc=oss-drivers@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;
as well as URLs for NNTP newsgroup(s).