From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 6DF6FB789 for ; Sat, 21 Feb 2015 02:53:17 +0100 (CET) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga101.fm.intel.com with ESMTP; 20 Feb 2015 17:53:15 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.09,618,1418112000"; d="scan'208";a="655087236" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by orsmga001.jf.intel.com with ESMTP; 20 Feb 2015 17:53:14 -0800 Received: from sivswdev02.ir.intel.com (sivswdev02.ir.intel.com [10.237.217.46]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id t1L1rCcU029672; Sat, 21 Feb 2015 01:53:12 GMT Received: from sivswdev02.ir.intel.com (localhost [127.0.0.1]) by sivswdev02.ir.intel.com with ESMTP id t1L1rCHP026020; Sat, 21 Feb 2015 01:53:12 GMT Received: (from pdelarax@localhost) by sivswdev02.ir.intel.com with id t1L1rCsC026016; Sat, 21 Feb 2015 01:53:12 GMT From: Pablo de Lara To: dev@dpdk.org Date: Sat, 21 Feb 2015 01:53:09 +0000 Message-Id: <1424483591-25944-4-git-send-email-pablo.de.lara.guarch@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1424483591-25944-1-git-send-email-pablo.de.lara.guarch@intel.com> References: <1423973254-605-1-git-send-email-jingjing.wu@intel.com> <1424483591-25944-1-git-send-email-pablo.de.lara.guarch@intel.com> Subject: [dpdk-dev] [PATCH v3 3/5] testpmd: new commands for flex 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: Sat, 21 Feb 2015 01:53:18 -0000 From: Jingjing Wu Following commands of flex filter are removed: - add_flex_filter (port_id) len (len_value) bytes (bytes_string) mask (mask_value) priority (prio_value) queue (queue_id) - remove_flex_filter (port_id) index (idx) - get_flex_filter (port_id) index (idx) New command is added for flex filter by using filter_ctrl API and new flex filter structure: - flex_filter (port_id) (add|del) len (len_value) bytes (bytes_value) mask (mask_value) priority (prio_value) queue (queue_id) Signed-off-by: Jingjing Wu --- app/test-pmd/cmdline.c | 239 ++++++++++++++++++------------------------------ app/test-pmd/config.c | 33 ------- app/test-pmd/testpmd.h | 1 - 3 files changed, 91 insertions(+), 182 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index d37610a..ca2ff62 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -698,15 +698,10 @@ static void cmd_help_long_parsed(void *parsed_result, "get_syn_filter (port_id) " " get syn filter info.\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" - " add a flex filter.\n\n" - - "remove_flex_filter (port_id) index (idx)\n" - " remove a flex filter.\n\n" - - "get_flex_filter (port_id) index (idx)\n" - " get info of a flex filter.\n\n" + "flex_filter (port_id) (add|del) len (len_value)" + " bytes (bytes_value) mask (mask_value)" + " priority (prio_value) queue (queue_id)\n" + " Add/Del a flex filter.\n\n" "flow_director_filter (port_id) (add|del)" " flow (ip4|ip4-frag|ip6|ip6-frag)" @@ -7828,6 +7823,7 @@ cmdline_parse_inst_t cmd_get_5tuple_filter = { /* *** ADD/REMOVE A flex FILTER *** */ struct cmd_flex_filter_result { cmdline_fixed_string_t filter; + cmdline_fixed_string_t ops; uint8_t port_id; cmdline_fixed_string_t len; uint8_t len_value; @@ -7839,8 +7835,6 @@ struct cmd_flex_filter_result { uint8_t priority_value; cmdline_fixed_string_t queue; uint16_t queue_id; - cmdline_fixed_string_t index; - uint16_t index_value; }; static int xdigit2val(unsigned char c) @@ -7861,113 +7855,106 @@ cmd_flex_filter_parsed(void *parsed_result, __attribute__((unused)) void *data) { int ret = 0; - struct rte_flex_filter filter; + struct rte_eth_flex_filter filter; struct cmd_flex_filter_result *res = parsed_result; char *bytes_ptr, *mask_ptr; - uint16_t len, i, j; + uint16_t len, i, j = 0; char c; - int val, mod = 0; - uint32_t dword = 0; + int val; uint8_t byte = 0; - uint8_t hex = 0; - if (!strcmp(res->filter, "add_flex_filter")) { - if (res->len_value > 128) { - printf("the len exceed the max length 128\n"); - return; - } - memset(&filter, 0, sizeof(struct rte_flex_filter)); - filter.len = res->len_value; - filter.priority = res->priority_value; - bytes_ptr = res->bytes_value; - mask_ptr = res->mask_value; - - j = 0; - /* translate bytes string to uint_32 array. */ - if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') || - (bytes_ptr[1] == 'X'))) - bytes_ptr += 2; - len = strnlen(bytes_ptr, res->len_value * 2); - if (len == 0 || (len % 8 != 0)) { - printf("please check len and bytes input\n"); + if (res->len_value > RTE_FLEX_FILTER_MAXLEN) { + printf("the len exceed the max length 128\n"); + return; + } + memset(&filter, 0, sizeof(struct rte_eth_flex_filter)); + filter.len = res->len_value; + filter.priority = res->priority_value; + filter.queue = res->queue_id; + bytes_ptr = res->bytes_value; + mask_ptr = res->mask_value; + + /* translate bytes string to array. */ + if (bytes_ptr[0] == '0' && ((bytes_ptr[1] == 'x') || + (bytes_ptr[1] == 'X'))) + bytes_ptr += 2; + len = strnlen(bytes_ptr, res->len_value * 2); + if (len == 0 || (len % 8 != 0)) { + printf("please check len and bytes input\n"); + return; + } + for (i = 0; i < len; i++) { + c = bytes_ptr[i]; + if (isxdigit(c) == 0) { + /* invalid characters. */ + printf("invalid input\n"); return; } - for (i = 0; i < len; i++) { - c = bytes_ptr[i]; - if (isxdigit(c) == 0) { - /* invalid characters. */ - printf("invalid input\n"); - return; - } - val = xdigit2val(c); - mod = i % 8; - if (i % 2) { - byte |= val; - dword |= byte << (4 * mod - 4); - byte = 0; - } else - byte |= val << 4; - if (mod == 7) { - filter.dwords[j] = dword; - printf("dwords[%d]:%08x ", j, filter.dwords[j]); - j++; - dword = 0; - } - } - printf("\n"); - /* translate mask string to uint8_t array. */ - j = 0; - if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') || - (mask_ptr[1] == 'X'))) - mask_ptr += 2; - len = strnlen(mask_ptr, (res->len_value+3)/4); - if (len == 0) { + val = xdigit2val(c); + if (i % 2) { + byte |= val; + filter.bytes[j] = byte; + printf("bytes[%d]:%02x ", j, filter.bytes[j]); + j++; + byte = 0; + } else + byte |= val << 4; + } + printf("\n"); + /* translate mask string to uint8_t array. */ + if (mask_ptr[0] == '0' && ((mask_ptr[1] == 'x') || + (mask_ptr[1] == 'X'))) + mask_ptr += 2; + len = strnlen(mask_ptr, (res->len_value + 3) / 4); + if (len == 0) { + printf("invalid input\n"); + return; + } + j = 0; + byte = 0; + for (i = 0; i < len; i++) { + c = mask_ptr[i]; + if (isxdigit(c) == 0) { + /* invalid characters. */ printf("invalid input\n"); return; } - for (i = 0; i < len; i++) { - c = mask_ptr[i]; - if (isxdigit(c) == 0) { - /* invalid characters. */ - printf("invalid input\n"); - return; - } - val = xdigit2val(c); - hex |= (uint8_t)(val & 0x8) >> 3; - hex |= (uint8_t)(val & 0x4) >> 1; - hex |= (uint8_t)(val & 0x2) << 1; - hex |= (uint8_t)(val & 0x1) << 3; - if (i % 2) { - byte |= hex << 4; - filter.mask[j] = byte; - printf("mask[%d]:%02x ", j, filter.mask[j]); - j++; - byte = 0; - } else - byte |= hex; - hex = 0; - } - printf("\n"); - printf("call function rte_eth_dev_add_flex_filter: " - "index = %d, queue-id = %d, len = %d, priority = %d\n", - res->index_value, res->queue_id, - filter.len, filter.priority); - ret = rte_eth_dev_add_flex_filter(res->port_id, res->index_value, - &filter, res->queue_id); + val = xdigit2val(c); + if (i % 2) { + byte |= val; + filter.mask[j] = byte; + printf("mask[%d]:%02x ", j, filter.mask[j]); + j++; + byte = 0; + } else + byte |= val << 4; + } + printf("\n"); - } else if (!strcmp(res->filter, "remove_flex_filter")) - ret = rte_eth_dev_remove_flex_filter(res->port_id, - res->index_value); - else if (!strcmp(res->filter, "get_flex_filter")) - get_flex_filter(res->port_id, res->index_value); + if (!strcmp(res->ops, "add")) + ret = rte_eth_dev_filter_ctrl(res->port_id, + RTE_ETH_FILTER_FLEXIBLE, + RTE_ETH_FILTER_ADD, + &filter); + else + ret = rte_eth_dev_filter_ctrl(res->port_id, + RTE_ETH_FILTER_FLEXIBLE, + RTE_ETH_FILTER_DELETE, + &filter); if (ret < 0) printf("flex filter setting error: (%s)\n", strerror(-ret)); } +cmdline_parse_token_string_t cmd_flex_filter_filter = + TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, + filter, "flex_filter"); cmdline_parse_token_num_t cmd_flex_filter_port_id = TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result, port_id, UINT8); +cmdline_parse_token_string_t cmd_flex_filter_ops = + TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, + ops, "add#del"); cmdline_parse_token_string_t cmd_flex_filter_len = TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, len, "len"); @@ -7998,22 +7985,14 @@ cmdline_parse_token_string_t cmd_flex_filter_queue = cmdline_parse_token_num_t cmd_flex_filter_queue_id = TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result, queue_id, UINT16); -cmdline_parse_token_string_t cmd_flex_filter_index = - TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, - index, "index"); -cmdline_parse_token_num_t cmd_flex_filter_index_value = - TOKEN_NUM_INITIALIZER(struct cmd_flex_filter_result, - index_value, UINT16); -cmdline_parse_token_string_t cmd_flex_filter_add_filter = - TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, - filter, "add_flex_filter"); -cmdline_parse_inst_t cmd_add_flex_filter = { +cmdline_parse_inst_t cmd_flex_filter = { .f = cmd_flex_filter_parsed, .data = NULL, - .help_str = "add a flex filter", + .help_str = "add/del a flex filter", .tokens = { - (void *)&cmd_flex_filter_add_filter, + (void *)&cmd_flex_filter_filter, (void *)&cmd_flex_filter_port_id, + (void *)&cmd_flex_filter_ops, (void *)&cmd_flex_filter_len, (void *)&cmd_flex_filter_len_value, (void *)&cmd_flex_filter_bytes, @@ -8024,40 +8003,6 @@ cmdline_parse_inst_t cmd_add_flex_filter = { (void *)&cmd_flex_filter_priority_value, (void *)&cmd_flex_filter_queue, (void *)&cmd_flex_filter_queue_id, - (void *)&cmd_flex_filter_index, - (void *)&cmd_flex_filter_index_value, - NULL, - }, -}; - -cmdline_parse_token_string_t cmd_flex_filter_remove_filter = - TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, - filter, "remove_flex_filter"); -cmdline_parse_inst_t cmd_remove_flex_filter = { - .f = cmd_flex_filter_parsed, - .data = NULL, - .help_str = "remove a flex filter", - .tokens = { - (void *)&cmd_flex_filter_remove_filter, - (void *)&cmd_flex_filter_port_id, - (void *)&cmd_flex_filter_index, - (void *)&cmd_flex_filter_index_value, - NULL, - }, -}; - -cmdline_parse_token_string_t cmd_flex_filter_get_filter = - TOKEN_STRING_INITIALIZER(struct cmd_flex_filter_result, - filter, "get_flex_filter"); -cmdline_parse_inst_t cmd_get_flex_filter = { - .f = cmd_flex_filter_parsed, - .data = NULL, - .help_str = "get a flex filter", - .tokens = { - (void *)&cmd_flex_filter_get_filter, - (void *)&cmd_flex_filter_port_id, - (void *)&cmd_flex_filter_index, - (void *)&cmd_flex_filter_index_value, NULL, }, }; @@ -9214,9 +9159,7 @@ cmdline_parse_ctx_t main_ctx[] = { (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_add_flex_filter, - (cmdline_parse_inst_t *)&cmd_remove_flex_filter, - (cmdline_parse_inst_t *)&cmd_get_flex_filter, + (cmdline_parse_inst_t *)&cmd_flex_filter, (cmdline_parse_inst_t *)&cmd_add_del_ip_flow_director, (cmdline_parse_inst_t *)&cmd_add_del_udp_flow_director, (cmdline_parse_inst_t *)&cmd_add_del_sctp_flow_director, diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 6bcd23c..a48aa5c 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -2257,36 +2257,3 @@ get_5tuple_filter(uint8_t port_id, uint16_t index) filter.priority, filter.tcp_flags, rx_queue); } } -void -get_flex_filter(uint8_t port_id, uint16_t index) - -{ - struct rte_flex_filter filter; - int ret = 0; - uint16_t rx_queue; - int i, j; - - memset(&filter, 0, sizeof(filter)); - ret = rte_eth_dev_get_flex_filter(port_id, index, - &filter, &rx_queue); - if (ret < 0) { - if (ret == (-ENOENT)) - printf("filter[%d] is not enabled\n", index); - else - printf("get flex filter fails(%s)\n", strerror(-ret)); - return; - } else { - printf("filter[%d]: ", index); - printf("\n length: %d", filter.len); - printf("\n dword[]: 0x"); - for (i = 0; i < 32; i++) - printf("%08x ", (unsigned)rte_be_to_cpu_32(filter.dwords[i])); - printf("\n mask[]: 0b"); - for (i = 0; i < 16; i++) { - for (j = 0; j < 8; j++) - printf("%c", (filter.mask[i] & (1 << j)) ? '1' : '0'); - } - printf("\n priority: %d queue: %d\n", - filter.priority, rx_queue); - } -} diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index 581130b..1bfaeea 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -564,7 +564,6 @@ void get_syn_filter(uint8_t port_id); void get_ethertype_filter(uint8_t port_id, uint16_t index); void get_2tuple_filter(uint8_t port_id, uint16_t index); void get_5tuple_filter(uint8_t port_id, uint16_t index); -void get_flex_filter(uint8_t port_id, uint16_t index); int port_id_is_invalid(portid_t port_id); int rx_queue_id_is_invalid(queueid_t rxq_id); int tx_queue_id_is_invalid(queueid_t txq_id); -- 1.7.4.1