From eebb19d9ebb7189d1e91258f18b24cd521f267e6 Mon Sep 17 00:00:00 2001
From: magounak <magounak@eurecom.fr>
Date: Tue, 27 Nov 2018 12:17:39 +0100
Subject: [PATCH] added some extra vcd signals

---
 common/utils/LOG/vcd_signal_dumper.c   |  32 +++++--
 common/utils/LOG/vcd_signal_dumper.h   |  28 ++++--
 common/utils/T/T_defs.h                |   2 +-
 common/utils/T/T_messages.txt          | 120 ++++++++++++++++++++-----
 openair1/PHY/LTE_TRANSPORT/if4_tools.c |   8 +-
 openair1/PHY/defs_eNB.h                |   6 +-
 targets/RT/USER/lte-enb.c              |   5 ++
 targets/RT/USER/lte-ru.c               |  37 ++++----
 targets/RT/USER/ru_control.c           |   2 +-
 9 files changed, 180 insertions(+), 60 deletions(-)

diff --git a/common/utils/LOG/vcd_signal_dumper.c b/common/utils/LOG/vcd_signal_dumper.c
index 8ea3f54d54..12b0627a23 100644
--- a/common/utils/LOG/vcd_signal_dumper.c
+++ b/common/utils/LOG/vcd_signal_dumper.c
@@ -82,10 +82,26 @@ const char* eurecomVariablesNames[] = {
   "frame_number_if4p5_north_out",
   "subframe_number_if4p5_north_asynch_in",
   "frame_number_if4p5_north_asynch_in",
-  "subframe_number_if4p5_south_out",
-  "frame_number_if4p5_south_out",
-  "subframe_number_if4p5_south_in",
-  "frame_number_if4p5_south_in",
+  "subframe_number_if4p5_south_out_ru",
+  "subframe_number_if4p5_south_out_ru1",
+  "frame_number_if4p5_south_out_ru",
+  "frame_number_if4p5_south_out_ru1",
+  "subframe_number_if4p5_south_in_ru",
+  "subframe_number_if4p5_south_in_ru1",
+  "frame_number_if4p5_south_in_ru",
+  "frame_number_if4p5_south_in_ru1",
+  "subframe_number_wakeup_l1s_ru",
+  "subframe_number_wakeup_l1s_ru1",
+  "frame_number_wakeup_l1s_ru",
+  "frame_number_wakeup_l1s_ru1",
+  "subframe_number_wakeup_rxtx_rx_ru",
+  "subframe_number_wakeup_rxtx_rx_ru1",
+  "frame_number_wakeup_rxtx_rx_ru",
+  "frame_number_wakeup_rxtx_rx_ru1",
+  "subframe_number_wakeup_rxtx_tx_ru",
+  "subframe_number_wakeup_rxtx_tx_ru1",
+  "frame_number_wakeup_rxtx_tx_ru",
+  "frame_number_wakeup_rxtx_tx_ru1",
   "ic_enb",
   "l1_proc_ic",
   "l1_proc_tx_ic",
@@ -427,10 +443,10 @@ const char* eurecomFunctionsNames[] = {
   "test",
   
   /* IF4/IF5 signals */
-  "send_if4",
-  "send_if4_RU1",
-  "recv_if4",
-  "recv_if4_RU1",
+  "send_if4_ru",
+  "send_if4_ru1",
+  "recv_if4_ru",
+  "recv_if4_ru1",
   "send_if5",
   "recv_if5",
 
diff --git a/common/utils/LOG/vcd_signal_dumper.h b/common/utils/LOG/vcd_signal_dumper.h
index 7e5b9a387d..707905ce4d 100644
--- a/common/utils/LOG/vcd_signal_dumper.h
+++ b/common/utils/LOG/vcd_signal_dumper.h
@@ -59,10 +59,26 @@ typedef enum {
   VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_IF4P5_NORTH_OUT,
   VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_IF4P5_NORTH_ASYNCH_IN,
   VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_IF4P5_NORTH_ASYNCH_IN,
-  VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_IF4P5_SOUTH_OUT,
-  VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_IF4P5_SOUTH_OUT,
-  VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_IF4P5_SOUTH_IN,
-  VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_IF4P5_SOUTH_IN,
+  VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_IF4P5_SOUTH_OUT_RU,
+  VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_IF4P5_SOUTH_OUT_RU1,
+  VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_IF4P5_SOUTH_OUT_RU,
+  VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_IF4P5_SOUTH_OUT_RU1,
+  VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_IF4P5_SOUTH_IN_RU,
+  VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_IF4P5_SOUTH_IN_RU1,
+  VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_IF4P5_SOUTH_IN_RU,
+  VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_IF4P5_SOUTH_IN_RU1,
+  VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_WAKEUP_L1S_RU,
+  VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_WAKEUP_L1S_RU1,
+  VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_WAKEUP_L1S_RU,
+  VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_WAKEUP_L1S_RU1,
+  VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_WAKEUP_RXTX_RX_RU,
+  VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_WAKEUP_RXTX_RX_RU1,
+  VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_WAKEUP_RXTX_RX_RU,
+  VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_WAKEUP_RXTX_RX_RU1,
+  VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_WAKEUP_RXTX_TX_RU,
+  VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_WAKEUP_RXTX_TX_RU1,
+  VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_WAKEUP_RXTX_TX_RU,
+  VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_WAKEUP_RXTX_TX_RU1,
   VCD_SIGNAL_DUMPER_VARIABLES_IC_ENB,
   VCD_SIGNAL_DUMPER_VARIABLES_L1_PROC_IC,
   VCD_SIGNAL_DUMPER_VARIABLES_L1_PROC_TX_IC,
@@ -407,9 +423,9 @@ typedef enum {
   VCD_SIGNAL_DUMPER_FUNCTIONS_TEST,
   
   /* IF4/IF5 signals */
-  VCD_SIGNAL_DUMPER_FUNCTIONS_SEND_IF4,
+  VCD_SIGNAL_DUMPER_FUNCTIONS_SEND_IF4_RU,
   VCD_SIGNAL_DUMPER_FUNCTIONS_SEND_IF4_RU1,
-  VCD_SIGNAL_DUMPER_FUNCTIONS_RECV_IF4,
+  VCD_SIGNAL_DUMPER_FUNCTIONS_RECV_IF4_RU,
   VCD_SIGNAL_DUMPER_FUNCTIONS_RECV_IF4_RU1,
   VCD_SIGNAL_DUMPER_FUNCTIONS_SEND_IF5,
   VCD_SIGNAL_DUMPER_FUNCTIONS_RECV_IF5,
diff --git a/common/utils/T/T_defs.h b/common/utils/T/T_defs.h
index 70e286d220..005a7e67a1 100644
--- a/common/utils/T/T_defs.h
+++ b/common/utils/T/T_defs.h
@@ -44,7 +44,7 @@ typedef struct {
 #define VCD_NUM_FUNCTIONS (218)
 
 /* number of VCD variables (to be kept up to date! see in T_messages.txt) */
-#define VCD_NUM_VARIABLES (139) /*(136)*//*(128)*/
+#define VCD_NUM_VARIABLES (155) 
 
 /* first VCD function (to be kept up to date! see in T_messages.txt) */
 #define VCD_FIRST_FUNCTION    ((uintptr_t)T_VCD_FUNCTION_RT_SLEEP)
diff --git a/common/utils/T/T_messages.txt b/common/utils/T/T_messages.txt
index b22be33b17..c4af298ab5 100644
--- a/common/utils/T/T_messages.txt
+++ b/common/utils/T/T_messages.txt
@@ -1051,26 +1051,106 @@ ID = VCD_VARIABLE_FRAME_NUMBER_IF4P5_NORTH_ASYNCH_IN
     GROUP = ALL:VCD:ENB:VCD_VARIABLE
     FORMAT = ulong,value
     VCD_NAME = frame_number_if4p5_north_asynch_in
-ID = VCD_VARIABLE_SUBFRAME_NUMBER_IF4P5_SOUTH_OUT
-    DESC = VCD variable SUBFRAME_NUMBER_IF4P5_SOUTH_OUT
+ID = VCD_VARIABLE_SUBFRAME_NUMBER_IF4P5_SOUTH_OUT_RU
+    DESC = VCD variable SUBFRAME_NUMBER_IF4P5_SOUTH_OUT_RU
     GROUP = ALL:VCD:ENB:VCD_VARIABLE
     FORMAT = ulong,value
-    VCD_NAME = subframe_number_if4p5_south_out
-ID = VCD_VARIABLE_FRAME_NUMBER_IF4P5_SOUTH_OUT
-    DESC = VCD variable FRAME_NUMBER_IF4P5_SOUTH_OUT
+    VCD_NAME = subframe_number_if4p5_south_out_ru
+ID = VCD_VARIABLE_SUBFRAME_NUMBER_IF4P5_SOUTH_OUT_RU1
+    DESC = VCD variable SUBFRAME_NUMBER_IF4P5_SOUTH_OUT_RU1
     GROUP = ALL:VCD:ENB:VCD_VARIABLE
     FORMAT = ulong,value
-    VCD_NAME = frame_number_if4p5_south_out
-ID = VCD_VARIABLE_SUBFRAME_NUMBER_IF4P5_SOUTH_IN
-    DESC = VCD variable SUBFRAME_NUMBER_IF4P5_SOUTH_IN
+    VCD_NAME = subframe_number_if4p5_south_out_ru1
+ID = VCD_VARIABLE_FRAME_NUMBER_IF4P5_SOUTH_OUT_RU
+    DESC = VCD variable FRAME_NUMBER_IF4P5_SOUTH_OUT_RU
     GROUP = ALL:VCD:ENB:VCD_VARIABLE
     FORMAT = ulong,value
-    VCD_NAME = subframe_number_if4p5_south_in
-ID = VCD_VARIABLE_FRAME_NUMBER_IF4P5_SOUTH_IN
-    DESC = VCD variable FRAME_NUMBER_IF4P5_SOUTH_IN
+    VCD_NAME = frame_number_if4p5_south_out_ru
+ID = VCD_VARIABLE_FRAME_NUMBER_IF4P5_SOUTH_OUT_RU1
+    DESC = VCD variable FRAME_NUMBER_IF4P5_SOUTH_OUT_RU1
     GROUP = ALL:VCD:ENB:VCD_VARIABLE
     FORMAT = ulong,value
-    VCD_NAME = frame_number_if4p5_south_in
+    VCD_NAME = frame_number_if4p5_south_out_ru1
+ID = VCD_VARIABLE_SUBFRAME_NUMBER_IF4P5_SOUTH_IN_RU
+    DESC = VCD variable SUBFRAME_NUMBER_IF4P5_SOUTH_IN_RU
+    GROUP = ALL:VCD:ENB:VCD_VARIABLE
+    FORMAT = ulong,value
+    VCD_NAME = subframe_number_if4p5_south_in_ru
+ID = VCD_VARIABLE_SUBFRAME_NUMBER_IF4P5_SOUTH_IN_RU1
+    DESC = VCD variable SUBFRAME_NUMBER_IF4P5_SOUTH_IN_RU1
+    GROUP = ALL:VCD:ENB:VCD_VARIABLE
+    FORMAT = ulong,value
+    VCD_NAME = subframe_number_if4p5_south_in_ru1
+ID = VCD_VARIABLE_FRAME_NUMBER_IF4P5_SOUTH_IN_RU
+    DESC = VCD variable FRAME_NUMBER_IF4P5_SOUTH_IN_RU
+    GROUP = ALL:VCD:ENB:VCD_VARIABLE
+    FORMAT = ulong,value
+    VCD_NAME = frame_number_if4p5_south_in_ru
+ID = VCD_VARIABLE_FRAME_NUMBER_IF4P5_SOUTH_IN_RU1
+    DESC = VCD variable FRAME_NUMBER_IF4P5_SOUTH_IN_RU1
+    GROUP = ALL:VCD:ENB:VCD_VARIABLE
+    FORMAT = ulong,value
+    VCD_NAME = frame_number_if4p5_south_in_ru1
+ID = VCD_VARIABLE_SUBFRAME_NUMBER_WAKEUP_L1S_RU
+    DESC = VCD variable SUBFRAME_NUMBER_WAKEUP_L1S_RU
+    GROUP = ALL:VCD:ENB:VCD_VARIABLE
+    FORMAT = ulong,value
+    VCD_NAME = subframe_number_wakeup_l1s_ru
+ID = VCD_VARIABLE_SUBFRAME_NUMBER_WAKEUP_L1S_RU1
+    DESC = VCD variable SUBFRAME_NUMBER_WAKEUP_L1S_RU1
+    GROUP = ALL:VCD:ENB:VCD_VARIABLE
+    FORMAT = ulong,value
+    VCD_NAME = subframe_number_wakeup_l1s_ru1
+ID = VCD_VARIABLE_FRAME_NUMBER_WAKEUP_L1S_RU
+    DESC = VCD variable FRAME_NUMBER_WAKEUP_L1S_RU
+    GROUP = ALL:VCD:ENB:VCD_VARIABLE
+    FORMAT = ulong,value
+    VCD_NAME = frame_number_wakeup_l1s_ru
+ID = VCD_VARIABLE_FRAME_NUMBER_WAKEUP_L1S_RU1
+    DESC = VCD variable FRAME_NUMBER_WAKEUP_L1S_RU1
+    GROUP = ALL:VCD:ENB:VCD_VARIABLE
+    FORMAT = ulong,value
+    VCD_NAME = frame_number_wakeup_l1s_ru1
+ID = VCD_VARIABLE_SUBFRAME_NUMBER_WAKEUP_RXTX_RX_RU
+    DESC = VCD variable SUBFRAME_NUMBER_WAKEUP_RXTX_RX_RU
+    GROUP = ALL:VCD:ENB:VCD_VARIABLE
+    FORMAT = ulong,value
+    VCD_NAME = subframe_number_wakeup_rxtx_rx_ru
+ID = VCD_VARIABLE_SUBFRAME_NUMBER_WAKEUP_RXTX_RX_RU1
+    DESC = VCD variable SUBFRAME_NUMBER_WAKEUP_RXTX_RX_RU1
+    GROUP = ALL:VCD:ENB:VCD_VARIABLE
+    FORMAT = ulong,value
+    VCD_NAME = subframe_number_wakeup_rxtx_rx_ru1
+ID = VCD_VARIABLE_FRAME_NUMBER_WAKEUP_RXTX_RX_RU
+    DESC = VCD variable FRAME_NUMBER_WAKEUP_RXTX_RX_RU
+    GROUP = ALL:VCD:ENB:VCD_VARIABLE
+    FORMAT = ulong,value
+    VCD_NAME = frame_number_wakeup_rxtx_rx_ru
+ID = VCD_VARIABLE_FRAME_NUMBER_WAKEUP_RXTX_RX_RU1
+    DESC = VCD variable FRAME_NUMBER_WAKEUP_RXTX_RX_RU1
+    GROUP = ALL:VCD:ENB:VCD_VARIABLE
+    FORMAT = ulong,value
+    VCD_NAME = frame_number_wakeup_rxtx_rx_ru1
+ID = VCD_VARIABLE_SUBFRAME_NUMBER_WAKEUP_RXTX_TX_RU
+    DESC = VCD variable SUBFRAME_NUMBER_WAKEUP_RXTX_TX_RU
+    GROUP = ALL:VCD:ENB:VCD_VARIABLE
+    FORMAT = ulong,value
+    VCD_NAME = subframe_number_wakeup_rxtx_tx_ru
+ID = VCD_VARIABLE_SUBFRAME_NUMBER_WAKEUP_RXTX_TX_RU1
+    DESC = VCD variable SUBFRAME_NUMBER_WAKEUP_RXTX_TX_RU1
+    GROUP = ALL:VCD:ENB:VCD_VARIABLE
+    FORMAT = ulong,value
+    VCD_NAME = subframe_number_wakeup_rxtx_tx_ru1
+ID = VCD_VARIABLE_FRAME_NUMBER_WAKEUP_RXTX_TX_RU
+    DESC = VCD variable FRAME_NUMBER_WAKEUP_RXTX_TX_RU
+    GROUP = ALL:VCD:ENB:VCD_VARIABLE
+    FORMAT = ulong,value
+    VCD_NAME = frame_number_wakeup_rxtx_tx_ru
+ID = VCD_VARIABLE_FRAME_NUMBER_WAKEUP_RXTX_TX_RU1
+    DESC = VCD variable FRAME_NUMBER_WAKEUP_RXTX_TX_RU1
+    GROUP = ALL:VCD:ENB:VCD_VARIABLE
+    FORMAT = ulong,value
+    VCD_NAME = frame_number_wakeup_rxtx_tx_ru1
 ID = VCD_VARIABLE_IC_ENB
     DESC = VCD variable IC_ENB
     GROUP = ALL:VCD:ENB:VCD_VARIABLE
@@ -2654,26 +2734,26 @@ ID = VCD_FUNCTION_TEST
     GROUP = ALL:VCD:ENB:VCD_FUNCTION
     FORMAT = int,value
     VCD_NAME = test
-ID = VCD_FUNCTION_SEND_IF4
-    DESC = VCD function SEND_IF4
+ID = VCD_FUNCTION_SEND_IF4_RU
+    DESC = VCD function SEND_IF4_RU
     GROUP = ALL:VCD:ENB:VCD_FUNCTION
     FORMAT = int,value
-    VCD_NAME = send_if4
+    VCD_NAME = send_if4_ru
 ID = VCD_FUNCTION_SEND_IF4_RU1
     DESC = VCD function SEND_IF4_RU1
     GROUP = ALL:VCD:ENB:VCD_FUNCTION
     FORMAT = int,value
-    VCD_NAME = send_if4_RU1
-ID = VCD_FUNCTION_RECV_IF4
-    DESC = VCD function RECV_IF4
+    VCD_NAME = send_if4_ru1
+ID = VCD_FUNCTION_RECV_IF4_RU
+    DESC = VCD function RECV_IF4_RU
     GROUP = ALL:VCD:ENB:VCD_FUNCTION
     FORMAT = int,value
-    VCD_NAME = recv_if4
+    VCD_NAME = recv_if4_ru
 ID = VCD_FUNCTION_RECV_IF4_RU1
     DESC = VCD function RECV_IF4_RU1
     GROUP = ALL:VCD:ENB:VCD_FUNCTION
     FORMAT = int,value
-    VCD_NAME = recv_if4_RU1
+    VCD_NAME = recv_if4_ru1
 ID = VCD_FUNCTION_SEND_IF5
     DESC = VCD function SEND_IF5
     GROUP = ALL:VCD:ENB:VCD_FUNCTION
diff --git a/openair1/PHY/LTE_TRANSPORT/if4_tools.c b/openair1/PHY/LTE_TRANSPORT/if4_tools.c
index 4037c51e43..494c3498c4 100644
--- a/openair1/PHY/LTE_TRANSPORT/if4_tools.c
+++ b/openair1/PHY/LTE_TRANSPORT/if4_tools.c
@@ -64,7 +64,7 @@ void send_IF4p5(RU_t *ru, int frame, int subframe, uint16_t packet_type) {
   eth_state_t *eth = (eth_state_t*) (ru->ifdevice.priv);
   int nsym = fp->symbols_per_tti;
   
-  if (ru->idx<=1) VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_SEND_IF4+ru->idx, 1 );   
+  if (ru->idx<=1) VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SEND_IF4_RU+ru->idx,1);   
 
   if (packet_type == IF4p5_PDLFFT) {
     LOG_D(PHY,"send DL_IF4p5: RU %d frame %d, subframe %d\n",ru->idx,frame,subframe);
@@ -266,7 +266,7 @@ void send_IF4p5(RU_t *ru, int frame, int subframe, uint16_t packet_type) {
     AssertFatal(1==0, "send_IF4p5 - Unknown packet_type %x", packet_type);     
   }
 
-  if (ru->idx<=1) VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_SEND_IF4+ru->idx, 0 );  
+  if (ru->idx<=1) VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_SEND_IF4_RU+ru->idx,0);  
   return;  		    
 }
 
@@ -285,7 +285,7 @@ void recv_IF4p5(RU_t *ru, int *frame, int *subframe, uint16_t *packet_type, uint
   int slotoffsetF=0, blockoffsetF=0; 
   eth_state_t *eth = (eth_state_t*) (ru->ifdevice.priv);
   int idx;
-  if (ru->idx<=1) VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_RECV_IF4+ru->idx, 1 );   
+  if (ru->idx<=1) VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RECV_IF4_RU+ru->idx,1);   
   
   if (ru->function == NGFI_RRU_IF4p5) {
     db_fulllength = (12*fp->N_RB_DL)*ru->nb_tx; 
@@ -420,7 +420,7 @@ void recv_IF4p5(RU_t *ru, int *frame, int *subframe, uint16_t *packet_type, uint
     AssertFatal(1==0, "recv_IF4p5 - Unknown packet_type %x", *packet_type);            
   }
 
-  if (ru->idx<=1) VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_RECV_IF4+ru->idx, 0 );     
+  if (ru->idx<=1) VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_RECV_IF4_RU+ru->idx,0);     
   return;   
 }
 
