From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 6033145AE2; Tue, 8 Oct 2024 16:44:02 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 806FB40B8F; Tue, 8 Oct 2024 16:43:50 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.9]) by mails.dpdk.org (Postfix) with ESMTP id 4C5C44064C for ; Tue, 8 Oct 2024 16:43:49 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1728398629; x=1759934629; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=jkNNdPDo53E8bOkWiIA5oko7MGFniAF3Xg9Q02Vz5cw=; b=lu1YtvSonse/4Z/hi1jdWRPbzb9eqCbX8gqyAEK3swmLfpA1piWK6Amr HovmBzmOKWDVXu0xJDut7AFCde0g3friKLaB1PW0dOCG/NShJXVaCx7LT MrNCEER6w+iU6+575Jsm4HqshTMk/0osKZy2DdwmYG4abqly7d++sQI+4 6FX29/Ou/FfIO6pCkCroTXKlXlGWdk7FBr88b4fC081hjmpSyHSWMoLJv adVXeyRxJng8+jgr1fvB6s3uUBnOsSZcNEJRNPzQ2i5HQeB3kO/8/EOot uI+RVz0wm5PjLEnagvve0b3kgyfTOpD+d0cE1t0Sgox57O2n5j2Iby3xH A==; X-CSE-ConnectionGUID: 8YMtXO5uRAK3dKSXjNBIcg== X-CSE-MsgGUID: 6uAlDvbPTHaJYnzfxLYm4w== X-IronPort-AV: E=McAfee;i="6700,10204,11219"; a="50133754" X-IronPort-AV: E=Sophos;i="6.11,187,1725346800"; d="scan'208";a="50133754" Received: from fmviesa001.fm.intel.com ([10.60.135.141]) by orvoesa101.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 Oct 2024 07:43:49 -0700 X-CSE-ConnectionGUID: EMgU0+uEQmekpxD8HGfmmw== X-CSE-MsgGUID: LaR5StwNT4i/B73LUHtKLQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,187,1725346800"; d="scan'208";a="106615527" Received: from unknown (HELO silpixa00401385.ir.intel.com) ([10.237.214.25]) by fmviesa001.fm.intel.com with ESMTP; 08 Oct 2024 07:43:48 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: ferruh.yigit@amd.com, Bruce Richardson Subject: [PATCH v2 3/3] app/testpmd: add support for querying TM nodes Date: Tue, 8 Oct 2024 15:43:20 +0100 Message-ID: <20241008144320.1632138-4-bruce.richardson@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241008144320.1632138-1-bruce.richardson@intel.com> References: <20241008105350.1396216-1-bruce.richardson@intel.com> <20241008144320.1632138-1-bruce.richardson@intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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 Support use of the rte_tm_node_query API to print out details about previously added TM nodes in testpmd. 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: Level ID: 0 Priority: 0 Weight: 0 Shaper Profile ID: Shared Shaper IDs: 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: Shared Shaper IDs: 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: Shared Shaper IDs: Stats Mask: 0 Leaf Node Parameters CMAN Mode: Tail Drop WRED Profile ID: Shared WRED Context Ids: Signed-off-by: Bruce Richardson --- app/test-pmd/cmdline.c | 1 + app/test-pmd/cmdline_tm.c | 131 ++++++++++++++++++++++++++++++++++++++ app/test-pmd/cmdline_tm.h | 1 + 3 files changed, 133 insertions(+) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 12d8c00293..6ec1d4e9b5 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -13573,6 +13573,7 @@ static cmdline_parse_ctx_t builtin_ctx[] = { &cmd_set_port_ptypes, &cmd_show_port_tm_cap, &cmd_show_port_tm_level_cap, + &cmd_show_port_tm_node, &cmd_show_port_tm_node_cap, &cmd_show_port_tm_node_type, &cmd_show_port_tm_node_stats, diff --git a/app/test-pmd/cmdline_tm.c b/app/test-pmd/cmdline_tm.c index aa917edb6c..7ade91549c 100644 --- a/app/test-pmd/cmdline_tm.c +++ b/app/test-pmd/cmdline_tm.c @@ -2111,6 +2111,137 @@ cmdline_parse_inst_t cmd_add_port_tm_leaf_node = { }, }; +struct cmd_show_port_tm_node_result { + cmdline_fixed_string_t show; + cmdline_fixed_string_t port; + cmdline_fixed_string_t tm; + cmdline_fixed_string_t node; + uint16_t port_id; + uint32_t node_id; +}; + +static cmdline_parse_token_string_t cmd_show_port_tm_node_show_tok = + TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_node_result, show, "show"); +static cmdline_parse_token_string_t cmd_show_port_tm_node_port_tok = + TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_node_result, port, "port"); +static cmdline_parse_token_string_t cmd_show_port_tm_node_tm_tok = + TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_node_result, tm, "tm"); +static cmdline_parse_token_string_t cmd_show_port_tm_node_node_tok = + TOKEN_STRING_INITIALIZER(struct cmd_show_port_tm_node_result, node, "node"); +static cmdline_parse_token_num_t cmd_show_port_tm_node_port_id_tok = + TOKEN_NUM_INITIALIZER(struct cmd_show_port_tm_node_result, port_id, RTE_UINT16); +static cmdline_parse_token_num_t cmd_show_port_tm_node_node_id_tok = + TOKEN_NUM_INITIALIZER(struct cmd_show_port_tm_node_result, node_id, RTE_UINT32); + +static void +cmd_show_port_tm_node_parsed(void *parsed_result, struct cmdline *cl, void *data __rte_unused) +{ + const struct cmd_show_port_tm_node_result *res = parsed_result; + const portid_t port_id = res->port_id; + const uint32_t node_id = res->node_id; + struct rte_tm_node_params params = {0}; + struct rte_tm_error error = {0}; + uint32_t parent_id, priority, weight, level_id; + int is_leaf; + int ret; + + if (port_id_is_invalid(port_id, ENABLED_WARN)) + return; + + ret = rte_tm_node_query(port_id, node_id, + &parent_id, &priority, &weight, &level_id, ¶ms, &error); + if (ret != 0) { + print_err_msg(&error); + return; + } + + ret = rte_tm_node_type_get(port_id, node_id, &is_leaf, &error); + if (ret != 0) { + print_err_msg(&error); + return; + } + + cmdline_printf(cl, "Port %u TM Node %u\n", port_id, node_id); + if (parent_id == RTE_TM_NODE_ID_NULL) + cmdline_printf(cl, " Parent Node ID: \n"); + else + cmdline_printf(cl, " Parent Node ID: %d\n", parent_id); + cmdline_printf(cl, " Level ID: %u\n", level_id); + cmdline_printf(cl, " Priority: %u\n", priority); + cmdline_printf(cl, " Weight: %u\n", weight); + if (params.shaper_profile_id == RTE_TM_SHAPER_PROFILE_ID_NONE) + cmdline_printf(cl, " Shaper Profile ID: \n"); + else + cmdline_printf(cl, " Shaper Profile ID: %d\n", params.shaper_profile_id); + cmdline_printf(cl, " Shared Shaper IDs: "); + if (params.n_shared_shapers == 0) + cmdline_printf(cl, "\n"); + else { + for (uint32_t i = 0; i < params.n_shared_shapers; i++) + cmdline_printf(cl, "%u ", params.shared_shaper_id[i]); + cmdline_printf(cl, "\n"); + } + cmdline_printf(cl, " Stats Mask: %"PRIu64"\n", params.stats_mask); + if (is_leaf) { + cmdline_printf(cl, " Leaf Node Parameters\n"); + switch (params.leaf.cman) { + case RTE_TM_CMAN_TAIL_DROP: + cmdline_printf(cl, " CMAN Mode: Tail Drop\n"); + break; + case RTE_TM_CMAN_HEAD_DROP: + cmdline_printf(cl, " CMAN Mode: Head Drop\n"); + break; + case RTE_TM_CMAN_WRED: + cmdline_printf(cl, " CMAN Mode: WRED\n"); + break; + } + if (params.leaf.wred.wred_profile_id == RTE_TM_WRED_PROFILE_ID_NONE) + cmdline_printf(cl, " WRED Profile ID: \n"); + else + cmdline_printf(cl, " WRED Profile ID: %u\n", + params.leaf.wred.wred_profile_id); + cmdline_printf(cl, " Shared WRED Context Ids: "); + if (params.leaf.wred.n_shared_wred_contexts == 0) + cmdline_printf(cl, "\n"); + else { + for (uint32_t i = 0; i < params.leaf.wred.n_shared_wred_contexts; i++) + cmdline_printf(cl, "%u ", + params.leaf.wred.shared_wred_context_id[i]); + cmdline_printf(cl, "\n"); + } + } else { + cmdline_printf(cl, " Nonleaf Node Parameters\n"); + cmdline_printf(cl, " Num Strict Priorities: %u\n", + params.nonleaf.n_sp_priorities); + cmdline_printf(cl, " WFQ Weights Mode: "); + if (params.nonleaf.wfq_weight_mode == NULL) + cmdline_printf(cl, "WFQ\n"); + else { + for (uint32_t i = 0; i < params.nonleaf.n_sp_priorities; i++) + cmdline_printf(cl, "%s(%d) ", + params.nonleaf.wfq_weight_mode[i] ? "Bytes" : "Packet", + params.nonleaf.wfq_weight_mode[i]); + cmdline_printf(cl, "\n"); + } + } +} + + +cmdline_parse_inst_t cmd_show_port_tm_node = { + .f = cmd_show_port_tm_node_parsed, + .data = NULL, + .help_str = "", + .tokens = { + (void *)&cmd_show_port_tm_node_show_tok, + (void *)&cmd_show_port_tm_node_port_tok, + (void *)&cmd_show_port_tm_node_tm_tok, + (void *)&cmd_show_port_tm_node_node_tok, + (void *)&cmd_show_port_tm_node_port_id_tok, + (void *)&cmd_show_port_tm_node_node_id_tok, + NULL, + } +}; + /* *** Delete Port TM Node *** */ struct cmd_del_port_tm_node_result { cmdline_fixed_string_t del; diff --git a/app/test-pmd/cmdline_tm.h b/app/test-pmd/cmdline_tm.h index e59c15c3cc..4ae5fd072f 100644 --- a/app/test-pmd/cmdline_tm.h +++ b/app/test-pmd/cmdline_tm.h @@ -9,6 +9,7 @@ extern cmdline_parse_inst_t cmd_show_port_tm_cap; extern cmdline_parse_inst_t cmd_show_port_tm_level_cap; extern cmdline_parse_inst_t cmd_show_port_tm_node_cap; +extern cmdline_parse_inst_t cmd_show_port_tm_node; extern cmdline_parse_inst_t cmd_show_port_tm_node_type; extern cmdline_parse_inst_t cmd_show_port_tm_node_stats; extern cmdline_parse_inst_t cmd_add_port_tm_node_shaper_profile; -- 2.43.0