From 72ff627a12a324941a890777d8958f41526254a2 Mon Sep 17 00:00:00 2001
From: Navid Nikaein <navid.nikaein@eurecom.fr>
Date: Tue, 12 Jan 2016 10:32:48 +0100
Subject: [PATCH] add eNB configuration parameters for the fronthaul

---
 openair2/ENB_APP/enb_config.c   |  73 +++++++++++
 openair2/ENB_APP/enb_config.h   |  18 +++
 targets/RT/USER/lte-softmodem.c | 206 ++++++++++----------------------
 3 files changed, 156 insertions(+), 141 deletions(-)

diff --git a/openair2/ENB_APP/enb_config.c b/openair2/ENB_APP/enb_config.c
index 07e0ffa640..0fd5dbe0e8 100755
--- a/openair2/ENB_APP/enb_config.c
+++ b/openair2/ENB_APP/enb_config.c
@@ -170,6 +170,14 @@
 #define ENB_CONFIG_STRING_ENB_IPV4_ADDR_FOR_S1U         "ENB_IPV4_ADDRESS_FOR_S1U"
 #define ENB_CONFIG_STRING_ENB_PORT_FOR_S1U              "ENB_PORT_FOR_S1U"
 
+#define ENB_CONFIG_STRING_RRH_GW_CONFIG                   "rrh_gw_config"
+#define ENB_CONFIG_STRING_RRH_GW_LOCAL_IF_NAME            "local_if_name"
+#define ENB_CONFIG_STRING_RRH_GW_LOCAL_ADDRESS            "local_address"
+#define ENB_CONFIG_STRING_RRH_GW_REMOTE_ADDRESS           "remote_address"
+#define ENB_CONFIG_STRING_RRH_GW_LOCAL_PORT               "local_port"
+#define ENB_CONFIG_STRING_RRH_GW_REMOTE_PORT              "remote_port"
+#define ENB_CONFIG_STRING_RRH_GW_ACTIVE                   "active"
+#define ENB_CONFIG_STRING_RRH_GW_PREFERENCE               "preference"
 
 #define ENB_CONFIG_STRING_ASN1_VERBOSITY                   "Asn1_verbosity"
 #define ENB_CONFIG_STRING_ASN1_VERBOSITY_NONE              "none"
@@ -274,6 +282,18 @@ static void enb_config_display(void)
     } else {
       printf( "\tMNC:                \t%02"PRIu16":\n",enb_properties.properties[i]->mnc);
     }
+    
+    for (j=0; j< enb_properties.properties[i]->nb_rrh_gw; j++) {
+      if (enb_properties.properties[i]->rrh_gw_config[j].active == 1 ){
+	printf( "\n\tRRH GW %d config for eNB %u:\n\n", j, i);
+	printf( "\tinterface name :       \t%s:\n",enb_properties.properties[i]->rrh_gw_if_name);
+	printf( "\tlocal address  :       \t%s:\n",enb_properties.properties[i]->rrh_gw_config[j].local_address);
+	printf( "\tlocal port     :       \t%d:\n",enb_properties.properties[i]->rrh_gw_config[j].local_port);
+	printf( "\tremote address :       \t%s:\n",enb_properties.properties[i]->rrh_gw_config[j].remote_address);
+	printf( "\tremote port    :       \t%d:\n",enb_properties.properties[i]->rrh_gw_config[j].remote_port);
+	printf( "\ttransport      :       \t%s Ethernet:\n\n",(enb_properties.properties[i]->rrh_gw_config[j].raw == 1)? "RAW" : "UDP");
+      }
+    }
 
     for (j=0; j< enb_properties.properties[i]->nb_cc; j++) {
       printf( "\teutra band for CC %d:         \t%"PRId16":\n",j,enb_properties.properties[i]->eutra_band[j]);
@@ -455,6 +475,8 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP)
   config_setting_t *setting_srb1                  = NULL;
   config_setting_t *setting_mme_addresses         = NULL;
   config_setting_t *setting_mme_address           = NULL;
+  config_setting_t *setting_rrh_gws               = NULL;
+  config_setting_t *setting_rrh_gw                = NULL;
   config_setting_t *setting_enb                   = NULL;
   config_setting_t *setting_otg                   = NULL;
   config_setting_t *subsetting_otg                   = NULL;
