DPDK patches and discussions
 help / color / mirror / Atom feed
From: Pablo de Lara <pablo.de.lara.guarch@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH v3 3/5] testpmd: new commands for flex filter
Date: Sat, 21 Feb 2015 01:53:09 +0000	[thread overview]
Message-ID: <1424483591-25944-4-git-send-email-pablo.de.lara.guarch@intel.com> (raw)
In-Reply-To: <1424483591-25944-1-git-send-email-pablo.de.lara.guarch@intel.com>

From: Jingjing Wu <jingjing.wu@intel.com>

Following commands of flex filter are removed:
  - add_flex_filter (port_id) len (len_value) bytes (bytes_string) mask (mask_value)
    priority (prio_value) queue (queue_id)
  - remove_flex_filter (port_id) index (idx)
  - get_flex_filter (port_id) index (idx)
New command is added for flex filter by using filter_ctrl API and new flex filter structure:
  - flex_filter (port_id) (add|del) len (len_value) bytes (bytes_value) mask (mask_value)
    priority (prio_value) queue (queue_id)

Signed-off-by: Jingjing Wu <jingjing.wu@intel.com>
---
 app/test-pmd/cmdline.c |  239 ++++++++++++++++++------------------------------
 app/test-pmd/config.c  |   33 -------
 app/test-pmd/testpmd.h |    1 -
 3 files changed, 91 insertions(+), 182 deletions(-)

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index d37610a..ca2ff62 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -698,15 +698,10 @@ static void cmd_help_long_parsed(void *parsed_result,
 			"get_syn_filter (port_id) "
 			"    get syn filter info.\n\n"
 
-			"add_flex_filter (port_id) len (len_value) bytes (bytes_string) mask (mask_value)"
-			" priority (prio_value) queue (queue_id) index (idx)\n"
-			"    add a flex filter.\n\n"
-
-			"remove_flex_filter (port_id) index (idx)\n"
-			"    remove a flex filter.\n\n"
-
-			"get_flex_filter (port_id) index (idx)\n"
-			"    get info of a flex filter.\n\n"
+			"flex_filter (port_id) (add|del) len (len_value)"
+			" bytes (bytes_value) mask (mask_value)"
+			" priority (prio_value) queue (queue_id)\n"
+			"    Add/Del a flex filter.\n\n"
 
 			"flow_director_filter (port_id) (add|del)"
 			" flow (ip4|ip4-frag|ip6|ip6-frag)"
@@ -7828,6 +7823,7 @@ cmdline_parse_inst_t cmd_get_5tuple_filter = {
 /* *** ADD/REMOVE A flex FILTER *** */
 struct cmd_flex_filter_result {
 	cmdline_fixed_string_t filter;
+	cmdline_fixed_string_t ops;
 	uint8_t port_id;
 	cmdline_fixed_string_t len;
 	uint8_t len_value;
@@ -7839,8 +7835,6 @@ struct cmd_flex_filter_result {
 	uint8_t priority_value;
 	cmdline_fixed_string_t queue;
 	uint16_t queue_id;
-	cmdline_fixed_string_t index;
-	uint16_t index_value;
 };
 
 static int xdigit2val(unsigned char c)
@@ -7861,113 +7855,106 @@ cmd_flex_filter_parsed(void *parsed_result,
 			  __attribute__((unused)) void *data)
 {
 	int ret = 0;
-	struct rte_flex_filter filter;
+	struct rte_eth_flex_filter filter;
 	struct cmd_flex_filter_result *res = parsed_result;
 	char *bytes_ptr, *mask_ptr;
-	uint16_t len, i, j;
+	uint16_t len, i, j = 0;
 	char c;
-	int val, mod = 0;
-	uint32_t dword = 0;
+	int val;
 	uint8_t byte = 0;
-	uint8_t hex = 0;
 
-	if (!strcmp(res->filter, "add_flex_filter")) {
-		if (res->len_value > 128) {
-			printf("the len exceed the max length 128\n");
-			return;
-		}
-		memset(&filter, 0, sizeof(struct rte_flex_filter));
-		filter.len = res->len_value;
-		filter.priority = res->priority_value;
-		bytes_ptr = res->bytes_value;
-		mask_ptr = res->mask_value;
-
-		j = 0;
-		 /* translate bytes string to uint_32 array. */
-		if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
-			(bytes_ptr[1] == 'X')))
-			bytes_ptr += 2;
-		len = strnlen(bytes_ptr, res->len_value * 2);
-		if (len == 0 || (len % 8 != 0)) {
-			printf("please check len and bytes input\n");
+	if (res->len_value > RTE_FLEX_FILTER_MAXLEN) {
+		printf("the len exceed the max length 128\n");
+		return;
+	}
+	memset(&filter, 0, sizeof(struct rte_eth_flex_filter));
+	filter.len = res->len_value;
+	filter.priority = res->priority_value;
+	filter.queue = res->queue_id;
+	bytes_ptr = res->bytes_value;
+	mask_ptr = res->mask_value;
+
+	 /* translate bytes string to array. */
+	if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') ||
+		(bytes_ptr[1] == 'X')))
+		bytes_ptr += 2;
+	len = strnlen(bytes_ptr, res->len_value * 2);
+	if (len == 0 || (len % 8 != 0)) {
+		printf("please check len and bytes input\n");
+		return;
+	}
+	for (i = 0; i < len; i++) {
+		c = bytes_ptr[i];
+		if (isxdigit(c) == 0) {
+			/* invalid characters. */
+			printf("invalid input\n");
 			return;
 		}
-		for (i = 0; i < len; i++) {
-			c = bytes_ptr[i];
-			if (isxdigit(c) == 0) {
-				/* invalid characters. */
-				printf("invalid input\n");
-				return;
-			}
-			val = xdigit2val(c);
-			mod = i % 8;
-			if (i % 2) {
-				byte |= val;
-				dword |= byte << (4 * mod - 4);
-				byte = 0;
-			} else
-				byte |= val << 4;
-			if (mod == 7) {
-				filter.dwords[j] = dword;
-				printf("dwords[%d]:%08x ", j, filter.dwords[j]);
-				j++;
-				dword = 0;
-			}
-		}
-		printf("\n");
-		 /* translate mask string to uint8_t array. */
-		j = 0;
-		if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
-			(mask_ptr[1] == 'X')))
-			mask_ptr += 2;
-		len = strnlen(mask_ptr, (res->len_value+3)/4);
-		if (len == 0) {
+		val = xdigit2val(c);
+		if (i % 2) {
+			byte |= val;
+			filter.bytes[j] = byte;
+			printf("bytes[%d]:%02x ", j, filter.bytes[j]);
+			j++;
+			byte = 0;
+		} else
+			byte |= val << 4;
+	}
+	printf("\n");
+	 /* translate mask string to uint8_t array. */
+	if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') ||
+		(mask_ptr[1] == 'X')))
+		mask_ptr += 2;
+	len = strnlen(mask_ptr, (res->len_value + 3) / 4);
+	if (len == 0) {
+		printf("invalid input\n");
+		return;
+	}
+	j = 0;
+	byte = 0;
+	for (i = 0; i < len; i++) {
+		c = mask_ptr[i];
+		if (isxdigit(c) == 0) {
+			/* invalid characters. */
 			printf("invalid input\n");
 			return;
 		}
-		for (i = 0; i < len; i++) {
-			c = mask_ptr[i];
-			if (isxdigit(c) == 0) {
-				/* invalid characters. */
-				printf("invalid input\n");
-				return;
-			}
-			val = xdigit2val(c);
-			hex |= (uint8_t)(val & 0x8) >> 3;
-			hex |= (uint8_t)(val & 0x4) >> 1;
-			hex |= (uint8_t)(val & 0x2) << 1;
-			hex |= (uint8_t)(val & 0x1) << 3;
-			if (i % 2) {
-				byte |= hex << 4;
-				filter.mask[j] = byte;
-				printf("mask[%d]:%02x ", j, filter.mask[j]);
-				j++;
-				byte = 0;
-			} else
-				byte |= hex;
-			hex = 0;
-		}
-		printf("\n");
-		printf("call function rte_eth_dev_add_flex_filter: "
-			"index = %d, queue-id = %d, len = %d, priority = %d\n",
-			res->index_value, res->queue_id,
-			filter.len, filter.priority);
-		ret = rte_eth_dev_add_flex_filter(res->port_id, res->index_value,
-				&filter, res->queue_id);
+		val = xdigit2val(c);
+		if (i % 2) {
+			byte |= val;
+			filter.mask[j] = byte;
+			printf("mask[%d]:%02x ", j, filter.mask[j]);
+			j++;
+			byte = 0;
+		} else
+			byte |= val << 4;
+	}
+	printf("\n");
 
