DPDK  18.05.1
rte_timer.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2014 Intel Corporation
3  */
4 
5 #ifndef _RTE_TIMER_H_
6 #define _RTE_TIMER_H_
7 
37 #include <stdio.h>
38 #include <stdint.h>
39 #include <stddef.h>
40 #include <rte_common.h>
41 #include <rte_config.h>
42 
43 #ifdef __cplusplus
44 extern "C" {
45 #endif
46 
47 #define RTE_TIMER_STOP 0
48 #define RTE_TIMER_PENDING 1
49 #define RTE_TIMER_RUNNING 2
50 #define RTE_TIMER_CONFIG 3
52 #define RTE_TIMER_NO_OWNER -2
57 enum rte_timer_type {
58  SINGLE,
59  PERIODICAL
60 };
61 
68  struct {
69  uint16_t state;
70  int16_t owner;
71  };
72  uint32_t u32;
73 };
74 
75 #ifdef RTE_LIBRTE_TIMER_DEBUG
76 
79 struct rte_timer_debug_stats {
80  uint64_t reset;
81  uint64_t stop;
82  uint64_t manage;
83  uint64_t pending;
84 };
85 #endif
86 
87 struct rte_timer;
88 
92 typedef void (*rte_timer_cb_t)(struct rte_timer *, void *);
93 
94 #define MAX_SKIPLIST_DEPTH 10
95 
99 struct rte_timer
100 {
101  uint64_t expire;
102  struct rte_timer *sl_next[MAX_SKIPLIST_DEPTH];
103  volatile union rte_timer_status status;
104  uint64_t period;
106  void *arg;
107 };
108 
109 
110 #ifdef __cplusplus
111 
114 #define RTE_TIMER_INITIALIZER { \
115  0, \
116  {NULL}, \
117  {{RTE_TIMER_STOP, RTE_TIMER_NO_OWNER}}, \
118  0, \
119  NULL, \
120  NULL, \
121  }
122 #else
123 
126 #define RTE_TIMER_INITIALIZER { \
127  .status = {{ \
128  .state = RTE_TIMER_STOP, \
129  .owner = RTE_TIMER_NO_OWNER, \
130  }}, \
131  }
132 #endif
133 
140 void rte_timer_subsystem_init(void);
141 
152 void rte_timer_init(struct rte_timer *tim);
153 
196 int rte_timer_reset(struct rte_timer *tim, uint64_t ticks,
197  enum rte_timer_type type, unsigned tim_lcore,
198  rte_timer_cb_t fct, void *arg);
199 
200 
227 void
228 rte_timer_reset_sync(struct rte_timer *tim, uint64_t ticks,
229  enum rte_timer_type type, unsigned tim_lcore,
230  rte_timer_cb_t fct, void *arg);
231 
255 int rte_timer_stop(struct rte_timer *tim);
256 
257 
267 void rte_timer_stop_sync(struct rte_timer *tim);
268 
282 int rte_timer_pending(struct rte_timer *tim);
283 
295 void rte_timer_manage(void);
296 
303 void rte_timer_dump_stats(FILE *f);
304 
305 #ifdef __cplusplus
306 }
307 #endif
308 
309 #endif /* _RTE_TIMER_H_ */