@@ -462,6 +484,7 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP)
   int               enb_properties_index          = 0;
   int               num_enbs                      = 0;
   int               num_mme_address               = 0;
+  int               num_rrh_gw                    = 0;
   int               num_otg_elements              =0;
   int               num_component_carriers        =0;
   int               i                             = 0;
@@ -558,10 +581,15 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP)
 
   libconfig_int     my_int;
 
+
+  char*             if_name                       = NULL;
   char*             ipv4                          = NULL;
+  char*             ipv4_remote                   = NULL;
   char*             ipv6                          = NULL;
   char*             active                        = NULL;
   char*             preference                    = NULL;
+  libconfig_int     local_port                    = 0;
+  libconfig_int     remote_port                   = 0;
   const char*       active_enb[MAX_ENB];
   char*             enb_interface_name_for_S1U    = NULL;
   char*             enb_ipv4_address_for_S1U      = NULL;
@@ -2136,6 +2164,51 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP)
               enb_properties.properties[enb_properties_index]->mme_ip_address[j].ipv6 = 1;
             }
           }
+	  // RRH Config 
+	  setting_rrh_gws = config_setting_get_member (setting_enb, ENB_CONFIG_STRING_RRH_GW_CONFIG);
+          num_rrh_gw     = config_setting_length(setting_rrh_gws);
+          enb_properties.properties[enb_properties_index]->nb_rrh_gw = 0;
+
+          for (j = 0; j < num_rrh_gw; j++) {
+            setting_rrh_gw = config_setting_get_elem(setting_rrh_gws, j);
+
+            if (  !(
+                   config_setting_lookup_string(setting_rrh_gw, ENB_CONFIG_STRING_RRH_GW_LOCAL_IF_NAME, (const char **)&if_name)
+		   && config_setting_lookup_string(setting_rrh_gw, ENB_CONFIG_STRING_RRH_GW_LOCAL_ADDRESS, (const char **)&ipv4)
+                   && config_setting_lookup_string(setting_rrh_gw, ENB_CONFIG_STRING_RRH_GW_REMOTE_ADDRESS , (const char **)&ipv4_remote)
+                   && config_setting_lookup_int(setting_rrh_gw, ENB_CONFIG_STRING_RRH_GW_LOCAL_PORT, &local_port)
+                   && config_setting_lookup_int(setting_rrh_gw, ENB_CONFIG_STRING_RRH_GW_REMOTE_PORT, &remote_port)
+                   && config_setting_lookup_string(setting_rrh_gw, ENB_CONFIG_STRING_RRH_GW_ACTIVE, (const char **)&active)
+                   && config_setting_lookup_string(setting_rrh_gw, ENB_CONFIG_STRING_RRH_GW_PREFERENCE, (const char **)&preference)
+                 )
+              ) {
+              AssertError (0, parse_errors ++,
+                           "Failed to parse eNB configuration file %s, %u th enb %u the RRH GW address !\n",
+                           lib_config_file_name_pP, i, j);
+              continue; // FIXME will prevent segfaults below, not sure what happens at function exit...
+            }
+
+            enb_properties.properties[enb_properties_index]->nb_rrh_gw += 1;
+
+	    enb_properties.properties[enb_properties_index]->rrh_gw_if_name = strdup(if_name);
+            enb_properties.properties[enb_properties_index]->rrh_gw_config[j].local_address  = strdup(ipv4);
+            enb_properties.properties[enb_properties_index]->rrh_gw_config[j].remote_address = strdup(ipv4_remote);
+	    enb_properties.properties[enb_properties_index]->rrh_gw_config[j].local_port= local_port;
+	    enb_properties.properties[enb_properties_index]->rrh_gw_config[j].remote_port= remote_port;
+
+            if (strcmp(active, "yes") == 0) {
+              enb_properties.properties[enb_properties_index]->rrh_gw_config[j].active = 1;
+            } 
+
+            if (strcmp(preference, "udp") == 0) {
+              enb_properties.properties[enb_properties_index]->rrh_gw_config[j].udp = 1;
+            } else if (strcmp(preference, "raw") == 0) {
+              enb_properties.properties[enb_properties_index]->rrh_gw_config[j].raw = 1;
+            } else {//if (strcmp(preference, "no") == 0) 
+              enb_properties.properties[enb_properties_index]->rrh_gw_config[j].udp = 1;
+              enb_properties.properties[enb_properties_index]->rrh_gw_config[j].raw = 1;
+            }
+          }
 
           // SCTP SETTING
           enb_properties.properties[enb_properties_index]->sctp_out_streams = SCTP_OUT_STREAMS;
