From patchwork Wed Oct 18 01:39:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jie Hai X-Patchwork-Id: 132823 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 72C4443192; Wed, 18 Oct 2023 03:43:27 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 3074540151; Wed, 18 Oct 2023 03:43:27 +0200 (CEST) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id 9B8634003C for ; Wed, 18 Oct 2023 03:43:25 +0200 (CEST) Received: from kwepemi500020.china.huawei.com (unknown [172.30.72.56]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4S9D5W1v3RzvPsx for ; Wed, 18 Oct 2023 09:38:39 +0800 (CST) Received: from localhost.localdomain (10.67.165.2) by kwepemi500020.china.huawei.com (7.221.188.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Wed, 18 Oct 2023 09:43:23 +0800 From: Jie Hai To: , Dongdong Liu , Yisen Zhuang , Lijun Ou , Chengwen Feng CC: , Subject: [PATCH 1/4] net/hns3: fix a typo Date: Wed, 18 Oct 2023 09:39:34 +0800 Message-ID: <20231018013938.3830742-2-haijie1@huawei.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20231018013938.3830742-1-haijie1@huawei.com> References: <20231018013938.3830742-1-haijie1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.165.2] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemi500020.china.huawei.com (7.221.188.8) X-CFilter-Loop: Reflected X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org This patch fixes a typo. Fixes: c09c7847d892 ("net/hns3: support traffic management") Cc: stable@dpdk.org Signed-off-by: Jie Hai Acked-by: Huisong Li --- drivers/net/hns3/hns3_tm.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/hns3/hns3_tm.c b/drivers/net/hns3/hns3_tm.c index 67402a700f46..d9691640140b 100644 --- a/drivers/net/hns3/hns3_tm.c +++ b/drivers/net/hns3/hns3_tm.c @@ -739,7 +739,7 @@ hns3_tm_node_type_get(struct rte_eth_dev *dev, uint32_t node_id, } static void -hns3_tm_nonleaf_level_capsbilities_get(struct rte_eth_dev *dev, +hns3_tm_nonleaf_level_capabilities_get(struct rte_eth_dev *dev, uint32_t level_id, struct rte_tm_level_capabilities *cap) { @@ -818,7 +818,7 @@ hns3_tm_level_capabilities_get(struct rte_eth_dev *dev, memset(cap, 0, sizeof(struct rte_tm_level_capabilities)); if (level_id != HNS3_TM_NODE_LEVEL_QUEUE) - hns3_tm_nonleaf_level_capsbilities_get(dev, level_id, cap); + hns3_tm_nonleaf_level_capabilities_get(dev, level_id, cap); else hns3_tm_leaf_level_capabilities_get(dev, cap); From patchwork Wed Oct 18 01:39:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jie Hai X-Patchwork-Id: 132824 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id BE21D43192; Wed, 18 Oct 2023 03:43:40 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 766FF406B4; Wed, 18 Oct 2023 03:43:29 +0200 (CEST) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id A29DB40151 for ; Wed, 18 Oct 2023 03:43:25 +0200 (CEST) Received: from kwepemi500020.china.huawei.com (unknown [172.30.72.53]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4S9D5W5P0wzvQ90; Wed, 18 Oct 2023 09:38:39 +0800 (CST) Received: from localhost.localdomain (10.67.165.2) by kwepemi500020.china.huawei.com (7.221.188.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Wed, 18 Oct 2023 09:43:23 +0800 From: Jie Hai To: , Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko CC: , Subject: [PATCH 2/4] ethdev: add telemetry command for TM capabilities Date: Wed, 18 Oct 2023 09:39:35 +0800 Message-ID: <20231018013938.3830742-3-haijie1@huawei.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20231018013938.3830742-1-haijie1@huawei.com> References: <20231018013938.3830742-1-haijie1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.165.2] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemi500020.china.huawei.com (7.221.188.8) X-CFilter-Loop: Reflected X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org 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 --- 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"); } From patchwork Wed Oct 18 01:39:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jie Hai X-Patchwork-Id: 132825 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0D6AF43192; Wed, 18 Oct 2023 03:43:48 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 96B3E40A79; Wed, 18 Oct 2023 03:43:30 +0200 (CEST) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id BADD14029F for ; Wed, 18 Oct 2023 03:43:25 +0200 (CEST) Received: from kwepemi500020.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4S9D5X1ztlzvQCw; Wed, 18 Oct 2023 09:38:40 +0800 (CST) Received: from localhost.localdomain (10.67.165.2) by kwepemi500020.china.huawei.com (7.221.188.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Wed, 18 Oct 2023 09:43:24 +0800 From: Jie Hai To: , Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko CC: , Subject: [PATCH 3/4] ethdev: add telemetry command for TM level capabilities Date: Wed, 18 Oct 2023 09:39:36 +0800 Message-ID: <20231018013938.3830742-4-haijie1@huawei.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20231018013938.3830742-1-haijie1@huawei.com> References: <20231018013938.3830742-1-haijie1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.165.2] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemi500020.china.huawei.com (7.221.188.8) X-CFilter-Loop: Reflected X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org This patch adds a telemetry command for traffic management level capabilities, using (port_id,level_id) as parameters. An example usage is shown below: --> /ethdev/tm_level_capability,0,0 { "/ethdev/tm_level_capability": { "n_nodes_max": 1, "n_nodes_nonleaf_max": 1, "n_nodes_leaf_max": 0, "non_leaf_nodes_identical": 1, "leaf_nodes_identical": 1, "nonleaf_cap": { "shaper_private_supported": 1, "shaper_private_dual_rate_supported": 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_packet_mode_supported": 0, "shaper_shared_byte_mode_supported": 0, "sched_n_children_max": 8, "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, "stats_mask": "0x0" }, "leaf_cap": { "shaper_private_supported": 1, "shaper_private_dual_rate_supported": 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_packet_mode_supported": 0, "shaper_shared_byte_mode_supported": 0, "cman_wred_packet_mode_supported": 8, "cman_wred_byte_mode_supported": 1, "cman_head_drop_supported": 0, "cman_wred_context_private_supported": 0, "cman_wred_context_shared_n_max": 1, "stats_mask": "0x0" } } } Signed-off-by: Jie Hai --- lib/ethdev/rte_ethdev_telemetry.c | 168 ++++++++++++++++++++++++++++++ 1 file changed, 168 insertions(+) diff --git a/lib/ethdev/rte_ethdev_telemetry.c b/lib/ethdev/rte_ethdev_telemetry.c index 02d23486806e..4a56685be426 100644 --- a/lib/ethdev/rte_ethdev_telemetry.c +++ b/lib/ethdev/rte_ethdev_telemetry.c @@ -1127,6 +1127,172 @@ eth_dev_handle_port_tm_caps(const char *cmd __rte_unused, return 0; } +static void +eth_dev_add_tm_level_basic_caps(struct rte_tel_data *d, + struct rte_tm_level_capabilities *cap) +{ + rte_tel_data_add_dict_uint(d, "n_nodes_max", cap->n_nodes_max); + rte_tel_data_add_dict_uint(d, "n_nodes_nonleaf_max", + cap->n_nodes_nonleaf_max); + rte_tel_data_add_dict_uint(d, "n_nodes_leaf_max", cap->n_nodes_leaf_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); +} + +static void +eth_dev_add_tm_level_nonleaf_caps(struct rte_tel_data *nonleaf, + struct rte_tm_level_capabilities *cap) +{ + rte_tel_data_add_dict_int(nonleaf, "shaper_private_supported", + cap->nonleaf.shaper_private_supported); + rte_tel_data_add_dict_int(nonleaf, "shaper_private_dual_rate_supported", + cap->nonleaf.shaper_private_dual_rate_supported); + rte_tel_data_add_dict_uint(nonleaf, "shaper_private_rate_min", + cap->nonleaf.shaper_private_rate_min); + rte_tel_data_add_dict_uint(nonleaf, "shaper_private_rate_max", + cap->nonleaf.shaper_private_rate_max); + rte_tel_data_add_dict_int(nonleaf, "shaper_private_packet_mode_supported", + cap->nonleaf.shaper_private_packet_mode_supported); + rte_tel_data_add_dict_int(nonleaf, "shaper_private_byte_mode_supported", + cap->nonleaf.shaper_private_byte_mode_supported); + rte_tel_data_add_dict_uint(nonleaf, "shaper_shared_n_max", + cap->nonleaf.shaper_shared_n_max); + rte_tel_data_add_dict_int(nonleaf, "shaper_shared_packet_mode_supported", + cap->nonleaf.shaper_shared_packet_mode_supported); + rte_tel_data_add_dict_int(nonleaf, "shaper_shared_byte_mode_supported", + cap->nonleaf.shaper_shared_byte_mode_supported); + rte_tel_data_add_dict_uint(nonleaf, "sched_n_children_max", + cap->nonleaf.sched_n_children_max); + rte_tel_data_add_dict_uint(nonleaf, "sched_sp_n_priorities_max", + cap->nonleaf.sched_sp_n_priorities_max); + rte_tel_data_add_dict_uint(nonleaf, "sched_wfq_n_children_per_group_max", + cap->nonleaf.sched_wfq_n_children_per_group_max); + rte_tel_data_add_dict_uint(nonleaf, "sched_wfq_n_groups_max", + cap->nonleaf.sched_wfq_n_groups_max); + rte_tel_data_add_dict_uint(nonleaf, "sched_wfq_weight_max", + cap->nonleaf.sched_wfq_weight_max); + rte_tel_data_add_dict_int(nonleaf, "sched_wfq_packet_mode_supported", + cap->nonleaf.sched_wfq_packet_mode_supported); + rte_tel_data_add_dict_int(nonleaf, "sched_wfq_byte_mode_supported", + cap->nonleaf.sched_wfq_byte_mode_supported); + rte_tel_data_add_dict_uint_hex(nonleaf, "stats_mask", + cap->nonleaf.stats_mask, 0); +} + +static void +eth_dev_add_tm_level_leaf_caps(struct rte_tel_data *leaf, + struct rte_tm_level_capabilities *cap) +{ + rte_tel_data_add_dict_int(leaf, "shaper_private_supported", + cap->leaf.shaper_private_supported); + rte_tel_data_add_dict_int(leaf, "shaper_private_dual_rate_supported", + cap->leaf.shaper_private_dual_rate_supported); + rte_tel_data_add_dict_uint(leaf, "shaper_private_rate_min", + cap->leaf.shaper_private_rate_min); + rte_tel_data_add_dict_uint(leaf, "shaper_private_rate_max", + cap->leaf.shaper_private_rate_max); + rte_tel_data_add_dict_int(leaf, "shaper_private_packet_mode_supported", + cap->leaf.shaper_private_packet_mode_supported); + rte_tel_data_add_dict_int(leaf, "shaper_private_byte_mode_supported", + cap->leaf.shaper_private_byte_mode_supported); + rte_tel_data_add_dict_uint(leaf, "shaper_shared_n_max", + cap->leaf.shaper_shared_n_max); + rte_tel_data_add_dict_int(leaf, "shaper_shared_packet_mode_supported", + cap->leaf.shaper_shared_packet_mode_supported); + rte_tel_data_add_dict_int(leaf, "shaper_shared_byte_mode_supported", + cap->leaf.shaper_shared_byte_mode_supported); + rte_tel_data_add_dict_int(leaf, "cman_wred_packet_mode_supported", + cap->leaf.cman_wred_packet_mode_supported); + rte_tel_data_add_dict_int(leaf, "cman_wred_byte_mode_supported", + cap->leaf.cman_wred_byte_mode_supported); + rte_tel_data_add_dict_int(leaf, "cman_head_drop_supported", + cap->leaf.cman_head_drop_supported); + rte_tel_data_add_dict_int(leaf, "cman_wred_context_private_supported", + cap->leaf.cman_wred_context_private_supported); + rte_tel_data_add_dict_uint(leaf, "cman_wred_context_shared_n_max", + cap->leaf.cman_wred_context_shared_n_max); + rte_tel_data_add_dict_uint_hex(leaf, "stats_mask", + cap->leaf.stats_mask, 0); +} + +static int +eth_dev_parse_tm_params(char *params, uint32_t *result) +{ + const char *splited_param; + uint64_t ret; + + splited_param = strtok(params, ","); + if (!splited_param || strlen(splited_param) == 0 || !isdigit(*splited_param)) + return -EINVAL; + + ret = strtoul(splited_param, ¶ms, 0); + if (*params != '\0') + RTE_ETHDEV_LOG(NOTICE, + "Extra parameters passed to ethdev telemetry command, ignoring\n"); + + if (ret >= UINT32_MAX) + return -EINVAL; + + *result = ret; + return 0; +} + +static int +eth_dev_handle_port_tm_level_caps(const char *cmd __rte_unused, + const char *params, + struct rte_tel_data *d) +{ + struct rte_tm_level_capabilities cap = {0}; + struct rte_tm_error error = {0}; + struct rte_tel_data *nonleaf; + struct rte_tel_data *leaf; + uint32_t level_id; + uint16_t port_id; + char *end_param; + int ret; + + ret = eth_dev_parse_port_params(params, &port_id, &end_param, true); + if (ret != 0) + return ret; + + ret = eth_dev_parse_tm_params(end_param, &level_id); + if (ret != 0) + return ret; + + ret = rte_tm_level_capabilities_get(port_id, level_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_level_basic_caps(d, &cap); + + nonleaf = rte_tel_data_alloc(); + if (nonleaf == NULL) + return -ENOMEM; + + rte_tel_data_start_dict(nonleaf); + eth_dev_add_tm_level_nonleaf_caps(nonleaf, &cap); + rte_tel_data_add_dict_container(d, "nonleaf_cap", nonleaf, 0); + + leaf = rte_tel_data_alloc(); + if (leaf == NULL) { + rte_tel_data_free(nonleaf); + return -ENOMEM; + } + + rte_tel_data_start_dict(leaf); + eth_dev_add_tm_level_leaf_caps(leaf, &cap); + rte_tel_data_add_dict_container(d, "leaf_cap", leaf, 0); + + return 0; +} + RTE_INIT(ethdev_init_telemetry) { rte_telemetry_register_cmd("/ethdev/list", eth_dev_handle_port_list, @@ -1164,4 +1330,6 @@ RTE_INIT(ethdev_init_telemetry) "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"); + rte_telemetry_register_cmd("/ethdev/tm_level_capability", eth_dev_handle_port_tm_level_caps, + "Returns TM Level Capabilities info for a port. Parameters: int port_id, int level_id (see tm_capability for the max)"); } From patchwork Wed Oct 18 01:39:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jie Hai X-Patchwork-Id: 132826 X-Patchwork-Delegate: ferruh.yigit@amd.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 974DC43192; Wed, 18 Oct 2023 03:43:55 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id B681340DCE; Wed, 18 Oct 2023 03:43:31 +0200 (CEST) Received: from szxga01-in.huawei.com (szxga01-in.huawei.com [45.249.212.187]) by mails.dpdk.org (Postfix) with ESMTP id 7997E40151 for ; Wed, 18 Oct 2023 03:43:26 +0200 (CEST) Received: from kwepemi500020.china.huawei.com (unknown [172.30.72.54]) by szxga01-in.huawei.com (SkyGuard) with ESMTP id 4S9D7t0WR0zrTSj; Wed, 18 Oct 2023 09:40:42 +0800 (CST) Received: from localhost.localdomain (10.67.165.2) by kwepemi500020.china.huawei.com (7.221.188.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2507.31; Wed, 18 Oct 2023 09:43:24 +0800 From: Jie Hai To: , Thomas Monjalon , Ferruh Yigit , Andrew Rybchenko CC: , Subject: [PATCH 4/4] ethdev: add telemetry command for TM node capabilities Date: Wed, 18 Oct 2023 09:39:37 +0800 Message-ID: <20231018013938.3830742-5-haijie1@huawei.com> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20231018013938.3830742-1-haijie1@huawei.com> References: <20231018013938.3830742-1-haijie1@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.67.165.2] X-ClientProxiedBy: dggems703-chm.china.huawei.com (10.3.19.180) To kwepemi500020.china.huawei.com (7.221.188.8) X-CFilter-Loop: Reflected X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org This patch adds a telemetry command for traffic management node capabilities, using (port_id, node_id) as parameters. An example usage is shown below: --> /ethdev/tm_node_capability,0,264 { "/ethdev/tm_node_capability": { "shaper_private_supported": 1, "shaper_private_dual_rate_supported": 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_packet_mode_supported": 0, "shaper_shared_byte_mode_supported": 0, "stats_mask": "0x0", "node_type": "nonleaf", "children_max": 8, "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 } } Signed-off-by: Jie Hai --- lib/ethdev/rte_ethdev_telemetry.c | 104 ++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) diff --git a/lib/ethdev/rte_ethdev_telemetry.c b/lib/ethdev/rte_ethdev_telemetry.c index 4a56685be426..b01028ce9b60 100644 --- a/lib/ethdev/rte_ethdev_telemetry.c +++ b/lib/ethdev/rte_ethdev_telemetry.c @@ -1293,6 +1293,108 @@ eth_dev_handle_port_tm_level_caps(const char *cmd __rte_unused, return 0; } +static void +eth_dev_add_tm_node_basic_caps(struct rte_tel_data *node_data, + struct rte_tm_node_capabilities *capnode) +{ + rte_tel_data_add_dict_int(node_data, "shaper_private_supported", + capnode->shaper_private_supported); + rte_tel_data_add_dict_int(node_data, "shaper_private_dual_rate_supported", + capnode->shaper_private_dual_rate_supported); + rte_tel_data_add_dict_uint(node_data, "shaper_private_rate_min", + capnode->shaper_private_rate_min); + rte_tel_data_add_dict_uint(node_data, "shaper_private_rate_max", + capnode->shaper_private_rate_max); + rte_tel_data_add_dict_int(node_data, "shaper_private_packet_mode_supported", + capnode->shaper_private_packet_mode_supported); + rte_tel_data_add_dict_int(node_data, "shaper_private_byte_mode_supported", + capnode->shaper_private_byte_mode_supported); + rte_tel_data_add_dict_uint(node_data, "shaper_shared_n_max", + capnode->shaper_shared_n_max); + rte_tel_data_add_dict_int(node_data, "shaper_shared_packet_mode_supported", + capnode->shaper_shared_packet_mode_supported); + rte_tel_data_add_dict_int(node_data, "shaper_shared_byte_mode_supported", + capnode->shaper_shared_byte_mode_supported); + rte_tel_data_add_dict_uint_hex(node_data, "stats_mask", + capnode->stats_mask, 0); +} + +static void +eth_dev_add_tm_type_node_caps(struct rte_tel_data *d, int is_leaf, + struct rte_tm_node_capabilities *cap) +{ + rte_tel_data_add_dict_string(d, "node_type", + is_leaf == 0 ? "nonleaf" : "leaf"); + if (is_leaf == 0) { + rte_tel_data_add_dict_uint(d, "children_max", + cap->nonleaf.sched_n_children_max); + rte_tel_data_add_dict_uint(d, "priorities_max", + cap->nonleaf.sched_sp_n_priorities_max); + rte_tel_data_add_dict_uint(d, "sched_wfq_n_children_per_group_max", + cap->nonleaf.sched_wfq_n_children_per_group_max); + rte_tel_data_add_dict_uint(d, "sched_wfq_n_groups_max", + cap->nonleaf.sched_wfq_n_groups_max); + rte_tel_data_add_dict_uint(d, "sched_wfq_weight_max", + cap->nonleaf.sched_wfq_weight_max); + rte_tel_data_add_dict_int(d, "sched_wfq_packet_mode_supported", + cap->nonleaf.sched_wfq_packet_mode_supported); + rte_tel_data_add_dict_int(d, "sched_wfq_byte_mode_supported", + cap->nonleaf.sched_wfq_byte_mode_supported); + } else { + rte_tel_data_add_dict_int(d, "cman_wred_packet_mode_supported", + cap->leaf.cman_wred_packet_mode_supported); + rte_tel_data_add_dict_int(d, "cman_wred_byte_mode_supported", + cap->leaf.cman_wred_byte_mode_supported); + rte_tel_data_add_dict_int(d, "cman_head_drop_supported", + cap->leaf.cman_head_drop_supported); + rte_tel_data_add_dict_int(d, "cman_wred_context_private_supported", + cap->leaf.cman_wred_context_private_supported); + rte_tel_data_add_dict_uint(d, "cman_wred_context_shared_n_max", + cap->leaf.cman_wred_context_shared_n_max); + } +} + +static int +eth_dev_handle_port_tm_node_caps(const char *cmd __rte_unused, + const char *params, + struct rte_tel_data *d) +{ + struct rte_tm_node_capabilities cap = {0}; + struct rte_tm_error error = {0}; + uint32_t node_id; + uint16_t port_id; + char *end_param; + int is_leaf; + int ret; + + ret = eth_dev_parse_port_params(params, &port_id, &end_param, true); + if (ret != 0) + return ret; + + ret = eth_dev_parse_tm_params(end_param, &node_id); + if (ret != 0) + return ret; + + ret = rte_tm_node_capabilities_get(port_id, node_id, &cap, &error); + if (ret != 0) + goto out; + + ret = rte_tm_node_type_get(port_id, node_id, &is_leaf, &error); + if (ret != 0) + goto out; + + rte_tel_data_start_dict(d); + eth_dev_add_tm_node_basic_caps(d, &cap); + eth_dev_add_tm_type_node_caps(d, is_leaf, &cap); + + return 0; +out: + RTE_ETHDEV_LOG(WARNING, "error: %s, error type: %u\n", + error.message ? error.message : "no stated reason", + error.type); + return ret; +} + RTE_INIT(ethdev_init_telemetry) { rte_telemetry_register_cmd("/ethdev/list", eth_dev_handle_port_list, @@ -1332,4 +1434,6 @@ RTE_INIT(ethdev_init_telemetry) "Returns TM Capabilities info for a port. Parameters: int port_id"); rte_telemetry_register_cmd("/ethdev/tm_level_capability", eth_dev_handle_port_tm_level_caps, "Returns TM Level Capabilities info for a port. Parameters: int port_id, int level_id (see tm_capability for the max)"); + rte_telemetry_register_cmd("/ethdev/tm_node_capability", eth_dev_handle_port_tm_node_caps, + "Returns TM Node Capabilities info for a port. Parameters: int port_id, int node_id (see tm_capability for the max)"); }