From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 671D75949 for ; Tue, 10 Feb 2015 05:48:58 +0100 (CET) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga101.jf.intel.com with ESMTP; 09 Feb 2015 20:48:57 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,548,1418112000"; d="scan'208";a="525144441" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga003.jf.intel.com with ESMTP; 09 Feb 2015 20:40:51 -0800 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id t1A4mpvV024851; Tue, 10 Feb 2015 12:48:51 +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 t1A4mogL021688; Tue, 10 Feb 2015 12:48:52 +0800 Received: (from wujingji@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id t1A4mocS021684; Tue, 10 Feb 2015 12:48:50 +0800 From: Jingjing Wu To: dev@dpdk.org Date: Tue, 10 Feb 2015 12:48:31 +0800 Message-Id: <1423543713-21624-5-git-send-email-jingjing.wu@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1423543713-21624-1-git-send-email-jingjing.wu@intel.com> References: <1421912305-2022-1-git-send-email-jingjing.wu@intel.com> <1423543713-21624-1-git-send-email-jingjing.wu@intel.com> Subject: [dpdk-dev] [PATCH v3 4/6] testpmd: new commands for ntuple 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: Tue, 10 Feb 2015 04:48:59 -0000 Following commands of 5tuple and 2tuple filter are removed: - add_2tuple_filter (port_id) protocol (pro_value) (pro_mask) dst_port (port_value) (port_mask) flags (flg_value) priority (prio_value) queue (queue_id) index (idx) - remove_2tuple_filter (port_id) index (idx) - get_2tuple_filter (port_id) index (idx) - add_5tuple_filter (port_id) dst_ip (dst_address) src_ip (src_address) dst_port (dst_port_value) src_port (src_port_value) protocol (protocol_value) mask (mask_value) flags (flags_value) priority (prio_value)" queue (queue_id) index (idx) - remove_5tuple_filter (port_id) index (idx) - get_5tuple_filter (port_id) index (idx) New commands are added for 5tuple and 2tuple filter by using filter_ctrl API and new ntuple filter structure: - 2tuple_filter (port_id) (add|del) dst_port (dst_port_value) protocol (protocol_value) mask (mask_value) tcp_flags (tcp_flags_value) priority (prio_value) queue (queue_id) - 5tuple_filter (port_id) (add|del) dst_ip (dst_address) src_ip (src_address) dst_port (dst_port_value) src_port (src_port_value) protocol (protocol_value) mask (mask_value) tcp_flags (tcp_flags_value) priority (prio_value) queue (queue_id) Signed-off-by: Jingjing Wu --- app/test-pmd/cmdline.c | 406 ++++++++++++++++++++++--------------------------- app/test-pmd/config.c | 65 -------- 2 files changed, 186 insertions(+), 285 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 590e427..c96f4d1 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -660,28 +660,19 @@ static void cmd_help_long_parsed(void *parsed_result, " (ether_type) (drop|fwd) queue (queue_id)\n" " Add/Del an ethertype filter.\n\n" - "add_2tuple_filter (port_id) protocol (pro_value) (pro_mask)" - " dst_port (port_value) (port_mask) flags (flg_value) priority (prio_value)" - " queue (queue_id) index (idx)\n" - " add a 2tuple filter.\n\n" - - "remove_2tuple_filter (port_id) index (idx)\n" - " remove a 2tuple filter.\n\n" - - "get_2tuple_filter (port_id) index (idx)\n" - " get info of a 2tuple filter.\n\n" - - "add_5tuple_filter (port_id) dst_ip (dst_address) src_ip (src_address)" - " dst_port (dst_port_value) src_port (src_port_value) protocol (protocol_value)" - " mask (mask_value) flags (flags_value) priority (prio_value)" - " queue (queue_id) index (idx)\n" - " add a 5tuple filter.\n\n" - - "remove_5tuple_filter (port_id) index (idx)\n" - " remove a 5tuple filter.\n\n" - - "get_5tuple_filter (port_id) index (idx)\n" - " get info of a 5tuple filter.\n\n" + "2tuple_filter (port_id) (add|del)" + " dst_port (dst_port_value) protocol (protocol_value)" + " mask (mask_value) tcp_flags (tcp_flags_value)" + " priority (prio_value) queue (queue_id)\n" + " Add/Del a 2tuple filter.\n\n" + + "5tuple_filter (port_id) (add|del)" + " dst_ip (dst_address) src_ip (src_address)" + " dst_port (dst_port_value) src_port (src_port_value)" + " protocol (protocol_value)" + " mask (mask_value) tcp_flags (tcp_flags_value)" + " priority (prio_value) queue (queue_id)\n" + " Add/Del a 5tuple filter.\n\n" "add_syn_filter (port_id) priority (high|low) queue (queue_id)" " add syn filter.\n\n" @@ -7373,21 +7364,20 @@ cmdline_parse_inst_t cmd_get_syn_filter = { /* *** ADD/REMOVE A 2tuple FILTER *** */ struct cmd_2tuple_filter_result { cmdline_fixed_string_t filter; - uint8_t port_id; - cmdline_fixed_string_t protocol; - uint8_t protocol_value; - uint8_t protocol_mask; + uint8_t port_id; + cmdline_fixed_string_t ops; cmdline_fixed_string_t dst_port; uint16_t dst_port_value; - uint16_t dst_port_mask; - cmdline_fixed_string_t flags; - uint8_t flags_value; + cmdline_fixed_string_t protocol; + uint8_t protocol_value; + cmdline_fixed_string_t mask; + uint8_t mask_value; + cmdline_fixed_string_t tcp_flags; + uint8_t tcp_flags_value; cmdline_fixed_string_t priority; - uint8_t priority_value; + uint8_t priority_value; cmdline_fixed_string_t queue; - uint16_t queue_id; - cmdline_fixed_string_t index; - uint16_t index_value; + uint16_t queue_id; }; static void @@ -7395,59 +7385,92 @@ cmd_2tuple_filter_parsed(void *parsed_result, __attribute__((unused)) struct cmdline *cl, __attribute__((unused)) void *data) { - int ret = 0; - struct rte_2tuple_filter filter; + struct rte_eth_ntuple_filter filter; struct cmd_2tuple_filter_result *res = parsed_result; + int ret = 0; - memset(&filter, 0, sizeof(struct rte_2tuple_filter)); + ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE); + if (ret < 0) { + printf("ntuple filter is not supported on port %u.\n", + res->port_id); + return; + } - if (!strcmp(res->filter, "add_2tuple_filter")) { - /* need convert to big endian. */ - filter.dst_port = rte_cpu_to_be_16(res->dst_port_value); - filter.protocol = res->protocol_value; - filter.dst_port_mask = (res->dst_port_mask) ? 0 : 1; - filter.protocol_mask = (res->protocol_mask) ? 0 : 1; - filter.priority = res->priority_value; - filter.tcp_flags = res->flags_value; - ret = rte_eth_dev_add_2tuple_filter(res->port_id, - res->index_value, &filter, res->queue_id); - } else if (!strcmp(res->filter, "remove_2tuple_filter")) - ret = rte_eth_dev_remove_2tuple_filter(res->port_id, - res->index_value); - else if (!strcmp(res->filter, "get_2tuple_filter")) - get_2tuple_filter(res->port_id, res->index_value); + memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter)); + filter.flags = RTE_2TUPLE_FLAGS; + filter.dst_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0; + filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0; + filter.proto = res->protocol_value; + filter.priority = res->priority_value; + if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) { + printf("nonzero tcp_flags is only meaningful" + " when protocol is TCP.\n"); + return; + } + if (res->tcp_flags_value > TCP_FLAG_ALL) { + printf("invalid TCP flags.\n"); + return; + } + + if (res->tcp_flags_value != 0) { + filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG; + filter.tcp_flags = res->tcp_flags_value; + } + + /* need convert to big endian. */ + filter.dst_port = rte_cpu_to_be_16(res->dst_port_value); + filter.queue = res->queue_id; + + if (!strcmp(res->ops, "add")) + ret = rte_eth_dev_filter_ctrl(res->port_id, + RTE_ETH_FILTER_NTUPLE, + RTE_ETH_FILTER_ADD, + &filter); + else + ret = rte_eth_dev_filter_ctrl(res->port_id, + RTE_ETH_FILTER_NTUPLE, + RTE_ETH_FILTER_DELETE, + &filter); if (ret < 0) - printf("2tuple filter setting error: (%s)\n", strerror(-ret)); + printf("2tuple filter programming error: (%s)\n", + strerror(-ret)); + } +cmdline_parse_token_string_t cmd_2tuple_filter_filter = + TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, + filter, "2tuple_filter"); cmdline_parse_token_num_t cmd_2tuple_filter_port_id = TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, port_id, UINT8); -cmdline_parse_token_string_t cmd_2tuple_filter_protocol = +cmdline_parse_token_string_t cmd_2tuple_filter_ops = TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, - protocol, "protocol"); -cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value = - TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, - protocol_value, UINT8); -cmdline_parse_token_num_t cmd_2tuple_filter_protocol_mask = - TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, - protocol_mask, UINT8); + ops, "add#del"); cmdline_parse_token_string_t cmd_2tuple_filter_dst_port = TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, dst_port, "dst_port"); cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_value = TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, dst_port_value, UINT16); -cmdline_parse_token_num_t cmd_2tuple_filter_dst_port_mask = +cmdline_parse_token_string_t cmd_2tuple_filter_protocol = + TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, + protocol, "protocol"); +cmdline_parse_token_num_t cmd_2tuple_filter_protocol_value = TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, - dst_port_mask, UINT16); -cmdline_parse_token_string_t cmd_2tuple_filter_flags = + protocol_value, UINT8); +cmdline_parse_token_string_t cmd_2tuple_filter_mask = TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, - flags, "flags"); -cmdline_parse_token_num_t cmd_2tuple_filter_flags_value = + mask, "mask"); +cmdline_parse_token_num_t cmd_2tuple_filter_mask_value = TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, - flags_value, UINT8); + mask_value, INT8); +cmdline_parse_token_string_t cmd_2tuple_filter_tcp_flags = + TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, + tcp_flags, "tcp_flags"); +cmdline_parse_token_num_t cmd_2tuple_filter_tcp_flags_value = + TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, + tcp_flags_value, UINT8); cmdline_parse_token_string_t cmd_2tuple_filter_priority = TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, priority, "priority"); @@ -7460,67 +7483,27 @@ cmdline_parse_token_string_t cmd_2tuple_filter_queue = cmdline_parse_token_num_t cmd_2tuple_filter_queue_id = TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, queue_id, UINT16); -cmdline_parse_token_string_t cmd_2tuple_filter_index = - TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, - index, "index"); -cmdline_parse_token_num_t cmd_2tuple_filter_index_value = - TOKEN_NUM_INITIALIZER(struct cmd_2tuple_filter_result, - index_value, UINT16); -cmdline_parse_token_string_t cmd_2tuple_filter_add_filter = - TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, - filter, "add_2tuple_filter"); -cmdline_parse_inst_t cmd_add_2tuple_filter = { + +cmdline_parse_inst_t cmd_2tuple_filter = { .f = cmd_2tuple_filter_parsed, .data = NULL, .help_str = "add a 2tuple filter", .tokens = { - (void *)&cmd_2tuple_filter_add_filter, + (void *)&cmd_2tuple_filter_filter, (void *)&cmd_2tuple_filter_port_id, - (void *)&cmd_2tuple_filter_protocol, - (void *)&cmd_2tuple_filter_protocol_value, - (void *)&cmd_2tuple_filter_protocol_mask, + (void *)&cmd_2tuple_filter_ops, (void *)&cmd_2tuple_filter_dst_port, (void *)&cmd_2tuple_filter_dst_port_value, - (void *)&cmd_2tuple_filter_dst_port_mask, - (void *)&cmd_2tuple_filter_flags, - (void *)&cmd_2tuple_filter_flags_value, + (void *)&cmd_2tuple_filter_protocol, + (void *)&cmd_2tuple_filter_protocol_value, + (void *)&cmd_2tuple_filter_mask, + (void *)&cmd_2tuple_filter_mask_value, + (void *)&cmd_2tuple_filter_tcp_flags, + (void *)&cmd_2tuple_filter_tcp_flags_value, (void *)&cmd_2tuple_filter_priority, (void *)&cmd_2tuple_filter_priority_value, (void *)&cmd_2tuple_filter_queue, (void *)&cmd_2tuple_filter_queue_id, - (void *)&cmd_2tuple_filter_index, - (void *)&cmd_2tuple_filter_index_value, - NULL, - }, -}; - -cmdline_parse_token_string_t cmd_2tuple_filter_remove_filter = - TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, - filter, "remove_2tuple_filter"); -cmdline_parse_inst_t cmd_remove_2tuple_filter = { - .f = cmd_2tuple_filter_parsed, - .data = NULL, - .help_str = "remove a 2tuple filter", - .tokens = { - (void *)&cmd_2tuple_filter_remove_filter, - (void *)&cmd_2tuple_filter_port_id, - (void *)&cmd_2tuple_filter_index, - (void *)&cmd_2tuple_filter_index_value, - NULL, - }, -}; -cmdline_parse_token_string_t cmd_2tuple_filter_get_filter = - TOKEN_STRING_INITIALIZER(struct cmd_2tuple_filter_result, - filter, "get_2tuple_filter"); -cmdline_parse_inst_t cmd_get_2tuple_filter = { - .f = cmd_2tuple_filter_parsed, - .data = NULL, - .help_str = "get a 2tuple filter", - .tokens = { - (void *)&cmd_2tuple_filter_get_filter, - (void *)&cmd_2tuple_filter_port_id, - (void *)&cmd_2tuple_filter_index, - (void *)&cmd_2tuple_filter_index_value, NULL, }, }; @@ -7529,6 +7512,7 @@ cmdline_parse_inst_t cmd_get_2tuple_filter = { struct cmd_5tuple_filter_result { cmdline_fixed_string_t filter; uint8_t port_id; + cmdline_fixed_string_t ops; cmdline_fixed_string_t dst_ip; cmdline_ipaddr_t dst_ip_value; cmdline_fixed_string_t src_ip; @@ -7541,14 +7525,12 @@ struct cmd_5tuple_filter_result { uint8_t protocol_value; cmdline_fixed_string_t mask; uint8_t mask_value; - cmdline_fixed_string_t flags; - uint8_t flags_value; + cmdline_fixed_string_t tcp_flags; + uint8_t tcp_flags_value; cmdline_fixed_string_t priority; uint8_t priority_value; cmdline_fixed_string_t queue; uint16_t queue_id; - cmdline_fixed_string_t index; - uint16_t index_value; }; static void @@ -7556,62 +7538,92 @@ cmd_5tuple_filter_parsed(void *parsed_result, __attribute__((unused)) struct cmdline *cl, __attribute__((unused)) void *data) { - int ret = 0; - struct rte_5tuple_filter filter; + struct rte_eth_ntuple_filter filter; struct cmd_5tuple_filter_result *res = parsed_result; + int ret = 0; - memset(&filter, 0, sizeof(struct rte_5tuple_filter)); + ret = rte_eth_dev_filter_supported(res->port_id, RTE_ETH_FILTER_NTUPLE); + if (ret < 0) { + printf("ntuple filter is not supported on port %u.\n", + res->port_id); + return; + } - if (!strcmp(res->filter, "add_5tuple_filter")) { - filter.dst_ip_mask = (res->mask_value & 0x10) ? 0 : 1; - filter.src_ip_mask = (res->mask_value & 0x08) ? 0 : 1; - filter.dst_port_mask = (res->mask_value & 0x04) ? 0 : 1; - filter.src_port_mask = (res->mask_value & 0x02) ? 0 : 1; - filter.protocol = res->protocol_value; - filter.protocol_mask = (res->mask_value & 0x01) ? 0 : 1; - filter.priority = res->priority_value; - filter.tcp_flags = res->flags_value; + memset(&filter, 0, sizeof(struct rte_eth_ntuple_filter)); + + filter.flags = RTE_5TUPLE_FLAGS; + filter.dst_ip_mask = (res->mask_value & 0x10) ? UINT32_MAX : 0; + filter.src_ip_mask = (res->mask_value & 0x08) ? UINT32_MAX : 0; + filter.dst_port_mask = (res->mask_value & 0x04) ? UINT16_MAX : 0; + filter.src_port_mask = (res->mask_value & 0x02) ? UINT16_MAX : 0; + filter.proto_mask = (res->mask_value & 0x01) ? UINT8_MAX : 0; + filter.proto = res->protocol_value; + filter.priority = res->priority_value; + if (res->tcp_flags_value != 0 && filter.proto != IPPROTO_TCP) { + printf("nonzero tcp_flags is only meaningful" + " when protocol is TCP.\n"); + return; + } + if (res->tcp_flags_value > TCP_FLAG_ALL) { + printf("invalid TCP flags.\n"); + return; + } - if (res->dst_ip_value.family == AF_INET) - /* no need to convert, already big endian. */ - filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr; - else { - if (filter.dst_ip_mask == 0) { - printf("can not support ipv6 involved compare.\n"); - return; - } - filter.dst_ip = 0; + if (res->tcp_flags_value != 0) { + filter.flags |= RTE_NTUPLE_FLAGS_TCP_FLAG; + filter.tcp_flags = res->tcp_flags_value; + } + + if (res->dst_ip_value.family == AF_INET) + /* no need to convert, already big endian. */ + filter.dst_ip = res->dst_ip_value.addr.ipv4.s_addr; + else { + if (filter.dst_ip_mask == 0) { + printf("can not support ipv6 involved compare.\n"); + return; } + filter.dst_ip = 0; + } - if (res->src_ip_value.family == AF_INET) - /* no need to convert, already big endian. */ - filter.src_ip = res->src_ip_value.addr.ipv4.s_addr; - else { - if (filter.src_ip_mask == 0) { - printf("can not support ipv6 involved compare.\n"); - return; - } - filter.src_ip = 0; + if (res->src_ip_value.family == AF_INET) + /* no need to convert, already big endian. */ + filter.src_ip = res->src_ip_value.addr.ipv4.s_addr; + else { + if (filter.src_ip_mask == 0) { + printf("can not support ipv6 involved compare.\n"); + return; } - /* need convert to big endian. */ - filter.dst_port = rte_cpu_to_be_16(res->dst_port_value); - filter.src_port = rte_cpu_to_be_16(res->src_port_value); + filter.src_ip = 0; + } + /* need convert to big endian. */ + filter.dst_port = rte_cpu_to_be_16(res->dst_port_value); + filter.src_port = rte_cpu_to_be_16(res->src_port_value); + filter.queue = res->queue_id; - ret = rte_eth_dev_add_5tuple_filter(res->port_id, - res->index_value, &filter, res->queue_id); - } else if (!strcmp(res->filter, "remove_5tuple_filter")) - ret = rte_eth_dev_remove_5tuple_filter(res->port_id, - res->index_value); - else if (!strcmp(res->filter, "get_5tuple_filter")) - get_5tuple_filter(res->port_id, res->index_value); + if (!strcmp(res->ops, "add")) + ret = rte_eth_dev_filter_ctrl(res->port_id, + RTE_ETH_FILTER_NTUPLE, + RTE_ETH_FILTER_ADD, + &filter); + else + ret = rte_eth_dev_filter_ctrl(res->port_id, + RTE_ETH_FILTER_NTUPLE, + RTE_ETH_FILTER_DELETE, + &filter); if (ret < 0) - printf("5tuple filter setting error: (%s)\n", strerror(-ret)); + printf("5tuple filter programming error: (%s)\n", + strerror(-ret)); } - +cmdline_parse_token_string_t cmd_5tuple_filter_filter = + TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, + filter, "5tuple_filter"); cmdline_parse_token_num_t cmd_5tuple_filter_port_id = TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, port_id, UINT8); +cmdline_parse_token_string_t cmd_5tuple_filter_ops = + TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, + ops, "add#del"); cmdline_parse_token_string_t cmd_5tuple_filter_dst_ip = TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, dst_ip, "dst_ip"); @@ -7648,12 +7660,12 @@ cmdline_parse_token_string_t cmd_5tuple_filter_mask = cmdline_parse_token_num_t cmd_5tuple_filter_mask_value = TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, mask_value, INT8); -cmdline_parse_token_string_t cmd_5tuple_filter_flags = +cmdline_parse_token_string_t cmd_5tuple_filter_tcp_flags = TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, - flags, "flags"); -cmdline_parse_token_num_t cmd_5tuple_filter_flags_value = + tcp_flags, "tcp_flags"); +cmdline_parse_token_num_t cmd_5tuple_filter_tcp_flags_value = TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, - flags_value, UINT8); + tcp_flags_value, UINT8); cmdline_parse_token_string_t cmd_5tuple_filter_priority = TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, priority, "priority"); @@ -7666,23 +7678,15 @@ cmdline_parse_token_string_t cmd_5tuple_filter_queue = cmdline_parse_token_num_t cmd_5tuple_filter_queue_id = TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, queue_id, UINT16); -cmdline_parse_token_string_t cmd_5tuple_filter_index = - TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, - index, "index"); -cmdline_parse_token_num_t cmd_5tuple_filter_index_value = - TOKEN_NUM_INITIALIZER(struct cmd_5tuple_filter_result, - index_value, UINT16); -cmdline_parse_token_string_t cmd_5tuple_filter_add_filter = - TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, - filter, "add_5tuple_filter"); -cmdline_parse_inst_t cmd_add_5tuple_filter = { +cmdline_parse_inst_t cmd_5tuple_filter = { .f = cmd_5tuple_filter_parsed, .data = NULL, - .help_str = "add a 5tuple filter", + .help_str = "add/del a 5tuple filter", .tokens = { - (void *)&cmd_5tuple_filter_add_filter, + (void *)&cmd_5tuple_filter_filter, (void *)&cmd_5tuple_filter_port_id, + (void *)&cmd_5tuple_filter_ops, (void *)&cmd_5tuple_filter_dst_ip, (void *)&cmd_5tuple_filter_dst_ip_value, (void *)&cmd_5tuple_filter_src_ip, @@ -7695,46 +7699,12 @@ cmdline_parse_inst_t cmd_add_5tuple_filter = { (void *)&cmd_5tuple_filter_protocol_value, (void *)&cmd_5tuple_filter_mask, (void *)&cmd_5tuple_filter_mask_value, - (void *)&cmd_5tuple_filter_flags, - (void *)&cmd_5tuple_filter_flags_value, + (void *)&cmd_5tuple_filter_tcp_flags, + (void *)&cmd_5tuple_filter_tcp_flags_value, (void *)&cmd_5tuple_filter_priority, (void *)&cmd_5tuple_filter_priority_value, (void *)&cmd_5tuple_filter_queue, (void *)&cmd_5tuple_filter_queue_id, - (void *)&cmd_5tuple_filter_index, - (void *)&cmd_5tuple_filter_index_value, - NULL, - }, -}; - -cmdline_parse_token_string_t cmd_5tuple_filter_remove_filter = - TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, - filter, "remove_5tuple_filter"); -cmdline_parse_inst_t cmd_remove_5tuple_filter = { - .f = cmd_5tuple_filter_parsed, - .data = NULL, - .help_str = "remove a 5tuple filter", - .tokens = { - (void *)&cmd_5tuple_filter_remove_filter, - (void *)&cmd_5tuple_filter_port_id, - (void *)&cmd_5tuple_filter_index, - (void *)&cmd_5tuple_filter_index_value, - NULL, - }, -}; - -cmdline_parse_token_string_t cmd_5tuple_filter_get_filter = - TOKEN_STRING_INITIALIZER(struct cmd_5tuple_filter_result, - filter, "get_5tuple_filter"); -cmdline_parse_inst_t cmd_get_5tuple_filter = { - .f = cmd_5tuple_filter_parsed, - .data = NULL, - .help_str = "get a 5tuple filter", - .tokens = { - (void *)&cmd_5tuple_filter_get_filter, - (void *)&cmd_5tuple_filter_port_id, - (void *)&cmd_5tuple_filter_index, - (void *)&cmd_5tuple_filter_index_value, NULL, }, }; @@ -9121,12 +9091,8 @@ cmdline_parse_ctx_t main_ctx[] = { (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_add_2tuple_filter, - (cmdline_parse_inst_t *)&cmd_remove_2tuple_filter, - (cmdline_parse_inst_t *)&cmd_get_2tuple_filter, - (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_2tuple_filter, + (cmdline_parse_inst_t *)&cmd_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, diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index c40f819..441ad93 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -2186,73 +2186,8 @@ get_syn_filter(uint8_t port_id) filter.hig_pri ? "high" : "low", rx_queue); } -void -get_2tuple_filter(uint8_t port_id, uint16_t index) -{ - struct rte_2tuple_filter filter; - int ret = 0; - uint16_t rx_queue; - - memset(&filter, 0, sizeof(filter)); - ret = rte_eth_dev_get_2tuple_filter(port_id, index, - &filter, &rx_queue); - if (ret < 0) { - if (ret == (-ENOENT)) - printf("filter[%d] is not enabled\n", index); - else - printf("get 2tuple filter fails(%s)\n", strerror(-ret)); - return; - } else { - printf("filter[%d]:\n", index); - printf(" Destination Port: 0x%04x mask: %d\n", - rte_be_to_cpu_16(filter.dst_port), - filter.dst_port_mask ? 0 : 1); - printf(" protocol: 0x%02x mask:%d tcp_flags: 0x%02x\n", - filter.protocol, filter.protocol_mask ? 0 : 1, - filter.tcp_flags); - printf(" priority: %d queue: %d\n", - filter.priority, rx_queue); - } -} void -get_5tuple_filter(uint8_t port_id, uint16_t index) -{ - struct rte_5tuple_filter filter; - int ret = 0; - uint16_t rx_queue; - - memset(&filter, 0, sizeof(filter)); - ret = rte_eth_dev_get_5tuple_filter(port_id, index, - &filter, &rx_queue); - if (ret < 0) { - if (ret == (-ENOENT)) - printf("filter[%d] is not enabled\n", index); - else - printf("get 5tuple filter fails(%s)\n", strerror(-ret)); - return; - } else { - printf("filter[%d]:\n", index); - printf(" Destination IP: 0x%08x mask: %d\n", - (unsigned)rte_be_to_cpu_32(filter.dst_ip), - filter.dst_ip_mask ? 0 : 1); - printf(" Source IP: 0x%08x mask: %d\n", - (unsigned)rte_be_to_cpu_32(filter.src_ip), - filter.src_ip_mask ? 0 : 1); - printf(" Destination Port: 0x%04x mask: %d\n", - rte_be_to_cpu_16(filter.dst_port), - filter.dst_port_mask ? 0 : 1); - printf(" Source Port: 0x%04x mask: %d\n", - rte_be_to_cpu_16(filter.src_port), - filter.src_port_mask ? 0 : 1); - printf(" protocol: 0x%02x mask: %d\n", - filter.protocol, - filter.protocol_mask ? 0 : 1); - printf(" priority: %d flags: 0x%02x queue: %d\n", - filter.priority, filter.tcp_flags, rx_queue); - } -} -void get_flex_filter(uint8_t port_id, uint16_t index) { -- 1.9.3