DPDK 25.03.0-rc0
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
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
67 struct {
68 RTE_ATOMIC(uint16_t) state;
69 RTE_ATOMIC(int16_t) owner;
70 };
71 RTE_ATOMIC(uint32_t) u32;
72};
73
74#ifdef RTE_LIBRTE_TIMER_DEBUG
78struct rte_timer_debug_stats {
79 uint64_t reset;
80 uint64_t stop;
81 uint64_t manage;
82 uint64_t pending;
83};
84#endif
85
86struct rte_timer;
87
91typedef void (*rte_timer_cb_t)(struct rte_timer *, void *);
92
93#define MAX_SKIPLIST_DEPTH 10
94
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
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
125#define RTE_TIMER_INITIALIZER { \
126 .status = {{ \
127 .state = RTE_TIMER_STOP, \
128 .owner = RTE_TIMER_NO_OWNER, \
129 }}, \
130 }
131#endif
132
145int rte_timer_data_alloc(uint32_t *id_ptr);
146
157int rte_timer_data_dealloc(uint32_t id);
158
175
180
191void rte_timer_init(struct rte_timer *tim);
192
235int 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
271void
272rte_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
299int rte_timer_stop(struct rte_timer *tim);
300
317
332
344
361
372
408int
409rte_timer_alt_reset(uint32_t timer_data_id, struct rte_timer *tim,
410 uint64_t ticks, enum rte_timer_type type,
411 unsigned int tim_lcore, rte_timer_cb_t fct, void *arg);
412
430int
431rte_timer_alt_stop(uint32_t timer_data_id, struct rte_timer *tim);
432
436typedef void (*rte_timer_alt_manage_cb_t)(struct rte_timer *tim);
437
463int
464rte_timer_alt_manage(uint32_t timer_data_id, unsigned int *poll_lcores,
465 int n_poll_lcores, rte_timer_alt_manage_cb_t f);
466
470typedef void (*rte_timer_stop_all_cb_t)(struct rte_timer *tim, void *arg);
471
492int
493rte_timer_stop_all(uint32_t timer_data_id, unsigned int *walk_lcores,
494 int nb_walk_lcores, rte_timer_stop_all_cb_t f, void *f_arg);
495
511int
512rte_timer_alt_dump_stats(uint32_t timer_data_id, FILE *f);
513
514#ifdef __cplusplus
515}
516#endif
517
518#endif /* _RTE_TIMER_H_ */
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:470
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)
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:436
void(* rte_timer_cb_t)(struct rte_timer *, void *)
Definition: rte_timer.h:91
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:104
volatile union rte_timer_status status
Definition: rte_timer.h:102
uint64_t period
Definition: rte_timer.h:103
void * arg
Definition: rte_timer.h:105
uint64_t expire
Definition: rte_timer.h:100
int16_t owner
Definition: rte_timer.h:69
uint32_t u32
Definition: rte_timer.h:71
uint16_t state
Definition: rte_timer.h:68