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 6E366466F6; Thu, 8 May 2025 15:16:27 +0200 (CEST) Received: from mails.dpdk.org (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 27B27406BC; Thu, 8 May 2025 15:16:12 +0200 (CEST) Received: from mgamail.intel.com (mgamail.intel.com [198.175.65.19]) by mails.dpdk.org (Postfix) with ESMTP id 5BAA040691 for ; Thu, 8 May 2025 15:16:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1746710171; x=1778246171; h=from:to:subject:date:message-id:in-reply-to:references: mime-version:content-transfer-encoding; bh=RzHa5of77EOJQw4EoOzRsksZ8HRb/DUzlY2mEjxjTxg=; b=BPS14QJgFoAevpwbTNg6Bkny2WJNI7Yf4CTrxjmEuXMalGcSztdFPxK0 7uUc05wPmwS0fo8H7RibqssEPhs8204w6sO6DqathAEqhB9r2p5juAKf6 VLwrJIW1xWuFpFhc3l5v8QPxDIFLJuqCuzw6kyWWP/MORYUCi0hwLs7Z+ GM4flYCTDFWNb9SI4NsK0cMeR9EuSbhikNxdXCuEuoKKpFcyDljY9ZbkY 6ltgXQsQixWUGRa9Bos+HC4sX8uR5fTRhJ/Ek1tuxPMk/zM1mL+4Ipglv I5nLE/M0ySH/0/wbdgDCRZ//f7to+NVJgyLumMGK8uSNSXbKjWi2e5nei g==; X-CSE-ConnectionGUID: oXBx7O7jTrOdeou7xYTOug== X-CSE-MsgGUID: eYRT+oOIQ8K1+1I40N7n5w== X-IronPort-AV: E=McAfee;i="6700,10204,11426"; a="48359616" X-IronPort-AV: E=Sophos;i="6.15,272,1739865600"; d="scan'208";a="48359616" Received: from fmviesa010.fm.intel.com ([10.60.135.150]) by orvoesa111.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 08 May 2025 06:16:10 -0700 X-CSE-ConnectionGUID: eLFk/juXSO6b9x2aYOykpw== X-CSE-MsgGUID: VUDVWR3LTiaMmTDzNaSN0g== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.15,272,1739865600"; d="scan'208";a="136781211" Received: from silpixa00401119.ir.intel.com ([10.55.129.167]) by fmviesa010.fm.intel.com with ESMTP; 08 May 2025 06:16:09 -0700 From: Anatoly Burakov To: dev@dpdk.org, Aman Singh Subject: [PATCH v8 3/3] app/testpmd: add sleep command Date: Thu, 8 May 2025 14:16:03 +0100 Message-ID: <15755be6192657d1e75940284d09939e58aee5b9.1746710154.git.anatoly.burakov@intel.com> X-Mailer: git-send-email 2.47.1 In-Reply-To: <7bebd92be36f945c175382bb1e0482e55844c1d2.1746710154.git.anatoly.burakov@intel.com> References: 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 Test-pmd already has a way to run a list of commands from file, but there is no way to pause execution for a specified amount of time between two commands. This may be necessary for simple automation, particularly for waiting on some asynchronous operation such as link status update. Add a simple sleep command to wait until certain number of seconds has passed, using the newly added cmdline library floating point support. Signed-off-by: Anatoly Burakov --- Notes: v1 -> v2: - Add floating point support to cmdline - Use floating point format for pause command app/test-pmd/cmdline.c | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index d4bb3ec998..b6152c07e6 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -151,6 +151,9 @@ static void cmd_help_long_parsed(void *parsed_result, "quit\n" " Quit to prompt.\n\n" + + "sleep secs\n" + " Sleep for secs seconds (can be fractional).\n\n" ); } @@ -7768,6 +7771,37 @@ static cmdline_parse_inst_t cmd_quit = { }, }; +/* *** SLEEP *** */ +struct cmd_sleep_result { + cmdline_fixed_string_t sleep; + double secs; +}; + +static void cmd_sleep_parsed(void *parsed_result, + __rte_unused struct cmdline *cl, + __rte_unused void *data) +{ + struct cmd_sleep_result *res = parsed_result; + + rte_delay_us_sleep(res->secs * 1E6); +} + +static cmdline_parse_token_string_t cmd_sleep_sleep = + TOKEN_STRING_INITIALIZER(struct cmd_sleep_result, sleep, "sleep"); +static cmdline_parse_token_num_t cmd_sleep_seconds = + TOKEN_NUM_INITIALIZER(struct cmd_sleep_result, secs, RTE_FLOAT_DOUBLE); + +static cmdline_parse_inst_t cmd_sleep = { + .f = cmd_sleep_parsed, + .data = NULL, + .help_str = "sleep : Sleep for a specified number of seconds", + .tokens = { + (void *)&cmd_sleep_sleep, + (void *)&cmd_sleep_seconds, + NULL, + }, +}; + /* *** ADD/REMOVE MAC ADDRESS FROM A PORT *** */ struct cmd_mac_addr_result { cmdline_fixed_string_t mac_addr_cmd; @@ -13711,6 +13745,7 @@ static cmdline_parse_ctx_t builtin_ctx[] = { &cmd_showdevice, &cmd_showcfg, &cmd_showfwdall, + &cmd_sleep, &cmd_start, &cmd_start_tx_first, &cmd_start_tx_first_n, -- 2.47.1