DPDK patches and discussions
 help / color / mirror / Atom feed
From: Helin Zhang <helin.zhang@intel.com>
To: dev@dpdk.org
Subject: [dpdk-dev] [PATCH v2 6/6] app/testpmd: add commands for configuring hash functions
Date: Mon, 28 Jul 2014 16:25:55 +0800	[thread overview]
Message-ID: <1406535955-31070-7-git-send-email-helin.zhang@intel.com> (raw)
In-Reply-To: <1406535955-31070-1-git-send-email-helin.zhang@intel.com>

Eight commands are added to configure hash functions.
They are,
 - i40e_get_sym_hash_ena_per_port
   Get symmetric hash enable per port.
 - i40e_set_sym_hash_ena_per_port
   Set symmetric hash enable per port.
 - i40e_get_sym_hash_ena_per_pctype
   Get symmetric hash enable per PCTYPE
   (Packet Classification Type).
 - i40e_set_sym_hash_ena_per_pctype
   Set symmetric hash enable per PCTYPE
   (Packet Classification Type).
 - i40e_get_filter_swap
   Get filter swap configurations.
 - i40e_set_filter_swap
   Set filter swap configurations.
 - i40e_get_hash_function
   Get hash function.
 - i40e_set_hash_function
   Set hash function to 'Toeplitz' or 'Simple XOR'

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

diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c
index 345be11..9890400 100644
--- a/app/test-pmd/cmdline.c
+++ b/app/test-pmd/cmdline.c
@@ -74,6 +74,10 @@
 #include <rte_ethdev.h>
 #include <rte_string_fns.h>
 #include <rte_devargs.h>
+#include <rte_eth_features.h>
+#ifdef RTE_LIBRTE_I40E_PMD
+#include <rte_i40e.h>
+#endif
 
 #include <cmdline_rdline.h>
 #include <cmdline_parse.h>
@@ -655,6 +659,43 @@ 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"
+
+#ifdef RTE_LIBRTE_I40E_PMD
+			"i40e_get_sym_hash_ena_per_port (port_id)\n"
+			"    get symmetric hash enable configuration per port,"
+			" on i40e only\n\n"
+
+			"i40e_set_sym_hash_ena_per_port (port_id)"
+			" (enable|disable)\n"
+			"    set symmetric hash enable configuration per port"
+			" to enable or disable, on i40e only\n\n"
+
+			"i40e_get_sym_hash_ena_per_pctype (port_id) (pctype)\n"
+			"    get symmetric hash enable configuration per port,"
+			" on i40e only\n\n"
+
+			"i40e_set_sym_hash_ena_per_pctype (port_id) (pctype)"
+			" (enable|disable)\n"
+			"    set symmetric hash enable configuration per"
+			" pctype to enable or disable, on i40e only\n\n"
+
+			"i40e_get_filter_swap (port_id) (pctype)\n"
+			"    get filter swap configurations on i40e,"
+			" on i40e only\n\n"
+
+			"i40e_set_filter_swap (port_id) (pctype) (off0_src0)"
+			" (off0_src1) (len0) (off1_src0) (off1_src1) (len1)\n"
+			"    set filter swap configurations, on i40e only\n\n"
+
+			"i40e_get_hash_function (port_id)\n"
+			"    get hash function of Toeplitz or Simple XOR,"
+			" on i40e only\n\n"
+
+			"i40e_set_hash_function (port_id)"
+			" (toeplitz|simple_xor)\n"
+			"    set the hash function to Toeplitz or Simple XOR,"
+			" on i40e only\n\n"
+#endif /* RTE_LIBRTE_I40E_PMD */
 		);
 	}
 }
@@ -7304,6 +7345,534 @@ cmdline_parse_inst_t cmd_get_flex_filter = {
 	},
 };
 
