DPDK  22.07.0
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 <rte_common.h>
40 #include <rte_spinlock.h>
41 
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
45 
46 #define RTE_TIMER_STOP 0
47 #define RTE_TIMER_PENDING 1
48 #define RTE_TIMER_RUNNING 2
49 #define RTE_TIMER_CONFIG 3
51 #define RTE_TIMER_NO_OWNER -2
56 enum rte_timer_type {
57  SINGLE,
58  PERIODICAL
59 };
60 
67  struct {
68  uint16_t state;
69  int16_t owner;
70  };
71  uint32_t u32;
72 };
73 
74 #ifdef RTE_LIBRTE_TIMER_DEBUG
75 
78 struct rte_timer_debug_stats {
79  uint64_t reset;
80  uint64_t stop;
81  uint64_t manage;
82  uint64_t pending;
83 };
84 #endif
85 
86 struct rte_timer;
87 
91 typedef void (*rte_timer_cb_t)(struct rte_timer *, void *);
92 
93 #define MAX_SKIPLIST_DEPTH 10
94 
98 struct rte_timer
99 {
100  uint64_t expire;
101  struct rte_timer *sl_next[MAX_SKIPLIST_DEPTH];
102  volatile union rte_timer_status status;
103  uint64_t period;
105  void *arg;
106 };
107 
108 
109 #ifdef __cplusplus
110 
113 #define RTE_TIMER_INITIALIZER { \
114  0, \
115  {NULL}, \
116  {{RTE_TIMER_STOP, RTE_TIMER_NO_OWNER}}, \
117  0, \
118  NULL, \
119  NULL, \
120  }
121 #else
122 
125 #define RTE_TIMER_INITIALIZER { \
126  .status = {{ \
127  .state = RTE_TIMER_STOP, \
128  .owner = RTE_TIMER_NO_OWNER, \
129  }}, \
130  }
131 #endif
132 
145 int rte_timer_data_alloc(uint32_t *id_ptr);
146 
157 int rte_timer_data_dealloc(uint32_t id);
158 
174 int rte_timer_subsystem_init(void);
175 
180 
191 void rte_timer_init(struct rte_timer *tim);
192 
235 int rte_timer_reset(struct rte_timer *tim, uint64_t ticks,
236  enum rte_timer_type type, unsigned tim_lcore,
237  rte_timer_cb_t fct, void *arg);
238 
271 void
272 rte_timer_reset_sync(struct rte_timer *tim, uint64_t ticks,
273  enum rte_timer_type type, unsigned tim_lcore,
274  rte_timer_cb_t fct, void *arg);
275 
299 int rte_timer_stop(struct rte_timer *tim);
300 
316 void rte_timer_stop_sync(struct rte_timer *tim);
317 
331 int rte_timer_pending(struct rte_timer *tim);
332 
346 __rte_experimental
347 int64_t rte_timer_next_ticks(void);
348 
364 int rte_timer_manage(void);
365 
375 int rte_timer_dump_stats(FILE *f);
376 
412 int
413 rte_timer_alt_reset(uint32_t timer_data_id, struct rte_timer *tim,
414  uint64_t ticks, enum rte_timer_type type,
415  unsigned int tim_lcore, rte_timer_cb_t fct, void *arg);
416 
434 int
435 rte_timer_alt_stop(uint32_t timer_data_id, struct rte_timer *tim);
436 
440 typedef void (*rte_timer_alt_manage_cb_t)(struct rte_timer *tim);
441 
467 int
468 rte_timer_alt_manage(uint32_t timer_data_id, unsigned int *poll_lcores,
469  int n_poll_lcores, rte_timer_alt_manage_cb_t f);
470 
474 typedef void (*rte_timer_stop_all_cb_t)(struct rte_timer *tim, void *arg);
475 
496 int
497 rte_timer_stop_all(uint32_t timer_data_id, unsigned int *walk_lcores,
498  int nb_walk_lcores, rte_timer_stop_all_cb_t f, void *f_arg);
499 
515 int
516 rte_timer_alt_dump_stats(uint32_t timer_data_id, FILE *f);
517 
518 #ifdef __cplusplus
519 }
520 #endif
521 
522 #endif /* _RTE_TIMER_H_ */
int rte_timer_pending(struct rte_timer *tim)
void rte_timer_stop_sync(struct rte_timer *tim)
void(* rte_timer_alt_manage_cb_t)(struct rte_timer *tim)
Definition: rte_timer.h:440
rte_timer_cb_t f
Definition: rte_timer.h:104
rte_timer_type
Definition: rte_timer.h:56
int rte_timer_manage(void)
void * arg
Definition: rte_timer.h:105
void rte_timer_subsystem_finalize(void)
int16_t owner
Definition: rte_timer.h:69
void rte_timer_reset_sync(struct rte_timer *tim, uint64_t ticks, enum rte_timer_type type, unsigned tim_lcore, rte_timer_cb_t fct, void *arg)
int rte_timer_reset(struct rte_timer *tim, uint64_t ticks, enum rte_timer_type type, unsigned tim_lcore, rte_timer_cb_t fct, void *arg)
uint16_t state
Definition: rte_timer.h:68
int rte_timer_subsystem_init(void)
int rte_timer_stop(struct rte_timer *tim)
int rte_timer_stop_all(uint32_t timer_data_id, unsigned int *walk_lcores, int nb_walk_lcores, rte_timer_stop_all_cb_t f, void *f_arg)
void(* rte_timer_cb_t)(struct rte_timer *, void *)
Definition: rte_timer.h:91
__rte_experimental int64_t rte_timer_next_ticks(void)
int rte_timer_alt_manage(uint32_t timer_data_id, unsigned int *poll_lcores, int n_poll_lcores, rte_timer_alt_manage_cb_t f)
uint64_t expire
Definition: rte_timer.h:100
int rte_timer_alt_dump_stats(uint32_t timer_data_id, FILE *f)
int rte_timer_data_dealloc(uint32_t id)
void rte_timer_init(struct rte_timer *tim)
int rte_timer_alt_reset(uint32_t timer_data_id, struct rte_timer *tim, uint64_t ticks, enum rte_timer_type type, unsigned int tim_lcore, rte_timer_cb_t fct, void *arg)
#define RTE_STD_C11
Definition: rte_common.h:42
uint32_t u32
Definition: rte_timer.h:71
uint64_t period
Definition: rte_timer.h:103
void(* rte_timer_stop_all_cb_t)(struct rte_timer *tim, void *arg)
Definition: rte_timer.h:474
int rte_timer_data_alloc(uint32_t *id_ptr)
int rte_timer_dump_stats(FILE *f)
int rte_timer_alt_stop(uint32_t timer_data_id, struct rte_timer *tim)