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 4B06A45AF1; Wed, 9 Oct 2024 12:32:35 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 095CE41101; Wed, 9 Oct 2024 12:32:23 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.12]) by mails.dpdk.org (Postfix) with ESMTP id A2D45410EE for ; Wed, 9 Oct 2024 12:32:19 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1728469940; x=1760005940; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=4QJu0TOKEuRfknvu/kC2uT+q7fNDsc16sGPI/eLmoqg=; b=E9dleSw5iwKoClq9SkMBvoqeyRAfEEN5KPFITUUjUprpxE4QPOxG3vDL N6j3+vyv7q8jKBWAqvywkYSxyhVvVZrkyIRdm0mRivAg+oUvZmp4OW0nf YRTYAMD9HjE0hJ+NIIz68oGZNDaJESZAOR3zM9S+wcWkODwYKg3Mg7C1s 1rGzOyU8zmtEM7UkihTziPK9eZN5NB0hvie5CATU4S74lx0a+kmGHaLup c897z+JF32biwm2SFSnUDFw+aKZWaCvNk8kw7qAlh3Gl1SK1JXUp4jXV3 /18amnBIVkP9PMCF+Ky3SToGcMhSUrxaDcIoLvQmFb6frBbajRLXVzWDK w==; X-CSE-ConnectionGUID: 4FBqgo1kRu+S5BmwfZOM6g== X-CSE-MsgGUID: F2pPZvwTQGKEub+gy4iBMw== X-IronPort-AV: E=McAfee;i="6700,10204,11219"; a="31649231" X-IronPort-AV: E=Sophos;i="6.11,189,1725346800"; d="scan'208";a="31649231" Received: from orviesa007.jf.intel.com ([10.64.159.147]) by fmvoesa106.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Oct 2024 03:32:19 -0700 X-CSE-ConnectionGUID: xtcDp/c/QsyP2RAuMEASRQ== X-CSE-MsgGUID: khewpSAiSr6ZE/VJcrIQeQ== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.11,189,1725346800"; d="scan'208";a="76651305" Received: from unknown (HELO silpixa00401385.ir.intel.com) ([10.237.214.25]) by orviesa007.jf.intel.com with ESMTP; 09 Oct 2024 03:32:19 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: ferruh.yigit@amd.com, Bruce Richardson , Chengwen Feng Subject: [PATCH v3 3/3] app/testpmd: add support for querying TM nodes Date: Wed, 9 Oct 2024 11:32:10 +0100 Message-ID: <20241009103210.3858363-4-bruce.richardson@intel.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241009103210.3858363-1-bruce.richardson@intel.com> References: <20241008105350.1396216-1-bruce.richardson@intel.com> <20241009103210.3858363-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 Acked-by: Chengwen Feng --- v2: added new command to testpmd documentation --- app/test-pmd/cmdline.c | 1 + app/test-pmd/cmdline_tm.c | 131 ++++++++++++++++++++ app/test-pmd/cmdline_tm.h | 1 + doc/guides/testpmd_app_ug/testpmd_funcs.rst | 27 ++++ 4 files changed, 160 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; diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index f00ab07605..5825846bb8 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -2790,6 +2790,33 @@ where: * ``n_shared_shapers``: Number of shared shapers. * ``shared_shaper_id``: Shared shaper id. +Query port traffic management hierarchy node +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +An added traffic management hierarchy node, whether leaf of non-leaf, +can be queried using:: + + testpmd> show port tm node (port_id) (node_id) + +where ``port_id`` and ``node_id`` are the numeric identifiers of the ethernet port +and the previously added traffic management node, respectively. +The output of this command are the parameters previously provided to the add call, +printed with appropriate labels. +For example:: + + 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 + Delete port traffic management hierarchy node ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -- 2.43.0