[v3] net/mlx5: add test for live migration

Message ID 20230919081225.480497-1-rongweil@nvidia.com (mailing list archive)
State Superseded, archived
Delegated to: Raslan Darawsheh
Headers
Series [v3] net/mlx5: add test for live migration |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/loongarch-compilation success Compilation OK
ci/loongarch-unit-testing success Unit Testing PASS
ci/Intel-compilation success Compilation OK
ci/intel-Testing success Testing PASS
ci/github-robot: build success github build: passed
ci/intel-Functional success Functional PASS
ci/iol-mellanox-Performance success Performance Testing PASS
ci/iol-broadcom-Performance success Performance Testing PASS
ci/iol-compile-amd64-testing success Testing PASS
ci/iol-intel-Performance success Performance Testing PASS
ci/iol-broadcom-Functional success Functional Testing PASS
ci/iol-intel-Functional success Functional Testing PASS
ci/iol-unit-amd64-testing success Testing PASS
ci/iol-sample-apps-testing success Testing PASS
ci/iol-unit-arm64-testing success Testing PASS
ci/iol-compile-arm64-testing success Testing PASS

Commit Message

Rongwei Liu Sept. 19, 2023, 8:12 a.m. UTC
  This patch adds testpmd app a runtime function to test the live
migration API.

    testpmd> mlx5 set flow_engine <active|standby> [<flag>]
Flag is optional.

Signed-off-by: Rongwei Liu <rongweil@nvidia.com>
Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
Acked-by: Ori Kam <orika@nvidia.com>

v3: Add missing --in-reply-to option.
v2: Change the command prompt from integer to string.
---
 doc/guides/nics/mlx5.rst        |  14 ++++
 drivers/net/mlx5/mlx5_testpmd.c | 124 ++++++++++++++++++++++++++++++++
 2 files changed, 138 insertions(+)
  

Comments

Thomas Monjalon Oct. 16, 2023, 8:19 a.m. UTC | #1
19/09/2023 10:12, Rongwei Liu:
> This patch adds testpmd app a runtime function to test the live
> migration API.
> 
>     testpmd> mlx5 set flow_engine <active|standby> [<flag>]
> Flag is optional.
> 
> Signed-off-by: Rongwei Liu <rongweil@nvidia.com>
> Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
> Acked-by: Ori Kam <orika@nvidia.com>
[...]
> +Set Flow Engine Mode
> +~~~~~~~~~~~~~~~~~~~~
> +
> +Set the flow engine to active(0) or standby(1) mode with specific flags::

Need space before brackets.

> +
> +.. code-block:: console
> +
> +   testpmd> mlx5 set flow_engine <active|standby> [<flags>]

What are the flags?

> +
> +This command is used for testing live migration and works for
> +software steering only.
> +Default FDB jump should be disabled if switchdev is enabled.
> +The mode will propagate to all the probed ports.

Looks OK.
  
Rongwei Liu Oct. 16, 2023, 8:25 a.m. UTC | #2
HI

BR
Rongwei

