From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 2ECF8A0352; Mon, 4 Nov 2019 16:14:13 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id C89261BE0C; Mon, 4 Nov 2019 16:13:17 +0100 (CET) Received: from proxy.6wind.com (host.76.145.23.62.rev.coltfrance.com [62.23.145.76]) by dpdk.org (Postfix) with ESMTP id 5D30F378E for ; Mon, 4 Nov 2019 16:13:05 +0100 (CET) Received: from glumotte.dev.6wind.com. (unknown [10.16.0.195]) by proxy.6wind.com (Postfix) with ESMTP id 3D3F033A838; Mon, 4 Nov 2019 16:13:05 +0100 (CET) From: Olivier Matz To: dev@dpdk.org Cc: Anatoly Burakov , Andrew Rybchenko , Ferruh Yigit , "Giridharan, Ganesan" , Jerin Jacob Kollanukkaran , "Kiran Kumar Kokkilagadda" , Stephen Hemminger , Thomas Monjalon , Vamsi Krishna Attunuru , Hemant Agrawal , Nipun Gupta Date: Mon, 4 Nov 2019 16:12:52 +0100 Message-Id: <20191104151254.6354-6-olivier.matz@6wind.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20191104151254.6354-1-olivier.matz@6wind.com> References: <20190719133845.32432-1-olivier.matz@6wind.com> <20191104151254.6354-1-olivier.matz@6wind.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [dpdk-dev] [PATCH v3 5/7] mempool: introduce helpers for populate and calc mem size X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Introduce new functions that can used by mempool drivers to calculate required memory size and to populate mempool. For now, these helpers just replace the *_default() functions without change. They will be enhanced in next commit. Signed-off-by: Olivier Matz Acked-by: Nipun Gupta --- drivers/mempool/bucket/Makefile | 2 ++ drivers/mempool/bucket/meson.build | 3 ++ drivers/mempool/bucket/rte_mempool_bucket.c | 2 +- drivers/mempool/dpaa/dpaa_mempool.c | 2 +- drivers/mempool/dpaa2/dpaa2_hw_mempool.c | 2 +- drivers/mempool/octeontx/Makefile | 3 ++ drivers/mempool/octeontx/meson.build | 3 ++ .../mempool/octeontx/rte_mempool_octeontx.c | 4 +-- drivers/mempool/octeontx2/Makefile | 3 ++ drivers/mempool/octeontx2/meson.build | 3 ++ drivers/mempool/octeontx2/otx2_mempool_ops.c | 4 +-- lib/librte_mempool/rte_mempool.h | 28 +++++++++++++++-- lib/librte_mempool/rte_mempool_ops_default.c | 31 +++++++++++++++---- lib/librte_mempool/rte_mempool_version.map | 2 ++ 14 files changed, 77 insertions(+), 15 deletions(-) diff --git a/drivers/mempool/bucket/Makefile b/drivers/mempool/bucket/Makefile index 7364916bc..47be6b5f7 100644 --- a/drivers/mempool/bucket/Makefile +++ b/drivers/mempool/bucket/Makefile @@ -15,6 +15,8 @@ LIB = librte_mempool_bucket.a CFLAGS += -O3 CFLAGS += $(WERROR_FLAGS) +# for mempool populate/calc_mem_size helpers +CFLAGS += -DALLOW_EXPERIMENTAL_API LDLIBS += -lrte_eal -lrte_mempool -lrte_ring diff --git a/drivers/mempool/bucket/meson.build b/drivers/mempool/bucket/meson.build index 618d79128..29df6751c 100644 --- a/drivers/mempool/bucket/meson.build +++ b/drivers/mempool/bucket/meson.build @@ -6,4 +6,7 @@ # This software was jointly developed between OKTET Labs (under contract # for Solarflare) and Solarflare Communications, Inc. +# for mempool populate/calc_mem_size helpers +allow_experimental_apis = true + sources = files('rte_mempool_bucket.c') diff --git a/drivers/mempool/bucket/rte_mempool_bucket.c b/drivers/mempool/bucket/rte_mempool_bucket.c index 78d2b9d04..dfeaf4e45 100644 --- a/drivers/mempool/bucket/rte_mempool_bucket.c +++ b/drivers/mempool/bucket/rte_mempool_bucket.c @@ -585,7 +585,7 @@ bucket_populate(struct rte_mempool *mp, unsigned int max_objs, hdr->fill_cnt = 0; hdr->lcore_id = LCORE_ID_ANY; - rc = rte_mempool_op_populate_default(mp, + rc = rte_mempool_op_populate_helper(mp, RTE_MIN(bd->obj_per_bucket, max_objs - n_objs), iter + bucket_header_sz, diff --git a/drivers/mempool/dpaa/dpaa_mempool.c b/drivers/mempool/dpaa/dpaa_mempool.c index a25697f05..27736e6c2 100644 --- a/drivers/mempool/dpaa/dpaa_mempool.c +++ b/drivers/mempool/dpaa/dpaa_mempool.c @@ -341,7 +341,7 @@ dpaa_populate(struct rte_mempool *mp, unsigned int max_objs, */ TAILQ_INSERT_HEAD(&rte_dpaa_memsegs, ms, next); - return rte_mempool_op_populate_default(mp, max_objs, vaddr, paddr, len, + return rte_mempool_op_populate_helper(mp, max_objs, vaddr, paddr, len, obj_cb, obj_cb_arg); } diff --git a/drivers/mempool/dpaa2/dpaa2_hw_mempool.c b/drivers/mempool/dpaa2/dpaa2_hw_mempool.c index f26c30b00..8f8dbeada 100644 --- a/drivers/mempool/dpaa2/dpaa2_hw_mempool.c +++ b/drivers/mempool/dpaa2/dpaa2_hw_mempool.c @@ -421,7 +421,7 @@ dpaa2_populate(struct rte_mempool *mp, unsigned int max_objs, /* Insert entry into the PA->VA Table */ dpaax_iova_table_update(paddr, vaddr, len); - return rte_mempool_op_populate_default(mp, max_objs, vaddr, paddr, len, + return rte_mempool_op_populate_helper(mp, max_objs, vaddr, paddr, len, obj_cb, obj_cb_arg); } diff --git a/drivers/mempool/octeontx/Makefile b/drivers/mempool/octeontx/Makefile index a3e1dce88..6540a2ab4 100644 --- a/drivers/mempool/octeontx/Makefile +++ b/drivers/mempool/octeontx/Makefile @@ -11,6 +11,9 @@ LIB = librte_mempool_octeontx.a CFLAGS += $(WERROR_FLAGS) CFLAGS += -I$(RTE_SDK)/drivers/common/octeontx/ +# for mempool populate/calc_mem_size helpers +CFLAGS += -DALLOW_EXPERIMENTAL_API + EXPORT_MAP := rte_mempool_octeontx_version.map LIBABIVER := 1 diff --git a/drivers/mempool/octeontx/meson.build b/drivers/mempool/octeontx/meson.build index 3baaf7db2..f293afa96 100644 --- a/drivers/mempool/octeontx/meson.build +++ b/drivers/mempool/octeontx/meson.build @@ -1,6 +1,9 @@ # SPDX-License-Identifier: BSD-3-Clause # Copyright(c) 2017 Cavium, Inc +# for mempool populate/calc_mem_size helpers +allow_experimental_apis = true + sources = files('octeontx_fpavf.c', 'rte_mempool_octeontx.c' ) diff --git a/drivers/mempool/octeontx/rte_mempool_octeontx.c b/drivers/mempool/octeontx/rte_mempool_octeontx.c index ab94dfe91..fff33e5c6 100644 --- a/drivers/mempool/octeontx/rte_mempool_octeontx.c +++ b/drivers/mempool/octeontx/rte_mempool_octeontx.c @@ -137,7 +137,7 @@ octeontx_fpavf_calc_mem_size(const struct rte_mempool *mp, * Simply need space for one more object to be able to * fulfil alignment requirements. */ - mem_size = rte_mempool_op_calc_mem_size_default(mp, obj_num + 1, + mem_size = rte_mempool_op_calc_mem_size_helper(mp, obj_num + 1, pg_shift, min_chunk_size, align); if (mem_size >= 0) { @@ -184,7 +184,7 @@ octeontx_fpavf_populate(struct rte_mempool *mp, unsigned int max_objs, if (ret < 0) return ret; - return rte_mempool_op_populate_default(mp, max_objs, vaddr, iova, len, + return rte_mempool_op_populate_helper(mp, max_objs, vaddr, iova, len, obj_cb, obj_cb_arg); } diff --git a/drivers/mempool/octeontx2/Makefile b/drivers/mempool/octeontx2/Makefile index 87cce22c6..8f55305c5 100644 --- a/drivers/mempool/octeontx2/Makefile +++ b/drivers/mempool/octeontx2/Makefile @@ -23,6 +23,9 @@ CFLAGS += -diag-disable 2259 endif endif +# for mempool populate/calc_mem_size helpers +CFLAGS += -DALLOW_EXPERIMENTAL_API + EXPORT_MAP := rte_mempool_octeontx2_version.map LIBABIVER := 1 diff --git a/drivers/mempool/octeontx2/meson.build b/drivers/mempool/octeontx2/meson.build index 9fde40f0e..5f93bb495 100644 --- a/drivers/mempool/octeontx2/meson.build +++ b/drivers/mempool/octeontx2/meson.build @@ -2,6 +2,9 @@ # Copyright(C) 2019 Marvell International Ltd. # +# for mempool populate/calc_mem_size helpers +allow_experimental_apis = true + sources = files('otx2_mempool_ops.c', 'otx2_mempool.c', 'otx2_mempool_irq.c', diff --git a/drivers/mempool/octeontx2/otx2_mempool_ops.c b/drivers/mempool/octeontx2/otx2_mempool_ops.c index d769575f4..3aea92a01 100644 --- a/drivers/mempool/octeontx2/otx2_mempool_ops.c +++ b/drivers/mempool/octeontx2/otx2_mempool_ops.c @@ -717,7 +717,7 @@ otx2_npa_calc_mem_size(const struct rte_mempool *mp, uint32_t obj_num, * Simply need space for one more object to be able to * fulfill alignment requirements. */ - return rte_mempool_op_calc_mem_size_default(mp, obj_num + 1, pg_shift, + return rte_mempool_op_calc_mem_size_helper(mp, obj_num + 1, pg_shift, min_chunk_size, align); } @@ -749,7 +749,7 @@ otx2_npa_populate(struct rte_mempool *mp, unsigned int max_objs, void *vaddr, if (npa_lf_aura_range_update_check(mp->pool_id) < 0) return -EBUSY; - return rte_mempool_op_populate_default(mp, max_objs, vaddr, iova, len, + return rte_mempool_op_populate_helper(mp, max_objs, vaddr, iova, len, obj_cb, obj_cb_arg); } diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_mempool.h index 1282414ba..26a98af30 100644 --- a/lib/librte_mempool/rte_mempool.h +++ b/lib/librte_mempool/rte_mempool.h @@ -465,7 +465,7 @@ typedef ssize_t (*rte_mempool_calc_mem_size_t)(const struct rte_mempool *mp, size_t *min_chunk_size, size_t *align); /** - * Default way to calculate memory size required to store given number of + * Helper to calculate memory size required to store given number of * objects. * * If page boundaries may be ignored, it is just a product of total @@ -480,6 +480,18 @@ typedef ssize_t (*rte_mempool_calc_mem_size_t)(const struct rte_mempool *mp, * Minimum size of memory chunk is the total element size. * Required memory chunk alignment is the cache line size. */ +__rte_experimental +ssize_t rte_mempool_op_calc_mem_size_helper(const struct rte_mempool *mp, + uint32_t obj_num, uint32_t pg_shift, + size_t *min_chunk_size, size_t *align); + +/** + * Default way to calculate memory size required to store given number of + * objects. + * + * Equivalent to rte_mempool_op_calc_mem_size_helper(mp, obj_num, pg_shift, + * min_chunk_size, align). + */ 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); @@ -533,9 +545,21 @@ typedef int (*rte_mempool_populate_t)(struct rte_mempool *mp, rte_mempool_populate_obj_cb_t *obj_cb, void *obj_cb_arg); /** - * Default way to populate memory pool object using provided memory + * Helper to populate memory pool object using provided memory * chunk: just slice objects one by one. */ +__rte_experimental +int rte_mempool_op_populate_helper(struct rte_mempool *mp, + unsigned int max_objs, + void *vaddr, rte_iova_t iova, size_t len, + rte_mempool_populate_obj_cb_t *obj_cb, void *obj_cb_arg); + +/** + * Default way to populate memory pool object using provided memory chunk. + * + * Equivalent to rte_mempool_op_populate_helper(mp, max_objs, vaddr, iova, + * len, obj_cb, obj_cb_arg). + */ int rte_mempool_op_populate_default(struct rte_mempool *mp, unsigned int max_objs, void *vaddr, rte_iova_t iova, size_t len, diff --git a/lib/librte_mempool/rte_mempool_ops_default.c b/lib/librte_mempool/rte_mempool_ops_default.c index f6aea7662..0bfc63497 100644 --- a/lib/librte_mempool/rte_mempool_ops_default.c +++ b/lib/librte_mempool/rte_mempool_ops_default.c @@ -7,9 +7,9 @@ #include 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) +rte_mempool_op_calc_mem_size_helper(const struct rte_mempool *mp, + uint32_t obj_num, uint32_t pg_shift, + size_t *min_chunk_size, size_t *align) { size_t total_elt_sz; size_t obj_per_page, pg_sz, objs_in_last_page; @@ -61,10 +61,19 @@ rte_mempool_op_calc_mem_size_default(const struct rte_mempool *mp, return mem_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) +{ + return rte_mempool_op_calc_mem_size_helper(mp, obj_num, pg_shift, + min_chunk_size, align); +} + int -rte_mempool_op_populate_default(struct rte_mempool *mp, unsigned int max_objs, - void *vaddr, rte_iova_t iova, size_t len, - rte_mempool_populate_obj_cb_t *obj_cb, void *obj_cb_arg) +rte_mempool_op_populate_helper(struct rte_mempool *mp, unsigned int max_objs, + void *vaddr, rte_iova_t iova, size_t len, + rte_mempool_populate_obj_cb_t *obj_cb, void *obj_cb_arg) { size_t total_elt_sz; size_t off; @@ -84,3 +93,13 @@ rte_mempool_op_populate_default(struct rte_mempool *mp, unsigned int max_objs, return i; } + +int +rte_mempool_op_populate_default(struct rte_mempool *mp, unsigned int max_objs, + void *vaddr, rte_iova_t iova, size_t len, + rte_mempool_populate_obj_cb_t *obj_cb, + void *obj_cb_arg) +{ + return rte_mempool_op_populate_helper(mp, max_objs, vaddr, iova, + len, obj_cb, obj_cb_arg); +} diff --git a/lib/librte_mempool/rte_mempool_version.map b/lib/librte_mempool/rte_mempool_version.map index 4eff2767d..b5e9c91a9 100644 --- a/lib/librte_mempool/rte_mempool_version.map +++ b/lib/librte_mempool/rte_mempool_version.map @@ -57,5 +57,7 @@ EXPERIMENTAL { global: rte_mempool_get_page_size; + rte_mempool_op_calc_mem_size_helper; + rte_mempool_op_populate_helper; rte_mempool_ops_get_info; }; -- 2.20.1