From 5df6153024023a036d895e631a9de8bc2e509b9b Mon Sep 17 00:00:00 2001 From: francescomani Date: Thu, 5 Dec 2024 13:49:25 +0100 Subject: [PATCH] remove unnecessary nr_ue_manage_ra_procedure function --- openair2/LAYER2/NR_MAC_UE/mac_proto.h | 9 ----- openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c | 42 +------------------- openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c | 27 ++++++++++--- 3 files changed, 23 insertions(+), 55 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h index c3f919be5e..38188d86c6 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h @@ -297,15 +297,6 @@ 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); - -/*@mac pointer to MAC instance -@param CC_id Component Carrier Index -@param frame -@param gNB_id gNB index -@param nr_slot_tx slot for PRACH transmission -@returns indication to generate PRACH to phy */ -void nr_ue_manage_ra_procedure(NR_UE_MAC_INST_t *mac, int CC_id, frame_t frame, uint8_t gNB_id, int nr_slot_tx); - void prepare_msg4_msgb_feedback(NR_UE_MAC_INST_t *mac, int pid, int ack_nack); void configure_initial_pucch(PUCCH_sched_t *pucch, int res_ind); void release_PUCCH_SRS(NR_UE_MAC_INST_t *mac); diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c index f6da74e102..3a93c88102 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c @@ -1068,6 +1068,7 @@ bool init_RA(NR_UE_MAC_INST_t *mac, int frame) twostep_generic, &mac->ntn_ta); ra->start_response_window = false; + return true; } @@ -1159,47 +1160,6 @@ void nr_get_Msg3_MsgA_PUSCH_payload(NR_UE_MAC_INST_t *mac, uint8_t *buf, int TBS memcpy(ra->Msg3_buffer, buf, sizeof(uint8_t) * TBS_max); } -/** - * Function: handles Random Access Preamble Initialization (5.1.1 TS 38.321) - * handles Random Access Response reception (5.1.4 TS 38.321) - * Note: In SA mode the Msg3 contains a CCCH SDU, therefore no C-RNTI MAC CE is transmitted. - * - * @prach_resources pointer to PRACH resources - * @prach_pdu pointer to FAPI UL PRACH PDU - * @mod_id module ID - * @CC_id CC ID - * @frame current UL TX frame - * @gNB_id gNB ID - * @nr_slot_tx current UL TX slot - */ -void nr_ue_manage_ra_procedure(NR_UE_MAC_INST_t *mac, int CC_id, frame_t frame, uint8_t gNB_id, int nr_slot_tx) -{ - RA_config_t *ra = &mac->ra; - if (ra->ra_state == nrRA_UE_IDLE) { - bool init_success = init_RA(mac, frame); - if (!init_success) - return; - else { - // perform the Random Access Resource selection procedure (see clause 5.1.2 and .2a) - ra_resource_selection(mac); - } - } - - LOG_D(NR_MAC, "[UE %d][%d.%d]: ra_state %d, RA_active %d\n", mac->ue_id, frame, nr_slot_tx, ra->ra_state, ra->RA_active); - - if (nr_timer_is_active(&ra->RA_backoff_timer)) { - // if the criteria (as defined in clause 5.1.2) to select contention-free Random Access Resources - // is met during the backoff time - // TODO verify what does this mean - if (ra->cfra) { - // perform the Random Access Resource selection procedure - nr_timer_stop(&ra->RA_backoff_timer); - mac->ra.ra_state = nrRA_GENERATE_PREAMBLE; - ra_resource_selection(mac); - } - } -} - // Handlig successful RA completion @ MAC layer // according to section 5 of 3GPP TS 38.321 version 16.2.1 Release 16 // todo: diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index 6ae011006f..fc69b5e517 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -246,6 +246,18 @@ void update_mac_timers(NR_UE_MAC_INST_t *mac) // perform the Random Access Resource selection procedure after the backoff time mac->ra.ra_state = nrRA_GENERATE_PREAMBLE; ra_resource_selection(mac); + } else { + if (nr_timer_is_active(&mac->ra.RA_backoff_timer)) { + // if the criteria (as defined in clause 5.1.2) to select contention-free Random Access Resources + // is met during the backoff time + // TODO verify what does this mean + if (mac->ra.cfra) { + // perform the Random Access Resource selection procedure + nr_timer_stop(&mac->ra.RA_backoff_timer); + mac->ra.ra_state = nrRA_GENERATE_PREAMBLE; + ra_resource_selection(mac); + } + } } } @@ -1315,11 +1327,18 @@ void nr_ue_ul_scheduler(NR_UE_MAC_INST_t *mac, nr_uplink_indication_t *ul_info) uint32_t gNB_index = ul_info->gNB_index; RA_config_t *ra = &mac->ra; - if (mac->state == UE_PERFORMING_RA) { - nr_ue_manage_ra_procedure(mac, cc_id, frame_tx, gNB_index, slot_tx); - nr_ue_prach_scheduler(mac, frame_tx, slot_tx); + + if (mac->state == UE_PERFORMING_RA && ra->ra_state == nrRA_UE_IDLE) { + bool res = init_RA(mac, frame_tx); + if (res) { + // perform the Random Access Resource selection procedure (see clause 5.1.2 and .2a) + ra_resource_selection(mac); + } } + if (mac->state == UE_PERFORMING_RA && ra->ra_state == nrRA_GENERATE_PREAMBLE) + nr_ue_prach_scheduler(mac, frame_tx, slot_tx); + bool BSRsent = false; if (mac->state == UE_CONNECTED) { nr_ue_periodic_srs_scheduling(mac, frame_tx, slot_tx); @@ -2075,8 +2094,6 @@ static bool is_prach_frame(frame_t frame, prach_occasion_info_t *prach_occasion_ static void nr_ue_prach_scheduler(NR_UE_MAC_INST_t *mac, frame_t frameP, slot_t slotP) { RA_config_t *ra = &mac->ra; - if (ra->ra_state != nrRA_GENERATE_PREAMBLE) - return; // Get any valid PRACH occasion in the current slot for the selected SSB index prach_occasion_info_t *prach_occasion_info = &ra->sched_ro_info;