aboutsummaryrefslogtreecommitdiff
path: root/platform/linux-generic/pool/subsystem.c
blob: c5f64491295e46a94c06e9164120f020cefd4c49 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
/* Copyright (c) 2017, ARM Limited. All rights reserved.
 *
 * Copyright (c) 2017, Linaro Limited
 * All rights reserved.
 *
 * SPDX-License-Identifier: BSD-3-Clause
 */
#include <odp/api/pool.h>
#include <odp_internal.h>
#include <odp_pool_subsystem.h>
#include <odp_debug_internal.h>
#include <odp_module.h>

#define SUBSYSTEM_VERSION 0x00010000UL
ODP_SUBSYSTEM_DEFINE(pool, "memory pool public APIs", SUBSYSTEM_VERSION);

ODP_SUBSYSTEM_CONSTRUCTOR(pool)
{
	odp_subsystem_constructor(pool);
}

int odp_pool_init_global(void)
{
	pool_module_t *mod;

	mod = odp_subsystem_active_module(pool, mod);
	if (mod == NULL) {
		ODP_ERR("No active module in pool subsystem\n");
		return -1;
	}
	if (mod->base.init_global == NULL) {
		ODP_ERR("No defined init_global function "
			"in module %s of pool subsystem\n", mod->base.name);
		return -1;
	}

	return mod->base.init_global();
}

int odp_pool_term_global(void)
{
	pool_module_t *mod;

	mod = odp_subsystem_active_module(pool, mod);
	if (mod == NULL) {
		ODP_ERR("No active module in pool subsystem\n");
		return -1;
	}
	if (mod->base.term_global == NULL) {
		ODP_ERR("No defined term_global function "
			"in module %s of pool subsystem\n", mod->base.name);
		return -1;
	}

	return mod->base.term_global();
}

int odp_pool_init_local(void)
{
	pool_module_t *mod;

	mod = odp_subsystem_active_module(pool, mod);
	if (mod == NULL) {
		ODP_ERR("No active module in pool subsystem\n");
		return -1;
	}
	if (mod->base.term_global == NULL) {
		ODP_ERR("No defined init_local function "
			"in module %s of pool subsystem\n", mod->base.name);
		return -1;
	}

	return mod->base.init_local();
}

int odp_pool_term_local(void)
{
	pool_module_t *mod;

	mod = odp_subsystem_active_module(pool, mod);
	if (mod == NULL) {
		ODP_ERR("No active module in pool subsystem\n");
		return -1;
	}
	if (mod->base.term_local == NULL) {
		ODP_ERR("No defined term_local function "
			"in module %s of pool subsystem\n", mod->base.name);
		return -1;
	}

	return mod->base.term_local();
}

int odp_pool_capability(odp_pool_capability_t *capa)
{
	pool_module_t *mod;

	mod = odp_subsystem_active_module(pool, mod);
	if (mod == NULL) {
		ODP_ERR("No active module in pool subsystem\n");
		return -1;
	}
	if (mod->capability == NULL) {
		ODP_ERR("No defined capability function "
			"in module %s of pool subsystem\n", mod->base.name);
		return -1;
	}

	return mod->capability(capa);
}

odp_pool_t odp_pool_create(const char *name, odp_pool_param_t *params)
{
	pool_module_t *mod;

	mod = odp_subsystem_active_module(pool, mod);
	if (mod == NULL) {
		ODP_ERR("No active module in pool subsystem\n");
		return ODP_POOL_INVALID;
	}
	if (mod->create == NULL) {
		ODP_ERR("No defined create function "
			"in module %s of pool subsystem\n", mod->base.name);
		return ODP_POOL_INVALID;
	}

	return mod->create(name, params);
}

int odp_pool_destroy(odp_pool_t pool_hdl)
{
	pool_module_t *mod;

	mod = odp_subsystem_active_module(pool, mod);
	if (mod == NULL) {
		ODP_ERR("No active module in pool subsystem\n");
		return -1;
	}
	if (mod->destroy == NULL) {
		ODP_ERR("No defined destroy function "
			"in module %s of pool subsystem\n", mod->base.name);
		return -1;
	}

	return mod->destroy(pool_hdl);
}

odp_pool_t odp_pool_lookup(const char *name)
{
	pool_module_t *mod;

	mod = odp_subsystem_active_module(pool, mod);
	if (mod == NULL) {
		ODP_ERR("No active module in pool subsystem\n");
		return ODP_POOL_INVALID;
	}
	if (mod->lookup == NULL) {
		ODP_ERR("No defined lookup function "
			"in module %s of pool subsystem\n", mod->base.name);
		return ODP_POOL_INVALID;
	}

	return mod->lookup(name);
}

int odp_pool_info(odp_pool_t pool_hdl, odp_pool_info_t *info)
{
	pool_module_t *mod;

	mod = odp_subsystem_active_module(pool, mod);
	if (mod == NULL) {
		ODP_ERR("No active module in pool subsystem\n");
		return -1;
	}
	if (mod->info == NULL) {
		ODP_ERR("No defined info function "
			"in module %s of pool subsystem\n", mod->base.name);
		return -1;
	}

	return mod->info(pool_hdl, info);
}

void odp_pool_print(odp_pool_t pool_hdl)
{
	pool_module_t *mod;

	mod = odp_subsystem_active_module(pool, mod);
	if (mod == NULL) {
		ODP_ERR("No active module in pool subsystem\n");
		return;
	}
	if (mod->print == NULL) {
		ODP_ERR("No defined print function "
			"in module %s of pool subsystem\n", mod->base.name);
		return;
	}

	mod->print(pool_hdl);
}

void odp_pool_param_init(odp_pool_param_t *params)
{
	pool_module_t *mod;

	mod = odp_subsystem_active_module(pool, mod);
	if (mod == NULL) {
		ODP_ERR("No active module in pool subsystem\n");
		return;
	}
	if (mod->param_init == NULL) {
		ODP_ERR("No defined param_init function "
			"in module %s of pool subsystem\n", mod->base.name);
		return;
	}

	mod->param_init(params);
}

uint64_t odp_pool_to_u64(odp_pool_t hdl)
{
	pool_module_t *mod;

	mod = odp_subsystem_active_module(pool, mod);
	if (mod == NULL) {
		ODP_ERR("No active module in pool subsystem\n");
		return -1;
	}
	if (mod->to_u64 == NULL) {
		ODP_ERR("No defined to_u64 function "
			"in module %s of pool subsystem\n", mod->base.name);
		return -1;
	}

	return mod->to_u64(hdl);
}