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 13260A0093; Fri, 7 Oct 2022 03:58:58 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 9A592400D6; Fri, 7 Oct 2022 03:58:57 +0200 (CEST) Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by mails.dpdk.org (Postfix) with ESMTP id D30B040042 for ; Fri, 7 Oct 2022 03:58:55 +0200 (CEST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 296JucbQ006886; Thu, 6 Oct 2022 18:56:43 -0700 Received: from nam10-dm6-obe.outbound.protection.outlook.com (mail-dm6nam10lp2100.outbound.protection.outlook.com [104.47.58.100]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3k1v9aug7x-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Thu, 06 Oct 2022 18:56:43 -0700 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iD+jcoLCRyuRBsRfDvhzEyYZLZ4aWZ5dNvnzZljswtSLkzRx3fXOFAZ8d+CBlYajXFumlw58m9QKsvghLo9nD3+DQCEE0LQ41w0F07htkFdSU1YbMpcYL7ruIpHeimSAtAoNatRoM0Y3Ghi8VosFOy+GS33sJwCRTqh8gLhGSzVmgC02gT6wqcm8RkwK1ZzIaJqm2F483g/VwR0Ds/Av1kK0Ntirt6IZMvFcFjGAlaFjG40KtGQq576fBVP7KNe7w9Vy2InKyEP4Oe7JZ9sGn65vt7SSQQ88L/aD/sXJhKaj6CZVgk7fTjytpPVcsdANfz18uT1++ZW/Ie2tFRe8aw== 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=R2Jq02VA/GDnIqZM/juUZaKAGmPk39LEYIc9Ercobdw=; b=irhNHunGS+hAgX6UQ1ZCkTqTQRRAUQeot3MA5iVoZtSBkeBNtcLvhhXW4xkpzDe0q/ltKaJ4vddg+0NlGkbXAlAjNmwg6r1FHOTGi7ZUR01KrfQZDtgFk/N52Nu6Hw7xYwZXWwuBLlbftfs+3JitBp6DEvz1nO6kwW0uz0Jd80+WpyVhw/E6O7Z/M/95p5sce8czEWvfq7zJCJYA2DiGjXYRhPuI0RvxmEbD20HUF/7EjsIqo1hv6ZVnrd0/QXizHIPliUG35meWthRI6vzBMMMmxkGsewx1rTISZ4hP8znic/T6PeZrFNYr2ae8/Ni1YHRepQ3+WyClazmhtQgy+A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=marvell.com; dmarc=pass action=none header.from=marvell.com; dkim=pass header.d=marvell.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.onmicrosoft.com; s=selector1-marvell-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=R2Jq02VA/GDnIqZM/juUZaKAGmPk39LEYIc9Ercobdw=; b=nWXCFWa157ALLr9LmVS97w0MpUK+FeDmbwKg7EBo32fRl1LOnmD7IR//7mIzFaY2nqZgglx0nrimkpqqhJwB5IG6YarQR2m6H3b6U8X1TCmQIe4Rycj4pbMkGkmrS2cSeO6m0FBDL6LljkCDm5vLqIm926hL3fRBFxX2EVIma10= Received: from BY3PR18MB4785.namprd18.prod.outlook.com (2603:10b6:a03:3cc::18) by MW5PR18MB5095.namprd18.prod.outlook.com (2603:10b6:303:1ce::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5676.28; Fri, 7 Oct 2022 01:56:40 +0000 Received: from BY3PR18MB4785.namprd18.prod.outlook.com ([fe80::3fb3:fa85:f101:219b]) by BY3PR18MB4785.namprd18.prod.outlook.com ([fe80::3fb3:fa85:f101:219b%6]) with mapi id 15.20.5676.036; Fri, 7 Oct 2022 01:56:40 +0000 From: Jerin Jacob Kollanukkaran To: Andrew Rybchenko , Ferruh Yigit , Thomas Monjalon , Ray Kinsella CC: "dev@dpdk.org" , Sunil Kumar Kori Subject: Re: [EXT] Re: [PATCH v4] ethdev: support congestion management Thread-Topic: [EXT] Re: [PATCH v4] ethdev: support congestion management Thread-Index: AQHY2V68AtIVdw1iwE6hLlpk95r8/64CLTaR Date: Fri, 7 Oct 2022 01:56:40 +0000 Message-ID: References: <20221004090258.2472727-1-andrew.rybchenko@oktetlabs.ru> <9ed695c4-15c3-0e50-05fb-7235915ae70d@oktetlabs.ru> In-Reply-To: <9ed695c4-15c3-0e50-05fb-7235915ae70d@oktetlabs.ru> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-ms-publictraffictype: Email x-ms-traffictypediagnostic: BY3PR18MB4785:EE_|MW5PR18MB5095:EE_ x-ms-office365-filtering-correlation-id: 1b4e3090-4509-4337-ffc0-08daa8072d4d x-ms-exchange-senderadcheck: 1 x-ms-exchange-antispam-relay: 0 x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: /4qhRs77WUSBV6kUrbE+3OwQAhd/MS7tYaTxmJeldG2/rUikmc+/w+WoYGuvDDYzxifl+qd9s5qeBm6BePAqgyuS3P3MpVXN9Fmw4DVIRITRth3wWnidQY8hiKCr+otTuY7no3AxKwer34KK48FOvoF3fPV6T0YDUKyaSsvTFPLjfASqGpIqxnd5eodk9VwJJYrVqpaYlDGpBOO1c4Q3JuGGCSY4+bpucOOIHRnbtjquTQVWNICCdVVda3/Hmm56YYsxMCnwtHDmgnY+kxdxMmcqfr9Jq5R3eosibvthcS1kGxtqIjVNnDAu+dWoJCxrhUpWl0H5HjNkIoNU9cWGCF/scRF0XYzPRzd5O8H97KUQKt1krxCOoxCm8hHloXBYRqk4Z1m6z/zxX9tA8XYpbqtBkrUL6bUy1e8IrWSVCu5OSHtPutzcVDKps7ug+IWrkmuQbBHTSit2uZnKdqpoTSNW7qPFnPzd8kAszte8W8rahVGElyw3IwWCxkaiqDZxpl3jJ7WKsKmCM27PSi2/9tCveEuFAFFXVeQShxtnl+hQ1uHU7/3494UsA12IC0/HqZwkzXzGHgIQ//DQuIA8D+ZUAbP8fnDHQQAajkL11yCgy5XoyX7oRWARCwZDKI1tnrj9q/YLA+AW+D/PP7dD7AjcJ21uyi97VoaLI3UiPBl0Cw01DkbuaLLR4CC3EMqcqiLsNpYF8UGGt4oMW1FSbxPnHUPKm+7c/wipt/COqO3EIJNsHPLAT4NWAgBcurt3ARfbPXzgyuEzO17XxX5dLBVlgPNRV1+/EbASlPZbLUtnsepWJwHCWjB/VDM91rC2zWZV/sKpQkwIzrjaR0ApCw== x-forefront-antispam-report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:BY3PR18MB4785.namprd18.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230022)(4636009)(396003)(376002)(39860400002)(366004)(346002)(136003)(451199015)(53546011)(8936002)(52536014)(41300700001)(30864003)(76116006)(9686003)(966005)(38070700005)(54906003)(5660300002)(6506007)(66946007)(2906002)(66476007)(110136005)(26005)(478600001)(64756008)(66556008)(7696005)(316002)(4326008)(91956017)(66446008)(8676002)(33656002)(71200400001)(186003)(83380400001)(107886003)(55016003)(122000001)(166002)(86362001)(38100700002); DIR:OUT; SFP:1101; x-ms-exchange-antispam-messagedata-chunkcount: 1 x-ms-exchange-antispam-messagedata-0: =?iso-8859-1?Q?e30sOQJyLnqOTik/s24EHaQAJKC4yUy3goGjJuBoH78eBMmjS8UOL41IR1?= =?iso-8859-1?Q?dEGoBGSncCySEz0ExrC+Yv01uwwnjYqpe5VXzu0wmR3vZIFvo90GqEVFzo?= =?iso-8859-1?Q?/DT5C4VuZVPq5SAEppP3uMsVUnssaFLba6TN1GLHOtJedPRGgmJ3MFwfb9?= =?iso-8859-1?Q?2MYn28GphxMKvfAbuEf6IuwK54ewEcjArGrMsqKAAieHSD9gM1MAFRvFG6?= =?iso-8859-1?Q?XczKtCOa6mUt+kzxpBT5NvxYgamW5Ilq6UQUmIIeeArDawDpFBoBq/Hf9w?= =?iso-8859-1?Q?sueSTt5ip1S5SwnmbQ5bdO/TpfwSspPajMnt+xFz4iTstbJeCARM18FOXn?= =?iso-8859-1?Q?gJQq4dpby0sWi7O6ahDm9bXte5EAN5dH9CgOkmZx6zpL9ek9ezPWWlmhhO?= =?iso-8859-1?Q?NJ2B4fQ3yl5hiRM+OXIaTpn+l7oF+gDAfDDCtBJ7YXQ0AfrbpHDB/tdyMb?= =?iso-8859-1?Q?k25PFHzD31LYjId4LkaLj4LI0OqMVKGu1DNNX7rzWZG75bnyUWS4VbayJh?= =?iso-8859-1?Q?kodFZafBmj3cLa35RYsRFnRrdW4jxr1GMsnQT3Ny+OIoNzG0Y42svEKrB6?= =?iso-8859-1?Q?eIaNH+MHmWgVp6Kv3bozaStUi5+izvL+dlBmdCTOXLjIWnR6MTXjxiNs+E?= =?iso-8859-1?Q?hTMxdepCCmJouBg8LCWNWxhhawC7GwChYDDPVLSY2VqaQFKvCj5l76Ws9Q?= =?iso-8859-1?Q?iyHwNiIEk2RPLZJH0Cl65eBPJl6IMsFMoXZTcpEWqi+Fs5I+zP5E2nSRHU?= =?iso-8859-1?Q?SdfH9MK/Z38O1Ng2/4413K0Ieuumf539vz86C+SKPJ9XXVPThXfgiXTB6n?= =?iso-8859-1?Q?v2h3w65ZFMzsRDIK2IA0WNlDyVZzAOugO1LoLxkCTXeXZX8MqVgwQmOlLi?= =?iso-8859-1?Q?52sdz+azR7AjnNA+comHhMU+j3mf/O9FwEv68b7eKSPdo3iPSCfzyAjXHq?= =?iso-8859-1?Q?T7NikFvROF3k2Hso+VXk+wKOpl7BAun6jFnJNRyMIXT3PtkAU7EkrFrXPx?= =?iso-8859-1?Q?KMF9U/m553GQOZ37RrtC7iQPHKTNkosc+kyBukabRE8rtXwG8b3QxXQYZX?= =?iso-8859-1?Q?BpYvYTXa6bkW32/MBk+O6GABd4kDYxSehdQve0HWJJF4tQfrqL77A2S6mD?= =?iso-8859-1?Q?kzucXbUA7kCTWvNafeF6l0/sdgVSSdmRrYNBnaa9KrEVeLYzaFR+siQ2sW?= =?iso-8859-1?Q?sP1fC847xI9BLit8cQIBOzl2ZypmUq1XWPSDiUCt7+q8Gllu7r1HEEQaz8?= =?iso-8859-1?Q?kEt3/ZqoMmfYd5iDcAt48897sROryW2TdPV6Yvqr86z8Nun1m7D8xwQwok?= =?iso-8859-1?Q?XFR5K9liqL8b7fFjLVGf3UM/TBmbG7cnPe1Bs4ZwygV1A0HYd1g9yfKcDf?= =?iso-8859-1?Q?YHPT9J7UJeRYtbPyQ8b2b/hJIQ8W+LZYbox14IV1sd7sqiXn07HTtC6wo7?= =?iso-8859-1?Q?LHp5no0YpNwFy678P+qwRkol4ppG5IGXB7dPLXxTmrTufKwVNyW7lPUn1h?= =?iso-8859-1?Q?WXIii0oiaiEa7plWBQxtlPtVKBtSJVDGL9s1tuL/fRfJkitS2gAuUFrSvZ?= =?iso-8859-1?Q?+/4w9x4XtMpe5Gn46m1YikGmY/9xl8Dq4WG/mC1jFuBYlj1BGma9uZdzt/?= =?iso-8859-1?Q?Y4qKfuKqb2yKytJsJ8ElVVeObFDGm1+p2c?= Content-Type: multipart/alternative; boundary="_000_BY3PR18MB47853E2E0A6D582E5DFDB60CC85F9BY3PR18MB4785namp_" MIME-Version: 1.0 X-OriginatorOrg: marvell.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-AuthSource: BY3PR18MB4785.namprd18.prod.outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1b4e3090-4509-4337-ffc0-08daa8072d4d X-MS-Exchange-CrossTenant-originalarrivaltime: 07 Oct 2022 01:56:40.4202 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 70e1fb47-1155-421d-87fc-2e58f638b6e0 X-MS-Exchange-CrossTenant-mailboxtype: HOSTED X-MS-Exchange-CrossTenant-userprincipalname: aDtUsU9vHGok9PrDdtwngfNahRBPWG3u/6qqyLjhGwLxmKHA6Jt4zYx1+ydOEFsR2yElQvPZHHK0ad/6xT6C8w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW5PR18MB5095 X-Proofpoint-GUID: zroUycWGmfR1IjDGTyLgIhYLAx9jlRoG X-Proofpoint-ORIG-GUID: zroUycWGmfR1IjDGTyLgIhYLAx9jlRoG X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.895,Hydra:6.0.528,FMLib:17.11.122.1 definitions=2022-10-06_05,2022-10-06_02,2022-06-22_01 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 --_000_BY3PR18MB47853E2E0A6D582E5DFDB60CC85F9BY3PR18MB4785namp_ Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable Thanks Andrew. Changes are fine with me ________________________________ From: Andrew Rybchenko Sent: Thursday, October 6, 2022 2:06 PM To: Ferruh Yigit ; Thomas Monjalon ; Ray Kinsella Cc: dev@dpdk.org ; Jerin Jacob Kollanukkaran ; Sunil Kumar Kori Subject: [EXT] Re: [PATCH v4] ethdev: support congestion management External Email ---------------------------------------------------------------------- @Jerin, could you confirm if my minor changes are OK for you and, if so, I'll proceed with applying the patch. On 10/4/22 12:02, Andrew Rybchenko wrote: > From: Jerin Jacob > > NIC HW controllers often come with congestion management support on > various HW objects such as Rx queue depth or mempool queue depth. > > Also, it can support various modes of operation such as RED > (Random early discard), WRED etc on those HW objects. > > Add a framework to express such modes(enum rte_cman_mode) and > introduce (enum rte_eth_cman_obj) to enumerate the different > objects where the modes can operate on. > > Add RTE_CMAN_RED mode of operation and RTE_ETH_CMAN_OBJ_RX_QUEUE, > RTE_ETH_CMAN_OBJ_RX_QUEUE_MEMPOOL objects. > > Introduce reserved fields in configuration structure > backed by rte_eth_cman_config_init() to add new configuration > parameters without ABI breakage. > > Add rte_eth_cman_info_get() API to get the information such as > supported modes and objects. > > Add rte_eth_cman_config_init(), rte_eth_cman_config_set() APIs > to configure congestion management on those object with associated mode. > > Finally, add rte_eth_cman_config_get() API to retrieve the > applied configuration. > > Signed-off-by: Jerin Jacob > Signed-off-by: Sunil Kumar Kori > Signed-off-by: Andrew Rybchenko > --- > v3..v4: Andrew Rybchenko > - rebase > - remove eth_check_err() and use eth_err() instead > - minor fixes in description to avoid "This patch" and "Added". > - correct position in release notes > v2..v3: > - Rename rte_cman.c to rte_ethdev_cman.c > - Move lib/eal/include/rte_cman.h to lib/ethdev/rte_cman.h > - Fix review comments (Andrew Rybchenko) > - Add release notes > > v1..v2: > - Fix review comments (Akhil Goyal) > > rfc..v1: > - Added RED specification (https://urldefense.proofpoint.com/v2/url?u= =3Dhttp-3A__www.aciri.org_floyd_papers_red_red.html&d=3DDwICaQ&c=3DnKjWec2b= 6R0mOyPaz7xtfQ&r=3D1DGob4H4rxz6H8uITozGOCa0s5f4wCNtTa4UUKvcsvI&m=3DkISGqWlR= wNHLBHvKCTkVQBoHyBW79qMFQEJNcoDZXb8X4GKLwHVeeE_D3Lh082fx&s=3DHZKFgpOQ0CtqvK= -_Zc-QZn87gBY4UrscDXgFihsXjvQ&e=3D ) link > - Fixed doxygen comment issue (Min Hu) > > doc/guides/nics/features.rst | 12 ++ > doc/guides/nics/features/default.ini | 1 + > doc/guides/rel_notes/release_22_11.rst | 6 + > lib/ethdev/ethdev_driver.h | 25 ++++ > lib/ethdev/ethdev_private.h | 3 + > lib/ethdev/meson.build | 2 + > lib/ethdev/rte_cman.h | 55 +++++++++ > lib/ethdev/rte_ethdev.c | 2 +- > lib/ethdev/rte_ethdev.h | 164 +++++++++++++++++++++++++ > lib/ethdev/rte_ethdev_cman.c | 101 +++++++++++++++ > lib/ethdev/version.map | 4 + > 11 files changed, 374 insertions(+), 1 deletion(-) > create mode 100644 lib/ethdev/rte_cman.h > create mode 100644 lib/ethdev/rte_ethdev_cman.c > > diff --git a/doc/guides/nics/features.rst b/doc/guides/nics/features.rst > index b4a8e9881c..70ca46e651 100644 > --- a/doc/guides/nics/features.rst > +++ b/doc/guides/nics/features.rst > @@ -727,6 +727,18 @@ Supports configuring per-queue stat counter mapping. > ``rte_eth_dev_set_tx_queue_stats_mapping()``. > > > +.. _nic_features_congestion_management: > + > +Congestion management > +--------------------- > + > +Supports congestion management. > + > +* **[implements] eth_dev_ops**: ``cman_info_get``, ``cman_config_set``, = ``cman_config_get``. > +* **[related] API**: ``rte_eth_cman_info_get()``, ``rte_eth_cman_conf= ig_init()``, > + ``rte_eth_cman_config_set()``, ``rte_eth_cman_config_get()``. > + > + > .. _nic_features_fw_version: > > FW version > diff --git a/doc/guides/nics/features/default.ini b/doc/guides/nics/featu= res/default.ini > index f7192cb0da..a9c0008ebd 100644 > --- a/doc/guides/nics/features/default.ini > +++ b/doc/guides/nics/features/default.ini > @@ -60,6 +60,7 @@ Tx descriptor status =3D > Basic stats =3D > Extended stats =3D > Stats per queue =3D > +Congestion management =3D > FW version =3D > EEPROM dump =3D > Module EEPROM dump =3D > diff --git a/doc/guides/rel_notes/release_22_11.rst b/doc/guides/rel_note= s/release_22_11.rst > index 44f9a30c6a..0ffa004a9e 100644 > --- a/doc/guides/rel_notes/release_22_11.rst > +++ b/doc/guides/rel_notes/release_22_11.rst > @@ -78,6 +78,12 @@ New Features > Added new rte_flow action which allows application to re-route packet= s > directly to the kernel without software involvement. > > +* **Added support for congestion management for ethdev.** > + > + Added new APIs ``rte_eth_cman_config_init()``, ``rte_eth_cman_config_g= et()``, > + ``rte_eth_cman_config_set()``, ``rte_eth_cman_info_get()`` > + to support congestion management. > + > * **Updated Intel iavf driver.** > > * Added flow subscription support. > diff --git a/lib/ethdev/ethdev_driver.h b/lib/ethdev/ethdev_driver.h > index 8cd8eb8685..e1e2d10a35 100644 > --- a/lib/ethdev/ethdev_driver.h > +++ b/lib/ethdev/ethdev_driver.h > @@ -1094,6 +1094,22 @@ typedef int (*eth_rx_queue_avail_thresh_query_t)(s= truct rte_eth_dev *dev, > uint16_t *rx_queue_id, > uint8_t *avail_thresh); > > +/** @internal Get congestion management information. */ > +typedef int (*eth_cman_info_get_t)(struct rte_eth_dev *dev, > + struct rte_eth_cman_info *info); > + > +/** @internal Init congestion management structure with default values. = */ > +typedef int (*eth_cman_config_init_t)(struct rte_eth_dev *dev, > + struct rte_eth_cman_config *config); > + > +/** @internal Configure congestion management on a port. */ > +typedef int (*eth_cman_config_set_t)(struct rte_eth_dev *dev, > + const struct rte_eth_cman_config *config); > + > +/** @internal Retrieve congestion management configuration of a port. */ > +typedef int (*eth_cman_config_get_t)(struct rte_eth_dev *dev, > + struct rte_eth_cman_config *config); > + > /** > * @internal A structure containing the functions exported by an Ethern= et driver. > */ > @@ -1309,6 +1325,15 @@ struct eth_dev_ops { > eth_rx_queue_avail_thresh_set_t rx_queue_avail_thresh_set; > /** Query Rx queue available descriptors threshold event */ > eth_rx_queue_avail_thresh_query_t rx_queue_avail_thresh_query; > + > + /** Get congestion management information */ > + eth_cman_info_get_t cman_info_get; > + /** Initialize congestion management structure with default values = */ > + eth_cman_config_init_t cman_config_init; > + /** Configure congestion management */ > + eth_cman_config_set_t cman_config_set; > + /** Retrieve congestion management configuration */ > + eth_cman_config_get_t cman_config_get; > }; > > /** > diff --git a/lib/ethdev/ethdev_private.h b/lib/ethdev/ethdev_private.h > index cc9879907c..acb4b335c8 100644 > --- a/lib/ethdev/ethdev_private.h > +++ b/lib/ethdev/ethdev_private.h > @@ -37,6 +37,9 @@ struct rte_eth_dev_callback { > > extern rte_spinlock_t eth_dev_cb_lock; > > +/* Convert all error to -EIO if device is removed. */ > +int eth_err(uint16_t port_id, int ret); > + > /* > * Convert rte_eth_dev pointer to port ID. > * NULL will be translated to RTE_MAX_ETHPORTS. > diff --git a/lib/ethdev/meson.build b/lib/ethdev/meson.build > index 47bb2625b0..39250b5da1 100644 > --- a/lib/ethdev/meson.build > +++ b/lib/ethdev/meson.build > @@ -8,6 +8,7 @@ sources =3D files( > 'ethdev_trace_points.c', > 'rte_class_eth.c', > 'rte_ethdev.c', > + 'rte_ethdev_cman.c', > 'rte_flow.c', > 'rte_mtr.c', > 'rte_tm.c', > @@ -19,6 +20,7 @@ sources =3D files( > ) > > headers =3D files( > + 'rte_cman.h', > 'rte_ethdev.h', > 'rte_ethdev_trace.h', > 'rte_ethdev_trace_fp.h', > diff --git a/lib/ethdev/rte_cman.h b/lib/ethdev/rte_cman.h > new file mode 100644 > index 0000000000..297db8e095 > --- /dev/null > +++ b/lib/ethdev/rte_cman.h > @@ -0,0 +1,55 @@ > +/* SPDX-License-Identifier: BSD-3-Clause > + * Copyright(C) 2022 Marvell International Ltd. > + */ > + > +#ifndef RTE_CMAN_H > +#define RTE_CMAN_H > + > +#ifdef __cplusplus > +extern "C" { > +#endif > + > +#include > + > +/** > + * @file > + * Congestion management related parameters for DPDK. > + */ > + > +/** Congestion management modes */ > +enum rte_cman_mode { > + /** > + * Congestion based on Random Early Detection. > + * > + * https://urldefense.proofpoint.com/v2/url?u=3Dhttps-3A__en.wikipe= dia.org_wiki_Random-5Fearly-5Fdetection&d=3DDwICaQ&c=3DnKjWec2b6R0mOyPaz7xt= fQ&r=3D1DGob4H4rxz6H8uITozGOCa0s5f4wCNtTa4UUKvcsvI&m=3DkISGqWlRwNHLBHvKCTkV= QBoHyBW79qMFQEJNcoDZXb8X4GKLwHVeeE_D3Lh082fx&s=3DiyRkqzJBjwu2oS-YMRhtxJOpsK= 8JWJG5gEH_1DC5pwM&e=3D > + * https://urldefense.proofpoint.com/v2/url?u=3Dhttp-3A__www.aciri.= org_floyd_papers_red_red.html&d=3DDwICaQ&c=3DnKjWec2b6R0mOyPaz7xtfQ&r=3D1DG= ob4H4rxz6H8uITozGOCa0s5f4wCNtTa4UUKvcsvI&m=3DkISGqWlRwNHLBHvKCTkVQBoHyBW79q= MFQEJNcoDZXb8X4GKLwHVeeE_D3Lh082fx&s=3DHZKFgpOQ0CtqvK-_Zc-QZn87gBY4UrscDXgF= ihsXjvQ&e=3D > + * @see struct rte_cman_red_params > + */ > + RTE_CMAN_RED =3D RTE_BIT32(0), > +}; > + > +/** > + * RED based congestion management configuration parameters. > + */ > +struct rte_cman_red_params { > + /** > + * Minimum threshold (min_th) value > + * > + * Value expressed as percentage. Value must be in 0 to 100(inclusi= ve). > + */ > + uint8_t min_th; > + /** > + * Maximum threshold (max_th) value > + * > + * Value expressed as percentage. Value must be in 0 to 100(inclusi= ve). > + */ > + uint8_t max_th; > + /** Inverse of packet marking probability maximum value (maxp =3D 1= / maxp_inv) */ > + uint16_t maxp_inv; > +}; > + > +#ifdef __cplusplus > +} > +#endif > + > +#endif /* RTE_CMAN_H */ > diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c > index 0c2c1088c0..e4eb17221b 100644 > --- a/lib/ethdev/rte_ethdev.c > +++ b/lib/ethdev/rte_ethdev.c > @@ -642,7 +642,7 @@ rte_eth_dev_get_port_by_name(const char *name, uint16= _t *port_id) > return -ENODEV; > } > > -static int > +int > eth_err(uint16_t port_id, int ret) > { > if (ret =3D=3D 0) > diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h > index a21f58b9cd..8df1cdfad0 100644 > --- a/lib/ethdev/rte_ethdev.h > +++ b/lib/ethdev/rte_ethdev.h > @@ -160,6 +160,7 @@ extern "C" { > #define RTE_ETHDEV_DEBUG_TX > #endif > > +#include > #include > #include > #include > @@ -5314,6 +5315,169 @@ typedef struct { > __rte_experimental > int rte_eth_dev_priv_dump(uint16_t port_id, FILE *file); > > +/* Congestion management */ > + > +/** Enumerate list of ethdev congestion management objects */ > +enum rte_eth_cman_obj { > + /** Congestion management based on Rx queue depth */ > + RTE_ETH_CMAN_OBJ_RX_QUEUE =3D RTE_BIT32(0), > + /** > + * Congestion management based on mempool depth associated with Rx = queue > + * @see rte_eth_rx_queue_setup() > + */ > + RTE_ETH_CMAN_OBJ_RX_QUEUE_MEMPOOL =3D RTE_BIT32(1), > +}; > + > +/** > + * @warning > + * @b EXPERIMENTAL: this structure may change, or be removed, without pr= ior notice > + * > + * A structure used to retrieve information of ethdev congestion managem= ent. > + */ > +struct rte_eth_cman_info { > + /** > + * Set of supported congestion management modes > + * @see enum rte_cman_mode > + */ > + uint64_t modes_supported; > + /** > + * Set of supported congestion management objects > + * @see enum rte_eth_cman_obj > + */ > + uint64_t objs_supported; > + /** > + * Reserved for future fields. Always returned as 0 when > + * rte_eth_cman_info_get() is invoked > + */ > + uint8_t rsvd[8]; > +}; > + > +/** > + * @warning > + * @b EXPERIMENTAL: this structure may change, or be removed, without pr= ior notice > + * > + * A structure used to configure the ethdev congestion management. > + */ > +struct rte_eth_cman_config { > + /** Congestion management object */ > + enum rte_eth_cman_obj obj; > + /** Congestion management mode */ > + enum rte_cman_mode mode; > + union { > + /** > + * Rx queue to configure congestion management. > + * > + * Valid when object is RTE_ETH_CMAN_OBJ_RX_QUEUE or > + * RTE_ETH_CMAN_OBJ_RX_QUEUE_MEMPOOL. > + */ > + uint16_t rx_queue; > + /** > + * Reserved for future fields. > + * It must be set to 0 when rte_eth_cman_config_set() is in= voked > + * and will be returned as 0 when rte_eth_cman_config_get()= is > + * invoked. > + */ > + uint8_t rsvd_obj_params[4]; > + } obj_param; > + union { > + /** > + * RED configuration parameters. > + * > + * Valid when mode is RTE_CMAN_RED. > + */ > + struct rte_cman_red_params red; > + /** > + * Reserved for future fields. > + * It must be set to 0 when rte_eth_cman_config_set() is in= voked > + * and will be returned as 0 when rte_eth_cman_config_get()= is > + * invoked. > + */ > + uint8_t rsvd_mode_params[4]; > + } mode_param; > +}; > + > +/** > + * @warning > + * @b EXPERIMENTAL: this API may change, or be removed, without prior no= tice > + * > + * Retrieve the information for ethdev congestion management > + * > + * @param port_id > + * The port identifier of the Ethernet device. > + * @param info > + * A pointer to a structure of type *rte_eth_cman_info* to be filled w= ith > + * the information about congestion management. > + * @return > + * - (0) if successful. > + * - (-ENOTSUP) if support for cman_info_get does not exist. > + * - (-ENODEV) if *port_id* invalid. > + * - (-EINVAL) if bad parameter. > + */ > +__rte_experimental > +int rte_eth_cman_info_get(uint16_t port_id, struct rte_eth_cman_info *in= fo); > + > +/** > + * @warning > + * @b EXPERIMENTAL: this API may change, or be removed, without prior no= tice > + * > + * Initialize the ethdev congestion management configuration structure w= ith default values. > + * > + * @param port_id > + * The port identifier of the Ethernet device. > + * @param config > + * A pointer to a structure of type *rte_eth_cman_config* to be initia= lized > + * with default value. > + * @return > + * - (0) if successful. > + * - (-ENOTSUP) if support for cman_config_init does not exist. > + * - (-ENODEV) if *port_id* invalid. > + * - (-EINVAL) if bad parameter. > + */ > +__rte_experimental > +int rte_eth_cman_config_init(uint16_t port_id, struct rte_eth_cman_confi= g *config); > + > +/** > + * @warning > + * @b EXPERIMENTAL: this API may change, or be removed, without prior no= tice > + * > + * Configure ethdev congestion management > + * > + * @param port_id > + * The port identifier of the Ethernet device. > + * @param config > + * A pointer to a structure of type *rte_eth_cman_config* to be config= ured. > + * @return > + * - (0) if successful. > + * - (-ENOTSUP) if support for cman_config_set does not exist. > + * - (-ENODEV) if *port_id* invalid. > + * - (-EINVAL) if bad parameter. > + */ > +__rte_experimental > +int rte_eth_cman_config_set(uint16_t port_id, const struct rte_eth_cman_= config *config); > + > +/** > + * @warning > + * @b EXPERIMENTAL: this API may change, or be removed, without prior no= tice > + * > + * Retrieve the applied ethdev congestion management parameters for the = given port. > + * > + * @param port_id > + * The port identifier of the Ethernet device. > + * @param config > + * A pointer to a structure of type *rte_eth_cman_config* to retrieve > + * congestion management parameters for the given object. > + * Application must fill all parameters except mode_param parameter in > + * struct rte_eth_cman_config. > + * > + * @return > + * - (0) if successful. > + * - (-ENOTSUP) if support for cman_config_get does not exist. > + * - (-ENODEV) if *port_id* invalid. > + * - (-EINVAL) if bad parameter. > + */ > +__rte_experimental > +int rte_eth_cman_config_get(uint16_t port_id, struct rte_eth_cman_config= *config); > + > #include > > /** > diff --git a/lib/ethdev/rte_ethdev_cman.c b/lib/ethdev/rte_ethdev_cman.c > new file mode 100644 > index 0000000000..4a1bdd7bd0 > --- /dev/null > +++ b/lib/ethdev/rte_ethdev_cman.c > @@ -0,0 +1,101 @@ > +/* SPDX-License-Identifier: BSD-3-Clause > + * Copyright(C) 2022 Marvell International Ltd. > + */ > + > +#include > + > +#include > +#include "rte_ethdev.h" > +#include "ethdev_driver.h" > +#include "ethdev_private.h" > + > +/* Get congestion management information for a port */ > +int > +rte_eth_cman_info_get(uint16_t port_id, struct rte_eth_cman_info *info) > +{ > + struct rte_eth_dev *dev; > + > + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); > + dev =3D &rte_eth_devices[port_id]; > + > + if (info =3D=3D NULL) { > + RTE_ETHDEV_LOG(ERR, "congestion management info is NULL\n")= ; > + return -EINVAL; > + } > + > + if (dev->dev_ops->cman_info_get =3D=3D NULL) { > + RTE_ETHDEV_LOG(ERR, "Function not implemented\n"); > + return -ENOTSUP; > + } > + > + memset(info, 0, sizeof(struct rte_eth_cman_info)); > + return eth_err(port_id, (*dev->dev_ops->cman_info_get)(dev, info)); > +} > + > +/* Initialize congestion management structure with default values */ > +int > +rte_eth_cman_config_init(uint16_t port_id, struct rte_eth_cman_config *c= onfig) > +{ > + struct rte_eth_dev *dev; > + > + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); > + dev =3D &rte_eth_devices[port_id]; > + > + if (config =3D=3D NULL) { > + RTE_ETHDEV_LOG(ERR, "congestion management config is NULL\n= "); > + return -EINVAL; > + } > + > + if (dev->dev_ops->cman_config_init =3D=3D NULL) { > + RTE_ETHDEV_LOG(ERR, "Function not implemented\n"); > + return -ENOTSUP; > + } > + > + memset(config, 0, sizeof(struct rte_eth_cman_config)); > + return eth_err(port_id, (*dev->dev_ops->cman_config_init)(dev, conf= ig)); > +} > + > +/* Configure congestion management on a port */ > +int > +rte_eth_cman_config_set(uint16_t port_id, const struct rte_eth_cman_conf= ig *config) > +{ > + struct rte_eth_dev *dev; > + > + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); > + dev =3D &rte_eth_devices[port_id]; > + > + if (config =3D=3D NULL) { > + RTE_ETHDEV_LOG(ERR, "congestion management config is NULL\n= "); > + return -EINVAL; > + } > + > + if (dev->dev_ops->cman_config_set =3D=3D NULL) { > + RTE_ETHDEV_LOG(ERR, "Function not implemented\n"); > + return -ENOTSUP; > + } > + > + return eth_err(port_id, (*dev->dev_ops->cman_config_set)(dev, confi= g)); > +} > + > +/* Retrieve congestion management configuration of a port */ > +int > +rte_eth_cman_config_get(uint16_t port_id, struct rte_eth_cman_config *co= nfig) > +{ > + struct rte_eth_dev *dev; > + > + RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV); > + dev =3D &rte_eth_devices[port_id]; > + > + if (config =3D=3D NULL) { > + RTE_ETHDEV_LOG(ERR, "congestion management config is NULL\n= "); > + return -EINVAL; > + } > + > + if (dev->dev_ops->cman_config_get =3D=3D NULL) { > + RTE_ETHDEV_LOG(ERR, "Function not implemented\n"); > + return -ENOTSUP; > + } > + > + memset(config, 0, sizeof(struct rte_eth_cman_config)); > + return eth_err(port_id, (*dev->dev_ops->cman_config_get)(dev, confi= g)); > +} > diff --git a/lib/ethdev/version.map b/lib/ethdev/version.map > index 3651ceb234..857d21be1c 100644 > --- a/lib/ethdev/version.map > +++ b/lib/ethdev/version.map > @@ -287,6 +287,10 @@ EXPERIMENTAL { > rte_mtr_meter_vlan_table_update; > > # added in 22.11 > + rte_eth_cman_config_get; > + rte_eth_cman_config_init; > + rte_eth_cman_config_set; > + rte_eth_cman_info_get; > rte_flow_async_action_handle_query; > rte_mtr_meter_policy_get; > rte_mtr_meter_profile_get; --_000_BY3PR18MB47853E2E0A6D582E5DFDB60CC85F9BY3PR18MB4785namp_ Content-Type: text/html; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable
Thanks Andrew. Changes are fine with me


From: Andrew Rybchenko <= andrew.rybchenko@oktetlabs.ru>
Sent: Thursday, October 6, 2022 2:06 PM
To: Ferruh Yigit <ferruh.yigit@amd.com>; Thomas Monjalon <t= homas@monjalon.net>; Ray Kinsella <mdr@ashroe.eu>
Cc: dev@dpdk.org <dev@dpdk.org>; Jerin Jacob Kollanukkaran <= ;jerinj@marvell.com>; Sunil Kumar Kori <skori@marvell.com>
Subject: [EXT] Re: [PATCH v4] ethdev: support congestion management<= /font>
 
External Email

----------------------------------------------------------------------
@Jerin, could you confirm if my minor changes are OK for you
and, if so, I'll proceed with applying the patch.

On 10/4/22 12:02, Andrew Rybchenko wrote:
> From: Jerin Jacob <jerinj@marvell.com>
>
> NIC HW controllers often come with congestion management support on > various HW objects such as Rx queue depth or mempool queue depth.
>
> Also, it can support various modes of operation such as RED
> (Random early discard), WRED etc on those HW objects.
>
> Add a framework to express such modes(enum rte_cman_mode) and
> introduce (enum rte_eth_cman_obj) to enumerate the different
> objects where the modes can operate on.
>
> Add RTE_CMAN_RED mode of operation and RTE_ETH_CMAN_OBJ_RX_QUEUE,
> RTE_ETH_CMAN_OBJ_RX_QUEUE_MEMPOOL objects.
>
> Introduce reserved fields in configuration structure
> backed by rte_eth_cman_config_init() to add new configuration
> parameters without ABI breakage.
>
> Add rte_eth_cman_info_get() API to get the information such as
> supported modes and objects.
>
> Add rte_eth_cman_config_init(), rte_eth_cman_config_set() APIs
> to configure congestion management on those object with associated mod= e.
>
> Finally, add rte_eth_cman_config_get() API to retrieve the
> applied configuration.
>
> Signed-off-by: Jerin Jacob <jerinj@marvell.com>
> Signed-off-by: Sunil Kumar Kori <skori@marvell.com>
> Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru><= br> > ---
> v3..v4: Andrew Rybchenko
>   - rebase
>   - remove eth_check_err() and use eth_err() instead
>   - minor fixes in description to avoid "This patch&quo= t; and "Added".
>   - correct position in release notes
> v2..v3:
>   - Rename rte_cman.c to rte_ethdev_cman.c
>   - Move lib/eal/include/rte_cman.h to lib/ethdev/rte_cman.h=
>   - Fix review comments (Andrew Rybchenko)
>   - Add release notes
>
> v1..v2:
>   - Fix review comments (Akhil Goyal)
>
> rfc..v1:
>   - Added RED specification (https://urldefense.proofpoint.c= om/v2/url?u=3Dhttp-3A__www.aciri.org_floyd_papers_red_red.html&d=3DDwIC= aQ&c=3DnKjWec2b6R0mOyPaz7xtfQ&r=3D1DGob4H4rxz6H8uITozGOCa0s5f4wCNtT= a4UUKvcsvI&m=3DkISGqWlRwNHLBHvKCTkVQBoHyBW79qMFQEJNcoDZXb8X4GKLwHVeeE_D= 3Lh082fx&s=3DHZKFgpOQ0CtqvK-_Zc-QZn87gBY4UrscDXgFihsXjvQ&e=3D  ) link
>   - Fixed doxygen comment issue (Min Hu)
>
>   doc/guides/nics/features.rst     =       |  12 ++
>   doc/guides/nics/features/default.ini   | &n= bsp; 1 +
>   doc/guides/rel_notes/release_22_11.rst |   6 + >   lib/ethdev/ethdev_driver.h     &n= bsp;       |  25 ++++
>   lib/ethdev/ethdev_private.h     &= nbsp;      |   3 +
>   lib/ethdev/meson.build      =            |   = 2 +
>   lib/ethdev/rte_cman.h      &= nbsp;           |  5= 5 +++++++++
>   lib/ethdev/rte_ethdev.c      = ;          |   2 +-<= br> >   lib/ethdev/rte_ethdev.h      = ;          | 164 +++++++++++++= ++++++++++++
>   lib/ethdev/rte_ethdev_cman.c     =       | 101 +++++++++++++++
>   lib/ethdev/version.map      =            |   = 4 +
>   11 files changed, 374 insertions(+), 1 deletion(-)
>   create mode 100644 lib/ethdev/rte_cman.h
>   create mode 100644 lib/ethdev/rte_ethdev_cman.c
>
> diff --git a/doc/guides/nics/features.rst b/doc/guides/nics/features.r= st
> index b4a8e9881c..70ca46e651 100644
> --- a/doc/guides/nics/features.rst
> +++ b/doc/guides/nics/features.rst
> @@ -727,6 +727,18 @@ Supports configuring per-queue stat counter mappi= ng.
>     ``rte_eth_dev_set_tx_queue_stats_mapping()``.<= br> >  
>  
> +.. _nic_features_congestion_management:
> +
> +Congestion management
> +---------------------
> +
> +Supports congestion management.
> +
> +* **[implements] eth_dev_ops**: ``cman_info_get``, ``cman_config_set`= `, ``cman_config_get``.
> +* **[related]    API**: ``rte_eth_cman_info_get()``, `= `rte_eth_cman_config_init()``,
> +  ``rte_eth_cman_config_set()``, ``rte_eth_cman_config_get()``.<= br> > +
> +
>   .. _nic_features_fw_version:
>  
>   FW version
> diff --git a/doc/guides/nics/features/default.ini b/doc/guides/nics/fe= atures/default.ini
> index f7192cb0da..a9c0008ebd 100644
> --- a/doc/guides/nics/features/default.ini
> +++ b/doc/guides/nics/features/default.ini
> @@ -60,6 +60,7 @@ Tx descriptor status =3D
>   Basic stats        = ;  =3D
>   Extended stats       =3D
>   Stats per queue      =3D
> +Congestion management =3D
>   FW version        =    =3D
>   EEPROM dump        = ;  =3D
>   Module EEPROM dump   =3D
> diff --git a/doc/guides/rel_notes/release_22_11.rst b/doc/guides/rel_n= otes/release_22_11.rst
> index 44f9a30c6a..0ffa004a9e 100644
> --- a/doc/guides/rel_notes/release_22_11.rst
> +++ b/doc/guides/rel_notes/release_22_11.rst
> @@ -78,6 +78,12 @@ New Features
>     Added new rte_flow action which allows applica= tion to re-route packets
>     directly to the kernel without software involv= ement.
>  
> +* **Added support for congestion management for ethdev.**
> +
> +  Added new APIs ``rte_eth_cman_config_init()``, ``rte_eth_cman_= config_get()``,
> +  ``rte_eth_cman_config_set()``, ``rte_eth_cman_info_get()``
> +  to support congestion management.
> +
>   * **Updated Intel iavf driver.**
>  
>     * Added flow subscription support.
> diff --git a/lib/ethdev/ethdev_driver.h b/lib/ethdev/ethdev_driver.h > index 8cd8eb8685..e1e2d10a35 100644
> --- a/lib/ethdev/ethdev_driver.h
> +++ b/lib/ethdev/ethdev_driver.h
> @@ -1094,6 +1094,22 @@ typedef int (*eth_rx_queue_avail_thresh_query_t= )(struct rte_eth_dev *dev,
>            = ;            &n= bsp;            = ;   uint16_t *rx_queue_id,
>            = ;            &n= bsp;            = ;   uint8_t *avail_thresh);
>  
> +/** @internal Get congestion management information. */
> +typedef int (*eth_cman_info_get_t)(struct rte_eth_dev *dev,
> +           &nb= sp;            =      struct rte_eth_cman_info *info);
> +
> +/** @internal Init congestion management structure with default value= s. */
> +typedef int (*eth_cman_config_init_t)(struct rte_eth_dev *dev,
> +           &nb= sp;            =      struct rte_eth_cman_config *config);
> +
> +/** @internal Configure congestion management on a port. */
> +typedef int (*eth_cman_config_set_t)(struct rte_eth_dev *dev,
> +           &nb= sp;            =      const struct rte_eth_cman_config *config);
> +
> +/** @internal Retrieve congestion management configuration of a port.= */
> +typedef int (*eth_cman_config_get_t)(struct rte_eth_dev *dev,
> +           &nb= sp;            =      struct rte_eth_cman_config *config);
> +
>   /**
>    * @internal A structure containing the functions exp= orted by an Ethernet driver.
>    */
> @@ -1309,6 +1325,15 @@ struct eth_dev_ops {
>        eth_rx_queue_avail_thresh_se= t_t rx_queue_avail_thresh_set;
>        /** Query Rx queue available= descriptors threshold event */
>        eth_rx_queue_avail_thresh_qu= ery_t rx_queue_avail_thresh_query;
> +
> +     /** Get congestion management information */=
> +     eth_cman_info_get_t cman_info_get;
> +     /** Initialize congestion management structu= re with default values */
> +     eth_cman_config_init_t cman_config_init;
> +     /** Configure congestion management */
> +     eth_cman_config_set_t cman_config_set;
> +     /** Retrieve congestion management configura= tion */
> +     eth_cman_config_get_t cman_config_get;
>   };
>  
>   /**
> diff --git a/lib/ethdev/ethdev_private.h b/lib/ethdev/ethdev_private.h=
> index cc9879907c..acb4b335c8 100644
> --- a/lib/ethdev/ethdev_private.h
> +++ b/lib/ethdev/ethdev_private.h
> @@ -37,6 +37,9 @@ struct rte_eth_dev_callback {
>  
>   extern rte_spinlock_t eth_dev_cb_lock;
>  
> +/* Convert all error to -EIO if device is removed. */
> +int eth_err(uint16_t port_id, int ret);
> +
>   /*
>    * Convert rte_eth_dev pointer to port ID.
>    * NULL will be translated to RTE_MAX_ETHPORTS.
> diff --git a/lib/ethdev/meson.build b/lib/ethdev/meson.build
> index 47bb2625b0..39250b5da1 100644
> --- a/lib/ethdev/meson.build
> +++ b/lib/ethdev/meson.build
> @@ -8,6 +8,7 @@ sources =3D files(
>           'ethdev_tr= ace_points.c',
>           'rte_class= _eth.c',
>           'rte_ethde= v.c',
> +        'rte_ethdev_cman.c',
>           'rte_flow.= c',
>           'rte_mtr.c= ',
>           'rte_tm.c'= ,
> @@ -19,6 +20,7 @@ sources =3D files(
>   )
>  
>   headers =3D files(
> +        'rte_cman.h',
>           'rte_ethde= v.h',
>           'rte_ethde= v_trace.h',
>           'rte_ethde= v_trace_fp.h',
> diff --git a/lib/ethdev/rte_cman.h b/lib/ethdev/rte_cman.h
> new file mode 100644
> index 0000000000..297db8e095
> --- /dev/null
> +++ b/lib/ethdev/rte_cman.h
> @@ -0,0 +1,55 @@
> +/* SPDX-License-Identifier: BSD-3-Clause
> + * Copyright(C) 2022 Marvell International Ltd.
> + */
> +
> +#ifndef RTE_CMAN_H
> +#define RTE_CMAN_H
> +
> +#ifdef __cplusplus
> +extern "C" {
> +#endif
> +
> +#include <rte_bitops.h>
> +
> +/**
> + * @file
> + * Congestion management related parameters for DPDK.
> + */
> +
> +/** Congestion management modes */
> +enum rte_cman_mode {
> +     /**
> +      * Congestion based on Random Early Det= ection.
> +      *
> +      * https://urldefense.proofpoint.com/v2/url?u=3Dhttps-3A__en.wikipedia.org_wik= i_Random-5Fearly-5Fdetection&d=3DDwICaQ&c=3DnKjWec2b6R0mOyPaz7xtfQ&= amp;r=3D1DGob4H4rxz6H8uITozGOCa0s5f4wCNtTa4UUKvcsvI&m=3DkISGqWlRwNHLBHv= KCTkVQBoHyBW79qMFQEJNcoDZXb8X4GKLwHVeeE_D3Lh082fx&s=3DiyRkqzJBjwu2oS-YM= RhtxJOpsK8JWJG5gEH_1DC5pwM&e=3D 
> +      * https://urldefense.proofpoint.com/v2/url?u=3Dhttp-3A__www.aciri.org_floyd_p= apers_red_red.html&d=3DDwICaQ&c=3DnKjWec2b6R0mOyPaz7xtfQ&r=3D1D= Gob4H4rxz6H8uITozGOCa0s5f4wCNtTa4UUKvcsvI&m=3DkISGqWlRwNHLBHvKCTkVQBoHy= BW79qMFQEJNcoDZXb8X4GKLwHVeeE_D3Lh082fx&s=3DHZKFgpOQ0CtqvK-_Zc-QZn87gBY= 4UrscDXgFihsXjvQ&e=3D 
> +      * @see struct rte_cman_red_params
> +      */
> +     RTE_CMAN_RED =3D RTE_BIT32(0),
> +};
> +
> +/**
> + * RED based congestion management configuration parameters.
> + */
> +struct rte_cman_red_params {
> +     /**
> +      * Minimum threshold (min_th) value
> +      *
> +      * Value expressed as percentage. Value= must be in 0 to 100(inclusive).
> +      */
> +     uint8_t min_th;
> +     /**
> +      * Maximum threshold (max_th) value
> +      *
> +      * Value expressed as percentage. Value= must be in 0 to 100(inclusive).
> +      */
> +     uint8_t max_th;
> +     /** Inverse of packet marking probability ma= ximum value (maxp =3D 1 / maxp_inv) */
> +     uint16_t maxp_inv;
> +};
> +
> +#ifdef __cplusplus
> +}
> +#endif
> +
> +#endif /* RTE_CMAN_H */
> diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c
> index 0c2c1088c0..e4eb17221b 100644
> --- a/lib/ethdev/rte_ethdev.c
> +++ b/lib/ethdev/rte_ethdev.c
> @@ -642,7 +642,7 @@ rte_eth_dev_get_port_by_name(const char *name, uin= t16_t *port_id)
>        return -ENODEV;
>   }
>  
> -static int
> +int
>   eth_err(uint16_t port_id, int ret)
>   {
>        if (ret =3D=3D 0)
> diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h
> index a21f58b9cd..8df1cdfad0 100644
> --- a/lib/ethdev/rte_ethdev.h
> +++ b/lib/ethdev/rte_ethdev.h
> @@ -160,6 +160,7 @@ extern "C" {
>   #define RTE_ETHDEV_DEBUG_TX
>   #endif
>  
> +#include <rte_cman.h>
>   #include <rte_compat.h>
>   #include <rte_log.h>
>   #include <rte_interrupts.h>
> @@ -5314,6 +5315,169 @@ typedef struct {
>   __rte_experimental
>   int rte_eth_dev_priv_dump(uint16_t port_id, FILE *file); >  
> +/* Congestion management */
> +
> +/** Enumerate list of ethdev congestion management objects */
> +enum rte_eth_cman_obj {
> +     /** Congestion management based on Rx queue = depth */
> +     RTE_ETH_CMAN_OBJ_RX_QUEUE =3D RTE_BIT32(0),<= br> > +     /**
> +      * Congestion management based on mempo= ol depth associated with Rx queue
> +      * @see rte_eth_rx_queue_setup()
> +      */
> +     RTE_ETH_CMAN_OBJ_RX_QUEUE_MEMPOOL =3D RTE_BI= T32(1),
> +};
> +
> +/**
> + * @warning
> + * @b EXPERIMENTAL: this structure may change, or be removed, without= prior notice
> + *
> + * A structure used to retrieve information of ethdev congestion mana= gement.
> + */
> +struct rte_eth_cman_info {
> +     /**
> +      * Set of supported congestion manageme= nt modes
> +      * @see enum rte_cman_mode
> +      */
> +     uint64_t modes_supported;
> +     /**
> +      * Set of supported congestion manageme= nt objects
> +      * @see enum rte_eth_cman_obj
> +      */
> +     uint64_t objs_supported;
> +     /**
> +      * Reserved for future fields. Always r= eturned as 0 when
> +      * rte_eth_cman_info_get() is invoked > +      */
> +     uint8_t rsvd[8];
> +};
> +
> +/**
> + * @warning
> + * @b EXPERIMENTAL: this structure may change, or be removed, without= prior notice
> + *
> + * A structure used to configure the ethdev congestion management. > + */
> +struct rte_eth_cman_config {
> +     /** Congestion management object */
> +     enum rte_eth_cman_obj obj;
> +     /** Congestion management mode */
> +     enum rte_cman_mode mode;
> +     union {
> +           &nb= sp; /**
> +           &nb= sp;  * Rx queue to configure congestion management.
> +           &nb= sp;  *
> +           &nb= sp;  * Valid when object is RTE_ETH_CMAN_OBJ_RX_QUEUE or
> +           &nb= sp;  * RTE_ETH_CMAN_OBJ_RX_QUEUE_MEMPOOL.
> +           &nb= sp;  */
> +           &nb= sp; uint16_t rx_queue;
> +           &nb= sp; /**
> +           &nb= sp;  * Reserved for future fields.
> +           &nb= sp;  * It must be set to 0 when rte_eth_cman_config_set() is invoked > +           &nb= sp;  * and will be returned as 0 when rte_eth_cman_config_get() is
> +           &nb= sp;  * invoked.
> +           &nb= sp;  */
> +           &nb= sp; uint8_t rsvd_obj_params[4];
> +     } obj_param;
> +     union {
> +           &nb= sp; /**
> +           &nb= sp;  * RED configuration parameters.
> +           &nb= sp;  *
> +           &nb= sp;  * Valid when mode is RTE_CMAN_RED.
> +           &nb= sp;  */
> +           &nb= sp; struct rte_cman_red_params red;
> +           &nb= sp; /**
> +           &nb= sp;  * Reserved for future fields.
> +           &nb= sp;  * It must be set to 0 when rte_eth_cman_config_set() is invoked > +           &nb= sp;  * and will be returned as 0 when rte_eth_cman_config_get() is
> +           &nb= sp;  * invoked.
> +           &nb= sp;  */
> +           &nb= sp; uint8_t rsvd_mode_params[4];
> +     } mode_param;
> +};
> +
> +/**
> + * @warning
> + * @b EXPERIMENTAL: this API may change, or be removed, without prior= notice
> + *
> + * Retrieve the information for ethdev congestion management
> + *
> + * @param port_id
> + *   The port identifier of the Ethernet device.
> + * @param info
> + *   A pointer to a structure of type *rte_eth_cman_info* t= o be filled with
> + *   the information about congestion management.
> + * @return
> + *   - (0) if successful.
> + *   - (-ENOTSUP) if support for cman_info_get does not exi= st.
> + *   - (-ENODEV) if *port_id* invalid.
> + *   - (-EINVAL) if bad parameter.
> + */
> +__rte_experimental
> +int rte_eth_cman_info_get(uint16_t port_id, struct rte_eth_cman_info = *info);
> +
> +/**
> + * @warning
> + * @b EXPERIMENTAL: this API may change, or be removed, without prior= notice
> + *
> + * Initialize the ethdev congestion management configuration structur= e with default values.
> + *
> + * @param port_id
> + *   The port identifier of the Ethernet device.
> + * @param config
> + *   A pointer to a structure of type *rte_eth_cman_config*= to be initialized
> + *   with default value.
> + * @return
> + *   - (0) if successful.
> + *   - (-ENOTSUP) if support for cman_config_init does not = exist.
> + *   - (-ENODEV) if *port_id* invalid.
> + *   - (-EINVAL) if bad parameter.
> + */
> +__rte_experimental
> +int rte_eth_cman_config_init(uint16_t port_id, struct rte_eth_cman_co= nfig *config);
> +
> +/**
> + * @warning
> + * @b EXPERIMENTAL: this API may change, or be removed, without prior= notice
> + *
> + * Configure ethdev congestion management
> + *
> + * @param port_id
> + *   The port identifier of the Ethernet device.
> + * @param config
> + *   A pointer to a structure of type *rte_eth_cman_config*= to be configured.
> + * @return
> + *   - (0) if successful.
> + *   - (-ENOTSUP) if support for cman_config_set does not e= xist.
> + *   - (-ENODEV) if *port_id* invalid.
> + *   - (-EINVAL) if bad parameter.
> + */
> +__rte_experimental
> +int rte_eth_cman_config_set(uint16_t port_id, const struct rte_eth_cm= an_config *config);
> +
> +/**
> + * @warning
> + * @b EXPERIMENTAL: this API may change, or be removed, without prior= notice
> + *
> + * Retrieve the applied ethdev congestion management parameters for t= he given port.
> + *
> + * @param port_id
> + *   The port identifier of the Ethernet device.
> + * @param config
> + *   A pointer to a structure of type *rte_eth_cman_config*= to retrieve
> + *   congestion management parameters for the given object.=
> + *   Application must fill all parameters except mode_param= parameter in
> + *   struct rte_eth_cman_config.
> + *
> + * @return
> + *   - (0) if successful.
> + *   - (-ENOTSUP) if support for cman_config_get does not e= xist.
> + *   - (-ENODEV) if *port_id* invalid.
> + *   - (-EINVAL) if bad parameter.
> + */
> +__rte_experimental
> +int rte_eth_cman_config_get(uint16_t port_id, struct rte_eth_cman_con= fig *config);
> +
>   #include <rte_ethdev_core.h>
>  
>   /**
> diff --git a/lib/ethdev/rte_ethdev_cman.c b/lib/ethdev/rte_ethdev_cman= .c
> new file mode 100644
> index 0000000000..4a1bdd7bd0
> --- /dev/null
> +++ b/lib/ethdev/rte_ethdev_cman.c
> @@ -0,0 +1,101 @@
> +/* SPDX-License-Identifier: BSD-3-Clause
> + * Copyright(C) 2022 Marvell International Ltd.
> + */
> +
> +#include <stdint.h>
> +
> +#include <rte_errno.h>
> +#include "rte_ethdev.h"
> +#include "ethdev_driver.h"
> +#include "ethdev_private.h"
> +
> +/* Get congestion management information for a port */
> +int
> +rte_eth_cman_info_get(uint16_t port_id, struct rte_eth_cman_info *inf= o)
> +{
> +     struct rte_eth_dev *dev;
> +
> +     RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EN= ODEV);
> +     dev =3D &rte_eth_devices[port_id];
> +
> +     if (info =3D=3D NULL) {
> +           &nb= sp; RTE_ETHDEV_LOG(ERR, "congestion management info is NULL\n");<= br> > +           &nb= sp; return -EINVAL;
> +     }
> +
> +     if (dev->dev_ops->cman_info_get =3D=3D= NULL) {
> +           &nb= sp; RTE_ETHDEV_LOG(ERR, "Function not implemented\n");
> +           &nb= sp; return -ENOTSUP;
> +     }
> +
> +     memset(info, 0, sizeof(struct rte_eth_cman_i= nfo));
> +     return eth_err(port_id, (*dev->dev_ops-&g= t;cman_info_get)(dev, info));
> +}
> +
> +/* Initialize congestion management structure with default values */<= br> > +int
> +rte_eth_cman_config_init(uint16_t port_id, struct rte_eth_cman_config= *config)
> +{
> +     struct rte_eth_dev *dev;
> +
> +     RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EN= ODEV);
> +     dev =3D &rte_eth_devices[port_id];
> +
> +     if (config =3D=3D NULL) {
> +           &nb= sp; RTE_ETHDEV_LOG(ERR, "congestion management config is NULL\n")= ;
> +           &nb= sp; return -EINVAL;
> +     }
> +
> +     if (dev->dev_ops->cman_config_init =3D= =3D NULL) {
> +           &nb= sp; RTE_ETHDEV_LOG(ERR, "Function not implemented\n");
> +           &nb= sp; return -ENOTSUP;
> +     }
> +
> +     memset(config, 0, sizeof(struct rte_eth_cman= _config));
> +     return eth_err(port_id, (*dev->dev_ops-&g= t;cman_config_init)(dev, config));
> +}
> +
> +/* Configure congestion management on a port */
> +int
> +rte_eth_cman_config_set(uint16_t port_id, const struct rte_eth_cman_c= onfig *config)
> +{
> +     struct rte_eth_dev *dev;
> +
> +     RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EN= ODEV);
> +     dev =3D &rte_eth_devices[port_id];
> +
> +     if (config =3D=3D NULL) {
> +           &nb= sp; RTE_ETHDEV_LOG(ERR, "congestion management config is NULL\n")= ;
> +           &nb= sp; return -EINVAL;
> +     }
> +
> +     if (dev->dev_ops->cman_config_set =3D= =3D NULL) {
> +           &nb= sp; RTE_ETHDEV_LOG(ERR, "Function not implemented\n");
> +           &nb= sp; return -ENOTSUP;
> +     }
> +
> +     return eth_err(port_id, (*dev->dev_ops-&g= t;cman_config_set)(dev, config));
> +}
> +
> +/* Retrieve congestion management configuration of a port */
> +int
> +rte_eth_cman_config_get(uint16_t port_id, struct rte_eth_cman_config = *config)
> +{
> +     struct rte_eth_dev *dev;
> +
> +     RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -EN= ODEV);
> +     dev =3D &rte_eth_devices[port_id];
> +
> +     if (config =3D=3D NULL) {
> +           &nb= sp; RTE_ETHDEV_LOG(ERR, "congestion management config is NULL\n")= ;
> +           &nb= sp; return -EINVAL;
> +     }
> +
> +     if (dev->dev_ops->cman_config_get =3D= =3D NULL) {
> +           &nb= sp; RTE_ETHDEV_LOG(ERR, "Function not implemented\n");
> +           &nb= sp; return -ENOTSUP;
> +     }
> +
> +     memset(config, 0, sizeof(struct rte_eth_cman= _config));
> +     return eth_err(port_id, (*dev->dev_ops-&g= t;cman_config_get)(dev, config));
> +}
> diff --git a/lib/ethdev/version.map b/lib/ethdev/version.map
> index 3651ceb234..857d21be1c 100644
> --- a/lib/ethdev/version.map
> +++ b/lib/ethdev/version.map
> @@ -287,6 +287,10 @@ EXPERIMENTAL {
>        rte_mtr_meter_vlan_table_upd= ate;
>  
>        # added in 22.11
> +     rte_eth_cman_config_get;
> +     rte_eth_cman_config_init;
> +     rte_eth_cman_config_set;
> +     rte_eth_cman_info_get;
>        rte_flow_async_action_handle= _query;
>        rte_mtr_meter_policy_get; >        rte_mtr_meter_profile_get;
--_000_BY3PR18MB47853E2E0A6D582E5DFDB60CC85F9BY3PR18MB4785namp_--