From e3e516e65247f42949b82caa28e8e3a50e298968 Mon Sep 17 00:00:00 2001 From: francescomani Date: Thu, 25 Jan 2024 18:57:19 +0100 Subject: [PATCH] Reception of RRC Setup as response to re-establishment request It also introduces state for resume request (even if not yet implemented) --- openair2/LAYER2/NR_MAC_UE/config_ue.c | 4 ++ openair2/LAYER2/NR_MAC_UE/mac_defs.h | 3 +- openair2/LAYER2/NR_MAC_UE/main_ue_nr.c | 2 +- openair2/RRC/NR_UE/rrc_UE.c | 63 +++++++++++++++++++++++--- openair2/RRC/NR_UE/rrc_defs.h | 1 + 5 files changed, 65 insertions(+), 8 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c index 3a5d5e5640..a9825a4de9 100644 --- a/openair2/LAYER2/NR_MAC_UE/config_ue.c +++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c @@ -1718,6 +1718,10 @@ void nr_rrc_mac_config_req_reset(module_id_t module_id, NR_UE_MAC_reset_cause_t sync_req.ssb_bw_scan = false; nr_ue_send_synch_request(mac, module_id, 0, &sync_req); break; + case RRC_SETUP_REESTAB_RESUME: + release_mac_configuration(mac, cause); + nr_ue_mac_default_configs(mac); + break; default: AssertFatal(false, "Invalid MAC reset cause %d\n", cause); } diff --git a/openair2/LAYER2/NR_MAC_UE/mac_defs.h b/openair2/LAYER2/NR_MAC_UE/mac_defs.h index b3ca280f86..7925e9b755 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_defs.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_defs.h @@ -196,7 +196,8 @@ typedef enum { GO_TO_IDLE, DETACH, T300_EXPIRY, - RE_ESTABLISHMENT + RE_ESTABLISHMENT, + RRC_SETUP_REESTAB_RESUME, } NR_UE_MAC_reset_cause_t; typedef struct { diff --git a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c index 6a6c7633bf..e189d7dcf9 100644 --- a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c +++ b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c @@ -271,7 +271,7 @@ void release_mac_configuration(NR_UE_MAC_INST_t *mac, NR_UE_MAC_reset_cause_t ca // in case of re-establishment we don't need to release initial BWP config common int first_bwp_rel = 0; // first BWP to release - if (cause == RE_ESTABLISHMENT) { + if (cause == RE_ESTABLISHMENT || cause == RRC_SETUP_REESTAB_RESUME) { first_bwp_rel = 1; // release dedicated BWP0 config NR_UE_DL_BWP_t *bwp = mac->dl_BWPs.array[0]; diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index 4abc712507..d36a1ca485 100644 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -1138,16 +1138,64 @@ static void rrc_ue_generate_RRCSetupComplete(const NR_UE_RRC_INST_t *rrc, const nr_pdcp_data_req_srb(rrc->ue_id, srb_id, 0, size, buffer, deliver_pdu_srb_rlc, NULL); } +static void nr_rrc_rrcsetup_fallback(NR_UE_RRC_INST_t *rrc) +{ + LOG_W(NR_RRC, + "[UE %ld] Recived RRCSetup in response to %s request\n", + rrc->ue_id, rrc->ra_trigger == RRC_CONNECTION_REESTABLISHMENT ? "RRCReestablishment" : "RRCResume"); + + // discard any stored UE Inactive AS context and suspendConfig + // TODO + + // discard any current AS security context including + // K_RRCenc key, the K_RRCint key, the K_UPint key and the K_UPenc key + // TODO only kgnb is stored + memset(rrc->kgnb, 0, sizeof(rrc->kgnb)); + rrc->as_security_activated = false; + + // release radio resources for all established RBs except SRB0, + // including release of the RLC entities, of the associated PDCP entities and of SDAP + for (int i = 1; i <= MAX_DRBS_PER_UE; i++) { + if (get_DRB_status(rrc, i) != RB_NOT_PRESENT) { + set_DRB_status(rrc, i, RB_NOT_PRESENT); + nr_pdcp_release_drb(rrc->ue_id, i); + } + } + for (int i = 1; i < NR_NUM_SRB; i++) { + if (rrc->Srb[i] != RB_NOT_PRESENT) { + rrc->Srb[i] = RB_NOT_PRESENT; + nr_pdcp_release_srb(rrc->ue_id, i); + } + } + for (int i = 1; i < NR_MAX_NUM_LCID; i++) { + if (rrc->active_RLC_entity[i]) { + rrc->active_RLC_entity[i] = false; + nr_rlc_release_entity(rrc->ue_id, i); + } + } + nr_sdap_delete_ue_entities(rrc->ue_id); + + // release the RRC configuration except for the default L1 parameter values, + // default MAC Cell Group configuration and CCCH configuration + // TODO to be completed + NR_UE_MAC_reset_cause_t cause = RRC_SETUP_REESTAB_RESUME; + MessageDef *msg = itti_alloc_new_message(TASK_RRC_NRUE, 0, NR_MAC_RRC_CONFIG_RESET); + NR_MAC_RRC_CONFIG_RESET(msg).cause = cause; + itti_send_msg_to_task(TASK_MAC_UE, rrc->ue_id, msg); + + // indicate to upper layers fallback of the RRC connection + // TODO + + // stop timer T380, if running + // TODO not implemented yet +} + static void nr_rrc_process_rrcsetup(NR_UE_RRC_INST_t *rrc, const NR_RRCSetup_t *rrcSetup) { // if the RRCSetup is received in response to an RRCReestablishmentRequest // or RRCResumeRequest or RRCResumeRequest1 - // TODO none of the procedures implemented yet - if (rrc->ra_trigger == RRC_CONNECTION_REESTABLISHMENT) { - LOG_E(NR_RRC, "Handling of RRCSetup in response of RRCReestablishment not implemented yet. Going back to IDLE.\n"); - nr_rrc_going_to_IDLE(rrc, OTHER, NULL); - return; - } + if (rrc->ra_trigger == RRC_CONNECTION_REESTABLISHMENT || rrc->ra_trigger == RRC_RESUME_REQUEST) + nr_rrc_rrcsetup_fallback(rrc); // perform the cell group configuration procedure in accordance with the received masterCellGroup nr_rrc_ue_process_masterCellGroup(rrc, @@ -1177,6 +1225,9 @@ static void nr_rrc_process_rrcsetup(NR_UE_RRC_INST_t *rrc, const NR_RRCSetup_t * MessageDef *msg_p = itti_alloc_new_message(TASK_RRC_NRUE, 0, NR_NAS_CONN_ESTABLISH_IND); itti_send_msg_to_task(TASK_NAS_NRUE, rrc->ue_id, msg_p); + // resetting the RA trigger state after receiving MSG4 with RRCSetup + rrc->ra_trigger = RA_NOT_RUNNING; + // set the content of RRCSetupComplete message // TODO procedues described in 5.3.3.4 seems more complex than what we actualy do rrc_ue_generate_RRCSetupComplete(rrc, rrcSetup->rrc_TransactionIdentifier); diff --git a/openair2/RRC/NR_UE/rrc_defs.h b/openair2/RRC/NR_UE/rrc_defs.h index e428c4c160..9c8b205083 100644 --- a/openair2/RRC/NR_UE/rrc_defs.h +++ b/openair2/RRC/NR_UE/rrc_defs.h @@ -94,6 +94,7 @@ typedef enum RA_trigger_e { RA_NOT_RUNNING, RRC_CONNECTION_SETUP, RRC_CONNECTION_REESTABLISHMENT, + RRC_RESUME_REQUEST, DURING_HANDOVER, NON_SYNCHRONISED, TRANSITION_FROM_RRC_INACTIVE,