From patchwork Thu Feb 20 13:53:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suanming Mou X-Patchwork-Id: 65964 X-Patchwork-Delegate: rasland@nvidia.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 843A1A0556; Thu, 20 Feb 2020 14:53:56 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id D8D851BFAD; Thu, 20 Feb 2020 14:53:50 +0100 (CET) Received: from git-send-mailer.rdmz.labs.mlnx (unknown [37.142.13.130]) by dpdk.org (Postfix) with ESMTP id 01C231BF98; Thu, 20 Feb 2020 14:53:48 +0100 (CET) From: Suanming Mou To: matan@mellanox.com, viacheslavo@mellanox.com Cc: dev@dpdk.org, rasland@mellanox.com, stable@dpdk.org Date: Thu, 20 Feb 2020 15:53:43 +0200 Message-Id: <1582206824-103222-2-git-send-email-suanmingm@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1582206824-103222-1-git-send-email-suanmingm@mellanox.com> References: <1582122664-54731-1-git-send-email-suanmingm@mellanox.com> <1582206824-103222-1-git-send-email-suanmingm@mellanox.com> Subject: [dpdk-dev] [PATCH v3 1/2] net/mlx5: fix layer flags missing in metadata X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Metadata suffix subflow inherits the RSS needed hash_fields from the prefix subflow as the suffix subflow only has the tag match item unable to generate the full original hash_fields for RSS action. Unfortunately, hash_fields will only be generated if flow has RSS action. So it means the prefix flow won't generate the hash_fields as the RSS action has been split to the suffix flow. Copy the layer flags from prefix subflow to suffix subflow to help the suffix subflow to generate the correct hash_fields itself. Fixes: 71e254bc0294 ("net/mlx5: split Rx flows to provide metadata copy") Cc: viacheslavo@mellanox.com Cc: stable@dpdk.org Signed-off-by: Suanming Mou Acked-by: Matan Azrad --- drivers/net/mlx5/mlx5_flow.c | 67 +++++++++++++++++++++++++++++++++++------ drivers/net/mlx5/mlx5_flow_dv.c | 6 +++- 2 files changed, 62 insertions(+), 11 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index ce5aded..9267858 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -2727,6 +2727,43 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority, } /** + * Get layer flags from the prefix flow. + * + * Some flows may be split to several subflows, the prefix subflow gets the + * match items and the suffix sub flow gets the actions. + * Some actions need the user defined match item flags to get the detail for + * the action. + * This function helps the suffix flow to get the item layer flags from prefix + * subflow. + * + * @param[in] dev_flow + * Pointer the created preifx subflow. + * + * @return + * The layers get from prefix subflow. + */ +static inline uint64_t +flow_get_prefix_layer_flags(struct mlx5_flow *dev_flow) +{ + uint64_t layers = 0; + + /* If no decap actions, use the layers directly. */ + if (!(dev_flow->actions & MLX5_FLOW_ACTION_DECAP)) + return dev_flow->layers; + /* Convert L3 layers with decap action. */ + if (dev_flow->layers & MLX5_FLOW_LAYER_INNER_L3_IPV4) + layers |= MLX5_FLOW_LAYER_OUTER_L3_IPV4; + else if (dev_flow->layers & MLX5_FLOW_LAYER_INNER_L3_IPV6) + layers |= MLX5_FLOW_LAYER_OUTER_L3_IPV6; + /* Convert L4 layers with decap action. */ + if (dev_flow->layers & MLX5_FLOW_LAYER_INNER_L4_TCP) + layers |= MLX5_FLOW_LAYER_OUTER_L4_TCP; + else if (dev_flow->layers & MLX5_FLOW_LAYER_INNER_L4_UDP) + layers |= MLX5_FLOW_LAYER_OUTER_L4_UDP; + return layers; +} + +/** * Get QUEUE/RSS action from the action list. * * @param[in] actions @@ -3406,6 +3443,8 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority, * Parent flow structure pointer. * @param[in, out] sub_flow * Pointer to return the created subflow, may be NULL. + * @param[in] prefix_layers + * Prefix subflow layers, may be 0. * @param[in] attr * Flow rule attributes. * @param[in] items @@ -3423,6 +3462,7 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority, flow_create_split_inner(struct rte_eth_dev *dev, struct rte_flow *flow, struct mlx5_flow **sub_flow, + uint64_t prefix_layers, const struct rte_flow_attr *attr, const struct rte_flow_item items[], const struct rte_flow_action actions[], @@ -3437,6 +3477,12 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority, dev_flow->external = external; /* Subflow object was created, we must include one in the list. */ LIST_INSERT_HEAD(&flow->dev_flows, dev_flow, next); + /* + * If dev_flow is as one of the suffix flow, some actions in suffix + * flow may need some user defined item layer flags. + */ + if (prefix_layers) + dev_flow->layers = prefix_layers; if (sub_flow) *sub_flow = dev_flow; return flow_drv_translate(dev, dev_flow, attr, items, actions, error); @@ -3768,8 +3814,9 @@ 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, attr, items, - actions, external, error); + return flow_create_split_inner(dev, flow, NULL, 0, + attr, items, actions, external, + error); actions_n = flow_parse_qrss_action(actions, &qrss); if (qrss) { /* Exclude hairpin flows from splitting. */ @@ -3850,9 +3897,9 @@ 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, attr, items, - ext_actions ? ext_actions : actions, - external, error); + ret = flow_create_split_inner(dev, flow, &dev_flow, 0, attr, + items, ext_actions ? ext_actions : + actions, external, error); if (ret < 0) goto exit; MLX5_ASSERT(dev_flow); @@ -3886,7 +3933,7 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority, .type = RTE_FLOW_ACTION_TYPE_END, }, }; - uint64_t hash_fields = dev_flow->hash_fields; + uint64_t layers = flow_get_prefix_layer_flags(dev_flow); /* * Configure the tag item only if there is no meter subflow. @@ -3913,14 +3960,13 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority, } dev_flow = NULL; /* Add suffix subflow to execute Q/RSS. */ - ret = flow_create_split_inner(dev, flow, &dev_flow, + ret = flow_create_split_inner(dev, flow, &dev_flow, layers, &q_attr, mtr_sfx ? items : q_items, q_actions, external, error); if (ret < 0) goto exit; MLX5_ASSERT(dev_flow); - dev_flow->hash_fields = hash_fields; } exit: @@ -4009,8 +4055,9 @@ uint32_t mlx5_flow_adjust_priority(struct rte_eth_dev *dev, int32_t priority, goto exit; } /* Add the prefix subflow. */ - ret = flow_create_split_inner(dev, flow, &dev_flow, attr, items, - pre_actions, external, error); + ret = flow_create_split_inner(dev, flow, &dev_flow, 0, attr, + items, pre_actions, external, + error); if (ret) { ret = -rte_errno; goto exit; diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index b6e50b1..19f5b61 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -7813,7 +7813,11 @@ struct field_modify_info modify_tcp[] = { MLX5_ASSERT(!flow_dv_check_valid_spec(matcher.mask.buf, dev_flow->dv.value.buf)); #endif - dev_flow->layers = item_flags; + /* + * Layers may be already initialized from prefix flow if this dev_flow + * is the suffix flow. + */ + dev_flow->layers |= item_flags; if (action_flags & MLX5_FLOW_ACTION_RSS) flow_dv_hashfields_set(dev_flow); /* Register matcher. */ From patchwork Thu Feb 20 13:53:44 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Suanming Mou X-Patchwork-Id: 65965 X-Patchwork-Delegate: rasland@nvidia.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 507D7A0556; Thu, 20 Feb 2020 14:54:07 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 7C79B1BFE3; Thu, 20 Feb 2020 14:53:52 +0100 (CET) Received: from git-send-mailer.rdmz.labs.mlnx (unknown [37.142.13.130]) by dpdk.org (Postfix) with ESMTP id 0DB541BF98; Thu, 20 Feb 2020 14:53:49 +0100 (CET) From: Suanming Mou To: matan@mellanox.com, viacheslavo@mellanox.com Cc: dev@dpdk.org, rasland@mellanox.com, stable@dpdk.org Date: Thu, 20 Feb 2020 15:53:44 +0200 Message-Id: <1582206824-103222-3-git-send-email-suanmingm@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1582206824-103222-1-git-send-email-suanmingm@mellanox.com> References: <1582122664-54731-1-git-send-email-suanmingm@mellanox.com> <1582206824-103222-1-git-send-email-suanmingm@mellanox.com> Subject: [dpdk-dev] [PATCH v3 2/2] net/mlx5: fix lack of match information in meter X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" 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") Cc: stable@dpdk.org 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 9267858..da60ce7 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -3778,6 +3778,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 @@ -3794,6 +3796,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[], @@ -3814,7 +3817,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); @@ -3897,7 +3900,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) @@ -4092,7 +4095,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 19f5b61..ebd7a93 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -85,16 +85,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: @@ -640,6 +659,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 @@ -653,8 +674,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); @@ -666,7 +687,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)); @@ -716,6 +737,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 @@ -729,8 +752,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); @@ -742,7 +765,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)); @@ -778,6 +801,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 @@ -790,8 +815,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; @@ -801,7 +826,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)); @@ -7505,7 +7530,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 == @@ -7515,7 +7540,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; @@ -7524,7 +7549,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;