Branch data Line data Source code
1 : : /* SPDX-License-Identifier: BSD-3-Clause 2 : : * Copyright(c) 2020 Mellanox Technologies, Ltd 3 : : */ 4 : : 5 : : #include <rte_string_fns.h> 6 : : 7 : : #include <eal_export.h> 8 : : #include "eal_private.h" 9 : : #include "eal_filesystem.h" 10 : : #include "eal_memcfg.h" 11 : : 12 : : /* early configuration structure, when memory config is not mmapped */ 13 : : static struct rte_mem_config early_mem_config = { 14 : : .mlock = RTE_RWLOCK_INITIALIZER, 15 : : .qlock = RTE_RWLOCK_INITIALIZER, 16 : : .mplock = RTE_RWLOCK_INITIALIZER, 17 : : .tlock = RTE_SPINLOCK_INITIALIZER, 18 : : .ethdev_lock = RTE_SPINLOCK_INITIALIZER, 19 : : .memory_hotplug_lock = RTE_RWLOCK_INITIALIZER, 20 : : }; 21 : : 22 : : /* Address of global and public configuration */ 23 : : static struct rte_config rte_config = { 24 : : .mem_config = &early_mem_config, 25 : : }; 26 : : 27 : : /* platform-specific runtime dir */ 28 : : static char runtime_dir[UNIX_PATH_MAX]; 29 : : 30 : : /* internal configuration */ 31 : : static struct internal_config internal_config; 32 : : 33 : : RTE_EXPORT_SYMBOL(rte_eal_get_runtime_dir) 34 : : const char * 35 : 2767 : rte_eal_get_runtime_dir(void) 36 : : { 37 : 2767 : return runtime_dir; 38 : : } 39 : : 40 : : int 41 [ - + ]: 223 : eal_set_runtime_dir(const char *run_dir) 42 : : { 43 : : /* runtime directory limited by maximum allowable unix domain socket */ 44 [ - + ]: 223 : if (strlcpy(runtime_dir, run_dir, UNIX_PATH_MAX) >= UNIX_PATH_MAX) { 45 : 0 : EAL_LOG(ERR, "Runtime directory string too long"); 46 : 0 : return -1; 47 : : } 48 : : 49 : : return 0; 50 : : } 51 : : 52 : : /* Return a pointer to the configuration structure */ 53 : : struct rte_config * 54 : 79647637 : rte_eal_get_configuration(void) 55 : : { 56 : 79647637 : return &rte_config; 57 : : } 58 : : 59 : : /* Return a pointer to the internal configuration structure */ 60 : : struct internal_config * 61 : 623980 : eal_get_internal_configuration(void) 62 : : { 63 : 623980 : return &internal_config; 64 : : } 65 : : 66 : : RTE_EXPORT_SYMBOL(rte_eal_iova_mode) 67 : : enum rte_iova_mode 68 : 58920222 : rte_eal_iova_mode(void) 69 : : { 70 : 58920222 : return rte_eal_get_configuration()->iova_mode; 71 : : } 72 : : 73 : : /* Get the EAL base address */ 74 : : RTE_EXPORT_INTERNAL_SYMBOL(rte_eal_get_baseaddr) 75 : : uint64_t 76 : 0 : rte_eal_get_baseaddr(void) 77 : : { 78 : 0 : return (internal_config.base_virtaddr != 0) ? 79 [ # # ]: 0 : (uint64_t) internal_config.base_virtaddr : 80 : 0 : eal_get_baseaddr(); 81 : : } 82 : : 83 : : RTE_EXPORT_SYMBOL(rte_eal_process_type) 84 : : enum rte_proc_type_t 85 : 14754 : rte_eal_process_type(void) 86 : : { 87 : 14754 : return rte_config.process_type; 88 : : } 89 : : 90 : : /* Return user provided mbuf pool ops name */ 91 : : RTE_EXPORT_SYMBOL(rte_eal_mbuf_user_pool_ops) 92 : : const char * 93 : 36 : rte_eal_mbuf_user_pool_ops(void) 94 : : { 95 : 36 : return internal_config.user_mbuf_pool_ops_name; 96 : : } 97 : : 98 : : /* return non-zero if hugepages are enabled. */ 99 : : RTE_EXPORT_SYMBOL(rte_eal_has_hugepages) 100 : : int 101 : 304055 : rte_eal_has_hugepages(void) 102 : : { 103 : 304055 : return !internal_config.no_hugetlbfs; 104 : : } 105 : : 106 : : RTE_EXPORT_SYMBOL(rte_eal_has_pci) 107 : : int 108 : 209 : rte_eal_has_pci(void) 109 : : { 110 : 209 : return !internal_config.no_pci; 111 : : }