static int
 mlx5_ib_nic_rep_load(struct mlx5_core_dev *dev, struct mlx5_eswitch_rep *rep)
 {
+       struct mlx5_ib_dev *ibdev;
+
+       ibdev = mlx5_ib_rep_to_dev(rep);
+       if (!__mlx5_ib_add(ibdev, ibdev->profile))
+               return -EINVAL;
        return 0;
 }
 
 static void
 mlx5_ib_nic_rep_unload(struct mlx5_eswitch_rep *rep)
 {
-       rep->rep_if[REP_IB].priv = NULL;
+       struct mlx5_ib_dev *ibdev;
+
+       ibdev = mlx5_ib_rep_to_dev(rep);
+       __mlx5_ib_remove(ibdev, ibdev->profile, MLX5_IB_STAGE_MAX);
 }
 
 static int
        dev = mlx5_ib_rep_to_dev(rep);
        __mlx5_ib_remove(dev, dev->profile, MLX5_IB_STAGE_MAX);
        rep->rep_if[REP_IB].priv = NULL;
+       ib_dealloc_device(&dev->ib_dev);
 }
 
 static void *mlx5_ib_vport_get_proto_dev(struct mlx5_eswitch_rep *rep)
 
        cancel_delay_drop(dev);
 }
 
-static int mlx5_ib_stage_rep_reg_init(struct mlx5_ib_dev *dev)
-{
-       mlx5_ib_register_vport_reps(dev);
-
-       return 0;
-}
-
-static void mlx5_ib_stage_rep_reg_cleanup(struct mlx5_ib_dev *dev)
-{
-       mlx5_ib_unregister_vport_reps(dev);
-}
-
 static int mlx5_ib_stage_dev_notifier_init(struct mlx5_ib_dev *dev)
 {
        dev->mdev_events.notifier_call = mlx5_ib_event;
                if (profile->stage[stage].cleanup)
                        profile->stage[stage].cleanup(dev);
        }
-
-       ib_dealloc_device((struct ib_device *)dev);
 }
 
 void *__mlx5_ib_add(struct mlx5_ib_dev *dev,
        STAGE_CREATE(MLX5_IB_STAGE_POST_IB_REG_UMR,
                     mlx5_ib_stage_post_ib_reg_umr_init,
                     NULL),
-       STAGE_CREATE(MLX5_IB_STAGE_REP_REG,
-                    mlx5_ib_stage_rep_reg_init,
-                    mlx5_ib_stage_rep_reg_cleanup),
 };
 
 static void *mlx5_ib_add_slave_port(struct mlx5_core_dev *mdev)
        if (MLX5_ESWITCH_MANAGER(mdev) &&
            mlx5_ib_eswitch_mode(mdev->priv.eswitch) == SRIOV_OFFLOADS) {
                dev->rep = mlx5_ib_vport_rep(mdev->priv.eswitch, 0);
-
-               return __mlx5_ib_add(dev, &nic_rep_profile);
+               dev->profile = &nic_rep_profile;
+               mlx5_ib_register_vport_reps(dev);
+               return dev;
        }
 
        return __mlx5_ib_add(dev, &pf_profile);
        }
 
        dev = context;
-       __mlx5_ib_remove(dev, dev->profile, MLX5_IB_STAGE_MAX);
+       if (dev->profile == &nic_rep_profile)
+               mlx5_ib_unregister_vport_reps(dev);
+       else
+               __mlx5_ib_remove(dev, dev->profile, MLX5_IB_STAGE_MAX);
+
+       ib_dealloc_device((struct ib_device *)dev);
 }
 
 static struct mlx5_interface mlx5_ib_interface = {