DPDK  17.11.10
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 
65 #include <stdio.h>
66 #include <stdlib.h>
67 #include <stdint.h>
68 #include <errno.h>
69 #include <inttypes.h>
70 #include <sys/queue.h>
71 
72 #include <rte_config.h>
73 #include <rte_spinlock.h>
74 #include <rte_log.h>
75 #include <rte_debug.h>
76 #include <rte_lcore.h>
77 #include <rte_memory.h>
78 #include <rte_branch_prediction.h>
79 #include <rte_ring.h>
80 #include <rte_memcpy.h>
81 #include <rte_common.h>
82 
83 #ifdef __cplusplus
84 extern "C" {
85 #endif
86 
87 #define RTE_MEMPOOL_HEADER_COOKIE1 0xbadbadbadadd2e55ULL
88 #define RTE_MEMPOOL_HEADER_COOKIE2 0xf2eef2eedadd2e55ULL
89 #define RTE_MEMPOOL_TRAILER_COOKIE 0xadd2e55badbadbadULL
91 #ifdef RTE_LIBRTE_MEMPOOL_DEBUG
92 
95 struct rte_mempool_debug_stats {
96  uint64_t put_bulk;
97  uint64_t put_objs;
98  uint64_t get_success_bulk;
99  uint64_t get_success_objs;
100  uint64_t get_fail_bulk;
101  uint64_t get_fail_objs;
103 #endif
104 
109  uint32_t size;
110  uint32_t flushthresh;
111  uint32_t len;
112  /*
113  * Cache is allocated to this size to allow it to overflow in certain
114  * cases to avoid needless emptying of cache.
115  */
116  void *objs[RTE_MEMPOOL_CACHE_MAX_SIZE * 3];
118 
123  uint32_t elt_size;
124  uint32_t header_size;
125  uint32_t trailer_size;
126  uint32_t total_size;
128 };
129 
131 #define RTE_MEMPOOL_NAMESIZE (RTE_RING_NAMESIZE - \
132  sizeof(RTE_MEMPOOL_MZ_PREFIX) + 1)
133 #define RTE_MEMPOOL_MZ_PREFIX "MP_"
134 
135 /* "MP_<name>" */
136 #define RTE_MEMPOOL_MZ_FORMAT RTE_MEMPOOL_MZ_PREFIX "%s"
137 
138 #define MEMPOOL_PG_SHIFT_MAX (sizeof(uintptr_t) * CHAR_BIT - 1)
139 
141 #define MEMPOOL_PG_NUM_DEFAULT 1
142 
143 #ifndef RTE_MEMPOOL_ALIGN
144 #define RTE_MEMPOOL_ALIGN RTE_CACHE_LINE_SIZE
145 #endif
146 
147 #define RTE_MEMPOOL_ALIGN_MASK (RTE_MEMPOOL_ALIGN - 1)
148 
160  struct rte_mempool *mp;
162  union {
165  };
166 #ifdef RTE_LIBRTE_MEMPOOL_DEBUG
167  uint64_t cookie;
168 #endif
169 };
170 
174 STAILQ_HEAD(rte_mempool_objhdr_list, rte_mempool_objhdr);
175 
176 #ifdef RTE_LIBRTE_MEMPOOL_DEBUG
177 
184 struct rte_mempool_objtlr {
185  uint64_t cookie;
186 };
187 
188 #endif
189 
193 STAILQ_HEAD(rte_mempool_memhdr_list, rte_mempool_memhdr);
194 
199  void *opaque);
200 
209  struct rte_mempool *mp;
210  void *addr;
212  union {
215  };
216  size_t len;
218  void *opaque;
219 };
220 
224 struct rte_mempool {
225  /*
226  * Note: this field kept the RTE_MEMZONE_NAMESIZE size due to ABI
227  * compatibility requirements, it could be changed to
228  * RTE_MEMPOOL_NAMESIZE next time the ABI changes
229  */
232  union {
233  void *pool_data;
234  uint64_t pool_id;
235  };
236  void *pool_config;
237  const struct rte_memzone *mz;
238  unsigned int flags;
239  int socket_id;
240  uint32_t size;
241  uint32_t cache_size;
244  uint32_t elt_size;
245  uint32_t header_size;
246  uint32_t trailer_size;
248  unsigned private_data_size;
256  int32_t ops_index;
257 
260  uint32_t populated_size;
261  struct rte_mempool_objhdr_list elt_list;
262  uint32_t nb_mem_chunks;
263  struct rte_mempool_memhdr_list mem_list;
265 #ifdef RTE_LIBRTE_MEMPOOL_DEBUG
266 
267  struct rte_mempool_debug_stats stats[RTE_MAX_LCORE];
268 #endif
270 
271 #define MEMPOOL_F_NO_SPREAD 0x0001
272 #define MEMPOOL_F_NO_CACHE_ALIGN 0x0002
273 #define MEMPOOL_F_SP_PUT 0x0004
274 #define MEMPOOL_F_SC_GET 0x0008
275 #define MEMPOOL_F_POOL_CREATED 0x0010
276 #define MEMPOOL_F_NO_PHYS_CONTIG 0x0020
282 #define MEMPOOL_F_CAPA_PHYS_CONTIG 0x0040
283 
294 #define MEMPOOL_F_CAPA_BLK_ALIGNED_OBJECTS 0x0080
295 
306 #ifdef RTE_LIBRTE_MEMPOOL_DEBUG
307 #define __MEMPOOL_STAT_ADD(mp, name, n) do { \
308  unsigned __lcore_id = rte_lcore_id(); \
309  if (__lcore_id < RTE_MAX_LCORE) { \
310  mp->stats[__lcore_id].name##_objs += n; \
311  mp->stats[__lcore_id].name##_bulk += 1; \
312  } \
313  } while(0)
314 #else
315 #define __MEMPOOL_STAT_ADD(mp, name, n) do {} while(0)
316 #endif
317 
326 #define MEMPOOL_HEADER_SIZE(mp, cs) \
327  (sizeof(*(mp)) + (((cs) == 0) ? 0 : \
328  (sizeof(struct rte_mempool_cache) * RTE_MAX_LCORE)))
329 
330 /* return the header of a mempool object (internal) */
331 static inline struct rte_mempool_objhdr *__mempool_get_header(void *obj)
332 {
333  return (struct rte_mempool_objhdr *)RTE_PTR_SUB(obj,
334  sizeof(struct rte_mempool_objhdr));
335 }
336 
346 static inline struct rte_mempool *rte_mempool_from_obj(void *obj)
347 {
348  struct rte_mempool_objhdr *hdr = __mempool_get_header(obj);
349  return hdr->mp;
350 }
351 
352 /* return the trailer of a mempool object (internal) */
353 static inline struct rte_mempool_objtlr *__mempool_get_trailer(void *obj)
354 {
355  struct rte_mempool *mp = rte_mempool_from_obj(obj);
356  return (struct rte_mempool_objtlr *)RTE_PTR_ADD(obj, mp->elt_size);
357 }
358 
373 void rte_mempool_check_cookies(const struct rte_mempool *mp,
374  void * const *obj_table_const, unsigned n, int free);
375 
376 #ifdef RTE_LIBRTE_MEMPOOL_DEBUG
377 #define __mempool_check_cookies(mp, obj_table_const, n, free) \
378  rte_mempool_check_cookies(mp, obj_table_const, n, free)
379 #else
380 #define __mempool_check_cookies(mp, obj_table_const, n, free) do {} while(0)
381 #endif /* RTE_LIBRTE_MEMPOOL_DEBUG */
382 
383 #define RTE_MEMPOOL_OPS_NAMESIZE 32
395 typedef int (*rte_mempool_alloc_t)(struct rte_mempool *mp);
396 
400 typedef void (*rte_mempool_free_t)(struct rte_mempool *mp);
401 
405 typedef int (*rte_mempool_enqueue_t)(struct rte_mempool *mp,
406  void * const *obj_table, unsigned int n);
407 
411 typedef int (*rte_mempool_dequeue_t)(struct rte_mempool *mp,
412  void **obj_table, unsigned int n);
413 
417 typedef unsigned (*rte_mempool_get_count)(const struct rte_mempool *mp);
418 
422 typedef int (*rte_mempool_get_capabilities_t)(const struct rte_mempool *mp,
423  unsigned int *flags);
424 
429 (const struct rte_mempool *mp, char *vaddr, rte_iova_t iova, size_t len);
430 
448 
449 #define RTE_MEMPOOL_MAX_OPS_IDX 16
460 struct rte_mempool_ops_table {
462  uint32_t num_ops;
468 
471 
481 static inline struct rte_mempool_ops *
482 rte_mempool_get_ops(int ops_index)
483 {
484  RTE_VERIFY((ops_index >= 0) && (ops_index < RTE_MEMPOOL_MAX_OPS_IDX));
485 
486  return &rte_mempool_ops_table.ops[ops_index];
487 }
488 
498 int
499 rte_mempool_ops_alloc(struct rte_mempool *mp);
500 
514 static inline int
515 rte_mempool_ops_dequeue_bulk(struct rte_mempool *mp,
516  void **obj_table, unsigned n)
517 {
518  struct rte_mempool_ops *ops;
519 
520  ops = rte_mempool_get_ops(mp->ops_index);
521  return ops->dequeue(mp, obj_table, n);
522 }
523 
537 static inline int
538 rte_mempool_ops_enqueue_bulk(struct rte_mempool *mp, void * const *obj_table,
539  unsigned n)
540 {
541  struct rte_mempool_ops *ops;
542 
543  ops = rte_mempool_get_ops(mp->ops_index);
544  return ops->enqueue(mp, obj_table, n);
545 }
546 
555 unsigned
556 rte_mempool_ops_get_count(const struct rte_mempool *mp);
557 
571 int
572 rte_mempool_ops_get_capabilities(const struct rte_mempool *mp,
573  unsigned int *flags);
591 int
592 rte_mempool_ops_register_memory_area(const struct rte_mempool *mp,
593  char *vaddr, rte_iova_t iova, size_t len);
594 
601 void
602 rte_mempool_ops_free(struct rte_mempool *mp);
603 
621 int
622 rte_mempool_set_ops_byname(struct rte_mempool *mp, const char *name,
623  void *pool_config);
624 
635 int rte_mempool_register_ops(const struct rte_mempool_ops *ops);
636 
642 #define MEMPOOL_REGISTER_OPS(ops) \
643  void mp_hdlr_init_##ops(void); \
644  void __attribute__((constructor, used)) mp_hdlr_init_##ops(void)\
645  { \
646  rte_mempool_register_ops(&ops); \
647  }
648 
654 typedef void (rte_mempool_obj_cb_t)(struct rte_mempool *mp,
655  void *opaque, void *obj, unsigned obj_idx);
656 typedef rte_mempool_obj_cb_t rte_mempool_obj_ctor_t; /* compat */
657 
663 typedef void (rte_mempool_mem_cb_t)(struct rte_mempool *mp,
664  void *opaque, struct rte_mempool_memhdr *memhdr,
665  unsigned mem_idx);
666 
673 typedef void (rte_mempool_ctor_t)(struct rte_mempool *, void *);
674 
754 struct rte_mempool *
755 rte_mempool_create(const char *name, unsigned n, unsigned elt_size,
756  unsigned cache_size, unsigned private_data_size,
757  rte_mempool_ctor_t *mp_init, void *mp_init_arg,
758  rte_mempool_obj_cb_t *obj_init, void *obj_init_arg,
759  int socket_id, unsigned flags);
760 
819 struct rte_mempool *
820 rte_mempool_xmem_create(const char *name, unsigned n, unsigned elt_size,
821  unsigned cache_size, unsigned private_data_size,
822  rte_mempool_ctor_t *mp_init, void *mp_init_arg,
823  rte_mempool_obj_cb_t *obj_init, void *obj_init_arg,
824  int socket_id, unsigned flags, void *vaddr,
825  const rte_iova_t iova[], uint32_t pg_num, uint32_t pg_shift);
826 
861 struct rte_mempool *
862 rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size,
863  unsigned cache_size, unsigned private_data_size,
864  int socket_id, unsigned flags);
875 void
876 rte_mempool_free(struct rte_mempool *mp);
877 
905 int rte_mempool_populate_iova(struct rte_mempool *mp, char *vaddr,
906  rte_iova_t iova, size_t len, rte_mempool_memchunk_free_cb_t *free_cb,
907  void *opaque);
908 
909 __rte_deprecated
910 int rte_mempool_populate_phys(struct rte_mempool *mp, char *vaddr,
911  phys_addr_t paddr, size_t len, rte_mempool_memchunk_free_cb_t *free_cb,
912  void *opaque);
913 
940 int rte_mempool_populate_iova_tab(struct rte_mempool *mp, char *vaddr,
941  const rte_iova_t iova[], uint32_t pg_num, uint32_t pg_shift,
942  rte_mempool_memchunk_free_cb_t *free_cb, void *opaque);
943 
944 __rte_deprecated
945 int rte_mempool_populate_phys_tab(struct rte_mempool *mp, char *vaddr,
946  const phys_addr_t paddr[], uint32_t pg_num, uint32_t pg_shift,
947  rte_mempool_memchunk_free_cb_t *free_cb, void *opaque);
948 
973 int
974 rte_mempool_populate_virt(struct rte_mempool *mp, char *addr,
975  size_t len, size_t pg_sz, rte_mempool_memchunk_free_cb_t *free_cb,
976  void *opaque);
977 
992 
1006 int rte_mempool_populate_anon(struct rte_mempool *mp);
1007 
1023 uint32_t rte_mempool_obj_iter(struct rte_mempool *mp,
1024  rte_mempool_obj_cb_t *obj_cb, void *obj_cb_arg);
1025 
1041 uint32_t rte_mempool_mem_iter(struct rte_mempool *mp,
1042  rte_mempool_mem_cb_t *mem_cb, void *mem_cb_arg);
1043 
1052 void rte_mempool_dump(FILE *f, struct rte_mempool *mp);
1053 
1068 struct rte_mempool_cache *
1069 rte_mempool_cache_create(uint32_t size, int socket_id);
1070 
1077 void
1079 
1088 static __rte_always_inline void
1090  struct rte_mempool *mp)
1091 {
1092  rte_mempool_ops_enqueue_bulk(mp, cache->objs, cache->len);
1093  cache->len = 0;
1094 }
1095 
1106 static __rte_always_inline struct rte_mempool_cache *
1107 rte_mempool_default_cache(struct rte_mempool *mp, unsigned lcore_id)
1108 {
1109  if (mp->cache_size == 0)
1110  return NULL;
1111 
1112  if (lcore_id >= RTE_MAX_LCORE)
1113  return NULL;
1114 
1115  return &mp->local_cache[lcore_id];
1116 }
1117 
1130 static __rte_always_inline void
1131 __mempool_generic_put(struct rte_mempool *mp, void * const *obj_table,
1132  unsigned int n, struct rte_mempool_cache *cache)
1133 {
1134  void **cache_objs;
1135 
1136  /* increment stat now, adding in mempool always success */
1137  __MEMPOOL_STAT_ADD(mp, put, n);
1138 
1139  /* No cache provided or if put would overflow mem allocated for cache */
1140  if (unlikely(cache == NULL || n > RTE_MEMPOOL_CACHE_MAX_SIZE))
1141  goto ring_enqueue;
1142 
1143  cache_objs = &cache->objs[cache->len];
1144 
1145  /*
1146  * The cache follows the following algorithm
1147  * 1. Add the objects to the cache
1148  * 2. Anything greater than the cache min value (if it crosses the
1149  * cache flush threshold) is flushed to the ring.
1150  */
1151 
1152  /* Add elements back into the cache */
1153  rte_memcpy(&cache_objs[0], obj_table, sizeof(void *) * n);
1154 
1155  cache->len += n;
1156 
1157  if (cache->len >= cache->flushthresh) {
1158  rte_mempool_ops_enqueue_bulk(mp, &cache->objs[cache->size],
1159  cache->len - cache->size);
1160  cache->len = cache->size;
1161  }
1162 
1163  return;
1164 
1165 ring_enqueue:
1166 
1167  /* push remaining objects in ring */
1168 #ifdef RTE_LIBRTE_MEMPOOL_DEBUG
1169  if (rte_mempool_ops_enqueue_bulk(mp, obj_table, n) < 0)
1170  rte_panic("cannot put objects in mempool\n");
1171 #else
1172  rte_mempool_ops_enqueue_bulk(mp, obj_table, n);
1173 #endif
1174 }
1175 
1176 
1189 static __rte_always_inline void
1190 rte_mempool_generic_put(struct rte_mempool *mp, void * const *obj_table,
1191  unsigned int n, struct rte_mempool_cache *cache)
1192 {
1193  __mempool_check_cookies(mp, obj_table, n, 0);
1194  __mempool_generic_put(mp, obj_table, n, cache);
1195 }
1196 
1211 static __rte_always_inline void
1212 rte_mempool_put_bulk(struct rte_mempool *mp, void * const *obj_table,
1213  unsigned int n)
1214 {
1215  struct rte_mempool_cache *cache;
1216  cache = rte_mempool_default_cache(mp, rte_lcore_id());
1217  rte_mempool_generic_put(mp, obj_table, n, cache);
1218 }
1219 
1232 static __rte_always_inline void
1233 rte_mempool_put(struct rte_mempool *mp, void *obj)
1234 {
1235  rte_mempool_put_bulk(mp, &obj, 1);
1236 }
1237 
1252 static __rte_always_inline int
1253 __mempool_generic_get(struct rte_mempool *mp, void **obj_table,
1254  unsigned int n, struct rte_mempool_cache *cache)
1255 {
1256  int ret;
1257  uint32_t index, len;
1258  void **cache_objs;
1259 
1260  /* No cache provided or cannot be satisfied from cache */
1261  if (unlikely(cache == NULL || n >= cache->size))
1262  goto ring_dequeue;
1263 
1264  cache_objs = cache->objs;
1265 
1266  /* Can this be satisfied from the cache? */
1267  if (cache->len < n) {
1268  /* No. Backfill the cache first, and then fill from it */
1269  uint32_t req = n + (cache->size - cache->len);
1270 
1271  /* How many do we require i.e. number to fill the cache + the request */
1272  ret = rte_mempool_ops_dequeue_bulk(mp,
1273  &cache->objs[cache->len], req);
1274  if (unlikely(ret < 0)) {
1275  /*
1276  * In the offchance that we are buffer constrained,
1277  * where we are not able to allocate cache + n, go to
1278  * the ring directly. If that fails, we are truly out of
1279  * buffers.
1280  */
1281  goto ring_dequeue;
1282  }
1283 
1284  cache->len += req;
1285  }
1286 
1287  /* Now fill in the response ... */
1288  for (index = 0, len = cache->len - 1; index < n; ++index, len--, obj_table++)
1289  *obj_table = cache_objs[len];
1290 
1291  cache->len -= n;
1292 
1293  __MEMPOOL_STAT_ADD(mp, get_success, n);
1294 
1295  return 0;
1296 
1297 ring_dequeue:
1298 
1299  /* get remaining objects from ring */
1300  ret = rte_mempool_ops_dequeue_bulk(mp, obj_table, n);
1301 
1302  if (ret < 0)
1303  __MEMPOOL_STAT_ADD(mp, get_fail, n);
1304  else
1305  __MEMPOOL_STAT_ADD(mp, get_success, n);
1306 
1307  return ret;
1308 }
1309 
1330 static __rte_always_inline int
1331 rte_mempool_generic_get(struct rte_mempool *mp, void **obj_table,
1332  unsigned int n, struct rte_mempool_cache *cache)
1333 {
1334  int ret;
1335  ret = __mempool_generic_get(mp, obj_table, n, cache);
1336  if (ret == 0)
1337  __mempool_check_cookies(mp, obj_table, n, 1);
1338  return ret;
1339 }
1340 
1363 static __rte_always_inline int
1364 rte_mempool_get_bulk(struct rte_mempool *mp, void **obj_table, unsigned int n)
1365 {
1366  struct rte_mempool_cache *cache;
1367  cache = rte_mempool_default_cache(mp, rte_lcore_id());
1368  return rte_mempool_generic_get(mp, obj_table, n, cache);
1369 }
1370 
1391 static __rte_always_inline int
1392 rte_mempool_get(struct rte_mempool *mp, void **obj_p)
1393 {
1394  return rte_mempool_get_bulk(mp, obj_p, 1);
1395 }
1396 
1409 unsigned int rte_mempool_avail_count(const struct rte_mempool *mp);
1410 
1423 unsigned int
1424 rte_mempool_in_use_count(const struct rte_mempool *mp);
1425 
1439 static inline int
1441 {
1442  return !!(rte_mempool_avail_count(mp) == mp->size);
1443 }
1444 
1458 static inline int
1460 {
1461  return !!(rte_mempool_avail_count(mp) == 0);
1462 }
1463 
1474 static inline rte_iova_t
1475 rte_mempool_virt2iova(const void *elt)
1476 {
1477  const struct rte_mempool_objhdr *hdr;
1478  hdr = (const struct rte_mempool_objhdr *)RTE_PTR_SUB(elt,
1479  sizeof(*hdr));
1480  return hdr->iova;
1481 }
1482 
1483 __rte_deprecated
1484 static inline phys_addr_t
1485 rte_mempool_virt2phy(__rte_unused const struct rte_mempool *mp, const void *elt)
1486 {
1487  return rte_mempool_virt2iova(elt);
1488 }
1489 
1500 void rte_mempool_audit(struct rte_mempool *mp);
1501 
1510 static inline void *rte_mempool_get_priv(struct rte_mempool *mp)
1511 {
1512  return (char *)mp +
1514 }
1515 
1522 void rte_mempool_list_dump(FILE *f);
1523 
1536 struct rte_mempool *rte_mempool_lookup(const char *name);
1537 
1555 uint32_t rte_mempool_calc_obj_size(uint32_t elt_size, uint32_t flags,
1556  struct rte_mempool_objsz *sz);
1557 
1581 size_t rte_mempool_xmem_size(uint32_t elt_num, size_t total_elt_sz,
1582  uint32_t pg_shift, unsigned int flags);
1583 
1612 ssize_t rte_mempool_xmem_usage(void *vaddr, uint32_t elt_num,
1613  size_t total_elt_sz, const rte_iova_t iova[], uint32_t pg_num,
1614  uint32_t pg_shift, unsigned int flags);
1615 
1624 void rte_mempool_walk(void (*func)(struct rte_mempool *, void *arg),
1625  void *arg);
1626 
1627 #ifdef __cplusplus
1628 }
1629 #endif
1630 
1631 #endif /* _RTE_MEMPOOL_H_ */
uint64_t pool_id
Definition: rte_mempool.h:234
#define __rte_always_inline
Definition: rte_common.h:139
struct rte_mempool * rte_mempool_lookup(const char *name)
int(* rte_mempool_ops_register_memory_area_t)(const struct rte_mempool *mp, char *vaddr, rte_iova_t iova, size_t len)
Definition: rte_mempool.h:429
struct rte_mempool_cache * rte_mempool_cache_create(uint32_t size, int socket_id)
uint32_t rte_mempool_mem_iter(struct rte_mempool *mp, rte_mempool_mem_cb_t *mem_cb, void *mem_cb_arg)
uint32_t header_size
Definition: rte_mempool.h:245
STAILQ_ENTRY(rte_mempool_objhdr) next
const struct rte_memzone * mz
Definition: rte_mempool.h:237
static __rte_always_inline void rte_mempool_put_bulk(struct rte_mempool *mp, void *const *obj_table, unsigned int n)
Definition: rte_mempool.h:1212
struct rte_mempool * mp
Definition: rte_mempool.h:209
rte_mempool_get_capabilities_t get_capabilities
Definition: rte_mempool.h:442
void rte_mempool_list_dump(FILE *f)
rte_mempool_alloc_t alloc
Definition: rte_mempool.h:434
void( rte_mempool_memchunk_free_cb_t)(struct rte_mempool_memhdr *memhdr, void *opaque)
Definition: rte_mempool.h:198
unsigned int flags
Definition: rte_mempool.h:238
void( rte_mempool_obj_cb_t)(struct rte_mempool *mp, void *opaque, void *obj, unsigned obj_idx)
Definition: rte_mempool.h:654
static __rte_always_inline void rte_mempool_generic_put(struct rte_mempool *mp, void *const *obj_table, unsigned int n, struct rte_mempool_cache *cache)
Definition: rte_mempool.h:1190
int(* rte_mempool_alloc_t)(struct rte_mempool *mp)
Definition: rte_mempool.h:395
static int rte_mempool_empty(const struct rte_mempool *mp)
Definition: rte_mempool.h:1459
#define __rte_unused
Definition: rte_common.h:105
phys_addr_t physaddr
Definition: rte_mempool.h:164
phys_addr_t phys_addr
Definition: rte_mempool.h:214
struct rte_mbuf __rte_cache_aligned
rte_mempool_memchunk_free_cb_t * free_cb
Definition: rte_mempool.h:217
char name[RTE_MEMPOOL_OPS_NAMESIZE]
Definition: rte_mempool.h:433
int(* rte_mempool_dequeue_t)(struct rte_mempool *mp, void **obj_table, unsigned int n)
Definition: rte_mempool.h:411
#define MEMPOOL_HEADER_SIZE(mp, cs)
Definition: rte_mempool.h:326
uint32_t cache_size
Definition: rte_mempool.h:241
unsigned int rte_mempool_avail_count(const struct rte_mempool *mp)
ssize_t rte_mempool_xmem_usage(void *vaddr, uint32_t elt_num, size_t total_elt_sz, const rte_iova_t iova[], uint32_t pg_num, uint32_t pg_shift, unsigned int flags)
uint32_t size
Definition: rte_mempool.h:240
struct rte_mempool_objhdr_list elt_list
Definition: rte_mempool.h:261
#define RTE_PTR_ADD(ptr, x)
Definition: rte_common.h:151
void rte_mempool_cache_free(struct rte_mempool_cache *cache)
uint32_t total_size
Definition: rte_mempool.h:126
uint32_t rte_mempool_obj_iter(struct rte_mempool *mp, rte_mempool_obj_cb_t *obj_cb, void *obj_cb_arg)
int rte_mempool_register_ops(const struct rte_mempool_ops *ops)
#define unlikely(x)
int rte_mempool_populate_iova_tab(struct rte_mempool *mp, char *vaddr, const rte_iova_t iova[], uint32_t pg_num, uint32_t pg_shift, rte_mempool_memchunk_free_cb_t *free_cb, void *opaque)
static __rte_always_inline int rte_mempool_generic_get(struct rte_mempool *mp, void **obj_table, unsigned int n, struct rte_mempool_cache *cache)
Definition: rte_mempool.h:1331
int rte_mempool_populate_default(struct rte_mempool *mp)
static __rte_always_inline void rte_mempool_cache_flush(struct rte_mempool_cache *cache, struct rte_mempool *mp)
Definition: rte_mempool.h:1089
#define RTE_MEMPOOL_OPS_NAMESIZE
Definition: rte_mempool.h:383
static __rte_always_inline int rte_mempool_get(struct rte_mempool *mp, void **obj_p)
Definition: rte_mempool.h:1392
STAILQ_HEAD(rte_mempool_objhdr_list, rte_mempool_objhdr)
uint32_t nb_mem_chunks
Definition: rte_mempool.h:262
struct rte_mempool * mp
Definition: rte_mempool.h:160
struct rte_mempool_ops ops[RTE_MEMPOOL_MAX_OPS_IDX]
Definition: rte_mempool.h:466
rte_mempool_get_count get_count
Definition: rte_mempool.h:438
static int rte_mempool_full(const struct rte_mempool *mp)
Definition: rte_mempool.h:1440
static unsigned rte_lcore_id(void)
Definition: rte_lcore.h:94
void * pool_config
Definition: rte_mempool.h:236
unsigned int rte_mempool_in_use_count(const struct rte_mempool *mp)
void( rte_mempool_mem_cb_t)(struct rte_mempool *mp, void *opaque, struct rte_mempool_memhdr *memhdr, unsigned mem_idx)
Definition: rte_mempool.h:663
static __rte_always_inline int rte_mempool_get_bulk(struct rte_mempool *mp, void **obj_table, unsigned int n)
Definition: rte_mempool.h:1364
#define rte_panic(...)
Definition: rte_debug.h:79
int rte_mempool_set_ops_byname(struct rte_mempool *mp, const char *name, void *pool_config)
int rte_mempool_populate_iova(struct rte_mempool *mp, char *vaddr, rte_iova_t iova, size_t len, rte_mempool_memchunk_free_cb_t *free_cb, void *opaque)
unsigned(* rte_mempool_get_count)(const struct rte_mempool *mp)
Definition: rte_mempool.h:417
uint32_t rte_mempool_calc_obj_size(uint32_t elt_size, uint32_t flags, struct rte_mempool_objsz *sz)
void * objs[RTE_MEMPOOL_CACHE_MAX_SIZE *3]
Definition: rte_mempool.h:116
void * pool_data
Definition: rte_mempool.h:233
int rte_mempool_populate_virt(struct rte_mempool *mp, char *addr, size_t len, size_t pg_sz, rte_mempool_memchunk_free_cb_t *free_cb, void *opaque)
uint32_t elt_size
Definition: rte_mempool.h:244
void rte_mempool_audit(struct rte_mempool *mp)
struct rte_mempool * rte_mempool_create_empty(const char *name, unsigned n, unsigned elt_size, unsigned cache_size, unsigned private_data_size, int socket_id, unsigned flags)
unsigned private_data_size
Definition: rte_mempool.h:248
void( rte_mempool_ctor_t)(struct rte_mempool *, void *)
Definition: rte_mempool.h:673
rte_spinlock_t sl
Definition: rte_mempool.h:461
static __rte_always_inline struct rte_mempool_cache * rte_mempool_default_cache(struct rte_mempool *mp, unsigned lcore_id)
Definition: rte_mempool.h:1107
void rte_mempool_dump(FILE *f, struct rte_mempool *mp)
int rte_mempool_populate_anon(struct rte_mempool *mp)
struct rte_mempool_cache * local_cache
Definition: rte_mempool.h:258
uint32_t trailer_size
Definition: rte_mempool.h:246
STAILQ_ENTRY(rte_mempool_memhdr) next
#define RTE_STD_C11
Definition: rte_common.h:66
rte_mempool_dequeue_t dequeue
Definition: rte_mempool.h:437
int(* rte_mempool_enqueue_t)(struct rte_mempool *mp, void *const *obj_table, unsigned int n)
Definition: rte_mempool.h:405
rte_mempool_ops_register_memory_area_t register_memory_area
Definition: rte_mempool.h:446
int(* rte_mempool_get_capabilities_t)(const struct rte_mempool *mp, unsigned int *flags)
Definition: rte_mempool.h:422
uint64_t rte_iova_t
Definition: rte_memory.h:107
uint32_t flushthresh
Definition: rte_mempool.h:110
struct rte_mempool_memhdr_list mem_list
Definition: rte_mempool.h:263
struct rte_mempool * rte_mempool_create(const char *name, unsigned n, unsigned elt_size, unsigned cache_size, unsigned private_data_size, rte_mempool_ctor_t *mp_init, void *mp_init_arg, rte_mempool_obj_cb_t *obj_init, void *obj_init_arg, int socket_id, unsigned flags)
uint64_t phys_addr_t
Definition: rte_memory.h:98
#define RTE_PTR_SUB(ptr, x)
Definition: rte_common.h:156
static struct rte_mempool * rte_mempool_from_obj(void *obj)
Definition: rte_mempool.h:346
uint32_t header_size
Definition: rte_mempool.h:124
int32_t ops_index
Definition: rte_mempool.h:256
static void * rte_memcpy(void *dst, const void *src, size_t n)
uint32_t populated_size
Definition: rte_mempool.h:260
static rte_iova_t rte_mempool_virt2iova(const void *elt)
Definition: rte_mempool.h:1475
static __rte_always_inline void rte_mempool_put(struct rte_mempool *mp, void *obj)
Definition: rte_mempool.h:1233
size_t rte_mempool_xmem_size(uint32_t elt_num, size_t total_elt_sz, uint32_t pg_shift, unsigned int flags)
void rte_mempool_free(struct rte_mempool *mp)
void rte_mempool_walk(void(*func)(struct rte_mempool *, void *arg), void *arg)
static void * rte_mempool_get_priv(struct rte_mempool *mp)
Definition: rte_mempool.h:1510
char name[RTE_MEMZONE_NAMESIZE]
Definition: rte_mempool.h:230
uint32_t trailer_size
Definition: rte_mempool.h:125
#define RTE_MEMPOOL_MAX_OPS_IDX
Definition: rte_mempool.h:449
void(* rte_mempool_free_t)(struct rte_mempool *mp)
Definition: rte_mempool.h:400
rte_mempool_free_t free
Definition: rte_mempool.h:435
struct rte_mempool * rte_mempool_xmem_create(const char *name, unsigned n, unsigned elt_size, unsigned cache_size, unsigned private_data_size, rte_mempool_ctor_t *mp_init, void *mp_init_arg, rte_mempool_obj_cb_t *obj_init, void *obj_init_arg, int socket_id, unsigned flags, void *vaddr, const rte_iova_t iova[], uint32_t pg_num, uint32_t pg_shift)
rte_mempool_enqueue_t enqueue
Definition: rte_mempool.h:436
#define RTE_MEMZONE_NAMESIZE
Definition: rte_memzone.h:78