[14/27] net/mlx5: fix indirect action validate

Message ID 20220923144334.27736-15-suanmingm@nvidia.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers
Series net/mlx5: HW steering PMD update |

Checks

Context Check Description
ci/checkpatch success coding style OK

Commit Message

Suanming Mou Sept. 23, 2022, 2:43 p.m. UTC
  For indirect actions, the action mask type indicates the indirect
action type. And action mask conf be NULL means the indirect action
will be provided by flow action conf.

This commit fixes the indirect action validate.

Fixes: 393e0eb555c0 ("net/mlx5: support DR action template API")

Signed-off-by: Suanming Mou <suanmingm@nvidia.com>
---
 drivers/net/mlx5/mlx5_flow_hw.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)
  

Patch

diff --git a/drivers/net/mlx5/mlx5_flow_hw.c b/drivers/net/mlx5/mlx5_flow_hw.c
index 6a1ed7e790..d828d49613 100644
--- a/drivers/net/mlx5/mlx5_flow_hw.c
+++ b/drivers/net/mlx5/mlx5_flow_hw.c
@@ -2726,7 +2726,8 @@  flow_hw_actions_validate(struct rte_eth_dev *dev,
 		const struct rte_flow_action *mask = &masks[i];
 
 		MLX5_ASSERT(i < MLX5_HW_MAX_ACTS);
-		if (action->type != mask->type)
+		if (action->type != RTE_FLOW_ACTION_TYPE_INDIRECT &&
+		    action->type != mask->type)
 			return rte_flow_error_set(error, ENOTSUP,
 						  RTE_FLOW_ERROR_TYPE_ACTION,
 						  action,
@@ -2824,22 +2825,25 @@  flow_hw_dr_actions_template_handle_shared(const struct rte_flow_action *mask,
 					  uint16_t *curr_off,
 					  struct rte_flow_actions_template *at)
 {
-	uint32_t act_idx;
 	uint32_t type;
 
-	if (!mask->conf) {
+	if (!mask) {
 		DRV_LOG(WARNING, "Unable to determine indirect action type "
 			"without a mask specified");
 		return -EINVAL;
 	}
-	act_idx = (uint32_t)(uintptr_t)mask->conf;
-	type = act_idx >> MLX5_INDIRECT_ACTION_TYPE_OFFSET;
+	type = mask->type;
 	switch (type) {
-	case MLX5_INDIRECT_ACTION_TYPE_RSS:
+	case RTE_FLOW_ACTION_TYPE_RSS:
 		at->actions_off[action_src] = *curr_off;
 		action_types[*curr_off] = MLX5DR_ACTION_TYP_TIR;
 		*curr_off = *curr_off + 1;
 		break;
+	case RTE_FLOW_ACTION_TYPE_COUNT:
+		at->actions_off[action_src] = *curr_off;
+		action_types[*curr_off] = MLX5DR_ACTION_TYP_CTR;
+		*curr_off = *curr_off + 1;
+		break;
 	default:
 		DRV_LOG(WARNING, "Unsupported shared action type: %d", type);
 		return -EINVAL;