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 652211B223 for ; Thu, 5 Oct 2017 22:53:00 +0200 (CEST) Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 05 Oct 2017 13:53:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,482,1500966000"; d="scan'208";a="1227551956" Received: from silpixa00389036.ir.intel.com (HELO silpixa00389036.ger.corp.intel.com) ([10.237.223.231]) by fmsmga002.fm.intel.com with ESMTP; 05 Oct 2017 13:52:58 -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: Thu, 5 Oct 2017 21:52:50 +0100 Message-Id: <1507236771-85423-4-git-send-email-kirill.rybalchenko@intel.com> X-Mailer: git-send-email 2.5.5 In-Reply-To: <1507236771-85423-1-git-send-email-kirill.rybalchenko@intel.com> References: <1505896926-70362-1-git-send-email-kirill.rybalchenko@intel.com> <1507236771-85423-1-git-send-email-kirill.rybalchenko@intel.com> Subject: [dpdk-dev] [PATCH v3 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: Thu, 05 Oct 2017 20:53:01 -0000 v3: Add raw flow type support to flow_director_filter command Signed-off-by: Kirill Rybalchenko --- app/test-pmd/cmdline.c | 69 +++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 66 insertions(+), 3 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index cdde5a1..b08c1b4 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -843,6 +843,12 @@ 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) flexbytes (flexbytes_value) (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" @@ -8904,6 +8910,7 @@ struct cmd_flow_director_result { cmdline_fixed_string_t mode_value; cmdline_fixed_string_t ops; cmdline_fixed_string_t flow; + uint16_t flow_id; cmdline_fixed_string_t flow_type; cmdline_fixed_string_t ether; uint16_t ether_type; @@ -8937,6 +8944,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 @@ -9063,6 +9072,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; @@ -9086,11 +9097,14 @@ 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; + } 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, @@ -9172,6 +9186,15 @@ 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: + entry.input.flow.raw_flow.flow = res->flow_id; + 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 = (uint16_t)raw_packet_size; + break; default: break; } @@ -9261,6 +9284,9 @@ 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"); +cmdline_parse_token_num_t cmd_flow_director_flow_id = + TOKEN_NUM_INITIALIZER(struct cmd_flow_director_result, + flow_id, UINT16); cmdline_parse_token_string_t cmd_flow_director_ether = TOKEN_STRING_INITIALIZER(struct cmd_flow_director_result, ether, "ether"); @@ -9352,6 +9378,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"); @@ -9370,6 +9399,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, @@ -9573,6 +9608,33 @@ 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_id, + (void *)&cmd_flow_director_flexbytes, + (void *)&cmd_flow_director_flexbytes_value, + (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; @@ -14755,6 +14817,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