diff --git a/openair2/ENB_APP/enb_config.h b/openair2/ENB_APP/enb_config.h
index 113681dafe..9c271ca4f4 100755
--- a/openair2/ENB_APP/enb_config.h
+++ b/openair2/ENB_APP/enb_config.h
@@ -78,6 +78,17 @@ typedef struct mme_ip_address_s {
   char     *ipv6_address;
 } mme_ip_address_t;
 
+typedef struct rrh_gw_config_s {
+  unsigned  udp:1;
+  unsigned  raw:1;
+  unsigned  active:1;
+  char     *local_address;
+  char     *remote_address;
+  uint16_t  local_port;
+  uint16_t  remote_port;
+
+} rrh_gw_config_t;
+
 typedef struct Enb_properties_s {
   /* Unique eNB_id to identify the eNB within EPC.
    * For macro eNB ids this field should be 20 bits long.
@@ -203,6 +214,13 @@ typedef struct Enb_properties_s {
   char               *enb_interface_name_for_S1_MME;
   in_addr_t           enb_ipv4_address_for_S1_MME;
 
+
+  /* Nb of RRH to connect to */
+  uint8_t             nb_rrh_gw;
+  char               *rrh_gw_if_name;
+  /* List of MME to connect to */
+  rrh_gw_config_t       rrh_gw_config[4];
+
   // otg config
   /* Nb of OTG elements */
   uint8_t            num_otg_elements;
diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c
index c67de21f56..1f51b21cf9 100644
--- a/targets/RT/USER/lte-softmodem.c
+++ b/targets/RT/USER/lte-softmodem.c
@@ -329,15 +329,7 @@ time_stats_t softmodem_stats_rx_sf[10]; // total rx time
 void reset_opp_meas(void);
 void print_opp_meas(void);
 int transmission_mode=1;
-/*
-   FT: not a very clean way of managing the rescale of iqs in rx path, but this is done in
-  openair1/PHY/MODULATION/ul_7_5_kHz.c which doesn't have access to config parameters
-  to re-worked later.....
-  RX_IQRESCALELEN is setup in device libraries for all non expressmimo targets and acessed as an
-  external variable in ul_7_5_kHz.c. For expressmimo it is a macro (openair1/PHY/defs.h) 
-  Regarding the value of this variable or macro: 18 is for 15 bits iqs, 15 is used for USRP, EXMIMO
-*/
-//int rxrescale; 
+
 
 int16_t           glog_level         = LOG_INFO;
 int16_t           glog_verbosity     = LOG_MED;
@@ -369,57 +361,16 @@ int16_t           osa_log_verbosity  = LOG_MED;
 
 
 #ifdef ETHERNET
+char rrh_eNB_ip[20] = "127.0.0.1";
+int rrh_eNB_port = 50000;
 char *rrh_UE_ip = "127.0.0.1";
 int rrh_UE_port = 51000;
 #endif
-/* flag given in runtime to specify if the RF head is local or remote (default option is local RF)*/
-uint8_t local_remote_RF = BBU_LOCAL_RF_ENABLED;
- 
+
 char uecap_xer[1024],uecap_xer_in=0;
 extern void *UE_thread(void *arg);
 extern void init_UE_threads(void);
 
-/*---------------------BMC: timespec helpers -----------------------------*/
-
-struct timespec min_diff_time = { .tv_sec = 0, .tv_nsec = 0 };
-struct timespec max_diff_time = { .tv_sec = 0, .tv_nsec = 0 };
-
-struct timespec clock_difftime(struct timespec start, struct timespec end)
-{
-    struct timespec temp;
-    if ((end.tv_nsec-start.tv_nsec)<0) {
-        temp.tv_sec = end.tv_sec-start.tv_sec-1;
-	temp.tv_nsec = 1000000000+end.tv_nsec-start.tv_nsec;
-    } else {
-        temp.tv_sec = end.tv_sec-start.tv_sec;
-	temp.tv_nsec = end.tv_nsec-start.tv_nsec;
-    }
-    return temp;
-}
-
-void print_difftimes()
-{
-#ifdef DEBUG
-    printf("difftimes min = %lu ns ; max = %lu ns\n", min_diff_time.tv_nsec, max_diff_time.tv_nsec);
-#else
-    LOG_I(HW,"difftimes min = %lu ns ; max = %lu ns\n", min_diff_time.tv_nsec, max_diff_time.tv_nsec);
-#endif
-}
-
-void update_difftimes(struct timespec start, struct timespec end)
-{
-    struct timespec diff_time = { .tv_sec = 0, .tv_nsec = 0 };
-    int             changed = 0;
-    diff_time = clock_difftime(start, end);
-    if ((min_diff_time.tv_nsec == 0) || (diff_time.tv_nsec < min_diff_time.tv_nsec)) { min_diff_time.tv_nsec = diff_time.tv_nsec; changed = 1; }
-    if ((max_diff_time.tv_nsec == 0) || (diff_time.tv_nsec > max_diff_time.tv_nsec)) { max_diff_time.tv_nsec = diff_time.tv_nsec; changed = 1; }
-#if 1
-    if (changed) print_difftimes();
-#endif
-}
-
-/*------------------------------------------------------------------------*/
-
 unsigned int build_rflocal(int txi, int txq, int rxi, int rxq)
 {
   return (txi + (txq<<6) + (rxi<<12) + (rxq<<18));
@@ -479,7 +430,7 @@ void help (void) {
   printf("  -h provides this help message!\n");
   printf("  -K Generate ITTI analyzser logs (similar to wireshark logs but with more details)\n");
   printf("  -m Set the maximum downlink MCS\n");
-  printf("  -M Specify whether RF head is local or remote,valid options: (1: local , 2:remote)  \n");
+  printf("  -M IP address of RRH\n");
   printf("  -O eNB configuration file (located in targets/PROJECTS/GENERIC-LTE-EPC/CONF\n");
   printf("  -q Enable processing timing measurement of lte softmodem on per subframe basis \n");
   printf("  -r Set the PRB, valid values: 6, 25, 50, 100  \n");    
@@ -996,12 +947,6 @@ void do_OFDM_mod_rt(int subframe,PHY_VARS_eNB *phy_vars_eNB)
         if (tx_offset>=(LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*phy_vars_eNB->lte_frame_parms.samples_per_tti))
           tx_offset -= LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*phy_vars_eNB->lte_frame_parms.samples_per_tti;
 
-    ((short*)&phy_vars_eNB->lte_eNB_common_vars.txdata[0][aa][tx_offset])[0] = ((short*)dummy_tx_b)[2*i]<<openair0_cfg[0].iq_txshift ;
-
-	((short*)&phy_vars_eNB->lte_eNB_common_vars.txdata[0][aa][tx_offset])[1] = ((short*)dummy_tx_b)[2*i+1]<<openair0_cfg[0].iq_txshift;
-
-
-/*
         ((short*)&phy_vars_eNB->lte_eNB_common_vars.txdata[0][aa][tx_offset])[0]=
 #ifdef EXMIMO
           ((short*)dummy_tx_b)[2*i]<<4;
@@ -1018,7 +963,6 @@ void do_OFDM_mod_rt(int subframe,PHY_VARS_eNB *phy_vars_eNB)
 #else
 	  ((short*)dummy_tx_b)[2*i+1]<<4;
 #endif
-*/
      }
      // if S-subframe switch to RX in second subframe
      if (subframe_select(&phy_vars_eNB->lte_frame_parms,subframe) == SF_S) {
@@ -1836,9 +1780,7 @@ static void* eNB_thread( void* arg )
 				     PHY_vars_eNB_g[0][0]->lte_frame_parms.nb_antennas_rx);
       
       stop_meas( &softmodem_stats_hw );
-      if (frame > 50) { 
-	  clock_gettime( CLOCK_MONOTONIC, &trx_time1 );
-      }
+      clock_gettime( CLOCK_MONOTONIC, &trx_time1 );
 
       if (frame > 20){ 
 	if (rxs != spp)
@@ -1847,6 +1789,8 @@ static void* eNB_thread( void* arg )
       VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ, 0 );
 
       // Transmit TX buffer based on timestamp from RX
+
+
     
       VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 1 );
       // prepare tx buffer pointers
@@ -1867,23 +1811,16 @@ static void* eNB_thread( void* arg )
       VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, (timestamp+(openair0_cfg[card].tx_delay*spp)-openair0_cfg[card].tx_forward_nsamps)&0xffffffff );
 
       stop_meas( &softmodem_stats_mt );
