From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) by dpdk.org (Postfix) with ESMTP id 135F8AFCA for ; Tue, 23 Sep 2014 05:24:02 +0200 (CEST) Received: from orsmga002.jf.intel.com ([10.7.209.21]) by orsmga102.jf.intel.com with ESMTP; 22 Sep 2014 20:23:55 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.04,577,1406617200"; d="scan'208";a="606922184" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by orsmga002.jf.intel.com with ESMTP; 22 Sep 2014 20:30:08 -0700 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id s8N3U64U010979; Tue, 23 Sep 2014 11:30:06 +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 s8N3U4ON015490; Tue, 23 Sep 2014 11:30:06 +0800 Received: (from jijiangl@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id s8N3U4gG015486; Tue, 23 Sep 2014 11:30:04 +0800 From: Jijiang Liu To: dev@dpdk.org Date: Tue, 23 Sep 2014 11:29:51 +0800 Message-Id: <1411442991-15386-6-git-send-email-jijiang.liu@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1411442991-15386-1-git-send-email-jijiang.liu@intel.com> References: <1411442991-15386-1-git-send-email-jijiang.liu@intel.com> Subject: [dpdk-dev] [PATCH 5/5]testpmd:test VF MACVLAN filter for i40e 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, 23 Sep 2014 03:24:04 -0000 Add a test command in testpmd to test VF MACVLAN filter feature. Signed-off-by: Jijiang Liu Acked-by: Helin Zhang Acked-by: Jingjing Wu Acked-by: Changchun Ouyang --- app/test-pmd/cmdline.c | 115 ++++++++++++++++++++++++++++++++++++++++++++++- 1 files changed, 112 insertions(+), 3 deletions(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index b04a4e8..bfdf265 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -351,9 +351,14 @@ static void cmd_help_long_parsed(void *parsed_result, " e.g., 'set stat_qmap rx 0 2 5' sets rx queue 2" " on port 0 to mapping 5.\n\n" - "set port (port_id) vf (vf_id) rx|tx on|off \n" + "set port (port_id) vf (vf_id) rx|tx on|off\n" " Enable/Disable a VF receive/tranmit from a port\n\n" + "set port (port_id) vf (vf_id) (mac_addr)" + " (exact-mac#exact-mac-vlan#hashmac|hashmac-vlan) on|off\n" + " Add/Remove unicast or multicast MAC addr filter" + " for a VF.\n\n" + "set port (port_id) vf (vf_id) rxmode (AUPE|ROPE|BAM" "|MPE) (on|off)\n" " AUPE:accepts untagged VLAN;" @@ -5795,6 +5800,108 @@ cmdline_parse_inst_t cmd_set_uc_all_hash_filter = { }, }; +/* *** CONFIGURE MACVLAN FILTER FOR VF(s) *** */ +struct cmd_set_vf_macvlan_filter { + cmdline_fixed_string_t set; + cmdline_fixed_string_t port; + uint8_t port_id; + cmdline_fixed_string_t vf; + uint8_t vf_id; + struct ether_addr address; + cmdline_fixed_string_t filter_type; + cmdline_fixed_string_t mode; +}; + +static void +cmd_set_vf_macvlan_parsed(void *parsed_result, + __attribute__((unused)) struct cmdline *cl, + __attribute__((unused)) void *data) +{ + int is_on, ret = 0; + struct cmd_set_vf_macvlan_filter *res = parsed_result; + struct rte_eth_mac_filter filter; + + memset(&filter, 0, sizeof(struct rte_eth_mac_filter)); + + (void)rte_memcpy(&filter.mac_addr, &res->address, ETHER_ADDR_LEN); + filter.id = res->vf_id; + filter.pf_vf_flag = 0; + + if (!strcmp(res->filter_type, "exact-mac")) + filter.filter_type = RTE_MAC_PERFECT_MATCH; + else if (!strcmp(res->filter_type, "exact-mac-vlan")) + filter.filter_type = RTE_MACVLAN_PERFECT_MATCH; + else if (!strcmp(res->filter_type, "hashmac")) + filter.filter_type = RTE_MAC_HASH_MATCH; + else if (!strcmp(res->filter_type, "hashmac-vlan")) + filter.filter_type = RTE_MACVLAN_HASH_MATCH; + + is_on = (strcmp(res->mode, "on") == 0) ? 1 : 0; + + if (is_on) + ret = rte_eth_dev_filter_ctrl(res->port_id, + RTE_ETH_FILTER_MACVLAN, + RTE_ETH_FILTER_OP_ADD, + &filter); + else + ret = rte_eth_dev_filter_ctrl(res->port_id, + RTE_ETH_FILTER_MACVLAN, + RTE_ETH_FILTER_OP_DELETE, + &filter); + + if (ret < 0) + printf("bad set MAC hash parameter, return code = %d\n", ret); + +} + +cmdline_parse_token_string_t cmd_set_vf_macvlan_set = + TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter, + set, "set"); +cmdline_parse_token_string_t cmd_set_vf_macvlan_port = + TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter, + port, "port"); +cmdline_parse_token_num_t cmd_set_vf_macvlan_portid = + TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter, + port_id, UINT8); +cmdline_parse_token_string_t cmd_set_vf_macvlan_vf = + TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter, + vf, "vf"); +cmdline_parse_token_num_t cmd_set_vf_macvlan_vf_id = + TOKEN_NUM_INITIALIZER(struct cmd_set_vf_macvlan_filter, + vf_id, UINT8); +cmdline_parse_token_etheraddr_t cmd_set_vf_macvlan_mac = + TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_vf_macvlan_filter, + address); +cmdline_parse_token_string_t cmd_set_vf_macvlan_filter_type = + TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter, + filter_type, "exact-mac#exact-mac-vlan" + "#hashmac#hashmac-vlan"); +cmdline_parse_token_string_t cmd_set_vf_macvlan_mode = + TOKEN_STRING_INITIALIZER(struct cmd_set_vf_macvlan_filter, + mode, "on#off"); + +cmdline_parse_inst_t cmd_set_vf_macvlan_filter = { + .f = cmd_set_vf_macvlan_parsed, + .data = NULL, + .help_str = "set port (portid) vf (vfid) (mac-addr) " + "(exact-mac|exact-mac-vlan|hashmac|hashmac-vlan) " + "on|off\n" + "exact match rule:exact match of MAC or MAC and VLAN; " + "hash match rule: hash match of MAC and exact match " + "of VLAN", + .tokens = { + (void *)&cmd_set_vf_macvlan_set, + (void *)&cmd_set_vf_macvlan_port, + (void *)&cmd_set_vf_macvlan_portid, + (void *)&cmd_set_vf_macvlan_vf, + (void *)&cmd_set_vf_macvlan_vf_id, + (void *)&cmd_set_vf_macvlan_mac, + (void *)&cmd_set_vf_macvlan_filter_type, + (void *)&cmd_set_vf_macvlan_mode, + NULL, + }, +}; + /* *** CONFIGURE VF TRAFFIC CONTROL *** */ struct cmd_set_vf_traffic { cmdline_fixed_string_t set; @@ -5843,7 +5950,8 @@ cmdline_parse_token_string_t cmd_setvf_traffic_mode = cmdline_parse_inst_t cmd_set_vf_traffic = { .f = cmd_set_vf_traffic_parsed, .data = NULL, - .help_str = "set port X vf Y rx|tx on|off (X = port number,Y = vf id)", + .help_str = "set port X vf Y rx|tx on|off" + "(X = port number,Y = vf id)", .tokens = { (void *)&cmd_setvf_traffic_set, (void *)&cmd_setvf_traffic_port, @@ -7501,7 +7609,8 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_set_vf_rxmode, (cmdline_parse_inst_t *)&cmd_set_uc_hash_filter, (cmdline_parse_inst_t *)&cmd_set_uc_all_hash_filter, - (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter , + (cmdline_parse_inst_t *)&cmd_vf_mac_addr_filter, + (cmdline_parse_inst_t *)&cmd_set_vf_macvlan_filter, (cmdline_parse_inst_t *)&cmd_set_vf_traffic, (cmdline_parse_inst_t *)&cmd_vf_rxvlan_filter, (cmdline_parse_inst_t *)&cmd_queue_rate_limit, -- 1.7.7.6