From 5b31fa72d3cf9c3fcfdf1e9582d3697609dd46dd Mon Sep 17 00:00:00 2001 From: Xavier Arteaga Date: Fri, 23 Jul 2021 13:20:54 +0200 Subject: [PATCH] Fix gnb race condition in asynchronous PRACH processing by setting number of threads to 0 --- srsenb/hdr/phy/nr/worker_pool.h | 2 ++ srsenb/src/phy/nr/worker_pool.cc | 4 +++- test/phy/CMakeLists.txt | 19 +++++++++---------- test/phy/dummy_gnb_stack.h | 5 +++++ test/phy/nr_phy_test.cc | 3 --- 5 files changed, 19 insertions(+), 14 deletions(-) diff --git a/srsenb/hdr/phy/nr/worker_pool.h b/srsenb/hdr/phy/nr/worker_pool.h index d246619c6..600bfd65a 100644 --- a/srsenb/hdr/phy/nr/worker_pool.h +++ b/srsenb/hdr/phy/nr/worker_pool.h @@ -82,6 +82,7 @@ private: uint32_t current_tti = 0; ///< Current TTI, read and write from same thread srslog::basic_logger& logger; prach_stack_adaptor_t prach_stack_adaptor; + uint32_t nof_prach_workers = 0; // Current configuration std::mutex common_cfg_mutex; @@ -91,6 +92,7 @@ private: public: struct args_t { uint32_t nof_phy_threads = 3; + uint32_t nof_prach_workers = 0; uint32_t prio = 52; uint32_t pusch_max_nof_iter = 10; srsran::phy_log_args_t log = {}; diff --git a/srsenb/src/phy/nr/worker_pool.cc b/srsenb/src/phy/nr/worker_pool.cc index 533557681..abd9846c3 100644 --- a/srsenb/src/phy/nr/worker_pool.cc +++ b/srsenb/src/phy/nr/worker_pool.cc @@ -30,6 +30,8 @@ worker_pool::worker_pool(srsran::phy_common_interface& common_, bool worker_pool::init(const args_t& args, const phy_cell_cfg_list_nr_t& cell_list) { + nof_prach_workers = args.nof_prach_workers; + // Configure logger srslog::basic_levels log_level = srslog::str_to_basic_level(args.log.phy_level); logger.set_level(log_level); @@ -131,7 +133,7 @@ int worker_pool::set_common_cfg(const phy_interface_rrc_nr::common_cfg_t& common prach_cfg.is_nr = true; // Set the PRACH configuration - prach.init(0, cell, prach_cfg, &prach_stack_adaptor, logger, 0, 1); + prach.init(0, cell, prach_cfg, &prach_stack_adaptor, logger, 0, nof_prach_workers); prach.set_max_prach_offset_us(1000); // Save current configuration diff --git a/test/phy/CMakeLists.txt b/test/phy/CMakeLists.txt index 1387419ae..a89a27329 100644 --- a/test/phy/CMakeLists.txt +++ b/test/phy/CMakeLists.txt @@ -60,16 +60,15 @@ if (RF_FOUND AND ENABLE_SRSUE AND ENABLE_SRSENB) --ue.phy.nof_threads=${NR_PHY_TEST_UE_NOF_THREADS} ) - # Disabled until fixed - #add_nr_test(nr_phy_test_10MHz_prach nr_phy_test - # --duration=1000 # 100 slots - # --gnb.stack.pdsch.slots=none # No PDSCH - # --gnb.stack.pusch.slots=none # No PUSCH - # --gnb.phy.nof_threads=${NR_PHY_TEST_GNB_NOF_THREADS} - # --ue.stack.prach.period=30 # Transmit PRACH every 30 radio frames - # --ue.stack.prach.preamble=10 # Use preamble 10 - # --ue.phy.nof_threads=${NR_PHY_TEST_UE_NOF_THREADS} - # ) + add_nr_test(nr_phy_test_10MHz_prach nr_phy_test + --duration=1000 # 100 slots + --gnb.stack.pdsch.slots=none # No PDSCH + --gnb.stack.pusch.slots=none # No PUSCH + --gnb.phy.nof_threads=${NR_PHY_TEST_GNB_NOF_THREADS} + --ue.stack.prach.period=30 # Transmit PRACH every 30 radio frames + --ue.stack.prach.preamble=10 # Use preamble 10 + --ue.phy.nof_threads=${NR_PHY_TEST_UE_NOF_THREADS} + ) add_nr_test(nr_phy_test_10MHz_sr nr_phy_test --duration=1000 # 100 slots diff --git a/test/phy/dummy_gnb_stack.h b/test/phy/dummy_gnb_stack.h index 649419d15..9ddbaee58 100644 --- a/test/phy/dummy_gnb_stack.h +++ b/test/phy/dummy_gnb_stack.h @@ -566,6 +566,11 @@ public: return SRSRAN_ERROR; } + // Skip next steps if uci data is invalid + if (not pucch_info.uci_data.value.valid) { + return SRSRAN_SUCCESS; + } + // Handle PHY metrics metrics.pucch.epre_db_avg = SRSRAN_VEC_CMA(pucch_info.csi.epre_dB, metrics.pucch.epre_db_avg, metrics.pucch.count); metrics.pucch.epre_db_min = SRSRAN_MIN(metrics.pucch.epre_db_min, pucch_info.csi.epre_dB); diff --git a/test/phy/nr_phy_test.cc b/test/phy/nr_phy_test.cc index e742af6f7..ccfed9a3d 100644 --- a/test/phy/nr_phy_test.cc +++ b/test/phy/nr_phy_test.cc @@ -254,9 +254,6 @@ int main(int argc, char** argv) metrics.gnb_stack.pucch.ta_us_min, metrics.gnb_stack.pucch.ta_us_max); srsran::console(" +------------+------------+------------+------------+\n"); - } else { - // In this case the gNb should not have detected any - TESTASSERT(metrics.gnb_stack.prach.empty()); } // Print SR