From 27a022d6f86950d6b624b4380efb46854c1383a8 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 30 Oct 2025 23:13:46 +0100 Subject: [PATCH] Fix: avoid retransmission with 0 RBs Check and return, if necessary, that we have enough resources to make retransmissions. Without, we can asserts in L1, such as Assertion (NPRB>0 && (NPRB + RBstart <= BWPsize)) failed! In PRBalloc_to_locationandbandwidth0() openairinterface5g/common/utils/nr/nr_common.c:506 Illegal NPRB/RBstart Configuration (0,51) for BWPsize 51 which indicates that the scheduler requested a transmission with 0 PRBs, which does not make sense. --- openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c | 8 ++++++++ openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c index aa184d8f85..b04e0029dd 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_dlsch.c @@ -494,6 +494,7 @@ static bool allocate_dl_retransmission(gNB_MAC_INST *nr_mac, while (rbStart + rbSize <= rbStop && !(rballoc_mask[rbStart + rbSize] & slbitmap) && rbSize < new_sched.rbSize) rbSize++; + DevAssert(rbSize > 0); } } else { /* the retransmission will use a different time domain allocation, check @@ -504,8 +505,14 @@ static bool allocate_dl_retransmission(gNB_MAC_INST *nr_mac, while (rbStart < rbStop && (rballoc_mask[rbStart] & slbitmap)) rbStart++; + if (rbStart >= rbStop) { + LOG_D(NR_MAC, "[UE %04x][%4d.%2d] could not allocate DL retransmission: no resources\n", UE->rnti, frame, slot); + return false; + } + while (rbStart + rbSize <= rbStop && !(rballoc_mask[rbStart + rbSize] & slbitmap)) rbSize++; + DevAssert(rbSize > 0); uint32_t new_tbs; uint16_t new_rbSize; @@ -1079,6 +1086,7 @@ void post_process_dlsch(gNB_MAC_INST *nr_mac, post_process_pdsch_t *pdsch, NR_UE pucch ? pucch->ul_slot : 0, sched_pdsch->pucch_allocation, sched_ctrl->tpc1); + DevAssert(sched_pdsch->rbSize > 0); const int bwp_id = current_BWP->bwp_id; const int coresetid = sched_ctrl->coreset->controlResourceSetId; diff --git a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c index f923a2c9ec..5974edf1f8 100644 --- a/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c +++ b/openair2/LAYER2/NR_MAC_gNB/gNB_scheduler_ulsch.c @@ -1834,6 +1834,10 @@ static bool allocate_ul_retransmission(gNB_MAC_INST *nrmac, const uint16_t slbitmap = SL_to_bitmap(tda_info->startSymbolIndex, tda_info->nrOfSymbols); while (rbStart < bwpSize && (rballoc_mask[rbStart + bwpStart] & slbitmap)) rbStart++; + if (rbStart >= bwpSize) { + LOG_D(NR_MAC, "[UE %04x][%4d.%2d] could not allocate UL retransmission: no resources\n", UE->rnti, frame, slot); + return false; + } int rbSize = 0; while (rbStart + rbSize < bwpSize && !(rballoc_mask[rbStart + bwpStart + rbSize] & slbitmap)) rbSize++;