DPDK 22.11.6
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#define MS_PER_S 1000
20#define US_PER_S 1000000
21#define NS_PER_S 1000000000
22
23enum timer_source {
24 EAL_TIMER_TSC = 0,
25 EAL_TIMER_HPET
26};
27extern enum timer_source eal_timer_source;
28
35uint64_t
37
44static inline uint64_t
46
47#ifdef RTE_LIBEAL_USE_HPET
57uint64_t
58rte_get_hpet_cycles(void);
59
66uint64_t
67rte_get_hpet_hz(void);
68
82int rte_eal_hpet_init(int make_default);
83
84#endif
85
92static inline uint64_t
94{
95#ifdef RTE_LIBEAL_USE_HPET
96 switch(eal_timer_source) {
97 case EAL_TIMER_TSC:
98#endif
99 return rte_get_tsc_cycles();
100#ifdef RTE_LIBEAL_USE_HPET
101 case EAL_TIMER_HPET:
102 return rte_get_hpet_cycles();
103 default: rte_panic("Invalid timer source specified\n");
104 }
105#endif
106}
107
114static inline uint64_t
116{
117#ifdef RTE_LIBEAL_USE_HPET
118 switch(eal_timer_source) {
119 case EAL_TIMER_TSC:
120#endif
121 return rte_get_tsc_hz();
122#ifdef RTE_LIBEAL_USE_HPET
123 case EAL_TIMER_HPET:
124 return rte_get_hpet_hz();
125 default: rte_panic("Invalid timer source specified\n");
126 }
127#endif
128}
137extern void
138(*rte_delay_us)(unsigned int us);
139
146static inline void
147rte_delay_ms(unsigned ms)
148{
149 rte_delay_us(ms * 1000);
150}
151
158void rte_delay_us_block(unsigned int us);
159
167void rte_delay_us_sleep(unsigned int us);
168
176void rte_delay_us_callback_register(void(*userfunc)(unsigned int));
177
178#endif /* _RTE_CYCLES_H_ */
static uint64_t rte_get_timer_hz(void)
Definition: rte_cycles.h:115
static uint64_t rte_get_timer_cycles(void)
Definition: rte_cycles.h:93
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:147
#define rte_panic(...)
Definition: rte_debug.h:43