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 12A0DA0511; Fri, 8 Apr 2022 04:47:23 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id F41084067E; Fri, 8 Apr 2022 04:47:22 +0200 (CEST) Received: from NAM02-DM3-obe.outbound.protection.outlook.com (mail-dm3nam07on2071.outbound.protection.outlook.com [40.107.95.71]) by mails.dpdk.org (Postfix) with ESMTP id EACC04003F for ; Fri, 8 Apr 2022 04:47:20 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lLnc2OOMhYo9azZBXoSVGYfDqphyUqFoFsQd6Cus1fCOD4OeEaxNG9rlv4ZUER6x+cxEtLkakouvMuAYXB9gQffLrgb53IM2UEtu69dL7kmfGbKIkfapzx4ZYhzHaHMhzrsBPOtHwwFhddwYBRFYmfC5RurnIqWIilhZKaGShrtfZofKjTZI3inT1a7anMZI/w8bmtA9NQvA2Sgamik5b+7RDIkUiM+/FQOtswZRUdsx2ZC/thzJpid5fvFgUan0PN5LNiY2MIgUKoNyJqgQbirB7+cDoacvpLw4HpBMwVM8BvZb2YY1VpyybcCcqHWq97RD1/Y44I4Pp68Ar3Hyng== 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=6Ta7ZT6+fPoxhZd+A25o7K4nBsLQbMZtG4osJvWpj+w=; b=m4NL4OB3uCwFGpXzpdlt30YqdUn7QOoqTGMG5u7lfoTq37qGfxQBfT5fkt1p3wQ/8rP5O5Tg9tdUVH6VclZIiTOfljEIJLzrLn0xuL9IJ3aAuwOuotggJd3fApQrg9AW0+aSbzfgsQy6tDgJEmO25F/rKvxSd4CRqol6BnrQx2egy0vIABWpmFaWO7CpfmbAAoP1G66zK2+vLTJwNePg5/eR4FRQKaEZgus/0Hz13UV0FHDx7UoPhYY9gtcjNlNEcIuBHkrYKGrINhUMGSHeylNYj7IwbxaLPLfixtOB2IOn3xzvVOjiSHSaQcFtU3yIrSOYvnPAho5EnuAkDjCc4w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.238) smtp.rcpttodomain=intel.com smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject 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=6Ta7ZT6+fPoxhZd+A25o7K4nBsLQbMZtG4osJvWpj+w=; b=W6gaC2+1gXTZYoC3dhU4zPIDuirI6VSaemHPGDsTIu/OEq4jI2mF68aD11+8LS8YJqH6zgC9a6jU7t0DNnqYm8VjaRvLaxGgDgvjuOoMwweVP/zhHij5pBTmHtdPdKo50RSrogEL07m7aLa5U8vKWU8F2DSJ4Rg9o18InjsRQvFcJpegH5Y9RXSIfSjuJPM/W72hEaJMB4AOgVSH9mpsy14ZL0cAbGSRIIviqRzgZjdFrsXHrzZrmULtSxIL7TfFvbUeJuo2q2nuoCyvN1/KZx1Kd8EcoRkjatDZ1l/SCzLnr5ExUygaNhkOEOdXsKgza5UWo7YwaErKTNDf8Oj8ng== Received: from BN6PR1401CA0014.namprd14.prod.outlook.com (2603:10b6:405:4b::24) by MWHPR12MB1629.namprd12.prod.outlook.com (2603:10b6:301:3::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5144.22; Fri, 8 Apr 2022 02:47:18 +0000 Received: from BN8NAM11FT060.eop-nam11.prod.protection.outlook.com (2603:10b6:405:4b:cafe::7a) by BN6PR1401CA0014.outlook.office365.com (2603:10b6:405:4b::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5144.22 via Frontend Transport; Fri, 8 Apr 2022 02:47:18 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.238) 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 12.22.5.238 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.238; helo=mail.nvidia.com; Received: from mail.nvidia.com (12.22.5.238) by BN8NAM11FT060.mail.protection.outlook.com (10.13.177.211) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5144.20 via Frontend Transport; Fri, 8 Apr 2022 02:47:18 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL105.nvidia.com (10.27.9.14) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Fri, 8 Apr 2022 02:47:17 +0000 Received: from pegasus01.mtr.labs.mlnx (10.126.231.35) by rnnvmail201.nvidia.com (10.129.68.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.22; Thu, 7 Apr 2022 19:47:14 -0700 From: Alexander Kozyrev To: CC: , , , , , , , , , Subject: [RFC] ethdev: datapath-focused meter actions Date: Fri, 8 Apr 2022 05:46:58 +0300 Message-ID: <20220408024658.2004918-1-akozyrev@nvidia.com> X-Mailer: git-send-email 2.18.2 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2c2c1806-ebe5-4031-f288-08da190a1909 X-MS-TrafficTypeDiagnostic: MWHPR12MB1629:EE_ X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 52B1GML1fAa0oGgv0SrS1+eGi8uvWihFaD+TZzP4bGah3dpjErZB/REUSi/zO/twyPJlGU3FyD1Uff2EbyQvWSh+YwkWKXyEmyhPGRKP6IAjoobBC9InQhI4B7/X7oKpJPbEtgfuKakMkUozpIygvjF7z5eUYDNS8WQs1ltiD1vr/6xZmXs5VM+SKPct3rKEf0HCe8NSjMtIUknYwpV54Iwfbl0cESYHSlQGVDoOUhcq5gPJMwfuLpBL3nwgTB3h2UwIXtlVN668MtfFgtZDj3o4rDZrsXisccGhr9o7Y/xl6w5JJ6iUmzBHqPjUk9WoYQJs7N3mHFJV8+PuV/y50HYnZFyHE4qOBAaURVYREjUEaIrPUPpQC6KLDS35C+i0Y9F7UlwqiIzuA0YRwc45D2YLYhr2WqGJLeEYPLD34DxQ18XsKUm04UcWPuENyJsq3SgWPOCtONhag6fCwxUYShtH7JbF8Kh4oV9qGUgmLIWRbpPiB43ftYoqQKaxt6SlN9Jirok6VPc1rhQGE+gszLhNERMcGpsmECE14Rx7pMjJPU6rTO7ADXSWyJgYg9+9zLRSRUE+dsfbw8OPhTdtYHdzlhzbWJeSk4IDTBwM3Yk0AWxgUdQ65um0JowxXcOsfHxo6QdJ6Nv9pPlrJh5DEjg/GPc4zTlPCKe1XXhWCk4APM4fsbDGJd5F5NgdmgSpZPXwjdsLd8bcMSF8ZqL1TQ== X-Forefront-Antispam-Report: CIP:12.22.5.238; CTRY:US; LANG:en; SCL:1; SRV:; IPV:CAL; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE; SFS:(13230001)(4636009)(40470700004)(46966006)(36840700001)(508600001)(6916009)(316002)(54906003)(8676002)(86362001)(70206006)(70586007)(81166007)(356005)(4326008)(426003)(40460700003)(5660300002)(36860700001)(336012)(16526019)(82310400005)(47076005)(36756003)(26005)(1076003)(7416002)(83380400001)(6666004)(8936002)(2906002)(186003)(2616005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Apr 2022 02:47:18.5233 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 2c2c1806-ebe5-4031-f288-08da190a1909 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[12.22.5.238]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT060.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR12MB1629 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 introduction of asynchronous flow rules operations allowed users to create/destroy flow rules as part of the datapath without blocking on Flow API and slowing the packet processing down. That applies to every possible action that has no preparation steps. Unfortunately, one notable exception is the meter action. There is a separate API to prepare a meter profile and a meter policy before any meter object can be used as a flow rule action. The application logic is the following: 1. rte_mtr_meter_profile_add() is called to create the meter profile first to define how to classify incoming packets and to assign an appropriate color to them. 2. rte_mtr_meter_policy_add() is invoked to define the fate of a packet, based on its color (practically creating flow rules, matching colors). 3. rte_mtr_create() is then needed to search (with locks) for previously created profile and policy in order to create the meter object. 4. rte_flow_create() is now finally can be used to specify the created meter as an action. This approach doesn't fit into the asynchronous rule creation model and can be improved with the following proposal: 1. Creating a policy may be replaced with the creation of a group with up to 3 different rules for every color using asynchronous Flow API. That requires the introduction of a new pattern item - meter color. Then creation a flow rule with the meter means a simple jump to a group: rte_flow_async_create(group=1, pattern=color, actions=...); rte_flow_async_create(group=0, pattern=5-tuple, actions=meter,jump group 1); This allows to classify packets and act upon their color classifications. The Meter action assigns a color to a packet and an appropriate action is selected based on the Meter color in group 1. 2. Preparing a meter object should be the part of flow rule creation and use the same flow queue to benefit from asynchronous operations: rte_flow_async_create(group=0, pattern=5-tuple, actions=meter id 1 profile rfc2697, jump group 1); Creation of the meter object takes time and flow creation must wait until it is ready before inserting the rule. Using the same queue allows ensuring that. There is no need to create a meter object outside of the Flow API, but this approach won't affect the old Meter API in any way. 3. Another point of optimization is to prepare all the resources needed in advance in rte_flow_configure(). All the policy rules can be created during the initialization stage easily and put into several groups. These groups can be used by many meter objects by simple jump action to an appropriate group. Meter objects can be preallocated as well and configured with required profile parameters later at the flow rule creation stage. The number of pre-allocated profiles/policies is specified in the Flow engine resources settings. These optimizations alongside already existing pattern/actions templates can improve the insertion rate significantly and allow meter usage as part of the datapath. The introduction of the new API is intended to be used with the asynchronous Flow API. Deprecation of the old Meter API is not planned at this point. Signed-off-by: Alexander Kozyrev --- lib/ethdev/rte_flow.h | 71 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 70 insertions(+), 1 deletion(-) diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index d8827dd184..aec36a9f0a 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -33,6 +33,7 @@ #include #include #include +#include #include #include #include @@ -671,6 +672,13 @@ enum rte_flow_item_type { * See struct rte_flow_item_gre_opt. */ RTE_FLOW_ITEM_TYPE_GRE_OPTION, + + /** + * Matches Meter Color. + * + * See struct rte_flow_item_meter_color. + */ + RTE_FLOW_ITEM_TYPE_METER_COLOR, }; /** @@ -1990,6 +1998,26 @@ static const struct rte_flow_item_ppp rte_flow_item_ppp_mask = { }; #endif +/** + * @warning + * @b EXPERIMENTAL: this structure may change without prior notice + * + * RTE_FLOW_ITEM_TYPE_METER_COLOR + * + * Matches a meter color set in the packet meta-data + * (i.e. struct rte_mbuf::sched::color). + */ +struct rte_flow_item_meter_color { + enum rte_color color; /**< Packet color. */ +}; + +/** Default mask for RTE_FLOW_ITEM_TYPE_METER_COLOR. */ +#ifndef __cplusplus +static const struct rte_flow_item_meter_color rte_flow_item_meter_color_mask = { + .color = 0x3, +}; +#endif + /** * Matching pattern item definition. * @@ -2376,6 +2404,14 @@ enum rte_flow_action_type { */ RTE_FLOW_ACTION_TYPE_METER, + /** + * Extended Traffic metering and policing (MTR). + * + * See struct rte_flow_action_meter_ext. + * See file rte_mtr.h for MTR object configuration. + */ + RTE_FLOW_ACTION_TYPE_METER_EXT, + /** * Redirects packets to security engine of current device for security * processing as specified by security session. @@ -3128,6 +3164,19 @@ struct rte_flow_action_meter { uint32_t mtr_id; /**< MTR object ID created with rte_mtr_create(). */ }; +/** + * RTE_FLOW_ACTION_TYPE_METER_EXT + * + * Extended Traffic metering and policing (MTR). + * + * Packets matched by items of this type can be either dropped or passed to the + * next item with their color set by the MTR object. + */ +struct rte_flow_action_meter_ext { + uint32_t mtr_id; /**< MTR object ID. */ + struct rte_meter_profile *profile; /**< MTR profile. */ +}; + /** * RTE_FLOW_ACTION_TYPE_SECURITY * @@ -4899,10 +4948,20 @@ struct rte_flow_port_info { */ uint32_t max_nb_aging_objects; /** - * Maximum number traffic meters. + * Maximum number of traffic meters. * @see RTE_FLOW_ACTION_TYPE_METER */ uint32_t max_nb_meters; + /** + * Maximum number of traffic meter profiles. + * @see RTE_FLOW_ACTION_TYPE_METER + */ + uint32_t max_nb_meter_profiles; + /** + * Maximum number of traffic meters policices. + * @see RTE_FLOW_ACTION_TYPE_METER + */ + uint32_t max_nb_meter_policies; }; /** @@ -4972,6 +5031,16 @@ struct rte_flow_port_attr { * @see RTE_FLOW_ACTION_TYPE_METER */ uint32_t nb_meters; + /** + * Number of meter profiles to configure. + * @see RTE_FLOW_ACTION_TYPE_METER + */ + uint32_t nb_meter_profiles; + /** + * Number of meter policies to configure. + * @see RTE_FLOW_ACTION_TYPE_METER + */ + uint32_t nb_meter_policies; }; /** -- 2.18.2