From 631b4cacf41a8a205d9606d554daf26577531c3c Mon Sep 17 00:00:00 2001
From: Sandeep Kumar <ee13b1025@iith.ac.in>
Date: Fri, 22 Jul 2016 16:51:37 +0200
Subject: [PATCH] read node fn, timing from config data

---
 targets/RT/USER/lte-enb.c       |  12 +--
 targets/RT/USER/lte-softmodem.c | 131 +++++++-------------------------
 2 files changed, 35 insertions(+), 108 deletions(-)

diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c
index 3317d289e06..1f80e175023 100644
--- a/targets/RT/USER/lte-enb.c
+++ b/targets/RT/USER/lte-enb.c
@@ -157,7 +157,7 @@ static struct {
 
 void exit_fun(const char* s);
 
-void init_eNB(eNB_func_t node_function);
+void init_eNB(eNB_func_t node_function[], eNB_timing_t node_timing[]);
 void stop_eNB(void);
 
 
@@ -1577,13 +1577,15 @@ void print_opp_meas(void) {
 }
  
 
-void init_eNB(eNB_func_t node_function) {
+void init_eNB(eNB_func_t node_function[], eNB_timing_t node_timing[]) {
 
   int CC_id;
 
-  for (CC_id=0;CC_id<MAX_NUM_CCs;CC_id++)
-    PHY_vars_eNB_g[0][CC_id]->node_function = node_function;
-
+  for (CC_id=0;CC_id<MAX_NUM_CCs;CC_id++) {
+    PHY_vars_eNB_g[0][CC_id]->node_function = node_function[CC_id];
+    PHY_vars_eNB_g[0][CC_id]->node_timing   = node_timing[CC_id];
+  }
+  
   init_eNB_proc();
   sleep(1);
   LOG_D(HW,"[lte-softmodem.c] eNB threads created\n");
diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c
index eedc6415747..42cefe4154b 100644
--- a/targets/RT/USER/lte-softmodem.c
+++ b/targets/RT/USER/lte-softmodem.c
@@ -119,7 +119,7 @@ unsigned short config_frames[4] = {2,9,11,13};
 
 // In lte-enb.c
 extern int setup_eNB_buffers(PHY_VARS_eNB **phy_vars_eNB, openair0_config_t *openair0_cfg, openair0_rf_map rf_map[MAX_NUM_CCs]);
-extern void init_eNB(eNB_func_t);
+extern void init_eNB(eNB_func_t *, eNB_timing_t *);
 extern void stop_eNB(void);
 extern void kill_eNB_proc(void);
 
@@ -229,7 +229,9 @@ int                             otg_enabled;
 
 
 static LTE_DL_FRAME_PARMS      *frame_parms[MAX_NUM_CCs];
-eNB_func_t node_function=eNodeB_3GPP;
+eNB_func_t node_function[MAX_NUM_CCs];
+eNB_timing_t node_timing[MAX_NUM_CCs];
+int16_t   node_synch_ref[MAX_NUM_CCs];
 
 uint32_t target_dl_mcs = 28; //maximum allowed mcs
 uint32_t target_ul_mcs = 20;
@@ -237,8 +239,6 @@ uint32_t timing_advance = 0;
 uint8_t exit_missed_slots=1;
 uint64_t num_missed_slots=0; // counter for the number of missed slots
 
-
-
 extern void reset_opp_meas(void);
 extern void print_opp_meas(void);
 int transmission_mode=1;
@@ -387,11 +387,6 @@ void help (void) {
   printf("  --ue-scan_carrier set UE to scan around carrier\n");
   printf("  --loop-memory get softmodem (UE) to loop through memory instead of acquiring from HW\n");
   printf("  --mmapped-dma sets flag for improved EXMIMO UE performance\n");   
-  printf("  --RCC run using NGFI RCC node function IF4 split\n");
-  printf("  --RRU run using NGFI RRU node function  IF4 split\n");
-  printf("  --eNB run using 3GPP eNB node function\n");   
-  printf("  --BBU run using 3GPP eNB node function with IF5 split\n");   
-  printf("  --RRH run using RRH node function with IF5 split\n");
   printf("  -C Set the downlink frequency for all component carriers\n");
   printf("  -d Enable soft scope and L1 and L2 stats (Xforms)\n");
   printf("  -F Calibrate the EXMIMO borad, available files: exmimo2_2arxg.lime exmimo2_2brxg.lime \n");
@@ -688,12 +683,7 @@ static void get_options (int argc, char **argv)
     LONG_OPTION_DUMP_FRAME,
     LONG_OPTION_LOOPMEMORY,
     LONG_OPTION_PHYTEST,
-    LONG_OPTION_MMAPPED_DMA,
-    LONG_OPTION_RCC,
-    LONG_OPTION_RRU,
-    LONG_OPTION_ENB,
-    LONG_OPTION_ENB_BBU,
-    LONG_OPTION_RRH
+    LONG_OPTION_MMAPPED_DMA
 #if T_TRACER
     ,
     LONG_OPTION_T_PORT,
@@ -718,11 +708,6 @@ static void get_options (int argc, char **argv)
     {"loop-memory", required_argument, NULL, LONG_OPTION_LOOPMEMORY},
     {"phy-test", no_argument, NULL, LONG_OPTION_PHYTEST},
     {"mmapped-dma", no_argument, NULL, LONG_OPTION_MMAPPED_DMA},
-    {"RCC", no_argument, NULL, LONG_OPTION_RCC},
-    {"RRU", no_argument, NULL, LONG_OPTION_RRU},
-    {"eNB", no_argument, NULL, LONG_OPTION_ENB},
-    {"BBU", no_argument, NULL, LONG_OPTION_ENB_BBU},
-    {"RRH", no_argument, NULL, LONG_OPTION_RRH},
 #if T_TRACER
     {"T_port",                 required_argument, 0, LONG_OPTION_T_PORT},
     {"T_nowait",               no_argument,       0, LONG_OPTION_T_NOWAIT},
@@ -817,26 +802,6 @@ static void get_options (int argc, char **argv)
     case LONG_OPTION_MMAPPED_DMA:
       mmapped_dma = 1;
       break;
-
-    case LONG_OPTION_RCC:
-      node_function = NGFI_RCC_IF4;
-      break;
-
-    case LONG_OPTION_RRU:
-      node_function = NGFI_RRU_IF4;
-      break;
-
-    case LONG_OPTION_ENB:
-      node_function = eNodeB_3GPP;
-      break;
-
-    case LONG_OPTION_ENB_BBU:
-      node_function = eNodeB_3GPP_BBU;
-      break;
-
-    case LONG_OPTION_RRH:
-      node_function = NGFI_RRU_IF5;
-      break;
               
 #if T_TRACER
     case LONG_OPTION_T_PORT: {
@@ -1116,6 +1081,10 @@ static void get_options (int argc, char **argv)
       }
 
       for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
+        node_function[CC_id]  = enb_properties->properties[i]->cc_node_function[CC_id];
+        node_timing[CC_id]    = enb_properties->properties[i]->cc_node_timing[CC_id];
+        node_synch_ref[CC_id] = enb_properties->properties[i]->cc_node_synch_ref[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];
         frame_parms[CC_id]->tdd_config_S =     enb_properties->properties[i]->tdd_config_s[CC_id];
@@ -1668,7 +1637,7 @@ int main( int argc, char **argv )
 
   if (UE_flag == 0) {
     for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
-      if (node_function == NGFI_RRU_IF4 || node_function == NGFI_RRU_IF5) {
+      if (node_function[CC_id] == NGFI_RRU_IF4 || node_function[CC_id] == NGFI_RRU_IF5) {
         PHY_vars_eNB_g[0][CC_id]->rfdevice.host_type = RRH_HOST;
         PHY_vars_eNB_g[0][CC_id]->ifdevice.host_type = RRH_HOST;
       } else {
@@ -1683,69 +1652,39 @@ int main( int argc, char **argv )
   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;
-  
-  // Legacy BBU - RRH init  
-  //int returns=-1;
-  ///* BBU can have either a local or a remote radio head */  
-  //if (local_remote_radio == BBU_LOCAL_RADIO_HEAD) { //local radio head active  - load library of radio head and initiate it
-  //if (mode!=loop_through_memory) {
-  //returns=openair0_device_load(&openair0, &openair0_cfg[0]);
-  //printf("openair0_device_init returns %d\n",returns);
-  //if (returns<0) {
-  //printf("Exiting, cannot initialize device\n");
-  //exit(-1);
-  //}
-  //}
-  //else if (mode==loop_through_memory) {    
-  //}
-  //}  else { //remote radio head active - load library of transport protocol and initiate it 
-  //if (mode!=loop_through_memory) {
-  //returns=openair0_transport_load(&openair0, &openair0_cfg[0], eth_params);
-  //printf("openair0_transport_init returns %d\n",returns);
-  //if (returns<0) { 
-  //printf("Exiting, cannot initialize transport protocol\n");
-  //exit(-1);
-  //}
-  //}
-  //else if (mode==loop_through_memory) {    
-  //}
-  //}   
-    
+      
   int returns=-1;
     
-  // Handle spatially distributed MIMO antenna ports   
   // Load RF device and initialize
-  if (node_function == NGFI_RRU_IF5 || node_function == NGFI_RRU_IF4 || node_function == eNodeB_3GPP) { 
-    for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {  
+  for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {  
+    if (node_function[CC_id] == NGFI_RRU_IF5 || node_function[CC_id] == NGFI_RRU_IF4 || node_function[CC_id] == eNodeB_3GPP) { 
       if (mode!=loop_through_memory) {
-        returns= (UE_flag == 0) ? 
-	  openair0_device_load(&(PHY_vars_eNB_g[0][CC_id]->rfdevice), &openair0_cfg[0]) :
-	  openair0_device_load(&openair0, &openair0_cfg[0]);
-
+        returns = (UE_flag == 0) ? 
+	                openair0_device_load(&(PHY_vars_eNB_g[0][CC_id]->rfdevice), &openair0_cfg[0]) :
+	                openair0_device_load(&openair0, &openair0_cfg[0]);
         printf("openair0_device_init returns %d for CC_id %d\n",returns,CC_id);
         if (returns<0) {
-	  printf("Exiting, cannot initialize device\n");
-	  exit(-1);
+          printf("Exiting, cannot initialize device\n");
+          exit(-1);
         }
-      }
-      else if (mode==loop_through_memory) {    
+      } else if (mode==loop_through_memory) {    
+      
       }    
     }
   }  
   
   // Load transport protocol and initialize
-
-  if ((UE_flag==0) && (node_function != eNodeB_3GPP)){ 
-    for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {  
+  for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {  
+    if ((UE_flag==0) && (node_function[CC_id] != eNodeB_3GPP)) {
       if (mode!=loop_through_memory) {
-        returns=openair0_transport_load(&(PHY_vars_eNB_g[0][CC_id]->ifdevice), &openair0_cfg[0], (eth_params+CC_id));
+        returns = openair0_transport_load(&(PHY_vars_eNB_g[0][CC_id]->ifdevice), &openair0_cfg[0], (eth_params+CC_id));
         printf("openair0_transport_init returns %d for CC_id %d\n",returns,CC_id);
         if (returns<0) {
-	  printf("Exiting, cannot initialize transport protocol\n");
-	  exit(-1);
+          printf("Exiting, cannot initialize transport protocol\n");
+          exit(-1);
         }
-      }
-      else if (mode==loop_through_memory) {    
+      } else if (mode==loop_through_memory) {    
+      
       }    
     }
   }
@@ -1783,7 +1722,6 @@ int main( int argc, char **argv )
 
   number_of_cards = 1;
 
-
   for(CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
     rf_map[CC_id].card=0;
     rf_map[CC_id].chain=CC_id+chain_offset;
@@ -1905,17 +1843,12 @@ int main( int argc, char **argv )
 
   // start the main thread
   if (UE_flag == 1) init_UE();
-  else init_eNB(node_function);
+  else init_eNB(node_function, node_timing);
 
   // Sleep to allow all threads to setup
   sleep(3);
 
 
-
-
-  // *** Handle per CC_id openair0
-
-
   printf("Sending sync to all threads\n");
 
   pthread_mutex_lock(&sync_mutex);
@@ -1977,7 +1910,6 @@ int main( int argc, char **argv )
   pthread_cond_destroy(&sync_cond);
   pthread_mutex_destroy(&sync_mutex);
 
-  // *** Handle per CC_id openair0
   if (UE_flag==1)
     openair0.trx_end_func(&openair0);
 
@@ -1998,10 +1930,3 @@ int main( int argc, char **argv )
 
   return 0;
 }
-
-
-
-
-
-
-
-- 
GitLab