From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-BY2-obe.outbound.protection.outlook.com (mail-by2nam03on0057.outbound.protection.outlook.com [104.47.42.57]) by dpdk.org (Postfix) with ESMTP id D938D199BE for ; Thu, 7 Sep 2017 17:31:47 +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=vkJwveSmf/xPIFDLyXWWgjH3U4nm4Uk0p7qF9g5f93E=; b=HpEeODr8HKXUysF5zxuOh3ZTl9D4GS0kZMN2a3gX8kSKG+YHAQjpM+3f0ZFVVld5PTnkZwSGQVabMREIsoXso0uAtUZh+WdyH+KeaYz1NNhSjFWUoi0fsRKNPZ/RGuxUgf+2McZoZPjNO9J7zW46KJY5pTTjvCgcOAVm6qDWHaE= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Santosh.Shukla@cavium.com; Received: from localhost.localdomain (14.140.2.178) by MWHPR07MB3101.namprd07.prod.outlook.com (10.172.95.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.13.10; Thu, 7 Sep 2017 15:31:44 +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: Thu, 7 Sep 2017 21:00:41 +0530 Message-Id: <20170907153042.30890-8-santosh.shukla@caviumnetworks.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170907153042.30890-1-santosh.shukla@caviumnetworks.com> References: <20170906112834.32378-1-santosh.shukla@caviumnetworks.com> <20170907153042.30890-1-santosh.shukla@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [14.140.2.178] X-ClientProxiedBy: BM1PR01CA0072.INDPRD01.PROD.OUTLOOK.COM (10.174.208.140) To MWHPR07MB3101.namprd07.prod.outlook.com (10.172.95.7) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9475833d-d49e-4068-0b52-08d4f6058cc5 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(300000502095)(300135100095)(22001)(2017030254152)(300000503095)(300135400095)(2017052603199)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:MWHPR07MB3101; X-Microsoft-Exchange-Diagnostics: 1; MWHPR07MB3101; 3:/8XceBQr5rGm2egNZslSxi67zR4BmDDmdgIHKhfSx1S7TZvSukRHokc8bIxqvTJtCws0hKyDD56F216byociDvqaw9WrL8ifQIjHmbYXCWduNoh9pq3fUP0e1nDRKm+7oWR1oUowMXw91JrDIIA+aqgBCDSziKSqKLAu9fi0IbgWY0Q/os3iCJWW67YqcBN09ZO8JpKDgTxNHWNtbS7pDkD8sThj0JxobejrIzq0tJXBmVrMyvl8Ngq+Bf3YE/vh; 25:P1AWdsQiAkwmqpRlBXc3MZoBjosFeE4rlzUHMARfR8qi9B9gWcjdMJjTMAELmE2YlZ8AIkSndmGD2g5KhB3e2DVf3iwFfnz+Dacp3rBbzMtgJOPgPTDbq5pedD6QfYPXNR1T7pEQFM3HXGocFG2p6p5TnPiAywJR10E322oO60DWyyXHVGu8HAd9maudU4UYdhCMeW8ezj11CEKp9bo+PjZ+QWVaHSaDQeZae+bJyUtH4U1r/r6cezCo4ILr1hnexaCgNjA8BPUBMss64Kzv3j87IInr0bjHCG1RtXSmGSsvB5eSq7L30gkB8/gDADnQZ5yrZO2hNt+PzdgfXoq58A==; 31:SSzmtATkfTe/pJS7Yp7Jo4D0P9WPMEeA8L5pp0PaiSKw0eNQIfgREOVr4gWIL3HMpvFSEVGN4gYR9cRnNXCgT5vl4IsUOPizv6PIY+RiHyqoS7IRG7ZpsZ6lhDPb3PlWNRVuQ2+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report-Test: UriScan:; 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)(20161123555025)(20161123558100)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123562025)(20161123560025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:MWHPR07MB3101; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:MWHPR07MB3101; X-Forefront-PRVS: 04238CD941 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6069001)(6009001)(189002)(199003)(25786009)(5660300001)(966005)(50986999)(76176999)(42186005)(106356001)(105586002)(4326008)(33646002)(8656003)(66066001)(53376002)(53936002)(36756003)(107886003)(110136004)(8936002)(50226002)(305945005)(6306002)(8676002)(7736002)(5003940100001)(1076002)(6512007)(47776003)(81156014)(3846002)(50466002)(6116002)(5009440100003)(101416001)(68736007)(48376002)(97736004)(81166006)(189998001)(2906002)(72206003)(6506006)(2950100002)(42882006)(6666003)(478600001)(6486002)(110426004); DIR:OUT; SFP:1101; SCL:1; SRVR:MWHPR07MB3101; 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; MWHPR07MB3101; 23:bhRSvSReZVmZu3xs/b/Tf0Wbq/Nd8RsR3QfeXXqCh?= =?us-ascii?Q?MG768pKG6+gg6UxAnO/sG8TWvHWBEh6vmsRqNwGA6C/PedZjyMl6MW31QYFI?= =?us-ascii?Q?OCZwG+jliCt305FBEkB/OJPhk1jTKAVXuUq4BEKJMbatc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2pwxNllqFMo6gk1+DHu/D2Aa04N9TIKJ5farG43/6A= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Sep 2017 15:31:44.0419 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR07MB3101 Subject: [dpdk-dev] [PATCH v6 7/8] mempool: introduce block size align flag 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: Thu, 07 Sep 2017 15:31:48 -0000 Some mempool hw like octeontx/fpa block, demands block size (/total_elem_sz) aligned object start address. Introducing an MEMPOOL_F_CAPA_BLK_ALIGNED_OBJECTS flag. If this flag is set: - Align object start address(vaddr) to a multiple of total_elt_sz. - Allocate one additional object. Additional object is needed to make sure that requested 'n' object gets correctly populated. Example: - Let's say that we get 'x' size of memory chunk from memzone. - And application has requested 'n' object from mempool. - Ideally, we start using objects at start address 0 to...(x-block_sz) for n obj. - Not necessarily first object address i.e. 0 is aligned to block_sz. - So we derive 'offset' value for block_sz alignment purpose i.e..'off'. - That 'off' makes sure that start address of object is blk_sz aligned. - Calculating 'off' may end up sacrificing first block_sz area of memzone area x. So total number of the object which can fit in the pool area is n-1, Which is incorrect behavior. Therefore we request one additional object (/block_sz area) from memzone when MEMPOOL_F_CAPA_BLK_ALIGNED_OBJECTS flag is set. Signed-off-by: Santosh Shukla Signed-off-by: Jerin Jacob --- v5 --> v6: - Renamed from MEMPOOL_F_BLK_ALIGNED_OBJECTS to MEMPOOL_F_CAPA_BLK_ALIGNED_OBJECTS. (Suggested by Olivier) - Updated Capability flag descrioption (Suggested by Olivier) History refer [1] [1] http://dpdk.org/dev/patchwork/patch/28418/ v4 --> v5: - Added vaddr in git description of patch (suggested by Olivier) - Renamed to aligned flag to MEMPOOL_F_BLK_ALIGNED_OBJECTS (suggested by Olivier) Refer [2]. [2] http://dpdk.org/dev/patchwork/patch/27600/ lib/librte_mempool/rte_mempool.c | 19 ++++++++++++++++--- lib/librte_mempool/rte_mempool.h | 12 ++++++++++++ 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c index 146e38675..decdda3a6 100644 --- a/lib/librte_mempool/rte_mempool.c +++ b/lib/librte_mempool/rte_mempool.c @@ -239,10 +239,15 @@ rte_mempool_calc_obj_size(uint32_t elt_size, uint32_t flags, */ size_t rte_mempool_xmem_size(uint32_t elt_num, size_t total_elt_sz, uint32_t pg_shift, - __rte_unused unsigned int flags) + unsigned int flags) { size_t obj_per_page, pg_num, pg_sz; + if (flags & (MEMPOOL_F_CAPA_BLK_ALIGNED_OBJECTS | + MEMPOOL_F_CAPA_PHYS_CONTIG)) + /* alignment need one additional object */ + elt_num += 1; + if (total_elt_sz == 0) return 0; @@ -265,13 +270,18 @@ 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, __rte_unused unsigned int flags) + uint32_t pg_shift, unsigned int flags) { uint32_t elt_cnt = 0; phys_addr_t start, end; uint32_t paddr_idx; size_t pg_sz = (size_t)1 << pg_shift; + if (flags & (MEMPOOL_F_CAPA_BLK_ALIGNED_OBJECTS | + MEMPOOL_F_CAPA_PHYS_CONTIG)) + /* alignment need one additional object */ + elt_num += 1; + /* if paddr is NULL, assume contiguous memory */ if (paddr == NULL) { start = 0; @@ -390,7 +400,10 @@ rte_mempool_populate_phys(struct rte_mempool *mp, char *vaddr, memhdr->free_cb = free_cb; memhdr->opaque = opaque; - if (mp->flags & MEMPOOL_F_NO_CACHE_ALIGN) + if (mp->flags & MEMPOOL_F_CAPA_BLK_ALIGNED_OBJECTS) + /* align object start address to a multiple of total_elt_sz */ + off = total_elt_sz - ((uintptr_t)vaddr % total_elt_sz); + else if (mp->flags & MEMPOOL_F_NO_CACHE_ALIGN) off = RTE_PTR_ALIGN_CEIL(vaddr, 8) - vaddr; else off = RTE_PTR_ALIGN_CEIL(vaddr, RTE_CACHE_LINE_SIZE) - vaddr; diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_mempool.h index 734392556..24195dda0 100644 --- a/lib/librte_mempool/rte_mempool.h +++ b/lib/librte_mempool/rte_mempool.h @@ -271,6 +271,18 @@ struct rte_mempool { * Note: This flag should not be passed by application. */ #define MEMPOOL_F_CAPA_PHYS_CONTIG 0x0040 +/** + * This capability flag is advertised by a mempool handler. Used for a case + * where mempool driver wants object start address(vaddr) aligned to block + * size(/ total element size). + * + * Note: + * - This flag should not be passed by application. + * Flag used for mempool driver only. + * - Mempool driver must also set MEMPOOL_F_CAPA_PHYS_CONTIG flag along with + * MEMPOOL_F_CAPA_BLK_ALIGNED_OBJECTS. + */ +#define MEMPOOL_F_CAPA_BLK_ALIGNED_OBJECTS 0x0080 /** * @internal When debug is enabled, store some statistics. -- 2.14.1