From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 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 Content-Type: text/plain X-Originating-IP: [10.126.231.35] X-ClientProxiedBy: rnnvmail202.nvidia.com (10.129.68.7) To rnnvmail201.nvidia.com (10.129.68.8) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-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 { -- 2.18.2