diff options
| author | Bruce Richardson <[email protected]> | 2024-10-09 11:32:08 +0100 |
|---|---|---|
| committer | Ferruh Yigit <[email protected]> | 2024-10-12 02:27:26 +0200 |
| commit | 25a2a0dc3de31ca0a6fbc9371cf3dd85dfd74b07 (patch) | |
| tree | bbb5a8991abd1df96efe2c2cabf9d9a65a0e7337 /lib/ethdev | |
| parent | ebb45428f493df4aed55ac3b31bf6c98de71162e (diff) | |
ethdev: add traffic manager query
Add function to allow querying a node in the scheduler tree. Returns
the parameters as were given to the add function. Adding this function
allows apps to just query the hierarchy rather than having to maintain
their own copies of it internally.
It is used in testpmd to print out details about previously added TM nodes.
Example output, configuring three nodes, and then printing the details:
testpmd> add port tm nonleaf node 0 100 -1 0 1 0 -1 1 0 0
testpmd> add port tm nonleaf node 0 90 100 0 1 1 -1 1 0 0
testpmd> add port tm leaf node 0 0 90 0 1 2 -1 0 0xffffffff 0 0
testpmd>
testpmd> show port tm node 0 100
Port 0 TM Node 100
Parent Node ID: <NULL>
Level ID: 0
Priority: 0
Weight: 0
Shaper Profile ID: <none>
Shared Shaper IDs: <none>
Stats Mask: 0
Nonleaf Node Parameters
Num Strict Priorities: 1
WFQ Weights Mode: WFQ
testpmd> show port tm node 0 90
Port 0 TM Node 90
Parent Node ID: 100
Level ID: 1
Priority: 0
Weight: 1
Shaper Profile ID: <none>
Shared Shaper IDs: <none>
Stats Mask: 0
Nonleaf Node Parameters
Num Strict Priorities: 1
WFQ Weights Mode: WFQ
testpmd> show port tm node 0 0
Port 0 TM Node 0
Parent Node ID: 90
Level ID: 2
Priority: 0
Weight: 1
Shaper Profile ID: <none>
Shared Shaper IDs: <none>
Stats Mask: 0
Leaf Node Parameters
CMAN Mode: Tail Drop
WRED Profile ID: <none>
Shared WRED Context Ids: <none>
Signed-off-by: Bruce Richardson <[email protected]>
Acked-by: Ferruh Yigit <[email protected]>
Acked-by: Chengwen Feng <[email protected]>
Diffstat (limited to 'lib/ethdev')
| -rw-r--r-- | lib/ethdev/ethdev_trace.h | 16 | ||||
| -rw-r--r-- | lib/ethdev/ethdev_trace_points.c | 3 | ||||
| -rw-r--r-- | lib/ethdev/rte_tm.c | 22 | ||||
| -rw-r--r-- | lib/ethdev/rte_tm.h | 50 | ||||
| -rw-r--r-- | lib/ethdev/rte_tm_driver.h | 12 | ||||
| -rw-r--r-- | lib/ethdev/version.map | 1 |
6 files changed, 104 insertions, 0 deletions
diff --git a/lib/ethdev/ethdev_trace.h b/lib/ethdev/ethdev_trace.h index e96213365d..5951ae2d99 100644 --- a/lib/ethdev/ethdev_trace.h +++ b/lib/ethdev/ethdev_trace.h @@ -1906,6 +1906,22 @@ RTE_TRACE_POINT( ) RTE_TRACE_POINT( + rte_tm_trace_node_query, + RTE_TRACE_POINT_ARGS(uint16_t port_id, uint32_t node_id, + uint32_t *parent_node_id, uint32_t *priority, + uint32_t *weight, uint32_t *level_id, + struct rte_tm_node_params *params, int ret), + rte_trace_point_emit_u16(port_id); + rte_trace_point_emit_u32(node_id); + rte_trace_point_emit_ptr(parent_node_id); + rte_trace_point_emit_ptr(priority); + rte_trace_point_emit_ptr(weight); + rte_trace_point_emit_ptr(level_id); + rte_trace_point_emit_ptr(params); + rte_trace_point_emit_int(ret); +) + +RTE_TRACE_POINT( rte_tm_trace_node_delete, RTE_TRACE_POINT_ARGS(uint16_t port_id, uint32_t node_id, int ret), rte_trace_point_emit_u16(port_id); diff --git a/lib/ethdev/ethdev_trace_points.c b/lib/ethdev/ethdev_trace_points.c index 1f6ce341bf..cb99cf91fc 100644 --- a/lib/ethdev/ethdev_trace_points.c +++ b/lib/ethdev/ethdev_trace_points.c @@ -709,6 +709,9 @@ RTE_TRACE_POINT_REGISTER(rte_tm_trace_mark_vlan_dei, RTE_TRACE_POINT_REGISTER(rte_tm_trace_node_add, lib.ethdev.tm.node_add) +RTE_TRACE_POINT_REGISTER(rte_tm_trace_node_query, + lib.ethdev.tm.node_query) + RTE_TRACE_POINT_REGISTER(rte_tm_trace_node_capabilities_get, lib.ethdev.tm.node_capabilities_get) diff --git a/lib/ethdev/rte_tm.c b/lib/ethdev/rte_tm.c index 3eb98e618a..347dbb81f9 100644 --- a/lib/ethdev/rte_tm.c +++ b/lib/ethdev/rte_tm.c @@ -301,6 +301,28 @@ int rte_tm_node_add(uint16_t port_id, return ret; } +int rte_tm_node_query(uint16_t port_id, + uint32_t node_id, + uint32_t *parent_node_id, + uint32_t *priority, + uint32_t *weight, + uint32_t *level_id, + struct rte_tm_node_params *params, + struct rte_tm_error *error) +{ + struct rte_eth_dev *dev = &rte_eth_devices[port_id]; + int ret; + + ret = RTE_TM_FUNC(port_id, node_query)(dev, + node_id, parent_node_id, priority, weight, level_id, + params, error); + + rte_tm_trace_node_query(port_id, node_id, parent_node_id, priority, + weight, level_id, params, ret); + + return ret; +} + /* Delete node from traffic manager hierarchy */ int rte_tm_node_delete(uint16_t port_id, uint32_t node_id, diff --git a/lib/ethdev/rte_tm.h b/lib/ethdev/rte_tm.h index e5da9b8323..c9dd760858 100644 --- a/lib/ethdev/rte_tm.h +++ b/lib/ethdev/rte_tm.h @@ -20,6 +20,7 @@ #include <rte_common.h> #include <rte_meter.h> +#include <rte_compat.h> #ifdef __cplusplus extern "C" { @@ -1600,6 +1601,55 @@ rte_tm_node_add(uint16_t port_id, struct rte_tm_error *error); /** + * Return information about a traffic management node + * + * Return information about a hierarchy node, using the same format of parameters + * as was passed to the rte_rm_node_add() function. + * Each of the "out" parameters pointers (except error) may be passed as NULL if the + * information is not needed by the caller. For example, to one may check if a node id + * is in use by: + * + * struct rte_tm_error error; + * int ret = rte_tm_node_query(port, node_id, NULL, NULL, NULL, NULL, NULL, &error); + * if (ret == ENOENT) ... + * + * @param[in] port_id + * The port identifier of the Ethernet device. + * @param[in] node_id + * Node ID. Should be a valid node id. + * @param[out] parent_node_id + * Parent node ID. + * @param[out] priority + * Node priority. The highest node priority is zero. Used by the SP algorithm + * running on the parent of the current node for scheduling this child node. + * @param[out] weight + * Node weight. The node weight is relative to the weight sum of all siblings + * that have the same priority. The lowest weight is one. Used by the WFQ + * algorithm running on the parent of the current node for scheduling this + * child node. + * @param[out] level_id + * The node level in the scheduler hierarchy. + * @param[out] params + * Node parameters, as would be used when creating the node. + * @param[out] error + * Error details. Filled in only on error. Must not be NULL. + * @return + * 0 on success, non-zero error code otherwise. + * -EINVAL - port or node id value is invalid + * -ENOENT - no node exists with the provided id on the provided port + */ +__rte_experimental +int +rte_tm_node_query(uint16_t port_id, + uint32_t node_id, + uint32_t *parent_node_id, + uint32_t *priority, + uint32_t *weight, + uint32_t *level_id, + struct rte_tm_node_params *params, + struct rte_tm_error *error); + +/** * Traffic manager node delete * * Delete an existing node. This operation fails when this node currently has diff --git a/lib/ethdev/rte_tm_driver.h b/lib/ethdev/rte_tm_driver.h index 6c2618c0d8..ddac78cb28 100644 --- a/lib/ethdev/rte_tm_driver.h +++ b/lib/ethdev/rte_tm_driver.h @@ -119,6 +119,16 @@ typedef int (*rte_tm_node_resume_t)(struct rte_eth_dev *dev, uint32_t node_id, struct rte_tm_error *error); +/** @internal Traffic manager node query */ +typedef int (*rte_tm_node_query_t)(const struct rte_eth_dev *dev, + uint32_t node_id, + uint32_t *parent_node_id, + uint32_t *priority, + uint32_t *weight, + uint32_t *level_id, + struct rte_tm_node_params *params, + struct rte_tm_error *error); + /** @internal Traffic manager hierarchy commit */ typedef int (*rte_tm_hierarchy_commit_t)(struct rte_eth_dev *dev, int clear_on_fail, @@ -248,6 +258,8 @@ struct rte_tm_ops { rte_tm_node_suspend_t node_suspend; /** Traffic manager node resume */ rte_tm_node_resume_t node_resume; + /** Traffic manager node query */ + rte_tm_node_query_t node_query; /** Traffic manager hierarchy commit */ rte_tm_hierarchy_commit_t hierarchy_commit; diff --git a/lib/ethdev/version.map b/lib/ethdev/version.map index d42966ec85..12f48c70a0 100644 --- a/lib/ethdev/version.map +++ b/lib/ethdev/version.map @@ -336,6 +336,7 @@ EXPERIMENTAL { rte_eth_speed_lanes_set; rte_eth_timesync_adjust_freq; rte_flow_async_create_by_index_with_pattern; + rte_tm_node_query; }; INTERNAL { |
