DPDK 21.11.9
rte_cycles.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2014 Intel Corporation.
3 * Copyright(c) 2013 6WIND S.A.
4 */
5
6#ifndef _RTE_CYCLES_H_
7#define _RTE_CYCLES_H_
8
15#include <stdint.h>
16#include <rte_compat.h>
17#include <rte_debug.h>
18#include <rte_atomic.h>
19
20#define MS_PER_S 1000
21#define US_PER_S 1000000
22#define NS_PER_S 1000000000
23
24enum timer_source {
25 EAL_TIMER_TSC = 0,
26 EAL_TIMER_HPET
27};
28extern enum timer_source eal_timer_source;
29
36uint64_t
38
45static inline uint64_t
47
48#ifdef RTE_LIBEAL_USE_HPET
58uint64_t
59rte_get_hpet_cycles(void);
60
67uint64_t
68rte_get_hpet_hz(void);
69
83int rte_eal_hpet_init(int make_default);
84
85#endif
86
93static inline uint64_t
95{
96#ifdef RTE_LIBEAL_USE_HPET
97 switch(eal_timer_source) {
98 case EAL_TIMER_TSC:
99#endif
100 return rte_get_tsc_cycles();
101#ifdef RTE_LIBEAL_USE_HPET
102 case EAL_TIMER_HPET:
103 return rte_get_hpet_cycles();
104 default: rte_panic("Invalid timer source specified\n");
105 }
106#endif
107}
108
115static inline uint64_t
117{
118#ifdef RTE_LIBEAL_USE_HPET
119 switch(eal_timer_source) {
120 case EAL_TIMER_TSC:
121#endif
122 return rte_get_tsc_hz();
123#ifdef RTE_LIBEAL_USE_HPET
124 case EAL_TIMER_HPET:
125 return rte_get_hpet_hz();
126 default: rte_panic("Invalid timer source specified\n");
127 }
128#endif
129}
138extern void
139(*rte_delay_us)(unsigned int us);
140
147static inline void
148rte_delay_ms(unsigned ms)
149{
150 rte_delay_us(ms * 1000);
151}
152
159void rte_delay_us_block(unsigned int us);
160
168__rte_experimental
169void
170rte_delay_us_sleep(unsigned int us);
171
179void rte_delay_us_callback_register(void(*userfunc)(unsigned int));
180
181#endif /* _RTE_CYCLES_H_ */
static uint64_t rte_get_timer_hz(void)
Definition: rte_cycles.h:116
static uint64_t rte_get_timer_cycles(void)
Definition: rte_cycles.h:94
static uint64_t rte_get_tsc_cycles(void)
void rte_delay_us_callback_register(void(*userfunc)(unsigned int))
__rte_experimental void rte_delay_us_sleep(unsigned int us)
void(* rte_delay_us)(unsigned int us)
void rte_delay_us_block(unsigned int us)
uint64_t rte_get_tsc_hz(void)
static void rte_delay_ms(unsigned ms)
Definition: rte_cycles.h:148
#define rte_panic(...)
Definition: rte_debug.h:43