DPDK  16.07.2
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 
79 #ifdef __cplusplus
80 extern "C" {
81 #endif
82 
83 #define RTE_MEMPOOL_HEADER_COOKIE1 0xbadbadbadadd2e55ULL
84 #define RTE_MEMPOOL_HEADER_COOKIE2 0xf2eef2eedadd2e55ULL
85 #define RTE_MEMPOOL_TRAILER_COOKIE 0xadd2e55badbadbadULL
87 #ifdef RTE_LIBRTE_MEMPOOL_DEBUG
88 
91 struct rte_mempool_debug_stats {
92  uint64_t put_bulk;
93  uint64_t put_objs;
94  uint64_t get_success_bulk;
95  uint64_t get_success_objs;
96  uint64_t get_fail_bulk;
97  uint64_t get_fail_objs;
99 #endif
100 
105  uint32_t size;
106  uint32_t flushthresh;
107  uint32_t len;
108  /*
109  * Cache is allocated to this size to allow it to overflow in certain
110  * cases to avoid needless emptying of cache.
111  */
112  void *objs[RTE_MEMPOOL_CACHE_MAX_SIZE * 3];
114 
119  uint32_t elt_size;
120  uint32_t header_size;
121  uint32_t trailer_size;
122  uint32_t total_size;
124 };
125 
127 #define RTE_MEMPOOL_NAMESIZE (RTE_RING_NAMESIZE - \
128  sizeof(RTE_MEMPOOL_MZ_PREFIX) + 1)
129 #define RTE_MEMPOOL_MZ_PREFIX "MP_"
130 
131 /* "MP_<name>" */
132 #define RTE_MEMPOOL_MZ_FORMAT RTE_MEMPOOL_MZ_PREFIX "%s"
133 
134 #define MEMPOOL_PG_SHIFT_MAX (sizeof(uintptr_t) * CHAR_BIT - 1)
135 
137 #define MEMPOOL_PG_NUM_DEFAULT 1
138 
139 #ifndef RTE_MEMPOOL_ALIGN
140 #define RTE_MEMPOOL_ALIGN RTE_CACHE_LINE_SIZE
141 #endif
142 
143 #define RTE_MEMPOOL_ALIGN_MASK (RTE_MEMPOOL_ALIGN - 1)
144 
156  struct rte_mempool *mp;
158 #ifdef RTE_LIBRTE_MEMPOOL_DEBUG
159  uint64_t cookie;
160 #endif
161 };
162 
166 STAILQ_HEAD(rte_mempool_objhdr_list, rte_mempool_objhdr);
167 
168 #ifdef RTE_LIBRTE_MEMPOOL_DEBUG
169 
176 struct rte_mempool_objtlr {
177  uint64_t cookie;
178 };
179 
180 #endif
181 
185 STAILQ_HEAD(rte_mempool_memhdr_list, rte_mempool_memhdr);
186 
191  void *opaque);
192 
201  struct rte_mempool *mp;
202  void *addr;
204  size_t len;
206  void *opaque;
207 };
208 
212 struct rte_mempool {
213  /*
214  * Note: this field kept the RTE_MEMZONE_NAMESIZE size due to ABI
215  * compatibility requirements, it could be changed to
216  * RTE_MEMPOOL_NAMESIZE next time the ABI changes
217  */
219  union {
220  void *pool_data;
221  uint64_t pool_id;
222  };
223  void *pool_config;
224  const struct rte_memzone *mz;
225  int flags;
226  int socket_id;
227  uint32_t size;
228  uint32_t cache_size;
231  uint32_t elt_size;
232  uint32_t header_size;
233  uint32_t trailer_size;
235  unsigned private_data_size;
243  int32_t ops_index;
244 
247  uint32_t populated_size;
248  struct rte_mempool_objhdr_list elt_list;
249  uint32_t nb_mem_chunks;
250  struct rte_mempool_memhdr_list mem_list;
252 #ifdef RTE_LIBRTE_MEMPOOL_DEBUG
253 
254  struct rte_mempool_debug_stats stats[RTE_MAX_LCORE];
255 #endif
257 
258 #define MEMPOOL_F_NO_SPREAD 0x0001
259 #define MEMPOOL_F_NO_CACHE_ALIGN 0x0002
260 #define MEMPOOL_F_SP_PUT 0x0004
261 #define MEMPOOL_F_SC_GET 0x0008
262 #define MEMPOOL_F_POOL_CREATED 0x0010
263 #define MEMPOOL_F_NO_PHYS_CONTIG 0x0020
275 #ifdef RTE_LIBRTE_MEMPOOL_DEBUG
276 #define __MEMPOOL_STAT_ADD(mp, name, n) do { \
277  unsigned __lcore_id = rte_lcore_id(); \
278  if (__lcore_id < RTE_MAX_LCORE) { \
279  mp->stats[__lcore_id].name##_objs += n; \
280  mp->stats[__lcore_id].name##_bulk += 1; \
281  } \
282  } while(0)
283 #else
284 #define __MEMPOOL_STAT_ADD(mp, name, n) do {} while(0)
285 #endif
286 
295 #define MEMPOOL_HEADER_SIZE(mp, cs) \
296  (sizeof(*(mp)) + (((cs) == 0) ? 0 : \
297  (sizeof(struct rte_mempool_cache) * RTE_MAX_LCORE)))
298 
299 /* return the header of a mempool object (internal) */
300 static inline struct rte_mempool_objhdr *__mempool_get_header(void *obj)
301 {
302  return (struct rte_mempool_objhdr *)RTE_PTR_SUB(obj,
303  sizeof(struct rte_mempool_objhdr));
304 }
305 
315 static inline struct rte_mempool *rte_mempool_from_obj(void *obj)
316 {
317  struct rte_mempool_objhdr *hdr = __mempool_get_header(obj);
318  return hdr->mp;
319 }
320 
321 /* return the trailer of a mempool object (internal) */
322 static inline struct rte_mempool_objtlr *__mempool_get_trailer(void *obj)
323 {
324  struct rte_mempool *mp = rte_mempool_from_obj(obj);
325  return (struct rte_mempool_objtlr *)RTE_PTR_ADD(obj, mp->elt_size);
326 }
327 
342 void rte_mempool_check_cookies(const struct rte_mempool *mp,
343  void * const *obj_table_const, unsigned n, int free);
344 
345 #ifdef RTE_LIBRTE_MEMPOOL_DEBUG
346 #define __mempool_check_cookies(mp, obj_table_const, n, free) \
347  rte_mempool_check_cookies(mp, obj_table_const, n, free)
348 #else
349 #define __mempool_check_cookies(mp, obj_table_const, n, free) do {} while(0)
350 #endif /* RTE_LIBRTE_MEMPOOL_DEBUG */
351 
352 #define RTE_MEMPOOL_OPS_NAMESIZE 32
364 typedef int (*rte_mempool_alloc_t)(struct rte_mempool *mp);
365 
369 typedef void (*rte_mempool_free_t)(struct rte_mempool *mp);
370 
374 typedef int (*rte_mempool_enqueue_t)(struct rte_mempool *mp,
375  void * const *obj_table, unsigned int n);
376 
380 typedef int (*rte_mempool_dequeue_t)(struct rte_mempool *mp,
381  void **obj_table, unsigned int n);
382 
386 typedef unsigned (*rte_mempool_get_count)(const struct rte_mempool *mp);
387 
397 
398 #define RTE_MEMPOOL_MAX_OPS_IDX 16
409 struct rte_mempool_ops_table {
411  uint32_t num_ops;
417 
420 
430 static inline struct rte_mempool_ops *
431 rte_mempool_get_ops(int ops_index)
432 {
433  RTE_VERIFY((ops_index >= 0) && (ops_index < RTE_MEMPOOL_MAX_OPS_IDX));
434 
435  return &rte_mempool_ops_table.ops[ops_index];
436 }
437 
447 int
448 rte_mempool_ops_alloc(struct rte_mempool *mp);
449 
463 static inline int
464 rte_mempool_ops_dequeue_bulk(struct rte_mempool *mp,
465  void **obj_table, unsigned n)
466 {
467  struct rte_mempool_ops *ops;
468 
469  ops = rte_mempool_get_ops(mp->ops_index);
470  return ops->dequeue(mp, obj_table, n);
471 }
472 
486 static inline int
487 rte_mempool_ops_enqueue_bulk(struct rte_mempool *mp, void * const *obj_table,
488  unsigned n)
489 {
490  struct rte_mempool_ops *ops;
491 
492  ops = rte_mempool_get_ops(mp->ops_index);
493  return ops->enqueue(mp, obj_table, n);
494 }
495 
504 unsigned
505 rte_mempool_ops_get_count(const struct rte_mempool *mp);
506 
513 void
514 rte_mempool_ops_free(struct rte_mempool *mp);
515 
533 int
534 rte_mempool_set_ops_byname(struct rte_mempool *mp, const char *name,
535  void *pool_config);
536 
547 int rte_mempool_register_ops(const struct rte_mempool_ops *ops);
548 
554 #define MEMPOOL_REGISTER_OPS(ops) \
555  void mp_hdlr_init_##ops(void); \
556  void __attribute__((constructor, used)) mp_hdlr_init_##ops(void)\
557  { \
558  rte_mempool_register_ops(&ops); \
559  }
560 
566 typedef void (rte_mempool_obj_cb_t)(struct rte_mempool *mp,
567  void *opaque, void *obj, unsigned obj_idx);
568 typedef rte_mempool_obj_cb_t rte_mempool_obj_ctor_t; /* compat */
569 
575 typedef void (rte_mempool_mem_cb_t)(struct rte_mempool *mp,
576  void *opaque, struct rte_mempool_memhdr *memhdr,
577  unsigned mem_idx);
578 
585 typedef void (rte_mempool_ctor_t)(struct rte_mempool *, void *);
586 
670 struct rte_mempool *
671 rte_mempool_create(const char *name, unsigned n, unsigned elt_size,
672  unsigned cache_size, unsigned private_data_size,
673  rte_mempool_ctor_t *mp_init, void *mp_init_arg,
674  rte_mempool_obj_cb_t *obj_init, void *obj_init_arg,
675  int socket_id, unsigned flags);
676 
736 struct rte_mempool *
737 rte_mempool_xmem_create(const char *name, unsigned n, unsigned elt_size,
738  unsigned cache_size, unsigned private_data_size,
739  rte_mempool_ctor_t *mp_init, void *mp_init_arg,
740  rte_mempool_obj_cb_t *obj_init, void *obj_init_arg,
741  int socket_id, unsigned flags, void *vaddr,
742  const phys_addr_t paddr[], uint32_t pg_num, uint32_t pg_shift);
743 
778 struct rte_mempool *
779 rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size,
780  unsigned cache_size, unsigned private_data_size,
781  int socket_id, unsigned flags);
792 void
793 rte_mempool_free(struct rte_mempool *mp);
794 
818 int rte_mempool_populate_phys(struct rte_mempool *mp, char *vaddr,
819  phys_addr_t paddr, size_t len, rte_mempool_memchunk_free_cb_t *free_cb,
820  void *opaque);
821 
849 int rte_mempool_populate_phys_tab(struct rte_mempool *mp, char *vaddr,
850  const phys_addr_t paddr[], uint32_t pg_num, uint32_t pg_shift,
851  rte_mempool_memchunk_free_cb_t *free_cb, void *opaque);
852 
877 int
878 rte_mempool_populate_virt(struct rte_mempool *mp, char *addr,
879  size_t len, size_t pg_sz, rte_mempool_memchunk_free_cb_t *free_cb,
880  void *opaque);
881 
896 
910 int rte_mempool_populate_anon(struct rte_mempool *mp);
911 
927 uint32_t rte_mempool_obj_iter(struct rte_mempool *mp,
928  rte_mempool_obj_cb_t *obj_cb, void *obj_cb_arg);
929 
945 uint32_t rte_mempool_mem_iter(struct rte_mempool *mp,
946  rte_mempool_mem_cb_t *mem_cb, void *mem_cb_arg);
947 
956 void rte_mempool_dump(FILE *f, struct rte_mempool *mp);
957 
972 struct rte_mempool_cache *
973 rte_mempool_cache_create(uint32_t size, int socket_id);
974 
981 void
983 
992 static inline void __attribute__((always_inline))
994  struct rte_mempool *mp)
995 {
996  rte_mempool_ops_enqueue_bulk(mp, cache->objs, cache->len);
997  cache->len = 0;
998 }
999 
1010 static inline struct rte_mempool_cache *__attribute__((always_inline))
1011 rte_mempool_default_cache(struct rte_mempool *mp, unsigned lcore_id)
1012 {
1013  if (mp->cache_size == 0)
1014  return NULL;
1015 
1016  if (lcore_id >= RTE_MAX_LCORE)
1017  return NULL;
1018 
1019  return &mp->local_cache[lcore_id];
1020 }
1021 
1037 static inline void __attribute__((always_inline))
1038 __mempool_generic_put(struct rte_mempool *mp, void * const *obj_table,
1039  unsigned n, struct rte_mempool_cache *cache, int flags)
1040 {
1041  void **cache_objs;
1042 
1043  /* increment stat now, adding in mempool always success */
1044  __MEMPOOL_STAT_ADD(mp, put, n);
1045 
1046  /* No cache provided or single producer */
1047  if (unlikely(cache == NULL || flags & MEMPOOL_F_SP_PUT))
1048  goto ring_enqueue;
1049 
1050  /* Go straight to ring if put would overflow mem allocated for cache */
1051  if (unlikely(n > RTE_MEMPOOL_CACHE_MAX_SIZE))
1052  goto ring_enqueue;
1053 
1054  cache_objs = &cache->objs[cache->len];
1055 
1056  /*
1057  * The cache follows the following algorithm
1058  * 1. Add the objects to the cache
1059  * 2. Anything greater than the cache min value (if it crosses the
1060  * cache flush threshold) is flushed to the ring.
1061  */
1062 
1063  /* Add elements back into the cache */
1064  rte_memcpy(&cache_objs[0], obj_table, sizeof(void *) * n);
1065 
1066  cache->len += n;
1067 
1068  if (cache->len >= cache->flushthresh) {
1069  rte_mempool_ops_enqueue_bulk(mp, &cache->objs[cache->size],
1070  cache->len - cache->size);
1071  cache->len = cache->size;
1072  }
1073 
1074  return;
1075 
1076 ring_enqueue:
1077 
1078  /* push remaining objects in ring */
1079 #ifdef RTE_LIBRTE_MEMPOOL_DEBUG
1080  if (rte_mempool_ops_enqueue_bulk(mp, obj_table, n) < 0)
1081  rte_panic("cannot put objects in mempool\n");
1082 #else
1083  rte_mempool_ops_enqueue_bulk(mp, obj_table, n);
1084 #endif
1085 }
1086 
1087 
1103 static inline void __attribute__((always_inline))
1104 rte_mempool_generic_put(struct rte_mempool *mp, void * const *obj_table,
1105  unsigned n, struct rte_mempool_cache *cache, int flags)
1106 {
1107  __mempool_check_cookies(mp, obj_table, n, 0);
1108  __mempool_generic_put(mp, obj_table, n, cache, flags);
1109 }
1110 
1122 __rte_deprecated
1123 static inline void __attribute__((always_inline))
1124 rte_mempool_mp_put_bulk(struct rte_mempool *mp, void * const *obj_table,
1125  unsigned n)
1126 {
1127  struct rte_mempool_cache *cache;
1128  cache = rte_mempool_default_cache(mp, rte_lcore_id());
1129  rte_mempool_generic_put(mp, obj_table, n, cache, 0);
1130 }
1131 
1143 __rte_deprecated
1144 static inline void __attribute__((always_inline))
1145 rte_mempool_sp_put_bulk(struct rte_mempool *mp, void * const *obj_table,
1146  unsigned n)
1147 {
1148  rte_mempool_generic_put(mp, obj_table, n, NULL, MEMPOOL_F_SP_PUT);
1149 }
1150 
1165 static inline void __attribute__((always_inline))
1166 rte_mempool_put_bulk(struct rte_mempool *mp, void * const *obj_table,
1167  unsigned n)
1168 {
1169  struct rte_mempool_cache *cache;
1170  cache = rte_mempool_default_cache(mp, rte_lcore_id());
1171  rte_mempool_generic_put(mp, obj_table, n, cache, mp->flags);
1172 }
1173 
1183 __rte_deprecated
1184 static inline void __attribute__((always_inline))
1185 rte_mempool_mp_put(struct rte_mempool *mp, void *obj)
1186 {
1187  struct rte_mempool_cache *cache;
1188  cache = rte_mempool_default_cache(mp, rte_lcore_id());
1189  rte_mempool_generic_put(mp, &obj, 1, cache, 0);
1190 }
1191 
1201 __rte_deprecated
1202 static inline void __attribute__((always_inline))
1203 rte_mempool_sp_put(struct rte_mempool *mp, void *obj)
1204 {
1205  rte_mempool_generic_put(mp, &obj, 1, NULL, MEMPOOL_F_SP_PUT);
1206 }
1207 
1220 static inline void __attribute__((always_inline))
1221 rte_mempool_put(struct rte_mempool *mp, void *obj)
1222 {
1223  rte_mempool_put_bulk(mp, &obj, 1);
1224 }
1225 
1243 static inline int __attribute__((always_inline))
1244 __mempool_generic_get(struct rte_mempool *mp, void **obj_table,
1245  unsigned n, struct rte_mempool_cache *cache, int flags)
1246 {
1247  int ret;
1248  uint32_t index, len;
1249  void **cache_objs;
1250 
1251  /* No cache provided or single consumer */
1252  if (unlikely(cache == NULL || flags & MEMPOOL_F_SC_GET ||
1253  n >= cache->size))
1254  goto ring_dequeue;
1255 
1256  cache_objs = cache->objs;
1257 
1258  /* Can this be satisfied from the cache? */
1259  if (cache->len < n) {
1260  /* No. Backfill the cache first, and then fill from it */
1261  uint32_t req = n + (cache->size - cache->len);
1262 
1263  /* How many do we require i.e. number to fill the cache + the request */
1264  ret = rte_mempool_ops_dequeue_bulk(mp,
1265  &cache->objs[cache->len], req);
1266  if (unlikely(ret < 0)) {
1267  /*
1268  * In the offchance that we are buffer constrained,
1269  * where we are not able to allocate cache + n, go to
1270  * the ring directly. If that fails, we are truly out of
1271  * buffers.
1272  */
1273  goto ring_dequeue;
1274  }
1275 
1276  cache->len += req;
1277  }
1278 
1279  /* Now fill in the response ... */
1280  for (index = 0, len = cache->len - 1; index < n; ++index, len--, obj_table++)
1281  *obj_table = cache_objs[len];
1282 
1283  cache->len -= n;
1284 
1285  __MEMPOOL_STAT_ADD(mp, get_success, n);
1286 
1287  return 0;
1288 
1289 ring_dequeue:
1290 
1291  /* get remaining objects from ring */
1292  ret = rte_mempool_ops_dequeue_bulk(mp, obj_table, n);
1293 
1294  if (ret < 0)
1295  __MEMPOOL_STAT_ADD(mp, get_fail, n);
1296  else
1297  __MEMPOOL_STAT_ADD(mp, get_success, n);
1298 
1299  return ret;
1300 }
1301 
1325 static inline int __attribute__((always_inline))
1326 rte_mempool_generic_get(struct rte_mempool *mp, void **obj_table, unsigned n,
1327  struct rte_mempool_cache *cache, int flags)
1328 {
1329  int ret;
1330  ret = __mempool_generic_get(mp, obj_table, n, cache, flags);
1331  if (ret == 0)
1332  __mempool_check_cookies(mp, obj_table, n, 1);
1333  return ret;
1334 }
1335 
1355 __rte_deprecated
1356 static inline int __attribute__((always_inline))
1357 rte_mempool_mc_get_bulk(struct rte_mempool *mp, void **obj_table, unsigned n)
1358 {
1359  struct rte_mempool_cache *cache;
1360  cache = rte_mempool_default_cache(mp, rte_lcore_id());
1361  return rte_mempool_generic_get(mp, obj_table, n, cache, 0);
1362 }
1363 
1384 __rte_deprecated
1385 static inline int __attribute__((always_inline))
1386 rte_mempool_sc_get_bulk(struct rte_mempool *mp, void **obj_table, unsigned n)
1387 {
1388  return rte_mempool_generic_get(mp, obj_table, n, NULL,
1390 }
1391 
1414 static inline int __attribute__((always_inline))
1415 rte_mempool_get_bulk(struct rte_mempool *mp, void **obj_table, unsigned n)
1416 {
1417  struct rte_mempool_cache *cache;
1418  cache = rte_mempool_default_cache(mp, rte_lcore_id());
1419  return rte_mempool_generic_get(mp, obj_table, n, cache, mp->flags);
1420 }
1421 
1439 __rte_deprecated
1440 static inline int __attribute__((always_inline))
1441 rte_mempool_mc_get(struct rte_mempool *mp, void **obj_p)
1442 {
1443  struct rte_mempool_cache *cache;
1444  cache = rte_mempool_default_cache(mp, rte_lcore_id());
1445  return rte_mempool_generic_get(mp, obj_p, 1, cache, 0);
1446 }
1447 
1465 __rte_deprecated
1466 static inline int __attribute__((always_inline))
1467 rte_mempool_sc_get(struct rte_mempool *mp, void **obj_p)
1468 {
1469  return rte_mempool_generic_get(mp, obj_p, 1, NULL, MEMPOOL_F_SC_GET);
1470 }
1471 
1492 static inline int __attribute__((always_inline))
1493 rte_mempool_get(struct rte_mempool *mp, void **obj_p)
1494 {
1495  return rte_mempool_get_bulk(mp, obj_p, 1);
1496 }
1497 
1510 unsigned int rte_mempool_avail_count(const struct rte_mempool *mp);
1511 
1525 __rte_deprecated
1526 unsigned rte_mempool_count(const struct rte_mempool *mp);
1527 
1540 unsigned int
1541 rte_mempool_in_use_count(const struct rte_mempool *mp);
1542 
1561 __rte_deprecated
1562 static inline unsigned
1564 {
1565  return rte_mempool_in_use_count(mp);
1566 }
1567 
1581 static inline int
1583 {
1584  return !!(rte_mempool_avail_count(mp) == mp->size);
1585 }
1586 
1600 static inline int
1602 {
1603  return !!(rte_mempool_avail_count(mp) == 0);
1604 }
1605 
1618 static inline phys_addr_t
1619 rte_mempool_virt2phy(__rte_unused const struct rte_mempool *mp, const void *elt)
1620 {
1621  const struct rte_mempool_objhdr *hdr;
1622  hdr = (const struct rte_mempool_objhdr *)RTE_PTR_SUB(elt,
1623  sizeof(*hdr));
1624  return hdr->physaddr;
1625 }
1626 
1637 void rte_mempool_audit(struct rte_mempool *mp);
1638 
1647 static inline void *rte_mempool_get_priv(struct rte_mempool *mp)
1648 {
1649  return (char *)mp +
1651 }
1652 
1659 void rte_mempool_list_dump(FILE *f);
1660 
1673 struct rte_mempool *rte_mempool_lookup(const char *name);
1674 
1692 uint32_t rte_mempool_calc_obj_size(uint32_t elt_size, uint32_t flags,
1693  struct rte_mempool_objsz *sz);
1694 
1716 size_t rte_mempool_xmem_size(uint32_t elt_num, size_t total_elt_sz,
1717  uint32_t pg_shift);
1718 
1746 ssize_t rte_mempool_xmem_usage(void *vaddr, uint32_t elt_num,
1747  size_t total_elt_sz, const phys_addr_t paddr[], uint32_t pg_num,
1748  uint32_t pg_shift);
1749 
1758 void rte_mempool_walk(void (*func)(struct rte_mempool *, void *arg),
1759  void *arg);
1760 
1761 #ifdef __cplusplus
1762 }
1763 #endif
1764 
1765 #endif /* _RTE_MEMPOOL_H_ */