-	} else if (!strcmp(res->filter, "remove_flex_filter"))
-		ret = rte_eth_dev_remove_flex_filter(res->port_id,
-			res->index_value);
-	else if (!strcmp(res->filter, "get_flex_filter"))
-		get_flex_filter(res->port_id, res->index_value);
+	if (!strcmp(res->ops, "add"))
+		ret = rte_eth_dev_filter_ctrl(res->port_id,
+				RTE_ETH_FILTER_FLEXIBLE,
+				RTE_ETH_FILTER_ADD,
+				&filter);
+	else
+		ret = rte_eth_dev_filter_ctrl(res->port_id,
+				RTE_ETH_FILTER_FLEXIBLE,
+				RTE_ETH_FILTER_DELETE,
+				&filter);
 
 	if (ret < 0)
 		printf("flex filter setting error: (%s)\n", strerror(-ret));
 }
 
+cmdline_parse_token_string_t cmd_flex_filter_filter =
+	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
+				filter, "flex_filter");
 cmdline_parse_token_num_t cmd_flex_filter_port_id =
 	TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
 				port_id, UINT8);
+cmdline_parse_token_string_t cmd_flex_filter_ops =
+	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
+				ops, "add#del");
 cmdline_parse_token_string_t cmd_flex_filter_len =
 	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
 				len, "len");
