From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id F2A01D0B2 for ; Mon, 13 Mar 2017 05:04:57 +0100 (CET) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 12 Mar 2017 21:04:56 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,156,1486454400"; d="scan'208";a="1121703633" Received: from unknown (HELO localhost.localdomain.sh.intel.com) ([10.239.129.167]) by fmsmga001.fm.intel.com with ESMTP; 12 Mar 2017 21:04:55 -0700 From: Qi Zhang To: jingjing.wu@intel.com, helin.zhang@intel.com Cc: dev@dpdk.org, Qi Zhang Date: Mon, 13 Mar 2017 00:55:43 -0400 Message-Id: <20170313045543.65464-3-qi.z.zhang@intel.com> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170313045543.65464-1-qi.z.zhang@intel.com> References: <20170303015924.68986-1-qi.z.zhang@intel.com> <20170313045543.65464-1-qi.z.zhang@intel.com> Subject: [dpdk-dev] [PATCH v2 2/2] app/testpmd: enable VF untag drop in testpmd 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: Mon, 13 Mar 2017 04:04:58 -0000 Add command line to support untag drop to specific VF in testpmd. Signed-off-by: Qi Zhang --- v2: - adjust compile option to align with others. app/test-pmd/cmdline.c | 99 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 43fc636..527a0f6 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -312,6 +312,9 @@ static void cmd_help_long_parsed(void *parsed_result, "set vf vlan antispoof (port_id) (vf_id) (on|off)\n" " Set VLAN antispoof for a VF from the PF.\n\n" + "set vf vlan untagdrop (port_id) (vf_id) (on|off)\n" + " Set VLAN untag drop for a VF from the PF.\n\n" + "set vf vlan tag (port_id) (vf_id) (on|off)\n" " Set VLAN tag for a VF from the PF.\n\n" @@ -10995,6 +10998,101 @@ cmdline_parse_inst_t cmd_set_vf_vlan_anti_spoof = { }, }; +/* vf vlan untag drop configuration */ + +/* Common result structure for vf vlan untag drop */ +struct cmd_vf_vlan_untag_drop_result { + cmdline_fixed_string_t set; + cmdline_fixed_string_t vf; + cmdline_fixed_string_t vlan; + cmdline_fixed_string_t untagdrop; + uint8_t port_id; + uint32_t vf_id; + cmdline_fixed_string_t on_off; +}; + +/* Common CLI fields for vf vlan untag drop enable disable */ +cmdline_parse_token_string_t cmd_vf_vlan_untag_drop_set = + TOKEN_STRING_INITIALIZER + (struct cmd_vf_vlan_untag_drop_result, + set, "set"); +cmdline_parse_token_string_t cmd_vf_vlan_untag_drop_vf = + TOKEN_STRING_INITIALIZER + (struct cmd_vf_vlan_untag_drop_result, + vf, "vf"); +cmdline_parse_token_string_t cmd_vf_vlan_untag_drop_vlan = + TOKEN_STRING_INITIALIZER + (struct cmd_vf_vlan_untag_drop_result, + vlan, "vlan"); +cmdline_parse_token_string_t cmd_vf_vlan_untag_drop_untagdrop = + TOKEN_STRING_INITIALIZER + (struct cmd_vf_vlan_untag_drop_result, + untagdrop, "untagdrop"); +cmdline_parse_token_num_t cmd_vf_vlan_untag_drop_port_id = + TOKEN_NUM_INITIALIZER + (struct cmd_vf_vlan_untag_drop_result, + port_id, UINT8); +cmdline_parse_token_num_t cmd_vf_vlan_untag_drop_vf_id = + TOKEN_NUM_INITIALIZER + (struct cmd_vf_vlan_untag_drop_result, + vf_id, UINT32); +cmdline_parse_token_string_t cmd_vf_vlan_untag_drop_on_off = + TOKEN_STRING_INITIALIZER + (struct cmd_vf_vlan_untag_drop_result, + on_off, "on#off"); + +static void +cmd_set_vf_vlan_untag_drop_parsed( + void *parsed_result, + __attribute__((unused)) struct cmdline *cl, + __attribute__((unused)) void *data) +{ + struct cmd_vf_vlan_untag_drop_result *res = parsed_result; + int ret = -ENOTSUP; + + __rte_unused int is_on = (strcmp(res->on_off, "on") == 0) ? 1 : 0; + + if (port_id_is_invalid(res->port_id, ENABLED_WARN)) + return; + +#ifdef RTE_LIBRTE_I40E_PMD + ret = rte_pmd_i40e_set_vf_vlan_untag_drop(res->port_id, + res->vf_id, is_on); +#endif + + switch (ret) { + case 0: + break; + case -EINVAL: + printf("invalid vf_id %d\n", res->vf_id); + break; + case -ENODEV: + printf("invalid port_id %d\n", res->port_id); + break; + case -ENOTSUP: + printf("function not implemented\n"); + break; + default: + printf("programming error: (%s)\n", strerror(-ret)); + } +} + +cmdline_parse_inst_t cmd_set_vf_vlan_untag_drop = { + .f = cmd_set_vf_vlan_untag_drop_parsed, + .data = NULL, + .help_str = "set vf vlan untagdrop on|off", + .tokens = { + (void *)&cmd_vf_vlan_untag_drop_set, + (void *)&cmd_vf_vlan_untag_drop_vf, + (void *)&cmd_vf_vlan_untag_drop_vlan, + (void *)&cmd_vf_vlan_untag_drop_untagdrop, + (void *)&cmd_vf_vlan_untag_drop_port_id, + (void *)&cmd_vf_vlan_untag_drop_vf_id, + (void *)&cmd_vf_vlan_untag_drop_on_off, + NULL, + }, +}; + /* vf mac anti spoof configuration */ /* Common result structure for vf mac anti spoof */ @@ -12549,6 +12647,7 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_add, (cmdline_parse_inst_t *)&cmd_config_e_tag_filter_del, (cmdline_parse_inst_t *)&cmd_set_vf_vlan_anti_spoof, + (cmdline_parse_inst_t *)&cmd_set_vf_vlan_untag_drop, (cmdline_parse_inst_t *)&cmd_set_vf_mac_anti_spoof, (cmdline_parse_inst_t *)&cmd_set_vf_vlan_stripq, (cmdline_parse_inst_t *)&cmd_set_vf_vlan_insert, -- 2.9.3