From patchwork Sat Feb 14 18:06:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stephen Hemminger X-Patchwork-Id: 3328 Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id 99C8BB4EF; Sat, 14 Feb 2015 19:07:03 +0100 (CET) Received: from mail-ig0-f179.google.com (mail-ig0-f179.google.com [209.85.213.179]) by dpdk.org (Postfix) with ESMTP id B266FB4DF for ; Sat, 14 Feb 2015 19:07:00 +0100 (CET) Received: by mail-ig0-f179.google.com with SMTP id l13so16667121iga.0 for ; Sat, 14 Feb 2015 10:07:00 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=Pm98xqAlVn/bcnwyz1ddKoMu5pr93LiuMN2ghkVXCY0=; b=MrtEYbwRiPoeMupK/mCebQ0Lh12fZLquzpPrwWPac23Ts3Tyzay2so7a2U/6XOD4c9 TiW87kAGkEoO4ywOcsTLAEwgVrFZCcHUBiCQBX+/zvKxn6Sh5PDMtUPr/h1LENic41cM Lgay2XLRFjbY8XlsN8k6lyoAFzXbRNbLxidyiKxcsjER3wAMXNxP9/3rVdG5z5qtbDSV MZsoi/n9eKJcJvMXwx53nY0OgjbUyXMOS+0Sx/J/cdDmxZwZ7u0djK0ECt8yWmDLXLnm iiq6Ao29CXl8MFzuE1KjdRST+EELyqDYms4rFqSq4XPS9Tp8tF09eE1W404daWI3Ufye KeKw== X-Gm-Message-State: ALoCoQlIZOQpSvLhA7cwervPvSqdTQCHgTYHT/YL1eC2sYjDqrcg/ZUstKA7KUCz4y6+DcSxSGOU X-Received: by 10.50.108.108 with SMTP id hj12mr11664642igb.47.1423937220224; Sat, 14 Feb 2015 10:07:00 -0800 (PST) Received: from uryu.home.lan ([67.210.173.2]) by mx.google.com with ESMTPSA id 199sm6551588ioe.14.2015.02.14.10.06.59 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sat, 14 Feb 2015 10:06:59 -0800 (PST) From: Stephen Hemminger X-Google-Original-From: Stephen Hemminger To: dev@dpdk.org Date: Sat, 14 Feb 2015 13:06:46 -0500 Message-Id: <1423937208-2063-2-git-send-email-shemming@brocade.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1423937208-2063-1-git-send-email-shemming@brocade.com> References: <1423937208-2063-1-git-send-email-shemming@brocade.com> Cc: Stephen Hemminger Subject: [dpdk-dev] [PATCH 2/4] 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" Allow overriding default Xen DOM0 behavior to use physical addresses insted of mfn. Signed-off-by: Stephen Hemminger --- 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(-) 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[] = { {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 = log; break; + + case OPT_XEN_PHYS_ADDR_NUM: + conf->xen_phys_addr_support = 1; + break; } /* 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); +/**< 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 mp. * 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 /** 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 =(uintptr_t) mcfg->memseg[memseg_id].addr; for (i = 0; i != pg_num; i++) { - mfn_id = ((uintptr_t)va + i * pg_sz - virt_addr) / RTE_PGSIZE_2M; - pa[i] = mcfg->memseg[memseg_id].mfn[mfn_id] * page_size; + if (!is_xen_phys_addr_supported()) { + mfn_id = ((uintptr_t)va + i * pg_sz - + virt_addr) / RTE_PGSIZE_2M; + pa[i] = mcfg->memseg[memseg_id].mfn[mfn_id] * page_size; + } else { + pa[i] = mcfg->memseg[memseg_id].phys_addr + i * pg_sz + + (uintptr_t)va - virt_addr; + } } }