diff --git a/openair1/PHY/defs_eNB.h b/openair1/PHY/defs_eNB.h
index 5e239123fb..6287d60d1b 100644
--- a/openair1/PHY/defs_eNB.h
+++ b/openair1/PHY/defs_eNB.h
@@ -301,7 +301,8 @@ typedef enum {
   RU_READY  = 2,
   RU_RUN    = 3,
   RU_ERROR  = 4,
-  RU_SYNC   = 5
+  RU_SYNC   = 5,
+  RU_CHECK_SYNC = 6
 } rru_state_t;
 
 /// Some commamds to RRU. Not sure we should do it like this !
@@ -480,7 +481,8 @@ typedef enum {
   RRU_stop=5,
   RRU_sync_ok=6,
   RRU_frame_resynch=7,
-  RRU_MSG_max_num=8
+  RRU_MSG_max_num=8,
+  RRU_check_sync = 9
 } rru_config_msg_type_t;
 
 typedef struct RRU_CONFIG_msg_s {
diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c
index a456770124..17c497372c 100644
--- a/targets/RT/USER/lte-enb.c
+++ b/targets/RT/USER/lte-enb.c
@@ -641,6 +641,11 @@ int wakeup_rxtx(PHY_VARS_eNB *eNB,RU_t *ru) {
   
   pthread_mutex_unlock( &L1_proc->mutex);
 
+  VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_WAKEUP_RXTX_RX_RU+ru->idx, L1_proc->frame_rx);
+  VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_WAKEUP_RXTX_RX_RU+ru->idx, L1_proc->subframe_rx);
+  VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_WAKEUP_RXTX_TX_RU+ru->idx, L1_proc->frame_tx);
+  VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_WAKEUP_RXTX_TX_RU+ru->idx, L1_proc->subframe_tx);
+
   return(0);
 }
 
diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c
index 12179cc79c..ac53efbb80 100644
--- a/targets/RT/USER/lte-ru.c
+++ b/targets/RT/USER/lte-ru.c
@@ -158,14 +158,14 @@ static inline void fh_if4p5_south_out(RU_t *ru) {
   if (subframe_select(&ru->frame_parms,ru->proc.subframe_tx)!=SF_UL) {
     send_IF4p5(ru,ru->proc.frame_tx, ru->proc.subframe_tx, IF4p5_PDLFFT);
     ru->south_out_cnt++;
-    printf("south_out_cnt %d, frame %d, subframe %d\n",ru->south_out_cnt,ru->proc.frame_tx,ru->proc.subframe_tx);
+    LOG_I(PHY,"south_out_cnt %d, frame %d, subframe %d, RU %d\n",ru->south_out_cnt,ru->proc.frame_tx,ru->proc.subframe_tx,ru->idx);
   }
 /*if (ru == RC.ru[0] || ru == RC.ru[1]) {
     VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX0_RU+ru->idx, ru->proc.frame_tx );
     VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_TX0_RU+ru->idx, ru->proc.subframe_tx );
   }*/
-VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_IF4P5_SOUTH_OUT,ru->proc.frame_tx);
-VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_IF4P5_SOUTH_OUT,ru->proc.subframe_tx);
+VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_IF4P5_SOUTH_OUT_RU+ru->idx,ru->proc.frame_tx);
+VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_IF4P5_SOUTH_OUT_RU+ru->idx,ru->proc.subframe_tx);
 
 }
 
