Refactor UE (RRC/MAC): typed NR_MAC_RRC_START_RA for T300 and re-estab

RRC starts random access via NR_MAC_RRC_START_RA with an explicit
cause. RA trigger is no longer piggybacked on NR_MAC_RRC_CONFIG_RESET.
T300 expiry and RRC re-establishment are the call sites switched in this
commit. MAC handles setup/T300 and re-establishment paths in
nr_mac_start_ra().

Changes:
- Add nr_mac_rrc_types.h (nr_mac_ra_start_cause_t)
- Add nr_mac_rrc_start_ra_t in rrc_messages_types.h
- In rrc_UE.c, add nr_rrc_trigger_mac_ra(), call it from
  handle_t300_expiry and nr_rrc_initiate_rrcReestablishment
- In config_ue.c:
  - add nr_mac_start_ra() entry point with causes switch
  - add nr_rrc_mac_start_ra() handler
  - remove T300_EXPIRY, RE_ESTABLISHMENT reset handling
    in nr_rrc_mac_config_req_reset, now delegated to
    nr_mac_start_ra
- mac_defs.h: drop T300_EXPIRY from NR_UE_MAC_reset_cause_t

Signed-off-by: Guido Casati <guido.casati@openairinterface.org>
This commit is contained in:
Guido Casati
2026-06-01 21:35:32 +02:00
parent bae10b8831
commit c9e82d6a12
8 changed files with 81 additions and 35 deletions

View File

@@ -30,6 +30,7 @@
#include "NR_BCCH-BCH-Message.h"
#include "NR_ReestablishmentCause.h"
#include "NR_UE-NR-Capability.h"
#include "RRC/NR_UE/nr_mac_rrc_types.h"
//-------------------------------------------------------------------------------------------//
// Messages for RRC logging
@@ -460,6 +461,9 @@ typedef struct {
int get_sib;
} nr_mac_rrc_sched_sib_t;
typedef struct {
nr_mac_ra_start_cause_t cause;
} nr_mac_rrc_start_ra_t;
enum payload_type {
NR_MAC_RRC_CONFIG_RESET,
@@ -480,6 +484,7 @@ typedef struct {
nr_mac_rrc_config_sib1_t config_sib1;
nr_mac_rrc_sched_sib_t sched_sib;
nr_mac_rrc_config_other_sib_t config_other_sib;
nr_mac_rrc_start_ra_t start_ra;
nr_mac_rrc_resume_rb_t resume_rb;
} payload;
} nr_mac_rrc_message_t;

View File

@@ -1879,35 +1879,11 @@ void nr_rrc_mac_config_req_reset(module_id_t module_id, NR_UE_MAC_reset_cause_t
release_mac_configuration(mac, cause);
mac->state = UE_DETACHING;
break;
case T300_EXPIRY:
reset_ra(mac, false);
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);
nr_ue_reset_sync_state(mac, true);
release_mac_configuration(mac, cause);
// suspend all RBs except SRB0
for (int j = 0; j < mac->lc_ordered_list.count; j++) {
nr_lcordered_info_t *lc = mac->lc_ordered_list.array[j];
if (lc->rb.type == NR_LCID_SRB && lc->rb.choice.srb_id == 0)
continue;
lc->rb_suspended = true;
}
// apply the timeAlignmentTimerCommon included in SIB1
configure_timeAlignmentTimer(&mac->time_alignment_timer, mac->timeAlignmentTimerCommon, mac->current_UL_BWP->scs);
// new sync with old cell ID (re-establishment on the same cell)
sync_req.target_Nid_cell = mac->physCellId;
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);
@@ -2042,6 +2018,50 @@ void nr_rrc_mac_config_req_paging_ue_id(module_id_t module_id, uint64_t fiveG_S_
pthread_mutex_unlock(&mac->if_mutex);
}
static void nr_mac_start_ra(NR_UE_MAC_INST_t *mac, module_id_t module_id, nr_mac_ra_start_cause_t cause)
{
switch (cause) {
case NR_MAC_RA_START_SETUP:
case NR_MAC_RA_START_T300:
reset_ra(mac, false);
reset_mac_inst(mac);
mac->msg3_C_RNTI = false;
mac->state = UE_PERFORMING_RA;
break;
case NR_MAC_RA_START_REESTABLISHMENT: {
fapi_nr_synch_request_t sync_req = {.target_Nid_cell = mac->physCellId, .ssb_bw_scan = false};
reset_mac_inst(mac);
nr_ue_mac_default_configs(mac);
nr_ue_reset_sync_state(mac, true);
release_mac_configuration(mac, RE_ESTABLISHMENT);
for (int j = 0; j < mac->lc_ordered_list.count; j++) {
nr_lcordered_info_t *lc = mac->lc_ordered_list.array[j];
if (lc->rb.type == NR_LCID_SRB && lc->rb.choice.srb_id == 0)
continue;
lc->rb_suspended = true;
}
configure_timeAlignmentTimer(&mac->time_alignment_timer, mac->timeAlignmentTimerCommon, mac->current_UL_BWP->scs);
nr_ue_send_synch_request(mac, module_id, 0, &sync_req);
break;
}
default:
AssertFatal(false, "unknown nr_mac_ra_start_cause_t %d\n", cause);
}
}
/** @brief All RRC-initiated RA entry points */
void nr_rrc_mac_start_ra(module_id_t module_id, nr_mac_ra_start_cause_t cause)
{
NR_UE_MAC_INST_t *mac = get_mac_inst(module_id);
int ret = pthread_mutex_lock(&mac->if_mutex);
AssertFatal(!ret, "mutex failed %d\n", ret);
nr_mac_start_ra(mac, module_id, cause);
ret = pthread_mutex_unlock(&mac->if_mutex);
AssertFatal(!ret, "mutex failed %d\n", ret);
}
void nr_rrc_mac_config_req_sib1(module_id_t module_id, int cc_idP, NR_SIB1_t *sib1, bool can_start_ra)
{
NR_UE_MAC_INST_t *mac = get_mac_inst(module_id);

View File

@@ -177,7 +177,6 @@ typedef struct {
typedef enum {
GO_TO_IDLE,
DETACH,
T300_EXPIRY,
RE_ESTABLISHMENT,
RRC_SETUP_REESTAB_RESUME,
UL_SYNC_LOST_T430_EXPIRED,

View File

@@ -67,6 +67,7 @@ void nr_rrc_mac_config_req_mib(module_id_t module_id, int cc_idP, NR_MIB_t *mibP
void nr_rrc_mac_sched_sib(module_id_t module_id, int sched_sib);
void nr_rrc_mac_config_req_sib1(module_id_t module_id, int cc_idP, NR_SIB1_t *sib1, bool can_start_ra);
void nr_rrc_mac_config_req_paging_ue_id(module_id_t module_id, uint64_t fiveG_S_TMSI);
void nr_rrc_mac_start_ra(module_id_t module_id, nr_mac_ra_start_cause_t cause);
struct position; /* forward declaration */
void nr_rrc_mac_config_other_sib(module_id_t module_id, NR_SIB19_r17_t *sib19_r17, int hfn, int frame, bool can_start_ra);

View File

@@ -144,6 +144,9 @@ void process_msg_rcc_to_mac(nr_mac_rrc_message_t *msg, int instance_id)
msg->payload.config_other_sib.frame,
msg->payload.config_other_sib.can_start_ra);
} break;
case NR_MAC_RRC_START_RA:
nr_rrc_mac_start_ra(instance_id, msg->payload.start_ra.cause);
break;
case NR_MAC_RRC_SCHED_SIB:
nr_rrc_mac_sched_sib(instance_id, msg->payload.sched_sib.get_sib);
break;

View File

@@ -0,0 +1,14 @@
/*
* SPDX-License-Identifier: LicenseRef-CSSL-1.0
*/
#ifndef NR_MAC_RRC_TYPES_H_
#define NR_MAC_RRC_TYPES_H_
typedef enum {
NR_MAC_RA_START_SETUP,
NR_MAC_RA_START_T300,
NR_MAC_RA_START_REESTABLISHMENT,
} nr_mac_ra_start_cause_t;
#endif /* NR_MAC_RRC_TYPES_H_ */

View File

@@ -128,6 +128,17 @@ static void nr_rrc_send_msg_to_mac(NR_UE_RRC_INST_t *rrc, nr_mac_rrc_message_t *
pushNotifiedFIFO(rrc->mac_input_nf, nf_msg);
}
/** @brief Ask MAC to start or restart random access
* @param rrc UE RRC instance
* @param cause Why RA is started (setup, T300, post-SIB, re-establishment) */
static void nr_rrc_trigger_mac_ra(NR_UE_RRC_INST_t *rrc, nr_mac_ra_start_cause_t cause)
{
nr_mac_rrc_message_t rrc_msg = {0};
rrc_msg.payload_type = NR_MAC_RRC_START_RA;
rrc_msg.payload.start_ra.cause = cause;
nr_rrc_send_msg_to_mac(rrc, &rrc_msg);
}
NR_UE_RRC_INST_t *get_NR_UE_rrc_inst(int instance)
{
AssertFatal(instance >= 0 && instance < MAX_NUM_NR_UE_INST, "RRC instance %d out of bounds\n", instance);
@@ -3356,10 +3367,7 @@ static void nr_rrc_initiate_rrcReestablishment(NR_UE_RRC_INST_t *rrc, NR_Reestab
// reset MAC
// release spCellConfig, if configured
// perform cell selection in accordance with the cell selection process
nr_mac_rrc_message_t rrc_msg = {0};
rrc_msg.payload_type = NR_MAC_RRC_CONFIG_RESET;
rrc_msg.payload.config_reset.cause = RE_ESTABLISHMENT;
nr_rrc_send_msg_to_mac(rrc, &rrc_msg);
nr_rrc_trigger_mac_ra(rrc, NR_MAC_RA_START_REESTABLISHMENT);
}
void handle_RRCRelease(NR_UE_RRC_INST_t *rrc)
@@ -3579,12 +3587,7 @@ void handle_t300_expiry(NR_UE_RRC_INST_t *rrc)
rrc->ra_trigger = RRC_CONNECTION_SETUP;
nr_rrc_ue_prepare_RRCSetupRequest(rrc);
// reset MAC, release the MAC configuration
NR_UE_MAC_reset_cause_t cause = T300_EXPIRY;
nr_mac_rrc_message_t rrc_msg = {0};
rrc_msg.payload_type = NR_MAC_RRC_CONFIG_RESET;
rrc_msg.payload.config_reset.cause = cause;
nr_rrc_send_msg_to_mac(rrc, &rrc_msg);
nr_rrc_trigger_mac_ra(rrc, NR_MAC_RA_START_T300);
// TODO handle connEstFailureControl
// TODO inform upper layers about the failure to establish the RRC connection

View File

@@ -40,6 +40,7 @@
#include "as_message.h"
#include "common/utils/nr/nr_common.h"
#include "notified_fifo.h"
#include "RRC/NR_UE/nr_mac_rrc_types.h"
#define NB_CNX_UE 2//MAX_MANAGED_RG_PER_MOBILE
#define MAX_MEAS_OBJ 64