From patchwork Mon Aug 12 13:26:43 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bruce Richardson X-Patchwork-Id: 143075 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 D1C8D457A1; Mon, 12 Aug 2024 15:27:13 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id C379740691; Mon, 12 Aug 2024 15:27:13 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.19]) by mails.dpdk.org (Postfix) with ESMTP id 76E3140665 for ; Mon, 12 Aug 2024 15:27:12 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1723469232; x=1755005232; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=yIfv6G7kgI/wBs5iVqCjiLuKep/2n6xmpAphTWf5cAM=; b=F6M4zAYM8iEH5FRKiqzKl7Lur0vyc5WLZEo28crzZBT6dUJt4SFkeBsq tYp7GOcmL87EYrtnveXKJEKoS5du/hqpYgprErBS+AMFhNS+vfSiU+EZW IpcmvXuHHgpIS3R0TMSRrcMItrtm3kbjFxubZNQr+ybNo80g+IV/7D/bz uPu6w+MnOZ/ChiwpBNSKJ3+Z14Dk07m1FmX9OEpKcLoYK8CCsXJMWU75h HlO2jzYIg/eH18zDnyB9YyLdfp2lKn1LsA9KtE5X5NuzNTDc0S3m1reT1 APeeUTaUuPvDaa1NjjgWNkkcOroI1OUFfK69aHUgK7AQgdCeKHcl3mIfN w==; X-CSE-ConnectionGUID: S6rTF/fMQg+tF/A8+8rRTQ== X-CSE-MsgGUID: 29m9lSsSTbeCSQMqHk2TVQ== X-IronPort-AV: E=McAfee;i="6700,10204,11162"; a="21232630" X-IronPort-AV: E=Sophos;i="6.09,283,1716274800"; d="scan'208";a="21232630" Received: from orviesa009.jf.intel.com ([10.64.159.149]) by fmvoesa113.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 Aug 2024 06:27:11 -0700 X-CSE-ConnectionGUID: jBgvXt5MQuW83foOwaCUag== X-CSE-MsgGUID: l2v5+U8ZQq+XpER/lIJ2uA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.09,283,1716274800"; d="scan'208";a="58187156" Received: from silpixa00400562.ir.intel.com (HELO silpixa00401385.ir.intel.com) ([10.237.214.39]) by orviesa009.jf.intel.com with ESMTP; 12 Aug 2024 06:27:10 -0700 From: Bruce Richardson To: dev@dpdk.org Cc: Bruce Richardson , Cristian Dumitrescu , Aman Singh Subject: [RFC PATCH] app/testpmd: display TM parameters when adding nodes Date: Mon, 12 Aug 2024 14:26:43 +0100 Message-ID: <20240812132643.160567-2-bruce.richardson@intel.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 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 The commands to add TM nodes and shapers take many parameters without any descriptive words in between to identify what parameter is what. To help make it clear what a command is actually doing, and to help catch any issues with parameters put in the wrong order, print out the parameters for each command after it is entered. Signed-off-by: Bruce Richardson Acked-by: Ferruh Yigit --- app/test-pmd/cmdline_tm.c | 60 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 57 insertions(+), 3 deletions(-) diff --git a/app/test-pmd/cmdline_tm.c b/app/test-pmd/cmdline_tm.c index 6ce074f538..aa917edb6c 100644 --- a/app/test-pmd/cmdline_tm.c +++ b/app/test-pmd/cmdline_tm.c @@ -882,8 +882,21 @@ static cmdline_parse_token_num_t cmd_add_port_tm_node_shaper_profile_packet_mode struct cmd_add_port_tm_node_shaper_profile_result, pkt_mode, RTE_UINT32); +static int +get_printable_rate(uint64_t rate, char *buffer, size_t size) +{ + if (rate >= 1000 * 1000 * 1000) + return snprintf(buffer, size, "%.1fG", rate / (1000 * 1000 * 1000.0)); + else if (rate >= 1000 * 1000) + return snprintf(buffer, size, "%.1fM", rate / (1000 * 1000.0)); + else if (rate >= 1000) + return snprintf(buffer, size, "%.1fK", rate / 1000.0); + else + return snprintf(buffer, size, "%"PRIu64, rate); +} + static void cmd_add_port_tm_node_shaper_profile_parsed(void *parsed_result, - __rte_unused struct cmdline *cl, + struct cmdline *cl, __rte_unused void *data) { struct cmd_add_port_tm_node_shaper_profile_result *res = parsed_result; @@ -892,8 +905,20 @@ static void cmd_add_port_tm_node_shaper_profile_parsed(void *parsed_result, uint32_t shaper_id = res->shaper_id; uint32_t pkt_len_adjust = res->pktlen_adjust; portid_t port_id = res->port_id; + char rate_str[20]; int ret; + cmdline_printf(cl, "adding node shaper on port %u, with id %u\n", res->port_id, shaper_id); + get_printable_rate(res->cmit_tb_rate, rate_str, sizeof(rate_str)); + cmdline_printf(cl, "# committed rate: %s, t.b. size: %"PRIu64"\n", + rate_str, res->cmit_tb_size); + + get_printable_rate(res->peak_tb_rate, rate_str, sizeof(rate_str)); + cmdline_printf(cl, "# peak rate: %s, t.b. size: %"PRIu64"\n", + rate_str, res->peak_tb_size); + cmdline_printf(cl, "# pkt length adjust: %u\n", res->pktlen_adjust); + cmdline_printf(cl, "# packet mode: %s\n", res->pkt_mode ? "true" : "false (bytes mode)"); + if (port_id_is_invalid(port_id, ENABLED_WARN)) return; @@ -1635,7 +1660,7 @@ static cmdline_parse_token_string_t multi_shared_shaper_id, TOKEN_STRING_MULTI); static void cmd_add_port_tm_nonleaf_node_parsed(void *parsed_result, - __rte_unused struct cmdline *cl, + struct cmdline *cl, __rte_unused void *data) { struct cmd_add_port_tm_nonleaf_node_result *res = parsed_result; @@ -1659,6 +1684,20 @@ static void cmd_add_port_tm_nonleaf_node_parsed(void *parsed_result, else parent_node_id = res->parent_node_id; + if (parent_node_id != UINT32_MAX) + cmdline_printf(cl, "adding node on port %u, with id %u and parent node %u\n", + port_id, res->node_id, parent_node_id); + else + cmdline_printf(cl, "adding node on port %u, with id %u as root node\n", + port_id, res->node_id); + cmdline_printf(cl, "# priority: %u\n", res->priority); + cmdline_printf(cl, "# weight: %u\n", res->weight); + cmdline_printf(cl, "# level_id: %u\n", res->level_id); + cmdline_printf(cl, "# shaper_profile_id: %d\n", res->shaper_profile_id); + cmdline_printf(cl, "# num SP priorities: %u\n", res->n_sp_priorities); + cmdline_printf(cl, "# stats_mask: %"PRIx64"\n", res->stats_mask); + cmdline_printf(cl, "# shared shapers: '%s'\n", s_str); + shared_shaper_id = (uint32_t *)malloc(MAX_NUM_SHARED_SHAPERS * sizeof(uint32_t)); if (shared_shaper_id == NULL) { @@ -1964,7 +2003,7 @@ static cmdline_parse_token_string_t multi_shared_shaper_id, TOKEN_STRING_MULTI); static void cmd_add_port_tm_leaf_node_parsed(void *parsed_result, - __rte_unused struct cmdline *cl, + struct cmdline *cl, __rte_unused void *data) { struct cmd_add_port_tm_leaf_node_result *res = parsed_result; @@ -1988,6 +2027,21 @@ static void cmd_add_port_tm_leaf_node_parsed(void *parsed_result, else parent_node_id = res->parent_node_id; + if (parent_node_id != UINT32_MAX) + cmdline_printf(cl, "adding leaf node on port %u, with id %u and parent node %u\n", + port_id, res->node_id, parent_node_id); + else + cmdline_printf(cl, "adding leaf node on port %u, with id %u as root node\n", + port_id, res->node_id); + cmdline_printf(cl, "# priority: %u\n", res->priority); + cmdline_printf(cl, "# weight: %u\n", res->weight); + cmdline_printf(cl, "# level_id: %u\n", res->level_id); + cmdline_printf(cl, "# shaper_profile_id: %d\n", res->shaper_profile_id); + cmdline_printf(cl, "# cman_mode: %u\n", res->cman_mode); + cmdline_printf(cl, "# wred_profile_id: %d\n", res->wred_profile_id); + cmdline_printf(cl, "# stats_mask: %"PRIx64"\n", res->stats_mask); + cmdline_printf(cl, "# shared shapers: '%s'\n", s_str); + shared_shaper_id = (uint32_t *)malloc(MAX_NUM_SHARED_SHAPERS * sizeof(uint32_t)); if (shared_shaper_id == NULL) {