@@ -7998,22 +7985,14 @@ cmdline_parse_token_string_t cmd_flex_filter_queue =
 cmdline_parse_token_num_t cmd_flex_filter_queue_id =
 	TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
 				queue_id, UINT16);
-cmdline_parse_token_string_t cmd_flex_filter_index =
-	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
-				index, "index");
-cmdline_parse_token_num_t cmd_flex_filter_index_value =
-	TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result,
-				index_value, UINT16);
-cmdline_parse_token_string_t cmd_flex_filter_add_filter =
-	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
-				filter, "add_flex_filter");
-cmdline_parse_inst_t cmd_add_flex_filter = {
+cmdline_parse_inst_t cmd_flex_filter = {
 	.f = cmd_flex_filter_parsed,
 	.data = NULL,
-	.help_str = "add a flex filter",
+	.help_str = "add/del a flex filter",
 	.tokens = {
-		(void *)&cmd_flex_filter_add_filter,
+		(void *)&cmd_flex_filter_filter,
 		(void *)&cmd_flex_filter_port_id,
+		(void *)&cmd_flex_filter_ops,
 		(void *)&cmd_flex_filter_len,
 		(void *)&cmd_flex_filter_len_value,
 		(void *)&cmd_flex_filter_bytes,
@@ -8024,40 +8003,6 @@ cmdline_parse_inst_t cmd_add_flex_filter = {
 		(void *)&cmd_flex_filter_priority_value,
 		(void *)&cmd_flex_filter_queue,
 		(void *)&cmd_flex_filter_queue_id,
-		(void *)&cmd_flex_filter_index,
-		(void *)&cmd_flex_filter_index_value,
-		NULL,
-	},
-};
-
-cmdline_parse_token_string_t cmd_flex_filter_remove_filter =
-	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
-				filter, "remove_flex_filter");
-cmdline_parse_inst_t cmd_remove_flex_filter = {
-	.f = cmd_flex_filter_parsed,
-	.data = NULL,
-	.help_str = "remove a flex filter",
-	.tokens = {
-		(void *)&cmd_flex_filter_remove_filter,
-		(void *)&cmd_flex_filter_port_id,
-		(void *)&cmd_flex_filter_index,
-		(void *)&cmd_flex_filter_index_value,
-		NULL,
-	},
-};
-
-cmdline_parse_token_string_t cmd_flex_filter_get_filter =
-	TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result,
-				filter, "get_flex_filter");
-cmdline_parse_inst_t cmd_get_flex_filter = {
-	.f = cmd_flex_filter_parsed,
-	.data = NULL,
-	.help_str = "get a flex filter",
-	.tokens = {
-		(void *)&cmd_flex_filter_get_filter,
-		(void *)&cmd_flex_filter_port_id,
-		(void *)&cmd_flex_filter_index,
-		(void *)&cmd_flex_filter_index_value,
 		NULL,
 	},
 };
