All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] app/testpmd: introduce new commands in forward topology
@ 2018-05-09 12:34 Wisam Jaddo
  2018-05-09 12:34 ` [PATCH 1/2] app/testpmd: add custom topology command Wisam Jaddo
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Wisam Jaddo @ 2018-05-09 12:34 UTC (permalink / raw)
  To: jingjing.wu, wenzhuo.lu, thomas; +Cc: rasland, dev, shahafs, wisamm

1- Add new forward topology (custom): This toplogy will
allow to create any topoloy you may need.
2- Add new command to set the custom toplogy.
3- Add new command to set the topoly on the fly.

Wisam Jaddo (2):
  app/testpmd: add custom topology command
  app/testpmd: add set topology on the fly command

 app/test-pmd/cmdline.c                      | 91 +++++++++++++++++++++++++++++
 app/test-pmd/config.c                       | 65 +++++++++++++++++++++
 app/test-pmd/parameters.c                   |  6 +-
 app/test-pmd/testpmd.h                      |  9 ++-
 doc/guides/testpmd_app_ug/testpmd_funcs.rst | 16 +++++
 5 files changed, 184 insertions(+), 3 deletions(-)

-- 
2.7.4

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] app/testpmd: add custom topology command
  2018-05-09 12:34 [PATCH 0/2] app/testpmd: introduce new commands in forward topology Wisam Jaddo
@ 2018-05-09 12:34 ` Wisam Jaddo
  2018-05-15 13:15   ` Kevin Traynor
  2018-05-09 12:34 ` [PATCH 2/2] app/testpmd: add set topology on the fly command Wisam Jaddo
  2018-05-16 14:55 ` [PATCH 0/2] app/testpmd: introduce new commands in forward topology Gaëtan Rivet
  2 siblings, 1 reply; 5+ messages in thread
From: Wisam Jaddo @ 2018-05-09 12:34 UTC (permalink / raw)
  To: jingjing.wu, wenzhuo.lu, thomas; +Cc: rasland, dev, shahafs, wisamm

Set custom topology for forwading packets by making the
given two ports as pair, in custom topology the active
ports will be the defiend in custum-topo only.

This command will be useful in testing, when special
topology is needed.

usage:
         testpmd> set custom-topo (port_id_1) (port_id_2)

Signed-off-by: Wisam Jaddo <wisamm@mellanox.com>
---
 app/test-pmd/cmdline.c                      | 49 +++++++++++++++++++++++++++++
 app/test-pmd/config.c                       | 41 ++++++++++++++++++++++++
 app/test-pmd/parameters.c                   |  6 ++--
 app/test-pmd/testpmd.h                      |  8 ++++-
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  8 +++++
 5 files changed, 109 insertions(+), 3 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 9615670..9d48048 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -466,6 +466,9 @@ static void cmd_help_long_parsed(void *parsed_result,
 			"set eth-peer (port_id) (peer_addr)\n"
 			"    set the peer address for certain port.\n\n"
 
+			"set custom-topo (port_id_1) (port_id_2)\n"
+			"    set custom topo.\n\n"
+
 			"set port (port_id) uta (mac_address|all) (on|off)\n"
 			"    Add/Remove a or all unicast hash filter(s)"
 			"from port X.\n\n"
@@ -7649,6 +7652,51 @@ cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
 	},
 };
 
+/* *** SET CUSTOM TOPO FOR CERTAIN PORT *** */
+struct cmd_custom_topo_result {
+		cmdline_fixed_string_t set;
+		cmdline_fixed_string_t custom_topo;
+		portid_t port_id_1;
+		portid_t port_id_2;
+};
+
+static void cmd_set_custom_topo_parsed(void *parsed_result,
+				__attribute__((unused)) struct cmdline *cl,
+				__attribute__((unused)) void *data)
+{
+	struct cmd_custom_topo_result *res = parsed_result;
+
+	if (test_done == 0) {
+		printf("Please stop forwarding first\n");
+		return;
+	}
+	if (!strcmp(res->custom_topo, "custom-topo")) {
+		set_custom_topo(res->port_id_1, res->port_id_2);
+		fwd_config_setup();
+	}
+}
+cmdline_parse_token_string_t cmd_set_custom_topo_set =
+	TOKEN_STRING_INITIALIZER(struct cmd_custom_topo_result, set, "set");
+cmdline_parse_token_string_t cmd_set_custom_topo_custom_topo =
+	TOKEN_STRING_INITIALIZER(struct cmd_custom_topo_result, custom_topo, "custom-topo");
+cmdline_parse_token_num_t cmd_set_custom_topo_port_id_1 =
+	TOKEN_NUM_INITIALIZER(struct cmd_custom_topo_result, port_id_1, UINT16);
+cmdline_parse_token_num_t cmd_set_custom_topo_port_id_2 =
+	TOKEN_NUM_INITIALIZER(struct cmd_custom_topo_result, port_id_2, UINT16);
+
+cmdline_parse_inst_t cmd_set_custom_topo = {
+	.f = cmd_set_custom_topo_parsed,
+	.data = NULL,
+	.help_str = "set custom-topo (port_id_1) (port_id_2)",
+	.tokens = {
+			(void *)&cmd_set_custom_topo_set,
+			(void *)&cmd_set_custom_topo_custom_topo,
+			(void *)&cmd_set_custom_topo_port_id_1,
+			(void *)&cmd_set_custom_topo_port_id_2,
+			NULL,
+	},
+};
+
 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
 struct cmd_set_qmap_result {
 	cmdline_fixed_string_t set;
@@ -16540,6 +16588,7 @@ cmdline_parse_ctx_t main_ctx[] = {
 	(cmdline_parse_inst_t *)&cmd_stop,
 	(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_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 16fc481..23799ad 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -2069,6 +2069,8 @@ fwd_topology_tx_port_get(portid_t rxp)
 		return (rxp + 1) % cur_fwd_config.nb_fwd_ports;
 	case PORT_TOPOLOGY_LOOP:
 		return rxp;
+	case PORT_TOPOLOGY_CUSTOM:
+		return fwd_streams[rxp]->tx_port;
 	}
 }
 
@@ -2378,6 +2380,45 @@ set_fwd_eth_peer(portid_t port_id, char *peer_addr)
 			new_peer_addr[c];
 }
 
+static void
+print_ports_range(void)
+{
+	portid_t pid;
+	printf("Valid port range is [");
+	RTE_ETH_FOREACH_DEV(pid)
+		printf(", %d", pid);
+	printf("]\n");
+}
+
+void
+set_custom_topo(portid_t port_id_1, portid_t port_id_2)
+{
+	unsigned int portlist[RTE_MAX_ETHPORTS];
+	unsigned int i;
+	unsigned int nb_pt = 0;
+	if (port_topology != PORT_TOPOLOGY_CUSTOM) {
+		printf("Please set the forward topology to custom first.\n");
+		return;
+	}
+	if (port_id_is_invalid(port_id_1, ENABLED_WARN)) {
+		print_ports_range();
+		return;
+	}
+	if (port_id_is_invalid(port_id_2, ENABLED_WARN)) {
+		print_ports_range();
+		return;
+	}
+	fwd_streams[port_id_1]->tx_port = port_id_2;
+	fwd_streams[port_id_2]->tx_port = port_id_1;
+	fwd_ports[port_id_1] = port_id_1;
+	fwd_ports[port_id_2] = port_id_2;
+
+	for (i = 0; i < RTE_MAX_ETHPORTS; i++)
+		if (fwd_ports[i] == i)
+			portlist[nb_pt++] = i;
+	set_fwd_ports_list(portlist, nb_pt);
+}
+
 int
 set_fwd_lcores_list(unsigned int *lcorelist, unsigned int nb_lc)
 {
diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c
index aea8af8..0db411d 100644
--- a/app/test-pmd/parameters.c
+++ b/app/test-pmd/parameters.c
@@ -139,8 +139,8 @@ usage(char* progname)
 	printf("  --enable-hw-vlan-extend: enable hardware vlan extend.\n");
 	printf("  --enable-drop-en: enable per queue packet drop.\n");
 	printf("  --disable-rss: disable rss.\n");
-	printf("  --port-topology=N: set port topology (N: paired (default) or "
-	       "chained).\n");
+	printf("  --port-topology=N: set port topology (N: paired (default)"
+	       "(loop), (custom) or (chained).\n");
 	printf("  --forward-mode=N: set forwarding mode (N: %s).\n",
 	       list_pkt_forwarding_modes());
 	printf("  --rss-ip: set RSS functions to IPv4/IPv6 only .\n");
@@ -920,6 +920,8 @@ launch_args_parse(int argc, char** argv)
 					port_topology = PORT_TOPOLOGY_CHAINED;
 				else if (!strcmp(optarg, "loop"))
 					port_topology = PORT_TOPOLOGY_LOOP;
+				else if (!strcmp(optarg, "custom"))
+					port_topology = PORT_TOPOLOGY_CUSTOM;
 				else
 					rte_exit(EXIT_FAILURE, "port-topology %s invalid -"
 						 " must be: paired, chained or loop\n",
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 1af87b8..3250683 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -67,6 +67,7 @@ enum {
 	PORT_TOPOLOGY_PAIRED,
 	PORT_TOPOLOGY_CHAINED,
 	PORT_TOPOLOGY_LOOP,
+	PORT_TOPOLOGY_CUSTOM,
 };
 
 #ifdef RTE_TEST_PMD_RECORD_BURST_STATS
@@ -363,6 +364,11 @@ extern uint8_t txring_numa[RTE_MAX_ETHPORTS];
 extern uint8_t socket_num;
 
 /*
+ * Store the custom topo.
+ */
+portid_t fwd_ports[RTE_MAX_ETHPORTS];
+
+/*
  * Configuration of logical cores:
  * nb_fwd_lcores <= nb_cfg_lcores <= nb_lcores
  */
@@ -598,7 +604,7 @@ void reconfig(portid_t new_port_id, unsigned socket_id);
 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 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 013a405..5edf210 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -1090,6 +1090,14 @@ Set the forwarding peer address for certain port::
 
 This is equivalent to the ``--eth-peer`` command-line option.
 
+set custom-topo
+~~~~~~~~~~~~~~
+
+Set custom topology for forwading packets by making the given two ports as pair.
+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 port-uta
 ~~~~~~~~~~~~
 
-- 
2.7.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] app/testpmd: add set topology on the fly command
  2018-05-09 12:34 [PATCH 0/2] app/testpmd: introduce new commands in forward topology Wisam Jaddo
  2018-05-09 12:34 ` [PATCH 1/2] app/testpmd: add custom topology command Wisam Jaddo
