From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by dpdk.org (Postfix) with ESMTP id 221011B326 for ; Tue, 10 Oct 2017 22:13:40 +0200 (CEST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga104.jf.intel.com with ESMTP; 10 Oct 2017 13:13:40 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.43,359,1503385200"; d="scan'208";a="1180653644" Received: from silpixa00389036.ir.intel.com (HELO silpixa00389036.ger.corp.intel.com) ([10.237.223.231]) by orsmga001.jf.intel.com with ESMTP; 10 Oct 2017 13:13:39 -0700 From: Kirill Rybalchenko To: dev@dpdk.org Cc: kirill.rybalchenko@intel.com, andrey.chilikin@intel.com, beilei.xing@intel.com, jingjing.wu@intel.com Date: Tue, 10 Oct 2017 21:13:31 +0100 Message-Id: <1507666412-15320-4-git-send-email-kirill.rybalchenko@intel.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1507666412-15320-1-git-send-email-kirill.rybalchenko@intel.com> References: <1507236771-85423-1-git-send-email-kirill.rybalchenko@intel.com> <1507666412-15320-1-git-send-email-kirill.rybalchenko@intel.com> Subject: [dpdk-dev] [PATCH v4 3/4] app/testpmd: add raw flow type to flow director X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Oct 2017 20:13:42 -0000 v3: Add raw flow type support to flow_director_filter command v4: Remove unnecessary flexbytes parameter for raw flow type flow director. Add possibility for arbitrary flow type for set_fdir_input_set and set_hash_global_config commands. Signed-off-by: Kirill Rybalchenko --- app/test-pmd/cmdline.c | 99 +++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 77 insertions(+), 22 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index a72679d..0512be0 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -862,6 +862,11 @@ static void cmd_help_long_parsed(void *parsed_result, " queue (queue_id) fd_id (fd_id_value)\n" " Add/Del a Tunnel flow director filter.\n\n" + "flow_director_filter (port_id) mode raw (add|del|update)" + " flow (flow_id) (drop|fwd) pf|vf(vf_id) queue (queue_id)" + " fd_id (fd_id_value) packet (packet file name)\n" + " Add/Del a raw type flow director filter.\n\n" + "flush_flow_director (port_id)\n" " Flush all flow director entries of a device.\n\n" @@ -902,8 +907,8 @@ static void cmd_help_long_parsed(void *parsed_result, "set_hash_global_config (port_id) (toeplitz|simple_xor|default)" " (ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|ipv6|" - "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload)" - " (enable|disable)\n" + "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload|" + ") (enable|disable)\n" " Set the global configurations of hash filters.\n\n" "set_hash_input_set (port_id) (ipv4|ipv4-frag|" @@ -921,7 +926,8 @@ static void cmd_help_long_parsed(void *parsed_result, "set_fdir_input_set (port_id) " "(ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" - "l2_payload) (ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|" + "l2_payload|) " + "(ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|" "dst-ipv6|ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|" "ipv6-next-header|ipv6-hop-limits|udp-src-port|" "udp-dst-port|tcp-src-port|tcp-dst-port|" @@ -9154,6 +9160,8 @@ struct cmd_flow_director_result { cmdline_fixed_string_t tunnel_type; cmdline_fixed_string_t tunnel_id; uint32_t tunnel_id_value; + cmdline_fixed_string_t packet; + char filepath[]; }; static inline int @@ -9280,6 +9288,8 @@ cmd_flow_director_filter_parsed(void *parsed_result, struct rte_eth_fdir_filter entry; uint8_t flexbytes[RTE_ETH_FDIR_MAX_FLEXLEN]; char *end; + uint8_t *raw_packet_buff; + uint32_t raw_packet_size; unsigned long vf_id; int ret = 0; @@ -9303,19 +9313,26 @@ cmd_flow_director_filter_parsed(void *parsed_result, return; } } else { - if (strcmp(res->mode_value, "IP")) { - printf("Please set mode to IP.\n"); + if (!strcmp(res->mode_value, "raw")) { + entry.input.flow_type = RTE_ETH_FLOW_RAW; + entry.input.flow.raw_flow.flow = + str2flowtype(res->flow_type); + } else if (!strcmp(res->mode_value, "IP")) { + entry.input.flow_type = str2flowtype(res->flow_type); + } else { + printf("Please set mode to IP or raw.\n"); return; } - entry.input.flow_type = str2flowtype(res->flow_type); } - ret = parse_flexbytes(res->flexbytes_value, - flexbytes, - RTE_ETH_FDIR_MAX_FLEXLEN); - if (ret < 0) { - printf("error: Cannot parse flexbytes input.\n"); - return; + if (entry.input.flow_type != RTE_ETH_FLOW_RAW) { + ret = parse_flexbytes(res->flexbytes_value, + flexbytes, + RTE_ETH_FDIR_MAX_FLEXLEN); + if (ret < 0) { + printf("error: Cannot parse flexbytes input.\n"); + return; + } } switch (entry.input.flow_type) { @@ -9389,6 +9406,14 @@ cmd_flow_director_filter_parsed(void *parsed_result, entry.input.flow.l2_flow.ether_type = rte_cpu_to_be_16(res->ether_type); break; + case RTE_ETH_FLOW_RAW: + raw_packet_buff = open_ddp_package_file(res->filepath, + &raw_packet_size); + if (!raw_packet_buff) + return; + entry.input.flow.raw_flow.packet = raw_packet_buff; + entry.input.flow.raw_flow.length = (uint32_t)raw_packet_size; + break; default: break; } @@ -9476,8 +9501,7 @@ cmdline_parse_token_string_t cmd_flow_director_flow = flow, "flow"); cmdline_parse_token_string_t cmd_flow_director_flow_type = TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, - flow_type, "ipv4-other#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#" - "ipv6-other#ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#l2_payload"); + flow_type, NULL); cmdline_parse_token_string_t cmd_flow_director_ether = TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, ether, "ether"); @@ -9569,6 +9593,9 @@ cmdline_parse_token_string_t cmd_flow_director_mode_mac_vlan = cmdline_parse_token_string_t cmd_flow_director_mode_tunnel = TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, mode_value, "Tunnel"); +cmdline_parse_token_string_t cmd_flow_director_mode_raw = + TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, + mode_value, "raw"); cmdline_parse_token_string_t cmd_flow_director_mac = TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, mac, "mac"); @@ -9587,6 +9614,12 @@ cmdline_parse_token_string_t cmd_flow_director_tunnel_id = cmdline_parse_token_num_t cmd_flow_director_tunnel_id_value = TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, tunnel_id_value, UINT32); +cmdline_parse_token_string_t cmd_flow_director_packet = + TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, + packet, "packet"); +cmdline_parse_token_string_t cmd_flow_director_filepath = + TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, + filepath, NULL); cmdline_parse_inst_t cmd_add_del_ip_flow_director = { .f = cmd_flow_director_filter_parsed, @@ -9790,6 +9823,31 @@ cmdline_parse_inst_t cmd_add_del_tunnel_flow_director = { }, }; +cmdline_parse_inst_t cmd_add_del_raw_flow_director = { + .f = cmd_flow_director_filter_parsed, + .data = NULL, + .help_str = "flow_director_filter ... : Add or delete a raw flow " + "director entry on NIC", + .tokens = { + (void *)&cmd_flow_director_filter, + (void *)&cmd_flow_director_port_id, + (void *)&cmd_flow_director_mode, + (void *)&cmd_flow_director_mode_raw, + (void *)&cmd_flow_director_ops, + (void *)&cmd_flow_director_flow, + (void *)&cmd_flow_director_flow_type, + (void *)&cmd_flow_director_drop, + (void *)&cmd_flow_director_pf_vf, + (void *)&cmd_flow_director_queue, + (void *)&cmd_flow_director_queue_id, + (void *)&cmd_flow_director_fd_id, + (void *)&cmd_flow_director_fd_id_value, + (void *)&cmd_flow_director_packet, + (void *)&cmd_flow_director_filepath, + NULL, + }, +}; + struct cmd_flush_flow_director_result { cmdline_fixed_string_t flush_flow_director; uint8_t port_id; @@ -10589,9 +10647,7 @@ cmdline_parse_token_string_t cmd_set_hash_global_config_hash_func = hash_func, "toeplitz#simple_xor#default"); cmdline_parse_token_string_t cmd_set_hash_global_config_flow_type = TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result, - flow_type, - "ipv4#ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#ipv6#" - "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload"); + flow_type, NULL); cmdline_parse_token_string_t cmd_set_hash_global_config_enable = TOKEN_STRING_INITIALIZER(struct cmd_set_hash_global_config_result, enable, "enable#disable"); @@ -10603,7 +10659,7 @@ cmdline_parse_inst_t cmd_set_hash_global_config = { "toeplitz|simple_xor|default " "ipv4|ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" "ipv6|ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|" - "l2_payload enable|disable", + "l2_payload| enable|disable", .tokens = { (void *)&cmd_set_hash_global_config_all, (void *)&cmd_set_hash_global_config_port_id, @@ -10775,9 +10831,7 @@ cmdline_parse_token_num_t cmd_set_fdir_input_set_port_id = port_id, UINT8); cmdline_parse_token_string_t cmd_set_fdir_input_set_flow_type = TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result, - flow_type, - "ipv4-frag#ipv4-tcp#ipv4-udp#ipv4-sctp#ipv4-other#" - "ipv6-frag#ipv6-tcp#ipv6-udp#ipv6-sctp#ipv6-other#l2_payload"); + flow_type, NULL); cmdline_parse_token_string_t cmd_set_fdir_input_set_field = TOKEN_STRING_INITIALIZER(struct cmd_set_fdir_input_set_result, inset_field, @@ -10795,7 +10849,7 @@ cmdline_parse_inst_t cmd_set_fdir_input_set = { .data = NULL, .help_str = "set_fdir_input_set " "ipv4-frag|ipv4-tcp|ipv4-udp|ipv4-sctp|ipv4-other|" - "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload " + "ipv6-frag|ipv6-tcp|ipv6-udp|ipv6-sctp|ipv6-other|l2_payload| " "ivlan|ethertype|src-ipv4|dst-ipv4|src-ipv6|dst-ipv6|" "ipv4-tos|ipv4-proto|ipv4-ttl|ipv6-tc|ipv6-next-header|" "ipv6-hop-limits|udp-src-port|udp-dst-port|" @@ -15055,6 +15109,7 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_add_del_l2_flow_director, (cmdline_parse_inst_t *)&cmd_add_del_mac_vlan_flow_director, (cmdline_parse_inst_t *)&cmd_add_del_tunnel_flow_director, + (cmdline_parse_inst_t *)&cmd_add_del_raw_flow_director, (cmdline_parse_inst_t *)&cmd_flush_flow_director, (cmdline_parse_inst_t *)&cmd_set_flow_director_ip_mask, (cmdline_parse_inst_t *)&cmd_set_flow_director_mac_vlan_mask, -- 2.5.5