eal: use sizeof to avoid a double use of a define
[dpdk.git] / lib / librte_eal / linuxapp / eal / eal.c
index ad72789..9c7d762 100644 (file)
@@ -56,7 +56,6 @@
 #include <rte_common.h>
 #include <rte_debug.h>
 #include <rte_memory.h>
-#include <rte_memzone.h>
 #include <rte_launch.h>
 #include <rte_eal.h>
 #include <rte_eal_memconfig.h>
 #include <rte_cpuflags.h>
 #include <rte_interrupts.h>
 #include <rte_bus.h>
-#include <rte_pci.h>
 #include <rte_dev.h>
 #include <rte_devargs.h>
 #include <rte_version.h>
 #include <rte_atomic.h>
 #include <malloc_heap.h>
+#include <rte_vfio.h>
 
 #include "eal_private.h"
 #include "eal_thread.h"
@@ -710,10 +709,9 @@ static int rte_eal_vfio_setup(void)
 {
        int vfio_enabled = 0;
 
-       if (!internal_config.no_pci) {
-               pci_vfio_enable();
-               vfio_enabled |= pci_vfio_is_enabled();
-       }
+       if (rte_vfio_enable("vfio"))
+               return -1;
+       vfio_enabled = rte_vfio_is_enabled("vfio");
 
        if (vfio_enabled) {
 
@@ -809,6 +807,15 @@ rte_eal_init(int argc, char **argv)
        /* autodetect the iova mapping mode (default is iova_pa) */
        rte_eal_get_configuration()->iova_mode = rte_bus_get_iommu_class();
 
+       /* Workaround for KNI which requires physical address to work */
+       if (rte_eal_get_configuration()->iova_mode == RTE_IOVA_VA &&
+                       rte_eal_check_module("rte_kni") == 1) {
+               rte_eal_get_configuration()->iova_mode = RTE_IOVA_PA;
+               RTE_LOG(WARNING, EAL,
+                       "Some devices want IOVA as VA but PA will be used because.. "
+                       "KNI module inserted\n");
+       }
+
        if (internal_config.no_hugetlbfs == 0 &&
                        internal_config.process_type != RTE_PROC_SECONDARY &&
                        eal_hugepage_info_init() < 0) {
@@ -891,7 +898,7 @@ rte_eal_init(int argc, char **argv)
 
        eal_thread_init_master(rte_config.master_lcore);
 
-       ret = eal_thread_dump_affinity(cpuset, RTE_CPU_AFFINITY_STR_LEN);
+       ret = eal_thread_dump_affinity(cpuset, sizeof(cpuset));
 
        RTE_LOG(DEBUG, EAL, "Master lcore %u is ready (tid=%x;cpuset=[%s%s])\n",
                rte_config.master_lcore, (int)thread_id, cpuset,
@@ -922,7 +929,7 @@ rte_eal_init(int argc, char **argv)
                        rte_panic("Cannot create thread\n");
 
                /* Set thread_name for aid in debugging. */
-               snprintf(thread_name, RTE_MAX_THREAD_NAME_LEN,
+               snprintf(thread_name, sizeof(thread_name),
                        "lcore-slave-%d", i);
                ret = rte_thread_setname(lcore_config[i].thread_id,
                                                thread_name);
@@ -985,6 +992,22 @@ int rte_eal_has_hugepages(void)
        return ! internal_config.no_hugetlbfs;
 }
 
+int rte_eal_has_pci(void)
+{
+       return !internal_config.no_pci;
+}
+
+int rte_eal_create_uio_dev(void)
+{
+       return internal_config.create_uio_dev;
+}
+
+enum rte_intr_mode
+rte_eal_vfio_intr_mode(void)
+{
+       return internal_config.vfio_intr_mode;
+}
+
 int
 rte_eal_check_module(const char *module_name)
 {