> -----Original Message-----
> From: Thomas Monjalon <thomas@monjalon.net>
> Sent: Monday, October 16, 2023 16:20
> To: Rongwei Liu <rongweil@nvidia.com>
> Cc: dev@dpdk.org; Matan Azrad <matan@nvidia.com>; Slava Ovsiienko
> <viacheslavo@nvidia.com>; Ori Kam <orika@nvidia.com>; Suanming Mou
> <suanmingm@nvidia.com>; Raslan Darawsheh <rasland@nvidia.com>
> Subject: Re: [PATCH v3] net/mlx5: add test for live migration
> 
> External email: Use caution opening links or attachments
> 
> 
> 19/09/2023 10:12, Rongwei Liu:
> > This patch adds testpmd app a runtime function to test the live
> > migration API.
> >
> >     testpmd> mlx5 set flow_engine <active|standby> [<flag>] Flag is
> > optional.
> >
> > Signed-off-by: Rongwei Liu <rongweil@nvidia.com>
> > Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
> > Acked-by: Ori Kam <orika@nvidia.com>
> [...]
> > +Set Flow Engine Mode
> > +~~~~~~~~~~~~~~~~~~~~
> > +
> > +Set the flow engine to active(0) or standby(1) mode with specific flags::
> 
> Need space before brackets.
> 
Sure.
> > +
> > +.. code-block:: console
> > +
> > +   testpmd> mlx5 set flow_engine <active|standby> [<flags>]
> 
> What are the flags?
> 
The flag is optional and defined a as bitmap.
For now, only one value is accepted: BIT(0). 
I don't have any idea to propagate the value definition list here. Any suggestions?
> > +
> > +This command is used for testing live migration and works for
> > +software steering only.
> > +Default FDB jump should be disabled if switchdev is enabled.
> > +The mode will propagate to all the probed ports.
> 
> Looks OK.
>
  
Rongwei Liu Oct. 16, 2023, 9:26 a.m. UTC | #3
BR
Rongwei

> -----Original Message-----
> From: Rongwei Liu <rongweil@nvidia.com>
> Sent: Monday, October 16, 2023 16:26
> To: Thomas Monjalon <thomas@monjalon.net>
> Cc: dev@dpdk.org; Matan Azrad <matan@nvidia.com>; Slava Ovsiienko
> <viacheslavo@nvidia.com>; Ori Kam <orika@nvidia.com>; Suanming Mou
> <suanmingm@nvidia.com>; Raslan Darawsheh <rasland@nvidia.com>
> Subject: RE: [PATCH v3] net/mlx5: add test for live migration
> 
> HI
> 
> BR
> Rongwei
> 
> > -----Original Message-----
> > From: Thomas Monjalon <thomas@monjalon.net>
> > Sent: Monday, October 16, 2023 16:20
> > To: Rongwei Liu <rongweil@nvidia.com>
> > Cc: dev@dpdk.org; Matan Azrad <matan@nvidia.com>; Slava Ovsiienko
> > <viacheslavo@nvidia.com>; Ori Kam <orika@nvidia.com>; Suanming Mou
> > <suanmingm@nvidia.com>; Raslan Darawsheh <rasland@nvidia.com>
> > Subject: Re: [PATCH v3] net/mlx5: add test for live migration
> >
> > External email: Use caution opening links or attachments
> >
> >
> > 19/09/2023 10:12, Rongwei Liu:
> > > This patch adds testpmd app a runtime function to test the live
> > > migration API.
> > >
> > >     testpmd> mlx5 set flow_engine <active|standby> [<flag>] Flag is
> > > optional.
> > >
> > > Signed-off-by: Rongwei Liu <rongweil@nvidia.com>
> > > Acked-by: Viacheslav Ovsiienko <viacheslavo@nvidia.com>
> > > Acked-by: Ori Kam <orika@nvidia.com>
> > [...]
> > > +Set Flow Engine Mode
> > > +~~~~~~~~~~~~~~~~~~~~
> > > +
> > > +Set the flow engine to active(0) or standby(1) mode with specific flags::
> >
> > Need space before brackets.
> >
> Sure.
> > > +
> > > +.. code-block:: console
> > > +
> > > +   testpmd> mlx5 set flow_engine <active|standby> [<flags>]
> >
> > What are the flags?
> >
> The flag is optional and defined a as bitmap.
> For now, only one value is accepted: BIT(0).
> I don't have any idea to propagate the value definition list here. Any
> suggestions?
Add one more description to mention it in bitmap style.
> > > +
> > > +This command is used for testing live migration and works for
> > > +software steering only.
> > > +Default FDB jump should be disabled if switchdev is enabled.
> > > +The mode will propagate to all the probed ports.
> >
> > Looks OK.
> >
  
