From 496b8e2748f02f28bf65e05263039c5faaccfe0a Mon Sep 17 00:00:00 2001 From: Ismael Gomez Date: Mon, 14 Mar 2022 09:44:37 +0100 Subject: [PATCH] srsue,mac: do not destroy active dl_harq_proc during a reconfiguration --- srsue/src/stack/mac_nr/dl_harq_nr.cc | 32 ++++++++++++++++++---------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/srsue/src/stack/mac_nr/dl_harq_nr.cc b/srsue/src/stack/mac_nr/dl_harq_nr.cc index 174fdf26f..377269057 100644 --- a/srsue/src/stack/mac_nr/dl_harq_nr.cc +++ b/srsue/src/stack/mac_nr/dl_harq_nr.cc @@ -26,6 +26,14 @@ dl_harq_entity_nr::dl_harq_entity_nr(uint8_t cc_idx_, // Init broadcast HARQ process bcch_proc.init(-1); pthread_rwlock_init(&rwlock, NULL); + + // Create default number of processes + for (uint32_t i = 0; i < cfg.nof_procs; i++) { + harq_procs[i] = std::unique_ptr(new dl_harq_process_nr(this)); + if (!harq_procs.at(i)->init(i)) { + logger.error("Error while initializing DL-HARQ process %d", i); + } + } } dl_harq_entity_nr::~dl_harq_entity_nr() @@ -42,17 +50,19 @@ int32_t dl_harq_entity_nr::set_config(const srsran::dl_harq_cfg_nr_t& cfg_) return SRSRAN_ERROR; } - // clear old processees - for (auto& proc : harq_procs) { - proc = nullptr; - } - - // Allocate and init configured HARQ processes - for (uint32_t i = 0; i < cfg.nof_procs; i++) { - harq_procs[i] = std::unique_ptr(new dl_harq_process_nr(this)); - if (!harq_procs.at(i)->init(i)) { - logger.error("Error while initializing DL-HARQ process %d", i); - return SRSRAN_ERROR; + if (cfg_.nof_procs < cfg.nof_procs) { + // clear old processes if not needed + for (uint32_t i = cfg.nof_procs - 1; i < cfg_.nof_procs; i++) { + harq_procs[i] = nullptr; + } + } else { + // Add new processes + for (uint32_t i = cfg.nof_procs; i < cfg_.nof_procs; i++) { + harq_procs[i] = std::unique_ptr(new dl_harq_process_nr(this)); + if (!harq_procs.at(i)->init(i)) { + logger.error("Error while initializing DL-HARQ process %d", i); + return SRSRAN_ERROR; + } } }