DPDK  19.08.2
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 #include <rte_spinlock.h>
43 
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47 
48 #define RTE_TIMER_STOP 0
49 #define RTE_TIMER_PENDING 1
50 #define RTE_TIMER_RUNNING 2
51 #define RTE_TIMER_CONFIG 3
53 #define RTE_TIMER_NO_OWNER -2
58 enum rte_timer_type {
59  SINGLE,
60  PERIODICAL
61 };
62 
69  struct {
70  uint16_t state;
71  int16_t owner;
72  };
73  uint32_t u32;
74 };
75 
76 #ifdef RTE_LIBRTE_TIMER_DEBUG
77 
80 struct rte_timer_debug_stats {
81  uint64_t reset;
82  uint64_t stop;
83  uint64_t manage;
84  uint64_t pending;
85 };
86 #endif
87 
88 struct rte_timer;
89 
93 typedef void (*rte_timer_cb_t)(struct rte_timer *, void *);
94 
95 #define MAX_SKIPLIST_DEPTH 10
96 
100 struct rte_timer
101 {
102  uint64_t expire;
103  struct rte_timer *sl_next[MAX_SKIPLIST_DEPTH];
104  volatile union rte_timer_status status;
105  uint64_t period;
107  void *arg;
108 };
109 
110 
111 #ifdef __cplusplus
112 
115 #define RTE_TIMER_INITIALIZER { \
116  0, \
117  {NULL}, \
118  {{RTE_TIMER_STOP, RTE_TIMER_NO_OWNER}}, \
119  0, \
120  NULL, \
121  NULL, \
122  }
123 #else
124 
127 #define RTE_TIMER_INITIALIZER { \
128  .status = {{ \
129  .state = RTE_TIMER_STOP, \
130  .owner = RTE_TIMER_NO_OWNER, \
131  }}, \
132  }
133 #endif
134 
150 __rte_experimental
151 int rte_timer_data_alloc(uint32_t *id_ptr);
152 
166 __rte_experimental
167 int rte_timer_data_dealloc(uint32_t id);
168 
183 int rte_timer_subsystem_init(void);
184 int rte_timer_subsystem_init_v1905(void);
185 void rte_timer_subsystem_init_v20(void);
186 
193 __rte_experimental
195 
206 void rte_timer_init(struct rte_timer *tim);
207 
250 int rte_timer_reset(struct rte_timer *tim, uint64_t ticks,
251  enum rte_timer_type type, unsigned tim_lcore,
252  rte_timer_cb_t fct, void *arg);
253 int rte_timer_reset_v1905(struct rte_timer *tim, uint64_t ticks,
254  enum rte_timer_type type, unsigned int tim_lcore,
255  rte_timer_cb_t fct, void *arg);
256 int rte_timer_reset_v20(struct rte_timer *tim, uint64_t ticks,
257  enum rte_timer_type type, unsigned int tim_lcore,
258  rte_timer_cb_t fct, void *arg);
259 
260 
287 void
288 rte_timer_reset_sync(struct rte_timer *tim, uint64_t ticks,
289  enum rte_timer_type type, unsigned tim_lcore,
290  rte_timer_cb_t fct, void *arg);
291 
315 int rte_timer_stop(struct rte_timer *tim);
316 int rte_timer_stop_v1905(struct rte_timer *tim);
317 int rte_timer_stop_v20(struct rte_timer *tim);
318 
328 void rte_timer_stop_sync(struct rte_timer *tim);
329 
343 int rte_timer_pending(struct rte_timer *tim);
344 
360 int rte_timer_manage(void);
361 int rte_timer_manage_v1905(void);
362 void rte_timer_manage_v20(void);
363 
373 int rte_timer_dump_stats(FILE *f);
374 int rte_timer_dump_stats_v1905(FILE *f);
375 void rte_timer_dump_stats_v20(FILE *f);
376 
415 __rte_experimental
416 int
417 rte_timer_alt_reset(uint32_t timer_data_id, struct rte_timer *tim,
418  uint64_t ticks, enum rte_timer_type type,
419  unsigned int tim_lcore, rte_timer_cb_t fct, void *arg);
420 
441 __rte_experimental
442 int
443 rte_timer_alt_stop(uint32_t timer_data_id, struct rte_timer *tim);
444 
448 typedef void (*rte_timer_alt_manage_cb_t)(struct rte_timer *tim);
449 
478 __rte_experimental
479 int
480 rte_timer_alt_manage(uint32_t timer_data_id, unsigned int *poll_lcores,
481  int n_poll_lcores, rte_timer_alt_manage_cb_t f);
482 
486 typedef void (*rte_timer_stop_all_cb_t)(struct rte_timer *tim, void *arg);
487 
511 __rte_experimental
512 int
513 rte_timer_stop_all(uint32_t timer_data_id, unsigned int *walk_lcores,
514  int nb_walk_lcores, rte_timer_stop_all_cb_t f, void *f_arg);
515 
534 __rte_experimental
535 int
536 rte_timer_alt_dump_stats(uint32_t timer_data_id, FILE *f);
537 
538 #ifdef __cplusplus
539 }
540 #endif
541 
542 #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:448
rte_timer_cb_t f
Definition: rte_timer.h:106
rte_timer_type
Definition: rte_timer.h:58
int rte_timer_manage(void)
volatile union rte_timer_status status
Definition: rte_timer.h:104
void * arg
Definition: rte_timer.h:107
__rte_experimental void rte_timer_subsystem_finalize(void)
__rte_experimental 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)
int16_t owner
Definition: rte_timer.h:71
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)
__rte_experimental int rte_timer_alt_stop(uint32_t timer_data_id, struct rte_timer *tim)
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:70
int rte_timer_subsystem_init(void)
int rte_timer_stop(struct rte_timer *tim)
__rte_experimental int rte_timer_data_dealloc(uint32_t id)
void(* rte_timer_cb_t)(struct rte_timer *, void *)
Definition: rte_timer.h:93
__rte_experimental 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:102
void rte_timer_init(struct rte_timer *tim)
#define RTE_STD_C11
Definition: rte_common.h:40
uint32_t u32
Definition: rte_timer.h:73
uint64_t period
Definition: rte_timer.h:105
void(* rte_timer_stop_all_cb_t)(struct rte_timer *tim, void *arg)
Definition: rte_timer.h:486
__rte_experimental 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)
int rte_timer_dump_stats(FILE *f)
__rte_experimental int rte_timer_data_alloc(uint32_t *id_ptr)
__rte_experimental int rte_timer_alt_dump_stats(uint32_t timer_data_id, FILE *f)