From adbc609bbf08a9c83bb4f6520351f9bb8a792070 Mon Sep 17 00:00:00 2001
From: Cedric Roux <cedric.roux@eurecom.fr>
Date: Wed, 18 Jan 2017 10:33:52 +0100
Subject: [PATCH] bugfix: reset DCI count before adding one

The management of uplink failure generates a DCI to send
a RA PDCCH order. It calls add_ue_spec_dci which increases
DCI_pdu[CC_id]->Num_ue_spec_dci, but this was reset to 0
*after* the DCI generation. Let's reset *before*.

Bug reported by Liang Yong on openair5g-user mailing list.
---
 openair2/LAYER2/MAC/eNB_scheduler.c | 27 +++++++++++----------------
 1 file changed, 11 insertions(+), 16 deletions(-)

diff --git a/openair2/LAYER2/MAC/eNB_scheduler.c b/openair2/LAYER2/MAC/eNB_scheduler.c
index e8ed8b8f5e..d00167160f 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler.c
@@ -121,6 +121,17 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag,
     memset(eNB_mac_inst[module_idP].common_channels[CC_id].vrb_map,0,100);
   }
 
+  // clear DCI and BCCH contents before scheduling
+  for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
+    DCI_pdu[CC_id]->Num_common_dci  = 0;
+    DCI_pdu[CC_id]->Num_ue_spec_dci = 0;
+#ifdef Rel10
+    eNB_mac_inst[module_idP].common_channels[CC_id].mcch_active =0;
+#endif
+    eNB_mac_inst[module_idP].frame    = frameP;
+    eNB_mac_inst[module_idP].subframe = subframeP;
+  }
+
   // refresh UE list based on UEs dropped by PHY in previous subframe
   i = UE_list->head;
 
@@ -318,22 +329,6 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag,
 
 #endif
 
-  // clear DCI and BCCH contents before scheduling
-  for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
-    DCI_pdu[CC_id]->Num_common_dci  = 0;
-    DCI_pdu[CC_id]->Num_ue_spec_dci = 0;
-
-
-#ifdef Rel10
-    eNB_mac_inst[module_idP].common_channels[CC_id].mcch_active =0;
-#endif
-
-    eNB_mac_inst[module_idP].frame    = frameP;
-    eNB_mac_inst[module_idP].subframe = subframeP;
-
-
-  }
-  
 /* #ifndef DISABLE_SF_TRIGGER */
 /*   //Send subframe trigger to the controller */
 /*   if (mac_agent_registered[module_idP]) { */
-- 
GitLab