When actions template is created in mlx5 PMD, some actions will be replaced with another or some actions will be added to implement required template semantics on NVIDIA NICs. For example:
- RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID actions is replaced with modify field action. - Modify field action is added for preserving metadata between FDB and NIC domains. - Modify field action is added when quota action is used to amend ASO syndrome. Types of actions and their order in flow rules based on some actions template must match the original, not modified one. This patch adds preserving of the original actions for actions template to allow for easier validation of ordering and types on fast path. Signed-off-by: Dariusz Sosnowski <dsosnow...@nvidia.com> Acked-by: Ori Kam <or...@nvidia.com> --- drivers/net/mlx5/mlx5_flow.h | 1 + drivers/net/mlx5/mlx5_flow_hw.c | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h index 5c2cc2b7c1..8e99e76e5d 100644 --- a/drivers/net/mlx5/mlx5_flow.h +++ b/drivers/net/mlx5/mlx5_flow.h @@ -1532,6 +1532,7 @@ struct rte_flow_actions_template { /* Template attributes. */ struct rte_flow_actions_template_attr attr; struct rte_flow_action *actions; /* Cached flow actions. */ + struct rte_flow_action *orig_actions; /* Original flow actions. */ struct rte_flow_action *masks; /* Cached action masks.*/ struct mlx5dr_action_template *tmpl; /* mlx5dr action template. */ uint64_t action_flags; /* Bit-map of all valid action in template. */ diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c index 1ad261d529..1ccaf844b8 100644 --- a/drivers/net/mlx5/mlx5_flow_hw.c +++ b/drivers/net/mlx5/mlx5_flow_hw.c @@ -7750,6 +7750,7 @@ __flow_hw_actions_template_create(struct rte_eth_dev *dev, { struct mlx5_priv *priv = dev->data->dev_private; int len, act_len, mask_len; + int orig_act_len; unsigned int act_num; unsigned int i; struct rte_flow_actions_template *at = NULL; @@ -7867,6 +7868,10 @@ __flow_hw_actions_template_create(struct rte_eth_dev *dev, len += RTE_ALIGN(mask_len, 16); len += RTE_ALIGN(act_num * sizeof(*at->dr_off), 16); len += RTE_ALIGN(act_num * sizeof(*at->src_off), 16); + orig_act_len = rte_flow_conv(RTE_FLOW_CONV_OP_ACTIONS, NULL, 0, actions, error); + if (orig_act_len <= 0) + return NULL; + len += RTE_ALIGN(orig_act_len, 16); at = mlx5_malloc(MLX5_MEM_ZERO, len + sizeof(*at), RTE_CACHE_LINE_SIZE, rte_socket_id()); if (!at) { @@ -7894,6 +7899,12 @@ __flow_hw_actions_template_create(struct rte_eth_dev *dev, at->src_off = RTE_PTR_ADD(at->dr_off, RTE_ALIGN(act_num * sizeof(*at->dr_off), 16)); memcpy(at->src_off, src_off, act_num * sizeof(at->src_off[0])); + at->orig_actions = RTE_PTR_ADD(at->src_off, + RTE_ALIGN(act_num * sizeof(*at->src_off), 16)); + orig_act_len = rte_flow_conv(RTE_FLOW_CONV_OP_ACTIONS, at->orig_actions, orig_act_len, + actions, error); + if (orig_act_len <= 0) + goto error; at->actions_num = act_num; for (i = 0; i < at->actions_num; ++i) at->dr_off[i] = UINT16_MAX; -- 2.39.2