EM-ODP 4.4.0
Event Machine on ODP
Loading...
Searching...
No Matches
em_eo.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2015, 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 EM_EO_H_
32#define EM_EO_H_
33
34/**
35 * @file
36 * EM internal EO functions
37 *
38 */
39
40#include <stddef.h>
41#include <stdint.h>
42
43#include <odp_api.h>
44
45#include <event_machine.h>
46
47#include "em_eo_types.h"
49#include "em_mem.h"
50#include "em_queue_types.h"
51#include "misc/objpool.h"
52
53#ifdef __cplusplus
54extern "C" {
55#endif
56
57#define invalid_eo(eo) ((unsigned int)eo_hdl2idx((eo)) >= EM_MAX_EOS)
58
60eo_init(eo_tbl_t eo_tbl[], eo_pool_t *eo_pool);
61
62em_eo_t
63eo_alloc(void);
64
66eo_free(em_eo_t eo);
67
69eo_add_queue(eo_elem_t *const eo_elem, queue_elem_t *const q_elem);
70
72eo_rem_queue(eo_elem_t *const eo_elem, queue_elem_t *const q_elem);
73
75eo_rem_queue_all(eo_elem_t *const eo_elem);
76
78eo_delete_queue_all(eo_elem_t *const eo_elem);
79
80int eo_start_local_req(eo_elem_t *const eo_elem,
81 int num_notif, const em_notif_t notif_tbl[]);
82int eo_start_sync_local_req(eo_elem_t *const eo_elem);
83
84int eo_start_buffer_events(const em_event_t events[], int num, em_queue_t queue);
85
86void eo_start_send_buffered_events(eo_elem_t *const eo_elem);
87
88int eo_stop_local_req(eo_elem_t *const eo_elem,
89 int num_notif, const em_notif_t notif_tbl[]);
90int eo_stop_sync_local_req(eo_elem_t *const eo_elem);
91
92em_status_t eo_stop_done(eo_elem_t *const eo_elem);
93
94int eo_remove_queue_local_req(eo_elem_t *const eo_elem, queue_elem_t *const q_elem,
95 int num_notif, const em_notif_t notif_tbl[]);
96int eo_remove_queue_sync_local_req(eo_elem_t *const eo_elem,
97 queue_elem_t *const q_elem);
98int eo_remove_queue_all_local_req(eo_elem_t *const eo_elem, int delete_queues,
99 int num_notif, const em_notif_t notif_tbl[]);
100int eo_remove_queue_all_sync_local_req(eo_elem_t *const eo_elem, int delete_queues);
101
102unsigned int
103eo_count(void);
104
105size_t eo_name(const eo_elem_t *const eo_elem,
106 char name[/*out*/], const size_t maxlen);
107
108odp_stash_t eo_start_stash_create(void);
109
110static inline int
111eo_allocated(const eo_elem_t *const eo_elem)
112{
113 return !objpool_in_pool(&eo_elem->eo_pool_elem);
114}
115
116/** Convert eo handle to eo index */
117static inline int
118eo_hdl2idx(em_eo_t eo)
119{
120 return (int)(uintptr_t)eo - 1;
121}
122
123/** Convert eo index to eo handle */
124static inline em_eo_t
125eo_idx2hdl(int eo_idx)
126{
127 return (em_eo_t)(uintptr_t)(eo_idx + 1);
128}
129
130/** Returns EO element associated with EO handle */
131static inline eo_elem_t *
132eo_elem_get(em_eo_t eo)
133{
134 const int eo_idx = eo_hdl2idx(eo);
135 eo_elem_t *eo_elem;
136
137 if (unlikely((unsigned int)eo_idx > EM_MAX_EOS - 1))
138 return NULL;
139
140 eo_elem = &em_shm->eo_tbl.eo_elem[eo_idx];
141
142 return eo_elem;
143}
144
145/** Returns the EO element of the currently active EO (if any)*/
146static inline eo_elem_t *
147eo_elem_current(void)
148{
149 const queue_elem_t *const q_elem = em_locm.current.q_elem;
150
151 if (unlikely(q_elem == NULL))
152 return NULL;
153
154 return q_elem->eo_elem;
155}
156
157static inline em_eo_t
158eo_current(void)
159{
160 const queue_elem_t *const q_elem = em_locm.current.q_elem;
161
162 if (unlikely(q_elem == NULL))
163 return EM_EO_UNDEF;
164
165 return (em_eo_t)(uintptr_t)q_elem->eo;
166}
167
168/**
169 * EM internal event handler (see em_internal_event.c&h)
170 * Handle the internal event requesting a local function call.
171 */
172void
174
175/** Print information about all EOs */
176void eo_info_print_all(void);
177
178/** Print information about all queues of the given eo */
179void eo_queue_info_print(em_eo_t eo);
180
182void eo_stop_local_fn_at_term(void);
183
184#ifdef __cplusplus
185}
186#endif
187
188#endif /* EM_EO_H_ */
int eo_stop_local_req(eo_elem_t *const eo_elem, int num_notif, const em_notif_t notif_tbl[])
Definition em_eo.c:662
void i_event__eo_local_func_call_req(const internal_event_t *i_ev)
Definition em_eo.c:1241
void eo_queue_info_print(em_eo_t eo)
Definition em_eo.c:1476
void eo_info_print_all(void)
Definition em_eo.c:1403
void eo_start_local_fn_at_init(void)
Run EO local-start functions for all EOs on a new core (if configured)
Definition em_eo.c:1597
odp_stash_t eo_start_stash_create(void)
Create a stash used to buffer events sent during EO-start.
Definition em_eo.c:1548
int eo_start_buffer_events(const em_event_t events[], int num, em_queue_t queue)
Definition em_eo.c:515
int eo_start_sync_local_req(eo_elem_t *const eo_elem)
Definition em_eo.c:453
em_status_t eo_stop_done(eo_elem_t *const eo_elem)
Definition em_eo.c:685
em_status_t eo_rem_queue(eo_elem_t *const eo_elem, queue_elem_t *const q_elem)
Definition em_eo.c:297
em_status_t eo_add_queue(eo_elem_t *const eo_elem, queue_elem_t *const q_elem)
Definition em_eo.c:240
int eo_stop_sync_local_req(eo_elem_t *const eo_elem)
Definition em_eo.c:765
int eo_start_local_req(eo_elem_t *const eo_elem, int num_notif, const em_notif_t notif_tbl[])
Definition em_eo.c:393
void eo_stop_local_fn_at_term(void)
Run EO local-stop funcs for all EOs during term-core (if configured)
Definition em_eo.c:1647
void eo_start_send_buffered_events(eo_elem_t *const eo_elem)
Definition em_eo.c:575
ENV_LOCAL em_locm_t em_locm
em_shm_t * em_shm
#define EM_MAX_EOS
#define EM_EO_UNDEF
uint32_t em_status_t
queue_elem_t * q_elem
Definition em_mem.h:214
em_locm_current_t current
Definition em_mem.h:228
objpool_elem_t eo_pool_elem
Definition em_eo_types.h:96
eo_elem_t * eo_elem