diff --git a/lib/include/srsran/interfaces/gnb_interfaces.h b/lib/include/srsran/interfaces/gnb_interfaces.h index 9f4901134..a0f64d123 100644 --- a/lib/include/srsran/interfaces/gnb_interfaces.h +++ b/lib/include/srsran/interfaces/gnb_interfaces.h @@ -145,9 +145,9 @@ public: virtual int read_pdu_bcch_dlsch(uint32_t sib_index, srsran::byte_buffer_t& buffer) = 0; /// User management - virtual int add_user(uint16_t rnti, const sched_nr_ue_cfg_t& uecfg) = 0; - virtual int update_user(uint16_t new_rnti, uint16_t old_rnti) = 0; - virtual void set_activity_user(uint16_t rnti) = 0; + virtual int add_user(uint16_t rnti, uint32_t pcell_cc_idx) = 0; + virtual int update_user(uint16_t new_rnti, uint16_t old_rnti) = 0; + virtual void set_activity_user(uint16_t rnti) = 0; }; // NR interface is almost identical to EUTRA version diff --git a/srsgnb/hdr/stack/common/test/dummy_nr_classes.h b/srsgnb/hdr/stack/common/test/dummy_nr_classes.h index 74871a6ea..299426636 100644 --- a/srsgnb/hdr/stack/common/test/dummy_nr_classes.h +++ b/srsgnb/hdr/stack/common/test/dummy_nr_classes.h @@ -46,7 +46,7 @@ class rrc_nr_dummy : public rrc_interface_mac_nr public: int read_pdu_bcch_bch(const uint32_t tti, srsran::byte_buffer_t& buffer) { return SRSRAN_SUCCESS; } int read_pdu_bcch_dlsch(uint32_t sib_index, srsran::byte_buffer_t& buffer) { return SRSRAN_SUCCESS; } - int add_user(uint16_t rnti, const sched_nr_ue_cfg_t& uecfg) { return SRSRAN_SUCCESS; } + int add_user(uint16_t rnti, uint32_t pcell_cc_idx) { return SRSRAN_SUCCESS; } int update_user(uint16_t new_rnti, uint16_t old_rnti) { return SRSRAN_SUCCESS; } void set_activity_user(uint16_t rnti) {} }; diff --git a/srsgnb/hdr/stack/rrc/rrc_nr.h b/srsgnb/hdr/stack/rrc/rrc_nr.h index 0534144a0..8da7ccc03 100644 --- a/srsgnb/hdr/stack/rrc/rrc_nr.h +++ b/srsgnb/hdr/stack/rrc/rrc_nr.h @@ -71,7 +71,7 @@ public: int read_pdu_bcch_dlsch(uint32_t sib_index, srsran::byte_buffer_t& buffer) final; /// User manegement - int add_user(uint16_t rnti, const sched_nr_ue_cfg_t& uecfg) final; + int add_user(uint16_t rnti, uint32_t pcell_cc_idx) final; void rem_user(uint16_t rnti); int update_user(uint16_t new_rnti, uint16_t old_rnti) final; void set_activity_user(uint16_t rnti) final; @@ -149,6 +149,7 @@ private: srsran::unique_byte_buffer_t mib_buffer = nullptr; std::vector sib_buffer; std::unique_ptr master_cell_group; + srsran::phy_cfg_nr_t default_phy_ue_cfg_nr; }; std::unique_ptr cell_ctxt; rnti_map_t > users; @@ -166,7 +167,7 @@ private: void handle_rrc_reest_request(uint16_t rnti, const asn1::rrc_nr::rrc_reest_request_s& msg); /// This gets called by rrc_nr::sgnb_addition_request and WILL NOT TRIGGER the RX MSG3 activity timer - int add_user(uint16_t rnti, const sched_nr_ue_cfg_t& uecfg, bool start_msg3_timer); + int add_user(uint16_t rnti, uint32_t pcell_cc_idx, bool start_msg3_timer); // Helper to create PDU from RRC message template diff --git a/srsgnb/hdr/stack/rrc/rrc_nr_ue.h b/srsgnb/hdr/stack/rrc/rrc_nr_ue.h index aaaaaa80f..dabfead70 100644 --- a/srsgnb/hdr/stack/rrc/rrc_nr_ue.h +++ b/srsgnb/hdr/stack/rrc/rrc_nr_ue.h @@ -29,7 +29,7 @@ public: }; /// @param [in] start_msg3_timer: indicates whether the UE is created as part of a RACH process - ue(rrc_nr* parent_, uint16_t rnti_, const sched_nr_ue_cfg_t& uecfg, bool start_msg3_timer = true); + ue(rrc_nr* parent_, uint16_t rnti_, uint32_t pcell_cc_idx, bool start_msg3_timer = true); ~ue(); int handle_sgnb_addition_request(uint16_t eutra_rnti, const sgnb_addition_req_params_t& params); diff --git a/srsgnb/src/stack/mac/mac_nr.cc b/srsgnb/src/stack/mac/mac_nr.cc index e36444c26..1d891cbb9 100644 --- a/srsgnb/src/stack/mac/mac_nr.cc +++ b/srsgnb/src/stack/mac/mac_nr.cc @@ -336,10 +336,6 @@ void mac_nr::rach_detected(const rach_info_t& rach_info) stack_task_queue.push([this, rach_info, enb_cc_idx, rach_tprof_meas]() mutable { rach_tprof_meas.defer_stop(); - // Add new user to the scheduler so that it can RX/TX SRB0 - sched_nr_ue_cfg_t uecfg = {}; - uecfg.phy_cfg = default_ue_phy_cfg; - uint16_t rnti = alloc_ue(enb_cc_idx); // Log this event. @@ -352,9 +348,8 @@ void mac_nr::rach_detected(const rach_info_t& rach_info) rar_info.temp_crnti = rnti; rar_info.ta_cmd = rach_info.time_adv; rar_info.prach_slot = slot_point{NUMEROLOGY_IDX, rach_info.slot_index}; - // TODO: fill remaining fields as required sched->dl_rach_info(rar_info); - rrc->add_user(rnti, uecfg); + rrc->add_user(rnti, enb_cc_idx); logger.info("RACH: slot=%d, cc=%d, preamble=%d, offset=%d, temp_crnti=0x%x", rach_info.slot_index, diff --git a/srsgnb/src/stack/mac/sched_nr_ue.cc b/srsgnb/src/stack/mac/sched_nr_ue.cc index 7675f7321..61b26ac67 100644 --- a/srsgnb/src/stack/mac/sched_nr_ue.cc +++ b/srsgnb/src/stack/mac/sched_nr_ue.cc @@ -129,7 +129,8 @@ int ue_carrier::ul_crc_info(uint32_t pid, bool crc) /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// -sched_nr_ue_cfg_t get_rach_ue_cfg(uint32_t cc, const sched_params_t& sched_params) +/// Generate basic UE config at the point of RACH +sched_nr_ue_cfg_t get_rach_ue_cfg_helper(uint32_t cc, const sched_params_t& sched_params) { sched_nr_ue_cfg_t uecfg = {}; uecfg.carriers.resize(1); @@ -140,7 +141,7 @@ sched_nr_ue_cfg_t get_rach_ue_cfg(uint32_t cc, const sched_params_t& sched_param } ue::ue(uint16_t rnti_, uint32_t cc, const sched_params_t& sched_cfg_) : - ue(rnti_, get_rach_ue_cfg(cc, sched_cfg_), sched_cfg_) + ue(rnti_, get_rach_ue_cfg_helper(cc, sched_cfg_), sched_cfg_) {} ue::ue(uint16_t rnti_, const sched_nr_ue_cfg_t& uecfg, const sched_params_t& sched_cfg_) : diff --git a/srsgnb/src/stack/rrc/rrc_nr.cc b/srsgnb/src/stack/rrc/rrc_nr.cc index 92d3e7ebe..fee9c35cd 100644 --- a/srsgnb/src/stack/rrc/rrc_nr.cc +++ b/srsgnb/src/stack/rrc/rrc_nr.cc @@ -178,11 +178,11 @@ void rrc_nr::log_rx_pdu_fail(uint16_t rnti, * * This function WILL NOT TRIGGER the RX MSG3 activity timer */ -int rrc_nr::add_user(uint16_t rnti, const sched_nr_ue_cfg_t& uecfg, bool start_msg3_timer) +int rrc_nr::add_user(uint16_t rnti, uint32_t pcell_cc_idx, bool start_msg3_timer) { if (users.contains(rnti) == 0) { // If in the ue ctor, "start_msg3_timer" is set to true, this will start the MSG3 RX TIMEOUT at ue creation - users.insert(rnti, std::unique_ptr(new ue(this, rnti, uecfg, start_msg3_timer))); + users.insert(rnti, std::unique_ptr(new ue(this, rnti, pcell_cc_idx, start_msg3_timer))); rlc->add_user(rnti); pdcp->add_user(rnti); logger.info("Added new user rnti=0x%x", rnti); @@ -197,10 +197,10 @@ int rrc_nr::add_user(uint16_t rnti, const sched_nr_ue_cfg_t& uecfg, bool start_m * * This function is called from PRACH worker (can wait) and WILL TRIGGER the RX MSG3 activity timer */ -int rrc_nr::add_user(uint16_t rnti, const sched_nr_ue_cfg_t& uecfg) +int rrc_nr::add_user(uint16_t rnti, uint32_t pcell_cc_idx) { // Set "triggered_by_rach" to true to start the MSG3 RX TIMEOUT - return add_user(rnti, uecfg, true); + return add_user(rnti, pcell_cc_idx, true); } void rrc_nr::rem_user(uint16_t rnti) @@ -344,6 +344,9 @@ void rrc_nr::config_mac() // Configure MAC/scheduler mac->cell_cfg(sched_cells_cfg); + + // Make default UE PHY config object + cell_ctxt->default_phy_ue_cfg_nr = get_common_ue_phy_cfg(cell); } int32_t rrc_nr::generate_sibs() @@ -708,12 +711,7 @@ void rrc_nr::sgnb_addition_request(uint16_t eutra_rnti, const sgnb_addition_req_ uecfg.carriers.resize(1); uecfg.carriers[0].active = true; uecfg.carriers[0].cc = 0; - srsran::phy_cfg_nr_default_t::reference_cfg_t ref_args{}; - ref_args.duplex = cfg.cell_list[0].duplex_mode == SRSRAN_DUPLEX_MODE_TDD - ? srsran::phy_cfg_nr_default_t::reference_cfg_t::R_DUPLEX_TDD_CUSTOM_6_4 - : srsran::phy_cfg_nr_default_t::reference_cfg_t::R_DUPLEX_FDD; - uecfg.phy_cfg = srsran::phy_cfg_nr_default_t{ref_args}; - uecfg.phy_cfg.csi = {}; // disable CSI until RA is complete + uecfg.phy_cfg = cell_ctxt->default_phy_ue_cfg_nr; uint16_t nr_rnti = mac->reserve_rnti(0, uecfg); if (nr_rnti == SRSRAN_INVALID_RNTI) { @@ -722,7 +720,7 @@ void rrc_nr::sgnb_addition_request(uint16_t eutra_rnti, const sgnb_addition_req_ return; } - if (add_user(nr_rnti, uecfg, false) != SRSRAN_SUCCESS) { + if (add_user(nr_rnti, 0, false) != SRSRAN_SUCCESS) { logger.error("Failed to allocate RNTI at RRC"); rrc_eutra->sgnb_addition_reject(eutra_rnti); return; diff --git a/srsgnb/src/stack/rrc/rrc_nr_ue.cc b/srsgnb/src/stack/rrc/rrc_nr_ue.cc index adbdeeca4..ea8ad540b 100644 --- a/srsgnb/src/stack/rrc/rrc_nr_ue.cc +++ b/srsgnb/src/stack/rrc/rrc_nr_ue.cc @@ -28,9 +28,15 @@ namespace srsenb { Every function in UE class is called from a mutex environment thus does not need extra protection. *******************************************************************************/ -rrc_nr::ue::ue(rrc_nr* parent_, uint16_t rnti_, const sched_nr_ue_cfg_t& uecfg_, bool start_msg3_timer) : - parent(parent_), logger(parent_->logger), rnti(rnti_), uecfg(uecfg_), sec_ctx(parent->cfg) +rrc_nr::ue::ue(rrc_nr* parent_, uint16_t rnti_, uint32_t pcell_cc_idx, bool start_msg3_timer) : + parent(parent_), logger(parent_->logger), rnti(rnti_), uecfg(), sec_ctx(parent->cfg) { + // Set default MAC UE config + uecfg.carriers.resize(1); + uecfg.carriers[0].active = true; + uecfg.carriers[0].cc = pcell_cc_idx; + uecfg.phy_cfg = parent->cell_ctxt->default_phy_ue_cfg_nr; + if (not parent->cfg.is_standalone) { // Add the final PDCCH config in case of NSA uecfg.phy_cfg.pdcch = parent->cfg.cell_list[0].phy_cell.pdcch; diff --git a/srsgnb/src/stack/rrc/test/CMakeLists.txt b/srsgnb/src/stack/rrc/test/CMakeLists.txt index 3f8d682bb..103b1bb38 100644 --- a/srsgnb/src/stack/rrc/test/CMakeLists.txt +++ b/srsgnb/src/stack/rrc/test/CMakeLists.txt @@ -9,9 +9,11 @@ add_library(rrc_nr_test_helpers rrc_nr_test_helpers.cc) add_executable(rrc_nr_test rrc_nr_test.cc) -target_link_libraries(rrc_nr_test srsgnb_rrc srsgnb_rrc_config_utils srsran_common rrc_nr_asn1 rrc_nr_test_helpers ${ATOMIC_LIBS}) +target_link_libraries(rrc_nr_test srsgnb_rrc srsgnb_rrc_config_utils srsran_common rrc_nr_asn1 rrc_nr_test_helpers srsgnb_mac ${ATOMIC_LIBS}) add_test(rrc_nr_test rrc_nr_test) add_executable(rrc_nr_core_test rrc_nr_core_test.cc) -target_link_libraries(rrc_nr_core_test srsgnb_rrc srsgnb_rrc_config_utils srsran_common rrc_nr_asn1 test_helpers rrc_nr_test_helpers srsgnb_ngap ngap_nr_asn1 srsran_gtpu srsenb_upper ${SCTP_LIBRARIES} ${ATOMIC_LIBS} ${Boost_LIBRARIES}) +target_link_libraries(rrc_nr_core_test srsgnb_rrc srsgnb_rrc_config_utils srsran_common rrc_nr_asn1 test_helpers + rrc_nr_test_helpers srsgnb_mac srsgnb_ngap ngap_nr_asn1 srsran_gtpu + srsenb_upper ${SCTP_LIBRARIES} ${ATOMIC_LIBS} ${Boost_LIBRARIES}) diff --git a/srsgnb/src/stack/rrc/test/rrc_nr_core_test.cc b/srsgnb/src/stack/rrc/test/rrc_nr_core_test.cc index 41a71b783..27680fbb7 100644 --- a/srsgnb/src/stack/rrc/test/rrc_nr_core_test.cc +++ b/srsgnb/src/stack/rrc/test/rrc_nr_core_test.cc @@ -164,10 +164,7 @@ void test_rrc_sa_ngap_integration(ngap_args_t ngap_args) rrc_obj.init(rrc_cfg_nr, &phy_obj, &mac_obj, &rlc_obj, &pdcp_obj, &ngap_obj, >pu_obj, bearer_mapper, nullptr) == SRSRAN_SUCCESS); - sched_nr_ue_cfg_t uecfg = get_default_ue_cfg(1); - uecfg.phy_cfg.pdcch = rrc_cfg_nr.cell_list[0].phy_cell.pdcch; - uecfg.phy_cfg.pdcch.search_space_present[2] = false; - TESTASSERT_SUCCESS(rrc_obj.add_user(0x4601, uecfg)); + TESTASSERT_SUCCESS(rrc_obj.add_user(0x4601, 0)); // RRCSetupComplete triggers NGAP Initial UE Message with NAS-PDU: Registration Request ngap_rrc_tester ngap_dummy; diff --git a/srsgnb/src/stack/rrc/test/rrc_nr_test.cc b/srsgnb/src/stack/rrc/test/rrc_nr_test.cc index 47c6ecbf9..d7a29392c 100644 --- a/srsgnb/src/stack/rrc/test/rrc_nr_test.cc +++ b/srsgnb/src/stack/rrc/test/rrc_nr_test.cc @@ -169,10 +169,7 @@ void test_rrc_sa_connection() rrc_obj.init(rrc_cfg_nr, &phy_obj, &mac_obj, &rlc_obj, &pdcp_obj, &ngap_obj, nullptr, bearer_mapper, nullptr) == SRSRAN_SUCCESS); - sched_nr_ue_cfg_t uecfg = get_default_ue_cfg(1); - uecfg.phy_cfg.pdcch = rrc_cfg_nr.cell_list[0].phy_cell.pdcch; - uecfg.phy_cfg.pdcch.search_space_present[2] = false; - TESTASSERT_SUCCESS(rrc_obj.add_user(0x4601, uecfg)); + TESTASSERT_SUCCESS(rrc_obj.add_user(0x4601, 0)); test_rrc_nr_connection_establishment(task_sched, rrc_obj, rlc_obj, mac_obj, ngap_obj, 0x4601); test_rrc_nr_info_transfer(task_sched, rrc_obj, pdcp_obj, ngap_obj, 0x4601);