DPDK 25.03.0-rc0
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_debug.h>
17#include <rte_atomic.h>
18
19#ifdef __cplusplus
20extern "C" {
21#endif
22
23#define MS_PER_S 1000
24#define US_PER_S 1000000
25#define NS_PER_S 1000000000
26
27enum timer_source {
28 EAL_TIMER_TSC = 0,
29 EAL_TIMER_HPET
30};
31extern enum timer_source eal_timer_source;
32
39uint64_t
41
48static inline uint64_t
50
51#ifdef RTE_LIBEAL_USE_HPET
61uint64_t
62rte_get_hpet_cycles(void);
63
70uint64_t
71rte_get_hpet_hz(void);
72
86int rte_eal_hpet_init(int make_default);
87
88#endif
89
96static inline uint64_t
98{
99#ifdef RTE_LIBEAL_USE_HPET
100 switch(eal_timer_source) {
101 case EAL_TIMER_TSC:
102#endif
103 return rte_get_tsc_cycles();
104#ifdef RTE_LIBEAL_USE_HPET
105 case EAL_TIMER_HPET:
106 return rte_get_hpet_cycles();
107 default: rte_panic("Invalid timer source specified\n");
108 }
109#endif
110}
111
118static inline uint64_t
120{
121#ifdef RTE_LIBEAL_USE_HPET
122 switch(eal_timer_source) {
123 case EAL_TIMER_TSC:
124#endif
125 return rte_get_tsc_hz();
126#ifdef RTE_LIBEAL_USE_HPET
127 case EAL_TIMER_HPET:
128 return rte_get_hpet_hz();
129 default: rte_panic("Invalid timer source specified\n");
130 }
131#endif
132}
141extern void
142(*rte_delay_us)(unsigned int us);
143
150static inline void
151rte_delay_ms(unsigned ms)
152{
153 rte_delay_us(ms * 1000);
154}
155
162void rte_delay_us_block(unsigned int us);
163
171void rte_delay_us_sleep(unsigned int us);
172
180void rte_delay_us_callback_register(void(*userfunc)(unsigned int));
181
182#ifdef __cplusplus
183}
184#endif
185
186#endif /* _RTE_CYCLES_H_ */
static uint64_t rte_get_timer_hz(void)
Definition: rte_cycles.h:119
static uint64_t rte_get_timer_cycles(void)
Definition: rte_cycles.h:97
static uint64_t rte_get_tsc_cycles(void)
void rte_delay_us_callback_register(void(*userfunc)(unsigned int))
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:151
#define rte_panic(...)
Definition: rte_debug.h:43