From 8ee3f3b353b786c75445640ecd24ada7b1401849 Mon Sep 17 00:00:00 2001
From: "Raymond.Knopp" <raymond.knopp@eurecom.fr>
Date: Tue, 25 Jul 2017 22:15:52 +0200
Subject: [PATCH] initial tests with USRP as monolithic eNB, "connectionless"
 execution is fine.

---
 openair1/PHY/LTE_TRANSPORT/dci.c              |  4 +--
 openair1/PHY/LTE_TRANSPORT/dci_tools.c        | 10 +++---
 openair1/PHY/LTE_TRANSPORT/pbch.c             |  2 +-
 openair1/PHY/LTE_TRANSPORT/prach.c            | 11 ++++---
 openair1/SCHED/phy_procedures_lte_eNb.c       | 32 +++++++++----------
 openair2/ENB_APP/enb_config.c                 | 28 ++++++++--------
 openair2/LAYER2/MAC/eNB_scheduler.c           | 20 +++---------
 openair2/LAYER2/MAC/eNB_scheduler_bch.c       |  8 ++---
 .../LAYER2/MAC/eNB_scheduler_primitives.c     | 21 ++++++------
 openair2/PHY_INTERFACE/IF_Module.c            | 10 +++---
 openair2/RRC/LITE/L2_interface.c              |  2 +-
 targets/RT/USER/lte-enb.c                     | 11 ++++++-
 targets/RT/USER/lte-ru.c                      | 24 +++++++-------
 13 files changed, 93 insertions(+), 90 deletions(-)