-      if (frame > 50) { 
-	  clock_gettime( CLOCK_MONOTONIC, &trx_time2 );
-	  // BMC: compute time between rx and tx
-	  update_difftimes(trx_time1, trx_time2);
-      }
-
+      clock_gettime( CLOCK_MONOTONIC, &trx_time2 );
 
       VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE,0);
 #else
       // USRP_DEBUG is active
       rt_sleep_ns(1000000);
 #endif
-/* FT configurable tx lauch delay (in slots )*/
+
       if ((tx_launched == 0) &&
-	   ((openair0_cfg[card].txlaunch_wait == 0) ||
-	    ((openair0_cfg[card].txlaunch_wait == 1) &&
-	     (rx_pos >= (((2*hw_subframe)+openair0_cfg[card].txlaunch_wait_slotcount)*PHY_vars_eNB_g[0][0]->lte_frame_parms.samples_per_tti>>1))))) { 
+          (rx_pos >= (((2*hw_subframe)+1)*PHY_vars_eNB_g[0][0]->lte_frame_parms.samples_per_tti>>1))) {
         tx_launched = 1;
 
         for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
@@ -2044,9 +1981,6 @@ eNB_thread_cleanup:
 #endif
 
   eNB_thread_status = 0;
-
-  print_difftimes();
-
   return &eNB_thread_status;
 }
 
