]> git.baikalelectronics.ru Git - kernel.git/commitdiff
netdevsim: dev: Initialize FIB module after debugfs
authorIdo Schimmel <idosch@nvidia.com>
Sun, 7 Feb 2021 08:22:55 +0000 (10:22 +0200)
committerDavid S. Miller <davem@davemloft.net>
Tue, 9 Feb 2021 00:47:03 +0000 (16:47 -0800)
Initialize the dummy FIB offload module after debugfs, so that the FIB
module could create its own directory there.

Signed-off-by: Amit Cohen <amcohen@nvidia.com>
Signed-off-by: Ido Schimmel <idosch@nvidia.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/netdevsim/dev.c

index 816af1f55e2cd512cfb27b23386b48d99140a1bc..dbeb29fa16e815c9aeb87e3df11447725d1d8dfb 100644 (file)
@@ -1012,23 +1012,25 @@ static int nsim_dev_reload_create(struct nsim_dev *nsim_dev,
        nsim_dev->fw_update_status = true;
        nsim_dev->fw_update_overwrite_mask = 0;
 
-       nsim_dev->fib_data = nsim_fib_create(devlink, extack);
-       if (IS_ERR(nsim_dev->fib_data))
-               return PTR_ERR(nsim_dev->fib_data);
-
        nsim_devlink_param_load_driverinit_values(devlink);
 
        err = nsim_dev_dummy_region_init(nsim_dev, devlink);
        if (err)
-               goto err_fib_destroy;
+               return err;
 
        err = nsim_dev_traps_init(devlink);
        if (err)
                goto err_dummy_region_exit;
 
+       nsim_dev->fib_data = nsim_fib_create(devlink, extack);
+       if (IS_ERR(nsim_dev->fib_data)) {
+               err = PTR_ERR(nsim_dev->fib_data);
+               goto err_traps_exit;
+       }
+
        err = nsim_dev_health_init(nsim_dev, devlink);
        if (err)
-               goto err_traps_exit;
+               goto err_fib_destroy;
 
        err = nsim_dev_port_add_all(nsim_dev, nsim_bus_dev->port_count);
        if (err)
@@ -1043,12 +1045,12 @@ static int nsim_dev_reload_create(struct nsim_dev *nsim_dev,
 
 err_health_exit:
        nsim_dev_health_exit(nsim_dev);
+err_fib_destroy:
+       nsim_fib_destroy(devlink, nsim_dev->fib_data);
 err_traps_exit:
        nsim_dev_traps_exit(devlink);
 err_dummy_region_exit:
        nsim_dev_dummy_region_exit(nsim_dev);
-err_fib_destroy:
-       nsim_fib_destroy(devlink, nsim_dev->fib_data);
        return err;
 }
 
@@ -1080,15 +1082,9 @@ int nsim_dev_probe(struct nsim_bus_dev *nsim_bus_dev)
        if (err)
                goto err_devlink_free;
 
-       nsim_dev->fib_data = nsim_fib_create(devlink, NULL);
-       if (IS_ERR(nsim_dev->fib_data)) {
-               err = PTR_ERR(nsim_dev->fib_data);
-               goto err_resources_unregister;
-       }
-
        err = devlink_register(devlink, &nsim_bus_dev->dev);
        if (err)
-               goto err_fib_destroy;
+               goto err_resources_unregister;
 
        err = devlink_params_register(devlink, nsim_devlink_params,
                                      ARRAY_SIZE(nsim_devlink_params));
@@ -1108,9 +1104,15 @@ int nsim_dev_probe(struct nsim_bus_dev *nsim_bus_dev)
        if (err)
                goto err_traps_exit;
 
+       nsim_dev->fib_data = nsim_fib_create(devlink, NULL);
+       if (IS_ERR(nsim_dev->fib_data)) {
+               err = PTR_ERR(nsim_dev->fib_data);
+               goto err_debugfs_exit;
+       }
+
        err = nsim_dev_health_init(nsim_dev, devlink);
        if (err)
-               goto err_debugfs_exit;
+               goto err_fib_destroy;
 
        err = nsim_bpf_dev_init(nsim_dev);
        if (err)
@@ -1128,6 +1130,8 @@ err_bpf_dev_exit:
        nsim_bpf_dev_exit(nsim_dev);
 err_health_exit:
        nsim_dev_health_exit(nsim_dev);
+err_fib_destroy:
+       nsim_fib_destroy(devlink, nsim_dev->fib_data);
 err_debugfs_exit:
        nsim_dev_debugfs_exit(nsim_dev);
 err_traps_exit:
@@ -1139,8 +1143,6 @@ err_params_unregister:
                                  ARRAY_SIZE(nsim_devlink_params));
 err_dl_unregister:
        devlink_unregister(devlink);
-err_fib_destroy:
-       nsim_fib_destroy(devlink, nsim_dev->fib_data);
 err_resources_unregister:
        devlink_resources_unregister(devlink, NULL);
 err_devlink_free:
@@ -1157,10 +1159,10 @@ static void nsim_dev_reload_destroy(struct nsim_dev *nsim_dev)
        debugfs_remove(nsim_dev->take_snapshot);
        nsim_dev_port_del_all(nsim_dev);
        nsim_dev_health_exit(nsim_dev);
+       nsim_fib_destroy(devlink, nsim_dev->fib_data);
        nsim_dev_traps_exit(devlink);
        nsim_dev_dummy_region_exit(nsim_dev);
        mutex_destroy(&nsim_dev->port_list_lock);
-       nsim_fib_destroy(devlink, nsim_dev->fib_data);
 }
 
 void nsim_dev_remove(struct nsim_bus_dev *nsim_bus_dev)