env: add spdk_mempool_create_ctor
Change-Id: I8b70d25d1b245bdb3f6fcd79599a2907a6d5bddc Signed-off-by: Ziye Yang <optimistyzy@gmail.com> Reviewed-on: https://review.gerrithub.io/391143 Tested-by: SPDK Automated Test System <sys_sgsw@intel.com> Reviewed-by: Jim Harris <james.r.harris@intel.com> Reviewed-by: Ben Walker <benjamin.walker@intel.com>
This commit is contained in:
parent
2a4d18e391
commit
c127a23690
@ -154,6 +154,28 @@ struct spdk_mempool;
|
|||||||
struct spdk_mempool *spdk_mempool_create(const char *name, size_t count,
|
struct spdk_mempool *spdk_mempool_create(const char *name, size_t count,
|
||||||
size_t ele_size, size_t cache_size, int socket_id);
|
size_t ele_size, size_t cache_size, int socket_id);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* An object callback function for mempool.
|
||||||
|
*
|
||||||
|
* Used by spdk_mempool_create_ctor
|
||||||
|
*/
|
||||||
|
typedef void (spdk_mempool_obj_cb_t)(struct spdk_mempool *mp,
|
||||||
|
void *opaque, void *obj, unsigned obj_idx);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Create a thread-safe memory pool with user provided initialization function and argument.
|
||||||
|
*
|
||||||
|
* \param cache_size How many elements may be cached in per-core caches. Use
|
||||||
|
* SPDK_MEMPOOL_DEFAULT_CACHE_SIZE for a reasonable default, or 0 for no
|
||||||
|
* per-core cache.
|
||||||
|
* \param socket_id Socket ID to allocate memory on, or SPDK_ENV_SOCKET_ID_ANY for any socket.
|
||||||
|
* \param obj_init User provided object calll back initialization function.
|
||||||
|
* \paam obj_init_arg User provided callback initialization function argument.
|
||||||
|
*/
|
||||||
|
struct spdk_mempool *spdk_mempool_create_ctor(const char *name, size_t count,
|
||||||
|
size_t ele_size, size_t cache_size, int socket_id,
|
||||||
|
spdk_mempool_obj_cb_t *obj_init, void *obj_init_arg);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the name of a mempool
|
* Get the name of a mempool
|
||||||
*/
|
*/
|
||||||
|
@ -150,8 +150,9 @@ spdk_memzone_dump(FILE *f)
|
|||||||
}
|
}
|
||||||
|
|
||||||
struct spdk_mempool *
|
struct spdk_mempool *
|
||||||
spdk_mempool_create(const char *name, size_t count,
|
spdk_mempool_create_ctor(const char *name, size_t count,
|
||||||
size_t ele_size, size_t cache_size, int socket_id)
|
size_t ele_size, size_t cache_size, int socket_id,
|
||||||
|
spdk_mempool_obj_cb_t *obj_init, void *obj_init_arg)
|
||||||
{
|
{
|
||||||
struct rte_mempool *mp;
|
struct rte_mempool *mp;
|
||||||
size_t tmp;
|
size_t tmp;
|
||||||
@ -171,12 +172,21 @@ spdk_mempool_create(const char *name, size_t count,
|
|||||||
}
|
}
|
||||||
|
|
||||||
mp = rte_mempool_create(name, count, ele_size, cache_size,
|
mp = rte_mempool_create(name, count, ele_size, cache_size,
|
||||||
0, NULL, NULL, NULL, NULL,
|
0, NULL, NULL, (rte_mempool_obj_cb_t *)obj_init, obj_init_arg,
|
||||||
socket_id, 0);
|
socket_id, 0);
|
||||||
|
|
||||||
return (struct spdk_mempool *)mp;
|
return (struct spdk_mempool *)mp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
struct spdk_mempool *
|
||||||
|
spdk_mempool_create(const char *name, size_t count,
|
||||||
|
size_t ele_size, size_t cache_size, int socket_id)
|
||||||
|
{
|
||||||
|
return spdk_mempool_create_ctor(name, count, ele_size, cache_size, socket_id,
|
||||||
|
NULL, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
char *
|
char *
|
||||||
spdk_mempool_get_name(struct spdk_mempool *mp)
|
spdk_mempool_get_name(struct spdk_mempool *mp)
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user