EM-ODP  3.7.0
Event Machine on ODP
em_timer_types.h
1 /*
2  * Copyright (c) 2017-2024, Nokia Solutions and Networks
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * * Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in the
13  * documentation and/or other materials provided with the distribution.
14  * * Neither the name of the copyright holder nor the names of its
15  * contributors may be used to endorse or promote products derived
16  * from this software without specific prior written permission.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 #ifndef EM_TIMER_TYPES_H_
31 #define EM_TIMER_TYPES_H_
32 
33 #include <stdatomic.h>
34 #include <odp_api.h>
35 #include "em_timer_conf.h"
36 
37 /* per timer (ODP timer pool) */
38 typedef struct event_timer_t {
39  odp_timer_pool_t odp_tmr_pool;
40  odp_pool_t tmo_pool;
41  em_timer_flag_t flags;
42  int idx;
43  int plain_q_ok;
44  bool is_ring;
45  uint32_t num_ring_reserve;
46  uint32_t num_tmo_reserve;
48 
49 /* Timer */
50 typedef struct {
51  /* locks handling of these values */
52  odp_ticketlock_t timer_lock;
53  /* shared tmo pool if used */
54  odp_pool_t shared_tmo_pool;
55  /* odp timeout event pool for ring timers */
56  odp_pool_t ring_tmo_pool;
57  /* counter for shared pool mgmt */
58  uint32_t num_rings;
59  /* all timers count for cleanup */
60  uint32_t num_timers;
61  /* how many events reserved by ring timers so far */
62  uint32_t ring_reserved;
63  /* how many tmos reserved by timers so far */
64  uint32_t reserved;
65  /* how many times em_timer_ring_create() has been called, incremented only */
66  uint32_t num_ring_create_calls;
67  /* to verify that the timer data has been initialized before use */
68  uint32_t init_check;
69  /* event timers */
70  event_timer_t timer[EM_ODP_MAX_TIMERS];
72 
73 /* EM timeout handle points to this. Holds the timer state.
74  * Some values are copies from e.g. timer data for faster access.
75  */
76 typedef struct em_timer_timeout_t {
77  odp_atomic_u32_t state; /* timeout state */
78  uint64_t period; /* for periodic */
79  uint64_t last_tick; /* for periodic */
80  em_tmo_flag_t flags; /* oneshot/periodic etc */
81  bool is_ring; /* ring or normal timer */
82  em_queue_t queue; /* destination queue */
83  odp_timer_t odp_timer; /* odp timer / em tmo */
84  odp_timer_pool_t odp_timer_pool;/* odp timer_pool <- em timer */
85  odp_buffer_t odp_buffer; /* this data is in odp buffer */
86  /* 2nd cache line: */
87  em_timer_t timer; /* related timer (can't lookup from odp timer pool) */
88  odp_pool_t ring_tmo_pool; /* if ring: this is the pool for odp timeout event */
89  odp_event_t odp_timeout; /* if ring: this is the pre-allocated odp timeout event */
90  em_tmo_stats_t stats; /* per tmo statistics */
92 
93 #endif /* EM_TIMER_TYPES_H_ */
em_tmo_stats_t
Definition: api/event_machine_timer.h:368
em_tmo_flag_t
em_tmo_flag_t
Definition: event_machine_timer_hw_specific.h:80
timer_storage_t
Definition: em_timer_types.h:50
em_timer_timeout_t
Definition: em_timer_types.h:76
em_timer_conf.h
event_timer_t
Definition: em_timer_types.h:38
em_timer_flag_t
em_timer_flag_t
Definition: event_machine_timer_hw_specific.h:57