Thomas Monjalon Oct. 16, 2023, 9:26 a.m. UTC | #4
16/10/2023 10:25, Rongwei Liu:
> From: Thomas Monjalon <thomas@monjalon.net>
> > 19/09/2023 10:12, Rongwei Liu:
> > > +   testpmd> mlx5 set flow_engine <active|standby> [<flags>]
> > 
> > What are the flags?
> > 
> The flag is optional and defined a as bitmap.
> For now, only one value is accepted: BIT(0). 
> I don't have any idea to propagate the value definition list here. Any suggestions?

Just add it and give the usage of the flag or refer to another part of the doc for explanation.
  
Rongwei Liu Oct. 16, 2023, 9:29 a.m. UTC | #5
Hi

BR
Rongwei

> -----Original Message-----
> From: Thomas Monjalon <thomas@monjalon.net>
> Sent: Monday, October 16, 2023 17:27
> To: Rongwei Liu <rongweil@nvidia.com>
> Cc: dev@dpdk.org; Matan Azrad <matan@nvidia.com>; Slava Ovsiienko
> <viacheslavo@nvidia.com>; Ori Kam <orika@nvidia.com>; Suanming Mou
> <suanmingm@nvidia.com>; Raslan Darawsheh <rasland@nvidia.com>
> Subject: Re: [PATCH v3] net/mlx5: add test for live migration
> 
> External email: Use caution opening links or attachments
> 
> 
> 16/10/2023 10:25, Rongwei Liu:
> > From: Thomas Monjalon <thomas@monjalon.net>
> > > 19/09/2023 10:12, Rongwei Liu:
> > > > +   testpmd> mlx5 set flow_engine <active|standby> [<flags>]
> > >
> > > What are the flags?
> > >
> > The flag is optional and defined a as bitmap.
> > For now, only one value is accepted: BIT(0).
> > I don't have any idea to propagate the value definition list here. Any
> suggestions?
> 
> Just add it and give the usage of the flag or refer to another part of the doc for
> explanation.
Change it as: " Set the flow engine to active or standby mode with specific flags (bitmap style)::"
Sound good?
>
  
Rongwei Liu Oct. 25, 2023, 9:07 a.m. UTC | #6
BR
Rongwei

> -----Original Message-----
> From: Rongwei Liu <rongweil@nvidia.com>
> Sent: Monday, October 16, 2023 17:30
> To: NBU-Contact-Thomas Monjalon (EXTERNAL) <thomas@monjalon.net>
> Cc: dev@dpdk.org; Matan Azrad <matan@nvidia.com>; Slava Ovsiienko
> <viacheslavo@nvidia.com>; Ori Kam <orika@nvidia.com>; Suanming Mou
> <suanmingm@nvidia.com>; Raslan Darawsheh <rasland@nvidia.com>
> Subject: RE: [PATCH v3] net/mlx5: add test for live migration
> 
> External email: Use caution opening links or attachments
> 
> 
> Hi
> 
> BR
> Rongwei
> 
> > -----Original Message-----
> > From: Thomas Monjalon <thomas@monjalon.net>
> > Sent: Monday, October 16, 2023 17:27
> > To: Rongwei Liu <rongweil@nvidia.com>
> > Cc: dev@dpdk.org; Matan Azrad <matan@nvidia.com>; Slava Ovsiienko
> > <viacheslavo@nvidia.com>; Ori Kam <orika@nvidia.com>; Suanming Mou
> > <suanmingm@nvidia.com>; Raslan Darawsheh <rasland@nvidia.com>
> > Subject: Re: [PATCH v3] net/mlx5: add test for live migration
> >
> > External email: Use caution opening links or attachments
> >
> >
> > 16/10/2023 10:25, Rongwei Liu:
> > > From: Thomas Monjalon <thomas@monjalon.net>
> > > > 19/09/2023 10:12, Rongwei Liu:
> > > > > +   testpmd> mlx5 set flow_engine <active|standby> [<flags>]
> > > >
> > > > What are the flags?
> > > >
> > > The flag is optional and defined a as bitmap.
> > > For now, only one value is accepted: BIT(0).
> > > I don't have any idea to propagate the value definition list here.
> > > Any
> > suggestions?
> >
> > Just add it and give the usage of the flag or refer to another part of
> > the doc for explanation.
> Change it as: " Set the flow engine to active or standby mode with specific
> flags (bitmap style)::"
> Sound good?
> >
@NBU-Contact-Thomas Monjalon (EXTERNAL) are we good to move forward? Thanks
  

