From 7ad4efb37a22f469efdd5216fc3ae1c311e8690d Mon Sep 17 00:00:00 2001
From: laurent <laurent.thomas@open-cells.com>
Date: Mon, 2 Mar 2020 17:39:44 +0100
Subject: [PATCH] fix warnings, reduce formating differences with develop
 branch

---
 executables/main-fs6.c                        |  4 +
 executables/main-ocp.c                        |  7 +-
 executables/nr-gnb.c                          | 57 ++++++++---
 executables/split_headers.h                   |  4 +
 executables/transport_split.c                 |  4 +
 nfapi/oai_integration/nfapi_vnf.c             |  2 +-
 .../PHY/LTE_ESTIMATION/lte_adjust_sync_eNB.c  |  4 +
 .../lte_dl_bf_channel_estimation.c            | 96 +++++++++----------
 openair1/PHY/LTE_TRANSPORT/if5_tools.c        |  2 +-
 openair1/PHY/LTE_TRANSPORT/phich.c            |  2 +-
 .../PHY/LTE_TRANSPORT/ulsch_demodulation.c    |  1 -
 openair1/SCHED/phy_procedures_lte_eNb.c       |  3 +-
 openair1/SCHED/prach_procedures.c             |  9 ++
 openair1/SCHED/sched_eNB.h                    |  2 +
 openair1/SCHED_UE/phy_procedures_lte_ue.c     |  2 +-
 .../LAYER2/MAC/eNB_scheduler_primitives.c     |  7 +-
 openair2/RRC/LTE/rrc_eNB.c                    |  3 +
 targets/RT/USER/lte-softmodem.h               |  1 +
 18 files changed, 129 insertions(+), 81 deletions(-)

diff --git a/executables/main-fs6.c b/executables/main-fs6.c
index c20777a5d67..0a5988c802e 100644
--- a/executables/main-fs6.c
+++ b/executables/main-fs6.c
@@ -1,3 +1,7 @@
+/*
+  Author: Laurent THOMAS, Open Cells Project company, funded by IRT SystemX
+  copyleft: OpenAirInterface Software Alliance and it's licence
+*/
 #include <stdint.h>
 #include <common/utils/LOG/log.h>
 #include <common/utils/system.h>
