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 18F62A052B; Wed, 29 Jul 2020 10:29:53 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 845371C043; Wed, 29 Jul 2020 10:29:28 +0200 (CEST) Received: from EUR03-AM5-obe.outbound.protection.outlook.com (mail-eopbgr30053.outbound.protection.outlook.com [40.107.3.53]) by dpdk.org (Postfix) with ESMTP id BCCAE1C012 for ; Wed, 29 Jul 2020 10:29:24 +0200 (CEST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hmTzrCtPqky/Rf3GAXDQVOZWag9Q6/aXZ+knI7F7kaurdLP27btxQ8fJd440hfEDhCR8t9L8O28Ma/Ip4k4GtZZXHofmsXg1+YeHKkckZwYfSEy2tE/u362lc+iyGW1/1jGUUjs5Az4YJdxyYp6GzV8PU37ecY9P71aHCwr+9NdyETWrreMgdyYmBMqvuSoWmyTxyTpMffLHmUzr4+W2xMz7rUzV4v9fu1qo3Aibx6fNTLwGq0nERrskIN39kF8f0QyzjtxC0C1mZVHvPknqaxO+oWsq1UX54NJfGYUWgtJuhpni5aU7JKg6e+0lyseh4zxwG0axalkpG1VjBkFEpA== 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=biA0WEWOYCyN0HB8hxjvtoZrD8kPEnn0VHnL/ztRMMo=; b=HnoUebZfZnXPUylZvI+we1/LnHcbvuym2O6CdgSvE5IWFWT3dRMhXq/dnk/PctEVzuuvuAbfV8vCi9u8ZujcBMzWbiiUpzzTGsnxX1Tr6imMwJtvdPnXnSKy3TzLWgk152k26vUdVda08IWd2Bp/W7w2xOg5/WishFtIyMRsk/cVlXeKEAxzc5YBW4o5zeQ5mEiOR2Vgc2M2iiHNwE4IeQivR2lLsSNOrZ21ZQFumbhIMB6hEEC+IZModvA4RoHqzIrqIlTOSa0aJo1Qp3oPKOvcO33U5qXnddmXCoqEJmsr9Pw7pRSB0BouzWdR+jET0m07HnNwEj9xKzhlx+x9og== 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=biA0WEWOYCyN0HB8hxjvtoZrD8kPEnn0VHnL/ztRMMo=; b=kVXtVUU0EoBecKu402rhpDIyNKRCvizj1zE87tJVIsYBIXmylIbwmtvQO0NuYRBJ71AgMl4HbKU5OmIH5uL/vZIXyQykOHEN3UmOglm4YIx5bfprUNonSpzTwxyA/1Bp0f7SDTZUN6kVDBIkKbta08JcjJLnO5dMdK7dvunX2zA= 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:24 +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:23 +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:05 +0000 Message-Id: <20200729082905.19499-4-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:23 +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: 6d0bd19c-c0c5-4eb4-fc4f-08d833997f9a 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:260; X-MS-Exchange-SenderADCheck: 1 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: outxKYndi03QxJV4ZMfNrR59pUXLhgBIaKLMxEWAdNpiLG8EOfs2wDnGiNfqbDRoHzEv7HSr3ALeC0OK+JONSAUrgkF/QLizqszffWQZbpQ9z3+rrbWKPrfdGN+wnwIfqEXOkQ6mq5d7e3adrEMBUkUJi5Oamxl5og+mHy8+ci0wbh9IQ5h7ni45jd50F5Z9qoVohtli53w9g29c8y77frRDVTZF9gtzeDhJ9QPgmVf+2J+Cg08RsmIfpEEJtgMVqihOAui3WvqhrLXqeX71MD70kcaYjmUp86oZYhcxMPHafXf+kL/HiteAYJq6H8bQ8DExN1opvZvEQgK/f2J76g== 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: t4Z7/iABGMu8u5F6nxJoc21oyLHi/+LsTxYkOKkikocuO9w+s2V7eHfqs7ggjWeeTvbmX4qm0Av/6gwBmRhbSQUdFgn8lf/ObLYC9YXjimEdh/YhSHH3lfQSmTbuHg8I34JlAnS6dUYiR69UGD6QEmoJPBxLTPloT8CNUIaKWKwuOu1K0c9cFmIIAKfX36VIJ2iiZdn2fYB/+AMiasRR8Rx8tgEKRyLWxiVj96SYtnzxt1tFCv0mWCs8WRJaW8xoDzYB1HXrR94jqdQRL4i7N0sfI8veS1HpVaAQo2n5nHdOHduZs+aRqn8E+IKr8ByP/BnhRhXNrr/y223gjUiX4MuqiSGtZ0Jw+p4reoobjEIGQicNzXvutsLrdxlByEv4kPoiuB52rtYglWJT70v5kLKzp8ybrbM0JGo64OhwLzyIHjVmV1ktM1qOOhnf4SdTr0giXhj7kyvke3CK5f6Lp1alr/vAhYeQnD8kZxX4NehTZQgRgzr4/Oe6UjsaBbxdtMmtqSWjqk0TCPC+rDNSqMvn0QyFyLg8rdEOQsCpWQwzxc3BXL56TM9T22Y+OWCorouy5hb2NXgxHCif2/KaEI0WErYxy8TBhOwhe7xGGQxRNdNugeYZ7PTabMYzixtwhixY3Qot40jOIsYoTb/aTQ== X-OriginatorOrg: Mellanox.com X-MS-Exchange-CrossTenant-Network-Message-Id: 6d0bd19c-c0c5-4eb4-fc4f-08d833997f9a 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:23.8790 (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: 0QhthoFaVQVNOPRCUE/VMwy216uotSLv8yUuGTy9gmCYyyYdwhACG1EMzUadfxYQhHK5keFZJhbeqdGBABmfNw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM4PR05MB3204 Subject: [dpdk-dev] [PATCH v1 3/3] app/testpmd: reduce tunnel parsing code duplication 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" This is a cleanup commit. It assembles all tunnel outer updates into one function call to avoid code duplications. It defines RTE_VXLAN_GPE_DEFAULT_PORT (4790) in accordance with all other tunnel protocol definitions. Signed-off-by: Ophir Munk --- app/test-pmd/csumonly.c | 72 +++++++++++++--------------------------------- lib/librte_net/rte_vxlan.h | 1 + 2 files changed, 21 insertions(+), 52 deletions(-) diff --git a/app/test-pmd/csumonly.c b/app/test-pmd/csumonly.c index 5f29868..3a0e46e 100644 --- a/app/test-pmd/csumonly.c +++ b/app/test-pmd/csumonly.c @@ -63,7 +63,7 @@ #define _htons(x) (x) #endif -uint16_t vxlan_gpe_udp_port = 4790; +uint16_t vxlan_gpe_udp_port = RTE_VXLAN_GPE_DEFAULT_PORT; uint16_t geneve_udp_port = RTE_GENEVE_DEFAULT_PORT; /* structure that caches offload info for the current packet */ @@ -181,6 +181,17 @@ parse_ethernet(struct rte_ether_hdr *eth_hdr, struct testpmd_offload_info *info) } } +/* 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 GTP protocol header. * No optional fields and next extension header type. @@ -201,11 +212,7 @@ parse_gtp(struct rte_udp_hdr *udp_hdr, udp_hdr->dst_port != _htons(RTE_GTPU_UDP_PORT)) return; - 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; + update_tunnel_outer(info); info->l2_len = 0; gtp_hdr = (struct rte_gtp_hdr *)((char *)udp_hdr + @@ -257,11 +264,7 @@ parse_vxlan(struct rte_udp_hdr *udp_hdr, RTE_ETH_IS_TUNNEL_PKT(pkt_type) == 0) return; - 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; + update_tunnel_outer(info); eth_hdr = (struct rte_ether_hdr *)((char *)udp_hdr + sizeof(struct rte_udp_hdr) + @@ -291,11 +294,7 @@ parse_vxlan_gpe(struct rte_udp_hdr *udp_hdr, if (!vxlan_gpe_hdr->proto || vxlan_gpe_hdr->proto == RTE_VXLAN_GPE_TYPE_IPV4) { - 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; + update_tunnel_outer(info); ipv4_hdr = (struct rte_ipv4_hdr *)((char *)vxlan_gpe_hdr + vxlan_gpe_len); @@ -305,11 +304,7 @@ parse_vxlan_gpe(struct rte_udp_hdr *udp_hdr, info->l2_len = 0; } else if (vxlan_gpe_hdr->proto == RTE_VXLAN_GPE_TYPE_IPV6) { - 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; + update_tunnel_outer(info); ipv6_hdr = (struct rte_ipv6_hdr *)((char *)vxlan_gpe_hdr + vxlan_gpe_len); @@ -319,11 +314,7 @@ parse_vxlan_gpe(struct rte_udp_hdr *udp_hdr, info->l2_len = 0; } else if (vxlan_gpe_hdr->proto == RTE_VXLAN_GPE_TYPE_ETH) { - 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; + update_tunnel_outer(info); eth_hdr = (struct rte_ether_hdr *)((char *)vxlan_gpe_hdr + vxlan_gpe_len); @@ -335,17 +326,6 @@ 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, @@ -412,11 +392,7 @@ parse_gre(struct simple_gre_hdr *gre_hdr, struct testpmd_offload_info *info) gre_len += GRE_EXT_LEN; if (gre_hdr->proto == _htons(RTE_ETHER_TYPE_IPV4)) { - 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; + update_tunnel_outer(info); ipv4_hdr = (struct rte_ipv4_hdr *)((char *)gre_hdr + gre_len); @@ -425,11 +401,7 @@ parse_gre(struct simple_gre_hdr *gre_hdr, struct testpmd_offload_info *info) info->l2_len = 0; } else if (gre_hdr->proto == _htons(RTE_ETHER_TYPE_IPV6)) { - 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; + update_tunnel_outer(info); ipv6_hdr = (struct rte_ipv6_hdr *)((char *)gre_hdr + gre_len); @@ -438,11 +410,7 @@ parse_gre(struct simple_gre_hdr *gre_hdr, struct testpmd_offload_info *info) info->l2_len = 0; } else if (gre_hdr->proto == _htons(RTE_ETHER_TYPE_TEB)) { - 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; + update_tunnel_outer(info); eth_hdr = (struct rte_ether_hdr *)((char *)gre_hdr + gre_len); diff --git a/lib/librte_net/rte_vxlan.h b/lib/librte_net/rte_vxlan.h index c23c10c..2ad6061 100644 --- a/lib/librte_net/rte_vxlan.h +++ b/lib/librte_net/rte_vxlan.h @@ -22,6 +22,7 @@ extern "C" { /** VXLAN default port. */ #define RTE_VXLAN_DEFAULT_PORT 4789 +#define RTE_VXLAN_GPE_DEFAULT_PORT 4790 /** * VXLAN protocol header. -- 2.8.4