From 64db7233b9af2207eefadb557cdd0b6d33a191dc Mon Sep 17 00:00:00 2001
From: Guy De Souza <desouza@eurecom.fr>
Date: Thu, 12 Apr 2018 17:04:47 +0200
Subject: [PATCH] NR parms fix

---
 openair1/PHY/INIT/defs.h       |  2 ++
 openair1/PHY/INIT/nr_init.c    |  4 ++--
 openair1/PHY/INIT/nr_parms.c   |  8 ++++----
 targets/RT/USER/nr-gnb.c       |  5 -----
 targets/RT/USER/nr-ru.c        |  9 +++------
 targets/RT/USER/nr-softmodem.c | 16 ++++++++--------
 6 files changed, 19 insertions(+), 25 deletions(-)

diff --git a/openair1/PHY/INIT/defs.h b/openair1/PHY/INIT/defs.h
index 2222b2900c..e2f00e3f77 100644
--- a/openair1/PHY/INIT/defs.h
+++ b/openair1/PHY/INIT/defs.h
@@ -372,6 +372,8 @@ void phy_config_request(PHY_Config_t *phy_config);
 
 int init_frame_parms(LTE_DL_FRAME_PARMS *frame_parms,uint8_t osf);
 void dump_frame_parms(LTE_DL_FRAME_PARMS *frame_parms);
+int nr_init_frame_parms(nfapi_config_request_t* config,
+                        NR_DL_FRAME_PARMS *frame_parms);
 void nr_phy_config_request(PHY_VARS_gNB *gNB);
 
 /** @} */
diff --git a/openair1/PHY/INIT/nr_init.c b/openair1/PHY/INIT/nr_init.c
index 1e3ea47610..f0bee5db85 100644
--- a/openair1/PHY/INIT/nr_init.c
+++ b/openair1/PHY/INIT/nr_init.c
@@ -339,7 +339,7 @@ void nr_phy_config_request(PHY_VARS_gNB *gNB)
 
   //overwrite for new NR parameters
   gNB_config->subframe_config.numerology_index_mu.value = 1;
-  gNB_config->subframe_config.duplex_mode.value = FDD;
+  gNB_config->subframe_config.duplex_mode.value = 1;//FDD
   gNB_config->rf_config.dl_channel_bandwidth.value = 106;
   gNB_config->rf_config.ul_channel_bandwidth.value = 106;
   gNB_config->sch_config.half_frame_index = 0;
@@ -350,7 +350,7 @@ void nr_phy_config_request(PHY_VARS_gNB *gNB)
 
   fp->threequarter_fs                    = 0;
 
-  nr_init_frame_parms(fp,1);
+  nr_init_frame_parms(gNB_config, fp);
 
   gNB->configured                                   = 1;
   LOG_I(PHY,"gNB configured\n");
diff --git a/openair1/PHY/INIT/nr_parms.c b/openair1/PHY/INIT/nr_parms.c
index 3e80266abd..90a027884b 100644
--- a/openair1/PHY/INIT/nr_parms.c
+++ b/openair1/PHY/INIT/nr_parms.c
@@ -26,13 +26,13 @@
 uint32_t nr_subcarrier_spacing[MAX_NUM_SUBCARRIER_SPACING] = {15e3, 30e3, 60e3, 120e3, 240e3};
 uint16_t nr_slots_per_subframe[MAX_NUM_SUBCARRIER_SPACING] = {1, 2, 4, 16, 32};
 
