diff --git a/srsue/hdr/stack/ue_stack_lte.h b/srsue/hdr/stack/ue_stack_lte.h index 8b2c6c736..b5c606af2 100644 --- a/srsue/hdr/stack/ue_stack_lte.h +++ b/srsue/hdr/stack/ue_stack_lte.h @@ -59,8 +59,15 @@ public: std::string get_type() final; - int init(const stack_args_t& args_, srslte::logger* logger_); - int init(const stack_args_t& args_, srslte::logger* logger_, phy_interface_stack_lte* phy_, gw_interface_stack* gw_); + int init(const stack_args_t& args_, srslte::logger* logger_); + int init(const stack_args_t& args_, srslte::logger* logger_, phy_interface_stack_lte* phy_, gw_interface_stack* gw_); +#ifdef HAVE_5GNR + int init(const stack_args_t& args_, + srslte::logger* logger_, + phy_interface_stack_lte* phy_, + phy_interface_stack_nr* phy_nr_, + gw_interface_stack* gw_); +#endif bool switch_on() final; bool switch_off() final; bool is_registered() final; @@ -177,6 +184,9 @@ private: // RAT-specific interfaces phy_interface_stack_lte* phy = nullptr; gw_interface_stack* gw = nullptr; +#ifdef HAVE_5GNR + phy_interface_stack_nr* phy_nr = nullptr; +#endif // Thread static const int STACK_MAIN_THREAD_PRIO = 4; // Next lower priority after PHY workers diff --git a/srsue/src/stack/ue_stack_lte.cc b/srsue/src/stack/ue_stack_lte.cc index e44be258f..de3e20887 100644 --- a/srsue/src/stack/ue_stack_lte.cc +++ b/srsue/src/stack/ue_stack_lte.cc @@ -65,6 +65,21 @@ std::string ue_stack_lte::get_type() return "lte"; } +#ifdef HAVE_5GNR +int ue_stack_lte::init(const stack_args_t& args_, + srslte::logger* logger_, + phy_interface_stack_lte* phy_, + phy_interface_stack_nr* phy_nr_, + gw_interface_stack* gw_) +{ + phy_nr = phy_nr_; + if (init(args_, logger_, phy_, gw_)) { + return SRSLTE_ERROR; + } + return SRSLTE_SUCCESS; +} +#endif + int ue_stack_lte::init(const stack_args_t& args_, srslte::logger* logger_, phy_interface_stack_lte* phy_, @@ -142,10 +157,15 @@ int ue_stack_lte::init(const stack_args_t& args_, srslte::logger* logger_) rlc.init(&pdcp, &rrc, task_sched.get_timer_handler(), 0 /* RB_ID_SRB0 */); pdcp.init(&rlc, &rrc, gw); nas.init(usim.get(), &rrc, gw, args.nas); + #ifdef HAVE_5GNR + if (phy_nr == nullptr) { + srslte::console("Failed to init as phy_nr is missing.\n"); + return SRSLTE_ERROR; + } mac_nr_args_t mac_nr_args = {}; - mac_nr.init(mac_nr_args, (phy_interface_mac_nr*)phy, &rlc); - rrc_nr.init((phy_interface_rrc_nr*)phy, + mac_nr.init(mac_nr_args, phy_nr, &rlc); + rrc_nr.init(phy_nr, &mac_nr, &rlc, &pdcp, diff --git a/srsue/src/ue.cc b/srsue/src/ue.cc index d277ee6e4..d4777e20c 100644 --- a/srsue/src/ue.cc +++ b/srsue/src/ue.cc @@ -107,12 +107,17 @@ int ue::init(const all_args_t& args_, srslte::logger* logger_) srslte::console("Error initializing NR PHY.\n"); ret = SRSLTE_ERROR; } -#endif // HAVE_5GNR + if (lte_stack->init(args.stack, old_logger, lte_phy.get(), lte_phy.get(), gw_ptr.get())) { + srslte::console("Error initializing stack.\n"); + ret = SRSLTE_ERROR; + } +#else // HAVE_5GNR if (lte_stack->init(args.stack, old_logger, lte_phy.get(), gw_ptr.get())) { srslte::console("Error initializing stack.\n"); ret = SRSLTE_ERROR; } +#endif if (gw_ptr->init(args.gw, old_logger, lte_stack.get())) { srslte::console("Error initializing GW.\n");