From mboxrd@z Thu Jan 1 00:00:00 1970 From: Santosh Shukla Subject: [PATCH v2 3/6] mempool: detect physical contiguous object in pool Date: Thu, 13 Jul 2017 09:32:52 +0000 Message-ID: <20170713093255.13986-4-santosh.shukla@caviumnetworks.com> References: <20170621173248.1313-1-santosh.shukla@caviumnetworks.com> <20170713093255.13986-1-santosh.shukla@caviumnetworks.com> Mime-Version: 1.0 Content-Type: text/plain Cc: jerin.jacob@caviumnetworks.com, hemant.agrawal@nxp.com, Santosh Shukla To: thomas@monjalon.net, dev@dpdk.org, olivier.matz@6wind.com Return-path: Received: from NAM01-SN1-obe.outbound.protection.outlook.com (mail-sn1nam01on0044.outbound.protection.outlook.com [104.47.32.44]) by dpdk.org (Postfix) with ESMTP id 283525A3E for ; Thu, 13 Jul 2017 11:34:04 +0200 (CEST) In-Reply-To: <20170713093255.13986-1-santosh.shukla@caviumnetworks.com> List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The memory area containing all the objects must be physically contiguous. Introducing MEMPOOL_F_CAPA_PHYS_CONTIG flag for such use-case. The flag useful to detect whether pool area has sufficient space to fit all objects. If not then return -ENOSPC. This way, we make sure that all object within a pool is contiguous. Signed-off-by: Santosh Shukla Signed-off-by: Jerin Jacob --- v1 -- v2: - Renamed flag to MEMPOOL_F_CAPA_PHYS_CONTIG - Comment reworded. Refer [1]. [1] http://dpdk.org/dev/patchwork/patch/25604/ lib/librte_mempool/rte_mempool.c | 8 ++++++++ lib/librte_mempool/rte_mempool.h | 1 + 2 files changed, 9 insertions(+) diff --git a/lib/librte_mempool/rte_mempool.c b/lib/librte_mempool/rte_mempool.c index 34619aafd..65a98c046 100644 --- a/lib/librte_mempool/rte_mempool.c +++ b/lib/librte_mempool/rte_mempool.c @@ -368,6 +368,14 @@ rte_mempool_populate_phys(struct rte_mempool *mp, char *vaddr, total_elt_sz = mp->header_size + mp->elt_size + mp->trailer_size; + /* Detect pool area has sufficient space for elements */ + if (mp->flags & MEMPOOL_F_CAPA_PHYS_CONTIG) { + if (len < total_elt_sz * mp->size) { + RTE_LOG(ERR, MEMPOOL, "pool area %" PRIx64 " not enough\n", len); + return -ENOSPC; + } + } + memhdr = rte_zmalloc("MEMPOOL_MEMHDR", sizeof(*memhdr), 0); if (memhdr == NULL) return -ENOMEM; diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_mempool.h index 0fa571c72..ca5634eaf 100644 --- a/lib/librte_mempool/rte_mempool.h +++ b/lib/librte_mempool/rte_mempool.h @@ -265,6 +265,7 @@ struct rte_mempool { #define MEMPOOL_F_SC_GET 0x0008 /**< Default get is "single-consumer".*/ #define MEMPOOL_F_POOL_CREATED 0x0010 /**< Internal: pool is created. */ #define MEMPOOL_F_NO_PHYS_CONTIG 0x0020 /**< Don't need physically contiguous objs. */ +#define MEMPOOL_F_CAPA_PHYS_CONTIG 0x0040 /**< Detect physcially contiguous objs */ /** * @internal When debug is enabled, store some statistics. -- 2.13.0