From 5b1260a759809b1f08f22fcaa0f6ee11001ee913 Mon Sep 17 00:00:00 2001
From: Wang Tsu-Han <wangts@eurecom.fr>
Date: Thu, 13 Sep 2018 15:02:15 +0200
Subject: [PATCH] fixed for phy-simulation mode

---
 openair1/PHY/LTE_TRANSPORT/dlsch_coding.c   |  2 +-
 openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c |  2 +-
 openair1/SIMULATION/LTE_PHY/dlsim.c         | 18 +++++++++++++++++-
 openair1/SIMULATION/LTE_PHY/ulsim.c         | 18 +++++++++++++++++-
 targets/RT/USER/lte-enb.c                   | 14 +++++++-------
 targets/RT/USER/lte-ru.c                    | 12 ++++++------
 targets/RT/USER/lte-softmodem.c             |  2 +-
 targets/RT/USER/lte-softmodem.h             |  2 +-
 targets/RT/USER/lte-uesoftmodem.c           |  2 +-
 9 files changed, 52 insertions(+), 20 deletions(-)

diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c
index 1c3aa48ed3..ded0905388 100644
--- a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c
+++ b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c
@@ -57,7 +57,7 @@
 		     uint64_t runtime,
 		     uint64_t deadline,
 		     uint64_t period);*/
-extern uint8_t get_thread_worker_conf(void);
+extern WORKER_CONF_t get_thread_worker_conf(void);
 
 
 void free_eNB_dlsch(LTE_eNB_DLSCH_t *dlsch)
diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c
index 3948b5e018..046e456916 100644
--- a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c
+++ b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c
@@ -45,7 +45,7 @@
 #include "targets/RT/USER/rt_wrapper.h"
 #include "transport_proto.h"
 
