From e395164a4c75b5ea8f870d3731fee85949963b0b Mon Sep 17 00:00:00 2001
From: Tien-Thinh Nguyen <tien-thinh.nguyen@eurecom.fr>
Date: Tue, 4 Oct 2016 17:02:50 +0200
Subject: [PATCH] fix issues to work with multiple carriers (conga-ercom)

---
 openair1/PHY/LTE_TRANSPORT/if5_tools.c        |  10 +-
 openair1/PHY/defs.h                           |   2 +
 openair2/ENB_APP/enb_config.c                 |   6 +-
 openair2/ENB_APP/enb_config.h                 |   1 +
 .../CONF/rcc.band7.tm1.50PRB.if4p5-ercom.conf | 294 ++++++++++++++++++
 targets/RT/USER/lte-enb.c                     |  83 +++--
 targets/RT/USER/lte-softmodem.c               |  10 +-
 7 files changed, 373 insertions(+), 33 deletions(-)
 create mode 100644 targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.50PRB.if4p5-ercom.conf

diff --git a/openair1/PHY/LTE_TRANSPORT/if5_tools.c b/openair1/PHY/LTE_TRANSPORT/if5_tools.c
index 8f5b7b32fe..3d3651ab59 100644
--- a/openair1/PHY/LTE_TRANSPORT/if5_tools.c
+++ b/openair1/PHY/LTE_TRANSPORT/if5_tools.c
@@ -105,8 +105,8 @@ void send_IF5(PHY_VARS_eNB *eNB, openair0_timestamp proc_timestamp, int subframe
     __m128i t0, t1;
 
     tx_buffer = memalign(16, MAC_HEADER_SIZE_BYTES + sizeof_IF5_mobipass_header_t + db_fulllength*sizeof(int16_t));
-    IF5_mobipass_header_t *header = (IF5_mobipass_header_t *)(tx_buffer + MAC_HEADER_SIZE_BYTES);
-    data_block_head = (__m128i *)(tx_buffer + MAC_HEADER_SIZE_BYTES + sizeof_IF5_mobipass_header_t + 4);
+    IF5_mobipass_header_t *header = (IF5_mobipass_header_t *)((uint8_t *)tx_buffer + MAC_HEADER_SIZE_BYTES);
+    data_block_head = (__m128i *)((uint8_t *)tx_buffer + MAC_HEADER_SIZE_BYTES + sizeof_IF5_mobipass_header_t + 4);
     
     header->flags = 0;
     header->fifo_status = 0;  
@@ -117,11 +117,11 @@ void send_IF5(PHY_VARS_eNB *eNB, openair0_timestamp proc_timestamp, int subframe
     txp[0] = (void*)&eNB->common_vars.txdata[0][0][subframe*eNB->frame_parms.samples_per_tti];
     txp128 = (__m128i *) txp[0];
               
-    for (packet_id=0; packet_id<(fp->samples_per_tti*2)/db_fulllength; packet_id++) {
-      header->time_stamp = proc_timestamp + packet_id*db_fulllength; 
+    for (packet_id=0; packet_id<fp->samples_per_tti/db_fulllength; packet_id++) {
+      header->time_stamp = (uint32_t)(proc_timestamp + packet_id*db_fulllength);
       data_block = data_block_head; 
     
-      for (i=0; i<db_fulllength>>3; i+=2) {
+      for (i=0; i<db_fulllength>>2; i+=2) {
         t0 = _mm_srai_epi16(*txp128++, 4);
         t1 = _mm_srai_epi16(*txp128++, 4);   
         
diff --git a/openair1/PHY/defs.h b/openair1/PHY/defs.h
index 0808bdc5ba..3532fa3c6f 100755
--- a/openair1/PHY/defs.h
+++ b/openair1/PHY/defs.h
@@ -234,6 +234,8 @@ typedef struct eNB_proc_t_s {
   int thread_index;
   /// timestamp received from HW
   openair0_timestamp timestamp_rx;
+  /// timestamp to send to "slave rru"
+  openair0_timestamp timestamp_tx;
   /// subframe to act upon for reception
   int subframe_rx;
   /// subframe to act upon for PRACH
diff --git a/openair2/ENB_APP/enb_config.c b/openair2/ENB_APP/enb_config.c
index def056ee3f..d4c6a81c4f 100755
--- a/openair2/ENB_APP/enb_config.c
+++ b/openair2/ENB_APP/enb_config.c
@@ -318,7 +318,7 @@ void enb_config_display(void)
     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( "\tinterface name :       \t%s:\n",enb_properties.properties[i]->rrh_gw_config[j].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);
@@ -2344,7 +2344,7 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP)
 
             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].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;
@@ -2393,7 +2393,7 @@ const Enb_properties_array_t *enb_config_init(char* lib_config_file_name_pP)
           }
 	  } else {
 	    enb_properties.properties[enb_properties_index]->nb_rrh_gw = 0;	    
-	    enb_properties.properties[enb_properties_index]->rrh_gw_if_name = "none";
+            enb_properties.properties[enb_properties_index]->rrh_gw_config[j].rrh_gw_if_name = "none";
             enb_properties.properties[enb_properties_index]->rrh_gw_config[j].local_address  = "0.0.0.0";
             enb_properties.properties[enb_properties_index]->rrh_gw_config[j].remote_address = "0.0.0.0";
 	    enb_properties.properties[enb_properties_index]->rrh_gw_config[j].local_port= 0;
diff --git a/openair2/ENB_APP/enb_config.h b/openair2/ENB_APP/enb_config.h
index 8d220c3d7b..397209d9ef 100755
--- a/openair2/ENB_APP/enb_config.h
+++ b/openair2/ENB_APP/enb_config.h
@@ -83,6 +83,7 @@ typedef struct rrh_gw_config_s {
   unsigned  udp:1;
   unsigned  raw:1;
   unsigned  active:1;
+  char      *rrh_gw_if_name;
   char     *local_address;
   char     *remote_address;
   uint16_t  local_port;
diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.50PRB.if4p5-ercom.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.50PRB.if4p5-ercom.conf
new file mode 100644
index 0000000000..9ce8fac59f
--- /dev/null
+++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.50PRB.if4p5-ercom.conf
@@ -0,0 +1,294 @@
+Active_eNBs = ( "eNB_Eurecom_LTEBox");
+# Asn1_verbosity, choice in: none, info, annoying
+Asn1_verbosity = "none";
+
+eNBs =
+(
+ {
+    ////////// Identification parameters:
+    eNB_ID    =  0xe00;
+
+    cell_type =  "CELL_MACRO_ENB";
+
+    eNB_name  =  "eNB_Eurecom_LTEBox";
+
+    // Tracking area code, 0x0000 and 0xfffe are reserved values
+    tracking_area_code  =  "1";
+
+    mobile_country_code =  "208";
+
+    mobile_network_code =  "93";
+
+       ////////// Physical parameters:
+
+    component_carriers = (
+      //First carrier -> Master
+      {
+      node_function             = "NGFI_RCC_IF4p5";
+      node_timing               = "synch_to_ext_device";
+      node_synch_ref            = 0;
+      frame_type                                              = "FDD";
+      tdd_config                                              = 3;
+      tdd_config_s                                    = 0;
+      prefix_type                                     = "NORMAL";
+      eutra_band                                      = 7;
+      downlink_frequency                              = 2660000000L;
+      uplink_frequency_offset                         = -120000000;
+      Nid_cell                                        = 0;
+      N_RB_DL                                         = 50;
+      Nid_cell_mbsfn                                  = 0;
+      nb_antenna_ports                               = 1;
+      nb_antennas_tx                                  = 1;
+      nb_antennas_rx                                  = 1;
+      tx_gain                                            = 90;
+      rx_gain                                            = 125;
+      prach_root                                      = 0;
+      prach_config_index                              = 0;
+      prach_high_speed                                = "DISABLE";
+      prach_zero_correlation                          = 1;
+      prach_freq_offset                               = 2;
+      pucch_delta_shift                               = 1;
+      pucch_nRB_CQI                                   = 1;
+      pucch_nCS_AN                                    = 0;
+      pucch_n1_AN                                     = 32;
+      pdsch_referenceSignalPower                              = -29;
+      pdsch_p_b                                               = 0;
+      pusch_n_SB                                              = 1;
+      pusch_enable64QAM                                       = "DISABLE";
+      pusch_hoppingMode                                  = "interSubFrame";
+      pusch_hoppingOffset                                = 0;
+      pusch_groupHoppingEnabled                               = "ENABLE";
+      pusch_groupAssignment                                   = 0;
+      pusch_sequenceHoppingEnabled                            = "DISABLE";
+      pusch_nDMRS1                                       = 1;
+      phich_duration                                     = "NORMAL";
+      phich_resource                                     = "ONESIXTH";
+      srs_enable                                         = "DISABLE";
+      /*  srs_BandwidthConfig                                =;
+      srs_SubframeConfig                                 =;
+      srs_ackNackST                                      =;
+      srs_MaxUpPts                                       =;*/
+
+      pusch_p0_Nominal                                   = -90;
+      pusch_alpha                                        = "AL1";
+      pucch_p0_Nominal                                   = -96;
+      msg3_delta_Preamble                                = 6;
+      pucch_deltaF_Format1                               = "deltaF2";
+      pucch_deltaF_Format1b                              = "deltaF3";
+      pucch_deltaF_Format2                               = "deltaF0";
+      pucch_deltaF_Format2a                              = "deltaF0";
+      pucch_deltaF_Format2b                           = "deltaF0";
+
+      rach_numberOfRA_Preambles                          = 64;
+      rach_preamblesGroupAConfig                         = "DISABLE";
+      /*
+      rach_sizeOfRA_PreamblesGroupA                      = ;
+      rach_messageSizeGroupA                             = ;
+      rach_messagePowerOffsetGroupB                      = ;
+      */
+      rach_powerRampingStep                              = 4;
+      rach_preambleInitialReceivedTargetPower            = -108;
+      rach_preambleTransMax                              = 10;
+      rach_raResponseWindowSize                          = 10;
+      rach_macContentionResolutionTimer                  = 48;
+      rach_maxHARQ_Msg3Tx                                = 4;
+
+      pcch_default_PagingCycle                           = 128;
+      pcch_nB                                            = "oneT";
+      bcch_modificationPeriodCoeff                            = 2;
+      ue_TimersAndConstants_t300                              = 1000;
+      ue_TimersAndConstants_t301                              = 1000;
+      ue_TimersAndConstants_t310                              = 1000;
+      ue_TimersAndConstants_t311                              = 10000;
+      ue_TimersAndConstants_n310                              = 20;
+      ue_TimersAndConstants_n311                              = 1;
+
+      ue_TransmissionMode                                     = 1;
+      },
+      // second carrier-> for ERCOM
+      {
+      node_function             = "eNodeB_3GPP_BBU" # should be verified
+      //node_function             = "NGFI_RCC_IF5"  # should be verified
+      node_timing               = "synch_to_other";
+      node_synch_ref            = 0; #should 
+      frame_type                                              = "FDD";
+      tdd_config                                              = 3;
+      tdd_config_s                                    = 0;
+      prefix_type                                     = "NORMAL";
+      eutra_band                                      = 7;
+      downlink_frequency                              = 2660000000L;
+      uplink_frequency_offset                         = -120000000;
+      Nid_cell                                        = 0;
+      N_RB_DL                                         = 50;
+      Nid_cell_mbsfn                                  = 0;
+      nb_antenna_ports                               = 1;
+      nb_antennas_tx                                  = 1;
+      nb_antennas_rx                                  = 1;
+      tx_gain                                            = 90;
+      rx_gain                                            = 125;
+      prach_root                                      = 0;
+      prach_config_index                              = 0;
+      prach_high_speed                                = "DISABLE";
+      prach_zero_correlation                          = 1;
+      prach_freq_offset                               = 2;
+      pucch_delta_shift                               = 1;
+      pucch_nRB_CQI                                   = 1;
+      pucch_nCS_AN                                    = 0;
+      pucch_n1_AN                                     = 32;
+      pdsch_referenceSignalPower                              = -29;
+      pdsch_p_b                                               = 0;
+      pusch_n_SB                                              = 1;
+      pusch_enable64QAM                                       = "DISABLE";
+      pusch_hoppingMode                                  = "interSubFrame";
+      pusch_hoppingOffset                                = 0;
+      pusch_groupHoppingEnabled                               = "ENABLE";
+      pusch_groupAssignment                                   = 0;
+      pusch_sequenceHoppingEnabled                            = "DISABLE";
+      pusch_nDMRS1                                       = 1;
+      phich_duration                                     = "NORMAL";
+      phich_resource                                     = "ONESIXTH";
+      srs_enable                                         = "DISABLE";
+      /*  srs_BandwidthConfig                                =;
+      srs_SubframeConfig                                 =;
+      srs_ackNackST                                      =;
+      srs_MaxUpPts                                       =;*/
+
+      pusch_p0_Nominal                                   = -90;
+      pusch_alpha                                        = "AL1";
+      pucch_p0_Nominal                                   = -96;
+      msg3_delta_Preamble                                = 6;
+      pucch_deltaF_Format1                               = "deltaF2";
+      pucch_deltaF_Format1b                              = "deltaF3";
+      pucch_deltaF_Format2                               = "deltaF0";
+      pucch_deltaF_Format2a                              = "deltaF0";
+      pucch_deltaF_Format2b                           = "deltaF0";
+
+      rach_numberOfRA_Preambles                          = 64;
+      rach_preamblesGroupAConfig                         = "DISABLE";
+      /*
+      rach_sizeOfRA_PreamblesGroupA                      = ;
+      rach_messageSizeGroupA                             = ;
+      rach_messagePowerOffsetGroupB                      = ;
+      */
+      rach_powerRampingStep                              = 4;
+      rach_preambleInitialReceivedTargetPower            = -108;
+      rach_preambleTransMax                              = 10;
+      rach_raResponseWindowSize                          = 10;
+      rach_macContentionResolutionTimer                  = 48;
+      rach_maxHARQ_Msg3Tx                                = 4;
+
+      pcch_default_PagingCycle                           = 128;
+      pcch_nB                                            = "oneT";
+      bcch_modificationPeriodCoeff                            = 2;
+      ue_TimersAndConstants_t300                              = 1000;
+      ue_TimersAndConstants_t301                              = 1000;
+      ue_TimersAndConstants_t310                              = 1000;
+      ue_TimersAndConstants_t311                              = 10000;
+      ue_TimersAndConstants_n310                              = 20;
+      ue_TimersAndConstants_n311                              = 1;
+
+      ue_TransmissionMode                                     = 1;
+      }
+    );
+
+
+    srb1_parameters :
+    {
+        # timer_poll_retransmit = (ms) [5, 10, 15, 20,... 250, 300, 350, ... 500]
+        timer_poll_retransmit    = 80;
+
+        # timer_reordering = (ms) [0,5, ... 100, 110, 120, ... ,200]
+        timer_reordering         = 35;
+
+        # timer_reordering = (ms) [0,5, ... 250, 300, 350, ... ,500]
+        timer_status_prohibit    = 0;
+
+        # poll_pdu = [4, 8, 16, 32 , 64, 128, 256, infinity(>10000)]
+        poll_pdu                 =  4;
+
+        # poll_byte = (kB) [25,50,75,100,125,250,375,500,750,1000,1250,1500,2000,3000,infinity(>10000)]
+        poll_byte                =  99999;
+
+        # max_retx_threshold = [1, 2, 3, 4 , 6, 8, 16, 32]
+        max_retx_threshold       =  4;
+    }
+
+    # ------- SCTP definitions
+    SCTP :
+    {
+        # Number of streams to use in input/output
+        SCTP_INSTREAMS  = 2;
+        SCTP_OUTSTREAMS = 2;
+    };
+
+
+    ////////// MME parameters:
+    mme_ip_address      = ( { ipv4       = "127.0.0.3";
+                              ipv6       = "192:168:30::17";
+                              active     = "yes";
+                              preference = "ipv4";
+                            }
+                          );
+
+    NETWORK_INTERFACES :
+    {
+
+        ENB_INTERFACE_NAME_FOR_S1_MME            = "lo";
+        ENB_IPV4_ADDRESS_FOR_S1_MME              = "127.0.0.2/24";
+        ENB_INTERFACE_NAME_FOR_S1U               = "lo";
+        ENB_IPV4_ADDRESS_FOR_S1U                 = "127.0.0.4/24";
+        ENB_PORT_FOR_S1U                         = 2152; # Spec 2152
+    };
+
+
+    rrh_gw_config = (
+    {
+        local_if_name = "eth2";
+        remote_address = "00:13:95:1f:a0:af"; #Conga's MAC
+        local_address = "90:e2:ba:c5:fc:04";
+        local_port = 50000;     #for raw option local port must be the same to remote          
+        remote_port = 50000;
+        rrh_gw_active = "yes";
+        tr_preference = "raw_if4p5";
+        rf_preference = "usrp_b200";
+        iq_txshift = 4;
+        tx_sample_advance = 80;
+        tx_scheduling_advance = 9;
+    },
+    //second config for Ercom
+    {
+        local_if_name = "eth1.300";
+        remote_address = "00:21:5e:91:5c:7e"; # should be updated with ERCOM's MAC 
+        local_address = "f0:1f:af:db:b9:c8";
+        local_port = 50000;     #for raw option local port must be the same to remote          
+        remote_port = 50000;
+        rrh_gw_active = "yes";
+        tr_preference = "raw_if5_mobipass";
+        rf_preference = "usrp_b200";
+        iq_txshift = 4;
+        tx_sample_advance = 80;
+        tx_scheduling_advance = 9;
+    }
+    );
+
+    log_config :
+    {
+      global_log_level                      ="info";
+      global_log_verbosity                  ="medium";
+      hw_log_level                          ="info";
+      hw_log_verbosity                      ="medium";
+      phy_log_level                         ="info";
+      phy_log_verbosity                     ="medium";
+      mac_log_level                         ="info";
+      mac_log_verbosity                     ="high";
+      rlc_log_level                         ="info";
+      rlc_log_verbosity                     ="medium";
+      pdcp_log_level                        ="info";
+      pdcp_log_verbosity                    ="medium";
+      rrc_log_level                         ="info";
+      rrc_log_verbosity                     ="medium";
+   };
+  }
+);
+
+
diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c
index 7d68f0c172..51937b7976 100644
--- a/targets/RT/USER/lte-enb.c
+++ b/targets/RT/USER/lte-enb.c
@@ -145,6 +145,8 @@ time_stats_t softmodem_stats_rx_sf; // total rx time
 int32_t **rxdata;
 int32_t **txdata;
 
+uint8_t seqno; //sequence number
+
 static int                      time_offset[4] = {0,0,0,0};
 
 /* mutex, cond and variable to serialize phy proc TX calls
@@ -288,6 +290,7 @@ void do_OFDM_mod_rt(int subframe,PHY_VARS_eNB *phy_vars_eNB) {
                    ((phy_vars_eNB->frame_parms.Ncp==1) ? 6 : 7);
   int len,len2;
   int16_t *txdata;
+//  int CC_id = phy_vars_eNB->proc.CC_id;
 
   VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_SFGEN , 1 );
 
@@ -406,11 +409,15 @@ void do_OFDM_mod_rt(int subframe,PHY_VARS_eNB *phy_vars_eNB) {
 }
 
 void tx_fh_if5(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) {
-  uint8_t seqno;
   VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, proc->timestamp_tx&0xffffffff );
   send_IF5(eNB, proc->timestamp_tx, proc->subframe_tx, &seqno, IF5_RRH_GW_DL);
 }
 
+void tx_fh_if5_mobipass(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) {
+  VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, proc->timestamp_tx&0xffffffff );
+  send_IF5(eNB, proc->timestamp_tx, proc->subframe_tx, &seqno, IF5_MOBIPASS); 
+}
+
 void tx_fh_if4p5(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) {    
   send_IF4p5(eNB,proc->frame_tx, proc->subframe_tx, IF4p5_PDLFFT, 0);
 }
@@ -552,7 +559,7 @@ static inline int rxtx(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, char *thread_nam
   // run PHY TX procedures the one after the other for all CCs to avoid race conditions
   // (may be relaxed in the future for performance reasons)
   // *****************************************
-  if (wait_CCs(proc)<0) return(-1);
+  //if (wait_CCs(proc)<0) return(-1);
   
   if (oai_exit) return(-1);
   
@@ -879,6 +886,7 @@ void rx_rf(PHY_VARS_eNB *eNB,int *frame,int *subframe) {
   
   proc->frame_rx    = (proc->timestamp_rx / (fp->samples_per_tti*10))&1023;
   proc->subframe_rx = (proc->timestamp_rx / fp->samples_per_tti)%10;
+  proc->timestamp_tx = proc->timestamp_rx+(4*fp->samples_per_tti);
   //  printf("trx_read <- USRP TS %llu (sf %d, first_rx %d)\n", proc->timestamp_rx,proc->subframe_rx,proc->first_rx);  
   
   if (proc->first_rx == 0) {
@@ -965,7 +973,12 @@ void rx_fh_if4p5(PHY_VARS_eNB *eNB,int *frame,int *subframe) {
     }
 
   } while( (symbol_mask != symbol_mask_full) || (prach_rx == 1));    
-  
+
+  //caculate timestamp_rx, timestamp_tx based on frame and subframe
+   proc->timestamp_rx = ((proc->frame_rx * 10)  + proc->subframe_rx ) * fp->samples_per_tti ;
+   proc->timestamp_tx = proc->timestamp_rx +  (4*fp->samples_per_tti);
+ 
+ 
   if (proc->first_rx == 0) {
     if (proc->subframe_rx != *subframe){
       LOG_E(PHY,"Received Timestamp doesn't correspond to the time we think it is (proc->subframe_rx %d, subframe %d)\n",proc->subframe_rx,*subframe);
@@ -1073,7 +1086,8 @@ void wakeup_slaves(eNB_proc_t *proc) {
     slave_proc->frame_rx     = proc->frame_rx;
     slave_proc->subframe_rx  = proc->subframe_rx;
     slave_proc->timestamp_rx = proc->timestamp_rx;
-    
+    slave_proc->timestamp_tx = proc->timestamp_tx; 
+
     pthread_mutex_unlock( &slave_proc->mutex_FH );
     
     if (cnt_slave == 0) {
@@ -1270,15 +1284,16 @@ static void* eNB_thread_single( void* param ) {
 
     T(T_ENB_MASTER_TICK, T_INT(0), T_INT(proc->frame_rx), T_INT(proc->subframe_rx));
 
+    proc_rxtx->subframe_rx = proc->subframe_rx;
+    proc_rxtx->frame_rx    = proc->frame_rx;
+    proc_rxtx->subframe_tx = (proc->subframe_rx+4)%10;
+    proc_rxtx->frame_tx    = (proc->subframe_rx < 6) ? proc->frame_rx : (proc->frame_rx+1)&1023; 
+    proc_rxtx->timestamp_tx = proc->timestamp_tx;
 
     // At this point, all information for subframe has been received on FH interface
     // If this proc is to provide synchronization, do so
     wakeup_slaves(proc);
 
-    proc_rxtx->subframe_rx = proc->subframe_rx;
-    proc_rxtx->frame_rx    = proc->frame_rx;
-    proc_rxtx->subframe_tx = (proc->subframe_rx+4)%10;
-    proc_rxtx->frame_tx    = (proc->subframe_rx < 6) ? proc->frame_rx : (proc->frame_rx+1)&1023; 
     if (rxtx(eNB,proc_rxtx,"eNB_thread_single") < 0) break;
   }
   
@@ -1384,6 +1399,26 @@ void init_eNB_proc(int inst) {
     }
   }
   
+  PHY_vars_eNB_g[inst][0]->proc.num_slaves=1;//hardcoded
+  PHY_vars_eNB_g[inst][0]->proc.slave_proc = (eNB_proc_t**)malloc(1*sizeof(eNB_proc_t*));
+  PHY_vars_eNB_g[inst][0]->proc.slave_proc[0]=&(PHY_vars_eNB_g[inst][1]->proc);
+/*  for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {//TTN - we supposed that CC_id=0 will play the role of master
+    eNB = PHY_vars_eNB_g[inst][CC_id];
+
+    if (eNB->node_timing == synch_to_ext_device) { //CC_id=0
+     // eNB = PHY_vars_eNB_g[inst][CC_id];
+
+      eNB->proc.num_slaves = MAX_NUM_CCs-1;
+      eNB->proc.slave_proc = (eNB_proc_t**)malloc(eNB->proc.num_slaves*sizeof(eNB_proc_t*));
+
+      for (i=0; i< eNB->proc.num_slaves; i++) {
+        eNB->proc.slave_proc[i] = &(PHY_vars_eNB_g[inst][i+1]->proc);
+      }
+    }
+  }
+
+*/
+
   /* setup PHY proc TX sync mechanism */
   pthread_mutex_init(&sync_phy_proc.mutex_phy_proc_tx, NULL);
   pthread_cond_init(&sync_phy_proc.cond_phy_proc_tx, NULL);
@@ -1598,14 +1633,14 @@ void init_eNB(eNB_func_t node_function[], eNB_timing_t node_timing[],int nb_inst
 	eNB->start_rf             = start_rf;
 	eNB->start_if             = start_if;
 	eNB->fh_asynch            = fh_if5_asynch_DL;
-	ret = openair0_device_load(&eNB->rfdevice, &openair0_cfg[0]);
+	ret = openair0_device_load(&eNB->rfdevice, &openair0_cfg[CC_id]);
         if (ret<0) {
           printf("Exiting, cannot initialize rf device\n");
           exit(-1);
         }
 	eNB->rfdevice.host_type   = RRH_HOST;
 	eNB->ifdevice.host_type   = RRH_HOST;
-        ret = openair0_transport_load(&eNB->ifdevice, &openair0_cfg[0], (eth_params+CC_id));
+        ret = openair0_transport_load(&eNB->ifdevice, &openair0_cfg[CC_id], (eth_params+CC_id));
 	printf("openair0_transport_init returns %d for CC_id %d\n",ret,CC_id);
         if (ret<0) {
           printf("Exiting, cannot initialize transport protocol\n");
@@ -1624,14 +1659,14 @@ void init_eNB(eNB_func_t node_function[], eNB_timing_t node_timing[],int nb_inst
 	eNB->fh_asynch            = fh_if4p5_asynch_DL;
 	eNB->start_rf             = start_rf;
 	eNB->start_if             = start_if;
-	ret = openair0_device_load(&eNB->rfdevice, &openair0_cfg[0]);
+	ret = openair0_device_load(&eNB->rfdevice, &openair0_cfg[CC_id]);
         if (ret<0) {
           printf("Exiting, cannot initialize rf device\n");
           exit(-1);
         }
 	eNB->rfdevice.host_type   = RRH_HOST;
 	eNB->ifdevice.host_type   = RRH_HOST;
-        ret = openair0_transport_load(&eNB->ifdevice, &openair0_cfg[0], (eth_params+CC_id));
+        ret = openair0_transport_load(&eNB->ifdevice, &openair0_cfg[CC_id], (eth_params+CC_id));
 	printf("openair0_transport_init returns %d for CC_id %d\n",ret,CC_id);
         if (ret<0) {
           printf("Exiting, cannot initialize transport protocol\n");
@@ -1653,7 +1688,7 @@ void init_eNB(eNB_func_t node_function[], eNB_timing_t node_timing[],int nb_inst
 	eNB->start_rf             = start_rf;
 	eNB->start_if             = NULL;
         eNB->fh_asynch            = NULL;
-	ret = openair0_device_load(&eNB->rfdevice, &openair0_cfg[0]);
+	ret = openair0_device_load(&eNB->rfdevice, &openair0_cfg[CC_id]);
         if (ret<0) {
           printf("Exiting, cannot initialize rf device\n");
           exit(-1);
@@ -1668,9 +1703,17 @@ void init_eNB(eNB_func_t node_function[], eNB_timing_t node_timing[],int nb_inst
 	eNB->te             = dlsch_encoding;//(single_thread_flag==1) ? dlsch_encoding_2threads : dlsch_encoding;
 	eNB->proc_uespec_rx = phy_procedures_eNB_uespec_RX;
 	eNB->proc_tx        = proc_tx_full;
-	eNB->tx_fh          = tx_fh_if5;
-	eNB->rx_fh          = rx_fh_if5;
-        eNB->fh_asynch      = (eNB->node_timing == synch_to_other) ? fh_if5_asynch_UL : NULL;
+        if (eNB->node_timing == synch_to_other) {
+           eNB->tx_fh          = tx_fh_if5_mobipass;
+           eNB->rx_fh          = rx_fh_slave;
+           eNB->fh_asynch      = fh_if5_asynch_UL;
+
+        }
+        else {
+           eNB->tx_fh          = tx_fh_if5;
+           eNB->rx_fh          = rx_fh_if5;
+           eNB->fh_asynch      = NULL;
+        }
 
 	eNB->start_rf       = NULL;
 	eNB->start_if       = start_if;
@@ -1678,7 +1721,7 @@ void init_eNB(eNB_func_t node_function[], eNB_timing_t node_timing[],int nb_inst
 
 	eNB->ifdevice.host_type   = BBU_HOST;
 
-        ret = openair0_transport_load(&eNB->ifdevice, &openair0_cfg[0], (eth_params+CC_id));
+        ret = openair0_transport_load(&eNB->ifdevice, &openair0_cfg[CC_id], (eth_params+CC_id));
         printf("openair0_transport_init returns %d for CC_id %d\n",ret,CC_id);
         if (ret<0) {
           printf("Exiting, cannot initialize transport protocol\n");
@@ -1699,7 +1742,7 @@ void init_eNB(eNB_func_t node_function[], eNB_timing_t node_timing[],int nb_inst
         eNB->fh_asynch            = (eNB->node_timing == synch_to_other) ? fh_if4p5_asynch_UL : NULL;
 	eNB->rfdevice.host_type   = BBU_HOST;
 	eNB->ifdevice.host_type   = BBU_HOST;
-        ret = openair0_transport_load(&eNB->ifdevice, &openair0_cfg[0], (eth_params+CC_id));
+        ret = openair0_transport_load(&eNB->ifdevice, &openair0_cfg[CC_id], (eth_params+CC_id));
         printf("openair0_transport_init returns %d for CC_id %d\n",ret,CC_id);
         if (ret<0) {
           printf("Exiting, cannot initialize transport protocol\n");
@@ -1724,7 +1767,7 @@ void init_eNB(eNB_func_t node_function[], eNB_timing_t node_timing[],int nb_inst
 
 	eNB->rfdevice.host_type   = BBU_HOST;
 	eNB->ifdevice.host_type   = BBU_HOST;
-        ret = openair0_transport_load(&eNB->ifdevice, &openair0_cfg[0], (eth_params+CC_id));
+        ret = openair0_transport_load(&eNB->ifdevice, &openair0_cfg[CC_id], (eth_params+CC_id));
         printf("openair0_transport_init returns %d for CC_id %d\n",ret,CC_id);
         if (ret<0) {
           printf("Exiting, cannot initialize transport protocol\n");
@@ -1736,7 +1779,7 @@ void init_eNB(eNB_func_t node_function[], eNB_timing_t node_timing[],int nb_inst
       }
     }
 
-    if (setup_eNB_buffers(PHY_vars_eNB_g[inst],&openair0_cfg[inst])!=0) {
+    if (setup_eNB_buffers(PHY_vars_eNB_g[inst],&openair0_cfg[CC_id])!=0) {
       printf("Exiting, cannot initialize eNodeB Buffers\n");
       exit(-1);
     }
diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c
index 390c2ac13f..d2ba49dcac 100644
--- a/targets/RT/USER/lte-softmodem.c
+++ b/targets/RT/USER/lte-softmodem.c
@@ -1066,7 +1066,7 @@ static void get_options (int argc, char **argv)
         	
         if (enb_properties->properties[i]->rrh_gw_config[j].active == 1 ) {
           local_remote_radio = BBU_REMOTE_RADIO_HEAD;
-          (eth_params+j)->local_if_name             = enb_properties->properties[i]->rrh_gw_if_name;
+          (eth_params+j)->local_if_name             = enb_properties->properties[i]->rrh_gw_config[j].rrh_gw_if_name;
           (eth_params+j)->my_addr                   = enb_properties->properties[i]->rrh_gw_config[j].local_address;
           (eth_params+j)->my_port                   = enb_properties->properties[i]->rrh_gw_config[j].local_port;
           (eth_params+j)->remote_addr               = enb_properties->properties[i]->rrh_gw_config[j].remote_address;
@@ -1306,10 +1306,10 @@ void init_openair0() {
 
     
     if (local_remote_radio == BBU_REMOTE_RADIO_HEAD) {      
-      openair0_cfg[card].remote_addr    = eth_params->remote_addr;
-      openair0_cfg[card].remote_port    = eth_params->remote_port;
-      openair0_cfg[card].my_addr        = eth_params->my_addr;
-      openair0_cfg[card].my_port        = eth_params->my_port;    
+      openair0_cfg[card].remote_addr    = (eth_params+card)->remote_addr;
+      openair0_cfg[card].remote_port    = (eth_params+card)->remote_port;
+      openair0_cfg[card].my_addr        = (eth_params+card)->my_addr;
+      openair0_cfg[card].my_port        = (eth_params+card)->my_port;    
     } 
     
     printf("HW: Configuring card %d, nb_antennas_tx/rx %d/%d\n",card,
-- 
GitLab