net/ice/base: remove unnecessary dummy packet finding
[dpdk.git] / lib / librte_eal / linux / eal / eal_memory.c
index 1853ace..8f62c34 100644 (file)
@@ -38,7 +38,6 @@
 #include <rte_memory.h>
 #include <rte_launch.h>
 #include <rte_eal.h>
-#include <rte_eal_memconfig.h>
 #include <rte_per_lcore.h>
 #include <rte_lcore.h>
 #include <rte_common.h>
@@ -46,6 +45,7 @@
 
 #include "eal_private.h"
 #include "eal_memalloc.h"
+#include "eal_memcfg.h"
 #include "eal_internal_cfg.h"
 #include "eal_filesystem.h"
 #include "eal_hugepages.h"
  * zone as well as a physical contiguous zone.
  */
 
-static bool phys_addrs_available = true;
+static int phys_addrs_available = -1;
 
 #define RANDOMIZE_VA_SPACE_FILE "/proc/sys/kernel/randomize_va_space"
 
-static void
-test_phys_addrs_available(void)
-{
-       uint64_t tmp = 0;
-       phys_addr_t physaddr;
-
-       if (!rte_eal_has_hugepages()) {
-               RTE_LOG(ERR, EAL,
-                       "Started without hugepages support, physical addresses not available\n");
-               phys_addrs_available = false;
-               return;
-       }
-
-       physaddr = rte_mem_virt2phy(&tmp);
-       if (physaddr == RTE_BAD_PHYS_ADDR) {
-               if (rte_eal_iova_mode() == RTE_IOVA_PA)
-                       RTE_LOG(ERR, EAL,
-                               "Cannot obtain physical addresses: %s. "
-                               "Only vfio will function.\n",
-                               strerror(errno));
-               phys_addrs_available = false;
-       }
-}
-
 /*
  * Get physical address of any mapped virtual address in the current process.
  */
@@ -105,8 +81,7 @@ rte_mem_virt2phy(const void *virtaddr)
        int page_size;
        off_t offset;
 
-       /* Cannot parse /proc/self/pagemap, no need to log errors everywhere */
-       if (!phys_addrs_available)
+       if (phys_addrs_available == 0)
                return RTE_BAD_IOVA;
 
        /* standard page size */
@@ -1336,8 +1311,6 @@ eal_legacy_hugepage_init(void)
        int nr_hugefiles, nr_hugepages = 0;
        void *addr;
 
-       test_phys_addrs_available();
-
        memset(used_hp, 0, sizeof(used_hp));
 
        /* get pointer to global configuration */
@@ -1516,7 +1489,7 @@ eal_legacy_hugepage_init(void)
                                continue;
                }
 
-               if (phys_addrs_available &&
+               if (rte_eal_using_phys_addrs() &&
                                rte_eal_iova_mode() != RTE_IOVA_VA) {
                        /* find physical addresses for each hugepage */
                        if (find_physaddrs(&tmp_hp[hp_offset], hpi) < 0) {
@@ -1735,8 +1708,6 @@ eal_hugepage_init(void)
        uint64_t memory[RTE_MAX_NUMA_NODES];
        int hp_sz_idx, socket_id;
 
-       test_phys_addrs_available();
-
        memset(used_hp, 0, sizeof(used_hp));
 
        for (hp_sz_idx = 0;
@@ -1879,8 +1850,6 @@ eal_legacy_hugepage_attach(void)
                                "into secondary processes\n");
        }
 
-       test_phys_addrs_available();
-
        fd_hugepage = open(eal_hugepage_data_path(), O_RDONLY);
        if (fd_hugepage < 0) {
                RTE_LOG(ERR, EAL, "Could not open %s\n",
@@ -2020,6 +1989,15 @@ rte_eal_hugepage_attach(void)
 int
 rte_eal_using_phys_addrs(void)
 {
+       if (phys_addrs_available == -1) {
+               uint64_t tmp = 0;
+
+               if (rte_eal_has_hugepages() != 0 &&
+                   rte_mem_virt2phy(&tmp) != RTE_BAD_PHYS_ADDR)
+                       phys_addrs_available = 1;
+               else
+                       phys_addrs_available = 0;
+       }
        return phys_addrs_available;
 }