diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c index 4d570ad120..d5bff30ff1 100644 --- a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c +++ b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c @@ -71,6 +71,42 @@ static nr_rlc_entity_t *get_rlc_entity_from_lcid(nr_rlc_ue_t *ue, logical_chan_i } } +void nr_release_rlc_entity(int rnti, + logical_chan_id_t channel_id) +{ + nr_rlc_manager_lock(nr_rlc_ue_manager); + nr_rlc_ue_t *ue = nr_rlc_manager_get_ue(nr_rlc_ue_manager, rnti); + if (channel_id == 0) { + if (ue->srb0 != NULL) { + free(ue->srb0->deliver_sdu_data); + ue->srb0->delete(ue->srb0); + } + else + LOG_E(RLC, "Trying to release a non-established enity with LCID %d\n", + channel_id); + } + else { + nr_rlc_rb_t *rb = &ue->lcid2rb[channel_id - 1]; + if (rb->type == NR_RLC_SRB) { + if (ue->srb[rb->choice.srb_id - 1] != NULL) + ue->srb[rb->choice.srb_id - 1]->delete(ue->srb[rb->choice.srb_id - 1]); + else + LOG_E(RLC, "Trying to release a non-established enity with LCID %d\n", + channel_id); + } + else { + AssertFatal(rb->type == NR_RLC_DRB, + "Invalid RB type\n"); + if (ue->drb[rb->choice.drb_id - 1] != NULL) + ue->drb[rb->choice.drb_id - 1]->delete(ue->drb[rb->choice.drb_id - 1]); + else + LOG_E(RLC, "Trying to release a non-established enity with LCID %d\n", + channel_id); + } + } + nr_rlc_manager_unlock(nr_rlc_ue_manager); +} + void mac_rlc_data_ind(const module_id_t module_idP, const rnti_t rntiP, const eNB_index_t eNB_index, diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.h b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.h index 00018de926..f7154f2fa2 100644 --- a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.h +++ b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.h @@ -51,6 +51,9 @@ bool nr_rlc_update_rnti(int from_rnti, int to_rnti); /* test function for CI to trigger reestablishments */ void nr_rlc_test_trigger_reestablishment(int rnti); +void nr_release_rlc_entity(int rnti, + logical_chan_id_t channel_id); + void nr_rlc_reconfigure_entity(int rnti, int lc_id, struct NR_RLC_Config *rlc_Config, diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index cde5e0f13b..5408a092c5 100644 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -760,7 +760,11 @@ void nr_rrc_manage_rlc_bearers(const NR_CellGroupConfig_t *cellGroupConfig, int rnti) { if(cellGroupConfig->rlc_BearerToReleaseList != NULL) { - //TODO (perform RLC bearer release as specified in 5.3.5.5.3) + for (int i = 0; i < cellGroupConfig->rlc_BearerToReleaseList->list.count; i++) { + NR_LogicalChannelIdentity_t *lcid = cellGroupConfig->rlc_BearerToReleaseList->list.array[i]; + AssertFatal(lcid, "LogicalChannelIdentity shouldn't be null here\n"); + nr_release_rlc_entity(rnti, *lcid); + } } if(cellGroupConfig->rlc_BearerToAddModList != NULL) {