diff --git a/srsenb/hdr/stack/rrc/rrc_ue.h b/srsenb/hdr/stack/rrc/rrc_ue.h index f75217e72..a3429fee9 100644 --- a/srsenb/hdr/stack/rrc/rrc_ue.h +++ b/srsenb/hdr/stack/rrc/rrc_ue.h @@ -53,9 +53,8 @@ public: void send_connection_reject(); void send_connection_release(); void send_connection_reest_rej(); - void send_connection_reconf(srslte::unique_byte_buffer_t sdu); + void send_connection_reconf(srslte::unique_byte_buffer_t sdu = {}); void send_connection_reconf_new_bearer(); - void send_connection_reconf_upd(srslte::unique_byte_buffer_t pdu); void send_security_mode_command(); void send_ue_cap_enquiry(); void parse_ul_dcch(uint32_t lcid, srslte::unique_byte_buffer_t pdu); @@ -106,9 +105,8 @@ private: srslte::byte_buffer_pool* pool = nullptr; srslte::timer_handler::unique_timer activity_timer; - // cached for ease of context transfer - asn1::rrc::rrc_conn_recfg_s last_rrc_conn_recfg; - asn1::rrc::rr_cfg_ded_s current_rr_cfg; + /// cached for ease of context transfer + asn1::rrc::rr_cfg_ded_s current_rr_cfg; asn1::rrc::establishment_cause_e establishment_cause; diff --git a/srsenb/hdr/stack/rrc/ue_rr_cfg.h b/srsenb/hdr/stack/rrc/ue_rr_cfg.h index c8a41e36f..0919836e6 100644 --- a/srsenb/hdr/stack/rrc/ue_rr_cfg.h +++ b/srsenb/hdr/stack/rrc/ue_rr_cfg.h @@ -38,14 +38,13 @@ void fill_rr_cfg_ded_setup(asn1::rrc::rr_cfg_ded_s& rr_cfg, const cell_ctxt_dedicated_list& ue_cell_list); /// Fill RadioResourceConfigDedicated with RRCReconf data -enum class reconf_cause { init, reest, crnti_ce, handover, other }; void fill_rr_cfg_ded_reconf(asn1::rrc::rr_cfg_ded_s& rr_cfg, const asn1::rrc::rr_cfg_ded_s& current_rr_cfg, const rrc_cfg_t& enb_cfg, const cell_ctxt_dedicated_list& ue_cell_list, const bearer_cfg_handler& bearers, const srslte::rrc_ue_capabilities_t& ue_caps, - reconf_cause cause); + bool phy_cfg_updated); void apply_rr_cfg_ded_diff(asn1::rrc::rr_cfg_ded_s& current_rr_cfg_ded, const asn1::rrc::rr_cfg_ded_s& pending_rr_cfg_ded); diff --git a/srsenb/src/stack/rrc/rrc.cc b/srsenb/src/stack/rrc/rrc.cc index cbe63084e..179cf246e 100644 --- a/srsenb/src/stack/rrc/rrc.cc +++ b/srsenb/src/stack/rrc/rrc.cc @@ -83,7 +83,7 @@ void rrc::init(const rrc_cfg_t& cfg_, rrc_log->info("T310 %d, T311 %d, N310 %d \n", t310, t311, n310); if (cfg.inactivity_timeout_ms < t310 + t311 + n310) { srslte::console("\nWarning: Inactivity timeout is smaller than the sum of t310, t311 and n310.\n" - "This may break the UE's re-establishment procedure.\n"); + "This may break the UE's re-establishment procedure.\n"); rrc_log->warning("Inactivity timeout is smaller than the sum of t310, t311 and n310. This may break the UE's " "re-establishment procedure.\n"); } @@ -203,7 +203,7 @@ void rrc::upd_user(uint16_t new_rnti, uint16_t old_rnti) if (ue_ptr->mobility_handler->is_ho_running()) { ue_ptr->mobility_handler->trigger(ue::rrc_mobility::user_crnti_upd_ev{old_rnti, new_rnti}); } else if (ue_ptr->is_connected()) { - old_it->second->send_connection_reconf_upd(srslte::allocate_unique_buffer(*pool)); + old_it->second->send_connection_reconf(); } else { old_it->second->send_connection_reject(); } diff --git a/srsenb/src/stack/rrc/rrc_mobility.cc b/srsenb/src/stack/rrc/rrc_mobility.cc index 042e44772..5683230c2 100644 --- a/srsenb/src/stack/rrc/rrc_mobility.cc +++ b/srsenb/src/stack/rrc/rrc_mobility.cc @@ -725,7 +725,7 @@ bool rrc::ue::rrc_mobility::start_ho_preparation(uint32_t target_eci, rrc_ue->cell_ded_list, rrc_ue->bearer_list, rrc_ue->ue_capabilities, - reconf_cause::handover); + true); // Get security cfg hoprep_r8.as_cfg.source_security_algorithm_cfg = rrc_ue->ue_security_cfg.get_security_algorithm_cfg(); hoprep_r8.as_cfg.source_ue_id.from_number(rrc_ue->rnti); diff --git a/srsenb/src/stack/rrc/rrc_ue.cc b/srsenb/src/stack/rrc/rrc_ue.cc index c2d408dcc..87c3f2333 100644 --- a/srsenb/src/stack/rrc/rrc_ue.cc +++ b/srsenb/src/stack/rrc/rrc_ue.cc @@ -468,20 +468,16 @@ void rrc::ue::send_connection_reconf(srslte::unique_byte_buffer_t pdu) { parent->rrc_log->debug("RRC state %d\n", state); + /* Create RRCConnectionReconfiguration ASN1 message */ dl_dcch_msg_s dl_dcch_msg; - rrc_conn_recfg_s& recfg = dl_dcch_msg.msg.set_c1().set_rrc_conn_recfg(); - recfg.rrc_transaction_id = (uint8_t)((transaction_id++) % 4); - rrc_conn_recfg_r8_ies_s& recfg_r8 = recfg.crit_exts.set_c1().set_rrc_conn_recfg_r8(); + rrc_conn_recfg_s& rrc_conn_recfg = dl_dcch_msg.msg.set_c1().set_rrc_conn_recfg(); + rrc_conn_recfg.rrc_transaction_id = (uint8_t)((transaction_id++) % 4); + rrc_conn_recfg_r8_ies_s& recfg_r8 = rrc_conn_recfg.crit_exts.set_c1().set_rrc_conn_recfg_r8(); // Fill RR Config Ded - fill_rr_cfg_ded_reconf(recfg_r8.rr_cfg_ded, - current_rr_cfg, - parent->cfg, - cell_ded_list, - bearer_list, - ue_capabilities, - reconf_cause::init); recfg_r8.rr_cfg_ded_present = true; + fill_rr_cfg_ded_reconf( + recfg_r8.rr_cfg_ded, current_rr_cfg, parent->cfg, cell_ded_list, bearer_list, ue_capabilities, true); // Add SCells if (fill_scell_to_addmod_list(&recfg_r8) != SRSLTE_SUCCESS) { @@ -489,106 +485,44 @@ void rrc::ue::send_connection_reconf(srslte::unique_byte_buffer_t pdu) return; } - apply_reconf_phy_config(recfg_r8, true); - - // setup SRB2/DRBs in PDCP and RLC - apply_pdcp_srb_updates(recfg_r8.rr_cfg_ded); - apply_pdcp_drb_updates(recfg_r8.rr_cfg_ded); - apply_rlc_rb_updates(recfg_r8.rr_cfg_ded); - // Add pending NAS info bearer_list.fill_pending_nas_info(&recfg_r8); + // Add measConfig if (mobility_handler != nullptr) { mobility_handler->fill_conn_recfg_no_ho_cmd(&recfg_r8); } - last_rrc_conn_recfg = dl_dcch_msg.msg.c1().rrc_conn_recfg(); - // Apply Reconf Msg configuration to MAC scheduler - mac_ctrl->handle_con_reconf(recfg_r8); - - // If reconf due to reestablishment, recover PDCP state - if (state == RRC_STATE_REESTABLISHMENT_COMPLETE) { - for (const auto& erab_pair : bearer_list.get_erabs()) { - uint16_t lcid = erab_pair.second.id - 2; - bool is_am = parent->cfg.qci_cfg[erab_pair.second.qos_params.qci].rlc_cfg.type().value == - asn1::rrc::rlc_cfg_c::types_opts::am; - if (is_am) { - parent->rrc_log->debug("Set PDCP state: TX HFN %d, NEXT_PDCP_TX_SN %d, RX_HFN %d, NEXT_PDCP_RX_SN %d, " - "LAST_SUBMITTED_PDCP_RX_SN %d\n", - old_reest_pdcp_state[lcid].tx_hfn, - old_reest_pdcp_state[lcid].next_pdcp_tx_sn, - old_reest_pdcp_state[lcid].rx_hfn, - old_reest_pdcp_state[lcid].next_pdcp_rx_sn, - old_reest_pdcp_state[lcid].last_submitted_pdcp_rx_sn); - parent->pdcp->set_bearer_state(rnti, lcid, old_reest_pdcp_state[lcid]); - } - } + // if no updates were detected, skip rrc reconfiguration + if (not(recfg_r8.rr_cfg_ded_present or recfg_r8.meas_cfg_present or recfg_r8.mob_ctrl_info_present or + recfg_r8.ded_info_nas_list_present or recfg_r8.security_cfg_ho_present or recfg_r8.non_crit_ext_present)) { + return; } - // Reuse same PDU - pdu->clear(); - - send_dl_dcch(&dl_dcch_msg, std::move(pdu)); + /* Apply updates present in RRCConnectionReconfiguration to lower layers */ + // apply PHY config + apply_reconf_phy_config(recfg_r8, true); - state = RRC_STATE_WAIT_FOR_CON_RECONF_COMPLETE; + // setup SRB2/DRBs in PDCP and RLC + apply_pdcp_srb_updates(recfg_r8.rr_cfg_ded); + apply_pdcp_drb_updates(recfg_r8.rr_cfg_ded); + apply_rlc_rb_updates(recfg_r8.rr_cfg_ded); - apply_rr_cfg_ded_diff(current_rr_cfg, recfg_r8.rr_cfg_ded); -} + // UE MAC scheduler updates + mac_ctrl->handle_con_reconf(recfg_r8); -void rrc::ue::send_connection_reconf_upd(srslte::unique_byte_buffer_t pdu) -{ - dl_dcch_msg_s dl_dcch_msg; - rrc_conn_recfg_s* rrc_conn_recfg = &dl_dcch_msg.msg.set_c1().set_rrc_conn_recfg(); - rrc_conn_recfg->rrc_transaction_id = (uint8_t)((transaction_id++) % 4); - rrc_conn_recfg_r8_ies_s& reconfig_r8 = rrc_conn_recfg->crit_exts.set_c1().set_rrc_conn_recfg_r8(); - - reconfig_r8.rr_cfg_ded_present = true; - rr_cfg_ded_s* rr_cfg = &reconfig_r8.rr_cfg_ded; - - rr_cfg->phys_cfg_ded_present = true; - phys_cfg_ded_s* phy_cfg = &rr_cfg->phys_cfg_ded; - phy_cfg->sched_request_cfg_present = true; - phy_cfg->sched_request_cfg.set_setup(); - phy_cfg->sched_request_cfg.setup().dsr_trans_max = parent->cfg.sr_cfg.dsr_max; - - phy_cfg->cqi_report_cfg_present = true; - if (cell_ded_list.nof_cells() > 0) { - phy_cfg->cqi_report_cfg.cqi_report_periodic_present = true; - phy_cfg->cqi_report_cfg.cqi_report_periodic.set_setup().cqi_format_ind_periodic.set( - cqi_report_periodic_c::setup_s_::cqi_format_ind_periodic_c_::types::wideband_cqi); - get_cqi(&phy_cfg->cqi_report_cfg.cqi_report_periodic.setup().cqi_pmi_cfg_idx, - &phy_cfg->cqi_report_cfg.cqi_report_periodic.setup().cqi_pucch_res_idx, - UE_PCELL_CC_IDX); - phy_cfg->cqi_report_cfg.cqi_report_periodic.setup().simul_ack_nack_and_cqi = parent->cfg.cqi_cfg.simultaneousAckCQI; - if (parent->cfg.antenna_info.tx_mode == ant_info_ded_s::tx_mode_e_::tm3 || - parent->cfg.antenna_info.tx_mode == ant_info_ded_s::tx_mode_e_::tm4) { - phy_cfg->cqi_report_cfg.cqi_report_periodic.setup().ri_cfg_idx_present = true; - phy_cfg->cqi_report_cfg.cqi_report_periodic.setup().ri_cfg_idx = 483; /* TODO: HARDCODED! Add to UL scheduler */ - } else { - phy_cfg->cqi_report_cfg.cqi_report_periodic.setup().ri_cfg_idx_present = false; - } - } else { - phy_cfg->cqi_report_cfg.cqi_report_mode_aperiodic_present = true; - if (phy_cfg->ant_info_present && parent->cfg.antenna_info.tx_mode == ant_info_ded_s::tx_mode_e_::tm4) { - phy_cfg->cqi_report_cfg.cqi_report_mode_aperiodic = cqi_report_mode_aperiodic_e::rm31; - } else { - phy_cfg->cqi_report_cfg.cqi_report_mode_aperiodic = cqi_report_mode_aperiodic_e::rm30; - } + // Reuse same PDU + if (pdu != nullptr) { + pdu->clear(); } - apply_reconf_phy_config(reconfig_r8, true); - - phy_cfg->sched_request_cfg.setup().sr_cfg_idx = cell_ded_list.get_sr_res()->sr_I; - phy_cfg->sched_request_cfg.setup().sr_pucch_res_idx = cell_ded_list.get_sr_res()->sr_N_pucch; - - // Apply Reconf Msg configuration to MAC scheduler - mac_ctrl->handle_con_reconf(reconfig_r8); - - pdu->clear(); + // send DL-DCCH message to lower layers send_dl_dcch(&dl_dcch_msg, std::move(pdu)); state = RRC_STATE_WAIT_FOR_CON_RECONF_COMPLETE; + + // Update UE current RadioResourceConfiguration + apply_rr_cfg_ded_diff(current_rr_cfg, recfg_r8.rr_cfg_ded); } void rrc::ue::send_connection_reconf_new_bearer() @@ -598,13 +532,8 @@ void rrc::ue::send_connection_reconf_new_bearer() dl_dcch_msg.msg.c1().rrc_conn_recfg().rrc_transaction_id = (uint8_t)((transaction_id++) % 4); rrc_conn_recfg_r8_ies_s* conn_reconf = &dl_dcch_msg.msg.c1().rrc_conn_recfg().crit_exts.c1().rrc_conn_recfg_r8(); - fill_rr_cfg_ded_reconf(conn_reconf->rr_cfg_ded, - current_rr_cfg, - parent->cfg, - cell_ded_list, - bearer_list, - ue_capabilities, - reconf_cause::other); + fill_rr_cfg_ded_reconf( + conn_reconf->rr_cfg_ded, current_rr_cfg, parent->cfg, cell_ded_list, bearer_list, ue_capabilities, false); // Setup new bearer apply_pdcp_srb_updates(conn_reconf->rr_cfg_ded); @@ -625,17 +554,18 @@ void rrc::ue::handle_rrc_reconf_complete(rrc_conn_recfg_complete_s* msg, srslte: // Inform PHY about the configuration completion parent->phy->complete_config(rnti); - if (last_rrc_conn_recfg.rrc_transaction_id == msg->rrc_transaction_id) { - // Activate SCells and bearers in the MAC scheduler that were advertised in the RRC Reconf message - mac_ctrl->handle_con_reconf_complete(); - - // If performing handover, signal its completion - mobility_handler->trigger(*msg); - } else { + if (transaction_id != msg->rrc_transaction_id) { parent->rrc_log->error("Expected RRCReconfigurationComplete with transaction ID: %d, got %d\n", - last_rrc_conn_recfg.rrc_transaction_id, + transaction_id, msg->rrc_transaction_id); + return; } + + // Activate SCells and bearers in the MAC scheduler that were advertised in the RRC Reconf message + mac_ctrl->handle_con_reconf_complete(); + + // If performing handover, signal its completion + mobility_handler->trigger(*msg); } /* @@ -1327,6 +1257,25 @@ void rrc::ue::apply_pdcp_drb_updates(const rr_cfg_ded_s& pending_rr_cfg) parent->pdcp->enable_encryption(rnti, drb.lc_ch_id); } } + + // If reconf due to reestablishment, recover PDCP state + if (state == RRC_STATE_REESTABLISHMENT_COMPLETE) { + for (const auto& erab_pair : bearer_list.get_erabs()) { + uint16_t lcid = erab_pair.second.id - 2; + bool is_am = parent->cfg.qci_cfg[erab_pair.second.qos_params.qci].rlc_cfg.type().value == + asn1::rrc::rlc_cfg_c::types_opts::am; + if (is_am) { + parent->rrc_log->debug("Set PDCP state: TX HFN %d, NEXT_PDCP_TX_SN %d, RX_HFN %d, NEXT_PDCP_RX_SN %d, " + "LAST_SUBMITTED_PDCP_RX_SN %d\n", + old_reest_pdcp_state[lcid].tx_hfn, + old_reest_pdcp_state[lcid].next_pdcp_tx_sn, + old_reest_pdcp_state[lcid].rx_hfn, + old_reest_pdcp_state[lcid].next_pdcp_rx_sn, + old_reest_pdcp_state[lcid].last_submitted_pdcp_rx_sn); + parent->pdcp->set_bearer_state(rnti, lcid, old_reest_pdcp_state[lcid]); + } + } + } } void rrc::ue::apply_rlc_rb_updates(const rr_cfg_ded_s& pending_rr_cfg) diff --git a/srsenb/src/stack/rrc/ue_rr_cfg.cc b/srsenb/src/stack/rrc/ue_rr_cfg.cc index 00411a709..8bd549ff4 100644 --- a/srsenb/src/stack/rrc/ue_rr_cfg.cc +++ b/srsenb/src/stack/rrc/ue_rr_cfg.cc @@ -327,7 +327,7 @@ void fill_rr_cfg_ded_reconf(asn1::rrc::rr_cfg_ded_s& rr_cfg, const cell_ctxt_dedicated_list& ue_cell_list, const bearer_cfg_handler& bearers, const srslte::rrc_ue_capabilities_t& ue_caps, - reconf_cause cause) + bool phy_cfg_updated) { // (Re)establish SRBs fill_srbs_reconf(rr_cfg.srb_to_add_mod_list, current_rr_cfg.srb_to_add_mod_list); @@ -342,7 +342,7 @@ void fill_rr_cfg_ded_reconf(asn1::rrc::rr_cfg_ded_s& rr_cfg, rr_cfg.drb_to_release_list_present = rr_cfg.drb_to_release_list.size() > 0; // PhysCfgDed update needed - if (cause != reconf_cause::other) { + if (phy_cfg_updated) { rr_cfg.phys_cfg_ded_present = true; fill_phy_cfg_ded_reconf(rr_cfg.phys_cfg_ded, enb_cfg, ue_cell_list, ue_caps); }