@ 2018-05-09 12:34 ` Wisam Jaddo
  2018-05-16 14:55 ` [PATCH 0/2] app/testpmd: introduce new commands in forward topology Gaëtan Rivet
  2 siblings, 0 replies; 5+ messages in thread
From: Wisam Jaddo @ 2018-05-09 12:34 UTC (permalink / raw)
  To: jingjing.wu, wenzhuo.lu, thomas; +Cc: rasland, dev, shahafs, wisamm

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                       | 24 +++++++++++++++++
 app/test-pmd/testpmd.h                      |  1 +
 doc/guides/testpmd_app_ug/testpmd_funcs.rst |  8 ++++++
 4 files changed, 75 insertions(+)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 9d48048..ecbecad 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..cc403c6 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -2380,6 +2380,30 @@ 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++)
+		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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 1/2] app/testpmd: add custom topology command
  2018-05-09 12:34 ` [PATCH 1/2] app/testpmd: add custom topology command Wisam Jaddo
@ 2018-05-15 13:15   ` Kevin Traynor
  0 siblings, 0 replies; 5+ messages in thread
From: Kevin Traynor @ 2018-05-15 13:15 UTC (permalink / raw)
  To: Wisam Jaddo, jingjing.wu, wenzhuo.lu, thomas; +Cc: rasland, dev, shahafs