-int nr_init_frame_parms(nfapi_config_request_t config,
+int nr_init_frame_parms(nfapi_config_request_t* config,
                         NR_DL_FRAME_PARMS *frame_parms)
 {
 
-  int N_RB = config.rf_config.dl_channel_bandwidth.value;
-  int Ncp = config.subframe_config.dl_cyclic_prefix_type.value;
-  int mu = config.subframe_config.numerology_index_mu.value;
+  int N_RB = config->rf_config.dl_channel_bandwidth.value;
+  int Ncp = config->subframe_config.dl_cyclic_prefix_type.value;
+  int mu = config->subframe_config.numerology_index_mu.value;
 
 #if DISABLE_LOG_X
   printf("Initializing frame parms for mu %d, N_RB %d, Ncp %d\n",mu, N_RB, Ncp);
diff --git a/targets/RT/USER/nr-gnb.c b/targets/RT/USER/nr-gnb.c
index ab10f99b20..18ec84b5e9 100644
--- a/targets/RT/USER/nr-gnb.c
+++ b/targets/RT/USER/nr-gnb.c
@@ -923,11 +923,6 @@ void init_gNB(int single_thread_flag,int wait_for_sync) {
       LOG_I(PHY,"Initializing gNB %d CC_id %d\n",inst,CC_id);
 #endif
 
-/*
-      gNB->td                   = ulsch_decoding_data;//(single_thread_flag==1) ? ulsch_decoding_data_2thread : ulsch_decoding_data;
-      gNB->te                   = dlsch_encoding;//(single_thread_flag==1) ? dlsch_encoding_2threads : dlsch_encoding;*/
-
-      
       LOG_I(PHY,"Registering with MAC interface module\n");
       AssertFatal((gNB->if_inst         = IF_Module_init(inst))!=NULL,"Cannot register interface");
       gNB->if_inst->schedule_response   = schedule_response;
diff --git a/targets/RT/USER/nr-ru.c b/targets/RT/USER/nr-ru.c
index 1b8eeb7b90..7ca19908ef 100644
--- a/targets/RT/USER/nr-ru.c
+++ b/targets/RT/USER/nr-ru.c
@@ -1373,10 +1373,9 @@ static void* ru_thread( void* param ) {
     else ret = attach_rru(ru);
     AssertFatal(ret==0,"Cannot connect to radio\n");
   }
-  if (ru->if_south == LOCAL_RF) { // configure RF parameters only 
+  if (ru->if_south == LOCAL_RF) { // configure RF parameters only
     fill_rf_config(ru,ru->rf_config_file);
-    nr_phy_config_request(ru->gNB_list[0]);
-    nr_init_frame_parms(ru->gNB_list[0]->gNB_config, fp);
+    nr_init_frame_parms(&ru->gNB_list[0]->gNB_config, fp);
     nr_dump_frame_parms(fp);
     nr_phy_init_RU(ru);
 
@@ -1901,10 +1900,8 @@ void configure_rru(int idx,
     ru->nr_frame_parms.prach_config_common.prach_ConfigInfo.prach_ConfigIndex = config->prach_ConfigIndex[0]; */
 
   }
-
   fill_rf_config(ru,ru->rf_config_file);
-  nr_phy_config_request(ru->gNB_list[0]);
-  nr_init_frame_parms(ru->gNB_list[0]->gNB_config, &ru->nr_frame_parms);
+  nr_init_frame_parms(&ru->gNB_list[0]->gNB_config, &ru->nr_frame_parms);
 
   nr_phy_init_RU(ru);
 
diff --git a/targets/RT/USER/nr-softmodem.c b/targets/RT/USER/nr-softmodem.c
index d7c1ef000f..4f230c2910 100644
--- a/targets/RT/USER/nr-softmodem.c
+++ b/targets/RT/USER/nr-softmodem.c
@@ -118,14 +118,14 @@ unsigned short config_frames[4] = {2,9,11,13};
 #ifdef XFORMS
 // current status is that every UE has a DL scope for a SINGLE eNB (gnb_id=0)
 // at eNB 0, an UL scope for every UE
-/*
+
 FD_lte_phy_scope_ue  *form_ue[NUMBER_OF_UE_MAX];
 FD_lte_phy_scope_enb *form_enb[MAX_NUM_CCs][NUMBER_OF_UE_MAX];
 FD_stats_form                  *form_stats=NULL,*form_stats_l2=NULL;
 char title[255];
 unsigned char                   scope_enb_num_ue = 2;
 static pthread_t                forms_thread; //xforms
-*/
+
 #endif //XFORMS
 
 pthread_cond_t nfapi_sync_cond;
@@ -388,7 +388,7 @@ void reset_stats(FL_OBJECT *button, long arg)
     }
   }
 }
-/*
+
 static void *scope_thread(void *arg) {
  
 # ifdef ENABLE_XFORMS_WRITE_STATS
@@ -438,7 +438,7 @@ static void *scope_thread(void *arg) {
 # endif
 
   pthread_exit((void*)arg);
-}*/
+}
 #endif
 
 
@@ -831,7 +831,7 @@ int stop_L1L2(module_id_t gnb_id)
 }
 
 /*
- * Restart the lte-softmodem after it has been soft-stopped with stop_L1L2()
+ * Restart the nr-softmodem after it has been soft-stopped with stop_L1L2()
  */
 int restart_L1L2(module_id_t gnb_id)
 {
@@ -851,7 +851,7 @@ int restart_L1L2(module_id_t gnb_id)
   RC.ru_mask |= (1 << ru->idx);
   /* copy the changed frame parameters to the RU */
   /* TODO this should be done for all RUs associated to this gNB */
-  memcpy(&ru->frame_parms, &RC.gNB[gnb_id][0]->frame_parms, sizeof(NR_DL_FRAME_PARMS));
+  memcpy(&ru->nr_frame_parms, &RC.gNB[gnb_id][0]->frame_parms, sizeof(NR_DL_FRAME_PARMS));
   set_function_spec_param(RC.ru[gnb_id]);
 
   LOG_I(ENB_APP, "attempting to create ITTI tasks\n");
@@ -1096,7 +1096,7 @@ int main( int argc, char **argv )
   pthread_mutex_init(&sync_mutex, NULL);
   
 #ifdef XFORMS
-/*
+
   int UE_id;
   
   printf("XFORMS\n");
@@ -1132,7 +1132,7 @@ int main( int argc, char **argv )
     
     printf("Scope thread created, ret=%d\n",ret);
   }
-*/  
+  
 #endif
   
   rt_sleep_ns(10*100000000ULL);
-- 
GitLab