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/88] 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/88] 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/88] 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/88] 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/88] 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/88] 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/88] 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/88] 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/88] 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/88] 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/88] 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/88] 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/88] 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/88] 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/88] 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/88] 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/88] 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/88] 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/88] 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/88] 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/88] 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/88] 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/88] 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/88] 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/88] 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/88] 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/88] 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/88] 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/88] 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/88] 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/88] 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/88] 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/88] 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/88] 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/88] 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/88] 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/88] 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/88] 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/88] 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/88] 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/88] 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/88] 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/88] 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/88] 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/88] 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/88] 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 445524bc879a71df38fba0f133810fae94f45694 Mon Sep 17 00:00:00 2001 From: Eino Virtanen Date: Mon, 12 Mar 2018 15:50:04 +0100 Subject: [PATCH 47/88] fix building protobuf when user name is not the same as primary group name --- cmake_targets/tools/build_helper | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake_targets/tools/build_helper b/cmake_targets/tools/build_helper index 706cd05fe9..3bb051f291 100755 --- a/cmake_targets/tools/build_helper +++ b/cmake_targets/tools/build_helper @@ -210,7 +210,7 @@ install_protobuf_from_source(){ #cd protobuf-2.6.1/ rm -rf /tmp/protobuf-cpp-3.3.0.tar.gz* /tmp/protobuf-3.3.0 wget https://github.com/google/protobuf/releases/download/v3.3.0/protobuf-cpp-3.3.0.tar.gz - tar -xzvf protobuf-cpp-3.3.0.tar.gz --owner $USER --group $USER --no-same-owner + tar -xzvf protobuf-cpp-3.3.0.tar.gz --owner $USER --group $(groups | cut -d" " -f1) --no-same-owner cd protobuf-3.3.0/ ./configure echo "Compiling protobuf" From 8d90eda6004b27408a61bfe3220229e3331b8225 Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Wed, 14 Mar 2018 16:21:51 +0100 Subject: [PATCH 48/88] 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 3da8cac59b23ba1900e2c0e39a4a375ce10c3994 Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Thu, 15 Mar 2018 10:48:16 +0100 Subject: [PATCH 49/88] bugfix: try to release HARQ processes properly The code is too complex. This commit may not be enough. --- openair1/SCHED/phy_procedures_lte_eNb.c | 88 ++++++++------ .../LAYER2/MAC/eNB_scheduler_primitives.c | 114 ++++++++++++++++-- openair2/LAYER2/MAC/pre_processor.c | 2 +- 3 files changed, 157 insertions(+), 47 deletions(-) diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index 6c2e580947..780d3a1a6f 100644 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -1451,7 +1451,9 @@ void fill_rx_indication(PHY_VARS_eNB *eNB,int UE_id,int frame,int subframe) pthread_mutex_unlock(&eNB->UL_INFO_mutex); } -void release_harq(PHY_VARS_eNB *eNB,int UE_id,int tb,uint16_t frame,uint8_t subframe,uint16_t mask) { +/* release the harq if its round is >= 'after_rounds' */ +static void do_release_harq(PHY_VARS_eNB *eNB,int UE_id,int tb,uint16_t frame,uint8_t subframe,uint16_t mask, int after_rounds) +{ LTE_eNB_DLSCH_t *dlsch0=NULL,*dlsch1=NULL; LTE_DL_eNB_HARQ_t *dlsch0_harq=NULL,*dlsch1_harq=NULL; @@ -1472,11 +1474,13 @@ void release_harq(PHY_VARS_eNB *eNB,int UE_id,int tb,uint16_t frame,uint8_t subf dlsch1_harq = dlsch1->harq_processes[harq_pid]; AssertFatal(dlsch0_harq!=NULL,"dlsch0_harq is null\n"); - dlsch0_harq->status = SCH_IDLE; - /*if ((dlsch1_harq == NULL)|| - ((dlsch1_harq!=NULL)&& - (dlsch1_harq->status == SCH_IDLE)))*/ - dlsch0->harq_mask &= ~(1<round >= after_rounds) { + dlsch0_harq->status = SCH_IDLE; + /*if ((dlsch1_harq == NULL)|| + ((dlsch1_harq!=NULL)&& + (dlsch1_harq->status == SCH_IDLE)))*/ + dlsch0->harq_mask &= ~(1<rnti); } @@ -1496,17 +1500,28 @@ void release_harq(PHY_VARS_eNB *eNB,int UE_id,int tb,uint16_t frame,uint8_t subf dlsch1_harq = dlsch1->harq_processes[harq_pid]; AssertFatal(dlsch0_harq!=NULL,"dlsch0_harq is null\n"); - dlsch0_harq->status = SCH_IDLE; - if ((dlsch1_harq == NULL)|| - ((dlsch1_harq!=NULL)&& - (dlsch1_harq->status == SCH_IDLE))) - dlsch0->harq_mask &= ~(1<round >= after_rounds) { + dlsch0_harq->status = SCH_IDLE; + if ((dlsch1_harq == NULL)|| + ((dlsch1_harq!=NULL)&& + (dlsch1_harq->status == SCH_IDLE))) + dlsch0->harq_mask &= ~(1<harq_indication_fdd_rel13.harq_tb_n[i] = 2-ulsch_harq->o_ACK[i]; // release DLSCH if needed - if (ulsch_harq->o_ACK[i] == 1) release_harq(eNB,UE_id,i,frame,subframe,0xffff); + release_harq(eNB,UE_id,i,frame,subframe,0xffff, ulsch_harq->o_ACK[i] == 1); #if T_TRACER /* TODO: get correct harq pid */ @@ -1633,13 +1648,17 @@ void fill_ulsch_harq_indication(PHY_VARS_eNB *eNB,LTE_UL_eNB_HARQ_t *ulsch_harq, pdu->harq_indication_tdd_rel13.harq_data[0].multiplex.value_0 = 2-ulsch_harq->o_ACK[i]; // release DLSCH if needed - if (ulsch_harq->o_ACK[i] == 1) release_harq(eNB,UE_id,i,frame,subframe,0xffff); - if (M==1 && ulsch_harq->O_ACK==1 && ulsch_harq->o_ACK[i] == 1) release_harq(eNB,UE_id,0,frame,subframe,0xffff); - else if (M==1 && ulsch_harq->O_ACK==2 && ulsch_harq->o_ACK[i] == 1) release_harq(eNB,UE_id,i,frame,subframe,0xffff); + /* TODO: review this code, it's most certainly wrong. + * We have to release the proper HARQ in case of ACK or NACK if max retransmission reached. + * Basically, call release_harq with 1 as last argument when ACK and 0 when NACK. + */ + release_harq(eNB,UE_id,i,frame,subframe,0xffff, ulsch_harq->o_ACK[i] == 1); + if (M==1 && ulsch_harq->O_ACK==1 && ulsch_harq->o_ACK[i] == 1) release_harq(eNB,UE_id,0,frame,subframe,0xffff, ulsch_harq->o_ACK[i] == 1); + else if (M==1 && ulsch_harq->O_ACK==2 && ulsch_harq->o_ACK[i] == 1) release_harq(eNB,UE_id,i,frame,subframe,0xffff, ulsch_harq->o_ACK[i] == 1); else if (M>1 && ulsch_harq->o_ACK[i] == 1) { // spatial bundling - release_harq(eNB,UE_id,0,frame,subframe,1<o_ACK[i] == 1); + release_harq(eNB,UE_id,1,frame,subframe,1<o_ACK[i] == 1); } } } @@ -1701,7 +1720,7 @@ void fill_uci_harq_indication(PHY_VARS_eNB *eNB, AssertFatal(harq_ack[0] == 1 || harq_ack[0] == 2 || harq_ack[0] == 4, "harq_ack[0] is %d, should be 1,2 or 4\n",harq_ack[0]); pdu->harq_indication_fdd_rel13.harq_tb_n[0] = harq_ack[0]; // release DLSCH if needed - if (harq_ack[0] == 1) release_harq(eNB,UE_id,0,frame,subframe,0xffff); + release_harq(eNB,UE_id,0,frame,subframe,0xffff, harq_ack[0] == 1); #if T_TRACER if (harq_ack[0] != 1) @@ -1721,8 +1740,8 @@ void fill_uci_harq_indication(PHY_VARS_eNB *eNB, pdu->harq_indication_fdd_rel13.harq_tb_n[0] = harq_ack[0]; pdu->harq_indication_fdd_rel13.harq_tb_n[1] = harq_ack[1]; // release DLSCH if needed - if (harq_ack[0] == 1) release_harq(eNB,UE_id,0,frame,subframe,0xffff); - if (harq_ack[1] == 1) release_harq(eNB,UE_id,1,frame,subframe,0xffff); + release_harq(eNB,UE_id,0,frame,subframe,0xffff, harq_ack[0] == 1); + release_harq(eNB,UE_id,1,frame,subframe,0xffff, harq_ack[1] == 1); } else AssertFatal(1==0,"only format 1a/b for now, received %d\n",uci->pucch_fmt); } @@ -1743,7 +1762,7 @@ void fill_uci_harq_indication(PHY_VARS_eNB *eNB, AssertFatal(harq_ack[0] == 1 || harq_ack[0] == 2 || harq_ack[0] == 4, "harq_ack[0] is %d, should be 1,2 or 4\n",harq_ack[0]); pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = harq_ack[0]; // release all bundled DLSCH if needed - if (harq_ack[0] == 1) release_harq(eNB,UE_id,0,frame,subframe,0xffff); + release_harq(eNB,UE_id,0,frame,subframe,0xffff, harq_ack[0] == 1); } else if (uci->pucch_fmt == pucch_format1b) { pdu->harq_indication_tdd_rel13.number_of_ack_nack = 2; @@ -1753,8 +1772,8 @@ void fill_uci_harq_indication(PHY_VARS_eNB *eNB, pdu->harq_indication_tdd_rel13.harq_data[0].bundling.value_0 = harq_ack[0]; pdu->harq_indication_tdd_rel13.harq_data[1].bundling.value_0 = harq_ack[1]; // release all DLSCH if needed - if (harq_ack[0] == 1) release_harq(eNB,UE_id,0,frame,subframe,0xffff); - if (harq_ack[1] == 1) release_harq(eNB,UE_id,1,frame,subframe,0xffff); + release_harq(eNB,UE_id,0,frame,subframe,0xffff, harq_ack[0] == 1); + release_harq(eNB,UE_id,1,frame,subframe,0xffff, harq_ack[1] == 1); } break; case 1: // multiplexing @@ -1766,7 +1785,7 @@ void fill_uci_harq_indication(PHY_VARS_eNB *eNB, AssertFatal(harq_ack[0] == 1 || harq_ack[0] == 2 || harq_ack[0] == 4, "harq_ack[0] is %d, should be 1,2 or 4\n",harq_ack[0]); pdu->harq_indication_tdd_rel13.harq_data[0].multiplex.value_0 = harq_ack[0]; // release all DLSCH if needed - if (harq_ack[0] == 1) release_harq(eNB,UE_id,0,frame,subframe,0xffff); + release_harq(eNB,UE_id,0,frame,subframe,0xffff, harq_ack[0] == 1); } else if (uci->num_pucch_resources == 1 && uci->pucch_fmt == pucch_format1b) { pdu->harq_indication_tdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_TDD_REL13_TAG; @@ -1776,8 +1795,8 @@ void fill_uci_harq_indication(PHY_VARS_eNB *eNB, pdu->harq_indication_tdd_rel13.harq_data[0].multiplex.value_0 = harq_ack[0]; pdu->harq_indication_tdd_rel13.harq_data[1].multiplex.value_0 = harq_ack[1]; // release all DLSCH if needed - if (harq_ack[0] == 1) release_harq(eNB,UE_id,0,frame,subframe,0xffff); - if (harq_ack[1] == 1) release_harq(eNB,UE_id,1,frame,subframe,0xffff); + release_harq(eNB,UE_id,0,frame,subframe,0xffff, harq_ack[0] == 1); + release_harq(eNB,UE_id,1,frame,subframe,0xffff, harq_ack[1] == 1); } else { // num_pucch_resources (M) > 1 pdu->harq_indication_tdd_rel13.tl.tag = NFAPI_HARQ_INDICATION_TDD_REL13_TAG; @@ -1788,8 +1807,8 @@ void fill_uci_harq_indication(PHY_VARS_eNB *eNB, if (uci->num_pucch_resources == 3) pdu->harq_indication_tdd_rel13.harq_data[2].multiplex.value_0 = harq_ack[2]; if (uci->num_pucch_resources == 4) pdu->harq_indication_tdd_rel13.harq_data[3].multiplex.value_0 = harq_ack[3]; // spatial-bundling in this case so release both HARQ if necessary - release_harq(eNB,UE_id,0,frame,subframe,tdd_multiplexing_mask); - release_harq(eNB,UE_id,1,frame,subframe,tdd_multiplexing_mask); + release_harq(eNB,UE_id,0,frame,subframe,tdd_multiplexing_mask, 1 /* force release? previous code was unconditional */); + release_harq(eNB,UE_id,1,frame,subframe,tdd_multiplexing_mask, 1 /* force release? previous code was unconditional */); } break; case 2: // special bundling (SR collision) @@ -1800,26 +1819,27 @@ void fill_uci_harq_indication(PHY_VARS_eNB *eNB, switch (harq_ack[0]) { case 0: + /* TODO: release_harq here? this whole code looks suspicious */ break; case 1: // check if M=1,4,7 if (uci->num_pucch_resources == 1 || uci->num_pucch_resources == 4 || tdd_config5_sf2scheds == 1 || tdd_config5_sf2scheds == 4 || tdd_config5_sf2scheds == 7) { - release_harq(eNB,UE_id,0,frame,subframe,0xffff); - release_harq(eNB,UE_id,1,frame,subframe,0xffff); + release_harq(eNB,UE_id,0,frame,subframe,0xffff, 1); + release_harq(eNB,UE_id,1,frame,subframe,0xffff, 1); } break; case 2: // check if M=2,5,8 if (uci->num_pucch_resources == 2 || tdd_config5_sf2scheds == 2 || tdd_config5_sf2scheds == 5 || tdd_config5_sf2scheds == 8) { - release_harq(eNB,UE_id,0,frame,subframe,0xffff); - release_harq(eNB,UE_id,1,frame,subframe,0xffff); + release_harq(eNB,UE_id,0,frame,subframe,0xffff, 1); + release_harq(eNB,UE_id,1,frame,subframe,0xffff, 1); } break; case 3: // check if M=3,6,9 if (uci->num_pucch_resources == 3 || tdd_config5_sf2scheds == 3 || tdd_config5_sf2scheds == 6 || tdd_config5_sf2scheds == 9) { - release_harq(eNB,UE_id,0,frame,subframe,0xffff); - release_harq(eNB,UE_id,1,frame,subframe,0xffff); + release_harq(eNB,UE_id,0,frame,subframe,0xffff, 1); + release_harq(eNB,UE_id,1,frame,subframe,0xffff, 1); } break; } diff --git a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c index 341db67934..110afc1a5a 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c @@ -3268,8 +3268,13 @@ extract_harq(module_id_t mod_idP, int CC_idP, int UE_id, if (pdu[0] == 1) { // ACK sched_ctl->round[CC_idP][harq_pid] = 8; // release HARQ process sched_ctl->tbcnt[CC_idP][harq_pid] = 0; - } else if (pdu[0] == 2 || pdu[0] == 4) // NAK (treat DTX as NAK) + } else if (pdu[0] == 2 || pdu[0] == 4) { // NAK (treat DTX as NAK) sched_ctl->round[CC_idP][harq_pid]++; // increment round + if (sched_ctl->round[CC_idP][harq_pid] == 4) { + sched_ctl->round[CC_idP][harq_pid] = 8; // release HARQ process + sched_ctl->tbcnt[CC_idP][harq_pid] = 0; + } + } } else { // one or two ACK/NAK bits AssertFatal(num_ack_nak <= 2, @@ -3285,8 +3290,13 @@ extract_harq(module_id_t mod_idP, int CC_idP, int UE_id, if ((num_ack_nak == 2) && (sched_ctl->round[CC_idP][harq_pid] < 8) && (sched_ctl->tbcnt[CC_idP][harq_pid] == 1) - && (pdu[0] == 2) && (pdu[1] == 2)) + && (pdu[0] == 2) && (pdu[1] == 2)) { sched_ctl->round[CC_idP][harq_pid]++; + if (sched_ctl->round[CC_idP][harq_pid] == 4) { + sched_ctl->round[CC_idP][harq_pid] = 8; // release HARQ process + sched_ctl->tbcnt[CC_idP][harq_pid] = 0; + } + } else if (((num_ack_nak == 2) && (sched_ctl->round[CC_idP][harq_pid] < 8) && (sched_ctl->tbcnt[0][harq_pid] == 2) @@ -3297,11 +3307,20 @@ extract_harq(module_id_t mod_idP, int CC_idP, int UE_id, && (pdu[0] == 2) && (pdu[1] == 1))) { sched_ctl->round[CC_idP][harq_pid]++; sched_ctl->tbcnt[CC_idP][harq_pid] = 1; + if (sched_ctl->round[CC_idP][harq_pid] == 4) { + sched_ctl->round[CC_idP][harq_pid] = 8; // release HARQ process + sched_ctl->tbcnt[CC_idP][harq_pid] = 0; /* TODO: do we have to set it to 0? */ + } } else if ((num_ack_nak == 2) && (sched_ctl->round[CC_idP][harq_pid] < 8) && (sched_ctl->tbcnt[CC_idP][harq_pid] == 2) - && (pdu[0] == 2) && (pdu[1] == 2)) + && (pdu[0] == 2) && (pdu[1] == 2)) { sched_ctl->round[CC_idP][harq_pid]++; + if (sched_ctl->round[CC_idP][harq_pid] == 4) { + sched_ctl->round[CC_idP][harq_pid] = 8; // release HARQ process + sched_ctl->tbcnt[CC_idP][harq_pid] = 0; + } + } else AssertFatal(1 == 0, "Illegal ACK/NAK/round combination (%d,%d,%d,%d,%d) for harq_pid %d, UE %d/%x\n", @@ -3327,12 +3346,18 @@ extract_harq(module_id_t mod_idP, int CC_idP, int UE_id, pdu[1]); if (pdu[0] == 1) sched_ctl->round[pCCid][harq_pid] = 8; - else + else { sched_ctl->round[pCCid][harq_pid]++; + if (sched_ctl->round[pCCid][harq_pid] == 4) + sched_ctl->round[pCCid][harq_pid] = 8; + } if (pdu[1] == 1) sched_ctl->round[1 - pCCid][harq_pid] = 8; - else + else { sched_ctl->round[1 - pCCid][harq_pid]++; + if (sched_ctl->round[1 - pCCid][harq_pid] == 4) + sched_ctl->round[1 - pCCid][harq_pid] = 8; + } } // A=2 else if ((num_ack_nak == 3) && (sched_ctl->round[pCCid][harq_pid] < 8) @@ -3358,13 +3383,26 @@ extract_harq(module_id_t mod_idP, int CC_idP, int UE_id, ((pdu[0] == 1) && (pdu[1] == 2))) { sched_ctl->round[pCCid][harq_pid]++; sched_ctl->tbcnt[pCCid][harq_pid] = 1; - } else + if (sched_ctl->round[pCCid][harq_pid] == 4) { + sched_ctl->round[pCCid][harq_pid] = 8; + sched_ctl->tbcnt[pCCid][harq_pid] = 0; /* TODO: do we have to set it to 0? */ + } + } else { sched_ctl->round[pCCid][harq_pid]++; + if (sched_ctl->round[pCCid][harq_pid] == 4) { + sched_ctl->round[pCCid][harq_pid] = 8; + sched_ctl->tbcnt[pCCid][harq_pid] = 0; + } + } if (pdu[2] == 1) sched_ctl->round[1 - pCCid][harq_pid] = 8; - else + else { sched_ctl->round[1 - pCCid][harq_pid]++; + if (sched_ctl->round[1 - pCCid][harq_pid] == 4) { + sched_ctl->round[1 - pCCid][harq_pid] = 8; + } + } } // A=3 primary cell has 2 TBs else if ((num_ack_nak == 3) && (sched_ctl->round[1 - pCCid][harq_pid] < 8) @@ -3390,13 +3428,26 @@ extract_harq(module_id_t mod_idP, int CC_idP, int UE_id, || ((pdu[0] == 1) && (pdu[1] >= 2))) { // one ACK sched_ctl->round[1 - pCCid][harq_pid]++; sched_ctl->tbcnt[1 - pCCid][harq_pid] = 1; - } else // both NAK/DTX + if (sched_ctl->round[1 - pCCid][harq_pid] == 4) { + sched_ctl->round[1 - pCCid][harq_pid] = 8; + sched_ctl->tbcnt[1 - pCCid][harq_pid] = 0; + } + } else { // both NAK/DTX sched_ctl->round[1 - pCCid][harq_pid]++; + if (sched_ctl->round[1 - pCCid][harq_pid] == 4) { + sched_ctl->round[1 - pCCid][harq_pid] = 8; + sched_ctl->tbcnt[1 - pCCid][harq_pid] = 0; + } + } if (pdu[2] == 1) sched_ctl->round[pCCid][harq_pid] = 8; - else + else { sched_ctl->round[pCCid][harq_pid]++; + if (sched_ctl->round[pCCid][harq_pid] == 4) { + sched_ctl->round[pCCid][harq_pid] = 8; + } + } } // A=3 secondary cell has 2 TBs #if MAX_NUM_CCs>1 else if ((num_ack_nak == 4) @@ -3425,8 +3476,17 @@ extract_harq(module_id_t mod_idP, int CC_idP, int UE_id, || ((pdu[0] == 1) && (pdu[1] >= 2))) { // one ACK sched_ctl->round[0][harq_pid]++; sched_ctl->tbcnt[0][harq_pid] = 1; - } else // both NAK/DTX + if (sched_ctl->round[0][harq_pid] == 4) { + sched_ctl->round[0][harq_pid] = 8; + sched_ctl->tbcnt[0][harq_pid] = 0; + } + } else { // both NAK/DTX sched_ctl->round[0][harq_pid]++; + if (sched_ctl->round[0][harq_pid] == 4) { + sched_ctl->round[0][harq_pid] = 8; + sched_ctl->tbcnt[0][harq_pid] = 0; + } + } if ((pdu[2] == 1) && (pdu[3] == 1)) { // both ACK sched_ctl->round[1][harq_pid] = 8; @@ -3435,8 +3495,17 @@ extract_harq(module_id_t mod_idP, int CC_idP, int UE_id, || ((pdu[2] == 1) && (pdu[3] >= 2))) { // one ACK sched_ctl->round[1][harq_pid]++; sched_ctl->tbcnt[1][harq_pid] = 1; - } else // both NAK/DTX + if (sched_ctl->round[1][harq_pid] == 4) { + sched_ctl->round[1][harq_pid] = 8; + sched_ctl->tbcnt[1][harq_pid] = 0; + } + } else { // both NAK/DTX sched_ctl->round[1][harq_pid]++; + if (sched_ctl->round[1][harq_pid] == 4) { + sched_ctl->round[1][harq_pid] = 8; + sched_ctl->tbcnt[1][harq_pid] = 0; + } + } } // A=4 both serving cells have 2 TBs #endif break; @@ -3451,8 +3520,13 @@ extract_harq(module_id_t mod_idP, int CC_idP, int UE_id, if (pdu[j] == 1) { sched_ctl->round[i][harq_pid] = 8; sched_ctl->tbcnt[i][harq_pid] = 0; - } else if (pdu[j] == 2) + } else if (pdu[j] == 2) { sched_ctl->round[i][harq_pid]++; + if (sched_ctl->round[i][harq_pid] == 4) { + sched_ctl->round[i][harq_pid] = 8; + sched_ctl->tbcnt[i][harq_pid] = 0; + } + } else AssertFatal(1 == 0, "Illegal harq_ack value for CC %d harq_pid %d (%d) UE %d/%x\n", @@ -3467,13 +3541,25 @@ extract_harq(module_id_t mod_idP, int CC_idP, int UE_id, && (pdu[j] == 1) && (pdu[j + 1] == 2)) { sched_ctl->round[i][harq_pid]++; sched_ctl->tbcnt[i][harq_pid] = 1; + if (sched_ctl->round[i][harq_pid] == 4) { + sched_ctl->round[i][harq_pid] = 8; + sched_ctl->tbcnt[i][harq_pid] = 0; + } } else if ((sched_ctl->tbcnt[i][harq_pid] == 2) && (pdu[j] == 2) && (pdu[j + 1] == 1)) { sched_ctl->round[i][harq_pid]++; sched_ctl->tbcnt[i][harq_pid] = 1; + if (sched_ctl->round[i][harq_pid] == 4) { + sched_ctl->round[i][harq_pid] = 8; + sched_ctl->tbcnt[i][harq_pid] = 0; + } } else if ((sched_ctl->tbcnt[i][harq_pid] == 2) && (pdu[j] == 2) && (pdu[j + 1] == 2)) { sched_ctl->round[i][harq_pid]++; + if (sched_ctl->round[i][harq_pid] == 4) { + sched_ctl->round[i][harq_pid] = 8; + sched_ctl->tbcnt[i][harq_pid] = 0; + } } else AssertFatal(1 == 0, "Illegal combination for CC %d harq_pid %d (%d,%d,%d) UE %d/%x\n", @@ -3487,6 +3573,10 @@ extract_harq(module_id_t mod_idP, int CC_idP, int UE_id, sched_ctl->tbcnt[i][harq_pid] = 0; } else if (pdu[j] == 2) { sched_ctl->round[i][harq_pid]++; + if (sched_ctl->round[i][harq_pid] == 4) { + sched_ctl->round[i][harq_pid] = 8; + sched_ctl->tbcnt[i][harq_pid] = 0; + } } else AssertFatal(1 == 0, "Illegal hack_nak value %d for CC %d harq_pid %d UE %d/%x\n", diff --git a/openair2/LAYER2/MAC/pre_processor.c b/openair2/LAYER2/MAC/pre_processor.c index e7458c347f..2cdcfc7de8 100644 --- a/openair2/LAYER2/MAC/pre_processor.c +++ b/openair2/LAYER2/MAC/pre_processor.c @@ -734,7 +734,7 @@ void dlsch_scheduler_pre_processor_accounting(module_id_t Mod_id, // control channel or retransmission /* TODO: do we have to check for retransmission? */ - if (mac_eNB_get_rrc_status(Mod_id, rnti) < RRC_RECONFIGURED || round > 0) { + if (mac_eNB_get_rrc_status(Mod_id, rnti) < RRC_RECONFIGURED || round != 8) { nb_rbs_required_remaining_1[CC_id][UE_id] = nb_rbs_required[CC_id][UE_id]; } else { From 71a98a977e5eb45a267491a047b4f44e431a20ae Mon Sep 17 00:00:00 2001 From: Wang Tsu-Han Date: Fri, 16 Mar 2018 18:18:55 +0100 Subject: [PATCH 50/88] 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 d312f9c8059ec2d2cb87d1cbc51f5dbd05a2beb2 Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Mon, 19 Mar 2018 01:10:10 -0700 Subject: [PATCH 51/88] debugging for TDD --- openair1/PHY/LTE_TRANSPORT/dci_tools.c | 4 +- openair1/PHY/LTE_TRANSPORT/if4_tools.c | 6 +- openair1/PHY/LTE_TRANSPORT/initial_sync.c | 14 ++- openair1/PHY/LTE_TRANSPORT/phich.c | 21 ++-- openair1/PHY/LTE_TRANSPORT/pucch.c | 10 +- openair1/PHY/defs.h | 2 +- openair1/PHY/impl_defs_lte.h | 10 +- openair1/SCHED/fapi_l1.c | 21 ++-- openair1/SCHED/phy_procedures_lte_common.c | 2 +- openair1/SCHED/phy_procedures_lte_eNb.c | 58 +++++------ openair1/SCHED/phy_procedures_lte_ue.c | 2 +- openair2/LAYER2/MAC/eNB_scheduler.c | 6 +- openair2/LAYER2/MAC/eNB_scheduler_RA.c | 32 +++--- .../LAYER2/MAC/eNB_scheduler_primitives.c | 99 +++++++++++++++++-- openair2/LAYER2/MAC/eNB_scheduler_ulsch.c | 23 +++-- targets/RT/USER/lte-enb.c | 2 + targets/RT/USER/lte-ru.c | 5 +- targets/SIMU/USER/oaisim.c | 4 +- targets/SIMU/USER/oaisim_functions.c | 32 +++--- 19 files changed, 234 insertions(+), 119 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/dci_tools.c b/openair1/PHY/LTE_TRANSPORT/dci_tools.c index c8aae2b36a..565cf7e3d5 100644 --- a/openair1/PHY/LTE_TRANSPORT/dci_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/dci_tools.c @@ -2660,7 +2660,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] Frame %d, Subframe %d Programming PUSCH with n_DMRS2 %d (cshift %d) ulsch:ndi:%d ulsch_pdu:ndi:%d new_ulsch:%d status:%d ulsch_pdu:rvidx:%d\n", + LOG_D(PHY,"[eNB %d][PUSCH %d] Frame %d, Subframe %d Programming PUSCH with n_DMRS2 %d (cshift %d) ulsch:ndi:%d ulsch_pdu:ndi:%d new_ulsch:%d status:%d ulsch_pdu:rvidx:%d\n", eNB->Mod_id,harq_pid,frame,subframe, ulsch->harq_processes[harq_pid]->n_DMRS2, ulsch->harq_processes[harq_pid]->n_DMRS, @@ -2692,7 +2692,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, status %d, handled %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, status %d, handled %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/if4_tools.c b/openair1/PHY/LTE_TRANSPORT/if4_tools.c index d9544e8f83..874907c482 100644 --- a/openair1/PHY/LTE_TRANSPORT/if4_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/if4_tools.c @@ -67,7 +67,7 @@ void send_IF4p5(RU_t *ru, int frame, int subframe, uint16_t packet_type) { if (ru->idx==0) VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_SEND_IF4, 1 ); if (packet_type == IF4p5_PDLFFT) { - //LOG_D(PHY,"send DL_IF4p5: RU %d frame %d, subframe %d\n",ru->idx,frame,subframe); + LOG_D(PHY,"send DL_IF4p5: RU %d frame %d, subframe %d\n",ru->idx,frame,subframe); if (subframe_select(fp,subframe)==SF_S) nsym=fp->dl_symbols_in_S_subframe; @@ -125,6 +125,8 @@ void send_IF4p5(RU_t *ru, int frame, int subframe, uint16_t packet_type) { slotoffsetF = 0; blockoffsetF = slotoffsetF + fp->ofdm_symbol_size - db_halflength; + LOG_D(PHY,"send UL_IF4p5: RU %d frame %d, subframe %d\n",ru->idx,frame,subframe); + if (subframe_select(fp,subframe)==SF_S) { nsym=fp->ul_symbols_in_S_subframe; slotoffsetF += (fp->ofdm_symbol_size*(fp->symbols_per_tti-nsym)); @@ -410,7 +412,7 @@ void recv_IF4p5(RU_t *ru, int *frame, int *subframe, uint16_t *packet_type, uint for (idx=0;idxnum_eNB;idx++) ru->wakeup_prach_eNB(ru->eNB_list[idx],ru,*frame,*subframe); } else if (*packet_type == IF4p5_PULTICK) { - + if (ru->idx==0) LOG_D(PHY,"UL_IF4p5: RU %d : frame %d, subframe %d, PULTICK\n",ru->idx,*frame,*subframe); } else { AssertFatal(1==0, "recv_IF4p5 - Unknown packet_type %x", *packet_type); } diff --git a/openair1/PHY/LTE_TRANSPORT/initial_sync.c b/openair1/PHY/LTE_TRANSPORT/initial_sync.c index dce3868efd..064f865c62 100644 --- a/openair1/PHY/LTE_TRANSPORT/initial_sync.c +++ b/openair1/PHY/LTE_TRANSPORT/initial_sync.c @@ -336,7 +336,7 @@ int initial_sync(PHY_VARS_UE *ue, runmode_t mode) #ifdef DEBUG_INITIAL_SYNCH LOG_I(PHY,"FDD Normal prefix: SSS error condition: sync_pos %d, sync_pos_slot %d\n", sync_pos, sync_pos_slot); #endif - write_output("rxdata.m","rxd",ue->common_vars.rxdata[0],10*frame_parms->samples_per_tti,1,1); + //write_output("rxdata.m","rxd",ue->common_vars.rxdata[0],10*frame_parms->samples_per_tti,1,1); } @@ -513,6 +513,18 @@ int initial_sync(PHY_VARS_UE *ue, runmode_t mode) ue->pbch_vars[0]->pdu_errors_conseq=0; + if (ue->frame_parms.frame_type==FDD) { + ue->N_TA_offset = 0; + } + else { + if (ue->frame_parms.N_RB_DL == 100) + ue->N_TA_offset = 624; + else if (ue->frame_parms.N_RB_DL == 50) + ue->N_TA_offset = 624/2; + else if (ue->frame_parms.N_RB_DL == 25) + ue->N_TA_offset = 624/4; + + } } #if DISABLE_LOG_X diff --git a/openair1/PHY/LTE_TRANSPORT/phich.c b/openair1/PHY/LTE_TRANSPORT/phich.c index 2bd7140c32..d4fb894f2c 100644 --- a/openair1/PHY/LTE_TRANSPORT/phich.c +++ b/openair1/PHY/LTE_TRANSPORT/phich.c @@ -1512,6 +1512,7 @@ void generate_phich_top(PHY_VARS_eNB *eNB, uint32_t pusch_frame; int subframe = proc->subframe_tx; phich_config_t *phich; + int absSF = subframe+(proc->frame_tx*10); // compute Ngroup_PHICH (see formula at beginning of Section 6.9 in 36-211 @@ -1523,16 +1524,20 @@ void generate_phich_top(PHY_VARS_eNB *eNB, if (frame_parms->Ncp == 1) NSF_PHICH = 2; - if (eNB->phich_vars[subframe&1].num_hi > 0) { + + + + for (i=0; iphich_vars.config[i]; + if (phich->active == 0 || phich->absSF != absSF) continue; + pusch_frame = phich_frame2_pusch_frame(frame_parms,proc->frame_tx,subframe); pusch_subframe = phich_subframe2_pusch_subframe(frame_parms,subframe); harq_pid = subframe2harq_pid(frame_parms,pusch_frame,pusch_subframe); - } + + phich->active = 0; - for (i=0; iphich_vars[subframe&1].num_hi; i++) { - - phich = &eNB->phich_vars[subframe&1].config[i]; - ngroup_PHICH = (phich->first_rb + phich->n_DMRS)%Ngroup_PHICH; @@ -1565,6 +1570,6 @@ void generate_phich_top(PHY_VARS_eNB *eNB, phich->hi, subframe, txdataF); - }// for (i=0; iphich_vars[subframe&1].num_hi; i++) { - eNB->phich_vars[subframe&1].num_hi=0; + } + } diff --git a/openair1/PHY/LTE_TRANSPORT/pucch.c b/openair1/PHY/LTE_TRANSPORT/pucch.c index 9a19b0ddaf..0d56839ba2 100644 --- a/openair1/PHY/LTE_TRANSPORT/pucch.c +++ b/openair1/PHY/LTE_TRANSPORT/pucch.c @@ -2438,9 +2438,9 @@ uint32_t rx_pucch(PHY_VARS_eNB *eNB, } // aa - LOG_D(PHY,"PUCCH 1a/b: subframe %d : stat %d,%d (pos %d)\n",subframe,stat_re,stat_im, + LOG_I(PHY,"PUCCH 1a/b: subframe %d : stat %d,%d (pos %d)\n",subframe,stat_re,stat_im, (subframe<<10) + (eNB->pucch1ab_stats_cnt[UE_id][subframe])); - LOG_D(PHY,"PUCCH 1a/b: subframe %d : sigma2_dB %d, stat_max %d, pucch1_thres %d\n",subframe,sigma2_dB,dB_fixed(stat_max),pucch1_thres); + LOG_I(PHY,"PUCCH 1a/b: subframe %d : sigma2_dB %d, stat_max %d, pucch1_thres %d\n",subframe,sigma2_dB,dB_fixed(stat_max),pucch1_thres); eNB->pucch1ab_stats[UE_id][(subframe<<11) + 2*(eNB->pucch1ab_stats_cnt[UE_id][subframe])] = (stat_re); eNB->pucch1ab_stats[UE_id][(subframe<<11) + 1+2*(eNB->pucch1ab_stats_cnt[UE_id][subframe])] = (stat_im); @@ -2454,11 +2454,7 @@ uint32_t rx_pucch(PHY_VARS_eNB *eNB, if (fmt==pucch_format1b) *(1+payload) = (stat_im<0) ? 1 : 2; } else { // insufficient energy on PUCCH so NAK -#if defined(USRP_REC_PLAY) - LOG_D(PHY,"PUCCH 1a/b: NAK subframe %d : sigma2_dB %d, stat_max %d, pucch1_thres %d\n",subframe,sigma2_dB,dB_fixed(stat_max),pucch1_thres); -#else - LOG_D(PHY,"PUCCH 1a/b: subframe %d : sigma2_dB %d, stat_max %d, pucch1_thres %d\n",subframe,sigma2_dB,dB_fixed(stat_max),pucch1_thres); -#endif + LOG_I(PHY,"PUCCH 1a/b (DTX): subframe %d : sigma2_dB %d, stat_max %d, pucch1_thres %d\n",subframe,sigma2_dB,dB_fixed(stat_max),pucch1_thres); *payload = 4; // DTX ((int16_t*)&eNB->pucch1ab_stats[UE_id][(subframe<<10) + (eNB->pucch1ab_stats_cnt[UE_id][subframe])])[0] = (int16_t)(stat_re); ((int16_t*)&eNB->pucch1ab_stats[UE_id][(subframe<<10) + (eNB->pucch1ab_stats_cnt[UE_id][subframe])])[1] = (int16_t)(stat_im); diff --git a/openair1/PHY/defs.h b/openair1/PHY/defs.h index 48b33b7ab3..198f1d9a29 100644 --- a/openair1/PHY/defs.h +++ b/openair1/PHY/defs.h @@ -1020,7 +1020,7 @@ typedef struct PHY_VARS_eNB_s { #endif Sched_Rsp_t Sched_INFO; LTE_eNB_PDCCH pdcch_vars[2]; - LTE_eNB_PHICH phich_vars[2]; + LTE_eNB_PHICH phich_vars; #ifdef Rel14 LTE_eNB_EPDCCH epdcch_vars[2]; LTE_eNB_MPDCCH mpdcch_vars[2]; diff --git a/openair1/PHY/impl_defs_lte.h b/openair1/PHY/impl_defs_lte.h index 066dc7012c..3364698045 100644 --- a/openair1/PHY/impl_defs_lte.h +++ b/openair1/PHY/impl_defs_lte.h @@ -839,22 +839,24 @@ typedef struct { uint8_t dci_pdu[8]; } mDCI_ALLOC_t; - +#define MAX_NUM_PDCCH 32 typedef struct { uint8_t num_dci; uint8_t num_pdcch_symbols; - DCI_ALLOC_t dci_alloc[32]; + DCI_ALLOC_t dci_alloc[MAX_NUM_PDCCH]; } LTE_eNB_PDCCH; typedef struct { + uint16_t absSF; + uint16_t active; uint8_t hi; uint8_t first_rb; uint8_t n_DMRS; } phich_config_t; +#define MAX_NUM_PHICH 32 typedef struct { - uint8_t num_hi; - phich_config_t config[32]; + phich_config_t config[MAX_NUM_PHICH]; } LTE_eNB_PHICH; typedef struct { diff --git a/openair1/SCHED/fapi_l1.c b/openair1/SCHED/fapi_l1.c index 8bed9970bf..5b39428c30 100644 --- a/openair1/SCHED/fapi_l1.c +++ b/openair1/SCHED/fapi_l1.c @@ -95,7 +95,8 @@ void handle_nfapi_hi_dci0_dci_pdu(PHY_VARS_eNB *eNB,int frame,int subframe,eNB_r void handle_nfapi_hi_dci0_hi_pdu(PHY_VARS_eNB *eNB,int frame,int subframe,eNB_rxtx_proc_t *proc, nfapi_hi_dci0_request_pdu_t *hi_dci0_config_pdu) { - LTE_eNB_PHICH *phich = &eNB->phich_vars[subframe&1]; + LTE_eNB_PHICH *phich = &eNB->phich_vars; + int i; // copy dci configuration in to eNB structure LOG_D(PHY,"Received HI PDU with value %d (rbstart %d,cshift %d)\n", @@ -104,11 +105,14 @@ void handle_nfapi_hi_dci0_hi_pdu(PHY_VARS_eNB *eNB,int frame,int subframe,eNB_rx hi_dci0_config_pdu->hi_pdu.hi_pdu_rel8.cyclic_shift_2_for_drms); // DJP - TODO FIXME - transmission power ignored - phich->config[phich->num_hi].hi = hi_dci0_config_pdu->hi_pdu.hi_pdu_rel8.hi_value; - phich->config[phich->num_hi].first_rb = hi_dci0_config_pdu->hi_pdu.hi_pdu_rel8.resource_block_start; - phich->config[phich->num_hi].n_DMRS = hi_dci0_config_pdu->hi_pdu.hi_pdu_rel8.cyclic_shift_2_for_drms; - phich->num_hi++; - AssertFatal(phich->num_hi<32,"Maximum number of phich reached in subframe\n"); + for (i=0;i<32;i++) if (phich->config[i].active==0) break; + AssertFatal(i<32,"no free PHICH allocation\n"); + + phich->config[i].active = 0; + phich->config[i].absSF = (frame*10)+subframe; + phich->config[i].hi = hi_dci0_config_pdu->hi_pdu.hi_pdu_rel8.hi_value; + phich->config[i].first_rb = hi_dci0_config_pdu->hi_pdu.hi_pdu_rel8.resource_block_start; + phich->config[i].n_DMRS = hi_dci0_config_pdu->hi_pdu.hi_pdu_rel8.cyclic_shift_2_for_drms; } void handle_nfapi_bch_pdu(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc, @@ -488,7 +492,7 @@ void handle_uci_harq_pdu(PHY_VARS_eNB *eNB,int UE_id,nfapi_ul_config_request_pdu { LTE_eNB_UCI *uci = &eNB->uci_vars[UE_id]; - LOG_D(PHY,"Frame %d, Subframe %d: Programming UCI_HARQ process (type %d)\n",frame,subframe,HARQ); + LOG_I(PHY,"Frame %d, Subframe %d: Programming UCI_HARQ process (type %d)\n",frame,subframe,HARQ); uci->frame = frame; uci->subframe = subframe; uci->rnti = ul_config_pdu->uci_harq_pdu.ue_information.ue_information_rel8.rnti; @@ -537,7 +541,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 in frame %d, subframe %d, modulation %d, rvidx %d\n", UE_id,rel8->rnti,frame,subframe,rel8->modulation_type,rel8->redundancy_version); + LOG_D(PHY,"Applying UL config for UE %d, rnti %x in frame %d, subframe %d, modulation %d, rvidx %d\n", UE_id,rel8->rnti,frame,subframe,rel8->modulation_type,rel8->redundancy_version); fill_ulsch(eNB,&ul_config_pdu->ulsch_pdu,frame,subframe); @@ -653,7 +657,6 @@ void schedule_response(Sched_Rsp_t *Sched_INFO) eNB->pdcch_vars[subframe&1].num_pdcch_symbols = number_pdcch_ofdm_symbols; eNB->pdcch_vars[subframe&1].num_dci = 0; - eNB->phich_vars[subframe&1].num_hi = 0; LOG_I(PHY,"NFAPI: Sched_INFO:SFN/SF:%04d%d DL_req:SFN/SF:%04d%d:dl_pdu:%d tx_req:SFN/SF:%04d%d:pdus:%d hi_dci0:SFN/SF:%04d%d:pdus:%d ul_cfg:SFN/SF:%04d%d:pdus:%d num_pdcch_symbols:%d\n", frame,subframe, diff --git a/openair1/SCHED/phy_procedures_lte_common.c b/openair1/SCHED/phy_procedures_lte_common.c index 8cc0ca4790..93fb404157 100644 --- a/openair1/SCHED/phy_procedures_lte_common.c +++ b/openair1/SCHED/phy_procedures_lte_common.c @@ -841,7 +841,7 @@ lte_subframe_t get_subframe_direction(uint8_t Mod_id,uint8_t CC_id,uint8_t subfr uint8_t phich_subframe_to_harq_pid(LTE_DL_FRAME_PARMS *frame_parms,uint32_t frame,uint8_t subframe) { - LOG_I(PHY,"phich_subframe_to_harq_pid.c: frame %d, subframe %d\n",frame,subframe); + LOG_D(PHY,"phich_subframe_to_harq_pid.c: frame %d, subframe %d\n",frame,subframe); return(subframe2harq_pid(frame_parms, phich_frame2_pusch_frame(frame_parms,frame,subframe), phich_subframe2_pusch_subframe(frame_parms,subframe))); diff --git a/openair1/SCHED/phy_procedures_lte_eNb.c b/openair1/SCHED/phy_procedures_lte_eNb.c index da32fdb427..7b176f1ac7 100644 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -749,7 +749,7 @@ void uci_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) /* cancel SR detection if reception on n1_pucch0 is better than on SR PUCCH resource index, otherwise send it up to MAC */ if (uci->type==HARQ_SR && metric[0] > metric_SR) SR_payload = 0; else if (SR_payload == 1) fill_sr_indication(eNB,uci->rnti,frame,subframe,metric_SR); - + if (uci->type==HARQ_SR && metric[0] <= metric_SR) { /* when transmitting ACK/NACK on SR PUCCH resource index, SR payload is always 1 */ SR_payload = 1; @@ -772,8 +772,8 @@ void uci_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) uci->rnti, frame,subframe, pucch_b0b1[0][0],metric[0]); - - uci->stat = metric[0]; + + uci->stat = metric[0]; fill_uci_harq_indication(eNB,uci,frame,subframe,pucch_b0b1[0],0,0xffff); } @@ -782,12 +782,12 @@ void uci_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) // if SR was detected, use the n1_pucch from SR if (SR_payload==1) { -#ifdef DEBUG_PHY_PROC - LOG_D(PHY,"[eNB %d][PDSCH %x] Frame %d subframe %d Checking ACK/NAK (%d,%d,%d,%d) format %d with SR\n",eNB->Mod_id, - eNB->dlsch[UE_id][0]->rnti, + + LOG_D(PHY,"[eNB %d][PDSCH %x] Frame %d subframe %d Checking ACK/NAK format %d with SR\n",eNB->Mod_id, + uci->rnti, frame,subframe, - n1_pucch0,n1_pucch1,n1_pucch2,n1_pucch3,format); -#endif + uci->pucch_fmt); + metric[0] = rx_pucch(eNB, pucch_format1b, @@ -800,9 +800,9 @@ void uci_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) subframe, PUCCH1a_THRES); } else { //using assigned pucch resources -#ifdef DEBUG_PHY_PROC - LOG_D(PHY,"[eNB %d][PDSCH %x] Frame %d subframe %d Checking ACK/NAK M=%d (%d,%d,%d,%d) format %d\n",eNB->Mod_id, - eNB->dlsch[UE_id][0]->rnti, + + LOG_I(PHY,"[eNB %d][PDSCH %x] Frame %d subframe %d Checking ACK/NAK M=%d (%d,%d,%d,%d) format %d\n",eNB->Mod_id, + uci->rnti, frame,subframe, uci->num_pucch_resources, uci->n_pucch_1[res][0], @@ -810,7 +810,7 @@ void uci_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) uci->n_pucch_1[res][2], uci->n_pucch_1[res][3], uci->pucch_fmt); -#endif + for (res=0;resnum_pucch_resources;res++) metric[res] = rx_pucch(eNB, uci->pucch_fmt, @@ -844,7 +844,7 @@ void uci_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) else if (pucch_b0b1[1][0] != 1 && pucch_b0b1[1][1] != 1) { // 0 ACKs, or at least one DL assignment missed harq_ack[0] = 0; } - uci->stat = metric[0]; + uci->stat = metric[0]; fill_uci_harq_indication(eNB,uci,frame,subframe,harq_ack,2,0xffff); // special_bundling mode } else if ((uci->tdd_bundling == 0) && (uci->num_pucch_resources==2)){ // multiplexing + no SR, implement Table 10.1.3-5 (Rel14) for multiplexing with M=2 @@ -886,7 +886,7 @@ void uci_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) } } } - uci->stat = max(metric[0],metric[1]); + uci->stat = max(metric[0],metric[1]); fill_uci_harq_indication(eNB,uci,frame,subframe,harq_ack,1,tdd_multiplexing_mask); // multiplexing mode } //else if ((uci->tdd_bundling == 0) && (res==2)) else if ((uci->tdd_bundling == 0) && (uci->num_pucch_resources==3)){ // multiplexing + no SR, implement Table 10.1.3-6 (Rel14) for multiplexing with M=3 @@ -1105,22 +1105,22 @@ void uci_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) } } } - uci->stat = max_metric; + uci->stat = max_metric; fill_uci_harq_indication(eNB,uci,frame,subframe,harq_ack,1,tdd_multiplexing_mask); // multiplexing mode } // else if ((uci->tdd_bundling == 0) && (res==4)) else { // bundling harq_ack[0] = pucch_b0b1[0][0]; harq_ack[1] = pucch_b0b1[0][1]; - uci->stat = metric[0]; + uci->stat = metric[0]; fill_uci_harq_indication(eNB,uci,frame,subframe,harq_ack,0,0xffff); // special_bundling mode } -#ifdef DEBUG_PHY_PROC - LOG_D(PHY,"[eNB %d][PDSCH %x] Frame %d subframe %d ACK/NAK metric 0 %d, metric 1 %d, (%d,%d)\n",eNB->Mod_id, - eNB->dlsch[UE_id][0]->rnti, + + LOG_I(PHY,"[eNB %d][PDSCH %x] Frame %d subframe %d ACK/NAK metric 0 %d, metric 1 %d, (%d,%d)\n",eNB->Mod_id, + uci->rnti, frame,subframe, - metric0,metric1,pucch_b0b1[0],pucch_b0b1[1]); -#endif + metric[0],metric[1],pucch_b0b1[0][0],pucch_b0b1[0][1]); + } break; default: @@ -1159,11 +1159,11 @@ void pusch_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) harq_pid = ((10*frame) + subframe)&7; - LOG_I(PHY,"Running eNB pusch procedures in %d.%d, harq_pid %d\n",frame,subframe,harq_pid); + LOG_D(PHY,"Running eNB pusch procedures in %d.%d, harq_pid %d\n",frame,subframe,harq_pid); for (i=0; iulsch[i]; ulsch_harq = ulsch->harq_processes[harq_pid]; - if (ulsch->rnti>0) LOG_I(PHY,"eNB->ulsch[%d]->harq_processes[harq_pid:%d] SFN/SF:%04d%d: PUSCH procedures, UE %d/%x ulsch_harq[status:%d SFN/SF:%04d%d handled:%d]\n", + if (ulsch->rnti>0) LOG_D(PHY,"eNB->ulsch[%d]->harq_processes[harq_pid:%d] SFN/SF:%04d%d: PUSCH procedures, UE %d/%x ulsch_harq[status:%d SFN/SF:%04d%d handled:%d]\n", i, harq_pid, frame,subframe,i,ulsch->rnti, ulsch_harq->status, ulsch_harq->frame, ulsch_harq->subframe, ulsch_harq->handled); @@ -1182,7 +1182,7 @@ void pusch_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) eNB->rb_mask_ul[rb2>>5] |= (1<<(rb2&31)); } - LOG_I(PHY,"[eNB %d] frame %d, subframe %d: Scheduling ULSCH Reception for UE %d \n", eNB->Mod_id, frame, subframe, i); + LOG_D(PHY,"[eNB %d] frame %d, subframe %d: Scheduling ULSCH Reception for UE %d \n", eNB->Mod_id, frame, subframe, i); nPRS = fp->pusch_config_common.ul_ReferenceSignalsPUSCH.nPRS[subframe<<1]; @@ -1190,7 +1190,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, ), O_ACK %d, beta_cqi %d \n", eNB->Mod_id,harq_pid,frame,subframe, ulsch_harq->dci_alloc, @@ -1223,7 +1223,7 @@ void pusch_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) stop_meas(&eNB->ulsch_decoding_stats); - LOG_I(PHY,"[eNB %d][PUSCH %d] frame %d subframe %d RNTI %x RX power (%d,%d) N0 (%d,%d) dB ACK (%d,%d), decoding iter %d ulsch_harq->cqi_crc_status:%d ackBits:%d ulsch_decoding_stats[t:%lld max:%lld]\n", + LOG_D(PHY,"[eNB %d][PUSCH %d] frame %d subframe %d RNTI %x RX power (%d,%d) N0 (%d,%d) dB ACK (%d,%d), decoding iter %d ulsch_harq->cqi_crc_status:%d ackBits:%d ulsch_decoding_stats[t:%lld max:%lld]\n", eNB->Mod_id,harq_pid, frame,subframe, ulsch->rnti, @@ -1259,7 +1259,7 @@ void pusch_procedures(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc) fill_crc_indication(eNB,i,frame,subframe,1); // indicate NAK to MAC fill_rx_indication(eNB,i,frame,subframe); // indicate SDU to MAC - LOG_I(PHY,"[eNB %d][PUSCH %d] frame %d subframe %d UE %d Error receiving ULSCH, round %d/%d (ACK %d,%d)\n", + LOG_D(PHY,"[eNB %d][PUSCH %d] frame %d subframe %d UE %d Error receiving ULSCH, round %d/%d (ACK %d,%d)\n", eNB->Mod_id,harq_pid, frame,subframe, i, ulsch_harq->round, @@ -1830,7 +1830,7 @@ void fill_uci_harq_indication(PHY_VARS_eNB *eNB, eNB->UL_INFO.harq_ind.harq_indication_body.number_of_harqs++; - LOG_D(PHY,"Incremented eNB->UL_INFO.harq_ind.harq_indication_body.number_of_harqs:%d\n", eNB->UL_INFO.harq_ind.harq_indication_body.number_of_harqs); + LOG_I(PHY,"Incremented eNB->UL_INFO.harq_ind.harq_indication_body.number_of_harqs:%d\n", eNB->UL_INFO.harq_ind.harq_indication_body.number_of_harqs); pthread_mutex_unlock(&eNB->UL_INFO_mutex); } @@ -1878,7 +1878,7 @@ void phy_procedures_eNB_uespec_RX(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,const VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_ENB_RX_UESPEC, 1 ); - LOG_D(PHY,"[eNB %d] Frame %d: Doing phy_procedures_eNB_uespec_RX(%d)\n",eNB->Mod_id,frame, subframe); + LOG_I(PHY,"[eNB %d] Frame %d: Doing phy_procedures_eNB_uespec_RX(%d)\n",eNB->Mod_id,frame, subframe); eNB->rb_mask_ul[0]=0; eNB->rb_mask_ul[1]=0; diff --git a/openair1/SCHED/phy_procedures_lte_ue.c b/openair1/SCHED/phy_procedures_lte_ue.c index bfe2ada358..6f8f7f0579 100644 --- a/openair1/SCHED/phy_procedures_lte_ue.c +++ b/openair1/SCHED/phy_procedures_lte_ue.c @@ -2161,7 +2161,7 @@ void ue_pucch_procedures(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB_id,uin &len); - LOG_D(PHY,"PUCCH feedback AbsSubframe %d.%d SR %d NbCW %d (%d %d) AckNack %d.%d CQI %d RI %d format %d pucch_resource %d pucch_payload %d %d \n", + LOG_I(PHY,"PUCCH feedback AbsSubframe %d.%d SR %d NbCW %d (%d %d) AckNack %d.%d CQI %d RI %d format %d pucch_resource %d pucch_payload %d %d \n", frame_tx%1024, subframe_tx, SR_payload, nb_cw, ack_status_cw0, ack_status_cw1, pucch_ack_payload[0], pucch_ack_payload[1], cqi_status, ri_status, format, pucch_resource,pucch_payload[0],pucch_payload[1]); // Part - IV diff --git a/openair2/LAYER2/MAC/eNB_scheduler.c b/openair2/LAYER2/MAC/eNB_scheduler.c index d446160f47..193a32c80a 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler.c +++ b/openair2/LAYER2/MAC/eNB_scheduler.c @@ -108,8 +108,7 @@ schedule_SRS(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP) if ((1 << tmp) & deltaTSFC) { // This is an SRS subframe, loop over UEs for (UE_id = 0; UE_id < NUMBER_OF_UE_MAX; UE_id++) { - if (RC.mac[module_idP]->UE_list.active[UE_id] != TRUE) - continue; + if (RC.mac[module_idP]->UE_list.active[UE_id] != TRUE) continue; ul_req = &RC.mac[module_idP]->UL_req[CC_id].ul_config_request_body; // drop the allocation if the UE hasn't send RRCConnectionSetupComplete yet if (mac_eNB_get_rrc_status(module_idP,UE_RNTI(module_idP, UE_id)) < RRC_CONNECTED) continue; @@ -124,6 +123,7 @@ schedule_SRS(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP) soundingRS_UL_ConfigDedicated->choice. setup.srs_ConfigIndex, &srsPeriodicity, &srsOffset); + if (((10 * frameP + subframeP) % srsPeriodicity) == srsOffset) { // Program SRS ul_req->srs_present = 1; @@ -262,7 +262,7 @@ schedule_SR(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP) ul_req_body = &ul_req->ul_config_request_body; // drop the allocation if the UE hasn't send RRCConnectionSetupComplete yet - if (mac_eNB_get_rrc_status(module_idP, UE_RNTI(module_idP, UE_id)) < RRC_CONNECTED) continue; + //if (mac_eNB_get_rrc_status(module_idP, UE_RNTI(module_idP, UE_id)) < RRC_CONNECTED) continue; AssertFatal(UE_list-> UE_template[CC_id][UE_id].physicalConfigDedicated!= NULL, diff --git a/openair2/LAYER2/MAC/eNB_scheduler_RA.c b/openair2/LAYER2/MAC/eNB_scheduler_RA.c index 408c93c45f..bf3baa898d 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_RA.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_RA.c @@ -1053,11 +1053,17 @@ generate_Msg4(module_id_t module_idP, int CC_idP, frame_t frameP, "Frame %d, Subframe %d: Preparing for Msg4 retransmission currently %d.%d\n", frameP, subframeP, ra->Msg4_frame, ra->Msg4_subframe); - if (ra->Msg4_subframe > 1) + if (cc[CC_idP].tdd_Config == NULL) { + if (ra->Msg4_subframe > 1) ra->Msg4_frame++; - ra->Msg4_frame &= 1023; - ra->Msg4_subframe = (ra->Msg4_subframe + 8) % 10; - LOG_D(MAC, + ra->Msg4_frame &= 1023; + ra->Msg4_subframe = (ra->Msg4_subframe + 8) % 10; + } + else { + ra->Msg4_frame++; + ra->Msg4_frame &= 1023; + } + LOG_I(MAC, "Frame %d, Subframe %d: Msg4 retransmission in %d.%d\n", frameP, subframeP, ra->Msg4_frame, ra->Msg4_subframe); @@ -1132,7 +1138,7 @@ generate_Msg4(module_id_t module_idP, int CC_idP, frame_t frameP, dl_req->sfn_sf = mac->TX_req[CC_idP].sfn_sf; - LOG_D(MAC, "Filling UCI ACK/NAK information, cce_idx %d\n", + LOG_I(MAC, "Filling UCI ACK/NAK information, cce_idx %d\n", dl_config_pdu->dci_dl_pdu.dci_dl_pdu_rel8.cce_idx); // Program PUCCH1a for ACK/NAK // Program ACK/NAK for Msg4 PDSCH @@ -1321,20 +1327,24 @@ check_Msg4_retransmission(module_id_t module_idP, int CC_idP, dci_dl_pdu_rel8.cce_idx); // prepare frame for retransmission - if (ra->Msg4_subframe > 1) + if (cc->tdd_Config==NULL) { + if (ra->Msg4_subframe > 1) ra->Msg4_frame++; - ra->Msg4_frame &= 1023; - ra->Msg4_subframe = (ra->Msg4_subframe + 8) % 10; - + ra->Msg4_frame &= 1023; + ra->Msg4_subframe = (ra->Msg4_subframe + 8) % 10; + } + else ra->Msg4_frame++; + LOG_W(MAC, "[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d: Msg4 not acknowledged, adding ue specific dci (rnti %x) for RA (Msg4 Retransmission round %d in %d.%d)\n", module_idP, CC_idP, frameP, subframeP, ra->rnti, round, ra->Msg4_frame, ra->Msg4_subframe); + AssertFatal(1==0,"Shouldn't happen exit\n"); } // Msg4 frame/subframe } // regular LTE case } else { - LOG_D(MAC, + LOG_I(MAC, "[eNB %d][RAPROC] CC_id %d Frame %d, subframeP %d : Msg4 acknowledged\n", module_idP, CC_idP, frameP, subframeP); ra->state = IDLE; @@ -1370,7 +1380,7 @@ schedule_RA(module_id_t module_idP, frame_t frameP, sub_frame_t subframeP) ra = (RA_t *) & cc[CC_id].ra[i]; - LOG_I(MAC,"RA[state:%d]\n",ra->state); + LOG_D(MAC,"RA[state:%d]\n",ra->state); if (ra->state == MSG2) generate_Msg2(module_idP, CC_id, frameP, subframeP, ra); diff --git a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c index 9803e71287..75e96b5a00 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c @@ -627,7 +627,7 @@ uint16_t get_pucch1_absSF(COMMON_channels_t * cc, uint16_t dlsch_absSF) case 3: if ((sf == 5) || (sf == 6) || (sf == 7) || (sf == 8) || (sf == 9)) - return ((10 * nextf) + (sf >> 1)); // ACK/NAK in 2,3,4 resp. next frame + return ((10 * nextf) + ((sf-1) >> 1)); // ACK/NAK in 2,3,4 resp. next frame else if (sf == 1) return ((10 * nextf) + 2); // ACK/NAK in 2 next frame else if (sf == 0) @@ -1380,7 +1380,7 @@ fill_nfapi_uci_acknak(module_id_t module_idP, rntiP, absSFP, &ul_config_pdu->uci_harq_pdu.harq_information, cce_idxP); - LOG_D(MAC, + LOG_I(MAC, "Filled in UCI HARQ request for rnti %x SF %d.%d acknakSF %d.%d, cce_idxP %d-> n1_pucch %d\n", rntiP, absSFP / 10, absSFP % 10, ackNAK_absSF / 10, ackNAK_absSF % 10, cce_idxP, @@ -3255,14 +3255,89 @@ extract_harq(module_id_t mod_idP, int CC_idP, int UE_id, AssertFatal(numCC == 1, "numCC %d > 1, should not be using Format1a/b\n", numCC); + + uint8_t harq_pid = ((10 * frameP) + subframeP + 10236) & 7; + + LOG_I(MAC,"frame %d subframe %d harq_pid %d mode %d tmode[0] %d num_ack_nak %d round %d\n",frameP,subframeP,harq_pid,harq_indication_fdd->mode,tmode[0],num_ack_nak,sched_ctl->round[CC_idP][harq_pid]); + + AssertFatal(numCC == 1, + "numCC %d > 1, should not be using Format1a/b\n", + numCC); + + + if (tmode[0] == 1 || tmode[0] == 2 || tmode[0] == 5 || tmode[0] == 6 || tmode[0] == 7) { // NOTE: have to handle the case of TM9-10 with 1 antenna port + // single ACK/NAK bit + AssertFatal(num_ack_nak == 1, + "num_ack_nak %d > 1 for 1 CC and single-layer transmission frame:%d subframe:%d\n", + num_ack_nak,frameP,subframeP); + AssertFatal(sched_ctl->round[CC_idP][harq_pid] < 8, + "Got ACK/NAK for inactive harq_pid %d for UE %d/%x\n", + harq_pid, UE_id, rnti); + AssertFatal(pdu[0] == 1 || pdu[0] == 2 + || pdu[0] == 4, + "Received ACK/NAK %d which is not 1 or 2 for harq_pid %d from UE %d/%x\n", + pdu[0], harq_pid, UE_id, rnti); + LOG_D(MAC, "Received %d for harq_pid %d\n", pdu[0], + harq_pid); + + pdu = &harq_indication_fdd->harq_data[0].bundling.value_0; + if (pdu[0] == 1) { // ACK + sched_ctl->round[CC_idP][harq_pid] = 8; // release HARQ process + sched_ctl->tbcnt[CC_idP][harq_pid] = 0; + } else if (pdu[0] == 2 || pdu[0] == 4) // NAK (treat DTX as NAK) + sched_ctl->round[CC_idP][harq_pid]++; // increment round + } else { + // one or two ACK/NAK bits + AssertFatal(num_ack_nak <= 2, + "num_ack_nak %d > 2 for 1 CC and TM3/4/8/9/10\n", + num_ack_nak); + if ((num_ack_nak == 2) + && (sched_ctl->round[CC_idP][harq_pid] < 8) + && (sched_ctl->tbcnt[CC_idP][harq_pid] == 1) + && (pdu[0] == 1) && (pdu[1] == 1)) { + sched_ctl->round[CC_idP][harq_pid] = 8; + sched_ctl->tbcnt[CC_idP][harq_pid] = 0; + } + if ((num_ack_nak == 2) + && (sched_ctl->round[CC_idP][harq_pid] < 8) + && (sched_ctl->tbcnt[CC_idP][harq_pid] == 1) + && (pdu[0] == 2) && (pdu[1] == 2)) + sched_ctl->round[CC_idP][harq_pid]++; + else if (((num_ack_nak == 2) + && (sched_ctl->round[CC_idP][harq_pid] < 8) + && (sched_ctl->tbcnt[0][harq_pid] == 2) + && (pdu[0] == 1) && (pdu[1] == 2)) + || ((num_ack_nak == 2) + && (sched_ctl->round[CC_idP][harq_pid] < 8) + && (sched_ctl->tbcnt[CC_idP][harq_pid] == 2) + && (pdu[0] == 2) && (pdu[1] == 1))) { + sched_ctl->round[CC_idP][harq_pid]++; + sched_ctl->tbcnt[CC_idP][harq_pid] = 1; + } else if ((num_ack_nak == 2) + && (sched_ctl->round[CC_idP][harq_pid] < 8) + && (sched_ctl->tbcnt[CC_idP][harq_pid] == 2) + && (pdu[0] == 2) && (pdu[1] == 2)) + sched_ctl->round[CC_idP][harq_pid]++; + else + AssertFatal(1 == 0, + "Illegal ACK/NAK/round combination (%d,%d,%d,%d,%d) for harq_pid %d, UE %d/%x\n", + num_ack_nak, + sched_ctl->round[CC_idP][harq_pid], + sched_ctl->round[CC_idP][harq_pid], pdu[0], + pdu[1], harq_pid, UE_id, rnti); + } + break; + case 1: // Channel Selection + AssertFatal(1==0,"Can't do channel selection yet in TDD\n"); break; - case 1: // Channel Selection + case 2: // Format 2 + AssertFatal(1==0,"Can't do Format 2 yet in TDD\n"); break; - case 2: // Format 3 - break; - case 3: // Format 4 + case 3: // Format 3 + AssertFatal(1==0,"Can't do Format 3 yet in TDD\n"); break; case 4: // Format 5 + AssertFatal(1==0,"Can't do Format 4 yet in TDD\n"); break; } } else { @@ -3272,7 +3347,7 @@ extract_harq(module_id_t mod_idP, int CC_idP, int UE_id, uint8_t harq_pid = ((10 * frameP) + subframeP + 10236) & 7; - LOG_D(MAC,"frame %d subframe %d harq_pid %d mode %d tmode[0] %d num_ack_nak %d round %d\n",frameP,subframeP,harq_pid,harq_indication_fdd->mode,tmode[0],num_ack_nak,sched_ctl->round[CC_idP][harq_pid]); + LOG_I(MAC,"frame %d subframe %d harq_pid %d mode %d tmode[0] %d num_ack_nak %d round %d\n",frameP,subframeP,harq_pid,harq_indication_fdd->mode,tmode[0],num_ack_nak,sched_ctl->round[CC_idP][harq_pid]); switch (harq_indication_fdd->mode) { case 0: // Format 1a/b (10.1.2.1) @@ -4026,8 +4101,12 @@ static int nack_or_dtx_reported( int i; if (cc->tdd_Config) { - AssertFatal(0==1, "TDD to be done. FAPI structures (see nfapi_harq_indication_tdd_rel13_t) are not clean. To be cleaned as well?\n"); - abort(); + LOG_W(MAC,"FAPI structures (see nfapi_harq_indication_tdd_rel13_t) are not clean. To be cleaned as well?\n"); + nfapi_harq_indication_tdd_rel13_t *hi = &harq_pdu->harq_indication_tdd_rel13; + for (i = 0; i < hi->number_of_ack_nack; hi++) + if (hi->harq_data[i].bundling.value_0 != 1) + return 1; + return 0; } else { nfapi_harq_indication_fdd_rel13_t *hi = &harq_pdu->harq_indication_fdd_rel13; for (i = 0; i < hi->number_of_ack_nack; hi++) @@ -4054,7 +4133,7 @@ harq_indication(module_id_t mod_idP, int CC_idP, frame_t frameP, UE_sched_ctrl *sched_ctl = &UE_list->UE_sched_ctrl[UE_id]; COMMON_channels_t *cc = &RC.mac[mod_idP]->common_channels[CC_idP]; // extract HARQ Information - LOG_D(MAC, + LOG_I(MAC, "Frame %d, subframe %d: Received harq indication (%d) from UE %d/%x, ul_cqi %d\n", frameP, subframeP, channel, UE_id, rnti, ul_cqi); if (cc->tdd_Config) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index acdcfe79e4..2ff0d677ae 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -160,8 +160,8 @@ rx_sdu(const module_id_t enb_mod_idP, if (UE_id != -1) { LOG_D(MAC, - "[eNB %d][PUSCH %d] CC_id %d Received ULSCH sdu round %d from PHY (rnti %x, UE_id %d) ul_cqi %d\n", - enb_mod_idP, harq_pid, CC_idP, + "[eNB %d][PUSCH %d] SFN.SF %d.%d : CC_id %d Received ULSCH sdu round %d from PHY (rnti %x, UE_id %d) ul_cqi %d\n", + enb_mod_idP, harq_pid, frameP,subframeP, CC_idP, UE_list->UE_sched_ctrl[UE_id].round_UL[CC_idP][harq_pid], current_rnti, UE_id, ul_cqi); @@ -225,8 +225,8 @@ rx_sdu(const module_id_t enb_mod_idP, maxHARQ_Msg3Tx); LOG_I(MAC, - "[eNB %d][PUSCH %d] CC_id %d [RAPROC Msg3] Received ULSCH sdu round %d from PHY (rnti %x, RA_id %d) ul_cqi %d\n", - enb_mod_idP, harq_pid, CC_idP, ra[RA_id].msg3_round, + "[eNB %d][PUSCH %d] SFN.SF %d.%d CC_id %d [RAPROC Msg3] : Received ULSCH sdu round %d from PHY (rnti %x, RA_id %d) ul_cqi %d\n", + enb_mod_idP, harq_pid, frameP,subframeP,CC_idP, ra[RA_id].msg3_round, current_rnti, RA_id, ul_cqi); first_rb = ra->msg3_first_rb; @@ -247,9 +247,15 @@ rx_sdu(const module_id_t enb_mod_idP, first_rb = UE_list->UE_template[CC_idP][UE_id].first_rb_ul[harq_pid]; ra[RA_id].msg3_round++; // prepare handling of retransmission - ra[RA_id].Msg3_frame = (ra[RA_id].Msg3_frame + ((ra[RA_id].Msg3_subframe > 1) ? 1 : 0)) % 1024; - ra[RA_id].Msg3_subframe = (ra[RA_id].Msg3_subframe + 8) % 10; - add_msg3(enb_mod_idP, CC_idP, &ra[RA_id], frameP, subframeP); + if (RC.mac[enb_mod_idP]->common_channels[CC_idP].tdd_Config == NULL) { + ra[RA_id].Msg3_frame = (ra[RA_id].Msg3_frame + ((ra[RA_id].Msg3_subframe > 1) ? 1 : 0)) % 1024; + ra[RA_id].Msg3_subframe = (ra[RA_id].Msg3_subframe + 8) % 10; + } + else { + ra[RA_id].Msg3_frame++; + ra[RA_id].Msg3_frame&=1023; + } + // add_msg3(enb_mod_idP, CC_idP, &ra[RA_id], frameP, subframeP); } return; } @@ -561,9 +567,10 @@ rx_sdu(const module_id_t enb_mod_idP, // Program Msg4 PDCCH+DLSCH/MPDCCH transmission 4 subframes from now, // Check if this is ok for BL/CE, or if the rule is different + // make sure this works for all TDD configurations! ra->Msg4_frame = frameP + ((subframeP > 5) ? 1 : 0); ra->Msg4_subframe = (subframeP + 4) % 10; - + } // if process is active } // loop on RA processes diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index a3637cebd1..8c0692e773 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -391,6 +391,8 @@ void eNB_top(PHY_VARS_eNB *eNB, int frame_rx, int subframe_rx, char *string) proc->frame_tx = proc_rxtx->frame_tx; proc_rxtx->timestamp_tx = proc->timestamp_tx; + LOG_I(PHY,"RXTX for TX: %d.%d, RX: %d.%d\n",proc_rxtx->frame_tx,proc_rxtx->subframe_tx,proc_rxtx->frame_rx,proc_rxtx->subframe_rx); + 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); } } diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index b5ce15a460..1ff4a2ab28 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -1648,8 +1648,8 @@ static void* ru_thread_control( void* param ) { } - AssertFatal((ru->rfdevice.trx_config_func(&ru->rfdevice,&ru->openair0_cfg)==0), - "Failed to configure RF device for RU %d\n",ru->idx); + if (ru->rfdevice.trx_config_func) AssertFatal((ru->rfdevice.trx_config_func(&ru->rfdevice,&ru->openair0_cfg)==0), + "Failed to configure RF device for RU %d\n",ru->idx); @@ -1908,7 +1908,6 @@ static void* ru_thread( void* param ) { LOG_D(PHY,"RU thread %d, frame %d, subframe %d \n", ru->idx,frame,subframe); - if ((ru->do_prach>0) && (is_prach_subframe(fp, proc->frame_rx, proc->subframe_rx)==1)) { wakeup_prach_ru(ru); } diff --git a/targets/SIMU/USER/oaisim.c b/targets/SIMU/USER/oaisim.c index 27ff0ffa64..cd3bc1794e 100644 --- a/targets/SIMU/USER/oaisim.c +++ b/targets/SIMU/USER/oaisim.c @@ -740,8 +740,8 @@ l2l1_task (void *args_p) while (all_done==0) { pthread_mutex_lock(&subframe_mutex); - int subframe_ru_mask_local = subframe_ru_mask; //((1<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; - - - } } } From d3938147725db69918d28cf89fbb093632caf474 Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Mon, 19 Mar 2018 10:28:16 +0100 Subject: [PATCH 52/88] bugfix: send UL NACK (on PHICH) at the right place The PHICH was not programmed for the last round (4) because it was not programmed in rx_sdu but in schedule_ulsch_rnti, only in case of a programmed retransmission (there is obviously no retransmission programmed after the last round). The case of Msg3 is not handled. To be done somehow. --- openair2/LAYER2/MAC/eNB_scheduler_ulsch.c | 32 +++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c index b4fb025ea4..9ccb0e66ab 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_ulsch.c @@ -212,6 +212,30 @@ rx_sdu(const module_id_t enb_mod_idP, UE_list->UE_template[CC_idP][UE_id].scheduled_ul_bytes = 0; } else UE_list->UE_sched_ctrl[UE_id].round_UL[CC_idP][harq_pid]++; + + first_rb = UE_list->UE_template[CC_idP][UE_id].first_rb_ul[harq_pid]; + + // Program NACK for PHICH + LOG_D(MAC, + "Programming PHICH NACK for rnti %x harq_pid %d (first_rb %d)\n", + current_rnti, harq_pid, first_rb); + nfapi_hi_dci0_request_t *hi_dci0_req = &mac->HI_DCI0_req[CC_idP]; + nfapi_hi_dci0_request_body_t *hi_dci0_req_body = &hi_dci0_req->hi_dci0_request_body; + nfapi_hi_dci0_request_pdu_t *hi_dci0_pdu = + &hi_dci0_req_body->hi_dci0_pdu_list[hi_dci0_req_body->number_of_dci + hi_dci0_req_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_HI_PDU_TYPE; + hi_dci0_pdu->pdu_size = 2 + sizeof(nfapi_hi_dci0_hi_pdu); + hi_dci0_pdu->hi_pdu.hi_pdu_rel8.tl.tag = NFAPI_HI_DCI0_REQUEST_HI_PDU_REL8_TAG; + hi_dci0_pdu->hi_pdu.hi_pdu_rel8.resource_block_start = first_rb; + hi_dci0_pdu->hi_pdu.hi_pdu_rel8.cyclic_shift_2_for_drms = 0; + hi_dci0_pdu->hi_pdu.hi_pdu_rel8.hi_value = 0; + hi_dci0_req_body->number_of_hi++; + hi_dci0_req_body->sfnsf = sfnsf_add_subframe(frameP,subframeP, 0); + hi_dci0_req_body->tl.tag = NFAPI_HI_DCI0_REQUEST_BODY_TAG; + hi_dci0_req->sfn_sf = sfnsf_add_subframe(frameP,subframeP, 4); + hi_dci0_req->header.message_id = NFAPI_HI_DCI0_REQUEST; + return; } @@ -251,6 +275,9 @@ rx_sdu(const module_id_t enb_mod_idP, ra[RA_id].Msg3_subframe = (ra[RA_id].Msg3_subframe + 8) % 10; add_msg3(enb_mod_idP, CC_idP, &ra[RA_id], frameP, subframeP); } + + /* TODO: program NACK for PHICH? */ + return; } } else { @@ -1448,6 +1475,10 @@ schedule_ulsch_rnti(module_id_t module_idP, T_INT(first_rb[CC_id]), T_INT(rb_table[rb_table_index]), T_INT(round)); +#if 0 + /* This is done in rx_sdu, as it has to. + * Since the code is a bit different, let's keep this version here for review, in case of problem. + */ // fill in NAK information hi_dci0_pdu = &hi_dci0_req_body->hi_dci0_pdu_list[hi_dci0_req_body->number_of_dci + hi_dci0_req_body->number_of_hi]; @@ -1471,6 +1502,7 @@ schedule_ulsch_rnti(module_id_t module_idP, UE_template->first_rb_ul[harq_pid], UE_template->nb_rb_ul[harq_pid], UE_template->TBS_UL[harq_pid], round); +#endif // Add UL_config PDUs LOG_D(MAC, "[PUSCH %d] Frame %d, Subframe %d: Adding UL CONFIG.Request for UE %d/%x, ulsch_frame %d, ulsch_subframe %d\n", From 318e4a345ec29d69837009d55395c44dfe666f1a Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Tue, 20 Mar 2018 14:41:58 +0100 Subject: [PATCH 53/88] free configmodule memory when shutting down It is possible to restart the lte-softmodem via the FlexRAN controller. For this to work, the end_configmodule() method needs to be called when shutting the lte-softmodem down so that the configuration can be read again during a restart. --- targets/RT/USER/lte-softmodem.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index 03313146df..29bbf44756 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -1209,9 +1209,6 @@ int main( int argc, char **argv ) sync_var=0; pthread_cond_broadcast(&sync_cond); pthread_mutex_unlock(&sync_mutex); - printf("About to call end_configmodule() from %s() %s:%d\n", __FUNCTION__, __FILE__, __LINE__); - end_configmodule(); - printf("Called end_configmodule() from %s() %s:%d\n", __FUNCTION__, __FILE__, __LINE__); // wait for end of program printf("TYPE TO TERMINATE\n"); @@ -1271,6 +1268,9 @@ int main( int argc, char **argv ) } free_lte_top(); + printf("About to call end_configmodule() from %s() %s:%d\n", __FUNCTION__, __FILE__, __LINE__); + end_configmodule(); + printf("Called end_configmodule() from %s() %s:%d\n", __FUNCTION__, __FILE__, __LINE__); pthread_cond_destroy(&sync_cond); pthread_mutex_destroy(&sync_mutex); From 846268fdd317ef2ed53f898de5c2b6842ac49b3e Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Tue, 20 Mar 2018 18:02:52 +0100 Subject: [PATCH 54/88] 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 e7a60fc992a7b8de4bc01be9bc9a1c3a5f6ad40b Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 22 Mar 2018 16:14:30 +0100 Subject: [PATCH 55/88] FlexRAN: make agent_id for identification purposes, discern from mod_id The agent_id is a uint64 consisting of: module ID (i.e. mod_id, the several instances of OAI at once, 16 bit), the enb_id from the configuration file (32 bit) and the cell_id from the configuration file (16 bit). The module ID is part of the agent ID but it is easier to have it directly in the struct. --- openair2/ENB_APP/enb_config.c | 110 +++++++++++++++++++++++--- openair2/ENB_APP/flexran_agent.c | 13 +-- openair2/ENB_APP/flexran_agent_defs.h | 17 ++-- 3 files changed, 110 insertions(+), 30 deletions(-) diff --git a/openair2/ENB_APP/enb_config.c b/openair2/ENB_APP/enb_config.c index 5e9c320f57..e0ab70154e 100644 --- a/openair2/ENB_APP/enb_config.c +++ b/openair2/ENB_APP/enb_config.c @@ -60,37 +60,121 @@ extern uint16_t sf_ahead; - void RCconfig_flexran() { - int i; + uint16_t i; + uint16_t num_enbs; + char aprefix[MAX_OPTNAME_SIZE*2 + 8]; + /* this will possibly truncate the cell id (RRC assumes int32_t). + * Both Nid_cell and enb_id are signed in RRC case, but we use unsigned for + * the bitshifting to work properly */ + int32_t Nid_cell = 0; + uint16_t Nid_cell_tr = 0; + uint32_t enb_id = 0; + + /* + * the only reason for all these variables is, that they are "hard-encoded" + * into the CCPARAMS_DESC macro and we need it for the Nid_cell variable ... + */ + char *frame_type, *prefix_type, *pbch_repetition, *prach_high_speed, + *pusch_hoppingMode, *pusch_enable64QAM, *pusch_groupHoppingEnabled, + *pusch_sequenceHoppingEnabled, *phich_duration, *phich_resource, + *srs_enable, *srs_ackNackST, *srs_MaxUpPts, *pusch_alpha, + *pucch_deltaF_Format1, *pucch_deltaF_Format1b, *pucch_deltaF_Format2, + *pucch_deltaF_Format2a, *pucch_deltaF_Format2b, + *rach_preamblesGroupAConfig, *rach_messagePowerOffsetGroupB, *pcch_nB; + long long int downlink_frequency; + int32_t tdd_config, tdd_config_s, eutra_band, uplink_frequency_offset, + Nid_cell_mbsfn, N_RB_DL, nb_antenna_ports, prach_root, prach_config_index, + prach_zero_correlation, prach_freq_offset, pucch_delta_shift, + pucch_nRB_CQI, pucch_nCS_AN, pucch_n1_AN, pdsch_referenceSignalPower, + pdsch_p_b, pusch_n_SB, pusch_hoppingOffset, pusch_groupAssignment, + pusch_nDMRS1, srs_BandwidthConfig, srs_SubframeConfig, pusch_p0_Nominal, + pucch_p0_Nominal, msg3_delta_Preamble, rach_numberOfRA_Preambles, + rach_sizeOfRA_PreamblesGroupA, rach_messageSizeGroupA, + rach_powerRampingStep, rach_preambleInitialReceivedTargetPower, + rach_preambleTransMax, rach_raResponseWindowSize, + rach_macContentionResolutionTimer, rach_maxHARQ_Msg3Tx, + pcch_defaultPagingCycle, bcch_modificationPeriodCoeff, + ue_TimersAndConstants_t300, ue_TimersAndConstants_t301, + ue_TimersAndConstants_t310, ue_TimersAndConstants_t311, + ue_TimersAndConstants_n310, ue_TimersAndConstants_n311, + ue_TransmissionMode; + + /* get number of eNBs */ + paramdef_t ENBSParams[] = ENBSPARAMS_DESC; + config_get(ENBSParams, sizeof(ENBSParams)/sizeof(paramdef_t), NULL); + num_enbs = ENBSParams[ENB_ACTIVE_ENBS_IDX].numelt; + + /* for eNB ID */ + paramdef_t ENBParams[] = ENBPARAMS_DESC; + paramlist_def_t ENBParamList = {ENB_CONFIG_STRING_ENB_LIST, NULL, 0}; + + /* for Nid_cell */ + checkedparam_t config_check_CCparams[] = CCPARAMS_CHECK; + paramdef_t CCsParams[] = CCPARAMS_DESC; + paramlist_def_t CCsParamList = {ENB_CONFIG_STRING_COMPONENT_CARRIERS, NULL, 0}; + /* map parameter checking array instances to parameter definition array instances */ + for (int I = 0; I < (sizeof(CCsParams) / sizeof(paramdef_t)); I++) { + CCsParams[I].chkPptr = &(config_check_CCparams[I]); + } paramdef_t flexranParams[] = FLEXRANPARAMS_DESC; config_get(flexranParams, sizeof(flexranParams)/sizeof(paramdef_t), CONFIG_STRING_NETWORK_CONTROLLER_CONFIG); if (!RC.flexran) { - RC.flexran = calloc(RC.nb_L1_inst, sizeof(flexran_agent_info_t*)); - AssertFatal(RC.flexran != NULL, + RC.flexran = calloc(num_enbs, sizeof(flexran_agent_info_t*)); + AssertFatal(RC.flexran, "can't ALLOCATE %zu Bytes for %d flexran agent info with size %zu\n", - RC.nb_L1_inst * sizeof(flexran_agent_info_t*), - RC.nb_L1_inst, sizeof(flexran_agent_info_t*)); + num_enbs * sizeof(flexran_agent_info_t*), + num_enbs, sizeof(flexran_agent_info_t*)); } - /* For all agent instance, fill in the same controller configuration. */ - for (i = 0; i < RC.nb_L1_inst; i++) { + for (i = 0; i < num_enbs; i++) { RC.flexran[i] = calloc(1, sizeof(flexran_agent_info_t)); - AssertFatal(RC.flexran[i] != NULL, + AssertFatal(RC.flexran[i], "can't ALLOCATE %zu Bytes for flexran agent info (iteration %d/%d)\n", - sizeof(flexran_agent_info_t), i + 1, RC.nb_L1_inst); + sizeof(flexran_agent_info_t), i + 1, num_enbs); /* if config says "yes", enable Agent, in all other cases it's like "no" */ - RC.flexran[i]->enabled = strcmp(*(flexranParams[FLEXRAN_ENABLED].strptr), "yes") == 0; + RC.flexran[i]->enabled = strcasecmp(*(flexranParams[FLEXRAN_ENABLED].strptr), "yes") == 0; RC.flexran[i]->interface_name = strdup(*(flexranParams[FLEXRAN_INTERFACE_NAME_IDX].strptr)); //inet_ntop(AF_INET, &(enb_properties->properties[mod_id]->flexran_agent_ipv4_address), in_ip, INET_ADDRSTRLEN); RC.flexran[i]->remote_ipv4_addr = strdup(*(flexranParams[FLEXRAN_IPV4_ADDRESS_IDX].strptr)); RC.flexran[i]->remote_port = *(flexranParams[FLEXRAN_PORT_IDX].uptr); RC.flexran[i]->cache_name = strdup(*(flexranParams[FLEXRAN_CACHE_IDX].strptr)); - RC.flexran[i]->node_ctrl_state = strcmp(*(flexranParams[FLEXRAN_AWAIT_RECONF_IDX].strptr), "yes") == 0 ? ENB_WAIT : ENB_NORMAL_OPERATION; - RC.flexran[i]->enb_id = i; + RC.flexran[i]->node_ctrl_state = strcasecmp(*(flexranParams[FLEXRAN_AWAIT_RECONF_IDX].strptr), "yes") == 0 ? ENB_WAIT : ENB_NORMAL_OPERATION; + + config_getlist(&ENBParamList, ENBParams, sizeof(ENBParams)/sizeof(paramdef_t),NULL); + /* eNB ID from configuration, as read in by RCconfig_RRC() */ + if (!ENBParamList.paramarray[i][ENB_ENB_ID_IDX].uptr) { + // Calculate a default eNB ID +# if defined(ENABLE_USE_MME) + enb_id = i + (s1ap_generate_eNB_id () & 0xFFFF8); +# else + enb_id = i; +# endif + } else { + enb_id = *(ENBParamList.paramarray[i][ENB_ENB_ID_IDX].uptr); + } + + /* cell ID */ + sprintf(aprefix, "%s.[%i]", ENB_CONFIG_STRING_ENB_LIST, i); + config_getlist(&CCsParamList, NULL, 0, aprefix); + if (CCsParamList.numelt > 0) { + sprintf(aprefix, "%s.[%i].%s.[%i]", ENB_CONFIG_STRING_ENB_LIST, i, ENB_CONFIG_STRING_COMPONENT_CARRIERS, 0); + config_get(CCsParams, sizeof(CCsParams)/sizeof(paramdef_t), aprefix); + Nid_cell_tr = (uint16_t) Nid_cell; + } + + RC.flexran[i]->mod_id = i; + RC.flexran[i]->agent_id = (((uint64_t)i) << 48) | (((uint64_t)enb_id) << 16) | ((uint64_t)Nid_cell_tr); + + /* assume for the moment the monolithic case, i.e. agent can provide + * information for all layers */ + RC.flexran[i]->capability_mask = FLEXRAN_CAP_LOPHY | FLEXRAN_CAP_HIPHY + | FLEXRAN_CAP_LOMAC | FLEXRAN_CAP_HIMAC + | FLEXRAN_CAP_RLC | FLEXRAN_CAP_PDCP + | FLEXRAN_CAP_SDAP | FLEXRAN_CAP_RRC; } } diff --git a/openair2/ENB_APP/flexran_agent.c b/openair2/ENB_APP/flexran_agent.c index bd46ecc49d..8d5cdbc06b 100644 --- a/openair2/ENB_APP/flexran_agent.c +++ b/openair2/ENB_APP/flexran_agent.c @@ -114,12 +114,12 @@ void *receive_thread(void *args) { while (1) { - while (flexran_agent_msg_recv(d->enb_id, FLEXRAN_AGENT_DEFAULT, &data, &size, &priority) == 0) { + while (flexran_agent_msg_recv(d->mod_id, FLEXRAN_AGENT_DEFAULT, &data, &size, &priority) == 0) { LOG_D(FLEXRAN_AGENT,"received message with size %d\n", size); // Invoke the message handler - msg=flexran_agent_handle_message(d->enb_id, data, size); + msg=flexran_agent_handle_message(d->mod_id, data, size); free(data); @@ -127,7 +127,7 @@ void *receive_thread(void *args) { if (msg != NULL){ data=flexran_agent_pack_message(msg,&size); - if (flexran_agent_msg_send(d->enb_id, FLEXRAN_AGENT_DEFAULT, data, size, priority)) { + if (flexran_agent_msg_send(d->mod_id, FLEXRAN_AGENT_DEFAULT, data, size, priority)) { err_code = PROTOCOL__FLEXRAN_ERR__MSG_ENQUEUING; goto error; } @@ -190,13 +190,6 @@ int flexran_agent_start(mid_t mod_id) LOG_I(FLEXRAN_AGENT, "FlexRAN Agent for eNB %d is DISABLED\n", mod_id); return 100; } - - flexran->enb_id = mod_id; - /* assume for the moment the monolithic case, i.e. agent can provide - * information for all layers */ - flexran->capability_mask = FLEXRAN_CAP_LOL1 | FLEXRAN_CAP_HIL1 - | FLEXRAN_CAP_LOL2 | FLEXRAN_CAP_HIL2 - | FLEXRAN_CAP_PDCP | FLEXRAN_CAP_RRC; /* * Initialize the channel container diff --git a/openair2/ENB_APP/flexran_agent_defs.h b/openair2/ENB_APP/flexran_agent_defs.h index 6364bc6281..aa71dd33fa 100644 --- a/openair2/ENB_APP/flexran_agent_defs.h +++ b/openair2/ENB_APP/flexran_agent_defs.h @@ -138,12 +138,14 @@ typedef enum { FLEXRAN_AGENT_TIMER_STATE_MAX, } flexran_agent_timer_state_t; -#define FLEXRAN_CAP_LOL1 0x1 -#define FLEXRAN_CAP_HIL1 0x2 -#define FLEXRAN_CAP_LOL2 0x4 // is: MAC -#define FLEXRAN_CAP_HIL2 0x8 // is: RLC -#define FLEXRAN_CAP_PDCP 0x16 -#define FLEXRAN_CAP_RRC 0x32 +#define FLEXRAN_CAP_LOPHY 1 +#define FLEXRAN_CAP_HIPHY 2 +#define FLEXRAN_CAP_LOMAC 4 +#define FLEXRAN_CAP_HIMAC 8 +#define FLEXRAN_CAP_RLC 16 +#define FLEXRAN_CAP_PDCP 32 +#define FLEXRAN_CAP_SDAP 64 +#define FLEXRAN_CAP_RRC 128 typedef enum { ENB_NORMAL_OPERATION = 0x0, @@ -159,7 +161,8 @@ typedef struct { uint16_t remote_port; char *cache_name; - int enb_id; + mid_t mod_id; + uint64_t agent_id; uint8_t capability_mask; /* lock for waiting before starting or soft-restart */ From 1854826053939de6fad8640565d40c152c3a30a0 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 22 Mar 2018 16:40:08 +0100 Subject: [PATCH 56/88] FlexRAN: send agent_id (aka enb_id) --- openair2/ENB_APP/MESSAGES/V2/flexran.proto | 2 +- openair2/ENB_APP/flexran_agent_common.c | 104 ++++++++++----------- 2 files changed, 52 insertions(+), 54 deletions(-) diff --git a/openair2/ENB_APP/MESSAGES/V2/flexran.proto b/openair2/ENB_APP/MESSAGES/V2/flexran.proto index b54fc171c6..9255372340 100644 --- a/openair2/ENB_APP/MESSAGES/V2/flexran.proto +++ b/openair2/ENB_APP/MESSAGES/V2/flexran.proto @@ -131,7 +131,7 @@ message flex_enb_config_request { message flex_enb_config_reply { optional flex_header header = 1; - optional uint32 eNB_id = 2; // Unique id to distinguish the eNB + optional uint64 eNB_id = 2; // Unique id to distinguish the eNB repeated flex_cell_config cell_config = 3; optional uint32 device_spec = 4; } diff --git a/openair2/ENB_APP/flexran_agent_common.c b/openair2/ENB_APP/flexran_agent_common.c index 6d32aeedbb..a7f74c1f22 100644 --- a/openair2/ENB_APP/flexran_agent_common.c +++ b/openair2/ENB_APP/flexran_agent_common.c @@ -804,7 +804,6 @@ int flexran_agent_enb_config_reply(mid_t mod_id, const void *params, Protocol__F xid = (enb_config_req_msg->header)->xid; int i, j; - int enb_id = mod_id; Protocol__FlexEnbConfigReply *enb_config_reply_msg; enb_config_reply_msg = malloc(sizeof(Protocol__FlexEnbConfigReply)); @@ -816,10 +815,10 @@ int flexran_agent_enb_config_reply(mid_t mod_id, const void *params, Protocol__F goto error; enb_config_reply_msg->header = header; - - enb_config_reply_msg->enb_id = mod_id; - - + + enb_config_reply_msg->enb_id = RC.flexran[mod_id]->agent_id; + enb_config_reply_msg->has_enb_id = 1; + enb_config_reply_msg->n_cell_config = MAX_NUM_CCs; Protocol__FlexCellConfig **cell_conf; @@ -832,43 +831,43 @@ int flexran_agent_enb_config_reply(mid_t mod_id, const void *params, Protocol__F protocol__flex_cell_config__init(cell_conf[i]); cell_conf[i]->phy_cell_id = 1; - cell_conf[i]->has_phy_cell_id = flexran_get_cell_id(enb_id,i); + cell_conf[i]->has_phy_cell_id = flexran_get_cell_id(mod_id,i); cell_conf[i]->cell_id = i; cell_conf[i]->has_cell_id = 1; - cell_conf[i]->pusch_hopping_offset = flexran_get_hopping_offset(enb_id,i); + cell_conf[i]->pusch_hopping_offset = flexran_get_hopping_offset(mod_id,i); cell_conf[i]->has_pusch_hopping_offset = 1; - if (flexran_get_hopping_mode(enb_id,i) == 0) { + if (flexran_get_hopping_mode(mod_id,i) == 0) { cell_conf[i]->hopping_mode = PROTOCOL__FLEX_HOPPING_MODE__FLHM_INTER; - } else if(flexran_get_hopping_mode(enb_id,i) == 1) { + } else if(flexran_get_hopping_mode(mod_id,i) == 1) { cell_conf[i]->hopping_mode = PROTOCOL__FLEX_HOPPING_MODE__FLHM_INTERINTRA; } cell_conf[i]->has_hopping_mode = 1; - cell_conf[i]->n_sb = flexran_get_n_SB(enb_id,i); + cell_conf[i]->n_sb = flexran_get_n_SB(mod_id,i); cell_conf[i]->has_n_sb = 1; - if (flexran_get_phich_resource(enb_id,i) == 0) { + if (flexran_get_phich_resource(mod_id,i) == 0) { cell_conf[i]->phich_resource = PROTOCOL__FLEX_PHICH_RESOURCE__FLPR_ONE_SIXTH; //0 - } else if (flexran_get_phich_resource(enb_id,i) == 1) { + } else if (flexran_get_phich_resource(mod_id,i) == 1) { cell_conf[i]->phich_resource = PROTOCOL__FLEX_PHICH_RESOURCE__FLPR_HALF; //1 - } else if (flexran_get_phich_resource(enb_id,i) == 2) { + } else if (flexran_get_phich_resource(mod_id,i) == 2) { cell_conf[i]->phich_resource = PROTOCOL__FLEX_PHICH_RESOURCE__FLPR_ONE; // 2 - } else if (flexran_get_phich_resource(enb_id,i) == 3) { + } else if (flexran_get_phich_resource(mod_id,i) == 3) { cell_conf[i]->phich_resource = PROTOCOL__FLEX_PHICH_RESOURCE__FLPR_TWO;//3 } cell_conf[i]->has_phich_resource = 1; - if (flexran_get_phich_duration(enb_id,i) == 0) { + if (flexran_get_phich_duration(mod_id,i) == 0) { cell_conf[i]->phich_duration = PROTOCOL__FLEX_PHICH_DURATION__FLPD_NORMAL; - } else if(flexran_get_phich_duration(enb_id,i) == 1) { + } else if(flexran_get_phich_duration(mod_id,i) == 1) { cell_conf[i]->phich_duration = PROTOCOL__FLEX_PHICH_DURATION__FLPD_EXTENDED; } cell_conf[i]->has_phich_duration = 1; //TODO: Fill in with actual value, See TS 36.211, section 6.9 - cell_conf[i]->init_nr_pdcch_ofdm_sym = flexran_get_num_pdcch_symb(enb_id,i); + cell_conf[i]->init_nr_pdcch_ofdm_sym = flexran_get_num_pdcch_symb(mod_id,i); cell_conf[i]->has_init_nr_pdcch_ofdm_sym = 0; //TODO: Fill in with actual value /* Protocol__FlexSiConfig *si_config; */ @@ -880,10 +879,10 @@ int flexran_agent_enb_config_reply(mid_t mod_id, const void *params, Protocol__F /* si_config->sfn = 1; */ /* si_config->has_sfn = 1; */ /* //TODO: Fill in with actual value, the length of SIB1 in bytes */ - /* si_config->sib1_length = get_sib1_length(enb_id,i); */ + /* si_config->sib1_length = get_sib1_length(mod_id,i); */ /* si_config->has_sib1_length = 1; */ /* //TODO: Fill in with actual value, Scheduling window for all SIs in SF */ - /* si_config->si_window_length = (uint32_t) get_si_window_length(enb_id,i); */ + /* si_config->si_window_length = (uint32_t) get_si_window_length(mod_id,i); */ /* si_config->has_si_window_length = 1; */ /* //TODO: Fill in with actual value, the number of SI messages */ /* si_config->n_si_message=1; */ @@ -908,22 +907,22 @@ int flexran_agent_enb_config_reply(mid_t mod_id, const void *params, Protocol__F /* } */ /* cell_conf[i]->si_config = si_config; */ - cell_conf[i]->dl_bandwidth = flexran_get_N_RB_DL(enb_id,i); + cell_conf[i]->dl_bandwidth = flexran_get_N_RB_DL(mod_id,i); cell_conf[i]->has_dl_bandwidth = 1; - cell_conf[i]->ul_bandwidth = flexran_get_N_RB_UL(enb_id,i); + cell_conf[i]->ul_bandwidth = flexran_get_N_RB_UL(mod_id,i); cell_conf[i]->has_ul_bandwidth = 1; - if (flexran_get_ul_cyclic_prefix_length(enb_id, i) == 0) { + if (flexran_get_ul_cyclic_prefix_length(mod_id, i) == 0) { cell_conf[i]->ul_cyclic_prefix_length = PROTOCOL__FLEX_UL_CYCLIC_PREFIX_LENGTH__FLUCPL_NORMAL; - } else if(flexran_get_ul_cyclic_prefix_length(enb_id, i) == 1) { - cell_conf[i]->ul_cyclic_prefix_length = PROTOCOL__FLEX_UL_CYCLIC_PREFIX_LENGTH__FLUCPL_EXTENDED; + } else if(flexran_get_ul_cyclic_prefix_length(mod_id, i) == 1) { + cell_conf[i]->ul_cyclic_prefix_length = PROTOCOL__FLEX_UL_CYCLIC_PREFIX_LENGTH__FLUCPL_EXTENDED; } cell_conf[i]->has_ul_cyclic_prefix_length = 1; - if (flexran_get_ul_cyclic_prefix_length(enb_id,i) == 0) { + if (flexran_get_ul_cyclic_prefix_length(mod_id,i) == 0) { cell_conf[i]->ul_cyclic_prefix_length = PROTOCOL__FLEX_DL_CYCLIC_PREFIX_LENGTH__FLDCPL_NORMAL; - } else if (flexran_get_ul_cyclic_prefix_length(enb_id,i) == 1) { + } else if (flexran_get_ul_cyclic_prefix_length(mod_id,i) == 1) { cell_conf[i]->ul_cyclic_prefix_length = PROTOCOL__FLEX_DL_CYCLIC_PREFIX_LENGTH__FLDCPL_EXTENDED; } @@ -932,17 +931,17 @@ int flexran_agent_enb_config_reply(mid_t mod_id, const void *params, Protocol__F cell_conf[i]->antenna_ports_count = 1; cell_conf[i]->has_antenna_ports_count = 1; - if (flexran_get_duplex_mode(enb_id,i) == 1) { + if (flexran_get_duplex_mode(mod_id,i) == 1) { cell_conf[i]->duplex_mode = PROTOCOL__FLEX_DUPLEX_MODE__FLDM_FDD; - } else if(flexran_get_duplex_mode(enb_id,i) == 0) { + } else if(flexran_get_duplex_mode(mod_id,i) == 0) { cell_conf[i]->duplex_mode = PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD; } cell_conf[i]->has_duplex_mode = 1; //TODO: Fill in with actual value, DL/UL subframe assignment. TDD only - cell_conf[i]->subframe_assignment = flexran_get_subframe_assignment(enb_id, i); + cell_conf[i]->subframe_assignment = flexran_get_subframe_assignment(mod_id, i); cell_conf[i]->has_subframe_assignment = 0; //TODO: Fill in with actual value, TDD only. See TS 36.211, table 4.2.1 - cell_conf[i]->special_subframe_patterns = flexran_get_special_subframe_assignment(enb_id,i); + cell_conf[i]->special_subframe_patterns = flexran_get_special_subframe_assignment(mod_id,i); cell_conf[i]->has_special_subframe_patterns = 0; //TODO: Fill in with actual value, The MBSFN radio frame period cell_conf[i]->n_mbsfn_subframe_config_rfperiod = 0; @@ -954,7 +953,7 @@ int flexran_agent_enb_config_reply(mid_t mod_id, const void *params, Protocol__F elem_rfperiod[j] = 1; } cell_conf[i]->mbsfn_subframe_config_rfperiod = elem_rfperiod; - + //TODO: Fill in with actual value, The MBSFN radio frame offset cell_conf[i]->n_mbsfn_subframe_config_rfoffset = 0; uint32_t *elem_rfoffset; @@ -965,7 +964,7 @@ int flexran_agent_enb_config_reply(mid_t mod_id, const void *params, Protocol__F elem_rfoffset[j] = 1; } cell_conf[i]->mbsfn_subframe_config_rfoffset = elem_rfoffset; - + //TODO: Fill in with actual value, Bitmap indicating the MBSFN subframes cell_conf[i]->n_mbsfn_subframe_config_sfalloc = 0; uint32_t *elem_sfalloc; @@ -976,63 +975,62 @@ int flexran_agent_enb_config_reply(mid_t mod_id, const void *params, Protocol__F elem_sfalloc[j] = 1; } cell_conf[i]->mbsfn_subframe_config_sfalloc = elem_sfalloc; - - cell_conf[i]->prach_config_index = flexran_get_prach_ConfigIndex(enb_id,i); + + cell_conf[i]->prach_config_index = flexran_get_prach_ConfigIndex(mod_id,i); cell_conf[i]->has_prach_config_index = 1; - cell_conf[i]->prach_freq_offset = flexran_get_prach_FreqOffset(enb_id,i); + cell_conf[i]->prach_freq_offset = flexran_get_prach_FreqOffset(mod_id,i); cell_conf[i]->has_prach_freq_offset = 1; - cell_conf[i]->ra_response_window_size = flexran_get_ra_ResponseWindowSize(enb_id,i); + cell_conf[i]->ra_response_window_size = flexran_get_ra_ResponseWindowSize(mod_id,i); cell_conf[i]->has_ra_response_window_size = 1; - cell_conf[i]->mac_contention_resolution_timer = flexran_get_mac_ContentionResolutionTimer(enb_id,i); + cell_conf[i]->mac_contention_resolution_timer = flexran_get_mac_ContentionResolutionTimer(mod_id,i); cell_conf[i]->has_mac_contention_resolution_timer = 1; - cell_conf[i]->max_harq_msg3tx = flexran_get_maxHARQ_Msg3Tx(enb_id,i); + cell_conf[i]->max_harq_msg3tx = flexran_get_maxHARQ_Msg3Tx(mod_id,i); cell_conf[i]->has_max_harq_msg3tx = 1; - cell_conf[i]->n1pucch_an = flexran_get_n1pucch_an(enb_id,i); + cell_conf[i]->n1pucch_an = flexran_get_n1pucch_an(mod_id,i); cell_conf[i]->has_n1pucch_an = 1; - cell_conf[i]->deltapucch_shift = flexran_get_deltaPUCCH_Shift(enb_id,i); + cell_conf[i]->deltapucch_shift = flexran_get_deltaPUCCH_Shift(mod_id,i); cell_conf[i]->has_deltapucch_shift = 1; - cell_conf[i]->nrb_cqi = flexran_get_nRB_CQI(enb_id,i); + cell_conf[i]->nrb_cqi = flexran_get_nRB_CQI(mod_id,i); cell_conf[i]->has_nrb_cqi = 1; - cell_conf[i]->srs_subframe_config = flexran_get_srs_SubframeConfig(enb_id,i); + cell_conf[i]->srs_subframe_config = flexran_get_srs_SubframeConfig(mod_id,i); cell_conf[i]->has_srs_subframe_config = 1; - cell_conf[i]->srs_bw_config = flexran_get_srs_BandwidthConfig(enb_id,i); + cell_conf[i]->srs_bw_config = flexran_get_srs_BandwidthConfig(mod_id,i); cell_conf[i]->has_srs_bw_config = 1; - cell_conf[i]->srs_mac_up_pts = flexran_get_srs_MaxUpPts(enb_id,i); + cell_conf[i]->srs_mac_up_pts = flexran_get_srs_MaxUpPts(mod_id,i); cell_conf[i]->has_srs_mac_up_pts = 1; - cell_conf[i]->dl_freq = flexran_agent_get_operating_dl_freq (enb_id,i); + cell_conf[i]->dl_freq = flexran_agent_get_operating_dl_freq (mod_id,i); cell_conf[i]->has_dl_freq = 1; - cell_conf[i]->ul_freq = flexran_agent_get_operating_ul_freq (enb_id, i); + cell_conf[i]->ul_freq = flexran_agent_get_operating_ul_freq (mod_id, i); cell_conf[i]->has_ul_freq = 1; - cell_conf[i]->eutra_band = flexran_agent_get_operating_eutra_band (enb_id,i); + cell_conf[i]->eutra_band = flexran_agent_get_operating_eutra_band (mod_id,i); cell_conf[i]->has_eutra_band = 1; - cell_conf[i]->dl_pdsch_power = flexran_agent_get_operating_pdsch_refpower(enb_id, i); + cell_conf[i]->dl_pdsch_power = flexran_agent_get_operating_pdsch_refpower(mod_id, i); cell_conf[i]->has_dl_pdsch_power = 1; - cell_conf[i]->ul_pusch_power = flexran_agent_get_operating_pusch_p0 (enb_id,i); + cell_conf[i]->ul_pusch_power = flexran_agent_get_operating_pusch_p0 (mod_id,i); cell_conf[i]->has_ul_pusch_power = 1; - - if (flexran_get_enable64QAM(enb_id,i) == 0) { + if (flexran_get_enable64QAM(mod_id,i) == 0) { cell_conf[i]->enable_64qam = PROTOCOL__FLEX_QAM__FLEQ_MOD_16QAM; - } else if(flexran_get_enable64QAM(enb_id,i) == 1) { + } else if(flexran_get_enable64QAM(mod_id,i) == 1) { cell_conf[i]->enable_64qam = PROTOCOL__FLEX_QAM__FLEQ_MOD_64QAM; } cell_conf[i]->has_enable_64qam = 1; - + cell_conf[i]->carrier_index = i; cell_conf[i]->has_carrier_index = 1; } From d54d41512576c78741db2388d3922c0d0d77b524 Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Thu, 22 Mar 2018 17:47:18 +0100 Subject: [PATCH 57/88] FlexRAN: add Information in enb_config_reply msg --- openair2/ENB_APP/flexran_agent_common.c | 51 ++++++++++++------------- 1 file changed, 24 insertions(+), 27 deletions(-) diff --git a/openair2/ENB_APP/flexran_agent_common.c b/openair2/ENB_APP/flexran_agent_common.c index a7f74c1f22..4b0a22300f 100644 --- a/openair2/ENB_APP/flexran_agent_common.c +++ b/openair2/ENB_APP/flexran_agent_common.c @@ -866,26 +866,25 @@ int flexran_agent_enb_config_reply(mid_t mod_id, const void *params, Protocol__F cell_conf[i]->phich_duration = PROTOCOL__FLEX_PHICH_DURATION__FLPD_EXTENDED; } cell_conf[i]->has_phich_duration = 1; - //TODO: Fill in with actual value, See TS 36.211, section 6.9 cell_conf[i]->init_nr_pdcch_ofdm_sym = flexran_get_num_pdcch_symb(mod_id,i); - cell_conf[i]->has_init_nr_pdcch_ofdm_sym = 0; - //TODO: Fill in with actual value - /* Protocol__FlexSiConfig *si_config; */ - /* si_config = malloc(sizeof(Protocol__FlexSiConfig)); */ - /* if(si_config == NULL) */ - /* goto error; */ - /* protocol__flex_si_config__init(si_config); */ - /* //TODO: Fill in with actual value, Frame number to apply the SI configuration */ - /* si_config->sfn = 1; */ - /* si_config->has_sfn = 1; */ - /* //TODO: Fill in with actual value, the length of SIB1 in bytes */ - /* si_config->sib1_length = get_sib1_length(mod_id,i); */ - /* si_config->has_sib1_length = 1; */ - /* //TODO: Fill in with actual value, Scheduling window for all SIs in SF */ - /* si_config->si_window_length = (uint32_t) get_si_window_length(mod_id,i); */ - /* si_config->has_si_window_length = 1; */ - /* //TODO: Fill in with actual value, the number of SI messages */ - /* si_config->n_si_message=1; */ + cell_conf[i]->has_init_nr_pdcch_ofdm_sym = 1; + Protocol__FlexSiConfig *si_config; + si_config = malloc(sizeof(Protocol__FlexSiConfig)); + if(si_config == NULL) + goto error; + protocol__flex_si_config__init(si_config); + + si_config->sfn = flexran_get_current_system_frame_num(mod_id); + si_config->has_sfn = 1; + + si_config->sib1_length = flexran_get_sib1_length(mod_id,i); + si_config->has_sib1_length = 1; + + si_config->si_window_length = (uint32_t) flexran_get_si_window_length(mod_id, i); + si_config->has_si_window_length = 1; + + si_config->n_si_message = 0; + /* Protocol__FlexSiMessage **si_message; */ /* si_message = malloc(sizeof(Protocol__FlexSiMessage *) * si_config->n_si_message); */ /* if(si_message == NULL) */ @@ -905,8 +904,9 @@ int flexran_agent_enb_config_reply(mid_t mod_id, const void *params, Protocol__F /* if(si_config->n_si_message > 0){ */ /* si_config->si_message = si_message; */ /* } */ - /* cell_conf[i]->si_config = si_config; */ - + + cell_conf[i]->si_config = si_config; + cell_conf[i]->dl_bandwidth = flexran_get_N_RB_DL(mod_id,i); cell_conf[i]->has_dl_bandwidth = 1; @@ -927,8 +927,7 @@ int flexran_agent_enb_config_reply(mid_t mod_id, const void *params, Protocol__F } cell_conf[i]->has_dl_cyclic_prefix_length = 1; - //TODO: Fill in with actual value, number of cell specific antenna ports. Currently single port support - cell_conf[i]->antenna_ports_count = 1; + cell_conf[i]->antenna_ports_count = flexran_get_antenna_ports(mod_id, i); cell_conf[i]->has_antenna_ports_count = 1; if (flexran_get_duplex_mode(mod_id,i) == 1) { @@ -937,12 +936,10 @@ int flexran_agent_enb_config_reply(mid_t mod_id, const void *params, Protocol__F cell_conf[i]->duplex_mode = PROTOCOL__FLEX_DUPLEX_MODE__FLDM_TDD; } cell_conf[i]->has_duplex_mode = 1; - //TODO: Fill in with actual value, DL/UL subframe assignment. TDD only cell_conf[i]->subframe_assignment = flexran_get_subframe_assignment(mod_id, i); - cell_conf[i]->has_subframe_assignment = 0; - //TODO: Fill in with actual value, TDD only. See TS 36.211, table 4.2.1 + cell_conf[i]->has_subframe_assignment = 1; cell_conf[i]->special_subframe_patterns = flexran_get_special_subframe_assignment(mod_id,i); - cell_conf[i]->has_special_subframe_patterns = 0; + cell_conf[i]->has_special_subframe_patterns = 1; //TODO: Fill in with actual value, The MBSFN radio frame period cell_conf[i]->n_mbsfn_subframe_config_rfperiod = 0; uint32_t *elem_rfperiod; From 9c47c860bcce8902ba714b96173dfaa65757322f Mon Sep 17 00:00:00 2001 From: Robert Schmidt Date: Fri, 23 Mar 2018 09:20:19 +0100 Subject: [PATCH 58/88] FlexRAN: RCconfig_flexran(): only read necessary information if the FlexRAN agent is disabled, do not read all the data and skip reading of more information --- openair2/ENB_APP/enb_config.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/openair2/ENB_APP/enb_config.c b/openair2/ENB_APP/enb_config.c index e0ab70154e..aa5bbdb3c7 100644 --- a/openair2/ENB_APP/enb_config.c +++ b/openair2/ENB_APP/enb_config.c @@ -137,6 +137,9 @@ void RCconfig_flexran() sizeof(flexran_agent_info_t), i + 1, num_enbs); /* if config says "yes", enable Agent, in all other cases it's like "no" */ RC.flexran[i]->enabled = strcasecmp(*(flexranParams[FLEXRAN_ENABLED].strptr), "yes") == 0; + /* if not enabled, simply skip the rest, it is not needed anyway */ + if (!RC.flexran[i]->enabled) + continue; RC.flexran[i]->interface_name = strdup(*(flexranParams[FLEXRAN_INTERFACE_NAME_IDX].strptr)); //inet_ntop(AF_INET, &(enb_properties->properties[mod_id]->flexran_agent_ipv4_address), in_ip, INET_ADDRSTRLEN); RC.flexran[i]->remote_ipv4_addr = strdup(*(flexranParams[FLEXRAN_IPV4_ADDRESS_IDX].strptr)); From 5fdc3077db40c461c8aac2cc7afd402d01bec77b Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Fri, 23 Mar 2018 10:07:47 +0100 Subject: [PATCH 59/88] disable U-plane inactivity timer. It is annoying and does not seem to work properly. To be checked/reworked if needed. Keep in mind that we also want oaisim to be functional. --- openair2/LAYER2/MAC/eNB_scheduler.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/openair2/LAYER2/MAC/eNB_scheduler.c b/openair2/LAYER2/MAC/eNB_scheduler.c index a7c79a70d5..8dab2a9b71 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler.c +++ b/openair2/LAYER2/MAC/eNB_scheduler.c @@ -423,12 +423,15 @@ check_ul_failure(module_id_t module_idP, int CC_id, int UE_id, } } // ul_failure_timer>0 +#if 0 + /* U-plane inactivity timer is disabled. Uncomment to re-enable. */ UE_list->UE_sched_ctrl[UE_id].uplane_inactivity_timer++; if(UE_list->UE_sched_ctrl[UE_id].uplane_inactivity_timer > (U_PLANE_INACTIVITY_VALUE*subframe_num(&RC.eNB[module_idP][CC_id]->frame_parms))){ LOG_D(MAC,"UE %d rnti %x: U-Plane Failure after repeated PDCCH orders: Triggering RRC \n",UE_id,rnti); mac_eNB_rrc_uplane_failure(module_idP,CC_id,frameP,subframeP,rnti); UE_list->UE_sched_ctrl[UE_id].uplane_inactivity_timer = 0; }// time > 60s +#endif } void From e7bca7fdacdf8c37da91dde390710f4e12709b4d Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Fri, 23 Mar 2018 10:13:41 +0100 Subject: [PATCH 60/88] Disable ITTI dump If anyone needs it, it's a simple matter of reverting this basic commit. --- common/utils/itti/intertask_interface.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/common/utils/itti/intertask_interface.c b/common/utils/itti/intertask_interface.c index 85b5fef509..1d38a3692b 100644 --- a/common/utils/itti/intertask_interface.c +++ b/common/utils/itti/intertask_interface.c @@ -325,8 +325,11 @@ int itti_send_msg_to_task(task_id_t destination_task_id, instance_t instance, Me /* Increment the global message number */ message_number = itti_increment_message_number (); +#if 0 + /* itti dump is disabled */ itti_dump_queue_message (origin_task_id, message_number, message, itti_desc.messages_info[message_id].name, sizeof(MessageHeader) + message->ittiMsgHeader.ittiMsgSize); +#endif if (destination_task_id != TASK_UNKNOWN) { @@ -421,8 +424,11 @@ int itti_try_send_msg_to_task(task_id_t destination_task_id, instance_t instance /* Increment the global message number */ message_number = itti_increment_message_number (); +#if 0 + /* itti dump is disabled */ itti_dump_queue_message (origin_task_id, message_number, message, itti_desc.messages_info[message_id].name, sizeof(MessageHeader) + message->ittiMsgHeader.ittiMsgSize); +#endif if (destination_task_id != TASK_UNKNOWN) { @@ -716,8 +722,11 @@ void itti_mark_task_ready(task_id_t task_id) AssertFatal (thread_id < itti_desc.thread_max, "Thread id (%d) is out of range (%d)!\n", thread_id, itti_desc.thread_max); +#if 0 + /* itti dump is disabled */ /* Register the thread in itti dump */ itti_dump_thread_use_ring_buffer(); +#endif /* Mark the thread as using LFDS queue */ lfds611_queue_use(itti_desc.tasks[task_id].message_queue); @@ -848,7 +857,10 @@ int itti_init(task_id_t task_max, thread_id_t thread_max, MessagesIds messages_i itti_desc.wait_tasks = 0; itti_desc.created_tasks = 0; itti_desc.ready_tasks = 0; +#if 0 + /* itti dump is disabled */ itti_dump_init (messages_definition_xml, dump_file_name); +#endif CHECK_INIT_RETURN(timer_init ()); @@ -915,7 +927,10 @@ void itti_wait_tasks_end(void) exit (0); } +#if 0 + /* itti dump is disabled */ itti_dump_exit(); +#endif } void itti_send_terminate_message(task_id_t task_id) From 3a0d9339dc136cb5acce1760a0c2bd9eaeb7b5fd Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Fri, 23 Mar 2018 10:14:55 +0100 Subject: [PATCH 61/88] bugfix: fix a memory leak When doing TCP downlink traffic with iperf for several hours, the memory consumption of lte-softmodem does not stop to grow. After analysis, this commit seems to be the only fix needed. To be checked somehow. --- openair3/GTPV1-U/gtpv1u_eNB.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/openair3/GTPV1-U/gtpv1u_eNB.c b/openair3/GTPV1-U/gtpv1u_eNB.c index 7f63e8c1ce..7ba3d88a87 100644 --- a/openair3/GTPV1-U/gtpv1u_eNB.c +++ b/openair3/GTPV1-U/gtpv1u_eNB.c @@ -290,6 +290,7 @@ NwGtpv1uRcT gtpv1u_eNB_process_stack_req( hashtable_rc_t hash_rc = HASH_TABLE_KEY_NOT_EXISTS; gtpv1u_teid_data_t *gtpv1u_teid_data_p = NULL; protocol_ctxt_t ctxt; + NwGtpv1uRcT rc; switch(pUlpApi->apiType) { /* Here there are two type of messages handled: @@ -314,6 +315,12 @@ NwGtpv1uRcT gtpv1u_eNB_process_stack_req( gtpv1u_eNB_write_dump_socket(buffer,buffer_len); #endif + rc = nwGtpv1uMsgDelete(RC.gtpv1u_data_g->gtpv1u_stack, + pUlpApi->apiInfo.recvMsgInfo.hMsg); + if (rc != NW_GTPV1U_OK) { + LOG_E(GTPU, "nwGtpv1uMsgDelete failed: 0x%x\n", rc); + } + //----------------------- // GTPV1U->PDCP mapping //----------------------- From 16cb7eba64b70fb054451b5c60619e5539524c36 Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Fri, 23 Mar 2018 10:23:05 +0100 Subject: [PATCH 62/88] remove start_background_system from eNB softmodem This is only needed by the UE code, to setup IP settings. The eNB does not need this. (To be reverted if this is wrong.) --- targets/RT/USER/lte-softmodem.c | 1 - 1 file changed, 1 deletion(-) diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index 03313146df..48169adffa 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -904,7 +904,6 @@ int main( int argc, char **argv ) int ret; #endif - start_background_system(); if ( load_configmodule(argc,argv) == NULL) { exit_fun("[SOFTMODEM] Error, configuration module init failed\n"); } From ff3c929ecf5d25c0550e66f8eb62a788cd88947a Mon Sep 17 00:00:00 2001 From: Cedric Roux Date: Fri, 23 Mar 2018 15:15:51 +0100 Subject: [PATCH 63/88] fix PHY simulators compilation Only ulsim and dlsim compile. The others (dlsim_tm4 pucchsim prachsim pdcchsim pbchsim mbmssim) have been disabled. Command line to compile: ./build_oai --phy_simulators --- cmake_targets/CMakeLists.txt | 3 ++- cmake_targets/build_oai | 7 ++++++- openair2/RRC/LITE/defs_NB_IoT.h | 3 +++ 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/cmake_targets/CMakeLists.txt b/cmake_targets/CMakeLists.txt index a22babc33f..34b868642d 100644 --- a/cmake_targets/CMakeLists.txt +++ b/cmake_targets/CMakeLists.txt @@ -280,7 +280,7 @@ set(protobuf_generated_dir ${OPENAIR_BIN_DIR}) # RRC ###### -add_list2_option(RRC_ASN1_VERSION "Rel10" "ASN.1 version of RRC interface" "Rel8" "Rel10" "CBA") +add_list2_option(RRC_ASN1_VERSION "Rel14" "ASN.1 version of RRC interface" "Rel8" "Rel10" "Rel14" "CBA") if (${RRC_ASN1_VERSION} STREQUAL "Rel8") set (RRC_GRAMMAR ${OPENAIR2_DIR}/RRC/LITE/MESSAGES/asn1c/ASN1_files/EUTRA-RRC-Definitions-86.asn) @@ -2238,6 +2238,7 @@ foreach(myExe dlsim dlsim_tm7 ulsim pbchsim scansim mbmssim pdcchsim pucchsim pr ${XFORMS_SOURCE} ${T_SOURCE} ${CONFIG_SOURCES} + ${SHLIB_LOADER_SOURCES} ) target_link_libraries (${myExe} diff --git a/cmake_targets/build_oai b/cmake_targets/build_oai index f5be69d3fa..d7b98bce41 100755 --- a/cmake_targets/build_oai +++ b/cmake_targets/build_oai @@ -626,12 +626,17 @@ function main() { if [ "$SIMUS_PHY" = "1" ] ; then # lte unitary simulators compilation echo_info "Compiling unitary tests simulators" - simlist="dlsim_tm4 dlsim ulsim pucchsim prachsim pdcchsim pbchsim mbmssim" + # TODO: fix: dlsim_tm4 pucchsim prachsim pdcchsim pbchsim mbmssim + #simlist="dlsim_tm4 dlsim ulsim pucchsim prachsim pdcchsim pbchsim mbmssim" + simlist="dlsim ulsim" for f in $simlist ; do compilations \ lte-simulators $f \ $f $dbin/$f.$REL done + compilations \ + lte-simulators coding \ + libcoding.so $dbin/libcoding.so fi # Core simulators diff --git a/openair2/RRC/LITE/defs_NB_IoT.h b/openair2/RRC/LITE/defs_NB_IoT.h index 376b66c79a..c8565d52bd 100644 --- a/openair2/RRC/LITE/defs_NB_IoT.h +++ b/openair2/RRC/LITE/defs_NB_IoT.h @@ -35,6 +35,9 @@ #include #include +#include "COMMON/s1ap_messages_types.h" +#include "COMMON/rrc_messages_types.h" + #include "collection/tree.h" #include "rrc_types_NB_IoT.h" #include "COMMON/platform_constants.h" From df9827b5fb84a65c2c465be28d119cae5aaebfad Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Sun, 25 Mar 2018 23:57:33 -0700 Subject: [PATCH 64/88] changes for TDD --- openair1/PHY/LTE_TRANSPORT/if4_tools.c | 2 +- openair1/PHY/LTE_TRANSPORT/prach.c | 17 ++++++++++++----- openair1/SCHED/prach_procedures.c | 2 +- openair2/LAYER2/MAC/eNB_scheduler_primitives.c | 2 +- targets/RT/USER/lte-enb.c | 2 +- targets/RT/USER/lte-ru.c | 4 +++- 6 files changed, 19 insertions(+), 10 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/if4_tools.c b/openair1/PHY/LTE_TRANSPORT/if4_tools.c index 874907c482..a0c137942b 100644 --- a/openair1/PHY/LTE_TRANSPORT/if4_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/if4_tools.c @@ -407,7 +407,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/PHY/LTE_TRANSPORT/prach.c b/openair1/PHY/LTE_TRANSPORT/prach.c index b58aa91636..c7d80d9241 100644 --- a/openair1/PHY/LTE_TRANSPORT/prach.c +++ b/openair1/PHY/LTE_TRANSPORT/prach.c @@ -38,9 +38,12 @@ #include "SCHED/extern.h" #include "UTIL/LOG/vcd_signal_dumper.h" -//#define PRACH_DEBUG 1 +#define PRACH_DEBUG 1 //#define PRACH_WRITE_OUTPUT_DEBUG 1 +#undef LOG_I +#define LOG_I(A,B,C...) printf(B,C) + uint16_t NCS_unrestricted[16] = {0,13,15,18,22,26,32,38,46,59,76,93,119,167,279,419}; uint16_t NCS_restricted[15] = {15,18,22,26,32,38,46,55,68,82,100,128,158,202,237}; // high-speed case uint16_t NCS_4[7] = {2,4,6,8,10,12,15}; @@ -1202,6 +1205,10 @@ void rx_prach0(PHY_VARS_eNB *eNB, int16_t *prach[nb_rx]; uint8_t prach_fmt = get_prach_fmt(prach_ConfigIndex,frame_type); uint16_t N_ZC = (prach_fmt <4)?839:139; + +#ifdef PRACH_DEBUG + int en; +#endif if (eNB) { #ifdef Rel14 @@ -1275,7 +1282,7 @@ void rx_prach0(PHY_VARS_eNB *eNB, #ifdef PRACH_DEBUG int32_t en0=signal_energy((int32_t*)prach[aa],fp->samples_per_tti); int8_t dbEn0 = dB_fixed(en0); - int8_t rach_dBm = dbEn0 - eNB->rx_total_gain_dB; + int8_t rach_dBm = dbEn0 - ru->rx_total_gain_dB; #ifdef PRACH_WRITE_OUTPUT_DEBUG if (dbEn0>32 && prach[0]!= NULL) @@ -1885,9 +1892,9 @@ void compute_prach_seq(uint16_t rootSequenceIndex, } -#ifdef PRACH_DEBUG - LOG_I( PHY, "compute_prach_seq: done init prach_tables\n" ); -#endif + //#ifdef PRACH_DEBUG + // LOG_I( PHY, "compute_prach_seq: done init prach_tables\n" ); + //#endif if (highSpeedFlag== 0) { diff --git a/openair1/SCHED/prach_procedures.c b/openair1/SCHED/prach_procedures.c index 4730eed613..51ce01ae42 100644 --- a/openair1/SCHED/prach_procedures.c +++ b/openair1/SCHED/prach_procedures.c @@ -116,7 +116,7 @@ void prach_procedures(PHY_VARS_eNB *eNB #endif ); - LOG_D(PHY,"[RAPROC] Frame %d, subframe %d : Most likely preamble %d, energy %d dB delay %d (prach_energy counter %d)\n", + LOG_I(PHY,"[RAPROC] Frame %d, subframe %d : Most likely preamble %d, energy %d dB delay %d (prach_energy counter %d)\n", frame,subframe, max_preamble[0], max_preamble_energy[0]/10, diff --git a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c index 75e96b5a00..e2e8925654 100644 --- a/openair2/LAYER2/MAC/eNB_scheduler_primitives.c +++ b/openair2/LAYER2/MAC/eNB_scheduler_primitives.c @@ -3280,7 +3280,7 @@ extract_harq(module_id_t mod_idP, int CC_idP, int UE_id, LOG_D(MAC, "Received %d for harq_pid %d\n", pdu[0], harq_pid); - pdu = &harq_indication_fdd->harq_data[0].bundling.value_0; + pdu = &harq_indication_tdd->harq_data[0].bundling.value_0; if (pdu[0] == 1) { // ACK sched_ctl->round[CC_idP][harq_pid] = 8; // release HARQ process sched_ctl->tbcnt[CC_idP][harq_pid] = 0; diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index 8c0692e773..d88f2cd1c7 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -630,7 +630,7 @@ static void* eNB_thread_prach( void* param ) { if (wait_on_condition(&proc->mutex_prach,&proc->cond_prach,&proc->instance_cnt_prach,"eNB_prach_thread") < 0) break; - LOG_D(PHY,"Running eNB prach procedures\n"); + LOG_I(PHY,"Running eNB prach procedures\n"); prach_procedures(eNB #ifdef Rel14 ,0 diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index 1ff4a2ab28..c475734898 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -1097,6 +1097,7 @@ static void* ru_thread_prach( void* param ) { ); } else { + LOG_I(PHY,"Running rx_prach in %d.%d\n",proc->frame_prach,proc->subframe_prach); rx_prach(NULL, ru, NULL, @@ -1905,10 +1906,11 @@ static void* ru_thread( void* param ) { } else { - LOG_D(PHY,"RU thread %d, frame %d, subframe %d \n", + LOG_I(PHY,"RU thread %d, frame %d, subframe %d \n", ru->idx,frame,subframe); if ((ru->do_prach>0) && (is_prach_subframe(fp, proc->frame_rx, proc->subframe_rx)==1)) { + LOG_I(PHY,"Waking up prach for %d.%d\n",proc->frame_rx,proc->subframe_rx); wakeup_prach_ru(ru); } #ifdef Rel14 From 9fa001c3c5b271401f453911b937fa46cdd8d5f6 Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Thu, 5 Apr 2018 16:33:08 +0200 Subject: [PATCH 65/88] 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 66/88] 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 497c818b0226c81086f9cd2abc875adbb15411f9 Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Thu, 5 Apr 2018 12:26:02 -0700 Subject: [PATCH 67/88] removed some logging --- targets/RT/USER/lte-ru.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index c475734898..d1a80c2bd7 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -1906,7 +1906,7 @@ static void* ru_thread( void* param ) { } else { - LOG_I(PHY,"RU thread %d, frame %d, subframe %d \n", + LOG_D(PHY,"RU thread %d, frame %d, subframe %d \n", ru->idx,frame,subframe); if ((ru->do_prach>0) && (is_prach_subframe(fp, proc->frame_rx, proc->subframe_rx)==1)) { From 3d8a21636a55f5738d81736347572db863aa0155 Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Thu, 5 Apr 2018 22:32:18 +0200 Subject: [PATCH 68/88] 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 69/88] 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 70/88] 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 71/88] 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 72/88] 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 73/88] 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 74/88] 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 75/88] 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 76/88] 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 77/88] 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 78/88] 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 79/88] 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; From 0eb2f0175e6998d7396d03ff3484b673985699c5 Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Fri, 4 May 2018 10:29:45 +0200 Subject: [PATCH 80/88] Support for RAW, not tested yet --- openair1/PHY/defs.h | 4 ++ targets/RT/USER/lte-ru.c | 98 ++++++++++++++++++++++++++++++++++------ 2 files changed, 88 insertions(+), 14 deletions(-) diff --git a/openair1/PHY/defs.h b/openair1/PHY/defs.h index fce45df6c8..6648223c00 100644 --- a/openair1/PHY/defs.h +++ b/openair1/PHY/defs.h @@ -434,6 +434,8 @@ typedef struct RU_proc_t_s { pthread_mutex_t mutex_ru; /// symbol mask for IF4p5 reception per subframe uint32_t symbol_mask[10]; + /// time measurements for each subframe + struct timespec t[10]; /// number of slave threads int num_slaves; /// array of pointers to slaves @@ -715,6 +717,8 @@ typedef struct RU_t_s{ int rx_offset; /// flag to indicate the RU is a slave to another source int is_slave; + /// flag to indicate if the RU has a control channel + int has_ctrl_prt; /// counter to delay start of processing of RU until HW settles int wait_cnt; /// Total gain of receive chain diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index e036909e17..5f25212099 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -1264,7 +1264,12 @@ void do_ru_synch(RU_t *ru) { LOG_I(PHY,"Exiting synch routine\n"); } +int check_sync(RU_t *ru, RU_t *ru_master, int subframe){ + if (fabs(ru_master->proc.t[subframe].tv_nsec - ru->proc.t[subframe].tv_nsec) > 500000) + return 0; + return 1; +} void wakeup_eNBs(RU_t *ru) { @@ -1285,11 +1290,13 @@ void wakeup_eNBs(RU_t *ru) { pthread_mutex_lock(&proc->mutex_RU); LOG_I(PHY,"Frame %d, Subframe %d: RU %d done (wait_cnt %d),RU_mask[%d] %x\n", ru->proc.frame_rx,ru->proc.subframe_rx,ru->idx,ru->wait_cnt,ru->proc.subframe_rx,proc->RU_mask[ru->proc.subframe_rx]); - + + clock_gettime(CLOCK_MONOTONIC,&ru->proc.t[ru->proc.subframe_rx]); + if (proc->RU_mask[ru->proc.subframe_rx] == 0){ - clock_gettime(CLOCK_MONOTONIC,&proc->t[ru->proc.subframe_rx]); + //clock_gettime(CLOCK_MONOTONIC,&proc->t[ru->proc.subframe_rx]); + proc->t[ru->proc.subframe_rx] = ru->proc.t[ru->proc.subframe_rx]; //start_meas(&proc->ru_arrival_time); - LOG_D(PHY,"RU %d starting timer for frame %d subframe %d\n",ru->idx, ru->proc.frame_rx,ru->proc.subframe_rx); } for (i=0;inum_RU;i++) { @@ -1297,12 +1304,22 @@ void wakeup_eNBs(RU_t *ru) { if (ru == eNB->RU_list[i]) { // AssertFatal((proc->RU_mask&(1<Mod_id,ru->proc.frame_rx,ru->proc.subframe_rx,ru->idx,eNB->num_RU,proc->RU_mask); proc->RU_mask[ru->proc.subframe_rx] |= (1<RU_list[i]->state == RU_SYNC || eNB->RU_list[i]->wait_cnt > 0){ + }else if (eNB->RU_list[i]->state == RU_SYNC){ proc->RU_mask[ru->proc.subframe_rx] |= (1<is_slave == 0 && ( (proc->RU_mask[ru->proc.subframe_rx]&(1<RU_list[i]->state == RU_RUN) { // This is master & the RRU has already been received + if (check_sync(eNB->RU_list[i],eNB->RU_list[0],ru->proc.subframe_rx) == 0) + LOG_E(PHY,"RU %d is not SYNC, subframe %d, time %f this is master\n", eNB->RU_list[i]->idx, ru->proc.subframe_rx, fabs(eNB->RU_list[i]->proc.t[ru->proc.subframe_rx].tv_nsec - eNB->RU_list[0]->proc.t[ru->proc.subframe_rx].tv_nsec)); + }else if (ru->is_slave == 1 && ru->state == RU_RUN && ( (proc->RU_mask[ru->proc.subframe_rx]&(1<<0)) == 1)){ // master already received. TODO: we assume that RU0 is master. + if (check_sync(ru,eNB->RU_list[0],ru->proc.subframe_rx) == 0) + LOG_E(PHY,"RU %d is not SYNC time, subframe %d, time %f\n", ru->idx, ru->proc.subframe_rx, fabs(ru->proc.t[ru->proc.subframe_rx].tv_nsec - eNB->RU_list[0]->proc.t[ru->proc.subframe_rx].tv_nsec)); + + } } - clock_gettime(CLOCK_MONOTONIC,&t); - LOG_I(PHY,"RU mask is now %x, time is %lu\n",proc->RU_mask[ru->proc.subframe_rx], t.tv_nsec - proc->t[ru->proc.subframe_rx].tv_nsec); + //clock_gettime(CLOCK_MONOTONIC,&t); + //LOG_I(PHY,"RU mask is now %x, time is %lu\n",proc->RU_mask[ru->proc.subframe_rx], t.tv_nsec - proc->t[ru->proc.subframe_rx].tv_nsec); + if (proc->RU_mask[ru->proc.subframe_rx] == (1<num_RU)-1) { LOG_D(PHY,"Reseting mask frame %d, subframe %d, this is RU %d\n",ru->proc.frame_rx, ru->proc.subframe_rx, ru->idx); @@ -1316,7 +1333,8 @@ void wakeup_eNBs(RU_t *ru) { pthread_mutex_unlock(&proc->mutex_RU); LOG_D(PHY,"wakeup eNB top for for subframe %d\n", ru->proc.subframe_rx); - ru->eNB_top(eNB_list[0],ru->proc.frame_rx,ru->proc.subframe_rx,string); + if (ru->wait_cnt == 0) + ru->eNB_top(eNB_list[0],ru->proc.frame_rx,ru->proc.subframe_rx,string); } else { // multiple eNB case for later @@ -1593,7 +1611,7 @@ static void* ru_thread_control( void* param ) { &rru_config_msg, msg_len))<0) { LOG_D(PHY,"Waiting msg for RU %d\n", ru->idx); - } + else { switch(rru_config_msg.type) @@ -1823,7 +1841,9 @@ static void* ru_thread( void* param ) { int subframe =9; int frame =1023; int resynch_done = 0; - + PHY_VARS_eNB **eNB_list = ru->eNB_list; + PHY_VARS_eNB *eNB=eNB_list[0]; + eNB_proc_t *eNBproc = &eNB->proc; // set default return value @@ -1831,6 +1851,36 @@ 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]); + if (ru->has_ctrl_prt == 0){ + // There is no control port: start everything here + + if (ru->if_south == LOCAL_RF){ + fill_rf_config(ru,ru->rf_config_file); + init_frame_parms(&ru->frame_parms,1); + ru->frame_parms.nb_antennas_rx = ru->nb_rx; + 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); + } + pthread_mutex_lock(&RC.ru_mutex); + RC.ru_mask &= ~(1<idx); + pthread_cond_signal(&RC.ru_cond); + pthread_mutex_unlock(&RC.ru_mutex); + } + pthread_mutex_lock(&RC.ru_mutex); + RC.ru_mask &= ~(1<idx); + pthread_cond_signal(&RC.ru_cond); + pthread_mutex_unlock(&RC.ru_mutex); + + ru->state = RU_RUN; + + } + while (!oai_exit) { @@ -1838,9 +1888,9 @@ static void* ru_thread( void* param ) { else ru->wait_cnt = 0; // wait to be woken up - if (ru->function!=eNodeB_3GPP) { + if (ru->function!=eNodeB_3GPP && ru->has_ctrl_prt == 1) { if (wait_on_condition(&ru->proc.mutex_ru,&ru->proc.cond_ru_thread,&ru->proc.instance_cnt_ru,"ru_thread")<0) break; - } + else wait_sync("ru_thread"); if (ru->is_slave == 0) AssertFatal(ru->state == RU_RUN,"ru-%d state = %s != RU_RUN\n",ru->idx,ru_states[ru->state]); @@ -1903,8 +1953,11 @@ static void* ru_thread( void* param ) { if (ru->fh_south_in && ru->state == RU_RUN ) ru->fh_south_in(ru,&frame,&subframe); else AssertFatal(1==0, "No fronthaul interface at south port"); + if (ru->wait_cnt > 0) { + ru->wait_cnt--; + LOG_I(PHY,"RU thread %d, frame %d, subframe %d, wait_cnt %d \n",ru->idx, frame, subframe, ru->wait_cnt); @@ -1919,8 +1972,10 @@ static void* ru_thread( void* param ) { AssertFatal((ru->ifdevice.trx_ctlsend_func(&ru->ifdevice,&rru_config_msg,rru_config_msg.len)!=-1),"Failed to send msg to RAU\n"); resynch_done=1; } + wakeup_eNBs(ru); } - if (ru->wait_cnt == 0) { + + else { LOG_D(PHY,"RU thread %d, frame %d, subframe %d \n", ru->idx,frame,subframe); @@ -2809,6 +2864,8 @@ void RCconfig_RU(void) { RC.ru[j]->num_eNB = 0; for (i=0;inum_eNB;i++) RC.ru[j]->eNB_list[i] = RC.eNB[RUParamList.paramarray[j][RU_ENB_LIST_IDX].iptr[i]][0]; + RC.ru[j]->has_ctrl_prt = 1; + if (strcmp(*(RUParamList.paramarray[j][RU_LOCAL_RF_IDX].strptr), "yes") == 0) { if ( !(config_isparamset(RUParamList.paramarray[j],RU_LOCAL_IF_NAME_IDX)) ) { @@ -2821,30 +2878,43 @@ void RCconfig_RU(void) { RC.ru[j]->eth_params.local_if_name = strdup(*(RUParamList.paramarray[j][RU_LOCAL_IF_NAME_IDX].strptr)); RC.ru[j]->eth_params.my_addr = strdup(*(RUParamList.paramarray[j][RU_LOCAL_ADDRESS_IDX].strptr)); RC.ru[j]->eth_params.remote_addr = strdup(*(RUParamList.paramarray[j][RU_REMOTE_ADDRESS_IDX].strptr)); - RC.ru[j]->eth_params.my_portc = *(RUParamList.paramarray[j][RU_LOCAL_PORTC_IDX].uptr); - RC.ru[j]->eth_params.remote_portc = *(RUParamList.paramarray[j][RU_REMOTE_PORTC_IDX].uptr); RC.ru[j]->eth_params.my_portd = *(RUParamList.paramarray[j][RU_LOCAL_PORTD_IDX].uptr); RC.ru[j]->eth_params.remote_portd = *(RUParamList.paramarray[j][RU_REMOTE_PORTD_IDX].uptr); + + + // Check if control port set + if (!(config_isparamset(RUParamList.paramarray[j],RU_REMOTE_PORTC_IDX)) ){ + RC.ru[j]->eth_params.my_portc = *(RUParamList.paramarray[j][RU_LOCAL_PORTC_IDX].uptr); + RC.ru[j]->eth_params.remote_portc = *(RUParamList.paramarray[j][RU_REMOTE_PORTC_IDX].uptr); + + RC.ru[j]->has_ctrl_prt = 0; + } + + if (strcmp(*(RUParamList.paramarray[j][RU_TRANSPORT_PREFERENCE_IDX].strptr), "udp") == 0) { RC.ru[j]->if_south = LOCAL_RF; RC.ru[j]->function = NGFI_RRU_IF5; RC.ru[j]->eth_params.transp_preference = ETH_UDP_MODE; + printf("Setting function for RU %d to NGFI_RRU_IF5 (udp)\n",j); } else if (strcmp(*(RUParamList.paramarray[j][RU_TRANSPORT_PREFERENCE_IDX].strptr), "raw") == 0) { RC.ru[j]->if_south = LOCAL_RF; RC.ru[j]->function = NGFI_RRU_IF5; RC.ru[j]->eth_params.transp_preference = ETH_RAW_MODE; + printf("Setting function for RU %d to NGFI_RRU_IF5 (raw)\n",j); } else if (strcmp(*(RUParamList.paramarray[j][RU_TRANSPORT_PREFERENCE_IDX].strptr), "udp_if4p5") == 0) { RC.ru[j]->if_south = LOCAL_RF; RC.ru[j]->function = NGFI_RRU_IF4p5; RC.ru[j]->eth_params.transp_preference = ETH_UDP_IF4p5_MODE; + printf("Setting function for RU %d to NGFI_RRU_IF4p5 (udp)\n",j); } else if (strcmp(*(RUParamList.paramarray[j][RU_TRANSPORT_PREFERENCE_IDX].strptr), "raw_if4p5") == 0) { RC.ru[j]->if_south = LOCAL_RF; RC.ru[j]->function = NGFI_RRU_IF4p5; RC.ru[j]->eth_params.transp_preference = ETH_RAW_IF4p5_MODE; + printf("Setting function for RU %d to NGFI_RRU_IF4p5 (raw)\n",j); } printf("RU %d is_slave=%s\n",j,*(RUParamList.paramarray[j][RU_IS_SLAVE_IDX].strptr)); From fe861bf49ee7986d07d0a14a54affd9411f480de Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Sun, 13 May 2018 05:16:57 -0700 Subject: [PATCH 81/88] compilation passes and 1 UE simulation ok. --- cmake_targets/build_oai | 14 ++-- openair1/PHY/LTE_TRANSPORT/if4_tools.c | 2 +- openair1/PHY/LTE_TRANSPORT/prach.c | 2 +- openair1/SCHED/fapi_l1.c | 2 +- openair1/SCHED/phy_procedures_lte_eNb.c | 2 +- openair1/SCHED/prach_procedures.c | 2 +- targets/RT/USER/lte-enb.c | 4 +- targets/RT/USER/lte-ru.c | 106 ++++++++++++------------ targets/SIMU/USER/channel_sim.c | 4 +- targets/SIMU/USER/oaisim_config.c | 4 +- targets/SIMU/USER/oaisim_functions.c | 7 +- 11 files changed, 77 insertions(+), 72 deletions(-) diff --git a/cmake_targets/build_oai b/cmake_targets/build_oai index eb34191107..ce7ebc46be 100755 --- a/cmake_targets/build_oai +++ b/cmake_targets/build_oai @@ -685,13 +685,6 @@ function main() { oaisim_build_dir=oaisim_build_oai oaisim_exec=oaisim fi -# mandatory shared lib - 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 echo_info "Compiling $oaisim_exec ($oaisim_build_dir)" cmake_file=$DIR/$oaisim_build_dir/CMakeLists.txt @@ -711,6 +704,13 @@ 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/PHY/LTE_TRANSPORT/if4_tools.c b/openair1/PHY/LTE_TRANSPORT/if4_tools.c index a0c137942b..874907c482 100644 --- a/openair1/PHY/LTE_TRANSPORT/if4_tools.c +++ b/openair1/PHY/LTE_TRANSPORT/if4_tools.c @@ -407,7 +407,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/openair1/PHY/LTE_TRANSPORT/prach.c b/openair1/PHY/LTE_TRANSPORT/prach.c index c7d80d9241..54b91184b9 100644 --- a/openair1/PHY/LTE_TRANSPORT/prach.c +++ b/openair1/PHY/LTE_TRANSPORT/prach.c @@ -1514,7 +1514,7 @@ void rx_prach0(PHY_VARS_eNB *eNB, else #endif send_IF4p5(ru, ru->proc.frame_prach, ru->proc.subframe_prach, IF4p5_PRACH); - + LOG_D(PHY,"SFN/SF %d.%d: Sending PRACH over IF4p5\n",ru->proc.frame_prach,ru->proc.subframe_prach); return; } else if (eNB!=NULL) { diff --git a/openair1/SCHED/fapi_l1.c b/openair1/SCHED/fapi_l1.c index e74c937670..a6f2eec5f2 100644 --- a/openair1/SCHED/fapi_l1.c +++ b/openair1/SCHED/fapi_l1.c @@ -834,7 +834,7 @@ void schedule_response(Sched_Rsp_t *Sched_INFO) else { 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 92ee1b4436..4d658dff25 100644 --- a/openair1/SCHED/phy_procedures_lte_eNb.c +++ b/openair1/SCHED/phy_procedures_lte_eNb.c @@ -1898,7 +1898,7 @@ void phy_procedures_eNB_uespec_RX(PHY_VARS_eNB *eNB,eNB_rxtx_proc_t *proc,const VCD_SIGNAL_DUMPER_DUMP_FUNCTION_BY_NAME( VCD_SIGNAL_DUMPER_FUNCTIONS_PHY_PROCEDURES_ENB_RX_UESPEC, 1 ); - LOG_I(PHY,"[eNB %d] Frame %d: Doing phy_procedures_eNB_uespec_RX(%d)\n",eNB->Mod_id,frame, subframe); + LOG_D(PHY,"[eNB %d] Frame %d: Doing phy_procedures_eNB_uespec_RX(%d)\n",eNB->Mod_id,frame, subframe); eNB->rb_mask_ul[0]=0; eNB->rb_mask_ul[1]=0; diff --git a/openair1/SCHED/prach_procedures.c b/openair1/SCHED/prach_procedures.c index 51ce01ae42..4730eed613 100644 --- a/openair1/SCHED/prach_procedures.c +++ b/openair1/SCHED/prach_procedures.c @@ -116,7 +116,7 @@ void prach_procedures(PHY_VARS_eNB *eNB #endif ); - LOG_I(PHY,"[RAPROC] Frame %d, subframe %d : Most likely preamble %d, energy %d dB delay %d (prach_energy counter %d)\n", + LOG_D(PHY,"[RAPROC] Frame %d, subframe %d : Most likely preamble %d, energy %d dB delay %d (prach_energy counter %d)\n", frame,subframe, max_preamble[0], max_preamble_energy[0]/10, diff --git a/targets/RT/USER/lte-enb.c b/targets/RT/USER/lte-enb.c index a6099c0228..740aae931a 100644 --- a/targets/RT/USER/lte-enb.c +++ b/targets/RT/USER/lte-enb.c @@ -391,7 +391,7 @@ void eNB_top(PHY_VARS_eNB *eNB, int frame_rx, int subframe_rx, char *string) proc->frame_tx = proc_rxtx->frame_tx; proc_rxtx->timestamp_tx = proc->timestamp_tx; - LOG_I(PHY,"RXTX for TX: %d.%d, RX: %d.%d\n",proc_rxtx->frame_tx,proc_rxtx->subframe_tx,proc_rxtx->frame_rx,proc_rxtx->subframe_rx); + LOG_D(PHY,"RXTX for TX: %d.%d, RX: %d.%d\n",proc_rxtx->frame_tx,proc_rxtx->subframe_tx,proc_rxtx->frame_rx,proc_rxtx->subframe_rx); 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); } @@ -630,7 +630,7 @@ static void* eNB_thread_prach( void* param ) { if (wait_on_condition(&proc->mutex_prach,&proc->cond_prach,&proc->instance_cnt_prach,"eNB_prach_thread") < 0) break; - LOG_I(PHY,"Running eNB prach procedures\n"); + LOG_D(PHY,"Running eNB prach procedures\n"); prach_procedures(eNB #ifdef Rel14 ,0 diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index cb22f1bd2c..be3fdfa9f1 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -1097,7 +1097,7 @@ static void* ru_thread_prach( void* param ) { ); } else { - LOG_I(PHY,"Running rx_prach in %d.%d\n",proc->frame_prach,proc->subframe_prach); + LOG_D(PHY,"Running rx_prach in %d.%d\n",proc->frame_prach,proc->subframe_prach); rx_prach(NULL, ru, NULL, @@ -1289,7 +1289,7 @@ void wakeup_eNBs(RU_t *ru) { sprintf(string,"Incoming RU %d",ru->idx); pthread_mutex_lock(&proc->mutex_RU); - LOG_I(PHY,"Frame %d, Subframe %d: RU %d done (wait_cnt %d),RU_mask[%d] %x\n", + LOG_D(PHY,"Frame %d, Subframe %d: RU %d done (wait_cnt %d),RU_mask[%d] %x\n", ru->proc.frame_rx,ru->proc.subframe_rx,ru->idx,ru->wait_cnt,ru->proc.subframe_rx,proc->RU_mask[ru->proc.subframe_rx]); clock_gettime(CLOCK_MONOTONIC,&ru->proc.t[ru->proc.subframe_rx]); @@ -1612,7 +1612,7 @@ static void* ru_thread_control( void* param ) { &rru_config_msg, msg_len))<0) { LOG_D(PHY,"Waiting msg for RU %d\n", ru->idx); - + } else { switch(rru_config_msg.type) @@ -1845,7 +1845,7 @@ static void* ru_thread( void* param ) { PHY_VARS_eNB **eNB_list = ru->eNB_list; PHY_VARS_eNB *eNB=eNB_list[0]; eNB_proc_t *eNBproc = &eNB->proc; - + int ret; // set default return value thread_top_init("ru_thread",0,870000,1000000,1000000); @@ -1862,8 +1862,8 @@ static void* ru_thread( void* param ) { phy_init_RU(ru); - ret = openair0_device_load(&ru->rfdevice,&ru->openair0_cfg); - } + ret = openair0_device_load(&ru->rfdevice,&ru->openair0_cfg); + if (setup_RU_buffers(ru)!=0) { printf("Exiting, cannot initialize RU Buffers\n"); exit(-1); @@ -1891,9 +1891,9 @@ static void* ru_thread( void* param ) { // wait to be woken up if (ru->function!=eNodeB_3GPP && ru->has_ctrl_prt == 1) { if (wait_on_condition(&ru->proc.mutex_ru,&ru->proc.cond_ru_thread,&ru->proc.instance_cnt_ru,"ru_thread")<0) break; - + } else wait_sync("ru_thread"); - + if (ru->is_slave == 0) AssertFatal(ru->state == RU_RUN,"ru-%d state = %s != RU_RUN\n",ru->idx,ru_states[ru->state]); else if (ru->is_slave == 1) AssertFatal(ru->state == RU_SYNC || ru->state == RU_RUN,"ru %d state = %s != RU_SYNC or RU_RUN\n",ru->idx,ru_states[ru->state]); // Start RF device if any @@ -1903,11 +1903,11 @@ static void* ru_thread( void* param ) { else LOG_I(PHY,"RU %d rf device ready\n",ru->idx); } else LOG_D(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 - + LOG_D(PHY,"Locking asynch mutex\n"); if ((ru->fh_south_asynch_in)||(ru->fh_north_asynch_in)) { pthread_mutex_lock(&proc->mutex_asynch_rxtx); @@ -1916,15 +1916,15 @@ static void* ru_thread( void* param ) { pthread_cond_signal(&proc->cond_asynch_rxtx); } else LOG_D(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 == 1) && (ru->if_south == LOCAL_RF)) do_ru_synch(ru); - - + + LOG_D(PHY,"Starting steady-state operation\n"); // This is a forever while loop, it loops over subframes which are scheduled by incoming samples from HW devices while (ru->state == RU_RUN) { - + // 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) { @@ -1934,8 +1934,8 @@ static void* ru_thread( void* param ) { } else { subframe++; } - - + + // synchronization on input FH interface, acquire signals/data and block if (ru->stop_rf && ru->cmd == STOP_RU) { ru->stop_rf(ru); @@ -1951,38 +1951,38 @@ static void* ru_thread( void* param ) { break; } if (oai_exit == 1) break; - + if (ru->fh_south_in && ru->state == RU_RUN ) ru->fh_south_in(ru,&frame,&subframe); else AssertFatal(1==0, "No fronthaul interface at south port"); - + if (ru->wait_cnt > 0) { - - ru->wait_cnt--; + + ru->wait_cnt--; - - LOG_I(PHY,"RU thread %d, frame %d, subframe %d, wait_cnt %d \n",ru->idx, frame, subframe, ru->wait_cnt); - - if (ru->if_south!=LOCAL_RF && ru->wait_cnt <=20 && subframe == 5 && frame != RC.ru[0]->proc.frame_rx && resynch_done == 0) { - // Send RRU_frame adjust - RRU_CONFIG_msg_t rru_config_msg; - rru_config_msg.type = RRU_frame_resynch; - rru_config_msg.len = sizeof(RRU_CONFIG_msg_t); // TODO: set to correct msg len - ((uint16_t*)&rru_config_msg.msg[0])[0] = RC.ru[0]->proc.frame_rx; - ru->cmd=WAIT_RESYNCH; - LOG_D(PHY,"Sending Frame Resynch %d to RRU %d\n", RC.ru[0]->proc.frame_rx,ru->idx); - AssertFatal((ru->ifdevice.trx_ctlsend_func(&ru->ifdevice,&rru_config_msg,rru_config_msg.len)!=-1),"Failed to send msg to RAU\n"); - resynch_done=1; - } - wakeup_eNBs(ru); + + LOG_I(PHY,"RU thread %d, frame %d, subframe %d, wait_cnt %d \n",ru->idx, frame, subframe, ru->wait_cnt); + + if (ru->if_south!=LOCAL_RF && ru->wait_cnt <=20 && subframe == 5 && frame != RC.ru[0]->proc.frame_rx && resynch_done == 0) { + // Send RRU_frame adjust + RRU_CONFIG_msg_t rru_config_msg; + rru_config_msg.type = RRU_frame_resynch; + rru_config_msg.len = sizeof(RRU_CONFIG_msg_t); // TODO: set to correct msg len + ((uint16_t*)&rru_config_msg.msg[0])[0] = RC.ru[0]->proc.frame_rx; + ru->cmd=WAIT_RESYNCH; + LOG_D(PHY,"Sending Frame Resynch %d to RRU %d\n", RC.ru[0]->proc.frame_rx,ru->idx); + AssertFatal((ru->ifdevice.trx_ctlsend_func(&ru->ifdevice,&rru_config_msg,rru_config_msg.len)!=-1),"Failed to send msg to RAU\n"); + resynch_done=1; + } + wakeup_eNBs(ru); } - - else { - + + else { + LOG_D(PHY,"RU thread %d, frame %d, subframe %d \n", ru->idx,frame,subframe); - + if ((ru->do_prach>0) && (is_prach_subframe(fp, proc->frame_rx, proc->subframe_rx)==1)) { - LOG_I(PHY,"Waking up prach for %d.%d\n",proc->frame_rx,proc->subframe_rx); + LOG_D(PHY,"Waking up prach for %d.%d\n",proc->frame_rx,proc->subframe_rx); wakeup_prach_ru(ru); } #ifdef Rel14 @@ -1990,14 +1990,14 @@ static void* ru_thread( void* param ) { wakeup_prach_ru_br(ru); } #endif - + // adjust for timing offset between RU if (ru->idx!=0) proc->frame_tx = (proc->frame_tx+proc->frame_offset)&1023; - + // At this point, all information for subframe has been received on FH interface // If this proc is to provide synchronization, do so wakeup_slaves(proc); - + // do RX front-end processing (frequency-shift, dft) if needed if (ru->feprx) ru->feprx(ru); @@ -2019,18 +2019,18 @@ static void* ru_thread( void* param ) { if (ru->fh_north_out) ru->fh_north_out(ru); } } - + } // while !oai_exit - + printf( "Exiting ru_thread \n"); - + if (ru->stop_rf != NULL) { if (ru->stop_rf(ru) != 0) LOG_E(HW,"Could not stop the RF device\n"); else LOG_I(PHY,"RU %d rf device stopped\n",ru->idx); } - + return NULL; } @@ -2886,12 +2886,16 @@ void RCconfig_RU(void) { // Check if control port set if (!(config_isparamset(RUParamList.paramarray[j],RU_REMOTE_PORTC_IDX)) ){ - RC.ru[j]->eth_params.my_portc = *(RUParamList.paramarray[j][RU_LOCAL_PORTC_IDX].uptr); - RC.ru[j]->eth_params.remote_portc = *(RUParamList.paramarray[j][RU_REMOTE_PORTC_IDX].uptr); + printf("Removing control port for RU %d\n",j); RC.ru[j]->has_ctrl_prt = 0; } - + else { + RC.ru[j]->eth_params.my_portc = *(RUParamList.paramarray[j][RU_LOCAL_PORTC_IDX].uptr); + RC.ru[j]->eth_params.remote_portc = *(RUParamList.paramarray[j][RU_REMOTE_PORTC_IDX].uptr); + printf(" Control port %u \n",RC.ru[j]->eth_params.my_portc); + + } if (strcmp(*(RUParamList.paramarray[j][RU_TRANSPORT_PREFERENCE_IDX].strptr), "udp") == 0) { RC.ru[j]->if_south = LOCAL_RF; diff --git a/targets/SIMU/USER/channel_sim.c b/targets/SIMU/USER/channel_sim.c index 553d480782..f3636ee96a 100644 --- a/targets/SIMU/USER/channel_sim.c +++ b/targets/SIMU/USER/channel_sim.c @@ -497,7 +497,7 @@ void do_UL_sig(channel_desc_t *UE2RU[NUMBER_OF_UE_MAX][NUMBER_OF_RU_MAX][MAX_NUM if (((double)PHY_vars_UE_g[UE_id][CC_id]->tx_power_dBm[subframe] + UE2RU[UE_id][ru_id][CC_id]->path_loss_dB) <= -125.0) { // don't simulate a UE that is too weak - LOG_D(OCM,"[SIM][UL] ULPOWERS UE %d tx_pwr %d dBm (num_RE %d) for subframe %d (sf_offset %d)\n", + LOG_D(PHY,"[SIM][UL] ULPOWERS UE %d tx_pwr %d dBm (num_RE %d) for subframe %d (sf_offset %d)\n", UE_id, PHY_vars_UE_g[UE_id][CC_id]->tx_power_dBm[subframe], PHY_vars_UE_g[UE_id][CC_id]->tx_total_RE[subframe], @@ -516,7 +516,7 @@ void do_UL_sig(channel_desc_t *UE2RU[NUMBER_OF_UE_MAX][NUMBER_OF_RU_MAX][MAX_NUM 1, NULL, PHY_vars_UE_g[UE_id][CC_id]->tx_total_RE[subframe]); // This make the previous argument the total power - LOG_D(OCM,"[SIM][UL] ULPOWERS UE %d tx_pwr %f dBm (target %d dBm, num_RE %d) for subframe %d (sf_offset %d)\n", + LOG_D(PHY,"[SIM][UL] ULPOWERS UE %d tx_pwr %f dBm (target %d dBm, num_RE %d) for subframe %d (sf_offset %d)\n", UE_id, 10*log10(tx_pwr*PHY_vars_UE_g[UE_id][CC_id]->tx_total_RE[subframe]), PHY_vars_UE_g[UE_id][CC_id]->tx_power_dBm[subframe], diff --git a/targets/SIMU/USER/oaisim_config.c b/targets/SIMU/USER/oaisim_config.c index 17ed9ff571..6188d49004 100644 --- a/targets/SIMU/USER/oaisim_config.c +++ b/targets/SIMU/USER/oaisim_config.c @@ -443,13 +443,13 @@ int olg_config(void) //set_log(OCM, LOG_INFO, 20); //set_log(OTG, LOG_INFO, 1); set_comp_log(OCG, LOG_ERR, 0x15,1); - set_comp_log(EMU, LOG_DEBUG, 0x15,20); + set_comp_log(EMU, LOG_INFO, 0x15,20); set_comp_log(MAC, LOG_TRACE, 0x15,1); set_comp_log(RLC, LOG_TRACE, 0x15,1); set_comp_log(PHY, LOG_TRACE, 0x15, 1); set_comp_log(PDCP, LOG_DEBUG, 0x15,1); set_comp_log(RRC, LOG_DEBUG, 0x15,1); - set_comp_log(OCM, LOG_DEBUG, 0x15,20); + set_comp_log(OCM, LOG_INFO, 0x15,20); set_comp_log(OTG, LOG_DEBUG, 0x15,1); set_comp_log(OMG, LOG_NOTICE, 0x15,1); set_comp_log(OPT, LOG_ERR, 0x15,1); diff --git a/targets/SIMU/USER/oaisim_functions.c b/targets/SIMU/USER/oaisim_functions.c index 070ea58e1d..1ebf993b2b 100644 --- a/targets/SIMU/USER/oaisim_functions.c +++ b/targets/SIMU/USER/oaisim_functions.c @@ -1072,7 +1072,7 @@ int ru_trx_read(openair0_device *device, openair0_timestamp *ptimestamp, void ** *ptimestamp = last_ru_rx_timestamp[ru_id][CC_id]; - LOG_D(EMU,"RU_trx_read nsamps %d TS(%llu,%llu) => subframe %d\n",nsamps, + LOG_D(PHY,"RU_trx_read nsamps %d TS(%llu,%llu) => subframe %d\n",nsamps, (unsigned long long)current_ru_rx_timestamp[ru_id][CC_id], (unsigned long long)last_ru_rx_timestamp[ru_id][CC_id], (int)((*ptimestamp/RC.ru[ru_id]->frame_parms.samples_per_tti)%10)); @@ -1087,8 +1087,9 @@ 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) { - LOG_D(EMU,"RU_trx_read generating UL subframe %d (Ts %llu, current TS %llu)\n", + if (RC.ru[ru_id]->frame_parms.frame_type == FDD || + subframe_select(&RC.ru[ru_id]->frame_parms,subframe) != SF_DL) { + LOG_D(PHY,"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 0ad9ab947c48988266a70594060d32d5afbb12ba Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Sun, 13 May 2018 15:53:59 -0700 Subject: [PATCH 82/88] dmrs-based OTA synchronization for RU --- openair1/PHY/LTE_ESTIMATION/defs.h | 9 ++ openair1/PHY/LTE_ESTIMATION/lte_sync_time.c | 118 ++++++++++++++++++++ openair1/PHY/LTE_TRANSPORT/drs_modulation.c | 74 ++++++------ openair1/PHY/LTE_TRANSPORT/proto.h | 18 +-- openair1/PHY/defs.h | 4 + openair1/SCHED/phy_procedures_lte_ue.c | 2 + openair1/SCHED/ru_procedures.c | 27 ++++- targets/RT/USER/lte-ru.c | 61 ++-------- targets/RT/USER/lte-softmodem.c | 3 +- targets/RT/USER/lte-softmodem.h | 4 +- 10 files changed, 220 insertions(+), 100 deletions(-) diff --git a/openair1/PHY/LTE_ESTIMATION/defs.h b/openair1/PHY/LTE_ESTIMATION/defs.h index a7b5d14701..07aad85e1a 100644 --- a/openair1/PHY/LTE_ESTIMATION/defs.h +++ b/openair1/PHY/LTE_ESTIMATION/defs.h @@ -92,6 +92,15 @@ int lte_sync_time_eNB_emul(PHY_VARS_eNB *phy_vars_eNb, uint8_t sect_id, int32_t *sync_val); + +int ru_sync_time_init(RU_t *ru); + +int ru_sync_time(RU_t *ru, + int64_t *lev, + int64_t *avg); + +void ru_sync_time_free(RU_t *ru); + /*! \brief This function performs channel estimation including frequency and temporal interpolation \param phy_vars_ue Pointer to UE PHY variables diff --git a/openair1/PHY/LTE_ESTIMATION/lte_sync_time.c b/openair1/PHY/LTE_ESTIMATION/lte_sync_time.c index d73d790a2b..319d310af2 100644 --- a/openair1/PHY/LTE_ESTIMATION/lte_sync_time.c +++ b/openair1/PHY/LTE_ESTIMATION/lte_sync_time.c @@ -479,6 +479,65 @@ int lte_sync_time(int **rxdata, ///rx data in time domain } + +int ru_sync_time_init(RU_t *ru) // LTE_UE_COMMON *common_vars +{ + + int16_t dmrs[2048]; + int16_t *dmrsp[2] = {dmrs,NULL}; + + ru->dmrssync = (int16_t*)malloc16_clear(ru->frame_parms.N_RB_DL*2*sizeof(int16_t)); + generate_drs_pusch(NULL,NULL, + &ru->frame_parms, + (int32_t**)dmrsp, + 0, + AMP, + 0, + 0, + ru->frame_parms.N_RB_DL, + 0); + + switch (ru->frame_parms.N_RB_DL) { + case 6: + idft128(dmrs, /// complex input + ru->dmrssync, /// complex output + 1); + break; + case 25: + idft512(dmrs, + ru->dmrssync, /// complex output + 1); + break; + case 50: + idft1024(dmrs, + ru->dmrssync, /// complex output + 1); + break; + + case 75: + idft1536(dmrs, + ru->dmrssync, + 1); /// complex output + break; + case 100: + idft2048(dmrs, + ru->dmrssync, /// complex output + 1); + break; + default: + AssertFatal(1==0,"Unsupported N_RB_DL %d\n",ru->frame_parms.N_RB_DL); + break; + } + + return(0); +} + +void ru_sync_time_free(RU_t *ru) { + + AssertFatal(ru->dmrssync!=NULL,"ru->dmrssync is NULL\n"); + free(ru->dmrssync); +} + //#define DEBUG_PHY int lte_sync_time_eNB(int32_t **rxdata, ///rx data in time domain @@ -570,3 +629,62 @@ int lte_sync_time_eNB(int32_t **rxdata, ///rx data in time domain } +int ru_sync_time(RU_t *ru, + int64_t *lev, + int64_t *avg) +{ + + + LTE_DL_FRAME_PARMS *frame_parms = &ru->frame_parms; + + // perform a time domain correlation using the oversampled sync sequence + + int length = LTE_NUMBER_OF_SUBFRAMES_PER_FRAME*frame_parms->samples_per_tti; + + + // circular copy of beginning to end of rxdata buffer. Note: buffer should be big enough upon calling this function + for (int ar=0;arnb_rx;ar++) memcpy((void*)&ru->common.rxdata[ar][2*length], + (void*)&ru->common.rxdata[ar][0], + frame_parms->ofdm_symbol_size); + + int32_t tmp0; + int32_t magtmp0,maxlev0=0; + int maxpos0=0; + int64_t avg0=0; + int32_t result; + + + for (int n=0; nnb_rx; ar++) { + + result = dot_product(ru->dmrssync, + (int16_t*) &ru->common.rxdata[ar][n], + frame_parms->ofdm_symbol_size, + 11); + ((int16_t*)&tmp0)[0] += ((int16_t*) &result)[0]; + ((int16_t*)&tmp0)[1] += ((int16_t*) &result)[1]; + } + + // tmpi holds ++...+ + + magtmp0 = abs32(tmp0); + + // this does max |tmp0(n)|^2 and argmax |tmp0(n)|^2 + + if (magtmp0>maxlev0) { maxlev0 = magtmp0; maxpos0 = n; } + avg0 += magtmp0; + } + avg0/=(length/4); + + int dmrsoffset = 2*(frame_parms->ofdm_symbol_size+frame_parms->nb_prefix_samples) + frame_parms->nb_prefix_samples0; + + if ((int64_t)maxlev0 > (5*avg0)) {*lev = maxlev0; *avg=avg0; return((length+maxpos0-dmrsoffset)%length);} + + return(-1); + + +} diff --git a/openair1/PHY/LTE_TRANSPORT/drs_modulation.c b/openair1/PHY/LTE_TRANSPORT/drs_modulation.c index a0bde219b5..30a78ed0fd 100644 --- a/openair1/PHY/LTE_TRANSPORT/drs_modulation.c +++ b/openair1/PHY/LTE_TRANSPORT/drs_modulation.c @@ -36,6 +36,8 @@ int generate_drs_pusch(PHY_VARS_UE *ue, UE_rxtx_proc_t *proc, + LTE_DL_FRAME_PARMS *frame_parms, + int32_t **txdataF, uint8_t eNB_id, short amp, unsigned int subframe, @@ -54,29 +56,33 @@ int generate_drs_pusch(PHY_VARS_UE *ue, int16_t alpha_re[12] = {32767, 28377, 16383, 0,-16384, -28378,-32768,-28378,-16384, -1, 16383, 28377}; int16_t alpha_im[12] = {0, 16383, 28377, 32767, 28377, 16383, 0,-16384,-28378,-32768,-28378,-16384}; - uint8_t cyclic_shift,cyclic_shift0,cyclic_shift1; - LTE_DL_FRAME_PARMS *frame_parms = &ue->frame_parms; - int32_t *txdataF = ue->common_vars.txdataF[ant]; + uint8_t cyclic_shift,cyclic_shift0=0,cyclic_shift1=0; + LTE_DL_FRAME_PARMS *fp = (ue==NULL) ? frame_parms : &ue->frame_parms; + int32_t *txF = (ue==NULL) ? txdataF[ant] : ue->common_vars.txdataF[ant]; uint32_t u,v,alpha_ind; - uint32_t u0=frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.grouphop[subframe<<1]; - uint32_t u1=frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.grouphop[1+(subframe<<1)]; - uint32_t v0=frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.seqhop[subframe<<1]; - uint32_t v1=frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.seqhop[1+(subframe<<1)]; + uint32_t u0=0,u1=0,v0=0,v1=0; int32_t ref_re,ref_im; - uint8_t harq_pid = subframe2harq_pid(frame_parms,proc->frame_tx,subframe); + uint8_t harq_pid = (proc == NULL) ? 0: subframe2harq_pid(fp,proc->frame_tx,subframe); - cyclic_shift0 = (frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.cyclicShift + - ue->ulsch[eNB_id]->harq_processes[harq_pid]->n_DMRS2 + - frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.nPRS[subframe<<1]+ - ((ue->ulsch[0]->cooperation_flag==2)?10:0)+ - ant*6) % 12; - // printf("PUSCH.cyclicShift %d, n_DMRS2 %d, nPRS %d\n",frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.cyclicShift,ue->ulsch[eNB_id]->n_DMRS2,ue->lte_frame_parms.pusch_config_common.ul_ReferenceSignalsPUSCH.nPRS[subframe<<1]); - cyclic_shift1 = (frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.cyclicShift + - ue->ulsch[eNB_id]->harq_processes[harq_pid]->n_DMRS2 + - frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.nPRS[(subframe<<1)+1]+ - ((ue->ulsch[0]->cooperation_flag==2)?10:0)+ - ant*6) % 12; + if (ue!=NULL) { + cyclic_shift0 = (fp->pusch_config_common.ul_ReferenceSignalsPUSCH.cyclicShift + + ue->ulsch[eNB_id]->harq_processes[harq_pid]->n_DMRS2 + + fp->pusch_config_common.ul_ReferenceSignalsPUSCH.nPRS[subframe<<1]+ + ((ue->ulsch[0]->cooperation_flag==2)?10:0)+ + ant*6) % 12; + // printf("PUSCH.cyclicShift %d, n_DMRS2 %d, nPRS %d\n",frame_parms->pusch_config_common.ul_ReferenceSignalsPUSCH.cyclicShift,ue->ulsch[eNB_id]->n_DMRS2,ue->lte_frame_parms.pusch_config_common.ul_ReferenceSignalsPUSCH.nPRS[subframe<<1]); + cyclic_shift1 = (fp->pusch_config_common.ul_ReferenceSignalsPUSCH.cyclicShift + + ue->ulsch[eNB_id]->harq_processes[harq_pid]->n_DMRS2 + + fp->pusch_config_common.ul_ReferenceSignalsPUSCH.nPRS[(subframe<<1)+1]+ + ((ue->ulsch[0]->cooperation_flag==2)?10:0)+ + ant*6) % 12; + u0=fp->pusch_config_common.ul_ReferenceSignalsPUSCH.grouphop[subframe<<1]; + u1=fp->pusch_config_common.ul_ReferenceSignalsPUSCH.grouphop[1+(subframe<<1)]; + v0=fp->pusch_config_common.ul_ReferenceSignalsPUSCH.seqhop[subframe<<1]; + v1=fp->pusch_config_common.ul_ReferenceSignalsPUSCH.seqhop[1+(subframe<<1)]; + } + // cyclic_shift0 = 0; // cyclic_shift1 = 0; Msc_RS = 12*nb_rb; @@ -90,9 +96,9 @@ int generate_drs_pusch(PHY_VARS_UE *ue, return(-1); } - for (l = (3 - frame_parms->Ncp),u=u0,v=v0,cyclic_shift=cyclic_shift0; + for (l = (3 - fp->Ncp),u=u0,v=v0,cyclic_shift=cyclic_shift0; lsymbols_per_tti; - l += (7 - frame_parms->Ncp),u=u1,v=v1,cyclic_shift=cyclic_shift1) { + l += (7 - fp->Ncp),u=u1,v=v1,cyclic_shift=cyclic_shift1) { drs_offset = 0; #ifdef DEBUG_DRS @@ -100,9 +106,9 @@ int generate_drs_pusch(PHY_VARS_UE *ue, #endif - re_offset = frame_parms->first_carrier_offset; - subframe_offset = subframe*frame_parms->symbols_per_tti*frame_parms->ofdm_symbol_size; - symbol_offset = subframe_offset + frame_parms->ofdm_symbol_size*l; + re_offset = fp->first_carrier_offset; + subframe_offset = subframe*fp->symbols_per_tti*frame_parms->ofdm_symbol_size; + symbol_offset = subframe_offset + fp->ofdm_symbol_size*l; #ifdef DEBUG_DRS @@ -110,7 +116,7 @@ int generate_drs_pusch(PHY_VARS_UE *ue, #endif alpha_ind = 0; - for (rb=0; rbN_RB_UL; rb++) { + for (rb=0; rbN_RB_UL; rb++) { if ((rb >= first_rb) && (rb<(first_rb+nb_rb))) { @@ -122,12 +128,12 @@ int generate_drs_pusch(PHY_VARS_UE *ue, ref_re = (int32_t) ul_ref_sigs[u][v][Msc_RS_idx][drs_offset<<1]; ref_im = (int32_t) ul_ref_sigs[u][v][Msc_RS_idx][(drs_offset<<1)+1]; - ((int16_t*) txdataF)[2*(symbol_offset + re_offset)] = (int16_t) (((ref_re*alpha_re[alpha_ind]) - + ((int16_t*) txF)[2*(symbol_offset + re_offset)] = (int16_t) (((ref_re*alpha_re[alpha_ind]) - (ref_im*alpha_im[alpha_ind]))>>15); - ((int16_t*) txdataF)[2*(symbol_offset + re_offset)+1] = (int16_t) (((ref_re*alpha_im[alpha_ind]) + + ((int16_t*) txF)[2*(symbol_offset + re_offset)+1] = (int16_t) (((ref_re*alpha_im[alpha_ind]) + (ref_im*alpha_re[alpha_ind]))>>15); - ((short*) txdataF)[2*(symbol_offset + re_offset)] = (short) ((((short*) txdataF)[2*(symbol_offset + re_offset)]*(int32_t)amp)>>15); - ((short*) txdataF)[2*(symbol_offset + re_offset)+1] = (short) ((((short*) txdataF)[2*(symbol_offset + re_offset)+1]*(int32_t)amp)>>15); + ((short*) txF)[2*(symbol_offset + re_offset)] = (short) ((((short*) txF)[2*(symbol_offset + re_offset)]*(int32_t)amp)>>15); + ((short*) txF)[2*(symbol_offset + re_offset)+1] = (short) ((((short*) txF)[2*(symbol_offset + re_offset)+1]*(int32_t)amp)>>15); alpha_ind = (alpha_ind + cyclic_shift); @@ -140,14 +146,14 @@ int generate_drs_pusch(PHY_VARS_UE *ue, symbol_offset, alpha_ind, re_offset, - ((short*) txdataF)[2*(symbol_offset + re_offset)], - ((short*) txdataF)[2*(symbol_offset + re_offset)+1]); + ((short*) txF)[2*(symbol_offset + re_offset)], + ((short*) txF)[2*(symbol_offset + re_offset)+1]); #endif // DEBUG_DRS re_offset++; drs_offset++; - if (re_offset >= frame_parms->ofdm_symbol_size) + if (re_offset >= fp->ofdm_symbol_size) re_offset = 0; } @@ -156,8 +162,8 @@ int generate_drs_pusch(PHY_VARS_UE *ue, // check if we crossed the symbol boundary and skip DC - if (re_offset >= frame_parms->ofdm_symbol_size) { - if (frame_parms->N_RB_DL&1) // odd number of RBs + if (re_offset >= fp->ofdm_symbol_size) { + if (fp->N_RB_DL&1) // odd number of RBs re_offset=6; else // even number of RBs (doesn't straddle DC) re_offset=0; diff --git a/openair1/PHY/LTE_TRANSPORT/proto.h b/openair1/PHY/LTE_TRANSPORT/proto.h index 0e1a60c0b9..2915918583 100644 --- a/openair1/PHY/LTE_TRANSPORT/proto.h +++ b/openair1/PHY/LTE_TRANSPORT/proto.h @@ -1660,15 +1660,17 @@ int32_t generate_srs_tx(PHY_VARS_UE *phy_vars_ue, /*! \brief This function generates the downlink reference signal for the PUSCH according to 36.211 v8.6.0. The DRS occuies the RS defined by rb_alloc and the symbols 2 and 8 for extended CP and 3 and 10 for normal CP. */ +int generate_drs_pusch(PHY_VARS_UE *ue, + UE_rxtx_proc_t *proc, + LTE_DL_FRAME_PARMS *frame_parms, + int32_t **txdataF, + uint8_t eNB_id, + short amp, + unsigned int subframe, + unsigned int first_rb, + unsigned int nb_rb, + uint8_t ant); -int32_t generate_drs_pusch(PHY_VARS_UE *phy_vars_ue, - UE_rxtx_proc_t *proc, - uint8_t eNB_id, - int16_t amp, - uint32_t subframe, - uint32_t first_rb, - uint32_t nb_rb, - uint8_t ant); /*! \brief This function initializes the Group Hopping, Sequence Hopping and nPRS sequences for PUCCH/PUSCH according to 36.211 v8.6.0. It should be called after configuration of UE (reception of SIB2/3) and initial configuration of eNB (or after reconfiguration of cell-specific parameters). diff --git a/openair1/PHY/defs.h b/openair1/PHY/defs.h index 811517dff5..73dfe65794 100644 --- a/openair1/PHY/defs.h +++ b/openair1/PHY/defs.h @@ -717,6 +717,8 @@ typedef struct RU_t_s{ int rx_offset; /// flag to indicate the RU is a slave to another source int is_slave; + /// flag to indicate that the RU should generate the DMRS sequence in slot 2 (subframe 1) for OTA synchronization and calibration + int generate_dmrs_sync; /// flag to indicate if the RU has a control channel int has_ctrl_prt; /// counter to delay start of processing of RU until HW settles @@ -830,6 +832,8 @@ typedef struct RU_t_s{ RU_proc_t proc; /// stats thread pthread descriptor pthread_t ru_stats_thread; + /// OTA synchronization signal + int16_t *dmrssync; } RU_t; diff --git a/openair1/SCHED/phy_procedures_lte_ue.c b/openair1/SCHED/phy_procedures_lte_ue.c index 6f8f7f0579..562a15899d 100644 --- a/openair1/SCHED/phy_procedures_lte_ue.c +++ b/openair1/SCHED/phy_procedures_lte_ue.c @@ -1851,6 +1851,8 @@ void ue_ulsch_uespec_procedures(PHY_VARS_UE *ue,UE_rxtx_proc_t *proc,uint8_t eNB for (aa=0; aa<1/*frame_parms->nb_antennas_tx*/; aa++) generate_drs_pusch(ue, proc, + (LTE_DL_FRAME_PARMS *)NULL, + (int32_t**)NULL, eNB_id, tx_amp, subframe_tx, diff --git a/openair1/SCHED/ru_procedures.c b/openair1/SCHED/ru_procedures.c index 534023632c..3fed116125 100644 --- a/openair1/SCHED/ru_procedures.c +++ b/openair1/SCHED/ru_procedures.c @@ -84,11 +84,28 @@ void feptx0(RU_t *ru,int slot) { 6, fp->nb_prefix_samples, CYCLIC_PREFIX); - else normal_prefix_mod(&ru->common.txdataF_BF[aa][slot*slot_sizeF], - (int*)&ru->common.txdata[aa][slot_offset], - 7, - fp); - + else { + AssertFatal(ru->generate_dmrs_sync==1 && (fp->frame_type != TDD || ru->is_slave == 1), + "ru->generate_dmrs_sync should not be set, frame_type %d, is_slave %d\n", + fp->frame_type,ru->is_slave); + + if (ru->generate_dmrs_sync == 1 && slot == 0 && subframe == 1 && aa==0) { + generate_drs_pusch((PHY_VARS_UE *)NULL, + (UE_rxtx_proc_t*)NULL, + fp, + ru->common.txdataF_BF, + 0, + AMP, + 1, + 0, + fp->N_RB_DL, + aa); + } + normal_prefix_mod(&ru->common.txdataF_BF[aa][slot*slot_sizeF], + (int*)&ru->common.txdata[aa][slot_offset], + 7, + fp); + } /* len = fp->samples_per_tti>>1; diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index be3fdfa9f1..a60588b2fd 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -123,7 +123,7 @@ extern volatile int oai_exit; extern void phy_init_RU(RU_t*); extern void phy_free_RU(RU_t*); -void init_RU(char*,clock_source_t clock_source,clock_source_t time_source); +void init_RU(char*,clock_source_t clock_source,clock_source_t time_source,int generate_dmrssync); void stop_RU(int nb_ru); void do_ru_sync(RU_t *ru); @@ -2042,8 +2042,8 @@ void *ru_thread_synch(void *arg) { RU_t *ru = (RU_t*)arg; LTE_DL_FRAME_PARMS *fp=&ru->frame_parms; int32_t sync_pos,sync_pos2; - uint32_t peak_val; - uint32_t sync_corr[307200] __attribute__((aligned(32))); + int64_t peak_val; + int64_t avg; static int ru_thread_synch_status=0; int cnt=0; @@ -2052,7 +2052,7 @@ void *ru_thread_synch(void *arg) { wait_sync("ru_thread_synch"); // initialize variables for PSS detection - lte_sync_time_init(&ru->frame_parms); + ru_sync_time_init(ru); while (!oai_exit) { @@ -2064,63 +2064,22 @@ void *ru_thread_synch(void *arg) { // run intial synch like UE LOG_I(PHY,"Running initial synchronization\n"); - sync_pos = lte_sync_time_eNB(ru->common.rxdata, - fp, - fp->samples_per_tti*5, + ru->rx_offset = ru_sync_time(ru, &peak_val, - sync_corr); + &avg); LOG_I(PHY,"RU synch cnt %d: %d, val %d\n",cnt,sync_pos,peak_val); cnt++; if (sync_pos >= 0) { - if (sync_pos >= fp->nb_prefix_samples) - sync_pos2 = sync_pos - fp->nb_prefix_samples; - else - sync_pos2 = sync_pos + (fp->samples_per_tti*10) - fp->nb_prefix_samples; - int sync_pos_slot; - if (fp->frame_type == FDD) { - - // PSS is hypothesized in last symbol of first slot in Frame - sync_pos_slot = (fp->samples_per_tti>>1) - fp->ofdm_symbol_size - fp->nb_prefix_samples; - } - else { - // PSS is hypothesized in 2nd symbol of third slot in Frame (S-subframe) - sync_pos_slot = fp->samples_per_tti + - (fp->ofdm_symbol_size<<1) + - fp->nb_prefix_samples0 + - (fp->nb_prefix_samples); - } - if (sync_pos2 >= sync_pos_slot) - ru->rx_offset = sync_pos2 - sync_pos_slot; - else - ru->rx_offset = (fp->samples_per_tti*10) + sync_pos2 - sync_pos_slot; - - - LOG_I(PHY,"Estimated sync_pos %d, peak_val %d => timing offset %d\n",sync_pos,peak_val,ru->rx_offset); - - /* - if ((peak_val > 300000) && (sync_pos > 0)) { - // if (sync_pos++ > 3) { - write_output("ru_sync.m","sync",(void*)&sync_corr[0],fp->samples_per_tti*5,1,2); - write_output("ru_rx.m","rxs",(void*)ru->ru_time.rxdata[0][0],fp->samples_per_tti*10,1,1); - exit(-1); - } - */ + LOG_I(PHY,"Estimated peak_val %d dB, avg %d => timing offset %d\n",ru->rx_offset,dB_fixed(peak_val),dB_fixed(ru->rx_offset)); ru->in_synch = 1; } // symc_pos > 0 - else { - if (cnt>1000) { - write_output("ru_sync.m","sync",(void*)&sync_corr[0],fp->samples_per_tti*5,1,2); - write_output("ru_rx.m","rxs",(void*)ru->common.rxdata[0],fp->samples_per_tti*10,1,1); - exit(1); - } - } + else AssertFatal(cnt<1000,"Cannot find synch reference\n"); } // ru->in_synch==0 - if (release_thread(&ru->proc.mutex_synch,&ru->proc.instance_cnt_synch,"ru_synch_thread") < 0) break; } // oai_exit - lte_sync_time_free(); + ru_sync_time_free(ru); ru_thread_synch_status = 0; return &ru_thread_synch_status; @@ -2735,7 +2694,7 @@ void set_function_spec_param(RU_t *ru) extern void RCconfig_RU(void); -void init_RU(char *rf_config_file, clock_source_t clock_source,clock_source_t time_source) { +void init_RU(char *rf_config_file, clock_source_t clock_source,clock_source_t time_source,int send_dmrssync) { int ru_id; RU_t *ru; diff --git a/targets/RT/USER/lte-softmodem.c b/targets/RT/USER/lte-softmodem.c index 179d6ccb0d..02a51da218 100644 --- a/targets/RT/USER/lte-softmodem.c +++ b/targets/RT/USER/lte-softmodem.c @@ -134,6 +134,7 @@ volatile int oai_exit = 0; static clock_source_t clock_source = internal,time_source=internal; static int wait_for_sync = 0; +static int send_dmrssync = 0; unsigned int mmapped_dma=0; int single_thread_flag=1; @@ -1167,7 +1168,7 @@ int main( int argc, char **argv ) printf("About to Init RU threads RC.nb_RU:%d\n", RC.nb_RU); if (RC.nb_RU >0) { printf("Initializing RU threads\n"); - init_RU(rf_config_file,clock_source,time_source); + init_RU(rf_config_file,clock_source,time_source,send_dmrssync); for (ru_id=0;ru_idrf_map.card=0; RC.ru[ru_id]->rf_map.chain=CC_id+chain_offset; diff --git a/targets/RT/USER/lte-softmodem.h b/targets/RT/USER/lte-softmodem.h index 1b02cbdc6a..3b96255c6d 100644 --- a/targets/RT/USER/lte-softmodem.h +++ b/targets/RT/USER/lte-softmodem.h @@ -63,6 +63,7 @@ #define CONFIG_HLP_PHYTST "test UE phy layer, mac disabled\n" #define CONFIG_HLP_DMAMAP "sets flag for improved EXMIMO UE performance\n" #define CONFIG_HLP_EXCCLK "tells hardware to use an external clock reference\n" +#define CONFIG_HLP_DMRSSYNC "tells RU to insert DMRS in subframe 1 slot 0" #define CONFIG_HLP_USIM "use XOR autentication algo in case of test usim mode\n" #define CONFIG_HLP_NOSNGLT "Disables single-thread mode in lte-softmodem\n" #define CONFIG_HLP_TADV "Set timing_advance\n" @@ -145,6 +146,7 @@ extern int16_t dlsch_demod_shift; {"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}, \ +{"send_dmrs_sync", CONFIG_HLP_DMRSSYNC, PARAMFLAG_BOOL, uptr:&send_dmrssync, 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}, \ @@ -245,7 +247,7 @@ extern void stop_eNB(int); extern void kill_eNB_proc(int inst); // In lte-ru.c -extern void init_RU(const char*,clock_source_t clock_source,clock_source_t time_source); +extern void init_RU(const char*,clock_source_t clock_source,clock_source_t time_source,int send_dmrssync); extern void init_RU_proc(RU_t *ru); extern void stop_RU(int nb_ru); extern void kill_RU_proc(int inst); From 8364b4f97d1b4853a73261063081ba4ed98c1d5d Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Sat, 26 May 2018 05:49:49 +0200 Subject: [PATCH 83/88] adding thread_tx from develop --- targets/RT/USER/lte-ru.c | 57 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 55 insertions(+), 2 deletions(-) diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index a60588b2fd..aaf842a266 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -134,7 +134,7 @@ void configure_rru(int idx, void *arg); int attach_rru(RU_t *ru); - +void reset_proc(RU_t *ru); int connect_rau(RU_t *ru); extern uint16_t sf_ahead; @@ -1574,8 +1574,61 @@ 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; + cpu_set_t cpuset; + CPU_ZERO(&cpuset); + + + thread_top_init("ru_thread_tx",1,400000,500000,500000); + + //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"); + + 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; + + + 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); + + // do OFDM if needed + if ((ru->fh_north_asynch_in == NULL) && (ru->feptx_ofdm)) ru->feptx_ofdm(ru); + 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"); + + 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; +} + + -void reset_proc(RU_t *ru); static void* ru_thread_control( void* param ) { From 285e01943d224b6909f6b2f9a84e52c8a536e214 Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Sat, 26 May 2018 06:26:33 +0200 Subject: [PATCH 84/88] fixing conflicts --- targets/RT/USER/lte-ru.c | 258 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 257 insertions(+), 1 deletion(-) diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index aaf842a266..07d2a46efa 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -138,7 +138,7 @@ void reset_proc(RU_t *ru); int connect_rau(RU_t *ru); extern uint16_t sf_ahead; - +static void* ru_thread_control( void* param ); /*************************************************************/ /* Functions to attach and configure RRU */ @@ -2992,3 +2992,259 @@ void RCconfig_RU(void) { return; } + + +static void* ru_thread_control( void* param ) { + + + RU_t *ru = (RU_t*)param; + RU_proc_t *proc = &ru->proc; + RRU_CONFIG_msg_t rru_config_msg; + ssize_t msg_len; + int len, ret; + + + // 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) wait_eNBs(); + } + + + ru->state = (ru->function==eNodeB_3GPP)? RU_RUN : RU_IDLE; + LOG_I(PHY,"Control channel ON for RU %d\n", ru->idx); + + while (!oai_exit) // Change the cond + { + msg_len = sizeof(RRU_CONFIG_msg_t); // TODO : check what should be the msg len + + if (ru->state == RU_IDLE && ru->if_south != LOCAL_RF) + send_tick(ru); + + + if ((len = ru->ifdevice.trx_ctlrecv_func(&ru->ifdevice, + &rru_config_msg, + msg_len))<0) { + LOG_D(PHY,"Waiting msg for RU %d\n", ru->idx); + } + else + { + switch(rru_config_msg.type) + { + case RAU_tick: // RRU + if (ru->if_south != LOCAL_RF){ + LOG_I(PHY,"Received Tick msg...Ignoring\n"); + }else{ + LOG_I(PHY,"Tick received from RAU\n"); + + if (send_capab(ru) == 0) ru->state = RU_CONFIG; + } + break; + + case RRU_capabilities: // RAU + if (ru->if_south == LOCAL_RF) LOG_E(PHY,"Received RRU_capab msg...Ignoring\n"); + + else{ + msg_len = sizeof(RRU_CONFIG_msg_t)-MAX_RRU_CONFIG_SIZE+sizeof(RRU_capabilities_t); + + AssertFatal(rru_config_msg.len==msg_len,"Received capabilities with incorrect length (%d!=%d)\n",(int)rru_config_msg.len,(int)msg_len); + LOG_I(PHY,"Received capabilities from RRU %d (len %d/%d, num_bands %d,max_pdschReferenceSignalPower %d, max_rxgain %d, nb_tx %d, nb_rx %d)\n",ru->idx, + (int)rru_config_msg.len,(int)msg_len, + ((RRU_capabilities_t*)&rru_config_msg.msg[0])->num_bands, + ((RRU_capabilities_t*)&rru_config_msg.msg[0])->max_pdschReferenceSignalPower[0], + ((RRU_capabilities_t*)&rru_config_msg.msg[0])->max_rxgain[0], + ((RRU_capabilities_t*)&rru_config_msg.msg[0])->nb_tx[0], + ((RRU_capabilities_t*)&rru_config_msg.msg[0])->nb_rx[0]); + + configure_ru(ru->idx,(RRU_capabilities_t *)&rru_config_msg.msg[0]); + + // send config + if (send_config(ru,rru_config_msg) == 0) ru->state = RU_CONFIG; + } + + break; + + case RRU_config: // RRU + if (ru->if_south == LOCAL_RF){ + LOG_I(PHY,"Configuration received from RAU (num_bands %d,band0 %d,txfreq %u,rxfreq %u,att_tx %d,att_rx %d,N_RB_DL %d,N_RB_UL %d,3/4FS %d, prach_FO %d, prach_CI %d)\n", + ((RRU_config_t *)&rru_config_msg.msg[0])->num_bands, + ((RRU_config_t *)&rru_config_msg.msg[0])->band_list[0], + ((RRU_config_t *)&rru_config_msg.msg[0])->tx_freq[0], + ((RRU_config_t *)&rru_config_msg.msg[0])->rx_freq[0], + ((RRU_config_t *)&rru_config_msg.msg[0])->att_tx[0], + ((RRU_config_t *)&rru_config_msg.msg[0])->att_rx[0], + ((RRU_config_t *)&rru_config_msg.msg[0])->N_RB_DL[0], + ((RRU_config_t *)&rru_config_msg.msg[0])->N_RB_UL[0], + ((RRU_config_t *)&rru_config_msg.msg[0])->threequarter_fs[0], + ((RRU_config_t *)&rru_config_msg.msg[0])->prach_FreqOffset[0], + ((RRU_config_t *)&rru_config_msg.msg[0])->prach_ConfigIndex[0]); + + configure_rru(ru->idx, (void*)&rru_config_msg.msg[0]); + + + fill_rf_config(ru,ru->rf_config_file); + init_frame_parms(&ru->frame_parms,1); + ru->frame_parms.nb_antennas_rx = ru->nb_rx; + phy_init_RU(ru); + + //if (ru->is_slave == 1) lte_sync_time_init(&ru->frame_parms); + + if (ru->rfdevice.is_init != 1){ + ret = openair0_device_load(&ru->rfdevice,&ru->openair0_cfg); + } + + + if (ru->rfdevice.trx_config_func) AssertFatal((ru->rfdevice.trx_config_func(&ru->rfdevice,&ru->openair0_cfg)==0), + "Failed to configure RF device for RU %d\n",ru->idx); + + + + + if (setup_RU_buffers(ru)!=0) { + printf("Exiting, cannot initialize RU Buffers\n"); + exit(-1); + } + + // send CONFIG_OK + + rru_config_msg.type = RRU_config_ok; + rru_config_msg.len = sizeof(RRU_CONFIG_msg_t); + LOG_I(PHY,"Sending CONFIG_OK to RAU %d\n", ru->idx); + + AssertFatal((ru->ifdevice.trx_ctlsend_func(&ru->ifdevice,&rru_config_msg,rru_config_msg.len)!=-1), + "RU %d failed send CONFIG_OK to RAU\n",ru->idx); + reset_proc(ru); + ru->state = RU_READY; + } else LOG_E(PHY,"Received RRU_config msg...Ignoring\n"); + + break; + + case RRU_config_ok: // RAU + if (ru->if_south == LOCAL_RF) LOG_E(PHY,"Received RRU_config_ok msg...Ignoring\n"); + else{ + + if (setup_RU_buffers(ru)!=0) { + printf("Exiting, cannot initialize RU Buffers\n"); + exit(-1); + } + + // Set state to RUN for Master RU, Others on SYNC + ru->state = (ru->is_slave == 1) ? RU_SYNC : RU_RUN ; + ru->in_synch = 0; + + + LOG_I(PHY, "Signaling main thread that RU %d (is_slave %d) is ready in state %s\n",ru->idx,ru->is_slave,ru_states[ru->state]); + pthread_mutex_lock(&RC.ru_mutex); + RC.ru_mask &= ~(1<idx); + pthread_cond_signal(&RC.ru_cond); + pthread_mutex_unlock(&RC.ru_mutex); + + wait_sync("ru_thread_control"); + + // send start + rru_config_msg.type = RRU_start; + rru_config_msg.len = sizeof(RRU_CONFIG_msg_t); // TODO: set to correct msg len + + + LOG_I(PHY,"Sending Start to RRU %d\n", ru->idx); + AssertFatal((ru->ifdevice.trx_ctlsend_func(&ru->ifdevice,&rru_config_msg,rru_config_msg.len)!=-1),"Failed to send msg to RU %d\n",ru->idx); + + + pthread_mutex_lock(&proc->mutex_ru); + proc->instance_cnt_ru = 1; + pthread_mutex_unlock(&proc->mutex_ru); + if (pthread_cond_signal(&proc->cond_ru_thread) != 0) { + LOG_E( PHY, "ERROR pthread_cond_signal for RU %d\n",ru->idx); + exit_fun( "ERROR pthread_cond_signal" ); + break; + } + } + break; + + case RRU_start: // RRU + if (ru->if_south == LOCAL_RF){ + LOG_I(PHY,"Start received from RAU\n"); + + if (ru->state == RU_READY){ + + LOG_I(PHY, "Signaling main thread that RU %d is ready\n",ru->idx); + pthread_mutex_lock(&RC.ru_mutex); + RC.ru_mask &= ~(1<idx); + pthread_cond_signal(&RC.ru_cond); + pthread_mutex_unlock(&RC.ru_mutex); + + wait_sync("ru_thread_control"); + + ru->state = (ru->is_slave == 1) ? RU_SYNC : RU_RUN ; + ru->cmd = EMPTY; + pthread_mutex_lock(&proc->mutex_ru); + proc->instance_cnt_ru = 1; + pthread_mutex_unlock(&proc->mutex_ru); + if (pthread_cond_signal(&proc->cond_ru_thread) != 0) { + LOG_E( PHY, "ERROR pthread_cond_signal for RU %d\n",ru->idx); + exit_fun( "ERROR pthread_cond_signal" ); + break; + } + } + else LOG_E(PHY,"RRU not ready, cannot start\n"); + + } else LOG_E(PHY,"Received RRU_start msg...Ignoring\n"); + + + break; + + case RRU_sync_ok: //RAU + if (ru->if_south == LOCAL_RF) LOG_E(PHY,"Received RRU_config_ok msg...Ignoring\n"); + else{ + if (ru->is_slave == 1){ + LOG_I(PHY,"Received RRU_sync_ok from RRU %d\n",ru->idx); + // Just change the state of the RRU to unblock ru_thread() + ru->state = RU_RUN; + }else LOG_E(PHY,"Received RRU_sync_ok from a master RRU...Ignoring\n"); + } + break; + case RRU_frame_resynch: //RRU + if (ru->if_south != LOCAL_RF) LOG_E(PHY,"Received RRU frame resynch message, should not happen in RAU\n"); + else { + LOG_I(PHY,"Received RRU_frame_resynch command\n"); + ru->cmd = RU_FRAME_RESYNCH; + ru->cmdval = ((uint16_t*)&rru_config_msg.msg[0])[0]; + LOG_I(PHY,"Received Frame Resynch messaage with value %d\n",ru->cmdval); + } + break; + + case RRU_stop: // RRU + if (ru->if_south == LOCAL_RF){ + LOG_I(PHY,"Stop received from RAU\n"); + + if (ru->state == RU_RUN || ru->state == RU_ERROR){ + + LOG_I(PHY,"Stopping RRU\n"); + ru->state = RU_READY; + // TODO: stop ru_thread + }else{ + LOG_I(PHY,"RRU not running, can't stop\n"); + } + }else LOG_E(PHY,"Received RRU_stop msg...Ignoring\n"); + + break; + + default: + if (ru->if_south != LOCAL_RF){ + if (ru->state == RU_IDLE){ + // Keep sending TICK + send_tick(ru); + } + } + + break; + } // switch + } //else + + + }//while + return(NULL); +} From 3864136700e86eb8d97afccea5345fdad2f3dfe2 Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Sat, 26 May 2018 06:30:36 +0200 Subject: [PATCH 85/88] fixing conflicts --- targets/RT/USER/lte-ru.c | 254 --------------------------------------- 1 file changed, 254 deletions(-) diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index 07d2a46efa..300ba3414a 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -1630,260 +1630,6 @@ static void* ru_thread_tx( void* param ) { -static void* ru_thread_control( void* param ) { - - - RU_t *ru = (RU_t*)param; - RU_proc_t *proc = &ru->proc; - RRU_CONFIG_msg_t rru_config_msg; - ssize_t msg_len; - int len, ret; - - - // 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) wait_eNBs(); - } - - - ru->state = (ru->function==eNodeB_3GPP)? RU_RUN : RU_IDLE; - LOG_I(PHY,"Control channel ON for RU %d\n", ru->idx); - - while (!oai_exit) // Change the cond - { - msg_len = sizeof(RRU_CONFIG_msg_t); // TODO : check what should be the msg len - - if (ru->state == RU_IDLE && ru->if_south != LOCAL_RF) - send_tick(ru); - - - if ((len = ru->ifdevice.trx_ctlrecv_func(&ru->ifdevice, - &rru_config_msg, - msg_len))<0) { - LOG_D(PHY,"Waiting msg for RU %d\n", ru->idx); - } - else - { - switch(rru_config_msg.type) - { - case RAU_tick: // RRU - if (ru->if_south != LOCAL_RF){ - LOG_I(PHY,"Received Tick msg...Ignoring\n"); - }else{ - LOG_I(PHY,"Tick received from RAU\n"); - - if (send_capab(ru) == 0) ru->state = RU_CONFIG; - } - break; - - case RRU_capabilities: // RAU - if (ru->if_south == LOCAL_RF) LOG_E(PHY,"Received RRU_capab msg...Ignoring\n"); - - else{ - msg_len = sizeof(RRU_CONFIG_msg_t)-MAX_RRU_CONFIG_SIZE+sizeof(RRU_capabilities_t); - - AssertFatal(rru_config_msg.len==msg_len,"Received capabilities with incorrect length (%d!=%d)\n",(int)rru_config_msg.len,(int)msg_len); - LOG_I(PHY,"Received capabilities from RRU %d (len %d/%d, num_bands %d,max_pdschReferenceSignalPower %d, max_rxgain %d, nb_tx %d, nb_rx %d)\n",ru->idx, - (int)rru_config_msg.len,(int)msg_len, - ((RRU_capabilities_t*)&rru_config_msg.msg[0])->num_bands, - ((RRU_capabilities_t*)&rru_config_msg.msg[0])->max_pdschReferenceSignalPower[0], - ((RRU_capabilities_t*)&rru_config_msg.msg[0])->max_rxgain[0], - ((RRU_capabilities_t*)&rru_config_msg.msg[0])->nb_tx[0], - ((RRU_capabilities_t*)&rru_config_msg.msg[0])->nb_rx[0]); - - configure_ru(ru->idx,(RRU_capabilities_t *)&rru_config_msg.msg[0]); - - // send config - if (send_config(ru,rru_config_msg) == 0) ru->state = RU_CONFIG; - } - - break; - - case RRU_config: // RRU - if (ru->if_south == LOCAL_RF){ - LOG_I(PHY,"Configuration received from RAU (num_bands %d,band0 %d,txfreq %u,rxfreq %u,att_tx %d,att_rx %d,N_RB_DL %d,N_RB_UL %d,3/4FS %d, prach_FO %d, prach_CI %d)\n", - ((RRU_config_t *)&rru_config_msg.msg[0])->num_bands, - ((RRU_config_t *)&rru_config_msg.msg[0])->band_list[0], - ((RRU_config_t *)&rru_config_msg.msg[0])->tx_freq[0], - ((RRU_config_t *)&rru_config_msg.msg[0])->rx_freq[0], - ((RRU_config_t *)&rru_config_msg.msg[0])->att_tx[0], - ((RRU_config_t *)&rru_config_msg.msg[0])->att_rx[0], - ((RRU_config_t *)&rru_config_msg.msg[0])->N_RB_DL[0], - ((RRU_config_t *)&rru_config_msg.msg[0])->N_RB_UL[0], - ((RRU_config_t *)&rru_config_msg.msg[0])->threequarter_fs[0], - ((RRU_config_t *)&rru_config_msg.msg[0])->prach_FreqOffset[0], - ((RRU_config_t *)&rru_config_msg.msg[0])->prach_ConfigIndex[0]); - - configure_rru(ru->idx, (void*)&rru_config_msg.msg[0]); - - - fill_rf_config(ru,ru->rf_config_file); - init_frame_parms(&ru->frame_parms,1); - ru->frame_parms.nb_antennas_rx = ru->nb_rx; - phy_init_RU(ru); - - //if (ru->is_slave == 1) lte_sync_time_init(&ru->frame_parms); - - if (ru->rfdevice.is_init != 1){ - ret = openair0_device_load(&ru->rfdevice,&ru->openair0_cfg); - } - - - if (ru->rfdevice.trx_config_func) AssertFatal((ru->rfdevice.trx_config_func(&ru->rfdevice,&ru->openair0_cfg)==0), - "Failed to configure RF device for RU %d\n",ru->idx); - - - - - if (setup_RU_buffers(ru)!=0) { - printf("Exiting, cannot initialize RU Buffers\n"); - exit(-1); - } - - // send CONFIG_OK - - rru_config_msg.type = RRU_config_ok; - rru_config_msg.len = sizeof(RRU_CONFIG_msg_t); - LOG_I(PHY,"Sending CONFIG_OK to RAU %d\n", ru->idx); - - AssertFatal((ru->ifdevice.trx_ctlsend_func(&ru->ifdevice,&rru_config_msg,rru_config_msg.len)!=-1), - "RU %d failed send CONFIG_OK to RAU\n",ru->idx); - reset_proc(ru); - ru->state = RU_READY; - } else LOG_E(PHY,"Received RRU_config msg...Ignoring\n"); - - break; - - case RRU_config_ok: // RAU - if (ru->if_south == LOCAL_RF) LOG_E(PHY,"Received RRU_config_ok msg...Ignoring\n"); - else{ - - if (setup_RU_buffers(ru)!=0) { - printf("Exiting, cannot initialize RU Buffers\n"); - exit(-1); - } - - // Set state to RUN for Master RU, Others on SYNC - ru->state = (ru->is_slave == 1) ? RU_SYNC : RU_RUN ; - ru->in_synch = 0; - - - LOG_I(PHY, "Signaling main thread that RU %d (is_slave %d) is ready in state %s\n",ru->idx,ru->is_slave,ru_states[ru->state]); - pthread_mutex_lock(&RC.ru_mutex); - RC.ru_mask &= ~(1<idx); - pthread_cond_signal(&RC.ru_cond); - pthread_mutex_unlock(&RC.ru_mutex); - - wait_sync("ru_thread_control"); - - // send start - rru_config_msg.type = RRU_start; - rru_config_msg.len = sizeof(RRU_CONFIG_msg_t); // TODO: set to correct msg len - - - LOG_I(PHY,"Sending Start to RRU %d\n", ru->idx); - AssertFatal((ru->ifdevice.trx_ctlsend_func(&ru->ifdevice,&rru_config_msg,rru_config_msg.len)!=-1),"Failed to send msg to RU %d\n",ru->idx); - - - pthread_mutex_lock(&proc->mutex_ru); - proc->instance_cnt_ru = 1; - pthread_mutex_unlock(&proc->mutex_ru); - if (pthread_cond_signal(&proc->cond_ru_thread) != 0) { - LOG_E( PHY, "ERROR pthread_cond_signal for RU %d\n",ru->idx); - exit_fun( "ERROR pthread_cond_signal" ); - break; - } - } - break; - - case RRU_start: // RRU - if (ru->if_south == LOCAL_RF){ - LOG_I(PHY,"Start received from RAU\n"); - - if (ru->state == RU_READY){ - - LOG_I(PHY, "Signaling main thread that RU %d is ready\n",ru->idx); - pthread_mutex_lock(&RC.ru_mutex); - RC.ru_mask &= ~(1<idx); - pthread_cond_signal(&RC.ru_cond); - pthread_mutex_unlock(&RC.ru_mutex); - - wait_sync("ru_thread_control"); - - ru->state = (ru->is_slave == 1) ? RU_SYNC : RU_RUN ; - ru->cmd = EMPTY; - pthread_mutex_lock(&proc->mutex_ru); - proc->instance_cnt_ru = 1; - pthread_mutex_unlock(&proc->mutex_ru); - if (pthread_cond_signal(&proc->cond_ru_thread) != 0) { - LOG_E( PHY, "ERROR pthread_cond_signal for RU %d\n",ru->idx); - exit_fun( "ERROR pthread_cond_signal" ); - break; - } - } - else LOG_E(PHY,"RRU not ready, cannot start\n"); - - } else LOG_E(PHY,"Received RRU_start msg...Ignoring\n"); - - - break; - - case RRU_sync_ok: //RAU - if (ru->if_south == LOCAL_RF) LOG_E(PHY,"Received RRU_config_ok msg...Ignoring\n"); - else{ - if (ru->is_slave == 1){ - LOG_I(PHY,"Received RRU_sync_ok from RRU %d\n",ru->idx); - // Just change the state of the RRU to unblock ru_thread() - ru->state = RU_RUN; - }else LOG_E(PHY,"Received RRU_sync_ok from a master RRU...Ignoring\n"); - } - break; - case RRU_frame_resynch: //RRU - if (ru->if_south != LOCAL_RF) LOG_E(PHY,"Received RRU frame resynch message, should not happen in RAU\n"); - else { - LOG_I(PHY,"Received RRU_frame_resynch command\n"); - ru->cmd = RU_FRAME_RESYNCH; - ru->cmdval = ((uint16_t*)&rru_config_msg.msg[0])[0]; - LOG_I(PHY,"Received Frame Resynch messaage with value %d\n",ru->cmdval); - } - break; - - case RRU_stop: // RRU - if (ru->if_south == LOCAL_RF){ - LOG_I(PHY,"Stop received from RAU\n"); - - if (ru->state == RU_RUN || ru->state == RU_ERROR){ - - LOG_I(PHY,"Stopping RRU\n"); - ru->state = RU_READY; - // TODO: stop ru_thread - }else{ - LOG_I(PHY,"RRU not running, can't stop\n"); - } - }else LOG_E(PHY,"Received RRU_stop msg...Ignoring\n"); - - break; - - default: - if (ru->if_south != LOCAL_RF){ - if (ru->state == RU_IDLE){ - // Keep sending TICK - send_tick(ru); - } - } - - break; - } // switch - } //else - - - }//while - return(NULL); -} static void* ru_thread( void* param ) { From a0e193c5e8473314495502d7c852eb3d4be24594 Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Sun, 27 May 2018 05:27:58 +0200 Subject: [PATCH 86/88] fixing conflicts --- targets/RT/USER/lte-ru.c | 253 --------------------------------------- 1 file changed, 253 deletions(-) diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index 300ba3414a..c9d13a8960 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -1574,265 +1574,12 @@ 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; - cpu_set_t cpuset; - CPU_ZERO(&cpuset); - - - thread_top_init("ru_thread_tx",1,400000,500000,500000); - - //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"); - - 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; - - - 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); - - // do OFDM if needed - if ((ru->fh_north_asynch_in == NULL) && (ru->feptx_ofdm)) ru->feptx_ofdm(ru); - 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"); - - 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; -} -static void* ru_thread( void* param ) { - - - RU_t *ru = (RU_t*)param; - RU_proc_t *proc = &ru->proc; - LTE_DL_FRAME_PARMS *fp = &ru->frame_parms; - int subframe =9; - int frame =1023; - int resynch_done = 0; - PHY_VARS_eNB **eNB_list = ru->eNB_list; - PHY_VARS_eNB *eNB=eNB_list[0]; - eNB_proc_t *eNBproc = &eNB->proc; - int ret; - - // set default return value - thread_top_init("ru_thread",0,870000,1000000,1000000); - - LOG_I(PHY,"Starting RU %d (%s,%s),\n",ru->idx,eNB_functions[ru->function],eNB_timing[ru->if_timing]); - - if (ru->has_ctrl_prt == 0){ - // There is no control port: start everything here - - if (ru->if_south == LOCAL_RF){ - fill_rf_config(ru,ru->rf_config_file); - init_frame_parms(&ru->frame_parms,1); - ru->frame_parms.nb_antennas_rx = ru->nb_rx; - 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); - } - pthread_mutex_lock(&RC.ru_mutex); - RC.ru_mask &= ~(1<idx); - pthread_cond_signal(&RC.ru_cond); - pthread_mutex_unlock(&RC.ru_mutex); - } - pthread_mutex_lock(&RC.ru_mutex); - RC.ru_mask &= ~(1<idx); - pthread_cond_signal(&RC.ru_cond); - pthread_mutex_unlock(&RC.ru_mutex); - - ru->state = RU_RUN; - - } - - - while (!oai_exit) { - - if (ru->if_south != LOCAL_RF && ru->is_slave==1) ru->wait_cnt = 100; - else ru->wait_cnt = 0; - - // wait to be woken up - if (ru->function!=eNodeB_3GPP && ru->has_ctrl_prt == 1) { - if (wait_on_condition(&ru->proc.mutex_ru,&ru->proc.cond_ru_thread,&ru->proc.instance_cnt_ru,"ru_thread")<0) break; - } - else wait_sync("ru_thread"); - - if (ru->is_slave == 0) AssertFatal(ru->state == RU_RUN,"ru-%d state = %s != RU_RUN\n",ru->idx,ru_states[ru->state]); - else if (ru->is_slave == 1) AssertFatal(ru->state == RU_SYNC || ru->state == RU_RUN,"ru %d state = %s != RU_SYNC or RU_RUN\n",ru->idx,ru_states[ru->state]); - // 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_D(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 - - LOG_D(PHY,"Locking asynch mutex\n"); - 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_D(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 == 1) && (ru->if_south == LOCAL_RF)) do_ru_synch(ru); - - - LOG_D(PHY,"Starting steady-state operation\n"); - // This is a forever while loop, it loops over subframes which are scheduled by incoming samples from HW devices - while (ru->state == RU_RUN) { - - // 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) { - subframe=0; - frame++; - frame&=1023; - } else { - subframe++; - } - - - // synchronization on input FH interface, acquire signals/data and block - if (ru->stop_rf && ru->cmd == STOP_RU) { - ru->stop_rf(ru); - ru->state = RU_IDLE; - ru->cmd = EMPTY; - LOG_I(PHY,"RU %d rf device stopped\n",ru->idx); - break; - } - else if (ru->cmd == STOP_RU) { - ru->state = RU_IDLE; - ru->cmd = EMPTY; - LOG_I(PHY,"RU %d stopped\n",ru->idx); - break; - } - if (oai_exit == 1) break; - - if (ru->fh_south_in && ru->state == RU_RUN ) ru->fh_south_in(ru,&frame,&subframe); - else AssertFatal(1==0, "No fronthaul interface at south port"); - - if (ru->wait_cnt > 0) { - - ru->wait_cnt--; - - - LOG_I(PHY,"RU thread %d, frame %d, subframe %d, wait_cnt %d \n",ru->idx, frame, subframe, ru->wait_cnt); - - if (ru->if_south!=LOCAL_RF && ru->wait_cnt <=20 && subframe == 5 && frame != RC.ru[0]->proc.frame_rx && resynch_done == 0) { - // Send RRU_frame adjust - RRU_CONFIG_msg_t rru_config_msg; - rru_config_msg.type = RRU_frame_resynch; - rru_config_msg.len = sizeof(RRU_CONFIG_msg_t); // TODO: set to correct msg len - ((uint16_t*)&rru_config_msg.msg[0])[0] = RC.ru[0]->proc.frame_rx; - ru->cmd=WAIT_RESYNCH; - LOG_D(PHY,"Sending Frame Resynch %d to RRU %d\n", RC.ru[0]->proc.frame_rx,ru->idx); - AssertFatal((ru->ifdevice.trx_ctlsend_func(&ru->ifdevice,&rru_config_msg,rru_config_msg.len)!=-1),"Failed to send msg to RAU\n"); - resynch_done=1; - } - wakeup_eNBs(ru); - } - - else { - - LOG_D(PHY,"RU thread %d, frame %d, subframe %d \n", - ru->idx,frame,subframe); - - if ((ru->do_prach>0) && (is_prach_subframe(fp, proc->frame_rx, proc->subframe_rx)==1)) { - LOG_D(PHY,"Waking up prach for %d.%d\n",proc->frame_rx,proc->subframe_rx); - wakeup_prach_ru(ru); - } -#ifdef Rel14 - else if ((ru->do_prach>0) && (is_prach_subframe(fp, proc->frame_rx, proc->subframe_rx)>1)) { - wakeup_prach_ru_br(ru); - } -#endif - - // adjust for timing offset between RU - if (ru->idx!=0) proc->frame_tx = (proc->frame_tx+proc->frame_offset)&1023; - - // At this point, all information for subframe has been received on FH interface - // If this proc is to provide synchronization, do so - wakeup_slaves(proc); - - // do RX front-end processing (frequency-shift, dft) if needed - if (ru->feprx) ru->feprx(ru); - - // 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); - } - } - - } // while !oai_exit - - - printf( "Exiting ru_thread \n"); - - if (ru->stop_rf != NULL) { - if (ru->stop_rf(ru) != 0) - LOG_E(HW,"Could not stop the RF device\n"); - else LOG_I(PHY,"RU %d rf device stopped\n",ru->idx); - } - - return NULL; - -} // This thread run the initial synchronization like a UE From d9568d2c06293da2d5a01133e4f500269706e8b3 Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Mon, 28 May 2018 15:31:14 +0200 Subject: [PATCH 87/88] bugfix after merge --- .../PHY/LTE_TRANSPORT/dlsch_demodulation.c | 2 +- targets/RT/USER/lte-ru.c | 252 +++++++++++++----- 2 files changed, 182 insertions(+), 72 deletions(-) diff --git a/openair1/PHY/LTE_TRANSPORT/dlsch_demodulation.c b/openair1/PHY/LTE_TRANSPORT/dlsch_demodulation.c index b37af234a9..be5d496561 100644 --- a/openair1/PHY/LTE_TRANSPORT/dlsch_demodulation.c +++ b/openair1/PHY/LTE_TRANSPORT/dlsch_demodulation.c @@ -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/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index 4ee349ec6b..4b5887e0a1 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -1220,7 +1220,7 @@ int wakeup_synch(RU_t *ru){ wait.tv_nsec=5000000L; // wake up synch thread - // lock the synch mutex and make sure the thread is ready + // lock the synch mutex and make sure the thread is readif (pthread_mutex_timedlock(&ru->proc.mutex_synch,&wait) != 0) { if (pthread_mutex_timedlock(&ru->proc.mutex_synch,&wait) != 0) { LOG_E( PHY, "[RU] ERROR pthread_mutex_lock for RU synch thread (IC %d)\n", ru->proc.instance_cnt_synch ); exit_fun( "error locking mutex_synch" ); @@ -1393,7 +1393,7 @@ void wakeup_eNBs(RU_t *ru) { pthread_mutex_unlock(&proc->mutex_RU); LOG_D(PHY,"wakeup eNB top for for subframe %d\n", ru->proc.subframe_rx); if (ru->wait_cnt == 0) - 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 { // multiple eNB case for later @@ -1416,6 +1416,7 @@ void wakeup_eNBs(RU_t *ru) { } } + } } static inline int wakeup_prach_ru(RU_t *ru) { @@ -1716,19 +1717,21 @@ static void* ru_thread( void* param ) { RU_t *ru = (RU_t*)param; RU_proc_t *proc = &ru->proc; LTE_DL_FRAME_PARMS *fp = &ru->frame_parms; - int ret; int subframe =9; - int frame =1023; + int frame =1023; + int resynch_done = 0; + PHY_VARS_eNB **eNB_list = ru->eNB_list; + PHY_VARS_eNB *eNB=eNB_list[0]; + eNB_proc_t *eNBproc = &eNB->proc; + int ret; cpu_set_t cpuset; CPU_ZERO(&cpuset); - // set default return value + ru_thread_status = 0; - - // set default return value - thread_top_init("ru_thread",1,400000,500000,500000); + thread_top_init("ru_thread",0,870000,1000000,1000000); //CPU_SET(1, &cpuset); //pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); @@ -1745,86 +1748,194 @@ static void* ru_thread( void* param ) { printf("Exiting, cannot initialize RU Buffers\n"); exit(-1); } + + LOG_I(PHY, "Signaling main thread that RU %d is ready\n",ru->idx); + pthread_mutex_lock(&RC.ru_mutex); + RC.ru_mask &= ~(1<idx); + pthread_cond_signal(&RC.ru_cond); + pthread_mutex_unlock(&RC.ru_mutex); + + ru->state = RU_RUN; + } - 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); - } + else if (ru->has_ctrl_prt == 0){ + // There is no control port: start everything here + + if (ru->if_south == LOCAL_RF){ + fill_rf_config(ru,ru->rf_config_file); + init_frame_parms(&ru->frame_parms,1); + ru->frame_parms.nb_antennas_rx = ru->nb_rx; + 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); + } + pthread_mutex_lock(&RC.ru_mutex); + RC.ru_mask &= ~(1<idx); + pthread_cond_signal(&RC.ru_cond); + pthread_mutex_unlock(&RC.ru_mutex); + } + pthread_mutex_lock(&RC.ru_mutex); + RC.ru_mask &= ~(1<idx); + pthread_cond_signal(&RC.ru_cond); + pthread_mutex_unlock(&RC.ru_mutex); + + ru->state = RU_RUN; + + } - LOG_I(PHY, "Signaling main thread that RU %d is ready\n",ru->idx); - pthread_mutex_lock(&RC.ru_mutex); - RC.ru_mask &= ~(1<idx); - pthread_cond_signal(&RC.ru_cond); - pthread_mutex_unlock(&RC.ru_mutex); - - 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"); + while (!oai_exit) { + + if (ru->if_south != LOCAL_RF && ru->is_slave==1) ru->wait_cnt = 100; + else ru->wait_cnt = 0; + + // wait to be woken up + if (ru->function!=eNodeB_3GPP && ru->has_ctrl_prt == 1) { + if (wait_on_condition(&ru->proc.mutex_ru,&ru->proc.cond_ru_thread,&ru->proc.instance_cnt_ru,"ru_thread")<0) break; + } + else wait_sync("ru_thread"); + + if (ru->is_slave == 0) AssertFatal(ru->state == RU_RUN,"ru-%d state = %s != RU_RUN\n",ru->idx,ru_states[ru->state]); + else if (ru->is_slave == 1) AssertFatal(ru->state == RU_SYNC || ru->state == RU_RUN,"ru %d state = %s != RU_SYNC or RU_RUN\n",ru->idx,ru_states[ru->state]); + // 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_D(PHY,"RU %d no rf device\n",ru->idx); - thread_top_init("ru_thread_tx",1,400000,500000,500000); + // if an asnych_rxtx thread exists + // wakeup the thread because the devices are ready at this point - //CPU_SET(5, &cpuset); - //pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &cpuset); - //wait_sync("ru_thread_tx"); + LOG_D(PHY,"Locking asynch mutex\n"); + 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_D(PHY,"RU %d no asynch_south interface\n",ru->idx); - 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 this is a slave RRU, try to synchronize on the DL frequency + if ((ru->is_slave == 1) && (ru->if_south == LOCAL_RF)) do_ru_synch(ru); - // do RX front-end processing (frequency-shift, dft) if needed - if (ru->feprx) ru->feprx(ru); + LOG_D(PHY,"Starting steady-state operation\n"); + // This is a forever while loop, it loops over subframes which are scheduled by incoming samples from HW devices + while (ru->state == RU_RUN) { - // At this point, all information for subframe has been received on FH interface - // If this proc is to provide synchronization, do so - wakeup_slaves(proc); + // 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) { + subframe=0; + frame++; + frame&=1023; + } else { + subframe++; + } - // wakeup all eNB processes waiting for this RU - if (ru->num_eNB>0) wakeup_eNBs(ru); - - 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 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); + + // synchronization on input FH interface, acquire signals/data and block + if (ru->stop_rf && ru->cmd == STOP_RU) { + ru->stop_rf(ru); + ru->state = RU_IDLE; + ru->cmd = EMPTY; + LOG_I(PHY,"RU %d rf device stopped\n",ru->idx); + break; + } + else if (ru->cmd == STOP_RU) { + ru->state = RU_IDLE; + ru->cmd = EMPTY; + LOG_I(PHY,"RU %d stopped\n",ru->idx); + break; + } + if (oai_exit == 1) break; + + if (ru->fh_south_in && ru->state == RU_RUN ) ru->fh_south_in(ru,&frame,&subframe); + else AssertFatal(1==0, "No fronthaul interface at south port"); + + if (ru->wait_cnt > 0) { + + ru->wait_cnt--; + + + LOG_I(PHY,"RU thread %d, frame %d, subframe %d, wait_cnt %d \n",ru->idx, frame, subframe, ru->wait_cnt); + + if (ru->if_south!=LOCAL_RF && ru->wait_cnt <=20 && subframe == 5 && frame != RC.ru[0]->proc.frame_rx && resynch_done == 0) { + // Send RRU_frame adjust + RRU_CONFIG_msg_t rru_config_msg; + rru_config_msg.type = RRU_frame_resynch; + rru_config_msg.len = sizeof(RRU_CONFIG_msg_t); // TODO: set to correct msg len + ((uint16_t*)&rru_config_msg.msg[0])[0] = RC.ru[0]->proc.frame_rx; + ru->cmd=WAIT_RESYNCH; + LOG_D(PHY,"Sending Frame Resynch %d to RRU %d\n", RC.ru[0]->proc.frame_rx,ru->idx); + AssertFatal((ru->ifdevice.trx_ctlsend_func(&ru->ifdevice,&rru_config_msg,rru_config_msg.len)!=-1),"Failed to send msg to RAU\n"); + resynch_done=1; + } + wakeup_eNBs(ru); + } + + else { + + LOG_D(PHY,"RU thread %d, frame %d, subframe %d \n", + ru->idx,frame,subframe); + + if ((ru->do_prach>0) && (is_prach_subframe(fp, proc->frame_rx, proc->subframe_rx)==1)) { + LOG_D(PHY,"Waking up prach for %d.%d\n",proc->frame_rx,proc->subframe_rx); + wakeup_prach_ru(ru); + } +#ifdef Rel14 + else if ((ru->do_prach>0) && (is_prach_subframe(fp, proc->frame_rx, proc->subframe_rx)>1)) { + wakeup_prach_ru_br(ru); + } +#endif + + // adjust for timing offset between RU + if (ru->idx!=0) proc->frame_tx = (proc->frame_tx+proc->frame_offset)&1023; + + // At this point, all information for subframe has been received on FH interface + // If this proc is to provide synchronization, do so + wakeup_slaves(proc); + + // do RX front-end processing (frequency-shift, dft) if needed + if (ru->feprx) ru->feprx(ru); + + // 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"); + + 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 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); + } + } } } - } - + } // while !oai_exit + printf( "Exiting ru_thread \n"); @@ -1834,8 +1945,7 @@ static void* ru_thread( void* param ) { else LOG_I(PHY,"RU %d rf device stopped\n",ru->idx); } - ru_thread_status = 0; - return &ru_thread_status; + return NULL; } From 6bbe8337356b2769aa380b550150ac6382029e8e Mon Sep 17 00:00:00 2001 From: Raymond Knopp Date: Wed, 30 May 2018 16:40:27 +0200 Subject: [PATCH 88/88] fixing for testing --- targets/RT/USER/lte-ru.c | 41 ++++++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/targets/RT/USER/lte-ru.c b/targets/RT/USER/lte-ru.c index 4b5887e0a1..bae4b41b1c 100644 --- a/targets/RT/USER/lte-ru.c +++ b/targets/RT/USER/lte-ru.c @@ -456,6 +456,7 @@ void fh_if4p5_south_in(RU_t *ru,int *frame,int *subframe) { int f,sf; + LOG_I(PHY,"rx_fh_if4p5 CALLED\n"); uint16_t packet_type; uint32_t symbol_number=0; uint32_t symbol_mask_full; @@ -466,7 +467,8 @@ void fh_if4p5_south_in(RU_t *ru,int *frame,int *subframe) { symbol_mask_full = (1<symbols_per_tti)-1; AssertFatal(proc->symbol_mask[*subframe]==0,"rx_fh_if4p5: proc->symbol_mask[%d] = %x\n",*subframe,proc->symbol_mask[*subframe]); - do { + do { + LOG_I(PHY,"rx_fh_if4p5: Calling recv_IF4p5\n"); recv_IF4p5(ru, &f, &sf, &packet_type, &symbol_number); if (oai_exit == 1 || ru->cmd== STOP_RU) break; if (packet_type == IF4p5_PULFFT) proc->symbol_mask[sf] = proc->symbol_mask[sf] | (1<symbol_mask[*subframe]); + LOG_I(PHY,"rx_fh_if4p5: subframe %d symbol mask %x\n",*subframe,proc->symbol_mask[*subframe]); } while(proc->symbol_mask[*subframe] != symbol_mask_full); //caculate timestamp_rx, timestamp_tx based on frame and subframe @@ -1337,7 +1339,7 @@ void wakeup_eNBs(RU_t *ru) { eNB_proc_t *proc = &eNB->proc; struct timespec t; - LOG_D(PHY,"wakeup_eNBs (num %d) for RU %d (state %s)ru->eNB_top:%p\n",ru->num_eNB,ru->idx, ru_states[ru->state],ru->eNB_top); + LOG_I(PHY,"wakeup_eNBs (num %d) for RU %d (state %s)ru->eNB_top:%p\n",ru->num_eNB,ru->idx, ru_states[ru->state],ru->eNB_top); if (ru->num_eNB==1 && ru->eNB_top!=0 && get_nprocs() <= 4) { @@ -1347,7 +1349,7 @@ void wakeup_eNBs(RU_t *ru) { sprintf(string,"Incoming RU %d",ru->idx); pthread_mutex_lock(&proc->mutex_RU); - LOG_D(PHY,"Frame %d, Subframe %d: RU %d done (wait_cnt %d),RU_mask[%d] %x\n", + LOG_I(PHY,"wakeup_eNBs: Frame %d, Subframe %d: RU %d done (wait_cnt %d),RU_mask[%d] %x\n", ru->proc.frame_rx,ru->proc.subframe_rx,ru->idx,ru->wait_cnt,ru->proc.subframe_rx,proc->RU_mask[ru->proc.subframe_rx]); clock_gettime(CLOCK_MONOTONIC,&ru->proc.t[ru->proc.subframe_rx]); @@ -1395,9 +1397,9 @@ void wakeup_eNBs(RU_t *ru) { if (ru->wait_cnt == 0) ru->eNB_top(eNB_list[0],ru->proc.frame_rx,ru->proc.subframe_rx,string, ru); } - else { // multiple eNB case for later + else { - LOG_D(PHY,"ru->num_eNB:%d\n", ru->num_eNB); + LOG_I(PHY,"ru->num_eNB:%d\n", ru->num_eNB); for (i=0;inum_eNB;i++) @@ -1679,9 +1681,10 @@ static void* ru_thread_tx( void* param ) { if (oai_exit) break; - LOG_D(PHY,"ru_thread_tx: Waiting for TX processing\n"); + LOG_I(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"); + LOG_I(PHY,"ru_thread_tx: Woken from condition\n"); if (oai_exit) break; // do TX front-end processing if needed (precoding and/or IDFTs) @@ -1760,7 +1763,7 @@ static void* ru_thread( void* param ) { } else if (ru->has_ctrl_prt == 0){ // There is no control port: start everything here - + LOG_I(PHY, "RU %d has not ctrl port\n",ru->idx); if (ru->if_south == LOCAL_RF){ fill_rf_config(ru,ru->rf_config_file); init_frame_parms(&ru->frame_parms,1); @@ -1863,9 +1866,26 @@ static void* ru_thread( void* param ) { } if (oai_exit == 1) break; + LOG_I(PHY,"RU thread %d, frame %d, subframe %d \n",ru->idx, frame, subframe); if (ru->fh_south_in && ru->state == RU_RUN ) ru->fh_south_in(ru,&frame,&subframe); else AssertFatal(1==0, "No fronthaul interface at south port"); + + if (ru->stop_rf && ru->cmd == STOP_RU) { + ru->stop_rf(ru); + ru->state = RU_IDLE; + ru->cmd = EMPTY; + LOG_I(PHY,"RU %d rf device stopped\n",ru->idx); + break; + } + else if (ru->cmd == STOP_RU) { + ru->state = RU_IDLE; + ru->cmd = EMPTY; + LOG_I(PHY,"RU %d stopped\n",ru->idx); + break; + } + if (oai_exit == 1) break; + if (ru->wait_cnt > 0) { ru->wait_cnt--; @@ -1887,9 +1907,10 @@ static void* ru_thread( void* param ) { wakeup_eNBs(ru); } + else { - LOG_D(PHY,"RU thread %d, frame %d, subframe %d \n", + LOG_I(PHY,"RU thread %d, frame %d, subframe %d \n", ru->idx,frame,subframe); if ((ru->do_prach>0) && (is_prach_subframe(fp, proc->frame_rx, proc->subframe_rx)==1)) { @@ -1927,7 +1948,7 @@ static void* ru_thread( void* param ) { 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); - + LOG_I(PHY,"Calling fh_north_out\n"); if (ru->fh_north_out) ru->fh_north_out(ru); } }