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 28DF4A0C43 for ; Mon, 15 Nov 2021 12:35:40 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 150174113E; Mon, 15 Nov 2021 12:35:40 +0100 (CET) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2054.outbound.protection.outlook.com [40.107.220.54]) by mails.dpdk.org (Postfix) with ESMTP id E92E240141; Mon, 15 Nov 2021 12:35:37 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=J/KqF2PLMHpoAs6lF5mt7ytg6mKFfrtsWGRQb9qzOIi19Hiln8e6HRYjww6QfqdpUtuvHj7kr8HCpeCAF11x5flL+Mbfk3SnYcE1x2hDBtG9xR0Mdmo+x9mi9DdJ4aSbQxbXYjlmPWZrVDpDm4jUFNS39OVffjX3Cn0z0MEfSHoxr9fGX3CVA0KljpZOm742KL1mpLWnYcG5+hyvGGQc7JgjyHoTmf2Wd5fqZKs1mh42FtKw2+peBEI42MysJwfrISghZ9l8wAijS0T/wvrEMl+/zk13Ti7BpgzPOF9Owt68pD2BUNfK5AV+pk8n2f1Z2MrFxkjT+HslGbkQs24S9A== 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=MyaKYr1pF+v26wC5LjNuC1WGOTgMNoilLq1pWKkghhM=; b=JtjwB/CDeMZEplcZddPW7HXEjGIoBdmpn1cobchl+ufrZNOmR3WWRohGrzs+ukv+RS6/I/G4GoD37BuGB9ODsaJNQYMxKGScMCQ+HmYM3f7W5tsn1G35UYG+IIv6sbqn3g0MrwUaO1TWNyt7BYJ6bOXW2dpRocaY3mzuiPgxl0AaSS5W8D5CQ8OrNvWN8j3BUIiurJkYRxjHIDgjQlotIEfaLjBDF9wWgmo1rmRssNwipVnJZOLLeaDaN8/aCqGUZ4gBsPIFAxwxnnpwKIq56W7EQZiasTnL2EPq6FQ8Ny4EbUjeQMmjpGM/bKQWVixAgZeT4yrz7tCtkWcWIivg1g== 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=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=MyaKYr1pF+v26wC5LjNuC1WGOTgMNoilLq1pWKkghhM=; b=gM3MoGKZn/03yXg4+4JZGMMxHXL2Bv1TdNK1vlhb3iIN2aIOiYT9YZpcm45LzMRcgOiN2qCMcr4fX0CpcXJpomE3j5wFVsa56QdCi/4wzGv0Lvu8p6vWGsPVU9IigqGp3cDwVYIWzyVUb1Sz/8H0IN/3snWY1n1nxwcmxp/J133FV0APA3kWaJIbKvxts/FGB6Sf26WSCpcOO+iYBWDI+hV/jtoQVf0CPXiN8QE2JCQpvJZPqA6j11oUB3WICfc4z/ddSGdkSyMk6Mjo7tJ8PYaGhCyTuNhRfDDJrPsDhRJOavPKOTgZu9x5FTEl6zvArshYIKDtmQ3Swwh5hrdQRQ== Received: from DM3PR08CA0005.namprd08.prod.outlook.com (2603:10b6:0:52::15) by MN2PR12MB4816.namprd12.prod.outlook.com (2603:10b6:208:1b5::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.26; Mon, 15 Nov 2021 11:35:35 +0000 Received: from DM6NAM11FT010.eop-nam11.prod.protection.outlook.com (2603:10b6:0:52:cafe::4) by DM3PR08CA0005.outlook.office365.com (2603:10b6:0:52::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.15 via Frontend Transport; Mon, 15 Nov 2021 11:35:35 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) 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.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 DM6NAM11FT010.mail.protection.outlook.com (10.13.172.222) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4690.15 via Frontend Transport; Mon, 15 Nov 2021 11:35:34 +0000 Received: from nvidia.com (172.20.187.6) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 15 Nov 2021 11:35:32 +0000 From: Bing Zhao To: , CC: , , , Subject: [PATCH] net/mlx5: fix missing RSS validation with meter policy Date: Mon, 15 Nov 2021 13:35:18 +0200 Message-ID: <20211115113518.1654183-1-bingz@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: HQMAIL101.nvidia.com (172.20.187.10) To HQMAIL107.nvidia.com (172.20.187.13) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: a7029e5b-1601-47b9-ba21-08d9a82c09fd X-MS-TrafficTypeDiagnostic: MN2PR12MB4816: X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xxIHk426M8Jqn+lYHSUM/KqJqjuS5DZTii6BOca4POuojUldHxwH5wHM+WTbZqAVODtbpvTGnKzeutlOUP4AjBWjuSEiq9FwEqMxwhOsPlW+PU185+y6Nk2ohgZyZHA4ks6nCubPSuaQQ0bqGT9iLo293yDCWsU7tJ1TS6EiF0vDSSnKMusour0l/VwW7OZyWrGELeehfIf9SdjK66BJL37MMYrZ8wagHYPTTXfF2yDk38G1Sf8W/Y+Cas6D0NdRq/4iEZRSSkbNtPKalb91KwPbjoekDwlb78yPFQVsiL7leuO1APOxwa8M8/RtoExlKCnDDe0618+hVkS6trg6GbxBAo7fz25QF1HvnTFkmnNu4r5Ii1wWs+uj8hX/ovujjG44ey7cM9h/tqcbtbgBfHxnXJk7o31FbqUgt0ot5ToEDKxOR5dOtRdPKb5CmdlNvSKUYqF68uQx/LnDHHgZseBp6vkrpzAGXRt3Rt7XE5VDdoce6FltC8qTRgRfZlLJeXNaOnhkajX1J9M/i9Tq1isFzIXMFFoHadYd22TsGj8FM+9Lh3AsjBEig8b3+PGhQDgYkBIdbf8UnCgWTjElSKGs7tDP1jM+nWHUp8ZolrlmZWbrgrDjoM+ikOLpTPeWeAr+71J+Ti/RmtT8/lduoEJ+/hAe7mSl4Bngx5wxHEK9mYB2upLK9AePFDmDPZSoZmBWcHCfdlMqYrH4U+MYNg== 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)(36840700001)(46966006)(186003)(356005)(47076005)(16526019)(336012)(426003)(36860700001)(54906003)(1076003)(6286002)(6636002)(7636003)(6666004)(2616005)(450100002)(70586007)(70206006)(8936002)(4326008)(5660300002)(110136005)(508600001)(316002)(55016002)(83380400001)(2906002)(26005)(36756003)(7696005)(86362001)(8676002)(82310400003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Nov 2021 11:35:34.6577 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a7029e5b-1601-47b9-ba21-08d9a82c09fd 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: DM6NAM11FT010.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN2PR12MB4816 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 The RSS can be one of the fate actions when creating a meter with policy. In the previous implementation, the RSS validation was missed when creating a flow rule with such meter due to the fact that a policy meter was created firstly and then used in the rule. In the stage of meter creation, no rte_flow_item* information was provided. A unnecessary RSS expansion might be called since the validation was missed and would cause an unexpected error of the rule creation. Even though the rule should be rejected from the very beginning, it would cause confusion. There might be some other errors when the validation was missed. Adding the RSS validation inside the meter action validation will prevent the code from continuing when there is a conflict between the items, other actions and the policy meter RSS action. Fixes: 444320186393 ("net/mlx5: support meter creation with policy") Cc: lizh@nvidia.com Cc: stable@dpdk.org Signed-off-by: Bing Zhao Acked-by: Matan Azrad --- drivers/net/mlx5/mlx5_flow_dv.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index 287a17d956..da975e0351 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -5133,6 +5133,8 @@ flow_dv_modify_hdr_action_max(struct rte_eth_dev *dev __rte_unused, * Pointer to rte_eth_dev structure. * @param[in] action_flags * Bit-fields that holds the actions detected until now. + * @param[in] item_flags + * Holds the items detected. * @param[in] action * Pointer to the meter action. * @param[in] attr @@ -5147,7 +5149,7 @@ flow_dv_modify_hdr_action_max(struct rte_eth_dev *dev __rte_unused, */ static int mlx5_flow_validate_action_meter(struct rte_eth_dev *dev, - uint64_t action_flags, + uint64_t action_flags, uint64_t item_flags, const struct rte_flow_action *action, const struct rte_flow_attr *attr, const struct rte_flow_item *port_id_item, @@ -5251,6 +5253,27 @@ mlx5_flow_validate_action_meter(struct rte_eth_dev *dev, NULL, "Flow and meter policy " "have different src port."); + } else if (mtr_policy->is_rss) { + struct mlx5_meter_policy_action_container *acg = + &mtr_policy->act_cnt[RTE_COLOR_GREEN]; + struct mlx5_meter_policy_action_container *acy = + &mtr_policy->act_cnt[RTE_COLOR_YELLOW]; + const struct rte_flow_action *rss_act; + int ret; + + MLX5_ASSERT(acg->fate_action == + MLX5_FLOW_FATE_SHARED_RSS || + acy->fate_action == + MLX5_FLOW_FATE_SHARED_RSS); + if (acg->fate_action == MLX5_FLOW_FATE_SHARED_RSS) + rss_act = acg->rss; + else rss_act = acy->rss; + + ret = mlx5_flow_validate_action_rss(rss_act, + action_flags, dev, attr, + item_flags, error); + if (ret) + return ret; } *def_policy = false; } @@ -7684,6 +7707,7 @@ flow_dv_validate(struct rte_eth_dev *dev, const struct rte_flow_attr *attr, case RTE_FLOW_ACTION_TYPE_METER: ret = mlx5_flow_validate_action_meter(dev, action_flags, + item_flags, actions, attr, port_id_item, &def_policy, -- 2.21.0