<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body>
<div>Thanks Andrew. Changes are fine with me</div>
<div></div>
<br>
<hr style="display:inline-block;width:98%" tabindex="-1">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" style="font-size:11pt" color="#000000"><b>From:</b> Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru><br>
<b>Sent:</b> Thursday, October 6, 2022 2:06 PM<br>
<b>To:</b> Ferruh Yigit <ferruh.yigit@amd.com>; Thomas Monjalon <thomas@monjalon.net>; Ray Kinsella <mdr@ashroe.eu><br>
<b>Cc:</b> dev@dpdk.org <dev@dpdk.org>; Jerin Jacob Kollanukkaran <jerinj@marvell.com>; Sunil Kumar Kori <skori@marvell.com><br>
<b>Subject:</b> [EXT] Re: [PATCH v4] ethdev: support congestion management</font>
<div> </div>
</div>
<div class="BodyFragment"><font size="2"><span style="font-size:11pt;">
<div class="PlainText">External Email<br>
<br>
----------------------------------------------------------------------<br>
@Jerin, could you confirm if my minor changes are OK for you<br>
and, if so, I'll proceed with applying the patch.<br>
<br>
On 10/4/22 12:02, Andrew Rybchenko wrote:<br>
> From: Jerin Jacob <jerinj@marvell.com><br>
> <br>
> NIC HW controllers often come with congestion management support on<br>
> various HW objects such as Rx queue depth or mempool queue depth.<br>
> <br>
> Also, it can support various modes of operation such as RED<br>
> (Random early discard), WRED etc on those HW objects.<br>
> <br>
> Add a framework to express such modes(enum rte_cman_mode) and<br>
> introduce (enum rte_eth_cman_obj) to enumerate the different<br>
> objects where the modes can operate on.<br>
> <br>
> Add RTE_CMAN_RED mode of operation and RTE_ETH_CMAN_OBJ_RX_QUEUE,<br>
> RTE_ETH_CMAN_OBJ_RX_QUEUE_MEMPOOL objects.<br>
> <br>
> Introduce reserved fields in configuration structure<br>
> backed by rte_eth_cman_config_init() to add new configuration<br>
> parameters without ABI breakage.<br>
> <br>
> Add rte_eth_cman_info_get() API to get the information such as<br>
> supported modes and objects.<br>
> <br>
> Add rte_eth_cman_config_init(), rte_eth_cman_config_set() APIs<br>
> to configure congestion management on those object with associated mode.<br>
> <br>
> Finally, add rte_eth_cman_config_get() API to retrieve the<br>
> applied configuration.<br>
> <br>
> Signed-off-by: Jerin Jacob <jerinj@marvell.com><br>
> Signed-off-by: Sunil Kumar Kori <skori@marvell.com><br>
> Signed-off-by: Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru><br>
> ---<br>
> v3..v4: Andrew Rybchenko<br>
>   - rebase<br>
>   - remove eth_check_err() and use eth_err() instead<br>
>   - minor fixes in description to avoid "This patch" and "Added".<br>
>   - correct position in release notes<br>
> v2..v3:<br>
>   - Rename rte_cman.c to rte_ethdev_cman.c<br>
>   - Move lib/eal/include/rte_cman.h to lib/ethdev/rte_cman.h<br>
>   - Fix review comments (Andrew Rybchenko)<br>
>   - Add release notes<br>
> <br>
> v1..v2:<br>
>   - Fix review comments (Akhil Goyal)<br>
> <br>
> rfc..v1:<br>
>   - Added RED specification (https://urldefense.proofpoint.com/v2/url?u=http-3A__www.aciri.org_floyd_papers_red_red.html&d=DwICaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=1DGob4H4rxz6H8uITozGOCa0s5f4wCNtTa4UUKvcsvI&m=kISGqWlRwNHLBHvKCTkVQBoHyBW79qMFQEJNcoDZXb8X4GKLwHVeeE_D3Lh082fx&s=HZKFgpOQ0CtqvK-_Zc-QZn87gBY4UrscDXgFihsXjvQ&e= 
 ) link<br>
