[dpdk-dev,v7,3/3] app/testpmd: add a command to add many MAC addrs

Message ID 1493944802-52943-4-git-send-email-wei.dai@intel.com (mailing list archive)
State Rejected, archived
Headers

Checks

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

Commit Message

Wei Dai May 5, 2017, 12:40 a.m. UTC
  This patch is added to introduce a testpmd command which
is used to add more than one MAC addresses one time.
This command can simplify the test for the change where
the type of return value of adding MAC address.
Normally a MAC address may fails to be added only after
many MAC addresses have been added.
Without this command, a tester may only trigger failed
MAC address by running many times of testpmd command
'mac_addr add' .

Signed-off-by: Wei Dai <wei.dai@intel.com>
---
 app/test-pmd/cmdline.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 55 insertions(+)
  

Comments

Thomas Monjalon May 5, 2017, 2:24 p.m. UTC | #1
05/05/2017 02:40, Wei Dai:
> This patch is added to introduce a testpmd command which
> is used to add more than one MAC addresses one time.
> This command can simplify the test for the change where
> the type of return value of adding MAC address.
> Normally a MAC address may fails to be added only after
> many MAC addresses have been added.
> Without this command, a tester may only trigger failed
> MAC address by running many times of testpmd command
> 'mac_addr add' .
> 
> Signed-off-by: Wei Dai <wei.dai@intel.com>
> ---
>  app/test-pmd/cmdline.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 55 insertions(+)

This patch has not been reviewed.
It is not a fix and I am not sure it is needed.
  
Jingjing Wu May 8, 2017, 1:01 a.m. UTC | #2
> -----Original Message-----
> From: Thomas Monjalon [mailto:thomas@monjalon.net]
> Sent: Friday, May 5, 2017 10:24 PM
> To: Dai, Wei <wei.dai@intel.com>
> Cc: dev@dpdk.org; Lu, Wenzhuo <wenzhuo.lu@intel.com>;
> harish.patil@cavium.com; rasesh.mody@cavium.com;
> stephen.hurd@broadcom.com; ajit.khaparde@broadcom.com; Zhang, Helin
> <helin.zhang@intel.com>; Ananyev, Konstantin
> <konstantin.ananyev@intel.com>; Wu, Jingjing <jingjing.wu@intel.com>; Chen,
> Jing D <jing.d.chen@intel.com>; adrien.mazarguil@6wind.com;
> nelio.laranjeiro@6wind.com; Richardson, Bruce <bruce.richardson@intel.com>;
> yuanhan.liu@linux.intel.com; maxime.coquelin@redhat.com;
> shepard.siegel@atomicrules.com; ed.czeck@atomicrules.com;
> john.miller@atomicrules.com
> Subject: Re: [dpdk-dev] [PATCH v7 3/3] app/testpmd: add a command to add
> many MAC addrs
> 
> 05/05/2017 02:40, Wei Dai:
> > This patch is added to introduce a testpmd command which is used to
> > add more than one MAC addresses one time.
> > This command can simplify the test for the change where the type of
> > return value of adding MAC address.
> > Normally a MAC address may fails to be added only after many MAC
> > addresses have been added.
> > Without this command, a tester may only trigger failed MAC address by
> > running many times of testpmd command 'mac_addr add' .
> >
> > Signed-off-by: Wei Dai <wei.dai@intel.com>
> > ---
> >  app/test-pmd/cmdline.c | 55
> > ++++++++++++++++++++++++++++++++++++++++++++++++++
> >  1 file changed, 55 insertions(+)
> 
> This patch has not been reviewed.
> It is not a fix and I am not sure it is needed.

The same doubt, what is this relationship with your fix in
Patch 1/3?
  
