RDMA/mlx5: Use the uapi disablement APIs instead of code
Rely on UAPI_DEF_IS_OBJ_SUPPORTED instead of manipulating the contents of the driver's definition list. Signed-off-by: Jason Gunthorpe <jgg@mellanox.com> Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
This commit is contained in:
parent
6829c1c2b3
commit
36e235c882
|
@ -1323,9 +1323,23 @@ DECLARE_UVERBS_NAMED_OBJECT(MLX5_IB_OBJECT_DEVX_UMEM,
|
|||
&UVERBS_METHOD(MLX5_IB_METHOD_DEVX_UMEM_REG),
|
||||
&UVERBS_METHOD(MLX5_IB_METHOD_DEVX_UMEM_DEREG));
|
||||
|
||||
static bool devx_is_supported(struct ib_device *device)
|
||||
{
|
||||
struct mlx5_ib_dev *dev = to_mdev(device);
|
||||
|
||||
return !dev->rep && MLX5_CAP_GEN_64(dev->mdev, general_obj_types) &
|
||||
MLX5_GENERAL_OBJ_TYPES_CAP_UCTX;
|
||||
}
|
||||
|
||||
const struct uapi_definition mlx5_ib_devx_defs[] = {
|
||||
UAPI_DEF_CHAIN_OBJ_TREE_NAMED(MLX5_IB_OBJECT_DEVX),
|
||||
UAPI_DEF_CHAIN_OBJ_TREE_NAMED(MLX5_IB_OBJECT_DEVX_OBJ),
|
||||
UAPI_DEF_CHAIN_OBJ_TREE_NAMED(MLX5_IB_OBJECT_DEVX_UMEM),
|
||||
UAPI_DEF_CHAIN_OBJ_TREE_NAMED(
|
||||
MLX5_IB_OBJECT_DEVX,
|
||||
UAPI_DEF_IS_OBJ_SUPPORTED(devx_is_supported)),
|
||||
UAPI_DEF_CHAIN_OBJ_TREE_NAMED(
|
||||
MLX5_IB_OBJECT_DEVX_OBJ,
|
||||
UAPI_DEF_IS_OBJ_SUPPORTED(devx_is_supported)),
|
||||
UAPI_DEF_CHAIN_OBJ_TREE_NAMED(
|
||||
MLX5_IB_OBJECT_DEVX_UMEM,
|
||||
UAPI_DEF_IS_OBJ_SUPPORTED(devx_is_supported)),
|
||||
{},
|
||||
};
|
||||
|
|
|
@ -5552,6 +5552,7 @@ ADD_UVERBS_ATTRIBUTES_SIMPLE(
|
|||
|
||||
static const struct uapi_definition mlx5_ib_defs[] = {
|
||||
#if IS_ENABLED(CONFIG_INFINIBAND_USER_ACCESS)
|
||||
UAPI_DEF_CHAIN(mlx5_ib_devx_defs),
|
||||
UAPI_DEF_CHAIN(mlx5_ib_flow_defs),
|
||||
#endif
|
||||
|
||||
|
@ -5561,27 +5562,6 @@ static const struct uapi_definition mlx5_ib_defs[] = {
|
|||
{}
|
||||
};
|
||||
|
||||
static int populate_specs_root(struct mlx5_ib_dev *dev)
|
||||
{
|
||||
struct uapi_definition *defs = dev->driver_defs;
|
||||
|
||||
#if IS_ENABLED(CONFIG_INFINIBAND_USER_ACCESS)
|
||||
if (MLX5_CAP_GEN_64(dev->mdev, general_obj_types) &
|
||||
MLX5_GENERAL_OBJ_TYPES_CAP_UCTX)
|
||||
*defs++ = (struct uapi_definition)UAPI_DEF_CHAIN(
|
||||
mlx5_ib_devx_defs);
|
||||
#endif
|
||||
|
||||
*defs++ = (struct uapi_definition)UAPI_DEF_CHAIN(mlx5_ib_defs);
|
||||
*defs++ = (struct uapi_definition){};
|
||||
WARN_ON(defs - dev->driver_defs >= ARRAY_SIZE(dev->driver_defs));
|
||||
|
||||
if (IS_ENABLED(CONFIG_INFINIBAND_USER_ACCESS))
|
||||
dev->ib_dev.driver_def = dev->driver_defs;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int mlx5_ib_read_counters(struct ib_counters *counters,
|
||||
struct ib_counters_read_attr *read_attr,
|
||||
struct uverbs_attr_bundle *attrs)
|
||||
|
@ -5898,6 +5878,9 @@ int mlx5_ib_stage_caps_init(struct mlx5_ib_dev *dev)
|
|||
dev->ib_dev.destroy_counters = mlx5_ib_destroy_counters;
|
||||
dev->ib_dev.read_counters = mlx5_ib_read_counters;
|
||||
|
||||
if (IS_ENABLED(CONFIG_INFINIBAND_USER_ACCESS))
|
||||
dev->ib_dev.driver_def = mlx5_ib_defs;
|
||||
|
||||
err = init_node_data(dev);
|
||||
if (err)
|
||||
return err;
|
||||
|
@ -6110,11 +6093,6 @@ void mlx5_ib_stage_bfrag_cleanup(struct mlx5_ib_dev *dev)
|
|||
mlx5_free_bfreg(dev->mdev, &dev->bfreg);
|
||||
}
|
||||
|
||||
static int mlx5_ib_stage_populate_specs(struct mlx5_ib_dev *dev)
|
||||
{
|
||||
return populate_specs_root(dev);
|
||||
}
|
||||
|
||||
int mlx5_ib_stage_ib_reg_init(struct mlx5_ib_dev *dev)
|
||||
{
|
||||
const char *name;
|
||||
|
@ -6249,9 +6227,6 @@ static const struct mlx5_ib_profile pf_profile = {
|
|||
STAGE_CREATE(MLX5_IB_STAGE_PRE_IB_REG_UMR,
|
||||
NULL,
|
||||
mlx5_ib_stage_pre_ib_reg_umr_cleanup),
|
||||
STAGE_CREATE(MLX5_IB_STAGE_SPECS,
|
||||
mlx5_ib_stage_populate_specs,
|
||||
NULL),
|
||||
STAGE_CREATE(MLX5_IB_STAGE_IB_REG,
|
||||
mlx5_ib_stage_ib_reg_init,
|
||||
mlx5_ib_stage_ib_reg_cleanup),
|
||||
|
@ -6294,9 +6269,6 @@ static const struct mlx5_ib_profile nic_rep_profile = {
|
|||
STAGE_CREATE(MLX5_IB_STAGE_PRE_IB_REG_UMR,
|
||||
NULL,
|
||||
mlx5_ib_stage_pre_ib_reg_umr_cleanup),
|
||||
STAGE_CREATE(MLX5_IB_STAGE_SPECS,
|
||||
mlx5_ib_stage_populate_specs,
|
||||
NULL),
|
||||
STAGE_CREATE(MLX5_IB_STAGE_IB_REG,
|
||||
mlx5_ib_stage_ib_reg_init,
|
||||
mlx5_ib_stage_ib_reg_cleanup),
|
||||
|
|
|
@ -781,7 +781,6 @@ enum mlx5_ib_stages {
|
|||
MLX5_IB_STAGE_UAR,
|
||||
MLX5_IB_STAGE_BFREG,
|
||||
MLX5_IB_STAGE_PRE_IB_REG_UMR,
|
||||
MLX5_IB_STAGE_SPECS,
|
||||
MLX5_IB_STAGE_IB_REG,
|
||||
MLX5_IB_STAGE_POST_IB_REG_UMR,
|
||||
MLX5_IB_STAGE_DELAY_DROP,
|
||||
|
@ -891,7 +890,6 @@ struct mlx5_ib_pf_eq {
|
|||
|
||||
struct mlx5_ib_dev {
|
||||
struct ib_device ib_dev;
|
||||
struct uapi_definition driver_defs[7];
|
||||
struct mlx5_core_dev *mdev;
|
||||
struct mlx5_roce roce[MLX5_MAX_PORTS];
|
||||
int num_ports;
|
||||
|
|
Loading…
Reference in New Issue