Patch

diff --git a/doc/guides/nics/mlx5.rst b/doc/guides/nics/mlx5.rst
index 7bee57d9dd..5726e497a8 100644
--- a/doc/guides/nics/mlx5.rst
+++ b/doc/guides/nics/mlx5.rst
@@ -2179,3 +2179,17 @@  where:
 * ``sw_queue_id``: queue index in range [64536, 65535].
   This range is the highest 1000 numbers.
 * ``hw_queue_id``: queue index given by HW in queue creation.
+
+Set Flow Engine Mode
+~~~~~~~~~~~~~~~~~~~~
+
+Set the flow engine to active(0) or standby(1) mode with specific flags::
+
+.. code-block:: console
+
+   testpmd> mlx5 set flow_engine <active|standby> [<flags>]
+
+This command is used for testing live migration and works for
+software steering only.
+Default FDB jump should be disabled if switchdev is enabled.
+The mode will propagate to all the probed ports.
diff --git a/drivers/net/mlx5/mlx5_testpmd.c b/drivers/net/mlx5/mlx5_testpmd.c
index 879ea2826e..c70a10b3af 100644
--- a/drivers/net/mlx5/mlx5_testpmd.c
+++ b/drivers/net/mlx5/mlx5_testpmd.c
@@ -25,6 +25,29 @@ 
 
 static uint8_t host_shaper_avail_thresh_triggered[RTE_MAX_ETHPORTS];
 #define SHAPER_DISABLE_DELAY_US 100000 /* 100ms */
