From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 0958837AF for ; Mon, 13 Aug 2018 09:53:25 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 13 Aug 2018 00:53:25 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,232,1531810800"; d="scan'208";a="248355313" Received: from dpdkx8602.sh.intel.com ([10.67.110.200]) by orsmga005.jf.intel.com with ESMTP; 13 Aug 2018 00:53:23 -0700 From: Rosen Xu To: dev@dpdk.org Cc: cristian.dumitrescu@intel.com, wenzhuo.lu@intel.com, jasvinder.singh@intel.com, rosen.xu@intel.com, ferruh.yigit@intel.com Date: Mon, 13 Aug 2018 15:53:32 +0800 Message-Id: <1534146812-120570-1-git-send-email-rosen.xu@intel.com> X-Mailer: git-send-email 1.8.3.1 Subject: [dpdk-dev] [RFC] ethdev: add tail drop API for traffic management X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Aug 2018 07:53:26 -0000 This patch introduces new ethdev generic Tail Drop API for Traffic Management, which is yet another standard congestion management offload for Ethernet devices. Tail Drop is about packets dropping when they arrive on a congested interface buffer. It's one mode of congestion management for hierarchy leaf nodes. There are two configuration parameters for Tail Drop: 1. Buffer Depth: determine the depth of receive fifo for packet RX. 2. Drop Threshold: water line of receive fifo to judge whether the current received packet dropped or enqueue. Signed-off-by: Rosen Xu --- lib/librte_ethdev/rte_tm.c | 42 ++++++++++ lib/librte_ethdev/rte_tm.h | 172 ++++++++++++++++++++++++++++++++++++++ lib/librte_ethdev/rte_tm_driver.h | 35 ++++++++ 3 files changed, 249 insertions(+) diff --git a/lib/librte_ethdev/rte_tm.c b/lib/librte_ethdev/rte_tm.c index 9709454..89a7dec 100644 --- a/lib/librte_ethdev/rte_tm.c +++ b/lib/librte_ethdev/rte_tm.c @@ -168,6 +168,48 @@ int rte_tm_shared_wred_context_delete(uint16_t port_id, shared_wred_context_id, error); } +/* Add Tail Drop profile */ +int rte_tm_tdrop_profile_add(uint16_t port_id, + uint32_t tdrop_profile_id, + struct rte_tm_tdrop_params *profile, + struct rte_tm_error *error) +{ + struct rte_eth_dev *dev = &rte_eth_devices[port_id]; + return RTE_TM_FUNC(port_id, tdrop_profile_add)(dev, + tdrop_profile_id, profile, error); +} + +/* Delete Tail Drop profile */ +int rte_tm_tdrop_profile_delete(uint16_t port_id, + uint32_t tdrop_profile_id, + struct rte_tm_error *error) +{ + struct rte_eth_dev *dev = &rte_eth_devices[port_id]; + return RTE_TM_FUNC(port_id, tdrop_profile_delete)(dev, + tdrop_profile_id, error); +} + +/* Add/update shared Tail Drop context */ +int rte_tm_shared_tdrop_context_add_update(uint16_t port_id, + uint32_t shared_tdrop_context_id, + uint32_t tdrop_profile_id, + struct rte_tm_error *error) +{ + struct rte_eth_dev *dev = &rte_eth_devices[port_id]; + return RTE_TM_FUNC(port_id, shared_tdrop_context_add_update)(dev, + shared_tdrop_context_id, tdrop_profile_id, error); +} + +/* Delete shared Tail Drop context */ +int rte_tm_shared_tdrop_context_delete(uint16_t port_id, + uint32_t shared_tdrop_context_id, + struct rte_tm_error *error) +{ + struct rte_eth_dev *dev = &rte_eth_devices[port_id]; + return RTE_TM_FUNC(port_id, shared_tdrop_context_delete)(dev, + shared_tdrop_context_id, error); +} + /* Add shaper profile */ int rte_tm_shaper_profile_add(uint16_t port_id, uint32_t shaper_profile_id, diff --git a/lib/librte_ethdev/rte_tm.h b/lib/librte_ethdev/rte_tm.h index 955f02f..91b087d 100644 --- a/lib/librte_ethdev/rte_tm.h +++ b/lib/librte_ethdev/rte_tm.h @@ -93,6 +93,15 @@ #define RTE_TM_WRED_PROFILE_ID_NONE UINT32_MAX /** + * Invalid TDROP profile ID. + * + * @see struct rte_tm_node_params + * @see rte_tm_node_add() + * @see rte_tm_node_tdrop_context_update() + */ +#define RTE_TM_TDROP_PROFILE_ID_NONE UINT32_MAX + +/** *Invalid shaper profile ID. * * @see struct rte_tm_node_params @@ -871,6 +880,37 @@ struct rte_tm_wred_params { }; /** + * Tail Drop (TDROP) profile + * + * Multiple TDROP contexts can share the same TDROP profile. Each leaf node with + * TDROP enabled as its congestion management mode has zero or one private TDROP + * context (only one leaf node using it) and/or zero, one or several shared + * TDROP contexts (multiple leaf nodes use the same TDROP context). A private + * TDROP context is used to perform congestion management for a single leaf + * node, while a shared TDROP context is used to perform congestion management + * for a group of leaf nodes. + * + * @see struct rte_tm_capabilities::cman_tdrop_packet_mode_supported + * @see struct rte_tm_capabilities::cman_tdrop_byte_mode_supported + */ +struct rte_tm_tdrop_params { + /** Committed queue length (in bytes) */ + uint64_t committed_length; + + /** Peak queue length (in bytes) */ + uint64_t peak_length; + + /** Drop threshold of queue */ + uint64_t drop_th; + + /** When non-zero, the *drop_th* threshold is specified + * in packets (TDROP packet mode). When zero, the *drop_th* + * threshold is specified in bytes (TDROP byte mode) + */ + int packet_mode; +}; + +/** * Token bucket */ struct rte_tm_token_bucket { @@ -1000,6 +1040,32 @@ struct rte_tm_node_params { */ uint32_t n_shared_wred_contexts; } wred; + + /** TDROP parameters (only valid when *cman* is set to + * TDROP). + */ + struct { + /** TDROP profile for private TDROP context. The + * absence of a private TDROP context for the + * current leaf node is indicated by value + * RTE_TM_TDROP_PROFILE_ID_NONE. + */ + uint32_t tdrop_profile_id; + + /** User allocated array of shared TDROP context + * IDs. When set to NULL, it indicates that the + * current leaf node should not currently be + * part of any shared TDROP contexts. + */ + uint32_t *shared_tdrop_context_id; + + /** Number of elements in the + * *shared_tdrop_context_id* array. Only valid + * when *shared_tdrop_context_id* is non-NULL, + * in which case it should be non-zero. + */ + uint32_t n_shared_tdrop_contexts; + } tdrop; } leaf; }; @@ -1028,6 +1094,8 @@ enum rte_tm_error_type { RTE_TM_ERROR_TYPE_WRED_PROFILE_YELLOW, RTE_TM_ERROR_TYPE_WRED_PROFILE_RED, RTE_TM_ERROR_TYPE_WRED_PROFILE_ID, + RTE_TM_ERROR_TYPE_TDROP_PROFILE, + RTE_TM_ERROR_TYPE_TDROP_PROFILE_ID, RTE_TM_ERROR_TYPE_SHARED_WRED_CONTEXT_ID, RTE_TM_ERROR_TYPE_SHAPER_PROFILE, RTE_TM_ERROR_TYPE_SHAPER_PROFILE_COMMITTED_RATE, @@ -1279,6 +1347,110 @@ struct rte_tm_error { struct rte_tm_error *error); /** + * Traffic manager Tail Drop profile add + * + * Create a new Tail Drop profile with ID set to *tdrop_profile_id*. + * The new profile is used to create one or several Tail Drop contexts. + * + * @param[in] port_id + * The port identifier of the Ethernet device. + * @param[in] tdrop_profile_id + * Tail Drop profile ID for the new profile. Needs to be unused. + * @param[in] profile + * Tail Drop 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. + * + * @see struct rte_tm_capabilities::cman_tdrop_context_n_max + */ +int +rte_tm_tdrop_profile_add(uint16_t port_id, + uint32_t tdrop_profile_id, + struct rte_tm_tdrop_params *profile, + struct rte_tm_error *error); + +/** + * Traffic manager Tail Drop profile delete + * + * Delete an existing Tail Drop profile. This operation fails when there is + * currently at least one user (i.e. Tail Drop context) of this Tail Drop + * profile. + * + * @param[in] port_id + * The port identifier of the Ethernet device. + * @param[in] tdrop_profile_id + * Tail Drop profile ID. Needs to be the valid. + * @param[out] error + * Error details. Filled in only on error, when not NULL. + * @return + * 0 on success, non-zero error code otherwise. + * + * @see struct rte_tm_capabilities::cman_tdrop_context_n_max + */ +int +rte_tm_tdrop_profile_delete(uint16_t port_id, + uint32_t tdrop_profile_id, + struct rte_tm_error *error); + +/** + * Traffic manager shared Tail Drop context add or update + * + * When *shared_tdrop_context_id* is invalid, a new Tail Drop context with + * this ID is created by using the Tail Drop profile identified by + * *tdrop_profile_id*. + * + * When *shared_tdrop_context_id* is valid, this Tail Drop context is no + * longer using the profile previously assigned to it and is updated to + * use the profile identified by *tdrop_profile_id*. + * + * A valid shared Tail Drop context can be assigned to several hierarchy + * leaf nodes configured to use Tail Drop as the congestion management mode. + * + * @param[in] port_id + * The port identifier of the Ethernet device. + * @param[in] shared_tdrop_context_id + * Shared Tail Drop context ID + * @param[in] tdrop_profile_id + * Tail Drop profile ID. Needs to be the valid. + * @param[out] error + * Error details. Filled in only on error, when not NULL. + * @return + * 0 on success, non-zero error code otherwise. + * + * @see struct rte_tm_capabilities::cman_tdrop_context_shared_n_max + */ +int +rte_tm_shared_tdrop_context_add_update(uint16_t port_id, + uint32_t shared_tdrop_context_id, + uint32_t tdrop_profile_id, + struct rte_tm_error *error); + +/** + * Traffic manager shared Tail Drop context delete + * + * Delete an existing shared Tail Drop context. This operation fails when + * there is currently at least one user (i.e. hierarchy leaf node) of this + * shared Tail Drop context. + * + * @param[in] port_id + * The port identifier of the Ethernet device. + * @param[in] shared_tdrop_context_id + * Shared Tail Drop context ID. Needs to be the valid. + * @param[out] error + * Error details. Filled in only on error, when not NULL. + * @return + * 0 on success, non-zero error code otherwise. + * + * @see struct rte_tm_capabilities::cman_tdrop_context_shared_n_max + */ +int +rte_tm_shared_tdrop_context_delete(uint16_t port_id, + uint32_t shared_tdrop_context_id, + struct rte_tm_error *error); + +/** * Traffic manager shaper profile add * * Create a new shaper profile with ID set to *shaper_profile_id*. The new diff --git a/lib/librte_ethdev/rte_tm_driver.h b/lib/librte_ethdev/rte_tm_driver.h index 90114ff..c0ca916 100644 --- a/lib/librte_ethdev/rte_tm_driver.h +++ b/lib/librte_ethdev/rte_tm_driver.h @@ -71,6 +71,30 @@ typedef int (*rte_tm_shared_wred_context_delete_t)( uint32_t shared_wred_context_id, struct rte_tm_error *error); +/** @internal Traffic manager TDROP profile add */ +typedef int (*rte_tm_tdrop_profile_add_t)(struct rte_eth_dev *dev, + uint32_t tdrop_profile_id, + struct rte_tm_tdrop_params *profile, + struct rte_tm_error *error); + +/** @internal Traffic manager TDROP profile delete */ +typedef int (*rte_tm_tdrop_profile_delete_t)(struct rte_eth_dev *dev, + uint32_t tdrop_profile_id, + struct rte_tm_error *error); + +/** @internal Traffic manager shared TDROP context add */ +typedef int (*rte_tm_shared_tdrop_context_add_update_t)( + struct rte_eth_dev *dev, + uint32_t shared_tdrop_context_id, + uint32_t tdrop_profile_id, + struct rte_tm_error *error); + +/** @internal Traffic manager shared TDROP context delete */ +typedef int (*rte_tm_shared_tdrop_context_delete_t)( + struct rte_eth_dev *dev, + uint32_t shared_tdrop_context_id, + struct rte_tm_error *error); + /** @internal Traffic manager shaper profile add */ typedef int (*rte_tm_shaper_profile_add_t)(struct rte_eth_dev *dev, uint32_t shaper_profile_id, @@ -230,6 +254,17 @@ struct rte_tm_ops { rte_tm_shared_wred_context_delete_t shared_wred_context_delete; + /** Traffic manager TDROP profile add */ + rte_tm_tdrop_profile_add_t tdrop_profile_add; + /** Traffic manager TDROP profile delete */ + rte_tm_tdrop_profile_delete_t tdrop_profile_delete; + /** Traffic manager shared TDROP context add/update */ + rte_tm_shared_tdrop_context_add_update_t + shared_tdrop_context_add_update; + /** Traffic manager shared TDROP context delete */ + rte_tm_shared_tdrop_context_delete_t + shared_tdrop_context_delete; + /** Traffic manager shaper profile add */ rte_tm_shaper_profile_add_t shaper_profile_add; /** Traffic manager shaper profile delete */ -- 1.8.3.1