@@ -218,7 +218,7 @@ void fh_if4p5_south_in(RU_t *ru,int *frame,int *subframe) {
     symbol_mask_full = (1<<fp->ul_symbols_in_S_subframe)-1;   
   else     
     symbol_mask_full = (1<<fp->symbols_per_tti)-1; 
-  //printf("fh_if4p5_south_in: RU %d, frame %d, subframe %d, ru %d\n",ru->idx,*frame,*subframe,ru->idx);
+  LOG_D(PHY,"fh_if4p5_south_in: RU %d, frame %d, subframe %d, ru %d\n",ru->idx,*frame,*subframe,ru->idx);
   AssertFatal(proc->symbol_mask[*subframe]==0,"rx_fh_if4p5: proc->symbol_mask[%d] = %x\n",*subframe,proc->symbol_mask[*subframe]);
   do {
     recv_IF4p5(ru, &f, &sf, &packet_type, &symbol_number);
@@ -269,8 +269,8 @@ void fh_if4p5_south_in(RU_t *ru,int *frame,int *subframe) {
     
   }*/
 
-  VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_IF4P5_SOUTH_IN,f);
-  VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_IF4P5_SOUTH_IN,sf);
+  VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_IF4P5_SOUTH_IN_RU+ru->idx,f);
+  VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_IF4P5_SOUTH_IN_RU+ru->idx,sf);
 
   proc->symbol_mask[sf] = 0;  
   VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TS, proc->timestamp_rx&0xffffffff );
