From dcc17a9d701b91e15b37a93935f4e5d757f7432a Mon Sep 17 00:00:00 2001 From: francescomani Date: Wed, 4 Dec 2024 19:11:05 +0100 Subject: [PATCH] signaling RRC RA problems (leading to possible radio link failure) --- .../SIMULATION/NR_PHY/nr_dummy_functions.c | 2 +- openair2/COMMON/mac_messages_types.h | 1 - openair2/LAYER2/NR_MAC_UE/mac_proto.h | 9 +-------- openair2/LAYER2/NR_MAC_UE/main_ue_nr.c | 8 ++++++-- openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c | 13 +++++++++---- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 2 +- openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c | 2 +- .../tests/test_nr_ue_ra_procedures.cpp | 2 +- openair2/RRC/NR_UE/L2_interface_ue.c | 3 +-- openair2/RRC/NR_UE/L2_interface_ue.h | 2 +- openair2/RRC/NR_UE/rrc_UE.c | 19 ++++++++++++++----- 11 files changed, 36 insertions(+), 27 deletions(-) diff --git a/openair1/SIMULATION/NR_PHY/nr_dummy_functions.c b/openair1/SIMULATION/NR_PHY/nr_dummy_functions.c index d55322156b..973aa60930 100644 --- a/openair1/SIMULATION/NR_PHY/nr_dummy_functions.c +++ b/openair1/SIMULATION/NR_PHY/nr_dummy_functions.c @@ -36,7 +36,7 @@ void nr_mac_rrc_sync_ind(const module_id_t module_id, void nr_mac_rrc_msg3_ind(const module_id_t mod_id, int rnti, int gnb_id) {} -void nr_mac_rrc_ra_ind(const module_id_t mod_id, int frame, bool success) {} +void nr_mac_rrc_ra_ind(const module_id_t mod_id, bool success) {} void nr_mac_rrc_inactivity_timer_ind(const module_id_t mod_id) {} diff --git a/openair2/COMMON/mac_messages_types.h b/openair2/COMMON/mac_messages_types.h index bc9e8f6c8a..882dba7740 100644 --- a/openair2/COMMON/mac_messages_types.h +++ b/openair2/COMMON/mac_messages_types.h @@ -72,7 +72,6 @@ // Messages between RRC and MAC layers typedef struct NRRrcMacRaInd_s { - uint32_t frame; bool RA_succeeded; } NRRrcMacRaInd; diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h index c494d477f5..c3f919be5e 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h @@ -292,15 +292,8 @@ void configure_csi_resource_mapping(fapi_nr_dl_config_csirs_pdu_rel15_t *csirs_c uint32_t bwp_size, uint32_t bwp_start); -/* \brief This function schedules the Msg3 transmission -@param -@param -@param -@returns void -*/ -void nr_ue_msg3_scheduler(NR_UE_MAC_INST_t *mac, frame_t current_frame, slot_t current_slot, uint8_t Msg3_tda_id); -void nr_ra_contention_resolution_failed(RA_config_t *ra); +void nr_ra_contention_resolution_failed(NR_UE_MAC_INST_t *mac); void nr_ra_succeeded(NR_UE_MAC_INST_t *mac, const uint8_t gNB_index, const frame_t frame, const int slot); void nr_ra_backoff_setting(RA_config_t *ra); void nr_get_RA_window(NR_UE_MAC_INST_t *mac); diff --git a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c index 7cac155bc6..0d957ad4b5 100644 --- a/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c +++ b/openair2/LAYER2/NR_MAC_UE/main_ue_nr.c @@ -180,9 +180,11 @@ void reset_mac_inst(NR_UE_MAC_INST_t *nr_mac) if (nr_mac->data_inactivity_timer) nr_timer_stop(nr_mac->data_inactivity_timer); nr_timer_stop(&nr_mac->time_alignment_timer); - nr_timer_stop(&nr_mac->ra.contention_resolution_timer); nr_timer_stop(&nr_mac->scheduling_info.sr_DelayTimer); nr_timer_stop(&nr_mac->scheduling_info.retxBSR_Timer); + nr_timer_stop(&nr_mac->ra.response_window_timer); + nr_timer_stop(&nr_mac->ra.RA_backoff_timer); + nr_timer_stop(&nr_mac->ra.contention_resolution_timer); for (int i = 0; i < NR_MAX_SR_ID; i++) nr_timer_stop(&nr_mac->scheduling_info.sr_info[i].prohibitTimer); @@ -194,8 +196,10 @@ void reset_mac_inst(NR_UE_MAC_INST_t *nr_mac) nr_mac->ul_harq_info[k].last_ndi = -1; // initialize to invalid value // stop any ongoing RACH procedure - if (nr_mac->ra.ra_state < nrRA_SUCCEEDED) + if (nr_mac->ra.RA_active) { nr_mac->ra.ra_state = nrRA_UE_IDLE; + nr_mac->ra.RA_active = false; + } // discard explicitly signalled contention-free Random Access Resources // TODO not sure what needs to be done here diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c index f198f4f17a..f6da74e102 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c @@ -879,6 +879,7 @@ bool init_RA(NR_UE_MAC_INST_t *mac, int frame) // Random acces procedure initialization mac->state = UE_PERFORMING_RA; ra->RA_active = true; + ra->msg3_C_RNTI = false; NR_PRACH_RESOURCES_t *prach_resources = &ra->prach_resources; fapi_nr_config_request_t *cfg = &mac->phy_config.config_req; // flush MSG3 buffer @@ -1234,7 +1235,7 @@ void nr_ra_succeeded(NR_UE_MAC_INST_t *mac, const uint8_t gNB_index, const frame ra->ra_state = nrRA_SUCCEEDED; mac->state = UE_CONNECTED; free_and_zero(ra->Msg3_buffer); - nr_mac_rrc_ra_ind(mac->ue_id, frame, true); + nr_mac_rrc_ra_ind(mac->ue_id, true); } void nr_ra_backoff_setting(RA_config_t *ra) @@ -1247,8 +1248,10 @@ void nr_ra_backoff_setting(RA_config_t *ra) nr_timer_start(&ra->RA_backoff_timer); } -void nr_ra_contention_resolution_failed(RA_config_t *ra) +void nr_ra_contention_resolution_failed(NR_UE_MAC_INST_t *mac) { + LOG_W(MAC, "[UE %d] Contention resolution failed\n", mac->ue_id); + RA_config_t *ra = &mac->ra; // discard the TEMPORARY_C-RNTI ra->t_crnti = 0; // flush MSG3 buffer @@ -1256,7 +1259,8 @@ void nr_ra_contention_resolution_failed(RA_config_t *ra) NR_PRACH_RESOURCES_t *prach_resources = &ra->prach_resources; prach_resources->preamble_tx_counter++; if (prach_resources->preamble_tx_counter == ra->preambleTransMax + 1) { - // TODO indicate a Random Access problem to upper layers + // indicate a Random Access problem to upper layers + nr_mac_rrc_ra_ind(mac->ue_id, false); } else { // TODO handle msgA-TransMax (go back to 4-step if the threshold is reached) // starting backoff time @@ -1275,7 +1279,8 @@ void nr_rar_not_successful(NR_UE_MAC_INST_t *mac) // if the Random Access Preamble is transmitted on the SpCell // TODO to be verified, this means SA if I'm not mistaken if (IS_SA_MODE(get_softmodem_params())) { - // TODO indicate a Random Access problem to upper layers + // indicate a Random Access problem to upper layers + nr_mac_rrc_ra_ind(mac->ue_id, false); } else { // if the Random Access Preamble is transmitted on an SCell: // consider the Random Access procedure unsuccessfully completed. diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index 8d42075c48..afe7438949 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -3722,7 +3722,7 @@ void nr_ue_process_mac_pdu(NR_UE_MAC_INST_t *mac, nr_downlink_indication_t *dl_i nr_ra_succeeded(mac, gNB_index, frameP, slot); } else if (!ra_success) { // consider this Contention Resolution not successful and discard the successfully decoded MAC PDU - nr_ra_contention_resolution_failed(ra); + nr_ra_contention_resolution_failed(mac); return; } } diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index c7a6d99c33..6ae011006f 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -194,7 +194,7 @@ void update_mac_timers(NR_UE_MAC_INST_t *mac) handle_time_alignment_timer_expired(mac); bool contention_resolution_expired = nr_timer_tick(&mac->ra.contention_resolution_timer); if (contention_resolution_expired) - nr_ra_contention_resolution_failed(&mac->ra); + nr_ra_contention_resolution_failed(mac); for (int j = 0; j < NR_MAX_SR_ID; j++) nr_timer_tick(&mac->scheduling_info.sr_info[j].prohibitTimer); nr_timer_tick(&mac->scheduling_info.sr_DelayTimer); diff --git a/openair2/LAYER2/NR_MAC_UE/tests/test_nr_ue_ra_procedures.cpp b/openair2/LAYER2/NR_MAC_UE/tests/test_nr_ue_ra_procedures.cpp index 504abae957..45fc34b47c 100644 --- a/openair2/LAYER2/NR_MAC_UE/tests/test_nr_ue_ra_procedures.cpp +++ b/openair2/LAYER2/NR_MAC_UE/tests/test_nr_ue_ra_procedures.cpp @@ -29,7 +29,7 @@ softmodem_params_t *get_softmodem_params(void) { return &softmodem_params; } -void nr_mac_rrc_ra_ind(const module_id_t mod_id, int frame, bool success) +void nr_mac_rrc_ra_ind(const module_id_t mod_id, bool success) { } tbs_size_t mac_rlc_data_req(const module_id_t module_idP, diff --git a/openair2/RRC/NR_UE/L2_interface_ue.c b/openair2/RRC/NR_UE/L2_interface_ue.c index 7fd34ff91c..74f4170abb 100644 --- a/openair2/RRC/NR_UE/L2_interface_ue.c +++ b/openair2/RRC/NR_UE/L2_interface_ue.c @@ -177,10 +177,9 @@ void nr_ue_rrc_timer_trigger(int instance, int frame, int gnb_id) itti_send_msg_to_task(TASK_RRC_NRUE, instance, message_p); } -void nr_mac_rrc_ra_ind(const module_id_t mod_id, int frame, bool success) +void nr_mac_rrc_ra_ind(const module_id_t mod_id, bool success) { MessageDef *message_p = itti_alloc_new_message(TASK_MAC_UE, 0, NR_RRC_MAC_RA_IND); - NR_RRC_MAC_RA_IND (message_p).frame = frame; NR_RRC_MAC_RA_IND (message_p).RA_succeeded = success; itti_send_msg_to_task(TASK_RRC_NRUE, GNB_MODULE_ID_TO_INSTANCE(mod_id), message_p); } diff --git a/openair2/RRC/NR_UE/L2_interface_ue.h b/openair2/RRC/NR_UE/L2_interface_ue.h index 05888cbc0e..469faf2ece 100644 --- a/openair2/RRC/NR_UE/L2_interface_ue.h +++ b/openair2/RRC/NR_UE/L2_interface_ue.h @@ -39,7 +39,7 @@ void nr_mac_rrc_data_ind_ue(const module_id_t module_id, void nr_mac_rrc_inactivity_timer_ind(const module_id_t mod_id); void nr_mac_rrc_msg3_ind(const module_id_t mod_id, const int rnti, int gnb_id); void nr_ue_rrc_timer_trigger(int instance, int frame, int gnb_id); -void nr_mac_rrc_ra_ind(const module_id_t mod_id, int frame, bool success); +void nr_mac_rrc_ra_ind(const module_id_t mod_id, bool success); void nsa_sendmsg_to_lte_ue(const void *message, size_t msg_len, Rrc_Msg_Type_t msg_type); void process_msg_rcc_to_mac(MessageDef *msg); #endif diff --git a/openair2/RRC/NR_UE/rrc_UE.c b/openair2/RRC/NR_UE/rrc_UE.c index f61ce49494..aa9e38a3c5 100644 --- a/openair2/RRC/NR_UE/rrc_UE.c +++ b/openair2/RRC/NR_UE/rrc_UE.c @@ -1975,6 +1975,16 @@ void nr_rrc_handle_ra_indication(NR_UE_RRC_INST_t *rrc, bool ra_succeeded) nr_timer_stop(&timers->T304); // TODO handle the rest of procedures as described in 5.3.5.3 for when // reconfigurationWithSync is included in spCellConfig + } else if (!ra_succeeded) { + // upon random access problem indication from MCG MAC + // while neither T300, T301, T304, T311 nor T319 are running + // consider radio link failure to be detected + if (!nr_timer_is_active(&timers->T300) + && !nr_timer_is_active(&timers->T301) + && !nr_timer_is_active(&timers->T304) + && !nr_timer_is_active(&timers->T311) + && !nr_timer_is_active(&timers->T319)) + handle_rlf_detection(rrc); } } @@ -2040,11 +2050,10 @@ void *rrc_nrue(void *notUsed) case NR_RRC_MAC_RA_IND: LOG_D(NR_RRC, - "[UE %ld] Received %s: frame %d RA %s\n", - rrc->ue_id, - ITTI_MSG_NAME(msg_p), - NR_RRC_MAC_RA_IND(msg_p).frame, - NR_RRC_MAC_RA_IND(msg_p).RA_succeeded ? "successful" : "failed"); + "[UE %ld] Received %s: RA %s\n", + rrc->ue_id, + ITTI_MSG_NAME(msg_p), + NR_RRC_MAC_RA_IND(msg_p).RA_succeeded ? "successful" : "failed"); nr_rrc_handle_ra_indication(rrc, NR_RRC_MAC_RA_IND(msg_p).RA_succeeded); break;