LCOV - code coverage report
Current view: top level - lib/eal/common - eal_common_mcfg.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 80 84 95.2 %
Date: 2025-01-02 22:41:34 Functions: 24 25 96.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 3 4 75.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(c) 2019 Intel Corporation
       3                 :            :  */
       4                 :            : 
       5                 :            : #include <rte_eal_memconfig.h>
       6                 :            : #include <rte_version.h>
       7                 :            : 
       8                 :            : #include "eal_internal_cfg.h"
       9                 :            : #include "eal_memcfg.h"
      10                 :            : #include "eal_private.h"
      11                 :            : 
      12                 :            : void
      13                 :        179 : eal_mcfg_complete(void)
      14                 :            : {
      15                 :        179 :         struct rte_config *cfg = rte_eal_get_configuration();
      16                 :        179 :         struct rte_mem_config *mcfg = cfg->mem_config;
      17                 :            :         struct internal_config *internal_conf =
      18                 :        179 :                 eal_get_internal_configuration();
      19                 :            : 
      20                 :            :         /* ALL shared mem_config related INIT DONE */
      21         [ +  + ]:        179 :         if (cfg->process_type == RTE_PROC_PRIMARY)
      22                 :        154 :                 mcfg->magic = RTE_MAGIC;
      23                 :            : 
      24                 :        179 :         internal_conf->init_complete = 1;
      25                 :        179 : }
      26                 :            : 
      27                 :            : void
      28                 :         27 : eal_mcfg_wait_complete(void)
      29                 :            : {
      30                 :         27 :         struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
      31                 :            : 
      32                 :            :         /* wait until shared mem_config finish initialising */
      33                 :         27 :         rte_wait_until_equal_32(&mcfg->magic, RTE_MAGIC, rte_memory_order_relaxed);
      34                 :         27 : }
      35                 :            : 
      36                 :            : int
      37                 :         27 : eal_mcfg_check_version(void)
      38                 :            : {
      39                 :         27 :         struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
      40                 :            : 
      41                 :            :         /* check if version from memconfig matches compiled in macro */
      42         [ -  + ]:         27 :         if (mcfg->version != RTE_VERSION)
      43                 :          0 :                 return -1;
      44                 :            : 
      45                 :            :         return 0;
      46                 :            : }
      47                 :            : 
      48                 :            : void
      49                 :         27 : eal_mcfg_update_internal(void)
      50                 :            : {
      51                 :         27 :         struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
      52                 :            :         struct internal_config *internal_conf =
      53                 :         27 :                 eal_get_internal_configuration();
      54                 :            : 
      55                 :         27 :         internal_conf->legacy_mem = mcfg->legacy_mem;
      56                 :         27 :         internal_conf->single_file_segments = mcfg->single_file_segments;
      57                 :         27 : }
      58                 :            : 
      59                 :            : void
      60                 :        157 : eal_mcfg_update_from_internal(void)
      61                 :            : {
      62                 :        157 :         struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
      63                 :            :         const struct internal_config *internal_conf =
      64                 :        157 :                 eal_get_internal_configuration();
      65                 :            : 
      66                 :        157 :         mcfg->legacy_mem = internal_conf->legacy_mem;
      67                 :        157 :         mcfg->single_file_segments = internal_conf->single_file_segments;
      68                 :            :         /* record current DPDK version */
      69                 :        157 :         mcfg->version = RTE_VERSION;
      70                 :        157 : }
      71                 :            : 
      72                 :            : rte_rwlock_t *
      73                 :      15938 : rte_mcfg_mem_get_lock(void)
      74                 :            : {
      75                 :      15938 :         return &rte_eal_get_configuration()->mem_config->memory_hotplug_lock;
      76                 :            : }
      77                 :            : 
      78                 :            : void
      79                 :       6967 : rte_mcfg_mem_read_lock(void)
      80                 :            : {
      81                 :       6967 :         rte_rwlock_read_lock(rte_mcfg_mem_get_lock());
      82                 :       6967 : }
      83                 :            : 
      84                 :            : void
      85                 :       6967 : rte_mcfg_mem_read_unlock(void)
      86                 :            : {
      87                 :       6967 :         rte_rwlock_read_unlock(rte_mcfg_mem_get_lock());
      88                 :       6967 : }
      89                 :            : 
      90                 :            : void
      91                 :       1002 : rte_mcfg_mem_write_lock(void)
      92                 :            : {
      93                 :       1002 :         rte_rwlock_write_lock(rte_mcfg_mem_get_lock());
      94                 :       1002 : }
      95                 :            : 
      96                 :            : void
      97                 :       1002 : rte_mcfg_mem_write_unlock(void)
      98                 :            : {
      99                 :       1002 :         rte_rwlock_write_unlock(rte_mcfg_mem_get_lock());
     100                 :       1002 : }
     101                 :            : 
     102                 :            : rte_rwlock_t *
     103                 :      30513 : rte_mcfg_tailq_get_lock(void)
     104                 :            : {
     105                 :      30513 :         return &rte_eal_get_configuration()->mem_config->qlock;
     106                 :            : }
     107                 :            : 
     108                 :            : void
     109                 :       4538 : rte_mcfg_tailq_read_lock(void)
     110                 :            : {
     111                 :       4538 :         rte_rwlock_read_lock(rte_mcfg_tailq_get_lock());
     112                 :       4534 : }
     113                 :            : 
     114                 :            : void
     115                 :       4531 : rte_mcfg_tailq_read_unlock(void)
     116                 :            : {
     117                 :       4531 :         rte_rwlock_read_unlock(rte_mcfg_tailq_get_lock());
     118                 :       4530 : }
     119                 :            : 
     120                 :            : void
     121                 :      10727 : rte_mcfg_tailq_write_lock(void)
     122                 :            : {
     123                 :      10727 :         rte_rwlock_write_lock(rte_mcfg_tailq_get_lock());
     124                 :      10735 : }
     125                 :            : 
     126                 :            : void
     127                 :      10735 : rte_mcfg_tailq_write_unlock(void)
     128                 :            : {
     129                 :      10735 :         rte_rwlock_write_unlock(rte_mcfg_tailq_get_lock());
     130                 :      10735 : }
     131                 :            : 
     132                 :            : rte_rwlock_t *
     133                 :        465 : rte_mcfg_mempool_get_lock(void)
     134                 :            : {
     135                 :        465 :         return &rte_eal_get_configuration()->mem_config->mplock;
     136                 :            : }
     137                 :            : 
     138                 :            : void
     139                 :        110 : rte_mcfg_mempool_read_lock(void)
     140                 :            : {
     141                 :        110 :         rte_rwlock_read_lock(rte_mcfg_mempool_get_lock());
     142                 :        110 : }
     143                 :            : 
     144                 :            : void
     145                 :        110 : rte_mcfg_mempool_read_unlock(void)
     146                 :            : {
     147                 :        110 :         rte_rwlock_read_unlock(rte_mcfg_mempool_get_lock());
     148                 :        110 : }
     149                 :            : 
     150                 :            : void
     151                 :        122 : rte_mcfg_mempool_write_lock(void)
     152                 :            : {
     153                 :        122 :         rte_rwlock_write_lock(rte_mcfg_mempool_get_lock());
     154                 :        123 : }
     155                 :            : 
     156                 :            : void
     157                 :        123 : rte_mcfg_mempool_write_unlock(void)
     158                 :            : {
     159                 :        123 :         rte_rwlock_write_unlock(rte_mcfg_mempool_get_lock());
     160                 :        123 : }
     161                 :            : 
     162                 :            : rte_spinlock_t *
     163                 :        850 : rte_mcfg_timer_get_lock(void)
     164                 :            : {
     165                 :        850 :         return &rte_eal_get_configuration()->mem_config->tlock;
     166                 :            : }
     167                 :            : 
     168                 :            : void
     169                 :        425 : rte_mcfg_timer_lock(void)
     170                 :            : {
     171                 :        425 :         rte_spinlock_lock(rte_mcfg_timer_get_lock());
     172                 :        425 : }
     173                 :            : 
     174                 :            : void
     175                 :        425 : rte_mcfg_timer_unlock(void)
     176                 :            : {
     177                 :        425 :         rte_spinlock_unlock(rte_mcfg_timer_get_lock());
     178                 :        425 : }
     179                 :            : 
     180                 :            : rte_spinlock_t *
     181                 :        172 : rte_mcfg_ethdev_get_lock(void)
     182                 :            : {
     183                 :        172 :         return &rte_eal_get_configuration()->mem_config->ethdev_lock;
     184                 :            : }
     185                 :            : 
     186                 :            : bool
     187                 :          0 : rte_mcfg_get_single_file_segments(void)
     188                 :            : {
     189                 :          0 :         struct rte_mem_config *mcfg = rte_eal_get_configuration()->mem_config;
     190                 :          0 :         return (bool)mcfg->single_file_segments;
     191                 :            : }

Generated by: LCOV version 1.14