From patchwork Thu Feb 9 11:53:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 93692 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp207895qgi; Thu, 9 Feb 2017 03:54:16 -0800 (PST) X-Received: by 10.55.214.152 with SMTP id p24mr2271742qkl.223.1486641256695; Thu, 09 Feb 2017 03:54:16 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id b197si7796472qkc.251.2017.02.09.03.54.16; Thu, 09 Feb 2017 03:54:16 -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 F1AD4634CE; Thu, 9 Feb 2017 11:54:15 +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 879D762C7E; Thu, 9 Feb 2017 11:54:06 +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 EE83362EB2; Thu, 9 Feb 2017 11:53:59 +0000 (UTC) Received: from mail-ot0-f170.google.com (mail-ot0-f170.google.com [74.125.82.170]) by lists.linaro.org (Postfix) with ESMTPS id E0E7660EC2 for ; Thu, 9 Feb 2017 11:53:57 +0000 (UTC) Received: by mail-ot0-f170.google.com with SMTP id f9so977173otd.1 for ; Thu, 09 Feb 2017 03:53:57 -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=KttKsZ9Hsts/JcA6Z1WB6RtqYFg+HHm95rWqJj3qk+8=; b=NDESLTDaI1rUqAYqKndXm0JjTvwjtkfZlnIq7rAsz/sJ0+C/VObjeTaJ76q606ZMCF C1a+KM/eUCWzA8gkjglJaDHOCmnNWx6X8Xi+Ty8L44OkB6SWZVWSjpCp68TlBJUA+5+7 vP3aGxY77QHw3WasJlovOabEhCjC9GyecF9UZR028ktXQZVUSoZhoLhO8UU1oJnSJPzn 2EHGcb0F0tFHuKNf8mKl5lz0SstRx48bbJp4odvW0mqATgtuaC9lCSrD+gFBJjv84NHh TL+4sQxUHrvTMbA3HvAZcN0dcz3jIGD69TKcSv1O1k9IAVRnYFOWmkI+Y7uZ4xMwdZWW 0HTA== X-Gm-Message-State: AMke39mrTYGoWiHDNAGa5qUi+SP+MjVxEOwtvpCbYExL+ezsiObklVp/dNsMItOaabbkI0Ul9q8= X-Received: by 10.157.27.70 with SMTP id l64mr1329621otl.92.1486641237235; Thu, 09 Feb 2017 03:53:57 -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.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Feb 2017 03:53:56 -0800 (PST) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Thu, 9 Feb 2017 05:53:48 -0600 Message-Id: <20170209115352.16271-2-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 1/5] linux-gen: inline: rename _STATIC to _ODP_INLINE 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 This define is visible to applications through API headers. Use _ODP prefix to avoid name space collision. Also "inline" describes better the purpose of the macro than "static". Signed-off-by: Petri Savolainen Signed-off-by: Bill Fischofer --- .../include/odp/api/plat/atomic_inlines.h | 114 +++++++++++---------- .../include/odp/api/plat/byteorder_inlines.h | 24 ++--- .../include/odp/api/plat/static_inline.h.in | 8 +- .../include/odp/api/plat/std_clib_inlines.h | 6 +- .../include/odp/api/plat/sync_inlines.h | 6 +- 5 files changed, 82 insertions(+), 76 deletions(-) -- 2.11.0.295.gd7dffce diff --git a/platform/linux-generic/include/odp/api/plat/atomic_inlines.h b/platform/linux-generic/include/odp/api/plat/atomic_inlines.h index 4471f2ec..03b2884f 100644 --- a/platform/linux-generic/include/odp/api/plat/atomic_inlines.h +++ b/platform/linux-generic/include/odp/api/plat/atomic_inlines.h @@ -13,63 +13,65 @@ #ifndef _ODP_PLAT_ATOMIC_INLINES_H_ #define _ODP_PLAT_ATOMIC_INLINES_H_ -_STATIC void odp_atomic_init_u32(odp_atomic_u32_t *atom, uint32_t val) +_ODP_INLINE void odp_atomic_init_u32(odp_atomic_u32_t *atom, uint32_t val) { __atomic_store_n(&atom->v, val, __ATOMIC_RELAXED); } -_STATIC uint32_t odp_atomic_load_u32(odp_atomic_u32_t *atom) +_ODP_INLINE uint32_t odp_atomic_load_u32(odp_atomic_u32_t *atom) { return __atomic_load_n(&atom->v, __ATOMIC_RELAXED); } -_STATIC void odp_atomic_store_u32(odp_atomic_u32_t *atom, uint32_t val) +_ODP_INLINE void odp_atomic_store_u32(odp_atomic_u32_t *atom, uint32_t val) { __atomic_store_n(&atom->v, val, __ATOMIC_RELAXED); } -_STATIC uint32_t odp_atomic_fetch_add_u32(odp_atomic_u32_t *atom, uint32_t val) +_ODP_INLINE uint32_t odp_atomic_fetch_add_u32(odp_atomic_u32_t *atom, + uint32_t val) { return __atomic_fetch_add(&atom->v, val, __ATOMIC_RELAXED); } -_STATIC void odp_atomic_add_u32(odp_atomic_u32_t *atom, uint32_t val) +_ODP_INLINE void odp_atomic_add_u32(odp_atomic_u32_t *atom, uint32_t val) { (void)__atomic_fetch_add(&atom->v, val, __ATOMIC_RELAXED); } -_STATIC uint32_t odp_atomic_fetch_sub_u32(odp_atomic_u32_t *atom, uint32_t val) +_ODP_INLINE uint32_t odp_atomic_fetch_sub_u32(odp_atomic_u32_t *atom, + uint32_t val) { return __atomic_fetch_sub(&atom->v, val, __ATOMIC_RELAXED); } -_STATIC void odp_atomic_sub_u32(odp_atomic_u32_t *atom, uint32_t val) +_ODP_INLINE void odp_atomic_sub_u32(odp_atomic_u32_t *atom, uint32_t val) { (void)__atomic_fetch_sub(&atom->v, val, __ATOMIC_RELAXED); } -_STATIC uint32_t odp_atomic_fetch_inc_u32(odp_atomic_u32_t *atom) +_ODP_INLINE uint32_t odp_atomic_fetch_inc_u32(odp_atomic_u32_t *atom) { return __atomic_fetch_add(&atom->v, 1, __ATOMIC_RELAXED); } -_STATIC void odp_atomic_inc_u32(odp_atomic_u32_t *atom) +_ODP_INLINE void odp_atomic_inc_u32(odp_atomic_u32_t *atom) { (void)__atomic_fetch_add(&atom->v, 1, __ATOMIC_RELAXED); } -_STATIC uint32_t odp_atomic_fetch_dec_u32(odp_atomic_u32_t *atom) +_ODP_INLINE uint32_t odp_atomic_fetch_dec_u32(odp_atomic_u32_t *atom) { return __atomic_fetch_sub(&atom->v, 1, __ATOMIC_RELAXED); } -_STATIC void odp_atomic_dec_u32(odp_atomic_u32_t *atom) +_ODP_INLINE void odp_atomic_dec_u32(odp_atomic_u32_t *atom) { (void)__atomic_fetch_sub(&atom->v, 1, __ATOMIC_RELAXED); } -_STATIC int odp_atomic_cas_u32(odp_atomic_u32_t *atom, uint32_t *old_val, - uint32_t new_val) +_ODP_INLINE int odp_atomic_cas_u32(odp_atomic_u32_t *atom, uint32_t *old_val, + uint32_t new_val) { return __atomic_compare_exchange_n(&atom->v, old_val, new_val, 0 /* strong */, @@ -77,12 +79,13 @@ _STATIC int odp_atomic_cas_u32(odp_atomic_u32_t *atom, uint32_t *old_val, __ATOMIC_RELAXED); } -_STATIC uint32_t odp_atomic_xchg_u32(odp_atomic_u32_t *atom, uint32_t new_val) +_ODP_INLINE uint32_t odp_atomic_xchg_u32(odp_atomic_u32_t *atom, + uint32_t new_val) { return __atomic_exchange_n(&atom->v, new_val, __ATOMIC_RELAXED); } -_STATIC void odp_atomic_max_u32(odp_atomic_u32_t *atom, uint32_t new_max) +_ODP_INLINE void odp_atomic_max_u32(odp_atomic_u32_t *atom, uint32_t new_max) { uint32_t old_val; @@ -94,7 +97,7 @@ _STATIC void odp_atomic_max_u32(odp_atomic_u32_t *atom, uint32_t new_max) } } -_STATIC void odp_atomic_min_u32(odp_atomic_u32_t *atom, uint32_t new_min) +_ODP_INLINE void odp_atomic_min_u32(odp_atomic_u32_t *atom, uint32_t new_min) { uint32_t old_val; @@ -106,7 +109,7 @@ _STATIC void odp_atomic_min_u32(odp_atomic_u32_t *atom, uint32_t new_min) } } -_STATIC void odp_atomic_init_u64(odp_atomic_u64_t *atom, uint64_t val) +_ODP_INLINE void odp_atomic_init_u64(odp_atomic_u64_t *atom, uint64_t val) { atom->v = val; #if __GCC_ATOMIC_LLONG_LOCK_FREE < 2 @@ -114,7 +117,7 @@ _STATIC void odp_atomic_init_u64(odp_atomic_u64_t *atom, uint64_t val) #endif } -_STATIC uint64_t odp_atomic_load_u64(odp_atomic_u64_t *atom) +_ODP_INLINE uint64_t odp_atomic_load_u64(odp_atomic_u64_t *atom) { #if __GCC_ATOMIC_LLONG_LOCK_FREE < 2 return ATOMIC_OP(atom, (void)0); @@ -123,7 +126,7 @@ _STATIC uint64_t odp_atomic_load_u64(odp_atomic_u64_t *atom) #endif } -_STATIC void odp_atomic_store_u64(odp_atomic_u64_t *atom, uint64_t val) +_ODP_INLINE void odp_atomic_store_u64(odp_atomic_u64_t *atom, uint64_t val) { #if __GCC_ATOMIC_LLONG_LOCK_FREE < 2 (void)ATOMIC_OP(atom, atom->v = val); @@ -132,7 +135,8 @@ _STATIC void odp_atomic_store_u64(odp_atomic_u64_t *atom, uint64_t val) #endif } -_STATIC uint64_t odp_atomic_fetch_add_u64(odp_atomic_u64_t *atom, uint64_t val) +_ODP_INLINE uint64_t odp_atomic_fetch_add_u64(odp_atomic_u64_t *atom, + uint64_t val) { #if __GCC_ATOMIC_LLONG_LOCK_FREE < 2 return ATOMIC_OP(atom, atom->v += val); @@ -141,7 +145,7 @@ _STATIC uint64_t odp_atomic_fetch_add_u64(odp_atomic_u64_t *atom, uint64_t val) #endif } -_STATIC void odp_atomic_add_u64(odp_atomic_u64_t *atom, uint64_t val) +_ODP_INLINE void odp_atomic_add_u64(odp_atomic_u64_t *atom, uint64_t val) { #if __GCC_ATOMIC_LLONG_LOCK_FREE < 2 (void)ATOMIC_OP(atom, atom->v += val); @@ -150,7 +154,8 @@ _STATIC void odp_atomic_add_u64(odp_atomic_u64_t *atom, uint64_t val) #endif } -_STATIC uint64_t odp_atomic_fetch_sub_u64(odp_atomic_u64_t *atom, uint64_t val) +_ODP_INLINE uint64_t odp_atomic_fetch_sub_u64(odp_atomic_u64_t *atom, + uint64_t val) { #if __GCC_ATOMIC_LLONG_LOCK_FREE < 2 return ATOMIC_OP(atom, atom->v -= val); @@ -159,7 +164,7 @@ _STATIC uint64_t odp_atomic_fetch_sub_u64(odp_atomic_u64_t *atom, uint64_t val) #endif } -_STATIC void odp_atomic_sub_u64(odp_atomic_u64_t *atom, uint64_t val) +_ODP_INLINE void odp_atomic_sub_u64(odp_atomic_u64_t *atom, uint64_t val) { #if __GCC_ATOMIC_LLONG_LOCK_FREE < 2 (void)ATOMIC_OP(atom, atom->v -= val); @@ -168,7 +173,7 @@ _STATIC void odp_atomic_sub_u64(odp_atomic_u64_t *atom, uint64_t val) #endif } -_STATIC uint64_t odp_atomic_fetch_inc_u64(odp_atomic_u64_t *atom) +_ODP_INLINE uint64_t odp_atomic_fetch_inc_u64(odp_atomic_u64_t *atom) { #if __GCC_ATOMIC_LLONG_LOCK_FREE < 2 return ATOMIC_OP(atom, atom->v++); @@ -177,7 +182,7 @@ _STATIC uint64_t odp_atomic_fetch_inc_u64(odp_atomic_u64_t *atom) #endif } -_STATIC void odp_atomic_inc_u64(odp_atomic_u64_t *atom) +_ODP_INLINE void odp_atomic_inc_u64(odp_atomic_u64_t *atom) { #if __GCC_ATOMIC_LLONG_LOCK_FREE < 2 (void)ATOMIC_OP(atom, atom->v++); @@ -186,7 +191,7 @@ _STATIC void odp_atomic_inc_u64(odp_atomic_u64_t *atom) #endif } -_STATIC uint64_t odp_atomic_fetch_dec_u64(odp_atomic_u64_t *atom) +_ODP_INLINE uint64_t odp_atomic_fetch_dec_u64(odp_atomic_u64_t *atom) { #if __GCC_ATOMIC_LLONG_LOCK_FREE < 2 return ATOMIC_OP(atom, atom->v--); @@ -195,7 +200,7 @@ _STATIC uint64_t odp_atomic_fetch_dec_u64(odp_atomic_u64_t *atom) #endif } -_STATIC void odp_atomic_dec_u64(odp_atomic_u64_t *atom) +_ODP_INLINE void odp_atomic_dec_u64(odp_atomic_u64_t *atom) { #if __GCC_ATOMIC_LLONG_LOCK_FREE < 2 (void)ATOMIC_OP(atom, atom->v--); @@ -204,8 +209,8 @@ _STATIC void odp_atomic_dec_u64(odp_atomic_u64_t *atom) #endif } -_STATIC int odp_atomic_cas_u64(odp_atomic_u64_t *atom, uint64_t *old_val, - uint64_t new_val) +_ODP_INLINE int odp_atomic_cas_u64(odp_atomic_u64_t *atom, uint64_t *old_val, + uint64_t new_val) { #if __GCC_ATOMIC_LLONG_LOCK_FREE < 2 int ret; @@ -219,7 +224,8 @@ _STATIC int odp_atomic_cas_u64(odp_atomic_u64_t *atom, uint64_t *old_val, #endif } -_STATIC uint64_t odp_atomic_xchg_u64(odp_atomic_u64_t *atom, uint64_t new_val) +_ODP_INLINE uint64_t odp_atomic_xchg_u64(odp_atomic_u64_t *atom, + uint64_t new_val) { #if __GCC_ATOMIC_LLONG_LOCK_FREE < 2 return ATOMIC_OP(atom, atom->v = new_val); @@ -228,7 +234,7 @@ _STATIC uint64_t odp_atomic_xchg_u64(odp_atomic_u64_t *atom, uint64_t new_val) #endif } -_STATIC void odp_atomic_max_u64(odp_atomic_u64_t *atom, uint64_t new_max) +_ODP_INLINE void odp_atomic_max_u64(odp_atomic_u64_t *atom, uint64_t new_max) { uint64_t old_val; @@ -240,7 +246,7 @@ _STATIC void odp_atomic_max_u64(odp_atomic_u64_t *atom, uint64_t new_max) } } -_STATIC void odp_atomic_min_u64(odp_atomic_u64_t *atom, uint64_t new_min) +_ODP_INLINE void odp_atomic_min_u64(odp_atomic_u64_t *atom, uint64_t new_min) { uint64_t old_val; @@ -252,28 +258,28 @@ _STATIC void odp_atomic_min_u64(odp_atomic_u64_t *atom, uint64_t new_min) } } -_STATIC uint32_t odp_atomic_load_acq_u32(odp_atomic_u32_t *atom) +_ODP_INLINE uint32_t odp_atomic_load_acq_u32(odp_atomic_u32_t *atom) { return __atomic_load_n(&atom->v, __ATOMIC_ACQUIRE); } -_STATIC void odp_atomic_store_rel_u32(odp_atomic_u32_t *atom, uint32_t val) +_ODP_INLINE void odp_atomic_store_rel_u32(odp_atomic_u32_t *atom, uint32_t val) { __atomic_store_n(&atom->v, val, __ATOMIC_RELEASE); } -_STATIC void odp_atomic_add_rel_u32(odp_atomic_u32_t *atom, uint32_t val) +_ODP_INLINE void odp_atomic_add_rel_u32(odp_atomic_u32_t *atom, uint32_t val) { (void)__atomic_fetch_add(&atom->v, val, __ATOMIC_RELEASE); } -_STATIC void odp_atomic_sub_rel_u32(odp_atomic_u32_t *atom, uint32_t val) +_ODP_INLINE void odp_atomic_sub_rel_u32(odp_atomic_u32_t *atom, uint32_t val) { (void)__atomic_fetch_sub(&atom->v, val, __ATOMIC_RELEASE); } -_STATIC int odp_atomic_cas_acq_u32(odp_atomic_u32_t *atom, - uint32_t *old_val, uint32_t new_val) +_ODP_INLINE int odp_atomic_cas_acq_u32(odp_atomic_u32_t *atom, + uint32_t *old_val, uint32_t new_val) { return __atomic_compare_exchange_n(&atom->v, old_val, new_val, 0 /* strong */, @@ -281,8 +287,8 @@ _STATIC int odp_atomic_cas_acq_u32(odp_atomic_u32_t *atom, __ATOMIC_RELAXED); } -_STATIC int odp_atomic_cas_rel_u32(odp_atomic_u32_t *atom, - uint32_t *old_val, uint32_t new_val) +_ODP_INLINE int odp_atomic_cas_rel_u32(odp_atomic_u32_t *atom, + uint32_t *old_val, uint32_t new_val) { return __atomic_compare_exchange_n(&atom->v, old_val, new_val, 0 /* strong */, @@ -290,9 +296,9 @@ _STATIC int odp_atomic_cas_rel_u32(odp_atomic_u32_t *atom, __ATOMIC_RELAXED); } -_STATIC int odp_atomic_cas_acq_rel_u32(odp_atomic_u32_t *atom, - uint32_t *old_val, - uint32_t new_val) +_ODP_INLINE int odp_atomic_cas_acq_rel_u32(odp_atomic_u32_t *atom, + uint32_t *old_val, + uint32_t new_val) { return __atomic_compare_exchange_n(&atom->v, old_val, new_val, 0 /* strong */, @@ -300,7 +306,7 @@ _STATIC int odp_atomic_cas_acq_rel_u32(odp_atomic_u32_t *atom, __ATOMIC_RELAXED); } -_STATIC uint64_t odp_atomic_load_acq_u64(odp_atomic_u64_t *atom) +_ODP_INLINE uint64_t odp_atomic_load_acq_u64(odp_atomic_u64_t *atom) { #if __GCC_ATOMIC_LLONG_LOCK_FREE < 2 return ATOMIC_OP(atom, (void)0); @@ -309,7 +315,7 @@ _STATIC uint64_t odp_atomic_load_acq_u64(odp_atomic_u64_t *atom) #endif } -_STATIC void odp_atomic_store_rel_u64(odp_atomic_u64_t *atom, uint64_t val) +_ODP_INLINE void odp_atomic_store_rel_u64(odp_atomic_u64_t *atom, uint64_t val) { #if __GCC_ATOMIC_LLONG_LOCK_FREE < 2 (void)ATOMIC_OP(atom, atom->v = val); @@ -318,7 +324,7 @@ _STATIC void odp_atomic_store_rel_u64(odp_atomic_u64_t *atom, uint64_t val) #endif } -_STATIC void odp_atomic_add_rel_u64(odp_atomic_u64_t *atom, uint64_t val) +_ODP_INLINE void odp_atomic_add_rel_u64(odp_atomic_u64_t *atom, uint64_t val) { #if __GCC_ATOMIC_LLONG_LOCK_FREE < 2 (void)ATOMIC_OP(atom, atom->v += val); @@ -327,7 +333,7 @@ _STATIC void odp_atomic_add_rel_u64(odp_atomic_u64_t *atom, uint64_t val) #endif } -_STATIC void odp_atomic_sub_rel_u64(odp_atomic_u64_t *atom, uint64_t val) +_ODP_INLINE void odp_atomic_sub_rel_u64(odp_atomic_u64_t *atom, uint64_t val) { #if __GCC_ATOMIC_LLONG_LOCK_FREE < 2 (void)ATOMIC_OP(atom, atom->v -= val); @@ -336,8 +342,8 @@ _STATIC void odp_atomic_sub_rel_u64(odp_atomic_u64_t *atom, uint64_t val) #endif } -_STATIC int odp_atomic_cas_acq_u64(odp_atomic_u64_t *atom, - uint64_t *old_val, uint64_t new_val) +_ODP_INLINE int odp_atomic_cas_acq_u64(odp_atomic_u64_t *atom, + uint64_t *old_val, uint64_t new_val) { #if __GCC_ATOMIC_LLONG_LOCK_FREE < 2 int ret; @@ -351,8 +357,8 @@ _STATIC int odp_atomic_cas_acq_u64(odp_atomic_u64_t *atom, #endif } -_STATIC int odp_atomic_cas_rel_u64(odp_atomic_u64_t *atom, - uint64_t *old_val, uint64_t new_val) +_ODP_INLINE int odp_atomic_cas_rel_u64(odp_atomic_u64_t *atom, + uint64_t *old_val, uint64_t new_val) { #if __GCC_ATOMIC_LLONG_LOCK_FREE < 2 int ret; @@ -366,9 +372,9 @@ _STATIC int odp_atomic_cas_rel_u64(odp_atomic_u64_t *atom, #endif } -_STATIC int odp_atomic_cas_acq_rel_u64(odp_atomic_u64_t *atom, - uint64_t *old_val, - uint64_t new_val) +_ODP_INLINE int odp_atomic_cas_acq_rel_u64(odp_atomic_u64_t *atom, + uint64_t *old_val, + uint64_t new_val) { #if __GCC_ATOMIC_LLONG_LOCK_FREE < 2 int ret; diff --git a/platform/linux-generic/include/odp/api/plat/byteorder_inlines.h b/platform/linux-generic/include/odp/api/plat/byteorder_inlines.h index c91a3b18..e7818904 100644 --- a/platform/linux-generic/include/odp/api/plat/byteorder_inlines.h +++ b/platform/linux-generic/include/odp/api/plat/byteorder_inlines.h @@ -21,7 +21,7 @@ extern "C" { * @{ */ -_STATIC uint16_t odp_be_to_cpu_16(odp_u16be_t be16) +_ODP_INLINE uint16_t odp_be_to_cpu_16(odp_u16be_t be16) { #if ODP_BYTE_ORDER == ODP_LITTLE_ENDIAN return __odp_builtin_bswap16((__odp_force uint16_t)be16); @@ -30,7 +30,7 @@ _STATIC uint16_t odp_be_to_cpu_16(odp_u16be_t be16) #endif } -_STATIC uint32_t odp_be_to_cpu_32(odp_u32be_t be32) +_ODP_INLINE uint32_t odp_be_to_cpu_32(odp_u32be_t be32) { #if ODP_BYTE_ORDER == ODP_LITTLE_ENDIAN return __builtin_bswap32((__odp_force uint32_t)be32); @@ -39,7 +39,7 @@ _STATIC uint32_t odp_be_to_cpu_32(odp_u32be_t be32) #endif } -_STATIC uint64_t odp_be_to_cpu_64(odp_u64be_t be64) +_ODP_INLINE uint64_t odp_be_to_cpu_64(odp_u64be_t be64) { #if ODP_BYTE_ORDER == ODP_LITTLE_ENDIAN return __builtin_bswap64((__odp_force uint64_t)be64); @@ -48,7 +48,7 @@ _STATIC uint64_t odp_be_to_cpu_64(odp_u64be_t be64) #endif } -_STATIC odp_u16be_t odp_cpu_to_be_16(uint16_t cpu16) +_ODP_INLINE odp_u16be_t odp_cpu_to_be_16(uint16_t cpu16) { #if ODP_BYTE_ORDER == ODP_LITTLE_ENDIAN return (__odp_force odp_u16be_t)__odp_builtin_bswap16(cpu16); @@ -57,7 +57,7 @@ _STATIC odp_u16be_t odp_cpu_to_be_16(uint16_t cpu16) #endif } -_STATIC odp_u32be_t odp_cpu_to_be_32(uint32_t cpu32) +_ODP_INLINE odp_u32be_t odp_cpu_to_be_32(uint32_t cpu32) { #if ODP_BYTE_ORDER == ODP_LITTLE_ENDIAN return (__odp_force odp_u32be_t)__builtin_bswap32(cpu32); @@ -66,7 +66,7 @@ _STATIC odp_u32be_t odp_cpu_to_be_32(uint32_t cpu32) #endif } -_STATIC odp_u64be_t odp_cpu_to_be_64(uint64_t cpu64) +_ODP_INLINE odp_u64be_t odp_cpu_to_be_64(uint64_t cpu64) { #if ODP_BYTE_ORDER == ODP_LITTLE_ENDIAN return (__odp_force odp_u64be_t)__builtin_bswap64(cpu64); @@ -75,7 +75,7 @@ _STATIC odp_u64be_t odp_cpu_to_be_64(uint64_t cpu64) #endif } -_STATIC uint16_t odp_le_to_cpu_16(odp_u16le_t le16) +_ODP_INLINE uint16_t odp_le_to_cpu_16(odp_u16le_t le16) { #if ODP_BYTE_ORDER == ODP_LITTLE_ENDIAN return (__odp_force uint16_t)le16; @@ -84,7 +84,7 @@ _STATIC uint16_t odp_le_to_cpu_16(odp_u16le_t le16) #endif } -_STATIC uint32_t odp_le_to_cpu_32(odp_u32le_t le32) +_ODP_INLINE uint32_t odp_le_to_cpu_32(odp_u32le_t le32) { #if ODP_BYTE_ORDER == ODP_LITTLE_ENDIAN return (__odp_force uint32_t)le32; @@ -93,7 +93,7 @@ _STATIC uint32_t odp_le_to_cpu_32(odp_u32le_t le32) #endif } -_STATIC uint64_t odp_le_to_cpu_64(odp_u64le_t le64) +_ODP_INLINE uint64_t odp_le_to_cpu_64(odp_u64le_t le64) { #if ODP_BYTE_ORDER == ODP_LITTLE_ENDIAN return (__odp_force uint64_t)le64; @@ -102,7 +102,7 @@ _STATIC uint64_t odp_le_to_cpu_64(odp_u64le_t le64) #endif } -_STATIC odp_u16le_t odp_cpu_to_le_16(uint16_t cpu16) +_ODP_INLINE odp_u16le_t odp_cpu_to_le_16(uint16_t cpu16) { #if ODP_BYTE_ORDER == ODP_LITTLE_ENDIAN return (__odp_force odp_u16le_t)cpu16; @@ -111,7 +111,7 @@ _STATIC odp_u16le_t odp_cpu_to_le_16(uint16_t cpu16) #endif } -_STATIC odp_u32le_t odp_cpu_to_le_32(uint32_t cpu32) +_ODP_INLINE odp_u32le_t odp_cpu_to_le_32(uint32_t cpu32) { #if ODP_BYTE_ORDER == ODP_LITTLE_ENDIAN return (__odp_force odp_u32le_t)cpu32; @@ -120,7 +120,7 @@ _STATIC odp_u32le_t odp_cpu_to_le_32(uint32_t cpu32) #endif } -_STATIC odp_u64le_t odp_cpu_to_le_64(uint64_t cpu64) +_ODP_INLINE odp_u64le_t odp_cpu_to_le_64(uint64_t cpu64) { #if ODP_BYTE_ORDER == ODP_LITTLE_ENDIAN return (__odp_force odp_u64le_t)cpu64; diff --git a/platform/linux-generic/include/odp/api/plat/static_inline.h.in b/platform/linux-generic/include/odp/api/plat/static_inline.h.in index 4562a225..3cf00434 100644 --- a/platform/linux-generic/include/odp/api/plat/static_inline.h.in +++ b/platform/linux-generic/include/odp/api/plat/static_inline.h.in @@ -25,15 +25,15 @@ extern "C" { /** * @internal - * @def _STATIC - * Control conditional static inline expansions for ABI compatibility + * @def _ODP_INLINE + * Define a function as inlined or not inlined (for ABI compatibility) */ #if @ODP_ABI_COMPAT@ #define ODP_ABI_COMPAT 1 -#define _STATIC +#define _ODP_INLINE #else #define ODP_ABI_COMPAT 0 -#define _STATIC static inline +#define _ODP_INLINE static inline #endif #ifdef __cplusplus diff --git a/platform/linux-generic/include/odp/api/plat/std_clib_inlines.h b/platform/linux-generic/include/odp/api/plat/std_clib_inlines.h index 2e833e41..8f505d07 100644 --- a/platform/linux-generic/include/odp/api/plat/std_clib_inlines.h +++ b/platform/linux-generic/include/odp/api/plat/std_clib_inlines.h @@ -14,17 +14,17 @@ extern "C" { #include #include -_STATIC void *odp_memcpy(void *dst, const void *src, size_t num) +_ODP_INLINE void *odp_memcpy(void *dst, const void *src, size_t num) { return memcpy(dst, src, num); } -_STATIC void *odp_memset(void *ptr, int value, size_t num) +_ODP_INLINE void *odp_memset(void *ptr, int value, size_t num) { return memset(ptr, value, num); } -_STATIC int odp_memcmp(const void *ptr1, const void *ptr2, size_t num) +_ODP_INLINE int odp_memcmp(const void *ptr1, const void *ptr2, size_t num) { return memcmp(ptr1, ptr2, num); } diff --git a/platform/linux-generic/include/odp/api/plat/sync_inlines.h b/platform/linux-generic/include/odp/api/plat/sync_inlines.h index 245c7502..76eb6810 100644 --- a/platform/linux-generic/include/odp/api/plat/sync_inlines.h +++ b/platform/linux-generic/include/odp/api/plat/sync_inlines.h @@ -21,17 +21,17 @@ extern "C" { * @{ */ -_STATIC void odp_mb_release(void) +_ODP_INLINE void odp_mb_release(void) { __atomic_thread_fence(__ATOMIC_RELEASE); } -_STATIC void odp_mb_acquire(void) +_ODP_INLINE void odp_mb_acquire(void) { __atomic_thread_fence(__ATOMIC_ACQUIRE); } -_STATIC void odp_mb_full(void) +_ODP_INLINE void odp_mb_full(void) { __atomic_thread_fence(__ATOMIC_SEQ_CST); } From patchwork Thu Feb 9 11:53:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 93693 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp208273qgi; Thu, 9 Feb 2017 03:55:30 -0800 (PST) X-Received: by 10.200.42.182 with SMTP id b51mr2171952qta.101.1486641330739; Thu, 09 Feb 2017 03:55:30 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id v27si7813986qkv.65.2017.02.09.03.55.30; Thu, 09 Feb 2017 03:55:30 -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 72D49608D2; Thu, 9 Feb 2017 11:55:30 +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 E2A5F62EB3; Thu, 9 Feb 2017 11:54:08 +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 9B88662EB2; Thu, 9 Feb 2017 11:54:02 +0000 (UTC) Received: from mail-ot0-f176.google.com (mail-ot0-f176.google.com [74.125.82.176]) by lists.linaro.org (Postfix) with ESMTPS id A694B62C7E for ; Thu, 9 Feb 2017 11:53:58 +0000 (UTC) Received: by mail-ot0-f176.google.com with SMTP id 32so923175oth.3 for ; Thu, 09 Feb 2017 03:53:58 -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=1y60NwbbKq6eZW4Xsegu9CcufRoymTdhbck2JDqoCww=; b=Hj64OvkgDD+imZ+vnEP/6atH6iQO10S0NZZCRcOik0mJvzWdB4kMlSAoRKXWjdA4XP q9R+9HiQ0R2FFZk3L6B0YXh3G3zD+r5XwKfPDuJPMSk8TJ8W87IDk6OCsYN69Kk1MQYH 5HVHiRgWwgue6iRQd4KjNy5AUTTiT7JOPBACjf3ojHsWCMusjmNopAYiUh4eqxxFSSqH imweZ+PjaVMxnB71zs/s15JtBkuDBDNPNsIJ4AKNAEElQVY90vtQySXFamhtT57MfsM4 NoAQagB8XWXfZAsYwoxudPl+l2k0XoXF6jBFERgSn5PKi2Q0t6/ix+bZ9MRlZqECPlMY +0lw== X-Gm-Message-State: AMke39kUOFw2fRx+HUFzGBZAGrdk0oXTU8rspS8LrGXzRNqaakLgS108C6wWooFER3nalaCPAjY= X-Received: by 10.157.2.39 with SMTP id 36mr1345693otb.150.1486641238122; Thu, 09 Feb 2017 03:53:58 -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.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Feb 2017 03:53:57 -0800 (PST) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Thu, 9 Feb 2017 05:53:49 -0600 Message-Id: <20170209115352.16271-3-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 2/5] linux-gen: ticketlock: inline also in application 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 Enable ticketlock function inlining in applications when not building for ABI compatibility. Signed-off-by: Petri Savolainen Signed-off-by: Bill Fischofer --- platform/linux-generic/Makefile.am | 1 + .../include/odp/api/plat/ticketlock_inlines.h | 19 +++++++++++- .../include/odp/api/plat/ticketlock_inlines_api.h | 36 ++++++++++++++++++++++ .../linux-generic/include/odp/api/ticketlock.h | 4 +++ platform/linux-generic/odp_ticketlock.c | 24 +++------------ 5 files changed, 64 insertions(+), 20 deletions(-) create mode 100644 platform/linux-generic/include/odp/api/plat/ticketlock_inlines_api.h -- 2.11.0.295.gd7dffce diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am index 66ff53d5..63d5cbc0 100644 --- a/platform/linux-generic/Makefile.am +++ b/platform/linux-generic/Makefile.am @@ -98,6 +98,7 @@ odpapiplatinclude_HEADERS = \ $(srcdir)/include/odp/api/plat/thread_types.h \ $(srcdir)/include/odp/api/plat/thrmask_types.h \ $(srcdir)/include/odp/api/plat/ticketlock_inlines.h \ + $(srcdir)/include/odp/api/plat/ticketlock_inlines_api.h \ $(srcdir)/include/odp/api/plat/ticketlock_types.h \ $(srcdir)/include/odp/api/plat/time_types.h \ $(srcdir)/include/odp/api/plat/timer_types.h \ diff --git a/platform/linux-generic/include/odp/api/plat/ticketlock_inlines.h b/platform/linux-generic/include/odp/api/plat/ticketlock_inlines.h index 87432a71..ecbea7c4 100644 --- a/platform/linux-generic/include/odp/api/plat/ticketlock_inlines.h +++ b/platform/linux-generic/include/odp/api/plat/ticketlock_inlines.h @@ -13,11 +13,12 @@ #ifndef _ODP_PLAT_TICKETLOCK_INLINES_H_ #define _ODP_PLAT_TICKETLOCK_INLINES_H_ -#include #include #include #include +#include + /** @internal * Acquire ticket lock. * @@ -110,4 +111,20 @@ static inline int _odp_ticketlock_is_locked(odp_ticketlock_t *ticketlock) odp_atomic_load_u32(&ticketlock->next_ticket); } +/* Include inlined versions of API functions */ +#include +#if ODP_ABI_COMPAT == 0 + +/** @ingroup odp_locks + * @{ + */ + +#include + +/** + * @} + */ + +#endif + #endif diff --git a/platform/linux-generic/include/odp/api/plat/ticketlock_inlines_api.h b/platform/linux-generic/include/odp/api/plat/ticketlock_inlines_api.h new file mode 100644 index 00000000..5efe696f --- /dev/null +++ b/platform/linux-generic/include/odp/api/plat/ticketlock_inlines_api.h @@ -0,0 +1,36 @@ +/* Copyright (c) 2017, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @file + * + * Ticketlock inline functions + */ + +#ifndef _ODP_PLAT_TICKETLOCK_INLINES_API_H_ +#define _ODP_PLAT_TICKETLOCK_INLINES_API_H_ + +_ODP_INLINE void odp_ticketlock_lock(odp_ticketlock_t *lock) +{ + return _odp_ticketlock_lock(lock); +} + +_ODP_INLINE int odp_ticketlock_trylock(odp_ticketlock_t *lock) +{ + return _odp_ticketlock_trylock(lock); +} + +_ODP_INLINE void odp_ticketlock_unlock(odp_ticketlock_t *lock) +{ + _odp_ticketlock_unlock(lock); +} + +_ODP_INLINE int odp_ticketlock_is_locked(odp_ticketlock_t *lock) +{ + return _odp_ticketlock_is_locked(lock); +} + +#endif diff --git a/platform/linux-generic/include/odp/api/ticketlock.h b/platform/linux-generic/include/odp/api/ticketlock.h index 85be4bc5..e0f5d81f 100644 --- a/platform/linux-generic/include/odp/api/ticketlock.h +++ b/platform/linux-generic/include/odp/api/ticketlock.h @@ -19,6 +19,10 @@ extern "C" { #include +#if ODP_ABI_COMPAT == 0 +#include +#endif + #include #ifdef __cplusplus diff --git a/platform/linux-generic/odp_ticketlock.c b/platform/linux-generic/odp_ticketlock.c index f18d78f5..f73dd9ab 100644 --- a/platform/linux-generic/odp_ticketlock.c +++ b/platform/linux-generic/odp_ticketlock.c @@ -5,6 +5,7 @@ */ #include +#include void odp_ticketlock_init(odp_ticketlock_t *ticketlock) { @@ -12,22 +13,7 @@ void odp_ticketlock_init(odp_ticketlock_t *ticketlock) odp_atomic_init_u32(&ticketlock->cur_ticket, 0); } -void odp_ticketlock_lock(odp_ticketlock_t *lock) -{ - return _odp_ticketlock_lock(lock); -} - -int odp_ticketlock_trylock(odp_ticketlock_t *lock) -{ - return _odp_ticketlock_trylock(lock); -} - -void odp_ticketlock_unlock(odp_ticketlock_t *lock) -{ - _odp_ticketlock_unlock(lock); -} - -int odp_ticketlock_is_locked(odp_ticketlock_t *lock) -{ - return _odp_ticketlock_is_locked(lock); -} +/* Include non-inlined versions of API functions */ +#if ODP_ABI_COMPAT == 1 +#include +#endif From patchwork Thu Feb 9 11:53:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 93695 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp208744qgi; Thu, 9 Feb 2017 03:56:59 -0800 (PST) X-Received: by 10.237.37.165 with SMTP id x34mr2244195qtc.218.1486641419612; Thu, 09 Feb 2017 03:56:59 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id 12si7802974qtq.202.2017.02.09.03.56.59; Thu, 09 Feb 2017 03:56:59 -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 42ECE62EB2; Thu, 9 Feb 2017 11:56:59 +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 9BA40634CE; Thu, 9 Feb 2017 11:54:25 +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 46E9A62C7E; Thu, 9 Feb 2017 11:54:05 +0000 (UTC) Received: from mail-ot0-f181.google.com (mail-ot0-f181.google.com [74.125.82.181]) by lists.linaro.org (Postfix) with ESMTPS id A671F62C80 for ; Thu, 9 Feb 2017 11:53:59 +0000 (UTC) Received: by mail-ot0-f181.google.com with SMTP id f9so977723otd.1 for ; Thu, 09 Feb 2017 03:53:59 -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=cw86PMZKpykwM+YpoMt1ERPPKr5Srcd46D3orxPGgcc=; b=Rl+CDrgr5FYmCcK6VOU2OA+PAsN+spvCxR4nbklEssL0o76uyE7XXEWwuBY8M0fRLp OSSIYj0VvmHWPIRpXQI6d4MTZXOEo/f36Z3VewIzSerBkjQD+yBy9HARbpIoSXwXioDQ bdHs+lyB57MzI2q7CcVKp10ukM/H+9dIE6wW1MAfn/wlqYq7gOjYSNQZadMmwAHY2Pzj iMG3R4H89DvOgGZ4RGyjX4SGuEUhK4CtCxO0mMgY8UTgJCNcn9aCTEXtkqXLVJ9ImTK8 FKSvhttXSejm9Bwr5AIEUZ8IxhK2WcmPYJeBbvmlEzJCQyoTUKJCt1ynvMbA5TaUdfwm ht/Q== X-Gm-Message-State: AMke39m2DRiHzCCdB2KtobESwscZyUf93yBoS0ratq625yvQwapScwzULT2x83UDnR4e6xuOm8g= X-Received: by 10.157.15.220 with SMTP id m28mr1273042otd.67.1486641239015; Thu, 09 Feb 2017 03:53:59 -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.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 09 Feb 2017 03:53:58 -0800 (PST) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Thu, 9 Feb 2017 05:53:50 -0600 Message-Id: <20170209115352.16271-4-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 3/5] linux-gen: packet: packet handle is hdr pointer 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 Changed packet handle (odp_packet_t) to store pointer to the packet header, instead a bit field structure of pool and index. Buffer and event handles are not changed. Pointer as handle improves packet accessor function performance and enable accessor function inlining as mapping to pool/index is not needed. Signed-off-by: Petri Savolainen Signed-off-by: Bill Fischofer --- .../include/odp/api/plat/packet_types.h | 2 +- .../linux-generic/include/odp_packet_internal.h | 17 +- platform/linux-generic/odp_packet.c | 175 ++++++++++++--------- 3 files changed, 106 insertions(+), 88 deletions(-) -- 2.11.0.295.gd7dffce 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 34e5dd81..999130ec 100644 --- a/platform/linux-generic/include/odp/api/plat/packet_types.h +++ b/platform/linux-generic/include/odp/api/plat/packet_types.h @@ -32,7 +32,7 @@ extern "C" { typedef ODP_HANDLE_T(odp_packet_t); -#define ODP_PACKET_INVALID _odp_cast_scalar(odp_packet_t, 0xffffffff) +#define ODP_PACKET_INVALID _odp_cast_scalar(odp_packet_t, 0) #define ODP_PACKET_OFFSET_INVALID (0x0fffffff) diff --git a/platform/linux-generic/include/odp_packet_internal.h b/platform/linux-generic/include/odp_packet_internal.h index 42df5ac8..d1c6d456 100644 --- a/platform/linux-generic/include/odp_packet_internal.h +++ b/platform/linux-generic/include/odp_packet_internal.h @@ -217,11 +217,11 @@ typedef struct odp_packet_hdr_t { */ static inline odp_packet_hdr_t *odp_packet_hdr(odp_packet_t pkt) { - return (odp_packet_hdr_t *)buf_hdl_to_hdr((odp_buffer_t)pkt); + return (odp_packet_hdr_t *)(uintptr_t)pkt; } -static inline odp_packet_hdr_t *odp_packet_last_hdr(odp_packet_t pkt, - uint32_t *offset) +static inline odp_packet_hdr_t *packet_last_hdr(odp_packet_t pkt, + uint32_t *offset) { odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); odp_packet_hdr_t *prev_hdr = pkt_hdr; @@ -242,9 +242,9 @@ static inline odp_packet_hdr_t *odp_packet_last_hdr(odp_packet_t pkt, return pkt_hdr; } -static inline odp_packet_hdr_t *odp_packet_prev_hdr(odp_packet_hdr_t *pkt_hdr, - odp_packet_hdr_t *cur_hdr, - uint32_t *offset) +static inline odp_packet_hdr_t *packet_prev_hdr(odp_packet_hdr_t *pkt_hdr, + odp_packet_hdr_t *cur_hdr, + uint32_t *offset) { uint32_t ref_offset = 0; odp_packet_hdr_t *prev_hdr = pkt_hdr; @@ -264,11 +264,6 @@ static inline odp_packet_hdr_t *odp_packet_prev_hdr(odp_packet_hdr_t *pkt_hdr, return pkt_hdr; } -static inline odp_packet_t _odp_packet_hdl(odp_packet_hdr_t *pkt_hdr) -{ - return (odp_packet_t)odp_hdr_to_buf(&pkt_hdr->buf_hdr); -} - static inline void copy_packet_parser_metadata(odp_packet_hdr_t *src_hdr, odp_packet_hdr_t *dst_hdr) { diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index 4aa99cdd..cfed3d9b 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -23,9 +23,14 @@ /* Initial packet segment data length */ #define BASE_LEN CONFIG_PACKET_MAX_SEG_LEN +static inline odp_packet_hdr_t *packet_hdr(odp_packet_t pkt) +{ + return (odp_packet_hdr_t *)(uintptr_t)pkt; +} + static inline odp_packet_t packet_handle(odp_packet_hdr_t *pkt_hdr) { - return (odp_packet_t)pkt_hdr->buf_hdr.handle.handle; + return (odp_packet_t)pkt_hdr; } static inline odp_buffer_t buffer_handle(odp_packet_hdr_t *pkt_hdr) @@ -43,6 +48,11 @@ static inline uint32_t packet_ref_dec(odp_packet_hdr_t *pkt_hdr) return odp_atomic_fetch_dec_u32(&pkt_hdr->ref_count); } +static inline odp_packet_hdr_t *buf_to_packet_hdr(odp_buffer_t buf) +{ + return (odp_packet_hdr_t *)buf_hdl_to_hdr(buf); +} + static inline uint32_t packet_seg_len(odp_packet_hdr_t *pkt_hdr, uint32_t seg_idx) { @@ -534,8 +544,8 @@ static inline int packet_alloc(pool_t *pool, uint32_t len, int max_pkt, odp_packet_hdr_t *hdr; /* First buffer is the packet descriptor */ - pkt[i] = (odp_packet_t)buf[i * num_seg]; hdr = pkt_hdr[i * num_seg]; + pkt[i] = packet_handle(hdr); init_segments(&pkt_hdr[i * num_seg], num_seg); packet_init(hdr, len, parse); @@ -669,7 +679,7 @@ static inline void packet_free(odp_packet_hdr_t *pkt_hdr) void odp_packet_free(odp_packet_t pkt) { - packet_free(odp_packet_hdr(pkt)); + packet_free(packet_hdr(pkt)); } void odp_packet_free_multi(const odp_packet_t pkt[], int num) @@ -678,7 +688,7 @@ void odp_packet_free_multi(const odp_packet_t pkt[], int num) odp_buffer_t buf[nbufs]; int nfree = 0; int i = 0; - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt[0]); + odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt[0]); uint32_t pool_id = pool_id_from_buf(pkt_hdr->buf_hdr.handle.handle); uint32_t next_pool; @@ -694,7 +704,7 @@ void odp_packet_free_multi(const odp_packet_t pkt[], int num) if (++i == num) break; - pkt_hdr = odp_packet_hdr(pkt[i]); + pkt_hdr = packet_hdr(pkt[i]); next_pool = pool_id_from_buf(pkt_hdr->buf_hdr.handle.handle); if (odp_unlikely(next_pool != pool_id)) { @@ -712,7 +722,7 @@ void odp_packet_free_multi(const odp_packet_t pkt[], int num) int odp_packet_reset(odp_packet_t pkt, uint32_t len) { - odp_packet_hdr_t *const pkt_hdr = odp_packet_hdr(pkt); + odp_packet_hdr_t *const pkt_hdr = packet_hdr(pkt); pool_t *pool = pool_entry_from_hdl(pkt_hdr->buf_hdr.pool_hdl); if (len > pool->headroom + pool->data_size + pool->tailroom) @@ -728,22 +738,34 @@ int odp_packet_reset(odp_packet_t pkt, uint32_t len) odp_packet_t _odp_packet_from_buffer(odp_buffer_t buf) { - return (odp_packet_t)buf; + if (odp_unlikely(buf == ODP_BUFFER_INVALID)) + return ODP_PACKET_INVALID; + + return (odp_packet_t)buf_to_packet_hdr(buf); } odp_buffer_t _odp_packet_to_buffer(odp_packet_t pkt) { - return (odp_buffer_t)pkt; + if (odp_unlikely(pkt == ODP_PACKET_INVALID)) + return ODP_BUFFER_INVALID; + + return buffer_handle(packet_hdr(pkt)); } odp_packet_t odp_packet_from_event(odp_event_t ev) { - return (odp_packet_t)ev; + if (odp_unlikely(ev == ODP_EVENT_INVALID)) + return ODP_PACKET_INVALID; + + return (odp_packet_t)buf_to_packet_hdr((odp_buffer_t)ev); } odp_event_t odp_packet_to_event(odp_packet_t pkt) { - return (odp_event_t)pkt; + if (odp_unlikely(pkt == ODP_PACKET_INVALID)) + return ODP_EVENT_INVALID; + + return (odp_event_t)buffer_handle(packet_hdr(pkt)); } /* @@ -755,14 +777,14 @@ odp_event_t odp_packet_to_event(odp_packet_t pkt) void *odp_packet_head(odp_packet_t pkt) { - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); return pkt_hdr->buf_hdr.seg[0].data - pkt_hdr->headroom; } uint32_t odp_packet_buf_len(odp_packet_t pkt) { - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); uint32_t buf_len = 0; do { @@ -775,26 +797,26 @@ uint32_t odp_packet_buf_len(odp_packet_t pkt) void *odp_packet_data(odp_packet_t pkt) { - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); return packet_map(pkt_hdr, 0, NULL, NULL); } uint32_t odp_packet_seg_len(odp_packet_t pkt) { - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); return packet_first_seg_len(pkt_hdr); } uint32_t odp_packet_len(odp_packet_t pkt) { - return packet_len(odp_packet_hdr(pkt)); + return packet_len(packet_hdr(pkt)); } uint32_t odp_packet_unshared_len(odp_packet_t pkt) { - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); uint32_t pkt_len = 0, offset = 0; do { @@ -819,24 +841,24 @@ uint32_t odp_packet_unshared_len(odp_packet_t pkt) uint32_t odp_packet_headroom(odp_packet_t pkt) { - return odp_packet_hdr(pkt)->headroom; + return packet_hdr(pkt)->headroom; } uint32_t odp_packet_tailroom(odp_packet_t pkt) { - return odp_packet_last_hdr(pkt, NULL)->tailroom; + return packet_last_hdr(pkt, NULL)->tailroom; } void *odp_packet_tail(odp_packet_t pkt) { - odp_packet_hdr_t *pkt_hdr = odp_packet_last_hdr(pkt, NULL); + odp_packet_hdr_t *pkt_hdr = packet_last_hdr(pkt, NULL); return packet_tail(pkt_hdr); } void *odp_packet_push_head(odp_packet_t pkt, uint32_t len) { - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); if (len > pkt_hdr->headroom) return NULL; @@ -1021,7 +1043,7 @@ static inline void reset_seg(odp_packet_hdr_t *pkt_hdr, int first, int num) int odp_packet_extend_head(odp_packet_t *pkt, uint32_t len, void **data_ptr, uint32_t *seg_len) { - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(*pkt); + odp_packet_hdr_t *pkt_hdr = packet_hdr(*pkt); uint32_t frame_len = pkt_hdr->frame_len; uint32_t headroom = pkt_hdr->headroom; int ret = 0; @@ -1171,7 +1193,7 @@ int odp_packet_extend_head(odp_packet_t *pkt, uint32_t len, void *odp_packet_pull_head(odp_packet_t pkt, uint32_t len) { - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); if (len > pkt_hdr->frame_len) return NULL; @@ -1185,7 +1207,7 @@ void *odp_packet_pull_head(odp_packet_t pkt, uint32_t len) int odp_packet_trunc_head(odp_packet_t *pkt, uint32_t len, void **data_ptr, uint32_t *seg_len_out) { - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(*pkt), *nxt_hdr; + odp_packet_hdr_t *pkt_hdr = packet_hdr(*pkt), *nxt_hdr; uint32_t seg_len = packet_first_seg_len(pkt_hdr); int ret = 0; @@ -1243,7 +1265,7 @@ int odp_packet_trunc_head(odp_packet_t *pkt, uint32_t len, void *odp_packet_push_tail(odp_packet_t pkt, uint32_t len) { - odp_packet_hdr_t *pkt_hdr = odp_packet_last_hdr(pkt, NULL); + odp_packet_hdr_t *pkt_hdr = packet_last_hdr(pkt, NULL); void *old_tail; if (len > pkt_hdr->tailroom) @@ -1260,7 +1282,7 @@ void *odp_packet_push_tail(odp_packet_t pkt, uint32_t len) int odp_packet_extend_tail(odp_packet_t *pkt, uint32_t len, void **data_ptr, uint32_t *seg_len_out) { - odp_packet_hdr_t *pkt_hdr = odp_packet_last_hdr(*pkt, NULL); + odp_packet_hdr_t *pkt_hdr = packet_last_hdr(*pkt, NULL); uint32_t frame_len = pkt_hdr->frame_len; uint32_t tailroom = pkt_hdr->tailroom; uint32_t tail_off = frame_len; @@ -1353,7 +1375,7 @@ int odp_packet_extend_tail(odp_packet_t *pkt, uint32_t len, void *odp_packet_pull_tail(odp_packet_t pkt, uint32_t len) { - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); if (len > packet_last_seg_len(pkt_hdr)) return NULL; @@ -1370,18 +1392,18 @@ int odp_packet_trunc_tail(odp_packet_t *pkt, uint32_t len, int last; uint32_t seg_len; uint32_t offset; - odp_packet_hdr_t *first_hdr = odp_packet_hdr(*pkt); + odp_packet_hdr_t *first_hdr = packet_hdr(*pkt); odp_packet_hdr_t *pkt_hdr, *prev_hdr; if (len > packet_len(first_hdr)) return -1; - pkt_hdr = odp_packet_last_hdr(*pkt, &offset); + pkt_hdr = packet_last_hdr(*pkt, &offset); /* Special processing for references */ while (len >= pkt_hdr->frame_len - offset && first_hdr->ref_hdr) { len -= (pkt_hdr->frame_len - offset); - prev_hdr = odp_packet_prev_hdr(first_hdr, pkt_hdr, &offset); + prev_hdr = packet_prev_hdr(first_hdr, pkt_hdr, &offset); ODP_ASSERT(packet_ref_count(prev_hdr) == 1); prev_hdr->ref_hdr = NULL; packet_free(pkt_hdr); @@ -1421,7 +1443,7 @@ void *odp_packet_offset(odp_packet_t pkt, uint32_t offset, uint32_t *len, odp_packet_seg_t *seg) { int seg_idx; - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); void *addr = packet_map(pkt_hdr, offset, len, &seg_idx); if (addr != NULL && seg != NULL) @@ -1446,42 +1468,42 @@ void odp_packet_prefetch(odp_packet_t pkt ODP_UNUSED, odp_pool_t odp_packet_pool(odp_packet_t pkt) { - return odp_packet_hdr(pkt)->buf_hdr.pool_hdl; + return packet_hdr(pkt)->buf_hdr.pool_hdl; } odp_pktio_t odp_packet_input(odp_packet_t pkt) { - return odp_packet_hdr(pkt)->input; + return packet_hdr(pkt)->input; } int odp_packet_input_index(odp_packet_t pkt) { - return odp_pktio_index(odp_packet_hdr(pkt)->input); + return odp_pktio_index(packet_hdr(pkt)->input); } void *odp_packet_user_ptr(odp_packet_t pkt) { - return odp_packet_hdr(pkt)->buf_hdr.buf_ctx; + return packet_hdr(pkt)->buf_hdr.buf_ctx; } void odp_packet_user_ptr_set(odp_packet_t pkt, const void *ctx) { - odp_packet_hdr(pkt)->buf_hdr.buf_cctx = ctx; + packet_hdr(pkt)->buf_hdr.buf_cctx = ctx; } void *odp_packet_user_area(odp_packet_t pkt) { - return odp_packet_hdr(pkt)->buf_hdr.uarea_addr; + return packet_hdr(pkt)->buf_hdr.uarea_addr; } uint32_t odp_packet_user_area_size(odp_packet_t pkt) { - return odp_packet_hdr(pkt)->buf_hdr.uarea_size; + return packet_hdr(pkt)->buf_hdr.uarea_size; } void *odp_packet_l2_ptr(odp_packet_t pkt, uint32_t *len) { - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); if (!packet_hdr_has_l2(pkt_hdr)) return NULL; @@ -1490,7 +1512,7 @@ void *odp_packet_l2_ptr(odp_packet_t pkt, uint32_t *len) uint32_t odp_packet_l2_offset(odp_packet_t pkt) { - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); if (!packet_hdr_has_l2(pkt_hdr)) return ODP_PACKET_OFFSET_INVALID; @@ -1499,7 +1521,7 @@ uint32_t odp_packet_l2_offset(odp_packet_t pkt) int odp_packet_l2_offset_set(odp_packet_t pkt, uint32_t offset) { - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); if (offset >= pkt_hdr->frame_len) return -1; @@ -1511,7 +1533,7 @@ int odp_packet_l2_offset_set(odp_packet_t pkt, uint32_t offset) void *odp_packet_l3_ptr(odp_packet_t pkt, uint32_t *len) { - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); if (pkt_hdr->p.parsed_layers < LAYER_L3) packet_parse_layer(pkt_hdr, LAYER_L3); @@ -1520,7 +1542,7 @@ void *odp_packet_l3_ptr(odp_packet_t pkt, uint32_t *len) uint32_t odp_packet_l3_offset(odp_packet_t pkt) { - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); if (pkt_hdr->p.parsed_layers < LAYER_L3) packet_parse_layer(pkt_hdr, LAYER_L3); @@ -1529,7 +1551,7 @@ uint32_t odp_packet_l3_offset(odp_packet_t pkt) int odp_packet_l3_offset_set(odp_packet_t pkt, uint32_t offset) { - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); if (offset >= pkt_hdr->frame_len) return -1; @@ -1542,7 +1564,7 @@ int odp_packet_l3_offset_set(odp_packet_t pkt, uint32_t offset) void *odp_packet_l4_ptr(odp_packet_t pkt, uint32_t *len) { - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); if (pkt_hdr->p.parsed_layers < LAYER_L4) packet_parse_layer(pkt_hdr, LAYER_L4); @@ -1551,7 +1573,7 @@ void *odp_packet_l4_ptr(odp_packet_t pkt, uint32_t *len) uint32_t odp_packet_l4_offset(odp_packet_t pkt) { - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); if (pkt_hdr->p.parsed_layers < LAYER_L4) packet_parse_layer(pkt_hdr, LAYER_L4); @@ -1560,7 +1582,7 @@ uint32_t odp_packet_l4_offset(odp_packet_t pkt) int odp_packet_l4_offset_set(odp_packet_t pkt, uint32_t offset) { - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); if (offset >= pkt_hdr->frame_len) return -1; @@ -1573,14 +1595,14 @@ int odp_packet_l4_offset_set(odp_packet_t pkt, uint32_t offset) uint32_t odp_packet_flow_hash(odp_packet_t pkt) { - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); return pkt_hdr->flow_hash; } void odp_packet_flow_hash_set(odp_packet_t pkt, uint32_t flow_hash) { - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); pkt_hdr->flow_hash = flow_hash; pkt_hdr->p.input_flags.flow_hash = 1; @@ -1588,14 +1610,14 @@ void odp_packet_flow_hash_set(odp_packet_t pkt, uint32_t flow_hash) odp_time_t odp_packet_ts(odp_packet_t pkt) { - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); return pkt_hdr->timestamp; } void odp_packet_ts_set(odp_packet_t pkt, odp_time_t timestamp) { - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); pkt_hdr->timestamp = timestamp; pkt_hdr->p.input_flags.timestamp = 1; @@ -1603,14 +1625,14 @@ void odp_packet_ts_set(odp_packet_t pkt, odp_time_t timestamp) int odp_packet_is_segmented(odp_packet_t pkt) { - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); return pkt_hdr->buf_hdr.segcount > 1 || pkt_hdr->ref_hdr != NULL; } int odp_packet_num_segs(odp_packet_t pkt) { - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); uint32_t segcount = 0, i; uint32_t seg_offset = 0, offset; @@ -1644,7 +1666,7 @@ odp_packet_seg_t odp_packet_last_seg(odp_packet_t pkt) odp_packet_seg_t odp_packet_next_seg(odp_packet_t pkt, odp_packet_seg_t seg) { - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); if (odp_unlikely(seg >= packet_last_seg(pkt_hdr))) return ODP_PACKET_SEG_INVALID; @@ -1661,7 +1683,7 @@ odp_packet_seg_t odp_packet_next_seg(odp_packet_t pkt, odp_packet_seg_t seg) void *odp_packet_seg_data(odp_packet_t pkt, odp_packet_seg_t seg) { - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); uint32_t seg_offset = 0, offset = 0, i; while (seg >= pkt_hdr->buf_hdr.segcount - seg_offset && @@ -1686,7 +1708,7 @@ void *odp_packet_seg_data(odp_packet_t pkt, odp_packet_seg_t seg) uint32_t odp_packet_seg_data_len(odp_packet_t pkt, odp_packet_seg_t seg) { - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); uint32_t seg_offset = 0, offset = 0, i; while (seg >= pkt_hdr->buf_hdr.segcount - seg_offset && @@ -1719,7 +1741,7 @@ uint32_t odp_packet_seg_data_len(odp_packet_t pkt, odp_packet_seg_t seg) int odp_packet_add_data(odp_packet_t *pkt_ptr, uint32_t offset, uint32_t len) { odp_packet_t pkt = *pkt_ptr; - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); uint32_t pktlen = packet_len(pkt_hdr); odp_packet_t newpkt; @@ -1750,7 +1772,7 @@ int odp_packet_add_data(odp_packet_t *pkt_ptr, uint32_t offset, uint32_t len) int odp_packet_rem_data(odp_packet_t *pkt_ptr, uint32_t offset, uint32_t len) { odp_packet_t pkt = *pkt_ptr; - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); uint32_t pktlen = pkt_hdr->frame_len; odp_packet_t newpkt; @@ -1782,7 +1804,7 @@ int odp_packet_align(odp_packet_t *pkt, uint32_t offset, uint32_t len, int rc; uint32_t shift; uint32_t seglen = 0; /* GCC */ - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(*pkt); + odp_packet_hdr_t *pkt_hdr = packet_hdr(*pkt); void *addr = packet_map(pkt_hdr, offset, &seglen, NULL); uint64_t uaddr = (uint64_t)(uintptr_t)addr; uint64_t misalign; @@ -1822,8 +1844,8 @@ int odp_packet_align(odp_packet_t *pkt, uint32_t offset, uint32_t len, int odp_packet_concat(odp_packet_t *dst, odp_packet_t src) { - odp_packet_hdr_t *dst_hdr = odp_packet_hdr(*dst); - odp_packet_hdr_t *src_hdr = odp_packet_hdr(src); + odp_packet_hdr_t *dst_hdr = packet_hdr(*dst); + odp_packet_hdr_t *src_hdr = packet_hdr(src); int dst_segs = dst_hdr->buf_hdr.segcount; int src_segs = src_hdr->buf_hdr.segcount; odp_pool_t dst_pool = dst_hdr->buf_hdr.pool_hdl; @@ -1922,12 +1944,12 @@ static inline odp_packet_t packet_splice(odp_packet_hdr_t *pkt_hdr, pkt_hdr->unshared_len = offset; packet_ref(pkt_hdr); - return _odp_packet_hdl(ref_hdr); + return packet_handle(ref_hdr); } odp_packet_t odp_packet_ref_static(odp_packet_t pkt) { - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); pkt_hdr->unshared_len = 0; packet_ref(pkt_hdr); @@ -1942,7 +1964,7 @@ odp_packet_t odp_packet_ref(odp_packet_t pkt, uint32_t offset) if (pkt == ODP_PACKET_INVALID) return ODP_PACKET_INVALID; - pkt_hdr = odp_packet_hdr(pkt); + pkt_hdr = packet_hdr(pkt); if (offset >= packet_len(pkt_hdr)) return ODP_PACKET_INVALID; @@ -1951,7 +1973,7 @@ odp_packet_t odp_packet_ref(odp_packet_t pkt, uint32_t offset) if (hdr == ODP_PACKET_INVALID) return ODP_PACKET_INVALID; - return packet_splice(pkt_hdr, offset, odp_packet_hdr(hdr)); + return packet_splice(pkt_hdr, offset, packet_hdr(hdr)); } odp_packet_t odp_packet_ref_pkt(odp_packet_t pkt, uint32_t offset, @@ -1966,16 +1988,16 @@ odp_packet_t odp_packet_ref_pkt(odp_packet_t pkt, uint32_t offset, ODP_ASSERT(odp_packet_has_ref(hdr) == 0); - pkt_hdr = odp_packet_hdr(pkt); + pkt_hdr = packet_hdr(pkt); if (offset >= packet_len(pkt_hdr)) return ODP_PACKET_INVALID; - return packet_splice(pkt_hdr, offset, odp_packet_hdr(hdr)); + return packet_splice(pkt_hdr, offset, packet_hdr(hdr)); } int odp_packet_has_ref(odp_packet_t pkt) { - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); return pkt_hdr->ref_hdr != NULL || packet_ref_count(pkt_hdr) > 1; } @@ -2026,7 +2048,7 @@ int odp_packet_copy_to_mem(odp_packet_t pkt, uint32_t offset, uint32_t seglen = 0; /* GCC */ uint32_t cpylen; uint8_t *dstaddr = (uint8_t *)dst; - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); if (offset + len > packet_len(pkt_hdr)) return -1; @@ -2050,7 +2072,7 @@ int odp_packet_copy_from_mem(odp_packet_t pkt, uint32_t offset, uint32_t seglen = 0; /* GCC */ uint32_t cpylen; const uint8_t *srcaddr = (const uint8_t *)src; - odp_packet_hdr_t *pkt_hdr = odp_packet_hdr(pkt); + odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); if (offset + len > packet_len(pkt_hdr)) return -1; @@ -2073,8 +2095,8 @@ int odp_packet_copy_from_pkt(odp_packet_t dst, uint32_t dst_offset, odp_packet_t src, uint32_t src_offset, uint32_t len) { - odp_packet_hdr_t *dst_hdr = odp_packet_hdr(dst); - odp_packet_hdr_t *src_hdr = odp_packet_hdr(src); + odp_packet_hdr_t *dst_hdr = packet_hdr(dst); + odp_packet_hdr_t *src_hdr = packet_hdr(src); void *dst_map; void *src_map; uint32_t cpylen, minseg; @@ -2153,10 +2175,11 @@ void odp_packet_print(odp_packet_t pkt) char str[max_len]; int len = 0; int n = max_len - 1; - odp_packet_hdr_t *hdr = odp_packet_hdr(pkt); + odp_packet_hdr_t *hdr = packet_hdr(pkt); + odp_buffer_t buf = _odp_packet_to_buffer(pkt); len += snprintf(&str[len], n - len, "Packet "); - len += odp_buffer_snprint(&str[len], n - len, (odp_buffer_t)pkt); + len += odp_buffer_snprint(&str[len], n - len, buf); len += snprintf(&str[len], n - len, " input_flags 0x%" PRIx64 "\n", hdr->p.input_flags.all); len += snprintf(&str[len], n - len, " error_flags 0x%" PRIx32 "\n", @@ -2201,7 +2224,7 @@ void odp_packet_print(odp_packet_t pkt) int odp_packet_is_valid(odp_packet_t pkt) { - if (odp_buffer_is_valid((odp_buffer_t)pkt) == 0) + if (odp_buffer_is_valid(_odp_packet_to_buffer(pkt)) == 0) return 0; if (odp_event_type(odp_packet_to_event(pkt)) != ODP_EVENT_PACKET) @@ -2219,8 +2242,8 @@ int odp_packet_is_valid(odp_packet_t pkt) int _odp_packet_copy_md_to_packet(odp_packet_t srcpkt, odp_packet_t dstpkt) { - odp_packet_hdr_t *srchdr = odp_packet_hdr(srcpkt); - odp_packet_hdr_t *dsthdr = odp_packet_hdr(dstpkt); + odp_packet_hdr_t *srchdr = packet_hdr(srcpkt); + odp_packet_hdr_t *dsthdr = packet_hdr(dstpkt); dsthdr->input = srchdr->input; dsthdr->dst_queue = srchdr->dst_queue; From patchwork Thu Feb 9 11:53:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bill Fischofer X-Patchwork-Id: 93697 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp209711qgi; Thu, 9 Feb 2017 04:00:05 -0800 (PST) X-Received: by 10.55.203.213 with SMTP id u82mr2213378qkl.10.1486641605043; Thu, 09 Feb 2017 04:00:05 -0800 (PST) Return-Path: Received: from lists.linaro.org (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTP id m30si7804419qtg.253.2017.02.09.04.00.04; Thu, 09 Feb 2017 04:00:05 -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 A86EA634E6; Thu, 9 Feb 2017 12:00:04 +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 3BF5A634CD; Thu, 9 Feb 2017 11:54:42 +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 3FFE6634C9; Thu, 9 Feb 2017 11:54:09 +0000 (UTC) Received: from mail-ot0-f176.google.com (mail-ot0-f176.google.com [74.125.82.176]) by lists.linaro.org (Postfix) with ESMTPS id 986F660EC2 for ; Thu, 9 Feb 2017 11:54:00 +0000 (UTC) Received: by mail-ot0-f176.google.com with SMTP id f9so978041otd.1 for ; Thu, 09 Feb 2017 03:54:00 -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=K8oXyJPN4nQdnsbLT8OkAOxtBVIk/XfKz7g5s3j6S1k=; b=Koofzv/SQQAQUAtIeKYhjpdxkOrr7bMA4wNGbGEfvdmojDpsGU5l8M9RVXT0S/4vDf e9dRLLiANEyOpvT3jk/tVslqSjUd2/p8bp6lCiNlaROq8nVSout+cJXgZc/yFc8VbOer D6+Q2Qo5y7AVkRgwSLkDc9dFTK8ezca625wOGd9u6Hctjqu+SS3Q1HZLdbrLxZyyUIvT tWr3rLYZBH6lxOfwMa1jihyhwrKMu8mEv7vhsjL409kBgPSok6OZdsYUyRen6WersF2w h5TIPQx4hFkzMihbr79kN9BY40qEKt0mGpmRMCVOQlwxrpmkNaWCbOerw+aC3l+sZKh+ tQPQ== X-Gm-Message-State: AMke39m24x6dsAfOlh8zCAIH7BlBh9NLNYUnemM6QQxLeAIy0DhMId4NCb8aAQNuAK06Vb4MJbg= X-Received: by 10.157.38.165 with SMTP id l34mr1285009otb.97.1486641239925; Thu, 09 Feb 2017 03:53:59 -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:53:59 -0800 (PST) From: Bill Fischofer To: lng-odp@lists.linaro.org Date: Thu, 9 Feb 2017 05:53:51 -0600 Message-Id: <20170209115352.16271-5-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 4/5] linux-gen: packet: inline 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 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 + platform/linux-generic/include/odp/api/packet.h | 11 +- .../include/odp/api/plat/packet_inlines.h | 156 +++++++++++++++++++++ .../include/odp/api/plat/packet_inlines_api.h | 97 +++++++++++++ .../include/odp/api/plat/packet_types.h | 41 ++++++ .../linux-generic/include/odp_packet_internal.h | 19 ++- platform/linux-generic/odp_packet.c | 127 ++++------------- platform/linux-generic/pktio/dpdk.c | 5 +- platform/linux-generic/pktio/netmap.c | 5 +- test/common_plat/performance/Makefile.am | 4 + 10 files changed, 350 insertions(+), 117 deletions(-) create mode 100644 platform/linux-generic/include/odp/api/plat/packet_inlines.h create mode 100644 platform/linux-generic/include/odp/api/plat/packet_inlines_api.h -- 2.11.0.295.gd7dffce diff --git a/platform/linux-generic/Makefile.am b/platform/linux-generic/Makefile.am index 63d5cbc0..a782b28c 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_inlines.h \ + $(srcdir)/include/odp/api/plat/packet_inlines_api.h \ $(srcdir)/include/odp/api/plat/packet_types.h \ $(srcdir)/include/odp/api/plat/packet_io_types.h \ $(srcdir)/include/odp/api/plat/pool_types.h \ diff --git a/platform/linux-generic/include/odp/api/packet.h b/platform/linux-generic/include/odp/api/packet.h index ebbeaf1b..eff40803 100644 --- a/platform/linux-generic/include/odp/api/packet.h +++ b/platform/linux-generic/include/odp/api/packet.h @@ -24,13 +24,10 @@ extern "C" { #include #include -/** @ingroup odp_packet - * @{ - */ - -/** - * @} - */ +#include +#if ODP_ABI_COMPAT == 0 +#include +#endif #include diff --git a/platform/linux-generic/include/odp/api/plat/packet_inlines.h b/platform/linux-generic/include/odp/api/plat/packet_inlines.h new file mode 100644 index 00000000..8bfd85fe --- /dev/null +++ b/platform/linux-generic/include/odp/api/plat/packet_inlines.h @@ -0,0 +1,156 @@ +/* Copyright (c) 2017, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @file + * + * Packet inline functions + */ + +#ifndef _ODP_PLAT_PACKET_INLINES_H_ +#define _ODP_PLAT_PACKET_INLINES_H_ + +#include +#include +#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 void *_odp_packet_data(odp_packet_t pkt) +{ + return _odp_pkt_get(pkt, void *, data); +} + +/** @internal Inline function @param pkt @return */ +static inline uint32_t _odp_packet_seg_len(odp_packet_t pkt) +{ + return _odp_pkt_get(pkt, uint32_t, seg_len); +} + +/** @internal Inline function @param pkt @return */ +static inline uint32_t _odp_packet_len(odp_packet_t pkt) +{ + uint32_t pkt_len = _odp_pkt_get(pkt, uint32_t, frame_len); + void *ref_nxt = _odp_pkt_get(pkt, void *, ref_hdr); + void *ref_pkt = (void *)pkt; + + while (ref_nxt) { + pkt_len += _odp_pkt_get(ref_pkt, uint32_t, ref_len) - + _odp_pkt_get(ref_pkt, uint32_t, ref_offset); + + ref_pkt = ref_nxt; + ref_nxt = _odp_pkt_get(ref_nxt, void *, ref_hdr); + } + + return pkt_len; +} + +/** @internal Inline function @param pkt @return */ +static inline uint32_t _odp_packet_headroom(odp_packet_t pkt) +{ + return _odp_pkt_get(pkt, uint32_t, headroom); +} + +/** @internal Inline function @param pkt @return */ +static inline uint32_t _odp_packet_tailroom(odp_packet_t pkt) +{ + return _odp_pkt_get(pkt, uint32_t, tailroom); +} + +/** @internal Inline function @param pkt @return */ +static inline odp_pool_t _odp_packet_pool(odp_packet_t pkt) +{ + return _odp_pkt_get(pkt, odp_pool_t, pool); +} + +/** @internal Inline function @param pkt @return */ +static inline odp_pktio_t _odp_packet_input(odp_packet_t pkt) +{ + return _odp_pkt_get(pkt, odp_pktio_t, input); +} + +/** @internal Inline function @param pkt @return */ +static inline void *_odp_packet_user_ptr(odp_packet_t pkt) +{ + return _odp_pkt_get(pkt, void *, user_ptr); +} + +/** @internal Inline function @param pkt @return */ +static inline void *_odp_packet_user_area(odp_packet_t pkt) +{ + return _odp_pkt_get(pkt, void *, user_area); +} + +/** @internal Inline function @param pkt @return */ +static inline uint32_t _odp_packet_user_area_size(odp_packet_t pkt) +{ + return _odp_pkt_get(pkt, uint32_t, user_area_size); +} + +/** @internal Inline function @param pkt @return */ +static inline uint32_t _odp_packet_flow_hash(odp_packet_t pkt) +{ + return _odp_pkt_get(pkt, uint32_t, flow_hash); +} + +/** @internal Inline function @param pkt @return */ +static inline odp_time_t _odp_packet_ts(odp_packet_t pkt) +{ + return _odp_pkt_get(pkt, odp_time_t, timestamp); +} + +/** @internal Inline function @param pkt @return */ +static inline void *_odp_packet_head(odp_packet_t pkt) +{ + return (uint8_t *)_odp_packet_data(pkt) - _odp_packet_headroom(pkt); +} + +/** @internal Inline function @param pkt @return */ +static inline int _odp_packet_is_segmented(odp_packet_t pkt) +{ + return _odp_pkt_get(pkt, uint8_t, segcount) > 1 || + _odp_pkt_get(pkt, void *, ref_hdr) != NULL; +} + +/** @internal Inline function @param pkt @return */ +static inline odp_packet_seg_t _odp_packet_first_seg(odp_packet_t pkt) +{ + (void)pkt; + + return 0; +} + +/** @internal Inline function @param pkt @param offset @param len */ +static inline void _odp_packet_prefetch(odp_packet_t pkt, uint32_t offset, + uint32_t len) +{ + (void)pkt; (void)offset; (void)len; +} + +/* 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_inlines_api.h b/platform/linux-generic/include/odp/api/plat/packet_inlines_api.h new file mode 100644 index 00000000..f818f820 --- /dev/null +++ b/platform/linux-generic/include/odp/api/plat/packet_inlines_api.h @@ -0,0 +1,97 @@ +/* Copyright (c) 2017, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @file + * + * Packet inline functions + */ + +#ifndef _ODP_PLAT_PACKET_INLINES_API_H_ +#define _ODP_PLAT_PACKET_INLINES_API_H_ + +_ODP_INLINE void *odp_packet_data(odp_packet_t pkt) +{ + return _odp_packet_data(pkt); +} + +_ODP_INLINE uint32_t odp_packet_seg_len(odp_packet_t pkt) +{ + return _odp_packet_seg_len(pkt); +} + +_ODP_INLINE uint32_t odp_packet_len(odp_packet_t pkt) +{ + return _odp_packet_len(pkt); +} + +_ODP_INLINE uint32_t odp_packet_headroom(odp_packet_t pkt) +{ + return _odp_packet_headroom(pkt); +} + +_ODP_INLINE uint32_t odp_packet_tailroom(odp_packet_t pkt) +{ + return _odp_packet_tailroom(pkt); +} + +_ODP_INLINE odp_pool_t odp_packet_pool(odp_packet_t pkt) +{ + return _odp_packet_pool(pkt); +} + +_ODP_INLINE odp_pktio_t odp_packet_input(odp_packet_t pkt) +{ + return _odp_packet_input(pkt); +} + +_ODP_INLINE void *odp_packet_user_ptr(odp_packet_t pkt) +{ + return _odp_packet_user_ptr(pkt); +} + +_ODP_INLINE void *odp_packet_user_area(odp_packet_t pkt) +{ + return _odp_packet_user_area(pkt); +} + +_ODP_INLINE uint32_t odp_packet_user_area_size(odp_packet_t pkt) +{ + return _odp_packet_user_area_size(pkt); +} + +_ODP_INLINE uint32_t odp_packet_flow_hash(odp_packet_t pkt) +{ + return _odp_packet_flow_hash(pkt); +} + +_ODP_INLINE odp_time_t odp_packet_ts(odp_packet_t pkt) +{ + return _odp_packet_ts(pkt); +} + +_ODP_INLINE void *odp_packet_head(odp_packet_t pkt) +{ + return _odp_packet_head(pkt); +} + +_ODP_INLINE int odp_packet_is_segmented(odp_packet_t pkt) +{ + return _odp_packet_is_segmented(pkt); +} + +_ODP_INLINE odp_packet_seg_t odp_packet_first_seg(odp_packet_t pkt) +{ + return _odp_packet_first_seg(pkt); +} + +_ODP_INLINE void odp_packet_prefetch(odp_packet_t pkt, uint32_t offset, + uint32_t len) +{ + return _odp_packet_prefetch(pkt, offset, len); +} + +#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 999130ec..9efb5165 100644 --- a/platform/linux-generic/include/odp/api/plat/packet_types.h +++ b/platform/linux-generic/include/odp/api/plat/packet_types.h @@ -18,6 +18,8 @@ extern "C" { #endif +#include + #include #if ODP_ABI_COMPAT == 1 #include @@ -55,6 +57,45 @@ typedef enum { #endif +/** @internal Packet header field offsets for inline functions */ +typedef struct _odp_packet_inline_offset_t { + /** @internal field offset */ + size_t data; + /** @internal field offset */ + size_t seg_len; + /** @internal field offset */ + size_t frame_len; + /** @internal field offset */ + size_t headroom; + /** @internal field offset */ + size_t tailroom; + /** @internal field offset */ + size_t unshared_len; + /** @internal field offset */ + size_t ref_hdr; + /** @internal field offset */ + size_t ref_offset; + /** *internal field offset */ + size_t ref_len; + /** @internal field offset */ + size_t pool; + /** @internal field offset */ + size_t input; + /** @internal field offset */ + size_t segcount; + /** @internal field offset */ + size_t user_ptr; + /** @internal field offset */ + size_t user_area; + /** @internal field offset */ + size_t user_area_size; + /** @internal field offset */ + size_t flow_hash; + /** @internal field offset */ + size_t timestamp; + +} _odp_packet_inline_offset_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 d1c6d456..875c376a 100644 --- a/platform/linux-generic/include/odp_packet_internal.h +++ b/platform/linux-generic/include/odp_packet_internal.h @@ -292,17 +292,14 @@ static inline void pull_tail(odp_packet_hdr_t *pkt_hdr, uint32_t len) static inline uint32_t packet_len(odp_packet_hdr_t *pkt_hdr) { - uint32_t pkt_len = 0; - uint32_t offset = 0; - - do { - pkt_len += pkt_hdr->frame_len - offset; - offset = pkt_hdr->ref_offset; - if (pkt_hdr->ref_hdr) - offset += (pkt_hdr->ref_hdr->frame_len - - pkt_hdr->ref_len); - pkt_hdr = pkt_hdr->ref_hdr; - } while (pkt_hdr); + uint32_t pkt_len = pkt_hdr->frame_len; + odp_packet_hdr_t *ref_hdr = pkt_hdr->ref_hdr; + + while (ref_hdr) { + pkt_len += pkt_hdr->ref_offset - pkt_hdr->ref_len; + pkt_hdr = ref_hdr; + ref_hdr = ref_hdr->ref_hdr; + } return pkt_len; } diff --git a/platform/linux-generic/odp_packet.c b/platform/linux-generic/odp_packet.c index cfed3d9b..a925e722 100644 --- a/platform/linux-generic/odp_packet.c +++ b/platform/linux-generic/odp_packet.c @@ -4,6 +4,7 @@ * SPDX-License-Identifier: BSD-3-Clause */ +#include #include #include #include @@ -23,6 +24,27 @@ /* Initial packet segment data length */ #define BASE_LEN CONFIG_PACKET_MAX_SEG_LEN +/* Fill in packet header field offsets for inline functions */ +const _odp_packet_inline_offset_t _odp_packet_inline ODP_ALIGNED_CACHE = { + .data = offsetof(odp_packet_hdr_t, buf_hdr.seg[0].data), + .seg_len = offsetof(odp_packet_hdr_t, buf_hdr.seg[0].len), + .frame_len = offsetof(odp_packet_hdr_t, frame_len), + .headroom = offsetof(odp_packet_hdr_t, headroom), + .tailroom = offsetof(odp_packet_hdr_t, tailroom), + .unshared_len = offsetof(odp_packet_hdr_t, unshared_len), + .ref_hdr = offsetof(odp_packet_hdr_t, ref_hdr), + .ref_offset = offsetof(odp_packet_hdr_t, ref_offset), + .ref_len = offsetof(odp_packet_hdr_t, ref_len), + .pool = offsetof(odp_packet_hdr_t, buf_hdr.pool_hdl), + .input = offsetof(odp_packet_hdr_t, input), + .segcount = offsetof(odp_packet_hdr_t, buf_hdr.segcount), + .user_ptr = offsetof(odp_packet_hdr_t, buf_hdr.buf_ctx), + .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) +}; + static inline odp_packet_hdr_t *packet_hdr(odp_packet_t pkt) { return (odp_packet_hdr_t *)(uintptr_t)pkt; @@ -775,13 +797,6 @@ odp_event_t odp_packet_to_event(odp_packet_t pkt) * */ -void *odp_packet_head(odp_packet_t pkt) -{ - odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); - - return pkt_hdr->buf_hdr.seg[0].data - pkt_hdr->headroom; -} - uint32_t odp_packet_buf_len(odp_packet_t pkt) { odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); @@ -795,25 +810,6 @@ uint32_t odp_packet_buf_len(odp_packet_t pkt) return buf_len; } -void *odp_packet_data(odp_packet_t pkt) -{ - odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); - - return packet_map(pkt_hdr, 0, NULL, NULL); -} - -uint32_t odp_packet_seg_len(odp_packet_t pkt) -{ - odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); - - return packet_first_seg_len(pkt_hdr); -} - -uint32_t odp_packet_len(odp_packet_t pkt) -{ - return packet_len(packet_hdr(pkt)); -} - uint32_t odp_packet_unshared_len(odp_packet_t pkt) { odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); @@ -839,16 +835,6 @@ uint32_t odp_packet_unshared_len(odp_packet_t pkt) return pkt_len; } -uint32_t odp_packet_headroom(odp_packet_t pkt) -{ - return packet_hdr(pkt)->headroom; -} - -uint32_t odp_packet_tailroom(odp_packet_t pkt) -{ - return packet_last_hdr(pkt, NULL)->tailroom; -} - void *odp_packet_tail(odp_packet_t pkt) { odp_packet_hdr_t *pkt_hdr = packet_last_hdr(pkt, NULL); @@ -1452,13 +1438,6 @@ void *odp_packet_offset(odp_packet_t pkt, uint32_t offset, uint32_t *len, return addr; } -/* This function is a no-op */ -void odp_packet_prefetch(odp_packet_t pkt ODP_UNUSED, - uint32_t offset ODP_UNUSED, - uint32_t len ODP_UNUSED) -{ -} - /* * * Meta-data @@ -1466,41 +1445,16 @@ void odp_packet_prefetch(odp_packet_t pkt ODP_UNUSED, * */ -odp_pool_t odp_packet_pool(odp_packet_t pkt) -{ - return packet_hdr(pkt)->buf_hdr.pool_hdl; -} - -odp_pktio_t odp_packet_input(odp_packet_t pkt) -{ - return packet_hdr(pkt)->input; -} - int odp_packet_input_index(odp_packet_t pkt) { return odp_pktio_index(packet_hdr(pkt)->input); } -void *odp_packet_user_ptr(odp_packet_t pkt) -{ - return packet_hdr(pkt)->buf_hdr.buf_ctx; -} - void odp_packet_user_ptr_set(odp_packet_t pkt, const void *ctx) { packet_hdr(pkt)->buf_hdr.buf_cctx = ctx; } -void *odp_packet_user_area(odp_packet_t pkt) -{ - return packet_hdr(pkt)->buf_hdr.uarea_addr; -} - -uint32_t odp_packet_user_area_size(odp_packet_t pkt) -{ - return packet_hdr(pkt)->buf_hdr.uarea_size; -} - void *odp_packet_l2_ptr(odp_packet_t pkt, uint32_t *len) { odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); @@ -1593,13 +1547,6 @@ int odp_packet_l4_offset_set(odp_packet_t pkt, uint32_t offset) return 0; } -uint32_t odp_packet_flow_hash(odp_packet_t pkt) -{ - odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); - - return pkt_hdr->flow_hash; -} - void odp_packet_flow_hash_set(odp_packet_t pkt, uint32_t flow_hash) { odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); @@ -1608,13 +1555,6 @@ void odp_packet_flow_hash_set(odp_packet_t pkt, uint32_t flow_hash) pkt_hdr->p.input_flags.flow_hash = 1; } -odp_time_t odp_packet_ts(odp_packet_t pkt) -{ - odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); - - return pkt_hdr->timestamp; -} - void odp_packet_ts_set(odp_packet_t pkt, odp_time_t timestamp) { odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); @@ -1623,13 +1563,6 @@ void odp_packet_ts_set(odp_packet_t pkt, odp_time_t timestamp) pkt_hdr->p.input_flags.timestamp = 1; } -int odp_packet_is_segmented(odp_packet_t pkt) -{ - odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); - - return pkt_hdr->buf_hdr.segcount > 1 || pkt_hdr->ref_hdr != NULL; -} - int odp_packet_num_segs(odp_packet_t pkt) { odp_packet_hdr_t *pkt_hdr = packet_hdr(pkt); @@ -1654,11 +1587,6 @@ int odp_packet_num_segs(odp_packet_t pkt) return segcount; } -odp_packet_seg_t odp_packet_first_seg(odp_packet_t pkt ODP_UNUSED) -{ - return 0; -} - odp_packet_seg_t odp_packet_last_seg(odp_packet_t pkt) { return (odp_packet_seg_t)(odp_packet_num_segs(pkt) - 1); @@ -1836,7 +1764,7 @@ int odp_packet_align(odp_packet_t *pkt, uint32_t offset, uint32_t len, return rc; (void)odp_packet_move_data(*pkt, 0, shift, - odp_packet_len(*pkt) - shift); + _odp_packet_len(*pkt) - shift); (void)odp_packet_trunc_tail(pkt, shift, NULL, NULL); return 1; @@ -1884,7 +1812,7 @@ int odp_packet_concat(odp_packet_t *dst, odp_packet_t src) int odp_packet_split(odp_packet_t *pkt, uint32_t len, odp_packet_t *tail) { - uint32_t pktlen = odp_packet_len(*pkt); + uint32_t pktlen = _odp_packet_len(*pkt); if (len >= pktlen || tail == NULL) return -1; @@ -2028,7 +1956,7 @@ odp_packet_t odp_packet_copy(odp_packet_t pkt, odp_pool_t pool) odp_packet_t odp_packet_copy_part(odp_packet_t pkt, uint32_t offset, uint32_t len, odp_pool_t pool) { - uint32_t pktlen = odp_packet_len(pkt); + uint32_t pktlen = _odp_packet_len(pkt); odp_packet_t newpkt; if (offset >= pktlen || offset + len > pktlen) @@ -2651,3 +2579,8 @@ uint64_t odp_packet_seg_to_u64(odp_packet_seg_t hdl) { return _odp_pri(hdl); } + +/* Include non-inlined versions of API functions */ +#if ODP_ABI_COMPAT == 1 +#include +#endif diff --git a/platform/linux-generic/pktio/dpdk.c b/platform/linux-generic/pktio/dpdk.c index 9a9f7a4e..1922109a 100644 --- a/platform/linux-generic/pktio/dpdk.c +++ b/platform/linux-generic/pktio/dpdk.c @@ -14,6 +14,9 @@ #include +#include +#include + #include #include #include @@ -836,7 +839,7 @@ static inline int pkt_to_mbuf(pktio_entry_t *pktio_entry, return 0; } for (i = 0; i < num; i++) { - pkt_len = odp_packet_len(pkt_table[i]); + pkt_len = _odp_packet_len(pkt_table[i]); if (pkt_len > pkt_dpdk->mtu) { if (i == 0) diff --git a/platform/linux-generic/pktio/netmap.c b/platform/linux-generic/pktio/netmap.c index 208984b6..ae3db34d 100644 --- a/platform/linux-generic/pktio/netmap.c +++ b/platform/linux-generic/pktio/netmap.c @@ -8,6 +8,9 @@ #include +#include +#include + #include #include #include @@ -806,7 +809,7 @@ static int netmap_send(pktio_entry_t *pktio_entry, int index, for (nb_tx = 0; nb_tx < num; nb_tx++) { pkt = pkt_table[nb_tx]; - pkt_len = odp_packet_len(pkt); + pkt_len = _odp_packet_len(pkt); if (pkt_len > pkt_nm->mtu) { if (nb_tx == 0) diff --git a/test/common_plat/performance/Makefile.am b/test/common_plat/performance/Makefile.am index 1074ade8..9111c0c2 100644 --- a/test/common_plat/performance/Makefile.am +++ b/test/common_plat/performance/Makefile.am @@ -28,6 +28,10 @@ odp_bench_packet_LDFLAGS = $(AM_LDFLAGS) -static odp_bench_packet_CFLAGS = $(AM_CFLAGS) -I${top_srcdir}/test odp_crypto_LDFLAGS = $(AM_LDFLAGS) -static odp_crypto_CFLAGS = $(AM_CFLAGS) -I${top_srcdir}/test +odp_pktio_perf_LDFLAGS = $(AM_LDFLAGS) -static +odp_pktio_perf_CFLAGS = $(AM_CFLAGS) -I${top_srcdir}/test +odp_l2fwd_LDFLAGS = $(AM_LDFLAGS) -static +odp_l2fwd_CFLAGS = $(AM_CFLAGS) -I${top_srcdir}/test odp_pktio_ordered_LDFLAGS = $(AM_LDFLAGS) -static odp_pktio_ordered_CFLAGS = $(AM_CFLAGS) -I${top_srcdir}/test odp_sched_latency_LDFLAGS = $(AM_LDFLAGS) -static 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