From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <jijiang.liu@intel.com>
Received: from mga02.intel.com (mga02.intel.com [134.134.136.20])
 by dpdk.org (Postfix) with ESMTP id 89E3F2E8A
 for <dev@dpdk.org>; Thu, 26 Feb 2015 08:55:19 +0100 (CET)
Received: from fmsmga003.fm.intel.com ([10.253.24.29])
 by orsmga101.jf.intel.com with ESMTP; 25 Feb 2015 23:55:18 -0800
X-ExtLoop1: 1
X-IronPort-AV: E=Sophos;i="5.09,651,1418112000"; d="scan'208";a="459738627"
Received: from kmsmsx153.gar.corp.intel.com ([172.21.73.88])
 by FMSMGA003.fm.intel.com with ESMTP; 25 Feb 2015 23:39:43 -0800
Received: from shsmsx104.ccr.corp.intel.com (10.239.110.15) by
 KMSMSX153.gar.corp.intel.com (172.21.73.88) with Microsoft SMTP Server (TLS)
 id 14.3.195.1; Thu, 26 Feb 2015 15:55:15 +0800
Received: from shsmsx101.ccr.corp.intel.com ([169.254.1.192]) by
 SHSMSX104.ccr.corp.intel.com ([169.254.5.161]) with mapi id 14.03.0195.001;
 Thu, 26 Feb 2015 15:55:13 +0800
From: "Liu, Jijiang" <jijiang.liu@intel.com>
To: Stephen Hemminger <stephen@networkplumber.org>, "dev@dpdk.org"
 <dev@dpdk.org>
Thread-Topic: [dpdk-dev] [PATCH 3/5] xen: add phys-addr command line argument
Thread-Index: AQHQSTO8Nobsnk7LR0yStA51AO4cA50CnlGg
Date: Thu, 26 Feb 2015 07:55:13 +0000
Message-ID: <1ED644BD7E0A5F4091CF203DAFB8E4CC01DDF09A@SHSMSX101.ccr.corp.intel.com>
References: <1424013889-2226-1-git-send-email-shemming@brocade.com>
 <1424013889-2226-3-git-send-email-shemming@brocade.com>
In-Reply-To: <1424013889-2226-3-git-send-email-shemming@brocade.com>
Accept-Language: en-US
Content-Language: en-US
X-MS-Has-Attach: 
X-MS-TNEF-Correlator: 
x-originating-ip: [10.239.127.40]
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
MIME-Version: 1.0
Cc: Stephen Hemminger <shemming@brocade.com>
Subject: Re: [dpdk-dev] [PATCH 3/5] xen: add phys-addr command line argument
X-BeenThere: dev@dpdk.org
X-Mailman-Version: 2.1.15
Precedence: list
List-Id: patches and discussions about DPDK <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: Thu, 26 Feb 2015 07:55:20 -0000



> -----Original Message-----
> From: dev [mailto:dev-bounces@dpdk.org] On Behalf Of Stephen Hemminger
> Sent: Sunday, February 15, 2015 11:25 PM
> To: dev@dpdk.org
> Cc: Stephen Hemminger
> Subject: [dpdk-dev] [PATCH 3/5] xen: add phys-addr command line argument
>=20
> Allow overriding default Xen DOM0 behavior to use physical addresses inst=
ed of
> mfn

If the application is built with DOM0 support , the application will run in=
 non Dom0 environment when using the new argument, correct?

> Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
> ---
> v2 -- no changes
>=20
>  lib/librte_eal/common/eal_common_options.c |  5 +++++
>  lib/librte_eal/common/eal_internal_cfg.h   |  1 +
>  lib/librte_eal/common/eal_options.h        |  2 ++
>  lib/librte_eal/common/include/rte_memory.h |  3 +++
>  lib/librte_eal/linuxapp/eal/eal_memory.c   |  5 +++++
>  lib/librte_mempool/rte_dom0_mempool.c      | 10 ++++++++--
>  6 files changed, 24 insertions(+), 2 deletions(-)
>=20
> diff --git a/lib/librte_eal/common/eal_common_options.c
> b/lib/librte_eal/common/eal_common_options.c
> index 67e02dc..1742364 100644
> --- a/lib/librte_eal/common/eal_common_options.c
> +++ b/lib/librte_eal/common/eal_common_options.c
> @@ -83,6 +83,7 @@ eal_long_options[] =3D {
>  	{OPT_LOG_LEVEL, 1, NULL, OPT_LOG_LEVEL_NUM},
>  	{OPT_BASE_VIRTADDR, 1, 0, OPT_BASE_VIRTADDR_NUM},
>  	{OPT_XEN_DOM0, 0, 0, OPT_XEN_DOM0_NUM},
> +	{OPT_XEN_PHYS_ADDR, 0, 0, OPT_XEN_PHYS_ADDR_NUM},
>  	{OPT_CREATE_UIO_DEV, 1, NULL, OPT_CREATE_UIO_DEV_NUM},
>  	{OPT_VFIO_INTR, 1, NULL, OPT_VFIO_INTR_NUM},
>  	{0, 0, 0, 0}
> @@ -491,6 +492,10 @@ eal_parse_common_option(int opt, const char
> *optarg,
>  		}
>  		conf->log_level =3D log;
>  		break;
> +
> +	case OPT_XEN_PHYS_ADDR_NUM:
> +		conf->xen_phys_addr_support =3D 1;
> +		break;
>  	}
>=20
>  	/* don't know what to do, leave this to caller */ diff --git
> a/lib/librte_eal/common/eal_internal_cfg.h
> b/lib/librte_eal/common/eal_internal_cfg.h
> index e2ecb0d..41b4169 100644
> --- a/lib/librte_eal/common/eal_internal_cfg.h
> +++ b/lib/librte_eal/common/eal_internal_cfg.h
> @@ -65,6 +65,7 @@ struct internal_config {
>  	volatile unsigned force_nrank;    /**< force number of ranks */
>  	volatile unsigned no_hugetlbfs;   /**< true to disable hugetlbfs */
>  	volatile unsigned xen_dom0_support; /**< support app running on Xen
> Dom0*/
> +	volatile unsigned xen_phys_addr_support; /**< support phys addr */
>  	volatile unsigned no_pci;         /**< true to disable PCI */
>  	volatile unsigned no_hpet;        /**< true to disable HPET */
>  	volatile unsigned vmware_tsc_map; /**< true to use VMware TSC
> mapping diff --git a/lib/librte_eal/common/eal_options.h
> b/lib/librte_eal/common/eal_options.h
> index e476f8d..8aee959 100644
> --- a/lib/librte_eal/common/eal_options.h
> +++ b/lib/librte_eal/common/eal_options.h
> @@ -73,6 +73,8 @@ enum {
>  	OPT_BASE_VIRTADDR_NUM,
>  #define OPT_XEN_DOM0    "xen-dom0"
>  	OPT_XEN_DOM0_NUM,
> +#define OPT_XEN_PHYS_ADDR "xen-phys-addr"
> +	OPT_XEN_PHYS_ADDR_NUM,
>  #define OPT_CREATE_UIO_DEV "create-uio-dev"
>  	OPT_CREATE_UIO_DEV_NUM,
>  #define OPT_VFIO_INTR    "vfio-intr"
> diff --git a/lib/librte_eal/common/include/rte_memory.h
> b/lib/librte_eal/common/include/rte_memory.h
> index ab6c1ff..c3b8a98 100644
> --- a/lib/librte_eal/common/include/rte_memory.h
> +++ b/lib/librte_eal/common/include/rte_memory.h
> @@ -180,6 +180,9 @@ unsigned rte_memory_get_nrank(void);  /**< Internal
> use only - should DOM0 memory mapping be used */  extern int
> is_xen_dom0_supported(void);
>=20
> +/**< Internal use only - should DOM0 use physical addresses insted of
> +mfn */ extern int is_xen_phys_addr_supported(void);
> +
>  /**
>   * Return the physical address of elt, which is an element of the pool m=
p.
>   *
> diff --git a/lib/librte_eal/linuxapp/eal/eal_memory.c
> b/lib/librte_eal/linuxapp/eal/eal_memory.c
> index 4afda2a..a759ac9 100644
> --- a/lib/librte_eal/linuxapp/eal/eal_memory.c
> +++ b/lib/librte_eal/linuxapp/eal/eal_memory.c
> @@ -103,6 +103,11 @@ int is_xen_dom0_supported(void)  {
>  	return internal_config.xen_dom0_support;  }
> +
> +int is_xen_phys_addr_supported(void)
> +{
> +	return internal_config.xen_phys_addr_support;
> +}
>  #endif
>=20
>  /**
> diff --git a/lib/librte_mempool/rte_dom0_mempool.c
> b/lib/librte_mempool/rte_dom0_mempool.c
> index 9ec68fb..ab35826 100644
> --- a/lib/librte_mempool/rte_dom0_mempool.c
> +++ b/lib/librte_mempool/rte_dom0_mempool.c
> @@ -74,8 +74,14 @@ get_phys_map(void *va, phys_addr_t pa[], uint32_t
> pg_num,
>      virt_addr =3D(uintptr_t) mcfg->memseg[memseg_id].addr;
>=20
>      for (i =3D 0; i !=3D pg_num; i++) {
> -        mfn_id =3D ((uintptr_t)va + i * pg_sz - virt_addr) / RTE_PGSIZE_=
2M;
> -        pa[i] =3D mcfg->memseg[memseg_id].mfn[mfn_id] * page_size;
> +	if (!is_xen_phys_addr_supported()) {
> +		mfn_id =3D ((uintptr_t)va + i * pg_sz -
> +				virt_addr) / RTE_PGSIZE_2M;
> +		pa[i] =3D mcfg->memseg[memseg_id].mfn[mfn_id] * page_size;
> +	} else {
> +		pa[i] =3D mcfg->memseg[memseg_id].phys_addr + i * pg_sz +
> +			(uintptr_t)va - virt_addr;
> +	}
>      }
>  }
>=20
> --
> 2.1.4