Commit 81773ce5 authored by Leon Romanovsky's avatar Leon Romanovsky

RDMA/mlx5: Use stages for callback to setup and release DEVX

Reuse existing infrastructure to initialize and release DEVX uid.
The DevX interface is intended for user space access, so it is supposed
to be initialized before ib_register_device(). Also it isn't supported
in switchdev mode and don't need to initialize it in that mode.

Fixes: 76dc5a84 ("IB/mlx5: Manage device uid for DEVX white list commands")
Reviewed-by: default avatarMark Bloch <markb@mellanox.com>
Signed-off-by: default avatarLeon Romanovsky <leonro@mellanox.com>
parent c48d386b
...@@ -6237,6 +6237,22 @@ static void mlx5_ib_stage_dev_notifier_cleanup(struct mlx5_ib_dev *dev) ...@@ -6237,6 +6237,22 @@ static void mlx5_ib_stage_dev_notifier_cleanup(struct mlx5_ib_dev *dev)
mlx5_notifier_unregister(dev->mdev, &dev->mdev_events); mlx5_notifier_unregister(dev->mdev, &dev->mdev_events);
} }
static int mlx5_ib_stage_devx_init(struct mlx5_ib_dev *dev)
{
int uid;
uid = mlx5_ib_devx_create(dev);
if (uid > 0)
dev->devx_whitelist_uid = uid;
return 0;
}
static void mlx5_ib_stage_devx_cleanup(struct mlx5_ib_dev *dev)
{
if (dev->devx_whitelist_uid)
mlx5_ib_devx_destroy(dev, dev->devx_whitelist_uid);
}
void __mlx5_ib_remove(struct mlx5_ib_dev *dev, void __mlx5_ib_remove(struct mlx5_ib_dev *dev,
const struct mlx5_ib_profile *profile, const struct mlx5_ib_profile *profile,
int stage) int stage)
...@@ -6248,8 +6264,6 @@ void __mlx5_ib_remove(struct mlx5_ib_dev *dev, ...@@ -6248,8 +6264,6 @@ void __mlx5_ib_remove(struct mlx5_ib_dev *dev,
profile->stage[stage].cleanup(dev); profile->stage[stage].cleanup(dev);
} }
if (dev->devx_whitelist_uid)
mlx5_ib_devx_destroy(dev, dev->devx_whitelist_uid);
ib_dealloc_device((struct ib_device *)dev); ib_dealloc_device((struct ib_device *)dev);
} }
...@@ -6258,7 +6272,6 @@ void *__mlx5_ib_add(struct mlx5_ib_dev *dev, ...@@ -6258,7 +6272,6 @@ void *__mlx5_ib_add(struct mlx5_ib_dev *dev,
{ {
int err; int err;
int i; int i;
int uid;
for (i = 0; i < MLX5_IB_STAGE_MAX; i++) { for (i = 0; i < MLX5_IB_STAGE_MAX; i++) {
if (profile->stage[i].init) { if (profile->stage[i].init) {
...@@ -6268,10 +6281,6 @@ void *__mlx5_ib_add(struct mlx5_ib_dev *dev, ...@@ -6268,10 +6281,6 @@ void *__mlx5_ib_add(struct mlx5_ib_dev *dev,
} }
} }
uid = mlx5_ib_devx_create(dev);
if (uid > 0)
dev->devx_whitelist_uid = uid;
dev->profile = profile; dev->profile = profile;
dev->ib_active = true; dev->ib_active = true;
...@@ -6326,6 +6335,9 @@ static const struct mlx5_ib_profile pf_profile = { ...@@ -6326,6 +6335,9 @@ static const struct mlx5_ib_profile pf_profile = {
STAGE_CREATE(MLX5_IB_STAGE_SPECS, STAGE_CREATE(MLX5_IB_STAGE_SPECS,
mlx5_ib_stage_populate_specs, mlx5_ib_stage_populate_specs,
NULL), NULL),
STAGE_CREATE(MLX5_IB_STAGE_WHITELIST_UID,
mlx5_ib_stage_devx_init,
mlx5_ib_stage_devx_cleanup),
STAGE_CREATE(MLX5_IB_STAGE_IB_REG, STAGE_CREATE(MLX5_IB_STAGE_IB_REG,
mlx5_ib_stage_ib_reg_init, mlx5_ib_stage_ib_reg_init,
mlx5_ib_stage_ib_reg_cleanup), mlx5_ib_stage_ib_reg_cleanup),
......
...@@ -783,6 +783,7 @@ enum mlx5_ib_stages { ...@@ -783,6 +783,7 @@ enum mlx5_ib_stages {
MLX5_IB_STAGE_BFREG, MLX5_IB_STAGE_BFREG,
MLX5_IB_STAGE_PRE_IB_REG_UMR, MLX5_IB_STAGE_PRE_IB_REG_UMR,
MLX5_IB_STAGE_SPECS, MLX5_IB_STAGE_SPECS,
MLX5_IB_STAGE_WHITELIST_UID,
MLX5_IB_STAGE_IB_REG, MLX5_IB_STAGE_IB_REG,
MLX5_IB_STAGE_POST_IB_REG_UMR, MLX5_IB_STAGE_POST_IB_REG_UMR,
MLX5_IB_STAGE_DELAY_DROP, MLX5_IB_STAGE_DELAY_DROP,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment