DPDK  24.11.0-rc3
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
20 extern "C" {
21 #endif
22 
23 #define MS_PER_S 1000
24 #define US_PER_S 1000000
25 #define NS_PER_S 1000000000
26 
27 enum timer_source {
28  EAL_TIMER_TSC = 0,
29  EAL_TIMER_HPET
30 };
31 extern enum timer_source eal_timer_source;
32 
39 uint64_t
40 rte_get_tsc_hz(void);
41 
48 static inline uint64_t
49 rte_get_tsc_cycles(void);
50 
51 #ifdef RTE_LIBEAL_USE_HPET
52 
61 uint64_t
62 rte_get_hpet_cycles(void);
63 
70 uint64_t
71 rte_get_hpet_hz(void);
72 
86 int rte_eal_hpet_init(int make_default);
87 
88 #endif
89 
96 static 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 
118 static 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 }
141 extern void
142 (*rte_delay_us)(unsigned int us);
143 
150 static inline void
151 rte_delay_ms(unsigned ms)
152 {
153  rte_delay_us(ms * 1000);
154 }
155 
162 void rte_delay_us_block(unsigned int us);
163 
171 void rte_delay_us_sleep(unsigned int us);
172 
180 void rte_delay_us_callback_register(void(*userfunc)(unsigned int));
181 
182 #ifdef __cplusplus
183 }
184 #endif
185 
186 #endif /* _RTE_CYCLES_H_ */
void rte_delay_us_block(unsigned int us)
void rte_delay_us_callback_register(void(*userfunc)(unsigned int))
static void rte_delay_ms(unsigned ms)
Definition: rte_cycles.h:151
static uint64_t rte_get_timer_hz(void)
Definition: rte_cycles.h:119
void(* rte_delay_us)(unsigned int us)
#define rte_panic(...)
Definition: rte_debug.h:43
static uint64_t rte_get_tsc_cycles(void)
void rte_delay_us_sleep(unsigned int us)
uint64_t rte_get_tsc_hz(void)
static uint64_t rte_get_timer_cycles(void)
Definition: rte_cycles.h:97