From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) by dpdk.org (Postfix) with ESMTP id 82A2F5A83 for ; Wed, 11 Feb 2015 08:52:08 +0100 (CET) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga103.jf.intel.com with ESMTP; 10 Feb 2015 23:47:07 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,557,1418112000"; d="scan'208";a="525812607" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga003.jf.intel.com with ESMTP; 10 Feb 2015 23:43:59 -0800 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id t1B7q3N3015226; Wed, 11 Feb 2015 15:52:03 +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 t1B7q0iV000721; Wed, 11 Feb 2015 15:52:02 +0800 Received: (from wujingji@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id t1B7q08d000717; Wed, 11 Feb 2015 15:52:00 +0800 From: Jingjing Wu To: dev@dpdk.org Date: Wed, 11 Feb 2015 15:51:48 +0800 Message-Id: <1423641110-658-5-git-send-email-jingjing.wu@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1423641110-658-1-git-send-email-jingjing.wu@intel.com> References: <1420681358-24809-1-git-send-email-zhida.zang@intel.com> <1423641110-658-1-git-send-email-jingjing.wu@intel.com> Subject: [dpdk-dev] [PATCH v2 4/6] testpmd: new commands for syn filter 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: Wed, 11 Feb 2015 07:52:09 -0000 Following commands of syn filter are removed: - add_syn_filter (port_id) priority (high|low) queue (queue_id) - remove_syn_filter (port_id) - get_syn_filter (port_id) New command is added for syn filter by using filter_ctrl API and new syn filter structure: - syn_filter (port_id) (add|del) priority (high|low) queue (queue_id) Signed-off-by: Jingjing Wu --- app/test-pmd/cmdline.c | 143 ++++++++++++++++++++++--------------------------- app/test-pmd/config.c | 21 -------- 2 files changed, 65 insertions(+), 99 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 590e427..f8d9f03 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -683,14 +683,8 @@ static void cmd_help_long_parsed(void *parsed_result, "get_5tuple_filter (port_id) index (idx)\n" " get info of a 5tuple filter.\n\n" - "add_syn_filter (port_id) priority (high|low) queue (queue_id)" - " add syn filter.\n\n" - - "remove_syn_filter (port_id)" - " remove syn filter.\n\n" - - "get_syn_filter (port_id) " - " get syn filter info.\n\n" + "syn_filter (port_id) (add|del) priority (high|low) queue (queue_id)" + " Add/Del syn filter.\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" @@ -7275,99 +7269,94 @@ cmdline_parse_inst_t cmd_dump_one = { }, }; -/* *** set SYN filter *** */ -struct cmd_set_syn_filter_result { +/* *** Add/Del syn filter *** */ +struct cmd_syn_filter_result { cmdline_fixed_string_t filter; uint8_t port_id; + cmdline_fixed_string_t ops; cmdline_fixed_string_t priority; cmdline_fixed_string_t high; cmdline_fixed_string_t queue; - uint16_t queue_id; + uint16_t queue_id; }; static void -cmd_set_syn_filter_parsed(void *parsed_result, +cmd_syn_filter_parsed(void *parsed_result, __attribute__((unused)) struct cmdline *cl, __attribute__((unused)) void *data) { + struct cmd_syn_filter_result *res = parsed_result; + struct rte_eth_syn_filter syn_filter; int ret = 0; - struct cmd_set_syn_filter_result *res = parsed_result; - struct rte_syn_filter filter; - if (!strcmp(res->filter, "add_syn_filter")) { + ret = rte_eth_dev_filter_supported(res->port_id, + RTE_ETH_FILTER_SYN); + if (ret < 0) { + printf("syn filter is not supported on port %u.\n", + res->port_id); + return; + } + + memset(&syn_filter, 0, sizeof(syn_filter)); + + if (!strcmp(res->ops, "add")) { if (!strcmp(res->high, "high")) - filter.hig_pri = 1; + syn_filter.hig_pri = 1; else - filter.hig_pri = 0; - ret = rte_eth_dev_add_syn_filter(res->port_id, - &filter, res->queue_id); - } else if (!strcmp(res->filter, "remove_syn_filter")) - ret = rte_eth_dev_remove_syn_filter(res->port_id); - else if (!strcmp(res->filter, "get_syn_filter")) - get_syn_filter(res->port_id); - if (ret < 0) - printf("syn filter setting error: (%s)\n", strerror(-ret)); + syn_filter.hig_pri = 0; + + syn_filter.queue = res->queue_id; + ret = rte_eth_dev_filter_ctrl(res->port_id, + RTE_ETH_FILTER_SYN, + RTE_ETH_FILTER_ADD, + &syn_filter); + } else + ret = rte_eth_dev_filter_ctrl(res->port_id, + RTE_ETH_FILTER_SYN, + RTE_ETH_FILTER_DELETE, + &syn_filter); + if (ret < 0) + printf("syn filter programming error: (%s)\n", + strerror(-ret)); } -cmdline_parse_token_num_t cmd_syn_filter_portid = - TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result, - port_id, UINT8); + +cmdline_parse_token_string_t cmd_syn_filter_filter = + TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result, + filter, "syn_filter"); +cmdline_parse_token_num_t cmd_syn_filter_port_id = + TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result, + port_id, UINT8); +cmdline_parse_token_string_t cmd_syn_filter_ops = + TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result, + ops, "add#del"); cmdline_parse_token_string_t cmd_syn_filter_priority = - TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result, + TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result, priority, "priority"); cmdline_parse_token_string_t cmd_syn_filter_high = - TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result, + TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result, high, "high#low"); cmdline_parse_token_string_t cmd_syn_filter_queue = - TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result, + TOKEN_STRING_INITIALIZER(struct cmd_syn_filter_result, queue, "queue"); cmdline_parse_token_num_t cmd_syn_filter_queue_id = - TOKEN_NUM_INITIALIZER(struct cmd_set_syn_filter_result, + TOKEN_NUM_INITIALIZER(struct cmd_syn_filter_result, queue_id, UINT16); -cmdline_parse_token_string_t cmd_syn_filter_add_filter = - TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result, - filter, "add_syn_filter"); -cmdline_parse_token_string_t cmd_syn_filter_remove_filter = - TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result, - filter, "remove_syn_filter"); -cmdline_parse_inst_t cmd_add_syn_filter = { - .f = cmd_set_syn_filter_parsed, - .data = NULL, - .help_str = "add syn filter", - .tokens = { - (void *)&cmd_syn_filter_add_filter, - (void *)&cmd_syn_filter_portid, - (void *)&cmd_syn_filter_priority, - (void *)&cmd_syn_filter_high, - (void *)&cmd_syn_filter_queue, - (void *)&cmd_syn_filter_queue_id, - NULL, - }, -}; -cmdline_parse_inst_t cmd_remove_syn_filter = { - .f = cmd_set_syn_filter_parsed, - .data = NULL, - .help_str = "remove syn filter", - .tokens = { - (void *)&cmd_syn_filter_remove_filter, - (void *)&cmd_syn_filter_portid, - NULL, - }, -}; - -cmdline_parse_token_string_t cmd_syn_filter_get_filter = - TOKEN_STRING_INITIALIZER(struct cmd_set_syn_filter_result, - filter, "get_syn_filter"); -cmdline_parse_inst_t cmd_get_syn_filter = { - .f = cmd_set_syn_filter_parsed, - .data = NULL, - .help_str = "get syn filter", - .tokens = { - (void *)&cmd_syn_filter_get_filter, - (void *)&cmd_syn_filter_portid, - NULL, - }, +cmdline_parse_inst_t cmd_syn_filter = { + .f = cmd_syn_filter_parsed, + .data = NULL, + .help_str = "add/delete syn filter", + .tokens = { + (void *)&cmd_syn_filter_filter, + (void *)&cmd_syn_filter_port_id, + (void *)&cmd_syn_filter_ops, + (void *)&cmd_syn_filter_priority, + (void *)&cmd_syn_filter_high, + (void *)&cmd_syn_filter_queue, + (void *)&cmd_syn_filter_queue_id, + NULL, + }, }; /* *** ADD/REMOVE A 2tuple FILTER *** */ @@ -9118,9 +9107,7 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_dump, (cmdline_parse_inst_t *)&cmd_dump_one, (cmdline_parse_inst_t *)&cmd_ethertype_filter, - (cmdline_parse_inst_t *)&cmd_add_syn_filter, - (cmdline_parse_inst_t *)&cmd_remove_syn_filter, - (cmdline_parse_inst_t *)&cmd_get_syn_filter, + (cmdline_parse_inst_t *)&cmd_syn_filter, (cmdline_parse_inst_t *)&cmd_add_2tuple_filter, (cmdline_parse_inst_t *)&cmd_remove_2tuple_filter, (cmdline_parse_inst_t *)&cmd_get_2tuple_filter, diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index c40f819..10454ab 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -2166,27 +2166,6 @@ set_vf_rate_limit(portid_t port_id, uint16_t vf, uint16_t rate, uint64_t q_msk) } void -get_syn_filter(uint8_t port_id) -{ - struct rte_syn_filter filter; - int ret = 0; - uint16_t rx_queue; - - memset(&filter, 0, sizeof(filter)); - ret = rte_eth_dev_get_syn_filter(port_id, &filter, &rx_queue); - - if (ret < 0) { - if (ret == (-ENOENT)) - printf("syn filter is not enabled\n"); - else - printf("get syn filter fails(%s)\n", strerror(-ret)); - return; - } - printf("syn filter: priority: %s, queue: %d\n", - filter.hig_pri ? "high" : "low", - rx_queue); -} -void get_2tuple_filter(uint8_t port_id, uint16_t index) { struct rte_2tuple_filter filter; -- 1.9.3