From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from EUR02-VE1-obe.outbound.protection.outlook.com (mail-eopbgr20055.outbound.protection.outlook.com [40.107.2.55]) by dpdk.org (Postfix) with ESMTP id A70C91B47A for ; Wed, 26 Sep 2018 23:01:41 +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=S9k0rjjCFkBqnI28/RzdmL71DJIU026JBhukfg/p9Ik=; b=B87qXmfCJzg/5iyvJZJN9nq6dr+7r/OFyUx/nKqw8UNlzdRIcfzb81TC0pz7O2RPZxgQViyM5V4PgU5GGUhZX/r0vpjMctkcTnl1+WSaZyZLD0ajXK4uz64Nkl7RWzZjU+ZAAnPZ/2FKH7Pcdz5867oQFB40PhIMXUEsOsEYbp0= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=orika@mellanox.com; Received: from mellanox.com (37.142.13.130) by DB6PR05MB3432.eurprd05.prod.outlook.com (2603:10a6:6:1e::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1164.25; Wed, 26 Sep 2018 21:01:38 +0000 From: Ori Kam To: 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: Wed, 26 Sep 2018 21:00:45 +0000 Message-Id: <1537995646-95260-3-git-send-email-orika@mellanox.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1537995646-95260-1-git-send-email-orika@mellanox.com> References: <1537116824-191205-1-git-send-email-orika@mellanox.com> <1537995646-95260-1-git-send-email-orika@mellanox.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [37.142.13.130] X-ClientProxiedBy: AM0PR02CA0018.eurprd02.prod.outlook.com (2603:10a6:208:3e::31) To DB6PR05MB3432.eurprd05.prod.outlook.com (2603:10a6:6:1e::19) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 33138b15-3119-47a3-0e8b-08d623f3415a 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:DB6PR05MB3432; X-Microsoft-Exchange-Diagnostics: 1; DB6PR05MB3432; 3:Cp89oMVibBWePgUthCcuzKyl0Abt8LAWs3cgQuGx3YIim6YSr7jK21Y9Erdoy6cc/PfQxIstc1dY2sdUQ2cQkOie1dm1JitC5iha3Q3cJQCpllRdlUiXsPXJI+nADaOMysgIfU1e559xoWvyaEPUQOXFlEJNjH5ASCndl7XkXufMDDdIY1/Fb57UVNdJXBOWZruZlMB3Mb3Lz8N8c7zIeQk9hsYFGVgDp/iSaI/2KFpMz3ML7P1vQr+byQDs9mqT; 25:t9lu7hwx4e8l1SgmSR6LmgyM6L1CS+0O9QIg4TZcJvvWE5sBHia9uO2elfkDsUsWqwhgwvbIa/YnWTOwYbTRcvXksL54ex0oQsMMs9zJhSWCVMTVacX7/ZfUBkRkuKNGda5Ji1waHGH/0a1lvtDt0XSrLYeWCsssQQsVD8WgnW9evOmN4FoW+1GY3/Vj60TTDECUgZ/hplM0wmrSkIXlZeVeKPEul3rsdBCX3xpDHPOA5sMTV8dOp7R8d03EKPmITP3UP76h/BS8nEW1RIOj5KVdvDlSB6Qa6jSx0Y9BVnYb6JxmW5E0tnNyBRp+BCOJc1wUgb6cJdjqVrQH9jBGZg==; 31:oT5MO7FRo+2NHYXQIqCfan7E1t79juoepeTrCo2zBqh9Jth2bKR3xcCbn/cm7lUqsBO4OA31mxorTU/wT4jOaZZYefLAUofgc6YzlM1CuQkxbuq7utQhBdnUeOywK9HAt9wfdMJZOA0vAuYbp6U8JKFzWfS71Y8pN7+mevpYFC0RaIk3P185OhtGMxmZNL/AgQoVCrGowCYqNUhUGsqVfKMEmMJyMe9+XEDNaxKRGqY= X-MS-TrafficTypeDiagnostic: DB6PR05MB3432: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr X-Microsoft-Exchange-Diagnostics: 1; DB6PR05MB3432; 20:HSxGIe42l7TsxViYxczY+5dx8vZdST+89DLs08pGAsRrfJdcRCdn1uSD2J1f/yKQz7C2ncodWVkPSReM10JHclRAOTvHosWRInxLF5lgzaeYPc2RKAjuaXdZEnxhd9DXd5uG51neemCmwEhOSRQYfYcrtH5v8gh11mVUSPmb93nupFRZze/bD3+SuYgHNPWJDfFeEw4xLPCMMWJHsa2HWyW72Patc+nbIQBfD5gQh9JKsRNHnk3KR+e3xM94UEvPotCw8kFrmUff5Z7SoDuHo7vGVKo2dqW+U+cmxI4eD4n7U83ypQcgNGRN5T6vlgNdyF+KAYR2c1F6AWMHex+PvN0LBMgO8TBO5rzP7rpJG4eqdMcerbpHveRf7S5nd8zu5d/UJYL44yHGEQfUQSo/j6JRXHiY3NJKQmJqc6KsgKw380M1wUhGfTWjF6fca9TeMaLgpDMOqQWEVVAG4EnxalVT/aKYnofuKaTeQejWOEoQqFxr+6F/MZfa51J2+Xtl; 4:DhTh1qC+KcvudE2uciFhy1vxLc/DdwPIV94nb5zN9bgA7X4XrF8WPSxqO0sfNXhwf+Rd4xPA/1aW8lgv/YeqLPp8gLD0EfHrYFWLjspyXIDFS4IYGSMaWfVJwumRzzFe+db2fEQxe+T07yJ7QQyWB7XdL2HT09Iv+pcaZLbOYisVi14Q9m2nV6iLnZP19XoYoOfar7lxxVWI/aeZTvTQryjWS/jhbwKjSXTay6Y1BsI4vgnhiqXpszPhsbwgbqvJHumbsrY6JjWePBj+dvhV1A== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(3002001)(10201501046)(3231355)(944501410)(52105095)(6055026)(149066)(150057)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123558120)(20161123564045)(20161123560045)(201708071742011)(7699051); SRVR:DB6PR05MB3432; BCL:0; PCL:0; RULEID:; SRVR:DB6PR05MB3432; X-Forefront-PRVS: 08076ABC99 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(376002)(396003)(39860400002)(136003)(346002)(366004)(199004)(189003)(305945005)(50226002)(478600001)(2906002)(16586007)(48376002)(386003)(4720700003)(55016002)(6666003)(8936002)(486006)(7696005)(51416003)(53936002)(81156014)(5660300001)(7736002)(8676002)(81166006)(50466002)(52116002)(76176011)(69596002)(8886007)(97736004)(186003)(16526019)(446003)(105586002)(36756003)(14444005)(34290500001)(107886003)(316002)(25786009)(106356001)(68736007)(66066001)(6116002)(11346002)(956004)(3846002)(86362001)(33026002)(47776003)(26005)(4326008)(476003)(2616005)(21086003); DIR:OUT; SFP:1101; SCL:1; SRVR:DB6PR05MB3432; 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; DB6PR05MB3432; 23:Rk4K1+TsQ28MxTJC6eR/jJezy6JUdY9EcklXKJUvM?= =?us-ascii?Q?oSSBp45SIz+Wff2bVrb4K58kKTGrR8ZhSjHy01Neaynfk9kZ4ugzVen/LKeo?= =?us-ascii?Q?FmBC+yvxeK0Vpn+jk7JG1gq37e3/7AiO2cTU6Te9tmkozUm0jCN2f2NHnKjK?= =?us-ascii?Q?dZJKyOwzbArunxZ61VF4brBBO+UYr+Cypi+W8QpLsNAQmbL8hhgPOKjhCL5E?= =?us-ascii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j3ELtZWZsdsYs54RmxQStMDEtudIWsMh7Z/bfYNVluiV2yxS9eliZUiqTXDLQCiiQgyLtx5Oqnh0AvIEg==; 5:jRvFMvQlSn72VDO+QLYSXhnkkI2DpxeObLW6g57uGhW+N59RszFZSGqMGE6bLMz4gUiTSXx5a/SblhEB+88w1tsbBJkFsAyJCC0VscEPklXBWG8ON7gL4oG5CvscY+pYv9/ah52J9rAcDcENUldZvM2UPTA/rUdwNlJhSr6h91E=; 7:SoapKOpJnibBkTxCzQj+4ekXvUWpUvHQjpdetNRKaCuaF/9T7lkRVUZHhXp2uz5h/JEY5ixmQdUvcaLmYR0GK3CC1TVoqxx9Y0i9zPpz8kH4kBeP9AeMWPvn1G5IavoNUv43R/pFk0ruOWpSYRApksAFIGfvHZ8PPbPClicmfMHoJWVjnmiCZqaW4xwufZsK4xxNQmlX0aOkv8zYrqWAvx80UfxlS6E9Pd80Cax6JcKqwj61hAw3ahh0eRC0sH+Y SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Sep 2018 21:01:38.3298 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 33138b15-3119-47a3-0e8b-08d623f3415a X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB6PR05MB3432 Subject: [dpdk-dev] [PATCH v2 2/3] app/testpmd: convert testpmd encap commands to new API 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: Wed, 26 Sep 2018 21:01:42 -0000 Currently there are 2 encapsulation commands in testpmd one for VXLAN and one for NVGRE, both of those commands are using the old rte encap command. This commit update the commands to work with the new tunnel encap actions. The reason that we have different encapsulation commands, one for VXLAN and one for NVGRE is the ease of use in testpmd, both commands are using the same rte flow action for tunnel encap. Signed-off-by: Ori Kam --- app/test-pmd/cmdline_flow.c | 294 +++++++++++++++++++++----------------------- app/test-pmd/config.c | 3 + 2 files changed, 140 insertions(+), 157 deletions(-) diff --git a/app/test-pmd/cmdline_flow.c b/app/test-pmd/cmdline_flow.c index f926060..349e822 100644 --- a/app/test-pmd/cmdline_flow.c +++ b/app/test-pmd/cmdline_flow.c @@ -262,37 +262,13 @@ struct action_rss_data { uint16_t queue[ACTION_RSS_QUEUE_NUM]; }; -/** Maximum number of items in struct rte_flow_action_vxlan_encap. */ -#define ACTION_VXLAN_ENCAP_ITEMS_NUM 6 - -/** Storage for struct rte_flow_action_vxlan_encap including external data. */ -struct action_vxlan_encap_data { - struct rte_flow_action_vxlan_encap conf; - struct rte_flow_item items[ACTION_VXLAN_ENCAP_ITEMS_NUM]; - struct rte_flow_item_eth item_eth; - struct rte_flow_item_vlan item_vlan; - union { - struct rte_flow_item_ipv4 item_ipv4; - struct rte_flow_item_ipv6 item_ipv6; - }; - struct rte_flow_item_udp item_udp; - struct rte_flow_item_vxlan item_vxlan; -}; +/** Maximum buffer size for the encap data. */ +#define ACTION_TUNNEL_ENCAP_MAX_BUFFER_SIZE 64 -/** Maximum number of items in struct rte_flow_action_nvgre_encap. */ -#define ACTION_NVGRE_ENCAP_ITEMS_NUM 5 - -/** Storage for struct rte_flow_action_nvgre_encap including external data. */ -struct action_nvgre_encap_data { - struct rte_flow_action_nvgre_encap conf; - struct rte_flow_item items[ACTION_NVGRE_ENCAP_ITEMS_NUM]; - struct rte_flow_item_eth item_eth; - struct rte_flow_item_vlan item_vlan; - union { - struct rte_flow_item_ipv4 item_ipv4; - struct rte_flow_item_ipv6 item_ipv6; - }; - struct rte_flow_item_nvgre item_nvgre; +/** Storage for struct rte_flow_action_tunnel_encap including external data. */ +struct action_tunnel_encap_data { + struct rte_flow_action_tunnel_encap conf; + uint8_t buf[ACTION_TUNNEL_ENCAP_MAX_BUFFER_SIZE]; }; /** Maximum number of subsequent tokens and arguments on the stack. */ @@ -2438,8 +2414,8 @@ static int comp_vc_action_rss_queue(struct context *, const struct token *, .name = "vxlan_encap", .help = "VXLAN encapsulation, uses configuration set by \"set" " vxlan\"", - .priv = PRIV_ACTION(VXLAN_ENCAP, - sizeof(struct action_vxlan_encap_data)), + .priv = PRIV_ACTION(TUNNEL_ENCAP, + sizeof(struct action_tunnel_encap_data)), .next = NEXT(NEXT_ENTRY(ACTION_NEXT)), .call = parse_vc_action_vxlan_encap, }, @@ -2448,7 +2424,7 @@ static int comp_vc_action_rss_queue(struct context *, const struct token *, .help = "Performs a decapsulation action by stripping all" " headers of the VXLAN tunnel network overlay from the" " matched flow.", - .priv = PRIV_ACTION(VXLAN_DECAP, 0), + .priv = PRIV_ACTION(TUNNEL_DECAP, 0), .next = NEXT(NEXT_ENTRY(ACTION_NEXT)), .call = parse_vc, }, @@ -2456,8 +2432,8 @@ static int comp_vc_action_rss_queue(struct context *, const struct token *, .name = "nvgre_encap", .help = "NVGRE encapsulation, uses configuration set by \"set" " nvgre\"", - .priv = PRIV_ACTION(NVGRE_ENCAP, - sizeof(struct action_nvgre_encap_data)), + .priv = PRIV_ACTION(TUNNEL_ENCAP, + sizeof(struct action_tunnel_encap_data)), .next = NEXT(NEXT_ENTRY(ACTION_NEXT)), .call = parse_vc_action_nvgre_encap, }, @@ -2466,7 +2442,7 @@ static int comp_vc_action_rss_queue(struct context *, const struct token *, .help = "Performs a decapsulation action by stripping all" " headers of the NVGRE tunnel network overlay from the" " matched flow.", - .priv = PRIV_ACTION(NVGRE_DECAP, 0), + .priv = PRIV_ACTION(TUNNEL_DECAP, 0), .next = NEXT(NEXT_ENTRY(ACTION_NEXT)), .call = parse_vc, }, @@ -3034,6 +3010,9 @@ static int comp_vc_action_rss_queue(struct context *, const struct token *, return len; } +/** IP next protocol UDP. */ +#define IP_PROTO_UDP 0x11 + /** Parse VXLAN encap action. */ static int parse_vc_action_vxlan_encap(struct context *ctx, const struct token *token, @@ -3042,7 +3021,32 @@ static int comp_vc_action_rss_queue(struct context *, const struct token *, { struct buffer *out = buf; struct rte_flow_action *action; - struct action_vxlan_encap_data *action_vxlan_encap_data; + struct action_tunnel_encap_data *action_vxlan_encap_data; + struct rte_flow_item_eth eth = { .type = 0, }; + struct rte_flow_item_vlan vlan = { + .tci = vxlan_encap_conf.vlan_tci, + .inner_type = 0, + }; + struct rte_flow_item_ipv4 ipv4 = { + .hdr = { + .src_addr = vxlan_encap_conf.ipv4_src, + .dst_addr = vxlan_encap_conf.ipv4_dst, + .next_proto_id = IP_PROTO_UDP, + }, + }; + struct rte_flow_item_ipv6 ipv6 = { + .hdr = { + .proto = IP_PROTO_UDP, + }, + }; + struct rte_flow_item_udp udp = { + .hdr = { + .src_port = vxlan_encap_conf.udp_src, + .dst_port = vxlan_encap_conf.udp_dst, + }, + }; + struct rte_flow_item_vxlan vxlan = { .flags = 0, }; + uint8_t *header; int ret; ret = parse_vc(ctx, token, str, len, buf, size); @@ -3057,83 +3061,58 @@ static int comp_vc_action_rss_queue(struct context *, const struct token *, /* Point to selected object. */ ctx->object = out->args.vc.data; ctx->objmask = NULL; - /* Set up default configuration. */ + /* Copy the headers to the buffer. */ action_vxlan_encap_data = ctx->object; - *action_vxlan_encap_data = (struct action_vxlan_encap_data){ - .conf = (struct rte_flow_action_vxlan_encap){ - .definition = action_vxlan_encap_data->items, - }, - .items = { - { - .type = RTE_FLOW_ITEM_TYPE_ETH, - .spec = &action_vxlan_encap_data->item_eth, - .mask = &rte_flow_item_eth_mask, - }, - { - .type = RTE_FLOW_ITEM_TYPE_VLAN, - .spec = &action_vxlan_encap_data->item_vlan, - .mask = &rte_flow_item_vlan_mask, - }, - { - .type = RTE_FLOW_ITEM_TYPE_IPV4, - .spec = &action_vxlan_encap_data->item_ipv4, - .mask = &rte_flow_item_ipv4_mask, - }, - { - .type = RTE_FLOW_ITEM_TYPE_UDP, - .spec = &action_vxlan_encap_data->item_udp, - .mask = &rte_flow_item_udp_mask, - }, - { - .type = RTE_FLOW_ITEM_TYPE_VXLAN, - .spec = &action_vxlan_encap_data->item_vxlan, - .mask = &rte_flow_item_vxlan_mask, - }, - { - .type = RTE_FLOW_ITEM_TYPE_END, - }, - }, - .item_eth.type = 0, - .item_vlan = { - .tci = vxlan_encap_conf.vlan_tci, - .inner_type = 0, - }, - .item_ipv4.hdr = { - .src_addr = vxlan_encap_conf.ipv4_src, - .dst_addr = vxlan_encap_conf.ipv4_dst, + *action_vxlan_encap_data = (struct action_tunnel_encap_data) { + .conf = (struct rte_flow_action_tunnel_encap){ + .buf = action_vxlan_encap_data->buf, }, - .item_udp.hdr = { - .src_port = vxlan_encap_conf.udp_src, - .dst_port = vxlan_encap_conf.udp_dst, - }, - .item_vxlan.flags = 0, + .buf = {}, }; - memcpy(action_vxlan_encap_data->item_eth.dst.addr_bytes, + header = action_vxlan_encap_data->buf; + if (vxlan_encap_conf.select_vlan) + eth.type = rte_cpu_to_be_16(ETHER_TYPE_VLAN); + else if (vxlan_encap_conf.select_ipv4) + eth.type = rte_cpu_to_be_16(ETHER_TYPE_IPv4); + else + eth.type = rte_cpu_to_be_16(ETHER_TYPE_IPv6); + memcpy(eth.dst.addr_bytes, vxlan_encap_conf.eth_dst, ETHER_ADDR_LEN); - memcpy(action_vxlan_encap_data->item_eth.src.addr_bytes, + memcpy(eth.src.addr_bytes, vxlan_encap_conf.eth_src, ETHER_ADDR_LEN); - if (!vxlan_encap_conf.select_ipv4) { - memcpy(&action_vxlan_encap_data->item_ipv6.hdr.src_addr, + memcpy(header, ð, sizeof(eth)); + header += sizeof(eth); + if (vxlan_encap_conf.select_vlan) { + if (vxlan_encap_conf.select_ipv4) + vlan.inner_type = rte_cpu_to_be_16(ETHER_TYPE_IPv4); + else + vlan.inner_type = rte_cpu_to_be_16(ETHER_TYPE_IPv6); + memcpy(header, &vlan, sizeof(vlan)); + header += sizeof(vlan); + } + if (vxlan_encap_conf.select_ipv4) { + memcpy(header, &ipv4, sizeof(ipv4)); + header += sizeof(ipv4); + } else { + memcpy(&ipv6.hdr.src_addr, &vxlan_encap_conf.ipv6_src, sizeof(vxlan_encap_conf.ipv6_src)); - memcpy(&action_vxlan_encap_data->item_ipv6.hdr.dst_addr, + memcpy(&ipv6.hdr.dst_addr, &vxlan_encap_conf.ipv6_dst, sizeof(vxlan_encap_conf.ipv6_dst)); - action_vxlan_encap_data->items[2] = (struct rte_flow_item){ - .type = RTE_FLOW_ITEM_TYPE_IPV6, - .spec = &action_vxlan_encap_data->item_ipv6, - .mask = &rte_flow_item_ipv6_mask, - }; + memcpy(header, &ipv6, sizeof(ipv6)); + header += sizeof(ipv6); } - if (!vxlan_encap_conf.select_vlan) - action_vxlan_encap_data->items[1].type = - RTE_FLOW_ITEM_TYPE_VOID; - memcpy(action_vxlan_encap_data->item_vxlan.vni, vxlan_encap_conf.vni, - RTE_DIM(vxlan_encap_conf.vni)); + memcpy(header, &udp, sizeof(udp)); + header += sizeof(udp); + memcpy(vxlan.vni, vxlan_encap_conf.vni, RTE_DIM(vxlan_encap_conf.vni)); + memcpy(header, &vxlan, sizeof(vxlan)); + header += sizeof(vxlan); + action_vxlan_encap_data->conf.size = header - + action_vxlan_encap_data->buf; action->conf = &action_vxlan_encap_data->conf; return ret; } - /** Parse NVGRE encap action. */ static int parse_vc_action_nvgre_encap(struct context *ctx, const struct token *token, @@ -3142,7 +3121,26 @@ static int comp_vc_action_rss_queue(struct context *, const struct token *, { struct buffer *out = buf; struct rte_flow_action *action; - struct action_nvgre_encap_data *action_nvgre_encap_data; + struct action_tunnel_encap_data *action_nvgre_encap_data; + struct rte_flow_item_eth eth = { .type = 0, }; + struct rte_flow_item_vlan vlan = { + .tci = nvgre_encap_conf.vlan_tci, + .inner_type = 0, + }; + struct rte_flow_item_ipv4 ipv4 = { + .hdr = { + .src_addr = nvgre_encap_conf.ipv4_src, + .dst_addr = nvgre_encap_conf.ipv4_dst, + .next_proto_id = IP_PROTO_UDP, + }, + }; + struct rte_flow_item_ipv6 ipv6 = { + .hdr = { + .proto = IP_PROTO_UDP, + }, + }; + struct rte_flow_item_nvgre nvgre = { .flow_id = 0, }; + uint8_t *header; int ret; ret = parse_vc(ctx, token, str, len, buf, size); @@ -3157,74 +3155,56 @@ static int comp_vc_action_rss_queue(struct context *, const struct token *, /* Point to selected object. */ ctx->object = out->args.vc.data; ctx->objmask = NULL; - /* Set up default configuration. */ + /* Copy the headers to the buffer. */ action_nvgre_encap_data = ctx->object; - *action_nvgre_encap_data = (struct action_nvgre_encap_data){ - .conf = (struct rte_flow_action_nvgre_encap){ - .definition = action_nvgre_encap_data->items, - }, - .items = { - { - .type = RTE_FLOW_ITEM_TYPE_ETH, - .spec = &action_nvgre_encap_data->item_eth, - .mask = &rte_flow_item_eth_mask, - }, - { - .type = RTE_FLOW_ITEM_TYPE_VLAN, - .spec = &action_nvgre_encap_data->item_vlan, - .mask = &rte_flow_item_vlan_mask, - }, - { - .type = RTE_FLOW_ITEM_TYPE_IPV4, - .spec = &action_nvgre_encap_data->item_ipv4, - .mask = &rte_flow_item_ipv4_mask, - }, - { - .type = RTE_FLOW_ITEM_TYPE_NVGRE, - .spec = &action_nvgre_encap_data->item_nvgre, - .mask = &rte_flow_item_nvgre_mask, - }, - { - .type = RTE_FLOW_ITEM_TYPE_END, - }, - }, - .item_eth.type = 0, - .item_vlan = { - .tci = nvgre_encap_conf.vlan_tci, - .inner_type = 0, - }, - .item_ipv4.hdr = { - .src_addr = nvgre_encap_conf.ipv4_src, - .dst_addr = nvgre_encap_conf.ipv4_dst, + *action_nvgre_encap_data = (struct action_tunnel_encap_data) { + .conf = (struct rte_flow_action_tunnel_encap){ + .buf = action_nvgre_encap_data->buf, }, - .item_nvgre.flow_id = 0, + .buf = {}, }; - memcpy(action_nvgre_encap_data->item_eth.dst.addr_bytes, + header = action_nvgre_encap_data->buf; + if (nvgre_encap_conf.select_vlan) + eth.type = rte_cpu_to_be_16(ETHER_TYPE_VLAN); + else if (nvgre_encap_conf.select_ipv4) + eth.type = rte_cpu_to_be_16(ETHER_TYPE_IPv4); + else + eth.type = rte_cpu_to_be_16(ETHER_TYPE_IPv6); + memcpy(eth.dst.addr_bytes, nvgre_encap_conf.eth_dst, ETHER_ADDR_LEN); - memcpy(action_nvgre_encap_data->item_eth.src.addr_bytes, + memcpy(eth.src.addr_bytes, nvgre_encap_conf.eth_src, ETHER_ADDR_LEN); - if (!nvgre_encap_conf.select_ipv4) { - memcpy(&action_nvgre_encap_data->item_ipv6.hdr.src_addr, + memcpy(header, ð, sizeof(eth)); + header += sizeof(eth); + if (nvgre_encap_conf.select_vlan) { + if (nvgre_encap_conf.select_ipv4) + vlan.inner_type = rte_cpu_to_be_16(ETHER_TYPE_IPv4); + else + vlan.inner_type = rte_cpu_to_be_16(ETHER_TYPE_IPv6); + memcpy(header, &vlan, sizeof(vlan)); + header += sizeof(vlan); + } + if (nvgre_encap_conf.select_ipv4) { + memcpy(header, &ipv4, sizeof(ipv4)); + header += sizeof(ipv4); + } else { + memcpy(&ipv6.hdr.src_addr, &nvgre_encap_conf.ipv6_src, sizeof(nvgre_encap_conf.ipv6_src)); - memcpy(&action_nvgre_encap_data->item_ipv6.hdr.dst_addr, + memcpy(&ipv6.hdr.dst_addr, &nvgre_encap_conf.ipv6_dst, sizeof(nvgre_encap_conf.ipv6_dst)); - action_nvgre_encap_data->items[2] = (struct rte_flow_item){ - .type = RTE_FLOW_ITEM_TYPE_IPV6, - .spec = &action_nvgre_encap_data->item_ipv6, - .mask = &rte_flow_item_ipv6_mask, - }; + memcpy(header, &ipv6, sizeof(ipv6)); + header += sizeof(ipv6); } - if (!nvgre_encap_conf.select_vlan) - action_nvgre_encap_data->items[1].type = - RTE_FLOW_ITEM_TYPE_VOID; - memcpy(action_nvgre_encap_data->item_nvgre.tni, nvgre_encap_conf.tni, - RTE_DIM(nvgre_encap_conf.tni)); + memcpy(nvgre.tni, nvgre_encap_conf.tni, RTE_DIM(nvgre_encap_conf.tni)); + memcpy(header, &nvgre, sizeof(nvgre)); + header += sizeof(nvgre); + action_nvgre_encap_data->conf.size = header - + action_nvgre_encap_data->buf; action->conf = &action_nvgre_encap_data->conf; return ret; } - /** Parse tokens for destroy command. */ static int parse_destroy(struct context *ctx, const struct token *token, diff --git a/app/test-pmd/config.c b/app/test-pmd/config.c index 14ccd68..99a82de 100644 --- a/app/test-pmd/config.c +++ b/app/test-pmd/config.c @@ -1153,6 +1153,9 @@ enum item_spec_type { sizeof(struct rte_flow_action_of_pop_mpls)), MK_FLOW_ACTION(OF_PUSH_MPLS, sizeof(struct rte_flow_action_of_push_mpls)), + MK_FLOW_ACTION(TUNNEL_ENCAP, + sizeof(struct rte_flow_action_tunnel_encap)), + MK_FLOW_ACTION(TUNNEL_DECAP, 0), }; /** Compute storage space needed by action configuration and copy it. */ -- 1.8.3.1