From 14d28e2dbd25cd8a1614fe97d8bebe788cea56ec Mon Sep 17 00:00:00 2001
From: "Raymond.Knopp" <raymond.knopp@eurecom.fr>
Date: Sat, 7 Jan 2017 12:41:36 +0100
Subject: [PATCH] fixes for precoding (turning off if nb_antennas_tx=1),
 configuration files, timing advance with 3/4 sampling on 20 MHz, logging in
 MAC

---
 openair1/PHY/LTE_TRANSPORT/prach.c            |  9 ++++--
 openair1/PHY/MODULATION/beamforming.c         | 27 ++++++++--------
 openair1/SCHED/phy_procedures_lte_eNb.c       | 11 ++++---
 openair2/LAYER2/MAC/eNB_scheduler.c           |  5 +--
 openair2/LAYER2/MAC/pre_processor.c           |  5 ++-
 .../CONF/enb.band7.tm1.100PRB.usrpb210.conf   |  6 ++--
 .../CONF/enb.band7.tm1.50PRB.usrpb210.conf    |  4 +--
 .../CONF/rcc.band7.tm1.if4p5.25PRB.conf       |  2 +-
 .../CONF/rcc.band7.tm1.if4p5.50PRB.conf       |  2 +-
 targets/RT/USER/lte-enb.c                     | 32 +++++++++----------
 10 files changed, 57 insertions(+), 46 deletions(-)

diff --git a/openair1/PHY/LTE_TRANSPORT/prach.c b/openair1/PHY/LTE_TRANSPORT/prach.c
index 33780a7def..489fdb0f71 100644
--- a/openair1/PHY/LTE_TRANSPORT/prach.c
+++ b/openair1/PHY/LTE_TRANSPORT/prach.c
@@ -1185,9 +1185,7 @@ void rx_prach(PHY_VARS_eNB *eNB,
     break;
   }
 
