* [PATCH 0/2] net/mlx5: fix validation of count and AGE actions combination
@ 2022-02-28 7:09 Michael Baum
2022-02-28 7:09 ` [PATCH 1/2] net/mlx5: fix overridden flag in flow validation Michael Baum
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Michael Baum @ 2022-02-28 7:09 UTC (permalink / raw)
To: dev; +Cc: Matan Azrad, Raslan Darawsheh, Viacheslav Ovsiienko
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(-)
--
2.25.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/2] net/mlx5: fix overridden flag in flow validation
2022-02-28 7:09 [PATCH 0/2] net/mlx5: fix validation of count and AGE actions combination Michael Baum
@ 2022-02-28 7:09 ` Michael Baum
2022-02-28 7:09 ` [PATCH 2/2] net/mlx5: fix insufficient check in count action validation Michael Baum
2022-03-02 10:20 ` [PATCH 0/2] net/mlx5: fix validation of count and AGE actions combination Raslan Darawsheh
2 siblings, 0 replies; 4+ messages in thread
From: Michael Baum @ 2022-02-28 7:09 UTC (permalink / raw)
To: dev; +Cc: Matan Azrad, Raslan Darawsheh, Viacheslav Ovsiienko, stable
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.
Fixes: f3191849f2c2 ("net/mlx5: support flow count action handle")
Cc: stable@dpdk.org
Signed-off-by: Michael Baum <michaelba@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
drivers/net/mlx5/mlx5_flow_dv.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index 2191ce6e58..de6bf8c660 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -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,
--
2.25.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 2/2] net/mlx5: fix insufficient check in count action validation
2022-02-28 7:09 [PATCH 0/2] net/mlx5: fix validation of count and AGE actions combination Michael Baum
2022-02-28 7:09 ` [PATCH 1/2] net/mlx5: fix overridden flag in flow validation Michael Baum
@ 2022-02-28 7:09 ` Michael Baum
2022-03-02 10:20 ` [PATCH 0/2] net/mlx5: fix validation of count and AGE actions combination Raslan Darawsheh
2 siblings, 0 replies; 4+ messages in thread
From: Michael Baum @ 2022-02-28 7:09 UTC (permalink / raw)
To: dev; +Cc: Matan Azrad, Raslan Darawsheh, Viacheslav Ovsiienko, stable
The 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.
Fixes: daed4b6e3db2 ("net/mlx5: use aging by counter when counter exists")
Cc: stable@dpdk.org
Signed-off-by: Michael Baum <michaelba@nvidia.com>
Acked-by: Matan Azrad <matan@nvidia.com>
---
drivers/net/mlx5/mlx5_flow_dv.c | 41 +++++++++++++++++++++++++--------
1 file changed, 31 insertions(+), 10 deletions(-)
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index de6bf8c660..e5be435e32 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -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,
--
2.25.1
^ permalink raw reply [flat|nested] 4+ messages in thread
* RE: [PATCH 0/2] net/mlx5: fix validation of count and AGE actions combination
2022-02-28 7:09 [PATCH 0/2] net/mlx5: fix validation of count and AGE actions combination Michael Baum
2022-02-28 7:09 ` [PATCH 1/2] net/mlx5: fix overridden flag in flow validation Michael Baum
2022-02-28 7:09 ` [PATCH 2/2] net/mlx5: fix insufficient check in count action validation Michael Baum
@ 2022-03-02 10:20 ` Raslan Darawsheh
2 siblings, 0 replies; 4+ messages in thread
From: Raslan Darawsheh @ 2022-03-02 10:20 UTC (permalink / raw)
To: Michael Baum, dev; +Cc: Matan Azrad, Slava Ovsiienko
Hi,
> -----Original Message-----
> From: Michael Baum <michaelba@nvidia.com>
> Sent: Monday, February 28, 2022 9:10 AM
> To: dev@dpdk.org
> Cc: Matan Azrad <matan@nvidia.com>; Raslan Darawsheh
> <rasland@nvidia.com>; Slava Ovsiienko <viacheslavo@nvidia.com>
> Subject: [PATCH 0/2] 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(-)
>
> --
> 2.25.1
Series applied to next-net-mlx,
Kindest regards,
Raslan Darawsheh
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2022-03-02 10:20 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-02-28 7:09 [PATCH 0/2] net/mlx5: fix validation of count and AGE actions combination Michael Baum
2022-02-28 7:09 ` [PATCH 1/2] net/mlx5: fix overridden flag in flow validation Michael Baum
2022-02-28 7:09 ` [PATCH 2/2] net/mlx5: fix insufficient check in count action validation Michael Baum
2022-03-02 10:20 ` [PATCH 0/2] net/mlx5: fix validation of count and AGE actions combination Raslan Darawsheh
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).