From fb75cbaadcc1c2a5b21caf37129024a938729699 Mon Sep 17 00:00:00 2001 From: Carlo Galiotto Date: Thu, 14 Oct 2021 16:15:24 +0200 Subject: [PATCH] rrc: disable MAC bearers when RNTI gets updated When the RRC handles the C-RNTI CE to update the RNTI, all the bearers associated with the new RNTI (that will no longer be used) need to be disabled. This commit implements this. Signed-off-by: Carlo Galiotto --- srsenb/hdr/stack/rrc/rrc_nr.h | 1 + srsenb/src/stack/rrc/rrc_nr.cc | 24 ++++++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/srsenb/hdr/stack/rrc/rrc_nr.h b/srsenb/hdr/stack/rrc/rrc_nr.h index 8f2ff2316..e6fa16b73 100644 --- a/srsenb/hdr/stack/rrc/rrc_nr.h +++ b/srsenb/hdr/stack/rrc/rrc_nr.h @@ -122,6 +122,7 @@ public: // setters int pack_rrc_reconfiguration(); + int deactivate_bearers(); private: rrc_nr* parent = nullptr; diff --git a/srsenb/src/stack/rrc/rrc_nr.cc b/srsenb/src/stack/rrc/rrc_nr.cc index 10e1a6904..c4d62dc1c 100644 --- a/srsenb/src/stack/rrc/rrc_nr.cc +++ b/srsenb/src/stack/rrc/rrc_nr.cc @@ -189,6 +189,8 @@ int rrc_nr::update_user(uint16_t new_rnti, uint16_t old_rnti) // Remove new_rnti auto new_ue_it = users.find(new_rnti); if (new_ue_it != users.end()) { + // There is no need to check the return code, as this function should always return SUCCESS + new_ue_it->second->deactivate_bearers(); task_sched.defer_task([this, new_rnti]() { rem_user(new_rnti); }); } @@ -1496,4 +1498,26 @@ int rrc_nr::ue::add_drb() return SRSRAN_SUCCESS; } +/** + * @brief Deactivate all Bearers (MAC logical channel) for this specific RNTI + * + * The function iterates over the bearers or MAC logical channels and deactivates them by setting each of them to IDLE + * + * @return int SRSRAN_SUCCESS on success (only fails if the called sub-functions assert) + */ +int rrc_nr::ue::deactivate_bearers() +{ + // Iterate over the bearers (MAC LC CH) and set each of them to IDLE + for (auto& ue_bearer : uecfg.ue_bearers) { + ue_bearer.direction = mac_lc_ch_cfg_t::IDLE; + } + + // No need to check the returned value, as the function will return SRSRAN_SUCCESS + parent->mac->ue_cfg(rnti, uecfg); + + // Technically, the only way this function fails is if parent->mac->ue_cfg(rnti, uecfg) asserts + // Should we still return SRSRAN_SUCCESS or can we make it void? + return SRSRAN_SUCCESS; +} + } // namespace srsenb