From 3166f203837b1f2a6317b7d00ac2466c554216c4 Mon Sep 17 00:00:00 2001 From: francescomani Date: Thu, 2 May 2024 19:29:35 +0200 Subject: [PATCH] trigger RA DL or UL data arrival during RRC_CONNECTED when UL synchronisation status is non-synchronised --- openair2/LAYER2/NR_MAC_UE/config_ue.c | 3 +++ openair2/LAYER2/NR_MAC_UE/mac_proto.h | 1 + openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c | 13 +---------- openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c | 5 +++++ openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c | 23 ++++++++++++++++++++ 5 files changed, 33 insertions(+), 12 deletions(-) diff --git a/openair2/LAYER2/NR_MAC_UE/config_ue.c b/openair2/LAYER2/NR_MAC_UE/config_ue.c index 6f5cdef338..fab0fb7a7c 100644 --- a/openair2/LAYER2/NR_MAC_UE/config_ue.c +++ b/openair2/LAYER2/NR_MAC_UE/config_ue.c @@ -1578,7 +1578,10 @@ static void configure_timeAlignmentTimer(NR_timer_t *time_alignment_timer, NR_Ti } // length of slot is (1/2^scs)ms uint32_t n_slots = timer_ms != UINT_MAX ? (timer_ms << scs) : UINT_MAX; + bool timer_was_active = nr_timer_is_active(time_alignment_timer); nr_timer_setup(time_alignment_timer, n_slots, 1); // 1 slot update rate + if (timer_was_active) + nr_timer_start(time_alignment_timer); } void nr_rrc_mac_config_req_reset(module_id_t module_id, diff --git a/openair2/LAYER2/NR_MAC_UE/mac_proto.h b/openair2/LAYER2/NR_MAC_UE/mac_proto.h index dcd6a62f5d..e2d6125145 100644 --- a/openair2/LAYER2/NR_MAC_UE/mac_proto.h +++ b/openair2/LAYER2/NR_MAC_UE/mac_proto.h @@ -349,6 +349,7 @@ void free_rach_structures(NR_UE_MAC_INST_t *nr_mac, int bwp_id); void schedule_RA_after_SR_failure(NR_UE_MAC_INST_t *mac); void nr_Msg1_transmitted(NR_UE_MAC_INST_t *mac); void nr_Msg3_transmitted(NR_UE_MAC_INST_t *mac, uint8_t CC_id, frame_t frameP, slot_t slotP, uint8_t gNB_id); +void trigger_MAC_UE_RA(NR_UE_MAC_INST_t *mac); void nr_get_msg3_payload(NR_UE_MAC_INST_t *mac, uint8_t *buf, int TBS_max); void handle_time_alignment_timer_expired(NR_UE_MAC_INST_t *mac); int8_t nr_ue_process_dci_freq_dom_resource_assignment(nfapi_nr_ue_pusch_pdu_t *pusch_config_pdu, diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c index 66fbf20630..6272c4c33f 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ra_procedures.c @@ -936,23 +936,12 @@ void nr_ra_failed(NR_UE_MAC_INST_t *mac, uint8_t CC_id, NR_PRACH_RESOURCES_t *pr } } -void schedule_RA_after_SR_failure(NR_UE_MAC_INST_t *mac) +void trigger_MAC_UE_RA(NR_UE_MAC_INST_t *mac) { LOG_W(NR_MAC, "Triggering new RA procedure for UE with RNTI %x\n", mac->crnti); mac->state = UE_SYNC; reset_ra(mac, false); mac->ra.msg3_C_RNTI = true; - // release PUCCH for all Serving Cells; - // release SRS for all Serving Cells; - release_PUCCH_SRS(mac); - // clear any configured downlink assignments and uplink grants; - int scs = mac->current_UL_BWP->scs; - if (mac->dl_config_request) - memset(mac->dl_config_request, 0, sizeof(*mac->dl_config_request)); - if (mac->ul_config_request) - clear_ul_config_request(mac, scs); - // clear any PUSCH resources for semi-persistent CSI reporting - // TODO we don't have semi-persistent CSI reporting } void prepare_msg4_feedback(NR_UE_MAC_INST_t *mac, int pid, int ack_nack) diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index f9d23177eb..32d0dc72cf 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -2967,6 +2967,11 @@ void nr_ue_send_sdu(NR_UE_MAC_INST_t *mac, nr_downlink_indication_t *dl_info, in // DCCH logical channel, or CCCH logical channel if (mac->data_inactivity_timer) nr_timer_start(mac->data_inactivity_timer); + // DL data arrival during RRC_CONNECTED when UL synchronisation status is "non-synchronised" + if (!nr_timer_is_active(&mac->time_alignment_timer) && mac->state == UE_CONNECTED && !get_softmodem_params()->phy_test) { + trigger_MAC_UE_RA(mac); + break; + } nr_ue_process_mac_pdu(mac, dl_info, pdu_id); break; case FAPI_NR_RX_PDU_TYPE_RAR : diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index d742f7cc9a..84a35dcf52 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -1298,6 +1298,24 @@ static bool check_pucchres_for_pending_SR(NR_PUCCH_Config_t *pucch_Config, int t return false; } +void schedule_RA_after_SR_failure(NR_UE_MAC_INST_t *mac) +{ + if (get_softmodem_params()->phy_test) + return; // cannot trigger RA in phytest mode + trigger_MAC_UE_RA(mac); + // release PUCCH for all Serving Cells; + // release SRS for all Serving Cells; + release_PUCCH_SRS(mac); + // clear any configured downlink assignments and uplink grants; + int scs = mac->current_UL_BWP->scs; + if (mac->dl_config_request) + memset(mac->dl_config_request, 0, sizeof(*mac->dl_config_request)); + if (mac->ul_config_request) + clear_ul_config_request(mac, scs); + // clear any PUSCH resources for semi-persistent CSI reporting + // TODO we don't have semi-persistent CSI reporting +} + static void nr_update_sr(NR_UE_MAC_INST_t *mac) { NR_UE_SCHEDULING_INFO *sched_info = &mac->scheduling_info; @@ -1486,6 +1504,11 @@ void nr_ue_ul_scheduler(NR_UE_MAC_INST_t *mac, nr_uplink_indication_t *ul_info) } else { if (ulcfg_pdu->pusch_config_pdu.pusch_data.new_data_indicator && (mac->state == UE_CONNECTED || (ra->ra_state == nrRA_WAIT_RAR && ra->cfra))) { + if (!nr_timer_is_active(&mac->time_alignment_timer) && mac->state == UE_CONNECTED && !get_softmodem_params()->phy_test) { + // UL data arrival during RRC_CONNECTED when UL synchronisation status is "non-synchronised" + trigger_MAC_UE_RA(mac); + return; + } // Getting IP traffic to be transmitted int tx_power = ulcfg_pdu->pusch_config_pdu.tx_power; int P_CMAX = nr_get_Pcmax(mac->p_Max,