EM-ODP  3.7.0
Event Machine on ODP
em_core.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_CORE_H_
32 #define EM_CORE_H_
33 
34 /**
35  * @file
36  * EM internal core-related functions
37  *
38  */
39 
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 
44 em_status_t core_map_init(core_map_t *const core_map, int core_count,
45  const em_core_mask_t *phys_mask);
46 em_status_t core_map_init_local(core_map_t *const core_map);
47 em_status_t core_map_term_local(core_map_t *const core_map);
48 
49 static inline int
50 logic_to_phys_core_id(const int logic_core)
51 {
52  if (unlikely(logic_core >= EM_MAX_CORES))
53  return -1;
54 
55  return em_shm->core_map.phys_vs_logic.phys[logic_core];
56 }
57 
58 static inline int
59 phys_to_logic_core_id(const int phys_core)
60 {
61  if (unlikely(phys_core >= EM_MAX_CORES))
62  return -1;
63 
64  return em_shm->core_map.phys_vs_logic.logic[phys_core];
65 }
66 
67 int logic_to_thr_core_id(const int logic_core);
68 
69 int thr_to_logic_core_id(const int thr_id);
70 
71 void mask_em2odp(const em_core_mask_t *const em_core_mask,
72  odp_thrmask_t *const odp_thrmask /*out*/);
73 
74 void mask_em2phys(const em_core_mask_t *const em_core_mask,
75  odp_cpumask_t *const odp_cpumask /*out*/);
76 
77 #ifdef __cplusplus
78 }
79 #endif
80 
81 #endif /* EM_CORE_H_ */
em_core_mask_t
Definition: event_machine_hw_types.h:242
core_map_t
Definition: em_core_types.h:47
em_status_t
uint32_t em_status_t
Definition: event_machine_types.h:321
em_shm
em_shm_t * em_shm
Definition: event_machine_init.c:41