From 7ce23e0afb6e1363a67e4f0cfcfaf1fbd5b5f157 Mon Sep 17 00:00:00 2001 From: Francisco Paisana Date: Fri, 5 Jun 2020 18:05:17 +0100 Subject: [PATCH] extend handover intraenb handover fsm to account for multiple C-RNTI CEs --- srsenb/hdr/stack/rrc/rrc_mobility.h | 20 ++++++++------ srsenb/src/stack/rrc/rrc_mobility.cc | 39 ++++++++++++++++++---------- srsenb/src/stack/rrc/rrc_ue.cc | 3 +++ 3 files changed, 40 insertions(+), 22 deletions(-) diff --git a/srsenb/hdr/stack/rrc/rrc_mobility.h b/srsenb/hdr/stack/rrc/rrc_mobility.h index f78051a2c..40b7ba0e2 100644 --- a/srsenb/hdr/stack/rrc/rrc_mobility.h +++ b/srsenb/hdr/stack/rrc/rrc_mobility.h @@ -83,8 +83,8 @@ public: // Note: Made const to forbid silent updates and enable comparison based on addr std::vector > cell_meas_cfg_list; - rrc *get_rrc() { return rrc_ptr; } - const rrc *get_rrc() const { return rrc_ptr; } + rrc* get_rrc() { return rrc_ptr; } + const rrc* get_rrc() const { return rrc_ptr; } private: // args @@ -140,12 +140,14 @@ private: uint32_t target_cell_id; }; using unsuccessful_outcome_ev = std::false_type; + using recfg_complete_ev = asn1::rrc::rrc_conn_recfg_complete_s; // states struct idle_st {}; struct intraenb_ho_st { const cell_info_common* target_cell = nullptr; const cell_ctxt_dedicated* source_cell_ctxt = nullptr; + uint16_t last_temp_crnti = SRSLTE_INVALID_RNTI; void enter(rrc_mobility* f); }; @@ -190,7 +192,8 @@ private: // FSM transition handlers void handle_s1_meas_report(idle_st& s, s1_source_ho_st& d, const ho_meas_report_ev& meas_report); void handle_intraenb_meas_report(idle_st& s, intraenb_ho_st& d, const ho_meas_report_ev& meas_report); - void handle_crnti_ce(intraenb_ho_st& s, idle_st& d, const user_crnti_upd_ev& ev); + void handle_crnti_ce(intraenb_ho_st& s, intraenb_ho_st& d, const user_crnti_upd_ev& ev); + void handle_recfg_complete(intraenb_ho_st& s, idle_st& d, const recfg_complete_ev& ev); protected: // states @@ -204,11 +207,12 @@ protected: using fsm = rrc_mobility; // clang-format off using transitions = transition_table< - // Start Target Event Action Guard (optional) - // +------------+---------------+--------------------+---------------------------------+---------------------------+ - row< idle_st, intraenb_ho_st, ho_meas_report_ev, &fsm::handle_intraenb_meas_report, &fsm::needs_intraenb_ho >, - row< idle_st, s1_source_ho_st, ho_meas_report_ev, &fsm::handle_s1_meas_report, &fsm::needs_s1_ho >, - row< intraenb_ho_st, idle_st, user_crnti_upd_ev, &fsm::handle_crnti_ce > + // Start Target Event Action Guard (optional) + // +---------------+----------------+--------------------+---------------------------------+-------------------------+ + row< idle_st, s1_source_ho_st, ho_meas_report_ev, &fsm::handle_s1_meas_report, &fsm::needs_s1_ho >, + row< idle_st, intraenb_ho_st, ho_meas_report_ev, &fsm::handle_intraenb_meas_report, &fsm::needs_intraenb_ho >, + row< intraenb_ho_st, intraenb_ho_st, user_crnti_upd_ev, &fsm::handle_crnti_ce >, + row< intraenb_ho_st, idle_st, recfg_complete_ev, &fsm::handle_recfg_complete > >; // clang-format on }; diff --git a/srsenb/src/stack/rrc/rrc_mobility.cc b/srsenb/src/stack/rrc/rrc_mobility.cc index add3291d4..65ce19e18 100644 --- a/srsenb/src/stack/rrc/rrc_mobility.cc +++ b/srsenb/src/stack/rrc/rrc_mobility.cc @@ -958,6 +958,7 @@ void rrc::ue::rrc_mobility::intraenb_ho_st::enter(rrc_mobility* f) f->trigger(srslte::failure_ev{}); return; } + last_temp_crnti = SRSLTE_INVALID_RNTI; /* Allocate Resources in Target Cell */ // NOTE: for intra-eNB Handover only CQI resources will change @@ -993,26 +994,36 @@ void rrc::ue::rrc_mobility::intraenb_ho_st::enter(rrc_mobility* f) } } -void rrc::ue::rrc_mobility::handle_crnti_ce(intraenb_ho_st& s, idle_st& d, const user_crnti_upd_ev& ev) +void rrc::ue::rrc_mobility::handle_crnti_ce(intraenb_ho_st& s, intraenb_ho_st& d, const user_crnti_upd_ev& ev) { rrc_log->info("UE performing handover updated its temp-crnti=0x%x to rnti=0x%x\n", ev.temp_crnti, ev.crnti); + bool is_first_crnti_ce = s.last_temp_crnti == SRSLTE_INVALID_RNTI; + s.last_temp_crnti = ev.temp_crnti; - // Need to reset SNs of bearers. - rrc_enb->pdcp->rem_user(rrc_ue->rnti); - rrc_enb->pdcp->add_user(rrc_ue->rnti); - rrc_enb->rlc->reestablish(rrc_ue->rnti); + if (is_first_crnti_ce) { + // Need to reset SNs of bearers. + rrc_enb->pdcp->rem_user(rrc_ue->rnti); + rrc_enb->pdcp->add_user(rrc_ue->rnti); + rrc_enb->rlc->reestablish(rrc_ue->rnti); - // Change PCell in MAC/Scheduler - rrc_ue->current_sched_ue_cfg.supported_cc_list[0].active = true; - rrc_ue->current_sched_ue_cfg.supported_cc_list[0].enb_cc_idx = s.target_cell->enb_cc_idx; - rrc_ue->apply_setup_phy_common(s.target_cell->sib2.rr_cfg_common); - rrc_enb->mac->ue_set_crnti(ev.temp_crnti, ev.crnti, &rrc_ue->current_sched_ue_cfg); + // Change PCell in MAC/Scheduler + rrc_ue->current_sched_ue_cfg.supported_cc_list[0].active = true; + rrc_ue->current_sched_ue_cfg.supported_cc_list[0].enb_cc_idx = s.target_cell->enb_cc_idx; + rrc_ue->apply_setup_phy_common(s.target_cell->sib2.rr_cfg_common); + rrc_enb->mac->ue_set_crnti(ev.temp_crnti, ev.crnti, &rrc_ue->current_sched_ue_cfg); - rrc_ue->ue_security_cfg.regenerate_keys_handover(s.target_cell->cell_cfg.pci, s.target_cell->cell_cfg.dl_earfcn); - rrc_ue->bearer_list.reest_bearers(); - rrc_ue->bearer_list.apply_pdcp_bearer_updates(rrc_enb->pdcp, rrc_ue->ue_security_cfg); + rrc_ue->ue_security_cfg.regenerate_keys_handover(s.target_cell->cell_cfg.pci, s.target_cell->cell_cfg.dl_earfcn); + rrc_ue->bearer_list.reest_bearers(); + rrc_ue->bearer_list.apply_pdcp_bearer_updates(rrc_enb->pdcp, rrc_ue->ue_security_cfg); + } else { + rrc_log->info("Received duplicate C-RNTI CE during rnti=0x%x handover.\n", rrc_ue->rnti); + } +} - rrc_log->info("new rnti=0x%x PCell is %d\n", ev.crnti, s.target_cell->enb_cc_idx); +void rrc::ue::rrc_mobility::handle_recfg_complete(intraenb_ho_st& s, idle_st& d, const recfg_complete_ev& ev) +{ + rrc_log->info( + "User rnti=0x%x successfully handovered to cell_id=0x%x\n", rrc_ue->rnti, s.target_cell->cell_cfg.cell_id); } } // namespace srsenb diff --git a/srsenb/src/stack/rrc/rrc_ue.cc b/srsenb/src/stack/rrc/rrc_ue.cc index e4b699d3f..2555adc2f 100644 --- a/srsenb/src/stack/rrc/rrc_ue.cc +++ b/srsenb/src/stack/rrc/rrc_ue.cc @@ -652,6 +652,9 @@ void rrc::ue::handle_rrc_reconf_complete(rrc_conn_recfg_complete_s* msg, srslte: // Flag completion of RadioResource Configuration bearer_list.rr_ded_cfg_complete(); + + // If performing handover, signal its completion + mobility_handler->trigger(*msg); } else { parent->rrc_log->error("Expected RRCReconfigurationComplete with transaction ID: %d, got %d\n", last_rrc_conn_recfg.rrc_transaction_id,