#include <stdlib.h>
#include <string.h>
#include "mempool.h"
#define BUFFER_SIZE_MIN (sizeof(struct rte_mbuf) + RTE_PKTMBUF_HEADROOM)
static struct mempool_list mempool_list;
int
mempool_init(void)
{
TAILQ_INIT(&mempool_list);
return 0;
}
struct mempool *
mempool_find(const char *name)
{
struct mempool *mempool;
if (name == NULL)
return NULL;
TAILQ_FOREACH(mempool, &mempool_list, node)
if (strcmp(mempool->name, name) == 0)
return mempool;
return NULL;
}
struct mempool *
mempool_create(const char *name, struct mempool_params *params)
{
struct mempool *mempool;
(params == NULL) ||
(params->buffer_size < BUFFER_SIZE_MIN) ||
(params->pool_size == 0))
return NULL;
params->pool_size,
params->cache_size,
0,
params->buffer_size -
sizeof(
struct rte_mbuf),
params->cpu_id);
if (m == NULL)
return NULL;
mempool = calloc(1, sizeof(struct mempool));
if (mempool == NULL) {
return NULL;
}
strlcpy(mempool->name,
name,
sizeof(mempool->name));
mempool->m = m;
mempool->buffer_size = params->buffer_size;
TAILQ_INSERT_TAIL(&mempool_list, mempool, node);
return mempool;
}
struct rte_mempool * rte_pktmbuf_pool_create(const char *name, unsigned n, unsigned cache_size, uint16_t priv_size, uint16_t data_room_size, int socket_id)
void rte_mempool_free(struct rte_mempool *mp)
char name[RTE_MEMPOOL_NAMESIZE]