@@ -11,6 +11,7 @@ libmlx5.so.1 ibverbs-providers #MINVER#
MLX5_1.3@MLX5_1.3 16
MLX5_1.4@MLX5_1.4 17
MLX5_1.5@MLX5_1.5 18
+ MLX5_1.6@MLX5_1.6 20
mlx5dv_init_obj@MLX5_1.0 13
mlx5dv_init_obj@MLX5_1.2 15
mlx5dv_query_device@MLX5_1.0 13
@@ -20,3 +21,5 @@ libmlx5.so.1 ibverbs-providers #MINVER#
mlx5dv_create_wq@MLX5_1.3 16
mlx5dv_get_clock_info@MLX5_1.4 17
mlx5dv_create_flow_action_esp@MLX5_1.5 18
+ mlx5dv_create_flow_matcher@MLX5_1.6 20
+ mlx5dv_destroy_flow_matcher@MLX5_1.6 20
@@ -11,7 +11,7 @@ if (MLX5_MW_DEBUG)
endif()
rdma_shared_provider(mlx5 libmlx5.map
- 1 1.5.${PACKAGE_VERSION}
+ 1 1.6.${PACKAGE_VERSION}
buf.c
cq.c
dbrec.c
@@ -33,3 +33,9 @@ MLX5_1.5 {
global:
mlx5dv_create_flow_action_esp;
} MLX5_1.4;
+
+MLX5_1.6 {
+ global:
+ mlx5dv_create_flow_matcher;
+ mlx5dv_destroy_flow_matcher;
+} MLX5_1.5;
@@ -557,6 +557,11 @@ struct mlx5_flow {
struct mlx5_counters *mcounters;
};
+struct mlx5dv_flow_matcher {
+ struct ibv_context *context;
+ uint32_t handle;
+};
+
static inline int mlx5_ilog2(int n)
{
int t;
@@ -194,6 +194,28 @@ struct mlx5dv_flow_action_esp {
uint32_t action_flags; /* Use enum mlx5dv_flow_action_flags */
};
+struct mlx5dv_flow_match_parameters {
+ size_t match_sz;
+ uint64_t match_buf[]; /* Device spec format */
+};
+
+struct mlx5dv_flow_matcher_attr {
+ enum ibv_flow_attr_type type;
+ uint32_t flags; /* From enum ibv_flow_flags */
+ uint16_t priority;
+ uint8_t match_criteria_enable; /* Device spec format */
+ struct mlx5dv_flow_match_parameters *match_mask;
+ uint64_t comp_mask;
+};
+
+struct mlx5dv_flow_matcher;
+
+struct mlx5dv_flow_matcher *
+mlx5dv_create_flow_matcher(struct ibv_context *context,
+ struct mlx5dv_flow_matcher_attr *matcher_attr);
+
+int mlx5dv_destroy_flow_matcher(struct mlx5dv_flow_matcher *matcher);
+
struct ibv_flow_action *mlx5dv_create_flow_action_esp(struct ibv_context *ctx,
struct ibv_flow_action_esp_attr *esp,
struct mlx5dv_flow_action_esp *mlx5_attr);
@@ -3542,3 +3542,72 @@ int mlx5_read_counters(struct ibv_counters *counters,
NULL);
}
+
+struct mlx5dv_flow_matcher *
+mlx5dv_create_flow_matcher(struct ibv_context *context,
+ struct mlx5dv_flow_matcher_attr *attr)
+{
+ DECLARE_COMMAND_BUFFER_LINK(cmd, MLX5_IB_OBJECT_FLOW_MATCHER,
+ MLX5_IB_METHOD_FLOW_MATCHER_CREATE,
+ 4,
+ NULL);
+ struct mlx5dv_flow_matcher *flow_matcher;
+ struct ib_uverbs_attr *handle;
+ int ret;
+
+ if (!check_comp_mask(attr->comp_mask, 0)) {
+ errno = EOPNOTSUPP;
+ return NULL;
+ }
+
+ flow_matcher = calloc(1, sizeof(*flow_matcher));
+ if (!flow_matcher) {
+ errno = ENOMEM;
+ return NULL;
+ }
+
+ if (attr->type != IBV_FLOW_ATTR_NORMAL) {
+ errno = EOPNOTSUPP;
+ goto err;
+ }
+
+ handle = fill_attr_out_obj(cmd, MLX5_IB_ATTR_FLOW_MATCHER_CREATE_HANDLE);
+ fill_attr_in(cmd, MLX5_IB_ATTR_FLOW_MATCHER_MATCH_MASK,
+ attr->match_mask->match_buf,
+ attr->match_mask->match_sz);
+ fill_attr_in(cmd, MLX5_IB_ATTR_FLOW_MATCHER_MATCH_CRITERIA,
+ &attr->match_criteria_enable, sizeof(attr->match_criteria_enable));
+ fill_attr_in_enum(cmd, MLX5_IB_ATTR_FLOW_MATCHER_FLOW_TYPE,
+ IBV_FLOW_ATTR_NORMAL, &attr->priority,
+ sizeof(attr->priority));
+
+ ret = execute_ioctl(context, cmd);
+ if (ret)
+ goto err;
+
+ flow_matcher->context = context;
+ flow_matcher->handle = read_attr_obj(MLX5_IB_ATTR_FLOW_MATCHER_CREATE_HANDLE, handle);
+
+ return flow_matcher;
+
+err:
+ free(flow_matcher);
+ return NULL;
+}
+
+int mlx5dv_destroy_flow_matcher(struct mlx5dv_flow_matcher *flow_matcher)
+{
+ DECLARE_COMMAND_BUFFER(cmd, MLX5_IB_OBJECT_FLOW_MATCHER,
+ MLX5_IB_METHOD_FLOW_MATCHER_DESTROY,
+ 1);
+ int ret;
+
+ fill_attr_in_obj(cmd, MLX5_IB_ATTR_FLOW_MATCHER_DESTROY_HANDLE, flow_matcher->handle);
+ ret = execute_ioctl(flow_matcher->context, cmd);
+
+ if (ret)
+ return ret;
+
+ free(flow_matcher);
+ return 0;
+}
Introduce mlx5 flow matcher object and its related DV APIs. The flow matcher object matches to the device specification and enables creating a flow object that supports the device options. Downstream patches from this series use the matcher object as part of flow creation. Signed-off-by: Yishai Hadas <yishaih@mellanox.com> --- debian/ibverbs-providers.symbols | 3 ++ providers/mlx5/CMakeLists.txt | 2 +- providers/mlx5/libmlx5.map | 6 ++++ providers/mlx5/mlx5.h | 5 +++ providers/mlx5/mlx5dv.h | 22 +++++++++++++ providers/mlx5/verbs.c | 69 ++++++++++++++++++++++++++++++++++++++++ 6 files changed, 106 insertions(+), 1 deletion(-)