From 8464a6ed6357112cf086e6ed9aa9333d5a3b28c1 Mon Sep 17 00:00:00 2001 From: Andre Puschmann Date: Tue, 1 Feb 2022 10:28:51 +0100 Subject: [PATCH] srsue: refactor SA mode in RRC, don't initilize NSA-5G in NSA mode --- srsue/hdr/stack/rrc_nr/rrc_nr_config.h | 1 - srsue/hdr/stack/ue_stack_base.h | 2 +- srsue/src/stack/rrc_nr/rrc_nr.cc | 15 ++++++++++----- srsue/src/stack/rrc_nr/rrc_nr_procedures.cc | 8 ++++++-- srsue/src/stack/ue_stack_lte.cc | 10 ++++++---- srsue/src/ue.cc | 5 ++--- 6 files changed, 25 insertions(+), 16 deletions(-) diff --git a/srsue/hdr/stack/rrc_nr/rrc_nr_config.h b/srsue/hdr/stack/rrc_nr/rrc_nr_config.h index a76046b97..fc3e4a25a 100644 --- a/srsue/hdr/stack/rrc_nr/rrc_nr_config.h +++ b/srsue/hdr/stack/rrc_nr/rrc_nr_config.h @@ -19,7 +19,6 @@ namespace srsue { struct rrc_nr_args_t { - bool sa_mode; uint32_t sim_nr_meas_pci; bool pdcp_short_sn_support; std::string supported_bands_nr_str; diff --git a/srsue/hdr/stack/ue_stack_base.h b/srsue/hdr/stack/ue_stack_base.h index 8b80b4244..ac1ec3d62 100644 --- a/srsue/hdr/stack/ue_stack_base.h +++ b/srsue/hdr/stack/ue_stack_base.h @@ -66,7 +66,7 @@ typedef struct { gw_args_t gw; uint32_t sync_queue_size; // Max allowed difference between PHY and Stack clocks (in TTI) bool have_tti_time_stats; - bool attach_on_nr; + bool sa_mode; } stack_args_t; class ue_stack_base diff --git a/srsue/src/stack/rrc_nr/rrc_nr.cc b/srsue/src/stack/rrc_nr/rrc_nr.cc index 3e903b212..7fa2f4266 100644 --- a/srsue/src/stack/rrc_nr/rrc_nr.cc +++ b/srsue/src/stack/rrc_nr/rrc_nr.cc @@ -70,10 +70,11 @@ int rrc_nr::init(phy_interface_rrc_nr* phy_, t310 = task_sched.get_unique_timer(); t311 = task_sched.get_unique_timer(); - if (args.sa_mode) { - plmn_is_selected = true; // short-cut SA test + if (rrc_eutra == nullptr) { + // SA mode + plmn_is_selected = true; - // for SA mode setup inital HARQ config and SRB0 + // setup inital HARQ config srsran::dl_harq_cfg_nr_t harq_cfg = {}; harq_cfg.nof_procs = 8; mac->set_config(harq_cfg); @@ -129,7 +130,7 @@ const char* rrc_nr::get_rb_name(uint32_t lcid) void rrc_nr::timer_expired(uint32_t timeout_id) { logger.debug("Handling Timer Expired"); - if (timeout_id == sim_measurement_timer.id()) { + if (timeout_id == sim_measurement_timer.id() && rrc_eutra != nullptr) { logger.debug("Triggered simulated measurement"); phy_meas_nr_t sim_meas = {}; @@ -2072,7 +2073,11 @@ void rrc_nr::ra_completed() void rrc_nr::ra_problem() { - rrc_eutra->nr_scg_failure_information(scg_failure_cause_t::random_access_problem); + if (rrc_eutra) { + rrc_eutra->nr_scg_failure_information(scg_failure_cause_t::random_access_problem); + } else { + // TODO: handle RA problem + } } void rrc_nr::release_pucch_srs() {} diff --git a/srsue/src/stack/rrc_nr/rrc_nr_procedures.cc b/srsue/src/stack/rrc_nr/rrc_nr_procedures.cc index 862b2002f..fe307a0bb 100644 --- a/srsue/src/stack/rrc_nr/rrc_nr_procedures.cc +++ b/srsue/src/stack/rrc_nr/rrc_nr_procedures.cc @@ -142,12 +142,16 @@ void rrc_nr::connection_reconf_no_ho_proc::then(const srsran::proc_state_t& resu if (result.is_success()) { Info("Finished %s successfully", name()); srsran::console("RRC NR reconfiguration successful.\n"); - rrc_handle.rrc_eutra->nr_rrc_con_reconfig_complete(true); + if (rrc_handle.rrc_eutra) { + rrc_handle.rrc_eutra->nr_rrc_con_reconfig_complete(true); + } } else { // 5.3.5.8.2 Inability to comply with RRCReconfiguration switch (initiator) { case reconf_initiator_t::mcg_srb1: - rrc_handle.rrc_eutra->nr_notify_reconfiguration_failure(); + if (rrc_handle.rrc_eutra) { + rrc_handle.rrc_eutra->nr_notify_reconfiguration_failure(); + } break; default: Warning("Reconfiguration failure not implemented for initiator %d", initiator); diff --git a/srsue/src/stack/ue_stack_lte.cc b/srsue/src/stack/ue_stack_lte.cc index 63ddada6e..77359c4e2 100644 --- a/srsue/src/stack/ue_stack_lte.cc +++ b/srsue/src/stack/ue_stack_lte.cc @@ -221,14 +221,16 @@ int ue_stack_lte::init(const stack_args_t& args_) &pdcp_nr, gw, &nas_5g, - &rrc, + args.sa_mode ? nullptr : &rrc, usim.get(), task_sched.get_timer_handler(), this, args.rrc_nr); rrc.init(phy, &mac, &rlc, &pdcp, &nas, usim.get(), gw, &rrc_nr, args.rrc); - nas_5g.init(usim.get(), &rrc_nr, gw, args.nas_5g); + if (args.sa_mode) { + nas_5g.init(usim.get(), &rrc_nr, gw, args.nas_5g); + } running = true; start(STACK_MAIN_THREAD_PRIO); @@ -276,7 +278,7 @@ bool ue_stack_lte::switch_on() if (running) { stack_logger.info("Triggering NAS switch on"); if (!ue_task_queue.try_push([this]() { - if (args.attach_on_nr) { + if (args.sa_mode) { nas_5g.switch_on(); } else { nas.switch_on(); @@ -329,7 +331,7 @@ bool ue_stack_lte::start_service_request() { if (running) { ue_task_queue.try_push([this]() { - if (args.attach_on_nr) { + if (args.sa_mode) { nas_5g.start_service_request(); } else { nas.start_service_request(srsran::establishment_cause_t::mo_data); diff --git a/srsue/src/ue.cc b/srsue/src/ue.cc index 1729da5aa..27994309c 100644 --- a/srsue/src/ue.cc +++ b/srsue/src/ue.cc @@ -110,7 +110,7 @@ int ue::init(const all_args_t& args_) } // In SA mode, pass NR PHY pointer to stack - args.stack.attach_on_nr = true; + args.stack.sa_mode = true; if (lte_stack->init(args.stack, dummy_lte_phy.get(), nr_phy.get(), gw_ptr.get())) { srsran::console("Error initializing stack.\n"); ret = SRSRAN_ERROR; @@ -272,13 +272,12 @@ int ue::parse_args(const all_args_t& args_) // Make sure fix sampling rate is set for SA mode if (args.phy.nof_lte_carriers == 0 and not std::isnormal(args.rf.srate_hz)) { - srsran::console("Error. NR Standalone PHY requires a fix RF sampling rate.\n"); + srsran::console("Error. NR Standalone PHY requires a fixed RF sampling rate.\n"); return SRSRAN_ERROR; } // SA params if (args.phy.nof_lte_carriers == 0 && args.phy.nof_nr_carriers == 1) { - args.stack.rrc_nr.sa_mode = true; // TODO: expose to UE config args.stack.rrc_nr.dl_nr_arfcn = 368500; args.stack.rrc_nr.ssb_nr_arfcn = 368410;