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 81A2EA0C47; Tue, 6 Jul 2021 15:15:58 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id BBF5341262; Tue, 6 Jul 2021 15:15:53 +0200 (CEST) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2052.outbound.protection.outlook.com [40.107.236.52]) by mails.dpdk.org (Postfix) with ESMTP id 6F79D41377 for ; Tue, 6 Jul 2021 15:15:52 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KDBQ1ajVamu7hgRtIqYIlmzvDEOGuNAJrBL5PigJx0a06noIR+iMKuqnL4BX2MdpMZZ12DwDCINtXDQS4m9DHk1WaGS/bwQtu2mfloy75VQI9jSDJDmwKSQ75LA+bz0o+MqvgHdl2VtCTra4lIrEh3fmkwdUEVTG/kIMlpUsIm/95z4W3vvB+L4TUjQsp0Cetqo5djZ3By/ltvjrdjAq9GaaY92eg/D5w1CMMW1iyMJ7kQ1DTM1q2aKpz8nTSeKyLvclFJwiF0lgr165B+bkvOTkJUsqgQ3mmpQdBH6GQD+zPhW1GUHcT/6zHhiN9DrxUEQT0e8nKe6FEOEsr9XGSg== 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=HWbMa8OdTNdJ0xQXoVZ/KNy2XJagpFDE8yssdwTd6Og=; b=hUlbS9PdXmkFcHcZle6KyvesJXAjULnU236Wq4FOS5fu2aAqiWIsmvAGaSt8VHb5NvQybelcqDfIZK3kShqBxQPGNg1TGu77jSZsGhLpPEX8Jg74LFcc/v8bwIL9qBtmIcDLEbcHk8y/owyp7CAr0pnPPbiURR2y+9MRgXf75qst69/BxEgYVhlXasSpg0TD8/kNl1+qWqaSOTwv3BV0gEzpnfAAohbhcWwdxKKV/yRvs2TYPP7yfqHsltZBh3BAzPmzwJ+n/X1Qh5MJ1FhYe4Vi/UjYOxTaNqO4HY1tp+PMjBEBnaN374ql+ItRr6IUlYO7j1EWWa9m0ZnJxpUSUw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.112.34) smtp.rcpttodomain=monjalon.net smtp.mailfrom=nvidia.com; dmarc=pass (p=none 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=HWbMa8OdTNdJ0xQXoVZ/KNy2XJagpFDE8yssdwTd6Og=; b=qQowipxTdWln+VpjrYsu8Qf8XKb/4tJXOhIqPFTPC6TxeZcNkSjXTAFfDOpxix2uGmnXH4yZYH3F2unZJMOxdeDqChWjCAPT8msx36KnA3OypDACaaP1MT9bUiDtDFs0g/2MCeC5iXf+F0CnCLNeAsOcXYqIgLzCQmlyxkp/IVFP1V5mk+FKXv2WMOpg8MkVN8D3e0itj0n/4/LE9INTIz+4mHf3oGO/piPHqk2wByYyBXiLRtDgjLPV5VRTdEWxFX2JchYEOJOpK6z/oaKNdD8F7RDB/qx7GlVlWk88rIKDiPiXYRFmAj/nLnTmoVzGONOyw7+rylRUcbJUBLLwyw== Received: from BN6PR11CA0068.namprd11.prod.outlook.com (2603:10b6:404:f7::30) by DM6PR12MB3593.namprd12.prod.outlook.com (2603:10b6:5:11c::28) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4287.22; Tue, 6 Jul 2021 13:15:49 +0000 Received: from BN8NAM11FT035.eop-nam11.prod.protection.outlook.com (2603:10b6:404:f7:cafe::c4) by BN6PR11CA0068.outlook.office365.com (2603:10b6:404:f7::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4308.19 via Frontend Transport; Tue, 6 Jul 2021 13:15:49 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.112.34) smtp.mailfrom=nvidia.com; monjalon.net; dkim=none (message not signed) header.d=none;monjalon.net; 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 BN8NAM11FT035.mail.protection.outlook.com (10.13.177.116) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.4287.22 via Frontend Transport; Tue, 6 Jul 2021 13:15:49 +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.2; Tue, 6 Jul 2021 13:15:46 +0000 From: Shun Hao To: , , , "Shahaf Shuler" CC: , , Date: Tue, 6 Jul 2021 16:14:50 +0300 Message-ID: <20210706131450.30917-5-shunh@nvidia.com> X-Mailer: git-send-email 2.20.0 In-Reply-To: <20210706131450.30917-1-shunh@nvidia.com> References: <20210706131450.30917-1-shunh@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: e86c07c0-b3bb-4a3b-b076-08d940802c9a X-MS-TrafficTypeDiagnostic: DM6PR12MB3593: X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:8882; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: cxiWRTsZPhmKpRd9g5Bma9aFAF/4L48nThsHsLM9o9+d5Bp9KYJNN8Cp+VitJ64LzbF86jQ/jkiMLkS3bFq6qJawnFD7kV0fzJTp66IjDO+WcZwgpCmztHI36BRghC6ecwwLHLMYtiCFrEKd1aedH+3oNtLY7F3dRjPXZw5jsRDKPnPke3QEIFiqZPW1NLUoaFzuwjNsGq6gKNHPO2dVee3lcwYc9P9ftBsxOKTAV92K1QZIOj8AwisZBmbeRsE7r8xuwjaZMCsU+BsKPsins/yZ/sXtCZLVEGT5ED/gTA5AAl2wG30qWobNgflAs/fByP55w1hCixMvzF9MSEQIBaa7NVcV/V9s8ycMAHSsfFggfQFLKW6fkvZhUKB1nsgxdwMGU1DiUxRIrB0EOwZpLKdzLtDPjTU+shPsuKUxh3PiRAg4WeJ9plICf58st8z/D6jhHl2S8k+BDVZPMOO+eucdMI7d4oWCXQtXQi/jqCeGiSmXJrdSEN96NZW8JZ7Je+1VLhzRIYyAFmR+daGSvjhYt3rfJVfMcuI2qR9O8LJiUR/DrDif7DJvMQbTOJKxueSUHZbJF71WyZyZJ65NxVD1sZcqw7vBDQv7HYfFcDegAc1dWlTLOAIxb8a6DIRorp9R/9CSGTW33JTDVB6O+XHyogKzYGje40PwjaVF3x84bVCmPRx9aSNmYqPMMEH/zp+QMejSgoxNS2exf4/xeA== 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)(136003)(376002)(39860400002)(396003)(346002)(36840700001)(46966006)(110136005)(186003)(6666004)(55016002)(8936002)(7696005)(107886003)(4326008)(26005)(336012)(36860700001)(2616005)(70206006)(82310400003)(54906003)(6636002)(15650500001)(8676002)(1076003)(86362001)(316002)(5660300002)(36756003)(356005)(16526019)(70586007)(82740400003)(478600001)(2906002)(83380400001)(36906005)(426003)(7636003)(6286002)(47076005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Jul 2021 13:15:49.5993 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: e86c07c0-b3bb-4a3b-b076-08d940802c9a 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: BN8NAM11FT035.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM6PR12MB3593 Subject: [dpdk-dev] [PATCH v1 4/4] net/mlx5: validate meter action in policy 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 Sender: "dev" This adds the validation when creating a policy with meter action. Currently meter action is only allowed for green color in policy, and 8 meters are supported at maximum in one meter hierarchy. Signed-off-by: Shun Hao Acked-by: Matan Azrad --- doc/guides/nics/mlx5.rst | 15 ++++ doc/guides/rel_notes/release_21_08.rst | 6 ++ drivers/net/mlx5/mlx5_flow_dv.c | 98 ++++++++++++++++++++++++++ 3 files changed, 119 insertions(+) diff --git a/doc/guides/nics/mlx5.rst b/doc/guides/nics/mlx5.rst index a16af32e67..de04931f80 100644 --- a/doc/guides/nics/mlx5.rst +++ b/doc/guides/nics/mlx5.rst @@ -107,6 +107,7 @@ Features - 21844 flow priorities for ingress or egress flow groups greater than 0 and for any transfer flow group. - Flow metering, including meter policy API. +- Flow meter hierarchy. - Flow integrity offload API. - Connection tracking. - Sub-Function representors. @@ -1927,3 +1928,17 @@ This section demonstrates how to use the shared meter. A meter M can be created on port X and to be shared with a port Y on the same switch domain by the next way: flow create X ingress transfer pattern eth / port_id id is Y / end actions meter mtr_id M / end + +How to use meter hierarchy +-------------------------- + +This section demonstrates how to create and use a meter hierarchy. +A termination meter M can be the policy green action of another termination meter N. +The two meters are chained together as a chain. Using meter N in a flow will apply +both the meters in hierarchy on that flow. + + add port meter policy 0 1 g_actions queue index 0 / end y_actions end r_actions drop / end + create port meter 0 M 1 1 yes 0xffff 1 0 + add port meter policy 0 2 g_actions meter mtr_id M / end y_actions end r_actions drop / end + create port meter 0 N 2 2 yes 0xffff 1 0 + flow create 0 ingress group 1 pattern eth / end actions meter mtr_id N / end diff --git a/doc/guides/rel_notes/release_21_08.rst b/doc/guides/rel_notes/release_21_08.rst index 0a05cb02fa..b29d78f4de 100644 --- a/doc/guides/rel_notes/release_21_08.rst +++ b/doc/guides/rel_notes/release_21_08.rst @@ -68,6 +68,12 @@ New Features usecases. Configuration happens via standard rawdev enq/deq operations. See the :doc:`../rawdevs/cnxk_bphy` rawdev guide for more details on this driver. +* **Updated Mellanox mlx5 driver.** + + Updated the Mellanox mlx5 driver with new features and improvements, including: + + * Added support for Meter hierarchy. + Removed Items ------------- diff --git a/drivers/net/mlx5/mlx5_flow_dv.c b/drivers/net/mlx5/mlx5_flow_dv.c index 681e6fb07c..c085deed50 100644 --- a/drivers/net/mlx5/mlx5_flow_dv.c +++ b/drivers/net/mlx5/mlx5_flow_dv.c @@ -16858,6 +16858,78 @@ flow_dv_action_validate(struct rte_eth_dev *dev, } } +/** + * Validate the meter hierarchy chain for meter policy. + * + * @param[in] dev + * Pointer to the Ethernet device structure. + * @param[in] meter_id + * Meter id. + * @param[in] action_flags + * Holds the actions detected until now. + * @param[out] is_rss + * Is RSS or not. + * @param[out] hierarchy_domain + * The domain bitmap for hierarchy policy. + * @param[out] error + * Perform verbose error reporting if not NULL. Initialized in case of + * error only. + * + * @return + * 0 on success, otherwise negative errno value with error set. + */ +static int +flow_dv_validate_policy_mtr_hierarchy(struct rte_eth_dev *dev, + uint32_t meter_id, + uint64_t action_flags, + bool *is_rss, + uint8_t *hierarchy_domain, + struct rte_mtr_error *error) +{ + struct mlx5_priv *priv = dev->data->dev_private; + struct mlx5_flow_meter_info *fm; + struct mlx5_flow_meter_policy *policy; + uint8_t cnt = 1; + + if (action_flags & (MLX5_FLOW_FATE_ACTIONS | + MLX5_FLOW_FATE_ESWITCH_ACTIONS)) + return -rte_mtr_error_set(error, EINVAL, + RTE_MTR_ERROR_TYPE_POLICER_ACTION_GREEN, + NULL, + "Multiple fate actions not supported."); + while (true) { + fm = mlx5_flow_meter_find(priv, meter_id, NULL); + if (!fm) + return -rte_mtr_error_set(error, EINVAL, + RTE_MTR_ERROR_TYPE_MTR_ID, NULL, + "Meter not found in meter hierarchy."); + if (fm->def_policy) + return -rte_mtr_error_set(error, EINVAL, + RTE_MTR_ERROR_TYPE_MTR_ID, NULL, + "Non termination meter not supported in hierarchy."); + policy = mlx5_flow_meter_policy_find(dev, fm->policy_id, NULL); + MLX5_ASSERT(policy); + if (!policy->is_hierarchy) { + if (policy->transfer) + *hierarchy_domain |= + MLX5_MTR_DOMAIN_TRANSFER_BIT; + if (policy->ingress) + *hierarchy_domain |= + MLX5_MTR_DOMAIN_INGRESS_BIT; + if (policy->egress) + *hierarchy_domain |= MLX5_MTR_DOMAIN_EGRESS_BIT; + *is_rss = policy->is_rss; + break; + } + meter_id = policy->act_cnt[RTE_COLOR_GREEN].next_mtr_id; + if (++cnt >= MLX5_MTR_CHAIN_MAX_NUM) + return -rte_mtr_error_set(error, EINVAL, + RTE_MTR_ERROR_TYPE_METER_POLICY, NULL, + "Exceed max hierarchy meter number."); + } + return 0; +} + /** * Validate meter policy actions. * Dispatcher for action type specific validation. @@ -16893,6 +16965,8 @@ flow_dv_validate_mtr_policy_acts(struct rte_eth_dev *dev, struct rte_flow_error flow_err; uint8_t domain_color[RTE_COLORS] = {0}; uint8_t def_domain = MLX5_MTR_ALL_DOMAIN_BIT; + uint8_t hierarchy_domain = 0; + const struct rte_flow_action_meter *mtr; if (!priv->config.dv_esw_en) def_domain &= ~MLX5_MTR_DOMAIN_TRANSFER_BIT; @@ -17070,6 +17144,27 @@ flow_dv_validate_mtr_policy_acts(struct rte_eth_dev *dev, ++actions_n; action_flags |= MLX5_FLOW_ACTION_JUMP; break; + case RTE_FLOW_ACTION_TYPE_METER: + if (i != RTE_COLOR_GREEN) + return -rte_mtr_error_set(error, + ENOTSUP, + RTE_MTR_ERROR_TYPE_METER_POLICY, + NULL, flow_err.message ? + flow_err.message : + "Meter hierarchy only supports GREEN color."); + mtr = act->conf; + ret = flow_dv_validate_policy_mtr_hierarchy(dev, + mtr->mtr_id, + action_flags, + is_rss, + &hierarchy_domain, + error); + if (ret) + return ret; + ++actions_n; + action_flags |= + MLX5_FLOW_ACTION_METER_WITH_TERMINATED_POLICY; + break; default: return -rte_mtr_error_set(error, ENOTSUP, RTE_MTR_ERROR_TYPE_METER_POLICY, @@ -17090,6 +17185,9 @@ flow_dv_validate_mtr_policy_acts(struct rte_eth_dev *dev, * so MARK action only in ingress domain. */ domain_color[i] = MLX5_MTR_DOMAIN_INGRESS_BIT; + else if (action_flags & + MLX5_FLOW_ACTION_METER_WITH_TERMINATED_POLICY) + domain_color[i] = hierarchy_domain; else domain_color[i] = def_domain; /* -- 2.21.0