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 D4ADF374C for ; Wed, 9 Mar 2016 08:44:59 +0100 (CET) Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga103.fm.intel.com with ESMTP; 08 Mar 2016 23:44:58 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.24,310,1455004800"; d="scan'208";a="62659670" Received: from shvmail01.sh.intel.com ([10.239.29.42]) by fmsmga004.fm.intel.com with ESMTP; 08 Mar 2016 23:44:58 -0800 Received: from shecgisg004.sh.intel.com (shecgisg004.sh.intel.com [10.239.29.89]) by shvmail01.sh.intel.com with ESMTP id u297iuOv007299; Wed, 9 Mar 2016 15:44:56 +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 u297ir8U004366; Wed, 9 Mar 2016 15:44:55 +0800 Received: (from wenzhuol@localhost) by shecgisg004.sh.intel.com (8.13.6/8.13.6/Submit) id u297irU8004358; Wed, 9 Mar 2016 15:44:53 +0800 From: Wenzhuo Lu To: dev@dpdk.org Date: Wed, 9 Mar 2016 15:44:41 +0800 Message-Id: <1457509482-4297-5-git-send-email-wenzhuo.lu@intel.com> X-Mailer: git-send-email 1.7.4.1 In-Reply-To: <1457509482-4297-1-git-send-email-wenzhuo.lu@intel.com> References: <1454051035-25757-1-git-send-email-wenzhuo.lu@intel.com> <1457509482-4297-1-git-send-email-wenzhuo.lu@intel.com> Subject: [dpdk-dev] [PATCH v7 4/5] app/testpmd: add CLIs for l2 tunnel config 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: Wed, 09 Mar 2016 07:45:00 -0000 Add CLIs to config ether type of l2 tunnel, and to enable/disable a type of l2 tunnel. Now only e-tag tunnel is supported. Signed-off-by: Wenzhuo Lu --- app/test-pmd/cmdline.c | 278 +++++++++++++++++++++++++++- doc/guides/testpmd_app_ug/testpmd_funcs.rst | 11 ++ 2 files changed, 288 insertions(+), 1 deletion(-) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 52e9f5f..28be8e5 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -572,7 +572,15 @@ static void cmd_help_long_parsed(void *parsed_result, "port (port_id) (rxq|txq) (queue_id) (start|stop)\n" " Start/stop a rx/tx queue of port X. Only take effect" - " when port X is started\n" + " when port X is started\n\n" + + "port config (port_id|all) l2-tunnel E-tag ether-type" + " (value)\n" + " Set the value of E-tag ether-type.\n\n" + + "port config (port_id|all) l2-tunnel E-tag" + " (enable|disable)\n" + " Enable/disable the E-tag support.\n\n" ); } @@ -9632,6 +9640,270 @@ cmdline_parse_inst_t cmd_mcast_addr = { }, }; +/* l2 tunnel config + * only support E-tag now. + */ + +/* Ether type config */ +struct cmd_config_l2_tunnel_eth_type_result { + cmdline_fixed_string_t port; + cmdline_fixed_string_t config; + cmdline_fixed_string_t all; + uint8_t id; + cmdline_fixed_string_t l2_tunnel; + cmdline_fixed_string_t l2_tunnel_type; + cmdline_fixed_string_t eth_type; + uint16_t eth_type_val; +}; + +cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_port = + TOKEN_STRING_INITIALIZER + (struct cmd_config_l2_tunnel_eth_type_result, + port, "port"); +cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_config = + TOKEN_STRING_INITIALIZER + (struct cmd_config_l2_tunnel_eth_type_result, + config, "config"); +cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_all_str = + TOKEN_STRING_INITIALIZER + (struct cmd_config_l2_tunnel_eth_type_result, + all, "all"); +cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_id = + TOKEN_NUM_INITIALIZER + (struct cmd_config_l2_tunnel_eth_type_result, + id, UINT8); +cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel = + TOKEN_STRING_INITIALIZER + (struct cmd_config_l2_tunnel_eth_type_result, + l2_tunnel, "l2-tunnel"); +cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_l2_tunnel_type = + TOKEN_STRING_INITIALIZER + (struct cmd_config_l2_tunnel_eth_type_result, + l2_tunnel_type, "E-tag"); +cmdline_parse_token_string_t cmd_config_l2_tunnel_eth_type_eth_type = + TOKEN_STRING_INITIALIZER + (struct cmd_config_l2_tunnel_eth_type_result, + eth_type, "ether-type"); +cmdline_parse_token_num_t cmd_config_l2_tunnel_eth_type_eth_type_val = + TOKEN_NUM_INITIALIZER + (struct cmd_config_l2_tunnel_eth_type_result, + eth_type_val, UINT16); + +static uint32_t +str2fdir_l2_tunnel_type(char *string) +{ + uint32_t i = 0; + + static const struct { + char str[32]; + uint32_t type; + } l2_tunnel_type_str[] = { + {"E-tag", RTE_L2_TUNNEL_TYPE_E_TAG}, + }; + + for (i = 0; i < RTE_DIM(l2_tunnel_type_str); i++) { + if (!strcmp(l2_tunnel_type_str[i].str, string)) + return l2_tunnel_type_str[i].type; + } + return RTE_L2_TUNNEL_TYPE_NONE; +} + +/* ether type config for all ports */ +static void +cmd_config_l2_tunnel_eth_type_all_parsed + (void *parsed_result, + __attribute__((unused)) struct cmdline *cl, + __attribute__((unused)) void *data) +{ + struct cmd_config_l2_tunnel_eth_type_result *res = parsed_result; + struct rte_eth_l2_tunnel_conf entry; + portid_t pid; + + entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type); + entry.ether_type = res->eth_type_val; + + FOREACH_PORT(pid, ports) { + rte_eth_dev_l2_tunnel_eth_type_conf(pid, &entry); + } +} + +cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_all = { + .f = cmd_config_l2_tunnel_eth_type_all_parsed, + .data = NULL, + .help_str = "port config all l2-tunnel ether-type", + .tokens = { + (void *)&cmd_config_l2_tunnel_eth_type_port, + (void *)&cmd_config_l2_tunnel_eth_type_config, + (void *)&cmd_config_l2_tunnel_eth_type_all_str, + (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel, + (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type, + (void *)&cmd_config_l2_tunnel_eth_type_eth_type, + (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val, + NULL, + }, +}; + +/* ether type config for a specific port */ +static void +cmd_config_l2_tunnel_eth_type_specific_parsed( + void *parsed_result, + __attribute__((unused)) struct cmdline *cl, + __attribute__((unused)) void *data) +{ + struct cmd_config_l2_tunnel_eth_type_result *res = + parsed_result; + struct rte_eth_l2_tunnel_conf entry; + + if (port_id_is_invalid(res->id, ENABLED_WARN)) + return; + + entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type); + entry.ether_type = res->eth_type_val; + + rte_eth_dev_l2_tunnel_eth_type_conf(res->id, &entry); +} + +cmdline_parse_inst_t cmd_config_l2_tunnel_eth_type_specific = { + .f = cmd_config_l2_tunnel_eth_type_specific_parsed, + .data = NULL, + .help_str = "port config l2-tunnel ether-type", + .tokens = { + (void *)&cmd_config_l2_tunnel_eth_type_port, + (void *)&cmd_config_l2_tunnel_eth_type_config, + (void *)&cmd_config_l2_tunnel_eth_type_id, + (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel, + (void *)&cmd_config_l2_tunnel_eth_type_l2_tunnel_type, + (void *)&cmd_config_l2_tunnel_eth_type_eth_type, + (void *)&cmd_config_l2_tunnel_eth_type_eth_type_val, + NULL, + }, +}; + +/* Enable/disable l2 tunnel */ +struct cmd_config_l2_tunnel_en_dis_result { + cmdline_fixed_string_t port; + cmdline_fixed_string_t config; + cmdline_fixed_string_t all; + uint8_t id; + cmdline_fixed_string_t l2_tunnel; + cmdline_fixed_string_t l2_tunnel_type; + cmdline_fixed_string_t en_dis; +}; + +cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_port = + TOKEN_STRING_INITIALIZER + (struct cmd_config_l2_tunnel_en_dis_result, + port, "port"); +cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_config = + TOKEN_STRING_INITIALIZER + (struct cmd_config_l2_tunnel_en_dis_result, + config, "config"); +cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_all_str = + TOKEN_STRING_INITIALIZER + (struct cmd_config_l2_tunnel_en_dis_result, + all, "all"); +cmdline_parse_token_num_t cmd_config_l2_tunnel_en_dis_id = + TOKEN_NUM_INITIALIZER + (struct cmd_config_l2_tunnel_en_dis_result, + id, UINT8); +cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel = + TOKEN_STRING_INITIALIZER + (struct cmd_config_l2_tunnel_en_dis_result, + l2_tunnel, "l2-tunnel"); +cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_l2_tunnel_type = + TOKEN_STRING_INITIALIZER + (struct cmd_config_l2_tunnel_en_dis_result, + l2_tunnel_type, "E-tag"); +cmdline_parse_token_string_t cmd_config_l2_tunnel_en_dis_en_dis = + TOKEN_STRING_INITIALIZER + (struct cmd_config_l2_tunnel_en_dis_result, + en_dis, "enable#disable"); + +/* enable/disable l2 tunnel for all ports */ +static void +cmd_config_l2_tunnel_en_dis_all_parsed( + void *parsed_result, + __attribute__((unused)) struct cmdline *cl, + __attribute__((unused)) void *data) +{ + struct cmd_config_l2_tunnel_en_dis_result *res = parsed_result; + struct rte_eth_l2_tunnel_conf entry; + portid_t pid; + uint8_t en; + + entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type); + + if (!strcmp("enable", res->en_dis)) + en = 1; + else + en = 0; + + FOREACH_PORT(pid, ports) { + rte_eth_dev_l2_tunnel_offload_set(pid, + &entry, + ETH_L2_TUNNEL_ENABLE_MASK, + en); + } +} + +cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_all = { + .f = cmd_config_l2_tunnel_en_dis_all_parsed, + .data = NULL, + .help_str = "port config all l2-tunnel enable/disable", + .tokens = { + (void *)&cmd_config_l2_tunnel_en_dis_port, + (void *)&cmd_config_l2_tunnel_en_dis_config, + (void *)&cmd_config_l2_tunnel_en_dis_all_str, + (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel, + (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type, + (void *)&cmd_config_l2_tunnel_en_dis_en_dis, + NULL, + }, +}; + +/* enable/disable l2 tunnel for a port */ +static void +cmd_config_l2_tunnel_en_dis_specific_parsed( + void *parsed_result, + __attribute__((unused)) struct cmdline *cl, + __attribute__((unused)) void *data) +{ + struct cmd_config_l2_tunnel_en_dis_result *res = + parsed_result; + struct rte_eth_l2_tunnel_conf entry; + + if (port_id_is_invalid(res->id, ENABLED_WARN)) + return; + + entry.l2_tunnel_type = str2fdir_l2_tunnel_type(res->l2_tunnel_type); + + if (!strcmp("enable", res->en_dis)) + rte_eth_dev_l2_tunnel_offload_set(res->id, + &entry, + ETH_L2_TUNNEL_ENABLE_MASK, + 1); + else + rte_eth_dev_l2_tunnel_offload_set(res->id, + &entry, + ETH_L2_TUNNEL_ENABLE_MASK, + 0); +} + +cmdline_parse_inst_t cmd_config_l2_tunnel_en_dis_specific = { + .f = cmd_config_l2_tunnel_en_dis_specific_parsed, + .data = NULL, + .help_str = "port config l2-tunnel enable/disable", + .tokens = { + (void *)&cmd_config_l2_tunnel_en_dis_port, + (void *)&cmd_config_l2_tunnel_en_dis_config, + (void *)&cmd_config_l2_tunnel_en_dis_id, + (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel, + (void *)&cmd_config_l2_tunnel_en_dis_l2_tunnel_type, + (void *)&cmd_config_l2_tunnel_en_dis_en_dis, + NULL, + }, +}; + /* ******************************************************************************** */ /* list of instructions */ @@ -9773,6 +10045,10 @@ cmdline_parse_ctx_t main_ctx[] = { (cmdline_parse_inst_t *)&cmd_set_hash_input_set, (cmdline_parse_inst_t *)&cmd_set_fdir_input_set, (cmdline_parse_inst_t *)&cmd_mcast_addr, + (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_all, + (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_eth_type_specific, + (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_all, + (cmdline_parse_inst_t *)&cmd_config_l2_tunnel_en_dis_specific, NULL, }; diff --git a/doc/guides/testpmd_app_ug/testpmd_funcs.rst b/doc/guides/testpmd_app_ug/testpmd_funcs.rst index a520cc5..5471ebe 100644 --- a/doc/guides/testpmd_app_ug/testpmd_funcs.rst +++ b/doc/guides/testpmd_app_ug/testpmd_funcs.rst @@ -1268,6 +1268,17 @@ Where the threshold type can be: These threshold options are also available from the command-line. +port config - E-tag +~~~~~~~~~~~~~~~~~~~ + +Set the value of ether-type for E-tag:: + + testpmd> port config (port_id|all) l2-tunnel E-tag ether-type (value) + +Enable/disable the E-tag support:: + + testpmd> port config (port_id|all) l2-tunnel E-tag (enable|disable) + Link Bonding Functions ---------------------- -- 1.9.3