net/mlx5: fix validation of count and AGE actions combination
cover net/mlx5: fix validation of count and AGE actions combination
Fix mistakes done in floe_dv_validate() for count and AGE actions combination checking.
Michael Baum (2):
net/mlx5: fix overridden flag in flow validation net/mlx5: fix insufficient check in count action validation
drivers/net/mlx5/mlx5_flow_dv.c | 43 ++++++++++++++++++++++++--------- 1 file changed, 32 insertions(+), 11 deletions(-)
Signature · 1 line
2.25.1
PATCH 1/2 net/mlx5: fix overridden flag in flow validation
The AGE action can be implemented by either counters or ASO mechanism. When user ask count action in the flow rule, AGE action is implemented by the same counter. However, if user ask indirect count action, it cannot be used for AGE.
The flow_dv_validate() function has a flag named "shared_count" which indicates whether AGE action validate is depend on ASO support or not. This flag is initialized to false and is updated if there is indirect count action in the action list.
This flag is mistakenly set within the loop that reads the action list and in each iteration it is reinitialized to false, regardless of the existence of an indirect count action in the list.
This patch moves the flag initialization out of the loop.
--- drivers/net/mlx5/mlx5_flow_dv.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/mlx5/mlx5_flow_dv.c +1 -1
@@ -6907,6 +6907,7 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,const struct rte_flow_item *integrity_items[2 ] = {NULL ,NULL };const struct rte_flow_item *port_id_item =NULL ;bool def_policy = false; +bool shared_count = false;uint16_t udp_dport =0 ;if (items ==NULL )
@@ -7284,7 +7285,6 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, }for (; actions->type !=RTE_FLOW_ACTION_TYPE_END ; actions++) {int type = actions->type; -bool shared_count = false;if (!mlx5_flow_os_action_supported (type)) return rte_flow_error_set(error, ENOTSUP,
Signature · 1 line
2.25.1
PATCH 2/2 net/mlx5: fix insufficient check in count action validation
In reply to Michael BaumThe AGE action can be implemented by either counters or ASO mechanism. ASO is more efficient than generating counters just for the purpose of aging, so when ASO is supported its use is preferable. On the other hand, when there is count in the list of actions, the counter is already generated, and it is best to use it for aging even if ASO is supported. On the other hand, when the count action is "indirect", it cannot be used for aging since it may be updated from other flow rules in which it participates.
Checking whether ASO is supported depends on both the capability of the device and the flow rule group number, ASO is not supported for group 0. However, the flow_dv_validate() function only checks the capability and ignores the group, allowing inadmissible flow rules.
For example, when the device supports ASO and a flow rule is set that combines an indirect counter with aging for group 0, the rule should be rejected, but it is created and does not function properly.
This patch updates the counter validation which will also consider the group number when deciding if there is ASO support.
--- drivers/net/mlx5/mlx5_flow_dv.c | 41 +++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 10 deletions(-)
drivers/net/mlx5/mlx5_flow_dv.c +31 -10
@@ -3277,6 +3277,25 @@ flow_dv_validate_action_set_tag(struct rte_eth_dev *dev,return 0 ; } +/** +* Indicates whether ASO aging is supported. +* +* @param[in] sh +* Pointer to shared device context structure. +* @param[in] attr +* Attributes of flow that includes AGE action. +* +* @return +* True when ASO aging is supported, false otherwise. +*/ +static inline bool +flow_hit_aso_supported (const struct mlx5_dev_ctx_shared *sh, +const struct rte_flow_attr *attr) +{ +MLX5_ASSERT (sh && attr); +return (sh->flow_hit_aso_en && (attr->transfer || attr->group)); +} +/** * Validate count action. *
@@ -3286,6 +3305,8 @@ flow_dv_validate_action_set_tag(struct rte_eth_dev *dev,* Indicator if action is shared. * @param[in] action_flags * Holds the actions detected until now. +* @param[in] attr +* Attributes of flow that includes this action. * @param[out] error * Pointer to error structure. *
@@ -3295,6 +3316,7 @@ flow_dv_validate_action_set_tag(struct rte_eth_dev *dev,static int flow_dv_validate_action_count (struct rte_eth_dev *dev,bool shared,uint64_t action_flags, +const struct rte_flow_attr *attr,struct rte_flow_error *error) {struct mlx5_priv *priv = dev->data->dev_private;
@@ -3306,10 +3328,10 @@ flow_dv_validate_action_count(struct rte_eth_dev *dev, bool shared,RTE_FLOW_ERROR_TYPE_ACTION ,NULL , "duplicate count actions set");if (shared && (action_flags &MLX5_FLOW_ACTION_AGE ) && - !priv->sh->flow_hit_aso_en) + !flow_hit_aso_supported (priv->sh, attr))return rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION ,NULL , -"old age and shared count combination is not supported" ); +"old age and indirect count combination is not supported" );#ifdef HAVE_IBV_FLOW_DEVX_COUNTERS return 0 ;#endif
@@ -5679,7 +5701,7 @@ flow_dv_validate_action_sample(uint64_t *action_flags,case RTE_FLOW_ACTION_TYPE_COUNT : ret =flow_dv_validate_action_count (dev, false, *action_flags | sub_action_flags, - error); + attr, error);if (ret <0 )return ret; *count = act->conf;
@@ -7441,7 +7463,7 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,case RTE_FLOW_ACTION_TYPE_COUNT : ret =flow_dv_validate_action_count (dev, shared_count, action_flags, - error); + attr, error);if (ret <0 )return ret; action_flags |=MLX5_FLOW_ACTION_COUNT ;
@@ -7756,15 +7778,15 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,return ret;/* * Validate the regular AGE action (using counter) -* mutual exclusion with share counter actions. +* mutual exclusion with indirect counter actions. */ -if (!priv->sh->flow_hit_aso_en) { +if (!flow_hit_aso_supported (priv->sh, attr)) {if (shared_count)return rte_flow_error_set (error,EINVAL ,RTE_FLOW_ERROR_TYPE_ACTION ,NULL , -"old age and shared count combination is not supported" ); +"old age and indirect count combination is not supported" );if (sample_count)return rte_flow_error_set (error, EINVAL,
@@ -13415,8 +13437,7 @@ flow_dv_translate(struct rte_eth_dev *dev,*/ if (action_flags &MLX5_FLOW_ACTION_AGE ) {if ((non_shared_age && count) || - !(priv->sh->flow_hit_aso_en && - (attr->group || attr->transfer))) { + !flow_hit_aso_supported (priv->sh, attr)) {/* Creates age by counters. */ cnt_act = flow_dv_prepare_counter (dev, dev_flow,
@@ -17709,7 +17730,7 @@ flow_dv_action_validate(struct rte_eth_dev *dev, "Indirect age action not supported");return flow_dv_validate_action_age (0 , action, dev, err);case RTE_FLOW_ACTION_TYPE_COUNT : -return flow_dv_validate_action_count (dev, true,0 , err); +return flow_dv_validate_action_count (dev, true,0 ,NULL , err);case RTE_FLOW_ACTION_TYPE_CONNTRACK :if (!priv->sh->ct_aso_en) return rte_flow_error_set(err, ENOTSUP,
Signature · 1 line
2.25.1
Hi,
Quoted 16 lines
-----Original Message-----
From: Michael Baum <[email protected]>
Sent: Monday, February 28, 2022 9:10 AM
To: [email protected]
Cc: Matan Azrad <[email protected]>; Raslan Darawsheh <[email protected]>; Slava Ovsiienko <[email protected]>
Subject: [PATCH 0/2] net/mlx5: fix validation of count and AGE actions combinationFix mistakes done in
floe_dv_validate()for count and AGE actions combination checking.Michael Baum (2):
net/mlx5: fix overridden flag in flow validation net/mlx5: fix insufficient check in count action validation
Quoted 6 lines
drivers/net/mlx5/mlx5_flow_dv.c | 43 ++++++++++++++++++++++++------- -- 1 file changed, 32 insertions(+), 11 deletions(-)--
2.25.1
Series applied to next-net-mlx,
Kindest regards,
Raslan Darawsheh