From 41f864ef0936400a3fb4b6d54731bc89d33f3267 Mon Sep 17 00:00:00 2001
From: Raymond Knopp <raymond.knopp@eurecom.fr>
Date: Fri, 11 Aug 2017 17:43:42 +0200
Subject: [PATCH] modicaitions for rru, initial configuration exchage

---
 openair1/PHY/defs.h                           |  3 +++
 openair2/ENB_APP/enb_config.c                 | 27 ++++++++++++++++---
 .../GENERIC-LTE-EPC/CONF/rru.oaisim.conf      |  6 ++---
 targets/RT/USER/lte-ru.c                      | 16 +++++++++--
 4 files changed, 44 insertions(+), 8 deletions(-)

diff --git a/openair1/PHY/defs.h b/openair1/PHY/defs.h
index 22df648149..cea49525c1 100644
--- a/openair1/PHY/defs.h
+++ b/openair1/PHY/defs.h
@@ -619,6 +619,8 @@ typedef enum {
 typedef struct RU_t_s{
   /// index of this ru
   uint32_t idx;
+ /// Pointer to configuration file
+  char *rf_config_file;
   /// southbound interface
   RU_if_south_t if_south;
   /// timing
@@ -1423,6 +1425,7 @@ typedef struct RRU_capabilities_s {
 } RRU_capabilities_t;
 
 typedef struct RRU_config_s {
+
   /// Fronthaul format
   RU_if_south_t FH_fmt;
   /// number of EUTRA bands (<=4) configured in RRU
diff --git a/openair2/ENB_APP/enb_config.c b/openair2/ENB_APP/enb_config.c
index e278a64de2..07a979aff7 100644
--- a/openair2/ENB_APP/enb_config.c
+++ b/openair2/ENB_APP/enb_config.c
@@ -463,6 +463,8 @@ void RCconfig_RU() {
   int               num_eNB4RU                    = 0;
   libconfig_int     eNB_list[256];
   int               fronthaul_flag                = CONFIG_TRUE;
+  /// TRUE for eNB or RRU, FALSE for RAU
+  int		    local_rf_flag		  = CONFIG_TRUE;
 
   load_config_file(&cfg);
 
@@ -488,10 +490,29 @@ void RCconfig_RU() {
 	      )
 	    ) {
 	fronthaul_flag = CONFIG_FALSE;
+      }
+
+      if (  !(
+              config_setting_lookup_string(setting_ru, CONFIG_STRING_RU_LOCAL_RF,(const char **)&local_rf)
+              )
+            ) {
+        local_rf_flag = CONFIG_FALSE;
       }			  
       
-      if (fronthaul_flag != CONFIG_TRUE) { // no fronthaul
+      if (local_rf_flag == CONFIG_TRUE) { // eNB or RRU
 	
+
+	if (  !(
+                config_setting_lookup_int(setting_ru, CONFIG_STRING_RU_MAX_RS_EPRE, &max_pdschReferenceSignalPower)
+               )
+              ) {
+          AssertFatal (0,
+                       "Failed to parse configuration file %s, RU %d config !\n",
+                       RC.config_file_name, j);
+          continue;
+        }
+
+
 	AssertFatal((setting_band = config_setting_get_member(setting_ru, CONFIG_STRING_RU_BAND_LIST))!=NULL,"No allowable LTE bands\n");
 	
 	if (setting_band != NULL) num_bands    = config_setting_length(setting_band);
@@ -503,7 +524,8 @@ void RCconfig_RU() {
 	  printf("RU %d: band %d\n",j,band[i]);
 	}
       } // fronthaul_flag == CONFIG_FALSE
-      else { // fronthaul_flag == CONFIG_TRUE
+      
+      if (fronthaul_flag == CONFIG_TRUE) { // fronthaul_flag == CONFIG_TRUE
 	if (  !(
 		config_setting_lookup_string(setting_ru, CONFIG_STRING_RU_LOCAL_ADDRESS,        (const char **)&ipv4)
 	 	&& config_setting_lookup_string(setting_ru, CONFIG_STRING_RU_REMOTE_ADDRESS,       (const char **)&ipv4_remote)
@@ -542,7 +564,6 @@ void RCconfig_RU() {
       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)
-		    && config_setting_lookup_string(setting_ru, CONFIG_STRING_RU_LOCAL_RF,(const char **)&local_rf)
 		    )) {
 	AssertFatal (0,
 	  "Failed to parse configuration file %s, RU %d config !\n",
diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.oaisim.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.oaisim.conf
index 9d966fe315..99d128587a 100644
--- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.oaisim.conf
+++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.oaisim.conf
@@ -1,8 +1,8 @@
 RUs = (
     {		  
-      	local_if_name                    = "lo";			  
-      	remote_address                   = "127.0.0.2";
-    	local_address                    = "127.0.0.1"; 
+      	local_if_name                    = "enp1s0";			  
+      	remote_address                   = "192.168.117.113";
+    	local_address                    = "192.168.117.205"; 
     	local_portc                       = 50000;	     
     	remote_portc                      = 50000;
     	local_portd                       = 50001;	     
diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c
index 98a673ade6..7519b34e86 100644
--- a/targets/RT/USER/lte-ru.c
+++ b/targets/RT/USER/lte-ru.c
@@ -1210,6 +1210,17 @@ static void* ru_thread( void* param ) {
     else ret = attach_rru(ru);
     AssertFatal(ret==0,"Cannot connect to radio\n");
   }
+//      if (ru->function == eNodeB_3GPP) { // configure RF parameters only for 3GPP eNodeB, we need to get them from RAU otherwise
+        fill_rf_config(ru,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) {
+        printf("Exiting, cannot initialize RU Buffers\n");
+        exit(-1);
+      }
 
   LOG_I(PHY, "Signaling main thread that RU %d is ready\n",ru->idx);
   pthread_mutex_lock(&RC.ru_mutex);
@@ -1829,6 +1840,7 @@ void init_RU(const char *rf_config_file) {
 
   for (ru_id=0;ru_id<RC.nb_RU;ru_id++) {
     ru               = RC.ru[ru_id];
+    ru->rf_config_file = rf_config_file;
     ru->idx          = ru_id;              
     ru->ts_offset    = 0;
     // use eNB_list[0] as a reference for RU frame parameters
@@ -1911,7 +1923,7 @@ 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);
-
+/*
       if (ru->function == eNodeB_3GPP) { // configure RF parameters only for 3GPP eNodeB, we need to get them from RAU otherwise
 	fill_rf_config(ru,rf_config_file);      
 	init_frame_parms(&ru->frame_parms,1);
@@ -1922,7 +1934,7 @@ void init_RU(const char *rf_config_file) {
       if (setup_RU_buffers(ru)!=0) {
 	printf("Exiting, cannot initialize RU Buffers\n");
 	exit(-1);
-      }
+      }*/
       break;
 
     case REMOTE_IF5: // the remote unit is IF5 RRU
-- 
GitLab