From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-CO1-obe.outbound.protection.outlook.com (mail-co1nam03on0068.outbound.protection.outlook.com [104.47.40.68]) by dpdk.org (Postfix) with ESMTP id 24BB56D45 for ; Fri, 22 Sep 2017 14:59:10 +0200 (CEST) Received: from CY1PR03CA0020.namprd03.prod.outlook.com (10.174.128.30) by BN6PR03MB2689.namprd03.prod.outlook.com (10.173.144.8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.56.11; Fri, 22 Sep 2017 12:59:09 +0000 Received: from BY2FFO11FD047.protection.gbl (2a01:111:f400:7c0c::122) by CY1PR03CA0020.outlook.office365.com (2603:10b6:600::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.56.8 via Frontend Transport; Fri, 22 Sep 2017 12:59:08 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; caviumnetworks.com; dkim=none (message not signed) header.d=none; caviumnetworks.com; dmarc=fail action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BY2FFO11FD047.mail.protection.outlook.com (10.1.15.175) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.20.35.14 via Frontend Transport; Fri, 22 Sep 2017 12:59:08 +0000 Received: from [10.232.133.65] (B10814-12.ap.freescale.net [10.232.133.65]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id v8MCx4as021109; Fri, 22 Sep 2017 05:59:05 -0700 To: Santosh Shukla , , References: <20170906112834.32378-1-santosh.shukla@caviumnetworks.com> <20170907153042.30890-1-santosh.shukla@caviumnetworks.com> <20170907153042.30890-8-santosh.shukla@caviumnetworks.com> CC: , From: Hemant Agrawal Message-ID: <12c7fc46-e810-c72c-f625-3b45ed220cae@nxp.com> Date: Fri, 22 Sep 2017 18:29:03 +0530 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: <20170907153042.30890-8-santosh.shukla@caviumnetworks.com> Content-Type: text/plain; charset="windows-1252"; format=flowed Content-Transfer-Encoding: 7bit X-EOPAttributedMessage: 0 X-Matching-Connectors: 131505587484093894; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(336005)(7966004)(346002)(376002)(39860400002)(39380400002)(2980300002)(1109001)(1110001)(339900001)(199003)(377454003)(24454002)(189002)(58126008)(81166006)(81156014)(498600001)(53936002)(77096006)(356003)(23746002)(8676002)(4326008)(31686004)(8936002)(65956001)(50986999)(65806001)(85426001)(76176999)(97736004)(2906002)(54356999)(6246003)(68736007)(53376002)(6306002)(966005)(2950100002)(36756003)(53546010)(189998001)(229853002)(110136005)(33646002)(104016004)(316002)(106466001)(47776003)(86362001)(5660300001)(65826007)(64126003)(31696002)(230700001)(2201001)(50466002)(105606002)(305945005)(54906003)(83506001); DIR:OUT; SFP:1101; SCL:1; SRVR:BN6PR03MB2689; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BY2FFO11FD047; 1:XupLMda4Hza1bQZAfv0qvL48fxro+ws5pf+8NnXVr2tfQorH3M+KFNylbOudUiTg5IzVW8ENnbkZSHC9+Y0EYRUUqJ2KEJnzJedbfW+ikARcZxeuiixAbzSLNvCJJvbd X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 4f0692f2-14ef-4ecd-e2c6-08d501b9b65b X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(22001)(300000502095)(300135100095)(300000503095)(300135400095)(2017052603199)(201703131430075)(201703131517081)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:BN6PR03MB2689; X-Microsoft-Exchange-Diagnostics: 1; BN6PR03MB2689; 3:PNuIsg1wXnEOZ1v6A19ASV+2cqvbQVzutSkxaRjhYvewshVZafzBTSVpcrV609sbLtkJfocq+LUduL742aKfdl0Tkhp9uJWZnNZT00aZPe7CUFaFoxJtMXjmN39ni7CXOGDfbHgaGthHxXFvvt2pEQBOlPjEaEuyWFxttECB44gWbnBT8c75wE87g4MoCZpp2cQEjeZ2p1stQkWZqt0MQGzR1iLJBcQLQ01eZxmHzhmyxSJNikO/UY8vS1rzC/kfQ1T4rZL9+VaVrz+UoIJassHOdXgGVdMQmXrTQRPNTPZEIzMBCdIcHQy3CS3NToPbX+C2qPb6RPlUSNRgEs7f4/ClFXtpqoeQDLwwSw7wob0=; 25:54CQOrN1G6cbUwu9ephNWi8q/ZkQNQwokrLNM8V0ssCvDhA1j7RQpMYt7Iw4wcqGBxUUApH6DWvTGQRqv4r+CKp7jBY/KG+nCA+imtmVc+DC8hlgFnxgpBQFb83QcuKAOmnEfdOFPGPT/xBlXn0JAtBy0BibgZ0+ksklNn+4jBQnqq9JkrFvBvhm6v+6PQSduItQA4NMkhwrqBZNdSgqbZ3gfeQjNqKJAxTT0kKzzwaUaPRrE/REepuRDG+s6wXt0baLIrQ9P4Hq/d/7AnYT1ODZBOAOizDQtaXuLAqumCuf/8IqgIasDNFirzfc4PaoWe+ExqCmHG4rW3jYKGMkcw== X-MS-TrafficTypeDiagnostic: BN6PR03MB2689: X-Microsoft-Exchange-Diagnostics: 1; BN6PR03MB2689; 31:zakP3E0xm5tggH5EG5g3EXPIT7DjRhF5JF6tG8PRnB4A2UMzOu9VX8UeRT3DgaQz4ibusPEePZPOvN8/C24Ou3yppTSSpJgyIJsFh/Qxe5jntj7G9Sgq8Hab6zX+WD304CQk86DZZLbVjgKOvayUguY1s+KRB/NtliAcF2g2Y8W3VYw8iLQYaIwWaQqjktMF/Ri/2AfaF3b/Tyu9eJH3DLPIZYPyyGzxXmsJQInnrcM=; 4:req+qb25gLOzzZTm/ULRKzpdXFIU+wlkKtNizt+Z+r/q4X+Gw0lJpGkR7MD/NaatN768J7NMUAOQCOXXZdgCYc2FS9yo5s6ULIJSfzfLovOb8nVp2DjkRHADj9Yef6/iBzupglQf0nCM9pFxjCJv0qSDEaKpH3mZh8KXbt/e1T+ajU/TUq7zzf1XNvXoVPNUBOF6z/aGGRcx5fs0v7qGWcD4hZqxBvDC2VjjrgeEd86P7urygF1O+2MkVUj7Uea/tWllSB4GmHtJ4HQ/25pz0B6E0vfjShAScab9aonTCkE= X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6095135)(2401047)(5005006)(8121501046)(100000703101)(100105400095)(10201501046)(3002001)(93006095)(93001095)(6055026)(6096035)(201703131430075)(201703131433075)(201703131441075)(201703131448075)(201703161259150)(20161123563025)(20161123565025)(20161123561025)(20161123559100)(20161123556025)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:BN6PR03MB2689; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(400006)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:BN6PR03MB2689; X-Forefront-PRVS: 0438F90F17 X-Microsoft-Exchange-Diagnostics: =?Windows-1252?Q?1; BN6PR03MB2689; 23:O1TCPUSw/LQropRRIBjj0SkTtpnfp/hhP6Y+/?= =?Windows-1252?Q?xnXRL7eGgwfR1kPekcsXPzm2ew02JJCoQsrY6rrTdDORqH53YY1aT1gY?= =?Windows-1252?Q?0K6HESPSkOEznYlzR+o02C10idx87Xr2Mu1ZFo5P0jp2YDArFTWL3dJ8?= =?Windows-1252?Q?14DoeCv/Vu/8qNt0xSwads2l/9eoH/kbYAihMe6TDcIibn5jnuoCpUYD?= =?Windows-1252?Q?KYnwmtru9pXKHrrDyD60euE2Ciu2lsi5Ktz4PeTxDfQgn+6rXEg27HiX?= =?Windows-1252?Q?ea1jAcxWokTTmJUFodz0jUt0GscRxc00muJq0/MYRBoUxt6tsFs/bI5O?= =?Windows-1252?Q?8RWy+eb016YGWOsyzszJsolVZruEEU13t3lgLzUNB4lgBZJIi9qwMCXw?= =?Windows-1252?Q?9mdHPoVCmKoK0JbYHEoH7fcyroSeT336VEnAMSIhw0wAqfDFSXRmvHZs?= =?Windows-1252?Q?zFEqD/aSEptE3zni3RveVrvn0zu8G/Z4XUYFtNhV+DwuO1fTITPXlUA3?= =?Windows-1252?Q?7gslOiUGem4jPdCOgDjPKvSHgPpJDy38GwM/a0/dT2vuhnDrtTqlCntY?= =?Windows-1252?Q?J//LkH1qRCMFvJsFMV5RHdP51t0WuVLTmq6TcWYGxKUWdYS4lGa7CCWs?= =?Windows-1252?Q?j4ht+y/TmrUN2qLrn8bp2esAuutu8ODydGKnDpWPgrjdTVPv18gZn3Ru?= =?Windows-1252?Q?d6shRltU6rzxmOcbnCDXO/yAGZZI9wtpEn99wkBUyi4ZHztONTdFnsI7?= =?Windows-1252?Q?PYpjlPUhpK603dltx46SCfKj/2yCoi6LPPQAvsCrMA+CcExfms4j9y/r?= =?Windows-1252?Q?NuNr5GVI5+O8B9KNU3IloDyAGh23QlJUtENj5u3lRdgO9bqrpT8jE3uX?= =?Windows-1252?Q?FwCfroIQahVHw43e/vWEF6EwiOrIe7xXHDcJd6TJJ7fwHWRbby0aV9LZ?= =?Windows-1252?Q?t3xOi32UshV2oICXfhPpZL0lC/KlDAPrXLd1D23vsxPV2NWJwvwYZJn6?= =?Windows-1252?Q?vQHrCWiV6JkiOcMN2edhfdm2s3rPGOzPQwOabqYPuk7sCpsT9eXdeVEr?= =?Windows-1252?Q?psWMdVlV8c5Idz+Q20l/GQbZgiFBHC52fWMuGycqpEy1ZzpLQ3bujBRY?= =?Windows-1252?Q?T+yuunof4EfBW1H1rFUc/8NVo+PSQGlxW8tJ8WfddtG9cOVZGIhZefLI?= =?Windows-1252?Q?0QsKxzsTmpwY5cwWbTRAby3snFwvmlNG2SESUco8Kz9dugbe+1PUnHfx?= =?Windows-1252?Q?oqxbmY4JkPCi4GS40qurnOWFXjpJhIesxiMW6w4KdzgBmkcRrCjDlVXH?= =?Windows-1252?Q?ZTv93qE+kaqWhpgrJU66ouIyzXeDCoMvcUOI+RIB1oXL3i+qpCMNktU4?= =?Windows-1252?Q?eSRPs9a3ZzcGQ4WUPWIHzIzNB48AUfE4VU+GvfIu7EFW9bqfYDeeENjS?= =?Windows-1252?Q?XKuokVCWwmzF5ahjy8W/S05MrcTLG+7Py8xezTcvYfLZa7gOFp4ZF7CF?= =?Windows-1252?Q?UI/Mec4B9aEhmNnB5JMReyYdxeicnIN1J3Is5bbvxDUqED2vidUXM96O?= =?Windows-1252?Q?04OnajJu2FOKTfK1NshGrxiTOsKu8kBOhkN?= X-Microsoft-Exchange-Diagnostics: 1; BN6PR03MB2689; 6:LH7RQIu7CfdIQuLSA4te9iQsUjByOujVNAV8pXDwnI4ERU481GRTXn0mxGG+rpijFsTpTDfGTYqrBccj82rdudTbpT4yi0xbpKq/kNBTDyQWYolrXUdYMZbscq2d2FvleoBjl8ktohYJBzXD6XtxApx3PBHEeib6DNFEAxhENAXoBhDmv/4VqXalYf6uunCESW0raPrJojvCxDYotsxqHuvZiGkDyP5sLHblkgha7ODetiLXZ8vZCq9ffnakmCK4kdheTeuG25PFxtQfokVFBIlimHMZsIU4nbIZTYQou0S8kJwDhotWajGTYsEJSNIB9HooLqrtZiwXBssBEuhZEQ==; 5:hFR+1h4kmdGuj+7PNxsnQCGLlSD0ccd4F9lbkqbhnqXXNaSaVNDScKLCwIN+ab0Mkdk9ZX0CjVyHGf9AxCGXwZf20xDPEDNOkS4O7WJxw451a5G9SUOqGoUiT1frJl7zNzTMjYi1bX/xaxDL4XQbdQ==; 24:2Ih81adDeAHjXSkutR6BHB2iEkc78yVc1MWtBbBfI5ObcekUd4WmV6iPbI1d7nXQgmXS1rS0HOAX5/ykPezQuQyWsRU/6qkA7L7nf8gaTa4=; 7:w0Z2ngCicsoWAw0qRgJNih/4J5RsnhxpBEjogfymbE5Q5rIu6wgGY1OJBRCEn+0M3bFaw4cRcaEKJnvhpfD4COGuD1/N5fsG5A6Jfq0c3NwV7c/Cfh0QLl3EDdnglTS3PqM1CkQr16Cub607/0F8KuW5sSzL0TG3M45ZrWZhC/qCjg4MD59mxPw/mQu+V6ynIxWIE3/b/rBEvUn8XPKUN2mA/szRSk7rtglhnU9SZNU= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 22 Sep 2017 12:59:08.0505 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR03MB2689 Subject: Re: [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: Fri, 22 Sep 2017 12:59:11 -0000 Tested-by: Hemant Agrawal On 9/7/2017 9:00 PM, Santosh Shukla wrote: > 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. >