netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jakub Kicinski <jakub.kicinski@netronome.com>
To: davem@davemloft.net
Cc: netdev@vger.kernel.org, oss-drivers@netronome.com,
	Jakub Kicinski <jakub.kicinski@netronome.com>
Subject: [PATCH net-next 11/13] nfp: abm: force Ethternet port up
Date: Mon, 21 May 2018 22:12:53 -0700	[thread overview]
Message-ID: <20180522051255.9438-12-jakub.kicinski@netronome.com> (raw)
In-Reply-To: <20180522051255.9438-1-jakub.kicinski@netronome.com>

Current control firmware does not cater too well to multi-host
applications.  There is no way to check which hosts are up or
otherwise negotiate what the state of the external port (the
Ethernet port) should be.  Make sure the link is up when driver
loads, and don't take it down when Ethernet port netdev is
closed.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Dirk van der Merwe <dirk.vandermerwe@netronome.com>
---
 drivers/net/ethernet/netronome/nfp/abm/main.c | 14 ++++++++++++++
 drivers/net/ethernet/netronome/nfp/nfp_port.c |  2 ++
 drivers/net/ethernet/netronome/nfp/nfp_port.h |  2 ++
 3 files changed, 18 insertions(+)

diff --git a/drivers/net/ethernet/netronome/nfp/abm/main.c b/drivers/net/ethernet/netronome/nfp/abm/main.c
index d8f1bdac02b8..7afd24ce79a5 100644
--- a/drivers/net/ethernet/netronome/nfp/abm/main.c
+++ b/drivers/net/ethernet/netronome/nfp/abm/main.c
@@ -103,6 +103,7 @@ nfp_abm_spawn_repr(struct nfp_app *app, struct nfp_abm_link *alink,
 	}
 
 	if (ptype == NFP_PORT_PHYS_PORT) {
+		port->eth_forced = true;
 		err = nfp_port_init_phy_port(app->pf, app, port, alink->id);
 		if (err)
 			goto err_free_port;
@@ -276,8 +277,10 @@ nfp_abm_vnic_set_mac(struct nfp_pf *pf, struct nfp_abm *abm, struct nfp_net *nn,
 static int
 nfp_abm_vnic_alloc(struct nfp_app *app, struct nfp_net *nn, unsigned int id)
 {
+	struct nfp_eth_table_port *eth_port = &app->pf->eth_tbl->ports[id];
 	struct nfp_abm *abm = app->priv;
 	struct nfp_abm_link *alink;
+	int err;
 
 	alink = kzalloc(sizeof(*alink), GFP_KERNEL);
 	if (!alink)
@@ -287,12 +290,23 @@ nfp_abm_vnic_alloc(struct nfp_app *app, struct nfp_net *nn, unsigned int id)
 	alink->vnic = nn;
 	alink->id = id;
 
+	/* This is a multi-host app, make sure MAC/PHY is up, but don't
+	 * make the MAC/PHY state follow the state of any of the ports.
+	 */
+	err = nfp_eth_set_configured(app->cpp, eth_port->index, true);
+	if (err < 0)
+		goto err_free_alink;
+
 	netif_keep_dst(nn->dp.netdev);
 
 	nfp_abm_vnic_set_mac(app->pf, abm, nn, id);
 	nfp_abm_ctrl_read_params(alink);
 
 	return 0;
+
+err_free_alink:
+	kfree(alink);
+	return err;
 }
 
 static void nfp_abm_vnic_free(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 7bd8be5c833b..a17f1ace6988 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_port.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_port.c
@@ -218,6 +218,8 @@ int nfp_port_configure(struct net_device *netdev, bool configed)
 	eth_port = __nfp_port_get_eth_port(port);
 	if (!eth_port)
 		return 0;
+	if (port->eth_forced)
+		return 0;
 
 	err = nfp_eth_set_configured(port->app->cpp, eth_port->index, configed);
 	return err < 0 && err != -EOPNOTSUPP ? err : 0;
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_port.h b/drivers/net/ethernet/netronome/nfp/nfp_port.h
index fa7e669a969c..1d9b2b47e27d 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_port.h
+++ b/drivers/net/ethernet/netronome/nfp/nfp_port.h
@@ -77,6 +77,7 @@ enum nfp_port_flags {
  * @app:	backpointer to the app structure
  * @dl_port:	devlink port structure
  * @eth_id:	for %NFP_PORT_PHYS_PORT port ID in NFP enumeration scheme
+ * @eth_forced:	for %NFP_PORT_PHYS_PORT port is forced UP or DOWN, don't change
  * @eth_port:	for %NFP_PORT_PHYS_PORT translated ETH Table port entry
  * @eth_stats:	for %NFP_PORT_PHYS_PORT MAC stats if available
  * @pf_id:	for %NFP_PORT_PF_PORT, %NFP_PORT_VF_PORT ID of the PCI PF (0-3)
@@ -99,6 +100,7 @@ struct nfp_port {
 		/* NFP_PORT_PHYS_PORT */
 		struct {
 			unsigned int eth_id;
+			bool eth_forced;
 			struct nfp_eth_table_port *eth_port;
 			u8 __iomem *eth_stats;
 		};
-- 
2.17.0

  parent reply	other threads:[~2018-05-22  5:13 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-22  5:12 [PATCH net-next 00/13] nfp: abm: add basic support for advanced buffering NIC Jakub Kicinski
2018-05-22  5:12 ` [PATCH net-next 01/13] nfp: move rtsym helpers to pf code Jakub Kicinski
2018-05-22  5:12 ` [PATCH net-next 02/13] nfp: add support for per-PCI PF mailbox Jakub Kicinski
2018-05-22  5:12 ` [PATCH net-next 03/13] nfp: add shared buffer configuration Jakub Kicinski
2018-05-22  5:12 ` [PATCH net-next 04/13] nfp: core: allow 4-byte aligned accesses to Memory Units Jakub Kicinski
2018-05-22  5:12 ` [PATCH net-next 05/13] nfp: abm: add initial active buffer management NIC skeleton Jakub Kicinski
2018-05-22  5:12 ` [PATCH net-next 06/13] nfp: abm: create project-specific vNIC structure Jakub Kicinski
2018-05-22  5:12 ` [PATCH net-next 07/13] nfp: add app pointer to port representors Jakub Kicinski
2018-05-22  5:12 ` [PATCH net-next 08/13] devlink: don't take instance lock around eswitch mode set Jakub Kicinski
2018-05-22  8:41   ` Jiri Pirko
2018-05-22  5:12 ` [PATCH net-next 09/13] nfp: add devlink_eswitch_mode_set callback Jakub Kicinski
2018-05-22  5:12 ` [PATCH net-next 10/13] nfp: abm: spawn port netdevs Jakub Kicinski
2018-05-22  5:12 ` Jakub Kicinski [this message]
2018-05-22  5:12 ` [PATCH net-next 12/13] nfp: use split in naming of PCIe PF ports Jakub Kicinski
2018-05-22  5:12 ` [PATCH net-next 13/13] nfp: assign vNIC id as phys_port_name of vNICs which are not ports Jakub Kicinski
2018-05-22  6:32 ` [PATCH net-next 00/13] nfp: abm: add basic support for advanced buffering NIC Or Gerlitz
2018-05-22  7:56   ` Jakub Kicinski
2018-05-22 14:50     ` Or Gerlitz
2018-05-22 19:14       ` Jakub Kicinski
2018-05-23 18:28 ` David Miller

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=20180522051255.9438-12-jakub.kicinski@netronome.com \
    --to=jakub.kicinski@netronome.com \
    --cc=davem@davemloft.net \
    --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).