DPDK  18.05.1
rte_mempool.h
Go to the documentation of this file.
1 /* SPDX-License-Identifier: BSD-3-Clause
2  * Copyright(c) 2010-2014 Intel Corporation.
3  * Copyright(c) 2016 6WIND S.A.
4  */
5 
6 #ifndef _RTE_MEMPOOL_H_
7 #define _RTE_MEMPOOL_H_
8 
36 #include <stdio.h>
37 #include <stdlib.h>
38 #include <stdint.h>
39 #include <errno.h>
40 #include <inttypes.h>
41 #include <sys/queue.h>
42 
43 #include <rte_config.h>
44 #include <rte_spinlock.h>
45 #include <rte_log.h>
46 #include <rte_debug.h>
47 #include <rte_lcore.h>
48 #include <rte_memory.h>
49 #include <rte_branch_prediction.h>
50 #include <rte_ring.h>
51 #include <rte_memcpy.h>
52 #include <rte_common.h>
53 
54 #ifdef __cplusplus
55 extern "C" {
56 #endif
57 
58 #define RTE_MEMPOOL_HEADER_COOKIE1 0xbadbadbadadd2e55ULL
59 #define RTE_MEMPOOL_HEADER_COOKIE2 0xf2eef2eedadd2e55ULL
60 #define RTE_MEMPOOL_TRAILER_COOKIE 0xadd2e55badbadbadULL
62 #ifdef RTE_LIBRTE_MEMPOOL_DEBUG
63 
66 struct rte_mempool_debug_stats {
67  uint64_t put_bulk;
68  uint64_t put_objs;
69  uint64_t get_success_bulk;
70  uint64_t get_success_objs;
71  uint64_t get_fail_bulk;
72  uint64_t get_fail_objs;
74  uint64_t get_success_blks;
76  uint64_t get_fail_blks;
78 #endif
79 
84  uint32_t size;
85  uint32_t flushthresh;
86  uint32_t len;
87  /*
88  * Cache is allocated to this size to allow it to overflow in certain
89  * cases to avoid needless emptying of cache.
90  */
91  void *objs[RTE_MEMPOOL_CACHE_MAX_SIZE * 3];
93 
98  uint32_t elt_size;
99  uint32_t header_size;
100  uint32_t trailer_size;
101  uint32_t total_size;
103 };
104 
106 #define RTE_MEMPOOL_NAMESIZE (RTE_RING_NAMESIZE - \
107  sizeof(RTE_MEMPOOL_MZ_PREFIX) + 1)
108 #define RTE_MEMPOOL_MZ_PREFIX "MP_"
109 
110 /* "MP_<name>" */
111 #define RTE_MEMPOOL_MZ_FORMAT RTE_MEMPOOL_MZ_PREFIX "%s"
112 
113 #define MEMPOOL_PG_SHIFT_MAX (sizeof(uintptr_t) * CHAR_BIT - 1)
114 
116 #define MEMPOOL_PG_NUM_DEFAULT 1
117 
118 #ifndef RTE_MEMPOOL_ALIGN
119 #define RTE_MEMPOOL_ALIGN RTE_CACHE_LINE_SIZE
120 #endif
121 
122 #define RTE_MEMPOOL_ALIGN_MASK (RTE_MEMPOOL_ALIGN - 1)
123 
135  struct rte_mempool *mp;
137  union {
140  };
141 #ifdef RTE_LIBRTE_MEMPOOL_DEBUG
142  uint64_t cookie;
143 #endif
144 };
145 
149 STAILQ_HEAD(rte_mempool_objhdr_list, rte_mempool_objhdr);
150 
151 #ifdef RTE_LIBRTE_MEMPOOL_DEBUG
152 
159 struct rte_mempool_objtlr {
160  uint64_t cookie;
161 };
162 
163 #endif
164 
168 STAILQ_HEAD(rte_mempool_memhdr_list, rte_mempool_memhdr);
169 
174  void *opaque);
175 
184  struct rte_mempool *mp;
185  void *addr;
187  union {
190  };
191  size_t len;
193  void *opaque;
194 };
195 
207  unsigned int contig_block_size;
209 
213 struct rte_mempool {
214  /*
215  * Note: this field kept the RTE_MEMZONE_NAMESIZE size due to ABI
216  * compatibility requirements, it could be changed to
217  * RTE_MEMPOOL_NAMESIZE next time the ABI changes
218  */
221  union {
222  void *pool_data;
223  uint64_t pool_id;
224  };
225  void *pool_config;
226  const struct rte_memzone *mz;
227  unsigned int flags;
228  int socket_id;
229  uint32_t size;
230  uint32_t cache_size;
233  uint32_t elt_size;
234  uint32_t header_size;
235  uint32_t trailer_size;
237  unsigned private_data_size;
245  int32_t ops_index;
246 
249  uint32_t populated_size;
250  struct rte_mempool_objhdr_list elt_list;
251  uint32_t nb_mem_chunks;
252  struct rte_mempool_memhdr_list mem_list;
254 #ifdef RTE_LIBRTE_MEMPOOL_DEBUG
255 
256  struct rte_mempool_debug_stats stats[RTE_MAX_LCORE];
257 #endif
259 
260 #define MEMPOOL_F_NO_SPREAD 0x0001
261 #define MEMPOOL_F_NO_CACHE_ALIGN 0x0002
262 #define MEMPOOL_F_SP_PUT 0x0004
263 #define MEMPOOL_F_SC_GET 0x0008
264 #define MEMPOOL_F_POOL_CREATED 0x0010
265 #define MEMPOOL_F_NO_IOVA_CONTIG 0x0020
266 #define MEMPOOL_F_NO_PHYS_CONTIG MEMPOOL_F_NO_IOVA_CONTIG /* deprecated */
267 
278 #ifdef RTE_LIBRTE_MEMPOOL_DEBUG
279 #define __MEMPOOL_STAT_ADD(mp, name, n) do { \
280  unsigned __lcore_id = rte_lcore_id(); \
281  if (__lcore_id < RTE_MAX_LCORE) { \
282  mp->stats[__lcore_id].name##_objs += n; \
283  mp->stats[__lcore_id].name##_bulk += 1; \
284  } \
285  } while(0)
286 #define __MEMPOOL_CONTIG_BLOCKS_STAT_ADD(mp, name, n) do { \
287  unsigned int __lcore_id = rte_lcore_id(); \
288  if (__lcore_id < RTE_MAX_LCORE) { \
289  mp->stats[__lcore_id].name##_blks += n; \
290  mp->stats[__lcore_id].name##_bulk += 1; \
291  } \
292  } while (0)
293 #else
294 #define __MEMPOOL_STAT_ADD(mp, name, n) do {} while(0)
295 #define __MEMPOOL_CONTIG_BLOCKS_STAT_ADD(mp, name, n) do {} while (0)
296 #endif
297 
306 #define MEMPOOL_HEADER_SIZE(mp, cs) \
307  (sizeof(*(mp)) + (((cs) == 0) ? 0 : \
308  (sizeof(struct rte_mempool_cache) * RTE_MAX_LCORE)))
309 
310 /* return the header of a mempool object (internal) */
311 static inline struct rte_mempool_objhdr *__mempool_get_header(void *obj)
312 {
313  return (struct rte_mempool_objhdr *)RTE_PTR_SUB(obj,
314  sizeof(struct rte_mempool_objhdr));
315 }
316 
326 static inline struct rte_mempool *rte_mempool_from_obj(void *obj)
327 {
328  struct rte_mempool_objhdr *hdr = __mempool_get_header(obj);
329  return hdr->mp;
330 }
331 
332 /* return the trailer of a mempool object (internal) */
333 static inline struct rte_mempool_objtlr *__mempool_get_trailer(void *obj)
334 {
335  struct rte_mempool *mp = rte_mempool_from_obj(obj);
336  return (struct rte_mempool_objtlr *)RTE_PTR_ADD(obj, mp->elt_size);
337 }
338 
353 void rte_mempool_check_cookies(const struct rte_mempool *mp,
354  void * const *obj_table_const, unsigned n, int free);
355 
356 #ifdef RTE_LIBRTE_MEMPOOL_DEBUG
357 #define __mempool_check_cookies(mp, obj_table_const, n, free) \
358  rte_mempool_check_cookies(mp, obj_table_const, n, free)
359 #else
360 #define __mempool_check_cookies(mp, obj_table_const, n, free) do {} while(0)
361 #endif /* RTE_LIBRTE_MEMPOOL_DEBUG */
362 
382  void * const *first_obj_table_const, unsigned int n, int free);
383 
384 #ifdef RTE_LIBRTE_MEMPOOL_DEBUG
385 #define __mempool_contig_blocks_check_cookies(mp, first_obj_table_const, n, \
386  free) \
387  rte_mempool_contig_blocks_check_cookies(mp, first_obj_table_const, n, \
388  free)
389 #else
390 #define __mempool_contig_blocks_check_cookies(mp, first_obj_table_const, n, \
391  free) \
392  do {} while (0)
393 #endif /* RTE_LIBRTE_MEMPOOL_DEBUG */
394 
395 #define RTE_MEMPOOL_OPS_NAMESIZE 32
407 typedef int (*rte_mempool_alloc_t)(struct rte_mempool *mp);
408 
412 typedef void (*rte_mempool_free_t)(struct rte_mempool *mp);
413 
417 typedef int (*rte_mempool_enqueue_t)(struct rte_mempool *mp,
418  void * const *obj_table, unsigned int n);
419 
423 typedef int (*rte_mempool_dequeue_t)(struct rte_mempool *mp,
424  void **obj_table, unsigned int n);
425 
433  void **first_obj_table, unsigned int n);
434 
438 typedef unsigned (*rte_mempool_get_count)(const struct rte_mempool *mp);
439 
463 typedef ssize_t (*rte_mempool_calc_mem_size_t)(const struct rte_mempool *mp,
464  uint32_t obj_num, uint32_t pg_shift,
465  size_t *min_chunk_size, size_t *align);
466 
486 ssize_t rte_mempool_op_calc_mem_size_default(const struct rte_mempool *mp,
487  uint32_t obj_num, uint32_t pg_shift,
488  size_t *min_chunk_size, size_t *align);
489 
509 size_t rte_mempool_calc_mem_size_helper(uint32_t elt_num, size_t total_elt_sz,
510  uint32_t pg_shift);
511 
524 typedef void (rte_mempool_populate_obj_cb_t)(struct rte_mempool *mp,
525  void *opaque, void *vaddr, rte_iova_t iova);
526 
555 typedef int (*rte_mempool_populate_t)(struct rte_mempool *mp,
556  unsigned int max_objs,
557  void *vaddr, rte_iova_t iova, size_t len,
558  rte_mempool_populate_obj_cb_t *obj_cb, void *obj_cb_arg);
559 
565  unsigned int max_objs,
566  void *vaddr, rte_iova_t iova, size_t len,
567  rte_mempool_populate_obj_cb_t *obj_cb, void *obj_cb_arg);
568 
575 typedef int (*rte_mempool_get_info_t)(const struct rte_mempool *mp,
576  struct rte_mempool_info *info);
577 
578 
606 
607 #define RTE_MEMPOOL_MAX_OPS_IDX 16
618 struct rte_mempool_ops_table {
620  uint32_t num_ops;
626 
629 
639 static inline struct rte_mempool_ops *
640 rte_mempool_get_ops(int ops_index)
641 {
642  RTE_VERIFY((ops_index >= 0) && (ops_index < RTE_MEMPOOL_MAX_OPS_IDX));
643 
644  return &rte_mempool_ops_table.ops[ops_index];
645 }
646 
656 int
657 rte_mempool_ops_alloc(struct rte_mempool *mp);
658 
672 static inline int
673 rte_mempool_ops_dequeue_bulk(struct rte_mempool *mp,
674  void **obj_table, unsigned n)
675 {
676  struct rte_mempool_ops *ops;
677 
678  ops = rte_mempool_get_ops(mp->ops_index);
679  return ops->dequeue(mp, obj_table, n);
680 }
681 
695 static inline int
696 rte_mempool_ops_dequeue_contig_blocks(struct rte_mempool *mp,
697  void **first_obj_table, unsigned int n)
698 {
699  struct rte_mempool_ops *ops;
700 
701  ops = rte_mempool_get_ops(mp->ops_index);
702  RTE_ASSERT(ops->dequeue_contig_blocks != NULL);
703  return ops->dequeue_contig_blocks(mp, first_obj_table, n);
704 }
705 
719 static inline int
720 rte_mempool_ops_enqueue_bulk(struct rte_mempool *mp, void * const *obj_table,
721  unsigned n)
722 {
723  struct rte_mempool_ops *ops;
724 
725  ops = rte_mempool_get_ops(mp->ops_index);
726  return ops->enqueue(mp, obj_table, n);
727 }
728 
737 unsigned
738 rte_mempool_ops_get_count(const struct rte_mempool *mp);
739 
759 ssize_t rte_mempool_ops_calc_mem_size(const struct rte_mempool *mp,
760  uint32_t obj_num, uint32_t pg_shift,
761  size_t *min_chunk_size, size_t *align);
762 
786 int rte_mempool_ops_populate(struct rte_mempool *mp, unsigned int max_objs,
787  void *vaddr, rte_iova_t iova, size_t len,
789  void *obj_cb_arg);
790 
806 __rte_experimental
807 int rte_mempool_ops_get_info(const struct rte_mempool *mp,
808  struct rte_mempool_info *info);
809 
816 void
817 rte_mempool_ops_free(struct rte_mempool *mp);
818 
836 int
837 rte_mempool_set_ops_byname(struct rte_mempool *mp, const char *name,
838  void *pool_config);
839 
850 int rte_mempool_register_ops(const struct rte_mempool_ops *ops);
851 
857 #define MEMPOOL_REGISTER_OPS(ops) \
858  void mp_hdlr_init_##ops(void); \
859  void __attribute__((constructor, used)) mp_hdlr_init_##ops(void)\
860  { \
861  rte_mempool_register_ops(&ops); \
862  }
863 
869 typedef void (rte_mempool_obj_cb_t)(struct rte_mempool *mp,
870  void *opaque, void *obj, unsigned obj_idx);
871 typedef rte_mempool_obj_cb_t rte_mempool_obj_ctor_t; /* compat */
872 
878 typedef void (rte_mempool_mem_cb_t)(struct rte_mempool *mp,
879  void *opaque, struct rte_mempool_memhdr *memhdr,
880  unsigned mem_idx);
881 
888 typedef void (rte_mempool_ctor_t)(struct rte_mempool *, void *);
889 
969 struct rte_mempool *
970 rte_mempool_create(const char *name, unsigned n, unsigned elt_size,
971  unsigned cache_size, unsigned private_data_size,
972  rte_mempool_ctor_t *mp_init, void *mp_init_arg,
973  rte_mempool_obj_cb_t *obj_init, void *obj_init_arg,
974  int socket_id, unsigned flags);
975 
1035 __rte_deprecated
1036 struct rte_mempool *
1037 rte_mempool_xmem_create(const char *name, unsigned n, unsigned elt_size,
1038  unsigned cache_size, unsigned private_data_size,
1039  rte_mempool_ctor_t *mp_init, void *mp_init_arg,
1040  rte_mempool_obj_cb_t *obj_init, void *obj_init_arg,
1041  int socket_id, unsigned flags, void *vaddr,
1042  const rte_iova_t iova[], uint32_t pg_num, uint32_t pg_shift);
1043 
1078 struct rte_mempool *
1079 rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size,
1080  unsigned cache_size, unsigned private_data_size,
1081  int socket_id, unsigned flags);
1092 void
1093 rte_mempool_free(struct rte_mempool *mp);
1094 
1122 int rte_mempool_populate_iova(struct rte_mempool *mp, char *vaddr,
1123  rte_iova_t iova, size_t len, rte_mempool_memchunk_free_cb_t *free_cb,
1124  void *opaque);
1125 
1126 __rte_deprecated
1127 int rte_mempool_populate_phys(struct rte_mempool *mp, char *vaddr,
1128  phys_addr_t paddr, size_t len, rte_mempool_memchunk_free_cb_t *free_cb,
1129  void *opaque);
1130 
1158 __rte_deprecated
1159 int rte_mempool_populate_iova_tab(struct rte_mempool *mp, char *vaddr,
1160  const rte_iova_t iova[], uint32_t pg_num, uint32_t pg_shift,
1161  rte_mempool_memchunk_free_cb_t *free_cb, void *opaque);
1162 
1163 __rte_deprecated
1164 int rte_mempool_populate_phys_tab(struct rte_mempool *mp, char *vaddr,
1165  const phys_addr_t paddr[], uint32_t pg_num, uint32_t pg_shift,
1166  rte_mempool_memchunk_free_cb_t *free_cb, void *opaque);
1167 
1192 int
1193 rte_mempool_populate_virt(struct rte_mempool *mp, char *addr,
1194  size_t len, size_t pg_sz, rte_mempool_memchunk_free_cb_t *free_cb,
1195  void *opaque);
1196 
1211 
1225 int rte_mempool_populate_anon(struct rte_mempool *mp);
1226 
1242 uint32_t rte_mempool_obj_iter(struct rte_mempool *mp,
1243  rte_mempool_obj_cb_t *obj_cb, void *obj_cb_arg);
1244 
1260 uint32_t rte_mempool_mem_iter(struct rte_mempool *mp,
1261  rte_mempool_mem_cb_t *mem_cb, void *mem_cb_arg);
1262 
1271 void rte_mempool_dump(FILE *f, struct rte_mempool *mp);
1272 
1287 struct rte_mempool_cache *
1288 rte_mempool_cache_create(uint32_t size, int socket_id);
1289 
1296 void
1298 
1309 static __rte_always_inline struct rte_mempool_cache *
1310 rte_mempool_default_cache(struct rte_mempool *mp, unsigned lcore_id)
1311 {
1312  if (mp->cache_size == 0)
1313  return NULL;
1314 
1315  if (lcore_id >= RTE_MAX_LCORE)
1316  return NULL;
1317 
1318  return &mp->local_cache[lcore_id];
1319 }
1320 
1329 static __rte_always_inline void
1331  struct rte_mempool *mp)
1332 {
1333  if (cache == NULL)
1334  cache = rte_mempool_default_cache(mp, rte_lcore_id());
1335  if (cache == NULL || cache->len == 0)
1336  return;
1337  rte_mempool_ops_enqueue_bulk(mp, cache->objs, cache->len);
1338  cache->len = 0;
1339 }
1340 
1353 static __rte_always_inline void
1354 __mempool_generic_put(struct rte_mempool *mp, void * const *obj_table,
1355  unsigned int n, struct rte_mempool_cache *cache)
1356 {
1357  void **cache_objs;
1358 
1359  /* increment stat now, adding in mempool always success */
1360  __MEMPOOL_STAT_ADD(mp, put, n);
1361 
1362  /* No cache provided or if put would overflow mem allocated for cache */
1363  if (unlikely(cache == NULL || n > RTE_MEMPOOL_CACHE_MAX_SIZE))
1364  goto ring_enqueue;
1365 
1366  cache_objs = &cache->objs[cache->len];
1367 
1368  /*
1369  * The cache follows the following algorithm
1370  * 1. Add the objects to the cache
1371  * 2. Anything greater than the cache min value (if it crosses the
1372  * cache flush threshold) is flushed to the ring.
1373  */
1374 
1375  /* Add elements back into the cache */
1376  rte_memcpy(&cache_objs[0], obj_table, sizeof(void *) * n);
1377 
1378  cache->len += n;
1379 
1380  if (cache->len >= cache->flushthresh) {
1381  rte_mempool_ops_enqueue_bulk(mp, &cache->objs[cache->size],
1382  cache->len - cache->size);
1383  cache->len = cache->size;
1384  }
1385 
1386  return;
1387 
1388 ring_enqueue:
1389 
1390  /* push remaining objects in ring */
1391 #ifdef RTE_LIBRTE_MEMPOOL_DEBUG
1392  if (rte_mempool_ops_enqueue_bulk(mp, obj_table, n) < 0)
1393  rte_panic("cannot put objects in mempool\n");
1394 #else
1395  rte_mempool_ops_enqueue_bulk(mp, obj_table, n);
1396 #endif
1397 }
1398 
1399 
1412 static __rte_always_inline void
1413 rte_mempool_generic_put(struct rte_mempool *mp, void * const *obj_table,
1414  unsigned int n, struct rte_mempool_cache *cache)
1415 {
1416  __mempool_check_cookies(mp, obj_table, n, 0);
1417  __mempool_generic_put(mp, obj_table, n, cache);
1418 }
1419 
1434 static __rte_always_inline void
1435 rte_mempool_put_bulk(struct rte_mempool *mp, void * const *obj_table,
1436  unsigned int n)
1437 {
1438  struct rte_mempool_cache *cache;
1439  cache = rte_mempool_default_cache(mp, rte_lcore_id());
1440  rte_mempool_generic_put(mp, obj_table, n, cache);
1441 }
1442 
1455 static __rte_always_inline void
1456 rte_mempool_put(struct rte_mempool *mp, void *obj)
1457 {
1458  rte_mempool_put_bulk(mp, &obj, 1);
1459 }
1460 
1475 static __rte_always_inline int
1476 __mempool_generic_get(struct rte_mempool *mp, void **obj_table,
1477  unsigned int n, struct rte_mempool_cache *cache)
1478 {
1479  int ret;
1480  uint32_t index, len;
1481  void **cache_objs;
1482 
1483  /* No cache provided or cannot be satisfied from cache */
1484  if (unlikely(cache == NULL || n >= cache->size))
1485  goto ring_dequeue;
1486 
1487  cache_objs = cache->objs;
1488 
1489  /* Can this be satisfied from the cache? */
1490  if (cache->len < n) {
1491  /* No. Backfill the cache first, and then fill from it */
1492  uint32_t req = n + (cache->size - cache->len);
1493 
1494  /* How many do we require i.e. number to fill the cache + the request */
1495  ret = rte_mempool_ops_dequeue_bulk(mp,
1496  &cache->objs[cache->len], req);
1497  if (unlikely(ret < 0)) {
1498  /*
1499  * In the offchance that we are buffer constrained,
1500  * where we are not able to allocate cache + n, go to
1501  * the ring directly. If that fails, we are truly out of
1502  * buffers.
1503  */
1504  goto ring_dequeue;
1505  }
1506 
1507  cache->len += req;
1508  }
1509 
1510  /* Now fill in the response ... */
1511  for (index = 0, len = cache->len - 1; index < n; ++index, len--, obj_table++)
1512  *obj_table = cache_objs[len];
1513 
1514  cache->len -= n;
1515 
1516  __MEMPOOL_STAT_ADD(mp, get_success, n);
1517 
1518  return 0;
1519 
1520 ring_dequeue:
1521 
1522  /* get remaining objects from ring */
1523  ret = rte_mempool_ops_dequeue_bulk(mp, obj_table, n);
1524 
1525  if (ret < 0)
1526  __MEMPOOL_STAT_ADD(mp, get_fail, n);
1527  else
1528  __MEMPOOL_STAT_ADD(mp, get_success, n);
1529 
1530  return ret;
1531 }
1532 
1553 static __rte_always_inline int
1554 rte_mempool_generic_get(struct rte_mempool *mp, void **obj_table,
1555  unsigned int n, struct rte_mempool_cache *cache)
1556 {
1557  int ret;
1558  ret = __mempool_generic_get(mp, obj_table, n, cache);
1559  if (ret == 0)
1560  __mempool_check_cookies(mp, obj_table, n, 1);
1561  return ret;
1562 }
1563 
1586 static __rte_always_inline int
1587 rte_mempool_get_bulk(struct rte_mempool *mp, void **obj_table, unsigned int n)
1588 {
1589  struct rte_mempool_cache *cache;
1590  cache = rte_mempool_default_cache(mp, rte_lcore_id());
1591  return rte_mempool_generic_get(mp, obj_table, n, cache);
1592 }
1593 
1614 static __rte_always_inline int
1615 rte_mempool_get(struct rte_mempool *mp, void **obj_p)
1616 {
1617  return rte_mempool_get_bulk(mp, obj_p, 1);
1618 }
1619 
1644 static __rte_always_inline int
1645 __rte_experimental
1647  void **first_obj_table, unsigned int n)
1648 {
1649  int ret;
1650 
1651  ret = rte_mempool_ops_dequeue_contig_blocks(mp, first_obj_table, n);
1652  if (ret == 0) {
1653  __MEMPOOL_CONTIG_BLOCKS_STAT_ADD(mp, get_success, n);
1654  __mempool_contig_blocks_check_cookies(mp, first_obj_table, n,
1655  1);
1656  } else {
1657  __MEMPOOL_CONTIG_BLOCKS_STAT_ADD(mp, get_fail, n);
1658  }
1659 
1660  return ret;
1661 }
1662 
1675 unsigned int rte_mempool_avail_count(const struct rte_mempool *mp);
1676 
1689 unsigned int
1690 rte_mempool_in_use_count(const struct rte_mempool *mp);
1691 
1705 static inline int
1707 {
1708  return !!(rte_mempool_avail_count(mp) == mp->size);
1709 }
1710 
1724 static inline int
1726 {
1727  return !!(rte_mempool_avail_count(mp) == 0);
1728 }
1729 
1740 static inline rte_iova_t
1741 rte_mempool_virt2iova(const void *elt)
1742 {
1743  const struct rte_mempool_objhdr *hdr;
1744  hdr = (const struct rte_mempool_objhdr *)RTE_PTR_SUB(elt,
1745  sizeof(*hdr));
1746  return hdr->iova;
1747 }
1748 
1749 __rte_deprecated
1750 static inline phys_addr_t
1751 rte_mempool_virt2phy(__rte_unused const struct rte_mempool *mp, const void *elt)
1752 {
1753  return rte_mempool_virt2iova(elt);
1754 }
1755 
1766 void rte_mempool_audit(struct rte_mempool *mp);
1767 
1776 static inline void *rte_mempool_get_priv(struct rte_mempool *mp)
1777 {
1778  return (char *)mp +
1780 }
1781 
1788 void rte_mempool_list_dump(FILE *f);
1789 
1802 struct rte_mempool *rte_mempool_lookup(const char *name);
1803 
1821 uint32_t rte_mempool_calc_obj_size(uint32_t elt_size, uint32_t flags,
1822  struct rte_mempool_objsz *sz);
1823 
1848 __rte_deprecated
1849 size_t rte_mempool_xmem_size(uint32_t elt_num, size_t total_elt_sz,
1850  uint32_t pg_shift, unsigned int flags);
1851 
1881 __rte_deprecated
1882 ssize_t rte_mempool_xmem_usage(void *vaddr, uint32_t elt_num,
1883  size_t total_elt_sz, const rte_iova_t iova[], uint32_t pg_num,
1884  uint32_t pg_shift, unsigned int flags);
1885 
1894 void rte_mempool_walk(void (*func)(struct rte_mempool *, void *arg),
1895  void *arg);
1896 
1897 #ifdef __cplusplus
1898 }
1899 #endif
1900 
1901 #endif /* _RTE_MEMPOOL_H_ */