All of lore.kernel.org
 help / color / mirror / Atom feed
From: Santosh Shukla <santosh.shukla@caviumnetworks.com>
To: olivier.matz@6wind.com, dev@dpdk.org
Cc: thomas@monjalon.net, jerin.jacob@caviumnetworks.com,
	hemant.agrawal@nxp.com,
	Santosh Shukla <santosh.shukla@caviumnetworks.com>
Subject: [PATCH v5 3/8] mempool: add flags arg in xmem size and usage
Date: Wed,  6 Sep 2017 16:58:29 +0530	[thread overview]
Message-ID: <20170906112834.32378-4-santosh.shukla@caviumnetworks.com> (raw)
In-Reply-To: <20170906112834.32378-1-santosh.shukla@caviumnetworks.com>

xmem_size and xmem_usage need to know the status of mempool flags,
so add 'flags' arg in _xmem_size/usage() api.

Following patch will make use of that.

Signed-off-by: Santosh Shukla <santosh.shukla@caviumnetworks.com>
Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
---
v4 --> v5:
- Removed 'mp' param and replaced with 'flags' param for
  xmem_size/_usage api. (suggested by Olivier)
Refer [1].
[1] http://dpdk.org/dev/patchwork/patch/27596/

 drivers/net/xenvirt/rte_mempool_gntalloc.c |  7 ++++---
 lib/librte_mempool/rte_mempool.c           | 11 +++++++----
 lib/librte_mempool/rte_mempool.h           |  8 ++++++--
 test/test/test_mempool.c                   |  7 ++++---
 4 files changed, 21 insertions(+), 12 deletions(-)

