decoupled srsenb rrc ue mac controller from the rrc::ue class

This commit is contained in:
Francisco Paisana 2021-01-11 11:29:05 +00:00
parent 2866886ade
commit 434bdfca68
5 changed files with 88 additions and 66 deletions

View File

@ -13,17 +13,25 @@
#ifndef SRSLTE_MAC_CONTROLLER_H
#define SRSLTE_MAC_CONTROLLER_H
#include "rrc_ue.h"
#include "rrc_bearer_cfg.h"
#include "rrc_cell_cfg.h"
#include "srslte/interfaces/sched_interface.h"
#include <bitset>
namespace srsenb {
class rrc::ue::mac_controller
class mac_controller
{
using ue_cfg_t = sched_interface::ue_cfg_t;
public:
mac_controller(rrc::ue* rrc_ue, const ue_cfg_t& sched_ue_cfg);
mac_controller(uint16_t rnti_,
const ue_cell_ded_list& ue_cell_list_,
const bearer_cfg_handler& bearer_list_,
const rrc_cfg_t& rrc_cfg_,
mac_interface_rrc* mac_,
const enb_cell_common_list& cell_common_list,
const ue_cfg_t& sched_ue_cfg);
// Handling of Msg4
int handle_con_setup(const asn1::rrc::rrc_conn_setup_r8_ies_s& conn_setup);
@ -56,10 +64,14 @@ private:
int apply_basic_conn_cfg(const asn1::rrc::rr_cfg_ded_s& rr_cfg);
void apply_current_bearers_cfg();
srslte::log_ref log_h;
rrc_cfg_t* rrc_cfg = nullptr;
rrc::ue* rrc_ue = nullptr;
mac_interface_rrc* mac = nullptr;
srslte::log_ref log_h;
uint16_t rnti;
const ue_cell_ded_list& ue_cell_list;
const bearer_cfg_handler& bearer_list;
const rrc_cfg_t* rrc_cfg = nullptr;
mac_interface_rrc* mac = nullptr;
const enb_cell_common_list& cell_common_list;
/// UE configuration currently present at the MAC, including any transient disabling of bearers/scells
ue_cfg_t current_sched_ue_cfg = {};
/// UE configuration once the RRC config procedure (e.g. Reconfiguration) is complete

View File

@ -13,6 +13,7 @@
#ifndef SRSLTE_RRC_UE_H
#define SRSLTE_RRC_UE_H
#include "mac_controller.h"
#include "rrc.h"
namespace srsenb {
@ -132,8 +133,8 @@ private:
bearer_cfg_handler bearer_list;
security_cfg_handler ue_security_cfg;
class mac_controller;
std::unique_ptr<mac_controller> mac_ctrl;
// controllers
mac_controller mac_ctrl;
///< Helper to access a cell cfg based on ue_cc_idx
enb_cell_common* get_ue_cc_cfg(uint32_t ue_cc_idx);

View File

@ -11,8 +11,8 @@
*/
#include "srsenb/hdr/stack/rrc/mac_controller.h"
#include "srsenb/hdr/stack/upper/common_enb.h"
#include "srslte/asn1/rrc_utils.h"
#include "srslte/interfaces/sched_interface.h"
namespace srsenb {
@ -75,11 +75,20 @@ void ue_cfg_apply_capabilities(ue_cfg_t& ue_cfg, const rrc_cfg_t& rrc_cfg, const
* MAC Controller class
**************************/
rrc::ue::mac_controller::mac_controller(rrc::ue* rrc_ue_, const ue_cfg_t& sched_ue_cfg) :
mac_controller::mac_controller(uint16_t rnti_,
const ue_cell_ded_list& ue_cell_list_,
const bearer_cfg_handler& bearer_list_,
const rrc_cfg_t& rrc_cfg_,
mac_interface_rrc* mac_,
const enb_cell_common_list& cell_common_list_,
const ue_cfg_t& sched_ue_cfg) :
log_h("RRC"),
rrc_ue(rrc_ue_),
rrc_cfg(&rrc_ue_->parent->cfg),
mac(rrc_ue_->parent->mac),
rnti(rnti_),
ue_cell_list(ue_cell_list_),
bearer_list(bearer_list_),
rrc_cfg(&rrc_cfg_),
mac(mac_),
cell_common_list(cell_common_list_),
current_sched_ue_cfg(sched_ue_cfg)
{
if (current_sched_ue_cfg.supported_cc_list.empty() or not current_sched_ue_cfg.supported_cc_list[0].active) {
@ -90,28 +99,28 @@ rrc::ue::mac_controller::mac_controller(rrc::ue* rrc_ue_, const ue_cfg_t& sched_
}
}
int rrc::ue::mac_controller::handle_con_setup(const asn1::rrc::rrc_conn_setup_r8_ies_s& conn_setup)
int mac_controller::handle_con_setup(const asn1::rrc::rrc_conn_setup_r8_ies_s& conn_setup)
{
return apply_basic_conn_cfg(conn_setup.rr_cfg_ded);
}
int rrc::ue::mac_controller::handle_con_reest(const asn1::rrc::rrc_conn_reest_r8_ies_s& conn_reest)
int mac_controller::handle_con_reest(const asn1::rrc::rrc_conn_reest_r8_ies_s& conn_reest)
{
return apply_basic_conn_cfg(conn_reest.rr_cfg_ded);
}
//! Called when ConnectionSetup or Reestablishment is rejected (e.g. no MME connection)
void rrc::ue::mac_controller::handle_con_reject()
void mac_controller::handle_con_reject()
{
if (not crnti_set) {
crnti_set = true;
// Need to schedule ConRes CE for UE to see the Reject message
mac->ue_set_crnti(rrc_ue->rnti, rrc_ue->rnti, &current_sched_ue_cfg);
mac->ue_set_crnti(rnti, rnti, &current_sched_ue_cfg);
}
}
/// Called in case of intra-eNB Handover to activate the new PCell for the reception of the RRC Reconf Complete message
int rrc::ue::mac_controller::handle_crnti_ce(uint32_t temp_crnti)
int mac_controller::handle_crnti_ce(uint32_t temp_crnti)
{
// Change PCell and add SCell configurations to MAC/Scheduler
current_sched_ue_cfg = next_sched_ue_cfg;
@ -129,12 +138,12 @@ int rrc::ue::mac_controller::handle_crnti_ce(uint32_t temp_crnti)
current_sched_ue_cfg.ue_bearers[i] = next_sched_ue_cfg.ue_bearers[i];
}
return mac->ue_set_crnti(temp_crnti, rrc_ue->rnti, &current_sched_ue_cfg);
return mac->ue_set_crnti(temp_crnti, rnti, &current_sched_ue_cfg);
}
int rrc::ue::mac_controller::apply_basic_conn_cfg(const asn1::rrc::rr_cfg_ded_s& rr_cfg)
int mac_controller::apply_basic_conn_cfg(const asn1::rrc::rr_cfg_ded_s& rr_cfg)
{
const auto* pcell = rrc_ue->ue_cell_list.get_ue_cc_idx(UE_PCELL_CC_IDX);
const auto* pcell = ue_cell_list.get_ue_cc_idx(UE_PCELL_CC_IDX);
// Set static config params
current_sched_ue_cfg.maxharq_tx = rrc_cfg->mac_cnfg.ul_sch_cfg.max_harq_tx.to_number();
@ -173,32 +182,32 @@ int rrc::ue::mac_controller::apply_basic_conn_cfg(const asn1::rrc::rr_cfg_ded_s&
// Configure MAC
// In case of RRC Connection Setup/Reest message (Msg4), we need to resolve the contention by sending a ConRes CE
mac->phy_config_enabled(rrc_ue->rnti, false);
mac->phy_config_enabled(rnti, false);
crnti_set = true;
return mac->ue_set_crnti(rrc_ue->rnti, rrc_ue->rnti, &current_sched_ue_cfg);
return mac->ue_set_crnti(rnti, rnti, &current_sched_ue_cfg);
}
void rrc::ue::mac_controller::handle_con_setup_complete()
void mac_controller::handle_con_setup_complete()
{
// Acknowledge Dedicated Configuration
mac->phy_config_enabled(rrc_ue->rnti, true);
mac->phy_config_enabled(rnti, true);
}
void rrc::ue::mac_controller::handle_con_reest_complete()
void mac_controller::handle_con_reest_complete()
{
// Acknowledge Dedicated Configuration
mac->phy_config_enabled(rrc_ue->rnti, true);
mac->phy_config_enabled(rnti, true);
}
void rrc::ue::mac_controller::handle_con_reconf(const asn1::rrc::rrc_conn_recfg_r8_ies_s& conn_recfg,
const srslte::rrc_ue_capabilities_t& uecaps)
void mac_controller::handle_con_reconf(const asn1::rrc::rrc_conn_recfg_r8_ies_s& conn_recfg,
const srslte::rrc_ue_capabilities_t& uecaps)
{
ue_cfg_apply_conn_reconf(current_sched_ue_cfg, conn_recfg, *rrc_cfg);
// Store MAC updates that are applied once RRCReconfigurationComplete is received
next_sched_ue_cfg = current_sched_ue_cfg;
ue_cfg_apply_capabilities(next_sched_ue_cfg, *rrc_cfg, uecaps);
ue_cfg_apply_reconf_complete_updates(next_sched_ue_cfg, conn_recfg, rrc_ue->ue_cell_list);
ue_cfg_apply_reconf_complete_updates(next_sched_ue_cfg, conn_recfg, ue_cell_list);
// Temporarily freeze new allocations for DRBs (SRBs are needed to send RRC Reconf Message)
set_drb_activation(false);
@ -207,7 +216,7 @@ void rrc::ue::mac_controller::handle_con_reconf(const asn1::rrc::rrc_conn_recfg_
update_mac(proc_stage_t::config_tx);
}
void rrc::ue::mac_controller::handle_con_reconf_complete()
void mac_controller::handle_con_reconf_complete()
{
current_sched_ue_cfg = next_sched_ue_cfg;
@ -218,10 +227,10 @@ void rrc::ue::mac_controller::handle_con_reconf_complete()
update_mac(proc_stage_t::config_complete);
}
void rrc::ue::mac_controller::apply_current_bearers_cfg()
void mac_controller::apply_current_bearers_cfg()
{
// Configure DRBs
const drb_to_add_mod_list_l& drbs = rrc_ue->bearer_list.get_established_drbs();
const drb_to_add_mod_list_l& drbs = bearer_list.get_established_drbs();
for (const drb_to_add_mod_s& drb : drbs) {
auto& bcfg = current_sched_ue_cfg.ue_bearers[drb.lc_ch_id];
bcfg = {};
@ -237,34 +246,34 @@ void rrc::ue::mac_controller::apply_current_bearers_cfg()
}
}
void rrc::ue::mac_controller::handle_target_enb_ho_cmd(const asn1::rrc::rrc_conn_recfg_r8_ies_s& conn_recfg,
const srslte::rrc_ue_capabilities_t& uecaps)
void mac_controller::handle_target_enb_ho_cmd(const asn1::rrc::rrc_conn_recfg_r8_ies_s& conn_recfg,
const srslte::rrc_ue_capabilities_t& uecaps)
{
ue_cfg_apply_conn_reconf(current_sched_ue_cfg, conn_recfg, *rrc_cfg);
next_sched_ue_cfg = current_sched_ue_cfg;
ue_cfg_apply_capabilities(next_sched_ue_cfg, *rrc_cfg, uecaps);
ue_cfg_apply_reconf_complete_updates(next_sched_ue_cfg, conn_recfg, rrc_ue->ue_cell_list);
ue_cfg_apply_reconf_complete_updates(next_sched_ue_cfg, conn_recfg, ue_cell_list);
// Temporarily freeze new allocations for DRBs (SRBs are needed to send RRC Reconf Message)
set_drb_activation(false);
// Apply changes to MAC scheduler
mac->ue_cfg(rrc_ue->rnti, &current_sched_ue_cfg);
mac->phy_config_enabled(rrc_ue->rnti, false);
mac->ue_cfg(rnti, &current_sched_ue_cfg);
mac->phy_config_enabled(rnti, false);
}
void rrc::ue::mac_controller::handle_intraenb_ho_cmd(const asn1::rrc::rrc_conn_recfg_r8_ies_s& conn_recfg,
const srslte::rrc_ue_capabilities_t& uecaps)
void mac_controller::handle_intraenb_ho_cmd(const asn1::rrc::rrc_conn_recfg_r8_ies_s& conn_recfg,
const srslte::rrc_ue_capabilities_t& uecaps)
{
next_sched_ue_cfg = current_sched_ue_cfg;
next_sched_ue_cfg.supported_cc_list.resize(1);
next_sched_ue_cfg.supported_cc_list[0].active = true;
next_sched_ue_cfg.supported_cc_list[0].enb_cc_idx =
rrc_ue->parent->cell_common_list->get_pci(conn_recfg.mob_ctrl_info.target_pci)->enb_cc_idx;
cell_common_list.get_pci(conn_recfg.mob_ctrl_info.target_pci)->enb_cc_idx;
ue_cfg_apply_conn_reconf(next_sched_ue_cfg, conn_recfg, *rrc_cfg);
ue_cfg_apply_capabilities(next_sched_ue_cfg, *rrc_cfg, uecaps);
ue_cfg_apply_reconf_complete_updates(next_sched_ue_cfg, conn_recfg, rrc_ue->ue_cell_list);
ue_cfg_apply_reconf_complete_updates(next_sched_ue_cfg, conn_recfg, ue_cell_list);
// Freeze SCells
// NOTE: this avoids that the UE receives an HOCmd retx from target cell and do an incorrect RLC-level concatenation
@ -281,7 +290,7 @@ void rrc::ue::mac_controller::handle_intraenb_ho_cmd(const asn1::rrc::rrc_conn_r
update_mac(mac_controller::config_tx);
}
void rrc::ue::mac_controller::handle_ho_prep(const asn1::rrc::ho_prep_info_r8_ies_s& ho_prep)
void mac_controller::handle_ho_prep(const asn1::rrc::ho_prep_info_r8_ies_s& ho_prep)
{
// TODO: Apply configuration in ho_prep as a base
if (ho_prep.as_cfg.source_rr_cfg.srb_to_add_mod_list_present) {
@ -289,28 +298,28 @@ void rrc::ue::mac_controller::handle_ho_prep(const asn1::rrc::ho_prep_info_r8_ie
}
}
void rrc::ue::mac_controller::set_scell_activation(const std::bitset<SRSLTE_MAX_CARRIERS>& scell_mask)
void mac_controller::set_scell_activation(const std::bitset<SRSLTE_MAX_CARRIERS>& scell_mask)
{
for (uint32_t i = 1; i < current_sched_ue_cfg.supported_cc_list.size(); ++i) {
current_sched_ue_cfg.supported_cc_list[i].active = scell_mask[i];
}
}
void rrc::ue::mac_controller::set_drb_activation(bool active)
void mac_controller::set_drb_activation(bool active)
{
for (const drb_to_add_mod_s& drb : rrc_ue->bearer_list.get_established_drbs()) {
for (const drb_to_add_mod_s& drb : bearer_list.get_established_drbs()) {
current_sched_ue_cfg.ue_bearers[drb.drb_id + rb_id_t::RB_ID_SRB2].direction =
active ? sched_interface::ue_bearer_cfg_t::BOTH : sched_interface::ue_bearer_cfg_t::IDLE;
}
}
void rrc::ue::mac_controller::update_mac(proc_stage_t stage)
void mac_controller::update_mac(proc_stage_t stage)
{
// Apply changes to MAC scheduler
mac->ue_cfg(rrc_ue->rnti, &current_sched_ue_cfg);
mac->ue_cfg(rnti, &current_sched_ue_cfg);
if (stage != proc_stage_t::other) {
// Acknowledge Dedicated Configuration
mac->phy_config_enabled(rrc_ue->rnti, stage == proc_stage_t::config_complete);
mac->phy_config_enabled(rnti, stage == proc_stage_t::config_complete);
}
}

View File

@ -573,8 +573,8 @@ void rrc::ue::rrc_mobility::s1_source_ho_st::send_ho_cmd(wait_ho_req_ack_st& s,
}
// Disable DRBs
parent_fsm()->rrc_ue->mac_ctrl->set_drb_activation(false);
parent_fsm()->rrc_ue->mac_ctrl->update_mac(mac_controller::proc_stage_t::other);
parent_fsm()->rrc_ue->mac_ctrl.set_drb_activation(false);
parent_fsm()->rrc_ue->mac_ctrl.update_mac(mac_controller::proc_stage_t::other);
/* Send HO Command to UE */
if (not parent_fsm()->rrc_ue->send_dl_dcch(&dl_dcch_msg)) {
@ -681,7 +681,7 @@ void rrc::ue::rrc_mobility::handle_ho_req(idle_st& s, const ho_req_rx_ev& ho_req
rrc_ue->apply_pdcp_srb_updates(rrc_ue->current_ue_cfg.rr_cfg);
rrc_ue->apply_rlc_rb_updates(rrc_ue->current_ue_cfg.rr_cfg);
// Update MAC
rrc_ue->mac_ctrl->handle_target_enb_ho_cmd(recfg_r8, rrc_ue->ue_capabilities);
rrc_ue->mac_ctrl.handle_target_enb_ho_cmd(recfg_r8, rrc_ue->ue_capabilities);
// Apply PHY updates
rrc_ue->apply_reconf_phy_config(recfg_r8, true);
@ -763,7 +763,7 @@ bool rrc::ue::rrc_mobility::apply_ho_prep_cfg(const ho_prep_info_r8_ies_s& ho
rrc_ue->current_ue_cfg.meas_cfg = ho_prep.as_cfg.source_meas_cfg;
// Save source UE MAC configuration as a base
rrc_ue->mac_ctrl->handle_ho_prep(ho_prep);
rrc_ue->mac_ctrl.handle_ho_prep(ho_prep);
return true;
}
@ -861,7 +861,7 @@ void rrc::ue::rrc_mobility::intraenb_ho_st::enter(rrc_mobility* f, const ho_meas
rrc_conn_recfg_r8_ies_s& reconf_r8 = dl_dcch_msg.msg.c1().rrc_conn_recfg().crit_exts.c1().rrc_conn_recfg_r8();
// Apply changes to the MAC scheduler
f->rrc_ue->mac_ctrl->handle_intraenb_ho_cmd(reconf_r8, f->rrc_ue->ue_capabilities);
f->rrc_ue->mac_ctrl.handle_intraenb_ho_cmd(reconf_r8, f->rrc_ue->ue_capabilities);
f->rrc_ue->apply_setup_phy_common(f->rrc_enb->cfg.sibs[1].sib2().rr_cfg_common, false);
f->rrc_ue->apply_reconf_phy_config(reconf_r8, false);
@ -885,7 +885,7 @@ void rrc::ue::rrc_mobility::handle_crnti_ce(intraenb_ho_st& s, const user_crnti_
rrc_enb->rlc->reestablish(rrc_ue->rnti);
// Change PCell in MAC/Scheduler
rrc_ue->mac_ctrl->handle_crnti_ce(ev.temp_crnti);
rrc_ue->mac_ctrl.handle_crnti_ce(ev.temp_crnti);
// finally apply new phy changes
rrc_enb->phy->set_config(rrc_ue->rnti, rrc_ue->phy_rrc_dedicated_list);

View File

@ -37,9 +37,9 @@ rrc::ue::ue(rrc* outer_rrc, uint16_t rnti_, const sched_interface::ue_cfg_t& sch
phy_rrc_dedicated_list(sched_ue_cfg.supported_cc_list.size()),
ue_cell_list(parent->cfg, *outer_rrc->cell_res_list, *outer_rrc->cell_common_list),
bearer_list(rnti_, parent->cfg),
ue_security_cfg(parent->cfg)
ue_security_cfg(parent->cfg),
mac_ctrl(rnti, ue_cell_list, bearer_list, parent->cfg, parent->mac, *parent->cell_common_list, sched_ue_cfg)
{
mac_ctrl.reset(new mac_controller{this, sched_ue_cfg});
// Allocate cell and PUCCH resources
if (ue_cell_list.add_cell(sched_ue_cfg.supported_cc_list[0].enb_cc_idx) == nullptr) {
@ -277,7 +277,7 @@ void rrc::ue::send_connection_setup()
fill_rr_cfg_ded_setup(rr_cfg, parent->cfg, ue_cell_list);
// Apply ConnectionSetup Configuration to MAC scheduler
mac_ctrl->handle_con_setup(setup_r8);
mac_ctrl.handle_con_setup(setup_r8);
// Add SRBs/DRBs, and configure RLC+PDCP
apply_pdcp_srb_updates(setup_r8.rr_cfg_ded);
@ -307,7 +307,7 @@ void rrc::ue::handle_rrc_con_setup_complete(rrc_conn_setup_complete_s* msg, srsl
memcpy(pdu->msg, msg_r8->ded_info_nas.data(), pdu->N_bytes);
// Signal MAC scheduler that configuration was successful
mac_ctrl->handle_con_setup_complete();
mac_ctrl.handle_con_setup_complete();
asn1::s1ap::rrc_establishment_cause_e s1ap_cause;
s1ap_cause.value = (asn1::s1ap::rrc_establishment_cause_opts::options)establishment_cause.value;
@ -324,7 +324,7 @@ void rrc::ue::handle_rrc_con_setup_complete(rrc_conn_setup_complete_s* msg, srsl
void rrc::ue::send_connection_reject()
{
mac_ctrl->handle_con_reject();
mac_ctrl.handle_con_reject();
dl_ccch_msg_s dl_ccch_msg;
dl_ccch_msg.msg.set_c1().set_rrc_conn_reject().crit_exts.set_c1().set_rrc_conn_reject_r8().wait_time = 10;
@ -421,7 +421,7 @@ void rrc::ue::send_connection_reest(uint8_t ncc)
reest_r8.next_hop_chaining_count = ncc;
// Apply ConnectionReest Configuration to MAC scheduler
mac_ctrl->handle_con_reest(reest_r8);
mac_ctrl.handle_con_reest(reest_r8);
// Add SRBs/DRBs, and configure RLC+PDCP
apply_pdcp_srb_updates(rr_cfg);
@ -451,7 +451,7 @@ void rrc::ue::handle_rrc_con_reest_complete(rrc_conn_reest_complete_s* msg, srsl
parent->s1ap->user_mod(old_reest_rnti, rnti);
// Signal MAC scheduler that configuration was successful
mac_ctrl->handle_con_reest_complete();
mac_ctrl.handle_con_reest_complete();
// Activate security for SRB1
parent->pdcp->config_security(rnti, RB_ID_SRB1, ue_security_cfg.get_as_sec_cfg());
@ -473,7 +473,7 @@ void rrc::ue::handle_rrc_con_reest_complete(rrc_conn_reest_complete_s* msg, srsl
void rrc::ue::send_connection_reest_rej()
{
mac_ctrl->handle_con_reject();
mac_ctrl.handle_con_reject();
dl_ccch_msg_s dl_ccch_msg;
dl_ccch_msg.msg.set_c1().set_rrc_conn_reest_reject().crit_exts.set_rrc_conn_reest_reject_r8();
@ -520,7 +520,7 @@ void rrc::ue::send_connection_reconf(srslte::unique_byte_buffer_t pdu, bool phy_
apply_rlc_rb_updates(recfg_r8.rr_cfg_ded);
// UE MAC scheduler updates
mac_ctrl->handle_con_reconf(recfg_r8, ue_capabilities);
mac_ctrl.handle_con_reconf(recfg_r8, ue_capabilities);
// Reuse same PDU
if (pdu != nullptr) {
@ -546,7 +546,7 @@ void rrc::ue::handle_rrc_reconf_complete(rrc_conn_recfg_complete_s* msg, srslte:
}
// Activate SCells and bearers in the MAC scheduler that were advertised in the RRC Reconf message
mac_ctrl->handle_con_reconf_complete();
mac_ctrl.handle_con_reconf_complete();
// If performing handover, signal its completion
mobility_handler->trigger(*msg);