diff --git a/srsue/hdr/stack/rrc/rrc.h b/srsue/hdr/stack/rrc/rrc.h index 48a168974..003c6cb70 100644 --- a/srsue/hdr/stack/rrc/rrc.h +++ b/srsue/hdr/stack/rrc/rrc.h @@ -282,6 +282,7 @@ private: class si_acquire_proc; class serving_cell_config_proc; class cell_selection_proc; + class connection_setup_proc; class connection_request_proc; class connection_reconf_no_ho_proc; class plmn_search_proc; @@ -297,6 +298,7 @@ private: srsran::proc_t idle_setter; srsran::proc_t pcch_processor; srsran::proc_t conn_req_proc; + srsran::proc_t conn_setup_proc; srsran::proc_t plmn_searcher; srsran::proc_t cell_reselector; srsran::proc_t connection_reest; diff --git a/srsue/hdr/stack/rrc/rrc_procedures.h b/srsue/hdr/stack/rrc/rrc_procedures.h index 71a399f9c..20e1c5646 100644 --- a/srsue/hdr/stack/rrc/rrc_procedures.h +++ b/srsue/hdr/stack/rrc/rrc_procedures.h @@ -193,6 +193,24 @@ private: srsran::proc_future_t serv_cfg_fut; }; +class rrc::connection_setup_proc +{ +public: + explicit connection_setup_proc(rrc* parent_); + srsran::proc_outcome_t init(const asn1::rrc::rr_cfg_ded_s* cnfg_, srsran::unique_byte_buffer_t dedicated_info_nas_); + srsran::proc_outcome_t step() { return srsran::proc_outcome_t::yield; } + void then(const srsran::proc_state_t& result); + srsran::proc_outcome_t react(const bool& config_complete); + static const char* name() { return "Connection Setup"; } + +private: + // const + rrc* rrc_ptr; + srslog::basic_logger& logger; + // args + srsran::unique_byte_buffer_t dedicated_info_nas; +}; + class rrc::connection_reconf_no_ho_proc { public: diff --git a/srsue/src/stack/rrc/rrc.cc b/srsue/src/stack/rrc/rrc.cc index 39f69d6eb..928547935 100644 --- a/srsue/src/stack/rrc/rrc.cc +++ b/srsue/src/stack/rrc/rrc.cc @@ -66,6 +66,7 @@ rrc::rrc(stack_interface_rrc* stack_, srsran::task_sched_handle task_sched_) : plmn_searcher(this), cell_reselector(this), connection_reest(this), + conn_setup_proc(this), ho_handler(this), conn_recfg_proc(this), meas_cells_nr(task_sched_), @@ -364,6 +365,9 @@ void rrc::set_config_complete(bool status) { // Signal Reconfiguration Procedure that PHY configuration has completed phy_ctrl->set_config_complete(); + if (conn_setup_proc.is_busy()) { + conn_setup_proc.trigger(status); + } if (conn_recfg_proc.is_busy()) { conn_recfg_proc.trigger(status); } @@ -2538,16 +2542,12 @@ void rrc::handle_con_setup(const rrc_conn_setup_s& setup) t302.stop(); srsran::console("RRC Connected\n"); - // Apply the Radio Resource configuration - apply_rr_config_dedicated(&setup.crit_exts.c1().rrc_conn_setup_r8().rr_cfg_ded); - - nas->set_barring(srsran::barring_t::none); - - if (dedicated_info_nas.get()) { - send_con_setup_complete(std::move(dedicated_info_nas)); - } else { - logger.error("Pending to transmit a ConnectionSetupComplete but no dedicatedInfoNAS was in queue"); + // defer transmission of Setup Complete until PHY reconfiguration has been completed + if (not conn_setup_proc.launch(&setup.crit_exts.c1().rrc_conn_setup_r8().rr_cfg_ded, std::move(dedicated_info_nas))) { + logger.error("Failed to initiate connection setup procedure"); + return; } + callback_list.add_proc(conn_setup_proc); } /* Reception of RRCConnectionReestablishment by the UE 5.3.7.5 */ diff --git a/srsue/src/stack/rrc/rrc_procedures.cc b/srsue/src/stack/rrc/rrc_procedures.cc index 870246320..47f9daabb 100644 --- a/srsue/src/stack/rrc/rrc_procedures.cc +++ b/srsue/src/stack/rrc/rrc_procedures.cc @@ -934,6 +934,60 @@ srsran::proc_outcome_t rrc::connection_request_proc::react(const cell_selection_ } } +/****************************************** + * Connection Setup Procedure + *****************************************/ + +// Simple procedure mainly do defer the transmission of the SetupComplete until all PHY reconfiguration are done +rrc::connection_setup_proc::connection_setup_proc(srsue::rrc* parent_) : + rrc_ptr(parent_), logger(srslog::fetch_basic_logger("RRC")) +{} + +srsran::proc_outcome_t rrc::connection_setup_proc::init(const asn1::rrc::rr_cfg_ded_s* cnfg_, + srsran::unique_byte_buffer_t dedicated_info_nas_) +{ + Info("Starting..."); + + if (dedicated_info_nas_.get() == nullptr) { + rrc_ptr->logger.error("Connection Setup Failed, no dedicatedInfoNAS available"); + return proc_outcome_t::error; + } + + dedicated_info_nas = std::move(dedicated_info_nas_); + + // Apply the Radio Resource configuration + if (!rrc_ptr->apply_rr_config_dedicated(cnfg_)) { + return proc_outcome_t::error; + } + + rrc_ptr->nas->set_barring(srsran::barring_t::none); + + // No phy config was scheduled, run config completion immediately + if (rrc_ptr->phy_ctrl->is_config_pending()) { + return react(true); + } + return proc_outcome_t::yield; +} + +srsran::proc_outcome_t rrc::connection_setup_proc::react(const bool& config_complete) +{ + if (not config_complete) { + rrc_ptr->logger.error("Connection Setup Failed"); + return proc_outcome_t::error; + } + + rrc_ptr->send_con_setup_complete(std::move(dedicated_info_nas)); + return proc_outcome_t::success; +} + +void rrc::connection_setup_proc::then(const srsran::proc_state_t& result) +{ + if (result.is_success()) { + rrc_ptr->logger.info("Finished %s successfully", name()); + return; + } +} + /****************************************** * Connection Reconfiguration Procedure *****************************************/