net/mlx5: fix drop action attribute validation
PATCH 1/1 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.
--- 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(-)
drivers/net/mlx5/linux/mlx5_os.c +2 -2
@@ -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;
drivers/net/mlx5/mlx5.h +1 -1
@@ -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. */
drivers/net/mlx5/mlx5_flow.c +16 -4
@@ -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 ; }
drivers/net/mlx5/mlx5_flow.h +2 -1
@@ -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,
drivers/net/mlx5/mlx5_flow_dv.c +2 -2
@@ -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,
drivers/net/mlx5/mlx5_flow_verbs.c +4 -3
@@ -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 )
Signature · 1 line
2.25.1
Hi,
Quoted 48 lines
-----Original Message-----
From: Dariusz Sosnowski <[email protected]>
Sent: Wednesday, May 17, 2023 11:36 PM
To: Ori Kam <[email protected]>; Suanming Mou <[email protected]>; Matan Azrad <[email protected]>; Slava Ovsiienko <[email protected]>; Jiawei(Jonny) Wang <[email protected]>
Cc: [email protected]; [email protected]
Subject: [PATCH] net/mlx5: fix drop action attribute validationBefore 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_DROPIBV 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 inmlx5_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_enfield in device's private data todr_root_drop_action_ento align the name with field's meaning.Fixes 3c4338a42134 ("net/mlx5: optimize device spawn time withrepresentors")
Fixes 45633c460c22 ("net/mlx5: workaround drop action with old kernel")Fixes da845ae9d7c1 ("net/mlx5: fix drop action for Direct Rules/Verbs")
Quoted 2 lines
Signed-off-by Dariusz Sosnowski <[email protected]>
Patch applied to next-net-mlx,
Kindest regards,
Raslan Darawsheh