1 /* SPDX-License-Identifier: BSD-3-Clause
2 * Copyright(c) 2010-2018 Intel Corporation
9 #include <rte_string_fns.h>
13 #define BUFFER_SIZE_MIN (sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM)
15 static struct mempool_list mempool_list;
20 TAILQ_INIT(&mempool_list);
26 mempool_find(const char *name)
28 struct mempool *mempool;
33 TAILQ_FOREACH(mempool, &mempool_list, node)
34 if (strcmp(mempool->name, name) == 0)
41 mempool_create(const char *name, struct mempool_params *params)
43 struct mempool *mempool;
44 struct rte_mempool *m;
46 /* Check input params */
50 (params->buffer_size < BUFFER_SIZE_MIN) ||
51 (params->pool_size == 0))
55 m = rte_pktmbuf_pool_create(
60 params->buffer_size - sizeof(struct rte_mbuf),
67 mempool = calloc(1, sizeof(struct mempool));
68 if (mempool == NULL) {
74 strlcpy(mempool->name, name, sizeof(mempool->name));
76 mempool->buffer_size = params->buffer_size;
78 /* Node add to list */
79 TAILQ_INSERT_TAIL(&mempool_list, mempool, node);