[dpdk-dev] app/testpmd: add eth peer CLI command

Message ID AM5PR0502MB2865B9251D604A9840AC3485A91F0@AM5PR0502MB2865.eurprd05.prod.outlook.com (mailing list archive)
State Superseded, archived
Delegated to: Thomas Monjalon
Headers

Checks

Context Check Description
ci/checkpatch warning coding style issues
ci/Intel-compilation fail Compilation issues

Commit Message

Wisam Jaddo Jan. 4, 2018, 9:05 a.m. UTC
  +Raslan.

BRs,
Wisam Jaddo

-----Original Message-----
From: Wisam Jaddo [mailto:wisamm@mellanox.com] 
Sent: Monday, December 25, 2017 2:43 PM
To: jingjing.wu@intel.com
Cc: dev@dpdk.org; Ori Kam; Wisam Monther; Shahaf Shuler
Subject: [PATCH] app/testpmd: add eth peer CLI command

This command will simulate the process of setting the eth-peer from command line.

It will be useful to preform extra testing.

usage:
 testpmd> set eth-peer <port_id> <peer_addr>.

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

--
2.7.4
  

Comments

Wenzhuo Lu Jan. 10, 2018, 6:57 a.m. UTC | #1
Hi,


> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Wisam Monther
> Sent: Thursday, January 4, 2018 5:06 PM
> To: Wu, Jingjing <jingjing.wu@intel.com>; Raslan Darawsheh
> <rasland@mellanox.com>
> Cc: dev@dpdk.org; Ori Kam <orika@mellanox.com>; Shahaf Shuler
> <shahafs@mellanox.com>; Wisam Monther <wisamm@mellanox.com>
> Subject: Re: [dpdk-dev] [PATCH] app/testpmd: add eth peer CLI command
> 
> +Raslan.
> 
> BRs,
> Wisam Jaddo
> 
> -----Original Message-----
> From: Wisam Jaddo [mailto:wisamm@mellanox.com]
> Sent: Monday, December 25, 2017 2:43 PM
> To: jingjing.wu@intel.com
> Cc: dev@dpdk.org; Ori Kam; Wisam Monther; Shahaf Shuler
> Subject: [PATCH] app/testpmd: add eth peer CLI command
> 
> This command will simulate the process of setting the eth-peer from
> command line.
> 
> It will be useful to preform extra testing.
> 
> usage:
>  testpmd> set eth-peer <port_id> <peer_addr>.
> 
> Signed-off-by: Wisam Jaddo <wisamm@mellanox.com>
Acked-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
  
Thomas Monjalon Jan. 12, 2018, 6 p.m. UTC | #2
> > This command will simulate the process of setting the eth-peer from
> > command line.
> > 
> > It will be useful to preform extra testing.
> > 
> > usage:
> >  testpmd> set eth-peer <port_id> <peer_addr>.
> > 
> > Signed-off-by: Wisam Jaddo <wisamm@mellanox.com>
> Acked-by: Wenzhuo Lu <wenzhuo.lu@intel.com>

The patch has not been received on the mailing list.
Please Wisam, send a v2 (keeping this ack).
  

Patch

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index f71d963..605720d 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -277,6 +277,9 @@  static void cmd_help_long_parsed(void *parsed_result,
 			"set nbcore (num)\n"
 			"    Set number of cores.\n\n"
 
+			"set eth-peer (port_id) (peer_addr)\n"
+			"    set the peer address for certain port.\n\n"
+
 			"set coremask (mask)\n"
 			"    Set the forwarding cores hexadecimal mask.\n\n"
 
@@ -2954,6 +2957,51 @@  cmdline_parse_inst_t cmd_set_fwd_mask = {
 	},
 };
 
