From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id C9248A0C57 for ; Tue, 30 Nov 2021 13:17:36 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8FEB4410F7; Tue, 30 Nov 2021 13:17:36 +0100 (CET) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2074.outbound.protection.outlook.com [40.107.92.74]) by mails.dpdk.org (Postfix) with ESMTP id 0A1E3410F7 for ; Tue, 30 Nov 2021 13:17:35 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N1WuNzL8wHwJPbZSJWJVIgR/aoGI0wVikQMM5/3C8PXKik0C5Ibl+VAMllqa8DvZoBmQJ6Iq4MrnfLMeoqmAHJjMajZDpqyPF7E/7cj3Ayyvtfp2LyhJ1urrWYSMybqusj+41+xzY+snVr54HVeMSNtt0hQdV76t56TvnHuKs/0b1DNSK37NyXbEazxPv4WwjOuEk39ncNENU4abEgpgIkZ+U8LV+yGeY9fpeeMSB9YG46GWrmxxc/FSADXRDuSwwe1tUqJ60tz/UazinlVf1l92Yxwig0wfpfzV+5byWjR39FrPj+MOwcdxgAAkdRNlzB9/tRIczphSpjHgFflxPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=o4cSwSJQ0FLFI/nwmpSumzG24hHR0CtTVRrd8IM6qCc=; b=CImF/lxkWz2DtdTSvUeCQbTBGtNtk+H4jUTFa7nr0Fckq/m10p+mpcWVe4Qx120NEVd/NtTTgMt5ENIAm1fOawH8jedqVD5RBWTxs/zVC4PDGg8DqFgxmD4LgL/YDyhM1FPE9lfpESDSrkq0vYEh7aPY0Gstz7nXEX5lA4lZQbXxYNcsa+ETjqRTUmeHLo1ai56tWsQlTyJodE2W13cawunZJzf8zUUYtSGSBt9HtRrPa7MEyeBWwM6WJhIh98NQFP78l+GEfwZksNTXB1Al3e22Y+fwPMxWr3C94+wRf3YxtA6XwDxzK/K02GijXPMaGlmADzF+Rnq2cSgu1k8Wnw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.32) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=o4cSwSJQ0FLFI/nwmpSumzG24hHR0CtTVRrd8IM6qCc=; b=GJZXUW6Ys7z0HLb9DmvzzWeJ1m9zrjQRYGUBRMlVdS0U1kFkT3qzqm31wsAJPXf+AOgw9YV6fy/Amr6bcgjIZTUBJ9qi4esK3kgYtj0xWJoi8C7q12WuB2ET73dILWiYKptu2IgWzxNVjIwVGqGy7RF2ZJ7uSBfi0nN8IlXZV3g9+C9gWkt92OEK9MUJieb+cMgreng4FJRn/WxlJTBUkdw9ORlnFvBu7ABqf32G9E/nqaIDYBasKXjKPhFKROxCjPFVG9plP3WHwq5bzLRviRQ4BFwYYxQ2SES/lwMCe8SKiClMnzT2p2BwyyrQnKzDixDsNpJwu9+kxDjqOQYSXQ== Received: from BN9PR03CA0850.namprd03.prod.outlook.com (2603:10b6:408:13d::15) by BYAPR12MB4792.namprd12.prod.outlook.com (2603:10b6:a03:108::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.23; Tue, 30 Nov 2021 12:17:32 +0000 Received: from BN8NAM11FT062.eop-nam11.prod.protection.outlook.com (2603:10b6:408:13d:cafe::a5) by BN9PR03CA0850.outlook.office365.com (2603:10b6:408:13d::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4734.23 via Frontend Transport; Tue, 30 Nov 2021 12:17:32 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.32) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.32 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.32; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.32) by BN8NAM11FT062.mail.protection.outlook.com (10.13.177.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4734.22 via Frontend Transport; Tue, 30 Nov 2021 12:17:31 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by HQMAIL109.nvidia.com (172.20.187.15) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Tue, 30 Nov 2021 04:17:31 -0800 Received: from nvidia.com (172.20.187.6) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.2.986.5; Tue, 30 Nov 2021 04:17:29 -0800 From: Lior Margalit To: Matan Azrad CC: Lior Margalit , Subject: [PATCH 20.11 1/5] net/mlx5: fix RSS expansion for inner tunnel VLAN Date: Tue, 30 Nov 2021 14:17:10 +0200 Message-ID: <20211130121714.4170879-1-lmargalit@nvidia.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.187.6] X-ClientProxiedBy: HQMAIL111.nvidia.com (172.20.187.18) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 708d071c-8048-4e6b-87f9-08d9b3fb6270 X-MS-TrafficTypeDiagnostic: BYAPR12MB4792: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1388; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 8BZUU1nNQo9kTLzLPd6Hpo2mII5XzF3ZHGSdalSHjoOxShAhlmCuAIWIWkgxCq7c6YKv1reHB7YsN8VJ+q6PRsooHWd+3lE5Oq7kL9WIAbYlHtngPM2dzvR01uaJbe2B1PRrCTGcRWHSYrrLxvxxFUCaGxai+MUBSDC/fw2IX8rjBIXGOzooYFihNIdcA3wDJHf1rervhJAcF2iXG63c3ZEuFFiZivo8Hc0fgFKJcQzHmxnk0AYqASWvncrwxKINycBsNSt6TgGCiCZHC9V/BB6vBxPSqmYlT1AHYTo1uJRkTQ0MQFvRT5X66amapPemDs43VRXSElIv8FMp34kpZ1aQ5/FtvEOvrmIvmVP8isP9KCkx0sqXJ/WcMJdyLVKpbAJuNZRd6StvHGg59fzFJcYBucCYGb9y7LpW41X3aU7SYQ4BhJB6CvW5BMwLxRK/y6tF4z3a5H/xECiRoHZsMAR6AVbQhQiL1JmpzPCT9vSWJHWi1N/0DODMiOxjVNEMj1lVsX9BiU+ld8YKrte38dmIv6YuUMnaceE8yJtZRn9gd2ZIlWRj6eelAnw1OEDBssT4zn+bT3iQ91o3SYS1mWjgVyuzAjqXPa/xXWb+indU1kj4hD3cYi2Fzrj/4IrIIhvUftv2lH+vUY9b9FZsXdKrjIzNDE+0qfImwGj2NOMyapow/q4TTJ9xi+RqhLBaQIi6ScF/IXewZFl1cNh6cazgBuQeNZHYnop6cB0DzltjjqYsyCwrZLG+w/P94fQwvPpmSp6QclAaoB1SiS7/WQ== X-Forefront-Antispam-Report: CIP:216.228.112.32; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid01.nvidia.com; CAT:NONE; SFS:(4636009)(46966006)(36840700001)(40470700001)(47076005)(6862004)(54906003)(82310400004)(37006003)(2906002)(6286002)(55016003)(70206006)(7696005)(316002)(86362001)(508600001)(356005)(36860700001)(7636003)(70586007)(16526019)(2616005)(1076003)(8936002)(36756003)(4326008)(6636002)(8676002)(83380400001)(6666004)(336012)(426003)(186003)(5660300002)(40460700001)(26005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 30 Nov 2021 12:17:31.7632 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 708d071c-8048-4e6b-87f9-08d9b3fb6270 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.112.32]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT062.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB4792 X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 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 [ upstream commit 3f02c7ff6815286dfe81efbf2db196bdafc752b3 ] The RSS expansion algorithm is using a graph to find the possible expansion paths. The VLAN item in the flow pattern requires special treatment, because it should not be added implicitly by the expansion algorithm. If the flow pattern ends with ETH item, the pattern will be expanded with IPv4 and IPv6. For example: testpmd> flow create ... eth / end actions rss / end ETH END ETH IPV4 END ETH IPV6 END If a VLAN item follows the ETH item in the flow pattern, the pattern will be expanded with IPv4 and IPv6 following the VLAN item. For example: testpmd> flow create ... eth / vlan / end actions rss level 1 / end ETH VLAN END ETH VLAN IPV4 END ETH VLAN IPV6 END The case of inner tunnel VLAN item was not taken care of so the flow pattern did not expand with IPv6 and IPv4 as expected. Example with inner VLAN: testpmd> flow create ... / vxlan / eth / vlan / end actions rss level 2 / end The current result of the expansion alg: ETH IPV6 UDP VXLAN ETH VLAN END The expected result of the expansion alg: ETH IPV6 UDP VXLAN ETH VLAN END ETH IPV6 UDP VXLAN ETH VLAN IPV4 END ETH IPV6 UDP VXLAN ETH VLAN IPV6 END The fix is to introduce a new flag to set on a graph expansion node to apply the 'explicit' behavior, meaning the node is not added to the expanded pattern, if it is not found in the flow pattern, but the expansion alg can go deeper to its next nodes. Fixes: c7870bfe09dc ("ethdev: move RSS expansion code to mlx5 driver") Cc: stable@dpdk.org Signed-off-by: Lior Margalit Acked-by: Matan Azrad --- drivers/net/mlx5/mlx5_flow.c | 88 ++++++++++++++++++------------------ 1 file changed, 44 insertions(+), 44 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 3c35b87964..2b916899e8 100644 --- a/drivers/net/mlx5/mlx5_flow.c +++ b/drivers/net/mlx5/mlx5_flow.c @@ -100,10 +100,25 @@ struct mlx5_flow_expand_node { * RSS types bit-field associated with this node * (see ETH_RSS_* definitions). */ - uint8_t optional; - /**< optional expand field. Default 0 to expand, 1 not go deeper. */ + uint64_t node_flags; + /**< + * Bit-fields that define how the node is used in the expansion. + * (see MLX5_EXPANSION_NODE_* definitions). + */ }; +/* Optional expand field. The expansion alg will not go deeper. */ +#define MLX5_EXPANSION_NODE_OPTIONAL (UINT64_C(1) << 0) + +/* The node is not added implicitly as expansion to the flow pattern. + * If the node type does not match the flow pattern item type, the + * expansion alg will go deeper to its next items. + * In the current implementation, the list of next nodes indexes can + * have up to one node with this flag set and it has to be the last + * node index (before the list terminator). + */ +#define MLX5_EXPANSION_NODE_EXPLICIT (UINT64_C(1) << 1) + /** Object returned by mlx5_flow_expand_rss(). */ struct mlx5_flow_expand_rss { uint32_t entries; @@ -331,10 +346,17 @@ mlx5_flow_expand_rss(struct mlx5_flow_expand_rss *buf, size_t size, continue; } last_item = item; - for (i = 0; node->next && node->next[i]; ++i) { + i = 0; + while (node->next && node->next[i]) { next = &graph[node->next[i]]; if (next->type == item->type) break; + if (next->node_flags & MLX5_EXPANSION_NODE_EXPLICIT) { + node = next; + i = 0; + } else { + ++i; + } } if (next) node = next; @@ -393,6 +415,16 @@ mlx5_flow_expand_rss(struct mlx5_flow_expand_rss *buf, size_t size, } memset(flow_items, 0, sizeof(flow_items)); next_node = node->next; + while (next_node) { + /* + * Skip the nodes with the MLX5_EXPANSION_NODE_EXPLICIT + * flag set, because they were not found in the flow pattern. + */ + node = &graph[*next_node]; + if (!(node->node_flags & MLX5_EXPANSION_NODE_EXPLICIT)) + break; + next_node = node->next; + } stack[stack_pos] = next_node; node = next_node ? &graph[*next_node] : NULL; while (node) { @@ -427,7 +459,8 @@ mlx5_flow_expand_rss(struct mlx5_flow_expand_rss *buf, size_t size, addr = (void *)(((uintptr_t)addr) + n); } /* Go deeper. */ - if (!node->optional && node->next) { + if (!(node->node_flags & MLX5_EXPANSION_NODE_OPTIONAL) && + node->next) { next_node = node->next; if (stack_pos++ == MLX5_RSS_EXP_ELT_N) { rte_errno = E2BIG; @@ -452,10 +485,7 @@ mlx5_flow_expand_rss(struct mlx5_flow_expand_rss *buf, size_t size, enum mlx5_expansion { MLX5_EXPANSION_ROOT, MLX5_EXPANSION_ROOT_OUTER, - MLX5_EXPANSION_ROOT_ETH_VLAN, - MLX5_EXPANSION_ROOT_OUTER_ETH_VLAN, MLX5_EXPANSION_OUTER_ETH, - MLX5_EXPANSION_OUTER_ETH_VLAN, MLX5_EXPANSION_OUTER_VLAN, MLX5_EXPANSION_OUTER_IPV4, MLX5_EXPANSION_OUTER_IPV4_UDP, @@ -470,7 +500,6 @@ enum mlx5_expansion { MLX5_EXPANSION_GRE_KEY, MLX5_EXPANSION_MPLS, MLX5_EXPANSION_ETH, - MLX5_EXPANSION_ETH_VLAN, MLX5_EXPANSION_VLAN, MLX5_EXPANSION_IPV4, MLX5_EXPANSION_IPV4_UDP, @@ -497,22 +526,7 @@ static const struct mlx5_flow_expand_node mlx5_support_expansion[] = { MLX5_EXPANSION_OUTER_IPV6), .type = RTE_FLOW_ITEM_TYPE_END, }, - [MLX5_EXPANSION_ROOT_ETH_VLAN] = { - .next = MLX5_FLOW_EXPAND_RSS_NEXT(MLX5_EXPANSION_ETH_VLAN), - .type = RTE_FLOW_ITEM_TYPE_END, - }, - [MLX5_EXPANSION_ROOT_OUTER_ETH_VLAN] = { - .next = MLX5_FLOW_EXPAND_RSS_NEXT - (MLX5_EXPANSION_OUTER_ETH_VLAN), - .type = RTE_FLOW_ITEM_TYPE_END, - }, [MLX5_EXPANSION_OUTER_ETH] = { - .next = MLX5_FLOW_EXPAND_RSS_NEXT(MLX5_EXPANSION_OUTER_IPV4, - MLX5_EXPANSION_OUTER_IPV6), - .type = RTE_FLOW_ITEM_TYPE_ETH, - .rss_types = 0, - }, - [MLX5_EXPANSION_OUTER_ETH_VLAN] = { .next = MLX5_FLOW_EXPAND_RSS_NEXT(MLX5_EXPANSION_OUTER_VLAN), .type = RTE_FLOW_ITEM_TYPE_ETH, .rss_types = 0, @@ -521,6 +535,7 @@ static const struct mlx5_flow_expand_node mlx5_support_expansion[] = { .next = MLX5_FLOW_EXPAND_RSS_NEXT(MLX5_EXPANSION_OUTER_IPV4, MLX5_EXPANSION_OUTER_IPV6), .type = RTE_FLOW_ITEM_TYPE_VLAN, + .node_flags = MLX5_EXPANSION_NODE_EXPLICIT, }, [MLX5_EXPANSION_OUTER_IPV4] = { .next = MLX5_FLOW_EXPAND_RSS_NEXT @@ -597,7 +612,7 @@ static const struct mlx5_flow_expand_node mlx5_support_expansion[] = { MLX5_EXPANSION_IPV6, MLX5_EXPANSION_MPLS), .type = RTE_FLOW_ITEM_TYPE_GRE_KEY, - .optional = 1, + .node_flags = MLX5_EXPANSION_NODE_OPTIONAL, }, [MLX5_EXPANSION_NVGRE] = { .next = MLX5_FLOW_EXPAND_RSS_NEXT(MLX5_EXPANSION_ETH), @@ -608,13 +623,9 @@ static const struct mlx5_flow_expand_node mlx5_support_expansion[] = { MLX5_EXPANSION_IPV6, MLX5_EXPANSION_ETH), .type = RTE_FLOW_ITEM_TYPE_MPLS, + .node_flags = MLX5_EXPANSION_NODE_OPTIONAL, }, [MLX5_EXPANSION_ETH] = { - .next = MLX5_FLOW_EXPAND_RSS_NEXT(MLX5_EXPANSION_IPV4, - MLX5_EXPANSION_IPV6), - .type = RTE_FLOW_ITEM_TYPE_ETH, - }, - [MLX5_EXPANSION_ETH_VLAN] = { .next = MLX5_FLOW_EXPAND_RSS_NEXT(MLX5_EXPANSION_VLAN), .type = RTE_FLOW_ITEM_TYPE_ETH, }, @@ -622,6 +633,7 @@ static const struct mlx5_flow_expand_node mlx5_support_expansion[] = { .next = MLX5_FLOW_EXPAND_RSS_NEXT(MLX5_EXPANSION_IPV4, MLX5_EXPANSION_IPV6), .type = RTE_FLOW_ITEM_TYPE_VLAN, + .node_flags = MLX5_EXPANSION_NODE_EXPLICIT, }, [MLX5_EXPANSION_IPV4] = { .next = MLX5_FLOW_EXPAND_RSS_NEXT(MLX5_EXPANSION_IPV4_UDP, @@ -3458,20 +3470,8 @@ flow_get_shared_rss_action(struct rte_eth_dev *dev, } static unsigned int -find_graph_root(const struct rte_flow_item pattern[], uint32_t rss_level) +find_graph_root(uint32_t rss_level) { - const struct rte_flow_item *item; - unsigned int has_vlan = 0; - - for (item = pattern; item->type != RTE_FLOW_ITEM_TYPE_END; item++) { - if (item->type == RTE_FLOW_ITEM_TYPE_VLAN) { - has_vlan = 1; - break; - } - } - if (has_vlan) - return rss_level < 2 ? MLX5_EXPANSION_ROOT_ETH_VLAN : - MLX5_EXPANSION_ROOT_OUTER_ETH_VLAN; return rss_level < 2 ? MLX5_EXPANSION_ROOT : MLX5_EXPANSION_ROOT_OUTER; } @@ -5361,7 +5361,7 @@ flow_list_create(struct rte_eth_dev *dev, uint32_t *list, int shared_actions_n = MLX5_MAX_SHARED_ACTIONS; union { struct mlx5_flow_expand_rss buf; - uint8_t buffer[2048]; + uint8_t buffer[4096]; } expand_buffer; union { struct rte_flow_action actions[MLX5_MAX_SPLIT_ACTIONS]; @@ -5451,7 +5451,7 @@ flow_list_create(struct rte_eth_dev *dev, uint32_t *list, if (rss && rss->types) { unsigned int graph_root; - graph_root = find_graph_root(items, rss->level); + graph_root = find_graph_root(rss->level); ret = mlx5_flow_expand_rss(buf, sizeof(expand_buffer.buffer), items, rss->types, mlx5_support_expansion, graph_root); -- 2.25.1