diff options
author | Jason Gunthorpe <jgg@mellanox.com> | 2018-11-12 23:59:50 +0300 |
---|---|---|
committer | Jason Gunthorpe <jgg@mellanox.com> | 2018-11-22 21:57:32 +0300 |
commit | 0cbf432db405289216747a8d31d74bab2452337c (patch) | |
tree | ff3075888879f177c90e0a52bb31c1c5455938c0 /drivers/infiniband/hw/mlx5/main.c | |
parent | dfb631a187b9b04c066df60e28adf05334112ca6 (diff) | |
download | linux-0cbf432db405289216747a8d31d74bab2452337c.tar.xz |
RDMA/uverbs: Use a linear list to describe the compiled-in uapi
The 'tree' data structure is very hard to build at compile time, and this
makes it very limited. The new radix tree based compiler can handle a more
complex input language that does not require the compiler to perfectly
group everything into a neat tree structure.
Instead use a simple list to describe to input, where the list elements
can be of various different 'opcodes' instructing the radix compiler what
to do. Start out with opcodes chaining to other definition lists and
chaining to the existing 'tree' definition.
Replace the very top level of the 'object tree' with this list type and
get rid of struct uverbs_object_tree_def and DECLARE_UVERBS_OBJECT_TREE.
Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
Signed-off-by: Leon Romanovsky <leonro@mellanox.com>
Diffstat (limited to 'drivers/infiniband/hw/mlx5/main.c')
-rw-r--r-- | drivers/infiniband/hw/mlx5/main.c | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/drivers/infiniband/hw/mlx5/main.c b/drivers/infiniband/hw/mlx5/main.c index f12e045981fc..30a35a8ae0bb 100644 --- a/drivers/infiniband/hw/mlx5/main.c +++ b/drivers/infiniband/hw/mlx5/main.c @@ -5550,23 +5550,34 @@ ADD_UVERBS_ATTRIBUTES_SIMPLE( UVERBS_ATTR_FLAGS_IN(MLX5_IB_ATTR_CREATE_FLOW_ACTION_FLAGS, enum mlx5_ib_uapi_flow_action_flags)); +static const struct uapi_definition mlx5_ib_defs[] = { +#if IS_ENABLED(CONFIG_INFINIBAND_USER_ACCESS) + UAPI_DEF_CHAIN(mlx5_ib_flow_defs), +#endif + + UAPI_DEF_CHAIN_OBJ_TREE(UVERBS_OBJECT_FLOW_ACTION, + &mlx5_ib_flow_action), + UAPI_DEF_CHAIN_OBJ_TREE(UVERBS_OBJECT_DM, &mlx5_ib_dm), + {} +}; + static int populate_specs_root(struct mlx5_ib_dev *dev) { - const struct uverbs_object_tree_def **trees = dev->driver_trees; - size_t num_trees = 0; - - trees[num_trees++] = &mlx5_ib_flow_action; - trees[num_trees++] = &mlx5_ib_dm; + 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) - trees[num_trees++] = mlx5_ib_get_devx_tree(); + *defs++ = (struct uapi_definition)UAPI_DEF_CHAIN( + mlx5_ib_devx_defs); +#endif - num_trees += mlx5_ib_get_flow_trees(trees + num_trees); + *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)); - WARN_ON(num_trees >= ARRAY_SIZE(dev->driver_trees)); - trees[num_trees] = NULL; - dev->ib_dev.driver_specs = trees; + if (IS_ENABLED(CONFIG_INFINIBAND_USER_ACCESS)) + dev->ib_dev.driver_def = dev->driver_defs; return 0; } |