All of lore.kernel.org
 help / color / mirror / Atom feed
From: Wenzhuo Lu <wenzhuo.lu@intel.com>
To: dev@dpdk.org
Subject: [PATCH 4/8] app/testpmd: add CLIs for l2 tunnel config
Date: Fri, 29 Jan 2016 15:03:51 +0800	[thread overview]
Message-ID: <1454051035-25757-5-git-send-email-wenzhuo.lu@intel.com> (raw)
In-Reply-To: <1454051035-25757-1-git-send-email-wenzhuo.lu@intel.com>

Add CLIs to config ether type of l2 tunnel, and to enable/disable
a type of l2 tunnel.
Now only e-tag tunnel is supported.

Signed-off-by: Wenzhuo Lu <wenzhuo.lu@intel.com>
---
 app/test-pmd/cmdline.c | 259 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 259 insertions(+)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 73298c9..d409934 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -9630,6 +9630,261 @@ cmdline_parse_inst_t cmd_mcast_addr = {
 	},
 };
 
+/* l2 tunnel config
+ * only support E-tag now.
+ */
+
+/* Ether type config */
+struct cmd_config_l2_tunnel_eth_type_result {
+	cmdline_fixed_string_t port;
+	cmdline_fixed_string_t config;
+	cmdline_fixed_string_t all;
+	uint8_t id;
+	cmdline_fixed_string_t l2_tunnel;
+	cmdline_fixed_string_t l2_tunnel_type;
+	cmdline_fixed_string_t eth_type;
+	uint16_t eth_type_val;
+};
+
+cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_config_l2_tunnel_eth_type_result,
+		 port, "port");
+cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_config_l2_tunnel_eth_type_result,
+		 config, "config");
+cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_config_l2_tunnel_eth_type_result,
+		 all, "all");
+cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id =
+	TOKEN_NUM_INITIALIZER
+		(struct cmd_config_l2_tunnel_eth_type_result,
+		 id, UINT8);
+cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_config_l2_tunnel_eth_type_result,
+		 l2_tunnel, "l2-tunnel");
+cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_config_l2_tunnel_eth_type_result,
+		 l2_tunnel_type, "E-tag");
+cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_config_l2_tunnel_eth_type_result,
+		 eth_type, "ether-type");
+cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val =
+	TOKEN_NUM_INITIALIZER
+		(struct cmd_config_l2_tunnel_eth_type_result,
+		 eth_type_val, UINT16);
+
+static uint32_t
+str2fdir_l2_tunnel_type(char *string)
+{
+	uint32_t i = 0;
+
+	static const struct {
+		char str[32];
+		uint32_t type;
+	} l2_tunnel_type_str[] = {
+		{"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG},
+	};
+
+	for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) {
+		if (!strcmp(l2_tunnel_type_str[i].str, string))
+			return l2_tunnel_type_str[i].type;
+	}
+	return RTE_L2_TUNNEL_TYPE_NONE;
+}
+
+/* ether type config for all ports */
+static void
+cmd_config_l2_tunnel_eth_type_all_parsed
+	(void *parsed_result,
+	 __attribute__((unused)) struct cmdline *cl,
+	 __attribute__((unused)) void *data)
+{
+	struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result;
+	struct rte_eth_l2_tunnel entry;
+	portid_t pid;
+
+	entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
+	entry.ether_type = res->eth_type_val;
+
+	FOREACH_PORT(pid, ports) {
+		rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry);
+	}
+}
+
+cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = {
+	.f = cmd_config_l2_tunnel_eth_type_all_parsed,
+	.data = NULL,
+	.help_str = "port config all l2-tunnel ether-type",
+	.tokens = {
+		(void *)&cmd_config_l2_tunnel_eth_type_port,
+		(void *)&cmd_config_l2_tunnel_eth_type_config,
+		(void *)&cmd_config_l2_tunnel_eth_type_all_str,
+		(void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
+		(void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
+		(void *)&cmd_config_l2_tunnel_eth_type_eth_type,
+		(void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
+		NULL,
+	},
+};
+
+/* ether type config for a specific port */
+static void
+cmd_config_l2_tunnel_eth_type_specific_parsed(
+	void *parsed_result,
+	__attribute__((unused)) struct cmdline *cl,
+	__attribute__((unused)) void *data)
+{
+	struct cmd_config_l2_tunnel_eth_type_result *res =
+		 parsed_result;
+	struct rte_eth_l2_tunnel entry;
+
+	if (port_id_is_invalid(res->id, ENABLED_WARN))
+		return;
+
+	entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
+	entry.ether_type = res->eth_type_val;
+
+	rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry);
+}
+
+cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = {
+	.f = cmd_config_l2_tunnel_eth_type_specific_parsed,
+	.data = NULL,
+	.help_str = "port config l2-tunnel ether-type",
+	.tokens = {
+		(void *)&cmd_config_l2_tunnel_eth_type_port,
+		(void *)&cmd_config_l2_tunnel_eth_type_config,
+		(void *)&cmd_config_l2_tunnel_eth_type_id,
+		(void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel,
+		(void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type,
+		(void *)&cmd_config_l2_tunnel_eth_type_eth_type,
+		(void *)&cmd_config_l2_tunnel_eth_type_eth_type_val,
+		NULL,
+	},
+};
+
+/* Enable/disable l2 tunnel */
+struct cmd_config_l2_tunnel_en_dis_result {
+	cmdline_fixed_string_t port;
+	cmdline_fixed_string_t config;
+	cmdline_fixed_string_t all;
+	uint8_t id;
+	cmdline_fixed_string_t l2_tunnel;
+	cmdline_fixed_string_t l2_tunnel_type;
+	cmdline_fixed_string_t en_dis;
+};
+
+cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_config_l2_tunnel_en_dis_result,
+		 port, "port");
+cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_config_l2_tunnel_en_dis_result,
+		 config, "config");
+cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_config_l2_tunnel_en_dis_result,
+		 all, "all");
+cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id =
+	TOKEN_NUM_INITIALIZER
+		(struct cmd_config_l2_tunnel_en_dis_result,
+		 id, UINT8);
+cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_config_l2_tunnel_en_dis_result,
+		 l2_tunnel, "l2-tunnel");
+cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_config_l2_tunnel_en_dis_result,
+		 l2_tunnel_type, "E-tag");
+cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis =
+	TOKEN_STRING_INITIALIZER
+		(struct cmd_config_l2_tunnel_en_dis_result,
+		 en_dis, "enable#disable");
+
+/* enable/disable l2 tunnel for all ports */
+static void
+cmd_config_l2_tunnel_en_dis_all_parsed(
+	void *parsed_result,
+	__attribute__((unused)) struct cmdline *cl,
+	__attribute__((unused)) void *data)
+{
+	struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result;
+	enum rte_eth_l2_tunnel_type l2_tunnel_type;
+	portid_t pid;
+
+	l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
+
+	if (!strcmp("enable", res->en_dis)) {
+		FOREACH_PORT(pid, ports) {
+			rte_eth_dev_l2_tunnel_enable(pid, l2_tunnel_type);
+		}
+	} else {
+		FOREACH_PORT(pid, ports) {
+			rte_eth_dev_l2_tunnel_disable(pid, l2_tunnel_type);
+		}
+	}
+}
+
+cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = {
+	.f = cmd_config_l2_tunnel_en_dis_all_parsed,
+	.data = NULL,
+	.help_str = "port config all l2-tunnel enable/disable",
+	.tokens = {
+		(void *)&cmd_config_l2_tunnel_en_dis_port,
+		(void *)&cmd_config_l2_tunnel_en_dis_config,
+		(void *)&cmd_config_l2_tunnel_en_dis_all_str,
+		(void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
+		(void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
+		(void *)&cmd_config_l2_tunnel_en_dis_en_dis,
+		NULL,
+	},
+};
+
+/* enable/disable l2 tunnel for a port */
+static void
+cmd_config_l2_tunnel_en_dis_specific_parsed(
+	void *parsed_result,
+	__attribute__((unused)) struct cmdline *cl,
+	__attribute__((unused)) void *data)
+{
+	struct cmd_config_l2_tunnel_en_dis_result *res =
+		parsed_result;
+	enum rte_eth_l2_tunnel_type l2_tunnel_type;
+
+	if (port_id_is_invalid(res->id, ENABLED_WARN))
+		return;
+
+	l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type);
+
+	if (!strcmp("enable", res->en_dis))
+		rte_eth_dev_l2_tunnel_enable(res->id, l2_tunnel_type);
+	else
+		rte_eth_dev_l2_tunnel_disable(res->id, l2_tunnel_type);
+}
+
+cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = {
+	.f = cmd_config_l2_tunnel_en_dis_specific_parsed,
+	.data = NULL,
+	.help_str = "port config l2-tunnel enable/disable",
+	.tokens = {
+		(void *)&cmd_config_l2_tunnel_en_dis_port,
+		(void *)&cmd_config_l2_tunnel_en_dis_config,
+		(void *)&cmd_config_l2_tunnel_en_dis_id,
+		(void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel,
+		(void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type,
+		(void *)&cmd_config_l2_tunnel_en_dis_en_dis,
+		NULL,
+	},
+};
+
 /* ******************************************************************************** */
 
 /* list of instructions */
@@ -9771,6 +10026,10 @@ cmdline_parse_ctx_t main_ctx[] = {
 	(cmdline_parse_inst_t *)&cmd_set_hash_input_set,
 	(cmdline_parse_inst_t *)&cmd_set_fdir_input_set,
 	(cmdline_parse_inst_t *)&cmd_mcast_addr,
+	(cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all,
+	(cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific,
+	(cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all,
+	(cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific,
 	NULL,
 };
 
-- 
1.9.3

  parent reply	other threads:[~2016-01-29  7:04 UTC|newest]

Thread overview: 95+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-29  7:03 [PATCH 0/8] support E-tag offloading and forwarding on Intel X550 NIC Wenzhuo Lu
2016-01-29  7:03 ` [PATCH 1/8] ixgbe: select pool by MAC when using double VLAN Wenzhuo Lu
2016-01-29  7:03 ` [PATCH 2/8] lib/librte_ether: support l2 tunnel config Wenzhuo Lu
2016-01-29  7:03 ` [PATCH 3/8] ixgbe: " Wenzhuo Lu
2016-01-29  7:03 ` Wenzhuo Lu [this message]
2016-01-29  7:03 ` [PATCH 5/8] lib/librte_ether: support new l2 tunnel operation Wenzhuo Lu
2016-01-29  7:03 ` [PATCH 6/8] ixgbe: support " Wenzhuo Lu
2016-01-29  7:03 ` [PATCH 7/8] app/testpmd: add CLIs for E-tag operation Wenzhuo Lu
2016-01-29  7:03 ` [PATCH 8/8] doc: add release note for E-tag Wenzhuo Lu
2016-02-01 16:15   ` Mcnamara, John
2016-01-29  7:16 ` [PATCH 0/8] support E-tag offloading and forwarding on Intel X550 NIC Qiu, Michael
2016-02-01  1:04   ` Lu, Wenzhuo
2016-02-01  1:39     ` Yuanhan Liu
2016-02-01  1:56       ` Lu, Wenzhuo
2016-02-01  2:06         ` Yuanhan Liu
2016-02-01  3:00           ` Lu, Wenzhuo
2016-02-01  8:31       ` Qiu, Michael
2016-02-02  1:24         ` Lu, Wenzhuo
2016-02-02  6:56 ` [PATCH v2 0/7] " Wenzhuo Lu
2016-02-02  6:56   ` [PATCH v2 1/7] ixgbe: select pool by MAC when using double VLAN Wenzhuo Lu
2016-02-02  6:57   ` [PATCH v2 2/7] lib/librte_ether: support l2 tunnel config Wenzhuo Lu
2016-02-02 12:03     ` Bruce Richardson
2016-02-03  1:05       ` Lu, Wenzhuo
2016-02-03  3:36     ` Stephen Hemminger
2016-02-03  8:08       ` Lu, Wenzhuo
2016-02-02  6:57   ` [PATCH v2 3/7] ixgbe: " Wenzhuo Lu
2016-02-02  6:57   ` [PATCH v2 4/7] app/testpmd: add CLIs for " Wenzhuo Lu
2016-02-02  6:57   ` [PATCH v2 5/7] lib/librte_ether: support new l2 tunnel operation Wenzhuo Lu
2016-02-02  6:57   ` [PATCH v2 6/7] ixgbe: support " Wenzhuo Lu
2016-02-02  6:57   ` [PATCH v2 7/7] app/testpmd: add CLIs for E-tag operation Wenzhuo Lu
2016-02-12 13:50   ` [PATCH v2 0/7] support E-tag offloading and forwarding on Intel X550 NIC De Lara Guarch, Pablo
2016-02-15  1:21     ` Lu, Wenzhuo
2016-02-15  9:39       ` De Lara Guarch, Pablo
2016-02-16  8:20 ` [PATCH v3 " Wenzhuo Lu
2016-02-16  8:20   ` [PATCH v3 1/7] ixgbe: select pool by MAC when using double VLAN Wenzhuo Lu
2016-02-16  8:20   ` [PATCH v3 2/7] lib/librte_ether: support l2 tunnel config Wenzhuo Lu
2016-02-16  8:20   ` [PATCH v3 3/7] ixgbe: " Wenzhuo Lu
2016-02-16  8:20   ` [PATCH v3 4/7] app/testpmd: add CLIs for " Wenzhuo Lu
2016-02-16  8:20   ` [PATCH v3 5/7] lib/librte_ether: support new l2 tunnel operation Wenzhuo Lu
2016-02-16  8:20   ` [PATCH v3 6/7] ixgbe: support " Wenzhuo Lu
2016-02-16  8:20   ` [PATCH v3 7/7] app/testpmd: add CLIs for E-tag operation Wenzhuo Lu
2016-02-18  2:46 ` [PATCH v4 0/7] support E-tag offloading and forwarding on Intel X550 NIC Wenzhuo Lu
2016-02-18  2:46   ` [PATCH v4 1/7] ixgbe: select pool by MAC when using double VLAN Wenzhuo Lu
2016-02-18  2:46   ` [PATCH v4 2/7] lib/librte_ether: support l2 tunnel config Wenzhuo Lu
2016-02-18  2:46   ` [PATCH v4 3/7] ixgbe: " Wenzhuo Lu
2016-03-04  1:47     ` He, Shaopeng
2016-03-04  3:17       ` Lu, Wenzhuo
2016-02-18  2:46   ` [PATCH v4 4/7] app/testpmd: add CLIs for " Wenzhuo Lu
2016-02-18  2:46   ` [PATCH v4 5/7] lib/librte_ether: support new l2 tunnel operation Wenzhuo Lu
2016-03-04  1:47     ` He, Shaopeng
2016-03-04  3:31       ` Lu, Wenzhuo
2016-03-07  2:04         ` He, Shaopeng
2016-02-18  2:46   ` [PATCH v4 6/7] ixgbe: support " Wenzhuo Lu
2016-03-04  1:46     ` He, Shaopeng
2016-03-04  3:15       ` Lu, Wenzhuo
2016-02-18  2:46   ` [PATCH v4 7/7] app/testpmd: add CLIs for E-tag operation Wenzhuo Lu
2016-03-04  1:46     ` He, Shaopeng
2016-03-04  3:11       ` Lu, Wenzhuo
2016-03-04  9:23   ` [PATCH v4 0/7] support E-tag offloading and forwarding on Intel X550 NIC Liu, Yong
2016-03-07  2:42 ` [PATCH v5 0/7] support E-tag offloading and forwarding on X550 Wenzhuo Lu
2016-03-07  2:42   ` [PATCH v5 1/7] ixgbe: select pool by MAC when using double VLAN Wenzhuo Lu
2016-03-07  2:42   ` [PATCH v5 2/7] lib/librte_ether: support l2 tunnel config Wenzhuo Lu
2016-03-07  2:42   ` [PATCH v5 3/7] ixgbe: " Wenzhuo Lu
2016-03-07  2:42   ` [PATCH v5 4/7] app/testpmd: add CLIs for " Wenzhuo Lu
2016-03-07  2:42   ` [PATCH v5 5/7] lib/librte_ether: support new l2 tunnel operation Wenzhuo Lu
2016-03-07  3:29     ` Wu, Jingjing
2016-03-07  5:29       ` Lu, Wenzhuo
2016-03-07  2:42   ` [PATCH v5 6/7] ixgbe: support " Wenzhuo Lu
2016-03-07  2:42   ` [PATCH v5 7/7] app/testpmd: add CLIs for E-tag operation Wenzhuo Lu
2016-03-08  6:53 ` [PATCH v6 0/5] support E-tag offloading and forwarding on X550 Wenzhuo Lu
2016-03-08  6:53   ` [PATCH v6 1/5] ixgbe: select pool by MAC when using double VLAN Wenzhuo Lu
2016-03-08  6:53   ` [PATCH v6 2/5] lib/librte_ether: support l2 tunnel operations Wenzhuo Lu
2016-03-09  0:14     ` Thomas Monjalon
2016-03-09  1:15       ` Lu, Wenzhuo
2016-03-09  9:27         ` Thomas Monjalon
2016-03-10  0:54           ` Lu, Wenzhuo
2016-03-08  6:53   ` [PATCH v6 3/5] ixgbe: " Wenzhuo Lu
2016-03-08  6:53   ` [PATCH v6 4/5] app/testpmd: add CLIs for l2 tunnel config Wenzhuo Lu
2016-03-08  6:53   ` [PATCH v6 5/5] app/testpmd: add CLIs for E-tag operation Wenzhuo Lu
2016-03-08  8:08   ` [PATCH v6 0/5] support E-tag offloading and forwarding on X550 Wu, Jingjing
2016-03-09  7:44 ` [PATCH v7 " Wenzhuo Lu
2016-03-09  7:44   ` [PATCH v7 1/5] ixgbe: select pool by MAC when using double VLAN Wenzhuo Lu
2016-03-09  7:44   ` [PATCH v7 2/5] lib/librte_ether: support l2 tunnel operations Wenzhuo Lu
2016-03-09  7:44   ` [PATCH v7 3/5] ixgbe: " Wenzhuo Lu
2016-03-09  7:44   ` [PATCH v7 4/5] app/testpmd: add CLIs for l2 tunnel config Wenzhuo Lu
2016-03-09  7:44   ` [PATCH v7 5/5] app/testpmd: add CLIs for E-tag operation Wenzhuo Lu
2016-03-09 10:07   ` [PATCH v7 0/5] support E-tag offloading and forwarding on X550 Thomas Monjalon
2016-03-10  0:44     ` Lu, Wenzhuo
2016-03-11  1:10 ` [PATCH v8 " Wenzhuo Lu
2016-03-11  1:10   ` [PATCH v8 1/5] ixgbe: select pool by MAC when using double VLAN Wenzhuo Lu
2016-03-11  1:10   ` [PATCH v8 2/5] lib/librte_ether: support l2 tunnel operations Wenzhuo Lu
2016-03-11  1:10   ` [PATCH v8 3/5] ixgbe: " Wenzhuo Lu
2016-03-11  1:10   ` [PATCH v8 4/5] app/testpmd: add CLIs for l2 tunnel config Wenzhuo Lu
2016-03-11  1:10   ` [PATCH v8 5/5] app/testpmd: add CLIs for E-tag operation Wenzhuo Lu
2016-03-11 22:27   ` [PATCH v8 0/5] support E-tag offloading and forwarding on X550 Thomas Monjalon

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=1454051035-25757-5-git-send-email-wenzhuo.lu@intel.com \
    --to=wenzhuo.lu@intel.com \
    --cc=dev@dpdk.org \
    /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 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.