diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c index ed23d52aa7..a44154100b 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_procedures.c @@ -2512,11 +2512,10 @@ int8_t nr_ue_get_SR(NR_UE_MAC_INST_t *mac, frame_t frame, slot_t slot, NR_Schedu sr_info->maxTransmissions); // initiate a Random Access procedure (see clause 5.1) on the SpCell and cancel all pending SRs. - schedule_RA_after_SR_failure(mac); sr_info->pending = false; sr_info->counter = 0; nr_timer_stop(&sr_info->prohibitTimer); - + schedule_RA_after_SR_failure(mac); return -1; } diff --git a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c index 1f17931264..455a8d7c17 100644 --- a/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c +++ b/openair2/LAYER2/NR_MAC_UE/nr_ue_scheduler.c @@ -1122,6 +1122,19 @@ void nr_ue_dl_scheduler(NR_UE_MAC_INST_t *mac, nr_downlink_indication_t *dl_info LOG_E(NR_MAC, "Internal error, no scheduled_response function\n"); } +static bool check_pucchres_for_pending_SR(NR_PUCCH_Config_t *pucch_Config, int target_sr_id) +{ + for (int id = 0; id < pucch_Config->schedulingRequestResourceToAddModList->list.count; id++) { + NR_SchedulingRequestResourceConfig_t *sr_Config = pucch_Config->schedulingRequestResourceToAddModList->list.array[id]; + if (sr_Config->schedulingRequestID == target_sr_id) { + if (sr_Config->resource) { + return true; + } + } + } + return false; +} + static void nr_update_sr(NR_UE_MAC_INST_t *mac) { NR_UE_SCHEDULING_INFO *sched_info = &mac->scheduling_info; @@ -1164,17 +1177,27 @@ static void nr_update_sr(NR_UE_MAC_INST_t *mac) // if the UL-SCH resources available for a new transmission do not meet the LCP mapping restrictions // TODO not implemented - // trigger SR if (lc_info->sr_id < 0 || lc_info->sr_id >= NR_MAX_SR_ID) LOG_E(NR_MAC, "No SR corresponding to this LCID\n"); // TODO not sure what to do here else { nr_sr_info_t *sr = &sched_info->sr_info[lc_info->sr_id]; if (!sr->pending) { - LOG_D(NR_MAC, "Triggering SR for ID %d\n", lc_info->sr_id); - sr->pending = true; - sr->counter = 0; - // TODO initiate a Random Access procedure on the SpCell and cancel the pending SR - // if the MAC entity has no valid PUCCH resource configured for the pending SR + NR_UE_UL_BWP_t *current_UL_BWP = mac->current_UL_BWP; + NR_PUCCH_Config_t *pucch_Config = current_UL_BWP ? current_UL_BWP->pucch_Config : NULL; + if (check_pucchres_for_pending_SR(pucch_Config, lc_info->sr_id)) { + // trigger SR + LOG_D(NR_MAC, "Triggering SR for ID %d\n", lc_info->sr_id); + sr->pending = true; + sr->counter = 0; + } + else { + // initiate a Random Access procedure on the SpCell and cancel the pending SR + // if the MAC entity has no valid PUCCH resource configured for the pending SR + sr->pending = false; + sr->counter = 0; + nr_timer_stop(&sr->prohibitTimer); + schedule_RA_after_SR_failure(mac); + } } } }