Skip to content

Commit cb80fb1

Browse files
yishaihjgunthorpe
authored andcommitted
IB/mlx5: Enable driver uapi commands for flow steering
Expose the mlx5 flow steering parsing trees, exposing the functionality to user space. Signed-off-by: Yishai Hadas <[email protected]> Signed-off-by: Leon Romanovsky <[email protected]> Signed-off-by: Jason Gunthorpe <[email protected]>
1 parent 6346f0b commit cb80fb1

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

drivers/infiniband/hw/mlx5/flow.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,3 +242,13 @@ DECLARE_UVERBS_NAMED_OBJECT(MLX5_IB_OBJECT_FLOW_MATCHER,
242242

243243
DECLARE_UVERBS_OBJECT_TREE(flow_objects,
244244
&UVERBS_OBJECT(MLX5_IB_OBJECT_FLOW_MATCHER));
245+
246+
int mlx5_ib_get_flow_trees(const struct uverbs_object_tree_def **root)
247+
{
248+
int i = 0;
249+
250+
root[i++] = &flow_objects;
251+
root[i++] = &mlx5_ib_fs;
252+
253+
return i;
254+
}

drivers/infiniband/hw/mlx5/main.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5535,7 +5535,7 @@ ADD_UVERBS_ATTRIBUTES_SIMPLE(
55355535
UVERBS_ATTR_TYPE(u64),
55365536
UA_MANDATORY));
55375537

5538-
#define NUM_TREES 3
5538+
#define NUM_TREES 5
55395539
static int populate_specs_root(struct mlx5_ib_dev *dev)
55405540
{
55415541
const struct uverbs_object_tree_def *default_root[NUM_TREES + 1] = {
@@ -5555,6 +5555,8 @@ static int populate_specs_root(struct mlx5_ib_dev *dev)
55555555
!WARN_ON(num_trees >= ARRAY_SIZE(default_root)))
55565556
default_root[num_trees++] = mlx5_ib_get_devx_tree();
55575557

5558+
num_trees += mlx5_ib_get_flow_trees(default_root + num_trees);
5559+
55585560
dev->ib_dev.driver_specs_root =
55595561
uverbs_alloc_spec_tree(num_trees, default_root);
55605562

drivers/infiniband/hw/mlx5/mlx5_ib.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1236,6 +1236,7 @@ struct mlx5_ib_flow_handler *mlx5_ib_raw_fs_rule_add(
12361236
struct mlx5_ib_dev *dev, struct mlx5_ib_flow_matcher *fs_matcher,
12371237
void *cmd_in, int inlen, int dest_id, int dest_type);
12381238
bool mlx5_ib_devx_is_flow_dest(void *obj, int *dest_id, int *dest_type);
1239+
int mlx5_ib_get_flow_trees(const struct uverbs_object_tree_def **root);
12391240
#else
12401241
static inline int
12411242
mlx5_ib_devx_create(struct mlx5_ib_dev *dev,
@@ -1244,17 +1245,16 @@ static inline void mlx5_ib_devx_destroy(struct mlx5_ib_dev *dev,
12441245
struct mlx5_ib_ucontext *context) {}
12451246
static inline const struct uverbs_object_tree_def *
12461247
mlx5_ib_get_devx_tree(void) { return NULL; }
1247-
static inline struct mlx5_ib_flow_handler *mlx5_ib_raw_fs_rule_add(
1248-
struct mlx5_ib_dev *dev, struct mlx5_ib_flow_matcher *fs_matcher,
1249-
void *cmd_in, int inlen, int dest_id, int dest_type)
1250-
{
1251-
return ERR_PTR(-EOPNOTSUPP);
1252-
}
12531248
static inline bool mlx5_ib_devx_is_flow_dest(void *obj, int *dest_id,
12541249
int *dest_type)
12551250
{
12561251
return false;
12571252
}
1253+
static inline int
1254+
mlx5_ib_get_flow_trees(const struct uverbs_object_tree_def **root)
1255+
{
1256+
return 0;
1257+
}
12581258
#endif
12591259
static inline void init_query_mad(struct ib_smp *mad)
12601260
{

0 commit comments

Comments
 (0)