diff --git a/executables/main-ocp.c b/executables/main-ocp.c
index 50cd1f27144..0635df2bef7 100644
--- a/executables/main-ocp.c
+++ b/executables/main-ocp.c
@@ -1,9 +1,6 @@
 /*
- * Author: Laurent Thomas
- * Copyright: Open Cells Project company
- */
-
-/*
+  Author: Laurent THOMAS, Open Cells Project company, funded by IRT SystemX
+  copyleft: OpenAirInterface Software Alliance and it's licence
  * This file replaces
  * targets/RT/USER/lte-softmodem.c
  * targets/RT/USER/rt_wrapper.c
diff --git a/executables/nr-gnb.c b/executables/nr-gnb.c
index 43407de19bf..3a5916c577e 100644
--- a/executables/nr-gnb.c
+++ b/executables/nr-gnb.c
@@ -327,15 +327,16 @@ static void *gNB_L1_thread( void *param ) {
 
   while (!oai_exit) {
     VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_gNB_PROC_RXTX0, 0 );
-
     if (wait_on_condition(&L1_proc->mutex,&L1_proc->cond,&L1_proc->instance_cnt,thread_name)<0) break;
-
     VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_gNB_PROC_RXTX0, 1 );
+
     int frame_rx          = L1_proc->frame_rx;
     int slot_rx           = L1_proc->slot_rx;
     int frame_tx          = L1_proc->frame_tx;
     int slot_tx           = L1_proc->slot_tx;
     uint64_t timestamp_tx = L1_proc->timestamp_tx;
+
+
     VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_SLOT_NUMBER_TX0_GNB,slot_tx);
     VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_SLOT_NUMBER_RX0_GNB,slot_rx);
     VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX0_GNB,frame_tx);
@@ -407,15 +408,17 @@ void gNB_top(PHY_VARS_gNB *gNB, int frame_rx, int slot_rx, char *string, struct
 }
 
 int wakeup_txfh(PHY_VARS_gNB *gNB,gNB_L1_rxtx_proc_t *proc,int frame_tx,int slot_tx,uint64_t timestamp_tx) {
+
   RU_t *ru;
   RU_proc_t *ru_proc;
+
   int waitret = 0, ret = 0, time_ns = 1000*1000;
   struct timespec now, abstime;
   // note this should depend on the numerology used by the TX L1 thread, set here for 500us slot time
+  // note this should depend on the numerology used by the TX L1 thread, set here for 500us slot time
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_UE_GAIN_CONTROL,1);
   time_ns = time_ns/gNB->frame_parms.slots_per_subframe;
   AssertFatal((ret = pthread_mutex_lock(&proc->mutex_RUs_tx))==0,"mutex_lock returns %d\n",ret);
-
   while (proc->instance_cnt_RUs < 0) {
     clock_gettime(CLOCK_REALTIME, &now);
     abstime.tv_sec = now.tv_sec;
@@ -425,10 +428,8 @@ int wakeup_txfh(PHY_VARS_gNB *gNB,gNB_L1_rxtx_proc_t *proc,int frame_tx,int slot
       abstime.tv_nsec -= 1000*1000*1000;
       abstime.tv_sec  += 1;
     }
-
     if((waitret = pthread_cond_timedwait(&proc->cond_RUs,&proc->mutex_RUs_tx,&abstime)) == 0) break; // this unlocks mutex_rxtx while waiting and then locks it again
   }
-
   proc->instance_cnt_RUs = -1;
   VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_RX0_UE,proc->instance_cnt_RUs);
   AssertFatal((ret = pthread_mutex_unlock(&proc->mutex_RUs_tx))==0,"mutex_unlock returns %d\n",ret);
@@ -436,6 +437,7 @@ int wakeup_txfh(PHY_VARS_gNB *gNB,gNB_L1_rxtx_proc_t *proc,int frame_tx,int slot
 
   if (waitret == ETIMEDOUT) {
     LOG_W(PHY,"Dropping TX slot (%d.%d) because FH is blocked more than 1 slot times (500us)\n",frame_tx,slot_tx);
+
     AssertFatal((ret=pthread_mutex_lock(&gNB->proc.mutex_RU_tx))==0,"mutex_lock returns %d\n",ret);
     gNB->proc.RU_mask_tx = 0;
     AssertFatal((ret=pthread_mutex_unlock(&gNB->proc.mutex_RU_tx))==0,"mutex_unlock returns %d\n",ret);
@@ -443,61 +445,81 @@ int wakeup_txfh(PHY_VARS_gNB *gNB,gNB_L1_rxtx_proc_t *proc,int frame_tx,int slot
     proc->instance_cnt_RUs = 0;
     VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_RX0_UE,proc->instance_cnt_RUs);
     AssertFatal((ret=pthread_mutex_unlock(&proc->mutex_RUs_tx))==0,"mutex_unlock returns %d\n",ret);
+
     VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX0_UE,1);
     VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX0_UE,0);
+
     return(-1);
   }
 
-  for(int i=0; i<gNB->num_RU; i++) {
+  for(int i=0; i<gNB->num_RU; i++)
+  {
     ru      = gNB->RU_list[i];
     ru_proc = &ru->proc;
 
+
     if (ru_proc->instance_cnt_gNBs == 0) {
       VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST_UE, 1);
       LOG_E(PHY,"Frame %d, subframe %d: TX FH thread busy, dropping Frame %d, subframe %d\n", ru_proc->frame_tx, ru_proc->tti_tx, proc->frame_rx, proc->slot_rx);
       AssertFatal((ret=pthread_mutex_lock(&gNB->proc.mutex_RU_tx))==0,"mutex_lock returns %d\n",ret);
       gNB->proc.RU_mask_tx = 0;
       AssertFatal((ret=pthread_mutex_unlock(&gNB->proc.mutex_RU_tx))==0,"mutex_unlock returns %d\n",ret);
+
       VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST_UE, 0);
       return(-1);
     }
-
     AssertFatal((ret = pthread_mutex_lock(&ru_proc->mutex_gNBs))==0,"ERROR pthread_mutex_lock failed on mutex_gNBs L1_thread_tx with ret=%d\n",ret);
+
     ru_proc->instance_cnt_gNBs = 0;
     ru_proc->timestamp_tx = timestamp_tx;
     ru_proc->tti_tx       = slot_tx;
     ru_proc->frame_tx     = frame_tx;
+
     VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_RX1_UE, ru_proc->instance_cnt_gNBs);
+
     LOG_D(PHY,"Signaling tx_thread_fh for %d.%d\n",frame_tx,slot_tx);
     // the thread can now be woken up
     AssertFatal(pthread_cond_signal(&ru_proc->cond_gNBs) == 0,
                 "[gNB] ERROR pthread_cond_signal for gNB TXnp4 thread\n");
     AssertFatal((ret=pthread_mutex_unlock(&ru_proc->mutex_gNBs))==0,"mutex_unlock returned %d\n",ret);
-  }
 
+  }
   return(0);
 }
 
 int wakeup_tx(PHY_VARS_gNB *gNB,int frame_rx,int slot_rx,int frame_tx,int slot_tx,uint64_t timestamp_tx) {
+
+
   gNB_L1_rxtx_proc_t *L1_proc_tx = &gNB->proc.L1_proc_tx;
+
   int ret;
+ 
+  
   AssertFatal((ret = pthread_mutex_lock(&L1_proc_tx->mutex))==0,"mutex_lock returns %d\n",ret);
 
+
   while(L1_proc_tx->instance_cnt == 0) {
     pthread_cond_wait(&L1_proc_tx->cond,&L1_proc_tx->mutex);
   }
 
   L1_proc_tx->instance_cnt = 0;
+
+  
   L1_proc_tx->slot_rx       = slot_rx;
   L1_proc_tx->frame_rx      = frame_rx;
   L1_proc_tx->slot_tx       = slot_tx;
   L1_proc_tx->frame_tx      = frame_tx;
   L1_proc_tx->timestamp_tx  = timestamp_tx;
+
+ 
   VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX1_UE,1);
   VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX1_UE,0);
   // the thread can now be woken up
+  // the thread can now be woken up
   AssertFatal(pthread_cond_signal(&L1_proc_tx->cond) == 0, "ERROR pthread_cond_signal for gNB L1 thread\n");
+  
   AssertFatal((ret=pthread_mutex_unlock(&L1_proc_tx->mutex))==0,"mutex_unlock returns %d\n",ret);
+
   return(0);
 }
 
@@ -510,23 +532,22 @@ int wakeup_rxtx(PHY_VARS_gNB *gNB,RU_t *ru) {
   int i;
   struct timespec abstime;
   int time_ns = 50000;
+  
   AssertFatal((ret=pthread_mutex_lock(&proc->mutex_RU))==0,"mutex_lock returns %d\n",ret);
-
   for (i=0; i<gNB->num_RU; i++) {
     if (ru == gNB->RU_list[i]) {
       if ((proc->RU_mask&(1<<i)) > 0)
         LOG_E(PHY,"gNB %d frame %d, subframe %d : previous information from RU %d (num_RU %d,mask %x) has not been served yet!\n",
               gNB->Mod_id,proc->frame_rx,proc->slot_rx,ru->idx,gNB->num_RU,proc->RU_mask);
-
       proc->RU_mask |= (1<<i);
     }
   }
-
   if (proc->RU_mask != (1<<gNB->num_RU)-1) {  // not all RUs have provided their information so return
     LOG_E(PHY,"Not all RUs have provided their info\n");
     AssertFatal((ret=pthread_mutex_unlock(&proc->mutex_RU))==0,"mutex_unlock returns %d\n",ret);
     return(0);
-  } else { // all RUs have provided their information so continue on and wakeup gNB processing
+  }
+  else { // all RUs have provided their information so continue on and wakeup gNB processing
     proc->RU_mask = 0;
     AssertFatal((ret=pthread_mutex_unlock(&proc->mutex_RU))==0,"muex_unlock returns %d\n",ret);
   }
@@ -556,12 +577,15 @@ int wakeup_rxtx(PHY_VARS_gNB *gNB,RU_t *ru) {
   // The last (TS_rx mod samples_per_frame) was n*samples_per_tti,
   // we want to generate subframe (n+sl_ahead), so TS_tx = TX_rx+sl_ahead*samples_per_tti,
   // and proc->slot_tx = proc->slot_rx+sl_ahead
+  // and proc->slot_tx = proc->slot_rx+sl_ahead
   L1_proc->timestamp_tx = ru_proc->timestamp_rx + (sl_ahead*fp->samples_per_slot);
   L1_proc->frame_rx     = ru_proc->frame_rx;
   L1_proc->slot_rx  = ru_proc->tti_rx;
   L1_proc->frame_tx     = (L1_proc->slot_rx > (fp->slots_per_frame-1-sl_ahead)) ? (L1_proc->frame_rx+1)&1023 : L1_proc->frame_rx;
   L1_proc->slot_tx  = (L1_proc->slot_rx + sl_ahead)%fp->slots_per_frame;
+
   LOG_D(PHY,"wakeupL1: passing parameter IC = %d, RX: %d.%d, TX: %d.%d to L1 sl_ahead = %d\n", L1_proc->instance_cnt, L1_proc->frame_rx, L1_proc->slot_rx, L1_proc->frame_tx, L1_proc->slot_tx, sl_ahead);
+
   pthread_mutex_unlock( &L1_proc->mutex );
 
   // the thread can now be woken up
@@ -675,19 +699,22 @@ extern void init_td_thread(PHY_VARS_gNB *);
 extern void init_te_thread(PHY_VARS_gNB *);
 
 static void *process_stats_thread(void *param) {
+
   PHY_VARS_gNB *gNB  = (PHY_VARS_gNB *)param;
+
   reset_meas(&gNB->dlsch_encoding_stats);
   reset_meas(&gNB->dlsch_scrambling_stats);
   reset_meas(&gNB->dlsch_modulation_stats);
+
   wait_sync("process_stats_thread");
 
-  while(!oai_exit) {
+  while(!oai_exit)
+  {
     sleep(1);
     print_meas(&gNB->dlsch_encoding_stats, "pdsch_encoding", NULL, NULL);
     print_meas(&gNB->dlsch_scrambling_stats, "pdsch_scrambling", NULL, NULL);
     print_meas(&gNB->dlsch_modulation_stats, "pdsch_modulation", NULL, NULL);
   }
-
   return(NULL);
 }
 
@@ -740,7 +767,6 @@ void init_gNB_proc(int inst) {
     }
 
     if(opp_enabled == 1) threadCreate(&proc->L1_stats_thread, process_stats_thread,(void *)gNB, "time_meas", -1, OAI_PRIORITY_RT_LOW);
-
     //pthread_create( &proc->pthread_prach, attr_prach, gNB_thread_prach, gNB );
     char name[16];
 
@@ -942,6 +968,7 @@ void init_gNB(int single_thread_flag,int wait_for_sync) {
       gNB->UL_INFO.harq_ind.harq_indication_body.harq_pdu_list = gNB->harq_pdu_list;
       gNB->UL_INFO.cqi_ind.cqi_pdu_list = gNB->cqi_pdu_list;
       gNB->UL_INFO.cqi_ind.cqi_raw_pdu_list = gNB->cqi_raw_pdu_list;
+      
       gNB->prach_energy_counter = 0;
     }
   }
diff --git a/executables/split_headers.h b/executables/split_headers.h
index 54b9930250b..62293c73697 100644
--- a/executables/split_headers.h
+++ b/executables/split_headers.h
@@ -1,3 +1,7 @@
+/*
+  Author: Laurent THOMAS, Open Cells Project company, funded by IRT SystemX
+  copyleft: OpenAirInterface Software Alliance and it's licence
+*/
 #ifndef __SPLIT_HEADERS_H
 #define __SPLIT_HEADERS_H
 
