From patchwork Fri Nov 3 10:00:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Github ODP bot X-Patchwork-Id: 117868 Delivered-To: patch@linaro.org Received: by 10.80.245.45 with SMTP id t42csp3119004edm; Fri, 3 Nov 2017 03:10:30 -0700 (PDT) X-Google-Smtp-Source: ABhQp+ScPC2PXZV0rpcI7EGw8Rjm0A2iw7bjbxLj0YKfTZJ1DzWxMEihAythjpkFFveT4tk8nZYh X-Received: by 10.237.47.195 with SMTP id m61mr8955363qtd.143.1509703829869; Fri, 03 Nov 2017 03:10:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1509703829; cv=none; d=google.com; s=arc-20160816; b=rdlOEKvo+T1W8jpnKuTzsgtPwK69cXV2cyqsX/a8tsm1zkGK8E+CyK60+jxu39/bc9 9jM3uF8IdMGJR0iNk3c08uoZ+kegclcOjmDYHddPXLfjerj60wi52NASBu2R/xja1M2C vmQXUjWUdcMZg2Ksz4b1rufq1oNLHIUmXLQ+7M+MfJaibw4isz4+HOKghWqwyTYlnNyP pXiy0YE6u0aaMzhASeub3jSH51Oc+KNy99u4jDKM/53oGdtfXQI2iSeiCNSTRfV452pr jhGW4HNj94fUhhblAzQ5U0fsrD5T7cpJ2+K4azXhBuViBOwRDiotBRaAdfG/u6UK5/Cd oTNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:github-pr-num :references:in-reply-to:message-id:date:to:from:delivered-to :arc-authentication-results; bh=Mmy96C5RArITxbhVdwLClHV0ZJZV+XVBOVq0oxvdZxE=; b=jslB3WJNpxOBGyO3r0URPfIEYcCkrYcm8o8tzwm5wT2nqtSKJxIL+SkxZJfOyS37Y7 QQ/d1df2/yXNtsFRdKaUGlO84mo+XzAY90eGbNwI93Bby1AZvLA2EiazwrxfnturZ+cP AF8mucsZUoBhCNxHIQCo42hhK0jY2ux0fDQYxDXqRBFQiK5kS3BwRSR8FkZTpgJMWFM6 ZY3NCLoUh9WD28YIe+bj+vSlbasI5emStQ+dxy6Oo+cJYUpfyHp/eV6OsmOzuJ5/KOAd N94mfqkNWvBAiOpxGd3stg0PBKKg8dY9LeWIT4v2qWr5mEeu3M2vzQUHbfOBDO0pIvWB CAgg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Return-Path: Received: from lists.linaro.org (ec2-54-197-127-237.compute-1.amazonaws.com. [54.197.127.237]) by mx.google.com with ESMTP id t30si172872qtd.285.2017.11.03.03.10.29; Fri, 03 Nov 2017 03:10:29 -0700 (PDT) Received-SPF: pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) client-ip=54.197.127.237; Authentication-Results: mx.google.com; spf=pass (google.com: domain of lng-odp-bounces@lists.linaro.org designates 54.197.127.237 as permitted sender) smtp.mailfrom=lng-odp-bounces@lists.linaro.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=yandex.ru Received: by lists.linaro.org (Postfix, from userid 109) id 5A11D608DF; Fri, 3 Nov 2017 10:10:29 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on ip-10-142-244-252 X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,URIBL_BLOCKED autolearn=disabled version=3.4.0 Received: from [127.0.0.1] (localhost [127.0.0.1]) by lists.linaro.org (Postfix) with ESMTP id 1EDBA61009; Fri, 3 Nov 2017 10:03:58 +0000 (UTC) X-Original-To: lng-odp@lists.linaro.org Delivered-To: lng-odp@lists.linaro.org Received: by lists.linaro.org (Postfix, from userid 109) id 9826461009; Fri, 3 Nov 2017 10:03:24 +0000 (UTC) Received: from forward103p.mail.yandex.net (forward103p.mail.yandex.net [77.88.28.106]) by lists.linaro.org (Postfix) with ESMTPS id 55E3461009 for ; Fri, 3 Nov 2017 10:00:22 +0000 (UTC) Received: from mxback15j.mail.yandex.net (mxback15j.mail.yandex.net [IPv6:2a02:6b8:0:1619::91]) by forward103p.mail.yandex.net (Yandex) with ESMTP id 6DC642180E58 for ; Fri, 3 Nov 2017 13:00:20 +0300 (MSK) Received: from smtp2o.mail.yandex.net (smtp2o.mail.yandex.net [2a02:6b8:0:1a2d::26]) by mxback15j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id lNGRxfCEJv-0Ja4OsCA; Fri, 03 Nov 2017 13:00:19 +0300 Received: by smtp2o.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id yMyB5aoRpJ-0Iam7ePS; Fri, 03 Nov 2017 13:00:18 +0300 (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (Client certificate not present) From: Github ODP bot To: lng-odp@lists.linaro.org Date: Fri, 3 Nov 2017 13:00:09 +0300 Message-Id: <1509703209-5390-7-git-send-email-odpbot@yandex.ru> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1509703209-5390-1-git-send-email-odpbot@yandex.ru> References: <1509703209-5390-1-git-send-email-odpbot@yandex.ru> Github-pr-num: 272 Subject: [lng-odp] [PATCH API-NEXT v2 6/6] drv: remove remaining of files from api-next X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "The OpenDataPlane \(ODP\) List" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: lng-odp-bounces@lists.linaro.org Sender: "lng-odp" From: Maxim Uvarov Signed-off-by: Maxim Uvarov --- /** Email created from pull request 272 (muvarov:api-next_removedrv) ** https://github.com/Linaro/odp/pull/272 ** Patch: https://github.com/Linaro/odp/pull/272.patch ** Base sha: d22c949cc466bf28de559855a1cb525740578137 ** Merge commit sha: 0c1789481c8b7bca6dd96983992505b5132be3ab **/ doc/Doxyfile_common | 5 +- include/Makefile.am | 16 +- include/odp/drv/spec/align.h | 78 -- include/odp/drv/spec/atomic.h | 634 ----------- include/odp/drv/spec/barrier.h | 66 -- include/odp/drv/spec/byteorder.h | 181 --- include/odp/drv/spec/driver.h | 389 ------- include/odp/drv/spec/shm.h | 330 ------ include/odp/drv/spec/spinlock.h | 86 -- include/odp/drv/spec/sync.h | 91 -- include/odp_drv.h | 35 - platform/linux-generic/_ishm.c | 3 +- platform/linux-generic/_ishmpool.c | 1 - platform/linux-generic/drv_atomic.c | 26 - platform/linux-generic/drv_barrier.c | 50 - platform/linux-generic/drv_driver.c | 64 -- platform/linux-generic/drv_shm.c | 146 --- platform/linux-generic/drv_spinlock.c | 39 - platform/linux-generic/include/odp/drv/align.h | 58 - platform/linux-generic/include/odp/drv/atomic.h | 430 -------- platform/linux-generic/include/odp/drv/barrier.h | 30 - platform/linux-generic/include/odp/drv/byteorder.h | 146 --- platform/linux-generic/include/odp/drv/driver.h | 37 - .../include/odp/drv/plat/atomic_types.h | 88 -- .../include/odp/drv/plat/barrier_types.h | 38 - .../include/odp/drv/plat/byteorder_types.h | 84 -- .../include/odp/drv/plat/driver_types.h | 52 - .../linux-generic/include/odp/drv/plat/shm_types.h | 49 - .../include/odp/drv/plat/spinlock_types.h | 33 - .../include/odp/drv/plat/strong_types.h | 35 - platform/linux-generic/include/odp/drv/shm.h | 36 - platform/linux-generic/include/odp/drv/spinlock.h | 28 - platform/linux-generic/include/odp/drv/sync.h | 49 - .../linux-generic/include/odp_config_internal.h | 6 - test/m4/configure.m4 | 5 +- test/validation/Makefile.am | 3 +- test/validation/drv/.gitignore | 2 - test/validation/drv/Makefile.am | 4 - test/validation/drv/Makefile.inc | 1 - test/validation/drv/README | 35 - test/validation/drv/drvatomic/.gitignore | 1 - test/validation/drv/drvatomic/Makefile.am | 10 - test/validation/drv/drvatomic/drvatomic.c | 892 --------------- test/validation/drv/drvatomic/drvatomic.h | 35 - test/validation/drv/drvatomic/drvatomic_main.c | 12 - test/validation/drv/drvshmem/.gitignore | 1 - test/validation/drv/drvshmem/Makefile.am | 10 - test/validation/drv/drvshmem/drvshmem.c | 1147 -------------------- test/validation/drv/drvshmem/drvshmem.h | 30 - test/validation/drv/drvshmem/drvshmem_main.c | 12 - 50 files changed, 5 insertions(+), 5634 deletions(-) delete mode 100644 include/odp/drv/spec/align.h delete mode 100644 include/odp/drv/spec/atomic.h delete mode 100644 include/odp/drv/spec/barrier.h delete mode 100644 include/odp/drv/spec/byteorder.h delete mode 100644 include/odp/drv/spec/driver.h delete mode 100644 include/odp/drv/spec/shm.h delete mode 100644 include/odp/drv/spec/spinlock.h delete mode 100644 include/odp/drv/spec/sync.h delete mode 100644 include/odp_drv.h delete mode 100644 platform/linux-generic/drv_atomic.c delete mode 100644 platform/linux-generic/drv_barrier.c delete mode 100644 platform/linux-generic/drv_driver.c delete mode 100644 platform/linux-generic/drv_shm.c delete mode 100644 platform/linux-generic/drv_spinlock.c delete mode 100644 platform/linux-generic/include/odp/drv/align.h delete mode 100644 platform/linux-generic/include/odp/drv/atomic.h delete mode 100644 platform/linux-generic/include/odp/drv/barrier.h delete mode 100644 platform/linux-generic/include/odp/drv/byteorder.h delete mode 100644 platform/linux-generic/include/odp/drv/driver.h delete mode 100644 platform/linux-generic/include/odp/drv/plat/atomic_types.h delete mode 100644 platform/linux-generic/include/odp/drv/plat/barrier_types.h delete mode 100644 platform/linux-generic/include/odp/drv/plat/byteorder_types.h delete mode 100644 platform/linux-generic/include/odp/drv/plat/driver_types.h delete mode 100644 platform/linux-generic/include/odp/drv/plat/shm_types.h delete mode 100644 platform/linux-generic/include/odp/drv/plat/spinlock_types.h delete mode 100644 platform/linux-generic/include/odp/drv/plat/strong_types.h delete mode 100644 platform/linux-generic/include/odp/drv/shm.h delete mode 100644 platform/linux-generic/include/odp/drv/spinlock.h delete mode 100644 platform/linux-generic/include/odp/drv/sync.h delete mode 100644 test/validation/drv/.gitignore delete mode 100644 test/validation/drv/Makefile.am delete mode 100644 test/validation/drv/Makefile.inc delete mode 100644 test/validation/drv/README delete mode 100644 test/validation/drv/drvatomic/.gitignore delete mode 100644 test/validation/drv/drvatomic/Makefile.am delete mode 100644 test/validation/drv/drvatomic/drvatomic.c delete mode 100644 test/validation/drv/drvatomic/drvatomic.h delete mode 100644 test/validation/drv/drvatomic/drvatomic_main.c delete mode 100644 test/validation/drv/drvshmem/.gitignore delete mode 100644 test/validation/drv/drvshmem/Makefile.am delete mode 100644 test/validation/drv/drvshmem/drvshmem.c delete mode 100644 test/validation/drv/drvshmem/drvshmem.h delete mode 100644 test/validation/drv/drvshmem/drvshmem_main.c diff --git a/doc/Doxyfile_common b/doc/Doxyfile_common index 0471dcf3c..779442d00 100644 --- a/doc/Doxyfile_common +++ b/doc/Doxyfile_common @@ -33,12 +33,9 @@ DOT_IMAGE_FORMAT = svg PREDEFINED = __GNUC__ \ __attribute__(x)= \ ODP_ALIGNED(x)= \ - ODPDRV_ALIGNED(x)= \ __BIG_ENDIAN_BITFIELD \ __LITTLE_ENDIAN_BITFIELD \ __x86_64__ \ ODP_PACKED \ - ODPDRV_PACKED \ ODP_DEPRECATE(x)=x \ - "ODP_HANDLE_T(type)=odp_handle_t type" \ - "ODPDRV_HANDLE_T(type)=odpdrv_handle_t type" + "ODP_HANDLE_T(type)=odp_handle_t type" diff --git a/include/Makefile.am b/include/Makefile.am index d53181ceb..4e2d748b0 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -1,7 +1,6 @@ include_HEADERS = \ odp.h \ - odp_api.h \ - odp_drv.h + odp_api.h odpapispecincludedir= $(includedir)/odp/api/spec odpapispecinclude_HEADERS = \ @@ -54,19 +53,6 @@ nodist_odpapispecinclude_HEADERS = \ odp/api/spec/deprecated.h \ odp/api/spec/version.h -odpdrvspecincludedir= $(includedir)/odp/drv/spec -odpdrvspecinclude_HEADERS = \ - odp/drv/spec/align.h \ - odp/drv/spec/atomic.h \ - odp/drv/spec/barrier.h \ - odp/drv/spec/byteorder.h \ - odp/drv/spec/compiler.h \ - odp/drv/spec/driver.h \ - odp/drv/spec/shm.h \ - odp/drv/spec/spinlock.h \ - odp/drv/spec/std_types.h \ - odp/drv/spec/sync.h - odpapiabidefaultincludedir= $(includedir)/odp/arch/default/api/abi odpapiabidefaultinclude_HEADERS = \ odp/arch/default/api/abi/buffer.h \ diff --git a/include/odp/drv/spec/align.h b/include/odp/drv/spec/align.h deleted file mode 100644 index 2b2f32c53..000000000 --- a/include/odp/drv/spec/align.h +++ /dev/null @@ -1,78 +0,0 @@ -/* Copyright (c) 2016, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODPDRV alignments - */ - -#ifndef ODPDRV_API_ALIGN_H_ -#define ODPDRV_API_ALIGN_H_ -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** @addtogroup odpdrv_compiler_optim - * Macros that allow cache line size configuration, check that - * alignment is a power of two etc. - * @{ - */ - -/* Checkpatch complains, but cannot use __aligned(size) for this purpose. */ - -/** - * @def ODPDRV_ALIGNED - * Defines type/struct/variable alignment in bytes - */ - -/** - * @def ODPDRV_PACKED - * Defines type/struct to be packed - */ - -/** - * @def ODPDRV_OFFSETOF - * Returns offset of member in type - */ - -/** - * @def ODPDRV_FIELD_SIZEOF - * Returns sizeof member - */ - -/** - * @def ODPDRV_CACHE_LINE_SIZE - * Cache line size - */ - -/** - * @def ODPDRV_PAGE_SIZE - * Page size - */ - -/** - * @def ODPDRV_ALIGNED_CACHE - * Defines type/struct/variable to be cache line size aligned - */ - -/** - * @def ODPDRV_ALIGNED_PAGE - * Defines type/struct/variable to be page size aligned - */ - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#include -#endif diff --git a/include/odp/drv/spec/atomic.h b/include/odp/drv/spec/atomic.h deleted file mode 100644 index 3cb6e9bbf..000000000 --- a/include/odp/drv/spec/atomic.h +++ /dev/null @@ -1,634 +0,0 @@ -/* Copyright (c) 2016, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODPDRV atomic operations - */ - -#ifndef ODPDRV_API_ATOMIC_H_ -#define ODPDRV_API_ATOMIC_H_ -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup odpdrv_atomic ODPDRV ATOMIC - * @details - * Atomic integers using relaxed memory ordering - * - * Atomic integer types (odpdrv_atomic_u32_t and odpdrv_atomic_u64_t) can be - * used to implement e.g. shared counters. If not otherwise documented, - * operations in this API are implemented using RELAXED memory ordering - * (see memory order descriptions in the C11 specification). Relaxed operations - * do not provide synchronization or ordering for other memory accesses - * (initiated before or after the operation), only atomicity of the operation - * itself is guaranteed. - * - * Operations with non-relaxed memory ordering - * - * An operation with RELEASE memory ordering - * (odpdrv_atomic_xxx_rel_xxx()) ensures that other threads loading the same - * atomic variable with ACQUIRE memory ordering see all stores (from the - * calling thread) that happened before this releasing store. - * - * An operation with ACQUIRE memory ordering - * (odpdrv_atomic_xxx_acq_xxx()) ensures that the calling thread sees all stores - * (done by the releasing thread) that happened before a RELEASE memory ordered - * store to the same atomic variable. - * - * An operation with ACQUIRE-and-RELEASE memory ordering - * (odpdrv_atomic_xxx_acq_rel_xxx()) combines the effects of ACQUIRE and RELEASE - * memory orders. A single operation acts as both an acquiring load and - * a releasing store. - * - * @{ - */ - -/** - * @typedef odpdrv_atomic_u64_t - * Atomic 64-bit unsigned integer - * - * @typedef odpdrv_atomic_u32_t - * Atomic 32-bit unsigned integer - */ - -/* - * 32-bit operations in RELAXED memory ordering - * -------------------------------------------- - */ - -/** - * Initialize atomic uint32 variable - * - * Initializes the atomic variable with 'val'. This operation is not atomic. - * Drivers must ensure that there's no race condition while initializing - * the variable. - * - * @param atom Pointer to atomic variable - * @param val Value to initialize the variable with - */ -void odpdrv_atomic_init_u32(odpdrv_atomic_u32_t *atom, uint32_t val); - -/** - * Load value of atomic uint32 variable - * - * @param atom Pointer to atomic variable - * - * @return Value of the variable - */ -uint32_t odpdrv_atomic_load_u32(odpdrv_atomic_u32_t *atom); - -/** - * Store value to atomic uint32 variable - * - * @param atom Pointer to atomic variable - * @param val Value to store in the variable - */ -void odpdrv_atomic_store_u32(odpdrv_atomic_u32_t *atom, uint32_t val); - -/** - * Fetch and add to atomic uint32 variable - * - * @param atom Pointer to atomic variable - * @param val Value to be added to the variable - * - * @return Value of the variable before the addition - */ -uint32_t odpdrv_atomic_fetch_add_u32(odpdrv_atomic_u32_t *atom, uint32_t val); - -/** - * Add to atomic uint32 variable - * - * @param atom Pointer to atomic variable - * @param val Value to be added to the variable - */ -void odpdrv_atomic_add_u32(odpdrv_atomic_u32_t *atom, uint32_t val); - -/** - * Fetch and subtract from atomic uint32 variable - * - * @param atom Pointer to atomic variable - * @param val Value to be subracted from the variable - * - * @return Value of the variable before the subtraction - */ -uint32_t odpdrv_atomic_fetch_sub_u32(odpdrv_atomic_u32_t *atom, uint32_t val); - -/** - * Subtract from atomic uint32 variable - * - * @param atom Pointer to atomic variable - * @param val Value to be subtracted from the variable - */ -void odpdrv_atomic_sub_u32(odpdrv_atomic_u32_t *atom, uint32_t val); - -/** - * Fetch and increment atomic uint32 variable - * - * @param atom Pointer to atomic variable - * - * @return Value of the variable before the increment - */ -uint32_t odpdrv_atomic_fetch_inc_u32(odpdrv_atomic_u32_t *atom); - -/** - * Increment atomic uint32 variable - * - * @param atom Pointer to atomic variable - */ -void odpdrv_atomic_inc_u32(odpdrv_atomic_u32_t *atom); - -/** - * Fetch and decrement atomic uint32 variable - * - * @param atom Pointer to atomic variable - * - * @return Value of the variable before the subtraction - */ -uint32_t odpdrv_atomic_fetch_dec_u32(odpdrv_atomic_u32_t *atom); - -/** - * Decrement atomic uint32 variable - * - * @param atom Pointer to atomic variable - */ -void odpdrv_atomic_dec_u32(odpdrv_atomic_u32_t *atom); - -/** - * Update maximum value of atomic uint32 variable - * - * Compares value of atomic variable to the new maximum value. If the new value - * is greater than the current value, writes the new value into the variable. - * - * @param atom Pointer to atomic variable - * @param new_max New maximum value to be written into the atomic variable - */ -void odpdrv_atomic_max_u32(odpdrv_atomic_u32_t *atom, uint32_t new_max); - -/** - * Update minimum value of atomic uint32 variable - * - * Compares value of atomic variable to the new minimum value. If the new value - * is less than the current value, writes the new value into the variable. - * - * @param atom Pointer to atomic variable - * @param new_min New minimum value to be written into the atomic variable - */ -void odpdrv_atomic_min_u32(odpdrv_atomic_u32_t *atom, uint32_t new_min); - -/** - * Compare and swap atomic uint32 variable - * - * Compares value of atomic variable to the value pointed by 'old_val'. - * If values are equal, the operation writes 'new_val' into the atomic variable - * and returns success. If they are not equal, the operation writes current - * value of atomic variable into 'old_val' and returns failure. - * - * @param atom Pointer to atomic variable - * @param[in,out] old_val Pointer to the old value of the atomic variable. - * Operation updates this value on failure. - * @param new_val New value to be written into the atomic variable - * - * @return 0 on failure, !0 on success - * - */ -int odpdrv_atomic_cas_u32(odpdrv_atomic_u32_t *atom, uint32_t *old_val, - uint32_t new_val); - -/** - * Exchange value of atomic uint32 variable - * - * Atomically replaces the value of atomic variable with the new value. Returns - * the old value. - * - * @param atom Pointer to atomic variable - * @param new_val New value of the atomic variable - * - * @return Value of the variable before the operation - */ -uint32_t odpdrv_atomic_xchg_u32(odpdrv_atomic_u32_t *atom, uint32_t new_val); - -/* - * 64-bit operations in RELAXED memory ordering - * -------------------------------------------- - */ - -/** - * Initialize atomic uint64 variable - * - * Initializes the atomic variable with 'val'. This operation is not atomic. - * Drivers must ensure that there's no race condition while initializing - * the variable. - * - * @param atom Pointer to atomic variable - * @param val Value to initialize the variable with - */ -void odpdrv_atomic_init_u64(odpdrv_atomic_u64_t *atom, uint64_t val); - -/** - * Load value of atomic uint64 variable - * - * @param atom Pointer to atomic variable - * - * @return Value of the variable - */ -uint64_t odpdrv_atomic_load_u64(odpdrv_atomic_u64_t *atom); - -/** - * Store value to atomic uint64 variable - * - * @param atom Pointer to atomic variable - * @param val Value to store in the variable - */ -void odpdrv_atomic_store_u64(odpdrv_atomic_u64_t *atom, uint64_t val); - -/** - * Fetch and add to atomic uint64 variable - * - * @param atom Pointer to atomic variable - * @param val Value to be added to the variable - * - * @return Value of the variable before the addition - */ -uint64_t odpdrv_atomic_fetch_add_u64(odpdrv_atomic_u64_t *atom, uint64_t val); - -/** - * Add to atomic uint64 variable - * - * @param atom Pointer to atomic variable - * @param val Value to be added to the variable - */ -void odpdrv_atomic_add_u64(odpdrv_atomic_u64_t *atom, uint64_t val); - -/** - * Fetch and subtract from atomic uint64 variable - * - * @param atom Pointer to atomic variable - * @param val Value to be subtracted from the variable - * - * @return Value of the variable before the subtraction - */ -uint64_t odpdrv_atomic_fetch_sub_u64(odpdrv_atomic_u64_t *atom, uint64_t val); - -/** - * Subtract from atomic uint64 variable - * - * @param atom Pointer to atomic variable - * @param val Value to be subtracted from the variable - */ -void odpdrv_atomic_sub_u64(odpdrv_atomic_u64_t *atom, uint64_t val); - -/** - * Fetch and increment atomic uint64 variable - * - * @param atom Pointer to atomic variable - * - * @return Value of the variable before the increment - */ -uint64_t odpdrv_atomic_fetch_inc_u64(odpdrv_atomic_u64_t *atom); - -/** - * Increment atomic uint64 variable - * - * @param atom Pointer to atomic variable - */ -void odpdrv_atomic_inc_u64(odpdrv_atomic_u64_t *atom); - -/** - * Fetch and decrement atomic uint64 variable - * - * @param atom Pointer to atomic variable - * - * @return Value of the variable before the decrement - */ -uint64_t odpdrv_atomic_fetch_dec_u64(odpdrv_atomic_u64_t *atom); - -/** - * Decrement atomic uint64 variable - * - * @param atom Pointer to atomic variable - */ -void odpdrv_atomic_dec_u64(odpdrv_atomic_u64_t *atom); - -/** - * Update maximum value of atomic uint64 variable - * - * Compares value of atomic variable to the new maximum value. If the new value - * is greater than the current value, writes the new value into the variable. - * - * @param atom Pointer to atomic variable - * @param new_max New maximum value to be written into the atomic variable - */ -void odpdrv_atomic_max_u64(odpdrv_atomic_u64_t *atom, uint64_t new_max); - -/** - * Update minimum value of atomic uint64 variable - * - * Compares value of atomic variable to the new minimum value. If the new value - * is less than the current value, writes the new value into the variable. - * - * @param atom Pointer to atomic variable - * @param new_min New minimum value to be written into the atomic variable - */ -void odpdrv_atomic_min_u64(odpdrv_atomic_u64_t *atom, uint64_t new_min); - -/** - * Compare and swap atomic uint64 variable - * - * Compares value of atomic variable to the value pointed by 'old_val'. - * If values are equal, the operation writes 'new_val' into the atomic variable - * and returns success. If they are not equal, the operation writes current - * value of atomic variable into 'old_val' and returns failure. - * - * @param atom Pointer to atomic variable - * @param[in,out] old_val Pointer to the old value of the atomic variable. - * Operation updates this value on failure. - * @param new_val New value to be written into the atomic variable - * - * @return 0 on failure, !0 on success - */ -int odpdrv_atomic_cas_u64(odpdrv_atomic_u64_t *atom, uint64_t *old_val, - uint64_t new_val); - -/** - * Exchange value of atomic uint64 variable - * - * Atomically replaces the value of atomic variable with the new value. Returns - * the old value. - * - * @param atom Pointer to atomic variable - * @param new_val New value of the atomic variable - * - * @return Value of the variable before the operation - */ -uint64_t odpdrv_atomic_xchg_u64(odpdrv_atomic_u64_t *atom, uint64_t new_val); - -/* - * 32-bit operations in non-RELAXED memory ordering - * ------------------------------------------------ - */ - -/** - * Load value of atomic uint32 variable using ACQUIRE memory ordering - * - * Otherwise identical to odpdrv_atomic_load_u32() but ensures ACQUIRE memory - * ordering. - * - * @param atom Pointer to atomic variable - * - * @return Value of the variable - */ -uint32_t odpdrv_atomic_load_acq_u32(odpdrv_atomic_u32_t *atom); - -/** - * Store value to atomic uint32 variable using RELEASE memory ordering - * - * Otherwise identical to odpdrv_atomic_store_u32() but ensures RELEASE memory - * ordering. - * - * @param atom Pointer to atomic variable - * @param val Value to store in the variable - */ -void odpdrv_atomic_store_rel_u32(odpdrv_atomic_u32_t *atom, uint32_t val); - -/** - * Add to atomic uint32 variable using RELEASE memory ordering - * - * Otherwise identical to odpdrv_atomic_add_u32() but ensures RELEASE memory - * ordering. - * - * @param atom Pointer to atomic variable - * @param val Value to be added to the variable - */ -void odpdrv_atomic_add_rel_u32(odpdrv_atomic_u32_t *atom, uint32_t val); - -/** - * Subtract from atomic uint32 variable using RELEASE memory ordering - * - * Otherwise identical to odpdrv_atomic_sub_u32() but ensures RELEASE memory - * ordering. - * - * @param atom Pointer to atomic variable - * @param val Value to be subtracted from the variable - */ -void odpdrv_atomic_sub_rel_u32(odpdrv_atomic_u32_t *atom, uint32_t val); - -/** - * Compare and swap atomic uint32 variable using ACQUIRE memory ordering - * - * Otherwise identical to odpdrv_atomic_cas_u32() but ensures ACQUIRE memory - * ordering on success. Memory ordering is RELAXED on failure. - * - * @param atom Pointer to atomic variable - * @param[in,out] old_val Pointer to the old value of the atomic variable. - * Operation updates this value on failure. - * @param new_val New value to be written into the atomic variable - * - * @return 0 on failure, !0 on success - */ -int odpdrv_atomic_cas_acq_u32(odpdrv_atomic_u32_t *atom, uint32_t *old_val, - uint32_t new_val); - -/** - * Compare and swap atomic uint32 variable using RELEASE memory ordering - * - * Otherwise identical to odpdrv_atomic_cas_u32() but ensures RELEASE memory - * ordering on success. Memory ordering is RELAXED on failure. - * - * @param atom Pointer to atomic variable - * @param[in,out] old_val Pointer to the old value of the atomic variable. - * Operation updates this value on failure. - * @param new_val New value to be written into the atomic variable - * - * @return 0 on failure, !0 on success - */ -int odpdrv_atomic_cas_rel_u32(odpdrv_atomic_u32_t *atom, uint32_t *old_val, - uint32_t new_val); - -/** - * Compare and swap atomic uint32 variable using ACQUIRE-and-RELEASE memory - * ordering - * - * Otherwise identical to odpdrv_atomic_cas_u32() but ensures - * ACQUIRE-and-RELEASE memory ordering on success. - * Memory ordering is RELAXED on failure. - * - * @param atom Pointer to atomic variable - * @param[in,out] old_val Pointer to the old value of the atomic variable. - * Operation updates this value on failure. - * @param new_val New value to be written into the atomic variable - * - * @return 0 on failure, !0 on success - */ -int odpdrv_atomic_cas_acq_rel_u32(odpdrv_atomic_u32_t *atom, uint32_t *old_val, - uint32_t new_val); - -/* - * 64-bit operations in non-RELAXED memory ordering - * ------------------------------------------------ - */ - -/** - * Load value of atomic uint64 variable using ACQUIRE memory ordering - * - * Otherwise identical to odpdrv_atomic_load_u64() but ensures ACQUIRE memory - * ordering. - * - * @param atom Pointer to atomic variable - * - * @return Value of the variable - */ -uint64_t odpdrv_atomic_load_acq_u64(odpdrv_atomic_u64_t *atom); - -/** - * Store value to atomic uint64 variable using RELEASE memory ordering - * - * Otherwise identical to odpdrv_atomic_store_u64() but ensures RELEASE memory - * ordering. - * - * @param atom Pointer to atomic variable - * @param val Value to store in the variable - */ -void odpdrv_atomic_store_rel_u64(odpdrv_atomic_u64_t *atom, uint64_t val); - -/** - * Add to atomic uint64 variable using RELEASE memory ordering - * - * Otherwise identical to odpdrv_atomic_add_u64() but ensures RELEASE memory - * ordering. - * - * @param atom Pointer to atomic variable - * @param val Value to be added to the variable - */ -void odpdrv_atomic_add_rel_u64(odpdrv_atomic_u64_t *atom, uint64_t val); - -/** - * Subtract from atomic uint64 variable using RELEASE memory ordering - * - * Otherwise identical to odpdrv_atomic_sub_u64() but ensures RELEASE memory - * ordering. - * - * @param atom Pointer to atomic variable - * @param val Value to be subtracted from the variable - */ -void odpdrv_atomic_sub_rel_u64(odpdrv_atomic_u64_t *atom, uint64_t val); - -/** - * Compare and swap atomic uint64 variable using ACQUIRE memory ordering - * - * Otherwise identical to odpdrv_atomic_cas_u64() but ensures ACQUIRE memory - * ordering on success. Memory ordering is RELAXED on failure. - * - * @param atom Pointer to atomic variable - * @param[in,out] old_val Pointer to the old value of the atomic variable. - * Operation updates this value on failure. - * @param new_val New value to be written into the atomic variable - * - * @return 0 on failure, !0 on success - */ -int odpdrv_atomic_cas_acq_u64(odpdrv_atomic_u64_t *atom, uint64_t *old_val, - uint64_t new_val); - -/** - * Compare and swap atomic uint64 variable using RELEASE memory ordering - * - * Otherwise identical to odpdrv_atomic_cas_u64() but ensures RELEASE memory - * ordering on success. Memory ordering is RELAXED on failure. - * - * @param atom Pointer to atomic variable - * @param[in,out] old_val Pointer to the old value of the atomic variable. - * Operation updates this value on failure. - * @param new_val New value to be written into the atomic variable - * - * @return 0 on failure, !0 on success - */ -int odpdrv_atomic_cas_rel_u64(odpdrv_atomic_u64_t *atom, uint64_t *old_val, - uint64_t new_val); - -/** - * Compare and swap atomic uint64 variable using ACQUIRE-and-RELEASE memory - * ordering - * - * Otherwise identical to odpdrv_atomic_cas_u64() but ensures - * ACQUIRE-and-RELEASE memory ordering on success. Memory ordering is RELAXED - * on failure. - * - * @param atom Pointer to atomic variable - * @param[in,out] old_val Pointer to the old value of the atomic variable. - * Operation updates this value on failure. - * @param new_val New value to be written into the atomic variable - * - * @return 0 on failure, !0 on success - */ -int odpdrv_atomic_cas_acq_rel_u64(odpdrv_atomic_u64_t *atom, uint64_t *old_val, - uint64_t new_val); - -/** - * Atomic operations - * - * Atomic operations listed in a bit field structure. - */ -typedef union odpdrv_atomic_op_t { - /** Operation flags */ - struct { - uint32_t init : 1; /**< Init atomic variable */ - uint32_t load : 1; /**< Atomic load */ - uint32_t store : 1; /**< Atomic store */ - uint32_t fetch_add : 1; /**< Atomic fetch and add */ - uint32_t add : 1; /**< Atomic add */ - uint32_t fetch_sub : 1; /**< Atomic fetch and subtract */ - uint32_t sub : 1; /**< Atomic subtract */ - uint32_t fetch_inc : 1; /**< Atomic fetch and increment */ - uint32_t inc : 1; /**< Atomic increment */ - uint32_t fetch_dec : 1; /**< Atomic fetch and decrement */ - uint32_t dec : 1; /**< Atomic decrement */ - uint32_t min : 1; /**< Atomic minimum */ - uint32_t max : 1; /**< Atomic maximum */ - uint32_t cas : 1; /**< Atomic compare and swap */ - uint32_t xchg : 1; /**< Atomic exchange */ - } op; - - /** All bits of the bit field structure. - * Operation flag mapping is architecture specific. This field can be - * used to set/clear all flags, or bitwise operations over the entire - * structure. */ - uint32_t all_bits; -} odpdrv_atomic_op_t; - -/** - * Query which atomic uint64 operations are lock-free - * - * Lock-free implementations have higher performance and scale better than - * implementations using locks. User can decide to use e.g. uint32 atomic - * variables instead of uint64 to optimize performance on platforms that - * implement a performance critical operation using locks. - * - * Init operations (e.g. odpdrv_atomic_init_64()) are not atomic. This function - * clears the op.init bit but will never set it to one. - * - * @param atomic_op Pointer to atomic operation structure for storing - * operation flags. All bits are initialized to zero during - * the operation. The parameter is ignored when NULL. - * @retval 0 None of the operations are lock-free - * @retval 1 Some of the operations are lock-free - * @retval 2 All operations are lock-free - */ -int odpdrv_atomic_lock_free_u64(odpdrv_atomic_op_t *atomic_op); - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#include -#endif diff --git a/include/odp/drv/spec/barrier.h b/include/odp/drv/spec/barrier.h deleted file mode 100644 index 5ac65a30f..000000000 --- a/include/odp/drv/spec/barrier.h +++ /dev/null @@ -1,66 +0,0 @@ -/* Copyright (c) 2016, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODPDRV execution barriers - */ - -#ifndef ODPDRV_API_BARRIER_H_ -#define ODPDRV_API_BARRIER_H_ -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @defgroup odpdrv_barrier ODPDRV BARRIER - * Thread execution and memory ordering barriers. - * - * @details - * Thread execution barrier (odpdrv_barrier_t) - * - * Thread execution barrier synchronizes a group of threads to wait on the - * barrier until the entire group has reached the barrier. - * @{ - */ - -/** - * @typedef odpdrv_barrier_t - * ODPDRV thread synchronization barrier - */ - -/** - * Initialize barrier with thread count. - * - * @param barr Pointer to a barrier variable - * @param count Thread count - */ -void odpdrv_barrier_init(odpdrv_barrier_t *barr, int count); - -/** - * Synchronize thread execution on barrier. - * Wait for all threads to arrive at the barrier until they are let loose again. - * Threads will block (spin) until the last thread has arrived at the barrier. - * All memory operations before the odpdrv_barrier_wait() call will be visible - * to all threads when they leave the barrier. - * - * @param barr Pointer to a barrier variable - */ -void odpdrv_barrier_wait(odpdrv_barrier_t *barr); - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#include -#endif diff --git a/include/odp/drv/spec/byteorder.h b/include/odp/drv/spec/byteorder.h deleted file mode 100644 index bf363f59e..000000000 --- a/include/odp/drv/spec/byteorder.h +++ /dev/null @@ -1,181 +0,0 @@ -/* Copyright (c) 2016, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODPDRV byteorder - */ - -#ifndef ODPDRV_BYTEORDER_H_ -#define ODPDRV_BYTEORDER_H_ -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** @addtogroup odpdrv_compiler_optim ODPDRV COMPILER / OPTIMIZATION - * Macros that check byte order and operations for byte order conversion. - * @{ - */ - -/** - * @def ODPDRV_BIG_ENDIAN - * Big endian byte order - * - * @def ODPDRV_LITTLE_ENDIAN - * Little endian byte order - * - * @def ODPDRV_BIG_ENDIAN_BITFIELD - * Big endian bit field - * - * @def ODPDRV_LITTLE_ENDIAN_BITFIELD - * Little endian bit field - * - * @def ODPDRV_BYTE_ORDER - * Selected byte order - * - * @def ODPDRV_BITFIELD_ORDER - * Selected bitfield order - */ - -/** - * @typedef odpdrv_u16le_t - * unsigned 16bit little endian - * - * @typedef odpdrv_u16be_t - * unsigned 16bit big endian - * - * @typedef odpdrv_u32le_t - * unsigned 32bit little endian - * - * @typedef odpdrv_u32be_t - * unsigned 32bit big endian - * - * @typedef odpdrv_u64le_t - * unsigned 64bit little endian - * - * @typedef odpdrv_u64be_t - * unsigned 64bit big endian - * - * @typedef odpdrv_u16sum_t - * unsigned 16bit bitwise - * - * @typedef odpdrv_u32sum_t - * unsigned 32bit bitwise - */ - -/* - * Big Endian -> CPU byte order: - */ - -/** - * Convert 16bit big endian to cpu native uint16_t - * @param be16 big endian 16bit - * @return cpu native uint16_t - */ -uint16_t odpdrv_be_to_cpu_16(odpdrv_u16be_t be16); - -/** - * Convert 32bit big endian to cpu native uint32_t - * @param be32 big endian 32bit - * @return cpu native uint32_t - */ -uint32_t odpdrv_be_to_cpu_32(odpdrv_u32be_t be32); - -/** - * Convert 64bit big endian to cpu native uint64_t - * @param be64 big endian 64bit - * @return cpu native uint64_t - */ -uint64_t odpdrv_be_to_cpu_64(odpdrv_u64be_t be64); - -/* - * CPU byte order -> Big Endian: - */ - -/** - * Convert cpu native uint16_t to 16bit big endian - * @param cpu16 uint16_t in cpu native format - * @return big endian 16bit - */ -odpdrv_u16be_t odpdrv_cpu_to_be_16(uint16_t cpu16); - -/** - * Convert cpu native uint32_t to 32bit big endian - * @param cpu32 uint32_t in cpu native format - * @return big endian 32bit - */ -odpdrv_u32be_t odpdrv_cpu_to_be_32(uint32_t cpu32); - -/** - * Convert cpu native uint64_t to 64bit big endian - * @param cpu64 uint64_t in cpu native format - * @return big endian 64bit - */ -odpdrv_u64be_t odpdrv_cpu_to_be_64(uint64_t cpu64); - -/* - * Little Endian -> CPU byte order: - */ - -/** - * Convert 16bit little endian to cpu native uint16_t - * @param le16 little endian 16bit - * @return cpu native uint16_t - */ -uint16_t odpdrv_le_to_cpu_16(odpdrv_u16le_t le16); - -/** - * Convert 32bit little endian to cpu native uint32_t - * @param le32 little endian 32bit - * @return cpu native uint32_t - */ -uint32_t odpdrv_le_to_cpu_32(odpdrv_u32le_t le32); - -/** - * Convert 64bit little endian to cpu native uint64_t - * @param le64 little endian 64bit - * @return cpu native uint64_t - */ -uint64_t odpdrv_le_to_cpu_64(odpdrv_u64le_t le64); - -/* - * CPU byte order -> Little Endian: - */ - -/** - * Convert cpu native uint16_t to 16bit little endian - * @param cpu16 uint16_t in cpu native format - * @return little endian 16bit - */ -odpdrv_u16le_t odpdrv_cpu_to_le_16(uint16_t cpu16); - -/** - * Convert cpu native uint32_t to 32bit little endian - * @param cpu32 uint32_t in cpu native format - * @return little endian 32bit - */ -odpdrv_u32le_t odpdrv_cpu_to_le_32(uint32_t cpu32); - -/** - * Convert cpu native uint64_t to 64bit little endian - * @param cpu64 uint64_t in cpu native format - * @return little endian 64bit - */ -odpdrv_u64le_t odpdrv_cpu_to_le_64(uint64_t cpu64); - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#include -#endif diff --git a/include/odp/drv/spec/driver.h b/include/odp/drv/spec/driver.h deleted file mode 100644 index d83e907cd..000000000 --- a/include/odp/drv/spec/driver.h +++ /dev/null @@ -1,389 +0,0 @@ -/* Copyright (c) 2017, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODPDRV driver - */ - -#ifndef ODPDRV_DRIVER_H_ -#define ODPDRV_DRIVER_H_ -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** -* @addtogroup odpdrv_driver -* @details -* enumerator and driver interface to ODP -* -* 1) ODP loads the different modules (i.e. it loads shared libraries, *.so). -* In the context of drivers, shared libraries may contain enumerators, -* drivers and devios. These register in step 2. -* -* 2) -* @code -* odpdrv_enumr_class_register(int (probe*)()...) -* -----------------------------------------------------------> -* odpdrv_driver_register(int (probe*)()...) -* -----------------------------------------------------------> -* odpdrv_devio_register() -* -----------------------------------------------------------> -* @endcode -* A number of device_enumerator_classes are registered at the ODP startup. -* Many classes are expected: static, ACPI, PCI, switchdev, virtual, DPAA2... -* A number of drivers also register to ODP (passing their own probe function). -* A number of device IO may also register to ODP (defining available devices -* interfaces). -* -* 3) ODP calls the probe function of each enumerator class
-* @code -* enumerator class probe() -* <----------------------------------------------------------- -* odpdrv_emum_register(int (probe*)()...) -* -----------------------------------------------------------> -* -----------------------------------------------------------> -* -----------------------------------------------------------> -* odpdrv_devio_register(...) -* -----------------------------------------------------------> -* -----------------------------------------------------------> -* -----------------------------------------------------------> -* @endcode -* ODP calls the probe function of each registered enumerator_class. -* This result in the enumerator_class registering some -* enumerators (instances of the class) by calling -* odpdrv_emumerator_register() for each instance. -* A given enumerator_class may create many enumerators based on its platform: -* For instance Linux defines a number of PCI domains that can be viewed as -* multiple PCI enumerators. In addition, it could be considered that each PCI -* root of each processor socket in a NUMA environment has its own PCI -* enumerator. -* For enumerator class PCI, there could be one instance for each PCI -* domain. -* The devios delivered with their enumerator may also register at this stage. -* -* 4) -* @code -* enumerator probe() -* <----------------------------------------------------------- -* odpdrv_device_create() -* -----------------------------------------------------------> -* odpdrv_device_create() -* -----------------------------------------------------------> -* odpdrv_device_create() -* -----------------------------------------------------------> -* @endcode -* For each enumerator instance, odp calls the probe function. -* This will trigger devices creation (Enumerators calls odpdrv -* odpdrv_device_create() for each new device). Enumerators are allowed -* to call odpdrv_device_create() at any time once they have been probed -* (hotplug). They also may call odpdrv_device_destroy() if needed. -* -* 5) The driver framework calls the drivers probe(D,I) functions of the -* drivers, with device D and devio I as parameter, assuming that: -* -devio I was on the driver supported list of devio (and version matches) -* -the devio I is registered and found its enumerator interface(E) api -* (name and version) -* -device D was enumerated by an enumerator providing interface E. -* The return value of the driver probe function tells whether the driver -* can handle the device or not. -* -* @{ -*/ - -/* Forward declarations for a top down description of structures */ -/** Parameters for enumerator class registration */ -typedef struct odpdrv_enumr_class_param_t odpdrv_enumr_class_param_t; -/** Parameters for enumerator registration */ -typedef struct odpdrv_enumr_param_t odpdrv_enumr_param_t; -/** Parameters for new device creation */ -typedef struct odpdrv_device_param_t odpdrv_device_param_t; -/** Parameters for devio registration*/ -typedef struct odpdrv_devio_param_t odpdrv_devio_param_t; -/** Parameters for driver registration*/ -typedef struct odpdrv_driver_param_t odpdrv_driver_param_t; - -/** - * @typedef odpdrv_enumr_class_t - * ODPDRV enumerator class, such as PCI. - */ -/** - * @def ODPDRV_ENUMR_CLASS_INVALID - * Invalid odpdrv enumerator class - */ - -/** - * @typedef odpdrv_enumr_t - * ODPDRV enumerator. Instance of odpdrv_enumr_class_t. - */ -/** - * @def ODPDRV_ENUMR_INVALID - * Invalid odpdrv enumerator - */ - -/** - * @typedef odpdrv_device_t - * ODPDRV device. Created and destroyed by enumerators - */ -/** - * @def ODPDRV_DEVICE_INVALID - * Invalid odpdrv device - */ - -/** - * @typedef odpdrv_devio_t - * ODPDRV device IO interface. - */ -/** - * @def ODPDRV_DEVIO_INVALID - * Invalid odpdrv device IO - */ - -/** - * @typedef odpdrv_driver_t - * ODPDRV device driver. - */ -/** - * @def ODPDRV_DRIVER_INVALID - * Invalid odpdrv driver - */ - -/** Maximum size for driver and enumerator names */ -#define ODPDRV_NAME_SIZE 32 - -/** Maximum size for the enumerator dependent address */ -#define ODPDRV_NAME_ADDR_SZ 64 - -/** The maximum number of interfaces a driver may support */ -#define ODPDRV_MAX_DEVIOS 3 - -/** -* Parameters to be given at enumerator class registration -*/ -struct odpdrv_enumr_class_param_t { - /** Enumerator name: mostly used for debug purpose. - * Name must be unique (e.g. "PCI-DPAA2") - */ - const char name[ODPDRV_NAME_SIZE]; - - /** Probe function: - * Called by ODP to get the enumerator class instances registered - */ - int (*probe)(void); - - /** Remove function: - * Free whatever resource the class may have allocated. - */ - int (*remove)(void); -}; - -/** -* Parameter to be given at enumerator (instance) registration -*/ -struct odpdrv_enumr_param_t { - /** Class - * Identifies the class of the enumerator - */ - odpdrv_enumr_class_t enumr_class; - - /** Enumerator api_name and version are used by the devio - * to make sure the device can be accessed: - * E.g. "PCI" - * The format of the enum_dev part for the odpdrv_device_param_t - * structure is identified by the api-name and version below - */ - const char api_name[ODPDRV_NAME_SIZE]; - uint32_t api_version; /**<< the version of the provided API */ - - /** Probe function: - * Called by ODP when it is ready for device creation/deletion - * returns an negative value on error or 0 on success. - */ - int (*probe)(void); - - /** Remove function: - * destroy all enumerated devices and release all resources - */ - int (*remove)(void); - - /** Register event notifier function for hotplug events: - * register_notifier(fcnt,event_mask) registers fcnt as a callback when - * one of the event specified in event_mask occurs. - */ - int (*register_notifier)(void (*event_handler) (uint64_t event), - int64_t event_mask); -}; - -/* The following events are supported by enumerators */ -#define ODPDRV_ENUM_EV_REMOVED 0x0000000000000001 /**<< remove event */ - -/** This structure defines a generic enumerated device, or actually the -* common part between all devices, the enumerator specific part being pointed -* by the enum_dev field below. -*/ -struct odpdrv_device_param_t { - /** enumerator - * enumerator which enumerated the device: as returned by - * odpdrv_enumr_register - * devices with parents get destroyed when the parents dies. - */ - odpdrv_enumr_t enumerator; - - /** Device address: - * An enumerator dependent string giving the device address, - * e.g. "0000.23.12.1" for PCI domain 0, bus 23, device 12, function 1. - * This string identifies the device uniquely. - */ - const char address[ODPDRV_NAME_ADDR_SZ]; - - /** Enumerator dependent part - * This part is allocated by the enumerator and is enumerator dependent - * (i.e. different devices types will have different contents for - * enum_dev). - */ - void *enum_dev; -}; - -/** - * Parameter to be given at devio registration - */ -struct odpdrv_devio_param_t { - /** Devio name - * Identifies devio interface implemented by this devio - * (i.e:many devios may have the same name, but none of those - * with same provided interface should refer to a common enumerator - * class) - */ - const char api_name[ODPDRV_NAME_SIZE]; - uint32_t api_version; /**<< the version of the provided API */ - - /** Enumerator interface name and version - * The enumerator interface this devio needs. - */ - const char enumr_api_name[ODPDRV_NAME_SIZE]; - uint32_t enumr_api_version; /**<< required enumerator API version */ - - /** Ops - * Pointer to a devio ops structure (specific to each devio) - */ - void *ops; -}; - -/** -* Parameter to be given at driver registration -*/ -struct odpdrv_driver_param_t { - /** Driver name - * The driver name (the pair {driver-name, enum-api-name} must - * be unique) - */ - const char name[ODPDRV_NAME_SIZE]; - - /** Supported devios: - * The list of supported devio: one of the following devio - * (with correct version) must be available for the driver to work: - */ - struct { - const char api_name[ODPDRV_NAME_SIZE]; /**<< devio API name */ - uint32_t api_version; /**<< devio API version */ - } devios[ODPDRV_MAX_DEVIOS]; - - /** Probe function: - * Called by ODP to see if the driver can drive a given device - * - */ - int (*probe)(odpdrv_device_t *dev); - - /** Remove function: - * Only called with devices whose probe() returned true - * - */ - int (*remove)(odpdrv_device_param_t *dev); - -}; - -/** -* Register an enumerator class. -* Each enumerator class calls this function at init time. -* (probably using gcc/clang * __constructor__ attribute.) -* -* @param param Pointer to a enumerator class registration structure. -* @return an enumerator class handle or ODPDRV_ENUMR_CLASS_INVALID on error. -* On errors, enumerators classes should release allocated resources and return. -*/ -odpdrv_enumr_class_t odpdrv_enumr_class_register(odpdrv_enumr_class_param_t - *param); - -/** -* Register an enumerator. -* Each enumerator calls this function at init time. -* (probably using gcc/clang * __constructor__ attribute.) -* -* @param param Pointer to a enumerator registration parameter structure. -* @return an enumerator handle or ODPDRV_ENUMR_INVALID on error. -* On errors, enumerators should release allocated resources and return. -*/ -odpdrv_enumr_t odpdrv_enumr_register(odpdrv_enumr_param_t *param); - -/** -* Create a device -* Called by each enumerator at probe time, or anytime later, for each -* new created device -* @param param Pointer to a device parameter structure. -* @return an odpdrv devuice handle or ODPDRV_DEVICE_INVALID on error. -*/ -odpdrv_device_t odpdrv_device_create(odpdrv_device_param_t *param); - -/** -* Destroy a device -* Called by each enumerator at probe time, or anytime later, for each -* destroyed created device -* @param dev A odpdrv device handle as returned by odpdrv_device_create. -* @return 0 on success or a negative value on error. -*/ -void odpdrv_device_destroy(odpdrv_device_t dev); - -/** -* Register an devio. -* Each devio calls this function at init time. -* (probably using gcc/clang * __constructor__ attribute.) -* -* @param param Pointer to a devio registration structure. -* @return an odpdrv_devio_t handle or ODPDRV_DEVIO_INVALID on error. -*/ -odpdrv_devio_t odpdrv_devio_register(odpdrv_devio_param_t *param); - -/** -* Register a Driver. -* Each driver calls this function at init time. -* (probably using gcc/clang * __constructor__ attribute.) -* -* @param param Pointer to a driver registration structure. -* @return an odpdrv_driver_t handle or ODPDRV_DRIVER_INVALID on error. -* On errors, drivers should release allocated resources and return. -*/ -odpdrv_driver_t odpdrv_driver_register(odpdrv_driver_param_t *param); - -/** -* Print (ODP_DBG) the driver interface status (debug). -* -* @return 0 on success, less than zero on error (inconsistency detected) -*/ -int odpdrv_print_all(void); - -/** -* @} -*/ - -#ifdef __cplusplus -} -#endif - -#include -#endif diff --git a/include/odp/drv/spec/shm.h b/include/odp/drv/spec/shm.h deleted file mode 100644 index ee8181f27..000000000 --- a/include/odp/drv/spec/shm.h +++ /dev/null @@ -1,330 +0,0 @@ -/* Copyright (c) 2016, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODPRDV shared memory (shm) - */ - -#ifndef ODPDRV_SHM_H_ -#define ODPDRV_SHM_H_ -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** @addtogroup odpdrv_shm ODPDRV SHARED MEMORY - * Operations on driver shared memory. - * @{ - */ - -/** - * @typedef odpdrv_shm_t - * odpdrv shared memory block - */ - -/** - * @def ODPDRV_SHM_INVALID - * Invalid odpdrv shared memory block - */ - -/** Maximum shared memory block name length in chars */ -#define ODPDRV_SHM_NAME_LEN 32 - -/* - * Shared memory flags - */ -#define ODPDRV_SHM_SINGLE_VA 0x01 /**< Memory shall be mapped at same VA */ -#define ODPDRV_SHM_LOCK 0x02 /**< Memory shall be locked (no swap) */ - -/** - * Shared memory block info - */ -typedef struct odpdrv_shm_info_t { - const char *name; /**< Block name */ - void *addr; /**< Block address */ - uint64_t size; /**< Block size in bytes */ - uint64_t page_size; /**< Memory page size */ - uint32_t flags; /**< ODPDRV_SHM_* flags */ -} odpdrv_shm_info_t; - -/** - * Shared memory capabilities - */ -typedef struct odpdrv_shm_capability_t { - /** Maximum number of shared memory blocks - * - * This number of separate shared memory blocks can be - * reserved concurrently. */ - unsigned max_blocks; - - /** Maximum memory block size in bytes - * - * The value of zero means that size is limited only by the available - * memory size. */ - uint64_t max_size; - - /** Maximum memory block alignment in bytes - * - * The value of zero means that alignment is limited only by the - * available memory size. */ - uint64_t max_align; - -} odpdrv_shm_capability_t; - -/** - * Query shared memory capabilities - * - * Outputs shared memory capabilities on success. - * - * @param[out] capa Pointer to capability structure for output - * - * @retval 0 on success - * @retval <0 on failure - */ -int odpdrv_shm_capability(odpdrv_shm_capability_t *capa); - -/** - * Reserve a contiguous block of shared memory - * - * @param[in] name Name of the block (maximum ODPDRV_SHM_NAME_LEN - 1 chars) - * @param[in] size Block size in bytes - * @param[in] align Block alignment in bytes - * @param[in] flags Shared memory parameter flags (ODPDRV_SHM_*). - * Default value is 0. - * - * @return Handle of the reserved block - * @retval ODPDRV_SHM_INVALID on failure - */ -odpdrv_shm_t odpdrv_shm_reserve(const char *name, uint64_t size, uint64_t align, - uint32_t flags); - -/** - * Free a contiguous block of shared memory - * - * Frees a previously reserved block of shared memory (found by its handle). - * @note Freeing memory that is in use will result in UNDEFINED behavior - * - * @param[in] shm odpdrv_shm Block handle - * - * @retval 0 on success - * @retval <0 on failure - */ -int odpdrv_shm_free_by_handle(odpdrv_shm_t shm); - -/** - * Free a contiguous block of shared memory (found from its name) - * - * Frees a previously reserved block of shared memory. - * @note Freeing memory that is in use will result in UNDEFINED behavior - * - * @param[in] name odpdrv_shm Block name - * - * @retval 0 on success - * @retval <0 on failure - */ -int odpdrv_shm_free_by_name(const char *name); - -/** - * Free a contiguous block of shared memory (found from its address) - * - * Frees a previously reserved block of shared memory. - * @note Freeing memory that is in use will result in UNDEFINED behavior - * - * @param[in] address odpdrv_shm Block address - * - * @retval 0 on success - * @retval <0 on failure - */ -int odpdrv_shm_free_by_address(void *address); - -/** - * Lookup and map a block of shared memory (identified by its handle) - * - * @param[in] shm odpdrv_shm Block handle - * - * @return The address of the newly mapped block. - * @retval NULL on failure - */ -void *odpdrv_shm_lookup_by_handle(odpdrv_shm_t shm); - -/** - * Lookup and map a block of shared memory (identified by its name) - * - * @param[in] name odpdrv_shm Block name - * - * @return The handle of the newly mapped block. - * @retval ODPDRV_SHM_INVALID on failure - */ -odpdrv_shm_t odpdrv_shm_lookup_by_name(const char *name); - -/** - * Lookup and map a block of shared memory (identified by its address) - * - * @note This only works when the flag ODPDRV_SHM_SINGLE_VA was set, - * as otherwise addresses are odp-thread local and hence meaningless to - * identify the block between odp-threads. - * - * @param[in] address odpdrv_shm Block address - * - * @return The handle of the newly mapped block. - * @retval ODPDRV_SHM_INVALID on failure - */ -odpdrv_shm_t odpdrv_shm_lookup_by_address(void *address); - -/** - * Get a Shared memory block address - * - * @param[in] shm odpdrv_shm Block handle - * - * @return Memory block address - * @retval NULL on failure - */ -void *odpdrv_shm_addr(odpdrv_shm_t shm); - -/** - * Shared memory block info - * - * @param[in] shm Odpdrv_shm block handle - * @param[out] info Block info pointer for output - * - * @retval 0 on success - * @retval <0 on failure - */ -int odpdrv_shm_info(odpdrv_shm_t shm, odpdrv_shm_info_t *info); - -/** - * Print all shared memory blocks and returns the number of allocated blocks. - * This function is meant for debug. - * @param title A string to be printed before the shared memory status - * @return The total number of allocated blocks - */ -int odpdrv_shm_print_all(const char *title); - -/** - * Get printable value for an odpdrv_shm_t - * - * @param hdl odpdrv_shm_t handle to be printed - * @return uint64_t value that can be used to print/display this - * handle - * - * @note This routine is intended to be used for diagnostic purposes - * to enable applications to generate a printable value that represents - * an odpdrv_shm_t handle. - */ -uint64_t odpdrv_shm_to_u64(odpdrv_shm_t hdl); - -/** - * drv shm pool parameters - * Used to communicate pool creation options. - */ -typedef struct { - /** Sum of all (simultaneous) allocs (bytes)*/ - uint64_t pool_size; - - /** Minimum alloc size user will request from pool (bytes)*/ - uint64_t min_alloc; - - /** Maximum alloc size user will request from pool (bytes)*/ - uint64_t max_alloc; -} odpdrv_shm_pool_param_t; - -/** - * @typedef odpdrv_shm_pool_t - * odpdrv shared memory pool - */ - -/** - * @def ODPDRV_SHM_POOL_INVALID - * Invalid odpdrv shared memory pool - */ - -/** - * Create a memory pool - * - * This routine is used to create a memory pool. The use of pool name is - * optional. - * Unique names are not required. However, odpdrv_shm_pool_lookup() - * returns only a single matching pool. - * - * @param pool_name Name of the pool or NULL. - * @param param Pool parameters. - * - * @return Handle of the created drv shm memory pool - * @retval ODPDRV_SHM_POOL_INVALID Pool could not be created - */ -odpdrv_shm_pool_t odpdrv_shm_pool_create(const char *pool_name, - odpdrv_shm_pool_param_t *param); - -/** - * Destroy a pool previously created by odpdrv_shm_pool_create() - * - * @param pool Handle of the pool to be destroyed - * - * @retval 0 Success - * @retval <0 Failure - * - * @note This routine destroys a previously created pool, and will destroy any - * internal shared memory objects associated with the pool. Results are - * undefined if an attempt is made to destroy a pool that contains allocated - * or otherwise active allocations. - */ -int odpdrv_shm_pool_destroy(odpdrv_shm_pool_t pool); - -/** - * Find a memory pool by name - * - * @param name Name of the pool - * - * @return Handle of the first matching pool - * @retval ODPDRV_SHM_POOL_INVALID Pool could not be found - */ -odpdrv_shm_pool_t odpdrv_shm_pool_lookup(const char *name); - -/** - * Allocate memory from a memory pool - * - * @param pool Memory pool handle - * @param size Number of bytes to allocate (bytes) - * - * @return A pointer to the allocated memory - * @retval NULL on error. - */ -void *odpdrv_shm_pool_alloc(odpdrv_shm_pool_t pool, uint64_t size); - -/** - * Free memory back to a memory pool - * - * @param pool Memory pool handle - * @param addr pointer to a previously allocated memory - * (as returned by a previous call to odpdrv_shm_pool_alloc) - */ -void odpdrv_shm_pool_free(odpdrv_shm_pool_t pool, void *addr); - -/** - * Print memory pool info - * - * @param title A string to be printed as a title (e.g. location) - * @param pool Memory pool handle - * - * @return 0 on success, negative value if pool inconsistency is detected. - * - * @note This routine writes implementation-defined information about the - * specified pool to the ODP log. The intended use is for debugging. - */ -int odpdrv_shm_pool_print(const char *title, odpdrv_shm_pool_t pool); -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#include -#endif diff --git a/include/odp/drv/spec/spinlock.h b/include/odp/drv/spec/spinlock.h deleted file mode 100644 index 52efb565e..000000000 --- a/include/odp/drv/spec/spinlock.h +++ /dev/null @@ -1,86 +0,0 @@ -/* Copyright (c) 2016, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODPDRV spinlock - */ - -#ifndef ODPDRV_API_SPINLOCK_H_ -#define ODPDRV_API_SPINLOCK_H_ -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup odpdrv_locks - * @details - * Spin lock (odpdrv_spinlock_t) - * - * Spinlock simply re-tries to acquire the lock as long as takes to succeed. - * Spinlock is not fair since some threads may succeed more often than others. - * @{ - */ - -/** - * @typedef odpdrv_spinlock_t - * ODPDRV spinlock - */ - -/** - * Initialize spin lock. - * - * @param splock Pointer to a spin lock - */ -void odpdrv_spinlock_init(odpdrv_spinlock_t *splock); - -/** - * Acquire spin lock. - * - * @param splock Pointer to a spin lock - */ -void odpdrv_spinlock_lock(odpdrv_spinlock_t *splock); - -/** - * Try to acquire spin lock. - * - * @param splock Pointer to a spin lock - * - * @retval 0 lock not acquired - * @retval !0 lock acquired - */ -int odpdrv_spinlock_trylock(odpdrv_spinlock_t *splock); - -/** - * Release spin lock. - * - * @param splock Pointer to a spin lock - */ -void odpdrv_spinlock_unlock(odpdrv_spinlock_t *splock); - -/** - * Check if spin lock is busy (locked). - * - * @param splock Pointer to a spin lock - * - * @retval 1 lock busy (locked) - * @retval 0 lock not busy. - */ -int odpdrv_spinlock_is_locked(odpdrv_spinlock_t *splock); - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#include -#endif diff --git a/include/odp/drv/spec/sync.h b/include/odp/drv/spec/sync.h deleted file mode 100644 index ea6068552..000000000 --- a/include/odp/drv/spec/sync.h +++ /dev/null @@ -1,91 +0,0 @@ -/* Copyright (c) 2016, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODPDRV memory barriers - */ - -#ifndef ODPDRV_API_SYNC_H_ -#define ODPDRV_API_SYNC_H_ -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * @addtogroup odpdrv_barrier - * @details - * Memory barriers - * - * Memory barriers enforce ordering of memory load and store operations - * specified before and after the barrier. These barriers may affect both - * compiler optimizations and CPU out-of-order execution. All ODPDRV - * synchronization mechanisms (e.g. execution barriers, locks, queues, etc ) - * include all necessary memory barriers, so these calls are not needed when - * using those. Also ODPDRV atomic operations have memory ordered versions. - * These explicit barriers may be needed when thread synchronization is based on - * a non-ODPDRV defined mechanism. Depending on the HW platform, heavy usage of - * memory barriers may cause significant performance degradation. - * - * @{ - */ - -/** - * Memory barrier for release operations - * - * This memory barrier has release semantics. It synchronizes with a pairing - * barrier for acquire operations. The releasing and acquiring threads - * synchronize through shared memory. The releasing thread must call this - * barrier before signaling the acquiring thread. After the acquiring thread - * receives the signal, it must call odpdrv_mb_acquire() before it reads the - * memory written by the releasing thread. - * - * This call is not needed when using ODPDRV defined synchronization mechanisms. - * - * @see odpdrv_mb_acquire() - */ -void odpdrv_mb_release(void); - -/** - * Memory barrier for acquire operations - * - * This memory barrier has acquire semantics. It synchronizes with a pairing - * barrier for release operations. The releasing and acquiring threads - * synchronize through shared memory. The releasing thread must call - * odpdrv_mb_release() before signaling the acquiring thread. After the - * acquiring thread receives the signal, it must call this barrier before it - * read the memory written by the releasing thread. - * - * This call is not needed when using ODPDRV defined synchronization mechanisms. - * - * @see odpdrv_mb_release() - */ -void odpdrv_mb_acquire(void); - -/** - * Full memory barrier - * - * This is a full memory barrier. It guarantees that all load and store - * operations specified before it are visible to other threads before - * all load and store operations specified after it. - * - * This call is not needed when using ODPDRV defined synchronization mechanisms. - */ -void odpdrv_mb_full(void); - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#include -#endif diff --git a/include/odp_drv.h b/include/odp_drv.h deleted file mode 100644 index 96d81ba6e..000000000 --- a/include/odp_drv.h +++ /dev/null @@ -1,35 +0,0 @@ -/* Copyright (c) 2016, Linaro Limited - * All rights reserved - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * The OpenDataPlane nic driver programming interface - * - */ - -#ifndef ODP_DRV_H_ -#define ODP_DRV_H_ - -#ifdef __cplusplus -extern C { -#endif - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef __cplusplus -} -#endif -#endif diff --git a/platform/linux-generic/_ishm.c b/platform/linux-generic/_ishm.c index 238efb81a..45fd0714d 100644 --- a/platform/linux-generic/_ishm.c +++ b/platform/linux-generic/_ishm.c @@ -54,7 +54,6 @@ #include #include #include -#include #include #include #include @@ -86,7 +85,7 @@ * if some of the block ownwers never procsync() after free). This number * should take that into account) */ -#define ISHM_MAX_NB_BLOCKS ODPDRV_CONFIG_SHM_BLOCKS +#define ISHM_MAX_NB_BLOCKS 128 /* * Maximum internal shared memory block name length in chars diff --git a/platform/linux-generic/_ishmpool.c b/platform/linux-generic/_ishmpool.c index f196a6d82..c72209d90 100644 --- a/platform/linux-generic/_ishmpool.c +++ b/platform/linux-generic/_ishmpool.c @@ -48,7 +48,6 @@ #include #include #include -#include #include #include #include diff --git a/platform/linux-generic/drv_atomic.c b/platform/linux-generic/drv_atomic.c deleted file mode 100644 index 72c85e84e..000000000 --- a/platform/linux-generic/drv_atomic.c +++ /dev/null @@ -1,26 +0,0 @@ -/* Copyright (c) 2016, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include - -int odpdrv_atomic_lock_free_u64(odpdrv_atomic_op_t *atomic_op) -{ -#if __GCC_ATOMIC_LLONG_LOCK_FREE < 2 - /* All operations have locks */ - if (atomic_op) - atomic_op->all_bits = 0; - - return 0; -#else - /* All operations are lock-free */ - if (atomic_op) { - atomic_op->all_bits = ~((uint32_t)0); - atomic_op->op.init = 0; - } - - return 2; -#endif -} diff --git a/platform/linux-generic/drv_barrier.c b/platform/linux-generic/drv_barrier.c deleted file mode 100644 index 7a83981ff..000000000 --- a/platform/linux-generic/drv_barrier.c +++ /dev/null @@ -1,50 +0,0 @@ -/* Copyright (c) 2016, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include -#include -#include -#include - -void odpdrv_barrier_init(odpdrv_barrier_t *barrier, int count) -{ - barrier->count = (uint32_t)count; - odpdrv_atomic_init_u32(&barrier->bar, 0); -} - -/* - * Efficient barrier_sync - - * - * Barriers are initialized with a count of the number of callers - * that must sync on the barrier before any may proceed. - * - * To avoid race conditions and to permit the barrier to be fully - * reusable, the barrier value cycles between 0..2*count-1. When - * synchronizing the wasless variable simply tracks which half of - * the cycle the barrier was in upon entry. Exit is when the - * barrier crosses to the other half of the cycle. - */ -void odpdrv_barrier_wait(odpdrv_barrier_t *barrier) -{ - uint32_t count; - int wasless; - - odpdrv_mb_full(); - - count = odpdrv_atomic_fetch_inc_u32(&barrier->bar); - wasless = count < barrier->count; - - if (count == 2 * barrier->count - 1) { - /* Wrap around *atomically* */ - odpdrv_atomic_sub_u32(&barrier->bar, 2 * barrier->count); - } else { - while ((odpdrv_atomic_load_u32(&barrier->bar) < barrier->count) - == wasless) - odp_cpu_pause(); - } - - odpdrv_mb_full(); -} diff --git a/platform/linux-generic/drv_driver.c b/platform/linux-generic/drv_driver.c deleted file mode 100644 index 529da48fe..000000000 --- a/platform/linux-generic/drv_driver.c +++ /dev/null @@ -1,64 +0,0 @@ -/* Copyright (c) 2017, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include - -#include -#include -#include -#include - -odpdrv_enumr_class_t odpdrv_enumr_class_register(odpdrv_enumr_class_param_t - *param) -{ - ODP_ERR("NOT Supported yet! Enumerator Class %s Registration!\n.", - param->name); - - return ODPDRV_ENUMR_CLASS_INVALID; -} - -odpdrv_enumr_t odpdrv_enumr_register(odpdrv_enumr_param_t *param) -{ - ODP_ERR("NOT Supported yet! Enumerator API %s Registration!\n.", - param->api_name); - - return ODPDRV_ENUMR_INVALID; -} - -odpdrv_device_t odpdrv_device_create(odpdrv_device_param_t *param) -{ - ODP_ERR("odpdrv_device_create not Supported yet! devaddress: %s\n.", - param->address); - return ODPDRV_DEVICE_INVALID; -} - -void odpdrv_device_destroy(odpdrv_device_t dev) -{ - if (dev == ODPDRV_DEVICE_INVALID) - ODP_ERR("Invalid device\n"); -} - -odpdrv_devio_t odpdrv_devio_register(odpdrv_devio_param_t *param) -{ - ODP_ERR("NOT Supported yet! Driver %s Registration!\n.", - param->api_name); - - return ODPDRV_DEVIO_INVALID; -} - -odpdrv_driver_t odpdrv_driver_register(odpdrv_driver_param_t *param) -{ - ODP_ERR("NOT Supported yet! Driver %s Registration!\n.", - param->name); - - return ODPDRV_DRIVER_INVALID; -} - -int odpdrv_print_all(void) -{ - ODP_ERR("odpdrv_print_all not Supported yet!\n."); - return 0; -} diff --git a/platform/linux-generic/drv_shm.c b/platform/linux-generic/drv_shm.c deleted file mode 100644 index 325632e18..000000000 --- a/platform/linux-generic/drv_shm.c +++ /dev/null @@ -1,146 +0,0 @@ -/* Copyright (c) 2016, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include -#include -#include -#include <_ishm_internal.h> -#include <_ishmpool_internal.h> - -static inline uint32_t from_handle(odpdrv_shm_t shm) -{ - return _odpdrv_typeval(shm) - 1; -} - -static inline odpdrv_shm_t to_handle(uint32_t index) -{ - return _odpdrv_cast_scalar(odpdrv_shm_t, index + 1); -} - -int odpdrv_shm_capability(odpdrv_shm_capability_t *capa) -{ - capa->max_blocks = ODPDRV_CONFIG_SHM_BLOCKS; - capa->max_size = 0; - capa->max_align = 0; - - return 0; -} - -odpdrv_shm_t odpdrv_shm_reserve(const char *name, uint64_t size, uint64_t align, - uint32_t flags) -{ - int block_index; - int flgs = 0; /* internal ishm flags */ - - /* set internal ishm flags according to API flags: */ - flgs |= (flags & ODPDRV_SHM_SINGLE_VA) ? _ODP_ISHM_SINGLE_VA : 0; - flgs |= (flags & ODPDRV_SHM_LOCK) ? _ODP_ISHM_LOCK : 0; - - block_index = _odp_ishm_reserve(name, size, -1, align, flgs, flags); - if (block_index >= 0) - return to_handle(block_index); - else - return ODPDRV_SHM_INVALID; -} - -int odpdrv_shm_free_by_handle(odpdrv_shm_t shm) -{ - return _odp_ishm_free_by_index(from_handle(shm)); -} - -int odpdrv_shm_free_by_name(const char *name) -{ - return _odp_ishm_free_by_name(name); -} - -int odpdrv_shm_free_by_address(void *address) -{ - return _odp_ishm_free_by_address(address); -} - -void *odpdrv_shm_lookup_by_handle(odpdrv_shm_t shm) -{ - return _odp_ishm_lookup_by_index(from_handle(shm)); -} - -odpdrv_shm_t odpdrv_shm_lookup_by_name(const char *name) -{ - return to_handle(_odp_ishm_lookup_by_name(name)); -} - -odpdrv_shm_t odpdrv_shm_lookup_by_address(void *address) -{ - return to_handle(_odp_ishm_lookup_by_address(address)); -} - -void *odpdrv_shm_addr(odpdrv_shm_t shm) -{ - return _odp_ishm_address(from_handle(shm)); -} - -int odpdrv_shm_info(odpdrv_shm_t shm, odpdrv_shm_info_t *info) -{ - _odp_ishm_info_t ishm_info; - - if (_odp_ishm_info(from_handle(shm), &ishm_info)) - return -1; - - info->name = ishm_info.name; - info->addr = ishm_info.addr; - info->size = ishm_info.size; - info->page_size = ishm_info.page_size; - info->flags = ishm_info.user_flags; - - return 0; -} - -int odpdrv_shm_print_all(const char *title) -{ - return _odp_ishm_status(title); -} - -odpdrv_shm_pool_t odpdrv_shm_pool_create(const char *pool_name, - odpdrv_shm_pool_param_t *param) -{ - int flags; - - /* force unique address for all ODP threads */ - flags = _ODP_ISHM_SINGLE_VA; - return (odpdrv_shm_pool_t)_odp_ishm_pool_create(pool_name, - param->pool_size, - param->min_alloc, - param->max_alloc, - flags); -} - -int odpdrv_shm_pool_destroy(odpdrv_shm_pool_t pool) -{ - return _odp_ishm_pool_destroy((_odp_ishm_pool_t *)(void*)pool); -} - -odpdrv_shm_pool_t odpdrv_shm_pool_lookup(const char *name) -{ - return (odpdrv_shm_pool_t)_odp_ishm_pool_lookup(name); -} - -void *odpdrv_shm_pool_alloc(odpdrv_shm_pool_t pool, uint64_t size) -{ - return _odp_ishm_pool_alloc((_odp_ishm_pool_t *)(void*)pool, size); -} - -void odpdrv_shm_pool_free(odpdrv_shm_pool_t pool, void *addr) -{ - (void)_odp_ishm_pool_free((_odp_ishm_pool_t *)(void*)pool, addr); -} - -int odpdrv_shm_pool_print(const char *title, odpdrv_shm_pool_t pool) -{ - return _odp_ishm_pool_status(title, (_odp_ishm_pool_t *)(void*)pool); -} - -/** - * @} - */ diff --git a/platform/linux-generic/drv_spinlock.c b/platform/linux-generic/drv_spinlock.c deleted file mode 100644 index 69e3da769..000000000 --- a/platform/linux-generic/drv_spinlock.c +++ /dev/null @@ -1,39 +0,0 @@ -/* Copyright (c) 2016, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include -#include - -void odpdrv_spinlock_init(odpdrv_spinlock_t *spinlock) -{ - _odp_atomic_flag_init(&spinlock->lock, 0); -} - -void odpdrv_spinlock_lock(odpdrv_spinlock_t *spinlock) -{ - /* While the lock is already taken... */ - while (_odp_atomic_flag_tas(&spinlock->lock)) - /* ...spin reading the flag (relaxed MM), - * the loop will exit when the lock becomes available - * and we will retry the TAS operation above */ - while (_odp_atomic_flag_load(&spinlock->lock)) - odp_cpu_pause(); -} - -int odpdrv_spinlock_trylock(odpdrv_spinlock_t *spinlock) -{ - return (_odp_atomic_flag_tas(&spinlock->lock) == 0); -} - -void odpdrv_spinlock_unlock(odpdrv_spinlock_t *spinlock) -{ - _odp_atomic_flag_clear(&spinlock->lock); -} - -int odpdrv_spinlock_is_locked(odpdrv_spinlock_t *spinlock) -{ - return _odp_atomic_flag_load(&spinlock->lock) != 0; -} diff --git a/platform/linux-generic/include/odp/drv/align.h b/platform/linux-generic/include/odp/drv/align.h deleted file mode 100644 index 7636f8938..000000000 --- a/platform/linux-generic/include/odp/drv/align.h +++ /dev/null @@ -1,58 +0,0 @@ -/* Copyright (c) 2016, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODPDRV alignments - */ - -#ifndef ODPDRV_PLAT_ALIGN_H_ -#define ODPDRV_PLAT_ALIGN_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -/** @ingroup odpdrv_compiler_optim - * @{ - */ - -#ifdef __GNUC__ - -#define ODPDRV_ALIGNED(x) __attribute__((__aligned__(x))) - -#define ODPDRV_PACKED __attribute__((__packed__)) - -#define ODPDRV_OFFSETOF(type, member) __builtin_offsetof(type, member) - -#define ODPDRV_FIELD_SIZEOF(type, member) sizeof(((type *)0)->member) - -#else -#error Non-gcc compatible compiler -#endif - -#define ODPDRV_CACHE_LINE_SIZE _ODP_CACHE_LINE_SIZE - -#define ODPDRV_PAGE_SIZE 4096 - -#define ODPDRV_ALIGNED_CACHE ODPDRV_ALIGNED(ODPDRV_CACHE_LINE_SIZE) - -#define ODPDRV_ALIGNED_PAGE ODPDRV_ALIGNED(ODPDRV_PAGE_SIZE) - -/** - * @} - */ - -#include - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/drv/atomic.h b/platform/linux-generic/include/odp/drv/atomic.h deleted file mode 100644 index 7d922da21..000000000 --- a/platform/linux-generic/include/odp/drv/atomic.h +++ /dev/null @@ -1,430 +0,0 @@ -/* Copyright (c) 2016, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODPDRV atomic operations - */ - -#ifndef ODPDRV_PLAT_ATOMIC_H_ -#define ODPDRV_PLAT_ATOMIC_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -/** @ingroup odpdrv_atomic - * @{ - */ - -static inline void odpdrv_atomic_init_u32(odpdrv_atomic_u32_t *atom, - uint32_t val) -{ - __atomic_store_n(&atom->v, val, __ATOMIC_RELAXED); -} - -static inline uint32_t odpdrv_atomic_load_u32(odpdrv_atomic_u32_t *atom) -{ - return __atomic_load_n(&atom->v, __ATOMIC_RELAXED); -} - -static inline void odpdrv_atomic_store_u32(odpdrv_atomic_u32_t *atom, - uint32_t val) -{ - __atomic_store_n(&atom->v, val, __ATOMIC_RELAXED); -} - -static inline uint32_t odpdrv_atomic_fetch_add_u32(odpdrv_atomic_u32_t *atom, - uint32_t val) -{ - return __atomic_fetch_add(&atom->v, val, __ATOMIC_RELAXED); -} - -static inline void odpdrv_atomic_add_u32(odpdrv_atomic_u32_t *atom, - uint32_t val) -{ - (void)__atomic_fetch_add(&atom->v, val, __ATOMIC_RELAXED); -} - -static inline uint32_t odpdrv_atomic_fetch_sub_u32(odpdrv_atomic_u32_t *atom, - uint32_t val) -{ - return __atomic_fetch_sub(&atom->v, val, __ATOMIC_RELAXED); -} - -static inline void odpdrv_atomic_sub_u32(odpdrv_atomic_u32_t *atom, - uint32_t val) -{ - (void)__atomic_fetch_sub(&atom->v, val, __ATOMIC_RELAXED); -} - -static inline uint32_t odpdrv_atomic_fetch_inc_u32(odpdrv_atomic_u32_t *atom) -{ - return __atomic_fetch_add(&atom->v, 1, __ATOMIC_RELAXED); -} - -static inline void odpdrv_atomic_inc_u32(odpdrv_atomic_u32_t *atom) -{ - (void)__atomic_fetch_add(&atom->v, 1, __ATOMIC_RELAXED); -} - -static inline uint32_t odpdrv_atomic_fetch_dec_u32(odpdrv_atomic_u32_t *atom) -{ - return __atomic_fetch_sub(&atom->v, 1, __ATOMIC_RELAXED); -} - -static inline void odpdrv_atomic_dec_u32(odpdrv_atomic_u32_t *atom) -{ - (void)__atomic_fetch_sub(&atom->v, 1, __ATOMIC_RELAXED); -} - -static inline int odpdrv_atomic_cas_u32(odpdrv_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_RELAXED, - __ATOMIC_RELAXED); -} - -static inline uint32_t odpdrv_atomic_xchg_u32(odpdrv_atomic_u32_t *atom, - uint32_t new_val) -{ - return __atomic_exchange_n(&atom->v, new_val, __ATOMIC_RELAXED); -} - -static inline void odpdrv_atomic_max_u32(odpdrv_atomic_u32_t *atom, - uint32_t new_max) -{ - uint32_t old_val; - - old_val = odpdrv_atomic_load_u32(atom); - - while (new_max > old_val) { - if (odpdrv_atomic_cas_u32(atom, &old_val, new_max)) - break; - } -} - -static inline void odpdrv_atomic_min_u32(odpdrv_atomic_u32_t *atom, - uint32_t new_min) -{ - uint32_t old_val; - - old_val = odpdrv_atomic_load_u32(atom); - - while (new_min < old_val) { - if (odpdrv_atomic_cas_u32(atom, &old_val, new_min)) - break; - } -} - -static inline void odpdrv_atomic_init_u64(odpdrv_atomic_u64_t *atom, - uint64_t val) -{ - atom->v = val; -#if __GCC_ATOMIC_LLONG_LOCK_FREE < 2 - __atomic_clear(&atom->lock, __ATOMIC_RELAXED); -#endif -} - -static inline uint64_t odpdrv_atomic_load_u64(odpdrv_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 -} - -static inline void odpdrv_atomic_store_u64(odpdrv_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 -} - -static inline uint64_t odpdrv_atomic_fetch_add_u64(odpdrv_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 -} - -static inline void odpdrv_atomic_add_u64(odpdrv_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 -} - -static inline uint64_t odpdrv_atomic_fetch_sub_u64(odpdrv_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 -} - -static inline void odpdrv_atomic_sub_u64(odpdrv_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 -} - -static inline uint64_t odpdrv_atomic_fetch_inc_u64(odpdrv_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 -} - -static inline void odpdrv_atomic_inc_u64(odpdrv_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 -} - -static inline uint64_t odpdrv_atomic_fetch_dec_u64(odpdrv_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 -} - -static inline void odpdrv_atomic_dec_u64(odpdrv_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 -} - -static inline int odpdrv_atomic_cas_u64(odpdrv_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 -} - -static inline uint64_t odpdrv_atomic_xchg_u64(odpdrv_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 -} - -static inline void odpdrv_atomic_max_u64(odpdrv_atomic_u64_t *atom, - uint64_t new_max) -{ - uint64_t old_val; - - old_val = odpdrv_atomic_load_u64(atom); - - while (new_max > old_val) { - if (odpdrv_atomic_cas_u64(atom, &old_val, new_max)) - break; - } -} - -static inline void odpdrv_atomic_min_u64(odpdrv_atomic_u64_t *atom, - uint64_t new_min) -{ - uint64_t old_val; - - old_val = odpdrv_atomic_load_u64(atom); - - while (new_min < old_val) { - if (odpdrv_atomic_cas_u64(atom, &old_val, new_min)) - break; - } -} - -static inline uint32_t odpdrv_atomic_load_acq_u32(odpdrv_atomic_u32_t *atom) -{ - return __atomic_load_n(&atom->v, __ATOMIC_ACQUIRE); -} - -static inline void odpdrv_atomic_store_rel_u32(odpdrv_atomic_u32_t *atom, - uint32_t val) -{ - __atomic_store_n(&atom->v, val, __ATOMIC_RELEASE); -} - -static inline void odpdrv_atomic_add_rel_u32(odpdrv_atomic_u32_t *atom, - uint32_t val) -{ - (void)__atomic_fetch_add(&atom->v, val, __ATOMIC_RELEASE); -} - -static inline void odpdrv_atomic_sub_rel_u32(odpdrv_atomic_u32_t *atom, - uint32_t val) -{ - (void)__atomic_fetch_sub(&atom->v, val, __ATOMIC_RELEASE); -} - -static inline int odpdrv_atomic_cas_acq_u32(odpdrv_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); -} - -static inline int odpdrv_atomic_cas_rel_u32(odpdrv_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); -} - -static inline int odpdrv_atomic_cas_acq_rel_u32(odpdrv_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); -} - -static inline uint64_t odpdrv_atomic_load_acq_u64(odpdrv_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 -} - -static inline void odpdrv_atomic_store_rel_u64(odpdrv_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 -} - -static inline void odpdrv_atomic_add_rel_u64(odpdrv_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 -} - -static inline void odpdrv_atomic_sub_rel_u64(odpdrv_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 -} - -static inline int odpdrv_atomic_cas_acq_u64(odpdrv_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 -} - -static inline int odpdrv_atomic_cas_rel_u64(odpdrv_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 -} - -static inline int odpdrv_atomic_cas_acq_rel_u64(odpdrv_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 -} - -/** - * @} - */ - -#include - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/drv/barrier.h b/platform/linux-generic/include/odp/drv/barrier.h deleted file mode 100644 index 877cacf8b..000000000 --- a/platform/linux-generic/include/odp/drv/barrier.h +++ /dev/null @@ -1,30 +0,0 @@ -/* Copyright (c) 2016, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODPDRV execution barriers - */ - -#ifndef ODPDRV_PLAT_BARRIER_H_ -#define ODPDRV_PLAT_BARRIER_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include - -#include - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/drv/byteorder.h b/platform/linux-generic/include/odp/drv/byteorder.h deleted file mode 100644 index 3991b2656..000000000 --- a/platform/linux-generic/include/odp/drv/byteorder.h +++ /dev/null @@ -1,146 +0,0 @@ -/* Copyright (c) 2016, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODPDRV byteorder - */ - -#ifndef ODPDRV_PLAT_BYTEORDER_H_ -#define ODPDRV_PLAT_BYTEORDER_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include -#include - -/** @ingroup odpdrv_compiler_optim - * @{ - */ - -static inline uint16_t odpdrv_be_to_cpu_16(odpdrv_u16be_t be16) -{ -#if ODPDRV_BYTE_ORDER == ODPDRV_LITTLE_ENDIAN - return __odpdrv_builtin_bswap16((__odpdrv_force uint16_t)be16); -#else - return (__odpdrv_force uint16_t)be16; -#endif -} - -static inline uint32_t odpdrv_be_to_cpu_32(odpdrv_u32be_t be32) -{ -#if ODPDRV_BYTE_ORDER == ODPDRV_LITTLE_ENDIAN - return __builtin_bswap32((__odpdrv_force uint32_t)be32); -#else - return (__odpdrv_force uint32_t)be32; -#endif -} - -static inline uint64_t odpdrv_be_to_cpu_64(odpdrv_u64be_t be64) -{ -#if ODPDRV_BYTE_ORDER == ODPDRV_LITTLE_ENDIAN - return __builtin_bswap64((__odpdrv_force uint64_t)be64); -#else - return (__odpdrv_force uint64_t)be64; -#endif -} - -static inline odpdrv_u16be_t odpdrv_cpu_to_be_16(uint16_t cpu16) -{ -#if ODPDRV_BYTE_ORDER == ODPDRV_LITTLE_ENDIAN - return (__odpdrv_force odpdrv_u16be_t)__odpdrv_builtin_bswap16(cpu16); -#else - return (__odpdrv_force odpdrv_u16be_t)cpu16; -#endif -} - -static inline odpdrv_u32be_t odpdrv_cpu_to_be_32(uint32_t cpu32) -{ -#if ODPDRV_BYTE_ORDER == ODPDRV_LITTLE_ENDIAN - return (__odpdrv_force odpdrv_u32be_t)__builtin_bswap32(cpu32); -#else - return (__odpdrv_force odpdrv_u32be_t)cpu32; -#endif -} - -static inline odpdrv_u64be_t odpdrv_cpu_to_be_64(uint64_t cpu64) -{ -#if ODPDRV_BYTE_ORDER == ODPDRV_LITTLE_ENDIAN - return (__odpdrv_force odpdrv_u64be_t)__builtin_bswap64(cpu64); -#else - return (__odpdrv_force odpdrv_u64be_t)cpu64; -#endif -} - -static inline uint16_t odpdrv_le_to_cpu_16(odpdrv_u16le_t le16) -{ -#if ODPDRV_BYTE_ORDER == ODPDRV_LITTLE_ENDIAN - return (__odpdrv_force uint16_t)le16; -#else - return __odpdrv_builtin_bswap16((__odpdrv_force uint16_t)le16); -#endif -} - -static inline uint32_t odpdrv_le_to_cpu_32(odpdrv_u32le_t le32) -{ -#if ODPDRV_BYTE_ORDER == ODPDRV_LITTLE_ENDIAN - return (__odpdrv_force uint32_t)le32; -#else - return __builtin_bswap32((__odpdrv_force uint32_t)le32); -#endif -} - -static inline uint64_t odpdrv_le_to_cpu_64(odpdrv_u64le_t le64) -{ -#if ODPDRV_BYTE_ORDER == ODPDRV_LITTLE_ENDIAN - return (__odpdrv_force uint64_t)le64; -#else - return __builtin_bswap64((__odpdrv_force uint64_t)le64); -#endif -} - -static inline odpdrv_u16le_t odpdrv_cpu_to_le_16(uint16_t cpu16) -{ -#if ODPDRV_BYTE_ORDER == ODPDRV_LITTLE_ENDIAN - return (__odpdrv_force odpdrv_u16le_t)cpu16; -#else - return (__odpdrv_force odpdrv_u16le_t)__odpdrv_builtin_bswap16(cpu16); -#endif -} - -static inline odpdrv_u32le_t odpdrv_cpu_to_le_32(uint32_t cpu32) -{ -#if ODPDRV_BYTE_ORDER == ODPDRV_LITTLE_ENDIAN - return (__odpdrv_force odpdrv_u32le_t)cpu32; -#else - return (__odpdrv_force odpdrv_u32le_t)__builtin_bswap32(cpu32); -#endif -} - -static inline odpdrv_u64le_t odpdrv_cpu_to_le_64(uint64_t cpu64) -{ -#if ODPDRV_BYTE_ORDER == ODPDRV_LITTLE_ENDIAN - return (__odpdrv_force odpdrv_u64le_t)cpu64; -#else - return (__odpdrv_force odpdrv_u64le_t)__builtin_bswap64(cpu64); -#endif -} - -/** - * @} - */ - -#include - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/drv/driver.h b/platform/linux-generic/include/odp/drv/driver.h deleted file mode 100644 index b12c83da6..000000000 --- a/platform/linux-generic/include/odp/drv/driver.h +++ /dev/null @@ -1,37 +0,0 @@ -/* Copyright (c) 2017, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODPDRV drivers - */ - -#ifndef ODPDRV_PLAT_DRIVER_H_ -#define ODPDRV_PLAT_DRIVER_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -/** @ingroup odpdrv_driver - * @{ - */ - -/** - * @} - */ - -#include -#include - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/drv/plat/atomic_types.h b/platform/linux-generic/include/odp/drv/plat/atomic_types.h deleted file mode 100644 index 6a7ff0d7e..000000000 --- a/platform/linux-generic/include/odp/drv/plat/atomic_types.h +++ /dev/null @@ -1,88 +0,0 @@ -/* Copyright (c) 2016, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODPDRV atomic operations - */ - -#ifndef ODPDRV_ATOMIC_TYPES_H_ -#define ODPDRV_ATOMIC_TYPES_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -/** - * @internal - * Atomic 64-bit unsigned integer - */ -struct odpdrv_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 -} ODPDRV_ALIGNED(sizeof(uint64_t)); /* Enforce alignement! */; - -/** - * @internal - * Atomic 32-bit unsigned integer - */ -struct odpdrv_atomic_u32_s { - uint32_t v; /**< Actual storage for the atomic variable */ -} ODPDRV_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 odpdrv_atomic_u64_s odpdrv_atomic_u64_t; - -typedef struct odpdrv_atomic_u32_s odpdrv_atomic_u32_t; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/drv/plat/barrier_types.h b/platform/linux-generic/include/odp/drv/plat/barrier_types.h deleted file mode 100644 index 32264a134..000000000 --- a/platform/linux-generic/include/odp/drv/plat/barrier_types.h +++ /dev/null @@ -1,38 +0,0 @@ -/* Copyright (c) 2016, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODPDRV barrier - */ - -#ifndef ODPDRV_BARRIER_TYPES_H_ -#define ODPDRV_BARRIER_TYPES_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -/** - * @internal - * ODPDRV thread synchronization barrier - */ -struct odpdrv_barrier_s { - uint32_t count; /**< Thread count */ - odpdrv_atomic_u32_t bar; /**< Barrier counter */ -}; - -typedef struct odpdrv_barrier_s odpdrv_barrier_t; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/drv/plat/byteorder_types.h b/platform/linux-generic/include/odp/drv/plat/byteorder_types.h deleted file mode 100644 index 5dd182d9b..000000000 --- a/platform/linux-generic/include/odp/drv/plat/byteorder_types.h +++ /dev/null @@ -1,84 +0,0 @@ -/* Copyright (c) 2016, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODPDRV byteorder - */ - -#ifndef ODPDRV_BYTEORDER_TYPES_H_ -#define ODPDRV_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 __odpdrv_bitwise __attribute__((bitwise)) -/** @internal force attribute */ -#define __odpdrv_force __attribute__((force)) -#else -/** @internal bitwise attribute */ -#define __odpdrv_bitwise -/** @internal force attribute */ -#define __odpdrv_force -#endif - -/** @addtogroup odpdrv_compiler_optim - * @{ - */ -#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ - #define ODPDRV_LITTLE_ENDIAN 1 - #define ODPDRV_BIG_ENDIAN 0 - #define ODPDRV_BYTE_ORDER ODPDRV_LITTLE_ENDIAN - #define ODPDRV_LITTLE_ENDIAN_BITFIELD 1 - #define ODPDRV_BIG_ENDIAN_BITFIELD 0 - #define ODPDRV_BITFIELD_ORDER ODPDRV_LITTLE_ENDIAN_BITFIELD -#else - #define ODPDRV_LITTLE_ENDIAN 0 - #define ODPDRV_BIG_ENDIAN 1 - #define ODPDRV_BYTE_ORDER ODPDRV_BIG_ENDIAN - #define ODPDRV_LITTLE_ENDIAN_BITFIELD 0 - #define ODPDRV_BIG_ENDIAN_BITFIELD 1 - #define ODPDRV_BITFIELD_ORDER ODPDRV_BIG_ENDIAN_BITFIELD -#endif - -typedef uint16_t __odpdrv_bitwise odpdrv_u16le_t; -typedef uint16_t __odpdrv_bitwise odpdrv_u16be_t; - -typedef uint32_t __odpdrv_bitwise odpdrv_u32le_t; -typedef uint32_t __odpdrv_bitwise odpdrv_u32be_t; - -typedef uint64_t __odpdrv_bitwise odpdrv_u64le_t; -typedef uint64_t __odpdrv_bitwise odpdrv_u64be_t; - -typedef uint16_t __odpdrv_bitwise odpdrv_u16sum_t; -typedef uint32_t __odpdrv_bitwise odpdrv_u32sum_t; - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/drv/plat/driver_types.h b/platform/linux-generic/include/odp/drv/plat/driver_types.h deleted file mode 100644 index 6c611bd94..000000000 --- a/platform/linux-generic/include/odp/drv/plat/driver_types.h +++ /dev/null @@ -1,52 +0,0 @@ -/* Copyright (c) 2017, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP shared memory - */ - -#ifndef ODPDRV_DRIVER_TYPES_H_ -#define ODPDRV_DRIVER_TYPES_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -/** @addtogroup odpdrv_driver ODPDRV DRIVER - * Operations on driver related items (enumerator class, enumerators, - * devios and drivers). - * @{ - */ - -typedef ODPDRV_HANDLE_T(odpdrv_enumr_class_t); -#define ODPDRV_ENUMR_CLASS_INVALID _odpdrv_cast_scalar(odpdrv_enumr_class_t, 0) - -typedef ODPDRV_HANDLE_T(odpdrv_enumr_t); -#define ODPDRV_ENUMR_INVALID _odpdrv_cast_scalar(odpdrv_enumr_t, 0) - -typedef ODPDRV_HANDLE_T(odpdrv_device_t); -#define ODPDRV_DEVICE_INVALID _odpdrv_cast_scalar(odpdrv_device_t, 0) - -typedef ODPDRV_HANDLE_T(odpdrv_devio_t); -#define ODPDRV_DEVIO_INVALID _odpdrv_cast_scalar(odpdrv_devio_t, 0) - -typedef ODPDRV_HANDLE_T(odpdrv_driver_t); -#define ODPDRV_DRIVER_INVALID _odpdrv_cast_scalar(odpdrv_driver_t, 0) - -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/drv/plat/shm_types.h b/platform/linux-generic/include/odp/drv/plat/shm_types.h deleted file mode 100644 index 50a083778..000000000 --- a/platform/linux-generic/include/odp/drv/plat/shm_types.h +++ /dev/null @@ -1,49 +0,0 @@ -/* Copyright (c) 2016, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODP shared memory - */ - -#ifndef ODPDRV_SHM_TYPES_H_ -#define ODPDRV_SHM_TYPES_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include - -/** @addtogroup odpdrv_shm ODPDRV SHARED MEMORY - * Operations on driver shared memory. - * @{ - */ - -typedef ODPDRV_HANDLE_T(odpdrv_shm_t); - -#define ODPDRV_SHM_INVALID _odpdrv_cast_scalar(odpdrv_shm_t, 0) - -/** Get printable format of odpdrv_shm_t */ -static inline uint64_t odpdrv_shm_to_u64(odpdrv_shm_t hdl) -{ - return _odpdrv_pri(hdl); -} - -typedef ODPDRV_HANDLE_T(odpdrv_shm_pool_t); - -#define ODPDRV_SHM_POOL_INVALID _odpdrv_cast_scalar(odpdrv_shm_pool_t, NULL) -/** - * @} - */ - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/drv/plat/spinlock_types.h b/platform/linux-generic/include/odp/drv/plat/spinlock_types.h deleted file mode 100644 index 41dd9acc2..000000000 --- a/platform/linux-generic/include/odp/drv/plat/spinlock_types.h +++ /dev/null @@ -1,33 +0,0 @@ -/* Copyright (c) 2016, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODPDRV spinlock - */ - -#ifndef ODPDRV_SPINLOCK_TYPES_H_ -#define ODPDRV_SPINLOCK_TYPES_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -/** @internal */ -struct odpdrv_spinlock_s { - char lock; /**< lock flag, should match odpdrv_atomic_flag_t */ -}; - -typedef struct odpdrv_spinlock_s odpdrv_spinlock_t; - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/drv/plat/strong_types.h b/platform/linux-generic/include/odp/drv/plat/strong_types.h deleted file mode 100644 index a9c48efbe..000000000 --- a/platform/linux-generic/include/odp/drv/plat/strong_types.h +++ /dev/null @@ -1,35 +0,0 @@ -/* Copyright (c) 2016, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODPDRV Strong Types. Common macros for implementing strong typing - * for ODPDRV abstract data types - */ - -#ifndef ODPDRV_STRONG_TYPES_H_ -#define ODPDRV_STRONG_TYPES_H_ - -/** Use strong typing for ODPDRV types */ -#ifdef __cplusplus -#define ODPDRV_HANDLE_T(type) struct _##type { uint8_t unused_dummy_var; } *type -#else -#define odpdrv_handle_t struct { uint8_t unused_dummy_var; } * -/** C/C++ helper macro for strong typing */ -#define ODPDRV_HANDLE_T(type) odpdrv_handle_t type -#endif - -/** Internal macro to get value of an ODPDRV handle */ -#define _odpdrv_typeval(handle) ((uint32_t)(uintptr_t)(handle)) - -/** Internal macro to get printable value of an ODPDRV handle */ -#define _odpdrv_pri(handle) ((uint64_t)_odpdrv_typeval(handle)) - -/** Internal macro to convert a scalar to a typed handle */ -#define _odpdrv_cast_scalar(type, val) ((type)(uintptr_t)(val)) - -#endif diff --git a/platform/linux-generic/include/odp/drv/shm.h b/platform/linux-generic/include/odp/drv/shm.h deleted file mode 100644 index 644b03668..000000000 --- a/platform/linux-generic/include/odp/drv/shm.h +++ /dev/null @@ -1,36 +0,0 @@ -/* Copyright (c) 2016, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODPDRV shared memory - */ - -#ifndef ODPDRV_PLAT_SHM_H_ -#define ODPDRV_PLAT_SHM_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -/** @ingroup odpdrv_shm - * @{ - */ - -/** - * @} - */ - -#include - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/drv/spinlock.h b/platform/linux-generic/include/odp/drv/spinlock.h deleted file mode 100644 index dd05f8c60..000000000 --- a/platform/linux-generic/include/odp/drv/spinlock.h +++ /dev/null @@ -1,28 +0,0 @@ -/* Copyright (c) 2016, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODPDRV spinlock - */ - -#ifndef ODPDRV_PLAT_SPINLOCK_H_ -#define ODPDRV_PLAT_SPINLOCK_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -#include - -#include - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp/drv/sync.h b/platform/linux-generic/include/odp/drv/sync.h deleted file mode 100644 index 58521382d..000000000 --- a/platform/linux-generic/include/odp/drv/sync.h +++ /dev/null @@ -1,49 +0,0 @@ -/* Copyright (c) 2016, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -/** - * @file - * - * ODPDRV synchronisation - */ - -#ifndef ODPDRV_PLAT_SYNC_H_ -#define ODPDRV_PLAT_SYNC_H_ - -#ifdef __cplusplus -extern "C" { -#endif - -/** @ingroup odpdrv_barrier - * @{ - */ - -static inline void odpdrv_mb_release(void) -{ - __atomic_thread_fence(__ATOMIC_RELEASE); -} - -static inline void odpdrv_mb_acquire(void) -{ - __atomic_thread_fence(__ATOMIC_ACQUIRE); -} - -static inline void odpdrv_mb_full(void) -{ - __atomic_thread_fence(__ATOMIC_SEQ_CST); -} - -/** - * @} - */ - -#include - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/platform/linux-generic/include/odp_config_internal.h b/platform/linux-generic/include/odp_config_internal.h index 9b334df49..c83e573b5 100644 --- a/platform/linux-generic/include/odp_config_internal.h +++ b/platform/linux-generic/include/odp_config_internal.h @@ -134,12 +134,6 @@ */ #define ODP_CONFIG_ISHM_VA_PREALLOC_SZ (536870912L) -/* Maximum number of shared memory blocks available on the driver interface. - * - * This the the number of separate SHM areas that can be reserved concurrently - */ -#define ODPDRV_CONFIG_SHM_BLOCKS 48 - /* Maximum event burst size * * This controls the burst size on various enqueue, dequeue, etc calls. Large diff --git a/test/m4/configure.m4 b/test/m4/configure.m4 index 92bb53ad6..ef6096e87 100644 --- a/test/m4/configure.m4 +++ b/test/m4/configure.m4 @@ -32,7 +32,4 @@ AC_CONFIG_FILES([test/Makefile test/validation/api/thread/Makefile test/validation/api/time/Makefile test/validation/api/timer/Makefile - test/validation/api/traffic_mngr/Makefile - test/validation/drv/Makefile - test/validation/drv/drvatomic/Makefile - test/validation/drv/drvshmem/Makefile]) + test/validation/api/traffic_mngr/Makefile]) diff --git a/test/validation/Makefile.am b/test/validation/Makefile.am index 17e0444be..328543780 100644 --- a/test/validation/Makefile.am +++ b/test/validation/Makefile.am @@ -1,4 +1,3 @@ if test_vald - SUBDIRS = api \ - drv + SUBDIRS = api endif diff --git a/test/validation/drv/.gitignore b/test/validation/drv/.gitignore deleted file mode 100644 index 7e563b8b3..000000000 --- a/test/validation/drv/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*.log -*.trs diff --git a/test/validation/drv/Makefile.am b/test/validation/drv/Makefile.am deleted file mode 100644 index e445adf5d..000000000 --- a/test/validation/drv/Makefile.am +++ /dev/null @@ -1,4 +0,0 @@ -ODPDRV_MODULES = drvatomic \ - drvshmem - -SUBDIRS = $(ODPDRV_MODULES) diff --git a/test/validation/drv/Makefile.inc b/test/validation/drv/Makefile.inc deleted file mode 100644 index 5f8fbbb60..000000000 --- a/test/validation/drv/Makefile.inc +++ /dev/null @@ -1 +0,0 @@ -include $(top_srcdir)/test/validation/Makefile.inc diff --git a/test/validation/drv/README b/test/validation/drv/README deleted file mode 100644 index d1a9e6f4f..000000000 --- a/test/validation/drv/README +++ /dev/null @@ -1,35 +0,0 @@ -Copyright (c) 2016, Linaro Limited -All rights reserved. - -SPDX-License-Identifier: BSD-3-Clause - - -To add tests in here, please observe the rules listed below. This list -is a brief overview, for a more detailed explanation of the test -framework refer to the ODP Implementers' Guide, which can built as -follows: - - ./configure --enable-user-guides - make - -Output will be in doc/output/. If this fails, check the documentation -section of the DEPENDENCIES file. - -Rules for all tests under this tree: - -1. Tests must be placed in the directory of the module they belong to. - -2. Tests must be platform agnostic, i.e. - - - should be written in plain C only. - - may only use C standard library functions, CUnit functions and of - course ODP functions - - should be expected to pass on all ODP implementations - - Tests that do not follow these rules should be placed in the platform - specific test area (currently platform//test/). - -3. If a new ODP DRV module is created, please update the Makefile.am. - -4. Symbols exported from test libraries must respect the naming - convention detailed in the ODP Implementers' Guide. diff --git a/test/validation/drv/drvatomic/.gitignore b/test/validation/drv/drvatomic/.gitignore deleted file mode 100644 index 3b5e51024..000000000 --- a/test/validation/drv/drvatomic/.gitignore +++ /dev/null @@ -1 +0,0 @@ -drvatomic_main diff --git a/test/validation/drv/drvatomic/Makefile.am b/test/validation/drv/drvatomic/Makefile.am deleted file mode 100644 index 53e971c9c..000000000 --- a/test/validation/drv/drvatomic/Makefile.am +++ /dev/null @@ -1,10 +0,0 @@ -include ../Makefile.inc - -noinst_LTLIBRARIES = libtestdrvatomic.la -libtestdrvatomic_la_SOURCES = drvatomic.c - -test_PROGRAMS = drvatomic_main$(EXEEXT) -dist_drvatomic_main_SOURCES = drvatomic_main.c -drvatomic_main_LDADD = libtestdrvatomic.la $(LIBCUNIT_COMMON) $(LIBODP) - -EXTRA_DIST = drvatomic.h diff --git a/test/validation/drv/drvatomic/drvatomic.c b/test/validation/drv/drvatomic/drvatomic.c deleted file mode 100644 index cc5e4415e..000000000 --- a/test/validation/drv/drvatomic/drvatomic.c +++ /dev/null @@ -1,892 +0,0 @@ -/* Copyright (c) 2016, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include -#include -#include -#include -#include -#include -#include "drvatomic.h" - -#define VERBOSE 0 -#define MAX_ITERATIONS 1000 - -#define ADD_SUB_CNT 5 - -#define CNT 10 -#define U32_INIT_VAL (1UL << 10) -#define U64_INIT_VAL (1ULL << 33) -#define U32_MAGIC 0xa23f65b2 -#define U64_MAGIC 0xf2e1c5430cb6a52e - -#define GLOBAL_SHM_NAME "GlobalLockTest" - -#define UNUSED __attribute__((__unused__)) - -#define CHECK_MAX_MIN (1 << 0) -#define CHECK_XCHG (1 << 2) - -static odpdrv_atomic_u32_t a32u; -static odpdrv_atomic_u64_t a64u; -static odpdrv_atomic_u32_t a32u_min; -static odpdrv_atomic_u32_t a32u_max; -static odpdrv_atomic_u64_t a64u_min; -static odpdrv_atomic_u64_t a64u_max; -static odpdrv_atomic_u32_t a32u_xchg; -static odpdrv_atomic_u64_t a64u_xchg; - -typedef __volatile uint32_t volatile_u32_t; -typedef __volatile uint64_t volatile_u64_t; - -typedef struct { - /* Global variables */ - uint32_t g_num_threads; - uint32_t g_iterations; - uint32_t g_verbose; - uint32_t g_max_num_cores; - - volatile_u32_t global_lock_owner; -} global_shared_mem_t; - -/* Per-thread memory */ -typedef struct { - global_shared_mem_t *global_mem; - - int thread_id; - int thread_core; - - volatile_u64_t delay_counter; -} per_thread_mem_t; - -static odp_shm_t global_shm; -static global_shared_mem_t *global_mem; - -/* Initialise per-thread memory */ -static per_thread_mem_t *thread_init(void) -{ - global_shared_mem_t *global_mem; - per_thread_mem_t *per_thread_mem; - odp_shm_t global_shm; - uint32_t per_thread_mem_len; - - per_thread_mem_len = sizeof(per_thread_mem_t); - per_thread_mem = malloc(per_thread_mem_len); - memset(per_thread_mem, 0, per_thread_mem_len); - - per_thread_mem->delay_counter = 1; - - per_thread_mem->thread_id = odp_thread_id(); - per_thread_mem->thread_core = odp_cpu_id(); - - global_shm = odp_shm_lookup(GLOBAL_SHM_NAME); - global_mem = odp_shm_addr(global_shm); - CU_ASSERT_PTR_NOT_NULL(global_mem); - - per_thread_mem->global_mem = global_mem; - - return per_thread_mem; -} - -static void thread_finalize(per_thread_mem_t *per_thread_mem) -{ - free(per_thread_mem); -} - -static void test_atomic_inc_32(void) -{ - int i; - - for (i = 0; i < CNT; i++) - odpdrv_atomic_inc_u32(&a32u); -} - -static void test_atomic_inc_64(void) -{ - int i; - - for (i = 0; i < CNT; i++) - odpdrv_atomic_inc_u64(&a64u); -} - -static void test_atomic_dec_32(void) -{ - int i; - - for (i = 0; i < CNT; i++) - odpdrv_atomic_dec_u32(&a32u); -} - -static void test_atomic_dec_64(void) -{ - int i; - - for (i = 0; i < CNT; i++) - odpdrv_atomic_dec_u64(&a64u); -} - -static void test_atomic_fetch_inc_32(void) -{ - int i; - - for (i = 0; i < CNT; i++) - odpdrv_atomic_fetch_inc_u32(&a32u); -} - -static void test_atomic_fetch_inc_64(void) -{ - int i; - - for (i = 0; i < CNT; i++) - odpdrv_atomic_fetch_inc_u64(&a64u); -} - -static void test_atomic_fetch_dec_32(void) -{ - int i; - - for (i = 0; i < CNT; i++) - odpdrv_atomic_fetch_dec_u32(&a32u); -} - -static void test_atomic_fetch_dec_64(void) -{ - int i; - - for (i = 0; i < CNT; i++) - odpdrv_atomic_fetch_dec_u64(&a64u); -} - -static void test_atomic_add_32(void) -{ - int i; - - for (i = 0; i < CNT; i++) - odpdrv_atomic_add_u32(&a32u, ADD_SUB_CNT); -} - -static void test_atomic_add_64(void) -{ - int i; - - for (i = 0; i < CNT; i++) - odpdrv_atomic_add_u64(&a64u, ADD_SUB_CNT); -} - -static void test_atomic_sub_32(void) -{ - int i; - - for (i = 0; i < CNT; i++) - odpdrv_atomic_sub_u32(&a32u, ADD_SUB_CNT); -} - -static void test_atomic_sub_64(void) -{ - int i; - - for (i = 0; i < CNT; i++) - odpdrv_atomic_sub_u64(&a64u, ADD_SUB_CNT); -} - -static void test_atomic_fetch_add_32(void) -{ - int i; - - for (i = 0; i < CNT; i++) - odpdrv_atomic_fetch_add_u32(&a32u, ADD_SUB_CNT); -} - -static void test_atomic_fetch_add_64(void) -{ - int i; - - for (i = 0; i < CNT; i++) - odpdrv_atomic_fetch_add_u64(&a64u, ADD_SUB_CNT); -} - -static void test_atomic_fetch_sub_32(void) -{ - int i; - - for (i = 0; i < CNT; i++) - odpdrv_atomic_fetch_sub_u32(&a32u, ADD_SUB_CNT); -} - -static void test_atomic_fetch_sub_64(void) -{ - int i; - - for (i = 0; i < CNT; i++) - odpdrv_atomic_fetch_sub_u64(&a64u, ADD_SUB_CNT); -} - -static void test_atomic_min_32(void) -{ - int i; - uint32_t tmp; - - for (i = 0; i < CNT; i++) { - tmp = odpdrv_atomic_fetch_dec_u32(&a32u); - odpdrv_atomic_min_u32(&a32u_min, tmp); - } -} - -static void test_atomic_min_64(void) -{ - int i; - uint64_t tmp; - - for (i = 0; i < CNT; i++) { - tmp = odpdrv_atomic_fetch_dec_u64(&a64u); - odpdrv_atomic_min_u64(&a64u_min, tmp); - } -} - -static void test_atomic_max_32(void) -{ - int i; - uint32_t tmp; - - for (i = 0; i < CNT; i++) { - tmp = odpdrv_atomic_fetch_inc_u32(&a32u); - odpdrv_atomic_max_u32(&a32u_max, tmp); - } -} - -static void test_atomic_max_64(void) -{ - int i; - uint64_t tmp; - - for (i = 0; i < CNT; i++) { - tmp = odpdrv_atomic_fetch_inc_u64(&a64u); - odpdrv_atomic_max_u64(&a64u_max, tmp); - } -} - -static void test_atomic_cas_inc_32(void) -{ - int i; - uint32_t old; - - for (i = 0; i < CNT; i++) { - old = odpdrv_atomic_load_u32(&a32u); - - while (odpdrv_atomic_cas_u32(&a32u, &old, old + 1) == 0) - ; - } -} - -static void test_atomic_cas_dec_32(void) -{ - int i; - uint32_t old; - - for (i = 0; i < CNT; i++) { - old = odpdrv_atomic_load_u32(&a32u); - - while (odpdrv_atomic_cas_u32(&a32u, &old, old - 1) == 0) - ; - } -} - -static void test_atomic_cas_inc_64(void) -{ - int i; - uint64_t old; - - for (i = 0; i < CNT; i++) { - old = odpdrv_atomic_load_u64(&a64u); - - while (odpdrv_atomic_cas_u64(&a64u, &old, old + 1) == 0) - ; - } -} - -static void test_atomic_cas_dec_64(void) -{ - int i; - uint64_t old; - - for (i = 0; i < CNT; i++) { - old = odpdrv_atomic_load_u64(&a64u); - - while (odpdrv_atomic_cas_u64(&a64u, &old, old - 1) == 0) - ; - } -} - -static void test_atomic_xchg_32(void) -{ - uint32_t old, new; - int i; - - for (i = 0; i < CNT; i++) { - new = odpdrv_atomic_fetch_inc_u32(&a32u); - old = odpdrv_atomic_xchg_u32(&a32u_xchg, new); - - if (old & 0x1) - odpdrv_atomic_xchg_u32(&a32u_xchg, 0); - else - odpdrv_atomic_xchg_u32(&a32u_xchg, 1); - } - - odpdrv_atomic_sub_u32(&a32u, CNT); - odpdrv_atomic_xchg_u32(&a32u_xchg, U32_MAGIC); -} - -static void test_atomic_xchg_64(void) -{ - uint64_t old, new; - int i; - - for (i = 0; i < CNT; i++) { - new = odpdrv_atomic_fetch_inc_u64(&a64u); - old = odpdrv_atomic_xchg_u64(&a64u_xchg, new); - - if (old & 0x1) - odpdrv_atomic_xchg_u64(&a64u_xchg, 0); - else - odpdrv_atomic_xchg_u64(&a64u_xchg, 1); - } - - odpdrv_atomic_sub_u64(&a64u, CNT); - odpdrv_atomic_xchg_u64(&a64u_xchg, U64_MAGIC); -} - -static void test_atomic_non_relaxed_32(void) -{ - int i; - uint32_t tmp; - - for (i = 0; i < CNT; i++) { - tmp = odpdrv_atomic_load_acq_u32(&a32u); - odpdrv_atomic_store_rel_u32(&a32u, tmp); - - tmp = odpdrv_atomic_load_acq_u32(&a32u_max); - odpdrv_atomic_add_rel_u32(&a32u_max, 1); - - tmp = odpdrv_atomic_load_acq_u32(&a32u_min); - odpdrv_atomic_sub_rel_u32(&a32u_min, 1); - - tmp = odpdrv_atomic_load_u32(&a32u_xchg); - while (odpdrv_atomic_cas_acq_u32(&a32u_xchg, &tmp, tmp + 1) - == 0) - ; - - tmp = odpdrv_atomic_load_u32(&a32u_xchg); - while (odpdrv_atomic_cas_rel_u32(&a32u_xchg, &tmp, tmp + 1) - == 0) - ; - - tmp = odpdrv_atomic_load_u32(&a32u_xchg); - /* finally set value for validation */ - while (odpdrv_atomic_cas_acq_rel_u32(&a32u_xchg, &tmp, - U32_MAGIC) - == 0) - ; - } -} - -static void test_atomic_non_relaxed_64(void) -{ - int i; - uint64_t tmp; - - for (i = 0; i < CNT; i++) { - tmp = odpdrv_atomic_load_acq_u64(&a64u); - odpdrv_atomic_store_rel_u64(&a64u, tmp); - - tmp = odpdrv_atomic_load_acq_u64(&a64u_max); - odpdrv_atomic_add_rel_u64(&a64u_max, 1); - - tmp = odpdrv_atomic_load_acq_u64(&a64u_min); - odpdrv_atomic_sub_rel_u64(&a64u_min, 1); - - tmp = odpdrv_atomic_load_u64(&a64u_xchg); - while (odpdrv_atomic_cas_acq_u64(&a64u_xchg, &tmp, tmp + 1) - == 0) - ; - - tmp = odpdrv_atomic_load_u64(&a64u_xchg); - while (odpdrv_atomic_cas_rel_u64(&a64u_xchg, &tmp, tmp + 1) - == 0) - ; - - tmp = odpdrv_atomic_load_u64(&a64u_xchg); - /* finally set value for validation */ - while (odpdrv_atomic_cas_acq_rel_u64(&a64u_xchg, &tmp, - U64_MAGIC) - == 0) - ; - } -} - -static void test_atomic_inc_dec_32(void) -{ - test_atomic_inc_32(); - test_atomic_dec_32(); -} - -static void test_atomic_inc_dec_64(void) -{ - test_atomic_inc_64(); - test_atomic_dec_64(); -} - -static void test_atomic_fetch_inc_dec_32(void) -{ - test_atomic_fetch_inc_32(); - test_atomic_fetch_dec_32(); -} - -static void test_atomic_fetch_inc_dec_64(void) -{ - test_atomic_fetch_inc_64(); - test_atomic_fetch_dec_64(); -} - -static void test_atomic_add_sub_32(void) -{ - test_atomic_add_32(); - test_atomic_sub_32(); -} - -static void test_atomic_add_sub_64(void) -{ - test_atomic_add_64(); - test_atomic_sub_64(); -} - -static void test_atomic_fetch_add_sub_32(void) -{ - test_atomic_fetch_add_32(); - test_atomic_fetch_sub_32(); -} - -static void test_atomic_fetch_add_sub_64(void) -{ - test_atomic_fetch_add_64(); - test_atomic_fetch_sub_64(); -} - -static void test_atomic_max_min_32(void) -{ - test_atomic_max_32(); - test_atomic_min_32(); -} - -static void test_atomic_max_min_64(void) -{ - test_atomic_max_64(); - test_atomic_min_64(); -} - -static void test_atomic_cas_inc_dec_32(void) -{ - test_atomic_cas_inc_32(); - test_atomic_cas_dec_32(); -} - -static void test_atomic_cas_inc_dec_64(void) -{ - test_atomic_cas_inc_64(); - test_atomic_cas_dec_64(); -} - -static void test_atomic_init(void) -{ - odpdrv_atomic_init_u32(&a32u, 0); - odpdrv_atomic_init_u64(&a64u, 0); - odpdrv_atomic_init_u32(&a32u_min, 0); - odpdrv_atomic_init_u32(&a32u_max, 0); - odpdrv_atomic_init_u64(&a64u_min, 0); - odpdrv_atomic_init_u64(&a64u_max, 0); - odpdrv_atomic_init_u32(&a32u_xchg, 0); - odpdrv_atomic_init_u64(&a64u_xchg, 0); -} - -static void test_atomic_store(void) -{ - odpdrv_atomic_store_u32(&a32u, U32_INIT_VAL); - odpdrv_atomic_store_u64(&a64u, U64_INIT_VAL); - odpdrv_atomic_store_u32(&a32u_min, U32_INIT_VAL); - odpdrv_atomic_store_u32(&a32u_max, U32_INIT_VAL); - odpdrv_atomic_store_u64(&a64u_min, U64_INIT_VAL); - odpdrv_atomic_store_u64(&a64u_max, U64_INIT_VAL); - odpdrv_atomic_store_u32(&a32u_xchg, U32_INIT_VAL); - odpdrv_atomic_store_u64(&a64u_xchg, U64_INIT_VAL); -} - -static void test_atomic_validate(int check) -{ - CU_ASSERT(U32_INIT_VAL == odpdrv_atomic_load_u32(&a32u)); - CU_ASSERT(U64_INIT_VAL == odpdrv_atomic_load_u64(&a64u)); - - if (check & CHECK_MAX_MIN) { - CU_ASSERT(odpdrv_atomic_load_u32(&a32u_max) > - odpdrv_atomic_load_u32(&a32u_min)); - - CU_ASSERT(odpdrv_atomic_load_u64(&a64u_max) > - odpdrv_atomic_load_u64(&a64u_min)); - } - - if (check & CHECK_XCHG) { - CU_ASSERT(odpdrv_atomic_load_u32(&a32u_xchg) == U32_MAGIC); - CU_ASSERT(odpdrv_atomic_load_u64(&a64u_xchg) == U64_MAGIC); - } -} - -int drvatomic_init(odp_instance_t *inst) -{ - uint32_t workers_count, max_threads; - int ret = 0; - odp_cpumask_t mask; - - if (0 != odp_init_global(inst, NULL, NULL)) { - fprintf(stderr, "error: odp_init_global() failed.\n"); - return -1; - } - if (0 != odp_init_local(*inst, ODP_THREAD_CONTROL)) { - fprintf(stderr, "error: odp_init_local() failed.\n"); - return -1; - } - - global_shm = odp_shm_reserve(GLOBAL_SHM_NAME, - sizeof(global_shared_mem_t), 64, - ODP_SHM_SW_ONLY); - if (ODP_SHM_INVALID == global_shm) { - fprintf(stderr, "Unable reserve memory for global_shm\n"); - return -1; - } - - global_mem = odp_shm_addr(global_shm); - memset(global_mem, 0, sizeof(global_shared_mem_t)); - - global_mem->g_num_threads = MAX_WORKERS; - global_mem->g_iterations = MAX_ITERATIONS; - global_mem->g_verbose = VERBOSE; - - workers_count = odp_cpumask_default_worker(&mask, 0); - - max_threads = (workers_count >= MAX_WORKERS) ? - MAX_WORKERS : workers_count; - - if (max_threads < global_mem->g_num_threads) { - printf("Requested num of threads is too large\n"); - printf("reducing from %" PRIu32 " to %" PRIu32 "\n", - global_mem->g_num_threads, - max_threads); - global_mem->g_num_threads = max_threads; - } - - printf("Num of threads used = %" PRIu32 "\n", - global_mem->g_num_threads); - - return ret; -} - -/* Atomic tests */ -static int test_atomic_inc_dec_thread(void *arg UNUSED) -{ - per_thread_mem_t *per_thread_mem; - - per_thread_mem = thread_init(); - test_atomic_inc_dec_32(); - test_atomic_inc_dec_64(); - - thread_finalize(per_thread_mem); - - return CU_get_number_of_failures(); -} - -static int test_atomic_add_sub_thread(void *arg UNUSED) -{ - per_thread_mem_t *per_thread_mem; - - per_thread_mem = thread_init(); - test_atomic_add_sub_32(); - test_atomic_add_sub_64(); - - thread_finalize(per_thread_mem); - - return CU_get_number_of_failures(); -} - -static int test_atomic_fetch_inc_dec_thread(void *arg UNUSED) -{ - per_thread_mem_t *per_thread_mem; - - per_thread_mem = thread_init(); - test_atomic_fetch_inc_dec_32(); - test_atomic_fetch_inc_dec_64(); - - thread_finalize(per_thread_mem); - - return CU_get_number_of_failures(); -} - -static int test_atomic_fetch_add_sub_thread(void *arg UNUSED) -{ - per_thread_mem_t *per_thread_mem; - - per_thread_mem = thread_init(); - test_atomic_fetch_add_sub_32(); - test_atomic_fetch_add_sub_64(); - - thread_finalize(per_thread_mem); - - return CU_get_number_of_failures(); -} - -static int test_atomic_max_min_thread(void *arg UNUSED) -{ - per_thread_mem_t *per_thread_mem; - - per_thread_mem = thread_init(); - test_atomic_max_min_32(); - test_atomic_max_min_64(); - - thread_finalize(per_thread_mem); - - return CU_get_number_of_failures(); -} - -static int test_atomic_cas_inc_dec_thread(void *arg UNUSED) -{ - per_thread_mem_t *per_thread_mem; - - per_thread_mem = thread_init(); - test_atomic_cas_inc_dec_32(); - test_atomic_cas_inc_dec_64(); - - thread_finalize(per_thread_mem); - - return CU_get_number_of_failures(); -} - -static int test_atomic_xchg_thread(void *arg UNUSED) -{ - per_thread_mem_t *per_thread_mem; - - per_thread_mem = thread_init(); - test_atomic_xchg_32(); - test_atomic_xchg_64(); - - thread_finalize(per_thread_mem); - - return CU_get_number_of_failures(); -} - -static int test_atomic_non_relaxed_thread(void *arg UNUSED) -{ - per_thread_mem_t *per_thread_mem; - - per_thread_mem = thread_init(); - test_atomic_non_relaxed_32(); - test_atomic_non_relaxed_64(); - - thread_finalize(per_thread_mem); - - return CU_get_number_of_failures(); -} - -static void test_atomic_functional(int func_ptr(void *), int check) -{ - pthrd_arg arg; - - arg.numthrds = global_mem->g_num_threads; - test_atomic_init(); - test_atomic_store(); - odp_cunit_thread_create(func_ptr, &arg); - odp_cunit_thread_exit(&arg); - test_atomic_validate(check); -} - -void drvatomic_test_atomic_inc_dec(void) -{ - test_atomic_functional(test_atomic_inc_dec_thread, 0); -} - -void drvatomic_test_atomic_add_sub(void) -{ - test_atomic_functional(test_atomic_add_sub_thread, 0); -} - -void drvatomic_test_atomic_fetch_inc_dec(void) -{ - test_atomic_functional(test_atomic_fetch_inc_dec_thread, 0); -} - -void drvatomic_test_atomic_fetch_add_sub(void) -{ - test_atomic_functional(test_atomic_fetch_add_sub_thread, 0); -} - -void drvatomic_test_atomic_max_min(void) -{ - test_atomic_functional(test_atomic_max_min_thread, CHECK_MAX_MIN); -} - -void drvatomic_test_atomic_cas_inc_dec(void) -{ - test_atomic_functional(test_atomic_cas_inc_dec_thread, 0); -} - -void drvatomic_test_atomic_xchg(void) -{ - test_atomic_functional(test_atomic_xchg_thread, CHECK_XCHG); -} - -void drvatomic_test_atomic_non_relaxed(void) -{ - test_atomic_functional(test_atomic_non_relaxed_thread, - CHECK_MAX_MIN | CHECK_XCHG); -} - -void drvatomic_test_atomic_op_lock_free(void) -{ - odpdrv_atomic_op_t atomic_op; - int ret_null, ret; - - memset(&atomic_op, 0xff, sizeof(odpdrv_atomic_op_t)); - atomic_op.all_bits = 0; - - CU_ASSERT(atomic_op.all_bits == 0); - CU_ASSERT(atomic_op.op.init == 0); - CU_ASSERT(atomic_op.op.load == 0); - CU_ASSERT(atomic_op.op.store == 0); - CU_ASSERT(atomic_op.op.fetch_add == 0); - CU_ASSERT(atomic_op.op.add == 0); - CU_ASSERT(atomic_op.op.fetch_sub == 0); - CU_ASSERT(atomic_op.op.sub == 0); - CU_ASSERT(atomic_op.op.fetch_inc == 0); - CU_ASSERT(atomic_op.op.inc == 0); - CU_ASSERT(atomic_op.op.fetch_dec == 0); - CU_ASSERT(atomic_op.op.dec == 0); - CU_ASSERT(atomic_op.op.min == 0); - CU_ASSERT(atomic_op.op.max == 0); - CU_ASSERT(atomic_op.op.cas == 0); - CU_ASSERT(atomic_op.op.xchg == 0); - - /* Test setting first, last and couple of other bits */ - atomic_op.op.init = 1; - CU_ASSERT(atomic_op.op.init == 1); - CU_ASSERT(atomic_op.all_bits != 0); - atomic_op.op.init = 0; - CU_ASSERT(atomic_op.all_bits == 0); - - atomic_op.op.xchg = 1; - CU_ASSERT(atomic_op.op.xchg == 1); - CU_ASSERT(atomic_op.all_bits != 0); - atomic_op.op.xchg = 0; - CU_ASSERT(atomic_op.all_bits == 0); - - atomic_op.op.add = 1; - CU_ASSERT(atomic_op.op.add == 1); - CU_ASSERT(atomic_op.all_bits != 0); - atomic_op.op.add = 0; - CU_ASSERT(atomic_op.all_bits == 0); - - atomic_op.op.dec = 1; - CU_ASSERT(atomic_op.op.dec == 1); - CU_ASSERT(atomic_op.all_bits != 0); - atomic_op.op.dec = 0; - CU_ASSERT(atomic_op.all_bits == 0); - - memset(&atomic_op, 0xff, sizeof(odpdrv_atomic_op_t)); - ret = odpdrv_atomic_lock_free_u64(&atomic_op); - ret_null = odpdrv_atomic_lock_free_u64(NULL); - - CU_ASSERT(ret == ret_null); - - /* Init operation is not atomic by the spec. Call to - * odpdrv_atomic_lock_free_u64() zeros it but never sets it. */ - - if (ret == 0) { - /* none are lock free */ - CU_ASSERT(atomic_op.all_bits == 0); - CU_ASSERT(atomic_op.op.init == 0); - CU_ASSERT(atomic_op.op.load == 0); - CU_ASSERT(atomic_op.op.store == 0); - CU_ASSERT(atomic_op.op.fetch_add == 0); - CU_ASSERT(atomic_op.op.add == 0); - CU_ASSERT(atomic_op.op.fetch_sub == 0); - CU_ASSERT(atomic_op.op.sub == 0); - CU_ASSERT(atomic_op.op.fetch_inc == 0); - CU_ASSERT(atomic_op.op.inc == 0); - CU_ASSERT(atomic_op.op.fetch_dec == 0); - CU_ASSERT(atomic_op.op.dec == 0); - CU_ASSERT(atomic_op.op.min == 0); - CU_ASSERT(atomic_op.op.max == 0); - CU_ASSERT(atomic_op.op.cas == 0); - CU_ASSERT(atomic_op.op.xchg == 0); - } - - if (ret == 1) { - /* some are lock free */ - CU_ASSERT(atomic_op.all_bits != 0); - CU_ASSERT(atomic_op.op.init == 0); - } - - if (ret == 2) { - /* all are lock free */ - CU_ASSERT(atomic_op.all_bits != 0); - CU_ASSERT(atomic_op.op.init == 0); - CU_ASSERT(atomic_op.op.load == 1); - CU_ASSERT(atomic_op.op.store == 1); - CU_ASSERT(atomic_op.op.fetch_add == 1); - CU_ASSERT(atomic_op.op.add == 1); - CU_ASSERT(atomic_op.op.fetch_sub == 1); - CU_ASSERT(atomic_op.op.sub == 1); - CU_ASSERT(atomic_op.op.fetch_inc == 1); - CU_ASSERT(atomic_op.op.inc == 1); - CU_ASSERT(atomic_op.op.fetch_dec == 1); - CU_ASSERT(atomic_op.op.dec == 1); - CU_ASSERT(atomic_op.op.min == 1); - CU_ASSERT(atomic_op.op.max == 1); - CU_ASSERT(atomic_op.op.cas == 1); - CU_ASSERT(atomic_op.op.xchg == 1); - } -} - -odp_testinfo_t drvatomic_suite_atomic[] = { - ODP_TEST_INFO(drvatomic_test_atomic_inc_dec), - ODP_TEST_INFO(drvatomic_test_atomic_add_sub), - ODP_TEST_INFO(drvatomic_test_atomic_fetch_inc_dec), - ODP_TEST_INFO(drvatomic_test_atomic_fetch_add_sub), - ODP_TEST_INFO(drvatomic_test_atomic_max_min), - ODP_TEST_INFO(drvatomic_test_atomic_cas_inc_dec), - ODP_TEST_INFO(drvatomic_test_atomic_xchg), - ODP_TEST_INFO(drvatomic_test_atomic_non_relaxed), - ODP_TEST_INFO(drvatomic_test_atomic_op_lock_free), - ODP_TEST_INFO_NULL, -}; - -odp_suiteinfo_t drvatomic_suites[] = { - {"drvatomic", NULL, NULL, - drvatomic_suite_atomic}, - ODP_SUITE_INFO_NULL -}; - -int drvatomic_main(int argc, char *argv[]) -{ - int ret; - - /* parse common options: */ - if (odp_cunit_parse_options(argc, argv)) - return -1; - - odp_cunit_register_global_init(drvatomic_init); - - ret = odp_cunit_register(drvatomic_suites); - - if (ret == 0) - ret = odp_cunit_run(); - - return ret; -} diff --git a/test/validation/drv/drvatomic/drvatomic.h b/test/validation/drv/drvatomic/drvatomic.h deleted file mode 100644 index 62fb17d95..000000000 --- a/test/validation/drv/drvatomic/drvatomic.h +++ /dev/null @@ -1,35 +0,0 @@ -/* Copyright (c) 2016, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#ifndef _ODP_TEST_DRVATOMIC_H_ -#define _ODP_TEST_DRVATOMIC_H_ - -#include - -/* test functions: */ -void drvatomic_test_atomic_inc_dec(void); -void drvatomic_test_atomic_add_sub(void); -void drvatomic_test_atomic_fetch_inc_dec(void); -void drvatomic_test_atomic_fetch_add_sub(void); -void drvatomic_test_atomic_max_min(void); -void drvatomic_test_atomic_cas_inc_dec(void); -void drvatomic_test_atomic_xchg(void); -void drvatomic_test_atomic_non_relaxed(void); -void drvatomic_test_atomic_op_lock_free(void); - -/* test arrays: */ -extern odp_testinfo_t drvatomic_suite_atomic[]; - -/* test registry: */ -extern odp_suiteinfo_t drvatomic_suites[]; - -/* executable init/term functions: */ -int drvatomic_init(odp_instance_t *inst); - -/* main test program: */ -int drvatomic_main(int argc, char *argv[]); - -#endif diff --git a/test/validation/drv/drvatomic/drvatomic_main.c b/test/validation/drv/drvatomic/drvatomic_main.c deleted file mode 100644 index 390a3e2e0..000000000 --- a/test/validation/drv/drvatomic/drvatomic_main.c +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright (c) 2016, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include "drvatomic.h" - -int main(int argc, char *argv[]) -{ - return drvatomic_main(argc, argv); -} diff --git a/test/validation/drv/drvshmem/.gitignore b/test/validation/drv/drvshmem/.gitignore deleted file mode 100644 index 726dea340..000000000 --- a/test/validation/drv/drvshmem/.gitignore +++ /dev/null @@ -1 +0,0 @@ -drvshmem_main diff --git a/test/validation/drv/drvshmem/Makefile.am b/test/validation/drv/drvshmem/Makefile.am deleted file mode 100644 index 816a5e678..000000000 --- a/test/validation/drv/drvshmem/Makefile.am +++ /dev/null @@ -1,10 +0,0 @@ -include ../Makefile.inc - -noinst_LTLIBRARIES = libtestdrvshmem.la -libtestdrvshmem_la_SOURCES = drvshmem.c - -test_PROGRAMS = drvshmem_main$(EXEEXT) -dist_drvshmem_main_SOURCES = drvshmem_main.c -drvshmem_main_LDADD = libtestdrvshmem.la $(LIBCUNIT_COMMON) $(LIBODP) - -EXTRA_DIST = drvshmem.h diff --git a/test/validation/drv/drvshmem/drvshmem.c b/test/validation/drv/drvshmem/drvshmem.c deleted file mode 100644 index 0f882ae40..000000000 --- a/test/validation/drv/drvshmem/drvshmem.c +++ /dev/null @@ -1,1147 +0,0 @@ -/* Copyright (c) 2016, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include -#include -#include -#include "drvshmem.h" -#include - -#define ALIGN_SIZE (128) -#define MEM_NAME "test_shmem" -#define TEST_SHARE_FOO (0xf0f0f0f0) -#define TEST_SHARE_BAR (0xf0f0f0f) -#define SMALL_MEM 10 -#define MEDIUM_MEM 4096 -#define BIG_MEM 65536 -#define STRESS_SIZE 32 /* power of 2 and <=256 */ -#define STRESS_RANDOM_SZ 5 -#define STRESS_ITERATION 5000 - -#define POOL_NAME "test_pool" -#define POOL_SZ (1UL << 20) /* 1 MBytes */ -#define TEST_SZ 1000 -#define SZ_1K 1024 -#define BUFF_PATTERN 0xA3 - -typedef enum { - STRESS_FREE, /* entry is free and can be allocated */ - STRESS_BUSY, /* entry is being processed: don't touch */ - STRESS_ALLOC /* entry is allocated and can be freed */ -} stress_state_t; - -typedef struct { - stress_state_t state; - odpdrv_shm_t shm; - void *address; - uint32_t flags; - uint32_t size; - uint64_t align; - uint8_t data_val; -} stress_data_t; - -typedef struct { - odpdrv_barrier_t test_barrier1; - odpdrv_barrier_t test_barrier2; - odpdrv_barrier_t test_barrier3; - odpdrv_barrier_t test_barrier4; - uint32_t foo; - uint32_t bar; - odpdrv_atomic_u32_t index; - uint32_t nb_threads; - odpdrv_shm_t shm[MAX_WORKERS]; - void *address[MAX_WORKERS]; - odp_spinlock_t stress_lock; - stress_data_t stress[STRESS_SIZE]; -} shared_test_data_t; - -/* memory stuff expected to fit in a single page */ -typedef struct { - int data[SMALL_MEM]; -} shared_test_data_small_t; - -/* memory stuff expected to fit in a huge page */ -typedef struct { - int data[MEDIUM_MEM]; -} shared_test_data_medium_t; - -/* memory stuff expected to fit in many huge pages */ -typedef struct { - int data[BIG_MEM]; -} shared_test_data_big_t; - -/* - * thread part for the drvshmem_test_basic test - */ -static int run_test_basic_thread(void *arg ODP_UNUSED) -{ - odpdrv_shm_info_t info; - odpdrv_shm_t shm; - shared_test_data_t *shared_test_data; - int thr; - - thr = odp_thread_id(); - printf("Thread %i starts\n", thr); - - shm = odpdrv_shm_lookup_by_name(MEM_NAME); - CU_ASSERT(ODPDRV_SHM_INVALID != shm); - shared_test_data = odpdrv_shm_addr(shm); - CU_ASSERT(NULL != shared_test_data); - - odpdrv_barrier_wait(&shared_test_data->test_barrier1); - odpdrv_shm_print_all("(from thread) After lookup for the global shmem"); - CU_ASSERT(TEST_SHARE_FOO == shared_test_data->foo); - CU_ASSERT(TEST_SHARE_BAR == shared_test_data->bar); - CU_ASSERT(0 == odpdrv_shm_info(shm, &info)); - CU_ASSERT(0 == strcmp(MEM_NAME, info.name)); - CU_ASSERT(0 == info.flags); - CU_ASSERT(shared_test_data == info.addr); - CU_ASSERT(sizeof(shared_test_data_t) <= info.size); -#ifdef MAP_HUGETLB - CU_ASSERT(odp_sys_huge_page_size() == info.page_size); -#else - CU_ASSERT(odp_sys_page_size() == info.page_size); -#endif - odpdrv_shm_print_all("(from thread) About to end"); - - fflush(stdout); - return CU_get_number_of_failures(); -} - -/* - * test basic things: shmem creation, info, share, and free - */ -void drvshmem_test_basic(void) -{ - int base; /* memory usage when test starts */ - pthrd_arg thrdarg; - odpdrv_shm_t shm; - shared_test_data_t *shared_test_data; - odp_cpumask_t unused; - - base = odpdrv_shm_print_all("Before drvshmem_test_basic"); - shm = odpdrv_shm_reserve(MEM_NAME, - sizeof(shared_test_data_t), ALIGN_SIZE, 0); - CU_ASSERT(ODPDRV_SHM_INVALID != shm); - CU_ASSERT(odpdrv_shm_to_u64(shm) != - odpdrv_shm_to_u64(ODPDRV_SHM_INVALID)); - - CU_ASSERT(0 == odpdrv_shm_free_by_handle(shm)); - CU_ASSERT(ODPDRV_SHM_INVALID == odpdrv_shm_lookup_by_name(MEM_NAME)); - - shm = odpdrv_shm_reserve(MEM_NAME, - sizeof(shared_test_data_t), ALIGN_SIZE, 0); - CU_ASSERT(ODPDRV_SHM_INVALID != shm); - - shared_test_data = odpdrv_shm_addr(shm); - CU_ASSERT_FATAL(NULL != shared_test_data); - shared_test_data->foo = TEST_SHARE_FOO; - shared_test_data->bar = TEST_SHARE_BAR; - - thrdarg.numthrds = odp_cpumask_default_worker(&unused, 0); - - if (thrdarg.numthrds > MAX_WORKERS) - thrdarg.numthrds = MAX_WORKERS; - - odpdrv_barrier_init(&shared_test_data->test_barrier1, thrdarg.numthrds); - odp_cunit_thread_create(run_test_basic_thread, &thrdarg); - CU_ASSERT(odp_cunit_thread_exit(&thrdarg) >= 0); - - CU_ASSERT(0 == odpdrv_shm_free_by_handle(shm)); - CU_ASSERT(odpdrv_shm_print_all("Test completion") == base); -} - -/* - * thread part for the drvshmem_test_reserve_after_fork - */ -static int run_test_reserve_after_fork(void *arg ODP_UNUSED) -{ - odpdrv_shm_t shm; - shared_test_data_t *glob_data; - int thr; - int thr_index; - char *name; - int name_len; - int size; - shared_test_data_small_t *pattern_small; - shared_test_data_medium_t *pattern_medium; - shared_test_data_big_t *pattern_big; - int i; - - thr = odp_thread_id(); - printf("Thread %i starts\n", thr); - - shm = odpdrv_shm_lookup_by_name(MEM_NAME); - glob_data = odpdrv_shm_addr(shm); - - /* - * odp_thread_id are not guaranteed to be consecutive, so we create - * a consecutive ID - */ - thr_index = odpdrv_atomic_fetch_inc_u32(&glob_data->index); - - /* allocate some memory (of different sizes) and fill with pattern */ - name_len = strlen(MEM_NAME) + 20; - name = malloc(name_len); - snprintf(name, name_len, "%s-%09d", MEM_NAME, thr_index); - switch (thr_index % 3) { - case 0: - size = sizeof(shared_test_data_small_t); - shm = odpdrv_shm_reserve(name, size, 0, 0); - CU_ASSERT(ODPDRV_SHM_INVALID != shm); - glob_data->shm[thr_index] = shm; - pattern_small = odpdrv_shm_addr(shm); - CU_ASSERT_PTR_NOT_NULL(pattern_small); - for (i = 0; i < SMALL_MEM; i++) - pattern_small->data[i] = i; - break; - case 1: - size = sizeof(shared_test_data_medium_t); - shm = odpdrv_shm_reserve(name, size, 0, 0); - CU_ASSERT(ODPDRV_SHM_INVALID != shm); - glob_data->shm[thr_index] = shm; - pattern_medium = odpdrv_shm_addr(shm); - CU_ASSERT_PTR_NOT_NULL(pattern_medium); - for (i = 0; i < MEDIUM_MEM; i++) - pattern_medium->data[i] = (i << 2); - break; - case 2: - size = sizeof(shared_test_data_big_t); - shm = odpdrv_shm_reserve(name, size, 0, 0); - CU_ASSERT(ODPDRV_SHM_INVALID != shm); - glob_data->shm[thr_index] = shm; - pattern_big = odpdrv_shm_addr(shm); - CU_ASSERT_PTR_NOT_NULL(pattern_big); - for (i = 0; i < BIG_MEM; i++) - pattern_big->data[i] = (i >> 2); - break; - } - free(name); - - /* print block address */ - printf("In thread: Block index: %d mapped at %lx\n", - thr_index, (long int)odpdrv_shm_addr(shm)); - - odpdrv_barrier_wait(&glob_data->test_barrier1); - odpdrv_barrier_wait(&glob_data->test_barrier2); - - fflush(stdout); - return CU_get_number_of_failures(); -} - -/* - * test sharing memory reserved after odp_thread creation (e.g. fork()): - */ -void drvshmem_test_reserve_after_fork(void) -{ - int base; /* memory usage when test starts */ - pthrd_arg thrdarg; - odpdrv_shm_t shm; - odpdrv_shm_t thr_shm; - shared_test_data_t *glob_data; - odp_cpumask_t unused; - char *name; - int name_len; - int thr_index; - int i; - void *address; - shared_test_data_small_t *pattern_small; - shared_test_data_medium_t *pattern_medium; - shared_test_data_big_t *pattern_big; - - base = odpdrv_shm_print_all("Before drvshmem_test_reserve_after_fork"); - shm = odpdrv_shm_reserve(MEM_NAME, sizeof(shared_test_data_t), 0, 0); - CU_ASSERT(ODPDRV_SHM_INVALID != shm); - glob_data = odpdrv_shm_addr(shm); - CU_ASSERT_PTR_NOT_NULL(glob_data); - - thrdarg.numthrds = odp_cpumask_default_worker(&unused, 0); - if (thrdarg.numthrds > MAX_WORKERS) - thrdarg.numthrds = MAX_WORKERS; - - odpdrv_barrier_init(&glob_data->test_barrier1, thrdarg.numthrds + 1); - odpdrv_barrier_init(&glob_data->test_barrier2, thrdarg.numthrds + 1); - odpdrv_atomic_store_u32(&glob_data->index, 0); - - odp_cunit_thread_create(run_test_reserve_after_fork, &thrdarg); - - /* wait until all threads have made their shm_reserve: */ - odpdrv_barrier_wait(&glob_data->test_barrier1); - CU_ASSERT(odpdrv_shm_print_all("After all thread reserve") - == base + thrdarg.numthrds + 1); - - /* perform a lookup of all memories, by handle or name: */ - name_len = strlen(MEM_NAME) + 20; - name = malloc(name_len); - for (thr_index = 0; thr_index < thrdarg.numthrds; thr_index++) { - if (thr_index % 2) { - snprintf(name, name_len, "%s-%09d", - MEM_NAME, thr_index); - thr_shm = odpdrv_shm_lookup_by_name(name); - CU_ASSERT(thr_shm == glob_data->shm[thr_index]); - } else { - odpdrv_shm_lookup_by_handle(glob_data->shm[thr_index]); - } - } - - /* check that the patterns are correct: */ - for (thr_index = 0; thr_index < thrdarg.numthrds; thr_index++) { - switch (thr_index % 3) { - case 0: - pattern_small = - odpdrv_shm_addr(glob_data->shm[thr_index]); - CU_ASSERT_PTR_NOT_NULL(pattern_small); - for (i = 0; i < SMALL_MEM; i++) - CU_ASSERT(pattern_small->data[i] == i); - break; - case 1: - pattern_medium = - odpdrv_shm_addr(glob_data->shm[thr_index]); - CU_ASSERT_PTR_NOT_NULL(pattern_medium); - for (i = 0; i < MEDIUM_MEM; i++) - CU_ASSERT(pattern_medium->data[i] == (i << 2)); - break; - case 2: - pattern_big = - odpdrv_shm_addr(glob_data->shm[thr_index]); - CU_ASSERT_PTR_NOT_NULL(pattern_big); - for (i = 0; i < BIG_MEM; i++) - CU_ASSERT(pattern_big->data[i] == (i >> 2)); - break; - } - } - - /* - * print the mapping address of the blocks - */ - for (thr_index = 0; thr_index < thrdarg.numthrds; thr_index++) { - address = odpdrv_shm_addr(glob_data->shm[thr_index]); - printf("In main Block index: %d mapped at %lx\n", - thr_index, (long int)address); - } - - CU_ASSERT(odpdrv_shm_print_all("After main lookup of thread shmem") - == base + thrdarg.numthrds + 1); - - /* unblock the threads and let them terminate (no free is done): */ - odpdrv_barrier_wait(&glob_data->test_barrier2); - - /* at the same time, (race),free of all memories, by handle or name: */ - for (thr_index = 0; thr_index < thrdarg.numthrds; thr_index++) { - if (thr_index % 2) { - thr_shm = glob_data->shm[thr_index]; - CU_ASSERT(odpdrv_shm_free_by_handle(thr_shm) == 0); - } else { - snprintf(name, name_len, "%s-%09d", - MEM_NAME, thr_index); - CU_ASSERT(odpdrv_shm_free_by_name(name) == 0); - } - } - free(name); - - /* wait for all thread endings: */ - CU_ASSERT(odp_cunit_thread_exit(&thrdarg) >= 0); - - /* just glob_data should remain: */ - CU_ASSERT(odpdrv_shm_print_all("After all threads end") == base + 1); - - CU_ASSERT(0 == odpdrv_shm_free_by_handle(shm)); - CU_ASSERT(odpdrv_shm_print_all("Test completion") == base); -} - -/* - * thread part for the drvshmem_test_singleva_after_fork - */ -static int run_test_singleva_after_fork(void *arg ODP_UNUSED) -{ - odpdrv_shm_t shm; - shared_test_data_t *glob_data; - int thr; - int thr_index; - char *name; - int name_len; - int size; - shared_test_data_small_t *pattern_small; - shared_test_data_medium_t *pattern_medium; - shared_test_data_big_t *pattern_big; - uint32_t i; - int ret; - - thr = odp_thread_id(); - printf("Thread %i starts\n", thr); - - shm = odpdrv_shm_lookup_by_name(MEM_NAME); - glob_data = odpdrv_shm_addr(shm); - - /* - * odp_thread_id are not guaranteed to be consecutive, so we create - * a consecutive ID - */ - thr_index = odpdrv_atomic_fetch_inc_u32(&glob_data->index); - - /* allocate some memory (of different sizes) and fill with pattern */ - name_len = strlen(MEM_NAME) + 20; - name = malloc(name_len); - snprintf(name, name_len, "%s-%09d", MEM_NAME, thr_index); - switch (thr_index % 3) { - case 0: - size = sizeof(shared_test_data_small_t); - shm = odpdrv_shm_reserve(name, size, 0, ODPDRV_SHM_SINGLE_VA); - CU_ASSERT(ODPDRV_SHM_INVALID != shm); - glob_data->shm[thr_index] = shm; - pattern_small = odpdrv_shm_addr(shm); - CU_ASSERT_PTR_NOT_NULL(pattern_small); - glob_data->address[thr_index] = (void *)pattern_small; - for (i = 0; i < SMALL_MEM; i++) - pattern_small->data[i] = i; - break; - case 1: - size = sizeof(shared_test_data_medium_t); - shm = odpdrv_shm_reserve(name, size, 0, ODPDRV_SHM_SINGLE_VA); - CU_ASSERT(ODPDRV_SHM_INVALID != shm); - glob_data->shm[thr_index] = shm; - pattern_medium = odpdrv_shm_addr(shm); - CU_ASSERT_PTR_NOT_NULL(pattern_medium); - glob_data->address[thr_index] = (void *)pattern_medium; - for (i = 0; i < MEDIUM_MEM; i++) - pattern_medium->data[i] = (i << 2); - break; - case 2: - size = sizeof(shared_test_data_big_t); - shm = odpdrv_shm_reserve(name, size, 0, ODPDRV_SHM_SINGLE_VA); - CU_ASSERT(ODPDRV_SHM_INVALID != shm); - glob_data->shm[thr_index] = shm; - pattern_big = odpdrv_shm_addr(shm); - CU_ASSERT_PTR_NOT_NULL(pattern_big); - glob_data->address[thr_index] = (void *)pattern_big; - for (i = 0; i < BIG_MEM; i++) - pattern_big->data[i] = (i >> 2); - break; - } - free(name); - - /* print block address */ - printf("In thread: Block index: %d mapped at %lx\n", - thr_index, (long int)odpdrv_shm_addr(shm)); - - odpdrv_barrier_wait(&glob_data->test_barrier1); - odpdrv_barrier_wait(&glob_data->test_barrier2); - - /* map each-other block, checking common address: */ - for (i = 0; i < glob_data->nb_threads; i++) { - shm = odpdrv_shm_lookup_by_address(glob_data->address[i]); - CU_ASSERT(shm == glob_data->shm[i]); - CU_ASSERT(odpdrv_shm_addr(shm) == glob_data->address[i]); - } - - /* wait for main control task and free the allocated block */ - odpdrv_barrier_wait(&glob_data->test_barrier3); - odpdrv_barrier_wait(&glob_data->test_barrier4); - ret = odpdrv_shm_free_by_address(glob_data->address[thr_index]); - CU_ASSERT(ret == 0); - - fflush(stdout); - return CU_get_number_of_failures(); -} - -/* - * test sharing memory reserved after odp_thread creation (e.g. fork()): - * with single VA flag. - */ -void drvshmem_test_singleva_after_fork(void) -{ - int base; /* memory usage when test starts */ - pthrd_arg thrdarg; - odpdrv_shm_t shm; - odpdrv_shm_t thr_shm; - shared_test_data_t *glob_data; - odp_cpumask_t unused; - char *name; - int name_len; - int thr_index; - int i; - void *address; - shared_test_data_small_t *pattern_small; - shared_test_data_medium_t *pattern_medium; - shared_test_data_big_t *pattern_big; - - base = odpdrv_shm_print_all("Before drvshmem_test_singleva_after_fork"); - - shm = odpdrv_shm_reserve(MEM_NAME, sizeof(shared_test_data_t), - 0, ODPDRV_SHM_LOCK); - CU_ASSERT(ODPDRV_SHM_INVALID != shm); - glob_data = odpdrv_shm_addr(shm); - CU_ASSERT_PTR_NOT_NULL(glob_data); - - thrdarg.numthrds = odp_cpumask_default_worker(&unused, 0); - if (thrdarg.numthrds > MAX_WORKERS) - thrdarg.numthrds = MAX_WORKERS; - - glob_data->nb_threads = thrdarg.numthrds; - odpdrv_barrier_init(&glob_data->test_barrier1, thrdarg.numthrds + 1); - odpdrv_barrier_init(&glob_data->test_barrier2, thrdarg.numthrds + 1); - odpdrv_barrier_init(&glob_data->test_barrier3, thrdarg.numthrds + 1); - odpdrv_barrier_init(&glob_data->test_barrier4, thrdarg.numthrds + 1); - odpdrv_atomic_store_u32(&glob_data->index, 0); - - odp_cunit_thread_create(run_test_singleva_after_fork, &thrdarg); - - /* wait until all threads have made their shm_reserve: */ - odpdrv_barrier_wait(&glob_data->test_barrier1); - CU_ASSERT(odpdrv_shm_print_all("After thread reserve") - == base + thrdarg.numthrds + 1); - - /* perform a lookup of all memories, by handle or name: */ - name_len = strlen(MEM_NAME) + 20; - name = malloc(name_len); - for (thr_index = 0; thr_index < thrdarg.numthrds; thr_index++) { - if (thr_index % 2) { - snprintf(name, name_len, "%s-%09d", - MEM_NAME, thr_index); - thr_shm = odpdrv_shm_lookup_by_name(name); - CU_ASSERT(thr_shm == glob_data->shm[thr_index]); - } else { - odpdrv_shm_lookup_by_handle(glob_data->shm[thr_index]); - } - } - free(name); - - /* check that the patterns are correct: */ - for (thr_index = 0; thr_index < thrdarg.numthrds; thr_index++) { - switch (thr_index % 3) { - case 0: - pattern_small = - odpdrv_shm_addr(glob_data->shm[thr_index]); - CU_ASSERT_PTR_NOT_NULL(pattern_small); - for (i = 0; i < SMALL_MEM; i++) - CU_ASSERT(pattern_small->data[i] == i); - break; - case 1: - pattern_medium = - odpdrv_shm_addr(glob_data->shm[thr_index]); - CU_ASSERT_PTR_NOT_NULL(pattern_medium); - for (i = 0; i < MEDIUM_MEM; i++) - CU_ASSERT(pattern_medium->data[i] == (i << 2)); - break; - case 2: - pattern_big = - odpdrv_shm_addr(glob_data->shm[thr_index]); - CU_ASSERT_PTR_NOT_NULL(pattern_big); - for (i = 0; i < BIG_MEM; i++) - CU_ASSERT(pattern_big->data[i] == (i >> 2)); - break; - } - } - - /* - * check that the mapping address is common to all (SINGLE_VA): - */ - for (thr_index = 0; thr_index < thrdarg.numthrds; thr_index++) { - address = odpdrv_shm_addr(glob_data->shm[thr_index]); - CU_ASSERT(glob_data->address[thr_index] == address); - } - - CU_ASSERT(odpdrv_shm_print_all("After local lookup") - == base + thrdarg.numthrds + 1); - - /* unblock the threads and let them map each-other blocks: */ - odpdrv_barrier_wait(&glob_data->test_barrier2); - - /* then check mem status */ - odpdrv_barrier_wait(&glob_data->test_barrier3); - CU_ASSERT(odpdrv_shm_print_all("After mutual lookup") - == base + thrdarg.numthrds + 1); - - /* unblock the threads and let them free all thread blocks: */ - odpdrv_barrier_wait(&glob_data->test_barrier4); - - /* wait for all thread endings: */ - CU_ASSERT(odp_cunit_thread_exit(&thrdarg) >= 0); - - /* just glob_data should remain: */ - CU_ASSERT(odpdrv_shm_print_all("After threads free") == base + 1); - - CU_ASSERT(0 == odpdrv_shm_free_by_name(MEM_NAME)); - CU_ASSERT(odpdrv_shm_print_all("Test completion") == base); -} - -/* - * thread part for the drvshmem_test_stress - */ -static int run_test_stress(void *arg ODP_UNUSED) -{ - odpdrv_shm_t shm; - uint8_t *address; - shared_test_data_t *glob_data; - uint8_t random_bytes[STRESS_RANDOM_SZ]; - uint32_t index; - uint32_t size; - uint64_t align; - uint32_t flags; - uint8_t data; - uint32_t iter; - uint32_t i; - - shm = odpdrv_shm_lookup_by_name(MEM_NAME); - glob_data = odpdrv_shm_addr(shm); - CU_ASSERT_PTR_NOT_NULL(glob_data); - - /* wait for general GO! */ - odpdrv_barrier_wait(&glob_data->test_barrier1); - /* - - * at each iteration: pick up a random index for - * glob_data->stress[index]: If the entry is free, allocated mem - * randomly. If it is already allocated, make checks and free it: - * Note that different tread cann allocate or free a given block - */ - for (iter = 0; iter < STRESS_ITERATION; iter++) { - /* get 4 random bytes from which index, size ,align, flags - * and data will be derived: - */ - odp_random_data(random_bytes, STRESS_RANDOM_SZ, 0); - index = random_bytes[0] & (STRESS_SIZE - 1); - - odp_spinlock_lock(&glob_data->stress_lock); - - switch (glob_data->stress[index].state) { - case STRESS_FREE: - /* allocated a new block for this entry */ - - glob_data->stress[index].state = STRESS_BUSY; - odp_spinlock_unlock(&glob_data->stress_lock); - - size = (random_bytes[1] + 1) << 6; /* up to 16Kb */ - /* we just play with the VA flag. randomly setting - * the mlock flag may exceed user ulimit -l - */ - flags = random_bytes[2] & ODPDRV_SHM_SINGLE_VA; - align = (random_bytes[3] + 1) << 6;/* up to 16Kb */ - data = random_bytes[4]; - - shm = odpdrv_shm_reserve(NULL, size, align, flags); - glob_data->stress[index].shm = shm; - if (shm == ODPDRV_SHM_INVALID) { /* out of mem ? */ - odp_spinlock_lock(&glob_data->stress_lock); - glob_data->stress[index].state = STRESS_ALLOC; - odp_spinlock_unlock(&glob_data->stress_lock); - continue; - } - - address = odpdrv_shm_addr(shm); - CU_ASSERT_PTR_NOT_NULL(address); - glob_data->stress[index].address = address; - glob_data->stress[index].flags = flags; - glob_data->stress[index].size = size; - glob_data->stress[index].align = align; - glob_data->stress[index].data_val = data; - - /* write some data: writing each byte would be a - * waste of time: just make sure each page is reached */ - for (i = 0; i < size; i += 256) - address[i] = (data++) & 0xFF; - odp_spinlock_lock(&glob_data->stress_lock); - glob_data->stress[index].state = STRESS_ALLOC; - odp_spinlock_unlock(&glob_data->stress_lock); - - break; - - case STRESS_ALLOC: - /* free the block for this entry */ - - glob_data->stress[index].state = STRESS_BUSY; - odp_spinlock_unlock(&glob_data->stress_lock); - shm = glob_data->stress[index].shm; - - if (shm == ODPDRV_SHM_INVALID) { /* out of mem ? */ - odp_spinlock_lock(&glob_data->stress_lock); - glob_data->stress[index].state = STRESS_FREE; - odp_spinlock_unlock(&glob_data->stress_lock); - continue; - } - - CU_ASSERT(odpdrv_shm_lookup_by_handle(shm) != 0); - - address = odpdrv_shm_addr(shm); - CU_ASSERT_PTR_NOT_NULL(address); - - align = glob_data->stress[index].align; - if (align) { - align = glob_data->stress[index].align; - CU_ASSERT(((uintptr_t)address & (align - 1)) - == 0) - } - - flags = glob_data->stress[index].flags; - if (flags & ODPDRV_SHM_SINGLE_VA) - CU_ASSERT(glob_data->stress[index].address == - address) - - /* check that data is reachable and correct: */ - data = glob_data->stress[index].data_val; - size = glob_data->stress[index].size; - for (i = 0; i < size; i += 256) { - CU_ASSERT(address[i] == (data & 0xFF)); - data++; - } - - if (flags & ODPDRV_SHM_SINGLE_VA) { - CU_ASSERT(!odpdrv_shm_free_by_address(address)); - } else { - CU_ASSERT(!odpdrv_shm_free_by_handle(shm)); - } - - odp_spinlock_lock(&glob_data->stress_lock); - glob_data->stress[index].state = STRESS_FREE; - odp_spinlock_unlock(&glob_data->stress_lock); - - break; - - case STRESS_BUSY: - default: - odp_spinlock_unlock(&glob_data->stress_lock); - break; - } - } - - fflush(stdout); - return CU_get_number_of_failures(); -} - -/* - * stress tests - */ -void drvshmem_test_stress(void) -{ - pthrd_arg thrdarg; - odpdrv_shm_t shm; - shared_test_data_t *glob_data; - odp_cpumask_t unused; - int base; /* number of blocks already allocated at start of test */ - uint32_t i; - - base = odpdrv_shm_print_all("Before thread tests"); - - shm = odpdrv_shm_reserve(MEM_NAME, sizeof(shared_test_data_t), - 0, ODPDRV_SHM_LOCK); - CU_ASSERT(ODPDRV_SHM_INVALID != shm); - glob_data = odpdrv_shm_addr(shm); - CU_ASSERT_PTR_NOT_NULL(glob_data); - - thrdarg.numthrds = odp_cpumask_default_worker(&unused, 0); - if (thrdarg.numthrds > MAX_WORKERS) - thrdarg.numthrds = MAX_WORKERS; - - glob_data->nb_threads = thrdarg.numthrds; - odpdrv_barrier_init(&glob_data->test_barrier1, thrdarg.numthrds); - odp_spinlock_init(&glob_data->stress_lock); - - /* before starting the threads, mark all entries as free: */ - for (i = 0; i < STRESS_SIZE; i++) - glob_data->stress[i].state = STRESS_FREE; - - /* create threads */ - odp_cunit_thread_create(run_test_stress, &thrdarg); - - /* wait for all thread endings: */ - CU_ASSERT(odp_cunit_thread_exit(&thrdarg) >= 0); - - odpdrv_shm_print_all("Middle"); - - /* release left overs: */ - for (i = 0; i < STRESS_SIZE; i++) { - shm = glob_data->stress[i].shm; - if ((glob_data->stress[i].state == STRESS_ALLOC) && - (glob_data->stress[i].shm != ODPDRV_SHM_INVALID)) { - CU_ASSERT(odpdrv_shm_lookup_by_handle(shm) != - NULL); - CU_ASSERT(!odpdrv_shm_free_by_handle(shm)); - } - } - - CU_ASSERT(0 == odpdrv_shm_free_by_name(MEM_NAME)); - - /* check that no memory is left over: */ - CU_ASSERT(odpdrv_shm_print_all("After stress tests") == base); -} - -void drvshmem_test_buddy_basic(void) -{ - odpdrv_shm_pool_param_t pool_params; - odpdrv_shm_pool_t pool, found_pool; - uint8_t *buff; - uint8_t *addrs[TEST_SZ]; - uint8_t length; - int i, j; - - /* create a pool and check that it can be looked up */ - pool_params.pool_size = POOL_SZ; - pool_params.min_alloc = 1; - pool_params.max_alloc = POOL_SZ; - pool = odpdrv_shm_pool_create(POOL_NAME, &pool_params); - found_pool = odpdrv_shm_pool_lookup(POOL_NAME); - CU_ASSERT(found_pool == pool); - - /* alloc a 1k buffer, filling its contents: */ - buff = odpdrv_shm_pool_alloc(pool, SZ_1K); - CU_ASSERT_PTR_NOT_NULL(buff); - for (i = 0; i < SZ_1K; i++) - buff[i] = BUFF_PATTERN; - odpdrv_shm_pool_print("buddy test: 1K reserved", pool); - - /* alloc as many buffer a possible on increseasing sz */ - for (i = 0; i < TEST_SZ; i++) { - length = i * 16; - addrs[i] = odpdrv_shm_pool_alloc(pool, length); - /* if alloc was success, fill buffer for later check */ - if (addrs[i]) { - for (j = 0; j < length; j++) - addrs[i][j] = (uint8_t)(length & 0xFF); - } - } - odpdrv_shm_pool_print("buddy test: after many mallocs", pool); - - /* release every 3rth buffer, checking contents: */ - for (i = 0; i < TEST_SZ; i += 3) { - /* if buffer was allocated, check the pattern in it */ - if (addrs[i]) { - length = i * 16; - for (j = 0; j < length; j++) - CU_ASSERT(addrs[i][j] == - (uint8_t)(length & 0xFF)); - } - odpdrv_shm_pool_free(pool, addrs[i]); - } - odpdrv_shm_pool_print("buddy test: after 1/3 free:", pool); - - /* realloc them:*/ - for (i = 0; i < TEST_SZ; i += 3) { - length = i * 16; - addrs[i] = odpdrv_shm_pool_alloc(pool, length); - /* if alloc was success, fill buffer for later check */ - if (addrs[i]) { - for (j = 0; j < length; j++) - addrs[i][j] = (uint8_t)(length & 0xFF); - } - } - odpdrv_shm_pool_print("buddy test: after realloc:", pool); - - /* free all (except buff), checking contents: */ - for (i = 0; i < TEST_SZ; i++) { - /* if buffer was allocated, check the pattern in it */ - if (addrs[i]) { - length = i * 16; - for (j = 0; j < length; j++) - CU_ASSERT(addrs[i][j] == - (uint8_t)(length & 0xFF)) - } - odpdrv_shm_pool_free(pool, addrs[i]); - } - odpdrv_shm_pool_print("buddy test: after all but 1K free:", pool); - - /* check contents of our initial 1K buffer: */ - for (i = 0; i < SZ_1K; i++) - CU_ASSERT((buff[i] == BUFF_PATTERN)) - odpdrv_shm_pool_free(pool, buff); - - odpdrv_shm_pool_print("buddy test: after all free", pool); - - /* destroy pool: */ - odpdrv_shm_pool_destroy(pool); -} - -void drvshmem_test_slab_basic(void) -{ - odpdrv_shm_pool_param_t pool_params; - odpdrv_shm_pool_t pool, found_pool; - uint8_t *buff; - uint8_t *addrs[TEST_SZ]; - uint16_t length; - int i, j; - - /* create a pool and check that it can be looked up */ - pool_params.pool_size = POOL_SZ; - pool_params.min_alloc = SZ_1K; /* constant size will give slab */ - pool_params.max_alloc = SZ_1K; - pool = odpdrv_shm_pool_create(POOL_NAME, &pool_params); - found_pool = odpdrv_shm_pool_lookup(POOL_NAME); - CU_ASSERT(found_pool == pool); - - /* alloc a 1k buffer, filling its contents: */ - buff = odpdrv_shm_pool_alloc(pool, SZ_1K); - CU_ASSERT_PTR_NOT_NULL(buff); - for (i = 0; i < SZ_1K; i++) - buff[i] = BUFF_PATTERN; - odpdrv_shm_pool_print("buddy test: 1K reserved", pool); - - /* alloc as many 1K buffer a possible */ - for (i = 0; i < TEST_SZ; i++) { - length = SZ_1K; - addrs[i] = odpdrv_shm_pool_alloc(pool, length); - /* if alloc was success, fill buffer for later check */ - if (addrs[i]) { - for (j = 0; j < length; j++) - addrs[i][j] = (uint8_t)(length & 0xFF); - } - } - odpdrv_shm_pool_print("slab test: after many mallocs", pool); - - /* release every 3rth buffer, checking contents: */ - for (i = 0; i < TEST_SZ; i += 3) { - /* if buffer was allocated, check the pattern in it */ - if (addrs[i]) { - length = SZ_1K; - for (j = 0; j < length; j++) - CU_ASSERT(addrs[i][j] == - (uint8_t)(length & 0xFF)); - } - odpdrv_shm_pool_free(pool, addrs[i]); - } - odpdrv_shm_pool_print("slab test: after 1/3 free:", pool); - - /* realloc them:*/ - for (i = 0; i < TEST_SZ; i += 3) { - length = SZ_1K; - addrs[i] = odpdrv_shm_pool_alloc(pool, length); - /* if alloc was success, fill buffer for later check */ - if (addrs[i]) { - for (j = 0; j < length; j++) - addrs[i][j] = (uint8_t)(length & 0xFF); - } - } - odpdrv_shm_pool_print("slab test: after realloc:", pool); - - /* free all (except buff), checking contents: */ - for (i = 0; i < TEST_SZ; i++) { - /* if buffer was allocated, check the pattern in it */ - if (addrs[i]) { - length = SZ_1K; - for (j = 0; j < length; j++) - CU_ASSERT(addrs[i][j] == - (uint8_t)(length & 0xFF)) - } - odpdrv_shm_pool_free(pool, addrs[i]); - } - odpdrv_shm_pool_print("slab test: after all but 1K free:", pool); - - /* check contents of our initial 1K buffer: */ - for (i = 0; i < SZ_1K; i++) - CU_ASSERT((buff[i] == BUFF_PATTERN)) - odpdrv_shm_pool_free(pool, buff); - - odpdrv_shm_pool_print("slab test: after all free", pool); - - /* destroy pool: */ - odpdrv_shm_pool_destroy(pool); -} - -/* - * thread part for the drvshmem_test_buddy_stress - */ -static int run_test_buddy_stress(void *arg ODP_UNUSED) -{ - odpdrv_shm_t shm; - odpdrv_shm_pool_t pool; - uint8_t *address; - shared_test_data_t *glob_data; - uint8_t random_bytes[STRESS_RANDOM_SZ]; - uint32_t index; - uint32_t size; - uint8_t data; - uint32_t iter; - uint32_t i; - - shm = odpdrv_shm_lookup_by_name(MEM_NAME); - glob_data = odpdrv_shm_addr(shm); - CU_ASSERT_PTR_NOT_NULL(glob_data); - - /* get the pool to test */ - pool = odpdrv_shm_pool_lookup(POOL_NAME); - - /* wait for general GO! */ - odpdrv_barrier_wait(&glob_data->test_barrier1); - /* - - * at each iteration: pick up a random index for - * glob_data->stress[index]: If the entry is free, allocated small mem - * randomly. If it is already allocated, make checks and free it: - * Note that different tread can allocate or free a given block - */ - for (iter = 0; iter < STRESS_ITERATION; iter++) { - /* get 4 random bytes from which index, size ,align, flags - * and data will be derived: - */ - odp_random_data(random_bytes, STRESS_RANDOM_SZ, 0); - index = random_bytes[0] & (STRESS_SIZE - 1); - - odp_spinlock_lock(&glob_data->stress_lock); - - switch (glob_data->stress[index].state) { - case STRESS_FREE: - /* allocated a new block for this entry */ - - glob_data->stress[index].state = STRESS_BUSY; - odp_spinlock_unlock(&glob_data->stress_lock); - - size = (random_bytes[1] + 1) << 4; /* up to 4Kb */ - data = random_bytes[2]; - - address = odpdrv_shm_pool_alloc(pool, size); - glob_data->stress[index].address = address; - if (address == NULL) { /* out of mem ? */ - odp_spinlock_lock(&glob_data->stress_lock); - glob_data->stress[index].state = STRESS_ALLOC; - odp_spinlock_unlock(&glob_data->stress_lock); - continue; - } - - glob_data->stress[index].size = size; - glob_data->stress[index].data_val = data; - - /* write some data: */ - for (i = 0; i < size; i++) - address[i] = (data++) & 0xFF; - odp_spinlock_lock(&glob_data->stress_lock); - glob_data->stress[index].state = STRESS_ALLOC; - odp_spinlock_unlock(&glob_data->stress_lock); - - break; - - case STRESS_ALLOC: - /* free the block for this entry */ - - glob_data->stress[index].state = STRESS_BUSY; - odp_spinlock_unlock(&glob_data->stress_lock); - address = glob_data->stress[index].address; - - if (shm == NULL) { /* out of mem ? */ - odp_spinlock_lock(&glob_data->stress_lock); - glob_data->stress[index].state = STRESS_FREE; - odp_spinlock_unlock(&glob_data->stress_lock); - continue; - } - - /* check that data is reachable and correct: */ - data = glob_data->stress[index].data_val; - size = glob_data->stress[index].size; - for (i = 0; i < size; i++) { - CU_ASSERT(address[i] == (data & 0xFF)); - data++; - } - - odpdrv_shm_pool_free(pool, address); - - odp_spinlock_lock(&glob_data->stress_lock); - glob_data->stress[index].state = STRESS_FREE; - odp_spinlock_unlock(&glob_data->stress_lock); - - break; - - case STRESS_BUSY: - default: - odp_spinlock_unlock(&glob_data->stress_lock); - break; - } - } - - fflush(stdout); - return CU_get_number_of_failures(); -} - -/* - * stress tests - */ -void drvshmem_test_buddy_stress(void) -{ - odpdrv_shm_pool_param_t pool_params; - odpdrv_shm_pool_t pool; - pthrd_arg thrdarg; - odpdrv_shm_t shm; - shared_test_data_t *glob_data; - odp_cpumask_t unused; - uint32_t i; - uint8_t *address; - - /* create a pool and check that it can be looked up */ - pool_params.pool_size = POOL_SZ; - pool_params.min_alloc = 0; - pool_params.max_alloc = POOL_SZ; - pool = odpdrv_shm_pool_create(POOL_NAME, &pool_params); - odpdrv_shm_pool_print("Stress test start", pool); - - shm = odpdrv_shm_reserve(MEM_NAME, sizeof(shared_test_data_t), - 0, ODPDRV_SHM_LOCK); - CU_ASSERT(ODPDRV_SHM_INVALID != shm); - glob_data = odpdrv_shm_addr(shm); - CU_ASSERT_PTR_NOT_NULL(glob_data); - - thrdarg.numthrds = odp_cpumask_default_worker(&unused, 0); - if (thrdarg.numthrds > MAX_WORKERS) - thrdarg.numthrds = MAX_WORKERS; - - glob_data->nb_threads = thrdarg.numthrds; - odpdrv_barrier_init(&glob_data->test_barrier1, thrdarg.numthrds); - odp_spinlock_init(&glob_data->stress_lock); - - /* before starting the threads, mark all entries as free: */ - for (i = 0; i < STRESS_SIZE; i++) - glob_data->stress[i].state = STRESS_FREE; - - /* create threads */ - odp_cunit_thread_create(run_test_buddy_stress, &thrdarg); - - /* wait for all thread endings: */ - CU_ASSERT(odp_cunit_thread_exit(&thrdarg) >= 0); - - odpdrv_shm_pool_print("Stress test all thread finished", pool); - - /* release left overs: */ - for (i = 0; i < STRESS_SIZE; i++) { - address = glob_data->stress[i].address; - if (glob_data->stress[i].state == STRESS_ALLOC) - odpdrv_shm_pool_free(pool, address); - } - - CU_ASSERT(0 == odpdrv_shm_free_by_name(MEM_NAME)); - - /* check that no memory is left over: */ - odpdrv_shm_pool_print("Stress test all released", pool); - - /* destroy pool: */ - odpdrv_shm_pool_destroy(pool); -} - -odp_testinfo_t drvshmem_suite[] = { - ODP_TEST_INFO(drvshmem_test_basic), - ODP_TEST_INFO(drvshmem_test_reserve_after_fork), - ODP_TEST_INFO(drvshmem_test_singleva_after_fork), - ODP_TEST_INFO(drvshmem_test_stress), - ODP_TEST_INFO(drvshmem_test_buddy_basic), - ODP_TEST_INFO(drvshmem_test_slab_basic), - ODP_TEST_INFO(drvshmem_test_buddy_stress), - ODP_TEST_INFO_NULL, -}; - -odp_suiteinfo_t drvshmem_suites[] = { - {"Shared Memory", NULL, NULL, drvshmem_suite}, - ODP_SUITE_INFO_NULL, -}; - -int drvshmem_main(int argc, char *argv[]) -{ - int ret; - - /* parse common options: */ - if (odp_cunit_parse_options(argc, argv)) - return -1; - - ret = odp_cunit_register(drvshmem_suites); - - if (ret == 0) - ret = odp_cunit_run(); - - return ret; -} diff --git a/test/validation/drv/drvshmem/drvshmem.h b/test/validation/drv/drvshmem/drvshmem.h deleted file mode 100644 index 817b3d573..000000000 --- a/test/validation/drv/drvshmem/drvshmem.h +++ /dev/null @@ -1,30 +0,0 @@ -/* Copyright (c) 2016, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#ifndef _ODP_TEST_DRVSHMEM_H_ -#define _ODP_TEST_DRVSHMEM_H_ - -#include - -/* test functions: */ -void drvshmem_test_basic(void); -void drvshmem_test_reserve_after_fork(void); -void drvshmem_test_singleva_after_fork(void); -void drvshmem_test_stress(void); -void drvshmem_test_buddy_basic(void); -void drvshmem_test_slab_basic(void); -void drvshmem_test_buddy_stress(void); - -/* test arrays: */ -extern odp_testinfo_t drvshmem_suite[]; - -/* test registry: */ -extern odp_suiteinfo_t drvshmem_suites[]; - -/* main test program: */ -int drvshmem_main(int argc, char *argv[]); - -#endif diff --git a/test/validation/drv/drvshmem/drvshmem_main.c b/test/validation/drv/drvshmem/drvshmem_main.c deleted file mode 100644 index 566ccec66..000000000 --- a/test/validation/drv/drvshmem/drvshmem_main.c +++ /dev/null @@ -1,12 +0,0 @@ -/* Copyright (c) 2016, Linaro Limited - * All rights reserved. - * - * SPDX-License-Identifier: BSD-3-Clause - */ - -#include "drvshmem.h" - -int main(int argc, char *argv[]) -{ - return drvshmem_main(argc, argv); -}