Merge remote-tracking branch 'origin/develop' into feature-127-protocol-split

OAISIM NoS1 broken, needs fixing (no linking of libraries for the UE code)
This commit is contained in:
Nikos Makris
2018-02-02 20:21:34 +02:00
2388 changed files with 425329 additions and 575134 deletions
+57 -76
View File
@@ -1,31 +1,24 @@
/*******************************************************************************
OpenAirInterface
Copyright(c) 1999 - 2014 Eurecom
/*
* Licensed to the OpenAirInterface (OAI) Software Alliance under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The OpenAirInterface Software Alliance licenses this file to You under
* the OAI Public License, Version 1.1 (the "License"); you may not use this file
* except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.openairinterface.org/?page_id=698
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*-------------------------------------------------------------------------------
* For more information about the OpenAirInterface (OAI) Software Alliance:
* contact@openairinterface.org
*/
OpenAirInterface is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
OpenAirInterface is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with OpenAirInterface.The full GNU General Public License is
included in this distribution in the file called "COPYING". If not,
see <http://www.gnu.org/licenses/>.
Contact Information
OpenAirInterface Admin: openair_admin@eurecom.fr
OpenAirInterface Tech : openair_tech@eurecom.fr
OpenAirInterface Dev : openair4g-devel@lists.eurecom.fr
Address : Eurecom, Campus SophiaTech, 450 Route des Chappes, CS 50193 - 06904 Biot Sophia Antipolis cedex, FRANCE
*******************************************************************************/
/* file: lte_sync_time.c
purpose: coarse timing synchronization for LTE (using PSS)
author: florian.kaltenberger@eurecom.fr, oscar.tonelli@yahoo.it
@@ -66,31 +59,31 @@ int lte_sync_time_init(LTE_DL_FRAME_PARMS *frame_parms ) // LTE_UE_COMMON *com
if (sync_corr_ue0) {
#ifdef DEBUG_PHY
msg("[openair][LTE_PHY][SYNC] sync_corr_ue allocated at %p\n", sync_corr_ue0);
LOG_D(PHY,"[openair][LTE_PHY][SYNC] sync_corr_ue allocated at %p\n", sync_corr_ue0);
#endif
//common_vars->sync_corr = sync_corr;
} else {
msg("[openair][LTE_PHY][SYNC] sync_corr_ue0 not allocated\n");
LOG_E(PHY,"[openair][LTE_PHY][SYNC] sync_corr_ue0 not allocated\n");
return(-1);
}
if (sync_corr_ue1) {
#ifdef DEBUG_PHY
msg("[openair][LTE_PHY][SYNC] sync_corr_ue allocated at %p\n", sync_corr_ue1);
LOG_D(PHY,"[openair][LTE_PHY][SYNC] sync_corr_ue allocated at %p\n", sync_corr_ue1);
#endif
//common_vars->sync_corr = sync_corr;
} else {
msg("[openair][LTE_PHY][SYNC] sync_corr_ue1 not allocated\n");
LOG_E(PHY,"[openair][LTE_PHY][SYNC] sync_corr_ue1 not allocated\n");
return(-1);
}
if (sync_corr_ue2) {
#ifdef DEBUG_PHY
msg("[openair][LTE_PHY][SYNC] sync_corr_ue allocated at %p\n", sync_corr_ue2);
LOG_D(PHY,"[openair][LTE_PHY][SYNC] sync_corr_ue allocated at %p\n", sync_corr_ue2);
#endif
//common_vars->sync_corr = sync_corr;
} else {
msg("[openair][LTE_PHY][SYNC] sync_corr_ue2 not allocated\n");
LOG_E(PHY,"[openair][LTE_PHY][SYNC] sync_corr_ue2 not allocated\n");
return(-1);
}
@@ -101,10 +94,10 @@ int lte_sync_time_init(LTE_DL_FRAME_PARMS *frame_parms ) // LTE_UE_COMMON *com
// bzero(primary_synch0_time,(frame_parms->ofdm_symbol_size+frame_parms->nb_prefix_samples)*sizeof(int));
bzero(primary_synch0_time,(frame_parms->ofdm_symbol_size)*sizeof(int16_t)*2);
#ifdef DEBUG_PHY
msg("[openair][LTE_PHY][SYNC] primary_synch0_time allocated at %p\n", primary_synch0_time);
LOG_D(PHY,"[openair][LTE_PHY][SYNC] primary_synch0_time allocated at %p\n", primary_synch0_time);
#endif
} else {
msg("[openair][LTE_PHY][SYNC] primary_synch0_time not allocated\n");
LOG_E(PHY,"[openair][LTE_PHY][SYNC] primary_synch0_time not allocated\n");
return(-1);
}
@@ -115,10 +108,10 @@ int lte_sync_time_init(LTE_DL_FRAME_PARMS *frame_parms ) // LTE_UE_COMMON *com
// bzero(primary_synch1_time,(frame_parms->ofdm_symbol_size+frame_parms->nb_prefix_samples)*sizeof(int));
bzero(primary_synch1_time,(frame_parms->ofdm_symbol_size)*sizeof(int16_t)*2);
#ifdef DEBUG_PHY
msg("[openair][LTE_PHY][SYNC] primary_synch1_time allocated at %p\n", primary_synch1_time);
LOG_D(PHY,"[openair][LTE_PHY][SYNC] primary_synch1_time allocated at %p\n", primary_synch1_time);
#endif
} else {
msg("[openair][LTE_PHY][SYNC] primary_synch1_time not allocated\n");
LOG_E(PHY,"[openair][LTE_PHY][SYNC] primary_synch1_time not allocated\n");
return(-1);
}
@@ -129,10 +122,10 @@ int lte_sync_time_init(LTE_DL_FRAME_PARMS *frame_parms ) // LTE_UE_COMMON *com
// bzero(primary_synch2_time,(frame_parms->ofdm_symbol_size+frame_parms->nb_prefix_samples)*sizeof(int));
bzero(primary_synch2_time,(frame_parms->ofdm_symbol_size)*sizeof(int16_t)*2);
#ifdef DEBUG_PHY
msg("[openair][LTE_PHY][SYNC] primary_synch2_time allocated at %p\n", primary_synch2_time);
LOG_D(PHY,"[openair][LTE_PHY][SYNC] primary_synch2_time allocated at %p\n", primary_synch2_time);
#endif
} else {
msg("[openair][LTE_PHY][SYNC] primary_synch2_time not allocated\n");
LOG_E(PHY,"[openair][LTE_PHY][SYNC] primary_synch2_time not allocated\n");
return(-1);
}
@@ -299,32 +292,32 @@ void lte_sync_time_free(void)
if (sync_corr_ue0) {
msg("Freeing sync_corr_ue (%p)...\n",sync_corr_ue0);
LOG_D(PHY,"Freeing sync_corr_ue (%p)...\n",sync_corr_ue0);
free(sync_corr_ue0);
}
if (sync_corr_ue1) {
msg("Freeing sync_corr_ue (%p)...\n",sync_corr_ue1);
LOG_D(PHY,"Freeing sync_corr_ue (%p)...\n",sync_corr_ue1);
free(sync_corr_ue1);
}
if (sync_corr_ue2) {
msg("Freeing sync_corr_ue (%p)...\n",sync_corr_ue2);
LOG_D(PHY,"Freeing sync_corr_ue (%p)...\n",sync_corr_ue2);
free(sync_corr_ue2);
}
if (primary_synch0_time) {
msg("Freeing primary_sync0_time ...\n");
LOG_D(PHY,"Freeing primary_sync0_time ...\n");
free(primary_synch0_time);
}
if (primary_synch1_time) {
msg("Freeing primary_sync1_time ...\n");
LOG_D(PHY,"Freeing primary_sync1_time ...\n");
free(primary_synch1_time);
}
if (primary_synch2_time) {
msg("Freeing primary_sync2_time ...\n");
LOG_D(PHY,"Freeing primary_sync2_time ...\n");
free(primary_synch2_time);
}
@@ -362,19 +355,19 @@ int lte_sync_time(int **rxdata, ///rx data in time domain
int tmp[3] = {0,0,0};
int length = LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*frame_parms->samples_per_tti>>1;
//msg("[SYNC TIME] Calling sync_time.\n");
//LOG_D(PHY,"[SYNC TIME] Calling sync_time.\n");
if (sync_corr_ue0 == NULL) {
msg("[SYNC TIME] sync_corr_ue0 not yet allocated! Exiting.\n");
LOG_E(PHY,"[SYNC TIME] sync_corr_ue0 not yet allocated! Exiting.\n");
return(-1);
}
if (sync_corr_ue1 == NULL) {
msg("[SYNC TIME] sync_corr_ue1 not yet allocated! Exiting.\n");
LOG_E(PHY,"[SYNC TIME] sync_corr_ue1 not yet allocated! Exiting.\n");
return(-1);
}
if (sync_corr_ue2 == NULL) {
msg("[SYNC TIME] sync_corr_ue2 not yet allocated! Exiting.\n");
LOG_E(PHY,"[SYNC TIME] sync_corr_ue2 not yet allocated! Exiting.\n");
return(-1);
}
@@ -385,18 +378,6 @@ int lte_sync_time(int **rxdata, ///rx data in time domain
for (n=0; n<length; n+=4) {
#ifdef RTAI_ENABLED
// This is necessary since the sync takes a long time and it seems to block all other threads thus screwing up RTAI. If we pause it for a little while during its execution we give RTAI a chance to catch up with its other tasks.
if ((n%frame_parms->samples_per_tti == 0) && (n>0) && (openair_daq_vars.sync_state==0)) {
#ifdef DEBUG_PHY
msg("[SYNC TIME] pausing for 1000ns, n=%d\n",n);
#endif
rt_sleep(nano2count(1000));
}
#endif
sync_corr_ue0[n] = 0;
sync_corr_ue0[n+length] = 0;
sync_corr_ue1[n] = 0;
@@ -484,7 +465,7 @@ int lte_sync_time(int **rxdata, ///rx data in time domain
*eNB_id = sync_source;
LOG_D(PHY,"[UE] lte_sync_time: Sync source = %d, Peak found at pos %d, val = %d (%d dB)\n",sync_source,peak_pos,peak_val,dB_fixed(peak_val)/2);
LOG_I(PHY,"[UE] lte_sync_time: Sync source = %d, Peak found at pos %d, val = %d (%d dB)\n",sync_source,peak_pos,peak_val,dB_fixed(peak_val)/2);
#ifdef DEBUG_PHY
@@ -517,14 +498,15 @@ int lte_sync_time_eNB(int32_t **rxdata, ///rx data in time domain
// perform a time domain correlation using the oversampled sync sequence
unsigned int n, ar, peak_val, peak_pos, mean_val;
unsigned int n, ar, peak_val, peak_pos;
uint64_t mean_val;
int result;
short *primary_synch_time;
int eNB_id = frame_parms->Nid_cell%3;
// msg("[SYNC TIME] Calling sync_time_eNB(%p,%p,%d,%d)\n",rxdata,frame_parms,eNB_id,length);
// LOG_E(PHY,"[SYNC TIME] Calling sync_time_eNB(%p,%p,%d,%d)\n",rxdata,frame_parms,eNB_id,length);
if (sync_corr_eNB == NULL) {
msg("[SYNC TIME] sync_corr_eNB not yet allocated! Exiting.\n");
LOG_E(PHY,"[SYNC TIME] sync_corr_eNB not yet allocated! Exiting.\n");
return(-1);
}
@@ -542,7 +524,7 @@ int lte_sync_time_eNB(int32_t **rxdata, ///rx data in time domain
break;
default:
msg("[SYNC TIME] Illegal eNB_id!\n");
LOG_E(PHY,"[SYNC TIME] Illegal eNB_id!\n");
return (-1);
}
@@ -574,7 +556,7 @@ int lte_sync_time_eNB(int32_t **rxdata, ///rx data in time domain
peak_val);
}
*/
mean_val += (sync_corr_eNB[n]>>10);
mean_val += sync_corr_eNB[n];
if (sync_corr_eNB[n]>peak_val) {
peak_val = sync_corr_eNB[n];
@@ -582,17 +564,15 @@ int lte_sync_time_eNB(int32_t **rxdata, ///rx data in time domain
}
}
mean_val/=length;
*peak_val_out = peak_val;
if (peak_val <= (40*mean_val)) {
#ifdef DEBUG_PHY
msg("[SYNC TIME] No peak found (%u,%u,%u,%u)\n",peak_pos,peak_val,mean_val,40*mean_val);
#endif
if (peak_val <= (40*(uint32_t)mean_val)) {
LOG_D(PHY,"[SYNC TIME] No peak found (%u,%u,%"PRIu64",%"PRIu64")\n",peak_pos,peak_val,mean_val,40*mean_val);
return(-1);
} else {
#ifdef DEBUG_PHY
msg("[SYNC TIME] Peak found at pos %u, val = %u, mean_val = %u\n",peak_pos,peak_val,mean_val);
#endif
LOG_D(PHY,"[SYNC TIME] Peak found at pos %u, val = %u, mean_val = %"PRIu64"\n",peak_pos,peak_val,mean_val);
return(peak_pos);
}
@@ -611,11 +591,11 @@ int lte_sync_time_eNB_emul(PHY_VARS_eNB *phy_vars_eNB,
uint8_t UE_id;
uint8_t CC_id = phy_vars_eNB->CC_id;
msg("[PHY] EMUL lte_sync_time_eNB_emul eNB %d, sect_id %d\n",phy_vars_eNB->Mod_id,sect_id);
LOG_E(PHY,"[PHY] EMUL lte_sync_time_eNB_emul eNB %d, sect_id %d\n",phy_vars_eNB->Mod_id,sect_id);
*sync_val = 0;
for (UE_id=0; UE_id<NB_UE_INST; UE_id++) {
//msg("[PHY] EMUL : eNB %d checking UE %d (PRACH %d) PL %d dB\n",phy_vars_eNB->Mod_id,UE_id,PHY_vars_UE_g[UE_id]->generate_prach,UE2eNB[UE_id][phy_vars_eNB->Mod_id]->path_loss_dB);
//LOG_E(PHY,"[PHY] EMUL : eNB %d checking UE %d (PRACH %d) PL %d dB\n",phy_vars_eNB->Mod_id,UE_id,PHY_vars_UE_g[UE_id]->generate_prach,UE2eNB[UE_id][phy_vars_eNB->Mod_id]->path_loss_dB);
if ((PHY_vars_UE_g[UE_id][CC_id]->generate_prach == 1) && (phy_vars_eNB->Mod_id == (UE_id % NB_eNB_INST))) {
*sync_val = 1;
return(0);
@@ -625,3 +605,4 @@ int lte_sync_time_eNB_emul(PHY_VARS_eNB *phy_vars_eNB,
return(-1);
}
#endif