Jingjing Wu May 8, 2017, 6:17 a.m. UTC | #3
> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Wu, Jingjing
> Sent: Monday, May 8, 2017 9:02 AM
> To: Thomas Monjalon <thomas@monjalon.net>; Dai, Wei <wei.dai@intel.com>
> Cc: dev@dpdk.org; Lu, Wenzhuo <wenzhuo.lu@intel.com>;
> harish.patil@cavium.com; rasesh.mody@cavium.com;
> stephen.hurd@broadcom.com; ajit.khaparde@broadcom.com; Zhang, Helin
> <helin.zhang@intel.com>; Ananyev, Konstantin
> <konstantin.ananyev@intel.com>; Chen, Jing D <jing.d.chen@intel.com>;
> adrien.mazarguil@6wind.com; nelio.laranjeiro@6wind.com; Richardson, Bruce
> <bruce.richardson@intel.com>; yuanhan.liu@linux.intel.com;
> maxime.coquelin@redhat.com; shepard.siegel@atomicrules.com;
> ed.czeck@atomicrules.com; john.miller@atomicrules.com
> Subject: Re: [dpdk-dev] [PATCH v7 3/3] app/testpmd: add a command to add
> many MAC addrs
> 
> 
> 
> > -----Original Message-----
> > From: Thomas Monjalon [mailto:thomas@monjalon.net]
> > Sent: Friday, May 5, 2017 10:24 PM
> > To: Dai, Wei <wei.dai@intel.com>
> > Cc: dev@dpdk.org; Lu, Wenzhuo <wenzhuo.lu@intel.com>;
> > harish.patil@cavium.com; rasesh.mody@cavium.com;
> > stephen.hurd@broadcom.com; ajit.khaparde@broadcom.com; Zhang, Helin
> > <helin.zhang@intel.com>; Ananyev, Konstantin
> > <konstantin.ananyev@intel.com>; Wu, Jingjing <jingjing.wu@intel.com>;
> > Chen, Jing D <jing.d.chen@intel.com>; adrien.mazarguil@6wind.com;
> > nelio.laranjeiro@6wind.com; Richardson, Bruce
> > <bruce.richardson@intel.com>; yuanhan.liu@linux.intel.com;
> > maxime.coquelin@redhat.com; shepard.siegel@atomicrules.com;
> > ed.czeck@atomicrules.com; john.miller@atomicrules.com
> > Subject: Re: [dpdk-dev] [PATCH v7 3/3] app/testpmd: add a command to
> > add many MAC addrs
> >
> > 05/05/2017 02:40, Wei Dai:
> > > This patch is added to introduce a testpmd command which is used to
> > > add more than one MAC addresses one time.
> > > This command can simplify the test for the change where the type of
> > > return value of adding MAC address.
> > > Normally a MAC address may fails to be added only after many MAC
> > > addresses have been added.
> > > Without this command, a tester may only trigger failed MAC address
> > > by running many times of testpmd command 'mac_addr add' .
> > >
> > > Signed-off-by: Wei Dai <wei.dai@intel.com>
> > > ---
> > >  app/test-pmd/cmdline.c | 55
> > > ++++++++++++++++++++++++++++++++++++++++++++++++++
> > >  1 file changed, 55 insertions(+)
> >
> > This patch has not been reviewed.
> > It is not a fix and I am not sure it is needed.
> 
> The same doubt, what is this relationship with your fix in Patch 1/3?
> 
If it is only for testing for special case, and it can be done through
calling 'mac_addr add' by multi times. I'd like to Nack it.

Thanks
Jingjing
  

Patch

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 06c1ce2..f73bb83 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -6436,6 +6436,60 @@  cmdline_parse_inst_t cmd_mac_addr = {
 	},
 };
 
+/* *** ADD MORE THAN ONE MAC ADDRESS FROM A PORT *** */
+struct cmd_add_more_mac_addr_result {
+	cmdline_fixed_string_t mac_addr_cmd;
+	uint8_t port_num;
+	struct ether_addr address;
+	uint8_t cnt_addr;
+};
+
+static void cmd_add_more_mac_addr_parsed(void *parsed_result,
+		__attribute__((unused)) struct cmdline *cl,
+		__attribute__((unused)) void *data)
+{
+	struct cmd_add_more_mac_addr_result *res = parsed_result;
+	int ret;
+	int k;
+
+	for (k = 0; k < res->cnt_addr; k++) {
+		ret = rte_eth_dev_mac_addr_add(res->port_num, &res->address, 0);
+		if (ret  < 0) {
+			printf("Fail to add mac addr : (%s) after adding %u addresses\n",
+				strerror(-ret), k);
+			return;
+		}
+		res->address.addr_bytes[5]++;
+	}
+	printf("Success to add %u mac addresses\n", k);
+}
+
+cmdline_parse_token_string_t cmd_add_more_mac_addr_cmd =
+	TOKEN_STRING_INITIALIZER(struct cmd_add_more_mac_addr_result,
+		mac_addr_cmd, "add_more_mac_addr");
+cmdline_parse_token_num_t cmd_add_more_mac_addr_portnum =
+	TOKEN_NUM_INITIALIZER(struct cmd_add_more_mac_addr_result,
+		port_num, UINT8);
+cmdline_parse_token_etheraddr_t cmd_add_more_mac_addr_addr =
+	TOKEN_ETHERADDR_INITIALIZER(struct cmd_add_more_mac_addr_result,
+		address);
+cmdline_parse_token_num_t cmd_add_more_mac_addr_cnt_addr =
+	TOKEN_NUM_INITIALIZER(struct cmd_add_more_mac_addr_result,
+		cnt_addr, UINT8);
+
+cmdline_parse_inst_t cmd_add_more_mac_addr = {
+	.f = cmd_add_more_mac_addr_parsed,
+	.data = (void *)0,
+	.help_str = "add_more_mac_addr <port_id> <mac_addr> <cnt_addr>: "
+			"Add cnt_addr MAC addresses on port_id",
+	.tokens = {
+		(void *)&cmd_add_more_mac_addr_cmd,
+		(void *)&cmd_add_more_mac_addr_portnum,
+		(void *)&cmd_add_more_mac_addr_addr,
+		(void *)&cmd_add_more_mac_addr_cnt_addr,
+		NULL,
+	},
+};
 
 /* *** CONFIGURE QUEUE STATS COUNTER MAPPINGS *** */
 struct cmd_set_qmap_result {
@@ -13647,6 +13701,7 @@  cmdline_parse_ctx_t main_ctx[] = {
 	(cmdline_parse_inst_t *)&cmd_read_rxd_txd,
 	(cmdline_parse_inst_t *)&cmd_stop,
 	(cmdline_parse_inst_t *)&cmd_mac_addr,
+	(cmdline_parse_inst_t *)&cmd_add_more_mac_addr,
 	(cmdline_parse_inst_t *)&cmd_set_qmap,
 	(cmdline_parse_inst_t *)&cmd_operate_port,
 	(cmdline_parse_inst_t *)&cmd_operate_specific_port,