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 C5F8946121; Fri, 24 Jan 2025 12:44:04 +0100 (CET) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7C4D24278A; Fri, 24 Jan 2025 12:44:04 +0100 (CET) Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on2069.outbound.protection.outlook.com [40.107.236.69]) by mails.dpdk.org (Postfix) with ESMTP id 0367A410FA for ; Fri, 24 Jan 2025 12:44:02 +0100 (CET) ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=wI88mgc/DKYgM4iLxMLuilYgFsG/7EEdmoY0x3fAyDoXPiMyHLAhrnE59Qahd7vvWvrh8kHssDR3W1IzQrN2QYrVmTao45GuQaG9ramCdaFzEs8kSMkZ5ml80Wej7AVoaXyTJWP8TNxX1kJOTfV58seeXXusEmVh6aNhkAkld4LgPVW9tulJTc3vYXFSisMtIeHNOK6LIkOTd4ufytMrVrenZsoLblTmBxiqy9G6bwC4s1U0basD7BZ4EnTNro6QlC6DjO0qAd6ZmlB+bi4Ti6SHUVXd5UhlXvjClb4DBZlIHBZgDb6DAQ9K/i3dz6cXYUhHi2BRylv1ceoShBJK5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=nAYoKPXn2fA0WYt45FB8WWWG732t5aLNucGjCdqBoaY=; b=HQ4Vs44Ng0iTqJb4E8Jgw5QDoNFZ2YWcxGjk7oEtODE/pCoK6zZroGo0Q1wgI0DqF9nauYWuszde2F/DqywZAzzv553xgEqvoEFwTRpXDjY+zTK4lshBogBxMT1w4msbDO76o3PCIAhPwoXQJh/pr/MnTjOxiUZfyoCyGHewg6X0xnOjLlpjkis5GQF+oovTh4+XB0KJtqbRSPzCgUysLGSbt/NikK54djTD45Uw6KosawTBHl01LEta/iYzMexC2suIVnvmSBJVUvwMUNqzoY7TEl5D0NPbUH2WkC5P5TIC3ETiQkyVNyHAjKQ0oidhoGyK3GbR1TrumGebkzAtzg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 216.228.117.160) smtp.rcpttodomain=dpdk.org smtp.mailfrom=nvidia.com; dmarc=pass (p=reject sp=reject pct=100) action=none header.from=nvidia.com; dkim=none (message not signed); arc=none (0) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=nAYoKPXn2fA0WYt45FB8WWWG732t5aLNucGjCdqBoaY=; b=ldJlRZtdnXBC7Y241oHKmX7gFK8iTs2SvolHs0h3DmD9/UsDR7hKz06+BYGOlwPpLwY7VhG2VMacujLzEgWxgJQMt6DlgdxT5sVa8xE8Tu1SbiJ5vNf7/GMmYEteQz1Niq5C+7CDcqMuSP7A2gKp1Ik7QbFMs8wmg1q2pL0jhgvXG6P28B7g10pQT9e4xzx4rJJVdNpsDDhYk1OGcNBbkenqarIdnU23iYexyZiTgC4xlw4qZkUGYcQVK1vU94aRHZhOgdaY5yIwiOyAK4ZgcN3sm//7BQW86jTp+6YJ1g8DdufPQNKJL5gHW1Z+P+/PD8sPZqkcptDhoaMpFxCyXw== Received: from MN2PR19CA0060.namprd19.prod.outlook.com (2603:10b6:208:19b::37) by CH3PR12MB7668.namprd12.prod.outlook.com (2603:10b6:610:14d::5) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8356.21; Fri, 24 Jan 2025 11:43:57 +0000 Received: from BN2PEPF000044A2.namprd02.prod.outlook.com (2603:10b6:208:19b:cafe::c3) by MN2PR19CA0060.outlook.office365.com (2603:10b6:208:19b::37) with Microsoft SMTP Server (version=TLS1_3, cipher=TLS_AES_256_GCM_SHA384) id 15.20.8335.18 via Frontend Transport; Fri, 24 Jan 2025 11:43:57 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 216.228.117.160) smtp.mailfrom=nvidia.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=nvidia.com; Received-SPF: Pass (protection.outlook.com: domain of nvidia.com designates 216.228.117.160 as permitted sender) receiver=protection.outlook.com; client-ip=216.228.117.160; helo=mail.nvidia.com; pr=C Received: from mail.nvidia.com (216.228.117.160) by BN2PEPF000044A2.mail.protection.outlook.com (10.167.243.153) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8377.8 via Frontend Transport; Fri, 24 Jan 2025 11:43:56 +0000 Received: from rnnvmail202.nvidia.com (10.129.68.7) by mail.nvidia.com (10.129.200.66) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Fri, 24 Jan 2025 03:43:47 -0800 Received: from rnnvmail203.nvidia.com (10.129.68.9) by rnnvmail202.nvidia.com (10.129.68.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4; Fri, 24 Jan 2025 03:43:46 -0800 Received: from nvidia.com (10.127.8.9) by mail.nvidia.com (10.129.68.9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1544.4 via Frontend Transport; Fri, 24 Jan 2025 03:43:45 -0800 From: Shani Peretz To: CC: , , Shani Peretz , Aman Singh Subject: [PATCH v2 2/3] app/testpmd: added testpmd commands to enable/disable xstat Date: Fri, 24 Jan 2025 13:43:34 +0200 Message-ID: <20250124114336.16610-3-shperetz@nvidia.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20250124114336.16610-1-shperetz@nvidia.com> References: <20241222153819.62519-1-shperetz@nvidia.com> <20250124114336.16610-1-shperetz@nvidia.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-NV-OnPremToCloud: AnonymousSubmission X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN2PEPF000044A2:EE_|CH3PR12MB7668:EE_ X-MS-Office365-Filtering-Correlation-Id: f3b7f7ea-d8ff-4e93-f867-08dd3c6c62f0 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; ARA:13230040|82310400026|1800799024|376014|36860700013; X-Microsoft-Antispam-Message-Info: =?us-ascii?Q?0gaGOepr8Ktta4f8wtDm5WNBG/e/DCJh3k1BIowjyp9xTG+VFHGjLGE1RXcQ?= =?us-ascii?Q?TRNkEhxYSJzT4KGi5rLi2jtV8YqeRRGVsBXjI59SrS7P4uI/6xdtQzWiWlMg?= =?us-ascii?Q?HBWAnAuCow5z8zM217ol0yGkl/jjSrkjADHMl1s5qecKnmls+smdPH+Qlguv?= =?us-ascii?Q?Oge2Y75/ld+EKuLvuX+WHHgPXb9te8dTNEzBSUqR4wPk+IKnjr6WJpssCOO8?= =?us-ascii?Q?VFTWHCVcVj1w1DTkNVv0N8qVtESy5FKdmowUG/Fn7brPt2+bQjO1Gmc0r5e5?= =?us-ascii?Q?2Xstpl8bvp/kVg3yb1flRUiOWH1e3g7T0KKl9PKNPK56QJdbIGqSlf7CUITn?= =?us-ascii?Q?nPq02Rko8nyA+tlFrdZ45lEICHQ8IThfUTiTGHaWH8FLu+J+oA4iZXLNClNo?= =?us-ascii?Q?7jFXt6OQ/CZgdWnjnPLR3h15VWjV3R2wvY6bn58o3LzGyARaU5CcVADCYGrF?= =?us-ascii?Q?OnQockF8f+tXnKDKH2rW85W3oPxHL8rxheADFg4Day3WFYh3JnGghY7tLaUF?= =?us-ascii?Q?8COmOiakMUsIMmeWw5yLropt1kvLoVN35WctDKtrRrEfVrzGDwk6Oi4Aba0v?= =?us-ascii?Q?zQ9EWCNmDvqzHf117MYTFxLO9b2nBI7lXAirR6aQZffmB8CRU0KqhGGKDk8I?= =?us-ascii?Q?INujOfMkaOVOtx04Mecd4w/7tkcc7msnJbNyr0mGYHFF0WBGyBXFIOI09d7X?= =?us-ascii?Q?U79jmbxfQIQebpYxcdOVi0CDJzyEvzv4GcOnmmm8lGXPWgw9BFAqjTAwWBqK?= =?us-ascii?Q?0f+3Ni1WEErUaNquz34lN2ZYEyw3Utlk0noho7Ur8LhXD7E45hX6Q5eYkfu5?= =?us-ascii?Q?brUEFk06MznkKrldvecnwWot+aU3gUpEQePF3Dv3AJLa0UR8qR2KFBvvGxWH?= =?us-ascii?Q?zzHpoIbAP6YyH1/MtOjRCGQPErN6IW9Ivl4P8OCcml8thd7uEm09oQmdEMC4?= =?us-ascii?Q?yPXOP29LLBlZODfG5Wfy7B0GF8H0OXpjQX5D+R72k+q3tfiQkA9xzBYV/8lJ?= =?us-ascii?Q?6eUGNZJJ8NTm1v4sV20bMt7ygH0c9InqfP+OxogrHheBIfkYgXtIZClBa1Fq?= =?us-ascii?Q?nqea2W/7N4R25HJp9JhF0XMMLg1jIDM8XhBJzFJo26ArO3pXi7B8mTbqnWah?= =?us-ascii?Q?K8zmmwju31JhHyNaAJWRxme3osI5lfyySDbT+WB5DBpNITphWvUaEQTXprLd?= =?us-ascii?Q?J1K2Y9fZxZelbR8zQ8Z0hWha1aF67B1ZCChbiBUlnd9xQ96Edv3dyVqmU6EN?= =?us-ascii?Q?J/ttWzJYHg0EsS91a4Jn8saaL9sD0+0cyV4OzWQMsgUQmSbTgjGIMZdIRCcR?= =?us-ascii?Q?mXOwAY4K9m8R+j2ywGQxOeh1b5dfHk3me4z30SOMVaCNnGwz80/Uh2lRcWwj?= =?us-ascii?Q?7MS22ZuYu/f6oLjJP6ZLKmOgRbAnPyExl4XU8NLSCYk0hn8nInFp5JN70600?= =?us-ascii?Q?LMvLWIoaVDi5G4kNH3qR8qiTtawOrXWj2ax3VTEhrsIXZ45Zf+DhaFKpzyh5?= =?us-ascii?Q?4hPZIoaaKb3QDYk=3D?= X-Forefront-Antispam-Report: CIP:216.228.117.160; CTRY:US; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:mail.nvidia.com; PTR:dc6edge1.nvidia.com; CAT:NONE; SFS:(13230040)(82310400026)(1800799024)(376014)(36860700013); DIR:OUT; SFP:1101; X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 24 Jan 2025 11:43:56.8541 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f3b7f7ea-d8ff-4e93-f867-08dd3c6c62f0 X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=43083d15-7273-40c1-b7db-39efd9ccc17a; Ip=[216.228.117.160]; Helo=[mail.nvidia.com] X-MS-Exchange-CrossTenant-AuthSource: BN2PEPF000044A2.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CH3PR12MB7668 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 Added the following testpmd subcommands: toggle the counter on and off > port (port_id) enable|disable query the state of counters: > set xstats-hide-disabled on|off Signed-off-by: Shani Peretz --- app/test-pmd/cmdline.c | 125 +++++++++++++++++++++++++++++++ app/test-pmd/config.c | 96 ++++++++++++++++++++++++ app/test-pmd/testpmd.c | 10 +++ app/test-pmd/testpmd.h | 5 ++ lib/cmdline/cmdline_parse_bool.c | 49 ++++++++++++ lib/cmdline/cmdline_parse_bool.h | 39 ++++++++++ lib/cmdline/cmdline_parse_num.c | 2 +- lib/cmdline/cmdline_parse_num.h | 1 + lib/cmdline/meson.build | 2 + lib/cmdline/version.map | 7 ++ 10 files changed, 335 insertions(+), 1 deletion(-) create mode 100644 lib/cmdline/cmdline_parse_bool.c create mode 100644 lib/cmdline/cmdline_parse_bool.h diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 7e0666e9f6..f12715b8eb 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include @@ -7960,6 +7961,127 @@ static cmdline_parse_inst_t cmd_set_xstats_hide_zero = { }, }; +/* *** SET OPTION TO DISPLAY XSTAT STATE *** */ +struct cmd_set_xstats_show_state_result { + cmdline_fixed_string_t keyword; + cmdline_fixed_string_t name; + uint8_t on_off; +}; +static void +cmd_set_xstats_show_state_parsed(void *parsed_result, + __rte_unused struct cmdline *cl, + __rte_unused void *data) +{ + struct cmd_set_xstats_show_state_result *res = parsed_result; + set_xstats_show_state(res->on_off); +} + +static cmdline_parse_token_string_t cmd_set_xstats_show_state_keyword = + TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_show_state_result, + keyword, "set"); +static cmdline_parse_token_string_t cmd_set_xstats_show_state_name = + TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_show_state_result, + name, "xstats-show-state"); +static cmdline_parse_token_bool_t cmd_set_xstats_show_state_on_off = + TOKEN_BOOL_INITIALIZER(struct cmd_set_xstats_show_state_result, + on_off); + +static cmdline_parse_inst_t cmd_set_xstats_show_state = { + .f = cmd_set_xstats_show_state_parsed, + .data = NULL, + .help_str = "set xstats-show-state on|off", + .tokens = { + (void *)&cmd_set_xstats_show_state_keyword, + (void *)&cmd_set_xstats_show_state_name, + (void *)&cmd_set_xstats_show_state_on_off, + NULL, + }, +}; + +/* *** SET OPTION TO HIDE DISABLED XSTAT FOR XSTATS DISPLAY *** */ +struct cmd_set_xstats_hide_disabled_result { + cmdline_fixed_string_t keyword; + cmdline_fixed_string_t name; + uint8_t on_off; +}; + +static void +cmd_set_xstats_hide_disabled_parsed(void *parsed_result, + __rte_unused struct cmdline *cl, + __rte_unused void *data) +{ + struct cmd_set_xstats_hide_disabled_result *res = parsed_result; + set_xstats_hide_disabled(res->on_off); +} + +static cmdline_parse_token_string_t cmd_set_xstats_hide_disabled_keyword = + TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_disabled_result, + keyword, "set"); +static cmdline_parse_token_string_t cmd_set_xstats_hide_disabled_name = + TOKEN_STRING_INITIALIZER(struct cmd_set_xstats_hide_disabled_result, + name, "xstats-hide-disabled"); +static cmdline_parse_token_bool_t cmd_set_xstats_hide_disabled_on_off = + TOKEN_BOOL_INITIALIZER(struct cmd_set_xstats_hide_disabled_result, + on_off); + +static cmdline_parse_inst_t cmd_set_xstats_hide_disabled = { + .f = cmd_set_xstats_hide_disabled_parsed, + .data = NULL, + .help_str = "set xstats-hide-disabled on|off", + .tokens = { + (void *)&cmd_set_xstats_hide_disabled_keyword, + (void *)&cmd_set_xstats_hide_disabled_name, + (void *)&cmd_set_xstats_hide_disabled_on_off, + NULL, + }, +}; + +/* *** enable/disable counter by name *** */ +struct cmd_operate_set_counter_result { + cmdline_fixed_string_t port; + portid_t port_id; + cmdline_fixed_string_t what; + cmdline_multi_string_t counter_name; +}; + +static void +cmd_operate_set_counter_parsed(void *parsed_result, + __rte_unused struct cmdline *cl, + __rte_unused void *data) +{ + struct cmd_operate_set_counter_result *res = parsed_result; + uint16_t on_off = strcmp(res->what, "enable") ? 0 : 1; + + if ((strcmp(res->port, "port") == 0)) + nic_xstats_set_counter(res->port_id, res->counter_name, on_off); +} + +static cmdline_parse_token_string_t cmd_operate_set_counter_port = + TOKEN_STRING_INITIALIZER(struct cmd_operate_set_counter_result, + port, "port"); +static cmdline_parse_token_num_t cmd_operate_set_counter_port_id = + TOKEN_NUM_INITIALIZER(struct cmd_operate_set_counter_result, + port_id, RTE_UINT16); +static cmdline_parse_token_string_t cmd_operate_set_counter_what = + TOKEN_STRING_INITIALIZER(struct cmd_operate_set_counter_result, + what, "enable#disable"); +static cmdline_parse_token_string_t cmd_operate_set_counter_name = + TOKEN_STRING_INITIALIZER(struct cmd_operate_set_counter_result, + counter_name, TOKEN_STRING_MULTI); + +static cmdline_parse_inst_t cmd_operate_set_counter = { + .f = cmd_operate_set_counter_parsed, + .data = NULL, + .help_str = "port (port_id) enable|disable ", + .tokens = { + (void *)&cmd_operate_set_counter_port, + (void *)&cmd_operate_set_counter_port_id, + (void *)&cmd_operate_set_counter_what, + (void *)&cmd_operate_set_counter_name, + NULL, + }, +}; + /* *** SET OPTION TO ENABLE MEASUREMENT OF CPU CYCLES *** */ struct cmd_set_record_core_cycles_result { cmdline_fixed_string_t keyword; @@ -13648,6 +13770,9 @@ static cmdline_parse_ctx_t builtin_ctx[] = { &cmd_set_fwd_eth_peer, &cmd_set_qmap, &cmd_set_xstats_hide_zero, + &cmd_set_xstats_show_state, + &cmd_set_xstats_hide_disabled, + &cmd_operate_set_counter, &cmd_set_record_core_cycles, &cmd_set_record_burst_stats, &cmd_operate_port, diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 4e7fb69183..c77a34fddc 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -393,6 +393,7 @@ nic_xstats_display(portid_t port_id) struct rte_eth_xstat *xstats; int cnt_xstats, idx_xstat; struct rte_eth_xstat_name *xstats_names; + int state; if (port_id_is_invalid(port_id, ENABLED_WARN)) { print_valid_ports(); @@ -442,6 +443,17 @@ nic_xstats_display(portid_t port_id) for (idx_xstat = 0; idx_xstat < cnt_xstats; idx_xstat++) { if (xstats_hide_zero && !xstats[idx_xstat].value) continue; + if (xstats_hide_disabled) { + state = rte_eth_xstats_query_state(port_id, idx_xstat); + if (state == 0) + continue; + } + if (xstats_show_state) { + char opt[3] = {'D', 'E', '-'}; + state = rte_eth_xstats_query_state(port_id, idx_xstat); + printf("state: %c ", state < 0 ? opt[2] : opt[state]); + } + printf("%s: %"PRIu64"\n", xstats_names[idx_xstat].name, xstats[idx_xstat].value); @@ -6437,6 +6449,78 @@ rx_vlan_strip_set_on_queue(portid_t port_id, uint16_t queue_id, int on) __func__, port_id, queue_id, on, diag); } +void +nic_xstats_set_counter(portid_t port_id, char *counter_name, int on) +{ + struct rte_eth_xstat_name *xstats_names; + int cnt_xstats; + int ret; + uint64_t id; + + if (port_id_is_invalid(port_id, ENABLED_WARN)) { + print_valid_ports(); + return; + } + if (!rte_eth_dev_is_valid_port(port_id)) { + fprintf(stderr, "Error: Invalid port number %i\n", port_id); + return; + } + + if (counter_name == NULL) { + fprintf(stderr, "Error: Invalid counter name\n"); + return; + } + + /* Get count */ + cnt_xstats = rte_eth_xstats_get_names(port_id, NULL, 0); + if (cnt_xstats < 0) { + fprintf(stderr, "Error: Cannot get count of xstats\n"); + return; + } + + /* Get id-name lookup table */ + xstats_names = malloc(sizeof(struct rte_eth_xstat_name) * cnt_xstats); + if (xstats_names == NULL) { + fprintf(stderr, "Cannot allocate memory for xstats lookup\n"); + return; + } + if (cnt_xstats != rte_eth_xstats_get_names( + port_id, xstats_names, cnt_xstats)) { + fprintf(stderr, "Error: Cannot get xstats lookup\n"); + free(xstats_names); + return; + } + + if (rte_eth_xstats_get_id_by_name(port_id, counter_name, &id) < 0) { + fprintf(stderr, "Cannot find xstats with a given name\n"); + free(xstats_names); + return; + } + + /* set counter */ + ret = rte_eth_xstats_set_counter(port_id, id, on); + if (ret < 0) { + switch (ret) { + case -EINVAL: + fprintf(stderr, "failed to find %s\n", counter_name); + break; + case -ENOTSUP: + fprintf(stderr, "operation not supported by device\n"); + break; + case -ENOSPC: + fprintf(stderr, "there were not enough available counters\n"); + break; + case -EPERM: + fprintf(stderr, "operation not premitted\n"); + break; + default: + fprintf(stderr, "operation failed - diag=%d\n", ret); + break; + } + } + free(xstats_names); +} + void rx_vlan_filter_set(portid_t port_id, int on) { @@ -6665,6 +6749,18 @@ set_xstats_hide_zero(uint8_t on_off) xstats_hide_zero = on_off; } +void +set_xstats_show_state(uint8_t on_off) +{ + xstats_show_state = on_off; +} + +void +set_xstats_hide_disabled(uint8_t on_off) +{ + xstats_hide_disabled = on_off; +} + void set_record_core_cycles(uint8_t on_off) { diff --git a/app/test-pmd/testpmd.c b/app/test-pmd/testpmd.c index ac654048df..2bafe730b9 100644 --- a/app/test-pmd/testpmd.c +++ b/app/test-pmd/testpmd.c @@ -500,6 +500,16 @@ volatile int test_done = 1; /* stop packet forwarding when set to 1. */ */ uint8_t xstats_hide_zero; +/* + * Display of xstats without their state disabled by default + */ +uint8_t xstats_show_state; + +/* + * Display disabled xstat by default for xstats + */ +uint8_t xstats_hide_disabled; + /* * Measure of CPU cycles disabled by default */ diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index 260e4761bd..a88c1aeaf6 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -498,6 +498,8 @@ enum dcb_mode_enable }; extern uint8_t xstats_hide_zero; /**< Hide zero values for xstats display */ +extern uint8_t xstats_hide_disabled; /**< Hide disabled xstat for xstats display */ +extern uint8_t xstats_show_state; /**< Show xstat state in xstats display */ /* globals used for configuration */ extern uint8_t record_core_cycles; /**< Enables measurement of CPU cycles */ @@ -933,6 +935,7 @@ void nic_stats_display(portid_t port_id); void nic_stats_clear(portid_t port_id); void nic_xstats_display(portid_t port_id); void nic_xstats_clear(portid_t port_id); +void nic_xstats_set_counter(portid_t port_id, char *counter_name, int on); void device_infos_display(const char *identifier); void port_infos_display(portid_t port_id); void port_summary_display(portid_t port_id); @@ -1111,6 +1114,8 @@ void tx_vlan_pvid_set(portid_t port_id, uint16_t vlan_id, int on); void set_qmap(portid_t port_id, uint8_t is_rx, uint16_t queue_id, uint8_t map_value); void set_xstats_hide_zero(uint8_t on_off); +void set_xstats_show_state(uint8_t on_off); +void set_xstats_hide_disabled(uint8_t on_off); void set_record_core_cycles(uint8_t on_off); void set_record_burst_stats(uint8_t on_off); diff --git a/lib/cmdline/cmdline_parse_bool.c b/lib/cmdline/cmdline_parse_bool.c new file mode 100644 index 0000000000..aa7bf88d5a --- /dev/null +++ b/lib/cmdline/cmdline_parse_bool.c @@ -0,0 +1,49 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright (c) 2023 NVIDIA Corporation & Affiliates + */ + +#include +#include +#include +#include +#include +#include + +#include "cmdline_parse.h" +#include "cmdline_parse_bool.h" + + +struct cmdline_token_ops cmdline_token_bool_ops = { + .parse = cmdline_parse_bool, + .complete_get_nb = NULL, + .complete_get_elt = NULL, + .get_help = cmdline_get_help_string, +}; + +static cmdline_parse_token_string_t cmd_parse_token_bool = { + { + &cmdline_token_string_ops, + 0 + }, + { + "on#off" + } +}; + +/* parse string to bool */ +int +cmdline_parse_bool(__rte_unused cmdline_parse_token_hdr_t *tk, const char *srcbuf, void *res, + __rte_unused unsigned int ressize) +{ + cmdline_fixed_string_t on_off = {0}; + if (cmdline_token_string_ops.parse + (&cmd_parse_token_bool.hdr, srcbuf, on_off, sizeof(on_off)) < 0) + return -1; + + if (strcmp((char *)on_off, "on") == 0) + *(uint8_t *)res = 1; + else if (strcmp((char *)on_off, "off") == 0) + *(uint8_t *)res = 0; + + return strlen(on_off); +} diff --git a/lib/cmdline/cmdline_parse_bool.h b/lib/cmdline/cmdline_parse_bool.h new file mode 100644 index 0000000000..a601e4f54b --- /dev/null +++ b/lib/cmdline/cmdline_parse_bool.h @@ -0,0 +1,39 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright (c) 2023 NVIDIA Corporation & Affiliates + */ + +#ifndef _PARSE_BOOL_H_ +#define _PARSE_BOOL_H_ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +struct cmdline_token_bool { + struct cmdline_token_hdr hdr; +}; + +typedef struct cmdline_token_bool cmdline_parse_token_bool_t; +extern struct cmdline_token_ops cmdline_token_bool_ops; + +int cmdline_parse_bool(cmdline_parse_token_hdr_t *tk, + const char *srcbuf, void *res, unsigned int ressize); + +#define TOKEN_BOOL_INITIALIZER(structure, field) \ +{ \ + /* hdr */ \ + { \ + &cmdline_token_bool_ops, /* ops */ \ + offsetof(structure, field), /* offset */ \ + } \ +} + + +#ifdef __cplusplus +} +#endif + +#endif /* _PARSE_BOOL_H_ */ diff --git a/lib/cmdline/cmdline_parse_num.c b/lib/cmdline/cmdline_parse_num.c index e8498788fa..6dc325e6da 100644 --- a/lib/cmdline/cmdline_parse_num.c +++ b/lib/cmdline/cmdline_parse_num.c @@ -9,6 +9,7 @@ #include #include #include +#include #include "cmdline_parse.h" #include "cmdline_parse_num.h" @@ -26,7 +27,6 @@ struct cmdline_token_ops cmdline_token_num_ops = { .get_help = cmdline_get_help_num, }; - enum num_parse_state_t { START, DEC_NEG, diff --git a/lib/cmdline/cmdline_parse_num.h b/lib/cmdline/cmdline_parse_num.h index 02133bb21c..bdd0267612 100644 --- a/lib/cmdline/cmdline_parse_num.h +++ b/lib/cmdline/cmdline_parse_num.h @@ -8,6 +8,7 @@ #define _PARSE_NUM_H_ #include +#include #ifdef __cplusplus extern "C" { diff --git a/lib/cmdline/meson.build b/lib/cmdline/meson.build index 63fb69100d..e38e05893a 100644 --- a/lib/cmdline/meson.build +++ b/lib/cmdline/meson.build @@ -7,6 +7,7 @@ sources = files('cmdline.c', 'cmdline_parse_etheraddr.c', 'cmdline_parse_ipaddr.c', 'cmdline_parse_num.c', + 'cmdline_parse_bool.c', 'cmdline_parse_portlist.c', 'cmdline_parse_string.c', 'cmdline_rdline.c', @@ -16,6 +17,7 @@ sources = files('cmdline.c', headers = files('cmdline.h', 'cmdline_parse.h', 'cmdline_parse_num.h', + 'cmdline_parse_bool.h', 'cmdline_parse_ipaddr.h', 'cmdline_parse_etheraddr.h', 'cmdline_parse_string.h', diff --git a/lib/cmdline/version.map b/lib/cmdline/version.map index 6bcfebfcec..08050ea3f3 100644 --- a/lib/cmdline/version.map +++ b/lib/cmdline/version.map @@ -73,3 +73,10 @@ DPDK_25 { local: *; }; + +EXPERIMENTAL { + global: + + # added in 25.03 + cmdline_token_bool_ops; +}; \ No newline at end of file -- 2.34.1