From: Hamdan Igbaria <hamd...@nvidia.com> Extend mlx5dr_action_template_create function params to include flags parameter.
Signed-off-by: Hamdan Igbaria <hamd...@nvidia.com> Acked-by: Matan Azrad <ma...@nvidia.com> --- drivers/net/mlx5/hws/mlx5dr.h | 10 +++++++++- drivers/net/mlx5/hws/mlx5dr_action.c | 11 ++++++++++- drivers/net/mlx5/hws/mlx5dr_action.h | 1 + drivers/net/mlx5/hws/mlx5dr_matcher.c | 16 ++++++++++------ drivers/net/mlx5/mlx5_flow_hw.c | 2 +- 5 files changed, 31 insertions(+), 9 deletions(-) diff --git a/drivers/net/mlx5/hws/mlx5dr.h b/drivers/net/mlx5/hws/mlx5dr.h index 49f72118ba..3647e25cf2 100644 --- a/drivers/net/mlx5/hws/mlx5dr.h +++ b/drivers/net/mlx5/hws/mlx5dr.h @@ -84,6 +84,11 @@ enum mlx5dr_match_template_flags { MLX5DR_MATCH_TEMPLATE_FLAG_RELAXED_MATCH = 1, }; +enum mlx5dr_action_template_flags { + /* Allow relaxed actions order. */ + MLX5DR_ACTION_TEMPLATE_FLAG_RELAXED_ORDER = 1 << 0, +}; + enum mlx5dr_send_queue_actions { /* Start executing all pending queued rules */ MLX5DR_SEND_QUEUE_ACTION_DRAIN_ASYNC = 1 << 0, @@ -383,10 +388,13 @@ int mlx5dr_match_template_destroy(struct mlx5dr_match_template *mt); * An array of actions based on the order of actions which will be provided * with rule_actions to mlx5dr_rule_create. The last action is marked * using MLX5DR_ACTION_TYP_LAST. + * @param[in] flags + * Template creation flags * @return pointer to mlx5dr_action_template on success NULL otherwise */ struct mlx5dr_action_template * -mlx5dr_action_template_create(const enum mlx5dr_action_type action_type[]); +mlx5dr_action_template_create(const enum mlx5dr_action_type action_type[], + uint32_t flags); /* Destroy action template. * diff --git a/drivers/net/mlx5/hws/mlx5dr_action.c b/drivers/net/mlx5/hws/mlx5dr_action.c index 862ee3e332..370886907f 100644 --- a/drivers/net/mlx5/hws/mlx5dr_action.c +++ b/drivers/net/mlx5/hws/mlx5dr_action.c @@ -3385,12 +3385,19 @@ int mlx5dr_action_template_process(struct mlx5dr_action_template *at) } struct mlx5dr_action_template * -mlx5dr_action_template_create(const enum mlx5dr_action_type action_type[]) +mlx5dr_action_template_create(const enum mlx5dr_action_type action_type[], + uint32_t flags) { struct mlx5dr_action_template *at; uint8_t num_actions = 0; int i; + if (flags > MLX5DR_ACTION_TEMPLATE_FLAG_RELAXED_ORDER) { + DR_LOG(ERR, "Unsupported action template flag provided"); + rte_errno = EINVAL; + return NULL; + } + at = simple_calloc(1, sizeof(*at)); if (!at) { DR_LOG(ERR, "Failed to allocate action template"); @@ -3398,6 +3405,8 @@ mlx5dr_action_template_create(const enum mlx5dr_action_type action_type[]) return NULL; } + at->flags = flags; + while (action_type[num_actions++] != MLX5DR_ACTION_TYP_LAST) ; diff --git a/drivers/net/mlx5/hws/mlx5dr_action.h b/drivers/net/mlx5/hws/mlx5dr_action.h index fad35a845b..a8d9720c42 100644 --- a/drivers/net/mlx5/hws/mlx5dr_action.h +++ b/drivers/net/mlx5/hws/mlx5dr_action.h @@ -119,6 +119,7 @@ struct mlx5dr_action_template { uint8_t num_of_action_stes; uint8_t num_actions; uint8_t only_term; + uint32_t flags; }; struct mlx5dr_action { diff --git a/drivers/net/mlx5/hws/mlx5dr_matcher.c b/drivers/net/mlx5/hws/mlx5dr_matcher.c index 0d5c462734..402242308d 100644 --- a/drivers/net/mlx5/hws/mlx5dr_matcher.c +++ b/drivers/net/mlx5/hws/mlx5dr_matcher.c @@ -686,12 +686,16 @@ static int mlx5dr_matcher_check_and_process_at(struct mlx5dr_matcher *matcher, bool valid; int ret; - /* Check if action combinabtion is valid */ - valid = mlx5dr_action_check_combo(at->action_type_arr, matcher->tbl->type); - if (!valid) { - DR_LOG(ERR, "Invalid combination in action template"); - rte_errno = EINVAL; - return rte_errno; + if (!(at->flags & MLX5DR_ACTION_TEMPLATE_FLAG_RELAXED_ORDER)) { + /* Check if actions combinabtion is valid, + * in the case of not relaxed actions order. + */ + valid = mlx5dr_action_check_combo(at->action_type_arr, matcher->tbl->type); + if (!valid) { + DR_LOG(ERR, "Invalid combination in action template"); + rte_errno = EINVAL; + return rte_errno; + } } /* Process action template to setters */ diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c index 3bb3a9a178..9d3dad65d4 100644 --- a/drivers/net/mlx5/mlx5_flow_hw.c +++ b/drivers/net/mlx5/mlx5_flow_hw.c @@ -6202,7 +6202,7 @@ flow_hw_dr_actions_template_create(struct rte_eth_dev *dev, at->recom_off = recom_off; action_types[recom_off] = recom_type; } - dr_template = mlx5dr_action_template_create(action_types); + dr_template = mlx5dr_action_template_create(action_types, 0); if (dr_template) { at->dr_actions_num = curr_off; } else { -- 2.39.3