diff --git a/executables/transport_split.c b/executables/transport_split.c
index 1ed95db7a0e..7a1ee3e85ea 100644
--- a/executables/transport_split.c
+++ b/executables/transport_split.c
@@ -1,3 +1,7 @@
+/*
+  Author: Laurent THOMAS, Open Cells Project company, funded by IRT SystemX
+  copyleft: OpenAirInterface Software Alliance and it's licence
+*/
 #include <executables/split_headers.h>
 #include <sys/types.h>          /* See NOTES */
 #include <sys/socket.h>
diff --git a/nfapi/oai_integration/nfapi_vnf.c b/nfapi/oai_integration/nfapi_vnf.c
index c1f69574fdd..a0574221f5b 100644
--- a/nfapi/oai_integration/nfapi_vnf.c
+++ b/nfapi/oai_integration/nfapi_vnf.c
@@ -398,7 +398,7 @@ int phy_sync_indication(struct nfapi_vnf_p7_config *config, uint8_t sync) {
   return(0);
 }
 
-int phy_subframe_indication(L1_rxtx_proc_t * proc, struct nfapi_vnf_p7_config *config, uint16_t phy_id, uint16_t sfn_sf) {
+int phy_subframe_indication(struct nfapi_vnf_p7_config *config, uint16_t phy_id, uint16_t sfn_sf) {
   static uint8_t first_time = 1;
 
   if (first_time) {
diff --git a/openair1/PHY/LTE_ESTIMATION/lte_adjust_sync_eNB.c b/openair1/PHY/LTE_ESTIMATION/lte_adjust_sync_eNB.c
index 294169b75d6..04fe19ecbce 100644
--- a/openair1/PHY/LTE_ESTIMATION/lte_adjust_sync_eNB.c
+++ b/openair1/PHY/LTE_ESTIMATION/lte_adjust_sync_eNB.c
@@ -148,5 +148,9 @@ int lte_est_timing_advance_pusch(PHY_VARS_eNB *eNB,
   if (max_pos>frame_parms->ofdm_symbol_size/2)
     max_pos = max_pos-frame_parms->ofdm_symbol_size;
 
+  //#ifdef DEBUG_PHY
+  LOG_D(PHY,"frame %d: max_pos = %d, sync_pos=%d\n",eNB->proc.frame_rx,max_pos,sync_pos);
+  //#endif //DEBUG_PHY
+
   return max_pos - sync_pos;
 }
diff --git a/openair1/PHY/LTE_ESTIMATION/lte_dl_bf_channel_estimation.c b/openair1/PHY/LTE_ESTIMATION/lte_dl_bf_channel_estimation.c
index 43c0350efb1..2331e253d5f 100644
--- a/openair1/PHY/LTE_ESTIMATION/lte_dl_bf_channel_estimation.c
+++ b/openair1/PHY/LTE_ESTIMATION/lte_dl_bf_channel_estimation.c
@@ -43,7 +43,7 @@ int lte_dl_bf_channel_estimation(PHY_VARS_UE *phy_vars_ue,
   uint8_t pilot0,pilot1,pilot2,pilot3;
 
   short ch[2], *pil, *rxF, *dl_bf_ch, *dl_bf_ch_prev;
-  short *fl, *fm, *fr, *fl_dc, *fm_dc, *fr_dc, *f1, *f2l, *f2r;
+  short *fl=NULL, *fm=NULL, *fr=NULL, *fl_dc=NULL, *fm_dc=NULL, *fr_dc=NULL, *f1, *f2l=NULL, *f2r=NULL;
 
   unsigned int *rballoc; 
   int **rxdataF;
@@ -58,10 +58,10 @@ int lte_dl_bf_channel_estimation(PHY_VARS_UE *phy_vars_ue,
   dlsch0_harq = dlsch_ue[0]->harq_processes[harq_pid];
 
   if (((frame_parms->Ncp == NORMAL) && (symbol>=7)) ||
-      ((frame_parms->Ncp == EXTENDED) && (symbol>=6)))
-    rballoc = dlsch0_harq->rb_alloc_odd;
+		  ((frame_parms->Ncp == EXTENDED) && (symbol>=6)))
+	  rballoc = dlsch0_harq->rb_alloc_odd;
   else
-    rballoc = dlsch0_harq->rb_alloc_even;
+	  rballoc = dlsch0_harq->rb_alloc_even;
 
   rxdataF = phy_vars_ue->common_vars.common_vars_rx_data_per_thread[phy_vars_ue->current_thread_id[Ns>>1]].rxdataF;
 
@@ -69,56 +69,56 @@ int lte_dl_bf_channel_estimation(PHY_VARS_UE *phy_vars_ue,
   beamforming_mode   = phy_vars_ue->transmission_mode[eNB_id]>6 ? phy_vars_ue->transmission_mode[eNB_id] : 0;
 
   if (phy_vars_ue->high_speed_flag == 0) // use second channel estimate position for temporary storage
-    ch_offset     = frame_parms->ofdm_symbol_size;
+	  ch_offset     = frame_parms->ofdm_symbol_size;
   else
-    ch_offset     = frame_parms->ofdm_symbol_size*symbol;
+	  ch_offset     = frame_parms->ofdm_symbol_size*symbol;
+
 
-  
   uespec_nushift = frame_parms->Nid_cell%3;
   subframe = Ns>>1;
- 
 
-    //generate ue specific pilots
-    lprime = symbol/3-1;
-    lte_dl_ue_spec_rx(phy_vars_ue,uespec_pilot,Ns,5,lprime,0,dlsch0_harq->nb_rb);
-    //LOG_M("uespec_pilot_rx.m","uespec_pilot",uespec_pilot,300,1,1);
-
-    if (frame_parms->Ncp==0){
-      if (symbol==3 || symbol==6 || symbol==9 || symbol==12)
-        uespec_pilots = 1;
-    } else{
-      if (symbol==4 || symbol==7 || symbol==10)
-        uespec_pilots = 1;
-    }
-   
-    if ((frame_parms->Ncp==0 && (symbol==6 ||symbol ==12)) || (frame_parms->Ncp==1 && symbol==7))
-      uespec_poffset = 2;
-
-    if (phy_vars_ue->frame_parms.Ncp == 0) { // normal prefix
-      pilot0 = 3;
-      pilot1 = 6;
-      pilot2 = 9;
-      pilot3 = 12;
-    } else { // extended prefix
-      pilot0 = 4;
-      pilot1 = 7;
-      pilot2 = 10;
-    }
 
-    //define the filter
-    pil_offset = (uespec_nushift+uespec_poffset)%3;
-    // printf("symbol=%d,pil_offset=%d\n",symbol,pil_offset);
-    switch (pil_offset) {
-    case 0:
-      fl = filt16_l0;
-      fm = filt16_m0;
-      fr = filt16_r0;
-      fl_dc = filt16_l0;
-      fm_dc = filt16_m0;
-      fr_dc = filt16_r0;
-      f1 = filt16_1;
-      f2l = filt16_2l0;
-      f2r = filt16_2r0;
+  //generate ue specific pilots
+  lprime = symbol/3-1;
+  lte_dl_ue_spec_rx(phy_vars_ue,uespec_pilot,Ns,5,lprime,0,dlsch0_harq->nb_rb);
+  //LOG_M("uespec_pilot_rx.m","uespec_pilot",uespec_pilot,300,1,1);
+
+  if (frame_parms->Ncp==0){
+	  if (symbol==3 || symbol==6 || symbol==9 || symbol==12)
+		  uespec_pilots = 1;
+  } else{
+	  if (symbol==4 || symbol==7 || symbol==10)
+		  uespec_pilots = 1;
+  }
+
+  if ((frame_parms->Ncp==0 && (symbol==6 ||symbol ==12)) || (frame_parms->Ncp==1 && symbol==7))
+	  uespec_poffset = 2;
+
+  if (phy_vars_ue->frame_parms.Ncp == 0) { // normal prefix
+	  pilot0 = 3;
+	  pilot1 = 6;
+	  pilot2 = 9;
+	  pilot3 = 12;
+  } else { // extended prefix
+	  pilot0 = 4;
+	  pilot1 = 7;
+	  pilot2 = 10;
+  }
+
+  //define the filter
+  pil_offset = (uespec_nushift+uespec_poffset)%3;
+  // printf("symbol=%d,pil_offset=%d\n",symbol,pil_offset);
+  switch (pil_offset) {
+	  case 0:
+		  fl = filt16_l0;
+		  fm = filt16_m0;
+		  fr = filt16_r0;
+		  fl_dc = filt16_l0;
+		  fm_dc = filt16_m0;
+		  fr_dc = filt16_r0;
+		  f1 = filt16_1;
+		  f2l = filt16_2l0;
+		  f2r = filt16_2r0;
       break;
 
     case 1:
diff --git a/openair1/PHY/LTE_TRANSPORT/if5_tools.c b/openair1/PHY/LTE_TRANSPORT/if5_tools.c
index 0e383fa04f4..1e0dd9db1b7 100644
--- a/openair1/PHY/LTE_TRANSPORT/if5_tools.c
+++ b/openair1/PHY/LTE_TRANSPORT/if5_tools.c
@@ -1504,7 +1504,7 @@ void recv_IF5(RU_t *ru, openair0_timestamp *proc_timestamp, int subframe, uint16
       rxp[0] = (void*)&ru->common.rxdata[0][subframe*ru->frame_parms->samples_per_tti];
       rxp128 = (__m128i *) (rxp[0]);
    
-      RU_proc_t *proc = NULL; //&ru->eNB_list[0]->proc.L1_proc;
+      RU_proc_t *proc = &ru->proc;
 /*
    //   while(packet_id<fp->samples_per_tti/db_fulllength) {
         data_block = data_block_head;
diff --git a/openair1/PHY/LTE_TRANSPORT/phich.c b/openair1/PHY/LTE_TRANSPORT/phich.c
index ab2fe2d743b..6d8b58818b1 100644
--- a/openair1/PHY/LTE_TRANSPORT/phich.c
+++ b/openair1/PHY/LTE_TRANSPORT/phich.c
@@ -714,7 +714,7 @@ void generate_phich_top(PHY_VARS_eNB *eNB,
   int32_t **txdataF = eNB->common_vars.txdataF;
   uint8_t Ngroup_PHICH,ngroup_PHICH,nseq_PHICH;
   uint8_t NSF_PHICH = 4;
-  uint8_t pusch_subframe;
+  uint8_t pusch_subframe=-1;
   uint8_t i;
   int subframe = proc->subframe_tx;
   phich_config_t *phich;
diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c b/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c
index 9351cf0adc0..1b0d7feaf51 100644
--- a/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c
+++ b/openair1/PHY/LTE_TRANSPORT/ulsch_demodulation.c
@@ -1199,7 +1199,6 @@ void dump_ulsch(PHY_VARS_eNB *eNB,int frame,int subframe,uint8_t UE_id,int round
          eNB->ulsch[UE_id]->harq_processes[harq_pid]->Nsymb_pusch);
   sprintf(fname,"/tmp/ulsch_r%d_d",round);
   sprintf(vname,"/tmp/ulsch_r%d_dseq",round);
-
   LOG_UM(fname,vname,&eNB->ulsch[UE_id]->harq_processes[harq_pid]->d[0][96],
          eNB->ulsch[UE_id]->harq_processes[harq_pid]->Kplus*3,1,0);
 
diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c
index 1ada5947254..daa9039236f 100644
--- a/openair1/SCHED/phy_procedures_lte_eNb.c
+++ b/openair1/SCHED/phy_procedures_lte_eNb.c
@@ -175,7 +175,7 @@ void common_signal_procedures (PHY_VARS_eNB *eNB,int frame, int subframe) {
   LTE_DL_FRAME_PARMS *fp=&eNB->frame_parms;
   int **txdataF = eNB->common_vars.txdataF;
   uint8_t *pbch_pdu=&eNB->pbch_pdu[0];
-  LOG_D(PHY,"common_signal_procedures: frame %d, subframe %d fdd:%s dir:%s\n",frame,subframe,fp->frame_type == FDD?"FDD":"TDD", subframe_select(fp,subframe) == SF_DL?"DL":"UL?");
+  //LOG_D(PHY,"common_signal_procedures: frame %d, subframe %d fdd:%s dir:%s\n",frame,subframe,fp->frame_type == FDD?"FDD":"TDD", subframe_select(fp,subframe) == SF_DL?"DL":"UL?");
   // generate Cell-Specific Reference Signals for both slots
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_RS_TX,1);
 
@@ -291,7 +291,6 @@ bool dlsch_procedures(PHY_VARS_eNB *eNB,
 
   if (dlsch->rnti!=0xffff)
     LOG_D(PHY,"Generating DLSCH/PDSCH pdu:%p pdsch_start:%d frame:%d subframe:%d nb_rb:%d rb_alloc:%d Qm:%d Nl:%d round:%d\n",
-
           dlsch_harq->pdu,dlsch_harq->pdsch_start,frame,subframe,dlsch_harq->nb_rb,dlsch_harq->rb_alloc[0],
           dlsch_harq->Qm,dlsch_harq->Nl,dlsch_harq->round);
 
diff --git a/openair1/SCHED/prach_procedures.c b/openair1/SCHED/prach_procedures.c
index 4f2d05ef504..f1e7589a661 100644
--- a/openair1/SCHED/prach_procedures.c
+++ b/openair1/SCHED/prach_procedures.c
@@ -108,6 +108,15 @@ void prach_procedures(PHY_VARS_eNB *eNB,
         eNB->prach_energy_counter,
         eNB->measurements.prach_I0+eNB->prach_DTX_threshold,
         eNB->measurements.prach_I0);
+	if (max_preamble_energy[0] > 100 && br_flag==0)
+	  LOG_W(PHY,"[RAPROC] Frame %d, subframe %d : BR %d  Most likely preamble %d, energy %d dB delay %d (prach_energy counter %d), threshold %d, I0 %d\n",
+        frame,subframe,br_flag,
+        max_preamble[0],
+        max_preamble_energy[0]/10,
+        max_preamble_delay[0],
+        eNB->prach_energy_counter,
+        eNB->measurements.prach_I0+eNB->prach_DTX_threshold,
+        eNB->measurements.prach_I0);
 
   if (br_flag==1) {
     int             prach_mask;
diff --git a/openair1/SCHED/sched_eNB.h b/openair1/SCHED/sched_eNB.h
index da0106226e3..f04bec2e5c4 100644
--- a/openair1/SCHED/sched_eNB.h
+++ b/openair1/SCHED/sched_eNB.h
@@ -127,9 +127,11 @@ void phy_procedures_eNB_S_RX(PHY_VARS_eNB *phy_vars_eNB,L1_rxtx_proc_t *proc);
   @param phy_vars_eNB Pointer to eNB variables on which to act
   @param br_flag indicator for eMTC PRACH
 */
+
 void prach_procedures(PHY_VARS_eNB *eNB, 
 		      int br_flag);
 
+
 /*! \brief Function to compute timing of Msg3 transmission on UL-SCH (first UE transmission in RA procedure). This implements the timing in paragraph a) from Section 6.1.1 in 36.213 (p. 17 in version 8.6).  Used by eNB upon transmission of random-access response (RA_RNTI) to program corresponding ULSCH reception procedure.  Used by UE upon reception of random-access response (RA_RNTI) to program corresponding ULSCH transmission procedure.  This does not support the UL_delay field in RAR (always assumed to be 0).
   @param frame_parms Pointer to DL frame parameter descriptor
   @param current_subframe Index of subframe where RA_RNTI was received
diff --git a/openair1/SCHED_UE/phy_procedures_lte_ue.c b/openair1/SCHED_UE/phy_procedures_lte_ue.c
index c64a8ef177b..8ca533c1466 100644
--- a/openair1/SCHED_UE/phy_procedures_lte_ue.c
+++ b/openair1/SCHED_UE/phy_procedures_lte_ue.c
@@ -3467,7 +3467,7 @@ void ue_dlsch_procedures(PHY_VARS_UE *ue,
             frame_rx%1024, subframe_rx,(ue->dlsch_decoding_stats[ue->current_thread_id[subframe_rx]].p_time)/(cpuf*1000.0));
     }
 
-    LOG_D(PHY," ------ end turbo decoder for AbsSubframe %d.%d ------ iter %d \n", frame_rx, subframe_rx,ret1);
+    LOG_D(PHY," ------ end turbo decoder for AbsSubframe %d.%d ------  \n", frame_rx, subframe_rx);
 
     // Check CRC for CW 0
     if (ret == (1+dlsch0->max_turbo_iterations)) {
diff --git a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c
index 4aef7ce7719..5189e769757 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c
@@ -4982,12 +4982,7 @@ cqi_indication(module_id_t mod_idP,
           UE_id,
           ul_cqi_information->channel,
           ul_cqi_information->ul_cqi);
-/*
-    int sum=0;
-    for (int i=0; i <rel9->length; i++)
-	    sum+=pdu[i];
-    LOG_D(MAC, "pdu for channel: %d, checksum: %d\n", ul_cqi_information->channel, sum); 
-*/
+
     if (ul_cqi_information->channel == 0) { // PUCCH
       // extract pucch csi information before changing RI information
       extract_pucch_csi(mod_idP,
diff --git a/openair2/RRC/LTE/rrc_eNB.c b/openair2/RRC/LTE/rrc_eNB.c
index b77ac077296..baf4d824655 100644
--- a/openair2/RRC/LTE/rrc_eNB.c
+++ b/openair2/RRC/LTE/rrc_eNB.c
@@ -8604,6 +8604,8 @@ void *rrc_enb_process_itti_msg(void *notUsed) {
   return NULL;
 }
 
+// as there are race conditions, no rrc thread
+#if 0
 //-----------------------------------------------------------------------------
 void *
 rrc_enb_task(
@@ -8620,6 +8622,7 @@ rrc_enb_task(
   //}
   return NULL;
 }
+#endif
 
 /*------------------------------------------------------------------------------*/
 void
diff --git a/targets/RT/USER/lte-softmodem.h b/targets/RT/USER/lte-softmodem.h
index b67a54e4a05..7b896b28172 100644
--- a/targets/RT/USER/lte-softmodem.h
+++ b/targets/RT/USER/lte-softmodem.h
@@ -135,6 +135,7 @@
 
 #define DEFAULT_DLF 2680000000
 
+
 uint64_t get_pdcp_optmask(void);
 extern pthread_cond_t sync_cond;
 extern pthread_mutex_t sync_mutex;
-- 
GitLab