From patchwork Thu Sep 24 14:52:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dekel Peled X-Patchwork-Id: 78754 X-Patchwork-Delegate: ferruh.yigit@amd.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 3677AA04B5; Thu, 24 Sep 2020 16:54:00 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C2D631DEE6; Thu, 24 Sep 2020 16:53:56 +0200 (CEST) Received: from mellanox.co.il (mail-il-dmz.mellanox.com [193.47.165.129]) by dpdk.org (Postfix) with ESMTP id 10F1C1DEE0 for ; Thu, 24 Sep 2020 16:53:54 +0200 (CEST) Received: from Internal Mail-Server by MTLPINE1 (envelope-from dekelp@nvidia.com) with SMTP; 24 Sep 2020 17:53:52 +0300 Received: from mtl-vdi-280.wap.labs.mlnx. (mtl-vdi-280.wap.labs.mlnx [10.228.134.250]) by labmailer.mlnx (8.13.8/8.13.8) with ESMTP id 08OErlcO010486; Thu, 24 Sep 2020 17:53:51 +0300 From: Dekel Peled To: orika@mellanox.com, thomas@monjalon.net, ferruh.yigit@intel.com, arybchenko@solarflare.com Cc: dev@dpdk.org, matan@nvidia.com, stable@dpdk.org Date: Thu, 24 Sep 2020 17:52:13 +0300 Message-Id: <1777a273ed2b61aaec57d34852576e01c95626ee.1600958661.git.dekelp@nvidia.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: References: Subject: [dpdk-dev] [PATCH v2 1/2] ethdev: fix RSS flow expansion in case of mismatch 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" Function rte_flow_expand_rss() is used to expand a flow rule with partial pattern into several rules, to ensure all relevant packets are matched. It uses utility function rte_flow_expand_rss_item_complete(), to check if the last valid item in the flow rule pattern needs to be completed. For example the pattern "eth / ipv4 proto is 17 / end" will be completed with a "udp" item. This function returns "void" item in two cases: 1) The last item has empty spec, for example "eth / ipv4 / end". 2) The last itme has spec that can't be expanded for RSS. For example the pattern "eth / ipv4 proto is 47 / end" ends with IPv4 item that has next protocol GRE. In both cases the flow rule may be expanded, but in the second case such expansion may create rules with invalid pattern. For example "eth / ipv4 proto is 47 / udp / end". In such a case the flow rule should not be expanded. This patch updates function rte_flow_expand_rss_item_complete(). Return value RTE_FLOW_ITEM_TYPE_END is used to indicate the flow rule should not be expanded. In such a case, rte_flow_expand_rss() will return with the original flow rule only, without any expansion. Fixes: fc2dd8dd492f ("ethdev: fix expand RSS flows") Cc: stable@dpdk.org Signed-off-by: Dekel Peled Acked-by: Xiaoyu Min Acked-by: Viacheslav Ovsiienko Acked-by: Ori Kam --- lib/librte_ethdev/rte_flow.c | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/lib/librte_ethdev/rte_flow.c b/lib/librte_ethdev/rte_flow.c index f8fdd68..59a386d 100644 --- a/lib/librte_ethdev/rte_flow.c +++ b/lib/librte_ethdev/rte_flow.c @@ -247,6 +247,8 @@ struct rte_flow_desc_data { ret = RTE_FLOW_ITEM_TYPE_IPV6; else if (rte_be_to_cpu_16(ether_type) == RTE_ETHER_TYPE_VLAN) ret = RTE_FLOW_ITEM_TYPE_VLAN; + else + ret = RTE_FLOW_ITEM_TYPE_END; break; case RTE_FLOW_ITEM_TYPE_VLAN: if (item->mask) @@ -264,6 +266,8 @@ struct rte_flow_desc_data { ret = RTE_FLOW_ITEM_TYPE_IPV6; else if (rte_be_to_cpu_16(ether_type) == RTE_ETHER_TYPE_VLAN) ret = RTE_FLOW_ITEM_TYPE_VLAN; + else + ret = RTE_FLOW_ITEM_TYPE_END; break; case RTE_FLOW_ITEM_TYPE_IPV4: if (item->mask) @@ -284,6 +288,8 @@ struct rte_flow_desc_data { ret = RTE_FLOW_ITEM_TYPE_IPV4; else if (ip_next_proto == IPPROTO_IPV6) ret = RTE_FLOW_ITEM_TYPE_IPV6; + else + ret = RTE_FLOW_ITEM_TYPE_END; break; case RTE_FLOW_ITEM_TYPE_IPV6: if (item->mask) @@ -304,6 +310,8 @@ struct rte_flow_desc_data { ret = RTE_FLOW_ITEM_TYPE_IPV4; else if (ip_next_proto == IPPROTO_IPV6) ret = RTE_FLOW_ITEM_TYPE_IPV6; + else + ret = RTE_FLOW_ITEM_TYPE_END; break; default: ret = RTE_FLOW_ITEM_TYPE_VOID; @@ -1110,10 +1118,14 @@ enum rte_flow_conv_item_spec_type { memset(flow_items, 0, sizeof(flow_items)); user_pattern_size -= sizeof(*item); /* - * Check if the last valid item has spec set - * and need complete pattern. + * Check if the last valid item has spec set, need complete pattern, + * and the pattern can be used for expansion. */ missed_item.type = rte_flow_expand_rss_item_complete(last_item); + if (missed_item.type == RTE_FLOW_ITEM_TYPE_END) { + /* Item type END indicates expansion is not required. */ + return lsize; + } if (missed_item.type != RTE_FLOW_ITEM_TYPE_VOID) { next = NULL; missed = 1;