From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-DM3-obe.outbound.protection.outlook.com (mail-dm3nam03on0047.outbound.protection.outlook.com [104.47.41.47]) by dpdk.org (Postfix) with ESMTP id BD59537B1 for ; Sun, 1 Oct 2017 11:29:46 +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=bkusawx6/W1KFm9MM5tTG4rLuG9+odp+pyCO7FPzz40=; b=kpvyp6Oz1oYSc8nLRGMOchFzcFE1le0VSHUcLuZi79z5TldkohoLCsjqaf7B3x06EyvgW9DcMvPlAULvNNbAlc2IF1ySS4/Jfq9GMfxR1tLZKzEr1AYQlNPJp/efxJO8b6MJwvHiKfBXpLhWyabwkCkwoLl/3OYe6TNV6q4dGVo= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Santosh.Shukla@cavium.com; Received: from localhost.localdomain (111.93.218.67) by DM5PR07MB3098.namprd07.prod.outlook.com (10.172.85.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.77.7; Sun, 1 Oct 2017 09:29:42 +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: Sun, 1 Oct 2017 14:58:57 +0530 Message-Id: <20171001092902.10842-4-santosh.shukla@caviumnetworks.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171001092902.10842-1-santosh.shukla@caviumnetworks.com> References: <20170907153042.30890-1-santosh.shukla@caviumnetworks.com> <20171001092902.10842-1-santosh.shukla@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [111.93.218.67] X-ClientProxiedBy: BM1PR01CA0077.INDPRD01.PROD.OUTLOOK.COM (10.174.208.145) To DM5PR07MB3098.namprd07.prod.outlook.com (10.172.85.8) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4373f397-cc14-468a-22d0-08d508aef420 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(2017030254152)(2017052603199)(201703131423075)(201703031133081)(201702281549075); SRVR:DM5PR07MB3098; X-Microsoft-Exchange-Diagnostics: 1; DM5PR07MB3098; 3:HwIT2wC+YjNF2Y+TBol2LiqlDSsXo7AeNiWQ3SahyrMjsS5m+F0nqCGtK9fZi7YXKie/30HmxCUWfK4YzjAGt+WC3tn/vXHPKjC4JdymckWT1e3T4f5YroNNlldpkAHAnVG8dw6ai10OXBNn0R/Ez7VP6oh5gQJ8VT8UX97EEwgb+IslBREcSxzwBcNAUXMddPJ4NIGoXOOl3qe+VoNa0eIwGinyYh8NYsjzKbr3H/CzrsOQMt8Su0jdhf5ryE6e; 25:XlvyXjCYEVYJygX1WfPuWnJGCrLYlVNrcVaYIG7n/sa+qnbGjCJkbhjfrFJV+0NdRNj0RXCzkNCtVqjipI+KcOdf7KXYY470QqlULkJmJy1/ojmkQlTXVN6dmhJ59v9s4DrJ0tuM0lvY+XXxwZD+bZLfcXEaDu4mUpfwhEfGzMs8vKLtBq4+3NzzUmfVtNfsMqOqYix2LfA1zhL6GRX74YL9yuWQILKTgLF0S4sjLQcBCgCxbMlEHz3nfDKLJYPFn4/OXZT3TzxFA8w70bImPQXOwzjYMIulZcspHFjhbkH194IippBo+MYAvgwHiIUs+BIqRUMrzN/4wCyVJfENQA==; 31:hYGNXbOTTX89WNcWAISt54LV6Pgt26/pybLG9eomqOb9DrcV4QJeSTXv3GDOlrLkODUqjpkoyt7WxGsqi+1/DqYFGq0tnbsEOLJJWBDGeH6N3xhcZAcL9D7MUKQDIW+MBwZIVYokucBqTzstMzwaOMT7rN2n72tK9ERg5Tgr5d6CGCyIOiCr10iHZlLZvmmS7oONp2Tz7tFz0Zr91CY+X6o6cZ5toboxrrOPQgj4oTE= X-MS-TrafficTypeDiagnostic: DM5PR07MB3098: X-Microsoft-Exchange-Diagnostics: 1; DM5PR07MB3098; 20:IGSj+LycaaBiGQexWX7UHXFsViEAzFMdIozhVykoRxhq9jPtdkWQHHKv/sJ/TcEZxFwMrXunTFVzP9H67ngTCP1SKuwhggf/IcNtZhjRWll4w9UuJKoTgReWk4ovsNjqUEMwVfHbRsmLgFCQu4C4Dus7xDXi5M5eYQ/rl7bhr3NEZubXg0Ye/WzuUIMgotTUsm6dybMkwZkoUf9KlKdtDr4jjDMUx4a0gusgV9vLUzWr8GXtwlj3kdP7/ASweUX1A4AaTZZTLjjiAqXE/Ni+djaALiKRhxKtqQgM8aGEpUKPHvdBughk9KTUCEpWXEzY61vPhdmgbmYnbcdDbgdn0iszWtG/QptM64tAAFyHMZOeuf2oBCQqLLcijuDoKUqSDh7LZzlTs3gEo+/3wx7i7QuO1lqKWLawPMAxtHXfEQG8595puMygYp3hPXeU0JFir3rf6f7vayaKaFvHMu67wN5MlRyTFMv6k9S7XDaJOzIJcLtjG9dq2JcoGonh7i+3JlspMygqRITjaWDYhjGtjsQATZD9CPscXNBia4b9ytkR0/Xu2Xc0mzEfAfO5XMwgzvq+E/Wk+mVEkCAlfnotACHynHR63FpIrt1+Ex0sytA=; 4:FJC7fkx5oloMfwMCjOdUmZ3GjIvzBPLRfU4xdV/CtBpYWO2Utj1JeQuQettJ2eEaRQ4+55vWvX8kO/aRTlVp7lGOHa8wnh1iNK+5Z8o8BCWB6EPscVzu4QxkxDRKnBYA8HjqlIGm53mlHNUdz5FVfya8LJKOi9gkDHs04fbDsWiObhOP3RGxVlLceL2D5IHZaepGODrZaLiHK7zcj4qeCKhoF1P85AfKcp/sznqC/+eYYLkSu3EUH3kfn4e5ivyGFlWPAQ2nd+2n4DmJ8mcWlQ83DvWeFBei+F/QeyLUEoU= 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)(5005006)(8121501046)(100000703101)(100105400095)(93006095)(3002001)(10201501046)(6041248)(20161123558100)(20161123560025)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(20161123562025)(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: 0447DB1C71 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(6069001)(376002)(346002)(189002)(199003)(101416001)(478600001)(189998001)(106356001)(50986999)(81166006)(16586007)(81156014)(8676002)(72206003)(68736007)(42882006)(50466002)(8936002)(5660300001)(16526017)(48376002)(8656003)(2950100002)(2906002)(105586002)(66066001)(3846002)(6512007)(1076002)(36756003)(47776003)(316002)(76176999)(6116002)(4326008)(97736004)(53936002)(5009440100003)(25786009)(50226002)(6486002)(107886003)(6666003)(5003940100001)(33646002)(6506006)(305945005)(7736002); 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:xscUgjKr1kCK3EUUVWaAtQp19nphH5lvs1Q3fhRwH?= =?us-ascii?Q?CrtfaHaLDO8zvHX8KUnBkYJJ84x6/Fzh2O4glAfCxcx2ozrIFsACRaCsm1+i?= =?us-ascii?Q?8uTGwNsly7th4yi3liP5M+HvycZs83I9ilrivlm2d2ZgLLVPfKjNoGUYW5S+?= =?us-ascii?Q?ugs8Auq0IvjEuAXVk45O1wjDO87br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utput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Oct 2017 09:29:42.9189 (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 v7 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: Sun, 01 Oct 2017 09:29:47 -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 Acked-by: Olivier Matz --- 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..85eb770dc 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 flags. * @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 flags. * @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.14.1