From patchwork Mon Sep 26 14:57:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Kozyrev X-Patchwork-Id: 116890 X-Patchwork-Delegate: andrew.rybchenko@oktetlabs.ru Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 07B81A00C2; Mon, 26 Sep 2022 16:58:32 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E31E54281E; Mon, 26 Sep 2022 16:58:31 +0200 (CEST) Received: from NAM12-MW2-obe.outbound.protection.outlook.com (mail-mw2nam12on2085.outbound.protection.outlook.com [40.107.244.85]) by mails.dpdk.org (Postfix) with ESMTP id 2AE814281E for ; Mon, 26 Sep 2022 16:58:30 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Oq/vWJENGpMd9QSPPPrkhk7fTKKM/BEAYdMRipglithcU/K8jg3P2acgyKWyr7KvnEBgZjb4HiRQfu+mpDPV2lfIKF9PbAvRwZOwXdkGk07s9jquFuvd9ieAX6Q4RBnTCoG5boBofJ2Xv19EpvON6MagpqIYwqUSOq972rGHpAFkdONbyyFtugbZ450HboBNAledEuLacG8wSFbZqS+UWgslFXYTYx6T6AqeoBQLleQBTlPSTMbX3CLjw8vmdiB43o3bKQf4QhxioqFEAqQDX569IBHgCYLmb4I0rxSbKZuPzuJ3fDdajfN98/XQ7XcexVdjwRZV/aue1se9CpiOvQ== 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=bJOiIFakME6YTffkhKtTxUri8lnQF2QexJ2NgBpeGsA=; b=TKLECaBR7QDTFl5CMLvqIP/BYWJmaRu7jEUrLr//1ke9heyvJQdzD5+a3WhOUC8yyK5QaeaqQIUv9/0cX/PEMZbwdddFrtflk6IX9ymBfvti3ZaFYuSrLqtq8Nt9mREkgydnIpF3LLpq3O1vwQ7NW2TVrfDuHq5DWCCclvbULmNxzaQc9ln6JUXnuHh6jbqZqDEuTZ/SCo9vaYBhGuVwNZso8LuaUSX9397AS90M4hgxPPP8Ah6W62SU2W99JvQBZE19Afp/Zka5pwVEqYJdirsMgBSkl1AV+6N4lNnl624jvR6OxGVETpgAodlRfdLroud0OX0KxuCoGrIOyI83bw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=dpdk.org 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=bJOiIFakME6YTffkhKtTxUri8lnQF2QexJ2NgBpeGsA=; b=bW5KhdQDQzIIjFKhDXVIV3tOmy3mMyCZ0y2GaJqUhPB/6R+c//n6QAUMX8zh6qtHfHhqLIUCJAw39ms5tIvDe8hFf7csfsDyROfV4iwa3Gi6yrU+NC9i9vzOXQqaNj2uPW9HUcmnWJ5iX6cP+H983ociCazlux/Y/Y27+OBIHteYqMF2XZNu8LC4a+5FM3uuFhuf6N3GNsQtPRhDvTLIdnRd7Qzx88BZYGxjD2AFr+vBd84lR8V9WV6Z7RDvA2oM6Ax8VBtGAuxWte9G9FgstdVHTKfnTaMb3aIKbJmcuPnUbzY+SSaZxbchMi7jXz39u2yiz6WBwABRENJW8Csexg== Received: from DM6PR06CA0049.namprd06.prod.outlook.com (2603:10b6:5:54::26) by BY5PR12MB4968.namprd12.prod.outlook.com (2603:10b6:a03:1d2::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.25; Mon, 26 Sep 2022 14:58:28 +0000 Received: from DM6NAM11FT016.eop-nam11.prod.protection.outlook.com (2603:10b6:5:54:cafe::fc) by DM6PR06CA0049.outlook.office365.com (2603:10b6:5:54::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.26 via Frontend Transport; Mon, 26 Sep 2022 14:58:27 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) 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.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by DM6NAM11FT016.mail.protection.outlook.com (10.13.173.139) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.14 via Frontend Transport; Mon, 26 Sep 2022 14:58:27 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Mon, 26 Sep 2022 07:58:16 -0700 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.29; Mon, 26 Sep 2022 07:58:13 -0700 From: Alexander Kozyrev To: CC: , , , , , , , , , , , Subject: [PATCH v5 1/7] ethdev: add meter color flow matching item Date: Mon, 26 Sep 2022 17:57:39 +0300 Message-ID: <20220926145745.3962600-2-akozyrev@nvidia.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20220926145745.3962600-1-akozyrev@nvidia.com> References: <20220921021133.2982954-1-akozyrev@nvidia.com> <20220926145745.3962600-1-akozyrev@nvidia.com> MIME-Version: 1.0 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-TrafficTypeDiagnostic: DM6NAM11FT016:EE_|BY5PR12MB4968:EE_ X-MS-Office365-Filtering-Correlation-Id: a7ff9d84-e65a-4362-4a02-08da9fcf919a X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0i7Pl5xjI90veYsumNPcYbDi7YLfTPPgrZnerTspMW7WbKKfE1Q0U3OYk7wQacBM8/DjFssqMii/mc+PE8hi0MYhl2XJjPkkoAguCjvzcJgZURnVziqHmFUFR0Khuj4s5qvrhUd718r9/Gne0iPEbFQm4T3qz8Mao8GEeNyCaSEBDcOyeEJMz3gpztfg9NTinsOtncAko1E3uXXVeTBk2VCL8LnfGszV0JCY49cPKvNoDAP3FbguCS1alHnf7G2u/1Ki0nCWf4FRP9K4jjUwpWm9V7d4WRl/oTXZDjV2FOpFZCwJORmzUIhIFLwC2AIc1hWucuRpzdIVSecSUeWp6qXGH/T42JQNKkwMZozbBubsROrVwFPSKXeRGYUr491zN1SeEAQNZfbL5rOBe3BSEMQj1wCQy6epCrni+eDX5Kudwz0PYVVoGB6jRPx0RI6F1ACtSspSZLW/h/k6BEwpxYXBo1dwDVCms2ZSKRy/qO5sBfkrbaLU5N3CzTXW9znHshYGiqgtetfMTxAqU0DhS+p3uNS9L+GsuWIZkk0x1uSaO1clf/qQLp1YlBJVvhLYU0U0chbmbfgCkPKHzoW+/OV6cM52PnDWdsa2ECSzhAJOwT/z/prkSzkveUJ1uxd5nkdVZnRSBKISI2VEehUIPy/oll1p9VmeG55vLzxzlxHmQ3pz4N1GUA551RShjjpue2QEY92qz9JefQEqkIVA06o2SNiHT8f6dQfxMQVxNcP5l7RI3+QepATTGv/HQ7rUQRiR++PvkB4+tNhpOsXLwA== X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230022)(4636009)(396003)(39860400002)(346002)(136003)(376002)(451199015)(36840700001)(46966006)(40470700004)(336012)(186003)(16526019)(426003)(47076005)(1076003)(8936002)(7636003)(82310400005)(41300700001)(6666004)(82740400003)(40460700003)(86362001)(7416002)(5660300002)(4326008)(36756003)(356005)(83380400001)(26005)(2906002)(36860700001)(316002)(40480700001)(2616005)(54906003)(6916009)(8676002)(478600001)(70586007)(70206006); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Sep 2022 14:58:27.4638 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: a7ff9d84-e65a-4362-4a02-08da9fcf919a X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT016.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BY5PR12MB4968 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 Provide an ability to use a Color Marker set by a Meter as a matching item in Flow API. The Color Marker reflects the metering result by setting the metadata for a packet to a particular codepoint: green, yellow or red. Signed-off-by: Alexander Kozyrev --- doc/guides/prog_guide/rte_flow.rst | 7 +++++++ doc/guides/rel_notes/release_22_11.rst | 5 ++++- lib/ethdev/rte_flow.c | 1 + lib/ethdev/rte_flow.h | 24 ++++++++++++++++++++++++ 4 files changed, 36 insertions(+), 1 deletion(-) diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 588914b231..018def1033 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -1651,6 +1651,13 @@ Matches a PPP header. - ``proto_id``: PPP protocol identifier. - Default ``mask`` matches addr, ctrl, proto_id. +Item: ``METER_COLOR`` +^^^^^^^^^^^^^^^^^^^^^ + +Matches Color Marker set by a Meter. + +- ``color``: Metering color marker. + Actions ~~~~~~~ diff --git a/doc/guides/rel_notes/release_22_11.rst b/doc/guides/rel_notes/release_22_11.rst index 235ac9bf94..eeed420ae3 100644 --- a/doc/guides/rel_notes/release_22_11.rst +++ b/doc/guides/rel_notes/release_22_11.rst @@ -55,11 +55,14 @@ New Features Also, make sure to start the actual text at the margin. ======================================================= +* **Extended Metering and Marking support in the Flow API.** + + * Added METER_COLOR item to match Color Marker set by a Meter. + * **Updated Wangxun ngbe driver.** * Added support to set device link down/up. - Removed Items ------------- diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c index 501be9d602..99247b599d 100644 --- a/lib/ethdev/rte_flow.c +++ b/lib/ethdev/rte_flow.c @@ -159,6 +159,7 @@ static const struct rte_flow_desc_data rte_flow_desc_item[] = { rte_flow_item_flex_conv), MK_FLOW_ITEM(L2TPV2, sizeof(struct rte_flow_item_l2tpv2)), MK_FLOW_ITEM(PPP, sizeof(struct rte_flow_item_ppp)), + MK_FLOW_ITEM(METER_COLOR, sizeof(struct rte_flow_item_meter_color)), }; /** Generate flow_action[] entry. */ diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index 017f690798..c0409a5ada 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -668,6 +668,14 @@ enum rte_flow_item_type { * See struct rte_flow_item_gre_opt. */ RTE_FLOW_ITEM_TYPE_GRE_OPTION, + + /** + * Matches Meter Color Marker. + * + * See struct rte_flow_item_meter_color. + */ + + RTE_FLOW_ITEM_TYPE_METER_COLOR, }; /** @@ -2198,6 +2206,22 @@ struct rte_flow_item_flex_conf { uint32_t nb_outputs; }; +/** + * RTE_FLOW_ITEM_TYPE_METER_COLOR. + * + * Matches Color Marker set by a Meter. + */ +struct rte_flow_item_meter_color { + enum rte_color color; /**< Meter color marker. */ +}; + +/** 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 = RTE_COLORS, +}; +#endif + /** * Action types. * From patchwork Mon Sep 26 14:57:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Kozyrev X-Patchwork-Id: 116891 X-Patchwork-Delegate: andrew.rybchenko@oktetlabs.ru Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0DCB0A00C2; Mon, 26 Sep 2022 16:58:37 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E206542836; Mon, 26 Sep 2022 16:58:35 +0200 (CEST) Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2062.outbound.protection.outlook.com [40.107.220.62]) by mails.dpdk.org (Postfix) with ESMTP id 564C94069B for ; Mon, 26 Sep 2022 16:58:34 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dredjrChyhevqoNtVWUlERvvEeDdcs605zeJGttGnqw8Evtf+EJi7720qF60LhMdyyMlNYXCfh4Dhdw0Z6/s7aQew5bdNHBpvfRRriSpAoQnO0rnlb7q4ZYP4GYu2UnPCcVMW+n94knjJ8T/rztYtlUX1tdPLexC+2KaUYdWz8Q4t4I0oB4vuybpWK/yw6dpAO8K0JiXN89bGiE5kqfUBDgNF/UhraZBlyMftHIbo74RJXChSZE22nW9+FfSbYb9bK9w/vPEiUaTvknDZB9yOZCPCzkeW2IeiliJcbc3KvY2kfFMj4ei14vF6FwhgrY3C0F40TsNuPCI/FyeaytrqA== 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=ttFl9MHHgXoc/c2Vh9Ve4SAlh9kAonk78POx15DJwvU=; b=JW33dlTpznfGPronWCoLyJcqJOXHOncc+75zVPBXSCAPpf/40GGAT5xqhRJYdBHpBp348/2WxiNPbdM/E8ov7UI7j99hU0tlDC9D1OM5yz96mGTE0/pz4kZWhNHqX+qEzkEWXRONapMxNoxEz9djHymJCIFabsYWUjUJPwwVrVygMb8t7I4uUTPphsarcntytByLxbUuuR/bIIAU8fsi54S6qal37hy215JIOUpsNJvpGlulm0lWqduzs+NMTLgmKPx5DMEim9NYjUHLXwpOiqvy+N2GJd/4jGjSiTM11wGMO6rfTHxMqn/sxRgTPynj/PFkaNB9IO3x4EMFuAtc4g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=dpdk.org 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=ttFl9MHHgXoc/c2Vh9Ve4SAlh9kAonk78POx15DJwvU=; b=XvfgF1wsZg7c8LaDkqZ4Q7DZCb3o57lRUU/qkqoP4iNnaE9l1e2v8iNejV1FRQxD2YzI3/oEGcpIdbyExDiKiU1VzRYnYkrxxJkw/jZY+FVQe0m0eIuoqcFjHPuKLVH/CLPmgdtuODTOBIxRipEihOrewhbQvvEcDc3/gV56gGLdEvWfDm5y6GkW/u511R0bKEQUaV01zllTbDfjaw4MLGmUm4q2ReYnjOdapQS41G6unxBv0pLc9Pf/WwSmB7IqIKSQfDwfD1BR/avA3xvNrOrXpk+b2DhJyYfP4zWovQ72e7KBlCpo6vqqrvdJ8U4M5dHj/R+qhvtM4LkdiMtq0A== Received: from DS7PR05CA0053.namprd05.prod.outlook.com (2603:10b6:8:2f::34) by DM8PR12MB5399.namprd12.prod.outlook.com (2603:10b6:8:34::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.25; Mon, 26 Sep 2022 14:58:32 +0000 Received: from DM6NAM11FT106.eop-nam11.prod.protection.outlook.com (2603:10b6:8:2f:cafe::d8) by DS7PR05CA0053.outlook.office365.com (2603:10b6:8:2f::34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.9 via Frontend Transport; Mon, 26 Sep 2022 14:58:32 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) 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.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by DM6NAM11FT106.mail.protection.outlook.com (10.13.172.229) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.14 via Frontend Transport; Mon, 26 Sep 2022 14:58:32 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Mon, 26 Sep 2022 07:58:20 -0700 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.29; Mon, 26 Sep 2022 07:58:17 -0700 From: Alexander Kozyrev To: CC: , , , , , , , , , , , Subject: [PATCH v5 2/7] ethdev: allow meter color marker modification Date: Mon, 26 Sep 2022 17:57:40 +0300 Message-ID: <20220926145745.3962600-3-akozyrev@nvidia.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20220926145745.3962600-1-akozyrev@nvidia.com> References: <20220921021133.2982954-1-akozyrev@nvidia.com> <20220926145745.3962600-1-akozyrev@nvidia.com> MIME-Version: 1.0 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-TrafficTypeDiagnostic: DM6NAM11FT106:EE_|DM8PR12MB5399:EE_ X-MS-Office365-Filtering-Correlation-Id: d9b2c87b-f1fe-46b8-9269-08da9fcf9458 X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: SpH+rkaDXDX64Y9biOmB9ZJgRZcVuQl0m1FtfN7G0ffpwGsPkhJHulUjAwDLgdn7dSvvfq4RGi82fxpVUqY9MsoZbaLZA697zOkMkxD/xk4qIu6M2n71oYUwQN7WMO/GD70g73Lh4u3kBFRP4SCoPZ0h2SF25m7Z3O+DQy3KhGWXNhjAJ11FJ3DJbu5fUV/eZNO248TTGg8jsxRG8T2tsck5xMJ8h0HYTn3lASyqd0lDJiUzp12ghR4gRqqQVGOGkaQDKr6J5QZIFSwDzp2QSTC/RsAL0c1/D4FYBUBiAzW1XXR5CjpblwNqbhSPjKKd3YZnC8KN36+DnNq1+unamAUOESx0jL4KJjGO+xwdDVmC8TlygUIxMGvbUB1TrgVYq+LSCclvXt8bZe40lJsXRvuq+7KeeB5+/5FvNpAvreALYU+ktbrWOxsZmsudaVitG8BPG7iDOgSZpqdPhde52cLyi9kre0UHdNKOPS74ylBYO9MWn4ZLF1j7hPWHJaJBpK3S8cQnxOVaAF4IJGd0y8YRlfW9NO9RyaU2+5bXOPN2+TiBtoUiMbFUgc8fZHe0ZscdenXlY1SM3zOoPbOlwTWXEZTSlReEaSmU5jpd3HHuyXJR0BcufwRWy8li0XpB0wu56OBbJcveudJOO4H655A4wb7KLHDLk0sPCYPj4HtGF9+yMNb1JMG8H1dTo75mchpf1ko6s4yUrNA5ULS9y1m1bLwG9emyA5icAxHHU2LRuk9pX9tjiMhXErXKcvbs3L5qNE8NfGyIVs0st9xxdg== X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230022)(4636009)(346002)(376002)(136003)(396003)(39860400002)(451199015)(40470700004)(46966006)(36840700001)(70206006)(83380400001)(8676002)(70586007)(4326008)(478600001)(2906002)(36756003)(2616005)(8936002)(26005)(82740400003)(5660300002)(7416002)(47076005)(356005)(426003)(40460700003)(16526019)(1076003)(41300700001)(186003)(7636003)(82310400005)(6666004)(336012)(86362001)(36860700001)(40480700001)(6916009)(54906003)(316002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Sep 2022 14:58:32.0819 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: d9b2c87b-f1fe-46b8-9269-08da9fcf9458 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT106.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM8PR12MB5399 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 Extend modify_field Flow API with support of Meter Color Marker modifications. It allows setting the packet's metadata to any color marker: green, yellow or red. A user is able to specify an initial packet color for Meter API or create simple Metering and Marking flow rules based on his own coloring algorithm. Signed-off-by: Alexander Kozyrev --- doc/guides/rel_notes/release_22_11.rst | 1 + lib/ethdev/rte_flow.h | 1 + 2 files changed, 2 insertions(+) diff --git a/doc/guides/rel_notes/release_22_11.rst b/doc/guides/rel_notes/release_22_11.rst index eeed420ae3..0fcf2093ed 100644 --- a/doc/guides/rel_notes/release_22_11.rst +++ b/doc/guides/rel_notes/release_22_11.rst @@ -58,6 +58,7 @@ New Features * **Extended Metering and Marking support in the Flow API.** * Added METER_COLOR item to match Color Marker set by a Meter. + * Added ability to set Color Marker via modify_field Flow API. * **Updated Wangxun ngbe driver.** diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index c0409a5ada..d8e6608bcf 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -3713,6 +3713,7 @@ enum rte_flow_field_id { RTE_FLOW_FIELD_VALUE, /**< Immediate value. */ RTE_FLOW_FIELD_IPV4_ECN, /**< IPv4 ECN. */ RTE_FLOW_FIELD_IPV6_ECN, /**< IPv6 ECN. */ + RTE_FLOW_FIELD_METER_COLOR, /**< Meter color marker. */ }; /** From patchwork Mon Sep 26 14:57:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Kozyrev X-Patchwork-Id: 116893 X-Patchwork-Delegate: andrew.rybchenko@oktetlabs.ru Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 01A76A00C2; Mon, 26 Sep 2022 16:58:52 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3D44042B7B; Mon, 26 Sep 2022 16:58:42 +0200 (CEST) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2069.outbound.protection.outlook.com [40.107.93.69]) by mails.dpdk.org (Postfix) with ESMTP id 8F61342B7A for ; Mon, 26 Sep 2022 16:58:40 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZlIslyIO+Dy3UVUEWvh3EP2pkui9pprGQqnjPnhWFhNHcscGotNpDhWsMkhGM+YzZS4OlzqaMXztGgb2YGFGdbMEcOLL+ygXpoH5Xl3ToVzzzESQEXY2YT8s7tjE3dDCpeN20Qhi9l9SIGvs3F8Mjn8En71+5wOv6vJsI54hKvPaRspp+nELFB3uyJ49C5iUxVohJXMnujv84juHNnArP3qDn5fGFURG+upYNtSq5uZsKl2vfSjeAFBAplyuXV9epdIKULZKpHPUjwO0z3PGE0LV6pR6kO6TAreoWdAOmlhB67VfE+3psZATj4gh2N9JZYEIiBEIPdcIOwFrNQO2yA== 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=AL6YGmgXtN0A72iEbhxJ/lY6Mm+JaDdFWZCrO0p5YoA=; b=ngQwrku4Qi/m9Fkwm7scc+UYaa9D/I4H67DeYz6cXLJ/jsb4sO9kiuvmHoESaflDj5hSCobd7/a24gAfkxdz9v1DjvBVaKhT/QtLEoMdaK1K/8to8bNSWuUhri90CXkJHs5qdBvIrw0qbHKVJjQqgQqeKRyDjf/w4DZ2F7Pzz5+6Hv9qkmuhfleOMsfuZSkptEP0MSUq0T+1WpPhSevIvcSHqVaK8h7kqX9o/eoWBIrObkqh37EWz43j8Y7/9Bt1G+ge7T8mTUI75p2atsCP/usTY7Wfx21VRgVWlPV/ZpqJEzPFssf4xIp09Q4eZU6ZFzZoHnhCGAy9qspEcfUaPw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=dpdk.org 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=AL6YGmgXtN0A72iEbhxJ/lY6Mm+JaDdFWZCrO0p5YoA=; b=EPPDaPsEnFHbwam/kb63XbJ0TxWhz/gv4XWqXERdvyKXDXFLTiy/t73N72M/GwBG2p67SyKW9LS4YgNJ4OXBHVH4MuRy8IkydxQH0jSdebTzQL3Sm6a321hC/paDQmAK/jOXPrjBk+WjuJWFV+TcFNCt+1PjDgYYnTFRhysCjp9Mbu79w+MSE3X1HzkIT5Vpf22i8MSf3VFKNbZSGJB/+Yw4Lj/jO7V9RG9ynXmZ7fFx/f5Yyi70MaWhs8ugfI/EKLQt9NlsUuFoVZTbSOuFDZp9jcJ8bQmJq++GGkqMXfh7joXzyY0pAavm8IZlA0ReHP6JKx1cvZADtfEQA3TY0w== Received: from BN1PR12CA0004.namprd12.prod.outlook.com (2603:10b6:408:e1::9) by MW3PR12MB4394.namprd12.prod.outlook.com (2603:10b6:303:54::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.25; Mon, 26 Sep 2022 14:58:38 +0000 Received: from BN8NAM11FT056.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e1:cafe::4f) by BN1PR12CA0004.outlook.office365.com (2603:10b6:408:e1::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.25 via Frontend Transport; Mon, 26 Sep 2022 14:58:38 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) 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.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by BN8NAM11FT056.mail.protection.outlook.com (10.13.177.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.14 via Frontend Transport; Mon, 26 Sep 2022 14:58:38 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Mon, 26 Sep 2022 07:58:24 -0700 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.29; Mon, 26 Sep 2022 07:58:20 -0700 From: Alexander Kozyrev To: CC: , , , , , , , , , , , Subject: [PATCH v5 3/7] ethdev: get meter profile/policy objects Date: Mon, 26 Sep 2022 17:57:41 +0300 Message-ID: <20220926145745.3962600-4-akozyrev@nvidia.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20220926145745.3962600-1-akozyrev@nvidia.com> References: <20220921021133.2982954-1-akozyrev@nvidia.com> <20220926145745.3962600-1-akozyrev@nvidia.com> MIME-Version: 1.0 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-TrafficTypeDiagnostic: BN8NAM11FT056:EE_|MW3PR12MB4394:EE_ X-MS-Office365-Filtering-Correlation-Id: 4e9688ce-4de3-4860-7970-08da9fcf9808 X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: MhOF2bjk7dbKQSEKGfUuvIjrGeU/iNuAEy2ohnQ9v+VIt4htcX0oh8NZVO9m2ZaL8cwmjmx9KJF+eUAptHN5YezBXMeHsWb4GJVKvsZ/hMZv1+1jCZLXcGZ9ZhNK+ir0O7s3an9TnjItIegtyHilJ0rC9Y7ZVRvtJ1HnPK+qefFjfcKnetx6Q2tLulhxm2lyK2nU7nyfNQMmi1RFq3F7/8jrU7WogVZowxZSqCzl5NAQhGdKZ2z/RYhxc8TC6UsojfWXfGuJtzUhCVB83hPuIy4JZ9cqPR/W0RCg8631E7ebmyBfI5e4sbVuv0pgd3XTgMA5Fzy/lKRl5OSIIOWn9O+0XPUza19wX+z2QuwLFLdXjIbWa4ent+lyLIKP5e7oTyIpZgm1+mk2N9DrXtYJwATL1CBKBy/GPezZNzBbCwHgjXgSgEeoPARw4aq7wTo6gbfefKQHkOM79fgylycbyr2TtSOR2SQGz1juCSnPsAaWYludWh6SVrVKEVBIMvIyNdj2zZorxHYZMghw5zVCiplvKRPAWKkOHqPbAiG8A2dvmDVaDsZB9M80xaa8HpRs/il8QvNRsSwo9hcYKD8mKMeND94/+We/e23eq7OmZvj+rFPlyyEngNO2sAa/PPtwcYJSMuyW2PCWzP1HNGkh0gNt7n8rlyRPor+pPiDK4h/WiGAb74hYzO7HtTcHuGvIkZPHU1lkhFXdn/l838WeucktpWqYfnMn9PC/VL/0t2oX6TXBdEBoHEph2obGuoQdRvog9SeNdoxBLLRZkFF8Cg== X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230022)(4636009)(39860400002)(376002)(346002)(396003)(136003)(451199015)(40470700004)(36840700001)(46966006)(478600001)(54906003)(6916009)(316002)(8676002)(70586007)(40480700001)(86362001)(4326008)(70206006)(26005)(40460700003)(5660300002)(8936002)(36756003)(83380400001)(36860700001)(47076005)(7416002)(41300700001)(6666004)(82310400005)(336012)(426003)(2616005)(82740400003)(186003)(16526019)(1076003)(2906002)(7636003)(356005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Sep 2022 14:58:38.1898 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4e9688ce-4de3-4860-7970-08da9fcf9808 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT056.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4394 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 Introduce a new Meter API to retrieve a Meter profile and policy objects using the profile/policy ID previously created with meter_profile_add() and meter_policy_create() functions. That allows to save the pointer and avoid any lookups in the corresponding lists for quick access during a flow rule creation. Also, it eliminates the need for CIR, CBS and EBS calculations and conversion to a PMD-specific format when the profile is used. Pointers are destroyed and cannot be used after the corresponding meter_profile_delete() or meter_policy_delete() are called. Signed-off-by: Alexander Kozyrev --- .../traffic_metering_and_policing.rst | 7 ++++ doc/guides/rel_notes/release_22_11.rst | 1 + lib/ethdev/rte_flow.h | 14 +++++++ lib/ethdev/rte_mtr.c | 41 +++++++++++++++++++ lib/ethdev/rte_mtr.h | 40 ++++++++++++++++++ lib/ethdev/rte_mtr_driver.h | 19 +++++++++ lib/ethdev/version.map | 4 ++ 7 files changed, 126 insertions(+) diff --git a/doc/guides/prog_guide/traffic_metering_and_policing.rst b/doc/guides/prog_guide/traffic_metering_and_policing.rst index d1958a023d..2ce3236ad8 100644 --- a/doc/guides/prog_guide/traffic_metering_and_policing.rst +++ b/doc/guides/prog_guide/traffic_metering_and_policing.rst @@ -107,6 +107,13 @@ traffic meter and policing library. to the list of meter actions (``struct rte_mtr_meter_policy_params::actions``) specified per color as show in :numref:`figure_rte_mtr_chaining`. +#. The ``rte_mtr_meter_profile_get()`` and ``rte_mtr_meter_policy_get()`` + API functions are available for getting the object pointers directly. + These pointers allow quick access to profile/policy objects and are + required by the ``RTE_FLOW_ACTION_TYPE_METER_MARK`` action. + This action may omit the policy definition to providei flexibility + to match a color later with the ``RTE_FLOW_ITEM_TYPE_METER_COLOR`` item. + Protocol based input color selection ------------------------------------ diff --git a/doc/guides/rel_notes/release_22_11.rst b/doc/guides/rel_notes/release_22_11.rst index 0fcf2093ed..47925ef005 100644 --- a/doc/guides/rel_notes/release_22_11.rst +++ b/doc/guides/rel_notes/release_22_11.rst @@ -59,6 +59,7 @@ New Features * Added METER_COLOR item to match Color Marker set by a Meter. * Added ability to set Color Marker via modify_field Flow API. + * Added Meter API to get a pointer to profile/policy by their ID. * **Updated Wangxun ngbe driver.** diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index d8e6608bcf..906c28807a 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -3822,6 +3822,20 @@ struct rte_flow_action { */ struct rte_flow; +/** + * Opaque type for Meter profile object returned by MTR API. + * + * This handle can be used to create Meter actions instead of profile ID. + */ +struct rte_flow_meter_profile; + +/** + * Opaque type for Meter policy object returned by MTR API. + * + * This handle can be used to create Meter actions instead of policy ID. + */ +struct rte_flow_meter_policy; + /** * @warning * @b EXPERIMENTAL: this structure may change without prior notice diff --git a/lib/ethdev/rte_mtr.c b/lib/ethdev/rte_mtr.c index c460e4f4e0..9e79b744da 100644 --- a/lib/ethdev/rte_mtr.c +++ b/lib/ethdev/rte_mtr.c @@ -56,6 +56,25 @@ rte_mtr_ops_get(uint16_t port_id, struct rte_mtr_error *error) ops->func; \ }) +#define RTE_MTR_HNDL_FUNC(port_id, func) \ +({ \ + const struct rte_mtr_ops *ops = \ + rte_mtr_ops_get(port_id, error); \ + if (ops == NULL) \ + return NULL; \ + \ + if (ops->func == NULL) { \ + rte_mtr_error_set(error, \ + ENOSYS, \ + RTE_MTR_ERROR_TYPE_UNSPECIFIED, \ + NULL, \ + rte_strerror(ENOSYS)); \ + return NULL; \ + } \ + \ + ops->func; \ +}) + /* MTR capabilities get */ int rte_mtr_capabilities_get(uint16_t port_id, @@ -90,6 +109,17 @@ rte_mtr_meter_profile_delete(uint16_t port_id, meter_profile_id, error); } +/** MTR meter profile get */ +struct rte_flow_meter_profile * +rte_mtr_meter_profile_get(uint16_t port_id, + uint32_t meter_profile_id, + struct rte_mtr_error *error) +{ + struct rte_eth_dev *dev = &rte_eth_devices[port_id]; + return RTE_MTR_HNDL_FUNC(port_id, meter_profile_get)(dev, + meter_profile_id, error); +} + /* MTR meter policy validate */ int rte_mtr_meter_policy_validate(uint16_t port_id, @@ -124,6 +154,17 @@ rte_mtr_meter_policy_delete(uint16_t port_id, policy_id, error); } +/** MTR meter policy get */ +struct rte_flow_meter_policy * +rte_mtr_meter_policy_get(uint16_t port_id, + uint32_t policy_id, + struct rte_mtr_error *error) +{ + struct rte_eth_dev *dev = &rte_eth_devices[port_id]; + return RTE_MTR_HNDL_FUNC(port_id, meter_policy_get)(dev, + policy_id, error); +} + /** MTR object create */ int rte_mtr_create(uint16_t port_id, diff --git a/lib/ethdev/rte_mtr.h b/lib/ethdev/rte_mtr.h index 008bc84f0d..58f0d26215 100644 --- a/lib/ethdev/rte_mtr.h +++ b/lib/ethdev/rte_mtr.h @@ -623,6 +623,26 @@ rte_mtr_meter_profile_delete(uint16_t port_id, uint32_t meter_profile_id, struct rte_mtr_error *error); +/** + * Meter profile object get + * + * Get meter profile object for a given meter profile ID. + * + * @param[in] port_id + * The port identifier of the Ethernet device. + * @param[in] meter_profile_id + * Meter profile ID. Needs to be the valid. + * @param[out] error + * Error details. Filled in only on error, when not NULL. + * @return + * A valid handle in case of success, NULL otherwise. + */ +__rte_experimental +struct rte_flow_meter_profile * +rte_mtr_meter_profile_get(uint16_t port_id, + uint32_t meter_profile_id, + struct rte_mtr_error *error); + /** * Check whether a meter policy can be created on a given port. * @@ -679,6 +699,26 @@ rte_mtr_meter_policy_add(uint16_t port_id, struct rte_mtr_meter_policy_params *policy, struct rte_mtr_error *error); +/** + * Meter policy object get + * + * Get meter policy object for a given meter policy ID. + * + * @param[in] port_id + * The port identifier of the Ethernet device. + * @param[in] policy_id + * Meter policy ID. Needs to be the valid. + * @param[out] error + * Error details. Filled in only on error, when not NULL. + * @return + * A valid handle in case of success, NULL otherwise. + */ +__rte_experimental +struct rte_flow_meter_policy * +rte_mtr_meter_policy_get(uint16_t port_id, + uint32_t policy_id, + struct rte_mtr_error *error); + /** * Define meter policy action list: * GREEN - GREEN, YELLOW - YELLOW, RED - RED diff --git a/lib/ethdev/rte_mtr_driver.h b/lib/ethdev/rte_mtr_driver.h index f7dca9a54c..948a629b93 100644 --- a/lib/ethdev/rte_mtr_driver.h +++ b/lib/ethdev/rte_mtr_driver.h @@ -41,6 +41,12 @@ typedef int (*rte_mtr_meter_profile_delete_t)(struct rte_eth_dev *dev, uint32_t meter_profile_id, struct rte_mtr_error *error); +/** @internal MTR meter profile get. */ +typedef struct rte_flow_meter_profile * +(*rte_mtr_meter_profile_get_t)(struct rte_eth_dev *dev, + uint32_t meter_profile_id, + struct rte_mtr_error *error); + /** @internal MTR meter policy validate. */ typedef int (*rte_mtr_meter_policy_validate_t)(struct rte_eth_dev *dev, struct rte_mtr_meter_policy_params *policy, @@ -57,6 +63,13 @@ typedef int (*rte_mtr_meter_policy_delete_t)(struct rte_eth_dev *dev, uint32_t policy_id, struct rte_mtr_error *error); +/** @internal MTR meter policy get. */ +typedef struct rte_flow_meter_policy * +(*rte_mtr_meter_policy_get_t)(struct rte_eth_dev *dev, + uint32_t policy_id, + struct rte_mtr_error *error); + + /** @internal MTR object create. */ typedef int (*rte_mtr_create_t)(struct rte_eth_dev *dev, uint32_t mtr_id, @@ -194,6 +207,12 @@ struct rte_mtr_ops { /** MTR object meter policy update */ rte_mtr_meter_policy_update_t meter_policy_update; + + /** MTR meter profile get */ + rte_mtr_meter_profile_get_t meter_profile_get; + + /** MTR meter policy get */ + rte_mtr_meter_policy_get_t meter_policy_get; }; /** diff --git a/lib/ethdev/version.map b/lib/ethdev/version.map index 03f52fee91..1fec250c85 100644 --- a/lib/ethdev/version.map +++ b/lib/ethdev/version.map @@ -285,6 +285,10 @@ EXPERIMENTAL { rte_mtr_color_in_protocol_priority_get; rte_mtr_color_in_protocol_set; rte_mtr_meter_vlan_table_update; + + # added in 22.11 + rte_mtr_meter_profile_get; + rte_mtr_meter_policy_get; }; INTERNAL { From patchwork Mon Sep 26 14:57:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Kozyrev X-Patchwork-Id: 116892 X-Patchwork-Delegate: andrew.rybchenko@oktetlabs.ru Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id B9ED0A00C2; Mon, 26 Sep 2022 16:58:45 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 2823A42B6E; Mon, 26 Sep 2022 16:58:39 +0200 (CEST) Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam07on2066.outbound.protection.outlook.com [40.107.212.66]) by mails.dpdk.org (Postfix) with ESMTP id DDA1C42B76 for ; Mon, 26 Sep 2022 16:58:36 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=g9TGpcHbMiM6KzEEhQxZ+ch/ZJMLgxXgV6HUcJExEP/Vngm7db+y9Q3Nrb6MYXHnfqkClOi9Sxa81cOkl0CkkA4FyACIP7+oNJSgo5fCwnfXDDDLeajWiJXr+wEvDZ6zpErbfNBjQnY1G0yfOliUJRofOtzKodTOHxaWndsgU17bbYSMc4pKJOcMzceYx/+BMTao5eiiVGOlhZtSBsyw+WBIzvohOmR4oRAnMBHjgyZYSINTGOT0a3U3UzNEWZOvsrsUOCwpU2/jUn1lXq4YLTS7rClWpEeZ3hyEYNqajXCkZvd2iXLcXXtZt1ezmlVx9Nu1vx6tLoJv2nDU9fSK+Q== 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=ASmnbmXf5pN7G6ArcinnpguqadBZz7mozLymfu0IYQc=; b=d15PEG5sjz0FZ2n140kVytYXdcx8T/a8kwWG9npOnx1eUDOrFI/QOmT26WIuEvwkGW0Uj+zW/Dn8urGxwFYsgG/2+hNeHFnyvu2UlijM9wXfxkZqoOo9K5cKF7NpKhsWwNVo4DdQ/eoMdVe2AS5PZSlBVRvXQtoDCoSgfAfYTUhxc7lFkrOYhTiE2uNXC3Y6NR/J9Hyshc2hduRJMfNCVkiHPrlegKlyFENa6sIesrYbzi71du7RtaCtXlYZSOjxYLNdEpWUQ+LGpwNnnZVIdAb1hYbYmVYpH5NKgHlkSdH3U0eFWslXGJG77NIA7sFmGCcxFNVd5NqwCAYD2pB6oQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=dpdk.org 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=ASmnbmXf5pN7G6ArcinnpguqadBZz7mozLymfu0IYQc=; b=cSzq8cJs+2EuepNwzdIh++li5jgl4AX+JRAx+pP0NlkLqQTTOFOEq4CznKDyFv1iwUsFLkQkf0POTIsESVAeyPKYQ9u/5Z3fLK9Kv17ymfXqGHbu4mi46TPVDdKo69q/Jv5VpvpVU/camP3oCsG3SxZGvV9RzLCia/pn1wGjY4WpMwuzEZsujvA9fNRnw4YxAhN6LVOEiAxVfz3SPwC2Z6R3p+FdLrCcHemV+Zu0qnUyZX8V9paK+GpcgQYT6nz/S/ZIATxPOd6jnFjDBOduDXiVN57zB+Lz3f6fsPvnlIqXvWnM77DlHj0QTVO2MgamoVf1kQej9kXvuRFI6Augug== Received: from DS7PR05CA0046.namprd05.prod.outlook.com (2603:10b6:8:2f::14) by CY8PR12MB7435.namprd12.prod.outlook.com (2603:10b6:930:51::6) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.25; Mon, 26 Sep 2022 14:58:35 +0000 Received: from DM6NAM11FT106.eop-nam11.prod.protection.outlook.com (2603:10b6:8:2f:cafe::fc) by DS7PR05CA0046.outlook.office365.com (2603:10b6:8:2f::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.9 via Frontend Transport; Mon, 26 Sep 2022 14:58:35 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) 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.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by DM6NAM11FT106.mail.protection.outlook.com (10.13.172.229) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.14 via Frontend Transport; Mon, 26 Sep 2022 14:58:35 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Mon, 26 Sep 2022 07:58:28 -0700 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.29; Mon, 26 Sep 2022 07:58:24 -0700 From: Alexander Kozyrev To: CC: , , , , , , , , , , , Subject: [PATCH v5 4/7] ethdev: add meter color mark flow action Date: Mon, 26 Sep 2022 17:57:42 +0300 Message-ID: <20220926145745.3962600-5-akozyrev@nvidia.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20220926145745.3962600-1-akozyrev@nvidia.com> References: <20220921021133.2982954-1-akozyrev@nvidia.com> <20220926145745.3962600-1-akozyrev@nvidia.com> MIME-Version: 1.0 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-TrafficTypeDiagnostic: DM6NAM11FT106:EE_|CY8PR12MB7435:EE_ X-MS-Office365-Filtering-Correlation-Id: 4157be89-1077-46b8-132b-08da9fcf9627 X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: PvFT9ltiu4uIa5OJZIWy//pI4o1cX6WkQSIfu9pIxrLx1RrbEowExtBaM1QH/8cy4Y/EKYssDWkhtF7+tHDE0bNSWXyzQnHEY/gQkCFHs1+j5kurAqPGdXE+6uoBlAvdOBe+bfu1xG4T8rwrXHRt7PYCzqXhynNS3FXFekixN4/GfoumdQ309aY/r51I0KAY7J0Bu/QJc6f5D/Kl2EQKn6x0Uj7ilrEk+FR/b1fgXOUxRJRv0vUEDJ4H5HyJN97hiY0S7o9FxaUuzBZd6Tp770H67eK1gNL/tVnE4Pbt1aUKpEmVieAG/8JBIPICDthMaHmYdVNG2qNuXkHpJ6FcB/tYaaTy7rrr6dYSni1CPiaaoaDLSe7hvjPdLONFZJ0n61GTXYqeLWPA0lnU2cCu8TJVEfPu0Ql+n3/J7iJyZRK2qg+fp3hUjrN191V5+snvRMR6fhtPldpggjR7nMh+9xw0KWvFB8f7/OlAXU4ZyqBGRaW002EyH4xV0uxVPYVV/RDlKI1kaoSwG6HcEjGwLyr1fXoOxuJvKvhOebdNj1Fy3sFmhb309o8ABcv94R7f494S0vV/B2gr1IMA/qHOPEd3dp+OdtskVuJ/Vw030UDpB31BIoSslZJTzThlvbHqU0UWN+OtPQjnnubrK3Jg2CUOFOPmKKVKzwHRRFraNIyVbSp3HLB3obwjU0ZBRmI3yYi//aNTo6QOOWsaKGOMI4cnMna1WIvnaUMr2bWSZzakMqYiDtEsWCvy+AhbT38fQHht7iW/Yjx25JMFV2DVuQ== X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230022)(4636009)(39860400002)(396003)(136003)(376002)(346002)(451199015)(36840700001)(46966006)(40470700004)(54906003)(26005)(5660300002)(478600001)(316002)(6916009)(70206006)(70586007)(6666004)(8936002)(41300700001)(7416002)(2906002)(426003)(1076003)(83380400001)(40460700003)(36860700001)(47076005)(336012)(186003)(16526019)(36756003)(86362001)(40480700001)(4326008)(8676002)(82310400005)(82740400003)(2616005)(7636003)(356005); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Sep 2022 14:58:35.1130 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4157be89-1077-46b8-132b-08da9fcf9627 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT106.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY8PR12MB7435 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 Create a new Flow API action: METER_MARK. It Meters a packet stream and marks its packets with colors. The marking is done on a metadata, not on a packet field. Unlike the METER action, it performs no policing at all. A user has the flexibility to create any policies with the help of the METER_COLOR item later, only meter profile is mandatory here. Signed-off-by: Alexander Kozyrev --- doc/guides/prog_guide/rte_flow.rst | 25 ++++++++++++ doc/guides/rel_notes/release_22_11.rst | 1 + lib/ethdev/rte_flow.c | 1 + lib/ethdev/rte_flow.h | 56 ++++++++++++++++++++++++++ 4 files changed, 83 insertions(+) diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 018def1033..5b87d9f61e 100644 --- a/doc/guides/prog_guide/rte_flow.rst +++ b/doc/guides/prog_guide/rte_flow.rst @@ -3411,6 +3411,31 @@ This action is meant to use the same structure as `Action: PORT_REPRESENTOR`_. See also `Item: REPRESENTED_PORT`_. +Action: ``METER_MARK`` +^^^^^^^^^^^^^^^^^^^^^^ + +Meters a packet stream and marks its packets with colors. + +Unlike the ``METER`` action, policing is optional and may be +performed later with the help of the ``METER_COLOR`` item. +The profile and/or policy objects have to be created +using the rte_mtr_profile_add()/rte_mtr_policy_add() API. +Pointers to these objects are used as action parameters +and need to be retrieved using the rte_mtr_profile_get() API +and rte_mtr_policy_get() API respectively. + +.. _table_rte_flow_action_meter_mark: + +.. table:: METER_MARK + + +------------------+----------------------+ + | Field | Value | + +==================+======================+ + | ``profile`` | Meter profile object | + +------------------+----------------------+ + | ``policy`` | Meter policy object | + +------------------+----------------------+ + Negative types ~~~~~~~~~~~~~~ diff --git a/doc/guides/rel_notes/release_22_11.rst b/doc/guides/rel_notes/release_22_11.rst index 47925ef005..375af892ac 100644 --- a/doc/guides/rel_notes/release_22_11.rst +++ b/doc/guides/rel_notes/release_22_11.rst @@ -60,6 +60,7 @@ New Features * Added METER_COLOR item to match Color Marker set by a Meter. * Added ability to set Color Marker via modify_field Flow API. * Added Meter API to get a pointer to profile/policy by their ID. + * Added METER_MARK action for Metering with lockless profile/policy access. * **Updated Wangxun ngbe driver.** diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c index 99247b599d..7ff024f33e 100644 --- a/lib/ethdev/rte_flow.c +++ b/lib/ethdev/rte_flow.c @@ -260,6 +260,7 @@ static const struct rte_flow_desc_data rte_flow_desc_action[] = { MK_FLOW_ACTION(CONNTRACK, sizeof(struct rte_flow_action_conntrack)), MK_FLOW_ACTION(PORT_REPRESENTOR, sizeof(struct rte_flow_action_ethdev)), MK_FLOW_ACTION(REPRESENTED_PORT, sizeof(struct rte_flow_action_ethdev)), + MK_FLOW_ACTION(METER_MARK, sizeof(struct rte_flow_action_meter_mark)), }; int diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index 906c28807a..4531d2f7c5 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -2903,6 +2903,14 @@ enum rte_flow_action_type { * @see struct rte_flow_action_ethdev */ RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT, + + /** + * Traffic metering and marking (MTR). + * + * @see struct rte_flow_action_meter_mark + * See file rte_mtr.h for MTR profile object configuration. + */ + RTE_FLOW_ACTION_TYPE_METER_MARK, }; /** @@ -3774,6 +3782,54 @@ struct rte_flow_action_modify_field { uint32_t width; /**< Number of bits to use from a source field. */ }; +/** + * RTE_FLOW_ACTION_TYPE_METER_MARK + * + * Traffic metering and marking (MTR). + * + * Meters a packet stream and marks its packets either + * green, yellow, or red according to the specified profile. + * The policy is optional and may be specified for defining + * subsequent actions based on a color assigned by MTR. + * Alternatively, the METER_COLOR item may be used for this. + */ +struct rte_flow_action_meter_mark { + + /**< Profile config retrieved with rte_mtr_profile_get(). */ + struct rte_flow_meter_profile *profile; + /**< Policy config retrieved with rte_mtr_policy_get(). */ + struct rte_flow_meter_policy *policy; + /** Metering mode: 0 - Color-Blind, 1 - Color-Aware. */ + int color_mode; + /** Initial Color applied to packets in Color-Aware mode. */ + enum rte_color init_color; + /** Metering state: 0 - Disabled, 1 - Enabled. */ + int state; +}; + +/** + * RTE_FLOW_ACTION_TYPE_METER_MARK + * + * Wrapper structure for the context update interface. + * + */ +struct rte_flow_update_meter_mark { + /** New meter_mark parameters to be updated. */ + struct rte_flow_action_meter_mark meter_mark; + /** The profile will be updated. */ + uint32_t profile_valid:1; + /** The policy will be updated. */ + uint32_t policy_valid:1; + /** The color mode will be updated. */ + uint32_t color_mode_valid:1; + /** The initial color will be updated. */ + uint32_t init_color_valid:1; + /** The meter state will be updated. */ + uint32_t state_valid:1; + /** Reserved bits for the future usage. */ + uint32_t reserved:27; +}; + /* Mbuf dynamic field offset for metadata. */ extern int32_t rte_flow_dynf_metadata_offs; From patchwork Mon Sep 26 14:57:43 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Kozyrev X-Patchwork-Id: 116895 X-Patchwork-Delegate: andrew.rybchenko@oktetlabs.ru Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 1E2B0A00C2; Mon, 26 Sep 2022 16:59:08 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 986ED42B7E; Mon, 26 Sep 2022 16:58:47 +0200 (CEST) Received: from NAM04-DM6-obe.outbound.protection.outlook.com (mail-dm6nam04on2061.outbound.protection.outlook.com [40.107.102.61]) by mails.dpdk.org (Postfix) with ESMTP id 0CCE14069B for ; Mon, 26 Sep 2022 16:58:46 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LT0BVx96sqs8rGggQh0IndssfAqDjS09Lae+aOKDcv9h8M3epYr96DMpEVppfNSXa7LZWHttmATHWJKfMda0UL9mlIjjOc6tRcPmyYdRvr4lSobuqM6QaxZ0GZ+nrpjpXbk8WGWFXELSxZ3PUwS7wq5m/63pHnxOVbzgBhWRxF7ZHLz0a4vBMw9ACIisbpbL3/+B7xuONSqGzyMEhMoHSJpq8iyaNYCXhgwKkF+fTsKcfGMKy+0q3YatoKGePLdXqJr0JvJhUVPPIi3hBvMT23CZjmTF3CcvUypB3C7fTn6XFZ6li3IMCxcPgWfBr9rbGjxGFIDnRuYmlvdJ0Wl8Hg== 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=OSc012QTAAPCpca/QiKV7658B37NEdHsKBx7sQuRA0k=; b=OnNsrOVB73paGJUXFhQ8BcHEUeJNTHOh3f3ouI0v5sNJeT2se1rI5QgeArUf4HxIcNPVDIGBUech1G/OoCw6xknWtNnUfwkJGd44cyWRcHCHal/j8dXJFqQXqzanbeYzGJO1VjmeNm8eOg9AZnnCgkd1ps0SaFhfk1ByH0erOcb/sRf9K8AqfHacypxFtTPfGoLznUsYT6ZJHV0/ncdKnW+ERiPyG+lBqH+gZ2rcd0LGPU2LaK5Eik56SS2DwGL9+EnDEbWw4/Oc6KnQoxUpKKhyRwlveF///h+H/ZdNNv5GnDQazVSn9+nNkT6gc4Q9LLKswHYYChU03URDbfv/7g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.161) smtp.rcpttodomain=dpdk.org 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=OSc012QTAAPCpca/QiKV7658B37NEdHsKBx7sQuRA0k=; b=HiZp54dxHSOAmRwllzBhP8qSpB2hVHp1nKH95ZrvqXNKGrTUDECBpaDxmU0fpLowqpF1Jb0O0wI/BfYHXUhoe6yTM44TSXWZpr/I8E4DKE9sBXE9xWbnRiftDwp4rWu57vC/rmLeKY0r3xBt+KRlil96j8iGIeefbwB/xAl1V3abD/hhAzVzM4k2dB1wPDKfPtPx9fliCPv1KA/EL37AxTcsK6pRzhzLFb6PlHudZwBUCwRxJOUquxZAZ3k/KK3prxsAVesnJuQGXp4d531Db4G1SnItHlW/4toDOmkkz71iq/knw0uDxitesrQ7YKi7MCpFNKqr5sts/07vlcQRow== Received: from BN0PR02CA0047.namprd02.prod.outlook.com (2603:10b6:408:e5::22) by SA0PR12MB4461.namprd12.prod.outlook.com (2603:10b6:806:9c::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.26; Mon, 26 Sep 2022 14:58:42 +0000 Received: from BN8NAM11FT028.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e5:cafe::34) by BN0PR02CA0047.outlook.office365.com (2603:10b6:408:e5::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.25 via Frontend Transport; Mon, 26 Sep 2022 14:58:42 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.161) 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.117.161 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.161; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.161) by BN8NAM11FT028.mail.protection.outlook.com (10.13.176.225) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.14 via Frontend Transport; Mon, 26 Sep 2022 14:58:42 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.67) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Mon, 26 Sep 2022 07:58:32 -0700 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.29; Mon, 26 Sep 2022 07:58:28 -0700 From: Alexander Kozyrev To: CC: , , , , , , , , , , , Subject: [PATCH v5 5/7] app/testpmd: add meter color flow matching item Date: Mon, 26 Sep 2022 17:57:43 +0300 Message-ID: <20220926145745.3962600-6-akozyrev@nvidia.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20220926145745.3962600-1-akozyrev@nvidia.com> References: <20220921021133.2982954-1-akozyrev@nvidia.com> <20220926145745.3962600-1-akozyrev@nvidia.com> MIME-Version: 1.0 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-TrafficTypeDiagnostic: BN8NAM11FT028:EE_|SA0PR12MB4461:EE_ X-MS-Office365-Filtering-Correlation-Id: 920a4c72-84ae-4bb4-72ac-08da9fcf9a8d X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /LSP2TYTqDyzLJ0KSz3KHXbhZ0OB4io9wCaxHz5UvY3lemQPMQSheT9b6yg/DHGfeoBIq1jC6gES2ucweQKrIiVIUFfACxQA1oseSV7yaHo147+zigznDSfFBnWqzYEWK2kEJiNZWYQATLUC48Xhlfxd9bph9TBoyofFte33gq9h4SNrLnbMd3VmgIeMr21uNXc1loZV4mIQskv5aJTG4D+1319CB+QdLrYOYkdinAAzTQ8lfpdF747Ou9Cma7D6Luy2wqTgNOQgoKWbkBJBt5iN9TT5AjyPVeCgELBm0HNlPafOurtk31mBrnXdjrVaUFA5Nf/bL0nMMQGkcpWrwmsdY6TRneEmmjIgDy8e8n1ICqE99MRk6xI03dklLhYYbyEv1azR6M6zhuy2vhhEZnA5ZVe9YMqIKswMhPx8xxYERAL98/GqcsIoJ0KQD4uA2NDalF7UTxgLHIHc3g93SOvpKqZSfkSOIoaDAIRAZOiRNnKu3MbPwS+naGEbJdsHZemYF1lTJ/DTBDW5Ow8UDjK9yR5X8PIdfmXcNlxEEllGxZGGSpAam/GRhMdAyqWYm1RW3uh4RYPA6LxDHZJJGRrKInj2sT8WMbHc9N72aXkCs5PNbZW57IxwhWpvAytvMxJcvsjr5agNG1frzfDpsV/Rg+iZr0F2oQiFoLoss7JDFApAomSohthRzTLIpLkdIk3+dZsJ01U6PCmjlwUEnP6TjGySOei9I++foh0I+dHoa4Q3iM9pUVoXiszSVqLnjZP59D7shgDll404ccLeMQ== X-Forefront-Antispam-Report: CIP:216.228.117.161; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge2.nvidia.com; CAT:NONE; SFS:(13230022)(4636009)(39860400002)(136003)(396003)(346002)(376002)(451199015)(40470700004)(46966006)(36840700001)(83380400001)(426003)(1076003)(186003)(16526019)(336012)(356005)(7636003)(82310400005)(82740400003)(36756003)(40460700003)(47076005)(86362001)(40480700001)(36860700001)(70206006)(70586007)(8676002)(4326008)(6666004)(41300700001)(54906003)(478600001)(316002)(6916009)(8936002)(26005)(2906002)(2616005)(7416002)(5660300002); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Sep 2022 14:58:42.4323 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 920a4c72-84ae-4bb4-72ac-08da9fcf9a8d X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.161]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT028.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: SA0PR12MB4461 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 Add testpmd command line to match on a meter color: flow create 0 ingress group 0 pattern meter color is green / end Signed-off-by: Alexander Kozyrev --- app/test-pmd/cmdline_flow.c | 83 +++++++++++++++++++++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 4 + 2 files changed, 87 insertions(+) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index d97be6fe98..57fc30d13b 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -459,6 +459,9 @@ enum index { ITEM_PPP_ADDR, ITEM_PPP_CTRL, ITEM_PPP_PROTO_ID, + ITEM_METER, + ITEM_METER_COLOR, + ITEM_METER_COLOR_NAME, /* Validate/create actions. */ ACTIONS, @@ -800,6 +803,10 @@ static const char *const modify_field_ids[] = { "ipv4_ecn", "ipv6_ecn", NULL }; +static const char *const meter_colors[] = { + "green", "yellow", "red", "all", NULL +}; + /** Maximum number of subsequent tokens and arguments on the stack. */ #define CTX_STACK_SIZE 16 @@ -1333,6 +1340,7 @@ static const enum index next_item[] = { ITEM_FLEX, ITEM_L2TPV2, ITEM_PPP, + ITEM_METER, END_SET, ZERO, }; @@ -1805,6 +1813,12 @@ static const enum index item_ppp[] = { ZERO, }; +static const enum index item_meter[] = { + ITEM_METER_COLOR, + ITEM_NEXT, + ZERO, +}; + static const enum index next_action[] = { ACTION_END, ACTION_VOID, @@ -2373,6 +2387,9 @@ static int parse_ia_id2ptr(struct context *ctx, const struct token *token, static int parse_mp(struct context *, const struct token *, const char *, unsigned int, void *, unsigned int); +static int parse_meter_color(struct context *ctx, const struct token *token, + const char *str, unsigned int len, void *buf, + unsigned int size); static int comp_none(struct context *, const struct token *, unsigned int, char *, unsigned int); static int comp_boolean(struct context *, const struct token *, @@ -2403,6 +2420,8 @@ static int comp_table_id(struct context *, const struct token *, unsigned int, char *, unsigned int); static int comp_queue_id(struct context *, const struct token *, unsigned int, char *, unsigned int); +static int comp_meter_color(struct context *, const struct token *, + unsigned int, char *, unsigned int); /** Token definitions. */ static const struct token token_list[] = { @@ -5065,6 +5084,29 @@ static const struct token token_list[] = { .args = ARGS(ARGS_ENTRY(struct rte_flow_item_ppp, hdr.proto_id)), }, + [ITEM_METER] = { + .name = "meter", + .help = "match meter color", + .priv = PRIV_ITEM(METER_COLOR, + sizeof(struct rte_flow_item_meter_color)), + .next = NEXT(item_meter), + .call = parse_vc, + }, + [ITEM_METER_COLOR] = { + .name = "color", + .help = "meter color", + .next = NEXT(item_meter, + NEXT_ENTRY(ITEM_METER_COLOR_NAME), + item_param), + .args = ARGS(ARGS_ENTRY(struct rte_flow_item_meter_color, + color)), + }, + [ITEM_METER_COLOR_NAME] = { + .name = "color_name", + .help = "meter color name", + .call = parse_meter_color, + .comp = comp_meter_color, + }, /* Validate/create actions. */ [ACTIONS] = { .name = "actions", @@ -9868,6 +9910,30 @@ parse_flex_handle(struct context *ctx, const struct token *token, return ret; } +/** Parse Meter color name */ +static int +parse_meter_color(struct context *ctx, const struct token *token, + const char *str, unsigned int len, void *buf, + unsigned int size) +{ + struct rte_flow_item_meter_color *meter_color; + unsigned int i; + + (void)token; + (void)buf; + (void)size; + for (i = 0; meter_colors[i]; ++i) + if (!strcmp_partial(meter_colors[i], str, len)) + break; + if (!meter_colors[i]) + return -1; + if (!ctx->object) + return len; + meter_color = ctx->object; + meter_color->color = (enum rte_color)i; + return len; +} + /** No completion. */ static int comp_none(struct context *ctx, const struct token *token, @@ -10159,6 +10225,20 @@ comp_queue_id(struct context *ctx, const struct token *token, return i; } +/** Complete available Meter colors. */ +static int +comp_meter_color(struct context *ctx, const struct token *token, + unsigned int ent, char *buf, unsigned int size) +{ + RTE_SET_USED(ctx); + RTE_SET_USED(token); + if (!buf) + return RTE_DIM(meter_colors); + if (ent < RTE_DIM(meter_colors) - 1) + return strlcpy(buf, meter_colors[ent], size); + return -1; +} + /** Internal context. */ static struct context cmd_flow_context; @@ -10774,6 +10854,9 @@ flow_item_default_mask(const struct rte_flow_item *item) case RTE_FLOW_ITEM_TYPE_PPP: mask = &rte_flow_item_ppp_mask; break; + case RTE_FLOW_ITEM_TYPE_METER_COLOR: + mask = &rte_flow_item_meter_color_mask; + break; default: break; } diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index 5fbec06c35..b586e92649 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3697,6 +3697,10 @@ This section lists supported pattern items and their attributes, if any. - ``ctrl {unsigned}``: PPP control. - ``proto_id {unsigned}``: PPP protocol identifier. +- ``meter``: match Meter color. + + - ``color {value}``: Meter color value(green/yellow/red). + Actions list ^^^^^^^^^^^^ From patchwork Mon Sep 26 14:57:44 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Kozyrev X-Patchwork-Id: 116894 X-Patchwork-Delegate: andrew.rybchenko@oktetlabs.ru Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 58F4EA00C2; Mon, 26 Sep 2022 16:58:59 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 5617342B87; Mon, 26 Sep 2022 16:58:43 +0200 (CEST) Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2046.outbound.protection.outlook.com [40.107.92.46]) by mails.dpdk.org (Postfix) with ESMTP id 140EE42B7A for ; Mon, 26 Sep 2022 16:58:41 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ezE4kZg/IWJoEi4VGWfOn6QDZkkVOd7JnTL/JGAS8JMXAnZVELsoLJPm+gaxF7Rort2htQfvEOzAzD5EwDQaqR9oDpzydCmhu7SQP0a95ni0doQq4icW30JZCd8r6NKhPVhAqr6F8NuZEr0c2j5s/AKBywLABuvyngS5vINbiJDEbCd47T5WFeepdIFBn+eAoUrZhMgJRAx3CGad7/WcLQIeg6wXq+D5ikxwBnd7EZjL8A+OupL/Ky5mjGxNl3jpr7B9YXlC6wLro/drACHtR3O+0WhWGTLeDfcYXjCUf8EfhI39nco6orwL/ZiHpg/OVXN87qGrrQ6NICamn3cvTg== 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=bUNnRyAD2KOF/Orkd1vhRo9w92rKVaNNmvJJJIx3lOo=; b=Iwwo9SOvQxUbO6ccIW++D80FUb0PEwP9Ea2pYrk+3Z1+6iSKJm4PYLUW7OCqAoTBAbQTJnNiT5f1DLkQLAw/8aYCVFsuOKZcW0005BD4Q4Pg+d/RyAdSMymWqn/CHnG58BMoR2SZrhScrldnqyzOjNfya0O+lzYRLrpOokC9nF5gBpXsXSQsWEAgP3pO+JjCq4nFbl6JRNCTjYkkbdsHTmUITIQpE1F4RoAY4fe5nWl3ENA3foq91wYONC1XvhWgo+MSagsBaDh4RSNk42B6S2BRHJn0xtjT2wGBxteN1zqoek30hXBALX4Cg1sgGMluX7hKZMNSsWd+ZW7tCF5iSg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=dpdk.org 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=bUNnRyAD2KOF/Orkd1vhRo9w92rKVaNNmvJJJIx3lOo=; b=f6zxAKld/xT+MLPASmEZGhuZNoduUL37ZMf3tK2idshL/dFOGodMDkyfYZq3Q3+aEgxllCT68zFtvfzVO8ihoUJf5Moi4SH4Vo6wz9PvYlRQlysvdObzrLG2ToYvj/p2YfHOeyp7CtPM2YL+qoQO8r/JiiXlZxPIMg0TGhh2Zlba6BU60lRz+mEBKs9JmmSXbbVZIrJsMN9I4K5tkoAWay/9OVTJey1pOschwgcttR0nC9h9WtyVNXTNQxsDbJLlrI4Ocu2J3W20VNckLHpMEeA2dlfSivjADuGvicD9VmxgiNDrJKZWzZA3ttfeuvwzIGDyBcdOddRFTN4JYNzi3g== Received: from DS7PR05CA0056.namprd05.prod.outlook.com (2603:10b6:8:2f::17) by DM4PR12MB5231.namprd12.prod.outlook.com (2603:10b6:5:39b::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.25; Mon, 26 Sep 2022 14:58:38 +0000 Received: from DM6NAM11FT106.eop-nam11.prod.protection.outlook.com (2603:10b6:8:2f:cafe::95) by DS7PR05CA0056.outlook.office365.com (2603:10b6:8:2f::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.11 via Frontend Transport; Mon, 26 Sep 2022 14:58:38 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) 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.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by DM6NAM11FT106.mail.protection.outlook.com (10.13.172.229) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.14 via Frontend Transport; Mon, 26 Sep 2022 14:58:38 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Mon, 26 Sep 2022 07:58:36 -0700 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.29; Mon, 26 Sep 2022 07:58:32 -0700 From: Alexander Kozyrev To: CC: , , , , , , , , , , , Subject: [PATCH v5 6/7] app/testpmd: allow meter color marker modification Date: Mon, 26 Sep 2022 17:57:44 +0300 Message-ID: <20220926145745.3962600-7-akozyrev@nvidia.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20220926145745.3962600-1-akozyrev@nvidia.com> References: <20220921021133.2982954-1-akozyrev@nvidia.com> <20220926145745.3962600-1-akozyrev@nvidia.com> MIME-Version: 1.0 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-TrafficTypeDiagnostic: DM6NAM11FT106:EE_|DM4PR12MB5231:EE_ X-MS-Office365-Filtering-Correlation-Id: c6413cee-1eda-4408-2fe9-08da9fcf9812 X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: RD4/JGAQKzJ7GTiatip6Z8p/zxwmNWvlTRL86IH6QajyuH1HOas0K5XON6Vc9XVCiuV53SDHu+zteIPdSh1v+VQIDGfXKvkHWACcLEla4BCRxz661KuqAs8BnHmDyd48hEVagOfZrF/jBNzXiwhSWF9nZG2vgsNI5uJ9y7L8BeuwGChVAF/RgTX5b/zTQ0E0JxujAw9Gw42DZzx7y5PPXRb14mSr2XHBps63T9C8dLR4M0MtenK3bKS+Of/syjnkZImIYFQpTfPJ3na1Rw5pN7m/Ub4l1vQkVwgfS+Siq1heK4MxjJckfTyKBLOx1PaduGW8qxQoN1aDOCwEzcy0Dg5YAG/jyZWTIfJ+8tJrYohcUEb+8iSFdRfhUOsii8utZMaUNipQ9jxozxgjy8S4/QUL0XLw1BnCDZKwdlNd5tQj8WxU1vl6LRvleRoNoPMPumsQbraRfABtxXCQm1Snl9ui4agX/hG1d0S+2Lg9ztAQuuWkDn2olBTTtGQQcmmLj0Tr0+Zhaf9rQdAjMyicewexpktPqLVFnhUeJ4+YL2UBYCDXCIii5oakR238EjN11cizEW7vUFNa+nx5nKvSR9MIQl3V7FAykn2nMdg0WnnqgSgzK0RExs4akj7pzAu5p2iNAttHQ3TgJugAdpaUoQPvZoeG2zT7CpE2vlVw/fvLTKq0KiLYZu5yof7gH2mLy6DoAAirHp5bk85p/Gx/3r7xWuvIiFOSG9J2hLfdsgg6Nl2XqGP/rWT6kYAHKKZpVFIzI0xRiY0mv0HUKAJqCw== X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230022)(4636009)(376002)(136003)(346002)(396003)(39860400002)(451199015)(46966006)(36840700001)(40470700004)(5660300002)(40460700003)(7636003)(7416002)(40480700001)(478600001)(2906002)(356005)(316002)(82310400005)(86362001)(26005)(4744005)(8936002)(6666004)(6916009)(82740400003)(36756003)(4326008)(41300700001)(70206006)(36860700001)(70586007)(54906003)(2616005)(8676002)(1076003)(16526019)(186003)(336012)(426003)(47076005)(83380400001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Sep 2022 14:58:38.3315 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c6413cee-1eda-4408-2fe9-08da9fcf9812 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT106.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5231 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 Extend the list of available modify_field IDs to include recently added meter color marker item in testpmd CLI. Signed-off-by: Alexander Kozyrev --- app/test-pmd/cmdline_flow.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 57fc30d13b..601df52f38 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -800,7 +800,7 @@ static const char *const modify_field_ids[] = { "udp_port_src", "udp_port_dst", "vxlan_vni", "geneve_vni", "gtp_teid", "tag", "mark", "meta", "pointer", "value", - "ipv4_ecn", "ipv6_ecn", NULL + "ipv4_ecn", "ipv6_ecn", "meter_color", NULL }; static const char *const meter_colors[] = { From patchwork Mon Sep 26 14:57:45 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Kozyrev X-Patchwork-Id: 116896 X-Patchwork-Delegate: andrew.rybchenko@oktetlabs.ru Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 5AE55A00C2; Mon, 26 Sep 2022 16:59:14 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 90E1C42B8B; Mon, 26 Sep 2022 16:58:50 +0200 (CEST) Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on2072.outbound.protection.outlook.com [40.107.93.72]) by mails.dpdk.org (Postfix) with ESMTP id 8D8F442B7A for ; Mon, 26 Sep 2022 16:58:46 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fnF1cuuC3kmR+6yJMp6PrhZx/9S6TGUON9U42pg/1nYX7POtwVy0El+GMfvDvu0MWJDqz0HqlCWpxcq1UV4zcNYUFvhgERWJjlvVsHSWSotBeEZsWR9HALM9rH/XgmnWDgsBKRrWWBA0O6dINWdO0nhst5n6X8B5Ve02Xn6wQkbqJQSCWsOkXmSmycn3GOP5fY3FWx3pZHd6p3eDulXiK6fBI6WRn3y7FGHGAXbhrgb732E6s++Gf/Z0FfP08IadRKAhRSm0361Xsr6rY2Itzb/CYZ6JNkpVgltm2M3D0Ch0Czd4Ez8hHmvVJa/k8qDXWdZQRXl5CkmtEYeo7NOFcA== 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=hMdqvzn/CJD7Gf/YtlJ0590okm3w/NIf/x1wqQDqJ4s=; b=Cp7aV5w3oN5NvY2l0WudfunOzSeeTb7v4cLbZxl3rhqxHIPf1L3sHZipSbAVwglWJHVN0neTgt3zWRMuEo+4Ks0EYIFx9Poqdy1oRfMuYAtbEVKe7CabHiknaT2Y5cSFBBZLwPox7Z5X25rWt5GeM3Hn6EsoZwRHhUgZ0RANnX/ThSx2Ymz4WkfPBkvV04lmjVA9u7eSB3fEcbDUfEjQWr8AFnATDrfA48jgveSJq+mfGNSpmcjSzeXFoIBdQwIcSmvaXvzB+qKJBZXRFbW2Lb7a94SY+rNrCXJNFybwEWf1S8/qJGuzNp3DxTwb/IrrBaO7PDRMVoNpfe9/OTiXTw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=dpdk.org 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=hMdqvzn/CJD7Gf/YtlJ0590okm3w/NIf/x1wqQDqJ4s=; b=tJP9xDdQIGG1yn7aRiFqKAlT1MvxC2ybyHtPjTIEj0kROUeg3vTKx7MX47SaitnVEPtB6gwcGWcI0TP5xm+I6zE1LqjplEDiRu3hnMoK+x3qp0xqYwPEUBgUNWJrtlaQdkrXEgH9OhJyrG0pPplz6y1vVagvj69zpuGfwP7ovdcMODDxFqXbQ52KsxdREA7v64frwrSfO/PeKOhJ/Lc11D7mSbCv6V8WMZhg1ZcXXizy9//nunOcVBsVJ5Nt7QHEKR2K6RmfMnJd6H5yoE/jwQgsqAYot82q03CHTkrasqIBtpvXtCjfRPpSPjaKiHuzsjc3dStXI+ebeZNakuzG/w== Received: from DM5PR07CA0087.namprd07.prod.outlook.com (2603:10b6:4:ae::16) by PH7PR12MB5760.namprd12.prod.outlook.com (2603:10b6:510:1d3::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.25; Mon, 26 Sep 2022 14:58:44 +0000 Received: from DM6NAM11FT052.eop-nam11.prod.protection.outlook.com (2603:10b6:4:ae:cafe::6b) by DM5PR07CA0087.outlook.office365.com (2603:10b6:4:ae::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.25 via Frontend Transport; Mon, 26 Sep 2022 14:58:44 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) 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.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by DM6NAM11FT052.mail.protection.outlook.com (10.13.172.111) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5654.14 via Frontend Transport; Mon, 26 Sep 2022 14:58:44 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.986.26; Mon, 26 Sep 2022 07:58:39 -0700 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.29; Mon, 26 Sep 2022 07:58:36 -0700 From: Alexander Kozyrev To: CC: , , , , , , , , , , , Subject: [PATCH v5 7/7] app/testpmd: add meter color mark flow action Date: Mon, 26 Sep 2022 17:57:45 +0300 Message-ID: <20220926145745.3962600-8-akozyrev@nvidia.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20220926145745.3962600-1-akozyrev@nvidia.com> References: <20220921021133.2982954-1-akozyrev@nvidia.com> <20220926145745.3962600-1-akozyrev@nvidia.com> MIME-Version: 1.0 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-TrafficTypeDiagnostic: DM6NAM11FT052:EE_|PH7PR12MB5760:EE_ X-MS-Office365-Filtering-Correlation-Id: ea07dddd-b0dd-4024-e561-08da9fcf9b83 X-LD-Processed: 43083d15-7273-40c1-b7db-39efd9ccc17a,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Y26JBftFwrrJ/P4NsJgXIUl5FdfgFByqoUiDk54xzAgBuxe/ST7VwCXW2K1xqLhVzjoE8HlXjTP8crWgJl6yiXl4a3DKdgefb13oZkFewsxMrX7++pwSu8LUIffrGbITzMgI1IsblHATaQO5x6fC5gnFWp+VGXxWUt6yVUWPehZeY061pN+h8dipRjdqo/WHhsEk0+ompu5jBwUz6e1tuw988bkJjlQQZB+gP6ie6Zxa4GTpuWM6wmVd02Dr+uEB+j3fpF1DX5oos2LLjUxIymcJKLNXpPVfOvlyUZ9hJJnRwClUx10ehAjZfuRR37J11r9VWr9j7OIR0sJ3O8oTi6Fz4fKpvHIyshevCVyipJ6gea8V27TbvZZ1isvgGoyfqJXwFeWGTSE+ZAwWCnPcUMoW6QbVwj2zXoTTGjkAhQrpeYwhw55pzgPCy2Aaj/k12PKBqWXqKMFb7YV2uWLFmsuUCOvm5ETQ0rsG8b6xtmngGaf9py3IVhe+KJg6qiNF4asPq7nwHnXSWw9IkvgwoL3Z4mzrPGfPjpgVsOCIDHjEfXl3BIJ4vR03tDaY1sWKJLKh0eiUwSRzX5lRYFFVO41BLInbNHEsM1gPPW9RhPerB1YsVqx6DKMOcCznW3tWj+a3n2StJDzcY20fYrBCeJrekpzM8cDKAXanV0AOsbK/L07OD3NO8huz4tEbinBqi7Tp+tH6Vy7TxTbPFEKZDQ5iPB5kvDujCQYeBJSX8psojKYUGkA/0Q4ZHA7eqz8GnSCva4gdfmVcAzGovFjjzw== X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230022)(4636009)(376002)(136003)(39860400002)(396003)(346002)(451199015)(46966006)(36840700001)(40470700004)(478600001)(41300700001)(6666004)(426003)(83380400001)(47076005)(2616005)(186003)(1076003)(336012)(16526019)(26005)(5660300002)(40460700003)(2906002)(7416002)(30864003)(82310400005)(40480700001)(6916009)(54906003)(8936002)(70206006)(70586007)(4326008)(8676002)(316002)(82740400003)(7636003)(86362001)(356005)(36860700001)(36756003); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Sep 2022 14:58:44.1099 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ea07dddd-b0dd-4024-e561-08da9fcf9b83 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT052.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB5760 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 Add testpmd command line to match for METER_MARK action: flow create ... actions meter_mark mtr_profile 20 / end Signed-off-by: Alexander Kozyrev --- app/test-pmd/cmdline_flow.c | 153 ++++++++++++++++++++ app/test-pmd/config.c | 45 +++++- app/test-pmd/testpmd.h | 4 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 8 + 4 files changed, 209 insertions(+), 1 deletion(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 601df52f38..417655eca8 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -54,6 +54,7 @@ enum index { COMMON_GROUP_ID, COMMON_PRIORITY_LEVEL, COMMON_INDIRECT_ACTION_ID, + COMMON_PROFILE_ID, COMMON_POLICY_ID, COMMON_FLEX_HANDLE, COMMON_FLEX_TOKEN, @@ -509,6 +510,14 @@ enum index { ACTION_METER_COLOR_YELLOW, ACTION_METER_COLOR_RED, ACTION_METER_ID, + ACTION_METER_MARK, + ACTION_METER_PROFILE, + ACTION_METER_PROFILE_ID2PTR, + ACTION_METER_POLICY, + ACTION_METER_POLICY_ID2PTR, + ACTION_METER_COLOR_MODE, + ACTION_METER_INIT_COLOR, + ACTION_METER_STATE, ACTION_OF_SET_MPLS_TTL, ACTION_OF_SET_MPLS_TTL_MPLS_TTL, ACTION_OF_DEC_MPLS_TTL, @@ -1836,6 +1845,7 @@ static const enum index next_action[] = { ACTION_PORT_ID, ACTION_METER, ACTION_METER_COLOR, + ACTION_METER_MARK, ACTION_OF_SET_MPLS_TTL, ACTION_OF_DEC_MPLS_TTL, ACTION_OF_SET_NW_TTL, @@ -1952,6 +1962,16 @@ static const enum index action_meter_color[] = { ZERO, }; +static const enum index action_meter_mark[] = { + ACTION_METER_PROFILE, + ACTION_METER_POLICY, + ACTION_METER_COLOR_MODE, + ACTION_METER_INIT_COLOR, + ACTION_METER_STATE, + ACTION_NEXT, + ZERO, +}; + static const enum index action_of_set_mpls_ttl[] = { ACTION_OF_SET_MPLS_TTL_MPLS_TTL, ACTION_NEXT, @@ -2387,6 +2407,14 @@ static int parse_ia_id2ptr(struct context *ctx, const struct token *token, static int parse_mp(struct context *, const struct token *, const char *, unsigned int, void *, unsigned int); +static int parse_meter_profile_id2ptr(struct context *ctx, + const struct token *token, + const char *str, unsigned int len, + void *buf, unsigned int size); +static int parse_meter_policy_id2ptr(struct context *ctx, + const struct token *token, + const char *str, unsigned int len, + void *buf, unsigned int size); static int parse_meter_color(struct context *ctx, const struct token *token, const char *str, unsigned int len, void *buf, unsigned int size); @@ -2551,6 +2579,13 @@ static const struct token token_list[] = { .call = parse_int, .comp = comp_none, }, + [COMMON_PROFILE_ID] = { + .name = "{profile_id}", + .type = "PROFILE_ID", + .help = "profile id", + .call = parse_int, + .comp = comp_none, + }, [COMMON_POLICY_ID] = { .name = "{policy_id}", .type = "POLICY_ID", @@ -5429,6 +5464,62 @@ static const struct token token_list[] = { .args = ARGS(ARGS_ENTRY(struct rte_flow_action_meter, mtr_id)), .call = parse_vc_conf, }, + [ACTION_METER_MARK] = { + .name = "meter_mark", + .help = "meter the directed packets using profile and policy", + .priv = PRIV_ACTION(METER_MARK, + sizeof(struct rte_flow_action_meter_mark)), + .next = NEXT(action_meter_mark), + .call = parse_vc, + }, + [ACTION_METER_PROFILE] = { + .name = "mtr_profile", + .help = "meter profile id to use", + .next = NEXT(NEXT_ENTRY(ACTION_METER_PROFILE_ID2PTR)), + .args = ARGS(ARGS_ENTRY_ARB(0, sizeof(uint32_t))), + }, + [ACTION_METER_PROFILE_ID2PTR] = { + .name = "{mtr_profile_id}", + .type = "PROFILE_ID", + .help = "meter profile id", + .next = NEXT(action_meter_mark), + .call = parse_meter_profile_id2ptr, + .comp = comp_none, + }, + [ACTION_METER_POLICY] = { + .name = "mtr_policy", + .help = "meter policy id to use", + .next = NEXT(NEXT_ENTRY(ACTION_METER_POLICY_ID2PTR)), + ARGS(ARGS_ENTRY_ARB(0, sizeof(uint32_t))), + }, + [ACTION_METER_POLICY_ID2PTR] = { + .name = "{mtr_policy_id}", + .type = "POLICY_ID", + .help = "meter policy id", + .next = NEXT(action_meter_mark), + .call = parse_meter_policy_id2ptr, + .comp = comp_none, + }, + [ACTION_METER_COLOR_MODE] = { + .name = "mtr_color_mode", + .help = "meter color awareness mode", + .next = NEXT(action_meter_mark, NEXT_ENTRY(COMMON_UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_meter_mark, color_mode)), + .call = parse_vc_conf, + }, + [ACTION_METER_INIT_COLOR] = { + .name = "mtr_init_color", + .help = "meter initial color", + .next = NEXT(action_meter_mark, NEXT_ENTRY(ITEM_METER_COLOR_NAME)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_meter_mark, init_color)), + }, + [ACTION_METER_STATE] = { + .name = "mtr_state", + .help = "meter state", + .next = NEXT(action_meter_mark, NEXT_ENTRY(COMMON_UNSIGNED)), + .args = ARGS(ARGS_ENTRY(struct rte_flow_action_meter_mark, state)), + .call = parse_vc_conf, + }, [ACTION_OF_SET_MPLS_TTL] = { .name = "of_set_mpls_ttl", .help = "OpenFlow's OFPAT_SET_MPLS_TTL", @@ -9748,6 +9839,68 @@ parse_ia_id2ptr(struct context *ctx, const struct token *token, return ret; } +static int +parse_meter_profile_id2ptr(struct context *ctx, const struct token *token, + const char *str, unsigned int len, + void *buf, unsigned int size) +{ + struct rte_flow_action *action = ctx->object; + struct rte_flow_action_meter_mark *meter; + struct rte_flow_meter_profile *profile = NULL; + uint32_t id = 0; + int ret; + + (void)buf; + (void)size; + ctx->objdata = 0; + ctx->object = &id; + ctx->objmask = NULL; + ret = parse_int(ctx, token, str, len, ctx->object, sizeof(id)); + ctx->object = action; + if (ret != (int)len) + return ret; + /* set meter profile */ + if (action) { + meter = (struct rte_flow_action_meter_mark *) + (uintptr_t)(action->conf); + profile = port_meter_profile_get_by_id(ctx->port, id); + meter->profile = profile; + ret = (profile) ? ret : -1; + } + return ret; +} + +static int +parse_meter_policy_id2ptr(struct context *ctx, const struct token *token, + const char *str, unsigned int len, + void *buf, unsigned int size) +{ + struct rte_flow_action *action = ctx->object; + struct rte_flow_action_meter_mark *meter; + struct rte_flow_meter_policy *policy = NULL; + uint32_t id = 0; + int ret; + + (void)buf; + (void)size; + ctx->objdata = 0; + ctx->object = &id; + ctx->objmask = NULL; + ret = parse_int(ctx, token, str, len, ctx->object, sizeof(id)); + ctx->object = action; + if (ret != (int)len) + return ret; + /* set meter policy */ + if (action) { + meter = (struct rte_flow_action_meter_mark *) + (uintptr_t)(action->conf); + policy = port_meter_policy_get_by_id(ctx->port, id); + meter->policy = policy; + ret = (policy) ? ret : -1; + } + return ret; +} + /** Parse set command, initialize output buffer for subsequent tokens. */ static int parse_set_raw_encap_decap(struct context *ctx, const struct token *token, diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 568b0881d4..06d6dc3546 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -2122,6 +2122,29 @@ port_meter_policy_add(portid_t port_id, uint32_t policy_id, return ret; } +struct rte_flow_meter_profile * +port_meter_profile_get_by_id(portid_t port_id, uint32_t id) +{ + struct rte_mtr_error error; + struct rte_flow_meter_profile *profile; + + profile = rte_mtr_meter_profile_get(port_id, id, &error); + if (!profile) + print_mtr_err_msg(&error); + return profile; +} +struct rte_flow_meter_policy * +port_meter_policy_get_by_id(portid_t port_id, uint32_t id) +{ + struct rte_mtr_error error; + struct rte_flow_meter_policy *policy; + + policy = rte_mtr_meter_policy_get(port_id, id, &error); + if (!policy) + print_mtr_err_msg(&error); + return policy; +} + /** Validate flow rule. */ int port_flow_validate(portid_t port_id, @@ -2709,6 +2732,9 @@ port_queue_action_handle_update(portid_t port_id, struct rte_port *port; struct rte_flow_error error; struct rte_flow_action_handle *action_handle; + struct port_indirect_action *pia; + struct rte_flow_update_meter_mark mtr_update; + const void *update; action_handle = port_action_handle_get_by_id(port_id, id); if (!action_handle) @@ -2720,8 +2746,25 @@ port_queue_action_handle_update(portid_t port_id, return -EINVAL; } + pia = action_get_by_id(port_id, id); + if (!pia) + return -EINVAL; + + if (pia->type == RTE_FLOW_ACTION_TYPE_METER_MARK) { + rte_memcpy(&mtr_update.meter_mark, action->conf, + sizeof(struct rte_flow_action_meter_mark)); + mtr_update.profile_valid = 1; + mtr_update.policy_valid = 1; + mtr_update.color_mode_valid = 1; + mtr_update.init_color_valid = 1; + mtr_update.state_valid = 1; + update = &mtr_update; + } else { + update = action; + } + if (rte_flow_async_action_handle_update(port_id, queue_id, &attr, - action_handle, action, NULL, &error)) { + action_handle, update, NULL, &error)) { return port_flow_complain(&error); } printf("Indirect action #%u update queued\n", id); diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index 21c5632aec..e96f563674 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -938,6 +938,10 @@ void port_flow_tunnel_create(portid_t port_id, const struct tunnel_ops *ops); int port_flow_isolate(portid_t port_id, int set); int port_meter_policy_add(portid_t port_id, uint32_t policy_id, const struct rte_flow_action *actions); +struct rte_flow_meter_profile *port_meter_profile_get_by_id(portid_t port_id, + uint32_t id); +struct rte_flow_meter_policy *port_meter_policy_get_by_id(portid_t port_id, + uint32_t id); void rx_ring_desc_display(portid_t port_id, queueid_t rxq_id, uint16_t rxd_id); void tx_ring_desc_display(portid_t port_id, queueid_t txq_id, uint16_t txd_id); diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index b586e92649..d1f536b6fe 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -3986,6 +3986,14 @@ This section lists supported actions and their attributes, if any. - ``ethdev_port_id {unsigned}``: ethdev port ID +- ``meter_mark``: meter the directed packets using profile and policy + + - ``mtr_profile {unsigned}``: meter profile id to use + - ``mtr_policy {unsigned}``: meter policy id to use + - ``mtr_color_mode {unsigned}``: meter color-awareness mode (blind/aware) + - ``mtr_init_color {value}``: initial color value(green/yellow/red) + - ``mtr_state {unsigned}``: meter state (disabled/enabled) + Destroying flow rules ~~~~~~~~~~~~~~~~~~~~~