@@ -2058,8 +1992,8 @@ static void get_options (int argc, char **argv)
   int c;
   //  char                          line[1000];
   //  int                           l;
-  int k,i;//,j,k;
-#if defined(OAI_USRP) || defined(CPRIGW) //#ifndef EXMIMO?
+  int k,i,j;//,j,k;
+#if defined(OAI_USRP) || defined(CPRIGW)
   int clock_src;
 #endif
   int CC_id;
@@ -2178,7 +2112,9 @@ static void get_options (int argc, char **argv)
      break;
 
     case 'M':
-      local_remote_RF=atoi(optarg);
+#ifdef ETHERNET
+      strcpy(rrh_eNB_ip,optarg);
+#endif
       break;
 
     case 'C':
@@ -2307,7 +2243,7 @@ static void get_options (int argc, char **argv)
       break;
 
     case 's':
-#if defined(OAI_USRP) || defined(CPRIGW) //#ifndef EXMIMO
+#if defined(OAI_USRP) || defined(CPRIGW)
 
       clock_src = atoi(optarg);
 
@@ -2406,6 +2342,21 @@ static void get_options (int argc, char **argv)
                    "lte-softmodem compiled with MAX_NUM_CCs=%d, but only %d CCs configured for eNB %d!",
                    MAX_NUM_CCs, enb_properties->properties[i]->nb_cc, i);
 
+      for (j=0; j<enb_properties->properties[i]->nb_rrh_gw; j++) {
+	 
+	if (enb_properties->properties[i]->rrh_gw_config[j].active == 1 ){
+	  // replace printf by setting
+	  printf( "\n\tRRH GW %d config for eNB %u:\n\n", j, i);
+	  printf( "\tinterface name :       \t%s:\n",enb_properties->properties[i]->rrh_gw_if_name);
+	  printf( "\tlocal address  :       \t%s:\n",enb_properties->properties[i]->rrh_gw_config[j].local_address);
+	  printf( "\tlocal port     :       \t%d:\n",enb_properties->properties[i]->rrh_gw_config[j].local_port);
+	  printf( "\tremote address :       \t%s:\n",enb_properties->properties[i]->rrh_gw_config[j].remote_address);
+	  printf( "\tremote port    :       \t%d:\n",enb_properties->properties[i]->rrh_gw_config[j].remote_port);
+	  printf( "\ttransport      :       \t%s Ethernet:\n\n",(enb_properties->properties[i]->rrh_gw_config[j].raw == 1)? "RAW" : "UDP");
+	}
+	
+      }
+
       for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
         frame_parms[CC_id]->frame_type =       enb_properties->properties[i]->frame_type[CC_id];
         frame_parms[CC_id]->tdd_config =       enb_properties->properties[i]->tdd_config[CC_id];
