From patchwork Wed Jun 1 03:44:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Kozyrev X-Patchwork-Id: 112170 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 9E4D0A0552; Wed, 1 Jun 2022 05:44:38 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 01C3141143; Wed, 1 Jun 2022 05:44:37 +0200 (CEST) Received: from NAM04-MW2-obe.outbound.protection.outlook.com (mail-mw2nam08on2089.outbound.protection.outlook.com [40.107.101.89]) by mails.dpdk.org (Postfix) with ESMTP id 183B441143 for ; Wed, 1 Jun 2022 05:44:35 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OMDHszHQ9zU4lP3C8Y6lzKrq/PlkEdbW7WAf1WXphaeRfX1Nn/fMWxGQpiZ7jnoOqFVMWrgGuX/eap5jaVUKepeMDpYEtU2A20My4IeZEeDRp9tpU1osDn/gUWmCHsbf7qnvbWp9oHSVoog7HCuMTpMnOzTf1Jm/v3inKFlfNaNkI6Uajt/RlIg9fOGNDuyvoI14rXtB2JF5eeAW2ai6JW1Hue6k61kJ/80EVo68YKQ7ythxPVhr3mQ5mJgnlEMEwihTUs5pkfvtbvP3oPve5HoZgMeEy1R6q2vyODpqDDM+F5xVa2ZTOs9sdkpOOUcCnhGiXMVQXllYoiLv9THzZQ== 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=99OQTBeI3vYDMpm92s3ntNBUJVKzzgRnQZd9ZUO7Fdg=; b=ji0p8jjSftPCZLjE7xQQnihYqX1pseiXfERC5VfqPXpdBHnnTSPiVX9PGLR9S+fEQlmVFSuzw/G3goQAfHxdY+FvlToAPUwfUv9BkQQcwW0v7/KTs5d0UTGx+P1ALcvISzvcaGggzVqsIwcEXUSDcbzbi6dlXaaXDkwA/Tn0ngJyJDGTBDXdRHN+wkTpstM0QAhETX6fXFumpwybKON82emPHSkv5dDw2E/OmmFfekpBFpccsUwF+1OGD9yGehJBSxibINksTkKXT3eAS3oE2/Axi08RQfzDkpPX2G4dDcJo+0J8/haUkiRZMh9V2UVwAXV+1KuPyoLBem+CLllfUQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.235) 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=99OQTBeI3vYDMpm92s3ntNBUJVKzzgRnQZd9ZUO7Fdg=; b=UNbFWOOuynfIEPBlE5B7jnh0mMzmq4AgHGBn+GF7JUa0OlNvdvG+ihs7xdDnRqoHeb0SjoBa2+uGB/mCA87HyngKvpFUAfqZJPux7C92lrCxP9wDCWRHeUalqntnE04YUAmzRac4Dm0OQ6+cQ0GeRtsBHrvt9oUMqy+2u2kjOJNxa1ZLHilfVXlktsSmEImGoQ6liSELGdDXSjg4jB0uoRx8SdedeQ9zZXmt6SR7mb+YUe4l81tkhiU4VvkzKfqMlkvYlbPGrUbe4WAnhuklpUmd+7tFTpucNMY9KAija++DCr44Si9VGC03Gxk78OQPpDW2ifAZF2z5fabTXJI8jQ== Received: from BN0PR10CA0024.namprd10.prod.outlook.com (2603:10b6:408:143::15) by MN0PR12MB6318.namprd12.prod.outlook.com (2603:10b6:208:3c1::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.12; Wed, 1 Jun 2022 03:44:32 +0000 Received: from BN8NAM11FT005.eop-nam11.prod.protection.outlook.com (2603:10b6:408:143:cafe::f9) by BN0PR10CA0024.outlook.office365.com (2603:10b6:408:143::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.12 via Frontend Transport; Wed, 1 Jun 2022 03:44:32 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.235) 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.235 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.235; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (12.22.5.235) by BN8NAM11FT005.mail.protection.outlook.com (10.13.176.69) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5314.12 via Frontend Transport; Wed, 1 Jun 2022 03:44:31 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL107.nvidia.com (10.27.9.16) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Wed, 1 Jun 2022 03:44:31 +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; Tue, 31 May 2022 20:44:27 -0700 From: Alexander Kozyrev To: CC: , , , , , , , , , , , Subject: [PATCH v3 1/7] ethdev: add meter color flow matching item Date: Wed, 1 Jun 2022 06:44:02 +0300 Message-ID: <20220601034408.2579943-2-akozyrev@nvidia.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20220601034408.2579943-1-akozyrev@nvidia.com> References: <20220522105102.1692526-1-akozyrev@nvidia.com> <20220601034408.2579943-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-Office365-Filtering-Correlation-Id: 4dc660fa-d60d-4bf6-711d-08da438109c7 X-MS-TrafficTypeDiagnostic: MN0PR12MB6318: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: qTE7Nh5mPd1o7lr4Jw41WUyMZ9l6O4//gLzd/GlV78g1C8PHNUfNv7KNxMyVVevLJZtYwQMoHki3D/cb8P/wgL5EUeQOLbNUP1oJk3QuE1ierPPfEiwXSgF+eTSHVd9ts7si5RF/O2MD5llpp8B6n76ZFSaRunkkoMJqBsz+hMK8B//4O89e/a9gbBjwofe/Zvribl7vMcpEk+SSBdQ4hnAb/iaMZUmvC5BKcHp0OB5SdvxuufCW8xt0MRWwaiqsDUelO15eY5DW8pzuf63MW9Q8k3fO/BRdQ3zlxdH0p67qHG7aPOskoeVVVwvHGfm3R0//dN9zaIKjnGOqg/OjabF0VuFzEvtt83GRvV8K3prPYPiSwbHtFH4E6Po3yjm3nAnMzl5/ufj+pe7lRH+WI/6DhdgBfYrSmbdpFg/RuI99mTZQD+piuPkQH+t8+E1uZ5haoKOabFX0bvPmjsNhN3AJohsjoi9qL097CptWN0wTe84UHcXnnslu5JJtyZ/JEVQ0ARWs9hbzizlRowB/YrB4xpqAepMMJ/vnCuxLxW+1kL5nMzduLLDJsHqGj3Ga3c1wQmKc5vMoaNJkIn/H2Gdsnm9UGQgpJYcboFAItKOIVNU3WU1CsxP3+tpHnP8d/6PZUh8yc25YTABTKLE3qIvYJhifyMe8mRRx/j90DxouPt0B8pZcHqjaglHyb0UcH1dqGsw67Ha+RZeihaWNGA== X-Forefront-Antispam-Report: CIP:12.22.5.235; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE; SFS:(13230001)(4636009)(46966006)(36840700001)(40470700004)(356005)(81166007)(36860700001)(70206006)(5660300002)(316002)(6666004)(8936002)(6916009)(70586007)(7416002)(2906002)(86362001)(40460700003)(36756003)(47076005)(4326008)(8676002)(426003)(83380400001)(336012)(1076003)(2616005)(54906003)(26005)(508600001)(82310400005)(16526019)(186003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jun 2022 03:44:31.8379 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4dc660fa-d60d-4bf6-711d-08da438109c7 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.235]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT005.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB6318 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 Acked-by: Ori Kam Reviewed-by: Andrew Rybchenko --- doc/guides/prog_guide/rte_flow.rst | 7 +++++++ doc/guides/rel_notes/release_22_07.rst | 4 ++++ lib/ethdev/rte_flow.c | 1 + lib/ethdev/rte_flow.h | 24 ++++++++++++++++++++++++ 4 files changed, 36 insertions(+) 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_07.rst b/doc/guides/rel_notes/release_22_07.rst index 0ed4f92820..c1804bc74f 100644 --- a/doc/guides/rel_notes/release_22_07.rst +++ b/doc/guides/rel_notes/release_22_07.rst @@ -69,6 +69,10 @@ New Features Added an API which can get the number of in-flight packets in vhost async data path without using lock. +* **Extended Metering and Marking support in the Flow API.** + + * Added METER_COLOR item to match Color Marker set by a Meter. + * **Updated Intel iavf driver.** * Added Tx QoS queue rate limitation support. diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c index 2c35a2f13e..07d7e998c0 100644 --- a/lib/ethdev/rte_flow.c +++ b/lib/ethdev/rte_flow.c @@ -161,6 +161,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 d8827dd184..75ec6621ac 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -671,6 +671,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, }; /** @@ -2201,6 +2209,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 Wed Jun 1 03:44:03 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Kozyrev X-Patchwork-Id: 112171 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 96BADA0552; Wed, 1 Jun 2022 05:44:43 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E4B3F4281C; Wed, 1 Jun 2022 05:44:41 +0200 (CEST) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2089.outbound.protection.outlook.com [40.107.237.89]) by mails.dpdk.org (Postfix) with ESMTP id 46CD54281C for ; Wed, 1 Jun 2022 05:44:40 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=jgCIR8HR8tMjwi1dtw4/lv57+bJ6souoL9fraPSieufl381YrsXmYYlyPvcR4ZC/4vOcScBL44aNl1pYbjwRewnX6PBCqgasAI+7t1OHWFd+gZSZD44iOGsYSBsKqTq+hZ8qjnDJqXZEiU70tZqYtEQTvMld3DbuTFbCUkJ53BWhXEzSJE3qUDjT7JT0l1lLJV6xNcK3L6W1CS6xUWt095YSnAztss1br+uy5eBUt+p7SDCUDFYRGY3RG+u+5/ksVQFyzxXTzCV9W+Oyeid5SqWHGGthCORiyWRHiJKes1uQkdlBU4t4XvWXNG2WuEj3wd0ANsyCWjLEhA71HjDn7Q== 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=Knpa3Mw/QSauFr0f1N3eGNUUsAm1gTbRA70TIIJz1XM=; b=O1lSJjiQCun7yXCxLJ9ZfUsVWWRUEUjudzAbNQJlpDuEQ4Fwvrc1Aivev+DoGWk0JiPAGrwiFKgqXO6AYGVm74s7NX9Wqr27O40D4wLhovlW2R0WlqeHSg4uUtoIgopXstRH0ZLFZAngvK5i2KrkYT6qUt6mRYrvJ7yRUX6SS+GohzjYThzPwUKVDoHeR5CP5GUIAnmh5GCmbWBI9jIQ95ZrHCTModmv/G2aQU6HbEecEp7fcGIeoY4evy0Q/I/yrFiQHRqOaQK5nKqHtOwBPXBwJ6eCjqXUPneN2RmkoERkS03VrAABk9XQekY4cVYyY4GqJGLPfGjudQ3FDzyvfA== 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=Knpa3Mw/QSauFr0f1N3eGNUUsAm1gTbRA70TIIJz1XM=; b=Jm244dC5OJTCMCIpAs9c/g6FqE/542qARvT26xiZe68jpILdsLCjh3Pou/IOqnhPfso/QucdPI2QPVoEnsWMG2dq2NNj6Q20vHAfEtq+pCudzcg2ZTriHvt97Lzpn4TaX4Mbd+OrfhWISxTio1pf7ECbcLsSahME2promdlb/E68vWjiuAJwd72N/P4ctR2GNGN3/FkZ74BI6NUp5b3PF7KrrfB3bYV26OE++yxmg6zC3Uk4IFS1uKhrqYMvIsyeAr6YdMA4xPUyGmZ+WJsTmPWWTOFo2vyCdhUZtKMvEkV3umfti/9aQmWlbTmtuWq2J7qDp9H718rgjmIOcyUpVQ== Received: from DS7PR03CA0106.namprd03.prod.outlook.com (2603:10b6:5:3b7::21) by MN0PR12MB6294.namprd12.prod.outlook.com (2603:10b6:208:3c1::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.12; Wed, 1 Jun 2022 03:44:35 +0000 Received: from DM6NAM11FT056.eop-nam11.prod.protection.outlook.com (2603:10b6:5:3b7:cafe::df) by DS7PR03CA0106.outlook.office365.com (2603:10b6:5:3b7::21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5293.13 via Frontend Transport; Wed, 1 Jun 2022 03:44:35 +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; pr=C Received: from mail.nvidia.com (12.22.5.238) by DM6NAM11FT056.mail.protection.outlook.com (10.13.173.99) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5314.12 via Frontend Transport; Wed, 1 Jun 2022 03:44:35 +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; Wed, 1 Jun 2022 03:44:34 +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; Tue, 31 May 2022 20:44:30 -0700 From: Alexander Kozyrev To: CC: , , , , , , , , , , , Subject: [PATCH v3 2/7] ethdev: allow meter color marker modification Date: Wed, 1 Jun 2022 06:44:03 +0300 Message-ID: <20220601034408.2579943-3-akozyrev@nvidia.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20220601034408.2579943-1-akozyrev@nvidia.com> References: <20220522105102.1692526-1-akozyrev@nvidia.com> <20220601034408.2579943-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-Office365-Filtering-Correlation-Id: b2d4bc4d-3589-4169-5025-08da43810bb3 X-MS-TrafficTypeDiagnostic: MN0PR12MB6294: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: jyMVvDuhEbP9g5gzmYo/VXy+A9awL5XcWTEOX7YjPSyCmVG52Sw8iqpU5N86UoU4C923RWzx0+pOyfUaQGSISEmfwtsoqHZFIcW61lt6+Xfn0oGpsgjvEVw9N/+Er/T2X7Yj96CA4as5t5CbiMgb3qdXIAoHJhJbXr5UAhpRaEYC1/GSw6V7dLcWFCM4cY5SmKsBGz+DwwCBU4d6jLQsK7pdHOQc/mbZ3A5M8jPHuZnSX6G+x7le+ZWyxMGN5Dsl6rYI9Pjto86cAnmxPnuJb/Nrwf7OYXK30fFd9+3RJs4NEAA9jrDeAkJa7rqefgTIUZ4zMNFwYU2V0bTygGO0zuOzCAxgM9pZaERHNpS/5gvGmVfgMCrriWHxUpCYH6P3RgJHC+i/Cbnrxqd7Op0NwzIeec9QZJltIsEaIh8N6sjbekBBeCzZrN9VGCa6ftRlhhEC7/okF4iXKJqa788iuk6hO+Vd6kB/IZSllozC+MIswZa1+kpvt1901jMxr1Z2muP8hERob+7I6xN1hFYy71djxOZCPtSK4XHDkFdp/1k7Df3ybB1by8VV9sYrdEZSzExJUA65AKJBoEkbrvrXJK21D60dnX4VJ9vy7jVQjYuqCxOjFYLHxOOlcOoNIY4JDtKDOfY4Ht6LSwau1XwB4/cgUB2z7ek/T3A8g7GRR0e7R942l1sVZsLp4YoBTBLcxUOsbnS1WEIJB3G3plPAQQ== X-Forefront-Antispam-Report: CIP:12.22.5.238; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE; SFS:(13230001)(4636009)(46966006)(40470700004)(36840700001)(6666004)(4326008)(8676002)(186003)(16526019)(1076003)(6916009)(508600001)(2616005)(70206006)(47076005)(426003)(83380400001)(336012)(82310400005)(7416002)(70586007)(8936002)(5660300002)(316002)(2906002)(36756003)(36860700001)(356005)(40460700003)(54906003)(26005)(81166007)(86362001)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jun 2022 03:44:35.1395 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: b2d4bc4d-3589-4169-5025-08da43810bb3 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: DM6NAM11FT056.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MN0PR12MB6294 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 Acked-by: Ori Kam Reviewed-by: Andrew Rybchenko --- doc/guides/rel_notes/release_22_07.rst | 1 + lib/ethdev/rte_flow.h | 1 + 2 files changed, 2 insertions(+) diff --git a/doc/guides/rel_notes/release_22_07.rst b/doc/guides/rel_notes/release_22_07.rst index c1804bc74f..451ff8d460 100644 --- a/doc/guides/rel_notes/release_22_07.rst +++ b/doc/guides/rel_notes/release_22_07.rst @@ -72,6 +72,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 Intel iavf driver.** diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index 75ec6621ac..68af109554 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -3714,6 +3714,7 @@ enum rte_flow_field_id { RTE_FLOW_FIELD_META, /**< Metadata value. */ RTE_FLOW_FIELD_POINTER, /**< Memory pointer. */ RTE_FLOW_FIELD_VALUE, /**< Immediate value. */ + RTE_FLOW_FIELD_METER_COLOR, /**< Meter color marker. */ }; /** From patchwork Wed Jun 1 03:44:04 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Kozyrev X-Patchwork-Id: 112172 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 73F38A0552; Wed, 1 Jun 2022 05:44:49 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id CF89442B6C; Wed, 1 Jun 2022 05:44:42 +0200 (CEST) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2044.outbound.protection.outlook.com [40.107.237.44]) by mails.dpdk.org (Postfix) with ESMTP id 5818040150 for ; Wed, 1 Jun 2022 05:44:41 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=awiDtKiTVTtS/jJ3tSBHi6XbM4wVFNPX+H8QbFZqtXPgs5/+yZBKtGClsiIUADYfyiMZHOKxFwj6H2GFDsOgzdRh5KWdswwUx7Pp6lAFKVM02BS6kFHmx8YTVtUH4nNapqdfhcTpxkrXu+8aaIiLQV+BV3PEIA4sNWitbZqI/oxhNjXXJ1IIFwMs68QbcAanvgxDQCpk/SGGYpg+Oz/mdyhl03irye9WDTGPZl/evqh/IfQrplZ3bgOTUYKvdHRs4Nh/X1mibD1SxNJ55weholee8VxjhT98w6Mko6yVzmWuip26y/O5abnAwZBYNdYmjYG4Lkhr6piB9Db8NtBUJQ== 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=UkV5JPLoUimHKzyXkYuh79MZF3v568yESlC7uvz55FA=; b=JfIjYjqtOFh/bHEgkpZSgGi4OlgltyJDKExyZHYSJORzM5PhgCxcKIkuN2yWV63S9Ss9es9D3f2es/usaC2HZv6Eif6cPhPFOLRjB7ow7CYnw+a5pvLts6ujw9aUpJVRpx65gVgowolTOAdWi75/GCw5DZBKQAs/s5O1H6km9MkT3ssSwbwGMcXDNBi+1e4G7jlDNJX/ZXzoaGhKIxU8jbqrfw0lZE4Au7AzjTzh9eaUGAZVpQKOk02+nNZlFCwIlLyFNnQ5lOe5XfNLXfTvdcnJaR2YzP2Xkq3oMe+LPr34ongPEC/ssWw9/AQp7RveOgNDhn7Vju8YABN4p4I39w== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.234) 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=UkV5JPLoUimHKzyXkYuh79MZF3v568yESlC7uvz55FA=; b=Y392tqvYR5yp9WiJ5dsu099nKbSbDIFQEwJSZYzsRhMZeHotkceMEuJQlWh0Y/EUOf0VTJmZCzLct8qLPjKcUb61VkkSVhNyY0r0beGWC4zEBjwXf4ZUga0Y7RE0K2t0DR1R0L3OyEFxEBoQa4nA/c9tQQfhoj4yOrxwd4Ikd0mwpRee6+e6OFevIeVWSzkcCRcPgLMDUrbGJlNy0JeUPpk8yafyfH/tIduphDB+S1HjbRVxlC8DlqCSg3K86dDTNqLz6mOjEB3jcoZp4vLtUdGJBcBDOdK515U2HRa0cbCTIHQiR2oK0meBVbpjdkIErmro9mGxX9A6o5+ySuv1NQ== Received: from DM5PR06CA0039.namprd06.prod.outlook.com (2603:10b6:3:5d::25) by MWHPR12MB1167.namprd12.prod.outlook.com (2603:10b6:300:8::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5293.13; Wed, 1 Jun 2022 03:44:39 +0000 Received: from DM6NAM11FT041.eop-nam11.prod.protection.outlook.com (2603:10b6:3:5d:cafe::39) by DM5PR06CA0039.outlook.office365.com (2603:10b6:3:5d::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.12 via Frontend Transport; Wed, 1 Jun 2022 03:44:38 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.234) 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.234 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.234; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (12.22.5.234) by DM6NAM11FT041.mail.protection.outlook.com (10.13.172.98) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5314.12 via Frontend Transport; Wed, 1 Jun 2022 03:44:38 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL101.nvidia.com (10.27.9.10) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Wed, 1 Jun 2022 03:44:38 +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; Tue, 31 May 2022 20:44:34 -0700 From: Alexander Kozyrev To: CC: , , , , , , , , , , , Subject: [PATCH v3 3/7] ethdev: get meter profile/policy objects Date: Wed, 1 Jun 2022 06:44:04 +0300 Message-ID: <20220601034408.2579943-4-akozyrev@nvidia.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20220601034408.2579943-1-akozyrev@nvidia.com> References: <20220522105102.1692526-1-akozyrev@nvidia.com> <20220601034408.2579943-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-Office365-Filtering-Correlation-Id: eee7e1c9-2fa4-4b65-e485-08da43810dc6 X-MS-TrafficTypeDiagnostic: MWHPR12MB1167: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: p0fmxcnb/iLeaj/aX8hBupTz1Jw+iRaL+NRAknNgnRqDEkWAb5YGv4468o4BFxGLyrkockxxu+ybWsZwoKidc9vdxNFa8nTrw3MIsI6e/vMEc6VnC/yddw71REejD9mRSEE4nxL3Pt2QWuhXJ9T86GirDECN5iEFap0Uy2SxoHaOsazkDwfdKWd0qq96j/osgBDQawXPR6GkD2F49Os5UBmHEfJZ5SMreMHJ3Taln6CYytapPiuEaEwrbN6Sz8LeD3rJ8CtGSGvDJMtIcVk7gasM+7sD4EylCGD8Sz86IjCC/vKsWJ3gMpMAVtRdpKO1mfwE4uFkoNFpEj9pHHz8Vp0BHg4QavXGJX6sT4DkMThunP0aF0iA+FC0wEz5BWJy+to85Lg/rsJUMvCKTJcbNWhglkANxbG5LA6Bnuho+gh03rfWPWn/9kV1YM1hj+l40KBhckcNnO6afDyLWeujUZkRbnwbAV6BKR/O0LruXb21IrHut8Cd5XpgqfrJyX718jOkxCzorlM6WnW3piajS9WsdrSJL/U4MOU/msmCizmXp2uvFz+J/eAHAps9k2CBnxw7dEs8RvI68Oh/i+th/uY0Uwmkd+xZTlVZgQkv2BX7WcniBceRYrP8cvUIDJeF1z4TVLeht4/S5rqqFXjVHxn8P0uTOZWx+zeulhFJD+GA57GsP+se/cNgL1PqOXOvAozwGEVT/97tcTby2pZNwA== X-Forefront-Antispam-Report: CIP:12.22.5.234; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE; SFS:(13230001)(4636009)(46966006)(40470700004)(36840700001)(316002)(54906003)(81166007)(2906002)(26005)(6916009)(36756003)(356005)(47076005)(83380400001)(336012)(426003)(8936002)(4326008)(7416002)(16526019)(2616005)(70206006)(82310400005)(5660300002)(70586007)(86362001)(8676002)(508600001)(40460700003)(186003)(36860700001)(1076003)(6666004)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jun 2022 03:44:38.6233 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: eee7e1c9-2fa4-4b65-e485-08da43810dc6 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.234]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT041.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR12MB1167 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 thecorresponding meter_profile_delete() or meter_policy_delete() are called. Signed-off-by: Alexander Kozyrev Acked-by: Ori Kam --- .../traffic_metering_and_policing.rst | 7 ++++ doc/guides/rel_notes/release_22_07.rst | 1 + lib/ethdev/rte_flow.h | 7 ++++ lib/ethdev/rte_mtr.c | 41 +++++++++++++++++++ lib/ethdev/rte_mtr.h | 40 ++++++++++++++++++ lib/ethdev/rte_mtr_driver.h | 19 +++++++++ lib/ethdev/version.map | 2 + 7 files changed, 117 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_07.rst b/doc/guides/rel_notes/release_22_07.rst index 451ff8d460..6d030bead5 100644 --- a/doc/guides/rel_notes/release_22_07.rst +++ b/doc/guides/rel_notes/release_22_07.rst @@ -73,6 +73,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 Intel iavf driver.** diff --git a/lib/ethdev/rte_flow.h b/lib/ethdev/rte_flow.h index 68af109554..9754f6630a 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -3827,6 +3827,13 @@ 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; + /** * @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 441ea1dca9..90fd277040 100644 --- a/lib/ethdev/rte_mtr.c +++ b/lib/ethdev/rte_mtr.c @@ -57,6 +57,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, @@ -91,6 +110,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, @@ -125,6 +155,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 daca7851f2..2609f2e709 100644 --- a/lib/ethdev/version.map +++ b/lib/ethdev/version.map @@ -285,6 +285,8 @@ EXPERIMENTAL { rte_mtr_color_in_protocol_priority_get; rte_mtr_color_in_protocol_set; rte_mtr_meter_vlan_table_update; + rte_mtr_meter_profile_get; + rte_mtr_meter_policy_get; }; INTERNAL { From patchwork Wed Jun 1 03:44:05 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Kozyrev X-Patchwork-Id: 112173 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 E1470A0552; Wed, 1 Jun 2022 05:44:56 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 0E0F042B73; Wed, 1 Jun 2022 05:44:47 +0200 (CEST) Received: from NAM12-BN8-obe.outbound.protection.outlook.com (mail-bn8nam12on2044.outbound.protection.outlook.com [40.107.237.44]) by mails.dpdk.org (Postfix) with ESMTP id 3B96A42B71 for ; Wed, 1 Jun 2022 05:44:45 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=DSxj9nkn2JL/HTffE8mb+Fpyys2+m0NvUihqlOjswfkbrc+oCblCEnadkx0wN+Pe8hrUrJmXgEqM2hxkZp85cXSraOA//pKiCzD5rUlpqLbZhP9dTuUvwwhVUyuwZ/GTyG+cqxXierSM5uzi8I8f8XhkUANMV2fvvjTZiw/V+WBqpw/BbOnylkbR2UKeGJyQjJiooue2m/9+aK5TXb0RhPFDO079y6CVrCksuJIN83oCn8Yt1qV121/+TDBkuAyw7/DessHUQqITQevR9xscDhKPFl/IBVzj+5tAbkA2gJytGGFkG4mWU6lI0p3tGTSMLRaklIQeNx2OOYxWEcs9Qg== 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=dp1p1doztMofSOWz6CNGn4646AtWD5/BgXxAR1lS4+U=; b=FfStFZIwmmUoIVLxHUp/EldOeEIhf3ApVAenntEtx3ETMX7sheAAUQtdMkVfWKR9tHeDZr5uUrWVih90tnK2x3ea1TdGwsQOb8Id57W/3ekW5TCpyz8ZmVIgiZ7Ba+lRsPUxg+QPVtvXs2M3vwmvzISKRZvAUxeiDnIaxOXo4GRV6Gi9OUdFOROmFtHc1qGASPy63CFMqzVkGLiqpRNmqiltHfVJZE3OxeEq2JCbvR0LxgBmWLuAB2lnUur/zK13HHLW8DK5q5viqgeuhQV4VUJ6nT1VwJaGE2xKExa4oZsbNR8Sl4J+KAgKFsB/Sh0ir1kxRQtErwP7a7qi21PIaQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.236) 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=dp1p1doztMofSOWz6CNGn4646AtWD5/BgXxAR1lS4+U=; b=eIac0ASLmxWad8v3iGRsEoPDdn/KjOe6fJPbjloBh83EdphzwDusAn9wo84Il0tPDvuh/p4zMZLSiykYArZbZ6DisELB9YucRedLBYDZCsHU6jtHH3wsjhfbySzwxmEDrIKmQ55i1fxuJ3t7J7N+9CQCmm5uRhRTueAojEP8lT4XpYFJWjGsGq7TaECQltaVXIHKc1NRQh06lqB09UKPSw9U8MMhMyH6m/0OqCIFXUSa629nEnfxtfudNx9q736y5/OjE+R4PYi0O+ocwbNdrL3hqhzz8KxM4oH6Zx56pDctqiNWlcancQsW5jnwf5YZqGCWwdZZLP1KZStXsgt6ZQ== Received: from DM6PR03CA0050.namprd03.prod.outlook.com (2603:10b6:5:100::27) by BYAPR12MB3093.namprd12.prod.outlook.com (2603:10b6:a03:dc::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.12; Wed, 1 Jun 2022 03:44:42 +0000 Received: from DM6NAM11FT044.eop-nam11.prod.protection.outlook.com (2603:10b6:5:100:cafe::f1) by DM6PR03CA0050.outlook.office365.com (2603:10b6:5:100::27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5293.15 via Frontend Transport; Wed, 1 Jun 2022 03:44:42 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.236) 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.236 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.236; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (12.22.5.236) by DM6NAM11FT044.mail.protection.outlook.com (10.13.173.185) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5314.12 via Frontend Transport; Wed, 1 Jun 2022 03:44:42 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL109.nvidia.com (10.27.9.19) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Wed, 1 Jun 2022 03:44:41 +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; Tue, 31 May 2022 20:44:37 -0700 From: Alexander Kozyrev To: CC: , , , , , , , , , , , Subject: [PATCH v3 4/7] ethdev: add meter color mark flow action Date: Wed, 1 Jun 2022 06:44:05 +0300 Message-ID: <20220601034408.2579943-5-akozyrev@nvidia.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20220601034408.2579943-1-akozyrev@nvidia.com> References: <20220522105102.1692526-1-akozyrev@nvidia.com> <20220601034408.2579943-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-Office365-Filtering-Correlation-Id: 4ebaa08f-fa44-490b-13af-08da43810ff5 X-MS-TrafficTypeDiagnostic: BYAPR12MB3093: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: uK26rGoLJ8MK+gFzAb6VdaI0pgLkGa24zRMH7ac+fbmq0KxOuX/DfNScPnKkm+UXMtnnKy8IvneLc+8qtA2b4OUrVzhnA0/rqHmrG57cyIjbWg3JrMgwLVHWsjLBrAjOzlRsdOQV5zqji4vymztbSKVhNGStrq1DkkrF8vlh0xTGc7PvClbeGpD93A9+5iL/WhSV/NI0TGOANciooSJ8AglU0UwTGtNUEP559d5lrDuoAH2pCw1OYjJ4ENVM/XBxCyQFK1hwLUnmYUd1z/FiM3I70M8ZPe5lQ3aF+EWPywTTDMiUXjseao7/q8BiNYV3Dvr5qIV7n1hf/wWFSnMpNgyClh/nvUn+DC4yOkkmehy1wUlDtkEm1Zzd6qxQVQBZElwohpUHOSWKqFoEwzBf3G3NdgWgbL0laF96skUB1ZtFW+DNAKdvQ+CgAm1DerrUyCRsVc8eVMi3LvVTDTrHu54E+KHi01ZrT7p9MtICRRqvTSHH1ftQ8unTLgBF/AWWCS24+Eg2MeeJWGXpz18ktkQIKfMoCvYsLnvXQrlYbJZEfE56qMB8Mrb8qYKPXy6B75aw3KEybLlFQTzG1noxM7GrcMiw6JK4L3j+ZC/PqUVRQ89JH2c69cSvaNETMUDuRLqymX032cVYleG05Wc18UcyndpwpbG8FUoT789tc7p+36aXVcVTPjHdtVhYTn+lXl/Gk7YwwSjFgUqMEA5mKA== X-Forefront-Antispam-Report: CIP:12.22.5.236; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE; SFS:(13230001)(4636009)(46966006)(40470700004)(36840700001)(5660300002)(8936002)(7416002)(26005)(86362001)(16526019)(186003)(2616005)(336012)(508600001)(1076003)(47076005)(426003)(2906002)(40460700003)(8676002)(83380400001)(4326008)(70586007)(82310400005)(81166007)(70206006)(36756003)(356005)(6916009)(36860700001)(316002)(54906003)(6666004)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jun 2022 03:44:42.2658 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4ebaa08f-fa44-490b-13af-08da43810ff5 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.236]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT044.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB3093 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 an IP packet stream and marks its packets with colors. 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 Acked-by: Ori Kam --- doc/guides/prog_guide/rte_flow.rst | 25 +++++++++++++++++++++++ doc/guides/rel_notes/release_22_07.rst | 1 + lib/ethdev/rte_flow.c | 1 + lib/ethdev/rte_flow.h | 28 ++++++++++++++++++++++++++ 4 files changed, 55 insertions(+) diff --git a/doc/guides/prog_guide/rte_flow.rst b/doc/guides/prog_guide/rte_flow.rst index 018def1033..90f0ebc9bc 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 an IP 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_07.rst b/doc/guides/rel_notes/release_22_07.rst index 6d030bead5..fca7d07e4b 100644 --- a/doc/guides/rel_notes/release_22_07.rst +++ b/doc/guides/rel_notes/release_22_07.rst @@ -74,6 +74,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 Intel iavf driver.** diff --git a/lib/ethdev/rte_flow.c b/lib/ethdev/rte_flow.c index 07d7e998c0..9049d3bad3 100644 --- a/lib/ethdev/rte_flow.c +++ b/lib/ethdev/rte_flow.c @@ -262,6 +262,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 9754f6630a..2dc80ad9ef 100644 --- a/lib/ethdev/rte_flow.h +++ b/lib/ethdev/rte_flow.h @@ -2906,6 +2906,15 @@ enum rte_flow_action_type { * @see struct rte_flow_action_ethdev */ RTE_FLOW_ACTION_TYPE_REPRESENTED_PORT, + + /** + * Traffic metering and marking (MTR). + * the entity represented by the given ethdev. + * + * @see struct rte_flow_action_meter_mark + * See file rte_mtr.h for MTR profile object configuration. + */ + RTE_FLOW_ACTION_TYPE_METER_MARK, }; /** @@ -3775,6 +3784,25 @@ 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 an IP 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; +}; + /* Mbuf dynamic field offset for metadata. */ extern int32_t rte_flow_dynf_metadata_offs; From patchwork Wed Jun 1 03:44:06 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Kozyrev X-Patchwork-Id: 112174 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 516EAA0552; Wed, 1 Jun 2022 05:45:02 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E431C42B81; Wed, 1 Jun 2022 05:44:48 +0200 (CEST) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2054.outbound.protection.outlook.com [40.107.223.54]) by mails.dpdk.org (Postfix) with ESMTP id 10DF942B7C for ; Wed, 1 Jun 2022 05:44:48 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KxoRQiFmS7ipqFdBdjt6MBKwWuMCU56WQuCxXYC8uKq1UAfAPk7MHDVm9PdAsHBHFUnim2XAAnOL0UgxyZEacNsXRQBqo1vqYtGtQ1RRxoCbD2AmoyXMqrVmoMpECRG9dqWuNLBTvIOPqYG+AJJO/9ve4UkWNQAp1SCAyZ1gbZHU+2VY+rek4gzE0x6xRn9paB/vnlVSCp8DC2BaJHYO7cLlYk/zM359RnZAo6J0P68x3p4ciWBvX2R3NIAybpmrfUgcxTCXXDd3VF+shBzzg1w1+XOCU0/z/6iO3ThwcDLIQb31TXCK3VXS33raqoXJWlJbGh2tDvD4DAm/ChhfWQ== 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=UpYq83qG9AA2W2v8RMRxB1kKI8pkN7iTFWXNGsu1QbI=; b=PtAQBPM7ts+jkSZbWZPFXAfKgNEHIEdEtdc8Bzv9+F4h/R4N2+0Tj+eWmQhI16j8go8upM/sUJhdKKwAxdE28CUJSAcQ+IB7dXGbZPVeG6FqH8naA7anVbZfLlz6Dq1P8Y024AsKslmWeOzB1QGGg4/+9WSOsPGE/tS8lgYqMfIqIXDBluuYikaKklnqeeik9HCwcjIFi/RUxc46XoWIVnVCZp/5bzA9joL+tp1yGG2uzVEUCj57BhgqAXUabSneqyYcYnwJZQiLuAaH0dE7KGqSnFuIPNqBw8UgaDi+Zz34o2hEN3GriXQ7da1Ar/AX1LcTJ7UhZljddRIspv1sQA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.235) 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=UpYq83qG9AA2W2v8RMRxB1kKI8pkN7iTFWXNGsu1QbI=; b=teqbTvV3ivywEZsiAIrYXSK7DZ18w2cR7HPKw6Pp9Lc9qOI6K64lcG0/Qq5xHO8y33IRPp1dXH9ymvWrSbCqbNiYIZr/f8Hj7rcErpXr4CFSv7XHp9SVqNYG2zknpZ7pyCY8qms0ij8gvqHXZ5Y3wZUqRMP6HB/uI0emmBPoK/A0IfyP19tczpQslMIWwUamo3zZUsRd72tJY6lCIMf8UbkA1hMsOhkF0mBczGpD99iv34FnHLN5SnH539Ml+95HcTsr2ZPQRaIhFkf9pkpJerMpTiaAxPIHEU63LliOE9/pUGo13j/LzfCkps1P2B2iAXD/eehLwxD5DaekDZyOuw== Received: from BN0PR04CA0058.namprd04.prod.outlook.com (2603:10b6:408:e8::33) by BL0PR12MB5507.namprd12.prod.outlook.com (2603:10b6:208:1c4::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5293.13; Wed, 1 Jun 2022 03:44:46 +0000 Received: from BN8NAM11FT053.eop-nam11.prod.protection.outlook.com (2603:10b6:408:e8:cafe::d9) by BN0PR04CA0058.outlook.office365.com (2603:10b6:408:e8::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5293.13 via Frontend Transport; Wed, 1 Jun 2022 03:44:46 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.235) 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.235 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.235; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (12.22.5.235) by BN8NAM11FT053.mail.protection.outlook.com (10.13.177.209) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5314.12 via Frontend Transport; Wed, 1 Jun 2022 03:44:45 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL107.nvidia.com (10.27.9.16) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Wed, 1 Jun 2022 03:44:45 +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; Tue, 31 May 2022 20:44:41 -0700 From: Alexander Kozyrev To: CC: , , , , , , , , , , , Subject: [PATCH v3 5/7] app/testpmd: add meter color flow matching item Date: Wed, 1 Jun 2022 06:44:06 +0300 Message-ID: <20220601034408.2579943-6-akozyrev@nvidia.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20220601034408.2579943-1-akozyrev@nvidia.com> References: <20220522105102.1692526-1-akozyrev@nvidia.com> <20220601034408.2579943-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-Office365-Filtering-Correlation-Id: 99ad62bc-a158-4423-a6ed-08da4381122d X-MS-TrafficTypeDiagnostic: BL0PR12MB5507: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: +4NCXM77wG09AC5nLwuuOsokEyPTBInf5syx53f8acIlg7iWHXhmLBNoxqFKccaoEfxv3oXrGsP5891hleJGJU4vp6gZk+D1o3MZbnDkVnGryIBiZRzyKAw29rwDmDa991fuoHeT8vQxsoZedbctkIiYwuXE9vrLRQyxjOy3oPxa0HuiJP7BeWjvhX3ujEkTJ+pgM71NiHyFUv2uP1GC6xOwEd9nfX8U635CW7JWRzG+GWGbIZqJn0NgDeZiVNDPBSaxx+VdFDVEVz/pjQe4EkX8TICnwyhfudSSW1/CuQP7NFabW8EzGh567JrGP6FTgAb6gxCDAz+zyzuNqzAPBwi1Q+5f8bmRoN297n9qeFENYutrdfWnMrZCZhz4pPE4xAh1E6AuD5G3TKzrTkPJzp8mSexr7G8hsayVIueATOASnKcXCa+Vg2N6zO9aOOSg7FjwDP7sZhiY7ygK2NCtFR27MkeQyYDwSb/lqTYdqZjrLvdjEuhmhIyZ2ER6NB8jKJQk4tyMzv6hLgSEIn6qNV4kdr1CrvYF3ZmkggWMhpdRC/jt8myMU2d+cw/ZPTTONy/8GwzcL+IOqpl/LiXAzBkK9316SGpnkQlMz+qVxJ0nfwjmBJ49tt+xPC6lGl1gb0g5m7cBYWw/Ru47Vur8PWmSo23dKxJnzmoKO61kqLAqnL6givKalapsZ7ZV9Bp+vZVp0v+eL746xgB4PvKeEA== X-Forefront-Antispam-Report: CIP:12.22.5.235; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE; SFS:(13230001)(4636009)(36840700001)(46966006)(40470700004)(82310400005)(86362001)(70586007)(5660300002)(8676002)(8936002)(16526019)(4326008)(70206006)(7416002)(2616005)(186003)(1076003)(36860700001)(6666004)(508600001)(40460700003)(26005)(6916009)(81166007)(54906003)(2906002)(316002)(47076005)(426003)(336012)(83380400001)(36756003)(356005)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jun 2022 03:44:45.9295 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 99ad62bc-a158-4423-a6ed-08da4381122d 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.235]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT053.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL0PR12MB5507 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 Acked-by: Ori Kam --- 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 e3269e278d..c66da76f25 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -458,6 +458,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, @@ -798,6 +801,10 @@ static const char *const modify_field_ids[] = { "tag", "mark", "meta", "pointer", "value", 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 @@ -1331,6 +1338,7 @@ static const enum index next_item[] = { ITEM_FLEX, ITEM_L2TPV2, ITEM_PPP, + ITEM_METER, END_SET, ZERO, }; @@ -1803,6 +1811,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, @@ -2371,6 +2385,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 *, @@ -2401,6 +2418,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[] = { @@ -5063,6 +5082,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", @@ -9866,6 +9908,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, @@ -10157,6 +10223,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; @@ -10772,6 +10852,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 1083c6d538..5e2f5ffb40 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -4164,6 +4164,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 Wed Jun 1 03:44:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Kozyrev X-Patchwork-Id: 112175 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 E3F92A0552; Wed, 1 Jun 2022 05:45:07 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id E07CE4281A; Wed, 1 Jun 2022 05:44:52 +0200 (CEST) Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2088.outbound.protection.outlook.com [40.107.94.88]) by mails.dpdk.org (Postfix) with ESMTP id 106EC410EA for ; Wed, 1 Jun 2022 05:44:52 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=WsUnj1tUlND4AHVuXjt/4X37EEQbMBeZOXAPbwrsNWKSVi4UrNxuUmnEdeKRpjDSBWqTViXy7HFcmk/dK8vYPSiSiHcd9Jze025ZDoHhGe9bxLT2OlPwQc2LMleTbAFcfMQFwtnWdh7Svz16f/jkPeUjdKPqq/D60aX/5rThVTPRX7CJMr47z/Y92MR7kAfn1qP2HS+bVwvkvwT4PLDAMtc4KhfgI2pWkPg4LGpY31so4yc5YvADNH3W7Y3893wji+eQTinM8E4QRCT7Os60kDwnAWzmHld4XwbaPy5z2oqhFGc9judpuimMcsGpV1oRehUsznx1aFRq7o880Ncagw== 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=AbQkBl0E46/MwW+7z2POmDFQk3Ui/qRzKhfnzK53T2Y=; b=jAuaJtEPkZxi2HCCWPlgebPuvbxsTlQnYNKT4u9pXB4/4jCp3r7vlSdOBGCWpyMis1Hit88CLNjPblDs2eWt7qAse9HDWO/5svrSUqFiqN1Wfo1cdHNgE8J6J02ssKfV1kiDUEiR98lHLS5W0ZFEJCbGt47CSwyWyuYNUSUUszEQiFPkpCIHhw2PL9bD8OD8BXrif0DFAfcr4SIOApftrUst9hiERdUU7qZ+EHSeQU2epBOCI2ZkbnMMEHdjz/EJxHVZmAlZqDdm/B5YiUi3cWAdVcffmDKSnQdcZAPzLJ8fCIQmPubNYPS+0OEelB1BOViIHDxE5DQSsd2ScEoyQQ== 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=AbQkBl0E46/MwW+7z2POmDFQk3Ui/qRzKhfnzK53T2Y=; b=JurLYC3nPAhWS9WvjNoA2A12ud3ETok3Vlh8eLAfBMW2P3zeYVnWExg/yz9LrenvIP0yL1oV3XdSDeJ1V1ZN5ahlp1kY9ruTBkL5UXcP0Tyr8pwbivmPG/0bvrviUOyJlXGDcvVKqd5KGdOpqXCFfeePdeeLYGbhlL4zdpTfV7M5nrOpXDRQyVMsSfWaqIxiRybK452ywoJicAlOd1G7XtrZdvQ9FlCDnR/8crgZ32i/riVswO62Pd6xmfXKCah09dKU+Lz2HDaaPJnxRRVa4isy4G/PME3zwaQ+Fp5NDeWdRNq8bUiOn7gjJdCf785sfU0kS0BC5WZkirbdpj19Vw== Received: from DM5PR06CA0028.namprd06.prod.outlook.com (2603:10b6:3:5d::14) by BYAPR12MB2616.namprd12.prod.outlook.com (2603:10b6:a03:66::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5293.17; Wed, 1 Jun 2022 03:44:49 +0000 Received: from DM6NAM11FT046.eop-nam11.prod.protection.outlook.com (2603:10b6:3:5d:cafe::c2) by DM5PR06CA0028.outlook.office365.com (2603:10b6:3:5d::14) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.12 via Frontend Transport; Wed, 1 Jun 2022 03:44:49 +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; pr=C Received: from mail.nvidia.com (12.22.5.238) by DM6NAM11FT046.mail.protection.outlook.com (10.13.172.121) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5314.12 via Frontend Transport; Wed, 1 Jun 2022 03:44:49 +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; Wed, 1 Jun 2022 03:44:48 +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; Tue, 31 May 2022 20:44:45 -0700 From: Alexander Kozyrev To: CC: , , , , , , , , , , , Subject: [PATCH v3 6/7] app/testpmd: allow meter color marker modification Date: Wed, 1 Jun 2022 06:44:07 +0300 Message-ID: <20220601034408.2579943-7-akozyrev@nvidia.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20220601034408.2579943-1-akozyrev@nvidia.com> References: <20220522105102.1692526-1-akozyrev@nvidia.com> <20220601034408.2579943-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-Office365-Filtering-Correlation-Id: ab9db732-9102-4fa5-71f0-08da43811429 X-MS-TrafficTypeDiagnostic: BYAPR12MB2616: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: l0DWD9n51NeNpR3ghdPKMcPbsgI3ERIDWNSjQIGJ9iqWlBaa7iWsNtprL5xi9eu5Ekj1R39sEWNPM40nxRrLq2of2YWq/h/AZk5jI016FmGw6LGPdSAW0Cww7bckJ/qmB3Ak2KnwhQIsfdIrEagZCh4pYQSJklThpkuwLKJK560QGrCXk3xAM7hV2tUw+6EimO2l5pap2YhAKzG0I7bGCY+nDb+dGL/aeMEB+JzuLbuF9MqVCKnrmWkrfs7dKOwqaSS8BxAicCpJIRFVuTAtGdKllQbFn9boSCDfo/n7EjtVXvzjB1skk4uGtpbxN2UcsBVHDb9h3ya0wSZu1CtRBZh2V+sdiBvO4rEWNX0Zh0GEYG1xobxT0pjr4NXJiRPgL87In2PuXCtjPIlHQILn+O45WhHDGK+QBOjgUPgDdJgGdIQ5FOzsQzE/GT4syTlywA2RNqlSaLf+j1Uv90cSAB6T7urBUU/hOZM2nj0xAUK5Vc5URPRUR2//pZZEg83JDYx2n47IjsOcDZRI4B0gH7SEizQy3cRFKbY/mot8HjpffpBzO5NesTT4ZDBZ3SyRlIFHxUJz9CB37V5qolBuruenCgLewn9jm1kdmr7Q0ML0gohjhnm4K4rY74UiqWL8a4k3OA/aLzk2OejuO+o7quknjI/rJR9nVyrMVnLlNqtgXjMNyDTcf81UkKadn5zRSzvYhNnmseV4opH4Qb7U+g== X-Forefront-Antispam-Report: CIP:12.22.5.238; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE; SFS:(13230001)(4636009)(46966006)(36840700001)(40470700004)(508600001)(8676002)(5660300002)(4326008)(70206006)(186003)(70586007)(83380400001)(40460700003)(7416002)(86362001)(8936002)(1076003)(26005)(16526019)(82310400005)(81166007)(356005)(36860700001)(4744005)(2616005)(2906002)(6916009)(54906003)(6666004)(36756003)(47076005)(426003)(336012)(316002)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jun 2022 03:44:49.3355 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ab9db732-9102-4fa5-71f0-08da43811429 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: DM6NAM11FT046.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BYAPR12MB2616 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 Acked-by: Ori Kam --- app/test-pmd/cmdline_flow.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index c66da76f25..401922fc34 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -798,7 +798,8 @@ static const char *const modify_field_ids[] = { "tcp_seq_num", "tcp_ack_num", "tcp_flags", "udp_port_src", "udp_port_dst", "vxlan_vni", "geneve_vni", "gtp_teid", - "tag", "mark", "meta", "pointer", "value", NULL + "tag", "mark", "meta", "pointer", "value", "meter_color", + NULL }; static const char *const meter_colors[] = { From patchwork Wed Jun 1 03:44:08 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Kozyrev X-Patchwork-Id: 112176 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 6BFE5A0552; Wed, 1 Jun 2022 05:45:15 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 38EC442B92; Wed, 1 Jun 2022 05:44:56 +0200 (CEST) Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on2062.outbound.protection.outlook.com [40.107.223.62]) by mails.dpdk.org (Postfix) with ESMTP id 574FC42B92 for ; Wed, 1 Jun 2022 05:44:55 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=nxglfwYvtzJcvjSkyUndfuOlk73MMFtmjVzojVIr6avwbIZi3JS9/UjLtSz5zobpPwWoVB7gBILFt2L6b4k0mZERo4jiwlv3PKKZpD/RzqjPd1D15PIFMCvhbI1hJ/OzL8OksTcR/Zb9xSG6cM3WtH8xJX83Y38mRRD+TGDDj1SrduVvgnfc2ddWaqOgGgnGFFnp+XzycdSNniT81QA6JKy+1hxRZ/+TtcM5EhPGniw2UHUJPENtG+pzCLCOjMlAkEnFNwGfN98j/j5skCqz/N8WQsEgHWQ/LII614E3x4gtiGCvPOervsurL7fuxPiNPBxS50t7m+oy+R4WXK+7Qw== 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=/M4pif3XjpsmFoIdffCMnAA9AOVTQfbhoM+yQgr48X0=; b=loPIsmeSwC9Y5SNgbBWZ45RZVMKEhZHk/LJ0WWXJlGw8TZhQtcI3DS1GLqTVOU6U2uVrZRj/H6V3t4X1vWZnNfrD/1jzJdm4BjxQ+R3Gfj9f206BmuDoqY/O6NvJZ+DkkBBDCDqZUA1R4eRHS22ydlQuvnyOaPP0mShl4Ayj+CXWVNhonvaHBCPZTG1UUVe+0DSEiYkORDoSTbQPw4aHUWMBPvsx2NmSOY9M3iw2kIyNulEvg6AgRQQy1N4Z1JeeQkiteRPXWieDIjCYzOAkmRK1x7+/bYZtrFbyBanUn4UFWniYlYysogfSOZMsPDZlDDyBquTxD4P/bT+eZSCjQw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 12.22.5.234) 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=/M4pif3XjpsmFoIdffCMnAA9AOVTQfbhoM+yQgr48X0=; b=D4WMfSn6QnQt8382Guq+7N1MafhiaSGiIsir4xpW1aFW9W+ssnZOt9Sgr4tBfAbF5WUUXyZa2DCAAboEFiu/Duo8531jijXkGUPq0WQY+92fUmbhoFAvD6JUV+rqatwVpBnaz/CtehRVzOLh4UXgd9/AzYnnbs9bbv1NTUda/QvQZkUhNXxmAZFUkY3428U9ekTv/utlPuKJEK8QF5Y1rO5rMN6Xo+8EU/nAZfJph/wDh5R/YfEmpXGAkOErLfg2CtL8D9SztSq/mviYXiBZY8/ggTrGbJXYm5BljyDTgY6MUxHIjTVSB/mYaTMnPFzEl7xUKxjDzrsOz5IUjZ1avA== Received: from DM5PR06CA0036.namprd06.prod.outlook.com (2603:10b6:3:5d::22) by CO6PR12MB5491.namprd12.prod.outlook.com (2603:10b6:303:13b::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5314.12; Wed, 1 Jun 2022 03:44:53 +0000 Received: from DM6NAM11FT046.eop-nam11.prod.protection.outlook.com (2603:10b6:3:5d:cafe::5a) by DM5PR06CA0036.outlook.office365.com (2603:10b6:3:5d::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5293.13 via Frontend Transport; Wed, 1 Jun 2022 03:44:52 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 12.22.5.234) 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.234 as permitted sender) receiver=protection.outlook.com; client-ip=12.22.5.234; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (12.22.5.234) by DM6NAM11FT046.mail.protection.outlook.com (10.13.172.121) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384) id 15.20.5314.12 via Frontend Transport; Wed, 1 Jun 2022 03:44:52 +0000 Received: from rnnvmail201.nvidia.com (10.129.68.8) by DRHQMAIL101.nvidia.com (10.27.9.10) with Microsoft SMTP Server (TLS) id 15.0.1497.32; Wed, 1 Jun 2022 03:44:52 +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; Tue, 31 May 2022 20:44:48 -0700 From: Alexander Kozyrev To: CC: , , , , , , , , , , , Subject: [PATCH v3 7/7] app/testpmd: add meter color mark flow action Date: Wed, 1 Jun 2022 06:44:08 +0300 Message-ID: <20220601034408.2579943-8-akozyrev@nvidia.com> X-Mailer: git-send-email 2.18.2 In-Reply-To: <20220601034408.2579943-1-akozyrev@nvidia.com> References: <20220522105102.1692526-1-akozyrev@nvidia.com> <20220601034408.2579943-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-Office365-Filtering-Correlation-Id: 16a027f8-6bff-4d30-bf9a-08da4381163a X-MS-TrafficTypeDiagnostic: CO6PR12MB5491: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: Ub1BpoQnsgh9rs6KVUy78baVal0FmFlB//+lHAqPTa8ODwYL3Uwj9zWr6aKdwn0WpXRGFQuCqesIq/gPey9NLdUoIWu9Ro/8OjM4NMmhsKWoImBizfDnBdQBbEVspQRy+j2eMg7C02fpaW/4Rz8DN6IBqxyNxKZDN+HgJY9VJLorZ9wsUoDdsQ0X/nsnubumwaOzPHN5w6KYrJwGMlqML7O43IYej06u8JJcWsozfi1WThMa61sjBKITzNhiVYfLOxpWaUextAc2Alf6IIEo5vl6xCdefamWEsilw2gDND3g91QF38DyrbQntI8y1bj9scH3F2cnphyBPm56cy2LB5pk0kcVRniMR6QIoLamnGQmJQPQ/HZRZjBzW0ek25RvAQbpFGT5+d1qN/xynsWnJd3Aa5DY/2SG8lD2MoHe0GyuKGiUQlhZFE6En+hgvLAQtRmAZ/qeNakzfp2QxaYD/24w6ppGWvzv6X/tD0u6lExjen18lTZhdfzo2/Mh/iFlBd5X5FAn4CW2Yu0O2TRwVCpfRZjIDnywKgMbKlAMEg6zM0xgnxwVc97RxrogfEv28V9PH7B28BVURBF0tDOBUBQZSrM1PkD/8uTwa/+44ixv/yMkFbRYyct5bpQxL9ag9nvwves/h3IHr5MadnEjsQyi/MZQMJaB+QMrk9ummp9M62VCb3xXJX5ACx5nJKMTqH6rmwn+WRscB9GXA8YC5A== X-Forefront-Antispam-Report: CIP:12.22.5.234; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:InfoNoRecords; CAT:NONE; SFS:(13230001)(4636009)(40470700004)(46966006)(36840700001)(26005)(16526019)(186003)(2616005)(36860700001)(316002)(356005)(36756003)(70206006)(70586007)(4326008)(8676002)(81166007)(6916009)(8936002)(6666004)(5660300002)(7416002)(508600001)(2906002)(82310400005)(86362001)(83380400001)(426003)(40460700003)(336012)(1076003)(47076005)(54906003)(36900700001); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Jun 2022 03:44:52.8043 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 16a027f8-6bff-4d30-bf9a-08da4381163a 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.234]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT046.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CO6PR12MB5491 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 Acked-by: Ori Kam --- app/test-pmd/cmdline_flow.c | 127 ++++++++++++++++++++ app/test-pmd/config.c | 26 ++++ app/test-pmd/testpmd.h | 4 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 5 + 4 files changed, 162 insertions(+) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index 401922fc34..7261d6f52e 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -53,6 +53,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, @@ -508,6 +509,11 @@ 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_OF_SET_MPLS_TTL, ACTION_OF_SET_MPLS_TTL_MPLS_TTL, ACTION_OF_DEC_MPLS_TTL, @@ -1835,6 +1841,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, @@ -1951,6 +1958,13 @@ static const enum index action_meter_color[] = { ZERO, }; +static const enum index action_meter_mark[] = { + ACTION_METER_PROFILE, + ACTION_METER_POLICY, + ACTION_NEXT, + ZERO, +}; + static const enum index action_of_set_mpls_ttl[] = { ACTION_OF_SET_MPLS_TTL_MPLS_TTL, ACTION_NEXT, @@ -2389,6 +2403,14 @@ static int parse_mp(struct context *, const struct token *, 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 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 comp_none(struct context *, const struct token *, unsigned int, char *, unsigned int); static int comp_boolean(struct context *, const struct token *, @@ -2550,6 +2572,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", @@ -5428,6 +5457,42 @@ 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_OF_SET_MPLS_TTL] = { .name = "of_set_mpls_ttl", .help = "OpenFlow's OFPAT_SET_MPLS_TTL", @@ -9747,6 +9812,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; + 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; + 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 1b1e738f83..413dcb6e9d 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -2184,6 +2184,32 @@ port_meter_policy_add(portid_t port_id, uint32_t policy_id, return ret; } +/** Get port meter profile */ +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; +} + +/** Get port meter policy */ +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, diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index f04a9a11b4..5fed46ae17 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -985,6 +985,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 5e2f5ffb40..fd5a05dbad 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -4453,6 +4453,11 @@ 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 + Destroying flow rules ~~~~~~~~~~~~~~~~~~~~~