net/mlx5: fix the implicit tag insertion in sample flow
PATCH 1/1 net/mlx5: fix the implicit tag insertion in sample flow
The flow with sample action was split into two sub-flows, and the implicit tag action with unique id was added in the prefix sub-flow, the suffix sub-flow used the tag item to match with that unique id, and the implicit set tag action was inserted next to the sample action.
While there's either PUSH VLAN action or ENCAP action preceding the sample action, implicit set tag action was added after PUSH VLAN or ENCAP actions, causing flow creation failure due to rdma-core does not support this action order.
This patch ensures the implicit set tag action is inserted before either PUSH VLAN or encap action (if any) in the prefix sub-flow.
--- drivers/net/mlx5/mlx5_flow.c | 63 ++++++++++++++++++++++++++++++++++-- 1 file changed, 61 insertions(+), 2 deletions(-)
drivers/net/mlx5/mlx5_flow.c +61 -2
@@ -5831,8 +5831,9 @@ flow_sample_split_prep(struct rte_eth_dev *dev,struct mlx5_rte_flow_item_tag *tag_mask;struct rte_flow_action_jump *jump_action;uint32_t tag_id =0 ; -int index;int append_index =0 ; +int set_tag_idx =-1 ; +int index;int ret;if (sample_action_pos <0 )
@@ -5841,6 +5842,52 @@ flow_sample_split_prep(struct rte_eth_dev *dev,NULL ,"invalid position of sample " "action in list");/* Prepare the actions for prefix and suffix flow. */ +if (add_tag) { +/* Update the new added tag action index preceding +* the PUSH_VLAN or ENCAP action. +*/ +const struct rte_flow_action_raw_encap *raw_encap; +const struct rte_flow_action *action = actions; +int encap_idx; +int action_idx =0 ; +int raw_decap_idx =-1 ; +int push_vlan_idx =-1 ; +for (; action->type !=RTE_FLOW_ACTION_TYPE_END ; action++) { +switch (action->type) { +case RTE_FLOW_ACTION_TYPE_RAW_DECAP : + raw_decap_idx = action_idx; +break ; +case RTE_FLOW_ACTION_TYPE_RAW_ENCAP : + raw_encap = action->conf; +if (raw_encap->size > +MLX5_ENCAPSULATION_DECISION_SIZE ) { + encap_idx = raw_decap_idx !=-1 ? + raw_decap_idx : action_idx; +if (encap_idx < sample_action_pos && + push_vlan_idx ==-1 ) + set_tag_idx = encap_idx; + } +break ; +case RTE_FLOW_ACTION_TYPE_VXLAN_ENCAP : +case RTE_FLOW_ACTION_TYPE_NVGRE_ENCAP : + encap_idx = action_idx; +if (encap_idx < sample_action_pos && + push_vlan_idx ==-1 ) + set_tag_idx = encap_idx; +break ; +case RTE_FLOW_ACTION_TYPE_OF_PUSH_VLAN : +case RTE_FLOW_ACTION_TYPE_OF_SET_VLAN_VID : + push_vlan_idx = action_idx; +if (push_vlan_idx < sample_action_pos) + set_tag_idx = action_idx; +break ; +default : +break ; + } + action_idx++; + } + } +/* Prepare the actions for prefix and suffix flow. */ if (qrss_action_pos >=0 && qrss_action_pos < sample_action_pos) { index = qrss_action_pos;/* Put the preceding the Queue/RSS action into prefix flow. */
@@ -5857,6 +5904,14 @@ flow_sample_split_prep(struct rte_eth_dev *dev,memcpy (actions_sfx, actions + qrss_action_pos,sizeof (struct rte_flow_action )); actions_sfx++; + }else if (add_tag && set_tag_idx >=0 ) { +if (set_tag_idx >0 ) +memcpy (actions_pre, actions, +sizeof (struct rte_flow_action ) * set_tag_idx); +memcpy (actions_pre + set_tag_idx +1 , actions + set_tag_idx, +sizeof (struct rte_flow_action ) * + (sample_action_pos - set_tag_idx)); + index = sample_action_pos; }else { index = sample_action_pos;if (index !=0 )
@@ -5898,13 +5953,17 @@ flow_sample_split_prep(struct rte_eth_dev *dev,RTE_FLOW_ITEM_TYPE_END , };/* Prepare the tag action in prefix subflow. */ - actions_pre[index++] = + set_tag_idx = (set_tag_idx ==-1 ) ? index : set_tag_idx; + actions_pre[set_tag_idx] = (struct rte_flow_action ){ .type = (enum rte_flow_action_type )MLX5_RTE_FLOW_ACTION_TYPE_TAG , .conf = set_tag, }; +/* Update next sample position due to add one tag action */ + index +=1 ; } +/* Copy the sample action into prefix flow. */ memcpy (actions_pre + index, actions + sample_action_pos,sizeof (struct rte_flow_action )); index +=1 ;
Signature · 1 line
2.18.1
Hi,
Quoted 23 lines
-----Original Message-----
From: Jiawei(Jonny) Wang <[email protected]>
Sent: Thursday, March 10, 2022 6:00 AM
To: Slava Ovsiienko <[email protected]>; Matan Azrad <[email protected]>; Ori Kam <[email protected]>
Cc: [email protected]; Raslan Darawsheh <[email protected]>; [email protected]
Subject: [PATCH] net/mlx5: fix the implicit tag insertion in sample flowThe flow with sample action was split into two sub-flows, and the implicit tag action with unique id was added in the prefix sub-flow, the suffix sub-flow used the tag item to match with that unique id, and the implicit set tag action was inserted next to the sample action.
While there's either PUSH VLAN action or ENCAP action preceding the sample action, implicit set tag action was added after PUSH VLAN or ENCAP actions, causing flow creation failure due to rdma-core does not support this action order.
This patch ensures the implicit set tag action is inserted before either PUSH VLAN or encap action (if any) in the prefix sub-flow.
Quoted 6 lines
Fixes 6a951567c159 ("net/mlx5: support E-Switch mirroring and jump in oneflow")
Cc: [email protected]Signed-off-by Jiawei Wang <[email protected]>
Patch applied to next-net-mlx,
Kindest regards,
Raslan Darawsheh