This patch adds a telemetry command for traffic management capabilities. An example usage is shown below:
--> /ethdev/tm_capability,0 { "/ethdev/tm_capability": { "n_nodes_max": 265, "n_levels_max": 3, "non_leaf_nodes_identical": 1, "leaf_nodes_identical": 1, "shaper_n_max": 9, "shaper_private_n_max": 9, "shaper_private_dual_rate_n_max": 0, "shaper_private_rate_min": 0, "shaper_private_rate_max": 25000000000, "shaper_private_packet_mode_supported": 0, "shaper_private_byte_mode_supported": 0, "shaper_shared_n_max": 0, "shaper_shared_n_nodes_per_shaper_max": 0, "shaper_shared_n_shapers_per_node_max": 0, "shaper_share_dual_rate_n_max": 0, "shaper_shared_rate_min": 0, "shaper_shared_rate_max": 0, "shaper_shared_packet_mode_supported": 0, "shaper_shared_byte_mode_supported": 0, "shaper_pkt_length_adjust_min": 20, "shaper_pkt_length_adjust_max": 24, "sched_n_children_max": 256, "sched_sp_n_priorities_max": 1, "sched_wfq_n_children_per_group_max": 0, "sched_wfq_n_groups_max": 0, "sched_wfq_weight_max": 1, "sched_wfq_packet_mode_supported": 0, "sched_wfq_byte_mode_supported": 0, "cman_wred_packet_mode_supported": 0, "cman_wred_byte_mode_supported": 0, "cman_head_drop_supported": 0, "cman_wred_context_n_max": 0, "cman_wred_context_private_n_max": 0, "cman_wred_context_shared_n_max": 0, "cman_wred_context_shared_n_nodes_per_context_max": 0, "cman_wred_context_shared_n_contexts_per_node_max": 0, "dynamic_update": "0x0", "stats_mask": "0x0" } } Signed-off-by: Jie Hai <haij...@huawei.com> --- lib/ethdev/rte_ethdev_telemetry.c | 108 ++++++++++++++++++++++++++++++ 1 file changed, 108 insertions(+) diff --git a/lib/ethdev/rte_ethdev_telemetry.c b/lib/ethdev/rte_ethdev_telemetry.c index f246a03e2966..02d23486806e 100644 --- a/lib/ethdev/rte_ethdev_telemetry.c +++ b/lib/ethdev/rte_ethdev_telemetry.c @@ -11,6 +11,7 @@ #include "rte_ethdev.h" #include "ethdev_driver.h" #include "sff_telemetry.h" +#include "rte_tm.h" static const struct { uint32_t capa; @@ -1021,6 +1022,111 @@ eth_dev_handle_port_vlan(const char *cmd __rte_unused, return eth_dev_add_vlan_id(port_id, d); } +static void +eth_dev_add_tm_caps(struct rte_tel_data *d, struct rte_tm_capabilities *cap) +{ + rte_tel_data_add_dict_uint(d, "n_nodes_max", cap->n_nodes_max); + rte_tel_data_add_dict_uint(d, "n_levels_max", cap->n_levels_max); + rte_tel_data_add_dict_int(d, "non_leaf_nodes_identical", + cap->non_leaf_nodes_identical); + rte_tel_data_add_dict_int(d, "leaf_nodes_identical", + cap->leaf_nodes_identical); + rte_tel_data_add_dict_uint(d, "shaper_n_max", cap->shaper_n_max); + rte_tel_data_add_dict_uint(d, "shaper_private_n_max", + cap->shaper_private_n_max); + rte_tel_data_add_dict_int(d, "shaper_private_dual_rate_n_max", + cap->shaper_private_dual_rate_n_max); + rte_tel_data_add_dict_uint(d, "shaper_private_rate_min", + cap->shaper_private_rate_min); + rte_tel_data_add_dict_uint(d, "shaper_private_rate_max", + cap->shaper_private_rate_max); + rte_tel_data_add_dict_int(d, "shaper_private_packet_mode_supported", + cap->shaper_private_packet_mode_supported); + rte_tel_data_add_dict_int(d, "shaper_private_byte_mode_supported", + cap->shaper_private_byte_mode_supported); + rte_tel_data_add_dict_uint(d, "shaper_shared_n_max", + cap->shaper_shared_n_max); + rte_tel_data_add_dict_uint(d, "shaper_shared_n_nodes_per_shaper_max", + cap->shaper_shared_n_nodes_per_shaper_max); + rte_tel_data_add_dict_uint(d, "shaper_shared_n_shapers_per_node_max", + cap->shaper_shared_n_shapers_per_node_max); + rte_tel_data_add_dict_uint(d, "shaper_share_dual_rate_n_max", + cap->shaper_shared_dual_rate_n_max); + rte_tel_data_add_dict_uint(d, "shaper_shared_rate_min", + cap->shaper_shared_rate_min); + rte_tel_data_add_dict_uint(d, "shaper_shared_rate_max", + cap->shaper_shared_rate_max); + rte_tel_data_add_dict_int(d, "shaper_shared_packet_mode_supported", + cap->shaper_shared_packet_mode_supported); + rte_tel_data_add_dict_int(d, "shaper_shared_byte_mode_supported", + cap->shaper_shared_byte_mode_supported); + rte_tel_data_add_dict_int(d, "shaper_pkt_length_adjust_min", + cap->shaper_pkt_length_adjust_min); + rte_tel_data_add_dict_int(d, "shaper_pkt_length_adjust_max", + cap->shaper_pkt_length_adjust_max); + rte_tel_data_add_dict_uint(d, "sched_n_children_max", + cap->sched_n_children_max); + rte_tel_data_add_dict_uint(d, "sched_sp_n_priorities_max", + cap->sched_sp_n_priorities_max); + rte_tel_data_add_dict_uint(d, "sched_wfq_n_children_per_group_max", + cap->sched_wfq_n_children_per_group_max); + rte_tel_data_add_dict_uint(d, "sched_wfq_n_groups_max", + cap->sched_wfq_n_groups_max); + rte_tel_data_add_dict_uint(d, "sched_wfq_weight_max", + cap->sched_wfq_weight_max); + rte_tel_data_add_dict_int(d, "sched_wfq_packet_mode_supported", + cap->sched_wfq_packet_mode_supported); + rte_tel_data_add_dict_int(d, "sched_wfq_byte_mode_supported", + cap->sched_wfq_byte_mode_supported); + rte_tel_data_add_dict_int(d, "cman_wred_packet_mode_supported", + cap->cman_wred_packet_mode_supported); + rte_tel_data_add_dict_int(d, "cman_wred_byte_mode_supported", + cap->cman_wred_byte_mode_supported); + rte_tel_data_add_dict_int(d, "cman_head_drop_supported", + cap->cman_head_drop_supported); + rte_tel_data_add_dict_uint(d, "cman_wred_context_n_max", + cap->cman_wred_context_n_max); + rte_tel_data_add_dict_uint(d, "cman_wred_context_private_n_max", + cap->cman_wred_context_private_n_max); + rte_tel_data_add_dict_uint(d, "cman_wred_context_shared_n_max", + cap->cman_wred_context_shared_n_max); + rte_tel_data_add_dict_uint(d, "cman_wred_context_shared_n_nodes_per_context_max", + cap->cman_wred_context_shared_n_nodes_per_context_max); + rte_tel_data_add_dict_uint(d, "cman_wred_context_shared_n_contexts_per_node_max", + cap->cman_wred_context_shared_n_contexts_per_node_max); + rte_tel_data_add_dict_uint_hex(d, "dynamic_update", cap->dynamic_update_mask, 0); + rte_tel_data_add_dict_uint_hex(d, "stats_mask", cap->stats_mask, 0); +} + +static int +eth_dev_handle_port_tm_caps(const char *cmd __rte_unused, + const char *params, + struct rte_tel_data *d) +{ + struct rte_tm_capabilities cap = {0}; + struct rte_tm_error error = {0}; + uint16_t port_id; + char *end_param; + int ret; + + ret = eth_dev_parse_port_params(params, &port_id, &end_param, false); + if (ret != 0) + return ret; + + ret = rte_tm_capabilities_get(port_id, &cap, &error); + if (ret != 0) { + RTE_ETHDEV_LOG(ERR, "error: %s, error type: %u\n", + error.message ? error.message : "no stated reason", + error.type); + return ret; + } + + rte_tel_data_start_dict(d); + eth_dev_add_tm_caps(d, &cap); + + return 0; +} + RTE_INIT(ethdev_init_telemetry) { rte_telemetry_register_cmd("/ethdev/list", eth_dev_handle_port_list, @@ -1056,4 +1162,6 @@ RTE_INIT(ethdev_init_telemetry) "Returns FEC info for a port. Parameters: int port_id"); rte_telemetry_register_cmd("/ethdev/vlan", eth_dev_handle_port_vlan, "Returns VLAN info for a port. Parameters: int port_id"); + rte_telemetry_register_cmd("/ethdev/tm_capability", eth_dev_handle_port_tm_caps, + "Returns TM Capabilities info for a port. Parameters: int port_id"); } -- 2.30.0