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,
	Jakub Kicinski <jakub.kicinski@netronome.com>
Subject: [PATCH net-next 06/13] nfp: disallow mixing vNICs with and without NSP port entry
Date: Fri, 19 May 2017 15:01:48 -0700	[thread overview]
Message-ID: <20170519220155.27857-7-jakub.kicinski@netronome.com> (raw)
In-Reply-To: <20170519220155.27857-1-jakub.kicinski@netronome.com>

We only support core NIC apps which have vNICs for each physical port/
split and no representors right now.  Enforce that either each vNIC has
a NSP eth_table entry or if NSP port table is not available none do.

One scenario this will prevent from happening is user force-loading
wrong firmware file if FW app requires different firmwares per media
config.

While at it move some code to nfp_net_pf_alloc_vnic() to make it
counter-match nfp_net_pf_free_vnic() better.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Simon Horman <simon.horman@netronome.com>
---
 drivers/net/ethernet/netronome/nfp/nfp_net_main.c | 52 ++++++++++++++---------
 1 file changed, 32 insertions(+), 20 deletions(-)

diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_main.c b/drivers/net/ethernet/netronome/nfp/nfp_net_main.c
index 17ff8a88fc24..d54506b3f783 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_net_main.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_net_main.c
@@ -289,7 +289,7 @@ static struct nfp_net *
 nfp_net_pf_alloc_vnic(struct nfp_pf *pf, void __iomem *ctrl_bar,
 		      void __iomem *tx_bar, void __iomem *rx_bar,
 		      int stride, struct nfp_net_fw_version *fw_ver,
-		      struct nfp_eth_table_port *eth_port)
+		      unsigned int eth_id)
 {
 	u32 n_tx_rings, n_rx_rings;
 	struct nfp_net *nn;
@@ -310,7 +310,10 @@ nfp_net_pf_alloc_vnic(struct nfp_pf *pf, void __iomem *ctrl_bar,
 	nn->dp.is_vf = 0;
 	nn->stride_rx = stride;
 	nn->stride_tx = stride;
-	nn->eth_port = eth_port;
+	nn->eth_port = nfp_net_find_port(pf->eth_tbl, eth_id);
+
+	pf->num_vnics++;
+	list_add_tail(&nn->vnic_list, &pf->vnics);
 
 	return nn;
 }
@@ -346,11 +349,16 @@ nfp_net_pf_alloc_vnics(struct nfp_pf *pf, void __iomem *ctrl_bar,
 		       int stride, struct nfp_net_fw_version *fw_ver)
 {
 	u32 prev_tx_base, prev_rx_base, tgt_tx_base, tgt_rx_base;
-	struct nfp_eth_table_port *eth_port;
 	struct nfp_net *nn;
 	unsigned int i;
 	int err;
 
+	if (pf->eth_tbl && pf->max_data_vnics != pf->eth_tbl->count) {
+		nfp_err(pf->cpp, "ETH entries don't match vNICs (%d vs %d)\n",
+			pf->max_data_vnics, pf->eth_tbl->count);
+		return -EINVAL;
+	}
+
 	prev_tx_base = readl(ctrl_bar + NFP_NET_CFG_START_TXQ);
 	prev_rx_base = readl(ctrl_bar + NFP_NET_CFG_START_RXQ);
 
@@ -362,21 +370,26 @@ nfp_net_pf_alloc_vnics(struct nfp_pf *pf, void __iomem *ctrl_bar,
 		prev_tx_base = tgt_tx_base;
 		prev_rx_base = tgt_rx_base;
 
-		eth_port = nfp_net_find_port(pf->eth_tbl, i);
-		if (eth_port && eth_port->override_changed) {
-			nfp_warn(pf->cpp, "Config changed for port #%d, reboot required before port will be operational\n", i);
-		} else {
-			nn = nfp_net_pf_alloc_vnic(pf, ctrl_bar, tx_bar, rx_bar,
-						   stride, fw_ver, eth_port);
-			if (IS_ERR(nn)) {
-				err = PTR_ERR(nn);
-				goto err_free_prev;
-			}
-			list_add_tail(&nn->vnic_list, &pf->vnics);
-			pf->num_vnics++;
+		nn = nfp_net_pf_alloc_vnic(pf, ctrl_bar, tx_bar, rx_bar,
+					   stride, fw_ver, i);
+		if (IS_ERR(nn)) {
+			err = PTR_ERR(nn);
+			goto err_free_prev;
 		}
 
 		ctrl_bar += NFP_PF_CSR_SLICE_SIZE;
+
+		/* Check if vNIC has external port associated and cfg is OK */
+		if (pf->eth_tbl && !nn->eth_port) {
+			nfp_err(pf->cpp, "NSP port entries don't match vNICs (no entry for port #%d)\n", i);
+			err = -EINVAL;
+			goto err_free_prev;
+		}
+		if (nn->eth_port && nn->eth_port->override_changed) {
+			nfp_warn(pf->cpp, "Config changed for port #%d, reboot required before port will be operational\n", i);
+			nfp_net_pf_free_vnic(pf, nn);
+			continue;
+		}
 	}
 
 	if (list_empty(&pf->vnics))
@@ -517,6 +530,9 @@ static void nfp_net_refresh_vnics(struct work_struct *work)
 			continue;
 		nn->eth_port = nfp_net_find_port(eth_table,
 						 nn->eth_port->eth_index);
+		if (!nn->eth_port)
+			nfp_err(pf->cpp,
+				"Warning: port disappeared after reconfig\n");
 	}
 	rtnl_unlock();
 
@@ -524,11 +540,7 @@ static void nfp_net_refresh_vnics(struct work_struct *work)
 	pf->eth_tbl = eth_table;
 
 	list_for_each_entry_safe(nn, next, &pf->vnics, vnic_list) {
-		if (!nn->eth_port) {
-			nfp_warn(pf->cpp, "Warning: port not present after reconfig\n");
-			continue;
-		}
-		if (!nn->eth_port->override_changed)
+		if (nn->eth_port && !nn->eth_port->override_changed)
 			continue;
 
 		nn_warn(nn, "Port config changed, unregistering. Reboot required before port will be operational again.\n");
-- 
2.11.0

  parent 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 ` [PATCH net-next 01/13] nfp: add nfp_cppcore_pcie_unit() helper Jakub Kicinski
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 ` Jakub Kicinski [this message]
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-7-jakub.kicinski@netronome.com \
    --to=jakub.kicinski@netronome.com \
    --cc=kubakici@wp.pl \
    --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