From 465168d2af443989cfa791bd0c6c0a71dc9f3196 Mon Sep 17 00:00:00 2001
From: Xenofon Foukas <x.foukas@sms.ed.ac.uk>
Date: Mon, 22 Feb 2016 14:45:39 +0000
Subject: [PATCH] Integrated sf triggering to MAC layer and fixed bugs in
 creation of sf trigger message

---
 openair2/ENB_APP/enb_agent_mac.c    |  8 ++++----
 openair2/LAYER2/MAC/eNB_scheduler.c | 10 +++++++++-
 2 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/openair2/ENB_APP/enb_agent_mac.c b/openair2/ENB_APP/enb_agent_mac.c
index dfe29bcc3e..f31da89d81 100644
--- a/openair2/ENB_APP/enb_agent_mac.c
+++ b/openair2/ENB_APP/enb_agent_mac.c
@@ -918,7 +918,7 @@ int enb_agent_mac_sf_trigger(mid_t mod_id, const void *params, Protocol__Progran
     if(dl_info == NULL)
       goto error;
     //Fill the status of the current HARQ process for each UE
-    for(i = 0; i++; i < sf_trigger_msg->n_dl_info) {
+    for(i = 0; i < sf_trigger_msg->n_dl_info; i++) {
       dl_info[i] = malloc(sizeof(Protocol__PrpDlInfo));
       if(dl_info[i] == NULL)
 	goto error;
@@ -934,7 +934,7 @@ int enb_agent_mac_sf_trigger(mid_t mod_id, const void *params, Protocol__Progran
       /*TODO: fill in the status of the HARQ process (2 TBs)*/
       dl_info[i]->n_harq_status = 2;
       dl_info[i]->harq_status = malloc(sizeof(uint32_t) * dl_info[i]->n_harq_status);
-      for (j = 0; j < dl_info[j]->n_harq_status; j++) {
+      for (j = 0; j < dl_info[i]->n_harq_status; j++) {
 	// TODO: This should be different per TB
 	dl_info[i]->harq_status[j] = harq_status;
       }
@@ -958,7 +958,7 @@ int enb_agent_mac_sf_trigger(mid_t mod_id, const void *params, Protocol__Progran
     if(ul_info == NULL)
       goto error;
     //Fill the reception info for each transmitting UE
-    for(i = 0; i++; i < sf_trigger_msg->n_ul_info) {
+    for(i = 0; i < sf_trigger_msg->n_ul_info; i++) {
       ul_info[i] = malloc(sizeof(Protocol__PrpUlInfo));
       if(ul_info[i] == NULL)
 	goto error;
@@ -978,7 +978,7 @@ int enb_agent_mac_sf_trigger(mid_t mod_id, const void *params, Protocol__Progran
 	given logical channel*/
       ul_info[i]->n_ul_reception = 11;
       ul_info[i]->ul_reception = malloc(sizeof(uint32_t) * ul_info[i]->n_ul_reception);
-      for (j = 0; j < ul_info[j]->n_ul_reception; j++) {
+      for (j = 0; j < ul_info[i]->n_ul_reception; j++) {
 	ul_info[i]->ul_reception[j] = 100;
       }
       /*TODO: Fill in the reception status for each UEs data*/
diff --git a/openair2/LAYER2/MAC/eNB_scheduler.c b/openair2/LAYER2/MAC/eNB_scheduler.c
index 54b31b6e64..a39b9efb54 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler.c
@@ -71,6 +71,7 @@
 #define ENABLE_MAC_PAYLOAD_DEBUG
 #define DEBUG_eNB_SCHEDULER 1
 #define ENABLE_ENB_AGENT_DL_SCHEDULER
+//#define DISABLE_SF_TRIGGER
 
 //#define DEBUG_HEADER_PARSING 1
 //#define DEBUG_PACKET_TRACE 1
@@ -207,7 +208,14 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag,
 
 
   }
-
+  
+#ifndef DISABLE_SF_TRIGGER
+  //Send subframe trigger to the controller
+  if (mac_agent_registered[module_idP]) {
+    agent_mac_xface[module_idP]->enb_agent_send_sf_trigger(module_idP);
+  }
+#endif
+  
   //if (subframeP%5 == 0)
   //#ifdef EXMIMO
   PROTOCOL_CTXT_SET_BY_MODULE_ID(&ctxt, module_idP, ENB_FLAG_YES, NOT_A_RNTI, frameP, 0,module_idP);
-- 
GitLab