@@ -2910,11 +2861,6 @@ int main( int argc, char **argv )
 
   for (card=0; card<MAX_CARDS; card++) {
 
-#ifdef EXMIMO
-/* FT: for all other devices the iq_txshift value is setup in the device library */
-       openair0_cfg[card].iq_txshift=4;
-#endif
-
     if(frame_parms[0]->N_RB_DL == 100) {
       sample_rate = 30.72e6;
       bw          = 10.0e6;
@@ -2925,8 +2871,8 @@ int main( int argc, char **argv )
       openair0_cfg[card].tx_bw = 10e6;
       openair0_cfg[card].rx_bw = 10e6;
       // from usrp_time_offset
-      //openair0_cfg[card].tx_forward_nsamps = 175;
-      // openair0_cfg[card].tx_delay = 8;
+      openair0_cfg[card].tx_forward_nsamps = 175;
+      openair0_cfg[card].tx_delay = 8;
 #endif
     } else if(frame_parms[0]->N_RB_DL == 50) {
       sample_rate = 15.36e6;
@@ -2937,8 +2883,8 @@ int main( int argc, char **argv )
       openair0_cfg[card].samples_per_frame = 153600;
       openair0_cfg[card].tx_bw = 5e6;
       openair0_cfg[card].rx_bw = 5e6;
-      //openair0_cfg[card].tx_forward_nsamps = 95;
-      //openair0_cfg[card].tx_delay = 5;
+      openair0_cfg[card].tx_forward_nsamps = 95;
+      openair0_cfg[card].tx_delay = 5;
 #endif
     } else if (frame_parms[0]->N_RB_DL == 25) {
       sample_rate = 7.68e6;
@@ -2950,14 +2896,12 @@ int main( int argc, char **argv )
       openair0_cfg[card].rx_bw = 2.5e6;
       openair0_cfg[card].samples_per_packet = 1024;
 #ifdef OAI_USRP
-
-      // openair0_cfg[card].tx_forward_nsamps = 70;
-      //openair0_cfg[card].tx_delay = 5;
-#endif
-      //#elif OAI_BLADERF
-      //openair0_cfg[card].tx_forward_nsamps = 0;
-      //openair0_cfg[card].tx_delay = 8;
-      //#endif 
+    openair0_cfg[card].tx_forward_nsamps = 70;
+    openair0_cfg[card].tx_delay = 5;
+#elif OAI_BLADERF
+      openair0_cfg[card].tx_forward_nsamps = 0;
+      openair0_cfg[card].tx_delay = 8;
+#endif 
 #endif
     } else if (frame_parms[0]->N_RB_DL == 6) {
       sample_rate = 1.92e6;
@@ -2968,26 +2912,16 @@ int main( int argc, char **argv )
       openair0_cfg[card].samples_per_frame = 19200;
       openair0_cfg[card].tx_bw = 1.5e6;
       openair0_cfg[card].rx_bw = 1.5e6;
-      //openair0_cfg[card].tx_forward_nsamps = 40;
-      //openair0_cfg[card].tx_delay = 8;
+      openair0_cfg[card].tx_forward_nsamps = 40;
+      openair0_cfg[card].tx_delay = 8;
 #endif
     }
     
 #ifdef ETHERNET
 
-    //openair0_cfg[card].remote_addr = "192.168.12.242";
-    //openair0_cfg[card].remote_addr = "127.0.0.1";
-    openair0_cfg[card].remote_addr = "74:d4:35:cc:88:45";
-    openair0_cfg[card].remote_port = 50000;
-    //openair0_cfg[card].my_addr = "192.168.12.31";
-    //openair0_cfg[card].my_addr = "127.0.0.1";
-    openair0_cfg[card].my_addr = "d4:be:d9:22:0a:ac";
-    openair0_cfg[card].my_port = 50000; 
-    //openair0_cfg[card].my_port = 50001;
-    openair0_cfg[card].tx_delay = 10;
+    //calib needed
+    openair0_cfg[card].tx_delay = 0;
     openair0_cfg[card].tx_forward_nsamps = 0;
-    openair0_cfg[card].txlaunch_wait = 0;
-    openair0_cfg[card].txlaunch_wait_slotcount = 0;
     
     if (frame_parms[0]->N_RB_DL == 6) 
       openair0_cfg[card].samples_per_packet = 256;
@@ -3000,20 +2934,23 @@ int main( int argc, char **argv )
 
 #ifndef EXMIMO
     openair0_cfg[card].samples_per_packet = openair0_cfg[0].samples_per_packet;
-    openair0_cfg[card].num_rb_dl=frame_parms[0]->N_RB_DL;
 #endif
     printf("HW: Configuring card %d, nb_antennas_tx/rx %d/%d\n",card,
            ((UE_flag==0) ? PHY_vars_eNB_g[0][0]->lte_frame_parms.nb_antennas_tx : PHY_vars_UE_g[0][0]->lte_frame_parms.nb_antennas_tx),
            ((UE_flag==0) ? PHY_vars_eNB_g[0][0]->lte_frame_parms.nb_antennas_rx : PHY_vars_UE_g[0][0]->lte_frame_parms.nb_antennas_rx));
     openair0_cfg[card].Mod_id = 0;
-#ifdef ETHERNET/*do we need to separate ue and enb????*/
-    
+#ifdef ETHERNET
+
     if (UE_flag) {
       printf("ETHERNET: Configuring UE ETH for %s:%d\n",rrh_UE_ip,rrh_UE_port);
-      openair0_cfg[card].remote_addr   = &rrh_UE_ip[0];
+      openair0_cfg[card].remote_ip   = &rrh_UE_ip[0];
       openair0_cfg[card].remote_port = rrh_UE_port;
-    } 
-
+    } else {
+      printf("ETHERNET: Configuring eNB ETH for %s:%d\n",rrh_eNB_ip,rrh_eNB_port);
+      openair0_cfg[card].remote_ip   = &rrh_eNB_ip[0];
+      openair0_cfg[card].remote_port = rrh_eNB_port;
+    }
+openair0_cfg[card].num_rb_dl=frame_parms[0]->N_RB_DL;
 #endif
     openair0_cfg[card].sample_rate = sample_rate;
     openair0_cfg[card].tx_bw = bw;
