From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-eopbgr20049.outbound.protection.outlook.com [40.107.2.49]) by dpdk.org (Postfix) with ESMTP id 883621B12F for ; Sat, 29 Sep 2018 22:08:06 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Mellanox.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ZIaAg4Ke9t6OiHepdJDD/MhPxIa14oX/h32jDgCLE8k=; b=qK03qkMtYOEUyZBoP0qbTAyVNQa0C6MWdsoMBW8tq361XfYBveFt/YIjGRvYaS3wgoBgItEGXFYL0P74ocCTqg/Ll7ktrBqj2IKWhQUaAe8u2Zb6mce+aGeUmhMThWKXdfPqkqdSkij+kaFj6ImPEqsAHAL81PdY1GqscsuSmgY= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=orika@mellanox.com; Received: from mellanox.com (37.142.13.130) by AM4PR05MB3427.eurprd05.prod.outlook.com (2603:10a6:205:6::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1185.23; Sat, 29 Sep 2018 20:08:03 +0000 From: Ori Kam To: wenzhuo.lu@intel.com, jingjing.wu@intel.com, bernard.iremonger@intel.com, arybchenko@solarflare.com, ferruh.yigit@intel.com, stephen@networkplumber.org, adrien.mazarguil@6wind.com Cc: dev@dpdk.org, dekelp@mellanox.com, thomas@monjalon.net, nelio.laranjeiro@6wind.com, yskoh@mellanox.com, orika@mellanox.com, shahafs@mellanox.com Date: Sat, 29 Sep 2018 20:07:20 +0000 Message-Id: <1538251641-91511-3-git-send-email-orika@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1538251641-91511-1-git-send-email-orika@mellanox.com> References: <1538251641-91511-1-git-send-email-orika@mellanox.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [37.142.13.130] X-ClientProxiedBy: HE1PR05CA0381.eurprd05.prod.outlook.com (2603:10a6:7:94::40) To AM4PR05MB3427.eurprd05.prod.outlook.com (2603:10a6:205:6::16) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c5106d82-52cf-426d-27a1-08d62647449a X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0; PCL:0; RULEID:(7020095)(4652040)(8989299)(4534165)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020); SRVR:AM4PR05MB3427; X-Microsoft-Exchange-Diagnostics: 1; AM4PR05MB3427; 3:SfDh22msN4Ycj7sn5V3ZrrEZg9jTtlOioYyoaXCeGnBFVA5O3Vy1XbISwBa0mfoIEMpW4mngLubtVMcUURsUtV3NZaGTLRQBaWjBrFCYWZaJ8XFlVkeU+IwCI8Rq38qnIblIYns4Vh11b9yNjUIodaF+G56Oq3nJUBBm34FmlYNXLGLd18OjUBxClJKNXLhmpv5I+9Bkp9NuBE1St2qXuh5PXBp0FxRgr1mUXLPsMyBxXSF+Gh/bR7nN7WelimIE; 25:HBwAaw+qFq66tt53hP3C01A11d+h0agmuHSjrY+DeNbnN6mqhK7nWIxWrQdvyrWodaOORv3MplYgmhnwmbYKayOEBr9u5nLpLRoZjCBbrRur5Ypm6160WKrELI2Bd5FCJiGJEI2xGaDA1ob1lM1ybnKBZPqEUSYV41FblRUmwMdl6JNfIgRvRn3GjzrYKs4ibyD/8Ul2LCLWDxUQZwf8PQ5HR/X0o3/4+5w4cbAQfRy/CQxMamn+kttN9wx8QkOFi53yMOLVApq3vQinn4JVSDVK5i0y2Qyn4Vof4TV4IThkgpfKVL8R82wKmBkvoC2qpIqqKdyFSykCuQ13ElMbFA==; 31:J68yb+DzQwIUN9KOJ6aa1NJxMj0EpGynA9NMRiza7PC5V9boei/QIGJoQU1xldug//AlGSYpORPhY3bb0XeV7Od3oW7Bvd1Buioj/iO1lmvevXqSmdb4P9u8c8O5HZQwQNshwCTZffYIMzrTCliM+lEvVq6wzUpPh/3Acr3FhMxvqcABebPOqAIvEg7ROhy78ob5UoJj9IQp6DqJMCWQeRy7Hftn7B6Ju2zFVoEO7JI= X-MS-TrafficTypeDiagnostic: AM4PR05MB3427: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr X-Microsoft-Exchange-Diagnostics: 1; AM4PR05MB3427; 20:FKeUBW3/MAzsB5uBbFYvy9Xlx364O54c7cs3iCrP0+RbVPGfd0mbCmJz7iCkk8xBtLn6kuche+U1egI86iECZVzF3C4890gV/0A5zFFIVnp4JntunQwKXJ/6NXDqCat9XO+qoqvmJmhfYinm5vqLEMWxdx+SZSGISM7/8z34OW+LjKT8bDZi8KEEP5TEmtzF6qO3uICkfgpPQKKIKKU2d+DdS7HtiE5tXFKYuisX4OvGOTAK3EPXiDCTy+MkHoVMB1oNsVu0usi0QOI27F4KxDAkC4BMHKNSG6G1nYHwswpgjH0jkxrYKK8gSz69GTDo/Jmmm7CYLfnlsAxQY/i/CtBsu3vW+BPLdZBNvp80zKtgdQqm692sXExOkVoeA4igqgxCUmWCni0h4Dvp2I3kxD15voVLax5Yzijbv53APoXUrlDr/6a+WPR/UXXmMale3rgg/poBErIL+4uK0gT7rewOCpkitZX+wUPjOFELeoXIvEbi8QsW3/49vCY6nvTB; 4:YbHb6nwFVAqDR/USfFxJtC+ls2ctbIvjZvN1+4ObWwlLyxwIJKQrSM8bhODBYuSoA/Ms5WJHnvZxp7GC2KoEWXvVAuvnADwp1/K/+qFzQVIkzqtUXg7dv0O9r81Xg04nUf7WsGgtUEk4pxyCCS7nRmVpqUIZzes7SyspQNKCjBBlg80vFYps2kAj1g2l1FPGOktdEirDOM/9pWoSZpzNuN7RqUhMyHSeuUQyA0fCZw+3MUzcvMAFjxhbZh2sGirKlMDRNMqVO3wrIzEichuhxx+MmOHNKkv0qIdfFH7me1goQqAWbr6P0iozxZ0BdqsI X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(17755550239193); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3231355)(944501410)(52105095)(10201501046)(3002001)(93006095)(93001095)(6055026)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123564045)(20161123558120)(20161123560045)(201708071742011)(7699051); SRVR:AM4PR05MB3427; BCL:0; PCL:0; RULEID:; SRVR:AM4PR05MB3427; X-Forefront-PRVS: 0810818DA0 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(366004)(346002)(396003)(376002)(39860400002)(136003)(199004)(189003)(53936002)(7696005)(105586002)(106356001)(4326008)(107886003)(2906002)(68736007)(478600001)(66066001)(47776003)(21086003)(7416002)(36756003)(48376002)(50466002)(8886007)(33026002)(316002)(4720700003)(6666003)(6116002)(3846002)(97736004)(5660300001)(7736002)(305945005)(55016002)(25786009)(69596002)(16586007)(476003)(2616005)(956004)(16526019)(446003)(186003)(81156014)(51416003)(11346002)(81166006)(386003)(52116002)(486006)(4006002)(76176011)(8676002)(86362001)(34290500001)(26005)(8936002)(50226002); DIR:OUT; SFP:1101; SCL:1; SRVR:AM4PR05MB3427; H:mellanox.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; A:1; MX:1; Received-SPF: None (protection.outlook.com: mellanox.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; AM4PR05MB3427; 23:7wnYS34bUQkqZP7axjNMB2HAgjnNENZ1nWlZIY8mE?= =?us-ascii?Q?yYs9pjYQvON7Hl/JGLB38d8DM2+5694PB6drzEeW+TNjg5bGOXai3VOq8VUv?= =?us-ascii?Q?tT3sakjxaekFJiEqrJbaIZ6tLNcz4MHPep/xt1CXiaw0lr+5unvYDHQDHDaF?= =?us-ascii?Q?0ZNMeqIhJFco8D8ounMAvRn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NbtjkcgVzhDMiLjlZAX4o2bcwQ3anAmypWBPRY376OCJRy6ifbLh4JeOwW+qLxNPYlL+iOIdqRkjEnLPKW2MCvr7s9h2GAvH1X76MBlZvwu3Se7VnhQf9nQ6zguYkVzEeAe/UDHPPlBnoBiXt3/HiqYT+wW3Q==; 5:YYGGZlAdnNw8IHo6SIBWXI0/mzCb3o5+9+nSQa9cv+VeFaheToCPXGD+vic4TPHi+PgdjRtllTCEyKJjhuzTMWCSoBOHU3XTNkY7xD5kxFrCvyZ/VHmT9WraHxUgYraSomebsuo/WPB3g1A8OXOc1RsaK1V9QQiNV+qsROO65Qg=; 7:mfh7mHPpaGUE8a/KtY/uudTBluQ6J1Iavot5IvILAkrMST2rUqkTJOwxiGtZzIjBe470S1fDzzsTIVtKabbe6Lwyg5URMlFhQR4U9jF6GI+lAuA7GsgO9UP2gH1qN8lZcMmBJZhTMzmB/0lKxejJg16Q277GVYpoL5+wlJceqrAtIVy0KlNa9SngAJwRXPzs6ruujm1LOOo1fcSFXMq3CcFvha0b19e07p2Z3SZk+QK9Z4yVDblxYtelzuVFX3J+ SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Sep 2018 20:08:03.4967 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c5106d82-52cf-426d-27a1-08d62647449a X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR05MB3427 Subject: [dpdk-dev] [PATCH 2/3] app/testpmd: add MPLSoGRE encapsulation 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: Sat, 29 Sep 2018 20:08:07 -0000 Due to the complex encapsulation of MPLSoGRE flow action and based on the fact testpmd does not allocate memory, this patch adds a new command in testpmd to initialise a global structure containing the necessary information to make the outer layer of the packet. This same global structure will then be used by the flow command line in testpmd when the action mplsoudp_encap will be parsed, at this point, the conversion into such action becomes trivial. Signed-off-by: Ori Kam --- app/test-pmd/cmdline.c | 153 ++++++++++++++++++++++++++++ app/test-pmd/cmdline_flow.c | 113 ++++++++++++++++++++ app/test-pmd/testpmd.h | 15 +++ doc/guides/testpmd_app_ug/testpmd_funcs.rst | 46 +++++++++ 4 files changed, 327 insertions(+) diff --git a/app/test-pmd/cmdline.c b/app/test-pmd/cmdline.c index 10d9489..2428b04 100644 --- a/app/test-pmd/cmdline.c +++ b/app/test-pmd/cmdline.c @@ -15359,6 +15359,157 @@ static void cmd_set_mplsoudp_parsed(void *parsed_result, }, }; +/** Set MPLSoGRE encapsulation details */ +struct cmd_set_mplsogre_result { + cmdline_fixed_string_t set; + cmdline_fixed_string_t mplsogre; + cmdline_fixed_string_t pos_token; + cmdline_fixed_string_t ip_version; + uint32_t vlan_present:1; + uint32_t label; + cmdline_ipaddr_t ip_src; + cmdline_ipaddr_t ip_dst; + uint16_t tci; + struct ether_addr eth_src; + struct ether_addr eth_dst; +}; + +cmdline_parse_token_string_t cmd_set_mplsogre_set = + TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_result, set, "set"); +cmdline_parse_token_string_t cmd_set_mplsogre_mplsogre = + TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_result, mplsogre, + "mplsogre"); +cmdline_parse_token_string_t cmd_set_mplsogre_mplsogre_with_vlan = + TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_result, mplsogre, + "mplsogre-with-vlan"); +cmdline_parse_token_string_t cmd_set_mplsogre_ip_version = + TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_result, pos_token, + "ip-version"); +cmdline_parse_token_string_t cmd_set_mplsogre_ip_version_value = + TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_result, ip_version, + "ipv4#ipv6"); +cmdline_parse_token_string_t cmd_set_mplsogre_label = + TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_result, pos_token, + "label"); +cmdline_parse_token_num_t cmd_set_mplsogre_label_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_result, label, UINT32); +cmdline_parse_token_string_t cmd_set_mplsogre_ip_src = + TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_result, pos_token, + "ip-src"); +cmdline_parse_token_ipaddr_t cmd_set_mplsogre_ip_src_value = + TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_result, ip_src); +cmdline_parse_token_string_t cmd_set_mplsogre_ip_dst = + TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_result, pos_token, + "ip-dst"); +cmdline_parse_token_ipaddr_t cmd_set_mplsogre_ip_dst_value = + TOKEN_IPADDR_INITIALIZER(struct cmd_set_mplsogre_result, ip_dst); +cmdline_parse_token_string_t cmd_set_mplsogre_vlan = + TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_result, pos_token, + "vlan-tci"); +cmdline_parse_token_num_t cmd_set_mplsogre_vlan_value = + TOKEN_NUM_INITIALIZER(struct cmd_set_mplsogre_result, tci, UINT16); +cmdline_parse_token_string_t cmd_set_mplsogre_eth_src = + TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_result, pos_token, + "eth-src"); +cmdline_parse_token_etheraddr_t cmd_set_mplsogre_eth_src_value = + TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_result, eth_src); +cmdline_parse_token_string_t cmd_set_mplsogre_eth_dst = + TOKEN_STRING_INITIALIZER(struct cmd_set_mplsogre_result, pos_token, + "eth-dst"); +cmdline_parse_token_etheraddr_t cmd_set_mplsogre_eth_dst_value = + TOKEN_ETHERADDR_INITIALIZER(struct cmd_set_mplsogre_result, eth_dst); + +static void cmd_set_mplsogre_parsed(void *parsed_result, + __attribute__((unused)) struct cmdline *cl, + __attribute__((unused)) void *data) +{ + struct cmd_set_mplsogre_result *res = parsed_result; + union { + uint32_t mplsogre_label; + uint8_t label[3]; + } id = { + .mplsogre_label = + rte_cpu_to_be_32(res->label) & RTE_BE32(0x00ffffff), + }; + + if (strcmp(res->mplsogre, "mplsogre") == 0) + mplsogre_encap_conf.select_vlan = 0; + else if (strcmp(res->mplsogre, "mplsogre-with-vlan") == 0) + mplsogre_encap_conf.select_vlan = 1; + if (strcmp(res->ip_version, "ipv4") == 0) + mplsogre_encap_conf.select_ipv4 = 1; + else if (strcmp(res->ip_version, "ipv6") == 0) + mplsogre_encap_conf.select_ipv4 = 0; + else + return; + rte_memcpy(mplsogre_encap_conf.label, &id.label[1], 3); + if (mplsogre_encap_conf.select_ipv4) { + IPV4_ADDR_TO_UINT(res->ip_src, mplsogre_encap_conf.ipv4_src); + IPV4_ADDR_TO_UINT(res->ip_dst, mplsogre_encap_conf.ipv4_dst); + } else { + IPV6_ADDR_TO_ARRAY(res->ip_src, mplsogre_encap_conf.ipv6_src); + IPV6_ADDR_TO_ARRAY(res->ip_dst, mplsogre_encap_conf.ipv6_dst); + } + if (mplsogre_encap_conf.select_vlan) + mplsogre_encap_conf.vlan_tci = rte_cpu_to_be_16(res->tci); + rte_memcpy(mplsogre_encap_conf.eth_src, res->eth_src.addr_bytes, + ETHER_ADDR_LEN); + rte_memcpy(mplsogre_encap_conf.eth_dst, res->eth_dst.addr_bytes, + ETHER_ADDR_LEN); +} + +cmdline_parse_inst_t cmd_set_mplsogre = { + .f = cmd_set_mplsogre_parsed, + .data = NULL, + .help_str = "set mplsogre ip-version ipv4|ipv6 label