[PATCH v3 5/8] net/mlx5: store expected type on indirect action
Dariusz Sosnowski
dsosnowski at nvidia.com
Wed Jun 26 20:14:25 CEST 2024
When template table is created, list of unmasked actions is recorded for
future flow rule insertions.
This patch expands entries for RTE_FLOW_ACTION_TYPE_INDIRECT actions in
this list with information about expected indirect action type.
This will be used in follow up commits which add flow rule operation
validation. Specifically, this will be used to verify if indirect action
provided by the user references an action of a correct type.
Signed-off-by: Dariusz Sosnowski <dsosnowski at nvidia.com>
Acked-by: Ori Kam <orika at nvidia.com>
---
drivers/net/mlx5/mlx5_flow.h | 4 ++++
drivers/net/mlx5/mlx5_flow_hw.c | 22 ++++++++++++++++++++--
2 files changed, 24 insertions(+), 2 deletions(-)
diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h
index 8e99e76e5d..33847e2272 100644
--- a/drivers/net/mlx5/mlx5_flow.h
+++ b/drivers/net/mlx5/mlx5_flow.h
@@ -1442,6 +1442,10 @@ struct mlx5_action_construct_data {
uint16_t action_dst; /* mlx5dr_rule_action dst offset. */
indirect_list_callback_t indirect_list_cb;
union {
+ struct {
+ /* Expected type of indirection action. */
+ enum rte_flow_action_type expected_type;
+ } indirect;
struct {
/* encap data len. */
uint16_t len;
diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c
index 1ccaf844b8..f337f76450 100644
--- a/drivers/net/mlx5/mlx5_flow_hw.c
+++ b/drivers/net/mlx5/mlx5_flow_hw.c
@@ -997,6 +997,24 @@ __flow_hw_act_data_general_append(struct mlx5_priv *priv,
return 0;
}
+static __rte_always_inline int
+__flow_hw_act_data_indirect_append(struct mlx5_priv *priv,
+ struct mlx5_hw_actions *acts,
+ enum rte_flow_action_type type,
+ enum rte_flow_action_type mask_type,
+ uint16_t action_src,
+ uint16_t action_dst)
+{
+ struct mlx5_action_construct_data *act_data;
+
+ act_data = __flow_hw_act_data_alloc(priv, type, action_src, action_dst);
+ if (!act_data)
+ return -1;
+ act_data->indirect.expected_type = mask_type;
+ LIST_INSERT_HEAD(&acts->act_list, act_data, next);
+ return 0;
+}
+
static __rte_always_inline int
flow_hw_act_data_indirect_list_append(struct mlx5_priv *priv,
struct mlx5_hw_actions *acts,
@@ -2486,9 +2504,9 @@ __flow_hw_translate_actions_template(struct rte_eth_dev *dev,
if (flow_hw_shared_action_translate
(dev, actions, acts, src_pos, dr_pos))
goto err;
- } else if (__flow_hw_act_data_general_append
+ } else if (__flow_hw_act_data_indirect_append
(priv, acts, RTE_FLOW_ACTION_TYPE_INDIRECT,
- src_pos, dr_pos)){
+ masks->type, src_pos, dr_pos)){
goto err;
}
break;
--
2.39.2
More information about the dev
mailing list