From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 760B0A0564 for ; Fri, 28 Feb 2020 04:34:12 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 68D311BFAB; Fri, 28 Feb 2020 04:34:12 +0100 (CET) Received: from git-send-mailer.rdmz.labs.mlnx (unknown [37.142.13.130]) by dpdk.org (Postfix) with ESMTP id 9953F1BFAB for ; Fri, 28 Feb 2020 04:34:09 +0100 (CET) From: Suanming Mou To: luca.boccassi@gmail.com Cc: stable@dpdk.org Date: Fri, 28 Feb 2020 11:33:53 +0800 Message-Id: <1582860835-282594-10-git-send-email-suanmingm@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1582860835-282594-1-git-send-email-suanmingm@mellanox.com> References: <1582860835-282594-1-git-send-email-suanmingm@mellanox.com> Subject: [dpdk-stable] [PATCH 19.11 09/11] net/mlx5: fix match information in meter X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" [ upstream commit 6e77151286b2f551ae30aac0f251ed067f1ec011 ] As meter flows are split into three subflows each, the prefix subflow with meter action color the packet, the meter subflow filters out the colored packets, the suffix subflow applies all the remaining actions to the passed packets. Currently, all the user defined items are matched in the prefix flow. Flow id tag match item is the only item added to the meter suffix subflow. Some of the remaining actions to be applied in the suffix subflow require more information in the match item, or the suffix subflow will not be created successfully. Actions require the L3/L4 type in the match items as below: RTE_FLOW_ACTION_TYPE_SET_TP_SRC RTE_FLOW_ACTION_TYPE_SET_TP_DST RTE_FLOW_ACTION_TYPE_DEC_TTL RTE_FLOW_ACTION_TYPE_SET_TTL RTE_FLOW_ACTION_TYPE_RSS RTE_FLOW_ACTION_TYPE_QUEUE Inherit the match item flags from meter prefix subflow to make actions in suffix subflow get sufficient information. Fixes: 9ea9b049a960 ("net/mlx5: split meter flow") Signed-off-by: Suanming Mou Acked-by: Matan Azrad --- drivers/net/mlx5/mlx5_flow.c | 11 ++++++--- drivers/net/mlx5/mlx5_flow_dv.c | 53 ++++++++++++++++++++++++++++++----------- 2 files changed, 47 insertions(+), 17 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 03ee207..365b832 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -3758,6 +3758,8 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority, * Pointer to Ethernet device. * @param[in] flow * Parent flow structure pointer. + * @param[in] prefix_layers + * Prefix flow layer flags. * @param[in] attr * Flow rule attributes. * @param[in] items @@ -3774,6 +3776,7 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority, static int flow_create_split_metadata(struct rte_eth_dev *dev, struct rte_flow *flow, + uint64_t prefix_layers, const struct rte_flow_attr *attr, const struct rte_flow_item items[], const struct rte_flow_action actions[], @@ -3794,7 +3797,7 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority, if (!config->dv_flow_en || config->dv_xmeta_en == MLX5_XMETA_MODE_LEGACY || !mlx5_flow_ext_mreg_supported(dev)) - return flow_create_split_inner(dev, flow, NULL, 0, + return flow_create_split_inner(dev, flow, NULL, prefix_layers, attr, items, actions, external, error); actions_n = flow_parse_qrss_action(actions, &qrss); @@ -3877,7 +3880,7 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority, goto exit; } /* Add the unmodified original or prefix subflow. */ - ret = flow_create_split_inner(dev, flow, &dev_flow, 0, attr, + ret = flow_create_split_inner(dev, flow, &dev_flow, prefix_layers, attr, items, ext_actions ? ext_actions : actions, external, error); if (ret < 0) @@ -4072,7 +4075,9 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority, MLX5_FLOW_TABLE_LEVEL_SUFFIX; } /* Add the prefix subflow. */ - ret = flow_create_split_metadata(dev, flow, &sfx_attr, + ret = flow_create_split_metadata(dev, flow, dev_flow ? + flow_get_prefix_layer_flags(dev_flow) : + 0, &sfx_attr, sfx_items ? sfx_items : items, sfx_actions ? sfx_actions : actions, external, error); diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index f5929bf..a5824dc 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -82,16 +82,35 @@ * Pointer to item specification. * @param[out] attr * Pointer to flow attributes structure. + * @param[in] dev_flow + * Pointer to the sub flow. * @param[in] tunnel_decap * Whether action is after tunnel decapsulation. */ static void flow_dv_attr_init(const struct rte_flow_item *item, union flow_dv_attr *attr, - bool tunnel_decap) + struct mlx5_flow *dev_flow, bool tunnel_decap) { + /* + * If layers is already initialized, it means this dev_flow is the + * suffix flow, the layers flags is set by the prefix flow. Need to + * use the layer flags from prefix flow as the suffix flow may not + * have the user defined items as the flow is split. + */ + if (dev_flow->layers) { + if (dev_flow->layers & MLX5_FLOW_LAYER_OUTER_L3_IPV4) + attr->ipv4 = 1; + else if (dev_flow->layers & MLX5_FLOW_LAYER_OUTER_L3_IPV6) + attr->ipv6 = 1; + if (dev_flow->layers & MLX5_FLOW_LAYER_OUTER_L4_TCP) + attr->tcp = 1; + else if (dev_flow->layers & MLX5_FLOW_LAYER_OUTER_L4_UDP) + attr->udp = 1; + attr->valid = 1; + return; + } for (; item->type != RTE_FLOW_ITEM_TYPE_END; item++) { uint8_t next_protocol = 0xff; - switch (item->type) { case RTE_FLOW_ITEM_TYPE_GRE: case RTE_FLOW_ITEM_TYPE_NVGRE: @@ -635,6 +654,8 @@ struct field_modify_info modify_tcp[] = { * Pointer to rte_flow_item objects list. * @param[in] attr * Pointer to flow attributes structure. + * @param[in] dev_flow + * Pointer to the sub flow. * @param[in] tunnel_decap * Whether action is after tunnel decapsulation. * @param[out] error @@ -648,8 +669,8 @@ struct field_modify_info modify_tcp[] = { (struct mlx5_flow_dv_modify_hdr_resource *resource, const struct rte_flow_action *action, const struct rte_flow_item *items, - union flow_dv_attr *attr, bool tunnel_decap, - struct rte_flow_error *error) + union flow_dv_attr *attr, struct mlx5_flow *dev_flow, + bool tunnel_decap, struct rte_flow_error *error) { const struct rte_flow_action_set_tp *conf = (const struct rte_flow_action_set_tp *)(action->conf); @@ -661,7 +682,7 @@ struct field_modify_info modify_tcp[] = { struct field_modify_info *field; if (!attr->valid) - flow_dv_attr_init(items, attr, tunnel_decap); + flow_dv_attr_init(items, attr, dev_flow, tunnel_decap); if (attr->udp) { memset(&udp, 0, sizeof(udp)); memset(&udp_mask, 0, sizeof(udp_mask)); @@ -711,6 +732,8 @@ struct field_modify_info modify_tcp[] = { * Pointer to rte_flow_item objects list. * @param[in] attr * Pointer to flow attributes structure. + * @param[in] dev_flow + * Pointer to the sub flow. * @param[in] tunnel_decap * Whether action is after tunnel decapsulation. * @param[out] error @@ -724,8 +747,8 @@ struct field_modify_info modify_tcp[] = { (struct mlx5_flow_dv_modify_hdr_resource *resource, const struct rte_flow_action *action, const struct rte_flow_item *items, - union flow_dv_attr *attr, bool tunnel_decap, - struct rte_flow_error *error) + union flow_dv_attr *attr, struct mlx5_flow *dev_flow, + bool tunnel_decap, struct rte_flow_error *error) { const struct rte_flow_action_set_ttl *conf = (const struct rte_flow_action_set_ttl *)(action->conf); @@ -737,7 +760,7 @@ struct field_modify_info modify_tcp[] = { struct field_modify_info *field; if (!attr->valid) - flow_dv_attr_init(items, attr, tunnel_decap); + flow_dv_attr_init(items, attr, dev_flow, tunnel_decap); if (attr->ipv4) { memset(&ipv4, 0, sizeof(ipv4)); memset(&ipv4_mask, 0, sizeof(ipv4_mask)); @@ -773,6 +796,8 @@ struct field_modify_info modify_tcp[] = { * Pointer to rte_flow_item objects list. * @param[in] attr * Pointer to flow attributes structure. + * @param[in] dev_flow + * Pointer to the sub flow. * @param[in] tunnel_decap * Whether action is after tunnel decapsulation. * @param[out] error @@ -785,8 +810,8 @@ struct field_modify_info modify_tcp[] = { flow_dv_convert_action_modify_dec_ttl (struct mlx5_flow_dv_modify_hdr_resource *resource, const struct rte_flow_item *items, - union flow_dv_attr *attr, bool tunnel_decap, - struct rte_flow_error *error) + union flow_dv_attr *attr, struct mlx5_flow *dev_flow, + bool tunnel_decap, struct rte_flow_error *error) { struct rte_flow_item item; struct rte_flow_item_ipv4 ipv4; @@ -796,7 +821,7 @@ struct field_modify_info modify_tcp[] = { struct field_modify_info *field; if (!attr->valid) - flow_dv_attr_init(items, attr, tunnel_decap); + flow_dv_attr_init(items, attr, dev_flow, tunnel_decap); if (attr->ipv4) { memset(&ipv4, 0, sizeof(ipv4)); memset(&ipv4_mask, 0, sizeof(ipv4_mask)); @@ -7172,7 +7197,7 @@ struct field_modify_info modify_tcp[] = { case RTE_FLOW_ACTION_TYPE_SET_TP_DST: if (flow_dv_convert_action_modify_tp (mhdr_res, actions, items, - &flow_attr, !!(action_flags & + &flow_attr, dev_flow, !!(action_flags & MLX5_FLOW_ACTION_DECAP), error)) return -rte_errno; action_flags |= actions->type == @@ -7182,7 +7207,7 @@ struct field_modify_info modify_tcp[] = { break; case RTE_FLOW_ACTION_TYPE_DEC_TTL: if (flow_dv_convert_action_modify_dec_ttl - (mhdr_res, items, &flow_attr, + (mhdr_res, items, &flow_attr, dev_flow, !!(action_flags & MLX5_FLOW_ACTION_DECAP), error)) return -rte_errno; @@ -7191,7 +7216,7 @@ struct field_modify_info modify_tcp[] = { case RTE_FLOW_ACTION_TYPE_SET_TTL: if (flow_dv_convert_action_modify_ttl (mhdr_res, actions, items, &flow_attr, - !!(action_flags & + dev_flow, !!(action_flags & MLX5_FLOW_ACTION_DECAP), error)) return -rte_errno; action_flags |= MLX5_FLOW_ACTION_SET_TTL; -- 1.8.3.1