diff --git a/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h b/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h index 67dd5d19b7efb2c4b30d09d77d80ba6a7edb232d..b28e45ae2d04b05a630f5816b15f6dfeb66c32f5 100644 --- a/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h +++ b/nfapi/open-nFAPI/nfapi/public_inc/fapi_nr_ue_interface.h @@ -673,7 +673,7 @@ typedef struct } fapi_nr_prach_config_t; typedef struct { - uint16_t target_Nid_cell; + int16_t target_Nid_cell; } fapi_nr_synch_request_t; typedef struct { diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c index ed2afb80f3dde8947a3bb77f516d0bc42c363a89..234533099c42099db4a5ebd0998a5bd33376d6dc 100644 --- a/openair2/LAYER2/NR_MAC_UE/config_ue.c +++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c @@ -675,9 +675,8 @@ static int lcid_cmp(const void *lc1, const void *lc2, void *mac_inst) return (lc_config[id1 - 1]->ul_SpecificParameters->priority - lc_config[id2 - 1]->ul_SpecificParameters->priority); } -void nr_release_mac_config_logicalChannelBearer(module_id_t module_id, long channel_identity) +void nr_release_mac_config_logicalChannelBearer(NR_UE_MAC_INST_t *mac, long channel_identity) { - NR_UE_MAC_INST_t *mac = get_mac_inst(module_id); if (mac->logicalChannelConfig[channel_identity - 1] != NULL) { ASN_STRUCT_FREE(asn_DEF_NR_LogicalChannelConfig, mac->logicalChannelConfig[channel_identity - 1]); mac->logicalChannelConfig[channel_identity - 1] = NULL; @@ -750,7 +749,7 @@ void nr_rrc_mac_config_req_ue_logicalChannelBearer(module_id_t module_id, for (int i = 0; i < rlc_torelease_list->list.count; i++) { if (rlc_torelease_list->list.array[i]) { int lc_identity = *rlc_torelease_list->list.array[i]; - nr_release_mac_config_logicalChannelBearer(module_id, lc_identity); + nr_release_mac_config_logicalChannelBearer(mac, lc_identity); } } } @@ -1351,19 +1350,20 @@ static void configure_common_BWP_ul(NR_UE_MAC_INST_t *mac, int bwp_id, NR_BWP_Up } } -void nr_rrc_mac_config_req_reset(module_id_t module_id) +void nr_rrc_mac_config_req_reset(module_id_t module_id, + NR_UE_MAC_reset_cause_t reset_cause) { NR_UE_MAC_INST_t *mac = get_mac_inst(module_id); reset_mac_inst(mac); -} - -void nr_rrc_mac_config_req_release(module_id_t module_id) -{ - NR_UE_MAC_INST_t *mac = get_mac_inst(module_id); - reset_ra(&mac->ra); + release_mac_configuration(mac); + for (int i = 0; i < NR_MAX_NUM_LCID; i++) { + nr_release_mac_config_logicalChannelBearer(mac, i + 1); + memset(&mac->lc_ordered_info[i], 0, sizeof(nr_lcordered_info_t)); + } + mac->first_sync_frame = -1; mac->get_sib1 = false; mac->phy_config_request_sent = false; @@ -1375,6 +1375,7 @@ void nr_rrc_mac_config_req_release(module_id_t module_id) mac->synch_request.CC_id = 0; mac->synch_request.synch_req.target_Nid_cell = -1; mac->if_module->synch_request(&mac->synch_request); + } void nr_rrc_mac_config_req_sib1(module_id_t module_id, diff --git a/openair2/LAYER2/NR_MAC_UE/mac_defs.h b/openair2/LAYER2/NR_MAC_UE/mac_defs.h index d687ecf70e9213949c2cf9a2f6a1ab81d39fd4e6..1263f12b5dc6a4fcb3ed459dd9b5fdcfc6727c2d 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_defs.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_defs.h @@ -165,6 +165,11 @@ typedef enum { UE_CONNECTED } NR_UE_L2_STATE_t; +typedef enum { + GO_TO_IDLE, + RE_ESTABLISHMENT +} NR_UE_MAC_reset_cause_t; + typedef enum { RA_2STEP = 0, RA_4STEP diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h index 599d90d54e659e760b8d48fc1179d9137a6b42e5..6ba88e6f95cf31d8a6fd9fa1355666dc47b78b17 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h @@ -170,8 +170,7 @@ void nr_rrc_mac_config_req_sib1(module_id_t module_id, NR_SI_SchedulingInfo_t *si_SchedulingInfo, NR_ServingCellConfigCommonSIB_t *scc); -void nr_rrc_mac_config_req_reset(module_id_t module_id); -void nr_rrc_mac_config_req_release(module_id_t module_id); +void nr_rrc_mac_config_req_reset(module_id_t module_id, NR_UE_MAC_reset_cause_t cause); /**\brief initialization NR UE MAC instance(s), total number of MAC instance based on NB_NR_UE_MAC_INST*/ NR_UE_MAC_INST_t * nr_l2_init_ue(); diff --git a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c index 89394200a368c5f5acc04e40c1eff0edc48d3552..8ebde18cc7ebceecb85a01f13a28933feb508f32 100644 --- a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c +++ b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c @@ -181,17 +181,21 @@ void reset_mac_inst(NR_UE_MAC_INST_t *nr_mac) void release_mac_configuration(NR_UE_MAC_INST_t *mac) { - if(mac->mib) + if(mac->mib) { ASN_STRUCT_FREE(asn_DEF_NR_MIB, mac->mib); + mac->mib = NULL; + } for (int i = 0; i < 5; i++) { NR_BWP_PDCCH_t *pdcch = &mac->config_BWP_PDCCH[5]; release_common_ss_cset(pdcch); for (int j = 0; j < pdcch->list_Coreset.count; j++) asn_sequence_del(&pdcch->list_Coreset, j, 1); for (int j = 0; j < pdcch->list_SS.count; j++) - asn_sequence_del(&pdcch->list_SS, j, 1); + asn_sequence_del(&pdcch->list_SS, j, 1); } + memset(&mac->current_DL_BWP, 0, sizeof(mac->current_DL_BWP)); + memset(&mac->current_UL_BWP, 0, sizeof(mac->current_UL_BWP)); memset(&mac->ssb_measurements, 0, sizeof(mac->ssb_measurements)); memset(&mac->csirs_measurements, 0, sizeof(mac->csirs_measurements)); memset(&mac->ul_time_alignment, 0, sizeof(mac->ul_time_alignment)); diff --git a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c index 383ae37d35a78d53bc20c811259e4f831daa3d1d..9d5602479a7f9832620b112ffe16252dd56f907b 100644 --- a/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c +++ b/openair2/LAYER2/nr_rlc/nr_rlc_oai_api.c @@ -62,7 +62,7 @@ static void release_rlc_entity_from_lcid(nr_rlc_ue_t *ue, logical_chan_id_t chan return; if (rb->type == NR_RLC_SRB) { int id = rb->choice.srb_id - 1; - AssertFatal(id > 0, "logic bug: impossible to have srb0 here\n"); + AssertFatal(id >= 0, "logic bug: impossible to have srb0 here\n"); if (ue->srb[id]) { ue->srb[id]->delete_entity(ue->srb[id]); ue->srb[id] = NULL; diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index 84e5de5099810513fece2e33eadd8bb9ddecfa41..6e85dfef126b3059cd01f18278138d42dc916671 100644 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -49,7 +49,6 @@ #include "rrc_defs.h" #include "rrc_proto.h" #include "LAYER2/NR_MAC_UE/mac_proto.h" -#include "COMMON/mac_rrc_primitives.h" #include "intertask_interface.h" @@ -1846,8 +1845,7 @@ void nr_rrc_going_to_IDLE(instance_t instance, { NR_UE_RRC_INST_t *rrc = &NR_UE_rrc_inst[instance]; NR_UE_Timers_Constants_t *tac = &rrc->timers_and_constants; - // reset MAC - nr_rrc_mac_config_req_reset(instance); + // if going to RRC_IDLE was triggered by reception // of the RRCRelease message including a waitTime NR_RejectWaitTime_t *waitTime = NULL; @@ -1915,11 +1913,30 @@ void nr_rrc_going_to_IDLE(instance_t instance, // discard the keys (only kgnb is stored) memset(rrc->kgnb, 0, sizeof(rrc->kgnb)); - // TODO release all radio resources, including release of the RLC entity, + // release all radio resources, including release of the RLC entity, // the MAC configuration and the associated PDCP entity // and SDAP for all established RBs - nr_pdcp_remove_UE(rrc->rnti); - nr_rlc_remove_ue(rrc->rnti); + for (int j = 0; j < NB_CNX_UE; j++) { + rrcPerNB_t *nb = &rrc->perNB[j]; + for (int i = 0; i < MAX_DRBS_PER_UE; i++) { + if (nb->status_DRBs[i] != RB_NOT_PRESENT) { + nb->status_DRBs[i] = RB_NOT_PRESENT; + nr_pdcp_release_drb(rrc->rnti, i); + } + } + for (int i = 1; i < NR_NUM_SRB; i++) { + if (nb->Srb[i] != RB_NOT_PRESENT) { + nb->Srb[i] = RB_NOT_PRESENT; + nr_pdcp_release_srb(rrc->rnti, i); + } + } + for (int i = 0; i < NR_MAX_NUM_LCID; i++) { + if (nb->active_RLC_entity[i]) { + nb->active_RLC_entity[i] = false; + nr_rlc_release_entity(rrc->rnti, i); + } + } + } if(rrc->meas_config) { ASN_STRUCT_FREE(asn_DEF_NR_MeasConfig, rrc->meas_config); @@ -1987,7 +2004,9 @@ void nr_rrc_going_to_IDLE(instance_t instance, } } - nr_rrc_mac_config_req_release(instance); + // reset MAC + NR_UE_MAC_reset_cause_t cause = GO_TO_IDLE; + nr_rrc_mac_config_req_reset(instance, cause); // enter RRC_IDLE rrc->nrRrcState = RRC_STATE_IDLE_NR; diff --git a/openair2/SDAP/nr_sdap/nr_sdap_entity.c b/openair2/SDAP/nr_sdap/nr_sdap_entity.c index f3f83158394da9d1fc6cbf8b6a66316291928a4f..d030eca60e1bcc92c9b1b304862d0a719217e969 100644 --- a/openair2/SDAP/nr_sdap/nr_sdap_entity.c +++ b/openair2/SDAP/nr_sdap/nr_sdap_entity.c @@ -491,7 +491,7 @@ bool nr_sdap_delete_entity(ue_id_t ue_id, int pdusession_id) int upperBound = 0; if (entityPtr == NULL && (pdusession_id) * (pdusession_id - NGAP_MAX_PDU_SESSION) > 0) { - LOG_W(SDAP, "SDAP entities not established or Invalid range of pdusession_id [0, 256].\n"); + LOG_E(SDAP, "SDAP entities not established or Invalid range of pdusession_id [0, 256].\n"); return ret; } LOG_D(SDAP, "Deleting SDAP entity for UE %lx and PDU Session id %d\n", ue_id, entityPtr->pdusession_id); @@ -516,7 +516,7 @@ bool nr_sdap_delete_entity(ue_id_t ue_id, int pdusession_id) ret = true; } } - LOG_W(SDAP, "Entity does not exist or it was not found.\n"); + LOG_E(SDAP, "Entity does not exist or it was not found.\n"); return ret; }