>   - Fixed doxygen comment issue (Min Hu)<br>
> <br>
>   doc/guides/nics/features.rst           |  12 ++<br>
>   doc/guides/nics/features/default.ini   |   1 +<br>
>   doc/guides/rel_notes/release_22_11.rst |   6 +<br>
>   lib/ethdev/ethdev_driver.h             |  25 ++++<br>
>   lib/ethdev/ethdev_private.h            |   3 +<br>
>   lib/ethdev/meson.build                 |   2 +<br>
>   lib/ethdev/rte_cman.h                  |  55 +++++++++<br>
>   lib/ethdev/rte_ethdev.c                |   2 +-<br>
>   lib/ethdev/rte_ethdev.h                | 164 +++++++++++++++++++++++++<br>
>   lib/ethdev/rte_ethdev_cman.c           | 101 +++++++++++++++<br>
>   lib/ethdev/version.map                 |   4 +<br>
>   11 files changed, 374 insertions(+), 1 deletion(-)<br>
>   create mode 100644 lib/ethdev/rte_cman.h<br>
>   create mode 100644 lib/ethdev/rte_ethdev_cman.c<br>
> <br>
> diff --git a/doc/guides/nics/features.rst b/doc/guides/nics/features.rst<br>
> index b4a8e9881c..70ca46e651 100644<br>
> --- a/doc/guides/nics/features.rst<br>
> +++ b/doc/guides/nics/features.rst<br>
> @@ -727,6 +727,18 @@ Supports configuring per-queue stat counter mapping.<br>
>     ``rte_eth_dev_set_tx_queue_stats_mapping()``.<br>
>   <br>
>   <br>
> +.. _nic_features_congestion_management:<br>
> +<br>
> +Congestion management<br>
> +---------------------<br>
> +<br>
> +Supports congestion management.<br>
> +<br>
> +* **[implements] eth_dev_ops**: ``cman_info_get``, ``cman_config_set``, ``cman_config_get``.<br>
> +* **[related]    API**: ``rte_eth_cman_info_get()``, ``rte_eth_cman_config_init()``,<br>
> +  ``rte_eth_cman_config_set()``, ``rte_eth_cman_config_get()``.<br>
> +<br>
> +<br>
>   .. _nic_features_fw_version:<br>
>   <br>
>   FW version<br>
> diff --git a/doc/guides/nics/features/default.ini b/doc/guides/nics/features/default.ini<br>
> index f7192cb0da..a9c0008ebd 100644<br>
> --- a/doc/guides/nics/features/default.ini<br>
> +++ b/doc/guides/nics/features/default.ini<br>
> @@ -60,6 +60,7 @@ Tx descriptor status =<br>
>   Basic stats          =<br>
>   Extended stats       =<br>
>   Stats per queue      =<br>
> +Congestion management =<br>
>   FW version           =<br>
>   EEPROM dump          =<br>
>   Module EEPROM dump   =<br>
> diff --git a/doc/guides/rel_notes/release_22_11.rst b/doc/guides/rel_notes/release_22_11.rst<br>
> index 44f9a30c6a..0ffa004a9e 100644<br>
> --- a/doc/guides/rel_notes/release_22_11.rst<br>
> +++ b/doc/guides/rel_notes/release_22_11.rst<br>
> @@ -78,6 +78,12 @@ New Features<br>
>     Added new rte_flow action which allows application to re-route packets<br>
>     directly to the kernel without software involvement.<br>
>   <br>
> +* **Added support for congestion management for ethdev.**<br>
> +<br>
> +  Added new APIs ``rte_eth_cman_config_init()``, ``rte_eth_cman_config_get()``,<br>
> +  ``rte_eth_cman_config_set()``, ``rte_eth_cman_info_get()``<br>
> +  to support congestion management.<br>
> +<br>
>   * **Updated Intel iavf driver.**<br>
>   <br>
>     * Added flow subscription support.<br>
> diff --git a/lib/ethdev/ethdev_driver.h b/lib/ethdev/ethdev_driver.h<br>
> index 8cd8eb8685..e1e2d10a35 100644<br>
> --- a/lib/ethdev/ethdev_driver.h<br>
> +++ b/lib/ethdev/ethdev_driver.h<br>
> @@ -1094,6 +1094,22 @@ typedef int (*eth_rx_queue_avail_thresh_query_t)(struct rte_eth_dev *dev,<br>
>                                        uint16_t *rx_queue_id,<br>
>                                        uint8_t *avail_thresh);<br>
>   <br>
> +/** @internal Get congestion management information. */<br>
> +typedef int (*eth_cman_info_get_t)(struct rte_eth_dev *dev,<br>
> +                             struct rte_eth_cman_info *info);<br>
> +<br>
> +/** @internal Init congestion management structure with default values. */<br>
> +typedef int (*eth_cman_config_init_t)(struct rte_eth_dev *dev,<br>
> +                             struct rte_eth_cman_config *config);<br>
> +<br>
> +/** @internal Configure congestion management on a port. */<br>
> +typedef int (*eth_cman_config_set_t)(struct rte_eth_dev *dev,<br>
> +                             const struct rte_eth_cman_config *config);<br>
> +<br>
> +/** @internal Retrieve congestion management configuration of a port. */<br>
> +typedef int (*eth_cman_config_get_t)(struct rte_eth_dev *dev,<br>
> +                             struct rte_eth_cman_config *config);<br>
> +<br>
>   /**<br>
>    * @internal A structure containing the functions exported by an Ethernet driver.<br>
>    */<br>
> @@ -1309,6 +1325,15 @@ struct eth_dev_ops {<br>
>        eth_rx_queue_avail_thresh_set_t rx_queue_avail_thresh_set;<br>
>        /** Query Rx queue available descriptors threshold event */<br>
>        eth_rx_queue_avail_thresh_query_t rx_queue_avail_thresh_query;<br>
> +<br>
> +     /** Get congestion management information */<br>
> +     eth_cman_info_get_t cman_info_get;<br>
> +     /** Initialize congestion management structure with default values */<br>
> +     eth_cman_config_init_t cman_config_init;<br>
> +     /** Configure congestion management */<br>
> +     eth_cman_config_set_t cman_config_set;<br>
> +     /** Retrieve congestion management configuration */<br>
> +     eth_cman_config_get_t cman_config_get;<br>
>   };<br>
>   <br>
>   /**<br>
> diff --git a/lib/ethdev/ethdev_private.h b/lib/ethdev/ethdev_private.h<br>
> index cc9879907c..acb4b335c8 100644<br>
> --- a/lib/ethdev/ethdev_private.h<br>
> +++ b/lib/ethdev/ethdev_private.h<br>
> @@ -37,6 +37,9 @@ struct rte_eth_dev_callback {<br>
>   <br>
>   extern rte_spinlock_t eth_dev_cb_lock;<br>
>   <br>
> +/* Convert all error to -EIO if device is removed. */<br>
> +int eth_err(uint16_t port_id, int ret);<br>
> +<br>
>   /*<br>
>    * Convert rte_eth_dev pointer to port ID.<br>
>    * NULL will be translated to RTE_MAX_ETHPORTS.<br>
> diff --git a/lib/ethdev/meson.build b/lib/ethdev/meson.build<br>
> index 47bb2625b0..39250b5da1 100644<br>
> --- a/lib/ethdev/meson.build<br>
> +++ b/lib/ethdev/meson.build<br>
> @@ -8,6 +8,7 @@ sources = files(<br>
>           'ethdev_trace_points.c',<br>
>           'rte_class_eth.c',<br>
>           'rte_ethdev.c',<br>
> +        'rte_ethdev_cman.c',<br>
>           'rte_flow.c',<br>
>           'rte_mtr.c',<br>
>           'rte_tm.c',<br>
> @@ -19,6 +20,7 @@ sources = files(<br>
>   )<br>
>   <br>
>   headers = files(<br>
> +        'rte_cman.h',<br>
>           'rte_ethdev.h',<br>
>           'rte_ethdev_trace.h',<br>
>           'rte_ethdev_trace_fp.h',<br>
> diff --git a/lib/ethdev/rte_cman.h b/lib/ethdev/rte_cman.h<br>
> new file mode 100644<br>
> index 0000000000..297db8e095<br>
> --- /dev/null<br>
> +++ b/lib/ethdev/rte_cman.h<br>
> @@ -0,0 +1,55 @@<br>
> +/* SPDX-License-Identifier: BSD-3-Clause<br>
> + * Copyright(C) 2022 Marvell International Ltd.<br>
> + */<br>
> +<br>
> +#ifndef RTE_CMAN_H<br>
> +#define RTE_CMAN_H<br>
> +<br>
> +#ifdef __cplusplus<br>
> +extern "C" {<br>
> +#endif<br>
> +<br>
> +#include <rte_bitops.h><br>
> +<br>
> +/**<br>
> + * @file<br>
> + * Congestion management related parameters for DPDK.<br>
> + */<br>
> +<br>
> +/** Congestion management modes */<br>
> +enum rte_cman_mode {<br>
> +     /**<br>
> +      * Congestion based on Random Early Detection.<br>
> +      *<br>
> +      * <a href="https://urldefense.proofpoint.com/v2/url?u=https-3A__en.wikipedia.org_wiki_Random-5Fearly-5Fdetection&d=DwICaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=1DGob4H4rxz6H8uITozGOCa0s5f4wCNtTa4UUKvcsvI&m=kISGqWlRwNHLBHvKCTkVQBoHyBW79qMFQEJNcoDZXb8X4GKLwHVeeE_D3Lh082fx&s=iyRkqzJBjwu2oS-YMRhtxJOpsK8JWJG5gEH_1DC5pwM&e=" data-auth="NotApplicable">
https://urldefense.proofpoint.com/v2/url?u=https-3A__en.wikipedia.org_wiki_Random-5Fearly-5Fdetection&d=DwICaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=1DGob4H4rxz6H8uITozGOCa0s5f4wCNtTa4UUKvcsvI&m=kISGqWlRwNHLBHvKCTkVQBoHyBW79qMFQEJNcoDZXb8X4GKLwHVeeE_D3Lh082fx&s=iyRkqzJBjwu2oS-YMRhtxJOpsK8JWJG5gEH_1DC5pwM&e=</a> 
<br>
> +      * <a href="https://urldefense.proofpoint.com/v2/url?u=http-3A__www.aciri.org_floyd_papers_red_red.html&d=DwICaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=1DGob4H4rxz6H8uITozGOCa0s5f4wCNtTa4UUKvcsvI&m=kISGqWlRwNHLBHvKCTkVQBoHyBW79qMFQEJNcoDZXb8X4GKLwHVeeE_D3Lh082fx&s=HZKFgpOQ0CtqvK-_Zc-QZn87gBY4UrscDXgFihsXjvQ&e=" data-auth="NotApplicable">
https://urldefense.proofpoint.com/v2/url?u=http-3A__www.aciri.org_floyd_papers_red_red.html&d=DwICaQ&c=nKjWec2b6R0mOyPaz7xtfQ&r=1DGob4H4rxz6H8uITozGOCa0s5f4wCNtTa4UUKvcsvI&m=kISGqWlRwNHLBHvKCTkVQBoHyBW79qMFQEJNcoDZXb8X4GKLwHVeeE_D3Lh082fx&s=HZKFgpOQ0CtqvK-_Zc-QZn87gBY4UrscDXgFihsXjvQ&e=</a> 
<br>
> +      * @see struct rte_cman_red_params<br>
> +      */<br>
> +     RTE_CMAN_RED = RTE_BIT32(0),<br>
> +};<br>
> +<br>
> +/**<br>
> + * RED based congestion management configuration parameters.<br>
> + */<br>
> +struct rte_cman_red_params {<br>
> +     /**<br>
> +      * Minimum threshold (min_th) value<br>
> +      *<br>
> +      * Value expressed as percentage. Value must be in 0 to 100(inclusive).<br>
> +      */<br>
> +     uint8_t min_th;<br>
> +     /**<br>
> +      * Maximum threshold (max_th) value<br>
> +      *<br>
> +      * Value expressed as percentage. Value must be in 0 to 100(inclusive).<br>
> +      */<br>
> +     uint8_t max_th;<br>
> +     /** Inverse of packet marking probability maximum value (maxp = 1 / maxp_inv) */<br>
> +     uint16_t maxp_inv;<br>
> +};<br>
> +<br>
> +#ifdef __cplusplus<br>
> +}<br>
> +#endif<br>
> +<br>
> +#endif /* RTE_CMAN_H */<br>
> diff --git a/lib/ethdev/rte_ethdev.c b/lib/ethdev/rte_ethdev.c<br>
> index 0c2c1088c0..e4eb17221b 100644<br>
> --- a/lib/ethdev/rte_ethdev.c<br>
> +++ b/lib/ethdev/rte_ethdev.c<br>
> @@ -642,7 +642,7 @@ rte_eth_dev_get_port_by_name(const char *name, uint16_t *port_id)<br>
>        return -ENODEV;<br>
>   }<br>
>   <br>
> -static int<br>
> +int<br>
>   eth_err(uint16_t port_id, int ret)<br>
>   {<br>
>        if (ret == 0)<br>
> diff --git a/lib/ethdev/rte_ethdev.h b/lib/ethdev/rte_ethdev.h<br>
> index a21f58b9cd..8df1cdfad0 100644<br>
> --- a/lib/ethdev/rte_ethdev.h<br>
> +++ b/lib/ethdev/rte_ethdev.h<br>
> @@ -160,6 +160,7 @@ extern "C" {<br>
>   #define RTE_ETHDEV_DEBUG_TX<br>
>   #endif<br>
>   <br>
> +#include <rte_cman.h><br>
>   #include <rte_compat.h><br>
>   #include <rte_log.h><br>
>   #include <rte_interrupts.h><br>
> @@ -5314,6 +5315,169 @@ typedef struct {<br>
>   __rte_experimental<br>
>   int rte_eth_dev_priv_dump(uint16_t port_id, FILE *file);<br>
>   <br>
> +/* Congestion management */<br>
> +<br>
> +/** Enumerate list of ethdev congestion management objects */<br>
> +enum rte_eth_cman_obj {<br>
> +     /** Congestion management based on Rx queue depth */<br>
> +     RTE_ETH_CMAN_OBJ_RX_QUEUE = RTE_BIT32(0),<br>
> +     /**<br>
> +      * Congestion management based on mempool depth associated with Rx queue<br>
> +      * @see rte_eth_rx_queue_setup()<br>
> +      */<br>
> +     RTE_ETH_CMAN_OBJ_RX_QUEUE_MEMPOOL = RTE_BIT32(1),<br>
> +};<br>
> +<br>
> +/**<br>
> + * @warning<br>
> + * @b EXPERIMENTAL: this structure may change, or be removed, without prior notice<br>
> + *<br>
> + * A structure used to retrieve information of ethdev congestion management.<br>
> + */<br>
> +struct rte_eth_cman_info {<br>
> +     /**<br>
> +      * Set of supported congestion management modes<br>
> +      * @see enum rte_cman_mode<br>
> +      */<br>
> +     uint64_t modes_supported;<br>
> +     /**<br>
> +      * Set of supported congestion management objects<br>
> +      * @see enum rte_eth_cman_obj<br>
> +      */<br>
> +     uint64_t objs_supported;<br>
> +     /**<br>
> +      * Reserved for future fields. Always returned as 0 when<br>
> +      * rte_eth_cman_info_get() is invoked<br>
> +      */<br>
> +     uint8_t rsvd[8];<br>
> +};<br>
> +<br>
> +/**<br>
> + * @warning<br>
> + * @b EXPERIMENTAL: this structure may change, or be removed, without prior notice<br>
> + *<br>
> + * A structure used to configure the ethdev congestion management.<br>
> + */<br>
> +struct rte_eth_cman_config {<br>
> +     /** Congestion management object */<br>
> +     enum rte_eth_cman_obj obj;<br>
> +     /** Congestion management mode */<br>
> +     enum rte_cman_mode mode;<br>
> +     union {<br>
> +             /**<br>
> +              * Rx queue to configure congestion management.<br>
> +              *<br>
> +              * Valid when object is RTE_ETH_CMAN_OBJ_RX_QUEUE or<br>
> +              * RTE_ETH_CMAN_OBJ_RX_QUEUE_MEMPOOL.<br>
> +              */<br>
> +             uint16_t rx_queue;<br>
> +             /**<br>
> +              * Reserved for future fields.<br>
> +              * It must be set to 0 when rte_eth_cman_config_set() is invoked<br>
> +              * and will be returned as 0 when rte_eth_cman_config_get() is<br>
> +              * invoked.<br>
> +              */<br>
> +             uint8_t rsvd_obj_params[4];<br>
> +     } obj_param;<br>
> +     union {<br>
> +             /**<br>
> +              * RED configuration parameters.<br>
> +              *<br>
> +              * Valid when mode is RTE_CMAN_RED.<br>
> +              */<br>
> +             struct rte_cman_red_params red;<br>
> +             /**<br>
> +              * Reserved for future fields.<br>
> +              * It must be set to 0 when rte_eth_cman_config_set() is invoked<br>
> +              * and will be returned as 0 when rte_eth_cman_config_get() is<br>
> +              * invoked.<br>
> +              */<br>
> +             uint8_t rsvd_mode_params[4];<br>
> +     } mode_param;<br>
> +};<br>
> +<br>
> +/**<br>
> + * @warning<br>
> + * @b EXPERIMENTAL: this API may change, or be removed, without prior notice<br>
> + *<br>
> + * Retrieve the information for ethdev congestion management<br>
> + *<br>
> + * @param port_id<br>
> + *   The port identifier of the Ethernet device.<br>
> + * @param info<br>
> + *   A pointer to a structure of type *rte_eth_cman_info* to be filled with<br>
> + *   the information about congestion management.<br>
> + * @return<br>
> + *   - (0) if successful.<br>
> + *   - (-ENOTSUP) if support for cman_info_get does not exist.<br>
> + *   - (-ENODEV) if *port_id* invalid.<br>
> + *   - (-EINVAL) if bad parameter.<br>
> + */<br>
> +__rte_experimental<br>
> +int rte_eth_cman_info_get(uint16_t port_id, struct rte_eth_cman_info *info);<br>
> +<br>
> +/**<br>
> + * @warning<br>
> + * @b EXPERIMENTAL: this API may change, or be removed, without prior notice<br>
> + *<br>
> + * Initialize the ethdev congestion management configuration structure with default values.<br>
> + *<br>
> + * @param port_id<br>
> + *   The port identifier of the Ethernet device.<br>
> + * @param config<br>
> + *   A pointer to a structure of type *rte_eth_cman_config* to be initialized<br>
> + *   with default value.<br>
> + * @return<br>
> + *   - (0) if successful.<br>
> + *   - (-ENOTSUP) if support for cman_config_init does not exist.<br>
> + *   - (-ENODEV) if *port_id* invalid.<br>
> + *   - (-EINVAL) if bad parameter.<br>
> + */<br>
> +__rte_experimental<br>
> +int rte_eth_cman_config_init(uint16_t port_id, struct rte_eth_cman_config *config);<br>
> +<br>
> +/**<br>
> + * @warning<br>
> + * @b EXPERIMENTAL: this API may change, or be removed, without prior notice<br>
> + *<br>
> + * Configure ethdev congestion management<br>
> + *<br>
> + * @param port_id<br>
> + *   The port identifier of the Ethernet device.<br>
> + * @param config<br>
> + *   A pointer to a structure of type *rte_eth_cman_config* to be configured.<br>
> + * @return<br>
> + *   - (0) if successful.<br>
> + *   - (-ENOTSUP) if support for cman_config_set does not exist.<br>
> + *   - (-ENODEV) if *port_id* invalid.<br>
> + *   - (-EINVAL) if bad parameter.<br>
> + */<br>
> +__rte_experimental<br>
> +int rte_eth_cman_config_set(uint16_t port_id, const struct rte_eth_cman_config *config);<br>
> +<br>
> +/**<br>
> + * @warning<br>
> + * @b EXPERIMENTAL: this API may change, or be removed, without prior notice<br>
> + *<br>
> + * Retrieve the applied ethdev congestion management parameters for the given port.<br>
> + *<br>
> + * @param port_id<br>
> + *   The port identifier of the Ethernet device.<br>
> + * @param config<br>
> + *   A pointer to a structure of type *rte_eth_cman_config* to retrieve<br>
> + *   congestion management parameters for the given object.<br>
> + *   Application must fill all parameters except mode_param parameter in<br>
> + *   struct rte_eth_cman_config.<br>
> + *<br>
> + * @return<br>
> + *   - (0) if successful.<br>
> + *   - (-ENOTSUP) if support for cman_config_get does not exist.<br>
> + *   - (-ENODEV) if *port_id* invalid.<br>
> + *   - (-EINVAL) if bad parameter.<br>
> + */<br>
> +__rte_experimental<br>
> +int rte_eth_cman_config_get(uint16_t port_id, struct rte_eth_cman_config *config);<br>
> +<br>
>   #include <rte_ethdev_core.h><br>
>   <br>
>   /**<br>
> diff --git a/lib/ethdev/rte_ethdev_cman.c b/lib/ethdev/rte_ethdev_cman.c<br>
> new file mode 100644<br>
> index 0000000000..4a1bdd7bd0<br>
> --- /dev/null<br>
> +++ b/lib/ethdev/rte_ethdev_cman.c<br>
> @@ -0,0 +1,101 @@<br>
> +/* SPDX-License-Identifier: BSD-3-Clause<br>
> + * Copyright(C) 2022 Marvell International Ltd.<br>
> + */<br>
> +<br>
> +#include <stdint.h><br>
> +<br>
> +#include <rte_errno.h><br>
> +#include "rte_ethdev.h"<br>
> +#include "ethdev_driver.h"<br>
> +#include "ethdev_private.h"<br>
> +<br>
> +/* Get congestion management information for a port */<br>
> +int<br>
> +rte_eth_cman_info_get(uint16_t port_id, struct rte_eth_cman_info *info)<br>
> +{<br>
> +     struct rte_eth_dev *dev;<br>
> +<br>
> +     RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);<br>
> +     dev = &rte_eth_devices[port_id];<br>
> +<br>
> +     if (info == NULL) {<br>
> +             RTE_ETHDEV_LOG(ERR, "congestion management info is NULL\n");<br>
> +             return -EINVAL;<br>
> +     }<br>
> +<br>
> +     if (dev->dev_ops->cman_info_get == NULL) {<br>
> +             RTE_ETHDEV_LOG(ERR, "Function not implemented\n");<br>
> +             return -ENOTSUP;<br>
> +     }<br>
> +<br>
> +     memset(info, 0, sizeof(struct rte_eth_cman_info));<br>
> +     return eth_err(port_id, (*dev->dev_ops->cman_info_get)(dev, info));<br>
> +}<br>
> +<br>
> +/* Initialize congestion management structure with default values */<br>
> +int<br>
> +rte_eth_cman_config_init(uint16_t port_id, struct rte_eth_cman_config *config)<br>
> +{<br>
> +     struct rte_eth_dev *dev;<br>
> +<br>
> +     RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);<br>
> +     dev = &rte_eth_devices[port_id];<br>
> +<br>
> +     if (config == NULL) {<br>
> +             RTE_ETHDEV_LOG(ERR, "congestion management config is NULL\n");<br>
> +             return -EINVAL;<br>
> +     }<br>
> +<br>
> +     if (dev->dev_ops->cman_config_init == NULL) {<br>
> +             RTE_ETHDEV_LOG(ERR, "Function not implemented\n");<br>
> +             return -ENOTSUP;<br>
> +     }<br>
> +<br>
> +     memset(config, 0, sizeof(struct rte_eth_cman_config));<br>
> +     return eth_err(port_id, (*dev->dev_ops->cman_config_init)(dev, config));<br>
> +}<br>
> +<br>
> +/* Configure congestion management on a port */<br>
> +int<br>
> +rte_eth_cman_config_set(uint16_t port_id, const struct rte_eth_cman_config *config)<br>
> +{<br>
> +     struct rte_eth_dev *dev;<br>
> +<br>
> +     RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);<br>
> +     dev = &rte_eth_devices[port_id];<br>
> +<br>
> +     if (config == NULL) {<br>
> +             RTE_ETHDEV_LOG(ERR, "congestion management config is NULL\n");<br>
> +             return -EINVAL;<br>
> +     }<br>
> +<br>
> +     if (dev->dev_ops->cman_config_set == NULL) {<br>
> +             RTE_ETHDEV_LOG(ERR, "Function not implemented\n");<br>
> +             return -ENOTSUP;<br>
> +     }<br>
> +<br>
> +     return eth_err(port_id, (*dev->dev_ops->cman_config_set)(dev, config));<br>
> +}<br>
> +<br>
> +/* Retrieve congestion management configuration of a port */<br>
> +int<br>
> +rte_eth_cman_config_get(uint16_t port_id, struct rte_eth_cman_config *config)<br>
> +{<br>
> +     struct rte_eth_dev *dev;<br>
> +<br>
> +     RTE_ETH_VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);<br>
> +     dev = &rte_eth_devices[port_id];<br>
> +<br>
> +     if (config == NULL) {<br>
> +             RTE_ETHDEV_LOG(ERR, "congestion management config is NULL\n");<br>
> +             return -EINVAL;<br>
> +     }<br>
> +<br>
> +     if (dev->dev_ops->cman_config_get == NULL) {<br>
> +             RTE_ETHDEV_LOG(ERR, "Function not implemented\n");<br>
> +             return -ENOTSUP;<br>
> +     }<br>
> +<br>
> +     memset(config, 0, sizeof(struct rte_eth_cman_config));<br>
> +     return eth_err(port_id, (*dev->dev_ops->cman_config_get)(dev, config));<br>
> +}<br>
> diff --git a/lib/ethdev/version.map b/lib/ethdev/version.map<br>
> index 3651ceb234..857d21be1c 100644<br>
> --- a/lib/ethdev/version.map<br>
> +++ b/lib/ethdev/version.map<br>
> @@ -287,6 +287,10 @@ EXPERIMENTAL {<br>
>        rte_mtr_meter_vlan_table_update;<br>
>   <br>
>        # added in 22.11<br>
> +     rte_eth_cman_config_get;<br>
> +     rte_eth_cman_config_init;<br>
> +     rte_eth_cman_config_set;<br>
> +     rte_eth_cman_info_get;<br>
>        rte_flow_async_action_handle_query;<br>
>        rte_mtr_meter_policy_get;<br>
>        rte_mtr_meter_profile_get;<br>
<br>
</div>
</span></font></div>
</body>
</html>