diff --git a/openair2/LAYER2/NR_MAC_gNB/config.c b/openair2/LAYER2/NR_MAC_gNB/config.c index a04ffad88d..9710a90518 100644 --- a/openair2/LAYER2/NR_MAC_gNB/config.c +++ b/openair2/LAYER2/NR_MAC_gNB/config.c @@ -443,36 +443,6 @@ static void config_common(gNB_MAC_INST *nrmac, int pdsch_AntennaPorts, int pusch } } -int nr_mac_enable_ue_rrc_processing_timer(module_id_t Mod_idP, rnti_t rnti, NR_SubcarrierSpacing_t subcarrierSpacing, uint32_t rrc_reconfiguration_delay) -{ - if (rrc_reconfiguration_delay == 0) { - return -1; - } - - gNB_MAC_INST *nrmac = RC.nrmac[Mod_idP]; - NR_SCHED_LOCK(&nrmac->sched_lock); - - NR_UE_info_t *UE_info = find_nr_UE(&nrmac->UE_info,rnti); - if (!UE_info) { - LOG_W(NR_MAC, "Could not find UE for RNTI 0x%04x\n", rnti); - NR_SCHED_UNLOCK(&nrmac->sched_lock); - return -1; - } - NR_UE_sched_ctrl_t *sched_ctrl = &UE_info->UE_sched_ctrl; - const uint16_t sl_ahead = nrmac->if_inst->sl_ahead; - sched_ctrl->rrc_processing_timer = (rrc_reconfiguration_delay<rnti, rrc_reconfiguration_delay); - - // it might happen that timing advance command should be sent during the RRC - // processing timer. To prevent this, set a variable as if we would have just - // sent it. This way, another TA command will for sure be sent in some - // frames, after RRC processing timer. - sched_ctrl->ta_frame = (nrmac->frame - 1 + 1024) % 1024; - - NR_SCHED_UNLOCK(&nrmac->sched_lock); - return 0; -} - void nr_mac_config_scc(gNB_MAC_INST *nrmac, NR_ServingCellConfigCommon_t *scc, const nr_mac_config_t *config) { DevAssert(nrmac != NULL); @@ -626,28 +596,24 @@ bool nr_mac_prepare_ra_ue(gNB_MAC_INST *nrmac, uint32_t rnti, NR_CellGroupConfig return true; } -bool nr_mac_update_cellgroup(gNB_MAC_INST *nrmac, uint32_t rnti, NR_CellGroupConfig_t *CellGroup) +/* Prepare a new CellGroupConfig to be applied for this UE. We cannot + * immediatly apply it, as we have to wait for the reconfiguration through RRC. + * This function sets up everything to apply the reconfiguration. Later, we + * will trigger the timer with nr_mac_enable_ue_rrc_processing_timer(); upon + * expiry nr_mac_apply_cellgroup() will apply the CellGroupConfig (radio config + * etc). */ +bool nr_mac_prepare_cellgroup_update(gNB_MAC_INST *nrmac, NR_UE_info_t *UE, NR_CellGroupConfig_t *CellGroup) { DevAssert(nrmac != NULL); + DevAssert(UE != NULL); + DevAssert(CellGroup != NULL); + /* we assume that this function is mutex-protected from outside */ NR_SCHED_ENSURE_LOCKED(&nrmac->sched_lock); - DevAssert(CellGroup != NULL); - - NR_UE_info_t *UE = find_nr_UE(&nrmac->UE_info, rnti); - AssertFatal(UE != NULL, "Can't find UE %04x for CellGroup update\n", rnti); - - /* copy CellGroup by calling asn1c encode this is a temporary hack to avoid the gNB having a pointer to RRC CellGroup structure - * (otherwise it would be applied to early) - * TODO remove once we have a proper implementation */ - UE->enc_rval = uper_encode_to_buffer(&asn_DEF_NR_CellGroupConfig, NULL, (void *)CellGroup, UE->cg_buf, 32768); - - if (UE->enc_rval.encoded == -1) { - LOG_E(NR_MAC, "ASN1 message CellGroupConfig encoding failed (%s, %lu)!\n", UE->enc_rval.failed_type->name, UE->enc_rval.encoded); - exit(1); - } - process_CellGroup(CellGroup, UE); + UE->reconfigCellGroup = CellGroup; + UE->expect_reconfiguration = true; return true; } diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c index 19a1a0d34b..71dd7731e5 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_RA.c @@ -1893,14 +1893,9 @@ static void nr_check_Msg4_Ack(module_id_t module_id, int CC_id, frame_t frame, s // Pause scheduling according to: // 3GPP TS 38.331 Section 12 Table 12.1-1: UE performance requirements for RRC procedures for UEs - const NR_ServingCellConfig_t *servingCellConfig = UE->CellGroup && UE->CellGroup->spCellConfig ? UE->CellGroup->spCellConfig->spCellConfigDedicated : NULL; - uint32_t delay_ms = servingCellConfig && servingCellConfig->downlinkBWP_ToAddModList ? - NR_RRC_SETUP_DELAY_MS + NR_RRC_BWP_SWITCHING_DELAY_MS : NR_RRC_SETUP_DELAY_MS; - - sched_ctrl->rrc_processing_timer = (delay_ms << ra->DL_BWP.scs); - LOG_I(NR_MAC, "(%d.%d) Activating RRC processing timer for UE %04x with %d ms\n", frame, slot, UE->rnti, delay_ms); + nr_mac_enable_ue_rrc_processing_timer(RC.nrmac[module_id], UE, false); } else { - LOG_I(NR_MAC, "(ue rnti 0x%04x) RA Procedure failed at Msg4!\n", ra->rnti); + LOG_I(NR_MAC, "%4d.%2d UE %04x: RA Procedure failed at Msg4!\n", frame, slot, ra->rnti); } nr_clear_ra_proc(module_id, CC_id, frame, ra); diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c index 9955b240b3..07c8da3092 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_primitives.c @@ -1946,6 +1946,8 @@ int get_nrofHARQ_ProcessesForPDSCH(e_NR_PDSCH_ServingCellConfig__nrofHARQ_Proces void delete_nr_ue_data(NR_UE_info_t *UE, NR_COMMON_channels_t *ccPtr, uid_allocator_t *uia) { + ASN_STRUCT_FREE(asn_DEF_NR_CellGroupConfig, UE->CellGroup); + ASN_STRUCT_FREE(asn_DEF_NR_CellGroupConfig, UE->reconfigCellGroup); NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; destroy_nr_list(&sched_ctrl->available_dl_harq); destroy_nr_list(&sched_ctrl->feedback_dl_harq); @@ -2727,20 +2729,80 @@ void nr_csirs_scheduling(int Mod_idP, frame_t frame, sub_frame_t slot, int n_slo } } +static void nr_mac_apply_cellgroup(gNB_MAC_INST *mac, NR_UE_info_t *UE, frame_t frame, sub_frame_t slot) +{ + LOG_I(NR_MAC, "%4d.%2d RNTI %04x: RRC processing timer expired\n", frame, slot, UE->rnti); + + /* check if there is a new CellGroupConfig to be applied */ + if (UE->apply_cellgroup && UE->reconfigCellGroup != NULL) { + LOG_I(NR_MAC, "%4d.%2d RNTI %04x: Apply CellGroupConfig after RRC processing timer expiry\n", frame, slot, UE->rnti); + ASN_STRUCT_FREE(asn_DEF_NR_CellGroupConfig, UE->CellGroup); + UE->CellGroup = UE->reconfigCellGroup; + UE->reconfigCellGroup = NULL; + UE->apply_cellgroup = false; + + if (LOG_DEBUGFLAG(DEBUG_ASN1)) + xer_fprint(stdout, &asn_DEF_NR_CellGroupConfig, (const void *)UE->CellGroup); + } + + NR_ServingCellConfigCommon_t *scc = mac->common_channels[0].ServingCellConfigCommon; + + /* Note! we already did process_CellGroup(), so no need to do this again */ + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; + configure_UE_BWP(mac, scc, sched_ctrl, NULL, UE, -1, -1); + + reset_srs_stats(UE); + + if (get_softmodem_params()->sa) { + // add all available DL HARQ processes for this UE in SA + create_dl_harq_list(sched_ctrl, UE->current_DL_BWP.pdsch_servingcellconfig); + } +} + +int nr_mac_enable_ue_rrc_processing_timer(gNB_MAC_INST *mac, NR_UE_info_t *UE, bool apply_cellgroup) +{ + DevAssert(mac != NULL); + DevAssert(UE != NULL); + NR_SCHED_ENSURE_LOCKED(&mac->sched_lock); + + const uint16_t sl_ahead = mac->if_inst->sl_ahead; + // TODO: account for BWP switch with NR_RRC_BWP_SWITCHING_DELAY_MS + int delay = NR_RRC_RECONFIGURATION_DELAY_MS; + NR_SubcarrierSpacing_t scs = UE->current_UL_BWP.scs; + + UE->UE_sched_ctrl.rrc_processing_timer = (delay << scs) + sl_ahead; + UE->apply_cellgroup = apply_cellgroup; + AssertFatal(!UE->apply_cellgroup || (UE->apply_cellgroup && UE->reconfigCellGroup), + "logic bug: apply_cellgroup %d and UE->reconfigCellGroup %p: did you try to apply a cellGroup, while none is deposited?\n", + UE->apply_cellgroup, + UE->reconfigCellGroup); + + // it might happen that timing advance command should be sent during the RRC + // processing timer. To prevent this, set a variable as if we would have just + // sent it. This way, another TA command will for sure be sent in some + // frames, after RRC processing timer. + UE->UE_sched_ctrl.ta_frame = (mac->frame - 1 + 1024) % 1024; + + LOG_I(NR_MAC, "%4d.%2d UE %04x: Activate RRC processing timer (%d ms)\n", mac->frame, mac->slot, UE->rnti, delay); + return 0; +} + void nr_mac_update_timers(module_id_t module_id, frame_t frame, sub_frame_t slot) { - /* already mutex protected: held in gNB_dlsch_ulsch_scheduler() */ - NR_SCHED_ENSURE_LOCKED(&RC.nrmac[module_id]->sched_lock); + gNB_MAC_INST *mac = RC.nrmac[module_id]; - NR_UEs_t *UE_info = &RC.nrmac[module_id]->UE_info; + /* already mutex protected: held in gNB_dlsch_ulsch_scheduler() */ + NR_SCHED_ENSURE_LOCKED(&mac->sched_lock); + + NR_UEs_t *UE_info = &mac->UE_info; UE_iterator(UE_info->list, UE) { NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; if (nr_mac_check_release(sched_ctrl, UE->rnti)) { nr_rlc_remove_ue(UE->rnti); - mac_remove_nr_ue(RC.nrmac[module_id], UE->rnti); + mac_remove_nr_ue(mac, UE->rnti); // go back to examine the next UE, which is at the position the // current UE was UE--; @@ -2748,41 +2810,12 @@ void nr_mac_update_timers(module_id_t module_id, } /* check if UL failure and trigger release request if necessary */ - nr_mac_check_ul_failure(RC.nrmac[module_id], UE->rnti, sched_ctrl); + nr_mac_check_ul_failure(mac, UE->rnti, sched_ctrl); if (sched_ctrl->rrc_processing_timer > 0) { sched_ctrl->rrc_processing_timer--; - if (sched_ctrl->rrc_processing_timer == 0) { - LOG_I(NR_MAC, "(%d.%d) De-activating RRC processing timer for UE %04x\n", frame, slot, UE->rnti); - - reset_srs_stats(UE); - - NR_CellGroupConfig_t *cg = NULL; - uper_decode(NULL, - &asn_DEF_NR_CellGroupConfig, // might be added prefix later - (void **)&cg, - (uint8_t *)UE->cg_buf, - (UE->enc_rval.encoded + 7) / 8, - 0, - 0); - UE->CellGroup = cg; - - if (LOG_DEBUGFLAG(DEBUG_ASN1)) { - xer_fprint(stdout, &asn_DEF_NR_CellGroupConfig, (const void *) UE->CellGroup); - } - - NR_ServingCellConfigCommon_t *scc = RC.nrmac[module_id]->common_channels[0].ServingCellConfigCommon; - - LOG_I(NR_MAC,"Modified rnti %04x with CellGroup\n", UE->rnti); - process_CellGroup(cg, UE); - NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; - configure_UE_BWP(RC.nrmac[module_id], scc, sched_ctrl, NULL, UE, -1, -1); - - if (get_softmodem_params()->sa) { - // add all available DL HARQ processes for this UE in SA - create_dl_harq_list(sched_ctrl, UE->current_DL_BWP.pdsch_servingcellconfig); - } - } + if (sched_ctrl->rrc_processing_timer == 0) + nr_mac_apply_cellgroup(mac, UE, frame, slot); } // RA timer @@ -2790,7 +2823,7 @@ void nr_mac_update_timers(module_id_t module_id, UE->ra_timer--; if (UE->ra_timer == 0) { LOG_W(NR_MAC, "Removing UE %04x because RA timer expired\n", UE->rnti); - mac_remove_nr_ue(RC.nrmac[module_id], UE->rnti); + mac_remove_nr_ue(mac, UE->rnti); } } } @@ -2890,7 +2923,7 @@ void prepare_initial_ul_rrc_message(gNB_MAC_INST *mac, NR_UE_info_t *UE) NR_CellGroupConfig_t *cellGroupConfig = get_initial_cellGroupConfig(UE->uid, scc, sccd, &mac->radio_config); UE->CellGroup = cellGroupConfig; - nr_mac_update_cellgroup(mac, UE->rnti, cellGroupConfig); + process_CellGroup(cellGroupConfig, UE); /* activate SRB0 */ nr_rlc_activate_srb0(UE->rnti, mac, UE, send_initial_ul_rrc_message); diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h index 386788170b..3b4a73a670 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_gNB/mac_proto.h @@ -44,17 +44,14 @@ void mac_top_init_gNB(ngran_node_t node_type, const nr_mac_config_t *conf); void nr_mac_send_f1_setup_req(void); -int nr_mac_enable_ue_rrc_processing_timer(module_id_t Mod_idP, - rnti_t rnti, - NR_SubcarrierSpacing_t subcarrierSpacing, - uint32_t rrc_reconfiguration_delay); - void nr_mac_config_scc(gNB_MAC_INST *nrmac, NR_ServingCellConfigCommon_t *scc, const nr_mac_config_t *mac_config); void nr_mac_configure_sib1(gNB_MAC_INST *nrmac, const f1ap_plmn_t *plmn, uint64_t cellID, int tac); bool nr_mac_add_test_ue(gNB_MAC_INST *nrmac, uint32_t rnti, NR_CellGroupConfig_t *CellGroup); bool nr_mac_prepare_ra_ue(gNB_MAC_INST *nrmac, uint32_t rnti, NR_CellGroupConfig_t *CellGroup); -bool nr_mac_update_cellgroup(gNB_MAC_INST *nrmac, uint32_t rnti, NR_CellGroupConfig_t *CellGroup); + +bool nr_mac_prepare_cellgroup_update(gNB_MAC_INST *nrmac, NR_UE_info_t *UE, NR_CellGroupConfig_t *CellGroup); +int nr_mac_enable_ue_rrc_processing_timer(gNB_MAC_INST *mac, NR_UE_info_t *UE, bool apply_cellGroup); void clear_nr_nfapi_information(gNB_MAC_INST *gNB, int CC_idP, diff --git a/openair2/LAYER2/NR_MAC_gNB/mac_rrc_dl_handler.c b/openair2/LAYER2/NR_MAC_gNB/mac_rrc_dl_handler.c index c6dfab563a..71d2ecc36a 100644 --- a/openair2/LAYER2/NR_MAC_gNB/mac_rrc_dl_handler.c +++ b/openair2/LAYER2/NR_MAC_gNB/mac_rrc_dl_handler.c @@ -138,6 +138,18 @@ static int handle_ue_context_drbs_setup(int rnti, return drbs_len; } +static NR_CellGroupConfig_t *clone_CellGroupConfig(const NR_CellGroupConfig_t *orig) +{ + uint8_t buf[16636]; + asn_enc_rval_t enc_rval = uper_encode_to_buffer(&asn_DEF_NR_CellGroupConfig, NULL, orig, buf, sizeof(buf)); + AssertFatal(enc_rval.encoded > 0, "could not clone CellGroupConfig: problem while encoding\n"); + NR_CellGroupConfig_t *cloned = NULL; + asn_dec_rval_t dec_rval = uper_decode(NULL, &asn_DEF_NR_CellGroupConfig, (void **)&cloned, buf, enc_rval.encoded, 0, 0); + AssertFatal(dec_rval.code == RC_OK && dec_rval.consumed == enc_rval.encoded, + "could not clone CellGroupConfig: problem while decodung\n"); + return cloned; +} + void ue_context_setup_request(const f1ap_ue_context_setup_t *req) { gNB_MAC_INST *mac = RC.nrmac[0]; @@ -158,12 +170,14 @@ void ue_context_setup_request(const f1ap_ue_context_setup_t *req) NR_UE_info_t *UE = find_nr_UE(&RC.nrmac[0]->UE_info, req->gNB_DU_ue_id); AssertFatal(UE != NULL, "did not find UE with RNTI %04x, but UE Context Setup Failed not implemented\n", req->gNB_DU_ue_id); + NR_CellGroupConfig_t *new_CellGroup = clone_CellGroupConfig(UE->CellGroup); + if (req->srbs_to_be_setup_length > 0) { resp.srbs_to_be_setup_length = handle_ue_context_srbs_setup(req->gNB_DU_ue_id, req->srbs_to_be_setup_length, req->srbs_to_be_setup, &resp.srbs_to_be_setup, - UE->CellGroup); + new_CellGroup); } if (req->drbs_to_be_setup_length > 0) { @@ -171,7 +185,7 @@ void ue_context_setup_request(const f1ap_ue_context_setup_t *req) req->drbs_to_be_setup_length, req->drbs_to_be_setup, &resp.drbs_to_be_setup, - UE->CellGroup); + new_CellGroup); } if (req->rrc_container != NULL) @@ -182,16 +196,13 @@ void ue_context_setup_request(const f1ap_ue_context_setup_t *req) AssertFatal(resp.du_to_cu_rrc_information != NULL, "out of memory\n"); resp.du_to_cu_rrc_information->cellGroupConfig = calloc(1,1024); AssertFatal(resp.du_to_cu_rrc_information->cellGroupConfig != NULL, "out of memory\n"); - asn_enc_rval_t enc_rval = uper_encode_to_buffer(&asn_DEF_NR_CellGroupConfig, - NULL, - UE->CellGroup, - resp.du_to_cu_rrc_information->cellGroupConfig, - 1024); + asn_enc_rval_t enc_rval = + uper_encode_to_buffer(&asn_DEF_NR_CellGroupConfig, NULL, new_CellGroup, resp.du_to_cu_rrc_information->cellGroupConfig, 1024); AssertFatal(enc_rval.encoded > 0, "Could not encode CellGroup, failed element %s\n", enc_rval.failed_type->name); resp.du_to_cu_rrc_information->cellGroupConfig_length = (enc_rval.encoded + 7) >> 3; /* TODO: need to apply after UE context reconfiguration confirmed? */ - process_CellGroup(UE->CellGroup, UE); + nr_mac_prepare_cellgroup_update(mac, UE, new_CellGroup); NR_SCHED_UNLOCK(&mac->sched_lock); @@ -226,12 +237,14 @@ void ue_context_modification_request(const f1ap_ue_context_modif_req_t *req) NR_SCHED_LOCK(&mac->sched_lock); NR_UE_info_t *UE = find_nr_UE(&RC.nrmac[0]->UE_info, req->gNB_DU_ue_id); + NR_CellGroupConfig_t *new_CellGroup = clone_CellGroupConfig(UE->CellGroup); + if (req->srbs_to_be_setup_length > 0) { resp.srbs_to_be_setup_length = handle_ue_context_srbs_setup(req->gNB_DU_ue_id, req->srbs_to_be_setup_length, req->srbs_to_be_setup, &resp.srbs_to_be_setup, - UE->CellGroup); + new_CellGroup); } if (req->drbs_to_be_setup_length > 0) { @@ -239,7 +252,7 @@ void ue_context_modification_request(const f1ap_ue_context_modif_req_t *req) req->drbs_to_be_setup_length, req->drbs_to_be_setup, &resp.drbs_to_be_setup, - UE->CellGroup); + new_CellGroup); } if (req->rrc_container != NULL) @@ -251,23 +264,21 @@ void ue_context_modification_request(const f1ap_ue_context_modif_req_t *req) } if (req->srbs_to_be_setup_length > 0 || req->drbs_to_be_setup_length > 0) { - /* TODO: if we change e.g. BWP or MCS table, need to automatically call - * configure_UE_BWP() (form nr_mac_update_timers()) after some time? */ - resp.du_to_cu_rrc_information = calloc(1, sizeof(du_to_cu_rrc_information_t)); AssertFatal(resp.du_to_cu_rrc_information != NULL, "out of memory\n"); resp.du_to_cu_rrc_information->cellGroupConfig = calloc(1, 1024); AssertFatal(resp.du_to_cu_rrc_information->cellGroupConfig != NULL, "out of memory\n"); asn_enc_rval_t enc_rval = uper_encode_to_buffer(&asn_DEF_NR_CellGroupConfig, NULL, - UE->CellGroup, + new_CellGroup, resp.du_to_cu_rrc_information->cellGroupConfig, 1024); AssertFatal(enc_rval.encoded > 0, "Could not encode CellGroup, failed element %s\n", enc_rval.failed_type->name); resp.du_to_cu_rrc_information->cellGroupConfig_length = (enc_rval.encoded + 7) >> 3; - /* works? */ - nr_mac_update_cellgroup(RC.nrmac[0], req->gNB_DU_ue_id, UE->CellGroup); + nr_mac_prepare_cellgroup_update(mac, UE, new_CellGroup); + } else { + ASN_STRUCT_FREE(asn_DEF_NR_CellGroupConfig, new_CellGroup); // we actually don't need it } NR_SCHED_UNLOCK(&mac->sched_lock); @@ -398,26 +409,13 @@ void dl_rrc_message_transfer(const f1ap_dl_rrc_message_t *dl_rrc) if (UE->expect_reconfiguration && dl_rrc->srb_id == DCCH) { /* we expected a reconfiguration, and this is on DCCH. We assume this is - * the reconfiguration; nr_mac_update_cellgroup() brings the config into - * the form expected by nr_mac_update_timers(), and we set the timer to - * apply the real configuration at expiration. - * Calling it nr_mac_update_cellgroup() is misleading, and using an - * intermediate buffer seems not necessary. This is for historical reasons, - * when we only had pointer to an RRC structure, and wanted to duplicate - * the contents to be applied later. The actually interesting function here - * is also configure_UE_BWP(), only called in nr_mac_update_timers(). - * TODO: This should be cleaned up when the whole CellGroupConfig is - * handled entirely at the DU: no intermediate buffer, trigger the timer - * from a function (there is nr_mac_enable_ue_rrc_processing_timer(), which - * is called from the RRC, hence locks the scheduler, which we cannot use). */ - LOG_I(NR_MAC, "triggering rrc_processing_timer time UE %04x\n", UE->rnti); - pthread_mutex_lock(&mac->sched_lock); - nr_mac_update_cellgroup(mac, dl_rrc->gNB_DU_ue_id, UE->reconfigCellGroup); - pthread_mutex_unlock(&mac->sched_lock); - const uint16_t sl_ahead = mac->if_inst->sl_ahead; - NR_SubcarrierSpacing_t scs = 1; - int delay = 10; - UE->UE_sched_ctrl.rrc_processing_timer = (delay << scs) + sl_ahead; + * the reconfiguration: nr_mac_prepare_cellgroup_update() already stored + * the CellGroupConfig. Below, we trigger a timer, and the CellGroupConfig + * will be applied after its expiry in nr_mac_apply_cellgroup().*/ + NR_SCHED_LOCK(&mac->sched_lock); + nr_mac_enable_ue_rrc_processing_timer(mac, UE, /* apply_cellGroup = */ true); + NR_SCHED_UNLOCK(&mac->sched_lock); + UE->expect_reconfiguration = false; } if (dl_rrc->old_gNB_DU_ue_id != NULL) { @@ -433,9 +431,11 @@ void dl_rrc_message_transfer(const f1ap_dl_rrc_message_t *dl_rrc) * from the current configuration. Also, expect the reconfiguration from * the CU, so save the old UE's CellGroup for the new UE */ UE->CellGroup->spCellConfig = NULL; - nr_mac_update_cellgroup(mac, dl_rrc->gNB_DU_ue_id, UE->CellGroup); - UE->reconfigCellGroup = oldUE->CellGroup; - UE->expect_reconfiguration = true; + NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; + NR_ServingCellConfigCommon_t *scc = mac->common_channels[0].ServingCellConfigCommon; + configure_UE_BWP(mac, scc, sched_ctrl, NULL, UE, -1, -1); + + nr_mac_prepare_cellgroup_update(mac, UE, oldUE->CellGroup); oldUE->CellGroup = NULL; mac_remove_nr_ue(mac, *dl_rrc->old_gNB_DU_ue_id); pthread_mutex_unlock(&mac->sched_lock); diff --git a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h index 53406b2f87..d7c38f3179 100644 --- a/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h +++ b/openair2/LAYER2/NR_MAC_gNB/nr_mac_gNB.h @@ -700,10 +700,9 @@ typedef struct { /// currently active CellGroupConfig NR_CellGroupConfig_t *CellGroup; /// CellGroupConfig that is to be activated after the next reconfiguration - NR_CellGroupConfig_t *reconfigCellGroup; bool expect_reconfiguration; - char cg_buf[32768]; /* arbitrary size */ - asn_enc_rval_t enc_rval; + NR_CellGroupConfig_t *reconfigCellGroup; + bool apply_cellgroup; // UE selected beam index uint8_t UE_beam_index; bool Msg4_ACKed; diff --git a/openair2/RRC/NR/L2_nr_interface.c b/openair2/RRC/NR/L2_nr_interface.c index a3bc40dc9c..090486cf65 100644 --- a/openair2/RRC/NR/L2_nr_interface.c +++ b/openair2/RRC/NR/L2_nr_interface.c @@ -52,14 +52,6 @@ extern RAN_CONTEXT_t RC; -void nr_rrc_mac_update_cellgroup(rnti_t rntiMaybeUEid, NR_CellGroupConfig_t *cgc) -{ - gNB_MAC_INST *nrmac = RC.nrmac[0]; - NR_SCHED_LOCK(&nrmac->sched_lock); - nr_mac_update_cellgroup(nrmac, rntiMaybeUEid, cgc); - NR_SCHED_UNLOCK(&nrmac->sched_lock); -} - int8_t nr_mac_rrc_bwp_switch_req(const module_id_t module_idP, const frame_t frameP, const sub_frame_t sub_frameP, diff --git a/openair2/RRC/NR/nr_rrc_proto.h b/openair2/RRC/NR/nr_rrc_proto.h index 69f71316ba..d132b8291d 100644 --- a/openair2/RRC/NR/nr_rrc_proto.h +++ b/openair2/RRC/NR/nr_rrc_proto.h @@ -110,8 +110,6 @@ void *rrc_gnb_task(void *args_p); \ *reOffset Pointer to RE Offset Value */ void rrc_config_dl_ptrs_params(NR_BWP_Downlink_t *bwp, long *ptrsNrb, long *ptrsMcs, long *epre_Ratio, long *reOffset); -void nr_rrc_mac_update_cellgroup(rnti_t rntiMaybeUEid, NR_CellGroupConfig_t *cgc); - int8_t nr_mac_rrc_bwp_switch_req(const module_id_t module_idP, const frame_t frameP, const sub_frame_t sub_frameP, diff --git a/openair2/RRC/NR/rrc_gNB.c b/openair2/RRC/NR/rrc_gNB.c index 07c951c4e2..1b00e380a2 100644 --- a/openair2/RRC/NR/rrc_gNB.c +++ b/openair2/RRC/NR/rrc_gNB.c @@ -45,7 +45,6 @@ #include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" #include "LAYER2/NR_MAC_gNB/mac_proto.h" #include "common/utils/LOG/log.h" -#include "COMMON/mac_rrc_primitives.h" #include "RRC/NR/MESSAGES/asn1_msg.h" #include "NR_BCCH-BCH-Message.h" @@ -605,21 +604,6 @@ static void rrc_gNB_generate_defaultRRCReconfiguration(const protocol_ctxt_t *co AssertFatal(!NODE_IS_DU(rrc->node_type), "illegal node type DU!\n"); nr_rrc_transfer_protected_rrc_message(rrc, ue_p, DCCH, buffer, size); - - if (NODE_IS_DU(rrc->node_type) || NODE_IS_MONOLITHIC(rrc->node_type)) { - gNB_RRC_UE_t *ue_p = &ue_context_pP->ue_context; - nr_rrc_mac_update_cellgroup(ue_p->rnti, ue_p->masterCellGroup); - - uint32_t delay_ms = ue_p->masterCellGroup && ue_p->masterCellGroup->spCellConfig && ue_p->masterCellGroup->spCellConfig->spCellConfigDedicated - && ue_p->masterCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList - ? NR_RRC_RECONFIGURATION_DELAY_MS + NR_RRC_BWP_SWITCHING_DELAY_MS - : NR_RRC_RECONFIGURATION_DELAY_MS; - - const nr_rrc_du_container_t *du = rrc->du; - DevAssert(du != NULL); - int scs = get_ssb_scs(&du->setup_req->cell[0].info); - nr_mac_enable_ue_rrc_processing_timer(ctxt_pP->module_id, ue_p->rnti, scs, delay_ms); - } } //----------------------------------------------------------------------------- @@ -713,20 +697,6 @@ void rrc_gNB_generate_dedicatedRRCReconfiguration(const protocol_ctxt_t *const c DCCH); nr_rrc_transfer_protected_rrc_message(rrc, ue_p, DCCH, buffer, size); - - if (NODE_IS_DU(rrc->node_type) || NODE_IS_MONOLITHIC(rrc->node_type)) { - nr_rrc_mac_update_cellgroup(ue_context_pP->ue_context.rnti, ue_context_pP->ue_context.masterCellGroup); - - uint32_t delay_ms = ue_p->masterCellGroup && ue_p->masterCellGroup->spCellConfig && ue_p->masterCellGroup->spCellConfig->spCellConfigDedicated - && ue_p->masterCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList - ? NR_RRC_RECONFIGURATION_DELAY_MS + NR_RRC_BWP_SWITCHING_DELAY_MS - : NR_RRC_RECONFIGURATION_DELAY_MS; - - const nr_rrc_du_container_t *du = rrc->du; - DevAssert(du != NULL); - int scs = get_ssb_scs(&du->setup_req->cell[0].info); - nr_mac_enable_ue_rrc_processing_timer(ctxt_pP->module_id, ue_p->rnti, scs, delay_ms); - } } //----------------------------------------------------------------------------- @@ -867,18 +837,6 @@ rrc_gNB_modify_dedicatedRRCReconfiguration( gNB_RRC_INST *rrc = RC.nrrrc[ctxt_pP->module_id]; nr_rrc_transfer_protected_rrc_message(rrc, ue_p, DCCH, buffer, size); - - if (NODE_IS_DU(rrc->node_type) || NODE_IS_MONOLITHIC(rrc->node_type)) { - uint32_t delay_ms = ue_p->masterCellGroup && ue_p->masterCellGroup->spCellConfig && ue_p->masterCellGroup->spCellConfig->spCellConfigDedicated - && ue_p->masterCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList - ? NR_RRC_RECONFIGURATION_DELAY_MS + NR_RRC_BWP_SWITCHING_DELAY_MS - : NR_RRC_RECONFIGURATION_DELAY_MS; - - const nr_rrc_du_container_t *du = rrc->du; - DevAssert(du != NULL); - int scs = get_ssb_scs(&du->setup_req->cell[0].info); - nr_mac_enable_ue_rrc_processing_timer(ctxt_pP->module_id, ue_p->rnti, scs, delay_ms); - } } //----------------------------------------------------------------------------- @@ -949,18 +907,6 @@ rrc_gNB_generate_dedicatedRRCReconfiguration_release( gNB_RRC_INST *rrc = RC.nrrrc[ctxt_pP->module_id]; nr_rrc_transfer_protected_rrc_message(rrc, ue_p, DCCH, buffer, size); - - if (NODE_IS_DU(rrc->node_type) || NODE_IS_MONOLITHIC(rrc->node_type)) { - uint32_t delay_ms = ue_p->masterCellGroup && ue_p->masterCellGroup->spCellConfig && ue_p->masterCellGroup->spCellConfig->spCellConfigDedicated - && ue_p->masterCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList - ? NR_RRC_RECONFIGURATION_DELAY_MS + NR_RRC_BWP_SWITCHING_DELAY_MS - : NR_RRC_RECONFIGURATION_DELAY_MS; - - const nr_rrc_du_container_t *du = rrc->du; - DevAssert(du != NULL); - int scs = get_ssb_scs(&du->setup_req->cell[0].info); - nr_mac_enable_ue_rrc_processing_timer(ctxt_pP->module_id, ue_p->rnti, scs, delay_ms); - } } //----------------------------------------------------------------------------- @@ -1192,19 +1138,6 @@ static void rrc_gNB_process_RRCReestablishmentComplete(const protocol_ctxt_t *co ue_p->rnti, size); nr_rrc_transfer_protected_rrc_message(rrc, ue_p, DCCH, buffer, size); - - if (NODE_IS_DU(RC.nrrrc[ctxt_pP->module_id]->node_type) || NODE_IS_MONOLITHIC(RC.nrrrc[ctxt_pP->module_id]->node_type)) { - uint32_t delay_ms = ue_p->masterCellGroup && ue_p->masterCellGroup->spCellConfig - && ue_p->masterCellGroup->spCellConfig->spCellConfigDedicated - && ue_p->masterCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList - ? NR_RRC_RECONFIGURATION_DELAY_MS + NR_RRC_BWP_SWITCHING_DELAY_MS - : NR_RRC_RECONFIGURATION_DELAY_MS; - - const nr_rrc_du_container_t *du = RC.nrrrc[0]->du; - DevAssert(du != NULL); - int scs = get_ssb_scs(&du->setup_req->cell[0].info); - nr_mac_enable_ue_rrc_processing_timer(ctxt_pP->module_id, ue_p->rnti, scs, delay_ms); - } } //----------------------------------------------------------------------------- @@ -1245,21 +1178,6 @@ int nr_rrc_reconfiguration_req(rrc_gNB_ue_context_t *const ue_context_pP gNB_RRC_INST *rrc = RC.nrrrc[ctxt_pP->module_id]; nr_rrc_transfer_protected_rrc_message(rrc, ue_p, DCCH, buffer, size); - if (NODE_IS_DU(rrc->node_type) || NODE_IS_MONOLITHIC(rrc->node_type)) { - nr_rrc_mac_update_cellgroup(ue_context_pP->ue_context.rnti, masterCellGroup); - - uint32_t delay_ms = ue_p->masterCellGroup && ue_p->masterCellGroup->spCellConfig - && ue_p->masterCellGroup->spCellConfig->spCellConfigDedicated - && ue_p->masterCellGroup->spCellConfig->spCellConfigDedicated->downlinkBWP_ToAddModList - ? NR_RRC_RECONFIGURATION_DELAY_MS + NR_RRC_BWP_SWITCHING_DELAY_MS - : NR_RRC_RECONFIGURATION_DELAY_MS; - - const nr_rrc_du_container_t *du = rrc->du; - DevAssert(du != NULL); - int scs = get_ssb_scs(&du->setup_req->cell[0].info); - nr_mac_enable_ue_rrc_processing_timer(ctxt_pP->module_id, ue_p->rnti, scs, delay_ms); - } - return 0; }