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 1041AA0032; Mon, 15 Nov 2021 15:51:42 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 8C62040E01; Mon, 15 Nov 2021 15:51:41 +0100 (CET) Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2041.outbound.protection.outlook.com [40.107.243.41]) by mails.dpdk.org (Postfix) with ESMTP id 5E9EB40141; Mon, 15 Nov 2021 15:51:40 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=CaKUckyH1+rMZFbjmYRzG5YXSCpd7gbKM4vcEKj7t4TnZWEIKkdVaExX5x51YpLTAR4fHobWCSZcTIex2n471rXI1vxUJjy3zKTfF0M3atpEjht+tjwhhBo5rh2ZtW1A1miR4CcUMWdKh2zG+woiIQiAcsDdv/Jx2ohy/wnwJeg4EVkm45ZUZ30/gi5F3teKtBPNVn036sKjVK8s6UOI7Q7P2nmopbT0GFHTQahL7XCM0GpUx1T9OB7lHb2+s4aDb0Lf6TpDMmANpTLkThX/X98W2I0cJlXGgJT2JqsjiL31s8l1Ez1iQ4rnXNEMTyje2Zj3B+jdKifAYUwgbvguNQ== 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=QfmIhzB7UYYEmrGYgT8+uk5bm/vA1ny1EWWFRKozxzo=; b=QRSyqokvYHDJy2OQas47RMWzgbzkh3w44fdqAZZpPgGgqlCKg6SYep2DCxuSPxNAVDXkGSvc3PZ7bCGamyi+a9/dnQw3zQhkIObQm2OPD1okPgjznRLn5mq5pOmwqp0WTJkpy16O4p8gFlxetjOtonWolXiWnwrMJC8Ns7bprj0NK/rpcZGlNHAdDkQFfQY9TyjVKUJg3nOn6/e6DrLaCmwgMJU32c81sphbhjfRnH30N1OrFZQRDcT9IBmbVYxSOvluCQzC4pDTQ8UwgUYHVqefXbK3dak/PWMHXJL04Xv682li6XKH0S1Yo54eIY+sfNT13Ywtza3DksYjuwBXNw== 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=QfmIhzB7UYYEmrGYgT8+uk5bm/vA1ny1EWWFRKozxzo=; b=AzF5stGDfI4yqDLyxYgIUaipU+Ki/c3dVjV85z+J1ejB69PpvWwJmxo/UxnZR40QENPAm7BpjOdiTintIMZDM00HDYHeNollJErVkMEhezYOO1rz9hjzQGMgSwrOu5AiO4/hmIjOulXz8yvXAyJhASA2H/QD1yIeTSCtqMCIkHaCfJ4fwvsHl1mtmYxlzryMcUD37ewnll1HPCg0sGSyYuoWTbXTslTpFthMMrWBobNnweHmipY/eG6ENmHGtSj15ZNbUCgKnAvxz7WVMqd4J3FNS6MrgXBcqmzfWyzZpsYNrJaw/Rk7qPjB0x9K0OTfGFtrDcXiaoiQO8tsEiG+4g== Received: from DM5PR13CA0052.namprd13.prod.outlook.com (2603:10b6:3:117::14) by DM6PR12MB2681.namprd12.prod.outlook.com (2603:10b6:5:41::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4690.27; Mon, 15 Nov 2021 14:51:38 +0000 Received: from DM6NAM11FT011.eop-nam11.prod.protection.outlook.com (2603:10b6:3:117:cafe::a7) by DM5PR13CA0052.outlook.office365.com (2603:10b6:3:117::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4713.15 via Frontend Transport; Mon, 15 Nov 2021 14:51:38 +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 DM6NAM11FT011.mail.protection.outlook.com (10.13.172.108) 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 14:51:38 +0000 Received: from nvidia.com (172.20.187.5) by HQMAIL107.nvidia.com (172.20.187.13) with Microsoft SMTP Server (TLS) id 15.0.1497.18; Mon, 15 Nov 2021 14:51:36 +0000 From: Bing Zhao To: , CC: , , , Subject: [PATCH v2] net/mlx5: fix missing RSS validation with meter policy Date: Mon, 15 Nov 2021 16:51:21 +0200 Message-ID: <20211115145121.1663173-1-bingz@nvidia.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20211115113518.1654183-1-bingz@nvidia.com> References: <20211115113518.1654183-1-bingz@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [172.20.187.5] 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: e51f9a2b-f0e8-4074-ad7f-08d9a8476d90 X-MS-TrafficTypeDiagnostic: DM6PR12MB2681: 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: AQTxk+QKU93V9G3NpwiOsXjjORlhC/h8AcNOJZX2bUDTUiJXhOfzHlHHIlAE4DIG7h/KHemm7+XKOfA2pQiIrTvlsjgwmbXec2Mh5eb5lUJmnOnHjMcG061YsdzLl78EeWtsCi1Y6NVUb+R9MlNRLnNlg/m5Q2iRjNL6bjWZ0H6IgcvaMzqTkib6v1ifc7auuEQsUHKeBMVplnlmfZeL2Lq79Vq6K2TphbpbpghVvLYvalvXt4miIdUKsYVOK17Y/C6iS7viJ163PDlT3vPOQr19SiBuPBGR+uiRiCOLPoquJHCLV+8HTM5ZUfDLbmcohZqCQkqIW7xeN2CB4kH6aToducf5UABTRqDsiGr75O3LxgMcSF8x6hNBexjKZFN0kitT6h/cKRf+rP7ah31xrR115Tv6McZVySwyAzfIsABkCLu4VSTdn7ff5qwyGytTYK+4uE5NMpNANDWq0/JUeZB9BNQkQKMYrL40v3tkWcasZOnSGriJq/3Xd5zi/IR0LBBnmUYU7SQqdrcvA0dIcb9HzFwja9BgbhgpNLiQP3x8Nfte5xk8b1AOVEiV2rQzaqwWR5MA4i8EobgeCINxwRl4L7azoflGnahBwAdqCU4rKan/gPlcAKlKgl2hMufWZJprEXf/DWBOZbXnwZP8GQmE6x8uNPRGw3/zYbyRnR7tP0CedG+dCZssUhXrdnf1E4rbvdQsoP10XOSCxQ44hA== 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)(46966006)(36840700001)(8676002)(8936002)(82310400003)(426003)(356005)(70586007)(336012)(16526019)(26005)(186003)(1076003)(36756003)(86362001)(70206006)(36860700001)(6666004)(83380400001)(47076005)(110136005)(450100002)(54906003)(4326008)(55016002)(2616005)(316002)(508600001)(5660300002)(6636002)(7696005)(36906005)(7636003)(6286002)(2906002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Nov 2021 14:51:38.2948 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e51f9a2b-f0e8-4074-ad7f-08d9a8476d90 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: DM6NAM11FT011.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB2681 X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-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 Reviewed-by: Li Zhang Acked-by: Matan Azrad --- v2: fix the coding style issue. --- 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..7b32c06fc6 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.25.1