From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM03-DM3-obe.outbound.protection.outlook.com (mail-dm3nam03on0066.outbound.protection.outlook.com [104.47.41.66]) by dpdk.org (Postfix) with ESMTP id 2CDE537B1 for ; Sun, 1 Oct 2017 11:29:59 +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=DAM+R2D5UnSzVH9MYqsBSeYL1EMssUBcqqXWNn84c3g=; b=CUvLEmXqMgCR66OnXbr8VhCv87YVmewAsS+8aSPOArhU03YNC4tSTBh171vzygD4LY1YKanM/rGUGCPmqnWzlkqJVTHHBP5SLiWinGHl4zuimkr25v6Kzy4ndfRvMyKToQSYFeBaf9t3ONZECIc754Eb0SJXHdmSOF/cJxsojFc= 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:56 +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:59:01 +0530 Message-Id: <20171001092902.10842-8-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: 7caca395-7b20-4dbf-cb09-08d508aefc17 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(2017030254152)(2017052603199)(201703131423075)(201703031133081)(201702281549075); SRVR:DM5PR07MB3098; X-Microsoft-Exchange-Diagnostics: 1; DM5PR07MB3098; 3:3gKJiqFWMaz3iscWdaMYiOJ5Fe5WGULtflte1hnUXFkXuawSpMGtl9EZuY4rQxf8HKe4LbfxjQfDii4SV4Hz7o7672kPgTO3CyefIaqf5ntQAYcEUEPgI7e1OwIxB/K79ksz2g8dpE5ZCntfSkoAkvmqEDp81U7NtkJ/kR1FwsXwOMoy7ldJEqHSZrAvBYThI2/fh4W4kJBYAyFSUMLwQssdrZ58NfH2sdkNDx6t3y/xJRZ527LHvqtpGjznJfN0; 25:GQZox6f2xpVDdC/4gvZyLqt2bP/AjpDz52ScuEQUexV5AFRJxV0GWeJYlYoIR/lHvnIS+AC6ckgAy6QGMsE6YWOI4gC1zvNp47Qsp15ScvyKrMDqyjpXDcRjWkMVkON3SqvVxHpPQspLxDCnVlRUkG3rNkqvFslKZlpH7GF4mgumI3HWsEEn7f2HpNJr2Ahja335WyjTGs/pm5Z1nRKRiJbRWnmZgDO6LAyfhpaZI7Ra4JIrmsmtrsCZclzh49PIp3ADKAE5sgOZTvoCgCF+pNLXOx7TAmVaZ097exMmUcVU8+1xzT1suemFNJlKnxc10nsXtnBAtsoTkE0vGulKXw==; 31:nSzEg6bVd1tkUFVPgVECjl2cBx7FiCuwRsHeR1IM2vbPOaNKJJ7s1aHxm8szFYpWieQwQCexUf9k3O5zTORm2cv4Jckb5Jumle06Nw+a2ocPe/emQlQ++ec/oDO2t7yP2DCXCpMeIoFo/mB4C5isQuimqTt9BIXOsopZTowd8gBrO8GlT2i3ynRhDi6jg+nA/a4CHPKB6Qjbm2UPkwoU0pSEcyE76X1qv9uR5gB6PSc= X-MS-TrafficTypeDiagnostic: DM5PR07MB3098: X-Microsoft-Exchange-Diagnostics: 1; DM5PR07MB3098; 20:aJ9kQbQDcOKLTL4N/6LiVHWqVZva88HwSGDbv/QGZUt1PZ5l1vHNFn1MX64JqI8OAO70f7rG3hp8jxeoXKB6OpfuuAVPxl/Ia2AzowOlOcC51C2/cEfNnklSFykV/QsYhjtf/6h9DTICoryQe2GedVu5MAZ2W6vrF/HVg+PKUBNuectooLwYi3tqk15dVdnIbhU/a4F965Cz0HY8JgcxYFudxQtOFcs+m+lzpDWaF0Atk1O3HCQte02t1RCtztZkWX2VAjzv4cqPtNbpCZIS4h9NwPqzQ+lgLCTUM4KtSH3wAAFIUtSa5yFjF6rkWjywYv5xJeTP51xe9FCeCRm6XUR3Lo4q0sniSCm/mydvfVFyYF5FwN7FGZFb2Y/5fnXSMIvcTmN6hsJdI011ekDs6LnrJrM4ZU4WejdCxpqBV3XFGd1reFCVs7c3TpZVX0bROEuIv8O6tv2qJ/mHI0I4Fh1ubnSI7sqpjUTkjUZjjQn2tFHBYUvKcFN8y+l+zIlgnaP/JwisXOLWXqpCdvC0Mu33K14d400Vt2jQFPtbY+jAMYWd1fi2vk6jv6o5sirGMAsXv74zF1kEgz3bf6gj8pwRnTjGTKK4gDMwGMVz/qY=; 4:u50F8I59U46eT4+H8hsBu2T5YgBnB7fvKiI2TlqzMKJhe5Ylb86pP1HGHEHoih/RQrxFBN1RTndyNTfxjzdeWkUmLw1UTonOGXkp2b9ZoIp/Epl2Wni94xz/gNyjDJD4NR8/qP5brfqt53W8Ym5LiN9WwZ+aixV0VzgHYYoyGAhM5tBt/vd7SZSy7f7nNdDVhOaTzuZ0utBUXRRelrGKZnRR3LmAtmm1JMqEzzf0UUNKL4+5UbmhevQJzo31RIUqD3+vNFlvHVL1Op7KNBhlybSqBOMGGtRhQDwosQKPJDU= 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)(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)(979002)(6009001)(6069001)(376002)(346002)(189002)(199003)(101416001)(478600001)(189998001)(106356001)(966005)(50986999)(81166006)(16586007)(81156014)(8676002)(72206003)(68736007)(42882006)(50466002)(8936002)(5660300001)(16526017)(48376002)(8656003)(2950100002)(2906002)(105586002)(66066001)(3846002)(6512007)(1076002)(36756003)(6306002)(47776003)(316002)(76176999)(6116002)(4326008)(97736004)(53936002)(5009440100003)(25786009)(50226002)(6486002)(107886003)(6666003)(5003940100001)(33646002)(6506006)(305945005)(53376002)(7736002)(969003)(989001)(999001)(1009001)(1019001); 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:jdY8AOmI7Il32UZH+ezjb1ICki9M5fH1q9MHhMU+s?= =?us-ascii?Q?1Is14F1YZM2TgJXj72L7tDhclq1KFEFWGWzfClCJqLIGEalfm2gygSNjdgVI?= =?us-ascii?Q?HbP3hBGcbNMjUNbjHYZIAjfGA7Lk9HjGOix2Bm/mhXtDzATxpARuC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ckBOBwsyhRt/yE4BhY07OcjwPmXkqyjl7GDzVQvlzeQEdPbjIfXbrEXLstTExxrwY/q7qdz058uyZX9XREwDcg+518tWWTYPvdpyB4xgByoc4NZq5Q1zMAo3fKvPgWcslPGuvsnkbpQqsecw0fiJLYyepNuMlLGdfHBL0WPeMYTKvddeUcs28ldj2JmffC8VFvtGGXjWrSr+c= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 01 Oct 2017 09:29:56.1489 (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 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: Sun, 01 Oct 2017 09:30:00 -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 Tested-by: Hemant Agrawal --- v6 --> v7: - Added mask var (a flag checker) in xmem_size/usage() (suggested by Olivier) Refer [1]. [1] http://dpdk.org/dev/patchwork/patch/28467/ 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 [2] [2] 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 [3]. [3] http://dpdk.org/dev/patchwork/patch/27600/ lib/librte_mempool/rte_mempool.c | 21 ++++++++++++++++++--- lib/librte_mempool/rte_mempool.h | 12 ++++++++++++ 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c index 146e38675..df9d67ae6 100644 --- a/lib/librte_mempool/rte_mempool.c +++ b/lib/librte_mempool/rte_mempool.c @@ -239,9 +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; + unsigned int mask; + + mask = MEMPOOL_F_CAPA_BLK_ALIGNED_OBJECTS | MEMPOOL_F_CAPA_PHYS_CONTIG; + if ((flags & mask) == mask) + /* alignment need one additional object */ + elt_num += 1; if (total_elt_sz == 0) return 0; @@ -265,12 +271,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; + unsigned int mask; + + mask = MEMPOOL_F_CAPA_BLK_ALIGNED_OBJECTS | MEMPOOL_F_CAPA_PHYS_CONTIG; + if ((flags & mask) == mask) + /* alignment need one additional object */ + elt_num += 1; /* if paddr is NULL, assume contiguous memory */ if (paddr == NULL) { @@ -390,7 +402,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