From ebaab9b1d0a6d4ee56985681b71b5c173fbb4995 Mon Sep 17 00:00:00 2001 From: Carlo Galiotto Date: Fri, 22 Oct 2021 17:42:56 +0200 Subject: [PATCH] rrc,nr: add private fnc to overload public method... ... and propagate input to calling function Signed-off-by: Carlo Galiotto --- srsenb/hdr/stack/rrc/rrc_nr.h | 21 +++------------- srsenb/src/stack/rrc/rrc_nr.cc | 46 ++++++++++++++++------------------ 2 files changed, 26 insertions(+), 41 deletions(-) diff --git a/srsenb/hdr/stack/rrc/rrc_nr.h b/srsenb/hdr/stack/rrc/rrc_nr.h index a8d58937a..a74f2e909 100644 --- a/srsenb/hdr/stack/rrc/rrc_nr.h +++ b/srsenb/hdr/stack/rrc/rrc_nr.h @@ -111,20 +111,8 @@ public: nulltype }; - /// List of results a RRC procedure may produce. - enum class procedure_result_code { - none, - activity_timeout, - error_mme_not_connected, - error_unknown_rnti, - radio_conn_with_ue_lost, - msg3_timeout, - fail_in_radio_interface_proc, - unspecified - }; - /// @param [in] triggered_by_rach: indicates whether the UE is created as part of a RACH process - ue(rrc_nr* parent_, uint16_t rnti_, const sched_nr_ue_cfg_t& uecfg, bool triggered_by_rach = false); + ue(rrc_nr* parent_, uint16_t rnti_, const sched_nr_ue_cfg_t& uecfg, bool triggered_by_rach = true); void send_connection_setup(); void send_dl_ccch(asn1::rrc_nr::dl_ccch_msg_s* dl_dcch_msg); @@ -208,9 +196,6 @@ public: rrc_nr_state_t state = rrc_nr_state_t::RRC_IDLE; uint8_t transaction_id = 0; - /// Connection release result. - procedure_result_code con_release_result = procedure_result_code::none; - // RRC configs for UEs asn1::rrc_nr::cell_group_cfg_s cell_group_cfg; asn1::rrc_nr::radio_bearer_cfg_s radio_bearer_cfg; @@ -254,8 +239,10 @@ private: uint32_t nof_si_messages = 0; - // Private Methods + /// Private Methods void handle_pdu(uint16_t rnti, uint32_t lcid, srsran::unique_byte_buffer_t pdu); + /// This gets called by rrc_nr::sgnb_addition_request and WILL NOT TRIGGER the RX MSG3 activity timer + int add_user(uint16_t rnti, const sched_nr_ue_cfg_t& uecfg, bool triggered_by_rach = false); // logging typedef enum { Rx = 0, Tx } direction_t; diff --git a/srsenb/src/stack/rrc/rrc_nr.cc b/srsenb/src/stack/rrc/rrc_nr.cc index 439bfa6ca..6a666c8ae 100644 --- a/srsenb/src/stack/rrc/rrc_nr.cc +++ b/srsenb/src/stack/rrc/rrc_nr.cc @@ -157,12 +157,15 @@ rrc_nr_cfg_t rrc_nr::update_default_cfg(const rrc_nr_cfg_t& current) return cfg_default; } -// This function is called from PRACH worker (can wait) -int rrc_nr::add_user(uint16_t rnti, const sched_nr_ue_cfg_t& uecfg) +/* @brief PRIVATE function, gets called by sgnb_addition_request + * + * This function WILL NOT TRIGGER the RX MSG3 activity timer + */ +int rrc_nr::add_user(uint16_t rnti, const sched_nr_ue_cfg_t& uecfg, bool triggered_by_rach) { if (users.count(rnti) == 0) { - // in the ue ctor, "triggered_by_rach" is set to true so as to start the MSG3 RX TIMEOUT when we create the ue - users.insert(std::make_pair(rnti, std::unique_ptr(new ue(this, rnti, uecfg, true)))); + // If in the ue ctor, "triggered_by_rach" is set to true, this will start the MSG3 RX TIMEOUT at ue creation + users.insert(std::make_pair(rnti, std::unique_ptr(new ue(this, rnti, uecfg, triggered_by_rach)))); rlc->add_user(rnti); pdcp->add_user(rnti); logger.info("Added new user rnti=0x%x", rnti); @@ -173,6 +176,16 @@ int rrc_nr::add_user(uint16_t rnti, const sched_nr_ue_cfg_t& uecfg) } } +/* @brief PUBLIC function, gets called by mac_nr::rach_detected + * + * This function is called from PRACH worker (can wait) and WILL TRIGGER the RX MSG3 activity timer + */ +int rrc_nr::add_user(uint16_t rnti, const sched_nr_ue_cfg_t& uecfg) +{ + // Set "triggered_by_rach" to true to start the MSG3 RX TIMEOUT + return add_user(rnti, uecfg, true); +} + void rrc_nr::rem_user(uint16_t rnti) { auto user_it = users.find(rnti); @@ -508,7 +521,7 @@ void rrc_nr::sgnb_addition_request(uint16_t eutra_rnti, const sgnb_addition_req_ return; } - if (add_user(nr_rnti, uecfg) != SRSRAN_SUCCESS) { + if (add_user(nr_rnti, uecfg, false) != SRSRAN_SUCCESS) { logger.error("Failed to allocate RNTI at RRC"); rrc_eutra->sgnb_addition_reject(eutra_rnti); return; @@ -583,9 +596,6 @@ void rrc_nr::ue::set_activity_timeout(activity_timeout_type_t type) void rrc_nr::ue::set_activity(bool enabled) { - if (rnti == SRSRAN_MRNTI) { - return; - } if (not enabled) { if (activity_timer.is_running()) { parent->logger.debug("Inactivity timer interrupted for rnti=0x%x", rnti); @@ -603,31 +613,21 @@ void rrc_nr::ue::activity_timer_expired(const activity_timeout_type_t type) { parent->logger.info("Activity timer for rnti=0x%x expired after %d ms", rnti, activity_timer.time_elapsed()); - // TODO: Insert a check to ensure the RNTI exists -#if 0 - if (parent->s1ap->user_exists(rnti)) { -#endif switch (type) { case UE_INACTIVITY_TIMEOUT: // TODO: Add action to be executed break; case MSG3_RX_TIMEOUT: - // MSG3 timeout, no need to notify S1AP, just remove UE + // MSG3 timeout, no need to notify NGAP or LTE stack. Just remove UE parent->rem_user(rnti); - con_release_result = procedure_result_code::msg3_timeout; break; default: // Unhandled activity timeout, just remove UE and log an error parent->rem_user(rnti); - con_release_result = procedure_result_code::activity_timeout; parent->logger.error( "Unhandled reason for activity timer expiration. rnti=0x%x, cause %d", rnti, static_cast(type)); } -#if 0 - } else { - parent->rem_user_thread(rnti); - } -#endif + state = rrc_nr_state_t::RRC_IDLE; } @@ -1374,10 +1374,6 @@ int rrc_nr::ue::handle_sgnb_addition_request(uint16_t eutra_rnti_, const sgnb_ad ack_params.eps_bearer_id = req_params.eps_bearer_id; parent->rrc_eutra->sgnb_addition_ack(eutra_rnti_, ack_params); - // stop activity timer for msg3 - activity_timer.stop(); - parent->logger.debug("SgNB addition req. - Stopping MSG3 activity timer for rnti=0x%x", rnti); - // recognize RNTI as ENDC user endc = true; eutra_rnti = eutra_rnti_; @@ -1391,6 +1387,8 @@ void rrc_nr::ue::crnti_ce_received() if (endc) { // send SgNB addition complete for ENDC users parent->rrc_eutra->sgnb_addition_complete(eutra_rnti, rnti); + + // stop RX MSG3 activity timer on MAC CE RNTI reception activity_timer.stop(); parent->logger.debug("Received MAC CE-RNTI for 0x%x - stopping MSG3 timer", rnti);