From patchwork Thu Feb 9 11:53:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 93696 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp209211qgi; Thu, 9 Feb 2017 03:58:32 -0800 (PST) X-Received: by 10.36.111.143 with SMTP id x137mr19463718itb.42.1486641512666; Thu, 09 Feb 2017 03:58:32 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id d76si4631624itd.74.2017.02.09.03.58.32; Thu, 09 Feb 2017 03:58:32 -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 2C10F634D0; Thu, 9 Feb 2017 11:58:32 +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 EBF72634D1; Thu, 9 Feb 2017 11:54:35 +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 775D9634C3; Thu, 9 Feb 2017 11:54:07 +0000 (UTC) Received: from mail-ot0-f173.google.com (mail-ot0-f173.google.com [74.125.82.173]) by lists.linaro.org (Postfix) with ESMTPS id 8615962C8E for ; Thu, 9 Feb 2017 11:54:01 +0000 (UTC) Received: by mail-ot0-f173.google.com with SMTP id 32so924050oth.3 for ; Thu, 09 Feb 2017 03:54:01 -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=gGp2QYsm6ydpDn0ck14wlMiKXfGBlVx71jBhVJQJSxM=; b=CjNMCGo6nhF4V4Pme4iNVXVciqSXEDqvXKLkYsFCQo9yoASwUxjzN2VB5gxVfapq1V LakLCudqSvO2OnyYEa82VRuaKCC6b3QkkO0x530qyyHYnTQevR/0c3uNEhR5YJPWZxDq FBkHM5mfFFXT38bYMXgbr6BK5eAK4jW2tnbxsvgTYgtaF/zLU3rSNDCgOD19ub6EI4PV 08AA0jcIwRepYam5jErJGe6Fd+JghimxB/ieuinEdDmOjMwV66HNl6+/fyIQcJUULHwI 3woW4U9LmmV/XWtiILEn47iLtqbHkPjL99kL3UD0H6CunCoWaoSSR8J8Tf7TiptMd8JS uUSg== X-Gm-Message-State: AMke39mHFZj2M2s/C5aD4eeWHnKX1H+V29waZByxhvSPbHm9o2h+/LURZUyQa0Qtm5PLU7heuNo= X-Received: by 10.157.14.25 with SMTP id c25mr1312582otc.56.1486641240806; Thu, 09 Feb 2017 03:54:00 -0800 (PST) Received: from localhost.localdomain (cpe-70-121-83-241.austin.res.rr.com. [70.121.83.241]) by smtp.gmail.com with ESMTPSA id t53sm5767383otd.6.2017.02.09.03.53.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Feb 2017 03:54:00 -0800 (PST) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Thu, 9 Feb 2017 05:53:52 -0600 Message-Id: <20170209115352.16271-6-bill.fischofer@linaro.org> X-Mailer: git-send-email 2.11.0.295.gd7dffce In-Reply-To: <20170209115352.16271-1-bill.fischofer@linaro.org> References: <20170209115352.16271-1-bill.fischofer@linaro.org> Cc: Petri Savolainen Subject: [lng-odp] [API-NEXT PATCHv3 5/5] linux-gen: packet: inline flag functions 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" From: Petri Savolainen Added first inlined packet flag functions. Functions are allways used inlined within the implementation. Applications see inlined versions only when ABI compatibility is disabled. Signed-off-by: Petri Savolainen Signed-off-by: Bill Fischofer --- platform/linux-generic/Makefile.am | 2 + .../linux-generic/include/odp/api/packet_flags.h | 11 +-- .../include/odp/api/plat/packet_flag_inlines.h | 93 ++++++++++++++++++++++ .../include/odp/api/plat/packet_flag_inlines_api.h | 41 ++++++++++ .../include/odp/api/plat/packet_types.h | 52 ++++++++++++ .../linux-generic/include/odp_packet_internal.h | 55 +------------ platform/linux-generic/odp_packet.c | 4 +- platform/linux-generic/odp_packet_flags.c | 41 ++-------- 8 files changed, 204 insertions(+), 95 deletions(-) create mode 100644 platform/linux-generic/include/odp/api/plat/packet_flag_inlines.h create mode 100644 platform/linux-generic/include/odp/api/plat/packet_flag_inlines_api.h -- 2.11.0.295.gd7dffce diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am index a782b28c..78e55518 100644 --- a/platform/linux-generic/Makefile.am +++ b/platform/linux-generic/Makefile.am @@ -82,6 +82,8 @@ odpapiplatinclude_HEADERS = \ $(srcdir)/include/odp/api/plat/event_types.h \ $(srcdir)/include/odp/api/plat/init_types.h \ $(srcdir)/include/odp/api/plat/ipsec_types.h \ + $(srcdir)/include/odp/api/plat/packet_flag_inlines.h \ + $(srcdir)/include/odp/api/plat/packet_flag_inlines_api.h \ $(srcdir)/include/odp/api/plat/packet_inlines.h \ $(srcdir)/include/odp/api/plat/packet_inlines_api.h \ $(srcdir)/include/odp/api/plat/packet_types.h \ diff --git a/platform/linux-generic/include/odp/api/packet_flags.h b/platform/linux-generic/include/odp/api/packet_flags.h index 467f5b1d..1e55af82 100644 --- a/platform/linux-generic/include/odp/api/packet_flags.h +++ b/platform/linux-generic/include/odp/api/packet_flags.h @@ -17,13 +17,10 @@ extern "C" { #endif -/** @ingroup odp_packet - * @{ - */ - -/** - * @} - */ +#include +#if ODP_ABI_COMPAT == 0 +#include +#endif #include diff --git a/platform/linux-generic/include/odp/api/plat/packet_flag_inlines.h b/platform/linux-generic/include/odp/api/plat/packet_flag_inlines.h new file mode 100644 index 00000000..738fced3 --- /dev/null +++ b/platform/linux-generic/include/odp/api/plat/packet_flag_inlines.h @@ -0,0 +1,93 @@ +/* Copyright (c) 2017, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @file + * + * Packet inline functions + */ + +#ifndef _ODP_PLAT_PACKET_FLAG_INLINES_H_ +#define _ODP_PLAT_PACKET_FLAG_INLINES_H_ + +#include +#include + +/** @internal Packet field accessor */ +#define _odp_pkt_get(pkt, cast, field) \ + (*(cast *)(uintptr_t)((uint8_t *)pkt + _odp_packet_inline.field)) + +/** @internal Inline function offsets */ +extern const _odp_packet_inline_offset_t _odp_packet_inline; + +/** @internal Inline function @param pkt @return */ +static inline uint64_t _odp_packet_input_flags(odp_packet_t pkt) +{ + return _odp_pkt_get(pkt, uint64_t, input_flags); +} + +/** @internal Inline function @param pkt @return */ +static inline int _odp_packet_has_l2(odp_packet_t pkt) +{ + _odp_packet_input_flags_t flags; + + flags.all = _odp_packet_input_flags(pkt); + return flags.l2; +} + +/** @internal Inline function @param pkt @return */ +static inline int _odp_packet_has_eth(odp_packet_t pkt) +{ + _odp_packet_input_flags_t flags; + + flags.all = _odp_packet_input_flags(pkt); + return flags.eth; +} + +/** @internal Inline function @param pkt @return */ +static inline int _odp_packet_has_jumbo(odp_packet_t pkt) +{ + _odp_packet_input_flags_t flags; + + flags.all = _odp_packet_input_flags(pkt); + return flags.jumbo; +} + +/** @internal Inline function @param pkt @return */ +static inline int _odp_packet_has_flow_hash(odp_packet_t pkt) +{ + _odp_packet_input_flags_t flags; + + flags.all = _odp_packet_input_flags(pkt); + return flags.flow_hash; +} + +/** @internal Inline function @param pkt @return */ +static inline int _odp_packet_has_ts(odp_packet_t pkt) +{ + _odp_packet_input_flags_t flags; + + flags.all = _odp_packet_input_flags(pkt); + return flags.timestamp; +} + +/* Include inlined versions of API functions */ +#include +#if ODP_ABI_COMPAT == 0 + +/** @ingroup odp_packet + * @{ + */ + +#include + +/** + * @} + */ + +#endif + +#endif diff --git a/platform/linux-generic/include/odp/api/plat/packet_flag_inlines_api.h b/platform/linux-generic/include/odp/api/plat/packet_flag_inlines_api.h new file mode 100644 index 00000000..f4e143aa --- /dev/null +++ b/platform/linux-generic/include/odp/api/plat/packet_flag_inlines_api.h @@ -0,0 +1,41 @@ +/* Copyright (c) 2017, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @file + * + * Packet inline functions + */ + +#ifndef _ODP_PLAT_PACKET_FLAG_INLINES_API_H_ +#define _ODP_PLAT_PACKET_FLAG_INLINES_API_H_ + +_ODP_INLINE int odp_packet_has_l2(odp_packet_t pkt) +{ + return _odp_packet_has_l2(pkt); +} + +_ODP_INLINE int odp_packet_has_eth(odp_packet_t pkt) +{ + return _odp_packet_has_eth(pkt); +} + +_ODP_INLINE int odp_packet_has_jumbo(odp_packet_t pkt) +{ + return _odp_packet_has_jumbo(pkt); +} + +_ODP_INLINE int odp_packet_has_flow_hash(odp_packet_t pkt) +{ + return _odp_packet_has_flow_hash(pkt); +} + +_ODP_INLINE int odp_packet_has_ts(odp_packet_t pkt) +{ + return _odp_packet_has_ts(pkt); +} + +#endif diff --git a/platform/linux-generic/include/odp/api/plat/packet_types.h b/platform/linux-generic/include/odp/api/plat/packet_types.h index 9efb5165..16e4b467 100644 --- a/platform/linux-generic/include/odp/api/plat/packet_types.h +++ b/platform/linux-generic/include/odp/api/plat/packet_types.h @@ -93,9 +93,61 @@ typedef struct _odp_packet_inline_offset_t { size_t flow_hash; /** @internal field offset */ size_t timestamp; + /** @internal field offset */ + size_t input_flags; } _odp_packet_inline_offset_t; +/** @internal Packet input & protocol flags */ +typedef union { + /** All input flags */ + uint64_t all; + + struct { + uint64_t parsed_l2:1; /**< L2 parsed */ + uint64_t dst_queue:1; /**< Dst queue present */ + + uint64_t flow_hash:1; /**< Flow hash present */ + uint64_t timestamp:1; /**< Timestamp present */ + + uint64_t l2:1; /**< known L2 protocol present */ + uint64_t l3:1; /**< known L3 protocol present */ + uint64_t l4:1; /**< known L4 protocol present */ + + uint64_t eth:1; /**< Ethernet */ + uint64_t eth_bcast:1; /**< Ethernet broadcast */ + uint64_t eth_mcast:1; /**< Ethernet multicast */ + uint64_t jumbo:1; /**< Jumbo frame */ + uint64_t vlan:1; /**< VLAN hdr found */ + uint64_t vlan_qinq:1; /**< Stacked VLAN found, QinQ */ + + uint64_t snap:1; /**< SNAP */ + uint64_t arp:1; /**< ARP */ + + uint64_t ipv4:1; /**< IPv4 */ + uint64_t ipv6:1; /**< IPv6 */ + uint64_t ip_bcast:1; /**< IP broadcast */ + uint64_t ip_mcast:1; /**< IP multicast */ + uint64_t ipfrag:1; /**< IP fragment */ + uint64_t ipopt:1; /**< IP optional headers */ + + uint64_t ipsec:1; /**< IPSec packet. Required by the + odp_packet_has_ipsec_set() func. */ + uint64_t ipsec_ah:1; /**< IPSec authentication header */ + uint64_t ipsec_esp:1; /**< IPSec encapsulating security + payload */ + uint64_t udp:1; /**< UDP */ + uint64_t tcp:1; /**< TCP */ + uint64_t tcpopt:1; /**< TCP options present */ + uint64_t sctp:1; /**< SCTP */ + uint64_t icmp:1; /**< ICMP */ + + uint64_t color:2; /**< Packet color for traffic mgmt */ + uint64_t nodrop:1; /**< Drop eligibility status */ + }; + +} _odp_packet_input_flags_t; + #ifdef __cplusplus } #endif diff --git a/platform/linux-generic/include/odp_packet_internal.h b/platform/linux-generic/include/odp_packet_internal.h index 875c376a..2db042e0 100644 --- a/platform/linux-generic/include/odp_packet_internal.h +++ b/platform/linux-generic/include/odp_packet_internal.h @@ -27,62 +27,13 @@ extern "C" { #include #include #include +#include /** Minimum segment length expected by packet_parse_common() */ #define PACKET_PARSE_SEG_LEN 96 -/** - * Packet input & protocol flags - */ -typedef union { - /* All input flags */ - uint64_t all; - - struct { - uint64_t parsed_l2:1; /**< L2 parsed */ - uint64_t dst_queue:1; /**< Dst queue present */ - - uint64_t flow_hash:1; /**< Flow hash present */ - uint64_t timestamp:1; /**< Timestamp present */ - - uint64_t l2:1; /**< known L2 protocol present */ - uint64_t l3:1; /**< known L3 protocol present */ - uint64_t l4:1; /**< known L4 protocol present */ - - uint64_t eth:1; /**< Ethernet */ - uint64_t eth_bcast:1; /**< Ethernet broadcast */ - uint64_t eth_mcast:1; /**< Ethernet multicast */ - uint64_t jumbo:1; /**< Jumbo frame */ - uint64_t vlan:1; /**< VLAN hdr found */ - uint64_t vlan_qinq:1; /**< Stacked VLAN found, QinQ */ - - uint64_t snap:1; /**< SNAP */ - uint64_t arp:1; /**< ARP */ - - uint64_t ipv4:1; /**< IPv4 */ - uint64_t ipv6:1; /**< IPv6 */ - uint64_t ip_bcast:1; /**< IP broadcast */ - uint64_t ip_mcast:1; /**< IP multicast */ - uint64_t ipfrag:1; /**< IP fragment */ - uint64_t ipopt:1; /**< IP optional headers */ - - uint64_t ipsec:1; /**< IPSec packet. Required by the - odp_packet_has_ipsec_set() func. */ - uint64_t ipsec_ah:1; /**< IPSec authentication header */ - uint64_t ipsec_esp:1; /**< IPSec encapsulating security - payload */ - uint64_t udp:1; /**< UDP */ - uint64_t tcp:1; /**< TCP */ - uint64_t tcpopt:1; /**< TCP options present */ - uint64_t sctp:1; /**< SCTP */ - uint64_t icmp:1; /**< ICMP */ - - uint64_t color:2; /**< Packet color for traffic mgmt */ - uint64_t nodrop:1; /**< Drop eligibility status */ - }; -} input_flags_t; -ODP_STATIC_ASSERT(sizeof(input_flags_t) == sizeof(uint64_t), +ODP_STATIC_ASSERT(sizeof(_odp_packet_input_flags_t) == sizeof(uint64_t), "INPUT_FLAGS_SIZE_ERROR"); /** @@ -145,7 +96,7 @@ typedef enum { * Packet parser metadata */ typedef struct { - input_flags_t input_flags; + _odp_packet_input_flags_t input_flags; error_flags_t error_flags; output_flags_t output_flags; diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index a925e722..4d2cde12 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -42,7 +42,9 @@ const _odp_packet_inline_offset_t _odp_packet_inline ODP_ALIGNED_CACHE = { .user_area = offsetof(odp_packet_hdr_t, buf_hdr.uarea_addr), .user_area_size = offsetof(odp_packet_hdr_t, buf_hdr.uarea_size), .flow_hash = offsetof(odp_packet_hdr_t, flow_hash), - .timestamp = offsetof(odp_packet_hdr_t, timestamp) + .timestamp = offsetof(odp_packet_hdr_t, timestamp), + .input_flags = offsetof(odp_packet_hdr_t, p.input_flags) + }; static inline odp_packet_hdr_t *packet_hdr(odp_packet_t pkt) diff --git a/platform/linux-generic/odp_packet_flags.c b/platform/linux-generic/odp_packet_flags.c index 798fa115..ea9a2271 100644 --- a/platform/linux-generic/odp_packet_flags.c +++ b/platform/linux-generic/odp_packet_flags.c @@ -4,6 +4,7 @@ * SPDX-License-Identifier: BSD-3-Clause */ +#include #include #include @@ -32,13 +33,6 @@ int odp_packet_has_error(odp_packet_t pkt) /* Get Input Flags */ -int odp_packet_has_l2(odp_packet_t pkt) -{ - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); - - return pkt_hdr->p.input_flags.l2; -} - int odp_packet_has_l2_error(odp_packet_t pkt) { odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); @@ -79,13 +73,6 @@ int odp_packet_has_l4_error(odp_packet_t pkt) return pkt_hdr->p.error_flags.tcp_err | pkt_hdr->p.error_flags.udp_err; } -int odp_packet_has_eth(odp_packet_t pkt) -{ - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); - - return pkt_hdr->p.input_flags.eth; -} - int odp_packet_has_eth_bcast(odp_packet_t pkt) { retflag(pkt, input_flags.eth_bcast, LAYER_L2); @@ -96,13 +83,6 @@ int odp_packet_has_eth_mcast(odp_packet_t pkt) retflag(pkt, input_flags.eth_mcast, LAYER_L2); } -int odp_packet_has_jumbo(odp_packet_t pkt) -{ - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); - - return pkt_hdr->p.input_flags.jumbo; -} - int odp_packet_has_vlan(odp_packet_t pkt) { retflag(pkt, input_flags.vlan, LAYER_L2); @@ -173,20 +153,6 @@ int odp_packet_has_icmp(odp_packet_t pkt) retflag(pkt, input_flags.icmp, LAYER_L4); } -int odp_packet_has_flow_hash(odp_packet_t pkt) -{ - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); - - return pkt_hdr->p.input_flags.flow_hash; -} - -int odp_packet_has_ts(odp_packet_t pkt) -{ - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); - - return pkt_hdr->p.input_flags.timestamp; -} - odp_packet_color_t odp_packet_color(odp_packet_t pkt) { retflag(pkt, input_flags.color, LAYER_ALL); @@ -352,3 +318,8 @@ void odp_packet_has_ts_clr(odp_packet_t pkt) pkt_hdr->p.input_flags.timestamp = 0; } + +/* Include non-inlined versions of API functions */ +#if ODP_ABI_COMPAT == 1 +#include +#endif