[dpdk-dev,v3,2/2] app/testpmd: add set topology on the fly command
diff mbox

Message ID 1525870039-11261-3-git-send-email-wisamm@mellanox.com
State New
Delegated to: Thomas Monjalon
Headers show

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation success Compilation OK

Commit Message

Wisam Jaddo May 9, 2018, 12:47 p.m. UTC
Change the forward topology while testpmd is running,
the valid topologies are loop, paired, chained & custom.

When the forward topology is changed on the fly, all
the ports will restore their active status.

usage:
     testpmd> set fwd-topo paired|chained|loop|custom

Signed-off-by: Wisam Jaddo <wisamm@mellanox.com>
---
 app/test-pmd/cmdline.c                      | 42 +++++++++++++++++++++++++++++
 app/test-pmd/config.c                       | 25 +++++++++++++++++
 app/test-pmd/testpmd.h                      |  1 +
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  8 ++++++
 4 files changed, 76 insertions(+)

Comments

Iremonger, Bernard May 16, 2018, 3:03 p.m. UTC | #1
Hi Wisam,

> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Wisam Jaddo
> Sent: Wednesday, May 9, 2018 1:47 PM
> To: Wu, Jingjing <jingjing.wu@intel.com>; Lu, Wenzhuo
> <wenzhuo.lu@intel.com>; thomas@monjalon.net
> Cc: rasland@mellanox.com; dev@dpdk.org; shahafs@mellanox.com;
> wisamm@mellanox.com
> Subject: [dpdk-dev] [PATCH v3 2/2] app/testpmd: add set topology on the fly
> command
> 
> Change the forward topology while testpmd is running, the valid topologies
> are loop, paired, chained & custom.
> 
> When the forward topology is changed on the fly, all the ports will restore
> their active status.
> 
> usage:
>      testpmd> set fwd-topo paired|chained|loop|custom
> 
> Signed-off-by: Wisam Jaddo <wisamm@mellanox.com>
> ---
>  app/test-pmd/cmdline.c                      | 42
> +++++++++++++++++++++++++++++
>  app/test-pmd/config.c                       | 25 +++++++++++++++++
>  app/test-pmd/testpmd.h                      |  1 +
>  doc/guides/testpmd_app_ug/testpmd_funcs.rst |  8 ++++++
>  4 files changed, 76 insertions(+)
> 
> diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index
> 9d48048..00fd4c7 100644
> --- a/app/test-pmd/cmdline.c
> +++ b/app/test-pmd/cmdline.c
> @@ -7651,6 +7651,47 @@ cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
>  		NULL,
>  	},
>  };
> +/* *** SET CUSTOM TOPO FOR CERTAIN PORT *** */ struct
> +cmd_set_fwd_topo_result {
> +	cmdline_fixed_string_t set;
> +	cmdline_fixed_string_t fwd_topo;
> +	cmdline_fixed_string_t topo;
> +};
> +
> +static void cmd_set_fwd_topo_parsed(void *parsed_result,
> +				__attribute__((unused)) struct cmdline *cl,
> +				__attribute__((unused)) void *data) {
> +	struct cmd_set_fwd_topo_result *res = parsed_result;
> +
> +	if (test_done == 0) {
> +		printf("Please stop forwarding first\n");
> +		return;
> +	}
> +	if (!strcmp(res->fwd_topo, "fwd-topo")) {
> +		set_set_fwd_topo(res->topo);
> +		fwd_config_setup();
> +	}
> +}
> +
> +cmdline_parse_token_string_t cmd_set_fwd_topo_set =
> +	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_topo_result, set,
> "set");
> +cmdline_parse_token_string_t cmd_set_fwd_topo_fwd_topo =
> +	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_topo_result,
> fwd_topo,
> +"fwd-topo"); cmdline_parse_token_string_t cmd_set_fwd_topo_topo =
> +	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_topo_result, topo,
> NULL);
> +
> +cmdline_parse_inst_t cmd_set_fwd_topo = {
> +	.f = cmd_set_fwd_topo_parsed,
> +	.data = NULL,
> +	.help_str = "set fwd-topo loop|paired|chained|custom",
> +	.tokens = {
> +		(void *)&cmd_set_fwd_topo_set,
> +		(void *)&cmd_set_fwd_topo_fwd_topo,
> +		(void *)&cmd_set_fwd_topo_topo,
> +		NULL,
> +	},
> +};
> 
>  /* *** SET CUSTOM TOPO FOR CERTAIN PORT *** */  struct
> cmd_custom_topo_result { @@ -16589,6 +16630,7 @@ cmdline_parse_ctx_t
> main_ctx[] = {
>  	(cmdline_parse_inst_t *)&cmd_mac_addr,
>  	(cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
>  	(cmdline_parse_inst_t *)&cmd_set_custom_topo,
> +	(cmdline_parse_inst_t *)&cmd_set_fwd_topo,
>  	(cmdline_parse_inst_t *)&cmd_set_qmap,
>  	(cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
>  	(cmdline_parse_inst_t *)&cmd_operate_port, diff --git a/app/test-
> pmd/config.c b/app/test-pmd/config.c index 23799ad..eaad885 100644
> --- a/app/test-pmd/config.c
> +++ b/app/test-pmd/config.c
> @@ -2380,6 +2380,31 @@ set_fwd_eth_peer(portid_t port_id, char
> *peer_addr)
>  			new_peer_addr[c];
>  }
> 
> +void
> +set_set_fwd_topo(char *topology)
> +{
> +	unsigned int portlist[RTE_MAX_ETHPORTS];
> +	unsigned int nb_pt = 0;
> +	unsigned int i;
> +
> +	if (!strcmp(topology, "custom"))
> +		port_topology = PORT_TOPOLOGY_CUSTOM;
> +	else if (!strcmp(topology, "loop"))
> +		port_topology = PORT_TOPOLOGY_LOOP;
> +	else if (!strcmp(topology, "chained"))
> +		port_topology = PORT_TOPOLOGY_CHAINED;
> +	else if (!strcmp(topology, "paired"))
> +		port_topology = PORT_TOPOLOGY_PAIRED;
> +	else {
> +		printf("Please set valid forward topology\n");
> +		printf("valid topologies are: [custom, paired, loop &
> chained]\n");
> +	}
> +	for (i = 0; i < RTE_MAX_ETHPORTS; i++)
> +		if (rte_eth_dev_is_valid_port((portid_t) i))
> +			portlist[nb_pt++] = i;
> +	set_fwd_ports_list(portlist, nb_pt);
> +}
> +
>  static void
>  print_ports_range(void)
>  {
> diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index
> 3250683..6b9db3b 100644
> --- a/app/test-pmd/testpmd.h
> +++ b/app/test-pmd/testpmd.h
> @@ -605,6 +605,7 @@ int init_fwd_streams(void);
> 
>  void set_fwd_eth_peer(portid_t port_id, char *peer_addr);  void
> set_custom_topo(portid_t port_id_1, portid_t port_id_2);
> +void set_set_fwd_topo(char *topology);
>  void port_mtu_set(portid_t port_id, uint16_t mtu);  void
> port_reg_bit_display(portid_t port_id, uint32_t reg_off, uint8_t bit_pos);
> void port_reg_bit_set(portid_t port_id, uint32_t reg_off, uint8_t bit_pos,
> diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> index 5edf210..584ed6b 100644
> --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> @@ -1098,6 +1098,14 @@ In custom topology the active ports will be the
> defiend in custum-topo only::
> 
>     testpmd> set custom-topo (port_id_1) (port_id_2)
> 
> +set fwd-topo
> +~~~~~~~~~~~~
> +Set the forward topology on the fly.
> +Once the forward topology is changed on the fly, all ports will restore
> +it's active
> +status::
> +
> +   testpmd> set fwd-topo loop|paired|chained|loop
> +
>  set port-uta
>  ~~~~~~~~~~~~
> 
> --
> 2.7.4

This patch does not apply to the dpdk_18_05_rc4 master branch and needs to be rebased.
It also has several checkpatch warnings which should be addressed.

Regards,

Bernard.
Iremonger, Bernard June 14, 2018, 1:19 p.m. UTC | #2
Hi Wisam,

> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Wisam Jaddo
> Sent: Wednesday, May 9, 2018 1:47 PM
> To: Wu, Jingjing <jingjing.wu@intel.com>; Lu, Wenzhuo
> <wenzhuo.lu@intel.com>; thomas@monjalon.net
> Cc: rasland@mellanox.com; dev@dpdk.org; shahafs@mellanox.com;
> wisamm@mellanox.com
> Subject: [dpdk-dev] [PATCH v3 2/2] app/testpmd: add set topology on the fly
> command
> 
> Change the forward topology while testpmd is running, the valid topologies
> are loop, paired, chained & custom.
> 
> When the forward topology is changed on the fly, all the ports will restore
> their active status.
> 
> usage:
>      testpmd> set fwd-topo paired|chained|loop|custom
> 
> Signed-off-by: Wisam Jaddo <wisamm@mellanox.com>
> ---

<snip>

This patch fails to apply to dpdk 18.08.rc0.
Checkpatch.pl is reporting one warning which should be fixed.

Regards,

Bernard.

Patch
diff mbox

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 9d48048..00fd4c7 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -7651,6 +7651,47 @@  cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
 		NULL,
 	},
 };
+/* *** SET CUSTOM TOPO FOR CERTAIN PORT *** */
+struct cmd_set_fwd_topo_result {
+	cmdline_fixed_string_t set;
+	cmdline_fixed_string_t fwd_topo;
+	cmdline_fixed_string_t topo;
+};
+
+static void cmd_set_fwd_topo_parsed(void *parsed_result,
+				__attribute__((unused)) struct cmdline *cl,
+				__attribute__((unused)) void *data)
+{
+	struct cmd_set_fwd_topo_result *res = parsed_result;
+
+	if (test_done == 0) {
+		printf("Please stop forwarding first\n");
+		return;
+	}
+	if (!strcmp(res->fwd_topo, "fwd-topo")) {
+		set_set_fwd_topo(res->topo);
+		fwd_config_setup();
+	}
+}
+
+cmdline_parse_token_string_t cmd_set_fwd_topo_set =
+	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_topo_result, set, "set");
+cmdline_parse_token_string_t cmd_set_fwd_topo_fwd_topo =
+	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_topo_result, fwd_topo, "fwd-topo");
+cmdline_parse_token_string_t cmd_set_fwd_topo_topo =
+	TOKEN_STRING_INITIALIZER(struct cmd_set_fwd_topo_result, topo, NULL);
+
+cmdline_parse_inst_t cmd_set_fwd_topo = {
+	.f = cmd_set_fwd_topo_parsed,
+	.data = NULL,
+	.help_str = "set fwd-topo loop|paired|chained|custom",
+	.tokens = {
+		(void *)&cmd_set_fwd_topo_set,
+		(void *)&cmd_set_fwd_topo_fwd_topo,
+		(void *)&cmd_set_fwd_topo_topo,
+		NULL,
+	},
+};
 
 /* *** SET CUSTOM TOPO FOR CERTAIN PORT *** */
 struct cmd_custom_topo_result {
@@ -16589,6 +16630,7 @@  cmdline_parse_ctx_t main_ctx[] = {
 	(cmdline_parse_inst_t *)&cmd_mac_addr,
 	(cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
 	(cmdline_parse_inst_t *)&cmd_set_custom_topo,
+	(cmdline_parse_inst_t *)&cmd_set_fwd_topo,
 	(cmdline_parse_inst_t *)&cmd_set_qmap,
 	(cmdline_parse_inst_t *)&cmd_set_xstats_hide_zero,
 	(cmdline_parse_inst_t *)&cmd_operate_port,
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 23799ad..eaad885 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -2380,6 +2380,31 @@  set_fwd_eth_peer(portid_t port_id, char *peer_addr)
 			new_peer_addr[c];
 }
 
+void
+set_set_fwd_topo(char *topology)
+{
+	unsigned int portlist[RTE_MAX_ETHPORTS];
+	unsigned int nb_pt = 0;
+	unsigned int i;
+
+	if (!strcmp(topology, "custom"))
+		port_topology = PORT_TOPOLOGY_CUSTOM;
+	else if (!strcmp(topology, "loop"))
+		port_topology = PORT_TOPOLOGY_LOOP;
+	else if (!strcmp(topology, "chained"))
+		port_topology = PORT_TOPOLOGY_CHAINED;
+	else if (!strcmp(topology, "paired"))
+		port_topology = PORT_TOPOLOGY_PAIRED;
+	else {
+		printf("Please set valid forward topology\n");
+		printf("valid topologies are: [custom, paired, loop & chained]\n");
+	}
+	for (i = 0; i < RTE_MAX_ETHPORTS; i++)
+		if (rte_eth_dev_is_valid_port((portid_t) i))
+			portlist[nb_pt++] = i;
+	set_fwd_ports_list(portlist, nb_pt);
+}
+
 static void
 print_ports_range(void)
 {
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 3250683..6b9db3b 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -605,6 +605,7 @@  int init_fwd_streams(void);
 
 void set_fwd_eth_peer(portid_t port_id, char *peer_addr);
 void set_custom_topo(portid_t port_id_1, portid_t port_id_2);
+void set_set_fwd_topo(char *topology);
 void port_mtu_set(portid_t port_id, uint16_t mtu);
 void port_reg_bit_display(portid_t port_id, uint32_t reg_off, uint8_t bit_pos);
 void port_reg_bit_set(portid_t port_id, uint32_t reg_off, uint8_t bit_pos,
diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index 5edf210..584ed6b 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -1098,6 +1098,14 @@  In custom topology the active ports will be the defiend in custum-topo only::
 
    testpmd> set custom-topo (port_id_1) (port_id_2)
 
+set fwd-topo
+~~~~~~~~~~~~
+Set the forward topology on the fly.
+Once the forward topology is changed on the fly, all ports will restore it's active
+status::
+
+   testpmd> set fwd-topo loop|paired|chained|loop
+
 set port-uta
 ~~~~~~~~~~~~