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

Generated by: LCOV version 1.14