X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=lib%2Flibrte_eal%2Flinuxapp%2Feal%2Feal_xen_memory.c;h=19db1cb5fde56a43c4f4fd8bbb9c6af228535041;hb=31850d26850e59cb20cdb84a8048d9f501f3cb22;hp=4c66bf3af2a124e875d5798574f6fcdc79173ca7;hpb=3031749c2df04a63cdcef186dcce3781e61436e8;p=dpdk.git diff --git a/lib/librte_eal/linuxapp/eal/eal_xen_memory.c b/lib/librte_eal/linuxapp/eal/eal_xen_memory.c index 4c66bf3af2..19db1cb5fd 100644 --- a/lib/librte_eal/linuxapp/eal/eal_xen_memory.c +++ b/lib/librte_eal/linuxapp/eal/eal_xen_memory.c @@ -38,7 +38,6 @@ #include #include #include -#include #include #include #include @@ -46,7 +45,6 @@ #include #include #include -#include #include #include @@ -54,7 +52,6 @@ #include #include #include -#include #include #include #include @@ -87,7 +84,7 @@ xen_get_virtual_area(size_t *size, size_t mem_size) int fd; long aligned_addr; - RTE_LOG(INFO, EAL, "Ask a virtual area of 0x%zu bytes\n", *size); + RTE_LOG(DEBUG, EAL, "Ask a virtual area of 0x%zu bytes\n", *size); fd = open("/dev/zero", O_RDONLY); if (fd < 0){ @@ -103,7 +100,7 @@ xen_get_virtual_area(size_t *size, size_t mem_size) if (addr == MAP_FAILED) { close(fd); - RTE_LOG(INFO, EAL, "Cannot get a virtual area\n"); + RTE_LOG(ERR, EAL, "Cannot get a virtual area\n"); return NULL; } @@ -115,7 +112,7 @@ xen_get_virtual_area(size_t *size, size_t mem_size) aligned_addr = RTE_ALIGN_CEIL(aligned_addr, mem_size); addr = (void *)(aligned_addr); - RTE_LOG(INFO, EAL, "Virtual area found at %p (size = 0x%zx)\n", + RTE_LOG(DEBUG, EAL, "Virtual area found at %p (size = 0x%zx)\n", addr, *size); return addr; @@ -133,7 +130,7 @@ get_xen_memory_size(void) static const char *file_name; file_name = "memsize"; - rte_snprintf(path, sizeof(path), "%s/%s", + snprintf(path, sizeof(path), "%s/%s", sys_dir_path, file_name); if (eal_parse_sysfs_value(path, &mem_size) < 0) @@ -157,13 +154,27 @@ get_xen_memory_size(void) * Based on physical address to caculate MFN in Xen Dom0. */ phys_addr_t -rte_mem_phy2mch(uint32_t memseg_id, const phys_addr_t phy_addr) +rte_xen_mem_phy2mch(int32_t memseg_id, const phys_addr_t phy_addr) { - int mfn_id; + int mfn_id, i; uint64_t mfn, mfn_offset; struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config; struct rte_memseg *memseg = mcfg->memseg; + /* find the memory segment owning the physical address */ + if (memseg_id == -1) { + for (i = 0; i < RTE_MAX_MEMSEG; i++) { + if ((phy_addr >= memseg[i].phys_addr) && + (phy_addr < memseg[i].phys_addr + + memseg[i].len)) { + memseg_id = i; + break; + } + } + if (memseg_id == -1) + return RTE_BAD_PHYS_ADDR; + } + mfn_id = (phy_addr - memseg[memseg_id].phys_addr) / RTE_PGSIZE_2M; /*the MFN is contiguous in 2M */ @@ -172,7 +183,7 @@ rte_mem_phy2mch(uint32_t memseg_id, const phys_addr_t phy_addr) mfn = mfn_offset + memseg[memseg_id].mfn[mfn_id]; /** return mechine address */ - return (mfn * PAGE_SIZE + phy_addr % PAGE_SIZE); + return mfn * PAGE_SIZE + phy_addr % PAGE_SIZE; } int @@ -213,7 +224,7 @@ rte_xen_dom0_memory_init(void) meminfo.size = mem_size; /* construct memory mangement name for Dom0 */ - rte_snprintf(meminfo.name, DOM0_NAME_MAX, "%s-%s", + snprintf(meminfo.name, DOM0_NAME_MAX, "%s-%s", internal_config.hugefile_prefix, DEFAUL_DOM0_NAME); /* Notify kernel driver to allocate memory */ @@ -329,7 +340,7 @@ rte_xen_dom0_memory_attach(void) } /* construct memory mangement name for Dom0 */ - rte_snprintf(name, DOM0_NAME_MAX, "%s-%s", + snprintf(name, DOM0_NAME_MAX, "%s-%s", internal_config.hugefile_prefix, DEFAUL_DOM0_NAME); /* attach to memory segments of primary process */ ret = ioctl(xen_fd, RTE_DOM0_IOCTL_ATTACH_TO_MEMSEG, name);