+#define PARSE_DELIMITER " \f\n\r\t\v"
+
+static int
+parse_uint(uint64_t *value, const char *str)
+{
+	char *next = NULL;
+	uint64_t n;
+
+	errno = 0;
+	/* Parse number string */
+	if (!strncasecmp(str, "0x", 2)) {
+		str += 2;
+		n = strtol(str, &next, 16);
+	} else {
+		n = strtol(str, &next, 10);
+	}
+	if (errno != 0 || str == next || *next != '\0')
+		return -1;
+
+	*value = n;
+
+	return 0;
+}
 
 /**
  * Disable the host shaper and re-arm available descriptor threshold event.
@@ -561,6 +584,102 @@  cmdline_parse_inst_t mlx5_cmd_unmap_ext_rxq = {
 	}
 };
 
+/* Set flow engine mode with flags command. */
+struct mlx5_cmd_set_flow_engine_mode {
+	cmdline_fixed_string_t mlx5;
+	cmdline_fixed_string_t set;
+	cmdline_fixed_string_t flow_engine;
+	cmdline_multi_string_t mode;
+};
+
+static int
+parse_multi_token_flow_engine_mode(char *t_str, enum mlx5_flow_engine_mode *mode,
+				   uint32_t *flag)
+{
+	uint64_t val;
+	char *token;
+	int ret;
+
+	*flag = 0;
+	/* First token: mode string */
+	token = strtok_r(t_str, PARSE_DELIMITER, &t_str);
+	if (token ==  NULL)
+		return -1;
+
+	if (!strcmp(token, "active"))
+		*mode = MLX5_FLOW_ENGINE_MODE_ACTIVE;
+	else if (!strcmp(token, "standby"))
+		*mode = MLX5_FLOW_ENGINE_MODE_STANDBY;
+	else
+		return -1;
+
+	/* Second token: flag */
+	token = strtok_r(t_str, PARSE_DELIMITER, &t_str);
+	if (token == NULL)
+		return 0;
+
+	ret = parse_uint(&val, token);
+	if (ret != 0 || val > UINT32_MAX)
+		return -1;
+
+	*flag = val;
+	return 0;
+}
+
+static void
+mlx5_cmd_set_flow_engine_mode_parsed(void *parsed_result,
+				     __rte_unused struct cmdline *cl,
+				     __rte_unused void *data)
+{
+	struct mlx5_cmd_set_flow_engine_mode *res = parsed_result;
+	enum mlx5_flow_engine_mode mode;
+	uint32_t flag;
+	int ret;
+
+	ret = parse_multi_token_flow_engine_mode(res->mode, &mode, &flag);
+
+	if (ret < 0) {
+		fprintf(stderr, "Bad input\n");
+		return;
+	}
+
+	ret = rte_pmd_mlx5_flow_engine_set_mode(mode, flag);
+
+	if (ret < 0)
+		fprintf(stderr, "Fail to set flow_engine to %s mode with flag 0x%x, error %s\n",
+			mode == MLX5_FLOW_ENGINE_MODE_ACTIVE ? "active" : "standby", flag,
+			strerror(-ret));
+	else
+		TESTPMD_LOG(DEBUG, "Set %d ports flow_engine to %s mode with flag 0x%x\n", ret,
+			    mode == MLX5_FLOW_ENGINE_MODE_ACTIVE ? "active" : "standby", flag);
+}
+
+cmdline_parse_token_string_t mlx5_cmd_set_flow_engine_mode_mlx5 =
+	TOKEN_STRING_INITIALIZER(struct mlx5_cmd_set_flow_engine_mode, mlx5,
+				 "mlx5");
+cmdline_parse_token_string_t mlx5_cmd_set_flow_engine_mode_set =
+	TOKEN_STRING_INITIALIZER(struct mlx5_cmd_set_flow_engine_mode, set,
+				 "set");
+cmdline_parse_token_string_t mlx5_cmd_set_flow_engine_mode_flow_engine =
+	TOKEN_STRING_INITIALIZER(struct mlx5_cmd_set_flow_engine_mode, flow_engine,
+				 "flow_engine");
+cmdline_parse_token_string_t mlx5_cmd_set_flow_engine_mode_mode =
+	TOKEN_STRING_INITIALIZER(struct mlx5_cmd_set_flow_engine_mode, mode,
+				 TOKEN_STRING_MULTI);
+
+cmdline_parse_inst_t mlx5_cmd_set_flow_engine_mode = {
+	.f = &mlx5_cmd_set_flow_engine_mode_parsed,
+	.data = NULL,
+	.help_str = "mlx5 set flow_engine <active|standby> [<flag>]",
+	.tokens = {
+		(void *)&mlx5_cmd_set_flow_engine_mode_mlx5,
+		(void *)&mlx5_cmd_set_flow_engine_mode_set,
+		(void *)&mlx5_cmd_set_flow_engine_mode_flow_engine,
+		(void *)&mlx5_cmd_set_flow_engine_mode_mode,
+		NULL,
+	}
+};
+
 static struct testpmd_driver_commands mlx5_driver_cmds = {
 	.commands = {
 		{
@@ -588,6 +707,11 @@  static struct testpmd_driver_commands mlx5_driver_cmds = {
 			.help = "mlx5 port (port_id) ext_rxq unmap (sw_queue_id)\n"
 				"    Unmap external Rx queue ethdev index mapping\n\n",
 		},
+		{
+			.ctx = &mlx5_cmd_set_flow_engine_mode,
+			.help = "mlx5 set flow_engine (active|standby) [(flag)]\n"
+				"    Set flow_engine to the specific mode with flag.\n\n"
+		},
 		{
 			.ctx = NULL,
 		},