1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2018 Intel Corporation
12 #define BUFFER_SIZE_MIN (sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM)
14 static struct mempool_list mempool_list;
19 TAILQ_INIT(&mempool_list);
25 mempool_find(const char *name)
27 struct mempool *mempool;
32 TAILQ_FOREACH(mempool, &mempool_list, node)
33 if (strcmp(mempool->name, name) == 0)
40 mempool_create(const char *name, struct mempool_params *params)
42 struct mempool *mempool;
43 struct rte_mempool *m;
45 /* Check input params */
49 (params->buffer_size < BUFFER_SIZE_MIN) ||
50 (params->pool_size == 0))
54 m = rte_pktmbuf_pool_create(
59 params->buffer_size - sizeof(struct rte_mbuf),
66 mempool = calloc(1, sizeof(struct mempool));
67 if (mempool == NULL) {
73 strncpy(mempool->name, name, sizeof(mempool->name));
75 mempool->buffer_size = params->buffer_size;
77 /* Node add to list */
78 TAILQ_INSERT_TAIL(&mempool_list, mempool, node);