net/mlx5: fix some sample/mirror issues
cover net/mlx5: fix some sample/mirror issues
Some fixes for sample/mirror issues.
Jiawei Wang (2):
net/mlx5: fix flow source port checking in sample flow rule net/mlx5: fix mirror flow validation with ASO action
drivers/net/mlx5/mlx5_flow.c | 55 +++++++++++++--- drivers/net/mlx5/mlx5_flow.h | 19 ++++++ drivers/net/mlx5/mlx5_flow_dv.c | 110 ++++++++++++++++++++------------ 3 files changed, 133 insertions(+), 51 deletions(-)
Signature · 1 line
2.18.1
PATCH 1/2 net/mlx5: fix flow source port checking in sample flow rule
The metadata register C value was lost in FDB egress while doing the flow sampler on ConnectX-5. The FDB direction checking was decided by the source port in the flow creation. If there's additional port item was added in the flow match, then the actual source port was changed.
This patch adds the checking for the port id item:RTE_FLOW_ITEM_TYPE_PORT_ID, RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT, and RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR,
then updates FDB egress checking and the source vport metadata from the port item, also updates the PUSH VLAN, POP VLAN and flow sampler action validation.
--- drivers/net/mlx5/mlx5_flow.c | 55 ++++++++++++++++++++++------ drivers/net/mlx5/mlx5_flow.h | 19 ++++++++++ drivers/net/mlx5/mlx5_flow_dv.c | 63 +++++++++++++++++++++------------ 3 files changed, 104 insertions(+), 33 deletions(-)
drivers/net/mlx5/mlx5_flow.c +45 -10
@@ -5934,7 +5934,8 @@ flow_check_match_action(const struct rte_flow_action actions[], ratio = sample->ratio; sub_type = ((const struct rte_flow_action *) (sample->actions))->type; -if (ratio ==1 && attr->transfer) +if (ratio ==1 && attr->transfer && + sub_type !=RTE_FLOW_ACTION_TYPE_END ) fdb_mirror =1 ;break ;case RTE_FLOW_ACTION_TYPE_SET_MAC_SRC :
@@ -6106,9 +6107,11 @@ flow_sample_split_prep(struct rte_eth_dev *dev,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) +if (action_idx < sample_action_pos && + push_vlan_idx ==-1 ) { set_tag_idx = action_idx; + push_vlan_idx = action_idx; + }break ;default :break ;
@@ -6171,18 +6174,20 @@ flow_sample_split_prep(struct rte_eth_dev *dev, .data = tag_id, };/* Prepare the suffix subflow items. */ + tag_spec = (void *)(sfx_items +SAMPLE_SUFFIX_ITEM ); + tag_spec->data = tag_id; + tag_spec->id = set_tag->id; + tag_mask = tag_spec +1 ; + tag_mask->data =UINT32_MAX ;for (; items->type !=RTE_FLOW_ITEM_TYPE_END ; items++) {if (items->type ==RTE_FLOW_ITEM_TYPE_PORT_ID || - items->type ==RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR ) { + items->type ==RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR || + items->type ==RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT ) {memcpy (sfx_items, items,sizeof (*sfx_items)); sfx_items++; +break ; } } - tag_spec = (void *)(sfx_items +SAMPLE_SUFFIX_ITEM ); - tag_spec->data = tag_id; - tag_spec->id = set_tag->id; - tag_mask = tag_spec +1 ; - tag_mask->data =UINT32_MAX ; sfx_items[0 ] = (struct rte_flow_item ){ .type = (enum rte_flow_item_type )MLX5_RTE_FLOW_ITEM_TYPE_TAG ,
@@ -6757,6 +6762,8 @@ flow_create_split_sample(struct rte_eth_dev *dev,uint16_t jump_table =0 ;const uint32_t next_ft_step =1 ;int ret =0 ; +struct mlx5_priv *item_port_priv =NULL ; +const struct rte_flow_item *item;if (priv->sampler_en) actions_n = flow_check_match_action(actions, attr,
@@ -6776,8 +6783,36 @@ flow_create_split_sample(struct rte_eth_dev *dev,RTE_FLOW_ERROR_TYPE_ACTION ,NULL ,"no memory to split " "sample flow"); +for (item = items; item->type !=RTE_FLOW_ITEM_TYPE_END ; item++) { +if (item->type ==RTE_FLOW_ITEM_TYPE_PORT_ID ) { +const struct rte_flow_item_port_id *spec; + + spec = (const struct rte_flow_item_port_id *)item->spec; +if (spec) + item_port_priv = +mlx5_port_to_eswitch_info (spec->id, true); +break ; + }else if (item->type ==RTE_FLOW_ITEM_TYPE_REPRESENTED_PORT ) { +const struct rte_flow_item_ethdev *spec; + + spec = (const struct rte_flow_item_ethdev *)item->spec; +if (spec) + item_port_priv = +mlx5_port_to_eswitch_info (spec->port_id, true); +break ; + }else if (item->type ==RTE_FLOW_ITEM_TYPE_PORT_REPRESENTOR ) { +const struct rte_flow_item_ethdev *spec; + + spec = (const struct rte_flow_item_ethdev *)item->spec; +if (spec) + item_port_priv = +mlx5_port_to_eswitch_info (spec->port_id, true); +break ; + } + }/* The representor_id is UINT16_MAX for uplink. */ - fdb_tx = (attr->transfer && priv->representor_id !=UINT16_MAX ); + fdb_tx = (attr->transfer && +flow_source_vport_representor (priv, item_port_priv));/* * When reg_c_preserve is set, metadata registers Cx preserve * their value even through packet duplication.
drivers/net/mlx5/mlx5_flow.h +19 -0
@@ -2118,6 +2118,25 @@ rte_col_2_mlx5_col(enum rte_color rcol)return MLX5_FLOW_COLOR_UNDEFINED ; } +/** +* Indicates whether flow source vport is representor port. +* +* @param[in] priv +* Pointer to device private context structure. +* @param[in] act_priv +* Pointer to actual device private context structure if have. +* +* @return +* True when the flow source vport is representor port, false otherwise. +*/ +static inline bool +flow_source_vport_representor (struct mlx5_priv *priv,struct mlx5_priv *act_priv) +{ +MLX5_ASSERT (priv); +return (!act_priv ? (priv->representor_id !=UINT16_MAX ) : + (act_priv->representor_id !=UINT16_MAX )); +} +/* All types of Ethernet patterns used in control flow rules. */ enum mlx5_flow_ctrl_rx_eth_pattern_type {MLX5_FLOW_HW_CTRL_RX_ETH_PATTERN_ALL =0 ,
drivers/net/mlx5/mlx5_flow_dv.c +40 -23
181 lines not on this page · raw message
Signature · 1 line
2.18.1
PATCH 2/2 net/mlx5: fix mirror flow validation with ASO action
In reply to Jiawei WangWhile the ASO action(AGE, CT) with the sample action in the one E-switch mirror flow, due to hardware limitation, the ASO action after the sample action was not supported.
This patch adds the checking for this validation and reject the flows with aso action after sample.
--- drivers/net/mlx5/mlx5_flow_dv.c | 53 ++++++++++++++++++++------------- 1 file changed, 32 insertions(+), 21 deletions(-)
drivers/net/mlx5/mlx5_flow_dv.c +32 -21
@@ -5759,8 +5759,8 @@ flow_dv_modify_clone_free_cb(void *tool_ctx, struct mlx5_list_entry *entry)* Pointer to the RSS action in sample action list. * @param[out] count * Pointer to the COUNT action in sample action list. -* @param[out] fdb_mirror_limit -* Pointer to the FDB mirror limitation flag. +* @param[out] fdb_mirror +* Pointer to the FDB mirror flag. * @param root * Whether action is on root table. * @param[out] error
@@ -5778,9 +5778,8 @@ flow_dv_validate_action_sample(uint64_t *action_flags,const struct rte_flow_action_rss *rss, const struct rte_flow_action_rss **sample_rss, const struct rte_flow_action_count **count, - int *fdb_mirror_limit, + int *fdb_mirror, bool root, - struct mlx5_priv *act_priv, struct rte_flow_error *error) { struct mlx5_priv *priv = dev->data->dev_private;
@@ -5968,9 +5967,7 @@ flow_dv_validate_action_sample(uint64_t *action_flags,NULL ,"E-Switch must has a dest " "port for mirroring"); -if (!priv->sh->cdev->config.hca_attr.reg_c_preserve && -flow_source_vport_representor (priv, act_priv)) - *fdb_mirror_limit =1 ; + *fdb_mirror =1 ; }/* Continue validation for Xcap actions.*/ if ((sub_action_flags & MLX5_FLOW_XCAP_ACTIONS) &&
@@ -7056,7 +7053,7 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,uint16_t ether_type =0 ;int actions_n =0 ;uint8_t item_ipv6_proto =0 ; -int fdb_mirror_limit =0 ; +int fdb_mirror =0 ;int modify_after_mirror =0 ;const struct rte_flow_item *geneve_item =NULL ;const struct rte_flow_item *gre_item =NULL ;
@@ -7122,6 +7119,7 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,const struct rte_flow_action_age *non_shared_age =NULL ;const struct rte_flow_action_count *count =NULL ;struct mlx5_priv *act_priv =NULL ; +int aso_after_sample =0 ;if (items ==NULL )return -1 ;
@@ -7902,12 +7900,6 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, error);if (ret)return ret; -if ((action_flags &MLX5_FLOW_ACTION_SAMPLE ) && - fdb_mirror_limit) -return rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION , -NULL , -"sample and jump action combination is not supported" ); ++actions_n; action_flags |=MLX5_FLOW_ACTION_JUMP ;break ;
@@ -7987,6 +7979,8 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,RTE_FLOW_ERROR_TYPE_ACTION ,NULL , "duplicate age actions set"); +if (action_flags &MLX5_FLOW_ACTION_SAMPLE ) + aso_after_sample =1 ; action_flags |=MLX5_FLOW_ACTION_AGE ; ++actions_n;break ;
@@ -8014,6 +8008,9 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,RTE_FLOW_ERROR_TYPE_ACTION ,NULL , "old age action and count must be in the same sub flow"); + }else { +if (action_flags &MLX5_FLOW_ACTION_SAMPLE ) + aso_after_sample =1 ; } action_flags |=MLX5_FLOW_ACTION_AGE ; ++actions_n;
@@ -8056,9 +8053,8 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, attr, item_flags, rss, &sample_rss, &sample_count, - &fdb_mirror_limit, + &fdb_mirror, is_root, - act_priv, error);if (ret <0 )return ret;
@@ -8093,6 +8089,8 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, is_root, error);if (ret <0 )return ret; +if (action_flags &MLX5_FLOW_ACTION_SAMPLE ) + aso_after_sample =1 ; action_flags |=MLX5_FLOW_ACTION_CT ;break ;case MLX5_RTE_FLOW_ACTION_TYPE_TUNNEL_SET :
@@ -8350,11 +8348,24 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,NULL ,"too many header modify" " actions to support"); } -/* Eswitch egress mirror and modify flow has limitation on CX5 */ -if (fdb_mirror_limit && modify_after_mirror) -return rte_flow_error_set (error,EINVAL , -RTE_FLOW_ERROR_TYPE_ACTION ,NULL , -"sample before modify action is not supported" ); +if (fdb_mirror) { +if (!priv->sh->cdev->config.hca_attr.reg_c_preserve && +flow_source_vport_representor (priv, act_priv)) { +/* Eswitch egress mirror and modify flow has limitation on CX5 */ +if (modify_after_mirror) +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION ,NULL , +"sample before modify action is not supported" ); +if (action_flags &MLX5_FLOW_ACTION_JUMP ) +return rte_flow_error_set (error,EINVAL , +RTE_FLOW_ERROR_TYPE_ACTION ,NULL , +"sample and jump action combination is not supported" ); + } +if (aso_mask >0 && aso_after_sample && fdb_mirror) +return rte_flow_error_set (error,ENOTSUP , +RTE_FLOW_ERROR_TYPE_ACTION ,NULL , +"sample before ASO action is not supported" ); + }/* * Validation the NIC Egress flow on representor, except implicit * hairpin default egress flow with TX_QUEUE item, other flows not
Signature · 1 line
2.18.1
Hi,
Quoted 14 lines
-----Original Message-----
From: Jiawei(Jonny) Wang <[email protected]>
Sent: Wednesday, November 2, 2022 3:44 PM
To: Slava Ovsiienko <[email protected]>; Matan Azrad <[email protected]>
Cc: [email protected]; Raslan Darawsheh <[email protected]>
Subject: [PATCH 0/2] net/mlx5: fix some sample/mirror issuesSome fixes for sample/mirror issues.
Jiawei Wang (2):
net/mlx5: fix flow source port checking in sample flow rule net/mlx5: fix mirror flow validation with ASO action
Quoted 7 lines
drivers/net/mlx5/mlx5_flow.c | 55 +++++++++++++--- drivers/net/mlx5/mlx5_flow.h | 19 ++++++ drivers/net/mlx5/mlx5_flow_dv.c | 110 ++++++++++++++++++++------------ 3 files changed, 133 insertions(+), 51 deletions(-)--
2.18.1
Series applied to next-net-mlx,
Kindest regards,
Raslan Darawsheh