From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <olivier.matz@6wind.com>
Received: from mail-wm0-f41.google.com (mail-wm0-f41.google.com [74.125.82.41])
 by dpdk.org (Postfix) with ESMTP id D7E0B2B99
 for <dev@dpdk.org>; Mon,  3 Jul 2017 10:25:06 +0200 (CEST)
Received: by mail-wm0-f41.google.com with SMTP id z75so36233186wmc.0
 for <dev@dpdk.org>; Mon, 03 Jul 2017 01:25:06 -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=b7E5xNytz8e9WNDVPRjNqWGX3JqC1dQRILqXYiMGIMw=;
 b=rk2L9z27CDC0TqOS+yAjFm7t4Sh/mJQT94nZAGAQTfpP/XWFpQ3NjMHb6Y5ec37Pyc
 LN5BOx4jWdMgKWAxDoHgp8z03lByrK7W5duS6lGvtbGUugpiFeHjrVPbYyybgKYSD6cZ
 xEsYU2wmrXdwJA2zSc4NnPG3RTBG2nWUT+brC8MgWIkm9hYtAKsXhkLfdhB5ArsJnjBz
 J3uVhG/R4xrOBfxzNh+zAQDhxnrPP//OPa1EABEYp42NCS2ACrqF1BeWOZfBOb+ZIi13
 g0d646oy+LlTUaCmux0//oD23LPELmFAZGlHPyNF8eHbftylLXuAFMvuuExEloZi5hu/
 cMAQ==
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=b7E5xNytz8e9WNDVPRjNqWGX3JqC1dQRILqXYiMGIMw=;
 b=NlRj6yGrTn6sCRfUU7c0q94tC7OJaIDV/wg1ymJKuKcaCrn3BYFtwFpqmmbJxWAxQy
 xN7qJ0Ywp032CkpAAp/N/5n10aMfefXFhw8/iuZGKxqQ0BAnEQsHBFCVEpUOq8Ck/ZEA
 oGxMhnCXXUd0/K9Od0Rbi5Yr/T3IYf644vUyL14TrNfUOQAl0yohkzejaSje0XdBfIIr
 TYtigpoP5TCbiRAKwV1juZL/cxHYmMT+K1pkvAOT0GEvJwYS5czWJKTJt1VsG7zcS2JE
 qGVqKCmzFPDgNNRQWR1vNziPY+r1vaeewIhDC/xEPH1V7dncawQ5sMbnTFt+1Pa93F11
 5Bcg==
X-Gm-Message-State: AIVw113wB/ZW12o7QLm+nez70nWWnXQg4Yo7+sRYbIpNyJ3GEgIelv3z
 bai2BGEHkwLSsZTR
X-Received: by 10.28.184.87 with SMTP id i84mr5824182wmf.22.1499070306383;
 Mon, 03 Jul 2017 01:25:06 -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 y2sm3212564wmy.29.2017.07.03.01.25.06
 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);
 Mon, 03 Jul 2017 01:25:06 -0700 (PDT)
Date: Mon, 3 Jul 2017 10:25:00 +0200
From: Olivier Matz <olivier.matz@6wind.com>
To: Jan Blunck <jblunck@infradead.org>
Cc: Gaetan Rivet <gaetan.rivet@6wind.com>, dev <dev@dpdk.org>
Message-ID: <20170703102500.75cf7cd7@platinum>
In-Reply-To: <CALe+Z000g3Ze9GQ-XPTm8ZpaW_oRiNKYPdES4gLzdtLi8mMLAw@mail.gmail.com>
References: <cover.1496308649.git.gaetan.rivet@6wind.com>
 <138ba842ce615de6a6895f0ca74b5645aad48ad9.1496308649.git.gaetan.rivet@6wind.com>
 <CALe+Z000g3Ze9GQ-XPTm8ZpaW_oRiNKYPdES4gLzdtLi8mMLAw@mail.gmail.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: quoted-printable
Subject: Re: [dpdk-dev] [PATCH 1/8] eal: expose rte_eal_using_phys_addrs
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, 03 Jul 2017 08:25:07 -0000

Hi,

