Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause
2 : : * Copyright(c) 2010-2014 Intel Corporation
3 : : */
4 : :
5 : : #include <string.h>
6 : : #include <stdio.h>
7 : : #include <stdlib.h>
8 : : #include <stdint.h>
9 : : #include <inttypes.h>
10 : : #include <stdarg.h>
11 : : #include <errno.h>
12 : : #include <sys/queue.h>
13 : :
14 : : #include <rte_common.h>
15 : : #include <rte_eal_paging.h>
16 : : #include <rte_log.h>
17 : : #include <rte_debug.h>
18 : : #include <rte_errno.h>
19 : : #include <rte_memory.h>
20 : : #include <rte_launch.h>
21 : : #include <rte_cycles.h>
22 : : #include <rte_eal.h>
23 : : #include <rte_per_lcore.h>
24 : : #include <rte_lcore.h>
25 : : #include <rte_branch_prediction.h>
26 : : #include <rte_mempool.h>
27 : : #include <rte_spinlock.h>
28 : : #include <rte_malloc.h>
29 : : #include <rte_mbuf_pool_ops.h>
30 : : #include <rte_mbuf.h>
31 : :
32 : : #include "test.h"
33 : :
34 : : /*
35 : : * Mempool
36 : : * =======
37 : : *
38 : : * Basic tests: done on one core with and without cache:
39 : : *
40 : : * - Get one object, put one object
41 : : * - Get two objects, put two objects
42 : : * - Get all objects, test that their content is not modified and
43 : : * put them back in the pool.
44 : : */
45 : :
46 : : #define MEMPOOL_ELT_SIZE 2048
47 : : #define MAX_KEEP 16
48 : : #define MEMPOOL_SIZE ((rte_lcore_count()*(MAX_KEEP+RTE_MEMPOOL_CACHE_MAX_SIZE))-1)
49 : :
50 : : #define LOG_ERR() printf("test failed at %s():%d\n", __func__, __LINE__)
51 : : #define RET_ERR() do { \
52 : : LOG_ERR(); \
53 : : return -1; \
54 : : } while (0)
55 : : #define GOTO_ERR(var, label) do { \
56 : : LOG_ERR(); \
57 : : var = -1; \
58 : : goto label; \
59 : : } while (0)
60 : :
61 : : /*
62 : : * save the object number in the first 4 bytes of object data. All
63 : : * other bytes are set to 0.
64 : : */
65 : : static void
66 : 7385 : my_obj_init(struct rte_mempool *mp, __rte_unused void *arg,
67 : : void *obj, unsigned i)
68 : : {
69 : : uint32_t *objnum = obj;
70 : :
71 : 7385 : memset(obj, 0, mp->elt_size);
72 : 7385 : *objnum = i;
73 : 7385 : }
74 : :
75 : : /* basic tests (done on one core) */
76 : : static int
77 : 5 : test_mempool_basic(struct rte_mempool *mp, int use_external_cache)
78 : : {
79 : : uint32_t *objnum;
80 : : void **objtable;
81 : : void *obj, *obj2;
82 : : char *obj_data;
83 : : int ret = 0;
84 : : unsigned i, j;
85 : : int offset;
86 : : struct rte_mempool_cache *cache;
87 : :
88 [ + + ]: 5 : if (use_external_cache) {
89 : : /* Create a user-owned mempool cache. */
90 : 3 : cache = rte_mempool_cache_create(RTE_MEMPOOL_CACHE_MAX_SIZE,
91 : : SOCKET_ID_ANY);
92 [ - + ]: 3 : if (cache == NULL)
93 : 0 : RET_ERR();
94 : : } else {
95 : : /* May be NULL if cache is disabled. */
96 : : cache = rte_mempool_default_cache(mp, rte_lcore_id());
97 : : }
98 : :
99 : : /* dump the mempool status */
100 : 5 : rte_mempool_dump(stdout, mp);
101 : :
102 : : printf("get an object\n");
103 [ - + ]: 1 : if (rte_mempool_generic_get(mp, &obj, 1, cache) < 0)
104 : 0 : GOTO_ERR(ret, out);
105 : 5 : rte_mempool_dump(stdout, mp);
106 : :
107 : : /* tests that improve coverage */
108 : : printf("get object count\n");
109 : : /* We have to count the extra caches, one in this case. */
110 [ + + ]: 5 : offset = use_external_cache ? 1 * cache->len : 0;
111 [ - + ]: 5 : if (rte_mempool_avail_count(mp) + offset != MEMPOOL_SIZE - 1)
112 : 0 : GOTO_ERR(ret, out);
113 : :
114 : : printf("get private data\n");
115 : : if (rte_mempool_get_priv(mp) != (char *)mp +
116 : : RTE_MEMPOOL_HEADER_SIZE(mp, mp->cache_size))
117 : : GOTO_ERR(ret, out);
118 : :
119 : : #ifndef RTE_EXEC_ENV_FREEBSD /* rte_mem_virt2iova() not supported on bsd */
120 : : printf("get physical address of an object\n");
121 [ - + ]: 5 : if (rte_mempool_virt2iova(obj) != rte_mem_virt2iova(obj))
122 : 0 : GOTO_ERR(ret, out);
123 : : #endif
124 : :
125 : : printf("put the object back\n");
126 : : rte_mempool_generic_put(mp, &obj, 1, cache);
127 : 5 : rte_mempool_dump(stdout, mp);
128 : :
129 : : printf("get 2 objects\n");
130 [ - + ]: 5 : if (rte_mempool_generic_get(mp, &obj, 1, cache) < 0)
131 : 0 : GOTO_ERR(ret, out);
132 [ - + ]: 5 : if (rte_mempool_generic_get(mp, &obj2, 1, cache) < 0) {
133 : : rte_mempool_generic_put(mp, &obj, 1, cache);
134 : 0 : GOTO_ERR(ret, out);
135 : : }
136 : 5 : rte_mempool_dump(stdout, mp);
137 : :
138 : : printf("put the objects back\n");
139 : : rte_mempool_generic_put(mp, &obj, 1, cache);
140 : : rte_mempool_generic_put(mp, &obj2, 1, cache);
141 : 5 : rte_mempool_dump(stdout, mp);
142 : :
143 : : /*
144 : : * get many objects: we cannot get them all because the cache
145 : : * on other cores may not be empty.
146 : : */
147 : 5 : objtable = malloc(MEMPOOL_SIZE * sizeof(void *));
148 [ - + ]: 5 : if (objtable == NULL)
149 : 0 : GOTO_ERR(ret, out);
150 : :
151 [ + + ]: 5280 : for (i = 0; i < MEMPOOL_SIZE; i++) {
152 [ + + + - ]: 10546 : if (rte_mempool_generic_get(mp, &objtable[i], 1, cache) < 0)
153 : : break;
154 : : }
155 : :
156 : : /*
157 : : * for each object, check that its content was not modified,
158 : : * and put objects back in pool
159 : : */
160 [ + + ]: 5280 : while (i--) {
161 : 5275 : obj = objtable[i];
162 : : obj_data = obj;
163 : : objnum = obj;
164 [ - + ]: 5275 : if (*objnum > MEMPOOL_SIZE) {
165 : 0 : printf("bad object number(%d)\n", *objnum);
166 : : ret = -1;
167 : 0 : break;
168 : : }
169 [ + + ]: 10787375 : for (j = sizeof(*objnum); j < mp->elt_size; j++) {
170 [ - + ]: 10782100 : if (obj_data[j] != 0)
171 : : ret = -1;
172 : : }
173 : :
174 : : rte_mempool_generic_put(mp, &objtable[i], 1, cache);
175 : : }
176 : :
177 : 5 : free(objtable);
178 [ + - ]: 5 : if (ret == -1)
179 : : printf("objects were modified!\n");
180 : :
181 : 5 : out:
182 [ + + ]: 5 : if (use_external_cache) {
183 : : rte_mempool_cache_flush(cache, mp);
184 : 3 : rte_mempool_cache_free(cache);
185 : : }
186 : :
187 : : return ret;
188 : : }
189 : :
190 : 1 : static int test_mempool_creation_with_exceeded_cache_size(void)
191 : : {
192 : : struct rte_mempool *mp_cov;
193 : :
194 : 1 : mp_cov = rte_mempool_create("test_mempool_cache_too_big",
195 : 1 : MEMPOOL_SIZE,
196 : : MEMPOOL_ELT_SIZE,
197 : : RTE_MEMPOOL_CACHE_MAX_SIZE + 32, 0,
198 : : NULL, NULL,
199 : : my_obj_init, NULL,
200 : : SOCKET_ID_ANY, 0);
201 : :
202 [ - + ]: 1 : if (mp_cov != NULL) {
203 : 0 : rte_mempool_free(mp_cov);
204 : 0 : RET_ERR();
205 : : }
206 : :
207 : : return 0;
208 : : }
209 : :
210 : 1 : static int test_mempool_creation_with_invalid_flags(void)
211 : : {
212 : : struct rte_mempool *mp_cov;
213 : :
214 : 1 : mp_cov = rte_mempool_create("test_mempool_invalid_flags", MEMPOOL_SIZE,
215 : : MEMPOOL_ELT_SIZE, 0, 0,
216 : : NULL, NULL,
217 : : NULL, NULL,
218 : : SOCKET_ID_ANY, ~RTE_MEMPOOL_VALID_USER_FLAGS);
219 : :
220 [ - + ]: 1 : if (mp_cov != NULL) {
221 : 0 : rte_mempool_free(mp_cov);
222 : 0 : RET_ERR();
223 : : }
224 : :
225 : : return 0;
226 : : }
227 : :
228 : : static struct rte_mempool *mp_spsc;
229 : : static rte_spinlock_t scsp_spinlock;
230 : : static void *scsp_obj_table[MAX_KEEP];
231 : :
232 : : /*
233 : : * single producer function
234 : : */
235 : 1 : static int test_mempool_single_producer(void)
236 : : {
237 : : unsigned int i;
238 : : void *obj = NULL;
239 : : uint64_t start_cycles, end_cycles;
240 : 1 : uint64_t duration = rte_get_timer_hz() / 4;
241 : :
242 : : start_cycles = rte_get_timer_cycles();
243 : : while (1) {
244 : : end_cycles = rte_get_timer_cycles();
245 : : /* duration uses up, stop producing */
246 [ + + ]: 5291757 : if (start_cycles + duration < end_cycles)
247 : : break;
248 : : rte_spinlock_lock(&scsp_spinlock);
249 [ + + ]: 86211577 : for (i = 0; i < MAX_KEEP; i ++) {
250 [ + + ]: 81196299 : if (NULL != scsp_obj_table[i]) {
251 : : obj = scsp_obj_table[i];
252 : : break;
253 : : }
254 : : }
255 : : rte_spinlock_unlock(&scsp_spinlock);
256 [ + + ]: 5291756 : if (i >= MAX_KEEP) {
257 : 5015278 : continue;
258 : : }
259 [ - + ]: 276478 : if (rte_mempool_from_obj(obj) != mp_spsc) {
260 : : printf("obj not owned by this mempool\n");
261 : 0 : RET_ERR();
262 : : }
263 : 276478 : rte_mempool_put(mp_spsc, obj);
264 : : rte_spinlock_lock(&scsp_spinlock);
265 : 276478 : scsp_obj_table[i] = NULL;
266 : : rte_spinlock_unlock(&scsp_spinlock);
267 : : }
268 : :
269 : : return 0;
270 : : }
271 : :
272 : : /*
273 : : * single consumer function
274 : : */
275 : 1 : static int test_mempool_single_consumer(void)
276 : : {
277 : : unsigned int i;
278 : : void * obj;
279 : : uint64_t start_cycles, end_cycles;
280 : 1 : uint64_t duration = rte_get_timer_hz() / 8;
281 : :
282 : : start_cycles = rte_get_timer_cycles();
283 : : while (1) {
284 : : end_cycles = rte_get_timer_cycles();
285 : : /* duration uses up, stop consuming */
286 [ + + ]: 306552 : if (start_cycles + duration < end_cycles)
287 : : break;
288 : : rte_spinlock_lock(&scsp_spinlock);
289 [ + + ]: 1463092 : for (i = 0; i < MAX_KEEP; i ++) {
290 [ + + ]: 1433019 : if (NULL == scsp_obj_table[i])
291 : : break;
292 : : }
293 : : rte_spinlock_unlock(&scsp_spinlock);
294 [ + + ]: 306551 : if (i >= MAX_KEEP)
295 : 30073 : continue;
296 [ - + + - ]: 552956 : if (rte_mempool_get(mp_spsc, &obj) < 0)
297 : : break;
298 : : rte_spinlock_lock(&scsp_spinlock);
299 : 276478 : scsp_obj_table[i] = obj;
300 : : rte_spinlock_unlock(&scsp_spinlock);
301 : : }
302 : :
303 : 1 : return 0;
304 : : }
305 : :
306 : : /*
307 : : * test function for mempool test based on single consumer and single producer,
308 : : * can run on one lcore only
309 : : */
310 : : static int
311 : 1 : test_mempool_launch_single_consumer(__rte_unused void *arg)
312 : : {
313 : 1 : return test_mempool_single_consumer();
314 : : }
315 : :
316 : : static void
317 : 1 : my_mp_init(struct rte_mempool *mp, __rte_unused void *arg)
318 : : {
319 : 1 : printf("mempool name is %s\n", mp->name);
320 : : /* nothing to be implemented here*/
321 : 1 : return ;
322 : : }
323 : :
324 : : /*
325 : : * it tests the mempool operations based on single producer and single consumer
326 : : */
327 : : static int
328 [ + - ]: 1 : test_mempool_sp_sc(void)
329 : : {
330 : : int ret = 0;
331 : : unsigned lcore_id = rte_lcore_id();
332 : : unsigned lcore_next;
333 : :
334 : : /* create a mempool with single producer/consumer ring */
335 [ + - ]: 1 : if (mp_spsc == NULL) {
336 : 1 : mp_spsc = rte_mempool_create("test_mempool_sp_sc", MEMPOOL_SIZE,
337 : : MEMPOOL_ELT_SIZE, 0, 0,
338 : : my_mp_init, NULL,
339 : : my_obj_init, NULL,
340 : : SOCKET_ID_ANY,
341 : : RTE_MEMPOOL_F_NO_CACHE_ALIGN | RTE_MEMPOOL_F_SP_PUT |
342 : : RTE_MEMPOOL_F_SC_GET);
343 [ - + ]: 1 : if (mp_spsc == NULL)
344 : 0 : RET_ERR();
345 : : }
346 [ - + ]: 1 : if (rte_mempool_lookup("test_mempool_sp_sc") != mp_spsc) {
347 : : printf("Cannot lookup mempool from its name\n");
348 : : ret = -1;
349 : 0 : goto err;
350 : : }
351 : 1 : lcore_next = rte_get_next_lcore(lcore_id, 0, 1);
352 [ - + ]: 1 : if (lcore_next >= RTE_MAX_LCORE) {
353 : : ret = -1;
354 : 0 : goto err;
355 : : }
356 [ - + ]: 1 : if (rte_eal_lcore_role(lcore_next) != ROLE_RTE) {
357 : : ret = -1;
358 : 0 : goto err;
359 : : }
360 : : rte_spinlock_init(&scsp_spinlock);
361 : : memset(scsp_obj_table, 0, sizeof(scsp_obj_table));
362 : 1 : rte_eal_remote_launch(test_mempool_launch_single_consumer, NULL,
363 : : lcore_next);
364 [ - + ]: 1 : if (test_mempool_single_producer() < 0)
365 : : ret = -1;
366 : :
367 [ + - ]: 1 : if (rte_eal_wait_lcore(lcore_next) < 0)
368 : : ret = -1;
369 : :
370 : 1 : err:
371 : 1 : rte_mempool_free(mp_spsc);
372 : 1 : mp_spsc = NULL;
373 : :
374 : 1 : return ret;
375 : : }
376 : :
377 : : /*
378 : : * it tests some more basic of mempool
379 : : */
380 : : static int
381 : 1 : test_mempool_basic_ex(struct rte_mempool *mp)
382 : : {
383 : : unsigned i;
384 : : void **obj;
385 : : void *err_obj;
386 : : int ret = -1;
387 : :
388 [ + - ]: 1 : if (mp == NULL)
389 : : return ret;
390 : :
391 : 1 : obj = rte_calloc("test_mempool_basic_ex", MEMPOOL_SIZE,
392 : : sizeof(void *), 0);
393 [ - + ]: 1 : if (obj == NULL) {
394 : : printf("test_mempool_basic_ex fail to rte_malloc\n");
395 : 0 : return ret;
396 : : }
397 : 1 : printf("test_mempool_basic_ex now mempool (%s) has %u free entries\n",
398 : 1 : mp->name, rte_mempool_in_use_count(mp));
399 [ - + ]: 1 : if (rte_mempool_full(mp) != 1) {
400 : : printf("test_mempool_basic_ex the mempool should be full\n");
401 : 0 : goto fail_mp_basic_ex;
402 : : }
403 : :
404 [ + + ]: 1056 : for (i = 0; i < MEMPOOL_SIZE; i ++) {
405 [ - + - + ]: 2110 : if (rte_mempool_get(mp, &obj[i]) < 0) {
406 : : printf("test_mp_basic_ex fail to get object for [%u]\n",
407 : : i);
408 : 0 : goto fail_mp_basic_ex;
409 : : }
410 : : }
411 [ - + ]: 1 : if (rte_mempool_get(mp, &err_obj) == 0) {
412 : : printf("test_mempool_basic_ex get an impossible obj\n");
413 : 0 : goto fail_mp_basic_ex;
414 : : }
415 : : printf("number: %u\n", i);
416 [ - + ]: 1 : if (rte_mempool_empty(mp) != 1) {
417 : : printf("test_mempool_basic_ex the mempool should be empty\n");
418 : 0 : goto fail_mp_basic_ex;
419 : : }
420 : :
421 [ + + ]: 1056 : for (i = 0; i < MEMPOOL_SIZE; i++)
422 [ - + ]: 2110 : rte_mempool_put(mp, obj[i]);
423 : :
424 [ - + ]: 1 : if (rte_mempool_full(mp) != 1) {
425 : : printf("test_mempool_basic_ex the mempool should be full\n");
426 : 0 : goto fail_mp_basic_ex;
427 : : }
428 : :
429 : : ret = 0;
430 : :
431 : 1 : fail_mp_basic_ex:
432 : : if (obj != NULL)
433 : 1 : rte_free((void *)obj);
434 : :
435 : 1 : return ret;
436 : : }
437 : :
438 : : static int
439 : 1 : test_mempool_same_name_twice_creation(void)
440 : : {
441 : : struct rte_mempool *mp_tc, *mp_tc2;
442 : :
443 : 1 : mp_tc = rte_mempool_create("test_mempool_same_name", MEMPOOL_SIZE,
444 : : MEMPOOL_ELT_SIZE, 0, 0,
445 : : NULL, NULL,
446 : : NULL, NULL,
447 : : SOCKET_ID_ANY, 0);
448 : :
449 [ - + ]: 1 : if (mp_tc == NULL)
450 : 0 : RET_ERR();
451 : :
452 : 1 : mp_tc2 = rte_mempool_create("test_mempool_same_name", MEMPOOL_SIZE,
453 : : MEMPOOL_ELT_SIZE, 0, 0,
454 : : NULL, NULL,
455 : : NULL, NULL,
456 : : SOCKET_ID_ANY, 0);
457 : :
458 [ - + ]: 1 : if (mp_tc2 != NULL) {
459 : 0 : rte_mempool_free(mp_tc);
460 : 0 : rte_mempool_free(mp_tc2);
461 : 0 : RET_ERR();
462 : : }
463 : :
464 : 1 : rte_mempool_free(mp_tc);
465 : 1 : return 0;
466 : : }
467 : :
468 : : static void
469 : 6 : walk_cb(struct rte_mempool *mp, void *userdata __rte_unused)
470 : : {
471 : 6 : printf("\t%s\n", mp->name);
472 : 6 : }
473 : :
474 : : struct mp_data {
475 : : int16_t ret;
476 : : };
477 : :
478 : : static void
479 : 2 : test_mp_mem_init(struct rte_mempool *mp,
480 : : __rte_unused void *opaque,
481 : : __rte_unused struct rte_mempool_memhdr *memhdr,
482 : : __rte_unused unsigned int mem_idx)
483 : : {
484 : : struct mp_data *data = opaque;
485 : :
486 [ - + ]: 2 : if (mp == NULL) {
487 : 0 : data->ret = -1;
488 : 0 : return;
489 : : }
490 : : /* nothing to be implemented here*/
491 : 2 : data->ret = 0;
492 : : }
493 : :
494 : : struct test_mempool_events_data {
495 : : struct rte_mempool *mp;
496 : : enum rte_mempool_event event;
497 : : bool invoked;
498 : : };
499 : :
500 : : static void
501 : 19 : test_mempool_events_cb(enum rte_mempool_event event,
502 : : struct rte_mempool *mp, void *user_data)
503 : : {
504 : : struct test_mempool_events_data *data = user_data;
505 : :
506 : 19 : data->mp = mp;
507 : 19 : data->event = event;
508 : 19 : data->invoked = true;
509 : 19 : }
510 : :
511 : : static int
512 : 2 : test_mempool_events(int (*populate)(struct rte_mempool *mp))
513 : 2 : {
514 : : #pragma push_macro("RTE_TEST_TRACE_FAILURE")
515 : : #undef RTE_TEST_TRACE_FAILURE
516 : : #define RTE_TEST_TRACE_FAILURE(...) do { goto fail; } while (0)
517 : :
518 : : static const size_t callback_num = 3;
519 : : static const size_t mempool_num = 2;
520 : : static const unsigned int mempool_elt_size = 64;
521 : : static const unsigned int mempool_size = 64;
522 : :
523 : 2 : struct test_mempool_events_data data[callback_num];
524 : : struct rte_mempool *mp[mempool_num], *freed;
525 : : char name[RTE_MEMPOOL_NAMESIZE];
526 : : size_t i, j;
527 : : int ret;
528 : :
529 : : memset(mp, 0, sizeof(mp));
530 [ + + ]: 8 : for (i = 0; i < callback_num; i++) {
531 : 6 : ret = rte_mempool_event_callback_register
532 : 6 : (test_mempool_events_cb, &data[i]);
533 [ - + ]: 6 : RTE_TEST_ASSERT_EQUAL(ret, 0, "Failed to register the callback %zu: %s",
534 : : i, rte_strerror(rte_errno));
535 : : }
536 : 2 : ret = rte_mempool_event_callback_unregister(test_mempool_events_cb, mp);
537 [ - + ]: 2 : RTE_TEST_ASSERT_NOT_EQUAL(ret, 0, "Unregistered a non-registered callback");
538 : : /* NULL argument has no special meaning in this API. */
539 : 2 : ret = rte_mempool_event_callback_unregister(test_mempool_events_cb,
540 : : NULL);
541 [ - + ]: 2 : RTE_TEST_ASSERT_NOT_EQUAL(ret, 0, "Unregistered a non-registered callback with NULL argument");
542 : :
543 : : /* Create mempool 0 that will be observed by all callbacks. */
544 : : memset(&data, 0, sizeof(data));
545 : : strcpy(name, "empty0");
546 : 2 : mp[0] = rte_mempool_create_empty(name, mempool_size,
547 : : mempool_elt_size, 0, 0,
548 : : SOCKET_ID_ANY, 0);
549 [ - + ]: 2 : RTE_TEST_ASSERT_NOT_NULL(mp[0], "Cannot create mempool %s: %s",
550 : : name, rte_strerror(rte_errno));
551 [ + + ]: 8 : for (j = 0; j < callback_num; j++)
552 [ - + ]: 6 : RTE_TEST_ASSERT_EQUAL(data[j].invoked, false,
553 : : "Callback %zu invoked on %s mempool creation",
554 : : j, name);
555 : :
556 : 2 : rte_mempool_set_ops_byname(mp[0], rte_mbuf_best_mempool_ops(), NULL);
557 : 2 : ret = populate(mp[0]);
558 [ - + ]: 2 : RTE_TEST_ASSERT_EQUAL(ret, (int)mp[0]->size, "Failed to populate mempool %s: %s",
559 : : name, rte_strerror(-ret));
560 [ + + ]: 8 : for (j = 0; j < callback_num; j++) {
561 [ - + ]: 6 : RTE_TEST_ASSERT_EQUAL(data[j].invoked, true,
562 : : "Callback %zu not invoked on mempool %s population",
563 : : j, name);
564 [ - + ]: 6 : RTE_TEST_ASSERT_EQUAL(data[j].event,
565 : : RTE_MEMPOOL_EVENT_READY,
566 : : "Wrong callback invoked, expected READY");
567 [ - + ]: 6 : RTE_TEST_ASSERT_EQUAL(data[j].mp, mp[0],
568 : : "Callback %zu invoked for a wrong mempool instead of %s",
569 : : j, name);
570 : : }
571 : :
572 : : /* Check that unregistered callback 0 observes no events. */
573 : 2 : ret = rte_mempool_event_callback_unregister(test_mempool_events_cb,
574 : 2 : &data[0]);
575 [ - + ]: 2 : RTE_TEST_ASSERT_EQUAL(ret, 0, "Failed to unregister callback 0: %s",
576 : : rte_strerror(rte_errno));
577 : : memset(&data, 0, sizeof(data));
578 : : strcpy(name, "empty1");
579 : 2 : mp[1] = rte_mempool_create_empty(name, mempool_size,
580 : : mempool_elt_size, 0, 0,
581 : : SOCKET_ID_ANY, 0);
582 [ - + ]: 2 : RTE_TEST_ASSERT_NOT_NULL(mp[1], "Cannot create mempool %s: %s",
583 : : name, rte_strerror(rte_errno));
584 : 2 : rte_mempool_set_ops_byname(mp[1], rte_mbuf_best_mempool_ops(), NULL);
585 : 2 : ret = populate(mp[1]);
586 [ - + ]: 2 : RTE_TEST_ASSERT_EQUAL(ret, (int)mp[1]->size, "Failed to populate mempool %s: %s",
587 : : name, rte_strerror(-ret));
588 [ - + ]: 2 : RTE_TEST_ASSERT_EQUAL(data[0].invoked, false,
589 : : "Unregistered callback 0 invoked on %s mempool populaton",
590 : : name);
591 : :
592 [ + + ]: 6 : for (i = 0; i < mempool_num; i++) {
593 : : memset(&data, 0, sizeof(data));
594 : : sprintf(name, "empty%zu", i);
595 : 4 : rte_mempool_free(mp[i]);
596 : : /*
597 : : * Save pointer to check that it was passed to the callback,
598 : : * but put NULL into the array in case cleanup is called early.
599 : : */
600 : 4 : freed = mp[i];
601 : 4 : mp[i] = NULL;
602 [ + + ]: 12 : for (j = 1; j < callback_num; j++) {
603 [ - + ]: 8 : RTE_TEST_ASSERT_EQUAL(data[j].invoked, true,
604 : : "Callback %zu not invoked on mempool %s destruction",
605 : : j, name);
606 [ - + ]: 8 : RTE_TEST_ASSERT_EQUAL(data[j].event,
607 : : RTE_MEMPOOL_EVENT_DESTROY,
608 : : "Wrong callback invoked, expected DESTROY");
609 [ - + ]: 8 : RTE_TEST_ASSERT_EQUAL(data[j].mp, freed,
610 : : "Callback %zu invoked for a wrong mempool instead of %s",
611 : : j, name);
612 : : }
613 [ - + ]: 4 : RTE_TEST_ASSERT_EQUAL(data[0].invoked, false,
614 : : "Unregistered callback 0 invoked on %s mempool destruction",
615 : : name);
616 : : }
617 : :
618 [ + + ]: 6 : for (j = 1; j < callback_num; j++) {
619 : 4 : ret = rte_mempool_event_callback_unregister
620 : 4 : (test_mempool_events_cb, &data[j]);
621 [ - + ]: 4 : RTE_TEST_ASSERT_EQUAL(ret, 0, "Failed to unregister the callback %zu: %s",
622 : : j, rte_strerror(rte_errno));
623 : : }
624 : : return TEST_SUCCESS;
625 : :
626 : : fail:
627 [ # # ]: 0 : for (j = 0; j < callback_num; j++)
628 : 0 : rte_mempool_event_callback_unregister
629 : 0 : (test_mempool_events_cb, &data[j]);
630 [ # # ]: 0 : for (i = 0; i < mempool_num; i++)
631 : 0 : rte_mempool_free(mp[i]);
632 : : return TEST_FAILED;
633 : :
634 : : #pragma pop_macro("RTE_TEST_TRACE_FAILURE")
635 : : }
636 : :
637 : : struct test_mempool_events_safety_data {
638 : : bool invoked;
639 : : int (*api_func)(rte_mempool_event_callback *func, void *user_data);
640 : : rte_mempool_event_callback *cb_func;
641 : : void *cb_user_data;
642 : : int ret;
643 : : };
644 : :
645 : : static void
646 : 3 : test_mempool_events_safety_cb(enum rte_mempool_event event,
647 : : struct rte_mempool *mp, void *user_data)
648 : : {
649 : : struct test_mempool_events_safety_data *data = user_data;
650 : :
651 : : RTE_SET_USED(event);
652 : : RTE_SET_USED(mp);
653 : 3 : data->invoked = true;
654 : 3 : data->ret = data->api_func(data->cb_func, data->cb_user_data);
655 : 3 : }
656 : :
657 : : static int
658 : 1 : test_mempool_events_safety(void)
659 : : {
660 : : #pragma push_macro("RTE_TEST_TRACE_FAILURE")
661 : : #undef RTE_TEST_TRACE_FAILURE
662 : : #define RTE_TEST_TRACE_FAILURE(...) do { \
663 : : ret = TEST_FAILED; \
664 : : goto exit; \
665 : : } while (0)
666 : :
667 : : struct test_mempool_events_data data;
668 : : struct test_mempool_events_safety_data sdata[2];
669 : : struct rte_mempool *mp;
670 : : size_t i;
671 : : int ret;
672 : :
673 : : /* removes itself */
674 : 1 : sdata[0].api_func = rte_mempool_event_callback_unregister;
675 : 1 : sdata[0].cb_func = test_mempool_events_safety_cb;
676 : 1 : sdata[0].cb_user_data = &sdata[0];
677 : 1 : sdata[0].ret = -1;
678 : 1 : rte_mempool_event_callback_register(test_mempool_events_safety_cb,
679 : : &sdata[0]);
680 : : /* inserts a callback after itself */
681 : 1 : sdata[1].api_func = rte_mempool_event_callback_register;
682 : 1 : sdata[1].cb_func = test_mempool_events_cb;
683 : 1 : sdata[1].cb_user_data = &data;
684 : 1 : sdata[1].ret = -1;
685 : 1 : rte_mempool_event_callback_register(test_mempool_events_safety_cb,
686 : : &sdata[1]);
687 : :
688 : 1 : mp = rte_mempool_create_empty("empty", MEMPOOL_SIZE,
689 : : MEMPOOL_ELT_SIZE, 0, 0,
690 : : SOCKET_ID_ANY, 0);
691 [ - + ]: 1 : RTE_TEST_ASSERT_NOT_NULL(mp, "Cannot create mempool: %s",
692 : : rte_strerror(rte_errno));
693 : : memset(&data, 0, sizeof(data));
694 : 1 : ret = rte_mempool_populate_default(mp);
695 [ - + ]: 1 : RTE_TEST_ASSERT_EQUAL(ret, (int)mp->size, "Failed to populate mempool: %s",
696 : : rte_strerror(-ret));
697 : :
698 [ - + ]: 1 : RTE_TEST_ASSERT_EQUAL(sdata[0].ret, 0, "Callback failed to unregister itself: %s",
699 : : rte_strerror(rte_errno));
700 [ - + ]: 1 : RTE_TEST_ASSERT_EQUAL(sdata[1].ret, 0, "Failed to insert a new callback: %s",
701 : : rte_strerror(rte_errno));
702 [ - + ]: 1 : RTE_TEST_ASSERT_EQUAL(data.invoked, false,
703 : : "Inserted callback is invoked on mempool population");
704 : :
705 : : memset(&data, 0, sizeof(data));
706 : 1 : sdata[0].invoked = false;
707 : 1 : rte_mempool_free(mp);
708 : : mp = NULL;
709 [ - + ]: 1 : RTE_TEST_ASSERT_EQUAL(sdata[0].invoked, false,
710 : : "Callback that unregistered itself was called");
711 [ - + ]: 1 : RTE_TEST_ASSERT_EQUAL(sdata[1].ret, -EEXIST,
712 : : "New callback inserted twice");
713 [ - + ]: 1 : RTE_TEST_ASSERT_EQUAL(data.invoked, true,
714 : : "Inserted callback is not invoked on mempool destruction");
715 : :
716 : 1 : rte_mempool_event_callback_unregister(test_mempool_events_cb, &data);
717 [ + + ]: 3 : for (i = 0; i < RTE_DIM(sdata); i++)
718 : 2 : rte_mempool_event_callback_unregister
719 : 2 : (test_mempool_events_safety_cb, &sdata[i]);
720 : : ret = TEST_SUCCESS;
721 : :
722 : 1 : exit:
723 : : /* cleanup, don't care which callbacks are already removed */
724 : 1 : rte_mempool_event_callback_unregister(test_mempool_events_cb, &data);
725 [ + + ]: 3 : for (i = 0; i < RTE_DIM(sdata); i++)
726 : 2 : rte_mempool_event_callback_unregister
727 : 2 : (test_mempool_events_safety_cb, &sdata[i]);
728 : : /* in case of failure before the planned destruction */
729 : 1 : rte_mempool_free(mp);
730 : : return ret;
731 : :
732 : : #pragma pop_macro("RTE_TEST_TRACE_FAILURE")
733 : : }
734 : :
735 : : #pragma push_macro("RTE_TEST_TRACE_FAILURE")
736 : : #undef RTE_TEST_TRACE_FAILURE
737 : : #define RTE_TEST_TRACE_FAILURE(...) do { \
738 : : ret = TEST_FAILED; \
739 : : goto exit; \
740 : : } while (0)
741 : :
742 : : static int
743 : 1 : test_mempool_flag_non_io_set_when_no_iova_contig_set(void)
744 : : {
745 : : const struct rte_memzone *mz = NULL;
746 : : void *virt;
747 : : rte_iova_t iova;
748 : : size_t size = MEMPOOL_ELT_SIZE * 16;
749 : : struct rte_mempool *mp = NULL;
750 : : int ret;
751 : :
752 : 1 : mz = rte_memzone_reserve("test_mempool", size, SOCKET_ID_ANY, 0);
753 [ - + ]: 1 : RTE_TEST_ASSERT_NOT_NULL(mz, "Cannot allocate memory");
754 : 1 : virt = mz->addr;
755 : 1 : iova = mz->iova;
756 : 1 : mp = rte_mempool_create_empty("empty", MEMPOOL_SIZE,
757 : : MEMPOOL_ELT_SIZE, 0, 0,
758 : : SOCKET_ID_ANY, RTE_MEMPOOL_F_NO_IOVA_CONTIG);
759 [ - + ]: 1 : RTE_TEST_ASSERT_NOT_NULL(mp, "Cannot create mempool: %s",
760 : : rte_strerror(rte_errno));
761 : 1 : rte_mempool_set_ops_byname(mp, rte_mbuf_best_mempool_ops(), NULL);
762 : :
763 [ - + ]: 1 : RTE_TEST_ASSERT(mp->flags & RTE_MEMPOOL_F_NON_IO,
764 : : "NON_IO flag is not set on an empty mempool");
765 : :
766 : : /*
767 : : * Always use valid IOVA so that populate() has no other reason
768 : : * to infer that the mempool cannot be used for IO.
769 : : */
770 : 1 : ret = rte_mempool_populate_iova(mp, virt, iova, size, NULL, NULL);
771 [ - + ]: 1 : RTE_TEST_ASSERT(ret > 0, "Failed to populate mempool: %s",
772 : : rte_strerror(-ret));
773 [ - + ]: 1 : RTE_TEST_ASSERT(mp->flags & RTE_MEMPOOL_F_NON_IO,
774 : : "NON_IO flag is not set when NO_IOVA_CONTIG is set");
775 : : ret = TEST_SUCCESS;
776 : 1 : exit:
777 : 1 : rte_mempool_free(mp);
778 : 1 : rte_memzone_free(mz);
779 : : return ret;
780 : : }
781 : :
782 : : static int
783 : 1 : test_mempool_flag_non_io_unset_when_populated_with_valid_iova(void)
784 : : {
785 : : const struct rte_memzone *mz = NULL;
786 : : void *virt;
787 : : rte_iova_t iova;
788 : 1 : size_t total_size = MEMPOOL_ELT_SIZE * MEMPOOL_SIZE;
789 : 1 : size_t block_size = total_size / 3;
790 : : struct rte_mempool *mp = NULL;
791 : : int ret;
792 : :
793 : : /*
794 : : * Since objects from the pool are never used in the test,
795 : : * we don't care for contiguous IOVA, on the other hand,
796 : : * requiring it could cause spurious test failures.
797 : : */
798 : 1 : mz = rte_memzone_reserve("test_mempool", total_size, SOCKET_ID_ANY, 0);
799 [ - + ]: 1 : RTE_TEST_ASSERT_NOT_NULL(mz, "Cannot allocate memory");
800 : 1 : virt = mz->addr;
801 : 1 : iova = mz->iova;
802 : 1 : mp = rte_mempool_create_empty("empty", MEMPOOL_SIZE,
803 : : MEMPOOL_ELT_SIZE, 0, 0,
804 : : SOCKET_ID_ANY, 0);
805 [ - + ]: 1 : RTE_TEST_ASSERT_NOT_NULL(mp, "Cannot create mempool: %s",
806 : : rte_strerror(rte_errno));
807 : :
808 [ - + ]: 1 : RTE_TEST_ASSERT(mp->flags & RTE_MEMPOOL_F_NON_IO,
809 : : "NON_IO flag is not set on an empty mempool");
810 : :
811 : 1 : ret = rte_mempool_populate_iova(mp, RTE_PTR_ADD(virt, 1 * block_size),
812 : : RTE_BAD_IOVA, block_size, NULL, NULL);
813 [ - + ]: 1 : RTE_TEST_ASSERT(ret > 0, "Failed to populate mempool: %s",
814 : : rte_strerror(-ret));
815 [ - + ]: 1 : RTE_TEST_ASSERT(mp->flags & RTE_MEMPOOL_F_NON_IO,
816 : : "NON_IO flag is not set when mempool is populated with only RTE_BAD_IOVA");
817 : :
818 : 1 : ret = rte_mempool_populate_iova(mp, virt, iova, block_size, NULL, NULL);
819 [ - + ]: 1 : RTE_TEST_ASSERT(ret > 0, "Failed to populate mempool: %s",
820 : : rte_strerror(-ret));
821 [ - + ]: 1 : RTE_TEST_ASSERT(!(mp->flags & RTE_MEMPOOL_F_NON_IO),
822 : : "NON_IO flag is not unset when mempool is populated with valid IOVA");
823 : :
824 : 1 : ret = rte_mempool_populate_iova(mp, RTE_PTR_ADD(virt, 2 * block_size),
825 : : RTE_BAD_IOVA, block_size, NULL, NULL);
826 [ - + ]: 1 : RTE_TEST_ASSERT(ret > 0, "Failed to populate mempool: %s",
827 : : rte_strerror(-ret));
828 [ - + ]: 1 : RTE_TEST_ASSERT(!(mp->flags & RTE_MEMPOOL_F_NON_IO),
829 : : "NON_IO flag is set even when some objects have valid IOVA");
830 : : ret = TEST_SUCCESS;
831 : :
832 : 1 : exit:
833 : 1 : rte_mempool_free(mp);
834 : 1 : rte_memzone_free(mz);
835 : : return ret;
836 : : }
837 : :
838 : : #pragma pop_macro("RTE_TEST_TRACE_FAILURE")
839 : :
840 : : static int
841 : 1 : test_mempool(void)
842 : : {
843 : : int ret = -1;
844 : : uint32_t nb_objs = 0;
845 : : uint32_t nb_mem_chunks = 0;
846 : : struct rte_mempool *mp_cache = NULL;
847 : : struct rte_mempool *mp_nocache = NULL;
848 : : struct rte_mempool *mp_stack_anon = NULL;
849 : : struct rte_mempool *mp_stack_mempool_iter = NULL;
850 : : struct rte_mempool *mp_stack = NULL;
851 : : struct rte_mempool *default_pool = NULL;
852 : 1 : struct mp_data cb_arg = {
853 : : .ret = -1
854 : : };
855 : 1 : const char *default_pool_ops = rte_mbuf_best_mempool_ops();
856 : :
857 : : /* create a mempool (without cache) */
858 : 1 : mp_nocache = rte_mempool_create("test_nocache", MEMPOOL_SIZE,
859 : : MEMPOOL_ELT_SIZE, 0, 0,
860 : : NULL, NULL,
861 : : my_obj_init, NULL,
862 : : SOCKET_ID_ANY, 0);
863 : :
864 [ - + ]: 1 : if (mp_nocache == NULL) {
865 : : printf("cannot allocate mp_nocache mempool\n");
866 : 0 : GOTO_ERR(ret, err);
867 : : }
868 : :
869 : : /* create a mempool (with cache) */
870 : 1 : mp_cache = rte_mempool_create("test_cache", MEMPOOL_SIZE,
871 : : MEMPOOL_ELT_SIZE,
872 : : RTE_MEMPOOL_CACHE_MAX_SIZE, 0,
873 : : NULL, NULL,
874 : : my_obj_init, NULL,
875 : : SOCKET_ID_ANY, 0);
876 : :
877 [ - + ]: 1 : if (mp_cache == NULL) {
878 : : printf("cannot allocate mp_cache mempool\n");
879 : 0 : GOTO_ERR(ret, err);
880 : : }
881 : :
882 : : /* create an empty mempool */
883 : 1 : mp_stack_anon = rte_mempool_create_empty("test_stack_anon",
884 : 1 : MEMPOOL_SIZE,
885 : : MEMPOOL_ELT_SIZE,
886 : : RTE_MEMPOOL_CACHE_MAX_SIZE, 0,
887 : : SOCKET_ID_ANY, 0);
888 : :
889 [ - + ]: 1 : if (mp_stack_anon == NULL)
890 : 0 : GOTO_ERR(ret, err);
891 : :
892 : : /* populate an empty mempool */
893 : 1 : ret = rte_mempool_populate_anon(mp_stack_anon);
894 : : printf("%s ret = %d\n", __func__, ret);
895 [ - + ]: 1 : if (ret < 0)
896 : 0 : GOTO_ERR(ret, err);
897 : :
898 : : /* Try to populate when already populated */
899 : 1 : ret = rte_mempool_populate_anon(mp_stack_anon);
900 [ - + ]: 1 : if (ret != 0)
901 : 0 : GOTO_ERR(ret, err);
902 : :
903 : : /* create a mempool */
904 : 1 : mp_stack_mempool_iter = rte_mempool_create("test_iter_obj",
905 : 1 : MEMPOOL_SIZE,
906 : : MEMPOOL_ELT_SIZE,
907 : : RTE_MEMPOOL_CACHE_MAX_SIZE, 0,
908 : : NULL, NULL,
909 : : my_obj_init, NULL,
910 : : SOCKET_ID_ANY, 0);
911 : :
912 [ - + ]: 1 : if (mp_stack_mempool_iter == NULL)
913 : 0 : GOTO_ERR(ret, err);
914 : :
915 : : /* test to initialize mempool objects and memory */
916 : 1 : nb_objs = rte_mempool_obj_iter(mp_stack_mempool_iter, my_obj_init,
917 : : NULL);
918 [ - + ]: 1 : if (nb_objs == 0)
919 : 0 : GOTO_ERR(ret, err);
920 : :
921 : 1 : nb_mem_chunks = rte_mempool_mem_iter(mp_stack_mempool_iter,
922 : : test_mp_mem_init, &cb_arg);
923 [ + - - + ]: 1 : if (nb_mem_chunks == 0 || cb_arg.ret < 0)
924 : 0 : GOTO_ERR(ret, err);
925 : :
926 : : /* create a mempool with an external handler */
927 : 1 : mp_stack = rte_mempool_create_empty("test_stack",
928 : 1 : MEMPOOL_SIZE,
929 : : MEMPOOL_ELT_SIZE,
930 : : RTE_MEMPOOL_CACHE_MAX_SIZE, 0,
931 : : SOCKET_ID_ANY, 0);
932 : :
933 [ - + ]: 1 : if (mp_stack == NULL) {
934 : : printf("cannot allocate mp_stack mempool\n");
935 : 0 : GOTO_ERR(ret, err);
936 : : }
937 [ - + ]: 1 : if (rte_mempool_set_ops_byname(mp_stack, "stack", NULL) < 0) {
938 : : printf("cannot set stack handler\n");
939 : 0 : GOTO_ERR(ret, err);
940 : : }
941 [ - + ]: 1 : if (rte_mempool_populate_default(mp_stack) < 0) {
942 : : printf("cannot populate mp_stack mempool\n");
943 : 0 : GOTO_ERR(ret, err);
944 : : }
945 : 1 : rte_mempool_obj_iter(mp_stack, my_obj_init, NULL);
946 : :
947 : : /* Create a mempool based on Default handler */
948 : : printf("Testing %s mempool handler\n", default_pool_ops);
949 : 1 : default_pool = rte_mempool_create_empty("default_pool",
950 : 1 : MEMPOOL_SIZE,
951 : : MEMPOOL_ELT_SIZE,
952 : : RTE_MEMPOOL_CACHE_MAX_SIZE, 0,
953 : : SOCKET_ID_ANY, 0);
954 : :
955 [ - + ]: 1 : if (default_pool == NULL) {
956 : : printf("cannot allocate default mempool\n");
957 : 0 : GOTO_ERR(ret, err);
958 : : }
959 [ - + ]: 1 : if (rte_mempool_set_ops_byname(default_pool,
960 : : default_pool_ops, NULL) < 0) {
961 : : printf("cannot set %s handler\n", default_pool_ops);
962 : 0 : GOTO_ERR(ret, err);
963 : : }
964 [ - + ]: 1 : if (rte_mempool_populate_default(default_pool) < 0) {
965 : : printf("cannot populate %s mempool\n", default_pool_ops);
966 : 0 : GOTO_ERR(ret, err);
967 : : }
968 : 1 : rte_mempool_obj_iter(default_pool, my_obj_init, NULL);
969 : :
970 : : /* retrieve the mempool from its name */
971 [ - + ]: 1 : if (rte_mempool_lookup("test_nocache") != mp_nocache) {
972 : : printf("Cannot lookup mempool from its name\n");
973 : 0 : GOTO_ERR(ret, err);
974 : : }
975 : :
976 : : printf("Walk into mempools:\n");
977 : 1 : rte_mempool_walk(walk_cb, NULL);
978 : :
979 : 1 : rte_mempool_list_dump(stdout);
980 : :
981 : : /* basic tests without cache */
982 [ - + ]: 1 : if (test_mempool_basic(mp_nocache, 0) < 0)
983 : 0 : GOTO_ERR(ret, err);
984 : :
985 : : /* basic tests with cache */
986 [ - + ]: 1 : if (test_mempool_basic(mp_cache, 0) < 0)
987 : 0 : GOTO_ERR(ret, err);
988 : :
989 : : /* basic tests with user-owned cache */
990 [ - + ]: 1 : if (test_mempool_basic(mp_nocache, 1) < 0)
991 : 0 : GOTO_ERR(ret, err);
992 : :
993 : : /* more basic tests without cache */
994 [ - + ]: 1 : if (test_mempool_basic_ex(mp_nocache) < 0)
995 : 0 : GOTO_ERR(ret, err);
996 : :
997 : : /* mempool operation test based on single producer and single consumer */
998 [ - + ]: 1 : if (test_mempool_sp_sc() < 0)
999 : 0 : GOTO_ERR(ret, err);
1000 : :
1001 [ - + ]: 1 : if (test_mempool_creation_with_exceeded_cache_size() < 0)
1002 : 0 : GOTO_ERR(ret, err);
1003 : :
1004 [ - + ]: 1 : if (test_mempool_creation_with_invalid_flags() < 0)
1005 : 0 : GOTO_ERR(ret, err);
1006 : :
1007 [ - + ]: 1 : if (test_mempool_same_name_twice_creation() < 0)
1008 : 0 : GOTO_ERR(ret, err);
1009 : :
1010 : : /* test the stack handler */
1011 [ - + ]: 1 : if (test_mempool_basic(mp_stack, 1) < 0)
1012 : 0 : GOTO_ERR(ret, err);
1013 : :
1014 [ - + ]: 1 : if (test_mempool_basic(default_pool, 1) < 0)
1015 : 0 : GOTO_ERR(ret, err);
1016 : :
1017 : : /* test mempool event callbacks */
1018 [ - + ]: 1 : if (test_mempool_events(rte_mempool_populate_default) < 0)
1019 : 0 : GOTO_ERR(ret, err);
1020 [ - + ]: 1 : if (test_mempool_events(rte_mempool_populate_anon) < 0)
1021 : 0 : GOTO_ERR(ret, err);
1022 [ - + ]: 1 : if (test_mempool_events_safety() < 0)
1023 : 0 : GOTO_ERR(ret, err);
1024 : :
1025 : : /* test NON_IO flag inference */
1026 [ - + ]: 1 : if (test_mempool_flag_non_io_set_when_no_iova_contig_set() < 0)
1027 : 0 : GOTO_ERR(ret, err);
1028 [ - + ]: 1 : if (test_mempool_flag_non_io_unset_when_populated_with_valid_iova() < 0)
1029 : 0 : GOTO_ERR(ret, err);
1030 : :
1031 : 1 : rte_mempool_list_dump(stdout);
1032 : :
1033 : : ret = 0;
1034 : :
1035 : 1 : err:
1036 : 1 : rte_mempool_free(mp_nocache);
1037 : 1 : rte_mempool_free(mp_cache);
1038 : 1 : rte_mempool_free(mp_stack_anon);
1039 : 1 : rte_mempool_free(mp_stack_mempool_iter);
1040 : 1 : rte_mempool_free(mp_stack);
1041 : 1 : rte_mempool_free(default_pool);
1042 : :
1043 : 1 : return ret;
1044 : : }
1045 : :
1046 : 235 : REGISTER_FAST_TEST(mempool_autotest, false, true, test_mempool);
|