From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 14961A052B; Wed, 29 Jul 2020 10:29:34 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 9FB711C025; Wed, 29 Jul 2020 10:29:25 +0200 (CEST) Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-eopbgr30065.outbound.protection.outlook.com [40.107.3.65]) by dpdk.org (Postfix) with ESMTP id A835F1BFD6 for ; Wed, 29 Jul 2020 10:29:22 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=be52JcN43Rq6n/6+0lMYfdOKou1/p30GXaWFBdBO0LK4Nw5cxYP/Pabn9e+Sx7M4xdullB23Q8/7RVza53OfV+Ukcc6sS5Y4Soctbhdb9KJFw7wfmTHlX34czJlTw2LIedh0YOz1/g6Rvs+633m0nwuU1r71cavxeDwhMa4fQBKGY2Z5LZM3vSmzYjX6H2Cv15pwG0Ah4XwvWF1O05qJdD6oX1UvbdWZPrtvO8ib0M+VQcQ1BYoUXQ0zXA7hkblRbR5j4NCPnzZhwL5tktF4ENnxHDNWXuQV7xbKrQfj9/WCxE/IJQRwSQUBDZuN0jrIge+kqkH9vDbJi0sTif00AA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=IFJ7+i98TIreOEKdXmpsgqRlrTggK4VJMx8dl4/GREg=; b=c+u0qNXeuM1oCDYlF2mcDLXfRx3QB1FNuz0dvmZmrqe6yLEGQm131hl4ySqavnS23fg7ylg+718z855cDeh5Z/ufuob68CEJrr4iZxz6ZFps8taY29qqZTSyVtiWeWL4uZxfGWJQJvXw3K8JRdxBjeAy5W527znD2726hkAqg+guUOsoZhAu8hD/QeSaeYEaGiD1DyIyiPS9Jf7GmlJeN8BYceP4FCP4TgqJtKMhRTlnWuzg/sKKHFrUJLxCTSO2wutrt7PK+1Yrrf7NolJf7LYOOWicn39edxMAgx32huqi1SI+s7bma90C0/zMyO5ryjqNvcfXDWyyeAovov0xdQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=mellanox.com; dmarc=pass action=none header.from=mellanox.com; dkim=pass header.d=mellanox.com; arc=none 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=IFJ7+i98TIreOEKdXmpsgqRlrTggK4VJMx8dl4/GREg=; b=tCotLkYTRpfMJ6J35aCmvcq0gWlmnhZuwSqG5zdp39Nr8akeC3uoQ5Y0G+B6S5RuNm9Yl0I+sPasCqhmDDQVoKKyVJRkMKI8LNWPTXhRrZy2bDpQ5F/PZNu0ej0vt2uOsvoVI6bWHyf0QfLR/5KffH+PgD91oI6utKANYmKsI2s= Authentication-Results: dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=none action=none header.from=mellanox.com; Received: from AM0PR05MB4209.eurprd05.prod.outlook.com (2603:10a6:208:61::22) by AM4PR05MB3204.eurprd05.prod.outlook.com (2603:10a6:205:3::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3239.16; Wed, 29 Jul 2020 08:29:21 +0000 Received: from AM0PR05MB4209.eurprd05.prod.outlook.com ([fe80::3949:70c3:126:3972]) by AM0PR05MB4209.eurprd05.prod.outlook.com ([fe80::3949:70c3:126:3972%7]) with mapi id 15.20.3216.034; Wed, 29 Jul 2020 08:29:21 +0000 From: Ophir Munk To: dev@dpdk.org, Wenzhuo Lu , Beilei Xing , Bernard Iremonger , Thomas Monjalon Cc: Ophir Munk Date: Wed, 29 Jul 2020 08:29:03 +0000 Message-Id: <20200729082905.19499-2-ophirmu@mellanox.com> X-Mailer: git-send-email 2.8.4 In-Reply-To: <20200729082905.19499-1-ophirmu@mellanox.com> References: <20200729082905.19499-1-ophirmu@mellanox.com> Content-Type: text/plain X-ClientProxiedBy: AM0PR05CA0079.eurprd05.prod.outlook.com (2603:10a6:208:136::19) To AM0PR05MB4209.eurprd05.prod.outlook.com (2603:10a6:208:61::22) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from mellanox.com (37.142.13.130) by AM0PR05CA0079.eurprd05.prod.outlook.com (2603:10a6:208:136::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3239.16 via Frontend Transport; Wed, 29 Jul 2020 08:29:20 +0000 X-Mailer: git-send-email 2.8.4 X-Originating-IP: [37.142.13.130] X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-HT: Tenant X-MS-Office365-Filtering-Correlation-Id: efb2a54c-ab5a-4ff6-0d6e-08d833997e37 X-MS-TrafficTypeDiagnostic: AM4PR05MB3204: X-LD-Processed: a652971c-7d2e-4d9b-a6a4-d149256f461b,ExtAddr X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:397; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: lvvoq+zbFDu7vpejSCw4v2N44R1zHf+R+1kSud3qMvp4Qun/F/tEkVhu0ZSny8WgDM+IoPP4aMLb1SxVZghoz4VJi9R15L831ByJ4SOYAMjH1x1I8Z+jg0xtBRyc43Ymv0/MLwU3FyDONZ5EyEhPAkclrE5RyPMmZaGf3y0RLymEeHcPSNJeBdoKokyoRfDWb4oFY+zoQd2RduRYYtoTMjshE87t5yh4lWE671E/Tks9Q7C6LTtXbH0FMgu40wazKbNoIWFp/uBHhKZRH7yHOQ2zbqyI/7US+pxH4CgYy+t0mJiKCM9XxiWOvjEDQKvs X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:AM0PR05MB4209.eurprd05.prod.outlook.com; PTR:; CAT:NONE; SFTY:; SFS:(4636009)(366004)(346002)(136003)(376002)(39860400002)(396003)(66946007)(66556008)(66476007)(16526019)(478600001)(186003)(2906002)(1076003)(26005)(8676002)(8936002)(5660300002)(2616005)(956004)(83380400001)(316002)(110136005)(4326008)(36756003)(6666004)(8886007)(55016002)(107886003)(52116002)(7696005)(86362001); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData: nhdTIgIFVHpWdxmzVd/kxElzGPG0BX+bSDLXkpOukq62g1Bb46PHQrqdseSwHCtYCcUXDg4a3pVpVZYCY3FUWb3TnXgQ3gnI9bxqbkaOZBWocv7e1fkU62ZM3+r/ELGCQjy1oGQVjA/3+GGCa/NcC12mY/ZziYAI//oMIVtRABYKzBP++eB0ilDm9wCv0BBIvUnoOryXi1dreWWwTx3No8cYMvPol6lTamN2bjdZqqCGwA1OrpLQFUxxdnCdjobQ1jjKHOcVmtjm9ox5Ujpwp2JUPJQdZQO8Pvi9K5ng0uDCNMm9jOm1ZUJk2vAQ9CvOYDzXY7BgowTRja49/2n2Q9PLiYSGaY5WRvgK1ySc+xBQOXWj4L2dHnpJf3Ku+wDrpCA44BgDW5q9hYtO/Tu70sdGQPY8IAobxGXH03+eVJ0yLQLhaaUivYrbIfEXsi7zu4tNOemIvSB+xoa+hgN/M1UGhFdJeEdzgXn272XDbYdLj0+S3uPtJBfNhdIPLap8wDb8cOgJQ2twRs5Y+kk0Ut5YYWUpzzElXYv4fD/RPArF8SM921ZSj3TqK9oS+O2uitM9R83AnECgE6UK9G1SpnQPmq6KyUtDCH6qCA/EY1I+TGMJHSrf+nAZJ6aVdk3kAmegG2390ACrojdqOPvuGQ== X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: efb2a54c-ab5a-4ff6-0d6e-08d833997e37 X-MS-Exchange-CrossTenant-AuthSource: AM0PR05MB4209.eurprd05.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Jul 2020 08:29:21.6663 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: a652971c-7d2e-4d9b-a6a4-d149256f461b X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: uAxa0uTKkuKs30ZKB/MiO9NlPbsCWgvX+LwLAl05N6wRH8w/rCGYqYVlHhkVOgPgXfn+vBQSVDo1Eu7zRhuUgg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR05MB3204 Subject: [dpdk-dev] [PATCH v1 1/3] app/testpmd: add GENEVE parsing 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: , Errors-To: dev-bounces@dpdk.org Sender: "dev" GENEVE is a widely used tunneling protocol in modern Virtualized Networks. testpmd already supports parsing of several tunneling protocols including VXLAN, VXLAN-GPE, GRE. This commit adds GENEVE parsing of inner protocols (IPv4-0x0800, IPv6-0x86dd, Ethernet-0x6558) based on IETF draft-ietf-nvo3-geneve-09. GENEVE is considered more flexible than the other protocols. In terms of protocol format GENEVE header has a variable length options as opposed to other tunneling protocols which have a fixed header size. Signed-off-by: Ophir Munk --- app/test-pmd/csumonly.c | 70 ++++++++++++++++++++++++++++++++++++++++++- app/test-pmd/testpmd.h | 1 + lib/librte_net/Makefile | 2 +- lib/librte_net/meson.build | 3 +- lib/librte_net/rte_geneve.h | 72 +++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 145 insertions(+), 3 deletions(-) create mode 100644 lib/librte_net/rte_geneve.h diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index 0a96b24..5f29868 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -43,6 +43,7 @@ #include #include #include +#include #include "testpmd.h" @@ -63,6 +64,7 @@ #endif uint16_t vxlan_gpe_udp_port = 4790; +uint16_t geneve_udp_port = RTE_GENEVE_DEFAULT_PORT; /* structure that caches offload info for the current packet */ struct testpmd_offload_info { @@ -333,6 +335,64 @@ parse_vxlan_gpe(struct rte_udp_hdr *udp_hdr, info->l2_len += RTE_ETHER_VXLAN_GPE_HLEN; } +/* Fill in outer layers length */ +static void +update_tunnel_outer(struct testpmd_offload_info *info) +{ + info->is_tunnel = 1; + info->outer_ethertype = info->ethertype; + info->outer_l2_len = info->l2_len; + info->outer_l3_len = info->l3_len; + info->outer_l4_proto = info->l4_proto; +} + +/* Parse a geneve header */ +static void +parse_geneve(struct rte_udp_hdr *udp_hdr, + struct testpmd_offload_info *info) +{ + struct rte_ether_hdr *eth_hdr; + struct rte_ipv4_hdr *ipv4_hdr; + struct rte_ipv6_hdr *ipv6_hdr; + struct rte_geneve_hdr *geneve_hdr; + uint16_t geneve_len; + + /* Check udp destination port. */ + if (udp_hdr->dst_port != _htons(geneve_udp_port)) + return; + + geneve_hdr = (struct rte_geneve_hdr *)((char *)udp_hdr + + sizeof(struct rte_udp_hdr)); + geneve_len = sizeof(struct rte_geneve_hdr) + geneve_hdr->opt_len * 4; + if (!geneve_hdr->proto || geneve_hdr->proto == + _htons(RTE_GENEVE_TYPE_IPV4)) { + update_tunnel_outer(info); + ipv4_hdr = (struct rte_ipv4_hdr *)((char *)geneve_hdr + + geneve_len); + parse_ipv4(ipv4_hdr, info); + info->ethertype = _htons(RTE_ETHER_TYPE_IPV4); + info->l2_len = 0; + } else if (geneve_hdr->proto == _htons(RTE_GENEVE_TYPE_IPV6)) { + update_tunnel_outer(info); + ipv6_hdr = (struct rte_ipv6_hdr *)((char *)geneve_hdr + + geneve_len); + info->ethertype = _htons(RTE_ETHER_TYPE_IPV6); + parse_ipv6(ipv6_hdr, info); + info->l2_len = 0; + + } else if (geneve_hdr->proto == _htons(RTE_GENEVE_TYPE_ETH)) { + update_tunnel_outer(info); + eth_hdr = (struct rte_ether_hdr *)((char *)geneve_hdr + + geneve_len); + parse_ethernet(eth_hdr, info); + } else + return; + + info->l2_len += + (sizeof(struct rte_udp_hdr) + sizeof(struct rte_geneve_hdr) + + ((struct rte_geneve_hdr *)geneve_hdr)->opt_len * 4); +} + /* Parse a gre header */ static void parse_gre(struct simple_gre_hdr *gre_hdr, struct testpmd_offload_info *info) @@ -873,9 +933,17 @@ pkt_burst_checksum_forward(struct fwd_stream *fs) } parse_vxlan(udp_hdr, &info, m->packet_type); - if (info.is_tunnel) + if (info.is_tunnel) { tx_ol_flags |= PKT_TX_TUNNEL_VXLAN; + goto tunnel_update; + } + parse_geneve(udp_hdr, &info); + if (info.is_tunnel) { + tx_ol_flags |= + PKT_TX_TUNNEL_GENEVE; + goto tunnel_update; + } } else if (info.l4_proto == IPPROTO_GRE) { struct simple_gre_hdr *gre_hdr; diff --git a/app/test-pmd/testpmd.h b/app/test-pmd/testpmd.h index 25a12b1..a60e009 100644 --- a/app/test-pmd/testpmd.h +++ b/app/test-pmd/testpmd.h @@ -456,6 +456,7 @@ extern struct fwd_lcore **fwd_lcores; extern struct fwd_stream **fwd_streams; extern uint16_t vxlan_gpe_udp_port; /**< UDP port of tunnel VXLAN-GPE. */ +extern uint16_t geneve_udp_port; /**< UDP port of tunnel GENEVE. */ extern portid_t nb_peer_eth_addrs; /**< Number of peer ethernet addresses. */ extern struct rte_ether_addr peer_eth_addrs[RTE_MAX_ETHPORTS]; diff --git a/lib/librte_net/Makefile b/lib/librte_net/Makefile index 9830e77..9fe99af 100644 --- a/lib/librte_net/Makefile +++ b/lib/librte_net/Makefile @@ -20,6 +20,6 @@ SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include += rte_sctp.h rte_icmp.h rte_arp.h SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include += rte_ether.h rte_gre.h rte_net.h SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include += rte_net_crc.h rte_mpls.h rte_higig.h SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include += rte_gtp.h rte_vxlan.h -SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include += rte_ecpri.h +SYMLINK-$(CONFIG_RTE_LIBRTE_NET)-include += rte_ecpri.h rte_geneve.h include $(RTE_SDK)/mk/rte.lib.mk diff --git a/lib/librte_net/meson.build b/lib/librte_net/meson.build index 24ed825..52d3a97 100644 --- a/lib/librte_net/meson.build +++ b/lib/librte_net/meson.build @@ -16,7 +16,8 @@ headers = files('rte_ip.h', 'rte_net_crc.h', 'rte_mpls.h', 'rte_higig.h', - 'rte_ecpri.h') + 'rte_ecpri.h', + 'rte_geneve.h') sources = files('rte_arp.c', 'rte_ether.c', 'rte_net.c', 'rte_net_crc.c') deps += ['mbuf'] diff --git a/lib/librte_net/rte_geneve.h b/lib/librte_net/rte_geneve.h new file mode 100644 index 0000000..a1b69c7 --- /dev/null +++ b/lib/librte_net/rte_geneve.h @@ -0,0 +1,72 @@ +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright 2020 Mellanox Technologies, Ltd + */ + +#ifndef _RTE_GENEVE_H_ +#define _RTE_GENEVE_H_ + +/** + * @file + * + * GENEVE-related definitions + */ + +#include + +#include + + +#ifdef __cplusplus +extern "C" { +#endif + +/** GENEVE default port. */ +#define RTE_GENEVE_DEFAULT_PORT 6081 + +/** + * GENEVE protocol header. (draft-ietf-nvo3-geneve-09) + * Contains: + * 2-bits version (must be 0). + * 6-bits option length in four byte multiples, not including the eight + * bytes of the fixed tunnel header. + * 1-bit control packet. + * 1-bit critical options in packet. + * 6-bits reserved + * 16-bits Protocol Type. The protol data unit after the Geneve header + * following the EtherType convention. Ethernet itself is represented by + * the value 0x6558. + * 24-bits Virtual Network Identifier (VNI). Virtual network unique identified. + * 8-bits reserved bits (must be 0 on transmission and ignored on reciept). + * More-bits (optinal) variable length options. + */ +__extension__ +struct rte_geneve_hdr { +#if RTE_BYTE_ORDER == RTE_BIG_ENDIAN + uint8_t ver:2; /**< Version (2). */ + uint8_t opt_len:6; /**< Options length (6). */ + uint8_t oam:1; /**< Control packet (1). */ + uint8_t critical:1; /**< Critical packet (1). */ + uint8_t rsvd1:6; /**< Reserved (6). */ +#else + uint8_t opt_len:6; /**< Options length (6). */ + uint8_t ver:2; /**< Version (2). */ + uint8_t rsvd1:6; /**< Reserved (6). */ + uint8_t critical:1; /**< Critical packet (1). */ + uint8_t oam:1; /**< Control packet (1). */ +#endif + rte_be16_t proto; /**< Protocol type (16). */ + uint8_t vni[3]; /**< Virtual network identifier (24). */ + uint8_t rsvd2; /**< Reserved (8). */ + char opts[0]; /**