From patchwork Tue Aug 12 03:12:05 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jijiang Liu X-Patchwork-Id: 147 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id EC416B3A7 for ; Tue, 12 Aug 2014 05:09:36 +0200 (CEST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by orsmga102.jf.intel.com with ESMTP; 11 Aug 2014 20:06:39 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.01,846,1400050800"; d="scan'208";a="557194128" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga001.jf.intel.com with ESMTP; 11 Aug 2014 20:12:29 -0700 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id s7C3CRJB012573; Tue, 12 Aug 2014 11:12:27 +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 s7C3CO21011131; Tue, 12 Aug 2014 11:12:26 +0800 Received: (from jijiangl@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id s7C3CO3t011127; Tue, 12 Aug 2014 11:12:24 +0800 From: Jijiang Liu To: dev@dpdk.org Date: Tue, 12 Aug 2014 11:12:05 +0800 Message-Id: <1407813127-10991-5-git-send-email-jijiang.liu@intel.com> X-Mailer: git-send-email 1.7.0.7 In-Reply-To: <1407813127-10991-1-git-send-email-jijiang.liu@intel.com> References: <1407813127-10991-1-git-send-email-jijiang.liu@intel.com> Subject: [dpdk-dev] [PATCH 4/6]app/testpmd:test VxLAN cloud filter API 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, 12 Aug 2014 03:09:37 -0000 Add commands to test VxLAN cloud filter API. Signed-off-by: jijiangl Acked-by: Helin Zhang Acked-by: Jingjing Wu Acked-by: Jing Chen --- app/test-pmd/cmdline.c | 142 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 142 insertions(+), 0 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 67cf63e..a5adac0 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -285,6 +285,14 @@ static void cmd_help_long_parsed(void *parsed_result, " Set the outer VLAN TPID for Packet Filtering on" " a port\n\n" + "cloud_filter add (port_id) (outer_mac) (inner_mac) (ip_addr) " + "(inner_vlan) (tunnel_type) (filter_type) (tenant_id) (queue_id)\n" + " add a cloud fiter of a port.\n\n" + + "cloud_filter rm (port_id) (outer_mac) (inner_mac) (ip_addr) " + "(inner_vlan) (tunnel_type) (filter_type) (tenant_id) (queue_id)\n" + " remove a cloud fiter of a port.\n\n" + "rx_vxlan_port add (udp_port) (port_id)\n" " Add an UDP port for VxLAN packet filter on a port\n\n" @@ -6123,6 +6131,139 @@ cmdline_parse_inst_t cmd_vf_rate_limit = { }, }; +/* *** ADD CLOUD FILTER OF A PORT *** */ +struct cmd_cloud_filter_result { + cmdline_fixed_string_t cmd; + cmdline_fixed_string_t what; + uint8_t port_id; + struct ether_addr outer_mac; + struct ether_addr inner_mac; + cmdline_ipaddr_t ip_value; + uint16_t inner_vlan; + cmdline_fixed_string_t tunnel_type; + cmdline_fixed_string_t filter_type; + uint32_t tenant_id; + uint16_t queue_num; +}; + +static void +cmd_cloud_filter_parsed(void *parsed_result, + __attribute__((unused)) struct cmdline *cl, + __attribute__((unused)) void *data) +{ + struct cmd_cloud_filter_result *res = parsed_result; + struct rte_eth_cloud_filter_conf cloud_filter_conf; + + cloud_filter_conf.outer_mac = &res->outer_mac; + cloud_filter_conf.inner_mac = &res->inner_mac; + cloud_filter_conf.inner_vlan = res->inner_vlan; + + if (res->ip_value.family == AF_INET) { + cloud_filter_conf.ip_addr.ipv4_addr = + res->ip_value.addr.ipv4.s_addr; + cloud_filter_conf.ip_type = RTE_CLOUD_IPTYPE_IPV4; + } else { + memcpy(&(cloud_filter_conf.ip_addr.ipv6_addr), + &(res->ip_value.addr.ipv6), + sizeof(struct in6_addr)); + cloud_filter_conf.ip_type = RTE_CLOUD_IPTYPE_IPV6; + } + + if (!strcmp(res->filter_type, "imac-ivlan")) + cloud_filter_conf.filter_type = RTE_CLOUD_FILTER_IMAC_IVLAN; + else if (!strcmp(res->filter_type, "imac-ivlan-tenid")) + cloud_filter_conf.filter_type = + RTE_CLOUD_FILTER_IMAC_IVLAN_TENID; + else if (!strcmp(res->filter_type, "imac-tenid")) + cloud_filter_conf.filter_type = RTE_CLOUD_FILTER_IMAC_TENID; + else if (!strcmp(res->filter_type, "imac")) + cloud_filter_conf.filter_type = RTE_CLOUD_FILTER_IMAC; + else if (!strcmp(res->filter_type, "omac-imac-tenid")) + cloud_filter_conf.filter_type = + RTE_CLOUD_FILTER_OMAC_TENID_IMAC; + else { + printf("The filter type is not supported"); + return; + } + + cloud_filter_conf.to_queue = RTE_CLOUD_FLAGS_TO_QUEUE; + + if (!strcmp(res->tunnel_type, "vxlan")) + cloud_filter_conf.tunnel_type = RTE_TUNNEL_TYPE_VXLAN; + else { + printf("Only VxLAN is supported now.\n"); + return; + } + + cloud_filter_conf.tenant_id = res->tenant_id; + cloud_filter_conf.queue_id = res->queue_num; + if (!strcmp(res->what, "add")) + rte_eth_dev_cloud_filter_set(res->port_id, + &cloud_filter_conf, 1, 1); + else + rte_eth_dev_cloud_filter_set(res->port_id, + &cloud_filter_conf, 1, 0); +} +cmdline_parse_token_string_t cmd_cloud_filter_cmd = + TOKEN_STRING_INITIALIZER(struct cmd_cloud_filter_result, + cmd, "cloud_filter"); +cmdline_parse_token_string_t cmd_cloud_filter_what = + TOKEN_STRING_INITIALIZER(struct cmd_cloud_filter_result, + what, "add#rm"); +cmdline_parse_token_num_t cmd_cloud_filter_port_id = + TOKEN_NUM_INITIALIZER(struct cmd_cloud_filter_result, + port_id, UINT8); +cmdline_parse_token_etheraddr_t cmd_cloud_filter_outer_mac = + TOKEN_ETHERADDR_INITIALIZER(struct cmd_cloud_filter_result, + outer_mac); +cmdline_parse_token_etheraddr_t cmd_cloud_filter_inner_mac = + TOKEN_ETHERADDR_INITIALIZER(struct cmd_cloud_filter_result, + inner_mac); +cmdline_parse_token_num_t cmd_cloud_filter_innner_vlan = + TOKEN_NUM_INITIALIZER(struct cmd_cloud_filter_result, + inner_vlan, UINT16); +cmdline_parse_token_ipaddr_t cmd_cloud_filter_ip_value = + TOKEN_IPADDR_INITIALIZER(struct cmd_cloud_filter_result, + ip_value); +cmdline_parse_token_string_t cmd_cloud_filter_tunnel_type = + TOKEN_STRING_INITIALIZER(struct cmd_cloud_filter_result, + tunnel_type, "vxlan"); + +cmdline_parse_token_string_t cmd_cloud_filter_filter_type = + TOKEN_STRING_INITIALIZER(struct cmd_cloud_filter_result, + filter_type, "imac-ivlan#imac-ivlan-tenid#imac-tenid#" + "imac#omac-imac-tenid"); +cmdline_parse_token_num_t cmd_cloud_filter_tenant_id = + TOKEN_NUM_INITIALIZER(struct cmd_cloud_filter_result, + tenant_id, UINT32); +cmdline_parse_token_num_t cmd_cloud_filter_queue_num = + TOKEN_NUM_INITIALIZER(struct cmd_cloud_filter_result, + queue_num, UINT16); + +cmdline_parse_inst_t cmd_cloud_filter = { + .f = cmd_cloud_filter_parsed, + .data = (void *)0, + .help_str = "add/rm cloud filter of a port: " + "cloud_filter add port_id outer_mac inner_mac ip " + "inner_vlan tunnel_type(vxlan) filter_type " + "(imac-ivlan|imac-ivlan-tenid|imac-tenid|imac|omac-imac-tenid) " + "tenant_id queue_num", + .tokens = { + (void *)&cmd_cloud_filter_cmd, + (void *)&cmd_cloud_filter_what, + (void *)&cmd_cloud_filter_port_id, + (void *)&cmd_cloud_filter_outer_mac, + (void *)&cmd_cloud_filter_inner_mac, + (void *)&cmd_cloud_filter_ip_value, + (void *)&cmd_cloud_filter_innner_vlan, + (void *)&cmd_cloud_filter_tunnel_type, + (void *)&cmd_cloud_filter_filter_type, + (void *)&cmd_cloud_filter_tenant_id, + (void *)&cmd_cloud_filter_queue_num, + NULL, + }, +}; + /* *** CONFIGURE TUNNEL UDP PORT *** */ struct cmd_tunnel_udp_config { cmdline_fixed_string_t cmd; @@ -7475,6 +7616,7 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter, (cmdline_parse_inst_t *)&cmd_queue_rate_limit, (cmdline_parse_inst_t *)&cmd_vf_rate_limit, + (cmdline_parse_inst_t *)&cmd_cloud_filter, (cmdline_parse_inst_t *)&cmd_tunnel_udp_config, (cmdline_parse_inst_t *)&cmd_set_mirror_mask, (cmdline_parse_inst_t *)&cmd_set_mirror_link,