From 81a466a6417db8497a276700a4322ad6634273eb Mon Sep 17 00:00:00 2001 From: Francisco Paisana Date: Fri, 11 Oct 2019 17:39:30 +0100 Subject: [PATCH] since we moved cell search to the background thread, cell reselection prints a error message that it cannot start. In fact it already started. It is just waiting for the cell search to finish. This PR fixes this --- srsue/hdr/stack/rrc/rrc.h | 2 ++ srsue/hdr/stack/rrc/rrc_procedures.h | 11 +++++++ srsue/src/stack/rrc/rrc.cc | 37 ++++----------------- srsue/src/stack/rrc/rrc_procedures.cc | 47 +++++++++++++++++++++++++++ 4 files changed, 66 insertions(+), 31 deletions(-) diff --git a/srsue/hdr/stack/rrc/rrc.h b/srsue/hdr/stack/rrc/rrc.h index 9a414b6f9..2528a75c0 100644 --- a/srsue/hdr/stack/rrc/rrc.h +++ b/srsue/hdr/stack/rrc/rrc.h @@ -615,6 +615,7 @@ private: class plmn_search_proc; class process_pcch_proc; class go_idle_proc; + class cell_reselection_proc; srslte::proc_t cell_searcher; srslte::proc_t si_acquirer; srslte::proc_t serv_cell_cfg; @@ -623,6 +624,7 @@ private: srslte::proc_t pcch_processor; srslte::proc_t conn_req_proc; srslte::proc_t plmn_searcher; + srslte::proc_t cell_reselector; srslte::callback_list_t callback_list; diff --git a/srsue/hdr/stack/rrc/rrc_procedures.h b/srsue/hdr/stack/rrc/rrc_procedures.h index be3272bfa..6b4a0445a 100644 --- a/srsue/hdr/stack/rrc/rrc_procedures.h +++ b/srsue/hdr/stack/rrc/rrc_procedures.h @@ -205,6 +205,17 @@ private: uint32_t rlc_flush_counter; }; +class rrc::cell_reselection_proc : public srslte::proc_impl_t +{ +public: + srslte::proc_outcome_t init(rrc* rrc_); + srslte::proc_outcome_t step() final; + static const char* name() { return "Cell Reselection"; } + +private: + rrc* rrc_ptr; +}; + } // namespace srsue #endif // SRSLTE_RRC_PROCEDURES_H diff --git a/srsue/src/stack/rrc/rrc.cc b/srsue/src/stack/rrc/rrc.cc index 4cec87702..696c45e1e 100644 --- a/srsue/src/stack/rrc/rrc.cc +++ b/srsue/src/stack/rrc/rrc.cc @@ -1445,40 +1445,15 @@ void rrc::start_cell_reselection() return; } - if (not cell_selector.launch(this)) { - rrc_log->error("Failed to initiate a Cell Selection procedure...\n"); + if (cell_reselector.is_active()) { + // it is already running return; } - rrc_log->info("Cell Reselection - Starting...\n"); - callback_list.defer_task([this]() { - if (cell_selector.run()) { - return srslte::proc_outcome_t::yield; - } - cell_selection_proc ret = cell_selector.pop(); - if (ret.is_error()) { - rrc_log->error("Cell Reselection - Error while selecting a cell\n"); - return srslte::proc_outcome_t::error; - } else { - switch (ret.get_cs_result()) { - case cs_result_t::changed_cell: - // New cell has been selected, start receiving PCCH - mac->pcch_start_rx(); - break; - case cs_result_t::no_cell: - rrc_log->warning("Could not find any cell to camp on\n"); - break; - case cs_result_t::same_cell: - if (!phy->cell_is_camping()) { - rrc_log->warning("Did not reselect cell but serving cell is out-of-sync.\n"); - serving_cell->in_sync = false; - } - break; - } - } - rrc_log->info("Cell Reselection - Finished successfully\n"); - return srslte::proc_outcome_t::success; - }); + if (not cell_reselector.launch(this)) { + rrc_log->error("Failed to initiate a Cell Reselection procedure...\n"); + } + callback_list.defer_proc(cell_reselector); } void rrc::cell_search_completed(const phy_interface_rrc_lte::cell_search_ret_t& cs_ret, diff --git a/srsue/src/stack/rrc/rrc_procedures.cc b/srsue/src/stack/rrc/rrc_procedures.cc index 22259df47..5a677e188 100644 --- a/srsue/src/stack/rrc/rrc_procedures.cc +++ b/srsue/src/stack/rrc/rrc_procedures.cc @@ -826,4 +826,51 @@ proc_outcome_t rrc::go_idle_proc::step() return proc_outcome_t::yield; } +/************************************** + * Cell Reselection procedure + *************************************/ + +proc_outcome_t rrc::cell_reselection_proc::init(srsue::rrc* rrc_) +{ + rrc_ptr = rrc_; + + Info("Cell Reselection - Starting...\n"); + if (not rrc_ptr->cell_selector.launch(rrc_ptr)) { + Error("Failed to initiate a Cell Selection procedure...\n"); + return proc_outcome_t::error; + } + + return proc_outcome_t::yield; +} + +proc_outcome_t rrc::cell_reselection_proc::step() +{ + if (rrc_ptr->cell_selector.run()) { + return srslte::proc_outcome_t::yield; + } + cell_selection_proc ret = rrc_ptr->cell_selector.pop(); + if (ret.is_error()) { + Error("Cell Reselection - Error while selecting a cell\n"); + return srslte::proc_outcome_t::error; + } + + switch (ret.get_cs_result()) { + case cs_result_t::changed_cell: + // New cell has been selected, start receiving PCCH + rrc_ptr->mac->pcch_start_rx(); + break; + case cs_result_t::no_cell: + Warning("Could not find any cell to camp on\n"); + break; + case cs_result_t::same_cell: + if (!rrc_ptr->phy->cell_is_camping()) { + Warning("Did not reselect cell but serving cell is out-of-sync.\n"); + rrc_ptr->serving_cell->in_sync = false; + } + break; + } + Info("Cell Reselection - Finished successfully\n"); + return srslte::proc_outcome_t::success; +} + } // namespace srsue