DPDK patches and discussions
 help / color / mirror / Atom feed
From: Jingjing Wu <jingjing.wu@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH 3/4] testpmd: new commands for ethertype filter
Date: Thu, 25 Dec 2014 11:14:29 +0800	[thread overview]
Message-ID: <1419477270-14611-4-git-send-email-jingjing.wu@intel.com> (raw)
In-Reply-To: <1419477270-14611-1-git-send-email-jingjing.wu@intel.com>

Following commands of ethertype filter are removed:
  - add_ethertype_filter (port_id) ethertype (eth_value)
  - remove_ethertype_filter (port_id) index (idx)
  - get_ethertype_filter (port_id) index (idx)
New command is added for ethertype filter by using filter_ctrl API and new
ethertype filter structure:
  - ethertype_filter (port_id) (add|del) (mac_addr|mac_ignr)
    (mac_address) ethertype (ether_type) (drop|fwd) queue (queue_id)

Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
---
 app/test-pmd/cmdline.c | 253 ++++++++++++++++++++++---------------------------
 app/test-pmd/config.c  |  27 ------
 2 files changed, 112 insertions(+), 168 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 882a5a2..f0c7d5f 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -654,15 +654,10 @@ static void cmd_help_long_parsed(void *parsed_result,
 			"filters:\n"
 			"--------\n\n"
 
-			"add_ethertype_filter (port_id) ethertype (eth_value)"
-			" priority (enable|disable)(pri_value) queue (queue_id) index (idx)\n"
-			"    add an ethertype filter.\n\n"
-
-			"remove_ethertype_filter (port_id) index (idx)\n"
-			"    remove an ethertype filter.\n\n"
-
-			"get_ethertype_filter (port_id) index (idx)\n"
-			"    get info of a ethertype filter.\n\n"
+			"ethertype_filter (port_id) (add|del)"
+			" (mac_addr|mac_ignr) (mac_address) ethertype"
+			" (ether_type) (drop|fwd) queue (queue_id)\n"
+			"    Add/Del an ethertype filter.\n\n"
 
 			"add_2tuple_filter (port_id) protocol (pro_value) (pro_mask)"
 			" dst_port (port_value) (port_mask) flags (flg_value) priority (prio_value)"
@@ -7264,135 +7259,6 @@ cmdline_parse_inst_t cmd_dump_one = {
 	},
 };
 
