EM-ODP 4.4.0
Event Machine on ODP
Loading...
Searching...
No Matches
em_queue_group.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/**
32 * @file
33 *
34 * EM internal queue group functions
35 *
36 */
37
38#ifndef EM_QUEUE_GROUP_H_
39#define EM_QUEUE_GROUP_H_
40
41#include <stdbool.h>
42#include <stddef.h>
43#include <stdint.h>
44#include <stdio.h>
45
46#include <event_machine.h>
47
49#include "em_mem.h"
51#include "em_queue_types.h"
52#include "misc/objpool.h"
53
54#ifdef __cplusplus
55extern "C" {
56#endif
57
58#define invalid_qgrp(queue_group) \
59 ((unsigned int)qgrp_hdl2idx((queue_group)) >= EM_MAX_QUEUE_GROUPS)
60
62 queue_group_pool_t *const queue_group_pool);
63em_status_t queue_group_init_local(void);
64em_status_t queue_group_term(void);
65void queue_group_join_all(void);
66void queue_group_leave_all(bool flush_orphan_qgrps);
67
68em_queue_group_t
69queue_group_create(const char *name, const em_core_mask_t *mask,
70 int num_notif, const em_notif_t notif_tbl[],
71 em_queue_group_t queue_group);
72em_queue_group_t
73queue_group_create_sync(const char *name, const em_core_mask_t *mask,
74 em_queue_group_t requested_queue_group);
75
78 const em_core_mask_t *new_mask,
79 int num_notif, const em_notif_t notif_tbl[],
80 bool is_delete);
83 const em_core_mask_t *new_mask, bool is_delete);
84
85void queue_group_add_queue_list(queue_group_elem_t *const queue_group_elem,
86 queue_elem_t *const queue_elem);
87void queue_group_rem_queue_list(queue_group_elem_t *const queue_group_elem,
88 queue_elem_t *const queue_elem);
89unsigned int queue_group_count(void);
90
91/**
92 * @brief Check that only running EM cores are set in mask
93 *
94 * @param mask Queue group core mask
95 * @return EM_OK if mask is valid
96 */
98
99/**
100 * @brief Print EM queue group info
101 */
103
104/**
105 * @brief Print info about all queues belonging to the given queue group
106 */
107void queue_group_queues_print(em_queue_group_t qgrp);
108
109/**
110 * @brief EM internal event handler, add core to an EM queue group.
111 * (see em_internal_event.c&h)
112 *
113 * Handle the internal event requesting to add the core to an
114 * ODP schedule group that is related to an EM queue group.
115 */
117
118/**
119 * @brief EM internal event handler, remove core from an EM queue group.
120 * (see em_internal_event.c&h)
121 *
122 * Handle the internal event requesting to remove the core from an
123 * ODP schedule group that is related to an EM queue group.
124 */
126
127/**
128 * Convert queue group handle <-> index
129 */
130static inline int
131qgrp_hdl2idx(const em_queue_group_t queue_group)
132{
133 return (int)((uintptr_t)queue_group - 1);
134}
135
136/**
137 * Convert queue group index <-> handle
138 */
139static inline em_queue_group_t
140qgrp_idx2hdl(const int queue_group_idx)
141{
142 return (em_queue_group_t)(uintptr_t)(queue_group_idx + 1);
143}
144
145/**
146 * Return the queue group element ptr or NULL if no such element
147 */
148static inline queue_group_elem_t *
149queue_group_elem_get(em_queue_group_t queue_group)
150{
151 const int qgrp_idx = qgrp_hdl2idx(queue_group);
152 queue_group_elem_t *qgrp_elem;
153
154 if (unlikely((unsigned int)qgrp_idx > EM_MAX_QUEUE_GROUPS - 1))
155 return NULL;
156
157 qgrp_elem = &em_shm->queue_group_tbl.queue_group_elem[qgrp_idx];
158
159 return qgrp_elem;
160}
161
162static inline int
163queue_group_allocated(const queue_group_elem_t *queue_group_elem)
164{
165 return !objpool_in_pool(&queue_group_elem->queue_group_pool_elem);
166}
167
168/**
169 * Write the EM single-core queue group name for a given core.
170 */
171static inline void
172core_queue_grp_name(int core, char qgrp_name[/*out:len*/], size_t len)
173{
174 const size_t maxlen = len < EM_QUEUE_GROUP_NAME_LEN ?
176
177 if (unlikely(maxlen == 0))
178 return;
179
180 /* write "core#" into qgrp_name[] */
181 snprintf(qgrp_name, maxlen, "%s%d",
183 qgrp_name[maxlen - 1] = '\0';
184}
185
186#ifdef __cplusplus
187}
188#endif
189
190#endif /* EM_QUEUE_GROUP_H_ */
em_shm_t * em_shm
void i_event__qgrp_add_core_req(const internal_event_t *i_ev)
EM internal event handler, add core to an EM queue group. (see em_internal_event.c&h)
void queue_group_join_all(void)
The calling core joins all available queue groups.
em_queue_group_t queue_group_create_sync(const char *name, const em_core_mask_t *mask, em_queue_group_t requested_queue_group)
em_queue_group_t queue_group_create(const char *name, const em_core_mask_t *mask, int num_notif, const em_notif_t notif_tbl[], em_queue_group_t queue_group)
em_status_t queue_group_modify_sync(queue_group_elem_t *const qgrp_elem, const em_core_mask_t *new_mask, bool is_delete)
void queue_group_leave_all(bool flush_orphan_qgrps)
The calling core leaves all queue groups it is part of.
void i_event__qgrp_rem_core_req(const internal_event_t *i_ev)
EM internal event handler, remove core from an EM queue group. (see em_internal_event....
em_status_t queue_group_modify(queue_group_elem_t *const qgrp_elem, const em_core_mask_t *new_mask, int num_notif, const em_notif_t notif_tbl[], bool is_delete)
em_status_t queue_group_check_mask(const em_core_mask_t *mask)
Check that only running EM cores are set in mask.
em_status_t queue_group_init(queue_group_tbl_t *const queue_group_tbl, queue_group_pool_t *const queue_group_pool)
void queue_group_info_print_all(void)
Print EM queue group info.
void queue_group_queues_print(em_queue_group_t qgrp)
Print info about all queues belonging to the given queue group.
#define EM_MAX_QUEUE_GROUPS
#define EM_QUEUE_GROUP_NAME_LEN
#define EM_QUEUE_GROUP_CORE_BASE_NAME
uint32_t em_status_t
objpool_elem_t queue_group_pool_elem