From ca1b0e2bbce66c49a96d117aba15281d46bfa2f1 Mon Sep 17 00:00:00 2001
From: Robert Schmidt <robert.schmidt@eurecom.fr>
Date: Fri, 11 Sep 2020 12:49:10 +0200
Subject: [PATCH] Bugfix RR algo: if a UE cannot be allocated, skip it

---
 openair2/LAYER2/MAC/pre_processor.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/openair2/LAYER2/MAC/pre_processor.c b/openair2/LAYER2/MAC/pre_processor.c
index 51e56095398..e820cfd9ee3 100644
--- a/openair2/LAYER2/MAC/pre_processor.c
+++ b/openair2/LAYER2/MAC/pre_processor.c
@@ -212,11 +212,12 @@ int rr_dl_run(module_id_t Mod_id,
   cur_UE = &UE_sched.head;
   while (*cur_UE >= 0 && max_num_ue > 0) {
     const int UE_id = *cur_UE;
-    cur_UE = &UE_sched.next[UE_id]; // go to next
     const uint8_t cqi = UE_info->UE_sched_ctrl[UE_id].dl_cqi[CC_id];
     const int idx = CCE_try_allocate_dlsch(Mod_id, CC_id, subframe, UE_id, cqi);
     if (idx < 0) {
       LOG_D(MAC, "cannot allocate CCE for UE %d, skipping\n", UE_id);
+      // SKIP this UE in the list by marking the next as the current
+      *cur_UE = UE_sched.next[UE_id];
       continue;
     }
     UE_info->UE_sched_ctrl[UE_id].pre_dci_dl_pdu_idx = idx;
@@ -225,6 +226,7 @@ int rr_dl_run(module_id_t Mod_id,
     const uint32_t B = UE_info->UE_template[CC_id][UE_id].dl_buffer_total;
     rb_required[UE_id] = find_nb_rb_DL(mcs, B, n_rbg_sched * RBGsize, RBGsize);
     max_num_ue--;
+    cur_UE = &UE_sched.next[UE_id]; // go to next
   }
   *cur_UE = -1; // not all UEs might be allocated, mark end
 
-- 
GitLab