mem: rename segment address from physical to IOVA
[dpdk.git] / lib / librte_eal / common / eal_common_memory.c
index 6155752..fc6c44d 100644 (file)
 #include <stdint.h>
 #include <stdlib.h>
 #include <stdarg.h>
+#include <unistd.h>
 #include <inttypes.h>
+#include <sys/mman.h>
 #include <sys/queue.h>
 
 #include <rte_memory.h>
-#include <rte_memzone.h>
 #include <rte_eal.h>
 #include <rte_eal_memconfig.h>
 #include <rte_log.h>
@@ -94,11 +95,11 @@ rte_dump_physmem_layout(FILE *f)
                if (mcfg->memseg[i].addr == NULL)
                        break;
 
-               fprintf(f, "Segment %u: phys:0x%"PRIx64", len:%zu, "
+               fprintf(f, "Segment %u: IOVA:0x%"PRIx64", len:%zu, "
                       "virt:%p, socket_id:%"PRId32", "
                       "hugepage_sz:%"PRIu64", nchannel:%"PRIx32", "
                       "nrank:%"PRIx32"\n", i,
-                      mcfg->memseg[i].phys_addr,
+                      mcfg->memseg[i].iova,
                       mcfg->memseg[i].len,
                       mcfg->memseg[i].addr,
                       mcfg->memseg[i].socket_id,
@@ -135,6 +136,16 @@ rte_eal_memdevice_init(void)
        return 0;
 }
 
+/* Lock page in physical memory and prevent from swapping. */
+int
+rte_mem_lock_page(const void *virt)
+{
+       unsigned long virtual = (unsigned long)virt;
+       int page_size = getpagesize();
+       unsigned long aligned = (virtual & ~(page_size - 1));
+       return mlock((void *)aligned, page_size);
+}
+
 /* init memory subsystem */
 int
 rte_eal_memory_init(void)