|
|
@ -161,7 +161,8 @@ rrc_nr_cfg_t rrc_nr::update_default_cfg(const rrc_nr_cfg_t& current)
|
|
|
|
int rrc_nr::add_user(uint16_t rnti, const sched_nr_ue_cfg_t& uecfg)
|
|
|
|
int rrc_nr::add_user(uint16_t rnti, const sched_nr_ue_cfg_t& uecfg)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if (users.count(rnti) == 0) {
|
|
|
|
if (users.count(rnti) == 0) {
|
|
|
|
users.insert(std::make_pair(rnti, std::unique_ptr<ue>(new ue(this, rnti, uecfg))));
|
|
|
|
// in the ue ctor, "triggered_by_rach" is set to true so as to start the MSG3 RX TIMEOUT when we create the ue
|
|
|
|
|
|
|
|
users.insert(std::make_pair(rnti, std::unique_ptr<ue>(new ue(this, rnti, uecfg, true))));
|
|
|
|
rlc->add_user(rnti);
|
|
|
|
rlc->add_user(rnti);
|
|
|
|
pdcp->add_user(rnti);
|
|
|
|
pdcp->add_user(rnti);
|
|
|
|
logger.info("Added new user rnti=0x%x", rnti);
|
|
|
|
logger.info("Added new user rnti=0x%x", rnti);
|
|
|
@ -545,11 +546,95 @@ void rrc_nr::sgnb_release_request(uint16_t nr_rnti)
|
|
|
|
Every function in UE class is called from a mutex environment thus does not
|
|
|
|
Every function in UE class is called from a mutex environment thus does not
|
|
|
|
need extra protection.
|
|
|
|
need extra protection.
|
|
|
|
*******************************************************************************/
|
|
|
|
*******************************************************************************/
|
|
|
|
rrc_nr::ue::ue(rrc_nr* parent_, uint16_t rnti_, const sched_nr_ue_cfg_t& uecfg_) :
|
|
|
|
rrc_nr::ue::ue(rrc_nr* parent_, uint16_t rnti_, const sched_nr_ue_cfg_t& uecfg_, bool triggered_by_rach) :
|
|
|
|
parent(parent_), rnti(rnti_), uecfg(uecfg_)
|
|
|
|
parent(parent_), rnti(rnti_), uecfg(uecfg_)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
// Derive UE cfg from rrc_cfg_nr_t
|
|
|
|
// Derive UE cfg from rrc_cfg_nr_t
|
|
|
|
uecfg.phy_cfg.pdcch = parent->cfg.cell_list[0].phy_cell.pdcch;
|
|
|
|
uecfg.phy_cfg.pdcch = parent->cfg.cell_list[0].phy_cell.pdcch;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Set timer for MSG3_RX_TIMEOUT or UE_INACTIVITY_TIMEOUT
|
|
|
|
|
|
|
|
activity_timer = parent->task_sched.get_unique_timer();
|
|
|
|
|
|
|
|
triggered_by_rach ? set_activity_timeout(MSG3_RX_TIMEOUT) : set_activity_timeout(UE_INACTIVITY_TIMEOUT);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void rrc_nr::ue::set_activity_timeout(activity_timeout_type_t type)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
uint32_t deadline_ms = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
|
|
|
|
case MSG3_RX_TIMEOUT:
|
|
|
|
|
|
|
|
// TODO: Retrieve the parameters from somewhere(RRC?) - Currently hardcoded to 100ms
|
|
|
|
|
|
|
|
deadline_ms = 100;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case UE_INACTIVITY_TIMEOUT:
|
|
|
|
|
|
|
|
// TODO: Add a value for the inactivity timeout - currently no activity set this case
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
parent->logger.error("Unknown timeout type %d", type);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Currently we only set the timer for the MSG3_RX_TIMEOUT case
|
|
|
|
|
|
|
|
activity_timer.set(deadline_ms, [this, type](uint32_t tid) { activity_timer_expired(type); });
|
|
|
|
|
|
|
|
parent->logger.debug("Setting timer for %s for rnti=0x%x to %dms", to_string(type).c_str(), rnti, deadline_ms);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
set_activity();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void rrc_nr::ue::set_activity(bool enabled)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
if (rnti == SRSRAN_MRNTI) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (not enabled) {
|
|
|
|
|
|
|
|
if (activity_timer.is_running()) {
|
|
|
|
|
|
|
|
parent->logger.debug("Inactivity timer interrupted for rnti=0x%x", rnti);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
activity_timer.stop();
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// re-start activity timer with current timeout value
|
|
|
|
|
|
|
|
activity_timer.run();
|
|
|
|
|
|
|
|
parent->logger.debug("Activity registered for rnti=0x%x (timeout_value=%dms)", rnti, activity_timer.duration());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void rrc_nr::ue::activity_timer_expired(const activity_timeout_type_t type)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
parent->logger.info("Activity timer for rnti=0x%x expired after %d ms", rnti, activity_timer.time_elapsed());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TODO: Insert a check to ensure the RNTI exists
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
|
|
|
if (parent->s1ap->user_exists(rnti)) {
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
switch (type) {
|
|
|
|
|
|
|
|
case UE_INACTIVITY_TIMEOUT:
|
|
|
|
|
|
|
|
// TODO: Add action to be executed
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MSG3_RX_TIMEOUT:
|
|
|
|
|
|
|
|
// MSG3 timeout, no need to notify S1AP, just remove UE
|
|
|
|
|
|
|
|
parent->rem_user(rnti);
|
|
|
|
|
|
|
|
con_release_result = procedure_result_code::msg3_timeout;
|
|
|
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
// Unhandled activity timeout, just remove UE and log an error
|
|
|
|
|
|
|
|
parent->rem_user(rnti);
|
|
|
|
|
|
|
|
con_release_result = procedure_result_code::activity_timeout;
|
|
|
|
|
|
|
|
parent->logger.error(
|
|
|
|
|
|
|
|
"Unhandled reason for activity timer expiration. rnti=0x%x, cause %d", rnti, static_cast<unsigned>(type));
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#if 0
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
parent->rem_user_thread(rnti);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
state = rrc_nr_state_t::RRC_IDLE;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
std::string rrc_nr::ue::to_string(const activity_timeout_type_t& type)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
constexpr static const char* options[] = {"Msg3 reception", "UE inactivity", "UE reestablishment"};
|
|
|
|
|
|
|
|
return srsran::enum_to_text(options, (uint32_t)activity_timeout_type_t::nulltype, (uint32_t)type);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void rrc_nr::ue::send_connection_setup()
|
|
|
|
void rrc_nr::ue::send_connection_setup()
|
|
|
@ -1289,6 +1374,10 @@ int rrc_nr::ue::handle_sgnb_addition_request(uint16_t eutra_rnti_, const sgnb_ad
|
|
|
|
ack_params.eps_bearer_id = req_params.eps_bearer_id;
|
|
|
|
ack_params.eps_bearer_id = req_params.eps_bearer_id;
|
|
|
|
parent->rrc_eutra->sgnb_addition_ack(eutra_rnti_, ack_params);
|
|
|
|
parent->rrc_eutra->sgnb_addition_ack(eutra_rnti_, ack_params);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// stop activity timer for msg3
|
|
|
|
|
|
|
|
activity_timer.stop();
|
|
|
|
|
|
|
|
parent->logger.debug("SgNB addition req. - Stopping MSG3 activity timer for rnti=0x%x", rnti);
|
|
|
|
|
|
|
|
|
|
|
|
// recognize RNTI as ENDC user
|
|
|
|
// recognize RNTI as ENDC user
|
|
|
|
endc = true;
|
|
|
|
endc = true;
|
|
|
|
eutra_rnti = eutra_rnti_;
|
|
|
|
eutra_rnti = eutra_rnti_;
|
|
|
@ -1302,6 +1391,8 @@ void rrc_nr::ue::crnti_ce_received()
|
|
|
|
if (endc) {
|
|
|
|
if (endc) {
|
|
|
|
// send SgNB addition complete for ENDC users
|
|
|
|
// send SgNB addition complete for ENDC users
|
|
|
|
parent->rrc_eutra->sgnb_addition_complete(eutra_rnti, rnti);
|
|
|
|
parent->rrc_eutra->sgnb_addition_complete(eutra_rnti, rnti);
|
|
|
|
|
|
|
|
activity_timer.stop();
|
|
|
|
|
|
|
|
parent->logger.debug("Received MAC CE-RNTI for 0x%x - stopping MSG3 timer", rnti);
|
|
|
|
|
|
|
|
|
|
|
|
// Add DRB1 to MAC
|
|
|
|
// Add DRB1 to MAC
|
|
|
|
for (auto& drb : cell_group_cfg.rlc_bearer_to_add_mod_list) {
|
|
|
|
for (auto& drb : cell_group_cfg.rlc_bearer_to_add_mod_list) {
|
|
|
|