From 88af2860a2966b169989835417f4e5268ee84e10 Mon Sep 17 00:00:00 2001 From: francescomani Date: Thu, 9 Jan 2025 19:21:36 +0100 Subject: [PATCH] handle RRC reject at UE --- openair2/LAYER2/NR_MAC_UE/config_ue.c | 5 ++++ openair2/LAYER2/NR_MAC_UE/mac_defs.h | 2 ++ openair2/LAYER2/NR_MAC_UE/mac_proto.h | 5 +--- openair2/RRC/NR_UE/rrc_UE.c | 41 +++++++++++++++++++++++++-- 4 files changed, 47 insertions(+), 6 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c index bfea78d540..9bdbeebe10 100644 --- a/openair2/LAYER2/NR_MAC_UE/config_ue.c +++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c @@ -1725,6 +1725,11 @@ void nr_rrc_mac_config_req_reset(module_id_t module_id, NR_UE_MAC_reset_cause_t reset_mac_inst(mac); mac->state = UE_PERFORMING_RA; // still in sync but need to restart RA break; + case REJECT: + reset_ra(mac, false); + reset_mac_inst(mac); + mac->state = UE_BARRED; + break; case RE_ESTABLISHMENT: reset_mac_inst(mac); nr_ue_mac_default_configs(mac); diff --git a/openair2/LAYER2/NR_MAC_UE/mac_defs.h b/openair2/LAYER2/NR_MAC_UE/mac_defs.h index dee2a30c08..0174e88abc 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_defs.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_defs.h @@ -148,6 +148,7 @@ // Define the UE L2 states with X-Macro #define NR_UE_L2_STATES \ UE_STATE(UE_NOT_SYNC) \ + UE_STATE(UE_BARRED) \ UE_STATE(UE_RECEIVING_SIB) \ UE_STATE(UE_PERFORMING_RA) \ UE_STATE(UE_CONNECTED) \ @@ -199,6 +200,7 @@ typedef enum { RE_ESTABLISHMENT, RRC_SETUP_REESTAB_RESUME, UL_SYNC_LOST_T430_EXPIRED, + REJECT, } NR_UE_MAC_reset_cause_t; typedef struct { diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h index c8eab85462..0a7365ef5d 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h @@ -87,10 +87,7 @@ void nr_rrc_mac_config_req_cg(module_id_t module_id, NR_CellGroupConfig_t *cell_group_config, NR_UE_NR_Capability_t *ue_Capability); -void nr_rrc_mac_config_req_mib(module_id_t module_id, - int cc_idP, - NR_MIB_t *mibP, - int sched_sib1); +void nr_rrc_mac_config_req_mib(module_id_t module_id, int cc_idP, NR_MIB_t *mibP, int sched_sib1); void nr_rrc_mac_config_req_sib1(module_id_t module_id, int cc_idP, NR_SIB1_t *sib1, bool can_start_ra); diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index 90713ff50c..af0c1350c1 100644 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -1394,8 +1394,44 @@ static void nr_rrc_process_rrcsetup(NR_UE_RRC_INST_t *rrc, const NR_RRCSetup_t * rrc_ue_generate_RRCSetupComplete(rrc, rrcSetup->rrc_TransactionIdentifier); } -static int8_t nr_rrc_ue_decode_ccch(NR_UE_RRC_INST_t *rrc, - const NRRrcMacCcchDataInd *ind) +static void nr_rrc_process_rrcreject(NR_UE_RRC_INST_t *rrc, const NR_RRCReject_t *rrcReject) +{ + // stop timer T300, T302, T319 if running; + NR_UE_Timers_Constants_t *timers = &rrc->timers_and_constants; + nr_timer_stop(&timers->T300); + nr_timer_stop(&timers->T302); + nr_timer_stop(&timers->T319); + + // reset MAC and release the default MAC Cell Group configuration + NR_UE_MAC_reset_cause_t cause = REJECT; + 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); + + // if waitTime is configured in the RRCReject: start timer T302, with the timer value set to the waitTime + NR_RejectWaitTime_t *waitTime = NULL; + if (rrcReject->criticalExtensions.present == NR_RRCReject__criticalExtensions_PR_rrcReject) { + NR_RRCReject_IEs_t *ies = rrcReject->criticalExtensions.choice.rrcReject; + waitTime = ies->waitTime; // Wait time value in seconds + } + if (waitTime) { + nr_timer_setup(&timers->T302, *waitTime * 1000, 10); + nr_timer_start(&timers->T302); + } else { + LOG_W(RRC, "Error: waitTime should be always included in RRCReject message\n"); + } + + // TODO if RRCReject is received in response to a request from upper layers + // inform the upper layer that access barring is applicable for all access categories except categories '0' and '2' + + // TODO if RRCReject is received in response to an RRCSetupRequest + // inform upper layers about the failure to setup the RRC connection, upon which the procedure ends + + // TODO else if RRCReject is received in response to an RRCResumeRequest or an RRCResumeRequest1 + // Resume not implemented yet +} + +static int8_t nr_rrc_ue_decode_ccch(NR_UE_RRC_INST_t *rrc, const NRRrcMacCcchDataInd *ind) { NR_DL_CCCH_Message_t *dl_ccch_msg = NULL; asn_dec_rval_t dec_rval; @@ -1423,6 +1459,7 @@ static int8_t nr_rrc_ue_decode_ccch(NR_UE_RRC_INST_t *rrc, case NR_DL_CCCH_MessageType__c1_PR_rrcReject: LOG_I(NR_RRC, "[UE%ld] Logical Channel DL-CCCH (SRB0), Received RRCReject \n", rrc->ue_id); + nr_rrc_process_rrcreject(rrc, dl_ccch_msg->message.choice.c1->choice.rrcReject); rval = 0; break;