Skip to content

Commit a7ceb99

Browse files
Jakub Kicinskidavem330
Jakub Kicinski
authored andcommitted
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: Jakub Kicinski <[email protected]> Signed-off-by: Simon Horman <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 9daee04 commit a7ceb99

File tree

3 files changed

+34
-17
lines changed

3 files changed

+34
-17
lines changed

drivers/net/ethernet/netronome/nfp/nfp_app_nic.c

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -42,33 +42,22 @@ static int
4242
nfp_app_nic_vnic_init_phy_port(struct nfp_pf *pf, struct nfp_app *app,
4343
struct nfp_net *nn, unsigned int id)
4444
{
45+
int err;
46+
4547
if (!pf->eth_tbl)
4648
return 0;
4749

4850
nn->port = nfp_port_alloc(app, NFP_PORT_PHYS_PORT, nn->dp.netdev);
4951
if (IS_ERR(nn->port))
5052
return PTR_ERR(nn->port);
5153

52-
nn->port->eth_id = id;
53-
nn->port->eth_port = nfp_net_find_port(pf->eth_tbl, id);
54-
55-
/* Check if vNIC has external port associated and cfg is OK */
56-
if (!nn->port->eth_port) {
57-
nfp_err(app->cpp,
58-
"NSP port entries don't match vNICs (no entry for port #%d)\n",
59-
id);
54+
err = nfp_port_init_phy_port(pf, app, nn->port, id);
55+
if (err) {
6056
nfp_port_free(nn->port);
61-
return -EINVAL;
62-
}
63-
if (nn->port->eth_port->override_changed) {
64-
nfp_warn(app->cpp,
65-
"Config changed for port #%d, reboot required before port will be operational\n",
66-
id);
67-
nn->port->type = NFP_PORT_INVALID;
68-
return 1;
57+
return err;
6958
}
7059

71-
return 0;
60+
return nn->port->type == NFP_PORT_INVALID;
7261
}
7362

7463
int nfp_app_nic_vnic_init(struct nfp_app *app, struct nfp_net *nn,

drivers/net/ethernet/netronome/nfp/nfp_port.c

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333

3434
#include <linux/lockdep.h>
3535

36+
#include "nfpcore/nfp_cpp.h"
3637
#include "nfpcore/nfp_nsp.h"
3738
#include "nfp_app.h"
3839
#include "nfp_main.h"
@@ -112,6 +113,30 @@ nfp_port_get_phys_port_name(struct net_device *netdev, char *name, size_t len)
112113
return 0;
113114
}
114115

116+
int nfp_port_init_phy_port(struct nfp_pf *pf, struct nfp_app *app,
117+
struct nfp_port *port, unsigned int id)
118+
{
119+
port->eth_id = id;
120+
port->eth_port = nfp_net_find_port(pf->eth_tbl, id);
121+
122+
/* Check if vNIC has external port associated and cfg is OK */
123+
if (!port->eth_port) {
124+
nfp_err(app->cpp,
125+
"NSP port entries don't match vNICs (no entry for port #%d)\n",
126+
id);
127+
return -EINVAL;
128+
}
129+
if (port->eth_port->override_changed) {
130+
nfp_warn(app->cpp,
131+
"Config changed for port #%d, reboot required before port will be operational\n",
132+
id);
133+
port->type = NFP_PORT_INVALID;
134+
return 0;
135+
}
136+
137+
return 0;
138+
}
139+
115140
struct nfp_port *
116141
nfp_port_alloc(struct nfp_app *app, enum nfp_port_type type,
117142
struct net_device *netdev)

drivers/net/ethernet/netronome/nfp/nfp_port.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ nfp_port_alloc(struct nfp_app *app, enum nfp_port_type type,
104104
struct net_device *netdev);
105105
void nfp_port_free(struct nfp_port *port);
106106

107+
int nfp_port_init_phy_port(struct nfp_pf *pf, struct nfp_app *app,
108+
struct nfp_port *port, unsigned int id);
109+
107110
int nfp_net_refresh_eth_port(struct nfp_port *port);
108111
void nfp_net_refresh_port_table(struct nfp_port *port);
109112
int nfp_net_refresh_port_table_sync(struct nfp_pf *pf);

0 commit comments

Comments
 (0)