DPDK patches and discussions
 help / color / mirror / Atom feed
From: Jie Hai <haijie1@huawei.com>
To: <dev@dpdk.org>, Thomas Monjalon <thomas@monjalon.net>,
	Ferruh Yigit <ferruh.yigit@amd.com>,
	Andrew Rybchenko <andrew.rybchenko@oktetlabs.ru>
Cc: <haijie1@huawei.com>, <lihuisong@huawei.com>
Subject: [PATCH 2/4] ethdev: add telemetry command for TM capabilities
Date: Wed, 18 Oct 2023 09:39:35 +0800	[thread overview]
Message-ID: <20231018013938.3830742-3-haijie1@huawei.com> (raw)
In-Reply-To: <20231018013938.3830742-1-haijie1@huawei.com>

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 <haijie1@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


  parent reply	other threads:[~2023-10-18  1:43 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-18  1:39 [PATCH 0/4] add telemetry commands " Jie Hai
2023-10-18  1:39 ` [PATCH 1/4] net/hns3: fix a typo Jie Hai
2023-10-18 11:32   ` lihuisong (C)
2023-10-27  6:20     ` Jie Hai
2023-10-18  1:39 ` Jie Hai [this message]
2023-10-18  1:39 ` [PATCH 3/4] ethdev: add telemetry command for TM level capabilities Jie Hai
2023-10-18  1:39 ` [PATCH 4/4] ethdev: add telemetry command for TM node capabilities Jie Hai
2023-10-18 10:50 ` [PATCH 0/4] add telemetry commands for TM capabilities fengchengwen
2023-10-25  1:47 ` Jie Hai
2023-10-31 15:30 ` Ferruh Yigit

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231018013938.3830742-3-haijie1@huawei.com \
    --to=haijie1@huawei.com \
    --cc=andrew.rybchenko@oktetlabs.ru \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@amd.com \
    --cc=lihuisong@huawei.com \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).