DPDK 22.11.5
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_compat.h>
40#include <rte_common.h>
41#include <rte_spinlock.h>
42
43#ifdef __cplusplus
44extern "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
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
79struct rte_timer_debug_stats {
80 uint64_t reset;
81 uint64_t stop;
82 uint64_t manage;
83 uint64_t pending;
84};
85#endif
86
87struct rte_timer;
88
92typedef void (*rte_timer_cb_t)(struct rte_timer *, void *);
93
94#define MAX_SKIPLIST_DEPTH 10
95
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
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
126#define RTE_TIMER_INITIALIZER { \
127 .status = {{ \
128 .state = RTE_TIMER_STOP, \
129 .owner = RTE_TIMER_NO_OWNER, \
130 }}, \
131 }
132#endif
133
146int rte_timer_data_alloc(uint32_t *id_ptr);
147
158int rte_timer_data_dealloc(uint32_t id);
159
176
181
192void rte_timer_init(struct rte_timer *tim);
193
236int rte_timer_reset(struct rte_timer *tim, uint64_t ticks,
237 enum rte_timer_type type, unsigned tim_lcore,
238 rte_timer_cb_t fct, void *arg);
239
272void
273rte_timer_reset_sync(struct rte_timer *tim, uint64_t ticks,
274 enum rte_timer_type type, unsigned tim_lcore,
275 rte_timer_cb_t fct, void *arg);
276
300int rte_timer_stop(struct rte_timer *tim);
301
318
333
347__rte_experimental
349
366
377
413int
414rte_timer_alt_reset(uint32_t timer_data_id, struct rte_timer *tim,
415 uint64_t ticks, enum rte_timer_type type,
416 unsigned int tim_lcore, rte_timer_cb_t fct, void *arg);
417
435int
436rte_timer_alt_stop(uint32_t timer_data_id, struct rte_timer *tim);
437
441typedef void (*rte_timer_alt_manage_cb_t)(struct rte_timer *tim);
442
468int
469rte_timer_alt_manage(uint32_t timer_data_id, unsigned int *poll_lcores,
470 int n_poll_lcores, rte_timer_alt_manage_cb_t f);
471
475typedef void (*rte_timer_stop_all_cb_t)(struct rte_timer *tim, void *arg);
476
497int
498rte_timer_stop_all(uint32_t timer_data_id, unsigned int *walk_lcores,
499 int nb_walk_lcores, rte_timer_stop_all_cb_t f, void *f_arg);
500
516int
517rte_timer_alt_dump_stats(uint32_t timer_data_id, FILE *f);
518
519#ifdef __cplusplus
520}
521#endif
522
523#endif /* _RTE_TIMER_H_ */
#define RTE_STD_C11
Definition: rte_common.h:39
int rte_timer_alt_stop(uint32_t timer_data_id, struct rte_timer *tim)
void rte_timer_stop_sync(struct rte_timer *tim)
void rte_timer_subsystem_finalize(void)
int rte_timer_data_alloc(uint32_t *id_ptr)
int rte_timer_data_dealloc(uint32_t id)
int rte_timer_pending(struct rte_timer *tim)
rte_timer_type
Definition: rte_timer.h:57
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)
void(* rte_timer_stop_all_cb_t)(struct rte_timer *tim, void *arg)
Definition: rte_timer.h:475
void rte_timer_init(struct rte_timer *tim)
int rte_timer_stop(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)
int rte_timer_alt_dump_stats(uint32_t timer_data_id, FILE *f)
__rte_experimental int64_t rte_timer_next_ticks(void)
int rte_timer_manage(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)
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)
void(* rte_timer_alt_manage_cb_t)(struct rte_timer *tim)
Definition: rte_timer.h:441
void(* rte_timer_cb_t)(struct rte_timer *, void *)
Definition: rte_timer.h:92
int rte_timer_dump_stats(FILE *f)
int rte_timer_subsystem_init(void)
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)
rte_timer_cb_t f
Definition: rte_timer.h:105
volatile union rte_timer_status status
Definition: rte_timer.h:103
uint64_t period
Definition: rte_timer.h:104
void * arg
Definition: rte_timer.h:106
uint64_t expire
Definition: rte_timer.h:101
int16_t owner
Definition: rte_timer.h:70
uint32_t u32
Definition: rte_timer.h:72
uint16_t state
Definition: rte_timer.h:69