-  if (eNB->frame_parms.threequarter_fs == 1)
-    Ncp=(Ncp*3)>>2;
-
+  // Adjust CP length based on UL bandwidth
   switch (eNB->frame_parms.N_RB_UL) {
   case 6:
     Ncp>>=4;
@@ -1208,6 +1206,11 @@ void rx_prach(PHY_VARS_eNB *eNB,
   case 75:
     Ncp=(Ncp*3)>>2;
     break;
+
+  case 100:
+    if (eNB->frame_parms.threequarter_fs == 1)
+      Ncp=(Ncp*3)>>2;
+    break;
   }
 
 
diff --git a/openair1/PHY/MODULATION/beamforming.c b/openair1/PHY/MODULATION/beamforming.c
index 6557a47ee7..4f2f7535e9 100644
--- a/openair1/PHY/MODULATION/beamforming.c
+++ b/openair1/PHY/MODULATION/beamforming.c
@@ -66,24 +66,25 @@ int beam_precoding(int32_t **txdataF,
   for (p=0; p<14; p++) {
     //if (p==0 || p==1 || p==5 || p>7)
     //  mult_cpx_conj_vector((int16_t*)txdataF[p], (int16_t*)beam_weights[p][aa], (int16_t*)txdataF_BF[aa], frame_parms->ofdm_symbol_size, 15);
-    for (re=0;re<frame_parms->ofdm_symbol_size;re++) {
-      if ((p==0 || p==1 || p==5 || p>=7) && txdataF[p][slot_offset_F+symbol*frame_parms->ofdm_symbol_size+re]!=0) {
+    if (txdataF[p]) {//[slot_offset_F+symbol*frame_parms->ofdm_symbol_size+re]!=0) {
+
+      for (re=0;re<frame_parms->ofdm_symbol_size;re++) {
         ((int16_t*)&txdataF_BF[aa][re])[0] += (int16_t)((((int16_t*)&txdataF[p][slot_offset_F+symbol*frame_parms->ofdm_symbol_size+re])[0]*((int16_t*)&beam_weights[p][aa][re])[0])>>15);
         ((int16_t*)&txdataF_BF[aa][re])[0] -= (int16_t)((((int16_t*)&txdataF[p][slot_offset_F+symbol*frame_parms->ofdm_symbol_size+re])[1]*((int16_t*)&beam_weights[p][aa][re])[1])>>15);
         ((int16_t*)&txdataF_BF[aa][re])[1] += (int16_t)((((int16_t*)&txdataF[p][slot_offset_F+symbol*frame_parms->ofdm_symbol_size+re])[0]*((int16_t*)&beam_weights[p][aa][re])[1])>>15);
         ((int16_t*)&txdataF_BF[aa][re])[1] += (int16_t)((((int16_t*)&txdataF[p][slot_offset_F+symbol*frame_parms->ofdm_symbol_size+re])[1]*((int16_t*)&beam_weights[p][aa][re])[0])>>15);
-
-	  /*
+	
+	/*
           printf("beamforming.c:txdataF[%d][%d]=%d+j%d, beam_weights[%d][%d][%d]=%d+j%d,txdata_BF[%d][%d]=%d+j%d\n",
-                 p,slot_offset_F+symbol*frame_parms->ofdm_symbol_size+re,
-                 ((int16_t*)&txdataF[p][slot_offset_F+symbol*frame_parms->ofdm_symbol_size+re])[0],
-                 ((int16_t*)&txdataF[p][slot_offset_F+symbol*frame_parms->ofdm_symbol_size+re])[1],
-                 p,aa,re,
-                 ((int16_t*)&beam_weights[p][aa][re])[0],((int16_t*)&beam_weights[p][aa][re])[1],
-                 aa,re,
-                 ((int16_t*)&txdataF_BF[aa][re])[0],
-                 ((int16_t*)&txdataF_BF[aa][re])[1]); 
-	  */
+	  p,slot_offset_F+symbol*frame_parms->ofdm_symbol_size+re,
+	  ((int16_t*)&txdataF[p][slot_offset_F+symbol*frame_parms->ofdm_symbol_size+re])[0],
+	  ((int16_t*)&txdataF[p][slot_offset_F+symbol*frame_parms->ofdm_symbol_size+re])[1],
+	  p,aa,re,
+	  ((int16_t*)&beam_weights[p][aa][re])[0],((int16_t*)&beam_weights[p][aa][re])[1],
+	  aa,re,
+	  ((int16_t*)&txdataF_BF[aa][re])[0],
+	  ((int16_t*)&txdataF_BF[aa][re])[1]); 
+	*/
       } 
     }
   }
diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c
index 85c822e273..50fd920262 100644
--- a/openair1/SCHED/phy_procedures_lte_eNb.c
+++ b/openair1/SCHED/phy_procedures_lte_eNb.c
@@ -2032,8 +2032,8 @@ void prach_procedures(PHY_VARS_eNB *eNB) {
         T_INT(preamble_max), T_INT(preamble_energy_max), T_INT(preamble_delay_list[preamble_max]));
 
       if (eNB->mac_enabled==1) {
-        uint8_t update_TA=4;
-
+        uint8_t update_TA  = 4;
+	uint8_t update_TA2 = 1;
         switch (fp->N_RB_DL) {
         case 6:
           update_TA = 16;
@@ -2047,8 +2047,11 @@ void prach_procedures(PHY_VARS_eNB *eNB) {
           update_TA = 2;
           break;
 
+	case 75:
+	  update_TA  = 3;
+	  update_TA2 = 2;
         case 100:
-          update_TA = 1;
+          update_TA  = 1;
           break;
         }
 
@@ -2056,7 +2059,7 @@ void prach_procedures(PHY_VARS_eNB *eNB) {
 				    eNB->CC_id,
 				    frame,
 				    preamble_max,
-				    preamble_delay_list[preamble_max]*update_TA,
+				    preamble_delay_list[preamble_max]*update_TA/update_TA2,
 				    0,subframe,0);
       }      
 
diff --git a/openair2/LAYER2/MAC/eNB_scheduler.c b/openair2/LAYER2/MAC/eNB_scheduler.c
index c5dc8c88b0..9a3a8f637e 100644
--- a/openair2/LAYER2/MAC/eNB_scheduler.c
+++ b/openair2/LAYER2/MAC/eNB_scheduler.c
@@ -128,8 +128,9 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP,uint8_t cooperation_flag,
     rnti = UE_RNTI(module_idP, i);
     CC_id = UE_PCCID(module_idP, i);
     if ((frameP==0)&&(subframeP==0))
-      LOG_I(MAC,"UE  rnti %x : %s\n", rnti, 
-	    UE_list->UE_sched_ctrl[i].ul_out_of_sync==0 ? "in synch" : "out of sync");
+      LOG_I(MAC,"UE  rnti %x : %s, PHR %d dB\n", rnti, 
+	    UE_list->UE_sched_ctrl[i].ul_out_of_sync==0 ? "in synch" : "out of sync",
+	    UE_list->UE_template[CC_id][i].phr_info);
 
     next_i= UE_list->next[i];
 
diff --git a/openair2/LAYER2/MAC/pre_processor.c b/openair2/LAYER2/MAC/pre_processor.c
index ed12d322c1..5024aa605d 100644
--- a/openair2/LAYER2/MAC/pre_processor.c
+++ b/openair2/LAYER2/MAC/pre_processor.c
@@ -791,7 +791,10 @@ void dlsch_scheduler_pre_processor_reset (int module_idP,
       break;
       
     case 100:
-      ue_sched_ctl->ta_update = eNB_UE_stats->timing_advance_update/16;
+      if (PHY_vars_eNB_g[module_idP][CC_id]->frame_parms.threequarter_fs == 0)
+	ue_sched_ctl->ta_update = eNB_UE_stats->timing_advance_update/16;
+      else
+	ue_sched_ctl->ta_update = eNB_UE_stats->timing_advance_update/12;
       break;
     }
     // clear the update in case PHY does not have a new measurement after timer expiry
diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.100PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.100PRB.usrpb210.conf
index f4ed76a21e..c974345888 100644
--- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.100PRB.usrpb210.conf
+++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.100PRB.usrpb210.conf
@@ -31,7 +31,7 @@ eNBs =
         tdd_config_s            			      = 0;
         prefix_type             			      = "NORMAL";
         eutra_band              			      = 7;
-        downlink_frequency      			      = 2660000000L;
+        downlink_frequency      			      = 2680000000L;
         uplink_frequency_offset 			      = -120000000;
         Nid_cell					      = 0;
         N_RB_DL                 			      = 100;
@@ -70,7 +70,7 @@ eNBs =
 
         pusch_p0_Nominal                                   = -96;
         pusch_alpha                                        = "AL1";
-        pucch_p0_Nominal                                   = -100;
+        pucch_p0_Nominal                                   = -104;
         msg3_delta_Preamble                                = 6;
         pucch_deltaF_Format1                               = "deltaF2";
         pucch_deltaF_Format1b                              = "deltaF3";
@@ -149,7 +149,7 @@ eNBs =
         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_IPV4_ADDRESS_FOR_S1U                 = "127.0.0.5/24";
         ENB_PORT_FOR_S1U                         = 2152; # Spec 2152
     };
 
diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.usrpb210.conf
index bcf1c15a4a..3cf1e7d15b 100644
--- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.usrpb210.conf
+++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.usrpb210.conf
@@ -31,7 +31,7 @@ eNBs =
         tdd_config_s            			      = 0;
         prefix_type             			      = "NORMAL";
         eutra_band              			      = 7;
-        downlink_frequency      			      = 2660000000L;
+        downlink_frequency      			      = 2685000000L;
         uplink_frequency_offset 			      = -120000000;
         Nid_cell					      = 0;
         N_RB_DL                 			      = 50;
@@ -149,7 +149,7 @@ eNBs =
         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_IPV4_ADDRESS_FOR_S1U                 = "127.0.0.5/24";
         ENB_PORT_FOR_S1U                         = 2152; # Spec 2152
     };
 
diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.25PRB.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.25PRB.conf
index 5bdfcc7a12..f9ebec3ab5 100644
--- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.25PRB.conf
+++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.25PRB.conf
@@ -150,7 +150,7 @@ eNBs =
         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_IPV4_ADDRESS_FOR_S1U                 = "127.0.0.5/24";
         ENB_PORT_FOR_S1U                         = 2152; # Spec 2152
     };
 
diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.50PRB.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.50PRB.conf
index 886d88eab1..4ad5767ce9 100644
--- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.50PRB.conf
+++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.50PRB.conf
@@ -151,7 +151,7 @@ eNBs =
         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_IPV4_ADDRESS_FOR_S1U                 = "127.0.0.5/24";
         ENB_PORT_FOR_S1U                         = 2152; # Spec 2152
     };
 
diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c
index 99e05a39bf..8a01179567 100644
--- a/targets/RT/USER/lte-enb.c
+++ b/targets/RT/USER/lte-enb.c
@@ -1964,7 +1964,7 @@ void init_eNB(eNB_func_t node_function[], eNB_timing_t node_timing[],int nb_inst
 
 	break;
       case eNodeB_3GPP:
-	eNB->do_precoding         = 1;
+	eNB->do_precoding         = (eNB->frame_parms.nb_antenna_ports_eNB==1) ? 0 : 1;
 	eNB->do_prach             = do_prach;
 	eNB->fep                  = eNB_fep_full;//(single_thread_flag==1) ? eNB_fep_full_2thread : eNB_fep_full;
 	eNB->td                   = ulsch_decoding_data;//(single_thread_flag==1) ? ulsch_decoding_data_2thread : ulsch_decoding_data;
@@ -1985,27 +1985,27 @@ void init_eNB(eNB_func_t node_function[], eNB_timing_t node_timing[],int nb_inst
 	eNB->ifdevice.host_type   = BBU_HOST;
 	break;
       case eNodeB_3GPP_BBU:
-	eNB->do_precoding   = 1;
-	eNB->do_prach       = do_prach;
-	eNB->fep            = eNB_fep_full;//(single_thread_flag==1) ? eNB_fep_full_2thread : eNB_fep_full;
-	eNB->td             = ulsch_decoding_data;//(single_thread_flag==1) ? ulsch_decoding_data_2thread : ulsch_decoding_data;
-	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->do_precoding         = (eNB->frame_parms.nb_antenna_ports_eNB==1) ? 0 : 1;
+	eNB->do_prach             = do_prach;
+	eNB->fep                  = eNB_fep_full;//(single_thread_flag==1) ? eNB_fep_full_2thread : eNB_fep_full;
+	eNB->td                   = ulsch_decoding_data;//(single_thread_flag==1) ? ulsch_decoding_data_2thread : ulsch_decoding_data;
+	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;
         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;
+           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->tx_fh             = tx_fh_if5;
+           eNB->rx_fh             = rx_fh_if5;
+           eNB->fh_asynch         = NULL;
         }
 
-	eNB->start_rf       = NULL;
-	eNB->start_if       = start_if;
+	eNB->start_rf             = NULL;
+	eNB->start_if             = start_if;
 	eNB->rfdevice.host_type   = BBU_HOST;
 
 	eNB->ifdevice.host_type   = BBU_HOST;
-- 
GitLab