-extern uint8_t get_thread_worker_conf(void);
+extern WORKER_CONF_t get_thread_worker_conf(void);
 
 void free_eNB_ulsch(LTE_eNB_ULSCH_t *ulsch)
 {
diff --git a/openair1/SIMULATION/LTE_PHY/dlsim.c b/openair1/SIMULATION/LTE_PHY/dlsim.c
index a03ce34bca..fd649ec0e4 100644
--- a/openair1/SIMULATION/LTE_PHY/dlsim.c
+++ b/openair1/SIMULATION/LTE_PHY/dlsim.c
@@ -82,7 +82,23 @@ double t_rx_min = 1000000000; /*!< \brief initial min process time for rx */
 int n_tx_dropped = 0; /*!< \brief initial max process time for tx */
 int n_rx_dropped = 0; /*!< \brief initial max process time for rx */
 
-int codingw = 0;
+static THREAD_STRUCT thread_struct;
+void set_parallel_conf(int parallel_conf)
+{
+   thread_struct.parallel_conf = (PARALLEL_CONF_t)parallel_conf;
+} 
+void set_parallel_worker_conf(int worker_conf)
+{
+  thread_struct.worker_conf = (WORKER_CONF_t)worker_conf;
+} 
+PARALLEL_CONF_t get_thread_parallel_conf(void)
+{
+  return thread_struct.parallel_conf;
+} 
+WORKER_CONF_t get_thread_worker_conf(void)
+{
+  return thread_struct.worker_conf;
+} 
 
 int emulate_rf = 0;
 
diff --git a/openair1/SIMULATION/LTE_PHY/ulsim.c b/openair1/SIMULATION/LTE_PHY/ulsim.c
index 3fcb010685..826f185d2a 100644
--- a/openair1/SIMULATION/LTE_PHY/ulsim.c
+++ b/openair1/SIMULATION/LTE_PHY/ulsim.c
@@ -97,7 +97,23 @@ nfapi_tx_request_pdu_t tx_pdu_list[MAX_NUM_TX_REQUEST_PDU];
 nfapi_tx_request_t TX_req;
 Sched_Rsp_t sched_resp;
 
-int codingw = 0;
+static THREAD_STRUCT thread_struct;
+void set_parallel_conf(int parallel_conf)
+{
+   thread_struct.parallel_conf = (PARALLEL_CONF_t)parallel_conf;
+} 
+void set_parallel_worker_conf(int worker_conf)
+{
+  thread_struct.worker_conf = (WORKER_CONF_t)worker_conf;
+} 
+PARALLEL_CONF_t get_thread_parallel_conf(void)
+{
+  return thread_struct.parallel_conf;
+} 
+WORKER_CONF_t get_thread_worker_conf(void)
+{
+  return thread_struct.worker_conf;
+} 
 
 void
 fill_nfapi_ulsch_config_request(nfapi_ul_config_request_pdu_t *ul_config_pdu,
diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c
index b51495c43f..91a3c2e479 100644
--- a/targets/RT/USER/lte-enb.c
+++ b/targets/RT/USER/lte-enb.c
@@ -151,8 +151,8 @@ void wakeup_prach_eNB(PHY_VARS_eNB *eNB,RU_t *ru,int frame,int subframe);
 #if (RRC_VERSION >= MAKE_VERSION(14, 0, 0))
 void wakeup_prach_eNB_br(PHY_VARS_eNB *eNB,RU_t *ru,int frame,int subframe);
 #endif
-extern uint8_t get_thread_paralle_conf(void);
-extern uint8_t get_thread_worker_conf(void);
+extern PARALLEL_CONF_t get_thread_parallel_conf(void);
+extern WORKER_CONF_t   get_thread_worker_conf(void);
 
 extern uint8_t nfapi_mode;
 extern void oai_subframe_ind(uint16_t sfn, uint16_t sf);
@@ -224,7 +224,7 @@ static inline int rxtx(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, char *thread_nam
   }
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER , 1 );
 
-  if(get_thread_paralle_conf() == PARALLEL_RU_L1_TRX_SPLIT){
+  if(get_thread_parallel_conf() == PARALLEL_RU_L1_TRX_SPLIT){
     if(wait_on_condition(&proc[1].mutex_rxtx,&proc[1].cond_rxtx,&proc[1].pipe_ready,"wakeup_tx")<0) {
       LOG_E(PHY,"Frame %d, subframe %d: TX1 not ready\n",proc[1].frame_rx,proc[1].subframe_rx);
       return(-1);
@@ -246,7 +246,7 @@ static inline int rxtx(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, char *thread_nam
   /* CONFLICT RESOLUTION: BEGIN */
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER , 0 );
   if(oai_exit) return(-1);
-  if(get_thread_paralle_conf() == PARALLEL_SINGLE_THREAD){
+  if(get_thread_parallel_conf() == PARALLEL_SINGLE_THREAD){
 #ifndef PHY_TX_THREAD
     phy_procedures_eNB_TX(eNB, proc, 1);
 #endif
@@ -422,8 +422,8 @@ static void* eNB_thread_rxtx( void* param ) {
     }
     pthread_mutex_unlock( &proc->mutex_rxtx );
     if (nfapi_mode!=2){
-    	if(get_thread_paralle_conf() == PARALLEL_RU_L1_TRX_SPLIT)      wakeup_tx(eNB,eNB->proc.ru_proc);
-    	else if(get_thread_paralle_conf() == PARALLEL_RU_L1_SPLIT)
+    	if(get_thread_parallel_conf() == PARALLEL_RU_L1_TRX_SPLIT)      wakeup_tx(eNB,eNB->proc.ru_proc);
+    	else if(get_thread_parallel_conf() == PARALLEL_RU_L1_SPLIT)
     	{
     		phy_procedures_eNB_TX(eNB, proc, 1);
     		wakeup_txfh(proc,eNB->proc.ru_proc);
@@ -963,7 +963,7 @@ void init_eNB_proc(int inst) {
 
     LOG_I(PHY,"eNB->single_thread_flag:%d\n", eNB->single_thread_flag);
 
-    if ((get_thread_paralle_conf() == PARALLEL_RU_L1_SPLIT || get_thread_paralle_conf() == PARALLEL_RU_L1_TRX_SPLIT) && nfapi_mode!=2) {
+    if ((get_thread_parallel_conf() == PARALLEL_RU_L1_SPLIT || get_thread_parallel_conf() == PARALLEL_RU_L1_TRX_SPLIT) && nfapi_mode!=2) {
       pthread_create( &proc_rxtx[0].pthread_rxtx, attr0, eNB_thread_rxtx, proc );
       pthread_create( &proc_rxtx[1].pthread_rxtx, attr1, tx_thread, proc);
     }
diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c
index 39e482a81f..8ee2cb04f6 100644
--- a/targets/RT/USER/lte-ru.c
+++ b/targets/RT/USER/lte-ru.c
@@ -121,8 +121,8 @@ extern int emulate_rf;
 extern int numerology;
 extern clock_source_t clock_source;
 
-extern uint8_t get_thread_paralle_conf(void);
-extern uint8_t get_thread_worker_conf(void);
+extern PARALLEL_CONF_t get_thread_parallel_conf(void);
+extern WORKER_CONF_t   get_thread_worker_conf(void);
 extern void  phy_init_RU(RU_t*);
 extern void  phy_free_RU(RU_t*);
 
@@ -1257,7 +1257,7 @@ void wakeup_eNBs(RU_t *ru) {
   LOG_D(PHY,"wakeup_eNBs (num %d) for RU %d ru->eNB_top:%p\n",ru->num_eNB,ru->idx, ru->eNB_top);
 
 
-  if (ru->num_eNB==1 && ru->eNB_top!=0 && get_thread_paralle_conf() == PARALLEL_SINGLE_THREAD) {
+  if (ru->num_eNB==1 && ru->eNB_top!=0 && get_thread_parallel_conf() == PARALLEL_SINGLE_THREAD) {
     // call eNB function directly
   
     char string[20];
@@ -1782,7 +1782,7 @@ static void* ru_thread( void* param ) {
     if (ru->num_eNB>0) wakeup_eNBs(ru);
     
 #ifndef PHY_TX_THREAD
-    if(get_thread_paralle_conf() == PARALLEL_SINGLE_THREAD || ru->num_eNB==0){
+    if(get_thread_parallel_conf() == PARALLEL_SINGLE_THREAD || ru->num_eNB==0){
       // do TX front-end processing if needed (precoding and/or IDFTs)
       if (ru->feptx_prec) ru->feptx_prec(ru);
       
@@ -2195,7 +2195,7 @@ void init_RU_proc(RU_t *ru) {
   if(emulate_rf)
     pthread_create( &proc->pthread_emulateRF, attr_emulateRF, emulatedRF_thread, (void*)proc );
 
-  if (get_thread_paralle_conf() == PARALLEL_RU_L1_SPLIT || get_thread_paralle_conf() == PARALLEL_RU_L1_TRX_SPLIT)
+  if (get_thread_parallel_conf() == PARALLEL_RU_L1_SPLIT || get_thread_parallel_conf() == PARALLEL_RU_L1_TRX_SPLIT)
     pthread_create( &proc->pthread_FH1, attr_FH1, ru_thread_tx, (void*)ru );
 
   if (ru->function == NGFI_RRU_IF4p5) {
@@ -2309,7 +2309,7 @@ void kill_RU_proc(RU_t *ru)
 
   LOG_D(PHY, "Joining pthread_FH\n");
   pthread_join(proc->pthread_FH, NULL);
-  if (get_thread_paralle_conf() == PARALLEL_RU_L1_SPLIT || get_thread_paralle_conf() == PARALLEL_RU_L1_TRX_SPLIT) {
+  if (get_thread_parallel_conf() == PARALLEL_RU_L1_SPLIT || get_thread_parallel_conf() == PARALLEL_RU_L1_TRX_SPLIT) {
     LOG_D(PHY, "Joining pthread_FHTX\n");
     pthread_join(proc->pthread_FH1, NULL);
   }
diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c
index f935677124..b9458afa1e 100644
--- a/targets/RT/USER/lte-softmodem.c
+++ b/targets/RT/USER/lte-softmodem.c
@@ -229,7 +229,7 @@ void set_parallel_worker_conf(int worker_conf)
 {
   thread_struct.worker_conf = (WORKER_CONF_t)worker_conf;
 } 
-PARALLEL_CONF_t get_thread_paralle_conf(void)
+PARALLEL_CONF_t get_thread_parallel_conf(void)
 {
   return thread_struct.parallel_conf;
 } 
diff --git a/targets/RT/USER/lte-softmodem.h b/targets/RT/USER/lte-softmodem.h
index e3ffeaab10..7074172a03 100644
--- a/targets/RT/USER/lte-softmodem.h
+++ b/targets/RT/USER/lte-softmodem.h
@@ -276,7 +276,7 @@ PHY_VARS_UE* init_ue_vars(LTE_DL_FRAME_PARMS *frame_parms,
                           uint8_t abstraction_flag);
 void init_eNB_afterRU(void);
 void thread_structure_init(void);
-PARALLEL_CONF_t get_thread_paralle_conf(void);
+PARALLEL_CONF_t get_thread_parallel_conf(void);
 WORKER_CONF_t   get_thread_worker_conf(void);
 void set_parallel_conf(int parallel_conf);
 void set_parallel_worker_conf(int worker_conf);
diff --git a/targets/RT/USER/lte-uesoftmodem.c b/targets/RT/USER/lte-uesoftmodem.c
index d87e3e69b1..1613622567 100644
--- a/targets/RT/USER/lte-uesoftmodem.c
+++ b/targets/RT/USER/lte-uesoftmodem.c
@@ -230,7 +230,7 @@ void set_parallel_worker_conf(int worker_conf)
 {
   thread_struct.worker_conf = (WORKER_CONF_t)worker_conf;
 } 
-PARALLEL_CONF_t get_thread_paralle_conf(void)
+PARALLEL_CONF_t get_thread_parallel_conf(void)
 {
   return thread_struct.parallel_conf;
 } 
-- 
GitLab