EM-ODP  3.7.0
Event Machine on ODP
em_pool_types.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  * EM internal POOL types & definitions
34  *
35  */
36 
37 #ifndef EM_POOL_TYPES_H_
38 #define EM_POOL_TYPES_H_
39 
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 
44 /**
45  * EM event/memory pool
46  */
47 typedef struct {
48  /** Event type of events allocated from the pool */
50  /** Event alignment offset, see em-odp.conf */
51  uint32_t align_offset;
52  /** Event user area size */
53  struct {
54  /** Requested user area size (bytes) */
55  uint16_t size;
56  /*
57  * Note: Use uint16_t instead of size_t to match bitfield sizes
58  * of event_hdr_t::user_area.size.
59  * Size is max EM_EVENT_USER_AREA_MAX_SIZE bytes which
60  * will fit into uint16_t.
61  */
62  } user_area;
63 
64  /** Number of subpools within one EM pool, max=EM_MAX_SUBPOOLS */
66  /** ODP (sub)pool buffer (event) payload sizes */
67  uint32_t size[EM_MAX_SUBPOOLS];
68  /** ODP buffer handles for the subpools */
69  odp_pool_t odp_pool[EM_MAX_SUBPOOLS];
70  /** EM pool handle */
71  em_pool_t em_pool;
72  /** for linking free pool-entries together */
74  /** Pool statistic options chosen during create */
75  odp_pool_stats_opt_t stats_opt;
76  /** Pool Configuration given during create */
78  /* Pool name */
79  char name[EM_POOL_NAME_LEN];
80 } mpool_elem_t;
81 
82 /**
83  * @def POOL_ODP2EM_TBL_LEN
84  * Length of the mpool_tbl_t::pool_odp2em[] array
85  */
86 #define POOL_ODP2EM_TBL_LEN 256
87 
88 /*
89  * Verify at compile time that the mpool_tbl_t::pool_odp2em[] mapping table
90  * is large enough.
91  * Verified also at runtime that: POOL_ODP2EM_TBL_LEN > odp_pool_max_index()
92  */
93 COMPILE_TIME_ASSERT(EM_CONFIG_POOLS * EM_MAX_SUBPOOLS <= POOL_ODP2EM_TBL_LEN,
94  "MPOOL_TBL_T__POOL_ODP2EM__LEN_ERR");
95 
96 /**
97  * Table entry in the mapping table from odp-pool to em-pool and subpool.
98  * See the mpool_tbl_t::pool_subpool_odp2em[] array.
99  */
100 typedef union {
101  struct {
102  uint32_t pool; /* em_pool_t typecast to uint32_t, always fits */
103  uint32_t subpool;
104  };
105  uint64_t both;
107 
108 COMPILE_TIME_ASSERT(sizeof(pool_subpool_t) == sizeof(uint64_t), "POOL_SUBPOOL_T__SIZE_ERR");
109 
110 /**
111  * Undef value for a pool_subpool_t
112  * pool_subpool_undef = {.pool = EM_POOL_UNDEF, .subpool = 0};
113  */
115 
116 /**
117  * EM pool element table
118  */
119 typedef struct {
120  /** event/memory pool elem table */
122 
123  /**
124  * Mapping from odp_pool_index(odp_pool) to em-pool handle and subpool.
125  * Verified at runtime that: POOL_ODP2EM_TBL_LEN > odp_pool_max_index()
126  */
127  pool_subpool_t pool_subpool_odp2em[POOL_ODP2EM_TBL_LEN];
128 
129  /** ODP pool capabilities common for all pools */
130  odp_pool_capability_t odp_pool_capability ENV_CACHE_LINE_ALIGNED;
131 } mpool_tbl_t;
132 
133 /**
134  * Pool of free mempools
135  */
136 typedef struct {
137  objpool_t objpool;
138 } mpool_pool_t;
139 
140 #ifdef __cplusplus
141 }
142 #endif
143 
144 #endif /* EM_POOL_TYPES_H_ */
mpool_elem_t::size
uint16_t size
Definition: em_pool_types.h:55
mpool_elem_t::em_pool
em_pool_t em_pool
Definition: em_pool_types.h:71
pool_subpool_undef
const pool_subpool_t pool_subpool_undef
Undef value for a pool_subpool_t pool_subpool_undef = {.pool = EM_POOL_UNDEF, .subpool = 0};.
Definition: em_pool.c:59
pool_subpool_t
Definition: em_pool_types.h:100
mpool_elem_t::objpool_elem
objpool_elem_t objpool_elem
Definition: em_pool_types.h:73
em_pool_cfg_t
Definition: event_machine_pool.h:141
mpool_elem_t
Definition: em_pool_types.h:47
mpool_elem_t::event_type
em_event_type_t event_type
Definition: em_pool_types.h:49
mpool_elem_t::stats_opt
odp_pool_stats_opt_t stats_opt
Definition: em_pool_types.h:75
mpool_elem_t::pool_cfg
em_pool_cfg_t pool_cfg
Definition: em_pool_types.h:77
mpool_elem_t::align_offset
uint32_t align_offset
Definition: em_pool_types.h:51
mpool_elem_t::num_subpools
int num_subpools
Definition: em_pool_types.h:65
mpool_pool_t
Definition: em_pool_types.h:136
objpool_t
Definition: objpool.h:64
mpool_tbl_t
Definition: em_pool_types.h:119
objpool_elem_t
Definition: objpool.h:48
em_event_type_t
uint32_t em_event_type_t
Definition: event_machine_types.h:85
EM_POOL_NAME_LEN
#define EM_POOL_NAME_LEN
Definition: event_machine_hw_config.h:196
EM_CONFIG_POOLS
#define EM_CONFIG_POOLS
Definition: event_machine_config.h:119
EM_MAX_SUBPOOLS
#define EM_MAX_SUBPOOLS
The number of subpools in each EM pool. The subpool is a pool with buffers of only one size.
Definition: event_machine_hw_types.h:254
mpool_tbl_t::ENV_CACHE_LINE_ALIGNED
odp_pool_capability_t odp_pool_capability ENV_CACHE_LINE_ALIGNED
Definition: em_pool_types.h:130
POOL_ODP2EM_TBL_LEN
#define POOL_ODP2EM_TBL_LEN
Definition: em_pool_types.h:86