nfp: move devlink port type set after netdev registration

Similar to other driver, move the port type set after netdev registration
is done. Along with that, clear the type before unregistration.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Jiri Pirko 2019-03-24 11:14:34 +01:00 committed by David S. Miller
parent 45b861120e
commit faaccbe6eb
3 changed files with 19 additions and 3 deletions

View File

@ -362,7 +362,6 @@ int nfp_devlink_port_register(struct nfp_app *app, struct nfp_port *port)
if (ret)
return ret;
devlink_port_type_eth_set(&port->dl_port, port->netdev);
devlink_port_attrs_set(&port->dl_port, DEVLINK_PORT_FLAVOUR_PHYSICAL,
eth_port.label_port, eth_port.is_split,
eth_port.label_subport);
@ -377,6 +376,16 @@ void nfp_devlink_port_unregister(struct nfp_port *port)
devlink_port_unregister(&port->dl_port);
}
void nfp_devlink_port_type_eth_set(struct nfp_port *port)
{
devlink_port_type_eth_set(&port->dl_port, port->netdev);
}
void nfp_devlink_port_type_clear(struct nfp_port *port)
{
devlink_port_type_clear(&port->dl_port);
}
struct devlink *nfp_devlink_get_devlink(struct net_device *netdev)
{
struct nfp_app *app;

View File

@ -160,6 +160,7 @@ nfp_net_pf_init_vnic(struct nfp_pf *pf, struct nfp_net *nn, unsigned int id)
err = nfp_devlink_port_register(pf->app, nn->port);
if (err)
goto err_dfs_clean;
nfp_devlink_port_type_eth_set(nn->port);
}
nfp_net_info(nn);
@ -173,8 +174,10 @@ nfp_net_pf_init_vnic(struct nfp_pf *pf, struct nfp_net *nn, unsigned int id)
return 0;
err_devlink_port_clean:
if (nn->port)
if (nn->port) {
nfp_devlink_port_type_clear(nn->port);
nfp_devlink_port_unregister(nn->port);
}
err_dfs_clean:
nfp_net_debugfs_dir_clean(&nn->debugfs_dir);
nfp_net_clean(nn);
@ -220,8 +223,10 @@ static void nfp_net_pf_clean_vnic(struct nfp_pf *pf, struct nfp_net *nn)
{
if (nfp_net_is_data_vnic(nn))
nfp_app_vnic_clean(pf->app, nn);
if (nn->port)
if (nn->port) {
nfp_devlink_port_type_clear(nn->port);
nfp_devlink_port_unregister(nn->port);
}
nfp_net_debugfs_dir_clean(&nn->debugfs_dir);
nfp_net_clean(nn);
}

View File

@ -131,6 +131,8 @@ int nfp_net_refresh_port_table_sync(struct nfp_pf *pf);
int nfp_devlink_port_register(struct nfp_app *app, struct nfp_port *port);
void nfp_devlink_port_unregister(struct nfp_port *port);
void nfp_devlink_port_type_eth_set(struct nfp_port *port);
void nfp_devlink_port_type_clear(struct nfp_port *port);
/**
* Mac stats (0x0000 - 0x0200)