Commit 0db02490 authored by Raphael Defosseux's avatar Raphael Defosseux

Merge remote-tracking branch...

Merge remote-tracking branch 'origin/373-parallelization-not-working-correctly-in-phy-simulators-and-bad-implementation-2' into develop_integration_w48
Signed-off-by: default avatarRaphael Defosseux <raphael.defosseux@eurecom.fr>
parents d109ffa1 af892cc0
...@@ -39,9 +39,8 @@ ...@@ -39,9 +39,8 @@
#include "vcd_signal_dumper.h" #include "vcd_signal_dumper.h"
#include "assertions.h" #include "assertions.h"
#include <pthread.h>
# include <pthread.h> #include <string.h>
# include <string.h>
#include <linux/prctl.h> #include <linux/prctl.h>
#include "common/config/config_userapi.h" #include "common/config/config_userapi.h"
// main log variables // main log variables
......
...@@ -196,14 +196,12 @@ void oai_create_enb(void) { ...@@ -196,14 +196,12 @@ void oai_create_enb(void) {
int bodge_counter=0; int bodge_counter=0;
PHY_VARS_eNB *eNB = RC.eNB[0][0]; PHY_VARS_eNB *eNB = RC.eNB[0][0];
printf("[VNF] RC.eNB[0][0]. Mod_id:%d CC_id:%d nb_CC[0]:%d abstraction_flag:%d single_thread_flag:%d td:%p te:%p if_inst:%p\n", eNB->Mod_id, eNB->CC_id, RC.nb_CC[0], eNB->abstraction_flag, eNB->single_thread_flag, eNB->td, eNB->te, eNB->if_inst); printf("[VNF] RC.eNB[0][0]. Mod_id:%d CC_id:%d nb_CC[0]:%d abstraction_flag:%d single_thread_flag:%d if_inst:%p\n", eNB->Mod_id, eNB->CC_id, RC.nb_CC[0], eNB->abstraction_flag, eNB->single_thread_flag, eNB->if_inst);
eNB->Mod_id = bodge_counter; eNB->Mod_id = bodge_counter;
eNB->CC_id = bodge_counter; eNB->CC_id = bodge_counter;
eNB->abstraction_flag = 0; eNB->abstraction_flag = 0;
eNB->single_thread_flag = 0;//single_thread_flag; eNB->single_thread_flag = 0;//single_thread_flag;
eNB->td = ulsch_decoding_data_all;//(single_thread_flag==1) ? ulsch_decoding_data_2thread : ulsch_decoding_data;
eNB->te = dlsch_encoding_all;//(single_thread_flag==1) ? dlsch_encoding_2threads : dlsch_encoding;
RC.nb_CC[bodge_counter] = 1; RC.nb_CC[bodge_counter] = 1;
......
...@@ -1505,7 +1505,7 @@ unsigned int ulsch_decoding(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, ...@@ -1505,7 +1505,7 @@ unsigned int ulsch_decoding(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,
// Do ULSCH Decoding for data portion // Do ULSCH Decoding for data portion
ret = eNB->td(eNB,UE_id,harq_pid,llr8_flag); ret = ulsch_decoding_data_all(eNB,UE_id,harq_pid,llr8_flag);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_ULSCH_DECODING0+harq_pid,0); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_ULSCH_DECODING0+harq_pid,0);
......
...@@ -1298,7 +1298,7 @@ void dlsch_channel_compensation(int **rxdataF_ext, ...@@ -1298,7 +1298,7 @@ void dlsch_channel_compensation(int **rxdataF_ext,
unsigned short rb; unsigned short rb;
unsigned char aatx,aarx,symbol_mod,pilots=0; unsigned char aatx,aarx,symbol_mod,pilots=0;
__m128i *dl_ch128,*dl_ch128_2,*dl_ch_mag128,*dl_ch_mag128b,*rxdataF128,*rxdataF_comp128,*rho128; __m128i *dl_ch128,*dl_ch128_2,*dl_ch_mag128,*dl_ch_mag128b,*rxdataF128,*rxdataF_comp128,*rho128;
__m128i mmtmpD0,mmtmpD1,mmtmpD2,mmtmpD3,QAM_amp128,QAM_amp128b; __m128i mmtmpD0,mmtmpD1,mmtmpD2,mmtmpD3,QAM_amp128;
symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol; symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol;
...@@ -1311,9 +1311,9 @@ void dlsch_channel_compensation(int **rxdataF_ext, ...@@ -1311,9 +1311,9 @@ void dlsch_channel_compensation(int **rxdataF_ext,
} }
for (aatx=0; aatx<frame_parms->nb_antenna_ports_eNB; aatx++) { for (aatx=0; aatx<frame_parms->nb_antenna_ports_eNB; aatx++) {
__m128i QAM_amp128b = _mm_setzero_si128();
if (mod_order == 4) { if (mod_order == 4) {
QAM_amp128 = _mm_set1_epi16(QAM16_n1); // 2/sqrt(10) QAM_amp128 = _mm_set1_epi16(QAM16_n1); // 2/sqrt(10)
QAM_amp128b = _mm_setzero_si128();
} else if (mod_order == 6) { } else if (mod_order == 6) {
QAM_amp128 = _mm_set1_epi16(QAM64_n1); // QAM_amp128 = _mm_set1_epi16(QAM64_n1); //
QAM_amp128b = _mm_set1_epi16(QAM64_n2); QAM_amp128b = _mm_set1_epi16(QAM64_n2);
...@@ -1766,11 +1766,11 @@ void dlsch_channel_compensation_core(int **rxdataF_ext, ...@@ -1766,11 +1766,11 @@ void dlsch_channel_compensation_core(int **rxdataF_ext,
int length_mod8 = 0; int length_mod8 = 0;
int length2; int length2;
__m128i *dl_ch128,*dl_ch_mag128,*dl_ch_mag128b, *dl_ch128_2, *rxdataF128,*rxdataF_comp128,*rho128; __m128i *dl_ch128,*dl_ch_mag128,*dl_ch_mag128b, *dl_ch128_2, *rxdataF128,*rxdataF_comp128,*rho128;
__m128i mmtmpD0,mmtmpD1,mmtmpD2,mmtmpD3,QAM_amp128,QAM_amp128b; __m128i mmtmpD0,mmtmpD1,mmtmpD2,mmtmpD3,QAM_amp128;
int aatx = 0, aarx = 0; int aatx = 0, aarx = 0;
for (aatx=0; aatx<n_tx; aatx++) { for (aatx=0; aatx<n_tx; aatx++) {
__m128i QAM_amp128b;
if (mod_order == 4) { if (mod_order == 4) {
QAM_amp128 = _mm_set1_epi16(QAM16_n1); // 2/sqrt(10) QAM_amp128 = _mm_set1_epi16(QAM16_n1); // 2/sqrt(10)
QAM_amp128b = _mm_setzero_si128(); QAM_amp128b = _mm_setzero_si128();
...@@ -2158,7 +2158,7 @@ void dlsch_channel_compensation_TM56(int **rxdataF_ext, ...@@ -2158,7 +2158,7 @@ void dlsch_channel_compensation_TM56(int **rxdataF_ext,
__m128i *dl_ch0_128,*dl_ch1_128,*dl_ch_mag128,*dl_ch_mag128b,*rxdataF128,*rxdataF_comp128; __m128i *dl_ch0_128,*dl_ch1_128,*dl_ch_mag128,*dl_ch_mag128b,*rxdataF128,*rxdataF_comp128;
unsigned char aarx=0,symbol_mod,pilots=0; unsigned char aarx=0,symbol_mod,pilots=0;
int precoded_signal_strength=0; int precoded_signal_strength=0;
__m128i mmtmpD0,mmtmpD1,mmtmpD2,mmtmpD3,QAM_amp128,QAM_amp128b; __m128i mmtmpD0,mmtmpD1,mmtmpD2,mmtmpD3,QAM_amp128;
symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol; symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol;
...@@ -2167,10 +2167,9 @@ void dlsch_channel_compensation_TM56(int **rxdataF_ext, ...@@ -2167,10 +2167,9 @@ void dlsch_channel_compensation_TM56(int **rxdataF_ext,
//printf("comp prec: symbol %d, pilots %d\n",symbol, pilots); //printf("comp prec: symbol %d, pilots %d\n",symbol, pilots);
__m128i QAM_amp128b = _mm_setzero_si128();
if (mod_order == 4) { if (mod_order == 4) {
QAM_amp128 = _mm_set1_epi16(QAM16_n1); QAM_amp128 = _mm_set1_epi16(QAM16_n1);
QAM_amp128b = _mm_setzero_si128();
} else if (mod_order == 6) { } else if (mod_order == 6) {
QAM_amp128 = _mm_set1_epi16(QAM64_n1); QAM_amp128 = _mm_set1_epi16(QAM64_n1);
QAM_amp128b = _mm_set1_epi16(QAM64_n2); QAM_amp128b = _mm_set1_epi16(QAM64_n2);
...@@ -2621,7 +2620,7 @@ void dlsch_channel_compensation_TM34(LTE_DL_FRAME_PARMS *frame_parms, ...@@ -2621,7 +2620,7 @@ void dlsch_channel_compensation_TM34(LTE_DL_FRAME_PARMS *frame_parms,
int **rxdataF_comp0 = pdsch_vars->rxdataF_comp0; int **rxdataF_comp0 = pdsch_vars->rxdataF_comp0;
int **rxdataF_comp1 = pdsch_vars->rxdataF_comp1[harq_pid][round]; int **rxdataF_comp1 = pdsch_vars->rxdataF_comp1[harq_pid][round];
unsigned char *pmi_ext = pdsch_vars->pmi_ext; unsigned char *pmi_ext = pdsch_vars->pmi_ext;
__m128i mmtmpD0,mmtmpD1,mmtmpD2,mmtmpD3,QAM_amp0_128,QAM_amp0_128b,QAM_amp1_128,QAM_amp1_128b; __m128i mmtmpD0,mmtmpD1,mmtmpD2,mmtmpD3,QAM_amp0_128,QAM_amp1_128;
symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol; symbol_mod = (symbol>=(7-frame_parms->Ncp)) ? symbol-(7-frame_parms->Ncp) : symbol;
...@@ -2632,17 +2631,17 @@ void dlsch_channel_compensation_TM34(LTE_DL_FRAME_PARMS *frame_parms, ...@@ -2632,17 +2631,17 @@ void dlsch_channel_compensation_TM34(LTE_DL_FRAME_PARMS *frame_parms,
// printf("comp prec: symbol %d, pilots %d\n",symbol, pilots); // printf("comp prec: symbol %d, pilots %d\n",symbol, pilots);
__m128i QAM_amp0_128b = _mm_setzero_si128();
if (mod_order0 == 4) { if (mod_order0 == 4) {
QAM_amp0_128 = _mm_set1_epi16(QAM16_n1); QAM_amp0_128 = _mm_set1_epi16(QAM16_n1);
QAM_amp0_128b = _mm_setzero_si128();
} else if (mod_order0 == 6) { } else if (mod_order0 == 6) {
QAM_amp0_128 = _mm_set1_epi16(QAM64_n1); QAM_amp0_128 = _mm_set1_epi16(QAM64_n1);
QAM_amp0_128b = _mm_set1_epi16(QAM64_n2); QAM_amp0_128b = _mm_set1_epi16(QAM64_n2);
} }
__m128i QAM_amp1_128b = _mm_setzero_si128();
if (mod_order1 == 4) { if (mod_order1 == 4) {
QAM_amp1_128 = _mm_set1_epi16(QAM16_n1); QAM_amp1_128 = _mm_set1_epi16(QAM16_n1);
QAM_amp1_128b = _mm_setzero_si128();
} else if (mod_order1 == 6) { } else if (mod_order1 == 6) {
QAM_amp1_128 = _mm_set1_epi16(QAM64_n1); QAM_amp1_128 = _mm_set1_epi16(QAM64_n1);
QAM_amp1_128b = _mm_set1_epi16(QAM64_n2); QAM_amp1_128b = _mm_set1_epi16(QAM64_n2);
......
...@@ -58,6 +58,7 @@ ...@@ -58,6 +58,7 @@
#include <math.h> #include <math.h>
#include "common_lib.h" #include "common_lib.h"
#include "msc.h" #include "msc.h"
#include <common/utils/LOG/log.h>
//#include <complex.h> //#include <complex.h>
...@@ -862,22 +863,60 @@ typedef enum { ...@@ -862,22 +863,60 @@ typedef enum {
RESYNCH=4 RESYNCH=4
} UE_MODE_t; } UE_MODE_t;
/// Threading Parameter #define FOREACH_PARALLEL(GEN) \
GEN(PARALLEL_SINGLE_THREAD) \
GEN(PARALLEL_RU_L1_SPLIT) \
GEN(PARALLEL_RU_L1_TRX_SPLIT)
#define GENERATE_ENUM(N) N,
#define GENERATE_ENUMTXT(N) {(char*)#N, N},
typedef enum { typedef enum {
PARALLEL_SINGLE_THREAD =0, FOREACH_PARALLEL(GENERATE_ENUM)
PARALLEL_RU_L1_SPLIT =1, } PARALLEL_CONF_t;
PARALLEL_RU_L1_TRX_SPLIT =2
}PARALLEL_CONF_t;
#define FOREACH_WORKER(GEN) GEN(WORKER_DISABLE) GEN(WORKER_ENABLE)
typedef enum { typedef enum {
WORKER_DISABLE =0, FOREACH_WORKER(GENERATE_ENUM)
WORKER_ENABLE =1
}WORKER_CONF_t; }WORKER_CONF_t;
typedef struct THREAD_STRUCT_s { typedef struct THREAD_STRUCT_s {
PARALLEL_CONF_t parallel_conf; PARALLEL_CONF_t parallel_conf;
WORKER_CONF_t worker_conf; WORKER_CONF_t worker_conf;
} THREAD_STRUCT; } THREAD_STRUCT;
extern THREAD_STRUCT thread_struct;
static inline void set_parallel_conf(char *parallel_conf) {
mapping config[]= {
FOREACH_PARALLEL(GENERATE_ENUMTXT)
{NULL,-1}
};
thread_struct.parallel_conf = (PARALLEL_CONF_t)map_str_to_int(config, parallel_conf);
if (thread_struct.parallel_conf == -1 ) {
LOG_E(ENB_APP,"Impossible value: %s\n", parallel_conf);
thread_struct.parallel_conf = PARALLEL_SINGLE_THREAD;
}
}
static inline void set_worker_conf(char *worker_conf) {
mapping config[]={
FOREACH_WORKER(GENERATE_ENUMTXT)
{NULL, -1}
};
thread_struct.worker_conf = (WORKER_CONF_t)map_str_to_int(config, worker_conf);
if (thread_struct.worker_conf == -1 ) {
LOG_E(ENB_APP,"Impossible value: %s\n", worker_conf);
thread_struct.worker_conf = WORKER_DISABLE ;
}
}
static inline PARALLEL_CONF_t get_thread_parallel_conf(void) {
return thread_struct.parallel_conf;
}
static inline WORKER_CONF_t get_thread_worker_conf(void) {
return thread_struct.worker_conf;
}
typedef enum {SF_DL, SF_UL, SF_S} lte_subframe_t; typedef enum {SF_DL, SF_UL, SF_S} lte_subframe_t;
......
...@@ -904,8 +904,6 @@ typedef struct PHY_VARS_eNB_s { ...@@ -904,8 +904,6 @@ typedef struct PHY_VARS_eNB_s {
/// Ethernet parameters for fronthaul interface /// Ethernet parameters for fronthaul interface
eth_params_t eth_params; eth_params_t eth_params;
int rx_total_gain_dB; int rx_total_gain_dB;
int (*td)(struct PHY_VARS_eNB_s *eNB,int UE_id,int harq_pid,int llr8_flag);
int (*te)(struct PHY_VARS_eNB_s *,uint8_t *,uint8_t,LTE_eNB_DLSCH_t *,int,uint8_t,time_stats_t *,time_stats_t *,time_stats_t *,time_stats_t *,time_stats_t *,time_stats_t *,time_stats_t *);
int (*start_if)(struct RU_t_s *ru,struct PHY_VARS_eNB_s *eNB); int (*start_if)(struct RU_t_s *ru,struct PHY_VARS_eNB_s *eNB);
uint8_t local_flag; uint8_t local_flag;
LTE_DL_FRAME_PARMS frame_parms; LTE_DL_FRAME_PARMS frame_parms;
...@@ -1080,6 +1078,7 @@ typedef struct PHY_VARS_eNB_s { ...@@ -1080,6 +1078,7 @@ typedef struct PHY_VARS_eNB_s {
time_stats_t ofdm_mod_stats; time_stats_t ofdm_mod_stats;
time_stats_t dlsch_common_and_dci; time_stats_t dlsch_common_and_dci;
time_stats_t dlsch_ue_specific;
time_stats_t dlsch_encoding_stats; time_stats_t dlsch_encoding_stats;
time_stats_t dlsch_modulation_stats; time_stats_t dlsch_modulation_stats;
time_stats_t dlsch_scrambling_stats; time_stats_t dlsch_scrambling_stats;
......
...@@ -400,7 +400,7 @@ void pdsch_procedures(PHY_VARS_eNB *eNB, ...@@ -400,7 +400,7 @@ void pdsch_procedures(PHY_VARS_eNB *eNB,
start_meas(&eNB->dlsch_encoding_stats); start_meas(&eNB->dlsch_encoding_stats);
eNB->te(eNB, dlsch_encoding_all(eNB,
dlsch_harq->pdu, dlsch_harq->pdu,
dlsch_harq->pdsch_start, dlsch_harq->pdsch_start,
dlsch, dlsch,
...@@ -582,6 +582,7 @@ void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB, ...@@ -582,6 +582,7 @@ void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB,
} }
if (do_meas==1) stop_meas(&eNB->dlsch_common_and_dci); if (do_meas==1) stop_meas(&eNB->dlsch_common_and_dci);
if (do_meas==1) start_meas(&eNB->dlsch_ue_specific);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_PDCCH_TX,0); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_PDCCH_TX,0);
...@@ -649,6 +650,7 @@ void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB, ...@@ -649,6 +650,7 @@ void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB,
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_GENERATE_PHICH,0); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_GENERATE_PHICH,0);
VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_ENB_TX+(eNB->CC_id),0); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_ENB_TX+(eNB->CC_id),0);
if (do_meas==1) stop_meas(&eNB->dlsch_ue_specific);
if (do_meas==1) stop_meas(&eNB->phy_proc_tx); if (do_meas==1) stop_meas(&eNB->phy_proc_tx);
} }
......
...@@ -49,38 +49,46 @@ void sumUpStatsSlot(time_stats_t *res, time_stats_t src[RX_NB_TH][2], int lastAc ...@@ -49,38 +49,46 @@ void sumUpStatsSlot(time_stats_t *res, time_stats_t src[RX_NB_TH][2], int lastAc
res->p_time=src[lastActive][last].p_time; res->p_time=src[lastActive][last].p_time;
} }
double squareRoot(time_stats_t *ptr) {
double timeBase=1/(1000*cpu_freq_GHz);
return sqrt((double)ptr->diff_square*pow(timeBase,2)/ptr->trials -
pow((double)ptr->diff/ptr->trials*timeBase,2));
}
void printDistribution(time_stats_t *ptr, varArray_t *sortedList, char *txt) {
double timeBase=1/(1000*cpu_freq_GHz);
printf("%-43s %6.2f us (%d trials)\n",
txt,
(double)ptr->diff/ptr->trials*timeBase,
ptr->trials);
printf(" Statistics std=%.2f, median=%.2f, q1=%.2f, q3=%.2f µs (on %ld trials)\n",
squareRoot(ptr), median(sortedList),q1(sortedList),q3(sortedList), sortedList->size);
}
void printStatIndent(time_stats_t *ptr, char *txt) { void printStatIndent(time_stats_t *ptr, char *txt) {
printf("|__ %-50s %.2f us (%d trials)\n", printf("|__ %-38s %6.2f us (%3d trials)\n",
txt, txt,
ptr->trials?inMicroS(ptr->diff/ptr->trials):0, ptr->trials?inMicroS(ptr->diff/ptr->trials):0,
ptr->trials); ptr->trials);
} }
void printStatIndent2(time_stats_t *ptr, char *txt, int turbo_iter) { void printStatIndent2(time_stats_t *ptr, char *txt) {
double timeBase=1/(1000*cpu_freq_GHz); double timeBase=1/(1000*cpu_freq_GHz);
printf(" |__ %-45s %.2f us (cycles/block %ld, %5d trials)\n", printf(" |__ %-34s %6.2f us (%3d trials)\n",
txt, txt,
ptr->trials?((double)ptr->diff)/ptr->trials*timeBase:0, ptr->trials?((double)ptr->diff)/ptr->trials*timeBase:0,
turbo_iter?(uint64_t)round(((double)ptr->diff)/turbo_iter):0,
ptr->trials); ptr->trials);
} }
double squareRoot(time_stats_t *ptr) { void printStatIndent3(time_stats_t *ptr, char *txt) {
double timeBase=1/(1000*cpu_freq_GHz);
return sqrt((double)ptr->diff_square*pow(timeBase,2)/ptr->trials -
pow((double)ptr->diff/ptr->trials*timeBase,2));
}
void printDistribution(time_stats_t *ptr, varArray_t *sortedList, char *txt) {
double timeBase=1/(1000*cpu_freq_GHz); double timeBase=1/(1000*cpu_freq_GHz);
printf("%-50s :%.2f us (%d trials)\n", printf(" |__ %-30s %6.2f us (%3d trials)\n",
txt, txt,
(double)ptr->diff/ptr->trials*timeBase, ptr->trials?((double)ptr->diff)/ptr->trials*timeBase:0,
ptr->trials); ptr->trials);
printf("|__ Statistics std=%.2f, median=%.2f, q1=%.2f, q3=%.2f µs (on %ld trials)\n",
squareRoot(ptr), median(sortedList),q1(sortedList),q3(sortedList), sortedList->size);
} }
void logDistribution(FILE* fd, time_stats_t *ptr, varArray_t *sortedList, int dropped) { void logDistribution(FILE* fd, time_stats_t *ptr, varArray_t *sortedList, int dropped) {
fprintf(fd,"%f;%f;%f;%f;%f;%f;%d;", fprintf(fd,"%f;%f;%f;%f;%f;%f;%d;",
squareRoot(ptr), squareRoot(ptr),
......
...@@ -85,30 +85,7 @@ double t_rx_min = 1000000000; /*!< \brief initial min process time for rx */ ...@@ -85,30 +85,7 @@ double t_rx_min = 1000000000; /*!< \brief initial min process time for rx */
int n_tx_dropped = 0; /*!< \brief initial max process time for tx */ int n_tx_dropped = 0; /*!< \brief initial max process time for tx */
int n_rx_dropped = 0; /*!< \brief initial max process time for rx */ int n_rx_dropped = 0; /*!< \brief initial max process time for rx */
char *parallel_config = NULL; THREAD_STRUCT thread_struct;
char *worker_config = NULL;
static THREAD_STRUCT thread_struct;
void set_parallel_conf(char *parallel_conf)
{
if(strcmp(parallel_conf,"PARALLEL_SINGLE_THREAD")==0) thread_struct.parallel_conf = PARALLEL_SINGLE_THREAD;
else if(strcmp(parallel_conf,"PARALLEL_RU_L1_SPLIT")==0) thread_struct.parallel_conf = PARALLEL_RU_L1_SPLIT;
else if(strcmp(parallel_conf,"PARALLEL_RU_L1_TRX_SPLIT")==0) thread_struct.parallel_conf = PARALLEL_RU_L1_TRX_SPLIT;
printf("[CONFIG] parallel conf is set to %d\n",thread_struct.parallel_conf);
}
void set_worker_conf(char *worker_conf)
{
if(strcmp(worker_conf,"WORKER_DISABLE")==0) thread_struct.worker_conf = WORKER_DISABLE;
else if(strcmp(worker_conf,"WORKER_ENABLE")==0) thread_struct.worker_conf = WORKER_ENABLE;
printf("[CONFIG] worker conf is set to %d\n",thread_struct.worker_conf);
}
PARALLEL_CONF_t get_thread_parallel_conf(void)
{
return thread_struct.parallel_conf;
}
WORKER_CONF_t get_thread_worker_conf(void)
{
return thread_struct.worker_conf;
}
int emulate_rf = 0; int emulate_rf = 0;
...@@ -715,7 +692,7 @@ int main(int argc, char **argv) ...@@ -715,7 +692,7 @@ int main(int argc, char **argv)
DL_req.dl_config_request_body.dl_config_pdu_list = dl_config_pdu_list; DL_req.dl_config_request_body.dl_config_pdu_list = dl_config_pdu_list;
TX_req.tx_request_body.tx_pdu_list = tx_pdu_list; TX_req.tx_request_body.tx_pdu_list = tx_pdu_list;
set_parallel_conf("PARALLEL_SINGLE_THREAD");
cpuf = cpu_freq_GHz; cpuf = cpu_freq_GHz;
//signal(SIGSEGV, handler); //signal(SIGSEGV, handler);
...@@ -758,6 +735,7 @@ int main(int argc, char **argv) ...@@ -758,6 +735,7 @@ int main(int argc, char **argv)
{ "Subframe", "subframe ",0, iptr:&subframe, defintval:7, TYPE_INT, 0 }, { "Subframe", "subframe ",0, iptr:&subframe, defintval:7, TYPE_INT, 0 },
{ "Trnti", "rnti",0, u16ptr:&n_rnti, defuintval:0x1234, TYPE_UINT16, 0 }, { "Trnti", "rnti",0, u16ptr:&n_rnti, defuintval:0x1234, TYPE_UINT16, 0 },
{ "vi_mod", "i_mod",0, iptr:NULL, defintval:0, TYPE_INT, 0 }, { "vi_mod", "i_mod",0, iptr:NULL, defintval:0, TYPE_INT, 0 },
{ "Qparallel", "Enable parallel execution",0, strptr:NULL, defstrval:NULL, TYPE_STRING, 0 },
{ "Performance", "Display CPU perfomance of each L1 piece", PARAMFLAG_BOOL, iptr:&print_perf, defintval:0, TYPE_INT, 0 }, { "Performance", "Display CPU perfomance of each L1 piece", PARAMFLAG_BOOL, iptr:&print_perf, defintval:0, TYPE_INT, 0 },
{ "q_tx_port", "Number of TX antennas ports used in eNB",0, iptr:NULL, defintval:0, TYPE_INT, 0 }, { "q_tx_port", "Number of TX antennas ports used in eNB",0, iptr:NULL, defintval:0, TYPE_INT, 0 },
{ "uEdual", "Enables the Interference Aware Receiver for TM5 (default is normal receiver)",0, iptr:NULL, defintval:0, TYPE_INT, 0 }, { "uEdual", "Enables the Interference Aware Receiver for TM5 (default is normal receiver)",0, iptr:NULL, defintval:0, TYPE_INT, 0 },
...@@ -965,6 +943,10 @@ int main(int argc, char **argv) ...@@ -965,6 +943,10 @@ int main(int argc, char **argv)
break; break;
case 'Q':
set_parallel_conf(optarg);
break;
default: default:
printf("Wrong option: %s\n",long_options[option_index].name); printf("Wrong option: %s\n",long_options[option_index].name);
exit(1); exit(1);
...@@ -982,7 +964,7 @@ int main(int argc, char **argv) ...@@ -982,7 +964,7 @@ int main(int argc, char **argv)
if (help) if (help)
exit(0); exit(0);
set_parallel_conf("PARALLEL_RU_L1_TRX_SPLIT"); if (thread_struct.parallel_conf != PARALLEL_SINGLE_THREAD)
set_worker_conf("WORKER_ENABLE"); set_worker_conf("WORKER_ENABLE");
if (transmission_mode>1) pa=dBm3; if (transmission_mode>1) pa=dBm3;
...@@ -1079,11 +1061,7 @@ int main(int argc, char **argv) ...@@ -1079,11 +1061,7 @@ int main(int argc, char **argv)
ru->do_precoding=1; ru->do_precoding=1;
eNB->mac_enabled=1; eNB->mac_enabled=1;
if (two_thread_flag == 0) { if(get_thread_worker_conf() == WORKER_ENABLE) {
eNB->te = dlsch_encoding;
}
else {
eNB->te = dlsch_encoding_2threads;
extern void init_td_thread(PHY_VARS_eNB *); extern void init_td_thread(PHY_VARS_eNB *);
extern void init_te_thread(PHY_VARS_eNB *); extern void init_te_thread(PHY_VARS_eNB *);
init_td_thread(eNB); init_td_thread(eNB);
...@@ -1442,6 +1420,8 @@ int main(int argc, char **argv) ...@@ -1442,6 +1420,8 @@ int main(int argc, char **argv)
reset_meas(&eNB->dlsch_interleaving_stats); reset_meas(&eNB->dlsch_interleaving_stats);
reset_meas(&eNB->dlsch_rate_matching_stats); reset_meas(&eNB->dlsch_rate_matching_stats);
reset_meas(&eNB->dlsch_turbo_encoding_stats); reset_meas(&eNB->dlsch_turbo_encoding_stats);
reset_meas(&eNB->dlsch_common_and_dci);
reset_meas(&eNB->dlsch_ue_specific);
for (int i=0; i<RX_NB_TH; i++) { for (int i=0; i<RX_NB_TH; i++) {
reset_meas(&UE->phy_proc_rx[i]); // total UE rx reset_meas(&UE->phy_proc_rx[i]); // total UE rx
reset_meas(&UE->ue_front_end_stat[i]); reset_meas(&UE->ue_front_end_stat[i]);
...@@ -1783,9 +1763,6 @@ int main(int argc, char **argv) ...@@ -1783,9 +1763,6 @@ int main(int argc, char **argv)
} }
if (UE->dlsch[UE->current_thread_id[subframe]][eNB_id][0]->harq_ack[subframe].ack == 1) { if (UE->dlsch[UE->current_thread_id[subframe]][eNB_id][0]->harq_ack[subframe].ack == 1) {
avg_iter += UE->dlsch[UE->current_thread_id[subframe]][eNB_id][0]->last_iteration_cnt; avg_iter += UE->dlsch[UE->current_thread_id[subframe]][eNB_id][0]->last_iteration_cnt;
...@@ -2011,21 +1988,22 @@ int main(int argc, char **argv) ...@@ -2011,21 +1988,22 @@ int main(int argc, char **argv)
printf("\neNB TX function statistics (per 1ms subframe)\n"); printf("\neNB TX function statistics (per 1ms subframe)\n");
printDistribution(&eNB->phy_proc_tx,table_tx,"PHY proc tx"); printDistribution(&eNB->phy_proc_tx,table_tx,"PHY proc tx");
printStatIndent(&eNB->dlsch_common_and_dci,"DL common channels and dci time"); printStatIndent(&eNB->dlsch_common_and_dci,"DL common channels and dci time");
printStatIndent(&eNB->dlsch_encoding_stats,"DLSCH encoding time"); printStatIndent(&eNB->dlsch_ue_specific,"DL per ue part time");
printStatIndent2(&eNB->dlsch_rate_matching_stats,"DLSCH rate matching time",eNB->dlsch_rate_matching_stats.trials); printStatIndent2(&eNB->dlsch_encoding_stats,"DLSCH encoding time");
printStatIndent2(&eNB->dlsch_turbo_encoding_stats,"DLSCH turbo encoding time", eNB->dlsch_turbo_encoding_stats.trials); printStatIndent3(&eNB->dlsch_rate_matching_stats,"DLSCH rate matching time");
printStatIndent2(&eNB->dlsch_interleaving_stats,"DLSCH interleaving time", eNB->dlsch_interleaving_stats.trials); printStatIndent3(&eNB->dlsch_turbo_encoding_stats,"DLSCH turbo encoding time");
printStatIndent(&eNB->dlsch_scrambling_stats, "DLSCH scrambling time"); printStatIndent3(&eNB->dlsch_interleaving_stats,"DLSCH interleaving time");
printStatIndent(&eNB->dlsch_modulation_stats, "DLSCH modulation time"); printStatIndent2(&eNB->dlsch_scrambling_stats, "DLSCH scrambling time");
printStatIndent2(&eNB->dlsch_modulation_stats, "DLSCH modulation time");
printDistribution(&eNB->ofdm_mod_stats,table_tx_ifft,"OFDM_mod (idft) time"); printDistribution(&eNB->ofdm_mod_stats,table_tx_ifft,"OFDM_mod (idft) time");
printf("\nUE RX function statistics (per 1ms subframe)\n"); printf("\nUE RX function statistics (per 1ms subframe)\n");
printDistribution(&phy_proc_rx_tot, table_rx,"Total PHY proc rx"); printDistribution(&phy_proc_rx_tot, table_rx,"Total PHY proc rx");
printStatIndent(&ue_front_end_tot,"Front end processing"); printStatIndent(&ue_front_end_tot,"Front end processing");
printStatIndent(&dlsch_llr_tot,"rx_pdsch processing"); printStatIndent(&dlsch_llr_tot,"rx_pdsch processing");
printStatIndent2(&pdsch_procedures_tot,"pdsch processing", pdsch_procedures_tot.trials); printStatIndent2(&pdsch_procedures_tot,"pdsch processing");
printStatIndent2(&dlsch_procedures_tot,"dlsch processing", dlsch_procedures_tot.trials); printStatIndent2(&dlsch_procedures_tot,"dlsch processing");
printStatIndent2(&UE->crnti_procedures_stats,"C-RNTI processing", UE->crnti_procedures_stats.trials); printStatIndent2(&UE->crnti_procedures_stats,"C-RNTI processing");
printStatIndent(&UE->ofdm_demod_stats,"ofdm demodulation"); printStatIndent(&UE->ofdm_demod_stats,"ofdm demodulation");
printStatIndent(&UE->dlsch_channel_estimation_stats,"DLSCH channel estimation time"); printStatIndent(&UE->dlsch_channel_estimation_stats,"DLSCH channel estimation time");
printStatIndent(&UE->dlsch_freq_offset_estimation_stats,"DLSCH frequency offset estimation time"); printStatIndent(&UE->dlsch_freq_offset_estimation_stats,"DLSCH frequency offset estimation time");
...@@ -2041,13 +2019,13 @@ int main(int argc, char **argv) ...@@ -2041,13 +2019,13 @@ int main(int argc, char **argv)
(double)UE->dlsch_turbo_decoding_stats.diff/UE->dlsch_turbo_decoding_stats.trials*timeBase, (double)UE->dlsch_turbo_decoding_stats.diff/UE->dlsch_turbo_decoding_stats.trials*timeBase,
(int)((double)UE->dlsch_turbo_decoding_stats.diff/UE->dlsch_turbo_decoding_stats.trials), (int)((double)UE->dlsch_turbo_decoding_stats.diff/UE->dlsch_turbo_decoding_stats.trials),
UE->dlsch_turbo_decoding_stats.trials); UE->dlsch_turbo_decoding_stats.trials);
printStatIndent2(&UE->dlsch_tc_init_stats,"init", UE->dlsch_tc_init_stats.trials); printStatIndent2(&UE->dlsch_tc_init_stats,"init");
printStatIndent2(&UE->dlsch_tc_alpha_stats,"alpha", UE->dlsch_tc_init_stats.trials); printStatIndent2(&UE->dlsch_tc_alpha_stats,"alpha");
printStatIndent2(&UE->dlsch_tc_beta_stats,"beta", UE->dlsch_tc_init_stats.trials); printStatIndent2(&UE->dlsch_tc_beta_stats,"beta");
printStatIndent2(&UE->dlsch_tc_gamma_stats,"gamma", UE->dlsch_tc_init_stats.trials); printStatIndent2(&UE->dlsch_tc_gamma_stats,"gamma");
printStatIndent2(&UE->dlsch_tc_ext_stats,"ext", UE->dlsch_tc_init_stats.trials); printStatIndent2(&UE->dlsch_tc_ext_stats,"ext");
printStatIndent2(&UE->dlsch_tc_intl1_stats,"turbo internal interleaver", UE->dlsch_tc_init_stats.trials); printStatIndent2(&UE->dlsch_tc_intl1_stats,"turbo internal interleaver");
printStatIndent2(&UE->dlsch_tc_intl2_stats,"intl2+HardDecode+CRC", UE->dlsch_tc_init_stats.trials); printStatIndent2(&UE->dlsch_tc_intl2_stats,"intl2+HardDecode+CRC");
} }
......
...@@ -96,30 +96,7 @@ nfapi_tx_request_pdu_t tx_pdu_list[MAX_NUM_TX_REQUEST_PDU]; ...@@ -96,30 +96,7 @@ nfapi_tx_request_pdu_t tx_pdu_list[MAX_NUM_TX_REQUEST_PDU];
nfapi_tx_request_t TX_req; nfapi_tx_request_t TX_req;
Sched_Rsp_t sched_resp; Sched_Rsp_t sched_resp;
char *parallel_config = NULL; THREAD_STRUCT thread_struct;
char *worker_config = NULL;
static THREAD_STRUCT thread_struct;
void set_parallel_conf(char *parallel_conf)
{
if(strcmp(parallel_conf,"PARALLEL_SINGLE_THREAD")==0) thread_struct.parallel_conf = PARALLEL_SINGLE_THREAD;
else if(strcmp(parallel_conf,"PARALLEL_RU_L1_SPLIT")==0) thread_struct.parallel_conf = PARALLEL_RU_L1_SPLIT;
else if(strcmp(parallel_conf,"PARALLEL_RU_L1_TRX_SPLIT")==0) thread_struct.parallel_conf = PARALLEL_RU_L1_TRX_SPLIT;
printf("[CONFIG] parallel conf is set to %d\n",thread_struct.parallel_conf);
}
void set_worker_conf(char *worker_conf)
{
if(strcmp(worker_conf,"WORKER_DISABLE")==0) thread_struct.worker_conf = WORKER_DISABLE;
else if(strcmp(worker_conf,"WORKER_ENABLE")==0) thread_struct.worker_conf = WORKER_ENABLE;
printf("[CONFIG] worker conf is set to %d\n",thread_struct.worker_conf);
}
PARALLEL_CONF_t get_thread_parallel_conf(void)
{
return thread_struct.parallel_conf;
}
WORKER_CONF_t get_thread_worker_conf(void)
{
return thread_struct.worker_conf;
}
void void
fill_nfapi_ulsch_config_request(nfapi_ul_config_request_pdu_t *ul_config_pdu, fill_nfapi_ulsch_config_request(nfapi_ul_config_request_pdu_t *ul_config_pdu,
...@@ -410,7 +387,6 @@ int main(int argc, char **argv) { ...@@ -410,7 +387,6 @@ int main(int argc, char **argv) {
double effective_rate=0.0; double effective_rate=0.0;
char channel_model_input[10]= {0}; char channel_model_input[10]= {0};
static int max_turbo_iterations=4; static int max_turbo_iterations=4;
static int parallel_flag=0;
int nb_rb_set = 0; int nb_rb_set = 0;
int sf; int sf;
static int threequarter_fs=0; static int threequarter_fs=0;
...@@ -428,6 +404,8 @@ int main(int argc, char **argv) { ...@@ -428,6 +404,8 @@ int main(int argc, char **argv) {
TX_req.tx_request_body.tx_pdu_list = tx_pdu_list; TX_req.tx_request_body.tx_pdu_list = tx_pdu_list;
cpu_freq_GHz = (double)get_cpu_freq_GHz(); cpu_freq_GHz = (double)get_cpu_freq_GHz();
cpuf = cpu_freq_GHz; cpuf = cpu_freq_GHz;
set_parallel_conf("PARALLEL_SINGLE_THREAD");
printf("Detected cpu_freq %f GHz\n",cpu_freq_GHz); printf("Detected cpu_freq %f GHz\n",cpu_freq_GHz);
AssertFatal(load_configmodule(argc,argv,CONFIG_ENABLECMDLINEONLY) != NULL, AssertFatal(load_configmodule(argc,argv,CONFIG_ENABLECMDLINEONLY) != NULL,
"cannot load configuration module, exiting\n"); "cannot load configuration module, exiting\n");
...@@ -455,7 +433,7 @@ int main(int argc, char **argv) { ...@@ -455,7 +433,7 @@ int main(int argc, char **argv) {
{ "Doppler", "Maximum doppler shift",0, dblptr:&maxDoppler, defdblval:0.0, TYPE_DOUBLE, 0 }, { "Doppler", "Maximum doppler shift",0, dblptr:&maxDoppler, defdblval:0.0, TYPE_DOUBLE, 0 },
{ "Zdump", "dump table",PARAMFLAG_BOOL, iptr:&dump_table, defintval:0, TYPE_INT, 0 }, { "Zdump", "dump table",PARAMFLAG_BOOL, iptr:&dump_table, defintval:0, TYPE_INT, 0 },
{ "Forms", "Display the soft scope", PARAMFLAG_BOOL, iptr:&xforms, defintval:0, TYPE_INT, 0 }, { "Forms", "Display the soft scope", PARAMFLAG_BOOL, iptr:&xforms, defintval:0, TYPE_INT, 0 },
{ "Lparallel", "Enable parallel execution", PARAMFLAG_BOOL, iptr:&parallel_flag, defintval:0, TYPE_INT, 0 }, { "Lparallel", "Enable parallel execution",0, strptr:NULL, defstrval:NULL, TYPE_STRING, 0 },
{ "Iterations", "Number of iterations of turbo decoder", 0, iptr:&max_turbo_iterations, defintval:4, TYPE_INT, 0 }, { "Iterations", "Number of iterations of turbo decoder", 0, iptr:&max_turbo_iterations, defintval:4, TYPE_INT, 0 },
{ "Performance", "Display CPU perfomance of each L1 piece", PARAMFLAG_BOOL, iptr:NULL, defintval:0, TYPE_INT, 0 }, { "Performance", "Display CPU perfomance of each L1 piece", PARAMFLAG_BOOL, iptr:NULL, defintval:0, TYPE_INT, 0 },
{ "Q_cqi", "Enable CQI", PARAMFLAG_BOOL, iptr:&cqi_flag, defintval:0, TYPE_INT, 0 }, { "Q_cqi", "Enable CQI", PARAMFLAG_BOOL, iptr:&cqi_flag, defintval:0, TYPE_INT, 0 },
...@@ -600,6 +578,10 @@ int main(int argc, char **argv) { ...@@ -600,6 +578,10 @@ int main(int argc, char **argv) {
opp_enabled=1; opp_enabled=1;
break; break;
case 'L':
set_parallel_conf(optarg);
break;
default: default:
printf("Wrong option: %s\n",long_options[option_index].name); printf("Wrong option: %s\n",long_options[option_index].name);
exit(1); exit(1);
...@@ -618,7 +600,7 @@ int main(int argc, char **argv) { ...@@ -618,7 +600,7 @@ int main(int argc, char **argv) {
if (help) if (help)
exit(0); exit(0);
set_parallel_conf("PARALLEL_RU_L1_TRX_SPLIT"); if (thread_struct.parallel_conf != PARALLEL_SINGLE_THREAD)
set_worker_conf("WORKER_ENABLE"); set_worker_conf("WORKER_ENABLE");
RC.nb_L1_inst = 1; RC.nb_L1_inst = 1;
RC.nb_RU = 1; RC.nb_RU = 1;
...@@ -767,7 +749,7 @@ int main(int argc, char **argv) { ...@@ -767,7 +749,7 @@ int main(int argc, char **argv) {
UE->ulsch[0] = new_ue_ulsch(N_RB_DL,0); UE->ulsch[0] = new_ue_ulsch(N_RB_DL,0);
printf("ULSCH %p\n",UE->ulsch[0]); printf("ULSCH %p\n",UE->ulsch[0]);
if (parallel_flag == 1) { if(get_thread_worker_conf() == WORKER_ENABLE) {
extern void init_fep_thread(PHY_VARS_eNB *, pthread_attr_t *); extern void init_fep_thread(PHY_VARS_eNB *, pthread_attr_t *);
extern void init_td_thread(PHY_VARS_eNB *); extern void init_td_thread(PHY_VARS_eNB *);
init_fep_thread(eNB,NULL); init_fep_thread(eNB,NULL);
...@@ -1175,8 +1157,7 @@ int main(int argc, char **argv) { ...@@ -1175,8 +1157,7 @@ int main(int argc, char **argv) {
} }
start_meas(&eNB->phy_proc_rx); start_meas(&eNB->phy_proc_rx);
ru->feprx = (parallel_flag == 1) ? ru_fep_full_2thread : fep_full; ru->feprx = (get_thread_worker_conf() == WORKER_ENABLE) ? ru_fep_full_2thread : fep_full;
eNB->td = (parallel_flag == 1) ? ulsch_decoding_data_2thread : ulsch_decoding_data;
ru->feprx(ru); ru->feprx(ru);
phy_procedures_eNB_uespec_RX(eNB,proc_rxtx); phy_procedures_eNB_uespec_RX(eNB,proc_rxtx);
stop_meas(&eNB->phy_proc_rx); stop_meas(&eNB->phy_proc_rx);
...@@ -1377,20 +1358,18 @@ int main(int argc, char **argv) { ...@@ -1377,20 +1358,18 @@ int main(int argc, char **argv) {
printStatIndent(&UE->ulsch_rate_matching_stats,"ULSCH rate-matching time"); printStatIndent(&UE->ulsch_rate_matching_stats,"ULSCH rate-matching time");
printStatIndent(&UE->ulsch_interleaving_stats,"ULSCH sub-block interleaving"); printStatIndent(&UE->ulsch_interleaving_stats,"ULSCH sub-block interleaving");
printStatIndent(&UE->ulsch_multiplexing_stats,"ULSCH multiplexing time"); printStatIndent(&UE->ulsch_multiplexing_stats,"ULSCH multiplexing time");
printDistribution(&eNB->phy_proc_rx,table_rx,"\nTotal PHY proc rx subframe"); printf("\n");
printDistribution(&ru->ofdm_demod_stats,table_rx_fft,"OFDM_demod time"); printDistribution(&eNB->phy_proc_rx,table_rx,"Total PHY proc rx subframe");
printDistribution(&eNB->ulsch_demodulation_stats,table_rx_demod,"ULSCH demodulation time"); printDistribution(&ru->ofdm_demod_stats,table_rx_fft,"|__ OFDM_demod time");
printf("ULSCH Decoding time (%.2f Mbit/s, avg iter %.2f) :%.2f us (%d trials, max %.2f)\n", printDistribution(&eNB->ulsch_demodulation_stats,table_rx_demod,"|__ ULSCH demodulation time");
UE->ulsch[0]->harq_processes[harq_pid]->TBS/1000.0,(double)iter_trials, printDistribution(&eNB->ulsch_decoding_stats,table_rx_dec,"|__ ULSCH Decoding time");
(double)eNB->ulsch_decoding_stats.diff/eNB->ulsch_decoding_stats.trials*timeBase, printf(" (%.2f Mbit/s, avg iter %.2f, max %.2f)\n",
eNB->ulsch_decoding_stats.trials, UE->ulsch[0]->harq_processes[harq_pid]->TBS/1000.0,
(double)iter_trials,
(double)eNB->ulsch_decoding_stats.max*timeBase); (double)eNB->ulsch_decoding_stats.max*timeBase);
printf("|__ Statistics std: %.2fus median %.2fus q1 %.2fus q3 %.2fus \n", printStatIndent2(&eNB->ulsch_deinterleaving_stats,"sub-block interleaving" );
squareRoot(&eNB->ulsch_decoding_stats), printStatIndent2(&eNB->ulsch_demultiplexing_stats,"sub-block demultiplexing" );
median(table_rx_dec), q1(table_rx_dec), q3(table_rx_dec)); printStatIndent2(&eNB->ulsch_rate_unmatching_stats,"sub-block rate-matching" );
printStatIndent(&eNB->ulsch_deinterleaving_stats,"sub-block interleaving" );
printStatIndent(&eNB->ulsch_demultiplexing_stats,"sub-block demultiplexing" );
printStatIndent(&eNB->ulsch_rate_unmatching_stats,"sub-block rate-matching" );
printf("|__ turbo_decoder(%d bits), avg iterations: %.1f %.2f us (%d cycles, %d trials)\n", printf("|__ turbo_decoder(%d bits), avg iterations: %.1f %.2f us (%d cycles, %d trials)\n",
eNB->ulsch[0]->harq_processes[harq_pid]->Cminus ? eNB->ulsch[0]->harq_processes[harq_pid]->Cminus ?
eNB->ulsch[0]->harq_processes[harq_pid]->Kminus : eNB->ulsch[0]->harq_processes[harq_pid]->Kminus :
...@@ -1399,13 +1378,13 @@ int main(int argc, char **argv) { ...@@ -1399,13 +1378,13 @@ int main(int argc, char **argv) {
(double)eNB->ulsch_turbo_decoding_stats.diff/eNB->ulsch_turbo_decoding_stats.trials*timeBase, (double)eNB->ulsch_turbo_decoding_stats.diff/eNB->ulsch_turbo_decoding_stats.trials*timeBase,
(int)((double)eNB->ulsch_turbo_decoding_stats.diff/eNB->ulsch_turbo_decoding_stats.trials), (int)((double)eNB->ulsch_turbo_decoding_stats.diff/eNB->ulsch_turbo_decoding_stats.trials),
eNB->ulsch_turbo_decoding_stats.trials); eNB->ulsch_turbo_decoding_stats.trials);
printStatIndent2(&eNB->ulsch_tc_init_stats,"init", eNB->ulsch_tc_init_stats.trials); printStatIndent3(&eNB->ulsch_tc_init_stats,"init");
printStatIndent2(&eNB->ulsch_tc_alpha_stats,"alpha", eNB->ulsch_tc_init_stats.trials); printStatIndent3(&eNB->ulsch_tc_alpha_stats,"alpha");
printStatIndent2(&eNB->ulsch_tc_beta_stats,"beta", eNB->ulsch_tc_init_stats.trials); printStatIndent3(&eNB->ulsch_tc_beta_stats,"beta");
printStatIndent2(&eNB->ulsch_tc_gamma_stats,"gamma", eNB->ulsch_tc_init_stats.trials); printStatIndent3(&eNB->ulsch_tc_gamma_stats,"gamma");
printStatIndent2(&eNB->ulsch_tc_ext_stats,"ext", eNB->ulsch_tc_init_stats.trials); printStatIndent3(&eNB->ulsch_tc_ext_stats,"ext");
printStatIndent2(&eNB->ulsch_tc_intl1_stats,"turbo internal interleaver", eNB->ulsch_tc_init_stats.trials); printStatIndent3(&eNB->ulsch_tc_intl1_stats,"turbo internal interleaver");
printStatIndent2(&eNB->ulsch_tc_intl2_stats,"intl2+HardDecode+CRC", eNB->ulsch_tc_init_stats.trials); printStatIndent3(&eNB->ulsch_tc_intl2_stats,"intl2+HardDecode+CRC");
} }
if(abstx) { //ABSTRACTION if(abstx) { //ABSTRACTION
......
...@@ -149,8 +149,6 @@ void wakeup_prach_eNB(PHY_VARS_eNB *eNB,RU_t *ru,int frame,int subframe); ...@@ -149,8 +149,6 @@ void wakeup_prach_eNB(PHY_VARS_eNB *eNB,RU_t *ru,int frame,int subframe);
#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
void wakeup_prach_eNB_br(PHY_VARS_eNB *eNB,RU_t *ru,int frame,int subframe); void wakeup_prach_eNB_br(PHY_VARS_eNB *eNB,RU_t *ru,int frame,int subframe);
#endif #endif
extern PARALLEL_CONF_t get_thread_parallel_conf(void);
extern WORKER_CONF_t get_thread_worker_conf(void);
extern uint8_t nfapi_mode; extern uint8_t nfapi_mode;
extern void oai_subframe_ind(uint16_t sfn, uint16_t sf); extern void oai_subframe_ind(uint16_t sfn, uint16_t sf);
...@@ -800,9 +798,10 @@ static void *process_stats_thread(void *param) { ...@@ -800,9 +798,10 @@ static void *process_stats_thread(void *param) {
sleep(1); sleep(1);
if (opp_enabled == 1) { if (opp_enabled == 1) {
if (eNB->td) print_meas(&eNB->ulsch_decoding_stats,"ulsch_decoding",NULL,NULL); if ( eNB->ulsch_decoding_stats.trials>0)
print_meas(&eNB->ulsch_decoding_stats,"ulsch_decoding",NULL,NULL);
if (eNB->te) { if (eNB->dlsch_encoding_stats.trials >0) {
print_meas(&eNB->dlsch_turbo_encoding_preperation_stats,"dlsch_coding_crc",NULL,NULL); print_meas(&eNB->dlsch_turbo_encoding_preperation_stats,"dlsch_coding_crc",NULL,NULL);
print_meas(&eNB->dlsch_turbo_encoding_segmentation_stats,"dlsch_segmentation",NULL,NULL); print_meas(&eNB->dlsch_turbo_encoding_segmentation_stats,"dlsch_segmentation",NULL,NULL);
print_meas(&eNB->dlsch_encoding_stats,"dlsch_encoding",NULL,NULL); print_meas(&eNB->dlsch_encoding_stats,"dlsch_encoding",NULL,NULL);
...@@ -1210,7 +1209,7 @@ void init_eNB(int single_thread_flag,int wait_for_sync) { ...@@ -1210,7 +1209,7 @@ void init_eNB(int single_thread_flag,int wait_for_sync) {
PHY_VARS_eNB *eNB; PHY_VARS_eNB *eNB;
LOG_I(PHY,"[lte-softmodem.c] eNB structure about to allocated RC.nb_L1_inst:%d RC.nb_L1_CC[0]:%d\n",RC.nb_L1_inst,RC.nb_L1_CC[0]); LOG_I(PHY,"[lte-softmodem.c] eNB structure about to allocated RC.nb_L1_inst:%d RC.nb_L1_CC[0]:%d\n",RC.nb_L1_inst,RC.nb_L1_CC[0]);
if (RC.eNB == NULL) RC.eNB = (PHY_VARS_eNB ***) malloc(RC.nb_L1_inst*sizeof(PHY_VARS_eNB **)); if (RC.eNB == NULL) RC.eNB = (PHY_VARS_eNB ** *) malloc(RC.nb_L1_inst*sizeof(PHY_VARS_eNB **));
LOG_I(PHY,"[lte-softmodem.c] eNB structure RC.eNB allocated\n"); LOG_I(PHY,"[lte-softmodem.c] eNB structure RC.eNB allocated\n");
...@@ -1227,8 +1226,6 @@ void init_eNB(int single_thread_flag,int wait_for_sync) { ...@@ -1227,8 +1226,6 @@ void init_eNB(int single_thread_flag,int wait_for_sync) {
#ifndef OCP_FRAMEWORK #ifndef OCP_FRAMEWORK
LOG_I(PHY,"Initializing eNB %d CC_id %d\n",inst,CC_id); LOG_I(PHY,"Initializing eNB %d CC_id %d\n",inst,CC_id);
#endif #endif
eNB->td = ulsch_decoding_data_all;
eNB->te = dlsch_encoding_all;
LOG_I(PHY,"Registering with MAC interface module\n"); LOG_I(PHY,"Registering with MAC interface module\n");
AssertFatal((eNB->if_inst = IF_Module_init(inst))!=NULL,"Cannot register interface"); AssertFatal((eNB->if_inst = IF_Module_init(inst))!=NULL,"Cannot register interface");
eNB->if_inst->schedule_response = schedule_response; eNB->if_inst->schedule_response = schedule_response;
......
...@@ -79,11 +79,11 @@ unsigned short config_frames[4] = {2,9,11,13}; ...@@ -79,11 +79,11 @@ unsigned short config_frames[4] = {2,9,11,13};
//#include "PHY/TOOLS/time_meas.h" //#include "PHY/TOOLS/time_meas.h"
#ifndef OPENAIR2 #ifndef OPENAIR2
#include "UTIL/OTG/otg_vars.h" #include "UTIL/OTG/otg_vars.h"
#endif #endif
#if defined(ENABLE_ITTI) #if defined(ENABLE_ITTI)
#include "create_tasks.h" #include "create_tasks.h"
#endif #endif
#include "PHY/INIT/phy_init.h" #include "PHY/INIT/phy_init.h"
...@@ -91,24 +91,24 @@ unsigned short config_frames[4] = {2,9,11,13}; ...@@ -91,24 +91,24 @@ unsigned short config_frames[4] = {2,9,11,13};
#include "system.h" #include "system.h"
#ifdef XFORMS #ifdef XFORMS
#include "PHY/TOOLS/lte_phy_scope.h" #include "PHY/TOOLS/lte_phy_scope.h"
#include "stats.h" #include "stats.h"
#endif #endif
#include "lte-softmodem.h" #include "lte-softmodem.h"
#include "NB_IoT_interface.h" #include "NB_IoT_interface.h"
#ifdef XFORMS #ifdef XFORMS
// current status is that every UE has a DL scope for a SINGLE eNB (eNB_id=0) // current status is that every UE has a DL scope for a SINGLE eNB (eNB_id=0)
// at eNB 0, an UL scope for every UE // at eNB 0, an UL scope for every UE
FD_lte_phy_scope_ue *form_ue[NUMBER_OF_UE_MAX]; FD_lte_phy_scope_ue *form_ue[NUMBER_OF_UE_MAX];
FD_lte_phy_scope_enb *form_enb[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; FD_lte_phy_scope_enb *form_enb[MAX_NUM_CCs][NUMBER_OF_UE_MAX];
FD_stats_form *form_stats=NULL,*form_stats_l2=NULL; FD_stats_form *form_stats=NULL,*form_stats_l2=NULL;
char title[255]; char title[255];
unsigned char scope_enb_num_ue = 2; unsigned char scope_enb_num_ue = 2;
static pthread_t forms_thread; //xforms static pthread_t forms_thread; //xforms
#endif //XFORMS #endif //XFORMS
#ifndef ENABLE_USE_MME #ifndef ENABLE_USE_MME
#define EPC_MODE_ENABLED 0 #define EPC_MODE_ENABLED 0
#endif #endif
pthread_cond_t nfapi_sync_cond; pthread_cond_t nfapi_sync_cond;
...@@ -128,8 +128,8 @@ uint16_t runtime_phy_rx[29][6]; // SISO [MCS 0-28][RBs 0-5 : 6, 15, 25, 50, 75, ...@@ -128,8 +128,8 @@ uint16_t runtime_phy_rx[29][6]; // SISO [MCS 0-28][RBs 0-5 : 6, 15, 25, 50, 75,
uint16_t runtime_phy_tx[29][6]; // SISO [MCS 0-28][RBs 0-5 : 6, 15, 25, 50, 75, 100] uint16_t runtime_phy_tx[29][6]; // SISO [MCS 0-28][RBs 0-5 : 6, 15, 25, 50, 75, 100]
#if defined(ENABLE_ITTI) #if defined(ENABLE_ITTI)
volatile int start_eNB = 0; volatile int start_eNB = 0;
volatile int start_UE = 0; volatile int start_UE = 0;
#endif #endif
volatile int oai_exit = 0; volatile int oai_exit = 0;
...@@ -171,9 +171,9 @@ char channels[128] = "0"; ...@@ -171,9 +171,9 @@ char channels[128] = "0";
int rx_input_level_dBm; int rx_input_level_dBm;
#ifdef XFORMS #ifdef XFORMS
extern int otg_enabled; extern int otg_enabled;
#else #else
int otg_enabled; int otg_enabled;
#endif #endif
//int number_of_cards = 1; //int number_of_cards = 1;
...@@ -190,7 +190,9 @@ extern void init_eNB_afterRU(void); ...@@ -190,7 +190,9 @@ extern void init_eNB_afterRU(void);
int transmission_mode=1; int transmission_mode=1;
THREAD_STRUCT thread_struct;
/* struct for ethernet specific parameters given in eNB conf file */
eth_params_t *eth_params;
double cpuf; double cpuf;
...@@ -206,6 +208,7 @@ struct timespec max_diff_time = { .tv_sec = 0, .tv_nsec = 0 }; ...@@ -206,6 +208,7 @@ struct timespec max_diff_time = { .tv_sec = 0, .tv_nsec = 0 };
struct timespec clock_difftime(struct timespec start, struct timespec end) { struct timespec clock_difftime(struct timespec start, struct timespec end) {
struct timespec temp; struct timespec temp;
if ((end.tv_nsec-start.tv_nsec)<0) { if ((end.tv_nsec-start.tv_nsec)<0) {
temp.tv_sec = end.tv_sec-start.tv_sec-1; temp.tv_sec = end.tv_sec-start.tv_sec-1;
temp.tv_nsec = 1000000000+end.tv_nsec-start.tv_nsec; temp.tv_nsec = 1000000000+end.tv_nsec-start.tv_nsec;
...@@ -213,6 +216,7 @@ struct timespec clock_difftime(struct timespec start, struct timespec end) { ...@@ -213,6 +216,7 @@ struct timespec clock_difftime(struct timespec start, struct timespec end) {
temp.tv_sec = end.tv_sec-start.tv_sec; temp.tv_sec = end.tv_sec-start.tv_sec;
temp.tv_nsec = end.tv_nsec-start.tv_nsec; temp.tv_nsec = end.tv_nsec-start.tv_nsec;
} }
return temp; return temp;
} }
...@@ -228,16 +232,21 @@ void update_difftimes(struct timespec start, struct timespec end) { ...@@ -228,16 +232,21 @@ void update_difftimes(struct timespec start, struct timespec end) {
struct timespec diff_time = { .tv_sec = 0, .tv_nsec = 0 }; struct timespec diff_time = { .tv_sec = 0, .tv_nsec = 0 };
int changed = 0; int changed = 0;
diff_time = clock_difftime(start, end); diff_time = clock_difftime(start, end);
if ((min_diff_time.tv_nsec == 0) || (diff_time.tv_nsec < min_diff_time.tv_nsec)) { if ((min_diff_time.tv_nsec == 0) || (diff_time.tv_nsec < min_diff_time.tv_nsec)) {
min_diff_time.tv_nsec = diff_time.tv_nsec; min_diff_time.tv_nsec = diff_time.tv_nsec;
changed = 1; changed = 1;
} }
if ((max_diff_time.tv_nsec == 0) || (diff_time.tv_nsec > max_diff_time.tv_nsec)) { if ((max_diff_time.tv_nsec == 0) || (diff_time.tv_nsec > max_diff_time.tv_nsec)) {
max_diff_time.tv_nsec = diff_time.tv_nsec; max_diff_time.tv_nsec = diff_time.tv_nsec;
changed = 1; changed = 1;
} }
#if 1 #if 1
if (changed) print_difftimes(); if (changed) print_difftimes();
#endif #endif
} }
...@@ -258,7 +267,6 @@ void signal_handler(int sig) { ...@@ -258,7 +267,6 @@ void signal_handler(int sig) {
if (sig==SIGSEGV) { if (sig==SIGSEGV) {
// get void*'s for all entries on the stack // get void*'s for all entries on the stack
size = backtrace(array, 10); size = backtrace(array, 10);
// print out all the frames to stderr // print out all the frames to stderr
fprintf(stderr, "Error: signal %d:\n", sig); fprintf(stderr, "Error: signal %d:\n", sig);
backtrace_symbols_fd(array, size, 2); backtrace_symbols_fd(array, size, 2);
...@@ -266,15 +274,11 @@ void signal_handler(int sig) { ...@@ -266,15 +274,11 @@ void signal_handler(int sig) {
} else { } else {
printf("Linux signal %s...\n",strsignal(sig)); printf("Linux signal %s...\n",strsignal(sig));
exit_function(__FILE__, __FUNCTION__, __LINE__,"softmodem starting exit procedure\n"); exit_function(__FILE__, __FUNCTION__, __LINE__,"softmodem starting exit procedure\n");
} }
} }
void exit_function(const char* file, const char* function, const int line, const char* s) void exit_function(const char *file, const char *function, const int line, const char *s) {
{
int ru_id; int ru_id;
if (s != NULL) { if (s != NULL) {
...@@ -283,34 +287,32 @@ void exit_function(const char* file, const char* function, const int line, const ...@@ -283,34 +287,32 @@ void exit_function(const char* file, const char* function, const int line, const
oai_exit = 1; oai_exit = 1;
if (RC.ru == NULL) if (RC.ru == NULL)
exit(-1); // likely init not completed, prevent crash or hang, exit now... exit(-1); // likely init not completed, prevent crash or hang, exit now...
for (ru_id=0; ru_id<RC.nb_RU;ru_id++) {
for (ru_id=0; ru_id<RC.nb_RU; ru_id++) {
if (RC.ru[ru_id] && RC.ru[ru_id]->rfdevice.trx_end_func) { if (RC.ru[ru_id] && RC.ru[ru_id]->rfdevice.trx_end_func) {
RC.ru[ru_id]->rfdevice.trx_end_func(&RC.ru[ru_id]->rfdevice); RC.ru[ru_id]->rfdevice.trx_end_func(&RC.ru[ru_id]->rfdevice);
RC.ru[ru_id]->rfdevice.trx_end_func = NULL; RC.ru[ru_id]->rfdevice.trx_end_func = NULL;
} }
if (RC.ru[ru_id] && RC.ru[ru_id]->ifdevice.trx_end_func) { if (RC.ru[ru_id] && RC.ru[ru_id]->ifdevice.trx_end_func) {
RC.ru[ru_id]->ifdevice.trx_end_func(&RC.ru[ru_id]->ifdevice); RC.ru[ru_id]->ifdevice.trx_end_func(&RC.ru[ru_id]->ifdevice);
RC.ru[ru_id]->ifdevice.trx_end_func = NULL; RC.ru[ru_id]->ifdevice.trx_end_func = NULL;
} }
} }
sleep(1); //allow lte-softmodem threads to exit first sleep(1); //allow lte-softmodem threads to exit first
#if defined(ENABLE_ITTI) #if defined(ENABLE_ITTI)
itti_terminate_tasks (TASK_UNKNOWN); itti_terminate_tasks (TASK_UNKNOWN);
#endif #endif
exit(1); exit(1);
} }
#ifdef XFORMS #ifdef XFORMS
void reset_stats(FL_OBJECT *button, long arg) void reset_stats(FL_OBJECT *button, long arg) {
{
int i,j,k; int i,j,k;
PHY_VARS_eNB *phy_vars_eNB = RC.eNB[0][0]; PHY_VARS_eNB *phy_vars_eNB = RC.eNB[0][0];
...@@ -325,8 +327,6 @@ void reset_stats(FL_OBJECT *button, long arg) ...@@ -325,8 +327,6 @@ void reset_stats(FL_OBJECT *button, long arg)
phy_vars_eNB->UE_stats[i].dlsch_l2_errors[k]=0; phy_vars_eNB->UE_stats[i].dlsch_l2_errors[k]=0;
phy_vars_eNB->UE_stats[i].ulsch_errors[k]=0; phy_vars_eNB->UE_stats[i].ulsch_errors[k]=0;
phy_vars_eNB->UE_stats[i].ulsch_consecutive_errors=0; phy_vars_eNB->UE_stats[i].ulsch_consecutive_errors=0;
phy_vars_eNB->UE_stats[i].dlsch_sliding_cnt=0; phy_vars_eNB->UE_stats[i].dlsch_sliding_cnt=0;
phy_vars_eNB->UE_stats[i].dlsch_NAK_round0=0; phy_vars_eNB->UE_stats[i].dlsch_NAK_round0=0;
phy_vars_eNB->UE_stats[i].dlsch_mcs_offset=0; phy_vars_eNB->UE_stats[i].dlsch_mcs_offset=0;
...@@ -335,28 +335,22 @@ void reset_stats(FL_OBJECT *button, long arg) ...@@ -335,28 +335,22 @@ void reset_stats(FL_OBJECT *button, long arg)
} }
static void *scope_thread(void *arg) { static void *scope_thread(void *arg) {
# ifdef ENABLE_XFORMS_WRITE_STATS # ifdef ENABLE_XFORMS_WRITE_STATS
FILE *eNB_stats; FILE *eNB_stats;
# endif # endif
struct sched_param sched_param; struct sched_param sched_param;
int UE_id, CC_id; int UE_id, CC_id;
int ue_cnt=0; int ue_cnt=0;
sched_param.sched_priority = sched_get_priority_min(SCHED_FIFO)+1; sched_param.sched_priority = sched_get_priority_min(SCHED_FIFO)+1;
sched_setscheduler(0, SCHED_FIFO,&sched_param); sched_setscheduler(0, SCHED_FIFO,&sched_param);
printf("Scope thread has priority %d\n",sched_param.sched_priority); printf("Scope thread has priority %d\n",sched_param.sched_priority);
# ifdef ENABLE_XFORMS_WRITE_STATS # ifdef ENABLE_XFORMS_WRITE_STATS
eNB_stats = fopen("eNB_stats.txt", "w"); eNB_stats = fopen("eNB_stats.txt", "w");
#endif #endif
while (!oai_exit) { while (!oai_exit) {
ue_cnt=0; ue_cnt=0;
for(UE_id=0; UE_id<NUMBER_OF_UE_MAX; UE_id++) { for(UE_id=0; UE_id<NUMBER_OF_UE_MAX; UE_id++) {
for(CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { for(CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
if ((ue_cnt<scope_enb_num_ue)) { if ((ue_cnt<scope_enb_num_ue)) {
...@@ -367,11 +361,11 @@ static void *scope_thread(void *arg) { ...@@ -367,11 +361,11 @@ static void *scope_thread(void *arg) {
} }
} }
} }
sleep(1); sleep(1);
} }
// printf("%s",stats_buffer); // printf("%s",stats_buffer);
# ifdef ENABLE_XFORMS_WRITE_STATS # ifdef ENABLE_XFORMS_WRITE_STATS
if (eNB_stats) { if (eNB_stats) {
...@@ -381,8 +375,7 @@ static void *scope_thread(void *arg) { ...@@ -381,8 +375,7 @@ static void *scope_thread(void *arg) {
} }
# endif # endif
pthread_exit((void *)arg);
pthread_exit((void*)arg);
} }
#endif #endif
...@@ -393,12 +386,11 @@ static void *scope_thread(void *arg) { ...@@ -393,12 +386,11 @@ static void *scope_thread(void *arg) {
void *l2l1_task(void *arg) { void *l2l1_task(void *arg) {
MessageDef *message_p = NULL; MessageDef *message_p = NULL;
int result; int result;
itti_set_task_real_time(TASK_L2L1); itti_set_task_real_time(TASK_L2L1);
itti_mark_task_ready(TASK_L2L1); itti_mark_task_ready(TASK_L2L1);
/* Wait for the initialize message */ /* Wait for the initialize message */
printf("Wait for the ITTI initialize message\n"); printf("Wait for the ITTI initialize message\n");
while (1) { while (1) {
itti_receive_msg (TASK_L2L1, &message_p); itti_receive_msg (TASK_L2L1, &message_p);
...@@ -444,18 +436,17 @@ void *l2l1_task(void *arg) { ...@@ -444,18 +436,17 @@ void *l2l1_task(void *arg) {
static void get_options(void) { static void get_options(void) {
CONFIG_SETRTFLAG(CONFIG_NOEXITONHELP); CONFIG_SETRTFLAG(CONFIG_NOEXITONHELP);
get_common_options(); get_common_options();
CONFIG_CLEARRTFLAG(CONFIG_NOEXITONHELP); CONFIG_CLEARRTFLAG(CONFIG_NOEXITONHELP);
if ( !(CONFIG_ISFLAGSET(CONFIG_ABORT)) ) { if ( !(CONFIG_ISFLAGSET(CONFIG_ABORT)) ) {
memset((void*)&RC,0,sizeof(RC)); memset((void *)&RC,0,sizeof(RC));
/* Read RC configuration file */ /* Read RC configuration file */
RCConfig(); RCConfig();
NB_eNB_INST = RC.nb_inst; NB_eNB_INST = RC.nb_inst;
printf("Configuration: nb_rrc_inst %d, nb_L1_inst %d, nb_ru %d\n",NB_eNB_INST,RC.nb_L1_inst,RC.nb_RU); printf("Configuration: nb_rrc_inst %d, nb_L1_inst %d, nb_ru %d\n",NB_eNB_INST,RC.nb_L1_inst,RC.nb_RU);
if (!SOFTMODEM_NONBIOT) { if (!SOFTMODEM_NONBIOT) {
load_NB_IoT(); load_NB_IoT();
printf(" nb_nbiot_rrc_inst %d, nb_nbiot_L1_inst %d, nb_nbiot_macrlc_inst %d\n", printf(" nb_nbiot_rrc_inst %d, nb_nbiot_L1_inst %d, nb_nbiot_macrlc_inst %d\n",
...@@ -465,7 +456,6 @@ static void get_options(void) { ...@@ -465,7 +456,6 @@ static void get_options(void) {
RC.nb_nb_iot_rrc_inst=RC.nb_nb_iot_L1_inst=RC.nb_nb_iot_macrlc_inst=0; RC.nb_nb_iot_rrc_inst=RC.nb_nb_iot_L1_inst=RC.nb_nb_iot_macrlc_inst=0;
} }
} }
} }
...@@ -473,11 +463,10 @@ static void get_options(void) { ...@@ -473,11 +463,10 @@ static void get_options(void) {
void set_default_frame_parms(LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]) { void set_default_frame_parms(LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]) {
int CC_id; int CC_id;
for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
frame_parms[CC_id] = (LTE_DL_FRAME_PARMS*) malloc(sizeof(LTE_DL_FRAME_PARMS)); frame_parms[CC_id] = (LTE_DL_FRAME_PARMS *) malloc(sizeof(LTE_DL_FRAME_PARMS));
/* Set some default values that may be overwritten while reading options */ /* Set some default values that may be overwritten while reading options */
frame_parms[CC_id]->frame_type = FDD; frame_parms[CC_id]->frame_type = FDD;
frame_parms[CC_id]->tdd_config = 3; frame_parms[CC_id]->tdd_config = 3;
...@@ -491,9 +480,7 @@ void set_default_frame_parms(LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]) { ...@@ -491,9 +480,7 @@ void set_default_frame_parms(LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]) {
frame_parms[CC_id]->nb_antenna_ports_eNB = 1; frame_parms[CC_id]->nb_antenna_ports_eNB = 1;
frame_parms[CC_id]->nb_antennas_tx = 1; frame_parms[CC_id]->nb_antennas_tx = 1;
frame_parms[CC_id]->nb_antennas_rx = 1; frame_parms[CC_id]->nb_antennas_rx = 1;
frame_parms[CC_id]->nushift = 0; frame_parms[CC_id]->nushift = 0;
frame_parms[CC_id]->phich_config_common.phich_resource = oneSixth; frame_parms[CC_id]->phich_config_common.phich_resource = oneSixth;
frame_parms[CC_id]->phich_config_common.phich_duration = normal; frame_parms[CC_id]->phich_config_common.phich_duration = normal;
// UL RS Config // UL RS Config
...@@ -501,54 +488,47 @@ void set_default_frame_parms(LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]) { ...@@ -501,54 +488,47 @@ void set_default_frame_parms(LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]) {
frame_parms[CC_id]->pusch_config_common.ul_ReferenceSignalsPUSCH.groupHoppingEnabled = 0; frame_parms[CC_id]->pusch_config_common.ul_ReferenceSignalsPUSCH.groupHoppingEnabled = 0;
frame_parms[CC_id]->pusch_config_common.ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled = 0; frame_parms[CC_id]->pusch_config_common.ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled = 0;
frame_parms[CC_id]->pusch_config_common.ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH = 0; frame_parms[CC_id]->pusch_config_common.ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH = 0;
frame_parms[CC_id]->prach_config_common.rootSequenceIndex=22; frame_parms[CC_id]->prach_config_common.rootSequenceIndex=22;
frame_parms[CC_id]->prach_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig=1; frame_parms[CC_id]->prach_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig=1;
frame_parms[CC_id]->prach_config_common.prach_ConfigInfo.prach_ConfigIndex=0; frame_parms[CC_id]->prach_config_common.prach_ConfigInfo.prach_ConfigIndex=0;
frame_parms[CC_id]->prach_config_common.prach_ConfigInfo.highSpeedFlag=0; frame_parms[CC_id]->prach_config_common.prach_ConfigInfo.highSpeedFlag=0;
frame_parms[CC_id]->prach_config_common.prach_ConfigInfo.prach_FreqOffset=0; frame_parms[CC_id]->prach_config_common.prach_ConfigInfo.prach_FreqOffset=0;
// downlink_frequency[CC_id][0] = 2680000000; // Use float to avoid issue with frequency over 2^31.
// downlink_frequency[CC_id][0] = 2680000000; // Use float to avoid issue with frequency over 2^31. // downlink_frequency[CC_id][1] = downlink_frequency[CC_id][0];
// downlink_frequency[CC_id][1] = downlink_frequency[CC_id][0]; // downlink_frequency[CC_id][2] = downlink_frequency[CC_id][0];
// downlink_frequency[CC_id][2] = downlink_frequency[CC_id][0]; // downlink_frequency[CC_id][3] = downlink_frequency[CC_id][0];
// downlink_frequency[CC_id][3] = downlink_frequency[CC_id][0];
//printf("Downlink for CC_id %d frequency set to %u\n", CC_id, downlink_frequency[CC_id][0]); //printf("Downlink for CC_id %d frequency set to %u\n", CC_id, downlink_frequency[CC_id][0]);
frame_parms[CC_id]->dl_CarrierFreq=downlink_frequency[CC_id][0]; frame_parms[CC_id]->dl_CarrierFreq=downlink_frequency[CC_id][0];
} }
} }
void wait_RUs(void) { void wait_RUs(void) {
LOG_I(PHY,"Waiting for RUs to be configured ... RC.ru_mask:%02lx\n", RC.ru_mask); LOG_I(PHY,"Waiting for RUs to be configured ... RC.ru_mask:%02lx\n", RC.ru_mask);
// wait for all RUs to be configured over fronthaul // wait for all RUs to be configured over fronthaul
pthread_mutex_lock(&RC.ru_mutex); pthread_mutex_lock(&RC.ru_mutex);
while (RC.ru_mask>0) { while (RC.ru_mask>0) {
pthread_cond_wait(&RC.ru_cond,&RC.ru_mutex); pthread_cond_wait(&RC.ru_cond,&RC.ru_mutex);
printf("RC.ru_mask:%02lx\n", RC.ru_mask); printf("RC.ru_mask:%02lx\n", RC.ru_mask);
} }
pthread_mutex_unlock(&RC.ru_mutex);
pthread_mutex_unlock(&RC.ru_mutex);
LOG_I(PHY,"RUs configured\n"); LOG_I(PHY,"RUs configured\n");
} }
void wait_eNBs(void) { void wait_eNBs(void) {
int i,j; int i,j;
int waiting=1; int waiting=1;
while (waiting==1) { while (waiting==1) {
printf("Waiting for eNB L1 instances to all get configured ... sleeping 50ms (nb_L1_inst %d)\n",RC.nb_L1_inst); printf("Waiting for eNB L1 instances to all get configured ... sleeping 50ms (nb_L1_inst %d)\n",RC.nb_L1_inst);
usleep(50*1000); usleep(50*1000);
waiting=0; waiting=0;
for (i=0;i<RC.nb_L1_inst;i++) {
for (i=0; i<RC.nb_L1_inst; i++) {
printf("RC.nb_L1_CC[%d]:%d\n", i, RC.nb_L1_CC[i]); printf("RC.nb_L1_CC[%d]:%d\n", i, RC.nb_L1_CC[i]);
for (j=0;j<RC.nb_L1_CC[i];j++) { for (j=0; j<RC.nb_L1_CC[i]; j++) {
if (RC.eNB[i][j]->configured==0) { if (RC.eNB[i][j]->configured==0) {
waiting=1; waiting=1;
break; break;
...@@ -556,6 +536,7 @@ void wait_eNBs(void) { ...@@ -556,6 +536,7 @@ void wait_eNBs(void) {
} }
} }
} }
printf("eNB L1 are configured\n"); printf("eNB L1 are configured\n");
} }
...@@ -563,8 +544,7 @@ void wait_eNBs(void) { ...@@ -563,8 +544,7 @@ void wait_eNBs(void) {
/* /*
* helper function to terminate a certain ITTI task * helper function to terminate a certain ITTI task
*/ */
void terminate_task(module_id_t mod_id, task_id_t from, task_id_t to) void terminate_task(module_id_t mod_id, task_id_t from, task_id_t to) {
{
LOG_I(ENB_APP, "sending TERMINATE_MESSAGE from task %s (%d) to task %s (%d)\n", LOG_I(ENB_APP, "sending TERMINATE_MESSAGE from task %s (%d) to task %s (%d)\n",
itti_get_task_name(from), from, itti_get_task_name(to), to); itti_get_task_name(from), from, itti_get_task_name(to), to);
MessageDef *msg; MessageDef *msg;
...@@ -573,10 +553,9 @@ void terminate_task(module_id_t mod_id, task_id_t from, task_id_t to) ...@@ -573,10 +553,9 @@ void terminate_task(module_id_t mod_id, task_id_t from, task_id_t to)
} }
extern void free_transport(PHY_VARS_eNB *); extern void free_transport(PHY_VARS_eNB *);
extern void phy_free_RU(RU_t*); extern void phy_free_RU(RU_t *);
int stop_L1L2(module_id_t enb_id) int stop_L1L2(module_id_t enb_id) {
{
LOG_W(ENB_APP, "stopping lte-softmodem\n"); LOG_W(ENB_APP, "stopping lte-softmodem\n");
if (!RC.ru) { if (!RC.ru) {
...@@ -593,10 +572,12 @@ int stop_L1L2(module_id_t enb_id) ...@@ -593,10 +572,12 @@ int stop_L1L2(module_id_t enb_id)
LOG_I(ENB_APP, "calling kill_eNB_proc() for instance %d\n", enb_id); LOG_I(ENB_APP, "calling kill_eNB_proc() for instance %d\n", enb_id);
kill_eNB_proc(enb_id); kill_eNB_proc(enb_id);
oai_exit = 0; oai_exit = 0;
for (int cc_id = 0; cc_id < RC.nb_CC[enb_id]; cc_id++) { for (int cc_id = 0; cc_id < RC.nb_CC[enb_id]; cc_id++) {
free_transport(RC.eNB[enb_id][cc_id]); free_transport(RC.eNB[enb_id][cc_id]);
phy_free_lte_eNB(RC.eNB[enb_id][cc_id]); phy_free_lte_eNB(RC.eNB[enb_id][cc_id]);
} }
phy_free_RU(RC.ru[enb_id]); phy_free_RU(RC.ru[enb_id]);
free_lte_top(); free_lte_top();
return 0; return 0;
...@@ -605,14 +586,11 @@ int stop_L1L2(module_id_t enb_id) ...@@ -605,14 +586,11 @@ int stop_L1L2(module_id_t enb_id)
/* /*
* Restart the lte-softmodem after it has been soft-stopped with stop_L1L2() * Restart the lte-softmodem after it has been soft-stopped with stop_L1L2()
*/ */
int restart_L1L2(module_id_t enb_id) int restart_L1L2(module_id_t enb_id) {
{
RU_t *ru = RC.ru[enb_id]; RU_t *ru = RC.ru[enb_id];
int cc_id; int cc_id;
MessageDef *msg_p = NULL; MessageDef *msg_p = NULL;
LOG_W(ENB_APP, "restarting lte-softmodem\n"); LOG_W(ENB_APP, "restarting lte-softmodem\n");
/* block threads */ /* block threads */
pthread_mutex_lock(&sync_mutex); pthread_mutex_lock(&sync_mutex);
sync_var = -1; sync_var = -1;
...@@ -630,14 +608,15 @@ int restart_L1L2(module_id_t enb_id) ...@@ -630,14 +608,15 @@ int restart_L1L2(module_id_t enb_id)
/* reset the list of connected UEs in the MAC, since in this process with /* reset the list of connected UEs in the MAC, since in this process with
* loose all UEs (have to reconnect) */ * loose all UEs (have to reconnect) */
init_UE_list(&RC.mac[enb_id]->UE_list); init_UE_list(&RC.mac[enb_id]->UE_list);
LOG_I(ENB_APP, "attempting to create ITTI tasks\n"); LOG_I(ENB_APP, "attempting to create ITTI tasks\n");
if (itti_create_task (TASK_RRC_ENB, rrc_enb_task, NULL) < 0) { if (itti_create_task (TASK_RRC_ENB, rrc_enb_task, NULL) < 0) {
LOG_E(RRC, "Create task for RRC eNB failed\n"); LOG_E(RRC, "Create task for RRC eNB failed\n");
return -1; return -1;
} else { } else {
LOG_I(RRC, "Re-created task for RRC eNB successfully\n"); LOG_I(RRC, "Re-created task for RRC eNB successfully\n");
} }
if (itti_create_task (TASK_L2L1, l2l1_task, NULL) < 0) { if (itti_create_task (TASK_L2L1, l2l1_task, NULL) < 0) {
LOG_E(PDCP, "Create task for L2L1 failed\n"); LOG_E(PDCP, "Create task for L2L1 failed\n");
return -1; return -1;
...@@ -652,26 +631,22 @@ int restart_L1L2(module_id_t enb_id) ...@@ -652,26 +631,22 @@ int restart_L1L2(module_id_t enb_id)
itti_send_msg_to_task(TASK_RRC_ENB, ENB_MODULE_ID_TO_INSTANCE(enb_id), msg_p); itti_send_msg_to_task(TASK_RRC_ENB, ENB_MODULE_ID_TO_INSTANCE(enb_id), msg_p);
/* TODO XForms might need to be restarted, but it is currently (09/02/18) /* TODO XForms might need to be restarted, but it is currently (09/02/18)
* broken, so we cannot test it */ * broken, so we cannot test it */
wait_eNBs(); wait_eNBs();
init_RU_proc(ru); init_RU_proc(ru);
ru->rf_map.card = 0; ru->rf_map.card = 0;
ru->rf_map.chain = 0; /* CC_id + chain_offset;*/ ru->rf_map.chain = 0; /* CC_id + chain_offset;*/
wait_RUs(); wait_RUs();
init_eNB_afterRU(); init_eNB_afterRU();
printf("Sending sync to all threads\n"); printf("Sending sync to all threads\n");
pthread_mutex_lock(&sync_mutex); pthread_mutex_lock(&sync_mutex);
sync_var=0; sync_var=0;
pthread_cond_broadcast(&sync_cond); pthread_cond_broadcast(&sync_cond);
pthread_mutex_unlock(&sync_mutex); pthread_mutex_unlock(&sync_mutex);
return 0; return 0;
} }
#endif #endif
static void wait_nfapi_init(char *thread_name) { static void wait_nfapi_init(char *thread_name) {
printf( "waiting for NFAPI PNF connection and population of global structure (%s)\n",thread_name); printf( "waiting for NFAPI PNF connection and population of global structure (%s)\n",thread_name);
pthread_mutex_lock( &nfapi_sync_mutex ); pthread_mutex_lock( &nfapi_sync_mutex );
...@@ -679,74 +654,65 @@ static void wait_nfapi_init(char *thread_name) { ...@@ -679,74 +654,65 @@ static void wait_nfapi_init(char *thread_name) {
pthread_cond_wait( &nfapi_sync_cond, &nfapi_sync_mutex ); pthread_cond_wait( &nfapi_sync_cond, &nfapi_sync_mutex );
pthread_mutex_unlock(&nfapi_sync_mutex); pthread_mutex_unlock(&nfapi_sync_mutex);
printf( "NFAPI: got sync (%s)\n", thread_name); printf( "NFAPI: got sync (%s)\n", thread_name);
} }
int main( int argc, char **argv ) int main( int argc, char **argv ) {
{
int i; int i;
#if defined (XFORMS) #if defined (XFORMS)
void *status; void *status;
#endif #endif
int CC_id; int CC_id;
int ru_id; int ru_id;
#if defined (XFORMS) #if defined (XFORMS)
int ret; int ret;
#endif #endif
if ( load_configmodule(argc,argv,0) == NULL) { if ( load_configmodule(argc,argv,0) == NULL) {
exit_fun("[SOFTMODEM] Error, configuration module init failed\n"); exit_fun("[SOFTMODEM] Error, configuration module init failed\n");
} }
mode = normal_txrx; mode = normal_txrx;
set_latency_target(); set_latency_target();
logInit(); logInit();
printf("Reading in command-line options\n"); printf("Reading in command-line options\n");
CONFIG_SETRTFLAG(CONFIG_NOCHECKUNKOPT); CONFIG_SETRTFLAG(CONFIG_NOCHECKUNKOPT);
get_options (); get_options ();
if (CONFIG_ISFLAGSET(CONFIG_ABORT) ) { if (CONFIG_ISFLAGSET(CONFIG_ABORT) ) {
fprintf(stderr,"Getting configuration failed\n"); fprintf(stderr,"Getting configuration failed\n");
exit(-1); exit(-1);
} }
#if T_TRACER #if T_TRACER
T_Config_Init(); T_Config_Init();
#endif #endif
ret=config_check_cmdlineopt(NULL); ret=config_check_cmdlineopt(NULL);
if (ret != 0) { if (ret != 0) {
LOG_E(ENB_APP, "%i unknown options in command line\n",ret); LOG_E(ENB_APP, "%i unknown options in command line\n",ret);
exit_fun(""); exit_fun("");
} }
CONFIG_CLEARRTFLAG(CONFIG_NOCHECKUNKOPT); CONFIG_CLEARRTFLAG(CONFIG_NOCHECKUNKOPT);
//randominit (0); //randominit (0);
set_taus_seed (0); set_taus_seed (0);
printf("configuring for RAU/RRU\n"); printf("configuring for RAU/RRU\n");
if (opp_enabled ==1) { if (opp_enabled ==1) {
reset_opp_meas(); reset_opp_meas();
} }
cpuf=get_cpu_freq_GHz();
cpuf=get_cpu_freq_GHz();
#if defined(ENABLE_ITTI) #if defined(ENABLE_ITTI)
printf("ITTI init, useMME: %i\n" ,EPC_MODE_ENABLED); printf("ITTI init, useMME: %i\n" ,EPC_MODE_ENABLED);
itti_init(TASK_MAX, THREAD_MAX, MESSAGES_ID_MAX, tasks_info, messages_info); itti_init(TASK_MAX, THREAD_MAX, MESSAGES_ID_MAX, tasks_info, messages_info);
// initialize mscgen log after ITTI // initialize mscgen log after ITTI
if (get_softmodem_params()->start_msc) { if (get_softmodem_params()->start_msc) {
load_module_shlib("msc",NULL,0,&msc_interface); load_module_shlib("msc",NULL,0,&msc_interface);
} }
MSC_INIT(MSC_E_UTRAN, THREAD_MAX+TASK_MAX); MSC_INIT(MSC_E_UTRAN, THREAD_MAX+TASK_MAX);
#endif #endif
...@@ -762,56 +728,50 @@ int main( int argc, char **argv ) ...@@ -762,56 +728,50 @@ int main( int argc, char **argv )
pdcp_netlink_init(); pdcp_netlink_init();
#endif #endif
#endif #endif
// to make a graceful exit when ctrl-c is pressed // to make a graceful exit when ctrl-c is pressed
signal(SIGSEGV, signal_handler); signal(SIGSEGV, signal_handler);
signal(SIGINT, signal_handler); signal(SIGINT, signal_handler);
signal(SIGTERM, signal_handler); signal(SIGTERM, signal_handler);
signal(SIGABRT, signal_handler); signal(SIGABRT, signal_handler);
check_clock(); check_clock();
#ifndef PACKAGE_VERSION #ifndef PACKAGE_VERSION
# define PACKAGE_VERSION "UNKNOWN-EXPERIMENTAL" # define PACKAGE_VERSION "UNKNOWN-EXPERIMENTAL"
#endif #endif
LOG_I(HW, "Version: %s\n", PACKAGE_VERSION); LOG_I(HW, "Version: %s\n", PACKAGE_VERSION);
printf("Runtime table\n"); printf("Runtime table\n");
fill_modeled_runtime_table(runtime_phy_rx,runtime_phy_tx); fill_modeled_runtime_table(runtime_phy_rx,runtime_phy_tx);
#ifndef DEADLINE_SCHEDULER #ifndef DEADLINE_SCHEDULER
printf("NO deadline scheduler\n"); printf("NO deadline scheduler\n");
/* Currently we set affinity for UHD to CPU 0 for eNB/UE and only if number of CPUS >2 */ /* Currently we set affinity for UHD to CPU 0 for eNB/UE and only if number of CPUS >2 */
cpu_set_t cpuset; cpu_set_t cpuset;
int s; int s;
char cpu_affinity[1024]; char cpu_affinity[1024];
CPU_ZERO(&cpuset); CPU_ZERO(&cpuset);
#ifdef CPU_AFFINITY #ifdef CPU_AFFINITY
if (get_nprocs() > 2) { if (get_nprocs() > 2) {
CPU_SET(0, &cpuset); CPU_SET(0, &cpuset);
s = pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); s = pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset);
if (s != 0) { if (s != 0) {
perror( "pthread_setaffinity_np"); perror( "pthread_setaffinity_np");
exit_fun("Error setting processor affinity"); exit_fun("Error setting processor affinity");
} }
LOG_I(HW, "Setting the affinity of main function to CPU 0, for device library to use CPU 0 only!\n"); LOG_I(HW, "Setting the affinity of main function to CPU 0, for device library to use CPU 0 only!\n");
} }
#endif
#endif
/* Check the actual affinity mask assigned to the thread */ /* Check the actual affinity mask assigned to the thread */
s = pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); s = pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset);
if (s != 0) { if (s != 0) {
perror( "pthread_getaffinity_np"); perror( "pthread_getaffinity_np");
exit_fun("Error getting processor affinity "); exit_fun("Error getting processor affinity ");
} }
memset(cpu_affinity, 0 , sizeof(cpu_affinity)); memset(cpu_affinity, 0 , sizeof(cpu_affinity));
for (int j = 0; j < CPU_SETSIZE; j++) { for (int j = 0; j < CPU_SETSIZE; j++) {
if (CPU_ISSET(j, &cpuset)) { if (CPU_ISSET(j, &cpuset)) {
char temp[1024]; char temp[1024];
...@@ -819,30 +779,28 @@ int main( int argc, char **argv ) ...@@ -819,30 +779,28 @@ int main( int argc, char **argv )
strcat(cpu_affinity, temp); strcat(cpu_affinity, temp);
} }
} }
LOG_I(HW, "CPU Affinity of main() function is... %s\n", cpu_affinity); LOG_I(HW, "CPU Affinity of main() function is... %s\n", cpu_affinity);
#endif #endif
#if defined(ENABLE_ITTI) #if defined(ENABLE_ITTI)
if (RC.nb_inst > 0) {
if (RC.nb_inst > 0) {
// don't create if node doesn't connect to RRC/S1/GTP // don't create if node doesn't connect to RRC/S1/GTP
if (create_tasks(1) < 0) { if (create_tasks(1) < 0) {
printf("cannot create ITTI tasks\n"); printf("cannot create ITTI tasks\n");
exit(-1); // need a softer mode exit(-1); // need a softer mode
} }
printf("ITTI tasks created\n"); printf("ITTI tasks created\n");
} } else {
else {
printf("No ITTI, Initializing L1\n"); printf("No ITTI, Initializing L1\n");
RCconfig_L1(); RCconfig_L1();
} }
#endif
#endif
/* Start the agent. If it is turned off in the configuration, it won't start */ /* Start the agent. If it is turned off in the configuration, it won't start */
RCconfig_flexran(); RCconfig_flexran();
for (i = 0; i < RC.nb_L1_inst; i++) { for (i = 0; i < RC.nb_L1_inst; i++) {
flexran_agent_start(i); flexran_agent_start(i);
} }
...@@ -850,20 +808,15 @@ int main( int argc, char **argv ) ...@@ -850,20 +808,15 @@ int main( int argc, char **argv )
// init UE_PF_PO and mutex lock // init UE_PF_PO and mutex lock
pthread_mutex_init(&ue_pf_po_mutex, NULL); pthread_mutex_init(&ue_pf_po_mutex, NULL);
memset (&UE_PF_PO[0][0], 0, sizeof(UE_PF_PO_t)*MAX_MOBILES_PER_ENB*MAX_NUM_CCs); memset (&UE_PF_PO[0][0], 0, sizeof(UE_PF_PO_t)*MAX_MOBILES_PER_ENB*MAX_NUM_CCs);
mlockall(MCL_CURRENT | MCL_FUTURE); mlockall(MCL_CURRENT | MCL_FUTURE);
pthread_cond_init(&sync_cond,NULL); pthread_cond_init(&sync_cond,NULL);
pthread_mutex_init(&sync_mutex, NULL); pthread_mutex_init(&sync_mutex, NULL);
#ifdef XFORMS #ifdef XFORMS
int UE_id; int UE_id;
printf("XFORMS\n"); printf("XFORMS\n");
if (get_softmodem_params()->do_forms==1) { if (get_softmodem_params()->do_forms==1) {
fl_initialize (&argc, argv, NULL, 0, 0); fl_initialize (&argc, argv, NULL, 0, 0);
form_stats_l2 = create_form_stats_form(); form_stats_l2 = create_form_stats_form();
fl_show_form (form_stats_l2->stats_form, FL_PLACE_HOTSPOT, FL_FULLBORDER, "l2 stats"); fl_show_form (form_stats_l2->stats_form, FL_PLACE_HOTSPOT, FL_FULLBORDER, "l2 stats");
form_stats = create_form_stats_form(); form_stats = create_form_stats_form();
...@@ -894,11 +847,9 @@ int main( int argc, char **argv ) ...@@ -894,11 +847,9 @@ int main( int argc, char **argv )
} }
#endif #endif
rt_sleep_ns(10*100000000ULL); rt_sleep_ns(10*100000000ULL);
if (nfapi_mode) if (nfapi_mode) {
{
printf("NFAPI*** - mutex and cond created - will block shortly for completion of PNF connection\n"); printf("NFAPI*** - mutex and cond created - will block shortly for completion of PNF connection\n");
pthread_cond_init(&sync_cond,NULL); pthread_cond_init(&sync_cond,NULL);
pthread_mutex_init(&sync_mutex, NULL); pthread_mutex_init(&sync_mutex, NULL);
...@@ -910,27 +861,30 @@ int main( int argc, char **argv ) ...@@ -910,27 +861,30 @@ int main( int argc, char **argv )
case 0: case 0:
nfapi_mode_str = "MONOLITHIC"; nfapi_mode_str = "MONOLITHIC";
break; break;
case 1: case 1:
nfapi_mode_str = "PNF"; nfapi_mode_str = "PNF";
break; break;
case 2: case 2:
nfapi_mode_str = "VNF"; nfapi_mode_str = "VNF";
break; break;
default: default:
nfapi_mode_str = "<UNKNOWN NFAPI MODE>"; nfapi_mode_str = "<UNKNOWN NFAPI MODE>";
break; break;
} }
printf("NFAPI MODE:%s\n", nfapi_mode_str); printf("NFAPI MODE:%s\n", nfapi_mode_str);
if (nfapi_mode==2) // VNF if (nfapi_mode==2) // VNF
wait_nfapi_init("main?"); wait_nfapi_init("main?");
printf("START MAIN THREADS\n"); printf("START MAIN THREADS\n");
// start the main threads // start the main threads
number_of_cards = 1; number_of_cards = 1;
printf("RC.nb_L1_inst:%d\n", RC.nb_L1_inst); printf("RC.nb_L1_inst:%d\n", RC.nb_L1_inst);
if (RC.nb_L1_inst > 0) { if (RC.nb_L1_inst > 0) {
printf("Initializing eNB threads single_thread_flag:%d wait_for_sync:%d\n", get_softmodem_params()->single_thread_flag,get_softmodem_params()->wait_for_sync); printf("Initializing eNB threads single_thread_flag:%d wait_for_sync:%d\n", get_softmodem_params()->single_thread_flag,get_softmodem_params()->wait_for_sync);
init_eNB(get_softmodem_params()->single_thread_flag,get_softmodem_params()->wait_for_sync); init_eNB(get_softmodem_params()->single_thread_flag,get_softmodem_params()->wait_for_sync);
...@@ -940,12 +894,13 @@ int main( int argc, char **argv ) ...@@ -940,12 +894,13 @@ int main( int argc, char **argv )
printf("wait_eNBs()\n"); printf("wait_eNBs()\n");
wait_eNBs(); wait_eNBs();
printf("About to Init RU threads RC.nb_RU:%d\n", RC.nb_RU); printf("About to Init RU threads RC.nb_RU:%d\n", RC.nb_RU);
if (RC.nb_RU >0) { if (RC.nb_RU >0) {
printf("Initializing RU threads\n"); printf("Initializing RU threads\n");
init_RU(get_softmodem_params()->rf_config_file); init_RU(get_softmodem_params()->rf_config_file);
for (ru_id=0;ru_id<RC.nb_RU;ru_id++) {
for (ru_id=0; ru_id<RC.nb_RU; ru_id++) {
RC.ru[ru_id]->rf_map.card=0; RC.ru[ru_id]->rf_map.card=0;
RC.ru[ru_id]->rf_map.chain=CC_id+(get_softmodem_params()->chain_offset); RC.ru[ru_id]->rf_map.chain=CC_id+(get_softmodem_params()->chain_offset);
} }
...@@ -966,31 +921,23 @@ int main( int argc, char **argv ) ...@@ -966,31 +921,23 @@ int main( int argc, char **argv )
// once all RUs are ready intiailize the rest of the eNBs ((dependence on final RU parameters after configuration) // once all RUs are ready intiailize the rest of the eNBs ((dependence on final RU parameters after configuration)
printf("ALL RUs ready - init eNBs\n"); printf("ALL RUs ready - init eNBs\n");
if (nfapi_mode != 1 && nfapi_mode != 2) if (nfapi_mode != 1 && nfapi_mode != 2) {
{
printf("Not NFAPI mode - call init_eNB_afterRU()\n"); printf("Not NFAPI mode - call init_eNB_afterRU()\n");
init_eNB_afterRU(); init_eNB_afterRU();
} } else {
else
{
printf("NFAPI mode - DO NOT call init_eNB_afterRU()\n"); printf("NFAPI mode - DO NOT call init_eNB_afterRU()\n");
} }
printf("ALL RUs ready - ALL eNBs ready\n"); printf("ALL RUs ready - ALL eNBs ready\n");
// connect the TX/RX buffers // connect the TX/RX buffers
sleep(1); /* wait for thread activation */ sleep(1); /* wait for thread activation */
printf("Sending sync to all threads\n"); printf("Sending sync to all threads\n");
pthread_mutex_lock(&sync_mutex); pthread_mutex_lock(&sync_mutex);
sync_var=0; sync_var=0;
pthread_cond_broadcast(&sync_cond); pthread_cond_broadcast(&sync_cond);
pthread_mutex_unlock(&sync_mutex); pthread_mutex_unlock(&sync_mutex);
ret=config_check_cmdlineopt(CONFIG_CHECKALLSECTIONS); ret=config_check_cmdlineopt(CONFIG_CHECKALLSECTIONS);
if (ret != 0) { if (ret != 0) {
LOG_E(ENB_APP, "%i unknown options in command line (invalid section name)\n",ret); LOG_E(ENB_APP, "%i unknown options in command line (invalid section name)\n",ret);
exit_fun(""); exit_fun("");
...@@ -999,7 +946,6 @@ int main( int argc, char **argv ) ...@@ -999,7 +946,6 @@ int main( int argc, char **argv )
// wait for end of program // wait for end of program
printf("TYPE <CTRL-C> TO TERMINATE\n"); printf("TYPE <CTRL-C> TO TERMINATE\n");
//getchar(); //getchar();
#if defined(ENABLE_ITTI) #if defined(ENABLE_ITTI)
printf("Entering ITTI signals handler\n"); printf("Entering ITTI signals handler\n");
itti_wait_tasks_end(); itti_wait_tasks_end();
...@@ -1010,10 +956,9 @@ int main( int argc, char **argv ) ...@@ -1010,10 +956,9 @@ int main( int argc, char **argv )
while (oai_exit==0) while (oai_exit==0)
rt_sleep_ns(100000000ULL); rt_sleep_ns(100000000ULL);
printf("Terminating application - oai_exit=%d\n",oai_exit);
printf("Terminating application - oai_exit=%d\n",oai_exit);
#endif #endif
// stop threads // stop threads
#ifdef XFORMS #ifdef XFORMS
printf("waiting for XFORMS thread\n"); printf("waiting for XFORMS thread\n");
...@@ -1022,7 +967,6 @@ int main( int argc, char **argv ) ...@@ -1022,7 +967,6 @@ int main( int argc, char **argv )
pthread_join(forms_thread,&status); pthread_join(forms_thread,&status);
fl_hide_form(form_stats->stats_form); fl_hide_form(form_stats->stats_form);
fl_free_form(form_stats->stats_form); fl_free_form(form_stats->stats_form);
fl_hide_form(form_stats_l2->stats_form); fl_hide_form(form_stats_l2->stats_form);
fl_free_form(form_stats_l2->stats_form); fl_free_form(form_stats_l2->stats_form);
...@@ -1035,11 +979,10 @@ int main( int argc, char **argv ) ...@@ -1035,11 +979,10 @@ int main( int argc, char **argv )
} }
#endif #endif
printf("stopping MODEM threads\n"); printf("stopping MODEM threads\n");
stop_eNB(NB_eNB_INST); stop_eNB(NB_eNB_INST);
stop_RU(RC.nb_RU); stop_RU(RC.nb_RU);
/* release memory used by the RU/eNB threads (incomplete), after all /* release memory used by the RU/eNB threads (incomplete), after all
* threads have been stopped (they partially use the same memory) */ * threads have been stopped (they partially use the same memory) */
for (int inst = 0; inst < NB_eNB_INST; inst++) { for (int inst = 0; inst < NB_eNB_INST; inst++) {
...@@ -1048,29 +991,27 @@ int main( int argc, char **argv ) ...@@ -1048,29 +991,27 @@ int main( int argc, char **argv )
phy_free_lte_eNB(RC.eNB[inst][cc_id]); phy_free_lte_eNB(RC.eNB[inst][cc_id]);
} }
} }
for (int inst = 0; inst < RC.nb_RU; inst++) { for (int inst = 0; inst < RC.nb_RU; inst++) {
phy_free_RU(RC.ru[inst]); phy_free_RU(RC.ru[inst]);
} }
free_lte_top();
free_lte_top();
printf("About to call end_configmodule() from %s() %s:%d\n", __FUNCTION__, __FILE__, __LINE__); printf("About to call end_configmodule() from %s() %s:%d\n", __FUNCTION__, __FILE__, __LINE__);
end_configmodule(); end_configmodule();
printf("Called end_configmodule() from %s() %s:%d\n", __FUNCTION__, __FILE__, __LINE__); printf("Called end_configmodule() from %s() %s:%d\n", __FUNCTION__, __FILE__, __LINE__);
pthread_cond_destroy(&sync_cond); pthread_cond_destroy(&sync_cond);
pthread_mutex_destroy(&sync_mutex); pthread_mutex_destroy(&sync_mutex);
pthread_cond_destroy(&nfapi_sync_cond); pthread_cond_destroy(&nfapi_sync_cond);
pthread_mutex_destroy(&nfapi_sync_mutex); pthread_mutex_destroy(&nfapi_sync_mutex);
pthread_mutex_destroy(&ue_pf_po_mutex); pthread_mutex_destroy(&ue_pf_po_mutex);
for(ru_id=0; ru_id<RC.nb_RU; ru_id++) { for(ru_id=0; ru_id<RC.nb_RU; ru_id++) {
if (RC.ru[ru_id]->rfdevice.trx_end_func) { if (RC.ru[ru_id]->rfdevice.trx_end_func) {
RC.ru[ru_id]->rfdevice.trx_end_func(&RC.ru[ru_id]->rfdevice); RC.ru[ru_id]->rfdevice.trx_end_func(&RC.ru[ru_id]->rfdevice);
RC.ru[ru_id]->rfdevice.trx_end_func = NULL; RC.ru[ru_id]->rfdevice.trx_end_func = NULL;
} }
if (RC.ru[ru_id]->ifdevice.trx_end_func) { if (RC.ru[ru_id]->ifdevice.trx_end_func) {
RC.ru[ru_id]->ifdevice.trx_end_func(&RC.ru[ru_id]->ifdevice); RC.ru[ru_id]->ifdevice.trx_end_func(&RC.ru[ru_id]->ifdevice);
RC.ru[ru_id]->ifdevice.trx_end_func = NULL; RC.ru[ru_id]->ifdevice.trx_end_func = NULL;
...@@ -1081,8 +1022,6 @@ int main( int argc, char **argv ) ...@@ -1081,8 +1022,6 @@ int main( int argc, char **argv )
terminate_opt(); terminate_opt();
logClean(); logClean();
printf("Bye.\n"); printf("Bye.\n");
return 0; return 0;
} }
...@@ -75,18 +75,18 @@ ...@@ -75,18 +75,18 @@
#include "UTIL/OPT/opt.h" #include "UTIL/OPT/opt.h"
#ifndef OPENAIR2 #ifndef OPENAIR2
#include "UTIL/OTG/otg_vars.h" #include "UTIL/OTG/otg_vars.h"
#endif #endif
#if defined(ENABLE_ITTI) #if defined(ENABLE_ITTI)
#include "create_tasks.h" #include "create_tasks.h"
#endif #endif
#include "system.h" #include "system.h"
#ifdef XFORMS #ifdef XFORMS
#include "PHY/TOOLS/lte_phy_scope.h" #include "PHY/TOOLS/lte_phy_scope.h"
#include "stats.h" #include "stats.h"
#endif #endif
#include "lte-softmodem.h" #include "lte-softmodem.h"
...@@ -95,14 +95,14 @@ ...@@ -95,14 +95,14 @@
/* temporary compilation wokaround (UE/eNB split */ /* temporary compilation wokaround (UE/eNB split */
uint16_t sf_ahead; uint16_t sf_ahead;
#ifdef XFORMS #ifdef XFORMS
// current status is that every UE has a DL scope for a SINGLE eNB (eNB_id=0) // current status is that every UE has a DL scope for a SINGLE eNB (eNB_id=0)
// at eNB 0, an UL scope for every UE // at eNB 0, an UL scope for every UE
FD_lte_phy_scope_ue *form_ue[NUMBER_OF_UE_MAX]; FD_lte_phy_scope_ue *form_ue[NUMBER_OF_UE_MAX];
FD_lte_phy_scope_enb *form_enb[MAX_NUM_CCs][NUMBER_OF_UE_MAX]; FD_lte_phy_scope_enb *form_enb[MAX_NUM_CCs][NUMBER_OF_UE_MAX];
FD_stats_form *form_stats=NULL,*form_stats_l2=NULL; FD_stats_form *form_stats=NULL,*form_stats_l2=NULL;
char title[255]; char title[255];
unsigned char scope_enb_num_ue = 2; unsigned char scope_enb_num_ue = 2;
static pthread_t forms_thread; //xforms static pthread_t forms_thread; //xforms
#endif //XFORMS #endif //XFORMS
pthread_cond_t nfapi_sync_cond; pthread_cond_t nfapi_sync_cond;
...@@ -125,8 +125,8 @@ uint16_t runtime_phy_rx[29][6]; // SISO [MCS 0-28][RBs 0-5 : 6, 15, 25, 50, 75, ...@@ -125,8 +125,8 @@ uint16_t runtime_phy_rx[29][6]; // SISO [MCS 0-28][RBs 0-5 : 6, 15, 25, 50, 75,
uint16_t runtime_phy_tx[29][6]; // SISO [MCS 0-28][RBs 0-5 : 6, 15, 25, 50, 75, 100] uint16_t runtime_phy_tx[29][6]; // SISO [MCS 0-28][RBs 0-5 : 6, 15, 25, 50, 75, 100]
#if defined(ENABLE_ITTI) #if defined(ENABLE_ITTI)
volatile int start_eNB = 0; volatile int start_eNB = 0;
volatile int start_UE = 0; volatile int start_UE = 0;
#endif #endif
volatile int oai_exit = 0; volatile int oai_exit = 0;
...@@ -181,7 +181,7 @@ char channels[128] = "0"; ...@@ -181,7 +181,7 @@ char channels[128] = "0";
int rx_input_level_dBm; int rx_input_level_dBm;
#ifdef XFORMS #ifdef XFORMS
extern int otg_enabled; extern int otg_enabled;
#endif #endif
//int number_of_cards = 1; //int number_of_cards = 1;
...@@ -195,7 +195,7 @@ uint64_t num_missed_slots=0; // counter for the number of missed slots ...@@ -195,7 +195,7 @@ uint64_t num_missed_slots=0; // counter for the number of missed slots
file */ file */
extern void init_UE_stub_single_thread(int nb_inst,int eMBMS_active, int uecap_xer_in, char *emul_iface); extern void init_UE_stub_single_thread(int nb_inst,int eMBMS_active, int uecap_xer_in, char *emul_iface);
extern PHY_VARS_UE* init_ue_vars(LTE_DL_FRAME_PARMS *frame_parms, extern PHY_VARS_UE *init_ue_vars(LTE_DL_FRAME_PARMS *frame_parms,
uint8_t UE_id, uint8_t UE_id,
uint8_t abstraction_flag); uint8_t abstraction_flag);
...@@ -205,11 +205,10 @@ int transmission_mode=1; ...@@ -205,11 +205,10 @@ int transmission_mode=1;
char* usrp_args=NULL; char *usrp_args=NULL;
char* usrp_clksrc=NULL; char *usrp_clksrc=NULL;
THREAD_STRUCT thread_struct;
/* struct for ethernet specific parameters given in eNB conf file */ /* struct for ethernet specific parameters given in eNB conf file */
eth_params_t *eth_params; eth_params_t *eth_params;
...@@ -238,6 +237,7 @@ struct timespec max_diff_time = { .tv_sec = 0, .tv_nsec = 0 }; ...@@ -238,6 +237,7 @@ struct timespec max_diff_time = { .tv_sec = 0, .tv_nsec = 0 };
struct timespec clock_difftime(struct timespec start, struct timespec end) { struct timespec clock_difftime(struct timespec start, struct timespec end) {
struct timespec temp; struct timespec temp;
if ((end.tv_nsec-start.tv_nsec)<0) { if ((end.tv_nsec-start.tv_nsec)<0) {
temp.tv_sec = end.tv_sec-start.tv_sec-1; temp.tv_sec = end.tv_sec-start.tv_sec-1;
temp.tv_nsec = 1000000000+end.tv_nsec-start.tv_nsec; temp.tv_nsec = 1000000000+end.tv_nsec-start.tv_nsec;
...@@ -245,6 +245,7 @@ struct timespec clock_difftime(struct timespec start, struct timespec end) { ...@@ -245,6 +245,7 @@ struct timespec clock_difftime(struct timespec start, struct timespec end) {
temp.tv_sec = end.tv_sec-start.tv_sec; temp.tv_sec = end.tv_sec-start.tv_sec;
temp.tv_nsec = end.tv_nsec-start.tv_nsec; temp.tv_nsec = end.tv_nsec-start.tv_nsec;
} }
return temp; return temp;
} }
...@@ -260,16 +261,21 @@ void update_difftimes(struct timespec start, struct timespec end) { ...@@ -260,16 +261,21 @@ void update_difftimes(struct timespec start, struct timespec end) {
struct timespec diff_time = { .tv_sec = 0, .tv_nsec = 0 }; struct timespec diff_time = { .tv_sec = 0, .tv_nsec = 0 };
int changed = 0; int changed = 0;
diff_time = clock_difftime(start, end); diff_time = clock_difftime(start, end);
if ((min_diff_time.tv_nsec == 0) || (diff_time.tv_nsec < min_diff_time.tv_nsec)) { if ((min_diff_time.tv_nsec == 0) || (diff_time.tv_nsec < min_diff_time.tv_nsec)) {
min_diff_time.tv_nsec = diff_time.tv_nsec; min_diff_time.tv_nsec = diff_time.tv_nsec;
changed = 1; changed = 1;
} }
if ((max_diff_time.tv_nsec == 0) || (diff_time.tv_nsec > max_diff_time.tv_nsec)) { if ((max_diff_time.tv_nsec == 0) || (diff_time.tv_nsec > max_diff_time.tv_nsec)) {
max_diff_time.tv_nsec = diff_time.tv_nsec; max_diff_time.tv_nsec = diff_time.tv_nsec;
changed = 1; changed = 1;
} }
#if 1 #if 1
if (changed) print_difftimes(); if (changed) print_difftimes();
#endif #endif
} }
...@@ -291,7 +297,6 @@ void signal_handler(int sig) { ...@@ -291,7 +297,6 @@ void signal_handler(int sig) {
if (sig==SIGSEGV) { if (sig==SIGSEGV) {
// get void*'s for all entries on the stack // get void*'s for all entries on the stack
size = backtrace(array, 10); size = backtrace(array, 10);
// print out all the frames to stderr // print out all the frames to stderr
fprintf(stderr, "Error: signal %d:\n", sig); fprintf(stderr, "Error: signal %d:\n", sig);
backtrace_symbols_fd(array, size, 2); backtrace_symbols_fd(array, size, 2);
...@@ -300,20 +305,14 @@ void signal_handler(int sig) { ...@@ -300,20 +305,14 @@ void signal_handler(int sig) {
char msg[64]; char msg[64];
sprintf(msg,"Received linux signal %s...\n",strsignal(sig)); sprintf(msg,"Received linux signal %s...\n",strsignal(sig));
exit_function(__FILE__, __FUNCTION__, __LINE__,msg); exit_function(__FILE__, __FUNCTION__, __LINE__,msg);
} }
} }
void exit_function(const char* file, const char* function, const int line, const char* s) void exit_function(const char *file, const char *function, const int line, const char *s) {
{
int CC_id; int CC_id;
logClean(); logClean();
printf("%s:%d %s() Exiting OAI softmodem: %s\n",file,line, function, ((s==NULL)?"":s)); printf("%s:%d %s() Exiting OAI softmodem: %s\n",file,line, function, ((s==NULL)?"":s));
oai_exit = 1; oai_exit = 1;
for(CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { for(CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
...@@ -326,8 +325,10 @@ void exit_function(const char* file, const char* function, const int line, const ...@@ -326,8 +325,10 @@ void exit_function(const char* file, const char* function, const int line, const
sleep(1); //allow lte-softmodem threads to exit first sleep(1); //allow lte-softmodem threads to exit first
#if defined(ENABLE_ITTI) #if defined(ENABLE_ITTI)
if(PHY_vars_UE_g != NULL ) if(PHY_vars_UE_g != NULL )
itti_terminate_tasks (TASK_UNKNOWN); itti_terminate_tasks (TASK_UNKNOWN);
#endif #endif
exit(1); exit(1);
} }
...@@ -335,8 +336,7 @@ void exit_function(const char* file, const char* function, const int line, const ...@@ -335,8 +336,7 @@ void exit_function(const char* file, const char* function, const int line, const
#ifdef XFORMS #ifdef XFORMS
void reset_stats(FL_OBJECT *button, long arg) void reset_stats(FL_OBJECT *button, long arg) {
{
int i,j,k; int i,j,k;
PHY_VARS_eNB *phy_vars_eNB = RC.eNB[0][0]; PHY_VARS_eNB *phy_vars_eNB = RC.eNB[0][0];
...@@ -351,8 +351,6 @@ void reset_stats(FL_OBJECT *button, long arg) ...@@ -351,8 +351,6 @@ void reset_stats(FL_OBJECT *button, long arg)
phy_vars_eNB->UE_stats[i].dlsch_l2_errors[k]=0; phy_vars_eNB->UE_stats[i].dlsch_l2_errors[k]=0;
phy_vars_eNB->UE_stats[i].ulsch_errors[k]=0; phy_vars_eNB->UE_stats[i].ulsch_errors[k]=0;
phy_vars_eNB->UE_stats[i].ulsch_consecutive_errors=0; phy_vars_eNB->UE_stats[i].ulsch_consecutive_errors=0;
phy_vars_eNB->UE_stats[i].dlsch_sliding_cnt=0; phy_vars_eNB->UE_stats[i].dlsch_sliding_cnt=0;
phy_vars_eNB->UE_stats[i].dlsch_NAK_round0=0; phy_vars_eNB->UE_stats[i].dlsch_NAK_round0=0;
phy_vars_eNB->UE_stats[i].dlsch_mcs_offset=0; phy_vars_eNB->UE_stats[i].dlsch_mcs_offset=0;
...@@ -366,17 +364,11 @@ static void *scope_thread(void *arg) { ...@@ -366,17 +364,11 @@ static void *scope_thread(void *arg) {
FILE *UE_stats, *eNB_stats; FILE *UE_stats, *eNB_stats;
# endif # endif
struct sched_param sched_param; struct sched_param sched_param;
sched_param.sched_priority = sched_get_priority_min(SCHED_FIFO)+1; sched_param.sched_priority = sched_get_priority_min(SCHED_FIFO)+1;
sched_setscheduler(0, SCHED_FIFO,&sched_param); sched_setscheduler(0, SCHED_FIFO,&sched_param);
printf("Scope thread has priority %d\n",sched_param.sched_priority); printf("Scope thread has priority %d\n",sched_param.sched_priority);
# ifdef ENABLE_XFORMS_WRITE_STATS # ifdef ENABLE_XFORMS_WRITE_STATS
UE_stats = fopen("UE_stats.txt", "w"); UE_stats = fopen("UE_stats.txt", "w");
#endif #endif
while (!oai_exit) { while (!oai_exit) {
...@@ -384,14 +376,13 @@ static void *scope_thread(void *arg) { ...@@ -384,14 +376,13 @@ static void *scope_thread(void *arg) {
//fl_set_object_label(form_stats->stats_text, stats_buffer); //fl_set_object_label(form_stats->stats_text, stats_buffer);
fl_clear_browser(form_stats->stats_text); fl_clear_browser(form_stats->stats_text);
fl_add_browser_line(form_stats->stats_text, stats_buffer); fl_add_browser_line(form_stats->stats_text, stats_buffer);
phy_scope_UE(form_ue[0], phy_scope_UE(form_ue[0],
PHY_vars_UE_g[0][0], PHY_vars_UE_g[0][0],
0, 0,
0,7); 0,7);
// printf("%s",stats_buffer); // printf("%s",stats_buffer);
} }
# ifdef ENABLE_XFORMS_WRITE_STATS # ifdef ENABLE_XFORMS_WRITE_STATS
if (UE_stats) { if (UE_stats) {
...@@ -401,8 +392,7 @@ static void *scope_thread(void *arg) { ...@@ -401,8 +392,7 @@ static void *scope_thread(void *arg) {
} }
# endif # endif
pthread_exit((void *)arg);
pthread_exit((void*)arg);
} }
#endif #endif
...@@ -412,11 +402,9 @@ static void *scope_thread(void *arg) { ...@@ -412,11 +402,9 @@ static void *scope_thread(void *arg) {
void *l2l1_task(void *arg) { void *l2l1_task(void *arg) {
MessageDef *message_p = NULL; MessageDef *message_p = NULL;
int result; int result;
itti_set_task_real_time(TASK_L2L1); itti_set_task_real_time(TASK_L2L1);
itti_mark_task_ready(TASK_L2L1); itti_mark_task_ready(TASK_L2L1);
do { do {
// Wait for a message // Wait for a message
itti_receive_msg (TASK_L2L1, &message_p); itti_receive_msg (TASK_L2L1, &message_p);
...@@ -460,43 +448,48 @@ static void get_options(void) { ...@@ -460,43 +448,48 @@ static void get_options(void) {
char *loopfile=NULL; char *loopfile=NULL;
int dumpframe; int dumpframe;
int timingadv; int timingadv;
set_default_frame_parms(frame_parms); set_default_frame_parms(frame_parms);
CONFIG_SETRTFLAG(CONFIG_NOEXITONHELP); CONFIG_SETRTFLAG(CONFIG_NOEXITONHELP);
/* unknown parameters on command line will be checked in main /* unknown parameters on command line will be checked in main
after all init have been performed */ after all init have been performed */
CONFIG_SETRTFLAG(CONFIG_NOCHECKUNKOPT); CONFIG_SETRTFLAG(CONFIG_NOCHECKUNKOPT);
get_common_options(); get_common_options();
get_uethreads_params(); get_uethreads_params();
paramdef_t cmdline_uemodeparams[] =CMDLINE_UEMODEPARAMS_DESC; paramdef_t cmdline_uemodeparams[] =CMDLINE_UEMODEPARAMS_DESC;
paramdef_t cmdline_ueparams[] =CMDLINE_UEPARAMS_DESC; paramdef_t cmdline_ueparams[] =CMDLINE_UEPARAMS_DESC;
config_process_cmdline( cmdline_uemodeparams,sizeof(cmdline_uemodeparams)/sizeof(paramdef_t),NULL); config_process_cmdline( cmdline_uemodeparams,sizeof(cmdline_uemodeparams)/sizeof(paramdef_t),NULL);
config_process_cmdline( cmdline_ueparams,sizeof(cmdline_ueparams)/sizeof(paramdef_t),NULL); config_process_cmdline( cmdline_ueparams,sizeof(cmdline_ueparams)/sizeof(paramdef_t),NULL);
if (loopfile != NULL) { if (loopfile != NULL) {
printf("Input file for hardware emulation: %s",loopfile); printf("Input file for hardware emulation: %s",loopfile);
mode=loop_through_memory; mode=loop_through_memory;
input_fd = fopen(loopfile,"r"); input_fd = fopen(loopfile,"r");
AssertFatal(input_fd != NULL,"Please provide a valid input file\n"); AssertFatal(input_fd != NULL,"Please provide a valid input file\n");
} }
get_softmodem_params()->hw_timing_advance = timingadv; get_softmodem_params()->hw_timing_advance = timingadv;
if ( (cmdline_uemodeparams[CMDLINE_CALIBUERX_IDX].paramflags & PARAMFLAG_PARAMSET) != 0) mode = rx_calib_ue; if ( (cmdline_uemodeparams[CMDLINE_CALIBUERX_IDX].paramflags & PARAMFLAG_PARAMSET) != 0) mode = rx_calib_ue;
if ( (cmdline_uemodeparams[CMDLINE_CALIBUERXMED_IDX].paramflags & PARAMFLAG_PARAMSET) != 0) mode = rx_calib_ue_med; if ( (cmdline_uemodeparams[CMDLINE_CALIBUERXMED_IDX].paramflags & PARAMFLAG_PARAMSET) != 0) mode = rx_calib_ue_med;
if ( (cmdline_uemodeparams[CMDLINE_CALIBUERXBYP_IDX].paramflags & PARAMFLAG_PARAMSET) != 0) mode = rx_calib_ue_byp; if ( (cmdline_uemodeparams[CMDLINE_CALIBUERXBYP_IDX].paramflags & PARAMFLAG_PARAMSET) != 0) mode = rx_calib_ue_byp;
if (cmdline_uemodeparams[CMDLINE_DEBUGUEPRACH_IDX].uptr) if (cmdline_uemodeparams[CMDLINE_DEBUGUEPRACH_IDX].uptr)
if ( *(cmdline_uemodeparams[CMDLINE_DEBUGUEPRACH_IDX].uptr) > 0) mode = debug_prach; if ( *(cmdline_uemodeparams[CMDLINE_DEBUGUEPRACH_IDX].uptr) > 0) mode = debug_prach;
if (cmdline_uemodeparams[CMDLINE_NOL2CONNECT_IDX].uptr) if (cmdline_uemodeparams[CMDLINE_NOL2CONNECT_IDX].uptr)
if ( *(cmdline_uemodeparams[CMDLINE_NOL2CONNECT_IDX].uptr) > 0) mode = no_L2_connect; if ( *(cmdline_uemodeparams[CMDLINE_NOL2CONNECT_IDX].uptr) > 0) mode = no_L2_connect;
if (cmdline_uemodeparams[CMDLINE_CALIBPRACHTX_IDX].uptr) if (cmdline_uemodeparams[CMDLINE_CALIBPRACHTX_IDX].uptr)
if ( *(cmdline_uemodeparams[CMDLINE_CALIBPRACHTX_IDX].uptr) > 0) mode = calib_prach_tx; if ( *(cmdline_uemodeparams[CMDLINE_CALIBPRACHTX_IDX].uptr) > 0) mode = calib_prach_tx;
if (dumpframe > 0) mode = rx_dump_frame; if (dumpframe > 0) mode = rx_dump_frame;
for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
frame_parms[CC_id]->dl_CarrierFreq = downlink_frequency[0][0]; frame_parms[CC_id]->dl_CarrierFreq = downlink_frequency[0][0];
} }
UE_scan=0; UE_scan=0;
if (tddflag > 0) { if (tddflag > 0) {
...@@ -509,28 +502,32 @@ static void get_options(void) { ...@@ -509,28 +502,32 @@ static void get_options(void) {
frame_parms[0]->N_RB_DL = 6; frame_parms[0]->N_RB_DL = 6;
printf ( "%i: Invalid number of ressource blocks, adjusted to 6\n",frame_parms[0]->N_RB_DL); printf ( "%i: Invalid number of ressource blocks, adjusted to 6\n",frame_parms[0]->N_RB_DL);
} }
if ( frame_parms[0]->N_RB_DL > 100 ) { if ( frame_parms[0]->N_RB_DL > 100 ) {
frame_parms[0]->N_RB_DL = 100; frame_parms[0]->N_RB_DL = 100;
printf ( "%i: Invalid number of ressource blocks, adjusted to 100\n",frame_parms[0]->N_RB_DL); printf ( "%i: Invalid number of ressource blocks, adjusted to 100\n",frame_parms[0]->N_RB_DL);
} }
if ( frame_parms[0]->N_RB_DL > 50 && frame_parms[0]->N_RB_DL < 100 ) { if ( frame_parms[0]->N_RB_DL > 50 && frame_parms[0]->N_RB_DL < 100 ) {
frame_parms[0]->N_RB_DL = 50; frame_parms[0]->N_RB_DL = 50;
printf ( "%i: Invalid number of ressource blocks, adjusted to 50\n",frame_parms[0]->N_RB_DL); printf ( "%i: Invalid number of ressource blocks, adjusted to 50\n",frame_parms[0]->N_RB_DL);
} }
if ( frame_parms[0]->N_RB_DL > 25 && frame_parms[0]->N_RB_DL < 50 ) { if ( frame_parms[0]->N_RB_DL > 25 && frame_parms[0]->N_RB_DL < 50 ) {
frame_parms[0]->N_RB_DL = 25; frame_parms[0]->N_RB_DL = 25;
printf ( "%i: Invalid number of ressource blocks, adjusted to 25\n",frame_parms[0]->N_RB_DL); printf ( "%i: Invalid number of ressource blocks, adjusted to 25\n",frame_parms[0]->N_RB_DL);
} }
UE_scan = 0; UE_scan = 0;
frame_parms[0]->N_RB_UL=frame_parms[0]->N_RB_DL; frame_parms[0]->N_RB_UL=frame_parms[0]->N_RB_DL;
for (CC_id=1; CC_id<MAX_NUM_CCs; CC_id++) { for (CC_id=1; CC_id<MAX_NUM_CCs; CC_id++) {
frame_parms[CC_id]->N_RB_DL=frame_parms[0]->N_RB_DL; frame_parms[CC_id]->N_RB_DL=frame_parms[0]->N_RB_DL;
frame_parms[CC_id]->N_RB_UL=frame_parms[0]->N_RB_UL; frame_parms[CC_id]->N_RB_UL=frame_parms[0]->N_RB_UL;
} }
} }
for (CC_id=1; CC_id<MAX_NUM_CCs; CC_id++) {
for (CC_id=1;CC_id<MAX_NUM_CCs;CC_id++) {
rx_gain[0][CC_id] = rx_gain[0][0]; rx_gain[0][CC_id] = rx_gain[0][0];
tx_gain[0][CC_id] = tx_gain[0][0]; tx_gain[0][CC_id] = tx_gain[0][0];
} }
...@@ -548,11 +545,10 @@ static void get_options(void) { ...@@ -548,11 +545,10 @@ static void get_options(void) {
void set_default_frame_parms(LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]) { void set_default_frame_parms(LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]) {
int CC_id; int CC_id;
for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
frame_parms[CC_id] = (LTE_DL_FRAME_PARMS*) malloc(sizeof(LTE_DL_FRAME_PARMS)); frame_parms[CC_id] = (LTE_DL_FRAME_PARMS *) malloc(sizeof(LTE_DL_FRAME_PARMS));
/* Set some default values that may be overwritten while reading options */ /* Set some default values that may be overwritten while reading options */
frame_parms[CC_id]->frame_type = FDD; frame_parms[CC_id]->frame_type = FDD;
frame_parms[CC_id]->tdd_config = 3; frame_parms[CC_id]->tdd_config = 3;
...@@ -566,9 +562,7 @@ void set_default_frame_parms(LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]) { ...@@ -566,9 +562,7 @@ void set_default_frame_parms(LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]) {
frame_parms[CC_id]->nb_antenna_ports_eNB = 1; frame_parms[CC_id]->nb_antenna_ports_eNB = 1;
frame_parms[CC_id]->nb_antennas_tx = 1; frame_parms[CC_id]->nb_antennas_tx = 1;
frame_parms[CC_id]->nb_antennas_rx = 1; frame_parms[CC_id]->nb_antennas_rx = 1;
frame_parms[CC_id]->nushift = 0; frame_parms[CC_id]->nushift = 0;
frame_parms[CC_id]->phich_config_common.phich_resource = oneSixth; frame_parms[CC_id]->phich_config_common.phich_resource = oneSixth;
frame_parms[CC_id]->phich_config_common.phich_duration = normal; frame_parms[CC_id]->phich_config_common.phich_duration = normal;
// UL RS Config // UL RS Config
...@@ -576,31 +570,24 @@ void set_default_frame_parms(LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]) { ...@@ -576,31 +570,24 @@ void set_default_frame_parms(LTE_DL_FRAME_PARMS *frame_parms[MAX_NUM_CCs]) {
frame_parms[CC_id]->pusch_config_common.ul_ReferenceSignalsPUSCH.groupHoppingEnabled = 0; frame_parms[CC_id]->pusch_config_common.ul_ReferenceSignalsPUSCH.groupHoppingEnabled = 0;
frame_parms[CC_id]->pusch_config_common.ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled = 0; frame_parms[CC_id]->pusch_config_common.ul_ReferenceSignalsPUSCH.sequenceHoppingEnabled = 0;
frame_parms[CC_id]->pusch_config_common.ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH = 0; frame_parms[CC_id]->pusch_config_common.ul_ReferenceSignalsPUSCH.groupAssignmentPUSCH = 0;
frame_parms[CC_id]->prach_config_common.rootSequenceIndex=22; frame_parms[CC_id]->prach_config_common.rootSequenceIndex=22;
frame_parms[CC_id]->prach_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig=1; frame_parms[CC_id]->prach_config_common.prach_ConfigInfo.zeroCorrelationZoneConfig=1;
frame_parms[CC_id]->prach_config_common.prach_ConfigInfo.prach_ConfigIndex=0; frame_parms[CC_id]->prach_config_common.prach_ConfigInfo.prach_ConfigIndex=0;
frame_parms[CC_id]->prach_config_common.prach_ConfigInfo.highSpeedFlag=0; frame_parms[CC_id]->prach_config_common.prach_ConfigInfo.highSpeedFlag=0;
frame_parms[CC_id]->prach_config_common.prach_ConfigInfo.prach_FreqOffset=0; frame_parms[CC_id]->prach_config_common.prach_ConfigInfo.prach_FreqOffset=0;
downlink_frequency[CC_id][0] = DEFAULT_DLF; // Use float to avoid issue with frequency over 2^31. downlink_frequency[CC_id][0] = DEFAULT_DLF; // Use float to avoid issue with frequency over 2^31.
downlink_frequency[CC_id][1] = downlink_frequency[CC_id][0]; downlink_frequency[CC_id][1] = downlink_frequency[CC_id][0];
downlink_frequency[CC_id][2] = downlink_frequency[CC_id][0]; downlink_frequency[CC_id][2] = downlink_frequency[CC_id][0];
downlink_frequency[CC_id][3] = downlink_frequency[CC_id][0]; downlink_frequency[CC_id][3] = downlink_frequency[CC_id][0];
frame_parms[CC_id]->dl_CarrierFreq=downlink_frequency[CC_id][0]; frame_parms[CC_id]->dl_CarrierFreq=downlink_frequency[CC_id][0];
} }
} }
void init_openair0(LTE_DL_FRAME_PARMS *frame_parms,int rxgain) { void init_openair0(LTE_DL_FRAME_PARMS *frame_parms,int rxgain) {
int card; int card;
int i; int i;
for (card=0; card<MAX_CARDS; card++) { for (card=0; card<MAX_CARDS; card++) {
openair0_cfg[card].mmapped_dma=mmapped_dma; openair0_cfg[card].mmapped_dma=mmapped_dma;
openair0_cfg[card].configFilename = NULL; openair0_cfg[card].configFilename = NULL;
...@@ -633,26 +620,18 @@ void init_openair0(LTE_DL_FRAME_PARMS *frame_parms,int rxgain) { ...@@ -633,26 +620,18 @@ void init_openair0(LTE_DL_FRAME_PARMS *frame_parms,int rxgain) {
openair0_cfg[card].rx_bw = 1.5e6; openair0_cfg[card].rx_bw = 1.5e6;
} }
if (frame_parms->frame_type==TDD) if (frame_parms->frame_type==TDD)
openair0_cfg[card].duplex_mode = duplex_mode_TDD; openair0_cfg[card].duplex_mode = duplex_mode_TDD;
else //FDD else //FDD
openair0_cfg[card].duplex_mode = duplex_mode_FDD; openair0_cfg[card].duplex_mode = duplex_mode_FDD;
openair0_cfg[card].Mod_id = 0; openair0_cfg[card].Mod_id = 0;
openair0_cfg[card].num_rb_dl=frame_parms->N_RB_DL; openair0_cfg[card].num_rb_dl=frame_parms->N_RB_DL;
openair0_cfg[card].clock_source = clock_source; openair0_cfg[card].clock_source = clock_source;
openair0_cfg[card].tx_num_channels=min(2,frame_parms->nb_antennas_tx); openair0_cfg[card].tx_num_channels=min(2,frame_parms->nb_antennas_tx);
openair0_cfg[card].rx_num_channels=min(2,frame_parms->nb_antennas_rx); openair0_cfg[card].rx_num_channels=min(2,frame_parms->nb_antennas_rx);
for (i=0; i<4; i++) { for (i=0; i<4; i++) {
if (i<openair0_cfg[card].tx_num_channels) if (i<openair0_cfg[card].tx_num_channels)
openair0_cfg[card].tx_freq[i] = downlink_frequency[0][i]+uplink_frequency_offset[0][i]; openair0_cfg[card].tx_freq[i] = downlink_frequency[0][i]+uplink_frequency_offset[0][i];
else else
...@@ -666,8 +645,6 @@ void init_openair0(LTE_DL_FRAME_PARMS *frame_parms,int rxgain) { ...@@ -666,8 +645,6 @@ void init_openair0(LTE_DL_FRAME_PARMS *frame_parms,int rxgain) {
openair0_cfg[card].autocal[i] = 1; openair0_cfg[card].autocal[i] = 1;
openair0_cfg[card].tx_gain[i] = tx_gain[0][i]; openair0_cfg[card].tx_gain[i] = tx_gain[0][i];
openair0_cfg[card].rx_gain[i] = rxgain - rx_gain_off; openair0_cfg[card].rx_gain[i] = rxgain - rx_gain_off;
openair0_cfg[card].configFilename = get_softmodem_params()->rf_config_file; openair0_cfg[card].configFilename = get_softmodem_params()->rf_config_file;
printf("Card %d, channel %d, Setting tx_gain %f, rx_gain %f, tx_freq %f, rx_freq %f\n", printf("Card %d, channel %d, Setting tx_gain %f, rx_gain %f, tx_freq %f, rx_freq %f\n",
card,i, openair0_cfg[card].tx_gain[i], card,i, openair0_cfg[card].tx_gain[i],
...@@ -677,6 +654,7 @@ void init_openair0(LTE_DL_FRAME_PARMS *frame_parms,int rxgain) { ...@@ -677,6 +654,7 @@ void init_openair0(LTE_DL_FRAME_PARMS *frame_parms,int rxgain) {
} }
if (usrp_args) openair0_cfg[card].sdr_addrs = usrp_args; if (usrp_args) openair0_cfg[card].sdr_addrs = usrp_args;
if (usrp_clksrc) { if (usrp_clksrc) {
if (strcmp(usrp_clksrc, "internal") == 0) { if (strcmp(usrp_clksrc, "internal") == 0) {
openair0_cfg[card].clock_source = internal; openair0_cfg[card].clock_source = internal;
...@@ -705,8 +683,7 @@ void init_openair0(LTE_DL_FRAME_PARMS *frame_parms,int rxgain) { ...@@ -705,8 +683,7 @@ void init_openair0(LTE_DL_FRAME_PARMS *frame_parms,int rxgain) {
/* /*
* helper function to terminate a certain ITTI task * helper function to terminate a certain ITTI task
*/ */
void terminate_task(task_id_t task_id, module_id_t mod_id) void terminate_task(task_id_t task_id, module_id_t mod_id) {
{
LOG_I(ENB_APP, "sending TERMINATE_MESSAGE to task %s (%d)\n", itti_get_task_name(task_id), task_id); LOG_I(ENB_APP, "sending TERMINATE_MESSAGE to task %s (%d)\n", itti_get_task_name(task_id), task_id);
MessageDef *msg; MessageDef *msg;
msg = itti_alloc_new_message (ENB_APP, TERMINATE_MESSAGE); msg = itti_alloc_new_message (ENB_APP, TERMINATE_MESSAGE);
...@@ -720,7 +697,6 @@ void terminate_task(task_id_t task_id, module_id_t mod_id) ...@@ -720,7 +697,6 @@ void terminate_task(task_id_t task_id, module_id_t mod_id)
static inline void wait_nfapi_init(char *thread_name) { static inline void wait_nfapi_init(char *thread_name) {
printf( "waiting for NFAPI PNF connection and population of global structure (%s)\n",thread_name); printf( "waiting for NFAPI PNF connection and population of global structure (%s)\n",thread_name);
pthread_mutex_lock( &nfapi_sync_mutex ); pthread_mutex_lock( &nfapi_sync_mutex );
...@@ -728,91 +704,64 @@ static inline void wait_nfapi_init(char *thread_name) { ...@@ -728,91 +704,64 @@ static inline void wait_nfapi_init(char *thread_name) {
pthread_cond_wait( &nfapi_sync_cond, &nfapi_sync_mutex ); pthread_cond_wait( &nfapi_sync_cond, &nfapi_sync_mutex );
pthread_mutex_unlock(&nfapi_sync_mutex); pthread_mutex_unlock(&nfapi_sync_mutex);
printf( "NFAPI: got sync (%s)\n", thread_name); printf( "NFAPI: got sync (%s)\n", thread_name);
} }
int stop_L1L2(module_id_t enb_id) int stop_L1L2(module_id_t enb_id) {
{
return 0; return 0;
} }
int restart_L1L2(module_id_t enb_id) int restart_L1L2(module_id_t enb_id) {
{
return 0; return 0;
} }
int main( int argc, char **argv ) int main( int argc, char **argv ) {
{
#if defined (XFORMS) #if defined (XFORMS)
void *status; void *status;
#endif #endif
int CC_id; int CC_id;
uint8_t abstraction_flag=0; uint8_t abstraction_flag=0;
// Default value for the number of UEs. It will hold, // Default value for the number of UEs. It will hold,
// if not changed from the command line option --num-ues // if not changed from the command line option --num-ues
NB_UE_INST=1; NB_UE_INST=1;
#if defined (XFORMS) #if defined (XFORMS)
int ret; int ret;
#endif #endif
start_background_system(); start_background_system();
if ( load_configmodule(argc,argv,CONFIG_ENABLECMDLINEONLY) == NULL) { if ( load_configmodule(argc,argv,CONFIG_ENABLECMDLINEONLY) == NULL) {
exit_fun("[SOFTMODEM] Error, configuration module init failed\n"); exit_fun("[SOFTMODEM] Error, configuration module init failed\n");
} }
mode = normal_txrx; mode = normal_txrx;
memset(&openair0_cfg[0],0,sizeof(openair0_config_t)*MAX_CARDS); memset(&openair0_cfg[0],0,sizeof(openair0_config_t)*MAX_CARDS);
set_latency_target(); set_latency_target();
logInit(); logInit();
printf("Reading in command-line options\n"); printf("Reading in command-line options\n");
for (int i=0;i<MAX_NUM_CCs;i++) tx_max_power[i]=23; for (int i=0; i<MAX_NUM_CCs; i++) tx_max_power[i]=23;
CONFIG_SETRTFLAG(CONFIG_NOCHECKUNKOPT); CONFIG_SETRTFLAG(CONFIG_NOCHECKUNKOPT);
get_options (); get_options ();
printf("Running with %d UE instances\n",NB_UE_INST); printf("Running with %d UE instances\n",NB_UE_INST);
if (NB_UE_INST > 1 && simL1flag != 1) { if (NB_UE_INST > 1 && simL1flag != 1) {
printf("Running with more than 1 UE instance and simL1 is not active, this will result in undefined behaviour for now, exiting.\n"); printf("Running with more than 1 UE instance and simL1 is not active, this will result in undefined behaviour for now, exiting.\n");
abort(); abort();
} }
printf("NFAPI_MODE value: %d \n", nfapi_mode); printf("NFAPI_MODE value: %d \n", nfapi_mode);
#if T_TRACER #if T_TRACER
T_Config_Init(); T_Config_Init();
#endif #endif
CONFIG_CLEARRTFLAG(CONFIG_NOCHECKUNKOPT); CONFIG_CLEARRTFLAG(CONFIG_NOCHECKUNKOPT);
//randominit (0); //randominit (0);
set_taus_seed (0); set_taus_seed (0);
cpuf=get_cpu_freq_GHz(); cpuf=get_cpu_freq_GHz();
pthread_cond_init(&sync_cond,NULL); pthread_cond_init(&sync_cond,NULL);
pthread_mutex_init(&sync_mutex, NULL); pthread_mutex_init(&sync_mutex, NULL);
#if defined(ENABLE_ITTI) #if defined(ENABLE_ITTI)
printf("ITTI init\n"); printf("ITTI init\n");
itti_init(TASK_MAX, THREAD_MAX, MESSAGES_ID_MAX, tasks_info, messages_info); itti_init(TASK_MAX, THREAD_MAX, MESSAGES_ID_MAX, tasks_info, messages_info);
...@@ -820,6 +769,7 @@ int main( int argc, char **argv ) ...@@ -820,6 +769,7 @@ int main( int argc, char **argv )
if (get_softmodem_params()->start_msc) { if (get_softmodem_params()->start_msc) {
load_module_shlib("msc",NULL,0,&msc_interface); load_module_shlib("msc",NULL,0,&msc_interface);
} }
MSC_INIT(MSC_E_UTRAN, THREAD_MAX+TASK_MAX); MSC_INIT(MSC_E_UTRAN, THREAD_MAX+TASK_MAX);
#endif #endif
...@@ -835,27 +785,22 @@ int main( int argc, char **argv ) ...@@ -835,27 +785,22 @@ int main( int argc, char **argv )
pdcp_netlink_init(); pdcp_netlink_init();
#endif #endif
#endif #endif
//TTN for D2D
//TTN for D2D
#if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0)) #if (LTE_RRC_VERSION >= MAKE_VERSION(14, 0, 0))
printf ("RRC control socket\n"); printf ("RRC control socket\n");
rrc_control_socket_init(); rrc_control_socket_init();
printf ("PDCP PC5S socket\n"); printf ("PDCP PC5S socket\n");
pdcp_pc5_socket_init(); pdcp_pc5_socket_init();
#endif #endif
// to make a graceful exit when ctrl-c is pressed // to make a graceful exit when ctrl-c is pressed
signal(SIGSEGV, signal_handler); signal(SIGSEGV, signal_handler);
signal(SIGINT, signal_handler); signal(SIGINT, signal_handler);
signal(SIGTERM, signal_handler); signal(SIGTERM, signal_handler);
signal(SIGABRT, signal_handler); signal(SIGABRT, signal_handler);
check_clock(); check_clock();
#ifndef PACKAGE_VERSION #ifndef PACKAGE_VERSION
# define PACKAGE_VERSION "UNKNOWN-EXPERIMENTAL" # define PACKAGE_VERSION "UNKNOWN-EXPERIMENTAL"
#endif #endif
LOG_I(HW, "Version: %s\n", PACKAGE_VERSION); LOG_I(HW, "Version: %s\n", PACKAGE_VERSION);
// init the parameters // init the parameters
...@@ -865,98 +810,92 @@ int main( int argc, char **argv ) ...@@ -865,98 +810,92 @@ int main( int argc, char **argv )
frame_parms[CC_id]->nb_antenna_ports_eNB = 1; //initial value overwritten by initial sync later frame_parms[CC_id]->nb_antenna_ports_eNB = 1; //initial value overwritten by initial sync later
} }
NB_INST=1;
if(nfapi_mode == 3) {
PHY_vars_UE_g = malloc(sizeof(PHY_VARS_UE **)*NB_UE_INST);
NB_INST=1;
if(nfapi_mode == 3){
PHY_vars_UE_g = malloc(sizeof(PHY_VARS_UE**)*NB_UE_INST);
for (int i=0; i<NB_UE_INST; i++) { for (int i=0; i<NB_UE_INST; i++) {
for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { for (CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
PHY_vars_UE_g[i] = malloc(sizeof(PHY_VARS_UE*)*MAX_NUM_CCs); PHY_vars_UE_g[i] = malloc(sizeof(PHY_VARS_UE *)*MAX_NUM_CCs);
PHY_vars_UE_g[i][CC_id] = init_ue_vars(frame_parms[CC_id], i,abstraction_flag); PHY_vars_UE_g[i][CC_id] = init_ue_vars(frame_parms[CC_id], i,abstraction_flag);
if (get_softmodem_params()->phy_test==1) if (get_softmodem_params()->phy_test==1)
PHY_vars_UE_g[i][CC_id]->mac_enabled = 0; PHY_vars_UE_g[i][CC_id]->mac_enabled = 0;
else else
PHY_vars_UE_g[i][CC_id]->mac_enabled = 1; PHY_vars_UE_g[i][CC_id]->mac_enabled = 1;
} }
} }
} } else init_openair0(frame_parms[0],(int)rx_gain[0][0]);
else init_openair0(frame_parms[0],(int)rx_gain[0][0]);
if (simL1flag==1) { if (simL1flag==1) {
AssertFatal(NULL!=load_configmodule(argc,argv,CONFIG_ENABLECMDLINEONLY), AssertFatal(NULL!=load_configmodule(argc,argv,CONFIG_ENABLECMDLINEONLY),
"[SOFTMODEM] Error, configuration module init failed\n"); "[SOFTMODEM] Error, configuration module init failed\n");
RCConfig_sim(); RCConfig_sim();
} }
// start the main UE threads // start the main UE threads
int eMBMS_active = 0; int eMBMS_active = 0;
if (nfapi_mode==3) // UE-STUB-PNF if (nfapi_mode==3) { // UE-STUB-PNF
{
config_sync_var=0; config_sync_var=0;
wait_nfapi_init("main?"); wait_nfapi_init("main?");
//Panos: Temporarily we will be using single set of threads for multiple UEs. //Panos: Temporarily we will be using single set of threads for multiple UEs.
//init_UE_stub(1,eMBMS_active,uecap_xer_in,emul_iface); //init_UE_stub(1,eMBMS_active,uecap_xer_in,emul_iface);
init_UE_stub_single_thread(NB_UE_INST,eMBMS_active,uecap_xer_in,emul_iface); init_UE_stub_single_thread(NB_UE_INST,eMBMS_active,uecap_xer_in,emul_iface);
} } else {
else {
init_UE(NB_UE_INST,eMBMS_active,uecap_xer_in,0,get_softmodem_params()->phy_test,UE_scan,UE_scan_carrier,mode,(int)rx_gain[0][0],tx_max_power[0], init_UE(NB_UE_INST,eMBMS_active,uecap_xer_in,0,get_softmodem_params()->phy_test,UE_scan,UE_scan_carrier,mode,(int)rx_gain[0][0],tx_max_power[0],
frame_parms[0]); frame_parms[0]);
} }
if (get_softmodem_params()->phy_test==0) { if (get_softmodem_params()->phy_test==0) {
printf("Filling UE band info\n"); printf("Filling UE band info\n");
fill_ue_band_info(); fill_ue_band_info();
dl_phy_sync_success (0, 0, 0, 1); dl_phy_sync_success (0, 0, 0, 1);
} }
if (nfapi_mode!=3){ if (nfapi_mode!=3) {
number_of_cards = 1; number_of_cards = 1;
for(CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) { for(CC_id=0; CC_id<MAX_NUM_CCs; CC_id++) {
PHY_vars_UE_g[0][CC_id]->rf_map.card=0; PHY_vars_UE_g[0][CC_id]->rf_map.card=0;
PHY_vars_UE_g[0][CC_id]->rf_map.chain=CC_id+(get_softmodem_params()->chain_offset); PHY_vars_UE_g[0][CC_id]->rf_map.chain=CC_id+(get_softmodem_params()->chain_offset);
} }
} }
cpuf=get_cpu_freq_GHz(); cpuf=get_cpu_freq_GHz();
#ifndef DEADLINE_SCHEDULER #ifndef DEADLINE_SCHEDULER
printf("NO deadline scheduler\n"); printf("NO deadline scheduler\n");
/* Currently we set affinity for UHD to CPU 0 for eNB/UE and only if number of CPUS >2 */ /* Currently we set affinity for UHD to CPU 0 for eNB/UE and only if number of CPUS >2 */
cpu_set_t cpuset; cpu_set_t cpuset;
int s; int s;
char cpu_affinity[1024]; char cpu_affinity[1024];
CPU_ZERO(&cpuset); CPU_ZERO(&cpuset);
#ifdef CPU_AFFINITY #ifdef CPU_AFFINITY
if (get_nprocs() > 2) { if (get_nprocs() > 2) {
CPU_SET(0, &cpuset); CPU_SET(0, &cpuset);
s = pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); s = pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset);
if (s != 0) { if (s != 0) {
perror( "pthread_setaffinity_np"); perror( "pthread_setaffinity_np");
exit_fun("Error setting processor affinity"); exit_fun("Error setting processor affinity");
} }
LOG_I(HW, "Setting the affinity of main function to CPU 0, for device library to use CPU 0 only!\n"); LOG_I(HW, "Setting the affinity of main function to CPU 0, for device library to use CPU 0 only!\n");
} }
#endif
#endif
/* Check the actual affinity mask assigned to the thread */ /* Check the actual affinity mask assigned to the thread */
s = pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); s = pthread_getaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset);
if (s != 0) { if (s != 0) {
perror( "pthread_getaffinity_np"); perror( "pthread_getaffinity_np");
exit_fun("Error getting processor affinity "); exit_fun("Error getting processor affinity ");
} }
memset(cpu_affinity, 0 , sizeof(cpu_affinity)); memset(cpu_affinity, 0 , sizeof(cpu_affinity));
for (int j = 0; j < CPU_SETSIZE; j++) { for (int j = 0; j < CPU_SETSIZE; j++) {
if (CPU_ISSET(j, &cpuset)) { if (CPU_ISSET(j, &cpuset)) {
char temp[1024]; char temp[1024];
...@@ -964,58 +903,56 @@ int main( int argc, char **argv ) ...@@ -964,58 +903,56 @@ int main( int argc, char **argv )
strcat(cpu_affinity, temp); strcat(cpu_affinity, temp);
} }
} }
LOG_I(HW, "CPU Affinity of main() function is... %s\n", cpu_affinity); LOG_I(HW, "CPU Affinity of main() function is... %s\n", cpu_affinity);
#endif #endif
#if defined(ENABLE_ITTI) #if defined(ENABLE_ITTI)
if (create_tasks_ue(1) < 0) { if (create_tasks_ue(1) < 0) {
printf("cannot create ITTI tasks\n"); printf("cannot create ITTI tasks\n");
exit(-1); // need a softer mode exit(-1); // need a softer mode
} }
if(nfapi_mode==3){ // Here we should add another nfapi_mode for the case of Supervised LTE-D2D
if(nfapi_mode==3) { // Here we should add another nfapi_mode for the case of Supervised LTE-D2D
UE_config_stub_pnf(); UE_config_stub_pnf();
} }
printf("ITTI tasks created\n"); printf("ITTI tasks created\n");
#endif #endif
mlockall(MCL_CURRENT | MCL_FUTURE); mlockall(MCL_CURRENT | MCL_FUTURE);
rt_sleep_ns(10*100000000ULL); rt_sleep_ns(10*100000000ULL);
const char *nfapi_mode_str = "<UNKNOWN>"; const char *nfapi_mode_str = "<UNKNOWN>";
switch(nfapi_mode) switch(nfapi_mode) {
{
case 0: case 0:
nfapi_mode_str = "MONOLITHIC"; nfapi_mode_str = "MONOLITHIC";
break; break;
case 1: case 1:
nfapi_mode_str = "PNF"; nfapi_mode_str = "PNF";
break; break;
case 2: case 2:
nfapi_mode_str = "VNF"; nfapi_mode_str = "VNF";
break; break;
case 3: case 3:
nfapi_mode_str = "UE_STUB_PNF"; nfapi_mode_str = "UE_STUB_PNF";
break; break;
case 4: case 4:
nfapi_mode_str = "UE_STUB_OFFNET"; nfapi_mode_str = "UE_STUB_OFFNET";
break; break;
default: default:
nfapi_mode_str = "<UNKNOWN NFAPI MODE>"; nfapi_mode_str = "<UNKNOWN NFAPI MODE>";
break; break;
} }
printf("NFAPI MODE:%s\n", nfapi_mode_str);
printf("NFAPI MODE:%s\n", nfapi_mode_str);
// connect the TX/RX buffers // connect the TX/RX buffers
/* /*
if(nfapi_mode!=3) { if(nfapi_mode!=3) {
if (setup_ue_buffers(PHY_vars_UE_g[0],&openair0_cfg[0])!=0) { if (setup_ue_buffers(PHY_vars_UE_g[0],&openair0_cfg[0])!=0) {
...@@ -1025,41 +962,35 @@ int main( int argc, char **argv ) ...@@ -1025,41 +962,35 @@ int main( int argc, char **argv )
} }
*/ */
if (input_fd) { if (input_fd) {
printf("Reading in from file to antenna buffer %d\n",0); printf("Reading in from file to antenna buffer %d\n",0);
if (fread(PHY_vars_UE_g[0][0]->common_vars.rxdata[0], if (fread(PHY_vars_UE_g[0][0]->common_vars.rxdata[0],
sizeof(int32_t), sizeof(int32_t),
frame_parms[0]->samples_per_tti*10, frame_parms[0]->samples_per_tti*10,
input_fd) != frame_parms[0]->samples_per_tti*10) input_fd) != frame_parms[0]->samples_per_tti*10)
printf("error reading from file\n"); printf("error reading from file\n");
} }
//p_exmimo_config->framing.tdd_config = TXRXSWITCH_TESTRX;
//p_exmimo_config->framing.tdd_config = TXRXSWITCH_TESTRX;
if (simL1flag==1) { if (simL1flag==1) {
init_ocm((double)snr_dB,0); init_ocm((double)snr_dB,0);
PHY_vars_UE_g[0][0]->no_timing_correction = 1; PHY_vars_UE_g[0][0]->no_timing_correction = 1;
} }
#ifdef XFORMS #ifdef XFORMS
int UE_id; int UE_id;
printf("XFORMS\n"); printf("XFORMS\n");
if (get_softmodem_params()->do_forms==1) { if (get_softmodem_params()->do_forms==1) {
fl_initialize (&argc, argv, NULL, 0, 0); fl_initialize (&argc, argv, NULL, 0, 0);
form_stats = create_form_stats_form(); form_stats = create_form_stats_form();
fl_show_form (form_stats->stats_form, FL_PLACE_HOTSPOT, FL_FULLBORDER, "stats"); fl_show_form (form_stats->stats_form, FL_PLACE_HOTSPOT, FL_FULLBORDER, "stats");
UE_id = 0; UE_id = 0;
form_ue[UE_id] = create_lte_phy_scope_ue(); form_ue[UE_id] = create_lte_phy_scope_ue();
sprintf (title, "LTE DL SCOPE UE"); sprintf (title, "LTE DL SCOPE UE");
fl_show_form (form_ue[UE_id]->lte_phy_scope_ue, FL_PLACE_HOTSPOT, FL_FULLBORDER, title); fl_show_form (form_ue[UE_id]->lte_phy_scope_ue, FL_PLACE_HOTSPOT, FL_FULLBORDER, title);
/* /*
if (openair_daq_vars.use_ia_receiver) { if (openair_daq_vars.use_ia_receiver) {
fl_set_button(form_ue[UE_id]->button_0,1); fl_set_button(form_ue[UE_id]->button_0,1);
...@@ -1080,30 +1011,26 @@ int main( int argc, char **argv ) ...@@ -1080,30 +1011,26 @@ int main( int argc, char **argv )
#endif #endif
ret=config_check_cmdlineopt(CONFIG_CHECKALLSECTIONS); ret=config_check_cmdlineopt(CONFIG_CHECKALLSECTIONS);
if (ret != 0) { if (ret != 0) {
LOG_E(ENB_APP, "%i unknown options in command line (invalid section name)\n",ret); LOG_E(ENB_APP, "%i unknown options in command line (invalid section name)\n",ret);
exit_fun(""); exit_fun("");
} }
printf("Sending sync to all threads (%p,%p,%p)\n",&sync_var,&sync_cond,&sync_mutex); printf("Sending sync to all threads (%p,%p,%p)\n",&sync_var,&sync_cond,&sync_mutex);
pthread_mutex_lock(&sync_mutex); pthread_mutex_lock(&sync_mutex);
sync_var=0; sync_var=0;
pthread_cond_broadcast(&sync_cond); pthread_cond_broadcast(&sync_cond);
pthread_mutex_unlock(&sync_mutex); pthread_mutex_unlock(&sync_mutex);
printf("sync sent\n"); printf("sync sent\n");
/* /*
printf("About to call end_configmodule() from %s() %s:%d\n", __FUNCTION__, __FILE__, __LINE__); printf("About to call end_configmodule() from %s() %s:%d\n", __FUNCTION__, __FILE__, __LINE__);
end_configmodule(); end_configmodule();
printf("Called end_configmodule() from %s() %s:%d\n", __FUNCTION__, __FILE__, __LINE__); printf("Called end_configmodule() from %s() %s:%d\n", __FUNCTION__, __FILE__, __LINE__);
*/ */
// wait for end of program // wait for end of program
printf("TYPE <CTRL-C> TO TERMINATE\n"); printf("TYPE <CTRL-C> TO TERMINATE\n");
//getchar(); //getchar();
#if defined(ENABLE_ITTI) #if defined(ENABLE_ITTI)
printf("Entering ITTI signals handler\n"); printf("Entering ITTI signals handler\n");
itti_wait_tasks_end(); itti_wait_tasks_end();
...@@ -1114,10 +1041,9 @@ int main( int argc, char **argv ) ...@@ -1114,10 +1041,9 @@ int main( int argc, char **argv )
while (oai_exit==0) while (oai_exit==0)
rt_sleep_ns(100000000ULL); rt_sleep_ns(100000000ULL);
printf("Terminating application - oai_exit=%d\n",oai_exit);
printf("Terminating application - oai_exit=%d\n",oai_exit);
#endif #endif
// stop threads // stop threads
#ifdef XFORMS #ifdef XFORMS
printf("waiting for XFORMS thread\n"); printf("waiting for XFORMS thread\n");
...@@ -1131,9 +1057,7 @@ int main( int argc, char **argv ) ...@@ -1131,9 +1057,7 @@ int main( int argc, char **argv )
} }
#endif #endif
printf("stopping MODEM threads\n"); printf("stopping MODEM threads\n");
pthread_cond_destroy(&sync_cond); pthread_cond_destroy(&sync_cond);
pthread_mutex_destroy(&sync_mutex); pthread_mutex_destroy(&sync_mutex);
...@@ -1147,8 +1071,6 @@ int main( int argc, char **argv ) ...@@ -1147,8 +1071,6 @@ int main( int argc, char **argv )
terminate_opt(); terminate_opt();
logClean(); logClean();
printf("Bye.\n"); printf("Bye.\n");
return 0; return 0;
} }
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment