DPDK patches and discussions
 help / color / mirror / Atom feed
From: Helin Zhang <helin.zhang@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH v6 3/3] app/testpmd: add commands to support hash functions
Date: Wed, 19 Nov 2014 22:58:16 +0800
Message-ID: <1416409096-1340-4-git-send-email-helin.zhang@intel.com> (raw)
In-Reply-To: <1416409096-1340-1-git-send-email-helin.zhang@intel.com>

To demonstrate the hash filter control, commands are added.
They are,
- get_sym_hash_ena_per_port
- set_sym_hash_ena_per_port
- get_sym_hash_ena_per_pctype
- set_sym_hash_ena_per_pctype
- get_filter_swap
- set_filter_swap
- get_hash_function
- set_hash_function

Signed-off-by: Helin Zhang <helin.zhang@intel.com>
---
 app/test-pmd/cmdline.c | 628 +++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 628 insertions(+)

v6 changes:
* Flow type strings are used to replace Packet Classification
  Types, to isolate hardware specific things.

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 4c3fc76..ce1547d 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -74,6 +74,7 @@
 #include <rte_ethdev.h>
 #include <rte_string_fns.h>
 #include <rte_devargs.h>
+#include <rte_eth_ctrl.h>
 
 #include <cmdline_rdline.h>
 #include <cmdline_parse.h>
@@ -683,6 +684,44 @@ static void cmd_help_long_parsed(void *parsed_result,
 
 			"get_flex_filter (port_id) index (idx)\n"
 			"    get info of a flex filter.\n\n"
+
+			"get_sym_hash_ena_per_port (port_id)\n"
+			"    get symmetric hash enable configuration per port.\n\n"
+
+			"set_sym_hash_ena_per_port (port_id)"
+			" (enable|disable)\n"
+			"    set symmetric hash enable configuration per port"
+			" to enable or disable.\n\n"
+
+			"get_sym_hash_ena_per_flow_type (port_id) (ipv4-udp|"
+			"ipv4-tcp|ipv4-sctp|ipv4-other|ipv4-frag|ipv6-udp|"
+			"ipv6-tcp|ipv6-sctp|ipv6-other|ipv6-frag|l2_payload)\n"
+			"    get symmetric hash enable configuration per flow type.\n\n"
+
+			"set_sym_hash_ena_per_flow_type (port_id) (ipv4-udp|"
+			"ipv4-tcp|ipv4-sctp|ipv4-other|ipv4-frag|ipv6-udp|"
+			"ipv6-tcp|ipv6-sctp|ipv6-other|ipv6-frag|l2_payload) "
+			"(enable|disable)\n"
+			"    set symmetric hash enable configuration per"
+			" flow type to enable or disable.\n\n"
+
+			"get_filter_swap (port_id) (ipv4-udp|ipv4-tcp|"
+			"ipv4-sctp|ipv4-other|ipv4-frag|ipv6-udp|ipv6-tcp|"
+			"ipv6-sctp|ipv6-other|ipv6-frag|l2_payload)\n"
+			"    get filter swap configurations.\n\n"
+
+			"set_filter_swap (port_id) (ipv4-udp|ipv4-tcp|"
+			"ipv4-sctp|ipv4-other|ipv4-frag|ipv6-udp|ipv6-tcp|"
+			"ipv6-sctp|ipv6-other|ipv6-frag|l2_payload) "
+			"(off0_src0) (off0_src1) (len0) (off1_src0) "
+			"(off1_src1) (len1)\n"
+			"    set filter swap configurations.\n\n"
+
+			"get_hash_function (port_id)\n"
+			"    get hash function of Toeplitz or Simple XOR.\n\n"
+
+			"set_hash_function (port_id) (toeplitz|simple_xor)\n"
+			"    set the hash function to Toeplitz or Simple XOR.\n\n"
 		);
 	}
 }
@@ -7745,6 +7784,587 @@ cmdline_parse_inst_t cmd_get_flex_filter = {
 	},
 };
 
+/* *** Classification Filters Control *** */
+static uint8_t
+parse_flow_type(const char *str)
+{
+	struct flow_type_pair {
+		char str[STR_TOKEN_SIZE];
+		uint8_t flow_type;
+	};
+	uint32_t i;
+	static const struct flow_type_pair ftype[] = {
+		{"ipv4-udp",   ETH_RSS_NONF_IPV4_UDP_SHIFT},
+		{"ipv4-tcp",   ETH_RSS_NONF_IPV4_TCP_SHIFT},
+		{"ipv4-sctp",  ETH_RSS_NONF_IPV4_SCTP_SHIFT},
+		{"ipv4-other", ETH_RSS_NONF_IPV4_OTHER_SHIFT},
+		{"ipv4-frag",  ETH_RSS_FRAG_IPV4_SHIFT},
+		{"ipv6-udp",   ETH_RSS_NONF_IPV6_UDP_SHIFT},
+		{"ipv6-tcp",   ETH_RSS_NONF_IPV6_TCP_SHIFT},
+		{"ipv6-sctp",  ETH_RSS_NONF_IPV6_SCTP_SHIFT},
+		{"ipv6-other", ETH_RSS_NONF_IPV6_OTHER_SHIFT},
+		{"ipv6-frag",  ETH_RSS_FRAG_IPV6_SHIFT},
+		{"l2_payload", ETH_RSS_L2_PAYLOAD_SHIFT},
+	};
+
+	if (!str)
+		return 0xFF;
+
+	for (i = 0; i < RTE_DIM(ftype); i++) {
+		if (!strcmp(ftype[i].str, str))
+			return ftype[i].flow_type;
+	}
+
+	return 0xFF;
+}
+
+/* *** Get symmetric hash enable per port *** */
+struct cmd_get_sym_hash_ena_per_port_result {
+	cmdline_fixed_string_t get_sym_hash_ena_per_port;
+	uint8_t port_id;
+};
+
+static void
+cmd_get_sym_hash_per_port_parsed(void *parsed_result,
+				 __rte_unused struct cmdline *cl,
+				 __rte_unused void *data)
+{
+	struct cmd_get_sym_hash_ena_per_port_result *res = parsed_result;
+	struct rte_eth_hash_filter_info info;
+	int ret;
+
+	if (rte_eth_dev_filter_supported(res->port_id,
+				RTE_ETH_FILTER_HASH) < 0) {
+		printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
+							res->port_id);
+		return;
+	}
+
+	memset(&info, 0, sizeof(info));
+	info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
+	ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
+						RTE_ETH_FILTER_GET, &info);
+	if (ret < 0) {
+		printf("Cannot get symmetric hash enable per port "
+					"on port %u\n", res->port_id);
+		return;
+	}
+
+	printf("Symmetric hash is %s on port %u\n", info.info.enable ?
+				"enabled" : "disabled", res->port_id);
+}
+
+cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_port_all =
+	TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
+		get_sym_hash_ena_per_port, "get_sym_hash_ena_per_port");
+cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_port_port_id =
+	TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_port_result,
+		port_id, UINT8);
+
+cmdline_parse_inst_t cmd_get_sym_hash_ena_per_port = {
+	.f = cmd_get_sym_hash_per_port_parsed,
+	.data = NULL,
+	.help_str = "get_sym_hash_ena_per_port port_id",
+	.tokens = {
+		(void *)&cmd_get_sym_hash_ena_per_port_all,
+		(void *)&cmd_get_sym_hash_ena_per_port_port_id,
+		NULL,
+	},
+};
+
+/* *** Set symmetric hash enable per port *** */
+struct cmd_set_sym_hash_ena_per_port_result {
+	cmdline_fixed_string_t set_sym_hash_ena_per_port;
+	cmdline_fixed_string_t enable;
+	uint8_t port_id;
+};
+
+static void
+cmd_set_sym_hash_per_port_parsed(void *parsed_result,
+				 __rte_unused struct cmdline *cl,
+				 __rte_unused void *data)
+{
+	struct cmd_set_sym_hash_ena_per_port_result *res = parsed_result;
+	struct rte_eth_hash_filter_info info;
+	int ret;
+
+	if (rte_eth_dev_filter_supported(res->port_id,
+				RTE_ETH_FILTER_HASH) < 0) {
+		printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
+							res->port_id);
+		return;
+	}
+
+	memset(&info, 0, sizeof(info));
+	info.info_type = RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_PORT;
+	if (!strcmp(res->enable, "enable"))
+		info.info.enable = 1;
+	ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
+						RTE_ETH_FILTER_SET, &info);
+	if (ret < 0) {
+		printf("Cannot set symmetric hash enable per port on "
+					"port %u\n", res->port_id);
+		return;
+	}
+
+	printf("Symmetric hash has been set to %s on port %u\n",
+					res->enable, res->port_id);
+}
+
+cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_all =
+	TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
+		set_sym_hash_ena_per_port, "set_sym_hash_ena_per_port");
+cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_port_port_id =
+	TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
+		port_id, UINT8);
+cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_port_enable =
+	TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_port_result,
+		enable, "enable#disable");
+
+cmdline_parse_inst_t cmd_set_sym_hash_ena_per_port = {
+	.f = cmd_set_sym_hash_per_port_parsed,
+	.data = NULL,
+	.help_str = "set_sym_hash_ena_per_port port_id enable|disable",
+	.tokens = {
+		(void *)&cmd_set_sym_hash_ena_per_port_all,
+		(void *)&cmd_set_sym_hash_ena_per_port_port_id,
+		(void *)&cmd_set_sym_hash_ena_per_port_enable,
+		NULL,
+	},
+};
+
+/* *** Get symmetric hash enable per flow_type *** */
+struct cmd_get_sym_hash_ena_per_flow_type_result {
+	cmdline_fixed_string_t get_sym_hash_ena_per_flow_type;
+	uint8_t port_id;
+	cmdline_fixed_string_t flow_type;
+};
+
+static void
+cmd_get_sym_hash_per_flow_type_parsed(void *parsed_result,
+				      __rte_unused struct cmdline *cl,
+				      __rte_unused void *data)
+{
+	struct cmd_get_sym_hash_ena_per_flow_type_result *res = parsed_result;
+	struct rte_eth_hash_filter_info info;
+	int ret;
+
+	if (rte_eth_dev_filter_supported(res->port_id,
+				RTE_ETH_FILTER_HASH) < 0) {
+		printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
+							res->port_id);
+		return;
+	}
+
+	memset(&info, 0, sizeof(info));
+	info.info_type =
+		RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_FLOW_TYPE;
+	info.info.sym_hash_ena.flow_type = parse_flow_type(res->flow_type);
+	ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
+						RTE_ETH_FILTER_GET, &info);
+	if (ret < 0) {
+		printf("Cannot get symmetric hash enable per flow_type on "
+						"port %u, flow_type %s\n",
+						res->port_id, res->flow_type);
+		return;
+	}
+	printf("Symmetric hash is %s on port %u, flow_type %s\n",
+			info.info.sym_hash_ena.enable ? "enabled" :
+			"disabled", res->port_id, res->flow_type);
+}
+
+cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_flow_type_all =
+	TOKEN_STRING_INITIALIZER(
+		struct cmd_get_sym_hash_ena_per_flow_type_result,
+			get_sym_hash_ena_per_flow_type,
+			"get_sym_hash_ena_per_flow_type");
+cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_flow_type_port_id =
+	TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_flow_type_result,
+		port_id, UINT8);
+cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_flow_type_flow_type =
+	TOKEN_STRING_INITIALIZER(
+		struct cmd_get_sym_hash_ena_per_flow_type_result, flow_type,
+		"ipv4-udp#ipv4-tcp#ipv4-sctp#ipv4-other#ipv4-frag#ipv6-udp#"
+		"ipv6-tcp#ipv6-sctp#ipv6-other#ipv6-frag#l2_payload");
+
+cmdline_parse_inst_t cmd_get_sym_hash_ena_per_flow_type = {
+	.f = cmd_get_sym_hash_per_flow_type_parsed,
+	.data = NULL,
+	.help_str = "get_sym_hash_ena_per_flow_type port_id ipv4-udp|ipv4-tcp|"
+		"ipv4-sctp|ipv4-other|ipv4-frag|ipv6-udp|ipv6-tcp|ipv6-sctp|"
+		"ipv6-other|ipv6-frag|l2_payload",
+	.tokens = {
+		(void *)&cmd_get_sym_hash_ena_per_flow_type_all,
+		(void *)&cmd_get_sym_hash_ena_per_flow_type_port_id,
+		(void *)&cmd_get_sym_hash_ena_per_flow_type_flow_type,
+		NULL,
+	},
+};
+
+/* *** Set symmetric hash enable per flow_type *** */
+struct cmd_set_sym_hash_ena_per_flow_type_result {
+	cmdline_fixed_string_t set_sym_hash_ena_per_flow_type;
+	cmdline_fixed_string_t enable;
+	uint8_t port_id;
+	cmdline_fixed_string_t flow_type;
+};
+
+static void
+cmd_set_sym_hash_per_flow_type_parsed(void *parsed_result,
+				      __rte_unused struct cmdline *cl,
+				      __rte_unused void *data)
+{
+	struct cmd_set_sym_hash_ena_per_flow_type_result *res = parsed_result;
+	struct rte_eth_hash_filter_info info;
+	int ret;
+
+	if (rte_eth_dev_filter_supported(res->port_id,
+				RTE_ETH_FILTER_HASH) < 0) {
+		printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
+							res->port_id);
+		return;
+	}
+
+	memset(&info, 0, sizeof(info));
+	info.info_type =
+		RTE_ETH_HASH_FILTER_SYM_HASH_ENA_PER_FLOW_TYPE;
+	info.info.sym_hash_ena.flow_type = parse_flow_type(res->flow_type);
+	if (!strcmp(res->enable, "enable"))
+		info.info.sym_hash_ena.enable = 1;
+	ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
+						RTE_ETH_FILTER_SET, &info);
+	if (ret < 0) {
+		printf("Cannot set symmetric hash enable per flow_type to %s "
+			"on port %u, flow_type %s\n", res->enable ? "enabled" :
+				"disabled", res->port_id, res->flow_type);
+		return;
+	}
+	printf("Symmetic hash has been set to %s on port %u, flow_type %s\n",
+				res->enable, res->port_id, res->flow_type);
+}
+
+cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_flow_type_all =
+	TOKEN_STRING_INITIALIZER(
+		struct cmd_set_sym_hash_ena_per_flow_type_result,
+				set_sym_hash_ena_per_flow_type,
+				"set_sym_hash_ena_per_flow_type");
+cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_flow_type_port_id =
+	TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_flow_type_result,
+		port_id, UINT8);
+cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_flow_type_flow_type =
+	TOKEN_STRING_INITIALIZER(
+		struct cmd_set_sym_hash_ena_per_flow_type_result, flow_type,
+		"ipv4-udp#ipv4-tcp#ipv4-sctp#ipv4-other#ipv4-frag#ipv6-udp#"
+		"ipv6-tcp#ipv6-sctp#ipv6-other#ipv6-frag#l2_payload");
+cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_flow_type_enable =
+	TOKEN_STRING_INITIALIZER(
+		struct cmd_set_sym_hash_ena_per_flow_type_result,
+		enable, "enable#disable");
+
+cmdline_parse_inst_t cmd_set_sym_hash_ena_per_flow_type = {
+	.f = cmd_set_sym_hash_per_flow_type_parsed,
+	.data = NULL,
+	.help_str = "set_sym_hash_ena_per_flow_type pord_id ipv4-udp|ipv4-tcp|"
+		"ipv4-sctp|ipv4-other|ipv4-frag|ipv6-udp|ipv6-tcp|ipv6-sctp|"
+		"ipv6-other|ipv6-frag|l2_payload enable|disable",
+	.tokens = {
+		(void *)&cmd_set_sym_hash_ena_per_flow_type_all,
+		(void *)&cmd_set_sym_hash_ena_per_flow_type_port_id,
+		(void *)&cmd_set_sym_hash_ena_per_flow_type_flow_type,
+		(void *)&cmd_set_sym_hash_ena_per_flow_type_enable,
+		NULL,
+	},
+};
+
+/* *** Get filter swap *** */
+struct cmd_get_filter_swap_result {
+	cmdline_fixed_string_t get_filter_swap;
+	uint8_t port_id;
+	cmdline_fixed_string_t flow_type;
+};
+
+static void
+cmd_get_filter_swap_parsed(void *parsed_result,
+			   __rte_unused struct cmdline *cl,
+			   __rte_unused void *data)
+{
+	struct cmd_get_filter_swap_result *res = parsed_result;
+	struct rte_eth_hash_filter_info info;
+	int ret;
+
+	if (rte_eth_dev_filter_supported(res->port_id,
+				RTE_ETH_FILTER_HASH) < 0) {
+		printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
+							res->port_id);
+		return;
+	}
+
+	memset(&info, 0, sizeof(info));
+	info.info_type = RTE_ETH_HASH_FILTER_SWAP;
+	info.info.filter_swap.flow_type = parse_flow_type(res->flow_type);
+	ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
+						RTE_ETH_FILTER_GET, &info);
+	if (ret < 0) {
+		printf("Cannot get filter swap on port %u, flow_type %s\n",
+					res->port_id, res->flow_type);
+		return;
+	}
+	printf("Filter swap of port %u, flow_type %s is configured as:\n"
+		"off0_src0: 0x%02x, off0_src1: 0x%02x, len0: 0x%02x\n"
+		"off1_src0: 0x%02x, off1_src1: 0x%02x, len1: 0x%02x\n",
+		res->port_id, res->flow_type, info.info.filter_swap.off0_src0,
+		info.info.filter_swap.off0_src1, info.info.filter_swap.len0,
+		info.info.filter_swap.off1_src0,
+		info.info.filter_swap.off1_src1, info.info.filter_swap.len1);
+}
+
+cmdline_parse_token_string_t cmd_get_filter_swap_all =
+	TOKEN_STRING_INITIALIZER(struct cmd_get_filter_swap_result,
+		get_filter_swap, "get_filter_swap");
+cmdline_parse_token_num_t cmd_get_filter_swap_port_id =
+	TOKEN_NUM_INITIALIZER(struct cmd_get_filter_swap_result,
+		port_id, UINT8);
+cmdline_parse_token_string_t cmd_get_filter_swap_flow_type =
+	TOKEN_STRING_INITIALIZER(struct cmd_get_filter_swap_result, flow_type,
+		"ipv4-udp#ipv4-tcp#ipv4-sctp#ipv4-other#ipv4-frag#ipv6-udp#"
+		"ipv6-tcp#ipv6-sctp#ipv6-other#ipv6-frag#l2_payload");
+
+cmdline_parse_inst_t cmd_get_filter_swap = {
+	.f = cmd_get_filter_swap_parsed,
+	.data = NULL,
+	.help_str = "get_filter_swap port_id ipv4-udp|ipv4-tcp|ipv4-sctp|"
+		"ipv4-other|ipv4-frag|ipv6-udp|ipv6-tcp|ipv6-sctp|ipv6-other|"
+		"ipv6-frag|l2_payload",
+	.tokens = {
+		(void *)&cmd_get_filter_swap_all,
+		(void *)&cmd_get_filter_swap_port_id,
+		(void *)&cmd_get_filter_swap_flow_type,
+		NULL,
+	},
+};
+
+/* *** Set filter swap *** */
+struct cmd_set_filter_swap_result {
+	cmdline_fixed_string_t set_filter_swap;
+	uint8_t port_id;
+	cmdline_fixed_string_t flow_type;
+	uint8_t off0_src0;
+	uint8_t off0_src1;
+	uint8_t len0;
+	uint8_t off1_src0;
+	uint8_t off1_src1;
+	uint8_t len1;
+};
+
+static void
+cmd_set_filter_swap_parsed(void *parsed_result,
+			   __rte_unused struct cmdline *cl,
+			   __rte_unused void *data)
+{
+	struct cmd_set_filter_swap_result *res = parsed_result;
+	struct rte_eth_hash_filter_info info;
+	int ret;
+
+	if (rte_eth_dev_filter_supported(res->port_id,
+				RTE_ETH_FILTER_HASH) < 0) {
+		printf("RTE_ETH_FILTER_HASH not supported on port: %d\n",
+							res->port_id);
+		return;
+	}
+
+	memset(&info, 0, sizeof(info));
+	info.info_type = RTE_ETH_HASH_FILTER_SWAP;
+	info.info.filter_swap.flow_type = parse_flow_type(res->flow_type);
+	info.info.filter_swap.off0_src0 = res->off0_src0;
+	info.info.filter_swap.off0_src1 = res->off0_src1;
+	info.info.filter_swap.len0 = res->len0;
+	info.info.filter_swap.off1_src0 = res->off1_src0;
+	info.info.filter_swap.off1_src1 = res->off1_src1;
+	info.info.filter_swap.len1 = res->len1;
+	ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
+						RTE_ETH_FILTER_SET, &info);
+	if (ret < 0) {
+		printf("Cannot set filter swap on port %u, flow_type %s\n",
+					res->port_id, res->flow_type);
+		return;
+	}
+	printf("Filter swap of port %u, flow_type %s has been set as:\n"
+		"off0_src0: 0x%02x, off0_src1: 0x%02x, len0: 0x%02x\n"
+		"off1_src0: 0x%02x, off1_src1: 0x%02x, len1: 0x%02x\n",
+		res->port_id, res->flow_type, info.info.filter_swap.off0_src0,
+		info.info.filter_swap.off0_src1, info.info.filter_swap.len0,
+		info.info.filter_swap.off1_src0,
+		info.info.filter_swap.off1_src1, info.info.filter_swap.len1);
+}
+
+cmdline_parse_token_string_t cmd_set_filter_swap_all =
+	TOKEN_STRING_INITIALIZER(struct cmd_set_filter_swap_result,
+		set_filter_swap, "set_filter_swap");
+cmdline_parse_token_num_t cmd_set_filter_swap_port_id =
+	TOKEN_NUM_INITIALIZER(struct cmd_set_filter_swap_result,
+		port_id, UINT8);
+cmdline_parse_token_string_t cmd_set_filter_swap_flow_type =
+	TOKEN_STRING_INITIALIZER(struct cmd_set_filter_swap_result, flow_type,
+		"ipv4-udp#ipv4-tcp#ipv4-sctp#ipv4-other#ipv4-frag#ipv6-udp#"
+		"ipv6-tcp#ipv6-sctp#ipv6-other#ipv6-frag#l2_payload");
+cmdline_parse_token_num_t cmd_set_filter_swap_off0_src0 =
+	TOKEN_NUM_INITIALIZER(struct cmd_set_filter_swap_result,
+		off0_src0, UINT8);
+cmdline_parse_token_num_t cmd_set_filter_swap_off0_src1 =
+	TOKEN_NUM_INITIALIZER(struct cmd_set_filter_swap_result,
+		off0_src1, UINT8);
+cmdline_parse_token_num_t cmd_set_filter_swap_len0 =
+	TOKEN_NUM_INITIALIZER(struct cmd_set_filter_swap_result,
+		len0, UINT8);
+cmdline_parse_token_num_t cmd_set_filter_swap_off1_src0 =
+	TOKEN_NUM_INITIALIZER(struct cmd_set_filter_swap_result,
+		off1_src0, UINT8);
+cmdline_parse_token_num_t cmd_set_filter_swap_off1_src1 =
+	TOKEN_NUM_INITIALIZER(struct cmd_set_filter_swap_result,
+		off1_src1, UINT8);
+cmdline_parse_token_num_t cmd_set_filter_swap_len1 =
+	TOKEN_NUM_INITIALIZER(struct cmd_set_filter_swap_result,
+		len1, UINT8);
+
+cmdline_parse_inst_t cmd_set_filter_swap = {
+	.f = cmd_set_filter_swap_parsed,
+	.data = NULL,
+	.help_str = "set_filter_swap port_id ipv4-udp|ipv4-tcp|ipv4-sctp|"
+		"ipv4-other|ipv4-frag|ipv6-udp|ipv6-tcp|ipv6-sctp|ipv6-other|"
+		"ipv6-frag|l2_payload off0_src0 off0_src1 len0 off1_src0 "
+		"off1_src1 len1",
+	.tokens = {
+		(void *)&cmd_set_filter_swap_all,
+		(void *)&cmd_set_filter_swap_port_id,
+		(void *)&cmd_set_filter_swap_flow_type,
+		(void *)&cmd_set_filter_swap_off0_src0,
+		(void *)&cmd_set_filter_swap_off0_src1,
+		(void *)&cmd_set_filter_swap_len0,
+		(void *)&cmd_set_filter_swap_off1_src0,
+		(void *)&cmd_set_filter_swap_off1_src1,
+		(void *)&cmd_set_filter_swap_len1,
+		NULL,
+	},
+};
+
+/* Get hash function */
+struct cmd_get_hash_function_result {
+	cmdline_fixed_string_t get_hash_function;
+	uint8_t port_id;
+};
+
+static void
+cmd_get_hash_function_parsed(void *parsed_result,
+			     __rte_unused struct cmdline *cl,
+			     __rte_unused void *data)
+{
+	struct cmd_get_hash_function_result *res = parsed_result;
+	struct rte_eth_hash_filter_info info;
+	int ret;
+
+	if (rte_eth_dev_filter_supported(res->port_id,
+				RTE_ETH_FILTER_HASH) < 0) {
+		printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
+							res->port_id);
+		return;
+	}
+
+	memset(&info, 0, sizeof(info));
+	info.info_type = RTE_ETH_HASH_FILTER_HASH_FUNCTION;
+	ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
+						RTE_ETH_FILTER_GET, &info);
+	if (ret < 0) {
+		printf("Cannot get hash function on port %d\n", res->port_id);
+		return;
+	}
+	printf("Hash function is %s\n", info.info.hash_function ==
+		RTE_ETH_HASH_FUNCTION_TOEPLITZ ? "Toeplitz" : "Simple XOR");
+}
+
+cmdline_parse_token_string_t cmd_get_hash_function_all =
+	TOKEN_STRING_INITIALIZER(struct cmd_get_hash_function_result,
+		get_hash_function, "get_hash_function");
+cmdline_parse_token_num_t cmd_get_hash_function_port_id =
+	TOKEN_NUM_INITIALIZER(struct cmd_get_hash_function_result,
+		port_id, UINT8);
+
+cmdline_parse_inst_t cmd_get_hash_function = {
+	.f = cmd_get_hash_function_parsed,
+	.data = NULL,
+	.help_str = "get_hash_function port_id",
+	.tokens = {
+		(void *)&cmd_get_hash_function_all,
+		(void *)&cmd_get_hash_function_port_id,
+		NULL,
+	},
+};
+
+/* Set hash function of Hoeplitz or Simple XOR */
+struct cmd_set_hash_function_result {
+	cmdline_fixed_string_t set_hash_function;
+	uint8_t port_id;
+	cmdline_fixed_string_t hash_function;
+};
+
+static void
+cmd_set_hash_function_parsed(void *parsed_result,
+			     __rte_unused struct cmdline *cl,
+			     __rte_unused void *data)
+{
+	struct cmd_set_hash_function_result *res = parsed_result;
+	struct rte_eth_hash_filter_info info;
+	int ret;
+
+	if (rte_eth_dev_filter_supported(res->port_id,
+				RTE_ETH_FILTER_HASH) < 0) {
+		printf("RTE_ETH_FILTER_HASH not supported on port %d\n",
+							res->port_id);
+		return;
+	}
+
+	memset(&info, 0, sizeof(info));
+	info.info_type = RTE_ETH_HASH_FILTER_HASH_FUNCTION;
+	if (!strcmp(res->hash_function, "toeplitz"))
+		info.info.hash_function = RTE_ETH_HASH_FUNCTION_TOEPLITZ;
+	else if (!strcmp(res->hash_function, "simple_xor"))
+		info.info.hash_function = RTE_ETH_HASH_FUNCTION_SIMPLE_XOR;
+	else {
+		printf("Unsupported hash function %s\n", res->hash_function);
+		return;
+	}
+	ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH,
+						RTE_ETH_FILTER_SET, &info);
+	if (ret < 0) {
+		printf("Cannot set hash function to %s on port %d\n",
+				res->hash_function, res->port_id);
+		return;
+	}
+	printf("Hash function has been successfully set to %s on port %d\n",
+					res->hash_function, res->port_id);
+}
+
+cmdline_parse_token_string_t cmd_set_hash_function_all =
+	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_function_result,
+		set_hash_function, "set_hash_function");
+cmdline_parse_token_num_t cmd_set_hash_function_port_id =
+	TOKEN_NUM_INITIALIZER(struct cmd_set_hash_function_result,
+		port_id, UINT8);
+cmdline_parse_token_string_t cmd_set_hash_function_hash_function =
+	TOKEN_STRING_INITIALIZER(struct cmd_set_hash_function_result,
+		hash_function, "toeplitz#simple_xor");
+
+cmdline_parse_inst_t cmd_set_hash_function = {
+	.f = cmd_set_hash_function_parsed,
+	.data = NULL,
+	.help_str = "set_hash_function port_id toeplitz|simple_xor",
+	.tokens = {
+		(void *)&cmd_set_hash_function_all,
+		(void *)&cmd_set_hash_function_port_id,
+		(void *)&cmd_set_hash_function_hash_function,
+		NULL,
+	},
+};
+
 /* ******************************************************************************** */
 
 /* list of instructions */