+/* *** Classification Filters Control *** */
+#ifdef RTE_LIBRTE_I40E_PMD
+/* *** Get symmetric hash enable per port *** */
+struct cmd_i40e_get_sym_hash_ena_per_port_result {
+	cmdline_fixed_string_t i40e_get_sym_hash_ena_per_port;
+	uint8_t port_id;
+};
+
+static void
+cmd_i40e_get_sym_hash_per_port_parsed(void *parsed_result,
+				      __rte_unused struct cmdline *cl,
+				      __rte_unused void *data)
+{
+	struct cmd_i40e_get_sym_hash_ena_per_port_result *res = parsed_result;
+	uint8_t enable = 0;
+	int ret;
+
+	if (rte_eth_dev_is_command_supported(res->port_id,
+		RTE_CMD_GET_SYM_HASH_ENABLE_PER_PORT) <= 0) {
+		printf("Command of RTE_CMD_GET_SYM_HASH_ENABLE_PER_PORT "
+			"not supported on port: %d\n", res->port_id);
+		return;
+	}
+
+	ret = rte_eth_dev_rx_classification_filter_ctl(res->port_id,
+		RTE_CMD_GET_SYM_HASH_ENABLE_PER_PORT, &enable);
+	if (ret < 0) {
+		printf("Cannot get symmetric hash enable per port "
+				"on i40e port %u\n", res->port_id);
+		return;
+	}
+
+	printf("Symmetric hash is %s on i40e port %u\n",
+		enable ? "enabled" : "disabled", res->port_id);
+}
+
+cmdline_parse_token_string_t cmd_i40e_get_sym_hash_ena_per_port_all =
+	TOKEN_STRING_INITIALIZER(
+		struct cmd_i40e_get_sym_hash_ena_per_port_result,
+			i40e_get_sym_hash_ena_per_port,
+			"i40e_get_sym_hash_ena_per_port");
+cmdline_parse_token_num_t cmd_i40e_get_sym_hash_ena_per_port_port_id =
+	TOKEN_NUM_INITIALIZER(struct cmd_i40e_get_sym_hash_ena_per_port_result,
+		port_id, UINT8);
+
+cmdline_parse_inst_t cmd_i40e_get_sym_hash_ena_per_port = {
+	.f = cmd_i40e_get_sym_hash_per_port_parsed,
+	.data = NULL,
+	.help_str = "i40e_get_sym_hash_ena_per_port port_id",
+	.tokens = {
+		(void *)&cmd_i40e_get_sym_hash_ena_per_port_all,
+		(void *)&cmd_i40e_get_sym_hash_ena_per_port_port_id,
+		NULL,
+	},
+};
+
+/* *** Set symmetric hash enable per port *** */
+struct cmd_i40e_set_sym_hash_ena_per_port_result {
+	cmdline_fixed_string_t i40e_set_sym_hash_ena_per_port;
+	cmdline_fixed_string_t enable;
+	uint8_t port_id;
+};
+
+static void
+cmd_i40e_set_sym_hash_per_port_parsed(void *parsed_result,
+				      __rte_unused struct cmdline *cl,
+				      __rte_unused void *data)
+{
+	struct cmd_i40e_set_sym_hash_ena_per_port_result *res = parsed_result;
+	uint8_t enable = 0;
+	int ret;
+
+	if (rte_eth_dev_is_command_supported(res->port_id,
+		RTE_CMD_SET_SYM_HASH_ENABLE_PER_PORT) <= 0) {
+		printf("Command of RTE_CMD_SET_SYM_HASH_ENABLE_PER_PORT "
+			"not supported on port: %d\n", res->port_id);
+		return;
+	}
+
+	if (!strcmp(res->enable, "enable"))
+		enable = 1;
+	ret = rte_eth_dev_rx_classification_filter_ctl(res->port_id,
+		RTE_CMD_SET_SYM_HASH_ENABLE_PER_PORT, &enable);
+	if (ret < 0) {
+		printf("Cannot set symmetric hash enable per port "
+				"on i40e port %u\n", res->port_id);
+		return;
+	}
+
+	printf("Symmetric hash has been set to %s on i40e port %u\n",
+					res->enable, res->port_id);
+}
+
+cmdline_parse_token_string_t cmd_i40e_set_sym_hash_ena_per_port_all =
+	TOKEN_STRING_INITIALIZER(
+		struct cmd_i40e_set_sym_hash_ena_per_port_result,
+				i40e_set_sym_hash_ena_per_port,
+				"i40e_set_sym_hash_ena_per_port");
+cmdline_parse_token_num_t cmd_i40e_set_sym_hash_ena_per_port_port_id =
+	TOKEN_NUM_INITIALIZER(struct cmd_i40e_set_sym_hash_ena_per_port_result,
+		port_id, UINT8);
+cmdline_parse_token_string_t cmd_i40e_set_sym_hash_ena_per_port_enable =
+	TOKEN_STRING_INITIALIZER(
+		struct cmd_i40e_set_sym_hash_ena_per_port_result,
+					enable, "enable#disable");
+
+cmdline_parse_inst_t cmd_i40e_set_sym_hash_ena_per_port = {
+	.f = cmd_i40e_set_sym_hash_per_port_parsed,
+	.data = NULL,
+	.help_str = "i40e_set_sym_hash_ena_per_port port_id enable|disable",
+	.tokens = {
+		(void *)&cmd_i40e_set_sym_hash_ena_per_port_all,
+		(void *)&cmd_i40e_set_sym_hash_ena_per_port_port_id,
+		(void *)&cmd_i40e_set_sym_hash_ena_per_port_enable,
+		NULL,
+	},
+};
+
+/* *** Get symmetric hash enable per pctype *** */
+struct cmd_i40e_get_sym_hash_ena_per_pctype_result {
+	cmdline_fixed_string_t i40e_get_sym_hash_ena_per_pctype;
+	uint8_t port_id;
+	uint8_t pctype;
+};
+
+static void
+cmd_i40e_get_sym_hash_per_pctype_parsed(void *parsed_result,
+					__rte_unused struct cmdline *cl,
+					__rte_unused void *data)
+{
+	struct cmd_i40e_get_sym_hash_ena_per_pctype_result *res =
+						parsed_result;
+	struct rte_i40e_sym_hash_enable_info info;
+	int ret;
+
+	if (rte_eth_dev_is_command_supported(res->port_id,
+		RTE_CMD_GET_SYM_HASH_ENABLE_PER_PCTYPE) <= 0) {
+		printf("Command of RTE_CMD_GET_SYM_HASH_ENABLE_PER_PCTYPE "
+			"not supported on port: %d\n", res->port_id);
+		return;
+	}
+
+	memset(&info, 0, sizeof(info));
+	info.pctype = res->pctype;
+	ret = rte_eth_dev_rx_classification_filter_ctl(res->port_id,
+		RTE_CMD_GET_SYM_HASH_ENABLE_PER_PCTYPE, &info);
+	if (ret < 0) {
+		printf("Cannot get symmetric hash enable per pctype on i40e "
+			"port %u, pctype %u\n", res->port_id, res->pctype);
+		return;
+	}
+	printf("Symmetric hash is %s on i40e port %u, pctype %u\n",
+				info.enable ? "enabled" : "disabled",
+					res->port_id, res->pctype);
+}
+
+cmdline_parse_token_string_t cmd_i40e_get_sym_hash_ena_per_pctype_all =
+	TOKEN_STRING_INITIALIZER(
+		struct cmd_i40e_get_sym_hash_ena_per_pctype_result,
+				i40e_get_sym_hash_ena_per_pctype,
+				"i40e_get_sym_hash_ena_per_pctype");
+cmdline_parse_token_num_t cmd_i40e_get_sym_hash_ena_per_pctype_port_id =
+	TOKEN_NUM_INITIALIZER(
+		struct cmd_i40e_get_sym_hash_ena_per_pctype_result,
+						port_id, UINT8);
+cmdline_parse_token_num_t cmd_i40e_get_sym_hash_ena_per_pctype_pctype =
+	TOKEN_NUM_INITIALIZER(
+		struct cmd_i40e_get_sym_hash_ena_per_pctype_result,
+						pctype, UINT8);
+
+cmdline_parse_inst_t cmd_i40e_get_sym_hash_ena_per_pctype = {
+	.f = cmd_i40e_get_sym_hash_per_pctype_parsed,
+	.data = NULL,
+	.help_str = "i40e_get_sym_hash_ena_per_pctype port_id pctype",
+	.tokens = {
+		(void *)&cmd_i40e_get_sym_hash_ena_per_pctype_all,
+		(void *)&cmd_i40e_get_sym_hash_ena_per_pctype_port_id,
+		(void *)&cmd_i40e_get_sym_hash_ena_per_pctype_pctype,
+		NULL,
+	},
+};
+
+/* *** Set symmetric hash enable per pctype *** */
+struct cmd_i40e_set_sym_hash_ena_per_pctype_result {
+	cmdline_fixed_string_t i40e_set_sym_hash_ena_per_pctype;
+	cmdline_fixed_string_t enable;
+	uint8_t port_id;
+	uint8_t pctype;
+};
+
+static void
+cmd_i40e_set_sym_hash_per_pctype_parsed(void *parsed_result,
+					__rte_unused struct cmdline *cl,
+					__rte_unused void *data)
+{
+	struct cmd_i40e_set_sym_hash_ena_per_pctype_result *res =
+						parsed_result;
+	struct rte_i40e_sym_hash_enable_info info;
+	int ret;
+
+	if (rte_eth_dev_is_command_supported(res->port_id,
+		RTE_CMD_SET_SYM_HASH_ENABLE_PER_PCTYPE) <= 0) {
+		printf("Command of RTE_CMD_SET_SYM_HASH_ENABLE_PER_PCTYPE "
+			"not supported on port: %d\n", res->port_id);
+		return;
+	}
+
+	memset(&info, 0, sizeof(info));
+	info.pctype = res->pctype;
+	if (!strcmp(res->enable, "enable"))
+		info.enable = 1;
+	ret = rte_eth_dev_rx_classification_filter_ctl(res->port_id,
+		RTE_CMD_SET_SYM_HASH_ENABLE_PER_PCTYPE, &info);
+	if (ret < 0) {
+		printf("Cannot set symmetric hash enable per pctype to %s "
+			"on i40e port %u, pctype %u\n", res->enable ?
+			"enabled" : "disabled", res->port_id, res->pctype);
+		return;
+	}
+	printf("Symmetic hash has been set to %s on i40e port %u, pctype %u\n",
+				res->enable, res->port_id, res->pctype);
+}
+
+cmdline_parse_token_string_t cmd_i40e_set_sym_hash_ena_per_pctype_all =
+	TOKEN_STRING_INITIALIZER(
+		struct cmd_i40e_set_sym_hash_ena_per_pctype_result,
+				i40e_set_sym_hash_ena_per_pctype,
+				"i40e_set_sym_hash_ena_per_pctype");
+cmdline_parse_token_num_t cmd_i40e_set_sym_hash_ena_per_pctype_port_id =
+	TOKEN_NUM_INITIALIZER(
+		struct cmd_i40e_set_sym_hash_ena_per_pctype_result,
+						port_id, UINT8);
+cmdline_parse_token_num_t cmd_i40e_set_sym_hash_ena_per_pctype_pctype =
+	TOKEN_NUM_INITIALIZER(
+		struct cmd_i40e_set_sym_hash_ena_per_pctype_result,
+		pctype, UINT8);
+cmdline_parse_token_string_t cmd_i40e_set_sym_hash_ena_per_pctype_enable =
+	TOKEN_STRING_INITIALIZER(
+		struct cmd_i40e_set_sym_hash_ena_per_pctype_result,
+		enable, "enable#disable");
+
+cmdline_parse_inst_t cmd_i40e_set_sym_hash_ena_per_pctype = {
+	.f = cmd_i40e_set_sym_hash_per_pctype_parsed,
+	.data = NULL,
+	.help_str = "i40e_set_sym_hash_ena_per_pctype pord_id "
+					"pctype enable|disable",
+	.tokens = {
+		(void *)&cmd_i40e_set_sym_hash_ena_per_pctype_all,
+		(void *)&cmd_i40e_set_sym_hash_ena_per_pctype_port_id,
+		(void *)&cmd_i40e_set_sym_hash_ena_per_pctype_pctype,
+		(void *)&cmd_i40e_set_sym_hash_ena_per_pctype_enable,
+		NULL,
+	},
+};
+
+/* *** Get filter swap *** */
+struct cmd_i40e_get_filter_swap_result {
+	cmdline_fixed_string_t i40e_get_filter_swap;
+	uint8_t port_id;
+	uint8_t pctype;
+};
+
+static void
+cmd_i40e_get_filter_swap_parsed(void *parsed_result,
+				__rte_unused struct cmdline *cl,
+				__rte_unused void *data)
+{
+	struct cmd_i40e_get_filter_swap_result *res = parsed_result;
+	struct rte_i40e_filter_swap_info info;
+	int ret;
+
+	if (rte_eth_dev_is_command_supported(res->port_id,
+			RTE_CMD_GET_FILTER_SWAP) <= 0) {
+		printf("Command of RTE_CMD_GET_FILTER_SWAP not supported "
+					"on port: %d\n", res->port_id);
+		return;
+	}
+
+	memset(&info, 0, sizeof(info));
+	info.pctype = res->pctype;
+	ret = rte_eth_dev_rx_classification_filter_ctl(res->port_id,
+				RTE_CMD_GET_FILTER_SWAP, &info);
+	if (ret < 0) {
+		printf("Cannot get filter swap on i40e port %u, pctype %u\n",
+						res->port_id, res->pctype);
+		return;
+	}
+	printf("Filter swap of i40e port %u, pctype %u 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->pctype, info.off0_src0, info.off0_src1,
+		info.len0, info.off1_src0, info.off1_src1, info.len1);
+}
+
+cmdline_parse_token_string_t cmd_i40e_get_filter_swap_all =
+	TOKEN_STRING_INITIALIZER(struct cmd_i40e_get_filter_swap_result,
+		i40e_get_filter_swap, "i40e_get_filter_swap");
+cmdline_parse_token_num_t cmd_i40e_get_filter_swap_port_id =
+	TOKEN_NUM_INITIALIZER(struct cmd_i40e_get_filter_swap_result,
+		port_id, UINT8);
+cmdline_parse_token_num_t cmd_i40e_get_filter_swap_pctype =
+	TOKEN_NUM_INITIALIZER(struct cmd_i40e_get_filter_swap_result,
+		pctype, UINT8);
+
+cmdline_parse_inst_t cmd_i40e_get_filter_swap = {
+	.f = cmd_i40e_get_filter_swap_parsed,
+	.data = NULL,
+	.help_str = "i40e_get_filter_swap port_id pctype",
+	.tokens = {
+		(void *)&cmd_i40e_get_filter_swap_all,
+		(void *)&cmd_i40e_get_filter_swap_port_id,
+		(void *)&cmd_i40e_get_filter_swap_pctype,
+		NULL,
+	},
+};
+
+/* *** Set filter swap *** */
+struct cmd_i40e_set_filter_swap_result {
+	cmdline_fixed_string_t i40e_set_filter_swap;
+	uint8_t port_id;
+	uint8_t pctype;
+	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_i40e_set_filter_swap_parsed(void *parsed_result,
+				__rte_unused struct cmdline *cl,
+				__rte_unused void *data)
+{
+	struct cmd_i40e_set_filter_swap_result *res = parsed_result;
+	struct rte_i40e_filter_swap_info info;
+	int ret;
+
+	if (rte_eth_dev_is_command_supported(res->port_id,
+			RTE_CMD_SET_FILTER_SWAP) <= 0) {
+		printf("Command of RTE_CMD_SET_FILTER_SWAP not supported "
+					"on port: %d\n", res->port_id);
+		return;
+	}
+
+	memset(&info, 0, sizeof(info));
+	info.pctype = res->pctype;
+	info.off0_src0 = res->off0_src0;
+	info.off0_src1 = res->off0_src1;
+	info.len0 = res->len0;
+	info.off1_src0 = res->off1_src0;
+	info.off1_src1 = res->off1_src1;
+	info.len1 = res->len1;
+	ret = rte_eth_dev_rx_classification_filter_ctl(res->port_id,
+				RTE_CMD_SET_FILTER_SWAP, &info);
+	if (ret < 0) {
+		printf("Cannot set filter swap on i40e port %u, pctype %u\n",
+						res->port_id, res->pctype);
+		return;
+	}
+	printf("Filter swap of i40e port %u, pctype %u 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->pctype, info.off0_src0, info.off0_src1,
+		info.len0, info.off1_src0, info.off1_src1, info.len1);
+}
+
+cmdline_parse_token_string_t cmd_i40e_set_filter_swap_all =
+	TOKEN_STRING_INITIALIZER(struct cmd_i40e_set_filter_swap_result,
+		i40e_set_filter_swap, "i40e_set_filter_swap");
+cmdline_parse_token_num_t cmd_i40e_set_filter_swap_port_id =
+	TOKEN_NUM_INITIALIZER(struct cmd_i40e_set_filter_swap_result,
+		port_id, UINT8);
+cmdline_parse_token_num_t cmd_i40e_set_filter_swap_pctype =
+	TOKEN_NUM_INITIALIZER(struct cmd_i40e_set_filter_swap_result,
+		pctype, UINT8);
+cmdline_parse_token_num_t cmd_i40e_set_filter_swap_off0_src0 =
+	TOKEN_NUM_INITIALIZER(struct cmd_i40e_set_filter_swap_result,
+		off0_src0, UINT8);
+cmdline_parse_token_num_t cmd_i40e_set_filter_swap_off0_src1 =
+	TOKEN_NUM_INITIALIZER(struct cmd_i40e_set_filter_swap_result,
+		off0_src1, UINT8);
+cmdline_parse_token_num_t cmd_i40e_set_filter_swap_len0 =
+	TOKEN_NUM_INITIALIZER(struct cmd_i40e_set_filter_swap_result,
+		len0, UINT8);
+cmdline_parse_token_num_t cmd_i40e_set_filter_swap_off1_src0 =
+	TOKEN_NUM_INITIALIZER(struct cmd_i40e_set_filter_swap_result,
+		off1_src0, UINT8);
+cmdline_parse_token_num_t cmd_i40e_set_filter_swap_off1_src1 =
+	TOKEN_NUM_INITIALIZER(struct cmd_i40e_set_filter_swap_result,
+		off1_src1, UINT8);
+cmdline_parse_token_num_t cmd_i40e_set_filter_swap_len1 =
+	TOKEN_NUM_INITIALIZER(struct cmd_i40e_set_filter_swap_result,
+		len1, UINT8);
+
+cmdline_parse_inst_t cmd_i40e_set_filter_swap = {
+	.f = cmd_i40e_set_filter_swap_parsed,
+	.data = NULL,
+	.help_str = "i40e_set_filter_swap port_id pctype off0_src0 off0_src1 "
+					"len0 off1_src0 off1_src1 len1",
+	.tokens = {
+		(void *)&cmd_i40e_set_filter_swap_all,
+		(void *)&cmd_i40e_set_filter_swap_port_id,
+		(void *)&cmd_i40e_set_filter_swap_pctype,
+		(void *)&cmd_i40e_set_filter_swap_off0_src0,
+		(void *)&cmd_i40e_set_filter_swap_off0_src1,
+		(void *)&cmd_i40e_set_filter_swap_len0,
+		(void *)&cmd_i40e_set_filter_swap_off1_src0,
+		(void *)&cmd_i40e_set_filter_swap_off1_src1,
+		(void *)&cmd_i40e_set_filter_swap_len1,
+		NULL,
+	},
+};
+
+/* Get hash function */
+struct cmd_i40e_get_hash_function_result {
+	cmdline_fixed_string_t i40e_get_hash_function;
+	uint8_t port_id;
+};
+
+static void
+cmd_i40e_get_hash_function_parsed(void *parsed_result,
+				  __rte_unused struct cmdline *cl,
+				  __rte_unused void *data)
+{
+	struct cmd_i40e_get_hash_function_result *res = parsed_result;
+	enum rte_i40e_hash_function hf;
+	int ret;
+
+	if (rte_eth_dev_is_command_supported(res->port_id,
+			RTE_CMD_GET_HASH_FUNCTION) <= 0) {
+		printf("Command of RTE_CMD_GET_HASH_FUNCTION not "
+			"supported on port %d\n", res->port_id);
+		return;
+	}
+	ret = rte_eth_dev_rx_classification_filter_ctl(res->port_id,
+					RTE_CMD_GET_HASH_FUNCTION, &hf);
+	if (ret < 0) {
+		printf("Cannot get hash function on port %d\n", res->port_id);
+		return;
+	}
+	printf("Hash function is %s\n", hf == rte_i40e_hash_function_toeplitz ?
+						"Toeplitz" : "Simple XOR");
+}
+
+cmdline_parse_token_string_t cmd_i40e_get_hash_function_all =
+	TOKEN_STRING_INITIALIZER(struct cmd_i40e_get_hash_function_result,
+		i40e_get_hash_function, "i40e_get_hash_function");
+cmdline_parse_token_num_t cmd_i40e_get_hash_function_port_id =
+	TOKEN_NUM_INITIALIZER(struct cmd_i40e_get_hash_function_result,
+		port_id, UINT8);
+
+cmdline_parse_inst_t cmd_i40e_get_hash_function = {
+	.f = cmd_i40e_get_hash_function_parsed,
+	.data = NULL,
+	.help_str = "i40e_get_hash_function port_id",
+	.tokens = {
+		(void *)&cmd_i40e_get_hash_function_all,
+		(void *)&cmd_i40e_get_hash_function_port_id,
+		NULL,
+	},
+};
+
+/* Set hash function of Hoeplitz or Simple XOR */
+struct cmd_i40e_set_hash_function_result {
+	cmdline_fixed_string_t i40e_set_hash_function;
+	uint8_t port_id;
+	cmdline_fixed_string_t hash_function;
+};
+
+static void
+cmd_i40e_set_hash_function_parsed(void *parsed_result,
+				  __rte_unused struct cmdline *cl,
+				  __rte_unused void *data)
+{
+	struct cmd_i40e_set_hash_function_result *res = parsed_result;
+	enum rte_i40e_hash_function hf;
+	int ret;
+
+	if (!strcmp(res->hash_function, "toeplitz"))
+		hf = rte_i40e_hash_function_toeplitz;
+	else if (!strcmp(res->hash_function, "simple_xor"))
+		hf = rte_i40e_hash_function_simple_xor;
+	else {
+		printf("Unsupported hash function %s\n", res->hash_function);
+		return;
+	}
+	if (rte_eth_dev_is_command_supported(res->port_id,
+			RTE_CMD_SET_HASH_FUNCTION) <= 0) {
+		printf("Command of RTE_CMD_SET_HASH_FUNCTION not "
+			"supported on port %d\n", res->port_id);
+		return;
+	}
+	ret = rte_eth_dev_rx_classification_filter_ctl(res->port_id,
+				RTE_CMD_SET_HASH_FUNCTION, &hf);
+	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_i40e_set_hash_function_all =
+	TOKEN_STRING_INITIALIZER(struct cmd_i40e_set_hash_function_result,
+		i40e_set_hash_function, "i40e_set_hash_function");
+cmdline_parse_token_num_t cmd_i40e_set_hash_function_port_id =
+	TOKEN_NUM_INITIALIZER(struct cmd_i40e_set_hash_function_result,
+		port_id, UINT8);
+cmdline_parse_token_string_t cmd_i40e_set_hash_function_hash_function =
+	TOKEN_STRING_INITIALIZER(struct cmd_i40e_set_hash_function_result,
+		hash_function, "toeplitz#simple_xor");
+
+cmdline_parse_inst_t cmd_i40e_set_hash_function = {
+	.f = cmd_i40e_set_hash_function_parsed,
+	.data = NULL,
+	.help_str = "i40e_set_hash_function port_id toeplitz|simple_xor",
+	.tokens = {
+		(void *)&cmd_i40e_set_hash_function_all,
+		(void *)&cmd_i40e_set_hash_function_port_id,
+		(void *)&cmd_i40e_set_hash_function_hash_function,
+		NULL,
+	},
+};
+
+#endif /* RTE_LIBRTE_I40E_PMD */
+
 /* ******************************************************************************** */
 
 /* list of instructions */
@@ -7429,6 +7998,16 @@ 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,
+#ifdef RTE_LIBRTE_I40E_PMD
+	(cmdline_parse_inst_t *)&cmd_i40e_get_sym_hash_ena_per_port,
+	(cmdline_parse_inst_t *)&cmd_i40e_set_sym_hash_ena_per_port,
+	(cmdline_parse_inst_t *)&cmd_i40e_get_sym_hash_ena_per_pctype,
+	(cmdline_parse_inst_t *)&cmd_i40e_set_sym_hash_ena_per_pctype,
+	(cmdline_parse_inst_t *)&cmd_i40e_get_filter_swap,
+	(cmdline_parse_inst_t *)&cmd_i40e_set_filter_swap,
+	(cmdline_parse_inst_t *)&cmd_i40e_set_hash_function,
+	(cmdline_parse_inst_t *)&cmd_i40e_get_hash_function,
+#endif /* RTE_LIBRTE_I40E_PMD */
 	NULL,
 };
 
-- 
1.8.1.4

  parent reply	other threads:[~2014-07-28  8:24 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-28  8:25 [dpdk-dev] [PATCH v2 0/6] Support " Helin Zhang
2014-07-28  8:25 ` [dpdk-dev] [PATCH v2 1/6] ethdev: rename macros of packet classification type Helin Zhang
2014-08-27 16:44   ` Thomas Monjalon
2014-07-28  8:25 ` [dpdk-dev] [PATCH v2 2/6] ethdev: add new ops of 'is_command_supported' and 'rx_classification_filter_ctl' Helin Zhang
2014-07-28  8:25 ` [dpdk-dev] [PATCH v2 3/6] i40e: support of 'rx_classification_filter_ctl' Helin Zhang
2014-07-28  8:25 ` [dpdk-dev] [PATCH v2 4/6] i40e: support of 'is_command_supported' Helin Zhang
2014-07-28  8:25 ` [dpdk-dev] [PATCH v2 5/6] i40e: Initialize hash function during port initialization Helin Zhang
2014-07-28  8:25 ` Helin Zhang [this message]
2014-07-29  2:57 ` [dpdk-dev] [PATCH v2 0/6] Support configuring hash functions Wu, Jingjing
2014-07-31  2:49 ` Zhan, Zhaochen
2014-08-01  5:26   ` Zhang, Helin
2014-08-29 16:11     ` Thomas Monjalon
2014-08-20  7:05 ` Zhang, Helin

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=1406535955-31070-7-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
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).