diff options
Diffstat (limited to 'platform/linux-generic/include/odp')
114 files changed, 3882 insertions, 3633 deletions
diff --git a/platform/linux-generic/include/odp/api/align.h b/platform/linux-generic/include/odp/api/align.h deleted file mode 100644 index c238b80af..000000000 --- a/platform/linux-generic/include/odp/api/align.h +++ /dev/null @@ -1,58 +0,0 @@ -/* Copyright (c) 2013, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP alignments - */ - -#ifndef ODP_PLAT_ALIGN_H_ -#define ODP_PLAT_ALIGN_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <odp/api/cpu_arch.h> - -/** @ingroup odp_compiler_optim - * @{ - */ - -#ifdef __GNUC__ - -#define ODP_ALIGNED(x) __attribute__((__aligned__(x))) - -#define ODP_PACKED __attribute__((__packed__)) - -#define ODP_OFFSETOF(type, member) __builtin_offsetof(type, member) - -#define ODP_FIELD_SIZEOF(type, member) sizeof(((type *)0)->member) - -#else -#error Non-gcc compatible compiler -#endif - -#define ODP_CACHE_LINE_SIZE _ODP_CACHE_LINE_SIZE - -#define ODP_PAGE_SIZE 4096 - -#define ODP_ALIGNED_CACHE ODP_ALIGNED(ODP_CACHE_LINE_SIZE) - -#define ODP_ALIGNED_PAGE ODP_ALIGNED(ODP_PAGE_SIZE) - -/** - * @} - */ - -#include <odp/api/spec/align.h> - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/api/atomic.h b/platform/linux-generic/include/odp/api/atomic.h deleted file mode 100644 index 7886cb4ea..000000000 --- a/platform/linux-generic/include/odp/api/atomic.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (c) 2013, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP atomic operations - */ - -#ifndef ODP_PLAT_ATOMIC_H_ -#define ODP_PLAT_ATOMIC_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <odp/api/align.h> -#include <odp/api/plat/atomic_types.h> - -/** @ingroup odp_atomic - * @{ - */ - -#include <odp/api/plat/static_inline.h> -#if ODP_ABI_COMPAT == 0 -#include <odp/api/plat/atomic_inlines.h> -#endif - -/** - * @} - */ - -#include <odp/api/spec/atomic.h> - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/api/barrier.h b/platform/linux-generic/include/odp/api/barrier.h deleted file mode 100644 index ab1b77562..000000000 --- a/platform/linux-generic/include/odp/api/barrier.h +++ /dev/null @@ -1,31 +0,0 @@ -/* Copyright (c) 2013, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP execution barriers - */ - -#ifndef ODP_PLAT_BARRIER_H_ -#define ODP_PLAT_BARRIER_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <odp/api/std_types.h> -#include <odp/api/atomic.h> -#include <odp/api/plat/shared_memory_types.h> -#include <odp/api/plat/barrier_types.h> - -#include <odp/api/spec/barrier.h> - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/api/buffer.h b/platform/linux-generic/include/odp/api/buffer.h deleted file mode 100644 index 81dbf1280..000000000 --- a/platform/linux-generic/include/odp/api/buffer.h +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright (c) 2013, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP buffer descriptor - */ - -#ifndef ODP_PLAT_BUFFER_H_ -#define ODP_PLAT_BUFFER_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <odp/api/std_types.h> -#include <odp/api/plat/event_types.h> -#include <odp/api/plat/buffer_types.h> -#include <odp/api/plat/pool_types.h> - -/** @ingroup odp_buffer - * @{ - */ - -/** - * @} - */ - -#include <odp/api/spec/buffer.h> - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/api/byteorder.h b/platform/linux-generic/include/odp/api/byteorder.h deleted file mode 100644 index ec3d0eef7..000000000 --- a/platform/linux-generic/include/odp/api/byteorder.h +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright (c) 2014, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP byteorder - */ - -#ifndef ODP_PLAT_BYTEORDER_H_ -#define ODP_PLAT_BYTEORDER_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <odp/api/std_types.h> -#include <odp/api/plat/byteorder_types.h> -#include <odp/api/compiler.h> - -/** @ingroup odp_compiler_optim - * @{ - */ - -#include <odp/api/plat/static_inline.h> -#if ODP_ABI_COMPAT == 0 -#include <odp/api/plat/byteorder_inlines.h> -#endif - -/** - * @} - */ - -#include <odp/api/spec/byteorder.h> - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/api/classification.h b/platform/linux-generic/include/odp/api/classification.h deleted file mode 100644 index 2ba6eb0eb..000000000 --- a/platform/linux-generic/include/odp/api/classification.h +++ /dev/null @@ -1,46 +0,0 @@ -/* Copyright (c) 2014, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP classification descriptor - */ - -#ifndef ODP_PLAT_CLASSIFICATION_H_ -#define ODP_PLAT_CLASSIFICATION_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <odp/api/std_types.h> -#include <odp/api/plat/pool_types.h> -#include <odp/api/plat/classification_types.h> -#include <odp/api/plat/packet_types.h> -#include <odp/api/plat/packet_io_types.h> -#include <odp/api/plat/queue_types.h> - -/** @ingroup odp_classification - * @{ - */ - -/* REMOVE THESE FROM API SPEC. Typedefs needed only for suppressing Doxygen - * warning. */ -typedef void odp_flowsig_t; -typedef void odp_cos_flow_set_t; - -/** - * @} - */ - -#include <odp/api/spec/classification.h> - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/api/compiler.h b/platform/linux-generic/include/odp/api/compiler.h deleted file mode 100644 index 5249d5d62..000000000 --- a/platform/linux-generic/include/odp/api/compiler.h +++ /dev/null @@ -1,34 +0,0 @@ -/* Copyright (c) 2014, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * Compiler related - */ - -#ifndef ODP_PLAT_COMPILER_H_ -#define ODP_PLAT_COMPILER_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -/** @ingroup odp_compiler_optim - * @{ - */ - -/** - * @} - */ - -#include <odp/api/spec/compiler.h> - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/api/cpu.h b/platform/linux-generic/include/odp/api/cpu.h deleted file mode 100644 index d49c782b1..000000000 --- a/platform/linux-generic/include/odp/api/cpu.h +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright (c) 2015, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP CPU - */ - -#ifndef ODP_PLAT_CPU_H_ -#define ODP_PLAT_CPU_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <odp/api/cpu_arch.h> - -#include <odp/api/spec/cpu.h> - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/api/cpumask.h b/platform/linux-generic/include/odp/api/cpumask.h deleted file mode 100644 index 325ea52ed..000000000 --- a/platform/linux-generic/include/odp/api/cpumask.h +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright (c) 2013, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP CPU masks and enumeration - */ - -#ifndef ODP_PLAT_CPUMASK_H_ -#define ODP_PLAT_CPUMASK_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <odp/api/plat/cpumask_types.h> - -#include <odp/api/spec/cpumask.h> - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/api/crypto.h b/platform/linux-generic/include/odp/api/crypto.h deleted file mode 100644 index 4f65932aa..000000000 --- a/platform/linux-generic/include/odp/api/crypto.h +++ /dev/null @@ -1,41 +0,0 @@ -/* Copyright (c) 2014, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP crypto - */ - -#ifndef ODP_PLAT_CRYPTO_H_ -#define ODP_PLAT_CRYPTO_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <odp/api/std_types.h> -#include <odp/api/plat/packet_types.h> -#include <odp/api/plat/crypto_types.h> -#include <odp/api/plat/buffer_types.h> -#include <odp/api/plat/pool_types.h> -#include <odp/api/queue.h> - -/** @ingroup odp_crypto - * @{ - */ - -/** - * @} - */ - -#include <odp/api/spec/crypto.h> - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/api/debug.h b/platform/linux-generic/include/odp/api/debug.h deleted file mode 100644 index 7db143395..000000000 --- a/platform/linux-generic/include/odp/api/debug.h +++ /dev/null @@ -1,48 +0,0 @@ -/* Copyright (c) 2013, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP debug - */ - -#ifndef ODP_PLAT_DEBUG_H_ -#define ODP_PLAT_DEBUG_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <odp/api/spec/debug.h> - -#if defined(__GNUC__) && !defined(__clang__) - -#if __GNUC__ < 4 || (__GNUC__ == 4 && (__GNUC_MINOR__ < 6)) - -/** - * @internal _Static_assert was only added in GCC 4.6. Provide a weak replacement - * for previous versions. - */ -#define _Static_assert(e, s) (extern int (*static_assert_checker(void)) \ - [sizeof(struct { unsigned int error_if_negative:(e) ? 1 : -1; })]) - -#endif - -#endif - -/** - * @internal Compile time assertion macro. Fails compilation and outputs 'msg' - * if condition 'cond' is false. Macro definition is empty when compiler is not - * supported or the compiler does not support static assertion. - */ -#define ODP_STATIC_ASSERT(cond, msg) _Static_assert(cond, msg) - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/api/errno.h b/platform/linux-generic/include/odp/api/errno.h deleted file mode 100644 index f70d84df0..000000000 --- a/platform/linux-generic/include/odp/api/errno.h +++ /dev/null @@ -1,27 +0,0 @@ -/* Copyright (c) 2015, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP errno API - */ - -#ifndef ODP_PLAT_ERRNO_H_ -#define ODP_PLAT_ERRNO_H_ - -#ifdef __cplusplus -extern "C" { -#endif - - -#include <odp/api/spec/errno.h> - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/api/event.h b/platform/linux-generic/include/odp/api/event.h deleted file mode 100644 index 55931b625..000000000 --- a/platform/linux-generic/include/odp/api/event.h +++ /dev/null @@ -1,36 +0,0 @@ -/* Copyright (c) 2015, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP event - */ - -#ifndef ODP_PLAT_EVENT_H_ -#define ODP_PLAT_EVENT_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <odp/api/plat/event_types.h> - -/** @ingroup odp_event - * @{ - */ - -/** - * @} - */ - -#include <odp/api/spec/event.h> - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/api/hash.h b/platform/linux-generic/include/odp/api/hash.h deleted file mode 100644 index 332029ed0..000000000 --- a/platform/linux-generic/include/odp/api/hash.h +++ /dev/null @@ -1,34 +0,0 @@ -/* Copyright (c) 2015, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP Hash function - */ - -#ifndef ODP_PLAT_HASH_H_ -#define ODP_PLAT_HASH_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -/** @ingroup odp_hash - * @{ - */ - -/** - * @} - */ - -#include <odp/api/spec/hash.h> - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/api/hints.h b/platform/linux-generic/include/odp/api/hints.h deleted file mode 100644 index 3ba1ba95e..000000000 --- a/platform/linux-generic/include/odp/api/hints.h +++ /dev/null @@ -1,34 +0,0 @@ -/* Copyright (c) 2013, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP compiler hints - */ - -#ifndef ODP_PLAT_HINTS_H_ -#define ODP_PLAT_HINTS_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -/** @ingroup odp_compiler_optim - * @{ - */ - -/** - * @} - */ - -#include <odp/api/spec/hints.h> - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/api/init.h b/platform/linux-generic/include/odp/api/init.h deleted file mode 100644 index 1d9f59a6f..000000000 --- a/platform/linux-generic/include/odp/api/init.h +++ /dev/null @@ -1,36 +0,0 @@ -/* Copyright (c) 2013, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP initialization. - */ - -#ifndef ODP_PLAT_INIT_H_ -#define ODP_PLAT_INIT_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <odp/api/plat/init_types.h> - -/** @ingroup odp_initialization - * @{ - */ - -/** - * @} - */ - -#include <odp/api/spec/init.h> - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/api/packet.h b/platform/linux-generic/include/odp/api/packet.h deleted file mode 100644 index eff408035..000000000 --- a/platform/linux-generic/include/odp/api/packet.h +++ /dev/null @@ -1,38 +0,0 @@ -/* Copyright (c) 2013, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP packet descriptor - */ - -#ifndef ODP_PLAT_PACKET_H_ -#define ODP_PLAT_PACKET_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <odp/api/std_types.h> -#include <odp/api/plat/event_types.h> -#include <odp/api/plat/packet_io_types.h> -#include <odp/api/plat/packet_types.h> -#include <odp/api/plat/buffer_types.h> -#include <odp/api/plat/pool_types.h> - -#include <odp/api/plat/static_inline.h> -#if ODP_ABI_COMPAT == 0 -#include <odp/api/plat/packet_inlines.h> -#endif - -#include <odp/api/spec/packet.h> - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/api/packet_flags.h b/platform/linux-generic/include/odp/api/packet_flags.h deleted file mode 100644 index 1e55af823..000000000 --- a/platform/linux-generic/include/odp/api/packet_flags.h +++ /dev/null @@ -1,31 +0,0 @@ -/* Copyright (c) 2014, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP packet flags - */ - -#ifndef ODP_PLAT_PACKET_FLAGS_H_ -#define ODP_PLAT_PACKET_FLAGS_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <odp/api/plat/static_inline.h> -#if ODP_ABI_COMPAT == 0 -#include <odp/api/plat/packet_flag_inlines.h> -#endif - -#include <odp/api/spec/packet_flags.h> - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/api/packet_io.h b/platform/linux-generic/include/odp/api/packet_io.h deleted file mode 100644 index 76c7dfeda..000000000 --- a/platform/linux-generic/include/odp/api/packet_io.h +++ /dev/null @@ -1,41 +0,0 @@ -/* Copyright (c) 2013, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP Packet IO - */ - -#ifndef ODP_PLAT_PACKET_IO_H_ -#define ODP_PLAT_PACKET_IO_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <odp/api/std_types.h> -#include <odp/api/plat/pool_types.h> -#include <odp/api/plat/classification_types.h> -#include <odp/api/plat/packet_types.h> -#include <odp/api/plat/packet_io_types.h> -#include <odp/api/plat/queue_types.h> - -/** @ingroup odp_packet_io - * @{ - */ - -/** - * @} - */ - -#include <odp/api/spec/packet_io.h> - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/api/packet_io_stats.h b/platform/linux-generic/include/odp/api/packet_io_stats.h deleted file mode 100644 index a9cd9535e..000000000 --- a/platform/linux-generic/include/odp/api/packet_io_stats.h +++ /dev/null @@ -1,26 +0,0 @@ -/* Copyright (c) 2016, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP packet IO stats - */ - -#ifndef ODP_PLAT_PACKET_IO_STATS_H_ -#define ODP_PLAT_PACKET_IO_STATS_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <odp/api/spec/packet_io_stats.h> - -#ifdef __cplusplus -} -#endif - -#endif 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 03b2884fd..e47559102 100644 --- a/platform/linux-generic/include/odp/api/plat/atomic_inlines.h +++ b/platform/linux-generic/include/odp/api/plat/atomic_inlines.h @@ -1,4 +1,5 @@ -/* Copyright (c) 2016, Linaro Limited +/* Copyright (c) 2016-2018, Linaro Limited + * Copyright (c) 2021, Nokia * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -13,6 +14,69 @@ #ifndef _ODP_PLAT_ATOMIC_INLINES_H_ #define _ODP_PLAT_ATOMIC_INLINES_H_ +#include <odp/api/abi/atomic_inlines.h> + +/** @cond _ODP_HIDE_FROM_DOXYGEN_ */ + +#ifndef _ODP_NO_INLINE + /* Inline functions by default */ + #define _ODP_INLINE static inline + #define odp_atomic_init_u32 __odp_atomic_init_u32 + #define odp_atomic_load_u32 __odp_atomic_load_u32 + #define odp_atomic_store_u32 __odp_atomic_store_u32 + #define odp_atomic_fetch_add_u32 __odp_atomic_fetch_add_u32 + #define odp_atomic_add_u32 __odp_atomic_add_u32 + #define odp_atomic_fetch_sub_u32 __odp_atomic_fetch_sub_u32 + #define odp_atomic_sub_u32 __odp_atomic_sub_u32 + #define odp_atomic_fetch_inc_u32 __odp_atomic_fetch_inc_u32 + #define odp_atomic_inc_u32 __odp_atomic_inc_u32 + #define odp_atomic_fetch_dec_u32 __odp_atomic_fetch_dec_u32 + #define odp_atomic_dec_u32 __odp_atomic_dec_u32 + #define odp_atomic_cas_u32 __odp_atomic_cas_u32 + #define odp_atomic_xchg_u32 __odp_atomic_xchg_u32 + #define odp_atomic_load_acq_u32 __odp_atomic_load_acq_u32 + #define odp_atomic_store_rel_u32 __odp_atomic_store_rel_u32 + #define odp_atomic_add_rel_u32 __odp_atomic_add_rel_u32 + #define odp_atomic_sub_rel_u32 __odp_atomic_sub_rel_u32 + #define odp_atomic_cas_acq_u32 __odp_atomic_cas_acq_u32 + #define odp_atomic_cas_rel_u32 __odp_atomic_cas_rel_u32 + #define odp_atomic_cas_acq_rel_u32 __odp_atomic_cas_acq_rel_u32 + #define odp_atomic_max_u32 __odp_atomic_max_u32 + #define odp_atomic_min_u32 __odp_atomic_min_u32 + #define odp_atomic_init_u64 __odp_atomic_init_u64 + #define odp_atomic_load_u64 __odp_atomic_load_u64 + #define odp_atomic_store_u64 __odp_atomic_store_u64 + #define odp_atomic_fetch_add_u64 __odp_atomic_fetch_add_u64 + #define odp_atomic_add_u64 __odp_atomic_add_u64 + #define odp_atomic_fetch_sub_u64 __odp_atomic_fetch_sub_u64 + #define odp_atomic_sub_u64 __odp_atomic_sub_u64 + #define odp_atomic_fetch_inc_u64 __odp_atomic_fetch_inc_u64 + #define odp_atomic_inc_u64 __odp_atomic_inc_u64 + #define odp_atomic_fetch_dec_u64 __odp_atomic_fetch_dec_u64 + #define odp_atomic_dec_u64 __odp_atomic_dec_u64 + #define odp_atomic_cas_u64 __odp_atomic_cas_u64 + #define odp_atomic_xchg_u64 __odp_atomic_xchg_u64 + #define odp_atomic_load_acq_u64 __odp_atomic_load_acq_u64 + #define odp_atomic_store_rel_u64 __odp_atomic_store_rel_u64 + #define odp_atomic_add_rel_u64 __odp_atomic_add_rel_u64 + #define odp_atomic_sub_rel_u64 __odp_atomic_sub_rel_u64 + #define odp_atomic_cas_acq_u64 __odp_atomic_cas_acq_u64 + #define odp_atomic_cas_rel_u64 __odp_atomic_cas_rel_u64 + #define odp_atomic_cas_acq_rel_u64 __odp_atomic_cas_acq_rel_u64 + #define odp_atomic_max_u64 __odp_atomic_max_u64 + #define odp_atomic_min_u64 __odp_atomic_min_u64 + #define odp_atomic_init_u128 __odp_atomic_init_u128 + #define odp_atomic_load_u128 __odp_atomic_load_u128 + #define odp_atomic_store_u128 __odp_atomic_store_u128 + #define odp_atomic_cas_u128 __odp_atomic_cas_u128 + #define odp_atomic_cas_acq_u128 __odp_atomic_cas_acq_u128 + #define odp_atomic_cas_rel_u128 __odp_atomic_cas_rel_u128 + #define odp_atomic_cas_acq_rel_u128 __odp_atomic_cas_acq_rel_u128 + +#else + #define _ODP_INLINE +#endif + _ODP_INLINE void odp_atomic_init_u32(odp_atomic_u32_t *atom, uint32_t val) { __atomic_store_n(&atom->v, val, __ATOMIC_RELAXED); @@ -36,7 +100,7 @@ _ODP_INLINE uint32_t odp_atomic_fetch_add_u32(odp_atomic_u32_t *atom, _ODP_INLINE void odp_atomic_add_u32(odp_atomic_u32_t *atom, uint32_t val) { - (void)__atomic_fetch_add(&atom->v, val, __ATOMIC_RELAXED); + _odp_atomic_add_u32(atom, val); } _ODP_INLINE uint32_t odp_atomic_fetch_sub_u32(odp_atomic_u32_t *atom, @@ -47,7 +111,7 @@ _ODP_INLINE uint32_t odp_atomic_fetch_sub_u32(odp_atomic_u32_t *atom, _ODP_INLINE void odp_atomic_sub_u32(odp_atomic_u32_t *atom, uint32_t val) { - (void)__atomic_fetch_sub(&atom->v, val, __ATOMIC_RELAXED); + _odp_atomic_sub_u32(atom, val); } _ODP_INLINE uint32_t odp_atomic_fetch_inc_u32(odp_atomic_u32_t *atom) @@ -57,7 +121,7 @@ _ODP_INLINE uint32_t odp_atomic_fetch_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); + _odp_atomic_inc_u32(atom); } _ODP_INLINE uint32_t odp_atomic_fetch_dec_u32(odp_atomic_u32_t *atom) @@ -67,7 +131,7 @@ _ODP_INLINE uint32_t odp_atomic_fetch_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); + _odp_atomic_dec_u32(atom); } _ODP_INLINE int odp_atomic_cas_u32(odp_atomic_u32_t *atom, uint32_t *old_val, @@ -85,307 +149,413 @@ _ODP_INLINE uint32_t odp_atomic_xchg_u32(odp_atomic_u32_t *atom, return __atomic_exchange_n(&atom->v, new_val, __ATOMIC_RELAXED); } -_ODP_INLINE 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 val) { - uint32_t old_val; - - old_val = odp_atomic_load_u32(atom); - - while (new_max > old_val) { - if (odp_atomic_cas_u32(atom, &old_val, new_max)) - break; - } + _odp_atomic_max_u32(atom, val); } -_ODP_INLINE 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 val) { - uint32_t old_val; + _odp_atomic_min_u32(atom, val); +} - old_val = odp_atomic_load_u32(atom); +#ifdef ODP_ATOMIC_U64_LOCK - while (new_min < old_val) { - if (odp_atomic_cas_u32(atom, &old_val, new_min)) - break; - } -} +/** + * @internal + * CAS operation expression for the ATOMIC_OP macro + */ +#define ATOMIC_CAS_OP(ret_ptr, old_val, new_val) \ +__extension__ ({ \ + if (atom->v == (old_val)) { \ + atom->v = (new_val); \ + *(ret_ptr) = 1; \ + } else { \ + *(ret_ptr) = 0; \ + } \ +}) + +/** + * @internal + * Helper macro for lock-based atomic operations on 64-bit integers + * @param[in,out] atom Pointer to the 64-bit atomic variable + * @param expr Expression used update the variable. + * @return The old value of the variable. + */ +#define ATOMIC_OP(atom, expr) \ +__extension__ ({ \ + uint64_t _old_val; \ + /* Loop while lock is already taken, stop when lock becomes clear */ \ + while (__atomic_test_and_set(&(atom)->lock, __ATOMIC_ACQUIRE)) \ + (void)0; \ + _old_val = (atom)->v; \ + (expr); /* Perform whatever update is desired */ \ + __atomic_clear(&(atom)->lock, __ATOMIC_RELEASE); \ + _old_val; /* Return old value */ \ +}) _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 __atomic_clear(&atom->lock, __ATOMIC_RELAXED); -#endif } _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); -#else - return __atomic_load_n(&atom->v, __ATOMIC_RELAXED); -#endif } _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); -#else - __atomic_store_n(&atom->v, val, __ATOMIC_RELAXED); -#endif } _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); -#else - return __atomic_fetch_add(&atom->v, val, __ATOMIC_RELAXED); -#endif } _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); -#else - (void)__atomic_fetch_add(&atom->v, val, __ATOMIC_RELAXED); -#endif } _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); -#else - return __atomic_fetch_sub(&atom->v, val, __ATOMIC_RELAXED); -#endif } _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); -#else - (void)__atomic_fetch_sub(&atom->v, val, __ATOMIC_RELAXED); -#endif } _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++); -#else - return __atomic_fetch_add(&atom->v, 1, __ATOMIC_RELAXED); -#endif } _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++); -#else - (void)__atomic_fetch_add(&atom->v, 1, __ATOMIC_RELAXED); -#endif } _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--); -#else - return __atomic_fetch_sub(&atom->v, 1, __ATOMIC_RELAXED); -#endif } _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--); -#else - (void)__atomic_fetch_sub(&atom->v, 1, __ATOMIC_RELAXED); -#endif } _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; *old_val = ATOMIC_OP(atom, ATOMIC_CAS_OP(&ret, *old_val, new_val)); return ret; -#else - return __atomic_compare_exchange_n(&atom->v, old_val, new_val, - 0 /* strong */, - __ATOMIC_RELAXED, - __ATOMIC_RELAXED); -#endif } _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); -#else - return __atomic_exchange_n(&atom->v, new_val, __ATOMIC_RELAXED); -#endif } -_ODP_INLINE void odp_atomic_max_u64(odp_atomic_u64_t *atom, uint64_t new_max) +_ODP_INLINE uint64_t odp_atomic_load_acq_u64(odp_atomic_u64_t *atom) +{ + return ATOMIC_OP(atom, (void)0); +} + +_ODP_INLINE void odp_atomic_store_rel_u64(odp_atomic_u64_t *atom, uint64_t val) +{ + (void)ATOMIC_OP(atom, atom->v = val); +} + +_ODP_INLINE void odp_atomic_add_rel_u64(odp_atomic_u64_t *atom, uint64_t val) +{ + (void)ATOMIC_OP(atom, atom->v += val); +} + +_ODP_INLINE void odp_atomic_sub_rel_u64(odp_atomic_u64_t *atom, uint64_t val) +{ + (void)ATOMIC_OP(atom, atom->v -= val); +} + +_ODP_INLINE int odp_atomic_cas_acq_u64(odp_atomic_u64_t *atom, + uint64_t *old_val, uint64_t new_val) +{ + int ret; + *old_val = ATOMIC_OP(atom, ATOMIC_CAS_OP(&ret, *old_val, new_val)); + return ret; +} + +_ODP_INLINE int odp_atomic_cas_rel_u64(odp_atomic_u64_t *atom, + uint64_t *old_val, uint64_t new_val) +{ + int ret; + *old_val = ATOMIC_OP(atom, ATOMIC_CAS_OP(&ret, *old_val, new_val)); + return ret; +} + +_ODP_INLINE int odp_atomic_cas_acq_rel_u64(odp_atomic_u64_t *atom, + uint64_t *old_val, + uint64_t new_val) +{ + int ret; + *old_val = ATOMIC_OP(atom, ATOMIC_CAS_OP(&ret, *old_val, new_val)); + return ret; +} + +_ODP_INLINE void odp_atomic_max_u64(odp_atomic_u64_t *atom, uint64_t new_val) { uint64_t old_val; old_val = odp_atomic_load_u64(atom); - while (new_max > old_val) { - if (odp_atomic_cas_u64(atom, &old_val, new_max)) + while (new_val > old_val) { + if (odp_atomic_cas_u64(atom, &old_val, new_val)) break; } } -_ODP_INLINE 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_val) { uint64_t old_val; old_val = odp_atomic_load_u64(atom); - while (new_min < old_val) { - if (odp_atomic_cas_u64(atom, &old_val, new_min)) + while (new_val < old_val) { + if (odp_atomic_cas_u64(atom, &old_val, new_val)) break; } } -_ODP_INLINE uint32_t odp_atomic_load_acq_u32(odp_atomic_u32_t *atom) +#else /* !ODP_ATOMIC_U64_LOCK */ + +_ODP_INLINE void odp_atomic_init_u64(odp_atomic_u64_t *atom, uint64_t val) { - return __atomic_load_n(&atom->v, __ATOMIC_ACQUIRE); + atom->v = val; } -_ODP_INLINE void odp_atomic_store_rel_u32(odp_atomic_u32_t *atom, uint32_t val) +_ODP_INLINE uint64_t odp_atomic_load_u64(odp_atomic_u64_t *atom) { - __atomic_store_n(&atom->v, val, __ATOMIC_RELEASE); + return __atomic_load_n(&atom->v, __ATOMIC_RELAXED); } -_ODP_INLINE void odp_atomic_add_rel_u32(odp_atomic_u32_t *atom, uint32_t val) +_ODP_INLINE void odp_atomic_store_u64(odp_atomic_u64_t *atom, uint64_t val) { - (void)__atomic_fetch_add(&atom->v, val, __ATOMIC_RELEASE); + __atomic_store_n(&atom->v, val, __ATOMIC_RELAXED); } -_ODP_INLINE void odp_atomic_sub_rel_u32(odp_atomic_u32_t *atom, uint32_t val) +_ODP_INLINE uint64_t odp_atomic_fetch_add_u64(odp_atomic_u64_t *atom, + uint64_t val) { - (void)__atomic_fetch_sub(&atom->v, val, __ATOMIC_RELEASE); + return __atomic_fetch_add(&atom->v, val, __ATOMIC_RELAXED); } -_ODP_INLINE int odp_atomic_cas_acq_u32(odp_atomic_u32_t *atom, - uint32_t *old_val, uint32_t new_val) +_ODP_INLINE void odp_atomic_add_u64(odp_atomic_u64_t *atom, uint64_t val) { - return __atomic_compare_exchange_n(&atom->v, old_val, new_val, - 0 /* strong */, - __ATOMIC_ACQUIRE, - __ATOMIC_RELAXED); + _odp_atomic_add_u64(atom, val); } -_ODP_INLINE int odp_atomic_cas_rel_u32(odp_atomic_u32_t *atom, - uint32_t *old_val, uint32_t new_val) +_ODP_INLINE uint64_t odp_atomic_fetch_sub_u64(odp_atomic_u64_t *atom, + uint64_t val) { - return __atomic_compare_exchange_n(&atom->v, old_val, new_val, - 0 /* strong */, - __ATOMIC_RELEASE, - __ATOMIC_RELAXED); + return __atomic_fetch_sub(&atom->v, val, __ATOMIC_RELAXED); } -_ODP_INLINE int odp_atomic_cas_acq_rel_u32(odp_atomic_u32_t *atom, - uint32_t *old_val, - uint32_t new_val) +_ODP_INLINE void odp_atomic_sub_u64(odp_atomic_u64_t *atom, uint64_t val) +{ + _odp_atomic_sub_u64(atom, val); +} + +_ODP_INLINE uint64_t odp_atomic_fetch_inc_u64(odp_atomic_u64_t *atom) +{ + return __atomic_fetch_add(&atom->v, 1, __ATOMIC_RELAXED); +} + +_ODP_INLINE void odp_atomic_inc_u64(odp_atomic_u64_t *atom) +{ + _odp_atomic_inc_u64(atom); +} + +_ODP_INLINE uint64_t odp_atomic_fetch_dec_u64(odp_atomic_u64_t *atom) +{ + return __atomic_fetch_sub(&atom->v, 1, __ATOMIC_RELAXED); +} + +_ODP_INLINE void odp_atomic_dec_u64(odp_atomic_u64_t *atom) +{ + _odp_atomic_dec_u64(atom); +} + +_ODP_INLINE int odp_atomic_cas_u64(odp_atomic_u64_t *atom, uint64_t *old_val, + uint64_t new_val) { return __atomic_compare_exchange_n(&atom->v, old_val, new_val, 0 /* strong */, - __ATOMIC_ACQ_REL, + __ATOMIC_RELAXED, __ATOMIC_RELAXED); } +_ODP_INLINE uint64_t odp_atomic_xchg_u64(odp_atomic_u64_t *atom, + uint64_t new_val) +{ + return __atomic_exchange_n(&atom->v, new_val, __ATOMIC_RELAXED); +} + _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); -#else return __atomic_load_n(&atom->v, __ATOMIC_ACQUIRE); -#endif } _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); -#else __atomic_store_n(&atom->v, val, __ATOMIC_RELEASE); -#endif } _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); -#else - (void)__atomic_fetch_add(&atom->v, val, __ATOMIC_RELEASE); -#endif + _odp_atomic_add_rel_u64(atom, 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); -#else - (void)__atomic_fetch_sub(&atom->v, val, __ATOMIC_RELEASE); -#endif + _odp_atomic_sub_rel_u64(atom, 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; - *old_val = ATOMIC_OP(atom, ATOMIC_CAS_OP(&ret, *old_val, new_val)); - return ret; -#else return __atomic_compare_exchange_n(&atom->v, old_val, new_val, 0 /* strong */, __ATOMIC_ACQUIRE, __ATOMIC_RELAXED); -#endif } _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; - *old_val = ATOMIC_OP(atom, ATOMIC_CAS_OP(&ret, *old_val, new_val)); - return ret; -#else return __atomic_compare_exchange_n(&atom->v, old_val, new_val, 0 /* strong */, __ATOMIC_RELEASE, __ATOMIC_RELAXED); -#endif } _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; - *old_val = ATOMIC_OP(atom, ATOMIC_CAS_OP(&ret, *old_val, new_val)); - return ret; -#else return __atomic_compare_exchange_n(&atom->v, old_val, new_val, 0 /* strong */, __ATOMIC_ACQ_REL, __ATOMIC_RELAXED); -#endif } +_ODP_INLINE void odp_atomic_max_u64(odp_atomic_u64_t *atom, uint64_t val) +{ + _odp_atomic_max_u64(atom, val); +} + +_ODP_INLINE void odp_atomic_min_u64(odp_atomic_u64_t *atom, uint64_t val) +{ + _odp_atomic_min_u64(atom, val); +} + +#endif /* !ODP_ATOMIC_U64_LOCK */ + +_ODP_INLINE uint32_t odp_atomic_load_acq_u32(odp_atomic_u32_t *atom) +{ + return __atomic_load_n(&atom->v, __ATOMIC_ACQUIRE); +} + +_ODP_INLINE void odp_atomic_store_rel_u32(odp_atomic_u32_t *atom, uint32_t val) +{ + __atomic_store_n(&atom->v, val, __ATOMIC_RELEASE); +} + +_ODP_INLINE void odp_atomic_add_rel_u32(odp_atomic_u32_t *atom, uint32_t val) +{ + _odp_atomic_add_rel_u32(atom, val); +} + +_ODP_INLINE void odp_atomic_sub_rel_u32(odp_atomic_u32_t *atom, uint32_t val) +{ + _odp_atomic_sub_rel_u32(atom, 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 */, + __ATOMIC_ACQUIRE, + __ATOMIC_RELAXED); +} + +_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 */, + __ATOMIC_RELEASE, + __ATOMIC_RELAXED); +} + +_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 */, + __ATOMIC_ACQ_REL, + __ATOMIC_RELAXED); +} + +_ODP_INLINE void odp_atomic_init_u128(odp_atomic_u128_t *atom, odp_u128_t val) +{ + _odp_atomic_init_u128(atom, val); +} + +_ODP_INLINE odp_u128_t odp_atomic_load_u128(odp_atomic_u128_t *atom) +{ + return _odp_atomic_load_u128(atom); +} + +_ODP_INLINE void odp_atomic_store_u128(odp_atomic_u128_t *atom, odp_u128_t val) +{ + _odp_atomic_store_u128(atom, val); +} + +_ODP_INLINE int odp_atomic_cas_u128(odp_atomic_u128_t *atom, + odp_u128_t *old_val, odp_u128_t new_val) +{ + return _odp_atomic_cas_u128(atom, old_val, new_val); +} + +_ODP_INLINE int odp_atomic_cas_acq_u128(odp_atomic_u128_t *atom, + odp_u128_t *old_val, odp_u128_t new_val) +{ + return _odp_atomic_cas_acq_u128(atom, old_val, new_val); +} + +_ODP_INLINE int odp_atomic_cas_rel_u128(odp_atomic_u128_t *atom, + odp_u128_t *old_val, odp_u128_t new_val) +{ + return _odp_atomic_cas_rel_u128(atom, old_val, new_val); +} + +_ODP_INLINE int odp_atomic_cas_acq_rel_u128(odp_atomic_u128_t *atom, + odp_u128_t *old_val, odp_u128_t new_val) +{ + return _odp_atomic_cas_acq_rel_u128(atom, old_val, new_val); +} + +/** @endcond */ + #endif diff --git a/platform/linux-generic/include/odp/api/plat/atomic_types.h b/platform/linux-generic/include/odp/api/plat/atomic_types.h deleted file mode 100644 index a674ac997..000000000 --- a/platform/linux-generic/include/odp/api/plat/atomic_types.h +++ /dev/null @@ -1,88 +0,0 @@ -/* Copyright (c) 2015, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP atomic operations - */ - -#ifndef ODP_ATOMIC_TYPES_H_ -#define ODP_ATOMIC_TYPES_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <odp/api/std_types.h> -#include <odp/api/align.h> - -/** - * @internal - * Atomic 64-bit unsigned integer - */ -struct odp_atomic_u64_s { - uint64_t v; /**< Actual storage for the atomic variable */ -#if __GCC_ATOMIC_LLONG_LOCK_FREE < 2 - /* Some architectures do not support lock-free operations on 64-bit - * data types. We use a spin lock to ensure atomicity. */ - char lock; /**< Spin lock (if needed) used to ensure atomic access */ -#endif -} ODP_ALIGNED(sizeof(uint64_t)); /* Enforce alignement! */ - -/** - * @internal - * Atomic 32-bit unsigned integer - */ -struct odp_atomic_u32_s { - uint32_t v; /**< Actual storage for the atomic variable */ -} ODP_ALIGNED(sizeof(uint32_t)); /* Enforce alignement! */ - -#if __GCC_ATOMIC_LLONG_LOCK_FREE < 2 - -/** - * @internal - * CAS operation expression for the ATOMIC_OP macro - */ -#define ATOMIC_CAS_OP(ret_ptr, old_val, new_val) \ -({ \ - if (atom->v == (old_val)) { \ - atom->v = (new_val); \ - *(ret_ptr) = 1; \ - } else { \ - *(ret_ptr) = 0; \ - } \ -}) - -/** - * @internal - * Helper macro for lock-based atomic operations on 64-bit integers - * @param[in,out] atom Pointer to the 64-bit atomic variable - * @param expr Expression used update the variable. - * @return The old value of the variable. - */ -#define ATOMIC_OP(atom, expr) \ -({ \ - uint64_t _old_val; \ - /* Loop while lock is already taken, stop when lock becomes clear */ \ - while (__atomic_test_and_set(&(atom)->lock, __ATOMIC_ACQUIRE)) \ - (void)0; \ - _old_val = (atom)->v; \ - (expr); /* Perform whatever update is desired */ \ - __atomic_clear(&(atom)->lock, __ATOMIC_RELEASE); \ - _old_val; /* Return old value */ \ -}) -#endif - -typedef struct odp_atomic_u64_s odp_atomic_u64_t; - -typedef struct odp_atomic_u32_s odp_atomic_u32_t; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/api/plat/barrier_types.h b/platform/linux-generic/include/odp/api/plat/barrier_types.h deleted file mode 100644 index 00b383cc6..000000000 --- a/platform/linux-generic/include/odp/api/plat/barrier_types.h +++ /dev/null @@ -1,38 +0,0 @@ -/* Copyright (c) 2015, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP barrier - */ - -#ifndef ODP_BARRIER_TYPES_H_ -#define ODP_BARRIER_TYPES_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <odp/api/std_types.h> -#include <odp/api/atomic.h> - -/** - * @internal - * ODP thread synchronization barrier - */ -struct odp_barrier_s { - uint32_t count; /**< Thread count */ - odp_atomic_u32_t bar; /**< Barrier counter */ -}; - -typedef struct odp_barrier_s odp_barrier_t; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/api/plat/buffer_inline_types.h b/platform/linux-generic/include/odp/api/plat/buffer_inline_types.h new file mode 100644 index 000000000..f64a176f5 --- /dev/null +++ b/platform/linux-generic/include/odp/api/plat/buffer_inline_types.h @@ -0,0 +1,37 @@ +/* Copyright (c) 2022, Nokia + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef ODP_PLAT_BUFFER_INLINE_TYPES_H_ +#define ODP_PLAT_BUFFER_INLINE_TYPES_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdint.h> + +/** @cond _ODP_HIDE_FROM_DOXYGEN_ */ + +/* Buffer header field accessors */ +#define _odp_buffer_get(buffer_hdr, cast, field) \ + (*(cast *)(uintptr_t)((uint8_t *)buffer_hdr + \ + _odp_buffer_inline_offset.field)) + +/* Buffer header field offsets for inline functions */ +typedef struct _odp_buffer_inline_offset_t { + uint16_t uarea_addr; + +} _odp_buffer_inline_offset_t; + +extern const _odp_buffer_inline_offset_t _odp_buffer_inline_offset; + +/** @endcond */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/platform/linux-generic/include/odp/api/plat/buffer_inlines.h b/platform/linux-generic/include/odp/api/plat/buffer_inlines.h new file mode 100644 index 000000000..75ef36cf3 --- /dev/null +++ b/platform/linux-generic/include/odp/api/plat/buffer_inlines.h @@ -0,0 +1,84 @@ +/* Copyright (c) 2019-2023, Nokia + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef ODP_PLAT_BUFFER_INLINES_H_ +#define ODP_PLAT_BUFFER_INLINES_H_ + +#include <odp/api/buffer_types.h> +#include <odp/api/event.h> +#include <odp/api/pool_types.h> + +#include <odp/api/plat/buffer_inline_types.h> +#include <odp/api/plat/debug_inlines.h> +#include <odp/api/plat/event_inline_types.h> +#include <odp/api/plat/pool_inline_types.h> + +/** @cond _ODP_HIDE_FROM_DOXYGEN_ */ + +#ifndef _ODP_NO_INLINE + /* Inline functions by default */ + #define _ODP_INLINE static inline + #define odp_buffer_from_event __odp_buffer_from_event + #define odp_buffer_from_event_multi __odp_buffer_from_event_multi + #define odp_buffer_to_event __odp_buffer_to_event + #define odp_buffer_to_event_multi __odp_buffer_to_event_multi + #define odp_buffer_addr __odp_buffer_addr + #define odp_buffer_size __odp_buffer_size + #define odp_buffer_pool __odp_buffer_pool + #define odp_buffer_user_area __odp_buffer_user_area +#else + #define _ODP_INLINE +#endif + +_ODP_INLINE odp_buffer_t odp_buffer_from_event(odp_event_t ev) +{ + _ODP_ASSERT(odp_event_type(ev) == ODP_EVENT_BUFFER); + + return (odp_buffer_t)ev; +} + +_ODP_INLINE void odp_buffer_from_event_multi(odp_buffer_t buf[], const odp_event_t ev[], int num) +{ + for (int i = 0; i < num; i++) + buf[i] = odp_buffer_from_event(ev[i]); +} + +_ODP_INLINE odp_event_t odp_buffer_to_event(odp_buffer_t buf) +{ + return (odp_event_t)buf; +} + +_ODP_INLINE void odp_buffer_to_event_multi(const odp_buffer_t buf[], odp_event_t ev[], int num) +{ + for (int i = 0; i < num; i++) + ev[i] = odp_buffer_to_event(buf[i]); +} + +_ODP_INLINE void *odp_buffer_addr(odp_buffer_t buf) +{ + return _odp_event_hdr_field((odp_event_t)buf, void *, base_data); +} + +_ODP_INLINE uint32_t odp_buffer_size(odp_buffer_t buf) +{ + odp_pool_t pool = _odp_event_hdr_field(buf, odp_pool_t, pool); + + return _odp_pool_get(pool, uint32_t, seg_len); +} + +_ODP_INLINE odp_pool_t odp_buffer_pool(odp_buffer_t buf) +{ + return _odp_event_hdr_field(buf, odp_pool_t, pool); +} + +_ODP_INLINE void *odp_buffer_user_area(odp_buffer_t buf) +{ + return _odp_buffer_get(buf, void *, uarea_addr); +} + +/** @endcond */ + +#endif diff --git a/platform/linux-generic/include/odp/api/plat/buffer_types.h b/platform/linux-generic/include/odp/api/plat/buffer_types.h deleted file mode 100644 index 809768f3d..000000000 --- a/platform/linux-generic/include/odp/api/plat/buffer_types.h +++ /dev/null @@ -1,50 +0,0 @@ -/* Copyright (c) 2015, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP buffer descriptor - */ - -#ifndef ODP_BUFFER_TYPES_H_ -#define ODP_BUFFER_TYPES_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <odp/api/plat/static_inline.h> -#if ODP_ABI_COMPAT == 1 -#include <odp/api/abi/buffer.h> -#else - -#include <odp/api/std_types.h> -#include <odp/api/plat/strong_types.h> - -/** @ingroup odp_buffer - * @{ - */ - -typedef ODP_HANDLE_T(odp_buffer_t); - -#define ODP_BUFFER_INVALID _odp_cast_scalar(odp_buffer_t, 0xffffffff) - -typedef ODP_HANDLE_T(odp_buffer_seg_t); - -#define ODP_SEGMENT_INVALID ((odp_buffer_seg_t)ODP_BUFFER_INVALID) - -/** - * @} - */ - -#endif - -#ifdef __cplusplus -} -#endif - -#endif 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 e7818904b..31d2f1db9 100644 --- a/platform/linux-generic/include/odp/api/plat/byteorder_inlines.h +++ b/platform/linux-generic/include/odp/api/plat/byteorder_inlines.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2016, Linaro Limited +/* Copyright (c) 2016-2018, Linaro Limited * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -17,9 +17,54 @@ extern "C" { #endif -/** @ingroup odp_compiler_optim - * @{ +#include <odp/api/abi/byteorder.h> + +/** @cond _ODP_HIDE_FROM_DOXYGEN_ */ + +#ifndef __odp_force +#define __odp_force +#endif + +#ifndef _ODP_NO_INLINE + /* Inline functions by default */ + #define _ODP_INLINE static inline + #define odp_be_to_cpu_16 __odp_be_to_cpu_16 + #define odp_be_to_cpu_32 __odp_be_to_cpu_32 + #define odp_be_to_cpu_64 __odp_be_to_cpu_64 + #define odp_cpu_to_be_16 __odp_cpu_to_be_16 + #define odp_cpu_to_be_32 __odp_cpu_to_be_32 + #define odp_cpu_to_be_64 __odp_cpu_to_be_64 + #define odp_le_to_cpu_16 __odp_le_to_cpu_16 + #define odp_le_to_cpu_32 __odp_le_to_cpu_32 + #define odp_le_to_cpu_64 __odp_le_to_cpu_64 + #define odp_cpu_to_le_16 __odp_cpu_to_le_16 + #define odp_cpu_to_le_32 __odp_cpu_to_le_32 + #define odp_cpu_to_le_64 __odp_cpu_to_le_64 +#else + #define _ODP_INLINE +#endif + +/** @internal GNU compiler version */ +#define GCC_VERSION (__GNUC__ * 10000 \ + + __GNUC_MINOR__ * 100 \ + + __GNUC_PATCHLEVEL__) + +/** + * @internal + * Compiler __builtin_bswap16() is not available on all platforms + * until GCC 4.8.0 - work around this by offering __odp_builtin_bswap16() + * Don't use this function directly, instead see odp_byteorder.h */ +#if GCC_VERSION < 40800 +/* + * We have to explicitly cast back to uint16_t because clang promotes the + * left side of << operator to int. + */ +#define __odp_builtin_bswap16(u16) ((uint16_t)(((u16)&0x00ff) << 8) | \ + (((u16)&0xff00) >> 8)) +#else +#define __odp_builtin_bswap16(u16) __builtin_bswap16(u16) +#endif _ODP_INLINE uint16_t odp_be_to_cpu_16(odp_u16be_t be16) { @@ -129,9 +174,7 @@ _ODP_INLINE odp_u64le_t odp_cpu_to_le_64(uint64_t cpu64) #endif } -/** - * @} - */ +/** @endcond */ #ifdef __cplusplus } diff --git a/platform/linux-generic/include/odp/api/plat/byteorder_types.h b/platform/linux-generic/include/odp/api/plat/byteorder_types.h deleted file mode 100644 index 20d52bf8f..000000000 --- a/platform/linux-generic/include/odp/api/plat/byteorder_types.h +++ /dev/null @@ -1,84 +0,0 @@ -/* Copyright (c) 2015, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP byteorder - */ - -#ifndef ODP_BYTEORDER_TYPES_H_ -#define ODP_BYTEORDER_TYPES_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#ifndef __BYTE_ORDER__ -#error __BYTE_ORDER not defined! -#endif - -#ifndef __ORDER_BIG_ENDIAN__ -#error __BIG_ENDIAN not defined! -#endif - -#ifndef __ORDER_LITTLE_ENDIAN__ -#error __LITTLE_ENDIAN not defined! -#endif - -/* for use with type checkers such as sparse */ -#ifdef __CHECKER__ -/** @internal bitwise attribute */ -#define __odp_bitwise __attribute__((bitwise)) -/** @internal force attribute */ -#define __odp_force __attribute__((force)) -#else -/** @internal bitwise attribute */ -#define __odp_bitwise -/** @internal force attribute */ -#define __odp_force -#endif - -/** @addtogroup odp_compiler_optim - * @{ - */ -#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ - #define ODP_LITTLE_ENDIAN 1 - #define ODP_BIG_ENDIAN 0 - #define ODP_BYTE_ORDER ODP_LITTLE_ENDIAN - #define ODP_LITTLE_ENDIAN_BITFIELD 1 - #define ODP_BIG_ENDIAN_BITFIELD 0 - #define ODP_BITFIELD_ORDER ODP_LITTLE_ENDIAN_BITFIELD -#else - #define ODP_LITTLE_ENDIAN 0 - #define ODP_BIG_ENDIAN 1 - #define ODP_BYTE_ORDER ODP_BIG_ENDIAN - #define ODP_LITTLE_ENDIAN_BITFIELD 0 - #define ODP_BIG_ENDIAN_BITFIELD 1 - #define ODP_BITFIELD_ORDER ODP_BIG_ENDIAN_BITFIELD -#endif - -typedef uint16_t __odp_bitwise odp_u16le_t; -typedef uint16_t __odp_bitwise odp_u16be_t; - -typedef uint32_t __odp_bitwise odp_u32le_t; -typedef uint32_t __odp_bitwise odp_u32be_t; - -typedef uint64_t __odp_bitwise odp_u64le_t; -typedef uint64_t __odp_bitwise odp_u64be_t; - -typedef uint16_t __odp_bitwise odp_u16sum_t; -typedef uint32_t __odp_bitwise odp_u32sum_t; - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/api/plat/classification_types.h b/platform/linux-generic/include/odp/api/plat/classification_types.h deleted file mode 100644 index d210feb0c..000000000 --- a/platform/linux-generic/include/odp/api/plat/classification_types.h +++ /dev/null @@ -1,49 +0,0 @@ -/* Copyright (c) 2015, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP classification descriptor - */ - -#ifndef ODP_CLASSIFICATION_TYPES_H_ -#define ODP_CLASSIFICATION_TYPES_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <odp/api/plat/static_inline.h> -#if ODP_ABI_COMPAT == 1 -#include <odp/api/abi/classification.h> -#else - -#include <odp/api/plat/strong_types.h> - -/** @ingroup odp_classification - * @{ - */ - -typedef ODP_HANDLE_T(odp_cos_t); -#define ODP_COS_INVALID _odp_cast_scalar(odp_cos_t, ~0) - -typedef ODP_HANDLE_T(odp_pmr_t); -#define ODP_PMR_INVAL _odp_cast_scalar(odp_pmr_t, ~0) - -#define ODP_COS_NAME_LEN 32 - -/** - * @} - */ - -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/api/plat/cpu_inlines.h b/platform/linux-generic/include/odp/api/plat/cpu_inlines.h new file mode 100644 index 000000000..bb1b89154 --- /dev/null +++ b/platform/linux-generic/include/odp/api/plat/cpu_inlines.h @@ -0,0 +1,61 @@ +/* Copyright (c) 2018, Linaro Limited + * Copyright (c) 2021-2023, Nokia + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef ODP_PLAT_CPU_INLINES_H_ +#define ODP_PLAT_CPU_INLINES_H_ + +#include <odp/api/hints.h> + +#include <odp/api/abi/cpu_inlines.h> + +#include <stdint.h> + +/** @cond _ODP_HIDE_FROM_DOXYGEN_ */ + +#ifndef _ODP_NO_INLINE + /* Inline functions by default */ + #define _ODP_INLINE static inline + #define odp_cpu_pause __odp_cpu_pause + #define odp_cpu_cycles __odp_cpu_cycles + #define odp_cpu_cycles_max __odp_cpu_cycles_max + #define odp_cpu_cycles_resolution __odp_cpu_cycles_resolution + #define odp_cpu_cycles_diff __odp_cpu_cycles_diff +#else + #define _ODP_INLINE +#endif + +_ODP_INLINE void odp_cpu_pause(void) +{ + _odp_cpu_pause(); +} + +_ODP_INLINE uint64_t odp_cpu_cycles_max(void) +{ + return _odp_cpu_cycles_max(); +} + +_ODP_INLINE uint64_t odp_cpu_cycles_resolution(void) +{ + return _odp_cpu_cycles_resolution(); +} + +_ODP_INLINE uint64_t odp_cpu_cycles(void) +{ + return _odp_cpu_cycles(); +} + +_ODP_INLINE uint64_t odp_cpu_cycles_diff(uint64_t c2, uint64_t c1) +{ + if (odp_likely(c2 >= c1)) + return c2 - c1; + + return c2 + (odp_cpu_cycles_max() - c1) + _odp_cpu_cycles_resolution(); +} + +/** @endcond */ + +#endif diff --git a/platform/linux-generic/include/odp/api/plat/cpumask_types.h b/platform/linux-generic/include/odp/api/plat/cpumask_types.h deleted file mode 100644 index c2727a46c..000000000 --- a/platform/linux-generic/include/odp/api/plat/cpumask_types.h +++ /dev/null @@ -1,54 +0,0 @@ -/* Copyright (c) 2015, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - - -/** - * @file - * - * ODP CPU masks and enumeration - */ - -#ifndef ODP_CPUMASK_TYPES_H_ -#define ODP_CPUMASK_TYPES_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -/** @addtogroup odp_cpumask - * @{ - */ - -#include <odp/api/std_types.h> -#include <odp/api/align.h> - -#define ODP_CPUMASK_SIZE 1024 - -#define ODP_CPUMASK_STR_SIZE ((ODP_CPUMASK_SIZE + 3) / 4 + 3) - -/** - * CPU mask - * - * Don't access directly, use access functions. - */ -typedef struct odp_cpumask_t { - /** @private CPU mask storage - * - * This is private to the implementation. - * Don't access directly, use access functions. - */ - uint8_t _u8[ODP_CPUMASK_SIZE / 8]; -} odp_cpumask_t ODP_ALIGNED(8); - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/api/plat/crypto_inlines.h b/platform/linux-generic/include/odp/api/plat/crypto_inlines.h new file mode 100644 index 000000000..f350edfea --- /dev/null +++ b/platform/linux-generic/include/odp/api/plat/crypto_inlines.h @@ -0,0 +1,70 @@ +/* Copyright (c) 2022, Nokia + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef ODP_PLAT_CRYPTO_INLINES_H_ +#define ODP_PLAT_CRYPTO_INLINES_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include <odp/api/crypto_types.h> +#include <odp/api/event.h> +#include <odp/api/packet.h> + +#include <odp/api/plat/debug_inlines.h> +#include <odp/api/plat/packet_inline_types.h> + +/** @cond _ODP_HIDE_FROM_DOXYGEN_ */ + +#ifndef _ODP_NO_INLINE + /* Inline functions by default */ + #define _ODP_INLINE static inline + #define odp_crypto_packet_from_event __odp_crypto_packet_from_event + #define odp_crypto_packet_to_event __odp_crypto_packet_to_event + #define odp_crypto_result __odp_crypto_result +#else + #define _ODP_INLINE +#endif + +_ODP_INLINE odp_packet_t odp_crypto_packet_from_event(odp_event_t ev) +{ + _ODP_ASSERT(odp_event_type(ev) == ODP_EVENT_PACKET); + _ODP_ASSERT(odp_event_subtype(ev) == ODP_EVENT_PACKET_CRYPTO); + + return odp_packet_from_event(ev); +} + +_ODP_INLINE odp_event_t odp_crypto_packet_to_event(odp_packet_t pkt) +{ + return odp_packet_to_event(pkt); +} + +_ODP_INLINE int odp_crypto_result(odp_crypto_packet_result_t *result, odp_packet_t pkt) +{ + odp_crypto_packet_result_t *op_result; + odp_bool_t ok; + + _ODP_ASSERT(odp_packet_subtype(pkt) == ODP_EVENT_PACKET_CRYPTO); + + op_result = _odp_pkt_get_ptr(pkt, odp_crypto_packet_result_t, crypto_op); + + ok = op_result->cipher_status.alg_err == ODP_CRYPTO_ALG_ERR_NONE && + op_result->auth_status.alg_err == ODP_CRYPTO_ALG_ERR_NONE; + + if (result) + *result = *op_result; + + return ok ? 0 : -1; +} + +/** @endcond */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/platform/linux-generic/include/odp/api/plat/crypto_types.h b/platform/linux-generic/include/odp/api/plat/crypto_types.h deleted file mode 100644 index 2cc747eb2..000000000 --- a/platform/linux-generic/include/odp/api/plat/crypto_types.h +++ /dev/null @@ -1,45 +0,0 @@ -/* Copyright (c) 2015, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - - -/** - * @file - * - * ODP crypto - */ - -#ifndef ODP_CRYPTO_TYPES_H_ -#define ODP_CRYPTO_TYPES_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <odp/api/plat/static_inline.h> -#if ODP_ABI_COMPAT == 1 -#include <odp/api/abi/crypto.h> -#else - -/** @ingroup odp_crypto - * @{ - */ - -#define ODP_CRYPTO_SESSION_INVALID (0xffffffffffffffffULL) - -typedef uint64_t odp_crypto_session_t; -typedef ODP_HANDLE_T(odp_crypto_compl_t); - -/** - * @} - */ - -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/api/plat/debug_inlines.h b/platform/linux-generic/include/odp/api/plat/debug_inlines.h new file mode 100644 index 000000000..0755b1fda --- /dev/null +++ b/platform/linux-generic/include/odp/api/plat/debug_inlines.h @@ -0,0 +1,124 @@ +/* Copyright (c) 2014-2018, Linaro Limited + * Copyright (c) 2020-2023, Nokia + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @file + * + * ODP Debug inlines + * + * @warning These definitions are not part of ODP API, they are for + * implementation internal use only. + */ + +#ifndef ODP_DEBUG_INLINES_H_ +#define ODP_DEBUG_INLINES_H_ + +#include <odp/autoheader_external.h> + +#include <odp/api/hints.h> +#include <odp/api/init.h> + +#include <odp/api/plat/thread_inline_types.h> + +/** @cond _ODP_HIDE_FROM_DOXYGEN_ */ + +#ifdef __cplusplus +extern "C" { +#endif + +#pragma GCC diagnostic push + +#ifdef __clang__ +#pragma GCC diagnostic ignored "-Wgnu-zero-variadic-macro-arguments" +#endif + +extern odp_log_func_t ODP_PRINTF_FORMAT(2, 3) _odp_log_fn; +extern odp_abort_func_t _odp_abort_fn; + +#define _ODP_LOG_FN(level, ...) \ + do { \ + if (_odp_this_thread && _odp_this_thread->log_fn) \ + _odp_this_thread->log_fn(level, ##__VA_ARGS__); \ + else \ + _odp_log_fn(level, ##__VA_ARGS__); \ + } while (0) + +/** + * ODP LOG macro. + */ +#define _ODP_LOG(level, prefix, fmt, ...) \ + _ODP_LOG_FN(level, "%s: %s:%d:%s(): " fmt, prefix, \ + __FILE__, __LINE__, __func__, ##__VA_ARGS__) + +/** + * Runtime assertion-macro - aborts if 'cond' is false. + */ +#define _ODP_ASSERT(cond) \ + do { if ((ODP_DEBUG == 1) && (!(cond))) { \ + _ODP_ERR("%s\n", #cond); \ + _odp_abort_fn(); } \ + } while (0) + +/* + * Print debug message to log, if ODP_DEBUG_PRINT flag is set (ignores CONFIG_DEBUG_LEVEL). + */ +#define _ODP_DBG(...) \ + do { \ + if (ODP_DEBUG_PRINT == 1) \ + __extension__ ({ \ + _ODP_LOG(ODP_LOG_DBG, "DBG", ##__VA_ARGS__); \ + }); \ + } while (0) + +/** + * Log warning message. + */ +#define _ODP_WARN(...) \ + do { \ + __extension__ ({ \ + _ODP_LOG(ODP_LOG_WARN, "WARN", ##__VA_ARGS__); \ + }); \ + } while (0) + +/** + * Log error message. + */ +#define _ODP_ERR(...) \ + do { \ + __extension__ ({ \ + _ODP_LOG(ODP_LOG_ERR, "ERR", ##__VA_ARGS__); \ + }); \ + } while (0) + +/** + * Log abort message and then stop execution (by default call abort()). + * This function should not return. + */ +#define _ODP_ABORT(...) \ + do { \ + __extension__ ({ \ + _ODP_LOG(ODP_LOG_ABORT, "ABORT", ##__VA_ARGS__); \ + }); \ + _odp_abort_fn(); \ + } while (0) + +/** + * Log print message when the application calls one of the ODP APIs + * specifically for dumping internal data. + */ +#define _ODP_PRINT(...) \ + _ODP_LOG_FN(ODP_LOG_PRINT, ##__VA_ARGS__) + +#pragma GCC diagnostic pop + +#ifdef __cplusplus +} +#endif + +/** @endcond */ + +#endif diff --git a/platform/linux-generic/include/odp/api/plat/dma_inlines.h b/platform/linux-generic/include/odp/api/plat/dma_inlines.h new file mode 100644 index 000000000..84b5fef5b --- /dev/null +++ b/platform/linux-generic/include/odp/api/plat/dma_inlines.h @@ -0,0 +1,135 @@ +/* Copyright (c) 2023, Nokia + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef ODP_PLAT_DMA_INLINES_H_ +#define ODP_PLAT_DMA_INLINES_H_ + +#include <odp/api/buffer.h> +#include <odp/api/dma_types.h> +#include <odp/api/event_types.h> +#include <odp/api/hints.h> +#include <odp/api/pool_types.h> +#include <odp/api/queue_types.h> + +#include <odp/api/plat/debug_inlines.h> +#include <odp/api/plat/event_inline_types.h> + +#include <stdint.h> +#include <string.h> + +/** @cond _ODP_HIDE_FROM_DOXYGEN_ */ + +#ifndef _ODP_NO_INLINE + /* Inline functions by default */ + #define _ODP_INLINE static inline + #define odp_dma_compl_from_event __odp_dma_compl_from_event + #define odp_dma_compl_to_event __odp_dma_compl_to_event + #define odp_dma_compl_user_area __odp_dma_compl_user_area + #define odp_dma_compl_result __odp_dma_compl_result + #define odp_dma_transfer_param_init __odp_dma_transfer_param_init + #define odp_dma_compl_param_init __odp_dma_compl_param_init + #define odp_dma_compl_alloc __odp_dma_compl_alloc + #define odp_dma_compl_free __odp_dma_compl_free +#else + #define _ODP_INLINE +#endif + +_ODP_INLINE odp_dma_compl_t odp_dma_compl_from_event(odp_event_t ev) +{ + _ODP_ASSERT(_odp_event_hdr_field(ev, int8_t, event_type) == ODP_EVENT_DMA_COMPL); + + return (odp_dma_compl_t)(uintptr_t)ev; +} + +_ODP_INLINE odp_event_t odp_dma_compl_to_event(odp_dma_compl_t dma_compl) +{ + return (odp_event_t)(uintptr_t)dma_compl; +} + +_ODP_INLINE void *odp_dma_compl_user_area(odp_dma_compl_t dma_compl) +{ + return odp_buffer_user_area((odp_buffer_t)(uintptr_t)dma_compl); +} + +_ODP_INLINE int odp_dma_compl_result(odp_dma_compl_t dma_compl, odp_dma_result_t *result_out) +{ + odp_dma_result_t *result; + odp_buffer_t buf = (odp_buffer_t)(uintptr_t)dma_compl; + + if (odp_unlikely(dma_compl == ODP_DMA_COMPL_INVALID)) { + _ODP_ERR("Bad DMA compl handle\n"); + return -1; + } + + result = (odp_dma_result_t *)odp_buffer_addr(buf); + + if (result_out) + *result_out = *result; + + return result->success ? 0 : -1; +} + +_ODP_INLINE void odp_dma_transfer_param_init(odp_dma_transfer_param_t *trs_param) +{ + memset(trs_param, 0, sizeof(odp_dma_transfer_param_t)); + + trs_param->src_format = ODP_DMA_FORMAT_ADDR; + trs_param->dst_format = ODP_DMA_FORMAT_ADDR; + trs_param->num_src = 1; + trs_param->num_dst = 1; +} + +_ODP_INLINE void odp_dma_compl_param_init(odp_dma_compl_param_t *compl_param) +{ + memset(compl_param, 0, sizeof(odp_dma_compl_param_t)); + + compl_param->queue = ODP_QUEUE_INVALID; + compl_param->event = ODP_EVENT_INVALID; + compl_param->transfer_id = ODP_DMA_TRANSFER_ID_INVALID; +} + +_ODP_INLINE odp_dma_compl_t odp_dma_compl_alloc(odp_pool_t pool) +{ + odp_buffer_t buf; + odp_event_t ev; + odp_dma_result_t *result; + int8_t *ev_type; + + buf = odp_buffer_alloc(pool); + if (odp_unlikely(buf == ODP_BUFFER_INVALID)) + return ODP_DMA_COMPL_INVALID; + + result = (odp_dma_result_t *)odp_buffer_addr(buf); + memset(result, 0, sizeof(odp_dma_result_t)); + + ev = odp_buffer_to_event(buf); + ev_type = _odp_event_hdr_ptr(ev, int8_t, event_type); + *ev_type = ODP_EVENT_DMA_COMPL; + + return (odp_dma_compl_t)(uintptr_t)buf; +} + +_ODP_INLINE void odp_dma_compl_free(odp_dma_compl_t dma_compl) +{ + int8_t *ev_type; + odp_event_t ev; + odp_buffer_t buf = (odp_buffer_t)(uintptr_t)dma_compl; + + if (odp_unlikely(dma_compl == ODP_DMA_COMPL_INVALID)) { + _ODP_ERR("Bad DMA compl handle\n"); + return; + } + + ev = odp_buffer_to_event(buf); + ev_type = _odp_event_hdr_ptr(ev, int8_t, event_type); + *ev_type = ODP_EVENT_BUFFER; + + odp_buffer_free(buf); +} + +/** @endcond */ + +#endif diff --git a/platform/linux-generic/include/odp/api/plat/event_inline_types.h b/platform/linux-generic/include/odp/api/plat/event_inline_types.h new file mode 100644 index 000000000..cbf01588f --- /dev/null +++ b/platform/linux-generic/include/odp/api/plat/event_inline_types.h @@ -0,0 +1,45 @@ +/* Copyright (c) 2018, Linaro Limited + * Copyright (c) 2022, Nokia + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef ODP_PLAT_EVENT_INLINE_TYPES_H_ +#define ODP_PLAT_EVENT_INLINE_TYPES_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdint.h> + +/** @cond _ODP_HIDE_FROM_DOXYGEN_ */ + +/* Event header field accessors */ +#define _odp_event_hdr_field(event_hdr, cast, field) \ + (*(cast *)(uintptr_t)((uint8_t *)event_hdr + \ + _odp_event_inline_offset.field)) +#define _odp_event_hdr_ptr(event_hdr, cast, field) \ + ((cast *)(uintptr_t)((uint8_t *)event_hdr + \ + _odp_event_inline_offset.field)) + +/* Event header field offsets for inline functions */ +typedef struct _odp_event_inline_offset_t { + uint16_t event_type; + uint16_t base_data; + uint16_t subtype; + uint16_t flow_id; + uint16_t pool; + +} _odp_event_inline_offset_t; + +extern const _odp_event_inline_offset_t _odp_event_inline_offset; + +/** @endcond */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/platform/linux-generic/include/odp/api/plat/event_inlines.h b/platform/linux-generic/include/odp/api/plat/event_inlines.h new file mode 100644 index 000000000..990575166 --- /dev/null +++ b/platform/linux-generic/include/odp/api/plat/event_inlines.h @@ -0,0 +1,199 @@ +/* Copyright (c) 2018, Linaro Limited + * Copyright (c) 2022-2023, Nokia + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef ODP_PLAT_EVENT_INLINES_H_ +#define ODP_PLAT_EVENT_INLINES_H_ + +#include <odp/api/buffer_types.h> +#include <odp/api/event_types.h> +#include <odp/api/packet_types.h> +#include <odp/api/pool_types.h> +#include <odp/api/timer_types.h> + +#include <odp/api/plat/buffer_inline_types.h> +#include <odp/api/plat/debug_inlines.h> +#include <odp/api/plat/event_inline_types.h> +#include <odp/api/plat/event_vector_inline_types.h> +#include <odp/api/plat/packet_inline_types.h> +#include <odp/api/plat/timer_inline_types.h> + +/** @cond _ODP_HIDE_FROM_DOXYGEN_ */ + +#ifndef _ODP_NO_INLINE + /* Inline functions by default */ + #define _ODP_INLINE static inline + #define odp_event_type __odp_event_type + #define odp_event_type_multi __odp_event_type_multi + #define odp_event_pool __odp_event_pool + #define odp_event_user_area __odp_event_user_area + #define odp_event_user_area_and_flag __odp_event_user_area_and_flag + #define odp_event_subtype __odp_event_subtype + #define odp_event_types __odp_event_types + #define odp_event_types_multi __odp_event_types_multi + #define odp_event_flow_id __odp_event_flow_id + #define odp_event_flow_id_set __odp_event_flow_id_set +#else + #define _ODP_INLINE +#endif + +static inline odp_event_type_t __odp_event_type_get(odp_event_t event) +{ + int8_t type; + + type = _odp_event_hdr_field(event, int8_t, event_type); + + return (odp_event_type_t)type; +} + +static inline odp_event_subtype_t __odp_event_subtype_get(odp_event_t event) +{ + int8_t type; + + type = _odp_event_hdr_field(event, int8_t, subtype); + + return (odp_event_subtype_t)type; +} + +_ODP_INLINE odp_event_type_t odp_event_type(odp_event_t event) +{ + return __odp_event_type_get(event); +} + +_ODP_INLINE int odp_event_type_multi(const odp_event_t event[], int num, + odp_event_type_t *type_out) +{ + int i; + odp_event_type_t type = __odp_event_type_get(event[0]); + + for (i = 1; i < num; i++) { + if (__odp_event_type_get(event[i]) != type) + break; + } + + *type_out = type; + + return i; +} + +_ODP_INLINE odp_pool_t odp_event_pool(odp_event_t event) +{ + const odp_event_type_t type = __odp_event_type_get(event); + + switch (type) { + case ODP_EVENT_BUFFER: + case ODP_EVENT_PACKET: + case ODP_EVENT_PACKET_VECTOR: + return _odp_event_hdr_field(event, odp_pool_t, pool); + default: + return ODP_POOL_INVALID; + } +} + +_ODP_INLINE void *odp_event_user_area(odp_event_t event) +{ + const odp_event_type_t type = __odp_event_type_get(event); + + switch (type) { + case ODP_EVENT_BUFFER: + case ODP_EVENT_ML_COMPL: + case ODP_EVENT_DMA_COMPL: + return _odp_buffer_get((odp_buffer_t)event, void *, uarea_addr); + case ODP_EVENT_PACKET: + return _odp_pkt_get((odp_packet_t)event, void *, user_area); + case ODP_EVENT_PACKET_VECTOR: + return _odp_event_vect_get((odp_packet_vector_t)event, void *, uarea_addr); + case ODP_EVENT_TIMEOUT: + return _odp_timeout_hdr_field((odp_timeout_t)event, void *, uarea_addr); + default: + return NULL; + } +} + +_ODP_INLINE void *odp_event_user_area_and_flag(odp_event_t event, int *flag) +{ + const odp_event_type_t type = __odp_event_type_get(event); + + _ODP_ASSERT(flag != NULL); + + switch (type) { + case ODP_EVENT_BUFFER: + case ODP_EVENT_DMA_COMPL: + case ODP_EVENT_ML_COMPL: + *flag = -1; + return _odp_buffer_get((odp_buffer_t)event, void *, uarea_addr); + case ODP_EVENT_PACKET: + { + _odp_packet_flags_t pkt_flags; + odp_packet_t pkt = (odp_packet_t)event; + + pkt_flags.all_flags = _odp_pkt_get(pkt, uint32_t, flags); + *flag = pkt_flags.user_flag; + + return _odp_pkt_get(pkt, void *, user_area); + } + case ODP_EVENT_PACKET_VECTOR: + { + _odp_event_vector_flags_t pktv_flags; + odp_packet_vector_t pktv = (odp_packet_vector_t)event; + + pktv_flags.all_flags = _odp_event_vect_get(pktv, uint32_t, flags); + *flag = pktv_flags.user_flag; + + return _odp_event_vect_get(pktv, void *, uarea_addr); + } + case ODP_EVENT_TIMEOUT: + *flag = -1; + return _odp_timeout_hdr_field((odp_timeout_t)event, void *, uarea_addr); + default: + *flag = -1; + return NULL; + } +} + +_ODP_INLINE odp_event_subtype_t odp_event_subtype(odp_event_t event) +{ + return __odp_event_subtype_get(event); +} + +_ODP_INLINE odp_event_type_t odp_event_types(odp_event_t event, + odp_event_subtype_t *subtype) +{ + odp_event_type_t event_type = __odp_event_type_get(event); + + *subtype = __odp_event_subtype_get(event); + + return event_type; +} + +_ODP_INLINE void odp_event_types_multi(const odp_event_t event[], odp_event_type_t type[], + odp_event_subtype_t subtype[], int num) +{ + for (int i = 0; i < num; i++) + type[i] = __odp_event_type_get(event[i]); + + if (subtype == NULL) + return; + + for (int i = 0; i < num; i++) + subtype[i] = __odp_event_subtype_get(event[i]); +} + +_ODP_INLINE uint32_t odp_event_flow_id(odp_event_t event) +{ + return _odp_event_hdr_field(event, uint8_t, flow_id); +} + +_ODP_INLINE void odp_event_flow_id_set(odp_event_t event, uint32_t id) +{ + uint8_t *flow_id = _odp_event_hdr_ptr(event, uint8_t, flow_id); + + *flow_id = (uint8_t)id; +} + +/** @endcond */ + +#endif diff --git a/platform/linux-generic/include/odp/api/plat/event_types.h b/platform/linux-generic/include/odp/api/plat/event_types.h deleted file mode 100644 index a1aa0e452..000000000 --- a/platform/linux-generic/include/odp/api/plat/event_types.h +++ /dev/null @@ -1,54 +0,0 @@ -/* Copyright (c) 2015, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - - -/** - * @file - * - * ODP event - */ - -#ifndef ODP_EVENT_TYPES_H_ -#define ODP_EVENT_TYPES_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <odp/api/plat/static_inline.h> -#if ODP_ABI_COMPAT == 1 -#include <odp/api/abi/event.h> -#else - -#include <odp/api/std_types.h> -#include <odp/api/plat/strong_types.h> - -/** @ingroup odp_event - * @{ - */ - -typedef ODP_HANDLE_T(odp_event_t); - -#define ODP_EVENT_INVALID _odp_cast_scalar(odp_event_t, 0xffffffff) - -typedef enum odp_event_type_t { - ODP_EVENT_BUFFER = 1, - ODP_EVENT_PACKET = 2, - ODP_EVENT_TIMEOUT = 3, - ODP_EVENT_CRYPTO_COMPL = 4, -} odp_event_type_t; - -/** - * @} - */ - -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/api/plat/event_validation_external.h b/platform/linux-generic/include/odp/api/plat/event_validation_external.h new file mode 100644 index 000000000..7f5c0364f --- /dev/null +++ b/platform/linux-generic/include/odp/api/plat/event_validation_external.h @@ -0,0 +1,111 @@ +/* Copyright (c) 2023, Nokia + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @file + * + * ODP event validation + * + * @warning These definitions are not part of ODP API, they are for + * implementation internal use only. + */ + +#ifndef ODP_EVENT_VALIDATION_EXTERNAL_H_ +#define ODP_EVENT_VALIDATION_EXTERNAL_H_ + +#include <odp/autoheader_external.h> + +#include <odp/api/buffer_types.h> +#include <odp/api/event_types.h> +#include <odp/api/hints.h> +#include <odp/api/packet_types.h> + +/** @cond _ODP_HIDE_FROM_DOXYGEN_ */ + +#ifdef __cplusplus +extern "C" { +#endif + +/** Enumerations for identifying ODP API functions */ +typedef enum { + _ODP_EV_BUFFER_FREE = 0, + _ODP_EV_BUFFER_FREE_MULTI, + _ODP_EV_BUFFER_IS_VALID, + _ODP_EV_EVENT_FREE, + _ODP_EV_EVENT_FREE_MULTI, + _ODP_EV_EVENT_FREE_SP, + _ODP_EV_EVENT_IS_VALID, + _ODP_EV_PACKET_FREE, + _ODP_EV_PACKET_FREE_MULTI, + _ODP_EV_PACKET_FREE_SP, + _ODP_EV_PACKET_IS_VALID, + _ODP_EV_QUEUE_ENQ, + _ODP_EV_QUEUE_ENQ_MULTI, + _ODP_EV_MAX +} _odp_ev_id_t; + +/* Implementation internal event validation functions */ +#if _ODP_EVENT_VALIDATION + +int _odp_event_validate(odp_event_t event, _odp_ev_id_t id); + +int _odp_event_validate_multi(const odp_event_t event[], int num, _odp_ev_id_t id); + +int _odp_buffer_validate(odp_buffer_t buf, _odp_ev_id_t ev_id); + +int _odp_buffer_validate_multi(const odp_buffer_t buf[], int num, _odp_ev_id_t ev_id); + +int _odp_packet_validate(odp_packet_t pkt, _odp_ev_id_t ev_id); + +int _odp_packet_validate_multi(const odp_packet_t pkt[], int num, _odp_ev_id_t ev_id); + +#else + +static inline int _odp_event_validate(odp_event_t event ODP_UNUSED, _odp_ev_id_t ev_id ODP_UNUSED) +{ + return 0; +} + +static inline int _odp_event_validate_multi(const odp_event_t event[] ODP_UNUSED, + int num ODP_UNUSED, + _odp_ev_id_t ev_id ODP_UNUSED) +{ + return 0; +} + +static inline int _odp_buffer_validate(odp_buffer_t buf ODP_UNUSED, _odp_ev_id_t ev_id ODP_UNUSED) +{ + return 0; +} + +static inline int _odp_buffer_validate_multi(const odp_buffer_t buf[] ODP_UNUSED, + int num ODP_UNUSED, + _odp_ev_id_t ev_id ODP_UNUSED) +{ + return 0; +} + +static inline int _odp_packet_validate(odp_packet_t pkt ODP_UNUSED, _odp_ev_id_t ev_id ODP_UNUSED) +{ + return 0; +} + +static inline int _odp_packet_validate_multi(const odp_packet_t pkt[] ODP_UNUSED, + int num ODP_UNUSED, + _odp_ev_id_t ev_id ODP_UNUSED) +{ + return 0; +} + +#endif /* _ODP_EVENT_VALIDATION */ + +#ifdef __cplusplus +} +#endif + +/** @endcond */ + +#endif diff --git a/platform/linux-generic/include/odp/api/plat/event_vector_inline_types.h b/platform/linux-generic/include/odp/api/plat/event_vector_inline_types.h new file mode 100644 index 000000000..773f5171c --- /dev/null +++ b/platform/linux-generic/include/odp/api/plat/event_vector_inline_types.h @@ -0,0 +1,51 @@ +/* Copyright (c) 2020, Nokia + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef ODP_PLAT_EVENT_VECTOR_INLINE_TYPES_H_ +#define ODP_PLAT_EVENT_VECTOR_INLINE_TYPES_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdint.h> + +/** @cond _ODP_HIDE_FROM_DOXYGEN_ */ + +typedef union { + uint32_t all_flags; + + struct { + uint32_t user_flag : 1; + }; + +} _odp_event_vector_flags_t; + +/* Event vector field accessors */ +#define _odp_event_vect_get(vect, cast, field) \ + (*(cast *)(uintptr_t)((uint8_t *)vect + _odp_event_vector_inline.field)) +#define _odp_event_vect_get_ptr(vect, cast, field) \ + ((cast *)(uintptr_t)((uint8_t *)vect + _odp_event_vector_inline.field)) + +/* Event vector header field offsets for inline functions */ +typedef struct _odp_event_vector_inline_offset_t { + uint16_t packet; + uint16_t pool; + uint16_t size; + uint16_t uarea_addr; + uint16_t flags; + +} _odp_event_vector_inline_offset_t; + +extern const _odp_event_vector_inline_offset_t _odp_event_vector_inline; + +/** @endcond */ + +#ifdef __cplusplus +} +#endif + +#endif /* ODP_PLAT_EVENT_VECTOR_INLINE_TYPES_H_ */ diff --git a/platform/linux-generic/include/odp/api/plat/hash_inlines.h b/platform/linux-generic/include/odp/api/plat/hash_inlines.h new file mode 100644 index 000000000..b38a34d53 --- /dev/null +++ b/platform/linux-generic/include/odp/api/plat/hash_inlines.h @@ -0,0 +1,47 @@ +/* Copyright (c) 2021, Nokia + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef ODP_PLAT_HASH_INLINES_H_ +#define ODP_PLAT_HASH_INLINES_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include <odp/api/abi/hash_crc32.h> + +#include <stdint.h> + +/** @cond _ODP_HIDE_FROM_DOXYGEN_ */ + +#ifndef _ODP_NO_INLINE + /* Inline functions by default */ + #define _ODP_INLINE static inline + #define odp_hash_crc32 __odp_hash_crc32 + #define odp_hash_crc32c __odp_hash_crc32c +#else + #define _ODP_INLINE +#endif + +_ODP_INLINE uint32_t odp_hash_crc32(const void *data, uint32_t data_len, + uint32_t init_val) +{ + return _odp_hash_crc32(data, data_len, init_val); +} + +_ODP_INLINE uint32_t odp_hash_crc32c(const void *data, uint32_t data_len, + uint32_t init_val) +{ + return _odp_hash_crc32c(data, data_len, init_val); +} + +/** @endcond */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/platform/linux-generic/include/odp/api/plat/init_types.h b/platform/linux-generic/include/odp/api/plat/init_types.h deleted file mode 100644 index 888b04a70..000000000 --- a/platform/linux-generic/include/odp/api/plat/init_types.h +++ /dev/null @@ -1,35 +0,0 @@ -/* Copyright (c) 2015, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP initialization. - */ - -#ifndef ODP_INIT_TYPES_H_ -#define ODP_INIT_TYPES_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <odp/api/std_types.h> - -typedef uint64_t odp_instance_t; - -/** - * @internal platform specific data - */ -typedef struct odp_platform_init_t { - int ipc_ns; /**< Name space for ipc shared objects. */ -} odp_platform_init_t; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/api/plat/ipsec_inlines.h b/platform/linux-generic/include/odp/api/plat/ipsec_inlines.h new file mode 100644 index 000000000..1d1f6ec61 --- /dev/null +++ b/platform/linux-generic/include/odp/api/plat/ipsec_inlines.h @@ -0,0 +1,58 @@ +/* Copyright (c) 2022, Nokia + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef ODP_PLAT_IPSEC_INLINES_H_ +#define ODP_PLAT_IPSEC_INLINES_H_ + +#include <odp/api/event.h> +#include <odp/api/ipsec_types.h> +#include <odp/api/packet.h> + +#include <odp/api/plat/debug_inlines.h> +#include <odp/api/plat/packet_inline_types.h> + +/** @cond _ODP_HIDE_FROM_DOXYGEN_ */ + +#ifndef _ODP_NO_INLINE + /* Inline functions by default */ + #define _ODP_INLINE static inline + #define odp_ipsec_packet_from_event __odp_ipsec_packet_from_event + #define odp_ipsec_packet_to_event __odp_ipsec_packet_to_event + #define odp_ipsec_result __odp_ipsec_result +#else + #define _ODP_INLINE +#endif + +_ODP_INLINE odp_packet_t odp_ipsec_packet_from_event(odp_event_t ev) +{ + _ODP_ASSERT(odp_event_type(ev) == ODP_EVENT_PACKET); + _ODP_ASSERT(odp_event_subtype(ev) == ODP_EVENT_PACKET_IPSEC); + + return odp_packet_from_event(ev); +} + +_ODP_INLINE odp_event_t odp_ipsec_packet_to_event(odp_packet_t pkt) +{ + return odp_packet_to_event(pkt); +} + +_ODP_INLINE int odp_ipsec_result(odp_ipsec_packet_result_t *result, odp_packet_t pkt) +{ + odp_ipsec_packet_result_t *res; + + _ODP_ASSERT(result != NULL); + _ODP_ASSERT(odp_packet_subtype(pkt) == ODP_EVENT_PACKET_IPSEC); + + res = _odp_pkt_get_ptr(pkt, odp_ipsec_packet_result_t, ipsec_ctx); + + *result = *res; + + return 0; +} + +/** @endcond */ + +#endif 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 index 2de04c814..9330d89f8 100644 --- a/platform/linux-generic/include/odp/api/plat/packet_flag_inlines.h +++ b/platform/linux-generic/include/odp/api/plat/packet_flag_inlines.h @@ -1,4 +1,5 @@ -/* Copyright (c) 2017, Linaro Limited +/* Copyright (c) 2017-2018, Linaro Limited + * Copyright (c) 2022, Nokia * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -13,21 +14,53 @@ #ifndef _ODP_PLAT_PACKET_FLAG_INLINES_H_ #define _ODP_PLAT_PACKET_FLAG_INLINES_H_ -#include <odp/api/plat/packet_types.h> +#include <odp/api/abi/packet_types.h> +#include <odp/api/plat/packet_inline_types.h> #include <odp/api/hints.h> -/** @internal Inline function offsets */ -extern const _odp_packet_inline_offset_t _odp_packet_inline; +/** @cond _ODP_HIDE_FROM_DOXYGEN_ */ -/** @internal Inline function @param pkt @return */ static inline uint64_t _odp_packet_input_flags(odp_packet_t pkt) { - return *(uint64_t *)(uintptr_t)((uint8_t *)pkt + - _odp_packet_inline.input_flags); + 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) +#ifndef _ODP_NO_INLINE + /* Inline functions by default */ + #define _ODP_INLINE static inline + #define odp_packet_has_l2 __odp_packet_has_l2 + #define odp_packet_has_l3 __odp_packet_has_l3 + #define odp_packet_has_l4 __odp_packet_has_l4 + #define odp_packet_has_eth __odp_packet_has_eth + #define odp_packet_has_jumbo __odp_packet_has_jumbo + #define odp_packet_has_flow_hash __odp_packet_has_flow_hash + #define odp_packet_has_ts __odp_packet_has_ts + #define odp_packet_has_ipsec __odp_packet_has_ipsec + #define odp_packet_has_eth_bcast __odp_packet_has_eth_bcast + #define odp_packet_has_eth_mcast __odp_packet_has_eth_mcast + #define odp_packet_has_vlan __odp_packet_has_vlan + #define odp_packet_has_vlan_qinq __odp_packet_has_vlan_qinq + #define odp_packet_has_arp __odp_packet_has_arp + #define odp_packet_has_ipv4 __odp_packet_has_ipv4 + #define odp_packet_has_ipv6 __odp_packet_has_ipv6 + #define odp_packet_has_ip_bcast __odp_packet_has_ip_bcast + #define odp_packet_has_ip_mcast __odp_packet_has_ip_mcast + #define odp_packet_has_ipfrag __odp_packet_has_ipfrag + #define odp_packet_has_ipopt __odp_packet_has_ipopt + #define odp_packet_has_udp __odp_packet_has_udp + #define odp_packet_has_tcp __odp_packet_has_tcp + #define odp_packet_has_sctp __odp_packet_has_sctp + #define odp_packet_has_icmp __odp_packet_has_icmp + #define odp_packet_has_error __odp_packet_has_error + #define odp_packet_has_l2_error __odp_packet_has_l2_error + #define odp_packet_has_l3_error __odp_packet_has_l3_error + #define odp_packet_has_l4_error __odp_packet_has_l4_error +#else + #undef _ODP_INLINE + #define _ODP_INLINE +#endif + +_ODP_INLINE int odp_packet_has_l2(odp_packet_t pkt) { _odp_packet_input_flags_t flags; @@ -35,8 +68,23 @@ static inline int _odp_packet_has_l2(odp_packet_t pkt) return flags.l2; } -/** @internal Inline function @param pkt @return */ -static inline int _odp_packet_has_eth(odp_packet_t pkt) +_ODP_INLINE int odp_packet_has_l3(odp_packet_t pkt) +{ + _odp_packet_input_flags_t flags; + + flags.all = _odp_packet_input_flags(pkt); + return flags.l3; +} + +_ODP_INLINE int odp_packet_has_l4(odp_packet_t pkt) +{ + _odp_packet_input_flags_t flags; + + flags.all = _odp_packet_input_flags(pkt); + return flags.l4; +} + +_ODP_INLINE int odp_packet_has_eth(odp_packet_t pkt) { _odp_packet_input_flags_t flags; @@ -44,8 +92,7 @@ static inline int _odp_packet_has_eth(odp_packet_t pkt) return flags.eth; } -/** @internal Inline function @param pkt @return */ -static inline int _odp_packet_has_jumbo(odp_packet_t pkt) +_ODP_INLINE int odp_packet_has_jumbo(odp_packet_t pkt) { _odp_packet_input_flags_t flags; @@ -53,8 +100,7 @@ static inline int _odp_packet_has_jumbo(odp_packet_t pkt) return flags.jumbo; } -/** @internal Inline function @param pkt @return */ -static inline int _odp_packet_has_flow_hash(odp_packet_t pkt) +_ODP_INLINE int odp_packet_has_flow_hash(odp_packet_t pkt) { _odp_packet_input_flags_t flags; @@ -62,8 +108,7 @@ static inline int _odp_packet_has_flow_hash(odp_packet_t pkt) return flags.flow_hash; } -/** @internal Inline function @param pkt @return */ -static inline int _odp_packet_has_ts(odp_packet_t pkt) +_ODP_INLINE int odp_packet_has_ts(odp_packet_t pkt) { _odp_packet_input_flags_t flags; @@ -71,20 +116,171 @@ static inline int _odp_packet_has_ts(odp_packet_t pkt) return flags.timestamp; } -/* Include inlined versions of API functions */ -#include <odp/api/plat/static_inline.h> -#if ODP_ABI_COMPAT == 0 +_ODP_INLINE int odp_packet_has_ipsec(odp_packet_t pkt) +{ + _odp_packet_input_flags_t flags; -/** @ingroup odp_packet - * @{ - */ + flags.all = _odp_packet_input_flags(pkt); + return flags.ipsec; +} -#include <odp/api/plat/packet_flag_inlines_api.h> +_ODP_INLINE int odp_packet_has_eth_bcast(odp_packet_t pkt) +{ + _odp_packet_input_flags_t flags; -/** - * @} - */ + flags.all = _odp_packet_input_flags(pkt); + return flags.eth_bcast; +} -#endif +_ODP_INLINE int odp_packet_has_eth_mcast(odp_packet_t pkt) +{ + _odp_packet_input_flags_t flags; + + flags.all = _odp_packet_input_flags(pkt); + return flags.eth_mcast; +} + +_ODP_INLINE int odp_packet_has_vlan(odp_packet_t pkt) +{ + _odp_packet_input_flags_t flags; + + flags.all = _odp_packet_input_flags(pkt); + return flags.vlan; +} + +_ODP_INLINE int odp_packet_has_vlan_qinq(odp_packet_t pkt) +{ + _odp_packet_input_flags_t flags; + + flags.all = _odp_packet_input_flags(pkt); + return flags.vlan_qinq; +} + +_ODP_INLINE int odp_packet_has_arp(odp_packet_t pkt) +{ + _odp_packet_input_flags_t flags; + + flags.all = _odp_packet_input_flags(pkt); + return flags.arp; +} + +_ODP_INLINE int odp_packet_has_ipv4(odp_packet_t pkt) +{ + _odp_packet_input_flags_t flags; + + flags.all = _odp_packet_input_flags(pkt); + return flags.ipv4; +} + +_ODP_INLINE int odp_packet_has_ipv6(odp_packet_t pkt) +{ + _odp_packet_input_flags_t flags; + + flags.all = _odp_packet_input_flags(pkt); + return flags.ipv6; +} + +_ODP_INLINE int odp_packet_has_ip_bcast(odp_packet_t pkt) +{ + _odp_packet_input_flags_t flags; + + flags.all = _odp_packet_input_flags(pkt); + return flags.ip_bcast; +} + +_ODP_INLINE int odp_packet_has_ip_mcast(odp_packet_t pkt) +{ + _odp_packet_input_flags_t flags; + + flags.all = _odp_packet_input_flags(pkt); + return flags.ip_mcast; +} + +_ODP_INLINE int odp_packet_has_ipfrag(odp_packet_t pkt) +{ + _odp_packet_input_flags_t flags; + + flags.all = _odp_packet_input_flags(pkt); + return flags.ipfrag; +} + +_ODP_INLINE int odp_packet_has_ipopt(odp_packet_t pkt) +{ + _odp_packet_input_flags_t flags; + + flags.all = _odp_packet_input_flags(pkt); + return flags.ipopt; +} + +_ODP_INLINE int odp_packet_has_udp(odp_packet_t pkt) +{ + _odp_packet_input_flags_t flags; + + flags.all = _odp_packet_input_flags(pkt); + return flags.udp; +} + +_ODP_INLINE int odp_packet_has_tcp(odp_packet_t pkt) +{ + _odp_packet_input_flags_t flags; + + flags.all = _odp_packet_input_flags(pkt); + return flags.tcp; +} + +_ODP_INLINE int odp_packet_has_sctp(odp_packet_t pkt) +{ + _odp_packet_input_flags_t flags; + + flags.all = _odp_packet_input_flags(pkt); + return flags.sctp; +} + +_ODP_INLINE int odp_packet_has_icmp(odp_packet_t pkt) +{ + _odp_packet_input_flags_t flags; + + flags.all = _odp_packet_input_flags(pkt); + return flags.icmp; +} + +_ODP_INLINE int odp_packet_has_error(odp_packet_t pkt) +{ + _odp_packet_flags_t flags; + + flags.all_flags = _odp_pkt_get(pkt, uint32_t, flags); + return flags.all.error != 0; +} + +_ODP_INLINE int odp_packet_has_l2_error(odp_packet_t pkt) +{ + _odp_packet_flags_t flags; + + flags.all_flags = _odp_pkt_get(pkt, uint32_t, flags); + + /* L2 parsing is always done by default and hence + no additional check is required. */ + return flags.snap_len_err; +} + +_ODP_INLINE int odp_packet_has_l3_error(odp_packet_t pkt) +{ + _odp_packet_flags_t flags; + + flags.all_flags = _odp_pkt_get(pkt, uint32_t, flags); + + return flags.ip_err; +} + +_ODP_INLINE int odp_packet_has_l4_error(odp_packet_t pkt) +{ + _odp_packet_flags_t flags; + + flags.all_flags = _odp_pkt_get(pkt, uint32_t, flags); + + return flags.tcp_err | flags.udp_err; +} + +/** @endcond */ #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 deleted file mode 100644 index f4e143aa0..000000000 --- a/platform/linux-generic/include/odp/api/plat/packet_flag_inlines_api.h +++ /dev/null @@ -1,41 +0,0 @@ -/* 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_inline_types.h b/platform/linux-generic/include/odp/api/plat/packet_inline_types.h new file mode 100644 index 000000000..691965624 --- /dev/null +++ b/platform/linux-generic/include/odp/api/plat/packet_inline_types.h @@ -0,0 +1,176 @@ +/* Copyright (c) 2015-2018, Linaro Limited + * Copyright (c) 2019-2022, Nokia + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + + +/** + * @file + * + * ODP packet descriptor + */ + +#ifndef ODP_PACKET_INLINE_TYPES_H_ +#define ODP_PACKET_INLINE_TYPES_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdint.h> + +/** @cond _ODP_HIDE_FROM_DOXYGEN_ */ + +/* Packet field accessor */ +#define _odp_pkt_get(pkt, cast, field) \ + (*(cast *)(uintptr_t)((uint8_t *)pkt + _odp_packet_inline.field)) + +#define _odp_pkt_get_ptr(pkt, cast, field) \ + ((cast *)(uintptr_t)((uint8_t *)pkt + _odp_packet_inline.field)) + +/* Packet header field offsets for inline functions */ +typedef struct _odp_packet_inline_offset_t { + uint16_t seg_data; + uint16_t seg_len; + uint16_t seg_next; + uint16_t frame_len; + uint16_t headroom; + uint16_t tailroom; + uint16_t pool; + uint16_t input; + uint16_t seg_count; + uint16_t user_ptr; + uint16_t user_area; + uint16_t l2_offset; + uint16_t l3_offset; + uint16_t l4_offset; + uint16_t flow_hash; + uint16_t timestamp; + uint16_t input_flags; + uint16_t flags; + uint16_t cls_mark; + uint16_t ipsec_ctx; + uint16_t crypto_op; + +} _odp_packet_inline_offset_t; + +extern const _odp_packet_inline_offset_t _odp_packet_inline; + +/* Packet input & protocol flags */ +typedef union { + /* All input flags */ + uint64_t all; + + /* Individual input flags */ + struct { + uint64_t dst_queue:1; /* Dst queue present */ + uint64_t cls_mark: 1; /* Classifier mark value 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 sctp:1; /* SCTP */ + uint64_t icmp:1; /* ICMP */ + uint64_t no_next_hdr:1; /* No Next Header */ + + uint64_t color:2; /* Packet color for traffic mgmt */ + uint64_t nodrop:1; /* Drop eligibility status */ + + uint64_t l3_chksum_done:1; /* L3 checksum validation done */ + uint64_t l4_chksum_done:1; /* L4 checksum validation done */ + uint64_t ipsec_udp:1; /* UDP-encapsulated IPsec packet */ + uint64_t udp_chksum_zero:1; /* UDP header had 0 as chksum */ + }; + +} _odp_packet_input_flags_t; + +/* + * Additional packet flags + */ +typedef union { + /* All flags */ + uint32_t all_flags; + + struct { + uint32_t reserved1: 4; + + /* + * Init flags + */ + uint32_t user_ptr_set: 1; /* User has set a non-NULL value */ + uint32_t user_flag: 1; + + /* + * Packet output flags + */ + uint32_t lso: 1; /* LSO requested */ + uint32_t payload_off: 1; /* Payload offset is valid */ + uint32_t l3_chksum_set: 1; /* L3 chksum bit is valid */ + uint32_t l3_chksum: 1; /* L3 chksum override */ + uint32_t l4_chksum_set: 1; /* L4 chksum bit is valid */ + uint32_t l4_chksum: 1; /* L4 chksum override */ + uint32_t ts_set: 1; /* Set Tx timestamp */ + uint32_t tx_compl_ev: 1; /* Tx completion event requested */ + uint32_t tx_compl_poll: 1; /* Tx completion poll requested */ + uint32_t free_ctrl: 1; /* Don't free option */ + uint32_t tx_aging: 1; /* Packet aging at Tx requested */ + uint32_t shaper_len_adj: 8; /* Adjustment for traffic mgr */ + + /* + * Error flags + */ + uint32_t snap_len_err: 1; /* Snap length error */ + uint32_t ip_err: 1; /* IP error */ + uint32_t l3_chksum_err: 1; /* L3 checksum error */ + uint32_t tcp_err: 1; /* TCP error */ + uint32_t udp_err: 1; /* UDP error */ + uint32_t sctp_err: 1; /* SCTP error */ + uint32_t l4_chksum_err: 1; /* L4 checksum error */ + }; + + /* Flag groups */ + struct { + uint32_t reserved2: 4; + uint32_t other: 21; /* All other flags */ + uint32_t error: 7; /* All error flags */ + } all; + +} _odp_packet_flags_t; + +/** @endcond */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/platform/linux-generic/include/odp/api/plat/packet_inlines.h b/platform/linux-generic/include/odp/api/plat/packet_inlines.h index 3dd643fe2..2dd74fa29 100644 --- a/platform/linux-generic/include/odp/api/plat/packet_inlines.h +++ b/platform/linux-generic/include/odp/api/plat/packet_inlines.h @@ -1,4 +1,5 @@ -/* Copyright (c) 2017, Linaro Limited +/* Copyright (c) 2017-2018, Linaro Limited + * Copyright (c) 2019-2022, Nokia * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -13,176 +14,671 @@ #ifndef _ODP_PLAT_PACKET_INLINES_H_ #define _ODP_PLAT_PACKET_INLINES_H_ -#include <odp/api/plat/packet_types.h> -#include <odp/api/pool.h> -#include <odp/api/packet_io.h> +#include <odp/api/event.h> #include <odp/api/hints.h> +#include <odp/api/packet_types.h> +#include <odp/api/pool_types.h> +#include <odp/api/time_types.h> + +#include <odp/api/plat/debug_inlines.h> +#include <odp/api/plat/packet_io_inlines.h> +#include <odp/api/plat/packet_inline_types.h> +#include <odp/api/plat/pool_inline_types.h> +#include <odp/api/plat/event_inline_types.h> + +#include <stdint.h> +#include <string.h> + +/** @cond _ODP_HIDE_FROM_DOXYGEN_ */ + +#ifndef _ODP_NO_INLINE + /* Inline functions by default */ + #define _ODP_INLINE static inline + #define odp_packet_data __odp_packet_data + #define odp_packet_seg_len __odp_packet_seg_len + #define odp_packet_data_seg_len __odp_packet_data_seg_len + #define odp_packet_len __odp_packet_len + #define odp_packet_headroom __odp_packet_headroom + #define odp_packet_tailroom __odp_packet_tailroom + #define odp_packet_pool __odp_packet_pool + #define odp_packet_input __odp_packet_input + #define odp_packet_input_set __odp_packet_input_set + #define odp_packet_input_index __odp_packet_input_index + #define odp_packet_num_segs __odp_packet_num_segs + #define odp_packet_user_ptr __odp_packet_user_ptr + #define odp_packet_user_ptr_set __odp_packet_user_ptr_set + #define odp_packet_user_area __odp_packet_user_area + #define odp_packet_user_area_size __odp_packet_user_area_size + #define odp_packet_user_flag __odp_packet_user_flag + #define odp_packet_user_flag_set __odp_packet_user_flag_set + #define odp_packet_l2_offset __odp_packet_l2_offset + #define odp_packet_l3_offset __odp_packet_l3_offset + #define odp_packet_l4_offset __odp_packet_l4_offset + #define odp_packet_l2_offset_set __odp_packet_l2_offset_set + #define odp_packet_l3_offset_set __odp_packet_l3_offset_set + #define odp_packet_l4_offset_set __odp_packet_l4_offset_set + #define odp_packet_l2_ptr __odp_packet_l2_ptr + #define odp_packet_l3_ptr __odp_packet_l3_ptr + #define odp_packet_l4_ptr __odp_packet_l4_ptr + #define odp_packet_l2_type __odp_packet_l2_type + #define odp_packet_l3_type __odp_packet_l3_type + #define odp_packet_l4_type __odp_packet_l4_type + #define odp_packet_l3_chksum_status __odp_packet_l3_chksum_status + #define odp_packet_l4_chksum_status __odp_packet_l4_chksum_status + #define odp_packet_l3_chksum_insert __odp_packet_l3_chksum_insert + #define odp_packet_l4_chksum_insert __odp_packet_l4_chksum_insert + #define odp_packet_flow_hash __odp_packet_flow_hash + #define odp_packet_ts __odp_packet_ts + #define odp_packet_ts_set __odp_packet_ts_set + #define odp_packet_ts_request __odp_packet_ts_request + #define odp_packet_head __odp_packet_head + #define odp_packet_is_segmented __odp_packet_is_segmented + #define odp_packet_first_seg __odp_packet_first_seg + #define odp_packet_seg_data __odp_packet_seg_data + #define odp_packet_seg_data_len __odp_packet_seg_data_len + #define odp_packet_next_seg __odp_packet_next_seg + #define odp_packet_prefetch __odp_packet_prefetch + #define odp_packet_copy_from_mem __odp_packet_copy_from_mem + #define odp_packet_copy_to_mem __odp_packet_copy_to_mem + #define odp_packet_from_event __odp_packet_from_event + #define odp_packet_to_event __odp_packet_to_event + #define odp_packet_from_event_multi __odp_packet_from_event_multi + #define odp_packet_to_event_multi __odp_packet_to_event_multi + #define odp_packet_subtype __odp_packet_subtype + #define odp_packet_tx_compl_from_event __odp_packet_tx_compl_from_event + #define odp_packet_tx_compl_to_event __odp_packet_tx_compl_to_event + #define odp_packet_color __odp_packet_color + #define odp_packet_drop_eligible __odp_packet_drop_eligible + #define odp_packet_shaper_len_adjust __odp_packet_shaper_len_adjust + #define odp_packet_cls_mark __odp_packet_cls_mark + #define odp_packet_buf_data_len __odp_packet_buf_data_len + #define odp_packet_buf_size __odp_packet_buf_size + #define odp_packet_buf_head __odp_packet_buf_head + #define odp_packet_buf_data_offset __odp_packet_buf_data_offset + #define odp_packet_buf_data_set __odp_packet_buf_data_set + #define odp_packet_buf_from_head __odp_packet_buf_from_head + +#else + #undef _ODP_INLINE + #define _ODP_INLINE +#endif + +void *_odp_packet_map(void *pkt_ptr, uint32_t offset, uint32_t *seg_len, + odp_packet_seg_t *seg); -/** @internal Inline function offsets */ -extern const _odp_packet_inline_offset_t _odp_packet_inline; +int _odp_packet_copy_from_mem_seg(odp_packet_t pkt, uint32_t offset, + uint32_t len, const void *src); -#if ODP_ABI_COMPAT == 1 -/** @internal Inline function @param seg @return */ -static inline uint32_t _odp_packet_seg_to_ndx(odp_packet_seg_t seg) +int _odp_packet_copy_to_mem_seg(odp_packet_t pkt, uint32_t offset, + uint32_t len, void *dst); + +_ODP_INLINE void *odp_packet_data(odp_packet_t pkt) { - return _odp_typeval(seg); + return _odp_pkt_get(pkt, void *, seg_data); } -/** @internal Inline function @param ndx @return */ -static inline odp_packet_seg_t _odp_packet_seg_from_ndx(uint32_t ndx) +_ODP_INLINE uint32_t odp_packet_seg_len(odp_packet_t pkt) { - return _odp_cast_scalar(odp_packet_seg_t, ndx); + return _odp_pkt_get(pkt, uint32_t, seg_len); +} + +_ODP_INLINE void *odp_packet_data_seg_len(odp_packet_t pkt, + uint32_t *seg_len) +{ + *seg_len = odp_packet_seg_len(pkt); + return odp_packet_data(pkt); +} + +_ODP_INLINE uint32_t odp_packet_len(odp_packet_t pkt) +{ + return _odp_pkt_get(pkt, uint32_t, frame_len); +} + +_ODP_INLINE uint32_t odp_packet_headroom(odp_packet_t pkt) +{ + return _odp_pkt_get(pkt, uint16_t, headroom); +} + +_ODP_INLINE uint32_t odp_packet_tailroom(odp_packet_t pkt) +{ + return _odp_pkt_get(pkt, uint16_t, tailroom); +} + +_ODP_INLINE odp_pool_t odp_packet_pool(odp_packet_t pkt) +{ + return _odp_pkt_get(pkt, odp_pool_t, pool); +} + +_ODP_INLINE odp_pktio_t odp_packet_input(odp_packet_t pkt) +{ + return _odp_pkt_get(pkt, odp_pktio_t, input); +} + +_ODP_INLINE void odp_packet_input_set(odp_packet_t pkt, odp_pktio_t pktio) +{ + odp_pktio_t *pktio_ptr = _odp_pkt_get_ptr(pkt, odp_pktio_t, input); + + *pktio_ptr = pktio; +} + +_ODP_INLINE int odp_packet_input_index(odp_packet_t pkt) +{ + odp_pktio_t pktio = odp_packet_input(pkt); + + return odp_pktio_index(pktio); +} + +_ODP_INLINE int odp_packet_num_segs(odp_packet_t pkt) +{ + return _odp_pkt_get(pkt, uint8_t, seg_count); +} + +_ODP_INLINE void *odp_packet_user_ptr(odp_packet_t pkt) +{ + _odp_packet_flags_t flags; + + flags.all_flags = _odp_pkt_get(pkt, uint32_t, flags); + + if (flags.user_ptr_set == 0) + return NULL; + + return _odp_pkt_get(pkt, void *, user_ptr); +} + +_ODP_INLINE void odp_packet_user_ptr_set(odp_packet_t pkt, const void *ptr) +{ + _odp_packet_flags_t *flags = _odp_pkt_get_ptr(pkt, _odp_packet_flags_t, flags); + const void **user_ptr = _odp_pkt_get_ptr(pkt, const void *, user_ptr); + + if (odp_unlikely(ptr == NULL)) { + flags->user_ptr_set = 0; + return; + } + + *user_ptr = ptr; + flags->user_ptr_set = 1; +} + +_ODP_INLINE void *odp_packet_user_area(odp_packet_t pkt) +{ + return _odp_pkt_get(pkt, void *, user_area); +} + +_ODP_INLINE uint32_t odp_packet_user_area_size(odp_packet_t pkt) +{ + void *pool = _odp_pkt_get(pkt, void *, pool); + + return _odp_pool_get(pool, uint32_t, uarea_size); } -#endif -/** @internal Inline function @param pkt @return */ -static inline void *_odp_packet_data(odp_packet_t pkt) +_ODP_INLINE int odp_packet_user_flag(odp_packet_t pkt) { - return *(void **)(uintptr_t)((uint8_t *)pkt + _odp_packet_inline.data); + _odp_packet_flags_t flags; + + flags.all_flags = _odp_pkt_get(pkt, uint32_t, flags); + + return flags.user_flag; } -/** @internal Inline function @param pkt @return */ -static inline uint32_t _odp_packet_seg_len(odp_packet_t pkt) +_ODP_INLINE void odp_packet_user_flag_set(odp_packet_t pkt, int val) { - return *(uint32_t *)(uintptr_t)((uint8_t *)pkt + - _odp_packet_inline.seg_len); + _odp_packet_flags_t *flags = _odp_pkt_get_ptr(pkt, _odp_packet_flags_t, flags); + + flags->user_flag = !!val; } -/** @internal Inline function @param pkt @return */ -static inline uint32_t _odp_packet_len(odp_packet_t pkt) +_ODP_INLINE uint32_t odp_packet_l2_offset(odp_packet_t pkt) { - return *(uint32_t *)(uintptr_t)((uint8_t *)pkt + - _odp_packet_inline.frame_len); + return _odp_pkt_get(pkt, uint16_t, l2_offset); } -/** @internal Inline function @param pkt @return */ -static inline uint32_t _odp_packet_headroom(odp_packet_t pkt) +_ODP_INLINE uint32_t odp_packet_l3_offset(odp_packet_t pkt) { - return *(uint32_t *)(uintptr_t)((uint8_t *)pkt + - _odp_packet_inline.headroom); + return _odp_pkt_get(pkt, uint16_t, l3_offset); } -/** @internal Inline function @param pkt @return */ -static inline uint32_t _odp_packet_tailroom(odp_packet_t pkt) +_ODP_INLINE uint32_t odp_packet_l4_offset(odp_packet_t pkt) { - return *(uint32_t *)(uintptr_t)((uint8_t *)pkt + - _odp_packet_inline.tailroom); + return _odp_pkt_get(pkt, uint16_t, l4_offset); } -/** @internal Inline function @param pkt @return */ -static inline odp_pool_t _odp_packet_pool(odp_packet_t pkt) +_ODP_INLINE int odp_packet_l2_offset_set(odp_packet_t pkt, uint32_t offset) { - return *(odp_pool_t *)(uintptr_t)((uint8_t *)pkt + - _odp_packet_inline.pool); + uint16_t *l2_offset = _odp_pkt_get_ptr(pkt, uint16_t, l2_offset); + _odp_packet_input_flags_t *input_flags = _odp_pkt_get_ptr(pkt, _odp_packet_input_flags_t, + input_flags); + + if (odp_unlikely(offset >= odp_packet_len(pkt))) + return -1; + + input_flags->l2 = 1; + *l2_offset = (uint16_t)offset; + return 0; } -/** @internal Inline function @param pkt @return */ -static inline odp_pktio_t _odp_packet_input(odp_packet_t pkt) +_ODP_INLINE int odp_packet_l3_offset_set(odp_packet_t pkt, uint32_t offset) { - return *(odp_pktio_t *)(uintptr_t)((uint8_t *)pkt + - _odp_packet_inline.input); + uint16_t *l3_offset = _odp_pkt_get_ptr(pkt, uint16_t, l3_offset); + + if (odp_unlikely(offset >= odp_packet_len(pkt))) + return -1; + + *l3_offset = (uint16_t)offset; + return 0; } -/** @internal Inline function @param pkt @return */ -static inline int _odp_packet_num_segs(odp_packet_t pkt) +_ODP_INLINE int odp_packet_l4_offset_set(odp_packet_t pkt, uint32_t offset) { - return *(uint8_t *)(uintptr_t)((uint8_t *)pkt + - _odp_packet_inline.segcount); + uint16_t *l4_offset = _odp_pkt_get_ptr(pkt, uint16_t, l4_offset); + + if (odp_unlikely(offset >= odp_packet_len(pkt))) + return -1; + + *l4_offset = (uint16_t)offset; + return 0; } -/** @internal Inline function @param pkt @return */ -static inline void *_odp_packet_user_ptr(odp_packet_t pkt) +_ODP_INLINE void *odp_packet_l2_ptr(odp_packet_t pkt, uint32_t *len) { - return *(void **)(uintptr_t)((uint8_t *)pkt + - _odp_packet_inline.user_ptr); + uint32_t offset = odp_packet_l2_offset(pkt); + uint32_t seg_len = odp_packet_seg_len(pkt); + uint8_t *data = (uint8_t *)odp_packet_data(pkt); + + if (odp_unlikely(offset >= seg_len)) { + void *pkt_hdr = (void *)pkt; + + return _odp_packet_map(pkt_hdr, offset, len, NULL); + } + + if (len) + *len = seg_len - offset; + + return data + offset; } -/** @internal Inline function @param pkt @return */ -static inline void *_odp_packet_user_area(odp_packet_t pkt) +_ODP_INLINE void *odp_packet_l3_ptr(odp_packet_t pkt, uint32_t *len) { - return *(void **)(uintptr_t)((uint8_t *)pkt + - _odp_packet_inline.user_area); + uint32_t offset = odp_packet_l3_offset(pkt); + uint32_t seg_len = odp_packet_seg_len(pkt); + uint8_t *data = (uint8_t *)odp_packet_data(pkt); + + if (odp_unlikely(offset >= seg_len)) { + void *pkt_hdr = (void *)pkt; + + return _odp_packet_map(pkt_hdr, offset, len, NULL); + } + + if (len) + *len = seg_len - offset; + + return data + offset; } -/** @internal Inline function @param pkt @return */ -static inline uint32_t _odp_packet_user_area_size(odp_packet_t pkt) +_ODP_INLINE void *odp_packet_l4_ptr(odp_packet_t pkt, uint32_t *len) { - return *(uint32_t *)(uintptr_t)((uint8_t *)pkt + - _odp_packet_inline.user_area_size); + uint32_t offset = odp_packet_l4_offset(pkt); + uint32_t seg_len = odp_packet_seg_len(pkt); + uint8_t *data = (uint8_t *)odp_packet_data(pkt); + + if (odp_unlikely(offset >= seg_len)) { + void *pkt_hdr = (void *)pkt; + + return _odp_packet_map(pkt_hdr, offset, len, NULL); + } + + if (len) + *len = seg_len - offset; + + return data + offset; } -/** @internal Inline function @param pkt @return */ -static inline uint32_t _odp_packet_flow_hash(odp_packet_t pkt) +_ODP_INLINE odp_proto_l2_type_t odp_packet_l2_type(odp_packet_t pkt) { - return *(uint32_t *)(uintptr_t)((uint8_t *)pkt + - _odp_packet_inline.flow_hash); + _odp_packet_input_flags_t input_flags; + + input_flags.all = _odp_pkt_get(pkt, uint64_t, input_flags); + + return input_flags.eth ? ODP_PROTO_L2_TYPE_ETH : ODP_PROTO_L2_TYPE_NONE; } -/** @internal Inline function @param pkt @return */ -static inline odp_time_t _odp_packet_ts(odp_packet_t pkt) +_ODP_INLINE odp_proto_l3_type_t odp_packet_l3_type(odp_packet_t pkt) { - return *(odp_time_t *)(uintptr_t)((uint8_t *)pkt + - _odp_packet_inline.timestamp); + _odp_packet_input_flags_t input_flags; + + input_flags.all = _odp_pkt_get(pkt, uint64_t, input_flags); + + if (input_flags.ipv4) + return ODP_PROTO_L3_TYPE_IPV4; + else if (input_flags.ipv6) + return ODP_PROTO_L3_TYPE_IPV6; + else if (input_flags.arp) + return ODP_PROTO_L3_TYPE_ARP; + + return ODP_PROTO_L3_TYPE_NONE; } -/** @internal Inline function @param pkt @return */ -static inline void *_odp_packet_head(odp_packet_t pkt) +_ODP_INLINE odp_proto_l4_type_t odp_packet_l4_type(odp_packet_t pkt) { - return (uint8_t *)_odp_packet_data(pkt) - _odp_packet_headroom(pkt); + _odp_packet_input_flags_t input_flags; + + input_flags.all = _odp_pkt_get(pkt, uint64_t, input_flags); + + if (input_flags.tcp) + return ODP_PROTO_L4_TYPE_TCP; + else if (input_flags.udp) + return ODP_PROTO_L4_TYPE_UDP; + else if (input_flags.sctp) + return ODP_PROTO_L4_TYPE_SCTP; + else if (input_flags.ipsec_ah) + return ODP_PROTO_L4_TYPE_AH; + else if (input_flags.ipsec_esp) + return ODP_PROTO_L4_TYPE_ESP; + else if (input_flags.icmp && input_flags.ipv4) + return ODP_PROTO_L4_TYPE_ICMPV4; + else if (input_flags.icmp && input_flags.ipv6) + return ODP_PROTO_L4_TYPE_ICMPV6; + else if (input_flags.no_next_hdr) + return ODP_PROTO_L4_TYPE_NO_NEXT; + + return ODP_PROTO_L4_TYPE_NONE; } -/** @internal Inline function @param pkt @return */ -static inline int _odp_packet_is_segmented(odp_packet_t pkt) +_ODP_INLINE odp_packet_chksum_status_t odp_packet_l3_chksum_status(odp_packet_t pkt) { - return _odp_packet_num_segs(pkt) > 1; + _odp_packet_flags_t flags; + _odp_packet_input_flags_t input_flags; + + flags.all_flags = _odp_pkt_get(pkt, uint32_t, flags); + input_flags.all = _odp_pkt_get(pkt, uint64_t, input_flags); + + if (!input_flags.l3_chksum_done) + return ODP_PACKET_CHKSUM_UNKNOWN; + + if (flags.l3_chksum_err) + return ODP_PACKET_CHKSUM_BAD; + + return ODP_PACKET_CHKSUM_OK; } -/** @internal Inline function @param pkt @return */ -static inline odp_packet_seg_t _odp_packet_first_seg(odp_packet_t pkt) +_ODP_INLINE odp_packet_chksum_status_t odp_packet_l4_chksum_status(odp_packet_t pkt) { - (void)pkt; + _odp_packet_flags_t flags; + _odp_packet_input_flags_t input_flags; + + flags.all_flags = _odp_pkt_get(pkt, uint32_t, flags); + input_flags.all = _odp_pkt_get(pkt, uint64_t, input_flags); + + if (!input_flags.l4_chksum_done) + return ODP_PACKET_CHKSUM_UNKNOWN; + + if (flags.l4_chksum_err) + return ODP_PACKET_CHKSUM_BAD; - return _odp_packet_seg_from_ndx(0); + return ODP_PACKET_CHKSUM_OK; } -/** @internal Inline function @param pkt @return */ -static inline odp_packet_seg_t _odp_packet_last_seg(odp_packet_t pkt) +_ODP_INLINE void odp_packet_l3_chksum_insert(odp_packet_t pkt, int insert) { - return _odp_packet_seg_from_ndx(_odp_packet_num_segs(pkt) - 1); + _odp_packet_flags_t *flags = _odp_pkt_get_ptr(pkt, _odp_packet_flags_t, flags); + + flags->l3_chksum_set = 1; + flags->l3_chksum = !!insert; +} + +_ODP_INLINE void odp_packet_l4_chksum_insert(odp_packet_t pkt, int insert) +{ + _odp_packet_flags_t *flags = _odp_pkt_get_ptr(pkt, _odp_packet_flags_t, flags); + + flags->l4_chksum_set = 1; + flags->l4_chksum = !!insert; } -/** @internal Inline function @param pkt @param seg @return */ -static inline odp_packet_seg_t _odp_packet_next_seg(odp_packet_t pkt, - odp_packet_seg_t seg) +_ODP_INLINE uint32_t odp_packet_flow_hash(odp_packet_t pkt) { - if (odp_unlikely(_odp_packet_seg_to_ndx(seg) >= - _odp_packet_seg_to_ndx(_odp_packet_last_seg(pkt)))) + return _odp_pkt_get(pkt, uint32_t, flow_hash); +} + +_ODP_INLINE odp_time_t odp_packet_ts(odp_packet_t pkt) +{ + return _odp_pkt_get(pkt, odp_time_t, timestamp); +} + +_ODP_INLINE void odp_packet_ts_set(odp_packet_t pkt, odp_time_t timestamp) +{ + odp_time_t *ts = _odp_pkt_get_ptr(pkt, odp_time_t, timestamp); + _odp_packet_input_flags_t *input_flags = _odp_pkt_get_ptr(pkt, _odp_packet_input_flags_t, + input_flags); + + *ts = timestamp; + input_flags->timestamp = 1; +} + +_ODP_INLINE void odp_packet_ts_request(odp_packet_t pkt, int enable) +{ + _odp_packet_flags_t *flags = _odp_pkt_get_ptr(pkt, _odp_packet_flags_t, flags); + + flags->ts_set = !!enable; +} + +_ODP_INLINE void *odp_packet_head(odp_packet_t pkt) +{ + return (uint8_t *)odp_packet_data(pkt) - odp_packet_headroom(pkt); +} + +_ODP_INLINE int odp_packet_is_segmented(odp_packet_t pkt) +{ + return _odp_pkt_get(pkt, uint8_t, seg_count) > 1; +} + +_ODP_INLINE odp_packet_seg_t odp_packet_first_seg(odp_packet_t pkt) +{ + return (odp_packet_seg_t)pkt; +} + +_ODP_INLINE void *odp_packet_seg_data(odp_packet_t pkt ODP_UNUSED, + odp_packet_seg_t seg) +{ + return _odp_pkt_get((odp_packet_t)seg, void *, seg_data); +} + +_ODP_INLINE uint32_t odp_packet_seg_data_len(odp_packet_t pkt ODP_UNUSED, + odp_packet_seg_t seg) +{ + return _odp_pkt_get((odp_packet_t)seg, uint32_t, seg_len); +} + +_ODP_INLINE odp_packet_seg_t odp_packet_next_seg(odp_packet_t pkt ODP_UNUSED, + odp_packet_seg_t seg) +{ + void *next_seg = _odp_pkt_get((odp_packet_t)seg, void *, seg_next); + + if (odp_unlikely(next_seg == NULL)) return ODP_PACKET_SEG_INVALID; - return seg + 1; + return (odp_packet_seg_t)next_seg; } -/** @internal Inline function @param pkt @param offset @param len */ -static inline void _odp_packet_prefetch(odp_packet_t pkt, uint32_t offset, +_ODP_INLINE void odp_packet_prefetch(odp_packet_t pkt, uint32_t offset, uint32_t len) { - (void)pkt; (void)offset; (void)len; + uint32_t seg_len = odp_packet_seg_len(pkt); + uint8_t *data = (uint8_t *)odp_packet_data(pkt); + (void)len; + + if (odp_unlikely(offset >= seg_len)) + return; + + odp_prefetch(data + offset); } -/* Include inlined versions of API functions */ -#include <odp/api/plat/static_inline.h> -#if ODP_ABI_COMPAT == 0 +_ODP_INLINE int odp_packet_copy_from_mem(odp_packet_t pkt, uint32_t offset, + uint32_t len, const void *src) +{ + uint32_t seg_len = odp_packet_seg_len(pkt); + uint8_t *data = (uint8_t *)odp_packet_data(pkt); -/** @ingroup odp_packet - * @{ - */ + if (odp_unlikely(offset + len > seg_len)) + return _odp_packet_copy_from_mem_seg(pkt, offset, len, src); -#include <odp/api/plat/packet_inlines_api.h> + memcpy(data + offset, src, len); -/** - * @} - */ + return 0; +} -#endif +_ODP_INLINE int odp_packet_copy_to_mem(odp_packet_t pkt, uint32_t offset, + uint32_t len, void *dst) +{ + uint32_t seg_len = odp_packet_seg_len(pkt); + uint8_t *data = (uint8_t *)odp_packet_data(pkt); + + if (odp_unlikely(offset + len > seg_len)) + return _odp_packet_copy_to_mem_seg(pkt, offset, len, dst); + + memcpy(dst, data + offset, len); + + return 0; +} + +_ODP_INLINE odp_packet_t odp_packet_from_event(odp_event_t ev) +{ + _ODP_ASSERT(odp_event_type(ev) == ODP_EVENT_PACKET); + + return (odp_packet_t)ev; +} + +_ODP_INLINE odp_event_t odp_packet_to_event(odp_packet_t pkt) +{ + return (odp_event_t)pkt; +} + +_ODP_INLINE void odp_packet_from_event_multi(odp_packet_t pkt[], + const odp_event_t ev[], + int num) +{ + int i; + + for (i = 0; i < num; i++) + pkt[i] = odp_packet_from_event(ev[i]); +} + +_ODP_INLINE void odp_packet_to_event_multi(const odp_packet_t pkt[], + odp_event_t ev[], int num) +{ + int i; + + for (i = 0; i < num; i++) + ev[i] = odp_packet_to_event(pkt[i]); +} + +_ODP_INLINE odp_event_subtype_t odp_packet_subtype(odp_packet_t pkt) +{ + return (odp_event_subtype_t)_odp_event_hdr_field((odp_event_t)(uintptr_t)pkt, + int8_t, subtype); +} + +_ODP_INLINE odp_packet_tx_compl_t odp_packet_tx_compl_from_event(odp_event_t ev) +{ + _ODP_ASSERT(odp_event_type(ev) == ODP_EVENT_PACKET_TX_COMPL); + + return (odp_packet_tx_compl_t)(uintptr_t)ev; +} + +_ODP_INLINE odp_event_t odp_packet_tx_compl_to_event(odp_packet_tx_compl_t tx_compl) +{ + return (odp_event_t)(uintptr_t)tx_compl; +} + +_ODP_INLINE odp_packet_color_t odp_packet_color(odp_packet_t pkt) +{ + _odp_packet_input_flags_t input_flags; + + input_flags.all = _odp_pkt_get(pkt, uint64_t, input_flags); + + return (odp_packet_color_t)input_flags.color; +} + +_ODP_INLINE odp_bool_t odp_packet_drop_eligible(odp_packet_t pkt) +{ + _odp_packet_input_flags_t input_flags; + + input_flags.all = _odp_pkt_get(pkt, uint64_t, input_flags); + + return !input_flags.nodrop; +} + +_ODP_INLINE int8_t odp_packet_shaper_len_adjust(odp_packet_t pkt) +{ + _odp_packet_flags_t flags; + + flags.all_flags = _odp_pkt_get(pkt, uint32_t, flags); + + return (int8_t)flags.shaper_len_adj; +} + +_ODP_INLINE uint64_t odp_packet_cls_mark(odp_packet_t pkt) +{ + _odp_packet_input_flags_t input_flags; + + input_flags.all = _odp_pkt_get(pkt, uint64_t, input_flags); + + return input_flags.cls_mark ? _odp_pkt_get(pkt, uint16_t, cls_mark) : 0; +} + +_ODP_INLINE uint32_t odp_packet_buf_data_len(odp_packet_buf_t pkt_buf) +{ + return _odp_pkt_get(pkt_buf, uint32_t, seg_len); +} + +_ODP_INLINE uint32_t odp_packet_buf_size(odp_packet_buf_t pkt_buf) +{ + odp_pool_t pool = _odp_pkt_get(pkt_buf, odp_pool_t, pool); + + return _odp_pool_get(pool, uint32_t, ext_pkt_buf_size) - + _odp_pool_get(pool, uint32_t, ext_head_offset) - + _odp_pool_get(pool, uint32_t, trailer_size); +} + +_ODP_INLINE void *odp_packet_buf_head(odp_packet_buf_t pkt_buf) +{ + odp_pool_t pool = _odp_pkt_get(pkt_buf, odp_pool_t, pool); + const uint32_t head_offset = _odp_pool_get(pool, uint32_t, ext_head_offset); + + /* Check that pool is external */ + if (odp_unlikely(!head_offset)) + return NULL; + + return (uint8_t *)(uintptr_t)pkt_buf + head_offset; +} + +_ODP_INLINE uint32_t odp_packet_buf_data_offset(odp_packet_buf_t pkt_buf) +{ + void *buf_head = odp_packet_buf_head(pkt_buf); + + return (uint32_t)((uintptr_t)_odp_pkt_get(pkt_buf, void *, seg_data) - (uintptr_t)buf_head); +} + +_ODP_INLINE void odp_packet_buf_data_set(odp_packet_buf_t pkt_buf, uint32_t data_offset, + uint32_t data_len) +{ + uint8_t *head = (uint8_t *)odp_packet_buf_head(pkt_buf); + uint32_t *seg_len = _odp_pkt_get_ptr(pkt_buf, uint32_t, seg_len); + void **seg_data = _odp_pkt_get_ptr(pkt_buf, void *, seg_data); + + *seg_len = data_len; + *seg_data = head + data_offset; +} + +_ODP_INLINE odp_packet_buf_t odp_packet_buf_from_head(odp_pool_t pool, void *head) +{ + const uint32_t head_offset = _odp_pool_get(pool, uint32_t, ext_head_offset); + + /* Check that pool is external */ + if (odp_unlikely(!head_offset)) + return ODP_PACKET_BUF_INVALID; + + return (odp_packet_buf_t)((uintptr_t)head - head_offset); +} + +/** @endcond */ #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 deleted file mode 100644 index 233bc8761..000000000 --- a/platform/linux-generic/include/odp/api/plat/packet_inlines_api.h +++ /dev/null @@ -1,113 +0,0 @@ -/* 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 int odp_packet_num_segs(odp_packet_t pkt) -{ - return _odp_packet_num_segs(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 odp_packet_seg_t odp_packet_last_seg(odp_packet_t pkt) -{ - return _odp_packet_last_seg(pkt); -} - -_ODP_INLINE odp_packet_seg_t odp_packet_next_seg(odp_packet_t pkt, - odp_packet_seg_t seg) -{ - return _odp_packet_next_seg(pkt, seg); -} - -_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_io_inlines.h b/platform/linux-generic/include/odp/api/plat/packet_io_inlines.h new file mode 100644 index 000000000..a3d1d0d61 --- /dev/null +++ b/platform/linux-generic/include/odp/api/plat/packet_io_inlines.h @@ -0,0 +1,41 @@ +/* Copyright (c) 2018-2018, Linaro Limited + * Copyright (c) 2022, Nokia + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef ODP_PLAT_PACKET_IO_INLINES_H_ +#define ODP_PLAT_PACKET_IO_INLINES_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include <odp/api/abi/packet_io_types.h> + +#include <stdint.h> + +/** @cond _ODP_HIDE_FROM_DOXYGEN_ */ + +#ifndef _ODP_NO_INLINE + /* Inline functions by default */ + #define _ODP_INLINE static inline + #define odp_pktio_index __odp_pktio_index +#else + #undef _ODP_INLINE + #define _ODP_INLINE +#endif + +_ODP_INLINE int odp_pktio_index(odp_pktio_t pktio) +{ + return (int)(uintptr_t)pktio - 1; +} + +/** @endcond */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/platform/linux-generic/include/odp/api/plat/packet_io_types.h b/platform/linux-generic/include/odp/api/plat/packet_io_types.h deleted file mode 100644 index 5a45321fb..000000000 --- a/platform/linux-generic/include/odp/api/plat/packet_io_types.h +++ /dev/null @@ -1,64 +0,0 @@ -/* Copyright (c) 2015, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - - -/** - * @file - * - * ODP Packet IO - */ - -#ifndef ODP_PACKET_IO_TYPES_H_ -#define ODP_PACKET_IO_TYPES_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <odp/api/std_types.h> -#include <odp/api/plat/strong_types.h> - -/** @addtogroup odp_packet_io - * Operations on a packet. - * @{ - */ - -typedef ODP_HANDLE_T(odp_pktio_t); - -/** @internal */ -typedef struct odp_pktin_queue_t { - odp_pktio_t pktio; /**< @internal pktio handle */ - int index; /**< @internal pktio queue index */ -} odp_pktin_queue_t; - -/** @internal */ -typedef struct odp_pktout_queue_t { - odp_pktio_t pktio; /**< @internal pktio handle */ - int index; /**< @internal pktio queue index */ -} odp_pktout_queue_t; - -#define ODP_PKTIO_INVALID _odp_cast_scalar(odp_pktio_t, 0) - -#define ODP_PKTIO_MACADDR_MAXSIZE 16 - -#define ODP_PKTIN_NO_WAIT 0 -#define ODP_PKTIN_WAIT UINT64_MAX - -/** Get printable format of odp_pktio_t */ -static inline uint64_t odp_pktio_to_u64(odp_pktio_t hdl) -{ - return _odp_pri(hdl); -} - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#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 deleted file mode 100644 index 7e3c51e6c..000000000 --- a/platform/linux-generic/include/odp/api/plat/packet_types.h +++ /dev/null @@ -1,157 +0,0 @@ -/* Copyright (c) 2015, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - - -/** - * @file - * - * ODP packet descriptor - */ - -#ifndef ODP_PACKET_TYPES_H_ -#define ODP_PACKET_TYPES_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <stddef.h> - -#include <odp/api/plat/static_inline.h> -#if ODP_ABI_COMPAT == 1 -#include <odp/api/abi/packet.h> -#else - -#include <odp/api/std_types.h> -#include <odp/api/plat/strong_types.h> - -/** @ingroup odp_packet - * @{ - */ - -typedef ODP_HANDLE_T(odp_packet_t); - -#define ODP_PACKET_INVALID _odp_cast_scalar(odp_packet_t, 0) - -#define ODP_PACKET_OFFSET_INVALID (0x0fffffff) - -typedef uint8_t odp_packet_seg_t; - -static inline uint8_t _odp_packet_seg_to_ndx(odp_packet_seg_t seg) -{ - return (uint8_t)seg; -} - -static inline odp_packet_seg_t _odp_packet_seg_from_ndx(uint8_t ndx) -{ - return (odp_packet_seg_t)ndx; -} - -#define ODP_PACKET_SEG_INVALID ((odp_packet_seg_t)-1) - -typedef enum { - ODP_PACKET_GREEN = 0, - ODP_PACKET_YELLOW = 1, - ODP_PACKET_RED = 2, - ODP_PACKET_ALL_COLORS = 3, -} odp_packet_color_t; - -#define ODP_NUM_PACKET_COLORS 3 - -/** - * @} - */ - -#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 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; - /** @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 - -#endif diff --git a/platform/linux-generic/include/odp/api/plat/packet_vector_inlines.h b/platform/linux-generic/include/odp/api/plat/packet_vector_inlines.h new file mode 100644 index 000000000..2f8e0a709 --- /dev/null +++ b/platform/linux-generic/include/odp/api/plat/packet_vector_inlines.h @@ -0,0 +1,105 @@ +/* Copyright (c) 2020-2022, Nokia + * + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @file + * + * Packet vector inline functions + */ + +#ifndef _ODP_PLAT_PACKET_VECTOR_INLINES_H_ +#define _ODP_PLAT_PACKET_VECTOR_INLINES_H_ + +#include <odp/api/event.h> +#include <odp/api/packet_types.h> +#include <odp/api/pool_types.h> + +#include <odp/api/plat/debug_inlines.h> +#include <odp/api/plat/event_vector_inline_types.h> + +#include <stdint.h> + +/** @cond _ODP_HIDE_FROM_DOXYGEN_ */ + +#ifndef _ODP_NO_INLINE + /* Inline functions by default */ + #define _ODP_INLINE static inline + #define odp_packet_vector_from_event __odp_packet_vector_from_event + #define odp_packet_vector_to_event __odp_packet_vector_to_event + #define odp_packet_vector_tbl __odp_packet_vector_tbl + #define odp_packet_vector_pool __odp_packet_vector_pool + #define odp_packet_vector_size __odp_packet_vector_size + #define odp_packet_vector_size_set __odp_packet_vector_size_set + #define odp_packet_vector_user_area __odp_packet_vector_user_area + #define odp_packet_vector_user_flag __odp_packet_vector_user_flag + #define odp_packet_vector_user_flag_set __odp_packet_vector_user_flag_set +#else + #undef _ODP_INLINE + #define _ODP_INLINE +#endif + +_ODP_INLINE odp_packet_vector_t odp_packet_vector_from_event(odp_event_t ev) +{ + _ODP_ASSERT(odp_event_type(ev) == ODP_EVENT_PACKET_VECTOR); + + return (odp_packet_vector_t)ev; +} + +_ODP_INLINE odp_event_t odp_packet_vector_to_event(odp_packet_vector_t pktv) +{ + return (odp_event_t)pktv; +} + +_ODP_INLINE uint32_t odp_packet_vector_tbl(odp_packet_vector_t pktv, odp_packet_t **pkt_tbl) +{ + *pkt_tbl = _odp_event_vect_get_ptr(pktv, odp_packet_t, packet); + + return _odp_event_vect_get(pktv, uint32_t, size); +} + +_ODP_INLINE odp_pool_t odp_packet_vector_pool(odp_packet_vector_t pktv) +{ + return _odp_event_vect_get(pktv, odp_pool_t, pool); +} + +_ODP_INLINE uint32_t odp_packet_vector_size(odp_packet_vector_t pktv) +{ + return _odp_event_vect_get(pktv, uint32_t, size); +} + +_ODP_INLINE void odp_packet_vector_size_set(odp_packet_vector_t pktv, uint32_t size) +{ + uint32_t *vector_size = _odp_event_vect_get_ptr(pktv, uint32_t, size); + + *vector_size = size; +} + +_ODP_INLINE void *odp_packet_vector_user_area(odp_packet_vector_t pktv) +{ + return _odp_event_vect_get(pktv, void *, uarea_addr); +} + +_ODP_INLINE int odp_packet_vector_user_flag(odp_packet_vector_t pktv) +{ + _odp_event_vector_flags_t flags; + + flags.all_flags = _odp_event_vect_get(pktv, uint32_t, flags); + + return flags.user_flag; +} + +_ODP_INLINE void odp_packet_vector_user_flag_set(odp_packet_vector_t pktv, int val) +{ + _odp_event_vector_flags_t *flags = _odp_event_vect_get_ptr(pktv, _odp_event_vector_flags_t, + flags); + + flags->user_flag = !!val; +} + +/** @endcond */ + +#endif diff --git a/platform/linux-generic/include/odp/api/plat/pool_inline_types.h b/platform/linux-generic/include/odp/api/plat/pool_inline_types.h new file mode 100644 index 000000000..fbff7eda7 --- /dev/null +++ b/platform/linux-generic/include/odp/api/plat/pool_inline_types.h @@ -0,0 +1,47 @@ +/* Copyright (c) 2015-2018, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +/** + * @file + * + * ODP packet descriptor + */ + +#ifndef ODP_POOL_INLINE_TYPES_H_ +#define ODP_POOL_INLINE_TYPES_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdint.h> + +/** @cond _ODP_HIDE_FROM_DOXYGEN_ */ + +/** Pool field accessor */ +#define _odp_pool_get(pool, cast, field) \ + (*(cast *)(uintptr_t)((uint8_t *)pool + _odp_pool_inline.field)) + +/** Pool header field offsets for inline functions */ +typedef struct _odp_pool_inline_offset_t { + uint16_t index; + uint16_t seg_len; + uint16_t uarea_size; + uint16_t trailer_size; + uint16_t ext_head_offset; + uint16_t ext_pkt_buf_size; + +} _odp_pool_inline_offset_t; + +extern const _odp_pool_inline_offset_t _odp_pool_inline; + +/** @endcond */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/platform/linux-generic/include/odp/api/plat/pool_inlines.h b/platform/linux-generic/include/odp/api/plat/pool_inlines.h new file mode 100644 index 000000000..58d66fad2 --- /dev/null +++ b/platform/linux-generic/include/odp/api/plat/pool_inlines.h @@ -0,0 +1,41 @@ +/* Copyright (c) 2022, Nokia + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef ODP_PLAT_POOL_INLINES_H_ +#define ODP_PLAT_POOL_INLINES_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include <odp/api/pool_types.h> + +#include <odp/api/plat/pool_inline_types.h> + +#include <stdint.h> + +/** @cond _ODP_HIDE_FROM_DOXYGEN_ */ + +#ifndef _ODP_NO_INLINE + /* Inline functions by default */ + #define _ODP_INLINE static inline + #define odp_pool_index __odp_pool_index +#else + #define _ODP_INLINE +#endif + +_ODP_INLINE int odp_pool_index(odp_pool_t pool) +{ + return (int)_odp_pool_get(pool, uint32_t, index); +} + +/** @endcond */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/platform/linux-generic/include/odp/api/plat/pool_types.h b/platform/linux-generic/include/odp/api/plat/pool_types.h deleted file mode 100644 index 8bc816d4e..000000000 --- a/platform/linux-generic/include/odp/api/plat/pool_types.h +++ /dev/null @@ -1,55 +0,0 @@ -/* Copyright (c) 2015, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP pool - */ - -#ifndef ODP_POOL_TYPES_H_ -#define ODP_POOL_TYPES_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <odp/api/plat/static_inline.h> -#if ODP_ABI_COMPAT == 1 -#include <odp/api/abi/pool.h> -#else - -#include <odp/api/std_types.h> -#include <odp/api/plat/strong_types.h> -#include <odp/api/plat/event_types.h> - -/** @ingroup odp_pool - * @{ - */ - -typedef ODP_HANDLE_T(odp_pool_t); - -#define ODP_POOL_INVALID _odp_cast_scalar(odp_pool_t, 0xffffffff) - -#define ODP_POOL_NAME_LEN 32 - -typedef enum odp_pool_type_t { - ODP_POOL_BUFFER = ODP_EVENT_BUFFER, - ODP_POOL_PACKET = ODP_EVENT_PACKET, - ODP_POOL_TIMEOUT = ODP_EVENT_TIMEOUT, -} odp_pool_type_t; - -/** - * @} - */ - -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/api/plat/queue_inline_types.h b/platform/linux-generic/include/odp/api/plat/queue_inline_types.h new file mode 100644 index 000000000..593942072 --- /dev/null +++ b/platform/linux-generic/include/odp/api/plat/queue_inline_types.h @@ -0,0 +1,73 @@ +/* Copyright (c) 2018, Linaro Limited + * Copyright (c) 2023, Nokia + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef ODP_PLAT_QUEUE_INLINE_TYPES_H_ +#define ODP_PLAT_QUEUE_INLINE_TYPES_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdint.h> +#include <odp/api/event_types.h> +#include <odp/api/queue_types.h> + +/** @cond _ODP_HIDE_FROM_DOXYGEN_ */ + +/* Queue entry field accessor */ +#define _odp_qentry_field(qentry, cast, field) \ + (*(cast *)(uintptr_t)((uint8_t *)qentry + \ + _odp_queue_inline_offset.field)) + +/* Queue entry field offsets for inline functions */ +typedef struct _odp_queue_inline_offset_t { + uint16_t context; + +} _odp_queue_inline_offset_t; + +/* Queue API functions */ +typedef struct { + odp_queue_t (*queue_create)(const char *name, + const odp_queue_param_t *param); + int (*queue_create_multi)(const char *name[], + const odp_queue_param_t param[], + odp_bool_t share_param, odp_queue_t queue[], + int num); + int (*queue_destroy)(odp_queue_t queue); + int (*queue_destroy_multi)(odp_queue_t queue[], int num); + odp_queue_t (*queue_lookup)(const char *name); + int (*queue_capability)(odp_queue_capability_t *capa); + int (*queue_context_set)(odp_queue_t queue, void *context, + uint32_t len); + int (*queue_enq)(odp_queue_t queue, odp_event_t ev); + int (*queue_enq_multi)(odp_queue_t queue, const odp_event_t events[], + int num); + odp_event_t (*queue_deq)(odp_queue_t queue); + int (*queue_deq_multi)(odp_queue_t queue, odp_event_t events[], + int num); + odp_queue_type_t (*queue_type)(odp_queue_t queue); + odp_schedule_sync_t (*queue_sched_type)(odp_queue_t queue); + odp_schedule_prio_t (*queue_sched_prio)(odp_queue_t queue); + odp_schedule_group_t (*queue_sched_group)(odp_queue_t queue); + uint32_t (*queue_lock_count)(odp_queue_t queue); + uint64_t (*queue_to_u64)(odp_queue_t queue); + void (*queue_param_init)(odp_queue_param_t *param); + int (*queue_info)(odp_queue_t queue, odp_queue_info_t *info); + void (*queue_print)(odp_queue_t queue); + void (*queue_print_all)(void); + +} _odp_queue_api_fn_t; + +extern _odp_queue_inline_offset_t _odp_queue_inline_offset; + +/** @endcond */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/platform/linux-generic/include/odp/api/plat/queue_inlines.h b/platform/linux-generic/include/odp/api/plat/queue_inlines.h new file mode 100644 index 000000000..609c0c9e4 --- /dev/null +++ b/platform/linux-generic/include/odp/api/plat/queue_inlines.h @@ -0,0 +1,72 @@ +/* Copyright (c) 2018, Linaro Limited + * Copyright (c) 2023, Nokia + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef ODP_PLAT_QUEUE_INLINES_H_ +#define ODP_PLAT_QUEUE_INLINES_H_ + +#include <odp/api/hints.h> + +#include <odp/api/plat/event_validation_external.h> +#include <odp/api/plat/queue_inline_types.h> + +/** @cond _ODP_HIDE_FROM_DOXYGEN_ */ + +extern const _odp_queue_api_fn_t *_odp_queue_api; + +#ifndef _ODP_NO_INLINE + /* Inline functions by default */ + #define _ODP_INLINE static inline + #define odp_queue_context __odp_queue_context + #define odp_queue_enq __odp_queue_enq + #define odp_queue_enq_multi __odp_queue_enq_multi + #define odp_queue_deq __odp_queue_deq + #define odp_queue_deq_multi __odp_queue_deq_multi +#else + #define _ODP_INLINE +#endif + +_ODP_INLINE void *odp_queue_context(odp_queue_t handle) +{ + void *context; + void *qentry = (void *)handle; + + context = _odp_qentry_field(qentry, void *, context); + + return context; +} + +_ODP_INLINE int odp_queue_enq(odp_queue_t queue, odp_event_t ev) +{ + if (odp_unlikely(_odp_event_validate(ev, _ODP_EV_QUEUE_ENQ))) + return -1; + + return _odp_queue_api->queue_enq(queue, ev); +} + +_ODP_INLINE int odp_queue_enq_multi(odp_queue_t queue, + const odp_event_t events[], int num) +{ + if (odp_unlikely(_odp_event_validate_multi(events, num, _ODP_EV_QUEUE_ENQ_MULTI))) + return -1; + + return _odp_queue_api->queue_enq_multi(queue, events, num); +} + +_ODP_INLINE odp_event_t odp_queue_deq(odp_queue_t queue) +{ + return _odp_queue_api->queue_deq(queue); +} + +_ODP_INLINE int odp_queue_deq_multi(odp_queue_t queue, + odp_event_t events[], int num) +{ + return _odp_queue_api->queue_deq_multi(queue, events, num); +} + +/** @endcond */ + +#endif diff --git a/platform/linux-generic/include/odp/api/plat/queue_types.h b/platform/linux-generic/include/odp/api/plat/queue_types.h deleted file mode 100644 index 1561e2239..000000000 --- a/platform/linux-generic/include/odp/api/plat/queue_types.h +++ /dev/null @@ -1,48 +0,0 @@ -/* Copyright (c) 2015, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP queue - */ - -#ifndef ODP_QUEUE_TYPES_H_ -#define ODP_QUEUE_TYPES_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <odp/api/plat/static_inline.h> -#if ODP_ABI_COMPAT == 1 -#include <odp/api/abi/queue.h> -#else - -#include <odp/api/std_types.h> -#include <odp/api/plat/strong_types.h> - -/** @ingroup odp_queue - * @{ - */ - -typedef ODP_HANDLE_T(odp_queue_t); - -#define ODP_QUEUE_INVALID _odp_cast_scalar(odp_queue_t, 0) - -#define ODP_QUEUE_NAME_LEN 32 - -/** - * @} - */ - -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/api/plat/rwlock_inlines.h b/platform/linux-generic/include/odp/api/plat/rwlock_inlines.h new file mode 100644 index 000000000..0bb9d8c6e --- /dev/null +++ b/platform/linux-generic/include/odp/api/plat/rwlock_inlines.h @@ -0,0 +1,105 @@ +/* Copyright (c) 2014-2018, Linaro Limited + * Copyright (c) 2022, Nokia + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef ODP_PLAT_RWLOCK_INLINES_H_ +#define ODP_PLAT_RWLOCK_INLINES_H_ + +#include <odp/api/atomic.h> +#include <odp/api/cpu.h> + +#include <odp/api/abi/rwlock.h> + +#include <stdint.h> + +/** @cond _ODP_HIDE_FROM_DOXYGEN_ */ + +#ifndef _ODP_NO_INLINE + /* Inline functions by default */ + #define _ODP_INLINE static inline + #define odp_rwlock_init __odp_rwlock_init + #define odp_rwlock_read_lock __odp_rwlock_read_lock + #define odp_rwlock_read_trylock __odp_rwlock_read_trylock + #define odp_rwlock_read_unlock __odp_rwlock_read_unlock + #define odp_rwlock_write_lock __odp_rwlock_write_lock + #define odp_rwlock_write_trylock __odp_rwlock_write_trylock + #define odp_rwlock_write_unlock __odp_rwlock_write_unlock +#else + #undef _ODP_INLINE + #define _ODP_INLINE +#endif + +_ODP_INLINE void odp_rwlock_init(odp_rwlock_t *rwlock) +{ + odp_atomic_init_u32(&rwlock->cnt, 0); +} + +_ODP_INLINE void odp_rwlock_read_lock(odp_rwlock_t *rwlock) +{ + uint32_t cnt; + int is_locked = 0; + + while (is_locked == 0) { + cnt = odp_atomic_load_u32(&rwlock->cnt); + /* waiting for read lock */ + if ((int32_t)cnt < 0) { + odp_cpu_pause(); + continue; + } + is_locked = odp_atomic_cas_acq_u32(&rwlock->cnt, &cnt, cnt + 1); + } +} + +_ODP_INLINE int odp_rwlock_read_trylock(odp_rwlock_t *rwlock) +{ + uint32_t cnt = odp_atomic_load_u32(&rwlock->cnt); + + while (cnt != (uint32_t)-1) { + if (odp_atomic_cas_acq_u32(&rwlock->cnt, &cnt, cnt + 1)) + return 1; + } + + return 0; +} + +_ODP_INLINE void odp_rwlock_read_unlock(odp_rwlock_t *rwlock) +{ + odp_atomic_sub_rel_u32(&rwlock->cnt, 1); +} + +_ODP_INLINE void odp_rwlock_write_lock(odp_rwlock_t *rwlock) +{ + uint32_t cnt; + int is_locked = 0; + + while (is_locked == 0) { + uint32_t zero = 0; + + cnt = odp_atomic_load_u32(&rwlock->cnt); + /* lock acquired, wait */ + if (cnt != 0) { + odp_cpu_pause(); + continue; + } + is_locked = odp_atomic_cas_acq_u32(&rwlock->cnt, &zero, (uint32_t)-1); + } +} + +_ODP_INLINE int odp_rwlock_write_trylock(odp_rwlock_t *rwlock) +{ + uint32_t zero = 0; + + return odp_atomic_cas_acq_u32(&rwlock->cnt, &zero, (uint32_t)-1); +} + +_ODP_INLINE void odp_rwlock_write_unlock(odp_rwlock_t *rwlock) +{ + odp_atomic_store_rel_u32(&rwlock->cnt, 0); +} + +/** @endcond */ + +#endif diff --git a/platform/linux-generic/include/odp/api/plat/rwlock_recursive_inlines.h b/platform/linux-generic/include/odp/api/plat/rwlock_recursive_inlines.h new file mode 100644 index 000000000..21ad4be4a --- /dev/null +++ b/platform/linux-generic/include/odp/api/plat/rwlock_recursive_inlines.h @@ -0,0 +1,142 @@ +/* Copyright (c) 2013-2018, Linaro Limited + * Copyright (c) 2022, Nokia + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef ODP_PLAT_RWLOCK_RECURSIVE_INLINES_H_ +#define ODP_PLAT_RWLOCK_RECURSIVE_INLINES_H_ + +#include <odp/api/rwlock.h> +#include <odp/api/thread.h> + +#include <odp/api/abi/rwlock_recursive.h> + +#include <odp/api/plat/debug_inlines.h> + +#include <stdint.h> +#include <string.h> + +/** @cond _ODP_HIDE_FROM_DOXYGEN_ */ + +#ifndef _ODP_NO_INLINE + /* Inline functions by default */ + #define _ODP_INLINE static inline + #define odp_rwlock_recursive_init __odp_rwlock_recursive_init + #define odp_rwlock_recursive_read_lock __odp_rwlock_recursive_read_lock + #define odp_rwlock_recursive_read_trylock __odp_rwlock_recursive_read_trylock + #define odp_rwlock_recursive_read_unlock __odp_rwlock_recursive_read_unlock + #define odp_rwlock_recursive_write_lock __odp_rwlock_recursive_write_lock + #define odp_rwlock_recursive_write_trylock __odp_rwlock_recursive_write_trylock + #define odp_rwlock_recursive_write_unlock __odp_rwlock_recursive_write_unlock +#else + #undef _ODP_INLINE + #define _ODP_INLINE +#endif + +_ODP_INLINE void odp_rwlock_recursive_init(odp_rwlock_recursive_t *rlock) +{ + memset(rlock, 0, sizeof(odp_rwlock_recursive_t)); + odp_rwlock_init(&rlock->lock); + rlock->wr_owner = -1; +} + +/* Multiple readers can recurse the lock concurrently */ +_ODP_INLINE void odp_rwlock_recursive_read_lock(odp_rwlock_recursive_t *rlock) +{ + int thr = odp_thread_id(); + + if (rlock->rd_cnt[thr]) { + _ODP_ASSERT(rlock->rd_cnt[thr] < UINT8_MAX); + rlock->rd_cnt[thr]++; + return; + } + + odp_rwlock_read_lock(&rlock->lock); + rlock->rd_cnt[thr] = 1; +} + +/* Multiple readers can recurse the lock concurrently */ +_ODP_INLINE int odp_rwlock_recursive_read_trylock(odp_rwlock_recursive_t *rlock) +{ + int thr = odp_thread_id(); + + if (rlock->rd_cnt[thr]) { + _ODP_ASSERT(rlock->rd_cnt[thr] < UINT8_MAX); + rlock->rd_cnt[thr]++; + return 1; + } + + if (odp_rwlock_read_trylock(&rlock->lock)) { + rlock->rd_cnt[thr] = 1; + return 1; + } + + return 0; +} + +_ODP_INLINE void odp_rwlock_recursive_read_unlock(odp_rwlock_recursive_t *rlock) +{ + int thr = odp_thread_id(); + + _ODP_ASSERT(rlock->rd_cnt[thr]); + rlock->rd_cnt[thr]--; + + if (rlock->rd_cnt[thr] > 0) + return; + + odp_rwlock_read_unlock(&rlock->lock); +} + +/* Only one writer can recurse the lock */ +_ODP_INLINE void odp_rwlock_recursive_write_lock(odp_rwlock_recursive_t *rlock) +{ + int thr = odp_thread_id(); + + if (rlock->wr_owner == thr) { + _ODP_ASSERT(rlock->wr_cnt < UINT32_MAX); + rlock->wr_cnt++; + return; + } + + odp_rwlock_write_lock(&rlock->lock); + rlock->wr_owner = thr; + rlock->wr_cnt = 1; +} + +/* Only one writer can recurse the lock */ +_ODP_INLINE int odp_rwlock_recursive_write_trylock(odp_rwlock_recursive_t *rlock) +{ + int thr = odp_thread_id(); + + if (rlock->wr_owner == thr) { + _ODP_ASSERT(rlock->wr_cnt < UINT32_MAX); + rlock->wr_cnt++; + return 1; + } + + if (odp_rwlock_write_trylock(&rlock->lock)) { + rlock->wr_owner = thr; + rlock->wr_cnt = 1; + return 1; + } + + return 0; +} + +_ODP_INLINE void odp_rwlock_recursive_write_unlock(odp_rwlock_recursive_t *rlock) +{ + _ODP_ASSERT(rlock->wr_cnt); + rlock->wr_cnt--; + + if (rlock->wr_cnt > 0) + return; + + rlock->wr_owner = -1; + odp_rwlock_write_unlock(&rlock->lock); +} + +/** @endcond */ + +#endif diff --git a/platform/linux-generic/include/odp/api/plat/rwlock_recursive_types.h b/platform/linux-generic/include/odp/api/plat/rwlock_recursive_types.h deleted file mode 100644 index 36f9204ac..000000000 --- a/platform/linux-generic/include/odp/api/plat/rwlock_recursive_types.h +++ /dev/null @@ -1,38 +0,0 @@ -/* Copyright (c) 2015, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP recursive read/write lock - */ - -#ifndef ODP_RWLOCK_RECURSIVE_TYPES_H_ -#define ODP_RWLOCK_RECURSIVE_TYPES_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <odp/api/rwlock.h> -#include <odp/api/std_types.h> -#include <odp/api/thread.h> - -/** @internal */ -struct odp_rwlock_recursive_s { - odp_rwlock_t lock; /**< the lock */ - int wr_owner; /**< write owner thread */ - uint32_t wr_cnt; /**< write recursion count */ - uint8_t rd_cnt[ODP_THREAD_COUNT_MAX]; /**< read recursion count */ -}; - -typedef struct odp_rwlock_recursive_s odp_rwlock_recursive_t; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/api/plat/rwlock_types.h b/platform/linux-generic/include/odp/api/plat/rwlock_types.h deleted file mode 100644 index f7dc04496..000000000 --- a/platform/linux-generic/include/odp/api/plat/rwlock_types.h +++ /dev/null @@ -1,37 +0,0 @@ -/* Copyright (c) 2015, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - - -/** - * @file - * - * ODP rwlock - */ - -#ifndef ODP_RWLOCK_TYPES_H_ -#define ODP_RWLOCK_TYPES_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <odp/api/atomic.h> - -/** @internal */ -struct odp_rwlock_s { - odp_atomic_u32_t cnt; /**< lock count - 0 lock not taken - -1 write lock taken - >0 read lock(s) taken */ -}; - -typedef struct odp_rwlock_s odp_rwlock_t; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/api/plat/schedule_inline_types.h b/platform/linux-generic/include/odp/api/plat/schedule_inline_types.h new file mode 100644 index 000000000..92089c9a0 --- /dev/null +++ b/platform/linux-generic/include/odp/api/plat/schedule_inline_types.h @@ -0,0 +1,68 @@ +/* Copyright (c) 2022, Nokia + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef ODP_PLAT_SCHEDULE_INLINE_TYPES_H_ +#define ODP_PLAT_SCHEDULE_INLINE_TYPES_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include <odp/api/event_types.h> +#include <odp/api/queue_types.h> +#include <odp/api/schedule_types.h> +#include <odp/api/thrmask.h> + +#include <stdint.h> + +/** @cond _ODP_HIDE_FROM_DOXYGEN_ */ + +/* Schedule API functions */ +typedef struct { + uint64_t (*schedule_wait_time)(uint64_t ns); + int (*schedule_capability)(odp_schedule_capability_t *capa); + void (*schedule_config_init)(odp_schedule_config_t *config); + int (*schedule_config)(const odp_schedule_config_t *config); + odp_event_t (*schedule)(odp_queue_t *from, uint64_t wait); + int (*schedule_multi)(odp_queue_t *from, uint64_t wait, odp_event_t events[], int num); + int (*schedule_multi_wait)(odp_queue_t *from, odp_event_t events[], int num); + int (*schedule_multi_no_wait)(odp_queue_t *from, odp_event_t events[], int num); + void (*schedule_pause)(void); + void (*schedule_resume)(void); + void (*schedule_release_atomic)(void); + void (*schedule_release_ordered)(void); + void (*schedule_prefetch)(int num); + int (*schedule_min_prio)(void); + int (*schedule_max_prio)(void); + int (*schedule_default_prio)(void); + int (*schedule_num_prio)(void); + odp_schedule_group_t (*schedule_group_create)(const char *name, const odp_thrmask_t *mask); + int (*schedule_group_destroy)(odp_schedule_group_t group); + odp_schedule_group_t (*schedule_group_lookup)(const char *name); + int (*schedule_group_join)(odp_schedule_group_t group, const odp_thrmask_t *mask); + int (*schedule_group_leave)(odp_schedule_group_t group, const odp_thrmask_t *mask); + int (*schedule_group_thrmask)(odp_schedule_group_t group, odp_thrmask_t *mask); + int (*schedule_group_info)(odp_schedule_group_t group, odp_schedule_group_info_t *info); + void (*schedule_order_lock)(uint32_t lock_index); + void (*schedule_order_unlock)(uint32_t lock_index); + void (*schedule_order_unlock_lock)(uint32_t unlock_index, uint32_t lock_index); + void (*schedule_order_lock_start)(uint32_t lock_index); + void (*schedule_order_lock_wait)(uint32_t lock_index); + void (*schedule_order_wait)(void); + void (*schedule_print)(void); + +} _odp_schedule_api_fn_t; + +/* Scheduler configuration status */ +int _odp_schedule_configured(void); + +/** @endcond */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/platform/linux-generic/include/odp/api/plat/schedule_inlines.h b/platform/linux-generic/include/odp/api/plat/schedule_inlines.h new file mode 100644 index 000000000..733b068d9 --- /dev/null +++ b/platform/linux-generic/include/odp/api/plat/schedule_inlines.h @@ -0,0 +1,135 @@ +/* Copyright (c) 2022, Nokia + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef ODP_PLAT_SCHEDULE_INLINES_H_ +#define ODP_PLAT_SCHEDULE_INLINES_H_ + +#include <odp/api/event_types.h> +#include <odp/api/queue_types.h> + +#include <odp/api/plat/debug_inlines.h> +#include <odp/api/plat/schedule_inline_types.h> + +#include <stdint.h> + +/** @cond _ODP_HIDE_FROM_DOXYGEN_ */ + +extern const _odp_schedule_api_fn_t *_odp_sched_api; + +#ifndef _ODP_NO_INLINE + /* Inline functions by default */ + #define _ODP_INLINE static inline + #define odp_schedule __odp_schedule + #define odp_schedule_multi __odp_schedule_multi + #define odp_schedule_multi_wait __odp_schedule_multi_wait + #define odp_schedule_multi_no_wait __odp_schedule_multi_no_wait + #define odp_schedule_wait_time __odp_schedule_wait_time + #define odp_schedule_pause __odp_schedule_pause + #define odp_schedule_resume __odp_schedule_resume + #define odp_schedule_release_atomic __odp_schedule_release_atomic + #define odp_schedule_release_ordered __odp_schedule_release_ordered + #define odp_schedule_prefetch __odp_schedule_prefetch + #define odp_schedule_order_lock __odp_schedule_order_lock + #define odp_schedule_order_unlock __odp_schedule_order_unlock + #define odp_schedule_order_unlock_lock __odp_schedule_order_unlock_lock + #define odp_schedule_order_lock_start __odp_schedule_order_lock_start + #define odp_schedule_order_lock_wait __odp_schedule_order_lock_wait + #define odp_schedule_order_wait __odp_schedule_order_wait +#else + #define _ODP_INLINE +#endif + +_ODP_INLINE odp_event_t odp_schedule(odp_queue_t *from, uint64_t wait) +{ + _ODP_ASSERT(_odp_schedule_configured()); + + return _odp_sched_api->schedule(from, wait); +} + +_ODP_INLINE int odp_schedule_multi(odp_queue_t *from, uint64_t wait, odp_event_t events[], int num) +{ + _ODP_ASSERT(_odp_schedule_configured()); + + return _odp_sched_api->schedule_multi(from, wait, events, num); +} + +_ODP_INLINE int odp_schedule_multi_wait(odp_queue_t *from, odp_event_t events[], int num) +{ + _ODP_ASSERT(_odp_schedule_configured()); + + return _odp_sched_api->schedule_multi_wait(from, events, num); +} + +_ODP_INLINE int odp_schedule_multi_no_wait(odp_queue_t *from, odp_event_t events[], int num) +{ + _ODP_ASSERT(_odp_schedule_configured()); + + return _odp_sched_api->schedule_multi_no_wait(from, events, num); +} + +_ODP_INLINE uint64_t odp_schedule_wait_time(uint64_t ns) +{ + return _odp_sched_api->schedule_wait_time(ns); +} + +_ODP_INLINE void odp_schedule_pause(void) +{ + _odp_sched_api->schedule_pause(); +} + +_ODP_INLINE void odp_schedule_resume(void) +{ + _odp_sched_api->schedule_resume(); +} + +_ODP_INLINE void odp_schedule_release_atomic(void) +{ + _odp_sched_api->schedule_release_atomic(); +} + +_ODP_INLINE void odp_schedule_release_ordered(void) +{ + _odp_sched_api->schedule_release_ordered(); +} + +_ODP_INLINE void odp_schedule_prefetch(int num) +{ + _odp_sched_api->schedule_prefetch(num); +} + +_ODP_INLINE void odp_schedule_order_lock(uint32_t lock_index) +{ + _odp_sched_api->schedule_order_lock(lock_index); +} + +_ODP_INLINE void odp_schedule_order_unlock(uint32_t lock_index) +{ + _odp_sched_api->schedule_order_unlock(lock_index); +} + +_ODP_INLINE void odp_schedule_order_unlock_lock(uint32_t unlock_index, uint32_t lock_index) +{ + _odp_sched_api->schedule_order_unlock_lock(unlock_index, lock_index); +} + +_ODP_INLINE void odp_schedule_order_lock_start(uint32_t lock_index) +{ + _odp_sched_api->schedule_order_lock_start(lock_index); +} + +_ODP_INLINE void odp_schedule_order_lock_wait(uint32_t lock_index) +{ + _odp_sched_api->schedule_order_lock_wait(lock_index); +} + +_ODP_INLINE void odp_schedule_order_wait(void) +{ + _odp_sched_api->schedule_order_wait(); +} + +/** @endcond */ + +#endif diff --git a/platform/linux-generic/include/odp/api/plat/schedule_types.h b/platform/linux-generic/include/odp/api/plat/schedule_types.h deleted file mode 100644 index 535fd6d05..000000000 --- a/platform/linux-generic/include/odp/api/plat/schedule_types.h +++ /dev/null @@ -1,62 +0,0 @@ -/* Copyright (c) 2015, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - - -/** - * @file - * - * ODP schedule - */ - -#ifndef ODP_SCHEDULE_TYPES_H_ -#define ODP_SCHEDULE_TYPES_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -/** @addtogroup odp_scheduler - * @{ - */ - -#define ODP_SCHED_WAIT UINT64_MAX -#define ODP_SCHED_NO_WAIT 0 - -typedef int odp_schedule_prio_t; - -#define ODP_SCHED_PRIO_HIGHEST 0 - -#define ODP_SCHED_PRIO_NORMAL 4 - -#define ODP_SCHED_PRIO_LOWEST 7 - -#define ODP_SCHED_PRIO_DEFAULT ODP_SCHED_PRIO_NORMAL - -typedef int odp_schedule_sync_t; - -#define ODP_SCHED_SYNC_PARALLEL 0 -#define ODP_SCHED_SYNC_ATOMIC 1 -#define ODP_SCHED_SYNC_ORDERED 2 - -typedef int odp_schedule_group_t; - -/* These must be kept in sync with thread_globals_t in odp_thread.c */ -#define ODP_SCHED_GROUP_INVALID -1 -#define ODP_SCHED_GROUP_ALL 0 -#define ODP_SCHED_GROUP_WORKER 1 -#define ODP_SCHED_GROUP_CONTROL 2 - -#define ODP_SCHED_GROUP_NAME_LEN 32 - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/api/plat/shared_memory_types.h b/platform/linux-generic/include/odp/api/plat/shared_memory_types.h deleted file mode 100644 index 2c5b4ed2e..000000000 --- a/platform/linux-generic/include/odp/api/plat/shared_memory_types.h +++ /dev/null @@ -1,50 +0,0 @@ -/* Copyright (c) 2015, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - - -/** - * @file - * - * ODP shared memory - */ - -#ifndef ODP_SHARED_MEMORY_TYPES_H_ -#define ODP_SHARED_MEMORY_TYPES_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <odp/api/plat/static_inline.h> -#if ODP_ABI_COMPAT == 1 -#include <odp/api/abi/shared_memory.h> -#else - -#include <odp/api/std_types.h> -#include <odp/api/plat/strong_types.h> - -/** @ingroup odp_shared_memory - * @{ - */ - -typedef ODP_HANDLE_T(odp_shm_t); - -#define ODP_SHM_INVALID _odp_cast_scalar(odp_shm_t, 0) -#define ODP_SHM_NULL ODP_SHM_INVALID - -#define ODP_SHM_NAME_LEN 32 - -/** - * @} - */ - -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/api/plat/spinlock_inlines.h b/platform/linux-generic/include/odp/api/plat/spinlock_inlines.h new file mode 100644 index 000000000..a04c43f88 --- /dev/null +++ b/platform/linux-generic/include/odp/api/plat/spinlock_inlines.h @@ -0,0 +1,65 @@ +/* Copyright (c) 2013-2018, Linaro Limited + * Copyright (c) 2022, Nokia + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef ODP_PLAT_SPINLOCK_INLINES_H_ +#define ODP_PLAT_SPINLOCK_INLINES_H_ + +#include <odp/api/cpu.h> + +#include <odp/api/abi/spinlock.h> + +/** @cond _ODP_HIDE_FROM_DOXYGEN_ */ + +#ifndef _ODP_NO_INLINE + /* Inline functions by default */ + #define _ODP_INLINE static inline + #define odp_spinlock_init __odp_spinlock_init + #define odp_spinlock_lock __odp_spinlock_lock + #define odp_spinlock_trylock __odp_spinlock_trylock + #define odp_spinlock_unlock __odp_spinlock_unlock + #define odp_spinlock_is_locked __odp_spinlock_is_locked + + #include <odp/api/plat/cpu_inlines.h> +#else + #undef _ODP_INLINE + #define _ODP_INLINE +#endif + +_ODP_INLINE void odp_spinlock_init(odp_spinlock_t *spinlock) +{ + __atomic_clear(&spinlock->lock, __ATOMIC_RELAXED); +} + +_ODP_INLINE void odp_spinlock_lock(odp_spinlock_t *spinlock) +{ + /* While the lock is already taken... */ + while (__atomic_test_and_set(&spinlock->lock, __ATOMIC_ACQUIRE)) + /* ...spin reading the flag (relaxed MM), + * the loop will exit when the lock becomes available + * and we will retry the TAS operation above */ + while (__atomic_load_n(&spinlock->lock, __ATOMIC_RELAXED)) + odp_cpu_pause(); +} + +_ODP_INLINE int odp_spinlock_trylock(odp_spinlock_t *spinlock) +{ + return (__atomic_test_and_set(&spinlock->lock, __ATOMIC_ACQUIRE) == 0); +} + +_ODP_INLINE void odp_spinlock_unlock(odp_spinlock_t *spinlock) +{ + __atomic_clear(&spinlock->lock, __ATOMIC_RELEASE); +} + +_ODP_INLINE int odp_spinlock_is_locked(odp_spinlock_t *spinlock) +{ + return __atomic_load_n(&spinlock->lock, __ATOMIC_RELAXED) != 0; +} + +/** @endcond */ + +#endif diff --git a/platform/linux-generic/include/odp/api/plat/spinlock_recursive_inlines.h b/platform/linux-generic/include/odp/api/plat/spinlock_recursive_inlines.h new file mode 100644 index 000000000..e795353f4 --- /dev/null +++ b/platform/linux-generic/include/odp/api/plat/spinlock_recursive_inlines.h @@ -0,0 +1,98 @@ +/* Copyright (c) 2013-2018, Linaro Limited + * Copyright (c) 2022, Nokia + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef ODP_PLAT_SPINLOCK_RECURSIVE_INLINES_H_ +#define ODP_PLAT_SPINLOCK_RECURSIVE_INLINES_H_ + +#include <odp/api/spinlock.h> +#include <odp/api/thread.h> + +#include <odp/api/abi/spinlock_recursive.h> + +#include <odp/api/plat/debug_inlines.h> + +#include <stdint.h> + +/** @cond _ODP_HIDE_FROM_DOXYGEN_ */ + +#ifndef _ODP_NO_INLINE + /* Inline functions by default */ + #define _ODP_INLINE static inline + #define odp_spinlock_recursive_init __odp_spinlock_recursive_init + #define odp_spinlock_recursive_lock __odp_spinlock_recursive_lock + #define odp_spinlock_recursive_trylock __odp_spinlock_recursive_trylock + #define odp_spinlock_recursive_unlock __odp_spinlock_recursive_unlock + #define odp_spinlock_recursive_is_locked __odp_spinlock_recursive_is_locked + + #include <odp/api/plat/spinlock_inlines.h> + #include <odp/api/plat/thread_inlines.h> +#else + #undef _ODP_INLINE + #define _ODP_INLINE +#endif + +_ODP_INLINE void odp_spinlock_recursive_init(odp_spinlock_recursive_t *rlock) +{ + odp_spinlock_init(&rlock->lock); + rlock->owner = -1; + rlock->cnt = 0; +} + +_ODP_INLINE void odp_spinlock_recursive_lock(odp_spinlock_recursive_t *rlock) +{ + int thr = odp_thread_id(); + + if (rlock->owner == thr) { + _ODP_ASSERT(rlock->cnt < UINT32_MAX); + rlock->cnt++; + return; + } + + odp_spinlock_lock(&rlock->lock); + rlock->owner = thr; + rlock->cnt = 1; +} + +_ODP_INLINE int odp_spinlock_recursive_trylock(odp_spinlock_recursive_t *rlock) +{ + int thr = odp_thread_id(); + + if (rlock->owner == thr) { + _ODP_ASSERT(rlock->cnt < UINT32_MAX); + rlock->cnt++; + return 1; + } + + if (odp_spinlock_trylock(&rlock->lock)) { + rlock->owner = thr; + rlock->cnt = 1; + return 1; + } + + return 0; +} + +_ODP_INLINE void odp_spinlock_recursive_unlock(odp_spinlock_recursive_t *rlock) +{ + _ODP_ASSERT(rlock->cnt); + rlock->cnt--; + + if (rlock->cnt > 0) + return; + + rlock->owner = -1; + odp_spinlock_unlock(&rlock->lock); +} + +_ODP_INLINE int odp_spinlock_recursive_is_locked(odp_spinlock_recursive_t *rlock) +{ + return odp_thread_id() == rlock->owner ? 1 : odp_spinlock_is_locked(&rlock->lock); +} + +/** @endcond */ + +#endif diff --git a/platform/linux-generic/include/odp/api/plat/spinlock_recursive_types.h b/platform/linux-generic/include/odp/api/plat/spinlock_recursive_types.h deleted file mode 100644 index c5a1adff9..000000000 --- a/platform/linux-generic/include/odp/api/plat/spinlock_recursive_types.h +++ /dev/null @@ -1,36 +0,0 @@ -/* Copyright (c) 2015, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP recursive spinlock - */ - -#ifndef ODP_SPINLOCK_RECURSIVE_TYPES_H_ -#define ODP_SPINLOCK_RECURSIVE_TYPES_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <odp/api/spinlock.h> -#include <odp/api/std_types.h> - -/** @internal */ -struct odp_spinlock_recursive_s { - odp_spinlock_t lock; /**< the lock */ - int owner; /**< thread owning the lock */ - uint32_t cnt; /**< recursion count */ -}; - -typedef struct odp_spinlock_recursive_s odp_spinlock_recursive_t; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/api/plat/spinlock_types.h b/platform/linux-generic/include/odp/api/plat/spinlock_types.h deleted file mode 100644 index f38ece6af..000000000 --- a/platform/linux-generic/include/odp/api/plat/spinlock_types.h +++ /dev/null @@ -1,34 +0,0 @@ -/* Copyright (c) 2015, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - - -/** - * @file - * - * ODP spinlock - */ - -#ifndef ODP_SPINLOCK_TYPES_H_ -#define ODP_SPINLOCK_TYPES_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <odp/api/std_types.h> - -/** @internal */ -struct odp_spinlock_s { - char lock; /**< lock flag, should match odp_atomic_flag_t */ -}; - -typedef struct odp_spinlock_s odp_spinlock_t; - -#ifdef __cplusplus -} -#endif - -#endif 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 deleted file mode 100644 index 3cf004347..000000000 --- a/platform/linux-generic/include/odp/api/plat/static_inline.h.in +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright (c) 2016, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * Macro for static inline functions - */ - -#ifndef ODP_PLAT_STATIC_INLINE_H_ -#define ODP_PLAT_STATIC_INLINE_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @internal - * @def ODP_ABI_COMPAT - * Control ABI compatibility - */ - -/** - * @internal - * @def _ODP_INLINE - * Define a function as inlined or not inlined (for ABI compatibility) - */ -#if @ODP_ABI_COMPAT@ -#define ODP_ABI_COMPAT 1 -#define _ODP_INLINE -#else -#define ODP_ABI_COMPAT 0 -#define _ODP_INLINE static inline -#endif - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/api/plat/std_clib_inlines.h b/platform/linux-generic/include/odp/api/plat/std_inlines.h index 8f505d079..3f6a7e9d4 100644 --- a/platform/linux-generic/include/odp/api/plat/std_clib_inlines.h +++ b/platform/linux-generic/include/odp/api/plat/std_inlines.h @@ -1,19 +1,26 @@ -/* Copyright (c) 2016, Linaro Limited +/* Copyright (c) 2016-2018, Linaro Limited * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ -#ifndef ODP_PLAT_STD_CLIB_INLINE_H_ -#define ODP_PLAT_STD_CLIB_INLINE_H_ +#ifndef ODP_PLAT_STD_INLINE_H_ +#define ODP_PLAT_STD_INLINE_H_ -#ifdef __cplusplus -extern "C" { -#endif +/** @cond _ODP_HIDE_FROM_DOXYGEN_ */ -#include <odp/api/spec/std_types.h> #include <string.h> +#ifndef _ODP_NO_INLINE + /* Inline functions by default */ + #define _ODP_INLINE static inline + #define odp_memcpy __odp_memcpy + #define odp_memset __odp_memset + #define odp_memcmp __odp_memcmp +#else + #define _ODP_INLINE +#endif + _ODP_INLINE void *odp_memcpy(void *dst, const void *src, size_t num) { return memcpy(dst, src, num); @@ -29,8 +36,6 @@ _ODP_INLINE int odp_memcmp(const void *ptr1, const void *ptr2, size_t num) return memcmp(ptr1, ptr2, num); } -#ifdef __cplusplus -} -#endif +/** @endcond */ #endif diff --git a/platform/linux-generic/include/odp/api/plat/strong_types.h b/platform/linux-generic/include/odp/api/plat/strong_types.h index a53d76352..6b61c7c27 100644 --- a/platform/linux-generic/include/odp/api/plat/strong_types.h +++ b/platform/linux-generic/include/odp/api/plat/strong_types.h @@ -1,4 +1,4 @@ -/* Copyright (c) 2015, Linaro Limited +/* Copyright (c) 2015-2018, Linaro Limited * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause @@ -15,9 +15,13 @@ #ifndef STRONG_TYPES_H_ #define STRONG_TYPES_H_ +#include <odp/api/std_types.h> + /** Use strong typing for ODP types */ #ifdef __cplusplus -#define ODP_HANDLE_T(type) struct _##type { uint8_t unused_dummy_var; } *type +/* Allow type to be expanded before concatenation with underscore */ +#define _ODP_HANDLE_T(type) struct _##type { uint8_t unused_dummy_var; } *type +#define ODP_HANDLE_T(type) _ODP_HANDLE_T(type) #else #define odp_handle_t struct { uint8_t unused_dummy_var; } * /** C/C++ helper macro for strong typing */ @@ -25,10 +29,10 @@ #endif /** Internal macro to get value of an ODP handle */ -#define _odp_typeval(handle) ((uint32_t)(uintptr_t)(handle)) +#define _odp_typeval(handle) ((uintptr_t)(handle)) /** Internal macro to get printable value of an ODP handle */ -#define _odp_pri(handle) ((uint64_t)_odp_typeval(handle)) +#define _odp_pri(handle) ((uint64_t)(uintptr_t)(handle)) /** Internal macro to convert a scalar to a typed handle */ #define _odp_cast_scalar(type, val) ((type)(uintptr_t)(val)) 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 76eb68107..b3a88b629 100644 --- a/platform/linux-generic/include/odp/api/plat/sync_inlines.h +++ b/platform/linux-generic/include/odp/api/plat/sync_inlines.h @@ -1,7 +1,6 @@ -/* Copyright (c) 2016, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause +/* SPDX-License-Identifier: BSD-3-Clause + * Copyright (c) 2016-2018 Linaro Limited + * Copyright (c) 2023 Nokia */ /** @@ -13,13 +12,26 @@ #ifndef ODP_PLAT_SYNC_INLINE_H_ #define ODP_PLAT_SYNC_INLINE_H_ +#include <odp/api/abi/sync_inlines.h> + #ifdef __cplusplus extern "C" { #endif -/** @ingroup odp_barrier - * @{ - */ +/** @cond _ODP_HIDE_FROM_DOXYGEN_ */ + +#ifndef _ODP_NO_INLINE + /* Inline functions by default */ + #define _ODP_INLINE static inline + #define odp_mb_release __odp_mb_release + #define odp_mb_acquire __odp_mb_acquire + #define odp_mb_full __odp_mb_full + #define odp_mb_sync __odp_mb_sync + #define odp_mb_sync_load __odp_mb_sync_load + #define odp_mb_sync_store __odp_mb_sync_store +#else + #define _ODP_INLINE +#endif _ODP_INLINE void odp_mb_release(void) { @@ -36,9 +48,22 @@ _ODP_INLINE void odp_mb_full(void) __atomic_thread_fence(__ATOMIC_SEQ_CST); } -/** - * @} - */ +_ODP_INLINE void odp_mb_sync(void) +{ + _odp_mb_sync(); +} + +_ODP_INLINE void odp_mb_sync_load(void) +{ + _odp_mb_sync_load(); +} + +_ODP_INLINE void odp_mb_sync_store(void) +{ + _odp_mb_sync_store(); +} + +/** @endcond */ #ifdef __cplusplus } diff --git a/platform/linux-generic/include/odp/api/plat/thread_inline_types.h b/platform/linux-generic/include/odp/api/plat/thread_inline_types.h new file mode 100644 index 000000000..d24263fa7 --- /dev/null +++ b/platform/linux-generic/include/odp/api/plat/thread_inline_types.h @@ -0,0 +1,36 @@ +/* Copyright (c) 2018-2018, Linaro Limited + * Copyright (c) 2022, Nokia + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef ODP_PLAT_THREAD_INLINE_TYPES_H_ +#define ODP_PLAT_THREAD_INLINE_TYPES_H_ + +#include <odp/api/init.h> +#include <odp/api/thread_types.h> + +#ifdef __cplusplus +extern "C" { +#endif + +/** @cond _ODP_HIDE_FROM_DOXYGEN_ */ + +typedef struct { + odp_log_func_t log_fn; + odp_thread_type_t type; + int thr; + int cpu; + +} _odp_thread_state_t; + +extern __thread _odp_thread_state_t *_odp_this_thread; + +/** @endcond */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/platform/linux-generic/include/odp/api/plat/thread_inlines.h b/platform/linux-generic/include/odp/api/plat/thread_inlines.h new file mode 100644 index 000000000..2b6957064 --- /dev/null +++ b/platform/linux-generic/include/odp/api/plat/thread_inlines.h @@ -0,0 +1,51 @@ +/* Copyright (c) 2018-2018, Linaro Limited + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef ODP_PLAT_THREAD_INLINES_H_ +#define ODP_PLAT_THREAD_INLINES_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include <odp/api/thread_types.h> + +#include <odp/api/plat/thread_inline_types.h> + +/** @cond _ODP_HIDE_FROM_DOXYGEN_ */ + +#ifndef _ODP_NO_INLINE + /* Inline functions by default */ + #define _ODP_INLINE static inline + #define odp_thread_id __odp_thread_id + #define odp_thread_type __odp_thread_type + #define odp_cpu_id __odp_cpu_id +#else + #define _ODP_INLINE +#endif + +_ODP_INLINE int odp_thread_id(void) +{ + return _odp_this_thread->thr; +} + +_ODP_INLINE odp_thread_type_t odp_thread_type(void) +{ + return _odp_this_thread->type; +} + +_ODP_INLINE int odp_cpu_id(void) +{ + return _odp_this_thread->cpu; +} + +/** @endcond */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/platform/linux-generic/include/odp/api/plat/thread_types.h b/platform/linux-generic/include/odp/api/plat/thread_types.h deleted file mode 100644 index 33af45983..000000000 --- a/platform/linux-generic/include/odp/api/plat/thread_types.h +++ /dev/null @@ -1,34 +0,0 @@ -/* Copyright (c) 2015, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP thread - */ - -#ifndef ODP_THREAD_TYPES_H_ -#define ODP_THREAD_TYPES_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -/** @addtogroup odp_thread - * @{ - */ - -#define ODP_THREAD_COUNT_MAX 128 - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/api/plat/thrmask_types.h b/platform/linux-generic/include/odp/api/plat/thrmask_types.h deleted file mode 100644 index 5d93890c1..000000000 --- a/platform/linux-generic/include/odp/api/plat/thrmask_types.h +++ /dev/null @@ -1,48 +0,0 @@ -/* Copyright (c) 2015, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP thread masks - */ - -#ifndef ODP_THRMASK_TYPES_H_ -#define ODP_THRMASK_TYPES_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -/** @addtogroup odp_thread - * @{ - */ - -#include <odp/api/cpumask.h> - -/** - * Minimum size of output buffer for odp_thrmask_to_str() - */ -#define ODP_THRMASK_STR_SIZE ODP_CPUMASK_STR_SIZE - -/** - * Thread mask - * - * Don't access directly, use access functions. - */ -typedef struct odp_thrmask_t { - odp_cpumask_t m; /**< @private Mask*/ -} odp_thrmask_t; - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif 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 ecbea7c4d..b596d1609 100644 --- a/platform/linux-generic/include/odp/api/plat/ticketlock_inlines.h +++ b/platform/linux-generic/include/odp/api/plat/ticketlock_inlines.h @@ -1,30 +1,42 @@ -/* Copyright (c) 2016, Linaro Limited +/* Copyright (c) 2016-2018, Linaro Limited * All rights reserved. * * SPDX-License-Identifier: BSD-3-Clause */ -/** - * @file - * - * Ticketlock inline functions - */ - #ifndef _ODP_PLAT_TICKETLOCK_INLINES_H_ #define _ODP_PLAT_TICKETLOCK_INLINES_H_ #include <odp/api/atomic.h> -#include <odp/api/sync.h> #include <odp/api/cpu.h> -#include <odp/api/plat/ticketlock_types.h> +#include <odp/api/abi/ticketlock.h> +#include <odp/api/abi/wait_until.h> +/** @cond _ODP_HIDE_FROM_DOXYGEN_ */ + +#ifndef _ODP_NO_INLINE + /* Inline functions by default */ + #define _ODP_INLINE static inline + #define odp_ticketlock_init __odp_ticketlock_init + #define odp_ticketlock_lock __odp_ticketlock_lock + #define odp_ticketlock_trylock __odp_ticketlock_trylock + #define odp_ticketlock_unlock __odp_ticketlock_unlock + #define odp_ticketlock_is_locked __odp_ticketlock_is_locked + /* Inline atomic functions */ + #include <odp/api/plat/atomic_inlines.h> + #include <odp/api/plat/cpu_inlines.h> +#else + #undef _ODP_INLINE + #define _ODP_INLINE +#endif -/** @internal - * Acquire ticket lock. - * - * @param ticketlock Pointer to a ticket lock - */ -static inline void _odp_ticketlock_lock(odp_ticketlock_t *ticketlock) +_ODP_INLINE void odp_ticketlock_init(odp_ticketlock_t *ticketlock) +{ + odp_atomic_init_u32(&ticketlock->next_ticket, 0); + odp_atomic_init_u32(&ticketlock->cur_ticket, 0); +} + +_ODP_INLINE void odp_ticketlock_lock(odp_ticketlock_t *ticketlock) { uint32_t ticket; @@ -35,19 +47,10 @@ static inline void _odp_ticketlock_lock(odp_ticketlock_t *ticketlock) /* Spin waiting for our turn. Use load-acquire so that we acquire * all stores from the previous lock owner */ - while (ticket != odp_atomic_load_acq_u32(&ticketlock->cur_ticket)) - odp_cpu_pause(); + _odp_wait_until_equal_acq_u32(&ticketlock->cur_ticket, ticket); } -/** @internal - * Try to acquire ticket lock. - * - * @param tklock Pointer to a ticket lock - * - * @retval 1 lock acquired - * @retval 0 lock not acquired - */ -static inline int _odp_ticketlock_trylock(odp_ticketlock_t *tklock) +_ODP_INLINE int odp_ticketlock_trylock(odp_ticketlock_t *tklock) { /* We read 'next_ticket' and 'cur_ticket' non-atomically which should * not be a problem as they are not independent of each other. @@ -75,12 +78,7 @@ static inline int _odp_ticketlock_trylock(odp_ticketlock_t *tklock) return 0; } -/** @internal - * Release ticket lock - * - * @param ticketlock Pointer to a ticket lock - */ -static inline void _odp_ticketlock_unlock(odp_ticketlock_t *ticketlock) +_ODP_INLINE void odp_ticketlock_unlock(odp_ticketlock_t *ticketlock) { /* Release the lock by incrementing 'cur_ticket'. As we are the * lock owner and thus the only thread that is allowed to write @@ -92,15 +90,7 @@ static inline void _odp_ticketlock_unlock(odp_ticketlock_t *ticketlock) odp_atomic_store_rel_u32(&ticketlock->cur_ticket, cur + 1); } -/** @internal - * Check if ticket lock is locked - * - * @param ticketlock Pointer to a ticket lock - * - * @retval 1 the lock is busy (locked) - * @retval 0 the lock is available (unlocked) - */ -static inline int _odp_ticketlock_is_locked(odp_ticketlock_t *ticketlock) +_ODP_INLINE int odp_ticketlock_is_locked(odp_ticketlock_t *ticketlock) { /* Compare 'cur_ticket' with 'next_ticket'. Ideally we should read * both variables atomically but the information can become stale @@ -111,20 +101,6 @@ 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 <odp/api/plat/static_inline.h> -#if ODP_ABI_COMPAT == 0 - -/** @ingroup odp_locks - * @{ - */ - -#include <odp/api/plat/ticketlock_inlines_api.h> - -/** - * @} - */ - -#endif +/** @endcond */ #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 deleted file mode 100644 index 5efe696ff..000000000 --- a/platform/linux-generic/include/odp/api/plat/ticketlock_inlines_api.h +++ /dev/null @@ -1,36 +0,0 @@ -/* 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/plat/ticketlock_types.h b/platform/linux-generic/include/odp/api/plat/ticketlock_types.h deleted file mode 100644 index 81d479d61..000000000 --- a/platform/linux-generic/include/odp/api/plat/ticketlock_types.h +++ /dev/null @@ -1,35 +0,0 @@ -/* Copyright (c) 2015, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - - -/** - * @file - * - * ODP ticketlock - */ - -#ifndef ODP_TICKETLOCK_TYPES_H_ -#define ODP_TICKETLOCK_TYPES_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <odp/api/atomic.h> - -/** @internal */ -struct odp_ticketlock_s { - odp_atomic_u32_t next_ticket; /**< Next ticket */ - odp_atomic_u32_t cur_ticket; /**< Current ticket */ -}; - -typedef struct odp_ticketlock_s odp_ticketlock_t; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/api/plat/time_inlines.h b/platform/linux-generic/include/odp/api/plat/time_inlines.h new file mode 100644 index 000000000..8ead06f7b --- /dev/null +++ b/platform/linux-generic/include/odp/api/plat/time_inlines.h @@ -0,0 +1,191 @@ +/* Copyright (c) 2018, Linaro Limited + * Copyright (c) 2020-2023, Nokia + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef ODP_PLAT_TIME_INLINES_H_ +#define ODP_PLAT_TIME_INLINES_H_ + +#include <odp/api/align.h> +#include <odp/api/hints.h> +#include <odp/api/time_types.h> + +#include <odp/api/abi/time_inlines.h> + +#include <stdint.h> + +/** @cond _ODP_HIDE_FROM_DOXYGEN_ */ + +#ifndef _ODP_NO_INLINE + /* Inline functions by default */ + #define _ODP_INLINE static inline + #define odp_time_local __odp_time_local + #define odp_time_global __odp_time_global + #define odp_time_to_ns __odp_time_to_ns + #define odp_time_local_ns __odp_time_local_ns + #define odp_time_global_ns __odp_time_global_ns + + #define odp_time_local_strict __odp_time_local_strict + #define odp_time_global_strict __odp_time_global_strict + #define odp_time_local_strict_ns __odp_time_local_strict_ns + #define odp_time_global_strict_ns __odp_time_global_strict_ns + + #define odp_time_cmp __odp_time_cmp + #define odp_time_diff __odp_time_diff + #define odp_time_diff_ns __odp_time_diff_ns + #define odp_time_add_ns __odp_time_add_ns + #define odp_time_sum __odp_time_sum + + #define odp_time_local_from_ns __odp_time_local_from_ns + #define odp_time_global_from_ns __odp_time_global_from_ns + + #define odp_time_local_res __odp_time_local_res + #define odp_time_global_res __odp_time_global_res + + #define odp_time_wait_ns __odp_time_wait_ns + #define odp_time_wait_until __odp_time_wait_until + #define odp_time_startup __odp_time_startup +#else + #define _ODP_INLINE +#endif + +_ODP_INLINE odp_time_t odp_time_local(void) +{ + return _odp_time_cur(); +} + +_ODP_INLINE odp_time_t odp_time_global(void) +{ + return _odp_time_cur(); +} + +_ODP_INLINE odp_time_t odp_time_local_strict(void) +{ + return _odp_time_cur_strict(); +} + +_ODP_INLINE odp_time_t odp_time_global_strict(void) +{ + return _odp_time_cur_strict(); +} + +_ODP_INLINE uint64_t odp_time_local_ns(void) +{ + return _odp_time_to_ns(_odp_time_cur()); +} + +_ODP_INLINE uint64_t odp_time_global_ns(void) +{ + return _odp_time_to_ns(_odp_time_cur()); +} + +_ODP_INLINE uint64_t odp_time_local_strict_ns(void) +{ + return _odp_time_to_ns(_odp_time_cur_strict()); +} + +_ODP_INLINE uint64_t odp_time_global_strict_ns(void) +{ + return _odp_time_to_ns(_odp_time_cur_strict()); +} + +_ODP_INLINE uint64_t odp_time_to_ns(odp_time_t time) +{ + return _odp_time_to_ns(time); +} + +_ODP_INLINE int odp_time_cmp(odp_time_t t2, odp_time_t t1) +{ + if (odp_likely(t2.u64 > t1.u64)) + return 1; + + if (t2.u64 < t1.u64) + return -1; + + return 0; +} + +_ODP_INLINE odp_time_t odp_time_diff(odp_time_t t2, odp_time_t t1) +{ + odp_time_t time; + + time.u64 = t2.u64 - t1.u64; + + return time; +} + +_ODP_INLINE uint64_t odp_time_diff_ns(odp_time_t t2, odp_time_t t1) +{ + odp_time_t time; + + time.u64 = t2.u64 - t1.u64; + + return odp_time_to_ns(time); +} + +_ODP_INLINE odp_time_t odp_time_add_ns(odp_time_t time, uint64_t ns) +{ + odp_time_t t = _odp_time_from_ns(ns); + + t.u64 += time.u64; + + return t; +} + +_ODP_INLINE odp_time_t odp_time_sum(odp_time_t t1, odp_time_t t2) +{ + odp_time_t time; + + time.u64 = t1.u64 + t2.u64; + + return time; +} + +_ODP_INLINE odp_time_t odp_time_local_from_ns(uint64_t ns) +{ + return _odp_time_from_ns(ns); +} + +_ODP_INLINE odp_time_t odp_time_global_from_ns(uint64_t ns) +{ + return _odp_time_from_ns(ns); +} + +_ODP_INLINE uint64_t odp_time_local_res(void) +{ + return _odp_time_res(); +} + +_ODP_INLINE uint64_t odp_time_global_res(void) +{ + return _odp_time_res(); +} + +_ODP_INLINE void odp_time_wait_until(odp_time_t time) +{ + odp_time_t cur; + + do { + cur = _odp_time_cur(); + } while (odp_time_cmp(time, cur) > 0); +} + +_ODP_INLINE void odp_time_wait_ns(uint64_t ns) +{ + odp_time_t cur = _odp_time_cur(); + odp_time_t wait = _odp_time_from_ns(ns); + odp_time_t end_time = odp_time_sum(cur, wait); + + odp_time_wait_until(end_time); +} + +_ODP_INLINE void odp_time_startup(odp_time_startup_t *startup) +{ + _odp_time_startup(startup); +} + +/** @endcond */ + +#endif diff --git a/platform/linux-generic/include/odp/api/plat/time_types.h b/platform/linux-generic/include/odp/api/plat/time_types.h deleted file mode 100644 index 4847f3b1f..000000000 --- a/platform/linux-generic/include/odp/api/plat/time_types.h +++ /dev/null @@ -1,43 +0,0 @@ -/* Copyright (c) 2015, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP time service - */ - -#ifndef ODP_TIME_TYPES_H_ -#define ODP_TIME_TYPES_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -/** @addtogroup odp_time - * @{ - **/ - -/** - * @internal Time structure used to isolate odp-linux implementation from - * the linux timespec structure, which is dependent on POSIX extension level. - */ -typedef struct odp_time_t { - int64_t tv_sec; /**< @internal Seconds */ - int64_t tv_nsec; /**< @internal Nanoseconds */ -} odp_time_t; - -#define ODP_TIME_NULL ((odp_time_t){0, 0}) - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/api/plat/timer_inline_types.h b/platform/linux-generic/include/odp/api/plat/timer_inline_types.h new file mode 100644 index 000000000..330cbe4ce --- /dev/null +++ b/platform/linux-generic/include/odp/api/plat/timer_inline_types.h @@ -0,0 +1,40 @@ +/* Copyright (c) 2022, Nokia + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef ODP_PLAT_TIMER_INLINE_TYPES_H_ +#define ODP_PLAT_TIMER_INLINE_TYPES_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdint.h> + +/** @cond _ODP_HIDE_FROM_DOXYGEN_ */ + +/* Timeout header field accessor */ +#define _odp_timeout_hdr_field(hdr, cast, field) \ + (*(cast *)(uintptr_t)((uint8_t *)hdr + \ + _odp_timeout_inline_offset.field)) + +/* Timeout header field offsets for inline functions */ +typedef struct _odp_timeout_inline_offset_t { + uint16_t expiration; + uint16_t timer; + uint16_t user_ptr; + uint16_t uarea_addr; + +} _odp_timeout_inline_offset_t; + +extern const _odp_timeout_inline_offset_t _odp_timeout_inline_offset; + +/** @endcond */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/platform/linux-generic/include/odp/api/plat/timer_inlines.h b/platform/linux-generic/include/odp/api/plat/timer_inlines.h new file mode 100644 index 000000000..d2982079f --- /dev/null +++ b/platform/linux-generic/include/odp/api/plat/timer_inlines.h @@ -0,0 +1,106 @@ +/* Copyright (c) 2022-2023, Nokia + * All rights reserved. + * + * SPDX-License-Identifier: BSD-3-Clause + */ + +#ifndef ODP_PLAT_TIMER_INLINES_H_ +#define ODP_PLAT_TIMER_INLINES_H_ + +#include <odp/api/event.h> +#include <odp/api/timer_types.h> + +#include <odp/api/abi/time_inlines.h> + +#include <odp/api/plat/debug_inlines.h> +#include <odp/api/plat/timer_inline_types.h> + +#include <stdint.h> + +/** @cond _ODP_HIDE_FROM_DOXYGEN_ */ + +#ifndef _ODP_NO_INLINE + /* Inline functions by default */ + #define _ODP_INLINE static inline + #define odp_timeout_timer __odp_timeout_timer + #define odp_timeout_tick __odp_timeout_tick + #define odp_timeout_user_ptr __odp_timeout_user_ptr + #define odp_timeout_user_area __odp_timeout_user_area + #define odp_timer_current_tick __odp_timer_current_tick + #define odp_timer_tick_to_ns __odp_timer_tick_to_ns + #define odp_timer_ns_to_tick __odp_timer_ns_to_tick + #define odp_timeout_from_event __odp_timeout_from_event + #define odp_timeout_from_event_multi __odp_timeout_from_event_multi + #define odp_timeout_to_event __odp_timeout_to_event +#else + #define _ODP_INLINE +#endif + +_ODP_INLINE odp_timer_t odp_timeout_timer(odp_timeout_t tmo) +{ + return _odp_timeout_hdr_field(tmo, odp_timer_t, timer); +} + +_ODP_INLINE uint64_t odp_timeout_tick(odp_timeout_t tmo) +{ + return _odp_timeout_hdr_field(tmo, uint64_t, expiration); +} + +_ODP_INLINE void *odp_timeout_user_ptr(odp_timeout_t tmo) +{ + return _odp_timeout_hdr_field(tmo, void *, user_ptr); +} + +_ODP_INLINE void *odp_timeout_user_area(odp_timeout_t tmo) +{ + return _odp_timeout_hdr_field(tmo, void *, uarea_addr); +} + +_ODP_INLINE uint64_t odp_timer_current_tick(odp_timer_pool_t tpid) +{ + (void)tpid; + + /* This is equal to odp_time_global_ns(). Cannot call inlined API function from here. */ + return _odp_time_to_ns(_odp_time_cur()); +} + +_ODP_INLINE uint64_t odp_timer_tick_to_ns(odp_timer_pool_t tp, uint64_t ticks) +{ + (void)tp; + + /* Timer ticks in API are nsec */ + return ticks; +} + +_ODP_INLINE uint64_t odp_timer_ns_to_tick(odp_timer_pool_t tp, uint64_t ns) +{ + (void)tp; + + /* Timer ticks in API are nsec */ + return ns; +} + +_ODP_INLINE odp_timeout_t odp_timeout_from_event(odp_event_t ev) +{ + _ODP_ASSERT(odp_event_type(ev) == ODP_EVENT_TIMEOUT); + + return (odp_timeout_t)ev; +} + +_ODP_INLINE void odp_timeout_from_event_multi(odp_timeout_t tmo[], const odp_event_t ev[], int num) +{ + for (int i = 0; i < num; i++) { + _ODP_ASSERT(odp_event_type(ev[i]) == ODP_EVENT_TIMEOUT); + + tmo[i] = odp_timeout_from_event(ev[i]); + } +} + +_ODP_INLINE odp_event_t odp_timeout_to_event(odp_timeout_t tmo) +{ + return (odp_event_t)tmo; +} + +/** @endcond */ + +#endif diff --git a/platform/linux-generic/include/odp/api/plat/timer_types.h b/platform/linux-generic/include/odp/api/plat/timer_types.h deleted file mode 100644 index 8821bed60..000000000 --- a/platform/linux-generic/include/odp/api/plat/timer_types.h +++ /dev/null @@ -1,51 +0,0 @@ -/* Copyright (c) 2013, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - - -/** - * @file - * - * ODP timer service - */ - -#ifndef ODP_TIMER_TYPES_H_ -#define ODP_TIMER_TYPES_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <odp/api/plat/strong_types.h> - -/** @addtogroup odp_timer - * @{ - **/ - -struct odp_timer_pool_s; /**< Forward declaration */ - -typedef struct odp_timer_pool_s *odp_timer_pool_t; - -#define ODP_TIMER_POOL_INVALID NULL - -#define ODP_TIMER_POOL_NAME_LEN 32 - -typedef ODP_HANDLE_T(odp_timer_t); - -#define ODP_TIMER_INVALID _odp_cast_scalar(odp_timer_t, 0xffffffff) - -typedef ODP_HANDLE_T(odp_timeout_t); - -#define ODP_TIMEOUT_INVALID _odp_cast_scalar(odp_timeout_t, 0xffffffff) - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/api/plat/traffic_mngr_types.h b/platform/linux-generic/include/odp/api/plat/traffic_mngr_types.h deleted file mode 100644 index b766afecd..000000000 --- a/platform/linux-generic/include/odp/api/plat/traffic_mngr_types.h +++ /dev/null @@ -1,185 +0,0 @@ -/* Copyright (c) 2015, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP traffic mngr - */ - -#ifndef ODP_TRAFFIC_MNGR_TYPES_H_ -#define ODP_TRAFFIC_MNGR_TYPES_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <odp/api/std_types.h> -#include <odp/api/plat/strong_types.h> - -/** @addtogroup odp_traffic_mngr - * Macros and operations on a TM system. - * @{ - */ - -/** The ODP_TM_MAX_NUM_SYSTEMS constant specifies the maximum number of TM - * systems that may be created. On some platforms this might be much more - * limited to as little as one hardware TM system. - */ -#define ODP_TM_MAX_NUM_SYSTEMS 64 - -/** The ODP_TM_MAX_PRIORITIES constant specifies the largest range of - * priorities that any TM system can support. All strict priority values MUST - * in the range 0..ODP_TM_MAX_PRIORITIES-1. - */ -#define ODP_TM_MAX_PRIORITIES 16 - -/** The ODP_TM MAX_LEVELS constant specifies the largest range of - * tm_node levels that any TM system can support. Hence all tm_node level - * values MUST be in the range 0..ODP_TM_MAX_LEVELS-1. Smaller tm_node - * levels are associated with tm_nodes closer to the TM system egress. - */ -#define ODP_TM_MAX_LEVELS 8 - -/** - * The smallest SCHED weight is 1 (i.e. 0 is not a legal WFQ/WRR value). - */ -#define ODP_TM_MIN_SCHED_WEIGHT 1 - -/** The ODP_TM_MAX_SCHED_WEIGHT constant is the largest weight any TM system - * can support (at least from a configuration standpoint). A given TM system - * could have a smaller value. - */ -#define ODP_TM_MAX_SCHED_WEIGHT 255 - -/** The ODP_TM_MAX_TM_QUEUES constant is the largest number of tm_queues - * that can handled by any one TM system. - */ -#define ODP_TM_MAX_TM_QUEUES (16 * 1024 * 1024) - -/** The ODP_TM_MAX_NUM_OUTPUTS constant is the largest number of outputs that - * can be configured for any one TM system. - */ -#define ODP_TM_MAX_NUM_OUTPUTS 256 - -/** The ODP_TM_MAX_NUM_TM_NODES constant is the largest number of tm_nodes that - * can be in existence for any one TM system. - */ -#define ODP_TM_MAX_NUM_TM_NODES (1024 * 1024) - -/** The ODP_TM_MAX_TM_NODE_FANIN constant is the largest number of fan-in - * "inputs" that can be simultaneously connected to a single tm_node. - * *TBD* Does this need to be as large as ODP_TM_MAX_TM_QUEUES? *TBD* - */ -#define ODP_TM_MAX_TM_NODE_FANIN (1024 * 1024) - -/** The ODP_TM_MIN_SHAPER_BW constant is the smallest amount of bandwidth that - * can a shaper's peak or commit rate can be set to. It is in units of - * 1000 bytes/second so that it and the ODP_TM_MAX_SHAPER_BW can both fit in - * 32 bits. - */ -#define ODP_TM_MIN_SHAPER_BW 1 - -/** The ODP_TM_MAX_SHAPER_BW constant is the largest amound of bandwidth that - * any shaper's peak or commit rate can be set to. It is in units of - * 1000 bytes/second so that it and the ODP_TM_MIN_SHAPER_BW can both fit in - * 32 bits. - */ -#define ODP_TM_MAX_SHAPER_BW 12500000 - -/** The ODP_NUM_SHAPER_COLORS constant just counts the number of enumeration - * values defined in the odp_tm_shaper_color_t type. - */ -#define ODP_NUM_SHAPER_COLORS 3 - -/** The INVALID_PRIORITY constant is used when one needs to indicate an - * invalid priority value. - */ -#define ODP_TM_INVALID_PRIORITY 255 - -/** The odp_tm_percent_t type is used when specifying fields that are - * percentages. It is a fixed point integer whose units are 1/100 of a - * percent. Hence 100% is represented as the integer value 10000. Note - * that because it is often used as a ratio of the current queue value and - * maximum queue threshold, it can be > 100%, but in any event will never - * be larger than 500% (i.e. it MUST be capped at 50000). - */ -typedef uint16_t odp_tm_percent_t; - -/** The odp_tm_handle_t type is a generic type that can stand for any of the - * other ODP_TM handle types. - */ -typedef uint64_t odp_tm_handle_t; - -/** Each odp_tm_t value represents a specific TM system. Almost all - * functions in this API require a odp_tm_t value - either directly - * as a function parameter or indirectly by having another ODP TM handle value - * as a function parameter. - */ -typedef odp_tm_handle_t odp_tm_t; - -/** Each odp_tm_queue_t value is an opaque ODP handle representing a specific - * tm_queue within a specific TM system. - */ -typedef odp_tm_handle_t odp_tm_queue_t; - -/** Each odp_tm_node_t value is an opaque ODP handle representing a specific - * tm_node within a specific TM system. - */ -typedef odp_tm_handle_t odp_tm_node_t; - -/** Each odp_tm_shaper_t value is an opaque ODP handle representing a specific - * shaper profile usable across all TM systems described by this API. A given - * shaper profile can then be attached to any tm_queue or tm_node. - */ -typedef odp_tm_handle_t odp_tm_shaper_t; - -/** Each odp_tm_sched_t value is an opaque ODP handle representing a specific - * tm_node scheduler profile usable across all TM systems described by this - * API. A given tm_node scheduler profile can then be attached to any tm_node. - */ -typedef odp_tm_handle_t odp_tm_sched_t; - -/** Each odp_tm_threshold_t value is an opaque ODP handle representing a - * specific queue threshold profile usable across all TM systems described by - * this API. A given queue threshold profile can then be attached to any - * tm_queue or tm_node. - */ -typedef odp_tm_handle_t odp_tm_threshold_t; - -/** Each odp_tm_wred_t value is an opaque ODP handle representing a specific - * WRED profile usable across all TM systems described by this API. A given - * WRED profile can then be attached to any tm_queue or tm_node. - */ -typedef odp_tm_handle_t odp_tm_wred_t; - -/** The ODP_TM_INVALID constant can be used with any ODP TM handle type and - * indicates that this value does NOT represent a valid TM object. - */ -#define ODP_TM_INVALID 0 - -/** - * @def ODP_TM_ROOT - * Constant that is used to refer to the egress/root node of the TM subsystem's - * tree/hierarchy of nodes. - */ -#define ODP_TM_ROOT ((odp_tm_handle_t)-1) - -/** Get printable format of odp_queue_t */ -static inline uint64_t odp_tm_handle_to_u64(odp_tm_handle_t hdl) -{ - return hdl; -} - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/api/plat/version_types.h b/platform/linux-generic/include/odp/api/plat/version_types.h deleted file mode 100644 index e3327eb33..000000000 --- a/platform/linux-generic/include/odp/api/plat/version_types.h +++ /dev/null @@ -1,30 +0,0 @@ -/* Copyright (c) 2015, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#ifndef ODP_VERSION_TYPESH_ -#define ODP_VERSION_TYPESH_ - -#ifdef __cplusplus -extern "C" { -#endif - -/** @internal Version string expand */ -#define ODP_VERSION_STR_EXPAND(x) #x - -/** @internal Version to string */ -#define ODP_VERSION_TO_STR(x) ODP_VERSION_STR_EXPAND(x) - -/** @internal API version string */ -#define ODP_VERSION_API_STR \ -ODP_VERSION_TO_STR(ODP_VERSION_API_GENERATION) "." \ -ODP_VERSION_TO_STR(ODP_VERSION_API_MAJOR) "." \ -ODP_VERSION_TO_STR(ODP_VERSION_API_MINOR) - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/api/pool.h b/platform/linux-generic/include/odp/api/pool.h deleted file mode 100644 index d712b6501..000000000 --- a/platform/linux-generic/include/odp/api/pool.h +++ /dev/null @@ -1,37 +0,0 @@ -/* Copyright (c) 2015, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP pool - */ - -#ifndef ODP_PLAT_POOL_H_ -#define ODP_PLAT_POOL_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -/** @ingroup odp_buffer - * @{ - */ - -/** - * @} - */ - -#include <odp/api/plat/pool_types.h> -#include <odp/api/plat/shared_memory_types.h> -#include <odp/api/plat/event_types.h> -#include <odp/api/spec/pool.h> - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/api/queue.h b/platform/linux-generic/include/odp/api/queue.h deleted file mode 100644 index adceafbd1..000000000 --- a/platform/linux-generic/include/odp/api/queue.h +++ /dev/null @@ -1,44 +0,0 @@ -/* Copyright (c) 2013, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP queue - */ - -#ifndef ODP_PLAT_QUEUE_H_ -#define ODP_PLAT_QUEUE_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <odp/api/std_types.h> -#include <odp/api/plat/event_types.h> -#include <odp/api/plat/queue_types.h> -#include <odp/api/plat/buffer_types.h> -#include <odp/api/plat/pool_types.h> - -/** @ingroup odp_queue - * @{ - */ - -/* REMOVE FROM API SPEC. Typedef needed only for suppressing Doxygen - * warning. */ -typedef void odp_queue_group_t; - -/** - * @} - */ - -#include <odp/api/spec/queue.h> - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/api/random.h b/platform/linux-generic/include/odp/api/random.h deleted file mode 100644 index c8529b3f9..000000000 --- a/platform/linux-generic/include/odp/api/random.h +++ /dev/null @@ -1,34 +0,0 @@ -/* Copyright (c) 2015, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP random number API - */ - -#ifndef ODP_PLAT_RANDOM_H_ -#define ODP_PLAT_RANDOM_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -/** @ingroup odp_random ODP RANDOM - * @{ - */ - -/** - * @} - */ - -#include <odp/api/spec/random.h> - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/api/rwlock.h b/platform/linux-generic/include/odp/api/rwlock.h deleted file mode 100644 index 4a86173f5..000000000 --- a/platform/linux-generic/include/odp/api/rwlock.h +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright (c) 2014, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP RW Locks - */ - -#ifndef ODP_PLAT_RWLOCK_H_ -#define ODP_PLAT_RWLOCK_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <odp/api/plat/rwlock_types.h> - -#include <odp/api/spec/rwlock.h> - -#ifdef __cplusplus -} -#endif - -#endif /* ODP_RWLOCK_H_ */ diff --git a/platform/linux-generic/include/odp/api/rwlock_recursive.h b/platform/linux-generic/include/odp/api/rwlock_recursive.h deleted file mode 100644 index 4a081532d..000000000 --- a/platform/linux-generic/include/odp/api/rwlock_recursive.h +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright (c) 2015, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP resursive read/write lock - */ - -#ifndef ODP_PLAT_RWLOCK_RECURSIVE_H_ -#define ODP_PLAT_RWLOCK_RECURSIVE_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <odp/api/plat/rwlock_recursive_types.h> - -#include <odp/api/spec/rwlock_recursive.h> - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/api/schedule.h b/platform/linux-generic/include/odp/api/schedule.h deleted file mode 100644 index 002648517..000000000 --- a/platform/linux-generic/include/odp/api/schedule.h +++ /dev/null @@ -1,36 +0,0 @@ -/* Copyright (c) 2013, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP schedule - */ - -#ifndef ODP_PLAT_SCHEDULE_H_ -#define ODP_PLAT_SCHEDULE_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <odp/api/plat/schedule_types.h> - -/** @ingroup odp_scheduler - * @{ - */ - -/** - * @} - */ - -#include <odp/api/spec/schedule.h> - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/api/schedule_types.h b/platform/linux-generic/include/odp/api/schedule_types.h deleted file mode 100644 index 536007d66..000000000 --- a/platform/linux-generic/include/odp/api/schedule_types.h +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright (c) 2013, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP schedule - */ - -#ifndef ODP_PLAT_SCHEDULE_TYPES_H_ -#define ODP_PLAT_SCHEDULE_TYPES_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <odp/api/plat/schedule_types.h> - -#include <odp/api/spec/schedule_types.h> - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/api/shared_memory.h b/platform/linux-generic/include/odp/api/shared_memory.h deleted file mode 100644 index affc290e7..000000000 --- a/platform/linux-generic/include/odp/api/shared_memory.h +++ /dev/null @@ -1,36 +0,0 @@ -/* Copyright (c) 2013-2014, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP shared memory - */ - -#ifndef ODP_PLAT_SHARED_MEMORY_H_ -#define ODP_PLAT_SHARED_MEMORY_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <odp/api/plat/shared_memory_types.h> - -/** @ingroup odp_shared_memory - * @{ - */ - -/** - * @} - */ - -#include <odp/api/spec/shared_memory.h> - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/api/spinlock.h b/platform/linux-generic/include/odp/api/spinlock.h deleted file mode 100644 index 830f4edd2..000000000 --- a/platform/linux-generic/include/odp/api/spinlock.h +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright (c) 2013, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP spinlock - */ - -#ifndef ODP_PLAT_SPINLOCK_H_ -#define ODP_PLAT_SPINLOCK_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <odp/api/plat/spinlock_types.h> - -#include <odp/api/spec/spinlock.h> - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/api/spinlock_recursive.h b/platform/linux-generic/include/odp/api/spinlock_recursive.h deleted file mode 100644 index d97b0173a..000000000 --- a/platform/linux-generic/include/odp/api/spinlock_recursive.h +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright (c) 2015, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP resursive spinlock - */ - -#ifndef ODP_PLAT_SPINLOCK_RECURSIVE_H_ -#define ODP_PLAT_SPINLOCK_RECURSIVE_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <odp/api/plat/spinlock_recursive_types.h> - -#include <odp/api/spec/spinlock_recursive.h> - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/api/std_clib.h b/platform/linux-generic/include/odp/api/std_clib.h deleted file mode 100644 index fea472543..000000000 --- a/platform/linux-generic/include/odp/api/std_clib.h +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright (c) 2015, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#ifndef ODP_PLAT_STD_CLIB_H_ -#define ODP_PLAT_STD_CLIB_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <odp/api/spec/std_types.h> -#include <string.h> - -#include <odp/api/plat/static_inline.h> -#if ODP_ABI_COMPAT == 0 -#include <odp/api/plat/std_clib_inlines.h> -#endif - -#include <odp/api/spec/std_clib.h> - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/api/std_types.h b/platform/linux-generic/include/odp/api/std_types.h deleted file mode 100644 index b61f33f4c..000000000 --- a/platform/linux-generic/include/odp/api/std_types.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (c) 2013, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * Standard C language types and definitions for ODP. - */ - -#ifndef ODP_PLAT_STD_TYPES_H_ -#define ODP_PLAT_STD_TYPES_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -/* uint64_t, uint32_t, etc */ -#include <stdint.h> - -/* true and false for odp_bool_t */ -#include <stdbool.h> - -/** @addtogroup odp_system ODP SYSTEM - * @{ - */ - -typedef int odp_bool_t; - -/** - * @} - */ - -#include <odp/api/spec/std_types.h> - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/api/sync.h b/platform/linux-generic/include/odp/api/sync.h deleted file mode 100644 index e1afcc722..000000000 --- a/platform/linux-generic/include/odp/api/sync.h +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright (c) 2013, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP synchronisation - */ - -#ifndef ODP_PLAT_SYNC_H_ -#define ODP_PLAT_SYNC_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -/** @ingroup odp_barrier - * @{ - */ - -#include <odp/api/plat/static_inline.h> -#if ODP_ABI_COMPAT == 0 -#include <odp/api/plat/sync_inlines.h> -#endif - -/** - * @} - */ - -#include <odp/api/spec/sync.h> - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/api/system_info.h b/platform/linux-generic/include/odp/api/system_info.h deleted file mode 100644 index 36ddc814b..000000000 --- a/platform/linux-generic/include/odp/api/system_info.h +++ /dev/null @@ -1,29 +0,0 @@ -/* Copyright (c) 2013, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP system information - */ - -#ifndef ODP_PLAT_SYSTEM_INFO_H_ -#define ODP_PLAT_SYSTEM_INFO_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <odp/api/std_types.h> - - -#include <odp/api/spec/system_info.h> - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/api/thread.h b/platform/linux-generic/include/odp/api/thread.h deleted file mode 100644 index c54abc890..000000000 --- a/platform/linux-generic/include/odp/api/thread.h +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright (c) 2013, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP thread API - */ - -#ifndef ODP_PLAT_THREAD_H_ -#define ODP_PLAT_THREAD_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <odp/api/plat/thread_types.h> - -#include <odp/api/spec/thread.h> - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/api/thrmask.h b/platform/linux-generic/include/odp/api/thrmask.h deleted file mode 100644 index b1c207775..000000000 --- a/platform/linux-generic/include/odp/api/thrmask.h +++ /dev/null @@ -1,36 +0,0 @@ -/* Copyright (c) 2015, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP thread masks - */ - -#ifndef ODP_PLAT_THRMASK_H_ -#define ODP_PLAT_THRMASK_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <odp/api/plat/thrmask_types.h> - -/** @ingroup odp_thread - * @{ - */ - -/** - * @} - */ - -#include <odp/api/spec/thrmask.h> - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/api/ticketlock.h b/platform/linux-generic/include/odp/api/ticketlock.h deleted file mode 100644 index e0f5d81fd..000000000 --- a/platform/linux-generic/include/odp/api/ticketlock.h +++ /dev/null @@ -1,32 +0,0 @@ -/* Copyright (c) 2013, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP ticketlock - */ - -#ifndef ODP_PLAT_TICKETLOCK_H_ -#define ODP_PLAT_TICKETLOCK_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <odp/api/plat/ticketlock_types.h> - -#if ODP_ABI_COMPAT == 0 -#include <odp/api/plat/ticketlock_inlines.h> -#endif - -#include <odp/api/spec/ticketlock.h> - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/api/time.h b/platform/linux-generic/include/odp/api/time.h deleted file mode 100644 index 8d1c33e68..000000000 --- a/platform/linux-generic/include/odp/api/time.h +++ /dev/null @@ -1,31 +0,0 @@ -/* Copyright (c) 2013, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP time - */ - -#ifndef ODP_PLAT_TIME_H_ -#define ODP_PLAT_TIME_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <odp/api/std_types.h> - - - -#include <odp/api/plat/time_types.h> -#include <odp/api/spec/time.h> - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/api/timer.h b/platform/linux-generic/include/odp/api/timer.h deleted file mode 100644 index 1450727f8..000000000 --- a/platform/linux-generic/include/odp/api/timer.h +++ /dev/null @@ -1,40 +0,0 @@ -/* Copyright (c) 2013, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP timer service - */ - -#ifndef ODP_PLAT_TIMER_H_ -#define ODP_PLAT_TIMER_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <odp/api/std_types.h> -#include <odp/api/plat/event_types.h> -#include <odp/api/plat/pool_types.h> -#include <odp/api/plat/queue_types.h> -#include <odp/api/plat/timer_types.h> - -/** @ingroup odp_timer - * @{ - */ - -/** - * @} - */ - -#include <odp/api/spec/timer.h> - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/api/traffic_mngr.h b/platform/linux-generic/include/odp/api/traffic_mngr.h deleted file mode 100644 index 3e6f5fbbe..000000000 --- a/platform/linux-generic/include/odp/api/traffic_mngr.h +++ /dev/null @@ -1,35 +0,0 @@ -/* Copyright (c) 2015, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP Traffic manager - */ - -#ifndef ODP_PLAT_TRAFFIC_MNGR_H_ -#define ODP_PLAT_TRAFFIC_MNGR_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -/** @ingroup odp_traffic_mngr - * @{ - */ - -/** - * @} - */ - -#include <odp/api/plat/traffic_mngr_types.h> -#include <odp/api/spec/traffic_mngr.h> - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/api/version.h b/platform/linux-generic/include/odp/api/version.h deleted file mode 100644 index fc4ea5865..000000000 --- a/platform/linux-generic/include/odp/api/version.h +++ /dev/null @@ -1,27 +0,0 @@ -/* Copyright (c) 2013, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP version - */ - -#ifndef ODP_PLAT_VERSION_H_ -#define ODP_PLAT_VERSION_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <odp/api/plat/version_types.h> -#include <odp/api/spec/version.h> - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/drv/README b/platform/linux-generic/include/odp/drv/README deleted file mode 100644 index fd38e8e57..000000000 --- a/platform/linux-generic/include/odp/drv/README +++ /dev/null @@ -1,2 +0,0 @@ -This directory contains the files defining the ODP driver interface, -for linux-generic. diff --git a/platform/linux-generic/include/odp/drv/compiler.h b/platform/linux-generic/include/odp/drv/compiler.h deleted file mode 100644 index 24e84c554..000000000 --- a/platform/linux-generic/include/odp/drv/compiler.h +++ /dev/null @@ -1,34 +0,0 @@ -/* Copyright (c) 2016, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * Compiler related - */ - -#ifndef ODPDRV_PLAT_COMPILER_H_ -#define ODPDRV_PLAT_COMPILER_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -/** @addtogroup odpdrv_compiler_optim ODPDRV COMPILER / OPTIMIZATION - * @{ - */ - -/** - * @} - */ - -#include <odp/drv/spec/compiler.h> - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/drv/std_types.h b/platform/linux-generic/include/odp/drv/std_types.h deleted file mode 100644 index 4fe4affda..000000000 --- a/platform/linux-generic/include/odp/drv/std_types.h +++ /dev/null @@ -1,42 +0,0 @@ -/* Copyright (c) 2016, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * Standard C language types and definitions for ODP driver interface. - */ - -#ifndef ODPDRV_PLAT_STD_TYPES_H_ -#define ODPDRV_PLAT_STD_TYPES_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include <stddef.h> -#include <stdbool.h> -#include <stdint.h> -#include <inttypes.h> -#include <limits.h> - -/** @addtogroup odpdrv_system ODPDRV SYSTEM - * @{ - */ - -typedef int odpdrv_bool_t; - -/** - * @} - */ - -#include <odp/drv/spec/std_types.h> - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/visibility_begin.h b/platform/linux-generic/include/odp/visibility_begin.h deleted file mode 100644 index 1bbb43def..000000000 --- a/platform/linux-generic/include/odp/visibility_begin.h +++ /dev/null @@ -1,15 +0,0 @@ -/* Copyright (c) 2016, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/* - * @file - * - * Linker visibility directives - */ - -#if __GNUC__ >= 4 -#pragma GCC visibility push(default) -#endif diff --git a/platform/linux-generic/include/odp/visibility_end.h b/platform/linux-generic/include/odp/visibility_end.h deleted file mode 100644 index 748af5103..000000000 --- a/platform/linux-generic/include/odp/visibility_end.h +++ /dev/null @@ -1,15 +0,0 @@ -/* Copyright (c) 2016, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/* - * @file - * - * Linker visibility directives - */ - -#if __GNUC__ >= 4 -#pragma GCC visibility pop -#endif |