LCOV - code coverage report
Current view: top level - lib/eal/common - eal_common_config.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 18 24 75.0 %
Date: 2025-05-01 17:49:45 Functions: 9 10 90.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 2 6 33.3 %

           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_memcfg.h"
      10                 :            : 
      11                 :            : /* early configuration structure, when memory config is not mmapped */
      12                 :            : static struct rte_mem_config early_mem_config = {
      13                 :            :         .mlock = RTE_RWLOCK_INITIALIZER,
      14                 :            :         .qlock = RTE_RWLOCK_INITIALIZER,
      15                 :            :         .mplock = RTE_RWLOCK_INITIALIZER,
      16                 :            :         .tlock = RTE_SPINLOCK_INITIALIZER,
      17                 :            :         .ethdev_lock = RTE_SPINLOCK_INITIALIZER,
      18                 :            :         .memory_hotplug_lock = RTE_RWLOCK_INITIALIZER,
      19                 :            : };
      20                 :            : 
      21                 :            : /* Address of global and public configuration */
      22                 :            : static struct rte_config rte_config = {
      23                 :            :         .mem_config = &early_mem_config,
      24                 :            : };
      25                 :            : 
      26                 :            : /* platform-specific runtime dir */
      27                 :            : static char runtime_dir[PATH_MAX];
      28                 :            : 
      29                 :            : /* internal configuration */
      30                 :            : static struct internal_config internal_config;
      31                 :            : 
      32                 :            : RTE_EXPORT_SYMBOL(rte_eal_get_runtime_dir)
      33                 :            : const char *
      34                 :       2722 : rte_eal_get_runtime_dir(void)
      35                 :            : {
      36                 :       2722 :         return runtime_dir;
      37                 :            : }
      38                 :            : 
      39                 :            : int
      40         [ -  + ]:        206 : eal_set_runtime_dir(const char *run_dir)
      41                 :            : {
      42         [ -  + ]:        206 :         if (strlcpy(runtime_dir, run_dir, PATH_MAX) >= PATH_MAX) {
      43                 :          0 :                 EAL_LOG(ERR, "Runtime directory string too long");
      44                 :          0 :                 return -1;
      45                 :            :         }
      46                 :            : 
      47                 :            :         return 0;
      48                 :            : }
      49                 :            : 
      50                 :            : /* Return a pointer to the configuration structure */
      51                 :            : struct rte_config *
      52                 :   60690955 : rte_eal_get_configuration(void)
      53                 :            : {
      54                 :   60690955 :         return &rte_config;
      55                 :            : }
      56                 :            : 
      57                 :            : /* Return a pointer to the internal configuration structure */
      58                 :            : struct internal_config *
      59                 :     550908 : eal_get_internal_configuration(void)
      60                 :            : {
      61                 :     550908 :         return &internal_config;
      62                 :            : }
      63                 :            : 
      64                 :            : RTE_EXPORT_SYMBOL(rte_eal_iova_mode)
      65                 :            : enum rte_iova_mode
      66                 :   47320055 : rte_eal_iova_mode(void)
      67                 :            : {
      68                 :   47320055 :         return rte_eal_get_configuration()->iova_mode;
      69                 :            : }
      70                 :            : 
      71                 :            : /* Get the EAL base address */
      72                 :            : RTE_EXPORT_INTERNAL_SYMBOL(rte_eal_get_baseaddr)
      73                 :            : uint64_t
      74                 :          0 : rte_eal_get_baseaddr(void)
      75                 :            : {
      76                 :          0 :         return (internal_config.base_virtaddr != 0) ?
      77         [ #  # ]:          0 :                        (uint64_t) internal_config.base_virtaddr :
      78                 :          0 :                        eal_get_baseaddr();
      79                 :            : }
      80                 :            : 
      81                 :            : RTE_EXPORT_SYMBOL(rte_eal_process_type)
      82                 :            : enum rte_proc_type_t
      83                 :      13504 : rte_eal_process_type(void)
      84                 :            : {
      85                 :      13504 :         return rte_config.process_type;
      86                 :            : }
      87                 :            : 
      88                 :            : /* Return user provided mbuf pool ops name */
      89                 :            : RTE_EXPORT_SYMBOL(rte_eal_mbuf_user_pool_ops)
      90                 :            : const char *
      91                 :         29 : rte_eal_mbuf_user_pool_ops(void)
      92                 :            : {
      93                 :         29 :         return internal_config.user_mbuf_pool_ops_name;
      94                 :            : }
      95                 :            : 
      96                 :            : /* return non-zero if hugepages are enabled. */
      97                 :            : RTE_EXPORT_SYMBOL(rte_eal_has_hugepages)
      98                 :            : int
      99                 :     235713 : rte_eal_has_hugepages(void)
     100                 :            : {
     101                 :     235713 :         return !internal_config.no_hugetlbfs;
     102                 :            : }
     103                 :            : 
     104                 :            : RTE_EXPORT_SYMBOL(rte_eal_has_pci)
     105                 :            : int
     106                 :        185 : rte_eal_has_pci(void)
     107                 :            : {
     108                 :        185 :         return !internal_config.no_pci;
     109                 :            : }

Generated by: LCOV version 1.14