From patchwork Wed Feb 1 13:14:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Holmes X-Patchwork-Id: 93027 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp2411445qgi; Wed, 1 Feb 2017 05:19:15 -0800 (PST) X-Received: by 10.200.35.250 with SMTP id r55mr2541108qtr.162.1485955154973; Wed, 01 Feb 2017 05:19:14 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id d77si14424241qkj.21.2017.02.01.05.19.14; Wed, 01 Feb 2017 05:19:14 -0800 (PST) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) client-ip=54.225.227.206; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.225.227.206 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id A17F262D29; Wed, 1 Feb 2017 13:19:14 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 7A84562DBD; Wed, 1 Feb 2017 13:14:50 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id D8DB062D00; Wed, 1 Feb 2017 13:14:23 +0000 (UTC) Received: from mail-qt0-f170.google.com (mail-qt0-f170.google.com [209.85.216.170]) by lists.linaro.org (Postfix) with ESMTPS id D571460CE5 for ; Wed, 1 Feb 2017 13:14:18 +0000 (UTC) Received: by mail-qt0-f170.google.com with SMTP id v23so263214604qtb.0 for ; Wed, 01 Feb 2017 05:14:18 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=JXBpWAFTgabXFU7o3+SwA6Pnq89qh6VxA5iHD2WRL7M=; b=QCu+k/3hYKjyiAV3mIqrQTxpPTpuu8aSHIDA/ncgnYFohi2slXAb5ESjGUuETbTxx8 gJX0c5RCg/3jospSI2R40B+Fp5B91xEqdX8Rli13Qo7Fn9ElhwipRJhQl1FOU6eJAjKN E8cV+wCMz3scf7k62aIAa5kY8GSVBzo7p07WP821HUjNJRUXEs8Y+hXvUH6UukpHUvlW 8uB+4Ieg1BX7HqL0YH6Foe1fqXIy5xW2XgeVWqCtxX1E7pwA3woHt+qcS2AG+zK5sN4C 7+aLtE/vN3yAwV/svPMITR5nq5DmqDRUSdKQZvRXqU/uO0+C2TAozMlTeTy0KiePc+09 mNAQ== X-Gm-Message-State: AIkVDXIHG2bCKrW3jn5uckggAV1+/hwX4wKmtapb/uhlUtY9naMa61tMvmSo2kgKvlvcAc7+eQk= X-Received: by 10.200.38.196 with SMTP id 4mr2488483qtp.96.1485954857972; Wed, 01 Feb 2017 05:14:17 -0800 (PST) Received: from localhost (c-98-221-136-245.hsd1.nj.comcast.net. [98.221.136.245]) by smtp.gmail.com with ESMTPSA id f35sm18462998qtb.49.2017.02.01.05.14.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 01 Feb 2017 05:14:17 -0800 (PST) From: Mike Holmes To: lng-odp@lists.linaro.org Date: Wed, 1 Feb 2017 08:14:07 -0500 Message-Id: <20170201131409.26631-4-mike.holmes@linaro.org> X-Mailer: git-send-email 2.9.3 In-Reply-To: <20170201131409.26631-1-mike.holmes@linaro.org> References: <20170201131409.26631-1-mike.holmes@linaro.org> Subject: [lng-odp] [PATCH 3/5] helper: use ABI mode for ip X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" Signed-off-by: Mike Holmes --- helper/Makefile.am | 1 + helper/include/odp/helper/ip.h | 48 +++++-------------------- helper/include/odp/helper/ip_inlines.h | 65 ++++++++++++++++++++++++++++++++++ helper/ip.c | 4 +++ 4 files changed, 79 insertions(+), 39 deletions(-) create mode 100644 helper/include/odp/helper/ip_inlines.h -- 2.9.3 diff --git a/helper/Makefile.am b/helper/Makefile.am index 69531d6..140f2f4 100644 --- a/helper/Makefile.am +++ b/helper/Makefile.am @@ -19,6 +19,7 @@ helperinclude_HEADERS = \ $(srcdir)/include/odp/helper/eth.h\ $(srcdir)/include/odp/helper/icmp.h\ $(srcdir)/include/odp/helper/ip.h\ + $(srcdir)/include/odp/helper/ip_inlines.h\ $(srcdir)/include/odp/helper/ip_types.h\ $(srcdir)/include/odp/helper/ipsec.h\ $(srcdir)/include/odp/helper/odph_api.h\ diff --git a/helper/include/odp/helper/ip.h b/helper/include/odp/helper/ip.h index 08af794..0afb184 100644 --- a/helper/include/odp/helper/ip.h +++ b/helper/include/odp/helper/ip.h @@ -17,47 +17,24 @@ extern "C" { #endif -#include #include #include -#include - /** @addtogroup odph_header ODPH HEADER * @{ */ /** + * @fn odph_ipv4_csum_valid(odp_packet_t pkt) * Check if IPv4 checksum is valid * * @param pkt ODP packet * * @return 1 if checksum is valid, otherwise 0 */ -static inline int odph_ipv4_csum_valid(odp_packet_t pkt) -{ - uint32_t offset; - odp_u16be_t res = 0; - uint16_t *w; - int nleft = sizeof(odph_ipv4hdr_t); - odph_ipv4hdr_t ip; - odp_u16be_t chksum; - offset = odp_packet_l3_offset(pkt); - if (offset == ODP_PACKET_OFFSET_INVALID) - return 0; - - odp_packet_copy_to_mem(pkt, offset, sizeof(odph_ipv4hdr_t), &ip); - - w = (uint16_t *)(void *)&ip; - chksum = ip.chksum; - ip.chksum = 0x0; - - res = odph_chksum(w, nleft); - return (res == chksum) ? 1 : 0; -} - -/** + /** + * @fn odph_ipv4_csum_update(odp_packet_t pkt) * Calculate and fill in IPv4 checksum * * @note when using this api to populate data destined for the wire @@ -67,20 +44,13 @@ static inline int odph_ipv4_csum_valid(odp_packet_t pkt) * * @return IPv4 checksum in host cpu order, or 0 on failure */ -static inline odp_u16sum_t odph_ipv4_csum_update(odp_packet_t pkt) -{ - uint16_t *w; - odph_ipv4hdr_t *ip; - int nleft = sizeof(odph_ipv4hdr_t); - ip = (odph_ipv4hdr_t *)odp_packet_l3_ptr(pkt, NULL); - if (ip == NULL) - return 0; - - w = (uint16_t *)(void *)ip; - ip->chksum = odph_chksum(w, nleft); - return ip->chksum; -} +#if ODP_HELPER_ABI_COMPAT == 0 +#include +#else +int odph_ipv4_csum_valid(odp_packet_t pkt); +odp_u16sum_t odph_ipv4_csum_update(odp_packet_t pkt); +#endif /** * Parse IPv4 address from a string diff --git a/helper/include/odp/helper/ip_inlines.h b/helper/include/odp/helper/ip_inlines.h new file mode 100644 index 0000000..b72d18c --- /dev/null +++ b/helper/include/odp/helper/ip_inlines.h @@ -0,0 +1,65 @@ +/* Copyright (c) 2017, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @file + * + * ODP IP inline header + */ + +#ifndef ODPH_IP_INLINES_H_ +#define ODPH_IP_INLINES_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +_HELPER_STATIC int odph_ipv4_csum_valid(odp_packet_t pkt) +{ + uint32_t offset; + odp_u16be_t res = 0; + uint16_t *w; + int nleft = sizeof(odph_ipv4hdr_t); + odph_ipv4hdr_t ip; + odp_u16be_t chksum; + + offset = odp_packet_l3_offset(pkt); + if (offset == ODP_PACKET_OFFSET_INVALID) + return 0; + + odp_packet_copy_to_mem(pkt, offset, sizeof(odph_ipv4hdr_t), &ip); + + w = (uint16_t *)(void *)&ip; + chksum = ip.chksum; + ip.chksum = 0x0; + + res = odph_chksum(w, nleft); + return (res == chksum) ? 1 : 0; +} + +_HELPER_STATIC odp_u16sum_t odph_ipv4_csum_update(odp_packet_t pkt) +{ + uint16_t *w; + odph_ipv4hdr_t *ip; + int nleft = sizeof(odph_ipv4hdr_t); + + ip = (odph_ipv4hdr_t *)odp_packet_l3_ptr(pkt, NULL); + if (ip == NULL) + return 0; + + w = (uint16_t *)(void *)ip; + ip->chksum = odph_chksum(w, nleft); + return ip->chksum; +} + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/helper/ip.c b/helper/ip.c index eb73e5a..77dc42c 100644 --- a/helper/ip.c +++ b/helper/ip.c @@ -9,6 +9,10 @@ #include #include +#if ODP_ABI_COMPAT == 1 +#include +#endif + int odph_ipv4_addr_parse(uint32_t *ip_addr, const char *str) { unsigned byte[ODPH_IPV4ADDR_LEN];