From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-by2nam01on0061.outbound.protection.outlook.com [104.47.34.61]) by dpdk.org (Postfix) with ESMTP id 7050F374F for ; Wed, 6 Sep 2017 13:29:23 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=jckn5jFl5ajmCGZAa+mkn6gXa7WqOFpO/0jf2KNiCtM=; b=jnTetp4Kuobdoo4+WAKTkg1k5QLMWdRz0kMY2IHJpQsxBrCjUgXY/kZ/N1kxsCP1mJnsdz9U2GP3LLfTx7/D3aJIXfzfDd7lgCbcd0BFACG1Wdhxh1UKZsg9hRpQNVfeKoteNVAmytPP2g/5BbEXZx/I5qbBJ4l2R8nkjeslFCU= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Santosh.Shukla@cavium.com; Received: from localhost.localdomain (14.140.2.178) by DM5PR07MB3098.namprd07.prod.outlook.com (10.172.85.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.20.35.12; Wed, 6 Sep 2017 11:29:19 +0000 From: Santosh Shukla To: olivier.matz@6wind.com, dev@dpdk.org Cc: thomas@monjalon.net, jerin.jacob@caviumnetworks.com, hemant.agrawal@nxp.com, Santosh Shukla Date: Wed, 6 Sep 2017 16:58:29 +0530 Message-Id: <20170906112834.32378-4-santosh.shukla@caviumnetworks.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170906112834.32378-1-santosh.shukla@caviumnetworks.com> References: <20170815060743.21076-1-santosh.shukla@caviumnetworks.com> <20170906112834.32378-1-santosh.shukla@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [14.140.2.178] X-ClientProxiedBy: BM1PR01CA0080.INDPRD01.PROD.OUTLOOK.COM (10.174.208.148) To DM5PR07MB3098.namprd07.prod.outlook.com (10.172.85.8) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 96be3c8d-2abd-4017-c840-08d4f51a856a X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(2017030254152)(300000503095)(300135400095)(2017052603199)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:DM5PR07MB3098; X-Microsoft-Exchange-Diagnostics: 1; DM5PR07MB3098; 3:0cgiS4vAxUoogjXxMDW6FOQfeQjGwWriCMYY5axx4Km5BM6RKINtoLodkbB84HtrOaCVZKTd6taSwji+INDKWtn/dFQKkWFO2OdICEBAyPWWqLHo8Sdeb3lWpSOqvESsniDZHkAmvdBzmn8GtJE1gehPL5sDs8WXIh1c+YZQaz69QizY80Z170AGcKpAvjPJKzWdSo/QmPatA4xLs5g9ZD//a/F3p4KTLsw5dp2hpisg0QXzJfJKmY1WuxmaOHvr; 25:0KjvOZoccbfpyCTAxIxp/hSYFbxTGQE/8HQ4z4wz0Qw9HBP9OBRIyHuiswcQ/6bDiJxPJj0sFKsOpoWLhgQBF2Bud5X5u0f3944MMgN0ykSk1x0r00YF3ZpWcRZk6uJsuwRSxrZt/QawhgI7fcJbpTOJO6pATVTMPEUF0ve8VdbBXY5YpztWr3Wltbhbtq6tgaI3f0FxHEGM8Lpi4Vctj3e+Dlu8eb5QpaOeHydTk4xURlCK0RCy0rTYmVimTtVsveOYm6hgdnId0fs2SjF6C409Dk5CxdwzxxlJD7WDZT06ldPh6bsrxLeZNfjG4xCD+xmT/F6HVwxj3JlwHOLTcg==; 31:QPaEYCw4VjbUxvMwXS9ATWPztcI1sJFRpSTZ3UVs1uOFRS7WNEd+mn9q9ymyz8XWBWVrM/AU10yHUssTcUOHyih1wBkYox6HM4ILhlLlMk5C2LRcqaZDcQ7DONMN3K5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RWu1CWENFiEY94I6uZHWl+gxN7tzMXE= X-Exchange-Antispam-Report-Test: UriScan:(131327999870524); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(8121501046)(5005006)(93006095)(10201501046)(100000703101)(100105400095)(3002001)(6041248)(20161123560025)(20161123558100)(20161123564025)(20161123555025)(20161123562025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:DM5PR07MB3098; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:DM5PR07MB3098; X-Forefront-PRVS: 0422860ED4 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(6069001)(189002)(199003)(53936002)(42882006)(2950100002)(6666003)(6506006)(6486002)(6306002)(6512007)(50986999)(76176999)(106356001)(36756003)(189998001)(42186005)(105586002)(50466002)(8936002)(50226002)(48376002)(33646002)(8676002)(81156014)(81166006)(7736002)(101416001)(305945005)(966005)(68736007)(6116002)(3846002)(5003940100001)(1076002)(478600001)(5660300001)(72206003)(2906002)(25786009)(97736004)(4326008)(8656003)(5009440100003)(110136004)(107886003)(66066001)(53376002)(47776003)(110426004); DIR:OUT; SFP:1101; SCL:1; SRVR:DM5PR07MB3098; H:localhost.localdomain; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM5PR07MB3098; 23:DBWPCPEiYUj8FwuPTwjnk+uLlgRL0g2olaGIf0tOZ?= =?us-ascii?Q?6exxhuwXSM8qtLfBkIIQppgpycNTSxVC1KdVf6y4pBr0nTYEmTjudi7fID2s?= =?us-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fQORkUuo1ovSoXRJ7Q8NoQ792/2DkxEaErTMB9SCSK3gpo3TUoNCa4fhiCHuwjhJhv5+gq1I/J3xUsift7Jga+i0a21WKbuhazGICtKvyR5eaNGZ+4kSUl8afjcW3llqJJMILYE5WTISqVi2mkolw= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Sep 2017 11:29:19.8498 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR07MB3098 Subject: [dpdk-dev] [PATCH v5 3/8] mempool: add flags arg in xmem size and usage 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: , X-List-Received-Date: Wed, 06 Sep 2017 11:29:24 -0000 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 Signed-off-by: Jerin Jacob --- 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