[dpdk-dev] [PATCH] net/mlx5: fix modify header action position

Ori Kam orika at mellanox.com
Sun Apr 14 22:19:57 CEST 2019


According to RTE flow the action order should be the order that the
actions were given.
In the case of modify actions the position of the action was always
last.

This commit solves this issue by saving the position of the first modify
action, and then adds to this position the pointer to the modify action.

Fixes: 4bb14c83df95 ("net/mlx5: support modify header using Direct Verbs")
Cc: dekelp at mellanox.com
Cc: stable at dpdk.org

Signed-off-by: Ori Kam <orika at mellanox.com>
---
 drivers/net/mlx5/mlx5_flow_dv.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 3862b26..7b5eab7 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -3235,6 +3235,7 @@ struct field_modify_info modify_tcp[] = {
 	};
 	union flow_dv_attr flow_attr = { .attr = 0 };
 	struct mlx5_flow_dv_tag_resource tag_resource;
+	uint32_t modify_action_position = UINT32_MAX;
 
 	if (priority == MLX5_FLOW_PRIO_RSVD)
 		priority = priv->config.flow_prio - 1;
@@ -3419,6 +3420,8 @@ struct field_modify_info modify_tcp[] = {
 					RTE_FLOW_ACTION_TYPE_SET_MAC_SRC ?
 					MLX5_FLOW_ACTION_SET_MAC_SRC :
 					MLX5_FLOW_ACTION_SET_MAC_DST;
+			if (modify_action_position == UINT32_MAX)
+				modify_action_position = actions_n++;
 			break;
 		case RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC:
 		case RTE_FLOW_ACTION_TYPE_SET_IPV4_DST:
@@ -3429,6 +3432,8 @@ struct field_modify_info modify_tcp[] = {
 					RTE_FLOW_ACTION_TYPE_SET_IPV4_SRC ?
 					MLX5_FLOW_ACTION_SET_IPV4_SRC :
 					MLX5_FLOW_ACTION_SET_IPV4_DST;
+			if (modify_action_position == UINT32_MAX)
+				modify_action_position = actions_n++;
 			break;
 		case RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC:
 		case RTE_FLOW_ACTION_TYPE_SET_IPV6_DST:
@@ -3439,6 +3444,8 @@ struct field_modify_info modify_tcp[] = {
 					RTE_FLOW_ACTION_TYPE_SET_IPV6_SRC ?
 					MLX5_FLOW_ACTION_SET_IPV6_SRC :
 					MLX5_FLOW_ACTION_SET_IPV6_DST;
+			if (modify_action_position == UINT32_MAX)
+				modify_action_position = actions_n++;
 			break;
 		case RTE_FLOW_ACTION_TYPE_SET_TP_SRC:
 		case RTE_FLOW_ACTION_TYPE_SET_TP_DST:
@@ -3450,6 +3457,8 @@ struct field_modify_info modify_tcp[] = {
 					RTE_FLOW_ACTION_TYPE_SET_TP_SRC ?
 					MLX5_FLOW_ACTION_SET_TP_SRC :
 					MLX5_FLOW_ACTION_SET_TP_DST;
+			if (modify_action_position == UINT32_MAX)
+				modify_action_position = actions_n++;
 			break;
 		case RTE_FLOW_ACTION_TYPE_DEC_TTL:
 			if (flow_dv_convert_action_modify_dec_ttl(&res, items,
@@ -3457,6 +3466,8 @@ struct field_modify_info modify_tcp[] = {
 								  error))
 				return -rte_errno;
 			action_flags |= MLX5_FLOW_ACTION_DEC_TTL;
+			if (modify_action_position == UINT32_MAX)
+				modify_action_position = actions_n++;
 			break;
 		case RTE_FLOW_ACTION_TYPE_SET_TTL:
 			if (flow_dv_convert_action_modify_ttl(&res, actions,
@@ -3464,6 +3475,8 @@ struct field_modify_info modify_tcp[] = {
 							     error))
 				return -rte_errno;
 			action_flags |= MLX5_FLOW_ACTION_SET_TTL;
+			if (modify_action_position == UINT32_MAX)
+				modify_action_position = actions_n++;
 			break;
 		case RTE_FLOW_ACTION_TYPE_END:
 			actions_end = true;
@@ -3474,7 +3487,7 @@ struct field_modify_info modify_tcp[] = {
 								 dev_flow,
 								 error))
 					return -rte_errno;
-				dev_flow->dv.actions[actions_n++] =
+				dev_flow->dv.actions[modify_action_position] =
 					dev_flow->dv.modify_hdr->verbs_action;
 			}
 			break;
-- 
1.8.3.1



More information about the dev mailing list