@@ -1151,9 +1151,10 @@ void wakeup_L1s(RU_t *ru) {
     sprintf(string,"Incoming RU %d",ru->idx);
     
     AssertFatal(0==pthread_mutex_lock(&proc->mutex_RU),"");
-    LOG_D(PHY,"Frame %d, Subframe %d: RU %d done (wait_cnt %d),RU_mask[%d] %x\n",
+    LOG_D(PHY,"wakeup_L1s: Frame %d, Subframe %d: RU %d done (wait_cnt %d),RU_mask[%d] %x\n",
           ru->proc.frame_rx,ru->proc.subframe_rx,ru->idx,ru->wait_cnt,ru->proc.subframe_rx,proc->RU_mask[ru->proc.subframe_rx]);
-    
+    VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_WAKEUP_L1S_RU+ru->idx, ru->proc.frame_rx);
+      VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_WAKEUP_L1S_RU+ru->idx, ru->proc.subframe_rx);
     clock_gettime(CLOCK_MONOTONIC,&ru->proc.t[ru->proc.subframe_rx]);
     
     if (proc->RU_mask[ru->proc.subframe_rx] == 0){
@@ -1167,7 +1168,8 @@ void wakeup_L1s(RU_t *ru) {
       if (ru == eNB->RU_list[i]) {
 //	AssertFatal((proc->RU_mask&(1<<i)) == 0, "eNB %d frame %d, subframe %d : previous information from RU %d (num_RU %d,mask %x) has not been served yet!\n",eNB->Mod_id,ru->proc.frame_rx,ru->proc.subframe_rx,ru->idx,eNB->num_RU,proc->RU_mask);
         proc->RU_mask[ru->proc.subframe_rx] |= (1<<i);
-      }else if (eNB->RU_list[i]->state == RU_SYNC){
+      }else if (eNB->RU_list[i]->state == RU_SYNC || 
+                (eNB->RU_list[i]->is_slave==1 && eNB->RU_list[i]->wait_cnt>0)){
       	proc->RU_mask[ru->proc.subframe_rx] |= (1<<i);
       }
 
@@ -1193,9 +1195,10 @@ void wakeup_L1s(RU_t *ru) {
       //stop_meas(&proc->ru_arrival_time);
       AssertFatal(t.tv_nsec < proc->t[ru->proc.subframe_rx].tv_nsec+5000000,
                   "Time difference for subframe %d (Frame %d) => %lu > 5ms, this is RU %d\n",
-                  ru->proc.subframe_rx, ru->proc.frame_rx,t.tv_nsec - proc->t[ru->proc.subframe_rx].tv_nsec, ru->idx);
+                  ru->proc.subframe_rx, ru->proc.frame_rx, t.tv_nsec - proc->t[ru->proc.subframe_rx].tv_nsec, ru->idx);
     
-
+     // VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_WAKEUP_L1S_RU+ru->idx, ru->proc.frame_rx);
+      //VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_WAKEUP_L1S_RU+ru->idx, ru->proc.subframe_rx);
       AssertFatal(0==pthread_mutex_unlock(&proc->mutex_RU),"");
 
       // unlock RUs that are waiting for eNB processing to be completed
@@ -1509,7 +1512,7 @@ static void* ru_thread_tx( void* param ) {
     LOG_D(PHY,"ru_thread_tx (ru %d): Waiting for TX processing\n",ru->idx);
     // wait until eNBs are finished subframe RX n and TX n+4
     wait_on_condition(&proc->mutex_eNBs,&proc->cond_eNBs,&proc->instance_cnt_eNBs,"ru_thread_tx");
-    LOG_I(PHY,"ru_thread_tx (ru %d): Woken from condition\n",ru->idx);
+    LOG_D(PHY,"ru_thread_tx (ru %d): Woken from condition\n",ru->idx);
     if (oai_exit) break;
     //printf("~~~~~~~~~~~~~~~~~~~~~~~~~~~~ru_thread_tx is waken up %d.%d having L1 %d\n", proc->frame_tx, proc->subframe_tx, ru->num_eNB);
   	       
@@ -1547,17 +1550,17 @@ static void* ru_thread_tx( void* param ) {
         }
       }
       if (eNB_proc->RU_mask_tx != (1<<eNB->num_RU)-1) {  // not all RUs have provided their information so return
-      	printf("Not all RUs have provided their info (mask = %d)\n", eNB_proc->RU_mask_tx);
+      	LOG_I(PHY,"Not all RUs have provided their info (mask = %d)\n", eNB_proc->RU_mask_tx);
         pthread_mutex_unlock(&eNB_proc->mutex_RU_tx);
       }
       else { // all RUs TX are finished so send the ready signal to eNB processing
-      	printf("All RUs TX are finished. Ready to send wakeup signal to eNB processing\n");
+      	LOG_I(PHY,"All RUs TX are finished. Ready to send wakeup signal to eNB processing\n");
         eNB_proc->RU_mask_tx = 0;
         pthread_mutex_unlock(&eNB_proc->mutex_RU_tx);
 
         pthread_mutex_lock( &L1_proc->mutex_RUs);
         L1_proc->instance_cnt_RUs = 0;
-        printf("ru_thread_tx send signal to L1_thread_tx with (mask = %d)\n", eNB_proc->RU_mask_tx);
+        LOG_I(PHY,"ru_thread_tx send signal to L1_thread_tx with (mask = %d)\n", eNB_proc->RU_mask_tx);
         // the thread can now be woken up
         if (pthread_cond_signal(&L1_proc->cond_RUs) != 0) {
           LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB TXnp4 thread\n");
@@ -1754,7 +1757,7 @@ if(!emulate_rf){
 
         ru->wait_cnt--;
 
-        LOG_D(PHY,"RU thread %d, frame %d, subframe %d, wait_cnt %d \n",ru->idx, frame, subframe, ru->wait_cnt);
+        LOG_I(PHY,"RU thread %d, frame %d, subframe %d, wait_cnt %d \n",ru->idx, frame, subframe, ru->wait_cnt);
 
         if (ru->if_south!=LOCAL_RF && ru->wait_cnt <=20 && subframe == 5 && frame != RC.ru[0]->proc.frame_rx && resynch_done == 0) {
         // Send RRU_frame adjust
@@ -1767,7 +1770,6 @@ if(!emulate_rf){
           AssertFatal((ru->ifdevice.trx_ctlsend_func(&ru->ifdevice,&rru_config_msg,rru_config_msg.len)!=-1),"Failed to send msg to RAU\n");
           resynch_done=1;
         }
-      
         wakeup_L1s(ru);
       }
       else {
@@ -1828,7 +1830,6 @@ if(!emulate_rf){
 	  exit_fun("error unlocking mutex_pre_scd");
 	}
 #endif
-
     // wakeup all eNB processes waiting for this RU
     if (ru->num_eNB>0) wakeup_L1s(ru);
     
diff --git a/targets/RT/USER/ru_control.c b/targets/RT/USER/ru_control.c
index af837c9dff..ca2526cbf1 100644
--- a/targets/RT/USER/ru_control.c
+++ b/targets/RT/USER/ru_control.c
@@ -705,7 +705,7 @@ void* ru_thread_control( void* param ) {
 	      if (ru->if_south == LOCAL_RF) LOG_E(PHY,"Received RRU_config_ok msg...Ignoring\n");
 	      else{
 		if (ru->is_slave == 1){
-                  LOG_I(PHY,"Received RRU_sync_ok from RRU %d\n",ru->idx);
+                  printf(PHY,"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Received RRU_sync_ok from RRU %d\n",ru->idx);
 		  // Just change the state of the RRU to unblock ru_thread()
 		  ru->state = RU_RUN;		
 		}else LOG_E(PHY,"Received RRU_sync_ok from a master RRU...Ignoring\n"); 	
-- 
GitLab