]> git.proxmox.com Git - mirror_ubuntu-kernels.git/commitdiff
nfp: register devlink port before netdev
authorJiri Pirko <jiri@mellanox.com>
Thu, 28 Mar 2019 12:56:35 +0000 (13:56 +0100)
committerDavid S. Miller <davem@davemloft.net>
Thu, 28 Mar 2019 19:55:30 +0000 (12:55 -0700)
Change the init/fini flow and register devlink port instance before
netdev. Now it is needed for correct behavior of phys_port_name
generation, but in general it makes sense to register devlink port
first.

Signed-off-by: Jiri Pirko <jiri@mellanox.com>
Reviewed-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/netronome/nfp/nfp_net_main.c

index f35278062476a4a1c82f608d69460d5469072b48..986464d4a20697e997cc18d9a7fe6dcb75ded347 100644 (file)
@@ -150,37 +150,39 @@ nfp_net_pf_init_vnic(struct nfp_pf *pf, struct nfp_net *nn, unsigned int id)
 
        nn->id = id;
 
+       if (nn->port) {
+               err = nfp_devlink_port_register(pf->app, nn->port);
+               if (err)
+                       return err;
+       }
+
        err = nfp_net_init(nn);
        if (err)
-               return err;
+               goto err_devlink_port_clean;
 
        nfp_net_debugfs_vnic_add(nn, pf->ddir);
 
-       if (nn->port) {
-               err = nfp_devlink_port_register(pf->app, nn->port);
-               if (err)
-                       goto err_dfs_clean;
+       if (nn->port)
                nfp_devlink_port_type_eth_set(nn->port);
-       }
 
        nfp_net_info(nn);
 
        if (nfp_net_is_data_vnic(nn)) {
                err = nfp_app_vnic_init(pf->app, nn);
                if (err)
-                       goto err_devlink_port_clean;
+                       goto err_devlink_port_type_clean;
        }
 
        return 0;
 
-err_devlink_port_clean:
-       if (nn->port) {
+err_devlink_port_type_clean:
+       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);
+err_devlink_port_clean:
+       if (nn->port)
+               nfp_devlink_port_unregister(nn->port);
        return err;
 }
 
@@ -223,12 +225,12 @@ 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);
+       if (nn->port)
+               nfp_devlink_port_unregister(nn->port);
 }
 
 static int nfp_net_pf_alloc_irqs(struct nfp_pf *pf)