Skip to content

Commit a146235

Browse files
Leon Romanovskyjgunthorpe
authored andcommitted
RDMA/mlx5: Fail early if user tries to create flows on IB representors
IB representors don't support creation of RAW ethernet QP flows. Disable them by reusing existing RDMA/core support macros. We do it for both creation and matcher because latter is not usable if no flow creation is available. Signed-off-by: Leon Romanovsky <leonro@mellanox.com> Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
1 parent f94e02d commit a146235

File tree

2 files changed

+17
-8
lines changed

2 files changed

+17
-8
lines changed

drivers/infiniband/hw/mlx5/flow.c

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,6 @@ static int UVERBS_HANDLER(MLX5_IB_METHOD_CREATE_FLOW)(
134134
return -EINVAL;
135135
flow_act.action |= MLX5_FLOW_CONTEXT_ACTION_COUNT;
136136
}
137-
if (dev->rep)
138-
return -ENOTSUPP;
139137

140138
if (dest_type == MLX5_FLOW_DESTINATION_TYPE_TIR &&
141139
fs_matcher->ns_type == MLX5_FLOW_NAMESPACE_EGRESS)
@@ -623,9 +621,19 @@ DECLARE_UVERBS_NAMED_OBJECT(MLX5_IB_OBJECT_FLOW_MATCHER,
623621
&UVERBS_METHOD(MLX5_IB_METHOD_FLOW_MATCHER_CREATE),
624622
&UVERBS_METHOD(MLX5_IB_METHOD_FLOW_MATCHER_DESTROY));
625623

624+
static bool flow_is_supported(struct ib_device *device)
625+
{
626+
return !to_mdev(device)->rep;
627+
}
628+
626629
const struct uapi_definition mlx5_ib_flow_defs[] = {
627-
UAPI_DEF_CHAIN_OBJ_TREE_NAMED(MLX5_IB_OBJECT_FLOW_MATCHER),
628-
UAPI_DEF_CHAIN_OBJ_TREE(UVERBS_OBJECT_FLOW, &mlx5_ib_fs),
630+
UAPI_DEF_CHAIN_OBJ_TREE_NAMED(
631+
MLX5_IB_OBJECT_FLOW_MATCHER,
632+
UAPI_DEF_IS_OBJ_SUPPORTED(flow_is_supported)),
633+
UAPI_DEF_CHAIN_OBJ_TREE(
634+
UVERBS_OBJECT_FLOW,
635+
&mlx5_ib_fs,
636+
UAPI_DEF_IS_OBJ_SUPPORTED(flow_is_supported)),
629637
UAPI_DEF_CHAIN_OBJ_TREE(UVERBS_OBJECT_FLOW_ACTION,
630638
&mlx5_ib_flow_actions),
631639
{},

include/rdma/uverbs_ioctl.h

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -454,15 +454,16 @@ struct uapi_definition {
454454
}
455455

456456
/* Temporary until the tree base description is replaced */
457-
#define UAPI_DEF_CHAIN_OBJ_TREE(_object_enum, _object_ptr) \
457+
#define UAPI_DEF_CHAIN_OBJ_TREE(_object_enum, _object_ptr, ...) \
458458
{ \
459459
.kind = UAPI_DEF_CHAIN_OBJ_TREE, \
460460
.object_start = { .object_id = _object_enum }, \
461461
.chain_obj_tree = _object_ptr, \
462-
}
463-
#define UAPI_DEF_CHAIN_OBJ_TREE_NAMED(_object_enum, ...) \
464-
UAPI_DEF_CHAIN_OBJ_TREE(_object_enum, &UVERBS_OBJECT(_object_enum)), \
462+
}, \
465463
##__VA_ARGS__
464+
#define UAPI_DEF_CHAIN_OBJ_TREE_NAMED(_object_enum, ...) \
465+
UAPI_DEF_CHAIN_OBJ_TREE(_object_enum, &UVERBS_OBJECT(_object_enum), \
466+
##__VA_ARGS__)
466467

467468
/*
468469
* =======================================

0 commit comments

Comments
 (0)