MCPcopy Create free account
hub / github.com/F-Stack/f-stack / rte_timer_subsystem_init

Function rte_timer_subsystem_init

dpdk/lib/timer/rte_timer.c:128–185  ·  view source on GitHub ↗

Init the timer library. Allocate an array of timer data structs in shared * memory, and allocate the zeroth entry for use with original timer * APIs. Since the intersection of the sets of lcore ids in primary and * secondary processes should be empty, the zeroth entry can be shared by * multiple processes. */

Source from the content-addressed store, hash-verified

126 * multiple processes.
127 */
128int
129rte_timer_subsystem_init(void)
130{
131 const struct rte_memzone *mz;
132 struct rte_timer_data *data;
133 int i, lcore_id;
134 static const char *mz_name = "rte_timer_mz";
135 const size_t data_arr_size =
136 RTE_MAX_DATA_ELS * sizeof(*rte_timer_data_arr);
137 const size_t mem_size = data_arr_size + sizeof(*rte_timer_mz_refcnt);
138 bool do_full_init = true;
139
140 rte_mcfg_timer_lock();
141
142 if (rte_timer_subsystem_initialized) {
143 rte_mcfg_timer_unlock();
144 return -EALREADY;
145 }
146
147 mz = rte_memzone_lookup(mz_name);
148 if (mz == NULL) {
149 mz = rte_memzone_reserve_aligned(mz_name, mem_size,
150 SOCKET_ID_ANY, 0, RTE_CACHE_LINE_SIZE);
151 if (mz == NULL) {
152 rte_mcfg_timer_unlock();
153 return -ENOMEM;
154 }
155 do_full_init = true;
156 } else
157 do_full_init = false;
158
159 rte_timer_data_mz = mz;
160 rte_timer_data_arr = mz->addr;
161 rte_timer_mz_refcnt = (void *)((char *)mz->addr + data_arr_size);
162
163 if (do_full_init) {
164 for (i = 0; i < RTE_MAX_DATA_ELS; i++) {
165 data = &rte_timer_data_arr[i];
166
167 for (lcore_id = 0; lcore_id < RTE_MAX_LCORE;
168 lcore_id++) {
169 rte_spinlock_init(
170 &data->priv_timer[lcore_id].list_lock);
171 data->priv_timer[lcore_id].prev_lcore =
172 lcore_id;
173 }
174 }
175 }
176
177 rte_timer_data_arr[default_data_id].internal_flags |= FL_ALLOCATED;
178 (*rte_timer_mz_refcnt)++;
179
180 rte_timer_subsystem_initialized = 1;
181
182 rte_mcfg_timer_unlock();
183
184 return 0;
185}

Callers 8

init_clockFunction · 0.85
swtim_initFunction · 0.85
ena_init_onceFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85
mainFunction · 0.85

Calls 5

rte_mcfg_timer_lockFunction · 0.85
rte_mcfg_timer_unlockFunction · 0.85
rte_memzone_lookupFunction · 0.85
rte_spinlock_initFunction · 0.85

Tested by 1

mainFunction · 0.68