diff --git a/openair1/PHY/LTE_TRANSPORT/dci.c b/openair1/PHY/LTE_TRANSPORT/dci.c
index 551a6b82f0..1ade246945 100755
--- a/openair1/PHY/LTE_TRANSPORT/dci.c
+++ b/openair1/PHY/LTE_TRANSPORT/dci.c
@@ -2123,11 +2123,11 @@ uint8_t generate_dci_top(uint8_t num_pdcch_symbols,
 
       if (dci_alloc[i].L == (uint8_t)L) {
 
-	//#ifdef DEBUG_DCI_ENCODING
+#ifdef DEBUG_DCI_ENCODING
         LOG_I(PHY,"Generating DCI %d/%d (nCCE %d) of length %d, aggregation %d (%x)\n",i,num_dci,dci_alloc[i].firstCCE,dci_alloc[i].dci_length,dci_alloc[i].L,
               *(unsigned int*)dci_alloc[i].dci_pdu);
         dump_dci(frame_parms,&dci_alloc[i]);
-	//#endif
+#endif
 
         if (dci_alloc[i].firstCCE>=0) {
           e_ptr = generate_dci0(dci_alloc[i].dci_pdu,
diff --git a/openair1/PHY/LTE_TRANSPORT/dci_tools.c b/openair1/PHY/LTE_TRANSPORT/dci_tools.c
index 78f141bb5b..d75827db4a 100644
--- a/openair1/PHY/LTE_TRANSPORT/dci_tools.c
+++ b/openair1/PHY/LTE_TRANSPORT/dci_tools.c
@@ -882,7 +882,7 @@ int fill_dci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci_
   dci_alloc->harq_pid = rel8->harq_process;
   dci_alloc->ra_flag  = 0;
 
-  LOG_I(PHY,"NFAPI: DCI format %d, nCCE %d, L %d, rnti %x,harq_pid %d\n",
+  LOG_D(PHY,"NFAPI: DCI format %d, nCCE %d, L %d, rnti %x,harq_pid %d\n",
 	rel8->dci_format,rel8->cce_idx,rel8->aggregation_level,rel8->rnti,rel8->harq_process);
   if ((rel8->rnti_type == 2 ) && (rel8->rnti != SI_RNTI) && (rel8->rnti != P_RNTI)) dci_alloc->ra_flag = 1;
 
@@ -1065,7 +1065,7 @@ int fill_dci_and_dlsch(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,DCI_ALLOC_t *dci_
     if (dlsch0_harq->round == 0)
       dlsch0_harq->status = ACTIVE;
 
-    LOG_I(PHY,"DCI 1A: mcs %d, rballoc %x,rv %d, rnti %x\n",rel8->mcs_1,rel8->resource_block_coding,rel8->redundancy_version_1,rel8->rnti);
+    LOG_D(PHY,"DCI 1A: mcs %d, rballoc %x,rv %d, rnti %x\n",rel8->mcs_1,rel8->resource_block_coding,rel8->redundancy_version_1,rel8->rnti);
 
     break;
   case NFAPI_DL_DCI_FORMAT_1:
@@ -6535,9 +6535,9 @@ void prepare_dl_decoding_format1_1A(DCI_format_t dci_format,
     {
     	if (rnti == tc_rnti) {
 			//fix for standalone Contention Resolution Id
-			pdlsch0_harq->DCINdi = (uint8_t)-1;
-			 LOG_D(PHY,"UE (%x/%d): Format1A DCI: C-RNTI is temporary. Set NDI = %d and to be ignored\n",
-				 rnti,harq_pid,pdlsch0_harq->DCINdi);
+	  pdlsch0_harq->DCINdi = (uint8_t)-1;
+	  LOG_D(PHY,"UE (%x/%d): Format1A DCI: C-RNTI is temporary. Set NDI = %d and to be ignored\n",
+		rnti,harq_pid,pdlsch0_harq->DCINdi);
     	}
 
         // DCI has been toggled or this is the first transmission
diff --git a/openair1/PHY/LTE_TRANSPORT/pbch.c b/openair1/PHY/LTE_TRANSPORT/pbch.c
index cc11afd2dc..603c92d69f 100644
--- a/openair1/PHY/LTE_TRANSPORT/pbch.c
+++ b/openair1/PHY/LTE_TRANSPORT/pbch.c
@@ -210,7 +210,7 @@ int generate_pbch(LTE_eNB_PBCH *eNB_pbch,
     //#ifdef DEBUG_PBCH
 
     for (i=0; i<(PBCH_A>>3); i++)
-      LOG_I(PHY,"[PBCH] pbch_data[%d] = %x\n",i,pbch_a[i]);
+      LOG_D(PHY,"[PBCH] pbch_data[%d] = %x\n",i,pbch_a[i]);
 
     //#endif
 
diff --git a/openair1/PHY/LTE_TRANSPORT/prach.c b/openair1/PHY/LTE_TRANSPORT/prach.c
index fd7f8ab3e0..dff9c62d24 100644
--- a/openair1/PHY/LTE_TRANSPORT/prach.c
+++ b/openair1/PHY/LTE_TRANSPORT/prach.c
@@ -1115,6 +1115,7 @@ void rx_prach(PHY_VARS_eNB *eNB,
   prach_ConfigIndex   = fp->prach_config_common.prach_ConfigInfo.prach_ConfigIndex;
   Ncs_config          = fp->prach_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig;
   restricted_set      = fp->prach_config_common.prach_ConfigInfo.highSpeedFlag;
+
   int16_t *prach[nb_rx];
 
   if (eNB) {
@@ -1161,9 +1162,10 @@ void rx_prach(PHY_VARS_eNB *eNB,
   int en,en0=0;
 #endif
 
+  AssertFatal(ru!=NULL,"ru is null\n");
+
   for (aa=0; aa<nb_rx; aa++) {
-    if ((eNB==NULL) && 
-	(ru!=NULL)) { 
+    if (ru->if_south == LOCAL_RF) { // set the time-domain signal if we have to use it in this node
       prach[aa] = (int16_t*)&ru->common.rxdata[aa][(subframe*fp->samples_per_tti)-ru->N_TA_offset];
 #ifdef PRACH_DEBUG
       LOG_D(PHY,"RU %d, subframe %d, : prach %p (energy %d)\n",ru->idx,subframe,prach[aa],dB_fixed(en0=signal_energy(prach[aa],fp->samples_per_tti))); 
@@ -1246,11 +1248,12 @@ void rx_prach(PHY_VARS_eNB *eNB,
   }
 
 
-  if (((eNB!=NULL) && (ru!=NULL) && (ru->function != NGFI_RAU_IF4p5))||
-      ((eNB==NULL) && (ru!=NULL) && (ru->function == NGFI_RRU_IF4p5))) { // compute the DFTs of the PRACH temporal resources
+  if (((eNB!=NULL) && (ru->function != NGFI_RAU_IF4p5))||
+      ((eNB==NULL) && (ru->function == NGFI_RRU_IF4p5))) { // compute the DFTs of the PRACH temporal resources
     // Do forward transform
     LOG_D(PHY,"rx_prach: Doing FFT for N_RB_UL %d\n",fp->N_RB_UL);
     for (aa=0; aa<nb_rx; aa++) {
+      AssertFatal(prach[aa]!=NULL,"prach[%d] is null\n",aa);
       prach2 = prach[aa] + (Ncp<<1);
   
       // do DFT
diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c
index f9a89c59b0..2ef387cf5d 100644
--- a/openair1/SCHED/phy_procedures_lte_eNb.c
+++ b/openair1/SCHED/phy_procedures_lte_eNb.c
@@ -715,7 +715,7 @@ void pdsch_procedures(PHY_VARS_eNB *eNB,
   LTE_DL_FRAME_PARMS *fp=&eNB->frame_parms;
   int i;
 
-  LOG_I(PHY,
+  LOG_D(PHY,
 	"[eNB %"PRIu8"][PDSCH %"PRIx16"/%"PRIu8"] Frame %d, subframe %d: Generating PDSCH/DLSCH with input size = %"PRIu16", G %d, nb_rb %"PRIu16", mcs %"PRIu8", pmi_alloc %"PRIx64", rv %"PRIu8" (round %"PRIu8")\n",
 	eNB->Mod_id, dlsch->rnti,harq_pid,
 	frame, subframe, input_buffer_length,
@@ -903,7 +903,7 @@ void handle_nfapi_dci_dl_pdu(PHY_VARS_eNB *eNB,
   LTE_eNB_PDCCH *pdcch_vars       = &eNB->pdcch_vars[idx];
   nfapi_dl_config_dci_dl_pdu *pdu = &dl_config_pdu->dci_dl_pdu;
 
-  LOG_I(PHY,"Frame %d, Subframe %d: DCI processing\n",proc->frame_tx,proc->subframe_tx);
+  LOG_D(PHY,"Frame %d, Subframe %d: DCI processing\n",proc->frame_tx,proc->subframe_tx);
 
   // copy dci configuration into eNB structure
   fill_dci_and_dlsch(eNB,proc,&pdcch_vars->dci_alloc[pdcch_vars->num_dci],pdu);
@@ -918,7 +918,7 @@ void handle_nfapi_mpdcch_pdu(PHY_VARS_eNB *eNB,
   LTE_eNB_MPDCCH *mpdcch_vars     = &eNB->mpdcch_vars[idx];
   nfapi_dl_config_mpdcch_pdu *pdu = &dl_config_pdu->mpdcch_pdu;
 
-  LOG_I(PHY,"Frame %d, Subframe %d: MDCI processing\n",proc->frame_tx,proc->subframe_tx);
+  LOG_D(PHY,"Frame %d, Subframe %d: MDCI processing\n",proc->frame_tx,proc->subframe_tx);
 
   // copy dci configuration into eNB structure
   fill_mdci_and_dlsch(eNB,proc,&mpdcch_vars->mdci_alloc[mpdcch_vars->num_dci],pdu);
@@ -946,7 +946,7 @@ void handle_nfapi_hi_dci0_hi_pdu(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,
   
   nfapi_hi_dci0_hi_pdu *pdu      = &hi_dci0_config_pdu->hi_pdu;
   // copy dci configuration in to eNB structure
-  LOG_I(PHY,"Received HI PDU which value %d (rbstart %d,cshift %d)\n",
+  LOG_D(PHY,"Received HI PDU which value %d (rbstart %d,cshift %d)\n",
 	hi_dci0_config_pdu->hi_pdu.hi_pdu_rel8.hi_value,
 	hi_dci0_config_pdu->hi_pdu.hi_pdu_rel8.resource_block_start,
 	hi_dci0_config_pdu->hi_pdu.hi_pdu_rel8.cyclic_shift_2_for_drms);
@@ -960,7 +960,7 @@ handle_nfapi_bch_pdu(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,
   
   AssertFatal(rel8->length == 3, "BCH PDU has length %d != 3\n",rel8->length);
 
-  LOG_I(PHY,"bch_pdu: %x,%x,%x\n",sdu[0],sdu[1],sdu[2]);
+  LOG_D(PHY,"bch_pdu: %x,%x,%x\n",sdu[0],sdu[1],sdu[2]);
   eNB->pbch_pdu[0] = sdu[2];
   eNB->pbch_pdu[1] = sdu[1];
   eNB->pbch_pdu[2] = sdu[0];
@@ -1012,7 +1012,7 @@ handle_nfapi_dlsch_pdu(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,
   dlsch1_harq     = dlsch1->harq_processes[harq_pid];
   AssertFatal(dlsch0_harq!=NULL,"dlsch_harq is null\n");
 
-  LOG_I(PHY,"NFAPI: frame %d, subframe %d: programming dlsch, rnti %x, UE_id %d, harq_pid %d\n",
+  LOG_D(PHY,"NFAPI: frame %d, subframe %d: programming dlsch, rnti %x, UE_id %d, harq_pid %d\n",
 	proc->frame_tx,proc->subframe_tx,rel8->rnti,UE_id,harq_pid);
   if (codeword_index == 0) dlsch0_harq->pdu                    = sdu;
   else                     dlsch1_harq->pdu                    = sdu;
@@ -1129,7 +1129,7 @@ void schedule_response(Sched_Rsp_t *Sched_INFO) {
   eNB->pdcch_vars[subframe&1].num_dci           = 0;
 
 
-  LOG_I(PHY,"NFAPI: received %d dl_pdu, %d tx_req, %d hi_dci0_config_req, %d UL_config \n",
+  LOG_D(PHY,"NFAPI: received %d dl_pdu, %d tx_req, %d hi_dci0_config_req, %d UL_config \n",
 	number_dl_pdu,TX_req->tx_request_body.number_of_pdus,number_hi_dci0_pdu,number_ul_pdu);
 
   
@@ -1149,7 +1149,7 @@ void schedule_response(Sched_Rsp_t *Sched_INFO) {
   }
   for (i=0;i<number_dl_pdu;i++) {
     dl_config_pdu = &DL_req->dl_config_request_body.dl_config_pdu_list[i];
-    LOG_I(PHY,"NFAPI: dl_pdu %d : type %d\n",i,dl_config_pdu->pdu_type);
+    LOG_D(PHY,"NFAPI: dl_pdu %d : type %d\n",i,dl_config_pdu->pdu_type);
     switch (dl_config_pdu->pdu_type) {
     case NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE:
       handle_nfapi_dci_dl_pdu(eNB,proc,dl_config_pdu);
@@ -1226,7 +1226,7 @@ void schedule_response(Sched_Rsp_t *Sched_INFO) {
 
   for (i=0;i<number_ul_pdu;i++) {
     ul_config_pdu = &UL_req->ul_config_request_body.ul_config_pdu_list[i];
-    LOG_I(PHY,"NFAPI: ul_pdu %d : type %d\n",i,ul_config_pdu->pdu_type);
+    LOG_D(PHY,"NFAPI: ul_pdu %d : type %d\n",i,ul_config_pdu->pdu_type);
     AssertFatal(ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_ULSCH_PDU_TYPE,
 		"Optional UL_PDU type %d not supported\n",ul_config_pdu->pdu_type);
     handle_nfapi_ul_pdu(eNB,proc,ul_config_pdu);
@@ -1382,7 +1382,7 @@ void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB,
   num_dci           = eNB->pdcch_vars[subframe&1].num_dci;
   //  LOG_D(PHY,"num_pdcch_symbols %"PRIu8",(dci common %"PRIu8", dci uespec %"PRIu8"\n",num_pdcch_symbols,
   //        DCI_pdu->Num_common_dci,DCI_pdu->Num_ue_spec_dci);
-  LOG_I(PHY,"num_pdcch_symbols %"PRIu8",(number dci %"PRIu8"\n",num_pdcch_symbols,
+  LOG_D(PHY,"num_pdcch_symbols %"PRIu8",(number dci %"PRIu8"\n",num_pdcch_symbols,
 	num_dci);
   VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_DCI_INFO,num_pdcch_symbols);
 
@@ -1394,7 +1394,7 @@ void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB,
   phy_config_dedicated_eNB_step2(eNB);
 
   if (num_dci > 0)
-    LOG_I(PHY,"[eNB %"PRIu8"] Frame %d, subframe %d: Calling generate_dci_top (pdcch) (num_dci %"PRIu8")\n",eNB->Mod_id,frame, subframe,
+    LOG_D(PHY,"[eNB %"PRIu8"] Frame %d, subframe %d: Calling generate_dci_top (pdcch) (num_dci %"PRIu8")\n",eNB->Mod_id,frame, subframe,
 	  num_dci);
     
   generate_dci_top(num_pdcch_symbols,
@@ -1956,7 +1956,7 @@ void prach_procedures(PHY_VARS_eNB *eNB) {
   }
 
   //#ifdef DEBUG_PHY_PROC
-  LOG_I(PHY,"[RAPROC] Frame %d, subframe %d : Most likely preamble %d, energy %d dB delay %d\n",
+  LOG_D(PHY,"[RAPROC] Frame %d, subframe %d : Most likely preamble %d, energy %d dB delay %d\n",
         frame,subframe,
 	preamble_max,
         preamble_energy_list[preamble_max],
@@ -1971,7 +1971,7 @@ void prach_procedures(PHY_VARS_eNB *eNB) {
       //      eNB->UE_stats[(uint32_t)UE_id].UE_timing_offset = preamble_delay_list[preamble_max]&0x1FFF; //limit to 13 (=11+2) bits
 
       //      eNB->UE_stats[(uint32_t)UE_id].sector = 0;
-    LOG_I(PHY,"[eNB %d/%d][RAPROC] Frame %d, subframe %d Initiating RA procedure with preamble %d, energy %d.%d dB, delay %d\n",
+    LOG_D(PHY,"[eNB %d/%d][RAPROC] Frame %d, subframe %d Initiating RA procedure with preamble %d, energy %d.%d dB, delay %d\n",
 	  eNB->Mod_id,
 	  eNB->CC_id,
 	  frame,
@@ -2569,7 +2569,7 @@ void phy_procedures_eNB_uespec_RX(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,const
     if ((ulsch) &&
         (eNB->ulsch[i]->rnti>0) &&
         (ulsch_harq->status = ACTIVE))
-      LOG_I(PHY,"Frame %d Subframe UE %d/%x active: scheduled for (%d,%d)\n",
+      LOG_D(PHY,"Frame %d Subframe UE %d/%x active: scheduled for (%d,%d)\n",
 	    frame,i,eNB->ulsch[i]->rnti,ulsch_harq->frame,ulsch_harq->subframe);
     if ((ulsch) &&
         (eNB->ulsch[i]->rnti>0) &&
@@ -2620,7 +2620,7 @@ void phy_procedures_eNB_uespec_RX(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,const
         }
       }
 
-      LOG_I(PHY,
+      LOG_D(PHY,
             "[eNB %d][PUSCH %d] Frame %d Subframe %d Demodulating PUSCH: dci_alloc %d, rar_alloc %d, round %d, first_rb %d, nb_rb %d, mcs %d, TBS %d, rv %d, cyclic_shift %d (n_DMRS2 %d, cyclicShift_common %d, nprs %d), O_ACK %d \n",
             eNB->Mod_id,harq_pid,frame,subframe,
             ulsch_harq->dci_alloc,
@@ -2660,7 +2660,7 @@ void phy_procedures_eNB_uespec_RX(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,const
 
       stop_meas(&eNB->ulsch_decoding_stats);
 
-      LOG_I(PHY,"[eNB %d][PUSCH %d] frame %d subframe %d RNTI %x RX power (%d,%d) RSSI (%d,%d) N0 (%d,%d) dB ACK (%d,%d), decoding iter %d\n",
+      LOG_D(PHY,"[eNB %d][PUSCH %d] frame %d subframe %d RNTI %x RX power (%d,%d) RSSI (%d,%d) N0 (%d,%d) dB ACK (%d,%d), decoding iter %d\n",
             eNB->Mod_id,harq_pid,
             frame,subframe,
             ulsch->rnti,
diff --git a/openair2/ENB_APP/enb_config.c b/openair2/ENB_APP/enb_config.c
index ae3c7d5bfb..5e0a1f4637 100644
--- a/openair2/ENB_APP/enb_config.c
+++ b/openair2/ENB_APP/enb_config.c
@@ -519,19 +519,20 @@ void RCconfig_RU() {
 		       RC.config_file_name, j);
 	  continue; // FIXME will prevent segfaults below, not sure what happens at function exit...
 	}
-	AssertFatal((setting_eNB_list = config_setting_get_member(setting_ru, CONFIG_STRING_RU_ENB_LIST))!=NULL,"No RU<->eNB mappings\n");
-	
-	if (setting_eNB_list != NULL) num_eNB4RU    = config_setting_length(setting_eNB_list);
-	else num_eNB4RU=0;
-	AssertFatal(num_eNB4RU>0,"Number of eNBs is zero\n");
-
-	for (i=0;i<num_eNB4RU;i++) {
-	  setting_eNB_list_elem = config_setting_get_elem(setting_eNB_list,i);
-	  eNB_list[i] = config_setting_get_int(setting_eNB_list_elem);
-	  printf("RU %d: eNB %d\n",j,eNB_list[i]);
-	}
       }
-	
+
+      AssertFatal((setting_eNB_list = config_setting_get_member(setting_ru, CONFIG_STRING_RU_ENB_LIST))!=NULL,"No RU<->eNB mappings\n");
+      
+      if (setting_eNB_list != NULL) num_eNB4RU    = config_setting_length(setting_eNB_list);
+      else num_eNB4RU=0;
+      AssertFatal(num_eNB4RU>0,"Number of eNBs is zero\n");
+      
+      for (i=0;i<num_eNB4RU;i++) {
+	setting_eNB_list_elem = config_setting_get_elem(setting_eNB_list,i);
+	eNB_list[i] = config_setting_get_int(setting_eNB_list_elem);
+	printf("RU %d: eNB %d\n",j,eNB_list[i]);
+      }
+      
       if ( !(
 	               config_setting_lookup_int(setting_ru, CONFIG_STRING_RU_NB_TX,  &nb_tx)
 		    && config_setting_lookup_int(setting_ru, CONFIG_STRING_RU_NB_RX,  &nb_rx)
@@ -552,6 +553,8 @@ void RCconfig_RU() {
       
       RC.ru[j]->if_timing                           = synch_to_ext_device;
       RC.ru[j]->num_eNB                             = num_eNB4RU;
+
+      for (i=0;i<num_eNB4RU;i++) RC.ru[j]->eNB_list[i] = RC.eNB[eNB_list[i]][0];
       
       if (strcmp(local_rf, "yes") == 0) {
 	if (fronthaul_flag == CONFIG_FALSE) {
@@ -593,7 +596,6 @@ void RCconfig_RU() {
 	RC.ru[j]->eth_params.remote_portc             = remote_portc;
 	RC.ru[j]->eth_params.my_portd                 = local_portd;
 	RC.ru[j]->eth_params.remote_portd             = remote_portd;
-	for (i=0;i<num_eNB4RU;i++) RC.ru[j]->eNB_list[i] = RC.eNB[eNB_list[i]][0];
 
 	if (strcmp(tr_preference, "udp") == 0) {
 	  RC.ru[j]->if_south                     = REMOTE_IF5;
diff --git a/openair2/LAYER2/MAC/eNB_scheduler.c b/openair2/LAYER2/MAC/eNB_scheduler.c
index 6a4c1424a9..39f54e0856 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler.c
@@ -313,10 +313,7 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag,
   }
 
 #endif
-  LOG_I(MAC,"[eNB %d][before switch] Frame %d, Subframe %d CC_id %d RA 0 is active, Msg3 in (%d,%d), (%d,%d,%d,%d) UL_pdus %d\n",
-	module_idP,frameP,subframeP,CC_id,cc[0].RA_template[0].Msg3_frame,cc[0].RA_template[0].Msg3_subframe,
-	cc[0].RA_template[0].RA_active,cc[0].RA_template[1].RA_active,cc[0].RA_template[2].RA_active,cc[0].RA_template[3].RA_active,
-	RC.mac[module_idP]->UL_req[0].ul_config_request_body.number_of_pdus);
+
   switch (subframeP) {
   case 0:
 
@@ -326,9 +323,9 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag,
 
 
     //    schedule_RA(module_idP,frameP,subframeP,2);
-    LOG_I(MAC,"Scheduling MIB\n");
+    LOG_D(MAC,"Scheduling MIB\n");
     if ((frameP&3) == 0) schedule_mib(module_idP,frameP,subframeP);
-    LOG_I(MAC,"NFAPI: number_of_pdus %d, number_of_TX_req %d\n",
+    LOG_D(MAC,"NFAPI: number_of_pdus %d, number_of_TX_req %d\n",
 	  DL_req[0].dl_config_request_body.number_pdu,
 	  TX_req[0].tx_request_body.number_of_pdus);
     if (cc[0].tdd_Config == NULL) {  //FDD
@@ -1026,21 +1023,12 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag,
 
   }
 
-  LOG_I(MAC,"FrameP %d, subframeP %d : Scheduling CCEs/Msg3\n",frameP,subframeP);
-
-  LOG_I(MAC,"[eNB %d][before] Frame %d, Subframe %d CC_id %d RA 0 is active, Msg3 in (%d,%d) (%d,%d,%d,%d) UL_pdus %d\n",
-	module_idP,frameP,subframeP,CC_id,cc[0].RA_template[0].Msg3_frame,cc[0].RA_template[0].Msg3_subframe,
-	cc[0].RA_template[0].RA_active,cc[0].RA_template[1].RA_active,cc[0].RA_template[2].RA_active,cc[0].RA_template[3].RA_active,
-	RC.mac[module_idP]->UL_req[0].ul_config_request_body.number_of_pdus);
   // Allocate CCEs and Msg3 for good after scheduling is done
   for (CC_id=0;CC_id<MAX_NUM_CCs;CC_id++) {
     allocate_CCEs(module_idP,CC_id,subframeP,0);
     check_and_add_msg3(module_idP,frameP,subframeP);
   }
-  LOG_I(MAC,"[eNB %d][after] Frame %d, Subframe %d CC_id 0 RA 0 is active, Msg3 in (%d,%d) (%d,%d,%d,%d) UL_pdus %d\n",
-	module_idP,frameP,subframeP,cc[0].RA_template[0].Msg3_frame,cc[0].RA_template[0].Msg3_subframe,
-	cc[0].RA_template[0].RA_active,cc[0].RA_template[1].RA_active,cc[0].RA_template[2].RA_active,cc[0].RA_template[3].RA_active,
-	RC.mac[module_idP]->UL_req[0].ul_config_request_body.number_of_pdus);
+
 #if defined(FLEXRAN_AGENT_SB_IF)
 #ifndef DISABLE_CONT_STATS
   //Send subframe trigger to the controller
diff --git a/openair2/LAYER2/MAC/eNB_scheduler_bch.c b/openair2/LAYER2/MAC/eNB_scheduler_bch.c
index f2ace8d328..7f4fd19db3 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler_bch.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler_bch.c
@@ -496,12 +496,12 @@ void schedule_mib(module_id_t   module_idP,
 				      module_idP,
 				      0); // not used in this case
 
-    LOG_I(MAC,"Frame %d, subframe %d: BCH PDU length %d\n",
+    LOG_D(MAC,"Frame %d, subframe %d: BCH PDU length %d\n",
 	  frameP,subframeP,mib_sdu_length);
 
     if (mib_sdu_length > 0) {
 
-      LOG_I(MAC,"Frame %d, subframe %d: Adding BCH PDU in position %d (length %d)\n",
+      LOG_D(MAC,"Frame %d, subframe %d: Adding BCH PDU in position %d (length %d)\n",
 	    frameP,subframeP,dl_req->number_pdu,mib_sdu_length);
 
       dl_config_pdu                                                         = &dl_req->dl_config_pdu_list[dl_req->number_pdu]; 
@@ -513,7 +513,7 @@ void schedule_mib(module_id_t   module_idP,
       dl_config_pdu->bch_pdu.bch_pdu_rel8.transmission_power                = 6000;
       dl_req->number_pdu++;
 
-      LOG_I(MAC,"eNB->DL_req[0].number_pdu %d (%p)\n",
+      LOG_D(MAC,"eNB->DL_req[0].number_pdu %d (%p)\n",
 	    dl_req->number_pdu,&dl_req->number_pdu);
       // DL request
 
@@ -647,7 +647,7 @@ schedule_SI(
       dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.resource_block_coding       = getRIV(N_RB_DL,first_rb,4);      
 
       if (!CCE_allocation_infeasible(module_idP,CC_id,1,subframeP,dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level,SI_RNTI)) {
-	LOG_I(MAC,"Frame %d: Subframe %d : Adding common DCI for S_RNTI\n",
+	LOG_D(MAC,"Frame %d: Subframe %d : Adding common DCI for S_RNTI\n",
 	      frameP,subframeP);
 	dl_req->number_dci++;
 	dl_req->number_pdu++;
diff --git a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c
index 6961013983..afffd90dd0 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c
@@ -645,7 +645,6 @@ printf("MAC: cannot remove UE rnti %x\n", rntiP);
 
   pCC_id = UE_PCCID(mod_idP,UE_id);
 
-printf("MAC: remove UE %d rnti %x\n", UE_id, rntiP);
   LOG_I(MAC,"Removing UE %d from Primary CC_id %d (rnti %x)\n",UE_id,pCC_id, rntiP);
   dump_ue_list(UE_list,0);
 
@@ -1331,14 +1330,14 @@ int get_nCCE_offset(int *CCE_table,
     nb_candidates = (L==4) ? 4 : 2;
     nb_candidates = min(nb_candidates,nCCE/L);
 
-    printf("Common DCI nb_candidates %d, L %d\n",nb_candidates,L);
+    //    printf("Common DCI nb_candidates %d, L %d\n",nb_candidates,L);
 
     for (m = nb_candidates-1 ; m >=0 ; m--) {
 
       search_space_free = 1;
       for (l=0; l<L; l++) {
 
-	printf("CCE_table[%d] %d\n",(m*L)+l,CCE_table[(m*L)+l]);
+	//	printf("CCE_table[%d] %d\n",(m*L)+l,CCE_table[(m*L)+l]);
         if (CCE_table[(m*L) + l] == 1) {
           search_space_free = 0;
           break;
@@ -1592,7 +1591,7 @@ int allocate_CCEs(int module_idP,
   int i,j,idci;
   int nCCE=0;
 
-  LOG_I(MAC,"Allocate CCEs subframe %d, test %d : (DL %d,UL %d)\n",subframeP,test_onlyP,DL_req->number_dci,HI_DCI0_req->number_of_dci);
+  LOG_D(MAC,"Allocate CCEs subframe %d, test %d : (DL %d,UL %d)\n",subframeP,test_onlyP,DL_req->number_dci,HI_DCI0_req->number_of_dci);
   DL_req->number_pdcch_ofdm_symbols=1;
 
 try_again:
@@ -1603,7 +1602,7 @@ try_again:
     // allocate DL common DCIs first
     if ((dl_config_pdu[i].pdu_type == NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE)&&
 	(dl_config_pdu[i].dci_dl_pdu.dci_dl_pdu_rel8.rnti_type==2)) {
-      LOG_I(MAC,"Trying to allocate COMMON DCI %d/%d (%d,%d) : rnti %x, aggreg %d nCCE %d / %d (num_pdcch_symbols %d)\n",
+      LOG_D(MAC,"Trying to allocate COMMON DCI %d/%d (%d,%d) : rnti %x, aggreg %d nCCE %d / %d (num_pdcch_symbols %d)\n",
 	    idci,DL_req->number_dci+HI_DCI0_req->number_of_dci,
 	    DL_req->number_dci,HI_DCI0_req->number_of_dci,
 	    dl_config_pdu[i].dci_dl_pdu.dci_dl_pdu_rel8.rnti,
@@ -1627,11 +1626,11 @@ try_again:
 			     subframeP);
       if (fCCE == -1) {
 	if (DL_req->number_pdcch_ofdm_symbols == 3) {
-	  LOG_I(MAC,"subframe %d: Dropping Allocation for RNTI %x\n",
+	  LOG_D(MAC,"subframe %d: Dropping Allocation for RNTI %x\n",
 		subframeP,dl_config_pdu[i].dci_dl_pdu.dci_dl_pdu_rel8.rnti);
 	  for (j=0;j<=i;j++){
 	    if (dl_config_pdu[j].pdu_type == NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE)
-	      LOG_I(MAC,"DCI %d/%d (%d,%d) : rnti %x dci format %d, aggreg %d nCCE %d / %d (num_pdcch_symbols %d)\n",
+	      LOG_D(MAC,"DCI %d/%d (%d,%d) : rnti %x dci format %d, aggreg %d nCCE %d / %d (num_pdcch_symbols %d)\n",
 		    j,DL_req->number_dci+HI_DCI0_req->number_of_dci,
 		    DL_req->number_dci,HI_DCI0_req->number_of_dci,
 		    dl_config_pdu[j].dci_dl_pdu.dci_dl_pdu_rel8.rnti,
@@ -1652,7 +1651,7 @@ try_again:
       LOG_D(MAC,"Allocating at nCCE %d\n",fCCE);
       if (test_onlyP == 0) {
 	dl_config_pdu[i].dci_dl_pdu.dci_dl_pdu_rel8.cce_idx=fCCE;
-	LOG_I(MAC,"Allocate COMMON DCI CCEs subframe %d, test %d => L %d fCCE %d\n",subframeP,test_onlyP,dl_config_pdu[i].dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level,fCCE);
+	LOG_D(MAC,"Allocate COMMON DCI CCEs subframe %d, test %d => L %d fCCE %d\n",subframeP,test_onlyP,dl_config_pdu[i].dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level,fCCE);
       }
       idci++;
     }
@@ -1687,11 +1686,11 @@ try_again:
 			     subframeP);
       if (fCCE == -1) {
 	if (DL_req->number_pdcch_ofdm_symbols == 3) {
-	  LOG_I(MAC,"subframe %d: Dropping Allocation for RNTI %x\n",
+	  LOG_D(MAC,"subframe %d: Dropping Allocation for RNTI %x\n",
 		subframeP,hi_dci0_pdu[i].dci_pdu.dci_pdu_rel8.rnti);
 	  for (j=0;j<=i;j++){
 	    if (hi_dci0_pdu[j].pdu_type == NFAPI_HI_DCI0_DCI_PDU_TYPE)
-	      LOG_I(MAC,"DCI %d/%d (%d,%d) : rnti %x dci format %d, aggreg %d nCCE %d / %d (num_pdcch_symbols %d)\n",
+	      LOG_D(MAC,"DCI %d/%d (%d,%d) : rnti %x dci format %d, aggreg %d nCCE %d / %d (num_pdcch_symbols %d)\n",
 		    j,DL_req->number_dci+HI_DCI0_req->number_of_dci,
 		    DL_req->number_dci,HI_DCI0_req->number_of_dci,
 		    hi_dci0_pdu[j].dci_pdu.dci_pdu_rel8.rnti,
@@ -1826,7 +1825,7 @@ void SR_indication(module_id_t mod_idP, int cc_idP, frame_t frameP, rnti_t rntiP
  
   if (UE_id  != -1) {
     if (mac_eNB_get_rrc_status(mod_idP,UE_RNTI(mod_idP,UE_id)) < RRC_CONNECTED)
-      LOG_I(MAC,"[eNB %d][SR %x] Frame %d subframeP %d Signaling SR for UE %d on CC_id %d\n",mod_idP,rntiP,frameP,subframeP, UE_id,cc_idP);
+      LOG_D(MAC,"[eNB %d][SR %x] Frame %d subframeP %d Signaling SR for UE %d on CC_id %d\n",mod_idP,rntiP,frameP,subframeP, UE_id,cc_idP);
     UE_list->UE_template[cc_idP][UE_id].ul_SR = 1;
     UE_list->UE_template[cc_idP][UE_id].ul_active = TRUE;
     VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SR_INDICATION,1);
diff --git a/openair2/PHY_INTERFACE/IF_Module.c b/openair2/PHY_INTERFACE/IF_Module.c
index 4936be61d5..e52b52203d 100644
--- a/openair2/PHY_INTERFACE/IF_Module.c
+++ b/openair2/PHY_INTERFACE/IF_Module.c
@@ -16,7 +16,7 @@ void handle_rach(UL_IND_t *UL_info) {
 
     AssertFatal(UL_info->rach_ind.number_of_preambles==1,"More than 1 preamble not supported\n");
     UL_info->rach_ind.number_of_preambles=0;
-    LOG_I(MAC,"Frame %d, Subframe %d Calling initiate_ra_proc\n",UL_info->frame,UL_info->subframe);
+    LOG_D(MAC,"Frame %d, Subframe %d Calling initiate_ra_proc\n",UL_info->frame,UL_info->subframe);
     initiate_ra_proc(UL_info->module_id,
 		     UL_info->CC_id,
 		     UL_info->frame,
@@ -33,7 +33,7 @@ void handle_ulsch(UL_IND_t *UL_info) {
 
   for (i=0;i<UL_info->rx_ind.number_of_pdus;i++) {
 
-    LOG_I(MAC,"Frame %d, Subframe %d Calling rx_sdu \n",UL_info->frame,UL_info->subframe);
+    LOG_D(MAC,"Frame %d, Subframe %d Calling rx_sdu \n",UL_info->frame,UL_info->subframe);
     rx_sdu(UL_info->module_id,
 	   UL_info->CC_id,
 	   UL_info->frame,
@@ -50,7 +50,7 @@ void handle_ulsch(UL_IND_t *UL_info) {
   for (i=0;i<UL_info->crc_ind.number_of_crcs;i++) {
 
     if (UL_info->crc_ind.crc_pdu_list[i].crc_indication_rel8.crc_flag == 1) { // CRC error indication
-      LOG_I(MAC,"Frame %d, Subframe %d Calling rx_sdu (CRC error) \n",UL_info->frame,UL_info->subframe);
+      LOG_D(MAC,"Frame %d, Subframe %d Calling rx_sdu (CRC error) \n",UL_info->frame,UL_info->subframe);
       rx_sdu(UL_info->module_id,
 	     UL_info->CC_id,
 	     UL_info->frame,
@@ -79,7 +79,7 @@ void UL_indication(UL_IND_t *UL_info)
   IF_Module_t  *ifi        = if_inst[module_id];
   eNB_MAC_INST *mac        = RC.mac[module_id];
 
-  LOG_I(PHY,"UL_Indication: frame %d, subframe %d, module_id %d, CC_id %d\n",
+  LOG_D(PHY,"UL_Indication: frame %d, subframe %d, module_id %d, CC_id %d\n",
 	UL_info->frame,UL_info->subframe,
 	module_id,CC_id);
 
@@ -124,7 +124,7 @@ void UL_indication(UL_IND_t *UL_info)
 		module_id,
 		CC_id);
     ifi->schedule_response(sched_info);
-    LOG_I(PHY,"Schedule_response: frame %d, subframe %d (dl_pdus %d / %p)\n",sched_info->frame,sched_info->subframe,sched_info->DL_req->dl_config_request_body.number_pdu,
+    LOG_D(PHY,"Schedule_response: frame %d, subframe %d (dl_pdus %d / %p)\n",sched_info->frame,sched_info->subframe,sched_info->DL_req->dl_config_request_body.number_pdu,
 	  &sched_info->DL_req->dl_config_request_body.number_pdu);
   }						 
 }
diff --git a/openair2/RRC/LITE/L2_interface.c b/openair2/RRC/LITE/L2_interface.c
index 7b58d9aa13..1f47b77b39 100644
--- a/openair2/RRC/LITE/L2_interface.c
+++ b/openair2/RRC/LITE/L2_interface.c
@@ -197,7 +197,7 @@ mac_rrc_data_req(
 					 (void*)mib,
 					 carrier->MIB,
 					 24);
-	LOG_I(RRC,"Encoded MIB for frame %d (%p), bits %lu\n",sfn,carrier->MIB,enc_rval.encoded);
+	LOG_D(RRC,"Encoded MIB for frame %d (%p), bits %lu\n",sfn,carrier->MIB,enc_rval.encoded);
 	buffer_pP[0]=carrier->MIB[0];
 	buffer_pP[1]=carrier->MIB[1];
 	buffer_pP[2]=carrier->MIB[2];
diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c
index 4c3ffd5aeb..3ba16a32a8 100644
--- a/targets/RT/USER/lte-enb.c
+++ b/targets/RT/USER/lte-enb.c
@@ -402,7 +402,7 @@ void wakeup_prach_eNB(PHY_VARS_eNB *eNB,RU_t *ru,int frame,int subframe) {
     
   // check if we have to detect PRACH first
   if (is_prach_subframe(fp,frame,subframe)>0) { 
-    LOG_I(PHY,"Triggering prach processing, frame %d, subframe %d\n",frame,subframe);
+    LOG_D(PHY,"Triggering prach processing, frame %d, subframe %d\n",frame,subframe);
     if (proc->instance_cnt_prach == 0) {
       LOG_W(PHY,"[eNB] Frame %d Subframe %d, dropping PRACH\n", frame,subframe);
       return;
@@ -721,6 +721,15 @@ void init_eNB_afterRU() {
       eNB->frame_parms.nb_antennas_rx       = 0;
       for (ru_id=0,aa=0;ru_id<eNB->num_RU;ru_id++) {
 	eNB->frame_parms.nb_antennas_rx    += eNB->RU_list[ru_id]->nb_rx;
+
+	AssertFatal(eNB->RU_list[ru_id]->common.rxdataF!=NULL,
+		    "RU %d : common.rxdataF is NULL\n",
+		    eNB->RU_list[ru_id]->idx);
+
+	AssertFatal(eNB->RU_list[ru_id]->prach_rxsigF!=NULL,
+		    "RU %d : prach_rxsigF is NULL\n",
+		    eNB->RU_list[ru_id]->idx);
+
 	for (i=0;i<eNB->RU_list[ru_id]->nb_rx;aa++,i++) { 
 	  LOG_I(PHY,"Attaching RU %d antenna %d to eNB antenna %d\n",eNB->RU_list[ru_id]->idx,i,aa);
 	  eNB->prach_vars.rxsigF[aa]       =  eNB->RU_list[ru_id]->prach_rxsigF[i];
diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c
index 3b6ab91d93..c34ad39cde 100644
--- a/targets/RT/USER/lte-ru.c
+++ b/targets/RT/USER/lte-ru.c
@@ -1084,15 +1084,17 @@ static void* ru_thread( void* param ) {
     if (ru->if_south == LOCAL_RF) ret = connect_rau(ru);
     else ret = attach_rru(ru);
     AssertFatal(ret==0,"Cannot connect to radio\n");
-    LOG_I(PHY, "Signaling main thread that RU %d is ready\n",ru->idx);
-    pthread_mutex_lock(&RC.ru_mutex);
-    RC.ru_mask &= ~(1<<ru->idx);
-    pthread_cond_signal(&RC.ru_cond);
-    pthread_mutex_unlock(&RC.ru_mutex);
   }
 
+  LOG_I(PHY, "Signaling main thread that RU %d is ready\n",ru->idx);
+  pthread_mutex_lock(&RC.ru_mutex);
+  RC.ru_mask &= ~(1<<ru->idx);
+  pthread_cond_signal(&RC.ru_cond);
+  pthread_mutex_unlock(&RC.ru_mutex);
   
   wait_sync("ru_thread");
+  
+
 
 
   // Start RF device if any
@@ -1686,13 +1688,12 @@ void init_RU(const char *rf_config_file) {
 
     
     eNB0             = ru->eNB_list[0];
-    if ((ru->function != RRU_IF5) || (ru->function != RRU_if4p5))
+    if ((ru->function != NGFI_RRU_IF5) || (ru->function != NGFI_RRU_IF4p5))
       AssertFatal(eNB0!=NULL,"eNB0 is null!\n");
 
     if (eNB0) {
       LOG_I(PHY,"Copying frame parms from eNB %d to ru %d\n",eNB0->Mod_id,ru->idx);
       memcpy((void*)&ru->frame_parms,(void*)&eNB0->frame_parms,sizeof(LTE_DL_FRAME_PARMS));
-      exit(-1);
     }
     // attach all RU to all eNBs in its list/
     for (i=0;i<ru->num_eNB;i++) {
@@ -1706,7 +1707,7 @@ void init_RU(const char *rf_config_file) {
     case LOCAL_RF:   // this is an RU with integrated RF (RRU, eNB)
       if (ru->function ==  NGFI_RRU_IF5) {                 // IF5 RRU
 	ru->do_prach              = 0;                      // no prach processing in RU
-	ru->fh_north_in           = NULL;                   // no synchronous incoming fronthaul from north
+	ru->fh_north_in           = NULL;                   // no shynchronous incoming fronthaul from north
 	ru->fh_north_out          = fh_if5_north_out;       // need only to do send_IF5  reception
 	ru->fh_south_out          = tx_rf;                  // send output to RF
 	ru->fh_north_asynch_in    = fh_if5_north_asynch_in; // TX packets come asynchronously 
@@ -1761,9 +1762,10 @@ void init_RU(const char *rf_config_file) {
       ru->fh_south_out           = tx_rf;                               // local synchronous RF TX
       ru->start_rf               = start_rf;                            // need to start the local RF interface
       printf("configuring ru_id %d (start_rf %p)\n",ru_id,start_rf);
-      ru->ifdevice.configure_rru = configure_rru;
-      fill_rf_config(ru,rf_config_file);
-      
+
+      fill_rf_config(ru,rf_config_file);      
+      init_frame_parms(&ru->frame_parms,1);
+      phy_init_RU(ru);
 
       ret = openair0_device_load(&ru->rfdevice,&ru->openair0_cfg);
       if (setup_RU_buffers(ru)!=0) {
-- 
GitLab