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 C636CA0A0C for ; Tue, 3 Aug 2021 20:13:50 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BAD6E41201; Tue, 3 Aug 2021 20:13:50 +0200 (CEST) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2077.outbound.protection.outlook.com [40.107.93.77]) by mails.dpdk.org (Postfix) with ESMTP id 0FBFB411A7; Tue, 3 Aug 2021 20:13:48 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SNngEJqg/CHNpHvT/TW3dky8o0eeybblq4qBmwuB9bK0Wq5gkY/UA0+EQS7iOuHIFAab6pVxCcq4OLwvOaTVsdNGlFeU9jc6pd3JFvY8IFw1m4SzpHeh0n2h51oCXkevdhlEN0O0YKcWxpnMQdfzPUMc/bDvUoZwvUOk/xm4zYLUyFPr5pQd6S/dJ+zbkKtQ2EM4TbNtgTPMF84E2DYsywWF10AEdCk0OiqVpi0CHwwyNk1GcuFbQS31Ui4VmTuic/xeUumEtaPtuwZBj7JSxOGLHyoTSDMrUHhlIv8hzTtSRZDgnC54MtGopErriwsNL/x+Xpo8aDZ8iKGsDeBoxA== 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-SenderADCheck; bh=P6i+NLhionGhWkeyqCAaagxveZWfU8ysrvjq4T8ybzE=; b=iKpBYumQzM+qQFT7yNcFi1t7VRlTCbUbA0zbsAwSA+s4dP3bXtRASZ/4nXE3Ld+830ekXCfgDNndelPnnIQreW1p83e0FYjzlCgPuXK/HGjCnZyuljHeGf+2qqyLTvLh57iWGkdY4wAtaRqz2JHKTDX+uAg6GFSJTZ6RIDOQSLSSH95LofFvLXtTGHT6Ty9RSQUWG14jP8USr5TSc1SzOGLxEkEZ2fyvw7hXndRVbXwSGGJEKvoEXWlr9gWzZdBotHrqlb7AKv202POkWzOZWpzd/+q0OT1fZVIZ1nUYIlEB8IGDCUpJL6T+xj8Q+CTpWihREjooGB74bZM4Nzu6Tg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=quarantine sp=none 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=P6i+NLhionGhWkeyqCAaagxveZWfU8ysrvjq4T8ybzE=; b=O7ELrGEttN6TbALel2DTq4BoqZJoLJsHbTpsrAp5hq2PzlOpXCXSYNRSlBFZ9wvNZPCc8ddb0racsFE4hqvq90oAXbHNv1UL46g/xKIFrUlkPYYdQogJaKE5GQNzIxNfD1hSHmKxhR6/jwbiqdRBbJVhYQw6jKqIz7jhCxLhGGpcDh4IepOhmj+6GOWlLzhvZXTXy8Hx3eK9+wO3+wFMlnsXLI6i5BwU4u6v2BxII0kC48ICVJFiiYFwXO7ZEJJH9UsRXZ6nnqCfn4LERR5OS5bjUAIhwkFKWs6dsiw3SH5jtYLwlQCAlacyOhrebefh4FbMMh7chN6CT1Ryvkn/Gw== Received: from DM5PR15CA0038.namprd15.prod.outlook.com (2603:10b6:4:4b::24) by DM6PR12MB3162.namprd12.prod.outlook.com (2603:10b6:5:15c::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4373.20; Tue, 3 Aug 2021 18:13:46 +0000 Received: from DM6NAM11FT034.eop-nam11.prod.protection.outlook.com (2603:10b6:4:4b:cafe::c4) by DM5PR15CA0038.outlook.office365.com (2603:10b6:4:4b::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4394.15 via Frontend Transport; Tue, 3 Aug 2021 18:13:46 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.112.34 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.112.34; helo=mail.nvidia.com; Received: from mail.nvidia.com (216.228.112.34) by DM6NAM11FT034.mail.protection.outlook.com (10.13.173.47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4373.18 via Frontend Transport; Tue, 3 Aug 2021 18:13:46 +0000 Received: from DRHQMAIL107.nvidia.com (10.27.9.16) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 3 Aug 2021 18:13:45 +0000 Received: from nvidia.com (172.20.187.6) by DRHQMAIL107.nvidia.com (10.27.9.16) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 3 Aug 2021 18:13:43 +0000 From: Lior Margalit To: Matan Azrad CC: , Lior Margalit , Date: Tue, 3 Aug 2021 21:13:22 +0300 Message-ID: <20210803181322.1409492-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: HQMAIL105.nvidia.com (172.20.187.12) To DRHQMAIL107.nvidia.com (10.27.9.16) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c7cadf24-9f57-487d-762a-08d956aa6f82 X-MS-TrafficTypeDiagnostic: DM6PR12MB3162: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8273; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 6MCgj2eppINuADMFs4CNJCqGkg4gUwEMKW/W5/ZhNp1/9I6Q+BIV4fVz5ngo9zsz8LaKx6UMO+bbeFXiZSPru31uNOvYJJaHSov6R8rTXMCVAgYM927fu+Z4tUOdLtpffbMnlP5UrBjkP2CHs/11WyCFwdi2w9wWataJ4HRjUwiG+XgbIkuh3Ih4DNzrw67+geI1lgj78KHa+QVk0PbKNGzEcgkPZNxrczjA6VhjLQbmiDVjydDNCI/FDK1q79gMlKBCod7Lruw8IyYKXAd42cD2bJFlbiTJ6O+gbWMYTT355LGYQWLg3VSQY1mCUJZJlJEbuOhXH5gesMdyc/RgQUyNP7OvZDinZwgrfY+TyMutOhgr75cuPfyo0nHpn5JDH6edQArOoZV5X3iapU7aYJjsAZl8MfpMHMobPwTzBwXZDaVeSx5fmRliDgqMU17HN3+ru9kt1k5MU92iGA7eMMA5Mzf+gkqfqTJMDMtGgajdz29V538rEVMg/7teoNh/9qi7d7MF+HM3jjpMPMiMsiMKg/F8c0wM7JcVvWLc9Ye+KAWej1dltKS5OY32ANDTFP/uAkVGvWjEIegGmWB6BjIO8m0Jkn0+q2JuZP2nG7SHs3TN4z0xd695EVkbskjbbf9G9hhCGmiX5eKKXlKokErpqQJ9/RmCZe6ZSol7Je1I821EIqK0YLF6ewe+TByecXsQ8z6XPkeYr8HdVe8DoA== X-Forefront-Antispam-Report: CIP:216.228.112.34; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:schybrid03.nvidia.com; CAT:NONE; SFS:(4636009)(376002)(39860400002)(396003)(136003)(346002)(36840700001)(46966006)(4326008)(6636002)(450100002)(6862004)(7696005)(186003)(6666004)(16526019)(26005)(70586007)(70206006)(47076005)(82310400003)(86362001)(6286002)(82740400003)(7636003)(336012)(36906005)(356005)(2616005)(36756003)(83380400001)(426003)(36860700001)(8676002)(5660300002)(1076003)(8936002)(37006003)(316002)(55016002)(478600001)(54906003)(2906002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Aug 2021 18:13:46.3926 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c7cadf24-9f57-487d-762a-08d956aa6f82 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.34]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT034.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3162 Subject: [dpdk-stable] [PATCH v1] net/mlx5: fix RSS expansion for inner tunnel VLAN 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 Sender: "stable" The RSS expansion alg 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 alg. 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 | 97 ++++++++++++++++++------------------ 1 file changed, 48 insertions(+), 49 deletions(-) diff --git a/drivers/net/mlx5/mlx5_flow.c b/drivers/net/mlx5/mlx5_flow.c index 0689e6d45d..858d25f837 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; @@ -308,10 +323,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; @@ -370,6 +392,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) { @@ -404,7 +436,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; @@ -429,10 +462,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, @@ -447,7 +477,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, @@ -473,22 +502,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, @@ -497,6 +511,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 @@ -570,7 +585,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), @@ -581,14 +596,9 @@ static const struct mlx5_flow_expand_node mlx5_support_expansion[] = { MLX5_EXPANSION_IPV6, MLX5_EXPANSION_ETH), .type = RTE_FLOW_ITEM_TYPE_MPLS, - .optional = 1, + .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, }, @@ -596,6 +606,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, @@ -632,10 +643,10 @@ static const struct mlx5_flow_expand_node mlx5_support_expansion[] = { .type = RTE_FLOW_ITEM_TYPE_IPV6_FRAG_EXT, }, [MLX5_EXPANSION_GTP] = { - .next = MLX5_FLOW_EXPAND_RSS_NEXT(MLX5_EXPANSION_IPV4, - MLX5_EXPANSION_IPV6), - .type = RTE_FLOW_ITEM_TYPE_GTP - } + .next = MLX5_FLOW_EXPAND_RSS_NEXT(MLX5_EXPANSION_IPV4, + MLX5_EXPANSION_IPV6), + .type = RTE_FLOW_ITEM_TYPE_GTP, + }, }; static struct rte_flow_action_handle * @@ -3765,20 +3776,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; } @@ -6272,7 +6271,7 @@ flow_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type, int indir_actions_n = MLX5_MAX_INDIRECT_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]; @@ -6363,7 +6362,7 @@ flow_list_create(struct rte_eth_dev *dev, enum mlx5_flow_type type, 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