Commit a7ceb990 authored by Jakub Kicinski's avatar Jakub Kicinski Committed by David S. Miller

nfp: move physical port init into a helper

Move MAC/PHY port init into a helper to make it easier to reuse
it in the representor code.
Signed-off-by: default avatarJakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: default avatarSimon Horman <simon.horman@netronome.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 9daee04a
...@@ -42,6 +42,8 @@ static int ...@@ -42,6 +42,8 @@ static int
nfp_app_nic_vnic_init_phy_port(struct nfp_pf *pf, struct nfp_app *app, nfp_app_nic_vnic_init_phy_port(struct nfp_pf *pf, struct nfp_app *app,
struct nfp_net *nn, unsigned int id) struct nfp_net *nn, unsigned int id)
{ {
int err;
if (!pf->eth_tbl) if (!pf->eth_tbl)
return 0; return 0;
...@@ -49,26 +51,13 @@ nfp_app_nic_vnic_init_phy_port(struct nfp_pf *pf, struct nfp_app *app, ...@@ -49,26 +51,13 @@ nfp_app_nic_vnic_init_phy_port(struct nfp_pf *pf, struct nfp_app *app,
if (IS_ERR(nn->port)) if (IS_ERR(nn->port))
return PTR_ERR(nn->port); return PTR_ERR(nn->port);
nn->port->eth_id = id; err = nfp_port_init_phy_port(pf, app, nn->port, id);
nn->port->eth_port = nfp_net_find_port(pf->eth_tbl, id); if (err) {
/* 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);
nfp_port_free(nn->port); nfp_port_free(nn->port);
return -EINVAL; return err;
}
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 0; return nn->port->type == NFP_PORT_INVALID;
} }
int nfp_app_nic_vnic_init(struct nfp_app *app, struct nfp_net *nn, int nfp_app_nic_vnic_init(struct nfp_app *app, struct nfp_net *nn,
......
...@@ -33,6 +33,7 @@ ...@@ -33,6 +33,7 @@
#include <linux/lockdep.h> #include <linux/lockdep.h>
#include "nfpcore/nfp_cpp.h"
#include "nfpcore/nfp_nsp.h" #include "nfpcore/nfp_nsp.h"
#include "nfp_app.h" #include "nfp_app.h"
#include "nfp_main.h" #include "nfp_main.h"
...@@ -112,6 +113,30 @@ nfp_port_get_phys_port_name(struct net_device *netdev, char *name, size_t len) ...@@ -112,6 +113,30 @@ nfp_port_get_phys_port_name(struct net_device *netdev, char *name, size_t len)
return 0; 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 * struct nfp_port *
nfp_port_alloc(struct nfp_app *app, enum nfp_port_type type, nfp_port_alloc(struct nfp_app *app, enum nfp_port_type type,
struct net_device *netdev) struct net_device *netdev)
......
...@@ -104,6 +104,9 @@ nfp_port_alloc(struct nfp_app *app, enum nfp_port_type type, ...@@ -104,6 +104,9 @@ nfp_port_alloc(struct nfp_app *app, enum nfp_port_type type,
struct net_device *netdev); struct net_device *netdev);
void nfp_port_free(struct nfp_port *port); 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); int nfp_net_refresh_eth_port(struct nfp_port *port);
void nfp_net_refresh_port_table(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); int nfp_net_refresh_port_table_sync(struct nfp_pf *pf);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment