From 876858b44c21123764261b6278314e4ef43508f8 Mon Sep 17 00:00:00 2001 From: David Rupprecht Date: Tue, 9 Feb 2021 11:56:28 +0100 Subject: [PATCH] Added mac nr prach common config convert function with test case --- lib/include/srslte/asn1/rrc_nr_utils.h | 2 ++ lib/src/asn1/rrc_nr_utils.cc | 12 +++++++++++ lib/test/asn1/rrc_nr_utils_test.cc | 29 +++++++++++++++++++++++++- srsue/src/stack/rrc/rrc_nr.cc | 7 +++++++ 4 files changed, 49 insertions(+), 1 deletion(-) diff --git a/lib/include/srslte/asn1/rrc_nr_utils.h b/lib/include/srslte/asn1/rrc_nr_utils.h index 64a08f755..b0d0773f1 100644 --- a/lib/include/srslte/asn1/rrc_nr_utils.h +++ b/lib/include/srslte/asn1/rrc_nr_utils.h @@ -30,6 +30,7 @@ struct sib1_s; struct rlc_cfg_c; struct pdcp_cfg_s; struct lc_ch_cfg_s; +struct rach_cfg_common_s; } // namespace rrc_nr } // namespace asn1 @@ -46,6 +47,7 @@ void to_asn1(asn1::rrc_nr::plmn_id_s* asn1_type, const plmn_id_t& cfg); * MAC Config **************************/ logical_channel_config_t make_mac_logical_channel_cfg_t(uint8_t lcid, const asn1::rrc_nr::lc_ch_cfg_s& asn1_type); +rach_nr_cfg_t make_mac_rach_cfg(const asn1::rrc_nr::rach_cfg_common_s& asn1_type); /*************************** * RLC Config **************************/ diff --git a/lib/src/asn1/rrc_nr_utils.cc b/lib/src/asn1/rrc_nr_utils.cc index 71d89b0bb..c4e887072 100644 --- a/lib/src/asn1/rrc_nr_utils.cc +++ b/lib/src/asn1/rrc_nr_utils.cc @@ -66,6 +66,18 @@ logical_channel_config_t make_mac_logical_channel_cfg_t(uint8_t lcid, const lc_c return logical_channel_config; } +rach_nr_cfg_t make_mac_rach_cfg(const rach_cfg_common_s& asn1_type) +{ + rach_nr_cfg_t rach_nr_cfg = {}; + rach_nr_cfg.powerRampingStep = asn1_type.rach_cfg_generic.pwr_ramp_step.to_number(); + rach_nr_cfg.ra_responseWindow = asn1_type.rach_cfg_generic.ra_resp_win.to_number(); + rach_nr_cfg.prach_ConfigurationIndex = asn1_type.rach_cfg_generic.prach_cfg_idx; + rach_nr_cfg.PreambleReceivedTargetPower = asn1_type.rach_cfg_generic.preamb_rx_target_pwr; + rach_nr_cfg.preambleTransMax = asn1_type.rach_cfg_generic.preamb_trans_max.to_number(); + rach_nr_cfg.ra_ContentionResolutionTimer = asn1_type.ra_contention_resolution_timer.to_number(); + return rach_nr_cfg; +}; + rlc_config_t make_rlc_config_t(const rlc_cfg_c& asn1_type) { rlc_config_t rlc_cfg = rlc_config_t::default_rlc_um_nr_config(); diff --git a/lib/test/asn1/rrc_nr_utils_test.cc b/lib/test/asn1/rrc_nr_utils_test.cc index 701cf6b11..c0936d7e8 100644 --- a/lib/test/asn1/rrc_nr_utils_test.cc +++ b/lib/test/asn1/rrc_nr_utils_test.cc @@ -42,6 +42,32 @@ int test_rlc_config() return SRSLTE_SUCCESS; } +int test_mac_rach_common_config() +{ + asn1::rrc_nr::rach_cfg_common_s rach_common_config_asn1; + rach_common_config_asn1.ra_contention_resolution_timer = + asn1::rrc_nr::rach_cfg_common_s::ra_contention_resolution_timer_opts::sf64; + rach_common_config_asn1.rach_cfg_generic.ra_resp_win = asn1::rrc_nr::rach_cfg_generic_s::ra_resp_win_opts::sl10; + rach_common_config_asn1.rach_cfg_generic.prach_cfg_idx = 160; + rach_common_config_asn1.rach_cfg_generic.preamb_rx_target_pwr = -110; + rach_common_config_asn1.rach_cfg_generic.pwr_ramp_step = asn1::rrc_nr::rach_cfg_generic_s::pwr_ramp_step_opts::db4; + rach_common_config_asn1.rach_cfg_generic.preamb_trans_max = + asn1::rrc_nr::rach_cfg_generic_s::preamb_trans_max_opts::n7; + + asn1::json_writer jw; + rach_common_config_asn1.to_json(jw); + srslog::fetch_basic_logger("RRC").info("MAC NR RACH Common config: \n %s", jw.to_string().c_str()); + + rach_nr_cfg_t rach_nr_cfg = make_mac_rach_cfg(rach_common_config_asn1); + TESTASSERT(rach_nr_cfg.ra_responseWindow == 10); + TESTASSERT(rach_nr_cfg.ra_ContentionResolutionTimer == 64); + TESTASSERT(rach_nr_cfg.prach_ConfigurationIndex == 160); + TESTASSERT(rach_nr_cfg.PreambleReceivedTargetPower == -110); + TESTASSERT(rach_nr_cfg.preambleTransMax == 7); + TESTASSERT(rach_nr_cfg.powerRampingStep == 4); + return SRSLTE_SUCCESS; +} + int main() { srslte::logmap::set_default_log_level(srslte::LOG_LEVEL_DEBUG); @@ -55,7 +81,8 @@ int main() // Start the log backend. srslog::init(); - TESTASSERT(test_rlc_config() == 0); + TESTASSERT(test_rlc_config() == SRSLTE_SUCCESS); + TESTASSERT(test_mac_rach_common_config() == SRSLTE_SUCCESS); srslog::flush(); diff --git a/srsue/src/stack/rrc/rrc_nr.cc b/srsue/src/stack/rrc/rrc_nr.cc index b674f66a3..7dd049718 100644 --- a/srsue/src/stack/rrc/rrc_nr.cc +++ b/srsue/src/stack/rrc/rrc_nr.cc @@ -558,6 +558,13 @@ bool rrc_nr::apply_sp_cell_cfg(const sp_cell_cfg_s& sp_cell_cfg) if (sp_cell_cfg.recfg_with_sync_present) { const recfg_with_sync_s& recfg_with_sync = sp_cell_cfg.recfg_with_sync; mac->set_crnti(recfg_with_sync.new_ue_id); + if(recfg_with_sync.sp_cell_cfg_common_present){ + if(recfg_with_sync.sp_cell_cfg_common.ul_cfg_common_present){ + if(recfg_with_sync.sp_cell_cfg_common.ul_cfg_common.init_ul_bwp.rach_cfg_common_present){ + // mac->set_rach_common_config(); + } + } + } } return true; }