@@ -219,6 +219,8 @@ has_sym_args = [
'ibv_import_device' ],
[ 'HAVE_MLX5DV_DR_ACTION_CREATE_DEST_ROOT_TABLE', 'infiniband/mlx5dv.h',
'mlx5dv_dr_action_create_dest_root_table' ],
+ [ 'HAVE_MLX5DV_CREATE_STEERING_ANCHOR', 'infiniband/mlx5dv.h',
+ 'mlx5dv_create_steering_anchor'],
]
if libmtcr_ul_found
has_sym_args += [
@@ -1548,6 +1548,32 @@ mlx5_glue_dr_create_flow_action_send_to_kernel(void *tbl, uint16_t priority)
#endif
}
+static struct mlx5dv_steering_anchor *
+mlx5_glue_dv_create_steering_anchor(struct ibv_context *context,
+ struct mlx5dv_steering_anchor_attr *attr)
+{
+#ifdef HAVE_MLX5DV_CREATE_STEERING_ANCHOR
+ return mlx5dv_create_steering_anchor(context, attr);
+#else
+ (void)context;
+ (void)attr;
+ errno = ENOTSUP;
+ return NULL;
+#endif
+}
+
+static int
+mlx5_glue_dv_destroy_steering_anchor(struct mlx5dv_steering_anchor *sa)
+{
+#ifdef HAVE_MLX5DV_CREATE_STEERING_ANCHOR
+ return mlx5dv_destroy_steering_anchor(sa);
+#else
+ (void)sa;
+ errno = ENOTSUP;
+ return -ENOTSUP;
+#endif
+}
+
__rte_cache_aligned
const struct mlx5_glue *mlx5_glue = &(const struct mlx5_glue) {
.version = MLX5_GLUE_VERSION,
@@ -1685,4 +1711,6 @@ const struct mlx5_glue *mlx5_glue = &(const struct mlx5_glue) {
.dv_free_pp = mlx5_glue_dv_free_pp,
.dr_create_flow_action_send_to_kernel =
mlx5_glue_dr_create_flow_action_send_to_kernel,
+ .create_steering_anchor = mlx5_glue_dv_create_steering_anchor,
+ .destroy_steering_anchor = mlx5_glue_dv_destroy_steering_anchor,
};
@@ -148,6 +148,18 @@ struct mlx5dv_var { uint32_t page_id; uint32_t length; off_t mmap_off;
#define IBV_ACCESS_RELAXED_ORDERING 0
#endif
+#ifndef HAVE_MLX5DV_CREATE_STEERING_ANCHOR
+struct mlx5dv_steering_anchor_attr {
+ uint32_t ft_type;
+ uint16_t priority;
+ uint64_t comp_mask;
+};
+
+struct mlx5dv_steering_anchor {
+ uint32_t id;
+};
+#endif
+
struct mlx5_glue {
const char *version;
int (*fork_init)(void);
@@ -392,6 +404,10 @@ struct mlx5_glue {
uint32_t offset, uint32_t flags, uint8_t return_reg_c);
void *(*dr_create_flow_action_send_to_kernel)(void *tbl,
uint16_t priority);
+ struct mlx5dv_steering_anchor *(*create_steering_anchor)
+ (struct ibv_context *context,
+ struct mlx5dv_steering_anchor_attr *attr);
+ int (*destroy_steering_anchor)(struct mlx5dv_steering_anchor *sa);
};
extern const struct mlx5_glue *mlx5_glue;
@@ -45,6 +45,7 @@ enum mlx5dr_action_type {
MLX5DR_ACTION_TYP_PUSH_VLAN,
MLX5DR_ACTION_TYP_ASO_METER,
MLX5DR_ACTION_TYP_ASO_CT,
+ MLX5DR_ACTION_TYP_DEST_ROOT_TABLE,
MLX5DR_ACTION_TYP_MAX,
};
@@ -565,6 +566,24 @@ mlx5dr_action_create_pop_vlan(struct mlx5dr_context *ctx, uint32_t flags);
struct mlx5dr_action *
mlx5dr_action_create_push_vlan(struct mlx5dr_context *ctx, uint32_t flags);
+/* Create dest root table, this action will jump to root table according
+ * the given priority.
+ * @param[in] ctx
+ * The context in which the new action will be created.
+ * @param[in] tbl
+ * The root table to jump to.
+ * @param[in] priority
+ * The priority of matcher in the root table to jump to.
+ * @param[in] flags
+ * Action creation flags. (enum mlx5dr_action_flags).
+ * @return pointer to mlx5dr_action on success NULL otherwise.
+ */
+struct mlx5dr_action *
+mlx5dr_action_create_dest_root_table(struct mlx5dr_context *ctx,
+ struct mlx5dr_table *tbl,
+ uint16_t priority,
+ uint32_t flags);
+
/* Destroy direct rule action.
*
* @param[in] action
@@ -33,7 +33,8 @@ static const uint32_t action_order_arr[MLX5DR_TABLE_TYPE_MAX][MLX5DR_ACTION_TYP_
BIT(MLX5DR_ACTION_TYP_FT) |
BIT(MLX5DR_ACTION_TYP_MISS) |
BIT(MLX5DR_ACTION_TYP_TIR) |
- BIT(MLX5DR_ACTION_TYP_DROP),
+ BIT(MLX5DR_ACTION_TYP_DROP) |
+ BIT(MLX5DR_ACTION_TYP_DEST_ROOT_TABLE),
BIT(MLX5DR_ACTION_TYP_LAST),
},
[MLX5DR_TABLE_TYPE_NIC_TX] = {
@@ -49,7 +50,8 @@ static const uint32_t action_order_arr[MLX5DR_TABLE_TYPE_MAX][MLX5DR_ACTION_TYP_
BIT(MLX5DR_ACTION_TYP_L2_TO_TNL_L3),
BIT(MLX5DR_ACTION_TYP_FT) |
BIT(MLX5DR_ACTION_TYP_MISS) |
- BIT(MLX5DR_ACTION_TYP_DROP),
+ BIT(MLX5DR_ACTION_TYP_DROP) |
+ BIT(MLX5DR_ACTION_TYP_DEST_ROOT_TABLE),
BIT(MLX5DR_ACTION_TYP_LAST),
},
[MLX5DR_TABLE_TYPE_FDB] = {
@@ -68,7 +70,8 @@ static const uint32_t action_order_arr[MLX5DR_TABLE_TYPE_MAX][MLX5DR_ACTION_TYP_
BIT(MLX5DR_ACTION_TYP_FT) |
BIT(MLX5DR_ACTION_TYP_MISS) |
BIT(MLX5DR_ACTION_TYP_VPORT) |
- BIT(MLX5DR_ACTION_TYP_DROP),
+ BIT(MLX5DR_ACTION_TYP_DROP) |
+ BIT(MLX5DR_ACTION_TYP_DEST_ROOT_TABLE),
BIT(MLX5DR_ACTION_TYP_LAST),
},
};
@@ -521,6 +524,11 @@ static void mlx5dr_action_fill_stc_attr(struct mlx5dr_action *action,
attr->action_offset = MLX5DR_ACTION_OFFSET_HIT;
attr->dest_table_id = obj->id;
break;
+ case MLX5DR_ACTION_TYP_DEST_ROOT_TABLE:
+ attr->action_type = MLX5_IFC_STC_ACTION_TYPE_JUMP_TO_FT;
+ attr->action_offset = MLX5DR_ACTION_OFFSET_HIT;
+ attr->dest_table_id = action->root_tbl.sa->id;
+ break;
case MLX5DR_ACTION_TYP_TNL_L2_TO_L2:
attr->action_type = MLX5_IFC_STC_ACTION_TYPE_HEADER_REMOVE;
attr->action_offset = MLX5DR_ACTION_OFFSET_DW5;
@@ -1172,12 +1180,12 @@ mlx5dr_action_conv_reformat_to_verbs(uint32_t action_type,
static int
mlx5dr_action_conv_flags_to_ft_type(uint32_t flags, enum mlx5dv_flow_table_type *ft_type)
{
- if (flags & MLX5DR_ACTION_FLAG_ROOT_RX) {
+ if (flags & (MLX5DR_ACTION_FLAG_ROOT_RX | MLX5DR_ACTION_FLAG_HWS_RX)) {
*ft_type = MLX5DV_FLOW_TABLE_TYPE_NIC_RX;
- } else if (flags & MLX5DR_ACTION_FLAG_ROOT_TX) {
+ } else if (flags & (MLX5DR_ACTION_FLAG_ROOT_TX | MLX5DR_ACTION_FLAG_HWS_TX)) {
*ft_type = MLX5DV_FLOW_TABLE_TYPE_NIC_TX;
#ifdef HAVE_MLX5DV_FLOW_MATCHER_FT_TYPE
- } else if (flags & MLX5DR_ACTION_FLAG_ROOT_FDB) {
+ } else if (flags & (MLX5DR_ACTION_FLAG_ROOT_FDB | MLX5DR_ACTION_FLAG_HWS_FDB)) {
*ft_type = MLX5DV_FLOW_TABLE_TYPE_FDB;
#endif
} else {
@@ -1633,6 +1641,65 @@ mlx5dr_action_create_modify_header(struct mlx5dr_context *ctx,
return NULL;
}
+struct mlx5dr_action *
+mlx5dr_action_create_dest_root_table(struct mlx5dr_context *ctx,
+ struct mlx5dr_table *tbl,
+ uint16_t priority,
+ uint32_t flags)
+{
+ struct mlx5dv_steering_anchor_attr attr = {0};
+ struct mlx5dv_steering_anchor *sa;
+ struct mlx5dr_action *action;
+ int ret;
+
+ if (mlx5dr_action_is_root_flags(flags)) {
+ DR_LOG(ERR, "Action flags must be only non root (HWS)");
+ rte_errno = ENOTSUP;
+ return NULL;
+ }
+
+ if (!mlx5dr_table_is_root(tbl)) {
+ DR_LOG(ERR, "Non root table cannot be set as destination");
+ rte_errno = ENOTSUP;
+ return NULL;
+ }
+
+ if (mlx5dr_context_shared_gvmi_used(ctx)) {
+ DR_LOG(ERR, "Cannot use this action in shared GVMI context");
+ rte_errno = ENOTSUP;
+ return NULL;
+ }
+
+ if (mlx5dr_action_conv_flags_to_ft_type(flags, &attr.ft_type))
+ return NULL;
+
+ attr.priority = priority;
+
+ sa = mlx5_glue->create_steering_anchor(ctx->ibv_ctx, &attr);
+ if (!sa) {
+ DR_LOG(ERR, "Creation of steering anchor failed");
+ return NULL;
+ }
+
+ action = mlx5dr_action_create_generic(ctx, flags, MLX5DR_ACTION_TYP_DEST_ROOT_TABLE);
+ if (!action)
+ goto free_steering_anchor;
+
+ action->root_tbl.sa = sa;
+
+ ret = mlx5dr_action_create_stcs(action, NULL);
+ if (ret)
+ goto free_action;
+
+ return action;
+
+free_action:
+ simple_free(action);
+free_steering_anchor:
+ mlx5_glue->destroy_steering_anchor(sa);
+ return NULL;
+}
+
static void mlx5dr_action_destroy_hws(struct mlx5dr_action *action)
{
switch (action->type) {
@@ -1652,6 +1719,10 @@ static void mlx5dr_action_destroy_hws(struct mlx5dr_action *action)
case MLX5DR_ACTION_TYP_PUSH_VLAN:
mlx5dr_action_destroy_stcs(action);
break;
+ case MLX5DR_ACTION_TYP_DEST_ROOT_TABLE:
+ mlx5dr_action_destroy_stcs(action);
+ mlx5_glue->destroy_steering_anchor(action->root_tbl.sa);
+ break;
case MLX5DR_ACTION_TYP_POP_VLAN:
mlx5dr_action_destroy_stcs(action);
mlx5dr_action_put_shared_stc(action, MLX5DR_CONTEXT_SHARED_STC_POP);
@@ -2132,6 +2203,7 @@ int mlx5dr_action_template_process(struct mlx5dr_action_template *at)
case MLX5DR_ACTION_TYP_DROP:
case MLX5DR_ACTION_TYP_TIR:
case MLX5DR_ACTION_TYP_FT:
+ case MLX5DR_ACTION_TYP_DEST_ROOT_TABLE:
case MLX5DR_ACTION_TYP_VPORT:
case MLX5DR_ACTION_TYP_MISS:
/* Hit action */
@@ -141,6 +141,9 @@ struct mlx5dr_action {
struct {
struct mlx5dr_devx_obj *devx_obj;
} alias;
+ struct {
+ struct mlx5dv_steering_anchor *sa;
+ } root_tbl;
};
};
@@ -22,6 +22,7 @@ const char *mlx5dr_debug_action_type_str[] = {
[MLX5DR_ACTION_TYP_PUSH_VLAN] = "PUSH_VLAN",
[MLX5DR_ACTION_TYP_ASO_METER] = "ASO_METER",
[MLX5DR_ACTION_TYP_ASO_CT] = "ASO_CT",
+ [MLX5DR_ACTION_TYP_DEST_ROOT_TABLE] = "DEST_ROOT_TABLE",
};
static_assert(ARRAY_SIZE(mlx5dr_debug_action_type_str) == MLX5DR_ACTION_TYP_MAX,