From ec94819f087de4e9f99a97d35689fb5e198d1057 Mon Sep 17 00:00:00 2001 From: Francisco Paisana Date: Mon, 20 Apr 2020 20:37:15 +0100 Subject: [PATCH] changed mechanism for conres ce scheduling to be controlled by rrc --- .../srslte/interfaces/sched_interface.h | 1 + srsenb/hdr/stack/mac/scheduler_ue.h | 5 +- srsenb/src/stack/mac/scheduler_carrier.cc | 4 +- srsenb/src/stack/mac/scheduler_ue.cc | 102 +++++++++--------- srsenb/src/stack/rrc/rrc.cc | 1 + srsenb/test/mac/scheduler_test_common.cc | 6 +- 6 files changed, 58 insertions(+), 61 deletions(-) diff --git a/lib/include/srslte/interfaces/sched_interface.h b/lib/include/srslte/interfaces/sched_interface.h index 94e8f465d..cc69986fb 100644 --- a/lib/include/srslte/interfaces/sched_interface.h +++ b/lib/include/srslte/interfaces/sched_interface.h @@ -144,6 +144,7 @@ public: std::vector supported_cc_list; ///< list of UE supported CCs. First index for PCell ant_info_ded_t dl_ant_info; bool use_tbs_index_alt = false; + enum conn_state_t { none, ue_id_rx } conn_state = none; }; typedef struct { diff --git a/srsenb/hdr/stack/mac/scheduler_ue.h b/srsenb/hdr/stack/mac/scheduler_ue.h index d42299d0d..6699b27fd 100644 --- a/srsenb/hdr/stack/mac/scheduler_ue.h +++ b/srsenb/hdr/stack/mac/scheduler_ue.h @@ -126,7 +126,6 @@ public: std::pair get_cell_index(uint32_t enb_cc_idx) const; const sched_interface::ue_cfg_t& get_ue_cfg() const { return cfg; } uint32_t get_aggr_level(uint32_t ue_cc_idx, uint32_t nof_bits); - void sched_conres_ce(uint32_t msg3_tti_tx_ul); /******************************************************* * Functions used by scheduler metric objects @@ -267,9 +266,7 @@ private: wait_msg3_ack, conres_sched_pending, conres_sent - } conres_state = ra_state_t::msg3_sched_pending; - uint32_t msg3_pid = 0; - + } conres_state = ra_state_t::msg3_sched_pending; int next_tpc_pusch = 0; int next_tpc_pucch = 0; diff --git a/srsenb/src/stack/mac/scheduler_carrier.cc b/srsenb/src/stack/mac/scheduler_carrier.cc index 09976721a..b8d23d621 100644 --- a/srsenb/src/stack/mac/scheduler_carrier.cc +++ b/srsenb/src/stack/mac/scheduler_carrier.cc @@ -139,8 +139,7 @@ ra_sched::ra_sched(const sched_cell_params_t& cfg_, std::map cc_cfg(&cfg_), log_h(srslte::logmap::get("MAC")), ue_db(&ue_db_) -{ -} +{} // Schedules RAR // On every call to this function, we schedule the oldest RAR which is still within the window. If outside the window we @@ -242,7 +241,6 @@ void ra_sched::ul_sched(sf_sched* sf_dl_sched, sf_sched* sf_msg3_sched) auto user_it = ue_db->find(crnti); if (user_it != ue_db->end() and sf_msg3_sched->alloc_msg3(&user_it->second, msg3grant)) { log_h->debug("SCHED: Queueing Msg3 for rnti=0x%x at tti=%d\n", crnti, sf_msg3_sched->get_tti_tx_ul()); - user_it->second.sched_conres_ce(sf_msg3_sched->get_tti_tx_ul()); } else { log_h->error("SCHED: Failed to allocate Msg3 for rnti=0x%x at tti=%d\n", crnti, sf_msg3_sched->get_tti_tx_ul()); } diff --git a/srsenb/src/stack/mac/scheduler_ue.cc b/srsenb/src/stack/mac/scheduler_ue.cc index 4fe6140aa..8c4fce214 100644 --- a/srsenb/src/stack/mac/scheduler_ue.cc +++ b/srsenb/src/stack/mac/scheduler_ue.cc @@ -107,56 +107,62 @@ void sched_ue::init(uint16_t rnti_, const std::vector& cell void sched_ue::set_cfg(const sched_interface::ue_cfg_t& cfg_) { - { - // for the first configured cc, set it as primary cc - if (cfg.supported_cc_list.empty()) { - uint32_t primary_cc_idx = 0; - if (not cfg_.supported_cc_list.empty()) { - primary_cc_idx = cfg_.supported_cc_list[0].enb_cc_idx; - } else { - Warning("Primary cc idx not provided in scheduler ue_cfg. Defaulting to cc_idx=0\n"); - } - // setup primary cc - main_cc_params = &(*cell_params_list)[primary_cc_idx]; - cell = main_cc_params->cfg.cell; - max_msg3retx = main_cc_params->cfg.maxharq_msg3tx; + // for the first configured cc, set it as primary cc + if (cfg.supported_cc_list.empty()) { + uint32_t primary_cc_idx = 0; + if (not cfg_.supported_cc_list.empty()) { + primary_cc_idx = cfg_.supported_cc_list[0].enb_cc_idx; + } else { + Warning("Primary cc idx not provided in scheduler ue_cfg. Defaulting to cc_idx=0\n"); } + // setup primary cc + main_cc_params = &(*cell_params_list)[primary_cc_idx]; + cell = main_cc_params->cfg.cell; + max_msg3retx = main_cc_params->cfg.maxharq_msg3tx; + } - // update configuration - std::vector prev_supported_cc_list = std::move(cfg.supported_cc_list); - cfg = cfg_; + // update configuration + std::vector prev_supported_cc_list = std::move(cfg.supported_cc_list); + sched::ue_cfg_t::conn_state_t prev_state = cfg.conn_state; + cfg = cfg_; - // update bearer cfgs - for (uint32_t i = 0; i < sched_interface::MAX_LC; ++i) { - set_bearer_cfg_unlocked(i, cfg.ue_bearers[i]); + // update in connection state detected + if (prev_state != cfg.conn_state) { + if (cfg.conn_state == sched_interface::ue_cfg_t::ue_id_rx) { + conres_state = ra_state_t::conres_sched_pending; } + } - // either add a new carrier, or reconfigure existing one - bool scell_activation_state_changed = false; - for (uint32_t ue_idx = 0; ue_idx < cfg.supported_cc_list.size(); ++ue_idx) { - auto& cc_cfg = cfg.supported_cc_list[ue_idx]; - - if (ue_idx >= prev_supported_cc_list.size()) { - // New carrier needs to be added - carriers.emplace_back(cfg, (*cell_params_list)[cc_cfg.enb_cc_idx], rnti, ue_idx); - } else if (cc_cfg.enb_cc_idx != prev_supported_cc_list[ue_idx].enb_cc_idx) { - // One carrier was added in the place of another - carriers[ue_idx] = sched_ue_carrier{cfg, (*cell_params_list)[cc_cfg.enb_cc_idx], rnti, ue_idx}; - if (ue_idx == 0) { - // PCell was changed possibly due to handover. Schedule a new ConRes CE to be transmitted after the Msg3 - conres_state = ra_state_t::conres_sched_pending; - log_h->info("SCHED: PCell has changed. ConRes CE scheduled\n"); - } - } else { - // The SCell internal configuration may have changed - carriers[ue_idx].set_cfg(cfg); + // update bearer cfgs + for (uint32_t i = 0; i < sched_interface::MAX_LC; ++i) { + set_bearer_cfg_unlocked(i, cfg.ue_bearers[i]); + } + + // either add a new carrier, or reconfigure existing one + bool scell_activation_state_changed = false; + for (uint32_t ue_idx = 0; ue_idx < cfg.supported_cc_list.size(); ++ue_idx) { + auto& cc_cfg = cfg.supported_cc_list[ue_idx]; + + if (ue_idx >= prev_supported_cc_list.size()) { + // New carrier needs to be added + carriers.emplace_back(cfg, (*cell_params_list)[cc_cfg.enb_cc_idx], rnti, ue_idx); + } else if (cc_cfg.enb_cc_idx != prev_supported_cc_list[ue_idx].enb_cc_idx) { + // One carrier was added in the place of another + carriers[ue_idx] = sched_ue_carrier{cfg, (*cell_params_list)[cc_cfg.enb_cc_idx], rnti, ue_idx}; + if (ue_idx == 0) { + // PCell was changed possibly due to handover. Schedule a new ConRes CE to be transmitted after the Msg3 + conres_state = ra_state_t::conres_sched_pending; + log_h->info("SCHED: PCell has changed for rnti=0x%x. ConRes CE scheduled\n", rnti); } - scell_activation_state_changed |= carriers[ue_idx].is_active() != cc_cfg.active and ue_idx > 0; - } - if (scell_activation_state_changed) { - pending_ces.emplace_back(srslte::sch_subh::SCELL_ACTIVATION); - log_h->info("SCHED: Enqueueing SCell Activation CMD for rnti=0x%x\n", rnti); + } else { + // The SCell internal configuration may have changed + carriers[ue_idx].set_cfg(cfg); } + scell_activation_state_changed |= carriers[ue_idx].is_active() != cc_cfg.active and ue_idx > 0; + } + if (scell_activation_state_changed) { + pending_ces.emplace_back(srslte::sch_subh::SCELL_ACTIVATION); + log_h->info("SCHED: Enqueueing SCell Activation CMD for rnti=0x%x\n", rnti); } } @@ -308,10 +314,6 @@ void sched_ue::set_ul_crc(srslte::tti_point tti_rx, uint32_t enb_cc_idx, bool cr auto ret = carriers[p.second].harq_ent.set_ul_crc(tti_rx, 0, crc_res); if (not ret.first) { log_h->warning("Received UL CRC for invalid tti_rx=%d\n", (int)tti_rx.to_uint()); - } else { - if (conres_state == ra_state_t::wait_msg3_ack and ret.second == msg3_pid and crc_res) { - conres_state = ra_state_t::conres_sched_pending; - } } } else { log_h->warning("Received UL CRC for invalid cell index %d\n", enb_cc_idx); @@ -1097,12 +1099,6 @@ uint32_t sched_ue::get_aggr_level(uint32_t ue_cc_idx, uint32_t nof_bits) return carriers[ue_cc_idx].get_aggr_level(nof_bits); } -void sched_ue::sched_conres_ce(uint32_t msg3_tti_tx_ul) -{ - msg3_pid = carriers[0].harq_ent.get_ul_harq(msg3_tti_tx_ul)->get_id(); - conres_state = ra_state_t::wait_msg3_ack; -} - void sched_ue::finish_tti(const tti_params_t& tti_params, uint32_t enb_cc_idx) { auto p = get_cell_index(enb_cc_idx); diff --git a/srsenb/src/stack/rrc/rrc.cc b/srsenb/src/stack/rrc/rrc.cc index cc17be40d..558d5ac59 100644 --- a/srsenb/src/stack/rrc/rrc.cc +++ b/srsenb/src/stack/rrc/rrc.cc @@ -1639,6 +1639,7 @@ void rrc::ue::send_connection_setup(bool is_setup) current_sched_ue_cfg.pucch_cfg.n_rb_2 = sib2.rr_cfg_common.pucch_cfg_common.nrb_cqi; current_sched_ue_cfg.pucch_cfg.N_pucch_1 = sib2.rr_cfg_common.pucch_cfg_common.n1_pucch_an; current_sched_ue_cfg.dl_ant_info = srslte::make_ant_info_ded(phy_cfg->ant_info.explicit_value()); + current_sched_ue_cfg.conn_state = sched_interface::ue_cfg_t::ue_id_rx; // Configure MAC parent->mac->ue_cfg(rnti, ¤t_sched_ue_cfg); diff --git a/srsenb/test/mac/scheduler_test_common.cc b/srsenb/test/mac/scheduler_test_common.cc index 038cdcf91..75e138aff 100644 --- a/srsenb/test/mac/scheduler_test_common.cc +++ b/srsenb/test/mac/scheduler_test_common.cc @@ -871,7 +871,7 @@ int common_sched_tester::process_tti_events(const tti_ev& tti_ev) rem_user(ue_ev.rnti); } - // configure carriers + // configure bearers if (ue_ev.bearer_cfg != nullptr) { CONDERROR(not ue_tester->user_exists(ue_ev.rnti), "User rnti=0x%x does not exist\n", ue_ev.rnti); // TODO: Instantiate more bearers @@ -886,6 +886,10 @@ int common_sched_tester::process_tti_events(const tti_ev& tti_ev) if (pending_dl_new_data == 0) { uint32_t lcid = 0; // Use SRB0 to schedule Msg4 dl_rlc_buffer_state(ue_ev.rnti, lcid, 50, 0); + auto current_ue_cfg = *get_current_ue_cfg(ue_ev.rnti); + current_ue_cfg.conn_state = ue_cfg_t::ue_id_rx; + TESTASSERT(ue_cfg(ue_ev.rnti, current_ue_cfg) == SRSLTE_SUCCESS); + ue_tester->user_reconf(ue_ev.rnti, current_ue_cfg); } else { // Let SRB0 Msg4 get fully transmitted }