diff --git a/drivers/net/xenvirt/rte_mempool_gntalloc.c b/drivers/net/xenvirt/rte_mempool_gntalloc.c
index 73e82f808..7f7aecdc1 100644
--- a/drivers/net/xenvirt/rte_mempool_gntalloc.c
+++ b/drivers/net/xenvirt/rte_mempool_gntalloc.c
@@ -79,7 +79,7 @@ _create_mempool(const char *name, unsigned elt_num, 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)
+		   int socket_id, unsigned int flags)
 {
 	struct _mempool_gntalloc_info mgi;
 	struct rte_mempool *mp = NULL;
@@ -114,7 +114,7 @@ _create_mempool(const char *name, unsigned elt_num, unsigned elt_size,
 	pg_shift = rte_bsf32(pg_sz);
 
 	rte_mempool_calc_obj_size(elt_size, flags, &objsz);
-	sz = rte_mempool_xmem_size(elt_num, objsz.total_size, pg_shift);
+	sz = rte_mempool_xmem_size(elt_num, objsz.total_size, pg_shift, flags);
 	pg_num = sz >> pg_shift;
 
 	pa_arr = calloc(pg_num, sizeof(pa_arr[0]));
@@ -162,7 +162,8 @@ _create_mempool(const char *name, unsigned elt_num, unsigned elt_size,
 	 * Check that allocated size is big enough to hold elt_num
 	 * objects and a calcualte how many bytes are actually required.
 	 */
-	usz = rte_mempool_xmem_usage(va, elt_num, objsz.total_size, pa_arr, pg_num, pg_shift);
+	usz = rte_mempool_xmem_usage(va, elt_num, objsz.total_size, pa_arr,
+				     pg_num, pg_shift, flags);
 	if (usz < 0) {
 		mp = NULL;
 		i = pg_num;
diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c
index 237665c65..005240042 100644
--- a/lib/librte_mempool/rte_mempool.c
+++ b/lib/librte_mempool/rte_mempool.c
@@ -238,7 +238,8 @@ rte_mempool_calc_obj_size(uint32_t elt_size, uint32_t flags,
  * Calculate maximum amount of memory required to store given number of objects.
  */
 size_t
-rte_mempool_xmem_size(uint32_t elt_num, size_t total_elt_sz, uint32_t pg_shift)
+rte_mempool_xmem_size(uint32_t elt_num, size_t total_elt_sz, uint32_t pg_shift,
+		      __rte_unused unsigned int flags)
 {
 	size_t obj_per_page, pg_num, pg_sz;
 
@@ -264,7 +265,7 @@ rte_mempool_xmem_size(uint32_t elt_num, size_t total_elt_sz, uint32_t pg_shift)
 ssize_t
 rte_mempool_xmem_usage(__rte_unused void *vaddr, uint32_t elt_num,
 	size_t total_elt_sz, const phys_addr_t paddr[], uint32_t pg_num,
-	uint32_t pg_shift)
+	uint32_t pg_shift, __rte_unused unsigned int flags)
 {
 	uint32_t elt_cnt = 0;
 	phys_addr_t start, end;
@@ -543,7 +544,8 @@ rte_mempool_populate_default(struct rte_mempool *mp)
 
 	total_elt_sz = mp->header_size + mp->elt_size + mp->trailer_size;
 	for (mz_id = 0, n = mp->size; n > 0; mz_id++, n -= ret) {
-		size = rte_mempool_xmem_size(n, total_elt_sz, pg_shift);
+		size = rte_mempool_xmem_size(n, total_elt_sz, pg_shift,
+						mp->flags);
 
 		ret = snprintf(mz_name, sizeof(mz_name),
 			RTE_MEMPOOL_MZ_FORMAT "_%d", mp->name, mz_id);
@@ -600,7 +602,8 @@ get_anon_size(const struct rte_mempool *mp)
 	pg_sz = getpagesize();
 	pg_shift = rte_bsf32(pg_sz);
 	total_elt_sz = mp->header_size + mp->elt_size + mp->trailer_size;
-	size = rte_mempool_xmem_size(mp->size, total_elt_sz, pg_shift);
+	size = rte_mempool_xmem_size(mp->size, total_elt_sz, pg_shift,
+					mp->flags);
 
 	return size;
 }
diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_mempool.h
index bf65d62fe..202854f30 100644
--- a/lib/librte_mempool/rte_mempool.h
+++ b/lib/librte_mempool/rte_mempool.h
@@ -1476,11 +1476,13 @@ uint32_t rte_mempool_calc_obj_size(uint32_t elt_size, uint32_t flags,
  *   by rte_mempool_calc_obj_size().
  * @param pg_shift
  *   LOG2 of the physical pages size. If set to 0, ignore page boundaries.
+ * @param flags
+ *  The mempool flag.
  * @return
  *   Required memory size aligned at page boundary.
  */
 size_t rte_mempool_xmem_size(uint32_t elt_num, size_t total_elt_sz,
-	uint32_t pg_shift);
+	uint32_t pg_shift, unsigned int flags);
 
 /**
  * Get the size of memory required to store mempool elements.
@@ -1503,6 +1505,8 @@ size_t rte_mempool_xmem_size(uint32_t elt_num, size_t total_elt_sz,
  *   Number of elements in the paddr array.
  * @param pg_shift
  *   LOG2 of the physical pages size.
+ * @param flags
+ *  The mempool flag.
  * @return
  *   On success, the number of bytes needed to store given number of
  *   objects, aligned to the given page size. If the provided memory
@@ -1511,7 +1515,7 @@ size_t rte_mempool_xmem_size(uint32_t elt_num, size_t total_elt_sz,
  */
 ssize_t rte_mempool_xmem_usage(void *vaddr, uint32_t elt_num,
 	size_t total_elt_sz, const phys_addr_t paddr[], uint32_t pg_num,
-	uint32_t pg_shift);
+	uint32_t pg_shift, unsigned int flags);
 
 /**
  * Walk list of all memory pools
diff --git a/test/test/test_mempool.c b/test/test/test_mempool.c
index 47dc3ac5f..a225e1209 100644
--- a/test/test/test_mempool.c
+++ b/test/test/test_mempool.c
@@ -474,7 +474,7 @@ test_mempool_same_name_twice_creation(void)
 }
 
 /*
- * BAsic test for mempool_xmem functions.
+ * Basic test for mempool_xmem functions.
  */
 static int
 test_mempool_xmem_misc(void)
@@ -485,10 +485,11 @@ test_mempool_xmem_misc(void)
 
 	elt_num = MAX_KEEP;
 	total_size = rte_mempool_calc_obj_size(MEMPOOL_ELT_SIZE, 0, NULL);
-	sz = rte_mempool_xmem_size(elt_num, total_size, MEMPOOL_PG_SHIFT_MAX);
+	sz = rte_mempool_xmem_size(elt_num, total_size, MEMPOOL_PG_SHIFT_MAX,
+					0);
 
 	usz = rte_mempool_xmem_usage(NULL, elt_num, total_size, 0, 1,
-		MEMPOOL_PG_SHIFT_MAX);
+		MEMPOOL_PG_SHIFT_MAX, 0);
 
 	if (sz != (size_t)usz)  {
 		printf("failure @ %s: rte_mempool_xmem_usage(%u, %u) "
-- 
2.11.0

  parent reply	other threads:[~2017-09-06 11:29 UTC|newest]

Thread overview: 116+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-21 17:32 [PATCH 0/4] Infrastructure to support octeontx HW mempool manager Santosh Shukla
2017-06-21 17:32 ` [PATCH 1/4] mempool: get the external mempool capability Santosh Shukla
2017-07-03 16:37   ` Olivier Matz
2017-07-05  6:41     ` santosh
2017-07-10 13:55       ` Olivier Matz
2017-07-10 16:09         ` santosh
2017-06-21 17:32 ` [PATCH 2/4] mempool: detect physical contiguous object in pool Santosh Shukla
2017-07-03 16:37   ` Olivier Matz
2017-07-05  7:07     ` santosh
2017-06-21 17:32 ` [PATCH 3/4] mempool: introduce block size align flag Santosh Shukla
2017-07-03 16:37   ` Olivier Matz
2017-07-05  7:35     ` santosh
2017-07-10 13:15       ` Olivier Matz
2017-07-10 16:22         ` santosh
2017-06-21 17:32 ` [PATCH 4/4] mempool: update range info to pool Santosh Shukla
2017-07-13  9:32 ` [PATCH v2 0/6] Infrastructure to support octeontx HW mempool manager Santosh Shukla
2017-07-13  9:32   ` [PATCH v2 1/6] mempool: fix flags data type Santosh Shukla
2017-07-13  9:32   ` [PATCH v2 2/6] mempool: get the mempool capability Santosh Shukla
2017-07-13  9:32   ` [PATCH v2 3/6] mempool: detect physical contiguous object in pool Santosh Shukla
2017-07-13  9:32   ` [PATCH v2 4/6] mempool: add mempool arg in xmem size and usage Santosh Shukla
2017-07-13  9:32   ` [PATCH v2 5/6] mempool: introduce block size align flag Santosh Shukla
2017-07-13  9:32   ` [PATCH v2 6/6] mempool: update range info to pool Santosh Shukla
2017-07-18  6:07   ` [PATCH v2 0/6] Infrastructure to support octeontx HW mempool manager santosh
2017-07-20 13:47   ` [PATCH v3 " Santosh Shukla
2017-07-20 13:47     ` [PATCH v3 1/6] mempool: fix flags data type Santosh Shukla
2017-07-20 13:47     ` [PATCH v3 2/6] mempool: get the mempool capability Santosh Shukla
2017-07-20 13:47     ` [PATCH v3 3/6] mempool: detect physical contiguous object in pool Santosh Shukla
2017-07-20 13:47     ` [PATCH v3 4/6] mempool: add mempool arg in xmem size and usage Santosh Shukla
2017-07-20 13:47     ` [PATCH v3 5/6] mempool: introduce block size align flag Santosh Shukla
2017-07-20 13:47     ` [PATCH v3 6/6] mempool: update range info to pool Santosh Shukla
2017-08-15  6:07     ` [PATCH v4 0/7] Infrastructure to support octeontx HW mempool manager Santosh Shukla
2017-08-15  6:07       ` [PATCH v4 1/7] mempool: fix flags data type Santosh Shukla
2017-09-04 14:11         ` Olivier MATZ
2017-09-04 14:18           ` santosh
2017-08-15  6:07       ` [PATCH v4 2/7] mempool: add mempool arg in xmem size and usage Santosh Shukla
2017-09-04 14:22         ` Olivier MATZ
2017-09-04 14:33           ` santosh
2017-09-04 14:46             ` Olivier MATZ
2017-09-04 14:58               ` santosh
2017-09-04 15:23                 ` Olivier MATZ
2017-09-04 15:52                   ` santosh
2017-08-15  6:07       ` [PATCH v4 3/7] doc: remove mempool api change notice Santosh Shukla
2017-08-15  6:07       ` [PATCH v4 4/7] mempool: get the mempool capability Santosh Shukla
2017-09-04 14:32         ` Olivier MATZ
2017-09-04 14:44           ` santosh
2017-09-04 15:56             ` Olivier MATZ
2017-09-04 16:29               ` santosh
2017-08-15  6:07       ` [PATCH v4 5/7] mempool: detect physical contiguous object in pool Santosh Shukla
2017-09-04 14:43         ` Olivier MATZ
2017-09-04 14:47           ` santosh
2017-09-04 16:00             ` Olivier MATZ
2017-08-15  6:07       ` [PATCH v4 6/7] mempool: introduce block size align flag Santosh Shukla
2017-09-04 16:20         ` Olivier MATZ
2017-09-04 17:45           ` santosh
2017-09-07  7:27             ` Olivier MATZ
2017-09-07  7:37               ` santosh
2017-08-15  6:07       ` [PATCH v4 7/7] mempool: update range info to pool Santosh Shukla
2017-09-06 11:28       ` [PATCH v5 0/8] Infrastructure to support octeontx HW mempool manager Santosh Shukla
2017-09-06 11:28         ` [PATCH v5 1/8] mempool: remove unused flags argument Santosh Shukla
2017-09-07  7:41           ` Olivier MATZ
2017-09-06 11:28         ` [PATCH v5 2/8] mempool: change flags from int to unsigned int Santosh Shukla
2017-09-07  7:43           ` Olivier MATZ
2017-09-06 11:28         ` Santosh Shukla [this message]
2017-09-07  7:46           ` [PATCH v5 3/8] mempool: add flags arg in xmem size and usage Olivier MATZ
2017-09-07  7:49             ` santosh
2017-09-06 11:28         ` [PATCH v5 4/8] doc: remove mempool notice Santosh Shukla
2017-09-07  7:47           ` Olivier MATZ
2017-09-06 11:28         ` [PATCH v5 5/8] mempool: get the mempool capability Santosh Shukla
2017-09-07  7:59           ` Olivier MATZ
2017-09-07  8:15             ` santosh
2017-09-07  8:39               ` Olivier MATZ
2017-09-06 11:28         ` [PATCH v5 6/8] mempool: detect physical contiguous object in pool Santosh Shukla
2017-09-07  8:05           ` Olivier MATZ
2017-09-06 11:28         ` [PATCH v5 7/8] mempool: introduce block size align flag Santosh Shukla
2017-09-07  8:13           ` Olivier MATZ
2017-09-07  8:27             ` santosh
2017-09-07  8:57               ` Olivier MATZ
2017-09-06 11:28         ` [PATCH v5 8/8] mempool: update range info to pool Santosh Shukla
2017-09-07  8:30           ` Olivier MATZ
2017-09-07  8:56             ` santosh
2017-09-07  9:09               ` Olivier MATZ
2017-09-07 15:30         ` [PATCH v6 0/8] Infrastructure to support octeontx HW mempool manager Santosh Shukla
2017-09-07 15:30           ` [PATCH v6 1/8] mempool: remove unused flags argument Santosh Shukla
2017-09-07 15:30           ` [PATCH v6 2/8] mempool: change flags from int to unsigned int Santosh Shukla
2017-09-07 15:30           ` [PATCH v6 3/8] mempool: add flags arg in xmem size and usage Santosh Shukla
2017-09-25 11:24             ` Olivier MATZ
2017-09-07 15:30           ` [PATCH v6 4/8] doc: remove mempool notice Santosh Shukla
2017-09-07 15:30           ` [PATCH v6 5/8] mempool: get the mempool capability Santosh Shukla
2017-09-25 11:26             ` Olivier MATZ
2017-09-07 15:30           ` [PATCH v6 6/8] mempool: detect physical contiguous object in pool Santosh Shukla
2017-09-07 15:30           ` [PATCH v6 7/8] mempool: introduce block size align flag Santosh Shukla
2017-09-22 12:59             ` Hemant Agrawal
2017-09-25 11:32             ` Olivier MATZ
2017-09-25 22:08               ` santosh
2017-09-07 15:30           ` [PATCH v6 8/8] mempool: notify memory area to pool Santosh Shukla
2017-09-25 11:41             ` Olivier MATZ
2017-09-25 22:18               ` santosh
2017-09-29  4:53                 ` santosh
2017-09-29  8:20                   ` Olivier MATZ
2017-09-29  8:25                     ` santosh
2017-09-13  9:58           ` [PATCH v6 0/8] Infrastructure to support octeontx HW mempool manager santosh
2017-09-19  8:26             ` santosh
2017-10-01  9:28           ` [PATCH v7 " Santosh Shukla
2017-10-01  9:28             ` [PATCH v7 1/8] mempool: remove unused flags argument Santosh Shukla
2017-10-01  9:28             ` [PATCH v7 2/8] mempool: change flags from int to unsigned int Santosh Shukla
2017-10-01  9:28             ` [PATCH v7 3/8] mempool: add flags arg in xmem size and usage Santosh Shukla
2017-10-01  9:28             ` [PATCH v7 4/8] doc: remove mempool notice Santosh Shukla
2017-10-01  9:28             ` [PATCH v7 5/8] mempool: get the mempool capability Santosh Shukla
2017-10-01  9:29             ` [PATCH v7 6/8] mempool: detect physical contiguous object in pool Santosh Shukla
2017-10-01  9:29             ` [PATCH v7 7/8] mempool: introduce block size align flag Santosh Shukla
2017-10-02  8:35               ` santosh
2017-10-02 14:26               ` Olivier MATZ
2017-10-01  9:29             ` [PATCH v7 8/8] mempool: notify memory area to pool Santosh Shukla
2017-10-02  8:36               ` santosh
2017-10-02 14:27               ` Olivier MATZ
2017-10-06 20:00             ` [PATCH v7 0/8] Infrastructure to support octeontx HW mempool manager Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20170906112834.32378-4-santosh.shukla@caviumnetworks.com \
    --to=santosh.shukla@caviumnetworks.com \
    --cc=dev@dpdk.org \
    --cc=hemant.agrawal@nxp.com \
    --cc=jerin.jacob@caviumnetworks.com \
    --cc=olivier.matz@6wind.com \
    --cc=thomas@monjalon.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.