aboutsummaryrefslogtreecommitdiff
path: root/platform/linux-generic/include/odp_timer_internal.h
blob: 2351def95f27f3df34ef37e9a302c9dc976e515f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/* SPDX-License-Identifier: BSD-3-Clause
 * Copyright (c) 2014-2018 Linaro Limited
 * Copyright (c) 2021-2022 Nokia
 */

/**
 * @file
 *
 * ODP timeout descriptor - implementation internal
 */

#ifndef ODP_TIMER_INTERNAL_H_
#define ODP_TIMER_INTERNAL_H_

#include <odp/api/align.h>
#include <odp/api/debug.h>
#include <odp/api/timer.h>

#include <odp_event_internal.h>
#include <odp_global_data.h>
#include <odp_pool_internal.h>

/*
 * Use as the argument to timer_run() to force a scan and to ignore rate
 * limit.
 */
#define TIMER_SCAN_FORCE INT32_MAX

/**
 * Internal Timeout header
 */
typedef struct ODP_ALIGNED_CACHE odp_timeout_hdr_t {
	/* Common event header */
	_odp_event_hdr_t event_hdr;

	/* Requested expiration time */
	uint64_t expiration;

	/* User ptr inherited from parent timer */
	const void *user_ptr;

	/* User area pointer */
	void *uarea_addr;

	/* Parent timer */
	odp_timer_t timer;

} odp_timeout_hdr_t;

ODP_STATIC_ASSERT(sizeof(odp_timeout_hdr_t) <= ODP_CACHE_LINE_SIZE,
		  "TIMEOUT_HDR_SIZE_ERROR");

/* A larger decrement value should be used after receiving events compared to
 * an 'empty' call. */
uint64_t _odp_timer_run_inline(int dec);

/* Static inline wrapper to minimize modification of schedulers. */
static inline uint64_t timer_run(int dec)
{
	if (odp_global_rw->inline_timers)
		return _odp_timer_run_inline(dec);

	return UINT64_MAX;
}

#endif