From patchwork Wed Feb 1 13:14:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Holmes X-Patchwork-Id: 93025 Delivered-To: patch@linaro.org Received: by 10.182.3.34 with SMTP id 2csp2313150obz; Wed, 1 Feb 2017 05:16:21 -0800 (PST) X-Received: by 10.55.135.1 with SMTP id j1mr2784112qkd.107.1485954981446; Wed, 01 Feb 2017 05:16:21 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id p102si14396358qkp.108.2017.02.01.05.16.21; Wed, 01 Feb 2017 05:16:21 -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 18F1F607C6; Wed, 1 Feb 2017 13:16:21 +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=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, 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 04BBB62D30; Wed, 1 Feb 2017 13:14:40 +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 A1E4162D18; Wed, 1 Feb 2017 13:14:20 +0000 (UTC) Received: from mail-qt0-f169.google.com (mail-qt0-f169.google.com [209.85.216.169]) by lists.linaro.org (Postfix) with ESMTPS id 3723762CDE for ; Wed, 1 Feb 2017 13:14:15 +0000 (UTC) Received: by mail-qt0-f169.google.com with SMTP id x49so262214043qtc.2 for ; Wed, 01 Feb 2017 05:14:15 -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=fhrSz/f6xo7TPgX5aPE28Fxy91blYIylNw1khuLU258=; b=BKSv4AbncbVuNZ4mAwBTeOFcuBgHgCBRcZHb9cLWdI96ztRMYtECxQ+SSw8pmXFC7x ffSiQqqlTLW+OnreN1bQZhdxaas35dWWDC/MH8cl/BfIn8cSWHw7RVbWuJP2YtiqVm38 dqn+8+cJOF7s+BZ9NTUsQr8eldYR2iMhvTHA5eYK0B3E48FUORD7zjKiErtm9pBIRPNz JkK77LsjQXxwYK31eIQynRew3cPvcR0TpDkM+TDnqC5WHalTJfwyVpqpU09Lvknck/tK qjo/O9gG9BWN2CpLRc2rF2zysGXM0vx/NUorryhilTH6ubE5u8X0htDj9KkfuZhb+uyh gUeQ== X-Gm-Message-State: AIkVDXLjSGpNqMyQ1SC6wCrn8epv74tI928jRwUShIbXpqxrtpCk1XEqExTwmdJtn3sY1Fo98xs= X-Received: by 10.200.32.146 with SMTP id 18mr2509296qtd.149.1485954854534; Wed, 01 Feb 2017 05:14:14 -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 k18sm18498682qtc.12.2017.02.01.05.14.13 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 01 Feb 2017 05:14:13 -0800 (PST) From: Mike Holmes To: lng-odp@lists.linaro.org Date: Wed, 1 Feb 2017 08:14:05 -0500 Message-Id: <20170201131409.26631-2-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 1/5] helper: split out types 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 | 5 +- helper/include/odp/helper/chksum.h | 13 +-- helper/include/odp/helper/chksum_types.h | 45 +++++++++ helper/include/odp/helper/ip.h | 136 +------------------------ helper/include/odp/helper/ip_types.h | 168 +++++++++++++++++++++++++++++++ helper/include/odp/helper/udp.h | 17 +--- helper/include/odp/helper/udp_types.h | 50 +++++++++ 7 files changed, 270 insertions(+), 164 deletions(-) create mode 100644 helper/include/odp/helper/chksum_types.h create mode 100644 helper/include/odp/helper/ip_types.h create mode 100644 helper/include/odp/helper/udp_types.h -- 2.9.3 diff --git a/helper/Makefile.am b/helper/Makefile.am index d484679..b77a928 100644 --- a/helper/Makefile.am +++ b/helper/Makefile.am @@ -15,9 +15,11 @@ AM_LDFLAGS += -version-number '$(ODPHELPER_LIBSO_VERSION)' helperincludedir = $(includedir)/odp/helper/ helperinclude_HEADERS = \ $(srcdir)/include/odp/helper/chksum.h\ + $(srcdir)/include/odp/helper/chksum_types.h\ $(srcdir)/include/odp/helper/eth.h\ $(srcdir)/include/odp/helper/icmp.h\ $(srcdir)/include/odp/helper/ip.h\ + $(srcdir)/include/odp/helper/ip_types.h\ $(srcdir)/include/odp/helper/ipsec.h\ $(srcdir)/include/odp/helper/odph_api.h\ $(srcdir)/include/odp/helper/odph_cuckootable.h\ @@ -28,7 +30,8 @@ helperinclude_HEADERS = \ $(srcdir)/include/odp/helper/tcp.h\ $(srcdir)/include/odp/helper/table.h\ $(srcdir)/include/odp/helper/threads.h \ - $(srcdir)/include/odp/helper/udp.h + $(srcdir)/include/odp/helper/udp.h \ + $(srcdir)/include/odp/helper/udp_types.h if helper_extn helperinclude_HEADERS += \ diff --git a/helper/include/odp/helper/chksum.h b/helper/include/odp/helper/chksum.h index 520e927..94c9305 100644 --- a/helper/include/odp/helper/chksum.h +++ b/helper/include/odp/helper/chksum.h @@ -17,24 +17,13 @@ extern "C" { #endif #include +#include /** @addtogroup odph_chksum ODPH CHECK SUM * @{ */ /** - * Chksum Operation Code - * - * This enumeration type is used to tell odph_udp_tcp_chksum what to do once - * it has calculated the TCP/UDP check sum. - */ -typedef enum { - ODPH_CHKSUM_GENERATE, /**< Set TCP/UDP header chksum field */ - ODPH_CHKSUM_VERIFY, /**< See if TCP/UDP header chksum is correct */ - ODPH_CHKSUM_RETURN /**< Don't generate or verify chksum */ -} odph_chksum_op_t; - -/** * Checksum * * @param buffer calculate chksum for buffer diff --git a/helper/include/odp/helper/chksum_types.h b/helper/include/odp/helper/chksum_types.h new file mode 100644 index 0000000..b01d9cc --- /dev/null +++ b/helper/include/odp/helper/chksum_types.h @@ -0,0 +1,45 @@ +/* Copyright (c) 2017, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @file + * + * ODP checksum helper + */ +#ifndef ODPH_CHKSUM_TYPES_H_ +#define ODPH_CHKSUM_TYPES_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/** @addtogroup odph_chksum ODPH CHECK SUM + * @{ + */ + +/** + * Chksum Operation Code + * + * This enumeration type is used to tell odph_udp_tcp_chksum what to do once + * it has calculated the TCP/UDP check sum. + */ +typedef enum { + ODPH_CHKSUM_GENERATE, /**< Set TCP/UDP header chksum field */ + ODPH_CHKSUM_VERIFY, /**< See if TCP/UDP header chksum is correct */ + ODPH_CHKSUM_RETURN /**< Don't generate or verify chksum */ +} odph_chksum_op_t; + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/helper/include/odp/helper/ip.h b/helper/include/odp/helper/ip.h index ba6e675..08af794 100644 --- a/helper/include/odp/helper/ip.h +++ b/helper/include/odp/helper/ip.h @@ -18,6 +18,7 @@ extern "C" { #endif #include +#include #include #include @@ -26,72 +27,6 @@ extern "C" { * @{ */ -#define ODPH_IPV4 4 /**< IP version 4 */ -#define ODPH_IPV4HDR_LEN 20 /**< Min length of IP header (no options) */ -#define ODPH_IPV4HDR_IHL_MIN 5 /**< Minimum IHL value*/ -#define ODPH_IPV4ADDR_LEN 4 /**< IPv4 address length in bytes */ - -/** The one byte IPv4 tos or IPv6 tc field is composed of the following two - * subfields - a six bit Differentiated Service Code Point (DSCP) and a two - * bit Explicit Congestion Notification (ECN) subfield. The following - * constants can be used to extract or modify these fields. Despite the - * name prefix being ODPH_IP_TOS_* these constants apply equally well for - * the IPv6 Traffic Class (tc) field. - */ -#define ODPH_IP_TOS_MAX_DSCP 63 /**< 6-bit DSCP field has max value 63 */ -#define ODPH_IP_TOS_DSCP_MASK 0xFC /**< DSCP field is in bits <7:2> */ -#define ODPH_IP_TOS_DSCP_SHIFT 2 /**< DSCP field is shifted letf by 2 */ -#define ODPH_IP_TOS_MAX_ECN 3 /**< 2-bit ECN field has max value 3 */ -#define ODPH_IP_TOS_ECN_MASK 0x03 /**< ECN field is in bits <1:0> */ -#define ODPH_IP_TOS_ECN_SHIFT 0 /**< ECN field is not shifted. */ - -/** The following constants give names to the four possible ECN values, - * as described in RFC 3168. - */ -#define ODPH_IP_ECN_NOT_ECT 0 /**< 0 indicates not participating in ECN */ -#define ODPH_IP_ECN_ECT1 1 /**< Indicates no congestion seen yet */ -#define ODPH_IP_ECN_ECT0 2 /**< Indicates no congestion seen yet */ -#define ODPH_IP_ECN_CE 3 /**< Used to signal Congestion Experienced */ - -/** @internal Returns IPv4 version */ -#define ODPH_IPV4HDR_VER(ver_ihl) (((ver_ihl) & 0xf0) >> 4) - -/** @internal Returns IPv4 header length */ -#define ODPH_IPV4HDR_IHL(ver_ihl) ((ver_ihl) & 0x0f) - -/** @internal Returns IPv4 DSCP */ -#define ODPH_IPV4HDR_DSCP(tos) (((tos) & 0xfc) >> 2) - -/** @internal Returns IPv4 Don't fragment */ -#define ODPH_IPV4HDR_FLAGS_DONT_FRAG(frag_offset) ((frag_offset) & 0x4000) - -/** @internal Returns IPv4 more fragments */ -#define ODPH_IPV4HDR_FLAGS_MORE_FRAGS(frag_offset) ((frag_offset) & 0x2000) - -/** @internal Returns IPv4 fragment offset */ -#define ODPH_IPV4HDR_FRAG_OFFSET(frag_offset) ((frag_offset) & 0x1fff) - -/** @internal Returns true if IPv4 packet is a fragment */ -#define ODPH_IPV4HDR_IS_FRAGMENT(frag_offset) ((frag_offset) & 0x3fff) - -/** IPv4 header */ -typedef struct ODP_PACKED { - uint8_t ver_ihl; /**< Version / Header length */ - uint8_t tos; /**< Type of service */ - odp_u16be_t tot_len; /**< Total length */ - odp_u16be_t id; /**< ID */ - odp_u16be_t frag_offset;/**< Fragmentation offset */ - uint8_t ttl; /**< Time to live */ - uint8_t proto; /**< Protocol */ - odp_u16sum_t chksum; /**< Checksum */ - odp_u32be_t src_addr; /**< Source address */ - odp_u32be_t dst_addr; /**< Destination address */ -} odph_ipv4hdr_t; - -/** @internal Compile time assert */ -ODP_STATIC_ASSERT(sizeof(odph_ipv4hdr_t) == ODPH_IPV4HDR_LEN, - "ODPH_IPV4HDR_T__SIZE_ERROR"); - /** * Check if IPv4 checksum is valid * @@ -147,75 +82,6 @@ static inline odp_u16sum_t odph_ipv4_csum_update(odp_packet_t pkt) return ip->chksum; } -/** IPv6 version */ -#define ODPH_IPV6 6 - -/** IPv6 header length */ -#define ODPH_IPV6HDR_LEN 40 - -/** IPv6 address length in bytes */ -#define ODPH_IPV6ADDR_LEN 16 - -/** The following constants can be used to access the three subfields - * of the 4 byte ver_tc_flow field - namely the four bit Version subfield, - * the eight bit Traffic Class subfield (TC) and the twenty bit Flow Label - * subfield. Note that the IPv6 TC field is analogous to the IPv4 TOS - * field and is composed of the DSCP and ECN subfields. Use the ODPH_IP_TOS_* - * constants above to access these subfields. - */ -#define ODPH_IPV6HDR_VERSION_MASK 0xF0000000 /**< Version field bit mask */ -#define ODPH_IPV6HDR_VERSION_SHIFT 28 /**< Version field shift */ -#define ODPH_IPV6HDR_TC_MASK 0x0FF00000 /**< TC field bit mask */ -#define ODPH_IPV6HDR_TC_SHIFT 20 /**< TC field shift */ -#define ODPH_IPV6HDR_FLOW_LABEL_MASK 0x000FFFFF /**< Flow Label bit mask */ -#define ODPH_IPV6HDR_FLOW_LABEL_SHIFT 0 /**< Flow Label shift */ - -/** @internal Returns IPv6 DSCP */ -#define ODPH_IPV6HDR_DSCP(ver_tc_flow) \ - (uint8_t)((((ver_tc_flow) & 0x0fc00000) >> 22) & 0xff) - -/** - * IPv6 header - */ -typedef struct ODP_PACKED { - odp_u32be_t ver_tc_flow; /**< Version / Traffic class / Flow label */ - odp_u16be_t payload_len; /**< Payload length */ - uint8_t next_hdr; /**< Next header */ - uint8_t hop_limit; /**< Hop limit */ - uint8_t src_addr[16]; /**< Source address */ - uint8_t dst_addr[16]; /**< Destination address */ -} odph_ipv6hdr_t; - -/** @internal Compile time assert */ -ODP_STATIC_ASSERT(sizeof(odph_ipv6hdr_t) == ODPH_IPV6HDR_LEN, - "ODPH_IPV6HDR_T__SIZE_ERROR"); - -/** - * IPv6 Header extensions - */ -typedef struct ODP_PACKED { - uint8_t next_hdr; /**< Protocol of next header */ - uint8_t ext_len; /**< Length of this extension in 8 byte units, - not counting first 8 bytes, so 0 = 8 bytes - 1 = 16 bytes, etc. */ - uint8_t filler[6]; /**< Fill out first 8 byte segment */ -} odph_ipv6hdr_ext_t; - -/** @name - * IP protocol values (IPv4:'proto' or IPv6:'next_hdr') - * @{*/ -#define ODPH_IPPROTO_HOPOPTS 0x00 /**< IPv6 hop-by-hop options */ -#define ODPH_IPPROTO_ICMP 0x01 /**< Internet Control Message Protocol (1) */ -#define ODPH_IPPROTO_TCP 0x06 /**< Transmission Control Protocol (6) */ -#define ODPH_IPPROTO_UDP 0x11 /**< User Datagram Protocol (17) */ -#define ODPH_IPPROTO_ROUTE 0x2B /**< IPv6 Routing header (43) */ -#define ODPH_IPPROTO_FRAG 0x2C /**< IPv6 Fragment (44) */ -#define ODPH_IPPROTO_AH 0x33 /**< Authentication Header (51) */ -#define ODPH_IPPROTO_ESP 0x32 /**< Encapsulating Security Payload (50) */ -#define ODPH_IPPROTO_INVALID 0xFF /**< Reserved invalid by IANA */ - -/**@}*/ - /** * Parse IPv4 address from a string * diff --git a/helper/include/odp/helper/ip_types.h b/helper/include/odp/helper/ip_types.h new file mode 100644 index 0000000..39c50c0 --- /dev/null +++ b/helper/include/odp/helper/ip_types.h @@ -0,0 +1,168 @@ +/* Copyright (c) 2017, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @file + * + * ODP IP header + */ + +#ifndef ODPH_IP_TYPES_H_ +#define ODPH_IP_TYPES_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/** @addtogroup odph_header ODPH HEADER + * @{ + */ + +#define ODPH_IPV4 4 /**< IP version 4 */ +#define ODPH_IPV4HDR_LEN 20 /**< Min length of IP header (no options) */ +#define ODPH_IPV4HDR_IHL_MIN 5 /**< Minimum IHL value*/ +#define ODPH_IPV4ADDR_LEN 4 /**< IPv4 address length in bytes */ + +/** The one byte IPv4 tos or IPv6 tc field is composed of the following two + * subfields - a six bit Differentiated Service Code Point (DSCP) and a two + * bit Explicit Congestion Notification (ECN) subfield. The following + * constants can be used to extract or modify these fields. Despite the + * name prefix being ODPH_IP_TOS_* these constants apply equally well for + * the IPv6 Traffic Class (tc) field. + */ +#define ODPH_IP_TOS_MAX_DSCP 63 /**< 6-bit DSCP field has max value 63 */ +#define ODPH_IP_TOS_DSCP_MASK 0xFC /**< DSCP field is in bits <7:2> */ +#define ODPH_IP_TOS_DSCP_SHIFT 2 /**< DSCP field is shifted letf by 2 */ +#define ODPH_IP_TOS_MAX_ECN 3 /**< 2-bit ECN field has max value 3 */ +#define ODPH_IP_TOS_ECN_MASK 0x03 /**< ECN field is in bits <1:0> */ +#define ODPH_IP_TOS_ECN_SHIFT 0 /**< ECN field is not shifted. */ + +/** The following constants give names to the four possible ECN values, + * as described in RFC 3168. + */ +#define ODPH_IP_ECN_NOT_ECT 0 /**< 0 indicates not participating in ECN */ +#define ODPH_IP_ECN_ECT1 1 /**< Indicates no congestion seen yet */ +#define ODPH_IP_ECN_ECT0 2 /**< Indicates no congestion seen yet */ +#define ODPH_IP_ECN_CE 3 /**< Used to signal Congestion Experienced */ + +/** @internal Returns IPv4 version */ +#define ODPH_IPV4HDR_VER(ver_ihl) (((ver_ihl) & 0xf0) >> 4) + +/** @internal Returns IPv4 header length */ +#define ODPH_IPV4HDR_IHL(ver_ihl) ((ver_ihl) & 0x0f) + +/** @internal Returns IPv4 DSCP */ +#define ODPH_IPV4HDR_DSCP(tos) (((tos) & 0xfc) >> 2) + +/** @internal Returns IPv4 Don't fragment */ +#define ODPH_IPV4HDR_FLAGS_DONT_FRAG(frag_offset) ((frag_offset) & 0x4000) + +/** @internal Returns IPv4 more fragments */ +#define ODPH_IPV4HDR_FLAGS_MORE_FRAGS(frag_offset) ((frag_offset) & 0x2000) + +/** @internal Returns IPv4 fragment offset */ +#define ODPH_IPV4HDR_FRAG_OFFSET(frag_offset) ((frag_offset) & 0x1fff) + +/** @internal Returns true if IPv4 packet is a fragment */ +#define ODPH_IPV4HDR_IS_FRAGMENT(frag_offset) ((frag_offset) & 0x3fff) + +/** IPv4 header */ +typedef struct ODP_PACKED { + uint8_t ver_ihl; /**< Version / Header length */ + uint8_t tos; /**< Type of service */ + odp_u16be_t tot_len; /**< Total length */ + odp_u16be_t id; /**< ID */ + odp_u16be_t frag_offset;/**< Fragmentation offset */ + uint8_t ttl; /**< Time to live */ + uint8_t proto; /**< Protocol */ + odp_u16sum_t chksum; /**< Checksum */ + odp_u32be_t src_addr; /**< Source address */ + odp_u32be_t dst_addr; /**< Destination address */ +} odph_ipv4hdr_t; + +/** @internal Compile time assert */ +ODP_STATIC_ASSERT(sizeof(odph_ipv4hdr_t) == ODPH_IPV4HDR_LEN, + "ODPH_IPV4HDR_T__SIZE_ERROR"); + +/** IPv6 version */ +#define ODPH_IPV6 6 + +/** IPv6 header length */ +#define ODPH_IPV6HDR_LEN 40 + +/** IPv6 address length in bytes */ +#define ODPH_IPV6ADDR_LEN 16 + +/** The following constants can be used to access the three subfields + * of the 4 byte ver_tc_flow field - namely the four bit Version subfield, + * the eight bit Traffic Class subfield (TC) and the twenty bit Flow Label + * subfield. Note that the IPv6 TC field is analogous to the IPv4 TOS + * field and is composed of the DSCP and ECN subfields. Use the ODPH_IP_TOS_* + * constants above to access these subfields. + */ +#define ODPH_IPV6HDR_VERSION_MASK 0xF0000000 /**< Version field bit mask */ +#define ODPH_IPV6HDR_VERSION_SHIFT 28 /**< Version field shift */ +#define ODPH_IPV6HDR_TC_MASK 0x0FF00000 /**< TC field bit mask */ +#define ODPH_IPV6HDR_TC_SHIFT 20 /**< TC field shift */ +#define ODPH_IPV6HDR_FLOW_LABEL_MASK 0x000FFFFF /**< Flow Label bit mask */ +#define ODPH_IPV6HDR_FLOW_LABEL_SHIFT 0 /**< Flow Label shift */ + +/** @internal Returns IPv6 DSCP */ +#define ODPH_IPV6HDR_DSCP(ver_tc_flow) \ + (uint8_t)((((ver_tc_flow) & 0x0fc00000) >> 22) & 0xff) + +/** + * IPv6 header + */ +typedef struct ODP_PACKED { + odp_u32be_t ver_tc_flow; /**< Version / Traffic class / Flow label */ + odp_u16be_t payload_len; /**< Payload length */ + uint8_t next_hdr; /**< Next header */ + uint8_t hop_limit; /**< Hop limit */ + uint8_t src_addr[16]; /**< Source address */ + uint8_t dst_addr[16]; /**< Destination address */ +} odph_ipv6hdr_t; + +/** @internal Compile time assert */ +ODP_STATIC_ASSERT(sizeof(odph_ipv6hdr_t) == ODPH_IPV6HDR_LEN, + "ODPH_IPV6HDR_T__SIZE_ERROR"); + +/** + * IPv6 Header extensions + */ +typedef struct ODP_PACKED { + uint8_t next_hdr; /**< Protocol of next header */ + uint8_t ext_len; /**< Length of this extension in 8 byte units, + not counting first 8 bytes, so 0 = 8 bytes + 1 = 16 bytes, etc. */ + uint8_t filler[6]; /**< Fill out first 8 byte segment */ +} odph_ipv6hdr_ext_t; + +/** @name + * IP protocol values (IPv4:'proto' or IPv6:'next_hdr') + * @{*/ +#define ODPH_IPPROTO_HOPOPTS 0x00 /**< IPv6 hop-by-hop options */ +#define ODPH_IPPROTO_ICMP 0x01 /**< Internet Control Message Protocol (1) */ +#define ODPH_IPPROTO_TCP 0x06 /**< Transmission Control Protocol (6) */ +#define ODPH_IPPROTO_UDP 0x11 /**< User Datagram Protocol (17) */ +#define ODPH_IPPROTO_ROUTE 0x2B /**< IPv6 Routing header (43) */ +#define ODPH_IPPROTO_FRAG 0x2C /**< IPv6 Fragment (44) */ +#define ODPH_IPPROTO_AH 0x33 /**< Authentication Header (51) */ +#define ODPH_IPPROTO_ESP 0x32 /**< Encapsulating Security Payload (50) */ +#define ODPH_IPPROTO_INVALID 0xFF /**< Reserved invalid by IANA */ + +/**@}*/ + +/** + * @} + */ +#ifdef __cplusplus +} +#endif + +#endif diff --git a/helper/include/odp/helper/udp.h b/helper/include/odp/helper/udp.h index 1ba2dff..e1661de 100644 --- a/helper/include/odp/helper/udp.h +++ b/helper/include/odp/helper/udp.h @@ -18,23 +18,12 @@ extern "C" { #endif #include -#include +#include /** @addtogroup odph_header ODPH HEADER * @{ */ -/** UDP header length */ -#define ODPH_UDPHDR_LEN 8 - -/** UDP header */ -typedef struct ODP_PACKED { - odp_u16be_t src_port; /**< Source port */ - odp_u16be_t dst_port; /**< Destination port */ - odp_u16be_t length; /**< UDP datagram length in bytes (header+data) */ - odp_u16be_t chksum; /**< UDP header and data checksum (0 if not used)*/ -} odph_udphdr_t; - /** * UDP checksum * @@ -52,10 +41,6 @@ static inline uint16_t odph_ipv4_udp_chksum(odp_packet_t pkt) return (rc == 0) ? chksum : 0; } -/** @internal Compile time assert */ -ODP_STATIC_ASSERT(sizeof(odph_udphdr_t) == ODPH_UDPHDR_LEN, - "ODPH_UDPHDR_T__SIZE_ERROR"); - /** * @} */ diff --git a/helper/include/odp/helper/udp_types.h b/helper/include/odp/helper/udp_types.h new file mode 100644 index 0000000..aa6703a --- /dev/null +++ b/helper/include/odp/helper/udp_types.h @@ -0,0 +1,50 @@ +/* Copyright (c) 2017, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @file + * + * ODP UDP header + */ + +#ifndef ODPH_UDP_TYPES_H_ +#define ODPH_UDP_TYPES_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +/** @addtogroup odph_header ODPH HEADER + * @{ + */ + +/** UDP header length */ +#define ODPH_UDPHDR_LEN 8 + +/** UDP header */ +typedef struct ODP_PACKED { + odp_u16be_t src_port; /**< Source port */ + odp_u16be_t dst_port; /**< Destination port */ + odp_u16be_t length; /**< UDP datagram length in bytes (header+data) */ + odp_u16be_t chksum; /**< UDP header and data checksum (0 if not used)*/ +} odph_udphdr_t; + +/** @internal Compile time assert */ +ODP_STATIC_ASSERT(sizeof(odph_udphdr_t) == ODPH_UDPHDR_LEN, + "ODPH_UDPHDR_T__SIZE_ERROR"); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif + +#endif From patchwork Wed Feb 1 13:14:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Holmes X-Patchwork-Id: 93024 Delivered-To: patch@linaro.org Received: by 10.182.3.34 with SMTP id 2csp2312762obz; Wed, 1 Feb 2017 05:15:29 -0800 (PST) X-Received: by 10.55.104.136 with SMTP id d130mr2874491qkc.9.1485954929664; Wed, 01 Feb 2017 05:15:29 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id t40si14414885qtb.173.2017.02.01.05.15.29; Wed, 01 Feb 2017 05:15:29 -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 4A4E36071D; Wed, 1 Feb 2017 13:15:29 +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=-1.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_NONE, 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 A9B5E62CDE; Wed, 1 Feb 2017 13:14:29 +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 8973862D18; Wed, 1 Feb 2017 13:14:19 +0000 (UTC) Received: from mail-qt0-f171.google.com (mail-qt0-f171.google.com [209.85.216.171]) by lists.linaro.org (Postfix) with ESMTPS id E3E1E62CE1 for ; Wed, 1 Feb 2017 13:14:16 +0000 (UTC) Received: by mail-qt0-f171.google.com with SMTP id w20so194227637qtb.1 for ; Wed, 01 Feb 2017 05:14:16 -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=l/kZjqj/Hzdpt8Mxx6sBmABttjqOkr9bolAoz0fSsbY=; b=CGylCj6BiBde7uI1mlWuC+BsMUWIpr01f3zN79aNMoL5lK7d5hOXHW4SI2v79Mezer pjwiDySoWZ+1luFnBm45NbB5Xi4Q0S4v7e3uiisuc/P2gDY6UL7frgdyPlCJGPFK5wbj qfvbr4jUIsNpX4wdCiNX+G9GSU9T3qodYx/W+CovYsIuen0ZvNYkccC6cel+sTrsG6Hf U+gz8x92TjgBqtDdc9QZhfnZvVdHVqmZFqKoMyZuYosL1ayIFXKqYUWqDqKqi9wDYIHj 53RWU1BgSK4vSdc9pXSH95mRZ2sM6s7kVeSzuMGQ2c0rquN+VPkK/RkaCMfFgEXIb6ur 9tIw== X-Gm-Message-State: AIkVDXLy7KRRc5Zae/HITQL+X6jCBhVJbgOS1ZHQL+PHtv4EtPsQ8aH5EMeheN5mDTQbYzILYpw= X-Received: by 10.237.43.167 with SMTP id e36mr2747874qtd.245.1485954856255; Wed, 01 Feb 2017 05:14:16 -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 b36sm18558166qte.21.2017.02.01.05.14.15 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 01 Feb 2017 05:14:15 -0800 (PST) From: Mike Holmes To: lng-odp@lists.linaro.org Date: Wed, 1 Feb 2017 08:14:06 -0500 Message-Id: <20170201131409.26631-3-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 2/5] helper: add ABI compile flag 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 --- configure.ac | 6 +++++ helper/Makefile.am | 1 + helper/include/odp/helper/.gitignore | 1 + helper/include/odp/helper/static_inline.h.in | 35 ++++++++++++++++++++++++++++ helper/m4/configure.m4 | 3 ++- 5 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 helper/include/odp/helper/.gitignore create mode 100644 helper/include/odp/helper/static_inline.h.in -- 2.9.3 diff --git a/configure.ac b/configure.ac index daa9b31..71f07f9 100644 --- a/configure.ac +++ b/configure.ac @@ -272,16 +272,22 @@ ODP_CFLAGS="$ODP_CFLAGS -DODP_DEBUG=$ODP_DEBUG" # Enable/disable ABI compatible build ########################################################################## ODP_ABI_COMPAT=1 +ODP_HELPER_ABI_COMPAT=1 abi_compat=yes AC_ARG_ENABLE([abi-compat], [ --disable-abi-compat disables ABI compatible mode, enables inline code in header files], [if test "x$enableval" = "xno"; then ODP_ABI_COMPAT=0 + ODP_HELPER_ABI_COMPAT=0 abi_compat=no #if there is no ABI compatibility the .so numbers are meaningless ODP_LIBSO_VERSION=0:0:0 + ODPHELPER_LIBSO_VERSION=0:0:0 fi]) AC_SUBST(ODP_ABI_COMPAT) +AC_SUBST(ODP_HELPER_ABI_COMPAT) +ODP_CFLAGS="$ODP_CFLAGS -DODP_HELPER_ABI_COMPAT=$ODP_HELPER_ABI_COMPAT" +ODP_CFLAGS="$ODP_CFLAGS -DODP_ABI_COMPAT=$ODP_ABI_COMPAT" ########################################################################## # Default warning setup diff --git a/helper/Makefile.am b/helper/Makefile.am index b77a928..69531d6 100644 --- a/helper/Makefile.am +++ b/helper/Makefile.am @@ -26,6 +26,7 @@ helperinclude_HEADERS = \ $(srcdir)/include/odp/helper/odph_hashtable.h\ $(srcdir)/include/odp/helper/odph_iplookuptable.h\ $(srcdir)/include/odp/helper/odph_lineartable.h\ + $(srcdir)/include/odp/helper/static_inline.h\ $(srcdir)/include/odp/helper/strong_types.h\ $(srcdir)/include/odp/helper/tcp.h\ $(srcdir)/include/odp/helper/table.h\ diff --git a/helper/include/odp/helper/.gitignore b/helper/include/odp/helper/.gitignore new file mode 100644 index 0000000..95db5f4 --- /dev/null +++ b/helper/include/odp/helper/.gitignore @@ -0,0 +1 @@ +static_inline.h diff --git a/helper/include/odp/helper/static_inline.h.in b/helper/include/odp/helper/static_inline.h.in new file mode 100644 index 0000000..a3efcae --- /dev/null +++ b/helper/include/odp/helper/static_inline.h.in @@ -0,0 +1,35 @@ +/* Copyright (c) 2017, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @file + * + * Macro for static inline functions + */ + +#ifndef ODP_HELPER_STATIC_INLINE_H_ +#define ODP_HELPER_STATIC_INLINE_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @internal + * @def _HELPER_STATIC + * Control conditional static inline expansions for ABI compatibility + */ +#if @ODP_HELPER_ABI_COMPAT@ +#define _HELPER_STATIC +#else +#define _HELPER_STATIC static inline +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/helper/m4/configure.m4 b/helper/m4/configure.m4 index 38c95d9..71b1f2d 100644 --- a/helper/m4/configure.m4 +++ b/helper/m4/configure.m4 @@ -20,4 +20,5 @@ AC_ARG_ENABLE([helper-extn], fi]) AC_CONFIG_FILES([helper/Makefile - helper/test/Makefile]) + helper/test/Makefile + helper/include/odp/helper/static_inline.h]) \ No newline at end of file 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]; From patchwork Wed Feb 1 13:14:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Holmes X-Patchwork-Id: 93026 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp2410963qgi; Wed, 1 Feb 2017 05:18:01 -0800 (PST) X-Received: by 10.200.48.172 with SMTP id v41mr2458614qta.54.1485955081801; Wed, 01 Feb 2017 05:18:01 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id c185si14388712qkd.294.2017.02.01.05.18.01; Wed, 01 Feb 2017 05:18:01 -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 76FC162D30; Wed, 1 Feb 2017 13:18:01 +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 3CA2D62D57; Wed, 1 Feb 2017 13:14:44 +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 E908C62D00; Wed, 1 Feb 2017 13:14:21 +0000 (UTC) Received: from mail-qt0-f175.google.com (mail-qt0-f175.google.com [209.85.216.175]) by lists.linaro.org (Postfix) with ESMTPS id 9018862CE1 for ; Wed, 1 Feb 2017 13:14:20 +0000 (UTC) Received: by mail-qt0-f175.google.com with SMTP id k15so264019091qtg.3 for ; Wed, 01 Feb 2017 05:14:20 -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=+BI4aFq+HSrRqkLUv4N5sBgF+PhW0s5BMZNvZ8Wafxo=; b=jcLo2zVhBlxtkSCqGmtL+mwvgPjlISQYmY/zadTmrWYmUIAi1OewAWPdXXG4UN+bY+ kIfI9qxfvdPW1TIrD0W3d4YmMUMziTigaqlxGHVDEe0l5nZQACbNXXT5QJWPu6WJfC1W CfTQSFO+G0IY1qCTDCivNcPphLBUTSA6lHq6tlVtHx1SdziOcjSdnXpA6lSPonrc5R0t Of2VENlBcpwZDCgT0361etap8ZBGUalFN4kOKrf80QdlnTKynimZWOvp55DPl8T9i+6Y EJvhW0UyFPz0waTFA2L4WeYo8D1/bTmXmV9GgWy934Vm38SwCMBmIxBiyOtfnV/ww5mZ SfGg== X-Gm-Message-State: AIkVDXIHZTvls96viXsYglYCVbwntegZcAlt+lAHh9ae4dLWNbZxxwniMhGUUI62qTZhM5r3hy8= X-Received: by 10.237.41.229 with SMTP id o92mr2409350qtd.223.1485954859892; Wed, 01 Feb 2017 05:14:19 -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 b190sm18557590qkg.32.2017.02.01.05.14.18 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 01 Feb 2017 05:14:18 -0800 (PST) From: Mike Holmes To: lng-odp@lists.linaro.org Date: Wed, 1 Feb 2017 08:14:08 -0500 Message-Id: <20170201131409.26631-5-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 4/5] helper: use ABI mode for chksum 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/chksum.c | 4 ++ helper/include/odp/helper/chksum.h | 59 ++++++----------------- helper/include/odp/helper/chksum_inlines.h | 77 ++++++++++++++++++++++++++++++ 4 files changed, 96 insertions(+), 45 deletions(-) create mode 100644 helper/include/odp/helper/chksum_inlines.h -- 2.9.3 diff --git a/helper/Makefile.am b/helper/Makefile.am index 140f2f4..6820532 100644 --- a/helper/Makefile.am +++ b/helper/Makefile.am @@ -15,6 +15,7 @@ AM_LDFLAGS += -version-number '$(ODPHELPER_LIBSO_VERSION)' helperincludedir = $(includedir)/odp/helper/ helperinclude_HEADERS = \ $(srcdir)/include/odp/helper/chksum.h\ + $(srcdir)/include/odp/helper/chksum_inlines.h\ $(srcdir)/include/odp/helper/chksum_types.h\ $(srcdir)/include/odp/helper/eth.h\ $(srcdir)/include/odp/helper/icmp.h\ diff --git a/helper/chksum.c b/helper/chksum.c index f740618..c809bc0 100644 --- a/helper/chksum.c +++ b/helper/chksum.c @@ -12,6 +12,10 @@ #include #include +#if ODP_ABI_COMPAT == 1 +#include +#endif + /* The following union type is used to "view" an ordered set of bytes (either * 2 or 4) as 1 or 2 16-bit quantities - using host endian order. */ typedef union { diff --git a/helper/include/odp/helper/chksum.h b/helper/include/odp/helper/chksum.h index 94c9305..ddca0e1 100644 --- a/helper/include/odp/helper/chksum.h +++ b/helper/include/odp/helper/chksum.h @@ -24,6 +24,7 @@ extern "C" { */ /** + * @fn odph_chksum(void *buffer, int len) * Checksum * * @param buffer calculate chksum for buffer @@ -31,24 +32,6 @@ extern "C" { * * @return checksum value in host cpu order */ -static inline odp_u16sum_t odph_chksum(void *buffer, int len) -{ - uint16_t *buf = (uint16_t *)buffer; - uint32_t sum = 0; - uint16_t result; - - for (sum = 0; len > 1; len -= 2) - sum += *buf++; - - if (len == 1) - sum += *(unsigned char *)buf; - - sum = (sum >> 16) + (sum & 0xFFFF); - sum += (sum >> 16); - result = ~sum; - - return (__odp_force odp_u16sum_t) result; -} /** * General Purpose TCP/UDP checksum function @@ -94,6 +77,7 @@ int odph_udp_tcp_chksum(odp_packet_t odp_pkt, uint16_t *chksum_ptr); /** + * @fn odph_tcp_chksum_set(odp_packet_t odp_pkt) * Generate TCP checksum * * This function supports TCP over either IPv4 or IPV6 - including handling @@ -112,15 +96,9 @@ int odph_udp_tcp_chksum(odp_packet_t odp_pkt, * be over IPv4 or IPv6. * @return 0 upon success and < 0 upon failure. */ -static inline int odph_tcp_chksum_set(odp_packet_t odp_pkt) -{ - if (!odp_packet_has_tcp(odp_pkt)) - return -1; - - return odph_udp_tcp_chksum(odp_pkt, ODPH_CHKSUM_GENERATE, NULL); -} /** + * @fn odph_udp_chksum_set(odp_packet_t odp_pkt) * Generate UDP checksum * * This function supports UDP over either IPv4 or IPV6 - including handling @@ -139,15 +117,9 @@ static inline int odph_tcp_chksum_set(odp_packet_t odp_pkt) * be over IPv4 or IPv6. * @return 0 upon success and < 0 upon failure. */ -static inline int odph_udp_chksum_set(odp_packet_t odp_pkt) -{ - if (!odp_packet_has_udp(odp_pkt)) - return -1; - - return odph_udp_tcp_chksum(odp_pkt, ODPH_CHKSUM_GENERATE, NULL); -} /** + * @fn odph_tcp_chksum_verify(odp_packet_t odp_pkt) * Verify TCP checksum * * This function supports TCP over either IPv4 or IPV6 - including handling @@ -167,15 +139,9 @@ static inline int odph_udp_chksum_set(odp_packet_t odp_pkt) * the incoming chksum field is correct, else returns 2 * when the chksum field is incorrect or 0. */ -static inline int odph_tcp_chksum_verify(odp_packet_t odp_pkt) -{ - if (!odp_packet_has_tcp(odp_pkt)) - return -1; - - return odph_udp_tcp_chksum(odp_pkt, ODPH_CHKSUM_VERIFY, NULL); -} /** + * @fn odph_udp_chksum_verify(odp_packet_t odp_pkt) * Verify UDP checksum * * This function supports UDP over either IPv4 or IPV6 - including handling @@ -197,13 +163,16 @@ static inline int odph_tcp_chksum_verify(odp_packet_t odp_pkt) * if the incoming chksum field is correct, else returns 2 * when the chksum field is incorrect. */ -static inline int odph_udp_chksum_verify(odp_packet_t odp_pkt) -{ - if (!odp_packet_has_udp(odp_pkt)) - return -1; - return odph_udp_tcp_chksum(odp_pkt, ODPH_CHKSUM_VERIFY, NULL); -} +#if ODP_HELPER_ABI_COMPAT == 0 +#include +#else +odp_u16sum_t odph_chksum(void *buffer, int len); +int odph_tcp_chksum_set(odp_packet_t odp_pkt); +int odph_udp_chksum_set(odp_packet_t odp_pkt); +int odph_tcp_chksum_verify(odp_packet_t odp_pkt); +int odph_udp_chksum_verify(odp_packet_t odp_pkt); +#endif /** * @} diff --git a/helper/include/odp/helper/chksum_inlines.h b/helper/include/odp/helper/chksum_inlines.h new file mode 100644 index 0000000..c022061 --- /dev/null +++ b/helper/include/odp/helper/chksum_inlines.h @@ -0,0 +1,77 @@ +/* Copyright (c) 2017, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @file + * + * ODP checksum inlne helper + */ +#ifndef ODPH_CHKSUM_INLINE_H_ +#define ODPH_CHKSUM_INLINE_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +_HELPER_STATIC odp_u16sum_t odph_chksum(void *buffer, int len) +{ + uint16_t *buf = (uint16_t *)buffer; + uint32_t sum = 0; + uint16_t result; + + for (sum = 0; len > 1; len -= 2) + sum += *buf++; + + if (len == 1) + sum += *(unsigned char *)buf; + + sum = (sum >> 16) + (sum & 0xFFFF); + sum += (sum >> 16); + result = ~sum; + + return (__odp_force odp_u16sum_t) result; +} + +_HELPER_STATIC int odph_tcp_chksum_set(odp_packet_t odp_pkt) +{ + if (!odp_packet_has_tcp(odp_pkt)) + return -1; + + return odph_udp_tcp_chksum(odp_pkt, ODPH_CHKSUM_GENERATE, NULL); +} + +_HELPER_STATIC int odph_udp_chksum_set(odp_packet_t odp_pkt) +{ + if (!odp_packet_has_udp(odp_pkt)) + return -1; + + return odph_udp_tcp_chksum(odp_pkt, ODPH_CHKSUM_GENERATE, NULL); +} + +_HELPER_STATIC int odph_tcp_chksum_verify(odp_packet_t odp_pkt) +{ + if (!odp_packet_has_tcp(odp_pkt)) + return -1; + + return odph_udp_tcp_chksum(odp_pkt, ODPH_CHKSUM_VERIFY, NULL); +} + +_HELPER_STATIC int odph_udp_chksum_verify(odp_packet_t odp_pkt) +{ + if (!odp_packet_has_udp(odp_pkt)) + return -1; + + return odph_udp_tcp_chksum(odp_pkt, ODPH_CHKSUM_VERIFY, NULL); +} + +#ifdef __cplusplus +} +#endif + +#endif From patchwork Wed Feb 1 13:14:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mike Holmes X-Patchwork-Id: 93028 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp2411851qgi; Wed, 1 Feb 2017 05:20:12 -0800 (PST) X-Received: by 10.55.24.8 with SMTP id j8mr2932511qkh.181.1485955211972; Wed, 01 Feb 2017 05:20:11 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id q1si14410834qtq.167.2017.02.01.05.20.11; Wed, 01 Feb 2017 05:20:11 -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 9FA77607C6; Wed, 1 Feb 2017 13:20:11 +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 D335662DC2; Wed, 1 Feb 2017 13:14:55 +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 20E4562D1B; Wed, 1 Feb 2017 13:14:27 +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 50F7562CDE for ; Wed, 1 Feb 2017 13:14:22 +0000 (UTC) Received: by mail-qt0-f170.google.com with SMTP id v23so263216253qtb.0 for ; Wed, 01 Feb 2017 05:14:22 -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=GkYXrdoFx7aBQ0ev5hYyYvG3yvYsqEzSTfIZOSL5eoQ=; b=U21SOsJ9UafcOfOHfzpx85q9FcwteDOZQkbr6GiEf1FQfTx54s1RE5OC07eBO4MwU2 TNW9u3Msqa+Tn1+db5yr6Y2cbJpYIYkR5EDOiaLrhoIGydUrdPhphMAy3+vSjYDfZFH9 ns841SCWii3MWa2j4Q7REc53rumvfuZEWTWMmSutonrHYfyVfRP8kztZBxpJBA4A7DQc LV83/HNPeX7bgTprRReVLcd0iXilpuxDyG74u52ZVKFo9DM820dfONKBypkL1mxr4EjN QfhAt+PDbkN3B5/qdxqJq4tQFIXa1ZCnNPdP4ql7ugTK2m8dg8zoWwe2vWPP7JwcTHxd kXyQ== X-Gm-Message-State: AIkVDXL6uwrSmWV+WS4lgIf8rIEEd1Si7BtI3UYKH81PB2rCNcxLa0T6fqnVdgKIYPUO0EDMjfQ= X-Received: by 10.200.39.130 with SMTP id w2mr2454371qtw.280.1485954861627; Wed, 01 Feb 2017 05:14:21 -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 g13sm18569010qtg.8.2017.02.01.05.14.20 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 01 Feb 2017 05:14:20 -0800 (PST) From: Mike Holmes To: lng-odp@lists.linaro.org Date: Wed, 1 Feb 2017 08:14:09 -0500 Message-Id: <20170201131409.26631-6-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 5/5] helper: use ABI mode for udp 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 | 4 +++- helper/include/odp/helper/udp.h | 13 ++++++------ helper/include/odp/helper/udp_inlines.h | 36 +++++++++++++++++++++++++++++++++ helper/udp.c | 14 +++++++++++++ 4 files changed, 59 insertions(+), 8 deletions(-) create mode 100644 helper/include/odp/helper/udp_inlines.h create mode 100644 helper/udp.c -- 2.9.3 diff --git a/helper/Makefile.am b/helper/Makefile.am index 6820532..1bd2cda 100644 --- a/helper/Makefile.am +++ b/helper/Makefile.am @@ -34,6 +34,7 @@ helperinclude_HEADERS = \ $(srcdir)/include/odp/helper/table.h\ $(srcdir)/include/odp/helper/threads.h \ $(srcdir)/include/odp/helper/udp.h \ + $(srcdir)/include/odp/helper/udp_inlines.h \ $(srcdir)/include/odp/helper/udp_types.h if helper_extn @@ -53,7 +54,8 @@ __LIB__libodphelper_@with_platform@_la_SOURCES = \ lineartable.c \ cuckootable.c \ iplookuptable.c \ - threads.c + threads.c \ + udp.c if helper_extn __LIB__libodphelper_@with_platform@_la_SOURCES += \ diff --git a/helper/include/odp/helper/udp.h b/helper/include/odp/helper/udp.h index e1661de..e52dd4f 100644 --- a/helper/include/odp/helper/udp.h +++ b/helper/include/odp/helper/udp.h @@ -25,6 +25,7 @@ extern "C" { */ /** + * @fn odph_ipv4_udp_chksum(odp_packet_t pkt) * UDP checksum * * This function calculates the UDP checksum given an odp packet. @@ -32,14 +33,12 @@ extern "C" { * @param pkt calculate chksum for pkt * @return checksum value in BE endianness */ -static inline uint16_t odph_ipv4_udp_chksum(odp_packet_t pkt) -{ - uint16_t chksum; - int rc; - rc = odph_udp_tcp_chksum(pkt, ODPH_CHKSUM_RETURN, &chksum); - return (rc == 0) ? chksum : 0; -} +#if ODP_HELPER_ABI_COMPAT == 0 +#include +#else +uint16_t odph_ipv4_udp_chksum(odp_packet_t pkt); +#endif /** * @} diff --git a/helper/include/odp/helper/udp_inlines.h b/helper/include/odp/helper/udp_inlines.h new file mode 100644 index 0000000..fa2fc4a --- /dev/null +++ b/helper/include/odp/helper/udp_inlines.h @@ -0,0 +1,36 @@ +/* Copyright (c) 2017, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @file + * + * ODP UDP inline header + */ + +#ifndef ODPH_UDP_INLINES_H_ +#define ODPH_UDP_INLINES_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include +#include + +_HELPER_STATIC uint16_t odph_ipv4_udp_chksum(odp_packet_t pkt) +{ + uint16_t chksum; + int rc; + + rc = odph_udp_tcp_chksum(pkt, ODPH_CHKSUM_RETURN, &chksum); + return (rc == 0) ? chksum : 0; +} + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/helper/udp.c b/helper/udp.c new file mode 100644 index 0000000..0b9a634 --- /dev/null +++ b/helper/udp.c @@ -0,0 +1,14 @@ +/* Copyright (c) 2017, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#include + +#include +#include + +#if ODP_ABI_COMPAT == 1 +#include +#endif