[v2,07/10] net/mlx5/hws: extend action template creation API
Checks
Commit Message
From: Hamdan Igbaria <hamdani@nvidia.com>
Extend mlx5dr_action_template_create function params
to include flags parameter.
Signed-off-by: Hamdan Igbaria <hamdani@nvidia.com>
Acked-by: Matan Azrad <matan@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(-)
@@ -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.
*
@@ -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)
;
@@ -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 {
@@ -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 */
@@ -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 {