diff --git a/srsenb/src/stack/mac/scheduler_ue.cc b/srsenb/src/stack/mac/scheduler_ue.cc index 5a22e0b7e..aa93bf34d 100644 --- a/srsenb/src/stack/mac/scheduler_ue.cc +++ b/srsenb/src/stack/mac/scheduler_ue.cc @@ -1178,10 +1178,6 @@ void cc_sched_ue::reset() void cc_sched_ue::set_cfg(const sched_interface::ue_cfg_t& cfg_) { - if (cfg != nullptr and cfg->maxharq_tx == cfg_.maxharq_tx) { - // nothing changed - return; - } cfg = &cfg_; // Config HARQ processes harq_ent.set_cfg(cfg->maxharq_tx); diff --git a/srsenb/test/mac/scheduler_ca_test.cc b/srsenb/test/mac/scheduler_ca_test.cc index b916629b5..ba92fd7e8 100644 --- a/srsenb/test/mac/scheduler_ca_test.cc +++ b/srsenb/test/mac/scheduler_ca_test.cc @@ -55,6 +55,8 @@ sim_sched_args generate_default_sim_args(uint32_t nof_prb, uint32_t nof_ccs) { sim_sched_args sim_args; + sim_args.default_ue_sim_cfg.ue_cfg = generate_default_ue_cfg2(); + // setup two cells std::vector cell_cfg(nof_ccs, generate_default_cell_cfg(nof_prb)); cell_cfg[0].scell_list.resize(1); @@ -89,18 +91,6 @@ int test_scell_activation(test_scell_activation_params params) uint32_t nof_ccs = 2; uint32_t start_tti = 0; // rand_int(0, 10240); - /* Setup simulation arguments struct */ - sim_sched_args sim_args = generate_default_sim_args(nof_prb, nof_ccs); - sim_args.sim_log = log_global.get(); - sim_args.start_tti = start_tti; - - /* Simulation Objects Setup */ - sched_sim_event_generator generator; - // Setup scheduler - common_sched_tester tester; - tester.init(nullptr); - tester.sim_cfg(sim_args); - /* Internal configurations. Do not touch */ float ul_sr_exps[] = {1, 4}; // log rand float dl_data_exps[] = {1, 4}; // log rand @@ -117,15 +107,29 @@ int test_scell_activation(test_scell_activation_params params) std::shuffle(cc_idxs.begin(), cc_idxs.end(), get_rand_gen()); std::iter_swap(cc_idxs.begin(), std::find(cc_idxs.begin(), cc_idxs.end(), params.pcell_idx)); + /* Setup simulation arguments struct */ + sim_sched_args sim_args = generate_default_sim_args(nof_prb, nof_ccs); + sim_args.sim_log = log_global.get(); + sim_args.start_tti = start_tti; + sim_args.default_ue_sim_cfg.ue_cfg.supported_cc_list.resize(1); + sim_args.default_ue_sim_cfg.ue_cfg.supported_cc_list[0].active = true; + sim_args.default_ue_sim_cfg.ue_cfg.supported_cc_list[0].enb_cc_idx = cc_idxs[0]; + sim_args.default_ue_sim_cfg.ue_cfg.dl_cfg.cqi_report.periodic_configured = true; + sim_args.default_ue_sim_cfg.ue_cfg.dl_cfg.cqi_report.pmi_idx = 0; + + /* Simulation Objects Setup */ + sched_sim_event_generator generator; + // Setup scheduler + common_sched_tester tester; + tester.init(nullptr); + tester.sim_cfg(sim_args); + /* Simulation */ // Event PRACH: PRACH takes place for "rnti1", and carrier "pcell_idx" generator.step_until(prach_tti); - tti_ev::user_cfg_ev* user = generator.add_new_default_user(duration); - user->ue_sim_cfg->ue_cfg.supported_cc_list[0].enb_cc_idx = cc_idxs[0]; - user->rnti = rnti1; - user->ue_sim_cfg->ue_cfg.dl_cfg.cqi_report.periodic_configured = true; - user->ue_sim_cfg->ue_cfg.dl_cfg.cqi_report.pmi_idx = 0; + tti_ev::user_cfg_ev* user = generator.add_new_default_user(duration, sim_args.default_ue_sim_cfg.ue_cfg); + user->rnti = rnti1; tester.test_next_ttis(generator.tti_events); TESTASSERT(tester.ue_tester->user_exists(rnti1)); @@ -159,7 +163,7 @@ int test_scell_activation(test_scell_activation_params params) } } }; - generate_data(20, P_dl, P_ul_sr, randf()); + generate_data(20, 1.0, P_ul_sr, randf()); tester.test_next_ttis(generator.tti_events); // Event: Reconf Complete. Activate SCells. Check if CE correctly transmitted diff --git a/srsenb/test/mac/scheduler_test_common.cc b/srsenb/test/mac/scheduler_test_common.cc index 6861c3667..b9c283be1 100644 --- a/srsenb/test/mac/scheduler_test_common.cc +++ b/srsenb/test/mac/scheduler_test_common.cc @@ -610,7 +610,7 @@ int ue_ctxt_test::test_harqs(cc_result result) CONDERROR(h.ndi != data.dci.tb[0].ndi, "Invalid ndi for retx\n"); CONDERROR(not h.active, "retx for inactive dl harq pid=%d\n", h.pid); CONDERROR(h.tti_tx > current_tti_rx, "harq pid=%d reused too soon\n", h.pid); - CONDERROR(h.nof_retxs + 1 >= sim_cfg.ue_cfg.maxharq_tx, + CONDERROR(h.nof_retxs + 1 > sim_cfg.ue_cfg.maxharq_tx, "The number of retx=%d exceeded its max=%d\n", h.nof_retxs + 1, sim_cfg.ue_cfg.maxharq_tx); @@ -893,7 +893,9 @@ int common_sched_tester::sim_cfg(sim_sched_args args) int common_sched_tester::add_user(uint16_t rnti, const ue_ctxt_test_cfg& ue_cfg_) { - CONDERROR(ue_cfg(rnti, ue_cfg_.ue_cfg) != SRSLTE_SUCCESS, "Configuring new user rnti=0x%x to sched\n", rnti); + CONDERROR(ue_cfg(rnti, generate_rach_ue_cfg(ue_cfg_.ue_cfg)) != SRSLTE_SUCCESS, + "Configuring new user rnti=0x%x to sched\n", + rnti); // CONDERROR(!srslte_prach_tti_opportunity_config_fdd( // sched_cell_params[CARRIER_IDX].cfg.prach_config, tti_info.tti_params.tti_rx, -1), // "New user added in a non-PRACH TTI\n"); @@ -912,6 +914,14 @@ int common_sched_tester::add_user(uint16_t rnti, const ue_ctxt_test_cfg& ue_cfg_ return SRSLTE_SUCCESS; } +int common_sched_tester::reconf_user(uint16_t rnti, const sched_interface::ue_cfg_t& ue_cfg_) +{ + CONDERROR(not ue_tester->user_exists(rnti), "User must already exist to be configured\n"); + CONDERROR(ue_cfg(rnti, ue_cfg_) != SRSLTE_SUCCESS, "Configuring new user rnti=0x%x to sched\n", rnti); + ue_tester->user_reconf(rnti, ue_cfg_); + return SRSLTE_SUCCESS; +} + void common_sched_tester::rem_user(uint16_t rnti) { tester_log->info("Removing user rnti=0x%x\n", rnti); @@ -959,8 +969,7 @@ int common_sched_tester::process_tti_events(const tti_ev& tti_ev) TESTASSERT(add_user(ue_ev.rnti, *ue_ev.ue_sim_cfg) == SRSLTE_SUCCESS); } else { // reconfiguration - TESTASSERT(ue_cfg(ue_ev.rnti, ue_ev.ue_sim_cfg->ue_cfg) == SRSLTE_SUCCESS); - ue_tester->user_reconf(ue_ev.rnti, ue_ev.ue_sim_cfg->ue_cfg); + TESTASSERT(reconf_user(ue_ev.rnti, ue_ev.ue_sim_cfg->ue_cfg) == SRSLTE_SUCCESS); } } @@ -976,10 +985,14 @@ int common_sched_tester::process_tti_events(const tti_ev& tti_ev) bearer_ue_cfg(ue_ev.rnti, 0, ue_ev.bearer_cfg.get()); } - auto* user = ue_tester->get_user_ctxt(ue_ev.rnti); + const ue_ctxt_test* user = ue_tester->get_user_ctxt(ue_ev.rnti); if (user != nullptr and not user->msg4_tti.is_valid() and user->msg3_tti.is_valid() and user->msg3_tti <= tic) { // Msg3 has been received but Msg4 has not been yet transmitted + // Setup default UE config + reconf_user(user->rnti, generate_setup_ue_cfg(sim_args0.default_ue_sim_cfg.ue_cfg)); + + // Schedule RRC Setup and ConRes CE uint32_t pending_dl_new_data = ue_db[ue_ev.rnti].get_pending_dl_new_data(); if (pending_dl_new_data == 0) { uint32_t lcid = RB_ID_SRB0; // Use SRB0 to schedule Msg4 @@ -1000,6 +1013,7 @@ int common_sched_tester::process_tti_events(const tti_ev& tti_ev) if (user->drb_cfg_flag or pending_dl_new_data == 0) { // If RRCSetup finished if (not user->drb_cfg_flag) { + reconf_user(user->rnti, sim_args0.default_ue_sim_cfg.ue_cfg); // setup lcid==drb1 bearer sched::ue_bearer_cfg_t cfg = {}; cfg.direction = ue_bearer_cfg_t::BOTH; diff --git a/srsenb/test/mac/scheduler_test_common.h b/srsenb/test/mac/scheduler_test_common.h index 53779bfa3..10aac52d1 100644 --- a/srsenb/test/mac/scheduler_test_common.h +++ b/srsenb/test/mac/scheduler_test_common.h @@ -243,6 +243,7 @@ public: int sim_cfg(sim_sched_args args); virtual int add_user(uint16_t rnti, const ue_ctxt_test_cfg& ue_cfg_); + virtual int reconf_user(uint16_t rnti, const sched_interface::ue_cfg_t& ue_cfg_); virtual void rem_user(uint16_t rnti); virtual int process_results(); int process_tti_events(const tti_ev& tti_ev); diff --git a/srsenb/test/mac/scheduler_test_rand.cc b/srsenb/test/mac/scheduler_test_rand.cc index 2f728c248..65b2fe9ec 100644 --- a/srsenb/test/mac/scheduler_test_rand.cc +++ b/srsenb/test/mac/scheduler_test_rand.cc @@ -442,10 +442,12 @@ sched_sim_events rand_sim_params(uint32_t nof_ttis) sched_sim_event_generator generator; - sim_gen.sim_args.cell_cfg = {generate_default_cell_cfg(nof_prb)}; - sim_gen.sim_args.default_ue_sim_cfg.periodic_cqi = true; - sim_gen.sim_args.start_tti = 0; - sim_gen.sim_args.sim_log = log_global.get(); + sim_gen.sim_args.cell_cfg = {generate_default_cell_cfg(nof_prb)}; + sim_gen.sim_args.default_ue_sim_cfg.ue_cfg = generate_default_ue_cfg(); + sim_gen.sim_args.default_ue_sim_cfg.periodic_cqi = true; + sim_gen.sim_args.default_ue_sim_cfg.ue_cfg.maxharq_tx = std::uniform_int_distribution<>{1, 5}(srsenb::get_rand_gen()); + sim_gen.sim_args.start_tti = 0; + sim_gen.sim_args.sim_log = log_global.get(); sim_gen.sim_args.sched_args.pdsch_mcs = boolean_dist() ? -1 : std::uniform_int_distribution<>{0, 24}(srsenb::get_rand_gen()); sim_gen.sim_args.sched_args.pusch_mcs = @@ -470,7 +472,8 @@ sched_sim_events rand_sim_params(uint32_t nof_ttis) bool is_prach_tti = srslte_prach_tti_opportunity_config_fdd(sim_gen.sim_args.cell_cfg[CARRIER_IDX].prach_config, tti, -1); if (is_prach_tti and generator.current_users.size() < max_nof_users and srsenb::randf() < P_prach) { - generator.add_new_default_user(connection_dur_dist(srsenb::get_rand_gen())); + generator.add_new_default_user(connection_dur_dist(srsenb::get_rand_gen()), + sim_gen.sim_args.default_ue_sim_cfg.ue_cfg); } generator.step_tti(); } diff --git a/srsenb/test/mac/scheduler_test_utils.h b/srsenb/test/mac/scheduler_test_utils.h index acb8fd7e1..ca676e1a2 100644 --- a/srsenb/test/mac/scheduler_test_utils.h +++ b/srsenb/test/mac/scheduler_test_utils.h @@ -23,6 +23,7 @@ #define SRSLTE_SCHEDULER_TEST_UTILS_H #include "srsenb/hdr/stack/mac/scheduler.h" +#include "srsenb/hdr/stack/upper/common_enb.h" #include "srslte/common/test_common.h" #include "srslte/interfaces/sched_interface.h" #include @@ -75,6 +76,56 @@ inline srsenb::sched_interface::ue_cfg_t generate_default_ue_cfg() return ue_cfg; } +inline srsenb::sched_interface::ue_cfg_t generate_default_ue_cfg2() +{ + srsenb::sched_interface::ue_cfg_t ue_cfg = generate_default_ue_cfg(); + + ue_cfg.ue_bearers[srsenb::RB_ID_SRB1].direction = srsenb::sched_interface::ue_bearer_cfg_t::BOTH; + ue_cfg.ue_bearers[srsenb::RB_ID_SRB2].direction = srsenb::sched_interface::ue_bearer_cfg_t::BOTH; + ue_cfg.ue_bearers[srsenb::RB_ID_DRB1].direction = srsenb::sched_interface::ue_bearer_cfg_t::BOTH; + ue_cfg.ue_bearers[srsenb::RB_ID_DRB1].group = 1; + + return ue_cfg; +} + +inline srsenb::sched_interface::ue_cfg_t generate_rach_ue_cfg(const srsenb::sched_interface::ue_cfg_t& final_cfg) +{ + srsenb::sched_interface::ue_cfg_t cfg = {}; + cfg.ue_bearers[srsenb::RB_ID_SRB0].direction = srsenb::sched_interface::ue_bearer_cfg_t::BOTH; + cfg.supported_cc_list.resize(1); + cfg.supported_cc_list[0].enb_cc_idx = final_cfg.supported_cc_list[0].enb_cc_idx; + cfg.supported_cc_list[0].active = true; + return cfg; +} + +inline srsenb::sched_interface::ue_cfg_t generate_setup_ue_cfg(const srsenb::sched_interface::ue_cfg_t& final_cfg) +{ + srsenb::sched_interface::ue_cfg_t cfg = generate_rach_ue_cfg(final_cfg); + + cfg.maxharq_tx = final_cfg.maxharq_tx; + cfg.ue_bearers[srsenb::RB_ID_SRB1].direction = srsenb::sched_interface::ue_bearer_cfg_t::BOTH; + cfg.dl_cfg.tm = SRSLTE_TM1; + cfg.continuous_pusch = final_cfg.continuous_pusch; + + cfg.dl_cfg.cqi_report = final_cfg.dl_cfg.cqi_report; + cfg.pucch_cfg = final_cfg.pucch_cfg; + cfg.aperiodic_cqi_period = final_cfg.aperiodic_cqi_period; + + return cfg; +} + +inline srsenb::sched_interface::ue_cfg_t generate_reconf_ue_cfg(const srsenb::sched_interface::ue_cfg_t& final_cfg) +{ + srsenb::sched_interface::ue_cfg_t cfg = final_cfg; + + cfg.supported_cc_list.resize(1); + cfg.ue_bearers = {}; + cfg.ue_bearers[srsenb::RB_ID_SRB0] = final_cfg.ue_bearers[srsenb::RB_ID_SRB0]; + cfg.ue_bearers[srsenb::RB_ID_SRB1] = final_cfg.ue_bearers[srsenb::RB_ID_SRB1]; + + return cfg; +} + /***************************** * Event Types ****************************/ @@ -158,7 +209,7 @@ struct sched_sim_event_generator { return jump; } - tti_ev::user_cfg_ev* add_new_default_user(uint32_t duration) + tti_ev::user_cfg_ev* add_new_default_user(uint32_t duration, const srsenb::sched_interface::ue_cfg_t& ue_cfg) { std::vector& user_updates = tti_events[tti_counter].user_updates; user_updates.emplace_back(); @@ -166,10 +217,11 @@ struct sched_sim_event_generator { user.rnti = next_rnti++; // creates a user with one supported CC (PRACH stage) user.ue_sim_cfg.reset(new ue_ctxt_test_cfg{}); - auto& u = current_users[user.rnti]; - u.rnti = user.rnti; - u.tti_start = tti_counter; - u.tti_duration = duration; + auto& u = current_users[user.rnti]; + u.rnti = user.rnti; + u.tti_start = tti_counter; + u.tti_duration = duration; + user.ue_sim_cfg->ue_cfg = ue_cfg; return &user; } @@ -205,7 +257,9 @@ struct sched_sim_event_generator { ue_sim_cfg.ue_cfg = generate_default_ue_cfg(); user->ue_sim_cfg.reset(new ue_ctxt_test_cfg{ue_sim_cfg}); // it should by now have a DRB1. Add other DRBs manually - user->ue_sim_cfg->ue_cfg.ue_bearers[2].direction = srsenb::sched_interface::ue_bearer_cfg_t::BOTH; + user->ue_sim_cfg->ue_cfg.ue_bearers[srsenb::RB_ID_SRB2].direction = srsenb::sched_interface::ue_bearer_cfg_t::BOTH; + user->ue_sim_cfg->ue_cfg.ue_bearers[srsenb::RB_ID_DRB1].direction = srsenb::sched_interface::ue_bearer_cfg_t::BOTH; + user->ue_sim_cfg->ue_cfg.ue_bearers[srsenb::RB_ID_DRB1].group = 1; return user; }