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 30621A0A0A; Tue, 23 Mar 2021 22:33:30 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id A09464014D; Tue, 23 Mar 2021 22:33:29 +0100 (CET) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id F027440143 for ; Tue, 23 Mar 2021 22:33:26 +0100 (CET) IronPort-SDR: xiYaofPpopGB+aoUo8n+rJiS8u+EIospTOeJ2sC+/ORg86b86TV/DUM0f3cQEyuecIkuqp8phl yGLh5TmjPuzA== X-IronPort-AV: E=McAfee;i="6000,8403,9932"; a="210660869" X-IronPort-AV: E=Sophos;i="5.81,272,1610438400"; d="scan'208";a="210660869" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Mar 2021 14:33:25 -0700 IronPort-SDR: cGoxNFmqc4E7CqdXJGHXq9l/A4wGRsVhQYsHqIeh5VQdWnl6UDarl8kGu74e0Fu5lgRy4wc8gD pPHIQojvTaOw== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,272,1610438400"; d="scan'208";a="525001080" Received: from fmsmsx604.amr.corp.intel.com ([10.18.126.84]) by orsmga004.jf.intel.com with ESMTP; 23 Mar 2021 14:33:24 -0700 Received: from fmsmsx610.amr.corp.intel.com (10.18.126.90) by fmsmsx604.amr.corp.intel.com (10.18.126.84) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2; Tue, 23 Mar 2021 14:33:24 -0700 Received: from fmsedg601.ED.cps.intel.com (10.1.192.135) by fmsmsx610.amr.corp.intel.com (10.18.126.90) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2106.2 via Frontend Transport; Tue, 23 Mar 2021 14:33:24 -0700 Received: from NAM04-DM6-obe.outbound.protection.outlook.com (104.47.73.41) by edgegateway.intel.com (192.55.55.70) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.1.2106.2; Tue, 23 Mar 2021 14:33:24 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=JVvZcjLmMIW2Y7pEfhhDS8s/wiO8a46AWG3th67bOfw9dv8HvdnBph+Va/d3WvAldaR5Vz73C+5JlKbqeuup1jCADiX1hTxoeLfoGR6vGTwCscSmQWnyZLVxY/iouraQ9HV1mhIqMGaMO3jVpPpNgH5dLRAgHHNnGSaN0WHym4yg9O+BvNznNZAvMQrRT1u3Ge4QOoiCXHmk6XNhA+hjdO42mHl3gtX2ybtDfPFeq63JtsIXN6lxrXIP+nmd8RINaQfi7xSaTbiSSakoEes/PHQrZmKeCRiAZvBCHe4/Kalvr6O9mjNm2HV70ReepHNEZWL9WkcluUudZSGPhBNh9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dAr2SxJ83MBiwGgT9B7OY1CDD0KZOxTYpAvMSeQ97rc=; b=eOaAraavrr80UNUgOKr/L66O9UEBJIRJWLraZox+iP/0UIORzmD5Ue5gtI/DfoaJnUUzo7tRFLeuph1u7KilqPNIU0FQEFq0oFUXYaxERI8nI6tM+J+wSANGZ9DDar0ItnukPdhReUrEa2yE9rAE+kr7IdUVZoGUq0FWTIGL3YCgUAHIeLs8pJ7+UTS8slasTHyIIGy7+flwjYWB8QriNx8Pz1PzXULe6wY2wqEgElVwrUVeVXqFIvMEgM6Ii3C4Kgxo99eh1obL+xV1PFFD9P5Saex9be7J1iAePCDQGLJnShfaJhYFSkdISMudrkIkrcUj9DrNxlu+G4x+xifnYw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=intel.com; dmarc=pass action=none header.from=intel.com; dkim=pass header.d=intel.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel.onmicrosoft.com; s=selector2-intel-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=dAr2SxJ83MBiwGgT9B7OY1CDD0KZOxTYpAvMSeQ97rc=; b=vzJRiG/HnleqEfUWmm9NKDUAfOWNIOVVEGzsaqXFzh7HUF6XxyEPV902qyyKwQ3jCxTNXDWJXK1WsFqZ1UngOTtsY6YCpNr/N5BYhvAjs26g4s/FtqW81NBxKpgkub9wTQ55Y3i2qNPo/f2tcSzdCMHvXtbaSGO/ROHrjUaODuo= Received: from DM6PR11MB2796.namprd11.prod.outlook.com (2603:10b6:5:c8::23) by DM5PR11MB0043.namprd11.prod.outlook.com (2603:10b6:4:69::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3890.19; Tue, 23 Mar 2021 21:33:20 +0000 Received: from DM6PR11MB2796.namprd11.prod.outlook.com ([fe80::b5d2:6f20:3c0:3627]) by DM6PR11MB2796.namprd11.prod.outlook.com ([fe80::b5d2:6f20:3c0:3627%7]) with mapi id 15.20.3955.027; Tue, 23 Mar 2021 21:33:20 +0000 From: "Dumitrescu, Cristian" To: Li Zhang , "dekelp@nvidia.com" , "orika@nvidia.com" , "viacheslavo@nvidia.com" , "matan@nvidia.com" , "shahafs@nvidia.com" , "lironh@marvell.com" , "Singh, Jasvinder" , "Thomas Monjalon" , "Yigit, Ferruh" , Andrew Rybchenko , Jerin Jacob , Hemant Agrawal , "Ajit Khaparde" , "Richardson, Bruce" , "Doherty, Declan" CC: "dev@dpdk.org" , "rasland@nvidia.com" , "roniba@nvidia.com" Thread-Topic: [PATCH 2/2] [RFC]: ethdev: manage meter API object handles by the drivers Thread-Index: AQHXG9TcG2V6YmVzx0OnxBK4CI2yNqqSGifg Date: Tue, 23 Mar 2021 21:33:20 +0000 Message-ID: References: <20210318085815.804896-1-lizh@nvidia.com> <20210318085815.804896-2-lizh@nvidia.com> In-Reply-To: <20210318085815.804896-2-lizh@nvidia.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-version: 11.5.1.3 dlp-reaction: no-action dlp-product: dlpe-windows authentication-results: nvidia.com; dkim=none (message not signed) header.d=none;nvidia.com; dmarc=none action=none header.from=intel.com; x-originating-ip: [51.37.64.137] x-ms-publictraffictype: Email x-ms-office365-filtering-correlation-id: fe7fe43a-fb64-4f27-94ca-08d8ee4347c4 x-ms-traffictypediagnostic: DM5PR11MB0043: x-ld-processed: 46c98d88-e344-4ed4-8496-4ed7712e255d,ExtAddr x-ms-exchange-transport-forked: True x-microsoft-antispam-prvs: x-ms-oob-tlc-oobclassifiers: OLM:7219; x-ms-exchange-senderadcheck: 1 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: GuIOYH0747jzdWwxps/iHP8o8KMgjiLV2v26qp4+eAKqwit1J9c1NZUP4UiOCZG/+FNIeH8T9h0f+YbfkRoJOhNUs9X4s3G0xObEGYDw8x8vs+Rh0MfBzAUff06m4RfGeZRg/elGVvmCEb2U/wrjc9yqf4JtHhNhE30Y3GIoHkZ3hrwqQXFok+Ahydxk4c1MClJ3zKf3JlL6/Y2RWZun1wFbLMlDgXG/0EzUgC45fRJmGazyWTyuxwOkYwiGXqnUUwZcMejCbUzXS9EL9TloYmUvWTJjg1afTmTP4t0MiQIGt9r5LbMVSxmeJqL3pcySpBrI+t3fO0ZcL+qeBsOCsx3WPflWr6UkbwY1NAjc8SZflTKjxJ+EDlQoHA5xIltvvEVNyHUXMLcBX57HwOwp17BHNNx9Hb1gRM62ylFqdjhSdB/V3TEf5nasx/V10JzJW5rKLdFnSuabsNjbzwWG+zVkq2ggWEKi7fW7x+Zi5G8d/MHNN7+k5k3q70yrbFzQCB8bbLANFSxUA7qbJy0ybDLqlDlvGKuSgvzbfQhMtjaxJ9AlP8EeFg2hi7+LCfVdO87W3w8a+vY1kq4IzlM0CLit3+M05o/F+L/4VATGbbE0/FNtj54w0v5ysWUe9eO4jvdFhCTAb8rTrJ23Ur8FswtvmduiwgVO0lVgp/IEkYY= x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DM6PR11MB2796.namprd11.prod.outlook.com; PTR:; CAT:NONE; SFS:(366004)(396003)(39860400002)(376002)(136003)(346002)(5660300002)(71200400001)(86362001)(316002)(7416002)(8936002)(6636002)(54906003)(66556008)(83380400001)(55016002)(30864003)(8676002)(66446008)(186003)(110136005)(9686003)(6506007)(52536014)(33656002)(53546011)(921005)(7696005)(966005)(66946007)(478600001)(4326008)(66476007)(38100700001)(76116006)(64756008)(26005)(2906002)(579004); DIR:OUT; SFP:1102; x-ms-exchange-antispam-messagedata: =?us-ascii?Q?m8tn2f4WFtw247W7ek1od1SNQJqr8Y11/yj52+03mGJXY7or8U5U1blHGlYM?= =?us-ascii?Q?VMel4koSBUe0supa+bDGGsOX79vWv4X3zYc7kjC3wZTG+4/GtzUWZiP9A58c?= =?us-ascii?Q?uXNU8NPyUkpoCCJeK49u55ykHSt+h302q5BC1htfiOrlnSEzUhhVJSJdmFqV?= =?us-ascii?Q?el0g4JkzxluCFUAl3jjndS4TDgwGAo8fFc7UlDRqW8kUA/i3j9FGeLM0/CHr?= =?us-ascii?Q?Wzq/ufWHorAtu0IHkmbvTcl+s1pgcdpVomuuQHvB4ImZmfA6bQlcFfoDZDpw?= =?us-ascii?Q?a3ZK5Yh/nnzc57WosOsWSOU99zcEuiLwCu5rLXNaekDf+C8ihxIiQ13D6Eih?= =?us-ascii?Q?fw8ISDGmOO5pLIgBSk46HFQ5rwrlDwb2QqjmAqiIButuELH+eiVgHerEM4su?= =?us-ascii?Q?A19uiaHz4B4snA+DD1NOxXySzcwMRkMfnKejv07qA2S/z/4MMdqDxpBCSpAS?= =?us-ascii?Q?NvD4Id2dD5mEjyUm+CpbjqGt7/HChmsDltWztzLqlOQ62eOhYj6NmOU5f/tE?= =?us-ascii?Q?MYY7f/mby01udc4QItTO6XJO9oEK+4YSv/t0qiYIZ9sz1OHznkXmPythe1WD?= =?us-ascii?Q?sOR9R60BAvsXh3CM1zvU7hSeKFnmxRfmQKY7wTob9YzOJayxU+23a2UQ0/xg?= =?us-ascii?Q?d+f4p0t76CWxSKRA0vHaik+XIObWASqMYC5rILU8kyuW9+4nLNMGbpxByZ2q?= =?us-ascii?Q?88f6pJL13nafproeC2Nzyb+F4pQ03Rn12zGCh/kd8C1sNuI7lhCKPRJMXTRT?= =?us-ascii?Q?QppGEx8HY3uN252/zd2OJGYTX9CBdtWypAbX6/d7bVBzbzSQp920aueUMCn9?= =?us-ascii?Q?6HFva3NL4skZo11hRvrMHjqS2YsZ5s7cBbYG1dJRr3ZZSBgf3AAxXCNXL5oe?= =?us-ascii?Q?U935gbwie//A2ne4HLfDyI5mvvkKejIhP6O1MdxZ14LPRAme6S/Klt499bP0?= =?us-ascii?Q?uSYqgVIptjv5XcnByiZwy+MRwT/hSGyWmVQB8vnh5McKo8c7qYRAUkGmuadC?= =?us-ascii?Q?ulcDGFb/K0EKwrQ+vxr5cABqiFuNvEPPNrXV2RCSu32QeImp4mrmZO8L/QzE?= =?us-ascii?Q?tegzSuorQQ77EtNzu2X1hkCbT028jUcsHDjfy6pdCf0tm5nyQYcC/8L5tH9p?= =?us-ascii?Q?5BiHMZA9bT9xm+iVkqnkhvQj6/qAIB8TTJG4HC4WNqIa4J6B/nQGyxPKztcW?= =?us-ascii?Q?tVWoxysdr4qE/OKeLZw9P/lGMMSOFE4VSA4wwKMU3K684ZmyJvz9XU29+hsI?= =?us-ascii?Q?78VZ1ThQ7Mw4T6nK20W47JLMMmWiP49l54n5VQPhEGnvWHYNdn4nWXE9ISts?= =?us-ascii?Q?DwU=3D?= Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: DM6PR11MB2796.namprd11.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: fe7fe43a-fb64-4f27-94ca-08d8ee4347c4 X-MS-Exchange-CrossTenant-originalarrivaltime: 23 Mar 2021 21:33:20.6080 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 46c98d88-e344-4ed4-8496-4ed7712e255d X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: iAuc0pHXk3WgOfw6HcBTCpc4+LyfRVscxGBQIQDnK8SIFNEpWY6CXiB5zobFuZyPtzdELfQ38vSdFKZqEgq4gcavxS2eZfKNTJ8SHCcpwgw= X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR11MB0043 X-OriginatorOrg: intel.com Subject: Re: [dpdk-dev] [PATCH 2/2] [RFC]: ethdev: manage meter API object handles by the drivers X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Hi Li and Matan, > -----Original Message----- > From: Li Zhang > Sent: Thursday, March 18, 2021 8:58 AM > To: dekelp@nvidia.com; orika@nvidia.com; viacheslavo@nvidia.com; > matan@nvidia.com; shahafs@nvidia.com; lironh@marvell.com; Singh, > Jasvinder ; Thomas Monjalon > ; Yigit, Ferruh ; Andrew > Rybchenko ; Dumitrescu, Cristian > > Cc: dev@dpdk.org; rasland@nvidia.com; roniba@nvidia.com > Subject: [PATCH 2/2] [RFC]: ethdev: manage meter API object handles by th= e > drivers >=20 > Currently, all the meter objects are managed by the user IDs: > meter, profile and policy. > Hence, each PMD should manage data-structure in order to > map each API ID to the private PMD management structure. >=20 > From the application side, it has all the picture how meter > is going to be assigned to flows and can easily use direct > mapping even when the meter handler is provided by the PMDs. >=20 > Also, this is the approach of the rte_flow API handles: > the flow handle and the shared action handle > is provided by the PMDs. >=20 > Use drivers handlers in order to manage all the meter API objects. >=20 This seems to be take 2 of the discussion that we already had in this thre= ad: https://mails.dpdk.org/archives/dev/2021-March/200710.html, so apologie= s for mostly summarizing my previous feedback here. I am against this proposal because: 1. We already discussed this topic of user-provided handles vs. driver-prov= ided handles at length on this exact email list back in 2017, when we first= introduced this API, and I don't see any real reason to revisit the decisi= on we took then. 2. For me, it is more natural and it also helps the application to simplify= its data structures if the user provides its own IDs rather than the user = having to deal with the IDs provided by the driver. 3. It is much easier and portable to pass numeric and string-based IDs arou= nd (e.g. between processes) as opposed to pointer-based IDs, as pointers ar= e only valid in one address space and not in others. There are several DPDK= APIs that moved away from pointer handles to string IDs. 4. The mapping of user IDs to internal pointers within the driver is IMO no= t a big issue in terms of memory footprint or API call rate. Matan also con= firmed this in the above thread when saying tis is not about either driver = memory footprint or API call speed, as this mapping is easy to optimize. And last but not least, this change obviously propagates in every API funct= ion, so it would result in big churn in API, all drivers and all apps (incl= uding testpmd, etc) implementing it (for IMO no real benefit). Yes, this AP= I is experimental and therefore we can operate changes in it, but I'd rathe= r see incremental and converging improvements rather than this. If you guys insist with this proposal, I would like to get more opinions fr= om other vendors and contributors from within our DPDK community. > The following API will be changed: > - rte_mtr_meter_profile_add > - rte_mtr_meter_profile_delete > - rte_mtr_meter_policy_validate > - rte_mtr_meter_policy_add > - rte_mtr_meter_policy_delete > - rte_mtr_create > - rte_mtr_destroy > - rte_mtr_meter_disable > - rte_mtr_meter_enable > - rte_mtr_meter_profile_update > - rte_mtr_meter_policy_update > - rte_mtr_meter_dscp_table_update > - rte_mtr_stats_update > - rte_mtr_stats_read > The next struct will be changed: > - rte_flow_action_meter > - rte_mtr_params >=20 > Signed-off-by: Li Zhang > --- > lib/librte_ethdev/rte_flow.h | 9 ++- > lib/librte_ethdev/rte_mtr.c | 77 ++++++++++++---------- > lib/librte_ethdev/rte_mtr.h | 102 +++++++++++++++-------------- > lib/librte_ethdev/rte_mtr_driver.h | 36 +++++----- > 4 files changed, 122 insertions(+), 102 deletions(-) >=20 > diff --git a/lib/librte_ethdev/rte_flow.h b/lib/librte_ethdev/rte_flow.h > index 5f38aa7fa4..6d2b86592d 100644 > --- a/lib/librte_ethdev/rte_flow.h > +++ b/lib/librte_ethdev/rte_flow.h > @@ -2480,6 +2480,13 @@ struct rte_flow_action_port_id { > uint32_t id; /**< DPDK port ID. */ > }; >=20 > +/** > + * Opaque type returned after successfully creating a meter. > + * > + * This handle can be used to manage the related meter (e.g. to destroy = it). > + */ > +struct rte_mtr; > + > /** > * RTE_FLOW_ACTION_TYPE_METER > * > @@ -2489,7 +2496,7 @@ struct rte_flow_action_port_id { > * next item with their color set by the MTR object. > */ > struct rte_flow_action_meter { > - uint32_t mtr_id; /**< MTR object ID created with rte_mtr_create(). > */ > + struct rte_mtr *mtr; /**< MTR object created with rte_mtr_create(). > */ > }; >=20 > /** > diff --git a/lib/librte_ethdev/rte_mtr.c b/lib/librte_ethdev/rte_mtr.c > index fccec3760b..e407c6f956 100644 > --- a/lib/librte_ethdev/rte_mtr.c > +++ b/lib/librte_ethdev/rte_mtr.c > @@ -57,6 +57,19 @@ rte_mtr_ops_get(uint16_t port_id, struct > rte_mtr_error *error) > ops->func; \ > }) >=20 > +#define RTE_MTR_FUNC_PTR(port_id, func) \ > +({ \ > + const struct rte_mtr_ops *ops =3D \ > + rte_mtr_ops_get(port_id, error); \ > + if (ops =3D=3D NULL) \ > + return NULL; \ > + \ > + if (ops->func =3D=3D NULL) \ > + return NULL; \ > + \ > + ops->func; \ > +}) > + > /* MTR capabilities get */ > int > rte_mtr_capabilities_get(uint16_t port_id, > @@ -69,26 +82,25 @@ rte_mtr_capabilities_get(uint16_t port_id, > } >=20 > /* MTR meter profile add */ > -int > +struct rte_mtr_profile * > rte_mtr_meter_profile_add(uint16_t port_id, > - uint32_t meter_profile_id, > struct rte_mtr_meter_profile *profile, > struct rte_mtr_error *error) > { > struct rte_eth_dev *dev =3D &rte_eth_devices[port_id]; > - return RTE_MTR_FUNC(port_id, meter_profile_add)(dev, > - meter_profile_id, profile, error); > + return RTE_MTR_FUNC_PTR(port_id, meter_profile_add)(dev, > + profile, error); > } >=20 > /** MTR meter profile delete */ > int > rte_mtr_meter_profile_delete(uint16_t port_id, > - uint32_t meter_profile_id, > + struct rte_mtr_profile *profile, > struct rte_mtr_error *error) > { > struct rte_eth_dev *dev =3D &rte_eth_devices[port_id]; > return RTE_MTR_FUNC(port_id, meter_profile_delete)(dev, > - meter_profile_id, error); > + profile, error); > } >=20 > /* MTR meter policy validate */ > @@ -103,126 +115,123 @@ rte_mtr_meter_policy_validate(uint16_t port_id, > } >=20 > /* MTR meter policy add */ > -int > +struct rte_mtr_policy * > rte_mtr_meter_policy_add(uint16_t port_id, > - uint32_t policy_id, > const struct rte_flow_action *actions[RTE_COLORS], > struct rte_mtr_error *error) > { > struct rte_eth_dev *dev =3D &rte_eth_devices[port_id]; > - return RTE_MTR_FUNC(port_id, meter_policy_add)(dev, > - policy_id, actions, error); > + return RTE_MTR_FUNC_PTR(port_id, meter_policy_add)(dev, > + actions, error); > } >=20 > /** MTR meter policy delete */ > int > rte_mtr_meter_policy_delete(uint16_t port_id, > - uint32_t policy_id, > + struct rte_mtr_policy *policy, > struct rte_mtr_error *error) > { > struct rte_eth_dev *dev =3D &rte_eth_devices[port_id]; > return RTE_MTR_FUNC(port_id, meter_policy_delete)(dev, > - policy_id, error); > + policy, error); > } >=20 > /** MTR object create */ > -int > +struct rte_mtr * > rte_mtr_create(uint16_t port_id, > - uint32_t mtr_id, > struct rte_mtr_params *params, > int shared, > struct rte_mtr_error *error) > { > struct rte_eth_dev *dev =3D &rte_eth_devices[port_id]; > - return RTE_MTR_FUNC(port_id, create)(dev, > - mtr_id, params, shared, error); > + return RTE_MTR_FUNC_PTR(port_id, create)(dev, params, shared, > error); > } >=20 > /** MTR object destroy */ > int > rte_mtr_destroy(uint16_t port_id, > - uint32_t mtr_id, > + struct rte_mtr *mtr, > struct rte_mtr_error *error) > { > struct rte_eth_dev *dev =3D &rte_eth_devices[port_id]; > return RTE_MTR_FUNC(port_id, destroy)(dev, > - mtr_id, error); > + mtr, error); > } >=20 > /** MTR object meter enable */ > int > rte_mtr_meter_enable(uint16_t port_id, > - uint32_t mtr_id, > + struct rte_mtr *mtr, > struct rte_mtr_error *error) > { > struct rte_eth_dev *dev =3D &rte_eth_devices[port_id]; > return RTE_MTR_FUNC(port_id, meter_enable)(dev, > - mtr_id, error); > + mtr, error); > } >=20 > /** MTR object meter disable */ > int > rte_mtr_meter_disable(uint16_t port_id, > - uint32_t mtr_id, > + struct rte_mtr *mtr, > struct rte_mtr_error *error) > { > struct rte_eth_dev *dev =3D &rte_eth_devices[port_id]; > return RTE_MTR_FUNC(port_id, meter_disable)(dev, > - mtr_id, error); > + mtr, error); > } >=20 > /** MTR object meter profile update */ > int > rte_mtr_meter_profile_update(uint16_t port_id, > - uint32_t mtr_id, > - uint32_t meter_profile_id, > + struct rte_mtr *mtr, > + struct rte_mtr_profile *profile, > struct rte_mtr_error *error) > { > struct rte_eth_dev *dev =3D &rte_eth_devices[port_id]; > return RTE_MTR_FUNC(port_id, meter_profile_update)(dev, > - mtr_id, meter_profile_id, error); > + mtr, profile, error); > } >=20 > /** MTR object meter policy update */ > int > rte_mtr_meter_policy_update(uint16_t port_id, > - uint32_t mtr_id, > - uint32_t meter_policy_id, > + struct rte_mtr *mtr, > + struct rte_mtr_policy *policy, > struct rte_mtr_error *error) > { > struct rte_eth_dev *dev =3D &rte_eth_devices[port_id]; > return RTE_MTR_FUNC(port_id, meter_policy_update)(dev, > - mtr_id, meter_policy_id, error); > + mtr, policy, error); > } >=20 > /** MTR object meter DSCP table update */ > int > rte_mtr_meter_dscp_table_update(uint16_t port_id, > - uint32_t mtr_id, > + struct rte_mtr *mtr, > enum rte_color *dscp_table, > struct rte_mtr_error *error) > { > struct rte_eth_dev *dev =3D &rte_eth_devices[port_id]; > return RTE_MTR_FUNC(port_id, meter_dscp_table_update)(dev, > - mtr_id, dscp_table, error); > + mtr, dscp_table, error); > } >=20 > /** MTR object enabled stats update */ > int > rte_mtr_stats_update(uint16_t port_id, > - uint32_t mtr_id, > + struct rte_mtr *mtr, > uint64_t stats_mask, > struct rte_mtr_error *error) > { > struct rte_eth_dev *dev =3D &rte_eth_devices[port_id]; > return RTE_MTR_FUNC(port_id, stats_update)(dev, > - mtr_id, stats_mask, error); > + mtr, stats_mask, error); > } >=20 > /** MTR object stats read */ > int > rte_mtr_stats_read(uint16_t port_id, > - uint32_t mtr_id, > + struct rte_mtr *mtr, > struct rte_mtr_stats *stats, > uint64_t *stats_mask, > int clear, > @@ -230,5 +239,5 @@ rte_mtr_stats_read(uint16_t port_id, > { > struct rte_eth_dev *dev =3D &rte_eth_devices[port_id]; > return RTE_MTR_FUNC(port_id, stats_read)(dev, > - mtr_id, stats, stats_mask, clear, error); > + mtr, stats, stats_mask, clear, error); > } > diff --git a/lib/librte_ethdev/rte_mtr.h b/lib/librte_ethdev/rte_mtr.h > index 07961f2777..2b20e55079 100644 > --- a/lib/librte_ethdev/rte_mtr.h > +++ b/lib/librte_ethdev/rte_mtr.h > @@ -181,8 +181,8 @@ struct rte_mtr_meter_profile { > * @see enum rte_mtr_stats_type > */ > struct rte_mtr_params { > - /** Meter profile ID. */ > - uint32_t meter_profile_id; > + /** Meter profile. */ > + struct rte_mtr_profile *profile; >=20 > /** Meter input color in case of MTR object chaining. When non- > zero: if > * a previous MTR object is enabled in the same flow, then the color > @@ -221,8 +221,8 @@ struct rte_mtr_params { > */ > uint64_t stats_mask; >=20 > - /** Meter policy ID. */ > - uint32_t meter_policy_id; > + /** Meter policy. */ > + struct rte_mtr_policy *policy; > }; >=20 > /** > @@ -395,28 +395,32 @@ rte_mtr_capabilities_get(uint16_t port_id, > struct rte_mtr_capabilities *cap, > struct rte_mtr_error *error); >=20 > +/** > + * Opaque type returned after successfully creating a profile. > + * > + * This handle can be used to manage the related profile (e.g. to destro= y it). > + */ > +struct rte_mtr_profile; > + > /** > * Meter profile add > * > - * Create a new meter profile with ID set to *meter_profile_id*. The new > profile > + * Create a new meter profile. The new profile > * is used to create one or several MTR objects. > * > * @param[in] port_id > * The port identifier of the Ethernet device. > - * @param[in] meter_profile_id > - * ID for the new meter profile. Needs to be unused by any of the exis= ting > - * meter profiles added for the current port. > * @param[in] profile > * Meter profile parameters. Needs to be pre-allocated and valid. > * @param[out] error > * Error details. Filled in only on error, when not NULL. > * @return > - * 0 on success, non-zero error code otherwise. > + * A valid handle in case of success, NULL otherwise and rte_errno is = set > + * to the positive version of one of the error codes. > */ > __rte_experimental > -int > +struct rte_mtr_profile * > rte_mtr_meter_profile_add(uint16_t port_id, > - uint32_t meter_profile_id, > struct rte_mtr_meter_profile *profile, > struct rte_mtr_error *error); >=20 > @@ -428,8 +432,8 @@ rte_mtr_meter_profile_add(uint16_t port_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[in] profile > + * Meter profile pointer. Needs to be the valid. > * @param[out] error > * Error details. Filled in only on error, when not NULL. > * @return > @@ -438,16 +442,15 @@ rte_mtr_meter_profile_add(uint16_t port_id, > __rte_experimental > int > rte_mtr_meter_profile_delete(uint16_t port_id, > - uint32_t meter_profile_id, > + struct rte_mtr_profile *profile, > struct rte_mtr_error *error); >=20 > /** > - * Policy id 0 is default policy. > - * Action per color as below: > - * green - no action, yellow - no action, red - drop > - * It can be used without creating it by the rte_mtr_meter_policy_add > function. > + * Opaque type returned after successfully creating a policy. > + * > + * This handle can be used to manage the related policy (e.g. to destroy= it). > */ > -#define RTE_MTR_DEFAULT_POLICY_ID 0 > +struct rte_mtr_policy; >=20 > /** > * Check whether a meter policy can be created on a given port. > @@ -478,7 +481,6 @@ rte_mtr_meter_profile_delete(uint16_t port_id, > __rte_experimental > int > rte_mtr_meter_policy_validate(uint16_t port_id, > - uint32_t policy_id, > const struct rte_flow_action *actions[RTE_COLORS], > struct rte_mtr_error *error); >=20 > @@ -490,8 +492,6 @@ rte_mtr_meter_policy_validate(uint16_t port_id, > * > * @param[in] port_id > * The port identifier of the Ethernet device. > - * @param[in] policy_id > - * Policy identifier for the new meter policy. > * @param[in] actions > * Associated actions per color. > * list NULL is legal and means no special action. > @@ -499,12 +499,12 @@ rte_mtr_meter_policy_validate(uint16_t port_id, > * @param[out] error > * Error details. Filled in only on error, when not NULL. > * @return > - * 0 on success, non-zero error code otherwise. > + * A valid handle in case of success, NULL otherwise and rte_errno is = set > + * to the positive version of one of the error codes. > */ > __rte_experimental > -int > +struct rte_mtr_policy * > rte_mtr_meter_policy_add(uint16_t port_id, > - uint32_t policy_id, > const struct rte_flow_action *actions[RTE_COLORS], > struct rte_mtr_error *error); >=20 > @@ -516,8 +516,8 @@ rte_mtr_meter_policy_add(uint16_t port_id, > * > * @param[in] port_id > * The port identifier of the Ethernet device. > - * @param[in] policy_id > - * Policy identifier. > + * @param[in] policy > + * Policy pointer. Needs to be valid. > * @param[out] error > * Error details. Filled in only on error, when not NULL. > * @return > @@ -526,20 +526,28 @@ rte_mtr_meter_policy_add(uint16_t port_id, > __rte_experimental > int > rte_mtr_meter_policy_delete(uint16_t port_id, > - uint32_t policy_id, > + struct rte_mtr_policy *policy, > struct rte_mtr_error *error); >=20 > +/** > + * Opaque type returned after successfully creating a meter. > + * > + * This handle can be used to manage the related meter (e.g. to destroy = it). > + */ > +struct rte_mtr; > + > /** > * MTR object create > * > * Create a new MTR object for the current port. This object is run as p= art of > * associated flow action for traffic metering and policing. > + * Policy pointer NULL is default policy. > + * Action per color as below: > + * green - no action, yellow - no action, red - drop > + * It can be used without creating it by the rte_mtr_meter_policy_add > function. > * > * @param[in] port_id > * The port identifier of the Ethernet device. > - * @param[in] mtr_id > - * MTR object ID. Needs to be unused by any of the existing MTR object= s. > - * created for the current port. > * @param[in] params > * MTR object params. Needs to be pre-allocated and valid. > * @param[in] shared > @@ -548,14 +556,14 @@ rte_mtr_meter_policy_delete(uint16_t port_id, > * @param[out] error > * Error details. Filled in only on error, when not NULL. > * @return > - * 0 on success, non-zero error code otherwise. > + * A valid handle in case of success, NULL otherwise and rte_errno is = set > + * to the positive version of one of the error codes. > * > * @see enum rte_flow_action_type::RTE_FLOW_ACTION_TYPE_METER > */ > __rte_experimental > -int > +struct rte_mtr * > rte_mtr_create(uint16_t port_id, > - uint32_t mtr_id, > struct rte_mtr_params *params, > int shared, > struct rte_mtr_error *error); > @@ -568,8 +576,8 @@ rte_mtr_create(uint16_t port_id, > * > * @param[in] port_id > * The port identifier of the Ethernet device. > - * @param[in] mtr_id > - * MTR object ID. Needs to be valid. > + * @param[in] mtr > + * MTR pointer. Needs to be valid. > * created for the current port. > * @param[out] error > * Error details. Filled in only on error, when not NULL. > @@ -579,7 +587,7 @@ rte_mtr_create(uint16_t port_id, > __rte_experimental > int > rte_mtr_destroy(uint16_t port_id, > - uint32_t mtr_id, > + struct rte_mtr *mtr, > struct rte_mtr_error *error); >=20 > /** > @@ -607,7 +615,7 @@ rte_mtr_destroy(uint16_t port_id, > __rte_experimental > int > rte_mtr_meter_disable(uint16_t port_id, > - uint32_t mtr_id, > + struct rte_mtr *mtr, > struct rte_mtr_error *error); >=20 > /** > @@ -629,7 +637,7 @@ rte_mtr_meter_disable(uint16_t port_id, > __rte_experimental > int > rte_mtr_meter_enable(uint16_t port_id, > - uint32_t mtr_id, > + struct rte_mtr *mtr, > struct rte_mtr_error *error); >=20 > /** > @@ -649,8 +657,8 @@ rte_mtr_meter_enable(uint16_t port_id, > __rte_experimental > int > rte_mtr_meter_profile_update(uint16_t port_id, > - uint32_t mtr_id, > - uint32_t meter_profile_id, > + struct rte_mtr *mtr, > + struct rte_mtr_profile *profile, > struct rte_mtr_error *error); >=20 > /** > @@ -660,8 +668,6 @@ rte_mtr_meter_profile_update(uint16_t port_id, > * The port identifier of the Ethernet device. > * @param[in] mtr_id > * MTR object ID. Needs to be valid. > - * @param[in] meter_policy_id > - * Meter policy ID for the current MTR object. Needs to be valid. > * @param[out] error > * Error details. Filled in only on error, when not NULL. > * @return > @@ -670,8 +676,8 @@ rte_mtr_meter_profile_update(uint16_t port_id, > __rte_experimental > int > rte_mtr_meter_policy_update(uint16_t port_id, > - uint32_t mtr_id, > - uint32_t meter_policy_id, > + struct rte_mtr *mtr, > + struct rte_mtr_policy *policy, > struct rte_mtr_error *error); >=20 > /** > @@ -695,7 +701,7 @@ rte_mtr_meter_policy_update(uint16_t port_id, > __rte_experimental > int > rte_mtr_meter_dscp_table_update(uint16_t port_id, > - uint32_t mtr_id, > + struct rte_mtr *mtr, > enum rte_color *dscp_table, > struct rte_mtr_error *error); >=20 > @@ -720,7 +726,7 @@ rte_mtr_meter_dscp_table_update(uint16_t port_id, > __rte_experimental > int > rte_mtr_stats_update(uint16_t port_id, > - uint32_t mtr_id, > + struct rte_mtr *mtr, > uint64_t stats_mask, > struct rte_mtr_error *error); >=20 > @@ -752,7 +758,7 @@ rte_mtr_stats_update(uint16_t port_id, > __rte_experimental > int > rte_mtr_stats_read(uint16_t port_id, > - uint32_t mtr_id, > + struct rte_mtr *mtr, > struct rte_mtr_stats *stats, > uint64_t *stats_mask, > int clear, > diff --git a/lib/librte_ethdev/rte_mtr_driver.h > b/lib/librte_ethdev/rte_mtr_driver.h > index 1ad8fb4c40..d7a8853b51 100644 > --- a/lib/librte_ethdev/rte_mtr_driver.h > +++ b/lib/librte_ethdev/rte_mtr_driver.h > @@ -30,82 +30,80 @@ typedef int (*rte_mtr_capabilities_get_t)(struct > rte_eth_dev *dev, > struct rte_mtr_error *error); > /**< @internal MTR capabilities get */ >=20 > -typedef int (*rte_mtr_meter_profile_add_t)(struct rte_eth_dev *dev, > - uint32_t meter_profile_id, > +typedef struct rte_mtr_profile *(*rte_mtr_meter_profile_add_t) > + (struct rte_eth_dev *dev, > struct rte_mtr_meter_profile *profile, > struct rte_mtr_error *error); > /**< @internal MTR meter profile add */ >=20 > typedef int (*rte_mtr_meter_profile_delete_t)(struct rte_eth_dev *dev, > - uint32_t meter_profile_id, > + struct rte_mtr_profile *profile, > struct rte_mtr_error *error); > /**< @internal MTR meter profile delete */ >=20 > typedef int (*rte_mtr_meter_policy_validate_t)(struct rte_eth_dev *dev, > - uint32_t policy_id, > const struct rte_flow_action *actions[RTE_COLORS], > struct rte_mtr_error *error); > /**< @internal MTR meter policy validate */ >=20 > -typedef int (*rte_mtr_meter_policy_add_t)(struct rte_eth_dev *dev, > - uint32_t policy_id, > +typedef struct rte_mtr_policy *(*rte_mtr_meter_policy_add_t) > + (struct rte_eth_dev *dev, > const struct rte_flow_action *actions[RTE_COLORS], > struct rte_mtr_error *error); > /**< @internal MTR meter policy add */ >=20 > typedef int (*rte_mtr_meter_policy_delete_t)(struct rte_eth_dev *dev, > - uint32_t policy_id, > + struct rte_mtr_policy *policy, > struct rte_mtr_error *error); > /**< @internal MTR meter policy delete */ >=20 > -typedef int (*rte_mtr_create_t)(struct rte_eth_dev *dev, > - uint32_t mtr_id, > +typedef struct rte_mtr *(*rte_mtr_create_t)(struct rte_eth_dev *dev, > struct rte_mtr_params *params, > int shared, > struct rte_mtr_error *error); > /**< @internal MTR object create */ >=20 > typedef int (*rte_mtr_destroy_t)(struct rte_eth_dev *dev, > - uint32_t mtr_id, > + struct rte_mtr *mtr, > struct rte_mtr_error *error); > /**< @internal MTR object destroy */ >=20 > typedef int (*rte_mtr_meter_enable_t)(struct rte_eth_dev *dev, > - uint32_t mtr_id, > + struct rte_mtr *mtr, > struct rte_mtr_error *error); > /**< @internal MTR object meter enable */ >=20 > typedef int (*rte_mtr_meter_disable_t)(struct rte_eth_dev *dev, > - uint32_t mtr_id, > + struct rte_mtr *mtr, > struct rte_mtr_error *error); > /**< @internal MTR object meter disable */ >=20 > typedef int (*rte_mtr_meter_profile_update_t)(struct rte_eth_dev *dev, > - uint32_t mtr_id, > - uint32_t meter_profile_id, > + struct rte_mtr *mtr, > + struct rte_mtr_profile *profile, > struct rte_mtr_error *error); > /**< @internal MTR object meter profile update */ >=20 > typedef int (*rte_mtr_meter_policy_update_t)(struct rte_eth_dev *dev, > - uint32_t mtr_id, > - uint32_t meter_policy_id, > + struct rte_mtr *mtr, > + struct rte_mtr_policy *policy, > struct rte_mtr_error *error); > /**< @internal MTR object meter policy update */ >=20 > typedef int (*rte_mtr_meter_dscp_table_update_t)(struct rte_eth_dev > *dev, > - uint32_t mtr_id, > + struct rte_mtr *mtr, > enum rte_color *dscp_table, > struct rte_mtr_error *error); > /**< @internal MTR object meter DSCP table update */ >=20 > typedef int (*rte_mtr_stats_update_t)(struct rte_eth_dev *dev, > - uint32_t mtr_id, > + struct rte_mtr *mtr, > uint64_t stats_mask, > struct rte_mtr_error *error); > /**< @internal MTR object enabled stats update */ >=20 > typedef int (*rte_mtr_stats_read_t)(struct rte_eth_dev *dev, > - uint32_t mtr_id, > + struct rte_mtr *mtr, > struct rte_mtr_stats *stats, > uint64_t *stats_mask, > int clear, > -- > 2.21.0 Regards, Cristian