DPDK patches and discussions
 help / color / mirror / Atom feed
From: Anatoly Burakov <anatoly.burakov@intel.com>
To: dev@dpdk.org, Aman Singh <aman.deep.singh@intel.com>
Subject: [PATCH v3 2/2] app/testpmd: add sleep command
Date: Wed,  7 May 2025 10:50:12 +0100	[thread overview]
Message-ID: <b63d39929fcc3f7410fe10bb1aa1467738fa60e8.1746611372.git.anatoly.burakov@intel.com> (raw)
In-Reply-To: <f9054c20d6ac09b82a4c03df268541118e8e9222.1746611372.git.anatoly.burakov@intel.com>

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 <anatoly.burakov@intel.com>
---

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 <secs>: 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


  reply	other threads:[~2025-05-07  9:50 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-02 12:27 [PATCH v1 1/1] " Anatoly Burakov
2025-05-02 12:37 ` Bruce Richardson
2025-05-02 14:35   ` Burakov, Anatoly
2025-05-02 14:43     ` Bruce Richardson
2025-05-02 15:33       ` Morten Brørup
2025-05-02 15:42 ` Stephen Hemminger
2025-05-06 12:36   ` Burakov, Anatoly
2025-05-06 13:08 ` [PATCH v2 1/2] cmdline: add floating point support Anatoly Burakov
2025-05-06 13:08   ` [PATCH v2 2/2] app/testpmd: add sleep command Anatoly Burakov
2025-05-06 13:38   ` [PATCH v2 1/2] cmdline: add floating point support Bruce Richardson
2025-05-07  9:02     ` Burakov, Anatoly
2025-05-07  9:50 ` [PATCH v3 " Anatoly Burakov
2025-05-07  9:50   ` Anatoly Burakov [this message]
2025-05-07  9:53   ` Burakov, Anatoly
2025-05-07 10:01 ` [PATCH v4 " Anatoly Burakov
2025-05-07 10:01   ` [PATCH v4 2/2] app/testpmd: add sleep command Anatoly Burakov
2025-05-07 10:35   ` [PATCH v4 1/2] cmdline: add floating point support Konstantin Ananyev
2025-05-07 11:06     ` Burakov, Anatoly
2025-05-07 12:24       ` Konstantin Ananyev
2025-05-07 14:06         ` Burakov, Anatoly
2025-05-07 15:22 ` [PATCH v5 1/3] cmdline: use C standard library as number parser Anatoly Burakov
2025-05-07 15:22   ` [PATCH v5 2/3] cmdline: add floating point support Anatoly Burakov
2025-05-07 15:22   ` [PATCH v5 3/3] app/testpmd: add sleep command Anatoly Burakov
2025-05-08  7:27   ` [PATCH v5 1/3] cmdline: use C standard library as number parser Bruce Richardson
2025-05-08  8:35     ` Burakov, Anatoly
2025-05-08  9:53 ` [PATCH v6 " Anatoly Burakov
2025-05-08  9:53   ` [PATCH v6 2/3] cmdline: add floating point support Anatoly Burakov
2025-05-08  9:53   ` [PATCH v6 3/3] app/testpmd: add sleep command Anatoly Burakov
2025-05-08 10:01 ` [PATCH v7 1/3] cmdline: use C standard library as number parser Anatoly Burakov
2025-05-08 10:01   ` [PATCH v7 2/3] cmdline: add floating point support Anatoly Burakov
2025-05-08 10:09     ` Burakov, Anatoly
2025-05-08 10:01   ` [PATCH v7 3/3] app/testpmd: add sleep command Anatoly Burakov
2025-05-08 13:16 ` [PATCH v8 1/3] cmdline: use C standard library as number parser Anatoly Burakov
2025-05-08 13:16   ` [PATCH v8 2/3] cmdline: add floating point support Anatoly Burakov
2025-05-08 13:16   ` [PATCH v8 3/3] app/testpmd: add sleep command Anatoly Burakov
2025-05-09 13:02   ` [PATCH v8 1/3] cmdline: use C standard library as number parser Burakov, Anatoly
2025-05-09 13:08     ` Burakov, Anatoly
2025-05-09 13:27       ` Burakov, Anatoly
2025-05-09 13:39 ` [PATCH v9 " Anatoly Burakov
2025-05-09 13:39   ` [PATCH v9 2/3] cmdline: add floating point support Anatoly Burakov
2025-05-09 13:39   ` [PATCH v9 3/3] app/testpmd: add sleep command Anatoly Burakov
2025-05-09 13:42   ` [PATCH v9 1/3] cmdline: use C standard library as number parser Burakov, Anatoly
2025-05-09 14:41 ` [PATCH v10 " Anatoly Burakov
2025-05-09 14:41   ` [PATCH v10 2/3] cmdline: add floating point support Anatoly Burakov
2025-05-09 14:41   ` [PATCH v10 3/3] app/testpmd: add sleep command Anatoly Burakov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=b63d39929fcc3f7410fe10bb1aa1467738fa60e8.1746611372.git.anatoly.burakov@intel.com \
    --to=anatoly.burakov@intel.com \
    --cc=aman.deep.singh@intel.com \
    --cc=dev@dpdk.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).