1 /* SPDX-License-Identifier: BSD-3-Clause 2 * Copyright (c) Intel Corporation. 3 * All rights reserved. 4 */ 5 6 #ifndef FTL_MEMPOOL_H 7 #define FTL_MEMPOOL_H 8 9 #include "spdk/stdinc.h" 10 11 /* TODO: Consider porting this mempool to general SPDK utils */ 12 13 /** 14 * @brief Creates custom FTL memory pool using DMA kind memory 15 * 16 * The pool is being initialized. 17 * 18 * @param count Count of element in the memory pool 19 * @param size Size of elements in the memory pool 20 * @param alignment Memory alignment of element in the memory pool 21 * @param socket_id It is the socket identifier in the case of NUMA. The value 22 * can be *SOCKET_ID_ANY* if there is no NUMA constraint for the reserved zone. 23 * 24 * @return Pointer to the memory pool 25 */ 26 struct ftl_mempool *ftl_mempool_create(size_t count, size_t size, 27 size_t alignment, int socket_id); 28 29 /** 30 * @brief Destroys the FTL memory pool 31 32 * @param mpool The memory pool to be destroyed 33 */ 34 void ftl_mempool_destroy(struct ftl_mempool *mpool); 35 36 /** 37 * @brief Gets (allocates) an element from the memory pool 38 * 39 * @param mpool The memory pool 40 * 41 * @return Element from memory pool. If memory pool empty it returns NULL. 42 */ 43 void *ftl_mempool_get(struct ftl_mempool *mpool); 44 45 /** 46 * @brief Puts (releases) the element to the memory pool 47 * 48 * @param mpool The memory pool 49 * @param element The element to be released 50 */ 51 void ftl_mempool_put(struct ftl_mempool *mpool, void *element); 52 53 #endif /* FTL_MEMPOOL_H */ 54