mempool: introduce function to get mempool page size
[dpdk.git] / lib / librte_mempool / rte_mempool.h
index 5d16025..9e41f59 100644 (file)
@@ -427,7 +427,7 @@ typedef int (*rte_mempool_dequeue_t)(struct rte_mempool *mp,
  * @warning
  * @b EXPERIMENTAL: this API may change without prior notice.
  *
- * Dequeue a number of contiquous object blocks from the external pool.
+ * Dequeue a number of contiguous object blocks from the external pool.
  */
 typedef int (*rte_mempool_dequeue_contig_blocks_t)(struct rte_mempool *mp,
                 void **first_obj_table, unsigned int n);
@@ -458,7 +458,7 @@ typedef unsigned (*rte_mempool_get_count)(const struct rte_mempool *mp);
  * @param[out] align
  *   Location for required memory chunk alignment.
  * @return
- *   Required memory size aligned at page boundary.
+ *   Required memory size.
  */
 typedef ssize_t (*rte_mempool_calc_mem_size_t)(const struct rte_mempool *mp,
                uint32_t obj_num,  uint32_t pg_shift,
@@ -477,38 +477,13 @@ typedef ssize_t (*rte_mempool_calc_mem_size_t)(const struct rte_mempool *mp,
  * that pages are grouped in subsets of physically continuous pages big
  * enough to store at least one object.
  *
- * Minimum size of memory chunk is a maximum of the page size and total
- * element size.
- *
- * Required memory chunk alignment is a maximum of page size and cache
- * line size.
+ * Minimum size of memory chunk is the total element size.
+ * Required memory chunk alignment is the cache line size.
  */
 ssize_t rte_mempool_op_calc_mem_size_default(const struct rte_mempool *mp,
                uint32_t obj_num, uint32_t pg_shift,
                size_t *min_chunk_size, size_t *align);
 
-/**
- * @internal Helper function to calculate memory size required to store
- * specified number of objects in assumption that the memory buffer will
- * be aligned at page boundary.
- *
- * Note that if object size is bigger than page size, then it assumes
- * that pages are grouped in subsets of physically continuous pages big
- * enough to store at least one object.
- *
- * @param elt_num
- *   Number of elements.
- * @param total_elt_sz
- *   The size of each element, including header and trailer, as returned
- *   by rte_mempool_calc_obj_size().
- * @param pg_shift
- *   LOG2 of the physical pages size. If set to 0, ignore page boundaries.
- * @return
- *   Required memory size aligned at page boundary.
- */
-size_t rte_mempool_calc_mem_size_helper(uint32_t elt_num, size_t total_elt_sz,
-               uint32_t pg_shift);
-
 /**
  * Function to be called for each populated object.
  *
@@ -854,10 +829,9 @@ int rte_mempool_register_ops(const struct rte_mempool_ops *ops);
  * 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)                                      \
-       void mp_hdlr_init_##ops(void);                                  \
-       void __attribute__((constructor, used)) mp_hdlr_init_##ops(void)\
-       {                                                               \
+#define MEMPOOL_REGISTER_OPS(ops)                              \
+       RTE_INIT(mp_hdlr_init_##ops)                            \
+       {                                                       \
                rte_mempool_register_ops(&ops);                 \
        }
 
@@ -1065,9 +1039,8 @@ int rte_mempool_populate_iova(struct rte_mempool *mp, char *vaddr,
  *   A pointer to the mempool structure.
  * @param addr
  *   The virtual address of memory that should be used to store objects.
- *   Must be page-aligned.
  * @param len
- *   The length of memory in bytes. Must be page-aligned.
+ *   The length of memory in bytes.
  * @param pg_sz
  *   The size of memory pages in this virtual area.
  * @param free_cb
@@ -1386,7 +1359,7 @@ __mempool_generic_get(struct rte_mempool *mp, void **obj_table,
                        &cache->objs[cache->len], req);
                if (unlikely(ret < 0)) {
                        /*
-                        * In the offchance that we are buffer constrained,
+                        * In the off chance that we are buffer constrained,
                         * where we are not able to allocate cache + n, go to
                         * the ring directly. If that fails, we are truly out of
                         * buffers.
@@ -1715,6 +1688,17 @@ uint32_t rte_mempool_calc_obj_size(uint32_t elt_size, uint32_t flags,
 void rte_mempool_walk(void (*func)(struct rte_mempool *, void *arg),
                      void *arg);
 
+/**
+ * @warning
+ * @b EXPERIMENTAL: this API may change without prior notice.
+ *
+ * @internal Get page size used for mempool object allocation.
+ * This function is internal to mempool library and mempool drivers.
+ */
+__rte_experimental
+int
+rte_mempool_get_page_size(struct rte_mempool *mp, size_t *pg_sz);
+
 #ifdef __cplusplus
 }
 #endif