EM-ODP 4.4.0
Event Machine on ODP
Loading...
Searching...
No Matches
event_machine_types.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2012, Nokia Siemens Networks
3 * Copyright (c) 2014-2026, Nokia Solutions and Networks
4 * All rights reserved.
5 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 *
10 * * Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * * Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
15 * * Neither the name of the copyright holder nor the names of its
16 * contributors may be used to endorse or promote products derived
17 * from this software without specific prior written permission.
18 *
19 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
22 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
23 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
24 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
25 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30 */
31
32#ifndef EVENT_MACHINE_TYPES_H_
33#define EVENT_MACHINE_TYPES_H_
34
35#pragma GCC visibility push(default)
36
37/**
38 * @file
39 *
40 * Event Machine basic types and defines
41 */
42
43#include <inttypes.h>
44#include <stdarg.h>
45#include <stddef.h>
46#include <stdbool.h>
47
48#include <odp/api/cpumask.h>
49
51
52#ifdef __cplusplus
53extern "C" {
54#endif
55
56/** EM boolean value: True */
57#define EM_TRUE 1
58/** EM boolean value: False */
59#define EM_FALSE 0
60
61/** EM undefined u64 */
62#define EM_UNDEF_U64 0
63/** EM undefined u32 */
64#define EM_UNDEF_U32 0
65/** EM undefined u16 */
66#define EM_UNDEF_U16 0
67/** EM undefined u8 */
68#define EM_UNDEF_U8 0
69/** EM undefined uintptr */
70#define EM_UNDEF_UINTPTR EM_STATIC_CAST(uintptr_t, NULL)
71/** EM undefined pointer */
72#ifndef __cplusplus
73#define EM_UNDEF_PTR NULL
74#else
75#define EM_UNDEF_PTR nullptr
76#endif
77
78/**
79 * @def EM_HANDLE_T
80 * Define 'type_t' as a struct ptr to improve type safety
81 */
82#define EM_HANDLE_T(type_t) \
83 typedef struct _##type_t { \
84 void *unused; \
85 } *(type_t)
86
87/**
88 * @def EM_HDL_UNDEF
89 * Undefined EM-handle
90 */
91#ifndef __cplusplus
92#define EM_HDL_UNDEF NULL
93#else
94#define EM_HDL_UNDEF nullptr
95#endif
96
97/**
98 * @def PRI_HDL
99 * EM-handle printf format
100 */
101#define PRI_HDL "p"
102
103/**
104 * @typedef em_event_t
105 * Event handle
106 */
107EM_HANDLE_T(em_event_t);
108
109/** Undefined event */
110#define EM_EVENT_UNDEF EM_STATIC_CAST(em_event_t, EM_HDL_UNDEF)
111/** em_event_t printf format */
112#define PRI_EVENT PRI_HDL
113
114/**
115 * @typedef em_pool_t
116 * Memory/Event Pool handle.
117 *
118 * Defines the memory pool e.g. used in em_alloc() and
119 * created by em_pool_create().
120 * The default pool is defined by EM_POOL_DEFAULT.
121 */
122EM_HANDLE_T(em_pool_t);
123/** Undefined EM pool */
124#define EM_POOL_UNDEF EM_STATIC_CAST(em_pool_t, EM_HDL_UNDEF)
125/** em_pool_t printf format */
126#define PRI_POOL PRI_HDL
127
128/**
129 * @typedef em_eo_t
130 * Execution Object handle
131 *
132 * @see em_eo_create()
133 */
134EM_HANDLE_T(em_eo_t);
135/** Undefined EO */
136#define EM_EO_UNDEF EM_STATIC_CAST(em_eo_t, EM_HDL_UNDEF)
137/** em_eo_t printf format */
138#define PRI_EO PRI_HDL
139
140/**
141 * @typedef em_queue_t
142 * Queue handle
143 *
144 * @see em_queue_create(), em_receive_func_t(), em_send()
145 */
146EM_HANDLE_T(em_queue_t);
147/** Undefined queue */
148#define EM_QUEUE_UNDEF EM_STATIC_CAST(em_queue_t, EM_HDL_UNDEF)
149/** em_queue_t printf format */
150#define PRI_QUEUE PRI_HDL
151
152/**
153 * @typedef em_queue_group_t
154 * Queue Group handle
155 *
156 * Each queue belongs to one queue group that defines a core mask for
157 * scheduling events, i.e. defines which cores participate in load balancing.
158 * A queue group can also allow only a single core for no load balancing.
159 *
160 * Queue groups need to be created as needed. One default queue group, i.e.
161 * EM_QUEUE_GROUP_DEFAULT, always exists, and that allows scheduling to all the
162 * EM cores running on the EM instance.
163 *
164 * @see em_queue_group_create()
165 */
166EM_HANDLE_T(em_queue_group_t);
167/** Undefined queue group */
168#define EM_QUEUE_GROUP_UNDEF EM_STATIC_CAST(em_queue_group_t, EM_HDL_UNDEF)
169/** em_queue_group_t printf format */
170#define PRI_QGRP PRI_HDL
171
172/**
173 * @typedef em_event_group_t
174 * Event Group handle
175 *
176 * Event groups are used for fork-join event handling.
177 *
178 * @see em_event_group_create()
179 */
180EM_HANDLE_T(em_event_group_t);
181/** Undefined event group */
182#define EM_EVENT_GROUP_UNDEF EM_STATIC_CAST(em_event_group_t, EM_HDL_UNDEF)
183/** em_event_group_t printf format */
184#define PRI_EGRP PRI_HDL
185
186/**
187 * @typedef em_atomic_group_t
188 * Atomic Group handle
189 *
190 * Atomic groups combine multiple atomic queues into one atomically
191 * scheduled group.
192 *
193 * @see em_atomic_group_create()
194 */
195EM_HANDLE_T(em_atomic_group_t);
196/** Undefined atomic group */
197#define EM_ATOMIC_GROUP_UNDEF EM_STATIC_CAST(em_atomic_group_t, EM_HDL_UNDEF)
198/** em_atomic_group_t printf format */
199#define PRI_AGRP PRI_HDL
200
201/**
202 * @typedef em_event_type_t
203 * Event type
204 *
205 * The event type is given to the EO-receive function for each received event
206 * and is also needed for event allocation. This type is an unsigned integer
207 * split into major and minor parts:
208 * 1) the major-field categorizes the event and
209 * 2) the minor is a more detailed system specific description.
210 * The major-part will not change by HW, but the minor-part can be
211 * HW/SW platform specific and thus could be split into more sub-fields as
212 * needed. The application should use the access functions for reading major
213 * and minor parts.
214 *
215 * The only event type with defined content is EM_EVENT_TYPE_SW with
216 * minor type 0, which needs to be portable (direct pointer to data).
217 *
218 * @see em_event_type_major_e, em_event_type_sw_minor_e for named type constants
219 * @see em_event_type_major(), em_event_type_minor(), em_receive_func_t()
220 */
221typedef uint32_t em_event_type_t;
222
223/**
224 * Notification
225 *
226 * A notification structure allows the user to define a notification event and
227 * a destination queue with an optional event group. EM will notify the user by
228 * sending the event into the given queue.
229 *
230 * The egroup-field defines an optional event group for this notification.
231 * The used event group has to exist and be initialized. Use value
232 * EM_EVENT_GROUP_UNDEF for normal operation (API 1.0 functionality), i.e.
233 * notification is not sent to a group.
234 * egroup should not be the originating group, i.e. should not be sent
235 * back to the group.
236 *
237 * @attention API 1.0 code using notifications may need to be modified
238 * as the new field need to be initialized. Value EM_EVENT_GROUP_UNDEF
239 * is the correct value to use for non-group notification but value 0
240 * is an alias, e.g. it is safe to initialize the structure with memset(0,..).
241 */
242typedef struct {
243 em_event_t event; /**< User defined notification event */
244 em_queue_t queue; /**< Destination queue */
245 em_event_group_t egroup; /**< Event group for this event */
246} em_notif_t;
247
248#ifdef __cplusplus
249}
250#endif
251
252#pragma GCC visibility pop
253#endif /* EVENT_MACHINE_TYPES_H_ */
uint32_t em_event_type_t
#define EM_HANDLE_T(type_t)
em_event_group_t egroup