* [PATCH] net/mlx5: fix drop action attribute validation
@ 2023-05-17 20:36 Dariusz Sosnowski
2023-05-28 12:17 ` Raslan Darawsheh
0 siblings, 1 reply; 2+ messages in thread
From: Dariusz Sosnowski @ 2023-05-17 20:36 UTC (permalink / raw)
To: Ori Kam, Suanming Mou, Matan Azrad, Viacheslav Ovsiienko, Jiawei Wang
Cc: dev, stable
Before this patch, DROP flow action was rejected for all egress
flow rules, which was not correct for all cases.
When Verbs flow engine is used (dv_flow_en=0) DROP flow action
is implemented using IBV_FLOW_SPEC_ACTION_DROP IBV action.
This action is supported on ingress only.
This patch amends the DROP flow action validation to allow it only on
ingress.
When DV flow engine is used (dv_flow_en=1) there are 2 implementation
options for DROP flow action:
- DR drop action (allocated through mlx5dv_dr_action_create_drop() API),
- dedicated drop queue.
When flow rules are created on non-root flow tables DR drop action can
be used on all steering domains. On root flow table however, this action
ca be used if and only if it is supported by rdma-core and kernel
drivers. mlx5 PMD dynamically checks if DR drop action is supported
on root tables during device probing
(it is checked in mlx5_flow_discover_dr_action_support()).
If DR drop action is not supported on root table, then dedicated
drop queue must be used and as a result, DROP flow action on root
is supported only for ingress flow rules.
This patch amends the DROP flow action validation with this logic
for DV flow engine.
This patch also renames the dr_drop_action_en field in device's private
data to dr_root_drop_action_en to align the name with field's meaning.
Fixes: 3c4338a42134 ("net/mlx5: optimize device spawn time with representors")
Fixes: 45633c460c22 ("net/mlx5: workaround drop action with old kernel")
Fixes: da845ae9d7c1 ("net/mlx5: fix drop action for Direct Rules/Verbs")
Cc: suanmingm@nvidia.com
Cc: viacheslavo@nvidia.com
Cc: jiaweiw@nvidia.com
Cc: stable@dpdk.org
Signed-off-by: Dariusz Sosnowski <dsosnowski@nvidia.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
---
drivers/net/mlx5/linux/mlx5_os.c | 4 ++--
drivers/net/mlx5/mlx5.h | 2 +-
drivers/net/mlx5/mlx5_flow.c | 20 ++++++++++++++++----
drivers/net/mlx5/mlx5_flow.h | 3 ++-
drivers/net/mlx5/mlx5_flow_dv.c | 4 ++--
drivers/net/mlx5/mlx5_flow_verbs.c | 7 ++++---
6 files changed, 27 insertions(+), 13 deletions(-)
diff --git a/drivers/net/mlx5/linux/mlx5_os.c b/drivers/net/mlx5/linux/mlx5_os.c
index 980234e2ac..d8f1adfe3d 100644
--- a/drivers/net/mlx5/linux/mlx5_os.c
+++ b/drivers/net/mlx5/linux/mlx5_os.c
@@ -876,10 +876,10 @@ mlx5_flow_drop_action_config(struct rte_eth_dev *dev __rte_unused)
*/
if (!priv->sh->drop_action_check_flag) {
if (!mlx5_flow_discover_dr_action_support(dev))
- priv->sh->dr_drop_action_en = 1;
+ priv->sh->dr_root_drop_action_en = 1;
priv->sh->drop_action_check_flag = 1;
}
- if (priv->sh->dr_drop_action_en)
+ if (priv->sh->dr_root_drop_action_en)
priv->root_drop_action = priv->sh->dr_drop_action;
else
priv->root_drop_action = priv->drop_queue.hrxq->action;
diff --git a/drivers/net/mlx5/mlx5.h b/drivers/net/mlx5/mlx5.h
index 9eae692037..785ca96a8a 100644
--- a/drivers/net/mlx5/mlx5.h
+++ b/drivers/net/mlx5/mlx5.h
@@ -1377,7 +1377,7 @@ struct mlx5_dev_ctx_shared {
uint32_t tunnel_header_0_1:1; /* tunnel_header_0_1 is supported. */
uint32_t tunnel_header_2_3:1; /* tunnel_header_2_3 is supported. */
uint32_t misc5_cap:1; /* misc5 matcher parameter is supported. */
- uint32_t dr_drop_action_en:1; /* Use DR drop action. */
+ uint32_t dr_root_drop_action_en:1; /* DR drop action is usable on root tables. */
uint32_t drop_action_check_flag:1; /* Check Flag for drop action. */
uint32_t flow_priority_check_flag:1; /* Check Flag for flow priority. */
uint32_t metadata_regc_check_flag:1; /* Check Flag for metadata REGC. */
diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c
index 19f7f92717..5f88eb5c06 100644
--- a/drivers/net/mlx5/mlx5_flow.c
+++ b/drivers/net/mlx5/mlx5_flow.c
@@ -1924,8 +1924,10 @@ mlx5_flow_validate_action_mark(const struct rte_flow_action *action,
/*
* Validate the drop action.
*
- * @param[in] action_flags
- * Bit-fields that holds the actions detected until now.
+ * @param[in] dev
+ * Pointer to the Ethernet device structure.
+ * @param[in] is_root
+ * True if flow is validated for root table. False otherwise.
* @param[in] attr
* Attributes of flow that includes this action.
* @param[out] error
@@ -1935,15 +1937,25 @@ mlx5_flow_validate_action_mark(const struct rte_flow_action *action,
* 0 on success, a negative errno value otherwise and rte_errno is set.
*/
int
-mlx5_flow_validate_action_drop(uint64_t action_flags __rte_unused,
+mlx5_flow_validate_action_drop(struct rte_eth_dev *dev,
+ bool is_root,
const struct rte_flow_attr *attr,
struct rte_flow_error *error)
{
- if (attr->egress)
+ struct mlx5_priv *priv = dev->data->dev_private;
+
+ if (priv->sh->config.dv_flow_en == 0 && attr->egress)
return rte_flow_error_set(error, ENOTSUP,
RTE_FLOW_ERROR_TYPE_ATTR_EGRESS, NULL,
"drop action not supported for "
"egress");
+ if (priv->sh->config.dv_flow_en == 1 && is_root && (attr->egress || attr->transfer) &&
+ !priv->sh->dr_root_drop_action_en) {
+ return rte_flow_error_set(error, ENOTSUP,
+ RTE_FLOW_ERROR_TYPE_ATTR, NULL,
+ "drop action not supported for "
+ "egress and transfer on group 0");
+ }
return 0;
}
diff --git a/drivers/net/mlx5/mlx5_flow.h b/drivers/net/mlx5/mlx5_flow.h
index 1d116ea0f6..65bfc2f2d0 100644
--- a/drivers/net/mlx5/mlx5_flow.h
+++ b/drivers/net/mlx5/mlx5_flow.h
@@ -2252,7 +2252,8 @@ int mlx5_validate_action_rss(struct rte_eth_dev *dev,
int mlx5_flow_validate_action_count(struct rte_eth_dev *dev,
const struct rte_flow_attr *attr,
struct rte_flow_error *error);
-int mlx5_flow_validate_action_drop(uint64_t action_flags,
+int mlx5_flow_validate_action_drop(struct rte_eth_dev *dev,
+ bool is_root,
const struct rte_flow_attr *attr,
struct rte_flow_error *error);
int mlx5_flow_validate_action_flag(uint64_t action_flags,
diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c
index f136f43b0a..679bd3b405 100644
--- a/drivers/net/mlx5/mlx5_flow_dv.c
+++ b/drivers/net/mlx5/mlx5_flow_dv.c
@@ -7819,7 +7819,7 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr,
rw_act_num += MLX5_ACT_NUM_SET_TAG;
break;
case RTE_FLOW_ACTION_TYPE_DROP:
- ret = mlx5_flow_validate_action_drop(action_flags,
+ ret = mlx5_flow_validate_action_drop(dev, is_root,
attr, error);
if (ret < 0)
return ret;
@@ -19256,7 +19256,7 @@ flow_dv_validate_mtr_policy_acts(struct rte_eth_dev *dev,
break;
case RTE_FLOW_ACTION_TYPE_DROP:
ret = mlx5_flow_validate_action_drop
- (action_flags[i], attr, &flow_err);
+ (dev, false, attr, &flow_err);
if (ret < 0)
return -rte_mtr_error_set(error,
ENOTSUP,
diff --git a/drivers/net/mlx5/mlx5_flow_verbs.c b/drivers/net/mlx5/mlx5_flow_verbs.c
index b363fb4ad3..fe9c818abc 100644
--- a/drivers/net/mlx5/mlx5_flow_verbs.c
+++ b/drivers/net/mlx5/mlx5_flow_verbs.c
@@ -1317,14 +1317,14 @@ flow_verbs_validate(struct rte_eth_dev *dev,
uint16_t ether_type = 0;
bool is_empty_vlan = false;
uint16_t udp_dport = 0;
- bool is_root;
+ /* Verbs interface does not support groups higher than 0. */
+ bool is_root = true;
if (items == NULL)
return -1;
ret = flow_verbs_validate_attributes(dev, attr, error);
if (ret < 0)
return ret;
- is_root = ret;
for (; items->type != RTE_FLOW_ITEM_TYPE_END; items++) {
int tunnel = !!(item_flags & MLX5_FLOW_LAYER_TUNNEL);
int ret = 0;
@@ -1531,7 +1531,8 @@ flow_verbs_validate(struct rte_eth_dev *dev,
action_flags |= MLX5_FLOW_ACTION_MARK;
break;
case RTE_FLOW_ACTION_TYPE_DROP:
- ret = mlx5_flow_validate_action_drop(action_flags,
+ ret = mlx5_flow_validate_action_drop(dev,
+ is_root,
attr,
error);
if (ret < 0)
--
2.25.1
^ permalink raw reply [flat|nested] 2+ messages in thread
* RE: [PATCH] net/mlx5: fix drop action attribute validation
2023-05-17 20:36 [PATCH] net/mlx5: fix drop action attribute validation Dariusz Sosnowski
@ 2023-05-28 12:17 ` Raslan Darawsheh
0 siblings, 0 replies; 2+ messages in thread
From: Raslan Darawsheh @ 2023-05-28 12:17 UTC (permalink / raw)
To: Dariusz Sosnowski, Ori Kam, Suanming Mou, Matan Azrad,
Slava Ovsiienko, Jiawei(Jonny) Wang
Cc: dev, stable
Hi,
> -----Original Message-----
> From: Dariusz Sosnowski <dsosnowski@nvidia.com>
> Sent: Wednesday, May 17, 2023 11:36 PM
> To: Ori Kam <orika@nvidia.com>; Suanming Mou <suanmingm@nvidia.com>;
> Matan Azrad <matan@nvidia.com>; Slava Ovsiienko
> <viacheslavo@nvidia.com>; Jiawei(Jonny) Wang <jiaweiw@nvidia.com>
> Cc: dev@dpdk.org; stable@dpdk.org
> Subject: [PATCH] net/mlx5: fix drop action attribute validation
>
> Before this patch, DROP flow action was rejected for all egress
> flow rules, which was not correct for all cases.
>
> When Verbs flow engine is used (dv_flow_en=0) DROP flow action
> is implemented using IBV_FLOW_SPEC_ACTION_DROP IBV action.
> This action is supported on ingress only.
> This patch amends the DROP flow action validation to allow it only on
> ingress.
>
> When DV flow engine is used (dv_flow_en=1) there are 2 implementation
> options for DROP flow action:
>
> - DR drop action (allocated through mlx5dv_dr_action_create_drop() API),
> - dedicated drop queue.
>
> When flow rules are created on non-root flow tables DR drop action can
> be used on all steering domains. On root flow table however, this action
> ca be used if and only if it is supported by rdma-core and kernel
> drivers. mlx5 PMD dynamically checks if DR drop action is supported
> on root tables during device probing
> (it is checked in mlx5_flow_discover_dr_action_support()).
> If DR drop action is not supported on root table, then dedicated
> drop queue must be used and as a result, DROP flow action on root
> is supported only for ingress flow rules.
> This patch amends the DROP flow action validation with this logic
> for DV flow engine.
>
> This patch also renames the dr_drop_action_en field in device's private
> data to dr_root_drop_action_en to align the name with field's meaning.
>
> Fixes: 3c4338a42134 ("net/mlx5: optimize device spawn time with
> representors")
> Fixes: 45633c460c22 ("net/mlx5: workaround drop action with old kernel")
> Fixes: da845ae9d7c1 ("net/mlx5: fix drop action for Direct Rules/Verbs")
> Cc: suanmingm@nvidia.com
> Cc: viacheslavo@nvidia.com
> Cc: jiaweiw@nvidia.com
> Cc: stable@dpdk.org
>
> Signed-off-by: Dariusz Sosnowski <dsosnowski@nvidia.com>
> Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
Patch applied to next-net-mlx,
Kindest regards,
Raslan Darawsheh
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-05-28 12:17 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-17 20:36 [PATCH] net/mlx5: fix drop action attribute validation Dariusz Sosnowski
2023-05-28 12:17 ` 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).