From 23c54b8db45fcc1f97d6ffe57a611d09dbf6585d Mon Sep 17 00:00:00 2001 From: Wang Tsu-Han Date: Mon, 23 Oct 2017 14:47:26 +0200 Subject: [PATCH 01/63] added parallelization of fep and encoding added numerology paramter --- cmake_targets/build_oai | 2 - openair1/PHY/LTE_TRANSPORT/dlsch_coding.c | 58 ++++++++++++++++++ openair1/PHY/LTE_TRANSPORT/proto.h | 11 ++++ openair1/PHY/defs.h | 2 + openair1/SCHED/phy_procedures_lte_eNb.c | 1 + targets/ARCH/COMMON/common_lib.c | 20 +++---- targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp | 14 +++++ targets/RT/USER/lte-enb.c | 42 ++++++++++--- targets/RT/USER/lte-ru.c | 44 ++++++++++---- targets/RT/USER/lte-softmodem.c | 20 +++++++ targets/RT/USER/lte-softmodem.h | 62 ++++++++++---------- 11 files changed, 214 insertions(+), 62 deletions(-) diff --git a/cmake_targets/build_oai b/cmake_targets/build_oai index 01d94da73e..d2610c4abc 100755 --- a/cmake_targets/build_oai +++ b/cmake_targets/build_oai @@ -856,11 +856,9 @@ function main() { ln -sf $dbin/liboai_exmimodevif.so.$REL $dbin/liboai_device.so echo_info "liboai_device.so is linked to EXMIMO device library" elif [ "$HW" == "OAI_USRP" ] ; then - if [ -d "/usr/include/uhd" ] ; then compilations \ $build_dir oai_usrpdevif \ liboai_usrpdevif.so $dbin/liboai_usrpdevif.so.$REL - fi ln -sf liboai_usrpdevif.so liboai_device.so ln -sf $dbin/liboai_usrpdevif.so.$REL $dbin/liboai_device.so diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c index f4a06837b9..9152a6a9ad 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c @@ -268,6 +268,8 @@ void clean_eNb_dlsch(LTE_eNB_DLSCH_t *dlsch) } + + int dlsch_encoding_2threads0(te_params *tep) { LTE_eNB_DLSCH_t *dlsch = tep->dlsch; @@ -560,6 +562,62 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB, return(0); } +int dlsch_encoding_all(PHY_VARS_eNB *eNB, + unsigned char *a, + uint8_t num_pdcch_symbols, + LTE_eNB_DLSCH_t *dlsch, + int frame, + uint8_t subframe, + time_stats_t *rm_stats, + time_stats_t *te_stats, + time_stats_t *i_stats) +{ + int encoding_return = 0; + unsigned int L,C,B; + B = dlsch->harq_processes[dlsch->harq_ids[subframe]]->B; + if(B<=6144) + { + L=0; + C=1; + } + else + { + L=24; + C = B/(6144-L); + if((6144-L)*C < B) + { + C = C+1; + } + } + if(C >= 5) + { + encoding_return = + dlsch_encoding_2threads(eNB, + a, + num_pdcch_symbols, + dlsch, + frame, + subframe, + rm_stats, + te_stats, + i_stats); + } + else + { + encoding_return = + dlsch_encoding(eNB, + a, + num_pdcch_symbols, + dlsch, + frame, + subframe, + rm_stats, + te_stats, + i_stats); + } + return encoding_return; +} + int dlsch_encoding(PHY_VARS_eNB *eNB, unsigned char *a, diff --git a/openair1/PHY/LTE_TRANSPORT/proto.h b/openair1/PHY/LTE_TRANSPORT/proto.h index 441cd5539a..2c6e73d45a 100644 --- a/openair1/PHY/LTE_TRANSPORT/proto.h +++ b/openair1/PHY/LTE_TRANSPORT/proto.h @@ -122,6 +122,17 @@ int32_t dlsch_encoding(PHY_VARS_eNB *eNB, time_stats_t *te_stats, time_stats_t *i_stats); +int32_t dlsch_encoding_all(PHY_VARS_eNB *eNB, + uint8_t *a, + uint8_t num_pdcch_symbols, + LTE_eNB_DLSCH_t *dlsch, + int frame, + uint8_t subframe, + time_stats_t *rm_stats, + time_stats_t *te_stats, + time_stats_t *i_stats); + + int32_t dlsch_encoding_SIC(PHY_VARS_UE *ue, uint8_t *a, uint8_t num_pdcch_symbols, diff --git a/openair1/PHY/defs.h b/openair1/PHY/defs.h index 6dd94bafcd..27ec0cc548 100644 --- a/openair1/PHY/defs.h +++ b/openair1/PHY/defs.h @@ -556,6 +556,8 @@ typedef struct eNB_proc_t_s { te_params tep; /// set of scheduling variables RXn-TXnp4 threads eNB_rxtx_proc_t proc_rxtx[2]; + /// stats thread pthread descriptor + pthread_t coding_stats_thread; } eNB_proc_t; diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index 8e5358da34..7840dc3534 100644 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -1517,6 +1517,7 @@ void init_te_thread(PHY_VARS_eNB *eNB,pthread_attr_t *attr_te) { } + void fill_rx_indication(PHY_VARS_eNB *eNB,int UE_id,int frame,int subframe) { nfapi_rx_indication_pdu_t *pdu; diff --git a/targets/ARCH/COMMON/common_lib.c b/targets/ARCH/COMMON/common_lib.c index 1fb8b4f981..a2e6d1071a 100644 --- a/targets/ARCH/COMMON/common_lib.c +++ b/targets/ARCH/COMMON/common_lib.c @@ -97,21 +97,21 @@ int load_lib(openair0_device *device, openair0_config_t *openair0_cfg, eth_param if (flag == RAU_LOCAL_RADIO_HEAD) { lib_handle = dlopen(OAI_RF_LIBNAME, RTLD_LAZY); if (!lib_handle) { - fprintf(stderr,"Unable to locate %s: HW device set to NONE_DEV.\n", OAI_RF_LIBNAME); - fprintf(stderr,"%s\n",dlerror()); - return -1; + fprintf(stderr,"Unable to locate %s: HW device set to NONE_DEV.\n", OAI_RF_LIBNAME); + fprintf(stderr,"%s\n",dlerror()); + return -1; } dp = dlsym(lib_handle,"device_init"); if (dp != NULL ) { - ret = dp(device,openair0_cfg); - if (ret<0) { - fprintf(stderr, "%s %d:oai device intialization failed %s\n", __FILE__, __LINE__, dlerror()); - } + ret = dp(device,openair0_cfg); + if (ret<0) { + fprintf(stderr, "%s %d:oai device intialization failed %s\n", __FILE__, __LINE__, dlerror()); + } } else { - fprintf(stderr, "%s %d:oai device intializing function not found %s\n", __FILE__, __LINE__, dlerror()); - return -1; + fprintf(stderr, "%s %d:oai device intializing function not found %s\n", __FILE__, __LINE__, dlerror()); + return -1; } } else { lib_handle = dlopen(OAI_TP_LIBNAME, RTLD_LAZY); @@ -142,7 +142,7 @@ int openair0_device_load(openair0_device *device, openair0_config_t *openair0_cf rc=load_lib(device, openair0_cfg, NULL,RAU_LOCAL_RADIO_HEAD ); if ( rc >= 0) { - if ( set_device(device) < 0) { + if ( set_device(device) < 0) { fprintf(stderr, "%s %d:Unsupported radio head\n",__FILE__, __LINE__); return -1; } diff --git a/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp b/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp index ec7aa1a549..f83dc21787 100644 --- a/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp +++ b/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp @@ -744,6 +744,20 @@ extern "C" { openair0_cfg[0].rx_gain_calib_table = calib_table_x310; switch ((int)openair0_cfg[0].sample_rate) { + case 122880000: + // from usrp_time_offset + //openair0_cfg[0].samples_per_packet = 2048; + openair0_cfg[0].tx_sample_advance = 15; //to be checked + openair0_cfg[0].tx_bw = 80e6; + openair0_cfg[0].rx_bw = 80e6; + break; + case 61440000: + // from usrp_time_offset + //openair0_cfg[0].samples_per_packet = 2048; + openair0_cfg[0].tx_sample_advance = 15; + openair0_cfg[0].tx_bw = 40e6; + openair0_cfg[0].rx_bw = 40e6; + break; case 30720000: // from usrp_time_offset //openair0_cfg[0].samples_per_packet = 2048; diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 8e476e06b7..d82732c2cf 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -577,9 +577,27 @@ static void* eNB_thread_prach_br( void* param ) { #endif -extern void init_fep_thread(PHY_VARS_eNB *, pthread_attr_t *); + extern void init_td_thread(PHY_VARS_eNB *, pthread_attr_t *); extern void init_te_thread(PHY_VARS_eNB *, pthread_attr_t *); +//////////////////////////////////////need to modified////////////////***** + +static void* coding_stats_thread(void* param) { + + PHY_VARS_eNB *eNB = (PHY_VARS_eNB*)param; + + wait_sync("coding_stats_thread"); + + while (!oai_exit) { + sleep(1); + if (opp_enabled == 1) { + if (eNB->td) print_meas(&eNB->ulsch_decoding_stats,"ulsch_decoding",NULL,NULL); + if (eNB->te) print_meas(&eNB->dlsch_encoding_stats,"dlsch_encoding",NULL,NULL); + } + } + return(NULL); +} + void init_eNB_proc(int inst) { @@ -588,8 +606,7 @@ void init_eNB_proc(int inst) { PHY_VARS_eNB *eNB; eNB_proc_t *proc; eNB_rxtx_proc_t *proc_rxtx; - pthread_attr_t *attr0=NULL,*attr1=NULL,*attr_prach=NULL; - //*attr_td=NULL,*attr_te=NULL; + pthread_attr_t *attr0=NULL,*attr1=NULL,*attr_prach=NULL,*attr_td=NULL,*attr_te=NULL; #ifdef Rel14 pthread_attr_t *attr_prach_br=NULL; #endif @@ -629,8 +646,8 @@ void init_eNB_proc(int inst) { pthread_attr_init( &proc->attr_prach); pthread_attr_init( &proc->attr_asynch_rxtx); - // pthread_attr_init( &proc->attr_td); - // pthread_attr_init( &proc->attr_te); + pthread_attr_init( &proc->attr_td); + pthread_attr_init( &proc->attr_te); pthread_attr_init( &proc_rxtx[0].attr_rxtx); pthread_attr_init( &proc_rxtx[1].attr_rxtx); #ifdef Rel14 @@ -652,7 +669,8 @@ void init_eNB_proc(int inst) { // attr_td = &proc->attr_td; // attr_te = &proc->attr_te; #endif - + attr_td = &proc->attr_td; + attr_te = &proc->attr_te; if (eNB->single_thread_flag==0) { pthread_create( &proc_rxtx[0].pthread_rxtx, attr0, eNB_thread_rxtx, &proc_rxtx[0] ); pthread_create( &proc_rxtx[1].pthread_rxtx, attr1, eNB_thread_rxtx, &proc_rxtx[1] ); @@ -670,6 +688,12 @@ void init_eNB_proc(int inst) { } AssertFatal(proc->instance_cnt_prach == -1,"instance_cnt_prach = %d\n",proc->instance_cnt_prach); + + + //////////////////////////////////////need to modified////////////////***** + init_te_thread(eNB,attr_te); + //init_td_thread(eNB,attr_td); + if (opp_enabled == 1) pthread_create(&proc->coding_stats_thread,NULL,coding_stats_thread,(void*)eNB); } @@ -695,6 +719,8 @@ void init_eNB_proc(int inst) { pthread_mutex_init(&sync_phy_proc.mutex_phy_proc_tx, NULL); pthread_cond_init(&sync_phy_proc.cond_phy_proc_tx, NULL); sync_phy_proc.phy_proc_CC_id = 0; + + } @@ -927,8 +953,8 @@ void init_eNB(int single_thread_flag,int wait_for_sync) { #endif - eNB->td = ulsch_decoding_data;//(single_thread_flag==1) ? ulsch_decoding_data_2thread : ulsch_decoding_data; - eNB->te = dlsch_encoding;//(single_thread_flag==1) ? dlsch_encoding_2threads : dlsch_encoding; + eNB->td = ulsch_decoding_data;//(get_nprocs()<=4) ? ulsch_decoding_data : ulsch_decoding_data_2thread; + eNB->te = dlsch_encoding_all;//(get_nprocs()<=4) ? dlsch_encoding : dlsch_encoding_2threads; LOG_I(PHY,"Registering with MAC interface module\n"); diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index 21804817d6..78511dc343 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -111,6 +111,7 @@ unsigned short config_frames[4] = {2,9,11,13}; #include "T.h" extern volatile int oai_exit; +extern int numerology; extern void phy_init_RU(RU_t*); @@ -1193,20 +1194,39 @@ void fill_rf_config(RU_t *ru, char *rf_config_file) { LTE_DL_FRAME_PARMS *fp = &ru->frame_parms; openair0_config_t *cfg = &ru->openair0_cfg; + //printf("////////////////numerology in config = %d\n",numerology); if(fp->N_RB_DL == 100) { - if (fp->threequarter_fs) { - cfg->sample_rate=23.04e6; - cfg->samples_per_frame = 230400; - cfg->tx_bw = 10e6; - cfg->rx_bw = 10e6; - } - else { - cfg->sample_rate=30.72e6; + if(numerology == 0){ + if (fp->threequarter_fs) { + cfg->sample_rate=23.04e6; + cfg->samples_per_frame = 230400; + cfg->tx_bw = 10e6; + cfg->rx_bw = 10e6; + } + else { + cfg->sample_rate=30.72e6; + cfg->samples_per_frame = 307200; + cfg->tx_bw = 10e6; + cfg->rx_bw = 10e6; + } + }else if(numerology == 1){ + cfg->sample_rate=61.44e6; + cfg->samples_per_frame = 307200; + cfg->tx_bw = 20e6; + cfg->rx_bw = 20e6; + }else if(numerology == 2){ + cfg->sample_rate=122.88e6; + cfg->samples_per_frame = 307200; + cfg->tx_bw = 40e6; + cfg->rx_bw = 40e6; + }else{ + printf("Wrong input for numerology %d\n setting to 20MHz normal CP configuration",numerology); + cfg->sample_rate=30.72e6; cfg->samples_per_frame = 307200; cfg->tx_bw = 10e6; cfg->rx_bw = 10e6; - } + } } else if(fp->N_RB_DL == 50) { cfg->sample_rate=15.36e6; cfg->samples_per_frame = 153600; @@ -1895,7 +1915,7 @@ void init_RU(char *rf_config_file) { eNB0->RU_list[eNB0->num_RU++] = ru; } } - // LOG_I(PHY,"Initializing RRU descriptor %d : (%s,%s,%d)\n",ru_id,ru_if_types[ru->if_south],eNB_timing[ru->if_timing],ru->function); + LOG_I(PHY,"Initializing RRU descriptor %d : (%s,%s,%d)\n",ru_id,ru_if_types[ru->if_south],eNB_timing[ru->if_timing],ru->function); switch (ru->if_south) { @@ -1945,8 +1965,8 @@ void init_RU(char *rf_config_file) { } else if (ru->function == eNodeB_3GPP) { ru->do_prach = 0; // no prach processing in RU - ru->feprx = (get_nprocs()<=2) ? fep_full : ru_fep_full_2thread; // RX DFTs - ru->feptx_ofdm = (get_nprocs()<=2) ? feptx_ofdm : feptx_ofdm_2thread; // this is fep with idft and precoding + ru->feprx = (get_nprocs()<=4) ? fep_full : ru_fep_full_2thread; // RX DFTs + ru->feptx_ofdm = (get_nprocs()<=4) ? feptx_ofdm : feptx_ofdm_2thread; // this is fep with idft and precoding ru->feptx_prec = feptx_prec; // this is fep with idft and precoding ru->fh_north_in = NULL; // no incoming fronthaul from north ru->fh_north_out = NULL; // no outgoing fronthaul to north diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index a8cc3e84d9..98a68a2e10 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -207,6 +207,8 @@ extern void print_opp_meas(void); int transmission_mode=1; +int numerology = 1; + /* struct for ethernet specific parameters given in eNB conf file */ @@ -751,6 +753,8 @@ void init_openair0() { openair0_cfg[card].configFilename = NULL; if(frame_parms[0]->N_RB_DL == 100) { + if(numerology == 0) + { if (frame_parms[0]->threequarter_fs) { openair0_cfg[card].sample_rate=23.04e6; openair0_cfg[card].samples_per_frame = 230400; @@ -762,6 +766,22 @@ void init_openair0() { openair0_cfg[card].tx_bw = 10e6; openair0_cfg[card].rx_bw = 10e6; } + }else if(numerology == 1) + { + openair0_cfg[card].sample_rate=61.44e6; + openair0_cfg[card].samples_per_frame = 307200; + openair0_cfg[card].tx_bw = 20e6; + openair0_cfg[card].rx_bw = 20e6; + }else if(numerology == 2) + { + openair0_cfg[card].sample_rate=122.88e6; + openair0_cfg[card].samples_per_frame = 307200; + openair0_cfg[card].tx_bw = 20e6; + openair0_cfg[card].rx_bw = 20e6; + }else + { + printf("Un supported numerology\n"); + } } else if(frame_parms[0]->N_RB_DL == 50) { openair0_cfg[card].sample_rate=15.36e6; openair0_cfg[card].samples_per_frame = 153600; diff --git a/targets/RT/USER/lte-softmodem.h b/targets/RT/USER/lte-softmodem.h index 28003f75db..27a6c11b5e 100644 --- a/targets/RT/USER/lte-softmodem.h +++ b/targets/RT/USER/lte-softmodem.h @@ -83,6 +83,7 @@ #define CONFIG_HLP_TPORT "tracer port\n" #define CONFIG_HLP_NOTWAIT "don't wait for tracer, start immediately\n" #define CONFIG_HLP_TNOFORK "to ease debugging with gdb\n" +#define CONFIG_HLP_NUMEROLOGY "adding numerology for 5G\n" /***************************************************************************************************************************************/ @@ -137,36 +138,37 @@ extern int16_t dlsch_demod_shift; /* optname helpstr paramflags XXXptr defXXXval type numelt */ /*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ #define CMDLINE_PARAMS_DESC { \ -{"rf-config-file", CONFIG_HLP_RFCFGF, 0, strptr:(char **)&rf_config_file, defstrval:NULL, TYPE_STRING, sizeof(rf_config_file)}, \ -{"ulsch-max-errors", CONFIG_HLP_ULMAXE, 0, uptr:&ULSCH_max_consecutive_errors, defuintval:0, TYPE_UINT, 0}, \ -{"phy-test", CONFIG_HLP_PHYTST, PARAMFLAG_BOOL, iptr:&phy_test, defintval:0, TYPE_INT, 0}, \ -{"usim-test", CONFIG_HLP_USIM, PARAMFLAG_BOOL, u8ptr:&usim_test, defintval:0, TYPE_UINT8, 0}, \ -{"mmapped-dma", CONFIG_HLP_DMAMAP, PARAMFLAG_BOOL, uptr:&mmapped_dma, defintval:0, TYPE_INT, 0}, \ -{"external-clock", CONFIG_HLP_EXCCLK, PARAMFLAG_BOOL, uptr:&clock_source, defintval:0, TYPE_INT, 0}, \ -{"wait-for-sync", NULL, PARAMFLAG_BOOL, iptr:&wait_for_sync, defintval:0, TYPE_INT, 0}, \ -{"single-thread-disable", CONFIG_HLP_NOSNGLT, PARAMFLAG_BOOL, iptr:&single_thread_flag, defintval:1, TYPE_INT, 0}, \ -{"threadIQ", NULL, 0, iptr:&(threads.iq), defintval:1, TYPE_INT, 0}, \ -{"threadOneSubframe", NULL, 0, iptr:&(threads.one), defintval:1, TYPE_INT, 0}, \ -{"threadTwoSubframe", NULL, 0, iptr:&(threads.two), defintval:1, TYPE_INT, 0}, \ -{"threadThreeSubframe", NULL, 0, iptr:&(threads.three), defintval:1, TYPE_INT, 0}, \ -{"threadSlot1ProcOne", NULL, 0, iptr:&(threads.slot1_proc_one), defintval:1, TYPE_INT, 0}, \ -{"threadSlot1ProcTwo", NULL, 0, iptr:&(threads.slot1_proc_two), defintval:1, TYPE_INT, 0}, \ -{"dlsch-demod-shift", CONFIG_HLP_DLSHIFT, 0, iptr:(int32_t *)&dlsch_demod_shift, defintval:0, TYPE_INT, 0}, \ -{"A" , CONFIG_HLP_TADV, 0, uptr:&timing_advance, defintval:0, TYPE_UINT, 0}, \ -{"C" , CONFIG_HLP_DLF, 0, uptr:&(downlink_frequency[0][0]), defuintval:2680000000, TYPE_UINT, 0}, \ -{"a" , CONFIG_HLP_CHOFF, 0, iptr:&chain_offset, defintval:0, TYPE_INT, 0}, \ -{"d" , CONFIG_HLP_SOFTS, PARAMFLAG_BOOL, uptr:(uint32_t *)&do_forms, defintval:0, TYPE_INT8, 0}, \ -{"E" , CONFIG_HLP_TQFS, PARAMFLAG_BOOL, i8ptr:&threequarter_fs, defintval:0, TYPE_INT8, 0}, \ -{"K" , CONFIG_HLP_ITTIL, PARAMFLAG_NOFREE, strptr:&itti_dump_file, defstrval:"/tmp/itti.dump", TYPE_STRING, 0}, \ -{"U" , CONFIG_HLP_UE, PARAMFLAG_BOOL, i8ptr:&UE_flag, defintval:0, TYPE_INT8, 0}, \ -{"m" , CONFIG_HLP_DLMCS, 0, uptr:&target_dl_mcs, defintval:0, TYPE_UINT, 0}, \ -{"t" , CONFIG_HLP_ULMCS, 0, uptr:&target_ul_mcs, defintval:0, TYPE_UINT, 0}, \ -{"W" , CONFIG_HLP_L2MONW, 0, strptr:(char **)&in_ip, defstrval:"127.0.0.1", TYPE_STRING, sizeof(in_ip)}, \ -{"P" , CONFIG_HLP_L2MONP, 0, strptr:(char **)&in_path, defstrval:"/tmp/oai_opt.pcap", TYPE_STRING, sizeof(in_path)}, \ -{"V" , CONFIG_HLP_VCD, PARAMFLAG_BOOL, iptr:&ouput_vcd, defintval:0, TYPE_INT, 0}, \ -{"q" , CONFIG_HLP_STMON, PARAMFLAG_BOOL, iptr:&opp_enabled, defintval:0, TYPE_INT, 0}, \ -{"S" , CONFIG_HLP_MSLOTS, PARAMFLAG_BOOL, u8ptr:&exit_missed_slots, defintval:1, TYPE_UINT8, 0}, \ -{"T" , CONFIG_HLP_TDD, PARAMFLAG_BOOL, iptr:&tddflag, defintval:0, TYPE_INT, 0} \ +{"rf-config-file", CONFIG_HLP_RFCFGF, 0, strptr:(char **)&rf_config_file, defstrval:NULL, TYPE_STRING, sizeof(rf_config_file)}, \ +{"ulsch-max-errors", CONFIG_HLP_ULMAXE, 0, uptr:&ULSCH_max_consecutive_errors, defuintval:0, TYPE_UINT, 0}, \ +{"phy-test", CONFIG_HLP_PHYTST, PARAMFLAG_BOOL, iptr:&phy_test, defintval:0, TYPE_INT, 0}, \ +{"usim-test", CONFIG_HLP_USIM, PARAMFLAG_BOOL, u8ptr:&usim_test, defintval:0, TYPE_UINT8, 0}, \ +{"mmapped-dma", CONFIG_HLP_DMAMAP, PARAMFLAG_BOOL, uptr:&mmapped_dma, defintval:0, TYPE_INT, 0}, \ +{"external-clock", CONFIG_HLP_EXCCLK, PARAMFLAG_BOOL, uptr:&clock_source, defintval:0, TYPE_INT, 0}, \ +{"wait-for-sync", NULL, PARAMFLAG_BOOL, iptr:&wait_for_sync, defintval:0, TYPE_INT, 0}, \ +{"single-thread-disable", CONFIG_HLP_NOSNGLT, PARAMFLAG_BOOL, iptr:&single_thread_flag, defintval:1, TYPE_INT, 0}, \ +{"threadIQ", NULL, 0, iptr:&(threads.iq), defintval:1, TYPE_INT, 0}, \ +{"threadOneSubframe", NULL, 0, iptr:&(threads.one), defintval:1, TYPE_INT, 0}, \ +{"threadTwoSubframe", NULL, 0, iptr:&(threads.two), defintval:1, TYPE_INT, 0}, \ +{"threadThreeSubframe", NULL, 0, iptr:&(threads.three), defintval:1, TYPE_INT, 0}, \ +{"threadSlot1ProcOne", NULL, 0, iptr:&(threads.slot1_proc_one), defintval:1, TYPE_INT, 0}, \ +{"threadSlot1ProcTwo", NULL, 0, iptr:&(threads.slot1_proc_two), defintval:1, TYPE_INT, 0}, \ +{"dlsch-demod-shift", CONFIG_HLP_DLSHIFT, 0, iptr:(int32_t *)&dlsch_demod_shift, defintval:0, TYPE_INT, 0}, \ +{"A" , CONFIG_HLP_TADV, 0, uptr:&timing_advance, defintval:0, TYPE_UINT, 0}, \ +{"C" , CONFIG_HLP_DLF, 0, uptr:&(downlink_frequency[0][0]), defuintval:2680000000, TYPE_UINT, 0}, \ +{"a" , CONFIG_HLP_CHOFF, 0, iptr:&chain_offset, defintval:0, TYPE_INT, 0}, \ +{"d" , CONFIG_HLP_SOFTS, PARAMFLAG_BOOL, uptr:(uint32_t *)&do_forms, defintval:0, TYPE_INT8, 0}, \ +{"E" , CONFIG_HLP_TQFS, PARAMFLAG_BOOL, i8ptr:&threequarter_fs, defintval:0, TYPE_INT8, 0}, \ +{"K" , CONFIG_HLP_ITTIL, PARAMFLAG_NOFREE, strptr:&itti_dump_file, defstrval:"/tmp/itti.dump", TYPE_STRING, 0}, \ +{"U" , CONFIG_HLP_UE, PARAMFLAG_BOOL, i8ptr:&UE_flag, defintval:0, TYPE_INT8, 0}, \ +{"m" , CONFIG_HLP_DLMCS, 0, uptr:&target_dl_mcs, defintval:0, TYPE_UINT, 0}, \ +{"t" , CONFIG_HLP_ULMCS, 0, uptr:&target_ul_mcs, defintval:0, TYPE_UINT, 0}, \ +{"W" , CONFIG_HLP_L2MONW, 0, strptr:(char **)&in_ip, defstrval:"127.0.0.1", TYPE_STRING, sizeof(in_ip)}, \ +{"P" , CONFIG_HLP_L2MONP, 0, strptr:(char **)&in_path, defstrval:"/tmp/oai_opt.pcap", TYPE_STRING, sizeof(in_path)}, \ +{"V" , CONFIG_HLP_VCD, PARAMFLAG_BOOL, iptr:&ouput_vcd, defintval:0, TYPE_INT, 0}, \ +{"q" , CONFIG_HLP_STMON, PARAMFLAG_BOOL, iptr:&opp_enabled, defintval:0, TYPE_INT, 0}, \ +{"S" , CONFIG_HLP_MSLOTS, PARAMFLAG_BOOL, u8ptr:&exit_missed_slots, defintval:1, TYPE_UINT8, 0}, \ +{"T" , CONFIG_HLP_TDD, PARAMFLAG_BOOL, iptr:&tddflag, defintval:0, TYPE_INT, 0}, \ +{"n" , CONFIG_HLP_NUMEROLOGY, 0, iptr:&numerology, defintval:1, TYPE_INT, 0} \ } #define CONFIG_HLP_FLOG "Enable online log \n" From 2dc1a602c6751597db6b15856be06b751b7cb7ee Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger Date: Mon, 16 Oct 2017 21:58:21 +0200 Subject: [PATCH 02/63] first phy-test version to be tested --- cmake_targets/CMakeLists.txt | 1 + openair2/LAYER2/MAC/eNB_scheduler.c | 4 +- openair2/LAYER2/MAC/eNB_scheduler_phytest.c | 181 ++++++++++++++++++++ openair2/LAYER2/MAC/proto.h | 2 + 4 files changed, 187 insertions(+), 1 deletion(-) create mode 100644 openair2/LAYER2/MAC/eNB_scheduler_phytest.c diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index e34e627459..dd56bdf760 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -1180,6 +1180,7 @@ set (MAC_SRC ${MAC_DIR}/eNB_scheduler_bch.c ${MAC_DIR}/eNB_scheduler_primitives.c ${MAC_DIR}/eNB_scheduler_RA.c + ${MAC_DIR}/eNB_scheduler_phytest.c ${MAC_DIR}/pre_processor.c ${MAC_DIR}/config.c ) diff --git a/openair2/LAYER2/MAC/eNB_scheduler.c b/openair2/LAYER2/MAC/eNB_scheduler.c index 5b74cdc4ae..e5d6bf67b3 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler.c +++ b/openair2/LAYER2/MAC/eNB_scheduler.c @@ -535,7 +535,9 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP, frame_t frameP, sub_frame schedule_CSI(module_idP, frameP, subframeP); // This schedules DLSCH in subframeP - schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status); + //schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status); + + schedule_ue_spec_phy_test(module_idP,frameP,subframeP,mbsfn_status); // Allocate CCEs for good after scheduling is done diff --git a/openair2/LAYER2/MAC/eNB_scheduler_phytest.c b/openair2/LAYER2/MAC/eNB_scheduler_phytest.c new file mode 100644 index 0000000000..603e08e382 --- /dev/null +++ b/openair2/LAYER2/MAC/eNB_scheduler_phytest.c @@ -0,0 +1,181 @@ +/* + * Licensed to the OpenAirInterface (OAI) Software Alliance under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The OpenAirInterface Software Alliance licenses this file to You under + * the OAI Public License, Version 1.0 (the "License"); you may not use this file + * except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.openairinterface.org/?page_id=698 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + *------------------------------------------------------------------------------- + * For more information about the OpenAirInterface (OAI) Software Alliance: + * contact@openairinterface.org + */ + +/*! \file eNB_scheduler_dlsch.c + * \brief procedures related to eNB for the DLSCH transport channel + * \author Navid Nikaein and Raymond Knopp + * \date 2010 - 2014 + * \email: navid.nikaein@eurecom.fr + * \version 1.0 + * @ingroup _mac + + */ + +#include "assertions.h" +#include "PHY/defs.h" +#include "PHY/extern.h" + +#include "SCHED/defs.h" +#include "SCHED/extern.h" + +#include "LAYER2/MAC/defs.h" +#include "LAYER2/MAC/proto.h" +#include "LAYER2/MAC/extern.h" +#include "UTIL/LOG/log.h" +#include "UTIL/LOG/vcd_signal_dumper.h" +#include "UTIL/OPT/opt.h" +#include "OCG.h" +#include "OCG_extern.h" + +#include "SIMULATION/TOOLS/defs.h" // for taus + +#include "T.h" + +extern RAN_CONTEXT_t RC; + +//------------------------------------------------------------------------------ +void +schedule_ue_spec_phy_test( + module_id_t module_idP, + frame_t frameP, + sub_frame_t subframeP, + int* mbsfn_flag +) +//------------------------------------------------------------------------------ +{ + uint8_t CC_id; + int UE_id=0; + uint16_t N_RB_DL; + uint16_t TBS; + uint16_t nb_rb; + + unsigned char harq_pid = subframeP%5; + uint16_t rnti = 0x1235; + uint32_t rb_alloc = 0x1FFF; + int32_t tpc = 1; + int32_t mcs = 0; + int32_t cqi = 15; + int32_t ndi = subframeP/5; + int32_t dai = 0; + + eNB_MAC_INST *eNB = RC.mac[module_idP]; + COMMON_channels_t *cc = eNB->common_channels; + nfapi_dl_config_request_body_t *dl_req; + nfapi_dl_config_request_pdu_t *dl_config_pdu; + + N_RB_DL = to_prb(cc->mib->message.dl_Bandwidth); + + for (CC_id=0; CC_idDL_req[CC_id].dl_config_request_body; + + if (mbsfn_flag[CC_id]>0) + continue; + + nb_rb = conv_nprb(0,rb_alloc,N_RB_DL); + TBS = get_TBS_DL(mcs,nb_rb); + + dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu]; + memset((void*)dl_config_pdu,0,sizeof(nfapi_dl_config_request_pdu_t)); + dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE; + dl_config_pdu->pdu_size = (uint8_t)(2+sizeof(nfapi_dl_config_dci_dl_pdu)); + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.dci_format = NFAPI_DL_DCI_FORMAT_1; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level = get_aggregation(get_bw_index(module_idP,CC_id),cqi,format1); + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti = rnti; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type = 1; // CRNTI : see Table 4-10 from SCF082 - nFAPI specifications + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.transmission_power = 6000; // equal to RS power + + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.harq_process = harq_pid; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.tpc = tpc; // dont adjust power when retransmitting + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.new_data_indicator_1 = ndi; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.mcs_1 = mcs; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.redundancy_version_1 = 0; + //deactivate second codeword + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.mcs_2 = 0; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.redundancy_version_2 = 1; + + if (cc[CC_id].tdd_Config != NULL) { //TDD + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.downlink_assignment_index = dai; + LOG_D(MAC,"[eNB %d] Initial transmission CC_id %d : harq_pid %d, dai %d, mcs %d\n", + module_idP,CC_id,harq_pid,dai,mcs); + } else { + LOG_D(MAC,"[eNB %d] Initial transmission CC_id %d : harq_pid %d, mcs %d\n", + module_idP,CC_id,harq_pid,mcs); + + } + LOG_D(MAC,"Checking feasibility pdu %d (new sdu)\n",dl_req->number_pdu); + if (!CCE_allocation_infeasible(module_idP,CC_id,1,subframeP,dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level,rnti)) { + + + //ue_sched_ctl->round[CC_id][harq_pid] = 0; + dl_req->number_dci++; + dl_req->number_pdu++; + + // Toggle NDI for next time + /* + LOG_D(MAC,"CC_id %d Frame %d, subframeP %d: Toggling Format1 NDI for UE %d (rnti %x/%d) oldNDI %d\n", + CC_id, frameP,subframeP,UE_id, + rnti,harq_pid,UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]); + + UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]=1-UE_list->UE_template[CC_id][UE_id].oldNDI[harq_pid]; + UE_list->UE_template[CC_id][UE_id].oldmcs1[harq_pid] = mcs; + UE_list->UE_template[CC_id][UE_id].oldmcs2[harq_pid] = 0; + AssertFatal(UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated!=NULL,"physicalConfigDedicated is NULL\n"); + AssertFatal(UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->pdsch_ConfigDedicated!=NULL,"physicalConfigDedicated->pdsch_ConfigDedicated is NULL\n"); + */ + + + + fill_nfapi_dlsch_config(eNB, + dl_req, + TBS, + eNB->pdu_index[CC_id], + rnti, + 0, // type 0 allocation from 7.1.6 in 36.213 + 0, // virtual_resource_block_assignment_flag + rb_alloc, // resource_block_coding + getQm(mcs), + 0, // redundancy version + 1, // transport blocks + 0, // transport block to codeword swap flag + cc[CC_id].p_eNB == 1 ? 0 : 1, // transmission_scheme + 1, // number of layers + 1, // number of subbands + // uint8_t codebook_index, + 4, // UE category capacity + 0, /*UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->pdsch_ConfigDedicated->p_a,*/ + 0, // delta_power_offset for TM5 + 0, // ngap + 0, // nprb + cc[CC_id].p_eNB == 1 ? 1 : 2, // transmission mode + 0, //number of PRBs treated as one subband, not used here + 0 // number of beamforming vectors, not used here + ); + + eNB->TX_req[CC_id].sfn_sf = fill_nfapi_tx_req(&eNB->TX_req[CC_id].tx_request_body, + (frameP*10)+subframeP, + TBS, + eNB->pdu_index[CC_id], + eNB->UE_list.DLSCH_pdu[CC_id][0][(unsigned char)UE_id].payload[0]); + } + } +} diff --git a/openair2/LAYER2/MAC/proto.h b/openair2/LAYER2/MAC/proto.h index 2bad81d52c..2b458cd96b 100644 --- a/openair2/LAYER2/MAC/proto.h +++ b/openair2/LAYER2/MAC/proto.h @@ -119,6 +119,8 @@ void fill_DLSCH_dci(module_id_t module_idP,frame_t frameP,sub_frame_t subframe,i */ void schedule_ue_spec(module_id_t module_idP,frame_t frameP,sub_frame_t subframe,int *mbsfn_flag); +void schedule_ue_spec_phy_test(module_id_t module_idP,frame_t frameP,sub_frame_t subframe,int *mbsfn_flag); + /** \brief Function for UE/PHY to compute PUSCH transmit power in power-control procedure. @param Mod_id Module id of UE From 5487c709b165d5718baa1549994f90bb63a11398 Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger Date: Thu, 19 Oct 2017 09:36:01 +0200 Subject: [PATCH 03/63] adding some missing parameters --- openair2/LAYER2/MAC/eNB_scheduler.c | 2 ++ openair2/LAYER2/MAC/eNB_scheduler_phytest.c | 10 ++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/openair2/LAYER2/MAC/eNB_scheduler.c b/openair2/LAYER2/MAC/eNB_scheduler.c index e5d6bf67b3..50592921dd 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler.c +++ b/openair2/LAYER2/MAC/eNB_scheduler.c @@ -519,6 +519,7 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP, frame_t frameP, sub_frame // This schedules MIB if ((subframeP==0) && (frameP&3) == 0) schedule_mib(module_idP,frameP,subframeP); + /* // This schedules SI for legacy LTE and eMTC starting in subframeP schedule_SI(module_idP,frameP,subframeP); // This schedules Random-Access for legacy LTE and eMTC starting in subframeP @@ -533,6 +534,7 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP, frame_t frameP, sub_frame schedule_SR(module_idP,frameP,subframeP); // This schedules UCI_CSI in subframeP schedule_CSI(module_idP, frameP, subframeP); + */ // This schedules DLSCH in subframeP //schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status); diff --git a/openair2/LAYER2/MAC/eNB_scheduler_phytest.c b/openair2/LAYER2/MAC/eNB_scheduler_phytest.c index 603e08e382..431eda87f8 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_phytest.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_phytest.c @@ -69,9 +69,9 @@ schedule_ue_spec_phy_test( unsigned char harq_pid = subframeP%5; uint16_t rnti = 0x1235; - uint32_t rb_alloc = 0x1FFF; + uint32_t rb_alloc = 0x1FFFFFFF; int32_t tpc = 1; - int32_t mcs = 0; + int32_t mcs = 16; int32_t cqi = 15; int32_t ndi = subframeP/5; int32_t dai = 0; @@ -94,12 +94,18 @@ schedule_ue_spec_phy_test( nb_rb = conv_nprb(0,rb_alloc,N_RB_DL); TBS = get_TBS_DL(mcs,nb_rb); + LOG_I(PHY,"schedule_ue_spec_phy_test: subframe %d: nb_rb=%d, TBS=%d, mcs=%d (rb_alloc=%x, N_RB_DL=%d)\n",subframeP,nb_rb,TBS,mcs,rb_alloc,N_RB_DL); + dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu]; memset((void*)dl_config_pdu,0,sizeof(nfapi_dl_config_request_pdu_t)); dl_config_pdu->pdu_type = NFAPI_DL_CONFIG_DCI_DL_PDU_TYPE; dl_config_pdu->pdu_size = (uint8_t)(2+sizeof(nfapi_dl_config_dci_dl_pdu)); dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.dci_format = NFAPI_DL_DCI_FORMAT_1; dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.aggregation_level = get_aggregation(get_bw_index(module_idP,CC_id),cqi,format1); + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.resource_allocation_type = 0; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.virtual_resource_block_assignment_flag = 0; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.resource_block_coding = rb_alloc; + dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti = rnti; dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.rnti_type = 1; // CRNTI : see Table 4-10 from SCF082 - nFAPI specifications dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.transmission_power = 6000; // equal to RS power From 2466f16ec3f1c0caf2af65061a377a7c5bd7a00c Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger Date: Mon, 23 Oct 2017 14:54:39 +0200 Subject: [PATCH 04/63] adding flag for phy-test --- openair2/LAYER2/MAC/defs.h | 2 ++ openair2/LAYER2/MAC/eNB_scheduler.c | 47 +++++++++++++++-------------- 2 files changed, 26 insertions(+), 23 deletions(-) diff --git a/openair2/LAYER2/MAC/defs.h b/openair2/LAYER2/MAC/defs.h index aab00d610b..b0d7dffa20 100644 --- a/openair2/LAYER2/MAC/defs.h +++ b/openair2/LAYER2/MAC/defs.h @@ -1051,6 +1051,8 @@ typedef struct eNB_MAC_INST_s { COMMON_channels_t common_channels[MAX_NUM_CCs]; /// current PDU index (BCH,MCH,DLSCH) uint16_t pdu_index[MAX_NUM_CCs]; + /// flag to enable phy-test (disables the scheduler) + uint16_t phy_test; /// NFAPI Config Request Structure nfapi_config_request_t config[MAX_NUM_CCs]; diff --git a/openair2/LAYER2/MAC/eNB_scheduler.c b/openair2/LAYER2/MAC/eNB_scheduler.c index 50592921dd..ca802f4201 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler.c +++ b/openair2/LAYER2/MAC/eNB_scheduler.c @@ -517,29 +517,30 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP, frame_t frameP, sub_frame #endif - // This schedules MIB - if ((subframeP==0) && (frameP&3) == 0) schedule_mib(module_idP,frameP,subframeP); - /* - // This schedules SI for legacy LTE and eMTC starting in subframeP - schedule_SI(module_idP,frameP,subframeP); - // This schedules Random-Access for legacy LTE and eMTC starting in subframeP - schedule_RA(module_idP,frameP,subframeP); - // copy previously scheduled UL resources (ULSCH + HARQ) - copy_ulreq(module_idP,frameP,subframeP); - // This schedules SRS in subframeP - schedule_SRS(module_idP,frameP,subframeP); - // This schedules ULSCH in subframeP (dci0) - schedule_ulsch(module_idP,frameP,subframeP); - // This schedules UCI_SR in subframeP - schedule_SR(module_idP,frameP,subframeP); - // This schedules UCI_CSI in subframeP - schedule_CSI(module_idP, frameP, subframeP); - */ - - // This schedules DLSCH in subframeP - //schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status); - - schedule_ue_spec_phy_test(module_idP,frameP,subframeP,mbsfn_status); + if (RC.mac[module_idP]->phy_test==0) { + // This schedules MIB + if ((subframeP==0) && (frameP&3) == 0) schedule_mib(module_idP,frameP,subframeP); + // This schedules SI for legacy LTE and eMTC starting in subframeP + schedule_SI(module_idP,frameP,subframeP); + // This schedules Random-Access for legacy LTE and eMTC starting in subframeP + schedule_RA(module_idP,frameP,subframeP); + // copy previously scheduled UL resources (ULSCH + HARQ) + copy_ulreq(module_idP,frameP,subframeP); + // This schedules SRS in subframeP + schedule_SRS(module_idP,frameP,subframeP); + // This schedules ULSCH in subframeP (dci0) + schedule_ulsch(module_idP,frameP,subframeP); + // This schedules UCI_SR in subframeP + schedule_SR(module_idP,frameP,subframeP); + // This schedules UCI_CSI in subframeP + schedule_CSI(module_idP, frameP, subframeP); + + // This schedules DLSCH in subframeP + schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status); + } + else { + schedule_ue_spec_phy_test(module_idP,frameP,subframeP,mbsfn_status); + } // Allocate CCEs for good after scheduling is done From 85ce7de775e95ef54b1d6536198395c651a6d7c7 Mon Sep 17 00:00:00 2001 From: Wang Tsu-Han Date: Fri, 27 Oct 2017 10:33:30 +0200 Subject: [PATCH 05/63] added thread for TX streaming --- openair1/PHY/LTE_TRANSPORT/dlsch_coding.c | 2 + openair1/PHY/LTE_TRANSPORT/proto.h | 8 +- openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c | 14 ++- openair1/PHY/defs.h | 8 +- openair2/LAYER2/MAC/eNB_scheduler.c | 6 +- openair2/LAYER2/MAC/eNB_scheduler_phytest.c | 4 +- targets/RT/USER/eNB_usrp.gtkw | 44 +++++--- targets/RT/USER/lte-enb.c | 8 +- targets/RT/USER/lte-ru.c | 105 ++++++++++++++++---- targets/RT/USER/lte-softmodem.c | 7 +- targets/RT/USER/lte-softmodem.h | 2 +- 11 files changed, 162 insertions(+), 46 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c index 9152a6a9ad..57dac12ae4 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c @@ -575,6 +575,7 @@ int dlsch_encoding_all(PHY_VARS_eNB *eNB, int encoding_return = 0; unsigned int L,C,B; B = dlsch->harq_processes[dlsch->harq_ids[subframe]]->B; + //printf("total bit length is %d\n",B);///////////******* if(B<=6144) { L=0; @@ -601,6 +602,7 @@ int dlsch_encoding_all(PHY_VARS_eNB *eNB, rm_stats, te_stats, i_stats); + //printf("having more then 5 segmentation\n");///////////******* } else { diff --git a/openair1/PHY/LTE_TRANSPORT/proto.h b/openair1/PHY/LTE_TRANSPORT/proto.h index 2c6e73d45a..169490d03d 100644 --- a/openair1/PHY/LTE_TRANSPORT/proto.h +++ b/openair1/PHY/LTE_TRANSPORT/proto.h @@ -121,7 +121,7 @@ int32_t dlsch_encoding(PHY_VARS_eNB *eNB, time_stats_t *rm_stats, time_stats_t *te_stats, time_stats_t *i_stats); - + int32_t dlsch_encoding_all(PHY_VARS_eNB *eNB, uint8_t *a, uint8_t num_pdcch_symbols, @@ -132,7 +132,6 @@ int32_t dlsch_encoding_all(PHY_VARS_eNB *eNB, time_stats_t *te_stats, time_stats_t *i_stats); - int32_t dlsch_encoding_SIC(PHY_VARS_UE *ue, uint8_t *a, uint8_t num_pdcch_symbols, @@ -1900,6 +1899,11 @@ unsigned int ulsch_decoding(PHY_VARS_eNB *phy_vars_eNB, uint8_t Nbundled, uint8_t llr8_flag); +int ulsch_decoding_data_all(PHY_VARS_eNB *eNB, + int UE_id, + int harq_pid, + int llr8_flag); + /*! \brief Decoding of ULSCH data component from 36-212. This one spawns 1 worker thread in parallel,half of the segments in each thread. @param phy_vars_eNB Pointer to eNB top-level descriptor diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c index b8a31f3daa..277e1918f2 100644 --- a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c +++ b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c @@ -207,7 +207,19 @@ uint8_t extract_cqi_crc(uint8_t *cqi,uint8_t CQI_LENGTH) - +/*int ulsch_decoding_data_all(PHY_VARS_eNB *eNB,int UE_id,int harq_pid,int llr8_flag) +{ + int value = 0; + if() + { + value = ulsch_decoding_data_2thread(eNB,UE_id,harq_pid,llr8_flag); + } + else + { + value = ulsch_decoding_data(eNB,UE_id,harq_pid,llr8_flag); + } + return value; +}*/ int ulsch_decoding_data_2thread0(td_params* tdp) { diff --git a/openair1/PHY/defs.h b/openair1/PHY/defs.h index 27ec0cc548..f1a38aedef 100644 --- a/openair1/PHY/defs.h +++ b/openair1/PHY/defs.h @@ -315,6 +315,7 @@ typedef struct RU_proc_t_s { /// \brief Instance count for FH processing thread. /// \internal This variable is protected by \ref mutex_FH. int instance_cnt_FH; + int instance_cnt_FH1; /// \internal This variable is protected by \ref mutex_prach. int instance_cnt_prach; #ifdef Rel14 @@ -334,6 +335,7 @@ typedef struct RU_proc_t_s { int instance_cnt_feptx; /// pthread structure for RU FH processing thread pthread_t pthread_FH; + pthread_t pthread_FH1; /// pthread structure for RU prach processing thread pthread_t pthread_prach; #ifdef Rel14 @@ -354,6 +356,7 @@ typedef struct RU_proc_t_s { int first_tx; /// pthread attributes for RU FH processing thread pthread_attr_t attr_FH; + pthread_attr_t attr_FH1; /// pthread attributes for RU prach pthread_attr_t attr_prach; #ifdef Rel14 @@ -370,6 +373,7 @@ typedef struct RU_proc_t_s { pthread_attr_t attr_feptx; /// scheduling parameters for RU FH thread struct sched_param sched_param_FH; + struct sched_param sched_param_FH1; /// scheduling parameters for RU prach thread struct sched_param sched_param_prach; #ifdef Rel14 @@ -382,6 +386,7 @@ typedef struct RU_proc_t_s { struct sched_param sched_param_asynch_rxtx; /// condition variable for RU FH thread pthread_cond_t cond_FH; + pthread_cond_t cond_FH1; /// condition variable for RU prach thread pthread_cond_t cond_prach; #ifdef Rel14 @@ -400,6 +405,7 @@ typedef struct RU_proc_t_s { pthread_cond_t cond_eNBs; /// mutex for RU FH pthread_mutex_t mutex_FH; + pthread_mutex_t mutex_FH1; /// mutex for RU prach pthread_mutex_t mutex_prach; #ifdef Rel14 @@ -749,7 +755,7 @@ typedef struct RU_t_s{ /// function pointer to wakeup routine in lte-enb. void (*wakeup_prach_eNB_br)(struct PHY_VARS_eNB_s *eNB,struct RU_t_s *ru,int frame,int subframe); /// function pointer to eNB entry routine - void (*eNB_top)(struct PHY_VARS_eNB_s *eNB, int frame_rx, int subframe_rx, char *string); + void (*eNB_top)(struct PHY_VARS_eNB_s *eNB, int frame_rx, int subframe_rx, char *string,struct RU_t_s *ru); /// Timing statistics time_stats_t ofdm_demod_stats; /// Timing statistics (TX) diff --git a/openair2/LAYER2/MAC/eNB_scheduler.c b/openair2/LAYER2/MAC/eNB_scheduler.c index ca802f4201..3c571718ca 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler.c +++ b/openair2/LAYER2/MAC/eNB_scheduler.c @@ -67,6 +67,7 @@ #define DEBUG_eNB_SCHEDULER 1 extern RAN_CONTEXT_t RC; +extern int phy_test; uint16_t pdcch_order_table[6] = {31,31,511,2047,2047,8191}; @@ -517,9 +518,10 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP, frame_t frameP, sub_frame #endif - if (RC.mac[module_idP]->phy_test==0) { + // This schedules MIB - if ((subframeP==0) && (frameP&3) == 0) schedule_mib(module_idP,frameP,subframeP); + if ((subframeP==0) && (frameP&3) == 0) schedule_mib(module_idP,frameP,subframeP); + if (phy_test==0) { // This schedules SI for legacy LTE and eMTC starting in subframeP schedule_SI(module_idP,frameP,subframeP); // This schedules Random-Access for legacy LTE and eMTC starting in subframeP diff --git a/openair2/LAYER2/MAC/eNB_scheduler_phytest.c b/openair2/LAYER2/MAC/eNB_scheduler_phytest.c index 431eda87f8..e279edd0dd 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_phytest.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_phytest.c @@ -71,7 +71,7 @@ schedule_ue_spec_phy_test( uint16_t rnti = 0x1235; uint32_t rb_alloc = 0x1FFFFFFF; int32_t tpc = 1; - int32_t mcs = 16; + int32_t mcs = 28; int32_t cqi = 15; int32_t ndi = subframeP/5; int32_t dai = 0; @@ -94,7 +94,7 @@ schedule_ue_spec_phy_test( nb_rb = conv_nprb(0,rb_alloc,N_RB_DL); TBS = get_TBS_DL(mcs,nb_rb); - LOG_I(PHY,"schedule_ue_spec_phy_test: subframe %d: nb_rb=%d, TBS=%d, mcs=%d (rb_alloc=%x, N_RB_DL=%d)\n",subframeP,nb_rb,TBS,mcs,rb_alloc,N_RB_DL); + LOG_D(PHY,"schedule_ue_spec_phy_test: subframe %d: nb_rb=%d, TBS=%d, mcs=%d (rb_alloc=%x, N_RB_DL=%d)\n",subframeP,nb_rb,TBS,mcs,rb_alloc,N_RB_DL); dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu]; memset((void*)dl_config_pdu,0,sizeof(nfapi_dl_config_request_pdu_t)); diff --git a/targets/RT/USER/eNB_usrp.gtkw b/targets/RT/USER/eNB_usrp.gtkw index 838ec54383..2067468102 100644 --- a/targets/RT/USER/eNB_usrp.gtkw +++ b/targets/RT/USER/eNB_usrp.gtkw @@ -1,19 +1,19 @@ [*] [*] GTKWave Analyzer v3.3.58 (w)1999-2014 BSI -[*] Tue Jul 25 20:26:12 2017 +[*] Tue Oct 24 08:41:51 2017 [*] [dumpfile] "/tmp/openair_dump_eNB.vcd" -[dumpfile_mtime] "Tue Jul 25 20:11:55 2017" -[dumpfile_size] 19201475 -[savefile] "/home/papillon/openairinterface5g/targets/RT/USER/eNB_usrp.gtkw" -[timestart] 29023604000 -[size] 1236 578 -[pos] 309 0 -*-20.793451 29026062100 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 +[dumpfile_mtime] "Tue Oct 24 08:27:56 2017" +[dumpfile_size] 4053651 +[savefile] "/homes/wangts/openairinterface5g/targets/RT/USER/eNB_usrp.gtkw" +[timestart] 15494750000 +[size] 1855 1056 +[pos] 65 -10 +*-19.872988 15497443000 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 [sst_width] 386 -[signals_width] 262 +[signals_width] 302 [sst_expanded] 1 -[sst_vpaned_height] 146 +[sst_vpaned_height] 317 @28 functions.trx_read functions.trx_write @@ -25,12 +25,32 @@ functions.eNB_thread_rxtx0 @24 variables.frame_number_RX0_RU[63:0] variables.subframe_number_RX0_RU[63:0] -@25 variables.frame_number_TX0_RU[63:0] -@24 variables.subframe_number_TX0_RU[63:0] @28 +functions.mac_schedule_dlsch +functions.macxface_eNB_dlsch_ulsch_scheduler +functions.macxface_ue_scheduler +functions.phy_eNB_ofdm_mod_l +functions.phy_eNB_dlsch_scrambling +functions.phy_eNB_dlsch_modulation +functions.phy_eNB_dlsch_scrambling +functions.phy_eNB_beam_precoding +functions.phy_enb_pdcch_tx +functions.phy_enb_prach_rx +@29 +functions.phy_procedures_ru_feprx0 +@28 +functions.phy_procedures_eNb_rx_uespec0 +functions.phy_procedures_eNb_rx_uespec1 +functions.phy_enb_sfgen functions.phy_procedures_eNb_tx0 +functions.phy_procedures_eNb_tx1 +functions.phy_procedures_ru_feprx1 +functions.phy_procedures_ru_feptx_ofdm0 +functions.phy_procedures_ru_feptx_ofdm1 +functions.phy_procedures_ru_feptx_prec0 +functions.phy_procedures_ru_feptx_prec1 functions.eNB_thread_rxtx1 functions.phy_enb_sfgen functions.phy_enb_prach_rx diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index d82732c2cf..7402b330be 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -269,8 +269,9 @@ static void wait_system_ready (char *message, volatile int *start_flag) { -void eNB_top(PHY_VARS_eNB *eNB, int frame_rx, int subframe_rx, char *string) +void eNB_top(PHY_VARS_eNB *eNB, int frame_rx, int subframe_rx, char *string,RU_t *ru) { + RU_proc_t *ru_proc = &ru->proc; eNB_proc_t *proc = &eNB->proc; eNB_rxtx_proc_t *proc_rxtx = &proc->proc_rxtx[0]; @@ -293,6 +294,11 @@ void eNB_top(PHY_VARS_eNB *eNB, int frame_rx, int subframe_rx, char *string) if (rxtx(eNB,proc_rxtx,string) < 0) LOG_E(PHY,"eNB %d CC_id %d failed during execution\n",eNB->Mod_id,eNB->CC_id); LOG_D(PHY,"eNB_top out %p (proc %p, CC_id %d), frame %d, subframe %d, instance_cnt_prach %d\n", (void*)pthread_self(), proc, eNB->CC_id, proc->frame_rx,proc->subframe_rx,proc->instance_cnt_prach); + + pthread_mutex_lock(&ru_proc->mutex_eNBs); + ++ru_proc->instance_cnt_eNBs; + pthread_mutex_unlock(&ru_proc->mutex_eNBs); + pthread_cond_signal(&ru_proc->cond_eNBs); } } diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index 78511dc343..fcd44834c8 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -112,6 +112,7 @@ unsigned short config_frames[4] = {2,9,11,13}; extern volatile int oai_exit; extern int numerology; +extern int fh_two_thread; extern void phy_init_RU(RU_t*); @@ -876,7 +877,7 @@ static void* ru_thread_asynch_rxtx( void* param ) { subframe++; } LOG_D(PHY,"ru_thread_asynch_rxtx: Waiting on incoming fronthaul\n"); - // asynchronous receive from south (Mobipass) + // asynchronous receive from south (Mobipass) if (ru->fh_south_asynch_in) ru->fh_south_asynch_in(ru,&frame,&subframe); // asynchronous receive from north (RRU IF4/IF5) else if (ru->fh_north_asynch_in) ru->fh_north_asynch_in(ru,&frame,&subframe); @@ -1121,7 +1122,7 @@ void wakeup_eNBs(RU_t *ru) { char string[20]; sprintf(string,"Incoming RU %d",ru->idx); LOG_D(PHY,"RU %d Waking up eNB\n",ru->idx); - ru->eNB_top(eNB_list[0],ru->proc.frame_rx,ru->proc.subframe_rx,string); + ru->eNB_top(eNB_list[0],ru->proc.frame_rx,ru->proc.subframe_rx,string,ru); } else { @@ -1359,6 +1360,48 @@ static void* ru_stats_thread(void* param) { return(NULL); } +static void* ru_thread_tx( void* param ) { + RU_t *ru = (RU_t*)param; + RU_proc_t *proc = &ru->proc; + int subframe=0, frame=0; + + thread_top_init("ru_thread_tx",1,870000L,1000000L,1000000L); + + wait_on_condition(&proc->mutex_FH1,&proc->cond_FH1,&proc->instance_cnt_FH1,"ru_thread_tx"); + + printf( "ru_thread_tx ready\n"); + while (!oai_exit) { + + if (oai_exit) break; + + if (subframe==9) { + subframe=0; + frame++; + frame&=1023; + } else { + subframe++; + } + LOG_D(PHY,"ru_thread_tx: Waiting for TX processing\n"); + // wait until eNBs are finished subframe RX n and TX n+4 + wait_on_condition(&proc->mutex_eNBs,&proc->cond_eNBs,&proc->instance_cnt_eNBs,"ru_thread"); + + + // do TX front-end processing if needed (precoding and/or IDFTs) + if (ru->feptx_prec) ru->feptx_prec(ru); + + // do OFDM if needed + if ((ru->fh_north_asynch_in == NULL) && (ru->feptx_ofdm)) ru->feptx_ofdm(ru); + // do outgoing fronthaul (south) if needed + if ((ru->fh_north_asynch_in == NULL) && (ru->fh_south_out)) ru->fh_south_out(ru); + + if (ru->fh_north_out) ru->fh_north_out(ru); + + release_thread(&proc->mutex_eNBs,&proc->instance_cnt_eNBs,"ru_thread"); + } + + return 0; +} + static void* ru_thread( void* param ) { static int ru_thread_status; @@ -1431,10 +1474,15 @@ static void* ru_thread( void* param ) { pthread_cond_signal(&proc->cond_asynch_rxtx); } else LOG_I(PHY,"RU %d no asynch_south interface\n",ru->idx); - + // if this is a slave RRU, try to synchronize on the DL frequency if ((ru->is_slave) && (ru->if_south == LOCAL_RF)) do_ru_synch(ru); + pthread_mutex_lock(&proc->mutex_FH1); + proc->instance_cnt_FH1=0; + pthread_mutex_unlock(&proc->mutex_FH1); + pthread_cond_signal(&proc->cond_FH1); + // This is a forever while loop, it loops over subframes which are scheduled by incoming samples from HW devices while (!oai_exit) { @@ -1485,19 +1533,22 @@ static void* ru_thread( void* param ) { // wakeup all eNB processes waiting for this RU if (ru->num_eNB>0) wakeup_eNBs(ru); - // wait until eNBs are finished subframe RX n and TX n+4 - wait_on_condition(&proc->mutex_eNBs,&proc->cond_eNBs,&proc->instance_cnt_eNBs,"ru_thread"); - - - // do TX front-end processing if needed (precoding and/or IDFTs) - if (ru->feptx_prec) ru->feptx_prec(ru); - - // do OFDM if needed - if ((ru->fh_north_asynch_in == NULL) && (ru->feptx_ofdm)) ru->feptx_ofdm(ru); - // do outgoing fronthaul (south) if needed - if ((ru->fh_north_asynch_in == NULL) && (ru->fh_south_out)) ru->fh_south_out(ru); - - if (ru->fh_north_out) ru->fh_north_out(ru); + if(fh_two_thread == 0) + { + // wait until eNBs are finished subframe RX n and TX n+4 + wait_on_condition(&proc->mutex_eNBs,&proc->cond_eNBs,&proc->instance_cnt_eNBs,"ru_thread"); + + + // do TX front-end processing if needed (precoding and/or IDFTs) + if (ru->feptx_prec) ru->feptx_prec(ru); + + // do OFDM if needed + if ((ru->fh_north_asynch_in == NULL) && (ru->feptx_ofdm)) ru->feptx_ofdm(ru); + // do outgoing fronthaul (south) if needed + if ((ru->fh_north_asynch_in == NULL) && (ru->fh_south_out)) ru->fh_south_out(ru); + + if (ru->fh_north_out) ru->fh_north_out(ru); + } } @@ -1611,7 +1662,7 @@ void init_RU_proc(RU_t *ru) { int i=0; RU_proc_t *proc; - pthread_attr_t *attr_FH=NULL,*attr_prach=NULL,*attr_asynch=NULL,*attr_synch=NULL; + pthread_attr_t *attr_FH=NULL,*attr_FH1=NULL,*attr_prach=NULL,*attr_asynch=NULL,*attr_synch=NULL; //pthread_attr_t *attr_fep=NULL; #ifdef Rel14 pthread_attr_t *attr_prach_br=NULL; @@ -1626,9 +1677,11 @@ void init_RU_proc(RU_t *ru) { proc->ru = ru; proc->instance_cnt_prach = -1; - proc->instance_cnt_synch = -1; ; + proc->instance_cnt_synch = -1; proc->instance_cnt_FH = -1; + proc->instance_cnt_FH1 = -1; proc->instance_cnt_asynch_rxtx = -1; + proc->instance_cnt_eNBs = -1; proc->first_rx = 1; proc->first_tx = 1; proc->frame_offset = 0; @@ -1641,13 +1694,16 @@ void init_RU_proc(RU_t *ru) { pthread_mutex_init( &proc->mutex_asynch_rxtx, NULL); pthread_mutex_init( &proc->mutex_synch,NULL); pthread_mutex_init( &proc->mutex_FH,NULL); + pthread_mutex_init( &proc->mutex_FH1,NULL); pthread_cond_init( &proc->cond_prach, NULL); pthread_cond_init( &proc->cond_FH, NULL); + pthread_cond_init( &proc->cond_FH1, NULL); pthread_cond_init( &proc->cond_asynch_rxtx, NULL); pthread_cond_init( &proc->cond_synch,NULL); pthread_attr_init( &proc->attr_FH); + pthread_attr_init( &proc->attr_FH1); pthread_attr_init( &proc->attr_prach); pthread_attr_init( &proc->attr_synch); pthread_attr_init( &proc->attr_asynch_rxtx); @@ -1662,6 +1718,7 @@ void init_RU_proc(RU_t *ru) { #ifndef DEADLINE_SCHEDULER attr_FH = &proc->attr_FH; + attr_FH1 = &proc->attr_FH1; attr_prach = &proc->attr_prach; attr_synch = &proc->attr_synch; attr_asynch = &proc->attr_asynch_rxtx; @@ -1670,7 +1727,10 @@ void init_RU_proc(RU_t *ru) { #endif #endif - pthread_create( &proc->pthread_FH, attr_FH, ru_thread, (void*)ru ); + pthread_create( &proc->pthread_FH, attr_FH, ru_thread, (void*)ru );\ + + if (fh_two_thread==1) + pthread_create( &proc->pthread_FH1, attr_FH1, ru_thread_tx, (void*)ru ); if (ru->function == NGFI_RRU_IF4p5) { pthread_create( &proc->pthread_prach, attr_prach, ru_thread_prach, (void*)ru ); @@ -1682,7 +1742,10 @@ void init_RU_proc(RU_t *ru) { if ((ru->if_timing == synch_to_other) || (ru->function == NGFI_RRU_IF5) || - (ru->function == NGFI_RRU_IF4p5)) pthread_create( &proc->pthread_asynch_rxtx, attr_asynch, ru_thread_asynch_rxtx, (void*)ru ); + (ru->function == NGFI_RRU_IF4p5)) + { + pthread_create( &proc->pthread_asynch_rxtx, attr_asynch, ru_thread_asynch_rxtx, (void*)ru ); + } snprintf( name, sizeof(name), "ru_thread_FH %d", ru->idx ); pthread_setname_np( proc->pthread_FH, name ); @@ -1963,7 +2026,7 @@ void init_RU(char *rf_config_file) { } malloc_IF4p5_buffer(ru); } - else if (ru->function == eNodeB_3GPP) { + else if (ru->function == eNodeB_3GPP) { ru->do_prach = 0; // no prach processing in RU ru->feprx = (get_nprocs()<=4) ? fep_full : ru_fep_full_2thread; // RX DFTs ru->feptx_ofdm = (get_nprocs()<=4) ? feptx_ofdm : feptx_ofdm_2thread; // this is fep with idft and precoding diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index 98a68a2e10..17bd7631b7 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -171,7 +171,7 @@ static int tx_max_power[MAX_NUM_CCs]; /* = {0,0}*/; char rf_config_file[1024]; int chain_offset=0; -int phy_test = 0; +int phy_test = 1; uint8_t usim_test = 0; uint8_t dci_Format = 0; @@ -206,8 +206,8 @@ extern void reset_opp_meas(void); extern void print_opp_meas(void); int transmission_mode=1; - -int numerology = 1; +int numerology = 0; +int fh_two_thread = 1; @@ -746,6 +746,7 @@ void init_openair0() { int card; int i; + for (card=0; card Date: Fri, 27 Oct 2017 10:33:30 +0200 Subject: [PATCH 06/63] adding phy-test to config. fixing power allocation for phy-test. --- openair2/ENB_APP/enb_config.c | 3 +++ openair2/ENB_APP/enb_paramdef.h | 3 +++ openair2/LAYER2/MAC/eNB_scheduler.c | 3 +-- openair2/LAYER2/MAC/eNB_scheduler_phytest.c | 2 +- .../GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.usrpb210.conf | 1 + targets/RT/USER/lte-softmodem.c | 2 +- 6 files changed, 10 insertions(+), 4 deletions(-) diff --git a/openair2/ENB_APP/enb_config.c b/openair2/ENB_APP/enb_config.c index a02f365954..8e8483d606 100644 --- a/openair2/ENB_APP/enb_config.c +++ b/openair2/ENB_APP/enb_config.c @@ -314,6 +314,9 @@ void RCconfig_macrlc() { mac_top_init_eNB(); for (j=0;jphy_test = *(MacRLC_ParamList.paramarray[j][MACRLC_PHY_TEST_IDX].iptr); + printf("PHY_TEST = %d,%d\n", RC.mac[j]->phy_test, j); + if (strcmp(*(MacRLC_ParamList.paramarray[j][MACRLC_TRANSPORT_N_PREFERENCE_IDX].strptr), "local_RRC") == 0) { // check number of instances is same as RRC/PDCP diff --git a/openair2/ENB_APP/enb_paramdef.h b/openair2/ENB_APP/enb_paramdef.h index 6a03687fab..3fef026961 100755 --- a/openair2/ENB_APP/enb_paramdef.h +++ b/openair2/ENB_APP/enb_paramdef.h @@ -650,6 +650,7 @@ static int DEFENBS[] = {0}; #define CONFIG_STRING_MACRLC_REMOTE_S_PORTC "remote_s_portc" #define CONFIG_STRING_MACRLC_LOCAL_S_PORTD "local_s_portd" #define CONFIG_STRING_MACRLC_REMOTE_S_PORTD "remote_s_portd" +#define CONFIG_STRING_MACRLC_PHY_TEST_MODE "phy_test_mode" /*-------------------------------------------------------------------------------------------------------------------------------------------------------*/ @@ -674,6 +675,7 @@ static int DEFENBS[] = {0}; {CONFIG_STRING_MACRLC_REMOTE_S_PORTC, NULL, 0, uptr:NULL, defintval:50020, TYPE_UINT, 0}, \ {CONFIG_STRING_MACRLC_LOCAL_S_PORTD, NULL, 0, uptr:NULL, defintval:50021, TYPE_UINT, 0}, \ {CONFIG_STRING_MACRLC_REMOTE_S_PORTD, NULL, 0, uptr:NULL, defintval:50021, TYPE_UINT, 0}, \ +{CONFIG_STRING_MACRLC_PHY_TEST_MODE, NULL, 0, uptr:NULL, defintval:1, TYPE_UINT, 0} \ } #define MACRLC_CC_IDX 0 #define MACRLC_TRANSPORT_N_PREFERENCE_IDX 1 @@ -692,4 +694,5 @@ static int DEFENBS[] = {0}; #define MACRLC_REMOTE_S_PORTC_IDX 14 #define MACRLC_LOCAL_S_PORTD_IDX 15 #define MACRLC_REMOTE_S_PORTD_IDX 16 +#define MACRLC_PHY_TEST_IDX 17 /*---------------------------------------------------------------------------------------------------------------------------------------------------------*/ diff --git a/openair2/LAYER2/MAC/eNB_scheduler.c b/openair2/LAYER2/MAC/eNB_scheduler.c index 3c571718ca..172168bee3 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler.c +++ b/openair2/LAYER2/MAC/eNB_scheduler.c @@ -518,8 +518,7 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP, frame_t frameP, sub_frame #endif - - // This schedules MIB + // This schedules MIB if ((subframeP==0) && (frameP&3) == 0) schedule_mib(module_idP,frameP,subframeP); if (phy_test==0) { // This schedules SI for legacy LTE and eMTC starting in subframeP diff --git a/openair2/LAYER2/MAC/eNB_scheduler_phytest.c b/openair2/LAYER2/MAC/eNB_scheduler_phytest.c index e279edd0dd..342b6b6437 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_phytest.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_phytest.c @@ -168,7 +168,7 @@ schedule_ue_spec_phy_test( 1, // number of subbands // uint8_t codebook_index, 4, // UE category capacity - 0, /*UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->pdsch_ConfigDedicated->p_a,*/ + PDSCH_ConfigDedicated__p_a_dB0, 0, // delta_power_offset for TM5 0, // ngap 0, // nprb diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.usrpb210.conf index 2e7e56589c..5815a56d8e 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.usrpb210.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.usrpb210.conf @@ -164,6 +164,7 @@ MACRLCs = ( num_cc = 1; tr_s_preference = "local_L1"; tr_n_preference = "local_RRC"; + phy_test_mode = 1; } ); diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index 17bd7631b7..e21fd12428 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -171,7 +171,7 @@ static int tx_max_power[MAX_NUM_CCs]; /* = {0,0}*/; char rf_config_file[1024]; int chain_offset=0; -int phy_test = 1; +int phy_test = 0; uint8_t usim_test = 0; uint8_t dci_Format = 0; From ecee5edccee94ac502d39616e4243b4d9becae64 Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger Date: Fri, 27 Oct 2017 16:16:05 +0200 Subject: [PATCH 07/63] enabling new modulation --- openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c | 17 +++++++++-------- targets/RT/USER/eNB_usrp.gtkw | 16 +++++++--------- 2 files changed, 16 insertions(+), 17 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c b/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c index 46572c52d6..873e47ec76 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c @@ -39,6 +39,7 @@ #include "UTIL/LOG/vcd_signal_dumper.h" //#define DEBUG_DLSCH_MODULATION +#define NEW_ALLOC_RE //#define is_not_pilot(pilots,re,nushift,use2ndpilots) ((pilots==0) || ((re!=nushift) && (re!=nushift+6)&&((re!=nushift+3)||(use2ndpilots==1))&&((re!=nushift+9)||(use2ndpilots==1)))?1:0) @@ -2015,7 +2016,7 @@ int dlsch_modulation(PHY_VARS_eNB* phy_vars_eNB, int16_t qam16_table_a1[4],qam64_table_a1[8],qam16_table_b1[4],qam64_table_b1[8]; int16_t *qam_table_s0=NULL,*qam_table_s1=NULL; -#if 0 +#ifdef NEW_ALLOC_RE /* TODO: variable to be removed? */ int (*allocate_REs)(PHY_VARS_eNB*, int **, @@ -2257,7 +2258,7 @@ int dlsch_modulation(PHY_VARS_eNB* phy_vars_eNB, re_offset = frame_parms->first_carrier_offset; symbol_offset = (uint32_t)frame_parms->ofdm_symbol_size*(l+(subframe_offset*nsymb)); -#if 0 +#ifdef NEW_ALLOC_RE /* TODO: remove this code? */ allocate_REs = allocate_REs_in_RB; #endif @@ -2269,7 +2270,7 @@ int dlsch_modulation(PHY_VARS_eNB* phy_vars_eNB, case 4: if (pilots) { qam_table_s0 = qam16_table_b0; -#if 0 +#ifdef NEW_ALLOC_RE /* TODO: remove this code? */ allocate_REs = (dlsch0->harq_processes[harq_pid]->mimo_mode == SISO) ? allocate_REs_in_RB_pilots_16QAM_siso : @@ -2278,7 +2279,7 @@ int dlsch_modulation(PHY_VARS_eNB* phy_vars_eNB, } else { qam_table_s0 = qam16_table_a0; -#if 0 +#ifdef NEW_ALLOC_RE /* TODO: remove this code? */ allocate_REs = (dlsch0->harq_processes[harq_pid]->mimo_mode == SISO) ? allocate_REs_in_RB_no_pilots_16QAM_siso : @@ -2291,7 +2292,7 @@ int dlsch_modulation(PHY_VARS_eNB* phy_vars_eNB, case 6: if (pilots) { qam_table_s0 = qam64_table_b0; -#if 0 +#ifdef NEW_ALLOC_RE /* TODO: remove this code? */ allocate_REs = (dlsch0->harq_processes[harq_pid]->mimo_mode == SISO) ? allocate_REs_in_RB_pilots_64QAM_siso : @@ -2300,7 +2301,7 @@ int dlsch_modulation(PHY_VARS_eNB* phy_vars_eNB, } else { qam_table_s0 = qam64_table_a0; -#if 0 +#ifdef NEW_ALLOC_RE /* TODO: remove this code? */ allocate_REs = (dlsch0->harq_processes[harq_pid]->mimo_mode == SISO) ? allocate_REs_in_RB_no_pilots_64QAM_siso : @@ -2314,7 +2315,7 @@ int dlsch_modulation(PHY_VARS_eNB* phy_vars_eNB, switch (mod_order1) { case 2: qam_table_s1 = NULL; -#if 0 +#ifdef NEW_ALLOC_RE /* TODO: remove this code? */ allocate_REs = allocate_REs_in_RB; #endif @@ -2393,7 +2394,7 @@ int dlsch_modulation(PHY_VARS_eNB* phy_vars_eNB, rb); - allocate_REs_in_RB(phy_vars_eNB, + allocate_REs(phy_vars_eNB, txdataF, &jj, &jj2, diff --git a/targets/RT/USER/eNB_usrp.gtkw b/targets/RT/USER/eNB_usrp.gtkw index 2067468102..d64f7cbd38 100644 --- a/targets/RT/USER/eNB_usrp.gtkw +++ b/targets/RT/USER/eNB_usrp.gtkw @@ -1,15 +1,15 @@ [*] [*] GTKWave Analyzer v3.3.58 (w)1999-2014 BSI -[*] Tue Oct 24 08:41:51 2017 +[*] Fri Oct 27 14:01:34 2017 [*] [dumpfile] "/tmp/openair_dump_eNB.vcd" -[dumpfile_mtime] "Tue Oct 24 08:27:56 2017" -[dumpfile_size] 4053651 -[savefile] "/homes/wangts/openairinterface5g/targets/RT/USER/eNB_usrp.gtkw" +[dumpfile_mtime] "Fri Oct 27 11:38:57 2017" +[dumpfile_size] 13854600 +[savefile] "/homes/kaltenbe/Devel/openair/openairinterface5g/targets/RT/USER/eNB_usrp.gtkw" [timestart] 15494750000 [size] 1855 1056 -[pos] 65 -10 -*-19.872988 15497443000 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 +[pos] 65 0 +*-19.872988 15495913242 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 [sst_width] 386 [signals_width] 302 [sst_expanded] 1 @@ -32,15 +32,13 @@ functions.mac_schedule_dlsch functions.macxface_eNB_dlsch_ulsch_scheduler functions.macxface_ue_scheduler functions.phy_eNB_ofdm_mod_l +functions.phy_eNB_dlsch_encoding functions.phy_eNB_dlsch_scrambling functions.phy_eNB_dlsch_modulation -functions.phy_eNB_dlsch_scrambling functions.phy_eNB_beam_precoding functions.phy_enb_pdcch_tx functions.phy_enb_prach_rx -@29 functions.phy_procedures_ru_feprx0 -@28 functions.phy_procedures_eNb_rx_uespec0 functions.phy_procedures_eNb_rx_uespec1 functions.phy_enb_sfgen From c84ddacd0003690eaf1af8943f62b1eac1a61250 Mon Sep 17 00:00:00 2001 From: Wang Tsu-Han Date: Thu, 2 Nov 2017 16:02:52 +0100 Subject: [PATCH 08/63] Seperate Front haul RX TX and process into three threads --- openair1/PHY/LTE_TRANSPORT/dci.c | 4 +- openair1/PHY/LTE_TRANSPORT/dlsch_coding.c | 4 +- openair1/PHY/defs.h | 2 + openair1/SCHED/phy_procedures_lte_eNb.c | 3 +- openair1/SCHED/ru_procedures.c | 9 +++- targets/RT/USER/eNB_usrp.gtkw | 19 +++++--- targets/RT/USER/lte-enb.c | 53 +++++++++++++++++------ targets/RT/USER/lte-ru.c | 10 +++-- 8 files changed, 73 insertions(+), 31 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/dci.c b/openair1/PHY/LTE_TRANSPORT/dci.c index b06f69181f..ef3e2cb679 100755 --- a/openair1/PHY/LTE_TRANSPORT/dci.c +++ b/openair1/PHY/LTE_TRANSPORT/dci.c @@ -2260,8 +2260,8 @@ uint8_t generate_dci_top(uint8_t num_pdcch_symbols, // reset all bits to , here we set elements as 2 // memset(e, 2, DCI_BITS_MAX); // here we interpret NIL as a random QPSK sequence. That makes power estimation easier. - for (i=0; iharq_processes[harq_pid]->Qm; G = get_G(frame_parms,nb_rb,dlsch->harq_processes[harq_pid]->rb_alloc,mod_order,dlsch->harq_processes[harq_pid]->Nl,num_pdcch_symbols,frame,subframe,dlsch->harq_processes[harq_pid]->mimo_mode==TM7?7:0); - if (dlsch->harq_processes[harq_pid]->round == 0) { // this is a new packet // Add 24-bit crc (polynomial A) to payload @@ -441,7 +440,6 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB, return(-1); } - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ENCODING, VCD_FUNCTION_OUT); ++proc->instance_cnt_te; proc->tep.eNB = eNB; @@ -458,7 +456,6 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB, pthread_mutex_unlock( &proc->mutex_te ); - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ENCODING, VCD_FUNCTION_IN); for (r=dlsch->harq_processes[harq_pid]->C>>1; rharq_processes[harq_pid]->C; r++) { if (rharq_processes[harq_pid]->Cminus) @@ -590,6 +587,7 @@ int dlsch_encoding_all(PHY_VARS_eNB *eNB, C = C+1; } } + if(C >= 5) { encoding_return = diff --git a/openair1/PHY/defs.h b/openair1/PHY/defs.h index f1a38aedef..7e4933f26b 100644 --- a/openair1/PHY/defs.h +++ b/openair1/PHY/defs.h @@ -564,6 +564,8 @@ typedef struct eNB_proc_t_s { eNB_rxtx_proc_t proc_rxtx[2]; /// stats thread pthread descriptor pthread_t coding_stats_thread; + /// for waking up tx procedure + RU_proc_t *ru_proc; } eNB_proc_t; diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index 7840dc3534..3e3326c4c5 100644 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -336,6 +336,7 @@ void pdsch_procedures(PHY_VARS_eNB *eNB, // 36-212 start_meas(&eNB->dlsch_encoding_stats); AssertFatal(dlsch_harq->pdu!=NULL,"dlsch_harq->pdu == NULL (rnti %x)\n",dlsch->rnti); + eNB->te(eNB, dlsch_harq->pdu, dlsch_harq->pdsch_start, @@ -486,7 +487,7 @@ void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB, LOG_D(PHY,"[eNB %"PRIu8"] Frame %d, subframe %d: Calling generate_dci_top (pdcch) (num_dci %"PRIu8")\n",eNB->Mod_id,frame, subframe, num_dci); - + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_PDCCH_TX,1); generate_dci_top(num_pdcch_symbols, num_dci, &eNB->pdcch_vars[subframe&1].dci_alloc[0], diff --git a/openair1/SCHED/ru_procedures.c b/openair1/SCHED/ru_procedures.c index 7e0ca4e76a..e927fcdbc2 100644 --- a/openair1/SCHED/ru_procedures.c +++ b/openair1/SCHED/ru_procedures.c @@ -170,7 +170,7 @@ void feptx_ofdm_2thread(RU_t *ru) { wait.tv_sec=0; wait.tv_nsec=5000000L; - + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPTX_OFDM , 1 ); start_meas(&ru->ofdm_mod_stats); if (subframe_select(fp,subframe) == SF_UL) return; @@ -207,6 +207,7 @@ void feptx_ofdm_2thread(RU_t *ru) { wait_on_busy_condition(&proc->mutex_feptx,&proc->cond_feptx,&proc->instance_cnt_feptx,"feptx thread"); stop_meas(&ru->ofdm_mod_stats); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPTX_OFDM , 0 ); } @@ -419,8 +420,10 @@ static void *fep_thread(void *param) { while (!oai_exit) { - if (wait_on_condition(&proc->mutex_fep,&proc->cond_fep,&proc->instance_cnt_fep,"fep thread")<0) break; + if (wait_on_condition(&proc->mutex_fep,&proc->cond_fep,&proc->instance_cnt_fep,"fep thread")<0) break; + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPRX1, 1 ); fep0(ru,0); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPRX1, 0 ); if (release_thread(&proc->mutex_fep,&proc->instance_cnt_fep,"fep thread")<0) break; if (pthread_cond_signal(&proc->cond_fep) != 0) { @@ -471,6 +474,7 @@ void ru_fep_full_2thread(RU_t *ru) { wait.tv_sec=0; wait.tv_nsec=5000000L; + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPRX, 1 ); start_meas(&ru->ofdm_demod_stats); if (pthread_mutex_timedlock(&proc->mutex_fep,&wait) != 0) { @@ -503,6 +507,7 @@ void ru_fep_full_2thread(RU_t *ru) { wait_on_busy_condition(&proc->mutex_fep,&proc->cond_fep,&proc->instance_cnt_fep,"fep thread"); stop_meas(&ru->ofdm_demod_stats); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPRX, 0 ); } diff --git a/targets/RT/USER/eNB_usrp.gtkw b/targets/RT/USER/eNB_usrp.gtkw index d64f7cbd38..59a8a460ee 100644 --- a/targets/RT/USER/eNB_usrp.gtkw +++ b/targets/RT/USER/eNB_usrp.gtkw @@ -1,15 +1,15 @@ [*] [*] GTKWave Analyzer v3.3.58 (w)1999-2014 BSI -[*] Fri Oct 27 14:01:34 2017 +[*] Thu Nov 2 14:19:21 2017 [*] [dumpfile] "/tmp/openair_dump_eNB.vcd" -[dumpfile_mtime] "Fri Oct 27 11:38:57 2017" -[dumpfile_size] 13854600 -[savefile] "/homes/kaltenbe/Devel/openair/openairinterface5g/targets/RT/USER/eNB_usrp.gtkw" -[timestart] 15494750000 +[dumpfile_mtime] "Thu Nov 2 14:15:28 2017" +[dumpfile_size] 1636821 +[savefile] "/homes/wangts/openairinterface5g/targets/RT/USER/eNB_usrp.gtkw" +[timestart] 14181427000 [size] 1855 1056 [pos] 65 0 -*-19.872988 15495913242 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 +*-19.872988 15497443000 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 [sst_width] 386 [signals_width] 302 [sst_expanded] 1 @@ -32,9 +32,14 @@ functions.mac_schedule_dlsch functions.macxface_eNB_dlsch_ulsch_scheduler functions.macxface_ue_scheduler functions.phy_eNB_ofdm_mod_l +@24 +variables.frame_number_RX0_eNB[63:0] +@25 +variables.frame_number_TX0_eNB[63:0] +@28 +functions.phy_eNB_dlsch_modulation functions.phy_eNB_dlsch_encoding functions.phy_eNB_dlsch_scrambling -functions.phy_eNB_dlsch_modulation functions.phy_eNB_beam_precoding functions.phy_enb_pdcch_tx functions.phy_enb_prach_rx diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 7402b330be..4a35a817fb 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -170,6 +170,8 @@ static inline int rxtx(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, char *thread_nam // UE-specific RX processing for subframe n phy_procedures_eNB_uespec_RX(eNB, proc, no_relay ); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER , 1 ); + pthread_mutex_lock(&eNB->UL_INFO_mutex); eNB->UL_INFO.frame = proc->frame_rx; eNB->UL_INFO.subframe = proc->subframe_rx; @@ -177,6 +179,9 @@ static inline int rxtx(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, char *thread_nam eNB->UL_INFO.CC_id = eNB->CC_id; eNB->if_inst->UL_indication(&eNB->UL_INFO); pthread_mutex_unlock(&eNB->UL_INFO_mutex); + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER , 0 ); + // ***************************************** // TX processing for subframe n+4 // run PHY TX procedures the one after the other for all CCs to avoid race conditions @@ -207,9 +212,10 @@ static inline int rxtx(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, char *thread_nam static void* eNB_thread_rxtx( void* param ) { static int eNB_thread_rxtx_status; - - eNB_rxtx_proc_t *proc = (eNB_rxtx_proc_t*)param; + eNB_proc_t *eNB_proc = (eNB_proc_t*)param; + eNB_rxtx_proc_t *proc = &eNB_proc->proc_rxtx[0]; PHY_VARS_eNB *eNB = RC.eNB[0][proc->CC_id]; + //RU_proc_t *ru_proc = NULL; char thread_name[100]; @@ -227,14 +233,24 @@ static void* eNB_thread_rxtx( void* param ) { if (wait_on_condition(&proc->mutex_rxtx,&proc->cond_rxtx,&proc->instance_cnt_rxtx,thread_name)<0) break; VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_eNB_PROC_RXTX0+(proc->subframe_rx&1), 1 ); - - + //ru_proc = eNB_proc->ru_proc; + + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_TX0_ENB,proc->subframe_tx); + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_RX0_ENB,proc->subframe_rx); + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX0_ENB,proc->frame_tx); + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_RX0_ENB,proc->frame_rx); + if (oai_exit) break; if (eNB->CC_id==0) if (rxtx(eNB,proc,thread_name) < 0) break; - + pthread_mutex_lock(&eNB_proc->ru_proc->mutex_eNBs); + //printf("//////////////////////////////ru_proc->instance_cnt_eNBs == %d \n",ru_proc->instance_cnt_eNBs);////////////////////////********* + ++eNB_proc->ru_proc->instance_cnt_eNBs; + pthread_cond_signal(&eNB_proc->ru_proc->cond_eNBs); + pthread_mutex_unlock(&eNB_proc->ru_proc->mutex_eNBs); + //release_thread(&proc->mutex_rxtx,&proc->instance_cnt_rxtx,thread_name); } // while !oai_exit VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_eNB_PROC_RXTX0+(proc->subframe_rx&1), 0 ); @@ -294,11 +310,10 @@ void eNB_top(PHY_VARS_eNB *eNB, int frame_rx, int subframe_rx, char *string,RU_t if (rxtx(eNB,proc_rxtx,string) < 0) LOG_E(PHY,"eNB %d CC_id %d failed during execution\n",eNB->Mod_id,eNB->CC_id); LOG_D(PHY,"eNB_top out %p (proc %p, CC_id %d), frame %d, subframe %d, instance_cnt_prach %d\n", (void*)pthread_self(), proc, eNB->CC_id, proc->frame_rx,proc->subframe_rx,proc->instance_cnt_prach); - - pthread_mutex_lock(&ru_proc->mutex_eNBs); - ++ru_proc->instance_cnt_eNBs; - pthread_mutex_unlock(&ru_proc->mutex_eNBs); - pthread_cond_signal(&ru_proc->cond_eNBs); + pthread_mutex_lock(&ru_proc->mutex_eNBs); + ++ru_proc->instance_cnt_eNBs; + pthread_mutex_unlock(&ru_proc->mutex_eNBs); + pthread_cond_signal(&ru_proc->cond_eNBs); } } @@ -306,8 +321,10 @@ void eNB_top(PHY_VARS_eNB *eNB, int frame_rx, int subframe_rx, char *string,RU_t int wakeup_rxtx(PHY_VARS_eNB *eNB,RU_t *ru) { eNB_proc_t *proc=&eNB->proc; + RU_proc_t *ru_proc=&ru->proc; - eNB_rxtx_proc_t *proc_rxtx=&proc->proc_rxtx[proc->frame_rx&1]; + eNB_rxtx_proc_t *proc_rxtx=&proc->proc_rxtx[0];//*proc_rxtx=&proc->proc_rxtx[proc->frame_rx&1]; + proc->ru_proc = &ru->proc; LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms; @@ -364,11 +381,20 @@ int wakeup_rxtx(PHY_VARS_eNB *eNB,RU_t *ru) { // The last (TS_rx mod samples_per_frame) was n*samples_per_tti, // we want to generate subframe (n+4), so TS_tx = TX_rx+4*samples_per_tti, // and proc->subframe_tx = proc->subframe_rx+4 - proc_rxtx->timestamp_tx = proc->timestamp_rx + (4*fp->samples_per_tti); + /*proc_rxtx->timestamp_tx = proc->timestamp_rx + (4*fp->samples_per_tti); proc_rxtx->frame_rx = proc->frame_rx; proc_rxtx->subframe_rx = proc->subframe_rx; proc_rxtx->frame_tx = (proc_rxtx->subframe_rx > 5) ? (proc_rxtx->frame_rx+1)&1023 : proc_rxtx->frame_rx; proc_rxtx->subframe_tx = (proc_rxtx->subframe_rx + 4)%10; + */ + + proc_rxtx->subframe_rx = ru_proc->subframe_rx; + proc_rxtx->frame_rx = ru_proc->frame_rx; + proc_rxtx->subframe_tx = (ru_proc->subframe_rx+4)%10; + proc_rxtx->frame_tx = (ru_proc->subframe_rx>5) ? (1+ru_proc->frame_rx)&1023 : ru_proc->frame_rx; + proc->frame_tx = proc_rxtx->frame_tx; + proc->frame_rx = proc_rxtx->frame_rx; + proc_rxtx->timestamp_tx = ru_proc->timestamp_tx; // the thread can now be woken up if (pthread_cond_signal(&proc_rxtx->cond_rxtx) != 0) { @@ -612,7 +638,7 @@ void init_eNB_proc(int inst) { PHY_VARS_eNB *eNB; eNB_proc_t *proc; eNB_rxtx_proc_t *proc_rxtx; - pthread_attr_t *attr0=NULL,*attr1=NULL,*attr_prach=NULL,*attr_td=NULL,*attr_te=NULL; + pthread_attr_t *attr0=NULL,*attr1=NULL,*attr_prach=NULL,*attr_te=NULL,*attr_td=NULL; #ifdef Rel14 pthread_attr_t *attr_prach_br=NULL; #endif @@ -677,6 +703,7 @@ void init_eNB_proc(int inst) { #endif attr_td = &proc->attr_td; attr_te = &proc->attr_te; + pthread_create( &proc_rxtx[0].pthread_rxtx, attr0, eNB_thread_rxtx, proc ); if (eNB->single_thread_flag==0) { pthread_create( &proc_rxtx[0].pthread_rxtx, attr0, eNB_thread_rxtx, &proc_rxtx[0] ); pthread_create( &proc_rxtx[1].pthread_rxtx, attr1, eNB_thread_rxtx, &proc_rxtx[1] ); diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index fcd44834c8..1dc3a8780c 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -900,6 +900,7 @@ void wakeup_slaves(RU_proc_t *proc) { wait.tv_nsec=5000000L; for (i=0;inum_slaves;i++) { + //printf("////////////////////calling for slave thrads\n");////////////////////////******** RU_proc_t *slave_proc = proc->slave_proc[i]; // wake up slave FH thread // lock the FH mutex and make sure the thread is ready @@ -1116,9 +1117,9 @@ void wakeup_eNBs(RU_t *ru) { LOG_D(PHY,"wakeup_eNBs (num %d) for RU %d\n",ru->num_eNB,ru->idx); - if (ru->num_eNB==1) { + if (0){//(ru->num_eNB==1) { // call eNB function directly - + char string[20]; sprintf(string,"Incoming RU %d",ru->idx); LOG_D(PHY,"RU %d Waking up eNB\n",ru->idx); @@ -1127,8 +1128,10 @@ void wakeup_eNBs(RU_t *ru) { else { for (i=0;inum_eNB;i++) + { if (ru->wakeup_rxtx(eNB_list[i],ru) < 0) - LOG_E(PHY,"could not wakeup eNB rxtx process for subframe %d\n", ru->proc.subframe_rx); + LOG_E(PHY,"could not wakeup eNB rxtx process for subframe %d\n", ru->proc.subframe_rx); + } } } @@ -1384,6 +1387,7 @@ static void* ru_thread_tx( void* param ) { LOG_D(PHY,"ru_thread_tx: Waiting for TX processing\n"); // wait until eNBs are finished subframe RX n and TX n+4 wait_on_condition(&proc->mutex_eNBs,&proc->cond_eNBs,&proc->instance_cnt_eNBs,"ru_thread"); + //printf("//////////////////instance_cnt_eNBs = %d\n",proc->instance_cnt_eNBs);//////////////////********* // do TX front-end processing if needed (precoding and/or IDFTs) From caef8c6e568f585d3a8b453a89a47addc50dfc52 Mon Sep 17 00:00:00 2001 From: Wang Tsu-Han Date: Fri, 3 Nov 2017 12:27:39 +0100 Subject: [PATCH 09/63] fixing the sleep delay problem for tx --- openair1/PHY/LTE_TRANSPORT/dlsch_coding.c | 6 +++++ openair1/SCHED/ru_procedures.c | 11 +++++++++ openair2/UTIL/LOG/vcd_signal_dumper.c | 3 +++ openair2/UTIL/LOG/vcd_signal_dumper.h | 3 +++ targets/RT/USER/lte-enb.c | 13 ++++++---- targets/RT/USER/lte-ru.c | 30 +++++++++++++++++------ targets/RT/USER/lte-softmodem.c | 2 +- 7 files changed, 55 insertions(+), 13 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c index 9b5a898aac..e407f2c4bf 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c @@ -354,9 +354,15 @@ int dlsch_encoding_2threads0(te_params *tep) { extern int oai_exit; void *te_thread(void *param) { + cpu_set_t cpuset; + CPU_ZERO(&cpuset); + pthread_setname_np( pthread_self(),"te processing"); LOG_I(PHY,"thread te created id=%ld", syscall(__NR_gettid)); + CPU_SET(4, &cpuset); + pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); + eNB_proc_t *proc = &((te_params *)param)->eNB->proc; while (!oai_exit) { diff --git a/openair1/SCHED/ru_procedures.c b/openair1/SCHED/ru_procedures.c index e927fcdbc2..f60f066ef5 100644 --- a/openair1/SCHED/ru_procedures.c +++ b/openair1/SCHED/ru_procedures.c @@ -140,6 +140,12 @@ static void *feptx_thread(void *param) { RU_t *ru = (RU_t *)param; RU_proc_t *proc = &ru->proc; + cpu_set_t cpuset; + CPU_ZERO(&cpuset); + + CPU_SET(6, &cpuset); + pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); + thread_top_init("feptx_thread",0,870000,1000000,1000000); @@ -418,6 +424,11 @@ static void *fep_thread(void *param) { thread_top_init("fep_thread",0,870000,1000000,1000000); + cpu_set_t cpuset; + CPU_ZERO(&cpuset); + CPU_SET(2, &cpuset); + pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); + while (!oai_exit) { if (wait_on_condition(&proc->mutex_fep,&proc->cond_fep,&proc->instance_cnt_fep,"fep thread")<0) break; diff --git a/openair2/UTIL/LOG/vcd_signal_dumper.c b/openair2/UTIL/LOG/vcd_signal_dumper.c index 665e5b4384..dfd48c77f7 100644 --- a/openair2/UTIL/LOG/vcd_signal_dumper.c +++ b/openair2/UTIL/LOG/vcd_signal_dumper.c @@ -195,6 +195,9 @@ const char* eurecomVariablesNames[] = { "ue0_trx_write_ns", "ue0_trx_read_ns_missing", "ue0_trx_write_ns_missing", + "enb_thread_rxtx_CPUID", + "ru_thread_CPUID", + "ru_thread_tx_CPUID" }; const char* eurecomFunctionsNames[] = { diff --git a/openair2/UTIL/LOG/vcd_signal_dumper.h b/openair2/UTIL/LOG/vcd_signal_dumper.h index d777236b34..e13ee7cfdc 100644 --- a/openair2/UTIL/LOG/vcd_signal_dumper.h +++ b/openair2/UTIL/LOG/vcd_signal_dumper.h @@ -167,6 +167,9 @@ typedef enum { VCD_SIGNAL_DUMPER_VARIABLES_UE0_TRX_WRITE_NS, VCD_SIGNAL_DUMPER_VARIABLES_UE0_TRX_READ_NS_MISSING, VCD_SIGNAL_DUMPER_VARIABLES_UE0_TRX_WRITE_NS_MISSING, + VCD_SIGNAL_DUMPER_VARIABLES_CPUID_ENB_THREAD_RXTX, + VCD_SIGNAL_DUMPER_VARIABLES_CPUID_RU_THREAD, + VCD_SIGNAL_DUMPER_VARIABLES_CPUID_RU_THREAD_TX, VCD_SIGNAL_DUMPER_VARIABLES_END } vcd_signal_dump_variables; diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 4a35a817fb..90a096285e 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -219,6 +219,8 @@ static void* eNB_thread_rxtx( void* param ) { char thread_name[100]; + cpu_set_t cpuset; + CPU_ZERO(&cpuset); // set default return value eNB_thread_rxtx_status = 0; @@ -227,11 +229,15 @@ static void* eNB_thread_rxtx( void* param ) { sprintf(thread_name,"RXn_TXnp4_%d\n",&eNB->proc.proc_rxtx[0] == proc ? 0 : 1); thread_top_init(thread_name,1,850000L,1000000L,2000000L); + CPU_SET(3, &cpuset); + pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); + while (!oai_exit) { VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_eNB_PROC_RXTX0+(proc->subframe_rx&1), 0 ); if (wait_on_condition(&proc->mutex_rxtx,&proc->cond_rxtx,&proc->instance_cnt_rxtx,thread_name)<0) break; + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_CPUID_ENB_THREAD_RXTX,sched_getcpu()); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_eNB_PROC_RXTX0+(proc->subframe_rx&1), 1 ); //ru_proc = eNB_proc->ru_proc; @@ -356,12 +362,9 @@ int wakeup_rxtx(PHY_VARS_eNB *eNB,RU_t *ru) { wait.tv_nsec=5000000L; /* accept some delay in processing - up to 5ms */ - for (i = 0; i < 10 && proc_rxtx->instance_cnt_rxtx == 0; i++) { - LOG_W( PHY,"[eNB] Frame %d, eNB RXn-TXnp4 thread busy!! (cnt_rxtx %i)\n", proc_rxtx->frame_tx, proc_rxtx->instance_cnt_rxtx); - usleep(500); - } + if (proc_rxtx->instance_cnt_rxtx == 0) { - exit_fun( "TX thread busy" ); + LOG_E(PHY,"Frame %d, subframe %d: RXTX thread busy, dropping",proc_rxtx->frame_rx,proc_rxtx->subframe_rx); return(-1); } diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index 1dc3a8780c..a106012815 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -1126,12 +1126,12 @@ void wakeup_eNBs(RU_t *ru) { ru->eNB_top(eNB_list[0],ru->proc.frame_rx,ru->proc.subframe_rx,string,ru); } else { - + for (i=0;inum_eNB;i++) - { - if (ru->wakeup_rxtx(eNB_list[i],ru) < 0) - LOG_E(PHY,"could not wakeup eNB rxtx process for subframe %d\n", ru->proc.subframe_rx); - } + { + if (ru->wakeup_rxtx(eNB_list[i],ru) < 0) + LOG_E(PHY,"could not wakeup eNB rxtx process for subframe %d\n", ru->proc.subframe_rx); + } } } @@ -1367,14 +1367,21 @@ static void* ru_thread_tx( void* param ) { RU_t *ru = (RU_t*)param; RU_proc_t *proc = &ru->proc; int subframe=0, frame=0; + cpu_set_t cpuset; + CPU_ZERO(&cpuset); + thread_top_init("ru_thread_tx",1,870000L,1000000L,1000000L); + CPU_SET(5, &cpuset); + pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); + wait_on_condition(&proc->mutex_FH1,&proc->cond_FH1,&proc->instance_cnt_FH1,"ru_thread_tx"); printf( "ru_thread_tx ready\n"); while (!oai_exit) { - + + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_CPUID_RU_THREAD_TX,sched_getcpu()); if (oai_exit) break; if (subframe==9) { @@ -1416,6 +1423,9 @@ static void* ru_thread( void* param ) { int ret; int subframe =9; int frame =1023; + cpu_set_t cpuset; + CPU_ZERO(&cpuset); + // set default return value ru_thread_status = 0; @@ -1424,6 +1434,9 @@ static void* ru_thread( void* param ) { // set default return value thread_top_init("ru_thread",0,870000,1000000,1000000); + CPU_SET(1, &cpuset); + pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); + LOG_I(PHY,"Starting RU %d (%s,%s),\n",ru->idx,eNB_functions[ru->function],eNB_timing[ru->if_timing]); @@ -1491,6 +1504,8 @@ static void* ru_thread( void* param ) { // This is a forever while loop, it loops over subframes which are scheduled by incoming samples from HW devices while (!oai_exit) { + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_CPUID_RU_THREAD,sched_getcpu()); + // these are local subframe/frame counters to check that we are in synch with the fronthaul timing. // They are set on the first rx/tx in the underly FH routines. if (subframe==9) { @@ -1537,6 +1552,7 @@ static void* ru_thread( void* param ) { // wakeup all eNB processes waiting for this RU if (ru->num_eNB>0) wakeup_eNBs(ru); + /* if(fh_two_thread == 0) { // wait until eNBs are finished subframe RX n and TX n+4 @@ -1553,7 +1569,7 @@ static void* ru_thread( void* param ) { if (ru->fh_north_out) ru->fh_north_out(ru); } - + */ } diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index e21fd12428..b126e70a25 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -206,7 +206,7 @@ extern void reset_opp_meas(void); extern void print_opp_meas(void); int transmission_mode=1; -int numerology = 0; +int numerology = 1; int fh_two_thread = 1; From c8420152de93c1f59862b33c66b0790318f65a83 Mon Sep 17 00:00:00 2001 From: Wang Tsu-Han Date: Fri, 3 Nov 2017 14:57:45 +0100 Subject: [PATCH 10/63] seperate processing thread into RX thread and TX thread --- targets/RT/USER/lte-enb.c | 105 +++++++++++++++++++++++++++++--------- 1 file changed, 82 insertions(+), 23 deletions(-) diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 90a096285e..6ac889791f 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -145,7 +145,7 @@ void exit_fun(const char* s); void init_eNB(int,int); void stop_eNB(int nb_inst); - +int wakeup_tx(PHY_VARS_eNB *eNB,RU_proc_t *ru_proc); void wakeup_prach_eNB(PHY_VARS_eNB *eNB,RU_t *ru,int frame,int subframe); #ifdef Rel14 void wakeup_prach_eNB_br(PHY_VARS_eNB *eNB,RU_t *ru,int frame,int subframe); @@ -169,9 +169,9 @@ static inline int rxtx(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, char *thread_nam } // UE-specific RX processing for subframe n phy_procedures_eNB_uespec_RX(eNB, proc, no_relay ); - + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER , 1 ); - + pthread_mutex_lock(&eNB->UL_INFO_mutex); eNB->UL_INFO.frame = proc->frame_rx; eNB->UL_INFO.subframe = proc->subframe_rx; @@ -179,23 +179,12 @@ static inline int rxtx(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, char *thread_nam eNB->UL_INFO.CC_id = eNB->CC_id; eNB->if_inst->UL_indication(&eNB->UL_INFO); pthread_mutex_unlock(&eNB->UL_INFO_mutex); - + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER , 0 ); - - // ***************************************** - // TX processing for subframe n+4 - // run PHY TX procedures the one after the other for all CCs to avoid race conditions - // (may be relaxed in the future for performance reasons) - // ***************************************** - //if (wait_CCs(proc)<0) return(-1); - - - - if (oai_exit) return(-1); - - phy_procedures_eNB_TX(eNB, proc, no_relay, NULL, 1); if (release_thread(&proc->mutex_rxtx,&proc->instance_cnt_rxtx,thread_name)<0) return(-1); + + wakeup_tx(eNB,eNB->proc.ru_proc); stop_meas( &softmodem_stats_rxtx_sf ); @@ -203,6 +192,41 @@ static inline int rxtx(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, char *thread_nam } +static void* tx_thread(void* param) { + + eNB_proc_t *eNB_proc = (eNB_proc_t*)param; + eNB_rxtx_proc_t *proc = &eNB_proc->proc_rxtx[1]; + PHY_VARS_eNB *eNB = RC.eNB[0][proc->CC_id]; + + char thread_name[100]; + sprintf(thread_name,"RXn_TXnp4_%d\n",&eNB->proc.proc_rxtx[0] == proc ? 0 : 1); + thread_top_init(thread_name,1,850000L,1000000L,2000000L); + + while (!oai_exit) { + + if (wait_on_condition(&proc->mutex_rxtx,&proc->cond_rxtx,&proc->instance_cnt_rxtx,thread_name)<0) break; + if (oai_exit) break; + // ***************************************** + // TX processing for subframe n+4 + // run PHY TX procedures the one after the other for all CCs to avoid race conditions + // (may be relaxed in the future for performance reasons) + // ***************************************** + //if (wait_CCs(proc)<0) return(-1); + + + phy_procedures_eNB_TX(eNB, proc, no_relay, NULL, 1); + if (release_thread(&proc->mutex_rxtx,&proc->instance_cnt_rxtx,thread_name)<0) break; + + + pthread_mutex_lock(&eNB_proc->ru_proc->mutex_eNBs); + ++eNB_proc->ru_proc->instance_cnt_eNBs; + pthread_cond_signal(&eNB_proc->ru_proc->cond_eNBs); + pthread_mutex_unlock(&eNB_proc->ru_proc->mutex_eNBs); + } + + return 0; +} + /*! * \brief The RX UE-specific and TX thread of eNB. * \param param is a \ref eNB_proc_t structure which contains the info what to process. @@ -251,12 +275,6 @@ static void* eNB_thread_rxtx( void* param ) { if (eNB->CC_id==0) if (rxtx(eNB,proc,thread_name) < 0) break; - pthread_mutex_lock(&eNB_proc->ru_proc->mutex_eNBs); - //printf("//////////////////////////////ru_proc->instance_cnt_eNBs == %d \n",ru_proc->instance_cnt_eNBs);////////////////////////********* - ++eNB_proc->ru_proc->instance_cnt_eNBs; - pthread_cond_signal(&eNB_proc->ru_proc->cond_eNBs); - pthread_mutex_unlock(&eNB_proc->ru_proc->mutex_eNBs); - //release_thread(&proc->mutex_rxtx,&proc->instance_cnt_rxtx,thread_name); } // while !oai_exit VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_eNB_PROC_RXTX0+(proc->subframe_rx&1), 0 ); @@ -323,6 +341,46 @@ void eNB_top(PHY_VARS_eNB *eNB, int frame_rx, int subframe_rx, char *string,RU_t } } +int wakeup_tx(PHY_VARS_eNB *eNB,RU_proc_t *ru_proc) { + + eNB_proc_t *proc=&eNB->proc; + + eNB_rxtx_proc_t *proc_rxtx=&proc->proc_rxtx[1];//*proc_rxtx=&proc->proc_rxtx[proc->frame_rx&1]; + + LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms; + + struct timespec wait; + wait.tv_sec=0; + wait.tv_nsec=5000000L; + + if (pthread_mutex_timedlock(&proc_rxtx->mutex_rxtx,&wait) != 0) { + LOG_E( PHY, "[eNB] ERROR pthread_mutex_lock for eNB RXTX thread %d (IC %d)\n", proc_rxtx->subframe_rx&1,proc_rxtx->instance_cnt_rxtx ); + exit_fun( "error locking mutex_rxtx" ); + return(-1); + } + + ++proc_rxtx->instance_cnt_rxtx; + + + proc_rxtx->subframe_rx = ru_proc->subframe_rx; + proc_rxtx->frame_rx = ru_proc->frame_rx; + proc_rxtx->subframe_tx = (ru_proc->subframe_rx+4)%10; + proc_rxtx->frame_tx = (ru_proc->subframe_rx>5) ? (1+ru_proc->frame_rx)&1023 : ru_proc->frame_rx; + proc->frame_tx = proc_rxtx->frame_tx; + proc->frame_rx = proc_rxtx->frame_rx; + proc_rxtx->timestamp_tx = ru_proc->timestamp_tx; + + // the thread can now be woken up + if (pthread_cond_signal(&proc_rxtx->cond_rxtx) != 0) { + LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB RXn-TXnp4 thread\n"); + exit_fun( "ERROR pthread_cond_signal" ); + return(-1); + } + + pthread_mutex_unlock( &proc_rxtx->mutex_rxtx ); + + return(0); +} int wakeup_rxtx(PHY_VARS_eNB *eNB,RU_t *ru) { @@ -707,6 +765,7 @@ void init_eNB_proc(int inst) { attr_td = &proc->attr_td; attr_te = &proc->attr_te; pthread_create( &proc_rxtx[0].pthread_rxtx, attr0, eNB_thread_rxtx, proc ); + pthread_create( &proc_rxtx[1].pthread_rxtx, attr1, tx_thread, proc); if (eNB->single_thread_flag==0) { pthread_create( &proc_rxtx[0].pthread_rxtx, attr0, eNB_thread_rxtx, &proc_rxtx[0] ); pthread_create( &proc_rxtx[1].pthread_rxtx, attr1, eNB_thread_rxtx, &proc_rxtx[1] ); From 8d5dc07a150a113602852073d3a3b6e4146d625b Mon Sep 17 00:00:00 2001 From: "Wolfgang A. Mozart" Date: Fri, 10 Nov 2017 09:04:10 +0100 Subject: [PATCH 11/63] making noS1 mode compile --- cmake_targets/CMakeLists.txt | 1 + openair2/RRC/LITE/rrc_eNB.c | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index dd56bdf760..723ad38d67 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -1804,6 +1804,7 @@ add_executable(lte-softmodem-nos1 ${OPENAIR_TARGETS}/RT/USER/rt_wrapper.c ${OPENAIR_TARGETS}/RT/USER/lte-ue.c ${OPENAIR_TARGETS}/RT/USER/lte-enb.c + ${OPENAIR_TARGETS}/RT/USER/lte-ru.c ${OPENAIR_TARGETS}/RT/USER/lte-softmodem.c ${OPENAIR1_DIR}/SIMULATION/TOOLS/taus.c ${OPENAIR_TARGETS}/SIMU/USER/init_lte.c diff --git a/openair2/RRC/LITE/rrc_eNB.c b/openair2/RRC/LITE/rrc_eNB.c index 37d6b0c9c5..fde39dc977 100644 --- a/openair2/RRC/LITE/rrc_eNB.c +++ b/openair2/RRC/LITE/rrc_eNB.c @@ -627,12 +627,12 @@ void rrc_eNB_emulation_notify_ue_module_id( return; } for (CC_id = 0; CC_id < MAX_NUM_CCs; CC_id++) { - if (RC.rrc[enb_module_id].carrier[CC_id].sib1 != NULL) { + if (&RC.rrc[enb_module_id]->carrier[CC_id].sib1 != NULL) { if ( - (RC.rrc[enb_module_id].carrier[CC_id].sib1->cellAccessRelatedInfo.cellIdentity.buf[0] == cell_identity_byte0P) && - (RC.rrc[enb_module_id].carrier[CC_id].sib1->cellAccessRelatedInfo.cellIdentity.buf[1] == cell_identity_byte1P) && - (RC.rrc[enb_module_id].carrier[CC_id].sib1->cellAccessRelatedInfo.cellIdentity.buf[2] == cell_identity_byte2P) && - (RC.rrc[enb_module_id].carrier[CC_id].sib1->cellAccessRelatedInfo.cellIdentity.buf[3] == cell_identity_byte3P) + (&RC.rrc[enb_module_id]->carrier[CC_id].sib1->cellAccessRelatedInfo.cellIdentity.buf[0] == cell_identity_byte0P) && + (&RC.rrc[enb_module_id]->carrier[CC_id].sib1->cellAccessRelatedInfo.cellIdentity.buf[1] == cell_identity_byte1P) && + (&RC.rrc[enb_module_id]->carrier[CC_id].sib1->cellAccessRelatedInfo.cellIdentity.buf[2] == cell_identity_byte2P) && + (&RC.rrc[enb_module_id]->carrier[CC_id].sib1->cellAccessRelatedInfo.cellIdentity.buf[3] == cell_identity_byte3P) ) { ue_context_p = rrc_eNB_get_ue_context( RC.rrc[enb_module_id], From 3f6c5430a29667dd48fbd2bd58815db22c8a3b2c Mon Sep 17 00:00:00 2001 From: Wang Tsu-Han Date: Fri, 10 Nov 2017 14:23:18 +0100 Subject: [PATCH 12/63] changing back the rxtx thread and add another worker thread for coding --- openair1/PHY/LTE_TRANSPORT/dlsch_coding.c | 208 +++++++++++++++++--- openair1/PHY/defs.h | 16 +- openair1/SCHED/phy_procedures_lte_eNb.c | 23 ++- openair2/LAYER2/MAC/eNB_scheduler_phytest.c | 7 +- targets/RT/USER/eNB_usrp.gtkw | 21 +- targets/RT/USER/lte-enb.c | 62 ++++-- 6 files changed, 267 insertions(+), 70 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c index e407f2c4bf..bf0675c7f3 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c @@ -287,7 +287,7 @@ int dlsch_encoding_2threads0(te_params *tep) { if (dlsch->harq_processes[harq_pid]->round == 0) { // this is a new packet - for (r=0; rharq_processes[harq_pid]->C>>1; r++) { + for (r=0; rharq_processes[harq_pid]->C/3; r++) { if (rharq_processes[harq_pid]->Cminus) Kr = dlsch->harq_processes[harq_pid]->Kminus; @@ -330,7 +330,7 @@ int dlsch_encoding_2threads0(te_params *tep) { // Fill in the "e"-sequence from 36-212, V8.6 2009-03, p. 16-17 (for each "e") and concatenate the // outputs for each code segment, see Section 5.1.5 p.20 - for (r=0; rharq_processes[harq_pid]->C>>1; r++) { + for (r=0; rharq_processes[harq_pid]->C/3; r++) { r_offset += lte_rate_matching_turbo(dlsch->harq_processes[harq_pid]->RTC[r], G, //G dlsch->harq_processes[harq_pid]->w[r], @@ -352,29 +352,123 @@ int dlsch_encoding_2threads0(te_params *tep) { return(0); } +int dlsch_encoding_2threads1(te_params *tep) { + + LTE_eNB_DLSCH_t *dlsch = tep->dlsch; + unsigned int G = tep->G; + unsigned char harq_pid = tep->harq_pid; + + unsigned short iind; + + unsigned short nb_rb = dlsch->harq_processes[harq_pid]->nb_rb; + unsigned int Kr=0,Kr_bytes,r,r_offset=0; + // unsigned short m=dlsch->harq_processes[harq_pid]->mcs; + + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ENCODING_W, VCD_FUNCTION_IN); + + if (dlsch->harq_processes[harq_pid]->round == 0) { // this is a new packet + + for (r=dlsch->harq_processes[harq_pid]->C/3; rharq_processes[harq_pid]->C/3*2; r++) { + + if (rharq_processes[harq_pid]->Cminus) + Kr = dlsch->harq_processes[harq_pid]->Kminus; + else + Kr = dlsch->harq_processes[harq_pid]->Kplus; + + Kr_bytes = Kr>>3; + + // get interleaver index for Turbo code (lookup in Table 5.1.3-3 36-212, V8.6 2009-03, p. 13-14) + if (Kr_bytes<=64) + iind = (Kr_bytes-5); + else if (Kr_bytes <=128) + iind = 59 + ((Kr_bytes-64)>>1); + else if (Kr_bytes <= 256) + iind = 91 + ((Kr_bytes-128)>>2); + else if (Kr_bytes <= 768) + iind = 123 + ((Kr_bytes-256)>>3); + else { + printf("dlsch_coding: Illegal codeword size %d!!!\n",Kr_bytes); + return(-1); + } + + + + threegpplte_turbo_encoder(dlsch->harq_processes[harq_pid]->c[r], + Kr>>3, + &dlsch->harq_processes[harq_pid]->d[r][96], + (r==0) ? dlsch->harq_processes[harq_pid]->F : 0, + f1f2mat_old[iind*2], // f1 (see 36121-820, page 14) + f1f2mat_old[(iind*2)+1] // f2 (see 36121-820, page 14) + ); + dlsch->harq_processes[harq_pid]->RTC[r] = + sub_block_interleaving_turbo(4+(Kr_bytes*8), + &dlsch->harq_processes[harq_pid]->d[r][96], + dlsch->harq_processes[harq_pid]->w[r]); + } + + } + + // Fill in the "e"-sequence from 36-212, V8.6 2009-03, p. 16-17 (for each "e") and concatenate the + // outputs for each code segment, see Section 5.1.5 p.20 + + for (r=0,r_offset=0; rharq_processes[harq_pid]->C/3*2; r++) { + if(r<(dlsch->harq_processes[harq_pid]->C/3)){ + int Nl=dlsch->harq_processes[harq_pid]->Nl; + int Qm=dlsch->harq_processes[harq_pid]->Qm; + int C = dlsch->harq_processes[harq_pid]->C; + int Gp = G/Nl/Qm; + int GpmodC = Gp%C; + if (r < (C-(GpmodC))) + r_offset += Nl*Qm * (Gp/C); + else + r_offset += Nl*Qm * ((GpmodC==0?0:1) + (Gp/C)); + } + else{ + r_offset += lte_rate_matching_turbo(dlsch->harq_processes[harq_pid]->RTC[r], + G, //G + dlsch->harq_processes[harq_pid]->w[r], + dlsch->harq_processes[harq_pid]->e+r_offset, + dlsch->harq_processes[harq_pid]->C, // C + dlsch->Nsoft, // Nsoft, + dlsch->Mdlharq, + dlsch->Kmimo, + dlsch->harq_processes[harq_pid]->rvidx, + dlsch->harq_processes[harq_pid]->Qm, + dlsch->harq_processes[harq_pid]->Nl, + r, + nb_rb); + // m); // r + } + } + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ENCODING_W, VCD_FUNCTION_OUT); + + return(0); +} + extern int oai_exit; void *te_thread(void *param) { cpu_set_t cpuset; CPU_ZERO(&cpuset); - + pthread_setname_np( pthread_self(),"te processing"); - LOG_I(PHY,"thread te created id=%ld", syscall(__NR_gettid)); - + LOG_I(PHY,"thread te created id=%ld\n", syscall(__NR_gettid)); + CPU_SET(4, &cpuset); pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); eNB_proc_t *proc = &((te_params *)param)->eNB->proc; while (!oai_exit) { - - if (wait_on_condition(&proc->mutex_te,&proc->cond_te,&proc->instance_cnt_te,"te thread")<0) break; + if (wait_on_condition(&proc->mutex_te[0],&proc->cond_te[0],&proc->instance_cnt_te[0],"te thread")<0) break; dlsch_encoding_2threads0((te_params*)param); - if (release_thread(&proc->mutex_te,&proc->instance_cnt_te,"te thread")<0) break; + if (release_thread(&proc->mutex_te[0],&proc->instance_cnt_te[0],"te thread")<0) break; - if (pthread_cond_signal(&proc->cond_te) != 0) { + if (pthread_cond_signal(&proc->cond_te[0]) != 0) { printf("[eNB] ERROR pthread_cond_signal for te thread exit\n"); exit_fun( "ERROR pthread_cond_signal" ); return(NULL); @@ -384,6 +478,37 @@ void *te_thread(void *param) { return(NULL); } +void *te_thread1(void *param) { + cpu_set_t cpuset; + CPU_ZERO(&cpuset); + + pthread_setname_np( pthread_self(),"te processing 1"); + LOG_I(PHY,"thread te 1 created id=%ld\n", syscall(__NR_gettid)); + + CPU_SET(7, &cpuset); + pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); + + eNB_proc_t *proc = &((te_params *)param)->eNB->proc; + while (!oai_exit) { + + + if (wait_on_condition(&proc->mutex_te[1],&proc->cond_te[1],&proc->instance_cnt_te[1],"te thread 1")<0) break; + + dlsch_encoding_2threads1((te_params*)param); + + + if (release_thread(&proc->mutex_te[1],&proc->instance_cnt_te[1],"te thread 1")<0) break; + + if (pthread_cond_signal(&proc->cond_te[1]) != 0) { + printf("[eNB] ERROR pthread_cond_signal for te thread 1 exit\n"); + exit_fun( "ERROR pthread_cond_signal" ); + return(NULL); + } + } + + return(NULL); +} + int dlsch_encoding_2threads(PHY_VARS_eNB *eNB, unsigned char *a, uint8_t num_pdcch_symbols, @@ -439,30 +564,53 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB, - if (proc->instance_cnt_te==0) { + if (proc->instance_cnt_te[0]==0) { printf("[eNB] TE thread busy\n"); exit_fun("TE thread busy"); - pthread_mutex_unlock( &proc->mutex_te ); + pthread_mutex_unlock( &proc->mutex_te[0] ); return(-1); } - ++proc->instance_cnt_te; + ++proc->instance_cnt_te[0]; - proc->tep.eNB = eNB; - proc->tep.dlsch = dlsch; - proc->tep.G = G; - proc->tep.harq_pid = harq_pid; + proc->tep[0].eNB = eNB; + proc->tep[0].dlsch = dlsch; + proc->tep[0].G = G; + proc->tep[0].harq_pid = harq_pid; // wakeup worker to do second half segments - if (pthread_cond_signal(&proc->cond_te) != 0) { + if (pthread_cond_signal(&proc->cond_te[0]) != 0) { printf("[eNB] ERROR pthread_cond_signal for te thread exit\n"); exit_fun( "ERROR pthread_cond_signal" ); return (-1); } - pthread_mutex_unlock( &proc->mutex_te ); + pthread_mutex_unlock( &proc->mutex_te[0] ); +//////////////////////////////////////////////////////////////// + if (proc->instance_cnt_te[1]==0) { + printf("[eNB] TE thread busy\n"); + exit_fun("TE thread busy"); + pthread_mutex_unlock( &proc->mutex_te[1] ); + return(-1); + } - for (r=dlsch->harq_processes[harq_pid]->C>>1; rharq_processes[harq_pid]->C; r++) { + ++proc->instance_cnt_te[1]; + + proc->tep[1].eNB = eNB; + proc->tep[1].dlsch = dlsch; + proc->tep[1].G = G; + proc->tep[1].harq_pid = harq_pid; + + // wakeup worker to do second half segments + if (pthread_cond_signal(&proc->cond_te[1]) != 0) { + printf("[eNB] ERROR pthread_cond_signal for te thread exit\n"); + exit_fun( "ERROR pthread_cond_signal" ); + return (-1); + } + + pthread_mutex_unlock( &proc->mutex_te[1] ); + + for (r=dlsch->harq_processes[harq_pid]->C/3*2; rharq_processes[harq_pid]->C; r++) { if (rharq_processes[harq_pid]->Cminus) Kr = dlsch->harq_processes[harq_pid]->Kminus; @@ -507,12 +655,21 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB, } else { - proc->tep.eNB = eNB; - proc->tep.dlsch = dlsch; - proc->tep.G = G; + proc->tep[0].eNB = eNB; + proc->tep[0].dlsch = dlsch; + proc->tep[0].G = G; + + proc->tep[1].eNB = eNB; + proc->tep[1].dlsch = dlsch; + proc->tep[1].G = G; // wakeup worker to do second half segments - if (pthread_cond_signal(&proc->cond_te) != 0) { + if (pthread_cond_signal(&proc->cond_te[0]) != 0) { + printf("[eNB] ERROR pthread_cond_signal for te thread exit\n"); + exit_fun( "ERROR pthread_cond_signal" ); + return (-1); + } + if (pthread_cond_signal(&proc->cond_te[1]) != 0) { printf("[eNB] ERROR pthread_cond_signal for te thread exit\n"); exit_fun( "ERROR pthread_cond_signal" ); return (-1); @@ -525,7 +682,7 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB, for (r=0,r_offset=0; rharq_processes[harq_pid]->C; r++) { // get information for E for the segments that are handled by the worker thread - if (r<(dlsch->harq_processes[harq_pid]->C>>1)) { + if (r<(dlsch->harq_processes[harq_pid]->C/3*2)) { int Nl=dlsch->harq_processes[harq_pid]->Nl; int Qm=dlsch->harq_processes[harq_pid]->Qm; int C = dlsch->harq_processes[harq_pid]->C; @@ -558,7 +715,8 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB, // wait for worker to finish - wait_on_busy_condition(&proc->mutex_te,&proc->cond_te,&proc->instance_cnt_te,"te thread"); + wait_on_busy_condition(&proc->mutex_te[0],&proc->cond_te[0],&proc->instance_cnt_te[0],"te thread"); + wait_on_busy_condition(&proc->mutex_te[1],&proc->cond_te[1],&proc->instance_cnt_te[1],"te thread1"); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ENCODING, VCD_FUNCTION_OUT); diff --git a/openair1/PHY/defs.h b/openair1/PHY/defs.h index 7e4933f26b..aa714c88cb 100644 --- a/openair1/PHY/defs.h +++ b/openair1/PHY/defs.h @@ -461,7 +461,7 @@ typedef struct eNB_proc_t_s { /// \internal This variable is protected by \ref mutex_td. int instance_cnt_td; /// \internal This variable is protected by \ref mutex_te. - int instance_cnt_te; + int instance_cnt_te[2]; /// \internal This variable is protected by \ref mutex_prach. int instance_cnt_prach; #ifdef Rel14 @@ -483,7 +483,7 @@ typedef struct eNB_proc_t_s { /// pthread attributes for parallel turbo-decoder thread pthread_attr_t attr_td; /// pthread attributes for parallel turbo-encoder thread - pthread_attr_t attr_te; + pthread_attr_t attr_te[2]; /// pthread attributes for single eNB processing thread pthread_attr_t attr_single; /// pthread attributes for prach processing thread @@ -497,7 +497,7 @@ typedef struct eNB_proc_t_s { /// scheduling parameters for parallel turbo-decoder thread struct sched_param sched_param_td; /// scheduling parameters for parallel turbo-encoder thread - struct sched_param sched_param_te; + struct sched_param sched_param_te[2]; /// scheduling parameters for single eNB thread struct sched_param sched_param_single; /// scheduling parameters for prach thread @@ -511,7 +511,7 @@ typedef struct eNB_proc_t_s { /// pthread structure for parallel turbo-decoder thread pthread_t pthread_td; /// pthread structure for parallel turbo-encoder thread - pthread_t pthread_te; + pthread_t pthread_te[2]; /// pthread structure for PRACH thread pthread_t pthread_prach; #ifdef Rel14 @@ -521,7 +521,7 @@ typedef struct eNB_proc_t_s { /// condition variable for parallel turbo-decoder thread pthread_cond_t cond_td; /// condition variable for parallel turbo-encoder thread - pthread_cond_t cond_te; + pthread_cond_t cond_te[2]; /// condition variable for PRACH processing thread; pthread_cond_t cond_prach; #ifdef Rel14 @@ -533,7 +533,7 @@ typedef struct eNB_proc_t_s { /// mutex for parallel turbo-decoder thread pthread_mutex_t mutex_td; /// mutex for parallel turbo-encoder thread - pthread_mutex_t mutex_te; + pthread_mutex_t mutex_te[2]; /// mutex for PRACH thread pthread_mutex_t mutex_prach; #ifdef Rel14 @@ -559,11 +559,11 @@ typedef struct eNB_proc_t_s { /// parameters for turbo-decoding worker thread td_params tdp; /// parameters for turbo-encoding worker thread - te_params tep; + te_params tep[2]; /// set of scheduling variables RXn-TXnp4 threads eNB_rxtx_proc_t proc_rxtx[2]; /// stats thread pthread descriptor - pthread_t coding_stats_thread; + pthread_t process_stats_thread; /// for waking up tx procedure RU_proc_t *ru_proc; } eNB_proc_t; diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index 3e3326c4c5..63bf430d7c 100644 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -1502,19 +1502,30 @@ void init_td_thread(PHY_VARS_eNB *eNB,pthread_attr_t *attr_td) { } extern void *te_thread(void*); +extern void *te_thread1(void*); -void init_te_thread(PHY_VARS_eNB *eNB,pthread_attr_t *attr_te) { +void init_te_thread(PHY_VARS_eNB *eNB,pthread_attr_t *attr_te,pthread_attr_t *attr_te1) { eNB_proc_t *proc = &eNB->proc; - proc->tep.eNB = eNB; - proc->instance_cnt_te = -1; + proc->tep[0].eNB = eNB; + proc->instance_cnt_te[0] = -1; - pthread_mutex_init( &proc->mutex_te, NULL); - pthread_cond_init( &proc->cond_te, NULL); + pthread_mutex_init( &proc->mutex_te[0], NULL); + pthread_cond_init( &proc->cond_te[0], NULL); printf("Creating te_thread\n"); - pthread_create(&proc->pthread_te, attr_te, te_thread, (void*)&proc->tep); + pthread_create(&proc->pthread_te[0], attr_te, te_thread, (void*)&proc->tep[0]); + + ///////////////////////////////////////////////////////////////////////// + proc->tep[1].eNB = eNB; + proc->instance_cnt_te[1] = -1; + + pthread_mutex_init( &proc->mutex_te[1], NULL); + pthread_cond_init( &proc->cond_te[1], NULL); + + printf("Creating te_thread1\n"); + pthread_create(&proc->pthread_te[1], attr_te1, te_thread1, (void*)&proc->tep[1]); } diff --git a/openair2/LAYER2/MAC/eNB_scheduler_phytest.c b/openair2/LAYER2/MAC/eNB_scheduler_phytest.c index 342b6b6437..348fb2be46 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_phytest.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_phytest.c @@ -71,7 +71,7 @@ schedule_ue_spec_phy_test( uint16_t rnti = 0x1235; uint32_t rb_alloc = 0x1FFFFFFF; int32_t tpc = 1; - int32_t mcs = 28; + int32_t mcs = 22; int32_t cqi = 15; int32_t ndi = subframeP/5; int32_t dai = 0; @@ -94,7 +94,7 @@ schedule_ue_spec_phy_test( nb_rb = conv_nprb(0,rb_alloc,N_RB_DL); TBS = get_TBS_DL(mcs,nb_rb); - LOG_D(PHY,"schedule_ue_spec_phy_test: subframe %d: nb_rb=%d, TBS=%d, mcs=%d (rb_alloc=%x, N_RB_DL=%d)\n",subframeP,nb_rb,TBS,mcs,rb_alloc,N_RB_DL); + LOG_D(PHY,"schedule_ue_spec_phy_test: subframe %d/%d: nb_rb=%d, TBS=%d, mcs=%d (rb_alloc=%x, N_RB_DL=%d)\n",frameP,subframeP,nb_rb,TBS,mcs,rb_alloc,N_RB_DL); dl_config_pdu = &dl_req->dl_config_pdu_list[dl_req->number_pdu]; memset((void*)dl_config_pdu,0,sizeof(nfapi_dl_config_request_pdu_t)); @@ -183,5 +183,8 @@ schedule_ue_spec_phy_test( eNB->pdu_index[CC_id], eNB->UE_list.DLSCH_pdu[CC_id][0][(unsigned char)UE_id].payload[0]); } + else { + LOG_W(MAC,"[eNB_scheduler_phytest] DCI allocation infeasible!\n"); + } } } diff --git a/targets/RT/USER/eNB_usrp.gtkw b/targets/RT/USER/eNB_usrp.gtkw index 59a8a460ee..2209e35851 100644 --- a/targets/RT/USER/eNB_usrp.gtkw +++ b/targets/RT/USER/eNB_usrp.gtkw @@ -1,19 +1,19 @@ [*] [*] GTKWave Analyzer v3.3.58 (w)1999-2014 BSI -[*] Thu Nov 2 14:19:21 2017 +[*] Fri Nov 3 16:03:52 2017 [*] [dumpfile] "/tmp/openair_dump_eNB.vcd" -[dumpfile_mtime] "Thu Nov 2 14:15:28 2017" -[dumpfile_size] 1636821 +[dumpfile_mtime] "Fri Nov 3 16:00:30 2017" +[dumpfile_size] 56765827 [savefile] "/homes/wangts/openairinterface5g/targets/RT/USER/eNB_usrp.gtkw" -[timestart] 14181427000 -[size] 1855 1056 -[pos] 65 0 -*-19.872988 15497443000 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 +[timestart] 15220241000 +[size] 1920 1018 +[pos] 0 22 +*-19.666586 15221741584 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 [sst_width] 386 [signals_width] 302 [sst_expanded] 1 -[sst_vpaned_height] 317 +[sst_vpaned_height] 303 @28 functions.trx_read functions.trx_write @@ -34,8 +34,11 @@ functions.macxface_ue_scheduler functions.phy_eNB_ofdm_mod_l @24 variables.frame_number_RX0_eNB[63:0] -@25 variables.frame_number_TX0_eNB[63:0] +@25 +variables.frame_number_RX1_eNB[63:0] +@24 +variables.frame_number_TX1_eNB[63:0] @28 functions.phy_eNB_dlsch_modulation functions.phy_eNB_dlsch_encoding diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 6ac889791f..6b91157e9c 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -182,9 +182,14 @@ static inline int rxtx(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, char *thread_nam VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER , 0 ); - if (release_thread(&proc->mutex_rxtx,&proc->instance_cnt_rxtx,thread_name)<0) return(-1); - - wakeup_tx(eNB,eNB->proc.ru_proc); + // wakeup_tx(eNB,eNB->proc.ru_proc); + if(oai_exit) return(-1); + phy_procedures_eNB_TX(eNB, proc, no_relay, NULL, 1); + + pthread_mutex_lock(&eNB->proc.ru_proc->mutex_eNBs); + ++eNB->proc.ru_proc->instance_cnt_eNBs; + pthread_cond_signal(&eNB->proc.ru_proc->cond_eNBs); + pthread_mutex_unlock(&eNB->proc.ru_proc->mutex_eNBs); stop_meas( &softmodem_stats_rxtx_sf ); @@ -199,7 +204,7 @@ static void* tx_thread(void* param) { PHY_VARS_eNB *eNB = RC.eNB[0][proc->CC_id]; char thread_name[100]; - sprintf(thread_name,"RXn_TXnp4_%d\n",&eNB->proc.proc_rxtx[0] == proc ? 0 : 1); + sprintf(thread_name,"TXnp4_%d\n",&eNB->proc.proc_rxtx[0] == proc ? 0 : 1); thread_top_init(thread_name,1,850000L,1000000L,2000000L); while (!oai_exit) { @@ -211,8 +216,10 @@ static void* tx_thread(void* param) { // run PHY TX procedures the one after the other for all CCs to avoid race conditions // (may be relaxed in the future for performance reasons) // ***************************************** - //if (wait_CCs(proc)<0) return(-1); - + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_TX1_ENB,proc->subframe_tx); + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_RX1_ENB,proc->subframe_rx); + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX1_ENB,proc->frame_tx); + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_RX1_ENB,proc->frame_rx); phy_procedures_eNB_TX(eNB, proc, no_relay, NULL, 1); if (release_thread(&proc->mutex_rxtx,&proc->instance_cnt_rxtx,thread_name)<0) break; @@ -275,6 +282,9 @@ static void* eNB_thread_rxtx( void* param ) { if (eNB->CC_id==0) if (rxtx(eNB,proc,thread_name) < 0) break; + + if (release_thread(&proc->mutex_rxtx,&proc->instance_cnt_rxtx,thread_name)<0) break; + } // while !oai_exit VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_eNB_PROC_RXTX0+(proc->subframe_rx&1), 0 ); @@ -353,9 +363,14 @@ int wakeup_tx(PHY_VARS_eNB *eNB,RU_proc_t *ru_proc) { wait.tv_sec=0; wait.tv_nsec=5000000L; + if (proc_rxtx->instance_cnt_rxtx == 0) { + LOG_E(PHY,"Frame %d, subframe %d: TX1 thread busy, dropping\n",proc_rxtx->frame_rx,proc_rxtx->subframe_rx); + return(-1); + } + if (pthread_mutex_timedlock(&proc_rxtx->mutex_rxtx,&wait) != 0) { - LOG_E( PHY, "[eNB] ERROR pthread_mutex_lock for eNB RXTX thread %d (IC %d)\n", proc_rxtx->subframe_rx&1,proc_rxtx->instance_cnt_rxtx ); - exit_fun( "error locking mutex_rxtx" ); + LOG_E( PHY, "[eNB] ERROR pthread_mutex_lock for eNB TX1 thread %d (IC %d)\n", proc_rxtx->subframe_rx&1,proc_rxtx->instance_cnt_rxtx ); + exit_fun( "error locking mutex_tx" ); return(-1); } @@ -372,7 +387,7 @@ int wakeup_tx(PHY_VARS_eNB *eNB,RU_proc_t *ru_proc) { // the thread can now be woken up if (pthread_cond_signal(&proc_rxtx->cond_rxtx) != 0) { - LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB RXn-TXnp4 thread\n"); + LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB TXnp4 thread\n"); exit_fun( "ERROR pthread_cond_signal" ); return(-1); } @@ -420,9 +435,8 @@ int wakeup_rxtx(PHY_VARS_eNB *eNB,RU_t *ru) { wait.tv_nsec=5000000L; /* accept some delay in processing - up to 5ms */ - if (proc_rxtx->instance_cnt_rxtx == 0) { - LOG_E(PHY,"Frame %d, subframe %d: RXTX thread busy, dropping",proc_rxtx->frame_rx,proc_rxtx->subframe_rx); + LOG_E(PHY,"Frame %d, subframe %d: RXTX0 thread busy, dropping\n",proc_rxtx->frame_rx,proc_rxtx->subframe_rx); return(-1); } @@ -434,6 +448,11 @@ int wakeup_rxtx(PHY_VARS_eNB *eNB,RU_t *ru) { return(-1); } + /*if (proc_rxtx->instance_cnt_rxtx == 0) { + LOG_E(PHY,"Frame %d, subframe %d: RXTX0 thread busy, dropping\n",proc_rxtx->frame_rx,proc_rxtx->subframe_rx); + return(-1); + }*/ + ++proc_rxtx->instance_cnt_rxtx; // We have just received and processed the common part of a subframe, say n. @@ -672,20 +691,21 @@ static void* eNB_thread_prach_br( void* param ) { extern void init_td_thread(PHY_VARS_eNB *, pthread_attr_t *); -extern void init_te_thread(PHY_VARS_eNB *, pthread_attr_t *); +extern void init_te_thread(PHY_VARS_eNB *, pthread_attr_t *,pthread_attr_t *); //////////////////////////////////////need to modified////////////////***** -static void* coding_stats_thread(void* param) { +static void* process_stats_thread(void* param) { PHY_VARS_eNB *eNB = (PHY_VARS_eNB*)param; - wait_sync("coding_stats_thread"); + wait_sync("process_stats_thread"); while (!oai_exit) { sleep(1); if (opp_enabled == 1) { if (eNB->td) print_meas(&eNB->ulsch_decoding_stats,"ulsch_decoding",NULL,NULL); if (eNB->te) print_meas(&eNB->dlsch_encoding_stats,"dlsch_encoding",NULL,NULL); + print_meas(&eNB->dlsch_modulation_stats,"dlsch_modulation",NULL,NULL); } } return(NULL); @@ -699,7 +719,7 @@ void init_eNB_proc(int inst) { PHY_VARS_eNB *eNB; eNB_proc_t *proc; eNB_rxtx_proc_t *proc_rxtx; - pthread_attr_t *attr0=NULL,*attr1=NULL,*attr_prach=NULL,*attr_te=NULL,*attr_td=NULL; + pthread_attr_t *attr0=NULL,*attr1=NULL,*attr_prach=NULL,*attr_te=NULL,*attr_te1=NULL;//*attr_td=NULL; #ifdef Rel14 pthread_attr_t *attr_prach_br=NULL; #endif @@ -740,7 +760,8 @@ void init_eNB_proc(int inst) { pthread_attr_init( &proc->attr_prach); pthread_attr_init( &proc->attr_asynch_rxtx); pthread_attr_init( &proc->attr_td); - pthread_attr_init( &proc->attr_te); + pthread_attr_init( &proc->attr_te[0]); + pthread_attr_init( &proc->attr_te[1]); pthread_attr_init( &proc_rxtx[0].attr_rxtx); pthread_attr_init( &proc_rxtx[1].attr_rxtx); #ifdef Rel14 @@ -762,8 +783,9 @@ void init_eNB_proc(int inst) { // attr_td = &proc->attr_td; // attr_te = &proc->attr_te; #endif - attr_td = &proc->attr_td; - attr_te = &proc->attr_te; + //attr_td = &proc->attr_td; + attr_te = &proc->attr_te[0]; + attr_te1 = &proc->attr_te[1]; pthread_create( &proc_rxtx[0].pthread_rxtx, attr0, eNB_thread_rxtx, proc ); pthread_create( &proc_rxtx[1].pthread_rxtx, attr1, tx_thread, proc); if (eNB->single_thread_flag==0) { @@ -786,9 +808,9 @@ void init_eNB_proc(int inst) { //////////////////////////////////////need to modified////////////////***** - init_te_thread(eNB,attr_te); + init_te_thread(eNB,attr_te,attr_te1); //init_td_thread(eNB,attr_td); - if (opp_enabled == 1) pthread_create(&proc->coding_stats_thread,NULL,coding_stats_thread,(void*)eNB); + if (opp_enabled == 1) pthread_create(&proc->process_stats_thread,NULL,process_stats_thread,(void*)eNB); } From 81177a8a7320271024934a00bbd3c56055531cf3 Mon Sep 17 00:00:00 2001 From: Wang Tsu-Han Date: Fri, 10 Nov 2017 15:42:50 +0100 Subject: [PATCH 13/63] making the numerology into a executional option --- targets/RT/USER/lte-softmodem.c | 2 +- targets/RT/USER/lte-softmodem.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index b126e70a25..e21fd12428 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -206,7 +206,7 @@ extern void reset_opp_meas(void); extern void print_opp_meas(void); int transmission_mode=1; -int numerology = 1; +int numerology = 0; int fh_two_thread = 1; diff --git a/targets/RT/USER/lte-softmodem.h b/targets/RT/USER/lte-softmodem.h index 37fdd6240e..058eab8e30 100644 --- a/targets/RT/USER/lte-softmodem.h +++ b/targets/RT/USER/lte-softmodem.h @@ -168,7 +168,7 @@ extern int16_t dlsch_demod_shift; {"q" , CONFIG_HLP_STMON, PARAMFLAG_BOOL, iptr:&opp_enabled, defintval:0, TYPE_INT, 0}, \ {"S" , CONFIG_HLP_MSLOTS, PARAMFLAG_BOOL, u8ptr:&exit_missed_slots, defintval:1, TYPE_UINT8, 0}, \ {"T" , CONFIG_HLP_TDD, PARAMFLAG_BOOL, iptr:&tddflag, defintval:0, TYPE_INT, 0}, \ -{"n" , CONFIG_HLP_NUMEROLOGY, 0, iptr:&numerology, defintval:0, TYPE_INT, 0} \ +{"numerology" , CONFIG_HLP_NUMEROLOGY, PARAMFLAG_BOOL, iptr:&numerology, defintval:0, TYPE_INT, 0} \ } #define CONFIG_HLP_FLOG "Enable online log \n" From 69e90fa6cbb2bbc31ac10a375bd016f2b57d0734 Mon Sep 17 00:00:00 2001 From: Wang Tsu-Han Date: Fri, 17 Nov 2017 11:11:24 +0100 Subject: [PATCH 14/63] Creating Emulated FH --- openair1/PHY/LTE_TRANSPORT/dlsch_coding.c | 19 ++++++++++-- openair1/PHY/LTE_TRANSPORT/proto.h | 2 ++ openair1/PHY/TOOLS/time_meas.c | 2 +- openair1/PHY/defs.h | 6 ++-- openair1/SCHED/phy_procedures_lte_eNb.c | 4 ++- targets/RT/USER/lte-enb.c | 2 -- targets/RT/USER/lte-ru.c | 36 +++++++++++++++++++---- 7 files changed, 56 insertions(+), 15 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c index bf0675c7f3..d7e106c2f4 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c @@ -52,7 +52,11 @@ ((pilots==1)&&(first_pilot==0)&&(((re<3))||((re>5)&&(re<9)))) \ */ #define is_not_pilot(pilots,first_pilot,re) (1) - +/*extern void thread_top_init(char *thread_name, + int affinity, + uint64_t runtime, + uint64_t deadline, + uint64_t period);*/ void free_eNB_dlsch(LTE_eNB_DLSCH_t *dlsch) { @@ -452,6 +456,7 @@ void *te_thread(void *param) { cpu_set_t cpuset; CPU_ZERO(&cpuset); + //thread_top_init("te_thread",1,870000,1000000,1000000); pthread_setname_np( pthread_self(),"te processing"); LOG_I(PHY,"thread te created id=%ld\n", syscall(__NR_gettid)); @@ -482,6 +487,7 @@ void *te_thread1(void *param) { cpu_set_t cpuset; CPU_ZERO(&cpuset); + //thread_top_init("te_thread1",1,870000,1000000,1000000); pthread_setname_np( pthread_self(),"te processing 1"); LOG_I(PHY,"thread te 1 created id=%ld\n", syscall(__NR_gettid)); @@ -517,6 +523,7 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB, uint8_t subframe, time_stats_t *rm_stats, time_stats_t *te_stats, + time_stats_t *te_wait_stats, time_stats_t *i_stats) { @@ -714,9 +721,14 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB, } // wait for worker to finish - + start_meas(te_wait_stats); wait_on_busy_condition(&proc->mutex_te[0],&proc->cond_te[0],&proc->instance_cnt_te[0],"te thread"); wait_on_busy_condition(&proc->mutex_te[1],&proc->cond_te[1],&proc->instance_cnt_te[1],"te thread1"); + stop_meas(te_wait_stats); + if(opp_enabled == 1 && te_wait_stats->diff_now>50*3000){ + print_meas_now(te_wait_stats,"coding_wait",stderr); + printf("frame_rx: %d subframe_rx: %d \n",proc->frame_rx,proc->subframe_rx); + } VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ENCODING, VCD_FUNCTION_OUT); @@ -731,6 +743,7 @@ int dlsch_encoding_all(PHY_VARS_eNB *eNB, uint8_t subframe, time_stats_t *rm_stats, time_stats_t *te_stats, + time_stats_t *te_wait_stats, time_stats_t *i_stats) { int encoding_return = 0; @@ -763,8 +776,8 @@ int dlsch_encoding_all(PHY_VARS_eNB *eNB, subframe, rm_stats, te_stats, + te_wait_stats, i_stats); - //printf("having more then 5 segmentation\n");///////////******* } else { diff --git a/openair1/PHY/LTE_TRANSPORT/proto.h b/openair1/PHY/LTE_TRANSPORT/proto.h index 169490d03d..6da6653492 100644 --- a/openair1/PHY/LTE_TRANSPORT/proto.h +++ b/openair1/PHY/LTE_TRANSPORT/proto.h @@ -130,6 +130,7 @@ int32_t dlsch_encoding_all(PHY_VARS_eNB *eNB, uint8_t subframe, time_stats_t *rm_stats, time_stats_t *te_stats, + time_stats_t *te_wait_stats, time_stats_t *i_stats); int32_t dlsch_encoding_SIC(PHY_VARS_UE *ue, @@ -175,6 +176,7 @@ int32_t dlsch_encoding_2threads(PHY_VARS_eNB *eNB, uint8_t subframe, time_stats_t *rm_stats, time_stats_t *te_stats, + time_stats_t *te_wait_stats, time_stats_t *i_stats); void dlsch_encoding_emul(PHY_VARS_eNB *phy_vars_eNB, diff --git a/openair1/PHY/TOOLS/time_meas.c b/openair1/PHY/TOOLS/time_meas.c index 31a613d032..857696a48f 100644 --- a/openair1/PHY/TOOLS/time_meas.c +++ b/openair1/PHY/TOOLS/time_meas.c @@ -53,7 +53,7 @@ void print_meas_now(time_stats_t *ts, const char* name, FILE* file_name){ if (ts->trials>0) { //fprintf(file_name,"Name %25s: Processing %15.3f ms for SF %d, diff_now %15.3f \n", name,(ts->diff_now/(cpu_freq_GHz*1000000.0)),subframe,ts->diff_now); - fprintf(file_name,"%15.3f ms, diff_now %15.3f \n",(ts->diff_now/(cpu_freq_GHz*1000000.0)),(double)ts->diff_now); + fprintf(file_name,"%15.3f us, diff_now %15.3f \n",(ts->diff_now/(cpu_freq_GHz*1000.0)),(double)ts->diff_now); } } diff --git a/openair1/PHY/defs.h b/openair1/PHY/defs.h index aa714c88cb..81a4953b15 100644 --- a/openair1/PHY/defs.h +++ b/openair1/PHY/defs.h @@ -666,7 +666,8 @@ typedef enum { REMOTE_MBP_IF5 =2, REMOTE_IF4p5 =3, REMOTE_IF1pp =4, - MAX_RU_IF_TYPES =5 + MAX_RU_IF_TYPES =5, + EMULATE_RF =6 } RU_if_south_t; typedef struct RU_t_s{ @@ -946,7 +947,7 @@ typedef struct PHY_VARS_eNB_s { eth_params_t eth_params; 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 *); + 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 *); int (*start_if)(struct RU_t_s *ru,struct PHY_VARS_eNB_s *eNB); uint8_t local_flag; LTE_DL_FRAME_PARMS frame_parms; @@ -1125,6 +1126,7 @@ typedef struct PHY_VARS_eNB_s { time_stats_t dlsch_scrambling_stats; time_stats_t dlsch_rate_matching_stats; time_stats_t dlsch_turbo_encoding_stats; + time_stats_t dlsch_turbo_encoding_waiting_stats; time_stats_t dlsch_interleaving_stats; time_stats_t rx_dft_stats; diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index 63bf430d7c..c3268cdccd 100644 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -341,9 +341,11 @@ void pdsch_procedures(PHY_VARS_eNB *eNB, dlsch_harq->pdu, dlsch_harq->pdsch_start, dlsch, - frame,subframe, + frame, + subframe, &eNB->dlsch_rate_matching_stats, &eNB->dlsch_turbo_encoding_stats, + &eNB->dlsch_turbo_encoding_waiting_stats, &eNB->dlsch_interleaving_stats); stop_meas(&eNB->dlsch_encoding_stats); // 36-211 diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 6b91157e9c..ff489dbd8b 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -381,8 +381,6 @@ int wakeup_tx(PHY_VARS_eNB *eNB,RU_proc_t *ru_proc) { proc_rxtx->frame_rx = ru_proc->frame_rx; proc_rxtx->subframe_tx = (ru_proc->subframe_rx+4)%10; proc_rxtx->frame_tx = (ru_proc->subframe_rx>5) ? (1+ru_proc->frame_rx)&1023 : ru_proc->frame_rx; - proc->frame_tx = proc_rxtx->frame_tx; - proc->frame_rx = proc_rxtx->frame_rx; proc_rxtx->timestamp_tx = ru_proc->timestamp_tx; // the thread can now be woken up diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index a106012815..8c139ae22f 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -110,6 +110,10 @@ unsigned short config_frames[4] = {2,9,11,13}; #include "T.h" +#ifndef EMULATE_RF +#define EMULATE_RF +#endif + extern volatile int oai_exit; extern int numerology; extern int fh_two_thread; @@ -694,12 +698,20 @@ void rx_rf(RU_t *ru,int *frame,int *subframe) { VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ, 1 ); old_ts = proc->timestamp_rx; - + #ifdef EMULATE_RF + int microsec = 450; // length of time to sleep, in miliseconds + struct timespec req = {0}; + req.tv_sec = 0; + req.tv_nsec = microsec * 1000L; + nanosleep(&req, (struct timespec *)NULL); + rxs = fp->samples_per_tti; + #else rxs = ru->rfdevice.trx_read_func(&ru->rfdevice, &ts, rxp, fp->samples_per_tti, ru->nb_rx); + #endif VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ, 0 ); @@ -714,7 +726,7 @@ void rx_rf(RU_t *ru,int *frame,int *subframe) { } else { if (proc->timestamp_rx - old_ts != fp->samples_per_tti) { - LOG_I(PHY,"rx_rf: rfdevice timing drift of %"PRId64" samples (ts_off %"PRId64")\n",proc->timestamp_rx - old_ts - fp->samples_per_tti,ru->ts_offset); + //LOG_I(PHY,"rx_rf: rfdevice timing drift of %"PRId64" samples (ts_off %"PRId64")\n",proc->timestamp_rx - old_ts - fp->samples_per_tti,ru->ts_offset); ru->ts_offset += (proc->timestamp_rx - old_ts - fp->samples_per_tti); proc->timestamp_rx = ts-ru->ts_offset; } @@ -1396,7 +1408,8 @@ static void* ru_thread_tx( void* param ) { wait_on_condition(&proc->mutex_eNBs,&proc->cond_eNBs,&proc->instance_cnt_eNBs,"ru_thread"); //printf("//////////////////instance_cnt_eNBs = %d\n",proc->instance_cnt_eNBs);//////////////////********* - + #ifdef EMULATE_RF + #else // do TX front-end processing if needed (precoding and/or IDFTs) if (ru->feptx_prec) ru->feptx_prec(ru); @@ -1406,6 +1419,7 @@ static void* ru_thread_tx( void* param ) { if ((ru->fh_north_asynch_in == NULL) && (ru->fh_south_out)) ru->fh_south_out(ru); if (ru->fh_north_out) ru->fh_north_out(ru); + #endif release_thread(&proc->mutex_eNBs,&proc->instance_cnt_eNBs,"ru_thread"); } @@ -1439,7 +1453,15 @@ static void* ru_thread( void* param ) { LOG_I(PHY,"Starting RU %d (%s,%s),\n",ru->idx,eNB_functions[ru->function],eNB_timing[ru->if_timing]); - + #ifdef EMULATE_RF + fill_rf_config(ru,ru->rf_config_file); + init_frame_parms(&ru->frame_parms,1); + phy_init_RU(ru); + if (setup_RU_buffers(ru)!=0) { + printf("Exiting, cannot initialize RU Buffers\n"); + exit(-1); + } + #else // Start IF device if any if (ru->start_if) { LOG_I(PHY,"Starting IF interface for RU %d\n",ru->idx); @@ -1460,6 +1482,7 @@ static void* ru_thread( void* param ) { printf("Exiting, cannot initialize RU Buffers\n"); exit(-1); } + #endif LOG_I(PHY, "Signaling main thread that RU %d is ready\n",ru->idx); pthread_mutex_lock(&RC.ru_mutex); @@ -1471,7 +1494,8 @@ static void* ru_thread( void* param ) { - + #ifdef EMULATE_RF + #else // Start RF device if any if (ru->start_rf) { if (ru->start_rf(ru) != 0) @@ -1480,7 +1504,6 @@ static void* ru_thread( void* param ) { } else LOG_I(PHY,"RU %d no rf device\n",ru->idx); - // if an asnych_rxtx thread exists // wakeup the thread because the devices are ready at this point @@ -1499,6 +1522,7 @@ static void* ru_thread( void* param ) { proc->instance_cnt_FH1=0; pthread_mutex_unlock(&proc->mutex_FH1); pthread_cond_signal(&proc->cond_FH1); + #endif // This is a forever while loop, it loops over subframes which are scheduled by incoming samples from HW devices From 8950c6ddd39894e974aa546a60561158e0fe205a Mon Sep 17 00:00:00 2001 From: Wang Tsu-Han Date: Fri, 17 Nov 2017 16:42:17 +0100 Subject: [PATCH 15/63] Bug fix for UDP loading --- common/utils/itti/intertask_interface.c | 7 +++++++ targets/COMMON/create_tasks.c | 8 +++++++- targets/RT/USER/lte-ru.c | 4 ++-- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/common/utils/itti/intertask_interface.c b/common/utils/itti/intertask_interface.c index 193b2c13fb..fc366f6057 100644 --- a/common/utils/itti/intertask_interface.c +++ b/common/utils/itti/intertask_interface.c @@ -99,6 +99,10 @@ const int itti_debug = (ITTI_DEBUG_ISSUES | ITTI_DEBUG_MP_STATISTICS); # define ITTI_MEM_SIZE (16 * 1024 * 1024) #endif +#ifndef EMULATE_RF +#define EMULATE_RF +#endif + typedef enum task_state_s { TASK_STATE_NOT_CONFIGURED, TASK_STATE_STARTING, TASK_STATE_READY, TASK_STATE_ENDED, TASK_STATE_MAX, } task_state_t; @@ -436,6 +440,8 @@ int itti_send_msg_to_task(task_id_t destination_task_id, instance_t instance, Me destination_task_id, itti_get_task_name(destination_task_id)); } else { + #ifdef EMULATE_RF + #else /* We cannot send a message if the task is not running */ AssertFatal (itti_desc.threads[destination_thread_id].task_state == TASK_STATE_READY, "Task %s Cannot send message %s (%d) to thread %d, it is not in ready state (%d)!\n", @@ -444,6 +450,7 @@ int itti_send_msg_to_task(task_id_t destination_task_id, instance_t instance, Me message_id, destination_thread_id, itti_desc.threads[destination_thread_id].task_state); + #endif /* Allocate new list element */ new = (message_list_t *) itti_malloc (origin_task_id, destination_task_id, sizeof(struct message_list_s)); diff --git a/targets/COMMON/create_tasks.c b/targets/COMMON/create_tasks.c index ef3124ff24..65aed76742 100644 --- a/targets/COMMON/create_tasks.c +++ b/targets/COMMON/create_tasks.c @@ -40,6 +40,10 @@ # endif # include "enb_app.h" +#ifndef EMULATE_RF +#define EMULATE_RF +#endif + int create_tasks(uint32_t enb_nb, uint32_t ue_nb) { itti_wait_ready(1); @@ -71,11 +75,13 @@ int create_tasks(uint32_t enb_nb, uint32_t ue_nb) LOG_E(S1AP, "Create task for S1AP failed\n"); return -1; } - + #ifdef EMULATE_RF + #else if (itti_create_task (TASK_UDP, udp_eNB_task, NULL) < 0) { LOG_E(UDP_, "Create task for UDP failed\n"); return -1; } + #endif if (itti_create_task (TASK_GTPV1_U, >pv1u_eNB_task, NULL) < 0) { LOG_E(GTPU, "Create task for GTPV1U failed\n"); diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index 8c139ae22f..922ff37c85 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -715,7 +715,7 @@ void rx_rf(RU_t *ru,int *frame,int *subframe) { VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ, 0 ); - proc->timestamp_rx = ts-ru->ts_offset; + proc->timestamp_rx = -ru->ts_offset;//ts-ru->ts_offset; if (rxs != fp->samples_per_tti) LOG_E(PHY,"rx_rf: Asked for %d samples, got %d from USRP\n",fp->samples_per_tti,rxs); @@ -728,7 +728,7 @@ void rx_rf(RU_t *ru,int *frame,int *subframe) { if (proc->timestamp_rx - old_ts != fp->samples_per_tti) { //LOG_I(PHY,"rx_rf: rfdevice timing drift of %"PRId64" samples (ts_off %"PRId64")\n",proc->timestamp_rx - old_ts - fp->samples_per_tti,ru->ts_offset); ru->ts_offset += (proc->timestamp_rx - old_ts - fp->samples_per_tti); - proc->timestamp_rx = ts-ru->ts_offset; + proc->timestamp_rx = -ru->ts_offset;//ts-ru->ts_offset; } } From 6b99b1b1e4d20acd9f47197d07abd5e331a2a9a9 Mon Sep 17 00:00:00 2001 From: Wang Tsu-Han Date: Tue, 21 Nov 2017 14:41:36 +0100 Subject: [PATCH 16/63] emulated RF using seperate thread condition signal every time period --- openair1/PHY/defs.h | 18 ++++++++++++---- targets/RT/USER/lte-ru.c | 45 ++++++++++++++++++++++++++++++---------- 2 files changed, 48 insertions(+), 15 deletions(-) diff --git a/openair1/PHY/defs.h b/openair1/PHY/defs.h index 81a4953b15..aa66bd59df 100644 --- a/openair1/PHY/defs.h +++ b/openair1/PHY/defs.h @@ -331,8 +331,10 @@ typedef struct RU_proc_t_s { int instance_cnt_asynch_rxtx; /// \internal This variable is protected by \ref mutex_fep int instance_cnt_fep; - /// \internal This variable is protected by \ref mutex_fep + /// \internal This variable is protected by \ref mutex_feptx int instance_cnt_feptx; + /// This varible is protected by \ref mutex_emulatedRF + int instance_cnt_emulateRF; /// pthread structure for RU FH processing thread pthread_t pthread_FH; pthread_t pthread_FH1; @@ -346,8 +348,10 @@ typedef struct RU_proc_t_s { pthread_t pthread_synch; /// pthread struct for RU RX FEP worker thread pthread_t pthread_fep; - /// pthread struct for RU RX FEPTX worker thread + /// pthread struct for RU TX FEP worker thread pthread_t pthread_feptx; + /// pthread struct for emulated RF + pthread_t pthread_emulateRF; /// pthread structure for asychronous RX/TX processing thread pthread_t pthread_asynch_rxtx; /// flag to indicate first RX acquisition @@ -371,6 +375,8 @@ typedef struct RU_proc_t_s { pthread_attr_t attr_fep; /// pthread attributes for worker feptx thread pthread_attr_t attr_feptx; + /// pthread attributes for emulated RF + pthread_attr_t attr_emulateRF; /// scheduling parameters for RU FH thread struct sched_param sched_param_FH; struct sched_param sched_param_FH1; @@ -397,10 +403,12 @@ typedef struct RU_proc_t_s { pthread_cond_t cond_synch; /// condition variable for asynch RX/TX thread pthread_cond_t cond_asynch_rxtx; - /// condition varaible for RU RX FEP thread + /// condition varible for RU RX FEP thread pthread_cond_t cond_fep; - /// condition varaible for RU RX FEPTX thread + /// condition varible for RU TX FEP thread pthread_cond_t cond_feptx; + /// condition varible for emulated RF + pthread_cond_t cond_emulateRF; /// condition variable for eNB signal pthread_cond_t cond_eNBs; /// mutex for RU FH @@ -422,6 +430,8 @@ typedef struct RU_proc_t_s { pthread_mutex_t mutex_fep; /// mutex for fep TX worker thread pthread_mutex_t mutex_feptx; + /// mutex for emulated RF thread + pthread_mutex_t mutex_emulateRF; /// symbol mask for IF4p5 reception per subframe uint32_t symbol_mask[10]; /// number of slave threads diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index 922ff37c85..158cb68898 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -683,6 +683,24 @@ void fh_if4p5_north_out(RU_t *ru) { if (ru->idx == 0) VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPRX, 0 ); } + +static void* emulatedRF_thread(void* param) { + RU_proc_t *proc = (RU_proc_t *) param; + int microsec = 500; // length of time to sleep, in miliseconds + struct timespec req = {0}; + req.tv_sec = 0; + req.tv_nsec = microsec * 1000L; + wait_sync("emulatedRF_thread"); + while(!oai_exit){ + nanosleep(&req, (struct timespec *)NULL); + pthread_mutex_lock(&proc->mutex_emulateRF); + ++proc->instance_cnt_emulateRF; + pthread_mutex_unlock(&proc->mutex_emulateRF); + pthread_cond_signal(&proc->cond_emulateRF); + } + return 0; +} + void rx_rf(RU_t *ru,int *frame,int *subframe) { RU_proc_t *proc = &ru->proc; @@ -699,11 +717,8 @@ void rx_rf(RU_t *ru,int *frame,int *subframe) { old_ts = proc->timestamp_rx; #ifdef EMULATE_RF - int microsec = 450; // length of time to sleep, in miliseconds - struct timespec req = {0}; - req.tv_sec = 0; - req.tv_nsec = microsec * 1000L; - nanosleep(&req, (struct timespec *)NULL); + wait_on_condition(&proc->mutex_emulateRF,&proc->cond_emulateRF,&proc->instance_cnt_emulateRF,"emulatedRF_thread"); + release_thread(&proc->mutex_emulateRF,&proc->instance_cnt_emulateRF,"emulatedRF_thread"); rxs = fp->samples_per_tti; #else rxs = ru->rfdevice.trx_read_func(&ru->rfdevice, @@ -715,7 +730,7 @@ void rx_rf(RU_t *ru,int *frame,int *subframe) { VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ, 0 ); - proc->timestamp_rx = -ru->ts_offset;//ts-ru->ts_offset; + proc->timestamp_rx = ts-ru->ts_offset; if (rxs != fp->samples_per_tti) LOG_E(PHY,"rx_rf: Asked for %d samples, got %d from USRP\n",fp->samples_per_tti,rxs); @@ -728,7 +743,7 @@ void rx_rf(RU_t *ru,int *frame,int *subframe) { if (proc->timestamp_rx - old_ts != fp->samples_per_tti) { //LOG_I(PHY,"rx_rf: rfdevice timing drift of %"PRId64" samples (ts_off %"PRId64")\n",proc->timestamp_rx - old_ts - fp->samples_per_tti,ru->ts_offset); ru->ts_offset += (proc->timestamp_rx - old_ts - fp->samples_per_tti); - proc->timestamp_rx = -ru->ts_offset;//ts-ru->ts_offset; + proc->timestamp_rx = ts-ru->ts_offset; } } @@ -1405,7 +1420,7 @@ static void* ru_thread_tx( void* param ) { } LOG_D(PHY,"ru_thread_tx: Waiting for TX processing\n"); // wait until eNBs are finished subframe RX n and TX n+4 - wait_on_condition(&proc->mutex_eNBs,&proc->cond_eNBs,&proc->instance_cnt_eNBs,"ru_thread"); + wait_on_condition(&proc->mutex_eNBs,&proc->cond_eNBs,&proc->instance_cnt_eNBs,"ru_thread_tx"); //printf("//////////////////instance_cnt_eNBs = %d\n",proc->instance_cnt_eNBs);//////////////////********* #ifdef EMULATE_RF @@ -1421,7 +1436,7 @@ static void* ru_thread_tx( void* param ) { if (ru->fh_north_out) ru->fh_north_out(ru); #endif - release_thread(&proc->mutex_eNBs,&proc->instance_cnt_eNBs,"ru_thread"); + release_thread(&proc->mutex_eNBs,&proc->instance_cnt_eNBs,"ru_thread_tx"); } return 0; @@ -1706,7 +1721,7 @@ void init_RU_proc(RU_t *ru) { int i=0; RU_proc_t *proc; - pthread_attr_t *attr_FH=NULL,*attr_FH1=NULL,*attr_prach=NULL,*attr_asynch=NULL,*attr_synch=NULL; + pthread_attr_t *attr_FH=NULL,*attr_FH1=NULL,*attr_prach=NULL,*attr_asynch=NULL,*attr_synch=NULL,*attr_emulateRF=NULL; //pthread_attr_t *attr_fep=NULL; #ifdef Rel14 pthread_attr_t *attr_prach_br=NULL; @@ -1724,6 +1739,7 @@ void init_RU_proc(RU_t *ru) { proc->instance_cnt_synch = -1; proc->instance_cnt_FH = -1; proc->instance_cnt_FH1 = -1; + proc->instance_cnt_emulateRF = -1; proc->instance_cnt_asynch_rxtx = -1; proc->instance_cnt_eNBs = -1; proc->first_rx = 1; @@ -1739,15 +1755,18 @@ void init_RU_proc(RU_t *ru) { pthread_mutex_init( &proc->mutex_synch,NULL); pthread_mutex_init( &proc->mutex_FH,NULL); pthread_mutex_init( &proc->mutex_FH1,NULL); + pthread_mutex_init( &proc->mutex_emulateRF,NULL); pthread_cond_init( &proc->cond_prach, NULL); pthread_cond_init( &proc->cond_FH, NULL); pthread_cond_init( &proc->cond_FH1, NULL); + pthread_cond_init( &proc->cond_emulateRF, NULL); pthread_cond_init( &proc->cond_asynch_rxtx, NULL); pthread_cond_init( &proc->cond_synch,NULL); pthread_attr_init( &proc->attr_FH); pthread_attr_init( &proc->attr_FH1); + pthread_attr_init( &proc->attr_emulateRF); pthread_attr_init( &proc->attr_prach); pthread_attr_init( &proc->attr_synch); pthread_attr_init( &proc->attr_asynch_rxtx); @@ -1766,12 +1785,16 @@ void init_RU_proc(RU_t *ru) { attr_prach = &proc->attr_prach; attr_synch = &proc->attr_synch; attr_asynch = &proc->attr_asynch_rxtx; + attr_emulateRF = &proc->attr_emulateRF; #ifdef Rel14 attr_prach_br = &proc->attr_prach_br; #endif #endif - pthread_create( &proc->pthread_FH, attr_FH, ru_thread, (void*)ru );\ + pthread_create( &proc->pthread_FH, attr_FH, ru_thread, (void*)ru ); +#ifdef EMULATE_RF + pthread_create( &proc->pthread_emulateRF, attr_emulateRF, emulatedRF_thread, (void*)proc ); +#endif if (fh_two_thread==1) pthread_create( &proc->pthread_FH1, attr_FH1, ru_thread_tx, (void*)ru ); From 22911600a817da48596d0a3225e318a2d88024ee Mon Sep 17 00:00:00 2001 From: Wang Tsu-Han Date: Fri, 24 Nov 2017 14:31:19 +0100 Subject: [PATCH 17/63] Adding measurment for waking up the thread --- openair1/PHY/LTE_TRANSPORT/dlsch_coding.c | 30 ++++++++++++++++++++--- openair1/PHY/LTE_TRANSPORT/proto.h | 4 +++ openair1/PHY/defs.h | 4 ++- openair1/SCHED/phy_procedures_lte_eNb.c | 2 ++ 4 files changed, 35 insertions(+), 5 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c index d7e106c2f4..407c3e9726 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c @@ -463,11 +463,14 @@ void *te_thread(void *param) { CPU_SET(4, &cpuset); pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); - eNB_proc_t *proc = &((te_params *)param)->eNB->proc; + PHY_VARS_eNB *eNB = ((te_params *)param)->eNB; + eNB_proc_t *proc = &eNB->proc; + time_stats_t *te_wakeup_stats0 = &eNB->dlsch_turbo_encoding_wakeup_stats0; while (!oai_exit) { if (wait_on_condition(&proc->mutex_te[0],&proc->cond_te[0],&proc->instance_cnt_te[0],"te thread")<0) break; + stop_meas(te_wakeup_stats0); dlsch_encoding_2threads0((te_params*)param); @@ -478,6 +481,10 @@ void *te_thread(void *param) { exit_fun( "ERROR pthread_cond_signal" ); return(NULL); } + if(opp_enabled == 1 && te_wakeup_stats0->diff_now>50*3000){ + print_meas_now(te_wakeup_stats0,"coding_wakeup",stderr); + printf("frame_rx: %d subframe_rx: %d \n",proc->frame_rx,proc->subframe_rx); + } } return(NULL); @@ -494,12 +501,15 @@ void *te_thread1(void *param) { CPU_SET(7, &cpuset); pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); - eNB_proc_t *proc = &((te_params *)param)->eNB->proc; + PHY_VARS_eNB *eNB = ((te_params *)param)->eNB; + eNB_proc_t *proc = &eNB->proc; + time_stats_t *te_wakeup_stats1 = &eNB->dlsch_turbo_encoding_wakeup_stats1; while (!oai_exit) { if (wait_on_condition(&proc->mutex_te[1],&proc->cond_te[1],&proc->instance_cnt_te[1],"te thread 1")<0) break; + stop_meas(te_wakeup_stats1); dlsch_encoding_2threads1((te_params*)param); @@ -510,6 +520,10 @@ void *te_thread1(void *param) { exit_fun( "ERROR pthread_cond_signal" ); return(NULL); } + if(opp_enabled == 1 && te_wakeup_stats1->diff_now>50*3000){ + print_meas_now(te_wakeup_stats1,"coding_wakeup",stderr); + printf("delay for waking up in frame_rx: %d subframe_rx: %d \n",proc->frame_rx,proc->subframe_rx); + } } return(NULL); @@ -524,6 +538,8 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB, time_stats_t *rm_stats, time_stats_t *te_stats, time_stats_t *te_wait_stats, + time_stats_t *te_wakeup_stats0, + time_stats_t *te_wakeup_stats1, time_stats_t *i_stats) { @@ -591,6 +607,7 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB, exit_fun( "ERROR pthread_cond_signal" ); return (-1); } + start_meas(te_wakeup_stats0); pthread_mutex_unlock( &proc->mutex_te[0] ); //////////////////////////////////////////////////////////////// @@ -614,6 +631,7 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB, exit_fun( "ERROR pthread_cond_signal" ); return (-1); } + start_meas(te_wakeup_stats1); pthread_mutex_unlock( &proc->mutex_te[1] ); @@ -727,7 +745,7 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB, stop_meas(te_wait_stats); if(opp_enabled == 1 && te_wait_stats->diff_now>50*3000){ print_meas_now(te_wait_stats,"coding_wait",stderr); - printf("frame_rx: %d subframe_rx: %d \n",proc->frame_rx,proc->subframe_rx); + printf("delay in wait on codition in frame_rx: %d subframe_rx: %d \n",proc->frame_rx,proc->subframe_rx); } @@ -744,6 +762,8 @@ int dlsch_encoding_all(PHY_VARS_eNB *eNB, time_stats_t *rm_stats, time_stats_t *te_stats, time_stats_t *te_wait_stats, + time_stats_t *te_wakeup_stats0, + time_stats_t *te_wakeup_stats1, time_stats_t *i_stats) { int encoding_return = 0; @@ -776,7 +796,9 @@ int dlsch_encoding_all(PHY_VARS_eNB *eNB, subframe, rm_stats, te_stats, - te_wait_stats, + te_wait_stats, + te_wakeup_stats0, + te_wakeup_stats1, i_stats); } else diff --git a/openair1/PHY/LTE_TRANSPORT/proto.h b/openair1/PHY/LTE_TRANSPORT/proto.h index 6da6653492..87aa2188ff 100644 --- a/openair1/PHY/LTE_TRANSPORT/proto.h +++ b/openair1/PHY/LTE_TRANSPORT/proto.h @@ -131,6 +131,8 @@ int32_t dlsch_encoding_all(PHY_VARS_eNB *eNB, time_stats_t *rm_stats, time_stats_t *te_stats, time_stats_t *te_wait_stats, + time_stats_t *te_wakeup_stats0, + time_stats_t *te_wakeup_stats1, time_stats_t *i_stats); int32_t dlsch_encoding_SIC(PHY_VARS_UE *ue, @@ -177,6 +179,8 @@ int32_t dlsch_encoding_2threads(PHY_VARS_eNB *eNB, time_stats_t *rm_stats, time_stats_t *te_stats, time_stats_t *te_wait_stats, + time_stats_t *te_wakeup_stats0, + time_stats_t *te_wakeup_stats1, time_stats_t *i_stats); void dlsch_encoding_emul(PHY_VARS_eNB *phy_vars_eNB, diff --git a/openair1/PHY/defs.h b/openair1/PHY/defs.h index aa66bd59df..8c1b02ec7e 100644 --- a/openair1/PHY/defs.h +++ b/openair1/PHY/defs.h @@ -957,7 +957,7 @@ typedef struct PHY_VARS_eNB_s { eth_params_t eth_params; 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 *); + 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 *); int (*start_if)(struct RU_t_s *ru,struct PHY_VARS_eNB_s *eNB); uint8_t local_flag; LTE_DL_FRAME_PARMS frame_parms; @@ -1137,6 +1137,8 @@ typedef struct PHY_VARS_eNB_s { time_stats_t dlsch_rate_matching_stats; time_stats_t dlsch_turbo_encoding_stats; time_stats_t dlsch_turbo_encoding_waiting_stats; + time_stats_t dlsch_turbo_encoding_wakeup_stats0; + time_stats_t dlsch_turbo_encoding_wakeup_stats1; time_stats_t dlsch_interleaving_stats; time_stats_t rx_dft_stats; diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index c3268cdccd..57e93fd6c2 100644 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -346,6 +346,8 @@ void pdsch_procedures(PHY_VARS_eNB *eNB, &eNB->dlsch_rate_matching_stats, &eNB->dlsch_turbo_encoding_stats, &eNB->dlsch_turbo_encoding_waiting_stats, + &eNB->dlsch_turbo_encoding_wakeup_stats0, + &eNB->dlsch_turbo_encoding_wakeup_stats1, &eNB->dlsch_interleaving_stats); stop_meas(&eNB->dlsch_encoding_stats); // 36-211 From d174e15ac890b15fb42336bf6db3003211d9336a Mon Sep 17 00:00:00 2001 From: Wang Tsu-Han Date: Mon, 27 Nov 2017 11:27:10 +0100 Subject: [PATCH 18/63] Measure timing wait for FEP and FEPTX --- openair1/PHY/LTE_TRANSPORT/dlsch_coding.c | 24 +++++++++++------------ openair1/PHY/defs.h | 8 ++++++++ openair1/SCHED/ru_procedures.c | 24 +++++++++++++++++++++++ 3 files changed, 44 insertions(+), 12 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c index 407c3e9726..a401111bc8 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c @@ -470,7 +470,7 @@ void *te_thread(void *param) { if (wait_on_condition(&proc->mutex_te[0],&proc->cond_te[0],&proc->instance_cnt_te[0],"te thread")<0) break; - stop_meas(te_wakeup_stats0); + //stop_meas(te_wakeup_stats0); dlsch_encoding_2threads0((te_params*)param); @@ -481,10 +481,10 @@ void *te_thread(void *param) { exit_fun( "ERROR pthread_cond_signal" ); return(NULL); } - if(opp_enabled == 1 && te_wakeup_stats0->diff_now>50*3000){ + /*if(opp_enabled == 1 && te_wakeup_stats0->diff_now>50*3000){ print_meas_now(te_wakeup_stats0,"coding_wakeup",stderr); - printf("frame_rx: %d subframe_rx: %d \n",proc->frame_rx,proc->subframe_rx); - } + printf("te_thread0 delay for waking up in frame_rx: %d subframe_rx: %d \n",proc->frame_rx,proc->subframe_rx); + }*/ } return(NULL); @@ -509,7 +509,7 @@ void *te_thread1(void *param) { if (wait_on_condition(&proc->mutex_te[1],&proc->cond_te[1],&proc->instance_cnt_te[1],"te thread 1")<0) break; - stop_meas(te_wakeup_stats1); + //stop_meas(te_wakeup_stats1); dlsch_encoding_2threads1((te_params*)param); @@ -520,10 +520,10 @@ void *te_thread1(void *param) { exit_fun( "ERROR pthread_cond_signal" ); return(NULL); } - if(opp_enabled == 1 && te_wakeup_stats1->diff_now>50*3000){ + /*if(opp_enabled == 1 && te_wakeup_stats1->diff_now>50*3000){ print_meas_now(te_wakeup_stats1,"coding_wakeup",stderr); - printf("delay for waking up in frame_rx: %d subframe_rx: %d \n",proc->frame_rx,proc->subframe_rx); - } + printf("te_thread1 delay for waking up in frame_rx: %d subframe_rx: %d \n",proc->frame_rx,proc->subframe_rx); + }*/ } return(NULL); @@ -607,7 +607,7 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB, exit_fun( "ERROR pthread_cond_signal" ); return (-1); } - start_meas(te_wakeup_stats0); + //start_meas(te_wakeup_stats0); pthread_mutex_unlock( &proc->mutex_te[0] ); //////////////////////////////////////////////////////////////// @@ -631,7 +631,7 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB, exit_fun( "ERROR pthread_cond_signal" ); return (-1); } - start_meas(te_wakeup_stats1); + //start_meas(te_wakeup_stats1); pthread_mutex_unlock( &proc->mutex_te[1] ); @@ -743,9 +743,9 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB, wait_on_busy_condition(&proc->mutex_te[0],&proc->cond_te[0],&proc->instance_cnt_te[0],"te thread"); wait_on_busy_condition(&proc->mutex_te[1],&proc->cond_te[1],&proc->instance_cnt_te[1],"te thread1"); stop_meas(te_wait_stats); - if(opp_enabled == 1 && te_wait_stats->diff_now>50*3000){ + if(opp_enabled == 1 && te_wait_stats->diff_now>100*3000){ print_meas_now(te_wait_stats,"coding_wait",stderr); - printf("delay in wait on codition in frame_rx: %d subframe_rx: %d \n",proc->frame_rx,proc->subframe_rx); + printf("delay in wait on codition in frame_rx: %d \n",proc->frame_rx); } diff --git a/openair1/PHY/defs.h b/openair1/PHY/defs.h index 8c1b02ec7e..4339d98b24 100644 --- a/openair1/PHY/defs.h +++ b/openair1/PHY/defs.h @@ -773,6 +773,14 @@ typedef struct RU_t_s{ time_stats_t ofdm_demod_stats; /// Timing statistics (TX) time_stats_t ofdm_mod_stats; + /// Timing wait statistics + time_stats_t ofdm_demod_wait_stats; + /// Timing wakeup statistics + time_stats_t ofdm_demod_wakeup_stats; + /// Timing wait statistics (TX) + time_stats_t ofdm_mod_wait_stats; + /// Timing wakeup statistics (TX) + time_stats_t ofdm_mod_wakeup_stats; /// RX and TX buffers for precoder output RU_COMMON common; /// beamforming weight vectors per eNB diff --git a/openair1/SCHED/ru_procedures.c b/openair1/SCHED/ru_procedures.c index f60f066ef5..9e3093e2ba 100644 --- a/openair1/SCHED/ru_procedures.c +++ b/openair1/SCHED/ru_procedures.c @@ -152,6 +152,7 @@ static void *feptx_thread(void *param) { while (!oai_exit) { if (wait_on_condition(&proc->mutex_feptx,&proc->cond_feptx,&proc->instance_cnt_feptx,"feptx thread")<0) break; + //stop_meas(&ru->ofdm_mod_wakeup_stats); feptx0(ru,1); if (release_thread(&proc->mutex_feptx,&proc->instance_cnt_feptx,"feptx thread")<0) break; @@ -160,6 +161,10 @@ static void *feptx_thread(void *param) { exit_fun( "ERROR pthread_cond_signal" ); return NULL; } + /*if(opp_enabled == 1 && ru->ofdm_mod_wakeup_stats.diff_now>30*3000){ + print_meas_now(&ru->ofdm_mod_wakeup_stats,"fep wakeup",stderr); + printf("delay in fep wakeup in frame_tx: %d subframe_rx: %d \n",proc->frame_tx,proc->subframe_tx); + }*/ } @@ -204,13 +209,20 @@ void feptx_ofdm_2thread(RU_t *ru) { exit_fun( "ERROR pthread_cond_signal" ); return; } + //start_meas(&ru->ofdm_mod_wakeup_stats); pthread_mutex_unlock( &proc->mutex_feptx ); } // call first slot in this thread feptx0(ru,0); + start_meas(&ru->ofdm_mod_wait_stats); wait_on_busy_condition(&proc->mutex_feptx,&proc->cond_feptx,&proc->instance_cnt_feptx,"feptx thread"); + stop_meas(&ru->ofdm_mod_wait_stats); + if(opp_enabled == 1 && ru->ofdm_mod_wait_stats.diff_now>30*3000){ + print_meas_now(&ru->ofdm_mod_wait_stats,"fep wakeup",stderr); + printf("delay in feptx wait on codition in frame_rx: %d subframe_rx: %d \n",proc->frame_tx,proc->subframe_tx); + } stop_meas(&ru->ofdm_mod_stats); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPTX_OFDM , 0 ); @@ -432,6 +444,7 @@ static void *fep_thread(void *param) { while (!oai_exit) { if (wait_on_condition(&proc->mutex_fep,&proc->cond_fep,&proc->instance_cnt_fep,"fep thread")<0) break; + //stop_meas(&ru->ofdm_demod_wakeup_stats); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPRX1, 1 ); fep0(ru,0); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPRX1, 0 ); @@ -442,6 +455,10 @@ static void *fep_thread(void *param) { exit_fun( "ERROR pthread_cond_signal" ); return NULL; } + /*if(opp_enabled == 1 && ru->ofdm_demod_wakeup_stats.diff_now>30*3000){ + print_meas_now(&ru->ofdm_demod_wakeup_stats,"fep wakeup",stderr); + printf("delay in fep wakeup in frame_rx: %d subframe_rx: %d \n",proc->frame_rx,proc->subframe_rx); + }*/ } @@ -509,13 +526,20 @@ void ru_fep_full_2thread(RU_t *ru) { exit_fun( "ERROR pthread_cond_signal" ); return; } + //start_meas(&ru->ofdm_demod_wakeup_stats); pthread_mutex_unlock( &proc->mutex_fep ); // call second slot in this symbol fep0(ru,1); + start_meas(&ru->ofdm_demod_wait_stats); wait_on_busy_condition(&proc->mutex_fep,&proc->cond_fep,&proc->instance_cnt_fep,"fep thread"); + stop_meas(&ru->ofdm_demod_wait_stats); + if(opp_enabled == 1 && ru->ofdm_demod_wakeup_stats.diff_now>30*3000){ + print_meas_now(&ru->ofdm_demod_wakeup_stats,"fep wakeup",stderr); + printf("delay in fep wait on codition in frame_rx: %d subframe_rx: %d \n",proc->frame_rx,proc->subframe_rx); + } stop_meas(&ru->ofdm_demod_stats); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPRX, 0 ); From 7ac9d2ab81ea9892c720d2b48435e51e1a1e204b Mon Sep 17 00:00:00 2001 From: Wang Tsu-Han Date: Mon, 11 Dec 2017 14:27:26 +0100 Subject: [PATCH 19/63] Deadline scheduling for 40MHz --- openair1/PHY/LTE_TRANSPORT/dlsch_coding.c | 12 ++++----- openair1/SCHED/ru_procedures.c | 19 +++++++++----- targets/RT/USER/lte-enb.c | 14 +++++----- targets/RT/USER/lte-ru.c | 31 ++++++++++++++++------- targets/RT/USER/rt_wrapper.c | 2 ++ 5 files changed, 50 insertions(+), 28 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c index a401111bc8..dfedb97e9c 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c @@ -456,12 +456,12 @@ void *te_thread(void *param) { cpu_set_t cpuset; CPU_ZERO(&cpuset); - //thread_top_init("te_thread",1,870000,1000000,1000000); + thread_top_init("te_thread",1,200000,250000,500000); pthread_setname_np( pthread_self(),"te processing"); LOG_I(PHY,"thread te created id=%ld\n", syscall(__NR_gettid)); - CPU_SET(4, &cpuset); - pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); + //CPU_SET(4, &cpuset); + //pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); PHY_VARS_eNB *eNB = ((te_params *)param)->eNB; eNB_proc_t *proc = &eNB->proc; @@ -494,12 +494,12 @@ void *te_thread1(void *param) { cpu_set_t cpuset; CPU_ZERO(&cpuset); - //thread_top_init("te_thread1",1,870000,1000000,1000000); + thread_top_init("te_thread1",1,200000,250000,500000); pthread_setname_np( pthread_self(),"te processing 1"); LOG_I(PHY,"thread te 1 created id=%ld\n", syscall(__NR_gettid)); - CPU_SET(7, &cpuset); - pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); + //CPU_SET(7, &cpuset); + //pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); PHY_VARS_eNB *eNB = ((te_params *)param)->eNB; eNB_proc_t *proc = &eNB->proc; diff --git a/openair1/SCHED/ru_procedures.c b/openair1/SCHED/ru_procedures.c index 9e3093e2ba..386cdc4153 100644 --- a/openair1/SCHED/ru_procedures.c +++ b/openair1/SCHED/ru_procedures.c @@ -142,12 +142,15 @@ static void *feptx_thread(void *param) { RU_proc_t *proc = &ru->proc; cpu_set_t cpuset; CPU_ZERO(&cpuset); - - CPU_SET(6, &cpuset); - pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); + + thread_top_init("feptx_thread",1,85000,120000,500000); + pthread_setname_np( pthread_self(),"feptx processing"); + LOG_I(PHY,"thread feptx created id=%ld\n", syscall(__NR_gettid)); + //CPU_SET(6, &cpuset); + //pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); - thread_top_init("feptx_thread",0,870000,1000000,1000000); + while (!oai_exit) { @@ -434,12 +437,14 @@ static void *fep_thread(void *param) { RU_t *ru = (RU_t *)param; RU_proc_t *proc = &ru->proc; - thread_top_init("fep_thread",0,870000,1000000,1000000); + thread_top_init("fep_thread",1,100000,120000,5000000); + pthread_setname_np( pthread_self(),"fep processing"); + LOG_I(PHY,"thread fep created id=%ld\n", syscall(__NR_gettid)); cpu_set_t cpuset; CPU_ZERO(&cpuset); - CPU_SET(2, &cpuset); - pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); + //CPU_SET(2, &cpuset); + //pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); while (!oai_exit) { diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index ff489dbd8b..1bd4f751f9 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -205,7 +205,7 @@ static void* tx_thread(void* param) { char thread_name[100]; sprintf(thread_name,"TXnp4_%d\n",&eNB->proc.proc_rxtx[0] == proc ? 0 : 1); - thread_top_init(thread_name,1,850000L,1000000L,2000000L); + thread_top_init(thread_name,1,470000,500000,500000); while (!oai_exit) { @@ -258,10 +258,12 @@ static void* eNB_thread_rxtx( void* param ) { sprintf(thread_name,"RXn_TXnp4_%d\n",&eNB->proc.proc_rxtx[0] == proc ? 0 : 1); - thread_top_init(thread_name,1,850000L,1000000L,2000000L); + thread_top_init(thread_name,1,470000,500000,500000); + pthread_setname_np( pthread_self(),"rxtx processing"); + LOG_I(PHY,"thread rxtx created id=%ld\n", syscall(__NR_gettid)); - CPU_SET(3, &cpuset); - pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); + //CPU_SET(3, &cpuset); + //pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); while (!oai_exit) { VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_eNB_PROC_RXTX0+(proc->subframe_rx&1), 0 ); @@ -621,7 +623,7 @@ static void* eNB_thread_prach( void* param ) { // set default return value eNB_thread_prach_status = 0; - thread_top_init("eNB_thread_prach",1,500000L,1000000L,20000000L); + thread_top_init("eNB_thread_prach",1,500000,1000000,20000000); while (!oai_exit) { @@ -663,7 +665,7 @@ static void* eNB_thread_prach_br( void* param ) { // set default return value eNB_thread_prach_status = 0; - thread_top_init("eNB_thread_prach_br",1,500000L,1000000L,20000000L); + thread_top_init("eNB_thread_prach_br",1,500000,1000000,20000000); while (!oai_exit) { diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index 158cb68898..fd59e1ae6f 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -690,6 +690,17 @@ static void* emulatedRF_thread(void* param) { struct timespec req = {0}; req.tv_sec = 0; req.tv_nsec = microsec * 1000L; + cpu_set_t cpuset; + CPU_SET(1,&cpuset); + pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); + + int policy; + struct sched_param sparam; + memset(&sparam, 0, sizeof(sparam)); + sparam.sched_priority = sched_get_priority_max(SCHED_FIFO); + policy = SCHED_FIFO ; + pthread_setschedparam(pthread_self(), policy, &sparam); + wait_sync("emulatedRF_thread"); while(!oai_exit){ nanosleep(&req, (struct timespec *)NULL); @@ -878,7 +889,7 @@ static void* ru_thread_asynch_rxtx( void* param ) { int subframe=0, frame=0; - thread_top_init("ru_thread_asynch_rxtx",1,870000L,1000000L,1000000L); + thread_top_init("ru_thread_asynch_rxtx",1,870000,1000000,1000000); // wait for top-level synchronization and do one acquisition to get timestamp for setting frame/subframe @@ -975,7 +986,7 @@ static void* ru_thread_prach( void* param ) { // set default return value ru_thread_prach_status = 0; - thread_top_init("ru_thread_prach",1,500000L,1000000L,20000000L); + thread_top_init("ru_thread_prach",1,500000,1000000,20000000); while (!oai_exit) { @@ -1014,7 +1025,7 @@ static void* ru_thread_prach_br( void* param ) { // set default return value ru_thread_prach_status = 0; - thread_top_init("ru_thread_prach_br",1,500000L,1000000L,20000000L); + thread_top_init("ru_thread_prach_br",1,500000,1000000,20000000); while (!oai_exit) { @@ -1398,10 +1409,10 @@ static void* ru_thread_tx( void* param ) { CPU_ZERO(&cpuset); - thread_top_init("ru_thread_tx",1,870000L,1000000L,1000000L); + thread_top_init("ru_thread_tx",1,400000,500000,500000); - CPU_SET(5, &cpuset); - pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); + //CPU_SET(5, &cpuset); + //pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); wait_on_condition(&proc->mutex_FH1,&proc->cond_FH1,&proc->instance_cnt_FH1,"ru_thread_tx"); @@ -1461,10 +1472,12 @@ static void* ru_thread( void* param ) { // set default return value - thread_top_init("ru_thread",0,870000,1000000,1000000); + thread_top_init("ru_thread",0,400000,500000,500000); - CPU_SET(1, &cpuset); - pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); + //CPU_SET(1, &cpuset); + //pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); + pthread_setname_np( pthread_self(),"ru thread"); + LOG_I(PHY,"thread ru created id=%ld\n", syscall(__NR_gettid)); LOG_I(PHY,"Starting RU %d (%s,%s),\n",ru->idx,eNB_functions[ru->function],eNB_timing[ru->if_timing]); diff --git a/targets/RT/USER/rt_wrapper.c b/targets/RT/USER/rt_wrapper.c index e50b0ae34f..7010abb5c0 100644 --- a/targets/RT/USER/rt_wrapper.c +++ b/targets/RT/USER/rt_wrapper.c @@ -43,6 +43,7 @@ #include #include #include "rt_wrapper.h" +#include static int latency_target_fd = -1; static int32_t latency_target_value = 0; @@ -281,6 +282,7 @@ void thread_top_init(char *thread_name, if (sched_setattr(0, &attr, flags) < 0 ) { perror("[SCHED] eNB tx thread: sched_setattr failed\n"); + fprintf(stderr,"sched_setattr Error = %s",strerror(errno)); exit(1); } From d82a0d900d8aafed464d939bb0d97dcc74a544f7 Mon Sep 17 00:00:00 2001 From: Wang Tsu-Han Date: Tue, 12 Dec 2017 15:24:00 +0100 Subject: [PATCH 20/63] adding ulsch_decoding multiy threading --- openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c | 33 ++++++++++++--------- openair2/LAYER2/MAC/eNB_scheduler_phytest.c | 2 +- targets/RT/USER/lte-enb.c | 8 ++--- targets/RT/USER/lte-ru.c | 2 +- targets/RT/USER/lte-softmodem.c | 2 +- 5 files changed, 26 insertions(+), 21 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c index 277e1918f2..89cb3756c4 100644 --- a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c +++ b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c @@ -207,20 +207,6 @@ uint8_t extract_cqi_crc(uint8_t *cqi,uint8_t CQI_LENGTH) -/*int ulsch_decoding_data_all(PHY_VARS_eNB *eNB,int UE_id,int harq_pid,int llr8_flag) -{ - int value = 0; - if() - { - value = ulsch_decoding_data_2thread(eNB,UE_id,harq_pid,llr8_flag); - } - else - { - value = ulsch_decoding_data(eNB,UE_id,harq_pid,llr8_flag); - } - return value; -}*/ - int ulsch_decoding_data_2thread0(td_params* tdp) { @@ -429,6 +415,9 @@ void *td_thread(void *param) { pthread_setname_np( pthread_self(), "td processing"); PHY_VARS_eNB *eNB = ((td_params*)param)->eNB; eNB_proc_t *proc = &eNB->proc; + + pthread_setname_np( pthread_self(),"td processing"); + LOG_I(PHY,"thread td created id=%ld\n", syscall(__NR_gettid)); while (!oai_exit) { @@ -820,6 +809,22 @@ int ulsch_decoding_data(PHY_VARS_eNB *eNB,int UE_id,int harq_pid,int llr8_flag) return(ret); } +int ulsch_decoding_data_all(PHY_VARS_eNB *eNB,int UE_id,int harq_pid,int llr8_flag) +{ + int ret = 0; + LTE_eNB_ULSCH_t *ulsch = eNB->ulsch[UE_id]; + LTE_UL_eNB_HARQ_t *ulsch_harq = ulsch->harq_processes[harq_pid]; + if(ulsch_harq->C>3) + { + ret = ulsch_decoding_data_2thread(eNB,UE_id,harq_pid,llr8_flag); + } + else + { + ret = ulsch_decoding_data(eNB,UE_id,harq_pid,llr8_flag); + } + return ret; +} + static inline unsigned int lte_gold_unscram(unsigned int *x1, unsigned int *x2, unsigned char reset) __attribute__((always_inline)); static inline unsigned int lte_gold_unscram(unsigned int *x1, unsigned int *x2, unsigned char reset) { diff --git a/openair2/LAYER2/MAC/eNB_scheduler_phytest.c b/openair2/LAYER2/MAC/eNB_scheduler_phytest.c index 348fb2be46..203358e0e1 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_phytest.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_phytest.c @@ -71,7 +71,7 @@ schedule_ue_spec_phy_test( uint16_t rnti = 0x1235; uint32_t rb_alloc = 0x1FFFFFFF; int32_t tpc = 1; - int32_t mcs = 22; + int32_t mcs = 28; int32_t cqi = 15; int32_t ndi = subframeP/5; int32_t dai = 0; diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 1bd4f751f9..636fa9d9cf 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -719,7 +719,7 @@ void init_eNB_proc(int inst) { PHY_VARS_eNB *eNB; eNB_proc_t *proc; eNB_rxtx_proc_t *proc_rxtx; - pthread_attr_t *attr0=NULL,*attr1=NULL,*attr_prach=NULL,*attr_te=NULL,*attr_te1=NULL;//*attr_td=NULL; + pthread_attr_t *attr0=NULL,*attr1=NULL,*attr_prach=NULL,*attr_te=NULL,*attr_te1=NULL,*attr_td=NULL; #ifdef Rel14 pthread_attr_t *attr_prach_br=NULL; #endif @@ -783,7 +783,7 @@ void init_eNB_proc(int inst) { // attr_td = &proc->attr_td; // attr_te = &proc->attr_te; #endif - //attr_td = &proc->attr_td; + attr_td = &proc->attr_td; attr_te = &proc->attr_te[0]; attr_te1 = &proc->attr_te[1]; pthread_create( &proc_rxtx[0].pthread_rxtx, attr0, eNB_thread_rxtx, proc ); @@ -809,7 +809,7 @@ void init_eNB_proc(int inst) { //////////////////////////////////////need to modified////////////////***** init_te_thread(eNB,attr_te,attr_te1); - //init_td_thread(eNB,attr_td); + init_td_thread(eNB,attr_td); if (opp_enabled == 1) pthread_create(&proc->process_stats_thread,NULL,process_stats_thread,(void*)eNB); @@ -1070,7 +1070,7 @@ void init_eNB(int single_thread_flag,int wait_for_sync) { #endif - eNB->td = ulsch_decoding_data;//(get_nprocs()<=4) ? ulsch_decoding_data : ulsch_decoding_data_2thread; + eNB->td = ulsch_decoding_data_all;//(get_nprocs()<=4) ? ulsch_decoding_data : ulsch_decoding_data_2thread; eNB->te = dlsch_encoding_all;//(get_nprocs()<=4) ? dlsch_encoding : dlsch_encoding_2threads; diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index fd59e1ae6f..8533b05001 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -689,7 +689,7 @@ static void* emulatedRF_thread(void* param) { int microsec = 500; // length of time to sleep, in miliseconds struct timespec req = {0}; req.tv_sec = 0; - req.tv_nsec = microsec * 1000L; + req.tv_nsec = ((microsec * 1000L)/numerology); cpu_set_t cpuset; CPU_SET(1,&cpuset); pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index e21fd12428..cb2aee9df4 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -206,7 +206,7 @@ extern void reset_opp_meas(void); extern void print_opp_meas(void); int transmission_mode=1; -int numerology = 0; +int numerology = 2; int fh_two_thread = 1; From 79b11d6b93c99f321dad704468aa3d84ecc67ac9 Mon Sep 17 00:00:00 2001 From: Wang Tsu-Han Date: Tue, 12 Dec 2017 16:23:38 +0100 Subject: [PATCH 21/63] Bug fix for ulsch_decoding --- openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c index 89cb3756c4..55e44fa8bf 100644 --- a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c +++ b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c @@ -31,7 +31,7 @@ */ //#include "defs.h" - +#include #include "PHY/defs.h" #include "PHY/extern.h" #include "PHY/CODING/extern.h" @@ -412,10 +412,12 @@ int ulsch_decoding_data_2thread0(td_params* tdp) { extern int oai_exit; void *td_thread(void *param) { - pthread_setname_np( pthread_self(), "td processing"); PHY_VARS_eNB *eNB = ((td_params*)param)->eNB; eNB_proc_t *proc = &eNB->proc; + cpu_set_t cpuset; + CPU_ZERO(&cpuset); + thread_top_init("td_thread",1,200000,250000,500000); pthread_setname_np( pthread_self(),"td processing"); LOG_I(PHY,"thread td created id=%ld\n", syscall(__NR_gettid)); From 22e7b1e6da306056819c5562e4c7d124455dfe8f Mon Sep 17 00:00:00 2001 From: Wang Tsu-Han Date: Thu, 14 Dec 2017 15:29:05 +0100 Subject: [PATCH 22/63] extending dlsch_coding into four thread --- openair1/PHY/LTE_TRANSPORT/dlsch_coding.c | 172 +++++++++++++++++++++- openair1/PHY/defs.h | 14 +- openair1/SCHED/phy_procedures_lte_eNb.c | 10 ++ targets/RT/USER/lte-ru.c | 2 +- 4 files changed, 182 insertions(+), 16 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c index dfedb97e9c..5438dd5f9f 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c @@ -291,7 +291,7 @@ int dlsch_encoding_2threads0(te_params *tep) { if (dlsch->harq_processes[harq_pid]->round == 0) { // this is a new packet - for (r=0; rharq_processes[harq_pid]->C/3; r++) { + for (r=0; r<(dlsch->harq_processes[harq_pid]->C>>2); r++) { if (rharq_processes[harq_pid]->Cminus) Kr = dlsch->harq_processes[harq_pid]->Kminus; @@ -334,7 +334,7 @@ int dlsch_encoding_2threads0(te_params *tep) { // Fill in the "e"-sequence from 36-212, V8.6 2009-03, p. 16-17 (for each "e") and concatenate the // outputs for each code segment, see Section 5.1.5 p.20 - for (r=0; rharq_processes[harq_pid]->C/3; r++) { + for (r=0; r<(dlsch->harq_processes[harq_pid]->C>>2); r++) { r_offset += lte_rate_matching_turbo(dlsch->harq_processes[harq_pid]->RTC[r], G, //G dlsch->harq_processes[harq_pid]->w[r], @@ -373,7 +373,7 @@ int dlsch_encoding_2threads1(te_params *tep) { if (dlsch->harq_processes[harq_pid]->round == 0) { // this is a new packet - for (r=dlsch->harq_processes[harq_pid]->C/3; rharq_processes[harq_pid]->C/3*2; r++) { + for (r=(dlsch->harq_processes[harq_pid]->C>>2); r<(dlsch->harq_processes[harq_pid]->C>>1); r++) { if (rharq_processes[harq_pid]->Cminus) Kr = dlsch->harq_processes[harq_pid]->Kminus; @@ -416,8 +416,103 @@ int dlsch_encoding_2threads1(te_params *tep) { // Fill in the "e"-sequence from 36-212, V8.6 2009-03, p. 16-17 (for each "e") and concatenate the // outputs for each code segment, see Section 5.1.5 p.20 - for (r=0,r_offset=0; rharq_processes[harq_pid]->C/3*2; r++) { - if(r<(dlsch->harq_processes[harq_pid]->C/3)){ + for (r=0,r_offset=0; r<(dlsch->harq_processes[harq_pid]->C>>1); r++) { + if(r<(dlsch->harq_processes[harq_pid]->C>>2)){ + int Nl=dlsch->harq_processes[harq_pid]->Nl; + int Qm=dlsch->harq_processes[harq_pid]->Qm; + int C = dlsch->harq_processes[harq_pid]->C; + int Gp = G/Nl/Qm; + int GpmodC = Gp%C; + if (r < (C-(GpmodC))) + r_offset += Nl*Qm * (Gp/C); + else + r_offset += Nl*Qm * ((GpmodC==0?0:1) + (Gp/C)); + } + else{ + r_offset += lte_rate_matching_turbo(dlsch->harq_processes[harq_pid]->RTC[r], + G, //G + dlsch->harq_processes[harq_pid]->w[r], + dlsch->harq_processes[harq_pid]->e+r_offset, + dlsch->harq_processes[harq_pid]->C, // C + dlsch->Nsoft, // Nsoft, + dlsch->Mdlharq, + dlsch->Kmimo, + dlsch->harq_processes[harq_pid]->rvidx, + dlsch->harq_processes[harq_pid]->Qm, + dlsch->harq_processes[harq_pid]->Nl, + r, + nb_rb); + // m); // r + } + } + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ENCODING_W, VCD_FUNCTION_OUT); + + return(0); +} + +int dlsch_encoding_2threads2(te_params *tep) { + + LTE_eNB_DLSCH_t *dlsch = tep->dlsch; + unsigned int G = tep->G; + unsigned char harq_pid = tep->harq_pid; + + unsigned short iind; + + unsigned short nb_rb = dlsch->harq_processes[harq_pid]->nb_rb; + unsigned int Kr=0,Kr_bytes,r,r_offset=0; + // unsigned short m=dlsch->harq_processes[harq_pid]->mcs; + + + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ENCODING_W, VCD_FUNCTION_IN); + + if (dlsch->harq_processes[harq_pid]->round == 0) { // this is a new packet + + for (r=(dlsch->harq_processes[harq_pid]->C>>1); r<(dlsch->harq_processes[harq_pid]->C>>2)*3; r++) { + + if (rharq_processes[harq_pid]->Cminus) + Kr = dlsch->harq_processes[harq_pid]->Kminus; + else + Kr = dlsch->harq_processes[harq_pid]->Kplus; + + Kr_bytes = Kr>>3; + + // get interleaver index for Turbo code (lookup in Table 5.1.3-3 36-212, V8.6 2009-03, p. 13-14) + if (Kr_bytes<=64) + iind = (Kr_bytes-5); + else if (Kr_bytes <=128) + iind = 59 + ((Kr_bytes-64)>>1); + else if (Kr_bytes <= 256) + iind = 91 + ((Kr_bytes-128)>>2); + else if (Kr_bytes <= 768) + iind = 123 + ((Kr_bytes-256)>>3); + else { + printf("dlsch_coding: Illegal codeword size %d!!!\n",Kr_bytes); + return(-1); + } + + + + threegpplte_turbo_encoder(dlsch->harq_processes[harq_pid]->c[r], + Kr>>3, + &dlsch->harq_processes[harq_pid]->d[r][96], + (r==0) ? dlsch->harq_processes[harq_pid]->F : 0, + f1f2mat_old[iind*2], // f1 (see 36121-820, page 14) + f1f2mat_old[(iind*2)+1] // f2 (see 36121-820, page 14) + ); + dlsch->harq_processes[harq_pid]->RTC[r] = + sub_block_interleaving_turbo(4+(Kr_bytes*8), + &dlsch->harq_processes[harq_pid]->d[r][96], + dlsch->harq_processes[harq_pid]->w[r]); + } + + } + + // Fill in the "e"-sequence from 36-212, V8.6 2009-03, p. 16-17 (for each "e") and concatenate the + // outputs for each code segment, see Section 5.1.5 p.20 + + for (r=0,r_offset=0; r<(dlsch->harq_processes[harq_pid]->C>>2)*3; r++) { + if(r<(dlsch->harq_processes[harq_pid]->C>>1)){ int Nl=dlsch->harq_processes[harq_pid]->Nl; int Qm=dlsch->harq_processes[harq_pid]->Qm; int C = dlsch->harq_processes[harq_pid]->C; @@ -529,6 +624,41 @@ void *te_thread1(void *param) { return(NULL); } +void *te_thread2(void *param) { + cpu_set_t cpuset; + CPU_ZERO(&cpuset); + + thread_top_init("te_thread2",1,200000,250000,500000); + pthread_setname_np( pthread_self(),"te processing 2"); + LOG_I(PHY,"thread te 2 created id=%ld\n", syscall(__NR_gettid)); + + //CPU_SET(7, &cpuset); + //pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); + + PHY_VARS_eNB *eNB = ((te_params *)param)->eNB; + eNB_proc_t *proc = &eNB->proc; + time_stats_t *te_wakeup_stats1 = &eNB->dlsch_turbo_encoding_wakeup_stats1; + while (!oai_exit) { + + + if (wait_on_condition(&proc->mutex_te[2],&proc->cond_te[2],&proc->instance_cnt_te[2],"te thread 2")<0) break; + + //stop_meas(te_wakeup_stats1); + dlsch_encoding_2threads1((te_params*)param); + + + if (release_thread(&proc->mutex_te[2],&proc->instance_cnt_te[2],"te thread 2")<0) break; + + if (pthread_cond_signal(&proc->cond_te[2]) != 0) { + printf("[eNB] ERROR pthread_cond_signal for te thread 1 exit\n"); + exit_fun( "ERROR pthread_cond_signal" ); + return(NULL); + } + } + + return(NULL); +} + int dlsch_encoding_2threads(PHY_VARS_eNB *eNB, unsigned char *a, uint8_t num_pdcch_symbols, @@ -611,7 +741,7 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB, pthread_mutex_unlock( &proc->mutex_te[0] ); //////////////////////////////////////////////////////////////// - if (proc->instance_cnt_te[1]==0) { + if (proc->instance_cnt_te[1]==0) { printf("[eNB] TE thread busy\n"); exit_fun("TE thread busy"); pthread_mutex_unlock( &proc->mutex_te[1] ); @@ -635,7 +765,32 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB, pthread_mutex_unlock( &proc->mutex_te[1] ); - for (r=dlsch->harq_processes[harq_pid]->C/3*2; rharq_processes[harq_pid]->C; r++) { +//////////////////////////////////////////////////////////////// + if (proc->instance_cnt_te[2]==0) { + printf("[eNB] TE thread busy\n"); + exit_fun("TE thread busy"); + pthread_mutex_unlock( &proc->mutex_te[2] ); + return(-1); + } + + ++proc->instance_cnt_te[2]; + + proc->tep[2].eNB = eNB; + proc->tep[2].dlsch = dlsch; + proc->tep[2].G = G; + proc->tep[2].harq_pid = harq_pid; + + // wakeup worker to do second half segments + if (pthread_cond_signal(&proc->cond_te[2]) != 0) { + printf("[eNB] ERROR pthread_cond_signal for te thread exit\n"); + exit_fun( "ERROR pthread_cond_signal" ); + return (-1); + } + + pthread_mutex_unlock( &proc->mutex_te[2] ); +//////////////////////////////////////////////////////////////// + + for (r=(dlsch->harq_processes[harq_pid]->C>>2)*3; rharq_processes[harq_pid]->C; r++) { if (rharq_processes[harq_pid]->Cminus) Kr = dlsch->harq_processes[harq_pid]->Kminus; @@ -707,7 +862,7 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB, for (r=0,r_offset=0; rharq_processes[harq_pid]->C; r++) { // get information for E for the segments that are handled by the worker thread - if (r<(dlsch->harq_processes[harq_pid]->C/3*2)) { + if (r<(dlsch->harq_processes[harq_pid]->C>>2)*3) { int Nl=dlsch->harq_processes[harq_pid]->Nl; int Qm=dlsch->harq_processes[harq_pid]->Qm; int C = dlsch->harq_processes[harq_pid]->C; @@ -742,6 +897,7 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB, start_meas(te_wait_stats); wait_on_busy_condition(&proc->mutex_te[0],&proc->cond_te[0],&proc->instance_cnt_te[0],"te thread"); wait_on_busy_condition(&proc->mutex_te[1],&proc->cond_te[1],&proc->instance_cnt_te[1],"te thread1"); + wait_on_busy_condition(&proc->mutex_te[2],&proc->cond_te[2],&proc->instance_cnt_te[2],"te thread2"); stop_meas(te_wait_stats); if(opp_enabled == 1 && te_wait_stats->diff_now>100*3000){ print_meas_now(te_wait_stats,"coding_wait",stderr); diff --git a/openair1/PHY/defs.h b/openair1/PHY/defs.h index 4339d98b24..3e35705c01 100644 --- a/openair1/PHY/defs.h +++ b/openair1/PHY/defs.h @@ -471,7 +471,7 @@ typedef struct eNB_proc_t_s { /// \internal This variable is protected by \ref mutex_td. int instance_cnt_td; /// \internal This variable is protected by \ref mutex_te. - int instance_cnt_te[2]; + int instance_cnt_te[3]; /// \internal This variable is protected by \ref mutex_prach. int instance_cnt_prach; #ifdef Rel14 @@ -493,7 +493,7 @@ typedef struct eNB_proc_t_s { /// pthread attributes for parallel turbo-decoder thread pthread_attr_t attr_td; /// pthread attributes for parallel turbo-encoder thread - pthread_attr_t attr_te[2]; + pthread_attr_t attr_te[3]; /// pthread attributes for single eNB processing thread pthread_attr_t attr_single; /// pthread attributes for prach processing thread @@ -507,7 +507,7 @@ typedef struct eNB_proc_t_s { /// scheduling parameters for parallel turbo-decoder thread struct sched_param sched_param_td; /// scheduling parameters for parallel turbo-encoder thread - struct sched_param sched_param_te[2]; + struct sched_param sched_param_te[3]; /// scheduling parameters for single eNB thread struct sched_param sched_param_single; /// scheduling parameters for prach thread @@ -521,7 +521,7 @@ typedef struct eNB_proc_t_s { /// pthread structure for parallel turbo-decoder thread pthread_t pthread_td; /// pthread structure for parallel turbo-encoder thread - pthread_t pthread_te[2]; + pthread_t pthread_te[3]; /// pthread structure for PRACH thread pthread_t pthread_prach; #ifdef Rel14 @@ -531,7 +531,7 @@ typedef struct eNB_proc_t_s { /// condition variable for parallel turbo-decoder thread pthread_cond_t cond_td; /// condition variable for parallel turbo-encoder thread - pthread_cond_t cond_te[2]; + pthread_cond_t cond_te[3]; /// condition variable for PRACH processing thread; pthread_cond_t cond_prach; #ifdef Rel14 @@ -543,7 +543,7 @@ typedef struct eNB_proc_t_s { /// mutex for parallel turbo-decoder thread pthread_mutex_t mutex_td; /// mutex for parallel turbo-encoder thread - pthread_mutex_t mutex_te[2]; + pthread_mutex_t mutex_te[3]; /// mutex for PRACH thread pthread_mutex_t mutex_prach; #ifdef Rel14 @@ -569,7 +569,7 @@ typedef struct eNB_proc_t_s { /// parameters for turbo-decoding worker thread td_params tdp; /// parameters for turbo-encoding worker thread - te_params tep[2]; + te_params tep[3]; /// set of scheduling variables RXn-TXnp4 threads eNB_rxtx_proc_t proc_rxtx[2]; /// stats thread pthread descriptor diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index 57e93fd6c2..838dc5d39e 100644 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -1507,6 +1507,7 @@ void init_td_thread(PHY_VARS_eNB *eNB,pthread_attr_t *attr_td) { extern void *te_thread(void*); extern void *te_thread1(void*); +extern void *te_thread2(void*); void init_te_thread(PHY_VARS_eNB *eNB,pthread_attr_t *attr_te,pthread_attr_t *attr_te1) { @@ -1530,7 +1531,16 @@ void init_te_thread(PHY_VARS_eNB *eNB,pthread_attr_t *attr_te,pthread_attr_t *at printf("Creating te_thread1\n"); pthread_create(&proc->pthread_te[1], attr_te1, te_thread1, (void*)&proc->tep[1]); + + ///////////////////////////////////////////////////////////////////////// + proc->tep[2].eNB = eNB; + proc->instance_cnt_te[2] = -1; + + pthread_mutex_init( &proc->mutex_te[2], NULL); + pthread_cond_init( &proc->cond_te[2], NULL); + printf("Creating te_thread2\n"); + pthread_create(&proc->pthread_te[2], attr_te1, te_thread2, (void*)&proc->tep[2]); } diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index 8533b05001..926dc7bd1c 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -1472,7 +1472,7 @@ static void* ru_thread( void* param ) { // set default return value - thread_top_init("ru_thread",0,400000,500000,500000); + thread_top_init("ru_thread",1,400000,500000,500000); //CPU_SET(1, &cpuset); //pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); From 7c27e09fcdb2a5c9feef1854c3193dcd9aac122c Mon Sep 17 00:00:00 2001 From: Wang Tsu-Han Date: Thu, 14 Dec 2017 15:38:02 +0100 Subject: [PATCH 23/63] Bug fix for coding worker thread --- openair1/PHY/LTE_TRANSPORT/dlsch_coding.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c index 5438dd5f9f..c9b1683cb2 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c @@ -637,14 +637,13 @@ void *te_thread2(void *param) { PHY_VARS_eNB *eNB = ((te_params *)param)->eNB; eNB_proc_t *proc = &eNB->proc; - time_stats_t *te_wakeup_stats1 = &eNB->dlsch_turbo_encoding_wakeup_stats1; while (!oai_exit) { if (wait_on_condition(&proc->mutex_te[2],&proc->cond_te[2],&proc->instance_cnt_te[2],"te thread 2")<0) break; //stop_meas(te_wakeup_stats1); - dlsch_encoding_2threads1((te_params*)param); + dlsch_encoding_2threads2((te_params*)param); if (release_thread(&proc->mutex_te[2],&proc->instance_cnt_te[2],"te thread 2")<0) break; From 409eadc9379ebe0d078ab235b99e69646a359e94 Mon Sep 17 00:00:00 2001 From: Wang Tsu-Han Date: Thu, 14 Dec 2017 17:17:31 +0100 Subject: [PATCH 24/63] measuring time for coding worker --- openair1/PHY/LTE_TRANSPORT/dlsch_coding.c | 10 ++++------ targets/RT/USER/lte-enb.c | 9 +++++++-- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c index c9b1683cb2..fc087679c9 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c @@ -560,14 +560,13 @@ void *te_thread(void *param) { PHY_VARS_eNB *eNB = ((te_params *)param)->eNB; eNB_proc_t *proc = &eNB->proc; - time_stats_t *te_wakeup_stats0 = &eNB->dlsch_turbo_encoding_wakeup_stats0; while (!oai_exit) { if (wait_on_condition(&proc->mutex_te[0],&proc->cond_te[0],&proc->instance_cnt_te[0],"te thread")<0) break; - //stop_meas(te_wakeup_stats0); + start_meas(&eNB->dlsch_turbo_encoding_wakeup_stats0); dlsch_encoding_2threads0((te_params*)param); - + stop_meas(&eNB->dlsch_turbo_encoding_wakeup_stats0); if (release_thread(&proc->mutex_te[0],&proc->instance_cnt_te[0],"te thread")<0) break; @@ -598,15 +597,14 @@ void *te_thread1(void *param) { PHY_VARS_eNB *eNB = ((te_params *)param)->eNB; eNB_proc_t *proc = &eNB->proc; - time_stats_t *te_wakeup_stats1 = &eNB->dlsch_turbo_encoding_wakeup_stats1; while (!oai_exit) { if (wait_on_condition(&proc->mutex_te[1],&proc->cond_te[1],&proc->instance_cnt_te[1],"te thread 1")<0) break; - //stop_meas(te_wakeup_stats1); + start_meas(&eNB->dlsch_turbo_encoding_wakeup_stats1); dlsch_encoding_2threads1((te_params*)param); - + stop_meas(&eNB->dlsch_turbo_encoding_wakeup_stats1); if (release_thread(&proc->mutex_te[1],&proc->instance_cnt_te[1],"te thread 1")<0) break; diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 636fa9d9cf..0f69f7be7b 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -704,8 +704,13 @@ static void* process_stats_thread(void* param) { sleep(1); if (opp_enabled == 1) { if (eNB->td) print_meas(&eNB->ulsch_decoding_stats,"ulsch_decoding",NULL,NULL); - if (eNB->te) print_meas(&eNB->dlsch_encoding_stats,"dlsch_encoding",NULL,NULL); - print_meas(&eNB->dlsch_modulation_stats,"dlsch_modulation",NULL,NULL); + if (eNB->te) + { + print_meas(&eNB->dlsch_encoding_stats,"dlsch_encoding",NULL,NULL); + print_meas(&eNB->dlsch_turbo_encoding_wakeup_stats0,"coding_worker_0",NULL,NULL); + print_meas(&eNB->dlsch_turbo_encoding_wakeup_stats1,"coding_worker_1",NULL,NULL); + } + print_meas(&eNB->dlsch_modulation_stats,"dlsch_modulation",NULL,NULL); } } return(NULL); From cabb4561d59745a439b7654102f090f2c2f571da Mon Sep 17 00:00:00 2001 From: Wang Tsu-Han Date: Wed, 3 Jan 2018 12:01:48 +0100 Subject: [PATCH 25/63] seperating rx tx process and fixixng coding threads on different cores --- openair1/PHY/LTE_TRANSPORT/dlsch_coding.c | 26 +++++++++++++++++------ openair1/PHY/LTE_TRANSPORT/proto.h | 2 ++ openair1/PHY/defs.h | 3 ++- openair1/SCHED/phy_procedures_lte_eNb.c | 1 + targets/RT/USER/lte-enb.c | 18 +++++++++------- targets/RT/USER/lte-ru.c | 4 ++-- 6 files changed, 37 insertions(+), 17 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c index fc087679c9..0a476c5ef5 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c @@ -555,8 +555,8 @@ void *te_thread(void *param) { pthread_setname_np( pthread_self(),"te processing"); LOG_I(PHY,"thread te created id=%ld\n", syscall(__NR_gettid)); - //CPU_SET(4, &cpuset); - //pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); + CPU_SET(4, &cpuset); + pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); PHY_VARS_eNB *eNB = ((te_params *)param)->eNB; eNB_proc_t *proc = &eNB->proc; @@ -592,8 +592,8 @@ void *te_thread1(void *param) { pthread_setname_np( pthread_self(),"te processing 1"); LOG_I(PHY,"thread te 1 created id=%ld\n", syscall(__NR_gettid)); - //CPU_SET(7, &cpuset); - //pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); + CPU_SET(7, &cpuset); + pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); PHY_VARS_eNB *eNB = ((te_params *)param)->eNB; eNB_proc_t *proc = &eNB->proc; @@ -630,8 +630,8 @@ void *te_thread2(void *param) { pthread_setname_np( pthread_self(),"te processing 2"); LOG_I(PHY,"thread te 2 created id=%ld\n", syscall(__NR_gettid)); - //CPU_SET(7, &cpuset); - //pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); + CPU_SET(8, &cpuset); + pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); PHY_VARS_eNB *eNB = ((te_params *)param)->eNB; eNB_proc_t *proc = &eNB->proc; @@ -665,6 +665,7 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB, time_stats_t *rm_stats, time_stats_t *te_stats, time_stats_t *te_wait_stats, + time_stats_t *te_main_stats, time_stats_t *te_wakeup_stats0, time_stats_t *te_wakeup_stats1, time_stats_t *i_stats) @@ -787,6 +788,7 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB, pthread_mutex_unlock( &proc->mutex_te[2] ); //////////////////////////////////////////////////////////////// + start_meas(te_main_stats); for (r=(dlsch->harq_processes[harq_pid]->C>>2)*3; rharq_processes[harq_pid]->C; r++) { if (rharq_processes[harq_pid]->Cminus) @@ -839,6 +841,10 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB, proc->tep[1].eNB = eNB; proc->tep[1].dlsch = dlsch; proc->tep[1].G = G; + + proc->tep[2].eNB = eNB; + proc->tep[2].dlsch = dlsch; + proc->tep[2].G = G; // wakeup worker to do second half segments if (pthread_cond_signal(&proc->cond_te[0]) != 0) { @@ -851,6 +857,11 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB, exit_fun( "ERROR pthread_cond_signal" ); return (-1); } + if (pthread_cond_signal(&proc->cond_te[2]) != 0) { + printf("[eNB] ERROR pthread_cond_signal for te thread exit\n"); + exit_fun( "ERROR pthread_cond_signal" ); + return (-1); + } } // Fill in the "e"-sequence from 36-212, V8.6 2009-03, p. 16-17 (for each "e") and concatenate the @@ -889,6 +900,7 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB, stop_meas(rm_stats); } } + stop_meas(te_main_stats); // wait for worker to finish start_meas(te_wait_stats); @@ -915,6 +927,7 @@ int dlsch_encoding_all(PHY_VARS_eNB *eNB, time_stats_t *rm_stats, time_stats_t *te_stats, time_stats_t *te_wait_stats, + time_stats_t *te_main_stats, time_stats_t *te_wakeup_stats0, time_stats_t *te_wakeup_stats1, time_stats_t *i_stats) @@ -950,6 +963,7 @@ int dlsch_encoding_all(PHY_VARS_eNB *eNB, rm_stats, te_stats, te_wait_stats, + te_main_stats, te_wakeup_stats0, te_wakeup_stats1, i_stats); diff --git a/openair1/PHY/LTE_TRANSPORT/proto.h b/openair1/PHY/LTE_TRANSPORT/proto.h index 87aa2188ff..161a658128 100644 --- a/openair1/PHY/LTE_TRANSPORT/proto.h +++ b/openair1/PHY/LTE_TRANSPORT/proto.h @@ -131,6 +131,7 @@ int32_t dlsch_encoding_all(PHY_VARS_eNB *eNB, time_stats_t *rm_stats, time_stats_t *te_stats, time_stats_t *te_wait_stats, + time_stats_t *te_main_stats, time_stats_t *te_wakeup_stats0, time_stats_t *te_wakeup_stats1, time_stats_t *i_stats); @@ -179,6 +180,7 @@ int32_t dlsch_encoding_2threads(PHY_VARS_eNB *eNB, time_stats_t *rm_stats, time_stats_t *te_stats, time_stats_t *te_wait_stats, + time_stats_t *te_main_stats, time_stats_t *te_wakeup_stats0, time_stats_t *te_wakeup_stats1, time_stats_t *i_stats); diff --git a/openair1/PHY/defs.h b/openair1/PHY/defs.h index 3e35705c01..e4ff721b92 100644 --- a/openair1/PHY/defs.h +++ b/openair1/PHY/defs.h @@ -965,7 +965,7 @@ typedef struct PHY_VARS_eNB_s { eth_params_t eth_params; 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 *); + 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); uint8_t local_flag; LTE_DL_FRAME_PARMS frame_parms; @@ -1145,6 +1145,7 @@ typedef struct PHY_VARS_eNB_s { time_stats_t dlsch_rate_matching_stats; time_stats_t dlsch_turbo_encoding_stats; time_stats_t dlsch_turbo_encoding_waiting_stats; + time_stats_t dlsch_turbo_encoding_main_stats; time_stats_t dlsch_turbo_encoding_wakeup_stats0; time_stats_t dlsch_turbo_encoding_wakeup_stats1; time_stats_t dlsch_interleaving_stats; diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index 838dc5d39e..bacb2da245 100644 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -346,6 +346,7 @@ void pdsch_procedures(PHY_VARS_eNB *eNB, &eNB->dlsch_rate_matching_stats, &eNB->dlsch_turbo_encoding_stats, &eNB->dlsch_turbo_encoding_waiting_stats, + &eNB->dlsch_turbo_encoding_main_stats, &eNB->dlsch_turbo_encoding_wakeup_stats0, &eNB->dlsch_turbo_encoding_wakeup_stats1, &eNB->dlsch_interleaving_stats); diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 0f69f7be7b..d8171ddcc4 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -182,14 +182,14 @@ static inline int rxtx(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, char *thread_nam VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER , 0 ); - // wakeup_tx(eNB,eNB->proc.ru_proc); - if(oai_exit) return(-1); - phy_procedures_eNB_TX(eNB, proc, no_relay, NULL, 1); - - pthread_mutex_lock(&eNB->proc.ru_proc->mutex_eNBs); - ++eNB->proc.ru_proc->instance_cnt_eNBs; - pthread_cond_signal(&eNB->proc.ru_proc->cond_eNBs); - pthread_mutex_unlock(&eNB->proc.ru_proc->mutex_eNBs); + wakeup_tx(eNB,eNB->proc.ru_proc); + //if(oai_exit) return(-1); + //phy_procedures_eNB_TX(eNB, proc, no_relay, NULL, 1); + // + //pthread_mutex_lock(&eNB->proc.ru_proc->mutex_eNBs); + //++eNB->proc.ru_proc->instance_cnt_eNBs; + //pthread_cond_signal(&eNB->proc.ru_proc->cond_eNBs); + //pthread_mutex_unlock(&eNB->proc.ru_proc->mutex_eNBs); stop_meas( &softmodem_stats_rxtx_sf ); @@ -707,6 +707,8 @@ static void* process_stats_thread(void* param) { if (eNB->te) { print_meas(&eNB->dlsch_encoding_stats,"dlsch_encoding",NULL,NULL); + print_meas(&eNB->dlsch_turbo_encoding_main_stats,"coding_main",NULL,NULL); + print_meas(&eNB->dlsch_turbo_encoding_waiting_stats,"coding_wait",NULL,NULL); print_meas(&eNB->dlsch_turbo_encoding_wakeup_stats0,"coding_worker_0",NULL,NULL); print_meas(&eNB->dlsch_turbo_encoding_wakeup_stats1,"coding_worker_1",NULL,NULL); } diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index 926dc7bd1c..7e24049ad6 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -1474,8 +1474,8 @@ static void* ru_thread( void* param ) { // set default return value thread_top_init("ru_thread",1,400000,500000,500000); - //CPU_SET(1, &cpuset); - //pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); + CPU_SET(1, &cpuset); + pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); pthread_setname_np( pthread_self(),"ru thread"); LOG_I(PHY,"thread ru created id=%ld\n", syscall(__NR_gettid)); From d1f7346c08dcd644fdff5642d01c31ae97bfd3d6 Mon Sep 17 00:00:00 2001 From: Eurecom Date: Fri, 5 Jan 2018 17:02:49 +0100 Subject: [PATCH 26/63] bug fix for missing wait sync --- openair1/PHY/LTE_TRANSPORT/dlsch_coding.c | 9 +++++++++ openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c | 1 + openair1/SCHED/ru_procedures.c | 3 ++- targets/RT/USER/lte-enb.c | 6 ++++++ targets/RT/USER/lte-ru.c | 3 +++ 5 files changed, 21 insertions(+), 1 deletion(-) diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c index 0a476c5ef5..f799f9341b 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c @@ -560,6 +560,9 @@ void *te_thread(void *param) { PHY_VARS_eNB *eNB = ((te_params *)param)->eNB; eNB_proc_t *proc = &eNB->proc; + + wait_sync("te_thread"); + while (!oai_exit) { if (wait_on_condition(&proc->mutex_te[0],&proc->cond_te[0],&proc->instance_cnt_te[0],"te thread")<0) break; @@ -597,6 +600,9 @@ void *te_thread1(void *param) { PHY_VARS_eNB *eNB = ((te_params *)param)->eNB; eNB_proc_t *proc = &eNB->proc; + + wait_sync("te_thread1"); + while (!oai_exit) { @@ -635,6 +641,9 @@ void *te_thread2(void *param) { PHY_VARS_eNB *eNB = ((te_params *)param)->eNB; eNB_proc_t *proc = &eNB->proc; + + wait_sync("te_thread2"); + while (!oai_exit) { diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c index 55e44fa8bf..19c7f6aa54 100644 --- a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c +++ b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c @@ -420,6 +420,7 @@ void *td_thread(void *param) { thread_top_init("td_thread",1,200000,250000,500000); pthread_setname_np( pthread_self(),"td processing"); LOG_I(PHY,"thread td created id=%ld\n", syscall(__NR_gettid)); + wait_sync("td_thread"); while (!oai_exit) { diff --git a/openair1/SCHED/ru_procedures.c b/openair1/SCHED/ru_procedures.c index 386cdc4153..2e460e7571 100644 --- a/openair1/SCHED/ru_procedures.c +++ b/openair1/SCHED/ru_procedures.c @@ -148,7 +148,7 @@ static void *feptx_thread(void *param) { LOG_I(PHY,"thread feptx created id=%ld\n", syscall(__NR_gettid)); //CPU_SET(6, &cpuset); //pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); - + wait_sync("feptx_thread"); @@ -445,6 +445,7 @@ static void *fep_thread(void *param) { CPU_ZERO(&cpuset); //CPU_SET(2, &cpuset); //pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); + wait_sync("fep_thread"); while (!oai_exit) { diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index d8171ddcc4..64731c9d8d 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -207,6 +207,8 @@ static void* tx_thread(void* param) { sprintf(thread_name,"TXnp4_%d\n",&eNB->proc.proc_rxtx[0] == proc ? 0 : 1); thread_top_init(thread_name,1,470000,500000,500000); + wait_sync("tx_thread"); + while (!oai_exit) { if (wait_on_condition(&proc->mutex_rxtx,&proc->cond_rxtx,&proc->instance_cnt_rxtx,thread_name)<0) break; @@ -264,6 +266,8 @@ static void* eNB_thread_rxtx( void* param ) { //CPU_SET(3, &cpuset); //pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); + + wait_sync("eNB_thread_rxtx"); while (!oai_exit) { VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_eNB_PROC_RXTX0+(proc->subframe_rx&1), 0 ); @@ -625,6 +629,7 @@ static void* eNB_thread_prach( void* param ) { thread_top_init("eNB_thread_prach",1,500000,1000000,20000000); + wait_sync("eNB_thread_prach"); while (!oai_exit) { @@ -743,6 +748,7 @@ void init_eNB_proc(int inst) { proc_rxtx[1].instance_cnt_rxtx = -1; proc->instance_cnt_prach = -1; proc->instance_cnt_asynch_rxtx = -1; + proc->instance_cnt_synch = -1; proc->CC_id = CC_id; proc->first_rx=1; diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index 7e24049ad6..e196584e25 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -987,6 +987,7 @@ static void* ru_thread_prach( void* param ) { ru_thread_prach_status = 0; thread_top_init("ru_thread_prach",1,500000,1000000,20000000); + wait_sync("ru_thread_prach"); while (!oai_exit) { @@ -1026,6 +1027,7 @@ static void* ru_thread_prach_br( void* param ) { ru_thread_prach_status = 0; thread_top_init("ru_thread_prach_br",1,500000,1000000,20000000); + wait_sync(ru_thread_prach_br); while (!oai_exit) { @@ -1413,6 +1415,7 @@ static void* ru_thread_tx( void* param ) { //CPU_SET(5, &cpuset); //pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); + wait_sync("ru_thread_tx"); wait_on_condition(&proc->mutex_FH1,&proc->cond_FH1,&proc->instance_cnt_FH1,"ru_thread_tx"); From 67c37417b6ecea8b22fa89ca1c318a80fd2f8c71 Mon Sep 17 00:00:00 2001 From: Eurecom Date: Mon, 8 Jan 2018 16:31:13 +0100 Subject: [PATCH 27/63] timing measure for full coding process --- openair1/PHY/LTE_TRANSPORT/dlsch_coding.c | 43 ++++++++++++++--------- openair1/PHY/defs.h | 3 ++ targets/RT/USER/lte-enb.c | 3 ++ 3 files changed, 33 insertions(+), 16 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c index f799f9341b..769a9af02a 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c @@ -680,6 +680,8 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB, time_stats_t *i_stats) { + //start_meas(&eNB->dlsch_turbo_encoding_preperation_stats); + LTE_DL_FRAME_PARMS *frame_parms = &eNB->frame_parms; eNB_proc_t *proc = &eNB->proc; unsigned int G; @@ -701,6 +703,7 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB, if (dlsch->harq_processes[harq_pid]->round == 0) { // this is a new packet + start_meas(&eNB->dlsch_turbo_encoding_preperation_stats); // Add 24-bit crc (polynomial A) to payload crc = crc24a(a, A)>>8; @@ -710,7 +713,9 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB, dlsch->harq_processes[harq_pid]->B = A+24; memcpy(dlsch->harq_processes[harq_pid]->b,a,(A/8)+4); + stop_meas(&eNB->dlsch_turbo_encoding_preperation_stats); + start_meas(&eNB->dlsch_turbo_encoding_segmentation_stats); if (lte_segmentation(dlsch->harq_processes[harq_pid]->b, dlsch->harq_processes[harq_pid]->c, dlsch->harq_processes[harq_pid]->B, @@ -722,8 +727,26 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB, &dlsch->harq_processes[harq_pid]->F)<0) return(-1); + stop_meas(&eNB->dlsch_turbo_encoding_segmentation_stats); - + proc->tep[0].eNB = eNB; + proc->tep[0].dlsch = dlsch; + proc->tep[0].G = G; + proc->tep[0].harq_pid = harq_pid; + + proc->tep[1].eNB = eNB; + proc->tep[1].dlsch = dlsch; + proc->tep[1].G = G; + proc->tep[1].harq_pid = harq_pid; + + proc->tep[2].eNB = eNB; + proc->tep[2].dlsch = dlsch; + proc->tep[2].G = G; + proc->tep[2].harq_pid = harq_pid; + + start_meas(&eNB->dlsch_turbo_encoding_signal_stats); + + pthread_mutex_lock( &proc->mutex_te[0] ); if (proc->instance_cnt_te[0]==0) { printf("[eNB] TE thread busy\n"); exit_fun("TE thread busy"); @@ -733,11 +756,6 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB, ++proc->instance_cnt_te[0]; - proc->tep[0].eNB = eNB; - proc->tep[0].dlsch = dlsch; - proc->tep[0].G = G; - proc->tep[0].harq_pid = harq_pid; - // wakeup worker to do second half segments if (pthread_cond_signal(&proc->cond_te[0]) != 0) { printf("[eNB] ERROR pthread_cond_signal for te thread exit\n"); @@ -748,6 +766,7 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB, pthread_mutex_unlock( &proc->mutex_te[0] ); //////////////////////////////////////////////////////////////// + pthread_mutex_lock( &proc->mutex_te[1] ); if (proc->instance_cnt_te[1]==0) { printf("[eNB] TE thread busy\n"); exit_fun("TE thread busy"); @@ -757,11 +776,6 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB, ++proc->instance_cnt_te[1]; - proc->tep[1].eNB = eNB; - proc->tep[1].dlsch = dlsch; - proc->tep[1].G = G; - proc->tep[1].harq_pid = harq_pid; - // wakeup worker to do second half segments if (pthread_cond_signal(&proc->cond_te[1]) != 0) { printf("[eNB] ERROR pthread_cond_signal for te thread exit\n"); @@ -773,6 +787,7 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB, pthread_mutex_unlock( &proc->mutex_te[1] ); //////////////////////////////////////////////////////////////// + pthread_mutex_lock( &proc->mutex_te[2] ); if (proc->instance_cnt_te[2]==0) { printf("[eNB] TE thread busy\n"); exit_fun("TE thread busy"); @@ -782,11 +797,6 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB, ++proc->instance_cnt_te[2]; - proc->tep[2].eNB = eNB; - proc->tep[2].dlsch = dlsch; - proc->tep[2].G = G; - proc->tep[2].harq_pid = harq_pid; - // wakeup worker to do second half segments if (pthread_cond_signal(&proc->cond_te[2]) != 0) { printf("[eNB] ERROR pthread_cond_signal for te thread exit\n"); @@ -797,6 +807,7 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB, pthread_mutex_unlock( &proc->mutex_te[2] ); //////////////////////////////////////////////////////////////// + stop_meas(&eNB->dlsch_turbo_encoding_signal_stats); start_meas(te_main_stats); for (r=(dlsch->harq_processes[harq_pid]->C>>2)*3; rharq_processes[harq_pid]->C; r++) { diff --git a/openair1/PHY/defs.h b/openair1/PHY/defs.h index e4ff721b92..a21f3b1378 100644 --- a/openair1/PHY/defs.h +++ b/openair1/PHY/defs.h @@ -1143,8 +1143,11 @@ typedef struct PHY_VARS_eNB_s { time_stats_t dlsch_modulation_stats; time_stats_t dlsch_scrambling_stats; time_stats_t dlsch_rate_matching_stats; + time_stats_t dlsch_turbo_encoding_preperation_stats; + time_stats_t dlsch_turbo_encoding_segmentation_stats; time_stats_t dlsch_turbo_encoding_stats; time_stats_t dlsch_turbo_encoding_waiting_stats; + time_stats_t dlsch_turbo_encoding_signal_stats; time_stats_t dlsch_turbo_encoding_main_stats; time_stats_t dlsch_turbo_encoding_wakeup_stats0; time_stats_t dlsch_turbo_encoding_wakeup_stats1; diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 64731c9d8d..cf5fe49a6a 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -711,7 +711,10 @@ static void* process_stats_thread(void* param) { if (eNB->td) print_meas(&eNB->ulsch_decoding_stats,"ulsch_decoding",NULL,NULL); if (eNB->te) { + print_meas(&eNB->dlsch_turbo_encoding_preperation_stats,"dlsch_coding_prepare",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_turbo_encoding_signal_stats,"coding_signal",NULL,NULL); print_meas(&eNB->dlsch_turbo_encoding_main_stats,"coding_main",NULL,NULL); print_meas(&eNB->dlsch_turbo_encoding_waiting_stats,"coding_wait",NULL,NULL); print_meas(&eNB->dlsch_turbo_encoding_wakeup_stats0,"coding_worker_0",NULL,NULL); From cfec3ffd56610b200b0ee14c51ae67685d88988f Mon Sep 17 00:00:00 2001 From: Wang Tsu-Han Date: Tue, 16 Jan 2018 15:50:57 +0100 Subject: [PATCH 28/63] adding EMULATE_RF into CMakelist --- cmake_targets/CMakeLists.txt | 1 + common/utils/itti/intertask_interface.c | 3 --- openair1/PHY/defs.h | 4 ++-- targets/COMMON/create_tasks.c | 3 --- targets/RT/USER/lte-ru.c | 3 --- 5 files changed, 3 insertions(+), 11 deletions(-) diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 723ad38d67..6cce5e306e 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -597,6 +597,7 @@ add_boolean_option(NAS_ADDRESS_FIX False "specific to oaisim: for nasmesh driver add_boolean_option(NAS_NETLINK False "???? Must be True to compile nasmesh driver without rtai") add_boolean_option(OAISIM False "specific to oaisim") add_boolean_option(OAI_NW_DRIVER_USE_NETLINK True "????") +add_boolean_option(EMULATE_RF True "allows to run lte-softmodem without HW") add_boolean_option(USE_MME False "this flag is used only one time in lte-softmodem.c") add_list_string_option(PACKAGE_NAME "NotDefined" "As per attribute name") diff --git a/common/utils/itti/intertask_interface.c b/common/utils/itti/intertask_interface.c index fc366f6057..5462c97523 100644 --- a/common/utils/itti/intertask_interface.c +++ b/common/utils/itti/intertask_interface.c @@ -99,9 +99,6 @@ const int itti_debug = (ITTI_DEBUG_ISSUES | ITTI_DEBUG_MP_STATISTICS); # define ITTI_MEM_SIZE (16 * 1024 * 1024) #endif -#ifndef EMULATE_RF -#define EMULATE_RF -#endif typedef enum task_state_s { TASK_STATE_NOT_CONFIGURED, TASK_STATE_STARTING, TASK_STATE_READY, TASK_STATE_ENDED, TASK_STATE_MAX, diff --git a/openair1/PHY/defs.h b/openair1/PHY/defs.h index a21f3b1378..f8645fec97 100644 --- a/openair1/PHY/defs.h +++ b/openair1/PHY/defs.h @@ -676,8 +676,8 @@ typedef enum { REMOTE_MBP_IF5 =2, REMOTE_IF4p5 =3, REMOTE_IF1pp =4, - MAX_RU_IF_TYPES =5, - EMULATE_RF =6 + MAX_RU_IF_TYPES =5 + //EMULATE_RF =6 } RU_if_south_t; typedef struct RU_t_s{ diff --git a/targets/COMMON/create_tasks.c b/targets/COMMON/create_tasks.c index 65aed76742..25b5828e06 100644 --- a/targets/COMMON/create_tasks.c +++ b/targets/COMMON/create_tasks.c @@ -40,9 +40,6 @@ # endif # include "enb_app.h" -#ifndef EMULATE_RF -#define EMULATE_RF -#endif int create_tasks(uint32_t enb_nb, uint32_t ue_nb) { diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index e196584e25..0b5a1e6087 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -110,9 +110,6 @@ unsigned short config_frames[4] = {2,9,11,13}; #include "T.h" -#ifndef EMULATE_RF -#define EMULATE_RF -#endif extern volatile int oai_exit; extern int numerology; From dea858849eee5290add6ec0b652072580d911674 Mon Sep 17 00:00:00 2001 From: Eurecom Date: Wed, 17 Jan 2018 16:30:50 +0100 Subject: [PATCH 29/63] code cleanup --- openair1/PHY/LTE_TRANSPORT/dlsch_coding.c | 474 +++++----------------- openair1/PHY/LTE_TRANSPORT/proto.h | 3 +- openair1/PHY/defs.h | 14 + openair1/SCHED/phy_procedures_lte_eNb.c | 37 +- targets/RT/USER/lte-enb.c | 14 +- 5 files changed, 139 insertions(+), 403 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c index 769a9af02a..461bf60442 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c @@ -279,6 +279,8 @@ int dlsch_encoding_2threads0(te_params *tep) { LTE_eNB_DLSCH_t *dlsch = tep->dlsch; unsigned int G = tep->G; unsigned char harq_pid = tep->harq_pid; + unsigned int total_worker = tep->total_worker; + unsigned int current_worker = tep->current_worker; unsigned short iind; @@ -291,7 +293,7 @@ int dlsch_encoding_2threads0(te_params *tep) { if (dlsch->harq_processes[harq_pid]->round == 0) { // this is a new packet - for (r=0; r<(dlsch->harq_processes[harq_pid]->C>>2); r++) { + for (r=(dlsch->harq_processes[harq_pid]->C/(total_worker+1))*current_worker; r<(dlsch->harq_processes[harq_pid]->C/(total_worker+1))*(current_worker+1); r++) { if (rharq_processes[harq_pid]->Cminus) Kr = dlsch->harq_processes[harq_pid]->Kminus; @@ -334,90 +336,8 @@ int dlsch_encoding_2threads0(te_params *tep) { // Fill in the "e"-sequence from 36-212, V8.6 2009-03, p. 16-17 (for each "e") and concatenate the // outputs for each code segment, see Section 5.1.5 p.20 - for (r=0; r<(dlsch->harq_processes[harq_pid]->C>>2); r++) { - r_offset += lte_rate_matching_turbo(dlsch->harq_processes[harq_pid]->RTC[r], - G, //G - dlsch->harq_processes[harq_pid]->w[r], - dlsch->harq_processes[harq_pid]->e+r_offset, - dlsch->harq_processes[harq_pid]->C, // C - dlsch->Nsoft, // Nsoft, - dlsch->Mdlharq, - dlsch->Kmimo, - dlsch->harq_processes[harq_pid]->rvidx, - dlsch->harq_processes[harq_pid]->Qm, - dlsch->harq_processes[harq_pid]->Nl, - r, - nb_rb); - // m); // r - } - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ENCODING_W, VCD_FUNCTION_OUT); - - return(0); -} - -int dlsch_encoding_2threads1(te_params *tep) { - - LTE_eNB_DLSCH_t *dlsch = tep->dlsch; - unsigned int G = tep->G; - unsigned char harq_pid = tep->harq_pid; - - unsigned short iind; - - unsigned short nb_rb = dlsch->harq_processes[harq_pid]->nb_rb; - unsigned int Kr=0,Kr_bytes,r,r_offset=0; - // unsigned short m=dlsch->harq_processes[harq_pid]->mcs; - - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ENCODING_W, VCD_FUNCTION_IN); - - if (dlsch->harq_processes[harq_pid]->round == 0) { // this is a new packet - - for (r=(dlsch->harq_processes[harq_pid]->C>>2); r<(dlsch->harq_processes[harq_pid]->C>>1); r++) { - - if (rharq_processes[harq_pid]->Cminus) - Kr = dlsch->harq_processes[harq_pid]->Kminus; - else - Kr = dlsch->harq_processes[harq_pid]->Kplus; - - Kr_bytes = Kr>>3; - - // get interleaver index for Turbo code (lookup in Table 5.1.3-3 36-212, V8.6 2009-03, p. 13-14) - if (Kr_bytes<=64) - iind = (Kr_bytes-5); - else if (Kr_bytes <=128) - iind = 59 + ((Kr_bytes-64)>>1); - else if (Kr_bytes <= 256) - iind = 91 + ((Kr_bytes-128)>>2); - else if (Kr_bytes <= 768) - iind = 123 + ((Kr_bytes-256)>>3); - else { - printf("dlsch_coding: Illegal codeword size %d!!!\n",Kr_bytes); - return(-1); - } - - - - threegpplte_turbo_encoder(dlsch->harq_processes[harq_pid]->c[r], - Kr>>3, - &dlsch->harq_processes[harq_pid]->d[r][96], - (r==0) ? dlsch->harq_processes[harq_pid]->F : 0, - f1f2mat_old[iind*2], // f1 (see 36121-820, page 14) - f1f2mat_old[(iind*2)+1] // f2 (see 36121-820, page 14) - ); - dlsch->harq_processes[harq_pid]->RTC[r] = - sub_block_interleaving_turbo(4+(Kr_bytes*8), - &dlsch->harq_processes[harq_pid]->d[r][96], - dlsch->harq_processes[harq_pid]->w[r]); - } - - } - - // Fill in the "e"-sequence from 36-212, V8.6 2009-03, p. 16-17 (for each "e") and concatenate the - // outputs for each code segment, see Section 5.1.5 p.20 - - for (r=0,r_offset=0; r<(dlsch->harq_processes[harq_pid]->C>>1); r++) { - if(r<(dlsch->harq_processes[harq_pid]->C>>2)){ + for (r=0,r_offset=0; r<(dlsch->harq_processes[harq_pid]->C/(total_worker+1))*(current_worker+1); r++) { + if(r<(dlsch->harq_processes[harq_pid]->C/(total_worker+1))*(current_worker)){ int Nl=dlsch->harq_processes[harq_pid]->Nl; int Qm=dlsch->harq_processes[harq_pid]->Qm; int C = dlsch->harq_processes[harq_pid]->C; @@ -451,100 +371,6 @@ int dlsch_encoding_2threads1(te_params *tep) { return(0); } -int dlsch_encoding_2threads2(te_params *tep) { - - LTE_eNB_DLSCH_t *dlsch = tep->dlsch; - unsigned int G = tep->G; - unsigned char harq_pid = tep->harq_pid; - - unsigned short iind; - - unsigned short nb_rb = dlsch->harq_processes[harq_pid]->nb_rb; - unsigned int Kr=0,Kr_bytes,r,r_offset=0; - // unsigned short m=dlsch->harq_processes[harq_pid]->mcs; - - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ENCODING_W, VCD_FUNCTION_IN); - - if (dlsch->harq_processes[harq_pid]->round == 0) { // this is a new packet - - for (r=(dlsch->harq_processes[harq_pid]->C>>1); r<(dlsch->harq_processes[harq_pid]->C>>2)*3; r++) { - - if (rharq_processes[harq_pid]->Cminus) - Kr = dlsch->harq_processes[harq_pid]->Kminus; - else - Kr = dlsch->harq_processes[harq_pid]->Kplus; - - Kr_bytes = Kr>>3; - - // get interleaver index for Turbo code (lookup in Table 5.1.3-3 36-212, V8.6 2009-03, p. 13-14) - if (Kr_bytes<=64) - iind = (Kr_bytes-5); - else if (Kr_bytes <=128) - iind = 59 + ((Kr_bytes-64)>>1); - else if (Kr_bytes <= 256) - iind = 91 + ((Kr_bytes-128)>>2); - else if (Kr_bytes <= 768) - iind = 123 + ((Kr_bytes-256)>>3); - else { - printf("dlsch_coding: Illegal codeword size %d!!!\n",Kr_bytes); - return(-1); - } - - - - threegpplte_turbo_encoder(dlsch->harq_processes[harq_pid]->c[r], - Kr>>3, - &dlsch->harq_processes[harq_pid]->d[r][96], - (r==0) ? dlsch->harq_processes[harq_pid]->F : 0, - f1f2mat_old[iind*2], // f1 (see 36121-820, page 14) - f1f2mat_old[(iind*2)+1] // f2 (see 36121-820, page 14) - ); - dlsch->harq_processes[harq_pid]->RTC[r] = - sub_block_interleaving_turbo(4+(Kr_bytes*8), - &dlsch->harq_processes[harq_pid]->d[r][96], - dlsch->harq_processes[harq_pid]->w[r]); - } - - } - - // Fill in the "e"-sequence from 36-212, V8.6 2009-03, p. 16-17 (for each "e") and concatenate the - // outputs for each code segment, see Section 5.1.5 p.20 - - for (r=0,r_offset=0; r<(dlsch->harq_processes[harq_pid]->C>>2)*3; r++) { - if(r<(dlsch->harq_processes[harq_pid]->C>>1)){ - int Nl=dlsch->harq_processes[harq_pid]->Nl; - int Qm=dlsch->harq_processes[harq_pid]->Qm; - int C = dlsch->harq_processes[harq_pid]->C; - int Gp = G/Nl/Qm; - int GpmodC = Gp%C; - if (r < (C-(GpmodC))) - r_offset += Nl*Qm * (Gp/C); - else - r_offset += Nl*Qm * ((GpmodC==0?0:1) + (Gp/C)); - } - else{ - r_offset += lte_rate_matching_turbo(dlsch->harq_processes[harq_pid]->RTC[r], - G, //G - dlsch->harq_processes[harq_pid]->w[r], - dlsch->harq_processes[harq_pid]->e+r_offset, - dlsch->harq_processes[harq_pid]->C, // C - dlsch->Nsoft, // Nsoft, - dlsch->Mdlharq, - dlsch->Kmimo, - dlsch->harq_processes[harq_pid]->rvidx, - dlsch->harq_processes[harq_pid]->Qm, - dlsch->harq_processes[harq_pid]->Nl, - r, - nb_rb); - // m); // r - } - } - - VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ENCODING_W, VCD_FUNCTION_OUT); - - return(0); -} extern int oai_exit; void *te_thread(void *param) { @@ -555,25 +381,20 @@ void *te_thread(void *param) { pthread_setname_np( pthread_self(),"te processing"); LOG_I(PHY,"thread te created id=%ld\n", syscall(__NR_gettid)); - CPU_SET(4, &cpuset); - pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); - PHY_VARS_eNB *eNB = ((te_params *)param)->eNB; - eNB_proc_t *proc = &eNB->proc; + te_params *tep = (te_params *)param; wait_sync("te_thread"); while (!oai_exit) { - if (wait_on_condition(&proc->mutex_te[0],&proc->cond_te[0],&proc->instance_cnt_te[0],"te thread")<0) break; + if (wait_on_condition(&tep->mutex_te,&tep->cond_te,&tep->instance_cnt_te,"te thread")<0) break; - start_meas(&eNB->dlsch_turbo_encoding_wakeup_stats0); - dlsch_encoding_2threads0((te_params*)param); - stop_meas(&eNB->dlsch_turbo_encoding_wakeup_stats0); + dlsch_encoding_2threads0(tep); - if (release_thread(&proc->mutex_te[0],&proc->instance_cnt_te[0],"te thread")<0) break; + if (release_thread(&tep->mutex_te,&tep->instance_cnt_te,"te thread")<0) break; - if (pthread_cond_signal(&proc->cond_te[0]) != 0) { + if (pthread_cond_signal(&tep->cond_te) != 0) { printf("[eNB] ERROR pthread_cond_signal for te thread exit\n"); exit_fun( "ERROR pthread_cond_signal" ); return(NULL); @@ -587,83 +408,7 @@ void *te_thread(void *param) { return(NULL); } -void *te_thread1(void *param) { - cpu_set_t cpuset; - CPU_ZERO(&cpuset); - - thread_top_init("te_thread1",1,200000,250000,500000); - pthread_setname_np( pthread_self(),"te processing 1"); - LOG_I(PHY,"thread te 1 created id=%ld\n", syscall(__NR_gettid)); - - CPU_SET(7, &cpuset); - pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); - PHY_VARS_eNB *eNB = ((te_params *)param)->eNB; - eNB_proc_t *proc = &eNB->proc; - - wait_sync("te_thread1"); - - while (!oai_exit) { - - - if (wait_on_condition(&proc->mutex_te[1],&proc->cond_te[1],&proc->instance_cnt_te[1],"te thread 1")<0) break; - - start_meas(&eNB->dlsch_turbo_encoding_wakeup_stats1); - dlsch_encoding_2threads1((te_params*)param); - stop_meas(&eNB->dlsch_turbo_encoding_wakeup_stats1); - - if (release_thread(&proc->mutex_te[1],&proc->instance_cnt_te[1],"te thread 1")<0) break; - - if (pthread_cond_signal(&proc->cond_te[1]) != 0) { - printf("[eNB] ERROR pthread_cond_signal for te thread 1 exit\n"); - exit_fun( "ERROR pthread_cond_signal" ); - return(NULL); - } - /*if(opp_enabled == 1 && te_wakeup_stats1->diff_now>50*3000){ - print_meas_now(te_wakeup_stats1,"coding_wakeup",stderr); - printf("te_thread1 delay for waking up in frame_rx: %d subframe_rx: %d \n",proc->frame_rx,proc->subframe_rx); - }*/ - } - - return(NULL); -} - -void *te_thread2(void *param) { - cpu_set_t cpuset; - CPU_ZERO(&cpuset); - - thread_top_init("te_thread2",1,200000,250000,500000); - pthread_setname_np( pthread_self(),"te processing 2"); - LOG_I(PHY,"thread te 2 created id=%ld\n", syscall(__NR_gettid)); - - CPU_SET(8, &cpuset); - pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); - - PHY_VARS_eNB *eNB = ((te_params *)param)->eNB; - eNB_proc_t *proc = &eNB->proc; - - wait_sync("te_thread2"); - - while (!oai_exit) { - - - if (wait_on_condition(&proc->mutex_te[2],&proc->cond_te[2],&proc->instance_cnt_te[2],"te thread 2")<0) break; - - //stop_meas(te_wakeup_stats1); - dlsch_encoding_2threads2((te_params*)param); - - - if (release_thread(&proc->mutex_te[2],&proc->instance_cnt_te[2],"te thread 2")<0) break; - - if (pthread_cond_signal(&proc->cond_te[2]) != 0) { - printf("[eNB] ERROR pthread_cond_signal for te thread 1 exit\n"); - exit_fun( "ERROR pthread_cond_signal" ); - return(NULL); - } - } - - return(NULL); -} int dlsch_encoding_2threads(PHY_VARS_eNB *eNB, unsigned char *a, @@ -677,7 +422,8 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB, time_stats_t *te_main_stats, time_stats_t *te_wakeup_stats0, time_stats_t *te_wakeup_stats1, - time_stats_t *i_stats) + time_stats_t *i_stats, + int worker_num) { //start_meas(&eNB->dlsch_turbo_encoding_preperation_stats); @@ -707,13 +453,14 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB, // Add 24-bit crc (polynomial A) to payload crc = crc24a(a, A)>>8; + stop_meas(&eNB->dlsch_turbo_encoding_preperation_stats); a[A>>3] = ((uint8_t*)&crc)[2]; a[1+(A>>3)] = ((uint8_t*)&crc)[1]; a[2+(A>>3)] = ((uint8_t*)&crc)[0]; dlsch->harq_processes[harq_pid]->B = A+24; memcpy(dlsch->harq_processes[harq_pid]->b,a,(A/8)+4); - stop_meas(&eNB->dlsch_turbo_encoding_preperation_stats); + //stop_meas(&eNB->dlsch_turbo_encoding_preperation_stats); start_meas(&eNB->dlsch_turbo_encoding_segmentation_stats); if (lte_segmentation(dlsch->harq_processes[harq_pid]->b, @@ -728,88 +475,40 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB, return(-1); stop_meas(&eNB->dlsch_turbo_encoding_segmentation_stats); - - proc->tep[0].eNB = eNB; - proc->tep[0].dlsch = dlsch; - proc->tep[0].G = G; - proc->tep[0].harq_pid = harq_pid; - - proc->tep[1].eNB = eNB; - proc->tep[1].dlsch = dlsch; - proc->tep[1].G = G; - proc->tep[1].harq_pid = harq_pid; - - proc->tep[2].eNB = eNB; - proc->tep[2].dlsch = dlsch; - proc->tep[2].G = G; - proc->tep[2].harq_pid = harq_pid; start_meas(&eNB->dlsch_turbo_encoding_signal_stats); + for(int i=0;itep[i].eNB = eNB; + proc->tep[i].dlsch = dlsch; + proc->tep[i].G = G; + proc->tep[i].harq_pid = harq_pid; + proc->tep[i].total_worker = worker_num; + proc->tep[i].current_worker = i; + + pthread_mutex_lock( &proc->tep[i].mutex_te ); + if (proc->tep[i].instance_cnt_te==0) { + printf("[eNB] TE thread busy\n"); + exit_fun("TE thread busy"); + pthread_mutex_unlock( &proc->tep[i].mutex_te ); + return(-1); + } - pthread_mutex_lock( &proc->mutex_te[0] ); - if (proc->instance_cnt_te[0]==0) { - printf("[eNB] TE thread busy\n"); - exit_fun("TE thread busy"); - pthread_mutex_unlock( &proc->mutex_te[0] ); - return(-1); + ++proc->tep[i].instance_cnt_te; + + // wakeup worker to do segments + if (pthread_cond_signal(&proc->tep[i].cond_te) != 0) { + printf("[eNB] ERROR pthread_cond_signal for te thread %d exit\n",i); + exit_fun( "ERROR pthread_cond_signal" ); + return (-1); + } + + pthread_mutex_unlock( &proc->tep[i].mutex_te ); } - ++proc->instance_cnt_te[0]; - - // wakeup worker to do second half segments - if (pthread_cond_signal(&proc->cond_te[0]) != 0) { - printf("[eNB] ERROR pthread_cond_signal for te thread exit\n"); - exit_fun( "ERROR pthread_cond_signal" ); - return (-1); - } - //start_meas(te_wakeup_stats0); - - pthread_mutex_unlock( &proc->mutex_te[0] ); -//////////////////////////////////////////////////////////////// - pthread_mutex_lock( &proc->mutex_te[1] ); - if (proc->instance_cnt_te[1]==0) { - printf("[eNB] TE thread busy\n"); - exit_fun("TE thread busy"); - pthread_mutex_unlock( &proc->mutex_te[1] ); - return(-1); - } - - ++proc->instance_cnt_te[1]; - - // wakeup worker to do second half segments - if (pthread_cond_signal(&proc->cond_te[1]) != 0) { - printf("[eNB] ERROR pthread_cond_signal for te thread exit\n"); - exit_fun( "ERROR pthread_cond_signal" ); - return (-1); - } - //start_meas(te_wakeup_stats1); - - pthread_mutex_unlock( &proc->mutex_te[1] ); - -//////////////////////////////////////////////////////////////// - pthread_mutex_lock( &proc->mutex_te[2] ); - if (proc->instance_cnt_te[2]==0) { - printf("[eNB] TE thread busy\n"); - exit_fun("TE thread busy"); - pthread_mutex_unlock( &proc->mutex_te[2] ); - return(-1); - } - - ++proc->instance_cnt_te[2]; - - // wakeup worker to do second half segments - if (pthread_cond_signal(&proc->cond_te[2]) != 0) { - printf("[eNB] ERROR pthread_cond_signal for te thread exit\n"); - exit_fun( "ERROR pthread_cond_signal" ); - return (-1); - } - - pthread_mutex_unlock( &proc->mutex_te[2] ); -//////////////////////////////////////////////////////////////// - stop_meas(&eNB->dlsch_turbo_encoding_signal_stats); start_meas(te_main_stats); - for (r=(dlsch->harq_processes[harq_pid]->C>>2)*3; rharq_processes[harq_pid]->C; r++) { + for (r=(dlsch->harq_processes[harq_pid]->C/(worker_num+1))*worker_num; rharq_processes[harq_pid]->C; r++) { if (rharq_processes[harq_pid]->Cminus) Kr = dlsch->harq_processes[harq_pid]->Kminus; @@ -854,33 +553,18 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB, } else { - proc->tep[0].eNB = eNB; - proc->tep[0].dlsch = dlsch; - proc->tep[0].G = G; - - proc->tep[1].eNB = eNB; - proc->tep[1].dlsch = dlsch; - proc->tep[1].G = G; - - proc->tep[2].eNB = eNB; - proc->tep[2].dlsch = dlsch; - proc->tep[2].G = G; - - // wakeup worker to do second half segments - if (pthread_cond_signal(&proc->cond_te[0]) != 0) { - printf("[eNB] ERROR pthread_cond_signal for te thread exit\n"); - exit_fun( "ERROR pthread_cond_signal" ); - return (-1); - } - if (pthread_cond_signal(&proc->cond_te[1]) != 0) { - printf("[eNB] ERROR pthread_cond_signal for te thread exit\n"); - exit_fun( "ERROR pthread_cond_signal" ); - return (-1); - } - if (pthread_cond_signal(&proc->cond_te[2]) != 0) { + for(int i=0;itep[i].eNB = eNB; + proc->tep[i].dlsch = dlsch; + proc->tep[i].G = G; + proc->tep[i].total_worker = worker_num; + proc->tep[i].current_worker = i; + if (pthread_cond_signal(&proc->tep[i].cond_te) != 0) { printf("[eNB] ERROR pthread_cond_signal for te thread exit\n"); exit_fun( "ERROR pthread_cond_signal" ); return (-1); + } } } @@ -890,7 +574,7 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB, for (r=0,r_offset=0; rharq_processes[harq_pid]->C; r++) { // get information for E for the segments that are handled by the worker thread - if (r<(dlsch->harq_processes[harq_pid]->C>>2)*3) { + if (r<(dlsch->harq_processes[harq_pid]->C/(worker_num+1))*worker_num) { int Nl=dlsch->harq_processes[harq_pid]->Nl; int Qm=dlsch->harq_processes[harq_pid]->Qm; int C = dlsch->harq_processes[harq_pid]->C; @@ -924,9 +608,9 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB, // wait for worker to finish start_meas(te_wait_stats); - wait_on_busy_condition(&proc->mutex_te[0],&proc->cond_te[0],&proc->instance_cnt_te[0],"te thread"); - wait_on_busy_condition(&proc->mutex_te[1],&proc->cond_te[1],&proc->instance_cnt_te[1],"te thread1"); - wait_on_busy_condition(&proc->mutex_te[2],&proc->cond_te[2],&proc->instance_cnt_te[2],"te thread2"); + wait_on_busy_condition(&proc->tep[0].mutex_te,&proc->tep[0].cond_te,&proc->tep[0].instance_cnt_te,"te thread 0"); + wait_on_busy_condition(&proc->tep[1].mutex_te,&proc->tep[1].cond_te,&proc->tep[1].instance_cnt_te,"te thread 1"); + wait_on_busy_condition(&proc->tep[2].mutex_te,&proc->tep[2].cond_te,&proc->tep[2].instance_cnt_te,"te thread 2"); stop_meas(te_wait_stats); if(opp_enabled == 1 && te_wait_stats->diff_now>100*3000){ print_meas_now(te_wait_stats,"coding_wait",stderr); @@ -955,7 +639,6 @@ int dlsch_encoding_all(PHY_VARS_eNB *eNB, int encoding_return = 0; unsigned int L,C,B; B = dlsch->harq_processes[dlsch->harq_ids[subframe]]->B; - //printf("total bit length is %d\n",B);///////////******* if(B<=6144) { L=0; @@ -971,8 +654,8 @@ int dlsch_encoding_all(PHY_VARS_eNB *eNB, } } - if(C >= 5) - { + if(C >= 8&&get_nprocs()>=6)//one main three worker + { encoding_return = dlsch_encoding_2threads(eNB, a, @@ -986,10 +669,47 @@ int dlsch_encoding_all(PHY_VARS_eNB *eNB, te_main_stats, te_wakeup_stats0, te_wakeup_stats1, - i_stats); - } + i_stats, + 3); + } + else if(C >= 6&&get_nprocs()>=4)//one main two worker + { + encoding_return = + dlsch_encoding_2threads(eNB, + a, + num_pdcch_symbols, + dlsch, + frame, + subframe, + rm_stats, + te_stats, + te_wait_stats, + te_main_stats, + te_wakeup_stats0, + te_wakeup_stats1, + i_stats, + 2); + } + else if(C >= 4&&get_nprocs()>=2)//one main one worker + { + encoding_return = + dlsch_encoding_2threads(eNB, + a, + num_pdcch_symbols, + dlsch, + frame, + subframe, + rm_stats, + te_stats, + te_wait_stats, + te_main_stats, + te_wakeup_stats0, + te_wakeup_stats1, + i_stats, + 1); + } else - { + { encoding_return = dlsch_encoding(eNB, a, @@ -1000,7 +720,7 @@ int dlsch_encoding_all(PHY_VARS_eNB *eNB, rm_stats, te_stats, i_stats); - } + } return encoding_return; } diff --git a/openair1/PHY/LTE_TRANSPORT/proto.h b/openair1/PHY/LTE_TRANSPORT/proto.h index 161a658128..2422b88120 100644 --- a/openair1/PHY/LTE_TRANSPORT/proto.h +++ b/openair1/PHY/LTE_TRANSPORT/proto.h @@ -183,7 +183,8 @@ int32_t dlsch_encoding_2threads(PHY_VARS_eNB *eNB, time_stats_t *te_main_stats, time_stats_t *te_wakeup_stats0, time_stats_t *te_wakeup_stats1, - time_stats_t *i_stats); + time_stats_t *i_stats, + int worker_num); void dlsch_encoding_emul(PHY_VARS_eNB *phy_vars_eNB, uint8_t *DLSCH_pdu, diff --git a/openair1/PHY/defs.h b/openair1/PHY/defs.h index f8645fec97..d5e595aaf0 100644 --- a/openair1/PHY/defs.h +++ b/openair1/PHY/defs.h @@ -279,6 +279,20 @@ typedef struct { LTE_eNB_DLSCH_t *dlsch; int G; int harq_pid; + int total_worker; + int current_worker; + /// \internal This variable is protected by \ref mutex_te. + int instance_cnt_te; + /// pthread attributes for parallel turbo-encoder thread + pthread_attr_t attr_te; + /// scheduling parameters for parallel turbo-encoder thread + struct sched_param sched_param_te; + /// pthread structure for parallel turbo-encoder thread + pthread_t pthread_te; + /// condition variable for parallel turbo-encoder thread + pthread_cond_t cond_te; + /// mutex for parallel turbo-encoder thread + pthread_mutex_t mutex_te; } te_params; typedef struct RU_proc_t_s { diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index bacb2da245..ad90e0dad7 100644 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -1507,41 +1507,42 @@ void init_td_thread(PHY_VARS_eNB *eNB,pthread_attr_t *attr_td) { } extern void *te_thread(void*); -extern void *te_thread1(void*); -extern void *te_thread2(void*); -void init_te_thread(PHY_VARS_eNB *eNB,pthread_attr_t *attr_te,pthread_attr_t *attr_te1) { +void init_te_thread(PHY_VARS_eNB *eNB) { eNB_proc_t *proc = &eNB->proc; proc->tep[0].eNB = eNB; - proc->instance_cnt_te[0] = -1; + proc->tep[0].instance_cnt_te = -1; - pthread_mutex_init( &proc->mutex_te[0], NULL); - pthread_cond_init( &proc->cond_te[0], NULL); + pthread_mutex_init( &proc->tep[0].mutex_te, NULL); + pthread_cond_init( &proc->tep[0].cond_te, NULL); + pthread_attr_init( &proc->tep[0].attr_te); - printf("Creating te_thread\n"); - pthread_create(&proc->pthread_te[0], attr_te, te_thread, (void*)&proc->tep[0]); + printf("Creating te_thread 0\n"); + pthread_create(&proc->tep[0].pthread_te, &proc->tep[0].attr_te, te_thread, (void*)&proc->tep[0]); ///////////////////////////////////////////////////////////////////////// proc->tep[1].eNB = eNB; - proc->instance_cnt_te[1] = -1; + proc->tep[1].instance_cnt_te = -1; - pthread_mutex_init( &proc->mutex_te[1], NULL); - pthread_cond_init( &proc->cond_te[1], NULL); + pthread_mutex_init( &proc->tep[1].mutex_te, NULL); + pthread_cond_init( &proc->tep[1].cond_te, NULL); + pthread_attr_init( &proc->tep[1].attr_te); - printf("Creating te_thread1\n"); - pthread_create(&proc->pthread_te[1], attr_te1, te_thread1, (void*)&proc->tep[1]); + printf("Creating te_thread 1\n"); + pthread_create(&proc->tep[1].pthread_te, &proc->tep[1].attr_te, te_thread, (void*)&proc->tep[1]); ///////////////////////////////////////////////////////////////////////// proc->tep[2].eNB = eNB; - proc->instance_cnt_te[2] = -1; + proc->tep[2].instance_cnt_te = -1; - pthread_mutex_init( &proc->mutex_te[2], NULL); - pthread_cond_init( &proc->cond_te[2], NULL); + pthread_mutex_init( &proc->tep[2].mutex_te, NULL); + pthread_cond_init( &proc->tep[2].cond_te, NULL); + pthread_attr_init( &proc->tep[2].attr_te); - printf("Creating te_thread2\n"); - pthread_create(&proc->pthread_te[2], attr_te1, te_thread2, (void*)&proc->tep[2]); + printf("Creating te_thread 2\n"); + pthread_create(&proc->tep[2].pthread_te, &proc->tep[2].attr_te, te_thread, (void*)&proc->tep[2]); } diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index cf5fe49a6a..d1ec7872d3 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -696,7 +696,7 @@ static void* eNB_thread_prach_br( void* param ) { extern void init_td_thread(PHY_VARS_eNB *, pthread_attr_t *); -extern void init_te_thread(PHY_VARS_eNB *, pthread_attr_t *,pthread_attr_t *); +extern void init_te_thread(PHY_VARS_eNB *); //////////////////////////////////////need to modified////////////////***** static void* process_stats_thread(void* param) { @@ -734,7 +734,7 @@ void init_eNB_proc(int inst) { PHY_VARS_eNB *eNB; eNB_proc_t *proc; eNB_rxtx_proc_t *proc_rxtx; - pthread_attr_t *attr0=NULL,*attr1=NULL,*attr_prach=NULL,*attr_te=NULL,*attr_te1=NULL,*attr_td=NULL; + pthread_attr_t *attr0=NULL,*attr1=NULL,*attr_prach=NULL,*attr_td=NULL;//,*attr_te=NULL,*attr_te1=NULL; #ifdef Rel14 pthread_attr_t *attr_prach_br=NULL; #endif @@ -776,8 +776,8 @@ void init_eNB_proc(int inst) { pthread_attr_init( &proc->attr_prach); pthread_attr_init( &proc->attr_asynch_rxtx); pthread_attr_init( &proc->attr_td); - pthread_attr_init( &proc->attr_te[0]); - pthread_attr_init( &proc->attr_te[1]); + //pthread_attr_init( &proc->attr_te[0]); + //pthread_attr_init( &proc->attr_te[1]); pthread_attr_init( &proc_rxtx[0].attr_rxtx); pthread_attr_init( &proc_rxtx[1].attr_rxtx); #ifdef Rel14 @@ -800,8 +800,8 @@ void init_eNB_proc(int inst) { // attr_te = &proc->attr_te; #endif attr_td = &proc->attr_td; - attr_te = &proc->attr_te[0]; - attr_te1 = &proc->attr_te[1]; + //attr_te = &proc->attr_te[0]; + //attr_te1 = &proc->attr_te[1]; pthread_create( &proc_rxtx[0].pthread_rxtx, attr0, eNB_thread_rxtx, proc ); pthread_create( &proc_rxtx[1].pthread_rxtx, attr1, tx_thread, proc); if (eNB->single_thread_flag==0) { @@ -824,7 +824,7 @@ void init_eNB_proc(int inst) { //////////////////////////////////////need to modified////////////////***** - init_te_thread(eNB,attr_te,attr_te1); + init_te_thread(eNB); init_td_thread(eNB,attr_td); if (opp_enabled == 1) pthread_create(&proc->process_stats_thread,NULL,process_stats_thread,(void*)eNB); From f0376d1b4fef5c8f59cb27ad9d28702495cc9c40 Mon Sep 17 00:00:00 2001 From: Massive Date: Fri, 19 Jan 2018 13:00:51 +0100 Subject: [PATCH 30/63] adding uhd network interface --- targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp | 15 +- .../CONF/enb.band7.tm1.100PRB.usrpx310.conf | 209 ++++++++++++++++++ 2 files changed, 219 insertions(+), 5 deletions(-) create mode 100644 targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.100PRB.usrpx310.conf diff --git a/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp b/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp index f83dc21787..e9b8131d6c 100644 --- a/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp +++ b/targets/ARCH/USRP/USERSPACE/LIB/usrp_lib.cpp @@ -716,15 +716,20 @@ extern "C" { // workaround for an api problem, master clock has to be set with the constructor not via set_master_clock_rate args += boost::str(boost::format(",master_clock_rate=%f") % usrp_master_clock); -// args += ",num_send_frames=256,num_recv_frames=256, send_frame_size=4096, recv_frame_size=4096"; - // args += ",num_send_frames=256,num_recv_frames=256, send_frame_size=4096, recv_frame_size=4096"; uhd::device_addrs_t device_adds = uhd::device::find(args); if(device_adds.size() == 0) { - std::cerr<<"No USRP Device Found. " << std::endl; - free(s); - return -1; + args += ",addr=192.168.30.2"; + + uhd::device_addrs_t device_adds = uhd::device::find(args); + + if(device_adds.size() == 0) { + + std::cerr<<"No USRP Device Found. " << std::endl; + free(s); + return -1; + } } LOG_I(PHY,"Found USRP X300\n"); s->usrp = uhd::usrp::multi_usrp::make(args); diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.100PRB.usrpx310.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.100PRB.usrpx310.conf new file mode 100644 index 0000000000..c1c858f95e --- /dev/null +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.100PRB.usrpx310.conf @@ -0,0 +1,209 @@ +Active_eNBs = ( "eNB_Eurecom_LTEBox"); +# Asn1_verbosity, choice in: none, info, annoying +Asn1_verbosity = "none"; + +eNBs = +( + { + ////////// Identification parameters: + eNB_ID = 0xe00; + + cell_type = "CELL_MACRO_ENB"; + + eNB_name = "eNB_Eurecom_LTEBox"; + + // Tracking area code, 0x0000 and 0xfffe are reserved values + tracking_area_code = "1"; + + mobile_country_code = "208"; + + mobile_network_code = "93"; + + tr_s_preference = "local_mac" + + ////////// Physical parameters: + + component_carriers = ( + { + node_function = "eNodeB_3GPP"; + node_timing = "synch_to_ext_device"; + node_synch_ref = 0; + frame_type = "FDD"; + tdd_config = 3; + tdd_config_s = 0; + prefix_type = "NORMAL"; + eutra_band = 7; + downlink_frequency = 2685000000L; + uplink_frequency_offset = -120000000; + Nid_cell = 0; + N_RB_DL = 100; + Nid_cell_mbsfn = 0; + nb_antenna_ports = 1; + nb_antennas_tx = 1; + nb_antennas_rx = 1; + tx_gain = 90; + rx_gain = 125; + pbch_repetition = "FALSE"; + prach_root = 0; + prach_config_index = 0; + prach_high_speed = "DISABLE"; + prach_zero_correlation = 1; + prach_freq_offset = 2; + pucch_delta_shift = 1; + pucch_nRB_CQI = 1; + pucch_nCS_AN = 0; + pucch_n1_AN = 32; + pdsch_referenceSignalPower = -27; + pdsch_p_b = 0; + pusch_n_SB = 1; + pusch_enable64QAM = "DISABLE"; + pusch_hoppingMode = "interSubFrame"; + pusch_hoppingOffset = 0; + pusch_groupHoppingEnabled = "ENABLE"; + pusch_groupAssignment = 0; + pusch_sequenceHoppingEnabled = "DISABLE"; + pusch_nDMRS1 = 1; + phich_duration = "NORMAL"; + phich_resource = "ONESIXTH"; + srs_enable = "DISABLE"; + /* srs_BandwidthConfig =; + srs_SubframeConfig =; + srs_ackNackST =; + srs_MaxUpPts =;*/ + + pusch_p0_Nominal = -96; + pusch_alpha = "AL1"; + pucch_p0_Nominal = -104; + msg3_delta_Preamble = 6; + pucch_deltaF_Format1 = "deltaF2"; + pucch_deltaF_Format1b = "deltaF3"; + pucch_deltaF_Format2 = "deltaF0"; + pucch_deltaF_Format2a = "deltaF0"; + pucch_deltaF_Format2b = "deltaF0"; + + rach_numberOfRA_Preambles = 64; + rach_preamblesGroupAConfig = "DISABLE"; + /* + rach_sizeOfRA_PreamblesGroupA = ; + rach_messageSizeGroupA = ; + rach_messagePowerOffsetGroupB = ; + */ + rach_powerRampingStep = 4; + rach_preambleInitialReceivedTargetPower = -108; + rach_preambleTransMax = 10; + rach_raResponseWindowSize = 10; + rach_macContentionResolutionTimer = 48; + rach_maxHARQ_Msg3Tx = 4; + + pcch_default_PagingCycle = 128; + pcch_nB = "oneT"; + bcch_modificationPeriodCoeff = 2; + ue_TimersAndConstants_t300 = 1000; + ue_TimersAndConstants_t301 = 1000; + ue_TimersAndConstants_t310 = 1000; + ue_TimersAndConstants_t311 = 10000; + ue_TimersAndConstants_n310 = 20; + ue_TimersAndConstants_n311 = 1; + ue_TransmissionMode = 1; + } + ); + + + srb1_parameters : + { + # timer_poll_retransmit = (ms) [5, 10, 15, 20,... 250, 300, 350, ... 500] + timer_poll_retransmit = 80; + + # timer_reordering = (ms) [0,5, ... 100, 110, 120, ... ,200] + timer_reordering = 35; + + # timer_reordering = (ms) [0,5, ... 250, 300, 350, ... ,500] + timer_status_prohibit = 0; + + # poll_pdu = [4, 8, 16, 32 , 64, 128, 256, infinity(>10000)] + poll_pdu = 4; + + # poll_byte = (kB) [25,50,75,100,125,250,375,500,750,1000,1250,1500,2000,3000,infinity(>10000)] + poll_byte = 99999; + + # max_retx_threshold = [1, 2, 3, 4 , 6, 8, 16, 32] + max_retx_threshold = 4; + } + + # ------- SCTP definitions + SCTP : + { + # Number of streams to use in input/output + SCTP_INSTREAMS = 2; + SCTP_OUTSTREAMS = 2; + }; + + + ////////// MME parameters: + mme_ip_address = ( { ipv4 = "192.168.12.26"; + ipv6 = "192:168:30::17"; + active = "yes"; + preference = "ipv4"; + } + ); + + NETWORK_INTERFACES : + { + + ENB_INTERFACE_NAME_FOR_S1_MME = "em1"; + ENB_IPV4_ADDRESS_FOR_S1_MME = "192.168.12.155/24"; + ENB_INTERFACE_NAME_FOR_S1U = "em1"; + ENB_IPV4_ADDRESS_FOR_S1U = "192.168.12.155/24"; + ENB_PORT_FOR_S1U = 2152; # Spec 2152 + }; + } +); + +MACRLCs = ( + { + num_cc = 1; + tr_s_preference = "local_L1"; + tr_n_preference = "local_RRC"; + } +); + +L1s = ( + { + num_cc = 1; + tr_n_preference = "local_mac"; + } +); + +RUs = ( + { + local_rf = "yes" + nb_tx = 1 + nb_rx = 1 + att_tx = 0 + att_rx = 0; + bands = [7]; + max_pdschReferenceSignalPower = -27; + max_rxgain = 116; + eNB_instances = [0]; + + } +); + + log_config : + { + global_log_level ="info"; + global_log_verbosity ="medium"; + hw_log_level ="info"; + hw_log_verbosity ="medium"; + phy_log_level ="info"; + phy_log_verbosity ="medium"; + mac_log_level ="info"; + mac_log_verbosity ="medium"; + rlc_log_level ="info"; + rlc_log_verbosity ="medium"; + pdcp_log_level ="info"; + pdcp_log_verbosity ="medium"; + rrc_log_level ="info"; + rrc_log_verbosity ="medium"; + }; + From 5d199f45004a35134545ad6c55e73ec38ac15a78 Mon Sep 17 00:00:00 2001 From: Massive Date: Mon, 22 Jan 2018 09:29:19 +0100 Subject: [PATCH 31/63] adding an addition error check on harq_pid as it is sometimes not in range. root cause still to be identified --- openair1/SCHED/phy_procedures_lte_eNb.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index ad90e0dad7..210933591f 100644 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -518,7 +518,7 @@ void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB, // get harq_pid harq_pid = dlsch0->harq_ids[subframe]; - AssertFatal(harq_pid>=0,"harq_pid is negative\n"); + if ((harq_pid>=0) && (harq_pid<8)) { // generate pdsch pdsch_procedures(eNB, proc, @@ -527,7 +527,9 @@ void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB, dlsch1, &eNB->UE_stats[(uint32_t)UE_id], 0); - + } else { + LOG_E(PHY,"harq_pid %d is not valid, not generating PDSCH\n",harq_pid); + } } From 30d5f151c39c44f93f9863b2b5ca5cbd838916a8 Mon Sep 17 00:00:00 2001 From: Eurecom Date: Mon, 22 Jan 2018 18:02:02 +0100 Subject: [PATCH 32/63] specified modulation for QPSK --- openair1/PHY/INIT/lte_init.c | 1 + openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c | 206 +++++++++++++++++- openair1/PHY/LTE_TRANSPORT/extern.h | 2 +- openair1/PHY/LTE_TRANSPORT/vars.h | 2 +- openair1/PHY/impl_defs_top.h | 3 + openair2/LAYER2/MAC/eNB_scheduler_phytest.c | 2 +- targets/RT/USER/lte-ru.c | 2 +- 7 files changed, 209 insertions(+), 9 deletions(-) diff --git a/openair1/PHY/INIT/lte_init.c b/openair1/PHY/INIT/lte_init.c index 9c9ab1a29b..db9306f5c2 100644 --- a/openair1/PHY/INIT/lte_init.c +++ b/openair1/PHY/INIT/lte_init.c @@ -1274,6 +1274,7 @@ void init_lte_top(LTE_DL_FRAME_PARMS *frame_parms) generate_64qam_table(); generate_16qam_table(); + generate_qpsk_table(); generate_RIV_tables(); init_unscrambling_lut(); diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c b/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c index 873e47ec76..f6b3104402 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c @@ -121,6 +121,16 @@ void generate_16qam_table(void) } } +void generate_qpsk_table(void) +{ + + int a,index; + + for (a=-1; a<=1; a+=2) + index = (1+a)/2; + qpsk_table[index] = -a*QPSK; +} + @@ -158,6 +168,158 @@ void layer1prec2A(int32_t *antenna0_sample, int32_t *antenna1_sample, uint8_t pr uint32_t FOUR[2]={0,4}; uint32_t TWO[2]={0,2}; +int allocate_REs_in_RB_no_pilots_QPSK_siso(PHY_VARS_eNB* phy_vars_eNB, + int **txdataF, + uint32_t *jj, + uint32_t *jj2, + uint16_t re_offset, + uint32_t symbol_offset, + LTE_DL_eNB_HARQ_t *dlsch0_harq, + LTE_DL_eNB_HARQ_t *dlsch1_harq, + uint8_t pilots, + int16_t amp, + uint8_t precoder_index, + int16_t *qam_table_s0, + int16_t *qam_table_s1, + uint32_t *re_allocated, + uint8_t skip_dc, + uint8_t skip_half, + uint8_t lprime, + uint8_t mprime, + uint8_t Ns, + int *P1_SHIFT, + int *P2_SHIFT) +{ + + LTE_DL_FRAME_PARMS *frame_parms = &phy_vars_eNB->frame_parms; + uint8_t *x0 = dlsch0_harq->e; + uint32_t qpsk_table_offset_re = 0; + uint32_t qpsk_table_offset_im = 0; + + uint32_t tti_offset; + uint8_t re; + uint8_t *x0p; + + if (skip_dc == 0) { + for (x0p=&x0[*jj],tti_offset=symbol_offset+re_offset,re=0; + re<12; + re++,x0p+=2,tti_offset++) { + + qpsk_table_offset_re=x0p[0]; + qpsk_table_offset_im=x0p[1]; + ((int16_t *)&txdataF[0][tti_offset])[0]=qam_table_s0[qpsk_table_offset_re]; + ((int16_t *)&txdataF[0][tti_offset])[1]=qam_table_s0[qpsk_table_offset_im]; + } + } + else { + // 1st half of PRB + for (x0p=&x0[*jj],tti_offset=symbol_offset+re_offset,re=0; + re<6; + re++,x0p+=2,tti_offset++) { + + qpsk_table_offset_re=x0p[0]; + qpsk_table_offset_im=x0p[1]; + ((int16_t *)&txdataF[0][tti_offset])[0]=qam_table_s0[qpsk_table_offset_re]; + ((int16_t *)&txdataF[0][tti_offset])[1]=qam_table_s0[qpsk_table_offset_im]; + } + // 2nd half of PRB + for (tti_offset=symbol_offset+re_offset-frame_parms->ofdm_symbol_size+7; + re<12; + re++,x0p+=2,tti_offset++) { + + qpsk_table_offset_re=x0p[0]; + qpsk_table_offset_im=x0p[1]; + ((int16_t *)&txdataF[0][tti_offset])[0]=qam_table_s0[qpsk_table_offset_re]; + ((int16_t *)&txdataF[0][tti_offset])[1]=qam_table_s0[qpsk_table_offset_im]; + } + } + *re_allocated = *re_allocated + 12; + *jj=*jj + 24; + + return(0); +} + +int allocate_REs_in_RB_pilots_QPSK_siso(PHY_VARS_eNB* phy_vars_eNB, + int **txdataF, + uint32_t *jj, + uint32_t *jj2, + uint16_t re_offset, + uint32_t symbol_offset, + LTE_DL_eNB_HARQ_t *dlsch0_harq, + LTE_DL_eNB_HARQ_t *dlsch1_harq, + uint8_t pilots, + int16_t amp, + uint8_t precoder_index, + int16_t *qam_table_s0, + int16_t *qam_table_s1, + uint32_t *re_allocated, + uint8_t skip_dc, + uint8_t skip_half, + uint8_t lprime, + uint8_t mprime, + uint8_t Ns, + int *P1_SHIFT, + int *P2_SHIFT) +{ + + + LTE_DL_FRAME_PARMS *frame_parms=&phy_vars_eNB->frame_parms; + + uint8_t *x0 = dlsch0_harq->e; + uint32_t qpsk_table_offset_re = 0; + uint32_t qpsk_table_offset_im = 0; + + uint32_t tti_offset; + uint8_t re; + uint8_t *x0p; + + + if (skip_dc == 0) { + // printf("pilots: P1_SHIFT[0] %d\n",P1_SHIFT[0]); + for (x0p=&x0[*jj],tti_offset=symbol_offset+re_offset+P1_SHIFT[0],re=P1_SHIFT[0]; + re<12; + x0p+=2) { + + qpsk_table_offset_re=x0p[0]; + qpsk_table_offset_im=x0p[1]; + ((int16_t *)&txdataF[0][tti_offset])[0]=qam_table_s0[qpsk_table_offset_re]; + ((int16_t *)&txdataF[0][tti_offset])[1]=qam_table_s0[qpsk_table_offset_im]; + // printf("pilots: re %d, tti_offset %d, P1_SHIFT %d\n",re,tti_offset,P1_SHIFT[re+1]); + tti_offset+=P1_SHIFT[re+1]; + re+=P1_SHIFT[re+1]; + } + } + else { + for (x0p=&x0[*jj],tti_offset=symbol_offset+re_offset+P1_SHIFT[0],re=P1_SHIFT[0]; + re<6; + x0p+=2) { + + qpsk_table_offset_re+=x0p[0]; + qpsk_table_offset_im+=x0p[1]; + ((int16_t *)&txdataF[0][tti_offset])[0]=qam_table_s0[qpsk_table_offset_re]; + ((int16_t *)&txdataF[0][tti_offset])[1]=qam_table_s0[qpsk_table_offset_im]; + tti_offset+=P1_SHIFT[re+1]; + re+=P1_SHIFT[re+1]; + } + + for (tti_offset=symbol_offset+re_offset-frame_parms->ofdm_symbol_size+6+P1_SHIFT[6]; + re<12; + x0p+=2) { + + qpsk_table_offset_re+=x0p[0]; + qpsk_table_offset_im+=x0p[1]; + ((int16_t *)&txdataF[0][tti_offset])[0]=qam_table_s0[qpsk_table_offset_re]; + ((int16_t *)&txdataF[0][tti_offset])[1]=qam_table_s0[qpsk_table_offset_im]; + tti_offset+=P1_SHIFT[re+1]; + re+=P1_SHIFT[re+1]; + } + } + *re_allocated = *re_allocated + 10; + *jj=*jj + 20; + + return(0); +} + int allocate_REs_in_RB_no_pilots_16QAM_siso(PHY_VARS_eNB* phy_vars_eNB, int **txdataF, uint32_t *jj, @@ -2012,8 +2174,8 @@ int dlsch_modulation(PHY_VARS_eNB* phy_vars_eNB, uint8_t mod_order0 = 0; uint8_t mod_order1 = 0; int16_t amp_rho_a, amp_rho_b; - int16_t qam16_table_a0[4],qam64_table_a0[8],qam16_table_b0[4],qam64_table_b0[8]; - int16_t qam16_table_a1[4],qam64_table_a1[8],qam16_table_b1[4],qam64_table_b1[8]; + int16_t qpsk_table_a0[2],qam16_table_a0[4],qam64_table_a0[8],qpsk_table_b0[2],qam16_table_b0[4],qam64_table_b0[8]; + int16_t qpsk_table_a1[2],qam16_table_a1[4],qam64_table_a1[8],qpsk_table_b1[2],qam16_table_b1[4],qam64_table_b1[8]; int16_t *qam_table_s0=NULL,*qam_table_s1=NULL; #ifdef NEW_ALLOC_RE @@ -2126,7 +2288,15 @@ int dlsch_modulation(PHY_VARS_eNB* phy_vars_eNB, amp_rho_b = (int16_t)(((int32_t)amp*dlsch1->sqrt_rho_b)>>13); } - if (mod_order0 == 4) + if(mod_order0 == 2) + { + for(i=0;i<2;i++) + { + qpsk_table_a0[i] = (int16_t)(((int32_t)qpsk_table[i]*amp_rho_a)>>15); + qpsk_table_b0[i] = (int16_t)(((int32_t)qpsk_table[i]*amp_rho_b)>>15); + } + } + else if (mod_order0 == 4) for (i=0;i<4; i++) { qam16_table_a0[i] = (int16_t)(((int32_t)qam16_table[i]*amp_rho_a)>>15); qam16_table_b0[i] = (int16_t)(((int32_t)qam16_table[i]*amp_rho_b)>>15); @@ -2137,7 +2307,14 @@ int dlsch_modulation(PHY_VARS_eNB* phy_vars_eNB, qam64_table_b0[i] = (int16_t)(((int32_t)qam64_table[i]*amp_rho_b)>>15); } - if (mod_order1 == 4) + if (mod_order1 == 2) + { + for (i=0; i<2; i++) { + qpsk_table_a1[i] = (int16_t)(((int32_t)qpsk_table[i]*amp_rho_a)>>15); + qpsk_table_b1[i] = (int16_t)(((int32_t)qpsk_table[i]*amp_rho_b)>>15); + } + } + else if (mod_order1 == 4) for (i=0; i<4; i++) { qam16_table_a1[i] = (int16_t)(((int32_t)qam16_table[i]*amp_rho_a)>>15); qam16_table_b1[i] = (int16_t)(((int32_t)qam16_table[i]*amp_rho_b)>>15); @@ -2265,7 +2442,26 @@ int dlsch_modulation(PHY_VARS_eNB* phy_vars_eNB, switch (mod_order0) { case 2: - qam_table_s0 = NULL; + //qam_table_s0 = NULL; + if (pilots) { + qam_table_s0 = qpsk_table_b0; +#ifdef NEW_ALLOC_RE + /* TODO: remove this code? */ + allocate_REs = (dlsch0->harq_processes[harq_pid]->mimo_mode == SISO) ? + allocate_REs_in_RB_pilots_QPSK_siso : + allocate_REs_in_RB; +#endif + } + else { + qam_table_s0 = qpsk_table_a0; +#ifdef NEW_ALLOC_RE + /* TODO: remove this code? */ + allocate_REs = (dlsch0->harq_processes[harq_pid]->mimo_mode == SISO) ? + allocate_REs_in_RB_no_pilots_QPSK_siso : + allocate_REs_in_RB; +#endif + + } break; case 4: if (pilots) { diff --git a/openair1/PHY/LTE_TRANSPORT/extern.h b/openair1/PHY/LTE_TRANSPORT/extern.h index af4dc20df6..723177f6c9 100644 --- a/openair1/PHY/LTE_TRANSPORT/extern.h +++ b/openair1/PHY/LTE_TRANSPORT/extern.h @@ -30,7 +30,7 @@ extern short *ul_ref_sigs_rx[30][2][33]; extern unsigned short dftsizes[33]; extern unsigned short ref_primes[33]; -extern int qam64_table[8],qam16_table[4]; +extern int qam64_table[8],qam16_table[4],qpsk_table[2]; extern unsigned char cs_ri_normal[4]; extern unsigned char cs_ri_extended[4]; diff --git a/openair1/PHY/LTE_TRANSPORT/vars.h b/openair1/PHY/LTE_TRANSPORT/vars.h index 4845ab6925..886b067cf6 100644 --- a/openair1/PHY/LTE_TRANSPORT/vars.h +++ b/openair1/PHY/LTE_TRANSPORT/vars.h @@ -62,7 +62,7 @@ unsigned char ue_power_offsets[25] = {14,11,9,8,7,6,6,5,4,4,4,3,3,3,2,2,2,1,1,1, short conjugate[8]__attribute__((aligned(16))) = {-1,1,-1,1,-1,1,-1,1}; short conjugate2[8]__attribute__((aligned(16))) = {1,-1,1,-1,1,-1,1,-1}; -int qam64_table[8],qam16_table[4]; +int qam64_table[8],qam16_table[4],qpsk_table[2]; unsigned char cs_ri_normal[4] = {1,4,7,10}; unsigned char cs_ri_extended[4] = {0,3,5,8}; diff --git a/openair1/PHY/impl_defs_top.h b/openair1/PHY/impl_defs_top.h index b510f8bb3f..13b6d1c8a7 100644 --- a/openair1/PHY/impl_defs_top.h +++ b/openair1/PHY/impl_defs_top.h @@ -207,6 +207,9 @@ // QAM amplitude definitions +/// Amplitude for QPSK (\f$ 2^15 \times 1/\sqrt{2}\f$) +#define QPSK 23170 + /// First Amplitude for QAM16 (\f$ 2^{15} \times 2/\sqrt{10}\f$) #define QAM16_n1 20724 /// Second Amplitude for QAM16 (\f$ 2^{15} \times 1/\sqrt{10}\f$) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_phytest.c b/openair2/LAYER2/MAC/eNB_scheduler_phytest.c index 203358e0e1..820fd526d3 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_phytest.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_phytest.c @@ -71,7 +71,7 @@ schedule_ue_spec_phy_test( uint16_t rnti = 0x1235; uint32_t rb_alloc = 0x1FFFFFFF; int32_t tpc = 1; - int32_t mcs = 28; + int32_t mcs = 0; int32_t cqi = 15; int32_t ndi = subframeP/5; int32_t dai = 0; diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index 0b5a1e6087..76442c8ce9 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -686,7 +686,7 @@ static void* emulatedRF_thread(void* param) { int microsec = 500; // length of time to sleep, in miliseconds struct timespec req = {0}; req.tv_sec = 0; - req.tv_nsec = ((microsec * 1000L)/numerology); + req.tv_nsec = (numerology>0)? ((microsec * 1000L)/numerology):(microsec * 1000L)*2; cpu_set_t cpuset; CPU_SET(1,&cpuset); pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); From 13c8931bf26bf51bb4866ffd6c1ca2491bc1c1a5 Mon Sep 17 00:00:00 2001 From: Florian Kaltenberger Date: Thu, 25 Jan 2018 15:57:57 +0100 Subject: [PATCH 33/63] bugfix in modulation --- openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c b/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c index f6b3104402..868f9e0e9f 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c @@ -126,9 +126,10 @@ void generate_qpsk_table(void) int a,index; - for (a=-1; a<=1; a+=2) + for (a=-1; a<=1; a+=2) { index = (1+a)/2; qpsk_table[index] = -a*QPSK; + } } @@ -2511,10 +2512,6 @@ int dlsch_modulation(PHY_VARS_eNB* phy_vars_eNB, switch (mod_order1) { case 2: qam_table_s1 = NULL; -#ifdef NEW_ALLOC_RE - /* TODO: remove this code? */ - allocate_REs = allocate_REs_in_RB; -#endif break; case 4: if (pilots) { From 3efaa383949fee27874ea3a9ef814e19c3a75d22 Mon Sep 17 00:00:00 2001 From: Wang Tsu-Han Date: Fri, 26 Jan 2018 18:05:17 +0100 Subject: [PATCH 34/63] adjustable thread structure --- cmake_targets/CMakeLists.txt | 2 +- openair1/PHY/LTE_TRANSPORT/dlsch_coding.c | 36 ++++++---- openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c | 4 +- openair1/SCHED/ru_procedures.c | 4 +- openair2/LAYER2/MAC/eNB_scheduler_phytest.c | 2 +- .../CONF/enb.band7.tm1.100PRB.usrpx310.conf | 8 +-- targets/RT/USER/lte-enb.c | 42 +++++++----- targets/RT/USER/lte-ru.c | 66 +++++++++---------- targets/RT/USER/lte-softmodem.c | 5 +- targets/RT/USER/lte-softmodem.h | 66 ++++++++++--------- 10 files changed, 131 insertions(+), 104 deletions(-) diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 6cce5e306e..67b2360517 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -597,7 +597,7 @@ add_boolean_option(NAS_ADDRESS_FIX False "specific to oaisim: for nasmesh driver add_boolean_option(NAS_NETLINK False "???? Must be True to compile nasmesh driver without rtai") add_boolean_option(OAISIM False "specific to oaisim") add_boolean_option(OAI_NW_DRIVER_USE_NETLINK True "????") -add_boolean_option(EMULATE_RF True "allows to run lte-softmodem without HW") +add_boolean_option(EMULATE_RF False "allows to run lte-softmodem without HW") add_boolean_option(USE_MME False "this flag is used only one time in lte-softmodem.c") add_list_string_option(PACKAGE_NAME "NotDefined" "As per attribute name") diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c index 461bf60442..fce305d9db 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c @@ -58,6 +58,8 @@ uint64_t deadline, uint64_t period);*/ +extern int codingw; + void free_eNB_dlsch(LTE_eNB_DLSCH_t *dlsch) { int i; @@ -606,16 +608,28 @@ int dlsch_encoding_2threads(PHY_VARS_eNB *eNB, } stop_meas(te_main_stats); - // wait for worker to finish start_meas(te_wait_stats); - wait_on_busy_condition(&proc->tep[0].mutex_te,&proc->tep[0].cond_te,&proc->tep[0].instance_cnt_te,"te thread 0"); - wait_on_busy_condition(&proc->tep[1].mutex_te,&proc->tep[1].cond_te,&proc->tep[1].instance_cnt_te,"te thread 1"); - wait_on_busy_condition(&proc->tep[2].mutex_te,&proc->tep[2].cond_te,&proc->tep[2].instance_cnt_te,"te thread 2"); - stop_meas(te_wait_stats); - if(opp_enabled == 1 && te_wait_stats->diff_now>100*3000){ - print_meas_now(te_wait_stats,"coding_wait",stderr); - printf("delay in wait on codition in frame_rx: %d \n",proc->frame_rx); + if(worker_num == 1) + { + wait_on_busy_condition(&proc->tep[0].mutex_te,&proc->tep[0].cond_te,&proc->tep[0].instance_cnt_te,"te thread 0"); } + else if(worker_num == 2) + { + wait_on_busy_condition(&proc->tep[0].mutex_te,&proc->tep[0].cond_te,&proc->tep[0].instance_cnt_te,"te thread 0"); + wait_on_busy_condition(&proc->tep[1].mutex_te,&proc->tep[1].cond_te,&proc->tep[1].instance_cnt_te,"te thread 1"); + } + else + { + wait_on_busy_condition(&proc->tep[0].mutex_te,&proc->tep[0].cond_te,&proc->tep[0].instance_cnt_te,"te thread 0"); + wait_on_busy_condition(&proc->tep[1].mutex_te,&proc->tep[1].cond_te,&proc->tep[1].instance_cnt_te,"te thread 1"); + wait_on_busy_condition(&proc->tep[2].mutex_te,&proc->tep[2].cond_te,&proc->tep[2].instance_cnt_te,"te thread 2"); + } + stop_meas(te_wait_stats); + + /*if(opp_enabled == 1 && te_wait_stats->diff_now>100*3000){ + print_meas_now(te_wait_stats,"coding_wait",stderr); + printf("coding delay in wait on codition in frame_rx: %d \n",proc->frame_rx); + }*/ VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ENCODING, VCD_FUNCTION_OUT); @@ -654,7 +668,7 @@ int dlsch_encoding_all(PHY_VARS_eNB *eNB, } } - if(C >= 8&&get_nprocs()>=6)//one main three worker + if(C >= 8 && get_nprocs()>8 && codingw)//one main three worker { encoding_return = dlsch_encoding_2threads(eNB, @@ -672,7 +686,7 @@ int dlsch_encoding_all(PHY_VARS_eNB *eNB, i_stats, 3); } - else if(C >= 6&&get_nprocs()>=4)//one main two worker + else if(C >= 6 && get_nprocs()>=6 && codingw)//one main two worker { encoding_return = dlsch_encoding_2threads(eNB, @@ -690,7 +704,7 @@ int dlsch_encoding_all(PHY_VARS_eNB *eNB, i_stats, 2); } - else if(C >= 4&&get_nprocs()>=2)//one main one worker + else if(C >= 4 && get_nprocs()>=4 && codingw)//one main one worker { encoding_return = dlsch_encoding_2threads(eNB, diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c index 19c7f6aa54..015279c9c2 100644 --- a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c +++ b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c @@ -52,6 +52,8 @@ #include "UTIL/LOG/vcd_signal_dumper.h" //#define DEBUG_ULSCH_DECODING +extern int codingw; + void free_eNB_ulsch(LTE_eNB_ULSCH_t *ulsch) { @@ -817,7 +819,7 @@ int ulsch_decoding_data_all(PHY_VARS_eNB *eNB,int UE_id,int harq_pid,int llr8_fl int ret = 0; LTE_eNB_ULSCH_t *ulsch = eNB->ulsch[UE_id]; LTE_UL_eNB_HARQ_t *ulsch_harq = ulsch->harq_processes[harq_pid]; - if(ulsch_harq->C>3) + if(ulsch_harq->C>3 && get_nprocs()>=2 && codingw) { ret = ulsch_decoding_data_2thread(eNB,UE_id,harq_pid,llr8_flag); } diff --git a/openair1/SCHED/ru_procedures.c b/openair1/SCHED/ru_procedures.c index 2e460e7571..decbe38c69 100644 --- a/openair1/SCHED/ru_procedures.c +++ b/openair1/SCHED/ru_procedures.c @@ -222,10 +222,10 @@ void feptx_ofdm_2thread(RU_t *ru) { start_meas(&ru->ofdm_mod_wait_stats); wait_on_busy_condition(&proc->mutex_feptx,&proc->cond_feptx,&proc->instance_cnt_feptx,"feptx thread"); stop_meas(&ru->ofdm_mod_wait_stats); - if(opp_enabled == 1 && ru->ofdm_mod_wait_stats.diff_now>30*3000){ + /*if(opp_enabled == 1 && ru->ofdm_mod_wait_stats.diff_now>30*3000){ print_meas_now(&ru->ofdm_mod_wait_stats,"fep wakeup",stderr); printf("delay in feptx wait on codition in frame_rx: %d subframe_rx: %d \n",proc->frame_tx,proc->subframe_tx); - } + }*/ stop_meas(&ru->ofdm_mod_stats); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPTX_OFDM , 0 ); diff --git a/openair2/LAYER2/MAC/eNB_scheduler_phytest.c b/openair2/LAYER2/MAC/eNB_scheduler_phytest.c index 820fd526d3..203358e0e1 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_phytest.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_phytest.c @@ -71,7 +71,7 @@ schedule_ue_spec_phy_test( uint16_t rnti = 0x1235; uint32_t rb_alloc = 0x1FFFFFFF; int32_t tpc = 1; - int32_t mcs = 0; + int32_t mcs = 28; int32_t cqi = 15; int32_t ndi = subframeP/5; int32_t dai = 0; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.100PRB.usrpx310.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.100PRB.usrpx310.conf index c1c858f95e..6c7c319a11 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.100PRB.usrpx310.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.100PRB.usrpx310.conf @@ -150,10 +150,10 @@ eNBs = NETWORK_INTERFACES : { - ENB_INTERFACE_NAME_FOR_S1_MME = "em1"; - ENB_IPV4_ADDRESS_FOR_S1_MME = "192.168.12.155/24"; - ENB_INTERFACE_NAME_FOR_S1U = "em1"; - ENB_IPV4_ADDRESS_FOR_S1U = "192.168.12.155/24"; + ENB_INTERFACE_NAME_FOR_S1_MME = "eth6"; + ENB_IPV4_ADDRESS_FOR_S1_MME = "192.168.12.111/24"; + ENB_INTERFACE_NAME_FOR_S1U = "eth6"; + ENB_IPV4_ADDRESS_FOR_S1U = "192.168.12.111/24"; ENB_PORT_FOR_S1U = 2152; # Spec 2152 }; } diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index d1ec7872d3..1845268138 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -150,6 +150,7 @@ void wakeup_prach_eNB(PHY_VARS_eNB *eNB,RU_t *ru,int frame,int subframe); #ifdef Rel14 void wakeup_prach_eNB_br(PHY_VARS_eNB *eNB,RU_t *ru,int frame,int subframe); #endif +extern int codingw; static inline int rxtx(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, char *thread_name) { @@ -182,14 +183,25 @@ static inline int rxtx(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, char *thread_nam VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER , 0 ); - wakeup_tx(eNB,eNB->proc.ru_proc); - //if(oai_exit) return(-1); - //phy_procedures_eNB_TX(eNB, proc, no_relay, NULL, 1); - // - //pthread_mutex_lock(&eNB->proc.ru_proc->mutex_eNBs); - //++eNB->proc.ru_proc->instance_cnt_eNBs; - //pthread_cond_signal(&eNB->proc.ru_proc->cond_eNBs); - //pthread_mutex_unlock(&eNB->proc.ru_proc->mutex_eNBs); + if(get_nprocs() > 8) + { + wakeup_tx(eNB,eNB->proc.ru_proc); + } + else if(get_nprocs() > 4) + { + if(oai_exit) return(-1); + phy_procedures_eNB_TX(eNB, proc, no_relay, NULL, 1); + + pthread_mutex_lock(&eNB->proc.ru_proc->mutex_eNBs); + ++eNB->proc.ru_proc->instance_cnt_eNBs; + pthread_cond_signal(&eNB->proc.ru_proc->cond_eNBs); + pthread_mutex_unlock(&eNB->proc.ru_proc->mutex_eNBs); + } + else + { + if(oai_exit) return(-1); + phy_procedures_eNB_TX(eNB, proc, no_relay, NULL, 1); + } stop_meas( &softmodem_stats_rxtx_sf ); @@ -350,10 +362,6 @@ void eNB_top(PHY_VARS_eNB *eNB, int frame_rx, int subframe_rx, char *string,RU_t if (rxtx(eNB,proc_rxtx,string) < 0) LOG_E(PHY,"eNB %d CC_id %d failed during execution\n",eNB->Mod_id,eNB->CC_id); LOG_D(PHY,"eNB_top out %p (proc %p, CC_id %d), frame %d, subframe %d, instance_cnt_prach %d\n", (void*)pthread_self(), proc, eNB->CC_id, proc->frame_rx,proc->subframe_rx,proc->instance_cnt_prach); - pthread_mutex_lock(&ru_proc->mutex_eNBs); - ++ru_proc->instance_cnt_eNBs; - pthread_mutex_unlock(&ru_proc->mutex_eNBs); - pthread_cond_signal(&ru_proc->cond_eNBs); } } @@ -824,9 +832,13 @@ void init_eNB_proc(int inst) { //////////////////////////////////////need to modified////////////////***** - init_te_thread(eNB); - init_td_thread(eNB,attr_td); - if (opp_enabled == 1) pthread_create(&proc->process_stats_thread,NULL,process_stats_thread,(void*)eNB); + //printf("//////////////////////////////////////////////////////////////////**************************************************************** codingw = %d\n",codingw); + if(get_nprocs() > 2 && codingw) + { + init_te_thread(eNB); + init_td_thread(eNB,attr_td); + } + if (opp_enabled == 1) pthread_create(&proc->process_stats_thread,NULL,process_stats_thread,(void*)eNB); } diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index 76442c8ce9..2fe02a10e8 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -113,7 +113,7 @@ unsigned short config_frames[4] = {2,9,11,13}; extern volatile int oai_exit; extern int numerology; -extern int fh_two_thread; +extern int fepw; extern void phy_init_RU(RU_t*); @@ -681,6 +681,7 @@ void fh_if4p5_north_out(RU_t *ru) { if (ru->idx == 0) VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPRX, 0 ); } +#ifdef EMULATE_RF static void* emulatedRF_thread(void* param) { RU_proc_t *proc = (RU_proc_t *) param; int microsec = 500; // length of time to sleep, in miliseconds @@ -708,6 +709,7 @@ static void* emulatedRF_thread(void* param) { } return 0; } +#endif void rx_rf(RU_t *ru,int *frame,int *subframe) { @@ -716,7 +718,7 @@ void rx_rf(RU_t *ru,int *frame,int *subframe) { void *rxp[ru->nb_rx]; unsigned int rxs; int i; - openair0_timestamp ts,old_ts; + openair0_timestamp ts=0,old_ts=0; for (i=0; inb_rx; i++) rxp[i] = (void*)&ru->common.rxdata[i][*subframe*fp->samples_per_tti]; @@ -1024,7 +1026,7 @@ static void* ru_thread_prach_br( void* param ) { ru_thread_prach_status = 0; thread_top_init("ru_thread_prach_br",1,500000,1000000,20000000); - wait_sync(ru_thread_prach_br); + wait_sync("ru_thread_prach_br"); while (!oai_exit) { @@ -1154,7 +1156,7 @@ void wakeup_eNBs(RU_t *ru) { LOG_D(PHY,"wakeup_eNBs (num %d) for RU %d\n",ru->num_eNB,ru->idx); - if (0){//(ru->num_eNB==1) { + if (get_nprocs() <= 4) { // call eNB function directly char string[20]; @@ -1165,10 +1167,10 @@ void wakeup_eNBs(RU_t *ru) { else { for (i=0;inum_eNB;i++) - { - if (ru->wakeup_rxtx(eNB_list[i],ru) < 0) + { + if (ru->wakeup_rxtx(eNB_list[i],ru) < 0) LOG_E(PHY,"could not wakeup eNB rxtx process for subframe %d\n", ru->proc.subframe_rx); - } + } } } @@ -1392,7 +1394,7 @@ static void* ru_stats_thread(void* param) { while (!oai_exit) { sleep(1); - if (opp_enabled == 1) { + if (opp_enabled == 1 && fepw) { if (ru->feprx) print_meas(&ru->ofdm_demod_stats,"feprx",NULL,NULL); if (ru->feptx_ofdm) print_meas(&ru->ofdm_mod_stats,"feptx_ofdm",NULL,NULL); } @@ -1422,17 +1424,10 @@ static void* ru_thread_tx( void* param ) { VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_CPUID_RU_THREAD_TX,sched_getcpu()); if (oai_exit) break; - if (subframe==9) { - subframe=0; - frame++; - frame&=1023; - } else { - subframe++; - } + LOG_D(PHY,"ru_thread_tx: Waiting for TX processing\n"); // wait until eNBs are finished subframe RX n and TX n+4 wait_on_condition(&proc->mutex_eNBs,&proc->cond_eNBs,&proc->instance_cnt_eNBs,"ru_thread_tx"); - //printf("//////////////////instance_cnt_eNBs = %d\n",proc->instance_cnt_eNBs);//////////////////********* #ifdef EMULATE_RF #else @@ -1474,8 +1469,8 @@ static void* ru_thread( void* param ) { // set default return value thread_top_init("ru_thread",1,400000,500000,500000); - CPU_SET(1, &cpuset); - pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); + //CPU_SET(1, &cpuset); + //pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); pthread_setname_np( pthread_self(),"ru thread"); LOG_I(PHY,"thread ru created id=%ld\n", syscall(__NR_gettid)); @@ -1604,24 +1599,23 @@ static void* ru_thread( void* param ) { // wakeup all eNB processes waiting for this RU if (ru->num_eNB>0) wakeup_eNBs(ru); - /* - if(fh_two_thread == 0) + + if(get_nprocs() <=4) { - // wait until eNBs are finished subframe RX n and TX n+4 - wait_on_condition(&proc->mutex_eNBs,&proc->cond_eNBs,&proc->instance_cnt_eNBs,"ru_thread"); - - - // do TX front-end processing if needed (precoding and/or IDFTs) - if (ru->feptx_prec) ru->feptx_prec(ru); - - // do OFDM if needed - if ((ru->fh_north_asynch_in == NULL) && (ru->feptx_ofdm)) ru->feptx_ofdm(ru); - // do outgoing fronthaul (south) if needed - if ((ru->fh_north_asynch_in == NULL) && (ru->fh_south_out)) ru->fh_south_out(ru); - - if (ru->fh_north_out) ru->fh_north_out(ru); + #ifdef EMULATE_RF + #else + // do TX front-end processing if needed (precoding and/or IDFTs) + if (ru->feptx_prec) ru->feptx_prec(ru); + + // do OFDM if needed + if ((ru->fh_north_asynch_in == NULL) && (ru->feptx_ofdm)) ru->feptx_ofdm(ru); + // do outgoing fronthaul (south) if needed + if ((ru->fh_north_asynch_in == NULL) && (ru->fh_south_out)) ru->fh_south_out(ru); + + if (ru->fh_north_out) ru->fh_north_out(ru); + #endif } - */ + } @@ -1809,7 +1803,7 @@ void init_RU_proc(RU_t *ru) { pthread_create( &proc->pthread_emulateRF, attr_emulateRF, emulatedRF_thread, (void*)proc ); #endif - if (fh_two_thread==1) + if (get_nprocs() > 4) pthread_create( &proc->pthread_FH1, attr_FH1, ru_thread_tx, (void*)ru ); if (ru->function == NGFI_RRU_IF4p5) { @@ -1832,7 +1826,7 @@ void init_RU_proc(RU_t *ru) { } - if (get_nprocs()>=2) { + if (get_nprocs()> 2 && fepw) { if (ru->feprx) init_fep_thread(ru,NULL); if (ru->feptx_ofdm) init_feptx_thread(ru,NULL); } diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index cb2aee9df4..3c54db4db0 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -206,8 +206,9 @@ extern void reset_opp_meas(void); extern void print_opp_meas(void); int transmission_mode=1; -int numerology = 2; -int fh_two_thread = 1; +int numerology = 0; +int codingw = 1; +int fepw = 1; diff --git a/targets/RT/USER/lte-softmodem.h b/targets/RT/USER/lte-softmodem.h index 058eab8e30..98aef640d8 100644 --- a/targets/RT/USER/lte-softmodem.h +++ b/targets/RT/USER/lte-softmodem.h @@ -84,6 +84,8 @@ #define CONFIG_HLP_NOTWAIT "don't wait for tracer, start immediately\n" #define CONFIG_HLP_TNOFORK "to ease debugging with gdb\n" #define CONFIG_HLP_NUMEROLOGY "adding numerology for 5G\n" +#define CONFIG_HLP_CODINGW "coding worker thread disabled(enable by defult)\n" +#define CONFIG_HLP_FEPW "FEP worker thread disabled(enable by defult)\n" /***************************************************************************************************************************************/ @@ -138,37 +140,39 @@ extern int16_t dlsch_demod_shift; /* optname helpstr paramflags XXXptr defXXXval type numelt */ /*---------------------------------------------------------------------------------------------------------------------------------------------------------------------------*/ #define CMDLINE_PARAMS_DESC { \ -{"rf-config-file", CONFIG_HLP_RFCFGF, 0, strptr:(char **)&rf_config_file, defstrval:NULL, TYPE_STRING, sizeof(rf_config_file)}, \ -{"ulsch-max-errors", CONFIG_HLP_ULMAXE, 0, uptr:&ULSCH_max_consecutive_errors, defuintval:0, TYPE_UINT, 0}, \ -{"phy-test", CONFIG_HLP_PHYTST, PARAMFLAG_BOOL, iptr:&phy_test, defintval:0, TYPE_INT, 0}, \ -{"usim-test", CONFIG_HLP_USIM, PARAMFLAG_BOOL, u8ptr:&usim_test, defintval:0, TYPE_UINT8, 0}, \ -{"mmapped-dma", CONFIG_HLP_DMAMAP, PARAMFLAG_BOOL, uptr:&mmapped_dma, defintval:0, TYPE_INT, 0}, \ -{"external-clock", CONFIG_HLP_EXCCLK, PARAMFLAG_BOOL, uptr:&clock_source, defintval:0, TYPE_INT, 0}, \ -{"wait-for-sync", NULL, PARAMFLAG_BOOL, iptr:&wait_for_sync, defintval:0, TYPE_INT, 0}, \ -{"single-thread-disable", CONFIG_HLP_NOSNGLT, PARAMFLAG_BOOL, iptr:&single_thread_flag, defintval:1, TYPE_INT, 0}, \ -{"threadIQ", NULL, 0, iptr:&(threads.iq), defintval:1, TYPE_INT, 0}, \ -{"threadOneSubframe", NULL, 0, iptr:&(threads.one), defintval:1, TYPE_INT, 0}, \ -{"threadTwoSubframe", NULL, 0, iptr:&(threads.two), defintval:1, TYPE_INT, 0}, \ -{"threadThreeSubframe", NULL, 0, iptr:&(threads.three), defintval:1, TYPE_INT, 0}, \ -{"threadSlot1ProcOne", NULL, 0, iptr:&(threads.slot1_proc_one), defintval:1, TYPE_INT, 0}, \ -{"threadSlot1ProcTwo", NULL, 0, iptr:&(threads.slot1_proc_two), defintval:1, TYPE_INT, 0}, \ -{"dlsch-demod-shift", CONFIG_HLP_DLSHIFT, 0, iptr:(int32_t *)&dlsch_demod_shift, defintval:0, TYPE_INT, 0}, \ -{"A" , CONFIG_HLP_TADV, 0, uptr:&timing_advance, defintval:0, TYPE_UINT, 0}, \ -{"C" , CONFIG_HLP_DLF, 0, uptr:&(downlink_frequency[0][0]), defuintval:2680000000, TYPE_UINT, 0}, \ -{"a" , CONFIG_HLP_CHOFF, 0, iptr:&chain_offset, defintval:0, TYPE_INT, 0}, \ -{"d" , CONFIG_HLP_SOFTS, PARAMFLAG_BOOL, uptr:(uint32_t *)&do_forms, defintval:0, TYPE_INT8, 0}, \ -{"E" , CONFIG_HLP_TQFS, PARAMFLAG_BOOL, i8ptr:&threequarter_fs, defintval:0, TYPE_INT8, 0}, \ -{"K" , CONFIG_HLP_ITTIL, PARAMFLAG_NOFREE, strptr:&itti_dump_file, defstrval:"/tmp/itti.dump", TYPE_STRING, 0}, \ -{"U" , CONFIG_HLP_UE, PARAMFLAG_BOOL, i8ptr:&UE_flag, defintval:0, TYPE_INT8, 0}, \ -{"m" , CONFIG_HLP_DLMCS, 0, uptr:&target_dl_mcs, defintval:0, TYPE_UINT, 0}, \ -{"t" , CONFIG_HLP_ULMCS, 0, uptr:&target_ul_mcs, defintval:0, TYPE_UINT, 0}, \ -{"W" , CONFIG_HLP_L2MONW, 0, strptr:(char **)&in_ip, defstrval:"127.0.0.1", TYPE_STRING, sizeof(in_ip)}, \ -{"P" , CONFIG_HLP_L2MONP, 0, strptr:(char **)&in_path, defstrval:"/tmp/oai_opt.pcap", TYPE_STRING, sizeof(in_path)}, \ -{"V" , CONFIG_HLP_VCD, PARAMFLAG_BOOL, iptr:&ouput_vcd, defintval:0, TYPE_INT, 0}, \ -{"q" , CONFIG_HLP_STMON, PARAMFLAG_BOOL, iptr:&opp_enabled, defintval:0, TYPE_INT, 0}, \ -{"S" , CONFIG_HLP_MSLOTS, PARAMFLAG_BOOL, u8ptr:&exit_missed_slots, defintval:1, TYPE_UINT8, 0}, \ -{"T" , CONFIG_HLP_TDD, PARAMFLAG_BOOL, iptr:&tddflag, defintval:0, TYPE_INT, 0}, \ -{"numerology" , CONFIG_HLP_NUMEROLOGY, PARAMFLAG_BOOL, iptr:&numerology, defintval:0, TYPE_INT, 0} \ +{"rf-config-file", CONFIG_HLP_RFCFGF, 0, strptr:(char **)&rf_config_file, defstrval:NULL, TYPE_STRING, sizeof(rf_config_file)},\ +{"ulsch-max-errors", CONFIG_HLP_ULMAXE, 0, uptr:&ULSCH_max_consecutive_errors, defuintval:0, TYPE_UINT, 0}, \ +{"phy-test", CONFIG_HLP_PHYTST, PARAMFLAG_BOOL, iptr:&phy_test, defintval:0, TYPE_INT, 0}, \ +{"usim-test", CONFIG_HLP_USIM, PARAMFLAG_BOOL, u8ptr:&usim_test, defintval:0, TYPE_UINT8, 0}, \ +{"mmapped-dma", CONFIG_HLP_DMAMAP, PARAMFLAG_BOOL, uptr:&mmapped_dma, defintval:0, TYPE_INT, 0}, \ +{"external-clock", CONFIG_HLP_EXCCLK, PARAMFLAG_BOOL, uptr:&clock_source, defintval:0, TYPE_INT, 0}, \ +{"wait-for-sync", NULL, PARAMFLAG_BOOL, iptr:&wait_for_sync, defintval:0, TYPE_INT, 0}, \ +{"single-thread-disable", CONFIG_HLP_NOSNGLT, PARAMFLAG_BOOL, iptr:&single_thread_flag, defintval:1, TYPE_INT, 0}, \ +{"threadIQ", NULL, 0, iptr:&(threads.iq), defintval:1, TYPE_INT, 0}, \ +{"threadOneSubframe", NULL, 0, iptr:&(threads.one), defintval:1, TYPE_INT, 0}, \ +{"threadTwoSubframe", NULL, 0, iptr:&(threads.two), defintval:1, TYPE_INT, 0}, \ +{"threadThreeSubframe", NULL, 0, iptr:&(threads.three), defintval:1, TYPE_INT, 0}, \ +{"threadSlot1ProcOne", NULL, 0, iptr:&(threads.slot1_proc_one), defintval:1, TYPE_INT, 0}, \ +{"threadSlot1ProcTwo", NULL, 0, iptr:&(threads.slot1_proc_two), defintval:1, TYPE_INT, 0}, \ +{"dlsch-demod-shift", CONFIG_HLP_DLSHIFT, 0, iptr:(int32_t *)&dlsch_demod_shift, defintval:0, TYPE_INT, 0}, \ +{"A" , CONFIG_HLP_TADV, 0, uptr:&timing_advance, defintval:0, TYPE_UINT, 0}, \ +{"C" , CONFIG_HLP_DLF, 0, uptr:&(downlink_frequency[0][0]), defuintval:2680000000, TYPE_UINT, 0}, \ +{"a" , CONFIG_HLP_CHOFF, 0, iptr:&chain_offset, defintval:0, TYPE_INT, 0}, \ +{"d" , CONFIG_HLP_SOFTS, PARAMFLAG_BOOL, uptr:(uint32_t *)&do_forms, defintval:0, TYPE_INT8, 0}, \ +{"E" , CONFIG_HLP_TQFS, PARAMFLAG_BOOL, i8ptr:&threequarter_fs, defintval:0, TYPE_INT8, 0}, \ +{"K" , CONFIG_HLP_ITTIL, PARAMFLAG_NOFREE, strptr:&itti_dump_file, defstrval:"/tmp/itti.dump", TYPE_STRING, 0}, \ +{"U" , CONFIG_HLP_UE, PARAMFLAG_BOOL, i8ptr:&UE_flag, defintval:0, TYPE_INT8, 0}, \ +{"m" , CONFIG_HLP_DLMCS, 0, uptr:&target_dl_mcs, defintval:0, TYPE_UINT, 0}, \ +{"t" , CONFIG_HLP_ULMCS, 0, uptr:&target_ul_mcs, defintval:0, TYPE_UINT, 0}, \ +{"W" , CONFIG_HLP_L2MONW, 0, strptr:(char **)&in_ip, defstrval:"127.0.0.1", TYPE_STRING, sizeof(in_ip)}, \ +{"P" , CONFIG_HLP_L2MONP, 0, strptr:(char **)&in_path, defstrval:"/tmp/oai_opt.pcap", TYPE_STRING, sizeof(in_path)}, \ +{"V" , CONFIG_HLP_VCD, PARAMFLAG_BOOL, iptr:&ouput_vcd, defintval:0, TYPE_INT, 0}, \ +{"q" , CONFIG_HLP_STMON, PARAMFLAG_BOOL, iptr:&opp_enabled, defintval:0, TYPE_INT, 0}, \ +{"S" , CONFIG_HLP_MSLOTS, PARAMFLAG_BOOL, u8ptr:&exit_missed_slots, defintval:1, TYPE_UINT8, 0}, \ +{"T" , CONFIG_HLP_TDD, PARAMFLAG_BOOL, iptr:&tddflag, defintval:0, TYPE_INT, 0}, \ +{"numerology" , CONFIG_HLP_NUMEROLOGY, PARAMFLAG_BOOL, iptr:&numerology, defintval:0, TYPE_INT, 0} \ +//{"coding-worker-disable" , CONFIG_HLP_CODINGW, PARAMFLAG_BOOL, iptr:&codingw, defintval:0, TYPE_INT, 0}, \ +//{"fep-worker-disable" , CONFIG_HLP_FEPW, PARAMFLAG_BOOL, iptr:&fepw, defintval:0, TYPE_INT, 0} \ } #define CONFIG_HLP_FLOG "Enable online log \n" From f0e10b0d89db072be018aad82e3b43b8068b74b8 Mon Sep 17 00:00:00 2001 From: Eurecom Date: Tue, 30 Jan 2018 14:56:23 +0100 Subject: [PATCH 35/63] bug fix for shared info between threads --- targets/RT/USER/lte-enb.c | 32 ++++++++++++++++++-------------- targets/RT/USER/lte-ru.c | 6 +++--- targets/RT/USER/lte-softmodem.h | 2 -- 3 files changed, 21 insertions(+), 19 deletions(-) diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 1845268138..c5593ab8d0 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -241,6 +241,9 @@ static void* tx_thread(void* param) { pthread_mutex_lock(&eNB_proc->ru_proc->mutex_eNBs); ++eNB_proc->ru_proc->instance_cnt_eNBs; + eNB_proc->ru_proc->timestamp_tx = proc->timestamp_tx; + eNB_proc->ru_proc->subframe_tx = proc->subframe_tx; + eNB_proc->ru_proc->frame_tx = proc->frame_tx; pthread_cond_signal(&eNB_proc->ru_proc->cond_eNBs); pthread_mutex_unlock(&eNB_proc->ru_proc->mutex_eNBs); } @@ -369,7 +372,8 @@ int wakeup_tx(PHY_VARS_eNB *eNB,RU_proc_t *ru_proc) { eNB_proc_t *proc=&eNB->proc; - eNB_rxtx_proc_t *proc_rxtx=&proc->proc_rxtx[1];//*proc_rxtx=&proc->proc_rxtx[proc->frame_rx&1]; + eNB_rxtx_proc_t *proc_rxtx1=&proc->proc_rxtx[1];//*proc_rxtx=&proc->proc_rxtx[proc->frame_rx&1]; + eNB_rxtx_proc_t *proc_rxtx0=&proc->proc_rxtx[0]; LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms; @@ -377,34 +381,34 @@ int wakeup_tx(PHY_VARS_eNB *eNB,RU_proc_t *ru_proc) { wait.tv_sec=0; wait.tv_nsec=5000000L; - if (proc_rxtx->instance_cnt_rxtx == 0) { - LOG_E(PHY,"Frame %d, subframe %d: TX1 thread busy, dropping\n",proc_rxtx->frame_rx,proc_rxtx->subframe_rx); + if (proc_rxtx1->instance_cnt_rxtx == 0) { + LOG_E(PHY,"Frame %d, subframe %d: TX1 thread busy, dropping\n",proc_rxtx1->frame_rx,proc_rxtx1->subframe_rx); return(-1); } - if (pthread_mutex_timedlock(&proc_rxtx->mutex_rxtx,&wait) != 0) { - LOG_E( PHY, "[eNB] ERROR pthread_mutex_lock for eNB TX1 thread %d (IC %d)\n", proc_rxtx->subframe_rx&1,proc_rxtx->instance_cnt_rxtx ); + if (pthread_mutex_timedlock(&proc_rxtx1->mutex_rxtx,&wait) != 0) { + LOG_E( PHY, "[eNB] ERROR pthread_mutex_lock for eNB TX1 thread %d (IC %d)\n", proc_rxtx1->subframe_rx&1,proc_rxtx1->instance_cnt_rxtx ); exit_fun( "error locking mutex_tx" ); return(-1); } - ++proc_rxtx->instance_cnt_rxtx; + ++proc_rxtx1->instance_cnt_rxtx; - proc_rxtx->subframe_rx = ru_proc->subframe_rx; - proc_rxtx->frame_rx = ru_proc->frame_rx; - proc_rxtx->subframe_tx = (ru_proc->subframe_rx+4)%10; - proc_rxtx->frame_tx = (ru_proc->subframe_rx>5) ? (1+ru_proc->frame_rx)&1023 : ru_proc->frame_rx; - proc_rxtx->timestamp_tx = ru_proc->timestamp_tx; + proc_rxtx1->subframe_rx = proc_rxtx0->subframe_rx; + proc_rxtx1->frame_rx = proc_rxtx0->frame_rx; + proc_rxtx1->subframe_tx = proc_rxtx0->subframe_tx; + proc_rxtx1->frame_tx = proc_rxtx0->frame_tx; + proc_rxtx1->timestamp_tx = proc_rxtx0->timestamp_tx; // the thread can now be woken up - if (pthread_cond_signal(&proc_rxtx->cond_rxtx) != 0) { + if (pthread_cond_signal(&proc_rxtx1->cond_rxtx) != 0) { LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB TXnp4 thread\n"); exit_fun( "ERROR pthread_cond_signal" ); return(-1); } - pthread_mutex_unlock( &proc_rxtx->mutex_rxtx ); + pthread_mutex_unlock( &proc_rxtx1->mutex_rxtx ); return(0); } @@ -486,7 +490,7 @@ int wakeup_rxtx(PHY_VARS_eNB *eNB,RU_t *ru) { proc_rxtx->frame_tx = (ru_proc->subframe_rx>5) ? (1+ru_proc->frame_rx)&1023 : ru_proc->frame_rx; proc->frame_tx = proc_rxtx->frame_tx; proc->frame_rx = proc_rxtx->frame_rx; - proc_rxtx->timestamp_tx = ru_proc->timestamp_tx; + proc_rxtx->timestamp_tx = ru_proc->timestamp_rx+(4*fp->samples_per_tti); // the thread can now be woken up if (pthread_cond_signal(&proc_rxtx->cond_rxtx) != 0) { diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index 2fe02a10e8..6081979e5d 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -761,9 +761,9 @@ void rx_rf(RU_t *ru,int *frame,int *subframe) { proc->subframe_rx = (proc->timestamp_rx / fp->samples_per_tti)%10; // synchronize first reception to frame 0 subframe 0 - proc->timestamp_tx = proc->timestamp_rx+(4*fp->samples_per_tti); - proc->subframe_tx = (proc->subframe_rx+4)%10; - proc->frame_tx = (proc->subframe_rx>5) ? (proc->frame_rx+1)&1023 : proc->frame_rx; + //proc->timestamp_tx = proc->timestamp_rx+(4*fp->samples_per_tti); + //proc->subframe_tx = (proc->subframe_rx+4)%10; + //proc->frame_tx = (proc->subframe_rx>5) ? (proc->frame_rx+1)&1023 : proc->frame_rx; LOG_D(PHY,"RU %d/%d TS %llu (off %d), frame %d, subframe %d\n", ru->idx, diff --git a/targets/RT/USER/lte-softmodem.h b/targets/RT/USER/lte-softmodem.h index 98aef640d8..4e79d5012d 100644 --- a/targets/RT/USER/lte-softmodem.h +++ b/targets/RT/USER/lte-softmodem.h @@ -171,8 +171,6 @@ extern int16_t dlsch_demod_shift; {"S" , CONFIG_HLP_MSLOTS, PARAMFLAG_BOOL, u8ptr:&exit_missed_slots, defintval:1, TYPE_UINT8, 0}, \ {"T" , CONFIG_HLP_TDD, PARAMFLAG_BOOL, iptr:&tddflag, defintval:0, TYPE_INT, 0}, \ {"numerology" , CONFIG_HLP_NUMEROLOGY, PARAMFLAG_BOOL, iptr:&numerology, defintval:0, TYPE_INT, 0} \ -//{"coding-worker-disable" , CONFIG_HLP_CODINGW, PARAMFLAG_BOOL, iptr:&codingw, defintval:0, TYPE_INT, 0}, \ -//{"fep-worker-disable" , CONFIG_HLP_FEPW, PARAMFLAG_BOOL, iptr:&fepw, defintval:0, TYPE_INT, 0} \ } #define CONFIG_HLP_FLOG "Enable online log \n" From 5f028730cd56059558cb656a07f6e59f74b8862b Mon Sep 17 00:00:00 2001 From: Eurecom Date: Tue, 30 Jan 2018 17:22:34 +0100 Subject: [PATCH 36/63] bug fix for RXTX same thread --- targets/RT/USER/lte-enb.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index c5593ab8d0..ee3c858e44 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -194,6 +194,9 @@ static inline int rxtx(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, char *thread_nam pthread_mutex_lock(&eNB->proc.ru_proc->mutex_eNBs); ++eNB->proc.ru_proc->instance_cnt_eNBs; + eNB->proc.ru_proc->timestamp_tx = proc->timestamp_tx; + eNB->proc.ru_proc->subframe_tx = proc->subframe_tx; + eNB->proc.ru_proc->frame_tx = proc->frame_tx; pthread_cond_signal(&eNB->proc.ru_proc->cond_eNBs); pthread_mutex_unlock(&eNB->proc.ru_proc->mutex_eNBs); } From 863c469d35928c55a5080d782f12ac9bb6eb0050 Mon Sep 17 00:00:00 2001 From: Eurecom Date: Wed, 31 Jan 2018 17:53:54 +0100 Subject: [PATCH 37/63] bug fix for adjustable thread structure --- targets/RT/USER/lte-enb.c | 5 ++--- targets/RT/USER/lte-ru.c | 5 +++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index ee3c858e44..9bf046bb1c 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -241,7 +241,6 @@ static void* tx_thread(void* param) { phy_procedures_eNB_TX(eNB, proc, no_relay, NULL, 1); if (release_thread(&proc->mutex_rxtx,&proc->instance_cnt_rxtx,thread_name)<0) break; - pthread_mutex_lock(&eNB_proc->ru_proc->mutex_eNBs); ++eNB_proc->ru_proc->instance_cnt_eNBs; eNB_proc->ru_proc->timestamp_tx = proc->timestamp_tx; @@ -422,7 +421,8 @@ int wakeup_rxtx(PHY_VARS_eNB *eNB,RU_t *ru) { RU_proc_t *ru_proc=&ru->proc; eNB_rxtx_proc_t *proc_rxtx=&proc->proc_rxtx[0];//*proc_rxtx=&proc->proc_rxtx[proc->frame_rx&1]; - proc->ru_proc = &ru->proc; + //proc->ru_proc = &ru->proc; + LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms; @@ -839,7 +839,6 @@ void init_eNB_proc(int inst) { //////////////////////////////////////need to modified////////////////***** - //printf("//////////////////////////////////////////////////////////////////**************************************************************** codingw = %d\n",codingw); if(get_nprocs() > 2 && codingw) { init_te_thread(eNB); diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index 6081979e5d..b8c07ad3e4 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -1168,8 +1168,9 @@ void wakeup_eNBs(RU_t *ru) { for (i=0;inum_eNB;i++) { - if (ru->wakeup_rxtx(eNB_list[i],ru) < 0) - LOG_E(PHY,"could not wakeup eNB rxtx process for subframe %d\n", ru->proc.subframe_rx); + eNB_list[i]->proc.ru_proc = &ru->proc; + if (ru->wakeup_rxtx(eNB_list[i],ru) < 0) + LOG_E(PHY,"could not wakeup eNB rxtx process for subframe %d\n", ru->proc.subframe_rx); } } } From bf601fce718f0327ed0ceac12747273ec9ebf468 Mon Sep 17 00:00:00 2001 From: Wang Tsu-Han Date: Fri, 16 Feb 2018 19:15:40 +0100 Subject: [PATCH 38/63] adding phy-test for UL --- openair1/PHY/LTE_TRANSPORT/dci_tools.c | 2 +- openair1/SCHED/fapi_l1.c | 4 +- openair1/SCHED/phy_procedures_lte_eNb.c | 7 +- openair2/LAYER2/MAC/eNB_scheduler.c | 1 + openair2/LAYER2/MAC/eNB_scheduler_phytest.c | 168 ++++++++++++++++++++ openair2/LAYER2/MAC/proto.h | 1 + targets/RT/USER/lte-enb.c | 2 +- 7 files changed, 179 insertions(+), 6 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/dci_tools.c b/openair1/PHY/LTE_TRANSPORT/dci_tools.c index 8a3047b5b2..2ba75b7afc 100644 --- a/openair1/PHY/LTE_TRANSPORT/dci_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/dci_tools.c @@ -2478,7 +2478,7 @@ void fill_ulsch(PHY_VARS_eNB *eNB,nfapi_ul_config_ulsch_pdu *ulsch_pdu,int frame else if(ulsch->harq_processes[harq_pid]->n_DMRS == 7) ulsch->harq_processes[harq_pid]->n_DMRS2 = 9; - LOG_D(PHY,"[eNB %d][PUSCH %d] Programming PUSCH with n_DMRS2 %d (cshift %d) for Frame %d, Subframe %d\n", + LOG_I(PHY,"[eNB %d][PUSCH %d] Programming PUSCH with n_DMRS2 %d (cshift %d) for Frame %d, Subframe %d\n", eNB->Mod_id,harq_pid,ulsch->harq_processes[harq_pid]->n_DMRS2,ulsch->harq_processes[harq_pid]->n_DMRS, frame,subframe); diff --git a/openair1/SCHED/fapi_l1.c b/openair1/SCHED/fapi_l1.c index 11cd85d57d..943fab8541 100644 --- a/openair1/SCHED/fapi_l1.c +++ b/openair1/SCHED/fapi_l1.c @@ -603,7 +603,7 @@ void schedule_response(Sched_Rsp_t *Sched_INFO) eNB->pdcch_vars[subframe&1].num_dci = 0; eNB->phich_vars[subframe&1].num_hi = 0; - LOG_D(PHY,"NFAPI: Frame %d, Subframe %d: received %d dl_pdu, %d tx_req, %d hi_dci0_config_req, %d UL_config \n", + LOG_I(PHY,"NFAPI: Frame %d, Subframe %d: received %d dl_pdu, %d tx_req, %d hi_dci0_config_req, %d UL_config \n", frame,subframe,number_dl_pdu,TX_req->tx_request_body.number_of_pdus,number_hi_dci0_pdu,number_ul_pdu); @@ -708,7 +708,7 @@ void schedule_response(Sched_Rsp_t *Sched_INFO) for (i=0;iul_config_request_body.ul_config_pdu_list[i]; - LOG_D(PHY,"NFAPI: ul_pdu %d : type %d\n",i,ul_config_pdu->pdu_type); + LOG_I(PHY,"NFAPI: ul_pdu %d : type %d\n",i,ul_config_pdu->pdu_type); AssertFatal(ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_ULSCH_PDU_TYPE || ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE || ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_ULSCH_CQI_RI_PDU_TYPE || diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index 210933591f..c54904f494 100644 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -1294,11 +1294,14 @@ void pusch_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) if (fp->frame_type == FDD) harq_pid = ((10*frame) + subframe)&7; else harq_pid = subframe%10; + LOG_I(PHY,"Frame %d, subframe %d: PUSCH procedures, harq_pid %d\n", + frame,subframe,harq_pid); + LOG_I(PHY,"rnti = %x\n",eNB->ulsch[0]->rnti); for (i=0; iulsch[i]; ulsch_harq = ulsch->harq_processes[harq_pid]; - if (ulsch->rnti>0) LOG_D(PHY,"Frame %d, subframe %d: PUSCH procedures, harq_pid %d, UE %d/%x\n", + if (ulsch->rnti>0) LOG_I(PHY,"Frame %d, subframe %d: PUSCH procedures, harq_pid %d, UE %d/%x\n", frame,subframe,harq_pid,i,ulsch->rnti); if ((ulsch) && @@ -1328,7 +1331,7 @@ void pusch_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) fp->pusch_config_common.ul_ReferenceSignalsPUSCH.cyclicShift + nPRS)%12; - LOG_D(PHY, + LOG_I(PHY, "[eNB %d][PUSCH %d] Frame %d Subframe %d Demodulating PUSCH: dci_alloc %d, rar_alloc %d, round %d, first_rb %d, nb_rb %d, Qm %d, TBS %d, rv %d, cyclic_shift %d (n_DMRS2 %d, cyclicShift_common %d, nprs %d), O_ACK %d, beta_cqi %d \n", eNB->Mod_id,harq_pid,frame,subframe, ulsch_harq->dci_alloc, diff --git a/openair2/LAYER2/MAC/eNB_scheduler.c b/openair2/LAYER2/MAC/eNB_scheduler.c index 172168bee3..1910d64444 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler.c +++ b/openair2/LAYER2/MAC/eNB_scheduler.c @@ -540,6 +540,7 @@ void eNB_dlsch_ulsch_scheduler(module_id_t module_idP, frame_t frameP, sub_frame schedule_ue_spec(module_idP,frameP,subframeP,mbsfn_status); } else { + schedule_ulsch_phy_test(module_idP,frameP,subframeP); schedule_ue_spec_phy_test(module_idP,frameP,subframeP,mbsfn_status); } diff --git a/openair2/LAYER2/MAC/eNB_scheduler_phytest.c b/openair2/LAYER2/MAC/eNB_scheduler_phytest.c index 203358e0e1..579b7e5dee 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_phytest.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_phytest.c @@ -92,6 +92,7 @@ schedule_ue_spec_phy_test( continue; nb_rb = conv_nprb(0,rb_alloc,N_RB_DL); + //printf("////////////////////////////////////*************************nb_rb = %d\n",nb_rb); TBS = get_TBS_DL(mcs,nb_rb); LOG_D(PHY,"schedule_ue_spec_phy_test: subframe %d/%d: nb_rb=%d, TBS=%d, mcs=%d (rb_alloc=%x, N_RB_DL=%d)\n",frameP,subframeP,nb_rb,TBS,mcs,rb_alloc,N_RB_DL); @@ -188,3 +189,170 @@ schedule_ue_spec_phy_test( } } } + +void schedule_ulsch_phy_test(module_id_t module_idP,frame_t frameP,sub_frame_t subframeP) +{ + uint16_t first_rb[MAX_NUM_CCs]; + int UE_id = 0; + uint8_t aggregation = 2; + rnti_t rnti = 0x1235; + uint8_t mcs = 28; + uint8_t harq_pid = 0; + uint32_t cqi_req = 0,cshift,ndi,tpc = 1; + int32_t normalized_rx_power; + int32_t target_rx_power= 178; + int n; + int CC_id = 0; + int N_RB_UL; + eNB_MAC_INST *eNB = RC.mac[module_idP]; + COMMON_channels_t *cc = eNB->common_channels; + UE_list_t *UE_list=&eNB->UE_list; + UE_TEMPLATE *UE_template; + UE_sched_ctrl *UE_sched_ctrl; + int sched_frame=frameP; + int sched_subframeP = (subframeP+4)%10; + + if (sched_subframePHI_DCI0_req[CC_id].hi_dci0_request_body; + nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu; + + nfapi_ul_config_request_pdu_t *ul_config_pdu; + nfapi_ul_config_request_body_t *ul_req = &eNB->UL_req[CC_id].ul_config_request_body; + + ul_config_pdu = &ul_req->ul_config_pdu_list[0]; + + eNB->UL_req[CC_id].sfn_sf = (frameP<<4) + subframeP; + eNB->HI_DCI0_req[CC_id].sfn_sf = (frameP<<4)+subframeP; + + for (CC_id=0; CC_idmode == PUSCH) { // ue has a ulsch channel + + UE_template = &UE_list->UE_template[CC_id][UE_id]; + UE_sched_ctrl = &UE_list->UE_sched_ctrl[UE_id]; + harq_pid = subframe2harqpid(&cc[CC_id],sched_frame,sched_subframeP); + + + RC.eNB[module_idP][CC_id]->pusch_stats_BO[UE_id][(frameP*10)+subframeP] = UE_template->ul_total_buffer; + printf("////////////////////////////////////*************************ul_total_buffer = %d\n",UE_template->ul_total_buffer); + + + + //power control + //compute the expected ULSCH RX power (for the stats) + + // this is the normalized RX power and this should be constant (regardless of mcs + normalized_rx_power = UE_sched_ctrl->pusch_snr[CC_id]; + printf("////////////////////////////////////*************************normalized_rx_power = %d\n",normalized_rx_power); + + // new transmission + + ndi = 1-UE_template->oldNDI_UL[harq_pid]; + UE_template->oldNDI_UL[harq_pid]=ndi; + UE_list->eNB_UE_stats[CC_id][UE_id].normalized_rx_power=normalized_rx_power; + UE_list->eNB_UE_stats[CC_id][UE_id].target_rx_power=target_rx_power; + UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs1 = mcs; + UE_template->mcs_UL[harq_pid] = mcs;//cmin (UE_template->pre_assigned_mcs_ul, openair_daq_vars.target_ue_ul_mcs); // adjust, based on user-defined MCS + UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_mcs2 = mcs; + // buffer_occupancy = UE_template->ul_total_buffer; + + + + UE_template->TBS_UL[harq_pid] = get_TBS_UL(UE_template->mcs_UL[harq_pid],N_RB_UL-1); + UE_list->eNB_UE_stats[CC_id][UE_id].total_rbs_used_rx+=N_RB_UL-1; + UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_TBS = get_TBS_UL(mcs,N_RB_UL-1); + // buffer_occupancy -= TBS; + + + + // bad indices : 20 (40 PRB), 21 (45 PRB), 22 (48 PRB) + //store for possible retransmission + UE_template->nb_rb_ul[harq_pid] = N_RB_UL-1; + UE_template->first_rb_ul[harq_pid] = first_rb[CC_id]; + + UE_sched_ctrl->ul_scheduled |= (1<ul_total_buffer = UE_template->TBS_UL[harq_pid]; + // Cyclic shift for DM RS + cshift = 0;// values from 0 to 7 can be used for mapping the cyclic shift (36.211 , Table 5.5.2.1.1-1) + // save it for a potential retransmission + UE_template->cshift[harq_pid] = cshift; + + hi_dci0_pdu = &hi_dci0_req->hi_dci0_pdu_list[eNB->HI_DCI0_req[CC_id].hi_dci0_request_body.number_of_dci+eNB->HI_DCI0_req[CC_id].hi_dci0_request_body.number_of_hi]; + memset((void*)hi_dci0_pdu,0,sizeof(nfapi_hi_dci0_request_pdu_t)); + hi_dci0_pdu->pdu_type = NFAPI_HI_DCI0_DCI_PDU_TYPE; + hi_dci0_pdu->pdu_size = 2+sizeof(nfapi_hi_dci0_dci_pdu); + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.dci_format = NFAPI_UL_DCI_FORMAT_0; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.aggregation_level = aggregation; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.rnti = rnti; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.transmission_power = 6000; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.resource_block_start = first_rb[CC_id]; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.number_of_resource_block = N_RB_UL-1; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.mcs_1 = mcs; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.cyclic_shift_2_for_drms = cshift; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.frequency_hopping_enabled_flag = 0; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.new_data_indication_1 = ndi; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.tpc = tpc; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.cqi_csi_request = cqi_req; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.dl_assignment_index = UE_template->DAI_ul[sched_subframeP]; + + + eNB->HI_DCI0_req[CC_id].hi_dci0_request_body.number_of_dci++; + + + // Add UL_config PDUs + fill_nfapi_ulsch_config_request_rel8(&ul_req->ul_config_pdu_list[ul_req->number_of_pdus], + cqi_req, + cc, + 0,//UE_template->physicalConfigDedicated, + get_tmode(module_idP,CC_id,UE_id), + eNB->ul_handle, + rnti, + first_rb[CC_id], // resource_block_start + N_RB_UL-1, // number_of_resource_blocks + mcs, + cshift, // cyclic_shift_2_for_drms + 0, // frequency_hopping_enabled_flag + 0, // frequency_hopping_bits + ndi, // new_data_indication + 0, // redundancy_version + harq_pid, // harq_process_number + 0, // ul_tx_mode + 0, // current_tx_nb + 0, // n_srs + get_TBS_UL(mcs,N_RB_UL-1) + ); +#ifdef Rel14 + if (UE_template->rach_resource_type>0) { // This is a BL/CE UE allocation + fill_nfapi_ulsch_config_request_emtc(&ul_req->ul_config_pdu_list[ul_req->number_of_pdus], + UE_template->rach_resource_type>2 ? 2 : 1, + 1, //total_number_of_repetitions + 1, //repetition_number + (frameP*10)+subframeP); + } +#endif + ul_req->number_of_pdus = 1; + eNB->ul_handle++; + + + + add_ue_ulsch_info(module_idP, + CC_id, + UE_id, + subframeP, + S_UL_SCHEDULED); + + // increment first rb for next UE allocation + first_rb[CC_id]+= N_RB_UL -1; + + + } // loop of CC_id +} \ No newline at end of file diff --git a/openair2/LAYER2/MAC/proto.h b/openair2/LAYER2/MAC/proto.h index 2b458cd96b..ee589471cf 100644 --- a/openair2/LAYER2/MAC/proto.h +++ b/openair2/LAYER2/MAC/proto.h @@ -120,6 +120,7 @@ void fill_DLSCH_dci(module_id_t module_idP,frame_t frameP,sub_frame_t subframe,i void schedule_ue_spec(module_id_t module_idP,frame_t frameP,sub_frame_t subframe,int *mbsfn_flag); void schedule_ue_spec_phy_test(module_id_t module_idP,frame_t frameP,sub_frame_t subframe,int *mbsfn_flag); +void schedule_ulsch_phy_test(module_id_t module_idP,frame_t frameP,sub_frame_t subframeP); /** \brief Function for UE/PHY to compute PUSCH transmit power in power-control procedure. diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 9bf046bb1c..a58434e71b 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -726,7 +726,7 @@ static void* process_stats_thread(void* param) { if (eNB->td) print_meas(&eNB->ulsch_decoding_stats,"ulsch_decoding",NULL,NULL); if (eNB->te) { - print_meas(&eNB->dlsch_turbo_encoding_preperation_stats,"dlsch_coding_prepare",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_encoding_stats,"dlsch_encoding",NULL,NULL); print_meas(&eNB->dlsch_turbo_encoding_signal_stats,"coding_signal",NULL,NULL); From 2194bc8564543bd8a88177a52b8e2af797d5bc0f Mon Sep 17 00:00:00 2001 From: "Wolfgang A. Mozart" Date: Mon, 19 Feb 2018 10:45:34 +0100 Subject: [PATCH 39/63] fixed timing issue for phy-test scheduling UL. UL is broken after first execution of dlsch decoding --- cmake_targets/CMakeLists.txt | 2 +- openair1/PHY/LTE_TRANSPORT/dci_tools.c | 2 +- openair1/SCHED/fapi_l1.c | 2 +- openair1/SCHED/phy_procedures_lte_eNb.c | 4 ++-- openair2/LAYER2/MAC/eNB_scheduler_phytest.c | 17 +++++++++-------- .../CONF/enb.band7.tm1.50PRB.usrpb210.conf | 4 ++-- 6 files changed, 16 insertions(+), 15 deletions(-) diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 67b2360517..6cce5e306e 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -597,7 +597,7 @@ add_boolean_option(NAS_ADDRESS_FIX False "specific to oaisim: for nasmesh driver add_boolean_option(NAS_NETLINK False "???? Must be True to compile nasmesh driver without rtai") add_boolean_option(OAISIM False "specific to oaisim") add_boolean_option(OAI_NW_DRIVER_USE_NETLINK True "????") -add_boolean_option(EMULATE_RF False "allows to run lte-softmodem without HW") +add_boolean_option(EMULATE_RF True "allows to run lte-softmodem without HW") add_boolean_option(USE_MME False "this flag is used only one time in lte-softmodem.c") add_list_string_option(PACKAGE_NAME "NotDefined" "As per attribute name") diff --git a/openair1/PHY/LTE_TRANSPORT/dci_tools.c b/openair1/PHY/LTE_TRANSPORT/dci_tools.c index 2ba75b7afc..9523c09625 100644 --- a/openair1/PHY/LTE_TRANSPORT/dci_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/dci_tools.c @@ -2507,7 +2507,7 @@ void fill_ulsch(PHY_VARS_eNB *eNB,nfapi_ul_config_ulsch_pdu *ulsch_pdu,int frame else ulsch->harq_processes[harq_pid]->round++; ulsch->rnti = ulsch_pdu->ulsch_pdu_rel8.rnti; - LOG_D(PHY,"Filling ULSCH %x (UE_id %d) (new_ulsch %d) for Frame %d, Subframe %d : harq_pid %d, first_rb %d, nb_rb %d, rvidx %d, Qm %d, TBS %d, round %d \n", + LOG_I(PHY,"Filling ULSCH %x (UE_id %d) (new_ulsch %d) for Frame %d, Subframe %d : harq_pid %d, first_rb %d, nb_rb %d, rvidx %d, Qm %d, TBS %d, round %d \n", ulsch->rnti, UE_id, new_ulsch, diff --git a/openair1/SCHED/fapi_l1.c b/openair1/SCHED/fapi_l1.c index 943fab8541..c84cfaa979 100644 --- a/openair1/SCHED/fapi_l1.c +++ b/openair1/SCHED/fapi_l1.c @@ -493,7 +493,7 @@ void handle_nfapi_ul_pdu(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_ULSCH_PDU_TYPE) { AssertFatal((UE_id = find_ulsch(ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.rnti,eNB,SEARCH_EXIST_OR_FREE))>=0, "No existing UE ULSCH for rnti %x\n",rel8->rnti); - LOG_D(PHY,"Applying UL config for UE %d, rnti %x for frame %d, subframe %d\n", + LOG_I(PHY,"Applying UL config for UE %d, rnti %x for frame %d, subframe %d\n", UE_id,rel8->rnti,frame,subframe); fill_ulsch(eNB,&ul_config_pdu->ulsch_pdu,frame,subframe); diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index c54904f494..551c604ac9 100644 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -1301,8 +1301,8 @@ void pusch_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) for (i=0; iulsch[i]; ulsch_harq = ulsch->harq_processes[harq_pid]; - if (ulsch->rnti>0) LOG_I(PHY,"Frame %d, subframe %d: PUSCH procedures, harq_pid %d, UE %d/%x\n", - frame,subframe,harq_pid,i,ulsch->rnti); + if (ulsch->rnti>0) LOG_I(PHY,"Frame %d, subframe %d: PUSCH procedures, harq_pid %d, UE %d/%x, status %d, harq_frame %d, harq_subframe %d ulsch_handled %d\n", + frame,subframe,harq_pid,i,ulsch->rnti,ulsch_harq->status,ulsch_harq->frame,ulsch_harq->subframe, ulsch_harq->handled); if ((ulsch) && (ulsch->rnti>0) && diff --git a/openair2/LAYER2/MAC/eNB_scheduler_phytest.c b/openair2/LAYER2/MAC/eNB_scheduler_phytest.c index 579b7e5dee..c6dc86acc6 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_phytest.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_phytest.c @@ -210,9 +210,9 @@ void schedule_ulsch_phy_test(module_id_t module_idP,frame_t frameP,sub_frame_t s UE_TEMPLATE *UE_template; UE_sched_ctrl *UE_sched_ctrl; int sched_frame=frameP; - int sched_subframeP = (subframeP+4)%10; + int sched_subframe = (subframeP+4)%10; - if (sched_subframePHI_DCI0_req[CC_id].hi_dci0_request_body; nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu; @@ -222,7 +222,7 @@ void schedule_ulsch_phy_test(module_id_t module_idP,frame_t frameP,sub_frame_t s ul_config_pdu = &ul_req->ul_config_pdu_list[0]; - eNB->UL_req[CC_id].sfn_sf = (frameP<<4) + subframeP; + eNB->UL_req[CC_id].sfn_sf = (sched_frame<<4) + sched_subframe; eNB->HI_DCI0_req[CC_id].sfn_sf = (frameP<<4)+subframeP; for (CC_id=0; CC_idUE_template[CC_id][UE_id]; UE_sched_ctrl = &UE_list->UE_sched_ctrl[UE_id]; - harq_pid = subframe2harqpid(&cc[CC_id],sched_frame,sched_subframeP); + harq_pid = subframe2harqpid(&cc[CC_id],sched_frame,sched_subframe); + LOG_I(MAC,"Scheduling for frame %d, subframe %d => harq_pid %d\n",sched_frame,sched_subframe,harq_pid); RC.eNB[module_idP][CC_id]->pusch_stats_BO[UE_id][(frameP*10)+subframeP] = UE_template->ul_total_buffer; printf("////////////////////////////////////*************************ul_total_buffer = %d\n",UE_template->ul_total_buffer); @@ -295,14 +296,14 @@ void schedule_ulsch_phy_test(module_id_t module_idP,frame_t frameP,sub_frame_t s hi_dci0_pdu->dci_pdu.dci_pdu_rel8.rnti = rnti; hi_dci0_pdu->dci_pdu.dci_pdu_rel8.transmission_power = 6000; hi_dci0_pdu->dci_pdu.dci_pdu_rel8.resource_block_start = first_rb[CC_id]; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.number_of_resource_block = N_RB_UL-1; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.number_of_resource_block = 20;//N_RB_UL-1; hi_dci0_pdu->dci_pdu.dci_pdu_rel8.mcs_1 = mcs; hi_dci0_pdu->dci_pdu.dci_pdu_rel8.cyclic_shift_2_for_drms = cshift; hi_dci0_pdu->dci_pdu.dci_pdu_rel8.frequency_hopping_enabled_flag = 0; hi_dci0_pdu->dci_pdu.dci_pdu_rel8.new_data_indication_1 = ndi; hi_dci0_pdu->dci_pdu.dci_pdu_rel8.tpc = tpc; hi_dci0_pdu->dci_pdu.dci_pdu_rel8.cqi_csi_request = cqi_req; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.dl_assignment_index = UE_template->DAI_ul[sched_subframeP]; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.dl_assignment_index = UE_template->DAI_ul[sched_subframe]; eNB->HI_DCI0_req[CC_id].hi_dci0_request_body.number_of_dci++; @@ -317,7 +318,7 @@ void schedule_ulsch_phy_test(module_id_t module_idP,frame_t frameP,sub_frame_t s eNB->ul_handle, rnti, first_rb[CC_id], // resource_block_start - N_RB_UL-1, // number_of_resource_blocks + 20,//N_RB_UL-1, // number_of_resource_blocks mcs, cshift, // cyclic_shift_2_for_drms 0, // frequency_hopping_enabled_flag @@ -355,4 +356,4 @@ void schedule_ulsch_phy_test(module_id_t module_idP,frame_t frameP,sub_frame_t s } // loop of CC_id -} \ No newline at end of file +} diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.usrpb210.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.usrpb210.conf index 5815a56d8e..9d1aa464e9 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.usrpb210.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/enb.band7.tm1.50PRB.usrpb210.conf @@ -151,9 +151,9 @@ eNBs = { ENB_INTERFACE_NAME_FOR_S1_MME = "eth0"; - ENB_IPV4_ADDRESS_FOR_S1_MME = "192.168.12.19/24"; + ENB_IPV4_ADDRESS_FOR_S1_MME = "192.168.12.111/24"; ENB_INTERFACE_NAME_FOR_S1U = "eth0"; - ENB_IPV4_ADDRESS_FOR_S1U = "192.168.12.19/24"; + ENB_IPV4_ADDRESS_FOR_S1U = "192.168.12.111/24"; ENB_PORT_FOR_S1U = 2152; # Spec 2152 }; } From 869b9a5c6f3719dcd4aaca484e6ddadd9ae8573d Mon Sep 17 00:00:00 2001 From: Wang Tsu-Han Date: Tue, 20 Feb 2018 15:05:00 +0100 Subject: [PATCH 40/63] fix for phy-test UL and adding wakeup_txfh --- openair1/PHY/LTE_TRANSPORT/dci_tools.c | 4 +- openair1/PHY/LTE_TRANSPORT/dlsch_coding.c | 3 +- openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c | 7 +- openair1/PHY/LTE_TRANSPORT/proto.h | 1 + openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c | 5 +- openair1/SCHED/fapi_l1.c | 6 +- openair1/SCHED/phy_procedures_lte_eNb.c | 7 +- openair1/SCHED/ru_procedures.c | 4 +- openair2/LAYER2/MAC/eNB_scheduler_phytest.c | 25 ++++--- targets/RT/USER/lte-enb.c | 65 ++++++++++++------- targets/RT/USER/lte-ru.c | 19 +++--- 11 files changed, 82 insertions(+), 64 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/dci_tools.c b/openair1/PHY/LTE_TRANSPORT/dci_tools.c index 9523c09625..8a3047b5b2 100644 --- a/openair1/PHY/LTE_TRANSPORT/dci_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/dci_tools.c @@ -2478,7 +2478,7 @@ void fill_ulsch(PHY_VARS_eNB *eNB,nfapi_ul_config_ulsch_pdu *ulsch_pdu,int frame else if(ulsch->harq_processes[harq_pid]->n_DMRS == 7) ulsch->harq_processes[harq_pid]->n_DMRS2 = 9; - LOG_I(PHY,"[eNB %d][PUSCH %d] Programming PUSCH with n_DMRS2 %d (cshift %d) for Frame %d, Subframe %d\n", + LOG_D(PHY,"[eNB %d][PUSCH %d] Programming PUSCH with n_DMRS2 %d (cshift %d) for Frame %d, Subframe %d\n", eNB->Mod_id,harq_pid,ulsch->harq_processes[harq_pid]->n_DMRS2,ulsch->harq_processes[harq_pid]->n_DMRS, frame,subframe); @@ -2507,7 +2507,7 @@ void fill_ulsch(PHY_VARS_eNB *eNB,nfapi_ul_config_ulsch_pdu *ulsch_pdu,int frame else ulsch->harq_processes[harq_pid]->round++; ulsch->rnti = ulsch_pdu->ulsch_pdu_rel8.rnti; - LOG_I(PHY,"Filling ULSCH %x (UE_id %d) (new_ulsch %d) for Frame %d, Subframe %d : harq_pid %d, first_rb %d, nb_rb %d, rvidx %d, Qm %d, TBS %d, round %d \n", + LOG_D(PHY,"Filling ULSCH %x (UE_id %d) (new_ulsch %d) for Frame %d, Subframe %d : harq_pid %d, first_rb %d, nb_rb %d, rvidx %d, Qm %d, TBS %d, round %d \n", ulsch->rnti, UE_id, new_ulsch, diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c index fce305d9db..1797c0a999 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c @@ -42,6 +42,7 @@ #include "UTIL/LOG/vcd_signal_dumper.h" #include "UTIL/LOG/log.h" #include +#include "targets/RT/USER/rt_wrapper.h" //#define DEBUG_DLSCH_CODING //#define DEBUG_DLSCH_FREE 1 @@ -386,7 +387,7 @@ void *te_thread(void *param) { te_params *tep = (te_params *)param; - wait_sync("te_thread"); + //wait_sync("te_thread"); while (!oai_exit) { diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c b/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c index 868f9e0e9f..b4cfdb65fe 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c @@ -2511,7 +2511,12 @@ int dlsch_modulation(PHY_VARS_eNB* phy_vars_eNB, switch (mod_order1) { case 2: - qam_table_s1 = NULL; + if (pilots) { + qam_table_s1 = qpsk_table_b1; + } + else { + qam_table_s1 = qpsk_table_a1; + } break; case 4: if (pilots) { diff --git a/openair1/PHY/LTE_TRANSPORT/proto.h b/openair1/PHY/LTE_TRANSPORT/proto.h index 2422b88120..f67af89bf7 100644 --- a/openair1/PHY/LTE_TRANSPORT/proto.h +++ b/openair1/PHY/LTE_TRANSPORT/proto.h @@ -1501,6 +1501,7 @@ uint8_t generate_dci_top_emul(PHY_VARS_eNB *phy_vars_eNB, void generate_64qam_table(void); void generate_16qam_table(void); +void generate_qpsk_table(void); uint16_t extract_crc(uint8_t *dci,uint8_t DCI_LENGTH); diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c index 015279c9c2..220702846b 100644 --- a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c +++ b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c @@ -51,6 +51,7 @@ #include "UTIL/LOG/vcd_signal_dumper.h" //#define DEBUG_ULSCH_DECODING +#include "targets/RT/USER/rt_wrapper.h" extern int codingw; @@ -422,7 +423,7 @@ void *td_thread(void *param) { thread_top_init("td_thread",1,200000,250000,500000); pthread_setname_np( pthread_self(),"td processing"); LOG_I(PHY,"thread td created id=%ld\n", syscall(__NR_gettid)); - wait_sync("td_thread"); + //wait_sync("td_thread"); while (!oai_exit) { @@ -819,7 +820,7 @@ int ulsch_decoding_data_all(PHY_VARS_eNB *eNB,int UE_id,int harq_pid,int llr8_fl int ret = 0; LTE_eNB_ULSCH_t *ulsch = eNB->ulsch[UE_id]; LTE_UL_eNB_HARQ_t *ulsch_harq = ulsch->harq_processes[harq_pid]; - if(ulsch_harq->C>3 && get_nprocs()>=2 && codingw) + if(codingw) { ret = ulsch_decoding_data_2thread(eNB,UE_id,harq_pid,llr8_flag); } diff --git a/openair1/SCHED/fapi_l1.c b/openair1/SCHED/fapi_l1.c index c84cfaa979..11cd85d57d 100644 --- a/openair1/SCHED/fapi_l1.c +++ b/openair1/SCHED/fapi_l1.c @@ -493,7 +493,7 @@ void handle_nfapi_ul_pdu(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, if (ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_ULSCH_PDU_TYPE) { AssertFatal((UE_id = find_ulsch(ul_config_pdu->ulsch_pdu.ulsch_pdu_rel8.rnti,eNB,SEARCH_EXIST_OR_FREE))>=0, "No existing UE ULSCH for rnti %x\n",rel8->rnti); - LOG_I(PHY,"Applying UL config for UE %d, rnti %x for frame %d, subframe %d\n", + LOG_D(PHY,"Applying UL config for UE %d, rnti %x for frame %d, subframe %d\n", UE_id,rel8->rnti,frame,subframe); fill_ulsch(eNB,&ul_config_pdu->ulsch_pdu,frame,subframe); @@ -603,7 +603,7 @@ void schedule_response(Sched_Rsp_t *Sched_INFO) eNB->pdcch_vars[subframe&1].num_dci = 0; eNB->phich_vars[subframe&1].num_hi = 0; - LOG_I(PHY,"NFAPI: Frame %d, Subframe %d: received %d dl_pdu, %d tx_req, %d hi_dci0_config_req, %d UL_config \n", + LOG_D(PHY,"NFAPI: Frame %d, Subframe %d: received %d dl_pdu, %d tx_req, %d hi_dci0_config_req, %d UL_config \n", frame,subframe,number_dl_pdu,TX_req->tx_request_body.number_of_pdus,number_hi_dci0_pdu,number_ul_pdu); @@ -708,7 +708,7 @@ void schedule_response(Sched_Rsp_t *Sched_INFO) for (i=0;iul_config_request_body.ul_config_pdu_list[i]; - LOG_I(PHY,"NFAPI: ul_pdu %d : type %d\n",i,ul_config_pdu->pdu_type); + LOG_D(PHY,"NFAPI: ul_pdu %d : type %d\n",i,ul_config_pdu->pdu_type); AssertFatal(ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_ULSCH_PDU_TYPE || ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_ULSCH_HARQ_PDU_TYPE || ul_config_pdu->pdu_type == NFAPI_UL_CONFIG_ULSCH_CQI_RI_PDU_TYPE || diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index 551c604ac9..9f13d3ff7e 100644 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -1294,14 +1294,11 @@ void pusch_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) if (fp->frame_type == FDD) harq_pid = ((10*frame) + subframe)&7; else harq_pid = subframe%10; - LOG_I(PHY,"Frame %d, subframe %d: PUSCH procedures, harq_pid %d\n", - frame,subframe,harq_pid); - LOG_I(PHY,"rnti = %x\n",eNB->ulsch[0]->rnti); for (i=0; iulsch[i]; ulsch_harq = ulsch->harq_processes[harq_pid]; - if (ulsch->rnti>0) LOG_I(PHY,"Frame %d, subframe %d: PUSCH procedures, harq_pid %d, UE %d/%x, status %d, harq_frame %d, harq_subframe %d ulsch_handled %d\n", + if (ulsch->rnti>0) LOG_D(PHY,"Frame %d, subframe %d: PUSCH procedures, harq_pid %d, UE %d/%x, status %d, harq_frame %d, harq_subframe %d ulsch_handled %d\n", frame,subframe,harq_pid,i,ulsch->rnti,ulsch_harq->status,ulsch_harq->frame,ulsch_harq->subframe, ulsch_harq->handled); if ((ulsch) && @@ -1331,7 +1328,7 @@ void pusch_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) fp->pusch_config_common.ul_ReferenceSignalsPUSCH.cyclicShift + nPRS)%12; - LOG_I(PHY, + LOG_D(PHY, "[eNB %d][PUSCH %d] Frame %d Subframe %d Demodulating PUSCH: dci_alloc %d, rar_alloc %d, round %d, first_rb %d, nb_rb %d, Qm %d, TBS %d, rv %d, cyclic_shift %d (n_DMRS2 %d, cyclicShift_common %d, nprs %d), O_ACK %d, beta_cqi %d \n", eNB->Mod_id,harq_pid,frame,subframe, ulsch_harq->dci_alloc, diff --git a/openair1/SCHED/ru_procedures.c b/openair1/SCHED/ru_procedures.c index decbe38c69..ea5d221d4c 100644 --- a/openair1/SCHED/ru_procedures.c +++ b/openair1/SCHED/ru_procedures.c @@ -148,7 +148,7 @@ static void *feptx_thread(void *param) { LOG_I(PHY,"thread feptx created id=%ld\n", syscall(__NR_gettid)); //CPU_SET(6, &cpuset); //pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); - wait_sync("feptx_thread"); + //wait_sync("feptx_thread"); @@ -445,7 +445,7 @@ static void *fep_thread(void *param) { CPU_ZERO(&cpuset); //CPU_SET(2, &cpuset); //pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); - wait_sync("fep_thread"); + //wait_sync("fep_thread"); while (!oai_exit) { diff --git a/openair2/LAYER2/MAC/eNB_scheduler_phytest.c b/openair2/LAYER2/MAC/eNB_scheduler_phytest.c index c6dc86acc6..ef31136fe7 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_phytest.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_phytest.c @@ -201,9 +201,8 @@ void schedule_ulsch_phy_test(module_id_t module_idP,frame_t frameP,sub_frame_t s uint32_t cqi_req = 0,cshift,ndi,tpc = 1; int32_t normalized_rx_power; int32_t target_rx_power= 178; - int n; int CC_id = 0; - int N_RB_UL; + int nb_rb = 20; eNB_MAC_INST *eNB = RC.mac[module_idP]; COMMON_channels_t *cc = eNB->common_channels; UE_list_t *UE_list=&eNB->UE_list; @@ -227,8 +226,6 @@ void schedule_ulsch_phy_test(module_id_t module_idP,frame_t frameP,sub_frame_t s for (CC_id=0; CC_id harq_pid %d\n",sched_frame,sched_subframe,harq_pid); RC.eNB[module_idP][CC_id]->pusch_stats_BO[UE_id][(frameP*10)+subframeP] = UE_template->ul_total_buffer; - printf("////////////////////////////////////*************************ul_total_buffer = %d\n",UE_template->ul_total_buffer); + //printf("////////////////////////////////////*************************ul_total_buffer = %d\n",UE_template->ul_total_buffer); @@ -251,7 +248,7 @@ void schedule_ulsch_phy_test(module_id_t module_idP,frame_t frameP,sub_frame_t s // this is the normalized RX power and this should be constant (regardless of mcs normalized_rx_power = UE_sched_ctrl->pusch_snr[CC_id]; - printf("////////////////////////////////////*************************normalized_rx_power = %d\n",normalized_rx_power); + //printf("////////////////////////////////////*************************normalized_rx_power = %d\n",normalized_rx_power); // new transmission @@ -266,16 +263,16 @@ void schedule_ulsch_phy_test(module_id_t module_idP,frame_t frameP,sub_frame_t s - UE_template->TBS_UL[harq_pid] = get_TBS_UL(UE_template->mcs_UL[harq_pid],N_RB_UL-1); - UE_list->eNB_UE_stats[CC_id][UE_id].total_rbs_used_rx+=N_RB_UL-1; - UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_TBS = get_TBS_UL(mcs,N_RB_UL-1); + UE_template->TBS_UL[harq_pid] = get_TBS_UL(mcs,nb_rb); + UE_list->eNB_UE_stats[CC_id][UE_id].total_rbs_used_rx += nb_rb; + UE_list->eNB_UE_stats[CC_id][UE_id].ulsch_TBS = get_TBS_UL(mcs,nb_rb); // buffer_occupancy -= TBS; // bad indices : 20 (40 PRB), 21 (45 PRB), 22 (48 PRB) //store for possible retransmission - UE_template->nb_rb_ul[harq_pid] = N_RB_UL-1; + UE_template->nb_rb_ul[harq_pid] = nb_rb; UE_template->first_rb_ul[harq_pid] = first_rb[CC_id]; UE_sched_ctrl->ul_scheduled |= (1<dci_pdu.dci_pdu_rel8.rnti = rnti; hi_dci0_pdu->dci_pdu.dci_pdu_rel8.transmission_power = 6000; hi_dci0_pdu->dci_pdu.dci_pdu_rel8.resource_block_start = first_rb[CC_id]; - hi_dci0_pdu->dci_pdu.dci_pdu_rel8.number_of_resource_block = 20;//N_RB_UL-1; + hi_dci0_pdu->dci_pdu.dci_pdu_rel8.number_of_resource_block = nb_rb; hi_dci0_pdu->dci_pdu.dci_pdu_rel8.mcs_1 = mcs; hi_dci0_pdu->dci_pdu.dci_pdu_rel8.cyclic_shift_2_for_drms = cshift; hi_dci0_pdu->dci_pdu.dci_pdu_rel8.frequency_hopping_enabled_flag = 0; @@ -318,7 +315,7 @@ void schedule_ulsch_phy_test(module_id_t module_idP,frame_t frameP,sub_frame_t s eNB->ul_handle, rnti, first_rb[CC_id], // resource_block_start - 20,//N_RB_UL-1, // number_of_resource_blocks + nb_rb, // number_of_resource_blocks mcs, cshift, // cyclic_shift_2_for_drms 0, // frequency_hopping_enabled_flag @@ -329,7 +326,7 @@ void schedule_ulsch_phy_test(module_id_t module_idP,frame_t frameP,sub_frame_t s 0, // ul_tx_mode 0, // current_tx_nb 0, // n_srs - get_TBS_UL(mcs,N_RB_UL-1) + get_TBS_UL(mcs,nb_rb) ); #ifdef Rel14 if (UE_template->rach_resource_type>0) { // This is a BL/CE UE allocation @@ -352,7 +349,7 @@ void schedule_ulsch_phy_test(module_id_t module_idP,frame_t frameP,sub_frame_t s S_UL_SCHEDULED); // increment first rb for next UE allocation - first_rb[CC_id]+= N_RB_UL -1; + first_rb[CC_id]+= nb_rb; } // loop of CC_id diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index a58434e71b..db24937ee3 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -146,6 +146,7 @@ void init_eNB(int,int); void stop_eNB(int nb_inst); int wakeup_tx(PHY_VARS_eNB *eNB,RU_proc_t *ru_proc); +int wakeup_txfh(eNB_rxtx_proc_t *proc,RU_proc_t *ru_proc); void wakeup_prach_eNB(PHY_VARS_eNB *eNB,RU_t *ru,int frame,int subframe); #ifdef Rel14 void wakeup_prach_eNB_br(PHY_VARS_eNB *eNB,RU_t *ru,int frame,int subframe); @@ -183,7 +184,7 @@ static inline int rxtx(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, char *thread_nam VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER , 0 ); - if(get_nprocs() > 8) + if(get_nprocs() >= 8) { wakeup_tx(eNB,eNB->proc.ru_proc); } @@ -192,13 +193,7 @@ static inline int rxtx(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, char *thread_nam if(oai_exit) return(-1); phy_procedures_eNB_TX(eNB, proc, no_relay, NULL, 1); - pthread_mutex_lock(&eNB->proc.ru_proc->mutex_eNBs); - ++eNB->proc.ru_proc->instance_cnt_eNBs; - eNB->proc.ru_proc->timestamp_tx = proc->timestamp_tx; - eNB->proc.ru_proc->subframe_tx = proc->subframe_tx; - eNB->proc.ru_proc->frame_tx = proc->frame_tx; - pthread_cond_signal(&eNB->proc.ru_proc->cond_eNBs); - pthread_mutex_unlock(&eNB->proc.ru_proc->mutex_eNBs); + wakeup_txfh(proc,eNB->proc.ru_proc); } else { @@ -222,7 +217,7 @@ static void* tx_thread(void* param) { sprintf(thread_name,"TXnp4_%d\n",&eNB->proc.proc_rxtx[0] == proc ? 0 : 1); thread_top_init(thread_name,1,470000,500000,500000); - wait_sync("tx_thread"); + //wait_sync("tx_thread"); while (!oai_exit) { @@ -241,13 +236,7 @@ static void* tx_thread(void* param) { phy_procedures_eNB_TX(eNB, proc, no_relay, NULL, 1); if (release_thread(&proc->mutex_rxtx,&proc->instance_cnt_rxtx,thread_name)<0) break; - pthread_mutex_lock(&eNB_proc->ru_proc->mutex_eNBs); - ++eNB_proc->ru_proc->instance_cnt_eNBs; - eNB_proc->ru_proc->timestamp_tx = proc->timestamp_tx; - eNB_proc->ru_proc->subframe_tx = proc->subframe_tx; - eNB_proc->ru_proc->frame_tx = proc->frame_tx; - pthread_cond_signal(&eNB_proc->ru_proc->cond_eNBs); - pthread_mutex_unlock(&eNB_proc->ru_proc->mutex_eNBs); + wakeup_txfh(proc,eNB_proc->ru_proc); } return 0; @@ -284,7 +273,7 @@ static void* eNB_thread_rxtx( void* param ) { //CPU_SET(3, &cpuset); //pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); - wait_sync("eNB_thread_rxtx"); + //wait_sync("eNB_thread_rxtx"); while (!oai_exit) { VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_eNB_PROC_RXTX0+(proc->subframe_rx&1), 0 ); @@ -344,7 +333,6 @@ static void wait_system_ready (char *message, volatile int *start_flag) { void eNB_top(PHY_VARS_eNB *eNB, int frame_rx, int subframe_rx, char *string,RU_t *ru) { - RU_proc_t *ru_proc = &ru->proc; eNB_proc_t *proc = &eNB->proc; eNB_rxtx_proc_t *proc_rxtx = &proc->proc_rxtx[0]; @@ -370,6 +358,36 @@ void eNB_top(PHY_VARS_eNB *eNB, int frame_rx, int subframe_rx, char *string,RU_t } } +int wakeup_txfh(eNB_rxtx_proc_t *proc,RU_proc_t *ru_proc) { + + struct timespec wait; + wait.tv_sec=0; + wait.tv_nsec=5000000L; + + + if (pthread_mutex_timedlock(&ru_proc->mutex_eNBs,&wait) != 0) { + LOG_E( PHY, "[eNB] ERROR pthread_mutex_lock for eNB TX1 thread %d (IC %d)\n", ru_proc->subframe_rx&1,ru_proc->instance_cnt_eNBs ); + exit_fun( "error locking mutex_eNB" ); + return(-1); + } + + ++ru_proc->instance_cnt_eNBs; + ru_proc->timestamp_tx = proc->timestamp_tx; + ru_proc->subframe_tx = proc->subframe_tx; + ru_proc->frame_tx = proc->frame_tx; + + // the thread can now be woken up + if (pthread_cond_signal(&ru_proc->cond_eNBs) != 0) { + LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB TXnp4 thread\n"); + exit_fun( "ERROR pthread_cond_signal" ); + return(-1); + } + + pthread_mutex_unlock( &ru_proc->mutex_eNBs ); + + return(0); +} + int wakeup_tx(PHY_VARS_eNB *eNB,RU_proc_t *ru_proc) { eNB_proc_t *proc=&eNB->proc; @@ -453,7 +471,10 @@ int wakeup_rxtx(PHY_VARS_eNB *eNB,RU_t *ru) { wait.tv_sec=0; wait.tv_nsec=5000000L; - /* accept some delay in processing - up to 5ms */ + /* accept some delay in processing - up to 50us */ + if (proc_rxtx->instance_cnt_rxtx == 0) { + usleep(50); + } if (proc_rxtx->instance_cnt_rxtx == 0) { LOG_E(PHY,"Frame %d, subframe %d: RXTX0 thread busy, dropping\n",proc_rxtx->frame_rx,proc_rxtx->subframe_rx); return(-1); @@ -467,10 +488,6 @@ int wakeup_rxtx(PHY_VARS_eNB *eNB,RU_t *ru) { return(-1); } - /*if (proc_rxtx->instance_cnt_rxtx == 0) { - LOG_E(PHY,"Frame %d, subframe %d: RXTX0 thread busy, dropping\n",proc_rxtx->frame_rx,proc_rxtx->subframe_rx); - return(-1); - }*/ ++proc_rxtx->instance_cnt_rxtx; @@ -644,7 +661,7 @@ static void* eNB_thread_prach( void* param ) { thread_top_init("eNB_thread_prach",1,500000,1000000,20000000); - wait_sync("eNB_thread_prach"); + //wait_sync("eNB_thread_prach"); while (!oai_exit) { diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index b8c07ad3e4..b9a2f364e7 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -986,7 +986,7 @@ static void* ru_thread_prach( void* param ) { ru_thread_prach_status = 0; thread_top_init("ru_thread_prach",1,500000,1000000,20000000); - wait_sync("ru_thread_prach"); + //wait_sync("ru_thread_prach"); while (!oai_exit) { @@ -1026,7 +1026,7 @@ static void* ru_thread_prach_br( void* param ) { ru_thread_prach_status = 0; thread_top_init("ru_thread_prach_br",1,500000,1000000,20000000); - wait_sync("ru_thread_prach_br"); + //wait_sync("ru_thread_prach_br"); while (!oai_exit) { @@ -1406,7 +1406,6 @@ static void* ru_stats_thread(void* param) { static void* ru_thread_tx( void* param ) { RU_t *ru = (RU_t*)param; RU_proc_t *proc = &ru->proc; - int subframe=0, frame=0; cpu_set_t cpuset; CPU_ZERO(&cpuset); @@ -1415,7 +1414,7 @@ static void* ru_thread_tx( void* param ) { //CPU_SET(5, &cpuset); //pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); - wait_sync("ru_thread_tx"); + //wait_sync("ru_thread_tx"); wait_on_condition(&proc->mutex_FH1,&proc->cond_FH1,&proc->instance_cnt_FH1,"ru_thread_tx"); @@ -1429,14 +1428,14 @@ static void* ru_thread_tx( void* param ) { LOG_D(PHY,"ru_thread_tx: Waiting for TX processing\n"); // wait until eNBs are finished subframe RX n and TX n+4 wait_on_condition(&proc->mutex_eNBs,&proc->cond_eNBs,&proc->instance_cnt_eNBs,"ru_thread_tx"); - - #ifdef EMULATE_RF - #else + // do TX front-end processing if needed (precoding and/or IDFTs) if (ru->feptx_prec) ru->feptx_prec(ru); - + // do OFDM if needed if ((ru->fh_north_asynch_in == NULL) && (ru->feptx_ofdm)) ru->feptx_ofdm(ru); + #ifdef EMULATE_RF + #else // do outgoing fronthaul (south) if needed if ((ru->fh_north_asynch_in == NULL) && (ru->fh_south_out)) ru->fh_south_out(ru); @@ -1445,7 +1444,7 @@ static void* ru_thread_tx( void* param ) { release_thread(&proc->mutex_eNBs,&proc->instance_cnt_eNBs,"ru_thread_tx"); } - + release_thread(&proc->mutex_FH1,&proc->instance_cnt_FH1,"ru_thread_tx"); return 0; } @@ -1543,7 +1542,7 @@ static void* ru_thread( void* param ) { if ((ru->is_slave) && (ru->if_south == LOCAL_RF)) do_ru_synch(ru); pthread_mutex_lock(&proc->mutex_FH1); - proc->instance_cnt_FH1=0; + proc->instance_cnt_FH1 = 0; pthread_mutex_unlock(&proc->mutex_FH1); pthread_cond_signal(&proc->cond_FH1); #endif From 56a32a22d44fdfaf56e3d5488de3681ef1caac59 Mon Sep 17 00:00:00 2001 From: Wang Tsu-Han Date: Wed, 21 Feb 2018 18:13:34 +0100 Subject: [PATCH 41/63] changing emulate-rf into an executional option instead of compiler option --- cmake_targets/CMakeLists.txt | 1 - common/utils/itti/intertask_interface.c | 22 +-- openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c | 1 + openair2/LAYER2/MAC/eNB_scheduler_phytest.c | 8 +- targets/COMMON/create_tasks.c | 12 +- targets/RT/USER/lte-enb.c | 19 ++- targets/RT/USER/lte-ru.c | 143 ++++++++++---------- targets/RT/USER/lte-softmodem.c | 5 +- targets/RT/USER/lte-softmodem.h | 10 +- 9 files changed, 113 insertions(+), 108 deletions(-) diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 6cce5e306e..723ad38d67 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -597,7 +597,6 @@ add_boolean_option(NAS_ADDRESS_FIX False "specific to oaisim: for nasmesh driver add_boolean_option(NAS_NETLINK False "???? Must be True to compile nasmesh driver without rtai") add_boolean_option(OAISIM False "specific to oaisim") add_boolean_option(OAI_NW_DRIVER_USE_NETLINK True "????") -add_boolean_option(EMULATE_RF True "allows to run lte-softmodem without HW") add_boolean_option(USE_MME False "this flag is used only one time in lte-softmodem.c") add_list_string_option(PACKAGE_NAME "NotDefined" "As per attribute name") diff --git a/common/utils/itti/intertask_interface.c b/common/utils/itti/intertask_interface.c index 5462c97523..5a6438ed3c 100644 --- a/common/utils/itti/intertask_interface.c +++ b/common/utils/itti/intertask_interface.c @@ -99,6 +99,7 @@ const int itti_debug = (ITTI_DEBUG_ISSUES | ITTI_DEBUG_MP_STATISTICS); # define ITTI_MEM_SIZE (16 * 1024 * 1024) #endif +extern int emulate_rf; typedef enum task_state_s { TASK_STATE_NOT_CONFIGURED, TASK_STATE_STARTING, TASK_STATE_READY, TASK_STATE_ENDED, TASK_STATE_MAX, @@ -437,17 +438,16 @@ int itti_send_msg_to_task(task_id_t destination_task_id, instance_t instance, Me destination_task_id, itti_get_task_name(destination_task_id)); } else { - #ifdef EMULATE_RF - #else - /* We cannot send a message if the task is not running */ - AssertFatal (itti_desc.threads[destination_thread_id].task_state == TASK_STATE_READY, - "Task %s Cannot send message %s (%d) to thread %d, it is not in ready state (%d)!\n", - itti_get_task_name(origin_task_id), - itti_desc.messages_info[message_id].name, - message_id, - destination_thread_id, - itti_desc.threads[destination_thread_id].task_state); - #endif + if(!emulate_rf){ + /* We cannot send a message if the task is not running */ + AssertFatal (itti_desc.threads[destination_thread_id].task_state == TASK_STATE_READY, + "Task %s Cannot send message %s (%d) to thread %d, it is not in ready state (%d)!\n", + itti_get_task_name(origin_task_id), + itti_desc.messages_info[message_id].name, + message_id, + destination_thread_id, + itti_desc.threads[destination_thread_id].task_state); + } /* Allocate new list element */ new = (message_list_t *) itti_malloc (origin_task_id, destination_task_id, sizeof(struct message_list_s)); diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c index 220702846b..01a76d307d 100644 --- a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c +++ b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c @@ -643,6 +643,7 @@ int ulsch_decoding_data_2thread(PHY_VARS_eNB *eNB,int UE_id,int harq_pid,int llr break; } stop_meas(&eNB->ulsch_turbo_decoding_stats); + printf("/////////////////////////////////////////**************************loop for %d time in ulsch_decoding main\n",r); } // wait for worker to finish diff --git a/openair2/LAYER2/MAC/eNB_scheduler_phytest.c b/openair2/LAYER2/MAC/eNB_scheduler_phytest.c index ef31136fe7..6cd02db114 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_phytest.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_phytest.c @@ -196,13 +196,13 @@ void schedule_ulsch_phy_test(module_id_t module_idP,frame_t frameP,sub_frame_t s int UE_id = 0; uint8_t aggregation = 2; rnti_t rnti = 0x1235; - uint8_t mcs = 28; + uint8_t mcs = 20; uint8_t harq_pid = 0; uint32_t cqi_req = 0,cshift,ndi,tpc = 1; int32_t normalized_rx_power; int32_t target_rx_power= 178; int CC_id = 0; - int nb_rb = 20; + int nb_rb = 96; eNB_MAC_INST *eNB = RC.mac[module_idP]; COMMON_channels_t *cc = eNB->common_channels; UE_list_t *UE_list=&eNB->UE_list; @@ -236,10 +236,9 @@ void schedule_ulsch_phy_test(module_id_t module_idP,frame_t frameP,sub_frame_t s UE_sched_ctrl = &UE_list->UE_sched_ctrl[UE_id]; harq_pid = subframe2harqpid(&cc[CC_id],sched_frame,sched_subframe); - LOG_I(MAC,"Scheduling for frame %d, subframe %d => harq_pid %d\n",sched_frame,sched_subframe,harq_pid); + LOG_D(MAC,"Scheduling for frame %d, subframe %d => harq_pid %d\n",sched_frame,sched_subframe,harq_pid); RC.eNB[module_idP][CC_id]->pusch_stats_BO[UE_id][(frameP*10)+subframeP] = UE_template->ul_total_buffer; - //printf("////////////////////////////////////*************************ul_total_buffer = %d\n",UE_template->ul_total_buffer); @@ -248,7 +247,6 @@ void schedule_ulsch_phy_test(module_id_t module_idP,frame_t frameP,sub_frame_t s // this is the normalized RX power and this should be constant (regardless of mcs normalized_rx_power = UE_sched_ctrl->pusch_snr[CC_id]; - //printf("////////////////////////////////////*************************normalized_rx_power = %d\n",normalized_rx_power); // new transmission diff --git a/targets/COMMON/create_tasks.c b/targets/COMMON/create_tasks.c index 25b5828e06..d72955e35f 100644 --- a/targets/COMMON/create_tasks.c +++ b/targets/COMMON/create_tasks.c @@ -40,6 +40,7 @@ # endif # include "enb_app.h" +extern int emulate_rf; int create_tasks(uint32_t enb_nb, uint32_t ue_nb) { @@ -72,13 +73,12 @@ int create_tasks(uint32_t enb_nb, uint32_t ue_nb) LOG_E(S1AP, "Create task for S1AP failed\n"); return -1; } - #ifdef EMULATE_RF - #else - if (itti_create_task (TASK_UDP, udp_eNB_task, NULL) < 0) { - LOG_E(UDP_, "Create task for UDP failed\n"); - return -1; + if(!emulate_rf){ + if (itti_create_task (TASK_UDP, udp_eNB_task, NULL) < 0) { + LOG_E(UDP_, "Create task for UDP failed\n"); + return -1; + } } - #endif if (itti_create_task (TASK_GTPV1_U, >pv1u_eNB_task, NULL) < 0) { LOG_E(GTPU, "Create task for GTPV1U failed\n"); diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index db24937ee3..0a1a7487fe 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -365,6 +365,10 @@ int wakeup_txfh(eNB_rxtx_proc_t *proc,RU_proc_t *ru_proc) { wait.tv_nsec=5000000L; + if (ru_proc->instance_cnt_eNBs == 0) { + LOG_E(PHY,"Frame %d, subframe %d: TX FH thread busy, dropping\n",proc->frame_rx,proc->subframe_rx); + return(-1); + } if (pthread_mutex_timedlock(&ru_proc->mutex_eNBs,&wait) != 0) { LOG_E( PHY, "[eNB] ERROR pthread_mutex_lock for eNB TX1 thread %d (IC %d)\n", ru_proc->subframe_rx&1,ru_proc->instance_cnt_eNBs ); exit_fun( "error locking mutex_eNB" ); @@ -834,6 +838,13 @@ void init_eNB_proc(int inst) { attr_td = &proc->attr_td; //attr_te = &proc->attr_te[0]; //attr_te1 = &proc->attr_te[1]; + //////////////////////////////////////need to modified////////////////***** + if(get_nprocs() > 2 && codingw) + { + init_te_thread(eNB); + init_td_thread(eNB,attr_td); + } + //////////////////////////////////////need to modified////////////////***** pthread_create( &proc_rxtx[0].pthread_rxtx, attr0, eNB_thread_rxtx, proc ); pthread_create( &proc_rxtx[1].pthread_rxtx, attr1, tx_thread, proc); if (eNB->single_thread_flag==0) { @@ -854,13 +865,7 @@ void init_eNB_proc(int inst) { AssertFatal(proc->instance_cnt_prach == -1,"instance_cnt_prach = %d\n",proc->instance_cnt_prach); - - //////////////////////////////////////need to modified////////////////***** - if(get_nprocs() > 2 && codingw) - { - init_te_thread(eNB); - init_td_thread(eNB,attr_td); - } + if (opp_enabled == 1) pthread_create(&proc->process_stats_thread,NULL,process_stats_thread,(void*)eNB); diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index b9a2f364e7..6b3fa67b13 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -112,6 +112,7 @@ unsigned short config_frames[4] = {2,9,11,13}; extern volatile int oai_exit; +extern int emulate_rf; extern int numerology; extern int fepw; @@ -681,7 +682,6 @@ void fh_if4p5_north_out(RU_t *ru) { if (ru->idx == 0) VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_RU_FEPRX, 0 ); } -#ifdef EMULATE_RF static void* emulatedRF_thread(void* param) { RU_proc_t *proc = (RU_proc_t *) param; int microsec = 500; // length of time to sleep, in miliseconds @@ -709,7 +709,6 @@ static void* emulatedRF_thread(void* param) { } return 0; } -#endif void rx_rf(RU_t *ru,int *frame,int *subframe) { @@ -726,17 +725,18 @@ void rx_rf(RU_t *ru,int *frame,int *subframe) { VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ, 1 ); old_ts = proc->timestamp_rx; - #ifdef EMULATE_RF - wait_on_condition(&proc->mutex_emulateRF,&proc->cond_emulateRF,&proc->instance_cnt_emulateRF,"emulatedRF_thread"); - release_thread(&proc->mutex_emulateRF,&proc->instance_cnt_emulateRF,"emulatedRF_thread"); - rxs = fp->samples_per_tti; - #else - rxs = ru->rfdevice.trx_read_func(&ru->rfdevice, + if(emulate_rf){ + wait_on_condition(&proc->mutex_emulateRF,&proc->cond_emulateRF,&proc->instance_cnt_emulateRF,"emulatedRF_thread"); + release_thread(&proc->mutex_emulateRF,&proc->instance_cnt_emulateRF,"emulatedRF_thread"); + rxs = fp->samples_per_tti; + } + else{ + rxs = ru->rfdevice.trx_read_func(&ru->rfdevice, &ts, rxp, fp->samples_per_tti, ru->nb_rx); - #endif + } VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_READ, 0 ); @@ -1434,13 +1434,12 @@ static void* ru_thread_tx( void* param ) { // do OFDM if needed if ((ru->fh_north_asynch_in == NULL) && (ru->feptx_ofdm)) ru->feptx_ofdm(ru); - #ifdef EMULATE_RF - #else - // do outgoing fronthaul (south) if needed - if ((ru->fh_north_asynch_in == NULL) && (ru->fh_south_out)) ru->fh_south_out(ru); - - if (ru->fh_north_out) ru->fh_north_out(ru); - #endif + if(!emulate_rf){ + // do outgoing fronthaul (south) if needed + if ((ru->fh_north_asynch_in == NULL) && (ru->fh_south_out)) ru->fh_south_out(ru); + + if (ru->fh_north_out) ru->fh_north_out(ru); + } release_thread(&proc->mutex_eNBs,&proc->instance_cnt_eNBs,"ru_thread_tx"); } @@ -1476,36 +1475,37 @@ static void* ru_thread( void* param ) { LOG_I(PHY,"Starting RU %d (%s,%s),\n",ru->idx,eNB_functions[ru->function],eNB_timing[ru->if_timing]); - #ifdef EMULATE_RF - fill_rf_config(ru,ru->rf_config_file); - init_frame_parms(&ru->frame_parms,1); - phy_init_RU(ru); - if (setup_RU_buffers(ru)!=0) { - printf("Exiting, cannot initialize RU Buffers\n"); - exit(-1); + if(emulate_rf){ + fill_rf_config(ru,ru->rf_config_file); + init_frame_parms(&ru->frame_parms,1); + phy_init_RU(ru); + if (setup_RU_buffers(ru)!=0) { + printf("Exiting, cannot initialize RU Buffers\n"); + exit(-1); + } } - #else - // Start IF device if any - if (ru->start_if) { - LOG_I(PHY,"Starting IF interface for RU %d\n",ru->idx); - AssertFatal(ru->start_if(ru,NULL) == 0, "Could not start the IF device\n"); - if (ru->if_south == LOCAL_RF) ret = connect_rau(ru); - else ret = attach_rru(ru); - AssertFatal(ret==0,"Cannot connect to radio\n"); + else{ + // Start IF device if any + if (ru->start_if) { + LOG_I(PHY,"Starting IF interface for RU %d\n",ru->idx); + AssertFatal(ru->start_if(ru,NULL) == 0, "Could not start the IF device\n"); + if (ru->if_south == LOCAL_RF) ret = connect_rau(ru); + else ret = attach_rru(ru); + AssertFatal(ret==0,"Cannot connect to radio\n"); + } + if (ru->if_south == LOCAL_RF) { // configure RF parameters only + fill_rf_config(ru,ru->rf_config_file); + init_frame_parms(&ru->frame_parms,1); + phy_init_RU(ru); + + + ret = openair0_device_load(&ru->rfdevice,&ru->openair0_cfg); + } + if (setup_RU_buffers(ru)!=0) { + printf("Exiting, cannot initialize RU Buffers\n"); + exit(-1); + } } - if (ru->if_south == LOCAL_RF) { // configure RF parameters only - fill_rf_config(ru,ru->rf_config_file); - init_frame_parms(&ru->frame_parms,1); - phy_init_RU(ru); - - - ret = openair0_device_load(&ru->rfdevice,&ru->openair0_cfg); - } - if (setup_RU_buffers(ru)!=0) { - printf("Exiting, cannot initialize RU Buffers\n"); - exit(-1); - } - #endif LOG_I(PHY, "Signaling main thread that RU %d is ready\n",ru->idx); pthread_mutex_lock(&RC.ru_mutex); @@ -1517,35 +1517,34 @@ static void* ru_thread( void* param ) { - #ifdef EMULATE_RF - #else - // Start RF device if any - if (ru->start_rf) { - if (ru->start_rf(ru) != 0) - LOG_E(HW,"Could not start the RF device\n"); - else LOG_I(PHY,"RU %d rf device ready\n",ru->idx); + if(!emulate_rf){ + // Start RF device if any + if (ru->start_rf) { + if (ru->start_rf(ru) != 0) + LOG_E(HW,"Could not start the RF device\n"); + else LOG_I(PHY,"RU %d rf device ready\n",ru->idx); + } + else LOG_I(PHY,"RU %d no rf device\n",ru->idx); + + // if an asnych_rxtx thread exists + // wakeup the thread because the devices are ready at this point + + if ((ru->fh_south_asynch_in)||(ru->fh_north_asynch_in)) { + pthread_mutex_lock(&proc->mutex_asynch_rxtx); + proc->instance_cnt_asynch_rxtx=0; + pthread_mutex_unlock(&proc->mutex_asynch_rxtx); + pthread_cond_signal(&proc->cond_asynch_rxtx); + } + else LOG_I(PHY,"RU %d no asynch_south interface\n",ru->idx); + + // if this is a slave RRU, try to synchronize on the DL frequency + if ((ru->is_slave) && (ru->if_south == LOCAL_RF)) do_ru_synch(ru); } - else LOG_I(PHY,"RU %d no rf device\n",ru->idx); - - // if an asnych_rxtx thread exists - // wakeup the thread because the devices are ready at this point - - if ((ru->fh_south_asynch_in)||(ru->fh_north_asynch_in)) { - pthread_mutex_lock(&proc->mutex_asynch_rxtx); - proc->instance_cnt_asynch_rxtx=0; - pthread_mutex_unlock(&proc->mutex_asynch_rxtx); - pthread_cond_signal(&proc->cond_asynch_rxtx); - } - else LOG_I(PHY,"RU %d no asynch_south interface\n",ru->idx); - - // if this is a slave RRU, try to synchronize on the DL frequency - if ((ru->is_slave) && (ru->if_south == LOCAL_RF)) do_ru_synch(ru); pthread_mutex_lock(&proc->mutex_FH1); proc->instance_cnt_FH1 = 0; pthread_mutex_unlock(&proc->mutex_FH1); pthread_cond_signal(&proc->cond_FH1); - #endif // This is a forever while loop, it loops over subframes which are scheduled by incoming samples from HW devices @@ -1602,8 +1601,7 @@ static void* ru_thread( void* param ) { if(get_nprocs() <=4) { - #ifdef EMULATE_RF - #else + if(!emulate_rf){ // do TX front-end processing if needed (precoding and/or IDFTs) if (ru->feptx_prec) ru->feptx_prec(ru); @@ -1613,7 +1611,7 @@ static void* ru_thread( void* param ) { if ((ru->fh_north_asynch_in == NULL) && (ru->fh_south_out)) ru->fh_south_out(ru); if (ru->fh_north_out) ru->fh_north_out(ru); - #endif + } } } @@ -1799,9 +1797,8 @@ void init_RU_proc(RU_t *ru) { #endif pthread_create( &proc->pthread_FH, attr_FH, ru_thread, (void*)ru ); -#ifdef EMULATE_RF - pthread_create( &proc->pthread_emulateRF, attr_emulateRF, emulatedRF_thread, (void*)proc ); -#endif + if(emulate_rf) + pthread_create( &proc->pthread_emulateRF, attr_emulateRF, emulatedRF_thread, (void*)proc ); if (get_nprocs() > 4) pthread_create( &proc->pthread_FH1, attr_FH1, ru_thread_tx, (void*)ru ); diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index 3c54db4db0..c6060a8463 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -206,9 +206,10 @@ extern void reset_opp_meas(void); extern void print_opp_meas(void); int transmission_mode=1; +int emulate_rf = 0; int numerology = 0; -int codingw = 1; -int fepw = 1; +int codingw = 0; +int fepw = 0; diff --git a/targets/RT/USER/lte-softmodem.h b/targets/RT/USER/lte-softmodem.h index 4e79d5012d..5a2e0365ea 100644 --- a/targets/RT/USER/lte-softmodem.h +++ b/targets/RT/USER/lte-softmodem.h @@ -84,8 +84,9 @@ #define CONFIG_HLP_NOTWAIT "don't wait for tracer, start immediately\n" #define CONFIG_HLP_TNOFORK "to ease debugging with gdb\n" #define CONFIG_HLP_NUMEROLOGY "adding numerology for 5G\n" -#define CONFIG_HLP_CODINGW "coding worker thread disabled(enable by defult)\n" -#define CONFIG_HLP_FEPW "FEP worker thread disabled(enable by defult)\n" +#define CONFIG_HLP_CODINGW "coding worker thread enable(disable by defult)\n" +#define CONFIG_HLP_FEPW "FEP worker thread enabled(disable by defult)\n" +#define CONFIG_HLP_EMULATE_RF "Emulated RF enabled(disable by defult)\n" /***************************************************************************************************************************************/ @@ -170,7 +171,10 @@ extern int16_t dlsch_demod_shift; {"q" , CONFIG_HLP_STMON, PARAMFLAG_BOOL, iptr:&opp_enabled, defintval:0, TYPE_INT, 0}, \ {"S" , CONFIG_HLP_MSLOTS, PARAMFLAG_BOOL, u8ptr:&exit_missed_slots, defintval:1, TYPE_UINT8, 0}, \ {"T" , CONFIG_HLP_TDD, PARAMFLAG_BOOL, iptr:&tddflag, defintval:0, TYPE_INT, 0}, \ -{"numerology" , CONFIG_HLP_NUMEROLOGY, PARAMFLAG_BOOL, iptr:&numerology, defintval:0, TYPE_INT, 0} \ +{"numerology" , CONFIG_HLP_NUMEROLOGY, PARAMFLAG_BOOL, iptr:&numerology, defintval:0, TYPE_INT, 0}, \ +{"emulate-rf" , CONFIG_HLP_EMULATE_RF, PARAMFLAG_BOOL, iptr:&emulate_rf, defintval:0, TYPE_INT, 0}, \ +{"codingw" , CONFIG_HLP_CODINGW, PARAMFLAG_BOOL, iptr:&codingw, defintval:0, TYPE_INT, 0}, \ +{"fepw" , CONFIG_HLP_FEPW, PARAMFLAG_BOOL, iptr:&fepw, defintval:0, TYPE_INT, 0} \ } #define CONFIG_HLP_FLOG "Enable online log \n" From cb4dc5304241cc644bf489dd02e24371847743d4 Mon Sep 17 00:00:00 2001 From: Wang Tsu-Han Date: Thu, 22 Feb 2018 15:59:23 +0100 Subject: [PATCH 42/63] adding wait stage for every wakeup --- openair1/PHY/defs.h | 4 + openair2/LAYER2/MAC/eNB_scheduler_phytest.c | 2 +- targets/RT/USER/eNB_usrp.gtkw | 20 +++-- targets/RT/USER/lte-enb.c | 85 ++++++++++++++------- targets/RT/USER/lte-ru.c | 3 + 5 files changed, 76 insertions(+), 38 deletions(-) diff --git a/openair1/PHY/defs.h b/openair1/PHY/defs.h index d5e595aaf0..97f94ea9c8 100644 --- a/openair1/PHY/defs.h +++ b/openair1/PHY/defs.h @@ -264,6 +264,8 @@ typedef struct { pthread_mutex_t mutex_rxtx; /// scheduling parameters for RXn-TXnp4 thread struct sched_param sched_param_rxtx; + /// pipeline ready state + int pipe_ready; } eNB_rxtx_proc_t; typedef struct { @@ -452,6 +454,8 @@ typedef struct RU_proc_t_s { int num_slaves; /// array of pointers to slaves struct RU_proc_t_s **slave_proc; + /// pipeline ready state + int ru_rx_ready; } RU_proc_t; /// Context data structure for eNB subframe processing diff --git a/openair2/LAYER2/MAC/eNB_scheduler_phytest.c b/openair2/LAYER2/MAC/eNB_scheduler_phytest.c index 6cd02db114..b2abcf8cb2 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_phytest.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_phytest.c @@ -196,7 +196,7 @@ void schedule_ulsch_phy_test(module_id_t module_idP,frame_t frameP,sub_frame_t s int UE_id = 0; uint8_t aggregation = 2; rnti_t rnti = 0x1235; - uint8_t mcs = 20; + uint8_t mcs = 0; uint8_t harq_pid = 0; uint32_t cqi_req = 0,cshift,ndi,tpc = 1; int32_t normalized_rx_power; diff --git a/targets/RT/USER/eNB_usrp.gtkw b/targets/RT/USER/eNB_usrp.gtkw index 2209e35851..e50c1831b6 100644 --- a/targets/RT/USER/eNB_usrp.gtkw +++ b/targets/RT/USER/eNB_usrp.gtkw @@ -1,17 +1,17 @@ [*] [*] GTKWave Analyzer v3.3.58 (w)1999-2014 BSI -[*] Fri Nov 3 16:03:52 2017 +[*] Thu Feb 22 14:46:40 2018 [*] [dumpfile] "/tmp/openair_dump_eNB.vcd" -[dumpfile_mtime] "Fri Nov 3 16:00:30 2017" -[dumpfile_size] 56765827 +[dumpfile_mtime] "Thu Feb 22 14:44:26 2018" +[dumpfile_size] 3482761 [savefile] "/homes/wangts/openairinterface5g/targets/RT/USER/eNB_usrp.gtkw" -[timestart] 15220241000 +[timestart] 4525000000 [size] 1920 1018 [pos] 0 22 -*-19.666586 15221741584 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 +*-21.506693 4530514310 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 -1 [sst_width] 386 -[signals_width] 302 +[signals_width] 344 [sst_expanded] 1 [sst_vpaned_height] 303 @28 @@ -34,11 +34,15 @@ functions.macxface_ue_scheduler functions.phy_eNB_ofdm_mod_l @24 variables.frame_number_RX0_eNB[63:0] -variables.frame_number_TX0_eNB[63:0] @25 -variables.frame_number_RX1_eNB[63:0] +variables.subframe_number_RX0_eNB[63:0] @24 +variables.frame_number_TX0_eNB[63:0] +variables.subframe_number_TX0_eNB[63:0] +variables.frame_number_RX1_eNB[63:0] +variables.subframe_number_RX1_eNB[63:0] variables.frame_number_TX1_eNB[63:0] +variables.subframe_number_TX1_eNB[63:0] @28 functions.phy_eNB_dlsch_modulation functions.phy_eNB_dlsch_encoding diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 0a1a7487fe..beb715119f 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -146,7 +146,7 @@ void init_eNB(int,int); void stop_eNB(int nb_inst); int wakeup_tx(PHY_VARS_eNB *eNB,RU_proc_t *ru_proc); -int wakeup_txfh(eNB_rxtx_proc_t *proc,RU_proc_t *ru_proc); +int wakeup_txfh(PHY_VARS_eNB *eNB,RU_proc_t *ru_proc); void wakeup_prach_eNB(PHY_VARS_eNB *eNB,RU_t *ru,int frame,int subframe); #ifdef Rel14 void wakeup_prach_eNB_br(PHY_VARS_eNB *eNB,RU_t *ru,int frame,int subframe); @@ -183,7 +183,7 @@ static inline int rxtx(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, char *thread_nam pthread_mutex_unlock(&eNB->UL_INFO_mutex); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER , 0 ); - + proc->pipe_ready = 1; if(get_nprocs() >= 8) { wakeup_tx(eNB,eNB->proc.ru_proc); @@ -193,13 +193,14 @@ static inline int rxtx(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, char *thread_nam if(oai_exit) return(-1); phy_procedures_eNB_TX(eNB, proc, no_relay, NULL, 1); - wakeup_txfh(proc,eNB->proc.ru_proc); + wakeup_txfh(eNB,eNB->proc.ru_proc); } else { if(oai_exit) return(-1); phy_procedures_eNB_TX(eNB, proc, no_relay, NULL, 1); } + proc->pipe_ready = 0; stop_meas( &softmodem_stats_rxtx_sf ); @@ -236,7 +237,9 @@ static void* tx_thread(void* param) { phy_procedures_eNB_TX(eNB, proc, no_relay, NULL, 1); if (release_thread(&proc->mutex_rxtx,&proc->instance_cnt_rxtx,thread_name)<0) break; - wakeup_txfh(proc,eNB_proc->ru_proc); + proc->pipe_ready = 1; + wakeup_txfh(eNB,eNB_proc->ru_proc); + proc->pipe_ready = 0; } return 0; @@ -358,15 +361,24 @@ void eNB_top(PHY_VARS_eNB *eNB, int frame_rx, int subframe_rx, char *string,RU_t } } -int wakeup_txfh(eNB_rxtx_proc_t *proc,RU_proc_t *ru_proc) { +int wakeup_txfh(PHY_VARS_eNB *eNB,RU_proc_t *ru_proc) { struct timespec wait; wait.tv_sec=0; wait.tv_nsec=5000000L; + eNB_proc_t *proc=&eNB->proc; + eNB_rxtx_proc_t *proc_rxtx1=&proc->proc_rxtx[1]; + eNB_rxtx_proc_t *proc_rxtx0=&proc->proc_rxtx[0]; + int ru_rx_ready = ru_proc->ru_rx_ready; + int pipe_ready_rx = proc_rxtx0->pipe_ready; + int pipe_ready_tx = proc_rxtx1->pipe_ready; + while(!ru_rx_ready && !pipe_ready_rx && !pipe_ready_tx){ + usleep(10); + } if (ru_proc->instance_cnt_eNBs == 0) { - LOG_E(PHY,"Frame %d, subframe %d: TX FH thread busy, dropping\n",proc->frame_rx,proc->subframe_rx); + LOG_E(PHY,"Frame %d, subframe %d: TX FH thread busy, dropping\n",proc_rxtx1->frame_rx,proc_rxtx1->subframe_rx); return(-1); } if (pthread_mutex_timedlock(&ru_proc->mutex_eNBs,&wait) != 0) { @@ -376,9 +388,9 @@ int wakeup_txfh(eNB_rxtx_proc_t *proc,RU_proc_t *ru_proc) { } ++ru_proc->instance_cnt_eNBs; - ru_proc->timestamp_tx = proc->timestamp_tx; - ru_proc->subframe_tx = proc->subframe_tx; - ru_proc->frame_tx = proc->frame_tx; + ru_proc->timestamp_tx = proc_rxtx1->timestamp_tx; + ru_proc->subframe_tx = proc_rxtx1->subframe_tx; + ru_proc->frame_tx = proc_rxtx1->frame_tx; // the thread can now be woken up if (pthread_cond_signal(&ru_proc->cond_eNBs) != 0) { @@ -405,6 +417,13 @@ int wakeup_tx(PHY_VARS_eNB *eNB,RU_proc_t *ru_proc) { wait.tv_sec=0; wait.tv_nsec=5000000L; + int ru_rx_ready = ru_proc->ru_rx_ready; + int pipe_ready_rx = proc_rxtx0->pipe_ready; + int pipe_ready_tx = proc_rxtx1->pipe_ready; + + while(!ru_rx_ready && !pipe_ready_rx && !pipe_ready_tx){ + usleep(10); + } if (proc_rxtx1->instance_cnt_rxtx == 0) { LOG_E(PHY,"Frame %d, subframe %d: TX1 thread busy, dropping\n",proc_rxtx1->frame_rx,proc_rxtx1->subframe_rx); return(-1); @@ -442,8 +461,8 @@ int wakeup_rxtx(PHY_VARS_eNB *eNB,RU_t *ru) { eNB_proc_t *proc=&eNB->proc; RU_proc_t *ru_proc=&ru->proc; - eNB_rxtx_proc_t *proc_rxtx=&proc->proc_rxtx[0];//*proc_rxtx=&proc->proc_rxtx[proc->frame_rx&1]; - //proc->ru_proc = &ru->proc; + eNB_rxtx_proc_t *proc_rxtx0=&proc->proc_rxtx[0];//*proc_rxtx=&proc->proc_rxtx[proc->frame_rx&1]; + eNB_rxtx_proc_t *proc_rxtx1=&proc->proc_rxtx[1]; LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms; @@ -474,26 +493,32 @@ int wakeup_rxtx(PHY_VARS_eNB *eNB,RU_t *ru) { wait.tv_sec=0; wait.tv_nsec=5000000L; - - /* accept some delay in processing - up to 50us */ - if (proc_rxtx->instance_cnt_rxtx == 0) { - usleep(50); + int ru_rx_ready = ru_proc->ru_rx_ready; + int pipe_ready_rx = proc_rxtx0->pipe_ready; + int pipe_ready_tx = proc_rxtx1->pipe_ready; + + while(!ru_rx_ready && !pipe_ready_rx && !pipe_ready_tx){ + usleep(10); } - if (proc_rxtx->instance_cnt_rxtx == 0) { - LOG_E(PHY,"Frame %d, subframe %d: RXTX0 thread busy, dropping\n",proc_rxtx->frame_rx,proc_rxtx->subframe_rx); + /* accept some delay in processing - up to 50us */ + //if (proc_rxtx0->instance_cnt_rxtx == 0) { + // usleep(50); + //} + if (proc_rxtx0->instance_cnt_rxtx == 0) { + LOG_E(PHY,"Frame %d, subframe %d: RXTX0 thread busy, dropping\n",proc_rxtx0->frame_rx,proc_rxtx0->subframe_rx); return(-1); } // wake up TX for subframe n+4 // lock the TX mutex and make sure the thread is ready - if (pthread_mutex_timedlock(&proc_rxtx->mutex_rxtx,&wait) != 0) { - LOG_E( PHY, "[eNB] ERROR pthread_mutex_lock for eNB RXTX thread %d (IC %d)\n", proc_rxtx->subframe_rx&1,proc_rxtx->instance_cnt_rxtx ); + if (pthread_mutex_timedlock(&proc_rxtx0->mutex_rxtx,&wait) != 0) { + LOG_E( PHY, "[eNB] ERROR pthread_mutex_lock for eNB RXTX thread %d (IC %d)\n", proc_rxtx0->subframe_rx&1,proc_rxtx0->instance_cnt_rxtx ); exit_fun( "error locking mutex_rxtx" ); return(-1); } - ++proc_rxtx->instance_cnt_rxtx; + ++proc_rxtx0->instance_cnt_rxtx; // We have just received and processed the common part of a subframe, say n. // TS_rx is the last received timestamp (start of 1st slot), TS_tx is the desired @@ -508,22 +533,22 @@ int wakeup_rxtx(PHY_VARS_eNB *eNB,RU_t *ru) { proc_rxtx->subframe_tx = (proc_rxtx->subframe_rx + 4)%10; */ - proc_rxtx->subframe_rx = ru_proc->subframe_rx; - proc_rxtx->frame_rx = ru_proc->frame_rx; - proc_rxtx->subframe_tx = (ru_proc->subframe_rx+4)%10; - proc_rxtx->frame_tx = (ru_proc->subframe_rx>5) ? (1+ru_proc->frame_rx)&1023 : ru_proc->frame_rx; - proc->frame_tx = proc_rxtx->frame_tx; - proc->frame_rx = proc_rxtx->frame_rx; - proc_rxtx->timestamp_tx = ru_proc->timestamp_rx+(4*fp->samples_per_tti); + proc_rxtx0->subframe_rx = ru_proc->subframe_rx; + proc_rxtx0->frame_rx = ru_proc->frame_rx; + proc_rxtx0->subframe_tx = (ru_proc->subframe_rx+4)%10; + proc_rxtx0->frame_tx = (ru_proc->subframe_rx>5) ? (1+ru_proc->frame_rx)&1023 : ru_proc->frame_rx; + proc->frame_tx = proc_rxtx0->frame_tx; + proc->frame_rx = proc_rxtx0->frame_rx; + proc_rxtx0->timestamp_tx = ru_proc->timestamp_rx+(4*fp->samples_per_tti); // the thread can now be woken up - if (pthread_cond_signal(&proc_rxtx->cond_rxtx) != 0) { + if (pthread_cond_signal(&proc_rxtx0->cond_rxtx) != 0) { LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB RXn-TXnp4 thread\n"); exit_fun( "ERROR pthread_cond_signal" ); return(-1); } - pthread_mutex_unlock( &proc_rxtx->mutex_rxtx ); + pthread_mutex_unlock( &proc_rxtx0->mutex_rxtx ); return(0); } @@ -785,6 +810,8 @@ void init_eNB_proc(int inst) { proc_rxtx = proc->proc_rxtx; proc_rxtx[0].instance_cnt_rxtx = -1; proc_rxtx[1].instance_cnt_rxtx = -1; + proc_rxtx[0].pipe_ready = 1; + proc_rxtx[1].pipe_ready = 1; proc->instance_cnt_prach = -1; proc->instance_cnt_asynch_rxtx = -1; proc->instance_cnt_synch = -1; diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index 6b3fa67b13..640f15ef7f 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -1596,7 +1596,9 @@ static void* ru_thread( void* param ) { LOG_D(PHY,"RU %d/%d frame_tx %d, subframe_tx %d\n",0,ru->idx,proc->frame_tx,proc->subframe_tx); // wakeup all eNB processes waiting for this RU + proc->ru_rx_ready = 1; if (ru->num_eNB>0) wakeup_eNBs(ru); + proc->ru_rx_ready = 0; if(get_nprocs() <=4) @@ -1752,6 +1754,7 @@ void init_RU_proc(RU_t *ru) { proc->frame_offset = 0; proc->num_slaves = 0; proc->frame_tx_unwrap = 0; + proc->ru_rx_ready = 1; for (i=0;i<10;i++) proc->symbol_mask[i]=0; From 4b39203763e5cd90865b9a6d55ebbbd26c8236d8 Mon Sep 17 00:00:00 2001 From: Wang Tsu-Han Date: Fri, 23 Feb 2018 16:59:57 +0100 Subject: [PATCH 43/63] adding te/td distructure --- openair1/PHY/defs.h | 12 ++--- openair1/SCHED/phy_procedures_lte_eNb.c | 65 +++++++++++++------------ targets/RT/USER/lte-enb.c | 35 ++++++------- targets/RT/USER/lte-softmodem.h | 6 ++- 4 files changed, 59 insertions(+), 59 deletions(-) diff --git a/openair1/PHY/defs.h b/openair1/PHY/defs.h index 97f94ea9c8..c140c3bcaa 100644 --- a/openair1/PHY/defs.h +++ b/openair1/PHY/defs.h @@ -489,7 +489,7 @@ typedef struct eNB_proc_t_s { /// \internal This variable is protected by \ref mutex_td. int instance_cnt_td; /// \internal This variable is protected by \ref mutex_te. - int instance_cnt_te[3]; + //int instance_cnt_te[3]; /// \internal This variable is protected by \ref mutex_prach. int instance_cnt_prach; #ifdef Rel14 @@ -511,7 +511,7 @@ typedef struct eNB_proc_t_s { /// pthread attributes for parallel turbo-decoder thread pthread_attr_t attr_td; /// pthread attributes for parallel turbo-encoder thread - pthread_attr_t attr_te[3]; + //pthread_attr_t attr_te[3]; /// pthread attributes for single eNB processing thread pthread_attr_t attr_single; /// pthread attributes for prach processing thread @@ -525,7 +525,7 @@ typedef struct eNB_proc_t_s { /// scheduling parameters for parallel turbo-decoder thread struct sched_param sched_param_td; /// scheduling parameters for parallel turbo-encoder thread - struct sched_param sched_param_te[3]; + //struct sched_param sched_param_te[3]; /// scheduling parameters for single eNB thread struct sched_param sched_param_single; /// scheduling parameters for prach thread @@ -539,7 +539,7 @@ typedef struct eNB_proc_t_s { /// pthread structure for parallel turbo-decoder thread pthread_t pthread_td; /// pthread structure for parallel turbo-encoder thread - pthread_t pthread_te[3]; + //pthread_t pthread_te[3]; /// pthread structure for PRACH thread pthread_t pthread_prach; #ifdef Rel14 @@ -549,7 +549,7 @@ typedef struct eNB_proc_t_s { /// condition variable for parallel turbo-decoder thread pthread_cond_t cond_td; /// condition variable for parallel turbo-encoder thread - pthread_cond_t cond_te[3]; + //pthread_cond_t cond_te[3]; /// condition variable for PRACH processing thread; pthread_cond_t cond_prach; #ifdef Rel14 @@ -561,7 +561,7 @@ typedef struct eNB_proc_t_s { /// mutex for parallel turbo-decoder thread pthread_mutex_t mutex_td; /// mutex for parallel turbo-encoder thread - pthread_mutex_t mutex_te[3]; + //pthread_mutex_t mutex_te[3]; /// mutex for PRACH thread pthread_mutex_t mutex_prach; #ifdef Rel14 diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index 9f13d3ff7e..c7d975d85f 100644 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -1494,18 +1494,29 @@ extern int oai_exit; extern void *td_thread(void*); -void init_td_thread(PHY_VARS_eNB *eNB,pthread_attr_t *attr_td) { +void init_td_thread(PHY_VARS_eNB *eNB) { eNB_proc_t *proc = &eNB->proc; proc->tdp.eNB = eNB; proc->instance_cnt_td = -1; - + + pthread_attr_init( &proc->attr_td); pthread_mutex_init( &proc->mutex_td, NULL); pthread_cond_init( &proc->cond_td, NULL); + + pthread_create(&proc->pthread_td, &proc->attr_td, td_thread, (void*)&proc->tdp); - pthread_create(&proc->pthread_td, attr_td, td_thread, (void*)&proc->tdp); +} +void kill_td_thread(PHY_VARS_eNB *eNB) { + eNB_proc_t *proc = &eNB->proc; + proc->instance_cnt_td = 0; + pthread_cond_signal(&proc->cond_td); + + pthread_join(proc->pthread_td, NULL); + pthread_mutex_destroy( &proc->mutex_td ); + pthread_cond_destroy( &proc->cond_td ); } extern void *te_thread(void*); @@ -1514,37 +1525,29 @@ void init_te_thread(PHY_VARS_eNB *eNB) { eNB_proc_t *proc = &eNB->proc; - proc->tep[0].eNB = eNB; - proc->tep[0].instance_cnt_te = -1; + for(int i=0; i<3 ;i++){ + proc->tep[i].eNB = eNB; + proc->tep[i].instance_cnt_te = -1; + + pthread_mutex_init( &proc->tep[i].mutex_te, NULL); + pthread_cond_init( &proc->tep[i].cond_te, NULL); + pthread_attr_init( &proc->tep[i].attr_te); - pthread_mutex_init( &proc->tep[0].mutex_te, NULL); - pthread_cond_init( &proc->tep[0].cond_te, NULL); - pthread_attr_init( &proc->tep[0].attr_te); + printf("Creating te_thread 0\n"); + pthread_create(&proc->tep[i].pthread_te, &proc->tep[i].attr_te, te_thread, (void*)&proc->tep[i]); + } +} +void kill_te_thread(PHY_VARS_eNB *eNB) { - printf("Creating te_thread 0\n"); - pthread_create(&proc->tep[0].pthread_te, &proc->tep[0].attr_te, te_thread, (void*)&proc->tep[0]); + eNB_proc_t *proc = &eNB->proc; - ///////////////////////////////////////////////////////////////////////// - proc->tep[1].eNB = eNB; - proc->tep[1].instance_cnt_te = -1; - - pthread_mutex_init( &proc->tep[1].mutex_te, NULL); - pthread_cond_init( &proc->tep[1].cond_te, NULL); - pthread_attr_init( &proc->tep[1].attr_te); - - printf("Creating te_thread 1\n"); - pthread_create(&proc->tep[1].pthread_te, &proc->tep[1].attr_te, te_thread, (void*)&proc->tep[1]); - - ///////////////////////////////////////////////////////////////////////// - proc->tep[2].eNB = eNB; - proc->tep[2].instance_cnt_te = -1; - - pthread_mutex_init( &proc->tep[2].mutex_te, NULL); - pthread_cond_init( &proc->tep[2].cond_te, NULL); - pthread_attr_init( &proc->tep[2].attr_te); - - printf("Creating te_thread 2\n"); - pthread_create(&proc->tep[2].pthread_te, &proc->tep[2].attr_te, te_thread, (void*)&proc->tep[2]); + for(int i=0; i<3 ;i++){ + proc->tep[i].instance_cnt_te = 0; + pthread_cond_signal(&proc->tep[i].cond_te); + pthread_join(proc->tep[i].pthread_te, NULL); + pthread_mutex_init( &proc->tep[i].mutex_te, NULL); + pthread_cond_init( &proc->tep[i].cond_te, NULL); + } } diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index beb715119f..d36f83b739 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -756,8 +756,10 @@ static void* eNB_thread_prach_br( void* param ) { -extern void init_td_thread(PHY_VARS_eNB *, pthread_attr_t *); +extern void init_td_thread(PHY_VARS_eNB *); extern void init_te_thread(PHY_VARS_eNB *); +extern void kill_td_thread(PHY_VARS_eNB *); +extern void kill_te_thread(PHY_VARS_eNB *); //////////////////////////////////////need to modified////////////////***** static void* process_stats_thread(void* param) { @@ -795,7 +797,7 @@ void init_eNB_proc(int inst) { PHY_VARS_eNB *eNB; eNB_proc_t *proc; eNB_rxtx_proc_t *proc_rxtx; - pthread_attr_t *attr0=NULL,*attr1=NULL,*attr_prach=NULL,*attr_td=NULL;//,*attr_te=NULL,*attr_te1=NULL; + pthread_attr_t *attr0=NULL,*attr1=NULL,*attr_prach=NULL; #ifdef Rel14 pthread_attr_t *attr_prach_br=NULL; #endif @@ -838,9 +840,6 @@ void init_eNB_proc(int inst) { pthread_attr_init( &proc->attr_prach); pthread_attr_init( &proc->attr_asynch_rxtx); - pthread_attr_init( &proc->attr_td); - //pthread_attr_init( &proc->attr_te[0]); - //pthread_attr_init( &proc->attr_te[1]); pthread_attr_init( &proc_rxtx[0].attr_rxtx); pthread_attr_init( &proc_rxtx[1].attr_rxtx); #ifdef Rel14 @@ -862,14 +861,11 @@ void init_eNB_proc(int inst) { // attr_td = &proc->attr_td; // attr_te = &proc->attr_te; #endif - attr_td = &proc->attr_td; - //attr_te = &proc->attr_te[0]; - //attr_te1 = &proc->attr_te[1]; //////////////////////////////////////need to modified////////////////***** if(get_nprocs() > 2 && codingw) { init_te_thread(eNB); - init_td_thread(eNB,attr_td); + init_td_thread(eNB); } //////////////////////////////////////need to modified////////////////***** pthread_create( &proc_rxtx[0].pthread_rxtx, attr0, eNB_thread_rxtx, proc ); @@ -941,11 +937,12 @@ void kill_eNB_proc(int inst) { proc_rxtx = &proc->proc_rxtx[0]; + kill_td_thread(eNB); + kill_te_thread(eNB); LOG_I(PHY, "Killing TX CC_id %d inst %d\n", CC_id, inst ); - + proc_rxtx[0].instance_cnt_rxtx = 0; // FIXME data race! + proc_rxtx[1].instance_cnt_rxtx = 0; // FIXME data race! if (eNB->single_thread_flag==0) { - proc_rxtx[0].instance_cnt_rxtx = 0; // FIXME data race! - proc_rxtx[1].instance_cnt_rxtx = 0; // FIXME data race! pthread_cond_signal( &proc_rxtx[0].cond_rxtx ); pthread_cond_signal( &proc_rxtx[1].cond_rxtx ); } @@ -968,14 +965,12 @@ void kill_eNB_proc(int inst) { LOG_I(PHY, "Destroying UL_INFO mutex\n"); pthread_mutex_destroy(&eNB->UL_INFO_mutex); int i; - if (eNB->single_thread_flag==0) { - for (i=0;i<2;i++) { - LOG_I(PHY, "Joining rxtx[%d] mutex/cond\n",i); - pthread_join( proc_rxtx[i].pthread_rxtx, (void**)&status ); - LOG_I(PHY, "Destroying rxtx[%d] mutex/cond\n",i); - pthread_mutex_destroy( &proc_rxtx[i].mutex_rxtx ); - pthread_cond_destroy( &proc_rxtx[i].cond_rxtx ); - } + for (i=0;i<2;i++) { + LOG_I(PHY, "Joining rxtx[%d] mutex/cond\n",i); + pthread_join( proc_rxtx[i].pthread_rxtx, (void**)&status ); + LOG_I(PHY, "Destroying rxtx[%d] mutex/cond\n",i); + pthread_mutex_destroy( &proc_rxtx[i].mutex_rxtx ); + pthread_cond_destroy( &proc_rxtx[i].cond_rxtx ); } } } diff --git a/targets/RT/USER/lte-softmodem.h b/targets/RT/USER/lte-softmodem.h index 5a2e0365ea..4027d24d57 100644 --- a/targets/RT/USER/lte-softmodem.h +++ b/targets/RT/USER/lte-softmodem.h @@ -264,7 +264,9 @@ extern void reset_opp_meas(void); extern void print_opp_meas(void); extern void init_fep_thread(PHY_VARS_eNB *, pthread_attr_t *); -extern void init_td_thread(PHY_VARS_eNB *, pthread_attr_t *); -extern void init_te_thread(PHY_VARS_eNB *, pthread_attr_t *); +extern void init_td_thread(PHY_VARS_eNB *); +extern void init_te_thread(PHY_VARS_eNB *); +extern void kill_td_thread(PHY_VARS_eNB *); +extern void kill_te_thread(PHY_VARS_eNB *); #endif From 23f5628735ef1332811a6e6b70958212dd047877 Mon Sep 17 00:00:00 2001 From: Wang Tsu-Han Date: Mon, 5 Mar 2018 11:20:51 +0100 Subject: [PATCH 44/63] changing into double sided signal for pipeline --- openair1/PHY/defs.h | 1 + openair2/LAYER2/MAC/eNB_scheduler_phytest.c | 3 +- targets/RT/USER/lte-enb.c | 69 ++++++++++++--------- targets/RT/USER/lte-ru.c | 19 ++++-- 4 files changed, 56 insertions(+), 36 deletions(-) diff --git a/openair1/PHY/defs.h b/openair1/PHY/defs.h index c140c3bcaa..e53513817d 100644 --- a/openair1/PHY/defs.h +++ b/openair1/PHY/defs.h @@ -456,6 +456,7 @@ typedef struct RU_proc_t_s { struct RU_proc_t_s **slave_proc; /// pipeline ready state int ru_rx_ready; + int ru_tx_ready; } RU_proc_t; /// Context data structure for eNB subframe processing diff --git a/openair2/LAYER2/MAC/eNB_scheduler_phytest.c b/openair2/LAYER2/MAC/eNB_scheduler_phytest.c index b2abcf8cb2..3245b9e8f0 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_phytest.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_phytest.c @@ -216,10 +216,9 @@ void schedule_ulsch_phy_test(module_id_t module_idP,frame_t frameP,sub_frame_t s nfapi_hi_dci0_request_body_t *hi_dci0_req = &eNB->HI_DCI0_req[CC_id].hi_dci0_request_body; nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu; - nfapi_ul_config_request_pdu_t *ul_config_pdu; + //nfapi_ul_config_request_pdu_t *ul_config_pdu = &ul_req->ul_config_pdu_list[0];; nfapi_ul_config_request_body_t *ul_req = &eNB->UL_req[CC_id].ul_config_request_body; - ul_config_pdu = &ul_req->ul_config_pdu_list[0]; eNB->UL_req[CC_id].sfn_sf = (sched_frame<<4) + sched_subframe; eNB->HI_DCI0_req[CC_id].sfn_sf = (frameP<<4)+subframeP; diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index d36f83b739..8b0609d428 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -183,12 +183,11 @@ static inline int rxtx(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, char *thread_nam pthread_mutex_unlock(&eNB->UL_INFO_mutex); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER , 0 ); - proc->pipe_ready = 1; if(get_nprocs() >= 8) { wakeup_tx(eNB,eNB->proc.ru_proc); } - else if(get_nprocs() > 4) + else if(get_nprocs() >= 4) { if(oai_exit) return(-1); phy_procedures_eNB_TX(eNB, proc, no_relay, NULL, 1); @@ -200,7 +199,6 @@ static inline int rxtx(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, char *thread_nam if(oai_exit) return(-1); phy_procedures_eNB_TX(eNB, proc, no_relay, NULL, 1); } - proc->pipe_ready = 0; stop_meas( &softmodem_stats_rxtx_sf ); @@ -221,6 +219,15 @@ static void* tx_thread(void* param) { //wait_sync("tx_thread"); while (!oai_exit) { + + pthread_mutex_lock( &proc->mutex_rxtx ); + proc->pipe_ready++; + // the thread can now be woken up + if (pthread_cond_signal(&proc->cond_rxtx) != 0) { + LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB TXnp4 thread\n"); + exit_fun( "ERROR pthread_cond_signal" ); + } + pthread_mutex_unlock( &proc->mutex_rxtx ); if (wait_on_condition(&proc->mutex_rxtx,&proc->cond_rxtx,&proc->instance_cnt_rxtx,thread_name)<0) break; if (oai_exit) break; @@ -237,9 +244,7 @@ static void* tx_thread(void* param) { phy_procedures_eNB_TX(eNB, proc, no_relay, NULL, 1); if (release_thread(&proc->mutex_rxtx,&proc->instance_cnt_rxtx,thread_name)<0) break; - proc->pipe_ready = 1; wakeup_txfh(eNB,eNB_proc->ru_proc); - proc->pipe_ready = 0; } return 0; @@ -279,7 +284,18 @@ static void* eNB_thread_rxtx( void* param ) { //wait_sync("eNB_thread_rxtx"); while (!oai_exit) { + + pthread_mutex_lock( &proc->mutex_rxtx ); + proc->pipe_ready++; + // the thread can now be woken up + if (pthread_cond_signal(&proc->cond_rxtx) != 0) { + LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB TXnp4 thread\n"); + exit_fun( "ERROR pthread_cond_signal" ); + } + pthread_mutex_unlock( &proc->mutex_rxtx ); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_eNB_PROC_RXTX0+(proc->subframe_rx&1), 0 ); + T(T_ENB_MASTER_TICK, T_INT(0), T_INT(proc->frame_rx), T_INT(proc->subframe_rx)); if (wait_on_condition(&proc->mutex_rxtx,&proc->cond_rxtx,&proc->instance_cnt_rxtx,thread_name)<0) break; @@ -368,17 +384,16 @@ int wakeup_txfh(PHY_VARS_eNB *eNB,RU_proc_t *ru_proc) { wait.tv_nsec=5000000L; eNB_proc_t *proc=&eNB->proc; eNB_rxtx_proc_t *proc_rxtx1=&proc->proc_rxtx[1]; - eNB_rxtx_proc_t *proc_rxtx0=&proc->proc_rxtx[0]; + //eNB_rxtx_proc_t *proc_rxtx0=&proc->proc_rxtx[0]; - int ru_rx_ready = ru_proc->ru_rx_ready; - int pipe_ready_rx = proc_rxtx0->pipe_ready; - int pipe_ready_tx = proc_rxtx1->pipe_ready; - - while(!ru_rx_ready && !pipe_ready_rx && !pipe_ready_tx){ - usleep(10); + if(wait_on_condition(&ru_proc->mutex_eNBs,&ru_proc->cond_eNBs,&ru_proc->ru_tx_ready,"wakeup_txfh")<0) { + LOG_E(PHY,"Frame %d, subframe %d: TX FH not ready\n", ru_proc->frame_tx, ru_proc->subframe_tx); + return(-1); } + if (release_thread(&ru_proc->mutex_eNBs,&ru_proc->ru_tx_ready,"wakeup_txfh")<0) return(-1); + if (ru_proc->instance_cnt_eNBs == 0) { - LOG_E(PHY,"Frame %d, subframe %d: TX FH thread busy, dropping\n",proc_rxtx1->frame_rx,proc_rxtx1->subframe_rx); + LOG_E(PHY,"Frame %d, subframe %d: TX FH thread busy, dropping Frame %d, subframe %d\n", ru_proc->frame_tx, ru_proc->subframe_tx, proc_rxtx1->frame_rx, proc_rxtx1->subframe_rx); return(-1); } if (pthread_mutex_timedlock(&ru_proc->mutex_eNBs,&wait) != 0) { @@ -417,13 +432,14 @@ int wakeup_tx(PHY_VARS_eNB *eNB,RU_proc_t *ru_proc) { wait.tv_sec=0; wait.tv_nsec=5000000L; - int ru_rx_ready = ru_proc->ru_rx_ready; - int pipe_ready_rx = proc_rxtx0->pipe_ready; int pipe_ready_tx = proc_rxtx1->pipe_ready; - while(!ru_rx_ready && !pipe_ready_rx && !pipe_ready_tx){ - usleep(10); + if(wait_on_condition(&proc_rxtx1->mutex_rxtx,&proc_rxtx1->cond_rxtx,&proc_rxtx1->pipe_ready,"wakeup_tx")<0) { + LOG_E(PHY,"Frame %d, subframe %d: TX1 not ready\n",proc_rxtx1->frame_rx,proc_rxtx1->subframe_rx); + return(-1); } + if (release_thread(&proc_rxtx1->mutex_rxtx,&proc_rxtx1->pipe_ready,"wakeup_tx")<0) return(-1); + if (proc_rxtx1->instance_cnt_rxtx == 0) { LOG_E(PHY,"Frame %d, subframe %d: TX1 thread busy, dropping\n",proc_rxtx1->frame_rx,proc_rxtx1->subframe_rx); return(-1); @@ -493,17 +509,14 @@ int wakeup_rxtx(PHY_VARS_eNB *eNB,RU_t *ru) { wait.tv_sec=0; wait.tv_nsec=5000000L; - int ru_rx_ready = ru_proc->ru_rx_ready; - int pipe_ready_rx = proc_rxtx0->pipe_ready; - int pipe_ready_tx = proc_rxtx1->pipe_ready; + - while(!ru_rx_ready && !pipe_ready_rx && !pipe_ready_tx){ - usleep(10); + if(wait_on_condition(&proc_rxtx0->mutex_rxtx,&proc_rxtx0->cond_rxtx,&proc_rxtx0->pipe_ready,"wakeup_rxtx")<0) { + LOG_E(PHY,"Frame %d, subframe %d: RXTX0 not ready\n",proc_rxtx0->frame_rx,proc_rxtx0->subframe_rx); + return(-1); } - /* accept some delay in processing - up to 50us */ - //if (proc_rxtx0->instance_cnt_rxtx == 0) { - // usleep(50); - //} + if (release_thread(&proc_rxtx0->mutex_rxtx,&proc_rxtx0->pipe_ready,"wakeup_rxtx")<0) return(-1); + if (proc_rxtx0->instance_cnt_rxtx == 0) { LOG_E(PHY,"Frame %d, subframe %d: RXTX0 thread busy, dropping\n",proc_rxtx0->frame_rx,proc_rxtx0->subframe_rx); return(-1); @@ -812,8 +825,8 @@ void init_eNB_proc(int inst) { proc_rxtx = proc->proc_rxtx; proc_rxtx[0].instance_cnt_rxtx = -1; proc_rxtx[1].instance_cnt_rxtx = -1; - proc_rxtx[0].pipe_ready = 1; - proc_rxtx[1].pipe_ready = 1; + proc_rxtx[0].pipe_ready = 0; + proc_rxtx[1].pipe_ready = 0; proc->instance_cnt_prach = -1; proc->instance_cnt_asynch_rxtx = -1; proc->instance_cnt_synch = -1; diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index 640f15ef7f..792cf4cc4d 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -1156,7 +1156,7 @@ void wakeup_eNBs(RU_t *ru) { LOG_D(PHY,"wakeup_eNBs (num %d) for RU %d\n",ru->num_eNB,ru->idx); - if (get_nprocs() <= 4) { + if (get_nprocs() < 4) { // call eNB function directly char string[20]; @@ -1440,8 +1440,16 @@ static void* ru_thread_tx( void* param ) { if (ru->fh_north_out) ru->fh_north_out(ru); } - release_thread(&proc->mutex_eNBs,&proc->instance_cnt_eNBs,"ru_thread_tx"); + + pthread_mutex_lock( &proc->mutex_eNBs ); + proc->ru_tx_ready++; + // the thread can now be woken up + if (pthread_cond_signal(&proc->cond_eNBs) != 0) { + LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB TXnp4 thread\n"); + exit_fun( "ERROR pthread_cond_signal" ); + } + pthread_mutex_unlock( &proc->mutex_eNBs ); } release_thread(&proc->mutex_FH1,&proc->instance_cnt_FH1,"ru_thread_tx"); return 0; @@ -1596,12 +1604,10 @@ static void* ru_thread( void* param ) { LOG_D(PHY,"RU %d/%d frame_tx %d, subframe_tx %d\n",0,ru->idx,proc->frame_tx,proc->subframe_tx); // wakeup all eNB processes waiting for this RU - proc->ru_rx_ready = 1; if (ru->num_eNB>0) wakeup_eNBs(ru); - proc->ru_rx_ready = 0; - if(get_nprocs() <=4) + if(get_nprocs() <4) { if(!emulate_rf){ // do TX front-end processing if needed (precoding and/or IDFTs) @@ -1754,7 +1760,8 @@ void init_RU_proc(RU_t *ru) { proc->frame_offset = 0; proc->num_slaves = 0; proc->frame_tx_unwrap = 0; - proc->ru_rx_ready = 1; + proc->ru_rx_ready = 0; + proc->ru_tx_ready = 0; for (i=0;i<10;i++) proc->symbol_mask[i]=0; From ac95f89aa5beaad218686195f32a16c2f4b18889 Mon Sep 17 00:00:00 2001 From: Wang Tsu-Han Date: Mon, 5 Mar 2018 11:43:14 +0100 Subject: [PATCH 45/63] fixes for fewer core --- targets/RT/USER/lte-enb.c | 22 ++++++++++------------ targets/RT/USER/lte-ru.c | 10 +++++----- 2 files changed, 15 insertions(+), 17 deletions(-) diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 8b0609d428..e67e1c88e7 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -146,7 +146,7 @@ void init_eNB(int,int); void stop_eNB(int nb_inst); int wakeup_tx(PHY_VARS_eNB *eNB,RU_proc_t *ru_proc); -int wakeup_txfh(PHY_VARS_eNB *eNB,RU_proc_t *ru_proc); +int wakeup_txfh(eNB_rxtx_proc_t *proc,RU_proc_t *ru_proc); void wakeup_prach_eNB(PHY_VARS_eNB *eNB,RU_t *ru,int frame,int subframe); #ifdef Rel14 void wakeup_prach_eNB_br(PHY_VARS_eNB *eNB,RU_t *ru,int frame,int subframe); @@ -192,7 +192,7 @@ static inline int rxtx(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, char *thread_nam if(oai_exit) return(-1); phy_procedures_eNB_TX(eNB, proc, no_relay, NULL, 1); - wakeup_txfh(eNB,eNB->proc.ru_proc); + wakeup_txfh(proc,eNB->proc.ru_proc); } else { @@ -244,7 +244,7 @@ static void* tx_thread(void* param) { phy_procedures_eNB_TX(eNB, proc, no_relay, NULL, 1); if (release_thread(&proc->mutex_rxtx,&proc->instance_cnt_rxtx,thread_name)<0) break; - wakeup_txfh(eNB,eNB_proc->ru_proc); + wakeup_txfh(proc,eNB_proc->ru_proc); } return 0; @@ -377,14 +377,12 @@ void eNB_top(PHY_VARS_eNB *eNB, int frame_rx, int subframe_rx, char *string,RU_t } } -int wakeup_txfh(PHY_VARS_eNB *eNB,RU_proc_t *ru_proc) { +int wakeup_txfh(eNB_rxtx_proc_t *proc,RU_proc_t *ru_proc) { struct timespec wait; wait.tv_sec=0; wait.tv_nsec=5000000L; - eNB_proc_t *proc=&eNB->proc; - eNB_rxtx_proc_t *proc_rxtx1=&proc->proc_rxtx[1]; - //eNB_rxtx_proc_t *proc_rxtx0=&proc->proc_rxtx[0]; + if(wait_on_condition(&ru_proc->mutex_eNBs,&ru_proc->cond_eNBs,&ru_proc->ru_tx_ready,"wakeup_txfh")<0) { LOG_E(PHY,"Frame %d, subframe %d: TX FH not ready\n", ru_proc->frame_tx, ru_proc->subframe_tx); @@ -393,7 +391,7 @@ int wakeup_txfh(PHY_VARS_eNB *eNB,RU_proc_t *ru_proc) { if (release_thread(&ru_proc->mutex_eNBs,&ru_proc->ru_tx_ready,"wakeup_txfh")<0) return(-1); if (ru_proc->instance_cnt_eNBs == 0) { - LOG_E(PHY,"Frame %d, subframe %d: TX FH thread busy, dropping Frame %d, subframe %d\n", ru_proc->frame_tx, ru_proc->subframe_tx, proc_rxtx1->frame_rx, proc_rxtx1->subframe_rx); + LOG_E(PHY,"Frame %d, subframe %d: TX FH thread busy, dropping Frame %d, subframe %d\n", ru_proc->frame_tx, ru_proc->subframe_tx, proc->frame_rx, proc->subframe_rx); return(-1); } if (pthread_mutex_timedlock(&ru_proc->mutex_eNBs,&wait) != 0) { @@ -403,9 +401,9 @@ int wakeup_txfh(PHY_VARS_eNB *eNB,RU_proc_t *ru_proc) { } ++ru_proc->instance_cnt_eNBs; - ru_proc->timestamp_tx = proc_rxtx1->timestamp_tx; - ru_proc->subframe_tx = proc_rxtx1->subframe_tx; - ru_proc->frame_tx = proc_rxtx1->frame_tx; + ru_proc->timestamp_tx = proc->timestamp_tx; + ru_proc->subframe_tx = proc->subframe_tx; + ru_proc->frame_tx = proc->frame_tx; // the thread can now be woken up if (pthread_cond_signal(&ru_proc->cond_eNBs) != 0) { @@ -478,7 +476,7 @@ int wakeup_rxtx(PHY_VARS_eNB *eNB,RU_t *ru) { RU_proc_t *ru_proc=&ru->proc; eNB_rxtx_proc_t *proc_rxtx0=&proc->proc_rxtx[0];//*proc_rxtx=&proc->proc_rxtx[proc->frame_rx&1]; - eNB_rxtx_proc_t *proc_rxtx1=&proc->proc_rxtx[1]; + //eNB_rxtx_proc_t *proc_rxtx1=&proc->proc_rxtx[1]; LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms; diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index 792cf4cc4d..c6de652bc1 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -1609,12 +1609,12 @@ static void* ru_thread( void* param ) { if(get_nprocs() <4) { + // do TX front-end processing if needed (precoding and/or IDFTs) + if (ru->feptx_prec) ru->feptx_prec(ru); + + // do OFDM if needed + if ((ru->fh_north_asynch_in == NULL) && (ru->feptx_ofdm)) ru->feptx_ofdm(ru); if(!emulate_rf){ - // do TX front-end processing if needed (precoding and/or IDFTs) - if (ru->feptx_prec) ru->feptx_prec(ru); - - // do OFDM if needed - if ((ru->fh_north_asynch_in == NULL) && (ru->feptx_ofdm)) ru->feptx_ofdm(ru); // do outgoing fronthaul (south) if needed if ((ru->fh_north_asynch_in == NULL) && (ru->fh_south_out)) ru->fh_south_out(ru); From 822416e9e21ab56f2e80238e476f4affd2253ae5 Mon Sep 17 00:00:00 2001 From: Wang Tsu-Han Date: Tue, 6 Mar 2018 15:41:05 +0100 Subject: [PATCH 46/63] fep initialization for less core --- targets/RT/USER/lte-enb.c | 3 ++- targets/RT/USER/lte-ru.c | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index e67e1c88e7..feec812b98 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -187,7 +187,7 @@ static inline int rxtx(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, char *thread_nam { wakeup_tx(eNB,eNB->proc.ru_proc); } - else if(get_nprocs() >= 4) + else if(get_nprocs() > 4) { if(oai_exit) return(-1); phy_procedures_eNB_TX(eNB, proc, no_relay, NULL, 1); @@ -977,6 +977,7 @@ void kill_eNB_proc(int inst) { pthread_mutex_destroy(&eNB->UL_INFO_mutex); int i; for (i=0;i<2;i++) { + pthread_cond_signal( &proc_rxtx[i].cond_rxtx ); LOG_I(PHY, "Joining rxtx[%d] mutex/cond\n",i); pthread_join( proc_rxtx[i].pthread_rxtx, (void**)&status ); LOG_I(PHY, "Destroying rxtx[%d] mutex/cond\n",i); diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index c6de652bc1..3ab9a29a75 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -1156,7 +1156,7 @@ void wakeup_eNBs(RU_t *ru) { LOG_D(PHY,"wakeup_eNBs (num %d) for RU %d\n",ru->num_eNB,ru->idx); - if (get_nprocs() < 4) { + if (get_nprocs() <= 4) { // call eNB function directly char string[20]; @@ -1607,7 +1607,7 @@ static void* ru_thread( void* param ) { if (ru->num_eNB>0) wakeup_eNBs(ru); - if(get_nprocs() <4) + if(get_nprocs() <= 4) { // do TX front-end processing if needed (precoding and/or IDFTs) if (ru->feptx_prec) ru->feptx_prec(ru); @@ -2109,8 +2109,8 @@ void init_RU(char *rf_config_file) { } else if (ru->function == eNodeB_3GPP) { ru->do_prach = 0; // no prach processing in RU - ru->feprx = (get_nprocs()<=4) ? fep_full : ru_fep_full_2thread; // RX DFTs - ru->feptx_ofdm = (get_nprocs()<=4) ? feptx_ofdm : feptx_ofdm_2thread; // this is fep with idft and precoding + ru->feprx = (get_nprocs()> 2 && fepw) ? ru_fep_full_2thread : fep_full; // RX DFTs + ru->feptx_ofdm = (get_nprocs()> 2 && fepw) ? feptx_ofdm_2thread : feptx_ofdm; // this is fep with idft and precoding ru->feptx_prec = feptx_prec; // this is fep with idft and precoding ru->fh_north_in = NULL; // no incoming fronthaul from north ru->fh_north_out = NULL; // no outgoing fronthaul to north From 8d90eda6004b27408a61bfe3220229e3331b8225 Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Wed, 14 Mar 2018 16:21:51 +0100 Subject: [PATCH 47/63] bug fix after merge --- common/config/libconfig/config_libconfig.c | 1 + openair2/ENB_APP/enb_config.c | 4 ++-- targets/RT/USER/lte-enb.c | 21 ++++++++++----------- targets/RT/USER/lte-ru.c | 4 ++-- 4 files changed, 15 insertions(+), 15 deletions(-) diff --git a/common/config/libconfig/config_libconfig.c b/common/config/libconfig/config_libconfig.c index a73a0737f2..cfb0a214cf 100644 --- a/common/config/libconfig/config_libconfig.c +++ b/common/config/libconfig/config_libconfig.c @@ -130,6 +130,7 @@ int config_libconfig_get(paramdef_t *cfgoptions,int numoptions, char *prefix ) { case TYPE_STRING: +printf("call config_lookup_string for '%s' %p\n", cfgpath, &(libconfig_privdata.cfg)); fflush(stdout); if ( config_lookup_string(&(libconfig_privdata.cfg),cfgpath, (const char **)&str)) { if ( cfgoptions[i].numelt > 0 && str != NULL && strlen(str) >= cfgoptions[i].numelt ) { fprintf(stderr,"[LIBCONFIG] %s: %s exceeds maximum length of %i bytes, value truncated\n", diff --git a/openair2/ENB_APP/enb_config.c b/openair2/ENB_APP/enb_config.c index da595a97a6..ab46b55e19 100644 --- a/openair2/ENB_APP/enb_config.c +++ b/openair2/ENB_APP/enb_config.c @@ -210,8 +210,8 @@ void RCconfig_macrlc() { mac_top_init_eNB(); for (j=0;jphy_test = *(MacRLC_ParamList.paramarray[j][MACRLC_PHY_TEST_IDX].iptr); - printf("PHY_TEST = %d,%d\n", RC.mac[j]->phy_test, j); + //RC.mac[j]->phy_test = *(MacRLC_ParamList.paramarray[j][MACRLC_PHY_TEST_IDX].iptr); + //printf("PHY_TEST = %d,%d\n", RC.mac[j]->phy_test, j); if (strcmp(*(MacRLC_ParamList.paramarray[j][MACRLC_TRANSPORT_N_PREFERENCE_IDX].strptr), "local_RRC") == 0) { // check number of instances is same as RRC/PDCP diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index e047e0aed7..ae95e161a8 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -446,6 +446,8 @@ void eNB_top(PHY_VARS_eNB *eNB, int frame_rx, int subframe_rx, char *string,RU_t { eNB_proc_t *proc = &eNB->proc; eNB_rxtx_proc_t *proc_rxtx = &proc->proc_rxtx[0]; + LTE_DL_FRAME_PARMS *fp = &ru->frame_parms; + RU_proc_t *ru_proc=&ru->proc; proc->frame_rx = frame_rx; proc->subframe_rx = subframe_rx; @@ -453,14 +455,16 @@ void eNB_top(PHY_VARS_eNB *eNB, int frame_rx, int subframe_rx, char *string,RU_t if (!oai_exit) { T(T_ENB_MASTER_TICK, T_INT(0), T_INT(proc->frame_rx), T_INT(proc->subframe_rx)); - proc_rxtx->subframe_rx = proc->subframe_rx; - proc_rxtx->frame_rx = proc->frame_rx; - proc_rxtx->subframe_tx = (proc->subframe_rx+sf_ahead)%10; - proc_rxtx->frame_tx = (proc->subframe_rx>(9-sf_ahead)) ? (1+proc->frame_rx)&1023 : proc->frame_rx; - proc->frame_tx = proc_rxtx->frame_tx; - proc_rxtx->timestamp_tx = proc->timestamp_tx; + proc_rxtx->timestamp_tx = ru_proc->timestamp_rx + (sf_ahead*fp->samples_per_tti); + proc_rxtx->frame_rx = ru_proc->frame_rx; + proc_rxtx->subframe_rx = ru_proc->subframe_rx; + proc_rxtx->frame_tx = (proc_rxtx->subframe_rx > (9-sf_ahead)) ? (proc_rxtx->frame_rx+1)&1023 : proc_rxtx->frame_rx; + proc_rxtx->subframe_tx = (proc_rxtx->subframe_rx + sf_ahead)%10; if (rxtx(eNB,proc_rxtx,string) < 0) LOG_E(PHY,"eNB %d CC_id %d failed during execution\n",eNB->Mod_id,eNB->CC_id); + ru_proc->timestamp_tx = proc_rxtx->timestamp_tx; + ru_proc->subframe_tx = proc_rxtx->subframe_tx; + ru_proc->frame_tx = proc_rxtx->frame_tx; } } @@ -511,7 +515,6 @@ int wakeup_tx(PHY_VARS_eNB *eNB,RU_proc_t *ru_proc) { eNB_rxtx_proc_t *proc_rxtx1=&proc->proc_rxtx[1];//*proc_rxtx=&proc->proc_rxtx[proc->frame_rx&1]; eNB_rxtx_proc_t *proc_rxtx0=&proc->proc_rxtx[0]; - LTE_DL_FRAME_PARMS *fp = &eNB->frame_parms; struct timespec wait; wait.tv_sec=0; @@ -1034,12 +1037,9 @@ void kill_eNB_proc(int inst) { kill_td_thread(eNB); kill_te_thread(eNB); LOG_I(PHY, "Killing TX CC_id %d inst %d\n", CC_id, inst ); - proc_rxtx[0].instance_cnt_rxtx = 0; // FIXME data race! - proc_rxtx[1].instance_cnt_rxtx = 0; // FIXME data race! for (i=0; i<2; i++) { pthread_mutex_lock(&proc_rxtx[i].mutex_rxtx); proc_rxtx[i].instance_cnt_rxtx = 0; - pthread_cond_signal( &proc_rxtx[i].cond_rxtx ); pthread_mutex_unlock(&proc_rxtx[i].mutex_rxtx); } proc->instance_cnt_prach = 0; @@ -1064,7 +1064,6 @@ void kill_eNB_proc(int inst) { LOG_I(PHY, "Destroying UL_INFO mutex\n"); pthread_mutex_destroy(&eNB->UL_INFO_mutex); for (i=0;i<2;i++) { - pthread_cond_signal( &proc_rxtx[i].cond_rxtx ); LOG_I(PHY, "Joining rxtx[%d] mutex/cond\n",i); pthread_join( proc_rxtx[i].pthread_rxtx, (void**)&status ); LOG_I(PHY, "Destroying rxtx[%d] mutex/cond\n",i); diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index 3825ec9886..ae07d61ebf 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -777,8 +777,6 @@ void rx_rf(RU_t *ru,int *frame,int *subframe) { if (ru == RC.ru[0]) { VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_RX0_RU, proc->frame_rx ); VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_RX0_RU, proc->subframe_rx ); - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX0_RU, proc->frame_tx ); - VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_TX0_RU, proc->subframe_tx ); } if (proc->first_rx == 0) { @@ -853,6 +851,8 @@ void tx_rf(RU_t *ru) { for (i=0; inb_tx; i++) txp[i] = (void*)&ru->common.txdata[i][(proc->subframe_tx*fp->samples_per_tti)-sf_extension]; + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_TX0_RU, proc->frame_tx ); + VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_SUBFRAME_NUMBER_TX0_RU, proc->subframe_tx ); VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_TRX_TST, (proc->timestamp_tx-ru->openair0_cfg.tx_sample_advance)&0xffffffff ); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_TRX_WRITE, 1 ); From 71a98a977e5eb45a267491a047b4f44e431a20ae Mon Sep 17 00:00:00 2001 From: Wang Tsu-Han Date: Fri, 16 Mar 2018 18:18:55 +0100 Subject: [PATCH 48/63] bug fix for killing thread --- openair1/PHY/LTE_TRANSPORT/dlsch_coding.c | 1 + openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c | 1 + openair1/SCHED/phy_procedures_lte_eNb.c | 4 ++-- targets/RT/USER/lte-enb.c | 2 ++ targets/RT/USER/lte-ru.c | 20 +++++++++++++------- 5 files changed, 19 insertions(+), 9 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c index dd073584f0..4c08c74c34 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c @@ -368,6 +368,7 @@ void *te_thread(void *param) { while (!oai_exit) { if (wait_on_condition(&tep->mutex_te,&tep->cond_te,&tep->instance_cnt_te,"te thread")<0) break; + if(oai_exit) break; dlsch_encoding_2threads0(tep); diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c index b76bfc2d37..b2c6d9986d 100644 --- a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c +++ b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c @@ -428,6 +428,7 @@ void *td_thread(void *param) { while (!oai_exit) { if (wait_on_condition(&proc->mutex_td,&proc->cond_td,&proc->instance_cnt_td,"td thread")<0) break; + if(oai_exit) break; ((td_params*)param)->ret = ulsch_decoding_data_2thread0((td_params*)param); diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index b1927b1bd9..31b327f992 100644 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -1415,8 +1415,8 @@ void kill_te_thread(PHY_VARS_eNB *eNB) { proc->tep[i].instance_cnt_te = 0; pthread_cond_signal(&proc->tep[i].cond_te); pthread_join(proc->tep[i].pthread_te, NULL); - pthread_mutex_init( &proc->tep[i].mutex_te, NULL); - pthread_cond_init( &proc->tep[i].cond_te, NULL); + pthread_mutex_destroy( &proc->tep[i].mutex_te); + pthread_cond_destroy( &proc->tep[i].cond_te); } } diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index ae95e161a8..5d2f79a45b 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -1040,6 +1040,8 @@ void kill_eNB_proc(int inst) { for (i=0; i<2; i++) { pthread_mutex_lock(&proc_rxtx[i].mutex_rxtx); proc_rxtx[i].instance_cnt_rxtx = 0; + proc_rxtx[i].pipe_ready = 0; + pthread_cond_signal( &proc_rxtx[i].cond_rxtx ); pthread_mutex_unlock(&proc_rxtx[i].mutex_rxtx); } proc->instance_cnt_prach = 0; diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index ae07d61ebf..795635ce9d 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -1901,35 +1901,41 @@ void kill_RU_proc(int inst) pthread_mutex_lock(&proc->mutex_FH); proc->instance_cnt_FH = 0; - pthread_mutex_unlock(&proc->mutex_FH); pthread_cond_signal(&proc->cond_FH); + pthread_mutex_unlock(&proc->mutex_FH); + + pthread_mutex_lock(&proc->mutex_FH1); + proc->instance_cnt_FH1 = 0; + pthread_cond_signal(&proc->cond_FH1); + pthread_mutex_unlock(&proc->mutex_FH1); pthread_mutex_lock(&proc->mutex_prach); proc->instance_cnt_prach = 0; - pthread_mutex_unlock(&proc->mutex_prach); pthread_cond_signal(&proc->cond_prach); + pthread_mutex_unlock(&proc->mutex_prach); #ifdef Rel14 pthread_mutex_lock(&proc->mutex_prach_br); proc->instance_cnt_prach_br = 0; - pthread_mutex_unlock(&proc->mutex_prach_br); pthread_cond_signal(&proc->cond_prach_br); + pthread_mutex_unlock(&proc->mutex_prach_br); #endif pthread_mutex_lock(&proc->mutex_synch); proc->instance_cnt_synch = 0; - pthread_mutex_unlock(&proc->mutex_synch); pthread_cond_signal(&proc->cond_synch); + pthread_mutex_unlock(&proc->mutex_synch); pthread_mutex_lock(&proc->mutex_eNBs); + proc->ru_tx_ready = 0; proc->instance_cnt_eNBs = 0; - pthread_mutex_unlock(&proc->mutex_eNBs); pthread_cond_signal(&proc->cond_eNBs); + pthread_mutex_unlock(&proc->mutex_eNBs); pthread_mutex_lock(&proc->mutex_asynch_rxtx); proc->instance_cnt_asynch_rxtx = 0; - pthread_mutex_unlock(&proc->mutex_asynch_rxtx); pthread_cond_signal(&proc->cond_asynch_rxtx); + pthread_mutex_unlock(&proc->mutex_asynch_rxtx); LOG_D(PHY, "Joining pthread_FH\n"); pthread_join(proc->pthread_FH, NULL); @@ -1952,7 +1958,7 @@ void kill_RU_proc(int inst) pthread_join(proc->pthread_asynch_rxtx, NULL); } } - if (get_nprocs() >= 2) { + if (get_nprocs() >= 2 && fepw) { if (ru->feprx) { pthread_mutex_lock(&proc->mutex_fep); proc->instance_cnt_fep = 0; From 846268fdd317ef2ed53f898de5c2b6842ac49b3e Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Tue, 20 Mar 2018 18:02:52 +0100 Subject: [PATCH 49/63] bug fix for qpsk modulation --- openair1/PHY/LTE_TRANSPORT/dci.c | 4 +-- openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c | 29 +++++++++++-------- openair1/SCHED/phy_procedures_lte_eNb.c | 1 + openair2/LAYER2/MAC/eNB_scheduler_bch.c | 1 + targets/RT/USER/lte-enb.c | 4 +-- targets/RT/USER/lte-ru.c | 12 ++++---- 6 files changed, 29 insertions(+), 22 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/dci.c b/openair1/PHY/LTE_TRANSPORT/dci.c index ded49d1c73..16d0e9d100 100755 --- a/openair1/PHY/LTE_TRANSPORT/dci.c +++ b/openair1/PHY/LTE_TRANSPORT/dci.c @@ -2265,7 +2265,7 @@ uint8_t generate_dci_top(uint8_t num_pdcch_symbols, y[0] = &yseq0[0]; y[1] = &yseq1[0]; -#if 1 +#if 0 // reset all bits to , here we set elements as 2 // memset(e, 2, DCI_BITS_MAX); // here we interpret NIL as a random QPSK sequence. That makes power estimation easier. @@ -2276,7 +2276,7 @@ uint8_t generate_dci_top(uint8_t num_pdcch_symbols, /* clear all bits, the above code may generate too much false detections * (not sure about this, to be checked somehow) */ - // memset(e, 0, DCI_BITS_MAX); + memset(e, 0, DCI_BITS_MAX); e_ptr = e; diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c b/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c index 5aec52240b..989d56cf6d 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c @@ -2289,7 +2289,7 @@ int dlsch_modulation(PHY_VARS_eNB* phy_vars_eNB, amp_rho_b = (int16_t)(((int32_t)amp*dlsch1->sqrt_rho_b)>>13); } - if(mod_order0 == 2) + /*if(mod_order0 == 2) { for(i=0;i<2;i++) { @@ -2297,7 +2297,7 @@ int dlsch_modulation(PHY_VARS_eNB* phy_vars_eNB, qpsk_table_b0[i] = (int16_t)(((int32_t)qpsk_table[i]*amp_rho_b)>>15); } } - else if (mod_order0 == 4) + else*/ if (mod_order0 == 4) for (i=0;i<4; i++) { qam16_table_a0[i] = (int16_t)(((int32_t)qam16_table[i]*amp_rho_a)>>15); qam16_table_b0[i] = (int16_t)(((int32_t)qam16_table[i]*amp_rho_b)>>15); @@ -2308,14 +2308,14 @@ int dlsch_modulation(PHY_VARS_eNB* phy_vars_eNB, qam64_table_b0[i] = (int16_t)(((int32_t)qam64_table[i]*amp_rho_b)>>15); } - if (mod_order1 == 2) + /*if (mod_order1 == 2) { for (i=0; i<2; i++) { qpsk_table_a1[i] = (int16_t)(((int32_t)qpsk_table[i]*amp_rho_a)>>15); qpsk_table_b1[i] = (int16_t)(((int32_t)qpsk_table[i]*amp_rho_b)>>15); } } - else if (mod_order1 == 4) + else*/ if (mod_order1 == 4) for (i=0; i<4; i++) { qam16_table_a1[i] = (int16_t)(((int32_t)qam16_table[i]*amp_rho_a)>>15); qam16_table_b1[i] = (int16_t)(((int32_t)qam16_table[i]*amp_rho_b)>>15); @@ -2444,11 +2444,11 @@ int dlsch_modulation(PHY_VARS_eNB* phy_vars_eNB, switch (mod_order0) { case 2: - //qam_table_s0 = NULL; - if (pilots) { + qam_table_s0 = NULL; + /*if (pilots) { qam_table_s0 = qpsk_table_b0; #ifdef NEW_ALLOC_RE - /* TODO: remove this code? */ + // TODO: remove this code? // allocate_REs = (dlsch0->harq_processes[harq_pid]->mimo_mode == SISO) ? allocate_REs_in_RB_pilots_QPSK_siso : allocate_REs_in_RB; @@ -2457,13 +2457,13 @@ int dlsch_modulation(PHY_VARS_eNB* phy_vars_eNB, else { qam_table_s0 = qpsk_table_a0; #ifdef NEW_ALLOC_RE - /* TODO: remove this code? */ + // TODO: remove this code? // allocate_REs = (dlsch0->harq_processes[harq_pid]->mimo_mode == SISO) ? allocate_REs_in_RB_no_pilots_QPSK_siso : allocate_REs_in_RB; #endif - } + }*/ break; case 4: if (pilots) { @@ -2512,12 +2512,17 @@ int dlsch_modulation(PHY_VARS_eNB* phy_vars_eNB, switch (mod_order1) { case 2: - if (pilots) { + qam_table_s1 = NULL; +#ifdef NEW_ALLOC_RE + /* TODO: remove this code? */ + allocate_REs = allocate_REs_in_RB; +#endif + /*if (pilots) { qam_table_s1 = qpsk_table_b1; } else { qam_table_s1 = qpsk_table_a1; - } + }*/ break; case 4: if (pilots) { @@ -2593,7 +2598,7 @@ int dlsch_modulation(PHY_VARS_eNB* phy_vars_eNB, rb); - allocate_REs(phy_vars_eNB, + allocate_REs_in_RB(phy_vars_eNB, txdataF, &jj, &jj2, diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index 31b327f992..b5c8ddf7be 100644 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -551,6 +551,7 @@ void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB, else { // generate pdsch +//printf("%d.%d pdsch_procedures ue rnti %d\n", frame, subframe, dlsch0->rnti);///////////////////////////////////********************** pdsch_procedures(eNB, proc, harq_pid, diff --git a/openair2/LAYER2/MAC/eNB_scheduler_bch.c b/openair2/LAYER2/MAC/eNB_scheduler_bch.c index de4641fac6..f12702fbb8 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_bch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_bch.c @@ -787,6 +787,7 @@ schedule_SI(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP) eNB->eNB_stats[CC_id].bcch_buffer = bcch_sdu_length; eNB->eNB_stats[CC_id].total_bcch_buffer += bcch_sdu_length; eNB->eNB_stats[CC_id].bcch_mcs = mcs; +//printf("SI %d.%d\n", frameP, subframeP);/////////////////////////////////////////****************************** } else { //LOG_D(MAC,"[eNB %d] Frame %d : BCCH not active \n",Mod_id,frame); diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 5d2f79a45b..54c6ddeb30 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -240,7 +240,7 @@ static inline int rxtx(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, char *thread_nam if(get_nprocs() >= 8){ wakeup_tx(eNB,eNB->proc.ru_proc); } - else if(get_nprocs() > 4){ + else if(get_nprocs() >= 4){ phy_procedures_eNB_TX(eNB, proc, no_relay, NULL, 1); wakeup_txfh(proc,eNB->proc.ru_proc); @@ -1041,7 +1041,7 @@ void kill_eNB_proc(int inst) { pthread_mutex_lock(&proc_rxtx[i].mutex_rxtx); proc_rxtx[i].instance_cnt_rxtx = 0; proc_rxtx[i].pipe_ready = 0; - pthread_cond_signal( &proc_rxtx[i].cond_rxtx ); + pthread_cond_signal(&proc_rxtx[i].cond_rxtx); pthread_mutex_unlock(&proc_rxtx[i].mutex_rxtx); } proc->instance_cnt_prach = 0; diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index 795635ce9d..642655804d 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -1181,7 +1181,7 @@ void wakeup_eNBs(RU_t *ru) { LOG_D(PHY,"wakeup_eNBs (num %d) for RU %d ru->eNB_top:%p\n",ru->num_eNB,ru->idx, ru->eNB_top); - if (ru->num_eNB==1 && ru->eNB_top!=0 && get_nprocs() <= 4) { + if (ru->num_eNB==1 && ru->eNB_top!=0 && get_nprocs() < 4) { // call eNB function directly char string[20]; @@ -1645,7 +1645,7 @@ static void* ru_thread( void* param ) { // wakeup all eNB processes waiting for this RU if (ru->num_eNB>0) wakeup_eNBs(ru); - if(get_nprocs() <= 4){ + if(get_nprocs() < 4){ // do TX front-end processing if needed (precoding and/or IDFTs) if (ru->feptx_prec) ru->feptx_prec(ru); @@ -1859,7 +1859,7 @@ void init_RU_proc(RU_t *ru) { if(emulate_rf) pthread_create( &proc->pthread_emulateRF, attr_emulateRF, emulatedRF_thread, (void*)proc ); - if (get_nprocs() > 4) + if (get_nprocs() >= 4) pthread_create( &proc->pthread_FH1, attr_FH1, ru_thread_tx, (void*)ru ); if (ru->function == NGFI_RRU_IF4p5) { @@ -1958,7 +1958,7 @@ void kill_RU_proc(int inst) pthread_join(proc->pthread_asynch_rxtx, NULL); } } - if (get_nprocs() >= 2 && fepw) { + if (get_nprocs() > 2 && fepw) { if (ru->feprx) { pthread_mutex_lock(&proc->mutex_fep); proc->instance_cnt_fep = 0; @@ -2250,8 +2250,8 @@ void set_function_spec_param(RU_t *ru) } else if (ru->function == eNodeB_3GPP) { ru->do_prach = 0; // no prach processing in RU - ru->feprx = (get_nprocs()<=2) ? fep_full : ru_fep_full_2thread; // RX DFTs - ru->feptx_ofdm = (get_nprocs()<=2) ? feptx_ofdm : feptx_ofdm_2thread; // this is fep with idft and precoding + ru->feprx = (get_nprocs()<=2 || !fepw) ? fep_full : ru_fep_full_2thread; // RX DFTs + ru->feptx_ofdm = (get_nprocs()<=2 || !fepw) ? feptx_ofdm : feptx_ofdm_2thread; // this is fep with idft and precoding ru->feptx_prec = feptx_prec; // this is fep with idft and precoding ru->fh_north_in = NULL; // no incoming fronthaul from north ru->fh_north_out = NULL; // no outgoing fronthaul to north From 9fa001c3c5b271401f453911b937fa46cdd8d5f6 Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Thu, 5 Apr 2018 16:33:08 +0200 Subject: [PATCH 50/63] prevent UL_indication from overlapping with tx process which cause the drop --- common/utils/T/T_defs.h | 4 +- common/utils/system.c | 1 + openair1/PHY/LTE_TRANSPORT/dci.c | 5 +- openair1/PHY/LTE_TRANSPORT/dci_tools.c | 1 + openair1/PHY/LTE_TRANSPORT/dlsch_coding.c | 10 ++-- openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c | 4 +- openair1/SCHED/fapi_l1.c | 5 +- openair1/SCHED/phy_procedures_lte_eNb.c | 14 ++++- openair2/LAYER2/MAC/eNB_scheduler_dlsch.c | 4 +- targets/RT/USER/lte-enb.c | 63 ++++++++++----------- targets/RT/USER/lte-ru.c | 17 +++--- 11 files changed, 71 insertions(+), 57 deletions(-) diff --git a/common/utils/T/T_defs.h b/common/utils/T/T_defs.h index 6bdda0edac..d373d91aa5 100644 --- a/common/utils/T/T_defs.h +++ b/common/utils/T/T_defs.h @@ -8,10 +8,10 @@ #define T_MAX_ARGS 16 /* maximum size of a message - increase if needed */ -#define T_BUFFER_MAX (1024*64) +#define T_BUFFER_MAX (10) /*(1024*64)*/ /* size of the local cache for messages (must be pow(2,something)) */ -#define T_CACHE_SIZE (8192 * 2) +#define T_CACHE_SIZE (1) /*(8192 * 2)*/ /* maximum number of bytes a message can contain */ #ifdef T_SEND_TIME diff --git a/common/utils/system.c b/common/utils/system.c index dcec681e2d..104e831910 100644 --- a/common/utils/system.c +++ b/common/utils/system.c @@ -148,6 +148,7 @@ int background_system(char *command) void start_background_system(void) { + return; int p[2]; pid_t son; diff --git a/openair1/PHY/LTE_TRANSPORT/dci.c b/openair1/PHY/LTE_TRANSPORT/dci.c index 16d0e9d100..71cc8130b2 100755 --- a/openair1/PHY/LTE_TRANSPORT/dci.c +++ b/openair1/PHY/LTE_TRANSPORT/dci.c @@ -2265,7 +2265,7 @@ uint8_t generate_dci_top(uint8_t num_pdcch_symbols, y[0] = &yseq0[0]; y[1] = &yseq1[0]; -#if 0 +#if 1 // reset all bits to , here we set elements as 2 // memset(e, 2, DCI_BITS_MAX); // here we interpret NIL as a random QPSK sequence. That makes power estimation easier. @@ -2276,7 +2276,7 @@ uint8_t generate_dci_top(uint8_t num_pdcch_symbols, /* clear all bits, the above code may generate too much false detections * (not sure about this, to be checked somehow) */ - memset(e, 0, DCI_BITS_MAX); + //memset(e, 0, DCI_BITS_MAX); e_ptr = e; @@ -2298,6 +2298,7 @@ uint8_t generate_dci_top(uint8_t num_pdcch_symbols, #endif if (dci_alloc[i].firstCCE>=0) { +//printf("generate DCI .%d rnti %d length %d\n", subframe, dci_alloc[i].rnti, dci_alloc[i].dci_length); e_ptr = generate_dci0(dci_alloc[i].dci_pdu, e+(72*dci_alloc[i].firstCCE), dci_alloc[i].dci_length, diff --git a/openair1/PHY/LTE_TRANSPORT/dci_tools.c b/openair1/PHY/LTE_TRANSPORT/dci_tools.c index 4b73de6fcc..f37e7432c5 100644 --- a/openair1/PHY/LTE_TRANSPORT/dci_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/dci_tools.c @@ -2183,6 +2183,7 @@ void fill_dci_and_dlsch(PHY_VARS_eNB *eNB,int frame,int subframe,eNB_rxtx_proc_t #endif +//printf("DCI %d.%d rnti %d harq %d TBS %d\n", frame, subframe, rel8->rnti, rel8->harq_process, dlsch0_harq->TBS); #if T_TRACER if (dlsch0->active) T(T_ENB_PHY_DLSCH_UE_DCI, T_INT(0), T_INT(frame), T_INT(subframe), diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c index 4c08c74c34..49db69cff4 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_coding.c @@ -646,9 +646,9 @@ int dlsch_encoding_all(PHY_VARS_eNB *eNB, } } - if(C >= 8 && get_nprocs()>8 && codingw)//one main three worker - { - encoding_return = + if(C >= 8 && get_nprocs()>=16 && codingw)//one main three worker + { + encoding_return = dlsch_encoding_2threads(eNB, a, num_pdcch_symbols, @@ -663,8 +663,8 @@ int dlsch_encoding_all(PHY_VARS_eNB *eNB, te_wakeup_stats1, i_stats, 3); - } - else if(C >= 6 && get_nprocs()>=6 && codingw)//one main two worker + } + else if(C >= 6 && get_nprocs()>=8 && codingw)//one main two worker { encoding_return = dlsch_encoding_2threads(eNB, diff --git a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c index b2c6d9986d..2f4cfd2344 100644 --- a/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c +++ b/openair1/PHY/LTE_TRANSPORT/ulsch_decoding.c @@ -794,11 +794,11 @@ int ulsch_decoding_data(PHY_VARS_eNB *eNB,int UE_id,int harq_pid,int llr8_flag) int ulsch_decoding_data_all(PHY_VARS_eNB *eNB,int UE_id,int harq_pid,int llr8_flag) { int ret = 0; - if(codingw) + /*if(codingw) { ret = ulsch_decoding_data_2thread(eNB,UE_id,harq_pid,llr8_flag); } - else + else*/ { ret = ulsch_decoding_data(eNB,UE_id,harq_pid,llr8_flag); } diff --git a/openair1/SCHED/fapi_l1.c b/openair1/SCHED/fapi_l1.c index df01fad136..e8a767e0f5 100644 --- a/openair1/SCHED/fapi_l1.c +++ b/openair1/SCHED/fapi_l1.c @@ -201,8 +201,9 @@ void handle_nfapi_dlsch_pdu(PHY_VARS_eNB *eNB,int frame,int subframe,eNB_rxtx_pr dlsch0_harq->pdsch_start = eNB->pdcch_vars[subframe & 1].num_pdcch_symbols; if (dlsch0_harq->round==0) { //get pointer to SDU if this a new SDU - AssertFatal(sdu!=NULL,"NFAPI: SFN/SF:%04d%d proc:TX:[frame %d subframe %d]: programming dlsch for round 0, rnti %x, UE_id %d, harq_pid %d : sdu is null for pdu_index %d dlsch0_harq[round:%d SFN/SF:%d%d pdu:%p mcs:%d ndi:%d pdschstart:%d]\n", - frame,subframe, +//if (sdu==NULL) printf("dlsch0_harq %p harq %d\n", dlsch0_harq, harq_pid); + AssertFatal(sdu!=NULL,"sdu==%d, NFAPI: SFN/SF:%04d%d proc:TX:[frame %d subframe %d]: programming dlsch for round 0, rnti %x, UE_id %d, harq_pid %d : sdu is null for pdu_index %d dlsch0_harq[round:%d SFN/SF:%d%d pdu:%p mcs:%d ndi:%d pdschstart:%d]\n", + *sdu,frame,subframe, proc->frame_tx,proc->subframe_tx,rel8->rnti,UE_id,harq_pid, dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index,dlsch0_harq->round,dlsch0_harq->frame,dlsch0_harq->subframe,dlsch0_harq->pdu,dlsch0_harq->mcs,dlsch0_harq->ndi,dlsch0_harq->pdsch_start); if (rel8->rnti != 0xFFFF) LOG_D(PHY,"NFAPI: SFN/SF:%04d%d proc:TX:[frame %d, subframe %d]: programming dlsch for round 0, rnti %x, UE_id %d, harq_pid %d\n", diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index b5c8ddf7be..cc855c6e12 100644 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -359,6 +359,11 @@ void pdsch_procedures(PHY_VARS_eNB *eNB, &eNB->dlsch_turbo_encoding_wakeup_stats1, &eNB->dlsch_interleaving_stats); stop_meas(&eNB->dlsch_encoding_stats); + //////////////////////////////////////////////////******************************************* + if(eNB->dlsch_encoding_stats.diff_now>500*3000 && opp_enabled == 1) + { + print_meas_now(&eNB->dlsch_encoding_stats,"total coding",stderr); + } // 36-211 start_meas(&eNB->dlsch_scrambling_stats); dlsch_scrambling(fp, @@ -394,6 +399,7 @@ void pdsch_procedures(PHY_VARS_eNB *eNB, dlsch->active = 0; dlsch_harq->round++; +//printf(" dlsch_harq ++ %p %d.%d harq %d rnti %d\n", dlsch_harq, frame, subframe, harq_pid, dlsch->rnti); LOG_D(PHY,"Generating DLSCH/PDSCH dlsch_harq[round:%d]\n",dlsch_harq->round); } @@ -513,7 +519,7 @@ void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB, //LOG_D(PHY,"Before generate_dci_top num_pdcch_symbols:%d num_dci:%d dci_alloc:dci_length:%d\n", num_pdcch_symbols, num_dci, eNB->pdcch_vars[subframe&1].dci_alloc[0].dci_length); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_PDCCH_TX,1); - +//printf("//////////************before generate_dci_top UL %d.%d TX %d.%d \n", ul_frame, ul_subframe, frame, subframe); if (nfapi_mode == 0 || nfapi_mode == 1) { generate_dci_top(num_pdcch_symbols, num_dci, @@ -1641,6 +1647,9 @@ void fill_ulsch_harq_indication(PHY_VARS_eNB *eNB,LTE_UL_eNB_HARQ_t *ulsch_harq, // release DLSCH if needed if (ulsch_harq->o_ACK[i] == 1) release_harq(eNB,UE_id,i,frame,subframe,0xffff); +//if (ulsch_harq->o_ACK[i] != 1) +//printf("got NACK %d.%d rnti %d harq %d\n", frame, subframe, rnti, eNB->dlsch[UE_id][0]->harq_ids[(subframe+6)%10]); + #if T_TRACER /* TODO: get correct harq pid */ if (ulsch_harq->o_ACK[i] != 1) @@ -1735,6 +1744,9 @@ void fill_uci_harq_indication(PHY_VARS_eNB *eNB, // release DLSCH if needed if (harq_ack[0] == 1) release_harq(eNB,UE_id,0,frame,subframe,0xffff); +//if (harq_ack[0] != 1) +//printf("got NACK %d.%d rnti %d harq %d\n", frame, subframe, uci->rnti, eNB->dlsch[UE_id][0]->harq_ids[(subframe+6)%10]); + #if T_TRACER if (harq_ack[0] != 1) T(T_ENB_PHY_DLSCH_UE_NACK, T_INT(0), T_INT(frame), T_INT(subframe), diff --git a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c index 0729073eba..fecd1cab5d 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c @@ -928,7 +928,7 @@ schedule_ue_spec(module_id_t module_idP,slice_id_t slice_idP, eNB->DL_req[CC_id].sfn_sf = frameP<<4 | subframeP; eNB->DL_req[CC_id].header.message_id = NFAPI_DL_CONFIG_REQUEST; - +//printf("doing retransmission for fill_nfapi_dlsch_config frame %d subframe %d rnti = %d harq_pid = %d\n", frameP, subframeP, rnti, harq_pid); fill_nfapi_dlsch_config(eNB, dl_req, TBS, -1 /* retransmission, no pdu_index */ , rnti, 0, // type 0 allocation from 7.1.6 in 36.213 @@ -1455,7 +1455,7 @@ schedule_ue_spec(module_id_t module_idP,slice_id_t slice_idP, "physicalConfigDedicated is NULL\n"); AssertFatal(UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->pdsch_ConfigDedicated != NULL, "physicalConfigDedicated->pdsch_ConfigDedicated is NULL\n"); - +//printf("mac DL transmition with frame = %d, subframe = %d, rnti = %d, pdu_index = %p\n", frameP, subframeP, rnti, eNB->pdu_index); fill_nfapi_dlsch_config(eNB, dl_req, TBS, eNB->pdu_index[CC_id], rnti, 0, // type 0 allocation from 7.1.6 in 36.213 0, // virtual_resource_block_assignment_flag, unused here 0, // resource_block_coding, to be filled in later diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 54c6ddeb30..3a526a7380 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -224,6 +224,12 @@ static inline int rxtx(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, char *thread_nam } VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER , 1 ); + if(wait_on_condition(&proc[1].mutex_rxtx,&proc[1].cond_rxtx,&proc[1].pipe_ready,"wakeup_tx")<0) { + LOG_E(PHY,"Frame %d, subframe %d: TX1 not ready\n",proc[1].frame_rx,proc[1].subframe_rx); + return(-1); + } + if (release_thread(&proc[1].mutex_rxtx,&proc[1].pipe_ready,"wakeup_tx")<0) return(-1); + pthread_mutex_lock(&eNB->UL_INFO_mutex); eNB->UL_INFO.frame = proc->frame_rx; @@ -237,17 +243,7 @@ static inline int rxtx(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, char *thread_nam VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER , 0 ); if(oai_exit) return(-1); - if(get_nprocs() >= 8){ - wakeup_tx(eNB,eNB->proc.ru_proc); - } - else if(get_nprocs() >= 4){ - - phy_procedures_eNB_TX(eNB, proc, no_relay, NULL, 1); - wakeup_txfh(proc,eNB->proc.ru_proc); - } - else{ - phy_procedures_eNB_TX(eNB, proc, no_relay, NULL, 1); - } + if(get_nprocs() <= 4) phy_procedures_eNB_TX(eNB, proc, no_relay, NULL, 1); stop_meas( &softmodem_stats_rxtx_sf ); @@ -314,14 +310,6 @@ static void* tx_thread(void* param) { while (!oai_exit) { - pthread_mutex_lock( &proc->mutex_rxtx ); - proc->pipe_ready++; - // the thread can now be woken up - if (pthread_cond_signal(&proc->cond_rxtx) != 0) { - LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB TXnp4 thread\n"); - exit_fun( "ERROR pthread_cond_signal" ); - } - pthread_mutex_unlock( &proc->mutex_rxtx ); if (wait_on_condition(&proc->mutex_rxtx,&proc->cond_rxtx,&proc->instance_cnt_rxtx,thread_name)<0) break; if (oai_exit) break; @@ -336,8 +324,16 @@ static void* tx_thread(void* param) { VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME(VCD_SIGNAL_DUMPER_VARIABLES_FRAME_NUMBER_RX1_ENB,proc->frame_rx); phy_procedures_eNB_TX(eNB, proc, no_relay, NULL, 1); - if (release_thread(&proc->mutex_rxtx,&proc->instance_cnt_rxtx,thread_name)<0) break; + if (release_thread(&proc->mutex_rxtx,&proc->instance_cnt_rxtx,thread_name)<0) break; + pthread_mutex_lock( &proc->mutex_rxtx ); + proc->pipe_ready++; + // the thread can now be woken up + if (pthread_cond_signal(&proc->cond_rxtx) != 0) { + LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB TXnp4 thread\n"); + exit_fun( "ERROR pthread_cond_signal" ); + } + pthread_mutex_unlock( &proc->mutex_rxtx ); wakeup_txfh(proc,eNB_proc->ru_proc); } @@ -376,14 +372,6 @@ static void* eNB_thread_rxtx( void* param ) { while (!oai_exit) { - pthread_mutex_lock( &proc->mutex_rxtx ); - proc->pipe_ready++; - // the thread can now be woken up - if (pthread_cond_signal(&proc->cond_rxtx) != 0) { - LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB TXnp4 thread\n"); - exit_fun( "ERROR pthread_cond_signal" ); - } - pthread_mutex_unlock( &proc->mutex_rxtx ); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_eNB_PROC_RXTX0+(proc->subframe_rx&1), 0 ); T(T_ENB_MASTER_TICK, T_INT(0), T_INT(proc->frame_rx), T_INT(proc->subframe_rx)); @@ -407,6 +395,20 @@ static void* eNB_thread_rxtx( void* param ) { } if (release_thread(&proc->mutex_rxtx,&proc->instance_cnt_rxtx,thread_name)<0) break; + pthread_mutex_lock( &proc->mutex_rxtx ); + proc->pipe_ready++; + // the thread can now be woken up + if (pthread_cond_signal(&proc->cond_rxtx) != 0) { + LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB TXnp4 thread\n"); + exit_fun( "ERROR pthread_cond_signal" ); + } + pthread_mutex_unlock( &proc->mutex_rxtx ); + if(get_nprocs() >= 8) wakeup_tx(eNB,eNB->proc.ru_proc); + else if(get_nprocs() > 4) + { + phy_procedures_eNB_TX(eNB, proc, no_relay, NULL, 1); + wakeup_txfh(proc,eNB->proc.ru_proc); + } } // while !oai_exit @@ -521,11 +523,6 @@ int wakeup_tx(PHY_VARS_eNB *eNB,RU_proc_t *ru_proc) { wait.tv_nsec=5000000L; - if(wait_on_condition(&proc_rxtx1->mutex_rxtx,&proc_rxtx1->cond_rxtx,&proc_rxtx1->pipe_ready,"wakeup_tx")<0) { - LOG_E(PHY,"Frame %d, subframe %d: TX1 not ready\n",proc_rxtx1->frame_rx,proc_rxtx1->subframe_rx); - return(-1); - } - if (release_thread(&proc_rxtx1->mutex_rxtx,&proc_rxtx1->pipe_ready,"wakeup_tx")<0) return(-1); if (proc_rxtx1->instance_cnt_rxtx == 0) { LOG_E(PHY,"Frame %d, subframe %d: TX1 thread busy, dropping\n",proc_rxtx1->frame_rx,proc_rxtx1->subframe_rx); diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index 642655804d..ca2304e8bb 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -1181,7 +1181,7 @@ void wakeup_eNBs(RU_t *ru) { LOG_D(PHY,"wakeup_eNBs (num %d) for RU %d ru->eNB_top:%p\n",ru->num_eNB,ru->idx, ru->eNB_top); - if (ru->num_eNB==1 && ru->eNB_top!=0 && get_nprocs() < 4) { + if (ru->num_eNB==1 && ru->eNB_top!=0 && get_nprocs() <= 4) { // call eNB function directly char string[20]; @@ -1556,9 +1556,13 @@ static void* ru_thread( void* param ) { pthread_cond_signal(&RC.ru_cond); pthread_mutex_unlock(&RC.ru_mutex); - wait_sync("ru_thread"); + pthread_mutex_lock(&proc->mutex_FH1); + proc->instance_cnt_FH1 = 0; + pthread_mutex_unlock(&proc->mutex_FH1); + pthread_cond_signal(&proc->cond_FH1); + wait_sync("ru_thread"); if(!emulate_rf){ // Start RF device if any @@ -1584,10 +1588,7 @@ static void* ru_thread( void* param ) { if ((ru->is_slave) && (ru->if_south == LOCAL_RF)) do_ru_synch(ru); } - pthread_mutex_lock(&proc->mutex_FH1); - proc->instance_cnt_FH1 = 0; - pthread_mutex_unlock(&proc->mutex_FH1); - pthread_cond_signal(&proc->cond_FH1); + // This is a forever while loop, it loops over subframes which are scheduled by incoming samples from HW devices @@ -1645,7 +1646,7 @@ static void* ru_thread( void* param ) { // wakeup all eNB processes waiting for this RU if (ru->num_eNB>0) wakeup_eNBs(ru); - if(get_nprocs() < 4){ + if(get_nprocs() <= 4){ // do TX front-end processing if needed (precoding and/or IDFTs) if (ru->feptx_prec) ru->feptx_prec(ru); @@ -1859,7 +1860,7 @@ void init_RU_proc(RU_t *ru) { if(emulate_rf) pthread_create( &proc->pthread_emulateRF, attr_emulateRF, emulatedRF_thread, (void*)proc ); - if (get_nprocs() >= 4) + if (get_nprocs() > 4) pthread_create( &proc->pthread_FH1, attr_FH1, ru_thread_tx, (void*)ru ); if (ru->function == NGFI_RRU_IF4p5) { From 0f5470b9133e64c36727617aaf4c5e0b8cff1391 Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Thu, 5 Apr 2018 11:11:58 -0700 Subject: [PATCH 51/63] removal of logging in UE --- openair1/PHY/LTE_TRANSPORT/dci_tools.c | 7 ++-- .../PHY/LTE_TRANSPORT/dlsch_demodulation.c | 6 ++-- openair1/PHY/LTE_TRANSPORT/if4_tools.c | 2 +- openair1/SCHED/phy_procedures_lte_ue.c | 4 +-- targets/RT/USER/lte-ru.c | 2 +- targets/SIMU/USER/channel_sim.c | 16 +++++---- targets/SIMU/USER/oaisim.c | 15 +++----- targets/SIMU/USER/oaisim_functions.c | 36 +++++++++---------- 8 files changed, 43 insertions(+), 45 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/dci_tools.c b/openair1/PHY/LTE_TRANSPORT/dci_tools.c index 4b73de6fcc..4493ae51ae 100644 --- a/openair1/PHY/LTE_TRANSPORT/dci_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/dci_tools.c @@ -5027,7 +5027,7 @@ void compute_llr_offset(LTE_DL_FRAME_PARMS *frame_parms, pdsch_vars->llr_offset[pdcch_vars->num_pdcch_symbols] = 0; - LOG_I(PHY,"compute_llr_offset: nb RB %d - Qm %d \n", nb_rb_alloc, dlsch0_harq->Qm); + // LOG_I(PHY,"compute_llr_offset: nb RB %d - Qm %d \n", nb_rb_alloc, dlsch0_harq->Qm); //dlsch0_harq->rb_alloc_even; //dlsch0_harq->rb_alloc_odd; @@ -5056,16 +5056,17 @@ void compute_llr_offset(LTE_DL_FRAME_PARMS *frame_parms, pdsch_vars->llr_length[symbol] = data_re; if(symbol < (frame_parms->symbols_per_tti-1)) pdsch_vars->llr_offset[symbol+1] = pdsch_vars->llr_offset[symbol] + llr_offset; - + /* LOG_I(PHY,"Granted Re subframe %d / symbol %d => %d (%d RBs)\n", subframe, symbol_mod, granted_re,dlsch0_harq->nb_rb); LOG_I(PHY,"Pbch/PSS/SSS Re subframe %d / symbol %d => %d \n", subframe, symbol_mod, pbch_pss_sss_re); LOG_I(PHY,"CRS Re Per PRB subframe %d / symbol %d => %d \n", subframe, symbol_mod, crs_re); LOG_I(PHY,"Data Re subframe %d / symbol %d => %d \n", subframe, symbol_mod, data_re); - + LOG_I(PHY,"Data Re subframe %d-symbol %d => llr length %d, llr offset %d \n", subframe, symbol, pdsch_vars->llr_length[symbol], pdsch_vars->llr_offset[symbol]); + */ } } void prepare_dl_decoding_format1_1A(DCI_format_t dci_format, diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_demodulation.c b/openair1/PHY/LTE_TRANSPORT/dlsch_demodulation.c index 6284f279d8..a104633a64 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_demodulation.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_demodulation.c @@ -48,7 +48,7 @@ int16_t interf_unaw_shift = 13; //#define DEBUG_HARQ -#define DEBUG_PHY 1 +//#define DEBUG_PHY 1 //#define DEBUG_DLSCH_DEMOD 1 //#define DISABLE_LOG_X @@ -842,7 +842,7 @@ int rx_pdsch(PHY_VARS_UE *ue, pllr_symbol_cw1 = (int8_t*)pdsch_vars[eNB_id]->llr[1]; pllr_symbol_cw0 += llr_offset_symbol; pllr_symbol_cw1 += llr_offset_symbol; - + /* LOG_I(PHY,"compute LLRs [AbsSubframe %d.%d-%d] NbRB %d Qm %d LLRs-Length %d LLR-Offset %d @LLR Buff %p @LLR Buff(symb) %p\n", frame, subframe,symbol, nb_rb,dlsch0_harq->Qm, @@ -850,7 +850,7 @@ int rx_pdsch(PHY_VARS_UE *ue, pdsch_vars[eNB_id]->llr_offset[symbol], (int16_t*)pdsch_vars[eNB_id]->llr[0], pllr_symbol_cw0); - + */ switch (dlsch0_harq->Qm) { case 2 : if ((rx_type==rx_standard) || (codeword_TB1 == -1)) { diff --git a/openair1/PHY/LTE_TRANSPORT/if4_tools.c b/openair1/PHY/LTE_TRANSPORT/if4_tools.c index 88312e4a46..2f65686d12 100644 --- a/openair1/PHY/LTE_TRANSPORT/if4_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/if4_tools.c @@ -381,7 +381,7 @@ void recv_IF4p5(RU_t *ru, int *frame, int *subframe, uint16_t *packet_type, uint PRACH_BLOCK_SIZE_BYTES); } - LOG_D(PHY,"PRACH_IF4p5: CC_id %d : frame %d, subframe %d => %d dB\n",ru->idx,*frame,*subframe, + LOG_I(PHY,"PRACH_IF4p5: CC_id %d : frame %d, subframe %d => %d dB\n",ru->idx,*frame,*subframe, dB_fixed(signal_energy((int*)&prach_rxsigF[0][0],839))); for (idx=0;idxnum_eNB;idx++) ru->wakeup_prach_eNB(ru->eNB_list[idx],ru,*frame,*subframe); diff --git a/openair1/SCHED/phy_procedures_lte_ue.c b/openair1/SCHED/phy_procedures_lte_ue.c index 2635649589..151a74f620 100644 --- a/openair1/SCHED/phy_procedures_lte_ue.c +++ b/openair1/SCHED/phy_procedures_lte_ue.c @@ -41,7 +41,7 @@ #include #include "targets/RT/USER/lte-softmodem.h" -#define DEBUG_PHY_PROC +//#define DEBUG_PHY_PROC #ifndef PUCCH #define PUCCH @@ -81,7 +81,7 @@ extern uint32_t downlink_frequency[MAX_NUM_CCs][4]; #endif -#define UE_DEBUG_TRACE 1 +//#define UE_DEBUG_TRACE 1 void dump_dlsch(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uint8_t subframe,uint8_t harq_pid) { diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index d9bda6a037..11f65d8be8 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -1185,7 +1185,7 @@ static inline int wakeup_prach_ru(RU_t *ru) { ru->eNB_list[0]->proc.frame_prach = ru->proc.frame_rx; ru->eNB_list[0]->proc.subframe_prach = ru->proc.subframe_rx; } - LOG_I(PHY,"RU %d: waking up PRACH thread\n",ru->idx); + LOG_D(PHY,"RU %d: waking up PRACH thread\n",ru->idx); // the thread can now be woken up AssertFatal(pthread_cond_signal(&ru->proc.cond_prach) == 0, "ERROR pthread_cond_signal for RU prach thread\n"); } diff --git a/targets/SIMU/USER/channel_sim.c b/targets/SIMU/USER/channel_sim.c index 94bd1bbe43..553d480782 100644 --- a/targets/SIMU/USER/channel_sim.c +++ b/targets/SIMU/USER/channel_sim.c @@ -60,7 +60,11 @@ #include "oaisim.h" #define RF -//#define DEBUG_SIM +#define DEBUG_SIM +/* +#undef LOG_D +#define LOG_D(A,B,C...) printf(B,C) +*/ int number_rb_ul; int first_rbUL ; @@ -232,7 +236,6 @@ void do_DL_sig(channel_desc_t *RU2UE[NUMBER_OF_RU_MAX][NUMBER_OF_UE_MAX][MAX_NUM pthread_mutex_lock(&RU_output_mutex[UE_id]); if (RU_output_mask[UE_id] == 0) { // This is the first eNodeB for this UE, clear the buffer - for (aa=0; aaframe_parms.samples_per_tti)*sizeof(double)); memset((void*)r_im_DL[UE_id][aa],0,(RC.ru[0]->frame_parms.samples_per_tti)*sizeof(double)); @@ -375,7 +378,8 @@ void do_DL_sig(channel_desc_t *RU2UE[NUMBER_OF_RU_MAX][NUMBER_OF_UE_MAX][MAX_NUM UE_id,ru_id, 10*log10(rx_pwr),subframe); #endif - + + pthread_mutex_lock(&RU_output_mutex[UE_id]); for (i=0; isamples_per_tti; i++) { for (aa=0; aaN_RB_DL); LOG_D(OCM,"[SIM][DL] UE %d : ADC in %f dBm/RE for subframe %d\n",UE_id,10*log10(rx_pwr),subframe); #endif - + rxdata = PHY_vars_UE_g[UE_id][CC_id]->common_vars.rxdata; sf_offset = (subframe*frame_parms->samples_per_tti)+offset; diff --git a/targets/SIMU/USER/oaisim.c b/targets/SIMU/USER/oaisim.c index 0008ba3bbd..cd3bc1794e 100644 --- a/targets/SIMU/USER/oaisim.c +++ b/targets/SIMU/USER/oaisim.c @@ -737,19 +737,16 @@ l2l1_task (void *args_p) CC_id=0; int all_done=0; - while (all_done==0) { pthread_mutex_lock(&subframe_mutex); - int subframe_ru_mask_local = subframe_ru_mask; - int subframe_UE_mask_local = subframe_UE_mask; + int subframe_ru_mask_local = (subframe_select(&RC.ru[0]->frame_parms,(sf+4)%10)!=SF_UL) ? subframe_ru_mask : ((1<frame_parms,(sf+4)%10)!=SF_DL) ? subframe_UE_mask : ((1<frame_parms.samples_per_tti)%10; - LOG_D(EMU,"RU_trx_read generating UL subframe %d (Ts %llu, current TS %llu)\n", - subframe,(unsigned long long)*ptimestamp, - (unsigned long long)current_ru_rx_timestamp[ru_id][CC_id]); - - do_UL_sig(UE2RU, - enb_data, - ue_data, - subframe, - 0, // abstraction_flag - &RC.ru[ru_id]->frame_parms, - 0, // frame is only used for abstraction - ru_id, - CC_id); - + if (subframe_select(&RC.ru[ru_id]->frame_parms,subframe) != SF_DL) { + LOG_D(EMU,"RU_trx_read generating UL subframe %d (Ts %llu, current TS %llu)\n", + subframe,(unsigned long long)*ptimestamp, + (unsigned long long)current_ru_rx_timestamp[ru_id][CC_id]); + + do_UL_sig(UE2RU, + enb_data, + ue_data, + subframe, + 0, // abstraction_flag + &RC.ru[ru_id]->frame_parms, + 0, // frame is only used for abstraction + ru_id, + CC_id); + } last_ru_rx_timestamp[ru_id][CC_id] += RC.ru[ru_id]->frame_parms.samples_per_tti; sample_count += RC.ru[ru_id]->frame_parms.samples_per_tti; } @@ -1352,9 +1353,6 @@ void init_devices(void){ PHY_vars_UE_g[UE_id][CC_id]->rfdevice.trx_set_freq_func = UE_trx_set_freq; PHY_vars_UE_g[UE_id][CC_id]->rfdevice.trx_set_gains_func = UE_trx_set_gains; last_UE_rx_timestamp[UE_id][CC_id] = 0; - - - } } } @@ -1529,11 +1527,11 @@ void update_ocm() //LOG_D(OMG," extracting position of eNb...\n"); //display_node_list(enb_node_list); // display_node_list(ue_node_list); - extract_position(enb_node_list, enb_data, RC.nb_RU); + //extract_position(enb_node_list, enb_data, RC.nb_RU); //extract_position_fixed_enb(enb_data, NB_eNB_INST,frame); //LOG_D(OMG," extracting position of UE...\n"); // if (oai_emulation.info.omg_model_ue == TRACE) - extract_position(ue_node_list, ue_data, NB_UE_INST); + //extract_position(ue_node_list, ue_data, NB_UE_INST); /* if (frame % 50 == 0) LOG_N(OCM,"Path loss for TTI %d : \n", frame); From 3d8a21636a55f5738d81736347572db863aa0155 Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Thu, 5 Apr 2018 22:32:18 +0200 Subject: [PATCH 52/63] multi-ue checks in pdcp --- openair1/PHY/LTE_TRANSPORT/if4_tools.c | 2 +- openair2/LAYER2/PDCP_v10.1.0/pdcp.c | 6 ++++-- targets/SIMU/USER/oaisim_functions.c | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/if4_tools.c b/openair1/PHY/LTE_TRANSPORT/if4_tools.c index 2f65686d12..88312e4a46 100644 --- a/openair1/PHY/LTE_TRANSPORT/if4_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/if4_tools.c @@ -381,7 +381,7 @@ void recv_IF4p5(RU_t *ru, int *frame, int *subframe, uint16_t *packet_type, uint PRACH_BLOCK_SIZE_BYTES); } - LOG_I(PHY,"PRACH_IF4p5: CC_id %d : frame %d, subframe %d => %d dB\n",ru->idx,*frame,*subframe, + LOG_D(PHY,"PRACH_IF4p5: CC_id %d : frame %d, subframe %d => %d dB\n",ru->idx,*frame,*subframe, dB_fixed(signal_energy((int*)&prach_rxsigF[0][0],839))); for (idx=0;idxnum_eNB;idx++) ru->wakeup_prach_eNB(ru->eNB_list[idx],ru,*frame,*subframe); diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c index 00557ce7e0..bd95808bc3 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp.c @@ -859,7 +859,8 @@ void pdcp_update_stats(const protocol_ctxt_t* const ctxt_pP){ for (pdcp_uid=0; pdcp_uid< NUMBER_OF_UE_MAX;pdcp_uid++){ //printf("frame %d and subframe %d \n", pdcp_enb[ctxt_pP->module_id].frame, pdcp_enb[ctxt_pP->module_id].subframe); // tx stats - if (pdcp_enb[ctxt_pP->module_id].sfn % Pdcp_stats_tx_window_ms[ctxt_pP->module_id][pdcp_uid] == 0){ + if (Pdcp_stats_tx_window_ms[ctxt_pP->module_id][pdcp_uid] > 0 && + pdcp_enb[ctxt_pP->module_id].sfn % Pdcp_stats_tx_window_ms[ctxt_pP->module_id][pdcp_uid] == 0){ // unit: bit/s Pdcp_stats_tx_throughput_w[ctxt_pP->module_id][pdcp_uid][rb_id]=Pdcp_stats_tx_bytes_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id]*8; Pdcp_stats_tx_w[ctxt_pP->module_id][pdcp_uid][rb_id]= Pdcp_stats_tx_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id]; @@ -875,7 +876,8 @@ void pdcp_update_stats(const protocol_ctxt_t* const ctxt_pP){ Pdcp_stats_tx_aiat_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id]=0; } - if (pdcp_enb[ctxt_pP->module_id].sfn % Pdcp_stats_rx_window_ms[ctxt_pP->module_id][pdcp_uid] == 0){ + if (Pdcp_stats_rx_window_ms[ctxt_pP->module_id][pdcp_uid] > 0 && + pdcp_enb[ctxt_pP->module_id].sfn % Pdcp_stats_rx_window_ms[ctxt_pP->module_id][pdcp_uid] == 0){ // rx stats Pdcp_stats_rx_goodput_w[ctxt_pP->module_id][pdcp_uid][rb_id]=Pdcp_stats_rx_bytes_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id]*8; Pdcp_stats_rx_w[ctxt_pP->module_id][pdcp_uid][rb_id]= Pdcp_stats_rx_tmp_w[ctxt_pP->module_id][pdcp_uid][rb_id]; diff --git a/targets/SIMU/USER/oaisim_functions.c b/targets/SIMU/USER/oaisim_functions.c index 070ea58e1d..5900170480 100644 --- a/targets/SIMU/USER/oaisim_functions.c +++ b/targets/SIMU/USER/oaisim_functions.c @@ -1087,7 +1087,7 @@ int ru_trx_read(openair0_device *device, openair0_timestamp *ptimestamp, void ** subframe = (last_ru_rx_timestamp[ru_id][CC_id]/RC.ru[ru_id]->frame_parms.samples_per_tti)%10; - if (subframe_select(&RC.ru[ru_id]->frame_parms,subframe) != SF_DL) { + if (subframe_select(&RC.ru[ru_id]->frame_parms,subframe) != SF_DL || RC.ru[ru_id]->frame_parms.frame_type == FDD) { LOG_D(EMU,"RU_trx_read generating UL subframe %d (Ts %llu, current TS %llu)\n", subframe,(unsigned long long)*ptimestamp, (unsigned long long)current_ru_rx_timestamp[ru_id][CC_id]); From fb4752a2cf5c6d3e8081502c0a89e0e0275cf2c0 Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Fri, 6 Apr 2018 00:07:23 +0200 Subject: [PATCH 53/63] default RF configuration --- .../GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.50PRB.lo.conf | 2 +- targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.oaisim.conf | 2 +- targets/SIMU/USER/oaisim.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.50PRB.lo.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.50PRB.lo.conf index aacc87e5b0..72ee47b9d6 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.50PRB.lo.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.50PRB.lo.conf @@ -76,7 +76,7 @@ eNBs = pusch_p0_Nominal = -96; pusch_alpha = "AL1"; - pucch_p0_Nominal = -104; + pucch_p0_Nominal = -100; msg3_delta_Preamble = 6; pucch_deltaF_Format1 = "deltaF2"; pucch_deltaF_Format1b = "deltaF3"; diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.oaisim.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.oaisim.conf index 24ae36a0a4..8a0f5feb58 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.oaisim.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rru.oaisim.conf @@ -11,7 +11,7 @@ RUs = ( tr_preference = "udp_if4p5"; nb_tx = 1; nb_rx = 1; - max_pdschReferenceSignalPower = -29; + max_pdschReferenceSignalPower = -15; max_rxgain = 120; bands = [7,13]; } diff --git a/targets/SIMU/USER/oaisim.c b/targets/SIMU/USER/oaisim.c index cd3bc1794e..65b0b8a3e4 100644 --- a/targets/SIMU/USER/oaisim.c +++ b/targets/SIMU/USER/oaisim.c @@ -741,7 +741,7 @@ l2l1_task (void *args_p) pthread_mutex_lock(&subframe_mutex); int subframe_ru_mask_local = (subframe_select(&RC.ru[0]->frame_parms,(sf+4)%10)!=SF_UL) ? subframe_ru_mask : ((1<frame_parms,(sf+4)%10)!=SF_DL) ? subframe_UE_mask : ((1<frame_parms.frame_type == FDD || subframe_select(&RC.ru[0]->frame_parms,(sf+4)%10)!=SF_DL) ? subframe_UE_mask : ((1< Date: Fri, 6 Apr 2018 15:57:23 +0200 Subject: [PATCH 54/63] warning remove --- common/utils/T/T_defs.h | 4 ++-- common/utils/system.c | 1 - openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c | 4 ++-- openair1/SCHED/fapi_l1.c | 1 - openair1/SCHED/phy_procedures_lte_eNb.c | 9 ++------- openair2/LAYER2/MAC/eNB_scheduler_dlsch.c | 4 ++-- 6 files changed, 8 insertions(+), 15 deletions(-) diff --git a/common/utils/T/T_defs.h b/common/utils/T/T_defs.h index d373d91aa5..6bdda0edac 100644 --- a/common/utils/T/T_defs.h +++ b/common/utils/T/T_defs.h @@ -8,10 +8,10 @@ #define T_MAX_ARGS 16 /* maximum size of a message - increase if needed */ -#define T_BUFFER_MAX (10) /*(1024*64)*/ +#define T_BUFFER_MAX (1024*64) /* size of the local cache for messages (must be pow(2,something)) */ -#define T_CACHE_SIZE (1) /*(8192 * 2)*/ +#define T_CACHE_SIZE (8192 * 2) /* maximum number of bytes a message can contain */ #ifdef T_SEND_TIME diff --git a/common/utils/system.c b/common/utils/system.c index 104e831910..dcec681e2d 100644 --- a/common/utils/system.c +++ b/common/utils/system.c @@ -148,7 +148,6 @@ int background_system(char *command) void start_background_system(void) { - return; int p[2]; pid_t son; diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c b/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c index 989d56cf6d..3bd174c3b3 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_modulation.c @@ -2175,8 +2175,8 @@ int dlsch_modulation(PHY_VARS_eNB* phy_vars_eNB, uint8_t mod_order0 = 0; uint8_t mod_order1 = 0; int16_t amp_rho_a, amp_rho_b; - int16_t qpsk_table_a0[2],qam16_table_a0[4],qam64_table_a0[8],qpsk_table_b0[2],qam16_table_b0[4],qam64_table_b0[8]; - int16_t qpsk_table_a1[2],qam16_table_a1[4],qam64_table_a1[8],qpsk_table_b1[2],qam16_table_b1[4],qam64_table_b1[8]; + int16_t qam16_table_a0[4],qam64_table_a0[8],qam16_table_b0[4],qam64_table_b0[8];//qpsk_table_a0[2],qpsk_table_b0[2] + int16_t qam16_table_a1[4],qam64_table_a1[8],qam16_table_b1[4],qam64_table_b1[8];//qpsk_table_a1[2],qpsk_table_b1[2] int16_t *qam_table_s0=NULL,*qam_table_s1=NULL; #ifdef NEW_ALLOC_RE diff --git a/openair1/SCHED/fapi_l1.c b/openair1/SCHED/fapi_l1.c index e8a767e0f5..1f52f18943 100644 --- a/openair1/SCHED/fapi_l1.c +++ b/openair1/SCHED/fapi_l1.c @@ -201,7 +201,6 @@ void handle_nfapi_dlsch_pdu(PHY_VARS_eNB *eNB,int frame,int subframe,eNB_rxtx_pr dlsch0_harq->pdsch_start = eNB->pdcch_vars[subframe & 1].num_pdcch_symbols; if (dlsch0_harq->round==0) { //get pointer to SDU if this a new SDU -//if (sdu==NULL) printf("dlsch0_harq %p harq %d\n", dlsch0_harq, harq_pid); AssertFatal(sdu!=NULL,"sdu==%d, NFAPI: SFN/SF:%04d%d proc:TX:[frame %d subframe %d]: programming dlsch for round 0, rnti %x, UE_id %d, harq_pid %d : sdu is null for pdu_index %d dlsch0_harq[round:%d SFN/SF:%d%d pdu:%p mcs:%d ndi:%d pdschstart:%d]\n", *sdu,frame,subframe, proc->frame_tx,proc->subframe_tx,rel8->rnti,UE_id,harq_pid, diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index e7293e9e89..ecdf8e5756 100644 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -399,7 +399,6 @@ void pdsch_procedures(PHY_VARS_eNB *eNB, dlsch->active = 0; dlsch_harq->round++; -//printf(" dlsch_harq ++ %p %d.%d harq %d rnti %d\n", dlsch_harq, frame, subframe, harq_pid, dlsch->rnti); LOG_D(PHY,"Generating DLSCH/PDSCH dlsch_harq[round:%d]\n",dlsch_harq->round); } @@ -519,7 +518,7 @@ void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB, //LOG_D(PHY,"Before generate_dci_top num_pdcch_symbols:%d num_dci:%d dci_alloc:dci_length:%d\n", num_pdcch_symbols, num_dci, eNB->pdcch_vars[subframe&1].dci_alloc[0].dci_length); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_ENB_PDCCH_TX,1); -//printf("//////////************before generate_dci_top UL %d.%d TX %d.%d \n", ul_frame, ul_subframe, frame, subframe); + if (nfapi_mode == 0 || nfapi_mode == 1) { generate_dci_top(num_pdcch_symbols, num_dci, @@ -557,7 +556,7 @@ void phy_procedures_eNB_TX(PHY_VARS_eNB *eNB, else { // generate pdsch -//printf("%d.%d pdsch_procedures ue rnti %d\n", frame, subframe, dlsch0->rnti);///////////////////////////////////********************** + pdsch_procedures(eNB, proc, harq_pid, @@ -1662,8 +1661,6 @@ void fill_ulsch_harq_indication(PHY_VARS_eNB *eNB,LTE_UL_eNB_HARQ_t *ulsch_harq, // release DLSCH if needed release_harq(eNB,UE_id,i,frame,subframe,0xffff, ulsch_harq->o_ACK[i] == 1); -//if (ulsch_harq->o_ACK[i] != 1) -//printf("got NACK %d.%d rnti %d harq %d\n", frame, subframe, rnti, eNB->dlsch[UE_id][0]->harq_ids[(subframe+6)%10]); #if T_TRACER /* TODO: get correct harq pid */ @@ -1763,8 +1760,6 @@ void fill_uci_harq_indication(PHY_VARS_eNB *eNB, // release DLSCH if needed release_harq(eNB,UE_id,0,frame,subframe,0xffff, harq_ack[0] == 1); -//if (harq_ack[0] != 1) -//printf("got NACK %d.%d rnti %d harq %d\n", frame, subframe, uci->rnti, eNB->dlsch[UE_id][0]->harq_ids[(subframe+6)%10]); #if T_TRACER if (harq_ack[0] != 1) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c index fecd1cab5d..0729073eba 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_dlsch.c @@ -928,7 +928,7 @@ schedule_ue_spec(module_id_t module_idP,slice_id_t slice_idP, eNB->DL_req[CC_id].sfn_sf = frameP<<4 | subframeP; eNB->DL_req[CC_id].header.message_id = NFAPI_DL_CONFIG_REQUEST; -//printf("doing retransmission for fill_nfapi_dlsch_config frame %d subframe %d rnti = %d harq_pid = %d\n", frameP, subframeP, rnti, harq_pid); + fill_nfapi_dlsch_config(eNB, dl_req, TBS, -1 /* retransmission, no pdu_index */ , rnti, 0, // type 0 allocation from 7.1.6 in 36.213 @@ -1455,7 +1455,7 @@ schedule_ue_spec(module_id_t module_idP,slice_id_t slice_idP, "physicalConfigDedicated is NULL\n"); AssertFatal(UE_list->UE_template[CC_id][UE_id].physicalConfigDedicated->pdsch_ConfigDedicated != NULL, "physicalConfigDedicated->pdsch_ConfigDedicated is NULL\n"); -//printf("mac DL transmition with frame = %d, subframe = %d, rnti = %d, pdu_index = %p\n", frameP, subframeP, rnti, eNB->pdu_index); + fill_nfapi_dlsch_config(eNB, dl_req, TBS, eNB->pdu_index[CC_id], rnti, 0, // type 0 allocation from 7.1.6 in 36.213 0, // virtual_resource_block_assignment_flag, unused here 0, // resource_block_coding, to be filled in later From cf459971101f920873672d5ec9802b904235ee82 Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Fri, 6 Apr 2018 16:53:42 +0200 Subject: [PATCH 55/63] Use TUN device for NAS for the UE instead of ue_ip.ko This work is based on work by NTT. To use the code, do: ./build_oai --oaisim --ue-nas-use-tun -t ETHERNET -c This commit only handles oaisim in S1 mode. We won't handle noS1 mode. --- cmake_targets/CMakeLists.txt | 1 + cmake_targets/build_oai | 8 ++ .../SIMULATION/ETH_TRANSPORT/netlink_init.c | 118 ++++++++++++++++++ openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c | 65 ++++++++++ 4 files changed, 192 insertions(+) diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index 34b868642d..c2d5168406 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -242,6 +242,7 @@ add_boolean_option(UE_DEBUG_TRACE False "Activate UE debug trace") add_boolean_option(UE_TIMING_TRACE False "Activate UE timing trace") add_boolean_option(DISABLE_LOG_X False "Deactivate all LOG_* macros") add_boolean_option(USRP_REC_PLAY False "Enable USRP record playback mode") +add_boolean_option(UE_NAS_USE_TUN False "Enable UE NAS TUN device instead of ue_ip.ko") add_boolean_option(DEBUG_CONSOLE False "makes debugging easier, disables stdout/stderr buffering") diff --git a/cmake_targets/build_oai b/cmake_targets/build_oai index d7b98bce41..440ff13b98 100755 --- a/cmake_targets/build_oai +++ b/cmake_targets/build_oai @@ -67,6 +67,7 @@ UE_TIMING_TRACE="False" DISABLE_LOG_X="False" USRP_REC_PLAY="False" BUILD_ECLIPSE=0 +UE_NAS_USE_TUN="False" trap handle_ctrl_c INT function print_help() { @@ -156,6 +157,8 @@ Options Build eclipse project files. Paths are auto corrected by fixprj.sh --usrp-recplay Build for I/Q record-playback modes +--ue-nas-use-tun + Use TUN devices for the UEs instead of ue_ip.ko Usage (first build): oaisim (eNB + UE): ./build_oai -I --oaisim -x --install-system-files Eurecom EXMIMO + COTS UE : ./build_oai -I --eNB -x --install-system-files @@ -347,6 +350,10 @@ function main() { USRP_REC_PLAY="True" echo_info "Enabling USRP record playback mode" shift 1;; + --ue-nas-use-tun) + UE_NAS_USE_TUN="True" + echo_info "Enabling UE NAS TUN device usage instead of ue_ip.ko" + shift 1;; -h | --help) print_help exit 1;; @@ -696,6 +703,7 @@ function main() { echo "set ( RRC_ASN1_VERSION \"${REL}\")" >> $cmake_file echo "set ( ENABLE_VCD_FIFO $VCD_TIMING )" >> $cmake_file echo "set ( T_TRACER $T_TRACER )" >> $cmake_file + echo "set ( UE_NAS_USE_TUN $UE_NAS_USE_TUN )" >> $cmake_file echo 'include(${CMAKE_CURRENT_SOURCE_DIR}/../CMakeLists.txt)' >> $cmake_file [ "$CLEAN" = "1" ] && rm -rf $DIR/$oaisim_build_dir/build mkdir -p $DIR/$oaisim_build_dir/build diff --git a/openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c b/openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c index b578721a1a..b90961a1c0 100644 --- a/openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c +++ b/openair1/SIMULATION/ETH_TRANSPORT/netlink_init.c @@ -39,6 +39,13 @@ #include #include #include "platform_constants.h" +#ifdef UE_NAS_USE_TUN +#include +#include +#include +#include +#include "openairinterface5g_limits.h" +#endif char nl_rx_buf[NL_MAX_PAYLOAD]; @@ -47,12 +54,121 @@ struct nlmsghdr *nas_nlh_tx = NULL; struct nlmsghdr *nas_nlh_rx = NULL; struct iovec nas_iov_tx; struct iovec nas_iov_rx = {nl_rx_buf, sizeof(nl_rx_buf)}; +#ifdef UE_NAS_USE_TUN +int nas_sock_fd[NUMBER_OF_UE_MAX]; +#else int nas_sock_fd; +#endif struct msghdr nas_msg_tx; struct msghdr nas_msg_rx; #define GRAAL_NETLINK_ID 31 +#ifdef UE_NAS_USE_TUN + +static int tun_alloc(char *dev) +{ + struct ifreq ifr; + int fd, err; + + if( (fd = open("/dev/net/tun", O_RDWR)) < 0 ) { + printf("[TUN] failed to open /dev/net/tun\n"); + return -1; + } + + memset(&ifr, 0, sizeof(ifr)); + + /* Flags: IFF_TUN - TUN device (no Ethernet headers) + * IFF_TAP - TAP device + * + * IFF_NO_PI - Do not provide packet information + */ + ifr.ifr_flags = IFF_TUN | IFF_NO_PI; + if( *dev ) + strncpy(ifr.ifr_name, dev, IFNAMSIZ); + + if( (err = ioctl(fd, TUNSETIFF, (void *) &ifr)) < 0 ){ + close(fd); + return err; + } + strcpy(dev, ifr.ifr_name); + return fd; +} + +int netlink_init(void) +{ + int i; + int ret; + + char ifname[64]; + for (i = 0; i < NUMBER_OF_UE_MAX; i++) { + sprintf(ifname, "oip%d", i+1); + nas_sock_fd[i] = tun_alloc(ifname); + + if (nas_sock_fd[i] == -1) { + printf("[NETLINK] Error opening socket %d (%d:%s)\n",nas_sock_fd[i],errno, strerror(errno)); +#if defined(LINK_ENB_PDCP_TO_IP_DRIVER) + exit(1); +#endif + } + + printf("[NETLINK]Opened socket with fd %d\n",nas_sock_fd[i]); + +#if !defined(PDCP_USE_NETLINK_QUEUES) + ret = fcntl(nas_sock_fd[i],F_SETFL,O_NONBLOCK); + + if (ret == -1) { + printf("[NETLINK] Error fcntl (%d:%s)\n",errno, strerror(errno)); +#if defined(LINK_ENB_PDCP_TO_IP_DRIVER) + exit(1); +#endif + } + +#endif + + memset(&nas_src_addr, 0, sizeof(nas_src_addr)); + nas_src_addr.nl_family = AF_NETLINK; + nas_src_addr.nl_pid = 1;//getpid(); /* self pid */ + nas_src_addr.nl_groups = 0; /* not in mcast groups */ + ret = bind(nas_sock_fd[i], (struct sockaddr*)&nas_src_addr, sizeof(nas_src_addr)); + + + + memset(&nas_dest_addr, 0, sizeof(nas_dest_addr)); + nas_dest_addr.nl_family = AF_NETLINK; + nas_dest_addr.nl_pid = 0; /* For Linux Kernel */ + nas_dest_addr.nl_groups = 0; /* unicast */ + + // TX PART + nas_nlh_tx=(struct nlmsghdr *)malloc(NLMSG_SPACE(NL_MAX_PAYLOAD)); + memset(nas_nlh_tx, 0, NLMSG_SPACE(NL_MAX_PAYLOAD)); + /* Fill the netlink message header */ + nas_nlh_tx->nlmsg_len = NLMSG_SPACE(NL_MAX_PAYLOAD); + nas_nlh_tx->nlmsg_pid = 1;//getpid(); /* self pid */ + nas_nlh_tx->nlmsg_flags = 0; + + nas_iov_tx.iov_base = (void *)nas_nlh_tx; + nas_iov_tx.iov_len = nas_nlh_tx->nlmsg_len; + memset(&nas_msg_tx,0,sizeof(nas_msg_tx)); + nas_msg_tx.msg_name = (void *)&nas_dest_addr; + nas_msg_tx.msg_namelen = sizeof(nas_dest_addr); + nas_msg_tx.msg_iov = &nas_iov_tx; + nas_msg_tx.msg_iovlen = 1; + + + // RX PART + memset(&nas_msg_rx,0,sizeof(nas_msg_rx)); + nas_msg_rx.msg_name = (void *)&nas_src_addr; + nas_msg_rx.msg_namelen = sizeof(nas_src_addr); + nas_msg_rx.msg_iov = &nas_iov_rx; + nas_msg_rx.msg_iovlen = 1; + } + + return 1; +} + +#else /* UE_NAS_USE_TUN */ + int netlink_init(void) { int ret; @@ -119,3 +235,5 @@ int netlink_init(void) return(nas_sock_fd); } + +#endif /* UE_NAS_USE_TUN */ diff --git a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c index 2de1b3fc74..50663cdc4f 100644 --- a/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c +++ b/openair2/LAYER2/PDCP_v10.1.0/pdcp_fifo.c @@ -72,7 +72,11 @@ extern struct nlmsghdr *nas_nlh_tx; extern struct nlmsghdr *nas_nlh_rx; extern struct iovec nas_iov_tx; extern struct iovec nas_iov_rx; +#ifdef UE_NAS_USE_TUN +extern int nas_sock_fd[NUMBER_OF_UE_MAX]; +#else extern int nas_sock_fd; +#endif extern struct msghdr nas_msg_tx; extern struct msghdr nas_msg_rx; @@ -239,7 +243,11 @@ int pdcp_fifo_flush_sdus(const protocol_ctxt_t* const ctxt_pP) nas_nlh_tx->nlmsg_len += pdcp_output_sdu_bytes_to_write; VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_UE_PDCP_FLUSH_SIZE, pdcp_output_sdu_bytes_to_write); VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_FLUSH_BUFFER, 1 ); +#ifdef UE_NAS_USE_TUN + ret = write(nas_sock_fd[ctxt_pP->module_id], &(sdu_p->data[sizeof(pdcp_data_ind_header_t)]), pdcp_output_sdu_bytes_to_write); +#else ret = sendmsg(nas_sock_fd,&nas_msg_tx,0); +#endif VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_FLUSH_BUFFER, 0 ); VCD_SIGNAL_DUMPER_DUMP_VARIABLE_BY_NAME( VCD_SIGNAL_DUMPER_VARIABLES_UE_PDCP_FLUSH_ERR, ret ); @@ -372,6 +380,62 @@ int pdcp_fifo_flush_sdus(const protocol_ctxt_t* const ctxt_pP) //----------------------------------------------------------------------------- int pdcp_fifo_read_input_sdus (const protocol_ctxt_t* const ctxt_pP) { +#ifdef UE_NAS_USE_TUN + protocol_ctxt_t ctxt = *ctxt_pP; + hash_key_t key = HASHTABLE_NOT_A_KEY_VALUE; + hashtable_rc_t h_rc; + pdcp_t* pdcp_p = NULL; + int len; + rb_id_t rab_id = DEFAULT_RAB_ID; + + do { + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ, 1 ); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ_BUFFER, 1 ); + len = read(nas_sock_fd[ctxt_pP->module_id], &nl_rx_buf, NL_MAX_PAYLOAD); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ_BUFFER, 0 ); + + if (len<=0) continue; + LOG_D(PDCP, "PDCP_COLL_KEY_DEFAULT_DRB_VALUE(module_id=%d, rnti=%x, enb_flag=%d)\n", + ctxt.module_id, ctxt.rnti, ctxt.enb_flag); + key = PDCP_COLL_KEY_DEFAULT_DRB_VALUE(ctxt.module_id, ctxt.rnti, ctxt.enb_flag); + h_rc = hashtable_get(pdcp_coll_p, key, (void**)&pdcp_p); + if (h_rc == HASH_TABLE_OK) { + LOG_D(PDCP, "[FRAME %5u][UE][NETLINK][IP->PDCP] INST %d: Received socket with length %d on Rab %d \n", + ctxt.frame, ctxt.instance, len, rab_id); + + LOG_D(PDCP, "[FRAME %5u][UE][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes --->][PDCP][MOD %u][UE %u][RB %u]\n", + ctxt.frame, ctxt.instance, rab_id, len, ctxt.module_id, + ctxt.rnti, rab_id); + MSC_LOG_RX_MESSAGE((ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE, + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE, + NULL, 0, + MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u rab %u size %u", + MSC_AS_TIME_ARGS(ctxt_pP), + ctxt.instance, rab_id, rab_id, len); + + pdcp_data_req(&ctxt, SRB_FLAG_NO, rab_id, RLC_MUI_UNDEFINED, + RLC_SDU_CONFIRM_NO, len, nl_rx_buf, + PDCP_TRANSMISSION_MODE_DATA); + } else { + MSC_LOG_RX_DISCARDED_MESSAGE( + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_PDCP_ENB:MSC_PDCP_UE, + (ctxt_pP->enb_flag == ENB_FLAG_YES) ? MSC_IP_ENB:MSC_IP_UE, + NULL, + 0, + MSC_AS_TIME_FMT" DATA-REQ inst %u rb %u rab %u size %u", + MSC_AS_TIME_ARGS(ctxt_pP), + ctxt.instance, rab_id, rab_id, len); + LOG_D(PDCP, + "[FRAME %5u][UE][IP][INSTANCE %u][RB %u][--- PDCP_DATA_REQ / %d Bytes ---X][PDCP][MOD %u][UE %u][RB %u] NON INSTANCIATED INSTANCE key 0x%"PRIx64", DROPPED\n", + ctxt.frame, ctxt.instance, rab_id, len, ctxt.module_id, + ctxt.rnti, rab_id, key); + } + } while (len > 0); + VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PDCP_FIFO_READ, 0 ); + return len; + +#else /* UE_NAS_USE_TUN */ + #ifdef PDCP_USE_NETLINK protocol_ctxt_t ctxt_cpy = *ctxt_pP; protocol_ctxt_t ctxt; @@ -764,6 +828,7 @@ int pdcp_fifo_read_input_sdus (const protocol_ctxt_t* const ctxt_pP) #else // neither PDCP_USE_NETLINK nor PDCP_USE_RT_FIFO return 0; #endif // PDCP_USE_NETLINK +#endif /* #else UE_NAS_USE_TUN */ } From 0ab2b2b26190c81350634d8418ed34386e1738fe Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Fri, 6 Apr 2018 10:27:23 -0700 Subject: [PATCH 56/63] modifications for simulator : power normalizations for UE TX, small changes to SNR targets for power control, default UE power (23 dBm now) --- openair1/SIMULATION/RF/dac.c | 10 ++++------ openair2/LAYER2/MAC/eNB_scheduler.c | 2 +- openair2/LAYER2/MAC/eNB_scheduler_ulsch.c | 2 +- .../CONF/rcc.band7.tm1.if4p5.50PRB.lo.conf | 5 ++--- targets/SIMU/USER/oaisim.c | 1 + 5 files changed, 9 insertions(+), 11 deletions(-) diff --git a/openair1/SIMULATION/RF/dac.c b/openair1/SIMULATION/RF/dac.c index 8cf6b49623..08f1ed7ab4 100644 --- a/openair1/SIMULATION/RF/dac.c +++ b/openair1/SIMULATION/RF/dac.c @@ -91,10 +91,8 @@ double dac_fixed_gain(double *s_re[2], int i; int aa; - double amp,amp1_local,*amp1p; - - amp = //sqrt(NB_RE)*pow(10.0,.05*txpwr_dBm)/sqrt(nb_tx_antennas); //this is amp per tx antenna - pow(10.0,.05*txpwr_dBm)/sqrt(nb_tx_antennas); //this is amp per tx antenna + double amp1_local,*amp1p; + double amp = pow(10.0,.05*txpwr_dBm)/sqrt(nb_tx_antennas); //this is amp per tx antenna if (amp1==NULL) amp1p = &1_local; else amp1p = amp1; @@ -123,7 +121,7 @@ double dac_fixed_gain(double *s_re[2], //printf("DL: amp1 %f dB (%d,%d), tx_power %f\n",20*log10(amp1),input_offset,input_offset_meas,txpwr_dBm); */ - + // printf("DAC: amp/amp1p %f amp1 %f dB (%d,%d), tx_power %f\n",amp/(*amp1p),20*log10(*amp1p),input_offset,input_offset_meas,txpwr_dBm); for (i=0; ipusch_snr[CC_id]; - target_rx_power = 178; + target_rx_power = 158; // this assumes accumulated tpc // make sure that we are only sending a tpc update once a frame, otherwise the control loop will freak out diff --git a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.50PRB.lo.conf b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.50PRB.lo.conf index 72ee47b9d6..771bf09499 100644 --- a/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.50PRB.lo.conf +++ b/targets/PROJECTS/GENERIC-LTE-EPC/CONF/rcc.band7.tm1.if4p5.50PRB.lo.conf @@ -73,10 +73,9 @@ eNBs = srs_SubframeConfig =; srs_ackNackST =; srs_MaxUpPts =;*/ - - pusch_p0_Nominal = -96; + pusch_p0_Nominal = -104; pusch_alpha = "AL1"; - pucch_p0_Nominal = -100; + pucch_p0_Nominal = -104; msg3_delta_Preamble = 6; pucch_deltaF_Format1 = "deltaF2"; pucch_deltaF_Format1b = "deltaF3"; diff --git a/targets/SIMU/USER/oaisim.c b/targets/SIMU/USER/oaisim.c index 65b0b8a3e4..898c695da4 100644 --- a/targets/SIMU/USER/oaisim.c +++ b/targets/SIMU/USER/oaisim.c @@ -1065,6 +1065,7 @@ void set_UE_defaults(int nb_ue) { PHY_vars_UE_g[UE_id][CC_id]->pdcch_vars[i][0]->agregationLevel = 0xFF; } PHY_vars_UE_g[UE_id][CC_id]->current_dlsch_cqi[0] = 10; + PHY_vars_UE_g[UE_id][CC_id]->tx_power_max_dBm = 23; } } } From 658aa0011929254b1edb955ed9629fa418b71e44 Mon Sep 17 00:00:00 2001 From: WANG Tsu-Han Date: Tue, 10 Apr 2018 16:52:05 +0200 Subject: [PATCH 57/63] bug fix for threading with under 8core --- targets/RT/USER/lte-enb.c | 22 ++++++++++++++++++++-- targets/RT/USER/lte-ru.c | 5 +++++ 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 3a526a7380..d12cb3edb2 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -243,7 +243,17 @@ static inline int rxtx(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, char *thread_nam VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER , 0 ); if(oai_exit) return(-1); - if(get_nprocs() <= 4) phy_procedures_eNB_TX(eNB, proc, no_relay, NULL, 1); + if(get_nprocs() <= 4){ + phy_procedures_eNB_TX(eNB, proc, no_relay, NULL, 1); + pthread_mutex_lock( &proc[1].mutex_rxtx ); + proc[1].pipe_ready++; + // the thread can now be woken up + if (pthread_cond_signal(&proc[1].cond_rxtx) != 0) { + LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB TXnp4 thread\n"); + exit_fun( "ERROR pthread_cond_signal" ); + } + pthread_mutex_unlock( &proc[1].mutex_rxtx ); + } stop_meas( &softmodem_stats_rxtx_sf ); @@ -404,9 +414,17 @@ static void* eNB_thread_rxtx( void* param ) { } pthread_mutex_unlock( &proc->mutex_rxtx ); if(get_nprocs() >= 8) wakeup_tx(eNB,eNB->proc.ru_proc); - else if(get_nprocs() > 4) + else { phy_procedures_eNB_TX(eNB, proc, no_relay, NULL, 1); + pthread_mutex_lock( &proc[1].mutex_rxtx ); + proc[1].pipe_ready++; + // the thread can now be woken up + if (pthread_cond_signal(&proc[1].cond_rxtx) != 0) { + LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB TXnp4 thread\n"); + exit_fun( "ERROR pthread_cond_signal" ); + } + pthread_mutex_unlock( &proc->mutex_rxtx ); wakeup_txfh(proc,eNB->proc.ru_proc); } diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index ca2304e8bb..c634a12bb8 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -1940,6 +1940,8 @@ void kill_RU_proc(int inst) LOG_D(PHY, "Joining pthread_FH\n"); pthread_join(proc->pthread_FH, NULL); + LOG_D(PHY, "Joining pthread_FHTX\n"); + pthread_join(proc->pthread_FH1, NULL); if (ru->function == NGFI_RRU_IF4p5) { LOG_D(PHY, "Joining pthread_prach\n"); pthread_join(proc->pthread_prach, NULL); @@ -1990,15 +1992,18 @@ void kill_RU_proc(int inst) pthread_mutex_destroy(&proc->mutex_asynch_rxtx); pthread_mutex_destroy(&proc->mutex_synch); pthread_mutex_destroy(&proc->mutex_FH); + pthread_mutex_destroy(&proc->mutex_FH1); pthread_mutex_destroy(&proc->mutex_eNBs); pthread_cond_destroy(&proc->cond_prach); pthread_cond_destroy(&proc->cond_FH); + pthread_cond_destroy(&proc->cond_FH1); pthread_cond_destroy(&proc->cond_asynch_rxtx); pthread_cond_destroy(&proc->cond_synch); pthread_cond_destroy(&proc->cond_eNBs); pthread_attr_destroy(&proc->attr_FH); + pthread_attr_destroy(&proc->attr_FH1); pthread_attr_destroy(&proc->attr_prach); pthread_attr_destroy(&proc->attr_synch); pthread_attr_destroy(&proc->attr_asynch_rxtx); From 68fdd19cb7e73447b6c4923d63d215c41f173b46 Mon Sep 17 00:00:00 2001 From: WANG Tsu-Han Date: Wed, 11 Apr 2018 15:09:07 +0200 Subject: [PATCH 58/63] fixs for 5-7 core --- targets/RT/USER/lte-enb.c | 26 ++++++-------------------- targets/RT/USER/lte-ru.c | 1 + 2 files changed, 7 insertions(+), 20 deletions(-) diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index d12cb3edb2..7dcfd432de 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -224,11 +224,13 @@ static inline int rxtx(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, char *thread_nam } VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME(VCD_SIGNAL_DUMPER_FUNCTIONS_ENB_DLSCH_ULSCH_SCHEDULER , 1 ); - if(wait_on_condition(&proc[1].mutex_rxtx,&proc[1].cond_rxtx,&proc[1].pipe_ready,"wakeup_tx")<0) { - LOG_E(PHY,"Frame %d, subframe %d: TX1 not ready\n",proc[1].frame_rx,proc[1].subframe_rx); - return(-1); + if(get_nprocs() >= 8){ + if(wait_on_condition(&proc[1].mutex_rxtx,&proc[1].cond_rxtx,&proc[1].pipe_ready,"wakeup_tx")<0) { + LOG_E(PHY,"Frame %d, subframe %d: TX1 not ready\n",proc[1].frame_rx,proc[1].subframe_rx); + return(-1); + } + if (release_thread(&proc[1].mutex_rxtx,&proc[1].pipe_ready,"wakeup_tx")<0) return(-1); } - if (release_thread(&proc[1].mutex_rxtx,&proc[1].pipe_ready,"wakeup_tx")<0) return(-1); pthread_mutex_lock(&eNB->UL_INFO_mutex); @@ -245,14 +247,6 @@ static inline int rxtx(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, char *thread_nam if(oai_exit) return(-1); if(get_nprocs() <= 4){ phy_procedures_eNB_TX(eNB, proc, no_relay, NULL, 1); - pthread_mutex_lock( &proc[1].mutex_rxtx ); - proc[1].pipe_ready++; - // the thread can now be woken up - if (pthread_cond_signal(&proc[1].cond_rxtx) != 0) { - LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB TXnp4 thread\n"); - exit_fun( "ERROR pthread_cond_signal" ); - } - pthread_mutex_unlock( &proc[1].mutex_rxtx ); } @@ -417,14 +411,6 @@ static void* eNB_thread_rxtx( void* param ) { else { phy_procedures_eNB_TX(eNB, proc, no_relay, NULL, 1); - pthread_mutex_lock( &proc[1].mutex_rxtx ); - proc[1].pipe_ready++; - // the thread can now be woken up - if (pthread_cond_signal(&proc[1].cond_rxtx) != 0) { - LOG_E( PHY, "[eNB] ERROR pthread_cond_signal for eNB TXnp4 thread\n"); - exit_fun( "ERROR pthread_cond_signal" ); - } - pthread_mutex_unlock( &proc->mutex_rxtx ); wakeup_txfh(proc,eNB->proc.ru_proc); } diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index c634a12bb8..bcc0e1c014 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -1463,6 +1463,7 @@ static void* ru_thread_tx( void* param ) { LOG_D(PHY,"ru_thread_tx: Waiting for TX processing\n"); // wait until eNBs are finished subframe RX n and TX n+4 wait_on_condition(&proc->mutex_eNBs,&proc->cond_eNBs,&proc->instance_cnt_eNBs,"ru_thread_tx"); + if (oai_exit) break; // do TX front-end processing if needed (precoding and/or IDFTs) if (ru->feptx_prec) ru->feptx_prec(ru); From e29d500db605ba6aba542a9bba83dc565b93844f Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Wed, 11 Apr 2018 17:15:14 +0200 Subject: [PATCH 59/63] integration fix: various fixes - fix compilation of dlsim/ulsim/oaisim by defining some needed global variables - fix compilation of oaisim: compile coding and params_libconfig - fix running of if4p5 with low CPU count (oaisim was not working on the machine 'haswell' because of this) --- cmake_targets/build_oai | 6 ++++++ openair1/SIMULATION/LTE_PHY/dlsim.c | 2 ++ openair1/SIMULATION/LTE_PHY/ulsim.c | 2 ++ targets/RT/USER/lte-ru.c | 8 ++++---- targets/SIMU/USER/oaisim.c | 5 +++++ 5 files changed, 19 insertions(+), 4 deletions(-) diff --git a/cmake_targets/build_oai b/cmake_targets/build_oai index 440ff13b98..04bd45e48e 100755 --- a/cmake_targets/build_oai +++ b/cmake_targets/build_oai @@ -712,6 +712,12 @@ function main() { compilations \ $oaisim_build_dir $oaisim_exec \ $oaisim_exec $dbin/$oaisim_exec.$REL + compilations \ + $oaisim_build_dir $config_libconfig_shlib \ + lib$config_libconfig_shlib.so $dbin/lib$config_libconfig_shlib.so + compilations \ + $oaisim_build_dir coding \ + libcoding.so $dbin/libcoding.so if [ "$NOS1" != "1" ] ; then diff --git a/openair1/SIMULATION/LTE_PHY/dlsim.c b/openair1/SIMULATION/LTE_PHY/dlsim.c index 885d29cc4e..ec66e357cc 100644 --- a/openair1/SIMULATION/LTE_PHY/dlsim.c +++ b/openair1/SIMULATION/LTE_PHY/dlsim.c @@ -69,6 +69,8 @@ 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_rx_dropped = 0; /*!< \brief initial max process time for rx */ +int codingw = 0; + void handler(int sig) { void *array[10]; diff --git a/openair1/SIMULATION/LTE_PHY/ulsim.c b/openair1/SIMULATION/LTE_PHY/ulsim.c index fc782be07a..c8909f83af 100644 --- a/openair1/SIMULATION/LTE_PHY/ulsim.c +++ b/openair1/SIMULATION/LTE_PHY/ulsim.c @@ -89,6 +89,8 @@ nfapi_tx_request_pdu_t tx_pdu_list[MAX_NUM_TX_REQUEST_PDU]; nfapi_tx_request_t TX_req; Sched_Rsp_t sched_resp; +int codingw = 0; + void fill_nfapi_ulsch_config_request(nfapi_ul_config_request_pdu_t *ul_config_pdu, uint8_t cqi_req, diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index fb77324734..1cbe73c309 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -2235,8 +2235,8 @@ void set_function_spec_param(RU_t *ru) ru->fh_north_out = fh_if4p5_north_out; // send_IF4p5 on reception ru->fh_south_out = tx_rf; // send output to RF ru->fh_north_asynch_in = fh_if4p5_north_asynch_in; // TX packets come asynchronously - ru->feprx = (get_nprocs()<=2) ? fep_full :ru_fep_full_2thread; // RX DFTs - ru->feptx_ofdm = (get_nprocs()<=2) ? feptx_ofdm : feptx_ofdm_2thread; // this is fep with idft only (no precoding in RRU) + ru->feprx = (get_nprocs()<=2 || !fepw) ? fep_full :ru_fep_full_2thread; // RX DFTs + ru->feptx_ofdm = (get_nprocs()<=2 || !fepw) ? feptx_ofdm : feptx_ofdm_2thread; // this is fep with idft only (no precoding in RRU) ru->feptx_prec = NULL; ru->start_if = start_if; // need to start the if interface for if4p5 ru->ifdevice.host_type = RRU_HOST; @@ -2286,9 +2286,9 @@ void set_function_spec_param(RU_t *ru) case REMOTE_IF5: // the remote unit is IF5 RRU ru->do_prach = 0; - ru->feprx = (get_nprocs()<=2) ? fep_full : fep_full; // this is frequency-shift + DFTs + ru->feprx = (get_nprocs()<=2 || !fepw) ? fep_full : fep_full; // this is frequency-shift + DFTs ru->feptx_prec = feptx_prec; // need to do transmit Precoding + IDFTs - ru->feptx_ofdm = (get_nprocs()<=2) ? feptx_ofdm : feptx_ofdm_2thread; // need to do transmit Precoding + IDFTs + ru->feptx_ofdm = (get_nprocs()<=2 || !fepw) ? feptx_ofdm : feptx_ofdm_2thread; // need to do transmit Precoding + IDFTs if (ru->if_timing == synch_to_other) { ru->fh_south_in = fh_slave_south_in; // synchronize to master ru->fh_south_out = fh_if5_mobipass_south_out; // use send_IF5 for mobipass diff --git a/targets/SIMU/USER/oaisim.c b/targets/SIMU/USER/oaisim.c index 898c695da4..7143634763 100644 --- a/targets/SIMU/USER/oaisim.c +++ b/targets/SIMU/USER/oaisim.c @@ -195,6 +195,11 @@ time_stats_t oaisim_stats_f; time_stats_t dl_chan_stats; time_stats_t ul_chan_stats; +int emulate_rf = 0; +int numerology = 0; +int codingw = 0; +int fepw = 0; + // this should reflect the channel models in openair1/SIMULATION/TOOLS/defs.h mapping small_scale_names[] = { { "custom", custom }, { "SCM_A", SCM_A }, From a1a60dc19a494efbbfdc5b741145fe796920135b Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Thu, 12 Apr 2018 11:28:51 +0200 Subject: [PATCH 60/63] integration fix: revert target_rx_power to 178 in eNB_scheduler_ulsch.c 158 does not work well with the eNB softmodem. --- openair2/LAYER2/MAC/eNB_scheduler_ulsch.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index b070167501..9ccb0e66ab 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -1281,7 +1281,7 @@ schedule_ulsch_rnti(module_id_t module_idP, // this is the normalized RX power and this should be constant (regardless of mcs normalized_rx_power = UE_sched_ctrl->pusch_snr[CC_id]; - target_rx_power = 158; + target_rx_power = 178; // this assumes accumulated tpc // make sure that we are only sending a tpc update once a frame, otherwise the control loop will freak out From fa4a9a0cb9682a2b1139df35c46eb0895b090f94 Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Thu, 12 Apr 2018 11:36:31 +0200 Subject: [PATCH 61/63] integration fix: update T tracer: add new VCD variables --- common/utils/T/T_defs.h | 2 +- common/utils/T/T_messages.txt | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/common/utils/T/T_defs.h b/common/utils/T/T_defs.h index 6bdda0edac..16d35210f2 100644 --- a/common/utils/T/T_defs.h +++ b/common/utils/T/T_defs.h @@ -32,7 +32,7 @@ typedef struct { #define VCD_NUM_FUNCTIONS 187 /* number of VCD variables (to be kept up to date! see in T_messages.txt) */ -#define VCD_NUM_VARIABLES 128 +#define VCD_NUM_VARIABLES 131 /* first VCD function (to be kept up to date! see in T_messages.txt) */ #define VCD_FIRST_FUNCTION ((uintptr_t)T_VCD_FUNCTION_RT_SLEEP) diff --git a/common/utils/T/T_messages.txt b/common/utils/T/T_messages.txt index 8d531f9067..4d59a8d380 100644 --- a/common/utils/T/T_messages.txt +++ b/common/utils/T/T_messages.txt @@ -1442,6 +1442,18 @@ ID = VCD_VARIABLE_UE0_TRX_WRITE_NS_MISSING DESC = VCD variable UE0_TRX_WRITE_NS_MISSING GROUP = ALL:VCD:UE:VCD_VARIABLE FORMAT = ulong,value +ID = VCD_VARIABLE_CPUID_ENB_THREAD_RXTX + DESC = VCD variable CPUID_ENB_THREAD_RXTX + GROUP = ALL:VCD:ENB:VCD_VARIABLE + FORMAT = ulong,value +ID = VCD_VARIABLE_CPUID_RU_THREAD + DESC = VCD variable CPUID_RU_THREAD + GROUP = ALL:VCD:ENB:VCD_VARIABLE + FORMAT = ulong,value +ID = VCD_VARIABLE_CPUID_RU_THREAD_TX + DESC = VCD variable CPUID_RU_THREAD_TX + GROUP = ALL:VCD:ENB:VCD_VARIABLE + FORMAT = ulong,value #functions From 17dda7bd702ce229bed3f53781dcd1bc72fbb4a3 Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Fri, 13 Apr 2018 11:59:56 +0200 Subject: [PATCH 62/63] integration fix: minor fix --- openair1/SCHED/fapi_l1.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openair1/SCHED/fapi_l1.c b/openair1/SCHED/fapi_l1.c index 1f52f18943..df01fad136 100644 --- a/openair1/SCHED/fapi_l1.c +++ b/openair1/SCHED/fapi_l1.c @@ -201,8 +201,8 @@ void handle_nfapi_dlsch_pdu(PHY_VARS_eNB *eNB,int frame,int subframe,eNB_rxtx_pr dlsch0_harq->pdsch_start = eNB->pdcch_vars[subframe & 1].num_pdcch_symbols; if (dlsch0_harq->round==0) { //get pointer to SDU if this a new SDU - AssertFatal(sdu!=NULL,"sdu==%d, NFAPI: SFN/SF:%04d%d proc:TX:[frame %d subframe %d]: programming dlsch for round 0, rnti %x, UE_id %d, harq_pid %d : sdu is null for pdu_index %d dlsch0_harq[round:%d SFN/SF:%d%d pdu:%p mcs:%d ndi:%d pdschstart:%d]\n", - *sdu,frame,subframe, + AssertFatal(sdu!=NULL,"NFAPI: SFN/SF:%04d%d proc:TX:[frame %d subframe %d]: programming dlsch for round 0, rnti %x, UE_id %d, harq_pid %d : sdu is null for pdu_index %d dlsch0_harq[round:%d SFN/SF:%d%d pdu:%p mcs:%d ndi:%d pdschstart:%d]\n", + frame,subframe, proc->frame_tx,proc->subframe_tx,rel8->rnti,UE_id,harq_pid, dl_config_pdu->dlsch_pdu.dlsch_pdu_rel8.pdu_index,dlsch0_harq->round,dlsch0_harq->frame,dlsch0_harq->subframe,dlsch0_harq->pdu,dlsch0_harq->mcs,dlsch0_harq->ndi,dlsch0_harq->pdsch_start); if (rel8->rnti != 0xFFFF) LOG_D(PHY,"NFAPI: SFN/SF:%04d%d proc:TX:[frame %d, subframe %d]: programming dlsch for round 0, rnti %x, UE_id %d, harq_pid %d\n", From 79eb6eb4d2ac6b5d62e9feba8a3cb69211cdf1cb Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Mon, 16 Apr 2018 11:23:05 +0200 Subject: [PATCH 63/63] integration fix: fix UE softmodem compilation --- targets/RT/USER/lte-uesoftmodem.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/targets/RT/USER/lte-uesoftmodem.c b/targets/RT/USER/lte-uesoftmodem.c index ae4798f399..a571aebe23 100644 --- a/targets/RT/USER/lte-uesoftmodem.c +++ b/targets/RT/USER/lte-uesoftmodem.c @@ -213,7 +213,10 @@ extern PHY_VARS_UE* init_ue_vars(LTE_DL_FRAME_PARMS *frame_parms, int transmission_mode=1; - +int emulate_rf = 0; +int numerology = 0; +int codingw = 0; +int fepw = 0; /* struct for ethernet specific parameters given in eNB conf file */ eth_params_t *eth_params;