+/* *** SET THE PEER ADDRESS FOR CERTAIN PORT *** */ struct 
+cmd_eth_peer_result {
+	cmdline_fixed_string_t set;
+	cmdline_fixed_string_t eth_peer;
+	portid_t port_id;
+	cmdline_fixed_string_t peer_addr;
+};
+
+static void cmd_set_eth_peer_parsed(void *parsed_result,
+			__attribute__((unused)) struct cmdline *cl,
+			__attribute__((unused)) void *data)
+{
+		struct cmd_eth_peer_result *res = parsed_result;
+
+		if (test_done == 0) {
+			printf("Please stop forwarding first\n");
+			return;
+		}
+		if (!strcmp(res->eth_peer, "eth-peer")) {
+			set_fwd_eth_peer(res->port_id, res->peer_addr);
+			fwd_config_setup();
+		}
+}
+cmdline_parse_token_string_t cmd_eth_peer_set =
+	TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, set, "set"); 
+cmdline_parse_token_string_t cmd_eth_peer =
+	TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, eth_peer, 
+"eth-peer"); cmdline_parse_token_num_t cmd_eth_peer_port_id =
+	TOKEN_NUM_INITIALIZER(struct cmd_eth_peer_result, port_id, UINT16); 
+cmdline_parse_token_string_t cmd_eth_peer_addr =
+	TOKEN_STRING_INITIALIZER(struct cmd_eth_peer_result, peer_addr, NULL);
+
+cmdline_parse_inst_t cmd_set_fwd_eth_peer = {
+	.f = cmd_set_eth_peer_parsed,
+	.data = NULL,
+	.help_str = "set eth-peer <port_id> <peer_mac>",
+	.tokens = {
+		(void *)&cmd_eth_peer_set,
+		(void *)&cmd_eth_peer,
+		(void *)&cmd_eth_peer_port_id,
+		(void *)&cmd_eth_peer_addr,
+		NULL,
+	},
+};
+
 /*
  * SET NBPORT, NBCORE, PACKET BURST, and VERBOSE LEVEL CONFIGURATION
  */
@@ -15558,6 +15606,7 @@  cmdline_parse_ctx_t main_ctx[] = {
 	(cmdline_parse_inst_t *)&cmd_set_txsplit,
 	(cmdline_parse_inst_t *)&cmd_set_fwd_list,
 	(cmdline_parse_inst_t *)&cmd_set_fwd_mask,
+	(cmdline_parse_inst_t *)&cmd_set_fwd_eth_peer,
 	(cmdline_parse_inst_t *)&cmd_set_fwd_mode,
 	(cmdline_parse_inst_t *)&cmd_set_fwd_retry_mode,
 	(cmdline_parse_inst_t *)&cmd_set_burst_tx_retry, diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index cd2ac11..876ee83 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -78,6 +78,7 @@ 
 #include <rte_pmd_bnxt.h>
 #endif
 #include <rte_gro.h>
+#include <cmdline_parse_etheraddr.h>
 
 #include "testpmd.h"
 
@@ -2234,6 +2235,24 @@  set_fwd_lcores_list(unsigned int *lcorelist, unsigned int nb_lc)
 	return 0;
 }
 
+void
+set_fwd_eth_peer(portid_t port_id, char *peer_addr) {
+	uint8_t c, new_peer_addr[6];
+	if (!rte_eth_dev_is_valid_port(port_id)) {
+		printf("Error: Invalid port number %i\n", port_id);
+		return;
+	}
+	if (cmdline_parse_etheraddr(NULL, peer_addr, &new_peer_addr,
+					sizeof(new_peer_addr)) < 0) {
+		printf("Error: Invalid ethernet address: %s\n", peer_addr);
+		return;
+	}
+	for (c = 0; c < 6; c++)
+		peer_eth_addrs[port_id].addr_bytes[c] =
+			new_peer_addr[c];
+}
+
 int
 set_fwd_lcores_mask(uint64_t lcoremask)  { diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index 1639d27..a2e1a5c 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -632,6 +632,7 @@  int set_fwd_lcores_list(unsigned int *lcorelist, unsigned int nb_lc);  int set_fwd_lcores_mask(uint64_t lcoremask);  void set_fwd_lcores_number(uint16_t nb_lc);
 
+void set_fwd_eth_peer(portid_t port_id, char *peer_addr);
 void set_fwd_ports_list(unsigned int *portlist, unsigned int nb_pt);  void set_fwd_ports_mask(uint64_t portmask);  void set_fwd_ports_number(uint16_t nb_pt); diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
index 9789139..7f09cf9 100644
--- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst
+++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst
@@ -459,6 +459,15 @@  set nbport (num)
 
 This is equivalent to the ``--nb-ports`` command-line option.
 
+set eth-peer
+~~~~~~~~~~~~
+
+Set the forwarding peer address for certain port::
+
+   testpmd> set eth-peer (port_id) (perr_addr)
+
+This is equivalent to the ``--eth-peer`` command-line option.
+
 set nbcore
 ~~~~~~~~~~