-/* *** ADD/REMOVE an ethertype FILTER *** */
-struct cmd_ethertype_filter_result {
-	cmdline_fixed_string_t filter;
-	uint8_t port_id;
-	cmdline_fixed_string_t ethertype;
-	uint16_t ethertype_value;
-	cmdline_fixed_string_t priority;
-	cmdline_fixed_string_t priority_en;
-	uint8_t priority_value;
-	cmdline_fixed_string_t queue;
-	uint16_t queue_id;
-	cmdline_fixed_string_t index;
-	uint16_t index_value;
-};
-
-static void
-cmd_ethertype_filter_parsed(void *parsed_result,
-			__attribute__((unused)) struct cmdline *cl,
-			__attribute__((unused)) void *data)
-{
-	int ret = 0;
-	struct cmd_ethertype_filter_result *res = parsed_result;
-	struct rte_ethertype_filter filter;
-
-	memset(&filter, 0, sizeof(struct rte_ethertype_filter));
-	filter.ethertype = rte_cpu_to_le_16(res->ethertype_value);
-	filter.priority = res->priority_value;
-
-	if (!strcmp(res->priority_en, "enable"))
-		filter.priority_en = 1;
-	if (!strcmp(res->filter, "add_ethertype_filter"))
-		ret = rte_eth_dev_add_ethertype_filter(res->port_id,
-				res->index_value,
-				&filter, res->queue_id);
-	else if (!strcmp(res->filter, "remove_ethertype_filter"))
-		ret = rte_eth_dev_remove_ethertype_filter(res->port_id,
-				res->index_value);
-	else if (!strcmp(res->filter, "get_ethertype_filter"))
-		get_ethertype_filter(res->port_id, res->index_value);
-
-	if (ret < 0)
-		printf("ethertype filter setting error: (%s)\n",
-			strerror(-ret));
-}
-
-cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
-	TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
-				port_id, UINT8);
-cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
-	TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
-				ethertype, "ethertype");
-cmdline_parse_token_ipaddr_t cmd_ethertype_filter_ethertype_value =
-	TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
-				ethertype_value, UINT16);
-cmdline_parse_token_string_t cmd_ethertype_filter_priority =
-	TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
-				priority, "priority");
-cmdline_parse_token_string_t cmd_ethertype_filter_priority_en =
-	TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
-				priority_en, "enable#disable");
-cmdline_parse_token_num_t cmd_ethertype_filter_priority_value =
-	TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
-				priority_value, UINT8);
-cmdline_parse_token_string_t cmd_ethertype_filter_queue =
-	TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
-				queue, "queue");
-cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
-	TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
-				queue_id, UINT16);
-cmdline_parse_token_string_t cmd_ethertype_filter_index =
-	TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
-				index, "index");
-cmdline_parse_token_num_t cmd_ethertype_filter_index_value =
-	TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
-				index_value, UINT16);
-cmdline_parse_token_string_t cmd_ethertype_filter_add_filter =
-	TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
-				filter, "add_ethertype_filter");
-cmdline_parse_inst_t cmd_add_ethertype_filter = {
-	.f = cmd_ethertype_filter_parsed,
-	.data = NULL,
-	.help_str = "add an ethertype filter",
-	.tokens = {
-		(void *)&cmd_ethertype_filter_add_filter,
-		(void *)&cmd_ethertype_filter_port_id,
-		(void *)&cmd_ethertype_filter_ethertype,
-		(void *)&cmd_ethertype_filter_ethertype_value,
-		(void *)&cmd_ethertype_filter_priority,
-		(void *)&cmd_ethertype_filter_priority_en,
-		(void *)&cmd_ethertype_filter_priority_value,
-		(void *)&cmd_ethertype_filter_queue,
-		(void *)&cmd_ethertype_filter_queue_id,
-		(void *)&cmd_ethertype_filter_index,
-		(void *)&cmd_ethertype_filter_index_value,
-		NULL,
-	},
-};
-
-cmdline_parse_token_string_t cmd_ethertype_filter_remove_filter =
-	TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
-				 filter, "remove_ethertype_filter");
-cmdline_parse_inst_t cmd_remove_ethertype_filter = {
-	.f = cmd_ethertype_filter_parsed,
-	.data = NULL,
-	.help_str = "remove an ethertype filter",
-	.tokens = {
-		(void *)&cmd_ethertype_filter_remove_filter,
-		(void *)&cmd_ethertype_filter_port_id,
-		(void *)&cmd_ethertype_filter_index,
-		(void *)&cmd_ethertype_filter_index_value,
-		NULL,
-	},
-};
-cmdline_parse_token_string_t cmd_ethertype_filter_get_filter =
-	TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
-				 filter, "get_ethertype_filter");
-cmdline_parse_inst_t cmd_get_ethertype_filter = {
-	.f = cmd_ethertype_filter_parsed,
-	.data = NULL,
-	.help_str = "get an ethertype filter",
-	.tokens = {
-		(void *)&cmd_ethertype_filter_get_filter,
-		(void *)&cmd_ethertype_filter_port_id,
-		(void *)&cmd_ethertype_filter_index,
-		(void *)&cmd_ethertype_filter_index_value,
-		NULL,
-	},
-};
-
 /* *** set SYN filter *** */
 struct cmd_set_syn_filter_result {
 	cmdline_fixed_string_t filter;
@@ -8096,6 +7962,113 @@ cmdline_parse_inst_t cmd_get_flex_filter = {
 
 /* *** Filters Control *** */
 
+/* *** deal with ethertype filter *** */
+struct cmd_ethertype_filter_result {
+	cmdline_fixed_string_t filter;
+	uint8_t port_id;
+	cmdline_fixed_string_t ops;
+	cmdline_fixed_string_t mac;
+	struct ether_addr mac_addr;
+	cmdline_fixed_string_t ethertype;
+	uint16_t ethertype_value;
+	cmdline_fixed_string_t drop;
+	cmdline_fixed_string_t queue;
+	uint16_t  queue_id;
+};
+
+cmdline_parse_token_string_t cmd_ethertype_filter_filter =
+	TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
+				 filter, "ethertype_filter");
+cmdline_parse_token_num_t cmd_ethertype_filter_port_id =
+	TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
+			      port_id, UINT8);
+cmdline_parse_token_string_t cmd_ethertype_filter_ops =
+	TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
+				 ops, "add#del");
+cmdline_parse_token_string_t cmd_ethertype_filter_mac =
+	TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
+				 mac, "mac_addr#mac_ignr");
+cmdline_parse_token_etheraddr_t cmd_ethertype_filter_mac_addr =
+	TOKEN_ETHERADDR_INITIALIZER(struct cmd_ethertype_filter_result,
+				     mac_addr);
+cmdline_parse_token_string_t cmd_ethertype_filter_ethertype =
+	TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
+				 ethertype, "ethertype");
+cmdline_parse_token_num_t cmd_ethertype_filter_ethertype_value =
+	TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
+			      ethertype_value, UINT16);
+cmdline_parse_token_string_t cmd_ethertype_filter_drop =
+	TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
+				 drop, "drop#fwd");
+cmdline_parse_token_string_t cmd_ethertype_filter_queue =
+	TOKEN_STRING_INITIALIZER(struct cmd_ethertype_filter_result,
+				 queue, "queue");
+cmdline_parse_token_num_t cmd_ethertype_filter_queue_id =
+	TOKEN_NUM_INITIALIZER(struct cmd_ethertype_filter_result,
+			      queue_id, UINT16);
+
+static void
+cmd_ethertype_filter_parsed(void *parsed_result,
+			  __attribute__((unused)) struct cmdline *cl,
+			  __attribute__((unused)) void *data)
+{
+	struct cmd_ethertype_filter_result *res = parsed_result;
+	struct rte_eth_ethertype_filter filter;
+	int ret = 0;
+
+	ret = rte_eth_dev_filter_supported(res->port_id,
+			RTE_ETH_FILTER_ETHERTYPE);
+	if (ret < 0) {
+		printf("ethertype filter is not supported on port %u.\n",
+			res->port_id);
+		return;
+	}
+
+	memset(&filter, 0, sizeof(filter));
+	if (!strcmp(res->mac, "mac_addr")) {
+		filter.flags |= RTE_ETHTYPE_FLAGS_MAC;
+		(void)rte_memcpy(&filter.mac_addr, &res->mac_addr,
+			sizeof(struct ether_addr));
+	}
+	if (!strcmp(res->drop, "drop"))
+		filter.flags |= RTE_ETHTYPE_FLAGS_DROP;
+	filter.ether_type = res->ethertype_value;
+	filter.queue = res->queue_id;
+
+	if (!strcmp(res->ops, "add"))
+		ret = rte_eth_dev_filter_ctrl(res->port_id,
+				RTE_ETH_FILTER_ETHERTYPE,
+				RTE_ETH_FILTER_ADD,
+				&filter);
+	else
+		ret = rte_eth_dev_filter_ctrl(res->port_id,
+				RTE_ETH_FILTER_ETHERTYPE,
+				RTE_ETH_FILTER_DELETE,
+				&filter);
+	if (ret < 0)
+		printf("ethertype filter programming error: (%s)\n",
+			strerror(-ret));
+}
+
+cmdline_parse_inst_t cmd_ethertype_filter = {
+	.f = cmd_ethertype_filter_parsed,
+	.data = NULL,
+	.help_str = "add or delete an ethertype filter entry",
+	.tokens = {
+		(void *)&cmd_ethertype_filter_filter,
+		(void *)&cmd_ethertype_filter_port_id,
+		(void *)&cmd_ethertype_filter_ops,
+		(void *)&cmd_ethertype_filter_mac,
+		(void *)&cmd_ethertype_filter_mac_addr,
+		(void *)&cmd_ethertype_filter_ethertype,
+		(void *)&cmd_ethertype_filter_ethertype_value,
+		(void *)&cmd_ethertype_filter_drop,
+		(void *)&cmd_ethertype_filter_queue,
+		(void *)&cmd_ethertype_filter_queue_id,
+		NULL,
+	},
+};
+
 /* *** deal with flow director filter *** */
 struct cmd_flow_director_result {
 	cmdline_fixed_string_t flow_director_filter;
@@ -8815,9 +8788,7 @@ cmdline_parse_ctx_t main_ctx[] = {
 	(cmdline_parse_inst_t *)&cmd_config_rss_hash_key,
 	(cmdline_parse_inst_t *)&cmd_dump,
 	(cmdline_parse_inst_t *)&cmd_dump_one,
-	(cmdline_parse_inst_t *)&cmd_add_ethertype_filter,
-	(cmdline_parse_inst_t *)&cmd_remove_ethertype_filter,
-	(cmdline_parse_inst_t *)&cmd_get_ethertype_filter,
+	(cmdline_parse_inst_t *)&cmd_ethertype_filter,
 	(cmdline_parse_inst_t *)&cmd_add_syn_filter,
 	(cmdline_parse_inst_t *)&cmd_remove_syn_filter,
 	(cmdline_parse_inst_t *)&cmd_get_syn_filter,
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 97b6525..c40f819 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -2166,33 +2166,6 @@ set_vf_rate_limit(portid_t port_id, uint16_t vf, uint16_t rate, uint64_t q_msk)
 }
 
 void
-get_ethertype_filter(uint8_t port_id, uint16_t index)
-{
-	struct rte_ethertype_filter filter;
-	int ret = 0;
-	uint16_t rx_queue;
-
-	memset(&filter, 0, sizeof(filter));
-	ret = rte_eth_dev_get_ethertype_filter(port_id, index,
-				&filter, &rx_queue);
-	if (ret < 0) {
-		if (ret == (-ENOENT))
-			printf("filter[%d] is not enabled\n", index);
-		else
-			printf("get ethertype filter fails(%s)\n", strerror(-ret));
-		return;
-	} else {
-		printf("filter[%d]:\n", index);
-		printf("    ethertype:  0x%04x\n",
-			rte_le_to_cpu_32(filter.ethertype));
-		printf("    priority: %s, %d\n",
-			filter.priority_en ? "enable" : "disable",
-			filter.priority);
-		printf("    queue: %d\n", rx_queue);
-	}
-}
-
-void
 get_syn_filter(uint8_t port_id)
 {
 	struct rte_syn_filter filter;
-- 
1.9.3

  parent reply	other threads:[~2014-12-25  3:14 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-12-25  3:14 [dpdk-dev] [PATCH 0/4] Integrate ethertype filter in igb/ixgbe driver to new API Jingjing Wu
2014-12-25  3:14 ` [dpdk-dev] [PATCH 1/4] ixgbe: new functions replace old ones for ethertype filter Jingjing Wu
2014-12-25  3:14 ` [dpdk-dev] [PATCH 2/4] e1000: new functions replace old ones for ethertype filters Jingjing Wu
2015-01-12  1:32   ` Zhang, Helin
2014-12-25  3:14 ` Jingjing Wu [this message]
2014-12-25  3:14 ` [dpdk-dev] [PATCH 4/4] ethdev: remove old APIs and structures of ethertype filter Jingjing Wu
2014-12-25  3:27 ` [dpdk-dev] [PATCH 0/4] Integrate ethertype filter in igb/ixgbe driver to new API Qiu, Michael
2014-12-25  3:39   ` Wu, Jingjing
2014-12-25  4:57     ` Qiu, Michael
2015-01-12  7:16 ` [dpdk-dev] [PATCH v2 " Jingjing Wu
2015-01-12  7:16   ` [dpdk-dev] [PATCH v2 1/4] ixgbe: new functions replace old ones for ethertype filter Jingjing Wu
2015-01-12  7:16   ` [dpdk-dev] [PATCH v2 2/4] e1000: " Jingjing Wu
2015-01-12  7:16   ` [dpdk-dev] [PATCH v2 3/4] testpmd: new commands " Jingjing Wu
2015-01-20 10:14     ` Thomas Monjalon
2015-01-12  7:16   ` [dpdk-dev] [PATCH v2 4/4] ethdev: remove old APIs and structures of " Jingjing Wu
2015-01-12  7:23   ` [dpdk-dev] [PATCH v2 0/4] Integrate ethertype filter in igb/ixgbe driver to new API Zhang, Helin
2015-01-20  8:17     ` 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=1419477270-14611-4-git-send-email-jingjing.wu@intel.com \
    --to=jingjing.wu@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 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).