From 0da275a81bb1d07733dd96d350de84933d270542 Mon Sep 17 00:00:00 2001
From: trilyrak <aikaterini.trilyraki@eurecom.fr>
Date: Wed, 17 Feb 2016 13:51:00 +0100
Subject: [PATCH] updates for rrh configuration params

---
 targets/ARCH/COMMON/common_lib.h              | 16 ++++++++---
 .../ETHERNET/USERSPACE/LIB/ethernet_lib.c     | 24 ++++++-----------
 targets/RT/USER/lte-softmodem.c               | 27 ++++++++++++-------
 3 files changed, 37 insertions(+), 30 deletions(-)

diff --git a/targets/ARCH/COMMON/common_lib.h b/targets/ARCH/COMMON/common_lib.h
index 0abe8fd22e..2bd6e4e15d 100644
--- a/targets/ARCH/COMMON/common_lib.h
+++ b/targets/ARCH/COMMON/common_lib.h
@@ -209,15 +209,23 @@ typedef struct {
 typedef struct {
   char *remote_addr;
   //! remote port number for Ethernet interface
-  unsigned int remote_port;
+  uint16_t remote_port;
   //! local IP/MAC addr for Ethernet interface (eNB/BBU, UE)
   char *my_addr;
   //! local port number for Ethernet interface (eNB/BBU, UE)
-  unsigned int my_port;
-  //! local port number for Ethernet interface (eNB/BBU, UE)
+  uint16_t  my_port;
+  //! local Ethernet interface (eNB/BBU, UE)
   char *local_if_name;
- //! local port number for Ethernet interface (eNB/BBU, UE)
+  //! tx_sample_advance for RF + ETH
+  uint8_t tx_sample_advance;
+  //! tx_scheduling_advance for RF + ETH
+  uint8_t tx_scheduling_advance;
+  //! iq_txshift  for RF + ETH
+  uint8_t iq_txshift;
+  //! transport type preference  (RAW/UDP)
   uint8_t transp_preference;
+  //! radio front end preference (EXMIMO,USRP, BALDERF,LMSSDR)
+  uint8_t rf_preference;
 } eth_params_t;
 
 
diff --git a/targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.c b/targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.c
index 4fa522f21a..f15f2d98eb 100644
--- a/targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.c
+++ b/targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.c
@@ -344,43 +344,35 @@ int transport_init(openair0_device *device, openair0_config_t *openair0_cfg, eth
   /* device specific */
   openair0_cfg[0].txlaunch_wait = 0;//manage when TX processing is triggered
   openair0_cfg[0].txlaunch_wait_slotcount = 0; //manage when TX processing is triggered
-  openair0_cfg[0].iq_txshift = 5;// shift
   openair0_cfg[0].iq_rxrescale = 15;//rescale iqs
+  openair0_cfg[0].iq_txshift = eth_params->iq_txshift;// shift
+  openair0_cfg[0].tx_sample_advance = eth_params->tx_sample_advance;
 
   /* RRH does not have any information to make this configuration atm */
   if (device->host_type == BBU_HOST) {
     /*Note scheduling advance values valid only for case 7680000 */    
     switch ((int)openair0_cfg[0].sample_rate) {
     case 30720000:
-      openair0_cfg[0].samples_per_packet    = 4096;
-      openair0_cfg[0].tx_sample_advance     = 115;
-      openair0_cfg[0].tx_scheduling_advance = 11*openair0_cfg[0].samples_per_packet;
+      openair0_cfg[0].samples_per_packet    = 4096;     
       break;
     case 23040000:     
       openair0_cfg[0].samples_per_packet    = 2048;
-      openair0_cfg[0].tx_sample_advance     = 113;
-      openair0_cfg[0].tx_scheduling_advance = 8*openair0_cfg[0].samples_per_packet;
       break;
     case 15360000:
-      openair0_cfg[0].samples_per_packet    = 2048;
-      openair0_cfg[0].tx_sample_advance     = 113;
-      openair0_cfg[0].tx_scheduling_advance = 9*openair0_cfg[0].samples_per_packet;
+      openair0_cfg[0].samples_per_packet    = 2048;      
       break;
     case 7680000:
-      openair0_cfg[0].samples_per_packet    = 1024;
-      openair0_cfg[0].tx_sample_advance     = 70;
-      openair0_cfg[0].tx_scheduling_advance = 9*openair0_cfg[0].samples_per_packet;
-     break;
+      openair0_cfg[0].samples_per_packet    = 1024;     
+      break;
     case 1920000:
-      openair0_cfg[0].samples_per_packet    = 256;
-      openair0_cfg[0].tx_sample_advance     = 40;
-      openair0_cfg[0].tx_scheduling_advance = 8*openair0_cfg[0].samples_per_packet;
+      openair0_cfg[0].samples_per_packet    = 256;     
       break;
     default:
       printf("Error: unknown sampling rate %f\n",openair0_cfg[0].sample_rate);
       exit(-1);
       break;
     }
+    openair0_cfg[0].tx_scheduling_advance = eth_params->tx_scheduling_advance*openair0_cfg[0].samples_per_packet;
   }
  
   device->openair0_cfg=&openair0_cfg[0];
diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c
index baba632de1..090fd4ecb5 100644
--- a/targets/RT/USER/lte-softmodem.c
+++ b/targets/RT/USER/lte-softmodem.c
@@ -2443,22 +2443,29 @@ static void get_options (int argc, char **argv)
 	  local_remote_radio = BBU_REMOTE_RADIO_HEAD;
 	  eth_params = (eth_params_t*)malloc(sizeof(eth_params_t));
 	  memset(eth_params, 0, sizeof(eth_params_t));
-	 
-	  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");
 	  
 	  eth_params->local_if_name             = enb_properties->properties[i]->rrh_gw_if_name;
 	  eth_params->my_addr                   = enb_properties->properties[i]->rrh_gw_config[j].local_address;
 	  eth_params->my_port                   = enb_properties->properties[i]->rrh_gw_config[j].local_port;
 	  eth_params->remote_addr               = enb_properties->properties[i]->rrh_gw_config[j].remote_address;
 	  eth_params->remote_port               = enb_properties->properties[i]->rrh_gw_config[j].remote_port;
-	  eth_params->transp_preference         = enb_properties->properties[i]->rrh_gw_config[j].raw;
- 
+	  eth_params->transp_preference         = enb_properties->properties[i]->rrh_gw_config[j].raw;	 
+	  eth_params->iq_txshift                = enb_properties->properties[i]->rrh_gw_config[j].iq_txshift;
+	  eth_params->tx_sample_advance         = enb_properties->properties[i]->rrh_gw_config[j].tx_sample_advance;
+	  eth_params->tx_scheduling_advance     = enb_properties->properties[i]->rrh_gw_config[j].tx_scheduling_advance;
+	  if (enb_properties->properties[i]->rrh_gw_config[j].exmimo == 1) {
+	     eth_params->rf_preference          = EXMIMO_DEV;
+	  } else if (enb_properties->properties[i]->rrh_gw_config[j].usrp_b200 == 1) {
+	    eth_params->rf_preference          = USRP_B200_DEV;
+	  } else if (enb_properties->properties[i]->rrh_gw_config[j].usrp_x300 == 1) {
+	   eth_params->rf_preference          = USRP_X300_DEV;
+	  } else if (enb_properties->properties[i]->rrh_gw_config[j].bladerf == 1) {
+	    eth_params->rf_preference          = BLADERF_DEV;
+	  } else if (enb_properties->properties[i]->rrh_gw_config[j].lmssdr == 1) {
+	    //eth_params->rf_preference          = LMSSDR_DEV;
+	  } else {
+	    eth_params->rf_preference          = 0;
+	  } 
 	} else {
 	  local_remote_radio = BBU_LOCAL_RADIO_HEAD; 
 	}
-- 
GitLab