Merge remote-tracking branch 'origin/develop' into x2

Conflicts:
	cmake_targets/CMakeLists.txt
	openair2/ENB_APP/enb_app.c
	openair2/X2AP/x2ap_common.h
This commit is contained in:
Konstantinos Alexandris
2018-09-07 15:30:49 +02:00
125 changed files with 6054 additions and 3311 deletions
+1 -1
View File
@@ -100,7 +100,7 @@ int load_lib(openair0_device *device, openair0_config_t *openair0_cfg, eth_param
libname=OAI_TP_LIBNAME;
shlib_fdesc[0].fname="transport_init";
}
ret=load_module_shlib(libname,shlib_fdesc,1);
ret=load_module_shlib(libname,shlib_fdesc,1,NULL);
if (ret < 0) {
fprintf(stderr,"Library %s couldn't be loaded\n",libname);
} else {
+2
View File
@@ -199,6 +199,8 @@ typedef struct {
double tx_bw;
//! clock source
clock_source_t clock_source;
//! Manual SDR IP address
char *sdr_addrs;
//! Auto calibration flag
int autocal[4];
//! rf devices work with x bits iqs when oai have its own iq format
+51 -18
View File
@@ -950,11 +950,15 @@ int trx_usrp_recplay_config_init(paramdef_t *usrp_recplay_params) {
#endif
extern "C" {
/*! \brief Initialize Openair USRP target. It returns 0 if OK
* \param device the hardware to use
* \param openair0_cfg RF frontend parameters set by application
*/
int device_init(openair0_device* device, openair0_config_t *openair0_cfg) {
/*! \brief Initialize Openair USRP target. It returns 0 if OK
* \param device the hardware to use
* \param openair0_cfg RF frontend parameters set by application
*/
int device_init(openair0_device* device, openair0_config_t *openair0_cfg) {
LOG_D(PHY, "openair0_cfg[0].sdr_addrs == '%s'\n", openair0_cfg[0].sdr_addrs);
LOG_D(PHY, "openair0_cfg[0].clock_source == '%d'\n", openair0_cfg[0].clock_source);
#if defined(USRP_REC_PLAY)
paramdef_t usrp_recplay_params[7];
struct sysinfo systeminfo;
@@ -1022,8 +1026,30 @@ extern "C" {
// Initialize USRP device
device->openair0_cfg = openair0_cfg;
std::string args = "type=b200";
uhd::device_addrs_t device_adds = uhd::device::find(args);
std::string args = "type=b200";
char *addr_args = NULL;
// Check whether sdr_addrs is set in the config or not
if (openair0_cfg[0].sdr_addrs != NULL) {
if (strcmp(openair0_cfg[0].sdr_addrs, "0.0.0.0") != 0) {
// Check whether sdr_addrs contains multiple IP addresses
// and split and add them to addr_args
if (strstr(openair0_cfg[0].sdr_addrs, ",") != NULL) {
char *addr0 = openair0_cfg[0].sdr_addrs;
// Replace , with \0
strsep(&openair0_cfg[0].sdr_addrs, ",");
char *addr1 = openair0_cfg[0].sdr_addrs;
// Allocate memory for ",addr0=,addr1=\0" and the addresses
size_t addr_args_len = sizeof(char)*(15 + strlen(addr0) + strlen(addr1));
addr_args = (char *)malloc(addr_args_len);
snprintf(addr_args, addr_args_len, ",addr0=%s,addr1=%s", addr0, addr1);
args += addr_args;
LOG_D(PHY, "addr_args == '%s'\n", addr_args);
}
}
}
uhd::device_addrs_t device_adds = uhd::device::find(args);
int vers=0,subvers=0,subsubvers=0;
int bw_gain_adjust=0;
@@ -1037,12 +1063,17 @@ extern "C" {
LOG_I(PHY,"Checking for USRPs : UHD %s (%d.%d.%d)\n",
uhd::get_version_string().c_str(),vers,subvers,subsubvers);
if(device_adds.size() == 0) {
double usrp_master_clock = 184.32e6;
std::string args = "type=x300";
if(device_adds.size() == 0) {
// workaround for an api problem, master clock has to be set with the constructor not via set_master_clock_rate
args += boost::str(boost::format(",master_clock_rate=%f") % usrp_master_clock);
double usrp_master_clock = 184.32e6;
std::string args = "type=x300";
if (addr_args) {
args += addr_args;
}
// workaround for an api problem, master clock has to be set with the constructor not via set_master_clock_rate
args += boost::str(boost::format(",master_clock_rate=%f") % usrp_master_clock);
// args += ",num_send_frames=256,num_recv_frames=256, send_frame_size=4096, recv_frame_size=4096";
uhd::device_addrs_t device_adds = uhd::device::find(args);
@@ -1232,12 +1263,14 @@ extern "C" {
}
}
for(int i=0; i<s->usrp->get_tx_num_channels(); i++) {
::uhd::gain_range_t gain_range_tx = s->usrp->get_tx_gain_range(i);
if (i<openair0_cfg[0].tx_num_channels) {
s->usrp->set_tx_rate(openair0_cfg[0].sample_rate,i);
s->usrp->set_tx_freq(openair0_cfg[0].tx_freq[i],i);
s->usrp->set_tx_gain(gain_range_tx.stop()-openair0_cfg[0].tx_gain[i],i);
LOG_D(PHY, "usrp->get_tx_num_channels() == %zd\n", s->usrp->get_tx_num_channels());
LOG_D(PHY, "openair0_cfg[0].tx_num_channels == %d\n", openair0_cfg[0].tx_num_channels);
for(int i=0; i<s->usrp->get_tx_num_channels(); i++) {
::uhd::gain_range_t gain_range_tx = s->usrp->get_tx_gain_range(i);
if (i<openair0_cfg[0].tx_num_channels) {
s->usrp->set_tx_rate(openair0_cfg[0].sample_rate,i);
s->usrp->set_tx_freq(openair0_cfg[0].tx_freq[i],i);
s->usrp->set_tx_gain(gain_range_tx.stop()-openair0_cfg[0].tx_gain[i],i);
LOG_I(PHY,"USRP TX_GAIN:%3.2lf gain_range:%3.2lf tx_gain:%3.2lf\n", gain_range_tx.stop()-openair0_cfg[0].tx_gain[i], gain_range_tx.stop(), openair0_cfg[0].tx_gain[i]);
}
+1 -1
View File
@@ -253,7 +253,7 @@ int tcp_bridge_ue_first_read(openair0_device *device, openair0_timestamp *timest
tcp_bridge_state_t *t = device->priv;
uint32_t b[t->samples_per_subframe * 12];
memset(b, 0, nsamps * 4);
memset(b, 0, t->samples_per_subframe * 12 * 4);
int n = fullwrite(t->sock, b, t->samples_per_subframe * 12 * 4);
if (n != t->samples_per_subframe * 12 * 4) {
printf("tcp_bridge: write error ret %d error %s\n", n, strerror(errno));
+7 -5
View File
@@ -22,7 +22,7 @@
#if defined(ENABLE_ITTI)
# include "intertask_interface.h"
# include "create_tasks.h"
# include "log.h"
# include "common/utils/LOG/log.h"
# ifdef OPENAIR2
# if defined(ENABLE_USE_MME)
@@ -32,6 +32,8 @@
# include "nas_ue_task.h"
# include "udp_eNB_task.h"
# include "gtpv1u_eNB_task.h"
# else
# define EPC_MODE_ENABLED 0
# endif
# if ENABLE_RAL
# include "lteRALue.h"
@@ -60,8 +62,8 @@ int create_tasks(uint32_t enb_nb)
return -1;
}
}
# if defined(ENABLE_USE_MME)
# if defined(ENABLE_USE_MME)
if (EPC_MODE_ENABLED) {
if (enb_nb > 0) {
if (itti_create_task (TASK_X2AP, x2ap_task, NULL) < 0) {
LOG_E(X2AP, "Create task for X2AP failed\n");
@@ -90,8 +92,8 @@ int create_tasks(uint32_t enb_nb)
}
}
# endif
} /* if (EPC_MODE_ENABLED) */
#endif
if (enb_nb > 0) {
LOG_I(RRC,"Creating RRC eNB Task\n");
+1 -1
View File
@@ -22,7 +22,7 @@
#if defined(ENABLE_ITTI)
# include "intertask_interface.h"
# include "create_tasks.h"
# include "log.h"
# include "common/utils/LOG/log.h"
# ifdef OPENAIR2
# if defined(ENABLE_USE_MME)
+25 -7
View File
@@ -1882,13 +1882,13 @@ void *ru_thread_synch(void *arg) {
LOG_I(PHY,"Estimated sync_pos %d, peak_val %d => timing offset %d\n",sync_pos,peak_val,ru->rx_offset);
LOG_M_BEGIN(RU)
if ((peak_val > 300000) && (sync_pos > 0)) {
LOG_M("ru_sync.m","sync",(void*)&sync_corr[0],fp->samples_per_tti*5,1,2);
LOG_M("ru_rx.m","rxs",&(ru->eNB_list[0]->common_vars.rxdata[0][0]),fp->samples_per_tti*10,1,1);
exit(-1);
}
LOG_M_END
if (LOG_DEBUGFLAG(RU)) {
if ((peak_val > 300000) && (sync_pos > 0)) {
LOG_M("ru_sync.m","sync",(void*)&sync_corr[0],fp->samples_per_tti*5,1,2);
LOG_M("ru_rx.m","rxs",&(ru->eNB_list[0]->common_vars.rxdata[0][0]),fp->samples_per_tti*10,1,1);
exit(-1);
}
}
ru->in_synch=1;
}
}
@@ -2838,6 +2838,24 @@ void RCconfig_RU(void) {
RC.ru[j]->num_eNB = 0;
for (i=0;i<RC.ru[j]->num_eNB;i++) RC.ru[j]->eNB_list[i] = RC.eNB[RUParamList.paramarray[j][RU_ENB_LIST_IDX].iptr[i]][0];
if (config_isparamset(RUParamList.paramarray[j], RU_SDR_ADDRS)) {
RC.ru[j]->openair0_cfg.sdr_addrs = strdup(*(RUParamList.paramarray[j][RU_SDR_ADDRS].strptr));
}
if (config_isparamset(RUParamList.paramarray[j], RU_SDR_CLK_SRC)) {
if (strcmp(*(RUParamList.paramarray[j][RU_SDR_CLK_SRC].strptr), "internal") == 0) {
RC.ru[j]->openair0_cfg.clock_source = internal;
LOG_D(PHY, "RU clock source set as internal\n");
} else if (strcmp(*(RUParamList.paramarray[j][RU_SDR_CLK_SRC].strptr), "external") == 0) {
RC.ru[j]->openair0_cfg.clock_source = external;
LOG_D(PHY, "RU clock source set as external\n");
} else if (strcmp(*(RUParamList.paramarray[j][RU_SDR_CLK_SRC].strptr), "gpsdo") == 0) {
RC.ru[j]->openair0_cfg.clock_source = gpsdo;
LOG_D(PHY, "RU clock source set as gpsdo\n");
} else {
LOG_E(PHY, "Erroneous RU clock source in the provided configuration file: '%s'\n", *(RUParamList.paramarray[j][RU_SDR_CLK_SRC].strptr));
}
}
if (strcmp(*(RUParamList.paramarray[j][RU_LOCAL_RF_IDX].strptr), "yes") == 0) {
if ( !(config_isparamset(RUParamList.paramarray[j],RU_LOCAL_IF_NAME_IDX)) ) {
+15 -15
View File
@@ -108,6 +108,10 @@ unsigned char scope_enb_num_ue = 2;
static pthread_t forms_thread; //xforms
#endif //XFORMS
#ifndef ENABLE_USE_MME
#define EPC_MODE_ENABLED 0
#endif
pthread_cond_t nfapi_sync_cond;
pthread_mutex_t nfapi_sync_mutex;
int nfapi_sync_var=-1; //!< protected by mutex \ref nfapi_sync_mutex
@@ -514,7 +518,7 @@ void *l2l1_task(void *arg) {
#endif
static void get_options(void) {
static void get_options(unsigned int *start_msc) {
int tddflag, nonbiotflag;
@@ -548,11 +552,9 @@ static void get_options(void) {
set_glog(glog_level);
}
if (start_telnetsrv) {
load_module_shlib("telnetsrv",NULL,0);
load_module_shlib("telnetsrv",NULL,0,NULL);
}
if ( !(CONFIG_ISFLAGSET(CONFIG_ABORT)) ) {
memset((void*)&RC,0,sizeof(RC));
/* Read RC configuration file */
@@ -788,7 +790,7 @@ int stop_L1L2(module_id_t enb_id)
oai_exit = 1;
if (!RC.ru) {
LOG_F(ENB_APP, "no RU configured\n");
LOG_UI(ENB_APP, "no RU configured\n");
return -1;
}
@@ -925,6 +927,7 @@ int main( int argc, char **argv )
#if defined (XFORMS)
int ret;
#endif
unsigned int start_msc=0;
if ( load_configmodule(argc,argv) == NULL) {
exit_fun("[SOFTMODEM] Error, configuration module init failed\n");
@@ -942,7 +945,7 @@ int main( int argc, char **argv )
printf("Reading in command-line options\n");
get_options ();
get_options (&start_msc);
if (CONFIG_ISFLAGSET(CONFIG_ABORT) ) {
fprintf(stderr,"Getting configuration failed\n");
exit(-1);
@@ -967,22 +970,19 @@ int main( int argc, char **argv )
#if defined(ENABLE_ITTI)
printf("ITTI init\n");
printf("ITTI init, useMME: %i\n" ,EPC_MODE_ENABLED);
itti_init(TASK_MAX, THREAD_MAX, MESSAGES_ID_MAX, tasks_info, messages_info);
// initialize mscgen log after ITTI
if (start_msc) {
load_module_shlib("msc",NULL,0,&msc_interface);
}
MSC_INIT(MSC_E_UTRAN, THREAD_MAX+TASK_MAX);
#endif
if (opt_type != OPT_NONE) {
radio_type_t radio_type;
if (frame_parms[0]->frame_type == FDD)
radio_type = RADIO_TYPE_FDD;
else
radio_type = RADIO_TYPE_TDD;
if (init_opt(in_path, in_ip, NULL, radio_type) == -1)
if (init_opt(in_path, in_ip) == -1)
LOG_E(OPT,"failed to run OPT \n");
}
+3 -1
View File
@@ -192,8 +192,9 @@
}
#define CONFIG_HLP_FLOG "Enable online log \n"
#define CONFIG_HLP_LOGL "Set the global log level, valide options: (9:trace, 8/7:debug, 6:info, 4:warn, 3:error)\n"
#define CONFIG_HLP_LOGL "Set the global log level, valide options: (4:trace, 3:debug, 2:info, 1:warn, (0:error))\n"
#define CONFIG_HLP_TELN "Start embedded telnet server \n"
#define CONFIG_HLP_MSC "Enable the MSC tracing utility \n"
/*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/
/* command line parameters for LOG utility */
/* optname helpstr paramflags XXXptr defXXXval type numelt */
@@ -202,6 +203,7 @@
{"R" , CONFIG_HLP_FLOG, 0, uptr:&online_log_messages, defintval:1, TYPE_INT, 0}, \
{"g" , CONFIG_HLP_LOGL, 0, uptr:&glog_level, defintval:0, TYPE_UINT, 0}, \
{"telnetsrv", CONFIG_HLP_TELN, PARAMFLAG_BOOL, uptr:&start_telnetsrv, defintval:0, TYPE_UINT, 0}, \
{"msc", CONFIG_HLP_MSC, PARAMFLAG_BOOL, uptr:start_msc, defintval:0, TYPE_UINT, 0}, \
}
#define CMDLINE_ONLINELOG_IDX 0
#define CMDLINE_GLOGLEVEL_IDX 1
+15 -19
View File
@@ -446,7 +446,6 @@ static void *UE_thread_synch(void *arg)
int freq_offset=0;
char threadname[128];
UE->is_synchronized = 0;
printf("UE_thread_sync in with PHY_vars_UE %p\n",arg);
cpu_set_t cpuset;
@@ -522,11 +521,6 @@ static void *UE_thread_synch(void *arg)
printf("Started device, unlocked sync_mutex (UE_sync_thread)\n");
if (UE->rfdevice.trx_start_func(&UE->rfdevice) != 0 ) {
LOG_E(HW,"Could not start the device\n");
oai_exit=1;
}
while (oai_exit==0) {
AssertFatal ( 0== pthread_mutex_lock(&UE->proc.mutex_synch), "");
while (UE->proc.instance_cnt_synch < 0)
@@ -755,7 +749,6 @@ static void *UE_thread_rxn_txnp4(void *arg) {
UE_rxtx_proc_t *proc = rtd->proc;
PHY_VARS_UE *UE = rtd->UE;
proc->instance_cnt_rxtx=-1;
proc->subframe_rx=proc->sub_frame_start;
char threadname[256];
@@ -1457,20 +1450,25 @@ void *UE_thread(void *arg) {
int sub_frame=-1;
//int cumulated_shift=0;
if (UE->rfdevice.trx_start_func(&UE->rfdevice) != 0 ) {
LOG_E(HW,"Could not start the device\n");
oai_exit=1;
}
while (!oai_exit) {
#if BASIC_SIMULATOR
while (!(UE->proc.instance_cnt_synch < 0)) {
printf("ue sync not ready\n");
usleep(500*1000);
}
#endif
AssertFatal ( 0== pthread_mutex_lock(&UE->proc.mutex_synch), "");
int instance_cnt_synch = UE->proc.instance_cnt_synch;
int is_synchronized = UE->is_synchronized;
AssertFatal ( 0== pthread_mutex_unlock(&UE->proc.mutex_synch), "");
if (is_synchronized == 0) {
#if BASIC_SIMULATOR
while (!((instance_cnt_synch = UE->proc.instance_cnt_synch) < 0)) {
printf("ue sync not ready\n");
usleep(500*1000);
}
#endif
if (instance_cnt_synch < 0) { // we can invoke the synch
// grab 10 ms of signal and wakeup synch thread
for (int i=0; i<UE->frame_parms.nb_antennas_rx; i++)
@@ -1661,12 +1659,7 @@ void *UE_thread(void *arg) {
proc->instance_cnt_rxtx++;
LOG_D( PHY, "[SCHED][UE %d] UE RX instance_cnt_rxtx %d subframe %d !!\n", UE->Mod_id, proc->instance_cnt_rxtx,proc->subframe_rx);
if (proc->instance_cnt_rxtx == 0) {
if (pthread_cond_signal(&proc->cond_rxtx) != 0) {
LOG_E( PHY, "[SCHED][UE %d] ERROR pthread_cond_signal for UE RX thread\n", UE->Mod_id);
exit_fun("nothing to add");
}
} else {
if (proc->instance_cnt_rxtx != 0) {
LOG_E( PHY, "[SCHED][UE %d] UE RX thread busy (IC %d)!!\n", UE->Mod_id, proc->instance_cnt_rxtx);
if (proc->instance_cnt_rxtx > 2)
exit_fun("instance_cnt_rxtx > 2");
@@ -1717,6 +1710,8 @@ void init_UE_threads(int inst) {
pthread_mutex_init(&UE->proc.mutex_synch,NULL);
pthread_cond_init(&UE->proc.cond_synch,NULL);
UE->proc.instance_cnt_synch = -1;
UE->is_synchronized = 0;
// the threads are not yet active, therefore access is allowed without locking
int nb_threads=RX_NB_TH;
@@ -1728,6 +1723,7 @@ void init_UE_threads(int inst) {
pthread_mutex_init(&UE->proc.proc_rxtx[i].mutex_rxtx,NULL);
pthread_cond_init(&UE->proc.proc_rxtx[i].cond_rxtx,NULL);
UE->proc.proc_rxtx[i].instance_cnt_rxtx = -1;
UE->proc.proc_rxtx[i].sub_frame_start=i;
UE->proc.proc_rxtx[i].sub_frame_step=nb_threads;
printf("Init_UE_threads rtd %d proc %d nb_threads %d i %d\n",rtd->proc->sub_frame_start, UE->proc.proc_rxtx[i].sub_frame_start,nb_threads, i);
+8 -26
View File
@@ -470,7 +470,7 @@ void *l2l1_task(void *arg) {
extern int16_t dlsch_demod_shift;
static void get_options(void) {
static void get_options(unsigned int *start_msc) {
int CC_id;
int tddflag, nonbiotflag;
char *loopfile=NULL;
@@ -505,7 +505,7 @@ static void get_options(void) {
set_glog(glog_level);
}
if (start_telnetsrv) {
load_module_shlib("telnetsrv",NULL,0);
load_module_shlib("telnetsrv",NULL,0,NULL);
}
paramdef_t cmdline_uemodeparams[] =CMDLINE_UEMODEPARAMS_DESC;
@@ -770,6 +770,7 @@ int main( int argc, char **argv )
int CC_id;
uint8_t abstraction_flag=0;
unsigned int start_msc=0;
// Default value for the number of UEs. It will hold,
// if not changed from the command line option --num-ues
@@ -797,7 +798,7 @@ int main( int argc, char **argv )
printf("Reading in command-line options\n");
for (int i=0;i<MAX_NUM_CCs;i++) tx_max_power[i]=23;
get_options ();
get_options (&start_msc);
printf("Running with %d UE instances\n",NB_UE_INST);
@@ -830,21 +831,6 @@ int main( int argc, char **argv )
//randominit (0);
set_taus_seed (0);
set_log(HW, OAILOG_DEBUG, 1);
set_log(PHY, OAILOG_INFO, 1);
set_log(MAC, OAILOG_INFO, 1);
set_log(RLC, OAILOG_INFO, 1);
set_log(PDCP, OAILOG_INFO, 1);
set_log(OTG, OAILOG_INFO, 1);
set_log(RRC, OAILOG_INFO, 1);
#if defined(ENABLE_ITTI)
set_log(SIM, OAILOG_INFO, 1);
# if defined(ENABLE_USE_MME)
set_log(NAS, OAILOG_INFO, 1);
# endif
#endif
cpuf=get_cpu_freq_GHz();
pthread_cond_init(&sync_cond,NULL);
@@ -858,18 +844,14 @@ int main( int argc, char **argv )
itti_init(TASK_MAX, THREAD_MAX, MESSAGES_ID_MAX, tasks_info, messages_info);
// initialize mscgen log after ITTI
if (start_msc) {
load_module_shlib("msc",NULL,0,&msc_interface);
}
MSC_INIT(MSC_E_UTRAN, THREAD_MAX+TASK_MAX);
#endif
if (opt_type != OPT_NONE) {
radio_type_t radio_type;
if (frame_parms[0]->frame_type == FDD)
radio_type = RADIO_TYPE_FDD;
else
radio_type = RADIO_TYPE_TDD;
if (init_opt(in_path, in_ip, NULL, radio_type) == -1)
if (init_opt(in_path, in_ip) == -1)
LOG_E(OPT,"failed to run OPT \n");
}