@@ -7874,6 +8494,14 @@ cmdline_parse_ctx_t main_ctx[] = {
 	(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_get_sym_hash_ena_per_port,
+	(cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_port,
+	(cmdline_parse_inst_t *)&cmd_get_sym_hash_ena_per_flow_type,
+	(cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_flow_type,
+	(cmdline_parse_inst_t *)&cmd_get_filter_swap,
+	(cmdline_parse_inst_t *)&cmd_set_filter_swap,
+	(cmdline_parse_inst_t *)&cmd_set_hash_function,
+	(cmdline_parse_inst_t *)&cmd_get_hash_function,
 	NULL,
 };
 
-- 
1.8.1.4

  parent reply	other threads:[~2014-11-19 14:48 UTC|newest]

Thread overview: 71+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-30  6:20 [dpdk-dev] [PATCH v3 0/7] Support configuring " Helin Zhang
2014-09-30  6:20 ` [dpdk-dev] [PATCH v3 1/7] ethdev: add more annotations Helin Zhang
2014-10-13  6:12   ` [dpdk-dev] [PATCH v4 0/7] Support configuring hash functions Helin Zhang
2014-10-13  6:12     ` [dpdk-dev] [PATCH v4 1/7] ethdev: add more annotations Helin Zhang
2014-10-13  6:12     ` [dpdk-dev] [PATCH v4 2/7] ethdev: add interfaces and relevant for filter control Helin Zhang
2014-10-13  6:12     ` [dpdk-dev] [PATCH v4 3/7] ethdev: add structures and enum for hash " Helin Zhang
2014-10-13  6:12     ` [dpdk-dev] [PATCH v4 4/7] i40e: add hash filter control implementation Helin Zhang
2014-10-13 10:23       ` Chilikin, Andrey
2014-10-14  0:42         ` Zhang, Helin
2014-10-13  6:12     ` [dpdk-dev] [PATCH v4 5/7] i40e: add hardware initialization Helin Zhang
2014-10-13  6:12     ` [dpdk-dev] [PATCH v4 6/7] i40e: Use constant random hash keys Helin Zhang
2014-10-13  6:12     ` [dpdk-dev] [PATCH v4 7/7] app/testpmd: add commands to support hash filter control Helin Zhang
2014-10-13 12:27     ` [dpdk-dev] [PATCH v4 0/7] Support configuring hash functions Zhan, Zhaochen
2014-10-14  3:32     ` Wu, Jingjing
2014-10-21  3:14     ` [dpdk-dev] [PATCH v5 0/5] " Helin Zhang
2014-10-21  3:14       ` [dpdk-dev] [PATCH v5 1/5] i40e: Use constant random hash keys Helin Zhang
2014-11-03  7:49         ` Thomas Monjalon
2014-11-03  8:18           ` Zhang, Helin
2014-11-03  8:59             ` Thomas Monjalon
2014-11-06  7:52               ` Zhang, Helin
2014-11-11  3:30               ` Zhang, Helin
2014-10-21  3:14       ` [dpdk-dev] [PATCH v5 2/5] ethdev: add enum type and relevant structures for hash filter control Helin Zhang
2014-11-03  7:57         ` Thomas Monjalon
2014-11-06  3:41           ` Zhang, Helin
2014-11-06  8:43             ` Thomas Monjalon
2014-11-06  8:54               ` Zhang, Helin
2014-11-11  3:27           ` Zhang, Helin
2014-11-11  6:46           ` Zhang, Helin
2014-11-11 21:08             ` Thomas Monjalon
2014-11-12  5:52               ` Zhang, Helin
2014-11-12  9:30                 ` Thomas Monjalon
2014-11-12 14:22                   ` Zhang, Helin
2014-10-21  3:14       ` [dpdk-dev] [PATCH v5 3/5] i40e: add hash filter control implementation Helin Zhang
2014-10-21  3:14       ` [dpdk-dev] [PATCH v5 4/5] i40e: add hardware initialization Helin Zhang
2014-10-21  3:14       ` [dpdk-dev] [PATCH v5 5/5] app/testpmd: add commands to support hash filter Helin Zhang
2014-11-07  3:45       ` [dpdk-dev] [PATCH v5 0/5] Support configuring hash functions Chen, Erlu
2014-11-07  6:12       ` Chen, Erlu
2014-11-19 14:58       ` [dpdk-dev] [PATCH v6 0/3] " Helin Zhang
2014-11-19 14:58         ` [dpdk-dev] [PATCH v6 1/3] i40e: Use constant as the default hash keys Helin Zhang
2014-11-19 14:58         ` [dpdk-dev] [PATCH v6 2/3] i40e: support of controlling hash functions Helin Zhang
2014-11-19 14:58         ` Helin Zhang [this message]
2014-11-27 15:45         ` [dpdk-dev] [PATCH v6 0/3] Support configuring " Thomas Monjalon
2014-11-27 16:17           ` Zhang, Helin
2014-11-28 12:14         ` [dpdk-dev] [PATCH v7 0/4] " Helin Zhang
2014-11-28 12:14           ` [dpdk-dev] [PATCH v7 1/4] ethdev: code style fixes Helin Zhang
2014-11-28 12:14           ` [dpdk-dev] [PATCH v7 2/4] i40e: use constant as the default hash keys Helin Zhang
2014-11-28 12:14           ` [dpdk-dev] [PATCH v7 3/4] i40e: support of controlling hash functions Helin Zhang
2014-11-28 12:52             ` Ananyev, Konstantin
2014-11-28 12:14           ` [dpdk-dev] [PATCH v7 4/4] app/testpmd: app/testpmd: add commands to support " Helin Zhang
2014-12-02  2:19           ` [dpdk-dev] [PATCH v8 0/4] Support configuring " Helin Zhang
2014-12-02  2:19             ` [dpdk-dev] [PATCH v8 1/4] ethdev: code style fixes Helin Zhang
2014-12-02  2:19             ` [dpdk-dev] [PATCH v8 2/4] i40e: use constant as the default hash keys Helin Zhang
2014-12-02  2:19             ` [dpdk-dev] [PATCH v8 3/4] i40e: support of controlling hash functions Helin Zhang
2015-01-20  7:54               ` Thomas Monjalon
2015-01-21  0:13                 ` Zhang, Helin
2015-01-22  7:44                 ` Zhang, Helin
2014-12-02  2:19             ` [dpdk-dev] [PATCH v8 4/4] app/testpmd: add commands to support " Helin Zhang
2014-12-02 13:15             ` [dpdk-dev] [PATCH v8 0/4] Support configuring " Ananyev, Konstantin
2015-01-22  7:36             ` [dpdk-dev] [PATCH v9 0/5] " Helin Zhang
2015-01-22  7:36               ` [dpdk-dev] [PATCH v9 1/5] i40e: use constant as the default hash keys Helin Zhang
2015-01-22  7:36               ` [dpdk-dev] [PATCH v9 2/5] ethdev: code style fixes Helin Zhang
2015-01-22  7:36               ` [dpdk-dev] [PATCH v9 3/5] ethdev: support of configuring hash functions Helin Zhang
2015-01-22  7:36               ` [dpdk-dev] [PATCH v9 4/5] i40e: support of controlling " Helin Zhang
2015-01-22  7:36               ` [dpdk-dev] [PATCH v9 5/5] app/testpmd: add commands to support " Helin Zhang
     [not found]                 ` <5028514.8nkR6oWFO2@xps13>
2015-02-03  2:35                   ` Zhang, Helin
2014-09-30  6:20 ` [dpdk-dev] [PATCH v3 2/7] ethdev: add interfaces and relevant for filter control Helin Zhang
2014-09-30  6:20 ` [dpdk-dev] [PATCH v3 3/7] ethdev: add structures and enum for hash " Helin Zhang
2014-09-30  6:20 ` [dpdk-dev] [PATCH v3 4/7] i40e: add hash filter control implementation Helin Zhang
2014-09-30  6:20 ` [dpdk-dev] [PATCH v3 5/7] i40e: add hardware initialization Helin Zhang
2014-09-30  6:20 ` [dpdk-dev] [PATCH v3 6/7] i40e: Use constant random hash keys Helin Zhang
2014-09-30  6:20 ` [dpdk-dev] [PATCH v3 7/7] app/testpmd: add commands to support hash filter control Helin Zhang

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=1416409096-1340-4-git-send-email-helin.zhang@intel.com \
    --to=helin.zhang@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

DPDK patches and discussions

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://inbox.dpdk.org/dev/0 dev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 dev dev/ https://inbox.dpdk.org/dev \
		dev@dpdk.org
	public-inbox-index dev

Example config snippet for mirrors.
Newsgroup available over NNTP:
	nntp://inbox.dpdk.org/inbox.dpdk.dev


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git