On 05/09/2018 01:34 PM, Wisam Jaddo wrote:
> Set custom topology for forwading packets by making the
                          ^^^^^^^^^
> given two ports as pair, in custom topology the active
> ports will be the defiend in custum-topo only.
                    ^^^^^^^    ^^^^^^
typos above and similar in the docs below

> 
> This command will be useful in testing, when special
> topology is needed.

Can you use a combination of paired mode and set portlist to achieve the
same topology? or there is something you want that it doesn't cover?

http://dpdk.org/doc/guides/testpmd_app_ug/testpmd_funcs.html#set-portlist

> 
> usage:
>          testpmd> set custom-topo (port_id_1) (port_id_2)
> 
> Signed-off-by: Wisam Jaddo <wisamm@mellanox.com>
> ---
>  app/test-pmd/cmdline.c                      | 49 +++++++++++++++++++++++++++++
>  app/test-pmd/config.c                       | 41 ++++++++++++++++++++++++
>  app/test-pmd/parameters.c                   |  6 ++--
>  app/test-pmd/testpmd.h                      |  8 ++++-
>  doc/guides/testpmd_app_ug/testpmd_funcs.rst |  8 +++++
>  5 files changed, 109 insertions(+), 3 deletions(-)
> 
> diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
> index 9615670..9d48048 100644
> --- a/app/test-pmd/cmdline.c
> +++ b/app/test-pmd/cmdline.c
> @@ -466,6 +466,9 @@ static void cmd_help_long_parsed(void *parsed_result,
>  			"set eth-peer (port_id) (peer_addr)\n"
>  			"    set the peer address for certain port.\n\n"
>  
> +			"set custom-topo (port_id_1) (port_id_2)\n"
> +			"    set custom topo.\n\n"
> +
>  			"set port (port_id) uta (mac_address|all) (on|off)\n"
>  			"    Add/Remove a or all unicast hash filter(s)"
>  			"from port X.\n\n"
> @@ -7649,6 +7652,51 @@ cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
>  	},
>  };
>  
> +/* *** SET CUSTOM TOPO FOR CERTAIN PORT *** */
> +struct cmd_custom_topo_result {
> +		cmdline_fixed_string_t set;
> +		cmdline_fixed_string_t custom_topo;
> +		portid_t port_id_1;
> +		portid_t port_id_2;
> +};
> +
> +static void cmd_set_custom_topo_parsed(void *parsed_result,
> +				__attribute__((unused)) struct cmdline *cl,
> +				__attribute__((unused)) void *data)
> +{
> +	struct cmd_custom_topo_result *res = parsed_result;
> +
> +	if (test_done == 0) {
> +		printf("Please stop forwarding first\n");
> +		return;
> +	}
> +	if (!strcmp(res->custom_topo, "custom-topo")) {
> +		set_custom_topo(res->port_id_1, res->port_id_2);
> +		fwd_config_setup();
> +	}
> +}
> +cmdline_parse_token_string_t cmd_set_custom_topo_set =
> +	TOKEN_STRING_INITIALIZER(struct cmd_custom_topo_result, set, "set");
> +cmdline_parse_token_string_t cmd_set_custom_topo_custom_topo =
> +	TOKEN_STRING_INITIALIZER(struct cmd_custom_topo_result, custom_topo, "custom-topo");
> +cmdline_parse_token_num_t cmd_set_custom_topo_port_id_1 =
> +	TOKEN_NUM_INITIALIZER(struct cmd_custom_topo_result, port_id_1, UINT16);
> +cmdline_parse_token_num_t cmd_set_custom_topo_port_id_2 =
> +	TOKEN_NUM_INITIALIZER(struct cmd_custom_topo_result, port_id_2, UINT16);
> +
> +cmdline_parse_inst_t cmd_set_custom_topo = {
> +	.f = cmd_set_custom_topo_parsed,
> +	.data = NULL,
> +	.help_str = "set custom-topo (port_id_1) (port_id_2)",
> +	.tokens = {
> +			(void *)&cmd_set_custom_topo_set,
> +			(void *)&cmd_set_custom_topo_custom_topo,
> +			(void *)&cmd_set_custom_topo_port_id_1,
> +			(void *)&cmd_set_custom_topo_port_id_2,
> +			NULL,
> +	},
> +};
> +
>  /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
>  struct cmd_set_qmap_result {
>  	cmdline_fixed_string_t set;
> @@ -16540,6 +16588,7 @@ cmdline_parse_ctx_t main_ctx[] = {
>  	(cmdline_parse_inst_t *)&cmd_stop,
>  	(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_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 16fc481..23799ad 100644
> --- a/app/test-pmd/config.c
> +++ b/app/test-pmd/config.c
> @@ -2069,6 +2069,8 @@ fwd_topology_tx_port_get(portid_t rxp)
>  		return (rxp + 1) % cur_fwd_config.nb_fwd_ports;
>  	case PORT_TOPOLOGY_LOOP:
>  		return rxp;
> +	case PORT_TOPOLOGY_CUSTOM:
> +		return fwd_streams[rxp]->tx_port;
>  	}
>  }
>  
> @@ -2378,6 +2380,45 @@ set_fwd_eth_peer(portid_t port_id, char *peer_addr)
>  			new_peer_addr[c];
>  }
>  
> +static void
> +print_ports_range(void)
> +{
> +	portid_t pid;
> +	printf("Valid port range is [");
> +	RTE_ETH_FOREACH_DEV(pid)
> +		printf(", %d", pid);
> +	printf("]\n");
> +}
> +
> +void
> +set_custom_topo(portid_t port_id_1, portid_t port_id_2)
> +{
> +	unsigned int portlist[RTE_MAX_ETHPORTS];
> +	unsigned int i;
> +	unsigned int nb_pt = 0;
> +	if (port_topology != PORT_TOPOLOGY_CUSTOM) {
> +		printf("Please set the forward topology to custom first.\n");
> +		return;
> +	}
> +	if (port_id_is_invalid(port_id_1, ENABLED_WARN)) {
> +		print_ports_range();
> +		return;
> +	}
> +	if (port_id_is_invalid(port_id_2, ENABLED_WARN)) {
> +		print_ports_range();
> +		return;
> +	}
> +	fwd_streams[port_id_1]->tx_port = port_id_2;
> +	fwd_streams[port_id_2]->tx_port = port_id_1;
> +	fwd_ports[port_id_1] = port_id_1;
> +	fwd_ports[port_id_2] = port_id_2;
> +
> +	for (i = 0; i < RTE_MAX_ETHPORTS; i++)
> +		if (fwd_ports[i] == i)
> +			portlist[nb_pt++] = i;
> +	set_fwd_ports_list(portlist, nb_pt);
> +}
> +
>  int
>  set_fwd_lcores_list(unsigned int *lcorelist, unsigned int nb_lc)
>  {
> diff --git a/app/test-pmd/parameters.c b/app/test-pmd/parameters.c
> index aea8af8..0db411d 100644
> --- a/app/test-pmd/parameters.c
> +++ b/app/test-pmd/parameters.c
> @@ -139,8 +139,8 @@ usage(char* progname)
>  	printf("  --enable-hw-vlan-extend: enable hardware vlan extend.\n");
>  	printf("  --enable-drop-en: enable per queue packet drop.\n");
>  	printf("  --disable-rss: disable rss.\n");
> -	printf("  --port-topology=N: set port topology (N: paired (default) or "
> -	       "chained).\n");
> +	printf("  --port-topology=N: set port topology (N: paired (default)"
> +	       "(loop), (custom) or (chained).\n");
>  	printf("  --forward-mode=N: set forwarding mode (N: %s).\n",
>  	       list_pkt_forwarding_modes());
>  	printf("  --rss-ip: set RSS functions to IPv4/IPv6 only .\n");
> @@ -920,6 +920,8 @@ launch_args_parse(int argc, char** argv)
>  					port_topology = PORT_TOPOLOGY_CHAINED;
>  				else if (!strcmp(optarg, "loop"))
>  					port_topology = PORT_TOPOLOGY_LOOP;
> +				else if (!strcmp(optarg, "custom"))
> +					port_topology = PORT_TOPOLOGY_CUSTOM;
>  				else
>  					rte_exit(EXIT_FAILURE, "port-topology %s invalid -"
>  						 " must be: paired, chained or loop\n",
> diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
> index 1af87b8..3250683 100644
> --- a/app/test-pmd/testpmd.h
> +++ b/app/test-pmd/testpmd.h
> @@ -67,6 +67,7 @@ enum {
>  	PORT_TOPOLOGY_PAIRED,
>  	PORT_TOPOLOGY_CHAINED,
>  	PORT_TOPOLOGY_LOOP,
> +	PORT_TOPOLOGY_CUSTOM,
>  };
>  
>  #ifdef RTE_TEST_PMD_RECORD_BURST_STATS
> @@ -363,6 +364,11 @@ extern uint8_t txring_numa[RTE_MAX_ETHPORTS];
>  extern uint8_t socket_num;
>  
>  /*
> + * Store the custom topo.
> + */
> +portid_t fwd_ports[RTE_MAX_ETHPORTS];
> +
> +/*
>   * Configuration of logical cores:
>   * nb_fwd_lcores <= nb_cfg_lcores <= nb_lcores
>   */
> @@ -598,7 +604,7 @@ void reconfig(portid_t new_port_id, unsigned socket_id);
>  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 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 013a405..5edf210 100644
> --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
> @@ -1090,6 +1090,14 @@ Set the forwarding peer address for certain port::
>  
>  This is equivalent to the ``--eth-peer`` command-line option.
>  
> +set custom-topo
> +~~~~~~~~~~~~~~
> +
> +Set custom topology for forwading packets by making the given two ports as pair.
> +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 port-uta
>  ~~~~~~~~~~~~
>  
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/2] app/testpmd: introduce new commands in forward topology
  2018-05-09 12:34 [PATCH 0/2] app/testpmd: introduce new commands in forward topology Wisam Jaddo
  2018-05-09 12:34 ` [PATCH 1/2] app/testpmd: add custom topology command Wisam Jaddo
  2018-05-09 12:34 ` [PATCH 2/2] app/testpmd: add set topology on the fly command Wisam Jaddo
@ 2018-05-16 14:55 ` Gaëtan Rivet
  2 siblings, 0 replies; 5+ messages in thread
From: Gaëtan Rivet @ 2018-05-16 14:55 UTC (permalink / raw)
  To: Wisam Jaddo; +Cc: jingjing.wu, wenzhuo.lu, thomas, rasland, dev, shahafs

Hi,

On Wed, May 09, 2018 at 03:34:37PM +0300, Wisam Jaddo wrote:
> 1- Add new forward topology (custom): This toplogy will
> allow to create any topoloy you may need.
> 2- Add new command to set the custom toplogy.
> 3- Add new command to set the topoly on the fly.

I have had the same kind of issues when developping a PMD for a
prototype NIC that had some queues behaving weirdly, or when using
testpmd for regression testing with a incompatible topology that was
impossible to change. I think this use-case is important for testpmd and
this should be useful for many people.

I think however that your approach is not flexible enough.

One should not only be able to edit ports pairing, but also select
specific (Rx) queue. Additionally, it should be possible to change the
lcore forwarding a specific pair.

Testpmd uses the concept of streams internally. I think the only way to
have enough flexibility here is to expose this concept as a set of
commands to define custom streams, and then to bind those streams to
sets of lcores.

You have found after testing that TX queues cannot be shared. This tool is
also used for pure IO performance regression testing. Adding the support
for shared TX queues would impact this use-case and I think this is not
acceptable. At the very least, the default configuration should not be
impacted (and I think compile-time options are now frowned upon).

This is the reason it should be necessary to be able to define the set of
lcores doing the forwarding: The lcore defines the TX queue used by a stream,
this way the current testpmd arch is respected.

Regards,
-- 
Gaëtan Rivet
6WIND

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2018-05-16 14:55 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-05-09 12:34 [PATCH 0/2] app/testpmd: introduce new commands in forward topology Wisam Jaddo
2018-05-09 12:34 ` [PATCH 1/2] app/testpmd: add custom topology command Wisam Jaddo
2018-05-15 13:15   ` Kevin Traynor
2018-05-09 12:34 ` [PATCH 2/2] app/testpmd: add set topology on the fly command Wisam Jaddo
2018-05-16 14:55 ` [PATCH 0/2] app/testpmd: introduce new commands in forward topology Gaëtan Rivet

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.