aboutsummaryrefslogtreecommitdiff
path: root/platform/linux-generic/include/odp_timer_internal.h
diff options
context:
space:
mode:
authorOla Liljedahl <ola.liljedahl@linaro.org>2015-01-08 22:35:22 +0100
committerMike Holmes <mike.holmes@linaro.org>2015-01-09 11:17:32 -0500
commit2d2e156c57921a45f656658f88ed9f79b16d7235 (patch)
tree47a33581796025dd0b0823de56eb3da1c3d25d9b /platform/linux-generic/include/odp_timer_internal.h
parent9f2be3df0570e898d0d061264bdd48a163980461 (diff)
api: odp_timer.h: updated API, lock-less implementation
The timer API is updated according to https://docs.google.com/a/linaro.org/document/d/1bfY_J8ecLJPsFTmYftb0NVmGnB9qkEc_NpcJ87yfaD8 A major change is that timers are allocated and freed separately from timeouts being set and cancelled. The life-length of a timer normally corresponds to the life-length of the associated stateful flow while the life-length of a timeout corresponds to individual packets being transmitted and received. The reference timer implementation is lock-less for platforms with support for 128-bit (16-byte) atomic exchange and CAS operations. Otherwise a lock-based implementation (using as many locks as desired) is used but some operations (e.g. reset reusing existing timeout buffer) may still be lock-less. Updated the example example/timer/odp_timer_test.c according to the updated API. Signed-off-by: Ola Liljedahl <ola.liljedahl@linaro.org> Reviewed-by: Petri Savolainen <petri.savolainen@linaro.org> Reviewed-and-tested-by: Bill Fischofer <bill.fischofer@linaro.org> Signed-off-by: Mike Holmes <mike.holmes@linaro.org>
Diffstat (limited to 'platform/linux-generic/include/odp_timer_internal.h')
-rw-r--r--platform/linux-generic/include/odp_timer_internal.h62
1 files changed, 16 insertions, 46 deletions
diff --git a/platform/linux-generic/include/odp_timer_internal.h b/platform/linux-generic/include/odp_timer_internal.h
index 0d10d00f2..ed5ee7e7d 100644
--- a/platform/linux-generic/include/odp_timer_internal.h
+++ b/platform/linux-generic/include/odp_timer_internal.h
@@ -1,4 +1,4 @@
-/* Copyright (c) 2013, Linaro Limited
+/* Copyright (c) 2014, Linaro Limited
* All rights reserved.
*
* SPDX-License-Identifier: BSD-3-Clause
@@ -8,74 +8,44 @@
/**
* @file
*
- * ODP timer timeout descriptor - implementation internal
+ * ODP timeout descriptor - implementation internal
*/
#ifndef ODP_TIMER_INTERNAL_H_
#define ODP_TIMER_INTERNAL_H_
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#include <odp_std_types.h>
-#include <odp_queue.h>
-#include <odp_buffer.h>
+#include <odp_align.h>
+#include <odp_debug.h>
#include <odp_buffer_internal.h>
#include <odp_buffer_pool_internal.h>
#include <odp_timer.h>
-struct timeout_t;
-
-typedef struct timeout_t {
- struct timeout_t *next;
- int timer_id;
- int tick;
- uint64_t tmo_tick;
- odp_queue_t queue;
- odp_buffer_t buf;
- odp_buffer_t tmo_buf;
-} timeout_t;
-
-
-struct odp_timeout_hdr_t;
-
/**
- * Timeout notification header
+ * Internal Timeout header
*/
-typedef struct odp_timeout_hdr_t {
+typedef struct {
+ /* common buffer header */
odp_buffer_hdr_t buf_hdr;
- timeout_t meta;
-
- uint8_t buf_data[];
+ /* Requested expiration time */
+ uint64_t expiration;
+ /* User ptr inherited from parent timer */
+ void *user_ptr;
+ /* Parent timer */
+ odp_timer_t timer;
} odp_timeout_hdr_t;
typedef struct odp_timeout_hdr_stride {
uint8_t pad[ODP_CACHE_LINE_SIZE_ROUNDUP(sizeof(odp_timeout_hdr_t))];
} odp_timeout_hdr_stride;
-_ODP_STATIC_ASSERT(sizeof(odp_timeout_hdr_t) ==
- ODP_OFFSETOF(odp_timeout_hdr_t, buf_data),
- "ODP_TIMEOUT_HDR_T__SIZE_ERR");
-
-_ODP_STATIC_ASSERT(sizeof(odp_timeout_hdr_t) % sizeof(uint64_t) == 0,
- "ODP_TIMEOUT_HDR_T__SIZE_ERR2");
-
/**
- * Return timeout header
+ * Return the timeout header
*/
-static inline odp_timeout_hdr_t *odp_timeout_hdr(odp_timeout_t tmo)
+static inline odp_timeout_hdr_t *odp_timeout_hdr(odp_buffer_t buf)
{
- odp_buffer_hdr_t *buf_hdr = odp_buf_to_hdr((odp_buffer_t)tmo);
- return (odp_timeout_hdr_t *)(uintptr_t)buf_hdr;
+ return (odp_timeout_hdr_t *)odp_buf_to_hdr(buf);
}
-
-
-#ifdef __cplusplus
-}
-#endif
-
#endif