Commit ab607f5f authored by Robert Schmidt's avatar Robert Schmidt

Handle CellGroupConfig completely at MAC

- MAC creates CellGroupConfig and sends to RRC
- the RRC does not manually update the CellGroupConfig
- MAC handles the RRC processing timer

In this commit, any updates to the CellGroupConfig previously done at
the RRC don't work. In other words, MIMO etc don't work; this is
implemented in the next wommit.
parent 894f453b
...@@ -414,36 +414,6 @@ static void config_common(gNB_MAC_INST *nrmac, int pdsch_AntennaPorts, int pusch ...@@ -414,36 +414,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<<subcarrierSpacing) + sl_ahead;
LOG_I(NR_MAC, "Activating RRC processing timer for UE %04x with %d ms\n", UE_info->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) void nr_mac_config_scc(gNB_MAC_INST *nrmac, NR_ServingCellConfigCommon_t *scc, const nr_mac_config_t *config)
{ {
DevAssert(nrmac != NULL); DevAssert(nrmac != NULL);
...@@ -611,28 +581,24 @@ bool nr_mac_prepare_ra_ue(gNB_MAC_INST *nrmac, uint32_t rnti, NR_CellGroupConfig ...@@ -611,28 +581,24 @@ bool nr_mac_prepare_ra_ue(gNB_MAC_INST *nrmac, uint32_t rnti, NR_CellGroupConfig
return true; 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(nrmac != NULL);
/* we assume that this function is mutex-protected from outside */ DevAssert(UE != NULL);
NR_SCHED_ENSURE_LOCKED(&nrmac->sched_lock);
DevAssert(CellGroup != NULL); DevAssert(CellGroup != NULL);
NR_UE_info_t *UE = find_nr_UE(&nrmac->UE_info, rnti); /* we assume that this function is mutex-protected from outside */
AssertFatal(UE != NULL, "Can't find UE %04x for CellGroup update\n", rnti); NR_SCHED_ENSURE_LOCKED(&nrmac->sched_lock);
/* 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); process_CellGroup(CellGroup, UE);
UE->reconfigCellGroup = CellGroup;
UE->expect_reconfiguration = true;
return true; return true;
} }
...@@ -1898,9 +1898,9 @@ static void nr_check_Msg4_Ack(module_id_t module_id, int CC_id, frame_t frame, s ...@@ -1898,9 +1898,9 @@ static void nr_check_Msg4_Ack(module_id_t module_id, int CC_id, frame_t frame, s
NR_RRC_SETUP_DELAY_MS + NR_RRC_BWP_SWITCHING_DELAY_MS : NR_RRC_SETUP_DELAY_MS; 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); 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); LOG_I(NR_MAC, "%4d.%2d UE %04x: Activate RRC processing timer (%d ms)\n", frame, slot, UE->rnti, delay_ms);
} else { } 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); nr_clear_ra_proc(module_id, CC_id, frame, ra);
......
...@@ -1946,6 +1946,8 @@ int get_nrofHARQ_ProcessesForPDSCH(e_NR_PDSCH_ServingCellConfig__nrofHARQ_Proces ...@@ -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) 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; NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl;
destroy_nr_list(&sched_ctrl->available_dl_harq); destroy_nr_list(&sched_ctrl->available_dl_harq);
destroy_nr_list(&sched_ctrl->feedback_dl_harq); destroy_nr_list(&sched_ctrl->feedback_dl_harq);
...@@ -2727,20 +2729,74 @@ void nr_csirs_scheduling(int Mod_idP, frame_t frame, sub_frame_t slot, int n_slo ...@@ -2727,20 +2729,74 @@ 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: Apply CellGroupConfig after RRC processing timer expiry\n", frame, slot, UE->rnti);
reset_srs_stats(UE);
/* check if there is a new CellGroupConfig to be applied */
if (UE->reconfigCellGroup != NULL) {
ASN_STRUCT_FREE(asn_DEF_NR_CellGroupConfig, UE->CellGroup);
UE->CellGroup = UE->reconfigCellGroup;
UE->reconfigCellGroup = NULL;
}
UE->expect_reconfiguration = 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);
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)
{
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;
// 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, void nr_mac_update_timers(module_id_t module_id,
frame_t frame, frame_t frame,
sub_frame_t slot) sub_frame_t slot)
{ {
gNB_MAC_INST *mac = RC.nrmac[module_id];
/* already mutex protected: held in gNB_dlsch_ulsch_scheduler() */ /* already mutex protected: held in gNB_dlsch_ulsch_scheduler() */
NR_SCHED_ENSURE_LOCKED(&RC.nrmac[module_id]->sched_lock); NR_SCHED_ENSURE_LOCKED(&mac->sched_lock);
NR_UEs_t *UE_info = &RC.nrmac[module_id]->UE_info; NR_UEs_t *UE_info = &mac->UE_info;
UE_iterator(UE_info->list, UE) { UE_iterator(UE_info->list, UE) {
NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl; NR_UE_sched_ctrl_t *sched_ctrl = &UE->UE_sched_ctrl;
if (nr_mac_check_release(sched_ctrl, UE->rnti)) { if (nr_mac_check_release(sched_ctrl, UE->rnti)) {
nr_rlc_remove_ue(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 // go back to examine the next UE, which is at the position the
// current UE was // current UE was
UE--; UE--;
...@@ -2748,41 +2804,12 @@ void nr_mac_update_timers(module_id_t module_id, ...@@ -2748,41 +2804,12 @@ void nr_mac_update_timers(module_id_t module_id,
} }
/* check if UL failure and trigger release request if necessary */ /* 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) { if (sched_ctrl->rrc_processing_timer > 0) {
sched_ctrl->rrc_processing_timer--; sched_ctrl->rrc_processing_timer--;
if (sched_ctrl->rrc_processing_timer == 0) { 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); nr_mac_apply_cellgroup(mac, UE, frame, slot);
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);
}
}
} }
// RA timer // RA timer
...@@ -2790,7 +2817,7 @@ void nr_mac_update_timers(module_id_t module_id, ...@@ -2790,7 +2817,7 @@ void nr_mac_update_timers(module_id_t module_id,
UE->ra_timer--; UE->ra_timer--;
if (UE->ra_timer == 0) { if (UE->ra_timer == 0) {
LOG_W(NR_MAC, "Removing UE %04x because RA timer expired\n", UE->rnti); 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 +2917,7 @@ void prepare_initial_ul_rrc_message(gNB_MAC_INST *mac, NR_UE_info_t *UE) ...@@ -2890,7 +2917,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); NR_CellGroupConfig_t *cellGroupConfig = get_initial_cellGroupConfig(UE->uid, scc, sccd, &mac->radio_config);
UE->CellGroup = cellGroupConfig; UE->CellGroup = cellGroupConfig;
nr_mac_update_cellgroup(mac, UE->rnti, cellGroupConfig); process_CellGroup(cellGroupConfig, UE);
/* activate SRB0 */ /* activate SRB0 */
nr_rlc_activate_srb0(UE->rnti, mac, UE, send_initial_ul_rrc_message); nr_rlc_activate_srb0(UE->rnti, mac, UE, send_initial_ul_rrc_message);
......
...@@ -41,17 +41,14 @@ void set_cset_offset(uint16_t); ...@@ -41,17 +41,14 @@ void set_cset_offset(uint16_t);
void mac_top_init_gNB(ngran_node_t node_type, NR_ServingCellConfigCommon_t *scc, NR_ServingCellConfig_t *scd, const nr_mac_config_t *conf); void mac_top_init_gNB(ngran_node_t node_type, NR_ServingCellConfigCommon_t *scc, NR_ServingCellConfig_t *scd, const nr_mac_config_t *conf);
void nr_mac_send_f1_setup_req(void); 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_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); 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_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_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);
void clear_nr_nfapi_information(gNB_MAC_INST *gNB, void clear_nr_nfapi_information(gNB_MAC_INST *gNB,
int CC_idP, int CC_idP,
......
...@@ -138,6 +138,18 @@ static int handle_ue_context_drbs_setup(int rnti, ...@@ -138,6 +138,18 @@ static int handle_ue_context_drbs_setup(int rnti,
return drbs_len; 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) void ue_context_setup_request(const f1ap_ue_context_setup_t *req)
{ {
gNB_MAC_INST *mac = RC.nrmac[0]; gNB_MAC_INST *mac = RC.nrmac[0];
...@@ -158,12 +170,14 @@ void ue_context_setup_request(const f1ap_ue_context_setup_t *req) ...@@ -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); 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); 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) { if (req->srbs_to_be_setup_length > 0) {
resp.srbs_to_be_setup_length = handle_ue_context_srbs_setup(req->gNB_DU_ue_id, 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_length,
req->srbs_to_be_setup, req->srbs_to_be_setup,
&resp.srbs_to_be_setup, &resp.srbs_to_be_setup,
UE->CellGroup); new_CellGroup);
} }
if (req->drbs_to_be_setup_length > 0) { if (req->drbs_to_be_setup_length > 0) {
...@@ -171,7 +185,7 @@ void ue_context_setup_request(const f1ap_ue_context_setup_t *req) ...@@ -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_length,
req->drbs_to_be_setup, req->drbs_to_be_setup,
&resp.drbs_to_be_setup, &resp.drbs_to_be_setup,
UE->CellGroup); new_CellGroup);
} }
if (req->rrc_container != NULL) if (req->rrc_container != NULL)
...@@ -182,16 +196,13 @@ void ue_context_setup_request(const f1ap_ue_context_setup_t *req) ...@@ -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"); AssertFatal(resp.du_to_cu_rrc_information != NULL, "out of memory\n");
resp.du_to_cu_rrc_information->cellGroupConfig = calloc(1,1024); resp.du_to_cu_rrc_information->cellGroupConfig = calloc(1,1024);
AssertFatal(resp.du_to_cu_rrc_information->cellGroupConfig != NULL, "out of memory\n"); 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, asn_enc_rval_t enc_rval =
NULL, uper_encode_to_buffer(&asn_DEF_NR_CellGroupConfig, NULL, new_CellGroup, resp.du_to_cu_rrc_information->cellGroupConfig, 1024);
UE->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); 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; resp.du_to_cu_rrc_information->cellGroupConfig_length = (enc_rval.encoded + 7) >> 3;
/* TODO: need to apply after UE context reconfiguration confirmed? */ /* 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); NR_SCHED_UNLOCK(&mac->sched_lock);
...@@ -226,12 +237,14 @@ void ue_context_modification_request(const f1ap_ue_context_modif_req_t *req) ...@@ -226,12 +237,14 @@ void ue_context_modification_request(const f1ap_ue_context_modif_req_t *req)
NR_SCHED_LOCK(&mac->sched_lock); 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_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) { if (req->srbs_to_be_setup_length > 0) {
resp.srbs_to_be_setup_length = handle_ue_context_srbs_setup(req->gNB_DU_ue_id, 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_length,
req->srbs_to_be_setup, req->srbs_to_be_setup,
&resp.srbs_to_be_setup, &resp.srbs_to_be_setup,
UE->CellGroup); new_CellGroup);
} }
if (req->drbs_to_be_setup_length > 0) { 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) ...@@ -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_length,
req->drbs_to_be_setup, req->drbs_to_be_setup,
&resp.drbs_to_be_setup, &resp.drbs_to_be_setup,
UE->CellGroup); new_CellGroup);
} }
if (req->rrc_container != NULL) if (req->rrc_container != NULL)
...@@ -251,23 +264,21 @@ void ue_context_modification_request(const f1ap_ue_context_modif_req_t *req) ...@@ -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) { 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)); 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"); AssertFatal(resp.du_to_cu_rrc_information != NULL, "out of memory\n");
resp.du_to_cu_rrc_information->cellGroupConfig = calloc(1, 1024); resp.du_to_cu_rrc_information->cellGroupConfig = calloc(1, 1024);
AssertFatal(resp.du_to_cu_rrc_information->cellGroupConfig != NULL, "out of memory\n"); 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, asn_enc_rval_t enc_rval = uper_encode_to_buffer(&asn_DEF_NR_CellGroupConfig,
NULL, NULL,
UE->CellGroup, new_CellGroup,
resp.du_to_cu_rrc_information->cellGroupConfig, resp.du_to_cu_rrc_information->cellGroupConfig,
1024); 1024);
AssertFatal(enc_rval.encoded > 0, "Could not encode CellGroup, failed element %s\n", enc_rval.failed_type->name); 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; resp.du_to_cu_rrc_information->cellGroupConfig_length = (enc_rval.encoded + 7) >> 3;
/* works? */ nr_mac_prepare_cellgroup_update(mac, UE, new_CellGroup);
nr_mac_update_cellgroup(RC.nrmac[0], req->gNB_DU_ue_id, UE->CellGroup); } else {
ASN_STRUCT_FREE(asn_DEF_NR_CellGroupConfig, new_CellGroup); // we actually don't need it
} }
NR_SCHED_UNLOCK(&mac->sched_lock); NR_SCHED_UNLOCK(&mac->sched_lock);
...@@ -398,26 +409,12 @@ void dl_rrc_message_transfer(const f1ap_dl_rrc_message_t *dl_rrc) ...@@ -398,26 +409,12 @@ void dl_rrc_message_transfer(const f1ap_dl_rrc_message_t *dl_rrc)
if (UE->expect_reconfiguration && dl_rrc->srb_id == DCCH) { if (UE->expect_reconfiguration && dl_rrc->srb_id == DCCH) {
/* we expected a reconfiguration, and this is on DCCH. We assume this is /* we expected a reconfiguration, and this is on DCCH. We assume this is
* the reconfiguration; nr_mac_update_cellgroup() brings the config into * the reconfiguration: nr_mac_prepare_cellgroup_update() already stored
* the form expected by nr_mac_update_timers(), and we set the timer to * the CellGroupConfig. Below, we trigger a timer, and the CellGroupConfig
* apply the real configuration at expiration. * will be applied after its expiry in nr_mac_apply_cellgroup().*/
* Calling it nr_mac_update_cellgroup() is misleading, and using an NR_SCHED_LOCK(&mac->sched_lock);
* intermediate buffer seems not necessary. This is for historical reasons, nr_mac_enable_ue_rrc_processing_timer(mac, UE);
* when we only had pointer to an RRC structure, and wanted to duplicate NR_SCHED_UNLOCK(&mac->sched_lock);
* 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;
} }
if (dl_rrc->old_gNB_DU_ue_id != NULL) { if (dl_rrc->old_gNB_DU_ue_id != NULL) {
...@@ -433,9 +430,7 @@ void dl_rrc_message_transfer(const f1ap_dl_rrc_message_t *dl_rrc) ...@@ -433,9 +430,7 @@ void dl_rrc_message_transfer(const f1ap_dl_rrc_message_t *dl_rrc)
* from the current configuration. Also, expect the reconfiguration from * from the current configuration. Also, expect the reconfiguration from
* the CU, so save the old UE's CellGroup for the new UE */ * the CU, so save the old UE's CellGroup for the new UE */
UE->CellGroup->spCellConfig = NULL; UE->CellGroup->spCellConfig = NULL;
nr_mac_update_cellgroup(mac, dl_rrc->gNB_DU_ue_id, UE->CellGroup); nr_mac_prepare_cellgroup_update(mac, UE, oldUE->CellGroup);
UE->reconfigCellGroup = oldUE->CellGroup;
UE->expect_reconfiguration = true;
oldUE->CellGroup = NULL; oldUE->CellGroup = NULL;
mac_remove_nr_ue(mac, *dl_rrc->old_gNB_DU_ue_id); mac_remove_nr_ue(mac, *dl_rrc->old_gNB_DU_ue_id);
pthread_mutex_unlock(&mac->sched_lock); pthread_mutex_unlock(&mac->sched_lock);
......
...@@ -702,8 +702,6 @@ typedef struct { ...@@ -702,8 +702,6 @@ typedef struct {
/// CellGroupConfig that is to be activated after the next reconfiguration /// CellGroupConfig that is to be activated after the next reconfiguration
NR_CellGroupConfig_t *reconfigCellGroup; NR_CellGroupConfig_t *reconfigCellGroup;
bool expect_reconfiguration; bool expect_reconfiguration;
char cg_buf[32768]; /* arbitrary size */
asn_enc_rval_t enc_rval;
// UE selected beam index // UE selected beam index
uint8_t UE_beam_index; uint8_t UE_beam_index;
bool Msg4_ACKed; bool Msg4_ACKed;
......
...@@ -52,14 +52,6 @@ ...@@ -52,14 +52,6 @@
extern RAN_CONTEXT_t RC; 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, int8_t nr_mac_rrc_bwp_switch_req(const module_id_t module_idP,
const frame_t frameP, const frame_t frameP,
const sub_frame_t sub_frameP, const sub_frame_t sub_frameP,
......
...@@ -110,8 +110,6 @@ void *rrc_gnb_task(void *args_p); ...@@ -110,8 +110,6 @@ void *rrc_gnb_task(void *args_p);
\ *reOffset Pointer to RE Offset Value */ \ *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 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, int8_t nr_mac_rrc_bwp_switch_req(const module_id_t module_idP,
const frame_t frameP, const frame_t frameP,
const sub_frame_t sub_frameP, const sub_frame_t sub_frameP,
......
...@@ -45,7 +45,6 @@ ...@@ -45,7 +45,6 @@
#include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h" #include "RRC/L2_INTERFACE/openair_rrc_L2_interface.h"
#include "LAYER2/NR_MAC_gNB/mac_proto.h" #include "LAYER2/NR_MAC_gNB/mac_proto.h"
#include "common/utils/LOG/log.h" #include "common/utils/LOG/log.h"
#include "COMMON/mac_rrc_primitives.h"
#include "RRC/NR/MESSAGES/asn1_msg.h" #include "RRC/NR/MESSAGES/asn1_msg.h"
#include "NR_BCCH-BCH-Message.h" #include "NR_BCCH-BCH-Message.h"
...@@ -560,21 +559,6 @@ static void rrc_gNB_generate_defaultRRCReconfiguration(const protocol_ctxt_t *co ...@@ -560,21 +559,6 @@ static void rrc_gNB_generate_defaultRRCReconfiguration(const protocol_ctxt_t *co
AssertFatal(!NODE_IS_DU(rrc->node_type), "illegal node type DU!\n"); AssertFatal(!NODE_IS_DU(rrc->node_type), "illegal node type DU!\n");
nr_rrc_transfer_protected_rrc_message(rrc, ue_p, DCCH, buffer, size); 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);
}
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
...@@ -668,20 +652,6 @@ void rrc_gNB_generate_dedicatedRRCReconfiguration(const protocol_ctxt_t *const c ...@@ -668,20 +652,6 @@ void rrc_gNB_generate_dedicatedRRCReconfiguration(const protocol_ctxt_t *const c
DCCH); DCCH);
nr_rrc_transfer_protected_rrc_message(rrc, ue_p, DCCH, buffer, size); 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);
}
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
...@@ -822,18 +792,6 @@ rrc_gNB_modify_dedicatedRRCReconfiguration( ...@@ -822,18 +792,6 @@ rrc_gNB_modify_dedicatedRRCReconfiguration(
gNB_RRC_INST *rrc = RC.nrrrc[ctxt_pP->module_id]; gNB_RRC_INST *rrc = RC.nrrrc[ctxt_pP->module_id];
nr_rrc_transfer_protected_rrc_message(rrc, ue_p, DCCH, buffer, size); 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);
}
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
...@@ -904,18 +862,6 @@ rrc_gNB_generate_dedicatedRRCReconfiguration_release( ...@@ -904,18 +862,6 @@ rrc_gNB_generate_dedicatedRRCReconfiguration_release(
gNB_RRC_INST *rrc = RC.nrrrc[ctxt_pP->module_id]; gNB_RRC_INST *rrc = RC.nrrrc[ctxt_pP->module_id];
nr_rrc_transfer_protected_rrc_message(rrc, ue_p, DCCH, buffer, size); 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);
}
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
...@@ -1146,19 +1092,6 @@ static void rrc_gNB_process_RRCReestablishmentComplete(const protocol_ctxt_t *co ...@@ -1146,19 +1092,6 @@ static void rrc_gNB_process_RRCReestablishmentComplete(const protocol_ctxt_t *co
ue_p->rnti, ue_p->rnti,
size); size);
nr_rrc_transfer_protected_rrc_message(rrc, ue_p, DCCH, buffer, 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);
}
} }
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
...@@ -1199,21 +1132,6 @@ int nr_rrc_reconfiguration_req(rrc_gNB_ue_context_t *const ue_context_pP ...@@ -1199,21 +1132,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]; gNB_RRC_INST *rrc = RC.nrrrc[ctxt_pP->module_id];
nr_rrc_transfer_protected_rrc_message(rrc, ue_p, DCCH, buffer, size); 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; return 0;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment