EM-ODP  3.7.0
Event Machine on ODP
event_machine_event.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-2023, 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 
31 #ifndef EVENT_MACHINE_EVENT_H_
32 #define EVENT_MACHINE_EVENT_H_
33 
34 #pragma GCC visibility push(default)
35 
36 /**
37  * @file
38  * @defgroup em_event Events
39  * Operations on an event.
40  * @{
41  *
42  * All application processing is driven by events in the Event Machine. An event
43  * describes a piece of work or data to be processed. The structure of an event
44  * is implementation and event type specific: it may be a directly accessible
45  * buffer of memory, packet headers and data, a vector or user specified content
46  * etc.
47  *
48  * Applications use the event type to interpret the event structure. The event
49  * type consists of a major and a minor part: the major part specifies the
50  * actual type or structure of the event (sw buf, packet, vector etc.) while the
51  * minor part is user specific and can be used to distinguish between different
52  * use cases of the event.
53  *
54  * Events follow message passing semantics: an event has to be allocated using
55  * the provided API (em_alloc()) or received through queues by an EO callback
56  * function after which the event is owned by the application. Event ownership
57  * is transferred back to the system by using em_send() or em_free().
58  * An event not owned by the application must not be touched.
59  *
60  * The event handle, of type em_event_t, is not a direct pointer to the event
61  * structure, hence EM API functions must be used to get access to the contained
62  * data: for events of (major) type sw buffer or packet use em_event_pointer()
63  * while for vector events the contained array of event handles must be accessed
64  * with em_event_vector_tbl() instead. Use the (major part of the) event type to
65  * distinguish between vectors and other types of events.
66  *
67  * ### Event References
68  * Normally, each event is associated with one event handle (em_event_t) - each
69  * event allocation produces a new event (and associated payload data) that can
70  * be processed, sent or freed. When the user EO has allocated or received an
71  * event from a queue, the event payload data may be read and written as needed
72  * by the application.
73  * An exception to the above described scenario happens when using event
74  * references.
75  * An event reference is an additional event handle referring to an existing
76  * event. New references are created with the em_event_ref() API call. The
77  * intent of using multiple references is to avoid event copies.
78  * An event that has multiple references shares its data with the other
79  * reference handles and thus the (shared) data must not be modified.
80  * Reading event data from a reference is allowed. Writes to the event data must
81  * only be done when there is a single event handle left, i.e. when
82  * em_event_has_ref(event) returns 'false'. Results are undefined if these
83  * restrictions are not observed.
84  * The event is freed when the last reference, including the original event,
85  * is freed.
86  * It is not allowed to use event references with event groups since assigning
87  * an event that has references to an event group would assign all the
88  * references to the event group resulting in undefined behaviour. E.g. using
89  * em_send_group()/em_send_group_multi() to send a reference is wrong.
90  *
91  * ### Event User Area
92  * Additionally, an event may contain a user area separate from the event
93  * payload. The size of the event user area is set when creating the event pool
94  * from which the event is allocated. The user area is a fixed size (per pool)
95  * data area into which event related state data can be stored without having
96  * to access and change the payload. Note that the size of the event user area
97  * can be zero(0), depending on event pool configuration.
98  * Note also that the user area content is not initialized by EM, neither
99  * em_alloc() nor em_free() will touch it and thus it might contain old user
100  * data set the last time the area was used during a previous allocation of the
101  * same event. Since the user area is not part of the event payload, it will not
102  * be transmitted as part of a packet etc.
103  * A user area ID can further be used to identify the user area contents.
104  * The event user area ID is stored outside of the user area itself and is thus
105  * always available, even if the size of the user area data is set to zero(0).
106  * See em_pool_create(), em_event_uarea_get(), em_event_uarea_id_get/set() and
107  * em_event_uarea_info() for more information on the event user area and its
108  * associated ID.
109  *
110  * ### Vector Events
111  * Event (major) Type: EM_EVENT_TYPE_VECTOR
112  *
113  * Vector events contain a table of events.
114  * All events in the event-table must be of major type EM_EVENT_TYPE_PACKET.
115  * Storing events of another type into the event-table is an error and leads to
116  * undefined behaviour.
117  * Event vector pools are created with em_pool_create() with the pool event-type
118  * set to EM_EVENT_TYPE_VECTOR. Event vectors can then be allocated from vector
119  * pools by calling em_alloc(..., vector_pool).
120  * To free the vector event along with all events it contains, use em_free() or
121  * em_free_multi().
122  * To free the vector event only, not the events it contains,
123  * use em_event_vector_free().
124  */
125 
126 #ifdef __cplusplus
127 extern "C" {
128 #endif
129 
132 
133 /**
134  * Allocate an event.
135  *
136  * Allocate a new event from the given pool. The pool used must support events
137  * of the requested (major) type:
138  * - Events of (major) type EM_EVENT_TYPE_SW can be allocated from pools
139  * created to support event types EM_EVENT_TYPE_SW or EM_EVENT_TYPE_PACKET.
140  * - Events of (major) type EM_EVENT_TYPE_PACKET can be allocated from pools
141  * created to support the event type EM_EVENT_TYPE_PACKET.
142  * - Event vectors of (major) type EM_EVENT_TYPE_VECTOR can be allocated from
143  * pools created to support the event type EM_EVENT_TYPE_VECTOR.
144  *
145  * The memory address of the allocated event is system specific and can depend
146  * on the given pool, event size and type. The returned event (handle) may refer
147  * to a memory buffer, packet or vector etc., i.e. the event structure is event
148  * type specific.
149  *
150  * Use em_event_pointer(), or for vectors em_event_vector_tbl(), to convert an
151  * event (handle) to a pointer to the event payload or access the vector table.
152  * EM does not initialize the payload data.
153  *
154  * Concerning events and pools of type EM_EVENT_TYPE_SW or EM_EVENT_TYPE_PACKET:
155  * - EM_EVENT_TYPE_SW with minor type '0' is reserved for direct portability -
156  * it is always guaranteed to produce an event with contiguous payload that can
157  * directly be used by the application up to the given size (no HW specific
158  * descriptors etc. are visible). This event payload will be 64-bit aligned
159  * by default (unless explicitly configured otherwise).
160  * - EM_POOL_DEFAULT can be used as a pool handle if there's no need to use a
161  * specific event pool (up to the size- or event limits of that pool).
162  *
163  * Additionally it is guaranteed, that two separate buffers never share a cache
164  * line (to avoid false sharing).
165  *
166  * @note Vector events must always have their major event type set to
167  * EM_EVENT_TYPE_VECTOR or EM will not recognize them as vectors.
168  * Also, the event type for periodic timer ring events,
169  * EM_EVENT_TYPE_TIMER_IND, must NOT be used with em_alloc().
170  *
171  * @param size 1) Packet & sw-buf: event size in bytes (B), size > 0.
172  * 2) Vector: number of event handles that should fit into
173  * the vector table of the event, size > 0.
174  * @param type Event type to allocate. The event major-type must be
175  * supported by given 'pool'. Vector events must be
176  * allocated with major type EM_EVENT_TYPE_VECTOR from a
177  * pool created to support vectors.
178  * @param pool Event pool handle. The pool must have been created to
179  * support events of type 'em_event_type_major(type)'
180  *
181  * @return The allocated event or EM_EVENT_UNDEF on error.
182  *
183  * @see em_free(), em_send(), em_event_pointer(), em_receive_func_t,
184  * em_event_clone() etc.
185  * @see additionally for vector events: em_event_vector_tbl(),
186  * em_event_vector_free() etc.
187  */
188 em_event_t em_alloc(uint32_t size, em_event_type_t type, em_pool_t pool);
189 
190 /**
191  * Allocate multiple events.
192  *
193  * Similar to em_alloc(), but allows allocation of multiple events, with same
194  * properties, with one function call.
195  * The em_alloc_multi() API function will try to allocate the requested number
196  * ('num') of events but may fail to do so, e.g. if the pool has run out of
197  * events, and will return the actual number of events that were successfully
198  * allocated from the given pool.
199  *
200  * @note Vector events must always have their major event type set to
201  * EM_EVENT_TYPE_VECTOR or EM will not recognize them as vectors.
202  * Also, the event type for periodic timer ring events,
203  * EM_EVENT_TYPE_TIMER_IND, must NOT be used with em_alloc_multi().
204  *
205  * @param[out] events Output event array, events are allocated and filled by
206  * em_alloc_multi(). The given array must fit 'num' events.
207  * @param num Number of events to allocate and write into 'events[]'
208  * @param size 1) Packet & sw-buf: event size in bytes (B), size > 0.
209  * 2) Vector: number of event handles that should fit into
210  * the vector table of the event, size > 0.
211  * @param type Event type to allocate. The event major-type must be
212  * supported by given 'pool'. Vector events must be
213  * allocated with major type EM_EVENT_TYPE_VECTOR from a
214  * pool created to support vectors.
215  * @param pool Event pool handle. The pool must have been created to
216  * support events of type 'em_event_type_major(type)'
217  *
218  * @return Number of events actually allocated from the pool (0 ... num) and
219  * written into the output array 'events[]'.
220  *
221  * @see em_alloc() for more documentation.
222  */
223 int em_alloc_multi(em_event_t events[/*out*/], int num,
224  uint32_t size, em_event_type_t type, em_pool_t pool);
225 
226 /**
227  * Free an event.
228  *
229  * The em_free() function transfers ownership of the event back to the system
230  * and the application must not touch the event (or related memory buffers)
231  * after calling it.
232  *
233  * It is assumed that the implementation can detect the event pool that
234  * the event was originally allocated from.
235  *
236  * The application must only free events it owns. For example, the sender must
237  * not free an event after sending it.
238  *
239  * @note Freeing a vector event (of type EM_EVENT_VECTOR) with this API will
240  * also free the events contained in the vector's event-table.
241  * To free only the vector event itself, use em_event_vector_free().
242  *
243  * @param event Event to be freed
244  *
245  * @see em_alloc(), em_free_multi(), em_event_vector_free()
246  */
247 void em_free(em_event_t event);
248 
249 /**
250  * Free multiple events.
251  *
252  * Similar to em_free(), but allows freeing of multiple events with one
253  * function call. The application must not touch the given events after a call
254  * to em_free_multi().
255  *
256  * @note Freeing vector events (of type EM_EVENT_VECTOR) with this API will
257  * also free the events contained in the vectors' event-table.
258  * To free only the vector event itself, use em_event_vector_free().
259  *
260  * @param[in] events Array of events to be freed
261  * @param num The number of events in the array 'events[]'
262  */
263 void em_free_multi(em_event_t events[], int num);
264 
265 /**
266  * Send an event to a queue.
267  *
268  * The event must have been allocated with em_alloc(), or received via an EO
269  * receive-function. The sender must not touch the event after calling em_send()
270  * as the ownership has been transferred to the system or possibly to the next
271  * receiver. If the return status is *not* EM_OK, the ownership has not been
272  * transferred and the application is still responsible for the event (e.g. may
273  * free it).
274  *
275  * EM does not currently define guaranteed event delivery, i.e. EM_OK return
276  * value only means the event was accepted for delivery. It could still be lost
277  * during delivery (e.g. due to a removed queue or system congestion, etc).
278  *
279  * @param event Event to be sent
280  * @param queue Destination queue
281  *
282  * @return EM_OK if successful (accepted for delivery).
283  *
284  * @see em_alloc()
285  */
286 em_status_t em_send(em_event_t event, em_queue_t queue);
287 
288 /**
289  * Send multiple events to a queue.
290  *
291  * As em_send, but multiple events can be sent with one call for potential
292  * performance gain.
293  * The function returns the number of events actually sent. A return value equal
294  * to the given 'num' means that all events were sent. A return value less than
295  * 'num' means that only the first 'num' events were sent and the rest must be
296  * handled by the application.
297  *
298  * @param events Array of events to send
299  * @param num Number of events.
300  * The array 'events[]' must contain 'num' entries.
301  * @param queue Destination queue
302  *
303  * @return number of events successfully sent (equal to num if all successful)
304  *
305  * @see em_send()
306  */
307 int em_send_multi(const em_event_t events[], int num, em_queue_t queue);
308 
309 /**
310  * Get a pointer to the event structure/data.
311  *
312  * Returns a pointer to the beginning of the event data or NULL in case of error.
313  * The structure/content of the event data is user and/or event type specific.
314  * It may be a directly accessible buffer of memory, contain packet headers and
315  * data or have user specified content etc.
316  * Use em_event_get_type() and em_event_type_major() to determine the type
317  * of the event.
318  *
319  * @note em_event_pointer() should NOT be used with events of (major) type
320  * EM_EVENT_TYPE_VECTOR or EM_EVENT_TYPE_TIMER_IND - usage with these
321  * types of events returns NULL and an error is reported.
322  * Instead, when dealing with event vectors, use em_event_vector_tbl() to
323  * get access to the vector table.
324  * Further, periodic timer-ring timeout indication events have no user
325  * accessible payload.
326  *
327  * @param event Event handle
328  *
329  * @return Pointer to the beginning of the event data
330  * @retval NULL on unsupported event type or other error
331  *
332  * @see em_event_vector_tbl() when dealing with vector events.
333  */
334 void *em_event_pointer(em_event_t event);
335 
336 /**
337  * @brief Get a pointer to the event structure/data as well as the event size.
338  *
339  * Returns a pointer to the beginning of the event data as well as the event
340  * type specific payload size via the output arg 'size'.
341  *
342  * This API is a combination of em_event_pointer() and em_event_get_size() since
343  * both are often needed, especially in the EO-receive function where event
344  * payload manipulation naturally takes place.
345  *
346  * The structure/content of the event data is user and/or event type specific.
347  * It may be a directly accessible buffer of memory, contain packet headers and
348  * data or have user specified content etc.
349  * Use em_event_get_type() to determine the type of the event or rely on the
350  * 'type' argument provided to the EO-receive function (em_receive_func_t).
351  * Use em_event_type_major() to get the major part of the event type.
352  *
353  * @note Do not use this API function for vector events (major event type
354  * EM_EVENT_TYPE_VECTOR) or periodic timer ring timeout events
355  * (event type EM_EVENT_TYPE_TIMER_IND).
356  * Instead, for vectors use the em_event_vector_...() APIs.
357  * Timer ring timeout events have no user accessible data.
358  *
359  * @param event Event handle
360  * @param[out] size Optional output arg into which the event type specific
361  * payload size (in bytes) is stored. Use 'size=NULL' if no
362  * size information is needed. Only set by the function when
363  * no errors occurred. For events of (major) type sw buf or
364  * packet the size is the available buffer/payload size in
365  * bytes (B).
366  *
367  * @return Pointer to the beginning of the event data
368  * @retval NULL on unsupported event type or other error ('size' not touched)
369  *
370  * @see em_event_pointer(), em_event_get_size()
371  */
372 void *em_event_pointer_and_size(em_event_t event, uint32_t *size /*out*/);
373 
374 /**
375  * Returns the event payload size in bytes (B) of the given event
376  *
377  * Returns the event type specific payload size of the event. For events of
378  * (major) type sw buf or packet the size is the available buffer/payload size
379  * in bytes (B).
380  *
381  * @note Do not use this API function for vector events, instead use
382  * em_event_vector_size(), em_event_vector_max_size() or
383  * em_event_vector_info(). Use the event type to distinguish between
384  * vectors and other types of events.
385  *
386  * @param event Event handle
387  *
388  * @return Event type specific payload size in bytes.
389  */
390 uint32_t em_event_get_size(em_event_t event);
391 
392 /**
393  * @brief Returns the EM event-pool the event was allocated from.
394  *
395  * The EM event-pool for the given event can only be obtained if the event has
396  * been allocated from a pool created with em_pool_create(). For other pools,
397  * e.g. external (to EM) pktio pools, EM_POOL_UNDEF is returned.
398  *
399  * @param event Event handle
400  *
401  * @return The EM event-pool handle or EM_POOL_UNDEF if no EM pool is found.
402  * EM_POOL_UNDEF is returned also for a valid event that has been
403  * allocated from a pool external to EM (no error is reported).
404  */
405 em_pool_t em_event_get_pool(em_event_t event);
406 
407 /**
408  * @brief Returns the EM event-pool and subpool the event was allocated from.
409  *
410  * Similar to em_event_get_pool(), but also outputs the subpool the event was
411  * allocated from.
412  * The subpool is in the range [0, EM_MAX_SUBPOOLS - 1].
413  *
414  * @param event Event handle
415  * @param[out] subpool Subpool index, output arg filled on successful return.
416  * Use 'NULL' if not interested in the subpool (or prefer
417  * em_event_get_pool() instead).
418  * The subpool is filled only when a valid EM pool can be
419  * found, i.e. when the return value is other than
420  * EM_POOL_UNDEF - EM doesn't touch it otherwise.
421  *
422  * @return The EM event-pool handle or EM_POOL_UNDEF if no EM pool is found.
423  * EM_POOL_UNDEF is returned also for a valid event that has been
424  * allocated from a pool external to EM (no error is reported).
425  */
426 em_pool_t em_event_get_pool_subpool(em_event_t event, int *subpool /*out*/);
427 
428 /**
429  * Set the event type of an event
430  *
431  * The operation may fail if (the major part of) the new type is not compatible
432  * with the old one.
433  * EM does not check the compatibility of the new vs. old event type for all
434  * cases, thus the user must take care not to incorrectly update the type.
435  *
436  * @note Vector events must always have their major type set to
437  * EM_EVENT_TYPE_VECTOR or EM will not recognize them as vectors.
438  * Also, timer ring events must always have their event type set to
439  * EM_EVENT_TYPE_TIMER_IND or EM will not recognize them as periodic
440  * timer ring timeout events.
441  * Trying to set an incorrect type for these events result in error.
442  *
443  * @param event Event handle
444  * @param newtype New type for the event
445  *
446  * @return EM_OK on success
447  *
448  * @see em_alloc(), em_event_get_type/_multi(),
449  * em_event_type_major(), em_event_type_minor(),
450  * em_receive_func_t(..., em_event_type_t type, ...)
451  */
452 em_status_t em_event_set_type(em_event_t event, em_event_type_t newtype);
453 
454 /**
455  * Get the event type of an event
456  *
457  * Returns the type of the given event. The type has been set by em_alloc...(),
458  * em_event_set_type() or e.g. packet input.
459  *
460  * @param event Event handle
461  *
462  * @return event type, EM_EVENT_TYPE_UNDEF on error
463  *
464  * @see em_alloc(), em_event_set_type(),
465  * em_event_type_major(), em_event_type_minor(),
466  * em_receive_func_t(..., em_event_type_t type, ...)
467  */
468 em_event_type_t em_event_get_type(em_event_t event);
469 
470 /**
471  * Get the event types of multiple events
472  *
473  * Writes the event type of each given event into an output type-array and
474  * returns the number of entries written.
475  * Note, if 'events[num]' are all of the same type then 'types[num]' will
476  * contain 'num' same entries.
477  *
478  * @param events Event handles: events[num]
479  * @param num Number of events and output types.
480  * The array 'events[]' must contain 'num' entries and the
481  * output array 'types[]' must have room for 'num' entries.
482  * @param[out] types Event types (output array): types[num]
483  * (types[i] is the type of events[i])
484  *
485  * @return Number of event types (0...num) written into 'types[]'.
486  * The return value (always >=0) is usually 'num' and thus '<num' is
487  * only seen in error scenarios when the type of event[i] could not be
488  * obtained. The return value will be '0' in error cases or if the given
489  * 'num=0'. The function stops and returns on the first error and will
490  * not fill the rest of 'types[]'.
491  */
492 int em_event_get_type_multi(const em_event_t events[], int num,
493  em_event_type_t types[/*out:num*/]);
494 
495 /**
496  * Get the number of events that have the same event type.
497  *
498  * Returns the number of consecutive events from the start of the array
499  * 'events[]' that have the same event type. Outputs that same event type.
500  * Useful for iterating through an event-array and grouping by event type.
501  *
502  * @param events Event handles: events[num]
503  * @param num Number of events.
504  * The array 'events[]' must contain 'num' entries.
505  * @param[out] same_type Event type pointer for output
506  *
507  * @return Number of consecutive events (0...num) with the same event type
508  * (return value always >=0), includes and starts from events[0].
509  * The return value is usually '>=1' and thus '0' is only seen in
510  * error scenarios when the type of the first event could not be
511  * obtained or if the given 'num=0'.
512  * The function stops and returns on the first error.
513  */
514 int em_event_same_type_multi(const em_event_t events[], int num,
515  em_event_type_t *same_type /*out*/);
516 
517 /**
518  * Mark the event as "sent".
519  *
520  * Indicates a user-given promise to EM that the event will later appear into
521  * 'queue' by some means other than an explicit user call to em_send...().
522  * Calling em_event_mark_send() transfers event ownership away from the user,
523  * and thus the event must not be used or touched by the user anymore (the only
524  * exception is (hw) error recovery where the "sent" state can be cancelled by
525  * using em_event_unmark_send() - dangerous!).
526  *
527  * Example use case:
528  * A user provided output-callback function associated with a queue of type
529  * 'EM_QUEUE_TYPE_OUTPUT' can use this API when configuring a HW-device to
530  * deliver the event back into EM. The HW will eventually "send" the event and
531  * it will "somehow" again appear into EM for the user to process.
532  *
533  * EM will, after this API-call, treat the event as "sent" and any further API
534  * operations or usage might lead to EM errors (depending on the error-check
535  * level), e.g. em_send/free/tmo_set/ack(event) etc. is forbidden after
536  * em_event_mark_send(event).
537  *
538  * @note Registered API-callback hooks for em_send...() (em_api_hook_send_t)
539  * will NOT be called.
540  * @note Marking an event "sent" with an event group (corresponding to
541  * em_send_group()) is currently NOT supported.
542  *
543  * @param event Event to be marked as "sent"
544  * @param queue Destination queue (must be scheduled, i.e. atomic,
545  * parallel or parallel-ordered)
546  *
547  * @return EM_OK if successful
548  *
549  * @see em_send(), em_event_unmark_send()
550  */
551 em_status_t em_event_mark_send(em_event_t event, em_queue_t queue);
552 
553 /**
554  * Unmark an event previously marked as "sent" (i.e mark as "unsent")
555  *
556  * @note This is for recovery situations only and can potentially crash the
557  * application if used incorrectly!
558  *
559  * Revert an event's "sent" state, as set by em_event_mark_send(), back to the
560  * state before the mark-send function call.
561  * Any further usage of the event after em_event_mark_send(), by EM or
562  * the user, will result in error when calling em_event_unmark_send() since the
563  * state has become unrecoverable.
564  * => the only allowed EM API call after em_event_mark_send() is
565  * em_event_unmark_send() if it is certain that the event, due to some
566  * external error, will never be sent into EM again otherwise.
567  * Calling em_event_unmark_send() transfers event ownership back to the user
568  * again.
569  *
570  * @note Unmark-send and unmark-free are the only valid cases of using an event
571  * that the user no longer owns - all other such uses leads to fatal error
572  *
573  * @code
574  * em_status_t err;
575  * hw_err_t hw_err;
576  *
577  * // 'event' owned by the user
578  * err = em_event_mark_send(event, queue);
579  * if (err != EM_OK)
580  * return err; // NOK
581  * // 'event' no longer owned by the user - don't touch!
582  *
583  * hw_err = config_hw_to_send_event(...hw-cfg..., event, queue);
584  * if (hw_err) {
585  * // hw config error - the event can be recovered if it is
586  * // certain that the hw won't send that same event.
587  * // note: the user doesn't own the event here and actually
588  * // uses an obsolete event handle to recover the event.
589  * err = em_event_unmark_send(event);
590  * if (err != EM_OK)
591  * return err; // NOK
592  * // 'event' recovered, again owned by the user
593  * em_free(event);
594  * }
595  * @endcode
596  *
597  * @param event Event previously marked as "sent" with em_event_mark_send(),
598  * any other case will be invalid!
599  *
600  * @return EM_OK if successful
601  *
602  * @see em_send(), em_event_mark_send()
603  */
604 em_status_t em_event_unmark_send(em_event_t event);
605 
606 /**
607  * @brief Mark the event as "free".
608  *
609  * Indicates a user-given promise to EM that the event will be freed back into
610  * the pool it was allocated from e.g. by HW or device drivers (external to EM).
611  * Calling em_event_mark_free() transfers event ownership away from the user,
612  * and thus the event must not be used or touched by the user anymore.
613  *
614  * Example use case:
615  * A user provided output-callback function associated with a queue of type
616  * 'EM_QUEUE_TYPE_OUTPUT' can use this API when configuring a HW-device or
617  * device-driver to free the event (outside of EM) after transmission.
618  *
619  * EM will, after this API-call, treat the event as "freed" and any further API
620  * operations or usage might lead to EM errors (depending on the error-check
621  * level), e.g. em_send/free/tmo_set/ack(event) etc. is forbidden after
622  * em_event_mark_free(event).
623  *
624  * @note Registered API-callback hooks for em_free/_multi() (em_api_hook_free_t)
625  * will NOT be called.
626  *
627  * @param event Event to be marked as "free"
628  *
629  * @see em_free(), em_event_unmark_free()
630  */
631 void em_event_mark_free(em_event_t event);
632 
633 /**
634  * @brief Unmark an event previously marked as "free"
635  * (i.e mark as "allocated" again).
636  *
637  * @note This is for recovery situations only and can potentially crash the
638  * application if used incorrectly! Unmarking the free-state of an event
639  * that has already been freed will lead to fatal error.
640  *
641  * Revert an event's "free" state, as set by em_event_mark_free(), back to the
642  * state before the mark-free function call.
643  * Any further usage of the event after em_event_mark_free(), by EM or the user,
644  * will result in error when calling em_event_unmark_free() since the state has
645  * become unrecoverable.
646  * => the only allowed EM API call after em_event_mark_free() (for a certain
647  * event) is em_event_unmark_free() when it is certain that the event, due to
648  * some external error, will not be freed otherwise and must be recovered
649  * back into the EM-domain so that calling em_free() by the user is possible.
650  * Calling em_event_unmark_free() transfers event ownership back to the user
651  * again.
652  *
653  * @note Unmark-send and unmark-free are the only valid cases of using an event
654  * that the user no longer owns - all other such uses leads to fatal error
655  *
656  * @code
657  * em_status_t err;
658  * hw_err_t hw_err;
659  *
660  * // 'event' owned by the user
661  * em_event_mark_free(event);
662  * // 'event' no longer owned by the user - don't touch!
663  *
664  * hw_err = config_hw_to_transmit_event(...hw-cfg..., event);
665  * if (hw_err) {
666  * // hw config error - the event can be recovered if it is
667  * // certain that the hw won't free that same event.
668  * // note: the user doesn't own the event here and actually
669  * // uses an obsolete event handle to recover the event.
670  * em_event_unmark_free(event);
671  * // 'event' recovered, again owned by the user
672  * em_free(event);
673  * }
674  * @endcode
675  *
676  * @param event Event previously marked as "free" with
677  * em_event_mark_free/_multi(), any other usecase is invalid!
678  *
679  * @see em_free(), em_event_mark_free()
680  */
681 void em_event_unmark_free(em_event_t event);
682 
683 /**
684  * @brief Mark multiple events as "free".
685  *
686  * Similar to em_event_mark_free(), but allows the marking of multiple events
687  * as "free" with one function call.
688  *
689  * @note Registered API-callback hooks for em_free/_multi() (em_api_hook_free_t)
690  * will NOT be called.
691  *
692  * @param[in] events Array of events to be marked as "free"
693  * @param num The number of events in the array 'events[]'
694  */
695 void em_event_mark_free_multi(const em_event_t events[], int num);
696 
697 /**
698  * @brief Unmark multiple events previously marked as "free".
699  *
700  * @note This is for recovery situations only and can potentially crash the
701  * application if used incorrectly!
702  *
703  * Similar to em_event_unmark_free(), but allows to do the "free"-unmarking of
704  * multiple events with one function call.
705  *
706  * @param[in] events Events previously marked as "free" with
707  * em_event_mark_free/_multi(), any other usecase is invalid!
708  * @param num The number of events in the array 'events[]'
709  */
710 void em_event_unmark_free_multi(const em_event_t events[], int num);
711 
712 /**
713  * @brief Clone an event.
714  *
715  * Allocate a new event with identical payload to the given event.
716  *
717  * If present, the event user area is also cloned. Note that if a 'pool' is
718  * given and it has been configured to provide a smaller user area for events
719  * than the pool the original event was allocated from, then the clone operation
720  * will fail, returning EM_EVENT_UNDEF. Thus make sure to use compatible pools
721  * for cloning. Using the same pool ('pool' == EM_POOL_UNDEF) will always be
722  * compatible with respect of the user area sizing.
723  *
724  * @note Other event metadata, internal headers and state are _NOT_ cloned
725  * (e.g. the event-group of a cloned event is EM_EVENT_GROUP_UNDEF etc).
726  *
727  * @param event Event to be cloned, must be a valid event.
728  * @param pool Optional event pool to allocate the cloned event from.
729  * Use 'EM_POOL_UNDEF' to clone from the same pool as 'event'
730  * was allocated from.
731  * The event-type of 'event' must be suitable for allocation
732  * from 'pool' (e.g. EM_EVENT_TYPE_PACKET can not be
733  * allocated from a pool supporting only EM_EVENT_TYPE_SW)
734  * The user area size of events from 'pool' must be large
735  * enough to fit the cloned user area.
736  *
737  * @return The cloned event or EM_EVENT_UNDEF on error.
738  *
739  * @see em_alloc(), em_free()
740  */
741 em_event_t em_event_clone(em_event_t event, em_pool_t pool/*or EM_POOL_UNDEF*/);
742 
743 /**
744  * @brief Partially clone an event
745  *
746  * Allocate a new event (of size 'len') and copy 'len' bytes of data starting
747  * from 'offset' from the given event into the new event.
748  * The maximum number of bytes to copy is event-size minus the offset.
749  *
750  * If present, and 'clone_uarea = true', the event user area is also cloned.
751  * Note that if a 'pool' is given and it has been configured to provide a
752  * smaller user area for events than the pool the original event was allocated
753  * from, then the clone operation will fail, returning EM_EVENT_UNDEF.
754  * Thus make sure to use compatible pools for cloning.
755  * Using the same pool ('pool' == EM_POOL_UNDEF) will always be compatible with
756  * respect of the user area sizing.
757  *
758  * @note Other event metadata, internal headers and state are _NOT_ cloned
759  * (e.g. the event-group of a cloned event is EM_EVENT_GROUP_UNDEF etc).
760  *
761  * @param event Event to be cloned, must be a valid event.
762  * @param pool Optional event pool to allocate the partially cloned event from.
763  * Use 'EM_POOL_UNDEF' to clone from the same pool as 'event'
764  * was allocated from.
765  * The event-type of 'event' must be suitable for allocation
766  * from 'pool' (e.g. EM_EVENT_TYPE_PACKET can not be
767  * allocated from a pool supporting only EM_EVENT_TYPE_SW).
768  * The user area size of events from 'pool' must be large
769  * enough to fit the cloned user area (if 'clone_uarea = true').
770  * @param offset Byte offset into the event payload
771  * @param len Number of bytes to copy/clone.
772  * @param clone_uarea Set 'true' to also clone the event user area (true/false).
773  *
774  * @return The partially cloned event or EM_EVENT_UNDEF on error.
775  *
776  * @see em_alloc(), em_free()
777  */
778 em_event_t em_event_clone_part(em_event_t event, em_pool_t pool/*or EM_POOL_UNDEF*/,
779  uint32_t offset, uint32_t len, bool clone_uarea);
780 /*
781  * Event User Area
782  */
783 
784 /**
785  * @brief Get a pointer to the event user area, optionally along with its size.
786  *
787  * The event user area is a fixed sized area located within the event metadata
788  * (i.e. outside of the event payload) that can be used to store application
789  * specific event related data without the need to adjust the payload.
790  * The event user area is configured during EM event pool creation and thus the
791  * size of the user area is set per pool.
792  *
793  * Note that the user area content is not initialized by EM, neither em_alloc()
794  * nor em_free() will touch it and thus it might contain old user data set the
795  * last time the area was used during a previous allocation of the same event.
796  * Since the user area is not part of the event payload, it will not be
797  * transmitted as part of a packet etc.
798  *
799  * @param event Event handle to get the user area of
800  * @param[out] size Optional output arg into which the user area size is
801  * stored. Use 'size=NULL' if no size information is needed.
802  *
803  * @return a pointer to the event user area
804  * @retval NULL on error or if the event contains no user area
805  *
806  * @see em_pool_create() for pool specific configuration and
807  * the EM runtime config file em-odp.conf for the default value:
808  * 'pool.user_area_size'.
809  * @see em_event_uarea_info() if both user area ptr and ID is needed
810  */
811 void *em_event_uarea_get(em_event_t event, size_t *size/*out*/);
812 
813 /**
814  * @brief Get the event user area ID along with information if it has been set
815  *
816  * The event user area can be associated with an optional ID that e.g. can be
817  * used to identify the contents of the actual user area data. The ID is stored
818  * outside of the actual user area data and is available for use even if the
819  * user area size has been set to zero(0) for the pool the event was allocated
820  * from.
821  *
822  * This function is used to determine whether the user area ID has been set
823  * earlier and to retrieve the ID in the case it has been set.
824  * EM will initialize 'ID isset = false' when allocating a new event (indicating
825  * that the ID is not set). Use em_event_uarea_id_set() to set the ID.
826  *
827  * @param event Event handle to get the user area ID and "set"-status of
828  * @param[out] isset Optional output arg: has the ID been set previously?
829  * At least one of 'isset' and 'id' must be given (or both).
830  * @param[out] id Optional output arg into which the user area ID is
831  * stored if it has been set before. The output arg 'isset'
832  * should be used to determine whether 'id' has been set.
833  * Note: 'id' will not be touched if the ID has not been set
834  * earlier (i.e. when 'isset' is 'false').
835  * At least one of 'isset' and 'id' must be given (or both).
836  *
837  * @return EM_OK if successful
838  *
839  * @see em_event_uarea_id_set(), em_event_uarea_get()
840  * @see em_event_uarea_info() if both user area ptr and ID is needed
841  */
842 em_status_t em_event_uarea_id_get(em_event_t event, bool *isset /*out*/,
843  uint16_t *id /*out*/);
844 
845 /**
846  * @brief Set the event user area ID
847  *
848  * The event user area can be associated with an optional ID that e.g. can be
849  * used to identify the contents of the actual user area data. The ID is stored
850  * outside of the actual user area data and is available for use even if the
851  * user area size has been set to 0 for the pool the event was allocated from.
852  *
853  * This function is used to set the event user area ID for the given event.
854  * The 'set' operation overwrites any ID stored earlier.
855  * Use em_event_uarea_id_get() to check whether an ID has been set earlier and
856  * to retrieve the ID.
857  *
858  * @param event Event handle for which to set the user area ID
859  * @param id The user area ID to set
860  *
861  * @return EM_OK if successful
862  *
863  * @see em_event_uarea_id_get(), em_event_uarea_get(), em_event_uarea_info()
864  */
865 em_status_t em_event_uarea_id_set(em_event_t event, uint16_t id);
866 
867 /**
868  * @brief Event user area information filled by em_event_uarea_info()
869  *
870  * Output structure for obtaining information about an event's user area.
871  * Information related to the user area will be filled into this struct by
872  * the em_event_uarea_info() API function.
873  *
874  * A user area is only present if the EM pool the event was allocated from
875  * was created with user area size > 0, see em_pool_cfg_t and em_pool_create().
876  * The user area ID can always be used (set/get), even when the size of the
877  * user area is zero(0).
878  *
879  * @see em_event_uarea_info(), em_event_uarea_id_set()
880  */
881 typedef struct {
882  /** Pointer to the event user area, NULL if event has no user area */
883  void *uarea;
884  /** Size of the event user area, zero(0) if event has no user area */
885  size_t size;
886 
887  /** Event user area ID (ID can be set/get even when no uarea present) */
888  struct {
889  /** Boolean: has the ID been set previously? true/false */
890  bool isset;
891  /** Value of the user area ID, if (and only if) set before.
892  * Only inspect '.id.value' when '.id.isset=true' indicating
893  * that ID has been set earlier by em_event_uarea_id_set().
894  */
895  uint16_t value;
896  } id;
898 
899 /**
900  * @brief Get the event user area information for a given event.
901  *
902  * Obtain information about the event user area for a certain given event.
903  * Information containing the user area pointer, size, as well as the ID is
904  * output via the 'uarea_info' struct.
905  * This API function combines the functionality of em_event_uarea_get() and
906  * em_event_uarea_id_get() for use cases where both the user area pointer as
907  * well as the ID is needed. Calling one API function instead of two might be
908  * faster due to a fewer checks and internal conversions.
909  *
910  * The event user area is a fixed sized area located within the event metadata
911  * (i.e. outside of the event payload) that can be used to store application
912  * specific event related data without the need to adjust the payload.
913  * The event user area is configured during EM event pool creation and thus the
914  * size of the user area is set per pool.
915  *
916  * Note that the user area content is not initialized by EM, neither em_alloc()
917  * nor em_free() will touch it and thus it might contain old user data set the
918  * last time the area was used during a previous allocation of the same event.
919  * Since the user area is not part of the event payload, it will not be
920  * transmitted as part of a packet etc.
921  *
922  * The event user area can be associated with an optional ID that can be used to
923  * identify the contents of the actual user area data. The ID is stored
924  * outside of the actual user area data and is available for use even if the
925  * user area size has been set to zero(0) for the pool the event was allocated
926  * from. EM will initialize 'uarea_info.id.isset = false' when allocating
927  * a new event (indicating that the ID is not set).
928  *
929  * @param event Event handle to get the user area information of.
930  * @param[out] uarea_info Output struct into which the user area information
931  * is stored.
932  *
933  * @return EM status code incidating success or failure of the operation.
934  * @retval EM_OK Operation successful.
935  * @retval Other Operation FAILED and no valid user area info could
936  * be obtained, 'uarea_info' is all NULL/zero(0) in this case.
937  *
938  * @see em_pool_create() for pool specific configuration and
939  * the EM runtime config file em-odp.conf for the default value:
940  * 'pool.user_area_size'.
941  * @see em_event_uarea_get(), em_event_uarea_id_get()
942  */
943 em_status_t em_event_uarea_info(em_event_t event,
944  em_event_uarea_info_t *uarea_info /*out*/);
945 /*
946  * Event References
947  */
948 
949 /**
950  * Create a reference to an event
951  *
952  * A reference is an additional event handle referring to an existing event.
953  * As long as an event has multiple references, none of them (including 'event')
954  * should be used to modify the event. Reading event data from a reference is
955  * allowed. Writes to the event data must only be done when there is a
956  * single event handle left, i.e. when em_event_has_ref(event) returns 'false'.
957  * Results are undefined if these restrictions are not observed.
958  *
959  * The event is freed when the last reference, including the original event,
960  * is freed.
961  *
962  * Currently only references to events of (major) type EM_EVENT_TYPE_PACKET can
963  * be created.
964  *
965  * It is not allowed to use event references with event groups since assigning
966  * an event that has references to an event group would assign all the
967  * references to the event group resulting in undefined behaviour. E.g. using
968  * em_send_group()/em_send_group_multi() to send a reference is wrong.
969  *
970  * @param event Event handle for which a reference is to be created.
971  *
972  * @return Reference to the event
973  * @retval EM_EVENT_UNDEF on failure
974  */
975 em_event_t em_event_ref(em_event_t event);
976 
977 /**
978  * Test if an event has references
979  *
980  * An event that has multiple references share data with other events and thus
981  * the (shared) data must not be modified.
982  *
983  * New references are created with the em_event_ref() API call. The intent of
984  * multiple references is to avoid event copies. When a reference is created,
985  * this function returns 'true' for both events (i.e. for the original event and
986  * the new reference).
987  *
988  * @param event Event handle
989  *
990  * @retval false This event has no references
991  * @retval true The event has multiple references
992  */
993 bool em_event_has_ref(em_event_t event);
994 
995 /*
996  * Event Vectors
997  */
998 
999 /**
1000  * @brief Free the vector event only, not the events it contains.
1001  *
1002  * Frees only the vector event itself and not the events it contains in its
1003  * vector-table.
1004  * To free the vector event along with all events it contains,
1005  * use em_free() or em_free_multi().
1006  *
1007  * @param vector_event Vector event handle
1008  */
1009 void em_event_vector_free(em_event_t vector_event);
1010 
1011 /**
1012  * @brief Get the event vector table from an event of (major) type
1013  * EM_EVENT_TYPE_VECTOR.
1014  *
1015  * The event vector table is an array of event handles (em_event_t) stored in
1016  * a contiguous memory location for events with major event type set to
1017  * EM_EVENT_TYPE_VECTOR.
1018  * Upon completion of this API, this function returns the event table pointer of
1019  * the given vector event via the output argument 'event_tbl'.
1020  *
1021  * All events in the event-table must be of major type EM_EVENT_TYPE_PACKET.
1022  * Storing events of another type into the event-table is an error and leads to
1023  * undefined behaviour.
1024  *
1025  * @param vector_event Vector event handle
1026  * @param[out] event_tbl Pointer into which the event table (ptr) is written
1027  *
1028  * @return Number of event handles available (set) in the vector event.
1029  *
1030  * @note A newly allocated vector has an empty event-table and thus the returned
1031  * size is zero until updated with em_event_vector_size_set().
1032  *
1033  * @code
1034  * em_event_type_t event_type = em_event_get_type(vector_event);
1035  *
1036  * if (em_event_type_major(event_type) == EM_EVENT_TYPE_VECTOR) {
1037  * em_event_t *event_tbl;
1038  * uint32_t num = em_event_vector_tbl(vector_event, &event_tbl);
1039  *
1040  * if (!num)
1041  * return;
1042  *
1043  * for (uint32_t i = 0; i < num; i++) {
1044  * event = event_tbl[i];
1045  * ... process 'event' ...
1046  * }
1047  * }
1048  * @endcode
1049  *
1050  * @see em_event_vector_size_set()
1051  */
1052 uint32_t em_event_vector_tbl(em_event_t vector_event, em_event_t **event_tbl/*out*/);
1053 
1054 /**
1055  * @brief Number of event handles available (set) in a vector.
1056  *
1057  * Returns the number of available events in the vector.
1058  * Note that the returned 'size' indicates how many valid events are stored in
1059  * the vector's event-table.
1060  * The 'size' neither indicates the alloc-size (size given to em_alloc()) nor
1061  * the max-size of the event-table, use em_event_vector_max_size/info() to
1062  * obtain that information.
1063  *
1064  * All events in the event-table must be of major type EM_EVENT_TYPE_PACKET.
1065  * Storing events of another type into the event-table is an error and leads to
1066  * undefined behaviour.
1067  *
1068  * @param vector_event Vector event handle
1069  *
1070  * @return The number of event handles available (set) in the vector
1071  *
1072  * @note A newly allocated vector has an empty event-table and thus the returned
1073  * size is zero until updated with em_event_vector_size_set()
1074  */
1075 uint32_t em_event_vector_size(em_event_t vector_event);
1076 
1077 /**
1078  * @brief Set the number of event handles stored in a vector
1079  *
1080  * Update the number of event handles stored in a vector.
1081  * This function shall be used to set the number of events available in the
1082  * given vector when the application itself is producing (or updating) the
1083  * event vector. Only valid event handles can be stored into the vector's
1084  * event-table. The events must be stored into the vector before setting the
1085  * size, i.e. first add/remove events to/from the vector's event-table (within
1086  * max-size limits) and only after that set the size.
1087  *
1088  * All events in the event-table must be of major type EM_EVENT_TYPE_PACKET.
1089  * Storing events of another type into the event-table is an error and leads to
1090  * undefined behaviour.
1091  *
1092  * @param vector_event Vector event handle
1093  * @param size Number of event handles in the vector
1094  *
1095  * @note The maximum number of event handles the vector can hold is defined by
1096  * em_pool_cfg_t::subpool[i].size or can be obtained for a specific vector
1097  * with em_event_vector_max_size(vector_event).
1098  *
1099  * @note All handles in the vector table (0 ... size - 1) need to be valid
1100  * event handles.
1101  */
1102 void em_event_vector_size_set(em_event_t vector_event, uint32_t size);
1103 
1104 /**
1105  * @brief Maximum number of event handles that can be stored in a vector.
1106  *
1107  * Returns the maximum number of events that can be stored into the event-table
1108  * of the given vector event, i.e. the max-size that can be used with
1109  * em_event_vector_size_set().
1110  * The max-size might be larger than the size requested during allocation and
1111  * instead reflects the vector-size used when creating the EM event vector pool.
1112  *
1113  * All events in the event-table must be of major type EM_EVENT_TYPE_PACKET.
1114  * Storing events of another type into the event-table is an error and leads to
1115  * undefined behaviour.
1116  *
1117  * @param vector_event Vector event handle
1118  *
1119  * @return The maximum number of event handles that can be stored in the vector
1120  * @retval >0 on success
1121  * @retval 0 on failure or if EM can't retrieve the max size (non-EM pool).
1122  */
1123 uint32_t em_event_vector_max_size(em_event_t vector_event);
1124 
1125 /**
1126  * @brief Vector event information filled by em_event_vector_info()
1127  *
1128  * Output structure for obtaining information about a vector event.
1129  * Information related to the vector event will be filled into this struct by
1130  * the em_event_vector_info() API function.
1131  */
1132 typedef struct {
1133  /** Pointer to the vector's event-table */
1134  em_event_t *event_tbl;
1135  /** Number of available/set valid events in the vectors event-table */
1136  uint32_t size;
1137  /**
1138  * Max number of events that can fit into the vector's event-table,
1139  * 0 on failure or if EM can't retrieve the max size (non-EM pool).
1140  */
1141  uint32_t max_size;
1143 
1144 /**
1145  * @brief Retrieve information about the given vector event.
1146  *
1147  * Vector event information is output via the struct 'vector_info'.
1148  * Combines the APIs em_event_vector_tbl(), em_event_vector_size() and
1149  * em_event_vector_max_size() into one API call.
1150  *
1151  * All events in the event-table must be of major type EM_EVENT_TYPE_PACKET.
1152  * Storing events of another type into the event-table is an error and leads to
1153  * undefined behaviour.
1154  *
1155  * @param vector_event Vector event handle to get the information of.
1156  * @param[out] vector_info Output struct into which the vector information
1157  * is stored.
1158  *
1159  * @return EM status code incidating success or failure of the operation.
1160  * @retval EM_OK Operation successful.
1161  * @retval Other Operation FAILED and no valid vector info could
1162  * be obtained, 'vector_info' is all NULL/zero(0) in this case.
1163  */
1164 em_status_t em_event_vector_info(em_event_t vector_event,
1165  em_event_vector_info_t *vector_info /*out*/);
1166 
1167 /**
1168  * Convert an event handle to an unsigned integer
1169  *
1170  * @param event Event handle to be converted
1171  * @return uint64_t value that can be used to print/display the handle
1172  *
1173  * @note This routine is intended to be used for diagnostic purposes
1174  * to enable applications to e.g. generate a printable value that represents
1175  * an em_event_t handle.
1176  */
1177 uint64_t em_event_to_u64(em_event_t event);
1178 
1179 /**
1180  * @}
1181  */
1182 #ifdef __cplusplus
1183 }
1184 #endif
1185 
1186 #pragma GCC visibility pop
1187 #endif /* EVENT_MACHINE_EVENT_H_ */
em_event_mark_send
em_status_t em_event_mark_send(em_event_t event, em_queue_t queue)
Definition: event_machine_event.c:1068
em_event_uarea_info_t::size
size_t size
Definition: event_machine_event.h:885
em_event_vector_info_t::event_tbl
em_event_t * event_tbl
Definition: event_machine_event.h:1134
em_alloc_multi
int em_alloc_multi(em_event_t events[], int num, uint32_t size, em_event_type_t type, em_pool_t pool)
Definition: event_machine_event.c:92
em_event_clone
em_event_t em_event_clone(em_event_t event, em_pool_t pool)
Clone an event.
Definition: event_machine_event.c:1454
em_event_uarea_info_t::value
uint16_t value
Definition: event_machine_event.h:895
em_event_uarea_id_set
em_status_t em_event_uarea_id_set(em_event_t event, uint16_t id)
Set the event user area ID.
Definition: event_machine_event.c:1568
em_event_vector_info
em_status_t em_event_vector_info(em_event_t vector_event, em_event_vector_info_t *vector_info)
Retrieve information about the given vector event.
Definition: event_machine_event.c:1856
em_event_vector_info_t
Vector event information filled by em_event_vector_info()
Definition: event_machine_event.h:1132
em_free
void em_free(em_event_t event)
Definition: event_machine_event.c:261
em_event_mark_free_multi
void em_event_mark_free_multi(const em_event_t events[], int num)
Mark multiple events as "free".
Definition: event_machine_event.c:1181
em_send
em_status_t em_send(em_event_t event, em_queue_t queue)
Definition: event_machine_event.c:661
em_event_uarea_get
void * em_event_uarea_get(em_event_t event, size_t *size)
Get a pointer to the event user area, optionally along with its size.
Definition: event_machine_event.c:1531
em_event_unmark_free_multi
void em_event_unmark_free_multi(const em_event_t events[], int num)
Unmark multiple events previously marked as "free".
Definition: event_machine_event.c:1225
em_event_uarea_info_t
Event user area information filled by em_event_uarea_info()
Definition: event_machine_event.h:881
em_event_vector_free
void em_event_vector_free(em_event_t vector_event)
Free the vector event only, not the events it contains.
Definition: event_machine_event.c:1746
em_event_unmark_free
void em_event_unmark_free(em_event_t event)
Unmark an event previously marked as "free" (i.e mark as "allocated" again).
Definition: event_machine_event.c:1157
em_event_uarea_id_get
em_status_t em_event_uarea_id_get(em_event_t event, bool *isset, uint16_t *id)
Get the event user area ID along with information if it has been set.
Definition: event_machine_event.c:1590
em_event_clone_part
em_event_t em_event_clone_part(em_event_t event, em_pool_t pool, uint32_t offset, uint32_t len, bool clone_uarea)
Partially clone an event.
Definition: event_machine_event.c:1459
em_event_uarea_info_t::uarea
void * uarea
Definition: event_machine_event.h:883
em_event_uarea_info_t::isset
bool isset
Definition: event_machine_event.h:890
em_event_get_pool_subpool
em_pool_t em_event_get_pool_subpool(em_event_t event, int *subpool)
Returns the EM event-pool and subpool the event was allocated from.
Definition: event_machine_event.c:899
em_event_vector_max_size
uint32_t em_event_vector_max_size(em_event_t vector_event)
Maximum number of event handles that can be stored in a vector.
Definition: event_machine_event.c:1834
em_event_get_type
em_event_type_t em_event_get_type(em_event_t event)
Definition: event_machine_event.c:968
em_event_vector_size_set
void em_event_vector_size_set(em_event_t vector_event, uint32_t size)
Set the number of event handles stored in a vector.
Definition: event_machine_event.c:1815
em_alloc
em_event_t em_alloc(uint32_t size, em_event_type_t type, em_pool_t pool)
Definition: event_machine_event.c:33
em_event_pointer_and_size
void * em_event_pointer_and_size(em_event_t event, uint32_t *size)
Get a pointer to the event structure/data as well as the event size.
Definition: event_machine_event.c:767
em_status_t
uint32_t em_status_t
Definition: event_machine_types.h:321
em_event_vector_tbl
uint32_t em_event_vector_tbl(em_event_t vector_event, em_event_t **event_tbl)
Get the event vector table from an event of (major) type EM_EVENT_TYPE_VECTOR.
Definition: event_machine_event.c:1776
em_event_vector_size
uint32_t em_event_vector_size(em_event_t vector_event)
Number of event handles available (set) in a vector.
Definition: event_machine_event.c:1796
event_machine_hw_types.h
em_event_type_t
uint32_t em_event_type_t
Definition: event_machine_types.h:85
em_event_get_size
uint32_t em_event_get_size(em_event_t event)
Definition: event_machine_event.c:818
em_event_unmark_send
em_status_t em_event_unmark_send(em_event_t event)
Definition: event_machine_event.c:1110
em_event_to_u64
uint64_t em_event_to_u64(em_event_t event)
Definition: event_machine_event.c:1896
em_event_mark_free
void em_event_mark_free(em_event_t event)
Mark the event as "free".
Definition: event_machine_event.c:1132
em_event_same_type_multi
int em_event_same_type_multi(const em_event_t events[], int num, em_event_type_t *same_type)
Definition: event_machine_event.c:1028
em_event_get_type_multi
int em_event_get_type_multi(const em_event_t events[], int num, em_event_type_t types[])
Definition: event_machine_event.c:989
em_event_ref
em_event_t em_event_ref(em_event_t event)
Definition: event_machine_event.c:1681
em_event_has_ref
bool em_event_has_ref(em_event_t event)
Definition: event_machine_event.c:1734
em_event_set_type
em_status_t em_event_set_type(em_event_t event, em_event_type_t newtype)
Definition: event_machine_event.c:923
em_event_vector_info_t::max_size
uint32_t max_size
Definition: event_machine_event.h:1141
event_machine_types.h
em_free_multi
void em_free_multi(em_event_t events[], int num)
Definition: event_machine_event.c:370
em_send_multi
int em_send_multi(const em_event_t events[], int num, em_queue_t queue)
Definition: event_machine_event.c:710
em_event_get_pool
em_pool_t em_event_get_pool(em_event_t event)
Returns the EM event-pool the event was allocated from.
Definition: event_machine_event.c:876
em_event_pointer
void * em_event_pointer(em_event_t event)
Definition: event_machine_event.c:750
em_event_vector_info_t::size
uint32_t size
Definition: event_machine_event.h:1136
em_event_uarea_info
em_status_t em_event_uarea_info(em_event_t event, em_event_uarea_info_t *uarea_info)
Get the event user area information for a given event.
Definition: event_machine_event.c:1628