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 08/13] nfp: update port state in place
Date: Fri, 19 May 2017 15:01:50 -0700 [thread overview]
Message-ID: <20170519220155.27857-9-jakub.kicinski@netronome.com> (raw)
In-Reply-To: <20170519220155.27857-1-jakub.kicinski@netronome.com>
Always updating port state in place by overriding values in exiting
pf->eth_tbl makes things easier to manage and allows us to have a
common helper for both full and per-port refresh.
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 | 54 +++++++++++++----------
1 file changed, 30 insertions(+), 24 deletions(-)
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_main.c b/drivers/net/ethernet/netronome/nfp/nfp_net_main.c
index 167ccf788ba2..7bed799dee83 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_net_main.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_net_main.c
@@ -518,6 +518,30 @@ static void nfp_net_pci_remove_finish(struct nfp_pf *pf)
nfp_cpp_area_release_free(pf->data_vnic_bar);
}
+static int
+nfp_net_eth_port_update(struct nfp_cpp *cpp, struct nfp_port *port,
+ struct nfp_eth_table *eth_table)
+{
+ struct nfp_eth_table_port *eth_port;
+
+ ASSERT_RTNL();
+
+ eth_port = nfp_net_find_port(eth_table, port->eth_id);
+ if (!eth_port) {
+ nfp_warn(cpp, "Warning: port #%d not present after reconfig\n",
+ port->eth_id);
+ return -EIO;
+ }
+ if (eth_port->override_changed) {
+ nfp_warn(cpp, "Port #%d config changed, unregistering. Reboot required before port will be operational again.\n", port->eth_id);
+ port->type = NFP_PORT_INVALID;
+ }
+
+ memcpy(port->eth_port, eth_port, sizeof(*eth_port));
+
+ return 0;
+}
+
static void nfp_net_refresh_vnics(struct work_struct *work)
{
struct nfp_pf *pf = container_of(work, struct nfp_pf,
@@ -544,23 +568,12 @@ static void nfp_net_refresh_vnics(struct work_struct *work)
list_for_each_entry(nn, &pf->vnics, vnic_list) {
if (!__nfp_port_get_eth_port(nn->port))
continue;
- nn->port->eth_port = nfp_net_find_port(eth_table,
- nn->port->eth_id);
- if (!nn->port->eth_port) {
- nfp_warn(pf->cpp, "Warning: port #%d not present after reconfig\n",
- nn->port->eth_id);
- continue;
- }
- if (nn->port->eth_port->override_changed) {
- nfp_warn(pf->cpp, "Port config changed, unregistering. Reboot required before port will be operational again.\n");
- nn->port->type = NFP_PORT_INVALID;
- continue;
- }
+
+ nfp_net_eth_port_update(pf->cpp, nn->port, eth_table);
}
rtnl_unlock();
- kfree(pf->eth_tbl);
- pf->eth_tbl = eth_table;
+ kfree(eth_table);
list_for_each_entry_safe(nn, next, &pf->vnics, vnic_list) {
if (!nn->port || nn->port->type != NFP_PORT_INVALID)
@@ -588,8 +601,8 @@ void nfp_net_refresh_port_table(struct nfp_port *port)
int nfp_net_refresh_eth_port(struct nfp_port *port)
{
struct nfp_cpp *cpp = nfp_app_cpp(port->app);
- struct nfp_eth_table_port *eth_port;
struct nfp_eth_table *eth_table;
+ int ret;
eth_table = nfp_eth_read_ports(cpp);
if (!eth_table) {
@@ -597,18 +610,11 @@ int nfp_net_refresh_eth_port(struct nfp_port *port)
return -EIO;
}
- eth_port = nfp_net_find_port(eth_table, port->eth_id);
- if (!eth_port) {
- nfp_err(cpp, "Error finding state of the port!\n");
- kfree(eth_table);
- return -EIO;
- }
-
- memcpy(port->eth_port, eth_port, sizeof(*eth_port));
+ ret = nfp_net_eth_port_update(cpp, port, eth_table);
kfree(eth_table);
- return 0;
+ return ret;
}
/*
--
2.11.0
next prev 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 ` [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 ` Jakub Kicinski [this message]
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-9-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