From 55c194b07dc9a344347d0283bac79cc983e2a2e4 Mon Sep 17 00:00:00 2001
From: Sandeep Kumar <ee13b1025@iith.ac.in>
Date: Fri, 1 Jul 2016 19:29:02 +0200
Subject: [PATCH] added mobipass interface and tested sending dummy and
 starting stream, no reply yet

---
 cmake_targets/CMakeLists.txt                   |  1 +
 openair2/ENB_APP/enb_config.c                  |  4 +++-
 openair2/ENB_APP/enb_config.h                  |  1 +
 targets/ARCH/ETHERNET/USERSPACE/LIB/eth_raw.c  | 10 ++++++++--
 .../ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.c | 16 ++++++++++++++++
 targets/ARCH/ETHERNET/USERSPACE/LIB/if_defs.h  |  5 +++++
 targets/RT/USER/lte-enb.c                      | 18 ++++++++++++++----
 targets/RT/USER/lte-softmodem.c                |  2 ++
 8 files changed, 50 insertions(+), 7 deletions(-)

diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt
index 56759ae0e5..f96c63f2bb 100644
--- a/cmake_targets/CMakeLists.txt
+++ b/cmake_targets/CMakeLists.txt
@@ -963,6 +963,7 @@ set(PHY_SRC
   ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/print_stats.c
   ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/initial_sync.c
   ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/if4_tools.c
+  ${OPENAIR1_DIR}/PHY/LTE_TRANSPORT/if5_mobipass_tools.c
   ${OPENAIR1_DIR}/PHY/MODULATION/ofdm_mod.c
   ${OPENAIR1_DIR}/PHY/MODULATION/slot_fep.c
   ${OPENAIR1_DIR}/PHY/MODULATION/slot_fep_mbsfn.c
diff --git a/openair2/ENB_APP/enb_config.c b/openair2/ENB_APP/enb_config.c
index 5bc0088ed5..d67c6eb6d7 100755
--- a/openair2/ENB_APP/enb_config.c
+++ b/openair2/ENB_APP/enb_config.c
@@ -298,7 +298,7 @@ void enb_config_display(void)
 	printf( "\ttx_scheduling_advance :\t%d:\n",enb_properties.properties[i]->rrh_gw_config[j].tx_scheduling_advance);
 	printf( "\ttx_sample_advance :    \t%d:\n",enb_properties.properties[i]->rrh_gw_config[j].tx_sample_advance);
 	printf( "\tiq_txshift :           \t%d:\n",enb_properties.properties[i]->rrh_gw_config[j].iq_txshift);
-	printf( "\ttransport  :           \t%s Ethernet:\n",(enb_properties.properties[i]->rrh_gw_config[j].raw == 1)? "RAW" : (enb_properties.properties[i]->rrh_gw_config[j].rawif4 == 1)? "RAW_IF4" : (enb_properties.properties[i]->rrh_gw_config[j].udpif4 == 1)? "UDP_IF4" : "UDP");
+	printf( "\ttransport  :           \t%s Ethernet:\n",(enb_properties.properties[i]->rrh_gw_config[j].raw == 1)? "RAW" : (enb_properties.properties[i]->rrh_gw_config[j].rawif4 == 1)? "RAW_IF4" : (enb_properties.properties[i]->rrh_gw_config[j].udpif4 == 1)? "UDP_IF4" : (enb_properties.properties[i]->rrh_gw_config[j].rawif5_mobipass == 1)? "RAW_IF5_MOBIPASS" : "UDP");
 	if (enb_properties.properties[i]->rrh_gw_config[j].exmimo == 1) {
 	  printf( "\tRF target  :           \tEXMIMO:\n\n");
 	} else if (enb_properties.properties[i]->rrh_gw_config[j].usrp_b200 == 1) {
@@ -2246,6 +2246,8 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP)
               enb_properties.properties[enb_properties_index]->rrh_gw_config[j].udpif4 = 1; 
             } else if (strcmp(tr_preference, "raw_if4") == 0) {
               enb_properties.properties[enb_properties_index]->rrh_gw_config[j].rawif4 = 1;
+            } else if (strcmp(tr_preference, "raw_if5_mobipass") == 0) {
+              enb_properties.properties[enb_properties_index]->rrh_gw_config[j].rawif5_mobipass = 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;
diff --git a/openair2/ENB_APP/enb_config.h b/openair2/ENB_APP/enb_config.h
index e53921b4d0..716d400178 100755
--- a/openair2/ENB_APP/enb_config.h
+++ b/openair2/ENB_APP/enb_config.h
@@ -88,6 +88,7 @@ typedef struct rrh_gw_config_s {
   uint16_t  remote_port;
   uint8_t   udpif4;
   uint8_t   rawif4;
+  uint8_t   rawif5_mobipass;
   int tx_scheduling_advance;
   int tx_sample_advance;
   int iq_txshift;
diff --git a/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_raw.c b/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_raw.c
index 13dfe574c2..17a9a677e0 100644
--- a/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_raw.c
+++ b/targets/ARCH/ETHERNET/USERSPACE/LIB/eth_raw.c
@@ -53,6 +53,7 @@
 #include "ethernet_lib.h"
 #include "if_defs.h"
 #include "openair1/PHY/LTE_TRANSPORT/if4_tools.h"
+#include "openair1/PHY/LTE_TRANSPORT/if5_mobipass_tools.h"
 
 #define DEBUG 0
 
@@ -123,8 +124,11 @@ int eth_socket_init_raw(openair0_device *device) {
  /* Construct the Ethernet header */ 
  ether_aton_r(local_mac, (struct ether_addr *)(&(eth->eh.ether_shost)));
  ether_aton_r(remote_mac, (struct ether_addr *)(&(eth->eh.ether_dhost)));
- eth->eh.ether_type = htons((short)device->openair0_cfg->my_port);
-
+// if (((*) device->priv)->flags == ETH_RAW_IF5_MOBIPASS) {
+   eth->eh.ether_type = htons(0xbffe);
+// } else {
+//   eth->eh.ether_type = htons((short)device->openair0_cfg->my_port);
+// } 
  printf("[%s] binding mod_%d to hardware address %x:%x:%x:%x:%x:%x\n",((device->host_type == BBU_HOST) ? "BBU": "RRH"),Mod_id,eth->eh.ether_shost[0],eth->eh.ether_shost[1],eth->eh.ether_shost[2],eth->eh.ether_shost[3],eth->eh.ether_shost[4],eth->eh.ether_shost[5]);
  
  return 0;
@@ -214,6 +218,8 @@ int trx_eth_write_raw_IF4(openair0_device *device, openair0_timestamp timestamp,
     packet_size = RAW_IF4_PDLFFT_SIZE_BYTES(nblocks);    
   } else if (flags == IF4_PULFFT) {
     packet_size = RAW_IF4_PULFFT_SIZE_BYTES(nblocks);    
+  } else if (flags == IF5_MOBIPASS) {
+    packet_size = RAW_IF5_MOBIPASS_SIZE_BYTES;
   } else {
     packet_size = RAW_IF4_PRACH_SIZE_BYTES;
   }
diff --git a/targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.c b/targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.c
index 5802b1569f..81e3d7b558 100644
--- a/targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.c
+++ b/targets/ARCH/ETHERNET/USERSPACE/LIB/ethernet_lib.c
@@ -88,6 +88,17 @@ int trx_eth_start(openair0_device *device) {
   } else if (eth->flags == ETH_UDP_IF4_MODE) {
     
   
+  } else if (eth->flags == ETH_RAW_IF5_MOBIPASS) {
+    if (eth_socket_init_raw(device)!=0)   return -1;
+    /* RRH gets openair0 device configuration - BBU sets openair0 device configuration*/
+    //if (device->host_type == BBU_HOST) {
+      //if(eth_set_dev_conf_raw_IF4(device)!=0)  return -1;
+    //} else {
+      //if(eth_get_dev_conf_raw_IF4(device)!=0)  return -1;
+//
+    /* adjust MTU wrt number of samples per packet */
+   // if(ethernet_tune (device,MTU_SIZE,RAW_PACKET_SIZE_BYTES(device->openair0_cfg->samples_per_packet))!=0)  return -1;
+
   } else {
     if (eth_socket_init_udp(device)!=0)   return -1; 
     /* RRH gets openair0 device configuration - BBU sets openair0 device configuration*/
@@ -334,6 +345,8 @@ int transport_init(openair0_device *device, openair0_config_t *openair0_cfg, eth
     eth->flags = ETH_RAW_IF4_MODE;
   } else if (eth_params->transp_preference == 2) {
     eth->flags = ETH_UDP_IF4_MODE;
+  } else if (eth_params->transp_preference == 4) {
+    eth->flags = ETH_RAW_IF5_MOBIPASS;
   } else {
     printf("transport_init: Unknown transport preference %d - default to RAW", eth_params->transp_preference);
     eth->flags = ETH_RAW_MODE;
@@ -361,6 +374,9 @@ int transport_init(openair0_device *device, openair0_config_t *openair0_cfg, eth
   } else if (eth->flags == ETH_RAW_IF4_MODE) {
     device->trx_write_func   = trx_eth_write_raw_IF4;
     device->trx_read_func    = trx_eth_read_raw_IF4;     
+  } else if (eth->flags == ETH_RAW_IF5_MOBIPASS) {
+    device->trx_write_func   = trx_eth_write_raw_IF4;
+    device->trx_read_func    = trx_eth_read_raw_IF4;     
   } else {
     //device->trx_write_func   = trx_eth_write_udp_IF4;
     //device->trx_read_func    = trx_eth_read_udp_IF4;     
diff --git a/targets/ARCH/ETHERNET/USERSPACE/LIB/if_defs.h b/targets/ARCH/ETHERNET/USERSPACE/LIB/if_defs.h
index 030bfda147..e17890836b 100644
--- a/targets/ARCH/ETHERNET/USERSPACE/LIB/if_defs.h
+++ b/targets/ARCH/ETHERNET/USERSPACE/LIB/if_defs.h
@@ -46,6 +46,7 @@
 #define ETH_RAW_MODE        1
 #define ETH_UDP_IF4_MODE    2
 #define ETH_RAW_IF4_MODE    3
+#define ETH_RAW_IF5_MOBIPASS    4    
 
 // Time domain RRH packet sizes
 #define MAC_HEADER_SIZE_BYTES (sizeof(struct ether_header))
@@ -61,3 +62,7 @@
 #define RAW_IF4_PDLFFT_SIZE_BYTES(nblocks) (MAC_HEADER_SIZE_BYTES + sizeof_IF4_header_t + DATA_BLOCK_SIZE_BYTES(nblocks))  
 #define RAW_IF4_PULFFT_SIZE_BYTES(nblocks) (MAC_HEADER_SIZE_BYTES + sizeof_IF4_header_t + DATA_BLOCK_SIZE_BYTES(nblocks))  
 #define RAW_IF4_PRACH_SIZE_BYTES (MAC_HEADER_SIZE_BYTES + sizeof_IF4_header_t + PRACH_BLOCK_SIZE_BYTES)
+
+// Mobipass packet sizes
+#define RAW_IF5_MOBIPASS_BLOCK_SIZE_BYTES 1280
+#define RAW_IF5_MOBIPASS_SIZE_BYTES (MAC_HEADER_SIZE_BYTES + sizeof_IF5_mobipass_header_t + RAW_IF5_MOBIPASS_BLOCK_SIZE_BYTES)
diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c
index 6eb916c41b..1fcd9bb61c 100644
--- a/targets/RT/USER/lte-enb.c
+++ b/targets/RT/USER/lte-enb.c
@@ -69,6 +69,7 @@
 //#undef FRAME_LENGTH_COMPLEX_SAMPLES //there are two conflicting definitions, so we better make sure we don't use it at all
 
 #include "PHY/LTE_TRANSPORT/if4_tools.h"
+#include "PHY/LTE_TRANSPORT/if5_mobipass_tools.h"
 
 #include "PHY/extern.h"
 #include "SCHED/extern.h"
@@ -547,7 +548,7 @@ static void* eNB_thread_rxtx( void* param ) {
 
     } else if (PHY_vars_eNB_g[0][proc->CC_id]->node_function == eNodeB_3GPP_BBU) {
       /// **** trx_write_func to IF device **** ///       
-      
+   //   send_IF5(PHY_vars_eNB_g[0][proc->CC_id], proc, 0);
       
     } else { 
       /// **** send_IF4 of txdataF to RRU **** ///       
@@ -624,10 +625,11 @@ static void* eNB_thread_rx_common( void* param ) {
   eNB_proc_t *proc = (eNB_proc_t*)param;
   PHY_VARS_eNB *eNB = PHY_vars_eNB_g[0][proc->CC_id];
   LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms;
-
+  
+  uint8_t seqno=0;
   FILE  *rx_time_file = NULL;
   char rx_time_name[101];
-  //int i;
+  int i;
   struct timespec wait;
 
   wait.tv_sec=0;
@@ -762,7 +764,15 @@ static void* eNB_thread_rx_common( void* param ) {
     if (eNB->rfdevice.trx_start_func(&eNB->rfdevice) != 0 ) 
       LOG_E(HW,"Could not start the RF device\n");
   }
-    
+
+  //  proc->proc_rxtx[0].timestamp_tx = 0;
+  //  seqno = send_IF5(eNB, &proc->proc_rxtx[0], 0); 
+  
+ // for (i=0; i<1000;i++) {
+ //   seqno = send_IF5(eNB, &proc->proc_rxtx[0], seqno); 
+ //   proc->proc_rxtx[0].timestamp_tx += 7680*2;
+ // }
+      
   // This is a forever while loop, it loops over subframes which are scheduled by incoming samples from HW devices
   while (!oai_exit) {
     VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_eNB_PROC_RX, 0 );
diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c
index 4447999bfd..656c22ced3 100644
--- a/targets/RT/USER/lte-softmodem.c
+++ b/targets/RT/USER/lte-softmodem.c
@@ -1071,6 +1071,8 @@ static void get_options (int argc, char **argv)
             (eth_params+j)->transp_preference       = ETH_RAW_IF4_MODE;             
           } else if (enb_properties->properties[i]->rrh_gw_config[j].udpif4 == 1) {
             (eth_params+j)->transp_preference       = ETH_UDP_IF4_MODE;             
+          } else if (enb_properties->properties[i]->rrh_gw_config[j].rawif5_mobipass == 1) {
+            (eth_params+j)->transp_preference       = ETH_RAW_IF5_MOBIPASS;             
           } else {
             (eth_params+j)->transp_preference       = ETH_UDP_MODE;	 
           }
-- 
GitLab