From 56e947bf27a1fe3f0075da769afe6d778405cc85 Mon Sep 17 00:00:00 2001 From: David Rupprecht Date: Tue, 6 Apr 2021 17:49:04 +0200 Subject: [PATCH] Added functionality for releasing a NR bearer --- .../srsran/interfaces/ue_pdcp_interfaces.h | 1 + lib/include/srsran/upper/pdcp.h | 2 +- srsue/hdr/stack/rrc/rrc_nr.h | 1 + srsue/src/stack/rrc/rrc.cc | 40 ++++--- srsue/src/stack/rrc/rrc_nr.cc | 110 +++++++++++------- 5 files changed, 96 insertions(+), 58 deletions(-) diff --git a/lib/include/srsran/interfaces/ue_pdcp_interfaces.h b/lib/include/srsran/interfaces/ue_pdcp_interfaces.h index fe1f129b4..530fcebf2 100644 --- a/lib/include/srsran/interfaces/ue_pdcp_interfaces.h +++ b/lib/include/srsran/interfaces/ue_pdcp_interfaces.h @@ -26,6 +26,7 @@ public: virtual void reset() = 0; virtual void write_sdu(uint32_t lcid, srsran::unique_byte_buffer_t sdu, int sn = -1) = 0; virtual void add_bearer(uint32_t lcid, srsran::pdcp_config_t cnfg) = 0; + virtual void del_bearer(uint32_t lcid) = 0; virtual void change_lcid(uint32_t old_lcid, uint32_t new_lcid) = 0; virtual void config_security(uint32_t lcid, srsran::as_security_config_t sec_cfg) = 0; virtual void config_security_all(srsran::as_security_config_t sec_cfg) = 0; diff --git a/lib/include/srsran/upper/pdcp.h b/lib/include/srsran/upper/pdcp.h index 962fdb828..d101bf70d 100644 --- a/lib/include/srsran/upper/pdcp.h +++ b/lib/include/srsran/upper/pdcp.h @@ -40,7 +40,7 @@ public: void write_sdu_mch(uint32_t lcid, unique_byte_buffer_t sdu); void add_bearer(uint32_t lcid, pdcp_config_t cnfg) override; void add_bearer_mrb(uint32_t lcid, pdcp_config_t cnfg); - void del_bearer(uint32_t lcid); + void del_bearer(uint32_t lcid) override; void change_lcid(uint32_t old_lcid, uint32_t new_lcid) override; void config_security(uint32_t lcid, as_security_config_t sec_cfg) override; void config_security_all(as_security_config_t sec_cfg) override; diff --git a/srsue/hdr/stack/rrc/rrc_nr.h b/srsue/hdr/stack/rrc/rrc_nr.h index ab17ea081..db269536c 100644 --- a/srsue/hdr/stack/rrc/rrc_nr.h +++ b/srsue/hdr/stack/rrc/rrc_nr.h @@ -207,6 +207,7 @@ private: bool apply_csi_meas_cfg(const asn1::rrc_nr::csi_meas_cfg_s& csi_meas_cfg); bool apply_res_csi_report_cfg(const asn1::rrc_nr::csi_report_cfg_s& csi_report_cfg); bool apply_drb_add_mod(const asn1::rrc_nr::drb_to_add_mod_s& drb_cfg); + bool apply_drb_release(const uint8_t drb); bool apply_security_cfg(const asn1::rrc_nr::security_cfg_s& security_cfg); srsran::as_security_config_t sec_cfg; diff --git a/srsue/src/stack/rrc/rrc.cc b/srsue/src/stack/rrc/rrc.cc index b94d93083..42f056cb8 100644 --- a/srsue/src/stack/rrc/rrc.cc +++ b/srsue/src/stack/rrc/rrc.cc @@ -777,13 +777,21 @@ bool rrc::nr_reconfiguration_proc(const rrc_conn_recfg_r8_ies_s& rx_recfg, bool bool nr_radio_bearer_cfg1_r15_present = false; asn1::dyn_octstring nr_radio_bearer_cfg1_r15; - endc_release_and_add_r15 = rrc_conn_recfg_v1510_ies->nr_cfg_r15.setup().endc_release_and_add_r15; - - if (rrc_conn_recfg_v1510_ies->nr_cfg_r15.setup().nr_secondary_cell_group_cfg_r15_present == true) { - nr_secondary_cell_group_cfg_r15_present = true; - nr_secondary_cell_group_cfg_r15 = rrc_conn_recfg_v1510_ies->nr_cfg_r15.setup().nr_secondary_cell_group_cfg_r15; + switch (rrc_conn_recfg_v1510_ies->nr_cfg_r15.type()) { + case setup_opts::options::release: + logger.info("NR config R15 of type release"); + break; + case setup_opts::options::setup: + endc_release_and_add_r15 = rrc_conn_recfg_v1510_ies->nr_cfg_r15.setup().endc_release_and_add_r15; + if (rrc_conn_recfg_v1510_ies->nr_cfg_r15.setup().nr_secondary_cell_group_cfg_r15_present) { + nr_secondary_cell_group_cfg_r15_present = true; + nr_secondary_cell_group_cfg_r15 = rrc_conn_recfg_v1510_ies->nr_cfg_r15.setup().nr_secondary_cell_group_cfg_r15; + } + break; + default: + logger.error("NR config R15 type not defined"); + break; } - if (rrc_conn_recfg_v1510_ies->sk_counter_r15_present) { sk_counter_r15_present = true; sk_counter_r15 = rrc_conn_recfg_v1510_ies->sk_counter_r15; @@ -793,14 +801,14 @@ bool rrc::nr_reconfiguration_proc(const rrc_conn_recfg_r8_ies_s& rx_recfg, bool nr_radio_bearer_cfg1_r15_present = true; nr_radio_bearer_cfg1_r15 = rrc_conn_recfg_v1510_ies->nr_radio_bearer_cfg1_r15; } - *has_5g_nr_reconfig = true; - return rrc_nr->rrc_reconfiguration(endc_release_and_add_r15, - nr_secondary_cell_group_cfg_r15_present, - nr_secondary_cell_group_cfg_r15, - sk_counter_r15_present, - sk_counter_r15, - nr_radio_bearer_cfg1_r15_present, - nr_radio_bearer_cfg1_r15); + *has_5g_nr_reconfig = true; + return rrc_nr->rrc_reconfiguration(endc_release_and_add_r15, + nr_secondary_cell_group_cfg_r15_present, + nr_secondary_cell_group_cfg_r15, + sk_counter_r15_present, + sk_counter_r15, + nr_radio_bearer_cfg1_r15_present, + nr_radio_bearer_cfg1_r15); } /******************************************************************************* * @@ -2641,6 +2649,10 @@ void rrc::add_drb(const drb_to_add_mod_s& drb_cnfg) drbs[drb_cnfg.drb_id] = drb_cnfg; drb_up = true; logger.info("Added DRB Id %d (LCID=%d)", drb_cnfg.drb_id, lcid); + // Update LCID if gw is running + if(gw->is_running()){ + gw->update_lcid(drb_cnfg.eps_bearer_id, lcid); + } } void rrc::release_drb(uint32_t drb_id) diff --git a/srsue/src/stack/rrc/rrc_nr.cc b/srsue/src/stack/rrc/rrc_nr.cc index fed9f3ce5..5ce963306 100644 --- a/srsue/src/stack/rrc/rrc_nr.cc +++ b/srsue/src/stack/rrc/rrc_nr.cc @@ -330,7 +330,7 @@ bool rrc_nr::rrc_reconfiguration(bool endc_release_and_add_r15, bool sk_counter_r15_present, uint32_t sk_counter_r15, bool nr_radio_bearer_cfg1_r15_present, - asn1::dyn_octstring nr_radio_bearer_cfg1_r15) + asn1::dyn_octstring nr_radio_bearer_cfg1_r15) { if (not conn_recfg_proc.launch(reconf_initiator_t::mcg_srb1, endc_release_and_add_r15, @@ -1068,6 +1068,22 @@ bool rrc_nr::apply_cell_group_cfg(const cell_group_cfg_s& cell_group_cfg) return true; } +bool rrc_nr::apply_drb_release(const uint8_t drb) +{ + uint32_t lcid = get_lcid_for_rbid(drb); + if(lcid == 0){ + logger.warning("Can not release bearer with lcid %d and drb %d", lcid, drb); + return false; + } + logger.info("Releasing bearer DRB: %d LCID: %d", drb, lcid); + pdcp->del_bearer(lcid); + // TODO + // 2> if the UE is operating in EN-DC + // 3> if a new bearer is not added either with NR or E-UTRA with same eps-BearerIdentity: + // 4> indicate the release of the DRB and the eps-BearerIdentity of the released DRB to upper layers. + return true; +} + bool rrc_nr::apply_drb_add_mod(const drb_to_add_mod_s& drb_cfg) { if (!drb_cfg.pdcp_cfg_present) { @@ -1178,6 +1194,13 @@ bool rrc_nr::apply_radio_bearer_cfg(const radio_bearer_cfg_s& radio_bearer_cfg) } } } + if (radio_bearer_cfg.drb_to_release_list_present) { + for (uint32_t i = 0; i < radio_bearer_cfg.drb_to_release_list.size(); i++) { + if (apply_drb_release(radio_bearer_cfg.drb_to_release_list[i]) == false) { + return false; + } + } + } if (radio_bearer_cfg.security_cfg_present) { if (apply_security_cfg(radio_bearer_cfg.security_cfg) == false) { return false; @@ -1221,45 +1244,56 @@ proc_outcome_t rrc_nr::connection_reconf_no_ho_proc::init(const reconf_initiator radio_bearer_cfg_s radio_bearer_cfg; asn1::SRSASN_CODE err; - if (nr_secondary_cell_group_cfg_r15_present == false || sk_counter_r15_present == false || - nr_radio_bearer_cfg1_r15_present == false) { - Error("RRC NR Reconfiguration failed sanity check failed"); - return proc_outcome_t::error; - } + if (nr_secondary_cell_group_cfg_r15_present) { + cbit_ref bref(nr_secondary_cell_group_cfg_r15.data(), nr_secondary_cell_group_cfg_r15.size()); + err = rrc_recfg.unpack(bref); + if (err != asn1::SRSASN_SUCCESS) { + Error("Could not unpack NR reconfiguration message."); + return proc_outcome_t::error; + } - cbit_ref bref(nr_secondary_cell_group_cfg_r15.data(), nr_secondary_cell_group_cfg_r15.size()); + rrc_ptr->log_rrc_message( + "RRC NR Reconfiguration", Rx, nr_secondary_cell_group_cfg_r15, rrc_recfg, "NR Secondary Cell Group Cfg R15"); - err = rrc_recfg.unpack(bref); - if (err != asn1::SRSASN_SUCCESS) { - Error("Could not unpack NR reconfiguration message."); - return proc_outcome_t::error; - } + if (rrc_recfg.crit_exts.type() != asn1::rrc_nr::rrc_recfg_s::crit_exts_c_::types::rrc_recfg) { + Error("Reconfiguration does not contain Secondary Cell Group Config"); + return proc_outcome_t::error; + } + + if (not rrc_recfg.crit_exts.rrc_recfg().secondary_cell_group_present) { + Error("Reconfiguration does not contain Secondary Cell Group Config"); + return proc_outcome_t::error; + } - rrc_ptr->log_rrc_message( - "RRC NR Reconfiguration", Rx, nr_secondary_cell_group_cfg_r15, rrc_recfg, "NR Secondary Cell Group Cfg R15"); + cbit_ref bref0(rrc_recfg.crit_exts.rrc_recfg().secondary_cell_group.data(), + rrc_recfg.crit_exts.rrc_recfg().secondary_cell_group.size()); - if (rrc_recfg.crit_exts.type() == asn1::rrc_nr::rrc_recfg_s::crit_exts_c_::types::rrc_recfg) { - if (rrc_recfg.crit_exts.rrc_recfg().secondary_cell_group_present == true) { - cbit_ref bref0(rrc_recfg.crit_exts.rrc_recfg().secondary_cell_group.data(), - rrc_recfg.crit_exts.rrc_recfg().secondary_cell_group.size()); + err = cell_group_cfg.unpack(bref0); + if (err != asn1::SRSASN_SUCCESS) { + Error("Could not unpack cell group message message."); + return proc_outcome_t::error; + } - err = cell_group_cfg.unpack(bref0); - if (err != asn1::SRSASN_SUCCESS) { - Error("Could not unpack cell group message message."); - return proc_outcome_t::error; - } + rrc_ptr->log_rrc_message("RRC NR Reconfiguration", + Rx, + rrc_recfg.crit_exts.rrc_recfg().secondary_cell_group, + cell_group_cfg, + "Secondary Cell Group Config"); - rrc_ptr->log_rrc_message("RRC NRf Reconfiguration", - Rx, - rrc_recfg.crit_exts.rrc_recfg().secondary_cell_group, - cell_group_cfg, - "Secondary Cell Group Config"); - } else { - Error("Reconfiguration does not contain Secondary Cell Group Config"); + Info("Applying Cell Group Cfg"); + if (!rrc_ptr->apply_cell_group_cfg(cell_group_cfg)) { + return proc_outcome_t::error; + } + } + + if (sk_counter_r15_present) { + Info("Applying Cell Group Cfg"); + if (!rrc_ptr->configure_sk_counter((uint16_t)sk_counter_r15)) { return proc_outcome_t::error; } } + if(nr_radio_bearer_cfg1_r15_present){ cbit_ref bref1(nr_radio_bearer_cfg1_r15.data(), nr_radio_bearer_cfg1_r15.size()); err = radio_bearer_cfg.unpack(bref1); @@ -1271,22 +1305,12 @@ proc_outcome_t rrc_nr::connection_reconf_no_ho_proc::init(const reconf_initiator rrc_ptr->log_rrc_message( "RRC NR Reconfiguration", Rx, nr_radio_bearer_cfg1_r15, radio_bearer_cfg, "Radio Bearer Config R15"); - Info("Applying Cell Group Cfg"); - if (!rrc_ptr->apply_cell_group_cfg(cell_group_cfg)) { - return proc_outcome_t::error; - } - - if (sk_counter_r15_present) { - Info("Applying Cell Group Cfg"); - if (!rrc_ptr->configure_sk_counter((uint16_t)sk_counter_r15)) { - return proc_outcome_t::error; - } - } - Info("Applying Radio Bearer Cfg"); if (!rrc_ptr->apply_radio_bearer_cfg(radio_bearer_cfg)) { return proc_outcome_t::error; } + } + return proc_outcome_t::success; } @@ -1302,7 +1326,7 @@ proc_outcome_t rrc_nr::connection_reconf_no_ho_proc::react(const bool& config_co // if (not rrc_ptr->phy_ctrl->is_config_pending()) { // return proc_outcome_t::yield; // } - + Info("Reconfig NR return successful"); return proc_outcome_t::success; }