On Fri, 30 Jun 2017 21:05:47 +0200, Jan Blunck <jblunck@infradead.org> wrot=
e:
> On Thu, Jun 1, 2017 at 12:14 PM, Gaetan Rivet <gaetan.rivet@6wind.com> wr=
ote:
> > This function was previously private to the EAL layer.
> > Other subsystems requires it, such as the PCI bus.
> >
> > This function is only exposed for linuxapps.
> >
> > In order not to force other components to include stdbool, which is
> > incompatible with several NIC drivers, the return type has
> > been changed from bool to int.
> >
> > Signed-off-by: Gaetan Rivet <gaetan.rivet@6wind.com>
> > ---
> >  lib/librte_eal/common/eal_private.h             | 11 -----
> >  lib/librte_eal/linuxapp/eal/Makefile            |  2 +
> >  lib/librte_eal/linuxapp/eal/eal_memory.c        |  3 +-
> >  lib/librte_eal/linuxapp/eal/eal_pci.c           |  1 +
> >  lib/librte_eal/linuxapp/eal/rte_eal_version.map |  1 +
> >  lib/librte_eal/linuxapp/eal/rte_memory_linux.h  | 64 +++++++++++++++++=
++++++++
> >  6 files changed, 70 insertions(+), 12 deletions(-)
> >  create mode 100644 lib/librte_eal/linuxapp/eal/rte_memory_linux.h
> >
> > diff --git a/lib/librte_eal/common/eal_private.h b/lib/librte_eal/commo=
n/eal_private.h
> > index 6d2206a..b7e4cc6 100644
> > --- a/lib/librte_eal/common/eal_private.h
> > +++ b/lib/librte_eal/common/eal_private.h
> > @@ -327,17 +327,6 @@ int rte_eal_hugepage_init(void);
> >   */
> >  int rte_eal_hugepage_attach(void);
> >
> > -/**
> > - * Returns true if the system is able to obtain
> > - * physical addresses. Return false if using DMA
> > - * addresses through an IOMMU.
> > - *
> > - * Drivers based on uio will not load unless physical
> > - * addresses are obtainable. It is only possible to get
> > - * physical addresses when running as a privileged user.
> > - */
> > -bool rte_eal_using_phys_addrs(void);
> > -
> >  /*
> >   * Validate a bus name.
> >   *
> > diff --git a/lib/librte_eal/linuxapp/eal/Makefile b/lib/librte_eal/linu=
xapp/eal/Makefile
> > index 640afd0..530e286 100644
> > --- a/lib/librte_eal/linuxapp/eal/Makefile
> > +++ b/lib/librte_eal/linuxapp/eal/Makefile
> > @@ -131,4 +131,6 @@ INC :=3D rte_interrupts.h rte_kni_common.h rte_dom0=
_common.h
> >  SYMLINK-$(CONFIG_RTE_EXEC_ENV_LINUXAPP)-include/exec-env :=3D \
> >         $(addprefix include/exec-env/,$(INC))
> >
> > +SYMLINK-$(CONFIG_RTE_EXEC_ENV_LINUXAPP)-include +=3D rte_memory_linux.h
> > +
> >  include $(RTE_SDK)/mk/rte.lib.mk
> > diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c b/lib/librte_eal/=
linuxapp/eal/eal_memory.c
> > index ebe0683..072bfe4 100644
> > --- a/lib/librte_eal/linuxapp/eal/eal_memory.c
> > +++ b/lib/librte_eal/linuxapp/eal/eal_memory.c
> > @@ -99,6 +99,7 @@
> >  #include "eal_internal_cfg.h"
> >  #include "eal_filesystem.h"
> >  #include "eal_hugepages.h"
> > +#include "rte_memory_linux.h"
> >
> >  #define PFN_MASK_SIZE  8
> >
> > @@ -1472,7 +1473,7 @@ rte_eal_hugepage_attach(void)
> >         return -1;
> >  }
> >
> > -bool
> > +int
> >  rte_eal_using_phys_addrs(void)
> >  {
> >         return phys_addrs_available;
> > diff --git a/lib/librte_eal/linuxapp/eal/eal_pci.c b/lib/librte_eal/lin=
uxapp/eal/eal_pci.c
> > index 595622b..9d5b051 100644
> > --- a/lib/librte_eal/linuxapp/eal/eal_pci.c
> > +++ b/lib/librte_eal/linuxapp/eal/eal_pci.c
> > @@ -45,6 +45,7 @@
> >  #include "eal_filesystem.h"
> >  #include "eal_private.h"
> >  #include "eal_pci_init.h"
> > +#include "rte_memory_linux.h"
> >
> >  /**
> >   * @file
> > diff --git a/lib/librte_eal/linuxapp/eal/rte_eal_version.map b/lib/libr=
te_eal/linuxapp/eal/rte_eal_version.map
> > index a5127d6..8916520 100644
> > --- a/lib/librte_eal/linuxapp/eal/rte_eal_version.map
> > +++ b/lib/librte_eal/linuxapp/eal/rte_eal_version.map
> > @@ -207,5 +207,6 @@ DPDK_17.08 {
> >
> >         rte_bus_from_name;
> >         rte_bus_from_dev;
> > +       rte_eal_using_phys_addrs; =20
>=20
> Is this only for the UIO mapping? Would it be better to let UIO skip
> (and warn?) over RTE_BAD_PHYS_ADDR mappings? That way we don't need
> this export and its probably more resilient to bad mappings.
>=20
> Thoughts? Olivier?

=46rom what I see, rte_eal_using_phys_addrs() is used by:

	rte_eal_pci_map_device(struct rte_pci_device *dev)
	{
		...
	        case RTE_KDRV_IGB_UIO:
	        case RTE_KDRV_UIO_GENERIC:
		if (rte_eal_using_phys_addrs()) {
			/* map resources for devices that use uio */
			ret =3D pci_uio_map_resource(dev);
		}


Looking at pci_uio_map_resource() and its callees, I'm not sure it's
easy to replace it something else. The functions that would return
RTE_BAD_PHYS_ADDR (virt2phy-like) are not called there.