From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by dpdk.org (Postfix) with ESMTP id 084F26890 for ; Mon, 13 Oct 2014 08:05:37 +0200 (CEST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga103.fm.intel.com with ESMTP; 12 Oct 2014 23:03:21 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.04,708,1406617200"; d="scan'208";a="604350154" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by fmsmga001.fm.intel.com with ESMTP; 12 Oct 2014 23:13:14 -0700 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id s9D6DCIs030766; Mon, 13 Oct 2014 14:13:12 +0800 Received: from shecgisg004.sh.intel.com (localhost [127.0.0.1]) by shecgisg004.sh.intel.com (8.13.6/8.13.6/SuSE Linux 0.8) with ESMTP id s9D6DA9a012294; Mon, 13 Oct 2014 14:13:12 +0800 Received: (from hzhan75@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id s9D6DAw6012290; Mon, 13 Oct 2014 14:13:10 +0800 From: Helin Zhang To: dev@dpdk.org Date: Mon, 13 Oct 2014 14:12:46 +0800 Message-Id: <1413180766-12211-8-git-send-email-helin.zhang@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1413180766-12211-1-git-send-email-helin.zhang@intel.com> References: <1412058028-10971-2-git-send-email-helin.zhang@intel.com> <1413180766-12211-1-git-send-email-helin.zhang@intel.com> Subject: [dpdk-dev] [PATCH v4 7/7] app/testpmd: add commands to support hash filter control X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Oct 2014 06:05:41 -0000 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 v4 changes: * Fixed a bug in testpmd for 'set_sym_hash_ena_per_port'. Signed-off-by: Helin Zhang --- app/test-pmd/cmdline.c | 566 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 566 insertions(+) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 0b972f9..bea88d1 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -74,6 +74,7 @@ #include #include #include +#include #include #include @@ -660,6 +661,35 @@ 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_pctype (port_id) (pctype)\n" + " get symmetric hash enable configuration per port\n\n" + + "set_sym_hash_ena_per_pctype (port_id) (pctype)" + " (enable|disable)\n" + " set symmetric hash enable configuration per" + " pctype to enable or disable.\n\n" + + "get_filter_swap (port_id) (pctype)\n" + " get filter swap configurations.\n\n" + + "set_filter_swap (port_id) (pctype) (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" ); } } @@ -7415,6 +7445,534 @@ cmdline_parse_inst_t cmd_get_flex_filter = { }, }; +/* *** Classification Filters Control *** */ + +/* *** 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_INFO_TYPE_SYM_HASH_ENA_PER_PORT; + ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, + RTE_ETH_FILTER_OP_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_INFO_TYPE_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_OP_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 pctype *** */ +struct cmd_get_sym_hash_ena_per_pctype_result { + cmdline_fixed_string_t get_sym_hash_ena_per_pctype; + uint8_t port_id; + uint8_t pctype; +}; + +static void +cmd_get_sym_hash_per_pctype_parsed(void *parsed_result, + __rte_unused struct cmdline *cl, + __rte_unused void *data) +{ + struct cmd_get_sym_hash_ena_per_pctype_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_INFO_TYPE_SYM_HASH_ENA_PER_PCTYPE; + info.info.sym_hash_ena.pctype = res->pctype; + ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, + RTE_ETH_FILTER_OP_GET, &info); + if (ret < 0) { + printf("Cannot get symmetric hash enable per pctype on " + "port %u, pctype %u\n", res->port_id, res->pctype); + return; + } + printf("Symmetric hash is %s on port %u, pctype %u\n", + info.info.sym_hash_ena.enable ? "enabled" : + "disabled", res->port_id, res->pctype); +} + +cmdline_parse_token_string_t cmd_get_sym_hash_ena_per_pctype_all = + TOKEN_STRING_INITIALIZER(struct cmd_get_sym_hash_ena_per_pctype_result, + get_sym_hash_ena_per_pctype, "get_sym_hash_ena_per_pctype"); +cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_pctype_port_id = + TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_pctype_result, + port_id, UINT8); +cmdline_parse_token_num_t cmd_get_sym_hash_ena_per_pctype_pctype = + TOKEN_NUM_INITIALIZER(struct cmd_get_sym_hash_ena_per_pctype_result, + pctype, UINT8); + +cmdline_parse_inst_t cmd_get_sym_hash_ena_per_pctype = { + .f = cmd_get_sym_hash_per_pctype_parsed, + .data = NULL, + .help_str = "get_sym_hash_ena_per_pctype port_id pctype", + .tokens = { + (void *)&cmd_get_sym_hash_ena_per_pctype_all, + (void *)&cmd_get_sym_hash_ena_per_pctype_port_id, + (void *)&cmd_get_sym_hash_ena_per_pctype_pctype, + NULL, + }, +}; + +/* *** Set symmetric hash enable per pctype *** */ +struct cmd_set_sym_hash_ena_per_pctype_result { + cmdline_fixed_string_t set_sym_hash_ena_per_pctype; + cmdline_fixed_string_t enable; + uint8_t port_id; + uint8_t pctype; +}; + +static void +cmd_set_sym_hash_per_pctype_parsed(void *parsed_result, + __rte_unused struct cmdline *cl, + __rte_unused void *data) +{ + struct cmd_set_sym_hash_ena_per_pctype_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_INFO_TYPE_SYM_HASH_ENA_PER_PCTYPE; + info.info.sym_hash_ena.pctype = res->pctype; + 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_OP_SET, &info); + if (ret < 0) { + printf("Cannot set symmetric hash enable per pctype to %s " + "on port %u, pctype %u\n", res->enable ? "enabled" : + "disabled", res->port_id, res->pctype); + return; + } + printf("Symmetic hash has been set to %s on port %u, pctype %u\n", + res->enable, res->port_id, res->pctype); +} + +cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_pctype_all = + TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_pctype_result, + set_sym_hash_ena_per_pctype, "set_sym_hash_ena_per_pctype"); +cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_pctype_port_id = + TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_pctype_result, + port_id, UINT8); +cmdline_parse_token_num_t cmd_set_sym_hash_ena_per_pctype_pctype = + TOKEN_NUM_INITIALIZER(struct cmd_set_sym_hash_ena_per_pctype_result, + pctype, UINT8); +cmdline_parse_token_string_t cmd_set_sym_hash_ena_per_pctype_enable = + TOKEN_STRING_INITIALIZER(struct cmd_set_sym_hash_ena_per_pctype_result, + enable, "enable#disable"); + +cmdline_parse_inst_t cmd_set_sym_hash_ena_per_pctype = { + .f = cmd_set_sym_hash_per_pctype_parsed, + .data = NULL, + .help_str = "set_sym_hash_ena_per_pctype pord_id pctype " + "enable|disable", + .tokens = { + (void *)&cmd_set_sym_hash_ena_per_pctype_all, + (void *)&cmd_set_sym_hash_ena_per_pctype_port_id, + (void *)&cmd_set_sym_hash_ena_per_pctype_pctype, + (void *)&cmd_set_sym_hash_ena_per_pctype_enable, + NULL, + }, +}; + +/* *** Get filter swap *** */ +struct cmd_get_filter_swap_result { + cmdline_fixed_string_t get_filter_swap; + uint8_t port_id; + uint8_t pctype; +}; + +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_INFO_TYPE_FILTER_SWAP; + info.info.filter_swap.pctype = res->pctype; + ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, + RTE_ETH_FILTER_OP_GET, &info); + if (ret < 0) { + printf("Cannot get filter swap on port %u, pctype %u\n", + res->port_id, res->pctype); + return; + } + printf("Filter swap of 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.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_num_t cmd_get_filter_swap_pctype = + TOKEN_NUM_INITIALIZER(struct cmd_get_filter_swap_result, + pctype, UINT8); + +cmdline_parse_inst_t cmd_get_filter_swap = { + .f = cmd_get_filter_swap_parsed, + .data = NULL, + .help_str = "get_filter_swap port_id pctype", + .tokens = { + (void *)&cmd_get_filter_swap_all, + (void *)&cmd_get_filter_swap_port_id, + (void *)&cmd_get_filter_swap_pctype, + NULL, + }, +}; + +/* *** Set filter swap *** */ +struct cmd_set_filter_swap_result { + cmdline_fixed_string_t 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_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_INFO_TYPE_FILTER_SWAP; + info.info.filter_swap.pctype = res->pctype; + 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_OP_SET, &info); + if (ret < 0) { + printf("Cannot set filter swap on port %u, pctype %u\n", + res->port_id, res->pctype); + return; + } + printf("Filter swap of 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.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_num_t cmd_set_filter_swap_pctype = + TOKEN_NUM_INITIALIZER(struct cmd_set_filter_swap_result, + pctype, UINT8); +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 pctype 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_pctype, + (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_INFO_TYPE_HASH_FUNCTION; + ret = rte_eth_dev_filter_ctrl(res->port_id, RTE_ETH_FILTER_HASH, + RTE_ETH_FILTER_OP_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_INFO_TYPE_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_OP_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 */ @@ -7541,6 +8099,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_pctype, + (cmdline_parse_inst_t *)&cmd_set_sym_hash_ena_per_pctype, + (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