From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <olivier.matz@6wind.com>
Received: from mail-wr0-f173.google.com (mail-wr0-f173.google.com
 [209.85.128.173]) by dpdk.org (Postfix) with ESMTP id A2C0458CB
 for <dev@dpdk.org>; Mon, 10 Jul 2017 14:27:13 +0200 (CEST)
Received: by mail-wr0-f173.google.com with SMTP id 77so136606609wrb.1
 for <dev@dpdk.org>; Mon, 10 Jul 2017 05:27:13 -0700 (PDT)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=6wind-com.20150623.gappssmtp.com; s=20150623;
 h=date:from:to:cc:subject:message-id:in-reply-to:references
 :mime-version:content-transfer-encoding;
 bh=oYa0L8+OeOt1NGXq+7bzfGjXMTUSywkMBTBFu+FST5k=;
 b=ibBeeuEn+fj1vqQxYlUO1uC0fFs46ydb/EwGeLfmkNQkzGt0BNxqs6LPAGqgU3/kaz
 iwdhEFcxTVrHUS1gjFt+8MOAQtiBFoX9U6VNyDo+qSO5hlr7saQZHRvL75CTbQ+eeiAG
 QcZHDh5yok03y2PhiO9A/XpHYACBjhuTC2Jltv29PXivHQ62Sh5Ykel7xcx8ANpFOWh3
 H3vhE3Ji2Acrkw27ZbxMHF9JfrZxRu5NfE+fPaEhWDNj0up928h+ypJAyyAY63KotMwr
 bvcNILmKws0Wv2rSX9knQQPSTHfxNHBLm8/xb5NpvyE9ajYPrhfNVANU7XGZgiDPndy7
 2Wsw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20161025;
 h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to
 :references:mime-version:content-transfer-encoding;
 bh=oYa0L8+OeOt1NGXq+7bzfGjXMTUSywkMBTBFu+FST5k=;
 b=iWPJTklal5slaDlK3/vCb9dpb9WqR90GO2C6Eo/e7WctTlcQxXvkw7DhfgyiQ/e8Rg
 dQVVjmzloNJOBTLJ4xUWKkMnCibR5qFFDgcmwgQuBxFV8du6J2jMxanD7Ry/qXZBk126
 +OaenMu8uBfsjSLHM/oDVgWCWEDIBGO+t2TdnUqtlp8w2cPMKZVSYVGh89w9yrt7R/eb
 8i32o1zsll5h/v1LqSf5rfz0dUDD6JvSIpGR9j+kEzas+X9C5EFoHpcHz3C6BBY7DBID
 se9cGUzVjeA6hBJjKNAC+cTn4buBE6ooKzMdmEEuvrcgoekPZ5dwbIPFbht/skUy1D0Q
 z2vQ==
X-Gm-Message-State: AIVw111G7bcgZYrtyeIL4s7wTKxVoheFHTEV2mwaTO2ji16s2XeDIajQ
 jSRmAiqHoN4s7uOd
X-Received: by 10.223.178.140 with SMTP id g12mr7751614wrd.158.1499689633335; 
 Mon, 10 Jul 2017 05:27:13 -0700 (PDT)
Received: from platinum (2a01cb0c03c651000226b0fffeed02fc.ipv6.abo.wanadoo.fr.
 [2a01:cb0c:3c6:5100:226:b0ff:feed:2fc])
 by smtp.gmail.com with ESMTPSA id j137sm10189928wmd.18.2017.07.10.05.27.13
 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);
 Mon, 10 Jul 2017 05:27:13 -0700 (PDT)
Date: Mon, 10 Jul 2017 14:27:06 +0200
From: Olivier Matz <olivier.matz@6wind.com>
To: Santosh Shukla <santosh.shukla@caviumnetworks.com>
Cc: thomas@monjalon.net, dev@dpdk.org, bruce.richardson@intel.com,
 jerin.jacob@caviumnetworks.com, hemant.agrawal@nxp.com,
 shreyansh.jain@nxp.com, gaetan.rivet@6wind.com,
 sergio.gonzalez.monroy@intel.com, anatoly.burakov@intel.com,
 stephen@networkplumber.org, maxime.coquelin@redhat.com
Message-ID: <20170710142706.4bee2ef1@platinum>
In-Reply-To: <20170710114235.18970-12-santosh.shukla@caviumnetworks.com>
References: <20170608110513.22548-1-santosh.shukla@caviumnetworks.com>
 <20170710114235.18970-1-santosh.shukla@caviumnetworks.com>
 <20170710114235.18970-12-santosh.shukla@caviumnetworks.com>
X-Mailer: Claws Mail 3.14.1 (GTK+ 2.24.31; x86_64-pc-linux-gnu)
MIME-Version: 1.0
Content-Type: text/plain; charset=US-ASCII
Content-Transfer-Encoding: 7bit
Subject: Re: [dpdk-dev] [PATCH v2 11/12] mempool: honor iova mode in virt2phy
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, 10 Jul 2017 12:27:13 -0000

On Mon, 10 Jul 2017 11:42:34 +0000, Santosh Shukla <santosh.shukla@caviumnetworks.com> wrote:
> Check iova mode and accordingly return phy addr.
> 
> Signed-off-by: Santosh Shukla <santosh.shukla@caviumnetworks.com>
> Signed-off-by: Jerin Jacob <jerin.jacob@caviumnetworks.com>
> ---
>  lib/librte_mempool/rte_mempool.h | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/lib/librte_mempool/rte_mempool.h b/lib/librte_mempool/rte_mempool.h
> index 76b5b3b15..fafa77e3b 100644
> --- a/lib/librte_mempool/rte_mempool.h
> +++ b/lib/librte_mempool/rte_mempool.h
> @@ -78,6 +78,7 @@
>  #include <rte_ring.h>
>  #include <rte_memcpy.h>
>  #include <rte_common.h>
> +#include <rte_bus.h>
>  
>  #ifdef __cplusplus
>  extern "C" {
> @@ -1397,9 +1398,14 @@ rte_mempool_empty(const struct rte_mempool *mp)
>  static inline phys_addr_t
>  rte_mempool_virt2phy(__rte_unused const struct rte_mempool *mp, const void *elt)
>  {
> -	const struct rte_mempool_objhdr *hdr;
> -	hdr = (const struct rte_mempool_objhdr *)RTE_PTR_SUB(elt,
> +	struct rte_mempool_objhdr *hdr;
> +
> +	hdr = (struct rte_mempool_objhdr *)RTE_PTR_SUB(elt,
>  		sizeof(*hdr));
> +
> +	if (rte_eal_iova_mode() == RTE_IOVA_VA)
> +		hdr->physaddr = (uintptr_t)elt;
> +
>  	return hdr->physaddr;
>  }
>  

This overrides the physaddr field in the object hdr, this is
surely not what you want (note that hdr was const).

This change could at least take place in mempool_add_elem().
There is even maybe no need to change rte_mempool at all: if
rte_memzone_reserve() already returns the proper address in
memzone->phys_addr, it should be transparent.

I didn't check the patchset in detail, but in my understanding,
what we call physaddr in dpdk is actually a bus address. Shouldn't
we start to rename some of these fields and functions to avoid
confusion?


Thanks,
Olivier