From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <olivier.matz@6wind.com>
Received: from mail.droids-corp.org (zoll.droids-corp.org [94.23.50.67])
 by dpdk.org (Postfix) with ESMTP id 7B3A95A6E
 for <dev@dpdk.org>; Mon,  4 Sep 2017 16:43:31 +0200 (CEST)
Received: from lfbn-1-18623-73.w90-103.abo.wanadoo.fr ([90.103.154.73]
 helo=droids-corp.org)
 by mail.droids-corp.org with esmtpsa (TLS1.0:RSA_AES_256_CBC_SHA1:256)
 (Exim 4.84_2) (envelope-from <olivier.matz@6wind.com>)
 id 1dosgS-0008GX-PK; Mon, 04 Sep 2017 16:49:06 +0200
Received: by droids-corp.org (sSMTP sendmail emulation);
 Mon, 04 Sep 2017 16:43:24 +0200
Date: Mon, 4 Sep 2017 16:43:24 +0200
From: Olivier MATZ <olivier.matz@6wind.com>
To: Santosh Shukla <santosh.shukla@caviumnetworks.com>
Cc: dev@dpdk.org, thomas@monjalon.net, jerin.jacob@caviumnetworks.com,
 hemant.agrawal@nxp.com
Message-ID: <20170904144323.6mluy4mpptaodx7a@neon>
References: <20170720134759.4680-1-santosh.shukla@caviumnetworks.com>
 <20170815060743.21076-1-santosh.shukla@caviumnetworks.com>
 <20170815060743.21076-6-santosh.shukla@caviumnetworks.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
In-Reply-To: <20170815060743.21076-6-santosh.shukla@caviumnetworks.com>
User-Agent: NeoMutt/20170113 (1.7.2)
Subject: Re: [dpdk-dev] [PATCH v4 5/7] mempool: detect physical contiguous
	object in pool
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: DPDK patches and discussions <dev.dpdk.org>
List-Unsubscribe: <http://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <http://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Mon, 04 Sep 2017 14:43:31 -0000

On Tue, Aug 15, 2017 at 11:37:41AM +0530, Santosh Shukla wrote:
> 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 <santosh.shukla@caviumnetworks.com>
> Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
> ---
>  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 d518c53de..19e5e6ddf 100644
> --- a/lib/librte_mempool/rte_mempool.c
> +++ b/lib/librte_mempool/rte_mempool.c
> @@ -370,6 +370,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", (uint64_t)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 bc4a1dac7..a4bfdb56e 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 */
>  

The description should be longer. It is impossible to understand what is the
meaning of this capability flag by just reading the comment.

Example:
/**
 * This capability flag is advertised by a mempool handler if the whole
 * memory area containing the objects must be physically contiguous.
 */