DPDK  17.02.1
rte_mempool.h
Go to the documentation of this file.
1 /*-
2  * BSD LICENSE
3  *
4  * Copyright(c) 2010-2014 Intel Corporation. All rights reserved.
5  * Copyright(c) 2016 6WIND S.A.
6  * All rights reserved.
7  *
8  * Redistribution and use in source and binary forms, with or without
9  * modification, are permitted provided that the following conditions
10  * are met:
11  *
12  * * Redistributions of source code must retain the above copyright
13  * notice, this list of conditions and the following disclaimer.
14  * * Redistributions in binary form must reproduce the above copyright
15  * notice, this list of conditions and the following disclaimer in
16  * the documentation and/or other materials provided with the
17  * distribution.
18  * * Neither the name of Intel Corporation nor the names of its
19  * contributors may be used to endorse or promote products derived
20  * from this software without specific prior written permission.
21  *
22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
25  * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
26  * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27  * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
28  * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30  * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
32  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33  */
34 
35 #ifndef _RTE_MEMPOOL_H_
36 #define _RTE_MEMPOOL_H_
37 
63 #include <stdio.h>
64 #include <stdlib.h>
65 #include <stdint.h>
66 #include <errno.h>
67 #include <inttypes.h>
68 #include <sys/queue.h>
69 
70 #include <rte_spinlock.h>
71 #include <rte_log.h>
72 #include <rte_debug.h>
73 #include <rte_lcore.h>
74 #include <rte_memory.h>
75 #include <rte_branch_prediction.h>
76 #include <rte_ring.h>
77 #include <rte_memcpy.h>
78 #include <rte_common.h>
79 
80 #ifdef __cplusplus
81 extern "C" {
82 #endif
83 
84 #define RTE_MEMPOOL_HEADER_COOKIE1 0xbadbadbadadd2e55ULL
85 #define RTE_MEMPOOL_HEADER_COOKIE2 0xf2eef2eedadd2e55ULL
86 #define RTE_MEMPOOL_TRAILER_COOKIE 0xadd2e55badbadbadULL
88 #ifdef RTE_LIBRTE_MEMPOOL_DEBUG
89 
92 struct rte_mempool_debug_stats {
93  uint64_t put_bulk;
94  uint64_t put_objs;
95  uint64_t get_success_bulk;
96  uint64_t get_success_objs;
97  uint64_t get_fail_bulk;
98  uint64_t get_fail_objs;
100 #endif
101 
106  uint32_t size;
107  uint32_t flushthresh;
108  uint32_t len;
109  /*
110  * Cache is allocated to this size to allow it to overflow in certain
111  * cases to avoid needless emptying of cache.
112  */
113  void *objs[RTE_MEMPOOL_CACHE_MAX_SIZE * 3];
115 
120  uint32_t elt_size;
121  uint32_t header_size;
122  uint32_t trailer_size;
123  uint32_t total_size;
125 };
126 
128 #define RTE_MEMPOOL_NAMESIZE (RTE_RING_NAMESIZE - \
129  sizeof(RTE_MEMPOOL_MZ_PREFIX) + 1)
130 #define RTE_MEMPOOL_MZ_PREFIX "MP_"
131 
132 /* "MP_<name>" */
133 #define RTE_MEMPOOL_MZ_FORMAT RTE_MEMPOOL_MZ_PREFIX "%s"
134 
135 #define MEMPOOL_PG_SHIFT_MAX (sizeof(uintptr_t) * CHAR_BIT - 1)
136 
138 #define MEMPOOL_PG_NUM_DEFAULT 1
139 
140 #ifndef RTE_MEMPOOL_ALIGN
141 #define RTE_MEMPOOL_ALIGN RTE_CACHE_LINE_SIZE
142 #endif
143 
144 #define RTE_MEMPOOL_ALIGN_MASK (RTE_MEMPOOL_ALIGN - 1)
145 
157  struct rte_mempool *mp;
159 #ifdef RTE_LIBRTE_MEMPOOL_DEBUG
160  uint64_t cookie;
161 #endif
162 };
163 
167 STAILQ_HEAD(rte_mempool_objhdr_list, rte_mempool_objhdr);
168 
169 #ifdef RTE_LIBRTE_MEMPOOL_DEBUG
170 
177 struct rte_mempool_objtlr {
178  uint64_t cookie;
179 };
180 
181 #endif
182 
186 STAILQ_HEAD(rte_mempool_memhdr_list, rte_mempool_memhdr);
187 
192  void *opaque);
193 
202  struct rte_mempool *mp;
203  void *addr;
205  size_t len;
207  void *opaque;
208 };
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  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_PHYS_CONTIG 0x0020
277 #ifdef RTE_LIBRTE_MEMPOOL_DEBUG
278 #define __MEMPOOL_STAT_ADD(mp, name, n) do { \
279  unsigned __lcore_id = rte_lcore_id(); \
280  if (__lcore_id < RTE_MAX_LCORE) { \
281  mp->stats[__lcore_id].name##_objs += n; \
282  mp->stats[__lcore_id].name##_bulk += 1; \
283  } \
284  } while(0)
285 #else
286 #define __MEMPOOL_STAT_ADD(mp, name, n) do {} while(0)
287 #endif
288 
297 #define MEMPOOL_HEADER_SIZE(mp, cs) \
298  (sizeof(*(mp)) + (((cs) == 0) ? 0 : \
299  (sizeof(struct rte_mempool_cache) * RTE_MAX_LCORE)))
300 
301 /* return the header of a mempool object (internal) */
302 static inline struct rte_mempool_objhdr *__mempool_get_header(void *obj)
303 {
304  return (struct rte_mempool_objhdr *)RTE_PTR_SUB(obj,
305  sizeof(struct rte_mempool_objhdr));
306 }
307 
317 static inline struct rte_mempool *rte_mempool_from_obj(void *obj)
318 {
319  struct rte_mempool_objhdr *hdr = __mempool_get_header(obj);
320  return hdr->mp;
321 }
322 
323 /* return the trailer of a mempool object (internal) */
324 static inline struct rte_mempool_objtlr *__mempool_get_trailer(void *obj)
325 {
326  struct rte_mempool *mp = rte_mempool_from_obj(obj);
327  return (struct rte_mempool_objtlr *)RTE_PTR_ADD(obj, mp->elt_size);
328 }
329 
344 void rte_mempool_check_cookies(const struct rte_mempool *mp,
345  void * const *obj_table_const, unsigned n, int free);
346 
347 #ifdef RTE_LIBRTE_MEMPOOL_DEBUG
348 #define __mempool_check_cookies(mp, obj_table_const, n, free) \
349  rte_mempool_check_cookies(mp, obj_table_const, n, free)
350 #else
351 #define __mempool_check_cookies(mp, obj_table_const, n, free) do {} while(0)
352 #endif /* RTE_LIBRTE_MEMPOOL_DEBUG */
353 
354 #define RTE_MEMPOOL_OPS_NAMESIZE 32
366 typedef int (*rte_mempool_alloc_t)(struct rte_mempool *mp);
367 
371 typedef void (*rte_mempool_free_t)(struct rte_mempool *mp);
372 
376 typedef int (*rte_mempool_enqueue_t)(struct rte_mempool *mp,
377  void * const *obj_table, unsigned int n);
378 
382 typedef int (*rte_mempool_dequeue_t)(struct rte_mempool *mp,
383  void **obj_table, unsigned int n);
384 
388 typedef unsigned (*rte_mempool_get_count)(const struct rte_mempool *mp);
389 
399 
400 #define RTE_MEMPOOL_MAX_OPS_IDX 16
411 struct rte_mempool_ops_table {
413  uint32_t num_ops;
419 
422 
432 static inline struct rte_mempool_ops *
433 rte_mempool_get_ops(int ops_index)
434 {
435  RTE_VERIFY((ops_index >= 0) && (ops_index < RTE_MEMPOOL_MAX_OPS_IDX));
436 
437  return &rte_mempool_ops_table.ops[ops_index];
438 }
439 
449 int
450 rte_mempool_ops_alloc(struct rte_mempool *mp);
451 
465 static inline int
466 rte_mempool_ops_dequeue_bulk(struct rte_mempool *mp,
467  void **obj_table, unsigned n)
468 {
469  struct rte_mempool_ops *ops;
470 
471  ops = rte_mempool_get_ops(mp->ops_index);
472  return ops->dequeue(mp, obj_table, n);
473 }
474 
488 static inline int
489 rte_mempool_ops_enqueue_bulk(struct rte_mempool *mp, void * const *obj_table,
490  unsigned n)
491 {
492  struct rte_mempool_ops *ops;
493 
494  ops = rte_mempool_get_ops(mp->ops_index);
495  return ops->enqueue(mp, obj_table, n);
496 }
497 
506 unsigned
507 rte_mempool_ops_get_count(const struct rte_mempool *mp);
508 
515 void
516 rte_mempool_ops_free(struct rte_mempool *mp);
517 
535 int
536 rte_mempool_set_ops_byname(struct rte_mempool *mp, const char *name,
537  void *pool_config);
538 
549 int rte_mempool_register_ops(const struct rte_mempool_ops *ops);
550 
556 #define MEMPOOL_REGISTER_OPS(ops) \
557  void mp_hdlr_init_##ops(void); \
558  void __attribute__((constructor, used)) mp_hdlr_init_##ops(void)\
559  { \
560  rte_mempool_register_ops(&ops); \
561  }
562 
568 typedef void (rte_mempool_obj_cb_t)(struct rte_mempool *mp,
569  void *opaque, void *obj, unsigned obj_idx);
570 typedef rte_mempool_obj_cb_t rte_mempool_obj_ctor_t; /* compat */
571 
577 typedef void (rte_mempool_mem_cb_t)(struct rte_mempool *mp,
578  void *opaque, struct rte_mempool_memhdr *memhdr,
579  unsigned mem_idx);
580 
587 typedef void (rte_mempool_ctor_t)(struct rte_mempool *, void *);
588 
668 struct rte_mempool *
669 rte_mempool_create(const char *name, unsigned n, unsigned elt_size,
670  unsigned cache_size, unsigned private_data_size,
671  rte_mempool_ctor_t *mp_init, void *mp_init_arg,
672  rte_mempool_obj_cb_t *obj_init, void *obj_init_arg,
673  int socket_id, unsigned flags);
674 
734 struct rte_mempool *
735 rte_mempool_xmem_create(const char *name, unsigned n, unsigned elt_size,
736  unsigned cache_size, unsigned private_data_size,
737  rte_mempool_ctor_t *mp_init, void *mp_init_arg,
738  rte_mempool_obj_cb_t *obj_init, void *obj_init_arg,
739  int socket_id, unsigned flags, void *vaddr,
740  const phys_addr_t paddr[], uint32_t pg_num, uint32_t pg_shift);
741 
776 struct rte_mempool *
777 rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size,
778  unsigned cache_size, unsigned private_data_size,
779  int socket_id, unsigned flags);
790 void
791 rte_mempool_free(struct rte_mempool *mp);
792 
820 int rte_mempool_populate_phys(struct rte_mempool *mp, char *vaddr,
821  phys_addr_t paddr, size_t len, rte_mempool_memchunk_free_cb_t *free_cb,
822  void *opaque);
823 
851 int rte_mempool_populate_phys_tab(struct rte_mempool *mp, char *vaddr,
852  const phys_addr_t paddr[], uint32_t pg_num, uint32_t pg_shift,
853  rte_mempool_memchunk_free_cb_t *free_cb, void *opaque);
854 
879 int
880 rte_mempool_populate_virt(struct rte_mempool *mp, char *addr,
881  size_t len, size_t pg_sz, rte_mempool_memchunk_free_cb_t *free_cb,
882  void *opaque);
883 
898 
912 int rte_mempool_populate_anon(struct rte_mempool *mp);
913 
929 uint32_t rte_mempool_obj_iter(struct rte_mempool *mp,
930  rte_mempool_obj_cb_t *obj_cb, void *obj_cb_arg);
931 
947 uint32_t rte_mempool_mem_iter(struct rte_mempool *mp,
948  rte_mempool_mem_cb_t *mem_cb, void *mem_cb_arg);
949 
958 void rte_mempool_dump(FILE *f, struct rte_mempool *mp);
959 
974 struct rte_mempool_cache *
975 rte_mempool_cache_create(uint32_t size, int socket_id);
976 
983 void
985 
994 static inline void __attribute__((always_inline))
996  struct rte_mempool *mp)
997 {
998  rte_mempool_ops_enqueue_bulk(mp, cache->objs, cache->len);
999  cache->len = 0;
1000 }
1001 
1012 static inline struct rte_mempool_cache *__attribute__((always_inline))
1013 rte_mempool_default_cache(struct rte_mempool *mp, unsigned lcore_id)
1014 {
1015  if (mp->cache_size == 0)
1016  return NULL;
1017 
1018  if (lcore_id >= RTE_MAX_LCORE)
1019  return NULL;
1020 
1021  return &mp->local_cache[lcore_id];
1022 }
1023 
1039 static inline void __attribute__((always_inline))
1040 __mempool_generic_put(struct rte_mempool *mp, void * const *obj_table,
1041  unsigned n, struct rte_mempool_cache *cache)
1042 {
1043  void **cache_objs;
1044 
1045  /* increment stat now, adding in mempool always success */
1046  __MEMPOOL_STAT_ADD(mp, put, n);
1047 
1048  /* No cache provided or if put would overflow mem allocated for cache */
1049  if (unlikely(cache == NULL || n > RTE_MEMPOOL_CACHE_MAX_SIZE))
1050  goto ring_enqueue;
1051 
1052  cache_objs = &cache->objs[cache->len];
1053 
1054  /*
1055  * The cache follows the following algorithm
1056  * 1. Add the objects to the cache
1057  * 2. Anything greater than the cache min value (if it crosses the
1058  * cache flush threshold) is flushed to the ring.
1059  */
1060 
1061  /* Add elements back into the cache */
1062  rte_memcpy(&cache_objs[0], obj_table, sizeof(void *) * n);
1063 
1064  cache->len += n;
1065 
1066  if (cache->len >= cache->flushthresh) {
1067  rte_mempool_ops_enqueue_bulk(mp, &cache->objs[cache->size],
1068  cache->len - cache->size);
1069  cache->len = cache->size;
1070  }
1071 
1072  return;
1073 
1074 ring_enqueue:
1075 
1076  /* push remaining objects in ring */
1077 #ifdef RTE_LIBRTE_MEMPOOL_DEBUG
1078  if (rte_mempool_ops_enqueue_bulk(mp, obj_table, n) < 0)
1079  rte_panic("cannot put objects in mempool\n");
1080 #else
1081  rte_mempool_ops_enqueue_bulk(mp, obj_table, n);
1082 #endif
1083 }
1084 
1085 
1101 static inline void __attribute__((always_inline))
1102 rte_mempool_generic_put(struct rte_mempool *mp, void * const *obj_table,
1103  unsigned n, struct rte_mempool_cache *cache,
1104  __rte_unused int flags)
1105 {
1106  __mempool_check_cookies(mp, obj_table, n, 0);
1107  __mempool_generic_put(mp, obj_table, n, cache);
1108 }
1109 
1121 __rte_deprecated
1122 static inline void __attribute__((always_inline))
1123 rte_mempool_mp_put_bulk(struct rte_mempool *mp, void * const *obj_table,
1124  unsigned n)
1125 {
1126  struct rte_mempool_cache *cache;
1127  cache = rte_mempool_default_cache(mp, rte_lcore_id());
1128  rte_mempool_generic_put(mp, obj_table, n, cache, 0);
1129 }
1130 
1142 __rte_deprecated
1143 static inline void __attribute__((always_inline))
1144 rte_mempool_sp_put_bulk(struct rte_mempool *mp, void * const *obj_table,
1145  unsigned n)
1146 {
1147  rte_mempool_generic_put(mp, obj_table, n, NULL, MEMPOOL_F_SP_PUT);
1148 }
1149 
1164 static inline void __attribute__((always_inline))
1165 rte_mempool_put_bulk(struct rte_mempool *mp, void * const *obj_table,
1166  unsigned n)
1167 {
1168  struct rte_mempool_cache *cache;
1169  cache = rte_mempool_default_cache(mp, rte_lcore_id());
1170  rte_mempool_generic_put(mp, obj_table, n, cache, mp->flags);
1171 }
1172 
1182 __rte_deprecated
1183 static inline void __attribute__((always_inline))
1184 rte_mempool_mp_put(struct rte_mempool *mp, void *obj)
1185 {
1186  struct rte_mempool_cache *cache;
1187  cache = rte_mempool_default_cache(mp, rte_lcore_id());
1188  rte_mempool_generic_put(mp, &obj, 1, cache, 0);
1189 }
1190 
1200 __rte_deprecated
1201 static inline void __attribute__((always_inline))
1202 rte_mempool_sp_put(struct rte_mempool *mp, void *obj)
1203 {
1204  rte_mempool_generic_put(mp, &obj, 1, NULL, MEMPOOL_F_SP_PUT);
1205 }
1206 
1219 static inline void __attribute__((always_inline))
1220 rte_mempool_put(struct rte_mempool *mp, void *obj)
1221 {
1222  rte_mempool_put_bulk(mp, &obj, 1);
1223 }
1224 
1242 static inline int __attribute__((always_inline))
1243 __mempool_generic_get(struct rte_mempool *mp, void **obj_table,
1244  unsigned n, struct rte_mempool_cache *cache)
1245 {
1246  int ret;
1247  uint32_t index, len;
1248  void **cache_objs;
1249 
1250  /* No cache provided or cannot be satisfied from cache */
1251  if (unlikely(cache == NULL || n >= cache->size))
1252  goto ring_dequeue;
1253 
1254  cache_objs = cache->objs;
1255 
1256  /* Can this be satisfied from the cache? */
1257  if (cache->len < n) {
1258  /* No. Backfill the cache first, and then fill from it */
1259  uint32_t req = n + (cache->size - cache->len);
1260 
1261  /* How many do we require i.e. number to fill the cache + the request */
1262  ret = rte_mempool_ops_dequeue_bulk(mp,
1263  &cache->objs[cache->len], req);
1264  if (unlikely(ret < 0)) {
1265  /*
1266  * In the offchance that we are buffer constrained,
1267  * where we are not able to allocate cache + n, go to
1268  * the ring directly. If that fails, we are truly out of
1269  * buffers.
1270  */
1271  goto ring_dequeue;
1272  }
1273 
1274  cache->len += req;
1275  }
1276 
1277  /* Now fill in the response ... */
1278  for (index = 0, len = cache->len - 1; index < n; ++index, len--, obj_table++)
1279  *obj_table = cache_objs[len];
1280 
1281  cache->len -= n;
1282 
1283  __MEMPOOL_STAT_ADD(mp, get_success, n);
1284 
1285  return 0;
1286 
1287 ring_dequeue:
1288 
1289  /* get remaining objects from ring */
1290  ret = rte_mempool_ops_dequeue_bulk(mp, obj_table, n);
1291 
1292  if (ret < 0)
1293  __MEMPOOL_STAT_ADD(mp, get_fail, n);
1294  else
1295  __MEMPOOL_STAT_ADD(mp, get_success, n);
1296 
1297  return ret;
1298 }
1299 
1323 static inline int __attribute__((always_inline))
1324 rte_mempool_generic_get(struct rte_mempool *mp, void **obj_table, unsigned n,
1325  struct rte_mempool_cache *cache, __rte_unused int flags)
1326 {
1327  int ret;
1328  ret = __mempool_generic_get(mp, obj_table, n, cache);
1329  if (ret == 0)
1330  __mempool_check_cookies(mp, obj_table, n, 1);
1331  return ret;
1332 }
1333 
1353 __rte_deprecated
1354 static inline int __attribute__((always_inline))
1355 rte_mempool_mc_get_bulk(struct rte_mempool *mp, void **obj_table, unsigned n)
1356 {
1357  struct rte_mempool_cache *cache;
1358  cache = rte_mempool_default_cache(mp, rte_lcore_id());
1359  return rte_mempool_generic_get(mp, obj_table, n, cache, 0);
1360 }
1361 
1382 __rte_deprecated
1383 static inline int __attribute__((always_inline))
1384 rte_mempool_sc_get_bulk(struct rte_mempool *mp, void **obj_table, unsigned n)
1385 {
1386  return rte_mempool_generic_get(mp, obj_table, n, NULL,
1388 }
1389 
1412 static inline int __attribute__((always_inline))
1413 rte_mempool_get_bulk(struct rte_mempool *mp, void **obj_table, unsigned n)
1414 {
1415  struct rte_mempool_cache *cache;
1416  cache = rte_mempool_default_cache(mp, rte_lcore_id());
1417  return rte_mempool_generic_get(mp, obj_table, n, cache, mp->flags);
1418 }
1419 
1437 __rte_deprecated
1438 static inline int __attribute__((always_inline))
1439 rte_mempool_mc_get(struct rte_mempool *mp, void **obj_p)
1440 {
1441  struct rte_mempool_cache *cache;
1442  cache = rte_mempool_default_cache(mp, rte_lcore_id());
1443  return rte_mempool_generic_get(mp, obj_p, 1, cache, 0);
1444 }
1445 
1463 __rte_deprecated
1464 static inline int __attribute__((always_inline))
1465 rte_mempool_sc_get(struct rte_mempool *mp, void **obj_p)
1466 {
1467  return rte_mempool_generic_get(mp, obj_p, 1, NULL, MEMPOOL_F_SC_GET);
1468 }
1469 
1490 static inline int __attribute__((always_inline))
1491 rte_mempool_get(struct rte_mempool *mp, void **obj_p)
1492 {
1493  return rte_mempool_get_bulk(mp, obj_p, 1);
1494 }
1495 
1508 unsigned int rte_mempool_avail_count(const struct rte_mempool *mp);
1509 
1523 __rte_deprecated
1524 unsigned rte_mempool_count(const struct rte_mempool *mp);
1525 
1538 unsigned int
1539 rte_mempool_in_use_count(const struct rte_mempool *mp);
1540 
1559 __rte_deprecated
1560 static inline unsigned
1562 {
1563  return rte_mempool_in_use_count(mp);
1564 }
1565 
1579 static inline int
1581 {
1582  return !!(rte_mempool_avail_count(mp) == mp->size);
1583 }
1584 
1598 static inline int
1600 {
1601  return !!(rte_mempool_avail_count(mp) == 0);
1602 }
1603 
1616 static inline phys_addr_t
1617 rte_mempool_virt2phy(__rte_unused const struct rte_mempool *mp, const void *elt)
1618 {
1619  const struct rte_mempool_objhdr *hdr;
1620  hdr = (const struct rte_mempool_objhdr *)RTE_PTR_SUB(elt,
1621  sizeof(*hdr));
1622  return hdr->physaddr;
1623 }
1624 
1635 void rte_mempool_audit(struct rte_mempool *mp);
1636 
1645 static inline void *rte_mempool_get_priv(struct rte_mempool *mp)
1646 {
1647  return (char *)mp +
1649 }
1650 
1657 void rte_mempool_list_dump(FILE *f);
1658 
1671 struct rte_mempool *rte_mempool_lookup(const char *name);
1672 
1690 uint32_t rte_mempool_calc_obj_size(uint32_t elt_size, uint32_t flags,
1691  struct rte_mempool_objsz *sz);
1692 
1714 size_t rte_mempool_xmem_size(uint32_t elt_num, size_t total_elt_sz,
1715  uint32_t pg_shift);
1716 
1744 ssize_t rte_mempool_xmem_usage(void *vaddr, uint32_t elt_num,
1745  size_t total_elt_sz, const phys_addr_t paddr[], uint32_t pg_num,
1746  uint32_t pg_shift);
1747 
1756 void rte_mempool_walk(void (*func)(struct rte_mempool *, void *arg),
1757  void *arg);
1758 
1759 #ifdef __cplusplus
1760 }
1761 #endif
1762 
1763 #endif /* _RTE_MEMPOOL_H_ */