@@ -9214,9 +9159,7 @@ cmdline_parse_ctx_t main_ctx[] = {
 	(cmdline_parse_inst_t *)&cmd_add_5tuple_filter,
 	(cmdline_parse_inst_t *)&cmd_remove_5tuple_filter,
 	(cmdline_parse_inst_t *)&cmd_get_5tuple_filter,
-	(cmdline_parse_inst_t *)&cmd_add_flex_filter,
-	(cmdline_parse_inst_t *)&cmd_remove_flex_filter,
-	(cmdline_parse_inst_t *)&cmd_get_flex_filter,
+	(cmdline_parse_inst_t *)&cmd_flex_filter,
 	(cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director,
 	(cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director,
 	(cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director,
diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c
index 6bcd23c..a48aa5c 100644
--- a/app/test-pmd/config.c
+++ b/app/test-pmd/config.c
@@ -2257,36 +2257,3 @@ get_5tuple_filter(uint8_t port_id, uint16_t index)
 			filter.priority, filter.tcp_flags, rx_queue);
 	}
 }
-void
-get_flex_filter(uint8_t port_id, uint16_t index)
-
-{
-	struct rte_flex_filter filter;
-	int ret = 0;
-	uint16_t rx_queue;
-	int i, j;
-
-	memset(&filter, 0, sizeof(filter));
-	ret = rte_eth_dev_get_flex_filter(port_id, index,
-				&filter, &rx_queue);
-	if (ret < 0) {
-		if (ret == (-ENOENT))
-			printf("filter[%d] is not enabled\n", index);
-		else
-			printf("get flex filter fails(%s)\n", strerror(-ret));
-		return;
-	} else {
-		printf("filter[%d]: ", index);
-		printf("\n    length: %d", filter.len);
-		printf("\n    dword[]: 0x");
-		for (i = 0; i < 32; i++)
-			printf("%08x ", (unsigned)rte_be_to_cpu_32(filter.dwords[i]));
-		printf("\n    mask[]: 0b");
-		for (i = 0; i < 16; i++) {
-			for (j = 0; j < 8; j++)
-				printf("%c", (filter.mask[i] & (1 << j)) ? '1' : '0');
-		}
-		printf("\n    priority: %d    queue: %d\n",
-			filter.priority, rx_queue);
-	}
-}
diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h
index 581130b..1bfaeea 100644
--- a/app/test-pmd/testpmd.h
+++ b/app/test-pmd/testpmd.h
@@ -564,7 +564,6 @@ void get_syn_filter(uint8_t port_id);
 void get_ethertype_filter(uint8_t port_id, uint16_t index);
 void get_2tuple_filter(uint8_t port_id, uint16_t index);
 void get_5tuple_filter(uint8_t port_id, uint16_t index);
-void get_flex_filter(uint8_t port_id, uint16_t index);
 int port_id_is_invalid(portid_t port_id);
 int rx_queue_id_is_invalid(queueid_t rxq_id);
 int tx_queue_id_is_invalid(queueid_t txq_id);
-- 
1.7.4.1

  parent reply	other threads:[~2015-02-21  1:53 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <igbv1>
2015-01-30  4:48 ` [dpdk-dev] [PATCH] igb: integrate flex filter to new API zhida zang
2015-02-15  4:07   ` [dpdk-dev] [PATCH v2 0/5] Integrate flex filter in igb driver " Jingjing Wu
2015-02-15  4:07     ` [dpdk-dev] [PATCH v2 1/5] ethdev: define flex filter type and its structure Jingjing Wu
2015-02-15  4:07     ` [dpdk-dev] [PATCH v2 2/5] e1000: new functions replace old ones for flex filter Jingjing Wu
2015-02-15  4:07     ` [dpdk-dev] [PATCH v2 3/5] testpmd: new commands " Jingjing Wu
2015-02-15  4:07     ` [dpdk-dev] [PATCH v2 4/5] ethdev: remove old APIs and structures of " Jingjing Wu
2015-02-15  4:07     ` [dpdk-dev] [PATCH v2 5/5] doc: commands changed in testpmd_funcs for " Jingjing Wu
2015-02-21  1:53     ` [dpdk-dev] [PATCH v3 0/5] Integrate flex filter in igb driver to new API Pablo de Lara
2015-02-21  1:53       ` [dpdk-dev] [PATCH v3 1/5] ethdev: define flex filter type and its structure Pablo de Lara
2015-02-21  1:53       ` [dpdk-dev] [PATCH v3 2/5] e1000: new functions replace old ones for flex filter Pablo de Lara
2015-02-21  1:53       ` Pablo de Lara [this message]
2015-02-21  1:53       ` [dpdk-dev] [PATCH v3 4/5] ethdev: remove old APIs and structures of " Pablo de Lara
2015-02-21  1:53       ` [dpdk-dev] [PATCH v3 5/5] doc: commands changed in testpmd_funcs for " Pablo de Lara
2015-02-22  1:29       ` [dpdk-dev] [PATCH v3 0/5] Integrate flex filter in igb driver to new API 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=1424483591-25944-4-git-send-email-pablo.de.lara.guarch@intel.com \
    --to=pablo.de.lara.guarch@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).