From: Wei Dai <wei.dai@intel.com>
To: dev@dpdk.org, thomas.monjalon@6wind.com, harish.patil@cavium.com,
rasesh.mody@cavium.com, stephen.hurd@broadcom.com,
ajit.khaparde@broadcom.com, wenzhuo.lu@intel.com,
helin.zhang@intel.com, konstantin.ananyev@intel.com,
jingjing.wu@intel.com, jing.d.chen@intel.com,
adrien.mazarguil@6wind.com, nelio.laranjeiro@6wind.com,
bruce.richardson@intel.com, yuanhan.liu@linux.intel.com,
maxime.coquelin@redhat.com
Cc: Wei Dai <wei.dai@intel.com>
Subject: [PATCH 2/2] app/testpmd: add a command to add many MAC addrs
Date: Sat, 1 Apr 2017 16:03:17 +0800 [thread overview]
Message-ID: <1491033797-14186-3-git-send-email-wei.dai@intel.com> (raw)
In-Reply-To: <1491033797-14186-1-git-send-email-wei.dai@intel.com>
Signed-off-by: Wei Dai <wei.dai@intel.com>
---
app/test-pmd/cmdline.c | 55 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 55 insertions(+)
diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 47f935d..8dab30e 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -6396,6 +6396,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 {
@@ -12484,6 +12538,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,
--
2.7.4
next prev parent reply other threads:[~2017-04-01 8:10 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-04-01 8:03 [PATCH 0/2] MAC address fail to be added shouldn't be stored Wei Dai
2017-04-01 8:03 ` [PATCH 1/2] ethdev: fix adding invalid MAC addr Wei Dai
2017-04-03 9:18 ` Nélio Laranjeiro
2017-04-07 1:38 ` Dai, Wei
2017-04-01 8:03 ` Wei Dai [this message]
-- strict thread matches above, loose matches on Subject: below --
2017-03-31 17:04 [PATCH 0/2] mac addr fail to be added shouldn't be storeid Wei Dai
2017-03-31 17:04 ` [PATCH 2/2] app/testpmd: add a command to add many mac addrs Wei Dai
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1491033797-14186-3-git-send-email-wei.dai@intel.com \
--to=wei.dai@intel.com \
--cc=adrien.mazarguil@6wind.com \
--cc=ajit.khaparde@broadcom.com \
--cc=bruce.richardson@intel.com \
--cc=dev@dpdk.org \
--cc=harish.patil@cavium.com \
--cc=helin.zhang@intel.com \
--cc=jing.d.chen@intel.com \
--cc=jingjing.wu@intel.com \
--cc=konstantin.ananyev@intel.com \
--cc=maxime.coquelin@redhat.com \
--cc=nelio.laranjeiro@6wind.com \
--cc=rasesh.mody@cavium.com \
--cc=stephen.hurd@broadcom.com \
--cc=thomas.monjalon@6wind.com \
--cc=wenzhuo.lu@intel.com \
--cc=yuanhan.liu@linux.intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).