/* "MP_<name>" */
#define RTE_MEMPOOL_MZ_FORMAT RTE_MEMPOOL_MZ_PREFIX "%s"
-#define MEMPOOL_PG_SHIFT_MAX (sizeof(uintptr_t) * CHAR_BIT - 1)
+#define MEMPOOL_PG_SHIFT_MAX \
+ RTE_DEPRECATED(MEMPOOL_PG_SHIFT_MAX) (sizeof(uintptr_t) * CHAR_BIT - 1)
-/** Mempool over one chunk of physically continuous memory */
-#define MEMPOOL_PG_NUM_DEFAULT 1
+/** Deprecated. Mempool over one chunk of physically continuous memory */
+#define MEMPOOL_PG_NUM_DEFAULT RTE_DEPRECATED(MEMPOOL_PG_NUM_DEFAULT) 1
#ifndef RTE_MEMPOOL_ALIGN
/**
/** Internal: no object from the pool can be used for device IO (DMA). */
#define RTE_MEMPOOL_F_NON_IO 0x0040
+/**
+ * This macro lists all the mempool flags an application may request.
+ */
+#define RTE_MEMPOOL_VALID_USER_FLAGS (RTE_MEMPOOL_F_NO_SPREAD \
+ | RTE_MEMPOOL_F_NO_CACHE_ALIGN \
+ | RTE_MEMPOOL_F_SP_PUT \
+ | RTE_MEMPOOL_F_SC_GET \
+ | RTE_MEMPOOL_F_NO_IOVA_CONTIG \
+ )
/**
* @internal When debug is enabled, store some statistics.
*
* Number to add to the object-oriented statistics.
*/
#ifdef RTE_LIBRTE_MEMPOOL_DEBUG
-#define __MEMPOOL_STAT_ADD(mp, name, n) do { \
+#define RTE_MEMPOOL_STAT_ADD(mp, name, n) do { \
unsigned __lcore_id = rte_lcore_id(); \
if (__lcore_id < RTE_MAX_LCORE) { \
mp->stats[__lcore_id].name += n; \
} \
- } while(0)
+ } while (0)
#else
-#define __MEMPOOL_STAT_ADD(mp, name, n) do {} while(0)
+#define RTE_MEMPOOL_STAT_ADD(mp, name, n) do {} while (0)
#endif
/**
- * Calculate the size of the mempool header.
+ * @internal Calculate the size of the mempool header.
*
* @param mp
* Pointer to the memory pool.
* @param cs
* Size of the per-lcore cache.
*/
-#define MEMPOOL_HEADER_SIZE(mp, cs) \
+#define RTE_MEMPOOL_HEADER_SIZE(mp, cs) \
(sizeof(*(mp)) + (((cs) == 0) ? 0 : \
(sizeof(struct rte_mempool_cache) * RTE_MAX_LCORE)))
+/** Deprecated. Use RTE_MEMPOOL_HEADER_SIZE() for internal purposes only. */
+#define MEMPOOL_HEADER_SIZE(mp, cs) \
+ RTE_DEPRECATED(MEMPOOL_HEADER_SIZE) RTE_MEMPOOL_HEADER_SIZE(mp, cs)
+
/* return the header of a mempool object (internal) */
-static inline struct rte_mempool_objhdr *__mempool_get_header(void *obj)
+static inline struct rte_mempool_objhdr *
+rte_mempool_get_header(void *obj)
{
return (struct rte_mempool_objhdr *)RTE_PTR_SUB(obj,
sizeof(struct rte_mempool_objhdr));
*/
static inline struct rte_mempool *rte_mempool_from_obj(void *obj)
{
- struct rte_mempool_objhdr *hdr = __mempool_get_header(obj);
+ struct rte_mempool_objhdr *hdr = rte_mempool_get_header(obj);
return hdr->mp;
}
/* return the trailer of a mempool object (internal) */
-static inline struct rte_mempool_objtlr *__mempool_get_trailer(void *obj)
+static inline struct rte_mempool_objtlr *rte_mempool_get_trailer(void *obj)
{
struct rte_mempool *mp = rte_mempool_from_obj(obj);
return (struct rte_mempool_objtlr *)RTE_PTR_ADD(obj, mp->elt_size);
void * const *obj_table_const, unsigned n, int free);
#ifdef RTE_LIBRTE_MEMPOOL_DEBUG
-#define __mempool_check_cookies(mp, obj_table_const, n, free) \
+#define RTE_MEMPOOL_CHECK_COOKIES(mp, obj_table_const, n, free) \
rte_mempool_check_cookies(mp, obj_table_const, n, free)
#else
-#define __mempool_check_cookies(mp, obj_table_const, n, free) do {} while(0)
+#define RTE_MEMPOOL_CHECK_COOKIES(mp, obj_table_const, n, free) do {} while (0)
#endif /* RTE_LIBRTE_MEMPOOL_DEBUG */
/**
void * const *first_obj_table_const, unsigned int n, int free);
#ifdef RTE_LIBRTE_MEMPOOL_DEBUG
-#define __mempool_contig_blocks_check_cookies(mp, first_obj_table_const, n, \
- free) \
+#define RTE_MEMPOOL_CONTIG_BLOCKS_CHECK_COOKIES(mp, first_obj_table_const, n, \
+ free) \
rte_mempool_contig_blocks_check_cookies(mp, first_obj_table_const, n, \
free)
#else
-#define __mempool_contig_blocks_check_cookies(mp, first_obj_table_const, n, \
- free) \
+#define RTE_MEMPOOL_CONTIG_BLOCKS_CHECK_COOKIES(mp, first_obj_table_const, n, \
+ free) \
do {} while (0)
#endif /* RTE_LIBRTE_MEMPOOL_DEBUG */
ops = rte_mempool_get_ops(mp->ops_index);
ret = ops->dequeue(mp, obj_table, n);
if (ret == 0) {
- __MEMPOOL_STAT_ADD(mp, get_common_pool_bulk, 1);
- __MEMPOOL_STAT_ADD(mp, get_common_pool_objs, n);
+ RTE_MEMPOOL_STAT_ADD(mp, get_common_pool_bulk, 1);
+ RTE_MEMPOOL_STAT_ADD(mp, get_common_pool_objs, n);
}
return ret;
}
{
struct rte_mempool_ops *ops;
- __MEMPOOL_STAT_ADD(mp, put_common_pool_bulk, 1);
- __MEMPOOL_STAT_ADD(mp, put_common_pool_objs, n);
+ RTE_MEMPOOL_STAT_ADD(mp, put_common_pool_bulk, 1);
+ RTE_MEMPOOL_STAT_ADD(mp, put_common_pool_objs, n);
rte_mempool_trace_ops_enqueue_bulk(mp, obj_table, n);
ops = rte_mempool_get_ops(mp->ops_index);
return ops->enqueue(mp, obj_table, n);
* Note that the rte_mempool_register_ops fails silently here when
* more than RTE_MEMPOOL_MAX_OPS_IDX is registered.
*/
-#define MEMPOOL_REGISTER_OPS(ops) \
+#define RTE_MEMPOOL_REGISTER_OPS(ops) \
RTE_INIT(mp_hdlr_init_##ops) \
{ \
rte_mempool_register_ops(&ops); \
}
+/** Deprecated. Use RTE_MEMPOOL_REGISTER_OPS() instead. */
+#define MEMPOOL_REGISTER_OPS(ops) \
+ RTE_DEPRECATED(MEMPOOL_REGISTER_OPS) RTE_MEMPOOL_REGISTER_OPS(ops)
+
/**
* An object callback function for mempool.
*
* A pointer to a mempool cache structure. May be NULL if not needed.
*/
static __rte_always_inline void
-__mempool_generic_put(struct rte_mempool *mp, void * const *obj_table,
- unsigned int n, struct rte_mempool_cache *cache)
+rte_mempool_do_generic_put(struct rte_mempool *mp, void * const *obj_table,
+ unsigned int n, struct rte_mempool_cache *cache)
{
void **cache_objs;
/* increment stat now, adding in mempool always success */
- __MEMPOOL_STAT_ADD(mp, put_bulk, 1);
- __MEMPOOL_STAT_ADD(mp, put_objs, n);
+ RTE_MEMPOOL_STAT_ADD(mp, put_bulk, 1);
+ RTE_MEMPOOL_STAT_ADD(mp, put_objs, n);
/* No cache provided or if put would overflow mem allocated for cache */
if (unlikely(cache == NULL || n > RTE_MEMPOOL_CACHE_MAX_SIZE))
unsigned int n, struct rte_mempool_cache *cache)
{
rte_mempool_trace_generic_put(mp, obj_table, n, cache);
- __mempool_check_cookies(mp, obj_table, n, 0);
- __mempool_generic_put(mp, obj_table, n, cache);
+ RTE_MEMPOOL_CHECK_COOKIES(mp, obj_table, n, 0);
+ rte_mempool_do_generic_put(mp, obj_table, n, cache);
}
/**
* - <0: Error; code of ring dequeue function.
*/
static __rte_always_inline int
-__mempool_generic_get(struct rte_mempool *mp, void **obj_table,
- unsigned int n, struct rte_mempool_cache *cache)
+rte_mempool_do_generic_get(struct rte_mempool *mp, void **obj_table,
+ unsigned int n, struct rte_mempool_cache *cache)
{
int ret;
uint32_t index, len;
cache->len -= n;
- __MEMPOOL_STAT_ADD(mp, get_success_bulk, 1);
- __MEMPOOL_STAT_ADD(mp, get_success_objs, n);
+ RTE_MEMPOOL_STAT_ADD(mp, get_success_bulk, 1);
+ RTE_MEMPOOL_STAT_ADD(mp, get_success_objs, n);
return 0;
ret = rte_mempool_ops_dequeue_bulk(mp, obj_table, n);
if (ret < 0) {
- __MEMPOOL_STAT_ADD(mp, get_fail_bulk, 1);
- __MEMPOOL_STAT_ADD(mp, get_fail_objs, n);
+ RTE_MEMPOOL_STAT_ADD(mp, get_fail_bulk, 1);
+ RTE_MEMPOOL_STAT_ADD(mp, get_fail_objs, n);
} else {
- __MEMPOOL_STAT_ADD(mp, get_success_bulk, 1);
- __MEMPOOL_STAT_ADD(mp, get_success_objs, n);
+ RTE_MEMPOOL_STAT_ADD(mp, get_success_bulk, 1);
+ RTE_MEMPOOL_STAT_ADD(mp, get_success_objs, n);
}
return ret;
unsigned int n, struct rte_mempool_cache *cache)
{
int ret;
- ret = __mempool_generic_get(mp, obj_table, n, cache);
+ ret = rte_mempool_do_generic_get(mp, obj_table, n, cache);
if (ret == 0)
- __mempool_check_cookies(mp, obj_table, n, 1);
+ RTE_MEMPOOL_CHECK_COOKIES(mp, obj_table, n, 1);
rte_mempool_trace_generic_get(mp, obj_table, n, cache);
return ret;
}
ret = rte_mempool_ops_dequeue_contig_blocks(mp, first_obj_table, n);
if (ret == 0) {
- __MEMPOOL_STAT_ADD(mp, get_success_bulk, 1);
- __MEMPOOL_STAT_ADD(mp, get_success_blks, n);
- __mempool_contig_blocks_check_cookies(mp, first_obj_table, n,
- 1);
+ RTE_MEMPOOL_STAT_ADD(mp, get_success_bulk, 1);
+ RTE_MEMPOOL_STAT_ADD(mp, get_success_blks, n);
+ RTE_MEMPOOL_CONTIG_BLOCKS_CHECK_COOKIES(mp, first_obj_table, n,
+ 1);
} else {
- __MEMPOOL_STAT_ADD(mp, get_fail_bulk, 1);
- __MEMPOOL_STAT_ADD(mp, get_fail_blks, n);
+ RTE_MEMPOOL_STAT_ADD(mp, get_fail_bulk, 1);
+ RTE_MEMPOOL_STAT_ADD(mp, get_fail_blks, n);
}
rte_mempool_trace_get_contig_blocks(mp, first_obj_table, n);
static inline void *rte_mempool_get_priv(struct rte_mempool *mp)
{
return (char *)mp +
- MEMPOOL_HEADER_SIZE(mp, mp->cache_size);
+ RTE_MEMPOOL_HEADER_SIZE(mp, mp->cache_size);
}
/**