@@ -3066,36 +3003,18 @@ int main( int argc, char **argv )
 
 #endif
   }
-  /* device host type is set*/
-  openair0.host_type = BBU_HOST;
-  /* device type is initialized NONE_DEV (no RF device) when the RF device will be initiated device type will be set */
-  openair0.type = NONE_DEV;
-  /* transport type is initialized NONE_TP (no transport protocol) when the transport protocol will be initiated transport protocol type will be set */
-  openair0.transp_type = NONE_TP;
+
+  openair0.func_type = BBU_FUNC;
   openair0_cfg[0].log_level = glog_level;
-  
-  /* BBU can either have local or remote radio heads - local radio head option is set by default so the corresponding device is initiated */
+
   if ((mode!=loop_through_memory) && 
-      (openair0_device_load(&openair0, &openair0_cfg[0]) <0)) {
+      (openair0_device_init(&openair0, &openair0_cfg[0]) <0)) {
     printf("Exiting, cannot initialize device\n");
     exit(-1);
   }
   else if (mode==loop_through_memory) {    
   }
-  /* radio heads are remote so the trasnsport protocol is initiated */
-  if (local_remote_RF == BBU_REMOTE_RF_ENABLED) {
-    if ((mode!=loop_through_memory) && 
-	(openair0_transport_load(&openair0, &openair0_cfg[0]) <0)) {
-      printf("Exiting, cannot initialize transport protocol\n");
-      exit(-1);
-    }
-    else if (mode==loop_through_memory) {    
-    }
-  }   
-  //for EXMIMO
-  //openair0_cfg[0].iq_rxrescale=15;  /* default value if build with EXMIMO */
-  //rxrescale=openair0_cfg[0].iq_rxrescale; /* see comments near RX_IQRESCALELEN definition */
-  
+ 
   printf("Done\n");
 
   mac_xface = malloc(sizeof(MAC_xface));
@@ -3513,6 +3432,7 @@ int main( int argc, char **argv )
     if (multi_thread>0) {
       printf("Killing eNB processing threads\n");
       kill_eNB_proc();
+
     }
   }
 
@@ -3604,6 +3524,10 @@ int setup_eNB_buffers(PHY_VARS_eNB **phy_vars_eNB, openair0_config_t *openair0_c
 
 #endif
 
+
+
+
+
     // replace RX signal buffers with mmaped HW versions
 #ifdef EXMIMO
     openair0_cfg[CC_id].tx_num_channels = 0;
-- 
GitLab